@samva/markup 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/AGENTS.md +19 -0
  2. package/dist/{ast-63I-VLQx.d.ts → ast-BrDtApwS.d.ts} +34 -60
  3. package/dist/ast.d.ts +2 -2
  4. package/dist/ast.js +4 -52
  5. package/dist/{catalog-Ck1tAGwO.d.ts → catalog-60eaYC7b.d.ts} +2 -2
  6. package/dist/{checks-DXuERO4B.js → checks-DBweSIPN.js} +18 -20
  7. package/dist/checks.d.ts +1 -1
  8. package/dist/checks.js +1 -1
  9. package/dist/classes.d.ts +1 -1
  10. package/dist/compile-sms.d.ts +3 -3
  11. package/dist/compile-whatsapp.d.ts +5 -5
  12. package/dist/compile-whatsapp.js +3 -3
  13. package/dist/compile.d.ts +5 -5
  14. package/dist/compile.js +5 -5
  15. package/dist/compiler.d.ts +8 -5
  16. package/dist/compiler.js +45 -45
  17. package/dist/components.d.ts +4 -4
  18. package/dist/conditionals.js +56 -24
  19. package/dist/corpus-BjYMqOoY.d.ts +106 -0
  20. package/dist/{css-ar2lU3NC.d.ts → css-COcFOT1y.d.ts} +4 -5
  21. package/dist/diagnostics-BMYtBCQk.d.ts +46 -0
  22. package/dist/diagnostics-OcQKQYSY.d.ts +49 -0
  23. package/dist/diagnostics.d.ts +2 -2
  24. package/dist/diagnostics.js +24 -33
  25. package/dist/{elements-DtwKlFVH.d.ts → elements-BzjjnoCS.d.ts} +40 -161
  26. package/dist/email/components.d.ts +1 -1
  27. package/dist/email/components.js +40 -10
  28. package/dist/email/diagnostics.d.ts +1 -1
  29. package/dist/email/diagnostics.js +8 -43
  30. package/dist/email/elements.d.ts +1 -1
  31. package/dist/email/html.d.ts +2 -2
  32. package/dist/email/html.js +11 -10
  33. package/dist/email/jsx-dev-runtime.d.ts +3 -21
  34. package/dist/email/jsx-runtime.d.ts +1 -1
  35. package/dist/email/jsx-runtime.js +29 -3
  36. package/dist/email/render.d.ts +4 -4
  37. package/dist/email/render.js +1 -1
  38. package/dist/email/selection.d.ts +20 -31
  39. package/dist/email/selection.js +1 -53
  40. package/dist/email/source-edit.d.ts +1 -1
  41. package/dist/email/source-edit.js +2 -2
  42. package/dist/email/stylesheets.d.ts +1 -1
  43. package/dist/email/text.d.ts +1 -1
  44. package/dist/email/text.js +3 -3
  45. package/dist/emit.d.ts +2 -2
  46. package/dist/emit.js +5 -5
  47. package/dist/footer.js +7 -4
  48. package/dist/guards-eV1qLbf2.js +9 -0
  49. package/dist/{input-schema-BIfzI63B.d.ts → input-schema-7dPFVvNE.d.ts} +2 -2
  50. package/dist/input-schema-zjkgrXn2.js +455 -0
  51. package/dist/input-schema.d.ts +1 -1
  52. package/dist/input-schema.js +1 -169
  53. package/dist/interpolate.d.ts +9 -12
  54. package/dist/interpolate.js +1 -19
  55. package/dist/jsx-dev-runtime.d.ts +2 -2
  56. package/dist/{jsx-runtime-C5k_Zq0A.d.ts → jsx-runtime-I-1nCtl2.d.ts} +3 -3
  57. package/dist/jsx-runtime.d.ts +1 -1
  58. package/dist/jsx-runtime.js +3 -3
  59. package/dist/lexer.js +17 -5
  60. package/dist/model.d.ts +18 -33
  61. package/dist/model.js +4 -17
  62. package/dist/ops-2aiiYO7m.js +630 -0
  63. package/dist/ops.d.ts +78 -172
  64. package/dist/ops.js +2 -546
  65. package/dist/{parser-CGBS73Gz.d.ts → parser-CQcASEyy.d.ts} +5 -5
  66. package/dist/parser.d.ts +1 -1
  67. package/dist/parser.js +8 -8
  68. package/dist/{predicate-CvkzT-a2.js → predicate-BI6uRRM-.js} +24 -14
  69. package/dist/{predicate-G2SeSvoN.d.ts → predicate-M-05Nd7R.d.ts} +4 -4
  70. package/dist/predicate.d.ts +1 -1
  71. package/dist/predicate.js +1 -1
  72. package/dist/presets/category-mapping.d.ts +1 -1
  73. package/dist/presets/corpus.d.ts +1 -1
  74. package/dist/presets/corpus.js +74 -117
  75. package/dist/presets/public-gallery.d.ts +2 -2
  76. package/dist/presets/public-gallery.js +17 -9
  77. package/dist/presets/public-handoff.d.ts +4 -4
  78. package/dist/presets/public-handoff.js +10 -9
  79. package/dist/presets/public-preview-artifacts.d.ts +7 -5
  80. package/dist/presets/public-preview-artifacts.js +10 -9
  81. package/dist/presets/showcase.d.ts +1 -1
  82. package/dist/presets.d.ts +1 -1
  83. package/dist/printer.d.ts +1 -1
  84. package/dist/{render-ykQhtMs_.js → render-aaJBnsXK.js} +44 -27
  85. package/dist/render-template.d.ts +7 -7
  86. package/dist/render-template.js +6 -6
  87. package/dist/{showcase-C_xgl6hz.d.ts → showcase-DGZAWn4Z.d.ts} +2 -2
  88. package/dist/{source-locations-BCJQnIfU.d.ts → source-locations-DrCM82Ym.d.ts} +4 -26
  89. package/dist/source-locations.d.ts +2 -2
  90. package/dist/source-locations.js +3 -26
  91. package/dist/{template-Dy5yOPyp.d.ts → template-DWftqh4x.d.ts} +4 -4
  92. package/dist/template.d.ts +1 -1
  93. package/dist/template.js +3 -3
  94. package/dist/theme-css.d.ts +3 -3
  95. package/dist/theme-css.js +3 -3
  96. package/dist/theme.js +25 -2
  97. package/dist/tsx-source-instrumentation.d.ts +1 -3
  98. package/dist/tsx-source-instrumentation.js +6 -6
  99. package/dist/tsx-tracer.d.ts +7 -11
  100. package/dist/tsx-tracer.js +165 -165
  101. package/dist/{variables-if1VrV34.d.ts → variables-J_L3qxRa.d.ts} +2 -2
  102. package/dist/variables.d.ts +1 -1
  103. package/dist/variables.js +4 -4
  104. package/package.json +4 -3
  105. package/dist/corpus-U2EeALvS.d.ts +0 -234
  106. package/dist/diagnostics-Djd9ckLg.d.ts +0 -90
  107. package/dist/diagnostics-oveE-laV.d.ts +0 -79
@@ -0,0 +1,455 @@
1
+ import { n as isObject, t as hasProperty } from "./guards-eV1qLbf2.js";
2
+ import { Validator } from "@cfworker/json-schema";
3
+ //#region src/json-schema/2020-12/meta/applicator.json
4
+ var applicator_default = {
5
+ $schema: "https://json-schema.org/draft/2020-12/schema",
6
+ $id: "https://json-schema.org/draft/2020-12/meta/applicator",
7
+ $vocabulary: { "https://json-schema.org/draft/2020-12/vocab/applicator": true },
8
+ $dynamicAnchor: "meta",
9
+ title: "Applicator vocabulary meta-schema",
10
+ type: ["object", "boolean"],
11
+ properties: {
12
+ "prefixItems": { "$ref": "#/$defs/schemaArray" },
13
+ "items": { "$dynamicRef": "#meta" },
14
+ "contains": { "$dynamicRef": "#meta" },
15
+ "additionalProperties": { "$dynamicRef": "#meta" },
16
+ "properties": {
17
+ "type": "object",
18
+ "additionalProperties": { "$dynamicRef": "#meta" },
19
+ "default": {}
20
+ },
21
+ "patternProperties": {
22
+ "type": "object",
23
+ "additionalProperties": { "$dynamicRef": "#meta" },
24
+ "propertyNames": { "format": "regex" },
25
+ "default": {}
26
+ },
27
+ "dependentSchemas": {
28
+ "type": "object",
29
+ "additionalProperties": { "$dynamicRef": "#meta" },
30
+ "default": {}
31
+ },
32
+ "propertyNames": { "$dynamicRef": "#meta" },
33
+ "if": { "$dynamicRef": "#meta" },
34
+ "then": { "$dynamicRef": "#meta" },
35
+ "else": { "$dynamicRef": "#meta" },
36
+ "allOf": { "$ref": "#/$defs/schemaArray" },
37
+ "anyOf": { "$ref": "#/$defs/schemaArray" },
38
+ "oneOf": { "$ref": "#/$defs/schemaArray" },
39
+ "not": { "$dynamicRef": "#meta" }
40
+ },
41
+ $defs: { "schemaArray": {
42
+ "type": "array",
43
+ "minItems": 1,
44
+ "items": { "$dynamicRef": "#meta" }
45
+ } }
46
+ };
47
+ //#endregion
48
+ //#region src/json-schema/2020-12/meta/content.json
49
+ var content_default = {
50
+ $schema: "https://json-schema.org/draft/2020-12/schema",
51
+ $id: "https://json-schema.org/draft/2020-12/meta/content",
52
+ $vocabulary: { "https://json-schema.org/draft/2020-12/vocab/content": true },
53
+ $dynamicAnchor: "meta",
54
+ title: "Content vocabulary meta-schema",
55
+ type: ["object", "boolean"],
56
+ properties: {
57
+ "contentEncoding": { "type": "string" },
58
+ "contentMediaType": { "type": "string" },
59
+ "contentSchema": { "$dynamicRef": "#meta" }
60
+ }
61
+ };
62
+ //#endregion
63
+ //#region src/json-schema/2020-12/meta/core.json
64
+ var core_default = {
65
+ $schema: "https://json-schema.org/draft/2020-12/schema",
66
+ $id: "https://json-schema.org/draft/2020-12/meta/core",
67
+ $vocabulary: { "https://json-schema.org/draft/2020-12/vocab/core": true },
68
+ $dynamicAnchor: "meta",
69
+ title: "Core vocabulary meta-schema",
70
+ type: ["object", "boolean"],
71
+ properties: {
72
+ "$id": {
73
+ "$ref": "#/$defs/uriReferenceString",
74
+ "$comment": "Non-empty fragments not allowed.",
75
+ "pattern": "^[^#]*#?$"
76
+ },
77
+ "$schema": { "$ref": "#/$defs/uriString" },
78
+ "$ref": { "$ref": "#/$defs/uriReferenceString" },
79
+ "$anchor": { "$ref": "#/$defs/anchorString" },
80
+ "$dynamicRef": { "$ref": "#/$defs/uriReferenceString" },
81
+ "$dynamicAnchor": { "$ref": "#/$defs/anchorString" },
82
+ "$vocabulary": {
83
+ "type": "object",
84
+ "propertyNames": { "$ref": "#/$defs/uriString" },
85
+ "additionalProperties": { "type": "boolean" }
86
+ },
87
+ "$comment": { "type": "string" },
88
+ "$defs": {
89
+ "type": "object",
90
+ "additionalProperties": { "$dynamicRef": "#meta" }
91
+ }
92
+ },
93
+ $defs: {
94
+ "anchorString": {
95
+ "type": "string",
96
+ "pattern": "^[A-Za-z_][-A-Za-z0-9._]*$"
97
+ },
98
+ "uriString": {
99
+ "type": "string",
100
+ "format": "uri"
101
+ },
102
+ "uriReferenceString": {
103
+ "type": "string",
104
+ "format": "uri-reference"
105
+ }
106
+ }
107
+ };
108
+ //#endregion
109
+ //#region src/json-schema/2020-12/meta/format-annotation.json
110
+ var format_annotation_default = {
111
+ $schema: "https://json-schema.org/draft/2020-12/schema",
112
+ $id: "https://json-schema.org/draft/2020-12/meta/format-annotation",
113
+ $vocabulary: { "https://json-schema.org/draft/2020-12/vocab/format-annotation": true },
114
+ $dynamicAnchor: "meta",
115
+ title: "Format vocabulary meta-schema for annotation results",
116
+ type: ["object", "boolean"],
117
+ properties: { "format": { "type": "string" } }
118
+ };
119
+ //#endregion
120
+ //#region src/json-schema/2020-12/meta/meta-data.json
121
+ var meta_data_default = {
122
+ $schema: "https://json-schema.org/draft/2020-12/schema",
123
+ $id: "https://json-schema.org/draft/2020-12/meta/meta-data",
124
+ $vocabulary: { "https://json-schema.org/draft/2020-12/vocab/meta-data": true },
125
+ $dynamicAnchor: "meta",
126
+ title: "Meta-data vocabulary meta-schema",
127
+ type: ["object", "boolean"],
128
+ properties: {
129
+ "title": { "type": "string" },
130
+ "description": { "type": "string" },
131
+ "default": true,
132
+ "deprecated": {
133
+ "type": "boolean",
134
+ "default": false
135
+ },
136
+ "readOnly": {
137
+ "type": "boolean",
138
+ "default": false
139
+ },
140
+ "writeOnly": {
141
+ "type": "boolean",
142
+ "default": false
143
+ },
144
+ "examples": {
145
+ "type": "array",
146
+ "items": true
147
+ }
148
+ }
149
+ };
150
+ //#endregion
151
+ //#region src/json-schema/2020-12/meta/unevaluated.json
152
+ var unevaluated_default = {
153
+ $schema: "https://json-schema.org/draft/2020-12/schema",
154
+ $id: "https://json-schema.org/draft/2020-12/meta/unevaluated",
155
+ $vocabulary: { "https://json-schema.org/draft/2020-12/vocab/unevaluated": true },
156
+ $dynamicAnchor: "meta",
157
+ title: "Unevaluated applicator vocabulary meta-schema",
158
+ type: ["object", "boolean"],
159
+ properties: {
160
+ "unevaluatedItems": { "$dynamicRef": "#meta" },
161
+ "unevaluatedProperties": { "$dynamicRef": "#meta" }
162
+ }
163
+ };
164
+ //#endregion
165
+ //#region src/json-schema/2020-12/meta/validation.json
166
+ var validation_default = {
167
+ $schema: "https://json-schema.org/draft/2020-12/schema",
168
+ $id: "https://json-schema.org/draft/2020-12/meta/validation",
169
+ $vocabulary: { "https://json-schema.org/draft/2020-12/vocab/validation": true },
170
+ $dynamicAnchor: "meta",
171
+ title: "Validation vocabulary meta-schema",
172
+ type: ["object", "boolean"],
173
+ properties: {
174
+ "type": { "anyOf": [{ "$ref": "#/$defs/simpleTypes" }, {
175
+ "type": "array",
176
+ "items": { "$ref": "#/$defs/simpleTypes" },
177
+ "minItems": 1,
178
+ "uniqueItems": true
179
+ }] },
180
+ "const": true,
181
+ "enum": {
182
+ "type": "array",
183
+ "items": true
184
+ },
185
+ "multipleOf": {
186
+ "type": "number",
187
+ "exclusiveMinimum": 0
188
+ },
189
+ "maximum": { "type": "number" },
190
+ "exclusiveMaximum": { "type": "number" },
191
+ "minimum": { "type": "number" },
192
+ "exclusiveMinimum": { "type": "number" },
193
+ "maxLength": { "$ref": "#/$defs/nonNegativeInteger" },
194
+ "minLength": { "$ref": "#/$defs/nonNegativeIntegerDefault0" },
195
+ "pattern": {
196
+ "type": "string",
197
+ "format": "regex"
198
+ },
199
+ "maxItems": { "$ref": "#/$defs/nonNegativeInteger" },
200
+ "minItems": { "$ref": "#/$defs/nonNegativeIntegerDefault0" },
201
+ "uniqueItems": {
202
+ "type": "boolean",
203
+ "default": false
204
+ },
205
+ "maxContains": { "$ref": "#/$defs/nonNegativeInteger" },
206
+ "minContains": {
207
+ "$ref": "#/$defs/nonNegativeInteger",
208
+ "default": 1
209
+ },
210
+ "maxProperties": { "$ref": "#/$defs/nonNegativeInteger" },
211
+ "minProperties": { "$ref": "#/$defs/nonNegativeIntegerDefault0" },
212
+ "required": { "$ref": "#/$defs/stringArray" },
213
+ "dependentRequired": {
214
+ "type": "object",
215
+ "additionalProperties": { "$ref": "#/$defs/stringArray" }
216
+ }
217
+ },
218
+ $defs: {
219
+ "nonNegativeInteger": {
220
+ "type": "integer",
221
+ "minimum": 0
222
+ },
223
+ "nonNegativeIntegerDefault0": {
224
+ "$ref": "#/$defs/nonNegativeInteger",
225
+ "default": 0
226
+ },
227
+ "simpleTypes": { "enum": [
228
+ "array",
229
+ "boolean",
230
+ "integer",
231
+ "null",
232
+ "number",
233
+ "object",
234
+ "string"
235
+ ] },
236
+ "stringArray": {
237
+ "type": "array",
238
+ "items": { "type": "string" },
239
+ "uniqueItems": true,
240
+ "default": []
241
+ }
242
+ }
243
+ };
244
+ //#endregion
245
+ //#region src/input-schema.ts
246
+ const meta = new Validator({
247
+ $schema: "https://json-schema.org/draft/2020-12/schema",
248
+ $id: "https://json-schema.org/draft/2020-12/schema",
249
+ $vocabulary: {
250
+ "https://json-schema.org/draft/2020-12/vocab/core": true,
251
+ "https://json-schema.org/draft/2020-12/vocab/applicator": true,
252
+ "https://json-schema.org/draft/2020-12/vocab/unevaluated": true,
253
+ "https://json-schema.org/draft/2020-12/vocab/validation": true,
254
+ "https://json-schema.org/draft/2020-12/vocab/meta-data": true,
255
+ "https://json-schema.org/draft/2020-12/vocab/format-annotation": true,
256
+ "https://json-schema.org/draft/2020-12/vocab/content": true
257
+ },
258
+ $dynamicAnchor: "meta",
259
+ title: "Core and Validation specifications meta-schema",
260
+ allOf: [
261
+ { "$ref": "meta/core" },
262
+ { "$ref": "meta/applicator" },
263
+ { "$ref": "meta/unevaluated" },
264
+ { "$ref": "meta/validation" },
265
+ { "$ref": "meta/meta-data" },
266
+ { "$ref": "meta/format-annotation" },
267
+ { "$ref": "meta/content" }
268
+ ],
269
+ type: ["object", "boolean"],
270
+ $comment: "This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",
271
+ properties: {
272
+ "definitions": {
273
+ "$comment": "\"definitions\" has been replaced by \"$defs\".",
274
+ "type": "object",
275
+ "additionalProperties": { "$dynamicRef": "#meta" },
276
+ "deprecated": true,
277
+ "default": {}
278
+ },
279
+ "dependencies": {
280
+ "$comment": "\"dependencies\" has been split and replaced by \"dependentSchemas\" and \"dependentRequired\" in order to serve their differing semantics.",
281
+ "type": "object",
282
+ "additionalProperties": { "anyOf": [{ "$dynamicRef": "#meta" }, { "$ref": "meta/validation#/$defs/stringArray" }] },
283
+ "deprecated": true,
284
+ "default": {}
285
+ },
286
+ "$recursiveAnchor": {
287
+ "$comment": "\"$recursiveAnchor\" has been replaced by \"$dynamicAnchor\".",
288
+ "$ref": "meta/core#/$defs/anchorString",
289
+ "deprecated": true
290
+ },
291
+ "$recursiveRef": {
292
+ "$comment": "\"$recursiveRef\" has been replaced by \"$dynamicRef\".",
293
+ "$ref": "meta/core#/$defs/uriReferenceString",
294
+ "deprecated": true
295
+ }
296
+ }
297
+ }, "2020-12", false);
298
+ for (const part of [
299
+ applicator_default,
300
+ content_default,
301
+ core_default,
302
+ format_annotation_default,
303
+ meta_data_default,
304
+ unevaluated_default,
305
+ validation_default
306
+ ]) meta.addSchema(part);
307
+ /** JSON Schema dialect accepted by template publications. */
308
+ const INPUT_SCHEMA_DIALECT = "https://json-schema.org/draft/2020-12/schema";
309
+ const canonicalJson = (value) => {
310
+ if (Array.isArray(value)) return value.map(canonicalJson);
311
+ if (isObject(value)) return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, item]) => [key, canonicalJson(item)]));
312
+ return value;
313
+ };
314
+ const annotations = /* @__PURE__ */ new Set([
315
+ "title",
316
+ "description",
317
+ "default",
318
+ "examples",
319
+ "deprecated",
320
+ "readOnly",
321
+ "writeOnly",
322
+ "$comment"
323
+ ]);
324
+ const scalarKeywords = /* @__PURE__ */ new Set([
325
+ "$schema",
326
+ "$ref",
327
+ "type",
328
+ "enum",
329
+ "const",
330
+ "required",
331
+ "minProperties",
332
+ "maxProperties",
333
+ "minItems",
334
+ "maxItems",
335
+ "uniqueItems",
336
+ "minLength",
337
+ "maxLength",
338
+ "pattern",
339
+ "minimum",
340
+ "maximum",
341
+ "exclusiveMinimum",
342
+ "exclusiveMaximum",
343
+ "multipleOf"
344
+ ]);
345
+ const schemaMaps = /* @__PURE__ */ new Set([
346
+ "properties",
347
+ "$defs",
348
+ "patternProperties",
349
+ "dependentSchemas"
350
+ ]);
351
+ const schemaValues = /* @__PURE__ */ new Set([
352
+ "additionalProperties",
353
+ "items",
354
+ "contains",
355
+ "not",
356
+ "if",
357
+ "then",
358
+ "else",
359
+ "propertyNames"
360
+ ]);
361
+ const schemaArrays = /* @__PURE__ */ new Set([
362
+ "allOf",
363
+ "anyOf",
364
+ "oneOf",
365
+ "prefixItems"
366
+ ]);
367
+ /** Check every schema position before deriving identity; unknown keywords never disappear. */
368
+ const canonicalSchema = (schema, path = "#") => {
369
+ if (typeof schema === "boolean") return schema;
370
+ if (!isObject(schema)) throw new TypeError(`Invalid schema at ${path}`);
371
+ const shape = meta.validate(schema);
372
+ if (!shape.valid) throw new TypeError(`Invalid JSON Schema at ${path}: ${JSON.stringify(shape.errors)}`);
373
+ const result = {};
374
+ for (const [key, value] of Object.entries(schema).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) {
375
+ if (annotations.has(key)) continue;
376
+ if (schemaMaps.has(key)) {
377
+ if (!isObject(value)) throw new TypeError(`Invalid ${path}/${key}`);
378
+ result[key] = Object.fromEntries(Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([name, child]) => [name, canonicalSchema(child, `${path}/${key}/${name}`)]));
379
+ } else if (schemaValues.has(key)) result[key] = canonicalSchema(value, `${path}/${key}`);
380
+ else if (schemaArrays.has(key)) {
381
+ if (!Array.isArray(value)) throw new TypeError(`Invalid ${path}/${key}`);
382
+ result[key] = value.map((child, index) => canonicalSchema(child, `${path}/${key}/${index}`));
383
+ } else if (scalarKeywords.has(key)) {
384
+ if (key === "$ref" && (typeof value !== "string" || !(value === "#" || value.startsWith("#/")))) throw new TypeError(`Only local JSON Pointer references are supported at ${path}/$ref`);
385
+ if (key === "$schema" && value !== "https://json-schema.org/draft/2020-12/schema") throw new TypeError(`Expected JSON Schema 2020-12 at ${path}`);
386
+ result[key] = canonicalJson(value);
387
+ } else throw new TypeError(`Unsupported input schema keyword ${path}/${key}`);
388
+ }
389
+ return result;
390
+ };
391
+ /** Direct portable JSON Schema authoring; the caller declares its JSON input type. */
392
+ const jsonSchema = (schema) => ({ "~standard": {
393
+ version: 1,
394
+ vendor: "samva-json-schema",
395
+ jsonSchema: {
396
+ input: () => schema,
397
+ output: () => schema
398
+ }
399
+ } });
400
+ /** Pinned Effect/Zod converters omit arbitrary refinements, so inspect those vendors' check metadata. */
401
+ const rejectNonportableChecks = (source) => {
402
+ const vendor = source["~standard"].vendor;
403
+ if (vendor !== "effect" && vendor !== "zod") return;
404
+ const seen = /* @__PURE__ */ new WeakSet();
405
+ const visit = (value) => {
406
+ if (Array.isArray(value)) {
407
+ for (const child of value) visit(child);
408
+ return;
409
+ }
410
+ if (!isObject(value) || seen.has(value)) return;
411
+ seen.add(value);
412
+ if (vendor === "zod" && isObject(value._zod)) {
413
+ visit(value._zod.def);
414
+ return;
415
+ }
416
+ if (vendor === "effect" && value.encoding !== void 0) throw new TypeError("Nonportable Effect transform; use a JSON input schema without decoding transforms");
417
+ if (vendor === "effect" && value._tag === "Suspend") throw new TypeError("Unsupported suspended Effect converter; use local JSON Schema references");
418
+ if (vendor === "zod" && value.type === "lazy") throw new TypeError("Unsupported lazy Zod converter; author recursive input with local JSON Schema references");
419
+ if (vendor === "zod" && (value.check === "custom" || value.check === "overwrite" || [
420
+ "transform",
421
+ "default",
422
+ "prefault",
423
+ "catch"
424
+ ].includes(String(value.type)))) throw new TypeError("Nonportable Zod refinement/transform; express constraints in JSON Schema");
425
+ if (vendor === "effect" && value._tag === "Filter" && (!isObject(value.annotations) || typeof value.annotations.toJsonSchema !== "function")) throw new TypeError("Nonportable Effect refinement; provide a JSON Schema constraint");
426
+ for (const [key, child] of Object.entries(value)) if (key !== "~standard" && key !== "annotations") visit(child);
427
+ };
428
+ if (vendor === "effect" && hasProperty(source, "ast")) visit(source.ast);
429
+ else visit(source);
430
+ };
431
+ /** Convert caller input, never validator output. Both conversion directions must be portable. */
432
+ const inputSchema = (source) => {
433
+ rejectNonportableChecks(source);
434
+ const converter = source["~standard"].jsonSchema;
435
+ const schema = structuredClone(converter.input({ target: "draft-2020-12" }));
436
+ const canonical = canonicalSchema(schema);
437
+ const output = canonicalSchema(converter.output({ target: "draft-2020-12" }));
438
+ if (JSON.stringify(canonical) !== JSON.stringify(output)) throw new TypeError("Template schemas must preserve JSON input; input/output conversion differs");
439
+ const validator = new Validator(schema, "2020-12", false);
440
+ const validate = (value) => {
441
+ const result = validator.validate(value);
442
+ validate.errors = result.errors;
443
+ return result.valid;
444
+ };
445
+ validate.errors = [];
446
+ return {
447
+ schema,
448
+ validationIdentity: JSON.stringify(canonical),
449
+ validate
450
+ };
451
+ };
452
+ //#endregion
453
+ export { inputSchema as n, jsonSchema as r, INPUT_SCHEMA_DIALECT as t };
454
+
455
+ //# sourceMappingURL=input-schema-zjkgrXn2.js.map
@@ -1,2 +1,2 @@
1
- import { a as jsonSchema, i as inputSchema, n as InputIssue, r as InputSchema, t as INPUT_SCHEMA_DIALECT } from "./input-schema-BIfzI63B.js";
1
+ import { a as jsonSchema, i as inputSchema, n as InputIssue, r as InputSchema, t as INPUT_SCHEMA_DIALECT } from "./input-schema-7dPFVvNE.js";
2
2
  export { INPUT_SCHEMA_DIALECT, InputIssue, InputSchema, inputSchema, jsonSchema };
@@ -1,170 +1,2 @@
1
- import { Validator } from "@cfworker/json-schema";
2
- import applicator from "ajv/dist/refs/json-schema-2020-12/meta/applicator.json" with { type: "json" };
3
- import content from "ajv/dist/refs/json-schema-2020-12/meta/content.json" with { type: "json" };
4
- import core from "ajv/dist/refs/json-schema-2020-12/meta/core.json" with { type: "json" };
5
- import format_annotation from "ajv/dist/refs/json-schema-2020-12/meta/format-annotation.json" with { type: "json" };
6
- import meta_data from "ajv/dist/refs/json-schema-2020-12/meta/meta-data.json" with { type: "json" };
7
- import unevaluated from "ajv/dist/refs/json-schema-2020-12/meta/unevaluated.json" with { type: "json" };
8
- import validation from "ajv/dist/refs/json-schema-2020-12/meta/validation.json" with { type: "json" };
9
- import metaSchema from "ajv/dist/refs/json-schema-2020-12/schema.json" with { type: "json" };
10
- import { Predicate } from "effect";
11
- //#region src/input-schema.ts
12
- const meta = new Validator(metaSchema, "2020-12", false);
13
- for (const part of [
14
- applicator,
15
- content,
16
- core,
17
- format_annotation,
18
- meta_data,
19
- unevaluated,
20
- validation
21
- ]) meta.addSchema(part);
22
- /** JSON Schema dialect accepted by template publications. */
23
- const INPUT_SCHEMA_DIALECT = "https://json-schema.org/draft/2020-12/schema";
24
- const canonicalJson = (value) => {
25
- if (Array.isArray(value)) return value.map(canonicalJson);
26
- if (Predicate.isObject(value)) return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, item]) => [key, canonicalJson(item)]));
27
- return value;
28
- };
29
- const annotations = /* @__PURE__ */ new Set([
30
- "title",
31
- "description",
32
- "default",
33
- "examples",
34
- "deprecated",
35
- "readOnly",
36
- "writeOnly",
37
- "$comment"
38
- ]);
39
- const scalarKeywords = /* @__PURE__ */ new Set([
40
- "$schema",
41
- "$ref",
42
- "type",
43
- "enum",
44
- "const",
45
- "required",
46
- "minProperties",
47
- "maxProperties",
48
- "minItems",
49
- "maxItems",
50
- "uniqueItems",
51
- "minLength",
52
- "maxLength",
53
- "pattern",
54
- "minimum",
55
- "maximum",
56
- "exclusiveMinimum",
57
- "exclusiveMaximum",
58
- "multipleOf"
59
- ]);
60
- const schemaMaps = /* @__PURE__ */ new Set([
61
- "properties",
62
- "$defs",
63
- "patternProperties",
64
- "dependentSchemas"
65
- ]);
66
- const schemaValues = /* @__PURE__ */ new Set([
67
- "additionalProperties",
68
- "items",
69
- "contains",
70
- "not",
71
- "if",
72
- "then",
73
- "else",
74
- "propertyNames"
75
- ]);
76
- const schemaArrays = /* @__PURE__ */ new Set([
77
- "allOf",
78
- "anyOf",
79
- "oneOf",
80
- "prefixItems"
81
- ]);
82
- /** Check every schema position before deriving identity; unknown keywords never disappear. */
83
- const canonicalSchema = (schema, path = "#") => {
84
- if (typeof schema === "boolean") return schema;
85
- if (!Predicate.isObject(schema)) throw new TypeError(`Invalid schema at ${path}`);
86
- const shape = meta.validate(schema);
87
- if (!shape.valid) throw new TypeError(`Invalid JSON Schema at ${path}: ${JSON.stringify(shape.errors)}`);
88
- const result = {};
89
- for (const [key, value] of Object.entries(schema).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) {
90
- if (annotations.has(key)) continue;
91
- if (schemaMaps.has(key)) {
92
- if (!Predicate.isObject(value)) throw new TypeError(`Invalid ${path}/${key}`);
93
- result[key] = Object.fromEntries(Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([name, child]) => [name, canonicalSchema(child, `${path}/${key}/${name}`)]));
94
- } else if (schemaValues.has(key)) result[key] = canonicalSchema(value, `${path}/${key}`);
95
- else if (schemaArrays.has(key)) {
96
- if (!Array.isArray(value)) throw new TypeError(`Invalid ${path}/${key}`);
97
- result[key] = value.map((child, index) => canonicalSchema(child, `${path}/${key}/${index}`));
98
- } else if (scalarKeywords.has(key)) {
99
- if (key === "$ref" && (typeof value !== "string" || !(value === "#" || value.startsWith("#/")))) throw new TypeError(`Only local JSON Pointer references are supported at ${path}/$ref`);
100
- if (key === "$schema" && value !== "https://json-schema.org/draft/2020-12/schema") throw new TypeError(`Expected JSON Schema 2020-12 at ${path}`);
101
- result[key] = canonicalJson(value);
102
- } else throw new TypeError(`Unsupported input schema keyword ${path}/${key}`);
103
- }
104
- return result;
105
- };
106
- /** Direct portable JSON Schema authoring; the caller declares its JSON input type. */
107
- const jsonSchema = (schema) => ({ "~standard": {
108
- version: 1,
109
- vendor: "samva-json-schema",
110
- jsonSchema: {
111
- input: () => schema,
112
- output: () => schema
113
- }
114
- } });
115
- /** Pinned Effect/Zod converters omit arbitrary refinements, so inspect those vendors' check metadata. */
116
- const rejectNonportableChecks = (source) => {
117
- const vendor = source["~standard"].vendor;
118
- if (vendor !== "effect" && vendor !== "zod") return;
119
- const seen = /* @__PURE__ */ new WeakSet();
120
- const visit = (value) => {
121
- if (Array.isArray(value)) {
122
- for (const child of value) visit(child);
123
- return;
124
- }
125
- if (!Predicate.isObject(value) || seen.has(value)) return;
126
- seen.add(value);
127
- if (vendor === "zod" && Predicate.isObject(value._zod)) {
128
- visit(value._zod.def);
129
- return;
130
- }
131
- if (vendor === "effect" && value.encoding !== void 0) throw new TypeError("Nonportable Effect transform; use a JSON input schema without decoding transforms");
132
- if (vendor === "effect" && value._tag === "Suspend") throw new TypeError("Unsupported suspended Effect converter; use local JSON Schema references");
133
- if (vendor === "zod" && value.type === "lazy") throw new TypeError("Unsupported lazy Zod converter; author recursive input with local JSON Schema references");
134
- if (vendor === "zod" && (value.check === "custom" || value.check === "overwrite" || [
135
- "transform",
136
- "default",
137
- "prefault",
138
- "catch"
139
- ].includes(String(value.type)))) throw new TypeError("Nonportable Zod refinement/transform; express constraints in JSON Schema");
140
- if (vendor === "effect" && value._tag === "Filter" && (!Predicate.isObject(value.annotations) || typeof value.annotations.toJsonSchema !== "function")) throw new TypeError("Nonportable Effect refinement; provide a JSON Schema constraint");
141
- for (const [key, child] of Object.entries(value)) if (key !== "~standard" && key !== "annotations") visit(child);
142
- };
143
- if (vendor === "effect" && Predicate.hasProperty(source, "ast")) visit(source.ast);
144
- else visit(source);
145
- };
146
- /** Convert caller input, never validator output. Both conversion directions must be portable. */
147
- const inputSchema = (source) => {
148
- rejectNonportableChecks(source);
149
- const converter = source["~standard"].jsonSchema;
150
- const schema = structuredClone(converter.input({ target: "draft-2020-12" }));
151
- const canonical = canonicalSchema(schema);
152
- const output = canonicalSchema(converter.output({ target: "draft-2020-12" }));
153
- if (JSON.stringify(canonical) !== JSON.stringify(output)) throw new TypeError("Template schemas must preserve JSON input; input/output conversion differs");
154
- const validator = new Validator(schema, "2020-12", false);
155
- const validate = (value) => {
156
- const result = validator.validate(value);
157
- validate.errors = result.errors;
158
- return result.valid;
159
- };
160
- validate.errors = [];
161
- return {
162
- schema,
163
- validationIdentity: JSON.stringify(canonical),
164
- validate
165
- };
166
- };
167
- //#endregion
1
+ import { n as inputSchema, r as jsonSchema, t as INPUT_SCHEMA_DIALECT } from "./input-schema-zjkgrXn2.js";
168
2
  export { INPUT_SCHEMA_DIALECT, inputSchema, jsonSchema };
169
-
170
- //# sourceMappingURL=input-schema.js.map
@@ -1,16 +1,13 @@
1
- import { Schema } from "effect";
2
1
  //#region src/interpolate.d.ts
3
- declare const DocumentVariableTypeSchema: Schema.Literals<readonly ["string", "number", "boolean", "date", "array", "object"]>;
4
- type DocumentVariableType = typeof DocumentVariableTypeSchema.Type;
2
+ type DocumentVariableType = "string" | "number" | "boolean" | "date" | "array" | "object";
5
3
  /** One entry of a template's declared variable schema. */
6
- declare const DocumentVariableSchema: Schema.Struct<{
7
- readonly name: Schema.String;
8
- readonly type: Schema.Literals<readonly ["string", "number", "boolean", "date", "array", "object"]>;
9
- readonly required: Schema.Boolean;
10
- readonly default: Schema.optional<Schema.Unknown>;
11
- readonly description: Schema.optional<Schema.String>;
12
- }>;
13
- interface DocumentVariable extends Schema.Schema.Type<typeof DocumentVariableSchema> {}
4
+ interface DocumentVariable {
5
+ readonly name: string;
6
+ readonly type: DocumentVariableType;
7
+ readonly required: boolean;
8
+ readonly default?: unknown;
9
+ readonly description?: string | undefined;
10
+ }
14
11
  declare const variableReferencePattern: RegExp;
15
12
  declare const getVariableValue: (variables: Record<string, unknown>, variableSchema: ReadonlyArray<DocumentVariable>, name: string) => unknown;
16
13
  declare const stringifyVariable: (value: unknown) => string;
@@ -23,5 +20,5 @@ declare const interpolate: (text: string, variables: Record<string, unknown>, va
23
20
  declare const variableReferences: (text: string) => Set<string>;
24
21
  declare const addVariableReferences: (target: Set<string>, text: string) => void;
25
22
  //#endregion
26
- export { DocumentVariable, DocumentVariableSchema, DocumentVariableType, DocumentVariableTypeSchema, InterpolationResult, addVariableReferences, getVariableValue, interpolate, stringifyVariable, variableReferencePattern, variableReferences };
23
+ export { DocumentVariable, DocumentVariableType, InterpolationResult, addVariableReferences, getVariableValue, interpolate, stringifyVariable, variableReferencePattern, variableReferences };
27
24
  //# sourceMappingURL=interpolate.d.ts.map