@venizia/ignis-kernel 0.4.8-5 → 0.4.8-7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/esm/base/applications/common/types/application.d.ts +3 -4
  2. package/dist/esm/base/applications/common/types/application.js.map +1 -1
  3. package/dist/esm/base/applications/rest.d.ts +13 -7
  4. package/dist/esm/base/applications/rest.js +52 -7
  5. package/dist/esm/base/applications/rest.js.map +1 -1
  6. package/dist/esm/base/applications/router-factory.d.ts +27 -0
  7. package/dist/esm/base/applications/router-factory.js +28 -0
  8. package/dist/esm/base/applications/router-factory.js.map +1 -0
  9. package/dist/esm/base/auth/authenticate/common/types/jwt.d.ts +6 -4
  10. package/dist/esm/base/auth/authenticate/common/types/jwt.js.map +1 -1
  11. package/dist/esm/base/auth/authenticate/common/types/service.d.ts +1 -1
  12. package/dist/esm/base/auth/authenticate/common/types/service.js.map +1 -1
  13. package/dist/esm/base/controllers/factory/controller.js +5 -2
  14. package/dist/esm/base/controllers/factory/controller.js.map +1 -1
  15. package/dist/esm/base/controllers/factory/crud/readable.js +2 -1
  16. package/dist/esm/base/controllers/factory/crud/readable.js.map +1 -1
  17. package/dist/esm/base/controllers/factory/definition.d.ts +3 -3
  18. package/dist/esm/base/controllers/factory/definition.js +3 -3
  19. package/dist/esm/base/controllers/factory/definition.js.map +1 -1
  20. package/dist/esm/base/controllers/rest/abstract.js +5 -0
  21. package/dist/esm/base/controllers/rest/abstract.js.map +1 -1
  22. package/dist/esm/base/datasources/abstract.d.ts +69 -2
  23. package/dist/esm/base/datasources/abstract.js +186 -1
  24. package/dist/esm/base/datasources/abstract.js.map +1 -1
  25. package/dist/esm/base/datasources/common/types.d.ts +60 -1
  26. package/dist/esm/base/datasources/common/types.js +14 -0
  27. package/dist/esm/base/datasources/common/types.js.map +1 -1
  28. package/dist/esm/base/datasources/opening-handles.d.ts +8 -0
  29. package/dist/esm/base/datasources/opening-handles.js +8 -0
  30. package/dist/esm/base/datasources/opening-handles.js.map +1 -0
  31. package/dist/esm/base/metadata/persistents.js +20 -1
  32. package/dist/esm/base/metadata/persistents.js.map +1 -1
  33. package/dist/esm/base/middlewares/app-error/app-error.middleware.js +12 -1
  34. package/dist/esm/base/middlewares/app-error/app-error.middleware.js.map +1 -1
  35. package/dist/esm/base/middlewares/app-error/common/types.d.ts +10 -8
  36. package/dist/esm/base/middlewares/app-error/common/types.js.map +1 -1
  37. package/dist/esm/base/middlewares/app-error/database.handler.js +14 -14
  38. package/dist/esm/base/middlewares/app-error/database.handler.js.map +1 -1
  39. package/dist/esm/base/middlewares/app-error/index.d.ts +2 -0
  40. package/dist/esm/base/middlewares/app-error/index.js +1 -0
  41. package/dist/esm/base/middlewares/app-error/index.js.map +1 -1
  42. package/dist/esm/base/middlewares/app-error/postgres-errors.d.ts +20 -0
  43. package/dist/esm/base/middlewares/app-error/postgres-errors.js +74 -0
  44. package/dist/esm/base/middlewares/app-error/postgres-errors.js.map +1 -0
  45. package/dist/esm/base/models/base.d.ts +0 -2
  46. package/dist/esm/base/models/base.js +0 -4
  47. package/dist/esm/base/models/base.js.map +1 -1
  48. package/dist/esm/base/models/common/constants.d.ts +9 -0
  49. package/dist/esm/base/models/common/constants.js +15 -0
  50. package/dist/esm/base/models/common/constants.js.map +1 -1
  51. package/dist/esm/base/repositories/common/request-filter-guard.d.ts +52 -2
  52. package/dist/esm/base/repositories/common/request-filter-guard.js +110 -25
  53. package/dist/esm/base/repositories/common/request-filter-guard.js.map +1 -1
  54. package/dist/esm/base/repositories/core/abstract.js +1 -1
  55. package/dist/esm/base/repositories/core/abstract.js.map +1 -1
  56. package/dist/esm/common/statuses/common.d.ts +8 -1
  57. package/dist/esm/common/statuses/common.js +24 -8
  58. package/dist/esm/common/statuses/common.js.map +1 -1
  59. package/dist/esm/helpers/inversion/common/types/model.d.ts +12 -2
  60. package/dist/esm/helpers/inversion/common/types/model.js.map +1 -1
  61. package/dist/esm/helpers/inversion/common/types/persistence.d.ts +3 -1
  62. package/dist/esm/helpers/inversion/common/types/persistence.js.map +1 -1
  63. package/dist/esm/repository.d.ts +3 -1
  64. package/dist/esm/repository.js +3 -1
  65. package/dist/esm/repository.js.map +1 -1
  66. package/dist/esm/statuses.d.ts +8 -0
  67. package/dist/esm/statuses.js +8 -0
  68. package/dist/esm/statuses.js.map +1 -0
  69. package/package.json +9 -5
@@ -10,6 +10,15 @@ export declare class SchemaTypes {
10
10
  }
11
11
  /** Valid `SchemaTypes` values. */
12
12
  export type TSchemaType = TConstValue<typeof SchemaTypes>;
13
+ /** The keys a write stamps, which a generated create or update body leaves out by default (`@model` `settings.properties.stamped`). */
14
+ export declare class AuditFields {
15
+ static readonly CREATED_BY = "createdBy";
16
+ static readonly MODIFIED_BY = "modifiedBy";
17
+ static readonly CREATED_AT = "createdAt";
18
+ static readonly MODIFIED_AT = "modifiedAt";
19
+ static readonly DELETED_AT = "deletedAt";
20
+ static readonly SCHEME_SET: Set<string>;
21
+ }
13
22
  /** What `@model` declares. Only ENTITY (a table-backed model) exists; `type` may be left out. */
14
23
  export declare class ModelTypes {
15
24
  static readonly ENTITY = "entity";
@@ -9,6 +9,21 @@ export class SchemaTypes {
9
9
  return this.SCHEME_SET.has(input);
10
10
  }
11
11
  }
12
+ /** The keys a write stamps, which a generated create or update body leaves out by default (`@model` `settings.properties.stamped`). */
13
+ export class AuditFields {
14
+ static { this.CREATED_BY = 'createdBy'; }
15
+ static { this.MODIFIED_BY = 'modifiedBy'; }
16
+ static { this.CREATED_AT = 'createdAt'; }
17
+ static { this.MODIFIED_AT = 'modifiedAt'; }
18
+ static { this.DELETED_AT = 'deletedAt'; }
19
+ static { this.SCHEME_SET = new Set([
20
+ this.CREATED_BY,
21
+ this.MODIFIED_BY,
22
+ this.CREATED_AT,
23
+ this.MODIFIED_AT,
24
+ this.DELETED_AT,
25
+ ]); }
26
+ }
12
27
  /** What `@model` declares. Only ENTITY (a table-backed model) exists; `type` may be left out. */
13
28
  export class ModelTypes {
14
29
  static { this.ENTITY = 'entity'; }
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/base/models/common/constants.ts"],"names":[],"mappings":"AAEA,6GAA6G;AAC7G,MAAM,OAAO,WAAW;aACN,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,YAAO,GAAG,SAAS,CAAC;aAEpB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAE5F,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAMH,iGAAiG;AACjG,MAAM,OAAO,UAAU;aACL,WAAM,GAAG,QAAQ,CAAC;aAClB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAEpD,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAMH,2FAA2F;AAC3F,MAAM,OAAO,aAAa;aACR,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAEzE,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/** The schema variants an entity can produce (`getSchema({ type })`): select, create, update and execute. */\nexport class SchemaTypes {\n static readonly SELECT = 'select';\n static readonly UPDATE = 'update';\n static readonly CREATE = 'create';\n static readonly EXECUTE = 'execute';\n\n static readonly SCHEME_SET = new Set([this.SELECT, this.UPDATE, this.CREATE, this.EXECUTE]);\n\n static isValid(input: string): input is TSchemaType {\n return this.SCHEME_SET.has(input);\n }\n}\n\n/** Valid `SchemaTypes` values. */\nexport type TSchemaType = TConstValue<typeof SchemaTypes>;\n\n/** What `@model` declares. Only ENTITY (a table-backed model) exists; `type` may be left out. */\nexport class ModelTypes {\n static readonly ENTITY = 'entity';\n static readonly SCHEME_SET = new Set([this.ENTITY]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid model type values. */\nexport type TModelType = TConstValue<typeof ModelTypes>;\n\n/** The path-param id shape an entity family resolves to (`AbstractEntity.getIdType()`). */\nexport class IdSchemaTypes {\n static readonly NUMBER = 'number';\n static readonly STRING = 'string';\n\n static readonly SCHEME_SET = new Set<string>([this.NUMBER, this.STRING]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid id schema type values. */\nexport type TIdSchemaType = TConstValue<typeof IdSchemaTypes>;\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/base/models/common/constants.ts"],"names":[],"mappings":"AAEA,6GAA6G;AAC7G,MAAM,OAAO,WAAW;aACN,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,YAAO,GAAG,SAAS,CAAC;aAEpB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAE5F,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAMH,uIAAuI;AACvI,MAAM,OAAO,WAAW;aACN,eAAU,GAAG,WAAW,CAAC;aACzB,gBAAW,GAAG,YAAY,CAAC;aAC3B,eAAU,GAAG,WAAW,CAAC;aACzB,gBAAW,GAAG,YAAY,CAAC;aAC3B,eAAU,GAAG,WAAW,CAAC;aAEzB,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,UAAU;QACf,IAAI,CAAC,WAAW;QAChB,IAAI,CAAC,UAAU;QACf,IAAI,CAAC,WAAW;QAChB,IAAI,CAAC,UAAU;KAChB,CAAC,CAAC;;AAGL,iGAAiG;AACjG,MAAM,OAAO,UAAU;aACL,WAAM,GAAG,QAAQ,CAAC;aAClB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAEpD,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAMH,2FAA2F;AAC3F,MAAM,OAAO,aAAa;aACR,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAEzE,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/** The schema variants an entity can produce (`getSchema({ type })`): select, create, update and execute. */\nexport class SchemaTypes {\n static readonly SELECT = 'select';\n static readonly UPDATE = 'update';\n static readonly CREATE = 'create';\n static readonly EXECUTE = 'execute';\n\n static readonly SCHEME_SET = new Set([this.SELECT, this.UPDATE, this.CREATE, this.EXECUTE]);\n\n static isValid(input: string): input is TSchemaType {\n return this.SCHEME_SET.has(input);\n }\n}\n\n/** Valid `SchemaTypes` values. */\nexport type TSchemaType = TConstValue<typeof SchemaTypes>;\n\n/** The keys a write stamps, which a generated create or update body leaves out by default (`@model` `settings.properties.stamped`). */\nexport class AuditFields {\n static readonly CREATED_BY = 'createdBy';\n static readonly MODIFIED_BY = 'modifiedBy';\n static readonly CREATED_AT = 'createdAt';\n static readonly MODIFIED_AT = 'modifiedAt';\n static readonly DELETED_AT = 'deletedAt';\n\n static readonly SCHEME_SET = new Set<string>([\n this.CREATED_BY,\n this.MODIFIED_BY,\n this.CREATED_AT,\n this.MODIFIED_AT,\n this.DELETED_AT,\n ]);\n}\n\n/** What `@model` declares. Only ENTITY (a table-backed model) exists; `type` may be left out. */\nexport class ModelTypes {\n static readonly ENTITY = 'entity';\n static readonly SCHEME_SET = new Set([this.ENTITY]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid model type values. */\nexport type TModelType = TConstValue<typeof ModelTypes>;\n\n/** The path-param id shape an entity family resolves to (`AbstractEntity.getIdType()`). */\nexport class IdSchemaTypes {\n static readonly NUMBER = 'number';\n static readonly STRING = 'string';\n\n static readonly SCHEME_SET = new Set<string>([this.NUMBER, this.STRING]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid id schema type values. */\nexport type TIdSchemaType = TConstValue<typeof IdSchemaTypes>;\n"]}
@@ -1,15 +1,40 @@
1
- /** What a request filter holds that names fields: `where`, `order` and the `include` scopes. */
1
+ import type { TConstValue } from '@venizia/ignis-helpers/common';
2
+ /** What a request filter holds that a query reads: `where`, `order`, the `include` scopes, and the `fields` that can decide the order it reads them in. */
2
3
  export interface IRequestFilterShape {
3
4
  where?: unknown;
4
5
  order?: unknown;
5
6
  include?: unknown;
7
+ fields?: unknown;
6
8
  }
7
9
  /** Which part of a filter a key came from: the refusal reads like the query's own refusal of an unknown column of that part. */
8
10
  export type TRequestFilterKeyKind = 'where' | 'order';
11
+ /** The parts of a request filter a query reads, one at a time, in an order the query decides. */
12
+ export declare class RequestFilterParts {
13
+ static readonly WHERE = "where";
14
+ static readonly ORDER = "order";
15
+ static readonly INCLUDE = "include";
16
+ }
17
+ /** A part of a request filter: `where`, `order` or `include`. */
18
+ export type TRequestFilterPart = TConstValue<typeof RequestFilterParts>;
19
+ /** One piece of a request filter, as the query reads it on its own: a `where` of one key, one `order` entry, or one `include` entry. */
20
+ export type TRequestFilterPiece = {
21
+ part: typeof RequestFilterParts.WHERE;
22
+ value: Record<string, unknown>;
23
+ } | {
24
+ part: typeof RequestFilterParts.ORDER;
25
+ value: string;
26
+ } | {
27
+ part: typeof RequestFilterParts.INCLUDE;
28
+ value: unknown;
29
+ };
9
30
  /**
10
31
  * How one model judges a key of a request filter. The repository of a model supplies it, so the judgment reads a key the way
11
32
  * that model's own query does (a relational JSON path names its first part, a search field is a dotted name), and a refusal
12
33
  * is the error that query gives for a column or field that does not exist.
34
+ *
35
+ * A filter that names a hidden field is refused with the first refusal the query itself would meet if the hidden name were
36
+ * missing: `readOrder` gives the order the query reads the parts in, `filterRefusal` and `queryRefusal` the errors it throws
37
+ * on its own before that point. Without them the parts are read `where`, `order`, `include`, and nothing else is refused.
13
38
  */
14
39
  export interface IRequestFilterJudge {
15
40
  /** Whether the key reaches a field the model hides. */
@@ -26,6 +51,22 @@ export interface IRequestFilterJudge {
26
51
  relation?(opts: {
27
52
  relation: string;
28
53
  }): IRequestFilterJudge | undefined;
54
+ /** The parts of `filter` in the order this model's query reads them. */
55
+ readOrder?(opts: {
56
+ filter: IRequestFilterShape;
57
+ }): ReadonlyArray<TRequestFilterPart>;
58
+ /** The error the query throws for `filter` as a whole before it reads any key of it, or `undefined`. */
59
+ filterRefusal?(opts: {
60
+ filter: IRequestFilterShape;
61
+ tableName: string;
62
+ }): Error | undefined;
63
+ /**
64
+ * The error the query throws for one piece of a filter on its own, or `undefined` when it reads the piece. A piece is a
65
+ * `where` of one key (`{ [key]: value }`), one `order` entry, or one `include` entry.
66
+ */
67
+ queryRefusal?(opts: TRequestFilterPiece & {
68
+ tableName: string;
69
+ }): Error | undefined;
29
70
  }
30
71
  /**
31
72
  * A filter that comes from a request is not allowed to name a field the model hides. Hidden fields are never returned, but a
@@ -57,12 +98,21 @@ export declare class RequestFilterGuard {
57
98
  }): void;
58
99
  /**
59
100
  * Refuses a filter that names a hidden field in its `where`, its `order`, or the `scope` of any `include`, each level
60
- * judged by the model it reads (`judge.relation` answers it).
101
+ * judged by the model it reads (`judge.relation` answers it). The parts are read in the order the query reads them, and a
102
+ * filter that the query refuses for another reason before it meets the hidden field gets that refusal instead, so the answer
103
+ * is the one the same filter gets with a missing name in place of the hidden one. A filter that names no hidden field is
104
+ * left to the query.
61
105
  */
62
106
  static assertFilter(opts: {
63
107
  filter?: IRequestFilterShape;
64
108
  judge: IRequestFilterJudge;
65
109
  tableName: string;
66
110
  }): void;
111
+ /** Throws for a hidden key: the refusal met before it, or the hidden key's own. Otherwise keeps the query's refusal of the piece when it is the first. */
112
+ private static visitKey;
113
+ private static walkFilter;
114
+ private static walkWhere;
115
+ private static walkOrder;
116
+ private static walkInclude;
67
117
  }
68
118
  //# sourceMappingURL=request-filter-guard.d.ts.map
@@ -1,6 +1,17 @@
1
1
  import { HTTP } from '@venizia/ignis-helpers/common';
2
2
  import { getError } from '@venizia/ignis-helpers/core';
3
3
  import { QueryOperators, Sorts } from '@venizia/ignis-filter';
4
+ /** The parts of a request filter a query reads, one at a time, in an order the query decides. */
5
+ export class RequestFilterParts {
6
+ static { this.WHERE = 'where'; }
7
+ static { this.ORDER = 'order'; }
8
+ static { this.INCLUDE = 'include'; }
9
+ }
10
+ const DEFAULT_READ_ORDER = [
11
+ RequestFilterParts.WHERE,
12
+ RequestFilterParts.ORDER,
13
+ RequestFilterParts.INCLUDE,
14
+ ];
4
15
  /**
5
16
  * A filter that comes from a request is not allowed to name a field the model hides. Hidden fields are never returned, but a
6
17
  * `where` or an `order` on one reveals its value one question at a time. The check runs where a request enters
@@ -27,7 +38,58 @@ export class RequestFilterGuard {
27
38
  }
28
39
  /** Refuses a `where` that names a hidden field, at any depth of `and` and `or`. */
29
40
  static assertWhere(opts) {
30
- const { where, judge, tableName } = opts;
41
+ RequestFilterGuard.walkWhere({ ...opts, walk: {} });
42
+ }
43
+ /** Refuses an `order` that names a hidden field (a string or a list of `'field DIRECTION'` entries), reading each entry as the query does. */
44
+ static assertOrder(opts) {
45
+ RequestFilterGuard.walkOrder({ ...opts, walk: {} });
46
+ }
47
+ /**
48
+ * Refuses a filter that names a hidden field in its `where`, its `order`, or the `scope` of any `include`, each level
49
+ * judged by the model it reads (`judge.relation` answers it). The parts are read in the order the query reads them, and a
50
+ * filter that the query refuses for another reason before it meets the hidden field gets that refusal instead, so the answer
51
+ * is the one the same filter gets with a missing name in place of the hidden one. A filter that names no hidden field is
52
+ * left to the query.
53
+ */
54
+ static assertFilter(opts) {
55
+ RequestFilterGuard.walkFilter({ ...opts, walk: {} });
56
+ }
57
+ /** Throws for a hidden key: the refusal met before it, or the hidden key's own. Otherwise keeps the query's refusal of the piece when it is the first. */
58
+ static visitKey(opts) {
59
+ const { walk, judge, tableName, key, piece } = opts;
60
+ if (judge.isHidden({ key })) {
61
+ throw walk.refusal ?? judge.refuse({ kind: piece.part, key, tableName });
62
+ }
63
+ walk.refusal ??= judge.queryRefusal?.({ ...piece, tableName });
64
+ }
65
+ static walkFilter(opts) {
66
+ const { filter, judge, tableName, walk } = opts;
67
+ if (typeof filter !== 'object' || filter === null) {
68
+ return;
69
+ }
70
+ walk.refusal ??= judge.filterRefusal?.({ filter, tableName });
71
+ for (const part of judge.readOrder?.({ filter }) ?? DEFAULT_READ_ORDER) {
72
+ switch (part) {
73
+ case RequestFilterParts.WHERE: {
74
+ RequestFilterGuard.walkWhere({ where: filter.where, judge, tableName, walk });
75
+ break;
76
+ }
77
+ case RequestFilterParts.ORDER: {
78
+ RequestFilterGuard.walkOrder({ order: filter.order, judge, tableName, walk });
79
+ break;
80
+ }
81
+ case RequestFilterParts.INCLUDE: {
82
+ RequestFilterGuard.walkInclude({ include: filter.include, judge, tableName, walk });
83
+ break;
84
+ }
85
+ default: {
86
+ break;
87
+ }
88
+ }
89
+ }
90
+ }
91
+ static walkWhere(opts) {
92
+ const { where, judge, tableName, walk } = opts;
31
93
  if (typeof where !== 'object' || where === null) {
32
94
  return;
33
95
  }
@@ -35,18 +97,21 @@ export class RequestFilterGuard {
35
97
  const value = where[key];
36
98
  if (QueryOperators.LOGICAL_GROUP_OPERATORS.has(key)) {
37
99
  for (const branch of Array.isArray(value) ? value : [value]) {
38
- RequestFilterGuard.assertWhere({ where: branch, judge, tableName });
100
+ RequestFilterGuard.walkWhere({ where: branch, judge, tableName, walk });
39
101
  }
40
102
  continue;
41
103
  }
42
- if (judge.isHidden({ key })) {
43
- throw judge.refuse({ kind: 'where', key, tableName });
44
- }
104
+ RequestFilterGuard.visitKey({
105
+ walk,
106
+ judge,
107
+ tableName,
108
+ key,
109
+ piece: { part: RequestFilterParts.WHERE, value: { [key]: value } },
110
+ });
45
111
  }
46
112
  }
47
- /** Refuses an `order` that names a hidden field (a string or a list of `'field DIRECTION'` entries), reading each entry as the query does. */
48
- static assertOrder(opts) {
49
- const { order, judge, tableName } = opts;
113
+ static walkOrder(opts) {
114
+ const { order, judge, tableName, walk } = opts;
50
115
  if (order === undefined || order === null) {
51
116
  return;
52
117
  }
@@ -54,27 +119,42 @@ export class RequestFilterGuard {
54
119
  if (typeof entry !== 'string') {
55
120
  continue;
56
121
  }
57
- const { field } = Sorts.parseEntry({ entry });
58
- if (judge.isHidden({ key: field })) {
59
- throw judge.refuse({ kind: 'order', key: field, tableName });
122
+ let field;
123
+ // A judge with `queryRefusal` reads order entries with this parser, so an entry it cannot parse is the query's own
124
+ // refusal and later entries are still judged. Any other judge's query may read the entry differently: refuse it here.
125
+ try {
126
+ field = Sorts.parseEntry({ entry }).field;
60
127
  }
128
+ catch (error) {
129
+ if (!judge.queryRefusal) {
130
+ throw error;
131
+ }
132
+ walk.refusal ??=
133
+ error instanceof Error
134
+ ? error
135
+ : getError({ message: 'A value that is not an Error was thrown', cause: error });
136
+ continue;
137
+ }
138
+ RequestFilterGuard.visitKey({
139
+ walk,
140
+ judge,
141
+ tableName,
142
+ key: field,
143
+ piece: { part: RequestFilterParts.ORDER, value: entry },
144
+ });
61
145
  }
62
146
  }
63
- /**
64
- * Refuses a filter that names a hidden field in its `where`, its `order`, or the `scope` of any `include`, each level
65
- * judged by the model it reads (`judge.relation` answers it).
66
- */
67
- static assertFilter(opts) {
68
- const { filter, judge, tableName } = opts;
69
- if (typeof filter !== 'object' || filter === null) {
70
- return;
71
- }
72
- RequestFilterGuard.assertWhere({ where: filter.where, judge, tableName });
73
- RequestFilterGuard.assertOrder({ order: filter.order, judge, tableName });
74
- if (!Array.isArray(filter.include)) {
147
+ static walkInclude(opts) {
148
+ const { include, judge, tableName, walk } = opts;
149
+ if (!Array.isArray(include)) {
75
150
  return;
76
151
  }
77
- for (const entry of filter.include) {
152
+ for (const entry of include) {
153
+ walk.refusal ??= judge.queryRefusal?.({
154
+ part: RequestFilterParts.INCLUDE,
155
+ value: entry,
156
+ tableName,
157
+ });
78
158
  if (typeof entry !== 'object' || entry === null) {
79
159
  continue;
80
160
  }
@@ -87,7 +167,12 @@ export class RequestFilterGuard {
87
167
  if (relationJudge === undefined) {
88
168
  continue;
89
169
  }
90
- RequestFilterGuard.assertFilter({ filter: scope, judge: relationJudge, tableName: relation });
170
+ RequestFilterGuard.walkFilter({
171
+ filter: scope,
172
+ judge: relationJudge,
173
+ tableName: relation,
174
+ walk,
175
+ });
91
176
  }
92
177
  }
93
178
  }
@@ -1 +1 @@
1
- {"version":3,"file":"request-filter-guard.js","sourceRoot":"","sources":["../../../../../src/base/repositories/common/request-filter-guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,Q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E,CAAC;gBAChC,SAAS;YACX,CAAC;YAED,kBAAkB,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChG,CAAC;IACH,CAAC;CACF","sourcesContent":["import { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { QueryOperators, Sorts } from '@venizia/ignis-filter';\n\n/** What a request filter holds that names fields: `where`, `order` and the `include` scopes. */\nexport interface IRequestFilterShape {\n where?: unknown;\n order?: unknown;\n include?: unknown;\n}\n\n/** Which part of a filter a key came from: the refusal reads like the query's own refusal of an unknown column of that part. */\nexport type TRequestFilterKeyKind = 'where' | 'order';\n\n/**\n * How one model judges a key of a request filter. The repository of a model supplies it, so the judgment reads a key the way\n * that model's own query does (a relational JSON path names its first part, a search field is a dotted name), and a refusal\n * is the error that query gives for a column or field that does not exist.\n */\nexport interface IRequestFilterJudge {\n /** Whether the key reaches a field the model hides. */\n isHidden(opts: { key: string }): boolean;\n\n /** The error to throw for a key that is hidden: the one an unknown column or field gets, so a caller cannot tell them apart. */\n refuse(opts: { kind: TRequestFilterKeyKind; key: string; tableName: string }): Error;\n\n /** The judge of the model a relation of this model points to; `undefined` when the relation is unknown (the query refuses it). A nested include is judged by the relation judge's own `relation`. */\n relation?(opts: { relation: string }): IRequestFilterJudge | undefined;\n}\n\n/**\n * A filter that comes from a request is not allowed to name a field the model hides. Hidden fields are never returned, but a\n * `where` or an `order` on one reveals its value one question at a time. The check runs where a request enters\n * (the generated controllers), never in the repository's own verbs, so server code can still filter and sort on a hidden field.\n */\nexport class RequestFilterGuard {\n /** The names of `hidden` a dotted key reaches: the key is one, a dotted prefix of one, or has one as its dotted prefix (`meta` and `meta.pin.x` both reach `meta.pin`). */\n static isHiddenByName(opts: { key: string; hidden: ReadonlySet<string> }): boolean {\n const { key, hidden } = opts;\n\n for (const name of hidden) {\n if (key === name || key.startsWith(`${name}.`) || name.startsWith(`${key}.`)) {\n return true;\n }\n }\n\n return false;\n }\n\n /** The refusal when a model has no query error of its own to borrow: a 400 `Column NOT FOUND`. */\n static columnNotFound(opts: { scope: string; key: string }): Error {\n const quoted = JSON.stringify(opts.key).replace(\n /[\\u007f-\\u009f\\u2028\\u2029]/g,\n (character) => `\\\\u${character.charCodeAt(0).toString(16).padStart(4, '0')}`,\n );\n\n return getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[${opts.scope}] Column NOT FOUND | key: ${quoted}`,\n });\n }\n\n /** Refuses a `where` that names a hidden field, at any depth of `and` and `or`. */\n static assertWhere(opts: {\n where?: unknown;\n judge: IRequestFilterJudge;\n tableName: string;\n }): void {\n const { where, judge, tableName } = opts;\n\n if (typeof where !== 'object' || where === null) {\n return;\n }\n\n for (const key of Object.keys(where)) {\n const value = (where as Record<string, unknown>)[key];\n\n if (QueryOperators.LOGICAL_GROUP_OPERATORS.has(key)) {\n for (const branch of Array.isArray(value) ? value : [value]) {\n RequestFilterGuard.assertWhere({ where: branch, judge, tableName });\n }\n\n continue;\n }\n\n if (judge.isHidden({ key })) {\n throw judge.refuse({ kind: 'where', key, tableName });\n }\n }\n }\n\n /** Refuses an `order` that names a hidden field (a string or a list of `'field DIRECTION'` entries), reading each entry as the query does. */\n static assertOrder(opts: {\n order?: unknown;\n judge: IRequestFilterJudge;\n tableName: string;\n }): void {\n const { order, judge, tableName } = opts;\n\n if (order === undefined || order === null) {\n return;\n }\n\n for (const entry of Array.isArray(order) ? order : [order]) {\n if (typeof entry !== 'string') {\n continue;\n }\n\n const { field } = Sorts.parseEntry({ entry });\n\n if (judge.isHidden({ key: field })) {\n throw judge.refuse({ kind: 'order', key: field, tableName });\n }\n }\n }\n\n /**\n * Refuses a filter that names a hidden field in its `where`, its `order`, or the `scope` of any `include`, each level\n * judged by the model it reads (`judge.relation` answers it).\n */\n static assertFilter(opts: {\n filter?: IRequestFilterShape;\n judge: IRequestFilterJudge;\n tableName: string;\n }): void {\n const { filter, judge, tableName } = opts;\n\n if (typeof filter !== 'object' || filter === null) {\n return;\n }\n\n RequestFilterGuard.assertWhere({ where: filter.where, judge, tableName });\n RequestFilterGuard.assertOrder({ order: filter.order, judge, tableName });\n\n if (!Array.isArray(filter.include)) {\n return;\n }\n\n for (const entry of filter.include) {\n if (typeof entry !== 'object' || entry === null) {\n continue;\n }\n\n const { relation, scope } = entry as { relation?: unknown; scope?: IRequestFilterShape };\n\n if (typeof relation !== 'string' || scope === undefined) {\n continue;\n }\n\n const relationJudge = judge.relation?.({ relation });\n\n // An unknown relation is refused by the query itself; here only a known one has a model to judge by.\n if (relationJudge === undefined) {\n continue;\n }\n\n RequestFilterGuard.assertFilter({ filter: scope, judge: relationJudge, tableName: relation });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"request-filter-guard.js","sourceRoot":"","sources":["../../../../../src/base/repositories/common/request-filter-guard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAa9D,iGAAiG;AACjG,MAAM,OAAO,kBAAkB;aACb,UAAK,GAAG,OAAO,CAAC;aAChB,UAAK,GAAG,OAAO,CAAC;aAChB,YAAO,GAAG,SAAS,CAAC;;AAiDtC,MAAM,kBAAkB,GAAsC;IAC5D,kBAAkB,CAAC,KAAK;IACxB,kBAAkB,CAAC,KAAK;IACxB,kBAAkB,CAAC,OAAO;CAC3B,CAAC;AAEF;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IAC7B,2KAA2K;IAC3K,MAAM,CAAC,cAAc,CAAC,IAAkD;QACtE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAE7B,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;YAC1B,IAAI,GAAG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M,CAAC,WAAW,CAAC,IAK1B;QACC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAEjD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,OAAO;QACT,CAAC;QAED,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,YAAY,EAAE,CAAC;gBACpC,IAAI,EAAE,kBAAkB,CAAC,OAAO;gBAChC,KAAK,EAAE,KAAK;gBACZ,SAAS;aACV,CAAC,CAAC;YAEH,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBAChD,SAAS;YACX,CAAC;YAED,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAA4D,CAAC;YAEzF,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxD,SAAS;YACX,CAAC;YAED,MAAM,aAAa,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;YAErD,qGAAqG;YACrG,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBAChC,SAAS;YACX,CAAC;YAED,kBAAkB,CAAC,UAAU,CAAC;gBAC5B,MAAM,EAAE,KAAK;gBACb,KAAK,EAAE,aAAa;gBACpB,SAAS,EAAE,QAAQ;gBACnB,IAAI;aACL,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers/common';\nimport { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { QueryOperators, Sorts } from '@venizia/ignis-filter';\n\n/** What a request filter holds that a query reads: `where`, `order`, the `include` scopes, and the `fields` that can decide the order it reads them in. */\nexport interface IRequestFilterShape {\n where?: unknown;\n order?: unknown;\n include?: unknown;\n fields?: unknown;\n}\n\n/** Which part of a filter a key came from: the refusal reads like the query's own refusal of an unknown column of that part. */\nexport type TRequestFilterKeyKind = 'where' | 'order';\n\n/** The parts of a request filter a query reads, one at a time, in an order the query decides. */\nexport class RequestFilterParts {\n static readonly WHERE = 'where';\n static readonly ORDER = 'order';\n static readonly INCLUDE = 'include';\n}\n\n/** A part of a request filter: `where`, `order` or `include`. */\nexport type TRequestFilterPart = TConstValue<typeof RequestFilterParts>;\n\n/** One piece of a request filter, as the query reads it on its own: a `where` of one key, one `order` entry, or one `include` entry. */\nexport type TRequestFilterPiece =\n | { part: typeof RequestFilterParts.WHERE; value: Record<string, unknown> }\n | { part: typeof RequestFilterParts.ORDER; value: string }\n | { part: typeof RequestFilterParts.INCLUDE; value: unknown };\n\n/**\n * How one model judges a key of a request filter. The repository of a model supplies it, so the judgment reads a key the way\n * that model's own query does (a relational JSON path names its first part, a search field is a dotted name), and a refusal\n * is the error that query gives for a column or field that does not exist.\n *\n * A filter that names a hidden field is refused with the first refusal the query itself would meet if the hidden name were\n * missing: `readOrder` gives the order the query reads the parts in, `filterRefusal` and `queryRefusal` the errors it throws\n * on its own before that point. Without them the parts are read `where`, `order`, `include`, and nothing else is refused.\n */\nexport interface IRequestFilterJudge {\n /** Whether the key reaches a field the model hides. */\n isHidden(opts: { key: string }): boolean;\n\n /** The error to throw for a key that is hidden: the one an unknown column or field gets, so a caller cannot tell them apart. */\n refuse(opts: { kind: TRequestFilterKeyKind; key: string; tableName: string }): Error;\n\n /** The judge of the model a relation of this model points to; `undefined` when the relation is unknown (the query refuses it). A nested include is judged by the relation judge's own `relation`. */\n relation?(opts: { relation: string }): IRequestFilterJudge | undefined;\n\n /** The parts of `filter` in the order this model's query reads them. */\n readOrder?(opts: { filter: IRequestFilterShape }): ReadonlyArray<TRequestFilterPart>;\n\n /** The error the query throws for `filter` as a whole before it reads any key of it, or `undefined`. */\n filterRefusal?(opts: { filter: IRequestFilterShape; tableName: string }): Error | undefined;\n\n /**\n * The error the query throws for one piece of a filter on its own, or `undefined` when it reads the piece. A piece is a\n * `where` of one key (`{ [key]: value }`), one `order` entry, or one `include` entry.\n */\n queryRefusal?(opts: TRequestFilterPiece & { tableName: string }): Error | undefined;\n}\n\n/** The first refusal a walk of a filter met, before any hidden key. */\ninterface IRequestFilterWalk {\n refusal?: Error;\n}\n\nconst DEFAULT_READ_ORDER: ReadonlyArray<TRequestFilterPart> = [\n RequestFilterParts.WHERE,\n RequestFilterParts.ORDER,\n RequestFilterParts.INCLUDE,\n];\n\n/**\n * A filter that comes from a request is not allowed to name a field the model hides. Hidden fields are never returned, but a\n * `where` or an `order` on one reveals its value one question at a time. The check runs where a request enters\n * (the generated controllers), never in the repository's own verbs, so server code can still filter and sort on a hidden field.\n */\nexport class RequestFilterGuard {\n /** The names of `hidden` a dotted key reaches: the key is one, a dotted prefix of one, or has one as its dotted prefix (`meta` and `meta.pin.x` both reach `meta.pin`). */\n static isHiddenByName(opts: { key: string; hidden: ReadonlySet<string> }): boolean {\n const { key, hidden } = opts;\n\n for (const name of hidden) {\n if (key === name || key.startsWith(`${name}.`) || name.startsWith(`${key}.`)) {\n return true;\n }\n }\n\n return false;\n }\n\n /** The refusal when a model has no query error of its own to borrow: a 400 `Column NOT FOUND`. */\n static columnNotFound(opts: { scope: string; key: string }): Error {\n const quoted = JSON.stringify(opts.key).replace(\n /[\\u007f-\\u009f\\u2028\\u2029]/g,\n (character) => `\\\\u${character.charCodeAt(0).toString(16).padStart(4, '0')}`,\n );\n\n return getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[${opts.scope}] Column NOT FOUND | key: ${quoted}`,\n });\n }\n\n /** Refuses a `where` that names a hidden field, at any depth of `and` and `or`. */\n static assertWhere(opts: {\n where?: unknown;\n judge: IRequestFilterJudge;\n tableName: string;\n }): void {\n RequestFilterGuard.walkWhere({ ...opts, walk: {} });\n }\n\n /** Refuses an `order` that names a hidden field (a string or a list of `'field DIRECTION'` entries), reading each entry as the query does. */\n static assertOrder(opts: {\n order?: unknown;\n judge: IRequestFilterJudge;\n tableName: string;\n }): void {\n RequestFilterGuard.walkOrder({ ...opts, walk: {} });\n }\n\n /**\n * Refuses a filter that names a hidden field in its `where`, its `order`, or the `scope` of any `include`, each level\n * judged by the model it reads (`judge.relation` answers it). The parts are read in the order the query reads them, and a\n * filter that the query refuses for another reason before it meets the hidden field gets that refusal instead, so the answer\n * is the one the same filter gets with a missing name in place of the hidden one. A filter that names no hidden field is\n * left to the query.\n */\n static assertFilter(opts: {\n filter?: IRequestFilterShape;\n judge: IRequestFilterJudge;\n tableName: string;\n }): void {\n RequestFilterGuard.walkFilter({ ...opts, walk: {} });\n }\n\n /** Throws for a hidden key: the refusal met before it, or the hidden key's own. Otherwise keeps the query's refusal of the piece when it is the first. */\n private static visitKey(opts: {\n walk: IRequestFilterWalk;\n judge: IRequestFilterJudge;\n tableName: string;\n key: string;\n piece: Exclude<TRequestFilterPiece, { part: typeof RequestFilterParts.INCLUDE }>;\n }): void {\n const { walk, judge, tableName, key, piece } = opts;\n\n if (judge.isHidden({ key })) {\n throw walk.refusal ?? judge.refuse({ kind: piece.part, key, tableName });\n }\n\n walk.refusal ??= judge.queryRefusal?.({ ...piece, tableName });\n }\n\n private static walkFilter(opts: {\n filter?: IRequestFilterShape;\n judge: IRequestFilterJudge;\n tableName: string;\n walk: IRequestFilterWalk;\n }): void {\n const { filter, judge, tableName, walk } = opts;\n\n if (typeof filter !== 'object' || filter === null) {\n return;\n }\n\n walk.refusal ??= judge.filterRefusal?.({ filter, tableName });\n\n for (const part of judge.readOrder?.({ filter }) ?? DEFAULT_READ_ORDER) {\n switch (part) {\n case RequestFilterParts.WHERE: {\n RequestFilterGuard.walkWhere({ where: filter.where, judge, tableName, walk });\n break;\n }\n case RequestFilterParts.ORDER: {\n RequestFilterGuard.walkOrder({ order: filter.order, judge, tableName, walk });\n break;\n }\n case RequestFilterParts.INCLUDE: {\n RequestFilterGuard.walkInclude({ include: filter.include, judge, tableName, walk });\n break;\n }\n default: {\n break;\n }\n }\n }\n }\n\n private static walkWhere(opts: {\n where?: unknown;\n judge: IRequestFilterJudge;\n tableName: string;\n walk: IRequestFilterWalk;\n }): void {\n const { where, judge, tableName, walk } = opts;\n\n if (typeof where !== 'object' || where === null) {\n return;\n }\n\n for (const key of Object.keys(where)) {\n const value = (where as Record<string, unknown>)[key];\n\n if (QueryOperators.LOGICAL_GROUP_OPERATORS.has(key)) {\n for (const branch of Array.isArray(value) ? value : [value]) {\n RequestFilterGuard.walkWhere({ where: branch, judge, tableName, walk });\n }\n\n continue;\n }\n\n RequestFilterGuard.visitKey({\n walk,\n judge,\n tableName,\n key,\n piece: { part: RequestFilterParts.WHERE, value: { [key]: value } },\n });\n }\n }\n\n private static walkOrder(opts: {\n order?: unknown;\n judge: IRequestFilterJudge;\n tableName: string;\n walk: IRequestFilterWalk;\n }): void {\n const { order, judge, tableName, walk } = opts;\n\n if (order === undefined || order === null) {\n return;\n }\n\n for (const entry of Array.isArray(order) ? order : [order]) {\n if (typeof entry !== 'string') {\n continue;\n }\n\n let field: string;\n\n // A judge with `queryRefusal` reads order entries with this parser, so an entry it cannot parse is the query's own\n // refusal and later entries are still judged. Any other judge's query may read the entry differently: refuse it here.\n try {\n field = Sorts.parseEntry({ entry }).field;\n } catch (error) {\n if (!judge.queryRefusal) {\n throw error;\n }\n\n walk.refusal ??=\n error instanceof Error\n ? error\n : getError({ message: 'A value that is not an Error was thrown', cause: error });\n continue;\n }\n\n RequestFilterGuard.visitKey({\n walk,\n judge,\n tableName,\n key: field,\n piece: { part: RequestFilterParts.ORDER, value: entry },\n });\n }\n }\n\n private static walkInclude(opts: {\n include?: unknown;\n judge: IRequestFilterJudge;\n tableName: string;\n walk: IRequestFilterWalk;\n }): void {\n const { include, judge, tableName, walk } = opts;\n\n if (!Array.isArray(include)) {\n return;\n }\n\n for (const entry of include) {\n walk.refusal ??= judge.queryRefusal?.({\n part: RequestFilterParts.INCLUDE,\n value: entry,\n tableName,\n });\n\n if (typeof entry !== 'object' || entry === null) {\n continue;\n }\n\n const { relation, scope } = entry as { relation?: unknown; scope?: IRequestFilterShape };\n\n if (typeof relation !== 'string' || scope === undefined) {\n continue;\n }\n\n const relationJudge = judge.relation?.({ relation });\n\n // An unknown relation is refused by the query itself; here only a known one has a model to judge by.\n if (relationJudge === undefined) {\n continue;\n }\n\n RequestFilterGuard.walkFilter({\n filter: scope,\n judge: relationJudge,\n tableName: relation,\n walk,\n });\n }\n }\n}\n"]}
@@ -71,7 +71,7 @@ export class AbstractRepository extends BaseHelper {
71
71
  return this._modelSettings;
72
72
  }
73
73
  get hiddenFields() {
74
- return this.modelSettings?.hiddenProperties ?? [];
74
+ return this.modelSettings?.properties?.hidden ?? [];
75
75
  }
76
76
  /**
77
77
  * Refuses (400, `Column NOT FOUND`) a filter that came from a request and names a field the model hides, in its
@@ -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;IAiBlB,YACE,UAA+B,EAC/B,IAIC;QAED,MAAM,SAAS,GACb,IAAI,EAAE,KAAK;YACX,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,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GAAG,IAAI,CAAC;QAEhC,IAAI,OAAO,EAAE,YAAY,KAAK,KAAK,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACjF,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["import type { AbstractDataSource } from '@/base/datasources';\nimport type { AbstractEntity, IdType } from '@/base/models';\nimport type { IModelMetadata } from '@/helpers/inversion';\nimport { MetadataRegistry } from '@/helpers/inversion';\nimport type { TClass, TNullable } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport { ResolverUtility } from '@venizia/ignis-helpers/common';\nimport { RetryBackoffStrategies, RetryHelper, RetryJitterModes } from '@venizia/ignis-helpers/core';\nimport type {\n IExtraOptions,\n IPersistableRepository,\n IWithReadRetry,\n TCount,\n TDataWithRange,\n TFindOneOptions,\n TFindOptions,\n TFindRangeOptions,\n TRepositoryOperationScope,\n} from '../common';\n// The file, not the `../common` barrel: the barrel re-exports the OpenAPI schemas, and this module is\n// on the `./repository` entry, which must load without `@hono/zod-openapi` installed.\nimport {\n DEFAULT_MAX_LIMIT,\n RepositoryErrorCodes,\n RepositoryOperationScopes,\n} from '../common/constants';\nimport { RequestFilterGuard } from '../common/request-filter-guard';\nimport type { IRequestFilterJudge, IRequestFilterShape } from '../common/request-filter-guard';\nimport type {\n TByIdFilter,\n TFields,\n TFilter,\n TInclusion,\n TRow,\n TWhere,\n} from '@venizia/ignis-filter';\n\n/**\n * Engine-neutral repository plumbing - lazy dataSource/entity resolution, class-keyed `@model`\n * settings, operation scope. `TOptions` defaults to `IExtraOptions` so connectors can narrow it\n * while staying assignable to this base.\n */\nexport abstract class AbstractRepository<\n TDataObject extends object,\n TPersistObject extends object = TDataObject,\n TOptions extends IExtraOptions = IExtraOptions,\n>\n extends BaseHelper\n implements IPersistableRepository<TDataObject, TPersistObject, TOptions>\n{\n protected _operationScope: TRepositoryOperationScope;\n\n /** Lazy-resolved on first access if not provided in constructor. */\n protected _dataSource?: AbstractDataSource;\n\n /** Lazy-resolved from @repository metadata on first access. */\n protected _entity?: AbstractEntity;\n\n /**\n * Memoized @model settings for `this.entity`'s class. `null` means not yet resolved - `undefined`\n * is itself a valid resolved value: the model declares no settings.\n */\n private _modelSettings: IModelMetadata['settings'] | null = null;\n\n constructor(\n dataSource?: AbstractDataSource,\n opts?: {\n scope?: string;\n entityClass?: TClass<AbstractEntity>;\n operationScope?: TRepositoryOperationScope;\n },\n ) {\n const scopeName =\n opts?.scope ??\n (opts?.entityClass?.name ? [opts.entityClass.name, 'Repository'].join('') : new.target.name);\n\n super({ scope: scopeName });\n\n this._operationScope = opts?.operationScope ?? RepositoryOperationScopes.READ_ONLY;\n\n if (dataSource) {\n this._dataSource = dataSource;\n }\n\n if (opts?.entityClass) {\n this._entity = new opts.entityClass();\n }\n }\n\n get dataSource(): AbstractDataSource {\n if (!this._dataSource) {\n throw getError({\n message: `[${this.constructor.name}] DataSource not available. Use @repository({ model: YourModel, dataSource: YourDataSource }) or pass dataSource in constructor.`,\n });\n }\n\n return this._dataSource;\n }\n\n set dataSource(value: AbstractDataSource) {\n this._dataSource = value;\n }\n\n /** Auto-resolves from @repository metadata if not explicitly set. */\n get entity(): AbstractEntity {\n this._entity ??= this.resolveEntity();\n\n return this._entity;\n }\n\n set entity(value: AbstractEntity) {\n this._entity = value;\n }\n\n get operationScope(): TRepositoryOperationScope {\n return this._operationScope;\n }\n\n setDataSource(opts: { dataSource: AbstractDataSource }): void {\n this._dataSource = opts.dataSource;\n }\n\n getEntity(): AbstractEntity {\n return this.entity;\n }\n\n /**\n * Resolved `@model` settings for `this.entity`'s class, keyed by Reflect target - not by\n * `entity.name`, which can diverge from the `@model` registry key.\n */\n protected get modelSettings(): IModelMetadata['settings'] {\n if (this._modelSettings !== null) {\n return this._modelSettings;\n }\n\n this._modelSettings = MetadataRegistry.getInstance().getModelMetadata({\n target: this.entity.constructor,\n })?.settings;\n\n return this._modelSettings;\n }\n\n protected get hiddenFields(): string[] {\n return this.modelSettings?.hiddenProperties ?? [];\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 updateAll(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 updateAll<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 /** Alias for updateAll. */\n updateBy(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n 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 updateBy<R = TDataObject>(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: boolean; force?: boolean };\n }): Promise<TCount & { data: TNullable<Array<R>> }> {\n const { data, where, options } = opts;\n\n if (options?.shouldReturn === false) {\n return this.updateAll({ data, where, options: { ...options, shouldReturn: false } });\n }\n\n return this.updateAll<R>({ data, where, options });\n }\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 deleteAll(opts: {\n where?: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract deleteAll<R = TDataObject>(opts: {\n where?: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\n\n /** Alias for deleteAll. */\n deleteBy(opts: {\n where: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n deleteBy<R = TDataObject>(opts: {\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\n deleteBy<R = TDataObject>(opts: {\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: boolean; force?: boolean };\n }): Promise<TCount & { data: TNullable<Array<R>> }> {\n const { where, options } = opts;\n\n if (options?.shouldReturn === false) {\n return this.deleteAll({ where, options: { ...options, shouldReturn: false } });\n }\n\n return this.deleteAll<R>({ where, options });\n }\n}\n"]}
1
+ {"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../../src/base/repositories/core/abstract.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;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;;;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QAED,OAAO,IAAI,CAAC,SAAS,CAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC;IA+BD,QAAQ,CAAkB,IAGzB;QACC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEhC,IAAI,OAAO,EAAE,YAAY,KAAK,KAAK,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACjF,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["import type { AbstractDataSource } from '@/base/datasources';\nimport type { AbstractEntity, IdType } from '@/base/models';\nimport type { IModelMetadata } from '@/helpers/inversion';\nimport { MetadataRegistry } from '@/helpers/inversion';\nimport type { TClass, TNullable } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport { ResolverUtility } from '@venizia/ignis-helpers/common';\nimport { RetryBackoffStrategies, RetryHelper, RetryJitterModes } from '@venizia/ignis-helpers/core';\nimport type {\n IExtraOptions,\n IPersistableRepository,\n IWithReadRetry,\n TCount,\n TDataWithRange,\n TFindOneOptions,\n TFindOptions,\n TFindRangeOptions,\n TRepositoryOperationScope,\n} from '../common';\n// The file, not the `../common` barrel: the barrel re-exports the OpenAPI schemas, and this module is\n// on the `./repository` entry, which must load without `@hono/zod-openapi` installed.\nimport {\n DEFAULT_MAX_LIMIT,\n RepositoryErrorCodes,\n RepositoryOperationScopes,\n} from '../common/constants';\nimport { RequestFilterGuard } from '../common/request-filter-guard';\nimport type { IRequestFilterJudge, IRequestFilterShape } from '../common/request-filter-guard';\nimport type {\n TByIdFilter,\n TFields,\n TFilter,\n TInclusion,\n TRow,\n TWhere,\n} from '@venizia/ignis-filter';\n\n/**\n * Engine-neutral repository plumbing - lazy dataSource/entity resolution, class-keyed `@model`\n * settings, operation scope. `TOptions` defaults to `IExtraOptions` so connectors can narrow it\n * while staying assignable to this base.\n */\nexport abstract class AbstractRepository<\n TDataObject extends object,\n TPersistObject extends object = TDataObject,\n TOptions extends IExtraOptions = IExtraOptions,\n>\n extends BaseHelper\n implements IPersistableRepository<TDataObject, TPersistObject, TOptions>\n{\n protected _operationScope: TRepositoryOperationScope;\n\n /** Lazy-resolved on first access if not provided in constructor. */\n protected _dataSource?: AbstractDataSource;\n\n /** Lazy-resolved from @repository metadata on first access. */\n protected _entity?: AbstractEntity;\n\n /**\n * Memoized @model settings for `this.entity`'s class. `null` means not yet resolved - `undefined`\n * is itself a valid resolved value: the model declares no settings.\n */\n private _modelSettings: IModelMetadata['settings'] | null = null;\n\n constructor(\n dataSource?: AbstractDataSource,\n opts?: {\n scope?: string;\n entityClass?: TClass<AbstractEntity>;\n operationScope?: TRepositoryOperationScope;\n },\n ) {\n const scopeName =\n opts?.scope ??\n (opts?.entityClass?.name ? [opts.entityClass.name, 'Repository'].join('') : new.target.name);\n\n super({ scope: scopeName });\n\n this._operationScope = opts?.operationScope ?? RepositoryOperationScopes.READ_ONLY;\n\n if (dataSource) {\n this._dataSource = dataSource;\n }\n\n if (opts?.entityClass) {\n this._entity = new opts.entityClass();\n }\n }\n\n get dataSource(): AbstractDataSource {\n if (!this._dataSource) {\n throw getError({\n message: `[${this.constructor.name}] DataSource not available. Use @repository({ model: YourModel, dataSource: YourDataSource }) or pass dataSource in constructor.`,\n });\n }\n\n return this._dataSource;\n }\n\n set dataSource(value: AbstractDataSource) {\n this._dataSource = value;\n }\n\n /** Auto-resolves from @repository metadata if not explicitly set. */\n get entity(): AbstractEntity {\n this._entity ??= this.resolveEntity();\n\n return this._entity;\n }\n\n set entity(value: AbstractEntity) {\n this._entity = value;\n }\n\n get operationScope(): TRepositoryOperationScope {\n return this._operationScope;\n }\n\n setDataSource(opts: { dataSource: AbstractDataSource }): void {\n this._dataSource = opts.dataSource;\n }\n\n getEntity(): AbstractEntity {\n return this.entity;\n }\n\n /**\n * Resolved `@model` settings for `this.entity`'s class, keyed by Reflect target - not by\n * `entity.name`, which can diverge from the `@model` registry key.\n */\n protected get modelSettings(): IModelMetadata['settings'] {\n if (this._modelSettings !== null) {\n return this._modelSettings;\n }\n\n this._modelSettings = MetadataRegistry.getInstance().getModelMetadata({\n target: this.entity.constructor,\n })?.settings;\n\n return this._modelSettings;\n }\n\n protected get hiddenFields(): string[] {\n return this.modelSettings?.properties?.hidden ?? [];\n }\n\n /**\n * Refuses (400, `Column NOT FOUND`) a filter that came from a request and names a field the model hides, in its\n * `where`, its `order` or the `scope` of an `include` (judged by the hidden fields of the model it reads). The generated\n * controllers call it on what a client sends; the repository's own verbs do not, so server code can still filter and\n * sort on a hidden field.\n */\n assertRequestFilter(opts: { filter?: IRequestFilterShape }): void {\n RequestFilterGuard.assertFilter({\n filter: opts.filter,\n judge: this.createRequestFilterJudge(),\n tableName: this.entity?.name ?? this.constructor.name,\n });\n }\n\n /**\n * How this repository judges the keys of a request filter. The default reads a key as a dotted field name and refuses it with\n * a 400 `Column NOT FOUND`; a relational or a search repository overrides it to read keys as its own query does and to\n * refuse with its own query's error for a column that does not exist.\n */\n protected createRequestFilterJudge(): IRequestFilterJudge {\n const hidden = new Set(this.hiddenFields);\n\n return {\n isHidden: ({ key }) => RequestFilterGuard.isHiddenByName({ key, hidden }),\n refuse: ({ key }) => RequestFilterGuard.columnNotFound({ scope: this.constructor.name, key }),\n };\n }\n\n /** Default where from @model settings.query.filter.where, AND-merged into every query unless skipped. */\n protected get defaultWhere(): TWhere | undefined {\n return this.modelSettings?.query?.filter?.where;\n }\n\n protected get defaultLimit(): number | undefined {\n return this.modelSettings?.query?.limit?.default;\n }\n\n /** Largest `limit` a caller may ask for, when the model declares one; undefined leaves the tier's own default in force. */\n protected get maxLimit(): number | undefined {\n return this.modelSettings?.query?.limit?.max;\n }\n\n /**\n * Both bounds, in one place, for every tier.\n *\n * The upper bound is the point: `@model({ settings: { query: { limit: { max } } } })` is public and validated at\n * decoration time, but the relational tier read it nowhere, so `limit.max: 2` still issued\n * `LIMIT 50000000`.\n *\n * The lower bound matters just as much and is easy to miss: a NEGATIVE limit is not a smaller\n * page. Drizzle renders the LIMIT clause only when the value is `>= 0`, so a negative one removes\n * the clause and returns the whole table. The wire schema now rejects it too, but a server-side\n * caller reaches this method without passing through the schema at all.\n */\n protected assertLimitWithinCeiling(opts: { limit?: number; scope?: string }): void {\n const { limit, scope = 'find' } = opts;\n\n if (limit === undefined) {\n return;\n }\n\n // The shape check first, because it needs no metadata at all.\n if (!Number.isInteger(limit) || limit < 0) {\n throw getError({\n message: `[${this.constructor.name}][${scope}] Invalid 'limit' | Expected a non-negative integer | Got: ${limit}`,\n });\n }\n\n // `limit.max` reaches `modelSettings`, which resolves the entity - and THAT throws for a\n // repository with no `@repository` model binding. Such a repository is a misconfiguration this\n // method has no business reporting, and the caller path that used to reach `getDefaultLimit()`\n // never touched it either, because `??` short-circuits when a limit is given. So the ceiling is\n // consulted only when the binding that makes it resolvable is actually present.\n const hasModelBinding = Boolean(\n MetadataRegistry.getInstance().getRepositoryBinding({ target: this.constructor })?.model,\n );\n const ceiling = (hasModelBinding ? this.maxLimit : undefined) ?? DEFAULT_MAX_LIMIT;\n\n if (limit > ceiling) {\n throw getError({\n message: `[${this.constructor.name}][${scope}] Requested page exceeds this model's limit | requested: ${limit} | maximum: ${ceiling} | raise it with @model settings.query.limit.max if larger pages are genuinely needed`,\n });\n }\n }\n\n /**\n * The whole filter, relations included. Checking only the top-level `limit` left the identical\n * defect reachable one level down: a relation scope's negative limit drops Drizzle's LIMIT clause\n * for that relation and loads the entire related table.\n *\n * A relation's limit gets the SHAPE check only, not a ceiling. The ceiling belongs to the\n * relation's own model, which this repository cannot resolve - claiming otherwise would enforce\n * the parent's `limit.max` on a different entity.\n */\n protected assertFilterLimits(opts: { filter?: TFilter; scope?: string }): void {\n const { filter, scope = 'find' } = opts;\n\n if (!filter) {\n return;\n }\n\n this.assertLimitWithinCeiling({ limit: filter.limit, scope });\n\n const walk = (inclusions: TInclusion[] | undefined, path: string): void => {\n const inclusionsList = inclusions ?? [];\n\n for (const inclusion of inclusionsList) {\n const relationScope = inclusion.scope;\n\n if (!relationScope) {\n continue;\n }\n\n const relationPath = `${path}.${inclusion.relation}`;\n const relationLimit = relationScope.limit;\n\n if (\n relationLimit !== undefined &&\n (!Number.isInteger(relationLimit) || relationLimit < 0)\n ) {\n throw getError({\n message: `[${this.constructor.name}][${scope}] Invalid 'limit' on relation scope | relation: ${relationPath} | Expected a non-negative integer | Got: ${relationLimit}`,\n });\n }\n\n walk(relationScope.include, relationPath);\n }\n };\n\n walk(filter.include, scope);\n }\n\n /** Resolves the entity instance from @repository metadata on first access. */\n protected resolveEntity(): AbstractEntity {\n const registry = MetadataRegistry.getInstance();\n const binding = registry.getRepositoryBinding({ target: this.constructor });\n\n if (!binding?.model) {\n throw getError({\n message: `[${this.constructor.name}] Cannot resolve entity. Either pass entityClass in constructor or use @repository decorator with model option.`,\n });\n }\n\n // ResolverUtility.resolveValue() erases to the resolved value's structural type, not this class-or-resolver\n // union's member - the `@repository` decorator guarantees a class constructor here.\n const ModelClass = ResolverUtility.resolveValue({\n value: binding.model,\n }) as TClass<AbstractEntity>;\n\n return new ModelClass();\n }\n\n /** Rejects a verb the current operation scope does not permit. */\n protected denyOperation(opts: { methodName: string }): never {\n throw getError({\n messageCode: RepositoryErrorCodes.OPERATION_NOT_ALLOWED,\n message: `[${opts.methodName}] Repository operation is NOT ALLOWED | scope: ${this.operationScope}`,\n });\n }\n\n /**\n * Shared retry orchestration for read verbs. Inside a transaction retry is skipped - the pool\n * routes transactions to the primary, so there is no replica lag to wait out.\n */\n protected executeReadWithRetry<TResult>(opts: {\n operation: string;\n options: IExtraOptions & IWithReadRetry<TResult>;\n defaultUntil: (result: TResult) => boolean;\n execution: () => Promise<TResult>;\n }): Promise<TResult> {\n const { operation, options, defaultUntil, execution } = opts;\n\n if (!options.retry) {\n return execution();\n }\n\n if (options.transaction) {\n this.logger.for(operation).debug('Read retry skipped inside transaction');\n\n return execution();\n }\n\n const { maxAttempts, maxTotalMs, signal, backoff, until } = options.retry;\n\n return RetryHelper.executeWithRetryUntil<TResult>({\n operation: [this.constructor.name, operation].join('.'),\n execution,\n until: until ?? defaultUntil,\n maxAttempts,\n maxTotalMs,\n signal,\n backoff: backoff ?? {\n strategy: RetryBackoffStrategies.EXPONENTIAL,\n initialDelayMs: 50,\n maxDelayMs: 500,\n jitter: RetryJitterModes.EQUAL,\n },\n logger: this.logger,\n });\n }\n\n /**\n * A copy of `options` without `retry`, so re-entering a read verb takes its non-retry path - this\n * is what keeps the retry recursion single-depth. Copy-then-delete rather than a rest-destructure\n * (lint rejects the unused rest sibling) or `lodash/omit` (its `Omit<>` return type is not\n * assignable back to `TOptions`).\n */\n private omitReadRetry<TReadOptions extends { retry?: unknown }>(\n options: TReadOptions,\n ): TReadOptions {\n const rest = { ...options };\n delete rest.retry;\n\n return rest;\n }\n\n /** `find`, re-executed until the retry predicate holds - connectors dispatch here from `find` when `options.retry` is set. */\n protected findUntil<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options: TFindOptions<TOptions, R>;\n }): Promise<Array<R>> {\n const options = this.omitReadRetry(opts.options);\n\n return this.executeReadWithRetry<Array<R>>({\n operation: 'find',\n options: opts.options,\n defaultUntil: (result) => result.length > 0,\n // `R` is named here, so the row is `R`; TypeScript cannot resolve `TRow` for an unresolved `R`.\n execution: () => this.find<R>({ filter: opts.filter, options }) as Promise<Array<R>>,\n });\n }\n\n /** `find` with the range envelope, re-executed until the retry predicate holds - split from `findUntil` so each result shape is checked against its own `find` overload. */\n protected findRangeUntil<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options: TFindRangeOptions<TOptions, R>;\n }): Promise<TDataWithRange<R>> {\n const options = this.omitReadRetry(opts.options);\n\n return this.executeReadWithRetry<TDataWithRange<R>>({\n operation: 'find',\n options: opts.options,\n defaultUntil: (result) => result.data.length > 0,\n execution: () =>\n this.find<R>({ filter: opts.filter, options }) as unknown as Promise<TDataWithRange<R>>,\n });\n }\n\n /** `findOne`, re-executed until the retry predicate holds - also serves `findById` via its findOne delegation. */\n protected findOneUntil<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options: TFindOneOptions<TOptions, R>;\n }): Promise<TNullable<R>> {\n const options = this.omitReadRetry(opts.options);\n\n return this.executeReadWithRetry<TNullable<R>>({\n operation: 'findOne',\n options: opts.options,\n defaultUntil: (result) => result !== null && result !== undefined,\n execution: () => this.findOne<R>({ filter: opts.filter, options }) as Promise<TNullable<R>>,\n });\n }\n\n abstract count(opts: { where: TWhere<TDataObject>; options?: TOptions }): Promise<TCount>;\n\n abstract existsWith(opts: { where: TWhere<TDataObject>; options?: TOptions }): Promise<boolean>;\n\n abstract find<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options: TFindRangeOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<TDataWithRange<TRow<TDataObject, R, F>>>;\n\n abstract find<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options?: TFindOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<Array<TRow<TDataObject, R, F>>>;\n\n abstract findOne<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options?: TFindOneOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<TNullable<TRow<TDataObject, R, F>>>;\n\n abstract findById<\n R = unknown,\n const F extends TFields<TDataObject> = TFields<TDataObject>,\n >(opts: {\n id: IdType;\n filter?: TByIdFilter<TDataObject, F>;\n options?: TFindOneOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<TNullable<TRow<TDataObject, R, F>>>;\n\n abstract create(opts: {\n data: TPersistObject;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract create<R = TDataObject>(opts: {\n data: TPersistObject;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract createAll(opts: {\n data: Array<TPersistObject>;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract createAll<R = TDataObject>(opts: {\n data: Array<TPersistObject>;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: Array<R> }>;\n\n abstract updateById(opts: {\n id: IdType;\n data: Partial<TPersistObject>;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract updateById<R = TDataObject>(opts: {\n id: IdType;\n data: Partial<TPersistObject>;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract updateAll(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 updateAll<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 /** Alias for updateAll. */\n updateBy(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n 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 updateBy<R = TDataObject>(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: boolean; force?: boolean };\n }): Promise<TCount & { data: TNullable<Array<R>> }> {\n const { data, where, options } = opts;\n\n if (options?.shouldReturn === false) {\n return this.updateAll({ data, where, options: { ...options, shouldReturn: false } });\n }\n\n return this.updateAll<R>({ data, where, options });\n }\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 deleteAll(opts: {\n where?: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract deleteAll<R = TDataObject>(opts: {\n where?: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\n\n /** Alias for deleteAll. */\n deleteBy(opts: {\n where: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n deleteBy<R = TDataObject>(opts: {\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\n deleteBy<R = TDataObject>(opts: {\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: boolean; force?: boolean };\n }): Promise<TCount & { data: TNullable<Array<R>> }> {\n const { where, options } = opts;\n\n if (options?.shouldReturn === false) {\n return this.deleteAll({ where, options: { ...options, shouldReturn: false } });\n }\n\n return this.deleteAll<R>({ where, options });\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- /** Application statuses categorized by lifecycle phase (initial, pending, active, completed, inactive, failed). */
1
+ /** Application statuses categorized by lifecycle phase: the leading digit of a code is its phase (0 initial, 1 pending, 2 active, 3 completed, 4 inactive, 5 failed). */
2
2
  export declare class Statuses {
3
3
  static readonly UNKNOWN = "000_UNKNOWN";
4
4
  static readonly DRAFT = "001_DRAFT";
@@ -7,18 +7,24 @@ export declare class Statuses {
7
7
  static readonly SCHEDULED = "102_SCHEDULED";
8
8
  static readonly PENDING = "103_PENDING";
9
9
  static readonly IN_REVIEW = "104_IN_REVIEW";
10
+ static readonly OPEN = "105_OPEN";
11
+ static readonly SUBMITTED = "106_SUBMITTED";
10
12
  static readonly ENABLED = "200_ENABLED";
11
13
  static readonly ACTIVATED = "201_ACTIVATED";
12
14
  static readonly RUNNING = "202_RUNNING";
13
15
  static readonly PROCESSING = "203_PROCESSING";
14
16
  static readonly SENT = "204_SENT";
15
17
  static readonly RECEIVED = "205_RECEIVED";
18
+ static readonly READY = "206_READY";
19
+ static readonly PUBLISHED = "207_PUBLISHED";
20
+ static readonly ISSUED = "208_ISSUED";
16
21
  static readonly PARTIAL = "300_PARTIAL";
17
22
  static readonly APPROVED = "301_APPROVED";
18
23
  static readonly SUCCESS = "302_SUCCESS";
19
24
  static readonly COMPLETED = "303_COMPLETED";
20
25
  static readonly SETTLED = "304_SETTLED";
21
26
  static readonly CONFIRMED = "305_CONFIRMED";
27
+ static readonly RESOLVED = "306_RESOLVED";
22
28
  static readonly DISABLED = "400_DISABLED";
23
29
  static readonly DEACTIVATED = "401_DEACTIVATED";
24
30
  static readonly SUSPENDED = "402_SUSPENDED";
@@ -36,6 +42,7 @@ export declare class Statuses {
36
42
  static readonly CANCELLED = "505_CANCELLED";
37
43
  static readonly DELETED = "506_DELETED";
38
44
  static readonly REJECTED = "507_REJECTED";
45
+ static readonly VOIDED = "508_VOIDED";
39
46
  static readonly INITIAL_SCHEME_SET: Set<string>;
40
47
  static readonly PENDING_SCHEME_SET: Set<string>;
41
48
  static readonly ACTIVE_SCHEME_SET: Set<string>;