@tstdl/base 0.93.17 → 0.93.19
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.
|
@@ -630,7 +630,7 @@ AuthenticationService = AuthenticationService_1 = __decorate([
|
|
|
630
630
|
Singleton({
|
|
631
631
|
providers: [
|
|
632
632
|
provide(EntityRepositoryConfig, { useValue: { schema: 'authentication' } }),
|
|
633
|
-
|
|
633
|
+
provide(DatabaseConfig, { useFactory: (_, context) => context.resolve(AuthenticationModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf: true }) }),
|
|
634
634
|
],
|
|
635
635
|
})
|
|
636
636
|
], AuthenticationService);
|
package/injector/decorators.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createClassDecorator, createDecorator, reflectionRegistry } from '../reflection/index.js';
|
|
3
3
|
import { toArray } from '../utils/array/array.js';
|
|
4
4
|
import { filterObject } from '../utils/object/object.js';
|
|
5
|
-
import { isArray, isDefined, isFunction, isNotNull } from '../utils/type-guards.js';
|
|
5
|
+
import { isArray, isDefined, isFunction, isNotNull, isPromise } from '../utils/type-guards.js';
|
|
6
6
|
import { Injector } from './injector.js';
|
|
7
7
|
import { injectMetadataSymbol, injectableMetadataSymbol, injectableOptionsSymbol } from './symbols.js';
|
|
8
8
|
/**
|
|
@@ -46,8 +46,11 @@ export function Injectable(options = {}) {
|
|
|
46
46
|
...registrationOptions,
|
|
47
47
|
providers: [...(optionsToInherit.providers ?? []), ...(registrationOptions.providers ?? [])],
|
|
48
48
|
afterResolve: (instance, argument, context) => {
|
|
49
|
-
optionsToInherit.afterResolve?.(instance, argument, context);
|
|
50
|
-
|
|
49
|
+
const result1 = optionsToInherit.afterResolve?.(instance, argument, context);
|
|
50
|
+
if (isPromise(result1)) {
|
|
51
|
+
return result1.then(async () => await registrationOptions.afterResolve?.(instance, argument, context)); // eslint-disable-line @typescript-eslint/no-unsafe-return
|
|
52
|
+
}
|
|
53
|
+
return registrationOptions.afterResolve?.(instance, argument, context);
|
|
51
54
|
},
|
|
52
55
|
metadata: {
|
|
53
56
|
...optionsToInherit.metadata,
|
package/injector/injector.js
CHANGED
|
@@ -152,7 +152,7 @@ export class Injector {
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
if (options?.onlySelf != true) {
|
|
155
|
-
return this.#parent?.tryGetRegistration(token);
|
|
155
|
+
return this.#parent?.tryGetRegistration(token, { ...options, skipSelf: false });
|
|
156
156
|
}
|
|
157
157
|
return undefined;
|
|
158
158
|
}
|
|
@@ -280,14 +280,11 @@ export class Injector {
|
|
|
280
280
|
if (isUndefined(token)) {
|
|
281
281
|
throw new ResolveError('Token is undefined. This might be due to a circular dependency. Consider using an alias or forwardRef.', chain);
|
|
282
282
|
}
|
|
283
|
-
const registration =
|
|
283
|
+
const registration = this.tryGetRegistration(token, options);
|
|
284
284
|
if (isDefined(registration)) {
|
|
285
285
|
const singleRegistration = isArray(registration) ? registration[0] : registration;
|
|
286
286
|
return this._resolveRegistration(singleRegistration, argument, options, context, chain);
|
|
287
287
|
}
|
|
288
|
-
if (isNotNull(this.#parent) && (options.onlySelf != true)) {
|
|
289
|
-
return this.#parent._resolve(token, argument, { ...options, skipSelf: false }, context, chain);
|
|
290
|
-
}
|
|
291
288
|
if (options.optional == true) {
|
|
292
289
|
return undefined;
|
|
293
290
|
}
|
|
@@ -305,49 +302,55 @@ export class Injector {
|
|
|
305
302
|
if (isUndefined(token)) {
|
|
306
303
|
throw new ResolveError('Token is undefined. This might be due to a circular dependency. Consider using an alias or forwardRef.', chain);
|
|
307
304
|
}
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
305
|
+
const ownValues = [];
|
|
306
|
+
const parentValues = [];
|
|
307
|
+
if (options.skipSelf != true) {
|
|
308
|
+
const registration = this.tryGetRegistration(token, { onlySelf: true });
|
|
309
|
+
if (isDefined(registration)) {
|
|
310
|
+
const registrations = isArray(registration) ? registration : [registration];
|
|
311
|
+
const resolved = registrations.map((reg) => this._resolveRegistration(reg, argument, options, context, chain));
|
|
312
|
+
ownValues.push(...resolved);
|
|
313
|
+
}
|
|
312
314
|
}
|
|
313
315
|
if (isNotNull(this.#parent) && (options.onlySelf != true)) {
|
|
314
|
-
|
|
316
|
+
parentValues.push(...this.#parent._resolveAll(token, argument, { ...options, skipSelf: false }, context, chain));
|
|
315
317
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
+
const allValues = [...ownValues, ...parentValues];
|
|
319
|
+
if ((allValues.length == 0) && (options.optional != true)) {
|
|
320
|
+
throw new ResolveError(`No provider for ${getTokenName(token)} registered.`, chain);
|
|
318
321
|
}
|
|
319
|
-
|
|
322
|
+
return allValues;
|
|
320
323
|
}
|
|
321
324
|
_resolveRegistration(registration, argument, options, context, chain) {
|
|
322
325
|
checkOverflow(chain, context);
|
|
323
326
|
const { token, provider, providers } = registration;
|
|
327
|
+
const resolutionTag = Symbol('ResolutionTag');
|
|
328
|
+
const resolutionScoped = registration.options.lifecycle == 'resolution';
|
|
329
|
+
const injectorScoped = registration.options.lifecycle == 'injector';
|
|
330
|
+
const singletonScoped = registration.options.lifecycle == 'singleton';
|
|
331
|
+
let resolveArgument = argument ?? registration.options.defaultArgument;
|
|
332
|
+
if (isUndefined(resolveArgument) && isFunction(registration.options.defaultArgumentProvider)) {
|
|
333
|
+
resolveArgument = wrapInResolveError(() => registration.options.defaultArgumentProvider(this.getResolveContext(resolutionTag, context, chain)), 'Error in defaultArgumentProvider', chain);
|
|
334
|
+
}
|
|
335
|
+
const argumentIdentity = resolveArgumentIdentity(registration, resolveArgument, chain);
|
|
336
|
+
if (resolutionScoped && context.resolutionScopedResolutions.hasFlat(token, argumentIdentity)) {
|
|
337
|
+
return context.resolutionScopedResolutions.getFlat(token, argumentIdentity).value;
|
|
338
|
+
}
|
|
339
|
+
else if (injectorScoped && this.#injectorScopedResolutions.hasFlat(token, argumentIdentity)) {
|
|
340
|
+
return this.#injectorScopedResolutions.getFlat(token, argumentIdentity).value;
|
|
341
|
+
}
|
|
342
|
+
else if (singletonScoped && registration.resolutions.has(argumentIdentity)) {
|
|
343
|
+
return registration.resolutions.get(argumentIdentity);
|
|
344
|
+
}
|
|
324
345
|
// A new scope is only needed if we are instantiating a class, running a factory, or if the registration explicitly defines scoped providers.
|
|
325
346
|
const needsNewScope = isClassProvider(provider) || isFactoryProvider(provider) || (providers.length > 0);
|
|
326
347
|
const injector = needsNewScope ? this.fork('ResolutionInjector') : this;
|
|
327
348
|
for (const nestedProvider of providers) {
|
|
328
349
|
injector.registerSingleton(nestedProvider.provide, nestedProvider, { multi: nestedProvider.multi });
|
|
329
350
|
}
|
|
330
|
-
const injectionContext = injector.getInjectionContext(context,
|
|
351
|
+
const injectionContext = injector.getInjectionContext(context, resolveArgument, chain);
|
|
331
352
|
const previousInjectionContext = setCurrentInjectionContext(injectionContext);
|
|
332
|
-
const resolutionTag = Symbol('ResolutionTag');
|
|
333
353
|
try {
|
|
334
|
-
const resolutionScoped = registration.options.lifecycle == 'resolution';
|
|
335
|
-
const injectorScoped = registration.options.lifecycle == 'injector';
|
|
336
|
-
const singletonScoped = registration.options.lifecycle == 'singleton';
|
|
337
|
-
let resolveArgument = argument ?? registration.options.defaultArgument;
|
|
338
|
-
if (isUndefined(resolveArgument) && isFunction(registration.options.defaultArgumentProvider)) {
|
|
339
|
-
resolveArgument = wrapInResolveError(() => registration.options.defaultArgumentProvider(injector.getResolveContext(resolutionTag, context, chain)), 'Error in defaultArgumentProvider', chain);
|
|
340
|
-
}
|
|
341
|
-
const argumentIdentity = resolveArgumentIdentity(registration, resolveArgument, chain);
|
|
342
|
-
if (resolutionScoped && context.resolutionScopedResolutions.hasFlat(token, argumentIdentity)) {
|
|
343
|
-
return context.resolutionScopedResolutions.getFlat(token, argumentIdentity).value;
|
|
344
|
-
}
|
|
345
|
-
else if (injectorScoped && this.#injectorScopedResolutions.hasFlat(token, argumentIdentity)) {
|
|
346
|
-
return this.#injectorScopedResolutions.getFlat(token, argumentIdentity).value;
|
|
347
|
-
}
|
|
348
|
-
else if (singletonScoped && registration.resolutions.has(argumentIdentity)) {
|
|
349
|
-
return registration.resolutions.get(argumentIdentity);
|
|
350
|
-
}
|
|
351
354
|
const resolutionContext = { afterResolveRegistrations: [] };
|
|
352
355
|
const value = injector._resolveProvider(resolutionTag, registration, resolveArgument, options, context, resolutionContext, injectionContext, chain);
|
|
353
356
|
const resolution = {
|
package/mail/module.js
CHANGED
|
@@ -31,6 +31,6 @@ export async function migrateMailSchema() {
|
|
|
31
31
|
await migrate(database, {
|
|
32
32
|
migrationsSchema: 'mail',
|
|
33
33
|
migrationsTable: '_migrations',
|
|
34
|
-
migrationsFolder: import.meta.resolve('./drizzle').replace('file://', '')
|
|
34
|
+
migrationsFolder: import.meta.resolve('./drizzle').replace('file://', ''),
|
|
35
35
|
});
|
|
36
36
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* using numeric representation (YYYYMMDD).
|
|
5
5
|
*/
|
|
6
6
|
import { customType } from 'drizzle-orm/pg-core';
|
|
7
|
-
import { dateToNumericDate,
|
|
7
|
+
import { dateToNumericDate, numericDateToDateObject } from '../../utils/date-time.js';
|
|
8
8
|
/**
|
|
9
9
|
* Custom Drizzle type for PostgreSQL `date` columns, storing dates as numeric values (YYYYMMDD).
|
|
10
10
|
* Converts between JavaScript `number` (YYYYMMDD) and database `date` (ISO string).
|
|
@@ -14,7 +14,11 @@ export const numericDate = customType({
|
|
|
14
14
|
return 'date';
|
|
15
15
|
},
|
|
16
16
|
toDriver(value) {
|
|
17
|
-
|
|
17
|
+
const { year, month, day } = numericDateToDateObject(value);
|
|
18
|
+
const yearString = year.toString().padStart(4, '0');
|
|
19
|
+
const monthString = month.toString().padStart(2, '0');
|
|
20
|
+
const dayString = day.toString().padStart(2, '0');
|
|
21
|
+
return `${yearString}-${monthString}-${dayString}`;
|
|
18
22
|
},
|
|
19
23
|
fromDriver(value) {
|
|
20
24
|
const date = new Date(value);
|