attaform 0.19.0 → 0.20.1
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/README.md +3 -0
- package/dist/chunks/devtools.cjs +1 -1
- package/dist/chunks/devtools.mjs +1 -1
- package/dist/chunks/indexeddb.cjs +1 -1
- package/dist/chunks/indexeddb.mjs +1 -1
- package/dist/chunks/local-storage.cjs +1 -1
- package/dist/chunks/local-storage.mjs +1 -1
- package/dist/chunks/session-storage.cjs +1 -1
- package/dist/chunks/session-storage.mjs +1 -1
- package/dist/index.cjs +3 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -40
- package/dist/index.d.mts +14 -40
- package/dist/index.d.ts +14 -40
- package/dist/index.mjs +5 -5
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +2 -2
- package/dist/runtime/components/DevtoolsValueTree.d.vue.ts +1 -3
- package/dist/runtime/components/DevtoolsValueTree.vue.d.ts +1 -3
- package/dist/runtime/plugins/attaform.cjs +2 -2
- package/dist/runtime/plugins/attaform.mjs +2 -2
- package/dist/shared/attaform.BCBxTyMC.cjs +1882 -0
- package/dist/shared/attaform.BCBxTyMC.cjs.map +1 -0
- package/dist/shared/{attaform.CrpjyXdO.mjs → attaform.BKozEdTr.mjs} +275 -266
- package/dist/shared/attaform.BKozEdTr.mjs.map +1 -0
- package/dist/shared/{attaform.Bubm_slq.cjs → attaform.BM6YD9kZ.cjs} +212 -269
- package/dist/shared/attaform.BM6YD9kZ.cjs.map +1 -0
- package/dist/shared/{attaform.CoxJ8Qm8.cjs → attaform.BPxsYtTe.cjs} +2 -26
- package/dist/shared/attaform.BPxsYtTe.cjs.map +1 -0
- package/dist/shared/{attaform.BqEfHpVB.cjs → attaform.BPy-4qRx.cjs} +275 -268
- package/dist/shared/attaform.BPy-4qRx.cjs.map +1 -0
- package/dist/shared/{attaform.BTpuvGec.d.ts → attaform.Bh3ACtts.d.ts} +109 -101
- package/dist/shared/{attaform.BTi-PsHr.mjs → attaform.BqZuwLTK.mjs} +1868 -1477
- package/dist/shared/attaform.BqZuwLTK.mjs.map +1 -0
- package/dist/shared/{attaform.JBx8cfMA.cjs → attaform.BrrXNmfK.cjs} +263 -799
- package/dist/shared/attaform.BrrXNmfK.cjs.map +1 -0
- package/dist/shared/{attaform.CXpzmj38.mjs → attaform.BupwXkj_.mjs} +213 -270
- package/dist/shared/attaform.BupwXkj_.mjs.map +1 -0
- package/dist/shared/{attaform.ePUcKxId.d.cts → attaform.D5-1XGQU.d.cts} +109 -101
- package/dist/shared/attaform.D6CwqkPx.mjs +1876 -0
- package/dist/shared/attaform.D6CwqkPx.mjs.map +1 -0
- package/dist/shared/attaform.DHRWn-cu.cjs +785 -0
- package/dist/shared/attaform.DHRWn-cu.cjs.map +1 -0
- package/dist/shared/{attaform.C1msmO2v.cjs → attaform.DLnE5bZa.cjs} +1798 -1405
- package/dist/shared/attaform.DLnE5bZa.cjs.map +1 -0
- package/dist/shared/{attaform.D4I63aBV.d.ts → attaform.DSD85fHb.d.cts} +1 -19
- package/dist/shared/{attaform.CBjmobqk.d.cts → attaform.DSD85fHb.d.mts} +1 -19
- package/dist/shared/{attaform.DXYHL99q.d.mts → attaform.DSD85fHb.d.ts} +1 -19
- package/dist/shared/{attaform.B7rzpK1U.d.cts → attaform.DkA5J8NW.d.cts} +1 -17
- package/dist/shared/{attaform.B7rzpK1U.d.mts → attaform.DkA5J8NW.d.mts} +1 -17
- package/dist/shared/{attaform.B7rzpK1U.d.ts → attaform.DkA5J8NW.d.ts} +1 -17
- package/dist/shared/{attaform.CJ-e9gYI.d.ts → attaform.Dl5kDY-A.d.ts} +1 -1
- package/dist/shared/{attaform.CRNA0vrd.d.mts → attaform.DoKXru-a.d.mts} +1 -1
- package/dist/shared/{attaform.BtBmfLQN.d.mts → attaform.EMzJcQci.d.mts} +109 -101
- package/dist/shared/attaform.EZG6fOFb.mjs +35 -0
- package/dist/shared/attaform.EZG6fOFb.mjs.map +1 -0
- package/dist/shared/{attaform.QvygsFGh.d.cts → attaform.GbDo_lJi.d.cts} +1 -1
- package/dist/shared/{attaform.C0uGZQ4M.d.ts → attaform.SfhU0OEY.d.cts} +134 -30
- package/dist/shared/{attaform.C0uGZQ4M.d.cts → attaform.SfhU0OEY.d.mts} +134 -30
- package/dist/shared/{attaform.C0uGZQ4M.d.mts → attaform.SfhU0OEY.d.ts} +134 -30
- package/dist/shared/{attaform.a3uBo-gw.mjs → attaform.iWo9soNX.mjs} +257 -793
- package/dist/shared/attaform.iWo9soNX.mjs.map +1 -0
- package/dist/shared/attaform.tVkmQh5w.mjs +774 -0
- package/dist/shared/attaform.tVkmQh5w.mjs.map +1 -0
- package/dist/transforms.cjs +2 -2
- package/dist/transforms.d.cts +22 -13
- package/dist/transforms.d.mts +22 -13
- package/dist/transforms.d.ts +22 -13
- package/dist/transforms.mjs +1 -1
- package/dist/vite.cjs +8 -7
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +8 -7
- package/dist/vite.mjs.map +1 -1
- package/dist/zod-v3.cjs +3 -3
- package/dist/zod-v3.d.cts +32 -6
- package/dist/zod-v3.d.mts +32 -6
- package/dist/zod-v3.d.ts +32 -6
- package/dist/zod-v3.mjs +3 -3
- package/dist/zod-v4.cjs +3 -3
- package/dist/zod-v4.d.cts +12 -8
- package/dist/zod-v4.d.mts +12 -8
- package/dist/zod-v4.d.ts +12 -8
- package/dist/zod-v4.mjs +3 -3
- package/dist/zod.cjs +8 -8
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +6 -6
- package/dist/zod.d.mts +6 -6
- package/dist/zod.d.ts +6 -6
- package/dist/zod.mjs +6 -6
- package/package.json +2 -1
- package/dist/shared/attaform.BTi-PsHr.mjs.map +0 -1
- package/dist/shared/attaform.BqEfHpVB.cjs.map +0 -1
- package/dist/shared/attaform.Bubm_slq.cjs.map +0 -1
- package/dist/shared/attaform.C1msmO2v.cjs.map +0 -1
- package/dist/shared/attaform.C8CyvYa_.cjs +0 -36
- package/dist/shared/attaform.C8CyvYa_.cjs.map +0 -1
- package/dist/shared/attaform.CXpzmj38.mjs.map +0 -1
- package/dist/shared/attaform.Cghpuav8.mjs +0 -57
- package/dist/shared/attaform.Cghpuav8.mjs.map +0 -1
- package/dist/shared/attaform.CiMqJHDm.mjs +0 -1594
- package/dist/shared/attaform.CiMqJHDm.mjs.map +0 -1
- package/dist/shared/attaform.CoxJ8Qm8.cjs.map +0 -1
- package/dist/shared/attaform.CrpjyXdO.mjs.map +0 -1
- package/dist/shared/attaform.D13GMFgK.mjs +0 -32
- package/dist/shared/attaform.D13GMFgK.mjs.map +0 -1
- package/dist/shared/attaform.JBx8cfMA.cjs.map +0 -1
- package/dist/shared/attaform.OznWyOPy.cjs +0 -1600
- package/dist/shared/attaform.OznWyOPy.cjs.map +0 -1
- package/dist/shared/attaform.a3uBo-gw.mjs.map +0 -1
|
@@ -0,0 +1,774 @@
|
|
|
1
|
+
import { A as AttaformErrorCode, e as isPlainRecord, j as safeOwnRead, s as safeAssign, m as slimKindOf } from './attaform.BqZuwLTK.mjs';
|
|
2
|
+
import { j as canonicalizePath } from './attaform.BKozEdTr.mjs';
|
|
3
|
+
|
|
4
|
+
const PATH_SEPARATOR = ".";
|
|
5
|
+
function createAbstractSchema(rootSchema, intro, services, formKey, options) {
|
|
6
|
+
const maxRecursionDepth = options.maxRecursionDepth;
|
|
7
|
+
const leafCache = /* @__PURE__ */ new Map();
|
|
8
|
+
const preprocessOrCoerceCache = /* @__PURE__ */ new Map();
|
|
9
|
+
const discriminatorCache = /* @__PURE__ */ new Map();
|
|
10
|
+
let asyncValidationFlag = null;
|
|
11
|
+
let containerRefineFlag = null;
|
|
12
|
+
function computeDiscriminator(path) {
|
|
13
|
+
const candidates = path.length === 0 ? [rootSchema] : services.getNestedSchemasAtPath(rootSchema, path, maxRecursionDepth);
|
|
14
|
+
let matchedUnion;
|
|
15
|
+
for (const candidate of candidates) {
|
|
16
|
+
const du = services.unwrapToDiscriminatedUnion(candidate);
|
|
17
|
+
if (du === void 0) continue;
|
|
18
|
+
if (matchedUnion !== void 0 && matchedUnion !== du) return void 0;
|
|
19
|
+
matchedUnion = du;
|
|
20
|
+
}
|
|
21
|
+
if (matchedUnion === void 0) return void 0;
|
|
22
|
+
const discKey = intro.getDiscriminator(matchedUnion);
|
|
23
|
+
if (discKey === void 0) return void 0;
|
|
24
|
+
const unionOptions = intro.getDiscriminatedOptions(matchedUnion);
|
|
25
|
+
const literalSet = /* @__PURE__ */ new Set();
|
|
26
|
+
for (const opt of unionOptions) {
|
|
27
|
+
const shape = intro.getObjectShape(opt);
|
|
28
|
+
const litSchema = shape[discKey];
|
|
29
|
+
if (litSchema === void 0) continue;
|
|
30
|
+
if (intro.kindOf(litSchema) !== "literal") continue;
|
|
31
|
+
for (const v of intro.getLiteralValues(litSchema)) literalSet.add(v);
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
discriminatorKey: discKey,
|
|
35
|
+
getVariantDefault(value) {
|
|
36
|
+
for (const opt of unionOptions) {
|
|
37
|
+
const shape = intro.getObjectShape(opt);
|
|
38
|
+
const litSchema = shape[discKey];
|
|
39
|
+
if (litSchema === void 0) continue;
|
|
40
|
+
if (intro.kindOf(litSchema) !== "literal") continue;
|
|
41
|
+
const literalValues = intro.getLiteralValues(litSchema);
|
|
42
|
+
if (literalValues.includes(value)) {
|
|
43
|
+
return services.deriveDefault(opt, true, maxRecursionDepth, formKey);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return void 0;
|
|
47
|
+
},
|
|
48
|
+
isVariantSelected(value) {
|
|
49
|
+
return literalSet.has(value);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const abstractSchema = {
|
|
54
|
+
fingerprint: () => services.fingerprint(rootSchema),
|
|
55
|
+
needsAsyncValidation() {
|
|
56
|
+
asyncValidationFlag ?? (asyncValidationFlag = intro.containsAsyncRefine(rootSchema) || intro.containsAsyncTransform(rootSchema));
|
|
57
|
+
return asyncValidationFlag;
|
|
58
|
+
},
|
|
59
|
+
hasContainerOrRootRefine() {
|
|
60
|
+
containerRefineFlag ?? (containerRefineFlag = intro.hasContainerOrRootRefine(rootSchema));
|
|
61
|
+
return containerRefineFlag;
|
|
62
|
+
},
|
|
63
|
+
getDefaultValues(config) {
|
|
64
|
+
return services.runStrictGetDefaults(rootSchema, config, formKey, maxRecursionDepth);
|
|
65
|
+
},
|
|
66
|
+
getDefaultAtPath(path) {
|
|
67
|
+
if (path.length === 0) {
|
|
68
|
+
return services.deriveDefault(rootSchema, true, maxRecursionDepth, formKey);
|
|
69
|
+
}
|
|
70
|
+
const [first] = services.getNestedSchemasAtPath(rootSchema, path, maxRecursionDepth);
|
|
71
|
+
if (first === void 0) return void 0;
|
|
72
|
+
const peeled = services.unwrapStructuralWrappers(first);
|
|
73
|
+
return services.deriveDefault(peeled, true, maxRecursionDepth, formKey);
|
|
74
|
+
},
|
|
75
|
+
getEmptyValueAtPath(path) {
|
|
76
|
+
if (path.length === 0) {
|
|
77
|
+
return services.deriveDefault(rootSchema, false, maxRecursionDepth, formKey);
|
|
78
|
+
}
|
|
79
|
+
const [first] = services.getNestedSchemasAtPath(rootSchema, path, maxRecursionDepth);
|
|
80
|
+
if (first === void 0) return void 0;
|
|
81
|
+
return services.deriveDefault(first, false, maxRecursionDepth, formKey);
|
|
82
|
+
},
|
|
83
|
+
arrayShapeAtPath(path) {
|
|
84
|
+
if (path.length === 0) return void 0;
|
|
85
|
+
const [first] = services.getNestedSchemasAtPath(rootSchema, path, maxRecursionDepth);
|
|
86
|
+
if (first === void 0) return void 0;
|
|
87
|
+
const peeled = services.peelAllWrappers(first);
|
|
88
|
+
const kind = intro.kindOf(peeled);
|
|
89
|
+
if (kind === "tuple") return intro.getTupleItems(peeled).length;
|
|
90
|
+
if (kind === "array") return null;
|
|
91
|
+
return void 0;
|
|
92
|
+
},
|
|
93
|
+
getSchemasAtPath(path) {
|
|
94
|
+
const resolved = services.getNestedSchemasInSlimMode(rootSchema, path, maxRecursionDepth);
|
|
95
|
+
if (resolved.length === 0) return [];
|
|
96
|
+
return resolved.map((sub) => services.makeSubSchema(sub, formKey, maxRecursionDepth));
|
|
97
|
+
},
|
|
98
|
+
getSlimPrimitiveTypesAtPath(path) {
|
|
99
|
+
if (path.length === 0) return /* @__PURE__ */ new Set(["object"]);
|
|
100
|
+
const resolved = services.getNestedSchemasInSlimMode(rootSchema, path, maxRecursionDepth);
|
|
101
|
+
if (resolved.length === 0) return /* @__PURE__ */ new Set();
|
|
102
|
+
const out = /* @__PURE__ */ new Set();
|
|
103
|
+
for (const candidate of resolved) {
|
|
104
|
+
for (const k of services.slimPrimitivesOf(candidate, maxRecursionDepth)) {
|
|
105
|
+
out.add(k);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
109
|
+
},
|
|
110
|
+
isLeafAtPath(path) {
|
|
111
|
+
const cacheKey = canonicalizePath(path).key;
|
|
112
|
+
const cached = leafCache.get(cacheKey);
|
|
113
|
+
if (cached !== void 0) return cached;
|
|
114
|
+
const prim = this.getSlimPrimitiveTypesAtPath(path);
|
|
115
|
+
const isLeaf = prim.size > 0 && !prim.has("object") && !prim.has("array") && !prim.has("map") && !prim.has("set");
|
|
116
|
+
leafCache.set(cacheKey, isLeaf);
|
|
117
|
+
return isLeaf;
|
|
118
|
+
},
|
|
119
|
+
isPreprocessOrCoerceLeaf(path) {
|
|
120
|
+
const cacheKey = canonicalizePath(path).key;
|
|
121
|
+
const cached = preprocessOrCoerceCache.get(cacheKey);
|
|
122
|
+
if (cached !== void 0) return cached;
|
|
123
|
+
let hit = false;
|
|
124
|
+
for (let i = 0; i <= path.length && !hit; i++) {
|
|
125
|
+
const prefix = path.slice(0, i);
|
|
126
|
+
const candidates = prefix.length === 0 ? [rootSchema] : services.getNestedSchemasAtPath(rootSchema, prefix, maxRecursionDepth);
|
|
127
|
+
for (const candidate of candidates) {
|
|
128
|
+
if (intro.isCoercePrimitive(candidate) || intro.isPreprocessNode(candidate)) {
|
|
129
|
+
hit = true;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
preprocessOrCoerceCache.set(cacheKey, hit);
|
|
135
|
+
return hit;
|
|
136
|
+
},
|
|
137
|
+
isRequiredAtPath(path) {
|
|
138
|
+
if (path.length === 0) return true;
|
|
139
|
+
const resolved = services.getNestedSchemasAtPath(rootSchema, path, maxRecursionDepth);
|
|
140
|
+
if (resolved.length === 0) return false;
|
|
141
|
+
return resolved.every((candidate) => services.isLeafRequired(candidate));
|
|
142
|
+
},
|
|
143
|
+
getFieldMetaAtPath(path) {
|
|
144
|
+
return services.resolveFieldMetaAtPath(rootSchema, path, maxRecursionDepth);
|
|
145
|
+
},
|
|
146
|
+
getUnionDiscriminatorAtPath(path) {
|
|
147
|
+
const cacheKey = canonicalizePath(path).key;
|
|
148
|
+
if (discriminatorCache.has(cacheKey)) {
|
|
149
|
+
return discriminatorCache.get(cacheKey);
|
|
150
|
+
}
|
|
151
|
+
const result = computeDiscriminator(path);
|
|
152
|
+
discriminatorCache.set(cacheKey, result);
|
|
153
|
+
return result;
|
|
154
|
+
},
|
|
155
|
+
validateAtPath(data, path, validateOptions) {
|
|
156
|
+
const trySync = validateOptions?.sync === true;
|
|
157
|
+
if (trySync) {
|
|
158
|
+
try {
|
|
159
|
+
return runSync();
|
|
160
|
+
} catch {
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return runAsync();
|
|
164
|
+
function runSync() {
|
|
165
|
+
if (path === void 0) {
|
|
166
|
+
const result = services.safeParseSync(rootSchema, data);
|
|
167
|
+
return result.success ? {
|
|
168
|
+
data: result.data,
|
|
169
|
+
errors: void 0,
|
|
170
|
+
success: true,
|
|
171
|
+
formKey
|
|
172
|
+
} : {
|
|
173
|
+
data: void 0,
|
|
174
|
+
errors: services.issuesToValidationErrors(result.issues, formKey),
|
|
175
|
+
success: false,
|
|
176
|
+
formKey
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
const resolved = services.getNestedSchemasAtPath(rootSchema, path, maxRecursionDepth);
|
|
180
|
+
if (resolved.length === 0) return pathNotFound(path);
|
|
181
|
+
const aggregated = [];
|
|
182
|
+
for (const candidate of resolved) {
|
|
183
|
+
const result = services.safeParseSync(candidate, data);
|
|
184
|
+
if (result.success) {
|
|
185
|
+
return {
|
|
186
|
+
data: result.data,
|
|
187
|
+
errors: void 0,
|
|
188
|
+
success: true,
|
|
189
|
+
formKey
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
aggregated.push(...services.issuesToValidationErrors(result.issues, formKey));
|
|
193
|
+
}
|
|
194
|
+
return { data: void 0, errors: aggregated, success: false, formKey };
|
|
195
|
+
}
|
|
196
|
+
async function runAsync() {
|
|
197
|
+
if (path === void 0) {
|
|
198
|
+
let result;
|
|
199
|
+
try {
|
|
200
|
+
result = await services.safeParseAsync(rootSchema, data);
|
|
201
|
+
} catch (err) {
|
|
202
|
+
return validatorThrewResponse(err, []);
|
|
203
|
+
}
|
|
204
|
+
return result.success ? {
|
|
205
|
+
data: result.data,
|
|
206
|
+
errors: void 0,
|
|
207
|
+
success: true,
|
|
208
|
+
formKey
|
|
209
|
+
} : {
|
|
210
|
+
data: void 0,
|
|
211
|
+
errors: services.issuesToValidationErrors(result.issues, formKey),
|
|
212
|
+
success: false,
|
|
213
|
+
formKey
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
const resolved = services.getNestedSchemasAtPath(rootSchema, path, maxRecursionDepth);
|
|
217
|
+
if (resolved.length === 0) return pathNotFound(path);
|
|
218
|
+
const aggregated = [];
|
|
219
|
+
for (const candidate of resolved) {
|
|
220
|
+
let result;
|
|
221
|
+
try {
|
|
222
|
+
result = await services.safeParseAsync(candidate, data);
|
|
223
|
+
} catch (err) {
|
|
224
|
+
return validatorThrewResponse(err, path);
|
|
225
|
+
}
|
|
226
|
+
if (result.success) {
|
|
227
|
+
return {
|
|
228
|
+
data: result.data,
|
|
229
|
+
errors: void 0,
|
|
230
|
+
success: true,
|
|
231
|
+
formKey
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
aggregated.push(...services.issuesToValidationErrors(result.issues, formKey));
|
|
235
|
+
}
|
|
236
|
+
return { data: void 0, errors: aggregated, success: false, formKey };
|
|
237
|
+
}
|
|
238
|
+
function validatorThrewResponse(err, errPath) {
|
|
239
|
+
const message = err instanceof Error ? err.message : typeof err === "string" ? err : "Validator threw";
|
|
240
|
+
return {
|
|
241
|
+
data: void 0,
|
|
242
|
+
errors: [
|
|
243
|
+
{
|
|
244
|
+
message,
|
|
245
|
+
path: [...errPath],
|
|
246
|
+
formKey,
|
|
247
|
+
code: AttaformErrorCode.ValidatorThrew
|
|
248
|
+
}
|
|
249
|
+
],
|
|
250
|
+
success: false,
|
|
251
|
+
formKey
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function pathNotFound(p) {
|
|
255
|
+
return {
|
|
256
|
+
data: void 0,
|
|
257
|
+
errors: [
|
|
258
|
+
{
|
|
259
|
+
message: `Path '${p.join(PATH_SEPARATOR)}' did not resolve to any schema`,
|
|
260
|
+
path: [...p],
|
|
261
|
+
formKey,
|
|
262
|
+
code: AttaformErrorCode.PathNotFound
|
|
263
|
+
}
|
|
264
|
+
],
|
|
265
|
+
success: false,
|
|
266
|
+
formKey
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
return abstractSchema;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function walkPathSegments(schema, segments, intro, maxDepth, lazyDepth) {
|
|
275
|
+
if (segments.length === 0) return [schema];
|
|
276
|
+
const [head, ...rest] = segments;
|
|
277
|
+
if (head === void 0) return [schema];
|
|
278
|
+
const kind = intro.kindOf(schema);
|
|
279
|
+
switch (kind) {
|
|
280
|
+
case "object": {
|
|
281
|
+
const shape = intro.getObjectShape(schema);
|
|
282
|
+
if (!Object.hasOwn(shape, head)) return [];
|
|
283
|
+
const next = shape[head];
|
|
284
|
+
return next === void 0 ? [] : walkPathSegments(next, rest, intro, maxDepth, lazyDepth);
|
|
285
|
+
}
|
|
286
|
+
case "array": {
|
|
287
|
+
const inner = intro.getArrayElement(schema);
|
|
288
|
+
return inner === void 0 ? [] : walkPathSegments(inner, rest, intro, maxDepth, lazyDepth);
|
|
289
|
+
}
|
|
290
|
+
case "set": {
|
|
291
|
+
const inner = intro.getSetValueType(schema);
|
|
292
|
+
return inner === void 0 ? [] : walkPathSegments(inner, rest, intro, maxDepth, lazyDepth);
|
|
293
|
+
}
|
|
294
|
+
case "record": {
|
|
295
|
+
const inner = intro.getRecordValueType(schema);
|
|
296
|
+
return inner === void 0 ? [] : walkPathSegments(inner, rest, intro, maxDepth, lazyDepth);
|
|
297
|
+
}
|
|
298
|
+
case "tuple": {
|
|
299
|
+
const index = Number(head);
|
|
300
|
+
if (!Number.isInteger(index)) return [];
|
|
301
|
+
const items = intro.getTupleItems(schema);
|
|
302
|
+
const item = items[index];
|
|
303
|
+
return item === void 0 ? [] : walkPathSegments(item, rest, intro, maxDepth, lazyDepth);
|
|
304
|
+
}
|
|
305
|
+
case "union":
|
|
306
|
+
return intro.getUnionOptions(schema).flatMap((opt) => walkPathSegments(opt, segments, intro, maxDepth, lazyDepth));
|
|
307
|
+
case "discriminated-union": {
|
|
308
|
+
const options = intro.getDiscriminatedOptions(schema);
|
|
309
|
+
const matching = options.filter((opt) => Object.hasOwn(intro.getObjectShape(opt), head));
|
|
310
|
+
const candidates = matching.length > 0 ? matching : options;
|
|
311
|
+
return candidates.flatMap(
|
|
312
|
+
(opt) => walkPathSegments(opt, segments, intro, maxDepth, lazyDepth)
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
case "optional":
|
|
316
|
+
case "nullable":
|
|
317
|
+
case "default":
|
|
318
|
+
case "readonly":
|
|
319
|
+
case "catch": {
|
|
320
|
+
const inner = intro.unwrapInner(schema);
|
|
321
|
+
return inner === void 0 ? [] : walkPathSegments(inner, segments, intro, maxDepth, lazyDepth);
|
|
322
|
+
}
|
|
323
|
+
case "pipe": {
|
|
324
|
+
const inner = intro.unwrapPipeIn(schema) ?? intro.unwrapPipeOut(schema);
|
|
325
|
+
return inner === void 0 ? [] : walkPathSegments(inner, segments, intro, maxDepth, lazyDepth);
|
|
326
|
+
}
|
|
327
|
+
case "pipeline": {
|
|
328
|
+
const inner = intro.unwrapPipeIn(schema);
|
|
329
|
+
return inner === void 0 ? [] : walkPathSegments(inner, segments, intro, maxDepth, lazyDepth);
|
|
330
|
+
}
|
|
331
|
+
case "effects": {
|
|
332
|
+
const inner = intro.unwrapEffectsSource(schema);
|
|
333
|
+
return inner === void 0 ? [] : walkPathSegments(inner, segments, intro, maxDepth, lazyDepth);
|
|
334
|
+
}
|
|
335
|
+
case "branded": {
|
|
336
|
+
const inner = intro.unwrapBranded(schema);
|
|
337
|
+
return inner === void 0 ? [] : walkPathSegments(inner, segments, intro, maxDepth, lazyDepth);
|
|
338
|
+
}
|
|
339
|
+
case "lazy": {
|
|
340
|
+
if (lazyDepth >= maxDepth) return [];
|
|
341
|
+
const inner = intro.unwrapLazy(schema);
|
|
342
|
+
return inner === void 0 ? [] : walkPathSegments(inner, segments, intro, maxDepth, lazyDepth + 1);
|
|
343
|
+
}
|
|
344
|
+
case "intersection": {
|
|
345
|
+
const left = intro.getIntersectionLeft(schema);
|
|
346
|
+
const right = intro.getIntersectionRight(schema);
|
|
347
|
+
const leftResults = left === void 0 ? [] : walkPathSegments(left, segments, intro, maxDepth, lazyDepth);
|
|
348
|
+
const rightResults = right === void 0 ? [] : walkPathSegments(right, segments, intro, maxDepth, lazyDepth);
|
|
349
|
+
return [...leftResults, ...rightResults];
|
|
350
|
+
}
|
|
351
|
+
// Leaves — can't descend further. The unsupported kinds (`map` /
|
|
352
|
+
// `symbol` / `function` / `promise`) are rejected at adapter
|
|
353
|
+
// construction by `assertSupportedKinds`; falling through to `[]`
|
|
354
|
+
// keeps the walker defensive in case construction is skipped
|
|
355
|
+
// (e.g. a downstream test instantiates a sub-schema directly).
|
|
356
|
+
default:
|
|
357
|
+
return [];
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function mergeDeep(base, override) {
|
|
362
|
+
if (override === void 0) return base;
|
|
363
|
+
if (!isPlainRecord(override)) return override;
|
|
364
|
+
if (!isPlainRecord(base)) return override;
|
|
365
|
+
const result = { ...base };
|
|
366
|
+
for (const key of Object.keys(override)) {
|
|
367
|
+
const oVal = safeOwnRead(override, key);
|
|
368
|
+
const bVal = safeOwnRead(base, key);
|
|
369
|
+
if (isPlainRecord(oVal) && isPlainRecord(bVal)) {
|
|
370
|
+
safeAssign(result, key, mergeDeep(bVal, oVal));
|
|
371
|
+
} else {
|
|
372
|
+
safeAssign(result, key, oVal);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return result;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const NO_EMBEDDED_DEFAULT = Symbol("atta:no-embedded-default");
|
|
379
|
+
function peelEmbeddedDefault(schema, intro) {
|
|
380
|
+
let current = schema;
|
|
381
|
+
for (let i = 0; i < 32; i++) {
|
|
382
|
+
if (current === void 0) return NO_EMBEDDED_DEFAULT;
|
|
383
|
+
const k = intro.kindOf(current);
|
|
384
|
+
if (k === "default") return intro.getDefaultValue(current);
|
|
385
|
+
if (k === "catch") {
|
|
386
|
+
if (intro.hasCatchValue(current)) return intro.getCatchDefault(current);
|
|
387
|
+
current = intro.unwrapInner(current);
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
if (k === "optional" || k === "nullable" || k === "readonly") {
|
|
391
|
+
current = intro.unwrapInner(current);
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
if (k === "branded") {
|
|
395
|
+
current = intro.unwrapBranded(current);
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
if (k === "effects") {
|
|
399
|
+
current = intro.unwrapEffectsSource(current);
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
if (k === "pipeline") {
|
|
403
|
+
current = intro.unwrapPipeIn(current);
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
return NO_EMBEDDED_DEFAULT;
|
|
407
|
+
}
|
|
408
|
+
return NO_EMBEDDED_DEFAULT;
|
|
409
|
+
}
|
|
410
|
+
function hasDeclaredDefaultInChain(schema, intro) {
|
|
411
|
+
let current = schema;
|
|
412
|
+
for (let i = 0; i < 32; i++) {
|
|
413
|
+
if (current === void 0) return false;
|
|
414
|
+
const k = intro.kindOf(current);
|
|
415
|
+
if (k === "default") return true;
|
|
416
|
+
if (k === "optional" || k === "nullable" || k === "readonly" || k === "catch") {
|
|
417
|
+
current = intro.unwrapInner(current);
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
return false;
|
|
421
|
+
}
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
function deriveDefaultWalk(schema, useDefault, intro, maxDepth, ctx, lazyDepth = 0) {
|
|
425
|
+
if (useDefault) {
|
|
426
|
+
const peeled = peelEmbeddedDefault(schema, intro);
|
|
427
|
+
if (peeled !== NO_EMBEDDED_DEFAULT) return peeled;
|
|
428
|
+
}
|
|
429
|
+
if (intro.isCoercePrimitive(schema)) return void 0;
|
|
430
|
+
const kind = intro.kindOf(schema);
|
|
431
|
+
switch (kind) {
|
|
432
|
+
case "object": {
|
|
433
|
+
const shape = intro.getObjectShape(schema);
|
|
434
|
+
const out = {};
|
|
435
|
+
for (const [key, subSchema] of Object.entries(shape)) {
|
|
436
|
+
safeAssign(
|
|
437
|
+
out,
|
|
438
|
+
key,
|
|
439
|
+
deriveDefaultWalk(subSchema, useDefault, intro, maxDepth, ctx, lazyDepth)
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
return out;
|
|
443
|
+
}
|
|
444
|
+
case "array":
|
|
445
|
+
return [];
|
|
446
|
+
case "set":
|
|
447
|
+
return /* @__PURE__ */ new Set();
|
|
448
|
+
case "record":
|
|
449
|
+
return {};
|
|
450
|
+
case "tuple": {
|
|
451
|
+
const items = intro.getTupleItems(schema);
|
|
452
|
+
return items.map(
|
|
453
|
+
(item) => deriveDefaultWalk(item, useDefault, intro, maxDepth, ctx, lazyDepth)
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
case "union": {
|
|
457
|
+
const options = intro.getUnionOptions(schema);
|
|
458
|
+
const first = options[0];
|
|
459
|
+
return first === void 0 ? void 0 : deriveDefaultWalk(first, useDefault, intro, maxDepth, ctx, lazyDepth);
|
|
460
|
+
}
|
|
461
|
+
case "discriminated-union": {
|
|
462
|
+
const options = intro.getDiscriminatedOptions(schema);
|
|
463
|
+
const first = options[0];
|
|
464
|
+
return first === void 0 ? void 0 : deriveDefaultWalk(first, useDefault, intro, maxDepth, ctx, lazyDepth);
|
|
465
|
+
}
|
|
466
|
+
case "optional":
|
|
467
|
+
return void 0;
|
|
468
|
+
case "nullable":
|
|
469
|
+
return null;
|
|
470
|
+
case "default": {
|
|
471
|
+
if (useDefault) return intro.getDefaultValue(schema);
|
|
472
|
+
const inner = intro.unwrapInner(schema);
|
|
473
|
+
return inner === void 0 ? void 0 : deriveDefaultWalk(inner, useDefault, intro, maxDepth, ctx, lazyDepth);
|
|
474
|
+
}
|
|
475
|
+
case "readonly":
|
|
476
|
+
case "branded": {
|
|
477
|
+
const inner = kind === "branded" ? intro.unwrapBranded(schema) : intro.unwrapInner(schema);
|
|
478
|
+
return inner === void 0 ? void 0 : deriveDefaultWalk(inner, useDefault, intro, maxDepth, ctx, lazyDepth);
|
|
479
|
+
}
|
|
480
|
+
case "effects": {
|
|
481
|
+
const inner = intro.unwrapEffectsSource(schema);
|
|
482
|
+
if (intro.isPreprocessNode(schema)) {
|
|
483
|
+
if (inner !== void 0 && hasDeclaredDefaultInChain(inner, intro)) {
|
|
484
|
+
return deriveDefaultWalk(inner, useDefault, intro, maxDepth, ctx, lazyDepth);
|
|
485
|
+
}
|
|
486
|
+
return void 0;
|
|
487
|
+
}
|
|
488
|
+
return inner === void 0 ? void 0 : deriveDefaultWalk(inner, useDefault, intro, maxDepth, ctx, lazyDepth);
|
|
489
|
+
}
|
|
490
|
+
case "pipeline": {
|
|
491
|
+
const inner = intro.unwrapPipeIn(schema);
|
|
492
|
+
return inner === void 0 ? void 0 : deriveDefaultWalk(inner, useDefault, intro, maxDepth, ctx, lazyDepth);
|
|
493
|
+
}
|
|
494
|
+
case "pipe": {
|
|
495
|
+
const inn = intro.unwrapPipeIn(schema);
|
|
496
|
+
if (inn !== void 0 && intro.kindOf(inn) === "transform") {
|
|
497
|
+
const out2 = intro.unwrapPipeOut(schema);
|
|
498
|
+
if (out2 !== void 0 && hasDeclaredDefaultInChain(out2, intro)) {
|
|
499
|
+
return deriveDefaultWalk(out2, useDefault, intro, maxDepth, ctx, lazyDepth);
|
|
500
|
+
}
|
|
501
|
+
return void 0;
|
|
502
|
+
}
|
|
503
|
+
const out = intro.unwrapPipeOut(schema);
|
|
504
|
+
const real = inn !== void 0 && intro.kindOf(inn) !== "transform" ? inn : out !== void 0 && intro.kindOf(out) !== "transform" ? out : inn ?? out;
|
|
505
|
+
return real === void 0 ? void 0 : deriveDefaultWalk(real, useDefault, intro, maxDepth, ctx, lazyDepth);
|
|
506
|
+
}
|
|
507
|
+
case "string":
|
|
508
|
+
return "";
|
|
509
|
+
case "number":
|
|
510
|
+
return 0;
|
|
511
|
+
case "bigint":
|
|
512
|
+
return 0n;
|
|
513
|
+
case "boolean":
|
|
514
|
+
return false;
|
|
515
|
+
case "date":
|
|
516
|
+
return /* @__PURE__ */ new Date(0);
|
|
517
|
+
case "null":
|
|
518
|
+
return null;
|
|
519
|
+
case "undefined":
|
|
520
|
+
return void 0;
|
|
521
|
+
case "enum": {
|
|
522
|
+
const values = intro.getEnumValues(schema);
|
|
523
|
+
return values[0];
|
|
524
|
+
}
|
|
525
|
+
case "native-enum": {
|
|
526
|
+
const values = intro.getNativeEnumValues(schema);
|
|
527
|
+
if (values === void 0) return void 0;
|
|
528
|
+
const validKeys = Object.keys(values).filter(
|
|
529
|
+
(k) => typeof values[values[k]] !== "number"
|
|
530
|
+
);
|
|
531
|
+
if (validKeys.length === 0) return void 0;
|
|
532
|
+
const first = validKeys[0];
|
|
533
|
+
return first === void 0 ? void 0 : values[first];
|
|
534
|
+
}
|
|
535
|
+
case "literal": {
|
|
536
|
+
const values = intro.getLiteralValues(schema);
|
|
537
|
+
return values[0];
|
|
538
|
+
}
|
|
539
|
+
case "nan":
|
|
540
|
+
return NaN;
|
|
541
|
+
case "lazy": {
|
|
542
|
+
if (lazyDepth >= maxDepth) return void 0;
|
|
543
|
+
let inner;
|
|
544
|
+
try {
|
|
545
|
+
inner = intro.unwrapLazy(schema);
|
|
546
|
+
} catch {
|
|
547
|
+
return void 0;
|
|
548
|
+
}
|
|
549
|
+
return inner === void 0 ? void 0 : deriveDefaultWalk(inner, useDefault, intro, maxDepth, ctx, lazyDepth + 1);
|
|
550
|
+
}
|
|
551
|
+
case "intersection": {
|
|
552
|
+
const left = intro.getIntersectionLeft(schema);
|
|
553
|
+
const right = intro.getIntersectionRight(schema);
|
|
554
|
+
const l = left === void 0 ? void 0 : deriveDefaultWalk(left, useDefault, intro, maxDepth, ctx, lazyDepth);
|
|
555
|
+
const r = right === void 0 ? void 0 : deriveDefaultWalk(right, useDefault, intro, maxDepth, ctx, lazyDepth);
|
|
556
|
+
return mergeDeep(l, r);
|
|
557
|
+
}
|
|
558
|
+
case "catch": {
|
|
559
|
+
if (useDefault) return intro.getCatchDefault(schema);
|
|
560
|
+
if (ctx.catchOnUseDefaultFalse === "preserveCatch" && intro.hasCatchValue(schema)) {
|
|
561
|
+
return intro.getCatchDefault(schema);
|
|
562
|
+
}
|
|
563
|
+
const inner = intro.unwrapInner(schema);
|
|
564
|
+
return inner === void 0 ? void 0 : deriveDefaultWalk(inner, useDefault, intro, maxDepth, ctx, lazyDepth);
|
|
565
|
+
}
|
|
566
|
+
case "file":
|
|
567
|
+
return null;
|
|
568
|
+
case "any":
|
|
569
|
+
case "unknown":
|
|
570
|
+
case "void":
|
|
571
|
+
case "never":
|
|
572
|
+
case "promise":
|
|
573
|
+
case "custom":
|
|
574
|
+
case "template-literal":
|
|
575
|
+
case "transform":
|
|
576
|
+
case "map":
|
|
577
|
+
case "symbol":
|
|
578
|
+
case "function":
|
|
579
|
+
return void 0;
|
|
580
|
+
default:
|
|
581
|
+
return ctx.unsupportedKindFallback(schema, kind);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
const store = /* @__PURE__ */ new WeakMap();
|
|
586
|
+
const lists = /* @__PURE__ */ new WeakMap();
|
|
587
|
+
const registry = {
|
|
588
|
+
add(schema, payload) {
|
|
589
|
+
store.set(schema, payload);
|
|
590
|
+
const list = lists.get(schema) ?? [];
|
|
591
|
+
list.push(payload);
|
|
592
|
+
lists.set(schema, list);
|
|
593
|
+
return registry;
|
|
594
|
+
},
|
|
595
|
+
get(schema) {
|
|
596
|
+
return store.get(schema);
|
|
597
|
+
},
|
|
598
|
+
has(schema) {
|
|
599
|
+
return store.has(schema);
|
|
600
|
+
},
|
|
601
|
+
remove(schema) {
|
|
602
|
+
store.delete(schema);
|
|
603
|
+
lists.delete(schema);
|
|
604
|
+
return registry;
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
const fieldMetaStore = registry;
|
|
608
|
+
function getFieldMetaForSchema(schema) {
|
|
609
|
+
return store.get(schema);
|
|
610
|
+
}
|
|
611
|
+
function getFieldMetaListForSchema(schema) {
|
|
612
|
+
return lists.get(schema) ?? [];
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
const PERMISSIVE_SLIM_KINDS = /* @__PURE__ */ new Set([
|
|
616
|
+
"string",
|
|
617
|
+
"number",
|
|
618
|
+
"boolean",
|
|
619
|
+
"bigint",
|
|
620
|
+
"date",
|
|
621
|
+
"null",
|
|
622
|
+
"undefined",
|
|
623
|
+
"object",
|
|
624
|
+
"array",
|
|
625
|
+
"symbol",
|
|
626
|
+
"function",
|
|
627
|
+
"map",
|
|
628
|
+
"set",
|
|
629
|
+
"file"
|
|
630
|
+
]);
|
|
631
|
+
const KIND_STRING = /* @__PURE__ */ new Set(["string"]);
|
|
632
|
+
const KIND_NUMBER = /* @__PURE__ */ new Set(["number"]);
|
|
633
|
+
const KIND_BOOLEAN = /* @__PURE__ */ new Set(["boolean"]);
|
|
634
|
+
const KIND_BIGINT = /* @__PURE__ */ new Set(["bigint"]);
|
|
635
|
+
const KIND_DATE = /* @__PURE__ */ new Set(["date"]);
|
|
636
|
+
const KIND_NULL = /* @__PURE__ */ new Set(["null"]);
|
|
637
|
+
const KIND_UNDEFINED = /* @__PURE__ */ new Set(["undefined"]);
|
|
638
|
+
const KIND_OBJECT = /* @__PURE__ */ new Set(["object"]);
|
|
639
|
+
const KIND_ARRAY = /* @__PURE__ */ new Set(["array"]);
|
|
640
|
+
const KIND_SET = /* @__PURE__ */ new Set(["set"]);
|
|
641
|
+
const KIND_FILE = /* @__PURE__ */ new Set(["file", "null"]);
|
|
642
|
+
const EMPTY_KINDS = /* @__PURE__ */ new Set();
|
|
643
|
+
function slimPrimitivesWalk(schema, intro, maxDepth, lazyDepth = 0) {
|
|
644
|
+
const kind = intro.kindOf(schema);
|
|
645
|
+
switch (kind) {
|
|
646
|
+
case "string":
|
|
647
|
+
return KIND_STRING;
|
|
648
|
+
case "number":
|
|
649
|
+
case "nan":
|
|
650
|
+
return KIND_NUMBER;
|
|
651
|
+
case "boolean":
|
|
652
|
+
return KIND_BOOLEAN;
|
|
653
|
+
case "bigint":
|
|
654
|
+
return KIND_BIGINT;
|
|
655
|
+
case "date":
|
|
656
|
+
return KIND_DATE;
|
|
657
|
+
case "file":
|
|
658
|
+
return KIND_FILE;
|
|
659
|
+
case "null":
|
|
660
|
+
return KIND_NULL;
|
|
661
|
+
case "undefined":
|
|
662
|
+
case "void":
|
|
663
|
+
return KIND_UNDEFINED;
|
|
664
|
+
case "enum": {
|
|
665
|
+
const values = intro.getEnumValues(schema);
|
|
666
|
+
const out = /* @__PURE__ */ new Set();
|
|
667
|
+
for (const v of values) {
|
|
668
|
+
if (typeof v === "string") out.add("string");
|
|
669
|
+
else if (typeof v === "number") out.add("number");
|
|
670
|
+
}
|
|
671
|
+
return out.size === 0 ? KIND_STRING : out;
|
|
672
|
+
}
|
|
673
|
+
case "native-enum": {
|
|
674
|
+
const values = intro.getNativeEnumValues(schema);
|
|
675
|
+
if (values === void 0) return KIND_STRING;
|
|
676
|
+
const out = /* @__PURE__ */ new Set();
|
|
677
|
+
for (const v of Object.values(values)) {
|
|
678
|
+
if (typeof v === "string") out.add("string");
|
|
679
|
+
else if (typeof v === "number") out.add("number");
|
|
680
|
+
}
|
|
681
|
+
return out.size === 0 ? KIND_STRING : out;
|
|
682
|
+
}
|
|
683
|
+
case "literal": {
|
|
684
|
+
const values = intro.getLiteralValues(schema);
|
|
685
|
+
const out = /* @__PURE__ */ new Set();
|
|
686
|
+
for (const v of values) out.add(slimKindOf(v));
|
|
687
|
+
return out.size === 0 ? PERMISSIVE_SLIM_KINDS : out;
|
|
688
|
+
}
|
|
689
|
+
case "object":
|
|
690
|
+
case "record":
|
|
691
|
+
return KIND_OBJECT;
|
|
692
|
+
case "array":
|
|
693
|
+
case "tuple":
|
|
694
|
+
return KIND_ARRAY;
|
|
695
|
+
case "set":
|
|
696
|
+
return KIND_SET;
|
|
697
|
+
case "optional": {
|
|
698
|
+
const inner = intro.unwrapInner(schema);
|
|
699
|
+
const innerSet = inner === void 0 ? EMPTY_KINDS : slimPrimitivesWalk(inner, intro, maxDepth, lazyDepth);
|
|
700
|
+
const out = new Set(innerSet);
|
|
701
|
+
out.add("undefined");
|
|
702
|
+
return out;
|
|
703
|
+
}
|
|
704
|
+
case "nullable": {
|
|
705
|
+
const inner = intro.unwrapInner(schema);
|
|
706
|
+
const innerSet = inner === void 0 ? EMPTY_KINDS : slimPrimitivesWalk(inner, intro, maxDepth, lazyDepth);
|
|
707
|
+
const out = new Set(innerSet);
|
|
708
|
+
out.add("null");
|
|
709
|
+
return out;
|
|
710
|
+
}
|
|
711
|
+
case "default":
|
|
712
|
+
case "readonly":
|
|
713
|
+
case "catch": {
|
|
714
|
+
const inner = intro.unwrapInner(schema);
|
|
715
|
+
return inner === void 0 ? PERMISSIVE_SLIM_KINDS : slimPrimitivesWalk(inner, intro, maxDepth, lazyDepth);
|
|
716
|
+
}
|
|
717
|
+
case "branded": {
|
|
718
|
+
const inner = intro.unwrapBranded(schema);
|
|
719
|
+
return inner === void 0 ? PERMISSIVE_SLIM_KINDS : slimPrimitivesWalk(inner, intro, maxDepth, lazyDepth);
|
|
720
|
+
}
|
|
721
|
+
case "effects": {
|
|
722
|
+
const inner = intro.unwrapEffectsSource(schema);
|
|
723
|
+
return inner === void 0 ? PERMISSIVE_SLIM_KINDS : slimPrimitivesWalk(inner, intro, maxDepth, lazyDepth);
|
|
724
|
+
}
|
|
725
|
+
case "pipeline": {
|
|
726
|
+
const inner = intro.unwrapPipeIn(schema);
|
|
727
|
+
return inner === void 0 ? PERMISSIVE_SLIM_KINDS : slimPrimitivesWalk(inner, intro, maxDepth, lazyDepth);
|
|
728
|
+
}
|
|
729
|
+
case "pipe": {
|
|
730
|
+
const pipeIn = intro.unwrapPipeIn(schema);
|
|
731
|
+
const pipeOut = intro.unwrapPipeOut(schema);
|
|
732
|
+
const inner = pipeIn !== void 0 && intro.kindOf(pipeIn) === "transform" ? pipeOut : pipeIn ?? pipeOut;
|
|
733
|
+
return inner === void 0 ? PERMISSIVE_SLIM_KINDS : slimPrimitivesWalk(inner, intro, maxDepth, lazyDepth);
|
|
734
|
+
}
|
|
735
|
+
case "lazy": {
|
|
736
|
+
if (lazyDepth >= maxDepth) return PERMISSIVE_SLIM_KINDS;
|
|
737
|
+
const inner = intro.unwrapLazy(schema);
|
|
738
|
+
return inner === void 0 ? PERMISSIVE_SLIM_KINDS : slimPrimitivesWalk(inner, intro, maxDepth, lazyDepth + 1);
|
|
739
|
+
}
|
|
740
|
+
case "union":
|
|
741
|
+
case "discriminated-union": {
|
|
742
|
+
const options = intro.getUnionOptions(schema);
|
|
743
|
+
const out = /* @__PURE__ */ new Set();
|
|
744
|
+
for (const opt of options) {
|
|
745
|
+
for (const k of slimPrimitivesWalk(opt, intro, maxDepth, lazyDepth)) out.add(k);
|
|
746
|
+
}
|
|
747
|
+
return out.size === 0 ? PERMISSIVE_SLIM_KINDS : out;
|
|
748
|
+
}
|
|
749
|
+
case "intersection": {
|
|
750
|
+
const left = intro.getIntersectionLeft(schema);
|
|
751
|
+
const right = intro.getIntersectionRight(schema);
|
|
752
|
+
const leftSet = left === void 0 ? PERMISSIVE_SLIM_KINDS : slimPrimitivesWalk(left, intro, maxDepth, lazyDepth);
|
|
753
|
+
const rightSet = right === void 0 ? PERMISSIVE_SLIM_KINDS : slimPrimitivesWalk(right, intro, maxDepth, lazyDepth);
|
|
754
|
+
const out = /* @__PURE__ */ new Set();
|
|
755
|
+
for (const k of leftSet) if (rightSet.has(k)) out.add(k);
|
|
756
|
+
return out;
|
|
757
|
+
}
|
|
758
|
+
case "never":
|
|
759
|
+
return EMPTY_KINDS;
|
|
760
|
+
case "any":
|
|
761
|
+
case "unknown":
|
|
762
|
+
return PERMISSIVE_SLIM_KINDS;
|
|
763
|
+
// Opaque / unsupported kinds: be permissive so legitimate writes
|
|
764
|
+
// aren't false-rejected. The unsupported kinds (`map` / `symbol` /
|
|
765
|
+
// `function` / `promise`) are rejected at adapter construction by
|
|
766
|
+
// `assertSupportedKinds`; this fallthrough keeps the walker
|
|
767
|
+
// defensive in case construction is skipped.
|
|
768
|
+
default:
|
|
769
|
+
return PERMISSIVE_SLIM_KINDS;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
export { NO_EMBEDDED_DEFAULT as N, getFieldMetaListForSchema as a, createAbstractSchema as c, deriveDefaultWalk as d, fieldMetaStore as f, getFieldMetaForSchema as g, mergeDeep as m, peelEmbeddedDefault as p, slimPrimitivesWalk as s, walkPathSegments as w };
|
|
774
|
+
//# sourceMappingURL=attaform.tVkmQh5w.mjs.map
|