@tstdl/base 0.93.19 → 0.93.21
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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ProvidersItem } from '../../../injector/injector.js';
|
|
2
1
|
export declare const documentManagementDatabaseConfigFactoryProvider: import("../../../injector/provider.js").FactoryProvider<unknown, unknown, import("../../../types/types.js").Record>;
|
|
3
|
-
export declare const documentManagementDatabaseConfigProvider: ProvidersItem
|
|
2
|
+
export declare const documentManagementDatabaseConfigProvider: import("../../../injector/injector.js").ProvidersItem<unknown, unknown, import("../../../types/types.js").Record>;
|
|
4
3
|
export declare function DocumentManagementSingleton(): ClassDecorator;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { Singleton } from '../../../injector/decorators.js';
|
|
2
|
+
import { provide } from '../../../injector/injector.js';
|
|
2
3
|
import { factoryProvider } from '../../../injector/provider.js';
|
|
3
4
|
import { DatabaseConfig } from '../../../orm/server/index.js';
|
|
4
5
|
import { DocumentManagementConfiguration } from '../module.js';
|
|
5
6
|
export const documentManagementDatabaseConfigFactoryProvider = factoryProvider((_, context) => context.resolve(DocumentManagementConfiguration).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf: true }));
|
|
6
|
-
export const documentManagementDatabaseConfigProvider =
|
|
7
|
-
provide: DatabaseConfig,
|
|
8
|
-
...documentManagementDatabaseConfigFactoryProvider,
|
|
9
|
-
};
|
|
7
|
+
export const documentManagementDatabaseConfigProvider = provide(DatabaseConfig, documentManagementDatabaseConfigFactoryProvider);
|
|
10
8
|
export function DocumentManagementSingleton() {
|
|
11
9
|
return Singleton({ providers: [documentManagementDatabaseConfigProvider] });
|
|
12
10
|
}
|
package/injector/injector.js
CHANGED
|
@@ -145,14 +145,15 @@ export class Injector {
|
|
|
145
145
|
this.register(globalRegistration.token, globalRegistration.provider, globalRegistration.options);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
if (options?.skipSelf
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
if (options?.skipSelf == true) {
|
|
149
|
+
return this.#parent?.tryGetRegistration(token, { ...options, skipSelf: false });
|
|
150
|
+
}
|
|
151
|
+
const ownRegistration = this.#registrations.get(token);
|
|
152
|
+
if (isDefined(ownRegistration)) {
|
|
153
|
+
return ownRegistration;
|
|
153
154
|
}
|
|
154
155
|
if (options?.onlySelf != true) {
|
|
155
|
-
return this.#parent?.tryGetRegistration(token,
|
|
156
|
+
return this.#parent?.tryGetRegistration(token, options);
|
|
156
157
|
}
|
|
157
158
|
return undefined;
|
|
158
159
|
}
|
|
@@ -269,6 +270,12 @@ export class Injector {
|
|
|
269
270
|
}
|
|
270
271
|
_resolve(token, argument, options, context, chain) {
|
|
271
272
|
this.assertNotDisposed();
|
|
273
|
+
if (options.skipSelf == true) {
|
|
274
|
+
if (isNull(this.#parent) && (options.optional != true)) {
|
|
275
|
+
throw new ResolveError(`No parent injector available.`, chain);
|
|
276
|
+
}
|
|
277
|
+
return this.#parent?._resolve(token, argument, { ...options, skipSelf: false }, context, chain);
|
|
278
|
+
}
|
|
272
279
|
if (isDefined(options.forwardRef) && (options.forwardRef != false)) {
|
|
273
280
|
assert(options.optional != true, 'ForwardRef does not support optional without resolveAll/injectAll as undefined is not forwardable.');
|
|
274
281
|
const forwardToken = isFunction(options.forwardRef) ? options.forwardRef() : token;
|
|
@@ -280,11 +287,14 @@ export class Injector {
|
|
|
280
287
|
if (isUndefined(token)) {
|
|
281
288
|
throw new ResolveError('Token is undefined. This might be due to a circular dependency. Consider using an alias or forwardRef.', chain);
|
|
282
289
|
}
|
|
283
|
-
const
|
|
284
|
-
if (isDefined(
|
|
285
|
-
const singleRegistration = isArray(
|
|
290
|
+
const ownRegistration = this.tryGetRegistration(token, { ...options, skipSelf: false, onlySelf: true });
|
|
291
|
+
if (isDefined(ownRegistration)) {
|
|
292
|
+
const singleRegistration = isArray(ownRegistration) ? ownRegistration[0] : ownRegistration;
|
|
286
293
|
return this._resolveRegistration(singleRegistration, argument, options, context, chain);
|
|
287
294
|
}
|
|
295
|
+
if ((options.onlySelf != true) && isNotNull(this.#parent)) {
|
|
296
|
+
return this.#parent._resolve(token, argument, { ...options, skipSelf: false }, context, chain);
|
|
297
|
+
}
|
|
288
298
|
if (options.optional == true) {
|
|
289
299
|
return undefined;
|
|
290
300
|
}
|
|
@@ -292,6 +302,12 @@ export class Injector {
|
|
|
292
302
|
}
|
|
293
303
|
_resolveAll(token, argument, options, context, chain) {
|
|
294
304
|
this.assertNotDisposed();
|
|
305
|
+
if (options.skipSelf == true) {
|
|
306
|
+
if (isNull(this.#parent) && (options.optional != true)) {
|
|
307
|
+
throw new ResolveError(`No parent injector available.`, chain);
|
|
308
|
+
}
|
|
309
|
+
return this.#parent?._resolveAll(token, argument, { ...options, skipSelf: false }, context, chain) ?? [];
|
|
310
|
+
}
|
|
295
311
|
if (isDefined(options.forwardRef) && (options.forwardRef != false)) {
|
|
296
312
|
const forwardToken = isFunction(options.forwardRef) ? options.forwardRef() : token;
|
|
297
313
|
const forwardRef = ForwardRef.create({ typeHint: options.forwardRefTypeHint ?? isFunction(forwardToken) ? forwardToken : undefined });
|
|
@@ -304,15 +320,13 @@ export class Injector {
|
|
|
304
320
|
}
|
|
305
321
|
const ownValues = [];
|
|
306
322
|
const parentValues = [];
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
ownValues.push(...resolved);
|
|
313
|
-
}
|
|
323
|
+
const ownRegistration = this.tryGetRegistration(token, { ...options, skipSelf: false, onlySelf: true });
|
|
324
|
+
if (isDefined(ownRegistration)) {
|
|
325
|
+
const registrations = isArray(ownRegistration) ? ownRegistration : [ownRegistration];
|
|
326
|
+
const resolved = registrations.map((reg) => this._resolveRegistration(reg, argument, options, context, chain));
|
|
327
|
+
ownValues.push(...resolved);
|
|
314
328
|
}
|
|
315
|
-
if (
|
|
329
|
+
if ((options.onlySelf != true) && isNotNull(this.#parent)) {
|
|
316
330
|
parentValues.push(...this.#parent._resolveAll(token, argument, { ...options, skipSelf: false }, context, chain));
|
|
317
331
|
}
|
|
318
332
|
const allValues = [...ownValues, ...parentValues];
|