@samva/markup 0.3.0 → 0.5.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.
- package/AGENTS.md +17 -0
- package/dist/{ast-63I-VLQx.d.ts → ast-BLybiDxp.d.ts} +34 -60
- package/dist/ast.d.ts +2 -2
- package/dist/ast.js +4 -52
- package/dist/catalog-Db0UcCTg.d.ts +356 -0
- package/dist/{checks-DXuERO4B.js → checks-CmmITP6j.js} +14 -14
- package/dist/checks.d.ts +1 -1
- package/dist/checks.js +1 -1
- package/dist/classes.d.ts +1 -1
- package/dist/compile-sms.d.ts +3 -3
- package/dist/compile-whatsapp.d.ts +5 -5
- package/dist/compile-whatsapp.js +3 -3
- package/dist/compile.d.ts +5 -5
- package/dist/compile.js +5 -5
- package/dist/compiler.d.ts +4 -4
- package/dist/compiler.js +6 -6
- package/dist/components.d.ts +4 -4
- package/dist/conditionals.js +3 -3
- package/dist/corpus-CM7rKX41.d.ts +106 -0
- package/dist/{css-ar2lU3NC.d.ts → css-DoNc7CiC.d.ts} +4 -5
- package/dist/diagnostics-CqepLcpI.d.ts +47 -0
- package/dist/diagnostics-eFM9A_TU.d.ts +46 -0
- package/dist/diagnostics.d.ts +2 -2
- package/dist/diagnostics.js +15 -29
- package/dist/{elements-DtwKlFVH.d.ts → elements-ChJULZlh.d.ts} +40 -161
- package/dist/email/components.d.ts +1 -1
- package/dist/email/diagnostics.d.ts +1 -1
- package/dist/email/diagnostics.js +8 -43
- package/dist/email/elements.d.ts +1 -1
- package/dist/email/html.d.ts +2 -2
- package/dist/email/html.js +9 -9
- package/dist/email/jsx-dev-runtime.d.ts +3 -21
- package/dist/email/jsx-runtime.d.ts +1 -1
- package/dist/email/jsx-runtime.js +29 -3
- package/dist/email/render.d.ts +4 -4
- package/dist/email/render.js +1 -1
- package/dist/email/selection.d.ts +20 -31
- package/dist/email/selection.js +1 -53
- package/dist/email/source-edit.d.ts +1 -1
- package/dist/email/source-edit.js +2 -2
- package/dist/email/stylesheets.d.ts +1 -1
- package/dist/email/text.d.ts +1 -1
- package/dist/email/text.js +3 -3
- package/dist/emit.d.ts +2 -2
- package/dist/emit.js +5 -5
- package/dist/guards-eV1qLbf2.js +9 -0
- package/dist/{input-schema-BIfzI63B.d.ts → input-schema-7dPFVvNE.d.ts} +2 -2
- package/dist/input-schema-zjkgrXn2.js +455 -0
- package/dist/input-schema.d.ts +1 -1
- package/dist/input-schema.js +1 -169
- package/dist/interpolate.d.ts +9 -12
- package/dist/interpolate.js +1 -19
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/{jsx-runtime-C5k_Zq0A.d.ts → jsx-runtime-BI4gI19E.d.ts} +3 -3
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +3 -3
- package/dist/model.d.ts +18 -33
- package/dist/model.js +4 -17
- package/dist/ops.d.ts +78 -172
- package/dist/ops.js +51 -117
- package/dist/{parser-CGBS73Gz.d.ts → parser-b_Kp5MT6.d.ts} +5 -5
- package/dist/parser.d.ts +1 -1
- package/dist/parser.js +8 -8
- package/dist/{predicate-G2SeSvoN.d.ts → predicate-Bmvgw7Ao.d.ts} +4 -4
- package/dist/{predicate-CvkzT-a2.js → predicate-DwXzmqIY.js} +11 -11
- package/dist/predicate.d.ts +1 -1
- package/dist/predicate.js +1 -1
- package/dist/presets/category-mapping.d.ts +1 -1
- package/dist/presets/corpus.d.ts +1 -1
- package/dist/presets/corpus.js +87 -140
- package/dist/presets/public-gallery.d.ts +106 -130
- package/dist/presets/public-gallery.js +131 -209
- package/dist/presets/public-handoff.d.ts +4 -4
- package/dist/presets/public-handoff.js +13 -11
- package/dist/presets/public-preview-artifacts.d.ts +5 -5
- package/dist/presets/public-preview-artifacts.js +9 -9
- package/dist/presets/public-preview.d.ts +0 -4
- package/dist/presets/public-preview.js +37 -362
- package/dist/presets/showcase.d.ts +2 -0
- package/dist/presets/showcase.js +627 -0
- package/dist/presets/sources.d.ts +1 -1
- package/dist/presets/sources.js +5767 -2023
- package/dist/presets.d.ts +2 -384
- package/dist/presets.js +299 -765
- package/dist/printer.d.ts +1 -1
- package/dist/{render-ykQhtMs_.js → render-T6IFPnP4.js} +12 -12
- package/dist/render-template.d.ts +7 -7
- package/dist/render-template.js +6 -6
- package/dist/showcase-dvJMn-Lo.d.ts +456 -0
- package/dist/{source-locations-BCJQnIfU.d.ts → source-locations-D6Te6Gy1.d.ts} +4 -26
- package/dist/source-locations.d.ts +2 -2
- package/dist/source-locations.js +3 -26
- package/dist/{template-Dy5yOPyp.d.ts → template-G-QPcfmn.d.ts} +4 -4
- package/dist/template.d.ts +1 -1
- package/dist/template.js +3 -3
- package/dist/theme-css.d.ts +3 -3
- package/dist/theme-css.js +3 -3
- package/dist/tsx-source-instrumentation.d.ts +1 -3
- package/dist/tsx-source-instrumentation.js +6 -6
- package/dist/tsx-tracer.d.ts +7 -11
- package/dist/tsx-tracer.js +164 -164
- package/dist/{variables-if1VrV34.d.ts → variables-BnKs1iqb.d.ts} +2 -2
- package/dist/variables.d.ts +1 -1
- package/dist/variables.js +4 -4
- package/package.json +8 -3
- package/dist/corpus-qrUD5O6r.d.ts +0 -254
- package/dist/diagnostics-Djd9ckLg.d.ts +0 -90
- package/dist/diagnostics-oveE-laV.d.ts +0 -79
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { n as isObject } from "../guards-eV1qLbf2.js";
|
|
1
2
|
import { buildLineMap } from "../diagnostics.js";
|
|
2
|
-
import { Predicate } from "effect";
|
|
3
3
|
import { parse } from "@babel/parser";
|
|
4
4
|
//#region src/email/source-edit.ts
|
|
5
|
-
const node = (value) =>
|
|
5
|
+
const node = (value) => isObject(value) && "type" in value && typeof value.type === "string" && "start" in value && typeof value.start === "number" && "end" in value && typeof value.end === "number";
|
|
6
6
|
const children = (value) => Array.isArray(value) ? value.filter(node) : [];
|
|
7
7
|
const walk = (value, visit, parent = null) => {
|
|
8
8
|
if (Array.isArray(value)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as Stylesheet } from "../css-
|
|
1
|
+
import { i as Stylesheet } from "../css-DoNc7CiC.js";
|
|
2
2
|
//#region src/email/stylesheets.d.ts
|
|
3
3
|
/** Called by a compiler-generated stylesheet module at import time. */
|
|
4
4
|
declare const registerStylesheet: (sheet: Stylesheet) => void;
|
package/dist/email/text.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as EmailNode } from "../elements-
|
|
1
|
+
import { m as EmailNode } from "../elements-ChJULZlh.js";
|
|
2
2
|
//#region src/email/text.d.ts
|
|
3
3
|
/** Derive the plain-text alternative from the semantic tree in reading order. */
|
|
4
4
|
declare const deriveEmailText: (node: EmailNode) => string;
|
package/dist/email/text.js
CHANGED
|
@@ -18,8 +18,8 @@ const block = (inner, separator) => {
|
|
|
18
18
|
return trimmed === "" ? "" : `${separator}${trimmed}${separator}`;
|
|
19
19
|
};
|
|
20
20
|
const collect = (nodes, keep, descend) => nodes.flatMap((child) => {
|
|
21
|
-
if (child.
|
|
22
|
-
if (child.
|
|
21
|
+
if (child.type === "Fragment") return collect(child.children, keep, descend);
|
|
22
|
+
if (child.type !== "Element") return [];
|
|
23
23
|
if (keep(child.tag)) return [child];
|
|
24
24
|
return descend(child.tag) ? collect(child.children, keep, descend) : [];
|
|
25
25
|
});
|
|
@@ -30,7 +30,7 @@ const TABLE_SECTIONS = /* @__PURE__ */ new Set([
|
|
|
30
30
|
]);
|
|
31
31
|
const childText = (node, context) => node.children.map((child) => derive(child, context)).join("");
|
|
32
32
|
const derive = (node, context) => {
|
|
33
|
-
switch (node.
|
|
33
|
+
switch (node.type) {
|
|
34
34
|
case "Text": return context.preformatted ? node.value : node.value.replace(INVISIBLE, "").replace(/[^\S\n]+/g, " ");
|
|
35
35
|
case "Raw": return node.text;
|
|
36
36
|
case "Fragment": return node.children.map((child) => derive(child, context)).join("");
|
package/dist/emit.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as Diagnostic } from "./diagnostics-
|
|
2
|
-
import {
|
|
1
|
+
import { t as Diagnostic } from "./diagnostics-CqepLcpI.js";
|
|
2
|
+
import { s as UnboundTemplateSourceLocations } from "./source-locations-D6Te6Gy1.js";
|
|
3
3
|
import { TemplateVariable } from "./render-template.js";
|
|
4
4
|
//#region src/emit.d.ts
|
|
5
5
|
/**
|
package/dist/emit.js
CHANGED
|
@@ -2,7 +2,7 @@ import { sameTemplateSourceLocations } from "./source-locations.js";
|
|
|
2
2
|
import { isRootTag } from "./ast.js";
|
|
3
3
|
import { createVariablesProxy } from "./variables.js";
|
|
4
4
|
import { renderTemplate } from "./render-template.js";
|
|
5
|
-
import { Result } from "
|
|
5
|
+
import { Result } from "better-result";
|
|
6
6
|
//#region src/emit.ts
|
|
7
7
|
/**
|
|
8
8
|
* emitModule — the module-level emit boundary for the TSX authoring layer
|
|
@@ -115,7 +115,7 @@ const emitModule = (moduleExports) => {
|
|
|
115
115
|
*/
|
|
116
116
|
const emitOne = (name, template) => {
|
|
117
117
|
const first = renderTemplate(template);
|
|
118
|
-
if (Result.
|
|
118
|
+
if (Result.isError(first)) return {
|
|
119
119
|
name,
|
|
120
120
|
ok: false,
|
|
121
121
|
source: void 0,
|
|
@@ -124,11 +124,11 @@ const emitOne = (name, template) => {
|
|
|
124
124
|
kind: "unavailable",
|
|
125
125
|
reason: "render-failed"
|
|
126
126
|
},
|
|
127
|
-
diagnostics: first.
|
|
127
|
+
diagnostics: first.error.diagnostics
|
|
128
128
|
};
|
|
129
|
-
const rendered = first.
|
|
129
|
+
const rendered = first.value;
|
|
130
130
|
const second = renderTemplate(template);
|
|
131
|
-
if (Result.
|
|
131
|
+
if (Result.isOk(second) && second.value.source === rendered.source && sameTemplateSourceLocations(second.value.sourceLocations, rendered.sourceLocations)) return {
|
|
132
132
|
name,
|
|
133
133
|
ok: true,
|
|
134
134
|
source: rendered.source,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/internal/guards.ts
|
|
2
|
+
/** A non-null, non-array object, narrowed for property access. */
|
|
3
|
+
const isObject = (input) => typeof input === "object" && input !== null && !Array.isArray(input);
|
|
4
|
+
/** True when `input` carries `property`, narrowing it for reads. */
|
|
5
|
+
const hasProperty = (input, property) => typeof input === "object" && input !== null || typeof input === "function" ? property in input : false;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { isObject as n, hasProperty as t };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=guards-eV1qLbf2.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OutputUnit } from "@cfworker/json-schema";
|
|
2
|
-
import { StandardJSONSchemaV1 } from "
|
|
2
|
+
import { StandardJSONSchemaV1 } from "@standard-schema/spec";
|
|
3
3
|
//#region src/input-schema.d.ts
|
|
4
4
|
/** JSON Schema dialect accepted by template publications. */
|
|
5
5
|
declare const INPUT_SCHEMA_DIALECT = "https://json-schema.org/draft/2020-12/schema";
|
|
@@ -20,4 +20,4 @@ declare const inputSchema: <S extends StandardJSONSchemaV1>(source: S) => InputS
|
|
|
20
20
|
type InputIssue = OutputUnit;
|
|
21
21
|
//#endregion
|
|
22
22
|
export { jsonSchema as a, inputSchema as i, InputIssue as n, InputSchema as r, INPUT_SCHEMA_DIALECT as t };
|
|
23
|
-
//# sourceMappingURL=input-schema-
|
|
23
|
+
//# sourceMappingURL=input-schema-7dPFVvNE.d.ts.map
|
|
@@ -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
|
package/dist/input-schema.d.ts
CHANGED
|
@@ -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-
|
|
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 };
|