@stonecrop/schema 0.16.6 → 0.18.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/cli.js +1 -1
- package/dist/index.js +23 -22
- package/dist/schema.d.ts +60 -6
- package/dist/src/doctype.d.ts +32 -3
- package/dist/src/doctype.d.ts.map +1 -1
- package/dist/src/doctype.js +25 -0
- package/dist/src/field.d.ts +26 -3
- package/dist/src/field.d.ts.map +1 -1
- package/dist/src/field.js +28 -3
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/{validation-CToUOy0a.js → validation-C25HJXWs.js} +129 -116
- package/dist/validation-C25HJXWs.js.map +1 -0
- package/package.json +1 -1
- package/dist/validation-CToUOy0a.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isScalarType as P, isEnumType as
|
|
1
|
+
import { isScalarType as P, isEnumType as K, isObjectType as k, isNonNullType as v, isListType as V, isNamedType as z, buildSchema as B, buildClientSchema as W } from "graphql";
|
|
2
2
|
import { z as e } from "zod";
|
|
3
3
|
function je(t) {
|
|
4
4
|
return t.replace(/_([a-z])/g, (n, i) => i.toUpperCase());
|
|
@@ -9,11 +9,11 @@ function Oe(t) {
|
|
|
9
9
|
function Ce(t) {
|
|
10
10
|
return t.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join(" ");
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function G(t) {
|
|
13
13
|
const n = t.replace(/([A-Z])/g, " $1").trim();
|
|
14
14
|
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function J(t) {
|
|
17
17
|
return t.split(/[-_\s]+/).map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join("");
|
|
18
18
|
}
|
|
19
19
|
function T(t) {
|
|
@@ -22,13 +22,13 @@ function T(t) {
|
|
|
22
22
|
function Ne(t) {
|
|
23
23
|
return t.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase();
|
|
24
24
|
}
|
|
25
|
-
const
|
|
25
|
+
const Q = {
|
|
26
26
|
String: { component: "ATextInput" },
|
|
27
27
|
Int: { component: "ANumericInput" },
|
|
28
28
|
Float: { component: "ANumericInput" },
|
|
29
29
|
Boolean: { component: "ACheckbox" },
|
|
30
30
|
ID: { component: "ATextInput" }
|
|
31
|
-
},
|
|
31
|
+
}, Z = {
|
|
32
32
|
// Arbitrary precision / large numbers — all numeric variants render with ANumericInput.
|
|
33
33
|
BigFloat: { component: "ANumericInput" },
|
|
34
34
|
BigDecimal: { component: "ANumericInput" },
|
|
@@ -48,17 +48,17 @@ const J = {
|
|
|
48
48
|
JSON: { component: "ACodeEditor" },
|
|
49
49
|
JSONObject: { component: "ACodeEditor" },
|
|
50
50
|
JsonNode: { component: "ACodeEditor" }
|
|
51
|
-
},
|
|
52
|
-
function
|
|
53
|
-
const n = { ...
|
|
54
|
-
for (const [i, o] of Object.entries(
|
|
51
|
+
}, H = /* @__PURE__ */ new Set(["Cursor"]);
|
|
52
|
+
function Y(t) {
|
|
53
|
+
const n = { ...Z };
|
|
54
|
+
for (const [i, o] of Object.entries(Q))
|
|
55
55
|
n[i] = o;
|
|
56
56
|
if (t)
|
|
57
57
|
for (const [i, o] of Object.entries(t))
|
|
58
58
|
n[i] = { component: o.component ?? "ATextInput" };
|
|
59
59
|
return n;
|
|
60
60
|
}
|
|
61
|
-
const
|
|
61
|
+
const X = [
|
|
62
62
|
"Connection",
|
|
63
63
|
"Edge",
|
|
64
64
|
"Input",
|
|
@@ -74,66 +74,66 @@ const Y = [
|
|
|
74
74
|
"InsertResponse",
|
|
75
75
|
"UpdateResponse",
|
|
76
76
|
"MutationResponse"
|
|
77
|
-
],
|
|
78
|
-
function
|
|
79
|
-
if (t.startsWith("__") ||
|
|
77
|
+
], ee = /* @__PURE__ */ new Set(["Query", "Mutation", "Subscription"]);
|
|
78
|
+
function te(t, n) {
|
|
79
|
+
if (t.startsWith("__") || ee.has(t) || t === "Node")
|
|
80
80
|
return !1;
|
|
81
|
-
for (const o of
|
|
81
|
+
for (const o of X)
|
|
82
82
|
if (t.endsWith(o))
|
|
83
83
|
return !1;
|
|
84
84
|
const i = n.getFields();
|
|
85
85
|
return Object.keys(i).length !== 0;
|
|
86
86
|
}
|
|
87
|
-
const
|
|
88
|
-
function
|
|
89
|
-
return !
|
|
87
|
+
const ne = /* @__PURE__ */ new Set(["nodeId", "__typename", "clientMutationId"]);
|
|
88
|
+
function ie(t, n, i) {
|
|
89
|
+
return !ne.has(t);
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function _(t) {
|
|
92
92
|
let n = !1, i = !1, o = t;
|
|
93
93
|
if (v(o) && (n = !0, o = o.ofType), V(o) && (i = !0, o = o.ofType, v(o) && (o = o.ofType)), !z(o))
|
|
94
94
|
throw new Error(`Expected a named GraphQL type, got: ${String(o)}`);
|
|
95
95
|
return { namedType: o, required: n, isList: i };
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function oe(t) {
|
|
98
98
|
const i = t.getFields().edges;
|
|
99
99
|
if (!i) return;
|
|
100
|
-
const { namedType: o, isList: r } =
|
|
101
|
-
if (!r || !
|
|
100
|
+
const { namedType: o, isList: r } = _(i.type);
|
|
101
|
+
if (!r || !k(o)) return;
|
|
102
102
|
const f = o.getFields().node;
|
|
103
103
|
if (!f) return;
|
|
104
|
-
const { namedType: g } =
|
|
105
|
-
if (
|
|
104
|
+
const { namedType: g } = _(f.type);
|
|
105
|
+
if (k(g))
|
|
106
106
|
return g.name;
|
|
107
107
|
}
|
|
108
|
-
function
|
|
109
|
-
const { namedType: r, required: p, isList: f } =
|
|
108
|
+
function ae(t, n, i, o = {}) {
|
|
109
|
+
const { namedType: r, required: p, isList: f } = _(n.type), g = Y(o.customScalars), a = {
|
|
110
110
|
kind: "field",
|
|
111
111
|
fieldname: t,
|
|
112
|
-
label:
|
|
112
|
+
label: G(t),
|
|
113
113
|
component: "ATextInput"
|
|
114
114
|
};
|
|
115
115
|
if (p && (a.required = !0), P(r)) {
|
|
116
|
-
if (
|
|
116
|
+
if (H.has(r.name))
|
|
117
117
|
return a._unmapped = !0, o.includeUnmappedMeta && (a._graphqlType = r.name), a;
|
|
118
118
|
if (r.name === "ID") {
|
|
119
|
-
const u =
|
|
119
|
+
const u = J(t);
|
|
120
120
|
if (i.has(u))
|
|
121
121
|
return a.component = "AFormLink", a.doctype = T(u), a;
|
|
122
122
|
}
|
|
123
123
|
const l = g[r.name];
|
|
124
124
|
return l ? a.component = l.component : (a._unmapped = !0, o.includeUnmappedMeta && (a._graphqlType = r.name)), a;
|
|
125
125
|
}
|
|
126
|
-
if (
|
|
126
|
+
if (K(r))
|
|
127
127
|
return a.component = "ADropdown", a.options = r.getValues().map((l) => l.name), a;
|
|
128
|
-
if (
|
|
128
|
+
if (k(r)) {
|
|
129
129
|
if (!f && i.has(r.name))
|
|
130
130
|
return a.component = "AFormLink", a.doctype = T(r.name), a;
|
|
131
|
-
const l =
|
|
131
|
+
const l = oe(r);
|
|
132
132
|
return l && i.has(l) ? (a.component = "ATable", a._isLink = !0, a.doctype = T(l), a.cardinality = "noneOrMany", a) : f && i.has(r.name) ? (a.component = "ATable", a._isLink = !0, a.doctype = T(r.name), a.cardinality = "noneOrMany", a) : (a._unmapped = !0, o.includeUnmappedMeta && (a._graphqlType = r.name), a);
|
|
133
133
|
}
|
|
134
134
|
return a._unmapped = !0, o.includeUnmappedMeta && (a._graphqlType = r.name), a;
|
|
135
135
|
}
|
|
136
|
-
const
|
|
136
|
+
const re = e.object({
|
|
137
137
|
/** The table view type */
|
|
138
138
|
view: e.enum(["list", "uncounted", "list-expansion", "tree", "gantt", "tree-gantt"]).optional(),
|
|
139
139
|
/** Allow the table to use the full width of its container */
|
|
@@ -145,7 +145,7 @@ const ae = e.object({
|
|
|
145
145
|
}).meta({
|
|
146
146
|
title: "TableViewConfig",
|
|
147
147
|
description: "JSON-safe view configuration for table fields in doctype authoring"
|
|
148
|
-
}),
|
|
148
|
+
}), se = e.union([
|
|
149
149
|
e.array(e.string()),
|
|
150
150
|
// Select choices: ["A", "B", "C"]
|
|
151
151
|
e.record(e.string(), e.unknown())
|
|
@@ -153,25 +153,25 @@ const ae = e.object({
|
|
|
153
153
|
]).meta({
|
|
154
154
|
title: "FieldOptions",
|
|
155
155
|
description: "Field options - flexible bag for type-specific configuration"
|
|
156
|
-
}),
|
|
156
|
+
}), ce = e.looseObject({
|
|
157
157
|
/** Error message to display when validation fails */
|
|
158
158
|
errorMessage: e.string()
|
|
159
159
|
}).meta({
|
|
160
160
|
title: "FieldValidation",
|
|
161
161
|
description: "Validation configuration for form fields"
|
|
162
162
|
});
|
|
163
|
-
function
|
|
163
|
+
function $(t) {
|
|
164
164
|
if (typeof t != "object" || t === null || Array.isArray(t)) return t;
|
|
165
165
|
const n = t;
|
|
166
166
|
return "kind" in n ? t : "schema" in n ? { kind: "fieldset", ...n } : "columns" in n ? { kind: "table", ...n } : { kind: "field", ...n };
|
|
167
167
|
}
|
|
168
|
-
function
|
|
169
|
-
const n =
|
|
168
|
+
function le(t) {
|
|
169
|
+
const n = $(t);
|
|
170
170
|
if (typeof n != "object" || n === null) return n;
|
|
171
171
|
const i = n;
|
|
172
|
-
return i.kind === "fieldset" && Array.isArray(i.schema) ? { ...i, schema: i.schema.map(
|
|
172
|
+
return i.kind === "fieldset" && Array.isArray(i.schema) ? { ...i, schema: i.schema.map(le) } : n;
|
|
173
173
|
}
|
|
174
|
-
const
|
|
174
|
+
const de = [
|
|
175
175
|
"fieldname",
|
|
176
176
|
"primaryKey",
|
|
177
177
|
"required",
|
|
@@ -179,11 +179,14 @@ const le = [
|
|
|
179
179
|
"cardinality",
|
|
180
180
|
"doctype"
|
|
181
181
|
];
|
|
182
|
-
function
|
|
182
|
+
function M(t) {
|
|
183
183
|
return t.find((n) => n.kind === "field" && !!n.primaryKey);
|
|
184
184
|
}
|
|
185
|
-
function ve(t
|
|
186
|
-
|
|
185
|
+
function ve(t) {
|
|
186
|
+
return M(t)?.fieldname ?? "id";
|
|
187
|
+
}
|
|
188
|
+
function $e(t, n) {
|
|
189
|
+
const i = M(t), o = i ? [n[i.fieldname], n.id] : [n.id];
|
|
187
190
|
for (const r of o) {
|
|
188
191
|
if (typeof r == "number") return String(r);
|
|
189
192
|
if (typeof r == "string" && r !== "") return r;
|
|
@@ -205,12 +208,12 @@ function pe() {
|
|
|
205
208
|
mask: e.string().optional(),
|
|
206
209
|
format: e.string().optional(),
|
|
207
210
|
mode: e.enum(["edit", "read", "display"]).optional(),
|
|
208
|
-
options:
|
|
211
|
+
options: se.optional(),
|
|
209
212
|
required: e.boolean().optional(),
|
|
210
213
|
readOnly: e.boolean().optional(),
|
|
211
214
|
hidden: e.boolean().optional(),
|
|
212
215
|
default: e.unknown().optional(),
|
|
213
|
-
validation:
|
|
216
|
+
validation: ce.optional(),
|
|
214
217
|
cardinality: e.enum(["atMostOne", "one", "noneOrMany", "atLeastOne"]).optional(),
|
|
215
218
|
source: e.literal("introspected").optional()
|
|
216
219
|
}).meta({ title: "ValueField" }), n = e.object({
|
|
@@ -220,7 +223,7 @@ function pe() {
|
|
|
220
223
|
label: e.string().optional(),
|
|
221
224
|
// Validates that each column has fieldname; allows all other ColumnSchema properties
|
|
222
225
|
columns: e.array(e.object({ fieldname: e.string().min(1) }).passthrough()),
|
|
223
|
-
config:
|
|
226
|
+
config: re.optional(),
|
|
224
227
|
mode: e.enum(["edit", "read", "display"]).optional()
|
|
225
228
|
}).meta({ title: "TableField" });
|
|
226
229
|
let i = e.never();
|
|
@@ -233,9 +236,9 @@ function pe() {
|
|
|
233
236
|
mode: e.enum(["edit", "read", "display"]).optional(),
|
|
234
237
|
schema: e.lazy(() => i.array())
|
|
235
238
|
}).meta({ title: "FieldsetField" }), r = e.discriminatedUnion("kind", [t, o, n]);
|
|
236
|
-
return i = e.preprocess(
|
|
239
|
+
return i = e.preprocess($, r), { ValueFieldSchema: t, TableFieldSchema: n, FieldsetFieldSchema: o, DoctypeFieldSchema: i };
|
|
237
240
|
}
|
|
238
|
-
const
|
|
241
|
+
const D = pe(), Me = D.ValueFieldSchema, qe = D.FieldsetFieldSchema, Ee = D.TableFieldSchema, O = D.DoctypeFieldSchema;
|
|
239
242
|
function L(t) {
|
|
240
243
|
const n = [];
|
|
241
244
|
for (const i of t)
|
|
@@ -245,10 +248,10 @@ function L(t) {
|
|
|
245
248
|
function j(t) {
|
|
246
249
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
247
250
|
}
|
|
248
|
-
function
|
|
251
|
+
function A(t) {
|
|
249
252
|
return t === void 0 ? "—" : JSON.stringify(t);
|
|
250
253
|
}
|
|
251
|
-
function
|
|
254
|
+
function xe(t, n) {
|
|
252
255
|
const i = Array.isArray(t.fields) ? t.fields.filter(j) : [], o = new Map(n.fields.map((s) => [s.fieldname, s])), r = new Set(Object.keys(n.links ?? {})), p = {
|
|
253
256
|
doctype: typeof t.name == "string" ? t.name : "(unnamed)",
|
|
254
257
|
mode: "clean",
|
|
@@ -264,11 +267,11 @@ function Ee(t, n) {
|
|
|
264
267
|
const y = typeof s.fieldname == "string" ? s.fieldname : "", d = o.get(y);
|
|
265
268
|
if (!d)
|
|
266
269
|
return s.computed !== !0 && !r.has(y) && p.orphan.push(y), s;
|
|
267
|
-
p.tagged.push(y), d.component !== s.component && p.componentDrift.push(`${y}: authored=${
|
|
268
|
-
for (const m of
|
|
270
|
+
p.tagged.push(y), d.component !== s.component && p.componentDrift.push(`${y}: authored=${A(s.component)} schema=${A(d.component)}`), !!d.required != !!s.required && p.requiredDrift.push(`${y}: authored=${!!s.required} schema=${!!d.required}`);
|
|
271
|
+
for (const m of de) {
|
|
269
272
|
if (m === "fieldname" || m === "required") continue;
|
|
270
|
-
const h = s[m],
|
|
271
|
-
h === void 0 &&
|
|
273
|
+
const h = s[m], F = d[m];
|
|
274
|
+
h === void 0 && F === void 0 || JSON.stringify(h) !== JSON.stringify(F) && p.identityDrift.push(`${y}.${m}: authored=${A(h)} schema=${A(F)}`);
|
|
272
275
|
}
|
|
273
276
|
return { ...s, source: "introspected" };
|
|
274
277
|
}, g = { ...t, fields: i.map(f) }, a = new Set(L(i).map((s) => s.fieldname));
|
|
@@ -276,7 +279,7 @@ function Ee(t, n) {
|
|
|
276
279
|
const l = L(i).find((s) => s.primaryKey === !0), u = n.fields.find((s) => s.primaryKey === !0);
|
|
277
280
|
return l && u && l.fieldname !== u.fieldname ? (p.mode = "partial", p.reason = `authored primary key '${String(l.fieldname)}' is not the derivable '${u.fieldname}' — left as authored`) : l && !u ? (p.mode = "partial", p.reason = `authored primary key '${String(l.fieldname)}' is not derivable from the schema — left as authored`) : !l && u && (p.mode = "partial", p.reason = `schema suggests '${u.fieldname}' as primary key but the doctype declares none — not applied`), { doctype: g, drift: p };
|
|
278
281
|
}
|
|
279
|
-
function
|
|
282
|
+
function Re(t) {
|
|
280
283
|
const n = [];
|
|
281
284
|
t.reason && n.push(` ${t.doctype}: ${t.reason}`);
|
|
282
285
|
const i = (o, r) => {
|
|
@@ -287,9 +290,9 @@ function xe(t) {
|
|
|
287
290
|
function Ue(t, n = {}) {
|
|
288
291
|
const i = me(t), o = i.getTypeMap(), r = /* @__PURE__ */ new Set(), p = i.getQueryType(), f = i.getMutationType(), g = i.getSubscriptionType();
|
|
289
292
|
p && r.add(p.name), f && r.add(f.name), g && r.add(g.name);
|
|
290
|
-
const a = n.isEntityType ??
|
|
293
|
+
const a = n.isEntityType ?? te, l = /* @__PURE__ */ new Set();
|
|
291
294
|
for (const [d, m] of Object.entries(o))
|
|
292
|
-
|
|
295
|
+
k(m) && (r.has(d) || a(d, m) && l.add(d));
|
|
293
296
|
let u = l;
|
|
294
297
|
if (n.include) {
|
|
295
298
|
const d = new Set(n.include);
|
|
@@ -299,53 +302,53 @@ function Ue(t, n = {}) {
|
|
|
299
302
|
const d = new Set(n.exclude);
|
|
300
303
|
u = new Set([...u].filter((m) => !d.has(m)));
|
|
301
304
|
}
|
|
302
|
-
const s = n.isEntityField ??
|
|
305
|
+
const s = n.isEntityField ?? ie, y = [];
|
|
303
306
|
for (const d of u) {
|
|
304
307
|
const m = o[d];
|
|
305
|
-
if (!
|
|
306
|
-
const h = m.getFields(),
|
|
307
|
-
|
|
308
|
+
if (!k(m)) continue;
|
|
309
|
+
const h = m.getFields(), F = "id" in h && "rowId" in h;
|
|
310
|
+
F && n.onWarning?.(
|
|
308
311
|
`${d}: schema exposes both 'id' (Relay identifier) and 'rowId' (the real column). Skipping 'id' and emitting 'rowId' verbatim — no primary key can be derived. Override the '_attributeName' and 'nodeIdFieldName' inflectors so the column keeps its own name.`
|
|
309
312
|
);
|
|
310
313
|
const C = Object.entries(h).filter(
|
|
311
|
-
([c, b]) => s(c, b, m) && !(
|
|
314
|
+
([c, b]) => s(c, b, m) && !(F && c === "id")
|
|
312
315
|
).map(([c, b]) => {
|
|
313
316
|
if (n.classifyField) {
|
|
314
|
-
const
|
|
315
|
-
if (
|
|
317
|
+
const S = n.classifyField(c, b, m);
|
|
318
|
+
if (S != null)
|
|
316
319
|
return {
|
|
317
320
|
kind: "field",
|
|
318
321
|
fieldname: c,
|
|
319
|
-
label:
|
|
320
|
-
component:
|
|
321
|
-
...
|
|
322
|
+
label: S.label ?? c,
|
|
323
|
+
component: S.component ?? "ATextInput",
|
|
324
|
+
...S
|
|
322
325
|
};
|
|
323
326
|
}
|
|
324
|
-
return
|
|
325
|
-
}),
|
|
327
|
+
return ae(c, b, l, n);
|
|
328
|
+
}), E = C.find(
|
|
326
329
|
(c) => c.fieldname === "id" && c.required && !c.doctype && !c._isLink
|
|
327
|
-
)?.fieldname,
|
|
330
|
+
)?.fieldname, w = {}, x = C.filter((c) => c._isLink && c.doctype && c.cardinality ? (w[c.fieldname] = {
|
|
328
331
|
target: c.doctype,
|
|
329
332
|
cardinality: c.cardinality
|
|
330
333
|
}, !1) : !0).map((c) => {
|
|
331
|
-
const b = c.fieldname ===
|
|
334
|
+
const b = c.fieldname === E ? { primaryKey: !0 } : {};
|
|
332
335
|
if (!n.includeUnmappedMeta) {
|
|
333
|
-
const { _graphqlType:
|
|
336
|
+
const { _graphqlType: De, _unmapped: we, _isLink: Ie, ...U } = c;
|
|
334
337
|
return Object.assign(U, b, { source: "introspected" });
|
|
335
338
|
}
|
|
336
|
-
const { _isLink:
|
|
337
|
-
return Object.assign(
|
|
338
|
-
}), N = n.doctypeNames?.[d] ?? d,
|
|
339
|
+
const { _isLink: S, ...R } = c;
|
|
340
|
+
return Object.assign(R, b, { source: "introspected" });
|
|
341
|
+
}), N = n.doctypeNames?.[d] ?? d, I = {
|
|
339
342
|
name: N,
|
|
340
343
|
slug: T(N),
|
|
341
|
-
fields:
|
|
344
|
+
fields: x
|
|
342
345
|
};
|
|
343
|
-
Object.keys(
|
|
346
|
+
Object.keys(w).length > 0 && (I.links = w), n.includeUnmappedMeta && (I._graphqlTypeName = d), y.push(I);
|
|
344
347
|
}
|
|
345
348
|
return y;
|
|
346
349
|
}
|
|
347
350
|
function me(t) {
|
|
348
|
-
return typeof t == "string" ? B(t) :
|
|
351
|
+
return typeof t == "string" ? B(t) : W(t);
|
|
349
352
|
}
|
|
350
353
|
const ue = e.enum(["atMostOne", "one", "noneOrMany", "atLeastOne"]).meta({
|
|
351
354
|
title: "Cardinality",
|
|
@@ -393,7 +396,7 @@ const ue = e.enum(["atMostOne", "one", "noneOrMany", "atLeastOne"]).meta({
|
|
|
393
396
|
}).meta({
|
|
394
397
|
title: "LinkDeclaration",
|
|
395
398
|
description: "Declares a relationship from one doctype to another"
|
|
396
|
-
}),
|
|
399
|
+
}), Fe = e.object({
|
|
397
400
|
/** Display label for the action */
|
|
398
401
|
label: e.string().min(1),
|
|
399
402
|
/** Fields that must have values before action can execute */
|
|
@@ -417,7 +420,7 @@ const ue = e.enum(["atMostOne", "one", "noneOrMany", "atLeastOne"]).meta({
|
|
|
417
420
|
}).meta({
|
|
418
421
|
title: "ActionDefinition",
|
|
419
422
|
description: "Action definition within a workflow"
|
|
420
|
-
}),
|
|
423
|
+
}), Se = e.object({
|
|
421
424
|
/** Optional display label; the map key is the trigger's identity */
|
|
422
425
|
label: e.string().optional(),
|
|
423
426
|
/** Fieldnames whose edits fire this trigger (fires when any listed field changes) */
|
|
@@ -439,13 +442,13 @@ const Te = e.record(
|
|
|
439
442
|
targetPosition: e.enum(["left", "top", "right", "bottom"]).optional(),
|
|
440
443
|
sourcePosition: e.enum(["left", "top", "right", "bottom"]).optional()
|
|
441
444
|
})
|
|
442
|
-
),
|
|
445
|
+
), ke = e.object({
|
|
443
446
|
/** List of workflow states */
|
|
444
447
|
states: e.array(e.string()).optional(),
|
|
445
448
|
/** Actions available in this workflow */
|
|
446
|
-
actions: e.record(e.string(),
|
|
449
|
+
actions: e.record(e.string(), Fe).optional(),
|
|
447
450
|
/** Reactive field-validation triggers (advisory, client-side), keyed by trigger name */
|
|
448
|
-
triggers: e.record(e.string(),
|
|
451
|
+
triggers: e.record(e.string(), Se).optional(),
|
|
449
452
|
/**
|
|
450
453
|
* DocBuilder node positions keyed by state name — authoring view-state. Persisted here so a
|
|
451
454
|
* doctype author's manual graph arrangement survives reloads; like `triggers`, it is client-only
|
|
@@ -455,7 +458,7 @@ const Te = e.record(
|
|
|
455
458
|
}).meta({
|
|
456
459
|
title: "WorkflowMeta",
|
|
457
460
|
description: "Workflow metadata - states and actions for a doctype"
|
|
458
|
-
}),
|
|
461
|
+
}), q = e.object({
|
|
459
462
|
/** Display name of the doctype */
|
|
460
463
|
name: e.string().min(1),
|
|
461
464
|
/** URL-friendly slug (kebab-case) */
|
|
@@ -465,14 +468,23 @@ const Te = e.record(
|
|
|
465
468
|
/** Relationship links to other doctypes */
|
|
466
469
|
links: e.record(e.string(), be).optional(),
|
|
467
470
|
/** Workflow configuration */
|
|
468
|
-
workflow:
|
|
471
|
+
workflow: ke.optional(),
|
|
469
472
|
/** Parent doctype for inheritance */
|
|
470
473
|
inherits: e.string().optional()
|
|
471
474
|
}).meta({
|
|
472
475
|
title: "DoctypeMeta",
|
|
473
476
|
description: "Doctype metadata - complete definition of a doctype"
|
|
477
|
+
}).superRefine((t, n) => {
|
|
478
|
+
const i = t.fields.filter((o) => o.kind === "field" && o.primaryKey);
|
|
479
|
+
i.length > 1 && n.addIssue({
|
|
480
|
+
code: "custom",
|
|
481
|
+
path: ["fields"],
|
|
482
|
+
message: `Doctype declares ${i.length} primaryKey fields (${i.map((o) => o.kind === "field" ? o.fieldname : "").join(
|
|
483
|
+
", "
|
|
484
|
+
)}); a record is identified by exactly one field. A composite database key is mapped to a single identity by the adapter, so a doctype never declares its parts`
|
|
485
|
+
});
|
|
474
486
|
});
|
|
475
|
-
function
|
|
487
|
+
function Ke(t) {
|
|
476
488
|
const n = O.safeParse(t);
|
|
477
489
|
return n.success ? { success: !0, errors: [] } : {
|
|
478
490
|
success: !1,
|
|
@@ -483,7 +495,7 @@ function Re(t) {
|
|
|
483
495
|
};
|
|
484
496
|
}
|
|
485
497
|
function Ve(t) {
|
|
486
|
-
const n =
|
|
498
|
+
const n = q.safeParse(t);
|
|
487
499
|
return n.success ? { success: !0, errors: [] } : {
|
|
488
500
|
success: !1,
|
|
489
501
|
errors: n.error.issues.map((i) => ({
|
|
@@ -496,43 +508,44 @@ function ze(t) {
|
|
|
496
508
|
return O.parse(t);
|
|
497
509
|
}
|
|
498
510
|
function Be(t) {
|
|
499
|
-
return
|
|
511
|
+
return q.parse(t);
|
|
500
512
|
}
|
|
501
513
|
export {
|
|
502
|
-
|
|
503
|
-
|
|
514
|
+
Fe as A,
|
|
515
|
+
T as B,
|
|
516
|
+
Ke as C,
|
|
504
517
|
O as D,
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
518
|
+
qe as F,
|
|
519
|
+
Q as G,
|
|
520
|
+
H as I,
|
|
521
|
+
Ee as T,
|
|
509
522
|
Me as V,
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
523
|
+
Z as W,
|
|
524
|
+
de as a,
|
|
525
|
+
re as b,
|
|
513
526
|
Ue as c,
|
|
514
|
-
|
|
527
|
+
Se as d,
|
|
515
528
|
Te as e,
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
529
|
+
Re as f,
|
|
530
|
+
ke as g,
|
|
531
|
+
Y as h,
|
|
532
|
+
G as i,
|
|
520
533
|
Oe as j,
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
534
|
+
ae as k,
|
|
535
|
+
ie as l,
|
|
536
|
+
xe as m,
|
|
537
|
+
te as n,
|
|
538
|
+
M as o,
|
|
526
539
|
ve as p,
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
540
|
+
$e as q,
|
|
541
|
+
Pe as r,
|
|
542
|
+
le as s,
|
|
543
|
+
Be as t,
|
|
544
|
+
ze as u,
|
|
532
545
|
Ve as v,
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
546
|
+
Ne as w,
|
|
547
|
+
je as x,
|
|
548
|
+
Ce as y,
|
|
549
|
+
J as z
|
|
537
550
|
};
|
|
538
|
-
//# sourceMappingURL=validation-
|
|
551
|
+
//# sourceMappingURL=validation-C25HJXWs.js.map
|