@prisma/orm-framework 8.0.0-rc.14-dev.35 → 8.0.0-rc.14-dev.37

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 (107) hide show
  1. package/dist/{authoring-CUDReFVP.d.mts → authoring-CcT010vl.d.mts} +5 -5
  2. package/dist/{authoring-CUDReFVP.d.mts.map → authoring-CcT010vl.d.mts.map} +1 -1
  3. package/dist/{authoring-Cp71GImA.mjs → authoring-iMWszF7p.mjs} +15 -5
  4. package/dist/authoring-iMWszF7p.mjs.map +1 -0
  5. package/dist/{binder-Dz5zT7tr-CCCwiQ29.d.mts → binder-Dz5zT7tr-UEfDpcxO.d.mts} +9 -9
  6. package/dist/{binder-Dz5zT7tr-CCCwiQ29.d.mts.map → binder-Dz5zT7tr-UEfDpcxO.d.mts.map} +1 -1
  7. package/dist/{codec-0XB-9TzG.d.mts → codec-BSm2qNVe.d.mts} +4 -8
  8. package/dist/codec-BSm2qNVe.d.mts.map +1 -0
  9. package/dist/{codec-Cz-bOon3.mjs → codec-U-xbQys_.mjs} +12 -7
  10. package/dist/codec-U-xbQys_.mjs.map +1 -0
  11. package/dist/{codec-types-CZ8xRBJy-BMjCsUt1.d.mts → codec-types-8NKqm4AQ-DyNSay3e.d.mts} +17 -5
  12. package/dist/codec-types-8NKqm4AQ-DyNSay3e.d.mts.map +1 -0
  13. package/dist/{components-CRRIFm30.d.mts → components-CK8GHz8l.d.mts} +4 -4
  14. package/dist/{components-CRRIFm30.d.mts.map → components-CK8GHz8l.d.mts.map} +1 -1
  15. package/dist/components.d.mts +18 -18
  16. package/dist/components.mjs +7 -7
  17. package/dist/components__authoring.d.mts +4 -4
  18. package/dist/components__authoring.mjs +3 -3
  19. package/dist/components__codec.d.mts +3 -3
  20. package/dist/components__codec.mjs +3 -3
  21. package/dist/components__components.d.mts +3 -3
  22. package/dist/components__control.d.mts +4 -4
  23. package/dist/components__control.mjs +3 -3
  24. package/dist/components__emission.d.mts +3 -3
  25. package/dist/components__execution.d.mts +1 -1
  26. package/dist/components__ir.d.mts +1 -1
  27. package/dist/components__psl-ast.d.mts +3 -3
  28. package/dist/components__runtime.d.mts +2 -2
  29. package/dist/components__runtime.mjs +2 -2
  30. package/dist/{config-types-E4OZwoHK.d.mts → config-types-D7Gkm2iv.d.mts} +6 -6
  31. package/dist/{config-types-E4OZwoHK.d.mts.map → config-types-D7Gkm2iv.d.mts.map} +1 -1
  32. package/dist/config.d.mts +1 -1
  33. package/dist/config__config-types.d.mts +1 -1
  34. package/dist/contract-authoring.d.mts +10 -13
  35. package/dist/contract-authoring.d.mts.map +1 -1
  36. package/dist/contract-authoring.mjs +1 -3
  37. package/dist/contract-authoring.mjs.map +1 -1
  38. package/dist/{control-D9TxxGse.mjs → control-BIv_-3QB.mjs} +20 -5
  39. package/dist/control-BIv_-3QB.mjs.map +1 -0
  40. package/dist/{control-DtFLqCvx.d.mts → control-C1x8zzHb.d.mts} +56 -41
  41. package/dist/control-C1x8zzHb.d.mts.map +1 -0
  42. package/dist/{declarations-DDT0hm5r-D_XDM-WN.mjs → declarations-DDT0hm5r-BZoOKiu1.mjs} +2 -2
  43. package/dist/{declarations-DDT0hm5r-D_XDM-WN.mjs.map → declarations-DDT0hm5r-BZoOKiu1.mjs.map} +1 -1
  44. package/dist/emission-D9NsURmS.d.mts +2 -0
  45. package/dist/{emission-types-CKbNqwUs-hrIslUsL.d.mts → emission-types-BpY3maMX-pzm7Xmn7.d.mts} +4 -4
  46. package/dist/{emission-types-CKbNqwUs-hrIslUsL.d.mts.map → emission-types-BpY3maMX-pzm7Xmn7.d.mts.map} +1 -1
  47. package/dist/errors.d.mts +1 -1
  48. package/dist/errors__execution.d.mts +1 -1
  49. package/dist/{execution-ZWG0tqRB.d.mts → execution-gjfB1CvH.d.mts} +2 -2
  50. package/dist/{execution-ZWG0tqRB.d.mts.map → execution-gjfB1CvH.d.mts.map} +1 -1
  51. package/dist/{execution-DHWSU95b.d.mts → execution-o-z5gzZh.d.mts} +2 -2
  52. package/dist/{execution-DHWSU95b.d.mts.map → execution-o-z5gzZh.d.mts.map} +1 -1
  53. package/dist/{framework-authoring-BJf_-FTJ-K8fp3V_r.d.mts → framework-authoring-DRrZ8_s0-CJ7XXqvx.d.mts} +37 -4
  54. package/dist/framework-authoring-DRrZ8_s0-CJ7XXqvx.d.mts.map +1 -0
  55. package/dist/{framework-components-7SQpxVko-BaUd55aP.d.mts → framework-components-DDr6lZoZ-EpXYrZj7.d.mts} +6 -12
  56. package/dist/framework-components-DDr6lZoZ-EpXYrZj7.d.mts.map +1 -0
  57. package/dist/ids.d.mts +1 -1
  58. package/dist/ids.mjs +1 -4
  59. package/dist/ids.mjs.map +1 -1
  60. package/dist/{ir-BOKp6I1y.d.mts → ir-bkQr_x1E.d.mts} +2 -2
  61. package/dist/{ir-BOKp6I1y.d.mts.map → ir-bkQr_x1E.d.mts.map} +1 -1
  62. package/dist/{mutation-default-types-CrA6rrwU-BkMgh2pO.d.mts → mutation-default-types-D_M8NC3U-BQNexfRU.d.mts} +3 -3
  63. package/dist/{mutation-default-types-CrA6rrwU-BkMgh2pO.d.mts.map → mutation-default-types-D_M8NC3U-BQNexfRU.d.mts.map} +1 -1
  64. package/dist/{parse-eSQ_clQv-BIek6vrj.d.mts → parse-eSQ_clQv-BQKtf4px.d.mts} +6 -6
  65. package/dist/{parse-eSQ_clQv-BIek6vrj.d.mts.map → parse-eSQ_clQv-BQKtf4px.d.mts.map} +1 -1
  66. package/dist/{parse-ymgXJUnk-SzrYveCt.mjs → parse-ymgXJUnk-CwVCe8ZD.mjs} +2 -2
  67. package/dist/{parse-ymgXJUnk-SzrYveCt.mjs.map → parse-ymgXJUnk-CwVCe8ZD.mjs.map} +1 -1
  68. package/dist/{psl-ast-DtjFlM-c-amCHIsWc.d.mts → psl-ast-BVYEC5xX-BEqjBVqF.d.mts} +3 -3
  69. package/dist/{psl-ast-DtjFlM-c-amCHIsWc.d.mts.map → psl-ast-BVYEC5xX-BEqjBVqF.d.mts.map} +1 -1
  70. package/dist/psl-ast-a1L1ep0a.d.mts +2 -0
  71. package/dist/psl-parser.d.mts +8 -8
  72. package/dist/psl-parser.mjs +19 -6
  73. package/dist/psl-parser.mjs.map +1 -1
  74. package/dist/psl-parser__format.d.mts +1 -1
  75. package/dist/psl-parser__format.mjs +2 -2
  76. package/dist/psl-parser__interpret.d.mts +6 -6
  77. package/dist/psl-parser__interpret.mjs +1 -1
  78. package/dist/psl-parser__syntax.d.mts +1 -1
  79. package/dist/psl-parser__syntax.mjs +2 -2
  80. package/dist/psl-printer.d.mts +4 -4
  81. package/dist/psl-printer.mjs +1 -1
  82. package/dist/{resolve-codec-qE0g980d-Ck_gIaTi.mjs → resolve-codec-vOfdHcIJ-IeNjz3Tm.mjs} +6 -5
  83. package/dist/resolve-codec-vOfdHcIJ-IeNjz3Tm.mjs.map +1 -0
  84. package/dist/{runtime-DhUFoLHx.mjs → runtime-7NCyLoeP.mjs} +109 -5
  85. package/dist/{runtime-DhUFoLHx.mjs.map → runtime-7NCyLoeP.mjs.map} +1 -1
  86. package/dist/{runtime-BccsLa5m.d.mts → runtime-NuBiQEuH.d.mts} +45 -3
  87. package/dist/runtime-NuBiQEuH.d.mts.map +1 -0
  88. package/dist/{temporal-presets-pC0xlwib-Diikns1l.d.mts → temporal-presets-CLsu00ZK-CAx-cLAM.d.mts} +4 -4
  89. package/dist/{temporal-presets-pC0xlwib-Diikns1l.d.mts.map → temporal-presets-CLsu00ZK-CAx-cLAM.d.mts.map} +1 -1
  90. package/dist/{temporal-presets-UoKnoAlu-6864WUSv.mjs → temporal-presets-DIo9uYtS-Odk6WBk8.mjs} +19 -3
  91. package/dist/temporal-presets-DIo9uYtS-Odk6WBk8.mjs.map +1 -0
  92. package/dist/{types-import-spec-BLFYPur6-QN7ntocb.d.mts → types-import-spec-U2GFdg-x-CRt_XdWj.d.mts} +3 -3
  93. package/dist/{types-import-spec-BLFYPur6-QN7ntocb.d.mts.map → types-import-spec-U2GFdg-x-CRt_XdWj.d.mts.map} +1 -1
  94. package/package.json +15 -15
  95. package/dist/authoring-Cp71GImA.mjs.map +0 -1
  96. package/dist/codec-0XB-9TzG.d.mts.map +0 -1
  97. package/dist/codec-Cz-bOon3.mjs.map +0 -1
  98. package/dist/codec-types-CZ8xRBJy-BMjCsUt1.d.mts.map +0 -1
  99. package/dist/control-D9TxxGse.mjs.map +0 -1
  100. package/dist/control-DtFLqCvx.d.mts.map +0 -1
  101. package/dist/emission-CKIZBZw3.d.mts +0 -2
  102. package/dist/framework-authoring-BJf_-FTJ-K8fp3V_r.d.mts.map +0 -1
  103. package/dist/framework-components-7SQpxVko-BaUd55aP.d.mts.map +0 -1
  104. package/dist/psl-ast-CcQp_u_l.d.mts +0 -2
  105. package/dist/resolve-codec-qE0g980d-Ck_gIaTi.mjs.map +0 -1
  106. package/dist/runtime-BccsLa5m.d.mts.map +0 -1
  107. package/dist/temporal-presets-UoKnoAlu-6864WUSv.mjs.map +0 -1
@@ -1,11 +1,11 @@
1
1
  import { t as Contract } from "./contract-types-BIaUtO7Z-Bcxx2I74.mjs";
2
- import { C as AuthoringPslBlockDescriptorNamespace, D as AuthoringTypeConstructorDescriptor, Q as instantiateAuthoringFieldPreset, U as PslSpan, n as AuthoringArgumentDescriptor, p as AuthoringFieldPresetDescriptor } from "./framework-authoring-BJf_-FTJ-K8fp3V_r.mjs";
3
- import "./authoring-CUDReFVP.mjs";
2
+ import { $ as instantiateAuthoringFieldPreset, C as AuthoringPslBlockDescriptorNamespace, D as AuthoringTypeConstructorDescriptor, U as PslSpan, n as AuthoringArgumentDescriptor, p as AuthoringFieldPresetDescriptor } from "./framework-authoring-DRrZ8_s0-CJ7XXqvx.mjs";
3
+ import "./authoring-CcT010vl.mjs";
4
4
  import { r as Result } from "./result-BYCOANWy.mjs";
5
- import "./psl-ast-CcQp_u_l.mjs";
6
- import { c as ContractSourceProvider, n as ContractSourceContext, o as ContractSourceDiagnostics, p as PslContractSourceProvider, r as ContractSourceDiagnostic } from "./config-types-E4OZwoHK.mjs";
7
- import { L as PslDiagnostic, R as PslDiagnosticCollector, d as DiagnosticSource, f as DocumentAst, z as PslSources } from "./parse-eSQ_clQv-BIek6vrj.mjs";
8
- import { Ct as ResolvedTypeConstructorCall, Et as SymbolTable, I as FieldSymbol, bt as ResolvedAttributeArg, l as Binder, p as BlockSymbol } from "./binder-Dz5zT7tr-CCCwiQ29.mjs";
5
+ import "./psl-ast-a1L1ep0a.mjs";
6
+ import { c as ContractSourceProvider, n as ContractSourceContext, o as ContractSourceDiagnostics, p as PslContractSourceProvider, r as ContractSourceDiagnostic } from "./config-types-D7Gkm2iv.mjs";
7
+ import { L as PslDiagnostic, R as PslDiagnosticCollector, d as DiagnosticSource, f as DocumentAst, z as PslSources } from "./parse-eSQ_clQv-BQKtf4px.mjs";
8
+ import { Ct as ResolvedTypeConstructorCall, Et as SymbolTable, I as FieldSymbol, bt as ResolvedAttributeArg, l as Binder, p as BlockSymbol } from "./binder-Dz5zT7tr-UEfDpcxO.mjs";
9
9
  //#region ../../../1-framework/2-authoring/psl-parser/dist/interpret.d.mts
10
10
  //#region src/authoring-arguments.d.ts
11
11
  /**
@@ -1,5 +1,5 @@
1
1
  import { n as notOk } from "./result-8OXF26MN.mjs";
2
- import { P as validateAuthoringHelperArguments, h as instantiateAuthoringFieldPreset, x as isAuthoringPslBlockDescriptor } from "./temporal-presets-UoKnoAlu-6864WUSv.mjs";
2
+ import { L as validateAuthoringHelperArguments, S as isAuthoringPslBlockDescriptor, g as instantiateAuthoringFieldPreset } from "./temporal-presets-DIo9uYtS-Odk6WBk8.mjs";
3
3
  import { i as keywordPslSpan, o as nodePslSpan, r as diagnosticSource } from "./resolve-C8PUf8zv-QAvnPhCt.mjs";
4
4
  //#region ../../../1-framework/2-authoring/psl-parser/dist/interpret.mjs
5
5
  function unquoteStringLiteral(value) {
@@ -1,5 +1,5 @@
1
1
  import { n as TokenKind } from "./tokenizer-DW30uwhx-BHsWTwYk.mjs";
2
- import { $ as any, A as NumberLiteralExprAst, B as QualifiedNameAst, C as IdentifierAst, D as NamedTypeDeclarationAst, E as ModelDeclarationAst, F as PathExprAst, G as SyntaxElement, H as SourceFile, I as Position, J as SyntaxToken, K as SyntaxKind, M as ObjectLiteralExprAst, N as ParseDiagnostic, O as NamespaceDeclarationAst, P as ParseResult, Q as TypesBlockAst, S as HasDocComment, T as ModelAttributeAst, U as StringLiteralExprAst, V as Range, W as StringLiteralQuote, X as TokenAtOffset, Y as TaggedLiteralExprAst, Z as TypeAnnotationAst, _ as GenericBlockDeclarationAst, a as AttributeAst, at as dottedPathsIn, b as GreenNode, c as BracedBlock, ct as findFirstChild, et as castExpression, f as DocumentAst, ft as parse, g as FunctionCallAst, h as FieldDeclarationAst, i as AttributeArgListAst, j as ObjectFieldAst, k as NamespaceMemberAst, l as CompositeTypeDeclarationAst, lt as greenNode, m as FieldAttributeAst, n as AstNode, nt as createSyntaxTree, o as BlockMemberAst, ot as filterChildren, p as ExpressionAst, pt as printSyntax, q as SyntaxNode, r as AttributeArgAst, s as BooleanLiteralExprAst, st as findChildToken, t as ArrayLiteralAst, u as DeclarationAst, ut as greenToken, v as GenericBlockMemberAst, w as KeyValuePairAst, x as GreenToken, y as GreenElement, z as PslSources } from "./parse-eSQ_clQv-BIek6vrj.mjs";
2
+ import { $ as any, A as NumberLiteralExprAst, B as QualifiedNameAst, C as IdentifierAst, D as NamedTypeDeclarationAst, E as ModelDeclarationAst, F as PathExprAst, G as SyntaxElement, H as SourceFile, I as Position, J as SyntaxToken, K as SyntaxKind, M as ObjectLiteralExprAst, N as ParseDiagnostic, O as NamespaceDeclarationAst, P as ParseResult, Q as TypesBlockAst, S as HasDocComment, T as ModelAttributeAst, U as StringLiteralExprAst, V as Range, W as StringLiteralQuote, X as TokenAtOffset, Y as TaggedLiteralExprAst, Z as TypeAnnotationAst, _ as GenericBlockDeclarationAst, a as AttributeAst, at as dottedPathsIn, b as GreenNode, c as BracedBlock, ct as findFirstChild, et as castExpression, f as DocumentAst, ft as parse, g as FunctionCallAst, h as FieldDeclarationAst, i as AttributeArgListAst, j as ObjectFieldAst, k as NamespaceMemberAst, l as CompositeTypeDeclarationAst, lt as greenNode, m as FieldAttributeAst, n as AstNode, nt as createSyntaxTree, o as BlockMemberAst, ot as filterChildren, p as ExpressionAst, pt as printSyntax, q as SyntaxNode, r as AttributeArgAst, s as BooleanLiteralExprAst, st as findChildToken, t as ArrayLiteralAst, u as DeclarationAst, ut as greenToken, v as GenericBlockMemberAst, w as KeyValuePairAst, x as GreenToken, y as GreenElement, z as PslSources } from "./parse-eSQ_clQv-BQKtf4px.mjs";
3
3
  //#region ../../../1-framework/2-authoring/psl-parser/dist/syntax.d.mts
4
4
  //#region src/syntax/green-builder.d.ts
5
5
  declare class GreenNodeBuilder {
@@ -1,6 +1,6 @@
1
1
  import { a as createSyntaxTree, c as findFirstChild, i as any, l as printSyntax, n as SyntaxToken, o as filterChildren, r as TokenAtOffset, s as findChildToken, t as SyntaxNode } from "./ast-helpers-CzydMPdh-Mi0SrZRa.mjs";
2
- import { C as TaggedLiteralExprAst, D as dottedPathsIn, E as castExpression, S as StringLiteralExprAst, T as TypesBlockAst, _ as NumberLiteralExprAst, a as CompositeTypeDeclarationAst, b as PathExprAst, c as FieldDeclarationAst, d as IdentifierAst, f as KeyValuePairAst, g as NamespaceDeclarationAst, h as NamedTypeDeclarationAst, i as BooleanLiteralExprAst, l as FunctionCallAst, m as ModelDeclarationAst, n as AttributeArgAst, o as DocumentAst, p as ModelAttributeAst, r as AttributeArgListAst, s as FieldAttributeAst, t as ArrayLiteralAst, u as GenericBlockDeclarationAst, v as ObjectFieldAst, w as TypeAnnotationAst, x as QualifiedNameAst, y as ObjectLiteralExprAst } from "./declarations-DDT0hm5r-D_XDM-WN.mjs";
3
- import { a as greenToken, i as greenNode, n as PslSources, o as parse, r as SourceFile, t as GreenNodeBuilder } from "./parse-ymgXJUnk-SzrYveCt.mjs";
2
+ import { C as TaggedLiteralExprAst, D as dottedPathsIn, E as castExpression, S as StringLiteralExprAst, T as TypesBlockAst, _ as NumberLiteralExprAst, a as CompositeTypeDeclarationAst, b as PathExprAst, c as FieldDeclarationAst, d as IdentifierAst, f as KeyValuePairAst, g as NamespaceDeclarationAst, h as NamedTypeDeclarationAst, i as BooleanLiteralExprAst, l as FunctionCallAst, m as ModelDeclarationAst, n as AttributeArgAst, o as DocumentAst, p as ModelAttributeAst, r as AttributeArgListAst, s as FieldAttributeAst, t as ArrayLiteralAst, u as GenericBlockDeclarationAst, v as ObjectFieldAst, w as TypeAnnotationAst, x as QualifiedNameAst, y as ObjectLiteralExprAst } from "./declarations-DDT0hm5r-BZoOKiu1.mjs";
3
+ import { a as greenToken, i as greenNode, n as PslSources, o as parse, r as SourceFile, t as GreenNodeBuilder } from "./parse-ymgXJUnk-CwVCe8ZD.mjs";
4
4
  //#region ../../../1-framework/2-authoring/psl-parser/dist/syntax.mjs
5
5
  const TRIVIA_KINDS = /* @__PURE__ */ new Set([
6
6
  "Whitespace",
@@ -1,7 +1,7 @@
1
- import { C as AuthoringPslBlockDescriptorNamespace } from "./framework-authoring-BJf_-FTJ-K8fp3V_r.mjs";
2
- import "./authoring-CUDReFVP.mjs";
3
- import { f as PslDocumentAst } from "./psl-ast-DtjFlM-c-amCHIsWc.mjs";
4
- import "./psl-ast-CcQp_u_l.mjs";
1
+ import { C as AuthoringPslBlockDescriptorNamespace } from "./framework-authoring-DRrZ8_s0-CJ7XXqvx.mjs";
2
+ import "./authoring-CcT010vl.mjs";
3
+ import { f as PslDocumentAst } from "./psl-ast-BVYEC5xX-BEqjBVqF.mjs";
4
+ import "./psl-ast-a1L1ep0a.mjs";
5
5
  //#region ../../../1-framework/2-authoring/psl-printer/dist/index.d.mts
6
6
  //#region src/print-psl.d.ts
7
7
  type PslBlockDescriptorsNamespace = AuthoringPslBlockDescriptorNamespace;
@@ -1,6 +1,6 @@
1
1
  import { t as ifDefined } from "./defined-BQWA85QH-BRSBMULx.mjs";
2
2
  import { o as structuredError } from "./structured-error-BXbihKQ-.mjs";
3
- import { x as isAuthoringPslBlockDescriptor } from "./temporal-presets-UoKnoAlu-6864WUSv.mjs";
3
+ import { S as isAuthoringPslBlockDescriptor } from "./temporal-presets-DIo9uYtS-Odk6WBk8.mjs";
4
4
  import { a as flatPslModels, c as namespacePslExtensionBlocks } from "./psl-ast-CyvE6CR-.mjs";
5
5
  //#region ../../../1-framework/2-authoring/psl-printer/dist/index.mjs
6
6
  function contractError(code, message, options) {
@@ -1,11 +1,12 @@
1
1
  import { t as blindCast } from "./casts-DpaahrlC-Bd5n2coI.mjs";
2
2
  import { t as ifDefined } from "./defined-BQWA85QH-BRSBMULx.mjs";
3
3
  import { n as runtimeError } from "./runtime-error-BA9d7XjZ-BlT8t6LB.mjs";
4
- //#region ../../../1-framework/1-core/framework-components/dist/resolve-codec-qE0g980d.mjs
5
- const DATA_TYPE_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*\/[a-z0-9]+(?:-[a-z0-9]+)*$/;
4
+ //#region ../../../1-framework/1-core/framework-components/dist/resolve-codec-vOfdHcIJ.mjs
5
+ /** The whole of what a data type id is: `owner/name` in lower case, with no version. */
6
+ const DATA_TYPE_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*\/[a-z0-9]+(?:-[a-z0-9]+)*$/;
6
7
  /** Read `id` as a data type id, refusing anything that is not `owner/name` in lower case. */
7
8
  function dataTypeId(id) {
8
- if (!DATA_TYPE_ID.test(id)) throw runtimeError("CONTRACT.DATA_TYPE_ID_INVALID", `"${id}" is not a data type id. A data type id is "owner/name" in lower case and carries no version, as in "owner/name"; a versioned id names a codec.`, { id });
9
+ if (!DATA_TYPE_ID_PATTERN.test(id)) throw runtimeError("CONTRACT.DATA_TYPE_ID_INVALID", `"${id}" is not a data type id. A data type id is "owner/name" in lower case and carries no version, as in "owner/name"; a versioned id names a codec.`, { id });
9
10
  return blindCast(id);
10
11
  }
11
12
  /** Declare a data type. Every id it names, its own and each cast's source, is validated here. */
@@ -157,6 +158,6 @@ function codecForRef(lookup, ref) {
157
158
  return descriptor === void 0 ? void 0 : materializeCodec(descriptor, ref, { name: ref.codecId });
158
159
  }
159
160
  //#endregion
160
- export { createDataTypeLookup as a, materializeCodec as c, requiredSchemaKeys as d, resolveCodecDescriptorOrThrow as f, codecForRef as i, objectSchemaKeys as l, assembleDataTypes as n, dataType as o, validateCodecTypeParams as p, codecDescriptorMissing as r, dataTypeId as s, CONTRACT_CODEC_DESCRIPTOR_MISSING as t, requiredParamKeys as u };
161
+ export { codecForRef as a, dataTypeId as c, requiredParamKeys as d, requiredSchemaKeys as f, codecDescriptorMissing as i, materializeCodec as l, validateCodecTypeParams as m, DATA_TYPE_ID_PATTERN as n, createDataTypeLookup as o, resolveCodecDescriptorOrThrow as p, assembleDataTypes as r, dataType as s, CONTRACT_CODEC_DESCRIPTOR_MISSING as t, objectSchemaKeys as u };
161
162
 
162
- //# sourceMappingURL=resolve-codec-qE0g980d-Ck_gIaTi.mjs.map
163
+ //# sourceMappingURL=resolve-codec-vOfdHcIJ-IeNjz3Tm.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-codec-vOfdHcIJ-IeNjz3Tm.mjs","names":[],"sources":["../../../../1-framework/1-core/framework-components/dist/resolve-codec-vOfdHcIJ.mjs"],"sourcesContent":["import { n as runtimeError } from \"./runtime-error-BA9d7XjZ.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\n//#region src/shared/data-type.ts\n/** The whole of what a data type id is: `owner/name` in lower case, with no version. */\nconst DATA_TYPE_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*\\/[a-z0-9]+(?:-[a-z0-9]+)*$/;\n/** Read `id` as a data type id, refusing anything that is not `owner/name` in lower case. */\nfunction dataTypeId(id) {\n\tif (!DATA_TYPE_ID_PATTERN.test(id)) throw runtimeError(\"CONTRACT.DATA_TYPE_ID_INVALID\", `\"${id}\" is not a data type id. A data type id is \"owner/name\" in lower case and carries no version, as in \"owner/name\"; a versioned id names a codec.`, { id });\n\treturn blindCast(id);\n}\n/** Declare a data type. Every id it names, its own and each cast's source, is validated here. */\nfunction dataType(id, spec) {\n\tconst casts = {};\n\tfor (const [source, cast] of Object.entries(spec.casts ?? {})) casts[dataTypeId(source)] = cast;\n\tconst listCast = spec.listCast;\n\treturn {\n\t\tid: dataTypeId(id),\n\t\t...ifDefined(\"params\", spec.params),\n\t\tcasts,\n\t\t...listCast === void 0 ? {} : { listCast: {\n\t\t\tof: listCast.of.map(dataTypeId),\n\t\t\tcast: listCast.cast\n\t\t} },\n\t\t...spec.toCanonicalForm === void 0 ? {} : { toCanonicalForm: spec.toCanonicalForm }\n\t};\n}\nfunction isSchemaPropList(value) {\n\treturn Array.isArray(value) && value.every((prop) => prop !== null && (typeof prop === \"object\" || typeof prop === \"function\") && \"key\" in prop);\n}\nfunction describesObjects(schema) {\n\tconst extendsType = Reflect.get(schema, \"extends\");\n\treturn typeof extendsType === \"function\" && extendsType.call(schema, \"object\") === true;\n}\nfunction objectSchemaProps(schema) {\n\tif (schema === null || typeof schema !== \"object\" && typeof schema !== \"function\") return;\n\tif (!describesObjects(schema)) return void 0;\n\tconst props = readProps(schema);\n\treturn isSchemaPropList(props) ? props : void 0;\n}\n/** Arktype throws from `props` for a union or a morph, whose keys it cannot list. */\nfunction readProps(schema) {\n\ttry {\n\t\treturn Reflect.get(schema, \"props\");\n\t} catch {\n\t\treturn;\n\t}\n}\n/** The keys an arktype object schema declares, or undefined when `schema` is not one. */\nfunction objectSchemaKeys(schema) {\n\treturn objectSchemaProps(schema)?.flatMap((prop) => typeof prop.key === \"string\" ? [prop.key] : []);\n}\n/** The required keys an arktype object schema declares, or undefined when `schema` is not one. */\nfunction requiredSchemaKeys(schema) {\n\treturn objectSchemaProps(schema)?.flatMap((prop) => prop.kind === \"required\" && typeof prop.key === \"string\" ? [prop.key] : []);\n}\n/** The parameters a data type requires. */\nfunction requiredParamKeys(type) {\n\treturn requiredSchemaKeys(type.params) ?? [];\n}\nfunction createDataTypeLookup(types) {\n\tconst byId = new Map(types.map((type) => [type.id, type]));\n\treturn {\n\t\tget: (id) => byId.get(id),\n\t\thas: (id) => byId.has(id)\n\t};\n}\n/** Collect every data type the composed components register, refusing two declarations of one id. */\nfunction assembleDataTypes(descriptors) {\n\tconst declared = [];\n\tconst owners = /* @__PURE__ */ new Map();\n\tfor (const descriptor of descriptors) {\n\t\tconst contributedBy = descriptor.id ?? \"<unknown>\";\n\t\tfor (const type of descriptor.dataTypes ?? []) {\n\t\t\tconst existingOwner = owners.get(type.id);\n\t\t\tif (existingOwner !== void 0) throw runtimeError(\"CONTRACT.DATA_TYPE_DUPLICATE\", `Duplicate data type \"${type.id}\". Component \"${contributedBy}\" conflicts with \"${existingOwner}\". Each data type has exactly one owner across the composed stack.`, {\n\t\t\t\tdataType: type.id,\n\t\t\t\tcontributedBy,\n\t\t\t\towner: existingOwner\n\t\t\t});\n\t\t\towners.set(type.id, contributedBy);\n\t\t\tdeclared.push({\n\t\t\t\ttype,\n\t\t\t\tcontributedBy\n\t\t\t});\n\t\t}\n\t}\n\treturn {\n\t\tlookup: createDataTypeLookup(declared.map((entry) => entry.type)),\n\t\tdeclared\n\t};\n}\n//#endregion\n//#region src/shared/resolve-codec.ts\nconst CONTRACT_CODEC_DESCRIPTOR_MISSING = \"CONTRACT.CODEC_DESCRIPTOR_MISSING\";\n/**\n* Look up a descriptor for `ref.codecId` using `descriptorFor`; throw\n* `code` if none is found. Each plane names its own error path: the control\n* plane resolves contract-stack descriptors (`CONTRACT.*`), the execution\n* plane resolves at query time (`RUNTIME.*`).\n*/\nfunction resolveCodecDescriptorOrThrow(descriptorFor, ref, code) {\n\treturn descriptorFor(ref.codecId) ?? codecDescriptorMissing(ref, code);\n}\n/** Throws the error for a codec reference no descriptor has, under the plane's `code`. */\nfunction codecDescriptorMissing(ref, code) {\n\tthrow runtimeError(code, `No codec descriptor registered for codecId '${ref.codecId}'.`, { codecId: ref.codecId });\n}\nfunction isAbsentOrEmpty(typeParams) {\n\treturn typeParams === void 0 || typeof typeParams === \"object\" && typeParams !== null && !Array.isArray(typeParams) && Object.keys(typeParams).length === 0;\n}\n/**\n* Validates `ref.typeParams` against `descriptor.paramsSchema`.\n*\n* A codec without a `paramsSchema` takes no params: it accepts absent or empty\n* `typeParams` (a bare native-type alias carries `{}`) and rejects anything else.\n* A parameterized codec whose ref omits `typeParams` validates `{}` (mirrors\n* `ast-codec-resolver.ts` semantics). Throws `RUNTIME.TYPE_PARAMS_INVALID` when\n* params are given to a codec without params, or when the validator returns a\n* `Promise` or reports issues.\n*/\nfunction validateCodecTypeParams(descriptor, ref) {\n\tconst schema = descriptor.paramsSchema;\n\tif (schema === void 0) {\n\t\tif (!isAbsentOrEmpty(ref.typeParams)) throw runtimeError(\"RUNTIME.TYPE_PARAMS_INVALID\", `Invalid typeParams for codec '${ref.codecId}': unexpected typeParams for non-parameterized codec`, {\n\t\t\tcodecId: ref.codecId,\n\t\t\ttypeParams: ref.typeParams\n\t\t});\n\t\treturn;\n\t}\n\tconst result = blindCast(schema[\"~standard\"].validate(ref.typeParams ?? {}));\n\tif (result instanceof Promise) throw runtimeError(\"RUNTIME.TYPE_PARAMS_INVALID\", `paramsSchema for codec '${ref.codecId}' returned a Promise; runtime validation requires a synchronous Standard Schema validator.`, {\n\t\tcodecId: ref.codecId,\n\t\ttypeParams: ref.typeParams\n\t});\n\tif (\"issues\" in result && result.issues) {\n\t\tconst messages = result.issues.map((issue) => issue.message).join(\"; \");\n\t\tthrow runtimeError(\"RUNTIME.TYPE_PARAMS_INVALID\", `Invalid typeParams for codec '${ref.codecId}': ${messages}`, {\n\t\t\tcodecId: ref.codecId,\n\t\t\ttypeParams: ref.typeParams\n\t\t});\n\t}\n\treturn blindCast(result).value;\n}\n/**\n* Resolves a `Codec` instance: validates `ref.typeParams` via\n* {@link validateCodecTypeParams} then calls `descriptor.factory(validated)(ctx)`\n* as a method on `descriptor`, preserving `this` for factories that build\n* their returned codec from the descriptor instance (e.g. `new XCodec(this)`).\n*/\nfunction materializeCodec(descriptor, ref, ctx) {\n\tconst validated = validateCodecTypeParams(descriptor, ref);\n\treturn descriptor.factory(validated)(ctx);\n}\n/**\n* Builds the codec a codec reference names with the reference's type parameters, so a parameterized codec checks values against them. `undefined` when no descriptor has the id.\n*/\nfunction codecForRef(lookup, ref) {\n\tconst descriptor = lookup.descriptorFor(ref.codecId);\n\treturn descriptor === void 0 ? void 0 : materializeCodec(descriptor, ref, { name: ref.codecId });\n}\n//#endregion\nexport { resolveCodecDescriptorOrThrow as a, assembleDataTypes as c, dataTypeId as d, objectSchemaKeys as f, materializeCodec as i, createDataTypeLookup as l, requiredSchemaKeys as m, codecDescriptorMissing as n, validateCodecTypeParams as o, requiredParamKeys as p, codecForRef as r, DATA_TYPE_ID_PATTERN as s, CONTRACT_CODEC_DESCRIPTOR_MISSING as t, dataType as u };\n\n//# sourceMappingURL=resolve-codec-vOfdHcIJ.mjs.map"],"mappings":";;;;;AAKA,MAAM,uBAAuB;;AAE7B,SAAS,WAAW,IAAI;CACvB,IAAI,CAAC,qBAAqB,KAAK,EAAE,GAAG,MAAM,aAAa,iCAAiC,IAAI,GAAG,kJAAkJ,EAAE,GAAG,CAAC;CACvP,OAAO,UAAU,EAAE;AACpB;;AAEA,SAAS,SAAS,IAAI,MAAM;CAC3B,MAAM,QAAQ,CAAC;CACf,KAAK,MAAM,CAAC,QAAQ,SAAS,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,GAAG,MAAM,WAAW,MAAM,KAAK;CAC3F,MAAM,WAAW,KAAK;CACtB,OAAO;EACN,IAAI,WAAW,EAAE;EACjB,GAAG,UAAU,UAAU,KAAK,MAAM;EAClC;EACA,GAAG,aAAa,KAAK,IAAI,CAAC,IAAI,EAAE,UAAU;GACzC,IAAI,SAAS,GAAG,IAAI,UAAU;GAC9B,MAAM,SAAS;EAChB,EAAE;EACF,GAAG,KAAK,oBAAoB,KAAK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I;GACb,YAAY,IAAI;EACjB,CAAC;EACD;CACD;CACA,MAAM,SAAS,UAAU,OAAO,YAAY,CAAC,SAAS,IAAI,cAAc,CAAC,CAAC,CAAC;CAC3E,IAAI,kBAAkB,SAAS,MAAM,aAAa,+BAA+B,2BAA2B,IAAI,QAAQ,6FAA6F;EACpN,SAAS,IAAI;EACb,YAAY,IAAI;CACjB,CAAC;CACD,IAAI,YAAY,UAAU,OAAO,QAAQ;EACxC,MAAM,WAAW,OAAO,OAAO,KAAK,UAAU,MAAM,OAAO,CAAC,CAAC,KAAK,IAAI;EACtE,MAAM,aAAa,+BAA+B,iCAAiC,IAAI,QAAQ,KAAK,YAAY;GAC/G,SAAS,IAAI;GACb,YAAY,IAAI;EACjB,CAAC;CACF;CACA,OAAO,UAAU,MAAM,CAAC,CAAC;AAC1B;;;;;;;AAOA,SAAS,iBAAiB,YAAY,KAAK,KAAK;CAC/C,MAAM,YAAY,wBAAwB,YAAY,GAAG;CACzD,OAAO,WAAW,QAAQ,SAAS,CAAC,CAAC,GAAG;AACzC;;;;AAIA,SAAS,YAAY,QAAQ,KAAK;CACjC,MAAM,aAAa,OAAO,cAAc,IAAI,OAAO;CACnD,OAAO,eAAe,KAAK,IAAI,KAAK,IAAI,iBAAiB,YAAY,KAAK,EAAE,MAAM,IAAI,QAAQ,CAAC;AAChG"}
@@ -621,6 +621,94 @@ async function runExecuteWithMiddleware(exec, middleware, ctx, runDriver) {
621
621
  }, ctx);
622
622
  return stats;
623
623
  }
624
+ /**
625
+ * Calls each middleware's `afterTransaction` hook in registration order. A
626
+ * thrown error is passed to `ctx.log.error` and swallowed, and later
627
+ * middleware still run. Never rejects, so a query's result or a resolved
628
+ * commit is never replaced by a hook's failure.
629
+ */
630
+ async function runAfterTransaction(exec, middleware, result, ctx) {
631
+ for (const mw of middleware) {
632
+ if (!mw.afterTransaction) continue;
633
+ try {
634
+ await mw.afterTransaction(exec, result, ctx);
635
+ } catch (error) {
636
+ try {
637
+ ctx.log.error({
638
+ event: "middleware.afterTransaction.error",
639
+ middleware: mw.name,
640
+ error
641
+ });
642
+ } catch {}
643
+ }
644
+ }
645
+ }
646
+ /**
647
+ * Returns what a query outside a transaction calls when it ends: it runs `runStage` with `committed` when the query completed and `unknown` otherwise. Returns `undefined` when `runStage` is `undefined`.
648
+ */
649
+ function onQueryEndOutsideTransaction(runStage) {
650
+ if (runStage === void 0) return void 0;
651
+ return (ending) => runStage({ outcome: ending === "completed" ? "committed" : "unknown" });
652
+ }
653
+ /**
654
+ * Streams `rows()` and then calls `onQueryEnd` exactly once with how the query ended: `completed` when the stream completes, `failed` when an error comes out of it, and `stopped` when the caller stops reading, calls `return()` or throws into the iterator, before or after the first row. Returns `rows()` itself when `onQueryEnd` is `undefined`.
655
+ */
656
+ function reportQueryEnding(onQueryEnd, rows) {
657
+ return onQueryEnd === void 0 ? rows() : rowsThenQueryEnd(onQueryEnd, rows);
658
+ }
659
+ function rowsThenQueryEnd(onQueryEnd, rows) {
660
+ return { [Symbol.asyncIterator]() {
661
+ let thrownByCaller;
662
+ const generator = streamThenQueryEnd(onQueryEnd, rows, (error) => thrownByCaller !== void 0 && thrownByCaller.error === error);
663
+ let started = false;
664
+ const reportStoppedBeforeStart = async () => {
665
+ if (started) return;
666
+ started = true;
667
+ await onQueryEnd("stopped");
668
+ };
669
+ return {
670
+ next: () => {
671
+ started = true;
672
+ return generator.next();
673
+ },
674
+ return: async () => {
675
+ await reportStoppedBeforeStart();
676
+ return generator.return(void 0);
677
+ },
678
+ throw: async (error) => {
679
+ thrownByCaller = { error };
680
+ await reportStoppedBeforeStart();
681
+ return generator.throw(error);
682
+ }
683
+ };
684
+ } };
685
+ }
686
+ async function* streamThenQueryEnd(onQueryEnd, rows, isThrownByCaller) {
687
+ let ending = "stopped";
688
+ try {
689
+ yield* rows();
690
+ ending = "completed";
691
+ } catch (error) {
692
+ if (!isThrownByCaller(error)) ending = "failed";
693
+ throw error;
694
+ } finally {
695
+ await onQueryEnd(ending);
696
+ }
697
+ }
698
+ /**
699
+ * Runs `execute()` and then calls `onQueryEnd` exactly once: with `completed` when it resolves, and with `failed` when it rejects.
700
+ */
701
+ async function reportExecuteEnding(onQueryEnd, execute) {
702
+ if (onQueryEnd === void 0) return execute();
703
+ let ending = "failed";
704
+ try {
705
+ const result = await execute();
706
+ ending = "completed";
707
+ return result;
708
+ } finally {
709
+ await onQueryEnd(ending);
710
+ }
711
+ }
624
712
  async function notifyQueryCompletion(middleware, exec, ctx, result, swallowErrors) {
625
713
  for (const mw of middleware) {
626
714
  if (!mw.afterQuery) continue;
@@ -646,6 +734,13 @@ async function notifyQueryCompletion(middleware, exec, ctx, result, swallowError
646
734
  * 4. The matching runner processes `interceptQuery` or `interceptExecute`
647
735
  * before invoking the driver. Queries then fire `onRow` and `afterQuery`;
648
736
  * statements fire `afterExecute`.
737
+ * 5. Every operation whose lowering (which encodes parameters) and before-hooks
738
+ * succeeded fires `afterTransaction` once, as its last hook: `committed`
739
+ * when it completed, `unknown` when it threw or the caller stopped reading
740
+ * its rows. `reportQueryEnding` and `reportExecuteEnding` report how the
741
+ * operation ended, and `onQueryEndOutsideTransaction` turns that into the
742
+ * outcome; family runtimes that override `query` or `execute` call them
743
+ * too, with {@link afterTransactionStageFor}.
649
744
  *
650
745
  * Concrete subclasses must implement `lower`, `runDriver`, `runExecute`, and
651
746
  * `close`.
@@ -661,9 +756,18 @@ async function notifyQueryCompletion(middleware, exec, ctx, result, swallowError
661
756
  var RuntimeCore = class {
662
757
  middleware;
663
758
  ctx;
759
+ anyMiddlewareDeclaresAfterTransaction;
664
760
  constructor(options) {
665
- this.middleware = options.middleware;
761
+ this.middleware = [...options.middleware];
666
762
  this.ctx = options.ctx;
763
+ this.anyMiddlewareDeclaresAfterTransaction = this.middleware.some((mw) => mw.afterTransaction !== void 0);
764
+ }
765
+ /**
766
+ * Returns the function that runs every middleware's `afterTransaction` hook for one operation with a given result, or `undefined` when no middleware declared the hook when the runtime was created.
767
+ */
768
+ afterTransactionStageFor(exec, ctx) {
769
+ if (!this.anyMiddlewareDeclaresAfterTransaction) return void 0;
770
+ return (result) => runAfterTransaction(exec, this.middleware, result, ctx);
667
771
  }
668
772
  /**
669
773
  * Pre-lowering hook for plan rewriting. Defaults to identity. Subclasses
@@ -688,7 +792,7 @@ var RuntimeCore = class {
688
792
  const compiled = await self.runBeforeCompile(plan);
689
793
  const exec = await self.lower(compiled, codecCtx);
690
794
  await runBeforeQueryChain(exec, self.middleware, execCtx);
691
- yield* runQueryWithMiddleware(exec, self.middleware, execCtx, () => self.runDriver(exec));
795
+ yield* reportQueryEnding(onQueryEndOutsideTransaction(self.afterTransactionStageFor(exec, execCtx)), () => runQueryWithMiddleware(exec, self.middleware, execCtx, () => blindCast(self.runDriver(exec))));
692
796
  }
693
797
  return new AsyncIterableResult(generator());
694
798
  }
@@ -705,7 +809,7 @@ var RuntimeCore = class {
705
809
  const compiled = await this.runBeforeCompile(plan);
706
810
  const exec = await this.lower(compiled, codecCtx);
707
811
  await runBeforeExecuteChain(exec, this.middleware, execCtx);
708
- return runExecuteWithMiddleware(exec, this.middleware, execCtx, () => this.runExecute(exec));
812
+ return reportExecuteEnding(onQueryEndOutsideTransaction(this.afterTransactionStageFor(exec, execCtx)), () => runExecuteWithMiddleware(exec, this.middleware, execCtx, () => this.runExecute(exec)));
709
813
  }
710
814
  };
711
815
  function checkMiddlewareCompatibility(middleware, runtimeFamilyId, runtimeTargetId) {
@@ -760,6 +864,6 @@ function createMetaBuilder(kind, terminalName) {
760
864
  return new MetaBuilderImpl(kind, terminalName);
761
865
  }
762
866
  //#endregion
763
- export { runQueryWithMiddleware as _, applyMutationDefaults as a, checkAborted as c, createMetaBuilder as d, defineAnnotation as f, runExecuteWithMiddleware as g, runBeforeQueryChain as h, RuntimeCore as i, checkMiddlewareCompatibility as l, runBeforeExecuteChain as m, RUNTIME_ABORTED as n, assertAnnotationsApplicable as o, raceAgainstAbort as p, RelationKeys as r, assertMutationDefaultGeneratorsAvailable as s, AsyncIterableResult as t, collectMutationDefaultGenerators as u, runtimeAborted as v };
867
+ export { runtimeAborted as S, runAfterTransaction as _, applyMutationDefaults as a, runExecuteWithMiddleware as b, checkAborted as c, createMetaBuilder as d, defineAnnotation as f, reportQueryEnding as g, reportExecuteEnding as h, RuntimeCore as i, checkMiddlewareCompatibility as l, raceAgainstAbort as m, RUNTIME_ABORTED as n, assertAnnotationsApplicable as o, onQueryEndOutsideTransaction as p, RelationKeys as r, assertMutationDefaultGeneratorsAvailable as s, AsyncIterableResult as t, collectMutationDefaultGenerators as u, runBeforeExecuteChain as v, runQueryWithMiddleware as x, runBeforeQueryChain as y };
764
868
 
765
- //# sourceMappingURL=runtime-DhUFoLHx.mjs.map
869
+ //# sourceMappingURL=runtime-7NCyLoeP.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-DhUFoLHx.mjs","names":["#kind","#terminalName","#annotations"],"sources":["../../../../1-framework/1-core/framework-components/dist/runtime.mjs"],"sourcesContent":["import { n as runtimeError, t as isRuntimeError } from \"./runtime-error-BA9d7XjZ.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\n//#region src/execution/runtime-error.ts\n/**\n* Stable code emitted by the runtime when an in-flight `execute()`\n* is cancelled via the per-query `AbortSignal`. The envelope's\n* `details.phase` distinguishes where the abort was observed:\n*\n* - `'encode'` — abort fired during `encodeParams` (SQL) or\n* `resolveValue` (Mongo).\n* - `'decode'` — abort fired during `decodeRow` / `decodeField`.\n* - `'stream'` — abort fired between rows or before any codec call\n* (already-aborted at entry).\n* - `'beforeQuery'` / `'beforeExecute'` / `'afterQuery'` /\n* `'afterExecute'` / `'onRow'` — abort fired on entry to or during\n* the corresponding middleware phase\n* (cooperative cancellation per the param-transform seam).\n*/\nconst RUNTIME_ABORTED = \"RUNTIME.ABORTED\";\n/**\n* Construct a `RUNTIME.ABORTED` envelope. Phase distinguishes where the\n* abort was observed — codec call sites (`encode` / `decode` / `stream`)\n* or operation-specific middleware seams, as\n* enumerated on {@link RuntimeAbortedPhase}. Cause carries\n* `signal.reason` verbatim from the platform — native abort produces a\n* `DOMException`, explicit `controller.abort(reason)` produces whatever\n* the caller passed. No synthesis happens here.\n*/\nfunction runtimeAborted(phase, cause) {\n\tconst envelope = runtimeError(RUNTIME_ABORTED, `Operation aborted during ${phase}`, { phase });\n\treturn Object.assign(envelope, { cause });\n}\n//#endregion\n//#region src/annotations.ts\n/**\n* Defines a typed annotation handle.\n*\n* Two-step call form. The first step takes the `Payload` type argument\n* (TypeScript cannot infer `Payload` from anything in the options, so it\n* must be supplied explicitly); the second step takes the runtime options\n* and infers `Kinds` from the `applicableTo` array via a `const` type\n* parameter, so the operation kinds appear exactly once at the call site.\n*\n* @example\n* ```typescript\n* // Read-only annotation. Lane terminals like `db.User.first(...)` accept\n* // it; `db.User.create(...)` rejects it at the type level.\n* const cacheAnnotation = defineAnnotation<{ ttl?: number; skip?: boolean }>()({\n* namespace: 'cache',\n* applicableTo: ['read'],\n* }); // Kinds inferred as 'read'\n*\n* // Write-only annotation. Mirror image.\n* const auditAnnotation = defineAnnotation<{ actor: string }>()({\n* namespace: 'audit',\n* applicableTo: ['write'],\n* }); // Kinds inferred as 'write'\n*\n* // Annotation applicable to both kinds (e.g. tracing).\n* const otelAnnotation = defineAnnotation<{ traceId: string }>()({\n* namespace: 'otel',\n* applicableTo: ['read', 'write'],\n* }); // Kinds inferred as 'read' | 'write'\n* ```\n*\n* **Reserved namespaces.** See `DefineAnnotationOptions.namespace` for the\n* list of framework-internal namespaces (`codecs`, target-specific keys).\n* `defineAnnotation` does not structurally prevent a user from naming a\n* reserved namespace, but the framework makes no compatibility guarantee\n* about handles that do.\n*/\nfunction defineAnnotation() {\n\treturn (options) => {\n\t\tconst namespace = options.namespace;\n\t\tconst applicableTo = Object.freeze(new Set(options.applicableTo));\n\t\tfunction handle(value) {\n\t\t\treturn Object.freeze({\n\t\t\t\t__annotation: true,\n\t\t\t\tnamespace,\n\t\t\t\tvalue,\n\t\t\t\tapplicableTo\n\t\t\t});\n\t\t}\n\t\tfunction read(plan) {\n\t\t\tconst stored = plan.meta.annotations?.[namespace];\n\t\t\tif (!isAnnotationValue(stored)) return;\n\t\t\tif (stored.namespace !== namespace) return;\n\t\t\treturn stored.value;\n\t\t}\n\t\treturn Object.freeze(Object.assign(handle, {\n\t\t\tnamespace,\n\t\t\tapplicableTo,\n\t\t\tread\n\t\t}));\n\t};\n}\n/**\n* Runtime applicability gate. Throws `RUNTIME.ANNOTATION_INAPPLICABLE` if\n* any annotation in `annotations` declares an `applicableTo` set that does\n* not include `kind`. Used by lane terminals (SQL DSL builders' `.build()`,\n* ORM `Collection` terminals) to fail closed when the type-level\n* `ValidAnnotations` gate is bypassed via cast / `any` / dynamic\n* invocation.\n*\n* Passes silently on:\n* - empty arrays\n* - annotations whose `applicableTo` includes `kind`\n*\n* Throws on:\n* - any annotation whose `applicableTo` does not include `kind`. The\n* error names the offending annotation's `namespace` and the\n* `terminalName` so users can locate the misuse.\n*\n* @example\n* ```typescript\n* // Inside an ORM read terminal:\n* assertAnnotationsApplicable(annotations, 'read', 'first');\n* ```\n*/\nfunction assertAnnotationsApplicable(annotations, kind, terminalName) {\n\tfor (const annotation of annotations) if (!annotation.applicableTo.has(kind)) throw runtimeError(\"RUNTIME.ANNOTATION_INAPPLICABLE\", `Annotation '${annotation.namespace}' is not applicable to '${kind}' operations (terminal: '${terminalName}'). The annotation declares applicableTo = [${Array.from(annotation.applicableTo).map((k) => `'${k}'`).join(\", \")}].`, {\n\t\tnamespace: annotation.namespace,\n\t\tterminalName,\n\t\tkind,\n\t\tapplicableTo: Array.from(annotation.applicableTo)\n\t});\n}\n/**\n* Type guard for branded annotation values stored in `plan.meta.annotations`.\n*\n* Internal — used by `AnnotationHandle.read` to distinguish user\n* annotations (created by calling a handle returned from\n* `defineAnnotation(...)`) from framework-internal metadata that may\n* happen to live under the same namespace key.\n*/\nfunction isAnnotationValue(value) {\n\tif (value === null || typeof value !== \"object\") return false;\n\treturn value.__annotation === true;\n}\n//#endregion\n//#region src/execution/async-iterable-result.ts\nvar AsyncIterableResult = class {\n\tgenerator;\n\tconsumed = false;\n\tconsumedBy;\n\tbufferedArrayPromise;\n\tconstructor(generator) {\n\t\tthis.generator = generator;\n\t}\n\t[Symbol.asyncIterator]() {\n\t\tif (this.consumed) throw runtimeError(\"RUNTIME.ITERATOR_CONSUMED\", `AsyncIterableResult iterator has already been consumed via ${this.consumedBy === \"bufferedArray\" ? \"toArray()/then()\" : \"for-await loop\"}. Each AsyncIterableResult can only be iterated once.`, {\n\t\t\tconsumedBy: this.consumedBy,\n\t\t\tsuggestion: this.consumedBy === \"bufferedArray\" ? \"If you need to iterate multiple times, store the results from toArray() in a variable and reuse that.\" : \"If you need to iterate multiple times, use toArray() to collect all results first.\"\n\t\t});\n\t\tthis.consumed = true;\n\t\tthis.consumedBy = \"iterator\";\n\t\treturn this.generator;\n\t}\n\ttoArray() {\n\t\tif (this.consumedBy === \"iterator\") return Promise.reject(runtimeError(\"RUNTIME.ITERATOR_CONSUMED\", \"AsyncIterableResult iterator has already been consumed via for-await loop. Each AsyncIterableResult can only be iterated once.\", {\n\t\t\tconsumedBy: this.consumedBy,\n\t\t\tsuggestion: \"The iterator was already consumed by a for-await loop. Use toArray() or await the result before iterating.\"\n\t\t}));\n\t\tif (this.bufferedArrayPromise) return this.bufferedArrayPromise;\n\t\tthis.consumed = true;\n\t\tthis.consumedBy = \"bufferedArray\";\n\t\tthis.bufferedArrayPromise = (async () => {\n\t\t\tconst out = [];\n\t\t\tfor await (const item of this.generator) out.push(item);\n\t\t\treturn out;\n\t\t})();\n\t\treturn this.bufferedArrayPromise;\n\t}\n\tasync first() {\n\t\treturn (await this.toArray())[0] ?? null;\n\t}\n\tasync firstOrThrow() {\n\t\tconst row = await this.first();\n\t\tif (row === null) throw runtimeError(\"RUNTIME.NO_ROWS\", \"Expected at least one row, but none were returned\", {});\n\t\treturn row;\n\t}\n\tthen(onfulfilled, onrejected) {\n\t\treturn this.toArray().then(onfulfilled, onrejected);\n\t}\n};\n//#endregion\n//#region src/execution/race-against-abort.ts\n/**\n* Throw a phase-tagged `RUNTIME.ABORTED` envelope if the supplied\n* context is already aborted at the precheck site. Centralises the\n* `if (ctx.signal?.aborted) throw runtimeAborted(...)` pattern that\n* every codec dispatch site (and the `beforeExecute` middleware phase)\n* repeats. Accepts both the framework `CodecCallContext` and the\n* `RuntimeMiddlewareContext`; both expose `signal?: AbortSignal`.\n*/\nfunction checkAborted(ctx, phase) {\n\tif (ctx.signal?.aborted) throw runtimeAborted(phase, ctx.signal.reason);\n}\n/**\n* Race a per-cell `Promise.all` (or any other in-flight work promise) against\n* the supplied abort signal so the runtime returns `RUNTIME.ABORTED` promptly\n* even when codec bodies ignore the signal. In-flight bodies that ignore the\n* signal are abandoned and run to completion in the background — the\n* cooperative-cancellation contract documented in ADR 204.\n*\n* Call sites still SHOULD pre-check `signal.aborted` and short-circuit with\n* a phase-tagged `RUNTIME.ABORTED` envelope before invoking this helper —\n* that path is the canonical \"aborted at entry\" surface and avoids\n* scheduling the work promise. As a defensive belt-and-braces, this helper\n* also handles the already-aborted case internally: `AbortSignal` does not\n* replay past abort events to listeners registered after the abort, so we\n* inspect `signal.aborted` synchronously and reject with the sentinel\n* before installing the listener. The rejection is still attributed to the\n* abort path via the sentinel-identity check.\n*\n* Distinguishing the rejection source is load-bearing for AC-ERR4\n* (`RUNTIME.ENCODE_FAILED` / `RUNTIME.DECODE_FAILED` pass through unchanged).\n* The semantically equivalent `abortable(signal)` helper in\n* `@internal/utils` rejects with `signal.reason ?? new DOMException(...)`,\n* which is not stably distinguishable from a codec-thrown error by identity\n* alone (a fresh fallback DOMException is allocated per call). We instead\n* track abort attribution with a unique sentinel: only the `onAbort` listener\n* installed here ever rejects with the sentinel, so an `error === sentinel`\n* identity check after the race is unambiguous.\n*\n* Lives in `framework-components` (rather than the SQL family, where it\n* originated in m2) so every family runtime that needs cooperative\n* cancellation around a codec-dispatch `Promise.all` (SQL encode + decode\n* today, Mongo encode in m3) shares the same attribution logic.\n*/\nasync function raceAgainstAbort(work, signal, phase) {\n\tif (signal === void 0) return await work;\n\tconst sentinel = { reason: void 0 };\n\tlet onAbort;\n\tconst abortPromise = new Promise((_, reject) => {\n\t\tif (signal.aborted) {\n\t\t\tsentinel.reason = signal.reason;\n\t\t\treject(sentinel);\n\t\t\treturn;\n\t\t}\n\t\tonAbort = () => {\n\t\t\tsentinel.reason = signal.reason;\n\t\t\treject(sentinel);\n\t\t};\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n\ttry {\n\t\treturn await Promise.race([work, abortPromise]);\n\t} catch (error) {\n\t\tif (error === sentinel) throw runtimeAborted(phase, sentinel.reason);\n\t\tthrow error;\n\t} finally {\n\t\tif (onAbort) signal.removeEventListener(\"abort\", onAbort);\n\t}\n}\n//#endregion\n//#region src/execution/before-execute-chain.ts\n/**\n* Runs every middleware's `beforeQuery` hook in registration order,\n* threading through the (optional) family-specific `paramsMutator`.\n*\n* Why this lives outside {@link runQueryWithMiddleware}: middleware that\n* mutates parameter values (e.g. cipherstash's bulk-encrypt SDK\n* round-trip) must run *before* the family runtime encodes those\n* parameters to driver wire format. Family runtimes call\n* `runBeforeQueryChain` between the AST → plan lowering step and\n* the parameter encode step; the encode then observes the mutator's\n* `currentParams()` view. `runQueryWithMiddleware` retains the rest of\n* the query lifecycle (`interceptQuery`, driver/row source loop, `onRow`,\n* `afterQuery`) but no longer fires `beforeQuery` itself.\n*\n* Lifecycle within this helper:\n*\n* 1. For each middleware in registration order, if `beforeQuery`\n* is implemented:\n* - `checkAborted(ctx, 'beforeQuery')` short-circuits if the\n* caller already aborted at entry.\n* - The hook is invoked with `(plan, ctx, paramsMutator)`. A\n* middleware body that ignores the mutator stays compatible —\n* JavaScript allows extra positional arguments.\n* - If the hook returns a Promise, it is raced against\n* `ctx.signal` via {@link raceAgainstAbort} so cooperative\n* cancellation surfaces a `RUNTIME.ABORTED { phase:\n* 'beforeQuery' }` envelope even when the body itself\n* ignores the signal.\n*\n* Error propagation: any error thrown by a `beforeQuery` body\n* (or surfaced by the abort race) propagates out of this helper\n* unchanged. Family runtime entry points await this helper before invoking\n* `runQueryWithMiddleware`, so a rejection prevents the runner and its\n* `afterQuery` hook from running.\n*\n* Relationship to {@link runQueryWithMiddleware}: the framework's\n* `RuntimeCore.query` template calls this helper between\n* `lower(plan)` and `runQueryWithMiddleware(...)`. Family runtimes that\n* override query preparation (e.g. SQL, which inlines lower + encode for\n* direct mutator threading) call this helper themselves at the\n* equivalent point — between the family's AST → draft-plan\n* lowering and the parameter-encode step.\n*\n* Intercept ordering: this helper fires unconditionally before\n* `runQueryWithMiddleware`. `interceptQuery` (inside\n* `runQueryWithMiddleware`) therefore observes the post-`beforeQuery`\n* plan — mutator mutations are visible in the params interceptors see.\n* The trade-off is documented on `RuntimeMiddleware.interceptQuery`.\n*/\nfunction runBeforeQueryChain(plan, middleware, ctx, paramsMutator) {\n\treturn runBeforeChain(plan, middleware, ctx, paramsMutator, \"beforeQuery\", (mw) => mw.beforeQuery);\n}\n/**\n* Runs every middleware's `beforeExecute` hook in registration order,\n* threading through the (optional) family-specific `paramsMutator`.\n*\n* Why this lives outside {@link runExecuteWithMiddleware}: middleware that\n* mutates parameter values (e.g. cipherstash's bulk-encrypt SDK\n* round-trip) must run *before* the family runtime encodes those\n* parameters to driver wire format. Family runtimes call\n* `runBeforeExecuteChain` between the AST → plan lowering step and\n* the parameter encode step; the encode then observes the mutator's\n* `currentParams()` view. `runExecuteWithMiddleware` retains the rest of\n* the execute lifecycle (`interceptExecute`, driver statistics execution,\n* `afterExecute`) but no longer fires `beforeExecute` itself.\n*\n* Lifecycle within this helper:\n*\n* 1. For each middleware in registration order, if `beforeExecute`\n* is implemented:\n* - `checkAborted(ctx, 'beforeExecute')` short-circuits if the\n* caller already aborted at entry.\n* - The hook is invoked with `(plan, ctx, paramsMutator)`. A\n* middleware body that ignores the mutator stays compatible —\n* JavaScript allows extra positional arguments.\n* - If the hook returns a Promise, it is raced against\n* `ctx.signal` via {@link raceAgainstAbort} so cooperative\n* cancellation surfaces a `RUNTIME.ABORTED { phase:\n* 'beforeExecute' }` envelope even when the body itself\n* ignores the signal.\n*\n* Error propagation: any error thrown by a `beforeExecute` body\n* (or surfaced by the abort race) propagates out of this helper\n* unchanged. Family runtime entry points await this helper before invoking\n* `runExecuteWithMiddleware`, so a rejection prevents the runner and its\n* `afterExecute` hook from running.\n*\n* Relationship to {@link runExecuteWithMiddleware}: the framework's\n* `RuntimeCore.execute` template calls this helper between\n* `lower(plan)` and `runExecuteWithMiddleware(...)`. Family runtimes that\n* override execute (e.g. SQL, which inlines lower + encode for\n* direct mutator threading) call this helper themselves at the\n* equivalent point — between the family's AST → draft-plan\n* lowering and the parameter-encode step.\n*\n* Intercept ordering: this helper fires unconditionally before\n* `runExecuteWithMiddleware`. `interceptExecute` (inside\n* `runExecuteWithMiddleware`) therefore observes the post-`beforeExecute`\n* plan — mutator mutations are visible in the params interceptors see.\n* The trade-off is documented on `RuntimeMiddleware.interceptExecute`.\n*/\nfunction runBeforeExecuteChain(plan, middleware, ctx, paramsMutator) {\n\treturn runBeforeChain(plan, middleware, ctx, paramsMutator, \"beforeExecute\", (mw) => mw.beforeExecute);\n}\nasync function runBeforeChain(plan, middleware, ctx, paramsMutator, phase, selectHook) {\n\tfor (const mw of middleware) {\n\t\tconst hook = selectHook(mw);\n\t\tif (hook === void 0) continue;\n\t\tcheckAborted(ctx, phase);\n\t\tconst work = hook(plan, ctx, paramsMutator);\n\t\tif (work !== void 0) await raceAgainstAbort(Promise.resolve(work), ctx.signal, phase);\n\t}\n}\n//#endregion\n//#region src/execution/mutation-defaults.ts\n/** Registers every generator the contributors provide, by id. Two contributors providing one id is an error naming both. */\nfunction collectMutationDefaultGenerators(contributors) {\n\tconst generators = /* @__PURE__ */ new Map();\n\tconst owners = /* @__PURE__ */ new Map();\n\tfor (const contributor of contributors) {\n\t\tconst nextGenerators = contributor.mutationDefaultGenerators?.() ?? [];\n\t\tfor (const generator of nextGenerators) {\n\t\t\tconst existingOwner = owners.get(generator.id);\n\t\t\tif (existingOwner !== void 0) throw runtimeError(\"RUNTIME.DUPLICATE_MUTATION_DEFAULT_GENERATOR\", `Duplicate mutation default generator '${generator.id}'.`, {\n\t\t\t\tid: generator.id,\n\t\t\t\texistingOwner,\n\t\t\t\tincomingOwner: contributor.id\n\t\t\t});\n\t\t\tgenerators.set(generator.id, generator);\n\t\t\towners.set(generator.id, contributor.id);\n\t\t}\n\t}\n\treturn generators;\n}\n/** Fails when the contract's mutation defaults name a generator the registry does not hold, listing every missing id and the fields that need it. */\nfunction assertMutationDefaultGeneratorsAvailable(execution, generatorRegistry) {\n\tconst defaults = execution?.mutations.defaults ?? [];\n\tif (defaults.length === 0) return;\n\tconst fieldsById = /* @__PURE__ */ new Map();\n\tfor (const mutationDefault of defaults) {\n\t\tconst phaseIds = new Set([mutationDefault.onCreate, mutationDefault.onUpdate].flatMap((phase) => phase?.kind === \"generator\" && !generatorRegistry.has(phase.id) ? [phase.id] : []));\n\t\tfor (const id of phaseIds) {\n\t\t\tconst fields = fieldsById.get(id) ?? [];\n\t\t\tfields.push(`${mutationDefault.ref.entry}.${mutationDefault.ref.field}`);\n\t\t\tfieldsById.set(id, fields);\n\t\t}\n\t}\n\tif (fieldsById.size === 0) return;\n\tconst ids = [...fieldsById.keys()];\n\tconst needs = [...fieldsById].map(([id, fields]) => `'${id}' for ${listInProse(fields)}`);\n\tthrow runtimeError(\"RUNTIME.MUTATION_DEFAULT_GENERATOR_MISSING\", `${ids.length === 1 ? `Contract requires mutation default generator ${needs[0]}, but no runtime component in the execution stack provides it.` : `Contract requires mutation default generators ${listInProse(needs)}, but no runtime component in the execution stack provides them.`} ${WHERE_GENERATORS_COME_FROM}`, {\n\t\tids,\n\t\tfields: [...fieldsById.values()].flat()\n\t});\n}\nconst WHERE_GENERATORS_COME_FROM = \"Built-in generators such as 'timestampNow' come from the database adapter's runtime descriptor, and others from the extension pack that defines them; include that component in the execution stack.\";\nfunction listInProse(items) {\n\treturn items.length > 1 ? `${items.slice(0, -1).join(\", \")} and ${items.at(-1)}` : items.join(\"\");\n}\nfunction computeExecutionDefaultValue(spec, generatorRegistry) {\n\tconst generator = generatorRegistry.get(spec.id);\n\tif (!generator) throw runtimeError(\"RUNTIME.MUTATION_DEFAULT_GENERATOR_MISSING\", `Contract references mutation default generator '${spec.id}' but no runtime component in the execution stack provides it. ${WHERE_GENERATORS_COME_FROM}`, { id: spec.id });\n\treturn generator.generate(spec.params);\n}\n/**\n* The defaults to write for one record: for each mutation default of the entry and namespace whose phase matches `op`, the generated value of every field the values do not carry. An update with no keys gets none.\n*/\nfunction applyMutationDefaults(execution, generatorRegistry, options) {\n\tconst defaults = execution?.mutations.defaults ?? [];\n\tif (defaults.length === 0) return [];\n\tconst isEmptyUpdate = options.op === \"update\" && Object.keys(options.values).length === 0;\n\tconst applied = [];\n\tconst appliedFields = /* @__PURE__ */ new Set();\n\tconst rowCache = /* @__PURE__ */ new Map();\n\tfor (const mutationDefault of defaults) {\n\t\tif (mutationDefault.ref.entry !== options.entry) continue;\n\t\tif (mutationDefault.ref.namespace !== options.namespace) continue;\n\t\tconst defaultSpec = options.op === \"create\" ? mutationDefault.onCreate : mutationDefault.onUpdate;\n\t\tif (!defaultSpec) continue;\n\t\tif (isEmptyUpdate) continue;\n\t\tconst fieldName = mutationDefault.ref.field;\n\t\tif (Object.hasOwn(options.values, fieldName) || appliedFields.has(fieldName)) continue;\n\t\tapplied.push({\n\t\t\tfield: fieldName,\n\t\t\tvalue: resolveScopedValue(defaultSpec, generatorRegistry, rowCache, options.defaultValueCache)\n\t\t});\n\t\tappliedFields.add(fieldName);\n\t}\n\treturn applied;\n}\nfunction resolveScopedValue(spec, generatorRegistry, rowCache, queryCache) {\n\tconst cache = scopedCache(generatorRegistry.get(spec.id)?.stability, rowCache, queryCache);\n\tif (!cache) return computeExecutionDefaultValue(spec, generatorRegistry);\n\tif (cache.has(spec.id)) return cache.get(spec.id);\n\tconst value = computeExecutionDefaultValue(spec, generatorRegistry);\n\tcache.set(spec.id, value);\n\treturn value;\n}\nfunction scopedCache(stability, rowCache, queryCache) {\n\tswitch (stability) {\n\t\tcase \"row\": return rowCache;\n\t\tcase \"query\": return queryCache;\n\t\tdefault: return;\n\t}\n}\n//#endregion\n//#region src/execution/run-with-middleware.ts\n/**\n* Drives a single query execution of `runDriver()` through the middleware\n* lifecycle's `interceptQuery` + row-source + termination phases.\n*\n* Lifecycle, in order:\n* 1. For each middleware in registration order: `interceptQuery(exec, ctx)`.\n* The first non-`undefined` result wins; subsequent middleware's\n* `interceptQuery` does not fire. On a hit, the runtime emits a\n* `middleware.interceptQuery` debug event naming the winning middleware,\n* switches the row source to the intercepted rows, and proceeds with\n* `source: 'middleware'`. On all-passthrough (every `interceptQuery`\n* returns `undefined` or is omitted), `source: 'driver'` is used and the\n* row source is `runDriver()`.\n* 2. Iterate the row source. On the driver path, for each row, for each\n* middleware in registration order: `onRow(row, exec, ctx)`; then yield\n* the row. On the intercepted hit path, `onRow` is skipped — intercepted\n* rows did not originate from a driver row stream — but rows are still\n* yielded to the consumer in order.\n* 3. On successful completion: for each middleware in registration order:\n* `afterQuery(exec, { rowCount, latencyMs, completed: true, source },\n* ctx)`.\n* 4. On any error thrown during steps 1–2: for each middleware in\n* registration order: `afterQuery(exec, { rowCount, latencyMs,\n* completed: false, source }, ctx)`. Errors thrown by `afterQuery`\n* during the error path are swallowed so they do not mask the original\n* error. The original error is then rethrown.\n*\n* `beforeQuery` is **not** fired here — see\n* {@link runBeforeQueryChain} in `before-execute-chain.ts`. Family runtimes\n* call that helper between the AST → plan lowering step and the parameter\n* encode step so middleware that mutates ParamRef values can have its\n* mutations visible to encode. `runQueryWithMiddleware` operates on the\n* fully-encoded plan; interceptors therefore observe a fully-mutated,\n* encoded plan.\n*\n* The `source` field on `AfterQueryResult` lets observers (telemetry, lints,\n* budgets) distinguish driver-served from middleware-served executions\n* without needing their own out-of-band signal.\n*\n* This helper is the single canonical implementation of the\n* intercept-and-row-source loop; family runtimes should not reimplement it.\n*/\nfunction runQueryWithMiddleware(exec, middleware, ctx, runDriver) {\n\tconst iterator = async function* () {\n\t\tconst startedAt = Date.now();\n\t\tlet rowCount = 0;\n\t\tlet completed = false;\n\t\tlet source = \"driver\";\n\t\tlet rowSource;\n\t\ttry {\n\t\t\tfor (const mw of middleware) {\n\t\t\t\tif (!mw.interceptQuery) continue;\n\t\t\t\tsource = \"middleware\";\n\t\t\t\tconst result = await mw.interceptQuery(exec, ctx);\n\t\t\t\tif (result === void 0) {\n\t\t\t\t\tsource = \"driver\";\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tctx.log.debug?.({\n\t\t\t\t\tevent: \"middleware.interceptQuery\",\n\t\t\t\t\tmiddleware: mw.name\n\t\t\t\t});\n\t\t\t\trowSource = blindCast(result.rows);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (source === \"driver\") rowSource = runDriver();\n\t\t\tfor await (const row of rowSource) {\n\t\t\t\tif (source === \"driver\") {\n\t\t\t\t\tfor (const mw of middleware) if (mw.onRow) await mw.onRow(row, exec, ctx);\n\t\t\t\t}\n\t\t\t\trowCount++;\n\t\t\t\tyield row;\n\t\t\t}\n\t\t\tcompleted = true;\n\t\t} catch (error) {\n\t\t\tawait notifyQueryCompletion(middleware, exec, ctx, {\n\t\t\t\trowCount,\n\t\t\t\tlatencyMs: Date.now() - startedAt,\n\t\t\t\tcompleted,\n\t\t\t\tsource\n\t\t\t}, true);\n\t\t\tthrow error;\n\t\t}\n\t\tawait notifyQueryCompletion(middleware, exec, ctx, {\n\t\t\trowCount,\n\t\t\tlatencyMs: Date.now() - startedAt,\n\t\t\tcompleted,\n\t\t\tsource\n\t\t}, false);\n\t};\n\treturn new AsyncIterableResult(iterator());\n}\n/**\n* Drives a single execute operation through the middleware\n* `interceptExecute` + statistics + termination phases.\n*\n* Lifecycle, in order:\n* 1. For each middleware in registration order: `interceptExecute(exec, ctx)`.\n* The first non-`undefined` result wins; subsequent middleware's\n* `interceptExecute` does not fire. On a hit, the runtime emits a\n* `middleware.interceptExecute` debug event naming the winning middleware,\n* uses the returned `stats`, and proceeds with `source: 'middleware'`.\n* On all-passthrough (every `interceptExecute` returns `undefined` or is\n* omitted), `source: 'driver'` is used and `runDriver()` supplies the\n* statistics.\n* 2. Execute operations return eager statistics. There is no row stream and\n* `onRow` does not fire.\n* 3. On successful completion: for each middleware in registration order:\n* `afterExecute(exec, { stats, latencyMs, completed: true, source }, ctx)`.\n* 4. On any error thrown during steps 1–2: for each middleware in\n* registration order: `afterExecute(exec, { latencyMs, completed: false,\n* source }, ctx)`. Errors thrown by `afterExecute` during the error path\n* are swallowed so they do not mask the original error. The original\n* error is then rethrown.\n*\n* `beforeExecute` is **not** fired here — see\n* {@link runBeforeExecuteChain} in `before-execute-chain.ts`. Family runtimes\n* call that helper between the AST → plan lowering step and the parameter\n* encode step so middleware that mutates ParamRef values can have its\n* mutations visible to encode. `runExecuteWithMiddleware` operates on the\n* fully-encoded plan; interceptors therefore observe a fully-mutated,\n* encoded plan.\n*\n* The `source` field on `AfterExecuteResult` lets observers (telemetry, lints,\n* budgets) distinguish driver-served from middleware-served executions\n* without needing their own out-of-band signal.\n*/\nasync function runExecuteWithMiddleware(exec, middleware, ctx, runDriver) {\n\tconst startedAt = Date.now();\n\tlet source = \"driver\";\n\tlet stats;\n\ttry {\n\t\tfor (const mw of middleware) {\n\t\t\tif (!mw.interceptExecute) continue;\n\t\t\tsource = \"middleware\";\n\t\t\tconst result = await mw.interceptExecute(exec, ctx);\n\t\t\tif (result === void 0) {\n\t\t\t\tsource = \"driver\";\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tctx.log.debug?.({\n\t\t\t\tevent: \"middleware.interceptExecute\",\n\t\t\t\tmiddleware: mw.name\n\t\t\t});\n\t\t\tstats = result.stats;\n\t\t\tbreak;\n\t\t}\n\t\tif (stats === void 0) stats = await runDriver();\n\t} catch (error) {\n\t\tconst latencyMs = Date.now() - startedAt;\n\t\tfor (const mw of middleware) {\n\t\t\tif (!mw.afterExecute) continue;\n\t\t\ttry {\n\t\t\t\tawait mw.afterExecute(exec, {\n\t\t\t\t\tlatencyMs,\n\t\t\t\t\tcompleted: false,\n\t\t\t\t\tsource\n\t\t\t\t}, ctx);\n\t\t\t} catch {}\n\t\t}\n\t\tthrow error;\n\t}\n\tconst latencyMs = Date.now() - startedAt;\n\tfor (const mw of middleware) if (mw.afterExecute) await mw.afterExecute(exec, {\n\t\tstats,\n\t\tlatencyMs,\n\t\tcompleted: true,\n\t\tsource\n\t}, ctx);\n\treturn stats;\n}\nasync function notifyQueryCompletion(middleware, exec, ctx, result, swallowErrors) {\n\tfor (const mw of middleware) {\n\t\tif (!mw.afterQuery) continue;\n\t\tif (swallowErrors) try {\n\t\t\tawait mw.afterQuery(exec, result, ctx);\n\t\t} catch {}\n\t\telse await mw.afterQuery(exec, result, ctx);\n\t}\n}\n//#endregion\n//#region src/execution/runtime-core.ts\n/**\n* Family-agnostic abstract runtime base.\n*\n* Defines the shared operation-specific middleware lifecycles:\n*\n* 1. `runBeforeCompile(plan)` — concrete; defaults to identity. SQL overrides\n* this to run its shared `beforeCompile` middleware-hook chain.\n* 2. `lower(plan)` — abstract. Each family produces its `*ExecutionPlan`\n* (SQL via `lowerSqlPlan`, Mongo via `adapter.lower`).\n* 3. Queries run `beforeQuery`; statements run `beforeExecute`. Both chains\n* run after lowering and before their matching driver terminal. Family\n* runtimes that expose a params mutator to downstream encoding override\n* the operation and call the matching helper at the pre-encode point.\n* 4. The matching runner processes `interceptQuery` or `interceptExecute`\n* before invoking the driver. Queries then fire `onRow` and `afterQuery`;\n* statements fire `afterExecute`.\n*\n* Concrete subclasses must implement `lower`, `runDriver`, `runExecute`, and\n* `close`.\n*\n* The class is generic over:\n* - `TPlan` — the family's pre-lowering plan type.\n* - `TExec` — the family's post-lowering (executable) plan type.\n* - `TMiddleware` — the family's middleware type. Constrained to\n* `RuntimeMiddleware<TExec>` because the operation-specific runners invoke\n* hooks with the lowered `TExec`. Middleware therefore sees the\n* post-lowering plan.\n*/\nvar RuntimeCore = class {\n\tmiddleware;\n\tctx;\n\tconstructor(options) {\n\t\tthis.middleware = options.middleware;\n\t\tthis.ctx = options.ctx;\n\t}\n\t/**\n\t* Pre-lowering hook for plan rewriting. Defaults to identity. Subclasses\n\t* may override to run a `beforeCompile` middleware chain (SQL does this\n\t* to support typed AST rewrites — see `before-compile-chain.ts`).\n\t*/\n\trunBeforeCompile(plan) {\n\t\treturn plan;\n\t}\n\tquery(plan, options) {\n\t\tconst self = this;\n\t\tconst signal = options?.signal;\n\t\tconst codecCtx = signal === void 0 ? {} : { signal };\n\t\tconst execCtx = {\n\t\t\t...self.ctx,\n\t\t\t...codecCtx,\n\t\t\tscope: options?.scope ?? self.ctx.scope,\n\t\t\tplanExecutionId: crypto.randomUUID()\n\t\t};\n\t\tasync function* generator() {\n\t\t\tcheckAborted(codecCtx, \"stream\");\n\t\t\tconst compiled = await self.runBeforeCompile(plan);\n\t\t\tconst exec = await self.lower(compiled, codecCtx);\n\t\t\tawait runBeforeQueryChain(exec, self.middleware, execCtx);\n\t\t\tyield* runQueryWithMiddleware(exec, self.middleware, execCtx, () => self.runDriver(exec));\n\t\t}\n\t\treturn new AsyncIterableResult(generator());\n\t}\n\tasync execute(plan, options) {\n\t\tconst signal = options?.signal;\n\t\tconst codecCtx = signal === void 0 ? {} : { signal };\n\t\tconst execCtx = {\n\t\t\t...this.ctx,\n\t\t\t...codecCtx,\n\t\t\tscope: options?.scope ?? this.ctx.scope,\n\t\t\tplanExecutionId: crypto.randomUUID()\n\t\t};\n\t\tcheckAborted(codecCtx, \"stream\");\n\t\tconst compiled = await this.runBeforeCompile(plan);\n\t\tconst exec = await this.lower(compiled, codecCtx);\n\t\tawait runBeforeExecuteChain(exec, this.middleware, execCtx);\n\t\treturn runExecuteWithMiddleware(exec, this.middleware, execCtx, () => this.runExecute(exec));\n\t}\n};\n//#endregion\n//#region src/execution/runtime-middleware.ts\nfunction checkMiddlewareCompatibility(middleware, runtimeFamilyId, runtimeTargetId) {\n\tif (middleware.targetId !== void 0 && middleware.familyId === void 0) throw runtimeError(\"RUNTIME.MIDDLEWARE_INCOMPATIBLE\", `Middleware '${middleware.name}' specifies targetId '${middleware.targetId}' without familyId`, {\n\t\tmiddleware: middleware.name,\n\t\ttargetId: middleware.targetId\n\t});\n\tif (middleware.familyId !== void 0 && middleware.familyId !== runtimeFamilyId) throw runtimeError(\"RUNTIME.MIDDLEWARE_FAMILY_MISMATCH\", `Middleware '${middleware.name}' requires family '${middleware.familyId}' but the runtime is configured for family '${runtimeFamilyId}'`, {\n\t\tmiddleware: middleware.name,\n\t\tmiddlewareFamilyId: middleware.familyId,\n\t\truntimeFamilyId\n\t});\n\tif (middleware.targetId !== void 0 && middleware.targetId !== runtimeTargetId) throw runtimeError(\"RUNTIME.MIDDLEWARE_TARGET_MISMATCH\", `Middleware '${middleware.name}' requires target '${middleware.targetId}' but the runtime is configured for target '${runtimeTargetId}'`, {\n\t\tmiddleware: middleware.name,\n\t\tmiddlewareTargetId: middleware.targetId,\n\t\truntimeTargetId\n\t});\n}\n//#endregion\n//#region src/execution/shape.ts\n/**\n* Phantom key an emitted model type carries to name its relation properties.\n* Never present at runtime; `Scalars` and `Shape` read it to tell relations from fields.\n*/\nconst RelationKeys = Symbol(\"RelationKeys\");\n//#endregion\n//#region src/meta-builder.ts\nvar MetaBuilderImpl = class {\n\t#kind;\n\t#terminalName;\n\t#annotations = /* @__PURE__ */ new Map();\n\tconstructor(kind, terminalName) {\n\t\tthis.#kind = kind;\n\t\tthis.#terminalName = terminalName;\n\t}\n\tget annotations() {\n\t\treturn this.#annotations;\n\t}\n\tannotate(annotation) {\n\t\tconst value = annotation;\n\t\tassertAnnotationsApplicable([value], this.#kind, this.#terminalName);\n\t\tthis.#annotations.set(value.namespace, value);\n\t\treturn this;\n\t}\n};\n/**\n* Construct a lane-side meta builder for a terminal of operation kind `K`.\n*\n* Lane terminals call this with their `kind` (`'read'` or `'write'`) and a\n* `terminalName` for error messages, hand the resulting builder to the\n* user-supplied configurator callback (typed as `MetaBuilder<K>`, the\n* narrower public view), and read `meta.annotations` afterwards to thread\n* the recorded values into `plan.meta.annotations`.\n*/\nfunction createMetaBuilder(kind, terminalName) {\n\treturn new MetaBuilderImpl(kind, terminalName);\n}\n//#endregion\nexport { AsyncIterableResult, RUNTIME_ABORTED, RelationKeys, RuntimeCore, applyMutationDefaults, assertAnnotationsApplicable, assertMutationDefaultGeneratorsAvailable, checkAborted, checkMiddlewareCompatibility, collectMutationDefaultGenerators, createMetaBuilder, defineAnnotation, isRuntimeError, raceAgainstAbort, runBeforeExecuteChain, runBeforeQueryChain, runExecuteWithMiddleware, runQueryWithMiddleware, runtimeAborted, runtimeError };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAM,kBAAkB;;;;;;;;;;AAUxB,SAAS,eAAe,OAAO,OAAO;CACrC,MAAM,WAAW,aAAa,iBAAiB,4BAA4B,SAAS,EAAE,MAAM,CAAC;CAC7F,OAAO,OAAO,OAAO,UAAU,EAAE,MAAM,CAAC;AACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAS,mBAAmB;CAC3B,QAAQ,YAAY;EACnB,MAAM,YAAY,QAAQ;EAC1B,MAAM,eAAe,OAAO,OAAO,IAAI,IAAI,QAAQ,YAAY,CAAC;EAChE,SAAS,OAAO,OAAO;GACtB,OAAO,OAAO,OAAO;IACpB,cAAc;IACd;IACA;IACA;GACD,CAAC;EACF;EACA,SAAS,KAAK,MAAM;GACnB,MAAM,SAAS,KAAK,KAAK,cAAc;GACvC,IAAI,CAAC,kBAAkB,MAAM,GAAG;GAChC,IAAI,OAAO,cAAc,WAAW;GACpC,OAAO,OAAO;EACf;EACA,OAAO,OAAO,OAAO,OAAO,OAAO,QAAQ;GAC1C;GACA;GACA;EACD,CAAC,CAAC;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AAK,KAAK,WAAW,aAAa,iBAAiB,MAAM,aAAa,sCAAsC,eAAe,WAAW,KAAK,qBAAqB,WAAW,SAAS,8CAA8C,gBAAgB,IAAI;EACjR,YAAY,WAAW;EACvB,oBAAoB,WAAW;EAC/B;CACD,CAAC;AACF;;;;;AAOA,MAAM,eAAe,OAAO,cAAc;AAG1C,IAAI,kBAAkB,MAAM;CAC3B;CACA;CACA,+BAA+B,IAAI,IAAI;CACvC,YAAY,MAAM,cAAc;EAC/B,KAAKA,QAAQ;EACb,KAAKC,gBAAgB;CACtB;CACA,IAAI,cAAc;EACjB,OAAO,KAAKC;CACb;CACA,SAAS,YAAY;EACpB,MAAM,QAAQ;EACd,4BAA4B,CAAC,KAAK,GAAG,KAAKF,OAAO,KAAKC,aAAa;EACnE,KAAKC,aAAa,IAAI,MAAM,WAAW,KAAK;EAC5C,OAAO;CACR;AACD;;;;;;;;;;AAUA,SAAS,kBAAkB,MAAM,cAAc;CAC9C,OAAO,IAAI,gBAAgB,MAAM,YAAY;AAC9C"}
1
+ {"version":3,"file":"runtime-7NCyLoeP.mjs","names":["#kind","#terminalName","#annotations"],"sources":["../../../../1-framework/1-core/framework-components/dist/runtime.mjs"],"sourcesContent":["import { n as runtimeError, t as isRuntimeError } from \"./runtime-error-BA9d7XjZ.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\n//#region src/execution/runtime-error.ts\n/**\n* Stable code emitted by the runtime when an in-flight `execute()`\n* is cancelled via the per-query `AbortSignal`. The envelope's\n* `details.phase` distinguishes where the abort was observed:\n*\n* - `'encode'` — abort fired during `encodeParams` (SQL) or\n* `resolveValue` (Mongo).\n* - `'decode'` — abort fired during `decodeRow` / `decodeField`.\n* - `'stream'` — abort fired between rows or before any codec call\n* (already-aborted at entry).\n* - `'beforeQuery'` / `'beforeExecute'` / `'afterQuery'` /\n* `'afterExecute'` / `'onRow'` — abort fired on entry to or during\n* the corresponding middleware phase\n* (cooperative cancellation per the param-transform seam).\n*/\nconst RUNTIME_ABORTED = \"RUNTIME.ABORTED\";\n/**\n* Construct a `RUNTIME.ABORTED` envelope. Phase distinguishes where the\n* abort was observed — codec call sites (`encode` / `decode` / `stream`)\n* or operation-specific middleware seams, as\n* enumerated on {@link RuntimeAbortedPhase}. Cause carries\n* `signal.reason` verbatim from the platform — native abort produces a\n* `DOMException`, explicit `controller.abort(reason)` produces whatever\n* the caller passed. No synthesis happens here.\n*/\nfunction runtimeAborted(phase, cause) {\n\tconst envelope = runtimeError(RUNTIME_ABORTED, `Operation aborted during ${phase}`, { phase });\n\treturn Object.assign(envelope, { cause });\n}\n//#endregion\n//#region src/annotations.ts\n/**\n* Defines a typed annotation handle.\n*\n* Two-step call form. The first step takes the `Payload` type argument\n* (TypeScript cannot infer `Payload` from anything in the options, so it\n* must be supplied explicitly); the second step takes the runtime options\n* and infers `Kinds` from the `applicableTo` array via a `const` type\n* parameter, so the operation kinds appear exactly once at the call site.\n*\n* @example\n* ```typescript\n* // Read-only annotation. Lane terminals like `db.User.first(...)` accept\n* // it; `db.User.create(...)` rejects it at the type level.\n* const cacheAnnotation = defineAnnotation<{ ttl?: number; skip?: boolean }>()({\n* namespace: 'cache',\n* applicableTo: ['read'],\n* }); // Kinds inferred as 'read'\n*\n* // Write-only annotation. Mirror image.\n* const auditAnnotation = defineAnnotation<{ actor: string }>()({\n* namespace: 'audit',\n* applicableTo: ['write'],\n* }); // Kinds inferred as 'write'\n*\n* // Annotation applicable to both kinds (e.g. tracing).\n* const otelAnnotation = defineAnnotation<{ traceId: string }>()({\n* namespace: 'otel',\n* applicableTo: ['read', 'write'],\n* }); // Kinds inferred as 'read' | 'write'\n* ```\n*\n* **Reserved namespaces.** See `DefineAnnotationOptions.namespace` for the\n* list of framework-internal namespaces (`codecs`, target-specific keys).\n* `defineAnnotation` does not structurally prevent a user from naming a\n* reserved namespace, but the framework makes no compatibility guarantee\n* about handles that do.\n*/\nfunction defineAnnotation() {\n\treturn (options) => {\n\t\tconst namespace = options.namespace;\n\t\tconst applicableTo = Object.freeze(new Set(options.applicableTo));\n\t\tfunction handle(value) {\n\t\t\treturn Object.freeze({\n\t\t\t\t__annotation: true,\n\t\t\t\tnamespace,\n\t\t\t\tvalue,\n\t\t\t\tapplicableTo\n\t\t\t});\n\t\t}\n\t\tfunction read(plan) {\n\t\t\tconst stored = plan.meta.annotations?.[namespace];\n\t\t\tif (!isAnnotationValue(stored)) return;\n\t\t\tif (stored.namespace !== namespace) return;\n\t\t\treturn stored.value;\n\t\t}\n\t\treturn Object.freeze(Object.assign(handle, {\n\t\t\tnamespace,\n\t\t\tapplicableTo,\n\t\t\tread\n\t\t}));\n\t};\n}\n/**\n* Runtime applicability gate. Throws `RUNTIME.ANNOTATION_INAPPLICABLE` if\n* any annotation in `annotations` declares an `applicableTo` set that does\n* not include `kind`. Used by lane terminals (SQL DSL builders' `.build()`,\n* ORM `Collection` terminals) to fail closed when the type-level\n* `ValidAnnotations` gate is bypassed via cast / `any` / dynamic\n* invocation.\n*\n* Passes silently on:\n* - empty arrays\n* - annotations whose `applicableTo` includes `kind`\n*\n* Throws on:\n* - any annotation whose `applicableTo` does not include `kind`. The\n* error names the offending annotation's `namespace` and the\n* `terminalName` so users can locate the misuse.\n*\n* @example\n* ```typescript\n* // Inside an ORM read terminal:\n* assertAnnotationsApplicable(annotations, 'read', 'first');\n* ```\n*/\nfunction assertAnnotationsApplicable(annotations, kind, terminalName) {\n\tfor (const annotation of annotations) if (!annotation.applicableTo.has(kind)) throw runtimeError(\"RUNTIME.ANNOTATION_INAPPLICABLE\", `Annotation '${annotation.namespace}' is not applicable to '${kind}' operations (terminal: '${terminalName}'). The annotation declares applicableTo = [${Array.from(annotation.applicableTo).map((k) => `'${k}'`).join(\", \")}].`, {\n\t\tnamespace: annotation.namespace,\n\t\tterminalName,\n\t\tkind,\n\t\tapplicableTo: Array.from(annotation.applicableTo)\n\t});\n}\n/**\n* Type guard for branded annotation values stored in `plan.meta.annotations`.\n*\n* Internal — used by `AnnotationHandle.read` to distinguish user\n* annotations (created by calling a handle returned from\n* `defineAnnotation(...)`) from framework-internal metadata that may\n* happen to live under the same namespace key.\n*/\nfunction isAnnotationValue(value) {\n\tif (value === null || typeof value !== \"object\") return false;\n\treturn value.__annotation === true;\n}\n//#endregion\n//#region src/execution/async-iterable-result.ts\nvar AsyncIterableResult = class {\n\tgenerator;\n\tconsumed = false;\n\tconsumedBy;\n\tbufferedArrayPromise;\n\tconstructor(generator) {\n\t\tthis.generator = generator;\n\t}\n\t[Symbol.asyncIterator]() {\n\t\tif (this.consumed) throw runtimeError(\"RUNTIME.ITERATOR_CONSUMED\", `AsyncIterableResult iterator has already been consumed via ${this.consumedBy === \"bufferedArray\" ? \"toArray()/then()\" : \"for-await loop\"}. Each AsyncIterableResult can only be iterated once.`, {\n\t\t\tconsumedBy: this.consumedBy,\n\t\t\tsuggestion: this.consumedBy === \"bufferedArray\" ? \"If you need to iterate multiple times, store the results from toArray() in a variable and reuse that.\" : \"If you need to iterate multiple times, use toArray() to collect all results first.\"\n\t\t});\n\t\tthis.consumed = true;\n\t\tthis.consumedBy = \"iterator\";\n\t\treturn this.generator;\n\t}\n\ttoArray() {\n\t\tif (this.consumedBy === \"iterator\") return Promise.reject(runtimeError(\"RUNTIME.ITERATOR_CONSUMED\", \"AsyncIterableResult iterator has already been consumed via for-await loop. Each AsyncIterableResult can only be iterated once.\", {\n\t\t\tconsumedBy: this.consumedBy,\n\t\t\tsuggestion: \"The iterator was already consumed by a for-await loop. Use toArray() or await the result before iterating.\"\n\t\t}));\n\t\tif (this.bufferedArrayPromise) return this.bufferedArrayPromise;\n\t\tthis.consumed = true;\n\t\tthis.consumedBy = \"bufferedArray\";\n\t\tthis.bufferedArrayPromise = (async () => {\n\t\t\tconst out = [];\n\t\t\tfor await (const item of this.generator) out.push(item);\n\t\t\treturn out;\n\t\t})();\n\t\treturn this.bufferedArrayPromise;\n\t}\n\tasync first() {\n\t\treturn (await this.toArray())[0] ?? null;\n\t}\n\tasync firstOrThrow() {\n\t\tconst row = await this.first();\n\t\tif (row === null) throw runtimeError(\"RUNTIME.NO_ROWS\", \"Expected at least one row, but none were returned\", {});\n\t\treturn row;\n\t}\n\tthen(onfulfilled, onrejected) {\n\t\treturn this.toArray().then(onfulfilled, onrejected);\n\t}\n};\n//#endregion\n//#region src/execution/race-against-abort.ts\n/**\n* Throw a phase-tagged `RUNTIME.ABORTED` envelope if the supplied\n* context is already aborted at the precheck site. Centralises the\n* `if (ctx.signal?.aborted) throw runtimeAborted(...)` pattern that\n* every codec dispatch site (and the `beforeExecute` middleware phase)\n* repeats. Accepts both the framework `CodecCallContext` and the\n* `RuntimeMiddlewareContext`; both expose `signal?: AbortSignal`.\n*/\nfunction checkAborted(ctx, phase) {\n\tif (ctx.signal?.aborted) throw runtimeAborted(phase, ctx.signal.reason);\n}\n/**\n* Race a per-cell `Promise.all` (or any other in-flight work promise) against\n* the supplied abort signal so the runtime returns `RUNTIME.ABORTED` promptly\n* even when codec bodies ignore the signal. In-flight bodies that ignore the\n* signal are abandoned and run to completion in the background — the\n* cooperative-cancellation contract documented in ADR 204.\n*\n* Call sites still SHOULD pre-check `signal.aborted` and short-circuit with\n* a phase-tagged `RUNTIME.ABORTED` envelope before invoking this helper —\n* that path is the canonical \"aborted at entry\" surface and avoids\n* scheduling the work promise. As a defensive belt-and-braces, this helper\n* also handles the already-aborted case internally: `AbortSignal` does not\n* replay past abort events to listeners registered after the abort, so we\n* inspect `signal.aborted` synchronously and reject with the sentinel\n* before installing the listener. The rejection is still attributed to the\n* abort path via the sentinel-identity check.\n*\n* Distinguishing the rejection source is load-bearing for AC-ERR4\n* (`RUNTIME.ENCODE_FAILED` / `RUNTIME.DECODE_FAILED` pass through unchanged).\n* The semantically equivalent `abortable(signal)` helper in\n* `@internal/utils` rejects with `signal.reason ?? new DOMException(...)`,\n* which is not stably distinguishable from a codec-thrown error by identity\n* alone (a fresh fallback DOMException is allocated per call). We instead\n* track abort attribution with a unique sentinel: only the `onAbort` listener\n* installed here ever rejects with the sentinel, so an `error === sentinel`\n* identity check after the race is unambiguous.\n*\n* Lives in `framework-components` (rather than the SQL family, where it\n* originated in m2) so every family runtime that needs cooperative\n* cancellation around a codec-dispatch `Promise.all` (SQL encode + decode\n* today, Mongo encode in m3) shares the same attribution logic.\n*/\nasync function raceAgainstAbort(work, signal, phase) {\n\tif (signal === void 0) return await work;\n\tconst sentinel = { reason: void 0 };\n\tlet onAbort;\n\tconst abortPromise = new Promise((_, reject) => {\n\t\tif (signal.aborted) {\n\t\t\tsentinel.reason = signal.reason;\n\t\t\treject(sentinel);\n\t\t\treturn;\n\t\t}\n\t\tonAbort = () => {\n\t\t\tsentinel.reason = signal.reason;\n\t\t\treject(sentinel);\n\t\t};\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n\ttry {\n\t\treturn await Promise.race([work, abortPromise]);\n\t} catch (error) {\n\t\tif (error === sentinel) throw runtimeAborted(phase, sentinel.reason);\n\t\tthrow error;\n\t} finally {\n\t\tif (onAbort) signal.removeEventListener(\"abort\", onAbort);\n\t}\n}\n//#endregion\n//#region src/execution/before-execute-chain.ts\n/**\n* Runs every middleware's `beforeQuery` hook in registration order,\n* threading through the (optional) family-specific `paramsMutator`.\n*\n* Why this lives outside {@link runQueryWithMiddleware}: middleware that\n* mutates parameter values (e.g. cipherstash's bulk-encrypt SDK\n* round-trip) must run *before* the family runtime encodes those\n* parameters to driver wire format. Family runtimes call\n* `runBeforeQueryChain` between the AST → plan lowering step and\n* the parameter encode step; the encode then observes the mutator's\n* `currentParams()` view. `runQueryWithMiddleware` retains the rest of\n* the query lifecycle (`interceptQuery`, driver/row source loop, `onRow`,\n* `afterQuery`) but no longer fires `beforeQuery` itself.\n*\n* Lifecycle within this helper:\n*\n* 1. For each middleware in registration order, if `beforeQuery`\n* is implemented:\n* - `checkAborted(ctx, 'beforeQuery')` short-circuits if the\n* caller already aborted at entry.\n* - The hook is invoked with `(plan, ctx, paramsMutator)`. A\n* middleware body that ignores the mutator stays compatible —\n* JavaScript allows extra positional arguments.\n* - If the hook returns a Promise, it is raced against\n* `ctx.signal` via {@link raceAgainstAbort} so cooperative\n* cancellation surfaces a `RUNTIME.ABORTED { phase:\n* 'beforeQuery' }` envelope even when the body itself\n* ignores the signal.\n*\n* Error propagation: any error thrown by a `beforeQuery` body\n* (or surfaced by the abort race) propagates out of this helper\n* unchanged. Family runtime entry points await this helper before invoking\n* `runQueryWithMiddleware`, so a rejection prevents the runner and its\n* `afterQuery` hook from running.\n*\n* Relationship to {@link runQueryWithMiddleware}: the framework's\n* `RuntimeCore.query` template calls this helper between\n* `lower(plan)` and `runQueryWithMiddleware(...)`. Family runtimes that\n* override query preparation (e.g. SQL, which inlines lower + encode for\n* direct mutator threading) call this helper themselves at the\n* equivalent point — between the family's AST → draft-plan\n* lowering and the parameter-encode step.\n*\n* Intercept ordering: this helper fires unconditionally before\n* `runQueryWithMiddleware`. `interceptQuery` (inside\n* `runQueryWithMiddleware`) therefore observes the post-`beforeQuery`\n* plan — mutator mutations are visible in the params interceptors see.\n* The trade-off is documented on `RuntimeMiddleware.interceptQuery`.\n*/\nfunction runBeforeQueryChain(plan, middleware, ctx, paramsMutator) {\n\treturn runBeforeChain(plan, middleware, ctx, paramsMutator, \"beforeQuery\", (mw) => mw.beforeQuery);\n}\n/**\n* Runs every middleware's `beforeExecute` hook in registration order,\n* threading through the (optional) family-specific `paramsMutator`.\n*\n* Why this lives outside {@link runExecuteWithMiddleware}: middleware that\n* mutates parameter values (e.g. cipherstash's bulk-encrypt SDK\n* round-trip) must run *before* the family runtime encodes those\n* parameters to driver wire format. Family runtimes call\n* `runBeforeExecuteChain` between the AST → plan lowering step and\n* the parameter encode step; the encode then observes the mutator's\n* `currentParams()` view. `runExecuteWithMiddleware` retains the rest of\n* the execute lifecycle (`interceptExecute`, driver statistics execution,\n* `afterExecute`) but no longer fires `beforeExecute` itself.\n*\n* Lifecycle within this helper:\n*\n* 1. For each middleware in registration order, if `beforeExecute`\n* is implemented:\n* - `checkAborted(ctx, 'beforeExecute')` short-circuits if the\n* caller already aborted at entry.\n* - The hook is invoked with `(plan, ctx, paramsMutator)`. A\n* middleware body that ignores the mutator stays compatible —\n* JavaScript allows extra positional arguments.\n* - If the hook returns a Promise, it is raced against\n* `ctx.signal` via {@link raceAgainstAbort} so cooperative\n* cancellation surfaces a `RUNTIME.ABORTED { phase:\n* 'beforeExecute' }` envelope even when the body itself\n* ignores the signal.\n*\n* Error propagation: any error thrown by a `beforeExecute` body\n* (or surfaced by the abort race) propagates out of this helper\n* unchanged. Family runtime entry points await this helper before invoking\n* `runExecuteWithMiddleware`, so a rejection prevents the runner and its\n* `afterExecute` hook from running.\n*\n* Relationship to {@link runExecuteWithMiddleware}: the framework's\n* `RuntimeCore.execute` template calls this helper between\n* `lower(plan)` and `runExecuteWithMiddleware(...)`. Family runtimes that\n* override execute (e.g. SQL, which inlines lower + encode for\n* direct mutator threading) call this helper themselves at the\n* equivalent point — between the family's AST → draft-plan\n* lowering and the parameter-encode step.\n*\n* Intercept ordering: this helper fires unconditionally before\n* `runExecuteWithMiddleware`. `interceptExecute` (inside\n* `runExecuteWithMiddleware`) therefore observes the post-`beforeExecute`\n* plan — mutator mutations are visible in the params interceptors see.\n* The trade-off is documented on `RuntimeMiddleware.interceptExecute`.\n*/\nfunction runBeforeExecuteChain(plan, middleware, ctx, paramsMutator) {\n\treturn runBeforeChain(plan, middleware, ctx, paramsMutator, \"beforeExecute\", (mw) => mw.beforeExecute);\n}\nasync function runBeforeChain(plan, middleware, ctx, paramsMutator, phase, selectHook) {\n\tfor (const mw of middleware) {\n\t\tconst hook = selectHook(mw);\n\t\tif (hook === void 0) continue;\n\t\tcheckAborted(ctx, phase);\n\t\tconst work = hook(plan, ctx, paramsMutator);\n\t\tif (work !== void 0) await raceAgainstAbort(Promise.resolve(work), ctx.signal, phase);\n\t}\n}\n//#endregion\n//#region src/execution/mutation-defaults.ts\n/** Registers every generator the contributors provide, by id. Two contributors providing one id is an error naming both. */\nfunction collectMutationDefaultGenerators(contributors) {\n\tconst generators = /* @__PURE__ */ new Map();\n\tconst owners = /* @__PURE__ */ new Map();\n\tfor (const contributor of contributors) {\n\t\tconst nextGenerators = contributor.mutationDefaultGenerators?.() ?? [];\n\t\tfor (const generator of nextGenerators) {\n\t\t\tconst existingOwner = owners.get(generator.id);\n\t\t\tif (existingOwner !== void 0) throw runtimeError(\"RUNTIME.DUPLICATE_MUTATION_DEFAULT_GENERATOR\", `Duplicate mutation default generator '${generator.id}'.`, {\n\t\t\t\tid: generator.id,\n\t\t\t\texistingOwner,\n\t\t\t\tincomingOwner: contributor.id\n\t\t\t});\n\t\t\tgenerators.set(generator.id, generator);\n\t\t\towners.set(generator.id, contributor.id);\n\t\t}\n\t}\n\treturn generators;\n}\n/** Fails when the contract's mutation defaults name a generator the registry does not hold, listing every missing id and the fields that need it. */\nfunction assertMutationDefaultGeneratorsAvailable(execution, generatorRegistry) {\n\tconst defaults = execution?.mutations.defaults ?? [];\n\tif (defaults.length === 0) return;\n\tconst fieldsById = /* @__PURE__ */ new Map();\n\tfor (const mutationDefault of defaults) {\n\t\tconst phaseIds = new Set([mutationDefault.onCreate, mutationDefault.onUpdate].flatMap((phase) => phase?.kind === \"generator\" && !generatorRegistry.has(phase.id) ? [phase.id] : []));\n\t\tfor (const id of phaseIds) {\n\t\t\tconst fields = fieldsById.get(id) ?? [];\n\t\t\tfields.push(`${mutationDefault.ref.entry}.${mutationDefault.ref.field}`);\n\t\t\tfieldsById.set(id, fields);\n\t\t}\n\t}\n\tif (fieldsById.size === 0) return;\n\tconst ids = [...fieldsById.keys()];\n\tconst needs = [...fieldsById].map(([id, fields]) => `'${id}' for ${listInProse(fields)}`);\n\tthrow runtimeError(\"RUNTIME.MUTATION_DEFAULT_GENERATOR_MISSING\", `${ids.length === 1 ? `Contract requires mutation default generator ${needs[0]}, but no runtime component in the execution stack provides it.` : `Contract requires mutation default generators ${listInProse(needs)}, but no runtime component in the execution stack provides them.`} ${WHERE_GENERATORS_COME_FROM}`, {\n\t\tids,\n\t\tfields: [...fieldsById.values()].flat()\n\t});\n}\nconst WHERE_GENERATORS_COME_FROM = \"Built-in generators such as 'timestampNow' come from the database adapter's runtime descriptor, and others from the extension pack that defines them; include that component in the execution stack.\";\nfunction listInProse(items) {\n\treturn items.length > 1 ? `${items.slice(0, -1).join(\", \")} and ${items.at(-1)}` : items.join(\"\");\n}\nfunction computeExecutionDefaultValue(spec, generatorRegistry) {\n\tconst generator = generatorRegistry.get(spec.id);\n\tif (!generator) throw runtimeError(\"RUNTIME.MUTATION_DEFAULT_GENERATOR_MISSING\", `Contract references mutation default generator '${spec.id}' but no runtime component in the execution stack provides it. ${WHERE_GENERATORS_COME_FROM}`, { id: spec.id });\n\treturn generator.generate(spec.params);\n}\n/**\n* The defaults to write for one record: for each mutation default of the entry and namespace whose phase matches `op`, the generated value of every field the values do not carry. An update with no keys gets none.\n*/\nfunction applyMutationDefaults(execution, generatorRegistry, options) {\n\tconst defaults = execution?.mutations.defaults ?? [];\n\tif (defaults.length === 0) return [];\n\tconst isEmptyUpdate = options.op === \"update\" && Object.keys(options.values).length === 0;\n\tconst applied = [];\n\tconst appliedFields = /* @__PURE__ */ new Set();\n\tconst rowCache = /* @__PURE__ */ new Map();\n\tfor (const mutationDefault of defaults) {\n\t\tif (mutationDefault.ref.entry !== options.entry) continue;\n\t\tif (mutationDefault.ref.namespace !== options.namespace) continue;\n\t\tconst defaultSpec = options.op === \"create\" ? mutationDefault.onCreate : mutationDefault.onUpdate;\n\t\tif (!defaultSpec) continue;\n\t\tif (isEmptyUpdate) continue;\n\t\tconst fieldName = mutationDefault.ref.field;\n\t\tif (Object.hasOwn(options.values, fieldName) || appliedFields.has(fieldName)) continue;\n\t\tapplied.push({\n\t\t\tfield: fieldName,\n\t\t\tvalue: resolveScopedValue(defaultSpec, generatorRegistry, rowCache, options.defaultValueCache)\n\t\t});\n\t\tappliedFields.add(fieldName);\n\t}\n\treturn applied;\n}\nfunction resolveScopedValue(spec, generatorRegistry, rowCache, queryCache) {\n\tconst cache = scopedCache(generatorRegistry.get(spec.id)?.stability, rowCache, queryCache);\n\tif (!cache) return computeExecutionDefaultValue(spec, generatorRegistry);\n\tif (cache.has(spec.id)) return cache.get(spec.id);\n\tconst value = computeExecutionDefaultValue(spec, generatorRegistry);\n\tcache.set(spec.id, value);\n\treturn value;\n}\nfunction scopedCache(stability, rowCache, queryCache) {\n\tswitch (stability) {\n\t\tcase \"row\": return rowCache;\n\t\tcase \"query\": return queryCache;\n\t\tdefault: return;\n\t}\n}\n//#endregion\n//#region src/execution/run-with-middleware.ts\n/**\n* Drives a single query execution of `runDriver()` through the middleware\n* lifecycle's `interceptQuery` + row-source + termination phases.\n*\n* Lifecycle, in order:\n* 1. For each middleware in registration order: `interceptQuery(exec, ctx)`.\n* The first non-`undefined` result wins; subsequent middleware's\n* `interceptQuery` does not fire. On a hit, the runtime emits a\n* `middleware.interceptQuery` debug event naming the winning middleware,\n* switches the row source to the intercepted rows, and proceeds with\n* `source: 'middleware'`. On all-passthrough (every `interceptQuery`\n* returns `undefined` or is omitted), `source: 'driver'` is used and the\n* row source is `runDriver()`.\n* 2. Iterate the row source. On the driver path, for each row, for each\n* middleware in registration order: `onRow(row, exec, ctx)`; then yield\n* the row. On the intercepted hit path, `onRow` is skipped — intercepted\n* rows did not originate from a driver row stream — but rows are still\n* yielded to the consumer in order.\n* 3. On successful completion: for each middleware in registration order:\n* `afterQuery(exec, { rowCount, latencyMs, completed: true, source },\n* ctx)`.\n* 4. On any error thrown during steps 1–2: for each middleware in\n* registration order: `afterQuery(exec, { rowCount, latencyMs,\n* completed: false, source }, ctx)`. Errors thrown by `afterQuery`\n* during the error path are swallowed so they do not mask the original\n* error. The original error is then rethrown.\n*\n* `beforeQuery` is **not** fired here — see\n* {@link runBeforeQueryChain} in `before-execute-chain.ts`. Family runtimes\n* call that helper between the AST → plan lowering step and the parameter\n* encode step so middleware that mutates ParamRef values can have its\n* mutations visible to encode. `runQueryWithMiddleware` operates on the\n* fully-encoded plan; interceptors therefore observe a fully-mutated,\n* encoded plan.\n*\n* The `source` field on `AfterQueryResult` lets observers (telemetry, lints,\n* budgets) distinguish driver-served from middleware-served executions\n* without needing their own out-of-band signal.\n*\n* This helper is the single canonical implementation of the\n* intercept-and-row-source loop; family runtimes should not reimplement it.\n*/\nfunction runQueryWithMiddleware(exec, middleware, ctx, runDriver) {\n\tconst iterator = async function* () {\n\t\tconst startedAt = Date.now();\n\t\tlet rowCount = 0;\n\t\tlet completed = false;\n\t\tlet source = \"driver\";\n\t\tlet rowSource;\n\t\ttry {\n\t\t\tfor (const mw of middleware) {\n\t\t\t\tif (!mw.interceptQuery) continue;\n\t\t\t\tsource = \"middleware\";\n\t\t\t\tconst result = await mw.interceptQuery(exec, ctx);\n\t\t\t\tif (result === void 0) {\n\t\t\t\t\tsource = \"driver\";\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tctx.log.debug?.({\n\t\t\t\t\tevent: \"middleware.interceptQuery\",\n\t\t\t\t\tmiddleware: mw.name\n\t\t\t\t});\n\t\t\t\trowSource = blindCast(result.rows);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (source === \"driver\") rowSource = runDriver();\n\t\t\tfor await (const row of rowSource) {\n\t\t\t\tif (source === \"driver\") {\n\t\t\t\t\tfor (const mw of middleware) if (mw.onRow) await mw.onRow(row, exec, ctx);\n\t\t\t\t}\n\t\t\t\trowCount++;\n\t\t\t\tyield row;\n\t\t\t}\n\t\t\tcompleted = true;\n\t\t} catch (error) {\n\t\t\tawait notifyQueryCompletion(middleware, exec, ctx, {\n\t\t\t\trowCount,\n\t\t\t\tlatencyMs: Date.now() - startedAt,\n\t\t\t\tcompleted,\n\t\t\t\tsource\n\t\t\t}, true);\n\t\t\tthrow error;\n\t\t}\n\t\tawait notifyQueryCompletion(middleware, exec, ctx, {\n\t\t\trowCount,\n\t\t\tlatencyMs: Date.now() - startedAt,\n\t\t\tcompleted,\n\t\t\tsource\n\t\t}, false);\n\t};\n\treturn new AsyncIterableResult(iterator());\n}\n/**\n* Drives a single execute operation through the middleware\n* `interceptExecute` + statistics + termination phases.\n*\n* Lifecycle, in order:\n* 1. For each middleware in registration order: `interceptExecute(exec, ctx)`.\n* The first non-`undefined` result wins; subsequent middleware's\n* `interceptExecute` does not fire. On a hit, the runtime emits a\n* `middleware.interceptExecute` debug event naming the winning middleware,\n* uses the returned `stats`, and proceeds with `source: 'middleware'`.\n* On all-passthrough (every `interceptExecute` returns `undefined` or is\n* omitted), `source: 'driver'` is used and `runDriver()` supplies the\n* statistics.\n* 2. Execute operations return eager statistics. There is no row stream and\n* `onRow` does not fire.\n* 3. On successful completion: for each middleware in registration order:\n* `afterExecute(exec, { stats, latencyMs, completed: true, source }, ctx)`.\n* 4. On any error thrown during steps 1–2: for each middleware in\n* registration order: `afterExecute(exec, { latencyMs, completed: false,\n* source }, ctx)`. Errors thrown by `afterExecute` during the error path\n* are swallowed so they do not mask the original error. The original\n* error is then rethrown.\n*\n* `beforeExecute` is **not** fired here — see\n* {@link runBeforeExecuteChain} in `before-execute-chain.ts`. Family runtimes\n* call that helper between the AST → plan lowering step and the parameter\n* encode step so middleware that mutates ParamRef values can have its\n* mutations visible to encode. `runExecuteWithMiddleware` operates on the\n* fully-encoded plan; interceptors therefore observe a fully-mutated,\n* encoded plan.\n*\n* The `source` field on `AfterExecuteResult` lets observers (telemetry, lints,\n* budgets) distinguish driver-served from middleware-served executions\n* without needing their own out-of-band signal.\n*/\nasync function runExecuteWithMiddleware(exec, middleware, ctx, runDriver) {\n\tconst startedAt = Date.now();\n\tlet source = \"driver\";\n\tlet stats;\n\ttry {\n\t\tfor (const mw of middleware) {\n\t\t\tif (!mw.interceptExecute) continue;\n\t\t\tsource = \"middleware\";\n\t\t\tconst result = await mw.interceptExecute(exec, ctx);\n\t\t\tif (result === void 0) {\n\t\t\t\tsource = \"driver\";\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tctx.log.debug?.({\n\t\t\t\tevent: \"middleware.interceptExecute\",\n\t\t\t\tmiddleware: mw.name\n\t\t\t});\n\t\t\tstats = result.stats;\n\t\t\tbreak;\n\t\t}\n\t\tif (stats === void 0) stats = await runDriver();\n\t} catch (error) {\n\t\tconst latencyMs = Date.now() - startedAt;\n\t\tfor (const mw of middleware) {\n\t\t\tif (!mw.afterExecute) continue;\n\t\t\ttry {\n\t\t\t\tawait mw.afterExecute(exec, {\n\t\t\t\t\tlatencyMs,\n\t\t\t\t\tcompleted: false,\n\t\t\t\t\tsource\n\t\t\t\t}, ctx);\n\t\t\t} catch {}\n\t\t}\n\t\tthrow error;\n\t}\n\tconst latencyMs = Date.now() - startedAt;\n\tfor (const mw of middleware) if (mw.afterExecute) await mw.afterExecute(exec, {\n\t\tstats,\n\t\tlatencyMs,\n\t\tcompleted: true,\n\t\tsource\n\t}, ctx);\n\treturn stats;\n}\n/**\n* Calls each middleware's `afterTransaction` hook in registration order. A\n* thrown error is passed to `ctx.log.error` and swallowed, and later\n* middleware still run. Never rejects, so a query's result or a resolved\n* commit is never replaced by a hook's failure.\n*/\nasync function runAfterTransaction(exec, middleware, result, ctx) {\n\tfor (const mw of middleware) {\n\t\tif (!mw.afterTransaction) continue;\n\t\ttry {\n\t\t\tawait mw.afterTransaction(exec, result, ctx);\n\t\t} catch (error) {\n\t\t\ttry {\n\t\t\t\tctx.log.error({\n\t\t\t\t\tevent: \"middleware.afterTransaction.error\",\n\t\t\t\t\tmiddleware: mw.name,\n\t\t\t\t\terror\n\t\t\t\t});\n\t\t\t} catch {}\n\t\t}\n\t}\n}\n/**\n* Returns what a query outside a transaction calls when it ends: it runs `runStage` with `committed` when the query completed and `unknown` otherwise. Returns `undefined` when `runStage` is `undefined`.\n*/\nfunction onQueryEndOutsideTransaction(runStage) {\n\tif (runStage === void 0) return void 0;\n\treturn (ending) => runStage({ outcome: ending === \"completed\" ? \"committed\" : \"unknown\" });\n}\n/**\n* Streams `rows()` and then calls `onQueryEnd` exactly once with how the query ended: `completed` when the stream completes, `failed` when an error comes out of it, and `stopped` when the caller stops reading, calls `return()` or throws into the iterator, before or after the first row. Returns `rows()` itself when `onQueryEnd` is `undefined`.\n*/\nfunction reportQueryEnding(onQueryEnd, rows) {\n\treturn onQueryEnd === void 0 ? rows() : rowsThenQueryEnd(onQueryEnd, rows);\n}\nfunction rowsThenQueryEnd(onQueryEnd, rows) {\n\treturn { [Symbol.asyncIterator]() {\n\t\tlet thrownByCaller;\n\t\tconst generator = streamThenQueryEnd(onQueryEnd, rows, (error) => thrownByCaller !== void 0 && thrownByCaller.error === error);\n\t\tlet started = false;\n\t\tconst reportStoppedBeforeStart = async () => {\n\t\t\tif (started) return;\n\t\t\tstarted = true;\n\t\t\tawait onQueryEnd(\"stopped\");\n\t\t};\n\t\treturn {\n\t\t\tnext: () => {\n\t\t\t\tstarted = true;\n\t\t\t\treturn generator.next();\n\t\t\t},\n\t\t\treturn: async () => {\n\t\t\t\tawait reportStoppedBeforeStart();\n\t\t\t\treturn generator.return(void 0);\n\t\t\t},\n\t\t\tthrow: async (error) => {\n\t\t\t\tthrownByCaller = { error };\n\t\t\t\tawait reportStoppedBeforeStart();\n\t\t\t\treturn generator.throw(error);\n\t\t\t}\n\t\t};\n\t} };\n}\nasync function* streamThenQueryEnd(onQueryEnd, rows, isThrownByCaller) {\n\tlet ending = \"stopped\";\n\ttry {\n\t\tyield* rows();\n\t\tending = \"completed\";\n\t} catch (error) {\n\t\tif (!isThrownByCaller(error)) ending = \"failed\";\n\t\tthrow error;\n\t} finally {\n\t\tawait onQueryEnd(ending);\n\t}\n}\n/**\n* Runs `execute()` and then calls `onQueryEnd` exactly once: with `completed` when it resolves, and with `failed` when it rejects.\n*/\nasync function reportExecuteEnding(onQueryEnd, execute) {\n\tif (onQueryEnd === void 0) return execute();\n\tlet ending = \"failed\";\n\ttry {\n\t\tconst result = await execute();\n\t\tending = \"completed\";\n\t\treturn result;\n\t} finally {\n\t\tawait onQueryEnd(ending);\n\t}\n}\nasync function notifyQueryCompletion(middleware, exec, ctx, result, swallowErrors) {\n\tfor (const mw of middleware) {\n\t\tif (!mw.afterQuery) continue;\n\t\tif (swallowErrors) try {\n\t\t\tawait mw.afterQuery(exec, result, ctx);\n\t\t} catch {}\n\t\telse await mw.afterQuery(exec, result, ctx);\n\t}\n}\n//#endregion\n//#region src/execution/runtime-core.ts\n/**\n* Family-agnostic abstract runtime base.\n*\n* Defines the shared operation-specific middleware lifecycles:\n*\n* 1. `runBeforeCompile(plan)` — concrete; defaults to identity. SQL overrides\n* this to run its shared `beforeCompile` middleware-hook chain.\n* 2. `lower(plan)` — abstract. Each family produces its `*ExecutionPlan`\n* (SQL via `lowerSqlPlan`, Mongo via `adapter.lower`).\n* 3. Queries run `beforeQuery`; statements run `beforeExecute`. Both chains\n* run after lowering and before their matching driver terminal. Family\n* runtimes that expose a params mutator to downstream encoding override\n* the operation and call the matching helper at the pre-encode point.\n* 4. The matching runner processes `interceptQuery` or `interceptExecute`\n* before invoking the driver. Queries then fire `onRow` and `afterQuery`;\n* statements fire `afterExecute`.\n* 5. Every operation whose lowering (which encodes parameters) and before-hooks\n* succeeded fires `afterTransaction` once, as its last hook: `committed`\n* when it completed, `unknown` when it threw or the caller stopped reading\n* its rows. `reportQueryEnding` and `reportExecuteEnding` report how the\n* operation ended, and `onQueryEndOutsideTransaction` turns that into the\n* outcome; family runtimes that override `query` or `execute` call them\n* too, with {@link afterTransactionStageFor}.\n*\n* Concrete subclasses must implement `lower`, `runDriver`, `runExecute`, and\n* `close`.\n*\n* The class is generic over:\n* - `TPlan` — the family's pre-lowering plan type.\n* - `TExec` — the family's post-lowering (executable) plan type.\n* - `TMiddleware` — the family's middleware type. Constrained to\n* `RuntimeMiddleware<TExec>` because the operation-specific runners invoke\n* hooks with the lowered `TExec`. Middleware therefore sees the\n* post-lowering plan.\n*/\nvar RuntimeCore = class {\n\tmiddleware;\n\tctx;\n\tanyMiddlewareDeclaresAfterTransaction;\n\tconstructor(options) {\n\t\tthis.middleware = [...options.middleware];\n\t\tthis.ctx = options.ctx;\n\t\tthis.anyMiddlewareDeclaresAfterTransaction = this.middleware.some((mw) => mw.afterTransaction !== void 0);\n\t}\n\t/**\n\t* Returns the function that runs every middleware's `afterTransaction` hook for one operation with a given result, or `undefined` when no middleware declared the hook when the runtime was created.\n\t*/\n\tafterTransactionStageFor(exec, ctx) {\n\t\tif (!this.anyMiddlewareDeclaresAfterTransaction) return void 0;\n\t\treturn (result) => runAfterTransaction(exec, this.middleware, result, ctx);\n\t}\n\t/**\n\t* Pre-lowering hook for plan rewriting. Defaults to identity. Subclasses\n\t* may override to run a `beforeCompile` middleware chain (SQL does this\n\t* to support typed AST rewrites — see `before-compile-chain.ts`).\n\t*/\n\trunBeforeCompile(plan) {\n\t\treturn plan;\n\t}\n\tquery(plan, options) {\n\t\tconst self = this;\n\t\tconst signal = options?.signal;\n\t\tconst codecCtx = signal === void 0 ? {} : { signal };\n\t\tconst execCtx = {\n\t\t\t...self.ctx,\n\t\t\t...codecCtx,\n\t\t\tscope: options?.scope ?? self.ctx.scope,\n\t\t\tplanExecutionId: crypto.randomUUID()\n\t\t};\n\t\tasync function* generator() {\n\t\t\tcheckAborted(codecCtx, \"stream\");\n\t\t\tconst compiled = await self.runBeforeCompile(plan);\n\t\t\tconst exec = await self.lower(compiled, codecCtx);\n\t\t\tawait runBeforeQueryChain(exec, self.middleware, execCtx);\n\t\t\tyield* reportQueryEnding(onQueryEndOutsideTransaction(self.afterTransactionStageFor(exec, execCtx)), () => runQueryWithMiddleware(exec, self.middleware, execCtx, () => blindCast(self.runDriver(exec))));\n\t\t}\n\t\treturn new AsyncIterableResult(generator());\n\t}\n\tasync execute(plan, options) {\n\t\tconst signal = options?.signal;\n\t\tconst codecCtx = signal === void 0 ? {} : { signal };\n\t\tconst execCtx = {\n\t\t\t...this.ctx,\n\t\t\t...codecCtx,\n\t\t\tscope: options?.scope ?? this.ctx.scope,\n\t\t\tplanExecutionId: crypto.randomUUID()\n\t\t};\n\t\tcheckAborted(codecCtx, \"stream\");\n\t\tconst compiled = await this.runBeforeCompile(plan);\n\t\tconst exec = await this.lower(compiled, codecCtx);\n\t\tawait runBeforeExecuteChain(exec, this.middleware, execCtx);\n\t\treturn reportExecuteEnding(onQueryEndOutsideTransaction(this.afterTransactionStageFor(exec, execCtx)), () => runExecuteWithMiddleware(exec, this.middleware, execCtx, () => this.runExecute(exec)));\n\t}\n};\n//#endregion\n//#region src/execution/runtime-middleware.ts\nfunction checkMiddlewareCompatibility(middleware, runtimeFamilyId, runtimeTargetId) {\n\tif (middleware.targetId !== void 0 && middleware.familyId === void 0) throw runtimeError(\"RUNTIME.MIDDLEWARE_INCOMPATIBLE\", `Middleware '${middleware.name}' specifies targetId '${middleware.targetId}' without familyId`, {\n\t\tmiddleware: middleware.name,\n\t\ttargetId: middleware.targetId\n\t});\n\tif (middleware.familyId !== void 0 && middleware.familyId !== runtimeFamilyId) throw runtimeError(\"RUNTIME.MIDDLEWARE_FAMILY_MISMATCH\", `Middleware '${middleware.name}' requires family '${middleware.familyId}' but the runtime is configured for family '${runtimeFamilyId}'`, {\n\t\tmiddleware: middleware.name,\n\t\tmiddlewareFamilyId: middleware.familyId,\n\t\truntimeFamilyId\n\t});\n\tif (middleware.targetId !== void 0 && middleware.targetId !== runtimeTargetId) throw runtimeError(\"RUNTIME.MIDDLEWARE_TARGET_MISMATCH\", `Middleware '${middleware.name}' requires target '${middleware.targetId}' but the runtime is configured for target '${runtimeTargetId}'`, {\n\t\tmiddleware: middleware.name,\n\t\tmiddlewareTargetId: middleware.targetId,\n\t\truntimeTargetId\n\t});\n}\n//#endregion\n//#region src/execution/shape.ts\n/**\n* Phantom key an emitted model type carries to name its relation properties.\n* Never present at runtime; `Scalars` and `Shape` read it to tell relations from fields.\n*/\nconst RelationKeys = Symbol(\"RelationKeys\");\n//#endregion\n//#region src/meta-builder.ts\nvar MetaBuilderImpl = class {\n\t#kind;\n\t#terminalName;\n\t#annotations = /* @__PURE__ */ new Map();\n\tconstructor(kind, terminalName) {\n\t\tthis.#kind = kind;\n\t\tthis.#terminalName = terminalName;\n\t}\n\tget annotations() {\n\t\treturn this.#annotations;\n\t}\n\tannotate(annotation) {\n\t\tconst value = annotation;\n\t\tassertAnnotationsApplicable([value], this.#kind, this.#terminalName);\n\t\tthis.#annotations.set(value.namespace, value);\n\t\treturn this;\n\t}\n};\n/**\n* Construct a lane-side meta builder for a terminal of operation kind `K`.\n*\n* Lane terminals call this with their `kind` (`'read'` or `'write'`) and a\n* `terminalName` for error messages, hand the resulting builder to the\n* user-supplied configurator callback (typed as `MetaBuilder<K>`, the\n* narrower public view), and read `meta.annotations` afterwards to thread\n* the recorded values into `plan.meta.annotations`.\n*/\nfunction createMetaBuilder(kind, terminalName) {\n\treturn new MetaBuilderImpl(kind, terminalName);\n}\n//#endregion\nexport { AsyncIterableResult, RUNTIME_ABORTED, RelationKeys, RuntimeCore, applyMutationDefaults, assertAnnotationsApplicable, assertMutationDefaultGeneratorsAvailable, checkAborted, checkMiddlewareCompatibility, collectMutationDefaultGenerators, createMetaBuilder, defineAnnotation, isRuntimeError, onQueryEndOutsideTransaction, raceAgainstAbort, reportExecuteEnding, reportQueryEnding, runAfterTransaction, runBeforeExecuteChain, runBeforeQueryChain, runExecuteWithMiddleware, runQueryWithMiddleware, runtimeAborted, runtimeError };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAM,kBAAkB;;;;;;;;;;AAUxB,SAAS,eAAe,OAAO,OAAO;CACrC,MAAM,WAAW,aAAa,iBAAiB,4BAA4B,SAAS,EAAE,MAAM,CAAC;CAC7F,OAAO,OAAO,OAAO,UAAU,EAAE,MAAM,CAAC;AACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAS,mBAAmB;CAC3B,QAAQ,YAAY;EACnB,MAAM,YAAY,QAAQ;EAC1B,MAAM,eAAe,OAAO,OAAO,IAAI,IAAI,QAAQ,YAAY,CAAC;EAChE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