@dsqlbase/core 0.2.0 → 0.3.0

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 (164) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/definition/base.d.ts +3 -30
  3. package/dist/definition/base.d.ts.map +1 -1
  4. package/dist/definition/base.js +3 -14
  5. package/dist/definition/base.js.map +1 -1
  6. package/dist/definition/column.d.ts +22 -14
  7. package/dist/definition/column.d.ts.map +1 -1
  8. package/dist/definition/column.js +11 -37
  9. package/dist/definition/column.js.map +1 -1
  10. package/dist/definition/constraint.d.ts +9 -9
  11. package/dist/definition/constraint.d.ts.map +1 -1
  12. package/dist/definition/constraint.js.map +1 -1
  13. package/dist/definition/domain.d.ts +2 -1
  14. package/dist/definition/domain.d.ts.map +1 -1
  15. package/dist/definition/domain.js +2 -1
  16. package/dist/definition/domain.js.map +1 -1
  17. package/dist/definition/index.d.ts +5 -6
  18. package/dist/definition/index.d.ts.map +1 -1
  19. package/dist/definition/index.js +3 -4
  20. package/dist/definition/index.js.map +1 -1
  21. package/dist/definition/indexes.d.ts +9 -20
  22. package/dist/definition/indexes.d.ts.map +1 -1
  23. package/dist/definition/indexes.js +3 -6
  24. package/dist/definition/indexes.js.map +1 -1
  25. package/dist/definition/namespace.d.ts +2 -2
  26. package/dist/definition/namespace.d.ts.map +1 -1
  27. package/dist/definition/namespace.js.map +1 -1
  28. package/dist/definition/policy.d.ts +35 -0
  29. package/dist/definition/policy.d.ts.map +1 -0
  30. package/dist/definition/policy.js +42 -0
  31. package/dist/definition/policy.js.map +1 -0
  32. package/dist/definition/relations.d.ts +28 -33
  33. package/dist/definition/relations.d.ts.map +1 -1
  34. package/dist/definition/relations.js +1 -4
  35. package/dist/definition/relations.js.map +1 -1
  36. package/dist/definition/table.d.ts +39 -32
  37. package/dist/definition/table.d.ts.map +1 -1
  38. package/dist/definition/table.js +57 -67
  39. package/dist/definition/table.js.map +1 -1
  40. package/dist/definition/union.d.ts +18 -61
  41. package/dist/definition/union.d.ts.map +1 -1
  42. package/dist/definition/union.js +8 -69
  43. package/dist/definition/union.js.map +1 -1
  44. package/dist/index.d.ts +5 -3
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +5 -3
  47. package/dist/index.js.map +1 -1
  48. package/dist/resolvers/codec.d.ts +16 -0
  49. package/dist/resolvers/codec.d.ts.map +1 -0
  50. package/dist/resolvers/codec.js +9 -0
  51. package/dist/resolvers/codec.js.map +1 -0
  52. package/dist/resolvers/hooks.d.ts +39 -0
  53. package/dist/resolvers/hooks.d.ts.map +1 -0
  54. package/dist/resolvers/hooks.js +2 -0
  55. package/dist/resolvers/hooks.js.map +1 -0
  56. package/dist/resolvers/index.d.ts +5 -0
  57. package/dist/resolvers/index.d.ts.map +1 -0
  58. package/dist/resolvers/index.js +2 -0
  59. package/dist/resolvers/index.js.map +1 -0
  60. package/dist/resolvers/policy.d.ts +31 -0
  61. package/dist/resolvers/policy.d.ts.map +1 -0
  62. package/dist/resolvers/policy.js +2 -0
  63. package/dist/resolvers/policy.js.map +1 -0
  64. package/dist/resolvers/validator.d.ts +14 -0
  65. package/dist/resolvers/validator.d.ts.map +1 -0
  66. package/dist/resolvers/validator.js +2 -0
  67. package/dist/resolvers/validator.js.map +1 -0
  68. package/dist/runtime/base.d.ts +7 -4
  69. package/dist/runtime/base.d.ts.map +1 -1
  70. package/dist/runtime/base.js.map +1 -1
  71. package/dist/runtime/build.d.ts +22 -0
  72. package/dist/runtime/build.d.ts.map +1 -0
  73. package/dist/runtime/build.js +184 -0
  74. package/dist/runtime/build.js.map +1 -0
  75. package/dist/runtime/column.d.ts +40 -23
  76. package/dist/runtime/column.d.ts.map +1 -1
  77. package/dist/runtime/column.js +120 -28
  78. package/dist/runtime/column.js.map +1 -1
  79. package/dist/runtime/context.d.ts +17 -26
  80. package/dist/runtime/context.d.ts.map +1 -1
  81. package/dist/runtime/context.js +4 -6
  82. package/dist/runtime/context.js.map +1 -1
  83. package/dist/runtime/errors.d.ts +31 -9
  84. package/dist/runtime/errors.d.ts.map +1 -1
  85. package/dist/runtime/errors.js +54 -11
  86. package/dist/runtime/errors.js.map +1 -1
  87. package/dist/runtime/executor.d.ts.map +1 -1
  88. package/dist/runtime/executor.js +10 -1
  89. package/dist/runtime/executor.js.map +1 -1
  90. package/dist/runtime/index.d.ts +10 -6
  91. package/dist/runtime/index.d.ts.map +1 -1
  92. package/dist/runtime/index.js +5 -3
  93. package/dist/runtime/index.js.map +1 -1
  94. package/dist/runtime/operation.d.ts +62 -83
  95. package/dist/runtime/operation.d.ts.map +1 -1
  96. package/dist/runtime/operation.js +194 -260
  97. package/dist/runtime/operation.js.map +1 -1
  98. package/dist/runtime/policy.d.ts +35 -0
  99. package/dist/runtime/policy.d.ts.map +1 -0
  100. package/dist/runtime/policy.js +72 -0
  101. package/dist/runtime/policy.js.map +1 -0
  102. package/dist/runtime/reference.d.ts +87 -0
  103. package/dist/runtime/reference.d.ts.map +1 -0
  104. package/dist/runtime/reference.js +68 -0
  105. package/dist/runtime/reference.js.map +1 -0
  106. package/dist/runtime/registry.d.ts +26 -95
  107. package/dist/runtime/registry.d.ts.map +1 -1
  108. package/dist/runtime/registry.js +29 -408
  109. package/dist/runtime/registry.js.map +1 -1
  110. package/dist/runtime/relation.d.ts +45 -0
  111. package/dist/runtime/relation.d.ts.map +1 -0
  112. package/dist/runtime/relation.js +2 -0
  113. package/dist/runtime/relation.js.map +1 -0
  114. package/dist/runtime/table.d.ts +31 -35
  115. package/dist/runtime/table.d.ts.map +1 -1
  116. package/dist/runtime/table.js +78 -47
  117. package/dist/runtime/table.js.map +1 -1
  118. package/dist/runtime/union.d.ts +11 -4
  119. package/dist/runtime/union.d.ts.map +1 -1
  120. package/dist/runtime/union.js +18 -7
  121. package/dist/runtime/union.js.map +1 -1
  122. package/dist/sql/index.d.ts +2 -2
  123. package/dist/sql/index.d.ts.map +1 -1
  124. package/dist/sql/index.js +1 -1
  125. package/dist/sql/index.js.map +1 -1
  126. package/dist/sql/nodes.d.ts +22 -0
  127. package/dist/sql/nodes.d.ts.map +1 -1
  128. package/dist/sql/nodes.js +21 -0
  129. package/dist/sql/nodes.js.map +1 -1
  130. package/dist/sql/tag.d.ts +3 -15
  131. package/dist/sql/tag.d.ts.map +1 -1
  132. package/dist/sql/tag.js +5 -71
  133. package/dist/sql/tag.js.map +1 -1
  134. package/dist/utils/index.d.ts +1 -1
  135. package/dist/utils/index.d.ts.map +1 -1
  136. package/dist/utils/index.js.map +1 -1
  137. package/dist/utils/types.d.ts +2 -14
  138. package/dist/utils/types.d.ts.map +1 -1
  139. package/dist/utils/types.js.map +1 -1
  140. package/dist/validation/index.d.ts +2 -0
  141. package/dist/validation/index.d.ts.map +1 -0
  142. package/dist/validation/index.js +2 -0
  143. package/dist/validation/index.js.map +1 -0
  144. package/dist/validation/references.d.ts +23 -0
  145. package/dist/validation/references.d.ts.map +1 -0
  146. package/dist/validation/references.js +240 -0
  147. package/dist/validation/references.js.map +1 -0
  148. package/dist/validation/validate.d.ts +40 -0
  149. package/dist/validation/validate.d.ts.map +1 -0
  150. package/dist/validation/validate.js +354 -0
  151. package/dist/validation/validate.js.map +1 -0
  152. package/package.json +13 -4
  153. package/dist/definition/embedded.d.ts +0 -131
  154. package/dist/definition/embedded.d.ts.map +0 -1
  155. package/dist/definition/embedded.js +0 -133
  156. package/dist/definition/embedded.js.map +0 -1
  157. package/dist/definition/tenant.d.ts +0 -50
  158. package/dist/definition/tenant.d.ts.map +0 -1
  159. package/dist/definition/tenant.js +0 -73
  160. package/dist/definition/tenant.js.map +0 -1
  161. package/dist/runtime/group.d.ts +0 -54
  162. package/dist/runtime/group.d.ts.map +0 -1
  163. package/dist/runtime/group.js +0 -96
  164. package/dist/runtime/group.js.map +0 -1
@@ -5,35 +5,25 @@ import { Schema } from "./base.js";
5
5
  import { Session } from "./session.js";
6
6
  import { SchemaRegistry } from "./registry.js";
7
7
  import { OperationsFactory } from "./operation.js";
8
- /** How a tenant table behaves on a client that carries no identity. */
9
- export type TenancyOptions = {
10
- /**
11
- * Refuse to build an operation on a tenant table when there are no claims to scope it with.
12
- * On by default: a query that silently runs unscoped is the bug this exists to prevent.
13
- */
14
- enforce?: boolean;
15
- };
16
- /** Page-size bounds for keyset pagination. Carried here for the client; core reads neither. */
17
- export type PaginationOptions = {
18
- /** The page size when a call names none. */
19
- defaultLimit?: number;
20
- /** The largest page size a call may ask for. Unbounded when absent. */
21
- maxLimit?: number;
22
- };
23
8
  export type ExecutionContextOptions<TSchema extends DefinitionSchema> = {
24
9
  session: Session;
25
10
  dialect: QueryBuilder;
26
11
  schema: SchemaRegistry<TSchema>;
27
12
  /**
28
- * The claims every tenant table on this context is scoped to, keyed by claim name.
29
- *
30
- * Absent on a base client and set once by `$identityClaims`, which builds a derived context
31
- * rather than mutating this one — the reason a scoped and an unscoped client can coexist in
32
- * one process, and why a query's SQL is fixed by the client that built it.
13
+ * The values settings render from, keyed by setting name. Absent on a base client; set by
14
+ * `$settings`, merged over the parent's. It derives a new context rather than mutating this
15
+ * one, so concurrent requests never see each other's values, and a query's SQL is fixed by the
16
+ * client that built it. An unset setting renders `NULL`.
17
+ */
18
+ settings?: Readonly<Record<string, unknown>>;
19
+ /**
20
+ * `bypass: true` skips every row policy — predicates and checks — on this context and every
21
+ * one derived from it: the `BYPASSRLS` analogue, for a worker rather than a request handler.
22
+ * Set per client, never per call. Settings still render.
33
23
  */
34
- identity?: Record<string, unknown>;
35
- tenancy?: TenancyOptions;
36
- pagination?: PaginationOptions;
24
+ policies?: {
25
+ bypass?: boolean;
26
+ };
37
27
  };
38
28
  export declare class ExecutionContext<TDefinition extends DefinitionSchema = DefinitionSchema> implements TypedObject<Schema<TDefinition>> {
39
29
  readonly __type: Schema<TDefinition>;
@@ -41,9 +31,10 @@ export declare class ExecutionContext<TDefinition extends DefinitionSchema = Def
41
31
  readonly dialect: QueryBuilder;
42
32
  readonly schema: SchemaRegistry<TDefinition>;
43
33
  readonly operations: OperationsFactory<Schema<TDefinition>>;
44
- readonly identity?: Record<string, unknown>;
45
- readonly tenancy: Required<TenancyOptions>;
46
- readonly pagination?: PaginationOptions;
34
+ readonly settings?: Readonly<Record<string, unknown>>;
35
+ readonly policies: {
36
+ readonly bypass: boolean;
37
+ };
47
38
  constructor(options: ExecutionContextOptions<TDefinition>);
48
39
  }
49
40
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/runtime/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,+FAA+F;AAC/F,MAAM,MAAM,iBAAiB,GAAG;IAC9B,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,uBAAuB,CAAC,OAAO,SAAS,gBAAgB,IAAI;IACtE,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IAEhC;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnC,OAAO,CAAC,E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E,OAAO,CAAC;IACjB,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IAEhC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAE7C;;;;OAIG;IACH,QAAQ,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACjC,CAAC;AAEF,qBAAa,gBAAgB,CAC3B,WAAW,SAAS,gBAAgB,GAAG,gBAAgB,CACvD,YAAW,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC3C,SAAiB,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAE7C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC;IAC7C,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;IAC5D,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACtD,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;gBAEpC,OAAO,EAAE,uBAAuB,CAAC,WAAW,CAAC;CAQ1D"}
@@ -4,16 +4,14 @@ export class ExecutionContext {
4
4
  dialect;
5
5
  schema;
6
6
  operations;
7
- identity;
8
- tenancy;
9
- pagination;
7
+ settings;
8
+ policies;
10
9
  constructor(options) {
11
10
  this.session = options.session;
12
11
  this.dialect = options.dialect;
13
12
  this.schema = options.schema;
14
- this.identity = options.identity;
15
- this.tenancy = { enforce: options.tenancy?.enforce ?? true };
16
- this.pagination = options.pagination;
13
+ this.settings = options.settings;
14
+ this.policies = Object.freeze({ bypass: options.policies?.bypass ?? false });
17
15
  this.operations = new OperationsFactory(this);
18
16
  }
19
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/runtime/context.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAsCnD,MAAM,OAAO,gBAAgB;IAKlB,OAAO,CAAU;IACjB,OAAO,CAAe;IACtB,MAAM,CAA8B;IACpC,UAAU,CAAyC;IACnD,QAAQ,CAA2B;IACnC,OAAO,CAA2B;IAClC,UAAU,CAAqB;IAExC,YAAY,OAA6C;QACvD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,CAAC;QAC7D,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,IAAI,iBAAiB,CAAsB,IAAI,CAAC,CAAC;IACrE,CAAC;CACF","sourcesContent":["import { TypedObject } from \"../utils/index.js\";\nimport { DefinitionSchema } from \"../definition/index.js\";\nimport { QueryBuilder } from \"./query.js\";\nimport { Schema } from \"./base.js\";\nimport { Session } from \"./session.js\";\nimport { SchemaRegistry } from \"./registry.js\";\nimport { OperationsFactory } from \"./operation.js\";\n\n/** How a tenant table behaves on a client that carries no identity. */\nexport type TenancyOptions = {\n /**\n * Refuse to build an operation on a tenant table when there are no claims to scope it with.\n * On by default: a query that silently runs unscoped is the bug this exists to prevent.\n */\n enforce?: boolean;\n};\n\n/** Page-size bounds for keyset pagination. Carried here for the client; core reads neither. */\nexport type PaginationOptions = {\n /** The page size when a call names none. */\n defaultLimit?: number;\n /** The largest page size a call may ask for. Unbounded when absent. */\n maxLimit?: number;\n};\n\nexport type ExecutionContextOptions<TSchema extends DefinitionSchema> = {\n session: Session;\n dialect: QueryBuilder;\n schema: SchemaRegistry<TSchema>;\n\n /**\n * The claims every tenant table on this context is scoped to, keyed by claim name.\n *\n * Absent on a base client and set once by `$identityClaims`, which builds a derived context\n * rather than mutating this one — the reason a scoped and an unscoped client can coexist in\n * one process, and why a query's SQL is fixed by the client that built it.\n */\n identity?: Record<string, unknown>;\n\n tenancy?: TenancyOptions;\n\n pagination?: PaginationOptions;\n};\n\nexport class ExecutionContext<\n TDefinition extends DefinitionSchema = DefinitionSchema,\n> implements TypedObject<Schema<TDefinition>> {\n declare readonly __type: Schema<TDefinition>;\n\n readonly session: Session;\n readonly dialect: QueryBuilder;\n readonly schema: SchemaRegistry<TDefinition>;\n readonly operations: OperationsFactory<Schema<TDefinition>>;\n readonly identity?: Record<string, unknown>;\n readonly tenancy: Required<TenancyOptions>;\n readonly pagination?: PaginationOptions;\n\n constructor(options: ExecutionContextOptions<TDefinition>) {\n this.session = options.session;\n this.dialect = options.dialect;\n this.schema = options.schema;\n this.identity = options.identity;\n this.tenancy = { enforce: options.tenancy?.enforce ?? true };\n this.pagination = options.pagination;\n this.operations = new OperationsFactory<Schema<TDefinition>>(this);\n }\n}\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/runtime/context.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAuBnD,MAAM,OAAO,gBAAgB;IAKlB,OAAO,CAAU;IACjB,OAAO,CAAe;IACtB,MAAM,CAA8B;IACpC,UAAU,CAAyC;IACnD,QAAQ,CAAqC;IAC7C,QAAQ,CAA+B;IAEhD,YAAY,OAA6C;QACvD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,EAAE,CAAC,CAAC;QAC7E,IAAI,CAAC,UAAU,GAAG,IAAI,iBAAiB,CAAsB,IAAI,CAAC,CAAC;IACrE,CAAC;CACF","sourcesContent":["import { TypedObject } from \"../utils/index.js\";\nimport { DefinitionSchema } from \"../definition/index.js\";\nimport { QueryBuilder } from \"./query.js\";\nimport { Schema } from \"./base.js\";\nimport { Session } from \"./session.js\";\nimport { SchemaRegistry } from \"./registry.js\";\nimport { OperationsFactory } from \"./operation.js\";\n\nexport type ExecutionContextOptions<TSchema extends DefinitionSchema> = {\n session: Session;\n dialect: QueryBuilder;\n schema: SchemaRegistry<TSchema>;\n\n /**\n * The values settings render from, keyed by setting name. Absent on a base client; set by\n * `$settings`, merged over the parent's. It derives a new context rather than mutating this\n * one, so concurrent requests never see each other's values, and a query's SQL is fixed by the\n * client that built it. An unset setting renders `NULL`.\n */\n settings?: Readonly<Record<string, unknown>>;\n\n /**\n * `bypass: true` skips every row policy — predicates and checks — on this context and every\n * one derived from it: the `BYPASSRLS` analogue, for a worker rather than a request handler.\n * Set per client, never per call. Settings still render.\n */\n policies?: { bypass?: boolean };\n};\n\nexport class ExecutionContext<\n TDefinition extends DefinitionSchema = DefinitionSchema,\n> implements TypedObject<Schema<TDefinition>> {\n declare readonly __type: Schema<TDefinition>;\n\n readonly session: Session;\n readonly dialect: QueryBuilder;\n readonly schema: SchemaRegistry<TDefinition>;\n readonly operations: OperationsFactory<Schema<TDefinition>>;\n readonly settings?: Readonly<Record<string, unknown>>;\n readonly policies: { readonly bypass: boolean };\n\n constructor(options: ExecutionContextOptions<TDefinition>) {\n this.session = options.session;\n this.dialect = options.dialect;\n this.schema = options.schema;\n this.settings = options.settings;\n this.policies = Object.freeze({ bypass: options.policies?.bypass ?? false });\n this.operations = new OperationsFactory<Schema<TDefinition>>(this);\n }\n}\n"]}
@@ -1,14 +1,36 @@
1
+ /** The marker a failing check raises, decoded back into a {@link PolicyViolationError}. */
2
+ export declare const POLICY_MARKER = "dsqlbase.policy";
1
3
  /**
2
- * A tenant boundary was crossed, or could not be established.
4
+ * A write refused by a row policy's check: the statement failed, and nothing it would have
5
+ * written was written. Reads are never refused — a policy's `using` only filters rows.
3
6
  *
4
- * Thrown when an operation is *built* — when `findMany()` is called, not when the query is
5
- * executed — so a missing identity surfaces before anything reaches the database.
7
+ * The message names the table and the policy, never a row's values. The driver's error is
8
+ * `cause`.
6
9
  */
7
- export declare class TenancyError extends Error {
8
- /** The table whose tenant boundary could not be satisfied, when one table in particular is. */
9
- readonly table?: string;
10
- /** The claim that was missing, when one claim in particular was. */
11
- readonly claim?: string;
12
- constructor(message: string, table?: string, claim?: string);
10
+ export declare class PolicyViolationError extends Error {
11
+ /** The schema alias of the table written to. */
12
+ readonly table: string;
13
+ /** `insert` or `update`. */
14
+ readonly command: string;
15
+ /** Which part of the check failed: one restrictive policy, or the permissive ones together. */
16
+ readonly as: "restrictive" | "permissive";
17
+ /**
18
+ * The policies that part names: the one restrictive policy, or every permissive policy for
19
+ * the command — empty when there is none, which denies by default.
20
+ */
21
+ readonly policies: readonly string[];
22
+ constructor(details: {
23
+ table: string;
24
+ command: string;
25
+ as: "restrictive" | "permissive";
26
+ policies: readonly string[];
27
+ }, options?: {
28
+ cause?: unknown;
29
+ });
30
+ /**
31
+ * The policy violation a driver error carries, or `undefined` when it is some other error. It
32
+ * reads the message alone, so a session that drops the error's `code` still decodes it.
33
+ */
34
+ static fromDriverError(error: unknown, command: string): PolicyViolationError | undefined;
13
35
  }
14
36
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/runtime/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,+FAA+F;IAC/F,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAExB,oEAAoE;IACpE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;gBAEZ,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;CAO5D"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/runtime/errors.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,eAAO,MAAM,aAAa,oBAAoB,CAAC;AAM/C;;;;;;GAMG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,4BAA4B;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,EAAE,aAAa,GAAG,YAAY,CAAC;IAC1C;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;gBAGnC,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,EAAE,EAAE,aAAa,GAAG,YAAY,CAAC;QACjC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;KAC7B,EACD,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;IAoB/B;;;OAGG;IACH,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS;CAyB1F"}
@@ -1,19 +1,62 @@
1
+ /** The marker a failing check raises, decoded back into a {@link PolicyViolationError}. */
2
+ export const POLICY_MARKER = "dsqlbase.policy";
3
+ // The alias is a schema export name and the names are identifiers (`TableDefinition.policy`), so
4
+ // neither holds `:` or `"`.
5
+ const MARKER_PATTERN = /"dsqlbase\.policy:([^:"]*):(restrictive|permissive):([^"]*)"/;
1
6
  /**
2
- * A tenant boundary was crossed, or could not be established.
7
+ * A write refused by a row policy's check: the statement failed, and nothing it would have
8
+ * written was written. Reads are never refused — a policy's `using` only filters rows.
3
9
  *
4
- * Thrown when an operation is *built* — when `findMany()` is called, not when the query is
5
- * executed — so a missing identity surfaces before anything reaches the database.
10
+ * The message names the table and the policy, never a row's values. The driver's error is
11
+ * `cause`.
6
12
  */
7
- export class TenancyError extends Error {
8
- /** The table whose tenant boundary could not be satisfied, when one table in particular is. */
13
+ export class PolicyViolationError extends Error {
14
+ /** The schema alias of the table written to. */
9
15
  table;
10
- /** The claim that was missing, when one claim in particular was. */
11
- claim;
12
- constructor(message, table, claim) {
13
- super(message);
14
- this.name = "TenancyError";
16
+ /** `insert` or `update`. */
17
+ command;
18
+ /** Which part of the check failed: one restrictive policy, or the permissive ones together. */
19
+ as;
20
+ /**
21
+ * The policies that part names: the one restrictive policy, or every permissive policy for
22
+ * the command — empty when there is none, which denies by default.
23
+ */
24
+ policies;
25
+ constructor(details, options) {
26
+ const { table, command, as, policies } = details;
27
+ const names = policies.map((name) => `"${name}"`).join(", ");
28
+ const reason = as === "restrictive"
29
+ ? `restrictive policy ${names} failed`
30
+ : policies.length === 0
31
+ ? `no permissive policy applies to ${command}`
32
+ : `no permissive policy passed (${names})`;
33
+ super(`Row policy refused the ${command} on "${table}": ${reason}.`, options);
34
+ this.name = "PolicyViolationError";
15
35
  this.table = table;
16
- this.claim = claim;
36
+ this.command = command;
37
+ this.as = as;
38
+ this.policies = Object.freeze([...policies]);
39
+ }
40
+ /**
41
+ * The policy violation a driver error carries, or `undefined` when it is some other error. It
42
+ * reads the message alone, so a session that drops the error's `code` still decodes it.
43
+ */
44
+ static fromDriverError(error, command) {
45
+ const message = error?.message;
46
+ if (typeof message !== "string") {
47
+ return undefined;
48
+ }
49
+ const match = MARKER_PATTERN.exec(message);
50
+ if (!match) {
51
+ return undefined;
52
+ }
53
+ const [, table = "", as, names = ""] = match;
54
+ return new PolicyViolationError({
55
+ table,
56
+ command,
57
+ as: as,
58
+ policies: names === "" ? [] : names.split(","),
59
+ }, { cause: error });
17
60
  }
18
61
  }
19
62
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/runtime/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,+FAA+F;IACtF,KAAK,CAAU;IAExB,oEAAoE;IAC3D,KAAK,CAAU;IAExB,YAAY,OAAe,EAAE,KAAc,EAAE,KAAc;QACzD,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF","sourcesContent":["/**\n * A tenant boundary was crossed, or could not be established.\n *\n * Thrown when an operation is *built* — when `findMany()` is called, not when the query is\n * executed — so a missing identity surfaces before anything reaches the database.\n */\nexport class TenancyError extends Error {\n /** The table whose tenant boundary could not be satisfied, when one table in particular is. */\n readonly table?: string;\n\n /** The claim that was missing, when one claim in particular was. */\n readonly claim?: string;\n\n constructor(message: string, table?: string, claim?: string) {\n super(message);\n\n this.name = \"TenancyError\";\n this.table = table;\n this.claim = claim;\n }\n}\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/runtime/errors.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAE/C,iGAAiG;AACjG,4BAA4B;AAC5B,MAAM,cAAc,GAAG,8DAA8D,CAAC;AAEtF;;;;;;GA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,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE3C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,EAAE,EAAE,EAAE,KAAK,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC;QAE7C,OAAO,IAAI,oBAAoB,CAC7B;YACE,KAAK;YACL,OAAO;YACP,EAAE,EAAE,EAAkC;YACtC,QAAQ,EAAE,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;SAC/C,EACD,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;IACJ,CAAC;CACF","sourcesContent":["/** The marker a failing check raises, decoded back into a {@link PolicyViolationError}. */\nexport const POLICY_MARKER = \"dsqlbase.policy\";\n\n// The alias is a schema export name and the names are identifiers (`TableDefinition.policy`), so\n// neither holds `:` or `\"`.\nconst MARKER_PATTERN = /\"dsqlbase\\.policy:([^:\"]*):(restrictive|permissive):([^\"]*)\"/;\n\n/**\n * A write refused by a row policy's check: the statement failed, and nothing it would have\n * written was written. Reads are never refused — a policy's `using` only filters rows.\n *\n * The message names the table and the policy, never a row's values. The driver's error is\n * `cause`.\n */\nexport class PolicyViolationError extends Error {\n /** The schema alias of the table written to. */\n readonly table: string;\n /** `insert` or `update`. */\n readonly command: string;\n /** Which part of the check failed: one restrictive policy, or the permissive ones together. */\n readonly as: \"restrictive\" | \"permissive\";\n /**\n * The policies that part names: the one restrictive policy, or every permissive policy for\n * the command — empty when there is none, which denies by default.\n */\n readonly policies: readonly string[];\n\n constructor(\n details: {\n table: string;\n command: string;\n as: \"restrictive\" | \"permissive\";\n policies: readonly string[];\n },\n options?: { cause?: unknown }\n ) {\n const { table, command, as, policies } = details;\n const names = policies.map((name) => `\"${name}\"`).join(\", \");\n const reason =\n as === \"restrictive\"\n ? `restrictive policy ${names} failed`\n : policies.length === 0\n ? `no permissive policy applies to ${command}`\n : `no permissive policy passed (${names})`;\n\n super(`Row policy refused the ${command} on \"${table}\": ${reason}.`, options);\n\n this.name = \"PolicyViolationError\";\n this.table = table;\n this.command = command;\n this.as = as;\n this.policies = Object.freeze([...policies]);\n }\n\n /**\n * The policy violation a driver error carries, or `undefined` when it is some other error. It\n * reads the message alone, so a session that drops the error's `code` still decodes it.\n */\n static fromDriverError(error: unknown, command: string): PolicyViolationError | undefined {\n const message = (error as { message?: unknown } | null)?.message;\n\n if (typeof message !== \"string\") {\n return undefined;\n }\n\n const match = MARKER_PATTERN.exec(message);\n\n if (!match) {\n return undefined;\n }\n\n const [, table = \"\", as, names = \"\"] = match;\n\n return new PolicyViolationError(\n {\n table,\n command,\n as: as as \"restrictive\" | \"permissive\",\n policies: names === \"\" ? [] : names.split(\",\"),\n },\n { cause: error }\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/runtime/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,MAAM,UAAU,CAAC,OAAO,IAAI;IAChC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;CAC9C,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;AAEzB,qBAAa,eAAe,CAAC,OAAO,CAAE,SAAQ,QAAQ,CAAC,OAAO,CAAE,YAAW,UAAU,CAAC,OAAO,CAAC;IAC5F,SAAiB,OAAO,EAAE,OAAO,CAAC;IAElC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAe;IAC1C,OAAO,CAAC,QA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 +1,5 @@
1
1
  import { Thenable } from "../utils/thenable.js";
2
+ import { PolicyViolationError } from "./errors.js";
2
3
  export class ExecutableQuery extends Thenable {
3
4
  _operation;
4
5
  _session;
@@ -8,7 +9,15 @@ export class ExecutableQuery extends Thenable {
8
9
  this._session = session;
9
10
  }
10
11
  async execute() {
11
- const result = await this._session.execute(this._operation.query);
12
+ let result;
13
+ try {
14
+ result = await this._session.execute(this._operation.query);
15
+ }
16
+ catch (error) {
17
+ // A row policy's check fails the statement with a marker in the message; decoded here, in
18
+ // core, so a consumer-written session gets the typed error without knowing about it.
19
+ throw PolicyViolationError.fromDriverError(error, this._operation.type) ?? error;
20
+ }
12
21
  return this._operation.resolve(result);
13
22
  }
14
23
  clone(session) {
@@ -1 +1 @@
1
- {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/runtime/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAehD,MAAM,OAAO,eAAyB,SAAQ,QAAiB;IAG5C,UAAU,CAAe;IACzB,QAAQ,CAAU;IAEnC,YAAY,SAAuB,EAAE,OAAgB;QACnD,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAClE,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAY,CAAC;IACpD,CAAC;IAEM,KAAK,CAAC,OAAgB;QAC3B,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;CACF;AAMD;;;;;GAKG;AACH,MAAM,OAAO,cACX,SAAQ,QAAiB;IAKR,MAAM,CAAS;IACf,QAAQ,CAA0C;IAEnE,YAAY,KAAa,EAAE,OAAgD;QACzE,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC7E,OAAO,IAAI,CAAC,QAAQ,CAAC,OAA4B,CAAC,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,OAAgB;QAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAsB,CAAC;QAClF,OAAO,IAAI,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC;CACF","sourcesContent":["import { Thenable } from \"../utils/thenable.js\";\nimport { AnyOperation } from \"./operation.js\";\nimport { Session } from \"./session.js\";\n\n/**\n * Anything a client hands back that runs when awaited, and can be re-bound to another session.\n *\n * `$transaction([...])` batches over this rather than over `ExecutableQuery`, so a result built\n * from several statements batches the same way a single statement does.\n */\nexport type Executable<TResult> = {\n execute(): Promise<TResult>;\n clone(session: Session): Executable<TResult>;\n} & PromiseLike<TResult>;\n\nexport class ExecutableQuery<TResult> extends Thenable<TResult> implements Executable<TResult> {\n declare readonly $typeOf: TResult;\n\n private readonly _operation: AnyOperation;\n private readonly _session: Session;\n\n constructor(operation: AnyOperation, session: Session) {\n super();\n\n this._operation = operation;\n this._session = session;\n }\n\n public async execute(): Promise<TResult> {\n const result = await this._session.execute(this._operation.query);\n return this._operation.resolve(result) as TResult;\n }\n\n public clone(session: Session): ExecutableQuery<TResult> {\n return new ExecutableQuery(this._operation, session);\n }\n}\n\ntype ResultsOf<TParts extends readonly Executable<unknown>[]> = {\n -readonly [K in keyof TParts]: Awaited<TParts[K]>;\n};\n\n/**\n * Several executables run together and combined into one result.\n *\n * The parts run concurrently. On a pool session each may take its own connection, so their\n * snapshots can differ; re-bound to a transaction session by `clone`, they share one.\n */\nexport class CompositeQuery<TParts extends readonly Executable<unknown>[], TResult>\n extends Thenable<TResult>\n implements Executable<TResult>\n{\n declare readonly $typeOf: TResult;\n\n private readonly _parts: TParts;\n private readonly _combine: (results: ResultsOf<TParts>) => TResult;\n\n constructor(parts: TParts, combine: (results: ResultsOf<TParts>) => TResult) {\n super();\n\n this._parts = parts;\n this._combine = combine;\n }\n\n public async execute(): Promise<TResult> {\n const results = await Promise.all(this._parts.map((part) => part.execute()));\n return this._combine(results as ResultsOf<TParts>);\n }\n\n public clone(session: Session): CompositeQuery<TParts, TResult> {\n const parts = this._parts.map((part) => part.clone(session)) as unknown as TParts;\n return new CompositeQuery(parts, this._combine);\n }\n}\n"]}
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/runtime/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAanD,MAAM,OAAO,eAAyB,SAAQ,QAAiB;IAG5C,UAAU,CAAe;IACzB,QAAQ,CAAU;IAEnC,YAAY,SAAuB,EAAE,OAAgB;QACnD,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,IAAI,MAAiB,CAAC;QAEtB,IAAI,CAAC;YACH,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC9D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,0FAA0F;YAC1F,qFAAqF;YACrF,MAAM,oBAAoB,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC;QACnF,CAAC;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAY,CAAC;IACpD,CAAC;IAEM,KAAK,CAAC,OAAgB;QAC3B,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;CACF;AAMD;;;;;GAKG;AACH,MAAM,OAAO,cACX,SAAQ,QAAiB;IAKR,MAAM,CAAS;IACf,QAAQ,CAA0C;IAEnE,YAAY,KAAa,EAAE,OAAgD;QACzE,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC7E,OAAO,IAAI,CAAC,QAAQ,CAAC,OAA4B,CAAC,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,OAAgB;QAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAsB,CAAC;QAClF,OAAO,IAAI,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC;CACF","sourcesContent":["import { Thenable } from \"../utils/thenable.js\";\nimport { AnyOperation } from \"./operation.js\";\nimport { Session } from \"./session.js\";\nimport { PolicyViolationError } from \"./errors.js\";\n\n/**\n * Anything a client hands back that runs when awaited, and can be re-bound to another session.\n *\n * `$transaction([...])` batches over this rather than over `ExecutableQuery`, so a result built\n * from several statements batches the same way a single statement does.\n */\nexport type Executable<TResult> = {\n execute(): Promise<TResult>;\n clone(session: Session): Executable<TResult>;\n} & PromiseLike<TResult>;\n\nexport class ExecutableQuery<TResult> extends Thenable<TResult> implements Executable<TResult> {\n declare readonly $typeOf: TResult;\n\n private readonly _operation: AnyOperation;\n private readonly _session: Session;\n\n constructor(operation: AnyOperation, session: Session) {\n super();\n\n this._operation = operation;\n this._session = session;\n }\n\n public async execute(): Promise<TResult> {\n let result: unknown[];\n\n try {\n result = await this._session.execute(this._operation.query);\n } catch (error) {\n // A row policy's check fails the statement with a marker in the message; decoded here, in\n // core, so a consumer-written session gets the typed error without knowing about it.\n throw PolicyViolationError.fromDriverError(error, this._operation.type) ?? error;\n }\n\n return this._operation.resolve(result) as TResult;\n }\n\n public clone(session: Session): ExecutableQuery<TResult> {\n return new ExecutableQuery(this._operation, session);\n }\n}\n\ntype ResultsOf<TParts extends readonly Executable<unknown>[]> = {\n -readonly [K in keyof TParts]: Awaited<TParts[K]>;\n};\n\n/**\n * Several executables run together and combined into one result.\n *\n * The parts run concurrently. On a pool session each may take its own connection, so their\n * snapshots can differ; re-bound to a transaction session by `clone`, they share one.\n */\nexport class CompositeQuery<TParts extends readonly Executable<unknown>[], TResult>\n extends Thenable<TResult>\n implements Executable<TResult>\n{\n declare readonly $typeOf: TResult;\n\n private readonly _parts: TParts;\n private readonly _combine: (results: ResultsOf<TParts>) => TResult;\n\n constructor(parts: TParts, combine: (results: ResultsOf<TParts>) => TResult) {\n super();\n\n this._parts = parts;\n this._combine = combine;\n }\n\n public async execute(): Promise<TResult> {\n const results = await Promise.all(this._parts.map((part) => part.execute()));\n return this._combine(results as ResultsOf<TParts>);\n }\n\n public clone(session: Session): CompositeQuery<TParts, TResult> {\n const parts = this._parts.map((part) => part.clone(session)) as unknown as TParts;\n return new CompositeQuery(parts, this._combine);\n }\n}\n"]}
@@ -1,13 +1,17 @@
1
1
  export type { AnySchema, DefinitionRelationsTableName, DefinitionTableName, DefinitionTableRelations, FieldRelationConfig, Schema, SchemaRelationDefinitions, SchemaTableDefinitions, SchemaTableRelations, SchemaUnionDefinitions, DefinitionUnionName, TableRelationFieldName, } from "./base.js";
2
- export { Column, type AnyColumn, type ColumnRowDecoder } from "./column.js";
3
- export { ColumnGroup, type AnyColumnGroup, type AnyField, type GroupReader, type GroupSelection, } from "./group.js";
4
- export { ExecutionContext, type ExecutionContextOptions, type PaginationOptions, type TenancyOptions, } from "./context.js";
5
- export { TenancyError } from "./errors.js";
2
+ export { Column, type AnyColumn } from "./column.js";
3
+ export { ExecutionContext, type ExecutionContextOptions } from "./context.js";
6
4
  export { CompositeQuery, ExecutableQuery, type Executable } from "./executor.js";
7
- export { OperationsFactory, type CountOperation, type CountOperationArgs, type DeleteOperation, type DeleteOperationArgs, type FieldMutation, type FieldResolver, type FieldSelection, type InsertOperation, type InsertOperationArgs, type Operation, type OperationMode, type OperationRequest, type OperationResult, type OperationType, type SelectOperation, type SelectOperationArgs, type UpdateOperation, type UpdateOperationArgs, type UnionOrderKey, type UnionSelectOperationArgs, type UnionSelectOperation, type UnionCountOperationArgs, UnionResolver, } from "./operation.js";
5
+ export { PolicyViolationError } from "./errors.js";
6
+ export { OperationsFactory, type AnyOperation, type CountOperation, type CountOperationArgs, type DeleteOperation, type DeleteOperationArgs, type FieldMutation, type FieldResolver, type FieldResolverEntry, type FieldSelection, type InsertOperation, type InsertOperationArgs, type Operation, type OperationMode, type OperationRequest, type OperationResult, type OperationType, type OrderByEntry, type RelationSelection, type SelectOperation, type SelectOperationArgs, type UpdateOperation, type UpdateOperationArgs, type UnionSelectOperationArgs, type UnionSelectOperation, type UnionCountOperationArgs, UnionResolver, } from "./operation.js";
7
+ export { ComputedDiscriminator } from "./reference.js";
8
+ export type { RuntimeRelation, TableRelation, UnionRelation } from "./relation.js";
9
+ export { buildSchema, type BuiltSchema } from "./build.js";
10
+ export type { ColumnReference, ReferenceEnd, ResolvedReferences, TableReference, UnionReference, } from "./reference.js";
8
11
  export { QueryBuilder, type DeleteParams, type InsertParams, type JoinParams, type SelectParams, type TableJoinParams, type UnionBranchParams, type UnionJoinParams, type UnionSelectParams, type UpdateParams, } from "./query.js";
9
- export { SchemaRegistry, type RuntimeTables, type TableByAlias, type TableByName, type TableByNameOrAlias, } from "./registry.js";
12
+ export { SchemaRegistry, type RuntimeTables, type TableByAlias, type TableByName, type TableByNameOrAlias, type RuntimeUnions, } from "./registry.js";
10
13
  export type { Session, TransactionSession } from "./session.js";
11
14
  export { Table, type AnyTable } from "./table.js";
12
15
  export { Union, type AnyUnion } from "./union.js";
16
+ export { Policy, resolvePolicy, type AnyPolicy, type RuntimePolicyConfig } from "./policy.js";
13
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,SAAS,EACT,4BAA4B,EAC5B,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,MAAM,EACN,yBAAyB,EACzB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,MAAM,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EACL,WAAW,EACX,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,cAAc,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EACL,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,kBAAkB,GACxB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,SAAS,EACT,4BAA4B,EAC5B,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,MAAM,EAC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,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
@@ -1,11 +1,13 @@
1
1
  export { Column } from "./column.js";
2
- export { ColumnGroup, } from "./group.js";
3
- export { ExecutionContext, } from "./context.js";
4
- export { TenancyError } from "./errors.js";
2
+ export { ExecutionContext } from "./context.js";
5
3
  export { CompositeQuery, ExecutableQuery } from "./executor.js";
4
+ export { PolicyViolationError } from "./errors.js";
6
5
  export { OperationsFactory, UnionResolver, } from "./operation.js";
6
+ export { ComputedDiscriminator } from "./reference.js";
7
+ export { buildSchema } from "./build.js";
7
8
  export { QueryBuilder, } from "./query.js";
8
9
  export { SchemaRegistry, } from "./registry.js";
9
10
  export { Table } from "./table.js";
10
11
  export { Union } from "./union.js";
12
+ export { Policy, resolvePolicy } from "./policy.js";
11
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAyC,MAAM,aAAa,CAAC;AAC5E,OAAO,EACL,WAAW,GAKZ,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gBAAgB,GAIjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAmB,MAAM,eAAe,CAAC;AACjF,OAAO,EACL,iBAAiB,EAuBjB,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,YAAY,GAUb,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,cAAc,GAKf,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,KAAK,EAAiB,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,KAAK,EAAiB,MAAM,YAAY,CAAC","sourcesContent":["export type {\n AnySchema,\n DefinitionRelationsTableName,\n DefinitionTableName,\n DefinitionTableRelations,\n FieldRelationConfig,\n Schema,\n SchemaRelationDefinitions,\n SchemaTableDefinitions,\n SchemaTableRelations,\n SchemaUnionDefinitions,\n DefinitionUnionName,\n TableRelationFieldName,\n} from \"./base.js\";\nexport { Column, type AnyColumn, type ColumnRowDecoder } from \"./column.js\";\nexport {\n ColumnGroup,\n type AnyColumnGroup,\n type AnyField,\n type GroupReader,\n type GroupSelection,\n} from \"./group.js\";\nexport {\n ExecutionContext,\n type ExecutionContextOptions,\n type PaginationOptions,\n type TenancyOptions,\n} from \"./context.js\";\nexport { TenancyError } from \"./errors.js\";\nexport { CompositeQuery, ExecutableQuery, type Executable } from \"./executor.js\";\nexport {\n OperationsFactory,\n type CountOperation,\n type CountOperationArgs,\n type DeleteOperation,\n type DeleteOperationArgs,\n type FieldMutation,\n type FieldResolver,\n type FieldSelection,\n type InsertOperation,\n type InsertOperationArgs,\n type Operation,\n type OperationMode,\n type OperationRequest,\n type OperationResult,\n type OperationType,\n type SelectOperation,\n type SelectOperationArgs,\n type UpdateOperation,\n type UpdateOperationArgs,\n type UnionOrderKey,\n type UnionSelectOperationArgs,\n type UnionSelectOperation,\n type UnionCountOperationArgs,\n UnionResolver,\n} from \"./operation.js\";\nexport {\n QueryBuilder,\n type DeleteParams,\n type InsertParams,\n type JoinParams,\n type SelectParams,\n type TableJoinParams,\n type UnionBranchParams,\n type UnionJoinParams,\n type UnionSelectParams,\n type UpdateParams,\n} from \"./query.js\";\nexport {\n SchemaRegistry,\n type RuntimeTables,\n type TableByAlias,\n type TableByName,\n type TableByNameOrAlias,\n} from \"./registry.js\";\nexport type { Session, TransactionSession } from \"./session.js\";\nexport { Table, type AnyTable } from \"./table.js\";\nexport { Union, type AnyUnion } from \"./union.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAkB,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAgC,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,eAAe,EAAmB,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACL,iBAAiB,EA0BjB,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAoB,MAAM,YAAY,CAAC;AAQ3D,OAAO,EACL,YAAY,GAUb,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,cAAc,GAMf,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,KAAK,EAAiB,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,KAAK,EAAiB,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,aAAa,EAA4C,MAAM,aAAa,CAAC","sourcesContent":["export type {\n AnySchema,\n DefinitionRelationsTableName,\n DefinitionTableName,\n DefinitionTableRelations,\n FieldRelationConfig,\n Schema,\n SchemaRelationDefinitions,\n SchemaTableDefinitions,\n SchemaTableRelations,\n SchemaUnionDefinitions,\n DefinitionUnionName,\n TableRelationFieldName,\n} from \"./base.js\";\nexport { Column, type AnyColumn } from \"./column.js\";\nexport { ExecutionContext, type ExecutionContextOptions } from \"./context.js\";\nexport { CompositeQuery, ExecutableQuery, type Executable } from \"./executor.js\";\nexport { PolicyViolationError } from \"./errors.js\";\nexport {\n OperationsFactory,\n type AnyOperation,\n type CountOperation,\n type CountOperationArgs,\n type DeleteOperation,\n type DeleteOperationArgs,\n type FieldMutation,\n type FieldResolver,\n type FieldResolverEntry,\n type FieldSelection,\n type InsertOperation,\n type InsertOperationArgs,\n type Operation,\n type OperationMode,\n type OperationRequest,\n type OperationResult,\n type OperationType,\n type OrderByEntry,\n type RelationSelection,\n type SelectOperation,\n type SelectOperationArgs,\n type UpdateOperation,\n type UpdateOperationArgs,\n type UnionSelectOperationArgs,\n type UnionSelectOperation,\n type UnionCountOperationArgs,\n UnionResolver,\n} from \"./operation.js\";\nexport { ComputedDiscriminator } from \"./reference.js\";\nexport type { RuntimeRelation, TableRelation, UnionRelation } from \"./relation.js\";\nexport { buildSchema, type BuiltSchema } from \"./build.js\";\nexport type {\n ColumnReference,\n ReferenceEnd,\n ResolvedReferences,\n TableReference,\n UnionReference,\n} from \"./reference.js\";\nexport {\n QueryBuilder,\n type DeleteParams,\n type InsertParams,\n type JoinParams,\n type SelectParams,\n type TableJoinParams,\n type UnionBranchParams,\n type UnionJoinParams,\n type UnionSelectParams,\n type UpdateParams,\n} from \"./query.js\";\nexport {\n SchemaRegistry,\n type RuntimeTables,\n type TableByAlias,\n type TableByName,\n type TableByNameOrAlias,\n type RuntimeUnions,\n} from \"./registry.js\";\nexport type { Session, TransactionSession } from \"./session.js\";\nexport { Table, type AnyTable } from \"./table.js\";\nexport { Union, type AnyUnion } from \"./union.js\";\nexport { Policy, resolvePolicy, type AnyPolicy, type RuntimePolicyConfig } from \"./policy.js\";\n"]}