@venizia/ignis-kernel 0.4.8-9 → 0.4.8

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 (131) 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/common/types/application.d.ts +2 -2
  6. package/dist/esm/base/applications/common/types/application.js.map +1 -1
  7. package/dist/esm/base/applications/common/types/middlewares.d.ts +2 -2
  8. package/dist/esm/base/applications/common/types/middlewares.js.map +1 -1
  9. package/dist/esm/base/applications/rest.js +6 -1
  10. package/dist/esm/base/applications/rest.js.map +1 -1
  11. package/dist/esm/base/auth/authenticate/common/types/jwt.d.ts +1 -1
  12. package/dist/esm/base/auth/authenticate/common/types/jwt.js.map +1 -1
  13. package/dist/esm/base/auth/authenticate/common/types/strategy.d.ts +2 -3
  14. package/dist/esm/base/auth/authenticate/common/types/strategy.js.map +1 -1
  15. package/dist/esm/base/auth/authenticate/strategies/strategy-registry.d.ts +1 -1
  16. package/dist/esm/base/auth/authenticate/strategies/strategy-registry.js +1 -1
  17. package/dist/esm/base/auth/authenticate/strategies/strategy-registry.js.map +1 -1
  18. package/dist/esm/base/auth/authorize/providers/request-domain.js +2 -1
  19. package/dist/esm/base/auth/authorize/providers/request-domain.js.map +1 -1
  20. package/dist/esm/base/controllers/common/types/route.d.ts +13 -4
  21. package/dist/esm/base/controllers/common/types/route.js.map +1 -1
  22. package/dist/esm/base/controllers/factory/controller.d.ts +3 -4
  23. package/dist/esm/base/controllers/factory/controller.js +0 -1
  24. package/dist/esm/base/controllers/factory/controller.js.map +1 -1
  25. package/dist/esm/base/controllers/factory/crud/abstract.d.ts +3 -4
  26. package/dist/esm/base/controllers/factory/crud/abstract.js.map +1 -1
  27. package/dist/esm/base/controllers/factory/definition.d.ts +21 -1
  28. package/dist/esm/base/controllers/factory/definition.js +45 -31
  29. package/dist/esm/base/controllers/factory/definition.js.map +1 -1
  30. package/dist/esm/base/controllers/factory/index.d.ts +1 -0
  31. package/dist/esm/base/controllers/factory/index.js +1 -0
  32. package/dist/esm/base/controllers/factory/index.js.map +1 -1
  33. package/dist/esm/base/controllers/factory/injection.d.ts +38 -0
  34. package/dist/esm/base/controllers/factory/injection.js +54 -0
  35. package/dist/esm/base/controllers/factory/injection.js.map +1 -0
  36. package/dist/esm/base/controllers/rest/abstract.js +1 -1
  37. package/dist/esm/base/controllers/rest/abstract.js.map +1 -1
  38. package/dist/esm/base/controllers/rest/base.d.ts +3 -3
  39. package/dist/esm/base/controllers/rest/base.js.map +1 -1
  40. package/dist/esm/base/datasources/abstract.d.ts +4 -92
  41. package/dist/esm/base/datasources/abstract.js +3 -217
  42. package/dist/esm/base/datasources/abstract.js.map +1 -1
  43. package/dist/esm/base/datasources/common/types.d.ts +2 -2
  44. package/dist/esm/base/datasources/common/types.js.map +1 -1
  45. package/dist/esm/base/datasources/index.d.ts +1 -0
  46. package/dist/esm/base/datasources/index.js +1 -0
  47. package/dist/esm/base/datasources/index.js.map +1 -1
  48. package/dist/esm/base/datasources/root.d.ts +107 -0
  49. package/dist/esm/base/datasources/root.js +237 -0
  50. package/dist/esm/base/datasources/root.js.map +1 -0
  51. package/dist/esm/base/events/event-bus.js.map +1 -1
  52. package/dist/esm/base/metadata/index.d.ts +1 -1
  53. package/dist/esm/base/metadata/index.js +1 -1
  54. package/dist/esm/base/metadata/injectors.d.ts +1 -1
  55. package/dist/esm/base/metadata/persistents/datasource.d.ts +21 -0
  56. package/dist/esm/base/metadata/persistents/datasource.js +46 -0
  57. package/dist/esm/base/metadata/persistents/datasource.js.map +1 -0
  58. package/dist/esm/base/metadata/persistents/index.d.ts +5 -0
  59. package/dist/esm/base/metadata/persistents/index.js +5 -0
  60. package/dist/esm/base/metadata/persistents/index.js.map +1 -0
  61. package/dist/esm/base/metadata/persistents/model.d.ts +18 -0
  62. package/dist/esm/base/metadata/persistents/model.js +64 -0
  63. package/dist/esm/base/metadata/persistents/model.js.map +1 -0
  64. package/dist/esm/base/metadata/persistents/repository/index.d.ts +19 -0
  65. package/dist/esm/base/metadata/persistents/repository/index.js +32 -0
  66. package/dist/esm/base/metadata/persistents/repository/index.js.map +1 -0
  67. package/dist/esm/base/metadata/persistents/repository/injection.d.ts +15 -0
  68. package/dist/esm/base/metadata/persistents/repository/injection.js +64 -0
  69. package/dist/esm/base/metadata/persistents/repository/injection.js.map +1 -0
  70. package/dist/esm/base/metadata/persistents/repository/resolve.d.ts +15 -0
  71. package/dist/esm/base/metadata/persistents/repository/resolve.js +76 -0
  72. package/dist/esm/base/metadata/persistents/repository/resolve.js.map +1 -0
  73. package/dist/esm/base/metadata/persistents/repository/validate.d.ts +15 -0
  74. package/dist/esm/base/metadata/persistents/repository/validate.js +50 -0
  75. package/dist/esm/base/metadata/persistents/repository/validate.js.map +1 -0
  76. package/dist/esm/base/models/common/utilities.d.ts +1 -1
  77. package/dist/esm/base/repositories/common/response-reader.d.ts +30 -0
  78. package/dist/esm/base/repositories/common/response-reader.js +53 -0
  79. package/dist/esm/base/repositories/common/response-reader.js.map +1 -1
  80. package/dist/esm/base/repositories/common/types/contracts.d.ts +2 -2
  81. package/dist/esm/base/repositories/common/types/contracts.js.map +1 -1
  82. package/dist/esm/base/repositories/common/types/options.d.ts +2 -2
  83. package/dist/esm/base/repositories/common/types/options.js.map +1 -1
  84. package/dist/esm/base/repositories/common/types/query.d.ts +6 -15
  85. package/dist/esm/base/repositories/common/types/query.js.map +1 -1
  86. package/dist/esm/base/repositories/core/abstract.d.ts +6 -6
  87. package/dist/esm/base/repositories/core/abstract.js.map +1 -1
  88. package/dist/esm/base/repositories/query-schemas/index.js +7 -0
  89. package/dist/esm/base/repositories/query-schemas/index.js.map +1 -1
  90. package/dist/esm/helpers/inversion/common/types/model.d.ts +1 -1
  91. package/dist/esm/helpers/inversion/common/types/model.js.map +1 -1
  92. package/dist/esm/helpers/inversion/mixins/artifact.mixin.d.ts +4 -3
  93. package/dist/esm/helpers/inversion/mixins/artifact.mixin.js +1 -0
  94. package/dist/esm/helpers/inversion/mixins/artifact.mixin.js.map +1 -1
  95. package/dist/esm/helpers/inversion/mixins/controllers/controller.d.ts +4 -3
  96. package/dist/esm/helpers/inversion/mixins/controllers/controller.js +1 -0
  97. package/dist/esm/helpers/inversion/mixins/controllers/controller.js.map +1 -1
  98. package/dist/esm/helpers/inversion/mixins/controllers/grpc.d.ts +4 -3
  99. package/dist/esm/helpers/inversion/mixins/controllers/grpc.js +1 -0
  100. package/dist/esm/helpers/inversion/mixins/controllers/grpc.js.map +1 -1
  101. package/dist/esm/helpers/inversion/mixins/controllers/rest.d.ts +4 -3
  102. package/dist/esm/helpers/inversion/mixins/controllers/rest.js +1 -0
  103. package/dist/esm/helpers/inversion/mixins/controllers/rest.js.map +1 -1
  104. package/dist/esm/helpers/inversion/mixins/datasource.mixin.d.ts +4 -3
  105. package/dist/esm/helpers/inversion/mixins/datasource.mixin.js +1 -0
  106. package/dist/esm/helpers/inversion/mixins/datasource.mixin.js.map +1 -1
  107. package/dist/esm/helpers/inversion/mixins/model.mixin.d.ts +4 -3
  108. package/dist/esm/helpers/inversion/mixins/model.mixin.js +1 -0
  109. package/dist/esm/helpers/inversion/mixins/model.mixin.js.map +1 -1
  110. package/dist/esm/helpers/inversion/mixins/repository.mixin.d.ts +9 -8
  111. package/dist/esm/helpers/inversion/mixins/repository.mixin.js +6 -6
  112. package/dist/esm/helpers/inversion/mixins/repository.mixin.js.map +1 -1
  113. package/dist/esm/helpers/inversion/registry.d.ts +26 -26
  114. package/dist/esm/helpers/inversion/registry.js.map +1 -1
  115. package/dist/esm/helpers/singleton-realm.js +5 -4
  116. package/dist/esm/helpers/singleton-realm.js.map +1 -1
  117. package/dist/esm/metadata.d.ts +1 -1
  118. package/dist/esm/metadata.js +1 -1
  119. package/dist/esm/repository.d.ts +1 -0
  120. package/dist/esm/repository.js +1 -0
  121. package/dist/esm/repository.js.map +1 -1
  122. package/dist/esm/utilities/index.d.ts +1 -0
  123. package/dist/esm/utilities/index.js +1 -0
  124. package/dist/esm/utilities/index.js.map +1 -1
  125. package/dist/esm/utilities/toggle.utility.d.ts +22 -0
  126. package/dist/esm/utilities/toggle.utility.js +16 -0
  127. package/dist/esm/utilities/toggle.utility.js.map +1 -0
  128. package/package.json +5 -5
  129. package/dist/esm/base/metadata/persistents.d.ts +0 -54
  130. package/dist/esm/base/metadata/persistents.js +0 -302
  131. package/dist/esm/base/metadata/persistents.js.map +0 -1
@@ -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,4 +1,4 @@
1
- import type { AbstractDataSource } from '../../datasources/index.js';
1
+ import type { DataSourceRoot } from '../../datasources/index.js';
2
2
  import type { AbstractEntity, IdType } from '../../models/index.js';
3
3
  import type { IModelMetadata } from '../../../helpers/inversion/index.js';
4
4
  import type { TClass, TNullable } from '@venizia/ignis-helpers/common';
@@ -17,7 +17,7 @@ export declare abstract class AbstractRepository<TDataObject extends object, TPe
17
17
  readonly $inferPersist?: TPersistObject;
18
18
  protected _operationScope: TRepositoryOperationScope;
19
19
  /** Lazy-resolved on first access if not provided in constructor. */
20
- protected _dataSource?: AbstractDataSource;
20
+ protected _dataSource?: DataSourceRoot;
21
21
  /** Lazy-resolved from @repository metadata on first access. */
22
22
  protected _entity?: AbstractEntity;
23
23
  /**
@@ -25,19 +25,19 @@ export declare abstract class AbstractRepository<TDataObject extends object, TPe
25
25
  * is itself a valid resolved value: the model declares no settings.
26
26
  */
27
27
  private _modelSettings;
28
- constructor(dataSource?: AbstractDataSource, opts?: {
28
+ constructor(dataSource?: DataSourceRoot, opts?: {
29
29
  scope?: string;
30
30
  entityClass?: TClass<AbstractEntity>;
31
31
  operationScope?: TRepositoryOperationScope;
32
32
  });
33
- get dataSource(): AbstractDataSource;
34
- set dataSource(value: AbstractDataSource);
33
+ get dataSource(): DataSourceRoot;
34
+ set dataSource(value: DataSourceRoot);
35
35
  /** Auto-resolves from @repository metadata if not explicitly set. */
36
36
  get entity(): AbstractEntity;
37
37
  set entity(value: AbstractEntity);
38
38
  get operationScope(): TRepositoryOperationScope;
39
39
  setDataSource(opts: {
40
- dataSource: AbstractDataSource;
40
+ dataSource: DataSourceRoot;
41
41
  }): void;
42
42
  getEntity(): AbstractEntity;
43
43
  /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E,EAAE,CAAC,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS;YACjE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAA0B;SAC5F,CAAC,CAAC;IACL,CAAC;CA6FF","sourcesContent":["import type { AbstractDataSource } from '@/base/datasources';\nimport type { AbstractEntity, IdType } from '@/base/models';\nimport type { IModelMetadata } from '@/helpers/inversion';\nimport { MetadataRegistry } from '@/helpers/inversion';\nimport type { TClass, TNullable } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport { ResolverUtility } from '@venizia/ignis-helpers/common';\nimport { RetryBackoffStrategies, RetryHelper, RetryJitterModes } from '@venizia/ignis-helpers/core';\nimport type {\n IExtraOptions,\n IPersistableRepository,\n IWithReadRetry,\n TCount,\n TDataWithRange,\n TFindOneOptions,\n TFindOptions,\n TFindRangeOptions,\n TRepositoryOperationScope,\n} from '../common';\n// The file, not the `../common` barrel: the barrel re-exports the OpenAPI schemas, and this module is\n// on the `./repository` entry, which must load without `@hono/zod-openapi` installed.\nimport {\n DEFAULT_MAX_LIMIT,\n RepositoryErrorCodes,\n RepositoryOperationScopes,\n} from '../common/constants';\nimport { RequestFilterGuard } from '../common/request-filter-guard';\nimport type { IRequestFilterJudge, IRequestFilterShape } from '../common/request-filter-guard';\nimport type {\n TByIdFilter,\n TFields,\n TFilter,\n TInclusion,\n TRow,\n TWhere,\n} from '@venizia/ignis-filter';\n\n/**\n * Engine-neutral repository plumbing - lazy dataSource/entity resolution, class-keyed `@model`\n * settings, operation scope. `TOptions` defaults to `IExtraOptions` so connectors can narrow it\n * while staying assignable to this base.\n */\nexport abstract class AbstractRepository<\n TDataObject extends object,\n TPersistObject extends object = TDataObject,\n TOptions extends IExtraOptions = IExtraOptions,\n>\n extends BaseHelper\n implements IPersistableRepository<TDataObject, TPersistObject, TOptions>\n{\n /** Phantom type markers, never set at runtime: the row and persist shapes, for the types that read them off a repository class (as an entity's `$inferData`). */\n declare readonly $inferData?: TDataObject;\n declare readonly $inferPersist?: TPersistObject;\n\n protected _operationScope: TRepositoryOperationScope;\n\n /** Lazy-resolved on first access if not provided in constructor. */\n protected _dataSource?: AbstractDataSource;\n\n /** Lazy-resolved from @repository metadata on first access. */\n protected _entity?: AbstractEntity;\n\n /**\n * Memoized @model settings for `this.entity`'s class. `null` means not yet resolved - `undefined`\n * is itself a valid resolved value: the model declares no settings.\n */\n private _modelSettings: IModelMetadata['settings'] | null = null;\n\n constructor(\n dataSource?: AbstractDataSource,\n opts?: {\n scope?: string;\n entityClass?: TClass<AbstractEntity>;\n operationScope?: TRepositoryOperationScope;\n },\n ) {\n const scopeName =\n opts?.scope ??\n (opts?.entityClass?.name ? [opts.entityClass.name, 'Repository'].join('') : new.target.name);\n\n super({ scope: scopeName });\n\n this._operationScope = opts?.operationScope ?? RepositoryOperationScopes.READ_ONLY;\n\n if (dataSource) {\n this._dataSource = dataSource;\n }\n\n if (opts?.entityClass) {\n this._entity = new opts.entityClass();\n }\n }\n\n get dataSource(): AbstractDataSource {\n if (!this._dataSource) {\n throw getError({\n message: `[${this.constructor.name}] DataSource not available. Use @repository({ model: YourModel, dataSource: YourDataSource }) or pass dataSource in constructor.`,\n });\n }\n\n return this._dataSource;\n }\n\n set dataSource(value: AbstractDataSource) {\n this._dataSource = value;\n }\n\n /** Auto-resolves from @repository metadata if not explicitly set. */\n get entity(): AbstractEntity {\n this._entity ??= this.resolveEntity();\n\n return this._entity;\n }\n\n set entity(value: AbstractEntity) {\n this._entity = value;\n }\n\n get operationScope(): TRepositoryOperationScope {\n return this._operationScope;\n }\n\n setDataSource(opts: { dataSource: AbstractDataSource }): void {\n this._dataSource = opts.dataSource;\n }\n\n getEntity(): AbstractEntity {\n return this.entity;\n }\n\n /**\n * Resolved `@model` settings for `this.entity`'s class, keyed by Reflect target - not by\n * `entity.name`, which can diverge from the `@model` registry key.\n */\n protected get modelSettings(): IModelMetadata['settings'] {\n if (this._modelSettings !== null) {\n return this._modelSettings;\n }\n\n this._modelSettings = MetadataRegistry.getInstance().getModelMetadata({\n target: this.entity.constructor,\n })?.settings;\n\n return this._modelSettings;\n }\n\n protected get hiddenFields(): string[] {\n return this.modelSettings?.properties?.hidden ?? [];\n }\n\n /**\n * Refuses (400, `Column NOT FOUND`) a filter that came from a request and names a field the model hides, in its\n * `where`, its `order` or the `scope` of an `include` (judged by the hidden fields of the model it reads). The generated\n * controllers call it on what a client sends; the repository's own verbs do not, so server code can still filter and\n * sort on a hidden field.\n */\n assertRequestFilter(opts: { filter?: IRequestFilterShape }): void {\n RequestFilterGuard.assertFilter({\n filter: opts.filter,\n judge: this.createRequestFilterJudge(),\n tableName: this.entity?.name ?? this.constructor.name,\n });\n }\n\n /**\n * How this repository judges the keys of a request filter. The default reads a key as a dotted field name and refuses it with\n * a 400 `Column NOT FOUND`; a relational or a search repository overrides it to read keys as its own query does and to\n * refuse with its own query's error for a column that does not exist.\n */\n protected createRequestFilterJudge(): IRequestFilterJudge {\n const hidden = new Set(this.hiddenFields);\n\n return {\n isHidden: ({ key }) => RequestFilterGuard.isHiddenByName({ key, hidden }),\n refuse: ({ key }) => RequestFilterGuard.columnNotFound({ scope: this.constructor.name, key }),\n };\n }\n\n /** Default where from @model settings.query.filter.where, AND-merged into every query unless skipped. */\n protected get defaultWhere(): TWhere | undefined {\n return this.modelSettings?.query?.filter?.where;\n }\n\n protected get defaultLimit(): number | undefined {\n return this.modelSettings?.query?.limit?.default;\n }\n\n /** Largest `limit` a caller may ask for, when the model declares one; undefined leaves the tier's own default in force. */\n protected get maxLimit(): number | undefined {\n return this.modelSettings?.query?.limit?.max;\n }\n\n /**\n * Both bounds, in one place, for every tier.\n *\n * The upper bound is the point: `@model({ settings: { query: { limit: { max } } } })` is public and validated at\n * decoration time, but the relational tier read it nowhere, so `limit.max: 2` still issued\n * `LIMIT 50000000`.\n *\n * The lower bound matters just as much and is easy to miss: a NEGATIVE limit is not a smaller\n * page. Drizzle renders the LIMIT clause only when the value is `>= 0`, so a negative one removes\n * the clause and returns the whole table. The wire schema now rejects it too, but a server-side\n * caller reaches this method without passing through the schema at all.\n */\n protected assertLimitWithinCeiling(opts: { limit?: number; scope?: string }): void {\n const { limit, scope = 'find' } = opts;\n\n if (limit === undefined) {\n return;\n }\n\n // The shape check first, because it needs no metadata at all.\n if (!Number.isInteger(limit) || limit < 0) {\n throw getError({\n message: `[${this.constructor.name}][${scope}] Invalid 'limit' | Expected a non-negative integer | Got: ${limit}`,\n });\n }\n\n // `limit.max` reaches `modelSettings`, which resolves the entity - and THAT throws for a\n // repository with no `@repository` model binding. Such a repository is a misconfiguration this\n // method has no business reporting, and the caller path that used to reach `getDefaultLimit()`\n // never touched it either, because `??` short-circuits when a limit is given. So the ceiling is\n // consulted only when the binding that makes it resolvable is actually present.\n const hasModelBinding = Boolean(\n MetadataRegistry.getInstance().getRepositoryBinding({ target: this.constructor })?.model,\n );\n const ceiling = (hasModelBinding ? this.maxLimit : undefined) ?? DEFAULT_MAX_LIMIT;\n\n if (limit > ceiling) {\n throw getError({\n message: `[${this.constructor.name}][${scope}] Requested page exceeds this model's limit | requested: ${limit} | maximum: ${ceiling} | raise it with @model settings.query.limit.max if larger pages are genuinely needed`,\n });\n }\n }\n\n /**\n * The whole filter, relations included. Checking only the top-level `limit` left the identical\n * defect reachable one level down: a relation scope's negative limit drops Drizzle's LIMIT clause\n * for that relation and loads the entire related table.\n *\n * A relation's limit gets the SHAPE check only, not a ceiling. The ceiling belongs to the\n * relation's own model, which this repository cannot resolve - claiming otherwise would enforce\n * the parent's `limit.max` on a different entity.\n */\n protected assertFilterLimits(opts: { filter?: TFilter; scope?: string }): void {\n const { filter, scope = 'find' } = opts;\n\n if (!filter) {\n return;\n }\n\n this.assertLimitWithinCeiling({ limit: filter.limit, scope });\n\n const walk = (inclusions: TInclusion[] | undefined, path: string): void => {\n const inclusionsList = inclusions ?? [];\n\n for (const inclusion of inclusionsList) {\n const relationScope = inclusion.scope;\n\n if (!relationScope) {\n continue;\n }\n\n const relationPath = `${path}.${inclusion.relation}`;\n const relationLimit = relationScope.limit;\n\n if (\n relationLimit !== undefined &&\n (!Number.isInteger(relationLimit) || relationLimit < 0)\n ) {\n throw getError({\n message: `[${this.constructor.name}][${scope}] Invalid 'limit' on relation scope | relation: ${relationPath} | Expected a non-negative integer | Got: ${relationLimit}`,\n });\n }\n\n walk(relationScope.include, relationPath);\n }\n };\n\n walk(filter.include, scope);\n }\n\n /** Resolves the entity instance from @repository metadata on first access. */\n protected resolveEntity(): AbstractEntity {\n const registry = MetadataRegistry.getInstance();\n const binding = registry.getRepositoryBinding({ target: this.constructor });\n\n if (!binding?.model) {\n throw getError({\n message: `[${this.constructor.name}] Cannot resolve entity. Either pass entityClass in constructor or use @repository decorator with model option.`,\n });\n }\n\n // ResolverUtility.resolveValue() erases to the resolved value's structural type, not this class-or-resolver\n // union's member - the `@repository` decorator guarantees a class constructor here.\n const ModelClass = ResolverUtility.resolveValue({\n value: binding.model,\n }) as TClass<AbstractEntity>;\n\n return new ModelClass();\n }\n\n /** Rejects a verb the current operation scope does not permit. */\n protected denyOperation(opts: { methodName: string }): never {\n throw getError({\n messageCode: RepositoryErrorCodes.OPERATION_NOT_ALLOWED,\n message: `[${opts.methodName}] Repository operation is NOT ALLOWED | scope: ${this.operationScope}`,\n });\n }\n\n /**\n * Shared retry orchestration for read verbs. Inside a transaction retry is skipped - the pool\n * routes transactions to the primary, so there is no replica lag to wait out.\n */\n protected executeReadWithRetry<TResult>(opts: {\n operation: string;\n options: IExtraOptions & IWithReadRetry<TResult>;\n defaultUntil: (result: TResult) => boolean;\n execution: () => Promise<TResult>;\n }): Promise<TResult> {\n const { operation, options, defaultUntil, execution } = opts;\n\n if (!options.retry) {\n return execution();\n }\n\n if (options.transaction) {\n this.logger.for(operation).debug('Read retry skipped inside transaction');\n\n return execution();\n }\n\n const { maxAttempts, maxTotalMs, signal, backoff, until } = options.retry;\n\n return RetryHelper.executeWithRetryUntil<TResult>({\n operation: [this.constructor.name, operation].join('.'),\n execution,\n until: until ?? defaultUntil,\n maxAttempts,\n maxTotalMs,\n signal,\n backoff: backoff ?? {\n strategy: RetryBackoffStrategies.EXPONENTIAL,\n initialDelayMs: 50,\n maxDelayMs: 500,\n jitter: RetryJitterModes.EQUAL,\n },\n logger: this.logger,\n });\n }\n\n /**\n * A copy of `options` without `retry`, so re-entering a read verb takes its non-retry path - this\n * is what keeps the retry recursion single-depth. Copy-then-delete rather than a rest-destructure\n * (lint rejects the unused rest sibling) or `lodash/omit` (its `Omit<>` return type is not\n * assignable back to `TOptions`).\n */\n private omitReadRetry<TReadOptions extends { retry?: unknown }>(\n options: TReadOptions,\n ): TReadOptions {\n const rest = { ...options };\n delete rest.retry;\n\n return rest;\n }\n\n /** `find`, re-executed until the retry predicate holds - connectors dispatch here from `find` when `options.retry` is set. */\n protected findUntil<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options: TFindOptions<TOptions, R>;\n }): Promise<Array<R>> {\n const options = this.omitReadRetry(opts.options);\n\n return this.executeReadWithRetry<Array<R>>({\n operation: 'find',\n options: opts.options,\n defaultUntil: (result) => result.length > 0,\n // `R` is named here, so the row is `R`; TypeScript cannot resolve `TRow` for an unresolved `R`.\n execution: () => this.find<R>({ filter: opts.filter, options }) as Promise<Array<R>>,\n });\n }\n\n /** `find` with the range envelope, re-executed until the retry predicate holds - split from `findUntil` so each result shape is checked against its own `find` overload. */\n protected findRangeUntil<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options: TFindRangeOptions<TOptions, R>;\n }): Promise<TDataWithRange<R>> {\n const options = this.omitReadRetry(opts.options);\n\n return this.executeReadWithRetry<TDataWithRange<R>>({\n operation: 'find',\n options: opts.options,\n defaultUntil: (result) => result.data.length > 0,\n execution: () =>\n this.find<R>({ filter: opts.filter, options }) as unknown as Promise<TDataWithRange<R>>,\n });\n }\n\n /** `findOne`, re-executed until the retry predicate holds - also serves `findById` via its findOne delegation. */\n protected findOneUntil<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options: TFindOneOptions<TOptions, R>;\n }): Promise<TNullable<R>> {\n const options = this.omitReadRetry(opts.options);\n\n return this.executeReadWithRetry<TNullable<R>>({\n operation: 'findOne',\n options: opts.options,\n defaultUntil: (result) => result !== null && result !== undefined,\n execution: () => this.findOne<R>({ filter: opts.filter, options }) as Promise<TNullable<R>>,\n });\n }\n\n abstract count(opts: { where: TWhere<TDataObject>; options?: TOptions }): Promise<TCount>;\n\n abstract existsWith(opts: { where: TWhere<TDataObject>; options?: TOptions }): Promise<boolean>;\n\n abstract find<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options: TFindRangeOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<TDataWithRange<TRow<TDataObject, R, F>>>;\n\n abstract find<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options?: TFindOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<Array<TRow<TDataObject, R, F>>>;\n\n abstract findOne<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options?: TFindOneOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<TNullable<TRow<TDataObject, R, F>>>;\n\n abstract findById<\n R = unknown,\n const F extends TFields<TDataObject> = TFields<TDataObject>,\n >(opts: {\n id: IdType;\n filter?: TByIdFilter<TDataObject, F>;\n options?: TFindOneOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<TNullable<TRow<TDataObject, R, F>>>;\n\n abstract create(opts: {\n data: TPersistObject;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract create<R = TDataObject>(opts: {\n data: TPersistObject;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract createAll(opts: {\n data: Array<TPersistObject>;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract createAll<R = TDataObject>(opts: {\n data: Array<TPersistObject>;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: Array<R> }>;\n\n abstract updateById(opts: {\n id: IdType;\n data: Partial<TPersistObject>;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract updateById<R = TDataObject>(opts: {\n id: IdType;\n data: Partial<TPersistObject>;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract updateBy(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract updateBy<R = TDataObject>(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\n\n abstract deleteById(opts: {\n id: IdType;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract deleteById<R = TDataObject>(opts: {\n id: IdType;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract deleteBy(opts: {\n where: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract deleteBy<R = TDataObject>(opts: {\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\n}\n"]}
1
+ {"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../../src/base/repositories/core/abstract.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACn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cesContent":["import type { DataSourceRoot } from '@/base/datasources';\nimport type { AbstractEntity, IdType } from '@/base/models';\nimport type { IModelMetadata } from '@/helpers/inversion';\nimport { MetadataRegistry } from '@/helpers/inversion';\nimport type { TClass, TNullable } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport { ResolverUtility } from '@venizia/ignis-helpers/common';\nimport { RetryBackoffStrategies, RetryHelper, RetryJitterModes } from '@venizia/ignis-helpers/core';\nimport type {\n IExtraOptions,\n IPersistableRepository,\n IWithReadRetry,\n TCount,\n TDataWithRange,\n TFindOneOptions,\n TFindOptions,\n TFindRangeOptions,\n TRepositoryOperationScope,\n} from '../common';\n// The file, not the `../common` barrel: the barrel re-exports the OpenAPI schemas, and this module is\n// on the `./repository` entry, which must load without `@hono/zod-openapi` installed.\nimport {\n DEFAULT_MAX_LIMIT,\n RepositoryErrorCodes,\n RepositoryOperationScopes,\n} from '../common/constants';\nimport { RequestFilterGuard } from '../common/request-filter-guard';\nimport type { IRequestFilterJudge, IRequestFilterShape } from '../common/request-filter-guard';\nimport type {\n TByIdFilter,\n TFields,\n TFilter,\n TInclusion,\n TRow,\n TWhere,\n} from '@venizia/ignis-filter';\n\n/**\n * Engine-neutral repository plumbing - lazy dataSource/entity resolution, class-keyed `@model`\n * settings, operation scope. `TOptions` defaults to `IExtraOptions` so connectors can narrow it\n * while staying assignable to this base.\n */\nexport abstract class AbstractRepository<\n TDataObject extends object,\n TPersistObject extends object = TDataObject,\n TOptions extends IExtraOptions = IExtraOptions,\n>\n extends BaseHelper\n implements IPersistableRepository<TDataObject, TPersistObject, TOptions>\n{\n /** Phantom type markers, never set at runtime: the row and persist shapes, for the types that read them off a repository class (as an entity's `$inferData`). */\n declare readonly $inferData?: TDataObject;\n declare readonly $inferPersist?: TPersistObject;\n\n protected _operationScope: TRepositoryOperationScope;\n\n /** Lazy-resolved on first access if not provided in constructor. */\n protected _dataSource?: DataSourceRoot;\n\n /** Lazy-resolved from @repository metadata on first access. */\n protected _entity?: AbstractEntity;\n\n /**\n * Memoized @model settings for `this.entity`'s class. `null` means not yet resolved - `undefined`\n * is itself a valid resolved value: the model declares no settings.\n */\n private _modelSettings: IModelMetadata['settings'] | null = null;\n\n constructor(\n dataSource?: DataSourceRoot,\n opts?: {\n scope?: string;\n entityClass?: TClass<AbstractEntity>;\n operationScope?: TRepositoryOperationScope;\n },\n ) {\n const scopeName =\n opts?.scope ??\n (opts?.entityClass?.name ? [opts.entityClass.name, 'Repository'].join('') : new.target.name);\n\n super({ scope: scopeName });\n\n this._operationScope = opts?.operationScope ?? RepositoryOperationScopes.READ_ONLY;\n\n if (dataSource) {\n this._dataSource = dataSource;\n }\n\n if (opts?.entityClass) {\n this._entity = new opts.entityClass();\n }\n }\n\n get dataSource(): DataSourceRoot {\n if (!this._dataSource) {\n throw getError({\n message: `[${this.constructor.name}] DataSource not available. Use @repository({ model: YourModel, dataSource: YourDataSource }) or pass dataSource in constructor.`,\n });\n }\n\n return this._dataSource;\n }\n\n set dataSource(value: DataSourceRoot) {\n this._dataSource = value;\n }\n\n /** Auto-resolves from @repository metadata if not explicitly set. */\n get entity(): AbstractEntity {\n this._entity ??= this.resolveEntity();\n\n return this._entity;\n }\n\n set entity(value: AbstractEntity) {\n this._entity = value;\n }\n\n get operationScope(): TRepositoryOperationScope {\n return this._operationScope;\n }\n\n setDataSource(opts: { dataSource: DataSourceRoot }): void {\n this._dataSource = opts.dataSource;\n }\n\n getEntity(): AbstractEntity {\n return this.entity;\n }\n\n /**\n * Resolved `@model` settings for `this.entity`'s class, keyed by Reflect target - not by\n * `entity.name`, which can diverge from the `@model` registry key.\n */\n protected get modelSettings(): IModelMetadata['settings'] {\n if (this._modelSettings !== null) {\n return this._modelSettings;\n }\n\n this._modelSettings = MetadataRegistry.getInstance().getModelMetadata({\n target: this.entity.constructor,\n })?.settings;\n\n return this._modelSettings;\n }\n\n protected get hiddenFields(): string[] {\n return this.modelSettings?.properties?.hidden ?? [];\n }\n\n /**\n * Refuses (400, `Column NOT FOUND`) a filter that came from a request and names a field the model hides, in its\n * `where`, its `order` or the `scope` of an `include` (judged by the hidden fields of the model it reads). The generated\n * controllers call it on what a client sends; the repository's own verbs do not, so server code can still filter and\n * sort on a hidden field.\n */\n assertRequestFilter(opts: { filter?: IRequestFilterShape }): void {\n RequestFilterGuard.assertFilter({\n filter: opts.filter,\n judge: this.createRequestFilterJudge(),\n tableName: this.entity?.name ?? this.constructor.name,\n });\n }\n\n /**\n * How this repository judges the keys of a request filter. The default reads a key as a dotted field name and refuses it with\n * a 400 `Column NOT FOUND`; a relational or a search repository overrides it to read keys as its own query does and to\n * refuse with its own query's error for a column that does not exist.\n */\n protected createRequestFilterJudge(): IRequestFilterJudge {\n const hidden = new Set(this.hiddenFields);\n\n return {\n isHidden: ({ key }) => RequestFilterGuard.isHiddenByName({ key, hidden }),\n refuse: ({ key }) => RequestFilterGuard.columnNotFound({ scope: this.constructor.name, key }),\n };\n }\n\n /** Default where from @model settings.query.filter.where, AND-merged into every query unless skipped. */\n protected get defaultWhere(): TWhere | undefined {\n return this.modelSettings?.query?.filter?.where;\n }\n\n protected get defaultLimit(): number | undefined {\n return this.modelSettings?.query?.limit?.default;\n }\n\n /** Largest `limit` a caller may ask for, when the model declares one; undefined leaves the tier's own default in force. */\n protected get maxLimit(): number | undefined {\n return this.modelSettings?.query?.limit?.max;\n }\n\n /**\n * Both bounds, in one place, for every tier.\n *\n * The upper bound is the point: `@model({ settings: { query: { limit: { max } } } })` is public and validated at\n * decoration time, but the relational tier read it nowhere, so `limit.max: 2` still issued\n * `LIMIT 50000000`.\n *\n * The lower bound matters just as much and is easy to miss: a NEGATIVE limit is not a smaller\n * page. Drizzle renders the LIMIT clause only when the value is `>= 0`, so a negative one removes\n * the clause and returns the whole table. The wire schema now rejects it too, but a server-side\n * caller reaches this method without passing through the schema at all.\n */\n protected assertLimitWithinCeiling(opts: { limit?: number; scope?: string }): void {\n const { limit, scope = 'find' } = opts;\n\n if (limit === undefined) {\n return;\n }\n\n // The shape check first, because it needs no metadata at all.\n if (!Number.isInteger(limit) || limit < 0) {\n throw getError({\n message: `[${this.constructor.name}][${scope}] Invalid 'limit' | Expected a non-negative integer | Got: ${limit}`,\n });\n }\n\n // `limit.max` reaches `modelSettings`, which resolves the entity - and THAT throws for a\n // repository with no `@repository` model binding. Such a repository is a misconfiguration this\n // method has no business reporting, and the caller path that used to reach `getDefaultLimit()`\n // never touched it either, because `??` short-circuits when a limit is given. So the ceiling is\n // consulted only when the binding that makes it resolvable is actually present.\n const hasModelBinding = Boolean(\n MetadataRegistry.getInstance().getRepositoryBinding({ target: this.constructor })?.model,\n );\n const ceiling = (hasModelBinding ? this.maxLimit : undefined) ?? DEFAULT_MAX_LIMIT;\n\n if (limit > ceiling) {\n throw getError({\n message: `[${this.constructor.name}][${scope}] Requested page exceeds this model's limit | requested: ${limit} | maximum: ${ceiling} | raise it with @model settings.query.limit.max if larger pages are genuinely needed`,\n });\n }\n }\n\n /**\n * The whole filter, relations included. Checking only the top-level `limit` left the identical\n * defect reachable one level down: a relation scope's negative limit drops Drizzle's LIMIT clause\n * for that relation and loads the entire related table.\n *\n * A relation's limit gets the SHAPE check only, not a ceiling. The ceiling belongs to the\n * relation's own model, which this repository cannot resolve - claiming otherwise would enforce\n * the parent's `limit.max` on a different entity.\n */\n protected assertFilterLimits(opts: { filter?: TFilter; scope?: string }): void {\n const { filter, scope = 'find' } = opts;\n\n if (!filter) {\n return;\n }\n\n this.assertLimitWithinCeiling({ limit: filter.limit, scope });\n\n const walk = (inclusions: TInclusion[] | undefined, path: string): void => {\n const inclusionsList = inclusions ?? [];\n\n for (const inclusion of inclusionsList) {\n const relationScope = inclusion.scope;\n\n if (!relationScope) {\n continue;\n }\n\n const relationPath = `${path}.${inclusion.relation}`;\n const relationLimit = relationScope.limit;\n\n if (\n relationLimit !== undefined &&\n (!Number.isInteger(relationLimit) || relationLimit < 0)\n ) {\n throw getError({\n message: `[${this.constructor.name}][${scope}] Invalid 'limit' on relation scope | relation: ${relationPath} | Expected a non-negative integer | Got: ${relationLimit}`,\n });\n }\n\n walk(relationScope.include, relationPath);\n }\n };\n\n walk(filter.include, scope);\n }\n\n /** Resolves the entity instance from @repository metadata on first access. */\n protected resolveEntity(): AbstractEntity {\n const registry = MetadataRegistry.getInstance();\n const binding = registry.getRepositoryBinding({ target: this.constructor });\n\n if (!binding?.model) {\n throw getError({\n message: `[${this.constructor.name}] Cannot resolve entity. Either pass entityClass in constructor or use @repository decorator with model option.`,\n });\n }\n\n // ResolverUtility.resolveValue() erases to the resolved value's structural type, not this class-or-resolver\n // union's member - the `@repository` decorator guarantees a class constructor here.\n const ModelClass = ResolverUtility.resolveValue({\n value: binding.model,\n }) as TClass<AbstractEntity>;\n\n return new ModelClass();\n }\n\n /** Rejects a verb the current operation scope does not permit. */\n protected denyOperation(opts: { methodName: string }): never {\n throw getError({\n messageCode: RepositoryErrorCodes.OPERATION_NOT_ALLOWED,\n message: `[${opts.methodName}] Repository operation is NOT ALLOWED | scope: ${this.operationScope}`,\n });\n }\n\n /**\n * Shared retry orchestration for read verbs. Inside a transaction retry is skipped - the pool\n * routes transactions to the primary, so there is no replica lag to wait out.\n */\n protected executeReadWithRetry<TResult>(opts: {\n operation: string;\n options: IExtraOptions & IWithReadRetry<TResult>;\n defaultUntil: (result: TResult) => boolean;\n execution: () => Promise<TResult>;\n }): Promise<TResult> {\n const { operation, options, defaultUntil, execution } = opts;\n\n if (!options.retry) {\n return execution();\n }\n\n if (options.transaction) {\n this.logger.for(operation).debug('Read retry skipped inside transaction');\n\n return execution();\n }\n\n const { maxAttempts, maxTotalMs, signal, backoff, until } = options.retry;\n\n return RetryHelper.executeWithRetryUntil<TResult>({\n operation: [this.constructor.name, operation].join('.'),\n execution,\n until: until ?? defaultUntil,\n maxAttempts,\n maxTotalMs,\n signal,\n backoff: backoff ?? {\n strategy: RetryBackoffStrategies.EXPONENTIAL,\n initialDelayMs: 50,\n maxDelayMs: 500,\n jitter: RetryJitterModes.EQUAL,\n },\n logger: this.logger,\n });\n }\n\n /**\n * A copy of `options` without `retry`, so re-entering a read verb takes its non-retry path - this\n * is what keeps the retry recursion single-depth. Copy-then-delete rather than a rest-destructure\n * (lint rejects the unused rest sibling) or `lodash/omit` (its `Omit<>` return type is not\n * assignable back to `TOptions`).\n */\n private omitReadRetry<TReadOptions extends { retry?: unknown }>(\n options: TReadOptions,\n ): TReadOptions {\n const rest = { ...options };\n delete rest.retry;\n\n return rest;\n }\n\n /** `find`, re-executed until the retry predicate holds - connectors dispatch here from `find` when `options.retry` is set. */\n protected findUntil<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options: TFindOptions<TOptions, R>;\n }): Promise<Array<R>> {\n const options = this.omitReadRetry(opts.options);\n\n return this.executeReadWithRetry<Array<R>>({\n operation: 'find',\n options: opts.options,\n defaultUntil: (result) => result.length > 0,\n // `R` is named here, so the row is `R`; TypeScript cannot resolve `TRow` for an unresolved `R`.\n execution: () => this.find<R>({ filter: opts.filter, options }) as Promise<Array<R>>,\n });\n }\n\n /** `find` with the range envelope, re-executed until the retry predicate holds - split from `findUntil` so each result shape is checked against its own `find` overload. */\n protected findRangeUntil<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options: TFindRangeOptions<TOptions, R>;\n }): Promise<TDataWithRange<R>> {\n const options = this.omitReadRetry(opts.options);\n\n return this.executeReadWithRetry<TDataWithRange<R>>({\n operation: 'find',\n options: opts.options,\n defaultUntil: (result) => result.data.length > 0,\n execution: () =>\n this.find<R>({ filter: opts.filter, options }) as unknown as Promise<TDataWithRange<R>>,\n });\n }\n\n /** `findOne`, re-executed until the retry predicate holds - also serves `findById` via its findOne delegation. */\n protected findOneUntil<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options: TFindOneOptions<TOptions, R>;\n }): Promise<TNullable<R>> {\n const options = this.omitReadRetry(opts.options);\n\n return this.executeReadWithRetry<TNullable<R>>({\n operation: 'findOne',\n options: opts.options,\n defaultUntil: (result) => result !== null && result !== undefined,\n execution: () => this.findOne<R>({ filter: opts.filter, options }) as Promise<TNullable<R>>,\n });\n }\n\n abstract count(opts: { where: TWhere<TDataObject>; options?: TOptions }): Promise<TCount>;\n\n abstract existsWith(opts: { where: TWhere<TDataObject>; options?: TOptions }): Promise<boolean>;\n\n abstract find<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options: TFindRangeOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<TDataWithRange<TRow<TDataObject, R, F>>>;\n\n abstract find<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options?: TFindOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<Array<TRow<TDataObject, R, F>>>;\n\n abstract findOne<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options?: TFindOneOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<TNullable<TRow<TDataObject, R, F>>>;\n\n abstract findById<\n R = unknown,\n const F extends TFields<TDataObject> = TFields<TDataObject>,\n >(opts: {\n id: IdType;\n filter?: TByIdFilter<TDataObject, F>;\n options?: TFindOneOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<TNullable<TRow<TDataObject, R, F>>>;\n\n abstract create(opts: {\n data: TPersistObject;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract create<R = TDataObject>(opts: {\n data: TPersistObject;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract createAll(opts: {\n data: Array<TPersistObject>;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract createAll<R = TDataObject>(opts: {\n data: Array<TPersistObject>;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: Array<R> }>;\n\n abstract updateById(opts: {\n id: IdType;\n data: Partial<TPersistObject>;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract updateById<R = TDataObject>(opts: {\n id: IdType;\n data: Partial<TPersistObject>;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract updateBy(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract updateBy<R = TDataObject>(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\n\n abstract deleteById(opts: {\n id: IdType;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract deleteById<R = TDataObject>(opts: {\n id: IdType;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract deleteBy(opts: {\n where: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract deleteBy<R = TDataObject>(opts: {\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\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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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';\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"]}
@@ -7,7 +7,7 @@ export interface IModelAuthorizeSettings {
7
7
  /** The authorization principal name (resource/subject) for this model. */
8
8
  principal: string;
9
9
  /** Extensible - consumers can add any extra authorization metadata. */
10
- [extra: string | symbol]: any;
10
+ [extra: string | symbol]: unknown;
11
11
  }
12
12
  /** What a restricted caller may write to the scope columns (`@model` settings.access.write). */
13
13
  export interface IModelAccessWriteSettings {
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../../../../../../src/helpers/inversion/common/types/model.ts"],"names":[],"mappings":"","sourcesContent":["import type { AbstractEntity, TModelType } from '@/base/models';\nimport type {\n ScopeFilters,\n ScopeThrough,\n TFilter,\n TScopeFilterMissingBehavior,\n TScopeOperation,\n TScopeWriteGuard,\n TWhere,\n} from '@/base/repositories';\nimport type { TClass, TNullable, TValueOrResolver } from '@venizia/ignis-helpers/common';\nimport type { IArtifactRegistrationOptions } from './artifact';\n\n/** The `authorize` settings of a model. */\nexport interface IModelAuthorizeSettings {\n /** The authorization principal name (resource/subject) for this model. */\n principal: string;\n /** Extensible - consumers can add any extra authorization metadata. */\n [extra: string | symbol]: any;\n}\n\n/** What a restricted caller may write to the scope columns (`@model` settings.access.write). */\nexport interface IModelAccessWriteSettings {\n /**\n * What a create, createAll or an update payload that names a scope column does when its value\n * disagrees with the resolved scope. `reject` refuses the write and writes nothing - for\n * `createAll` not even the valid rows. `assign` also fills a scope column that is ABSENT from a\n * created row, when the scope is a single equality; a value that is present and disagrees is\n * still refused.\n *\n * The scope's columns and allowed values are read from the resolved `where` (equality, `eq`, `inq`\n * and arrays, `and`, and an `or` over one column). Any other shape cannot be checked, and the write\n * is refused with its own message - never skipped. `ScopeFilters.UNRESTRICTED` bypasses the guard\n * too, which is the deliberate way to write across scopes (system scope, an admin role).\n *\n * Not checked: an update that does not name the scope column (the row was already selected through\n * the scoped `where`), and raw statements that bypass the repository.\n *\n * @default 'reject'\n */\n mode?: TScopeWriteGuard;\n\n /**\n * `true` lets a restricted caller write `null` to a scope column, or leave it out on create: the\n * row has no owner and is shared. Without it, `null` is refused like any other value\n * outside the scope, even when the resolved scope has a `null` branch (that branch lets the caller\n * READ shared rows, a separate permission). Reads are scoped as before.\n *\n * @default false\n */\n sharedRows?: boolean;\n}\n\n/**\n * Row access for `@model` settings.access - resolved per query, so it can depend on the current\n * request (tenant, org, membership). Framework-internal escape hatches aside, nothing short of\n * removing this setting from the model turns scoping off.\n *\n * @example\n * ```typescript\n * import { model, ScopeWriteGuards } from '@venizia/ignis';\n * import { ModelFactory } from '@venizia/ignis-connectors/postgres';\n * import { pgTable, serial, text } from 'drizzle-orm/pg-core';\n *\n * const productTable = pgTable('Product', { id: serial('id').primaryKey(), merchantId: text('merchant_id') });\n *\n * export @model({ settings: { access: {\n * resolve: () => ({ merchantId: 'm-1' }),\n * write: { mode: ScopeWriteGuards.ASSIGN },\n * } } })\n * class Product extends ModelFactory.defineEntity({ table: productTable }) {}\n * ```\n */\nexport interface IModelAccessSettings {\n /** A model declares a resolver or a `through`, never both. */\n through?: never;\n\n /**\n * Returns the scope `where`; `ScopeFilters.UNRESTRICTED` to apply no scope for THIS call (an\n * internal operator, a caller the application has decided sees everything); or null/undefined\n * when this caller's scope cannot be determined at all.\n *\n * Receives `{ operation }`: the one concrete operation the call performs (`ScopeOperations.READ`,\n * `CREATE`, `UPDATE` or `DELETE`, never a group), so one function can answer a wide scope for a\n * read and a narrow one for a write. A read, and an included relation, pass `READ`; a create passes\n * `CREATE`; an update passes `UPDATE` for the payload check and for choosing the rows to update; a\n * delete, a soft delete included, passes `DELETE` for both; a restore passes `UPDATE`. A read with a\n * row `lock` passes `READ`. A resolver that takes no argument keeps working. An `or` over different\n * columns is still refused on a write, so return the narrow scope for a write operation.\n */\n resolve: (context: {\n operation: TScopeOperation;\n }) => TNullable<TWhere> | typeof ScopeFilters.UNRESTRICTED;\n\n /**\n * What `applyScopeFilter` does when `resolve()` returns null/undefined - no request context, no\n * tenant, a background job. With `deny`, an unresolved scope matches zero rows, never\n * every row. `allow` is an explicit, reviewed opt-out for migrations and background jobs, declared\n * per MODEL - it cannot express a per-USER bypass; use `ScopeFilters.UNRESTRICTED` for that.\n *\n * @default 'deny'\n */\n onMissing?: TScopeFilterMissingBehavior;\n\n /**\n * The property names the write guard checks. Optional: with none declared the guard checks every\n * column the resolved scope constrains. When declared, each name must exist on the model (checked\n * at boot), and a resolved scope that constrains any other column is refused as unverifiable.\n */\n columns?: string[];\n\n /** What a restricted caller may write to the scope columns. See {@link IModelAccessWriteSettings}. */\n write?: IModelAccessWriteSettings;\n}\n\n/**\n * Row access for a child model that has no scope columns of its own: it inherits the scope of the parent a `one`\n * relation points at. A parent that resolves no scope always denies the child: `onMissing` is not offered here, because\n * `'allow'` would show the child's rows of every tenant while the parent shows none.\n *\n * @example\n * ```typescript\n * import { model, ScopeThrough } from '@venizia/ignis';\n * import { ModelFactory, one } from '@venizia/ignis-connectors/postgres';\n * import { integer, pgTable, serial } from 'drizzle-orm/pg-core';\n * const productTable = pgTable('Product', { id: serial('id').primaryKey() });\n * const variantTable = pgTable('Variant', {\n * id: serial('id').primaryKey(),\n * productId: integer('product_id').references(() => productTable.id),\n * });\n * const VariantBase = ModelFactory.defineEntity({ table: variantTable, relations: () => ({ product: one(productTable) }) });\n * export @model({ settings: { access: { through: ScopeThrough.of({ entity: VariantBase, relation: 'product' }) } } })\n * class Variant extends VariantBase {}\n * ```\n *\n * @example\n * ```typescript\n * // A hand-written entity declares the same relation by hand.\n * import { ScopeThrough } from '@venizia/ignis';\n * import { BaseEntity, one, RelationDeclarations } from '@venizia/ignis-connectors/postgres';\n * import { integer, pgTable, serial } from 'drizzle-orm/pg-core';\n * const productTable = pgTable('Product', { id: serial('id').primaryKey() });\n * const variantTable = pgTable('Variant', { id: serial('id').primaryKey(), productId: integer('product_id').references(() => productTable.id) });\n * const relations = { product: one(productTable) };\n * class VariantBase extends BaseEntity<typeof variantTable> {\n * static override schema = variantTable;\n * static readonly relationDefinitions = relations;\n * static override relations = () => RelationDeclarations.toRelationConfigs({ relations });\n * }\n * const through = ScopeThrough.of({ entity: VariantBase, relation: 'product' });\n * ```\n */\nexport interface IModelAccessThroughSettings {\n through: ScopeThrough;\n onMissing?: never;\n resolve?: never;\n columns?: never;\n write?: never;\n}\n\n/** The two shapes of `@model` settings.access: a resolver, or a `through`. */\nexport type TModelAccessSettings = IModelAccessSettings | IModelAccessThroughSettings;\n\n/** What a query runs with when it names nothing (`@model` settings.query). */\nexport interface IModelQuerySettings {\n /** Default filter auto-applied to all repository operations. Bypassable via shouldSkipDefaultFilter. */\n filter?: TFilter;\n\n limit?: {\n /**\n * Row limit when a query omits `limit`. Must be a positive integer.\n *\n * @default DEFAULT_LIMIT\n */\n default?: number;\n\n /**\n * Largest `limit` a CALLER may ask for. Must be a positive integer.\n *\n * Policy, not capacity - the engine's own ceiling sits far above it. The number is chosen so\n * that reaching it means the caller is doing something unusual, and raising it is how a model\n * says so deliberately.\n *\n * @default DEFAULT_MAX_LIMIT\n */\n max?: number;\n };\n}\n\n/** Property groups of `@model` settings. */\nexport interface IModelProperties {\n /** Properties excluded from all query results at SQL level. */\n hidden?: string[];\n\n /**\n * Properties the server fills on every write, which a generated create or update body leaves out.\n *\n * @default AuditFields.SCHEME_SET\n */\n stamped?: ReadonlyArray<string> | ReadonlySet<string>;\n}\n\n/** Per-model settings passed to `@model` as `settings`. */\nexport interface IModelSettings {\n properties?: IModelProperties;\n\n /** Default filter and limits of a query: `filter`, `limit.default`, `limit.max`. */\n query?: IModelQuerySettings;\n\n /**\n * Row access: the scope ANDed into every read and write whose scope is expressible as a filter\n * clause, NOT removable by `shouldSkipDefaultFilter`, and the guard that holds writes to it.\n * Ownership resolved per row or through a polymorphic reference is NOT expressible here - that\n * check is still the application's to perform.\n *\n * Relational repositories only - a search-backed model (Typesense, Meilisearch) never reads\n * this setting, so mirroring a scoped entity into a search index needs its own query-time scope.\n */\n access?: TModelAccessSettings;\n\n /** Authorization settings for this model (principal name, etc.). */\n authorize?: IModelAuthorizeSettings;\n}\n\n/** Whether tooling that reads the model registry should migrate this model (`@model({ migration })`). */\nexport interface IModelMigrationSettings {\n /**\n * `false` marks the model as one a migration tool leaves alone. IGNIS generates no migrations itself.\n *\n * @default true\n */\n use?: boolean;\n}\n\n/** Metadata accepted by `@model`. */\nexport interface IModelMetadata extends IArtifactRegistrationOptions {\n /**\n * `ModelTypes.ENTITY` is the only value.\n *\n * @default ModelTypes.ENTITY\n */\n type?: TModelType;\n tableName?: string;\n\n /** Migration marker for consumer tooling that reads the public registry. */\n migration?: IModelMigrationSettings;\n\n settings?: IModelSettings;\n}\n\n/** Static members an entity class carries: its `schema` and its `relations` (value or resolver). */\nexport interface IEntityStatics {\n schema?: unknown;\n relations?: TValueOrResolver<Array<unknown>>;\n}\n\n/** A model class together with its entity statics. */\nexport type TModelClass<Model extends AbstractEntity = AbstractEntity> = TClass<Model> &\n IEntityStatics;\n\n/** Decorator target for model classes (supports both strongly typed and ClassDecorator patterns). */\nexport type TDecoratorModelTarget<Model extends AbstractEntity = AbstractEntity> =\n | TModelClass<Model>\n | (Function & IEntityStatics);\n\n/** One model as stored in the metadata registry: class, metadata and schema, with lazily resolved relations. */\nexport interface IModelRegistryEntry<Model extends AbstractEntity = AbstractEntity> {\n target: TValueOrResolver<TClass<Model>>;\n metadata: IModelMetadata;\n schema: unknown;\n\n /** Lazy resolver to avoid circular deps. Resolved when DataSource builds schema. */\n relationsResolver?: TValueOrResolver<Array<unknown>>;\n\n /** Cache populated on first buildSchema() call. */\n _builtRelations?: unknown;\n}\n"]}
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../../../../../src/helpers/inversion/common/types/model.ts"],"names":[],"mappings":"","sourcesContent":["import type { AbstractEntity, TModelType } from '@/base/models';\nimport type {\n ScopeFilters,\n ScopeThrough,\n TFilter,\n TScopeFilterMissingBehavior,\n TScopeOperation,\n TScopeWriteGuard,\n TWhere,\n} from '@/base/repositories';\nimport type { TClass, TNullable, TValueOrResolver } from '@venizia/ignis-helpers/common';\nimport type { IArtifactRegistrationOptions } from './artifact';\n\n/** The `authorize` settings of a model. */\nexport interface IModelAuthorizeSettings {\n /** The authorization principal name (resource/subject) for this model. */\n principal: string;\n /** Extensible - consumers can add any extra authorization metadata. */\n [extra: string | symbol]: unknown;\n}\n\n/** What a restricted caller may write to the scope columns (`@model` settings.access.write). */\nexport interface IModelAccessWriteSettings {\n /**\n * What a create, createAll or an update payload that names a scope column does when its value\n * disagrees with the resolved scope. `reject` refuses the write and writes nothing - for\n * `createAll` not even the valid rows. `assign` also fills a scope column that is ABSENT from a\n * created row, when the scope is a single equality; a value that is present and disagrees is\n * still refused.\n *\n * The scope's columns and allowed values are read from the resolved `where` (equality, `eq`, `inq`\n * and arrays, `and`, and an `or` over one column). Any other shape cannot be checked, and the write\n * is refused with its own message - never skipped. `ScopeFilters.UNRESTRICTED` bypasses the guard\n * too, which is the deliberate way to write across scopes (system scope, an admin role).\n *\n * Not checked: an update that does not name the scope column (the row was already selected through\n * the scoped `where`), and raw statements that bypass the repository.\n *\n * @default 'reject'\n */\n mode?: TScopeWriteGuard;\n\n /**\n * `true` lets a restricted caller write `null` to a scope column, or leave it out on create: the\n * row has no owner and is shared. Without it, `null` is refused like any other value\n * outside the scope, even when the resolved scope has a `null` branch (that branch lets the caller\n * READ shared rows, a separate permission). Reads are scoped as before.\n *\n * @default false\n */\n sharedRows?: boolean;\n}\n\n/**\n * Row access for `@model` settings.access - resolved per query, so it can depend on the current\n * request (tenant, org, membership). Framework-internal escape hatches aside, nothing short of\n * removing this setting from the model turns scoping off.\n *\n * @example\n * ```typescript\n * import { model, ScopeWriteGuards } from '@venizia/ignis';\n * import { ModelFactory } from '@venizia/ignis-connectors/postgres';\n * import { pgTable, serial, text } from 'drizzle-orm/pg-core';\n *\n * const productTable = pgTable('Product', { id: serial('id').primaryKey(), merchantId: text('merchant_id') });\n *\n * export @model({ settings: { access: {\n * resolve: () => ({ merchantId: 'm-1' }),\n * write: { mode: ScopeWriteGuards.ASSIGN },\n * } } })\n * class Product extends ModelFactory.defineEntity({ table: productTable }) {}\n * ```\n */\nexport interface IModelAccessSettings {\n /** A model declares a resolver or a `through`, never both. */\n through?: never;\n\n /**\n * Returns the scope `where`; `ScopeFilters.UNRESTRICTED` to apply no scope for THIS call (an\n * internal operator, a caller the application has decided sees everything); or null/undefined\n * when this caller's scope cannot be determined at all.\n *\n * Receives `{ operation }`: the one concrete operation the call performs (`ScopeOperations.READ`,\n * `CREATE`, `UPDATE` or `DELETE`, never a group), so one function can answer a wide scope for a\n * read and a narrow one for a write. A read, and an included relation, pass `READ`; a create passes\n * `CREATE`; an update passes `UPDATE` for the payload check and for choosing the rows to update; a\n * delete, a soft delete included, passes `DELETE` for both; a restore passes `UPDATE`. A read with a\n * row `lock` passes `READ`. A resolver that takes no argument keeps working. An `or` over different\n * columns is still refused on a write, so return the narrow scope for a write operation.\n */\n resolve: (context: {\n operation: TScopeOperation;\n }) => TNullable<TWhere> | typeof ScopeFilters.UNRESTRICTED;\n\n /**\n * What `applyScopeFilter` does when `resolve()` returns null/undefined - no request context, no\n * tenant, a background job. With `deny`, an unresolved scope matches zero rows, never\n * every row. `allow` is an explicit, reviewed opt-out for migrations and background jobs, declared\n * per MODEL - it cannot express a per-USER bypass; use `ScopeFilters.UNRESTRICTED` for that.\n *\n * @default 'deny'\n */\n onMissing?: TScopeFilterMissingBehavior;\n\n /**\n * The property names the write guard checks. Optional: with none declared the guard checks every\n * column the resolved scope constrains. When declared, each name must exist on the model (checked\n * at boot), and a resolved scope that constrains any other column is refused as unverifiable.\n */\n columns?: string[];\n\n /** What a restricted caller may write to the scope columns. See {@link IModelAccessWriteSettings}. */\n write?: IModelAccessWriteSettings;\n}\n\n/**\n * Row access for a child model that has no scope columns of its own: it inherits the scope of the parent a `one`\n * relation points at. A parent that resolves no scope always denies the child: `onMissing` is not offered here, because\n * `'allow'` would show the child's rows of every tenant while the parent shows none.\n *\n * @example\n * ```typescript\n * import { model, ScopeThrough } from '@venizia/ignis';\n * import { ModelFactory, one } from '@venizia/ignis-connectors/postgres';\n * import { integer, pgTable, serial } from 'drizzle-orm/pg-core';\n * const productTable = pgTable('Product', { id: serial('id').primaryKey() });\n * const variantTable = pgTable('Variant', {\n * id: serial('id').primaryKey(),\n * productId: integer('product_id').references(() => productTable.id),\n * });\n * const VariantBase = ModelFactory.defineEntity({ table: variantTable, relations: () => ({ product: one(productTable) }) });\n * export @model({ settings: { access: { through: ScopeThrough.of({ entity: VariantBase, relation: 'product' }) } } })\n * class Variant extends VariantBase {}\n * ```\n *\n * @example\n * ```typescript\n * // A hand-written entity declares the same relation by hand.\n * import { ScopeThrough } from '@venizia/ignis';\n * import { BaseEntity, one, RelationDeclarations } from '@venizia/ignis-connectors/postgres';\n * import { integer, pgTable, serial } from 'drizzle-orm/pg-core';\n * const productTable = pgTable('Product', { id: serial('id').primaryKey() });\n * const variantTable = pgTable('Variant', { id: serial('id').primaryKey(), productId: integer('product_id').references(() => productTable.id) });\n * const relations = { product: one(productTable) };\n * class VariantBase extends BaseEntity<typeof variantTable> {\n * static override schema = variantTable;\n * static readonly relationDefinitions = relations;\n * static override relations = () => RelationDeclarations.toRelationConfigs({ relations });\n * }\n * const through = ScopeThrough.of({ entity: VariantBase, relation: 'product' });\n * ```\n */\nexport interface IModelAccessThroughSettings {\n through: ScopeThrough;\n onMissing?: never;\n resolve?: never;\n columns?: never;\n write?: never;\n}\n\n/** The two shapes of `@model` settings.access: a resolver, or a `through`. */\nexport type TModelAccessSettings = IModelAccessSettings | IModelAccessThroughSettings;\n\n/** What a query runs with when it names nothing (`@model` settings.query). */\nexport interface IModelQuerySettings {\n /** Default filter auto-applied to all repository operations. Bypassable via shouldSkipDefaultFilter. */\n filter?: TFilter;\n\n limit?: {\n /**\n * Row limit when a query omits `limit`. Must be a positive integer.\n *\n * @default DEFAULT_LIMIT\n */\n default?: number;\n\n /**\n * Largest `limit` a CALLER may ask for. Must be a positive integer.\n *\n * Policy, not capacity - the engine's own ceiling sits far above it. The number is chosen so\n * that reaching it means the caller is doing something unusual, and raising it is how a model\n * says so deliberately.\n *\n * @default DEFAULT_MAX_LIMIT\n */\n max?: number;\n };\n}\n\n/** Property groups of `@model` settings. */\nexport interface IModelProperties {\n /** Properties excluded from all query results at SQL level. */\n hidden?: string[];\n\n /**\n * Properties the server fills on every write, which a generated create or update body leaves out.\n *\n * @default AuditFields.SCHEME_SET\n */\n stamped?: ReadonlyArray<string> | ReadonlySet<string>;\n}\n\n/** Per-model settings passed to `@model` as `settings`. */\nexport interface IModelSettings {\n properties?: IModelProperties;\n\n /** Default filter and limits of a query: `filter`, `limit.default`, `limit.max`. */\n query?: IModelQuerySettings;\n\n /**\n * Row access: the scope ANDed into every read and write whose scope is expressible as a filter\n * clause, NOT removable by `shouldSkipDefaultFilter`, and the guard that holds writes to it.\n * Ownership resolved per row or through a polymorphic reference is NOT expressible here - that\n * check is still the application's to perform.\n *\n * Relational repositories only - a search-backed model (Typesense, Meilisearch) never reads\n * this setting, so mirroring a scoped entity into a search index needs its own query-time scope.\n */\n access?: TModelAccessSettings;\n\n /** Authorization settings for this model (principal name, etc.). */\n authorize?: IModelAuthorizeSettings;\n}\n\n/** Whether tooling that reads the model registry should migrate this model (`@model({ migration })`). */\nexport interface IModelMigrationSettings {\n /**\n * `false` marks the model as one a migration tool leaves alone. IGNIS generates no migrations itself.\n *\n * @default true\n */\n use?: boolean;\n}\n\n/** Metadata accepted by `@model`. */\nexport interface IModelMetadata extends IArtifactRegistrationOptions {\n /**\n * `ModelTypes.ENTITY` is the only value.\n *\n * @default ModelTypes.ENTITY\n */\n type?: TModelType;\n tableName?: string;\n\n /** Migration marker for consumer tooling that reads the public registry. */\n migration?: IModelMigrationSettings;\n\n settings?: IModelSettings;\n}\n\n/** Static members an entity class carries: its `schema` and its `relations` (value or resolver). */\nexport interface IEntityStatics {\n schema?: unknown;\n relations?: TValueOrResolver<Array<unknown>>;\n}\n\n/** A model class together with its entity statics. */\nexport type TModelClass<Model extends AbstractEntity = AbstractEntity> = TClass<Model> &\n IEntityStatics;\n\n/** Decorator target for model classes (supports both strongly typed and ClassDecorator patterns). */\nexport type TDecoratorModelTarget<Model extends AbstractEntity = AbstractEntity> =\n | TModelClass<Model>\n | (Function & IEntityStatics);\n\n/** One model as stored in the metadata registry: class, metadata and schema, with lazily resolved relations. */\nexport interface IModelRegistryEntry<Model extends AbstractEntity = AbstractEntity> {\n target: TValueOrResolver<TClass<Model>>;\n metadata: IModelMetadata;\n schema: unknown;\n\n /** Lazy resolver to avoid circular deps. Resolved when DataSource builds schema. */\n relationsResolver?: TValueOrResolver<Array<unknown>>;\n\n /** Cache populated on first buildSchema() call. */\n _builtRelations?: unknown;\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import 'reflect-metadata';
1
2
  import type { TMixinTarget } from '@venizia/ignis-helpers/common';
2
3
  import type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';
3
4
  import type { IArtifactMetadata, IProvideMetadata } from '../common/types/index.js';
@@ -25,12 +26,12 @@ export declare const ArtifactMetadataMixin: <BaseClass extends TMixinTarget<_Met
25
26
  getProvideMetadata<Target extends object = object>(opts: {
26
27
  target: Target;
27
28
  }): IProvideMetadata[];
28
- define: <Target extends object = object, Value = any>(opts: {
29
+ define: <Target extends object = object, Value = unknown>(opts: {
29
30
  target: Target;
30
31
  key: import("@venizia/ignis-inversion").TBindingKey;
31
32
  value: Value;
32
33
  }) => void;
33
- get: <Target extends object = object, Value_1 = any>(opts: {
34
+ get: <Target extends object = object, Value_1 = unknown>(opts: {
34
35
  target: Target;
35
36
  key: import("@venizia/ignis-inversion").TBindingKey;
36
37
  }) => Value_1 | undefined;
@@ -45,7 +46,7 @@ export declare const ArtifactMetadataMixin: <BaseClass extends TMixinTarget<_Met
45
46
  getKeys: <Target extends object = object>(opts: {
46
47
  target: Target;
47
48
  }) => import("@venizia/ignis-inversion").TBindingKey[];
48
- getMethodNames: <T = any>(opts: {
49
+ getMethodNames: <T = unknown>(opts: {
49
50
  target: import("@venizia/ignis-inversion").TClass<T>;
50
51
  }) => string[];
51
52
  clearMetadata: <T extends object = object>(opts: {
@@ -1,3 +1,4 @@
1
+ import 'reflect-metadata';
1
2
  import { MetadataKeys } from '../common/keys.js';
2
3
  export const ArtifactMetadataMixin = (baseClass) => {
3
4
  return class extends baseClass {
@@ -1 +1 @@
1
- {"version":3,"file":"artifact.mixin.js","sourceRoot":"","sources":["../../../../../src/helpers/inversion/mixins/artifact.mixin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,MAAM,CAAC,MAAM,qBAAqB,GAA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QAC1E,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { TMixinTarget } from '@venizia/ignis-helpers/common';\nimport type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';\nimport { MetadataKeys } from '../common/keys';\nimport type { IArtifactMetadata, IProvideMetadata } from '../common/types';\n\nexport const ArtifactMetadataMixin = <BaseClass extends TMixinTarget<_MetadataRegistry>>(\n baseClass: BaseClass,\n) => {\n return class extends baseClass {\n /** Every class a stereotype decorated, in decoration order - which is import order, and is identical in a bundle. Discovery reads this; registration order still comes from `order` and the configuration sort. */\n discoveredArtifacts: object[] = [];\n\n addDiscoveredArtifact<Target extends object = object>(opts: { target: Target }): void {\n if (this.discoveredArtifacts.includes(opts.target)) {\n return;\n }\n\n this.discoveredArtifacts.push(opts.target);\n }\n\n getDiscoveredArtifacts(): ReadonlyArray<object> {\n return [...this.discoveredArtifacts];\n }\n\n /** Tests only: the list is process-wide and a suite that decorates classes would leak into the next one. */\n clearDiscoveredArtifacts(): void {\n this.discoveredArtifacts = [];\n }\n\n setArtifactMetadata<Target extends object = object, ApplicationType = unknown>(opts: {\n target: Target;\n metadata: IArtifactMetadata<ApplicationType>;\n }): void {\n Reflect.defineMetadata(MetadataKeys.ARTIFACT, opts.metadata, opts.target);\n }\n\n // Own metadata only: a subclass of a decorated class is not itself an artifact.\n getArtifactMetadata<Target extends object = object>(opts: {\n target: Target;\n }): IArtifactMetadata | undefined {\n return Reflect.getOwnMetadata(MetadataKeys.ARTIFACT, opts.target);\n }\n\n addProvideMetadata<Target extends object = object>(opts: {\n target: Target;\n metadata: IProvideMetadata;\n }): void {\n const current = this.getProvideMetadata({ target: opts.target });\n Reflect.defineMetadata(MetadataKeys.PROVIDES, [...current, opts.metadata], opts.target);\n }\n\n getProvideMetadata<Target extends object = object>(opts: {\n target: Target;\n }): IProvideMetadata[] {\n return Reflect.getOwnMetadata(MetadataKeys.PROVIDES, opts.target) ?? [];\n }\n };\n};\n"]}
1
+ {"version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AAI,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1F,CAAC;QAED,kBAAkB,CAAiC,IAElD;YACC,OAAO,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC1E,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import 'reflect-metadata';\n\nimport type { TMixinTarget } from '@venizia/ignis-helpers/common';\nimport type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';\nimport { MetadataKeys } from '../common/keys';\nimport type { IArtifactMetadata, IProvideMetadata } from '../common/types';\n\nexport const ArtifactMetadataMixin = <BaseClass extends TMixinTarget<_MetadataRegistry>>(\n baseClass: BaseClass,\n) => {\n return class extends baseClass {\n /** Every class a stereotype decorated, in decoration order - which is import order, and is identical in a bundle. Discovery reads this; registration order still comes from `order` and the configuration sort. */\n discoveredArtifacts: object[] = [];\n\n addDiscoveredArtifact<Target extends object = object>(opts: { target: Target }): void {\n if (this.discoveredArtifacts.includes(opts.target)) {\n return;\n }\n\n this.discoveredArtifacts.push(opts.target);\n }\n\n getDiscoveredArtifacts(): ReadonlyArray<object> {\n return [...this.discoveredArtifacts];\n }\n\n /** Tests only: the list is process-wide and a suite that decorates classes would leak into the next one. */\n clearDiscoveredArtifacts(): void {\n this.discoveredArtifacts = [];\n }\n\n setArtifactMetadata<Target extends object = object, ApplicationType = unknown>(opts: {\n target: Target;\n metadata: IArtifactMetadata<ApplicationType>;\n }): void {\n Reflect.defineMetadata(MetadataKeys.ARTIFACT, opts.metadata, opts.target);\n }\n\n // Own metadata only: a subclass of a decorated class is not itself an artifact.\n getArtifactMetadata<Target extends object = object>(opts: {\n target: Target;\n }): IArtifactMetadata | undefined {\n return Reflect.getOwnMetadata(MetadataKeys.ARTIFACT, opts.target);\n }\n\n addProvideMetadata<Target extends object = object>(opts: {\n target: Target;\n metadata: IProvideMetadata;\n }): void {\n const current = this.getProvideMetadata({ target: opts.target });\n Reflect.defineMetadata(MetadataKeys.PROVIDES, [...current, opts.metadata], opts.target);\n }\n\n getProvideMetadata<Target extends object = object>(opts: {\n target: Target;\n }): IProvideMetadata[] {\n return Reflect.getOwnMetadata(MetadataKeys.PROVIDES, opts.target) ?? [];\n }\n };\n};\n"]}
@@ -1,3 +1,4 @@
1
+ import 'reflect-metadata';
1
2
  import type { TMixinTarget } from '@venizia/ignis-helpers/common';
2
3
  import type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';
3
4
  import type { IGrpcControllerMetadata, IRestControllerMetadata, TControllerMetadata } from '../../common/types/index.js';
@@ -16,12 +17,12 @@ export declare const ControllerMetadataMixin: <BaseClass extends TMixinTarget<_M
16
17
  getGrpcControllerMetadata<Target extends object = object>(opts: {
17
18
  target: Target;
18
19
  }): IGrpcControllerMetadata | undefined;
19
- define: <Target extends object = object, Value = any>(opts: {
20
+ define: <Target extends object = object, Value = unknown>(opts: {
20
21
  target: Target;
21
22
  key: import("@venizia/ignis-inversion").TBindingKey;
22
23
  value: Value;
23
24
  }) => void;
24
- get: <Target extends object = object, Value_1 = any>(opts: {
25
+ get: <Target extends object = object, Value_1 = unknown>(opts: {
25
26
  target: Target;
26
27
  key: import("@venizia/ignis-inversion").TBindingKey;
27
28
  }) => Value_1 | undefined;
@@ -36,7 +37,7 @@ export declare const ControllerMetadataMixin: <BaseClass extends TMixinTarget<_M
36
37
  getKeys: <Target extends object = object>(opts: {
37
38
  target: Target;
38
39
  }) => import("@venizia/ignis-inversion").TBindingKey[];
39
- getMethodNames: <T = any>(opts: {
40
+ getMethodNames: <T = unknown>(opts: {
40
41
  target: import("@venizia/ignis-inversion").TClass<T>;
41
42
  }) => string[];
42
43
  clearMetadata: <T extends object = object>(opts: {
@@ -1,3 +1,4 @@
1
+ import 'reflect-metadata';
1
2
  import { ControllerTransports } from '../../../../base/controllers/common/constants.js';
2
3
  import { MetadataKeys } from '../../common/keys.js';
3
4
  export const ControllerMetadataMixin = (baseClass) => {
@@ -1 +1 @@
1
- {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../../../src/helpers/inversion/mixins/controllers/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAG3E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAOjD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,SAAoB,EACpB,EAAE;IACF,OAAO,KAAM,SAAQ,SAAS;QAC5B,qBAAqB,CAAiC,IAGrD;YACC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;YAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;YAC9D,OAAO,CAAC,cAAc,CACpB,YAAY,CAAC,UAAU,EACvB,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,EACrC,MAAM,CACP,CAAC;QACJ,CAAC;QAED,qBAAqB,CAAiC,IAErD;YACC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;YAExB,OAAO,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC9D,CAAC;QAED,yBAAyB,CAAiC,IAEzD;YACC,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;YAElD,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,SAAS,KAAK,oBAAoB,CAAC,IAAI,EAAE,CAAC;gBAClE,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,OAAO,QAAmC,CAAC;QAC7C,CAAC;QAED,yBAAyB,CAAiC,IAEzD;YACC,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;YAElD,IAAI,QAAQ,EAAE,SAAS,KAAK,oBAAoB,CAAC,IAAI,EAAE,CAAC;gBACtD,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,OAAO,QAAmC,CAAC;QAC7C,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { ControllerTransports } from '@/base/controllers/common/constants';\nimport type { TMixinTarget } from '@venizia/ignis-helpers/common';\nimport type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';\nimport { MetadataKeys } from '../../common/keys';\nimport type {\n IGrpcControllerMetadata,\n IRestControllerMetadata,\n TControllerMetadata,\n} from '../../common/types';\n\nexport const ControllerMetadataMixin = <BaseClass extends TMixinTarget<_MetadataRegistry>>(\n baseClass: BaseClass,\n) => {\n return class extends baseClass {\n setControllerMetadata<Target extends object = object>(opts: {\n target: Target;\n metadata: TControllerMetadata;\n }): void {\n const { target, metadata } = opts;\n const existing = this.getControllerMetadata({ target }) ?? {};\n Reflect.defineMetadata(\n MetadataKeys.CONTROLLER,\n Object.assign({}, existing, metadata),\n target,\n );\n }\n\n getControllerMetadata<Target extends object = object>(opts: {\n target: Target;\n }): TControllerMetadata | undefined {\n const { target } = opts;\n\n return Reflect.getMetadata(MetadataKeys.CONTROLLER, target);\n }\n\n getRestControllerMetadata<Target extends object = object>(opts: {\n target: Target;\n }): IRestControllerMetadata | undefined {\n const metadata = this.getControllerMetadata(opts);\n\n if (!metadata || metadata.transport === ControllerTransports.GRPC) {\n return undefined;\n }\n\n return metadata as IRestControllerMetadata;\n }\n\n getGrpcControllerMetadata<Target extends object = object>(opts: {\n target: Target;\n }): IGrpcControllerMetadata | undefined {\n const metadata = this.getControllerMetadata(opts);\n\n if (metadata?.transport !== ControllerTransports.GRPC) {\n return undefined;\n }\n\n return metadata as IGrpcControllerMetadata;\n }\n };\n};\n"]}
1
+ {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../../../src/helpers/inversion/mixins/controllers/controller.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,oBA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\n\nimport { ControllerTransports } from '@/base/controllers/common/constants';\nimport type { TMixinTarget } from '@venizia/ignis-helpers/common';\nimport type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';\nimport { MetadataKeys } from '../../common/keys';\nimport type {\n IGrpcControllerMetadata,\n IRestControllerMetadata,\n TControllerMetadata,\n} from '../../common/types';\n\nexport const ControllerMetadataMixin = <BaseClass extends TMixinTarget<_MetadataRegistry>>(\n baseClass: BaseClass,\n) => {\n return class extends baseClass {\n setControllerMetadata<Target extends object = object>(opts: {\n target: Target;\n metadata: TControllerMetadata;\n }): void {\n const { target, metadata } = opts;\n const existing = this.getControllerMetadata({ target }) ?? {};\n Reflect.defineMetadata(\n MetadataKeys.CONTROLLER,\n Object.assign({}, existing, metadata),\n target,\n );\n }\n\n getControllerMetadata<Target extends object = object>(opts: {\n target: Target;\n }): TControllerMetadata | undefined {\n const { target } = opts;\n\n return Reflect.getMetadata(MetadataKeys.CONTROLLER, target);\n }\n\n getRestControllerMetadata<Target extends object = object>(opts: {\n target: Target;\n }): IRestControllerMetadata | undefined {\n const metadata = this.getControllerMetadata(opts);\n\n if (!metadata || metadata.transport === ControllerTransports.GRPC) {\n return undefined;\n }\n\n return metadata as IRestControllerMetadata;\n }\n\n getGrpcControllerMetadata<Target extends object = object>(opts: {\n target: Target;\n }): IGrpcControllerMetadata | undefined {\n const metadata = this.getControllerMetadata(opts);\n\n if (metadata?.transport !== ControllerTransports.GRPC) {\n return undefined;\n }\n\n return metadata as IGrpcControllerMetadata;\n }\n };\n};\n"]}
@@ -1,3 +1,4 @@
1
+ import 'reflect-metadata';
1
2
  import type { TMixinTarget } from '@venizia/ignis-helpers/common';
2
3
  import type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';
3
4
  import type { IRpcMetadata } from '../../common/types/index.js';
@@ -18,12 +19,12 @@ export declare const GrpcControllerMetadataMixin: <BaseClass extends TMixinTarge
18
19
  hasRpcs<Target extends object = object>(opts: {
19
20
  target: Target;
20
21
  }): boolean;
21
- define: <Target extends object = object, Value = any>(opts: {
22
+ define: <Target extends object = object, Value = unknown>(opts: {
22
23
  target: Target;
23
24
  key: import("@venizia/ignis-inversion").TBindingKey;
24
25
  value: Value;
25
26
  }) => void;
26
- get: <Target extends object = object, Value_1 = any>(opts: {
27
+ get: <Target extends object = object, Value_1 = unknown>(opts: {
27
28
  target: Target;
28
29
  key: import("@venizia/ignis-inversion").TBindingKey;
29
30
  }) => Value_1 | undefined;
@@ -38,7 +39,7 @@ export declare const GrpcControllerMetadataMixin: <BaseClass extends TMixinTarge
38
39
  getKeys: <Target extends object = object>(opts: {
39
40
  target: Target;
40
41
  }) => import("@venizia/ignis-inversion").TBindingKey[];
41
- getMethodNames: <T = any>(opts: {
42
+ getMethodNames: <T = unknown>(opts: {
42
43
  target: import("@venizia/ignis-inversion").TClass<T>;
43
44
  }) => string[];
44
45
  clearMetadata: <T extends object = object>(opts: {
@@ -1,3 +1,4 @@
1
+ import 'reflect-metadata';
1
2
  import { MetadataKeys } from '../../common/keys.js';
2
3
  export const GrpcControllerMetadataMixin = (baseClass) => {
3
4
  return class extends baseClass {
@@ -1 +1 @@
1
- {"version":3,"file":"grpc.js","sourceRoot":"","sources":["../../../../../../src/helpers/inversion/mixins/controllers/grpc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,SAAoB,EACpB,EAAE;IACF,OAAO,KAAM,SAAQ,SAAS;QAC5B,MAAM,CAAiC,IAItC;YACC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;YAE7C,sLAAsL;YACtL,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YAC3C,MAAM,IAAI,GACR,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,qBAAqB,EAAE,MAAM,CAAC;gBAClE,IAAI,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;YAE3B,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YAC9B,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,qBAAqB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC3E,CAAC;QAED,OAAO,CAAiC,IAEvC;YACC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;YAExB,OAAO,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;QACzE,CAAC;QAED,MAAM,CAAiC,IAGtC;YACC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;YACpC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YAEtC,OAAO,IAAI,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;QAC/B,CAAC;QAED,OAAO,CAAiC,IAAwB;YAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAEhC,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAC7C,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { TMixinTarget } from '@venizia/ignis-helpers/common';\nimport type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';\nimport { MetadataKeys } from '../../common/keys';\nimport type { IRpcMetadata } from '../../common/types';\n\nexport const GrpcControllerMetadataMixin = <BaseClass extends TMixinTarget<_MetadataRegistry>>(\n baseClass: BaseClass,\n) => {\n return class extends baseClass {\n addRpc<Target extends object = object>(opts: {\n target: Target;\n methodName: string | symbol;\n configs: IRpcMetadata;\n }): void {\n const { target, methodName, configs } = opts;\n\n // Copy-on-write, same reason as RestControllerMetadataMixin.addRoute: getRpcs() walks the prototype chain, so mutating the Map it returns would leak a subclass's rpcs onto its base.\n const inherited = this.getRpcs({ target });\n const rpcs: Map<string | symbol, IRpcMetadata> =\n Reflect.getOwnMetadata(MetadataKeys.CONTROLLER_GRPC_ROUTE, target) ??\n new Map(inherited ?? []);\n\n rpcs.set(methodName, configs);\n Reflect.defineMetadata(MetadataKeys.CONTROLLER_GRPC_ROUTE, rpcs, target);\n }\n\n getRpcs<Target extends object = object>(opts: {\n target: Target;\n }): Map<string | symbol, IRpcMetadata> | undefined {\n const { target } = opts;\n\n return Reflect.getMetadata(MetadataKeys.CONTROLLER_GRPC_ROUTE, target);\n }\n\n getRpc<Target extends object = object>(opts: {\n target: Target;\n methodName: string | symbol;\n }): IRpcMetadata | undefined {\n const { target, methodName } = opts;\n const rpcs = this.getRpcs({ target });\n\n return rpcs?.get(methodName);\n }\n\n hasRpcs<Target extends object = object>(opts: { target: Target }): boolean {\n const rpcs = this.getRpcs(opts);\n\n return rpcs !== undefined && rpcs.size > 0;\n }\n };\n};\n"]}
1
+ {"version":3,"file":"grpc.js","sourceRoot":"","sources":["../../../../../../src/helpers/inversion/mixins/controllers/grpc.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAI1B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,SAAoB,EACpB,EAAE;IACF,OAAO,KAAM,SAAQ,SAAS;QAC5B,MAAM,CAAiC,IAItC;YACC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;YAE7C,sLAAsL;YACtL,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YAC3C,MAAM,IAAI,GACR,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,qBAAqB,EAAE,MAAM,CAAC;gBAClE,IAAI,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;YAE3B,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YAC9B,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,qBAAqB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC3E,CAAC;QAED,OAAO,CAAiC,IAEvC;YACC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;YAExB,OAAO,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;QACzE,CAAC;QAED,MAAM,CAAiC,IAGtC;YACC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;YACpC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YAEtC,OAAO,IAAI,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;QAC/B,CAAC;QAED,OAAO,CAAiC,IAAwB;YAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAEhC,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAC7C,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import 'reflect-metadata';\n\nimport type { TMixinTarget } from '@venizia/ignis-helpers/common';\nimport type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';\nimport { MetadataKeys } from '../../common/keys';\nimport type { IRpcMetadata } from '../../common/types';\n\nexport const GrpcControllerMetadataMixin = <BaseClass extends TMixinTarget<_MetadataRegistry>>(\n baseClass: BaseClass,\n) => {\n return class extends baseClass {\n addRpc<Target extends object = object>(opts: {\n target: Target;\n methodName: string | symbol;\n configs: IRpcMetadata;\n }): void {\n const { target, methodName, configs } = opts;\n\n // Copy-on-write, same reason as RestControllerMetadataMixin.addRoute: getRpcs() walks the prototype chain, so mutating the Map it returns would leak a subclass's rpcs onto its base.\n const inherited = this.getRpcs({ target });\n const rpcs: Map<string | symbol, IRpcMetadata> =\n Reflect.getOwnMetadata(MetadataKeys.CONTROLLER_GRPC_ROUTE, target) ??\n new Map(inherited ?? []);\n\n rpcs.set(methodName, configs);\n Reflect.defineMetadata(MetadataKeys.CONTROLLER_GRPC_ROUTE, rpcs, target);\n }\n\n getRpcs<Target extends object = object>(opts: {\n target: Target;\n }): Map<string | symbol, IRpcMetadata> | undefined {\n const { target } = opts;\n\n return Reflect.getMetadata(MetadataKeys.CONTROLLER_GRPC_ROUTE, target);\n }\n\n getRpc<Target extends object = object>(opts: {\n target: Target;\n methodName: string | symbol;\n }): IRpcMetadata | undefined {\n const { target, methodName } = opts;\n const rpcs = this.getRpcs({ target });\n\n return rpcs?.get(methodName);\n }\n\n hasRpcs<Target extends object = object>(opts: { target: Target }): boolean {\n const rpcs = this.getRpcs(opts);\n\n return rpcs !== undefined && rpcs.size > 0;\n }\n };\n};\n"]}
@@ -1,3 +1,4 @@
1
+ import 'reflect-metadata';
1
2
  import type { IAuthRouteConfig } from '../../../../base/controllers/common/types/index.js';
2
3
  import type { TMixinTarget } from '@venizia/ignis-helpers/common';
3
4
  import type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';
@@ -18,12 +19,12 @@ export declare const RestControllerMetadataMixin: <BaseClass extends TMixinTarge
18
19
  methodName: string | symbol;
19
20
  configs: IAuthRouteConfig;
20
21
  }): void;
21
- define: <Target extends object = object, Value = any>(opts: {
22
+ define: <Target extends object = object, Value = unknown>(opts: {
22
23
  target: Target;
23
24
  key: import("@venizia/ignis-inversion").TBindingKey;
24
25
  value: Value;
25
26
  }) => void;
26
- get: <Target extends object = object, Value_1 = any>(opts: {
27
+ get: <Target extends object = object, Value_1 = unknown>(opts: {
27
28
  target: Target;
28
29
  key: import("@venizia/ignis-inversion").TBindingKey;
29
30
  }) => Value_1 | undefined;
@@ -38,7 +39,7 @@ export declare const RestControllerMetadataMixin: <BaseClass extends TMixinTarge
38
39
  getKeys: <Target extends object = object>(opts: {
39
40
  target: Target;
40
41
  }) => import("@venizia/ignis-inversion").TBindingKey[];
41
- getMethodNames: <T = any>(opts: {
42
+ getMethodNames: <T = unknown>(opts: {
42
43
  target: import("@venizia/ignis-inversion").TClass<T>;
43
44
  }) => string[];
44
45
  clearMetadata: <T extends object = object>(opts: {
@@ -1,3 +1,4 @@
1
+ import 'reflect-metadata';
1
2
  import { MetadataKeys } from '../../common/keys.js';
2
3
  export const RestControllerMetadataMixin = (baseClass) => {
3
4
  return class extends baseClass {
@@ -1 +1 @@
1
- {"version":3,"file":"rest.js","sourceRoot":"","sources":["../../../../../../src/helpers/inversion/mixins/controllers/rest.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,SAAoB,EACpB,EAAE;IACF,OAAO,KAAM,SAAQ,SAAS;QAC5B,SAAS,CAAiC,IAEzC;YACC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;YAExB,OAAO,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;QACzE,CAAC;QAED,QAAQ,CAAiC,IAGxC;YACC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;YACpC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YAE1C,OAAO,MAAM,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;QACjC,CAAC;QAED,SAAS,CAAiC,IAAwB;YAChE,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YAEpC,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;QACjD,CAAC;QAED,QAAQ,CAAiC,IAIxC;YACC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;YAE7C,+NAA+N;YAC/N,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YAC7C,MAAM,MAAM,GACV,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,qBAAqB,EAAE,MAAM,CAAC;gBAClE,IAAI,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;YAE3B,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YAEhC,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,qBAAqB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC7E,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { IAuthRouteConfig } from '@/base/controllers/common/types';\nimport type { TMixinTarget } from '@venizia/ignis-helpers/common';\nimport type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';\nimport { MetadataKeys } from '../../common/keys';\n\nexport const RestControllerMetadataMixin = <BaseClass extends TMixinTarget<_MetadataRegistry>>(\n baseClass: BaseClass,\n) => {\n return class extends baseClass {\n getRoutes<Target extends object = object>(opts: {\n target: Target;\n }): Map<string | symbol, IAuthRouteConfig> | undefined {\n const { target } = opts;\n\n return Reflect.getMetadata(MetadataKeys.CONTROLLER_REST_ROUTE, target);\n }\n\n getRoute<Target extends object = object>(opts: {\n target: Target;\n methodName: string | symbol;\n }): IAuthRouteConfig | undefined {\n const { target, methodName } = opts;\n const routes = this.getRoutes({ target });\n\n return routes?.get(methodName);\n }\n\n hasRoutes<Target extends object = object>(opts: { target: Target }): boolean {\n const routes = this.getRoutes(opts);\n\n return routes !== undefined && routes.size > 0;\n }\n\n addRoute<Target extends object = object>(opts: {\n target: Target;\n methodName: string | symbol;\n configs: IAuthRouteConfig;\n }): void {\n const { target, methodName, configs } = opts;\n\n // Copy-on-write: getRoutes() walks the prototype chain, so a subclass would otherwise mutate the Map its base owns, leaking its routes onto the base and every sibling. Inherited routes stay visible - copied in, base first.\n const inherited = this.getRoutes({ target });\n const routes: Map<string | symbol, IAuthRouteConfig> =\n Reflect.getOwnMetadata(MetadataKeys.CONTROLLER_REST_ROUTE, target) ??\n new Map(inherited ?? []);\n\n routes.set(methodName, configs);\n\n Reflect.defineMetadata(MetadataKeys.CONTROLLER_REST_ROUTE, routes, target);\n }\n };\n};\n"]}
1
+ {"version":3,"file":"rest.js","sourceRoot":"","sources":["../../../../../../src/helpers/inversion/mixins/controllers/rest.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAK1B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,SAAoB,EACpB,EAAE;IACF,OAAO,KAAM,SAAQ,SAAS;QAC5B,SAAS,CAAiC,IAEzC;YACC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;YAExB,OAAO,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;QACzE,CAAC;QAED,QAAQ,CAAiC,IAGxC;YACC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;YACpC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YAE1C,OAAO,MAAM,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;QACjC,CAAC;QAED,SAAS,CAAiC,IAAwB;YAChE,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YAEpC,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;QACjD,CAAC;QAED,QAAQ,CAAiC,IAIxC;YACC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;YAE7C,+NAA+N;YAC/N,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YAC7C,MAAM,MAAM,GACV,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,qBAAqB,EAAE,MAAM,CAAC;gBAClE,IAAI,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;YAE3B,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YAEhC,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,qBAAqB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC7E,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import 'reflect-metadata';\n\nimport type { IAuthRouteConfig } from '@/base/controllers/common/types';\nimport type { TMixinTarget } from '@venizia/ignis-helpers/common';\nimport type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';\nimport { MetadataKeys } from '../../common/keys';\n\nexport const RestControllerMetadataMixin = <BaseClass extends TMixinTarget<_MetadataRegistry>>(\n baseClass: BaseClass,\n) => {\n return class extends baseClass {\n getRoutes<Target extends object = object>(opts: {\n target: Target;\n }): Map<string | symbol, IAuthRouteConfig> | undefined {\n const { target } = opts;\n\n return Reflect.getMetadata(MetadataKeys.CONTROLLER_REST_ROUTE, target);\n }\n\n getRoute<Target extends object = object>(opts: {\n target: Target;\n methodName: string | symbol;\n }): IAuthRouteConfig | undefined {\n const { target, methodName } = opts;\n const routes = this.getRoutes({ target });\n\n return routes?.get(methodName);\n }\n\n hasRoutes<Target extends object = object>(opts: { target: Target }): boolean {\n const routes = this.getRoutes(opts);\n\n return routes !== undefined && routes.size > 0;\n }\n\n addRoute<Target extends object = object>(opts: {\n target: Target;\n methodName: string | symbol;\n configs: IAuthRouteConfig;\n }): void {\n const { target, methodName, configs } = opts;\n\n // Copy-on-write: getRoutes() walks the prototype chain, so a subclass would otherwise mutate the Map its base owns, leaking its routes onto the base and every sibling. Inherited routes stay visible - copied in, base first.\n const inherited = this.getRoutes({ target });\n const routes: Map<string | symbol, IAuthRouteConfig> =\n Reflect.getOwnMetadata(MetadataKeys.CONTROLLER_REST_ROUTE, target) ??\n new Map(inherited ?? []);\n\n routes.set(methodName, configs);\n\n Reflect.defineMetadata(MetadataKeys.CONTROLLER_REST_ROUTE, routes, target);\n }\n };\n};\n"]}