Skip to content

Commit 219c86a

Browse files
committed
style: prepare imports for ESM compatibility
1 parent da74a2e commit 219c86a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+208
-208
lines changed

src/defaultClasses.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Types } from 'mongoose';
2-
import { modelOptions } from './modelOptions';
3-
import type { AnyParamConstructor, DocumentType, RefType } from './types';
2+
import { modelOptions } from './modelOptions.js';
3+
import type { AnyParamConstructor, DocumentType, RefType } from './types.js';
44

55
@modelOptions({ schemaOptions: { timestamps: true } })
66
/**

src/globalOptions.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Severity } from './internal/constants';
2-
import { globalOptions } from './internal/data';
3-
import { ExpectedTypeError } from './internal/errors';
4-
import { assertion, isNullOrUndefined } from './internal/utils';
5-
import { logger } from './logSettings';
6-
import type { IGlobalOptions } from './types';
1+
import { Severity } from './internal/constants.js';
2+
import { globalOptions } from './internal/data.js';
3+
import { ExpectedTypeError } from './internal/errors.js';
4+
import { assertion, isNullOrUndefined } from './internal/utils.js';
5+
import { logger } from './logSettings.js';
6+
import type { IGlobalOptions } from './types.js';
77

88
/**
99
* Set Typegoose's global Options

src/hooks.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// disable "no-unused" for this file, to keep hooks consistent (it has to be an inline-comment, because of an problem with eslint)
22
/* eslint-disable @typescript-eslint/no-unused-vars */
33
import type { Aggregate, Query } from 'mongoose';
4-
import { DecoratorKeys } from './internal/constants';
5-
import { ExpectedTypeError } from './internal/errors';
6-
import { assertion, getName, isNullOrUndefined } from './internal/utils';
7-
import { logger } from './logSettings';
8-
import { mongoose } from './typegoose';
9-
import type { DocumentType, EmptyVoidFn, HookOptionsEither, IHooksArray } from './types';
4+
import { DecoratorKeys } from './internal/constants.js';
5+
import { ExpectedTypeError } from './internal/errors.js';
6+
import { assertion, getName, isNullOrUndefined } from './internal/utils.js';
7+
import { logger } from './logSettings.js';
8+
import { mongoose } from './typegoose.js';
9+
import type { DocumentType, EmptyVoidFn, HookOptionsEither, IHooksArray } from './types.js';
1010

1111
type NumberOrDocumentOrDocumentArray<T> = number | DocumentType<T> | DocumentType<T>[];
1212

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import mongoose from 'mongoose';
2-
import { DecoratorKeys } from './internal/constants';
3-
import { getName } from './internal/utils';
4-
import { logger } from './logSettings';
5-
import type { BeAnObject, IIndexArray, IndexOptions } from './types';
2+
import { DecoratorKeys } from './internal/constants.js';
3+
import { getName } from './internal/utils.js';
4+
import { logger } from './logSettings.js';
5+
import type { BeAnObject, IIndexArray, IndexOptions } from './types.js';
66

77
/**
88
* Defines a index for this Class which will then be added to the Schema.

src/internal/data.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Model, SchemaDefinition } from 'mongoose';
2-
import type { IGlobalOptions } from '../types';
3-
import { Severity } from './constants';
2+
import type { IGlobalOptions } from '../types.js';
3+
import { Severity } from './constants.js';
44

55
/** Schema Map */
66
export const schemas: Map<string, SchemaDefinition> = new Map();

src/internal/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { allVirtualoptions, toStringNoFail } from './utils';
1+
import { allVirtualoptions, toStringNoFail } from './utils.js';
22

33
// Note: dont forget to use "toStringNoFail" on values that are "unknown" or "any"
44

src/internal/processProp.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { logger } from '../logSettings';
2-
import { buildSchema, mongoose, Passthrough } from '../typegoose';
1+
import { logger } from '../logSettings.js';
2+
import { buildSchema, mongoose, Passthrough } from '../typegoose.js';
33
import type {
44
AnyParamConstructor,
55
DecoratedPropertyMetadata,
@@ -8,9 +8,9 @@ import type {
88
MappedInnerOuterOptions,
99
NestedDiscriminatorsMap,
1010
VirtualPopulateMap,
11-
} from '../types';
12-
import { DecoratorKeys, PropType } from './constants';
13-
import { schemas } from './data';
11+
} from '../types.js';
12+
import { DecoratorKeys, PropType } from './constants.js';
13+
import { schemas } from './data.js';
1414
import {
1515
CannotBeSymbolError,
1616
InvalidEnumTypeError,
@@ -23,8 +23,8 @@ import {
2323
RefOptionIsUndefinedError,
2424
SelfContainingClassError,
2525
StringLengthExpectedError,
26-
} from './errors';
27-
import * as utils from './utils';
26+
} from './errors.js';
27+
import * as utils from './utils.js';
2828

2929
/**
3030
* Function that is the actual processing of the prop's (used for caching)

src/internal/schema.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as mongoose from 'mongoose';
2-
import { logger } from '../logSettings';
3-
import { buildSchema } from '../typegoose';
2+
import { logger } from '../logSettings.js';
3+
import { buildSchema } from '../typegoose.js';
44
import type {
55
AnyParamConstructor,
66
DecoratedPropertyMetadataMap,
@@ -11,12 +11,12 @@ import type {
1111
NestedDiscriminatorsMap,
1212
QueryMethodMap,
1313
VirtualPopulateMap,
14-
} from '../types';
15-
import { DecoratorKeys } from './constants';
16-
import { constructors, schemas } from './data';
17-
import { NoDiscriminatorFunctionError, PathNotInSchemaError } from './errors';
18-
import { processProp } from './processProp';
19-
import { assertion, assertionIsClass, assignGlobalModelOptions, getName, isNullOrUndefined, mergeSchemaOptions } from './utils';
14+
} from '../types.js';
15+
import { DecoratorKeys } from './constants.js';
16+
import { constructors, schemas } from './data.js';
17+
import { NoDiscriminatorFunctionError, PathNotInSchemaError } from './errors.js';
18+
import { processProp } from './processProp.js';
19+
import { assertion, assertionIsClass, assignGlobalModelOptions, getName, isNullOrUndefined, mergeSchemaOptions } from './utils.js';
2020

2121
/**
2222
* Internal Schema Builder for Classes

src/internal/utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { intersection, mergeWith, omit } from 'lodash';
22
import * as mongoose from 'mongoose';
3-
import { logger } from '../logSettings';
3+
import { logger } from '../logSettings.js';
44
import type {
55
AnyParamConstructor,
66
DecoratedPropertyMetadataMap,
@@ -16,17 +16,17 @@ import type {
1616
PropOptionsForNumber,
1717
PropOptionsForString,
1818
VirtualOptions,
19-
} from '../types';
20-
import { DecoratorKeys, Severity, PropType } from './constants';
21-
import { constructors, globalOptions, schemas } from './data';
19+
} from '../types.js';
20+
import { DecoratorKeys, Severity, PropType } from './constants.js';
21+
import { constructors, globalOptions, schemas } from './data.js';
2222
import {
2323
AssertionFallbackError,
2424
InvalidOptionsConstructorError,
2525
InvalidPropTypeError,
2626
NoValidClassError,
2727
ResolveTypegooseNameError,
2828
StringLengthExpectedError,
29-
} from './errors';
29+
} from './errors.js';
3030

3131
/**
3232
* Returns true, if the type is included in mongoose.Schema.Types

src/modelOptions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { DecoratorKeys } from './internal/constants';
2-
import { assignGlobalModelOptions, assignMetadata } from './internal/utils';
3-
import type { IModelOptions } from './types';
1+
import { DecoratorKeys } from './internal/constants.js';
2+
import { assignGlobalModelOptions, assignMetadata } from './internal/utils.js';
3+
import type { IModelOptions } from './types.js';
44

55
/**
66
* Define Options for the Class

0 commit comments

Comments
 (0)