@wisemen/nestjs-typeorm 0.0.31 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/module.d.ts +5 -1
- package/dist/extensions/module.js +29 -16
- package/dist/extensions/module.js.map +1 -1
- package/dist/extensions/tests/sql/datasource.d.ts +1 -1
- package/dist/extensions/tests/sql/datasource.js +3 -3
- package/dist/extensions/tests/sql/datasource.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import { TypeOrmModule as TM } from '@nestjs/typeorm';
|
|
2
|
+
import { TypeOrmModule as TM, TypeOrmModuleAsyncOptions } from '@nestjs/typeorm';
|
|
3
3
|
import { EntityClassOrSchema } from '@nestjs/typeorm/dist/interfaces/entity-class-or-schema.type.js';
|
|
4
4
|
import { DataSource, DataSourceOptions } from 'typeorm';
|
|
5
|
+
export interface NestjsTypeOrmModuleAsyncOptions extends TypeOrmModuleAsyncOptions {
|
|
6
|
+
customDataTypes?: string[];
|
|
7
|
+
}
|
|
5
8
|
export declare class TypeOrmModule extends TM {
|
|
6
9
|
static forFeature(entities?: EntityClassOrSchema[], dataSource?: DataSource | DataSourceOptions | string): DynamicModule;
|
|
10
|
+
static forRootAsync(options: NestjsTypeOrmModuleAsyncOptions): DynamicModule;
|
|
7
11
|
}
|
|
@@ -1,28 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var TypeOrmModule_1;
|
|
8
|
-
import { Module } from '@nestjs/common';
|
|
9
|
-
import { TypeOrmModule as TM } from '@nestjs/typeorm';
|
|
1
|
+
import assert from 'assert';
|
|
2
|
+
import { getDataSourceToken, TypeOrmModule as TM } from '@nestjs/typeorm';
|
|
10
3
|
import { DEFAULT_DATA_SOURCE_NAME } from '@nestjs/typeorm/dist/typeorm.constants.js';
|
|
11
4
|
import { EntitiesMetadataStorage } from '@nestjs/typeorm/dist/entities-metadata.storage.js';
|
|
12
5
|
import { createTypeOrmProviders } from './create-providers.js';
|
|
13
|
-
|
|
6
|
+
export class TypeOrmModule extends TM {
|
|
14
7
|
static forFeature(entities = [], dataSource = DEFAULT_DATA_SOURCE_NAME) {
|
|
15
8
|
const providers = createTypeOrmProviders(entities, dataSource);
|
|
16
9
|
EntitiesMetadataStorage.addEntitiesByDataSource(dataSource, [...entities]);
|
|
17
10
|
return {
|
|
18
|
-
module:
|
|
11
|
+
module: TypeOrmModule,
|
|
19
12
|
providers: providers,
|
|
20
13
|
exports: providers
|
|
21
14
|
};
|
|
22
15
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
static forRootAsync(options) {
|
|
17
|
+
const module = super.forRootAsync(options);
|
|
18
|
+
const dataSourceToken = getDataSourceToken(options);
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
20
|
+
// @ts-expect-error
|
|
21
|
+
// eslint-disable-next-line @stylistic/max-len
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
23
|
+
const dataSourceProvider = module.imports?.[0].providers?.find(provider => 'provide' in provider
|
|
24
|
+
&& 'useFactory' in provider
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
26
|
+
&& provider.provide === dataSourceToken);
|
|
27
|
+
assert(dataSourceProvider !== undefined, 'unable to find datasource provider');
|
|
28
|
+
const originalFactory = dataSourceProvider.useFactory;
|
|
29
|
+
dataSourceProvider.useFactory = async (dataSourceOptions) => {
|
|
30
|
+
const modifiedOptions = { ...dataSourceOptions };
|
|
31
|
+
const dataTypes = (options.customDataTypes ?? []);
|
|
32
|
+
modifiedOptions.driver ??= await import('pg');
|
|
33
|
+
// eslint-disable-next-line @stylistic/max-len
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
35
|
+
modifiedOptions.driver.supportedDataTypes.push(...dataTypes);
|
|
36
|
+
return await originalFactory(dataSourceOptions);
|
|
37
|
+
};
|
|
38
|
+
return module;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
28
41
|
//# sourceMappingURL=module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../lib/extensions/module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../lib/extensions/module.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,OAAO,EAAE,kBAAkB,EAAE,aAAa,IAAI,EAAE,EAAmD,MAAM,iBAAiB,CAAA;AAG1H,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAA;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAA;AAE3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAQ9D,MAAM,OAAO,aAAc,SAAQ,EAAE;IACnC,MAAM,CAAC,UAAU,CACf,WAAkC,EAAE,EACpC,aAGa,wBAAwB;QAErC,MAAM,SAAS,GAAG,sBAAsB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;QAE9D,uBAAuB,CAAC,uBAAuB,CAAC,UAAU,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAA;QAE1E,OAAO;YACL,MAAM,EAAE,aAAa;YACrB,SAAS,EAAE,SAAS;YACpB,OAAO,EAAE,SAAS;SACnB,CAAA;IAC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
|
-
import { SnakeNamingStrategy } from
|
|
3
|
-
import { sslHelper } from
|
|
1
|
+
import { DataSource } from 'typeorm';
|
|
2
|
+
import { SnakeNamingStrategy } from '../../../naming/snake-case.naming-strategy.js';
|
|
3
|
+
import { sslHelper } from '../../../helpers/ssl.js';
|
|
4
4
|
export const dataSource = new DataSource({
|
|
5
5
|
name: 'default',
|
|
6
6
|
type: 'postgres',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datasource.js","sourceRoot":"","sources":["../../../../lib/extensions/tests/sql/datasource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"datasource.js","sourceRoot":"","sources":["../../../../lib/extensions/tests/sql/datasource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAA;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAEnD,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC;IACvC,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,UAAU;IAChB,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;IAC7B,GAAG,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IACxC,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;IAClB,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,KAAK;IAClB,aAAa,EAAE,IAAI;IACnB,QAAQ,EAAE,CAAC,qBAAqB,CAAC;IACjC,cAAc,EAAE,IAAI,mBAAmB,EAAE;CAC1C,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wisemen/nestjs-typeorm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.33",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"url": "git@github.com:wisemen-digital/node-core.git"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
+
"pg": "8.16.3",
|
|
33
34
|
"@nestjs/common": "^11.1.6",
|
|
34
35
|
"@nestjs/config": "^4.0.2",
|
|
35
36
|
"@nestjs/typeorm": "^11.0.0",
|