@venizia/ignis-kernel 0.4.8-15 → 0.4.8-16

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 (85) hide show
  1. package/dist/esm/base/applications/artifact-index.d.ts +3 -3
  2. package/dist/esm/base/applications/artifact-index.js.map +1 -1
  3. package/dist/esm/base/applications/body-limit.js +1 -1
  4. package/dist/esm/base/applications/body-limit.js.map +1 -1
  5. package/dist/esm/base/applications/rest.js.map +1 -1
  6. package/dist/esm/base/auth/authenticate/common/types/strategy.d.ts +1 -2
  7. package/dist/esm/base/auth/authenticate/common/types/strategy.js.map +1 -1
  8. package/dist/esm/base/auth/authorize/providers/request-domain.js +2 -1
  9. package/dist/esm/base/auth/authorize/providers/request-domain.js.map +1 -1
  10. package/dist/esm/base/controllers/common/types/route.d.ts +13 -4
  11. package/dist/esm/base/controllers/common/types/route.js.map +1 -1
  12. package/dist/esm/base/controllers/factory/controller.d.ts +3 -4
  13. package/dist/esm/base/controllers/factory/controller.js +0 -1
  14. package/dist/esm/base/controllers/factory/controller.js.map +1 -1
  15. package/dist/esm/base/controllers/factory/crud/abstract.d.ts +3 -4
  16. package/dist/esm/base/controllers/factory/crud/abstract.js.map +1 -1
  17. package/dist/esm/base/controllers/factory/index.d.ts +1 -0
  18. package/dist/esm/base/controllers/factory/index.js +1 -0
  19. package/dist/esm/base/controllers/factory/index.js.map +1 -1
  20. package/dist/esm/base/controllers/factory/injection.d.ts +38 -0
  21. package/dist/esm/base/controllers/factory/injection.js +54 -0
  22. package/dist/esm/base/controllers/factory/injection.js.map +1 -0
  23. package/dist/esm/base/controllers/rest/base.d.ts +3 -3
  24. package/dist/esm/base/controllers/rest/base.js.map +1 -1
  25. package/dist/esm/base/datasources/common/types.d.ts +2 -2
  26. package/dist/esm/base/datasources/common/types.js.map +1 -1
  27. package/dist/esm/base/datasources/root.d.ts +2 -2
  28. package/dist/esm/base/datasources/root.js.map +1 -1
  29. package/dist/esm/base/events/event-bus.js.map +1 -1
  30. package/dist/esm/base/metadata/index.d.ts +1 -1
  31. package/dist/esm/base/metadata/index.js +1 -1
  32. package/dist/esm/base/metadata/injectors.d.ts +1 -1
  33. package/dist/esm/base/metadata/persistents/datasource.d.ts +21 -0
  34. package/dist/esm/base/metadata/persistents/datasource.js +46 -0
  35. package/dist/esm/base/metadata/persistents/datasource.js.map +1 -0
  36. package/dist/esm/base/metadata/persistents/index.d.ts +5 -0
  37. package/dist/esm/base/metadata/persistents/index.js +5 -0
  38. package/dist/esm/base/metadata/persistents/index.js.map +1 -0
  39. package/dist/esm/base/metadata/persistents/model.d.ts +18 -0
  40. package/dist/esm/base/metadata/persistents/model.js +64 -0
  41. package/dist/esm/base/metadata/persistents/model.js.map +1 -0
  42. package/dist/esm/base/metadata/persistents/repository/index.d.ts +19 -0
  43. package/dist/esm/base/metadata/persistents/repository/index.js +32 -0
  44. package/dist/esm/base/metadata/persistents/repository/index.js.map +1 -0
  45. package/dist/esm/base/metadata/persistents/repository/injection.d.ts +15 -0
  46. package/dist/esm/base/metadata/persistents/repository/injection.js +64 -0
  47. package/dist/esm/base/metadata/persistents/repository/injection.js.map +1 -0
  48. package/dist/esm/base/metadata/persistents/repository/resolve.d.ts +15 -0
  49. package/dist/esm/base/metadata/persistents/repository/resolve.js +76 -0
  50. package/dist/esm/base/metadata/persistents/repository/resolve.js.map +1 -0
  51. package/dist/esm/base/metadata/persistents/repository/validate.d.ts +15 -0
  52. package/dist/esm/base/metadata/persistents/repository/validate.js +50 -0
  53. package/dist/esm/base/metadata/persistents/repository/validate.js.map +1 -0
  54. package/dist/esm/base/models/common/utilities.d.ts +1 -1
  55. package/dist/esm/base/repositories/common/types/options.d.ts +2 -2
  56. package/dist/esm/base/repositories/common/types/options.js.map +1 -1
  57. package/dist/esm/base/repositories/common/types/query.d.ts +6 -15
  58. package/dist/esm/base/repositories/common/types/query.js.map +1 -1
  59. package/dist/esm/base/repositories/query-schemas/index.js +7 -0
  60. package/dist/esm/base/repositories/query-schemas/index.js.map +1 -1
  61. package/dist/esm/helpers/inversion/mixins/artifact.mixin.d.ts +3 -3
  62. package/dist/esm/helpers/inversion/mixins/controllers/controller.d.ts +3 -3
  63. package/dist/esm/helpers/inversion/mixins/controllers/grpc.d.ts +3 -3
  64. package/dist/esm/helpers/inversion/mixins/controllers/rest.d.ts +3 -3
  65. package/dist/esm/helpers/inversion/mixins/datasource.mixin.d.ts +3 -3
  66. package/dist/esm/helpers/inversion/mixins/model.mixin.d.ts +3 -3
  67. package/dist/esm/helpers/inversion/mixins/repository.mixin.d.ts +8 -8
  68. package/dist/esm/helpers/inversion/mixins/repository.mixin.js +5 -6
  69. package/dist/esm/helpers/inversion/mixins/repository.mixin.js.map +1 -1
  70. package/dist/esm/helpers/inversion/registry.d.ts +26 -26
  71. package/dist/esm/helpers/inversion/registry.js.map +1 -1
  72. package/dist/esm/helpers/singleton-realm.js +5 -4
  73. package/dist/esm/helpers/singleton-realm.js.map +1 -1
  74. package/dist/esm/metadata.d.ts +1 -1
  75. package/dist/esm/metadata.js +1 -1
  76. package/dist/esm/utilities/index.d.ts +1 -0
  77. package/dist/esm/utilities/index.js +1 -0
  78. package/dist/esm/utilities/index.js.map +1 -1
  79. package/dist/esm/utilities/toggle.utility.d.ts +22 -0
  80. package/dist/esm/utilities/toggle.utility.js +16 -0
  81. package/dist/esm/utilities/toggle.utility.js.map +1 -0
  82. package/package.json +5 -5
  83. package/dist/esm/base/metadata/persistents.d.ts +0 -55
  84. package/dist/esm/base/metadata/persistents.js +0 -303
  85. package/dist/esm/base/metadata/persistents.js.map +0 -1
@@ -0,0 +1,50 @@
1
+ import { getError } from '@venizia/ignis-helpers/core';
2
+ import { isDataSourceClass } from '../../../datasources/index.js';
3
+ import { RepositoryTypes } from '../../../repositories/common/constants.js';
4
+ /** Mirrors the `TRepositoryMetadata` union for JavaScript callers: a known type, a dataSource always, a model exactly when the type is RepositoryTypes.MODEL. */
5
+ export const validateRepositoryMetadata = (opts) => {
6
+ const { metadata, target } = opts;
7
+ const type = metadata.type ?? RepositoryTypes.MODEL;
8
+ if (!RepositoryTypes.isValid(type)) {
9
+ throw getError({
10
+ message: `[validateRepositoryMetadata][@repository][${target.name}] Invalid metadata | Unknown 'type': ${type} | Expected one of: ${[...RepositoryTypes.SCHEME_SET].join(', ')}`,
11
+ });
12
+ }
13
+ if (type === RepositoryTypes.MODEL && !metadata.model) {
14
+ throw getError({
15
+ message: `[validateRepositoryMetadata][@repository][${target.name}] Invalid metadata | Missing 'model'`,
16
+ });
17
+ }
18
+ if (type === RepositoryTypes.REMOTE && metadata.model) {
19
+ throw getError({
20
+ message: `[validateRepositoryMetadata][@repository][${target.name}] Invalid metadata | A '${RepositoryTypes.REMOTE}' repository takes no 'model'`,
21
+ });
22
+ }
23
+ if (!metadata.dataSource) {
24
+ throw getError({
25
+ message: `[validateRepositoryMetadata][@repository][${target.name}] Invalid metadata | Missing 'dataSource'`,
26
+ });
27
+ }
28
+ };
29
+ /** Asserts the constructor's first parameter is a datasource class (`AbstractDataSource` or the `DataSourceRoot` it extends) compatible with what @repository declared. */
30
+ export const validateFirstConstructorParameter = (opts) => {
31
+ const { target, firstParamType, resolvedDataSource } = opts;
32
+ // NOT `instanceof`: two copies of this package give two `DataSourceRoot` classes and the
33
+ // check would be false across them, rejecting a perfectly valid repository at import time.
34
+ const isDataSourceType = isDataSourceClass(firstParamType);
35
+ if (!isDataSourceType) {
36
+ throw getError({
37
+ message: `[@repository][${target.name}] Invalid constructor | First parameter must extend AbstractDataSource (or DataSourceRoot) | Received: '${firstParamType.name}'`,
38
+ });
39
+ }
40
+ if (typeof resolvedDataSource !== 'function') {
41
+ return;
42
+ }
43
+ const isCompatible = firstParamType === resolvedDataSource || resolvedDataSource.prototype instanceof firstParamType;
44
+ if (!isCompatible) {
45
+ throw getError({
46
+ message: `[@repository][${target.name}] Invalid constructor | Type mismatch | Constructor expects '${firstParamType.name}' but @repository specifies '${resolvedDataSource.name}'`,
47
+ });
48
+ }
49
+ };
50
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../../../../src/base/metadata/persistents/repository/validate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAEzE,iKAAiK;AACjK,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAGxC,IAGD,EAAQ,EAAE;IACT,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAClC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,eAAe,CAAC,KAAK,CAAC;IAEpD,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,MAAM,QAAQ,CAAC;YACb,OAAO,EAAE,6CAA6C,MAAM,CAAC,IAAI,wCAAwC,IAAI,uBAAuB,CAAC,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;SACjL,CAAC,CAAC;IACL,CAAC;IAED,IAAI,IAAI,KAAK,eAAe,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtD,MAAM,QAAQ,CAAC;YACb,OAAO,EAAE,6CAA6C,MAAM,CAAC,IAAI,sCAAsC;SACxG,CAAC,CAAC;IACL,CAAC;IAED,IAAI,IAAI,KAAK,eAAe,CAAC,MAAM,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtD,MAAM,QAAQ,CAAC;YACb,OAAO,EAAE,6CAA6C,MAAM,CAAC,IAAI,2BAA2B,eAAe,CAAC,MAAM,+BAA+B;SAClJ,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QACzB,MAAM,QAAQ,CAAC;YACb,OAAO,EAAE,6CAA6C,MAAM,CAAC,IAAI,2CAA2C;SAC7G,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC;AAEF,2KAA2K;AAC3K,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,IAIjD,EAAQ,EAAE;IACT,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAC;IAE5D,yFAAyF;IACzF,2FAA2F;IAC3F,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAE3D,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,QAAQ,CAAC;YACb,OAAO,EAAE,iBAAiB,MAAM,CAAC,IAAI,2GAA2G,cAAc,CAAC,IAAI,GAAG;SACvK,CAAC,CAAC;IACL,CAAC;IAED,IAAI,OAAO,kBAAkB,KAAK,UAAU,EAAE,CAAC;QAC7C,OAAO;IACT,CAAC;IAED,MAAM,YAAY,GAChB,cAAc,KAAK,kBAAkB,IAAI,kBAAkB,CAAC,SAAS,YAAY,cAAc,CAAC;IAElG,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,QAAQ,CAAC;YACb,OAAO,EAAE,iBAAiB,MAAM,CAAC,IAAI,gEAAgE,cAAc,CAAC,IAAI,gCAAgC,kBAAkB,CAAC,IAAI,GAAG;SACnL,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { TRepositoryMetadata } from '@/helpers/inversion';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport type { IDataSource } from '../../../datasources';\nimport { isDataSourceClass } from '../../../datasources';\nimport type { AbstractEntity } from '../../../models';\nimport { RepositoryTypes } from '../../../repositories/common/constants';\n\n/** Mirrors the `TRepositoryMetadata` union for JavaScript callers: a known type, a dataSource always, a model exactly when the type is RepositoryTypes.MODEL. */\nexport const validateRepositoryMetadata = <\n Model extends AbstractEntity = AbstractEntity,\n DataSource extends IDataSource = IDataSource,\n>(opts: {\n metadata: TRepositoryMetadata<Model, DataSource>;\n target: Function;\n}): void => {\n const { metadata, target } = opts;\n const type = metadata.type ?? RepositoryTypes.MODEL;\n\n if (!RepositoryTypes.isValid(type)) {\n throw getError({\n message: `[validateRepositoryMetadata][@repository][${target.name}] Invalid metadata | Unknown 'type': ${type} | Expected one of: ${[...RepositoryTypes.SCHEME_SET].join(', ')}`,\n });\n }\n\n if (type === RepositoryTypes.MODEL && !metadata.model) {\n throw getError({\n message: `[validateRepositoryMetadata][@repository][${target.name}] Invalid metadata | Missing 'model'`,\n });\n }\n\n if (type === RepositoryTypes.REMOTE && metadata.model) {\n throw getError({\n message: `[validateRepositoryMetadata][@repository][${target.name}] Invalid metadata | A '${RepositoryTypes.REMOTE}' repository takes no 'model'`,\n });\n }\n\n if (!metadata.dataSource) {\n throw getError({\n message: `[validateRepositoryMetadata][@repository][${target.name}] Invalid metadata | Missing 'dataSource'`,\n });\n }\n};\n\n/** Asserts the constructor's first parameter is a datasource class (`AbstractDataSource` or the `DataSourceRoot` it extends) compatible with what @repository declared. */\nexport const validateFirstConstructorParameter = (opts: {\n target: Function;\n firstParamType: Function;\n resolvedDataSource: string | Function;\n}): void => {\n const { target, firstParamType, resolvedDataSource } = opts;\n\n // NOT `instanceof`: two copies of this package give two `DataSourceRoot` classes and the\n // check would be false across them, rejecting a perfectly valid repository at import time.\n const isDataSourceType = isDataSourceClass(firstParamType);\n\n if (!isDataSourceType) {\n throw getError({\n message: `[@repository][${target.name}] Invalid constructor | First parameter must extend AbstractDataSource (or DataSourceRoot) | Received: '${firstParamType.name}'`,\n });\n }\n\n if (typeof resolvedDataSource !== 'function') {\n return;\n }\n\n const isCompatible =\n firstParamType === resolvedDataSource || resolvedDataSource.prototype instanceof firstParamType;\n\n if (!isCompatible) {\n throw getError({\n message: `[@repository][${target.name}] Invalid constructor | Type mismatch | Constructor expects '${firstParamType.name}' but @repository specifies '${resolvedDataSource.name}'`,\n });\n }\n};\n"]}
@@ -12,7 +12,7 @@ export declare class ModelUtility {
12
12
  }): TEntityId;
13
13
  static snakeToCamel<T extends z.ZodRawShape>(opts: {
14
14
  shape: T;
15
- }): z.ZodPipe<z.ZodPipe<z.ZodObject<{ -readonly [P in keyof T]: T[P]; }, z.core.$strip>, z.ZodTransform<any, z.core.$InferObjectOutput<{ -readonly [P in keyof T]: T[P]; }, {}>>>, z.ZodObject<TCamelCaseKeys<T> extends infer T_1 ? { -readonly [P_1 in keyof T_1]: T_1[P_1]; } : never, z.core.$strip>>;
15
+ }): z.ZodPipe<z.ZodPipe<z.ZodObject<{ -readonly [P in keyof T]: T[P]; }, z.core.$strip>, z.ZodTransform<Record<string, unknown>, z.core.$InferObjectOutput<{ -readonly [P in keyof T]: T[P]; }, {}>>>, z.ZodObject<TCamelCaseKeys<T> extends infer T_1 ? { -readonly [P_1 in keyof T_1]: T_1[P_1]; } : never, z.core.$strip>>;
16
16
  }
17
17
  export {};
18
18
  //# sourceMappingURL=utilities.d.ts.map
@@ -5,8 +5,8 @@ import type { SQL } from 'drizzle-orm';
5
5
  import type { TLockStrength } from '../constants.js';
6
6
  import type { TDataWithRange } from './results.js';
7
7
  /** Update data supporting both regular fields and JSON path updates via dot notation. */
8
- export type TUpdateData<T = any> = Partial<T> & {
9
- [jsonPath: string]: any;
8
+ export type TUpdateData<T = object> = Partial<T> & {
9
+ [jsonPath: string]: unknown;
10
10
  };
11
11
  /** Options for Drizzle ORM query building, used internally by FilterBuilder. */
12
12
  export type TDrizzleQueryOptions = Partial<{
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../../../src/base/repositories/common/types/options.ts"],"names":[],"mappings":"","sourcesContent":["import type { ITransaction } from '@/base/datasources';\nimport type { IRetryBackoffOptions, TLogLevel } from '@venizia/ignis-helpers/core';\nimport type { TNullable } from '@venizia/ignis-helpers/common';\nimport type { SQL } from 'drizzle-orm';\nimport type { TLockStrength } from '../constants';\nimport type { TDataWithRange } from './results';\n\n/** Update data supporting both regular fields and JSON path updates via dot notation. */\nexport type TUpdateData<T = any> = Partial<T> & {\n [jsonPath: string]: any;\n};\n\n/** Options for Drizzle ORM query building, used internally by FilterBuilder. */\nexport type TDrizzleQueryOptions = Partial<{\n limit: number;\n offset: number;\n orderBy: SQL[];\n where: SQL;\n with: Record<string, true | TDrizzleQueryOptions>;\n columns: Record<string, boolean>;\n}>;\n\n/** Configuration for repository operation logging. */\nexport type TRepositoryLogOptions = {\n use: boolean;\n level?: TLogLevel;\n};\n\n/** Configuration for row-level lock wait behavior. Mutually exclusive: use noWait OR skipLocked. */\nexport type TLockConfig =\n | { noWait: true; skipLocked?: undefined }\n | { noWait?: undefined; skipLocked: true }\n | { noWait?: undefined; skipLocked?: undefined };\n\n/** Row-level locking options for read operations. */\nexport type TLockOptions = {\n strength: TLockStrength;\n config?: TLockConfig;\n};\n\n/** Neutral transaction association - postgres narrows to its own `IDatabaseTransaction` (via `isDatabaseTransaction`) where it needs `.connector`. */\nexport interface IWithTransaction {\n transaction?: ITransaction;\n}\n\n/** Extended options for repository operations with transaction, logging, and default filter bypass. */\nexport interface IExtraOptions extends IWithTransaction {\n log?: TRepositoryLogOptions;\n\n /** If true, bypass the default filter configured in model settings (e.g., soft delete). */\n shouldSkipDefaultFilter?: boolean;\n\n /** Row-level locking. Requires transaction. Incompatible with include/fields (Query API). */\n lock?: TLockOptions;\n}\n\n/**\n * Read-after-write retry for read verbs behind a replicated pool. The read re-executes while\n * `until(result)` returns false; on exhaustion the last result is returned as-is.\n */\nexport interface IReadRetryOptions<TResult> {\n /** @default 3 */\n maxAttempts?: number;\n\n /** Total budget in ms across attempts AND sleeps. Unlimited when omitted. */\n maxTotalMs?: number;\n\n /**\n * Aborts between attempts and during backoff sleeps - pass the request signal so a cancelled\n * request stops retrying.\n */\n signal?: AbortSignal;\n\n /**\n * Backoff between attempts, tuned for replica lag.\n *\n * @default { strategy: RetryBackoffStrategies.EXPONENTIAL, initialDelayMs: 50, maxDelayMs: 500, jitter: RetryJitterModes.EQUAL }\n */\n backoff?: IRetryBackoffOptions;\n\n /**\n * Retry while false. With none given, `findOne` and `findById` retry on a null row and `find` on an empty list.\n */\n until?: (result: TResult) => boolean;\n}\n\n/**\n * Intersected into READ verb signatures only - a write verb's options type has no `retry`, so an\n * inline `{ retry }` fails to compile and a pre-built object carrying it is inert.\n */\nexport interface IWithReadRetry<TResult> {\n retry?: IReadRetryOptions<TResult>;\n}\n\n/** Options for `find` returning a plain array - the retry predicate sees `Array<R>`. */\nexport type TFindOptions<TOptions extends IExtraOptions, R> = TOptions & {\n shouldQueryRange?: false;\n} & IWithReadRetry<Array<R>>;\n\n/** Options for `find` with the range envelope - the retry predicate sees `{ data, range }`. */\nexport type TFindRangeOptions<TOptions extends IExtraOptions, R> = TOptions & {\n shouldQueryRange: true;\n} & IWithReadRetry<TDataWithRange<R>>;\n\n/** Options for `findOne`/`findById` - the retry predicate sees `TNullable<R>`. */\nexport type TFindOneOptions<TOptions extends IExtraOptions, R> = TOptions &\n IWithReadRetry<TNullable<R>>;\n"]}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../../../src/base/repositories/common/types/options.ts"],"names":[],"mappings":"","sourcesContent":["import type { ITransaction } from '@/base/datasources';\nimport type { IRetryBackoffOptions, TLogLevel } from '@venizia/ignis-helpers/core';\nimport type { TNullable } from '@venizia/ignis-helpers/common';\nimport type { SQL } from 'drizzle-orm';\nimport type { TLockStrength } from '../constants';\nimport type { TDataWithRange } from './results';\n\n/** Update data supporting both regular fields and JSON path updates via dot notation. */\nexport type TUpdateData<T = object> = Partial<T> & {\n [jsonPath: string]: unknown;\n};\n\n/** Options for Drizzle ORM query building, used internally by FilterBuilder. */\nexport type TDrizzleQueryOptions = Partial<{\n limit: number;\n offset: number;\n orderBy: SQL[];\n where: SQL;\n with: Record<string, true | TDrizzleQueryOptions>;\n columns: Record<string, boolean>;\n}>;\n\n/** Configuration for repository operation logging. */\nexport type TRepositoryLogOptions = {\n use: boolean;\n level?: TLogLevel;\n};\n\n/** Configuration for row-level lock wait behavior. Mutually exclusive: use noWait OR skipLocked. */\nexport type TLockConfig =\n | { noWait: true; skipLocked?: undefined }\n | { noWait?: undefined; skipLocked: true }\n | { noWait?: undefined; skipLocked?: undefined };\n\n/** Row-level locking options for read operations. */\nexport type TLockOptions = {\n strength: TLockStrength;\n config?: TLockConfig;\n};\n\n/** Neutral transaction association - postgres narrows to its own `IDatabaseTransaction` (via `isDatabaseTransaction`) where it needs `.connector`. */\nexport interface IWithTransaction {\n transaction?: ITransaction;\n}\n\n/** Extended options for repository operations with transaction, logging, and default filter bypass. */\nexport interface IExtraOptions extends IWithTransaction {\n log?: TRepositoryLogOptions;\n\n /** If true, bypass the default filter configured in model settings (e.g., soft delete). */\n shouldSkipDefaultFilter?: boolean;\n\n /** Row-level locking. Requires transaction. Incompatible with include/fields (Query API). */\n lock?: TLockOptions;\n}\n\n/**\n * Read-after-write retry for read verbs behind a replicated pool. The read re-executes while\n * `until(result)` returns false; on exhaustion the last result is returned as-is.\n */\nexport interface IReadRetryOptions<TResult> {\n /** @default 3 */\n maxAttempts?: number;\n\n /** Total budget in ms across attempts AND sleeps. Unlimited when omitted. */\n maxTotalMs?: number;\n\n /**\n * Aborts between attempts and during backoff sleeps - pass the request signal so a cancelled\n * request stops retrying.\n */\n signal?: AbortSignal;\n\n /**\n * Backoff between attempts, tuned for replica lag.\n *\n * @default { strategy: RetryBackoffStrategies.EXPONENTIAL, initialDelayMs: 50, maxDelayMs: 500, jitter: RetryJitterModes.EQUAL }\n */\n backoff?: IRetryBackoffOptions;\n\n /**\n * Retry while false. With none given, `findOne` and `findById` retry on a null row and `find` on an empty list.\n */\n until?: (result: TResult) => boolean;\n}\n\n/**\n * Intersected into READ verb signatures only - a write verb's options type has no `retry`, so an\n * inline `{ retry }` fails to compile and a pre-built object carrying it is inert.\n */\nexport interface IWithReadRetry<TResult> {\n retry?: IReadRetryOptions<TResult>;\n}\n\n/** Options for `find` returning a plain array - the retry predicate sees `Array<R>`. */\nexport type TFindOptions<TOptions extends IExtraOptions, R> = TOptions & {\n shouldQueryRange?: false;\n} & IWithReadRetry<Array<R>>;\n\n/** Options for `find` with the range envelope - the retry predicate sees `{ data, range }`. */\nexport type TFindRangeOptions<TOptions extends IExtraOptions, R> = TOptions & {\n shouldQueryRange: true;\n} & IWithReadRetry<TDataWithRange<R>>;\n\n/** Options for `findOne`/`findById` - the retry predicate sees `TNullable<R>`. */\nexport type TFindOneOptions<TOptions extends IExtraOptions, R> = TOptions &\n IWithReadRetry<TNullable<R>>;\n"]}
@@ -1,18 +1,9 @@
1
- import type { AnyType } from '@venizia/ignis-helpers/common';
2
- import type { Column, SQL } from 'drizzle-orm';
3
- /** Options passed to query operator handler functions. */
4
- export interface IQueryHandlerOptions<T = any> {
5
- column: Column;
1
+ import type { SQL, SQLWrapper } from 'drizzle-orm';
2
+ /** Options passed to query operator handler functions. `column` is a `Column` or, on the JSON-path branch, a raw `#>>` extraction expression: both are `SQLWrapper`. */
3
+ export interface IQueryHandlerOptions<T = unknown> {
4
+ column: SQLWrapper;
6
5
  value: T;
7
6
  }
8
- /**
9
- * Operator-name to SQL-handler table a relational dialect translates with, so a second SQL engine
10
- * swaps the whole table without touching the walk that reaches it. `column` is wider than
11
- * `IQueryHandlerOptions` names it: the JSON-path branch hands handlers a raw `#>>` extraction
12
- * expression, not a `Column`.
13
- */
14
- export type TQueryOperatorHandlers = Record<string, (opts: {
15
- column: AnyType;
16
- value: AnyType;
17
- }) => SQL | undefined>;
7
+ /** Operator-name to SQL-handler table a relational dialect translates with, so a second SQL engine swaps the whole table without touching the walk that reaches it. */
8
+ export type TQueryOperatorHandlers = Record<string, (opts: IQueryHandlerOptions) => SQL | undefined>;
18
9
  //# sourceMappingURL=query.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../../../src/base/repositories/common/types/query.ts"],"names":[],"mappings":"","sourcesContent":["import type { AnyType } from '@venizia/ignis-helpers/common';\nimport type { Column, SQL } from 'drizzle-orm';\n\n/** Options passed to query operator handler functions. */\nexport interface IQueryHandlerOptions<T = any> {\n column: Column;\n value: T;\n}\n\n/**\n * Operator-name to SQL-handler table a relational dialect translates with, so a second SQL engine\n * swaps the whole table without touching the walk that reaches it. `column` is wider than\n * `IQueryHandlerOptions` names it: the JSON-path branch hands handlers a raw `#>>` extraction\n * expression, not a `Column`.\n */\nexport type TQueryOperatorHandlers = Record<\n string,\n (opts: { column: AnyType; value: AnyType }) => SQL | undefined\n>;\n"]}
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../../../src/base/repositories/common/types/query.ts"],"names":[],"mappings":"","sourcesContent":["import type { SQL, SQLWrapper } from 'drizzle-orm';\n\n/** Options passed to query operator handler functions. `column` is a `Column` or, on the JSON-path branch, a raw `#>>` extraction expression: both are `SQLWrapper`. */\nexport interface IQueryHandlerOptions<T = unknown> {\n column: SQLWrapper;\n value: T;\n}\n\n/** Operator-name to SQL-handler table a relational dialect translates with, so a second SQL engine swaps the whole table without touching the walk that reaches it. */\nexport type TQueryOperatorHandlers = Record<\n string,\n (opts: IQueryHandlerOptions) => SQL | undefined\n>;\n"]}
@@ -1,8 +1,15 @@
1
1
  import { QuerySchemaFactory } from '@venizia/ignis-filter/schemas';
2
2
  /** Load order is the point: `@hono/zod-openapi` peers on `zod`, so importing it patches `.openapi()` onto the shared `ZodType` prototype. `QuerySchemaFactory.build` runs at module scope below, and ESM evaluates imports first, so the method exists by the time the decorator is called. Without this import the schemas silently build undecorated whenever this module happens to load before anything else pulls in the OpenAPI layer. */
3
3
  import { z } from '@hono/zod-openapi';
4
+ import { getError } from '@venizia/ignis-helpers/core';
4
5
  /** The schemas themselves live in `@venizia/ignis-filter`, built with plain `zod` so a browser can use them. Documentation metadata is injected here because it is a server concern - `.openapi()` returns a new schema rather than mutating, and three of the decorations sit on inner nodes, so they cannot be applied after the tree is composed. */
5
6
  const openApiDecorator = (schema, metadata) => {
7
+ // `.openapi` is patched onto the zod prototype this module loaded; a schema from another copy of zod has none.
8
+ if (!(schema instanceof z.ZodType) || typeof Reflect.get(schema, 'openapi') !== 'function') {
9
+ throw getError({
10
+ message: '[openApiDecorator] Only a zod schema carrying .openapi() can take OpenAPI metadata | Pass a schema built with the zod copy @hono/zod-openapi extends',
11
+ });
12
+ }
6
13
  return schema.openapi(metadata);
7
14
  };
8
15
  const schemas = QuerySchemaFactory.build({ decorate: openApiDecorator });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/base/repositories/query-schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAyB,MAAM,+BAA+B,CAAC;AAE1F,gbAAgb;AAChb,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,wVAAwV;AACxV,MAAM,gBAAgB,GAAqB,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;IAC9D,OAAQ,MAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAEzE,+EAA+E;AAC/E,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;AAEjD,6HAA6H;AAC7H,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;AAEjD,iGAAiG;AACjG,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;AAEvD,sDAAsD;AACtD,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;AAE/C,wDAAwD;AACxD,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;AAEjD,iEAAiE;AACjE,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;AAEnD,sDAAsD;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;AAE7C,4CAA4C;AAC5C,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;AAE/C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC;IAC1E,WAAW,EAAE,wDAAwD;CACtE,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC;IAClF,WAAW,EAAE,mBAAmB;CACjC,CAAC,CAAC","sourcesContent":["import { QuerySchemaFactory, type TSchemaDecorator } from '@venizia/ignis-filter/schemas';\n\n/** Load order is the point: `@hono/zod-openapi` peers on `zod`, so importing it patches `.openapi()` onto the shared `ZodType` prototype. `QuerySchemaFactory.build` runs at module scope below, and ESM evaluates imports first, so the method exists by the time the decorator is called. Without this import the schemas silently build undecorated whenever this module happens to load before anything else pulls in the OpenAPI layer. */\nimport { z } from '@hono/zod-openapi';\n\n/** The schemas themselves live in `@venizia/ignis-filter`, built with plain `zod` so a browser can use them. Documentation metadata is injected here because it is a server concern - `.openapi()` returns a new schema rather than mutating, and three of the decorations sit on inner nodes, so they cannot be applied after the tree is composed. */\nconst openApiDecorator: TSchemaDecorator = (schema, metadata) => {\n return (schema as any).openapi(metadata);\n};\n\nconst schemas = QuerySchemaFactory.build({ decorate: openApiDecorator });\n\n/** Selected fields: an array of names to include, or a name-to-boolean map. */\nexport const FieldsSchema = schemas.FieldsSchema;\n\n/** The whole `filter` query: an object of where, fields, include, order, limit, offset and skip, or a JSON string of one. */\nexport const FilterSchema = schemas.FilterSchema;\n\n/** Relations to include: an array of `{ relation, scope? }` where `scope` is a nested filter. */\nexport const InclusionSchema = schemas.InclusionSchema;\n\n/** Maximum number of rows; a non-negative integer. */\nexport const LimitSchema = schemas.LimitSchema;\n\n/** Number of rows to offset; a non-negative integer. */\nexport const OffsetSchema = schemas.OffsetSchema;\n\n/** Sort order: an array of strings such as `'createdAt ASC'`. */\nexport const OrderBySchema = schemas.OrderBySchema;\n\n/** Number of rows to skip; a non-negative integer. */\nexport const SkipSchema = schemas.SkipSchema;\n\n/** Query conditions, with nested AND/OR. */\nexport const WhereSchema = schemas.WhereSchema;\n\n/**\n * The query shape of a route that accepts a `filter`. The framework's own `find`, `findById` and\n * `findOne` use it, and a hand-written route gets the same contract by naming it.\n *\n * `filter` needs no `.optional()` at the call site - {@link FilterSchema} already carries one, so a\n * second is a no-op and so is a trailing `.partial()`.\n *\n * Extend it rather than rebuilding it when a route takes more than `filter`:\n * `FilterQuerySchema.extend({ q: z.string().optional() })`.\n */\nexport const FilterQuerySchema = z.object({ filter: FilterSchema }).openapi({\n description: 'Filter with where, fields, limit, skip, order, include',\n});\n\n/**\n * The query shape of a route that accepts conditions and nothing else - `count` and anything shaped\n * like it. `where` is OPTIONAL here.\n *\n * `updateBy` and `deleteBy` deliberately do not use this. Their `where` is optional in the query\n * because it may ride in the body instead; the handler refuses a request that carries it in neither\n * place - a missing one there rewrites or deletes every row in the table.\n */\nexport const WhereQuerySchema = z.object({ where: WhereSchema.optional() }).openapi({\n description: 'Filter conditions',\n});\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/base/repositories/query-schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAyB,MAAM,+BAA+B,CAAC;AAE1F,gbAAgb;AAChb,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,wVAAwV;AACxV,MAAM,gBAAgB,GAAqB,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;IAC9D,+GAA+G;IAC/G,I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AAG,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC;IAClF,WAAW,EAAE,mBAAmB;CACjC,CAAC,CAAC","sourcesContent":["import { QuerySchemaFactory, type TSchemaDecorator } from '@venizia/ignis-filter/schemas';\n\n/** Load order is the point: `@hono/zod-openapi` peers on `zod`, so importing it patches `.openapi()` onto the shared `ZodType` prototype. `QuerySchemaFactory.build` runs at module scope below, and ESM evaluates imports first, so the method exists by the time the decorator is called. Without this import the schemas silently build undecorated whenever this module happens to load before anything else pulls in the OpenAPI layer. */\nimport { z } from '@hono/zod-openapi';\nimport { getError } from '@venizia/ignis-helpers/core';\n\n/** The schemas themselves live in `@venizia/ignis-filter`, built with plain `zod` so a browser can use them. Documentation metadata is injected here because it is a server concern - `.openapi()` returns a new schema rather than mutating, and three of the decorations sit on inner nodes, so they cannot be applied after the tree is composed. */\nconst openApiDecorator: TSchemaDecorator = (schema, metadata) => {\n // `.openapi` is patched onto the zod prototype this module loaded; a schema from another copy of zod has none.\n if (!(schema instanceof z.ZodType) || typeof Reflect.get(schema, 'openapi') !== 'function') {\n throw getError({\n message:\n '[openApiDecorator] Only a zod schema carrying .openapi() can take OpenAPI metadata | Pass a schema built with the zod copy @hono/zod-openapi extends',\n });\n }\n\n return schema.openapi(metadata);\n};\n\nconst schemas = QuerySchemaFactory.build({ decorate: openApiDecorator });\n\n/** Selected fields: an array of names to include, or a name-to-boolean map. */\nexport const FieldsSchema = schemas.FieldsSchema;\n\n/** The whole `filter` query: an object of where, fields, include, order, limit, offset and skip, or a JSON string of one. */\nexport const FilterSchema = schemas.FilterSchema;\n\n/** Relations to include: an array of `{ relation, scope? }` where `scope` is a nested filter. */\nexport const InclusionSchema = schemas.InclusionSchema;\n\n/** Maximum number of rows; a non-negative integer. */\nexport const LimitSchema = schemas.LimitSchema;\n\n/** Number of rows to offset; a non-negative integer. */\nexport const OffsetSchema = schemas.OffsetSchema;\n\n/** Sort order: an array of strings such as `'createdAt ASC'`. */\nexport const OrderBySchema = schemas.OrderBySchema;\n\n/** Number of rows to skip; a non-negative integer. */\nexport const SkipSchema = schemas.SkipSchema;\n\n/** Query conditions, with nested AND/OR. */\nexport const WhereSchema = schemas.WhereSchema;\n\n/**\n * The query shape of a route that accepts a `filter`. The framework's own `find`, `findById` and\n * `findOne` use it, and a hand-written route gets the same contract by naming it.\n *\n * `filter` needs no `.optional()` at the call site - {@link FilterSchema} already carries one, so a\n * second is a no-op and so is a trailing `.partial()`.\n *\n * Extend it rather than rebuilding it when a route takes more than `filter`:\n * `FilterQuerySchema.extend({ q: z.string().optional() })`.\n */\nexport const FilterQuerySchema = z.object({ filter: FilterSchema }).openapi({\n description: 'Filter with where, fields, limit, skip, order, include',\n});\n\n/**\n * The query shape of a route that accepts conditions and nothing else - `count` and anything shaped\n * like it. `where` is OPTIONAL here.\n *\n * `updateBy` and `deleteBy` deliberately do not use this. Their `where` is optional in the query\n * because it may ride in the body instead; the handler refuses a request that carries it in neither\n * place - a missing one there rewrites or deletes every row in the table.\n */\nexport const WhereQuerySchema = z.object({ where: WhereSchema.optional() }).openapi({\n description: 'Filter conditions',\n});\n"]}
@@ -26,12 +26,12 @@ export declare const ArtifactMetadataMixin: <BaseClass extends TMixinTarget<_Met
26
26
  getProvideMetadata<Target extends object = object>(opts: {
27
27
  target: Target;
28
28
  }): IProvideMetadata[];
29
- define: <Target extends object = object, Value = any>(opts: {
29
+ define: <Target extends object = object, Value = unknown>(opts: {
30
30
  target: Target;
31
31
  key: import("@venizia/ignis-inversion").TBindingKey;
32
32
  value: Value;
33
33
  }) => void;
34
- get: <Target extends object = object, Value_1 = any>(opts: {
34
+ get: <Target extends object = object, Value_1 = unknown>(opts: {
35
35
  target: Target;
36
36
  key: import("@venizia/ignis-inversion").TBindingKey;
37
37
  }) => Value_1 | undefined;
@@ -46,7 +46,7 @@ export declare const ArtifactMetadataMixin: <BaseClass extends TMixinTarget<_Met
46
46
  getKeys: <Target extends object = object>(opts: {
47
47
  target: Target;
48
48
  }) => import("@venizia/ignis-inversion").TBindingKey[];
49
- getMethodNames: <T = any>(opts: {
49
+ getMethodNames: <T = unknown>(opts: {
50
50
  target: import("@venizia/ignis-inversion").TClass<T>;
51
51
  }) => string[];
52
52
  clearMetadata: <T extends object = object>(opts: {
@@ -17,12 +17,12 @@ export declare const ControllerMetadataMixin: <BaseClass extends TMixinTarget<_M
17
17
  getGrpcControllerMetadata<Target extends object = object>(opts: {
18
18
  target: Target;
19
19
  }): IGrpcControllerMetadata | undefined;
20
- define: <Target extends object = object, Value = any>(opts: {
20
+ define: <Target extends object = object, Value = unknown>(opts: {
21
21
  target: Target;
22
22
  key: import("@venizia/ignis-inversion").TBindingKey;
23
23
  value: Value;
24
24
  }) => void;
25
- get: <Target extends object = object, Value_1 = any>(opts: {
25
+ get: <Target extends object = object, Value_1 = unknown>(opts: {
26
26
  target: Target;
27
27
  key: import("@venizia/ignis-inversion").TBindingKey;
28
28
  }) => Value_1 | undefined;
@@ -37,7 +37,7 @@ export declare const ControllerMetadataMixin: <BaseClass extends TMixinTarget<_M
37
37
  getKeys: <Target extends object = object>(opts: {
38
38
  target: Target;
39
39
  }) => import("@venizia/ignis-inversion").TBindingKey[];
40
- getMethodNames: <T = any>(opts: {
40
+ getMethodNames: <T = unknown>(opts: {
41
41
  target: import("@venizia/ignis-inversion").TClass<T>;
42
42
  }) => string[];
43
43
  clearMetadata: <T extends object = object>(opts: {
@@ -19,12 +19,12 @@ export declare const GrpcControllerMetadataMixin: <BaseClass extends TMixinTarge
19
19
  hasRpcs<Target extends object = object>(opts: {
20
20
  target: Target;
21
21
  }): boolean;
22
- define: <Target extends object = object, Value = any>(opts: {
22
+ define: <Target extends object = object, Value = unknown>(opts: {
23
23
  target: Target;
24
24
  key: import("@venizia/ignis-inversion").TBindingKey;
25
25
  value: Value;
26
26
  }) => void;
27
- get: <Target extends object = object, Value_1 = any>(opts: {
27
+ get: <Target extends object = object, Value_1 = unknown>(opts: {
28
28
  target: Target;
29
29
  key: import("@venizia/ignis-inversion").TBindingKey;
30
30
  }) => Value_1 | undefined;
@@ -39,7 +39,7 @@ export declare const GrpcControllerMetadataMixin: <BaseClass extends TMixinTarge
39
39
  getKeys: <Target extends object = object>(opts: {
40
40
  target: Target;
41
41
  }) => import("@venizia/ignis-inversion").TBindingKey[];
42
- getMethodNames: <T = any>(opts: {
42
+ getMethodNames: <T = unknown>(opts: {
43
43
  target: import("@venizia/ignis-inversion").TClass<T>;
44
44
  }) => string[];
45
45
  clearMetadata: <T extends object = object>(opts: {
@@ -19,12 +19,12 @@ export declare const RestControllerMetadataMixin: <BaseClass extends TMixinTarge
19
19
  methodName: string | symbol;
20
20
  configs: IAuthRouteConfig;
21
21
  }): void;
22
- define: <Target extends object = object, Value = any>(opts: {
22
+ define: <Target extends object = object, Value = unknown>(opts: {
23
23
  target: Target;
24
24
  key: import("@venizia/ignis-inversion").TBindingKey;
25
25
  value: Value;
26
26
  }) => void;
27
- get: <Target extends object = object, Value_1 = any>(opts: {
27
+ get: <Target extends object = object, Value_1 = unknown>(opts: {
28
28
  target: Target;
29
29
  key: import("@venizia/ignis-inversion").TBindingKey;
30
30
  }) => Value_1 | undefined;
@@ -39,7 +39,7 @@ export declare const RestControllerMetadataMixin: <BaseClass extends TMixinTarge
39
39
  getKeys: <Target extends object = object>(opts: {
40
40
  target: Target;
41
41
  }) => import("@venizia/ignis-inversion").TBindingKey[];
42
- getMethodNames: <T = any>(opts: {
42
+ getMethodNames: <T = unknown>(opts: {
43
43
  target: import("@venizia/ignis-inversion").TClass<T>;
44
44
  }) => string[];
45
45
  clearMetadata: <T extends object = object>(opts: {
@@ -11,12 +11,12 @@ export declare const DatasourceMetadataMixin: <BaseClass extends TMixinTarget<_M
11
11
  getDataSourceMetadata<Target extends object = object>(opts: {
12
12
  target: Target;
13
13
  }): IDataSourceMetadata | undefined;
14
- define: <Target extends object = object, Value = any>(opts: {
14
+ define: <Target extends object = object, Value = unknown>(opts: {
15
15
  target: Target;
16
16
  key: import("@venizia/ignis-inversion").TBindingKey;
17
17
  value: Value;
18
18
  }) => void;
19
- get: <Target extends object = object, Value_1 = any>(opts: {
19
+ get: <Target extends object = object, Value_1 = unknown>(opts: {
20
20
  target: Target;
21
21
  key: import("@venizia/ignis-inversion").TBindingKey;
22
22
  }) => Value_1 | undefined;
@@ -31,7 +31,7 @@ export declare const DatasourceMetadataMixin: <BaseClass extends TMixinTarget<_M
31
31
  getKeys: <Target extends object = object>(opts: {
32
32
  target: Target;
33
33
  }) => import("@venizia/ignis-inversion").TBindingKey[];
34
- getMethodNames: <T = any>(opts: {
34
+ getMethodNames: <T = unknown>(opts: {
35
35
  target: import("@venizia/ignis-inversion").TClass<T>;
36
36
  }) => string[];
37
37
  clearMetadata: <T extends object = object>(opts: {
@@ -50,12 +50,12 @@ export declare const ModelMetadataMixin: <BaseClass extends TMixinTarget<_Metada
50
50
  authorize: IModelAuthorizeSettings;
51
51
  entry: IModelRegistryEntry;
52
52
  }>;
53
- define: <Target extends object = object, Value = any>(opts: {
53
+ define: <Target extends object = object, Value = unknown>(opts: {
54
54
  target: Target;
55
55
  key: import("@venizia/ignis-inversion").TBindingKey;
56
56
  value: Value;
57
57
  }) => void;
58
- get: <Target extends object = object, Value_1 = any>(opts: {
58
+ get: <Target extends object = object, Value_1 = unknown>(opts: {
59
59
  target: Target;
60
60
  key: import("@venizia/ignis-inversion").TBindingKey;
61
61
  }) => Value_1 | undefined;
@@ -70,7 +70,7 @@ export declare const ModelMetadataMixin: <BaseClass extends TMixinTarget<_Metada
70
70
  getKeys: <Target extends object = object>(opts: {
71
71
  target: Target;
72
72
  }) => import("@venizia/ignis-inversion").TBindingKey[];
73
- getMethodNames: <T = any>(opts: {
73
+ getMethodNames: <T = unknown>(opts: {
74
74
  target: import("@venizia/ignis-inversion").TClass<T>;
75
75
  }) => string[];
76
76
  clearMetadata: <T extends object = object>(opts: {
@@ -1,7 +1,7 @@
1
1
  import 'reflect-metadata';
2
2
  import type { IDataSource } from '../../../base/datasources/index.js';
3
3
  import type { AbstractEntity } from '../../../base/models/index.js';
4
- import type { AnyType, TClass, TMixinTarget } from '@venizia/ignis-helpers/common';
4
+ import type { TClass, TMixinTarget } from '@venizia/ignis-helpers/common';
5
5
  import type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';
6
6
  import type { IModelMetadata, IModelRegistryEntry, IRepositoryBinding, IResolvedRepositoryMetadata, TRepositoryMetadata } from '../common/types/index.js';
7
7
  export declare const RepositoryMetadataMixin: <BaseClass extends TMixinTarget<_MetadataRegistry & {
@@ -20,7 +20,7 @@ export declare const RepositoryMetadataMixin: <BaseClass extends TMixinTarget<_M
20
20
  * repository named it with (`dataSource: 'PgDataSource'`), which only a class of that name
21
21
  * can match. Never by class name alone: a minified build gives two datasources one name.
22
22
  */
23
- datasourceModels: Map<string | Function, Set<TClass<AnyType>>>;
23
+ datasourceModels: Map<string | Function, Set<TClass<unknown>>>;
24
24
  setRepositoryMetadata<Target extends object = object, Model extends AbstractEntity = AbstractEntity<unknown>, DataSource extends IDataSource = IDataSource<{}, import("../../../base/datasources/index.js").TAnyDataSourceSchema, {}>>(opts: {
25
25
  target: Target;
26
26
  metadata: TRepositoryMetadata<Model, DataSource> & {
@@ -43,13 +43,13 @@ export declare const RepositoryMetadataMixin: <BaseClass extends TMixinTarget<_M
43
43
  /** A class finds what was registered under it, and under a string equal to its name. */
44
44
  getDataSourceModelClasses(opts: {
45
45
  dataSource: string | TClass<IDataSource>;
46
- }): Set<TClass<AnyType>>;
46
+ }): Set<TClass<unknown>>;
47
47
  /**
48
48
  * Resolves and caches relations for a model entry - called lazily from buildSchema() so that
49
49
  * every `@model` class is registered first, which avoids circular-dependency ordering issues.
50
50
  * @internal
51
51
  */
52
- resolveModelRelations(modelMeta: IModelRegistryEntry): unknown;
52
+ resolveModelRelations(modelMeta: Pick<IModelRegistryEntry, "schema" | "relationsResolver" | "_builtRelations">): unknown;
53
53
  /**
54
54
  * Models registered for a datasource, relations resolved lazily. `schema`/`relations` stay
55
55
  * `unknown` - the registry is shared across connectors, so each connector narrows at its call
@@ -71,7 +71,7 @@ export declare const RepositoryMetadataMixin: <BaseClass extends TMixinTarget<_M
71
71
  }): Array<TClass<unknown>>;
72
72
  /** The key a model occupies in `modelRegistry` - its table name, or its class name when it has none. */
73
73
  resolveModelKey(opts: {
74
- modelClass: TClass<AnyType>;
74
+ modelClass: TClass<unknown>;
75
75
  }): string;
76
76
  /** Assembles table schemas + relations for a datasource's registered models. */
77
77
  buildSchema(opts: {
@@ -83,12 +83,12 @@ export declare const RepositoryMetadataMixin: <BaseClass extends TMixinTarget<_M
83
83
  hasModels(opts: {
84
84
  dataSource: string | TClass<IDataSource>;
85
85
  }): boolean;
86
- define: <Target extends object = object, Value = any>(opts: {
86
+ define: <Target extends object = object, Value = unknown>(opts: {
87
87
  target: Target;
88
88
  key: import("@venizia/ignis-inversion").TBindingKey;
89
89
  value: Value;
90
90
  }) => void;
91
- get: <Target extends object = object, Value_1 = any>(opts: {
91
+ get: <Target extends object = object, Value_1 = unknown>(opts: {
92
92
  target: Target;
93
93
  key: import("@venizia/ignis-inversion").TBindingKey;
94
94
  }) => Value_1 | undefined;
@@ -103,7 +103,7 @@ export declare const RepositoryMetadataMixin: <BaseClass extends TMixinTarget<_M
103
103
  getKeys: <Target extends object = object>(opts: {
104
104
  target: Target;
105
105
  }) => import("@venizia/ignis-inversion").TBindingKey[];
106
- getMethodNames: <T = any>(opts: {
106
+ getMethodNames: <T = unknown>(opts: {
107
107
  target: import("@venizia/ignis-inversion").TClass<T>;
108
108
  }) => string[];
109
109
  clearMetadata: <T extends object = object>(opts: {
@@ -92,11 +92,10 @@ export const RepositoryMetadataMixin = (baseClass) => {
92
92
  // Read straight off the class: a class -> name -> modelRegistry round-trip collapses two
93
93
  // same-named models onto one entry, silently swapping schemas. `modelRegistry` stays
94
94
  // name-keyed for the by-name APIs that need it.
95
+ const statics = modelClass;
95
96
  const entry = {
96
- target: modelClass,
97
- metadata: this.getModelMetadata({ target: modelClass }) ?? { settings: {} },
98
- schema: modelClass.schema,
99
- relationsResolver: modelClass.relations,
97
+ schema: statics.schema,
98
+ relationsResolver: statics.relations,
100
99
  };
101
100
  if (entry.schema === undefined) {
102
101
  return null;
@@ -125,8 +124,8 @@ export const RepositoryMetadataMixin = (baseClass) => {
125
124
  resolveModelKey(opts) {
126
125
  const { modelClass } = opts;
127
126
  const modelMetadata = this.getModelMetadata({ target: modelClass });
128
- return ([modelMetadata?.tableName, modelClass.TABLE_NAME].find(Boolean) ??
129
- modelClass.name);
127
+ const statics = modelClass;
128
+ return [modelMetadata?.tableName, statics.TABLE_NAME].find(Boolean) ?? modelClass.name;
130
129
  }
131
130
  /** Assembles table schemas + relations for a datasource's registered models. */
132
131
  buildSchema(opts) {
@@ -1 +1 @@
1
- {"version":3,"file":"repository.mixin.js","sourceRoot":"","sources":["../../../../../src/helpers/inversion/mixins/repository.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAK1B,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AASrE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAQrC,SAAoB,EACpB,EAAE;IACF,OAAO,KAAM,SAAQ,SAAS;QAc5B,qBAAqB,CAInB,IAKD;YACC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;YAClC,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QACpE,CAAC;QAED,qBAAqB,CAAiC,IAErD;YACC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;YAExB,OAAO,OAAO,CAA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AC,SAAS,CAAC;gBAChE,CAAC;YACH,CAAC;YAED,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,SAAS,CAAC,IAAkD;YAC1D,OAAO,IAAI,CAAC,yBAAyB,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;QAClF,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import 'reflect-metadata';\n\nimport type { IDataSource } from '@/base/datasources';\nimport type { AbstractEntity } from '@/base/models';\nimport type { AnyType, TClass, TMixinTarget } from '@venizia/ignis-helpers/common';\nimport { ResolverUtility } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';\nimport { MetadataKeys } from '../common/keys';\nimport { RelationBuilderRegistry } from '../common/relation-builder';\nimport type {\n IModelMetadata,\n IModelRegistryEntry,\n IRepositoryBinding,\n IResolvedRepositoryMetadata,\n TRepositoryMetadata,\n} from '../common/types';\n\nexport const RepositoryMetadataMixin = <\n BaseClass extends TMixinTarget<\n _MetadataRegistry & {\n modelRegistry: Map<string, IModelRegistryEntry>;\n getModelMetadata(opts: { target: object }): IModelMetadata | undefined;\n }\n >,\n>(\n baseClass: BaseClass,\n) => {\n return class extends baseClass {\n /** By repository class name, for the by-name API. Two classes may share a name; `repositoryBindingsByClass` cannot confuse them. */\n repositoryBindings: Map<string, IRepositoryBinding<AbstractEntity>>;\n\n /** By repository class: a minified build renames classes, and two chunks may give two of them one name. */\n repositoryBindingsByClass: Map<Function, IRepositoryBinding<AbstractEntity>>;\n\n /**\n * The model classes each datasource owns, keyed by the datasource class - or by the string a\n * repository named it with (`dataSource: 'PgDataSource'`), which only a class of that name\n * can match. Never by class name alone: a minified build gives two datasources one name.\n */\n datasourceModels: Map<string | Function, Set<TClass<AnyType>>>;\n\n setRepositoryMetadata<\n Target extends object = object,\n Model extends AbstractEntity = AbstractEntity,\n DataSource extends IDataSource = IDataSource,\n >(opts: {\n target: Target;\n metadata: TRepositoryMetadata<Model, DataSource> & {\n _resolved?: IResolvedRepositoryMetadata<Model, DataSource>;\n };\n }): void {\n const { target, metadata } = opts;\n Reflect.defineMetadata(MetadataKeys.REPOSITORY, metadata, target);\n }\n\n getRepositoryMetadata<Target extends object = object>(opts: {\n target: Target;\n }): (TRepositoryMetadata & { _resolved?: IResolvedRepositoryMetadata }) | undefined {\n const { target } = opts;\n\n return Reflect.getMetadata(MetadataKeys.REPOSITORY, target);\n }\n\n /** Registers a repository binding (called by @repository) linking a repository to its model + datasource. */\n registerRepositoryBinding<\n Model extends AbstractEntity = AbstractEntity,\n DataSource extends IDataSource = IDataSource,\n >(opts: IRepositoryBinding<Model, DataSource>) {\n // Every member of the binding may be a resolver, the escape hatch for circular imports.\n // Reading `.name` off the resolver keys the registry by the arrow's inferred name, and the\n // datasource then silently discovers no schema.\n const repositoryClass = ResolverUtility.resolveValue({ value: opts.repository });\n this.repositoryBindings.set(repositoryClass.name, opts);\n this.repositoryBindingsByClass.set(repositoryClass, opts);\n\n const dataSourceRef = ResolverUtility.resolveValue({ value: opts.dataSource });\n const modelClass = ResolverUtility.resolveValue({ value: opts.model });\n\n if (!this.datasourceModels.has(dataSourceRef)) {\n this.datasourceModels.set(dataSourceRef, new Set());\n }\n\n this.datasourceModels.get(dataSourceRef)!.add(modelClass);\n }\n\n /** By class, walking up to the nearest decorated parent; by name only for callers holding a name. */\n getRepositoryBinding(\n opts: { target: Function } | { name: string },\n ): IRepositoryBinding<AbstractEntity> | undefined {\n if ('name' in opts) {\n return this.repositoryBindings.get(opts.name);\n }\n\n for (\n let current: Function | null = opts.target;\n current && current !== Function.prototype;\n current = Object.getPrototypeOf(current)\n ) {\n const binding = this.repositoryBindingsByClass.get(current);\n\n if (binding) {\n return binding;\n }\n }\n\n return undefined;\n }\n\n /** A class finds what was registered under it, and under a string equal to its name. */\n getDataSourceModelClasses(opts: {\n dataSource: string | TClass<IDataSource>;\n }): Set<TClass<AnyType>> {\n const { dataSource } = opts;\n\n if (typeof dataSource === 'string') {\n return this.datasourceModels.get(dataSource) ?? new Set();\n }\n\n return new Set([\n ...(this.datasourceModels.get(dataSource) ?? []),\n ...(this.datasourceModels.get(dataSource.name) ?? []),\n ]);\n }\n\n /**\n * Resolves and caches relations for a model entry - called lazily from buildSchema() so that\n * every `@model` class is registered first, which avoids circular-dependency ordering issues.\n * @internal\n */\n resolveModelRelations(modelMeta: IModelRegistryEntry): unknown {\n if (modelMeta._builtRelations !== undefined) {\n return modelMeta._builtRelations;\n }\n\n if (!modelMeta.relationsResolver) {\n return undefined;\n }\n\n const relations = ResolverUtility.resolveValue({ value: modelMeta.relationsResolver });\n\n if (!relations || !modelMeta.schema) {\n return undefined;\n }\n\n const builder = RelationBuilderRegistry.resolve();\n\n // Relations were declared but no connector installed a builder - silently dropping them\n // would surface much later as an empty `with` clause.\n if (!builder) {\n throw getError({\n message: `[RepositoryMetadataMixin][resolveModelRelations] Model declares relations but no relation builder is registered | Import the relational connector so it installs one`,\n });\n }\n\n const builtRelations = builder({ source: modelMeta.schema, relations });\n\n modelMeta._builtRelations = builtRelations?.relations;\n\n return modelMeta._builtRelations;\n }\n\n /**\n * Models registered for a datasource, relations resolved lazily. `schema`/`relations` stay\n * `unknown` - the registry is shared across connectors, so each connector narrows at its call\n * site.\n */\n getModels(opts: { dataSource: string | TClass<IDataSource> }): Array<{\n tableName: string;\n schema: unknown;\n relations?: unknown;\n }> {\n const modelClasses = this.getDataSourceModelClasses({ dataSource: opts.dataSource });\n\n const rs = Array.from(modelClasses)\n .map((modelClass) => {\n // Read straight off the class: a class -> name -> modelRegistry round-trip collapses two\n // same-named models onto one entry, silently swapping schemas. `modelRegistry` stays\n // name-keyed for the by-name APIs that need it.\n const entry: IModelRegistryEntry = {\n target: modelClass as AnyType,\n metadata:\n this.getModelMetadata({ target: modelClass }) ?? ({ settings: {} } as AnyType),\n schema: (modelClass as AnyType).schema,\n relationsResolver: (modelClass as AnyType).relations,\n };\n\n if (entry.schema === undefined) {\n return null;\n }\n\n return {\n tableName: this.resolveModelKey({ modelClass }),\n schema: entry.schema,\n relations: this.resolveModelRelations(entry),\n };\n })\n .filter((item): item is NonNullable<typeof item> => {\n return item !== undefined && item !== null;\n });\n\n return rs;\n }\n\n /**\n * Like getModels but returns only resolved model classes - used by BaseSearchDataSource, which\n * has no pgTable to resolve.\n */\n getModelClasses(opts: { dataSource: string | TClass<IDataSource> }): Array<TClass<unknown>> {\n // Straight from the stored class refs: a name round-trip through the shared modelRegistry\n // would hand back whichever same-named class registered last.\n return Array.from(this.getDataSourceModelClasses({ dataSource: opts.dataSource }));\n }\n\n /** The key a model occupies in `modelRegistry` - its table name, or its class name when it has none. */\n resolveModelKey(opts: { modelClass: TClass<AnyType> }): string {\n const { modelClass } = opts;\n const modelMetadata = this.getModelMetadata({ target: modelClass });\n\n return (\n [modelMetadata?.tableName, (modelClass as AnyType).TABLE_NAME].find(Boolean) ??\n modelClass.name\n );\n }\n\n /** Assembles table schemas + relations for a datasource's registered models. */\n buildSchema(opts: { dataSource: string | TClass<IDataSource> }): {\n schema: Record<string, unknown>;\n relations: Record<string, unknown>;\n } {\n const { dataSource } = opts;\n const models = this.getModels({ dataSource });\n\n const rs: {\n schema: Record<string, unknown>;\n relations: Record<string, unknown>;\n } = { schema: {}, relations: {} };\n\n for (const model of models) {\n if (model.schema) {\n rs.schema[model.tableName] = model.schema;\n }\n\n if (model.relations) {\n rs.relations[`${model.tableName}Relations`] = model.relations;\n }\n }\n\n return rs;\n }\n\n hasModels(opts: { dataSource: string | TClass<IDataSource> }): boolean {\n return this.getDataSourceModelClasses({ dataSource: opts.dataSource }).size > 0;\n }\n };\n};\n"]}
1
+ {"version":3,"file":"repository.mixin.js","sourceRoot":"","sources":["../../../../../src/helpers/inversion/mixins/repository.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAK1B,OAAO,EAAE,eAAe,EAAE,MA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GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;YAE9C,MAAM,EAAE,GAGJ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;YAElC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC3B,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;oBACjB,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;gBAC5C,CAAC;gBAED,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;oBACpB,EAAE,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,SAAS,WAAW,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;gBAChE,CAAC;YACH,CAAC;YAED,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,SAAS,CAAC,IAAkD;YAC1D,OAAO,IAAI,CAAC,yBAAyB,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;QAClF,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import 'reflect-metadata';\n\nimport type { IDataSource } from '@/base/datasources';\nimport type { AbstractEntity } from '@/base/models';\nimport type { TClass, TMixinTarget } from '@venizia/ignis-helpers/common';\nimport { ResolverUtility } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';\nimport { MetadataKeys } from '../common/keys';\nimport { RelationBuilderRegistry } from '../common/relation-builder';\nimport type {\n IEntityStatics,\n IModelMetadata,\n IModelRegistryEntry,\n IRepositoryBinding,\n IResolvedRepositoryMetadata,\n TRepositoryMetadata,\n} from '../common/types';\n\n/** A model class read for the statics `@model` entities carry; each is optional, so any class fits. */\ntype TStaticReadableModelClass = TClass<unknown> & IEntityStatics & { TABLE_NAME?: string };\n\nexport const RepositoryMetadataMixin = <\n BaseClass extends TMixinTarget<\n _MetadataRegistry & {\n modelRegistry: Map<string, IModelRegistryEntry>;\n getModelMetadata(opts: { target: object }): IModelMetadata | undefined;\n }\n >,\n>(\n baseClass: BaseClass,\n) => {\n return class extends baseClass {\n /** By repository class name, for the by-name API. Two classes may share a name; `repositoryBindingsByClass` cannot confuse them. */\n repositoryBindings: Map<string, IRepositoryBinding<AbstractEntity>>;\n\n /** By repository class: a minified build renames classes, and two chunks may give two of them one name. */\n repositoryBindingsByClass: Map<Function, IRepositoryBinding<AbstractEntity>>;\n\n /**\n * The model classes each datasource owns, keyed by the datasource class - or by the string a\n * repository named it with (`dataSource: 'PgDataSource'`), which only a class of that name\n * can match. Never by class name alone: a minified build gives two datasources one name.\n */\n datasourceModels: Map<string | Function, Set<TClass<unknown>>>;\n\n setRepositoryMetadata<\n Target extends object = object,\n Model extends AbstractEntity = AbstractEntity,\n DataSource extends IDataSource = IDataSource,\n >(opts: {\n target: Target;\n metadata: TRepositoryMetadata<Model, DataSource> & {\n _resolved?: IResolvedRepositoryMetadata<Model, DataSource>;\n };\n }): void {\n const { target, metadata } = opts;\n Reflect.defineMetadata(MetadataKeys.REPOSITORY, metadata, target);\n }\n\n getRepositoryMetadata<Target extends object = object>(opts: {\n target: Target;\n }): (TRepositoryMetadata & { _resolved?: IResolvedRepositoryMetadata }) | undefined {\n const { target } = opts;\n\n return Reflect.getMetadata(MetadataKeys.REPOSITORY, target);\n }\n\n /** Registers a repository binding (called by @repository) linking a repository to its model + datasource. */\n registerRepositoryBinding<\n Model extends AbstractEntity = AbstractEntity,\n DataSource extends IDataSource = IDataSource,\n >(opts: IRepositoryBinding<Model, DataSource>) {\n // Every member of the binding may be a resolver, the escape hatch for circular imports.\n // Reading `.name` off the resolver keys the registry by the arrow's inferred name, and the\n // datasource then silently discovers no schema.\n const repositoryClass = ResolverUtility.resolveValue({ value: opts.repository });\n this.repositoryBindings.set(repositoryClass.name, opts);\n this.repositoryBindingsByClass.set(repositoryClass, opts);\n\n const dataSourceRef = ResolverUtility.resolveValue({ value: opts.dataSource });\n const modelClass = ResolverUtility.resolveValue({ value: opts.model });\n\n if (!this.datasourceModels.has(dataSourceRef)) {\n this.datasourceModels.set(dataSourceRef, new Set());\n }\n\n this.datasourceModels.get(dataSourceRef)!.add(modelClass);\n }\n\n /** By class, walking up to the nearest decorated parent; by name only for callers holding a name. */\n getRepositoryBinding(\n opts: { target: Function } | { name: string },\n ): IRepositoryBinding<AbstractEntity> | undefined {\n if ('name' in opts) {\n return this.repositoryBindings.get(opts.name);\n }\n\n for (\n let current: Function | null = opts.target;\n current && current !== Function.prototype;\n current = Object.getPrototypeOf(current)\n ) {\n const binding = this.repositoryBindingsByClass.get(current);\n\n if (binding) {\n return binding;\n }\n }\n\n return undefined;\n }\n\n /** A class finds what was registered under it, and under a string equal to its name. */\n getDataSourceModelClasses(opts: {\n dataSource: string | TClass<IDataSource>;\n }): Set<TClass<unknown>> {\n const { dataSource } = opts;\n\n if (typeof dataSource === 'string') {\n return this.datasourceModels.get(dataSource) ?? new Set();\n }\n\n return new Set([\n ...(this.datasourceModels.get(dataSource) ?? []),\n ...(this.datasourceModels.get(dataSource.name) ?? []),\n ]);\n }\n\n /**\n * Resolves and caches relations for a model entry - called lazily from buildSchema() so that\n * every `@model` class is registered first, which avoids circular-dependency ordering issues.\n * @internal\n */\n resolveModelRelations(\n modelMeta: Pick<IModelRegistryEntry, 'schema' | 'relationsResolver' | '_builtRelations'>,\n ): unknown {\n if (modelMeta._builtRelations !== undefined) {\n return modelMeta._builtRelations;\n }\n\n if (!modelMeta.relationsResolver) {\n return undefined;\n }\n\n const relations = ResolverUtility.resolveValue({ value: modelMeta.relationsResolver });\n\n if (!relations || !modelMeta.schema) {\n return undefined;\n }\n\n const builder = RelationBuilderRegistry.resolve();\n\n // Relations were declared but no connector installed a builder - silently dropping them\n // would surface much later as an empty `with` clause.\n if (!builder) {\n throw getError({\n message: `[RepositoryMetadataMixin][resolveModelRelations] Model declares relations but no relation builder is registered | Import the relational connector so it installs one`,\n });\n }\n\n const builtRelations = builder({ source: modelMeta.schema, relations });\n\n modelMeta._builtRelations = builtRelations?.relations;\n\n return modelMeta._builtRelations;\n }\n\n /**\n * Models registered for a datasource, relations resolved lazily. `schema`/`relations` stay\n * `unknown` - the registry is shared across connectors, so each connector narrows at its call\n * site.\n */\n getModels(opts: { dataSource: string | TClass<IDataSource> }): Array<{\n tableName: string;\n schema: unknown;\n relations?: unknown;\n }> {\n const modelClasses = this.getDataSourceModelClasses({ dataSource: opts.dataSource });\n\n const rs = Array.from(modelClasses)\n .map((modelClass) => {\n // Read straight off the class: a class -> name -> modelRegistry round-trip collapses two\n // same-named models onto one entry, silently swapping schemas. `modelRegistry` stays\n // name-keyed for the by-name APIs that need it.\n const statics: TStaticReadableModelClass = modelClass;\n const entry: Pick<IModelRegistryEntry, 'schema' | 'relationsResolver'> = {\n schema: statics.schema,\n relationsResolver: statics.relations,\n };\n\n if (entry.schema === undefined) {\n return null;\n }\n\n return {\n tableName: this.resolveModelKey({ modelClass }),\n schema: entry.schema,\n relations: this.resolveModelRelations(entry),\n };\n })\n .filter((item): item is NonNullable<typeof item> => {\n return item !== undefined && item !== null;\n });\n\n return rs;\n }\n\n /**\n * Like getModels but returns only resolved model classes - used by BaseSearchDataSource, which\n * has no pgTable to resolve.\n */\n getModelClasses(opts: { dataSource: string | TClass<IDataSource> }): Array<TClass<unknown>> {\n // Straight from the stored class refs: a name round-trip through the shared modelRegistry\n // would hand back whichever same-named class registered last.\n return Array.from(this.getDataSourceModelClasses({ dataSource: opts.dataSource }));\n }\n\n /** The key a model occupies in `modelRegistry` - its table name, or its class name when it has none. */\n resolveModelKey(opts: { modelClass: TClass<unknown> }): string {\n const { modelClass } = opts;\n const modelMetadata = this.getModelMetadata({ target: modelClass });\n const statics: TStaticReadableModelClass = modelClass;\n\n return [modelMetadata?.tableName, statics.TABLE_NAME].find(Boolean) ?? modelClass.name;\n }\n\n /** Assembles table schemas + relations for a datasource's registered models. */\n buildSchema(opts: { dataSource: string | TClass<IDataSource> }): {\n schema: Record<string, unknown>;\n relations: Record<string, unknown>;\n } {\n const { dataSource } = opts;\n const models = this.getModels({ dataSource });\n\n const rs: {\n schema: Record<string, unknown>;\n relations: Record<string, unknown>;\n } = { schema: {}, relations: {} };\n\n for (const model of models) {\n if (model.schema) {\n rs.schema[model.tableName] = model.schema;\n }\n\n if (model.relations) {\n rs.relations[`${model.tableName}Relations`] = model.relations;\n }\n }\n\n return rs;\n }\n\n hasModels(opts: { dataSource: string | TClass<IDataSource> }): boolean {\n return this.getDataSourceModelClasses({ dataSource: opts.dataSource }).size > 0;\n }\n };\n};\n"]}