@venizia/ignis-kernel 0.4.0 → 0.4.2

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 (191) hide show
  1. package/dist/cjs/base/applications/abstract.js +2 -2
  2. package/dist/cjs/base/applications/abstract.js.map +1 -1
  3. package/dist/cjs/base/applications/artifact-group.js +1 -1
  4. package/dist/cjs/base/applications/artifact-group.js.map +1 -1
  5. package/dist/cjs/base/applications/artifact-index.js +11 -11
  6. package/dist/cjs/base/applications/artifact-index.js.map +1 -1
  7. package/dist/cjs/base/applications/boot-sequence.js +1 -1
  8. package/dist/cjs/base/applications/boot-sequence.js.map +1 -1
  9. package/dist/cjs/base/applications/cors.d.ts +13 -0
  10. package/dist/cjs/base/applications/cors.d.ts.map +1 -0
  11. package/dist/cjs/base/applications/cors.js +43 -0
  12. package/dist/cjs/base/applications/cors.js.map +1 -0
  13. package/dist/cjs/base/applications/deprecations.d.ts +10 -0
  14. package/dist/cjs/base/applications/deprecations.d.ts.map +1 -0
  15. package/dist/cjs/base/applications/deprecations.js +23 -0
  16. package/dist/cjs/base/applications/deprecations.js.map +1 -0
  17. package/dist/cjs/base/applications/rest.d.ts.map +1 -1
  18. package/dist/cjs/base/applications/rest.js +11 -5
  19. package/dist/cjs/base/applications/rest.js.map +1 -1
  20. package/dist/cjs/base/auth/authenticate/common/codecs.js +2 -2
  21. package/dist/cjs/base/auth/authenticate/common/codecs.js.map +1 -1
  22. package/dist/cjs/base/auth/authenticate/providers/authentication.provider.js +1 -1
  23. package/dist/cjs/base/auth/authenticate/providers/authentication.provider.js.map +1 -1
  24. package/dist/cjs/base/auth/authenticate/strategies/strategy-registry.js +1 -1
  25. package/dist/cjs/base/auth/authenticate/strategies/strategy-registry.js.map +1 -1
  26. package/dist/cjs/base/auth/authorize/builders/grant.builder.js +12 -12
  27. package/dist/cjs/base/auth/authorize/builders/grant.builder.js.map +1 -1
  28. package/dist/cjs/base/auth/authorize/builders/permission.builder.js +1 -1
  29. package/dist/cjs/base/auth/authorize/builders/permission.builder.js.map +1 -1
  30. package/dist/cjs/base/auth/authorize/builders/policy.builder.js +1 -1
  31. package/dist/cjs/base/auth/authorize/builders/policy.builder.js.map +1 -1
  32. package/dist/cjs/base/auth/authorize/common/constants/authorization.d.ts.map +1 -1
  33. package/dist/cjs/base/auth/authorize/common/constants/authorization.js +2 -2
  34. package/dist/cjs/base/auth/authorize/common/constants/authorization.js.map +1 -1
  35. package/dist/cjs/base/auth/authorize/enforcers/enforcer-registry.js +1 -1
  36. package/dist/cjs/base/auth/authorize/enforcers/enforcer-registry.js.map +1 -1
  37. package/dist/cjs/base/auth/authorize/providers/authorization.provider.js +3 -3
  38. package/dist/cjs/base/auth/authorize/providers/authorization.provider.js.map +1 -1
  39. package/dist/cjs/base/controllers/factory/authorize-guard.d.ts +19 -0
  40. package/dist/cjs/base/controllers/factory/authorize-guard.d.ts.map +1 -0
  41. package/dist/cjs/base/controllers/factory/authorize-guard.js +60 -0
  42. package/dist/cjs/base/controllers/factory/authorize-guard.js.map +1 -0
  43. package/dist/cjs/base/controllers/factory/controller.d.ts +2 -2
  44. package/dist/cjs/base/controllers/factory/controller.d.ts.map +1 -1
  45. package/dist/cjs/base/controllers/factory/controller.js +9 -0
  46. package/dist/cjs/base/controllers/factory/controller.js.map +1 -1
  47. package/dist/cjs/base/controllers/factory/crud/abstract.d.ts +1 -1
  48. package/dist/cjs/base/controllers/factory/crud/abstract.d.ts.map +1 -1
  49. package/dist/cjs/base/controllers/factory/crud/abstract.js.map +1 -1
  50. package/dist/cjs/base/controllers/factory/definition.js +1 -1
  51. package/dist/cjs/base/controllers/factory/definition.js.map +1 -1
  52. package/dist/cjs/base/controllers/rest/extras.js +5 -5
  53. package/dist/cjs/base/controllers/rest/extras.js.map +1 -1
  54. package/dist/cjs/base/metadata/injectable.js +1 -1
  55. package/dist/cjs/base/metadata/injectable.js.map +1 -1
  56. package/dist/cjs/base/metadata/model-settings.d.ts +21 -0
  57. package/dist/cjs/base/metadata/model-settings.d.ts.map +1 -0
  58. package/dist/cjs/base/metadata/model-settings.js +77 -0
  59. package/dist/cjs/base/metadata/model-settings.js.map +1 -0
  60. package/dist/cjs/base/metadata/persistents.d.ts +1 -1
  61. package/dist/cjs/base/metadata/persistents.d.ts.map +1 -1
  62. package/dist/cjs/base/metadata/persistents.js +24 -12
  63. package/dist/cjs/base/metadata/persistents.js.map +1 -1
  64. package/dist/cjs/base/metadata/routes/controller.js +1 -1
  65. package/dist/cjs/base/metadata/routes/controller.js.map +1 -1
  66. package/dist/cjs/base/middlewares/app-error/app-error.middleware.js +3 -3
  67. package/dist/cjs/base/middlewares/app-error/app-error.middleware.js.map +1 -1
  68. package/dist/cjs/base/middlewares/app-error/zod.handler.js +2 -2
  69. package/dist/cjs/base/middlewares/app-error/zod.handler.js.map +1 -1
  70. package/dist/cjs/base/middlewares/form-body/form-body.middleware.js +2 -2
  71. package/dist/cjs/base/middlewares/form-body/form-body.middleware.js.map +1 -1
  72. package/dist/cjs/base/middlewares/not-found/not-found.middleware.js.map +1 -1
  73. package/dist/cjs/base/models/common/utilities.js +1 -1
  74. package/dist/cjs/base/models/common/utilities.js.map +1 -1
  75. package/dist/cjs/base/repositories/common/constants.d.ts +18 -1
  76. package/dist/cjs/base/repositories/common/constants.d.ts.map +1 -1
  77. package/dist/cjs/base/repositories/common/constants.js +22 -2
  78. package/dist/cjs/base/repositories/common/constants.js.map +1 -1
  79. package/dist/cjs/base/repositories/common/types/contracts.d.ts +17 -17
  80. package/dist/cjs/base/repositories/common/types/contracts.d.ts.map +1 -1
  81. package/dist/cjs/base/repositories/common/types/contracts.js.map +1 -1
  82. package/dist/cjs/base/repositories/core/abstract.d.ts +18 -18
  83. package/dist/cjs/base/repositories/core/abstract.d.ts.map +1 -1
  84. package/dist/cjs/base/repositories/core/abstract.js +8 -7
  85. package/dist/cjs/base/repositories/core/abstract.js.map +1 -1
  86. package/dist/cjs/helpers/inversion/common/types/model.d.ts +94 -22
  87. package/dist/cjs/helpers/inversion/common/types/model.d.ts.map +1 -1
  88. package/dist/cjs/helpers/inversion/common/types/model.js.map +1 -1
  89. package/dist/cjs/helpers/inversion/mixins/model.mixin.js +1 -1
  90. package/dist/cjs/helpers/inversion/mixins/model.mixin.js.map +1 -1
  91. package/dist/cjs/helpers/inversion/mixins/repository.mixin.js +1 -1
  92. package/dist/cjs/helpers/inversion/mixins/repository.mixin.js.map +1 -1
  93. package/dist/cjs/repository.d.ts +1 -1
  94. package/dist/cjs/repository.d.ts.map +1 -1
  95. package/dist/cjs/repository.js.map +1 -1
  96. package/dist/esm/base/applications/abstract.js +2 -2
  97. package/dist/esm/base/applications/abstract.js.map +1 -1
  98. package/dist/esm/base/applications/artifact-group.js +1 -1
  99. package/dist/esm/base/applications/artifact-group.js.map +1 -1
  100. package/dist/esm/base/applications/artifact-index.js +11 -11
  101. package/dist/esm/base/applications/artifact-index.js.map +1 -1
  102. package/dist/esm/base/applications/boot-sequence.js +1 -1
  103. package/dist/esm/base/applications/boot-sequence.js.map +1 -1
  104. package/dist/esm/base/applications/cors.d.ts +13 -0
  105. package/dist/esm/base/applications/cors.d.ts.map +1 -0
  106. package/dist/esm/base/applications/cors.js +39 -0
  107. package/dist/esm/base/applications/cors.js.map +1 -0
  108. package/dist/esm/base/applications/deprecations.d.ts +10 -0
  109. package/dist/esm/base/applications/deprecations.d.ts.map +1 -0
  110. package/dist/esm/base/applications/deprecations.js +19 -0
  111. package/dist/esm/base/applications/deprecations.js.map +1 -0
  112. package/dist/esm/base/applications/rest.d.ts.map +1 -1
  113. package/dist/esm/base/applications/rest.js +11 -5
  114. package/dist/esm/base/applications/rest.js.map +1 -1
  115. package/dist/esm/base/auth/authenticate/common/codecs.js +2 -2
  116. package/dist/esm/base/auth/authenticate/common/codecs.js.map +1 -1
  117. package/dist/esm/base/auth/authenticate/providers/authentication.provider.js +1 -1
  118. package/dist/esm/base/auth/authenticate/providers/authentication.provider.js.map +1 -1
  119. package/dist/esm/base/auth/authenticate/strategies/strategy-registry.js +1 -1
  120. package/dist/esm/base/auth/authenticate/strategies/strategy-registry.js.map +1 -1
  121. package/dist/esm/base/auth/authorize/builders/grant.builder.js +12 -12
  122. package/dist/esm/base/auth/authorize/builders/grant.builder.js.map +1 -1
  123. package/dist/esm/base/auth/authorize/builders/permission.builder.js +1 -1
  124. package/dist/esm/base/auth/authorize/builders/permission.builder.js.map +1 -1
  125. package/dist/esm/base/auth/authorize/builders/policy.builder.js +1 -1
  126. package/dist/esm/base/auth/authorize/builders/policy.builder.js.map +1 -1
  127. package/dist/esm/base/auth/authorize/common/constants/authorization.d.ts.map +1 -1
  128. package/dist/esm/base/auth/authorize/common/constants/authorization.js +2 -2
  129. package/dist/esm/base/auth/authorize/common/constants/authorization.js.map +1 -1
  130. package/dist/esm/base/auth/authorize/enforcers/enforcer-registry.js +1 -1
  131. package/dist/esm/base/auth/authorize/enforcers/enforcer-registry.js.map +1 -1
  132. package/dist/esm/base/auth/authorize/providers/authorization.provider.js +3 -3
  133. package/dist/esm/base/auth/authorize/providers/authorization.provider.js.map +1 -1
  134. package/dist/esm/base/controllers/factory/authorize-guard.d.ts +19 -0
  135. package/dist/esm/base/controllers/factory/authorize-guard.d.ts.map +1 -0
  136. package/dist/esm/base/controllers/factory/authorize-guard.js +56 -0
  137. package/dist/esm/base/controllers/factory/authorize-guard.js.map +1 -0
  138. package/dist/esm/base/controllers/factory/controller.d.ts +2 -2
  139. package/dist/esm/base/controllers/factory/controller.d.ts.map +1 -1
  140. package/dist/esm/base/controllers/factory/controller.js +9 -0
  141. package/dist/esm/base/controllers/factory/controller.js.map +1 -1
  142. package/dist/esm/base/controllers/factory/crud/abstract.d.ts +1 -1
  143. package/dist/esm/base/controllers/factory/crud/abstract.d.ts.map +1 -1
  144. package/dist/esm/base/controllers/factory/crud/abstract.js.map +1 -1
  145. package/dist/esm/base/controllers/factory/definition.js +1 -1
  146. package/dist/esm/base/controllers/factory/definition.js.map +1 -1
  147. package/dist/esm/base/controllers/rest/extras.js +5 -5
  148. package/dist/esm/base/controllers/rest/extras.js.map +1 -1
  149. package/dist/esm/base/metadata/injectable.js +1 -1
  150. package/dist/esm/base/metadata/injectable.js.map +1 -1
  151. package/dist/esm/base/metadata/model-settings.d.ts +21 -0
  152. package/dist/esm/base/metadata/model-settings.d.ts.map +1 -0
  153. package/dist/esm/base/metadata/model-settings.js +73 -0
  154. package/dist/esm/base/metadata/model-settings.js.map +1 -0
  155. package/dist/esm/base/metadata/persistents.d.ts +1 -1
  156. package/dist/esm/base/metadata/persistents.d.ts.map +1 -1
  157. package/dist/esm/base/metadata/persistents.js +24 -12
  158. package/dist/esm/base/metadata/persistents.js.map +1 -1
  159. package/dist/esm/base/metadata/routes/controller.js +1 -1
  160. package/dist/esm/base/metadata/routes/controller.js.map +1 -1
  161. package/dist/esm/base/middlewares/app-error/app-error.middleware.js +3 -3
  162. package/dist/esm/base/middlewares/app-error/app-error.middleware.js.map +1 -1
  163. package/dist/esm/base/middlewares/app-error/zod.handler.js +2 -2
  164. package/dist/esm/base/middlewares/app-error/zod.handler.js.map +1 -1
  165. package/dist/esm/base/middlewares/form-body/form-body.middleware.js +2 -2
  166. package/dist/esm/base/middlewares/form-body/form-body.middleware.js.map +1 -1
  167. package/dist/esm/base/middlewares/not-found/not-found.middleware.js.map +1 -1
  168. package/dist/esm/base/models/common/utilities.js +1 -1
  169. package/dist/esm/base/models/common/utilities.js.map +1 -1
  170. package/dist/esm/base/repositories/common/constants.d.ts +18 -1
  171. package/dist/esm/base/repositories/common/constants.d.ts.map +1 -1
  172. package/dist/esm/base/repositories/common/constants.js +20 -1
  173. package/dist/esm/base/repositories/common/constants.js.map +1 -1
  174. package/dist/esm/base/repositories/common/types/contracts.d.ts +17 -17
  175. package/dist/esm/base/repositories/common/types/contracts.d.ts.map +1 -1
  176. package/dist/esm/base/repositories/common/types/contracts.js.map +1 -1
  177. package/dist/esm/base/repositories/core/abstract.d.ts +18 -18
  178. package/dist/esm/base/repositories/core/abstract.d.ts.map +1 -1
  179. package/dist/esm/base/repositories/core/abstract.js +8 -7
  180. package/dist/esm/base/repositories/core/abstract.js.map +1 -1
  181. package/dist/esm/helpers/inversion/common/types/model.d.ts +94 -22
  182. package/dist/esm/helpers/inversion/common/types/model.d.ts.map +1 -1
  183. package/dist/esm/helpers/inversion/common/types/model.js.map +1 -1
  184. package/dist/esm/helpers/inversion/mixins/model.mixin.js +1 -1
  185. package/dist/esm/helpers/inversion/mixins/model.mixin.js.map +1 -1
  186. package/dist/esm/helpers/inversion/mixins/repository.mixin.js +1 -1
  187. package/dist/esm/helpers/inversion/mixins/repository.mixin.js.map +1 -1
  188. package/dist/esm/repository.d.ts +1 -1
  189. package/dist/esm/repository.d.ts.map +1 -1
  190. package/dist/esm/repository.js.map +1 -1
  191. package/package.json +6 -6
@@ -1,5 +1,5 @@
1
1
  import type { AbstractEntity } from '../../../../base/models/index.js';
2
- import type { ScopeFilters, TFilter, TScopeFilterMissingBehavior, TWhere } from '../../../../base/repositories/index.js';
2
+ import type { ScopeFilters, TFilter, TScopeFilterMissingBehavior, TScopeWriteGuard, TWhere } from '../../../../base/repositories/index.js';
3
3
  import type { TClass, TNullable, TValueOrResolver } from '@venizia/ignis-helpers/common';
4
4
  import type { IArtifactRegistrationOptions } from './artifact.js';
5
5
  export interface IModelAuthorizeSettings {
@@ -8,12 +8,38 @@ export interface IModelAuthorizeSettings {
8
8
  /** Extensible - consumers can add any extra authorization metadata. */
9
9
  [extra: string | symbol]: any;
10
10
  }
11
+ /** What a restricted caller may write to the scope columns (`@model` settings.access.write). */
12
+ export interface IModelAccessWriteSettings {
13
+ /**
14
+ * What a create, createAll or an update payload that names a scope column does when its value
15
+ * disagrees with the resolved scope. `reject` (default) refuses the write and writes nothing - for
16
+ * `createAll` not even the valid rows. `assign` also fills a scope column that is ABSENT from a
17
+ * created row, when the scope is a single equality; a value that is present and disagrees is
18
+ * still refused.
19
+ *
20
+ * The scope's columns and allowed values are read from the resolved `where` (equality, `eq`, `inq`
21
+ * and arrays, `and`, and an `or` over one column). Any other shape cannot be checked, and the write
22
+ * is refused with its own message - never skipped. `ScopeFilters.UNRESTRICTED` bypasses the guard
23
+ * too, which is the deliberate way to write across scopes (system scope, an admin role).
24
+ *
25
+ * Not checked: an update that does not name the scope column (the row was already selected through
26
+ * the scoped `where`), and raw statements that bypass the repository.
27
+ */
28
+ mode?: TScopeWriteGuard;
29
+ /**
30
+ * `true` lets a restricted caller write `null` to a scope column, or leave it out on create: the
31
+ * row has no owner and is shared. Default `false`, so `null` is refused like any other value
32
+ * outside the scope, even when the resolved scope has a `null` branch (that branch lets the caller
33
+ * READ shared rows, a separate permission). Reads are scoped as before.
34
+ */
35
+ sharedRows?: boolean;
36
+ }
11
37
  /**
12
- * Row-scope resolver for `@model` settings.scopeFilter - resolved per query, so it can depend on
13
- * the current request (tenant, org, membership). Framework-internal escape hatches aside, nothing
14
- * short of removing this setting from the model turns scoping off.
38
+ * Row access for `@model` settings.access - resolved per query, so it can depend on the current
39
+ * request (tenant, org, membership). Framework-internal escape hatches aside, nothing short of
40
+ * removing this setting from the model turns scoping off.
15
41
  */
16
- export interface IScopeFilterSettings {
42
+ export interface IModelAccessSettings {
17
43
  /**
18
44
  * Returns the scope `where`; `ScopeFilters.UNRESTRICTED` to apply no scope for THIS call (an
19
45
  * internal operator, a caller the application has decided sees everything); or null/undefined
@@ -27,41 +53,87 @@ export interface IScopeFilterSettings {
27
53
  * per MODEL - it cannot express a per-USER bypass; use `ScopeFilters.UNRESTRICTED` for that.
28
54
  */
29
55
  onMissing?: TScopeFilterMissingBehavior;
56
+ /**
57
+ * The property names the write guard checks. Optional: with none declared the guard checks every
58
+ * column the resolved scope constrains. When declared, each name must exist on the model (checked
59
+ * at boot), and a resolved scope that constrains any other column is refused as unverifiable.
60
+ */
61
+ columns?: string[];
62
+ /** What a restricted caller may write to the scope columns. See {@link IModelAccessWriteSettings}. */
63
+ write?: IModelAccessWriteSettings;
64
+ }
65
+ /**
66
+ * The old, flat shape of {@link IModelAccessSettings}.
67
+ *
68
+ * @deprecated Use `settings.access` (`writeGuard` is `access.write.mode`, `sharedRows` is
69
+ * `access.write.sharedRows`). Removed in 0.4.3.
70
+ */
71
+ export interface IScopeFilterSettings {
72
+ resolve: () => TNullable<TWhere> | typeof ScopeFilters.UNRESTRICTED;
73
+ onMissing?: TScopeFilterMissingBehavior;
74
+ writeGuard?: TScopeWriteGuard;
75
+ sharedRows?: boolean;
76
+ columns?: string[];
77
+ }
78
+ /** What a query runs with when it names nothing (`@model` settings.query). */
79
+ export interface IModelQuerySettings {
80
+ /** Default filter auto-applied to all repository operations. Bypassable via shouldSkipDefaultFilter. */
81
+ filter?: TFilter;
82
+ limit?: {
83
+ /** Default row limit when a query omits `limit`. Must be a positive integer. Falls back to DEFAULT_LIMIT (10). */
84
+ default?: number;
85
+ /**
86
+ * Largest `limit` a CALLER may ask for. Must be a positive integer. Falls back to
87
+ * DEFAULT_MAX_LIMIT (1000).
88
+ *
89
+ * Policy, not capacity - the engine's own ceiling sits far above it. The number is chosen so
90
+ * that reaching it means the caller is doing something unusual, and raising it is how a model
91
+ * says so deliberately.
92
+ */
93
+ max?: number;
94
+ };
30
95
  }
31
96
  export interface IModelSettings {
32
97
  /** Properties excluded from all query results at SQL level. */
33
98
  hiddenProperties?: string[];
34
- /** Default filter auto-applied to all repository operations. Bypassable via shouldSkipDefaultFilter. */
35
- defaultFilter?: TFilter;
99
+ /** Default filter and limits of a query: `filter`, `limit.default`, `limit.max`. */
100
+ query?: IModelQuerySettings;
36
101
  /**
37
- * Row scope: ANDed into every read and write whose scope is expressible as a filter clause, and
38
- * NOT removable by `shouldSkipDefaultFilter`. Resolved per query, so it can depend on the current
39
- * request. Ownership resolved per row or through a polymorphic reference is NOT expressible here -
40
- * that check is still the application's to perform.
102
+ * Row access: the scope ANDed into every read and write whose scope is expressible as a filter
103
+ * clause, NOT removable by `shouldSkipDefaultFilter`, and the guard that holds writes to it.
104
+ * Ownership resolved per row or through a polymorphic reference is NOT expressible here - that
105
+ * check is still the application's to perform.
41
106
  *
42
107
  * Relational repositories only - a search-backed model (Typesense, Meilisearch) never reads
43
108
  * this setting, so mirroring a scoped entity into a search index needs its own query-time scope.
44
109
  */
110
+ access?: IModelAccessSettings;
111
+ /** Authorization settings for this model (principal name, etc.). */
112
+ authorize?: IModelAuthorizeSettings;
113
+ /** @deprecated Use `query.filter`. Removed in 0.4.3. */
114
+ defaultFilter?: TFilter;
115
+ /** @deprecated Use `access`. Removed in 0.4.3. */
45
116
  scopeFilter?: IScopeFilterSettings;
46
- /** Default row limit when a query omits `limit`. Must be a positive integer. Falls back to DEFAULT_LIMIT (10). */
117
+ /** @deprecated Use `query.limit.default`. Removed in 0.4.3. */
47
118
  defaultLimit?: number;
48
- /**
49
- * Largest `limit` a CALLER may ask for. Must be a positive integer. Falls back to
50
- * DEFAULT_MAX_LIMIT (1000).
51
- *
52
- * Policy, not capacity - the engine's own ceiling sits far above it. The number is chosen so
53
- * that reaching it means the caller is doing something unusual, and raising it is how a model
54
- * says so deliberately.
55
- */
119
+ /** @deprecated Use `query.limit.max`. Removed in 0.4.3. */
56
120
  maxLimit?: number;
57
- /** Authorization settings for this model (principal name, etc.). */
58
- authorize?: IModelAuthorizeSettings;
121
+ }
122
+ /** One deprecated settings key a model still uses, and the key that replaces it. */
123
+ export interface IDeprecatedModelSetting {
124
+ /** The old key, written as the model wrote it: `defaultFilter`, `scopeFilter.writeGuard`. */
125
+ key: string;
126
+ /** The key that replaces it: `query.filter`, `access.write.mode`. */
127
+ use: string;
59
128
  }
60
129
  export interface IModelMetadata extends IArtifactRegistrationOptions {
61
130
  type: 'entity' | 'view';
62
131
  tableName?: string;
63
132
  skipMigrate?: boolean;
133
+ /** As the `@model` decorator stores it: normalised to the new keys; the deprecated keys are gone. */
64
134
  settings?: IModelSettings;
135
+ /** Set by the decorator, read by the boot warning; not for application code. */
136
+ deprecatedSettings?: IDeprecatedModelSetting[];
65
137
  }
66
138
  export interface IEntityStatics {
67
139
  schema?: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../../../../src/helpers/inversion/common/types/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EACV,YAAY,EACZ,OAAO,EACP,2BAA2B,EAC3B,MAAM,EACP,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACzF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAE/D,MAAM,WAAW,uBAAuB;IACtC,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,OAAO,EAAE,MAAM,SAAS,CAAC,MAAM,CAAC,GAAG,OAAO,YAAY,CAAC,YAAY,CAAC;IAEpE;;;;;OAKG;IACH,SAAS,CAAC,EAAE,2BAA2B,CAAC;CACzC;AAED,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE5B,wGAAwG;IACxG,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,oBAAoB,CAAC;IAEnC,kHAAkH;IAClH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,oEAAoE;IACpE,SAAS,CAAC,EAAE,uBAAuB,CAAC;CACrC;AAED,MAAM,WAAW,cAAe,SAAQ,4BAA4B;IAClE,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM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,SAAS,cAAc,GAAG,cAAc;IAChF,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACxC,QAAQ,EAAE,cAAc,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAEhB,oFAAoF;IACpF,iBAAiB,CAAC,EAAE,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAErD,mDAAmD;IACnD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../../../../../../src/helpers/inversion/common/types/model.ts"],"names":[],"mappings":"","sourcesContent":["import type { AbstractEntity } from '@/base/models';\nimport type {\n ScopeFilters,\n TFilter,\n TScopeFilterMissingBehavior,\n TWhere,\n} from '@/base/repositories';\nimport type { TClass, TNullable, TValueOrResolver } from '@venizia/ignis-helpers/common';\nimport type { IArtifactRegistrationOptions } from './artifact';\n\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/**\n * Row-scope resolver for `@model` settings.scopeFilter - resolved per query, so it can depend on\n * the current request (tenant, org, membership). Framework-internal escape hatches aside, nothing\n * short of removing this setting from the model turns scoping off.\n */\nexport interface IScopeFilterSettings {\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 resolve: () => 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. Defaults to `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 onMissing?: TScopeFilterMissingBehavior;\n}\n\nexport interface IModelSettings {\n /** Properties excluded from all query results at SQL level. */\n hiddenProperties?: string[];\n\n /** Default filter auto-applied to all repository operations. Bypassable via shouldSkipDefaultFilter. */\n defaultFilter?: TFilter;\n\n /**\n * Row scope: ANDed into every read and write whose scope is expressible as a filter clause, and\n * NOT removable by `shouldSkipDefaultFilter`. Resolved per query, so it can depend on the current\n * request. Ownership resolved per row or through a polymorphic reference is NOT expressible here -\n * that 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 scopeFilter?: IScopeFilterSettings;\n\n /** Default row limit when a query omits `limit`. Must be a positive integer. Falls back to DEFAULT_LIMIT (10). */\n defaultLimit?: number;\n\n /**\n * Largest `limit` a CALLER may ask for. Must be a positive integer. Falls back to\n * DEFAULT_MAX_LIMIT (1000).\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 maxLimit?: number;\n\n /** Authorization settings for this model (principal name, etc.). */\n authorize?: IModelAuthorizeSettings;\n}\n\nexport interface IModelMetadata extends IArtifactRegistrationOptions {\n type: 'entity' | 'view';\n tableName?: string;\n skipMigrate?: boolean;\n settings?: IModelSettings;\n}\n\nexport interface IEntityStatics {\n schema?: unknown;\n relations?: TValueOrResolver<Array<unknown>>;\n}\n\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\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 } from '@/base/models';\nimport type {\n ScopeFilters,\n TFilter,\n TScopeFilterMissingBehavior,\n TScopeWriteGuard,\n TWhere,\n} from '@/base/repositories';\nimport type { TClass, TNullable, TValueOrResolver } from '@venizia/ignis-helpers/common';\nimport type { IArtifactRegistrationOptions } from './artifact';\n\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` (default) 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 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. Default `false`, so `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 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 */\nexport interface IModelAccessSettings {\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 resolve: () => 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. Defaults to `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 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 * The old, flat shape of {@link IModelAccessSettings}.\n *\n * @deprecated Use `settings.access` (`writeGuard` is `access.write.mode`, `sharedRows` is\n * `access.write.sharedRows`). Removed in 0.4.3.\n */\nexport interface IScopeFilterSettings {\n resolve: () => TNullable<TWhere> | typeof ScopeFilters.UNRESTRICTED;\n onMissing?: TScopeFilterMissingBehavior;\n writeGuard?: TScopeWriteGuard;\n sharedRows?: boolean;\n columns?: string[];\n}\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 /** Default row limit when a query omits `limit`. Must be a positive integer. Falls back to DEFAULT_LIMIT (10). */\n default?: number;\n\n /**\n * Largest `limit` a CALLER may ask for. Must be a positive integer. Falls back to\n * DEFAULT_MAX_LIMIT (1000).\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 max?: number;\n };\n}\n\nexport interface IModelSettings {\n /** Properties excluded from all query results at SQL level. */\n hiddenProperties?: string[];\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?: IModelAccessSettings;\n\n /** Authorization settings for this model (principal name, etc.). */\n authorize?: IModelAuthorizeSettings;\n\n /** @deprecated Use `query.filter`. Removed in 0.4.3. */\n defaultFilter?: TFilter;\n\n /** @deprecated Use `access`. Removed in 0.4.3. */\n scopeFilter?: IScopeFilterSettings;\n\n /** @deprecated Use `query.limit.default`. Removed in 0.4.3. */\n defaultLimit?: number;\n\n /** @deprecated Use `query.limit.max`. Removed in 0.4.3. */\n maxLimit?: number;\n}\n\n/** One deprecated settings key a model still uses, and the key that replaces it. */\nexport interface IDeprecatedModelSetting {\n /** The old key, written as the model wrote it: `defaultFilter`, `scopeFilter.writeGuard`. */\n key: string;\n /** The key that replaces it: `query.filter`, `access.write.mode`. */\n use: string;\n}\n\nexport interface IModelMetadata extends IArtifactRegistrationOptions {\n type: 'entity' | 'view';\n tableName?: string;\n skipMigrate?: boolean;\n\n /** As the `@model` decorator stores it: normalised to the new keys; the deprecated keys are gone. */\n settings?: IModelSettings;\n\n /** Set by the decorator, read by the boot warning; not for application code. */\n deprecatedSettings?: IDeprecatedModelSetting[];\n}\n\nexport interface IEntityStatics {\n schema?: unknown;\n relations?: TValueOrResolver<Array<unknown>>;\n}\n\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\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"]}
@@ -80,7 +80,7 @@ export const ModelMetadataMixin = (baseClass) => {
80
80
  getAuthorizeModelPrincipals(opts) {
81
81
  switch (opts.format) {
82
82
  case 'array': {
83
- return collectAuthorizePrincipals({ modelRegistry: this.modelRegistry }).map(item => item.principal);
83
+ return collectAuthorizePrincipals({ modelRegistry: this.modelRegistry }).map((item) => item.principal);
84
84
  }
85
85
  case 'record': {
86
86
  const record = {};
@@ -1 +1 @@
1
- {"version":3,"file":"model.mixin.js","sourceRoot":"","sources":["../../../../../src/helpers/inversion/mixins/model.mixin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAS9C,8EAA8E;AAC9E,MAAM,uBAAuB,GAAG,CAAC,IAEhC,EAA2F,EAAE;IAC5F,MAAM,MAAM,GAIP,EAAE,CAAC;IAER,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QAC/C,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;QACrD,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,SAAS;QACX,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,MAAM,CAAC;AACh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BAAgB,EAAE,CAAC;wBACpC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;oBACvE,CAAC;oBAED,OAAO,MAAM,CAAC;gBAChB,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACR,MAAM,QAAQ,CAAC;wBACb,OAAO,EAAE,wDAAwD,IAAI,CAAC,MAAM,yBAAyB;qBACtG,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { AbstractEntity } from '@/base/models';\nimport type { TMixinTarget } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';\nimport { MetadataKeys } from '../common/keys';\nimport type {\n IModelAuthorizeSettings,\n IModelMetadata,\n IModelRegistryEntry,\n TDecoratorModelTarget,\n TModelClass,\n} from '../common/types';\n\n/** Registered models that declare an authorize setting, in registry order. */\nconst collectAuthorizeEntries = (opts: {\n modelRegistry: Map<string, IModelRegistryEntry>;\n}): Array<{ name: string; authorize: IModelAuthorizeSettings; entry: IModelRegistryEntry }> => {\n const result: Array<{\n name: string;\n authorize: IModelAuthorizeSettings;\n entry: IModelRegistryEntry;\n }> = [];\n\n for (const [name, entry] of opts.modelRegistry) {\n const authorize = entry.metadata.settings?.authorize;\n if (!authorize) {\n continue;\n }\n\n result.push({ name, authorize, entry });\n }\n\n return result;\n};\n\n/** Registered models that declare an authorize principal, in registry order. */\nconst collectAuthorizePrincipals = (opts: {\n modelRegistry: Map<string, IModelRegistryEntry>;\n}): Array<{ name: string; principal: string }> => {\n const result: Array<{ name: string; principal: string }> = [];\n\n for (const [name, entry] of opts.modelRegistry) {\n const principal = entry.metadata.settings?.authorize?.principal;\n if (!principal) {\n continue;\n }\n\n result.push({ name, principal });\n }\n\n return result;\n};\n\nexport const ModelMetadataMixin = <BaseClass extends TMixinTarget<_MetadataRegistry>>(\n baseClass: BaseClass,\n) => {\n return class extends baseClass {\n modelRegistry: Map<string, IModelRegistryEntry>;\n modelsBySchema: WeakMap<object, IModelRegistryEntry>;\n\n setModelMetadata<Target extends object = object>(opts: {\n target: Target;\n metadata: IModelMetadata;\n }): void {\n const { target, metadata } = opts;\n Reflect.defineMetadata(MetadataKeys.MODEL, metadata, target);\n }\n\n getModelMetadata<Target extends object = object>(opts: {\n target: Target;\n }): IModelMetadata | undefined {\n const { target } = opts;\n return Reflect.getMetadata(MetadataKeys.MODEL, target);\n }\n\n /** Registers a model (called by @model) - relations are stored as a resolver, not resolved immediately, so circular references between models resolve lazily in buildSchema(). */\n registerModel<Model extends AbstractEntity = AbstractEntity>(opts: {\n target: TDecoratorModelTarget<Model>;\n metadata: IModelMetadata;\n }) {\n const { target, metadata } = opts;\n\n // Decorator target is always a class constructor at runtime\n const modelClass = target as TModelClass<Model>;\n\n // Table name precedence: explicit metadata > static TABLE_NAME > class name. TABLE_NAME is deliberately outside IEntityStatics (not part of the neutral contract) but still honored here via a local cast.\n const tableName =\n [metadata.tableName, (modelClass as { TABLE_NAME?: string }).TABLE_NAME].find(Boolean) ??\n modelClass.name;\n\n // Resolver, not resolved value - executed lazily in buildSchema() once all models are loaded\n const relationsResolver = modelClass.relations;\n\n const entry: IModelRegistryEntry = {\n target: modelClass,\n metadata,\n schema: modelClass.schema,\n relationsResolver,\n };\n this.modelRegistry.set(tableName, entry);\n\n const { schema } = modelClass;\n if (schema && typeof schema === 'object') {\n const claimed = this.modelsBySchema.get(schema);\n if (claimed && claimed.target !== modelClass) {\n this.modelsBySchema.delete(schema);\n } else {\n this.modelsBySchema.set(schema, entry);\n }\n }\n\n // Also mirrored via Reflect so plain metadata lookups (getModelMetadata) still see it\n this.setModelMetadata({ target, metadata });\n }\n\n getModelEntry(opts: { name: string }): IModelRegistryEntry | undefined {\n return this.modelRegistry.get(opts.name);\n }\n\n getModelEntryBySchema(opts: { schema: object }): IModelRegistryEntry | undefined {\n return this.modelsBySchema.get(opts.schema);\n }\n\n getAllModels(): Map<string, IModelRegistryEntry> {\n return this.modelRegistry;\n }\n\n getModelAuthorizeSettings(opts: { name: string }): IModelAuthorizeSettings | undefined {\n const entry = this.getModelEntry(opts);\n return entry?.metadata?.settings?.authorize;\n }\n\n /** Authorization principals across all models that declare an authorize setting. */\n getAuthorizeModelPrincipals(opts: { format: 'array' }): string[];\n getAuthorizeModelPrincipals(opts: { format: 'record' }): Record<string, string>;\n getAuthorizeModelPrincipals(opts: { format: 'array' | 'record' }) {\n switch (opts.format) {\n case 'array': {\n return collectAuthorizePrincipals({ modelRegistry: this.modelRegistry }).map(\n item => item.principal,\n );\n }\n case 'record': {\n const record: Record<string, string> = {};\n\n const authorizePrincipals = collectAuthorizePrincipals({\n modelRegistry: this.modelRegistry,\n });\n for (const item of authorizePrincipals) {\n record[item.name] = item.principal;\n }\n\n return record;\n }\n default: {\n throw getError({\n message: `[getAuthorizeModelPrincipals] Invalid format | format: ${opts.format} | valid: array, record`,\n });\n }\n }\n }\n\n getAuthorizeModelSettings(opts: { format: 'array' }): Array<{\n name: string;\n authorize: IModelAuthorizeSettings;\n entry: IModelRegistryEntry;\n }>;\n getAuthorizeModelSettings(opts: {\n format: 'record';\n }): Record<string, { authorize: IModelAuthorizeSettings; entry: IModelRegistryEntry }>;\n getAuthorizeModelSettings(opts: { format: 'array' | 'record' }) {\n switch (opts.format) {\n case 'array': {\n return collectAuthorizeEntries({ modelRegistry: this.modelRegistry });\n }\n case 'record': {\n const record: Record<\n string,\n { authorize: IModelAuthorizeSettings; entry: IModelRegistryEntry }\n > = {};\n\n const authorizeEntries = collectAuthorizeEntries({ modelRegistry: this.modelRegistry });\n for (const item of authorizeEntries) {\n record[item.name] = { authorize: item.authorize, entry: item.entry };\n }\n\n return record;\n }\n default: {\n throw getError({\n message: `[getAuthorizeModelSettings] Invalid format | format: ${opts.format} | valid: array, record`,\n });\n }\n }\n }\n };\n};\n"]}
1
+ {"version":3,"file":"model.mixin.js","sourceRoot":"","sources":["../../../../../src/helpers/inversion/mixins/model.mixin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAS9C,8EAA8E;AAC9E,MAAM,uBAAuB,GAAG,CAAC,IAEhC,EAA2F,EAAE;IAC5F,MAAM,MAAM,GAIP,EAAE,CAAC;IAER,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QAC/C,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;QACrD,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,SAAS;QACX,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,gFAAgF;AAChF,MAAM,0BAA0B,GAAG,CAAC,IAEnC,EAA8C,EAAE;IAC/C,MAAM,MAAM,GAA+C,EAAE,CAAC;IAE9D,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QAC/C,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;QAChE,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,SAAS;QACX,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,SAAoB,EACpB,EAAE;IACF,OAAO,KAAM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MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;oBACrC,CAAC;oBAED,OAAO,MAAM,CAAC;gBAChB,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACR,MAAM,QAAQ,CAAC;wBACb,OAAO,EAAE,0DAA0D,IAAI,CAAC,MAAM,yBAAyB;qBACxG,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;QAUD,yBAAyB,CAAC,IAAoC;YAC5D,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;gBACpB,KAAK,OAAO,CAAC,CAAC,CAAC;oBACb,OAAO,uBAAuB,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;gBACxE,CAAC;gBACD,KAAK,QAAQ,CAAC,CAAC,CAAC;oBACd,MAAM,MAAM,GAGR,EAAE,CAAC;oBAEP,MAAM,gBAAgB,GAAG,uBAAuB,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;oBACxF,KAAK,MAAM,IAAI,IAAI,gBAAgB,EAAE,CAAC;wBACpC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;oBACvE,CAAC;oBAED,OAAO,MAAM,CAAC;gBAChB,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACR,MAAM,QAAQ,CAAC;wBACb,OAAO,EAAE,wDAAwD,IAAI,CAAC,MAAM,yBAAyB;qBACtG,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { AbstractEntity } from '@/base/models';\nimport type { TMixinTarget } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';\nimport { MetadataKeys } from '../common/keys';\nimport type {\n IModelAuthorizeSettings,\n IModelMetadata,\n IModelRegistryEntry,\n TDecoratorModelTarget,\n TModelClass,\n} from '../common/types';\n\n/** Registered models that declare an authorize setting, in registry order. */\nconst collectAuthorizeEntries = (opts: {\n modelRegistry: Map<string, IModelRegistryEntry>;\n}): Array<{ name: string; authorize: IModelAuthorizeSettings; entry: IModelRegistryEntry }> => {\n const result: Array<{\n name: string;\n authorize: IModelAuthorizeSettings;\n entry: IModelRegistryEntry;\n }> = [];\n\n for (const [name, entry] of opts.modelRegistry) {\n const authorize = entry.metadata.settings?.authorize;\n if (!authorize) {\n continue;\n }\n\n result.push({ name, authorize, entry });\n }\n\n return result;\n};\n\n/** Registered models that declare an authorize principal, in registry order. */\nconst collectAuthorizePrincipals = (opts: {\n modelRegistry: Map<string, IModelRegistryEntry>;\n}): Array<{ name: string; principal: string }> => {\n const result: Array<{ name: string; principal: string }> = [];\n\n for (const [name, entry] of opts.modelRegistry) {\n const principal = entry.metadata.settings?.authorize?.principal;\n if (!principal) {\n continue;\n }\n\n result.push({ name, principal });\n }\n\n return result;\n};\n\nexport const ModelMetadataMixin = <BaseClass extends TMixinTarget<_MetadataRegistry>>(\n baseClass: BaseClass,\n) => {\n return class extends baseClass {\n modelRegistry: Map<string, IModelRegistryEntry>;\n modelsBySchema: WeakMap<object, IModelRegistryEntry>;\n\n setModelMetadata<Target extends object = object>(opts: {\n target: Target;\n metadata: IModelMetadata;\n }): void {\n const { target, metadata } = opts;\n Reflect.defineMetadata(MetadataKeys.MODEL, metadata, target);\n }\n\n getModelMetadata<Target extends object = object>(opts: {\n target: Target;\n }): IModelMetadata | undefined {\n const { target } = opts;\n return Reflect.getMetadata(MetadataKeys.MODEL, target);\n }\n\n /** Registers a model (called by @model) - relations are stored as a resolver, not resolved immediately, so circular references between models resolve lazily in buildSchema(). */\n registerModel<Model extends AbstractEntity = AbstractEntity>(opts: {\n target: TDecoratorModelTarget<Model>;\n metadata: IModelMetadata;\n }) {\n const { target, metadata } = opts;\n\n // Decorator target is always a class constructor at runtime\n const modelClass = target as TModelClass<Model>;\n\n // Table name precedence: explicit metadata > static TABLE_NAME > class name. TABLE_NAME is deliberately outside IEntityStatics (not part of the neutral contract) but still honored here via a local cast.\n const tableName =\n [metadata.tableName, (modelClass as { TABLE_NAME?: string }).TABLE_NAME].find(Boolean) ??\n modelClass.name;\n\n // Resolver, not resolved value - executed lazily in buildSchema() once all models are loaded\n const relationsResolver = modelClass.relations;\n\n const entry: IModelRegistryEntry = {\n target: modelClass,\n metadata,\n schema: modelClass.schema,\n relationsResolver,\n };\n this.modelRegistry.set(tableName, entry);\n\n const { schema } = modelClass;\n if (schema && typeof schema === 'object') {\n const claimed = this.modelsBySchema.get(schema);\n if (claimed && claimed.target !== modelClass) {\n this.modelsBySchema.delete(schema);\n } else {\n this.modelsBySchema.set(schema, entry);\n }\n }\n\n // Also mirrored via Reflect so plain metadata lookups (getModelMetadata) still see it\n this.setModelMetadata({ target, metadata });\n }\n\n getModelEntry(opts: { name: string }): IModelRegistryEntry | undefined {\n return this.modelRegistry.get(opts.name);\n }\n\n getModelEntryBySchema(opts: { schema: object }): IModelRegistryEntry | undefined {\n return this.modelsBySchema.get(opts.schema);\n }\n\n getAllModels(): Map<string, IModelRegistryEntry> {\n return this.modelRegistry;\n }\n\n getModelAuthorizeSettings(opts: { name: string }): IModelAuthorizeSettings | undefined {\n const entry = this.getModelEntry(opts);\n return entry?.metadata?.settings?.authorize;\n }\n\n /** Authorization principals across all models that declare an authorize setting. */\n getAuthorizeModelPrincipals(opts: { format: 'array' }): string[];\n getAuthorizeModelPrincipals(opts: { format: 'record' }): Record<string, string>;\n getAuthorizeModelPrincipals(opts: { format: 'array' | 'record' }) {\n switch (opts.format) {\n case 'array': {\n return collectAuthorizePrincipals({ modelRegistry: this.modelRegistry }).map(\n (item) => item.principal,\n );\n }\n case 'record': {\n const record: Record<string, string> = {};\n\n const authorizePrincipals = collectAuthorizePrincipals({\n modelRegistry: this.modelRegistry,\n });\n for (const item of authorizePrincipals) {\n record[item.name] = item.principal;\n }\n\n return record;\n }\n default: {\n throw getError({\n message: `[getAuthorizeModelPrincipals] Invalid format | format: ${opts.format} | valid: array, record`,\n });\n }\n }\n }\n\n getAuthorizeModelSettings(opts: { format: 'array' }): Array<{\n name: string;\n authorize: IModelAuthorizeSettings;\n entry: IModelRegistryEntry;\n }>;\n getAuthorizeModelSettings(opts: {\n format: 'record';\n }): Record<string, { authorize: IModelAuthorizeSettings; entry: IModelRegistryEntry }>;\n getAuthorizeModelSettings(opts: { format: 'array' | 'record' }) {\n switch (opts.format) {\n case 'array': {\n return collectAuthorizeEntries({ modelRegistry: this.modelRegistry });\n }\n case 'record': {\n const record: Record<\n string,\n { authorize: IModelAuthorizeSettings; entry: IModelRegistryEntry }\n > = {};\n\n const authorizeEntries = collectAuthorizeEntries({ modelRegistry: this.modelRegistry });\n for (const item of authorizeEntries) {\n record[item.name] = { authorize: item.authorize, entry: item.entry };\n }\n\n return record;\n }\n default: {\n throw getError({\n message: `[getAuthorizeModelSettings] Invalid format | format: ${opts.format} | valid: array, record`,\n });\n }\n }\n }\n };\n};\n"]}
@@ -87,7 +87,7 @@ export const RepositoryMetadataMixin = (baseClass) => {
87
87
  getModels(opts) {
88
88
  const modelClasses = this.getDataSourceModelClasses({ dataSource: opts.dataSource });
89
89
  const rs = Array.from(modelClasses)
90
- .map(modelClass => {
90
+ .map((modelClass) => {
91
91
  // Read straight off the class: a class -> name -> modelRegistry round-trip collapses two
92
92
  // same-named models onto one entry, silently swapping schemas. `modelRegistry` stays
93
93
  // name-keyed for the by-name APIs that need it.
@@ -1 +1 @@
1
- {"version":3,"file":"repository.mixin.js","sourceRoot":"","sources":["../../../../../src/helpers/inversion/mixins/repository.mixin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAA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CAAC,CAAC;YAE9C,MAAM,EAAE,GAGJ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;YAElC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC3B,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;oBACjB,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;gBAC5C,CAAC;gBAED,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;oBACpB,EAAE,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,SAAS,WAAW,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;gBAChE,CAAC;YACH,CAAC;YAED,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,SAAS,CAAC,IAAkD;YAC1D,OAAO,IAAI,CAAC,yBAAyB,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;QAClF,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { IDataSource } from '@/base/datasources';\nimport type { AbstractEntity } from '@/base/models';\nimport type { AnyType, TClass, TMixinTarget } from '@venizia/ignis-helpers/common';\nimport { resolveValue } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';\nimport { MetadataKeys } from '../common/keys';\nimport { RelationBuilderRegistry } from '../common/relation-builder';\nimport type {\n IModelMetadata,\n IModelRegistryEntry,\n IRepositoryBinding,\n IResolvedRepositoryMetadata,\n TRepositoryMetadata,\n} from '../common/types';\n\nexport const RepositoryMetadataMixin = <\n BaseClass extends TMixinTarget<\n _MetadataRegistry & {\n modelRegistry: Map<string, IModelRegistryEntry>;\n getModelMetadata(opts: { target: object }): IModelMetadata | undefined;\n }\n >,\n>(\n baseClass: BaseClass,\n) => {\n return class extends baseClass {\n /** By repository class name, for the by-name API. Two classes may share a name; `repositoryBindingsByClass` cannot confuse them. */\n repositoryBindings: Map<string, IRepositoryBinding<AbstractEntity>>;\n\n /** By repository class: a minified build renames classes, and two chunks may give two of them one name. */\n repositoryBindingsByClass: Map<Function, IRepositoryBinding<AbstractEntity>>;\n\n /**\n * The model classes each datasource owns, keyed by the datasource class - or by the string a\n * repository named it with (`dataSource: 'PgDataSource'`), which only a class of that name\n * can match. Never by class name alone: a minified build gives two datasources one name.\n */\n datasourceModels: Map<string | Function, Set<TClass<AnyType>>>;\n\n setRepositoryMetadata<\n Target extends object = object,\n Model extends AbstractEntity = AbstractEntity,\n DataSource extends IDataSource = IDataSource,\n >(opts: {\n target: Target;\n metadata: TRepositoryMetadata<Model, DataSource> & {\n _resolved?: IResolvedRepositoryMetadata<Model, DataSource>;\n };\n }): void {\n const { target, metadata } = opts;\n Reflect.defineMetadata(MetadataKeys.REPOSITORY, metadata, target);\n }\n\n getRepositoryMetadata<Target extends object = object>(opts: {\n target: Target;\n }): (TRepositoryMetadata & { _resolved?: IResolvedRepositoryMetadata }) | undefined {\n const { target } = opts;\n return Reflect.getMetadata(MetadataKeys.REPOSITORY, target);\n }\n\n /** Registers a repository binding (called by @repository) linking a repository to its model + datasource. */\n registerRepositoryBinding<\n Model extends AbstractEntity = AbstractEntity,\n DataSource extends IDataSource = IDataSource,\n >(opts: IRepositoryBinding<Model, DataSource>) {\n // Every member of the binding may be a resolver, the escape hatch for circular imports.\n // Reading `.name` off the resolver keys the registry by the arrow's inferred name, and the\n // datasource then silently discovers no schema.\n const repositoryClass = resolveValue({ value: opts.repository });\n this.repositoryBindings.set(repositoryClass.name, opts);\n this.repositoryBindingsByClass.set(repositoryClass, opts);\n\n const dataSourceRef = resolveValue({ value: opts.dataSource });\n const modelClass = resolveValue({ value: opts.model });\n\n if (!this.datasourceModels.has(dataSourceRef)) {\n this.datasourceModels.set(dataSourceRef, new Set());\n }\n\n this.datasourceModels.get(dataSourceRef)!.add(modelClass);\n }\n\n /** By class, walking up to the nearest decorated parent; by name only for callers holding a name. */\n getRepositoryBinding(\n opts: { target: Function } | { name: string },\n ): IRepositoryBinding<AbstractEntity> | undefined {\n if ('name' in opts) {\n return this.repositoryBindings.get(opts.name);\n }\n\n for (\n let current: Function | null = opts.target;\n current && current !== Function.prototype;\n current = Object.getPrototypeOf(current)\n ) {\n const binding = this.repositoryBindingsByClass.get(current);\n if (binding) {\n return binding;\n }\n }\n\n return undefined;\n }\n\n /** A class finds what was registered under it, and under a string equal to its name. */\n getDataSourceModelClasses(opts: {\n dataSource: string | TClass<IDataSource>;\n }): Set<TClass<AnyType>> {\n const { dataSource } = opts;\n\n if (typeof dataSource === 'string') {\n return this.datasourceModels.get(dataSource) ?? new Set();\n }\n\n return new Set([\n ...(this.datasourceModels.get(dataSource) ?? []),\n ...(this.datasourceModels.get(dataSource.name) ?? []),\n ]);\n }\n\n /**\n * Resolves and caches relations for a model entry - called lazily from buildSchema() so that\n * every `@model` class is registered first, which avoids circular-dependency ordering issues.\n * @internal\n */\n resolveModelRelations(modelMeta: IModelRegistryEntry): unknown {\n if (modelMeta._builtRelations !== undefined) {\n return modelMeta._builtRelations;\n }\n\n if (!modelMeta.relationsResolver) {\n return undefined;\n }\n\n const relations = resolveValue({ value: modelMeta.relationsResolver });\n\n if (!relations || !modelMeta.schema) {\n return undefined;\n }\n\n const builder = RelationBuilderRegistry.resolve();\n\n // Relations were declared but no connector installed a builder - silently dropping them\n // would surface much later as an empty `with` clause.\n if (!builder) {\n throw getError({\n message: `[RepositoryMetadataMixin][resolveModelRelations] Model declares relations but no relation builder is registered | Import the relational connector so it installs one`,\n });\n }\n\n const builtRelations = builder({ source: modelMeta.schema, relations });\n\n modelMeta._builtRelations = builtRelations?.relations;\n return modelMeta._builtRelations;\n }\n\n /**\n * Models registered for a datasource, relations resolved lazily. `schema`/`relations` stay\n * `unknown` - the registry is shared across connectors, so each connector narrows at its call\n * site.\n */\n getModels(opts: { dataSource: string | TClass<IDataSource> }): Array<{\n tableName: string;\n schema: unknown;\n relations?: unknown;\n }> {\n const modelClasses = this.getDataSourceModelClasses({ dataSource: opts.dataSource });\n\n const rs = Array.from(modelClasses)\n .map(modelClass => {\n // Read straight off the class: a class -> name -> modelRegistry round-trip collapses two\n // same-named models onto one entry, silently swapping schemas. `modelRegistry` stays\n // name-keyed for the by-name APIs that need it.\n const entry: IModelRegistryEntry = {\n target: modelClass as AnyType,\n metadata:\n this.getModelMetadata({ target: modelClass }) ?? ({ settings: {} } as AnyType),\n schema: (modelClass as AnyType).schema,\n relationsResolver: (modelClass as AnyType).relations,\n };\n\n if (entry.schema === undefined) {\n return null;\n }\n\n return {\n tableName: this.resolveModelKey({ modelClass }),\n schema: entry.schema,\n relations: this.resolveModelRelations(entry),\n };\n })\n .filter((item): item is NonNullable<typeof item> => {\n return item !== undefined && item !== null;\n });\n\n return rs;\n }\n\n /**\n * Like getModels but returns only resolved model classes - used by BaseSearchDataSource, which\n * has no pgTable to resolve.\n */\n getModelClasses(opts: { dataSource: string | TClass<IDataSource> }): Array<TClass<unknown>> {\n // Straight from the stored class refs: a name round-trip through the shared modelRegistry\n // would hand back whichever same-named class registered last.\n return Array.from(this.getDataSourceModelClasses({ dataSource: opts.dataSource }));\n }\n\n /** The key a model occupies in `modelRegistry` - its table name, or its class name when it has none. */\n resolveModelKey(opts: { modelClass: TClass<AnyType> }): string {\n const { modelClass } = opts;\n const modelMetadata = this.getModelMetadata({ target: modelClass });\n\n return (\n [modelMetadata?.tableName, (modelClass as AnyType).TABLE_NAME].find(Boolean) ??\n modelClass.name\n );\n }\n\n /** Assembles table schemas + relations for a datasource's registered models. */\n buildSchema(opts: { dataSource: string | TClass<IDataSource> }): {\n schema: Record<string, unknown>;\n relations: Record<string, unknown>;\n } {\n const { dataSource } = opts;\n const models = this.getModels({ dataSource });\n\n const rs: {\n schema: Record<string, unknown>;\n relations: Record<string, unknown>;\n } = { schema: {}, relations: {} };\n\n for (const model of models) {\n if (model.schema) {\n rs.schema[model.tableName] = model.schema;\n }\n\n if (model.relations) {\n rs.relations[`${model.tableName}Relations`] = model.relations;\n }\n }\n\n return rs;\n }\n\n hasModels(opts: { dataSource: string | TClass<IDataSource> }): boolean {\n return this.getDataSourceModelClasses({ dataSource: opts.dataSource }).size > 0;\n }\n };\n};\n"]}
1
+ {"version":3,"file":"repository.mixin.js","sourceRoot":"","sources":["../../../../../src/helpers/inversion/mixins/repository.mixin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AASrE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAQrC,SAAoB,EACpB,EAAE;IACF,OAAO,KAAM,SAAQ,SAAS;QAc5B,qBAAqB,CAInB,IAKD;YACC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;YAClC,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QACpE,CAAC;QAED,qBAAqB,CAAiC,IAErD;YACC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;YACxB,OAAO,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC9D,CAAC;QAED,6GAA6G;QAC7G,yBAAyB,CAGvB,IAA2C;YAC3C,wFAAwF;YACxF,2FAA2F;YAC3F,gDAAgD;YAChD,MAAM,eAAe,GAAG,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;YACjE,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACxD,IAAI,CAAC,yBAAyB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AC;YAC5B,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;YAEpE,OAAO,CACL,CAAC,aAAa,EAAE,SAAS,EAAG,UAAsB,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;gBAC5E,UAAU,CAAC,IAAI,CAChB,CAAC;QACJ,CAAC;QAED,gFAAgF;QAChF,WAAW,CAAC,IAAkD;YAI5D,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;YAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;YAE9C,MAAM,EAAE,GAGJ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;YAElC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC3B,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;oBACjB,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;gBAC5C,CAAC;gBAED,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;oBACpB,EAAE,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,SAAS,WAAW,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;gBAChE,CAAC;YACH,CAAC;YAED,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,SAAS,CAAC,IAAkD;YAC1D,OAAO,IAAI,CAAC,yBAAyB,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;QAClF,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { IDataSource } from '@/base/datasources';\nimport type { AbstractEntity } from '@/base/models';\nimport type { AnyType, TClass, TMixinTarget } from '@venizia/ignis-helpers/common';\nimport { resolveValue } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport type { MetadataRegistry as _MetadataRegistry } from '@venizia/ignis-inversion';\nimport { MetadataKeys } from '../common/keys';\nimport { RelationBuilderRegistry } from '../common/relation-builder';\nimport type {\n IModelMetadata,\n IModelRegistryEntry,\n IRepositoryBinding,\n IResolvedRepositoryMetadata,\n TRepositoryMetadata,\n} from '../common/types';\n\nexport const RepositoryMetadataMixin = <\n BaseClass extends TMixinTarget<\n _MetadataRegistry & {\n modelRegistry: Map<string, IModelRegistryEntry>;\n getModelMetadata(opts: { target: object }): IModelMetadata | undefined;\n }\n >,\n>(\n baseClass: BaseClass,\n) => {\n return class extends baseClass {\n /** By repository class name, for the by-name API. Two classes may share a name; `repositoryBindingsByClass` cannot confuse them. */\n repositoryBindings: Map<string, IRepositoryBinding<AbstractEntity>>;\n\n /** By repository class: a minified build renames classes, and two chunks may give two of them one name. */\n repositoryBindingsByClass: Map<Function, IRepositoryBinding<AbstractEntity>>;\n\n /**\n * The model classes each datasource owns, keyed by the datasource class - or by the string a\n * repository named it with (`dataSource: 'PgDataSource'`), which only a class of that name\n * can match. Never by class name alone: a minified build gives two datasources one name.\n */\n datasourceModels: Map<string | Function, Set<TClass<AnyType>>>;\n\n setRepositoryMetadata<\n Target extends object = object,\n Model extends AbstractEntity = AbstractEntity,\n DataSource extends IDataSource = IDataSource,\n >(opts: {\n target: Target;\n metadata: TRepositoryMetadata<Model, DataSource> & {\n _resolved?: IResolvedRepositoryMetadata<Model, DataSource>;\n };\n }): void {\n const { target, metadata } = opts;\n Reflect.defineMetadata(MetadataKeys.REPOSITORY, metadata, target);\n }\n\n getRepositoryMetadata<Target extends object = object>(opts: {\n target: Target;\n }): (TRepositoryMetadata & { _resolved?: IResolvedRepositoryMetadata }) | undefined {\n const { target } = opts;\n return Reflect.getMetadata(MetadataKeys.REPOSITORY, target);\n }\n\n /** Registers a repository binding (called by @repository) linking a repository to its model + datasource. */\n registerRepositoryBinding<\n Model extends AbstractEntity = AbstractEntity,\n DataSource extends IDataSource = IDataSource,\n >(opts: IRepositoryBinding<Model, DataSource>) {\n // Every member of the binding may be a resolver, the escape hatch for circular imports.\n // Reading `.name` off the resolver keys the registry by the arrow's inferred name, and the\n // datasource then silently discovers no schema.\n const repositoryClass = resolveValue({ value: opts.repository });\n this.repositoryBindings.set(repositoryClass.name, opts);\n this.repositoryBindingsByClass.set(repositoryClass, opts);\n\n const dataSourceRef = resolveValue({ value: opts.dataSource });\n const modelClass = resolveValue({ value: opts.model });\n\n if (!this.datasourceModels.has(dataSourceRef)) {\n this.datasourceModels.set(dataSourceRef, new Set());\n }\n\n this.datasourceModels.get(dataSourceRef)!.add(modelClass);\n }\n\n /** By class, walking up to the nearest decorated parent; by name only for callers holding a name. */\n getRepositoryBinding(\n opts: { target: Function } | { name: string },\n ): IRepositoryBinding<AbstractEntity> | undefined {\n if ('name' in opts) {\n return this.repositoryBindings.get(opts.name);\n }\n\n for (\n let current: Function | null = opts.target;\n current && current !== Function.prototype;\n current = Object.getPrototypeOf(current)\n ) {\n const binding = this.repositoryBindingsByClass.get(current);\n if (binding) {\n return binding;\n }\n }\n\n return undefined;\n }\n\n /** A class finds what was registered under it, and under a string equal to its name. */\n getDataSourceModelClasses(opts: {\n dataSource: string | TClass<IDataSource>;\n }): Set<TClass<AnyType>> {\n const { dataSource } = opts;\n\n if (typeof dataSource === 'string') {\n return this.datasourceModels.get(dataSource) ?? new Set();\n }\n\n return new Set([\n ...(this.datasourceModels.get(dataSource) ?? []),\n ...(this.datasourceModels.get(dataSource.name) ?? []),\n ]);\n }\n\n /**\n * Resolves and caches relations for a model entry - called lazily from buildSchema() so that\n * every `@model` class is registered first, which avoids circular-dependency ordering issues.\n * @internal\n */\n resolveModelRelations(modelMeta: IModelRegistryEntry): unknown {\n if (modelMeta._builtRelations !== undefined) {\n return modelMeta._builtRelations;\n }\n\n if (!modelMeta.relationsResolver) {\n return undefined;\n }\n\n const relations = resolveValue({ value: modelMeta.relationsResolver });\n\n if (!relations || !modelMeta.schema) {\n return undefined;\n }\n\n const builder = RelationBuilderRegistry.resolve();\n\n // Relations were declared but no connector installed a builder - silently dropping them\n // would surface much later as an empty `with` clause.\n if (!builder) {\n throw getError({\n message: `[RepositoryMetadataMixin][resolveModelRelations] Model declares relations but no relation builder is registered | Import the relational connector so it installs one`,\n });\n }\n\n const builtRelations = builder({ source: modelMeta.schema, relations });\n\n modelMeta._builtRelations = builtRelations?.relations;\n return modelMeta._builtRelations;\n }\n\n /**\n * Models registered for a datasource, relations resolved lazily. `schema`/`relations` stay\n * `unknown` - the registry is shared across connectors, so each connector narrows at its call\n * site.\n */\n getModels(opts: { dataSource: string | TClass<IDataSource> }): Array<{\n tableName: string;\n schema: unknown;\n relations?: unknown;\n }> {\n const modelClasses = this.getDataSourceModelClasses({ dataSource: opts.dataSource });\n\n const rs = Array.from(modelClasses)\n .map((modelClass) => {\n // Read straight off the class: a class -> name -> modelRegistry round-trip collapses two\n // same-named models onto one entry, silently swapping schemas. `modelRegistry` stays\n // name-keyed for the by-name APIs that need it.\n const entry: IModelRegistryEntry = {\n target: modelClass as AnyType,\n metadata:\n this.getModelMetadata({ target: modelClass }) ?? ({ settings: {} } as AnyType),\n schema: (modelClass as AnyType).schema,\n relationsResolver: (modelClass as AnyType).relations,\n };\n\n if (entry.schema === undefined) {\n return null;\n }\n\n return {\n tableName: this.resolveModelKey({ modelClass }),\n schema: entry.schema,\n relations: this.resolveModelRelations(entry),\n };\n })\n .filter((item): item is NonNullable<typeof item> => {\n return item !== undefined && item !== null;\n });\n\n return rs;\n }\n\n /**\n * Like getModels but returns only resolved model classes - used by BaseSearchDataSource, which\n * has no pgTable to resolve.\n */\n getModelClasses(opts: { dataSource: string | TClass<IDataSource> }): Array<TClass<unknown>> {\n // Straight from the stored class refs: a name round-trip through the shared modelRegistry\n // would hand back whichever same-named class registered last.\n return Array.from(this.getDataSourceModelClasses({ dataSource: opts.dataSource }));\n }\n\n /** The key a model occupies in `modelRegistry` - its table name, or its class name when it has none. */\n resolveModelKey(opts: { modelClass: TClass<AnyType> }): string {\n const { modelClass } = opts;\n const modelMetadata = this.getModelMetadata({ target: modelClass });\n\n return (\n [modelMetadata?.tableName, (modelClass as AnyType).TABLE_NAME].find(Boolean) ??\n modelClass.name\n );\n }\n\n /** Assembles table schemas + relations for a datasource's registered models. */\n buildSchema(opts: { dataSource: string | TClass<IDataSource> }): {\n schema: Record<string, unknown>;\n relations: Record<string, unknown>;\n } {\n const { dataSource } = opts;\n const models = this.getModels({ dataSource });\n\n const rs: {\n schema: Record<string, unknown>;\n relations: Record<string, unknown>;\n } = { schema: {}, relations: {} };\n\n for (const model of models) {\n if (model.schema) {\n rs.schema[model.tableName] = model.schema;\n }\n\n if (model.relations) {\n rs.relations[`${model.tableName}Relations`] = model.relations;\n }\n }\n\n return rs;\n }\n\n hasModels(opts: { dataSource: string | TClass<IDataSource> }): boolean {\n return this.getDataSourceModelClasses({ dataSource: opts.dataSource }).size > 0;\n }\n };\n};\n"]}
@@ -28,5 +28,5 @@ export type { IDataSource } from './base/datasources/common/types.js';
28
28
  export { AbstractEntity } from './base/models/base.js';
29
29
  export { SchemaTypes } from './base/models/common/constants.js';
30
30
  export type { TIdSchemaType, TSchemaType } from './base/models/common/index.js';
31
- export type { TFilter, TInclusion, TWhere } from '@venizia/ignis-filter';
31
+ export type { TByIdFilter, TFields, TFilter, TInclusion, TRow, TSelectedRow, TWhere, } from '@venizia/ignis-filter';
32
32
  //# sourceMappingURL=repository.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../src/repository.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEjE,YAAY,EACV,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,WAAW,EACX,oBAAoB,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O,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAG5E,mGAAmG;AACnG,mEAAmE;AACnE,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,eAAe,GAChB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAK9D,mGAAmG;AACnG,qFAAqF;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC","sourcesContent":["/**\n * The persistence contract, and nothing about how a row is served or validated.\n *\n * A repository talks to a datasource. `AbstractDataSource` is engine-neutral - its only required\n * member is `configure()` - so \"an HTTP request to another server\" is a datasource in the same sense\n * Drizzle-over-Postgres is one: same role, different transport. This entry exists so a consumer can\n * implement that without taking the OpenAPI layer, which `base/repositories` reaches through\n * `query-schemas` and `result-schemas`.\n *\n * Both halves already speak `@venizia/ignis-filter`, so a consumer on another transport shares the\n * query vocabulary rather than translating into one.\n *\n * Weight is a contract, checked by `src/__tests__/bundle/browser-weight.test.ts`.\n */\n\nexport { AbstractRepository } from '@/base/repositories/core/abstract';\nexport { AbstractDataSource } from '@/base/datasources/abstract';\n\nexport type {\n ICreatableRepository,\n ICrudRepository,\n IDeletableRepository,\n IPersistableRepository,\n IReadableRepository,\n IRepository,\n IUpdatableRepository,\n} from '@/base/repositories/common/types/contracts';\n\nexport { buildDataRange } from '@/base/repositories/common/types/results';\n\n// How a client reads what an IGNIS server answers - shared by the http connector and any client\n// that reads the same server without it.\nexport { HttpResponseReader } from '@/base/repositories/common/response-reader';\nexport { HttpExtraRequest } from '@/base/repositories/common/extra-request';\nexport type { TExtraRequest, TExtraResult } from '@/base/repositories/common/extra-request';\n\n// What a repository on any transport raises and bounds itself by - the constants, the error codes,\n// and the helper an engine that lacks an operation throws through.\nexport {\n DEFAULT_LIMIT,\n DEFAULT_MAX_LIMIT,\n RepositoryOperationScopes,\n RepositoryTypes,\n} from '@/base/repositories/common/constants';\nexport type { TRepositoryType } from '@/base/repositories/common/constants';\nexport { CoreErrorCodes, SearchErrorCodes } from '@/common/error-codes';\nexport { throwNotSupported } from '@/utilities/error.utility';\nexport type { TCount, TDataRange, TDataWithRange } from '@/base/repositories/common/types/results';\n\nexport type { IDataSource } from '@/base/datasources/common/types';\n\n// `IRepository` names an entity, so a consumer implementing the contract needs the base to extend.\n// Engine-neutral like the datasource: a name, `getSchema({ type })`, and an id type.\nexport { AbstractEntity } from '@/base/models/base';\nexport { SchemaTypes } from '@/base/models/common/constants';\nexport type { TIdSchemaType, TSchemaType } from '@/base/models/common';\n\n// The query vocabulary both transports share.\nexport type { TFilter, TInclusion, TWhere } from '@venizia/ignis-filter';\n"]}
1
+ {"version":3,"file":"repository.js","sourceRoot":"","sources":["../../src/repository.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAYjE,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAE1E,gGAAgG;AAChG,yCAAyC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAG5E,mGAAmG;AACnG,mEAAmE;AACnE,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,eAAe,GAChB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAK9D,mGAAmG;AACnG,qFAAqF;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC","sourcesContent":["/**\n * The persistence contract, and nothing about how a row is served or validated.\n *\n * A repository talks to a datasource. `AbstractDataSource` is engine-neutral - its only required\n * member is `configure()` - so \"an HTTP request to another server\" is a datasource in the same sense\n * Drizzle-over-Postgres is one: same role, different transport. This entry exists so a consumer can\n * implement that without taking the OpenAPI layer, which `base/repositories` reaches through\n * `query-schemas` and `result-schemas`.\n *\n * Both halves already speak `@venizia/ignis-filter`, so a consumer on another transport shares the\n * query vocabulary rather than translating into one.\n *\n * Weight is a contract, checked by `src/__tests__/bundle/browser-weight.test.ts`.\n */\n\nexport { AbstractRepository } from '@/base/repositories/core/abstract';\nexport { AbstractDataSource } from '@/base/datasources/abstract';\n\nexport type {\n ICreatableRepository,\n ICrudRepository,\n IDeletableRepository,\n IPersistableRepository,\n IReadableRepository,\n IRepository,\n IUpdatableRepository,\n} from '@/base/repositories/common/types/contracts';\n\nexport { buildDataRange } from '@/base/repositories/common/types/results';\n\n// How a client reads what an IGNIS server answers - shared by the http connector and any client\n// that reads the same server without it.\nexport { HttpResponseReader } from '@/base/repositories/common/response-reader';\nexport { HttpExtraRequest } from '@/base/repositories/common/extra-request';\nexport type { TExtraRequest, TExtraResult } from '@/base/repositories/common/extra-request';\n\n// What a repository on any transport raises and bounds itself by - the constants, the error codes,\n// and the helper an engine that lacks an operation throws through.\nexport {\n DEFAULT_LIMIT,\n DEFAULT_MAX_LIMIT,\n RepositoryOperationScopes,\n RepositoryTypes,\n} from '@/base/repositories/common/constants';\nexport type { TRepositoryType } from '@/base/repositories/common/constants';\nexport { CoreErrorCodes, SearchErrorCodes } from '@/common/error-codes';\nexport { throwNotSupported } from '@/utilities/error.utility';\nexport type { TCount, TDataRange, TDataWithRange } from '@/base/repositories/common/types/results';\n\nexport type { IDataSource } from '@/base/datasources/common/types';\n\n// `IRepository` names an entity, so a consumer implementing the contract needs the base to extend.\n// Engine-neutral like the datasource: a name, `getSchema({ type })`, and an id type.\nexport { AbstractEntity } from '@/base/models/base';\nexport { SchemaTypes } from '@/base/models/common/constants';\nexport type { TIdSchemaType, TSchemaType } from '@/base/models/common';\n\n// The query vocabulary both transports share.\nexport type {\n TByIdFilter,\n TFields,\n TFilter,\n TInclusion,\n TRow,\n TSelectedRow,\n TWhere,\n} from '@venizia/ignis-filter';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@venizia/ignis-kernel",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Browser-pure kernel of the IGNIS framework: dependency injection, lifecycle, REST controllers, repository and datasource abstractions, and the authentication and authorization seams. No node builtin and no server-only peer, so the same kernel serves a Bun server and a browser Worker.",
5
5
  "keywords": [
6
6
  "authentication",
@@ -75,18 +75,18 @@
75
75
  "access": "public"
76
76
  },
77
77
  "scripts": {
78
- "force-update": "sh ../../scripts/force-update.sh",
78
+ "force-update": "sh ../../scripts/build/force-update.sh",
79
79
  "prepublishOnly": "make rebuild"
80
80
  },
81
81
  "dependencies": {
82
- "@venizia/ignis-filter": "0.4.0",
83
- "@venizia/ignis-helpers": "0.4.0",
84
- "@venizia/ignis-inversion": "0.4.0",
82
+ "@venizia/ignis-filter": "0.4.2",
83
+ "@venizia/ignis-helpers": "0.4.2",
84
+ "@venizia/ignis-inversion": "0.4.2",
85
85
  "reflect-metadata": "^0.2.2"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@types/bun": "^1.4.3",
89
- "@venizia/dev-configs": "0.4.0",
89
+ "@venizia/dev-configs": "0.4.2",
90
90
  "casbin": "^5.51.1",
91
91
  "eslint": "^10.13.0",
92
92
  "oxlint": "1.89.0",