@nx-ddd/core 0.0.0-PLACEHOLDER
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/README.md +11 -0
- package/di/create-injector.d.ts +4 -0
- package/di/create-injector.js +21 -0
- package/di/create-injector.js.map +1 -0
- package/di/definition-factory.d.ts +24 -0
- package/di/definition-factory.js +22 -0
- package/di/definition-factory.js.map +1 -0
- package/di/forward_ref.d.ts +49 -0
- package/di/forward_ref.js +57 -0
- package/di/forward_ref.js.map +1 -0
- package/di/index.d.ts +3 -0
- package/di/index.js +7 -0
- package/di/index.js.map +1 -0
- package/di/injectable.d.ts +7 -0
- package/di/injectable.js +34 -0
- package/di/injectable.js.map +1 -0
- package/di/injector.d.ts +3 -0
- package/di/injector.js +23 -0
- package/di/injector.js.map +1 -0
- package/di/interface/defs.d.ts +181 -0
- package/di/interface/defs.js +137 -0
- package/di/interface/defs.js.map +1 -0
- package/di/interface/provider.d.ts +324 -0
- package/di/interface/provider.js +10 -0
- package/di/interface/provider.js.map +1 -0
- package/di/interface/type.d.ts +3 -0
- package/di/interface/type.js +3 -0
- package/di/interface/type.js.map +1 -0
- package/di/provider-collection.d.ts +7 -0
- package/di/provider-collection.js +45 -0
- package/di/provider-collection.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.js +7 -0
- package/index.js.map +1 -0
- package/nx-module/index.d.ts +2 -0
- package/nx-module/index.js +6 -0
- package/nx-module/index.js.map +1 -0
- package/nx-module/nx-module-ref.d.ts +15 -0
- package/nx-module/nx-module-ref.js +27 -0
- package/nx-module/nx-module-ref.js.map +1 -0
- package/nx-module/nx-module.d.ts +6 -0
- package/nx-module/nx-module.js +16 -0
- package/nx-module/nx-module.js.map +1 -0
- package/package.json +12 -0
- package/test-bed/index.d.ts +10 -0
- package/test-bed/index.js +32 -0
- package/test-bed/index.js.map +1 -0
- package/testing/index.d.ts +20 -0
- package/testing/index.js +32 -0
- package/testing/index.js.map +1 -0
- package/util/array_utils.d.ts +1 -0
- package/util/array_utils.js +8 -0
- package/util/array_utils.js.map +1 -0
- package/util/empty.d.ts +2 -0
- package/util/empty.js +6 -0
- package/util/empty.js.map +1 -0
- package/util/property.d.ts +19 -0
- package/util/property.js +34 -0
- package/util/property.js.map +1 -0
- package/util/stringify.d.ts +17 -0
- package/util/stringify.js +49 -0
- package/util/stringify.js.map +1 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { Type } from "./type";
|
|
9
|
+
/**
|
|
10
|
+
* Configures the `Injector` to return a value for a token.
|
|
11
|
+
* Base for `ValueProvider` decorator.
|
|
12
|
+
*
|
|
13
|
+
* @publicApi
|
|
14
|
+
*/
|
|
15
|
+
export interface ValueSansProvider {
|
|
16
|
+
/**
|
|
17
|
+
* The value to inject.
|
|
18
|
+
*/
|
|
19
|
+
useValue: any;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Configures the `Injector` to return a value for a token.
|
|
23
|
+
* @see ["Dependency Injection Guide"](guide/dependency-injection).
|
|
24
|
+
*
|
|
25
|
+
* @usageNotes
|
|
26
|
+
*
|
|
27
|
+
* ### Example
|
|
28
|
+
*
|
|
29
|
+
* {@example core/di/ts/provider_spec.ts region='ValueProvider'}
|
|
30
|
+
*
|
|
31
|
+
* ### Multi-value example
|
|
32
|
+
*
|
|
33
|
+
* {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
|
|
34
|
+
*
|
|
35
|
+
* @publicApi
|
|
36
|
+
*/
|
|
37
|
+
export interface ValueProvider extends ValueSansProvider {
|
|
38
|
+
/**
|
|
39
|
+
* An injection token. Typically an instance of `Type` or `InjectionToken`, but can be `any`.
|
|
40
|
+
*/
|
|
41
|
+
provide: any;
|
|
42
|
+
/**
|
|
43
|
+
* When true, injector returns an array of instances. This is useful to allow multiple
|
|
44
|
+
* providers spread across many files to provide configuration information to a common token.
|
|
45
|
+
*/
|
|
46
|
+
multi?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Configures the `Injector` to return an instance of `useClass` for a token.
|
|
50
|
+
* Base for `StaticClassProvider` decorator.
|
|
51
|
+
*
|
|
52
|
+
* @publicApi
|
|
53
|
+
*/
|
|
54
|
+
export interface StaticClassSansProvider {
|
|
55
|
+
/**
|
|
56
|
+
* An optional class to instantiate for the `token`. By default, the `provide`
|
|
57
|
+
* class is instantiated.
|
|
58
|
+
*/
|
|
59
|
+
useClass: Type<any>;
|
|
60
|
+
/**
|
|
61
|
+
* A list of `token`s to be resolved by the injector. The list of values is then
|
|
62
|
+
* used as arguments to the `useClass` constructor.
|
|
63
|
+
*/
|
|
64
|
+
deps: any[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Configures the `Injector` to return an instance of `useClass` for a token.
|
|
68
|
+
* @see ["Dependency Injection Guide"](guide/dependency-injection).
|
|
69
|
+
*
|
|
70
|
+
* @usageNotes
|
|
71
|
+
*
|
|
72
|
+
* {@example core/di/ts/provider_spec.ts region='StaticClassProvider'}
|
|
73
|
+
*
|
|
74
|
+
* Note that following two providers are not equal:
|
|
75
|
+
*
|
|
76
|
+
* {@example core/di/ts/provider_spec.ts region='StaticClassProviderDifference'}
|
|
77
|
+
*
|
|
78
|
+
* ### Multi-value example
|
|
79
|
+
*
|
|
80
|
+
* {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
|
|
81
|
+
*
|
|
82
|
+
* @publicApi
|
|
83
|
+
*/
|
|
84
|
+
export interface StaticClassProvider extends StaticClassSansProvider {
|
|
85
|
+
/**
|
|
86
|
+
* An injection token. Typically an instance of `Type` or `InjectionToken`, but can be `any`.
|
|
87
|
+
*/
|
|
88
|
+
provide: any;
|
|
89
|
+
/**
|
|
90
|
+
* When true, injector returns an array of instances. This is useful to allow multiple
|
|
91
|
+
* providers spread across many files to provide configuration information to a common token.
|
|
92
|
+
*/
|
|
93
|
+
multi?: boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Configures the `Injector` to return an instance of a token.
|
|
97
|
+
*
|
|
98
|
+
* @see ["Dependency Injection Guide"](guide/dependency-injection).
|
|
99
|
+
*
|
|
100
|
+
* @usageNotes
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* @Injectable(SomeModule, {deps: []})
|
|
104
|
+
* class MyService {}
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @publicApi
|
|
108
|
+
*/
|
|
109
|
+
export interface ConstructorSansProvider {
|
|
110
|
+
/**
|
|
111
|
+
* A list of `token`s to be resolved by the injector.
|
|
112
|
+
*/
|
|
113
|
+
deps?: any[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Configures the `Injector` to return an instance of a token.
|
|
117
|
+
*
|
|
118
|
+
* @see ["Dependency Injection Guide"](guide/dependency-injection).
|
|
119
|
+
*
|
|
120
|
+
* @usageNotes
|
|
121
|
+
*
|
|
122
|
+
* {@example core/di/ts/provider_spec.ts region='ConstructorProvider'}
|
|
123
|
+
*
|
|
124
|
+
* ### Multi-value example
|
|
125
|
+
*
|
|
126
|
+
* {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
|
|
127
|
+
*
|
|
128
|
+
* @publicApi
|
|
129
|
+
*/
|
|
130
|
+
export interface ConstructorProvider extends ConstructorSansProvider {
|
|
131
|
+
/**
|
|
132
|
+
* An injection token. Typically an instance of `Type` or `InjectionToken`, but can be `any`.
|
|
133
|
+
*/
|
|
134
|
+
provide: Type<any>;
|
|
135
|
+
/**
|
|
136
|
+
* When true, injector returns an array of instances. This is useful to allow multiple
|
|
137
|
+
* providers spread across many files to provide configuration information to a common token.
|
|
138
|
+
*/
|
|
139
|
+
multi?: boolean;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Configures the `Injector` to return a value of another `useExisting` token.
|
|
143
|
+
*
|
|
144
|
+
* @see `ExistingProvider`
|
|
145
|
+
* @see ["Dependency Injection Guide"](guide/dependency-injection).
|
|
146
|
+
*
|
|
147
|
+
* @publicApi
|
|
148
|
+
*/
|
|
149
|
+
export interface ExistingSansProvider {
|
|
150
|
+
/**
|
|
151
|
+
* Existing `token` to return. (Equivalent to `injector.get(useExisting)`)
|
|
152
|
+
*/
|
|
153
|
+
useExisting: any;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Configures the `Injector` to return a value of another `useExisting` token.
|
|
157
|
+
*
|
|
158
|
+
* @see ["Dependency Injection Guide"](guide/dependency-injection).
|
|
159
|
+
*
|
|
160
|
+
* @usageNotes
|
|
161
|
+
*
|
|
162
|
+
* {@example core/di/ts/provider_spec.ts region='ExistingProvider'}
|
|
163
|
+
*
|
|
164
|
+
* ### Multi-value example
|
|
165
|
+
*
|
|
166
|
+
* {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
|
|
167
|
+
*
|
|
168
|
+
* @publicApi
|
|
169
|
+
*/
|
|
170
|
+
export interface ExistingProvider extends ExistingSansProvider {
|
|
171
|
+
/**
|
|
172
|
+
* An injection token. Typically an instance of `Type` or `InjectionToken`, but can be `any`.
|
|
173
|
+
*/
|
|
174
|
+
provide: any;
|
|
175
|
+
/**
|
|
176
|
+
* When true, injector returns an array of instances. This is useful to allow multiple
|
|
177
|
+
* providers spread across many files to provide configuration information to a common token.
|
|
178
|
+
*/
|
|
179
|
+
multi?: boolean;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Configures the `Injector` to return a value by invoking a `useFactory` function.
|
|
183
|
+
*
|
|
184
|
+
* @see `FactoryProvider`
|
|
185
|
+
* @see ["Dependency Injection Guide"](guide/dependency-injection).
|
|
186
|
+
*
|
|
187
|
+
* @publicApi
|
|
188
|
+
*/
|
|
189
|
+
export interface FactorySansProvider {
|
|
190
|
+
/**
|
|
191
|
+
* A function to invoke to create a value for this `token`. The function is invoked with
|
|
192
|
+
* resolved values of `token`s in the `deps` field.
|
|
193
|
+
*/
|
|
194
|
+
useFactory: Function;
|
|
195
|
+
/**
|
|
196
|
+
* A list of `token`s to be resolved by the injector. The list of values is then
|
|
197
|
+
* used as arguments to the `useFactory` function.
|
|
198
|
+
*/
|
|
199
|
+
deps?: any[];
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Configures the `Injector` to return a value by invoking a `useFactory` function.
|
|
203
|
+
* @see ["Dependency Injection Guide"](guide/dependency-injection).
|
|
204
|
+
*
|
|
205
|
+
* @usageNotes
|
|
206
|
+
*
|
|
207
|
+
* {@example core/di/ts/provider_spec.ts region='FactoryProvider'}
|
|
208
|
+
*
|
|
209
|
+
* Dependencies can also be marked as optional:
|
|
210
|
+
*
|
|
211
|
+
* {@example core/di/ts/provider_spec.ts region='FactoryProviderOptionalDeps'}
|
|
212
|
+
*
|
|
213
|
+
* ### Multi-value example
|
|
214
|
+
*
|
|
215
|
+
* {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
|
|
216
|
+
*
|
|
217
|
+
* @publicApi
|
|
218
|
+
*/
|
|
219
|
+
export interface FactoryProvider extends FactorySansProvider {
|
|
220
|
+
/**
|
|
221
|
+
* An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`).
|
|
222
|
+
*/
|
|
223
|
+
provide: any;
|
|
224
|
+
/**
|
|
225
|
+
* When true, injector returns an array of instances. This is useful to allow multiple
|
|
226
|
+
* providers spread across many files to provide configuration information to a common token.
|
|
227
|
+
*/
|
|
228
|
+
multi?: boolean;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Describes how an `Injector` should be configured as static (that is, without reflection).
|
|
232
|
+
* A static provider provides tokens to an injector for various types of dependencies.
|
|
233
|
+
*
|
|
234
|
+
* @see `Injector.create()`.
|
|
235
|
+
* @see ["Dependency Injection Guide"](guide/dependency-injection-providers).
|
|
236
|
+
*
|
|
237
|
+
* @publicApi
|
|
238
|
+
*/
|
|
239
|
+
export declare type StaticProvider = ValueProvider | ExistingProvider | StaticClassProvider | ConstructorProvider | FactoryProvider | any[];
|
|
240
|
+
/**
|
|
241
|
+
* Configures the `Injector` to return an instance of `Type` when `Type' is used as the token.
|
|
242
|
+
*
|
|
243
|
+
* Create an instance by invoking the `new` operator and supplying additional arguments.
|
|
244
|
+
* This form is a short form of `TypeProvider`;
|
|
245
|
+
*
|
|
246
|
+
* For more details, see the ["Dependency Injection Guide"](guide/dependency-injection).
|
|
247
|
+
*
|
|
248
|
+
* @usageNotes
|
|
249
|
+
*
|
|
250
|
+
* {@example core/di/ts/provider_spec.ts region='TypeProvider'}
|
|
251
|
+
*
|
|
252
|
+
* @publicApi
|
|
253
|
+
*/
|
|
254
|
+
export interface TypeProvider extends Type<any> {
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Configures the `Injector` to return a value by invoking a `useClass` function.
|
|
258
|
+
* Base for `ClassProvider` decorator.
|
|
259
|
+
*
|
|
260
|
+
* @see ["Dependency Injection Guide"](guide/dependency-injection).
|
|
261
|
+
*
|
|
262
|
+
* @publicApi
|
|
263
|
+
*/
|
|
264
|
+
export interface ClassSansProvider {
|
|
265
|
+
/**
|
|
266
|
+
* Class to instantiate for the `token`.
|
|
267
|
+
*/
|
|
268
|
+
useClass: Type<any>;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Configures the `Injector` to return an instance of `useClass` for a token.
|
|
272
|
+
* @see ["Dependency Injection Guide"](guide/dependency-injection).
|
|
273
|
+
*
|
|
274
|
+
* @usageNotes
|
|
275
|
+
*
|
|
276
|
+
* {@example core/di/ts/provider_spec.ts region='ClassProvider'}
|
|
277
|
+
*
|
|
278
|
+
* Note that following two providers are not equal:
|
|
279
|
+
*
|
|
280
|
+
* {@example core/di/ts/provider_spec.ts region='ClassProviderDifference'}
|
|
281
|
+
*
|
|
282
|
+
* ### Multi-value example
|
|
283
|
+
*
|
|
284
|
+
* {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
|
|
285
|
+
*
|
|
286
|
+
* @publicApi
|
|
287
|
+
*/
|
|
288
|
+
export interface ClassProvider extends ClassSansProvider {
|
|
289
|
+
/**
|
|
290
|
+
* An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`).
|
|
291
|
+
*/
|
|
292
|
+
provide: any;
|
|
293
|
+
/**
|
|
294
|
+
* When true, injector returns an array of instances. This is useful to allow multiple
|
|
295
|
+
* providers spread across many files to provide configuration information to a common token.
|
|
296
|
+
*/
|
|
297
|
+
multi?: boolean;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Describes how the `Injector` should be configured.
|
|
301
|
+
* @see ["Dependency Injection Guide"](guide/dependency-injection).
|
|
302
|
+
*
|
|
303
|
+
* @see `StaticProvider`
|
|
304
|
+
*
|
|
305
|
+
* @publicApi
|
|
306
|
+
*/
|
|
307
|
+
export declare type Provider = TypeProvider | ValueProvider | ClassProvider | ConstructorProvider | ExistingProvider | FactoryProvider | any[];
|
|
308
|
+
/**
|
|
309
|
+
* Describes a function that is used to process provider lists (such as provider
|
|
310
|
+
* overrides).
|
|
311
|
+
*/
|
|
312
|
+
export declare type ProcessProvidersFunction = (providers: Provider[]) => Provider[];
|
|
313
|
+
/**
|
|
314
|
+
* A wrapper around an NgModule that associates it with [providers](guide/glossary#provider
|
|
315
|
+
* "Definition"). Usage without a generic type is deprecated.
|
|
316
|
+
*
|
|
317
|
+
* @see [Deprecations](guide/deprecations#modulewithproviders-type-without-a-generic)
|
|
318
|
+
*
|
|
319
|
+
* @publicApi
|
|
320
|
+
*/
|
|
321
|
+
export interface ModuleWithProviders<T> {
|
|
322
|
+
nxModule: Type<T>;
|
|
323
|
+
providers?: Provider[];
|
|
324
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../../../../packages/@nx-ddd/core/src/di/interface/provider.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../../../../../packages/@nx-ddd/core/src/di/interface/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Type } from './interface/type';
|
|
2
|
+
import { InjectorTypeWithProviders } from './interface/defs';
|
|
3
|
+
import { ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, ModuleWithProviders, Provider, StaticClassProvider, TypeProvider, ValueProvider } from './interface/provider';
|
|
4
|
+
export declare type ImportProvidersSource = Type<unknown> | ModuleWithProviders<unknown> | Array<ImportProvidersSource>;
|
|
5
|
+
export declare type SingleProvider = TypeProvider | ValueProvider | ClassProvider | ConstructorProvider | ExistingProvider | FactoryProvider | StaticClassProvider;
|
|
6
|
+
export declare function internalImportProvidersFrom(...sources: ImportProvidersSource[]): SingleProvider[];
|
|
7
|
+
export declare function walkProviderTree(sources: (Type<unknown> | InjectorTypeWithProviders<unknown>)[], parents: Type<unknown>[], callback: (providers: Provider[]) => void, dedup?: Set<Type<unknown>>): void;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.walkProviderTree = exports.internalImportProvidersFrom = void 0;
|
|
4
|
+
const defs_1 = require("./interface/defs");
|
|
5
|
+
const forward_ref_1 = require("./forward_ref");
|
|
6
|
+
const array_utils_1 = require("../util/array_utils");
|
|
7
|
+
const definition_factory_1 = require("./definition-factory");
|
|
8
|
+
const empty_1 = require("../util/empty");
|
|
9
|
+
function internalImportProvidersFrom(...sources) {
|
|
10
|
+
const providersOut = [];
|
|
11
|
+
walkProviderTree(sources, [], (providers) => {
|
|
12
|
+
(0, array_utils_1.deepForEach)(providers, provider => providersOut.push(provider));
|
|
13
|
+
});
|
|
14
|
+
return providersOut;
|
|
15
|
+
}
|
|
16
|
+
exports.internalImportProvidersFrom = internalImportProvidersFrom;
|
|
17
|
+
function getNxModuleType(container) {
|
|
18
|
+
const isNxModuleType = (obj) => (0, defs_1.hasInjectaorDef)(obj);
|
|
19
|
+
return isNxModuleType(container) ? container : container.nxModule;
|
|
20
|
+
}
|
|
21
|
+
function walkProviderTree(sources, parents, callback, dedup = new Set()) {
|
|
22
|
+
(0, array_utils_1.deepForEach)(sources, container => {
|
|
23
|
+
var _a, _b, _c;
|
|
24
|
+
container = (0, forward_ref_1.resolveForwardRef)(container);
|
|
25
|
+
if (!container)
|
|
26
|
+
return;
|
|
27
|
+
const nxModuleType = getNxModuleType(container);
|
|
28
|
+
const injDef = (0, defs_1.getInjectorDef)(nxModuleType);
|
|
29
|
+
if (!injDef)
|
|
30
|
+
return;
|
|
31
|
+
if (!dedup.has(nxModuleType) && dedup.add(nxModuleType)) {
|
|
32
|
+
walkProviderTree((_a = injDef.imports) !== null && _a !== void 0 ? _a : [], parents, callback, dedup);
|
|
33
|
+
callback([
|
|
34
|
+
{ provide: nxModuleType, useFactory: (0, definition_factory_1.getFactoryDef)(nxModuleType) || (() => new nxModuleType()), deps: empty_1.EMPTY_ARRAY },
|
|
35
|
+
// { provide: INJECTOR_DEF_TYPES, useValue: nxModuleType, multi: true },
|
|
36
|
+
// { provide: ENVIRONMENT_INITIALIZER, useValue: () => inject(nxModuleType!), multi: true },
|
|
37
|
+
...((_b = injDef.providers) !== null && _b !== void 0 ? _b : []),
|
|
38
|
+
]);
|
|
39
|
+
}
|
|
40
|
+
const isInjectorTypeWithProviders = (container) => container !== nxModuleType;
|
|
41
|
+
isInjectorTypeWithProviders(container) && callback((_c = container.providers) !== null && _c !== void 0 ? _c : []);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
exports.walkProviderTree = walkProviderTree;
|
|
45
|
+
//# sourceMappingURL=provider-collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-collection.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/core/src/di/provider-collection.ts"],"names":[],"mappings":";;;AACA,2CAA8F;AAE9F,+CAAkD;AAClD,qDAAkD;AAClD,6DAAqD;AACrD,yCAA4C;AAc5C,SAAgB,2BAA2B,CAAC,GAAG,OAAgC;IAC7E,MAAM,YAAY,GAAqB,EAAE,CAAC;IAC1C,gBAAgB,CAAC,OAAgE,EAAE,EAAE,EAAE,CAAC,SAAgB,EAAE,EAAE;QAC1G,IAAA,yBAAW,EAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IACH,OAAO,YAAY,CAAC;AACtB,CAAC;AAND,kEAMC;AAED,SAAS,eAAe,CAAC,SAA6D;IACpF,MAAM,cAAc,GAAG,CAAC,GAAG,EAAwB,EAAE,CAAC,IAAA,sBAAe,EAAC,GAAG,CAAC,CAAC;IAC3E,OAAO,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC;AACpE,CAAC;AAED,SAAgB,gBAAgB,CAC9B,OAA+D,EAC/D,OAAwB,EACxB,QAAyC,EACzC,QAAQ,IAAI,GAAG,EAAiB;IAEhC,IAAA,yBAAW,EAAC,OAAO,EAAE,SAAS,CAAC,EAAE;;QAC/B,SAAS,GAAG,IAAA,+BAAiB,EAAC,SAAS,CAAC,CAAC;QACzC,IAAI,CAAC,SAAS;YAAE,OAAO;QAEvB,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,IAAA,qBAAc,EAAC,YAAY,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM;YAAE,OAAO;QAEpB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;YACvD,gBAAgB,CAAC,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;YACjE,QAAQ,CAAC;gBACP,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,IAAA,kCAAa,EAAC,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,YAAa,EAAE,CAAC,EAAE,IAAI,EAAE,mBAAW,EAAE;gBACpH,wEAAwE;gBACxE,4FAA4F;gBAC5F,GAAG,CAAC,MAAA,MAAM,CAAC,SAAS,mCAAI,EAAE,CAAC;aAC5B,CAAC,CAAC;SACJ;QAED,MAAM,2BAA2B,GAC/B,CAAC,SAAS,EAA+C,EAAE,CAAC,SAAS,KAAK,YAAY,CAAC;QAEzF,2BAA2B,CAAC,SAAS,CAAC,IAAI,QAAQ,CAAC,MAAA,SAAS,CAAC,SAAS,mCAAI,EAAE,CAAC,CAAC;IAChF,CAAC,CAAC,CAAC;AACL,CAAC;AA7BD,4CA6BC"}
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./di"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./nx-module"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./test-bed"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/@nx-ddd/core/src/index.ts"],"names":[],"mappings":";;;AAAA,+CAAqB;AACrB,sDAA4B;AAC5B,qDAA2B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/core/src/nx-module/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC;AAChC,sDAA4B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Injector } from 'injection-js';
|
|
2
|
+
export declare type Type<T> = any;
|
|
3
|
+
export declare function createNxModuleRef<T>(moduleType: Type<T>, injector?: Injector): NxModuleRef<T>;
|
|
4
|
+
export declare class NxModuleRef<T = any> {
|
|
5
|
+
nxModuleType: Type<T>;
|
|
6
|
+
_parent: Injector;
|
|
7
|
+
injector: Injector;
|
|
8
|
+
instance: T;
|
|
9
|
+
constructor(nxModuleType: Type<T>, _parent: Injector);
|
|
10
|
+
}
|
|
11
|
+
export declare class NxModuleFactory<T> {
|
|
12
|
+
moduleType: Type<T>;
|
|
13
|
+
constructor(moduleType: Type<T>);
|
|
14
|
+
create(parentInjector: Injector | null): NxModuleRef<T>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NxModuleFactory = exports.NxModuleRef = exports.createNxModuleRef = void 0;
|
|
4
|
+
const create_injector_1 = require("../di/create-injector");
|
|
5
|
+
function createNxModuleRef(moduleType, injector) {
|
|
6
|
+
return new NxModuleRef(moduleType, injector !== null && injector !== void 0 ? injector : null);
|
|
7
|
+
}
|
|
8
|
+
exports.createNxModuleRef = createNxModuleRef;
|
|
9
|
+
class NxModuleRef {
|
|
10
|
+
constructor(nxModuleType, _parent) {
|
|
11
|
+
this.nxModuleType = nxModuleType;
|
|
12
|
+
this._parent = _parent;
|
|
13
|
+
this.injector = (0, create_injector_1.createInjectorWithoutInjectorInstances)(nxModuleType, _parent);
|
|
14
|
+
this.instance = this.injector.get(nxModuleType);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.NxModuleRef = NxModuleRef;
|
|
18
|
+
class NxModuleFactory {
|
|
19
|
+
constructor(moduleType) {
|
|
20
|
+
this.moduleType = moduleType;
|
|
21
|
+
}
|
|
22
|
+
create(parentInjector) {
|
|
23
|
+
return new NxModuleRef(this.moduleType, parentInjector);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.NxModuleFactory = NxModuleFactory;
|
|
27
|
+
//# sourceMappingURL=nx-module-ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nx-module-ref.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/core/src/nx-module/nx-module-ref.ts"],"names":[],"mappings":";;;AACA,2DAA+E;AAI/E,SAAgB,iBAAiB,CAAI,UAAmB,EAAE,QAAmB;IAC3E,OAAO,IAAI,WAAW,CAAC,UAAU,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,IAAI,CAAC,CAAC;AACvD,CAAC;AAFD,8CAEC;AAED,MAAa,WAAW;IAItB,YACS,YAAqB,EACrB,OAAiB;QADjB,iBAAY,GAAZ,YAAY,CAAS;QACrB,YAAO,GAAP,OAAO,CAAU;QAExB,IAAI,CAAC,QAAQ,GAAG,IAAA,wDAAsC,EAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAC9E,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC;CACF;AAXD,kCAWC;AAED,MAAa,eAAe;IAC1B,YAAmB,UAAmB;QAAnB,eAAU,GAAV,UAAU,CAAS;IAAI,CAAC;IAE3C,MAAM,CAAC,cAA6B;QAClC,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAC1D,CAAC;CACF;AAND,0CAMC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NxModule = void 0;
|
|
4
|
+
const defs_1 = require("../di/interface/defs");
|
|
5
|
+
function NxModule(nxModule) {
|
|
6
|
+
return function (target) {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
target[defs_1.NG_INJ_DEF] = {
|
|
9
|
+
imports: [...((_a = nxModule.imports) !== null && _a !== void 0 ? _a : [])],
|
|
10
|
+
providers: [...((_b = nxModule.providers) !== null && _b !== void 0 ? _b : [])],
|
|
11
|
+
};
|
|
12
|
+
return target;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.NxModule = NxModule;
|
|
16
|
+
//# sourceMappingURL=nx-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nx-module.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/core/src/nx-module/nx-module.ts"],"names":[],"mappings":";;;AAAA,+CAAkD;AAQlD,SAAgB,QAAQ,CAAC,QAAkB;IACzC,OAAO,UAAU,MAAM;;QACrB,MAAM,CAAC,iBAAU,CAAC,GAAG;YACnB,OAAO,EAAE,CAAC,GAAG,CAAC,MAAA,QAAQ,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC;YACtC,SAAS,EAAE,CAAC,GAAG,CAAC,MAAA,QAAQ,CAAC,SAAS,mCAAI,EAAE,CAAC,CAAC;SAC3C,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AARD,4BAQC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NxModule } from "../nx-module";
|
|
2
|
+
export declare class TestBed {
|
|
3
|
+
static _INSTANCE: TestBed;
|
|
4
|
+
static get INSTANCE(): TestBed;
|
|
5
|
+
private moduleRef;
|
|
6
|
+
configureTestingModule(nxModule: NxModule): this;
|
|
7
|
+
inject(token: any): any;
|
|
8
|
+
static inject(token: any): any;
|
|
9
|
+
static configureTestingModule(nxModule: NxModule): TestBed;
|
|
10
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TestBed = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const injection_js_1 = require("injection-js");
|
|
6
|
+
const nx_module_1 = require("../nx-module");
|
|
7
|
+
class TestBed {
|
|
8
|
+
static get INSTANCE() {
|
|
9
|
+
var _a;
|
|
10
|
+
return (_a = this._INSTANCE) !== null && _a !== void 0 ? _a : (this._INSTANCE = new this());
|
|
11
|
+
}
|
|
12
|
+
configureTestingModule(nxModule) {
|
|
13
|
+
let Module = class Module {
|
|
14
|
+
};
|
|
15
|
+
Module = tslib_1.__decorate([
|
|
16
|
+
(0, nx_module_1.NxModule)(nxModule)
|
|
17
|
+
], Module);
|
|
18
|
+
this.moduleRef = (0, nx_module_1.createNxModuleRef)(Module, injection_js_1.Injector.NULL);
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
inject(token) {
|
|
22
|
+
return this.moduleRef.injector.get(token);
|
|
23
|
+
}
|
|
24
|
+
static inject(token) {
|
|
25
|
+
return this.INSTANCE.inject(token);
|
|
26
|
+
}
|
|
27
|
+
static configureTestingModule(nxModule) {
|
|
28
|
+
return this.INSTANCE.configureTestingModule(nxModule);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.TestBed = TestBed;
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/core/src/test-bed/index.ts"],"names":[],"mappings":";;;;AAAA,+CAAwC;AACxC,4CAAwE;AAExE,MAAa,OAAO;IAGlB,MAAM,KAAK,QAAQ;;QACjB,aAAO,IAAI,CAAC,SAAS,oCAAd,IAAI,CAAC,SAAS,GAAK,IAAI,IAAI,EAAE,EAAC;IACvC,CAAC;IAID,sBAAsB,CAAC,QAAkB;QACnB,IAAM,MAAM,GAAZ,MAAM,MAAM;SAAI,CAAA;QAAV,MAAM;YAA/B,IAAA,oBAAQ,EAAC,QAAQ,CAAC;WAAO,MAAM,CAAI;QACpC,IAAI,CAAC,SAAS,GAAG,IAAA,6BAAiB,EAAC,MAAM,EAAE,uBAAQ,CAAC,IAAI,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,KAAU;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,KAAU;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,CAAC,sBAAsB,CAAC,QAAkB;QAC9C,OAAO,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC;CACF;AA1BD,0BA0BC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { InjectionToken } from '../di';
|
|
2
|
+
import { Type } from '../di/interface/type';
|
|
3
|
+
export interface TestModuleMetadata {
|
|
4
|
+
imports?: any[];
|
|
5
|
+
providers?: any[];
|
|
6
|
+
}
|
|
7
|
+
export interface TestBedStatic {
|
|
8
|
+
inject<T>(token: Type<T> | InjectionToken<T>): T;
|
|
9
|
+
}
|
|
10
|
+
export declare class TestBed {
|
|
11
|
+
nxModule: Type<any>;
|
|
12
|
+
static _instance: TestBedStatic;
|
|
13
|
+
static get instance(): TestBedStatic;
|
|
14
|
+
static NxModule?: Type<any>;
|
|
15
|
+
static configureTestingModule(moduleDef: TestModuleMetadata): TestBedStatic;
|
|
16
|
+
static inject<T>(token: Type<T> | InjectionToken<T>): T;
|
|
17
|
+
injector: import("injection-js/injector").Injector;
|
|
18
|
+
constructor(nxModule: Type<any>);
|
|
19
|
+
inject<T>(token: Type<T> | InjectionToken<T>): T;
|
|
20
|
+
}
|
package/testing/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TestBed = void 0;
|
|
4
|
+
const nx_module_1 = require("@nx-ddd/core/nx-module");
|
|
5
|
+
const di_1 = require("../di");
|
|
6
|
+
class TestBed {
|
|
7
|
+
constructor(nxModule) {
|
|
8
|
+
this.nxModule = nxModule;
|
|
9
|
+
this.injector = (0, di_1.createInjector)(this.nxModule);
|
|
10
|
+
}
|
|
11
|
+
static get instance() {
|
|
12
|
+
var _a;
|
|
13
|
+
return (_a = this._instance) !== null && _a !== void 0 ? _a : (this._instance = new TestBed(this.NxModule));
|
|
14
|
+
}
|
|
15
|
+
static configureTestingModule(moduleDef) {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
TestBed.NxModule = (0, nx_module_1.NxModule)({
|
|
18
|
+
imports: [...((_a = moduleDef.imports) !== null && _a !== void 0 ? _a : [])],
|
|
19
|
+
providers: [...((_b = moduleDef.providers) !== null && _b !== void 0 ? _b : [])],
|
|
20
|
+
})(class NxModule {
|
|
21
|
+
});
|
|
22
|
+
return this.instance;
|
|
23
|
+
}
|
|
24
|
+
static inject(token) {
|
|
25
|
+
return this.instance.inject(token);
|
|
26
|
+
}
|
|
27
|
+
inject(token) {
|
|
28
|
+
return this.injector.get(token);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.TestBed = TestBed;
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/core/src/testing/index.ts"],"names":[],"mappings":";;;AAAA,sDAAkD;AAClD,8BAAuD;AAYvD,MAAa,OAAO;IAsBlB,YAAmB,QAAmB;QAAnB,aAAQ,GAAR,QAAQ,CAAW;QAF/B,aAAQ,GAAG,IAAA,mBAAc,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEN,CAAC;IApB3C,MAAM,KAAK,QAAQ;;QACjB,aAAO,IAAI,CAAC,SAAS,oCAAd,IAAI,CAAC,SAAS,GAAK,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAC;IACvD,CAAC;IAID,MAAM,CAAC,sBAAsB,CAAC,SAA6B;;QACzD,OAAO,CAAC,QAAQ,GAAG,IAAA,oBAAQ,EAAC;YAC1B,OAAO,EAAE,CAAC,GAAG,CAAC,MAAA,SAAS,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC;YACvC,SAAS,EAAE,CAAC,GAAG,CAAC,MAAA,SAAS,CAAC,SAAS,mCAAI,EAAE,CAAC,CAAC;SAC5C,CAAC,CAAC,MAAM,QAAQ;SAAI,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,MAAM,CAAI,KAAkC;QACjD,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAMM,MAAM,CAAI,KAAkC;QACjD,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;CACF;AA3BD,0BA2BC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deepForEach<T>(input: (T | any[])[], fn: (value: T) => void): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deepForEach = void 0;
|
|
4
|
+
function deepForEach(input, fn) {
|
|
5
|
+
input.forEach(value => Array.isArray(value) ? deepForEach(value, fn) : fn(value));
|
|
6
|
+
}
|
|
7
|
+
exports.deepForEach = deepForEach;
|
|
8
|
+
//# sourceMappingURL=array_utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_utils.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/core/src/util/array_utils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CAAI,KAAkB,EAAE,EAAsB;IACvE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AACpF,CAAC;AAFD,kCAEC"}
|