@venizia/ignis-kernel 0.5.0-2 → 0.5.0-4

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 (59) hide show
  1. package/dist/esm/base/applications/boot-sequence.d.ts +2 -3
  2. package/dist/esm/base/applications/boot-sequence.js +2 -17
  3. package/dist/esm/base/applications/boot-sequence.js.map +1 -1
  4. package/dist/esm/base/applications/common/constants.d.ts +3 -6
  5. package/dist/esm/base/applications/common/constants.js +3 -17
  6. package/dist/esm/base/applications/common/constants.js.map +1 -1
  7. package/dist/esm/base/applications/rest.js +3 -3
  8. package/dist/esm/base/applications/rest.js.map +1 -1
  9. package/dist/esm/base/auth/authenticate/common/constants/authentication.d.ts +3 -7
  10. package/dist/esm/base/auth/authenticate/common/constants/authentication.js +3 -11
  11. package/dist/esm/base/auth/authenticate/common/constants/authentication.js.map +1 -1
  12. package/dist/esm/base/auth/authenticate/common/constants/jose.d.ts +6 -15
  13. package/dist/esm/base/auth/authenticate/common/constants/jose.js +6 -25
  14. package/dist/esm/base/auth/authenticate/common/constants/jose.js.map +1 -1
  15. package/dist/esm/base/auth/authorize/common/constants/authorization.d.ts +4 -9
  16. package/dist/esm/base/auth/authorize/common/constants/authorization.js +4 -15
  17. package/dist/esm/base/auth/authorize/common/constants/authorization.js.map +1 -1
  18. package/dist/esm/base/auth/authorize/common/constants/enforcer.d.ts +5 -12
  19. package/dist/esm/base/auth/authorize/common/constants/enforcer.js +5 -26
  20. package/dist/esm/base/auth/authorize/common/constants/enforcer.js.map +1 -1
  21. package/dist/esm/base/controllers/common/constants.d.ts +3 -6
  22. package/dist/esm/base/controllers/common/constants.js +3 -11
  23. package/dist/esm/base/controllers/common/constants.js.map +1 -1
  24. package/dist/esm/base/controllers/factory/controller.js +1 -1
  25. package/dist/esm/base/controllers/factory/controller.js.map +1 -1
  26. package/dist/esm/base/datasources/common/types.d.ts +2 -3
  27. package/dist/esm/base/datasources/common/types.js +2 -5
  28. package/dist/esm/base/datasources/common/types.js.map +1 -1
  29. package/dist/esm/base/events/common/constants.d.ts +3 -4
  30. package/dist/esm/base/events/common/constants.js +3 -6
  31. package/dist/esm/base/events/common/constants.js.map +1 -1
  32. package/dist/esm/base/events/event-bus.d.ts +2 -2
  33. package/dist/esm/base/events/event-bus.js +6 -6
  34. package/dist/esm/base/events/event-bus.js.map +1 -1
  35. package/dist/esm/base/metadata/injectable.js +1 -1
  36. package/dist/esm/base/metadata/injectable.js.map +1 -1
  37. package/dist/esm/base/metadata/model-metadata.js +1 -1
  38. package/dist/esm/base/metadata/model-metadata.js.map +1 -1
  39. package/dist/esm/base/metadata/persistents/datasource.js +1 -1
  40. package/dist/esm/base/metadata/persistents/datasource.js.map +1 -1
  41. package/dist/esm/base/metadata/persistents/repository/validate.js +1 -1
  42. package/dist/esm/base/metadata/persistents/repository/validate.js.map +1 -1
  43. package/dist/esm/base/models/common/constants.d.ts +5 -11
  44. package/dist/esm/base/models/common/constants.js +5 -23
  45. package/dist/esm/base/models/common/constants.js.map +1 -1
  46. package/dist/esm/base/repositories/common/constants.d.ts +7 -18
  47. package/dist/esm/base/repositories/common/constants.js +7 -35
  48. package/dist/esm/base/repositories/common/constants.js.map +1 -1
  49. package/dist/esm/base/repositories/core/abstract.js +2 -2
  50. package/dist/esm/base/repositories/core/abstract.js.map +1 -1
  51. package/dist/esm/common/statuses/user.d.ts +2 -3
  52. package/dist/esm/common/statuses/user.js +2 -5
  53. package/dist/esm/common/statuses/user.js.map +1 -1
  54. package/dist/esm/helpers/inversion/common/constants.d.ts +3 -6
  55. package/dist/esm/helpers/inversion/common/constants.js +3 -18
  56. package/dist/esm/helpers/inversion/common/constants.js.map +1 -1
  57. package/dist/esm/helpers/inversion/common/types/model.d.ts +1 -1
  58. package/dist/esm/helpers/inversion/common/types/model.js.map +1 -1
  59. package/package.json +5 -5
@@ -1,4 +1,5 @@
1
1
  import type { TConstValue } from '@venizia/ignis-helpers/common';
2
+ import { ConstClass } from '@venizia/ignis-helpers/common';
2
3
  /** Default pagination limit for repository queries. */
3
4
  export declare const DEFAULT_LIMIT = 10;
4
5
  /**
@@ -14,32 +15,26 @@ export declare const DEFAULT_LIMIT = 10;
14
15
  */
15
16
  export declare const DEFAULT_MAX_LIMIT = 1000;
16
17
  /** Defines the operation scope for repository instances (READ_ONLY, WRITE_ONLY, READ_WRITE). */
17
- export declare class RepositoryOperationScopes {
18
+ export declare class RepositoryOperationScopes extends ConstClass {
18
19
  static readonly READ_ONLY = "READ_ONLY";
19
20
  static readonly WRITE_ONLY = "WRITE_ONLY";
20
21
  static readonly READ_WRITE = "READ_WRITE";
21
- static readonly SCHEME_SET: Set<string>;
22
- static isValid(orgType: string): boolean;
23
22
  }
24
23
  /** Valid repository operation scope values. */
25
24
  export type TRepositoryOperationScope = TConstValue<typeof RepositoryOperationScopes>;
26
25
  /** What `@repository` binds: MODEL, a model this application declares; REMOTE, data behind another service's API, with no model. */
27
- export declare class RepositoryTypes {
26
+ export declare class RepositoryTypes extends ConstClass {
28
27
  static readonly MODEL = "model";
29
28
  static readonly REMOTE = "remote";
30
- static readonly SCHEME_SET: Set<string>;
31
- static isValid(value: string): boolean;
32
29
  }
33
30
  /** Valid repository type values. */
34
31
  export type TRepositoryType = TConstValue<typeof RepositoryTypes>;
35
32
  /** What a row-scope filter (`@model` settings.access) does when `resolve()` returns null/undefined. */
36
- export declare class ScopeFilterMissingBehaviors {
33
+ export declare class ScopeFilterMissingBehaviors extends ConstClass {
37
34
  /** An unresolved scope matches ZERO rows - the safe reading of "caller's scope is unknown". */
38
35
  static readonly DENY = "deny";
39
36
  /** Explicit opt-out: no scope is applied. For migrations and background jobs, never inferred from a request. */
40
37
  static readonly ALLOW = "allow";
41
- static readonly SCHEME_SET: Set<string>;
42
- static isValid(behavior: string): boolean;
43
38
  }
44
39
  /** Valid scope-filter missing-behavior values. */
45
40
  export type TScopeFilterMissingBehavior = TConstValue<typeof ScopeFilterMissingBehaviors>;
@@ -48,13 +43,11 @@ export type TScopeFilterMissingBehavior = TConstValue<typeof ScopeFilterMissingB
48
43
  * (`@model` settings.access.write.mode). A scope that returns `ScopeFilters.UNRESTRICTED`
49
44
  * passes either way.
50
45
  */
51
- export declare class ScopeWriteGuards {
46
+ export declare class ScopeWriteGuards extends ConstClass {
52
47
  /** A row whose scope column disagrees, or is absent on create, is refused and nothing is written. */
53
48
  static readonly REJECT = "reject";
54
49
  /** An ABSENT scope column is filled from an equality scope; a value that disagrees is still refused. */
55
50
  static readonly ASSIGN = "assign";
56
- static readonly SCHEME_SET: Set<string>;
57
- static isValid(guard: string): boolean;
58
51
  }
59
52
  /** Valid scope write-guard values. */
60
53
  export type TScopeWriteGuard = TConstValue<typeof ScopeWriteGuards>;
@@ -83,22 +76,18 @@ export declare class RepositoryErrorCodes {
83
76
  /** Valid repository error code values. */
84
77
  export type TRepositoryErrorCode = TConstValue<typeof RepositoryErrorCodes>;
85
78
  /** Entity relation types (one-to-one/many-to-one, one-to-many). */
86
- export declare class RelationTypes {
79
+ export declare class RelationTypes extends ConstClass {
87
80
  static readonly ONE = "one";
88
81
  static readonly MANY = "many";
89
- static readonly SCHEME_SET: Set<string>;
90
- static isValid(orgType: string): boolean;
91
82
  }
92
83
  /** Valid relation type values. */
93
84
  export type TRelationType = TConstValue<typeof RelationTypes>;
94
85
  /** PostgreSQL row-level lock strengths for SELECT ... FOR <strength>. */
95
- export declare class LockStrengths {
86
+ export declare class LockStrengths extends ConstClass {
96
87
  static readonly UPDATE = "update";
97
88
  static readonly NO_KEY_UPDATE = "no key update";
98
89
  static readonly SHARE = "share";
99
90
  static readonly KEY_SHARE = "key share";
100
- static readonly SCHEME_SET: Set<string>;
101
- static isValid(strength: string): boolean;
102
91
  }
103
92
  /** Valid lock strength values. */
104
93
  export type TLockStrength = TConstValue<typeof LockStrengths>;
@@ -1,4 +1,5 @@
1
1
  import { MessageCode } from '@venizia/ignis-helpers/core';
2
+ import { ConstClass } from '@venizia/ignis-helpers/common';
2
3
  /** Default pagination limit for repository queries. */
3
4
  export const DEFAULT_LIMIT = 10;
4
5
  /**
@@ -14,49 +15,33 @@ export const DEFAULT_LIMIT = 10;
14
15
  */
15
16
  export const DEFAULT_MAX_LIMIT = 1000;
16
17
  /** Defines the operation scope for repository instances (READ_ONLY, WRITE_ONLY, READ_WRITE). */
17
- export class RepositoryOperationScopes {
18
+ export class RepositoryOperationScopes extends ConstClass {
18
19
  static { this.READ_ONLY = 'READ_ONLY'; }
19
20
  static { this.WRITE_ONLY = 'WRITE_ONLY'; }
20
21
  static { this.READ_WRITE = 'READ_WRITE'; }
21
- static { this.SCHEME_SET = new Set([this.READ_ONLY, this.WRITE_ONLY, this.READ_WRITE]); }
22
- static isValid(orgType) {
23
- return this.SCHEME_SET.has(orgType);
24
- }
25
22
  }
26
23
  /** What `@repository` binds: MODEL, a model this application declares; REMOTE, data behind another service's API, with no model. */
27
- export class RepositoryTypes {
24
+ export class RepositoryTypes extends ConstClass {
28
25
  static { this.MODEL = 'model'; }
29
26
  static { this.REMOTE = 'remote'; }
30
- static { this.SCHEME_SET = new Set([this.MODEL, this.REMOTE]); }
31
- static isValid(value) {
32
- return this.SCHEME_SET.has(value);
33
- }
34
27
  }
35
28
  /** What a row-scope filter (`@model` settings.access) does when `resolve()` returns null/undefined. */
36
- export class ScopeFilterMissingBehaviors {
29
+ export class ScopeFilterMissingBehaviors extends ConstClass {
37
30
  /** An unresolved scope matches ZERO rows - the safe reading of "caller's scope is unknown". */
38
31
  static { this.DENY = 'deny'; }
39
32
  /** Explicit opt-out: no scope is applied. For migrations and background jobs, never inferred from a request. */
40
33
  static { this.ALLOW = 'allow'; }
41
- static { this.SCHEME_SET = new Set([this.DENY, this.ALLOW]); }
42
- static isValid(behavior) {
43
- return this.SCHEME_SET.has(behavior);
44
- }
45
34
  }
46
35
  /**
47
36
  * What a scoped write does with a row whose scope column disagrees with the resolved scope
48
37
  * (`@model` settings.access.write.mode). A scope that returns `ScopeFilters.UNRESTRICTED`
49
38
  * passes either way.
50
39
  */
51
- export class ScopeWriteGuards {
40
+ export class ScopeWriteGuards extends ConstClass {
52
41
  /** A row whose scope column disagrees, or is absent on create, is refused and nothing is written. */
53
42
  static { this.REJECT = 'reject'; }
54
43
  /** An ABSENT scope column is filled from an equality scope; a value that disagrees is still refused. */
55
44
  static { this.ASSIGN = 'assign'; }
56
- static { this.SCHEME_SET = new Set([this.REJECT, this.ASSIGN]); }
57
- static isValid(guard) {
58
- return this.SCHEME_SET.has(guard);
59
- }
60
45
  }
61
46
  /**
62
47
  * The third `resolve()` state, beside a `where` and `deny`-by-default null/undefined: unrestricted
@@ -85,29 +70,16 @@ export class RepositoryErrorCodes {
85
70
  }); }
86
71
  }
87
72
  /** Entity relation types (one-to-one/many-to-one, one-to-many). */
88
- export class RelationTypes {
73
+ export class RelationTypes extends ConstClass {
89
74
  static { this.ONE = 'one'; }
90
75
  static { this.MANY = 'many'; }
91
- static { this.SCHEME_SET = new Set([this.ONE, this.MANY]); }
92
- static isValid(orgType) {
93
- return this.SCHEME_SET.has(orgType);
94
- }
95
76
  }
96
77
  /** PostgreSQL row-level lock strengths for SELECT ... FOR <strength>. */
97
- export class LockStrengths {
78
+ export class LockStrengths extends ConstClass {
98
79
  static { this.UPDATE = 'update'; }
99
80
  static { this.NO_KEY_UPDATE = 'no key update'; }
100
81
  static { this.SHARE = 'share'; }
101
82
  static { this.KEY_SHARE = 'key share'; }
102
- static { this.SCHEME_SET = new Set([
103
- this.UPDATE,
104
- this.NO_KEY_UPDATE,
105
- this.SHARE,
106
- this.KEY_SHARE,
107
- ]); }
108
- static isValid(strength) {
109
- return this.SCHEME_SET.has(strength);
110
- }
111
83
  }
112
84
  /**
113
85
  * What a repository call does to rows, as the row scope (`@model` settings.access) sees it.
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/base/repositories/common/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,uDAAu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IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAiE;QAC/E,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QAElC,OAAO,KAAK,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,CAAC;IACrF,CAAC","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers/common';\nimport { MessageCode } from '@venizia/ignis-helpers/core';\n\n/** Default pagination limit for repository queries. */\nexport const DEFAULT_LIMIT = 10;\n\n/**\n * Largest `limit` a caller may ask for when a model declares no `query.limit.max`.\n *\n * POLICY, not capacity - it sits far below what an engine can physically serve. It exists because\n * removing an accidental guardrail without replacing it would leave the framework less safe than\n * before: a search engine refused a page over 250 hits, so `limit: 5000` failed fast and cheap.\n * Once that page is served, something has to decide when a page is unreasonable.\n *\n * 1000 sits above any list screen and well below the physical ceiling, so reaching it means the\n * caller is doing something unusual - and a model raises it by saying so explicitly.\n */\nexport const DEFAULT_MAX_LIMIT = 1000;\n\n/** Defines the operation scope for repository instances (READ_ONLY, WRITE_ONLY, READ_WRITE). */\nexport class RepositoryOperationScopes {\n static readonly READ_ONLY = 'READ_ONLY';\n static readonly WRITE_ONLY = 'WRITE_ONLY';\n static readonly READ_WRITE = 'READ_WRITE';\n static readonly SCHEME_SET = new Set([this.READ_ONLY, this.WRITE_ONLY, this.READ_WRITE]);\n\n static isValid(orgType: string): boolean {\n return this.SCHEME_SET.has(orgType);\n }\n}\n\n/** Valid repository operation scope values. */\nexport type TRepositoryOperationScope = TConstValue<typeof RepositoryOperationScopes>;\n\n/** What `@repository` binds: MODEL, a model this application declares; REMOTE, data behind another service's API, with no model. */\nexport class RepositoryTypes {\n static readonly MODEL = 'model';\n static readonly REMOTE = 'remote';\n static readonly SCHEME_SET = new Set([this.MODEL, this.REMOTE]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid repository type values. */\nexport type TRepositoryType = TConstValue<typeof RepositoryTypes>;\n\n/** What a row-scope filter (`@model` settings.access) does when `resolve()` returns null/undefined. */\nexport class ScopeFilterMissingBehaviors {\n /** An unresolved scope matches ZERO rows - the safe reading of \"caller's scope is unknown\". */\n static readonly DENY = 'deny';\n /** Explicit opt-out: no scope is applied. For migrations and background jobs, never inferred from a request. */\n static readonly ALLOW = 'allow';\n static readonly SCHEME_SET = new Set([this.DENY, this.ALLOW]);\n\n static isValid(behavior: string): boolean {\n return this.SCHEME_SET.has(behavior);\n }\n}\n\n/** Valid scope-filter missing-behavior values. */\nexport type TScopeFilterMissingBehavior = TConstValue<typeof ScopeFilterMissingBehaviors>;\n\n/**\n * What a scoped write does with a row whose scope column disagrees with the resolved scope\n * (`@model` settings.access.write.mode). A scope that returns `ScopeFilters.UNRESTRICTED`\n * passes either way.\n */\nexport class ScopeWriteGuards {\n /** A row whose scope column disagrees, or is absent on create, is refused and nothing is written. */\n static readonly REJECT = 'reject';\n /** An ABSENT scope column is filled from an equality scope; a value that disagrees is still refused. */\n static readonly ASSIGN = 'assign';\n static readonly SCHEME_SET = new Set([this.REJECT, this.ASSIGN]);\n\n static isValid(guard: string): boolean {\n return this.SCHEME_SET.has(guard);\n }\n}\n\n/** Valid scope write-guard values. */\nexport type TScopeWriteGuard = TConstValue<typeof ScopeWriteGuards>;\n\n/**\n * The third `resolve()` state, beside a `where` and `deny`-by-default null/undefined: unrestricted\n * for THIS call. `onMissing: 'allow'` cannot express it - `onMissing` lives on the model's static\n * settings, so using it for a per-user bypass (an internal operator) would also unscope every\n * ordinary user whose `resolve()` happens to return nothing.\n */\nexport class ScopeFilters {\n /**\n * Return from `resolve()` to apply NO scope for this request - a caller the application has\n * decided sees everything. Deliberately a symbol: forgetting to return must land in deny, and no\n * JSON body, query string, or header can ever produce this value. `Symbol.for` so two installed\n * copies of this package agree on identity, same as `DATA_SOURCE_BRAND`.\n */\n static readonly UNRESTRICTED = Symbol.for('@venizia/ignis-kernel:scope-filter-unrestricted');\n}\n\n/** Machine-readable codes for repository-level failures, in the dotted namespace core already uses (`core.not_supported`, `core.search_engine.*`) - a client maps the code, never the message. */\nexport class RepositoryErrorCodes {\n /** A verb the repository's `operationScope` does not permit (e.g. `create()` on a READ_ONLY one). */\n static readonly OPERATION_NOT_ALLOWED = MessageCode.build({\n parts: ['core', 'repository', 'operation_not_allowed'],\n });\n\n /** A write whose scope column disagrees with the resolved scope, or whose scope cannot be verified (`access` write guard). */\n static readonly SCOPE_WRITE_DENIED = MessageCode.build({\n parts: ['core', 'repository', 'scope_write_denied'],\n });\n}\n\n/** Valid repository error code values. */\nexport type TRepositoryErrorCode = TConstValue<typeof RepositoryErrorCodes>;\n\n/** Entity relation types (one-to-one/many-to-one, one-to-many). */\nexport class RelationTypes {\n static readonly ONE = 'one';\n static readonly MANY = 'many';\n static readonly SCHEME_SET = new Set([this.ONE, this.MANY]);\n\n static isValid(orgType: string): boolean {\n return this.SCHEME_SET.has(orgType);\n }\n}\n\n/** Valid relation type values. */\nexport type TRelationType = TConstValue<typeof RelationTypes>;\n\n/** PostgreSQL row-level lock strengths for SELECT ... FOR <strength>. */\nexport class LockStrengths {\n static readonly UPDATE = 'update';\n static readonly NO_KEY_UPDATE = 'no key update';\n static readonly SHARE = 'share';\n static readonly KEY_SHARE = 'key share';\n static readonly SCHEME_SET = new Set([\n this.UPDATE,\n this.NO_KEY_UPDATE,\n this.SHARE,\n this.KEY_SHARE,\n ]);\n\n static isValid(strength: string): boolean {\n return this.SCHEME_SET.has(strength);\n }\n}\n\n/** Valid lock strength values. */\nexport type TLockStrength = TConstValue<typeof LockStrengths>;\n\n/**\n * What a repository call does to rows, as the row scope (`@model` settings.access) sees it.\n * `access.resolve` receives one CONCRETE operation (READ, CREATE, UPDATE or DELETE), never a group,\n * so one function can answer a wide scope for a read and a narrow one for a write. WRITE and ALL\n * are groups of concrete operations, for application code that asks \"is this a write?\".\n */\nexport class ScopeOperations {\n // concrete: what a repository call is\n static readonly READ = 'read';\n static readonly CREATE = 'create';\n static readonly UPDATE = 'update';\n static readonly DELETE = 'delete';\n\n // groups: sets of concrete operations\n /** CREATE, UPDATE and DELETE. */\n static readonly WRITE = 'write';\n /** Every concrete operation. */\n static readonly ALL = 'all';\n\n /** All six values: the four concrete operations and the two groups. */\n static readonly SCHEME_SET = new Set<string>([\n this.READ,\n this.CREATE,\n this.UPDATE,\n this.DELETE,\n this.WRITE,\n this.ALL,\n ]);\n\n /** The concrete operations: what `access.resolve` can receive. */\n static readonly OPERATION_SET = new Set<string>([\n this.READ,\n this.CREATE,\n this.UPDATE,\n this.DELETE,\n ]);\n\n /** Which concrete operations each group holds. */\n static readonly GROUP_MAP: ReadonlyMap<string, ReadonlySet<string>> = new Map([\n [this.WRITE, new Set<string>([this.CREATE, this.UPDATE, this.DELETE])],\n [this.ALL, this.OPERATION_SET],\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n\n /**\n * Whether `operation` belongs to `group`. A concrete operation includes itself and nothing else;\n * WRITE includes CREATE, UPDATE and DELETE; ALL includes all four.\n */\n static includes(opts: { group: TScopeOperationGroup; operation: TScopeOperation }): boolean {\n const { group, operation } = opts;\n\n return group === operation || (this.GROUP_MAP.get(group)?.has(operation) ?? false);\n }\n}\n\n/** The four concrete operations: what `access.resolve` receives. Never WRITE or ALL. */\nexport type TScopeOperation =\n | typeof ScopeOperations.READ\n | typeof ScopeOperations.CREATE\n | typeof ScopeOperations.UPDATE\n | typeof ScopeOperations.DELETE;\n\n/** All six values: a concrete operation or a group. What `ScopeOperations.includes` takes as its group. */\nexport type TScopeOperationGroup = TConstValue<typeof ScopeOperations>;\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/base/repositories/common/constants.ts"],"names":[],"mappings":"AACA,OAAO,E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MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAiE;QAC/E,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QAElC,OAAO,KAAK,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,CAAC;IACrF,CAAC","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers/common';\nimport { MessageCode } from '@venizia/ignis-helpers/core';\nimport { ConstClass } from '@venizia/ignis-helpers/common';\n\n/** Default pagination limit for repository queries. */\nexport const DEFAULT_LIMIT = 10;\n\n/**\n * Largest `limit` a caller may ask for when a model declares no `query.limit.max`.\n *\n * POLICY, not capacity - it sits far below what an engine can physically serve. It exists because\n * removing an accidental guardrail without replacing it would leave the framework less safe than\n * before: a search engine refused a page over 250 hits, so `limit: 5000` failed fast and cheap.\n * Once that page is served, something has to decide when a page is unreasonable.\n *\n * 1000 sits above any list screen and well below the physical ceiling, so reaching it means the\n * caller is doing something unusual - and a model raises it by saying so explicitly.\n */\nexport const DEFAULT_MAX_LIMIT = 1000;\n\n/** Defines the operation scope for repository instances (READ_ONLY, WRITE_ONLY, READ_WRITE). */\nexport class RepositoryOperationScopes extends ConstClass {\n static readonly READ_ONLY = 'READ_ONLY';\n static readonly WRITE_ONLY = 'WRITE_ONLY';\n static readonly READ_WRITE = 'READ_WRITE';\n}\n\n/** Valid repository operation scope values. */\nexport type TRepositoryOperationScope = TConstValue<typeof RepositoryOperationScopes>;\n\n/** What `@repository` binds: MODEL, a model this application declares; REMOTE, data behind another service's API, with no model. */\nexport class RepositoryTypes extends ConstClass {\n static readonly MODEL = 'model';\n static readonly REMOTE = 'remote';\n}\n\n/** Valid repository type values. */\nexport type TRepositoryType = TConstValue<typeof RepositoryTypes>;\n\n/** What a row-scope filter (`@model` settings.access) does when `resolve()` returns null/undefined. */\nexport class ScopeFilterMissingBehaviors extends ConstClass {\n /** An unresolved scope matches ZERO rows - the safe reading of \"caller's scope is unknown\". */\n static readonly DENY = 'deny';\n /** Explicit opt-out: no scope is applied. For migrations and background jobs, never inferred from a request. */\n static readonly ALLOW = 'allow';\n}\n\n/** Valid scope-filter missing-behavior values. */\nexport type TScopeFilterMissingBehavior = TConstValue<typeof ScopeFilterMissingBehaviors>;\n\n/**\n * What a scoped write does with a row whose scope column disagrees with the resolved scope\n * (`@model` settings.access.write.mode). A scope that returns `ScopeFilters.UNRESTRICTED`\n * passes either way.\n */\nexport class ScopeWriteGuards extends ConstClass {\n /** A row whose scope column disagrees, or is absent on create, is refused and nothing is written. */\n static readonly REJECT = 'reject';\n /** An ABSENT scope column is filled from an equality scope; a value that disagrees is still refused. */\n static readonly ASSIGN = 'assign';\n}\n\n/** Valid scope write-guard values. */\nexport type TScopeWriteGuard = TConstValue<typeof ScopeWriteGuards>;\n\n/**\n * The third `resolve()` state, beside a `where` and `deny`-by-default null/undefined: unrestricted\n * for THIS call. `onMissing: 'allow'` cannot express it - `onMissing` lives on the model's static\n * settings, so using it for a per-user bypass (an internal operator) would also unscope every\n * ordinary user whose `resolve()` happens to return nothing.\n */\nexport class ScopeFilters {\n /**\n * Return from `resolve()` to apply NO scope for this request - a caller the application has\n * decided sees everything. Deliberately a symbol: forgetting to return must land in deny, and no\n * JSON body, query string, or header can ever produce this value. `Symbol.for` so two installed\n * copies of this package agree on identity, same as `DATA_SOURCE_BRAND`.\n */\n static readonly UNRESTRICTED = Symbol.for('@venizia/ignis-kernel:scope-filter-unrestricted');\n}\n\n/** Machine-readable codes for repository-level failures, in the dotted namespace core already uses (`core.not_supported`, `core.search_engine.*`) - a client maps the code, never the message. */\nexport class RepositoryErrorCodes {\n /** A verb the repository's `operationScope` does not permit (e.g. `create()` on a READ_ONLY one). */\n static readonly OPERATION_NOT_ALLOWED = MessageCode.build({\n parts: ['core', 'repository', 'operation_not_allowed'],\n });\n\n /** A write whose scope column disagrees with the resolved scope, or whose scope cannot be verified (`access` write guard). */\n static readonly SCOPE_WRITE_DENIED = MessageCode.build({\n parts: ['core', 'repository', 'scope_write_denied'],\n });\n}\n\n/** Valid repository error code values. */\nexport type TRepositoryErrorCode = TConstValue<typeof RepositoryErrorCodes>;\n\n/** Entity relation types (one-to-one/many-to-one, one-to-many). */\nexport class RelationTypes extends ConstClass {\n static readonly ONE = 'one';\n static readonly MANY = 'many';\n}\n\n/** Valid relation type values. */\nexport type TRelationType = TConstValue<typeof RelationTypes>;\n\n/** PostgreSQL row-level lock strengths for SELECT ... FOR <strength>. */\nexport class LockStrengths extends ConstClass {\n static readonly UPDATE = 'update';\n static readonly NO_KEY_UPDATE = 'no key update';\n static readonly SHARE = 'share';\n static readonly KEY_SHARE = 'key share';\n}\n\n/** Valid lock strength values. */\nexport type TLockStrength = TConstValue<typeof LockStrengths>;\n\n/**\n * What a repository call does to rows, as the row scope (`@model` settings.access) sees it.\n * `access.resolve` receives one CONCRETE operation (READ, CREATE, UPDATE or DELETE), never a group,\n * so one function can answer a wide scope for a read and a narrow one for a write. WRITE and ALL\n * are groups of concrete operations, for application code that asks \"is this a write?\".\n */\nexport class ScopeOperations {\n // concrete: what a repository call is\n static readonly READ = 'read';\n static readonly CREATE = 'create';\n static readonly UPDATE = 'update';\n static readonly DELETE = 'delete';\n\n // groups: sets of concrete operations\n /** CREATE, UPDATE and DELETE. */\n static readonly WRITE = 'write';\n /** Every concrete operation. */\n static readonly ALL = 'all';\n\n /** All six values: the four concrete operations and the two groups. */\n static readonly SCHEME_SET = new Set<string>([\n this.READ,\n this.CREATE,\n this.UPDATE,\n this.DELETE,\n this.WRITE,\n this.ALL,\n ]);\n\n /** The concrete operations: what `access.resolve` can receive. */\n static readonly OPERATION_SET = new Set<string>([\n this.READ,\n this.CREATE,\n this.UPDATE,\n this.DELETE,\n ]);\n\n /** Which concrete operations each group holds. */\n static readonly GROUP_MAP: ReadonlyMap<string, ReadonlySet<string>> = new Map([\n [this.WRITE, new Set<string>([this.CREATE, this.UPDATE, this.DELETE])],\n [this.ALL, this.OPERATION_SET],\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n\n /**\n * Whether `operation` belongs to `group`. A concrete operation includes itself and nothing else;\n * WRITE includes CREATE, UPDATE and DELETE; ALL includes all four.\n */\n static includes(opts: { group: TScopeOperationGroup; operation: TScopeOperation }): boolean {\n const { group, operation } = opts;\n\n return group === operation || (this.GROUP_MAP.get(group)?.has(operation) ?? false);\n }\n}\n\n/** The four concrete operations: what `access.resolve` receives. Never WRITE or ALL. */\nexport type TScopeOperation =\n | typeof ScopeOperations.READ\n | typeof ScopeOperations.CREATE\n | typeof ScopeOperations.UPDATE\n | typeof ScopeOperations.DELETE;\n\n/** All six values: a concrete operation or a group. What `ScopeOperations.includes` takes as its group. */\nexport type TScopeOperationGroup = TConstValue<typeof ScopeOperations>;\n"]}
@@ -1,7 +1,7 @@
1
1
  import { MetadataRegistry } from '../../../helpers/inversion/index.js';
2
2
  import { BaseHelper, getError } from '@venizia/ignis-helpers/core';
3
3
  import { ResolverUtility } from '@venizia/ignis-helpers/common';
4
- import { RetryBackoffStrategies, RetryHelper, RetryJitterModes } from '@venizia/ignis-helpers/core';
4
+ import { RetryBackoffStrategies, RetryUtility, RetryJitterModes, } from '@venizia/ignis-helpers/core';
5
5
  // The file, not the `../common` barrel: the barrel re-exports the OpenAPI schemas, and this module is
6
6
  // on the `./repository` entry, which must load without `@hono/zod-openapi` installed.
7
7
  import { DEFAULT_MAX_LIMIT, RepositoryErrorCodes, RepositoryOperationScopes, } from '../common/constants.js';
@@ -217,7 +217,7 @@ export class AbstractRepository extends BaseHelper {
217
217
  return execution();
218
218
  }
219
219
  const { maxAttempts, maxTotalMs, signal, backoff, until } = options.retry;
220
- return RetryHelper.executeWithRetryUntil({
220
+ return RetryUtility.executeWithRetryUntil({
221
221
  operation: [this.constructor.name, operation].join('.'),
222
222
  execution,
223
223
  until: until ?? defaultUntil,
@@ -1 +1 @@
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;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAYpG,sGAAsG;AACtG,sFAAsF;AACtF,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAWpE;;;;GAIG;AACH,MAAM,OAAgB,kBAKpB,SAAQ,UAAU;IAqBlB,YACE,UAA2B,EAC3B,IAIC;QAED,MAAM,SAAS,GACb,IAAI,EAAE,KAAK;YACX,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAE/F,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAlB9B;;;WAGG;QACK,mBAAc,GAAsC,IAAI,CAAC;QAgB/D,IAAI,CAAC,eAAe,GAAG,IAAI,EAAE,cAAc,IAAI,yBAAyB,CAAC,SAAS,CAAC;QAEnF,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAChC,CAAC;QAED,IAAI,IAAI,EAAE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C,SAAS,EAAE,SAAS;YACpB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,CAAC,MAAM,EAAE,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 { 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
+ {"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../../src/base/repositories/core/abstract.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE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EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAA0B;SAC5F,CAAC,CAAC;IACL,CAAC;CA6FF","sourcesContent":["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 {\n RetryBackoffStrategies,\n RetryUtility,\n RetryJitterModes,\n} 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 RetryUtility.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,12 +1,11 @@
1
1
  import { CommonStatuses } from './common.js';
2
+ import { ConstClass } from '@venizia/ignis-helpers/common';
2
3
  /** User statuses. */
3
4
  export declare class UserStatuses extends CommonStatuses {
4
5
  }
5
6
  /** User types within the application. */
6
- export declare class UserTypes {
7
+ export declare class UserTypes extends ConstClass {
7
8
  static readonly SYSTEM = "SYSTEM";
8
9
  static readonly LINKED = "LINKED";
9
- static readonly SCHEME_SET: Set<string>;
10
- static isValid(orgType: string): boolean;
11
10
  }
12
11
  //# sourceMappingURL=user.d.ts.map
@@ -1,14 +1,11 @@
1
1
  import { CommonStatuses } from './common.js';
2
+ import { ConstClass } from '@venizia/ignis-helpers/common';
2
3
  /** User statuses. */
3
4
  export class UserStatuses extends CommonStatuses {
4
5
  }
5
6
  /** User types within the application. */
6
- export class UserTypes {
7
+ export class UserTypes extends ConstClass {
7
8
  static { this.SYSTEM = 'SYSTEM'; }
8
9
  static { this.LINKED = 'LINKED'; }
9
- static { this.SCHEME_SET = new Set([this.SYSTEM, this.LINKED]); }
10
- static isValid(orgType) {
11
- return this.SCHEME_SET.has(orgType);
12
- }
13
10
  }
14
11
  //# sourceMappingURL=user.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"user.js","sourceRoot":"","sources":["../../../../src/common/statuses/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,qBAAqB;AACrB,MAAM,OAAO,YAAa,SAAQ,cAAc;CAAG;AAEnD,yCAAyC;AACzC,MAAM,OAAO,SAAS;aACJ,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAEjE,MAAM,CAAC,OAAO,CAAC,OAAe;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC","sourcesContent":["import { CommonStatuses } from './common';\n\n/** User statuses. */\nexport class UserStatuses extends CommonStatuses {}\n\n/** User types within the application. */\nexport class UserTypes {\n static readonly SYSTEM = 'SYSTEM';\n static readonly LINKED = 'LINKED';\n\n static readonly SCHEME_SET = new Set([this.SYSTEM, this.LINKED]);\n\n static isValid(orgType: string): boolean {\n return this.SCHEME_SET.has(orgType);\n }\n}\n"]}
1
+ {"version":3,"file":"user.js","sourceRoot":"","sources":["../../../../src/common/statuses/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,qBAAqB;AACrB,MAAM,OAAO,YAAa,SAAQ,cAAc;CAAG;AAEnD,yCAAyC;AACzC,MAAM,OAAO,SAAU,SAAQ,UAAU;aACvB,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC","sourcesContent":["import { CommonStatuses } from './common';\nimport { ConstClass } from '@venizia/ignis-helpers/common';\n\n/** User statuses. */\nexport class UserStatuses extends CommonStatuses {}\n\n/** User types within the application. */\nexport class UserTypes extends ConstClass {\n static readonly SYSTEM = 'SYSTEM';\n static readonly LINKED = 'LINKED';\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { TConstValue } from '@venizia/ignis-helpers/common';
2
+ import { ConstClass } from '@venizia/ignis-helpers/common';
2
3
  /** What a decorated class is to the application - the one fact the artifact generator and the registration methods both read. */
3
- export declare class ArtifactTypes {
4
+ export declare class ArtifactTypes extends ConstClass {
4
5
  static readonly CONFIGURATION = "configuration";
5
6
  static readonly COMPONENT = "component";
6
7
  static readonly CONTROLLER = "controller";
@@ -8,15 +9,11 @@ export declare class ArtifactTypes {
8
9
  static readonly REPOSITORY = "repository";
9
10
  static readonly DATASOURCE = "datasource";
10
11
  static readonly MODEL = "model";
11
- static readonly SCHEME_SET: Set<string>;
12
- static isValid(value: string): boolean;
13
12
  }
14
13
  /** The `format` of `getAuthorizeModelPrincipals` and `getAuthorizeModelSettings`: ARRAY or RECORD. */
15
- export declare class AuthorizeModelFormats {
14
+ export declare class AuthorizeModelFormats extends ConstClass {
16
15
  static readonly ARRAY = "array";
17
16
  static readonly RECORD = "record";
18
- static readonly SCHEME_SET: Set<string>;
19
- static isValid(value: string): boolean;
20
17
  }
21
18
  /** Valid authorize model format values. */
22
19
  export type TAuthorizeModelFormat = TConstValue<typeof AuthorizeModelFormats>;
@@ -1,5 +1,6 @@
1
+ import { ConstClass } from '@venizia/ignis-helpers/common';
1
2
  /** What a decorated class is to the application - the one fact the artifact generator and the registration methods both read. */
2
- export class ArtifactTypes {
3
+ export class ArtifactTypes extends ConstClass {
3
4
  static { this.CONFIGURATION = 'configuration'; }
4
5
  static { this.COMPONENT = 'component'; }
5
6
  static { this.CONTROLLER = 'controller'; }
@@ -7,26 +8,10 @@ export class ArtifactTypes {
7
8
  static { this.REPOSITORY = 'repository'; }
8
9
  static { this.DATASOURCE = 'datasource'; }
9
10
  static { this.MODEL = 'model'; }
10
- static { this.SCHEME_SET = new Set([
11
- this.CONFIGURATION,
12
- this.COMPONENT,
13
- this.CONTROLLER,
14
- this.SERVICE,
15
- this.REPOSITORY,
16
- this.DATASOURCE,
17
- this.MODEL,
18
- ]); }
19
- static isValid(value) {
20
- return this.SCHEME_SET.has(value);
21
- }
22
11
  }
23
12
  /** The `format` of `getAuthorizeModelPrincipals` and `getAuthorizeModelSettings`: ARRAY or RECORD. */
24
- export class AuthorizeModelFormats {
13
+ export class AuthorizeModelFormats extends ConstClass {
25
14
  static { this.ARRAY = 'array'; }
26
15
  static { this.RECORD = 'record'; }
27
- static { this.SCHEME_SET = new Set([this.ARRAY, this.RECORD]); }
28
- static isValid(value) {
29
- return this.SCHEME_SET.has(value);
30
- }
31
16
  }
32
17
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/helpers/inversion/common/constants.ts"],"names":[],"mappings":"AAEA,iIAAiI;AACjI,MAAM,OAAO,aAAa;aACR,kBAAa,GAAG,eAAe,CAAC;aAChC,cAAS,GAAG,WAAW,CAAC;aACxB,eAAU,GAAG,YAAY,CAAC;aAC1B,YAAO,GAAG,SAAS,CAAC;aACpB,eAAU,GAAG,YAAY,CAAC;aAC1B,eAAU,GAAG,YAAY,CAAC;aAC1B,UAAK,GAAG,OAAO,CAAC;aAEhB,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,aAAa;QAClB,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,UAAU;QACf,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,UAAU;QACf,IAAI,CAAC,UAAU;QACf,IAAI,CAAC,KAAK;KACX,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAGH,sGAAsG;AACtG,MAAM,OAAO,qBAAqB;aAChB,UAAK,GAAG,OAAO,CAAC;aAChB,WAAM,GAAG,QAAQ,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAExE,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers/common';\n\n/** What a decorated class is to the application - the one fact the artifact generator and the registration methods both read. */\nexport class ArtifactTypes {\n static readonly CONFIGURATION = 'configuration';\n static readonly COMPONENT = 'component';\n static readonly CONTROLLER = 'controller';\n static readonly SERVICE = 'service';\n static readonly REPOSITORY = 'repository';\n static readonly DATASOURCE = 'datasource';\n static readonly MODEL = 'model';\n\n static readonly SCHEME_SET = new Set<string>([\n this.CONFIGURATION,\n this.COMPONENT,\n this.CONTROLLER,\n this.SERVICE,\n this.REPOSITORY,\n this.DATASOURCE,\n this.MODEL,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** The `format` of `getAuthorizeModelPrincipals` and `getAuthorizeModelSettings`: ARRAY or RECORD. */\nexport class AuthorizeModelFormats {\n static readonly ARRAY = 'array';\n static readonly RECORD = 'record';\n\n static readonly SCHEME_SET = new Set<string>([this.ARRAY, this.RECORD]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid authorize model format values. */\nexport type TAuthorizeModelFormat = TConstValue<typeof AuthorizeModelFormats>;\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/helpers/inversion/common/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,iIAAiI;AACjI,MAAM,OAAO,aAAc,SAAQ,UAAU;aAC3B,kBAAa,GAAG,eAAe,CAAC;aAChC,cAAS,GAAG,WAAW,CAAC;aACxB,eAAU,GAAG,YAAY,CAAC;aAC1B,YAAO,GAAG,SAAS,CAAC;aACpB,eAAU,GAAG,YAAY,CAAC;aAC1B,eAAU,GAAG,YAAY,CAAC;aAC1B,UAAK,GAAG,OAAO,CAAC;;AAGlC,sGAAsG;AACtG,MAAM,OAAO,qBAAsB,SAAQ,UAAU;aACnC,UAAK,GAAG,OAAO,CAAC;aAChB,WAAM,GAAG,QAAQ,CAAC","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers/common';\nimport { ConstClass } from '@venizia/ignis-helpers/common';\n\n/** What a decorated class is to the application - the one fact the artifact generator and the registration methods both read. */\nexport class ArtifactTypes extends ConstClass {\n static readonly CONFIGURATION = 'configuration';\n static readonly COMPONENT = 'component';\n static readonly CONTROLLER = 'controller';\n static readonly SERVICE = 'service';\n static readonly REPOSITORY = 'repository';\n static readonly DATASOURCE = 'datasource';\n static readonly MODEL = 'model';\n}\n\n/** The `format` of `getAuthorizeModelPrincipals` and `getAuthorizeModelSettings`: ARRAY or RECORD. */\nexport class AuthorizeModelFormats extends ConstClass {\n static readonly ARRAY = 'array';\n static readonly RECORD = 'record';\n}\n\n/** Valid authorize model format values. */\nexport type TAuthorizeModelFormat = TConstValue<typeof AuthorizeModelFormats>;\n"]}
@@ -172,7 +172,7 @@ export interface IModelProperties {
172
172
  /**
173
173
  * Properties the server fills on every write, which a generated create or update body leaves out.
174
174
  *
175
- * @default AuditFields.SCHEME_SET
175
+ * @default AuditFields.values()
176
176
  */
177
177
  stamped?: ReadonlyArray<string> | ReadonlySet<string>;
178
178
  }
@@ -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]: 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
+ {"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.values()\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@venizia/ignis-kernel",
3
- "version": "0.5.0-2",
3
+ "version": "0.5.0-4",
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",
@@ -73,14 +73,14 @@
73
73
  "force-update": "sh ../../scripts/build/force-update.sh"
74
74
  },
75
75
  "dependencies": {
76
- "@venizia/ignis-filter": "0.5.0-0",
77
- "@venizia/ignis-helpers": "0.5.0-1",
78
- "@venizia/ignis-inversion": "0.5.0-0",
76
+ "@venizia/ignis-filter": "0.5.0-1",
77
+ "@venizia/ignis-helpers": "0.5.0-3",
78
+ "@venizia/ignis-inversion": "0.5.0-1",
79
79
  "reflect-metadata": "^0.2.2"
80
80
  },
81
81
  "devDependencies": {
82
82
  "@types/bun": "^1.4.5",
83
- "@venizia/dev-configs": "0.5.0-2",
83
+ "@venizia/dev-configs": "0.5.0-6",
84
84
  "casbin": "^5.51.1",
85
85
  "eslint": "^10.13.0",
86
86
  "oxlint": "1.89.0",