@rxap/plugin-nestjs 20.1.5-dev.1 → 20.2.0-dev.10

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/GUIDES.md +1 -1
  3. package/README.md +16 -1
  4. package/generators.json +10 -0
  5. package/package.json +11 -11
  6. package/src/generators/dynamic-configuration-module/__snapshots__/generator.spec.ts.snap +194 -0
  7. package/src/generators/dynamic-configuration-module/coerce-dynamic-module-options-token.d.ts +2 -0
  8. package/src/generators/dynamic-configuration-module/coerce-dynamic-module-options-token.js +17 -0
  9. package/src/generators/dynamic-configuration-module/coerce-dynamic-module-options-token.js.map +1 -0
  10. package/src/generators/dynamic-configuration-module/coerce-dynamic-module.d.ts +2 -0
  11. package/src/generators/dynamic-configuration-module/coerce-dynamic-module.js +100 -0
  12. package/src/generators/dynamic-configuration-module/coerce-dynamic-module.js.map +1 -0
  13. package/src/generators/dynamic-configuration-module/coerce-options-factory.d.ts +2 -0
  14. package/src/generators/dynamic-configuration-module/coerce-options-factory.js +62 -0
  15. package/src/generators/dynamic-configuration-module/coerce-options-factory.js.map +1 -0
  16. package/src/generators/dynamic-configuration-module/coerce-options-interface.d.ts +2 -0
  17. package/src/generators/dynamic-configuration-module/coerce-options-interface.js +20 -0
  18. package/src/generators/dynamic-configuration-module/coerce-options-interface.js.map +1 -0
  19. package/src/generators/dynamic-configuration-module/coerce-validation-schema-function.d.ts +2 -0
  20. package/src/generators/dynamic-configuration-module/coerce-validation-schema-function.js +49 -0
  21. package/src/generators/dynamic-configuration-module/coerce-validation-schema-function.js.map +1 -0
  22. package/src/generators/dynamic-configuration-module/find-module-file.d.ts +2 -0
  23. package/src/generators/dynamic-configuration-module/find-module-file.js +10 -0
  24. package/src/generators/dynamic-configuration-module/find-module-file.js.map +1 -0
  25. package/src/generators/dynamic-configuration-module/generator.d.ts +4 -0
  26. package/src/generators/dynamic-configuration-module/generator.js +42 -0
  27. package/src/generators/dynamic-configuration-module/generator.js.map +1 -0
  28. package/src/generators/dynamic-configuration-module/index.d.ts +2 -0
  29. package/src/generators/dynamic-configuration-module/index.js +7 -0
  30. package/src/generators/dynamic-configuration-module/index.js.map +1 -0
  31. package/src/generators/dynamic-configuration-module/schema.d.ts +7 -0
  32. package/src/generators/dynamic-configuration-module/schema.json +24 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,56 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [20.2.0-dev.10](https://gitlab.com/rxap/packages/compare/@rxap/plugin-nestjs@20.2.0-dev.9...@rxap/plugin-nestjs@20.2.0-dev.10) (2025-10-07)
7
+
8
+ **Note:** Version bump only for package @rxap/plugin-nestjs
9
+
10
+ # [20.2.0-dev.9](https://gitlab.com/rxap/packages/compare/@rxap/plugin-nestjs@20.2.0-dev.8...@rxap/plugin-nestjs@20.2.0-dev.9) (2025-10-07)
11
+
12
+ **Note:** Version bump only for package @rxap/plugin-nestjs
13
+
14
+ # [20.2.0-dev.8](https://gitlab.com/rxap/packages/compare/@rxap/plugin-nestjs@20.2.0-dev.7...@rxap/plugin-nestjs@20.2.0-dev.8) (2025-10-06)
15
+
16
+ **Note:** Version bump only for package @rxap/plugin-nestjs
17
+
18
+ # [20.2.0-dev.7](https://gitlab.com/rxap/packages/compare/@rxap/plugin-nestjs@20.2.0-dev.6...@rxap/plugin-nestjs@20.2.0-dev.7) (2025-09-18)
19
+
20
+ **Note:** Version bump only for package @rxap/plugin-nestjs
21
+
22
+ # [20.2.0-dev.6](https://gitlab.com/rxap/packages/compare/@rxap/plugin-nestjs@20.2.0-dev.5...@rxap/plugin-nestjs@20.2.0-dev.6) (2025-09-15)
23
+
24
+ **Note:** Version bump only for package @rxap/plugin-nestjs
25
+
26
+ # [20.2.0-dev.5](https://gitlab.com/rxap/packages/compare/@rxap/plugin-nestjs@20.2.0-dev.4...@rxap/plugin-nestjs@20.2.0-dev.5) (2025-09-10)
27
+
28
+ **Note:** Version bump only for package @rxap/plugin-nestjs
29
+
30
+ # [20.2.0-dev.4](https://gitlab.com/rxap/packages/compare/@rxap/plugin-nestjs@20.2.0-dev.3...@rxap/plugin-nestjs@20.2.0-dev.4) (2025-09-10)
31
+
32
+ **Note:** Version bump only for package @rxap/plugin-nestjs
33
+
34
+ # [20.2.0-dev.3](https://gitlab.com/rxap/packages/compare/@rxap/plugin-nestjs@20.2.0-dev.2...@rxap/plugin-nestjs@20.2.0-dev.3) (2025-09-10)
35
+
36
+ **Note:** Version bump only for package @rxap/plugin-nestjs
37
+
38
+ # [20.2.0-dev.2](https://gitlab.com/rxap/packages/compare/@rxap/plugin-nestjs@20.2.0-dev.1...@rxap/plugin-nestjs@20.2.0-dev.2) (2025-09-01)
39
+
40
+ ### Features
41
+
42
+ - **nestjs:** add schematic for dynamic configuration module generator ([a96504c](https://gitlab.com/rxap/packages/commit/a96504c67b95cddf7858d3a3dc6d9007f063d56d))
43
+
44
+ # [20.2.0-dev.1](https://gitlab.com/rxap/packages/compare/@rxap/plugin-nestjs@20.2.0-dev.0...@rxap/plugin-nestjs@20.2.0-dev.1) (2025-09-01)
45
+
46
+ ### Bug Fixes
47
+
48
+ - update package groups ([a68f799](https://gitlab.com/rxap/packages/commit/a68f799f406a01e034439d036081fbb17b996f20))
49
+
50
+ # [20.2.0-dev.0](https://gitlab.com/rxap/packages/compare/@rxap/plugin-nestjs@20.1.5-dev.1...@rxap/plugin-nestjs@20.2.0-dev.0) (2025-09-01)
51
+
52
+ ### Features
53
+
54
+ - **nestjs:** add dynamic configuration module generator ([d8c9c0a](https://gitlab.com/rxap/packages/commit/d8c9c0a4bb83be1a80f54bfed9430e749caf6477))
55
+
6
56
  ## [20.1.5-dev.1](https://gitlab.com/rxap/packages/compare/@rxap/plugin-nestjs@20.1.5-dev.0...@rxap/plugin-nestjs@20.1.5-dev.1) (2025-07-07)
7
57
 
8
58
  **Note:** Version bump only for package @rxap/plugin-nestjs
package/GUIDES.md CHANGED
@@ -28,7 +28,7 @@ nx g @rxap/plugin-nestjs:init-application \
28
28
  Use the nx generate to create a new standalone microservice:
29
29
 
30
30
  ```bash
31
- nx g @rxap/plugin-nestjs:frontend-microservice --name $NAME
31
+ nx g @rxap/plugin-nestjs:microservice --name $NAME
32
32
  ```
33
33
 
34
34
  ## Frontend Microservice
package/README.md CHANGED
@@ -23,6 +23,7 @@ This npm package provides generators and executors for NestJS applications withi
23
23
  - [microservice](#microservice)
24
24
  - [feature-microservice](#feature-microservice)
25
25
  - [frontend-microservice](#frontend-microservice)
26
+ - [dynamic-configuration-module](#dynamic-configuration-module)
26
27
  - [Executors](#executors)
27
28
  - [package-json](#package-json)
28
29
  - [swagger-generate](#swagger-generate)
@@ -69,7 +70,7 @@ nx g @rxap/plugin-nestjs:init-application \
69
70
  Use the nx generate to create a new standalone microservice:
70
71
 
71
72
  ```bash
72
- nx g @rxap/plugin-nestjs:frontend-microservice --name $NAME
73
+ nx g @rxap/plugin-nestjs:microservice --name $NAME
73
74
  ```
74
75
 
75
76
  ## Frontend Microservice
@@ -329,6 +330,20 @@ jwt | boolean | false | Whether the application should use jwt
329
330
  openApi | boolean | false | Whether the application should use openApi as client
330
331
  apiConfigurationFile | string | | The api configuration file to use
331
332
  standalone | boolean | false | Whether the nest service should be standalone
333
+
334
+ ## dynamic-configuration-module
335
+ > Extends the module with the dynamic configuration module pattern
336
+
337
+ ```bash
338
+ nx g @rxap/plugin-nestjs:dynamic-configuration-module
339
+ ```
340
+
341
+ Option | Type | Default | Description
342
+ --- | --- | --- | ---
343
+ project | string | |
344
+ overwrite | boolean | |
345
+ name | string | | name of the module. defaults to the project name
346
+ isGlobal | boolean | true |
332
347
  # Executors
333
348
 
334
349
  ## package-json
package/generators.json CHANGED
@@ -64,6 +64,11 @@
64
64
  "factory": "./src/generators/frontend-microservice/generator",
65
65
  "schema": "./src/generators/frontend-microservice/schema.json",
66
66
  "description": "frontend-microservice generator"
67
+ },
68
+ "dynamic-configuration-module": {
69
+ "factory": "./src/generators/dynamic-configuration-module/generator",
70
+ "schema": "./src/generators/dynamic-configuration-module/schema.json",
71
+ "description": "Extends the module with the dynamic configuration module pattern"
67
72
  }
68
73
  },
69
74
  "schematics": {
@@ -131,6 +136,11 @@
131
136
  "factory": "./src/generators/frontend-microservice/index",
132
137
  "schema": "./src/generators/frontend-microservice/schema.json",
133
138
  "description": "frontend-microservice generator"
139
+ },
140
+ "dynamic-configuration-module": {
141
+ "factory": "./src/generators/dynamic-configuration-module/index",
142
+ "schema": "./src/generators/dynamic-configuration-module/schema.json",
143
+ "description": "Extends the module with the dynamic configuration module pattern"
134
144
  }
135
145
  }
136
146
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "20.1.5-dev.1",
2
+ "version": "20.2.0-dev.10",
3
3
  "name": "@rxap/plugin-nestjs",
4
4
  "description": "This npm package provides generators and executors for NestJS applications within an Nx workspace. It helps streamline the setup of NestJS projects with features like Swagger, Sentry, health indicators, and standardized configurations. It also includes executors for generating package.json files and Swagger documentation.\n",
5
5
  "license": "GPL-3.0-or-later",
@@ -7,15 +7,15 @@
7
7
  "@nx/devkit": "20.5.0",
8
8
  "@nx/js": "20.5.0",
9
9
  "@nx/nest": "20.5.0",
10
- "@rxap/node-utilities": "^1.3.11-dev.0",
11
- "@rxap/plugin-application": "^20.0.5-dev.0",
12
- "@rxap/plugin-library": "^20.2.2-dev.0",
13
- "@rxap/plugin-open-api": "^20.1.1-dev.1",
14
- "@rxap/plugin-utilities": "^20.0.5-dev.0",
15
- "@rxap/ts-morph": "^1.5.6-dev.0",
16
- "@rxap/utilities": "^16.4.5-dev.0",
17
- "@rxap/workspace-ts-morph": "^19.1.13-dev.0",
18
- "@rxap/workspace-utilities": "^19.8.1-dev.0",
10
+ "@rxap/node-utilities": "^1.3.11-dev.2",
11
+ "@rxap/plugin-application": "^20.0.5-dev.2",
12
+ "@rxap/plugin-library": "^20.2.2-dev.3",
13
+ "@rxap/plugin-open-api": "^20.1.1-dev.10",
14
+ "@rxap/plugin-utilities": "^20.0.5-dev.2",
15
+ "@rxap/ts-morph": "^1.6.0-dev.2",
16
+ "@rxap/utilities": "^16.5.0-dev.0",
17
+ "@rxap/workspace-ts-morph": "^19.1.13-dev.3",
18
+ "@rxap/workspace-utilities": "^19.8.1-dev.2",
19
19
  "colors": "1.4.0",
20
20
  "semver": "7.5.3",
21
21
  "ts-morph": "18.0.0",
@@ -55,7 +55,7 @@
55
55
  },
56
56
  "schematics": "./generators.json",
57
57
  "type": "commonjs",
58
- "gitHead": "ec4bbc38100b50557a75466d6a1006ee26ab8392",
58
+ "gitHead": "0a174cabe1803652482d395dbcef36a1db3c4d62",
59
59
  "exports": {
60
60
  "./package.json": "./package.json",
61
61
  ".": {
@@ -0,0 +1,194 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`dynamic-configuration-module should add global dynamic configuration module to the root module 1`] = `
4
+ "import { ConfigurableModuleBuilder, DynamicModule, Global, Module } from '@nestjs/common';
5
+ import { TestModuleOptions } from './test-module-options';
6
+ import { TEST_MODULE_OPTIONS } from './tokens';
7
+
8
+ export const {
9
+ ConfigurableModuleClass,
10
+ MODULE_OPTIONS_TOKEN,
11
+ OPTIONS_TYPE,
12
+ ASYNC_OPTIONS_TYPE,
13
+ } = new ConfigurableModuleBuilder<TestModuleOptions>()
14
+ .setExtras({ global: true })
15
+ .build();
16
+
17
+ @Module({
18
+ controllers: [],
19
+ providers: [],
20
+ exports: [],
21
+ })
22
+ @Global()
23
+ export class TestModule extends ConfigurableModuleClass {
24
+ static register(options: typeof OPTIONS_TYPE): DynamicModule {
25
+ return this.updateProviders(super.register(options));
26
+ }
27
+
28
+ static registerAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule {
29
+ return this.updateProviders(super.registerAsync(options));
30
+ }
31
+
32
+ private static updateProviders(module: DynamicModule) {
33
+ module.providers ??= [];
34
+ module.providers.push({
35
+ provide: TEST_MODULE_OPTIONS,
36
+ useExisting: MODULE_OPTIONS_TOKEN,
37
+ });
38
+ return module;
39
+ }
40
+ }
41
+ "
42
+ `;
43
+
44
+ exports[`dynamic-configuration-module should add global dynamic configuration module to the root module 2`] = `
45
+ "export interface TestModuleOptions {
46
+ disabled: boolean;
47
+ }
48
+ "
49
+ `;
50
+
51
+ exports[`dynamic-configuration-module should add global dynamic configuration module to the root module 3`] = `
52
+ "import { ConfigurableModuleOptionsFactory, Inject, Injectable, Logger } from '@nestjs/common';
53
+ import { ConfigService } from '@nestjs/config';
54
+ import { TestModuleOptions } from './test-module-options';
55
+
56
+ @Injectable()
57
+ export class TestModuleOptionsFactory implements ConfigurableModuleOptionsFactory<TestModuleOptions, 'create'> {
58
+ @Inject(ConfigService)
59
+ private readonly config!: ConfigService;
60
+ @Inject(Logger)
61
+ private readonly logger!: Logger;
62
+
63
+ async create(): Promise<TestModuleOptions> {
64
+ return { disabled: this.config.get('TEST_DISABLED', false) }
65
+ }
66
+ }
67
+ "
68
+ `;
69
+
70
+ exports[`dynamic-configuration-module should add global dynamic configuration module to the root module 4`] = `
71
+ "import { Environment } from '@rxap/nest-utilities';
72
+ import * as Joi from 'joi';
73
+ import { SchemaMap } from 'joi';
74
+ import { TestModuleOptions } from './test-module-options';
75
+
76
+ export function testValidationSchema(environment: Environment, defaults: Partial<Pick<TestModuleOptions, 'disabled'>> = {}) {
77
+ const schema: SchemaMap = {};
78
+ schema['TEST_DISABLED'] = Joi.boolean().default(defaults.disabled ?? false);
79
+ return schema
80
+ }
81
+ "
82
+ `;
83
+
84
+ exports[`dynamic-configuration-module should add global dynamic configuration module to the root module 5`] = `
85
+ "export const TEST_MODULE_OPTIONS = Symbol('TEST_MODULE_OPTIONS');
86
+ "
87
+ `;
88
+
89
+ exports[`dynamic-configuration-module should add global dynamic configuration module to the root module 6`] = `
90
+ "// region
91
+ export * from './lib/test.module';
92
+ export * from './lib/test-module-options.factory';
93
+ export * from './lib/test-module-options';
94
+ export * from './lib/test-validation-schema';
95
+ export * from './lib/tokens';
96
+ // endregion
97
+ "
98
+ `;
99
+
100
+ exports[`dynamic-configuration-module should add local dynamic configuration module to the root module 1`] = `
101
+ "import { ConfigurableModuleBuilder, Module } from '@nestjs/common';
102
+ import { TestModuleOptions } from './test-module-options';
103
+ import { TEST_MODULE_OPTIONS } from './tokens';
104
+
105
+ export const {
106
+ ConfigurableModuleClass,
107
+ MODULE_OPTIONS_TOKEN,
108
+ OPTIONS_TYPE,
109
+ ASYNC_OPTIONS_TYPE,
110
+ } = new ConfigurableModuleBuilder<TestModuleOptions>()
111
+ .setExtras({ global: false })
112
+ .build();
113
+
114
+ @Module({
115
+ controllers: [],
116
+ providers: [],
117
+ exports: [],
118
+ })
119
+ export class TestModule extends ConfigurableModuleClass {
120
+ static register(options: typeof OPTIONS_TYPE): DynamicModule {
121
+ return this.updateProviders(super.register(options));
122
+ }
123
+
124
+ static registerAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule {
125
+ return this.updateProviders(super.registerAsync(options));
126
+ }
127
+
128
+ private static updateProviders(module: DynamicModule) {
129
+ module.providers ??= [];
130
+ module.providers.push({
131
+ provide: TEST_MODULE_OPTIONS,
132
+ useExisting: MODULE_OPTIONS_TOKEN,
133
+ });
134
+ return module;
135
+ }
136
+ }
137
+ "
138
+ `;
139
+
140
+ exports[`dynamic-configuration-module should add local dynamic configuration module to the root module 2`] = `
141
+ "export interface TestModuleOptions {
142
+ disabled: boolean;
143
+ }
144
+ "
145
+ `;
146
+
147
+ exports[`dynamic-configuration-module should add local dynamic configuration module to the root module 3`] = `
148
+ "import { ConfigurableModuleOptionsFactory, Inject, Injectable, Logger } from '@nestjs/common';
149
+ import { ConfigService } from '@nestjs/config';
150
+ import { TestModuleOptions } from './test-module-options';
151
+
152
+ @Injectable()
153
+ export class TestModuleOptionsFactory implements ConfigurableModuleOptionsFactory<TestModuleOptions, 'create'> {
154
+ @Inject(ConfigService)
155
+ private readonly config!: ConfigService;
156
+ @Inject(Logger)
157
+ private readonly logger!: Logger;
158
+
159
+ async create(): Promise<TestModuleOptions> {
160
+ return { disabled: this.config.get('TEST_DISABLED', false) }
161
+ }
162
+ }
163
+ "
164
+ `;
165
+
166
+ exports[`dynamic-configuration-module should add local dynamic configuration module to the root module 4`] = `
167
+ "import { Environment } from '@rxap/nest-utilities';
168
+ import * as Joi from 'joi';
169
+ import { SchemaMap } from 'joi';
170
+ import { TestModuleOptions } from './test-module-options';
171
+
172
+ export function testValidationSchema(environment: Environment, defaults: Partial<Pick<TestModuleOptions, 'disabled'>> = {}) {
173
+ const schema: SchemaMap = {};
174
+ schema['TEST_DISABLED'] = Joi.boolean().default(defaults.disabled ?? false);
175
+ return schema
176
+ }
177
+ "
178
+ `;
179
+
180
+ exports[`dynamic-configuration-module should add local dynamic configuration module to the root module 5`] = `
181
+ "export const TEST_MODULE_OPTIONS = Symbol('TEST_MODULE_OPTIONS');
182
+ "
183
+ `;
184
+
185
+ exports[`dynamic-configuration-module should add local dynamic configuration module to the root module 6`] = `
186
+ "// region
187
+ export * from './lib/test.module';
188
+ export * from './lib/test-module-options.factory';
189
+ export * from './lib/test-module-options';
190
+ export * from './lib/test-validation-schema';
191
+ export * from './lib/tokens';
192
+ // endregion
193
+ "
194
+ `;
@@ -0,0 +1,2 @@
1
+ import { Project } from 'ts-morph';
2
+ export declare function coerceDynamicModuleOptionsToken(project: Project, moduleName: string): void;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.coerceDynamicModuleOptionsToken = coerceDynamicModuleOptionsToken;
4
+ const ts_morph_1 = require("@rxap/ts-morph");
5
+ const utilities_1 = require("@rxap/utilities");
6
+ const ts_morph_2 = require("ts-morph");
7
+ function coerceDynamicModuleOptionsToken(project, moduleName) {
8
+ const tokenName = (0, utilities_1.underscore)(`${moduleName}Options`).toUpperCase();
9
+ const sourceFile = (0, ts_morph_1.CoerceSourceFile)(project, 'tokens.ts');
10
+ (0, ts_morph_1.CoerceVariableDeclaration)(sourceFile, tokenName, {
11
+ initializer: `Symbol('${tokenName}')`,
12
+ }, {
13
+ declarationKind: ts_morph_2.VariableDeclarationKind.Const,
14
+ isExported: true,
15
+ });
16
+ }
17
+ //# sourceMappingURL=coerce-dynamic-module-options-token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-dynamic-module-options-token.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/nestjs/src/generators/dynamic-configuration-module/coerce-dynamic-module-options-token.ts"],"names":[],"mappings":";;AAUA,0EASC;AAnBD,6CAGwB;AACxB,+CAA6C;AAC7C,uCAGkB;AAElB,SAAgB,+BAA+B,CAAC,OAAgB,EAAE,UAAkB;IAClF,MAAM,SAAS,GAAG,IAAA,sBAAU,EAAC,GAAG,UAAU,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;IACnE,MAAM,UAAU,GAAG,IAAA,2BAAgB,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAC1D,IAAA,oCAAyB,EAAC,UAAU,EAAE,SAAS,EAAE;QAC/C,WAAW,EAAE,WAAW,SAAS,IAAI;KACtC,EAAE;QACD,eAAe,EAAE,kCAAuB,CAAC,KAAK;QAC9C,UAAU,EAAE,IAAI;KACjB,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { SourceFile } from 'ts-morph';
2
+ export declare function coerceDynamicModule(sourceFile: SourceFile, isGlobal?: boolean): import("ts-morph").ClassDeclaration;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.coerceDynamicModule = coerceDynamicModule;
4
+ const ts_morph_1 = require("@rxap/ts-morph");
5
+ const utilities_1 = require("@rxap/utilities");
6
+ const ts_morph_2 = require("ts-morph");
7
+ function coerceDynamicModule(sourceFile, isGlobal = true) {
8
+ const moduleClass = sourceFile.getClass(ts_morph_1.IsNestModuleClass);
9
+ if (!moduleClass) {
10
+ throw new Error('No nest module class found');
11
+ }
12
+ const optionsName = moduleClass.getName() + 'Options';
13
+ if (!sourceFile.getFullText().includes('new ConfigurableModuleBuilder')) {
14
+ sourceFile.insertStatements(sourceFile.getImportDeclarations().reverse()[0].getChildIndex() + 1, `export const {
15
+ ConfigurableModuleClass,
16
+ MODULE_OPTIONS_TOKEN,
17
+ OPTIONS_TYPE,
18
+ ASYNC_OPTIONS_TYPE,
19
+ } = new ConfigurableModuleBuilder<${optionsName}>()
20
+ .setExtras({ global: ${isGlobal ? 'true' : 'false'} })
21
+ .build();`);
22
+ (0, ts_morph_1.CoerceImports)(sourceFile, [
23
+ {
24
+ namedImports: ['ConfigurableModuleBuilder'],
25
+ moduleSpecifier: '@nestjs/common'
26
+ }
27
+ ]);
28
+ }
29
+ (0, ts_morph_1.CoerceImports)(sourceFile, [
30
+ {
31
+ namedImports: [optionsName],
32
+ moduleSpecifier: `./${(0, utilities_1.dasherize)(optionsName)}`
33
+ }
34
+ ]);
35
+ if (isGlobal) {
36
+ (0, ts_morph_1.CoerceDecorator)(moduleClass, 'Global', { arguments: [] });
37
+ (0, ts_morph_1.CoerceImports)(sourceFile, [
38
+ {
39
+ namedImports: ['Global', 'DynamicModule'],
40
+ moduleSpecifier: '@nestjs/common'
41
+ }
42
+ ]);
43
+ }
44
+ if (!moduleClass.getExtends()) {
45
+ moduleClass.setExtends('ConfigurableModuleClass');
46
+ }
47
+ (0, ts_morph_1.CoerceClassMethod)(moduleClass, 'register', {
48
+ isStatic: true,
49
+ parameters: [
50
+ {
51
+ name: 'options',
52
+ type: 'typeof OPTIONS_TYPE',
53
+ }
54
+ ],
55
+ returnType: 'DynamicModule',
56
+ statements: [
57
+ 'return this.updateProviders(super.register(options));'
58
+ ]
59
+ });
60
+ (0, ts_morph_1.CoerceClassMethod)(moduleClass, 'registerAsync', {
61
+ isStatic: true,
62
+ parameters: [
63
+ {
64
+ name: 'options',
65
+ type: 'typeof ASYNC_OPTIONS_TYPE',
66
+ }
67
+ ],
68
+ returnType: 'DynamicModule',
69
+ statements: [
70
+ 'return this.updateProviders(super.registerAsync(options));'
71
+ ]
72
+ });
73
+ const optionsToken = (0, utilities_1.underscore)(optionsName).toUpperCase();
74
+ (0, ts_morph_1.CoerceClassMethod)(moduleClass, 'updateProviders', {
75
+ scope: ts_morph_2.Scope.Private,
76
+ isStatic: true,
77
+ parameters: [
78
+ {
79
+ name: 'module',
80
+ type: 'DynamicModule',
81
+ }
82
+ ],
83
+ statements: [
84
+ `module.providers ??= [];
85
+ module.providers.push({
86
+ provide: ${optionsToken},
87
+ useExisting: MODULE_OPTIONS_TOKEN,
88
+ });
89
+ return module;`
90
+ ]
91
+ });
92
+ (0, ts_morph_1.CoerceImports)(sourceFile, [
93
+ {
94
+ namedImports: [optionsToken],
95
+ moduleSpecifier: `./tokens`
96
+ }
97
+ ]);
98
+ return moduleClass;
99
+ }
100
+ //# sourceMappingURL=coerce-dynamic-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-dynamic-module.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/nestjs/src/generators/dynamic-configuration-module/coerce-dynamic-module.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ import { Project } from 'ts-morph';
2
+ export declare function coerceOptionsFactory(project: Project, moduleName: string): void;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.coerceOptionsFactory = coerceOptionsFactory;
4
+ const ts_morph_1 = require("@rxap/ts-morph");
5
+ const utilities_1 = require("@rxap/utilities");
6
+ const ts_morph_2 = require("ts-morph");
7
+ function coerceOptionsFactory(project, moduleName) {
8
+ const optionsFactoryFileName = `${(0, utilities_1.dasherize)(moduleName)}-options.factory.ts`;
9
+ const sourceFile = (0, ts_morph_1.CoerceSourceFile)(project, optionsFactoryFileName);
10
+ const optionsFactoryClassName = `${moduleName}OptionsFactory`;
11
+ const optionsInterfaceName = `${moduleName}Options`;
12
+ const factoryClass = (0, ts_morph_1.CoerceClass)(sourceFile, optionsFactoryClassName, {
13
+ implements: [`ConfigurableModuleOptionsFactory<${optionsInterfaceName}, 'create'>`],
14
+ isExported: true,
15
+ decorators: [
16
+ {
17
+ name: 'Injectable',
18
+ arguments: []
19
+ }
20
+ ]
21
+ });
22
+ (0, ts_morph_1.CoerceImports)(sourceFile, [
23
+ {
24
+ namedImports: [optionsInterfaceName],
25
+ moduleSpecifier: `./${(0, utilities_1.dasherize)(moduleName)}-options`
26
+ },
27
+ {
28
+ namedImports: [
29
+ 'ConfigurableModuleOptionsFactory',
30
+ 'Inject',
31
+ 'Injectable',
32
+ 'Logger'
33
+ ],
34
+ moduleSpecifier: '@nestjs/common'
35
+ },
36
+ {
37
+ namedImports: [
38
+ 'ConfigService'
39
+ ],
40
+ moduleSpecifier: '@nestjs/config'
41
+ }
42
+ ]);
43
+ const disabledConfigName = (0, utilities_1.underscore)(moduleName.replace('Module', '') + 'Disabled').toUpperCase();
44
+ (0, ts_morph_1.CoerceDependencyInjection)(sourceFile, {
45
+ injectionToken: 'ConfigService',
46
+ parameterName: 'config',
47
+ scope: ts_morph_2.Scope.Private,
48
+ module: ts_morph_1.Module.NEST,
49
+ });
50
+ (0, ts_morph_1.CoerceDependencyInjection)(sourceFile, {
51
+ injectionToken: 'Logger',
52
+ parameterName: 'logger',
53
+ scope: ts_morph_2.Scope.Private,
54
+ module: ts_morph_1.Module.NEST,
55
+ });
56
+ (0, ts_morph_1.CoerceClassMethod)(factoryClass, 'create', {
57
+ returnType: `Promise<${optionsInterfaceName}>`,
58
+ isAsync: true,
59
+ statements: [`return { disabled: this.config.get('${disabledConfigName}', false) }`]
60
+ });
61
+ }
62
+ //# sourceMappingURL=coerce-options-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-options-factory.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/nestjs/src/generators/dynamic-configuration-module/coerce-options-factory.ts"],"names":[],"mappings":";;AAiBA,oDAyDC;AA1ED,6CAOwB;AACxB,+CAGyB;AACzB,uCAGkB;AAElB,SAAgB,oBAAoB,CAAC,OAAgB,EAAE,UAAkB;IAEvE,MAAM,sBAAsB,GAAG,GAAI,IAAA,qBAAS,EAAC,UAAU,CAAE,qBAAqB,CAAC;IAC/E,MAAM,UAAU,GAAG,IAAA,2BAAgB,EAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC;IACrE,MAAM,uBAAuB,GAAG,GAAI,UAAW,gBAAgB,CAAC;IAChE,MAAM,oBAAoB,GAAG,GAAI,UAAW,SAAS,CAAC;IACtD,MAAM,YAAY,GAAG,IAAA,sBAAW,EAAC,UAAU,EAAE,uBAAuB,EAAE;QACpE,UAAU,EAAE,CAAE,oCAAoC,oBAAoB,aAAa,CAAC;QACpF,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE;YACV;gBACE,IAAI,EAAE,YAAY;gBAClB,SAAS,EAAE,EAAE;aACd;SACF;KACF,CAAC,CAAC;IACH,IAAA,wBAAa,EAAC,UAAU,EAAE;QACxB;YACE,YAAY,EAAE,CAAC,oBAAoB,CAAC;YACpC,eAAe,EAAE,KAAK,IAAA,qBAAS,EAAC,UAAU,CAAC,UAAU;SACtD;QACD;YACE,YAAY,EAAE;gBACZ,kCAAkC;gBAClC,QAAQ;gBACR,YAAY;gBACZ,QAAQ;aACT;YACD,eAAe,EAAE,gBAAgB;SAClC;QACD;YACE,YAAY,EAAE;gBACZ,eAAe;aAChB;YACD,eAAe,EAAE,gBAAgB;SAClC;KACF,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAG,IAAA,sBAAU,EAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;IACnG,IAAA,oCAAyB,EAAC,UAAU,EAAE;QACpC,cAAc,EAAE,eAAe;QAC/B,aAAa,EAAE,QAAQ;QACvB,KAAK,EAAE,gBAAK,CAAC,OAAO;QACpB,MAAM,EAAE,iBAAM,CAAC,IAAI;KACpB,CAAC,CAAC;IACH,IAAA,oCAAyB,EAAC,UAAU,EAAE;QACpC,cAAc,EAAE,QAAQ;QACxB,aAAa,EAAE,QAAQ;QACvB,KAAK,EAAE,gBAAK,CAAC,OAAO;QACpB,MAAM,EAAE,iBAAM,CAAC,IAAI;KACpB,CAAC,CAAC;IACH,IAAA,4BAAiB,EAAC,YAAY,EAAE,QAAQ,EAAE;QACxC,UAAU,EAAE,WAAW,oBAAoB,GAAG;QAC9C,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,CAAE,uCAAuC,kBAAkB,aAAa,CAAC;KACtF,CAAC,CAAC;AAEL,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Project } from 'ts-morph';
2
+ export declare function coerceOptionsInterface(project: Project, moduleName: string): void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.coerceOptionsInterface = coerceOptionsInterface;
4
+ const utilities_1 = require("@rxap/utilities");
5
+ const ts_morph_1 = require("@rxap/ts-morph");
6
+ function coerceOptionsInterface(project, moduleName) {
7
+ const interfaceName = `${moduleName}Options`;
8
+ const interfaceFileName = `${(0, utilities_1.dasherize)(interfaceName)}.ts`;
9
+ const sourceFile = (0, ts_morph_1.CoerceSourceFile)(project, interfaceFileName);
10
+ (0, ts_morph_1.CoerceInterface)(sourceFile, interfaceName, {
11
+ isExported: true,
12
+ properties: [
13
+ {
14
+ name: 'disabled',
15
+ type: 'boolean',
16
+ }
17
+ ]
18
+ });
19
+ }
20
+ //# sourceMappingURL=coerce-options-interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-options-interface.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/nestjs/src/generators/dynamic-configuration-module/coerce-options-interface.ts"],"names":[],"mappings":";;AAOA,wDAaC;AAnBD,+CAA4C;AAC5C,6CAGwB;AAExB,SAAgB,sBAAsB,CAAC,OAAgB,EAAE,UAAkB;IACzE,MAAM,aAAa,GAAG,GAAI,UAAW,SAAS,CAAC;IAC/C,MAAM,iBAAiB,GAAG,GAAI,IAAA,qBAAS,EAAC,aAAa,CAAE,KAAK,CAAC;IAC7D,MAAM,UAAU,GAAG,IAAA,2BAAgB,EAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAChE,IAAA,0BAAe,EAAC,UAAU,EAAE,aAAa,EAAE;QACzC,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE;YACV;gBACE,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,SAAS;aAChB;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Project } from 'ts-morph';
2
+ export declare function coerceValidationSchemaFunction(project: Project, moduleName: string): void;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.coerceValidationSchemaFunction = coerceValidationSchemaFunction;
4
+ const ts_morph_1 = require("@rxap/ts-morph");
5
+ const utilities_1 = require("@rxap/utilities");
6
+ function coerceValidationSchemaFunction(project, moduleName) {
7
+ const name = moduleName.replace('Module', '') + 'ValidationSchema';
8
+ const fileName = (0, utilities_1.dasherize)(name) + '.ts';
9
+ const functionName = (0, utilities_1.camelize)(name);
10
+ const sourceFile = (0, ts_morph_1.CoerceSourceFile)(project, fileName);
11
+ (0, ts_morph_1.CoerceImports)(sourceFile, [
12
+ {
13
+ namedImports: ['Environment'],
14
+ moduleSpecifier: '@rxap/nest-utilities'
15
+ },
16
+ {
17
+ namedImports: ['SchemaMap'],
18
+ moduleSpecifier: 'joi'
19
+ },
20
+ {
21
+ namespaceImport: 'Joi',
22
+ moduleSpecifier: 'joi'
23
+ },
24
+ {
25
+ namedImports: [moduleName + 'Options'],
26
+ moduleSpecifier: `./${(0, utilities_1.dasherize)(moduleName)}-options`,
27
+ },
28
+ ]);
29
+ (0, ts_morph_1.CoerceFunction)(sourceFile, functionName, {
30
+ parameters: [
31
+ {
32
+ name: 'environment',
33
+ type: 'Environment',
34
+ },
35
+ {
36
+ name: 'defaults',
37
+ type: `Partial<Pick<${moduleName}Options, 'disabled'>>`,
38
+ initializer: '{}'
39
+ }
40
+ ],
41
+ isExported: true,
42
+ statements: [
43
+ 'const schema: SchemaMap = {};',
44
+ `schema['${(0, utilities_1.underscore)(moduleName.replace('Module', '')).toUpperCase()}_DISABLED'] = Joi.boolean().default(defaults.disabled ?? false);`,
45
+ 'return schema'
46
+ ]
47
+ });
48
+ }
49
+ //# sourceMappingURL=coerce-validation-schema-function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-validation-schema-function.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/nestjs/src/generators/dynamic-configuration-module/coerce-validation-schema-function.ts"],"names":[],"mappings":";;AAYA,wEA0CC;AAtDD,6CAIwB;AACxB,+CAIyB;AAGzB,SAAgB,8BAA8B,CAAC,OAAgB,EAAE,UAAkB;IACjF,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,kBAAkB,CAAC;IACnE,MAAM,QAAQ,GAAG,IAAA,qBAAS,EAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IACzC,MAAM,YAAY,GAAG,IAAA,oBAAQ,EAAC,IAAI,CAAC,CAAC;IACpC,MAAM,UAAU,GAAG,IAAA,2BAAgB,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACvD,IAAA,wBAAa,EAAC,UAAU,EAAE;QACxB;YACE,YAAY,EAAE,CAAC,aAAa,CAAC;YAC7B,eAAe,EAAE,sBAAsB;SACxC;QACD;YACE,YAAY,EAAE,CAAC,WAAW,CAAC;YAC3B,eAAe,EAAE,KAAK;SACvB;QACD;YACE,eAAe,EAAE,KAAK;YACtB,eAAe,EAAE,KAAK;SACvB;QACD;YACE,YAAY,EAAE,CAAC,UAAU,GAAG,SAAS,CAAC;YACtC,eAAe,EAAE,KAAK,IAAA,qBAAS,EAAC,UAAU,CAAC,UAAU;SACtD;KACF,CAAC,CAAC;IACH,IAAA,yBAAc,EAAC,UAAU,EAAE,YAAY,EAAE;QACvC,UAAU,EAAE;YACV;gBACE,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,aAAa;aACpB;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,gBAAgB,UAAU,uBAAuB;gBACvD,WAAW,EAAE,IAAI;aAClB;SACF;QACD,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE;YACV,+BAA+B;YAC/B,WAAW,IAAA,sBAAU,EAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,kEAAkE;YACvI,eAAe;SAChB;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Project } from 'ts-morph';
2
+ export declare function findModuleFile(project: Project, moduleName: string): import("ts-morph").SourceFile | null;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findModuleFile = findModuleFile;
4
+ const ts_morph_1 = require("@rxap/ts-morph");
5
+ const utilities_1 = require("@rxap/utilities");
6
+ function findModuleFile(project, moduleName) {
7
+ var _a;
8
+ return (_a = project.getSourceFile(file => (0, ts_morph_1.HasNestModuleClass)(file) && file.getClasses().some(c => { var _a; return (_a = c.getName()) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes((0, utilities_1.classify)(moduleName).toLowerCase()); }))) !== null && _a !== void 0 ? _a : null;
9
+ }
10
+ //# sourceMappingURL=find-module-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-module-file.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/nestjs/src/generators/dynamic-configuration-module/find-module-file.ts"],"names":[],"mappings":";;AAIA,wCAEC;AAND,6CAAoD;AACpD,+CAA2C;AAG3C,SAAgB,cAAc,CAAC,OAAgB,EAAE,UAAkB;;IACjE,OAAO,MAAA,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,IAAA,6BAAkB,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,WAAC,OAAA,MAAA,CAAC,CAAC,OAAO,EAAE,0CAAE,WAAW,GAAG,QAAQ,CAAC,IAAA,oBAAQ,EAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA,EAAA,CAAC,CAAC,mCAAI,IAAI,CAAC;AACjL,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { DynamicConfigurationModuleGeneratorSchema } from './schema';
3
+ export declare function dynamicConfigurationModuleGenerator(tree: Tree, options: DynamicConfigurationModuleGeneratorSchema): Promise<void>;
4
+ export default dynamicConfigurationModuleGenerator;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dynamicConfigurationModuleGenerator = dynamicConfigurationModuleGenerator;
4
+ const tslib_1 = require("tslib");
5
+ const ts_morph_1 = require("@rxap/ts-morph");
6
+ const workspace_ts_morph_1 = require("@rxap/workspace-ts-morph");
7
+ const workspace_utilities_1 = require("@rxap/workspace-utilities");
8
+ const path_1 = require("path");
9
+ const coerce_dynamic_module_1 = require("./coerce-dynamic-module");
10
+ const coerce_dynamic_module_options_token_1 = require("./coerce-dynamic-module-options-token");
11
+ const coerce_options_factory_1 = require("./coerce-options-factory");
12
+ const coerce_options_interface_1 = require("./coerce-options-interface");
13
+ const coerce_validation_schema_function_1 = require("./coerce-validation-schema-function");
14
+ const find_module_file_1 = require("./find-module-file");
15
+ const plugin_library_1 = require("@rxap/plugin-library");
16
+ function dynamicConfigurationModuleGenerator(tree, options) {
17
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
18
+ var _a;
19
+ const project = (0, ts_morph_1.CreateProject)();
20
+ const projectSourceRoot = (0, workspace_utilities_1.GetProjectSourceRoot)(tree, options.project);
21
+ const projectLibSourceRoot = (0, path_1.join)(projectSourceRoot, 'lib');
22
+ (0, workspace_ts_morph_1.AddDir)(tree, projectLibSourceRoot, project);
23
+ let moduleName = (_a = options.name) !== null && _a !== void 0 ? _a : options.project;
24
+ const moduleSourceFile = (0, find_module_file_1.findModuleFile)(project, moduleName);
25
+ if (!moduleSourceFile) {
26
+ throw new Error(`Could not find the module file of the project: ${options.project}`);
27
+ }
28
+ const moduleClass = (0, coerce_dynamic_module_1.coerceDynamicModule)(moduleSourceFile, options.isGlobal);
29
+ moduleName = moduleClass.getName();
30
+ (0, coerce_dynamic_module_options_token_1.coerceDynamicModuleOptionsToken)(project, moduleName);
31
+ (0, coerce_validation_schema_function_1.coerceValidationSchemaFunction)(project, moduleName);
32
+ (0, coerce_options_factory_1.coerceOptionsFactory)(project, moduleName);
33
+ (0, coerce_options_interface_1.coerceOptionsInterface)(project, moduleName);
34
+ (0, workspace_ts_morph_1.ApplyTsMorphProject)(tree, project, projectLibSourceRoot);
35
+ yield (0, plugin_library_1.LibraryIndexExportGenerator)(tree, {
36
+ project: options.project,
37
+ generateRootExport: true,
38
+ });
39
+ });
40
+ }
41
+ exports.default = dynamicConfigurationModuleGenerator;
42
+ //# sourceMappingURL=generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/nestjs/src/generators/dynamic-configuration-module/generator.ts"],"names":[],"mappings":";;AAiBA,kFA0BC;;AA1CD,6CAA+C;AAC/C,iEAGkC;AAClC,mEAAiE;AACjE,+BAA4B;AAC5B,mEAA8D;AAC9D,+FAAwF;AACxF,qEAAgE;AAChE,yEAAoE;AACpE,2FAAqF;AACrF,yDAAoD;AAEpD,yDAAiE;AAEjE,SAAsB,mCAAmC,CACvD,IAAU,EACV,OAAkD;;;QAElD,MAAM,OAAO,GAAG,IAAA,wBAAa,GAAE,CAAC;QAChC,MAAM,iBAAiB,GAAG,IAAA,0CAAoB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACtE,MAAM,oBAAoB,GAAG,IAAA,WAAI,EAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;QAC5D,IAAA,2BAAM,EAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAAC;QAC5C,IAAI,UAAU,GAAG,MAAA,OAAO,CAAC,IAAI,mCAAI,OAAO,CAAC,OAAO,CAAC;QACjD,MAAM,gBAAgB,GAAG,IAAA,iCAAc,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAC7D,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,kDAAmD,OAAO,CAAC,OAAQ,EAAE,CAAC,CAAC;QACzF,CAAC;QACD,MAAM,WAAW,GAAG,IAAA,2CAAmB,EAAC,gBAAgB,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC5E,UAAU,GAAG,WAAW,CAAC,OAAO,EAAG,CAAC;QACpC,IAAA,qEAA+B,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACrD,IAAA,kEAA8B,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACpD,IAAA,6CAAoB,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAC1C,IAAA,iDAAsB,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAE5C,IAAA,wCAAmB,EAAC,IAAI,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC;QAEzD,MAAM,IAAA,4CAA2B,EAAC,IAAI,EAAE;YACtC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,kBAAkB,EAAE,IAAI;SACzB,CAAC,CAAC;IACL,CAAC;CAAA;AAED,kBAAe,mCAAmC,CAAC"}
@@ -0,0 +1,2 @@
1
+ declare const schematic: (generatorOptions: import("./schema").DynamicConfigurationModuleGeneratorSchema) => (tree: any, context: any) => Promise<any>;
2
+ export default schematic;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const generator_1 = require("./generator");
5
+ const schematic = (0, devkit_1.convertNxGenerator)(generator_1.default);
6
+ exports.default = schematic;
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/nestjs/src/generators/dynamic-configuration-module/index.ts"],"names":[],"mappings":";;AAAA,uCAAgD;AAChD,2CAAoC;AAEpC,MAAM,SAAS,GAAG,IAAA,2BAAkB,EAAC,mBAAS,CAAC,CAAC;AAChD,kBAAe,SAAS,CAAC"}
@@ -0,0 +1,7 @@
1
+ export interface DynamicConfigurationModuleGeneratorSchema {
2
+ project: string;
3
+ overwrite?: boolean;
4
+ /** name of the module. defaults to the project name */
5
+ name?: string;
6
+ isGlobal?: boolean;
7
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "DynamicConfigurationModule",
4
+ "title": "",
5
+ "type": "object",
6
+ "properties": {
7
+ "project": {
8
+ "type": "string",
9
+ "description": ""
10
+ },
11
+ "overwrite": {
12
+ "type": "boolean"
13
+ },
14
+ "name": {
15
+ "type": "string",
16
+ "description": "name of the module. defaults to the project name"
17
+ },
18
+ "isGlobal": {
19
+ "type": "boolean",
20
+ "default": true
21
+ }
22
+ },
23
+ "required": ["project"]
24
+ }