@lenne.tech/nest-server 11.27.5 → 11.27.7
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/.claude/rules/architecture.md +66 -0
- package/.claude/rules/better-auth.md +88 -2
- package/.claude/rules/configurable-features.md +2 -2
- package/.claude/rules/package-management.md +23 -14
- package/.claude/rules/testing.md +27 -9
- package/CLAUDE.md +12 -4
- package/FRAMEWORK-API.md +1 -1
- package/bin/migrate.js +84 -25
- package/dist/core/common/decorators/restricted.decorator.d.ts +4 -4
- package/dist/core/common/decorators/restricted.decorator.js +21 -22
- package/dist/core/common/decorators/restricted.decorator.js.map +1 -1
- package/dist/core/common/helpers/clone.helper.d.ts +6 -0
- package/dist/core/common/helpers/clone.helper.js +67 -0
- package/dist/core/common/helpers/clone.helper.js.map +1 -0
- package/dist/core/common/helpers/cookies.helper.d.ts +1 -0
- package/dist/core/common/helpers/cookies.helper.js +33 -16
- package/dist/core/common/helpers/cookies.helper.js.map +1 -1
- package/dist/core/common/helpers/db.helper.d.ts +2 -14
- package/dist/core/common/helpers/db.helper.js +13 -106
- package/dist/core/common/helpers/db.helper.js.map +1 -1
- package/dist/core/common/helpers/id.helper.d.ts +15 -0
- package/dist/core/common/helpers/id.helper.js +104 -0
- package/dist/core/common/helpers/id.helper.js.map +1 -0
- package/dist/core/common/helpers/input.helper.d.ts +1 -6
- package/dist/core/common/helpers/input.helper.js +11 -70
- package/dist/core/common/helpers/input.helper.js.map +1 -1
- package/dist/core/common/inputs/combined-filter.input.d.ts +1 -12
- package/dist/core/common/inputs/combined-filter.input.js +2 -51
- package/dist/core/common/inputs/combined-filter.input.js.map +1 -1
- package/dist/core/common/inputs/filter.input.d.ts +10 -1
- package/dist/core/common/inputs/filter.input.js +40 -5
- package/dist/core/common/inputs/filter.input.js.map +1 -1
- package/dist/core/common/services/config.service.js +5 -5
- package/dist/core/common/services/config.service.js.map +1 -1
- package/dist/core/modules/ai/core-ai.constants.d.ts +22 -0
- package/dist/core/modules/ai/core-ai.constants.js +26 -0
- package/dist/core/modules/ai/core-ai.constants.js.map +1 -0
- package/dist/core/modules/ai/index.d.ts +1 -0
- package/dist/core/modules/ai/index.js +1 -0
- package/dist/core/modules/ai/index.js.map +1 -1
- package/dist/core/modules/ai/interfaces/ai-interaction-record.interface.d.ts +17 -0
- package/dist/core/modules/ai/interfaces/ai-interaction-record.interface.js +3 -0
- package/dist/core/modules/ai/interfaces/ai-interaction-record.interface.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-budget.service.d.ts +1 -2
- package/dist/core/modules/ai/services/core-ai-budget.service.js +7 -5
- package/dist/core/modules/ai/services/core-ai-budget.service.js.map +1 -1
- package/dist/core/modules/ai/services/core-ai-connection-preference.service.d.ts +1 -2
- package/dist/core/modules/ai/services/core-ai-connection-preference.service.js +7 -5
- package/dist/core/modules/ai/services/core-ai-connection-preference.service.js.map +1 -1
- package/dist/core/modules/ai/services/core-ai-connection.service.d.ts +1 -2
- package/dist/core/modules/ai/services/core-ai-connection.service.js +7 -5
- package/dist/core/modules/ai/services/core-ai-connection.service.js.map +1 -1
- package/dist/core/modules/ai/services/core-ai-conversation.service.d.ts +1 -2
- package/dist/core/modules/ai/services/core-ai-conversation.service.js +7 -5
- package/dist/core/modules/ai/services/core-ai-conversation.service.js.map +1 -1
- package/dist/core/modules/ai/services/core-ai-interaction.service.d.ts +2 -3
- package/dist/core/modules/ai/services/core-ai-interaction.service.js +7 -5
- package/dist/core/modules/ai/services/core-ai-interaction.service.js.map +1 -1
- package/dist/core/modules/ai/services/core-ai-mode.service.d.ts +1 -2
- package/dist/core/modules/ai/services/core-ai-mode.service.js +7 -5
- package/dist/core/modules/ai/services/core-ai-mode.service.js.map +1 -1
- package/dist/core/modules/ai/services/core-ai-prompt-hint.service.d.ts +1 -3
- package/dist/core/modules/ai/services/core-ai-prompt-hint.service.js +7 -5
- package/dist/core/modules/ai/services/core-ai-prompt-hint.service.js.map +1 -1
- package/dist/core/modules/ai/services/core-ai-prompt.service.d.ts +1 -2
- package/dist/core/modules/ai/services/core-ai-prompt.service.js +7 -5
- package/dist/core/modules/ai/services/core-ai-prompt.service.js.map +1 -1
- package/dist/core/modules/ai/services/core-ai-slot.service.d.ts +1 -2
- package/dist/core/modules/ai/services/core-ai-slot.service.js +7 -5
- package/dist/core/modules/ai/services/core-ai-slot.service.js.map +1 -1
- package/dist/core/modules/ai/services/core-ai-tool-grant.service.d.ts +1 -2
- package/dist/core/modules/ai/services/core-ai-tool-grant.service.js +7 -5
- package/dist/core/modules/ai/services/core-ai-tool-grant.service.js.map +1 -1
- package/dist/core/modules/ai/services/core-ai-tool-policy.service.d.ts +1 -2
- package/dist/core/modules/ai/services/core-ai-tool-policy.service.js +7 -5
- package/dist/core/modules/ai/services/core-ai-tool-policy.service.js.map +1 -1
- package/dist/core/modules/ai/services/core-ai.service.d.ts +2 -17
- package/dist/core/modules/ai/services/core-ai.service.js.map +1 -1
- package/dist/core/modules/better-auth/better-auth-roles.guard.js +2 -2
- package/dist/core/modules/better-auth/better-auth-roles.guard.js.map +1 -1
- package/dist/core/modules/better-auth/better-auth.config.js +12 -8
- package/dist/core/modules/better-auth/better-auth.config.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth.constants.d.ts +3 -0
- package/dist/core/modules/better-auth/core-better-auth.constants.js +7 -0
- package/dist/core/modules/better-auth/core-better-auth.constants.js.map +1 -0
- package/dist/core/modules/better-auth/core-better-auth.module.d.ts +1 -2
- package/dist/core/modules/better-auth/core-better-auth.module.js +23 -20
- package/dist/core/modules/better-auth/core-better-auth.module.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth.registry.d.ts +4 -0
- package/dist/core/modules/better-auth/core-better-auth.registry.js +16 -0
- package/dist/core/modules/better-auth/core-better-auth.registry.js.map +1 -0
- package/dist/core/modules/better-auth/core-better-auth.service.d.ts +1 -2
- package/dist/core/modules/better-auth/core-better-auth.service.js +7 -6
- package/dist/core/modules/better-auth/core-better-auth.service.js.map +1 -1
- package/dist/core/modules/better-auth/index.d.ts +1 -0
- package/dist/core/modules/better-auth/index.js +1 -0
- package/dist/core/modules/better-auth/index.js.map +1 -1
- package/dist/core/modules/migrate/migration-runner.d.ts +1 -0
- package/dist/core/modules/migrate/migration-runner.js +3 -2
- package/dist/core/modules/migrate/migration-runner.js.map +1 -1
- package/dist/core/modules/tus/tus.constants.d.ts +1 -0
- package/dist/core/modules/tus/tus.constants.js +5 -0
- package/dist/core/modules/tus/tus.constants.js.map +1 -0
- package/dist/core/modules/tus/tus.module.d.ts +1 -1
- package/dist/core/modules/tus/tus.module.js +8 -6
- package/dist/core/modules/tus/tus.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/docs/REQUEST-LIFECYCLE.md +17 -4
- package/migration-guides/11.27.5-to-11.27.6.md +359 -0
- package/migration-guides/11.27.6-to-11.27.7.md +374 -0
- package/package.json +11 -104
- package/src/core/common/decorators/restricted.decorator.ts +33 -8
- package/src/core/common/helpers/clone.helper.ts +110 -0
- package/src/core/common/helpers/cookies.helper.ts +101 -26
- package/src/core/common/helpers/db.helper.ts +14 -161
- package/src/core/common/helpers/id.helper.ts +198 -0
- package/src/core/common/helpers/input.helper.ts +12 -84
- package/src/core/common/inputs/combined-filter.input.ts +10 -57
- package/src/core/common/inputs/filter.input.ts +92 -1
- package/src/core/common/interfaces/server-options.interface.ts +35 -6
- package/src/core/common/services/config.service.ts +4 -1
- package/src/core/modules/ai/core-ai.constants.ts +92 -0
- package/src/core/modules/ai/index.ts +1 -0
- package/src/core/modules/ai/interfaces/ai-interaction-record.interface.ts +34 -0
- package/src/core/modules/ai/services/core-ai-budget.service.ts +8 -4
- package/src/core/modules/ai/services/core-ai-connection-preference.service.ts +8 -4
- package/src/core/modules/ai/services/core-ai-connection.service.ts +5 -6
- package/src/core/modules/ai/services/core-ai-conversation.service.ts +5 -6
- package/src/core/modules/ai/services/core-ai-interaction.service.ts +6 -7
- package/src/core/modules/ai/services/core-ai-mode.service.ts +8 -2
- package/src/core/modules/ai/services/core-ai-prompt-hint.service.ts +7 -4
- package/src/core/modules/ai/services/core-ai-prompt.service.ts +8 -2
- package/src/core/modules/ai/services/core-ai-slot.service.ts +7 -4
- package/src/core/modules/ai/services/core-ai-tool-grant.service.ts +8 -4
- package/src/core/modules/ai/services/core-ai-tool-policy.service.ts +8 -4
- package/src/core/modules/ai/services/core-ai.service.ts +8 -11
- package/src/core/modules/better-auth/README.md +10 -4
- package/src/core/modules/better-auth/better-auth-roles.guard.ts +11 -5
- package/src/core/modules/better-auth/better-auth.config.ts +90 -15
- package/src/core/modules/better-auth/core-better-auth.constants.ts +73 -0
- package/src/core/modules/better-auth/core-better-auth.module.ts +34 -8
- package/src/core/modules/better-auth/core-better-auth.registry.ts +53 -0
- package/src/core/modules/better-auth/core-better-auth.service.ts +19 -12
- package/src/core/modules/better-auth/index.ts +9 -0
- package/src/core/modules/migrate/migration-runner.ts +16 -2
- package/src/core/modules/tus/tus.constants.ts +25 -0
- package/src/core/modules/tus/tus.module.ts +7 -2
|
@@ -28,15 +28,34 @@ import { CoreBetterAuthRateLimitMiddleware } from './core-better-auth-rate-limit
|
|
|
28
28
|
import { CoreBetterAuthRateLimiter } from './core-better-auth-rate-limiter.service';
|
|
29
29
|
import { CoreBetterAuthSignUpValidatorService } from './core-better-auth-signup-validator.service';
|
|
30
30
|
import { CoreBetterAuthUserMapper } from './core-better-auth-user.mapper';
|
|
31
|
+
import { BETTER_AUTH_CONFIG, BETTER_AUTH_COOKIE_DOMAIN, BETTER_AUTH_INSTANCE } from './core-better-auth.constants';
|
|
31
32
|
import { CoreBetterAuthController } from './core-better-auth.controller';
|
|
32
33
|
import { CoreBetterAuthMiddleware } from './core-better-auth.middleware';
|
|
34
|
+
import {
|
|
35
|
+
getBetterAuthTokenService,
|
|
36
|
+
resetBetterAuthRegistry,
|
|
37
|
+
setBetterAuthTokenService,
|
|
38
|
+
} from './core-better-auth.registry';
|
|
33
39
|
import { CoreBetterAuthResolver } from './core-better-auth.resolver';
|
|
34
|
-
import {
|
|
40
|
+
import { CoreBetterAuthService } from './core-better-auth.service';
|
|
35
41
|
|
|
36
42
|
/**
|
|
37
|
-
*
|
|
43
|
+
* @deprecated Import from `./core-better-auth.constants` instead. Re-exported only
|
|
44
|
+
* so existing deep imports keep working; it will be dropped in a future MINOR.
|
|
45
|
+
*
|
|
46
|
+
* Do NOT import this token from here inside the better-auth module itself — the
|
|
47
|
+
* token must come from the constants leaf, or module and service start importing
|
|
48
|
+
* each other again and SWC builds crash with a temporal-dead-zone ReferenceError
|
|
49
|
+
* (see core-better-auth.constants.ts).
|
|
50
|
+
*
|
|
51
|
+
* NOTE: the `@deprecated` tag above is documentation only — TypeScript does not
|
|
52
|
+
* honor JSDoc on an `export … from` declaration. Do NOT try to "fix" that by
|
|
53
|
+
* re-declaring the token as a local `const`: that would give the barrel two
|
|
54
|
+
* distinct declarations of the same name and turn its `export *` into a TS2308
|
|
55
|
+
* ambiguity error. The mechanical guards are `pnpm run check:swc-tdz` and
|
|
56
|
+
* `tests/unit/better-auth-di-tokens.spec.ts`.
|
|
38
57
|
*/
|
|
39
|
-
export
|
|
58
|
+
export { BETTER_AUTH_INSTANCE } from './core-better-auth.constants';
|
|
40
59
|
|
|
41
60
|
/**
|
|
42
61
|
* Options for CoreBetterAuthModule.forRoot()
|
|
@@ -239,10 +258,11 @@ export class CoreBetterAuthModule implements NestModule, OnModuleInit {
|
|
|
239
258
|
// Safety Net: Track if forRoot() has already been called to detect duplicate registration
|
|
240
259
|
private static forRootCalled = false;
|
|
241
260
|
private static cachedDynamicModule: DynamicModule | null = null;
|
|
242
|
-
// Static references for lazy GraphQL driver (autoRegister: false)
|
|
261
|
+
// Static references for lazy GraphQL driver (autoRegister: false).
|
|
262
|
+
// The BetterAuthTokenService reference lives in core-better-auth.registry.ts instead,
|
|
263
|
+
// so BetterAuthRolesGuard can read it without importing this module (cycle-free).
|
|
243
264
|
private static serviceInstance: CoreBetterAuthService | null = null;
|
|
244
265
|
private static userMapperInstance: CoreBetterAuthUserMapper | null = null;
|
|
245
|
-
private static tokenServiceInstance: BetterAuthTokenService | null = null;
|
|
246
266
|
private static resolvedCookieDomain: string | undefined = undefined;
|
|
247
267
|
|
|
248
268
|
/**
|
|
@@ -279,11 +299,14 @@ export class CoreBetterAuthModule implements NestModule, OnModuleInit {
|
|
|
279
299
|
|
|
280
300
|
/**
|
|
281
301
|
* Gets the static BetterAuthTokenService instance.
|
|
282
|
-
* Used by BetterAuthRolesGuard for token verification when user isn't already on request.
|
|
283
302
|
* Safe because guards are invoked only after module initialization.
|
|
303
|
+
*
|
|
304
|
+
* Delegates to the core-better-auth.registry leaf module, which is the single
|
|
305
|
+
* source of truth. BetterAuthRolesGuard reads the registry directly instead of
|
|
306
|
+
* calling this method, so that guard and module never import each other.
|
|
284
307
|
*/
|
|
285
308
|
static getTokenServiceInstance(): BetterAuthTokenService | null {
|
|
286
|
-
return
|
|
309
|
+
return getBetterAuthTokenService();
|
|
287
310
|
}
|
|
288
311
|
|
|
289
312
|
/**
|
|
@@ -315,7 +338,7 @@ export class CoreBetterAuthModule implements NestModule, OnModuleInit {
|
|
|
315
338
|
CoreBetterAuthModule.userMapperInstance = this.userMapper;
|
|
316
339
|
}
|
|
317
340
|
if (this.tokenService) {
|
|
318
|
-
|
|
341
|
+
setBetterAuthTokenService(this.tokenService);
|
|
319
342
|
}
|
|
320
343
|
|
|
321
344
|
// Configure rate limiter with stored config
|
|
@@ -747,6 +770,9 @@ export class CoreBetterAuthModule implements NestModule, OnModuleInit {
|
|
|
747
770
|
this.serviceInstance = null;
|
|
748
771
|
this.userMapperInstance = null;
|
|
749
772
|
this.resolvedCookieDomain = undefined;
|
|
773
|
+
// Reset the BetterAuthTokenService reference used by BetterAuthRolesGuard.
|
|
774
|
+
// Without this a token service from a previous testing module leaks into the next one.
|
|
775
|
+
resetBetterAuthRegistry();
|
|
750
776
|
// Reset shared RolesGuard registry (shared with CoreAuthModule)
|
|
751
777
|
RolesGuardRegistry.reset();
|
|
752
778
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime registry for better-auth singletons that must be reachable from files
|
|
3
|
+
* which cannot import core-better-auth.module.ts.
|
|
4
|
+
*
|
|
5
|
+
* `BetterAuthRolesGuard` deliberately has no constructor dependencies (see
|
|
6
|
+
* .claude/rules/better-auth.md §5), so it cannot receive `BetterAuthTokenService`
|
|
7
|
+
* through DI and has to look it up statically. Reading it from
|
|
8
|
+
* `CoreBetterAuthModule` would make guard and module import each other — the same
|
|
9
|
+
* cycle shape that crashed SWC builds when the DI tokens still lived in the module
|
|
10
|
+
* and the service (see core-better-auth.constants.ts).
|
|
11
|
+
*
|
|
12
|
+
* This file therefore holds the reference instead. It uses only `import type`,
|
|
13
|
+
* which both tsc and SWC erase entirely, so it emits no `require()` at all and is
|
|
14
|
+
* a true leaf: it can never be mid-evaluation when someone imports it, in any
|
|
15
|
+
* module system, under any compiler.
|
|
16
|
+
*
|
|
17
|
+
* @internal Populated by CoreBetterAuthModule.onModuleInit(). Read it through the
|
|
18
|
+
* public `CoreBetterAuthModule.getTokenServiceInstance()` unless you are in a file
|
|
19
|
+
* that the module itself imports — importing the module from there would re-create
|
|
20
|
+
* the cycle.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import type { BetterAuthTokenService } from './better-auth-token.service';
|
|
24
|
+
|
|
25
|
+
let tokenServiceInstance: BetterAuthTokenService | null = null;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Stores the BetterAuthTokenService singleton.
|
|
29
|
+
* Called by CoreBetterAuthModule during module initialization.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export function setBetterAuthTokenService(service: BetterAuthTokenService | null): void {
|
|
33
|
+
tokenServiceInstance = service;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Returns the BetterAuthTokenService singleton, or null when better-auth is
|
|
38
|
+
* disabled or the module has not initialized yet.
|
|
39
|
+
*
|
|
40
|
+
* Safe to call from guards: they run only after module initialization.
|
|
41
|
+
*/
|
|
42
|
+
export function getBetterAuthTokenService(): BetterAuthTokenService | null {
|
|
43
|
+
return tokenServiceInstance;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Clears the registry. Called by CoreBetterAuthModule.reset() so tests do not
|
|
48
|
+
* leak a token service from a previous testing module into the next one.
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
export function resetBetterAuthRegistry(): void {
|
|
52
|
+
tokenServiceInstance = null;
|
|
53
|
+
}
|
|
@@ -13,7 +13,7 @@ import { resolveBetterAuthCookiePrefix } from './better-auth-cookie-prefix.helpe
|
|
|
13
13
|
import { BetterAuthInstance } from './better-auth.config';
|
|
14
14
|
import { BetterAuthSessionUser } from './core-better-auth-user.mapper';
|
|
15
15
|
import { convertExpressHeaders, parseCookieHeader, signCookieValueIfNeeded } from './core-better-auth-web.helper';
|
|
16
|
-
import { BETTER_AUTH_INSTANCE } from './core-better-auth.
|
|
16
|
+
import { BETTER_AUTH_CONFIG, BETTER_AUTH_COOKIE_DOMAIN, BETTER_AUTH_INSTANCE } from './core-better-auth.constants';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Result of a session validation
|
|
@@ -28,6 +28,24 @@ export interface SessionResult {
|
|
|
28
28
|
user: BetterAuthSessionUser | null;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated Import from `./core-better-auth.constants` instead. Re-exported only
|
|
33
|
+
* so existing deep imports keep working; it will be dropped in a future MINOR.
|
|
34
|
+
*
|
|
35
|
+
* Do NOT import these tokens from here inside the better-auth module itself — they
|
|
36
|
+
* must come from the constants leaf, or module and service start importing each
|
|
37
|
+
* other again and SWC builds crash with a temporal-dead-zone ReferenceError
|
|
38
|
+
* (see core-better-auth.constants.ts).
|
|
39
|
+
*
|
|
40
|
+
* NOTE: the `@deprecated` tag above is documentation only — TypeScript does not
|
|
41
|
+
* honor JSDoc on an `export … from` declaration. Do NOT try to "fix" that by
|
|
42
|
+
* re-declaring the tokens as local `const`s: that would give the barrel two
|
|
43
|
+
* distinct declarations of the same name and turn its `export *` into a TS2308
|
|
44
|
+
* ambiguity error. The mechanical guards are `pnpm run check:swc-tdz` and
|
|
45
|
+
* `tests/unit/better-auth-di-tokens.spec.ts`.
|
|
46
|
+
*/
|
|
47
|
+
export { BETTER_AUTH_CONFIG, BETTER_AUTH_COOKIE_DOMAIN } from './core-better-auth.constants';
|
|
48
|
+
|
|
31
49
|
/**
|
|
32
50
|
* CoreBetterAuthService provides a NestJS-friendly wrapper around the better-auth instance.
|
|
33
51
|
*
|
|
@@ -51,17 +69,6 @@ export interface SessionResult {
|
|
|
51
69
|
* }
|
|
52
70
|
* ```
|
|
53
71
|
*/
|
|
54
|
-
/**
|
|
55
|
-
* Injection token for resolved BetterAuth configuration
|
|
56
|
-
*/
|
|
57
|
-
export const BETTER_AUTH_CONFIG = 'BETTER_AUTH_CONFIG';
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Injection token for resolved cross-subdomain cookie domain.
|
|
61
|
-
* Set during Better-Auth instance creation, undefined if disabled.
|
|
62
|
-
*/
|
|
63
|
-
export const BETTER_AUTH_COOKIE_DOMAIN = 'BETTER_AUTH_COOKIE_DOMAIN';
|
|
64
|
-
|
|
65
72
|
@Injectable()
|
|
66
73
|
export class CoreBetterAuthService implements OnModuleInit {
|
|
67
74
|
private readonly logger = new Logger(CoreBetterAuthService.name);
|
|
@@ -39,8 +39,17 @@ export * from './core-better-auth-signup-validator.service';
|
|
|
39
39
|
export * from './core-better-auth-token.helper';
|
|
40
40
|
export * from './core-better-auth-user.mapper';
|
|
41
41
|
export * from './core-better-auth-web.helper';
|
|
42
|
+
export * from './core-better-auth.constants';
|
|
42
43
|
export * from './core-better-auth.controller';
|
|
43
44
|
export * from './core-better-auth.middleware';
|
|
44
45
|
export * from './core-better-auth.module';
|
|
46
|
+
// NOT exported: './core-better-auth.registry'.
|
|
47
|
+
//
|
|
48
|
+
// It is module-internal plumbing that only exists so BetterAuthRolesGuard can reach
|
|
49
|
+
// BetterAuthTokenService without importing CoreBetterAuthModule (see .claude/rules/better-auth.md
|
|
50
|
+
// §6). Re-exporting it would put `setBetterAuthTokenService()` on the public API — letting a
|
|
51
|
+
// consumer swap or null the very token service the guard makes its authorization decisions with.
|
|
52
|
+
// Consumers that need the instance already have the public, read-only
|
|
53
|
+
// `CoreBetterAuthModule.getTokenServiceInstance()`.
|
|
45
54
|
export * from './core-better-auth.resolver';
|
|
46
55
|
export * from './core-better-auth.service';
|
|
@@ -19,13 +19,27 @@ export interface MigrationFile {
|
|
|
19
19
|
up: () => Promise<void>;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Default file pattern for migration files: `*.ts` and `*.js`, but never `*.d.ts`.
|
|
24
|
+
*
|
|
25
|
+
* A compiled migration ships `foo.js` next to `foo.d.ts` (whenever the project
|
|
26
|
+
* builds with `declaration: true`). A plain `/\.(ts|js)$/` matches the
|
|
27
|
+
* declaration file too, so the runner would load it as a *second* migration and
|
|
28
|
+
* throw — `export declare …` is not valid CommonJS.
|
|
29
|
+
*
|
|
30
|
+
* The lookbehind guards the `.ts` branch only. Writing it as `(?<!\.d)\.(ts|js)$`
|
|
31
|
+
* would also reject a perfectly valid `foo.d.js`, since `.d` precedes `.js` there
|
|
32
|
+
* as well.
|
|
33
|
+
*/
|
|
34
|
+
export const DEFAULT_MIGRATION_FILE_PATTERN = /(?:(?<!\.d)\.ts|\.js)$/;
|
|
35
|
+
|
|
22
36
|
/**
|
|
23
37
|
* Migration runner configuration
|
|
24
38
|
*/
|
|
25
39
|
export interface MigrationRunnerOptions {
|
|
26
40
|
/** Directory containing migration files */
|
|
27
41
|
migrationsDirectory: string;
|
|
28
|
-
/** Pattern to match migration files (default:
|
|
42
|
+
/** Pattern to match migration files (default: {@link DEFAULT_MIGRATION_FILE_PATTERN}) */
|
|
29
43
|
pattern?: RegExp;
|
|
30
44
|
/** State store for tracking migrations */
|
|
31
45
|
stateStore: MongoStateStore;
|
|
@@ -59,7 +73,7 @@ export class MigrationRunner {
|
|
|
59
73
|
|
|
60
74
|
constructor(options: MigrationRunnerOptions) {
|
|
61
75
|
this.options = options;
|
|
62
|
-
this.pattern = options.pattern ||
|
|
76
|
+
this.pattern = options.pattern || DEFAULT_MIGRATION_FILE_PATTERN;
|
|
63
77
|
}
|
|
64
78
|
|
|
65
79
|
/**
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency-injection tokens of the TUS module.
|
|
3
|
+
*
|
|
4
|
+
* They live in a dedicated, import-free leaf file — never in `tus.module.ts` or a service — so that
|
|
5
|
+
* no file needing a token has to import the module (or vice versa) and close an import cycle.
|
|
6
|
+
*
|
|
7
|
+
* On a cycle, a token read at MODULE-EVALUATION time — inside an `@Inject()` decorator argument, in
|
|
8
|
+
* `design:paramtypes` metadata, or in a static field initializer — reads a `const` still in its
|
|
9
|
+
* temporal dead zone, and SWC-compiled builds (`nest start -b swc`) die at startup with:
|
|
10
|
+
*
|
|
11
|
+
* ReferenceError: Cannot access 'TUS_CONFIG' before initialization
|
|
12
|
+
*
|
|
13
|
+
* A file that imports nothing can never be mid-evaluation when someone imports it, in any module
|
|
14
|
+
* system, under any compiler. That is the whole point — keep it import-free.
|
|
15
|
+
*
|
|
16
|
+
* `tsc`, `pnpm test` and `oxlint` are all blind to a regression here; only `pnpm run check:swc-tdz`
|
|
17
|
+
* sees it. See .claude/rules/architecture.md → "DI Token Placement (SWC-Safe)".
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Token for injecting the resolved TUS configuration.
|
|
22
|
+
*
|
|
23
|
+
* Injected type: `Required<ITusConfig>`.
|
|
24
|
+
*/
|
|
25
|
+
export const TUS_CONFIG = 'TUS_CONFIG';
|
|
@@ -5,12 +5,17 @@ import { Connection } from 'mongoose';
|
|
|
5
5
|
import { ITusConfig } from '../../common/interfaces/server-options.interface';
|
|
6
6
|
import { CoreTusController } from './core-tus.controller';
|
|
7
7
|
import { CoreTusService } from './core-tus.service';
|
|
8
|
+
import { TUS_CONFIG } from './tus.constants';
|
|
8
9
|
import { normalizeTusConfig } from './interfaces/tus-config.interface';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
+
* @deprecated Import from `./tus.constants` instead. Re-exported only so existing deep imports keep
|
|
13
|
+
* working; the token is declared in an import-free leaf so module and services stay acyclic
|
|
14
|
+
* (SWC-safe — see tus.constants.ts).
|
|
15
|
+
*
|
|
16
|
+
* Do NOT import it from here inside the TUS module itself — that is what re-creates the cycle.
|
|
12
17
|
*/
|
|
13
|
-
export
|
|
18
|
+
export { TUS_CONFIG } from './tus.constants';
|
|
14
19
|
|
|
15
20
|
/**
|
|
16
21
|
* Options for TusModule.forRoot()
|