attaform 0.28.0 → 0.30.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/dist/abstract.d.mts +5 -5
- package/dist/abstract.mjs +4 -4
- package/dist/dev/abstract.mjs +4 -4
- package/dist/dev/chunks/dev-key-collision-warnings.mjs +47 -8
- package/dist/dev/chunks/devtools.mjs +1 -1
- package/dist/dev/directive.mjs +1 -1
- package/dist/dev/history.mjs +1 -2
- package/dist/dev/index.mjs +5 -5
- package/dist/dev/runtime/plugins/attaform.mjs +3 -3
- package/dist/dev/shared/{attaform-dev.oYrkP9dj.mjs → attaform-dev.BK6Ge2qR.mjs} +80 -341
- package/dist/dev/shared/{attaform-dev.Dr2YzS5B.mjs → attaform-dev.BQc5QV3Y.mjs} +11 -19
- package/dist/dev/shared/{attaform-dev.BR8u0YOZ.mjs → attaform-dev.BcNtyOmf.mjs} +4 -4
- package/dist/{shared/attaform.h0i6LijT.mjs → dev/shared/attaform-dev.BcYT6tFh.mjs} +152 -20
- package/dist/dev/shared/{attaform-dev.6qxD-Yqo.mjs → attaform-dev.BisFstxh.mjs} +227 -88
- package/dist/dev/shared/{attaform-dev.WmuhD_CZ.mjs → attaform-dev.CQ2rJiAX.mjs} +833 -656
- package/dist/dev/shared/{attaform-dev.P7cseiEG.mjs → attaform-dev.D6CLvaQT.mjs} +20 -11
- package/dist/dev/shared/{attaform-dev.D2I8e_Mm.mjs → attaform-dev.DTrHonpc.mjs} +225 -238
- package/dist/dev/shared/{attaform-dev.BXE2cr0L.mjs → attaform-dev.DUZckyV8.mjs} +1 -3
- package/dist/dev/zod-v3.mjs +6 -6
- package/dist/dev/zod-v4.mjs +6 -6
- package/dist/dev/zod.mjs +5 -5
- package/dist/directive.d.mts +2 -2
- package/dist/directive.mjs +1 -1
- package/dist/history.d.mts +1 -1
- package/dist/history.mjs +1 -2
- package/dist/index.d.mts +9 -7
- package/dist/index.mjs +5 -5
- package/dist/nuxt.d.mts +11 -20
- package/dist/nuxt.mjs +0 -1
- package/dist/runtime/plugins/attaform.mjs +3 -3
- package/dist/shared/{attaform.uLbun31C.mjs → attaform.B3resMQ1.mjs} +19 -11
- package/dist/shared/{attaform.Cs2Rbdlo.mjs → attaform.BK0cgu2K.mjs} +123 -139
- package/dist/{dev/shared/attaform-dev.By4PRjt0.mjs → shared/attaform.BRDDQeHV.mjs} +136 -26
- package/dist/shared/{attaform.NLmerepI.mjs → attaform.BXneBxEj.mjs} +71 -334
- package/dist/shared/{attaform.D6DCnnQu.mjs → attaform.ByWP6kSx.mjs} +4 -4
- package/dist/shared/{attaform.CJP3RkGa.mjs → attaform.CJ8DpRGj.mjs} +223 -238
- package/dist/shared/{attaform.C09fpdLS.mjs → attaform.CUfrMK7t.mjs} +227 -88
- package/dist/shared/{attaform.wfY8XFvm.mjs → attaform.CdZIEf7_.mjs} +11 -19
- package/dist/shared/{attaform.JfSWdEcb.d.mts → attaform.Clz0ArIi.d.mts} +1 -1
- package/dist/shared/{attaform.B8k8JrmK.mjs → attaform.DNJOWjQw.mjs} +826 -612
- package/dist/shared/{attaform.B4VkS43-.d.mts → attaform.Rc9u4Vfw.d.mts} +1 -1
- package/dist/shared/{attaform.D5V4tZWq.d.mts → attaform.UGyOK83T.d.mts} +200 -218
- package/dist/shared/{attaform.Dq4vWxuG.mjs → attaform.WiGdIqgx.mjs} +1 -3
- package/dist/shared/{attaform.Cgu-hdSb.d.mts → attaform.bKLzMU0o.d.mts} +321 -523
- package/dist/transforms.d.mts +0 -22
- package/dist/transforms.mjs +1 -1
- package/dist/vite.d.mts +13 -4
- package/dist/vite.mjs +8 -2
- package/dist/zod-v3.d.mts +6 -4
- package/dist/zod-v3.mjs +6 -6
- package/dist/zod-v4.d.mts +18 -31
- package/dist/zod-v4.mjs +6 -6
- package/dist/zod.d.mts +4 -4
- package/dist/zod.mjs +5 -5
- package/package.json +19 -15
- package/skills/attaform/SKILL.md +6 -3
- package/skills/attaform/references/custom-components.md +8 -3
- package/skills/attaform/references/errors.md +8 -3
- package/skills/attaform/references/saving.md +77 -0
- package/skills/attaform/references/wizards.md +10 -8
- package/dist/chunks/fingerprint.mjs +0 -183
- package/dist/chunks/fingerprint2.mjs +0 -159
- package/dist/dev/chunks/fingerprint.mjs +0 -183
- package/dist/dev/chunks/fingerprint2.mjs +0 -159
- package/dist/dev/shared/attaform-dev.BJGA_UOS.mjs +0 -36
- package/dist/shared/attaform.BJGA_UOS.mjs +0 -36
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { c as canonicalStringify } from '../shared/attaform-dev.BJGA_UOS.mjs';
|
|
2
|
-
import { k as kindOf, g as getIntersectionLeft, b as getIntersectionRight, c as unwrapLazy, d as unwrapInner, e as unwrapPipe, f as getDiscriminator, h as getDiscriminatedOptions, i as getUnionOptions, j as getRecordKeyType, l as getRecordValueType, m as getTupleItems, n as getSetValueType, o as getArrayElement, p as getObjectShape, q as getEnumValues, r as getLiteralValues, s as getChecks, t as getCatchDefault, v as getDefaultValue } from '../shared/attaform-dev.oYrkP9dj.mjs';
|
|
3
|
-
|
|
4
|
-
const cyclicSentinel = "<cyclic>";
|
|
5
|
-
function fingerprintZodSchema(schema) {
|
|
6
|
-
const cache = /* @__PURE__ */ new WeakMap();
|
|
7
|
-
const inProgress = /* @__PURE__ */ new WeakSet();
|
|
8
|
-
return visit(schema, cache, inProgress);
|
|
9
|
-
}
|
|
10
|
-
function visit(schema, cache, inProgress) {
|
|
11
|
-
const cached = cache.get(schema);
|
|
12
|
-
if (cached !== void 0) return cached;
|
|
13
|
-
if (inProgress.has(schema)) return cyclicSentinel;
|
|
14
|
-
inProgress.add(schema);
|
|
15
|
-
try {
|
|
16
|
-
const computed = computeFingerprint(schema, cache, inProgress);
|
|
17
|
-
cache.set(schema, computed);
|
|
18
|
-
return computed;
|
|
19
|
-
} finally {
|
|
20
|
-
inProgress.delete(schema);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function computeFingerprint(schema, cache, inProgress) {
|
|
24
|
-
const kind = kindOf(schema);
|
|
25
|
-
const recurse = (child) => visit(child, cache, inProgress);
|
|
26
|
-
switch (kind) {
|
|
27
|
-
// Kind-only leaves: no further structure to descend into.
|
|
28
|
-
case "boolean":
|
|
29
|
-
case "null":
|
|
30
|
-
case "undefined":
|
|
31
|
-
case "any":
|
|
32
|
-
case "unknown":
|
|
33
|
-
case "nan":
|
|
34
|
-
case "void":
|
|
35
|
-
case "never":
|
|
36
|
-
return kind;
|
|
37
|
-
// Leaves with checks (min/max/email/regex/...). Checks are
|
|
38
|
-
// canonicalised and sorted so `.min(3).max(10)` and `.max(10).min(3)`
|
|
39
|
-
// produce identical fingerprints.
|
|
40
|
-
case "string":
|
|
41
|
-
case "number":
|
|
42
|
-
case "bigint":
|
|
43
|
-
case "date":
|
|
44
|
-
return `${kind}${formatChecks(schema)}`;
|
|
45
|
-
case "literal": {
|
|
46
|
-
const values = [...getLiteralValues(schema)].sort((a, b) => {
|
|
47
|
-
const as = canonicalStringify(a);
|
|
48
|
-
const bs = canonicalStringify(b);
|
|
49
|
-
return as < bs ? -1 : as > bs ? 1 : 0;
|
|
50
|
-
});
|
|
51
|
-
return `literal:${canonicalStringify(values)}`;
|
|
52
|
-
}
|
|
53
|
-
case "enum":
|
|
54
|
-
return `enum:${canonicalStringify([...getEnumValues(schema)].sort((a, b) => compare(a, b)))}`;
|
|
55
|
-
case "object": {
|
|
56
|
-
const shape = getObjectShape(schema);
|
|
57
|
-
const sortedEntries = Object.entries(shape).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${JSON.stringify(k)}:${recurse(v)}`);
|
|
58
|
-
return `object{${sortedEntries.join(",")}}${formatChecks(schema)}`;
|
|
59
|
-
}
|
|
60
|
-
case "array":
|
|
61
|
-
return `array[${recurse(getArrayElement(schema))}]${formatChecks(schema)}`;
|
|
62
|
-
case "set":
|
|
63
|
-
return `set<${recurse(getSetValueType(schema))}>${formatChecks(schema)}`;
|
|
64
|
-
case "tuple":
|
|
65
|
-
return `tuple[${getTupleItems(schema).map(recurse).join(",")}]`;
|
|
66
|
-
case "record":
|
|
67
|
-
return `record<${recurse(getRecordKeyType(schema))},${recurse(getRecordValueType(schema))}>`;
|
|
68
|
-
case "union": {
|
|
69
|
-
const options = getUnionOptions(schema).map(recurse).sort();
|
|
70
|
-
return `union(${options.join("|")})`;
|
|
71
|
-
}
|
|
72
|
-
case "discriminated-union": {
|
|
73
|
-
const disc = getDiscriminator(schema) ?? "?";
|
|
74
|
-
const options = getDiscriminatedOptions(schema).map(recurse).sort();
|
|
75
|
-
return `dunion[${JSON.stringify(disc)}](${options.join("|")})`;
|
|
76
|
-
}
|
|
77
|
-
case "optional": {
|
|
78
|
-
const inner = unwrapInner(schema);
|
|
79
|
-
return inner === void 0 ? "optional(?)" : `optional(${recurse(inner)})`;
|
|
80
|
-
}
|
|
81
|
-
case "nullable": {
|
|
82
|
-
const inner = unwrapInner(schema);
|
|
83
|
-
return inner === void 0 ? "nullable(?)" : `nullable(${recurse(inner)})`;
|
|
84
|
-
}
|
|
85
|
-
case "default": {
|
|
86
|
-
const inner = unwrapInner(schema);
|
|
87
|
-
return `default[${stableValueRepr(getDefaultValue, schema)}](${inner === void 0 ? "?" : recurse(inner)})`;
|
|
88
|
-
}
|
|
89
|
-
case "readonly": {
|
|
90
|
-
const inner = unwrapInner(schema);
|
|
91
|
-
return inner === void 0 ? "readonly(?)" : `readonly(${recurse(inner)})`;
|
|
92
|
-
}
|
|
93
|
-
case "pipe": {
|
|
94
|
-
const inner = unwrapPipe(schema);
|
|
95
|
-
return inner === void 0 ? "pipe(?)" : `pipe(${recurse(inner)})`;
|
|
96
|
-
}
|
|
97
|
-
case "catch": {
|
|
98
|
-
const inner = unwrapInner(schema);
|
|
99
|
-
return `catch[${stableValueRepr(getCatchDefault, schema)}](${inner === void 0 ? "?" : recurse(inner)})`;
|
|
100
|
-
}
|
|
101
|
-
case "lazy": {
|
|
102
|
-
const inner = unwrapLazy(schema);
|
|
103
|
-
return inner === void 0 ? "lazy(?)" : `lazy(${recurse(inner)})`;
|
|
104
|
-
}
|
|
105
|
-
case "intersection": {
|
|
106
|
-
const left = getIntersectionLeft(schema);
|
|
107
|
-
const right = getIntersectionRight(schema);
|
|
108
|
-
const leftFp = left === void 0 ? "?" : recurse(left);
|
|
109
|
-
const rightFp = right === void 0 ? "?" : recurse(right);
|
|
110
|
-
const parts = [leftFp, rightFp].sort();
|
|
111
|
-
return `intersection(${parts.join("&")})`;
|
|
112
|
-
}
|
|
113
|
-
// Structural shape isn't observable for these. Bucket them into
|
|
114
|
-
// kind-only fingerprints — a schema-mismatch warning can't do
|
|
115
|
-
// better than "both are `custom`" here, but that still catches
|
|
116
|
-
// `object` vs `custom` mismatches. `map` / `symbol` / `function`
|
|
117
|
-
// are rejected at adapter construction; kept here for exhaustive
|
|
118
|
-
// switch safety when `fingerprintSchema` is called from tooling.
|
|
119
|
-
case "promise":
|
|
120
|
-
case "custom":
|
|
121
|
-
case "template-literal":
|
|
122
|
-
case "transform":
|
|
123
|
-
case "file":
|
|
124
|
-
case "map":
|
|
125
|
-
case "symbol":
|
|
126
|
-
case "function":
|
|
127
|
-
return `${kind}:*`;
|
|
128
|
-
default: {
|
|
129
|
-
const _ = kind;
|
|
130
|
-
return `unknown:${String(_)}`;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
function stableValueRepr(get, schema) {
|
|
135
|
-
const first = get(schema);
|
|
136
|
-
const second = get(schema);
|
|
137
|
-
if (!Object.is(first, second) || typeof first === "function") return "fn:*";
|
|
138
|
-
return canonicalStringify(first);
|
|
139
|
-
}
|
|
140
|
-
function formatChecks(schema) {
|
|
141
|
-
const checks = getChecks(schema);
|
|
142
|
-
if (checks.length === 0) return "";
|
|
143
|
-
const parts = checks.map((c) => serializeCheck(c)).sort();
|
|
144
|
-
return `[${parts.join(";")}]`;
|
|
145
|
-
}
|
|
146
|
-
function serializeCheck(check) {
|
|
147
|
-
if (check !== null && typeof check === "object") {
|
|
148
|
-
const def = check._zod?.def;
|
|
149
|
-
if (def !== void 0) return canonicalStringify(def);
|
|
150
|
-
}
|
|
151
|
-
return canonicalStringify(check);
|
|
152
|
-
}
|
|
153
|
-
function compare(a, b) {
|
|
154
|
-
const as = String(a);
|
|
155
|
-
const bs = String(b);
|
|
156
|
-
return as < bs ? -1 : as > bs ? 1 : 0;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export { fingerprintZodSchema };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
function canonicalStringify(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
2
|
-
if (value === null) return "null";
|
|
3
|
-
if (value === void 0) return "undefined";
|
|
4
|
-
const t = typeof value;
|
|
5
|
-
if (t === "string") return JSON.stringify(value);
|
|
6
|
-
if (t === "number" || t === "boolean") return String(value);
|
|
7
|
-
if (t === "bigint") return `${String(value)}n`;
|
|
8
|
-
if (t === "function") return "fn:*";
|
|
9
|
-
if (t === "symbol") return "symbol:*";
|
|
10
|
-
if (Array.isArray(value)) {
|
|
11
|
-
if (seen.has(value)) return "<cyclic>";
|
|
12
|
-
seen.add(value);
|
|
13
|
-
try {
|
|
14
|
-
const parts = value.map((v) => canonicalStringify(v, seen));
|
|
15
|
-
return `[${parts.join(",")}]`;
|
|
16
|
-
} finally {
|
|
17
|
-
seen.delete(value);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
if (t === "object") {
|
|
21
|
-
const obj = value;
|
|
22
|
-
if (seen.has(obj)) return "<cyclic>";
|
|
23
|
-
seen.add(obj);
|
|
24
|
-
try {
|
|
25
|
-
if (value instanceof Date) return `date:${value.getTime()}`;
|
|
26
|
-
if (value instanceof RegExp) return `regex:${String(value)}`;
|
|
27
|
-
const entries = Object.entries(obj).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${JSON.stringify(k)}:${canonicalStringify(v, seen)}`);
|
|
28
|
-
return `{${entries.join(",")}}`;
|
|
29
|
-
} finally {
|
|
30
|
-
seen.delete(obj);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return "unknown";
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { canonicalStringify as c };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
function canonicalStringify(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
2
|
-
if (value === null) return "null";
|
|
3
|
-
if (value === void 0) return "undefined";
|
|
4
|
-
const t = typeof value;
|
|
5
|
-
if (t === "string") return JSON.stringify(value);
|
|
6
|
-
if (t === "number" || t === "boolean") return String(value);
|
|
7
|
-
if (t === "bigint") return `${String(value)}n`;
|
|
8
|
-
if (t === "function") return "fn:*";
|
|
9
|
-
if (t === "symbol") return "symbol:*";
|
|
10
|
-
if (Array.isArray(value)) {
|
|
11
|
-
if (seen.has(value)) return "<cyclic>";
|
|
12
|
-
seen.add(value);
|
|
13
|
-
try {
|
|
14
|
-
const parts = value.map((v) => canonicalStringify(v, seen));
|
|
15
|
-
return `[${parts.join(",")}]`;
|
|
16
|
-
} finally {
|
|
17
|
-
seen.delete(value);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
if (t === "object") {
|
|
21
|
-
const obj = value;
|
|
22
|
-
if (seen.has(obj)) return "<cyclic>";
|
|
23
|
-
seen.add(obj);
|
|
24
|
-
try {
|
|
25
|
-
if (value instanceof Date) return `date:${value.getTime()}`;
|
|
26
|
-
if (value instanceof RegExp) return `regex:${String(value)}`;
|
|
27
|
-
const entries = Object.entries(obj).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${JSON.stringify(k)}:${canonicalStringify(v, seen)}`);
|
|
28
|
-
return `{${entries.join(",")}}`;
|
|
29
|
-
} finally {
|
|
30
|
-
seen.delete(obj);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return "unknown";
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { canonicalStringify as c };
|