@prisma/orm-framework 8.0.0-rc.20-dev.14 → 8.0.0-rc.20-dev.15

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 (100) hide show
  1. package/dist/{authoring-C9wgJCNs.d.mts → authoring-C2UAuRfN.d.mts} +4 -14
  2. package/dist/{authoring-C9wgJCNs.d.mts.map → authoring-C2UAuRfN.d.mts.map} +1 -1
  3. package/dist/{authoring-BNzxszPO.mjs → authoring-CuGQP7_1.mjs} +4 -26
  4. package/dist/authoring-CuGQP7_1.mjs.map +1 -0
  5. package/dist/{binder-DJRPMfsD-D7PEvJOJ.d.mts → binder-BszqDG1t-icu83_4f.d.mts} +16 -12
  6. package/dist/{binder-DJRPMfsD-D7PEvJOJ.d.mts.map → binder-BszqDG1t-icu83_4f.d.mts.map} +1 -1
  7. package/dist/{components-Cl5lB_Iw.d.mts → components-BenCVFk4.d.mts} +3 -3
  8. package/dist/{components-Cl5lB_Iw.d.mts.map → components-BenCVFk4.d.mts.map} +1 -1
  9. package/dist/components.d.mts +10 -10
  10. package/dist/components.mjs +4 -4
  11. package/dist/components__authoring.d.mts +4 -4
  12. package/dist/components__authoring.mjs +3 -3
  13. package/dist/components__components.d.mts +3 -3
  14. package/dist/components__control.d.mts +3 -3
  15. package/dist/components__control.mjs +2 -2
  16. package/dist/components__execution.d.mts +1 -1
  17. package/dist/components__psl-ast.d.mts +3 -3
  18. package/dist/{config-types-j3Elycru.d.mts → config-types-BJ79TZCl.d.mts} +5 -5
  19. package/dist/{config-types-j3Elycru.d.mts.map → config-types-BJ79TZCl.d.mts.map} +1 -1
  20. package/dist/config.d.mts +1 -1
  21. package/dist/config__config-types.d.mts +1 -1
  22. package/dist/contract-authoring.d.mts +19 -54
  23. package/dist/contract-authoring.d.mts.map +1 -1
  24. package/dist/contract-authoring.mjs +15 -28
  25. package/dist/contract-authoring.mjs.map +1 -1
  26. package/dist/control-B3OS8JEw.d.mts +1 -0
  27. package/dist/{control-BeXOxtXA-DRX60Yu3.d.mts → control-BeXOxtXA-BU8y-LiK.d.mts} +2 -2
  28. package/dist/{control-BeXOxtXA-DRX60Yu3.d.mts.map → control-BeXOxtXA-BU8y-LiK.d.mts.map} +1 -1
  29. package/dist/{control-Df-HE5e4.d.mts → control-CS1uqJj_.d.mts} +8 -9
  30. package/dist/{control-Df-HE5e4.d.mts.map → control-CS1uqJj_.d.mts.map} +1 -1
  31. package/dist/{control-DKOWXGUq.mjs → control-Dn1CMH6R.mjs} +8 -16
  32. package/dist/control-Dn1CMH6R.mjs.map +1 -0
  33. package/dist/{control-MllEQmML-tXi_WAy3.mjs → control-MllEQmML-BdhmgQVr.mjs} +2 -2
  34. package/dist/{control-MllEQmML-tXi_WAy3.mjs.map → control-MllEQmML-BdhmgQVr.mjs.map} +1 -1
  35. package/dist/{declarations-BgUAq1RG-Dz_-EI1Q.mjs → declarations-BgUAq1RG-DPNkVezv.mjs} +2 -2
  36. package/dist/{declarations-BgUAq1RG-Dz_-EI1Q.mjs.map → declarations-BgUAq1RG-DPNkVezv.mjs.map} +1 -1
  37. package/dist/errors.d.mts +4 -4
  38. package/dist/errors.mjs +3 -3
  39. package/dist/errors__control.d.mts +2 -2
  40. package/dist/errors__control.mjs +1 -1
  41. package/dist/errors__execution.d.mts +1 -1
  42. package/dist/errors__execution.mjs +1 -1
  43. package/dist/errors__migration.d.mts +1 -1
  44. package/dist/errors__migration.mjs +1 -1
  45. package/dist/{execution-D5tvAHf4.d.mts → execution-BPJbNttJ.d.mts} +2 -2
  46. package/dist/{execution-D5tvAHf4.d.mts.map → execution-BPJbNttJ.d.mts.map} +1 -1
  47. package/dist/{execution-CgR7dFMU.d.mts → execution-BWR_z8XI.d.mts} +2 -2
  48. package/dist/{execution-CgR7dFMU.d.mts.map → execution-BWR_z8XI.d.mts.map} +1 -1
  49. package/dist/{execution-DMsDYKSr.mjs → execution-GInmnTZ9.mjs} +2 -2
  50. package/dist/{execution-DMsDYKSr.mjs.map → execution-GInmnTZ9.mjs.map} +1 -1
  51. package/dist/{expressions-CMQzbnHk-BL2zN0Iv.mjs → expressions-CMQzbnHk-FYhlr1aG.mjs} +2 -2
  52. package/dist/{expressions-CMQzbnHk-BL2zN0Iv.mjs.map → expressions-CMQzbnHk-FYhlr1aG.mjs.map} +1 -1
  53. package/dist/{framework-authoring-DSqNuI8w-BMQDwpgF.d.mts → framework-authoring-ebqZ8M_M-DIDpVcUB.d.mts} +17 -97
  54. package/dist/framework-authoring-ebqZ8M_M-DIDpVcUB.d.mts.map +1 -0
  55. package/dist/{framework-components-BhbsOiJc-BpDfGsqn.d.mts → framework-components-BqHA1V92-D9j8uXa-.d.mts} +3 -3
  56. package/dist/{framework-components-BhbsOiJc-BpDfGsqn.d.mts.map → framework-components-BqHA1V92-D9j8uXa-.d.mts.map} +1 -1
  57. package/dist/ids.d.mts +3 -98
  58. package/dist/ids.d.mts.map +1 -1
  59. package/dist/ids.mjs +12 -52
  60. package/dist/ids.mjs.map +1 -1
  61. package/dist/{migration-DpdvEAEC.mjs → migration-D57w8Uxv.mjs} +2 -2
  62. package/dist/{migration-DpdvEAEC.mjs.map → migration-D57w8Uxv.mjs.map} +1 -1
  63. package/dist/{migration-Ox7HWa_t.d.mts → migration-Dk1sYIvs.d.mts} +2 -2
  64. package/dist/{migration-Ox7HWa_t.d.mts.map → migration-Dk1sYIvs.d.mts.map} +1 -1
  65. package/dist/{parse-bZgfjovA-BNgYhylT.mjs → parse-bZgfjovA-gD3hVy3X.mjs} +3 -3
  66. package/dist/{parse-bZgfjovA-BNgYhylT.mjs.map → parse-bZgfjovA-gD3hVy3X.mjs.map} +1 -1
  67. package/dist/{parse-djL5wker-sY18Mt5K.d.mts → parse-djL5wker-DnMlKOii.d.mts} +6 -6
  68. package/dist/{parse-djL5wker-sY18Mt5K.d.mts.map → parse-djL5wker-DnMlKOii.d.mts.map} +1 -1
  69. package/dist/{psl-ast-C8W7AM1f-DYtFq1nP.d.mts → psl-ast-0oMzInxd-Nx9cHmcc.d.mts} +3 -3
  70. package/dist/{psl-ast-C8W7AM1f-DYtFq1nP.d.mts.map → psl-ast-0oMzInxd-Nx9cHmcc.d.mts.map} +1 -1
  71. package/dist/psl-ast-CFQfCJeM.d.mts +2 -0
  72. package/dist/psl-parser.d.mts +12 -12
  73. package/dist/psl-parser.mjs +17 -55
  74. package/dist/psl-parser.mjs.map +1 -1
  75. package/dist/psl-parser__format.d.mts +1 -1
  76. package/dist/psl-parser__format.mjs +3 -3
  77. package/dist/psl-parser__interpret.d.mts +30 -30
  78. package/dist/psl-parser__interpret.d.mts.map +1 -1
  79. package/dist/psl-parser__interpret.mjs +110 -298
  80. package/dist/psl-parser__interpret.mjs.map +1 -1
  81. package/dist/psl-parser__syntax.d.mts +1 -1
  82. package/dist/psl-parser__syntax.mjs +3 -3
  83. package/dist/psl-printer.d.mts +4 -4
  84. package/dist/psl-printer.mjs +1 -1
  85. package/dist/temporal-type-aliases-BIiamFSH-BrpK13hf.d.mts +133 -0
  86. package/dist/temporal-type-aliases-BIiamFSH-BrpK13hf.d.mts.map +1 -0
  87. package/dist/{temporal-presets-5TK1pTYJ-DmhrnMP1.mjs → temporal-type-aliases-D98ei6Fj-DEtfAQYL.mjs} +29 -281
  88. package/dist/temporal-type-aliases-D98ei6Fj-DEtfAQYL.mjs.map +1 -0
  89. package/dist/{type-constructor-calls-BLf-HsFy-CHiXyVEH.mjs → type-constructor-calls-CNd1Xlw2-DjyX5mKn.mjs} +52 -7
  90. package/dist/type-constructor-calls-CNd1Xlw2-DjyX5mKn.mjs.map +1 -0
  91. package/package.json +15 -15
  92. package/dist/authoring-BNzxszPO.mjs.map +0 -1
  93. package/dist/control-CV9doMHb.d.mts +0 -1
  94. package/dist/control-DKOWXGUq.mjs.map +0 -1
  95. package/dist/framework-authoring-DSqNuI8w-BMQDwpgF.d.mts.map +0 -1
  96. package/dist/psl-ast-sZ1tAYRc.d.mts +0 -2
  97. package/dist/temporal-presets-5TK1pTYJ-DmhrnMP1.mjs.map +0 -1
  98. package/dist/temporal-presets-De4oKG36-DlGYQgF1.d.mts +0 -258
  99. package/dist/temporal-presets-De4oKG36-DlGYQgF1.d.mts.map +0 -1
  100. package/dist/type-constructor-calls-BLf-HsFy-CHiXyVEH.mjs.map +0 -1
@@ -1,13 +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 { t as InternalError } from "./internal-error-ChGYPVpq-DhUD05u0.mjs";
4
- import { d as isColumnDefaultLiteralInputValue, f as isExecutionMutationDefaultValue } from "./types-B8ULzMAX.mjs";
5
4
  import { n as invariant } from "./assertions-Dw1lZz_Q.mjs";
6
5
  import { n as notOk, r as ok } from "./result-8OXF26MN.mjs";
7
6
  import { n as runtimeError } from "./runtime-error-BA9d7XjZ-BlT8t6LB.mjs";
8
7
  import { o as assembleDataTypes } from "./data-type-V6mcDhcG-DVQAPOQT.mjs";
9
8
  import { c as tsTemplateText, o as tsQuotedTextSource } from "./dist-D1f6xr7F.mjs";
10
- //#region ../../../1-framework/1-core/framework-components/dist/temporal-presets-5TK1pTYJ.mjs
9
+ //#region ../../../1-framework/1-core/framework-components/dist/temporal-type-aliases-D98ei6Fj.mjs
11
10
  /** The descriptor kinds a `type` namespace holds as leaves. */
12
11
  const AUTHORING_TYPE_DESCRIPTOR_KINDS = ["typeConstructor", "typeAlias"];
13
12
  const AUTHORING_WARNING_BATCH_THRESHOLD = 5;
@@ -84,33 +83,19 @@ function resolveEnumCodecId(block, ctx) {
84
83
  codecSpan: typeAttr.argSpans?.["codecId"] ?? typeAttr.span
85
84
  };
86
85
  }
86
+ /** Refuses the `authoring.field` key, which held field presets before Prisma 8 removed them. A component built against the old types would otherwise lose its presets silently. */
87
+ function assertNoAuthoringFieldNamespace(componentId, authoring) {
88
+ if (authoring === void 0 || !Object.hasOwn(authoring, "field")) return;
89
+ throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Component "${componentId}" contributes authoring.field, which Prisma 8 removed with field presets. Contribute a type alias (kind: 'typeAlias') or a type constructor in authoring.type.`);
90
+ }
87
91
  function isAuthoringArgRef(value) {
88
92
  if (typeof value !== "object" || value === null || value.kind !== "arg") return false;
89
- const { index, path } = value;
90
- if (typeof index !== "number" || !Number.isInteger(index) || index < 0) return false;
91
- if (path !== void 0 && (!Array.isArray(path) || path.some((s) => typeof s !== "string"))) return false;
92
- return true;
93
- }
94
- function isAuthoringSelectRef(value) {
95
- if (!isAuthoringTemplateRecord(value) || value["kind"] !== "select") return false;
96
- const index = value["index"];
97
- const path = value["path"];
98
- const cases = value["cases"];
99
- if (typeof index !== "number" || !Number.isInteger(index) || index < 0) return false;
100
- if (path !== void 0 && (!Array.isArray(path) || path.some((s) => typeof s !== "string"))) return false;
101
- return typeof cases === "object" && cases !== null && !Array.isArray(cases);
93
+ const { index } = value;
94
+ return typeof index === "number" && Number.isInteger(index) && index >= 0;
102
95
  }
103
96
  function isAuthoringTemplateRecord(value) {
104
97
  return typeof value === "object" && value !== null && !Array.isArray(value);
105
98
  }
106
- function readTemplateArgumentValue(args, index, path) {
107
- let value = args[index];
108
- for (const segment of path ?? []) {
109
- if (!isAuthoringTemplateRecord(value) || !Object.hasOwn(value, segment)) return;
110
- value = value[segment];
111
- }
112
- return value;
113
- }
114
99
  function isAuthoringTypeConstructorDescriptor(value) {
115
100
  return "kind" in value && value.kind === "typeConstructor";
116
101
  }
@@ -130,9 +115,6 @@ function getAuthoringTypeConstructor(contributions, path) {
130
115
  }
131
116
  return current !== void 0 && isAuthoringTypeConstructorDescriptor(current) ? current : void 0;
132
117
  }
133
- function isAuthoringFieldPresetDescriptor(value) {
134
- return "kind" in value && value.kind === "fieldPreset";
135
- }
136
118
  function isAuthoringEntityTypeDescriptor(value) {
137
119
  return "kind" in value && value.kind === "entity";
138
120
  }
@@ -152,8 +134,7 @@ function isWellFormedDescriptor(value, descriptorKinds) {
152
134
  const kind = value.kind;
153
135
  if (typeof kind !== "string" || !(typeof descriptorKinds === "string" ? [descriptorKinds] : descriptorKinds).includes(kind)) return false;
154
136
  switch (kind) {
155
- case "typeConstructor":
156
- case "fieldPreset": {
137
+ case "typeConstructor": {
157
138
  if (!("output" in value)) return false;
158
139
  const output = value.output;
159
140
  return typeof output === "object" && output !== null;
@@ -202,7 +183,7 @@ function deepCopyNamespace(source, descriptorKind) {
202
183
  /**
203
184
  * Merges `source` into `target` recursively at the descriptor-namespace
204
185
  * level. `descriptorKind` is the `kind` value, or values, ('typeConstructor'
205
- * and 'typeAlias', 'fieldPreset', 'entity', or 'pslBlock') that identifies a descriptor
186
+ * and 'typeAlias', 'entity', or 'pslBlock') that identifies a descriptor
206
187
  * (terminal merge point; same-path registrations across components are
207
188
  * reported as duplicates) as opposed to a sub-namespace (recursion target).
208
189
  *
@@ -307,7 +288,6 @@ function visitTemplateArgRefs(template, visit) {
307
288
  if (template === void 0) return;
308
289
  if (isAuthoringArgRef(template)) {
309
290
  visit(template);
310
- visitTemplateArgRefs(template.default, visit);
311
291
  return;
312
292
  }
313
293
  if (Array.isArray(template)) {
@@ -321,8 +301,8 @@ function visitTemplateArgRefs(template, visit) {
321
301
  * per contributing component at assembly (which supplies `contributedBy`
322
302
  * for attribution). Rejects what the types cannot express — entity-ref
323
303
  * constructors are skipped (their output derives from the referenced
324
- * entity): every `typeParams` arg-ref (including refs inside arg-ref
325
- * defaults) must point at a declared argument index.
304
+ * entity): every `typeParams` arg-ref must point at a declared argument
305
+ * index.
326
306
  */
327
307
  function assertResolvableTypeConstructorTemplates(namespace, contributedBy, path = []) {
328
308
  for (const [name, value] of Object.entries(namespace)) {
@@ -490,16 +470,12 @@ function assertUniqueModelAttributeNames(entries) {
490
470
  seen.set(attribute, path);
491
471
  }
492
472
  }
493
- function assertNoCrossRegistryCollisions(typeNamespace, fieldNamespace, entityTypeNamespace = {}, pslBlockNamespace = {}, modelAttributeNamespace = {}) {
473
+ function assertNoCrossRegistryCollisions(typeNamespace, entityTypeNamespace = {}, pslBlockNamespace = {}, modelAttributeNamespace = {}) {
494
474
  const typePaths = new Set(collectDescriptorPaths(typeNamespace, isAuthoringTypeDescriptor));
495
- const fieldPaths = new Set(collectDescriptorPaths(fieldNamespace, isAuthoringFieldPresetDescriptor));
496
475
  const entityPaths = new Set(collectDescriptorPaths(entityTypeNamespace, isAuthoringEntityTypeDescriptor));
497
- const ambiguityHint = "Register each path in only one of authoringContributions.field / authoringContributions.type / authoringContributions.entityTypes.";
498
- for (const fieldPath of fieldPaths) if (typePaths.has(fieldPath)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Ambiguous authoring registry path "${fieldPath}". The same path is registered as both a type constructor or type alias and a field preset; PSL resolution would be ambiguous. ${ambiguityHint}`);
499
- for (const entityPath of entityPaths) if (typePaths.has(entityPath) || fieldPaths.has(entityPath)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Ambiguous authoring registry path "${entityPath}". The same path is registered as an entity contribution AND as a type constructor, type alias or field preset; PSL resolution would be ambiguous. ${ambiguityHint}`);
476
+ for (const entityPath of entityPaths) if (typePaths.has(entityPath)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Ambiguous authoring registry path "${entityPath}". The same path is registered as an entity contribution AND as a type constructor or type alias; PSL resolution would be ambiguous. Register each path in only one of authoringContributions.type / authoringContributions.entityTypes.`);
500
477
  assertPslBlocksHaveFactories(entityTypeNamespace, pslBlockNamespace);
501
478
  assertUniqueModelAttributeNames(collectModelAttributeEntries(modelAttributeNamespace));
502
- assertSelectTemplatesMatchOptionArgs(typeNamespace, fieldNamespace, entityTypeNamespace);
503
479
  }
504
480
  function collectDescriptorNodes(namespace, isLeaf, path = []) {
505
481
  const nodes = [];
@@ -513,67 +489,9 @@ function collectDescriptorNodes(namespace, isLeaf, path = []) {
513
489
  }
514
490
  return nodes;
515
491
  }
516
- function collectSelectRefs(value, found) {
517
- if (typeof value !== "object" || value === null) return;
518
- if (isAuthoringSelectRef(value)) {
519
- found.push(value);
520
- for (const caseTemplate of Object.values(value.cases)) collectSelectRefs(caseTemplate, found);
521
- return;
522
- }
523
- if (isAuthoringArgRef(value)) {
524
- collectSelectRefs(value.default, found);
525
- return;
526
- }
527
- if (Array.isArray(value)) {
528
- for (const entry of value) collectSelectRefs(entry, found);
529
- return;
530
- }
531
- for (const entry of Object.values(value)) collectSelectRefs(entry, found);
532
- }
533
- function validateSelectRefsAgainstArgs(label, helperPath, args, templateRoot) {
534
- const selects = [];
535
- collectSelectRefs(templateRoot, selects);
536
- for (const select of selects) {
537
- const position = `#${select.index + 1}`;
538
- let descriptor = args?.[select.index];
539
- if (descriptor === void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" select template references argument ${position}, but the helper declares no argument at that position.`);
540
- for (const segment of select.path ?? []) {
541
- descriptor = descriptor.kind === "object" ? descriptor.properties[segment] : void 0;
542
- if (descriptor === void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" select template references argument ${position} at path "${(select.path ?? []).join(".")}", which does not resolve to a declared argument property.`);
543
- }
544
- if (descriptor.kind !== "option") throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" select template references argument ${position}, which is kind "${descriptor.kind}"; select requires an option argument.`);
545
- const argumentLabel = descriptor.name !== void 0 ? `"${descriptor.name}"` : position;
546
- const missing = descriptor.values.filter((value) => !Object.hasOwn(select.cases, value));
547
- if (missing.length > 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" option argument ${argumentLabel} allows [${descriptor.values.join(", ")}] but the select template has no case for: ${missing.join(", ")}.`);
548
- const values = descriptor.values;
549
- const unreachable = Object.keys(select.cases).filter((key) => !values.includes(key));
550
- if (unreachable.length > 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" select template has case(s) not allowed by option argument ${argumentLabel}: ${unreachable.join(", ")}. Allowed values: [${values.join(", ")}].`);
551
- }
552
- }
553
- /**
554
- * Every `select` template node must target an option argument whose `values`
555
- * exactly cover the node's `cases` — a legal token with no case and a case no
556
- * token can reach are both declaration bugs, caught here at pack-registration
557
- * time rather than at first resolution.
558
- */
559
- function assertSelectTemplatesMatchOptionArgs(typeNamespace, fieldNamespace, entityTypeNamespace) {
560
- for (const [helperPath, descriptor] of collectDescriptorNodes(fieldNamespace, isAuthoringFieldPresetDescriptor)) validateSelectRefsAgainstArgs("field", helperPath, descriptor.args, descriptor.output);
561
- for (const [helperPath, descriptor] of collectDescriptorNodes(typeNamespace, isAuthoringTypeDescriptor)) if (isAuthoringTypeConstructorDescriptor(descriptor)) validateSelectRefsAgainstArgs("type", helperPath, descriptor.args, descriptor.output);
562
- for (const [helperPath, descriptor] of collectDescriptorNodes(entityTypeNamespace, isAuthoringEntityTypeDescriptor)) if ("template" in descriptor.output) validateSelectRefsAgainstArgs("entityType", helperPath, descriptor.args, descriptor.output.template);
563
- }
564
492
  function resolveAuthoringTemplateValue(template, args) {
565
493
  if (template === void 0) return;
566
- if (isAuthoringArgRef(template)) {
567
- const value = readTemplateArgumentValue(args, template.index, template.path);
568
- if (value === void 0 && template.default !== void 0) return resolveAuthoringTemplateValue(template.default, args);
569
- return value;
570
- }
571
- if (isAuthoringSelectRef(template)) {
572
- const value = readTemplateArgumentValue(args, template.index, template.path);
573
- if (value === void 0) return;
574
- if (typeof value !== "string" || !Object.hasOwn(template.cases, value)) throw new InternalError(`Authoring template select has no case for value "${String(value)}"`);
575
- return resolveAuthoringTemplateValue(template.cases[value], args);
576
- }
494
+ if (isAuthoringArgRef(template)) return args[template.index];
577
495
  if (Array.isArray(template)) return template.map((value) => resolveAuthoringTemplateValue(value, args));
578
496
  if (typeof template === "object" && template !== null) {
579
497
  const resolved = {};
@@ -585,46 +503,17 @@ function resolveAuthoringTemplateValue(template, args) {
585
503
  }
586
504
  return template;
587
505
  }
588
- function validateAuthoringArgument(descriptor, value, path) {
589
- if (value === void 0) {
590
- if (descriptor.optional) return;
591
- throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${path} is missing`);
592
- }
593
- if (descriptor.kind === "value") return;
594
- if (descriptor.kind === "object") {
595
- if (typeof value !== "object" || value === null || Array.isArray(value)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${path} must be an object`);
596
- const input = value;
597
- const expectedKeys = new Set(Object.keys(descriptor.properties));
598
- for (const key of Object.keys(input)) if (!expectedKeys.has(key)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${path} contains unknown property "${key}"`);
599
- for (const [key, propertyDescriptor] of Object.entries(descriptor.properties)) validateAuthoringArgument(propertyDescriptor, input[key], `${path}.${key}`);
600
- return;
601
- }
602
- if (descriptor.kind === "option") {
603
- if (typeof value !== "string" || !descriptor.values.includes(value)) {
604
- const quoted = descriptor.values.map((option) => JSON.stringify(option));
605
- throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${path} ${quoted.length === 0 ? "takes no value" : `must be ${quoted.length === 1 ? quoted.join("") : `one of ${quoted.join(", ")}`}`}; received ${describeReceivedArgument(value)}`);
606
- }
607
- return;
608
- }
609
- if (typeof value !== "number" || Number.isNaN(value)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${path} must be a number`);
610
- if (descriptor.integer && !Number.isInteger(value)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${path} must be an integer`);
611
- if (descriptor.minimum !== void 0 && value < descriptor.minimum) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${path} must be >= ${descriptor.minimum}, received ${value}`);
612
- if (descriptor.maximum !== void 0 && value > descriptor.maximum) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${path} must be <= ${descriptor.maximum}, received ${value}`);
613
- }
614
506
  function validateAuthoringHelperArguments(helperPath, descriptors, args) {
615
507
  const expected = descriptors ?? [];
616
508
  const minimumArgs = expected.reduce((count, descriptor, index) => descriptor.optional ? count : index + 1, 0);
617
509
  if (args.length < minimumArgs || args.length > expected.length) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${helperPath} expects ${minimumArgs === expected.length ? expected.length : `${minimumArgs}-${expected.length}`} argument(s), received ${args.length}`);
618
510
  expected.forEach((descriptor, index) => {
619
- validateAuthoringArgument(descriptor, args[index], argumentLabel(helperPath, descriptor, index));
511
+ if (args[index] === void 0 && !descriptor.optional) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${argumentLabel(helperPath, descriptor, index)} is missing`);
620
512
  });
621
513
  }
622
514
  function argumentLabel(helperPath, descriptor, index) {
623
515
  return descriptor.name === void 0 ? `Authoring helper argument at ${helperPath}[${index}]` : `Argument "${descriptor.name}" of ${helperPath}`;
624
516
  }
625
- function describeReceivedArgument(value) {
626
- return typeof value === "string" ? JSON.stringify(value) : String(value);
627
- }
628
517
  function argumentIndexOf(template) {
629
518
  let index;
630
519
  visitTemplateArgRefs(template, (ref) => {
@@ -650,7 +539,7 @@ function authoringTypeParamsIssue(template, typeParams, paramsSchema) {
650
539
  };
651
540
  }
652
541
  /**
653
- * Checks the type parameters a constructor or preset produced against its codec's parameter schema, which is where the bounds of a data type's parameters are written. A failure names the argument the failing parameter came from.
542
+ * Checks the type parameters a constructor produced against its codec's parameter schema, which is where the bounds of a data type's parameters are written. A failure names the argument the failing parameter came from.
654
543
  */
655
544
  function validateAuthoringTypeParams(helperPath, template, typeParams, paramsSchema) {
656
545
  const issue = authoringTypeParamsIssue(template, typeParams, paramsSchema);
@@ -670,40 +559,6 @@ function resolveAuthoringStorageTypeTemplate(template, args) {
670
559
  ...ifDefined("typeParams", normalizedTypeParams)
671
560
  };
672
561
  }
673
- function resolveAuthoringColumnDefaultTemplate(template, args) {
674
- if (template.kind === "literal") {
675
- const value = resolveAuthoringTemplateValue(template.value, args);
676
- if (value === void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", "Resolved authoring literal default must not be undefined");
677
- if (!isColumnDefaultLiteralInputValue(value)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Resolved authoring literal default must be a JSON-serializable value or Date, received ${String(value)}`);
678
- return {
679
- kind: "literal",
680
- value
681
- };
682
- }
683
- const expression = resolveAuthoringTemplateValue(template.expression, args);
684
- if (expression === void 0 || typeof expression === "object" && expression !== null) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Resolved authoring function default expression must resolve to a primitive, received ${String(expression)}`);
685
- return {
686
- kind: "function",
687
- expression: String(expression)
688
- };
689
- }
690
- function resolveExecutionMutationDefaultPhase(phase, template, args) {
691
- const value = resolveAuthoringTemplateValue(template, args);
692
- if (value === void 0) return;
693
- if (!isExecutionMutationDefaultValue(value)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring preset executionDefaults.${phase} did not resolve to a valid generator descriptor (kind: 'generator', id: string).`);
694
- if (value.params !== void 0 && Object.keys(value.params).length === 0) {
695
- const { params: _unfilled, ...generator } = value;
696
- return generator;
697
- }
698
- return value;
699
- }
700
- function resolveAuthoringExecutionDefaultsTemplate(template, args) {
701
- const phases = {
702
- ...ifDefined("onCreate", template.onCreate !== void 0 ? resolveExecutionMutationDefaultPhase("onCreate", template.onCreate, args) : void 0),
703
- ...ifDefined("onUpdate", template.onUpdate !== void 0 ? resolveExecutionMutationDefaultPhase("onUpdate", template.onUpdate, args) : void 0)
704
- };
705
- return Object.keys(phases).length === 0 ? void 0 : phases;
706
- }
707
562
  function instantiateAuthoringTypeConstructor(descriptor, args) {
708
563
  return resolveAuthoringStorageTypeTemplate(descriptor.output, args);
709
564
  }
@@ -778,16 +633,6 @@ function instantiateAuthoringEntityType(helperPath, descriptor, args, ctx) {
778
633
  validateAuthoringHelperArguments(helperPath, descriptor.args, args);
779
634
  return blindCast(resolveAuthoringTemplateValue(descriptor.output.template, args));
780
635
  }
781
- function instantiateAuthoringFieldPreset(descriptor, args) {
782
- return {
783
- descriptor: resolveAuthoringStorageTypeTemplate(descriptor.output, args),
784
- nullable: descriptor.output.nullable ?? false,
785
- ...ifDefined("default", descriptor.output.default !== void 0 ? resolveAuthoringColumnDefaultTemplate(descriptor.output.default, args) : void 0),
786
- ...ifDefined("executionDefaults", descriptor.output.executionDefaults !== void 0 ? resolveAuthoringExecutionDefaultsTemplate(descriptor.output.executionDefaults, args) : void 0),
787
- id: descriptor.output.id ?? false,
788
- unique: descriptor.output.unique ?? false
789
- };
790
- }
791
636
  const UNKNOWN_CONTRIBUTOR = "<unknown>";
792
637
  /** Merge every component's PSL support for its data types, refusing two claims on one key. */
793
638
  function assembleAuthoringDataTypes(components) {
@@ -819,15 +664,13 @@ function descriptorsIn(namespace, isLeaf, path = []) {
819
664
  return descriptorsIn(value, isLeaf, currentPath);
820
665
  });
821
666
  }
822
- /** Every type constructor and field preset a component contributes. */
667
+ /** Every type constructor a component contributes. */
823
668
  function contributedHelpers(component) {
824
- return [...descriptorsIn(component.authoring?.type, isAuthoringTypeDescriptor).flatMap(({ path, descriptor }) => isAuthoringTypeConstructorDescriptor(descriptor) ? [{
669
+ return descriptorsIn(component.authoring?.type, isAuthoringTypeDescriptor).flatMap(({ path, descriptor }) => isAuthoringTypeConstructorDescriptor(descriptor) ? [{
825
670
  path,
826
- descriptor
827
- }] : []), ...descriptorsIn(component.authoring?.field, isAuthoringFieldPresetDescriptor)].map((entry) => ({
828
- ...entry,
671
+ descriptor,
829
672
  contributedBy: component.id ?? UNKNOWN_CONTRIBUTOR
830
- }));
673
+ }] : []);
831
674
  }
832
675
  /** The data types a contract source can write: each entry's own, and every type a plain-number entry classifies a number as. */
833
676
  function writableDataTypes(entries) {
@@ -836,15 +679,14 @@ function writableDataTypes(entries) {
836
679
  /** Refuses a value argument whose data type is unregistered, or that no contract source can write, directly or through a cast, and a type-constructor argument that is not a value. */
837
680
  function enforceValueArguments(support, contributed, writable) {
838
681
  const { path, descriptor, contributedBy } = contributed;
839
- const kind = descriptor.kind === "typeConstructor" ? "type constructor" : "field preset";
840
682
  for (const [index, argument] of (descriptor.args ?? []).entries()) {
841
- const label = `Argument ${argument.name === void 0 ? `#${index + 1}` : `"${argument.name}"`} of ${kind} "${path}"`;
842
- if (argument.kind !== "value" && descriptor.kind === "typeConstructor") throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `${label} contributed by "${contributedBy}" is an argument of kind "${argument.kind}", but a type constructor's argument is a value of a data type. Declare it as { kind: 'value', dataType: ... }, naming the data type its value belongs to.`, {
683
+ const label = `Argument ${argument.name === void 0 ? `#${index + 1}` : `"${argument.name}"`} of type constructor "${path}"`;
684
+ const argumentKind = argument.kind;
685
+ if (argumentKind !== "value") throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `${label} contributed by "${contributedBy}" is an argument of kind "${argumentKind}", but a type constructor's argument is a value of a data type. Declare it as { kind: 'value', dataType: ... }, naming the data type its value belongs to.`, {
843
686
  packId: contributedBy,
844
687
  contribution: path,
845
688
  reason: "type-constructor-argument-not-a-value"
846
689
  });
847
- if (argument.kind !== "value") continue;
848
690
  const type = support.lookup.get(argument.dataType);
849
691
  if (type === void 0) throw runtimeError("CONTRACT.DATA_TYPE_UNREGISTERED", `${label} names data type "${argument.dataType}", which no component registers. Contributed by "${contributedBy}".`, {
850
692
  dataType: argument.dataType,
@@ -917,7 +759,7 @@ function enforceDataTypeAssemblyInvariants(input) {
917
759
  }
918
760
  }
919
761
  /**
920
- * The data types the components register, with their authoring entries, as every contract source reads values with. Refuses two registrations of one data type or one entry key, every case {@link enforceDataTypeAssemblyInvariants} lists, a value argument of a type constructor or field preset whose data type is unregistered or that no contract source can write, and a type-constructor argument that is not a value. ADR 254.
762
+ * The data types the components register, with their authoring entries, as every contract source reads values with. Refuses two registrations of one data type or one entry key, every case {@link enforceDataTypeAssemblyInvariants} lists, a value argument of a type constructor whose data type is unregistered or that no contract source can write, and a type-constructor argument that is not a value. ADR 254.
921
763
  */
922
764
  function assembleDataTypeSupport(components, dataTypeOfCodec) {
923
765
  const { lookup, declared } = assembleDataTypes(components);
@@ -1140,55 +982,19 @@ function holdsCharacterThatNeedsAnEscape(text) {
1140
982
  return false;
1141
983
  }
1142
984
  /**
1143
- * Canonical id for the wall-clock-now mutation default generator. It flows to the control-plane descriptor and the temporal field presets below, to each family's runtime generator, and to the authoring surfaces (PSL `temporal.updatedAt()`, TS `field.temporal.updatedAt()`) through the descriptor.
985
+ * Canonical id for the wall-clock-now mutation default generator. It flows to the control-plane descriptor, to each family's runtime generator, and to the `now()` binding of the codecs that store it.
1144
986
  */
1145
987
  const TIMESTAMP_NOW_GENERATOR_ID = "timestampNow";
1146
988
  /** Builds the control-plane descriptor for the wall-clock-now mutation default generator. */
1147
989
  function timestampNowControlDescriptor() {
1148
990
  return { id: TIMESTAMP_NOW_GENERATOR_ID };
1149
991
  }
1150
- /**
1151
- * Builds the `temporal.{createdAt,updatedAt}` field-preset pair. `createdAt` lowers to an execution generator on `onCreate`; `updatedAt` lowers to the same generator on both `onCreate` and `onUpdate`. The target supplies the storage template of its timestamp codec, which the presets carry through unchanged; everything else is shared, so PSL and TS authoring lower to byte-identical contracts across targets.
1152
- */
1153
- /* @__NO_SIDE_EFFECTS__ */
1154
- function temporalAuthoringPresets(input) {
1155
- const { generatorId: requestedGeneratorId, ...storage } = input;
1156
- const generatorId = requestedGeneratorId ?? "timestampNow";
1157
- return {
1158
- createdAt: {
1159
- kind: "fieldPreset",
1160
- output: {
1161
- ...storage,
1162
- executionDefaults: { onCreate: {
1163
- kind: "generator",
1164
- id: generatorId
1165
- } }
1166
- }
1167
- },
1168
- updatedAt: {
1169
- kind: "fieldPreset",
1170
- output: {
1171
- ...storage,
1172
- executionDefaults: {
1173
- onCreate: {
1174
- kind: "generator",
1175
- id: generatorId
1176
- },
1177
- onUpdate: {
1178
- kind: "generator",
1179
- id: generatorId
1180
- }
1181
- }
1182
- }
1183
- }
1184
- };
1185
- }
1186
992
  const NOW_CALL = {
1187
993
  name: "now",
1188
994
  args: {}
1189
995
  };
1190
996
  /**
1191
- * Builds the `temporal.{CreatedAt,UpdatedAt}` type alias pair for a target's timestamp column type. `CreatedAt` calls `now()` on create; `UpdatedAt` calls it on create and on update. The target's `now()` binding for the codec picks the generator, so each alias stores what the matching `temporal.createdAt()` and `temporal.updatedAt()` presets store. `value` names the value the codec gives in TypeScript, such as `a JavaScript Date`, and ends each alias's documentation.
997
+ * Builds the `temporal.{CreatedAt,UpdatedAt}` type alias pair for a target's timestamp column type. `CreatedAt` calls `now()` on create; `UpdatedAt` calls it on create and on update. The target's `now()` binding for the codec picks the generator. `value` names the value the codec gives in TypeScript, such as `a JavaScript Date`, and ends each alias's documentation.
1192
998
  */
1193
999
  /* @__NO_SIDE_EFFECTS__ */
1194
1000
  function temporalTypeAliases(type, value) {
@@ -1212,65 +1018,7 @@ function temporalTypeAliases(type, value) {
1212
1018
  }
1213
1019
  };
1214
1020
  }
1215
- const TEMPORAL_ON_CREATE_ARG = {
1216
- name: "onCreate",
1217
- kind: "option",
1218
- values: ["now"],
1219
- optional: true
1220
- };
1221
- const TEMPORAL_ON_UPDATE_ARG = {
1222
- name: "onUpdate",
1223
- kind: "option",
1224
- values: ["now"],
1225
- optional: true
1226
- };
1227
- /**
1228
- * Selects a generator descriptor for the preset's `now` token. The token is preset vocabulary; the generator id never appears in a user's spelling (ADR 169 — these generators are preset-only).
1229
- */
1230
- function temporalPhaseTemplate(index, generatorId) {
1231
- return {
1232
- kind: "select",
1233
- index,
1234
- cases: { now: {
1235
- kind: "generator",
1236
- id: generatorId
1237
- } }
1238
- };
1239
- }
1240
- /**
1241
- * {@link temporalPhaseTemplate} for a generator that takes params. `params` is the template of the generator's params, resolved against the preset's arguments.
1242
- */
1243
- function temporalPhaseTemplateWithParams(index, generatorId, params) {
1244
- return {
1245
- kind: "select",
1246
- index,
1247
- cases: { now: {
1248
- kind: "generator",
1249
- id: generatorId,
1250
- params
1251
- } }
1252
- };
1253
- }
1254
- /**
1255
- * Builds a `temporal.<codec>` field preset for a codec with no type parameters, carrying the codec's storage template through unchanged. Both phase arguments are optional, and omitting one omits that phase. `generatorId` names the generator a `now` argument selects, `timestampNow` when omitted.
1256
- */
1257
- /* @__NO_SIDE_EFFECTS__ */
1258
- function temporalCodecPreset(input) {
1259
- const { generatorId, ...storage } = input;
1260
- const nowGeneratorId = generatorId ?? "timestampNow";
1261
- return {
1262
- kind: "fieldPreset",
1263
- args: [TEMPORAL_ON_CREATE_ARG, TEMPORAL_ON_UPDATE_ARG],
1264
- output: {
1265
- ...storage,
1266
- executionDefaults: {
1267
- onCreate: temporalPhaseTemplate(0, nowGeneratorId),
1268
- onUpdate: temporalPhaseTemplate(1, nowGeneratorId)
1269
- }
1270
- }
1271
- };
1272
- }
1273
1021
  //#endregion
1274
- export { isAuthoringTypeAliasDescriptor as A, resolveTemplateTagEscapes as B, instantiateAuthoringTypeConstructorFromValues as C, isAuthoringModelAttributeDescriptor as D, isAuthoringFieldPresetDescriptor as E, printTaggedLiteral as F, temporalPhaseTemplateWithParams as G, temporalAuthoringPresets as H, printedTaggedLiteralReadsBack as I, tsTaggedTemplateSource as J, temporalTypeAliases as K, resolveAuthoringTemplateValue as L, isAuthoringTypeDescriptor as M, mergeAuthoringAttributeSpecs as N, isAuthoringPslBlockDescriptor as O, mergeAuthoringNamespaces as P, resolveEnumCodecId as R, instantiateAuthoringTypeConstructor as S, isAuthoringEntityTypeDescriptor as T, temporalCodecPreset as U, resolveTypeAliasGenerators as V, temporalPhaseTemplate as W, validateAuthoringTypeParams as X, validateAuthoringHelperArguments as Y, flushAuthoringWarnings as _, TIMESTAMP_NOW_GENERATOR_ID as a, instantiateAuthoringFieldPreset as b, assertNoCrossRegistryCollisions as c, canonicalizeTaggedLiteralBody as d, classifyEnumMemberType as f, describeTaggedLiteralFailure as g, contributedHelpers as h, TEMPORAL_ON_UPDATE_ARG as i, isAuthoringTypeConstructorDescriptor as j, isAuthoringSelectRef as k, assertResolvableTypeConstructorTemplates as l, collectScalarTypeConstructors as m, TAGGED_LITERAL_MAX_BYTES as n, assembleAuthoringDataTypes as o, collectContributedDescriptorPaths as p, timestampNowControlDescriptor as q, TEMPORAL_ON_CREATE_ARG as r, assembleDataTypeSupport as s, AUTHORING_TYPE_DESCRIPTOR_KINDS as t, assertTypeAliasesValid as u, getAuthoringTypeConstructor as v, isAuthoringArgRef as w, instantiateAuthoringTypeAlias as x, instantiateAuthoringEntityType as y, resolvePslBacktickEscapes as z };
1022
+ export { mergeAuthoringNamespaces as A, tsTaggedTemplateSource as B, isAuthoringEntityTypeDescriptor as C, isAuthoringTypeConstructorDescriptor as D, isAuthoringTypeAliasDescriptor as E, resolvePslBacktickEscapes as F, validateAuthoringTypeParams as H, resolveTemplateTagEscapes as I, resolveTypeAliasGenerators as L, printedTaggedLiteralReadsBack as M, resolveAuthoringTemplateValue as N, isAuthoringTypeDescriptor as O, resolveEnumCodecId as P, temporalTypeAliases as R, isAuthoringArgRef as S, isAuthoringPslBlockDescriptor as T, validateAuthoringHelperArguments as V, getAuthoringTypeConstructor as _, assembleDataTypeSupport as a, instantiateAuthoringTypeConstructor as b, assertResolvableTypeConstructorTemplates as c, classifyEnumMemberType as d, collectContributedDescriptorPaths as f, flushAuthoringWarnings as g, describeTaggedLiteralFailure as h, assembleAuthoringDataTypes as i, printTaggedLiteral as j, mergeAuthoringAttributeSpecs as k, assertTypeAliasesValid as l, contributedHelpers as m, TAGGED_LITERAL_MAX_BYTES as n, assertNoAuthoringFieldNamespace as o, collectScalarTypeConstructors as p, TIMESTAMP_NOW_GENERATOR_ID as r, assertNoCrossRegistryCollisions as s, AUTHORING_TYPE_DESCRIPTOR_KINDS as t, canonicalizeTaggedLiteralBody as u, instantiateAuthoringEntityType as v, isAuthoringModelAttributeDescriptor as w, instantiateAuthoringTypeConstructorFromValues as x, instantiateAuthoringTypeAlias as y, timestampNowControlDescriptor as z };
1275
1023
 
1276
- //# sourceMappingURL=temporal-presets-5TK1pTYJ-DmhrnMP1.mjs.map
1024
+ //# sourceMappingURL=temporal-type-aliases-D98ei6Fj-DEtfAQYL.mjs.map