@stonecrop/schema 0.16.4 → 0.16.5
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 +23 -9
- package/dist/cli.js +74 -53
- package/dist/cli.js.map +1 -1
- package/dist/index.js +34 -29
- package/dist/schema.d.ts +142 -8
- package/dist/src/cli.js +49 -15
- package/dist/src/converter/index.d.ts +2 -0
- package/dist/src/converter/index.d.ts.map +1 -1
- package/dist/src/converter/index.js +30 -16
- package/dist/src/converter/merge.d.ts +87 -0
- package/dist/src/converter/merge.d.ts.map +1 -0
- package/dist/src/converter/merge.js +145 -0
- package/dist/src/converter/types.d.ts +17 -8
- package/dist/src/converter/types.d.ts.map +1 -1
- package/dist/src/field.d.ts +47 -0
- package/dist/src/field.d.ts.map +1 -1
- package/dist/src/field.js +67 -0
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -2
- package/dist/validation-CToUOy0a.js +538 -0
- package/dist/validation-CToUOy0a.js.map +1 -0
- package/package.json +1 -1
- package/dist/validation-Dyxjvaio.js +0 -458
- package/dist/validation-Dyxjvaio.js.map +0 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ export type { InteractionMode } from './mode';
|
|
|
2
2
|
export { TableViewConfig } from './table';
|
|
3
3
|
export { CANONICAL_COMPONENTS, COMPONENT_CATEGORY, COMPONENT_LINK_EXPANSION, componentCategory, componentLinkExpansion, resolveLinkRenderMode, type ComponentCategory, type LinkExpansion, type LinkRenderMode, } from './component-meta';
|
|
4
4
|
export type { DoctypeField, FieldOptions, FieldValidation, FieldsetField, TableField, ValueField } from './field';
|
|
5
|
-
export { DoctypeFieldSchema, FieldsetFieldSchema, normalizeFieldKind, TableFieldSchema, ValueFieldSchema, } from './field';
|
|
5
|
+
export { DoctypeFieldSchema, FieldsetFieldSchema, getPrimaryKeyField, getRecordIdentity, INTROSPECTED_IDENTITY_PROPS, normalizeFieldKind, TableFieldSchema, ValueFieldSchema, } from './field';
|
|
6
6
|
export { ActionDefinition, TriggerDefinition, WorkflowLayout, WorkflowMeta, isActionAllowedInState } from './doctype';
|
|
7
7
|
export type { Cardinality, CustomFetch, DataClient, DoctypeContext, DoctypeMeta, DoctypeRef, FetchStrategy, GetRecordOptions, GetRecordResult, GetRecordsOptions, LazyFetch, LinkDeclaration, SerializedFunction, SyncFetch, } from './doctype';
|
|
8
8
|
export { parseDoctype, parseField, validateDoctype, validateField, type ValidationError, type ValidationResult, } from './validation';
|
|
9
|
-
export { buildScalarMap, classifyFieldType, convertGraphQLSchema, defaultIsEntityField, defaultIsEntityType, GQL_SCALAR_MAP, INTERNAL_SCALARS, WELL_KNOWN_SCALARS, type ConvertedGraphQLDoctype, type GraphQLConversionFieldMeta, type GraphQLConversionOptions, type IntrospectionSource, } from './converter';
|
|
9
|
+
export { buildScalarMap, classifyFieldType, convertGraphQLSchema, defaultIsEntityField, defaultIsEntityType, formatDoctypeDrift, GQL_SCALAR_MAP, INTERNAL_SCALARS, mergeIntrospectedDoctype, WELL_KNOWN_SCALARS, type AuthoredDoctype, type ConvertedGraphQLDoctype, type DoctypeDrift, type GraphQLConversionFieldMeta, type GraphQLConversionOptions, type IntrospectionSource, type MergeResult, } from './converter';
|
|
10
10
|
export { toSlug, toPascalCase, pascalToSnake, snakeToCamel, camelToSnake, snakeToLabel, camelToLabel } from './naming';
|
|
11
11
|
export type { ColumnSchema } from './column-schema';
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAG7C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGzC,OAAO,EACN,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,cAAc,GACnB,MAAM,kBAAkB,CAAA;AAGzB,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACjH,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,SAAS,CAAA;AAKhB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AACrH,YAAY,EACX,WAAW,EACX,WAAW,EACX,UAAU,EACV,cAAc,EACd,WAAW,EACX,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,SAAS,GACT,MAAM,WAAW,CAAA;AAGlB,OAAO,EACN,YAAY,EACZ,UAAU,EACV,eAAe,EACf,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACrB,MAAM,cAAc,CAAA;AAGrB,OAAO,EACN,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAG7C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGzC,OAAO,EACN,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,cAAc,GACnB,MAAM,kBAAkB,CAAA;AAGzB,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACjH,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,2BAA2B,EAC3B,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,SAAS,CAAA;AAKhB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AACrH,YAAY,EACX,WAAW,EACX,WAAW,EACX,UAAU,EACV,cAAc,EACd,WAAW,EACX,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,SAAS,GACT,MAAM,WAAW,CAAA;AAGlB,OAAO,EACN,YAAY,EACZ,UAAU,EACV,eAAe,EACf,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACrB,MAAM,cAAc,CAAA;AAGrB,OAAO,EACN,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,wBAAwB,EACxB,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,WAAW,GAChB,MAAM,aAAa,CAAA;AAGpB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGtH,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA"}
|
package/dist/src/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export { TableViewConfig } from './table';
|
|
3
3
|
// Component → semantic category — the single source of "what kind of value does this component render"
|
|
4
4
|
export { CANONICAL_COMPONENTS, COMPONENT_CATEGORY, COMPONENT_LINK_EXPANSION, componentCategory, componentLinkExpansion, resolveLinkRenderMode, } from './component-meta';
|
|
5
|
-
export { DoctypeFieldSchema, FieldsetFieldSchema, normalizeFieldKind, TableFieldSchema, ValueFieldSchema, } from './field';
|
|
5
|
+
export { DoctypeFieldSchema, FieldsetFieldSchema, getPrimaryKeyField, getRecordIdentity, INTROSPECTED_IDENTITY_PROPS, normalizeFieldKind, TableFieldSchema, ValueFieldSchema, } from './field';
|
|
6
6
|
// Doctype schema
|
|
7
7
|
// ActionDefinition and WorkflowMeta are exported as values (Zod schemas) so consumers can use
|
|
8
8
|
// .safeParse(), .shape, etc. at runtime. TypeScript types are inferred from the same exports.
|
|
@@ -10,6 +10,6 @@ export { ActionDefinition, TriggerDefinition, WorkflowLayout, WorkflowMeta, isAc
|
|
|
10
10
|
// Validation helpers
|
|
11
11
|
export { parseDoctype, parseField, validateDoctype, validateField, } from './validation';
|
|
12
12
|
// GraphQL to Doctype conversion
|
|
13
|
-
export { buildScalarMap, classifyFieldType, convertGraphQLSchema, defaultIsEntityField, defaultIsEntityType, GQL_SCALAR_MAP, INTERNAL_SCALARS, WELL_KNOWN_SCALARS, } from './converter';
|
|
13
|
+
export { buildScalarMap, classifyFieldType, convertGraphQLSchema, defaultIsEntityField, defaultIsEntityType, formatDoctypeDrift, GQL_SCALAR_MAP, INTERNAL_SCALARS, mergeIntrospectedDoctype, WELL_KNOWN_SCALARS, } from './converter';
|
|
14
14
|
// Naming utilities
|
|
15
15
|
export { toSlug, toPascalCase, pascalToSnake, snakeToCamel, camelToSnake, snakeToLabel, camelToLabel } from './naming';
|
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
import { isScalarType as P, isEnumType as R, isObjectType as A, isNonNullType as v, isListType as V, isNamedType as z, buildSchema as B, buildClientSchema as K } from "graphql";
|
|
2
|
+
import { z as e } from "zod";
|
|
3
|
+
function je(t) {
|
|
4
|
+
return t.replace(/_([a-z])/g, (n, i) => i.toUpperCase());
|
|
5
|
+
}
|
|
6
|
+
function Oe(t) {
|
|
7
|
+
return t.replace(/[A-Z]/g, (n) => `_${n.toLowerCase()}`);
|
|
8
|
+
}
|
|
9
|
+
function Ce(t) {
|
|
10
|
+
return t.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join(" ");
|
|
11
|
+
}
|
|
12
|
+
function W(t) {
|
|
13
|
+
const n = t.replace(/([A-Z])/g, " $1").trim();
|
|
14
|
+
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
15
|
+
}
|
|
16
|
+
function G(t) {
|
|
17
|
+
return t.split(/[-_\s]+/).map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join("");
|
|
18
|
+
}
|
|
19
|
+
function T(t) {
|
|
20
|
+
return t.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
21
|
+
}
|
|
22
|
+
function Ne(t) {
|
|
23
|
+
return t.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase();
|
|
24
|
+
}
|
|
25
|
+
const J = {
|
|
26
|
+
String: { component: "ATextInput" },
|
|
27
|
+
Int: { component: "ANumericInput" },
|
|
28
|
+
Float: { component: "ANumericInput" },
|
|
29
|
+
Boolean: { component: "ACheckbox" },
|
|
30
|
+
ID: { component: "ATextInput" }
|
|
31
|
+
}, Q = {
|
|
32
|
+
// Arbitrary precision / large numbers — all numeric variants render with ANumericInput.
|
|
33
|
+
BigFloat: { component: "ANumericInput" },
|
|
34
|
+
BigDecimal: { component: "ANumericInput" },
|
|
35
|
+
Decimal: { component: "ANumericInput" },
|
|
36
|
+
BigInt: { component: "ANumericInput" },
|
|
37
|
+
Long: { component: "ANumericInput" },
|
|
38
|
+
// Identifiers
|
|
39
|
+
UUID: { component: "ATextInput" },
|
|
40
|
+
// Date / Time — no dedicated Time SFC exists; Time falls back to a plain text input.
|
|
41
|
+
DateTime: { component: "ADateTime" },
|
|
42
|
+
Datetime: { component: "ADateTime" },
|
|
43
|
+
Date: { component: "ADate" },
|
|
44
|
+
Time: { component: "ATextInput" },
|
|
45
|
+
Interval: { component: "ADuration" },
|
|
46
|
+
Duration: { component: "ADuration" },
|
|
47
|
+
// Structured data
|
|
48
|
+
JSON: { component: "ACodeEditor" },
|
|
49
|
+
JSONObject: { component: "ACodeEditor" },
|
|
50
|
+
JsonNode: { component: "ACodeEditor" }
|
|
51
|
+
}, Z = /* @__PURE__ */ new Set(["Cursor"]);
|
|
52
|
+
function H(t) {
|
|
53
|
+
const n = { ...Q };
|
|
54
|
+
for (const [i, o] of Object.entries(J))
|
|
55
|
+
n[i] = o;
|
|
56
|
+
if (t)
|
|
57
|
+
for (const [i, o] of Object.entries(t))
|
|
58
|
+
n[i] = { component: o.component ?? "ATextInput" };
|
|
59
|
+
return n;
|
|
60
|
+
}
|
|
61
|
+
const Y = [
|
|
62
|
+
"Connection",
|
|
63
|
+
"Edge",
|
|
64
|
+
"Input",
|
|
65
|
+
"Patch",
|
|
66
|
+
"Payload",
|
|
67
|
+
"Condition",
|
|
68
|
+
"Filter",
|
|
69
|
+
"OrderBy",
|
|
70
|
+
"Aggregate",
|
|
71
|
+
"AggregateResult",
|
|
72
|
+
"AggregateFilter",
|
|
73
|
+
"DeleteResponse",
|
|
74
|
+
"InsertResponse",
|
|
75
|
+
"UpdateResponse",
|
|
76
|
+
"MutationResponse"
|
|
77
|
+
], X = /* @__PURE__ */ new Set(["Query", "Mutation", "Subscription"]);
|
|
78
|
+
function ee(t, n) {
|
|
79
|
+
if (t.startsWith("__") || X.has(t) || t === "Node")
|
|
80
|
+
return !1;
|
|
81
|
+
for (const o of Y)
|
|
82
|
+
if (t.endsWith(o))
|
|
83
|
+
return !1;
|
|
84
|
+
const i = n.getFields();
|
|
85
|
+
return Object.keys(i).length !== 0;
|
|
86
|
+
}
|
|
87
|
+
const te = /* @__PURE__ */ new Set(["nodeId", "__typename", "clientMutationId"]);
|
|
88
|
+
function ne(t, n, i) {
|
|
89
|
+
return !te.has(t);
|
|
90
|
+
}
|
|
91
|
+
function I(t) {
|
|
92
|
+
let n = !1, i = !1, o = t;
|
|
93
|
+
if (v(o) && (n = !0, o = o.ofType), V(o) && (i = !0, o = o.ofType, v(o) && (o = o.ofType)), !z(o))
|
|
94
|
+
throw new Error(`Expected a named GraphQL type, got: ${String(o)}`);
|
|
95
|
+
return { namedType: o, required: n, isList: i };
|
|
96
|
+
}
|
|
97
|
+
function ie(t) {
|
|
98
|
+
const i = t.getFields().edges;
|
|
99
|
+
if (!i) return;
|
|
100
|
+
const { namedType: o, isList: r } = I(i.type);
|
|
101
|
+
if (!r || !A(o)) return;
|
|
102
|
+
const f = o.getFields().node;
|
|
103
|
+
if (!f) return;
|
|
104
|
+
const { namedType: g } = I(f.type);
|
|
105
|
+
if (A(g))
|
|
106
|
+
return g.name;
|
|
107
|
+
}
|
|
108
|
+
function oe(t, n, i, o = {}) {
|
|
109
|
+
const { namedType: r, required: p, isList: f } = I(n.type), g = H(o.customScalars), a = {
|
|
110
|
+
kind: "field",
|
|
111
|
+
fieldname: t,
|
|
112
|
+
label: W(t),
|
|
113
|
+
component: "ATextInput"
|
|
114
|
+
};
|
|
115
|
+
if (p && (a.required = !0), P(r)) {
|
|
116
|
+
if (Z.has(r.name))
|
|
117
|
+
return a._unmapped = !0, o.includeUnmappedMeta && (a._graphqlType = r.name), a;
|
|
118
|
+
if (r.name === "ID") {
|
|
119
|
+
const u = G(t);
|
|
120
|
+
if (i.has(u))
|
|
121
|
+
return a.component = "AFormLink", a.doctype = T(u), a;
|
|
122
|
+
}
|
|
123
|
+
const l = g[r.name];
|
|
124
|
+
return l ? a.component = l.component : (a._unmapped = !0, o.includeUnmappedMeta && (a._graphqlType = r.name)), a;
|
|
125
|
+
}
|
|
126
|
+
if (R(r))
|
|
127
|
+
return a.component = "ADropdown", a.options = r.getValues().map((l) => l.name), a;
|
|
128
|
+
if (A(r)) {
|
|
129
|
+
if (!f && i.has(r.name))
|
|
130
|
+
return a.component = "AFormLink", a.doctype = T(r.name), a;
|
|
131
|
+
const l = ie(r);
|
|
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
|
+
}
|
|
134
|
+
return a._unmapped = !0, o.includeUnmappedMeta && (a._graphqlType = r.name), a;
|
|
135
|
+
}
|
|
136
|
+
const ae = e.object({
|
|
137
|
+
/** The table view type */
|
|
138
|
+
view: e.enum(["list", "uncounted", "list-expansion", "tree", "gantt", "tree-gantt"]).optional(),
|
|
139
|
+
/** Allow the table to use the full width of its container */
|
|
140
|
+
fullWidth: e.boolean().optional(),
|
|
141
|
+
/** Default expansion state for tree views */
|
|
142
|
+
defaultTreeExpansion: e.enum(["root", "branch", "leaf"]).optional(),
|
|
143
|
+
/** Enable dependency graph connections for Gantt views */
|
|
144
|
+
dependencyGraph: e.boolean().optional()
|
|
145
|
+
}).meta({
|
|
146
|
+
title: "TableViewConfig",
|
|
147
|
+
description: "JSON-safe view configuration for table fields in doctype authoring"
|
|
148
|
+
}), re = e.union([
|
|
149
|
+
e.array(e.string()),
|
|
150
|
+
// Select choices: ["A", "B", "C"]
|
|
151
|
+
e.record(e.string(), e.unknown())
|
|
152
|
+
// Config: \{ precision: 10, scale: 2 \}
|
|
153
|
+
]).meta({
|
|
154
|
+
title: "FieldOptions",
|
|
155
|
+
description: "Field options - flexible bag for type-specific configuration"
|
|
156
|
+
}), se = e.looseObject({
|
|
157
|
+
/** Error message to display when validation fails */
|
|
158
|
+
errorMessage: e.string()
|
|
159
|
+
}).meta({
|
|
160
|
+
title: "FieldValidation",
|
|
161
|
+
description: "Validation configuration for form fields"
|
|
162
|
+
});
|
|
163
|
+
function M(t) {
|
|
164
|
+
if (typeof t != "object" || t === null || Array.isArray(t)) return t;
|
|
165
|
+
const n = t;
|
|
166
|
+
return "kind" in n ? t : "schema" in n ? { kind: "fieldset", ...n } : "columns" in n ? { kind: "table", ...n } : { kind: "field", ...n };
|
|
167
|
+
}
|
|
168
|
+
function ce(t) {
|
|
169
|
+
const n = M(t);
|
|
170
|
+
if (typeof n != "object" || n === null) return n;
|
|
171
|
+
const i = n;
|
|
172
|
+
return i.kind === "fieldset" && Array.isArray(i.schema) ? { ...i, schema: i.schema.map(ce) } : n;
|
|
173
|
+
}
|
|
174
|
+
const le = [
|
|
175
|
+
"fieldname",
|
|
176
|
+
"primaryKey",
|
|
177
|
+
"required",
|
|
178
|
+
"options",
|
|
179
|
+
"cardinality",
|
|
180
|
+
"doctype"
|
|
181
|
+
];
|
|
182
|
+
function de(t) {
|
|
183
|
+
return t.find((n) => n.kind === "field" && !!n.primaryKey);
|
|
184
|
+
}
|
|
185
|
+
function ve(t, n) {
|
|
186
|
+
const i = de(t), o = i ? [n[i.fieldname], n.id] : [n.id];
|
|
187
|
+
for (const r of o) {
|
|
188
|
+
if (typeof r == "number") return String(r);
|
|
189
|
+
if (typeof r == "string" && r !== "") return r;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function pe() {
|
|
193
|
+
const t = e.object({
|
|
194
|
+
kind: e.literal("field"),
|
|
195
|
+
fieldname: e.string().min(1),
|
|
196
|
+
component: e.string().min(1),
|
|
197
|
+
primaryKey: e.boolean().optional(),
|
|
198
|
+
computed: e.boolean().optional(),
|
|
199
|
+
language: e.string().optional(),
|
|
200
|
+
doctype: e.string().min(1).optional(),
|
|
201
|
+
label: e.string().optional(),
|
|
202
|
+
width: e.string().optional(),
|
|
203
|
+
align: e.enum(["left", "center", "right", "start", "end"]).optional(),
|
|
204
|
+
edit: e.boolean().optional(),
|
|
205
|
+
mask: e.string().optional(),
|
|
206
|
+
format: e.string().optional(),
|
|
207
|
+
mode: e.enum(["edit", "read", "display"]).optional(),
|
|
208
|
+
options: re.optional(),
|
|
209
|
+
required: e.boolean().optional(),
|
|
210
|
+
readOnly: e.boolean().optional(),
|
|
211
|
+
hidden: e.boolean().optional(),
|
|
212
|
+
default: e.unknown().optional(),
|
|
213
|
+
validation: se.optional(),
|
|
214
|
+
cardinality: e.enum(["atMostOne", "one", "noneOrMany", "atLeastOne"]).optional(),
|
|
215
|
+
source: e.literal("introspected").optional()
|
|
216
|
+
}).meta({ title: "ValueField" }), n = e.object({
|
|
217
|
+
kind: e.literal("table"),
|
|
218
|
+
fieldname: e.string().min(1),
|
|
219
|
+
component: e.string().optional(),
|
|
220
|
+
label: e.string().optional(),
|
|
221
|
+
// Validates that each column has fieldname; allows all other ColumnSchema properties
|
|
222
|
+
columns: e.array(e.object({ fieldname: e.string().min(1) }).passthrough()),
|
|
223
|
+
config: ae.optional(),
|
|
224
|
+
mode: e.enum(["edit", "read", "display"]).optional()
|
|
225
|
+
}).meta({ title: "TableField" });
|
|
226
|
+
let i = e.never();
|
|
227
|
+
const o = e.object({
|
|
228
|
+
kind: e.literal("fieldset"),
|
|
229
|
+
fieldname: e.string().min(1),
|
|
230
|
+
component: e.string().optional(),
|
|
231
|
+
label: e.string().optional(),
|
|
232
|
+
collapsible: e.boolean().optional(),
|
|
233
|
+
mode: e.enum(["edit", "read", "display"]).optional(),
|
|
234
|
+
schema: e.lazy(() => i.array())
|
|
235
|
+
}).meta({ title: "FieldsetField" }), r = e.discriminatedUnion("kind", [t, o, n]);
|
|
236
|
+
return i = e.preprocess(M, r), { ValueFieldSchema: t, TableFieldSchema: n, FieldsetFieldSchema: o, DoctypeFieldSchema: i };
|
|
237
|
+
}
|
|
238
|
+
const w = pe(), Me = w.ValueFieldSchema, $e = w.FieldsetFieldSchema, qe = w.TableFieldSchema, O = w.DoctypeFieldSchema;
|
|
239
|
+
function L(t) {
|
|
240
|
+
const n = [];
|
|
241
|
+
for (const i of t)
|
|
242
|
+
Array.isArray(i.schema) ? n.push(...L(i.schema.filter(j))) : n.push(i);
|
|
243
|
+
return n;
|
|
244
|
+
}
|
|
245
|
+
function j(t) {
|
|
246
|
+
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
247
|
+
}
|
|
248
|
+
function k(t) {
|
|
249
|
+
return t === void 0 ? "—" : JSON.stringify(t);
|
|
250
|
+
}
|
|
251
|
+
function Ee(t, n) {
|
|
252
|
+
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
|
+
doctype: typeof t.name == "string" ? t.name : "(unnamed)",
|
|
254
|
+
mode: "clean",
|
|
255
|
+
tagged: [],
|
|
256
|
+
orphan: [],
|
|
257
|
+
omitted: [],
|
|
258
|
+
componentDrift: [],
|
|
259
|
+
requiredDrift: [],
|
|
260
|
+
identityDrift: []
|
|
261
|
+
}, f = (s) => {
|
|
262
|
+
if (Array.isArray(s.schema))
|
|
263
|
+
return { ...s, schema: s.schema.filter(j).map(f) };
|
|
264
|
+
const y = typeof s.fieldname == "string" ? s.fieldname : "", d = o.get(y);
|
|
265
|
+
if (!d)
|
|
266
|
+
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=${k(s.component)} schema=${k(d.component)}`), !!d.required != !!s.required && p.requiredDrift.push(`${y}: authored=${!!s.required} schema=${!!d.required}`);
|
|
268
|
+
for (const m of le) {
|
|
269
|
+
if (m === "fieldname" || m === "required") continue;
|
|
270
|
+
const h = s[m], S = d[m];
|
|
271
|
+
h === void 0 && S === void 0 || JSON.stringify(h) !== JSON.stringify(S) && p.identityDrift.push(`${y}.${m}: authored=${k(h)} schema=${k(S)}`);
|
|
272
|
+
}
|
|
273
|
+
return { ...s, source: "introspected" };
|
|
274
|
+
}, g = { ...t, fields: i.map(f) }, a = new Set(L(i).map((s) => s.fieldname));
|
|
275
|
+
p.omitted = n.fields.map((s) => s.fieldname).filter((s) => !a.has(s));
|
|
276
|
+
const l = L(i).find((s) => s.primaryKey === !0), u = n.fields.find((s) => s.primaryKey === !0);
|
|
277
|
+
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
|
+
}
|
|
279
|
+
function xe(t) {
|
|
280
|
+
const n = [];
|
|
281
|
+
t.reason && n.push(` ${t.doctype}: ${t.reason}`);
|
|
282
|
+
const i = (o, r) => {
|
|
283
|
+
r.length && n.push(` ${t.doctype}: ${o} ${r.join("; ")}`);
|
|
284
|
+
};
|
|
285
|
+
return i("identity drift", t.identityDrift), i("component drift", t.componentDrift), i("required drift", t.requiredDrift), i("authored fields with no schema field:", t.orphan), i("schema fields not modelled:", t.omitted), n;
|
|
286
|
+
}
|
|
287
|
+
function Ue(t, n = {}) {
|
|
288
|
+
const i = me(t), o = i.getTypeMap(), r = /* @__PURE__ */ new Set(), p = i.getQueryType(), f = i.getMutationType(), g = i.getSubscriptionType();
|
|
289
|
+
p && r.add(p.name), f && r.add(f.name), g && r.add(g.name);
|
|
290
|
+
const a = n.isEntityType ?? ee, l = /* @__PURE__ */ new Set();
|
|
291
|
+
for (const [d, m] of Object.entries(o))
|
|
292
|
+
A(m) && (r.has(d) || a(d, m) && l.add(d));
|
|
293
|
+
let u = l;
|
|
294
|
+
if (n.include) {
|
|
295
|
+
const d = new Set(n.include);
|
|
296
|
+
u = new Set([...l].filter((m) => d.has(m)));
|
|
297
|
+
}
|
|
298
|
+
if (n.exclude) {
|
|
299
|
+
const d = new Set(n.exclude);
|
|
300
|
+
u = new Set([...u].filter((m) => !d.has(m)));
|
|
301
|
+
}
|
|
302
|
+
const s = n.isEntityField ?? ne, y = [];
|
|
303
|
+
for (const d of u) {
|
|
304
|
+
const m = o[d];
|
|
305
|
+
if (!A(m)) continue;
|
|
306
|
+
const h = m.getFields(), S = "id" in h && "rowId" in h;
|
|
307
|
+
S && n.onWarning?.(
|
|
308
|
+
`${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
|
+
);
|
|
310
|
+
const C = Object.entries(h).filter(
|
|
311
|
+
([c, b]) => s(c, b, m) && !(S && c === "id")
|
|
312
|
+
).map(([c, b]) => {
|
|
313
|
+
if (n.classifyField) {
|
|
314
|
+
const F = n.classifyField(c, b, m);
|
|
315
|
+
if (F != null)
|
|
316
|
+
return {
|
|
317
|
+
kind: "field",
|
|
318
|
+
fieldname: c,
|
|
319
|
+
label: F.label ?? c,
|
|
320
|
+
component: F.component ?? "ATextInput",
|
|
321
|
+
...F
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
return oe(c, b, l, n);
|
|
325
|
+
}), q = C.find(
|
|
326
|
+
(c) => c.fieldname === "id" && c.required && !c.doctype && !c._isLink
|
|
327
|
+
)?.fieldname, D = {}, E = C.filter((c) => c._isLink && c.doctype && c.cardinality ? (D[c.fieldname] = {
|
|
328
|
+
target: c.doctype,
|
|
329
|
+
cardinality: c.cardinality
|
|
330
|
+
}, !1) : !0).map((c) => {
|
|
331
|
+
const b = c.fieldname === q ? { primaryKey: !0 } : {};
|
|
332
|
+
if (!n.includeUnmappedMeta) {
|
|
333
|
+
const { _graphqlType: we, _unmapped: De, _isLink: _e, ...U } = c;
|
|
334
|
+
return Object.assign(U, b, { source: "introspected" });
|
|
335
|
+
}
|
|
336
|
+
const { _isLink: F, ...x } = c;
|
|
337
|
+
return Object.assign(x, b, { source: "introspected" });
|
|
338
|
+
}), N = n.doctypeNames?.[d] ?? d, _ = {
|
|
339
|
+
name: N,
|
|
340
|
+
slug: T(N),
|
|
341
|
+
fields: E
|
|
342
|
+
};
|
|
343
|
+
Object.keys(D).length > 0 && (_.links = D), n.includeUnmappedMeta && (_._graphqlTypeName = d), y.push(_);
|
|
344
|
+
}
|
|
345
|
+
return y;
|
|
346
|
+
}
|
|
347
|
+
function me(t) {
|
|
348
|
+
return typeof t == "string" ? B(t) : K(t);
|
|
349
|
+
}
|
|
350
|
+
const ue = e.enum(["atMostOne", "one", "noneOrMany", "atLeastOne"]).meta({
|
|
351
|
+
title: "Cardinality",
|
|
352
|
+
description: "Cardinality for relationship links between doctypes"
|
|
353
|
+
}), fe = e.object({
|
|
354
|
+
/** Fetch method type */
|
|
355
|
+
method: e.literal("sync"),
|
|
356
|
+
/** Optional limit on number of records to fetch */
|
|
357
|
+
limit: e.number().int().positive().optional()
|
|
358
|
+
}).meta({
|
|
359
|
+
title: "SyncFetch",
|
|
360
|
+
description: "Sync fetch strategy - data is fetched in the initial query"
|
|
361
|
+
}), ye = e.object({
|
|
362
|
+
/** Fetch method type */
|
|
363
|
+
method: e.literal("lazy")
|
|
364
|
+
}).meta({
|
|
365
|
+
title: "LazyFetch",
|
|
366
|
+
description: "Lazy fetch strategy - data is fetched on demand in a separate query"
|
|
367
|
+
}), ge = e.object({
|
|
368
|
+
/** Fetch method type */
|
|
369
|
+
method: e.literal("custom"),
|
|
370
|
+
/** Serialized handler function to invoke */
|
|
371
|
+
handler: e.string()
|
|
372
|
+
}).meta({
|
|
373
|
+
title: "CustomFetch",
|
|
374
|
+
description: "Custom fetch strategy - uses a custom handler function"
|
|
375
|
+
}), he = e.discriminatedUnion("method", [fe, ye, ge]).meta({
|
|
376
|
+
title: "FetchStrategy",
|
|
377
|
+
description: "Fetch strategy for link data loading"
|
|
378
|
+
}), be = e.object({
|
|
379
|
+
/** Target doctype slug */
|
|
380
|
+
target: e.string().min(1),
|
|
381
|
+
/** Cardinality of the relationship */
|
|
382
|
+
cardinality: ue,
|
|
383
|
+
/** Backlink fieldname on the target doctype that points back to this link */
|
|
384
|
+
backlink: e.string().optional(),
|
|
385
|
+
/** Override default rendering component (AForm for 1:1, ATable for 1:many) */
|
|
386
|
+
component: e.string().optional(),
|
|
387
|
+
/** Fieldname of the corresponding Link field in the fields array */
|
|
388
|
+
fieldname: e.string().min(1).optional(),
|
|
389
|
+
/** Fetch strategy for loading nested data */
|
|
390
|
+
fetch: he.optional(),
|
|
391
|
+
/** Whether to block workflow actions until nested data is loaded (default: true) */
|
|
392
|
+
blockWorkflows: e.boolean().optional()
|
|
393
|
+
}).meta({
|
|
394
|
+
title: "LinkDeclaration",
|
|
395
|
+
description: "Declares a relationship from one doctype to another"
|
|
396
|
+
}), Se = e.object({
|
|
397
|
+
/** Display label for the action */
|
|
398
|
+
label: e.string().min(1),
|
|
399
|
+
/** Fields that must have values before action can execute */
|
|
400
|
+
requiredFields: e.array(e.string()).optional(),
|
|
401
|
+
/** Workflow states where this action is available */
|
|
402
|
+
allowedStates: e.array(e.string()).optional(),
|
|
403
|
+
/** The state the record transitions to after this action executes */
|
|
404
|
+
nextState: e.string().optional(),
|
|
405
|
+
/** True for stateless command actions with no workflow effect at all (print, email, etc.) */
|
|
406
|
+
stateless: e.boolean().optional(),
|
|
407
|
+
/**
|
|
408
|
+
* True for an internal self-transition: the action runs within the current state without
|
|
409
|
+
* advancing the workflow (e.g. `save`, which mutates record data but stays put). Scoped by
|
|
410
|
+
* `allowedStates`, rendered as a self-loop in the graph, and has no `nextState`. Distinct from
|
|
411
|
+
* `stateless` (which has no workflow presence at all): a self-transition is graph-owned and,
|
|
412
|
+
* unlike a stateless command, persists record data on dispatch.
|
|
413
|
+
*/
|
|
414
|
+
selfTransition: e.boolean().optional(),
|
|
415
|
+
/** JS function body stored as a string; executed client-side via AsyncFunction with injected API surface */
|
|
416
|
+
clientHandler: e.string().optional()
|
|
417
|
+
}).meta({
|
|
418
|
+
title: "ActionDefinition",
|
|
419
|
+
description: "Action definition within a workflow"
|
|
420
|
+
}), Fe = e.object({
|
|
421
|
+
/** Optional display label; the map key is the trigger's identity */
|
|
422
|
+
label: e.string().optional(),
|
|
423
|
+
/** Fieldnames whose edits fire this trigger (fires when any listed field changes) */
|
|
424
|
+
on: e.array(e.string()),
|
|
425
|
+
/** JS function body stored as a string; run client-side with `{ record, value, setError }`. Advisory. */
|
|
426
|
+
clientHandler: e.string()
|
|
427
|
+
}).meta({
|
|
428
|
+
title: "TriggerDefinition",
|
|
429
|
+
description: "Reactive field-validation trigger — advisory client-side"
|
|
430
|
+
});
|
|
431
|
+
function Pe(t, n) {
|
|
432
|
+
const i = t.allowedStates;
|
|
433
|
+
return !i || i.length === 0 ? !0 : i.includes(n);
|
|
434
|
+
}
|
|
435
|
+
const Te = e.record(
|
|
436
|
+
e.string(),
|
|
437
|
+
e.object({
|
|
438
|
+
position: e.object({ x: e.number(), y: e.number() }).optional(),
|
|
439
|
+
targetPosition: e.enum(["left", "top", "right", "bottom"]).optional(),
|
|
440
|
+
sourcePosition: e.enum(["left", "top", "right", "bottom"]).optional()
|
|
441
|
+
})
|
|
442
|
+
), Ae = e.object({
|
|
443
|
+
/** List of workflow states */
|
|
444
|
+
states: e.array(e.string()).optional(),
|
|
445
|
+
/** Actions available in this workflow */
|
|
446
|
+
actions: e.record(e.string(), Se).optional(),
|
|
447
|
+
/** Reactive field-validation triggers (advisory, client-side), keyed by trigger name */
|
|
448
|
+
triggers: e.record(e.string(), Fe).optional(),
|
|
449
|
+
/**
|
|
450
|
+
* DocBuilder node positions keyed by state name — authoring view-state. Persisted here so a
|
|
451
|
+
* doctype author's manual graph arrangement survives reloads; like `triggers`, it is client-only
|
|
452
|
+
* and never enters the runtime GraphQL SDL. See {@link (WorkflowLayout:variable)}.
|
|
453
|
+
*/
|
|
454
|
+
layout: Te.optional()
|
|
455
|
+
}).meta({
|
|
456
|
+
title: "WorkflowMeta",
|
|
457
|
+
description: "Workflow metadata - states and actions for a doctype"
|
|
458
|
+
}), $ = e.object({
|
|
459
|
+
/** Display name of the doctype */
|
|
460
|
+
name: e.string().min(1),
|
|
461
|
+
/** URL-friendly slug (kebab-case) */
|
|
462
|
+
slug: e.string().min(1).optional(),
|
|
463
|
+
/** Field definitions (a link field is one carrying `doctype`) */
|
|
464
|
+
fields: e.array(O),
|
|
465
|
+
/** Relationship links to other doctypes */
|
|
466
|
+
links: e.record(e.string(), be).optional(),
|
|
467
|
+
/** Workflow configuration */
|
|
468
|
+
workflow: Ae.optional(),
|
|
469
|
+
/** Parent doctype for inheritance */
|
|
470
|
+
inherits: e.string().optional()
|
|
471
|
+
}).meta({
|
|
472
|
+
title: "DoctypeMeta",
|
|
473
|
+
description: "Doctype metadata - complete definition of a doctype"
|
|
474
|
+
});
|
|
475
|
+
function Re(t) {
|
|
476
|
+
const n = O.safeParse(t);
|
|
477
|
+
return n.success ? { success: !0, errors: [] } : {
|
|
478
|
+
success: !1,
|
|
479
|
+
errors: n.error.issues.map((i) => ({
|
|
480
|
+
path: i.path,
|
|
481
|
+
message: i.message
|
|
482
|
+
}))
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
function Ve(t) {
|
|
486
|
+
const n = $.safeParse(t);
|
|
487
|
+
return n.success ? { success: !0, errors: [] } : {
|
|
488
|
+
success: !1,
|
|
489
|
+
errors: n.error.issues.map((i) => ({
|
|
490
|
+
path: i.path,
|
|
491
|
+
message: i.message
|
|
492
|
+
}))
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
function ze(t) {
|
|
496
|
+
return O.parse(t);
|
|
497
|
+
}
|
|
498
|
+
function Be(t) {
|
|
499
|
+
return $.parse(t);
|
|
500
|
+
}
|
|
501
|
+
export {
|
|
502
|
+
Se as A,
|
|
503
|
+
Re as B,
|
|
504
|
+
O as D,
|
|
505
|
+
$e as F,
|
|
506
|
+
J as G,
|
|
507
|
+
Z as I,
|
|
508
|
+
qe as T,
|
|
509
|
+
Me as V,
|
|
510
|
+
Q as W,
|
|
511
|
+
le as a,
|
|
512
|
+
ae as b,
|
|
513
|
+
Ue as c,
|
|
514
|
+
Fe as d,
|
|
515
|
+
Te as e,
|
|
516
|
+
xe as f,
|
|
517
|
+
Ae as g,
|
|
518
|
+
H as h,
|
|
519
|
+
W as i,
|
|
520
|
+
Oe as j,
|
|
521
|
+
oe as k,
|
|
522
|
+
ne as l,
|
|
523
|
+
Ee as m,
|
|
524
|
+
ee as n,
|
|
525
|
+
de as o,
|
|
526
|
+
ve as p,
|
|
527
|
+
Pe as q,
|
|
528
|
+
ce as r,
|
|
529
|
+
Be as s,
|
|
530
|
+
ze as t,
|
|
531
|
+
Ne as u,
|
|
532
|
+
Ve as v,
|
|
533
|
+
je as w,
|
|
534
|
+
Ce as x,
|
|
535
|
+
G as y,
|
|
536
|
+
T as z
|
|
537
|
+
};
|
|
538
|
+
//# sourceMappingURL=validation-CToUOy0a.js.map
|