@stonecrop/schema 0.13.12 → 0.14.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/README.md +38 -92
- package/dist/cli.js +6 -6
- package/dist/index-BzhZpuzA.js +556 -0
- package/dist/index-BzhZpuzA.js.map +1 -0
- package/dist/index-C1oC7Xwz.js +552 -0
- package/dist/index-C1oC7Xwz.js.map +1 -0
- package/dist/index-C8F23K8c.js +555 -0
- package/dist/index-C8F23K8c.js.map +1 -0
- package/dist/index-CD5wQNH-.js +516 -0
- package/dist/index-CD5wQNH-.js.map +1 -0
- package/dist/index-CMeexvC6.js +459 -0
- package/dist/index-CMeexvC6.js.map +1 -0
- package/dist/index-CX662Zb2.js +551 -0
- package/dist/index-CX662Zb2.js.map +1 -0
- package/dist/index-Cq_yfoqI.js +553 -0
- package/dist/index-Cq_yfoqI.js.map +1 -0
- package/dist/index-D68mWfHm.js +510 -0
- package/dist/index-D68mWfHm.js.map +1 -0
- package/dist/index-D8R5ppAg.js +529 -0
- package/dist/index-D8R5ppAg.js.map +1 -0
- package/dist/index-DCjAX4l-.js +516 -0
- package/dist/index-DCjAX4l-.js.map +1 -0
- package/dist/index-DE0b6fs6.js +515 -0
- package/dist/index-DE0b6fs6.js.map +1 -0
- package/dist/index-DIY_FLR2.js +516 -0
- package/dist/index-DIY_FLR2.js.map +1 -0
- package/dist/index-DT-NJBvW.js +510 -0
- package/dist/index-DT-NJBvW.js.map +1 -0
- package/dist/index-DYy5E1cU.js +508 -0
- package/dist/index-DYy5E1cU.js.map +1 -0
- package/dist/index-Dk593rMz.js +512 -0
- package/dist/index-Dk593rMz.js.map +1 -0
- package/dist/index-DpCFgELB.js +514 -0
- package/dist/index-DpCFgELB.js.map +1 -0
- package/dist/index-DyK5-0kh.js +514 -0
- package/dist/index-DyK5-0kh.js.map +1 -0
- package/dist/index-Vd0_gZjr.js +451 -0
- package/dist/index-Vd0_gZjr.js.map +1 -0
- package/dist/index-YP0m26Y5.js +555 -0
- package/dist/index-YP0m26Y5.js.map +1 -0
- package/dist/index-_3q9Bzka.js +512 -0
- package/dist/index-_3q9Bzka.js.map +1 -0
- package/dist/index-glU_Uw7z.js +543 -0
- package/dist/index-glU_Uw7z.js.map +1 -0
- package/dist/index-i0Uz8G2K.js +554 -0
- package/dist/index-i0Uz8G2K.js.map +1 -0
- package/dist/index-rozX0Luh.js +458 -0
- package/dist/index-rozX0Luh.js.map +1 -0
- package/dist/index.js +70 -31
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +324 -88
- package/dist/src/column-schema.d.ts +17 -8
- package/dist/src/column-schema.d.ts.map +1 -1
- package/dist/src/component-meta.d.ts +96 -0
- package/dist/src/component-meta.d.ts.map +1 -0
- package/dist/src/component-meta.js +85 -0
- package/dist/src/converter/heuristics.d.ts.map +1 -1
- package/dist/src/converter/heuristics.js +6 -13
- package/dist/src/converter/index.d.ts +1 -1
- package/dist/src/converter/index.d.ts.map +1 -1
- package/dist/src/converter/index.js +9 -8
- package/dist/src/converter/scalars.d.ts +1 -1
- package/dist/src/converter/scalars.d.ts.map +1 -1
- package/dist/src/converter/scalars.js +23 -26
- package/dist/src/converter/types.d.ts +17 -8
- package/dist/src/converter/types.d.ts.map +1 -1
- package/dist/src/doctype.d.ts +127 -9
- package/dist/src/doctype.d.ts.map +1 -1
- package/dist/src/doctype.js +80 -7
- package/dist/src/field.d.ts +69 -12
- package/dist/src/field.d.ts.map +1 -1
- package/dist/src/field.js +45 -7
- package/dist/src/fieldtype.d.ts.map +1 -1
- package/dist/src/fieldtype.js +14 -13
- package/dist/src/index.d.ts +4 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -3
- package/package.json +1 -1
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
import { z as e } from "zod";
|
|
2
|
+
import { isScalarType as M, isEnumType as E, isObjectType as T, isNonNullType as L, isListType as v, isNamedType as U, buildSchema as P, buildClientSchema as q } from "graphql";
|
|
3
|
+
const R = e.object({
|
|
4
|
+
/** The table view type */
|
|
5
|
+
view: e.enum(["list", "uncounted", "list-expansion", "tree", "gantt", "tree-gantt"]).optional(),
|
|
6
|
+
/** Allow the table to use the full width of its container */
|
|
7
|
+
fullWidth: e.boolean().optional(),
|
|
8
|
+
/** Default expansion state for tree views */
|
|
9
|
+
defaultTreeExpansion: e.enum(["root", "branch", "leaf"]).optional(),
|
|
10
|
+
/** Enable dependency graph connections for Gantt views */
|
|
11
|
+
dependencyGraph: e.boolean().optional()
|
|
12
|
+
}).meta({
|
|
13
|
+
title: "TableViewConfig",
|
|
14
|
+
description: "JSON-safe view configuration for table fields in doctype authoring"
|
|
15
|
+
}), V = [
|
|
16
|
+
"Data",
|
|
17
|
+
// Short text, varchar
|
|
18
|
+
"Text",
|
|
19
|
+
// Long text
|
|
20
|
+
"Int",
|
|
21
|
+
// Integer
|
|
22
|
+
"Float",
|
|
23
|
+
// Floating point (IEEE 754)
|
|
24
|
+
"Decimal",
|
|
25
|
+
// Arbitrary precision decimal
|
|
26
|
+
"Check",
|
|
27
|
+
// Boolean/checkbox
|
|
28
|
+
"Date",
|
|
29
|
+
// Date only
|
|
30
|
+
"Time",
|
|
31
|
+
// Time only
|
|
32
|
+
"Datetime",
|
|
33
|
+
// Date and time
|
|
34
|
+
"Duration",
|
|
35
|
+
// Time interval
|
|
36
|
+
"DateRange",
|
|
37
|
+
// Date range
|
|
38
|
+
"JSON",
|
|
39
|
+
// JSON data
|
|
40
|
+
"Code",
|
|
41
|
+
// Code/source (with syntax highlighting)
|
|
42
|
+
"Link",
|
|
43
|
+
// Reference to another doctype
|
|
44
|
+
"Attach",
|
|
45
|
+
// File attachment
|
|
46
|
+
"Currency",
|
|
47
|
+
// Currency value
|
|
48
|
+
"Quantity",
|
|
49
|
+
// Quantity with unit
|
|
50
|
+
"Select",
|
|
51
|
+
// Dropdown selection
|
|
52
|
+
"PrimaryKey",
|
|
53
|
+
// Primary key field — used by the middleware to identify the record's PK column
|
|
54
|
+
"Fieldset",
|
|
55
|
+
// UI grouping container — no DB column; children are flat columns
|
|
56
|
+
"Display"
|
|
57
|
+
// Computed/read-only field — no DB column; excluded from SQL SELECT
|
|
58
|
+
], W = e.string().min(1).meta({
|
|
59
|
+
title: "StonecropFieldType",
|
|
60
|
+
description: "Semantic field types for Stonecrop doctypes, consistent across forms and tables"
|
|
61
|
+
});
|
|
62
|
+
function J(t) {
|
|
63
|
+
return V.includes(t);
|
|
64
|
+
}
|
|
65
|
+
const z = {
|
|
66
|
+
// Text
|
|
67
|
+
Data: { component: "ATextInput", fieldtype: "Data" },
|
|
68
|
+
Text: { component: "ATextarea", fieldtype: "Text" },
|
|
69
|
+
// Numeric — all numeric variants render with ANumericInput; display differences (currency,
|
|
70
|
+
// precision, unit) are carried by `format`/`mask`, not a distinct component.
|
|
71
|
+
Int: { component: "ANumericInput", fieldtype: "Int" },
|
|
72
|
+
Float: { component: "ANumericInput", fieldtype: "Float" },
|
|
73
|
+
Decimal: { component: "ANumericInput", fieldtype: "Decimal" },
|
|
74
|
+
// Boolean
|
|
75
|
+
Check: { component: "ACheckbox", fieldtype: "Check" },
|
|
76
|
+
// Date/Time — no dedicated Time SFC exists; Time falls back to a plain text input.
|
|
77
|
+
Date: { component: "ADate", fieldtype: "Date" },
|
|
78
|
+
Time: { component: "ATextInput", fieldtype: "Time" },
|
|
79
|
+
Datetime: { component: "ADateTime", fieldtype: "Datetime" },
|
|
80
|
+
Duration: { component: "ADuration", fieldtype: "Duration" },
|
|
81
|
+
DateRange: { component: "ADateRange", fieldtype: "DateRange" },
|
|
82
|
+
// Structured — JSON vs Code is disambiguated by the field's `language`, not the component.
|
|
83
|
+
JSON: { component: "ACodeEditor", fieldtype: "JSON" },
|
|
84
|
+
Code: { component: "ACodeEditor", fieldtype: "Code" },
|
|
85
|
+
// Relational
|
|
86
|
+
Link: { component: "AFormLink", fieldtype: "Link" },
|
|
87
|
+
// Files
|
|
88
|
+
Attach: { component: "AFileAttach", fieldtype: "Attach" },
|
|
89
|
+
// Specialized — Currency/Quantity are numeric with a display format.
|
|
90
|
+
Currency: { component: "ANumericInput", fieldtype: "Currency" },
|
|
91
|
+
Quantity: { component: "ANumericInput", fieldtype: "Quantity" },
|
|
92
|
+
Select: { component: "ADropdown", fieldtype: "Select" },
|
|
93
|
+
// Identity — PK fields are typically hidden; no interactive component is needed
|
|
94
|
+
PrimaryKey: { component: "ATextInput", fieldtype: "PrimaryKey" },
|
|
95
|
+
// Layout — UI grouping containers and computed fields with no backing DB column
|
|
96
|
+
Fieldset: { component: "AFieldset", fieldtype: "Fieldset" },
|
|
97
|
+
Display: { component: "ATextInput", fieldtype: "Display" }
|
|
98
|
+
};
|
|
99
|
+
function Q(t) {
|
|
100
|
+
return z[t]?.component ?? "ATextInput";
|
|
101
|
+
}
|
|
102
|
+
function Ie(t) {
|
|
103
|
+
return J(t) ? Q(t) : "ATextInput";
|
|
104
|
+
}
|
|
105
|
+
const B = e.union([
|
|
106
|
+
e.string(),
|
|
107
|
+
// legacy link target: "customer" — superseded by `doctype`
|
|
108
|
+
e.array(e.string()),
|
|
109
|
+
// Select choices: ["A", "B", "C"]
|
|
110
|
+
e.record(e.string(), e.unknown())
|
|
111
|
+
// Config: \{ precision: 10, scale: 2 \}
|
|
112
|
+
]).meta({
|
|
113
|
+
title: "FieldOptions",
|
|
114
|
+
description: "Field options - flexible bag for type-specific configuration"
|
|
115
|
+
}), K = e.looseObject({
|
|
116
|
+
/** Error message to display when validation fails */
|
|
117
|
+
errorMessage: e.string()
|
|
118
|
+
}).meta({
|
|
119
|
+
title: "FieldValidation",
|
|
120
|
+
description: "Validation configuration for form fields"
|
|
121
|
+
});
|
|
122
|
+
function $(t) {
|
|
123
|
+
if (typeof t != "object" || t === null || Array.isArray(t)) return t;
|
|
124
|
+
const n = t;
|
|
125
|
+
return "kind" in n ? t : "schema" in n ? { kind: "fieldset", ...n } : "columns" in n ? { kind: "table", ...n } : { kind: "field", ...n };
|
|
126
|
+
}
|
|
127
|
+
function G() {
|
|
128
|
+
const t = e.object({
|
|
129
|
+
kind: e.literal("field"),
|
|
130
|
+
fieldname: e.string().min(1),
|
|
131
|
+
fieldtype: W.optional(),
|
|
132
|
+
component: e.string().optional(),
|
|
133
|
+
primaryKey: e.boolean().optional(),
|
|
134
|
+
computed: e.boolean().optional(),
|
|
135
|
+
language: e.string().optional(),
|
|
136
|
+
doctype: e.string().min(1).optional(),
|
|
137
|
+
label: e.string().optional(),
|
|
138
|
+
width: e.string().optional(),
|
|
139
|
+
align: e.enum(["left", "center", "right", "start", "end"]).optional(),
|
|
140
|
+
edit: e.boolean().optional(),
|
|
141
|
+
mask: e.string().optional(),
|
|
142
|
+
format: e.string().optional(),
|
|
143
|
+
mode: e.enum(["edit", "read", "display"]).optional(),
|
|
144
|
+
options: B.optional(),
|
|
145
|
+
required: e.boolean().optional(),
|
|
146
|
+
readOnly: e.boolean().optional(),
|
|
147
|
+
hidden: e.boolean().optional(),
|
|
148
|
+
default: e.unknown().optional(),
|
|
149
|
+
validation: K.optional(),
|
|
150
|
+
cardinality: e.enum(["atMostOne", "one", "noneOrMany", "atLeastOne"]).optional(),
|
|
151
|
+
source: e.literal("introspected").optional()
|
|
152
|
+
}).meta({ title: "ValueField" }), n = e.object({
|
|
153
|
+
kind: e.literal("table"),
|
|
154
|
+
fieldname: e.string().min(1),
|
|
155
|
+
component: e.string().optional(),
|
|
156
|
+
label: e.string().optional(),
|
|
157
|
+
// Validates that each column has fieldname; allows all other ColumnSchema properties
|
|
158
|
+
columns: e.array(e.object({ fieldname: e.string().min(1) }).passthrough()),
|
|
159
|
+
config: R.optional(),
|
|
160
|
+
mode: e.enum(["edit", "read", "display"]).optional()
|
|
161
|
+
}).meta({ title: "TableField" });
|
|
162
|
+
let i = e.never();
|
|
163
|
+
const a = e.object({
|
|
164
|
+
kind: e.literal("fieldset"),
|
|
165
|
+
fieldname: e.string().min(1),
|
|
166
|
+
component: e.string().optional(),
|
|
167
|
+
label: e.string().optional(),
|
|
168
|
+
collapsible: e.boolean().optional(),
|
|
169
|
+
mode: e.enum(["edit", "read", "display"]).optional(),
|
|
170
|
+
schema: e.lazy(() => i.array())
|
|
171
|
+
}).meta({ title: "FieldsetField" }), r = e.discriminatedUnion("kind", [t, a, n]);
|
|
172
|
+
return i = e.preprocess($, r), { ValueFieldSchema: t, TableFieldSchema: n, FieldsetFieldSchema: a, DoctypeFieldSchema: i };
|
|
173
|
+
}
|
|
174
|
+
const F = G(), Ce = F.ValueFieldSchema, Le = F.FieldsetFieldSchema, _e = F.TableFieldSchema, k = F.DoctypeFieldSchema, Y = e.enum(["atMostOne", "one", "noneOrMany", "atLeastOne"]).meta({
|
|
175
|
+
title: "Cardinality",
|
|
176
|
+
description: "Cardinality for relationship links between doctypes"
|
|
177
|
+
}), Z = e.object({
|
|
178
|
+
/** Fetch method type */
|
|
179
|
+
method: e.literal("sync"),
|
|
180
|
+
/** Optional limit on number of records to fetch */
|
|
181
|
+
limit: e.number().int().positive().optional()
|
|
182
|
+
}).meta({
|
|
183
|
+
title: "SyncFetch",
|
|
184
|
+
description: "Sync fetch strategy - data is fetched in the initial query"
|
|
185
|
+
}), H = e.object({
|
|
186
|
+
/** Fetch method type */
|
|
187
|
+
method: e.literal("lazy")
|
|
188
|
+
}).meta({
|
|
189
|
+
title: "LazyFetch",
|
|
190
|
+
description: "Lazy fetch strategy - data is fetched on demand in a separate query"
|
|
191
|
+
}), X = e.object({
|
|
192
|
+
/** Fetch method type */
|
|
193
|
+
method: e.literal("custom"),
|
|
194
|
+
/** Serialized handler function to invoke */
|
|
195
|
+
handler: e.string()
|
|
196
|
+
}).meta({
|
|
197
|
+
title: "CustomFetch",
|
|
198
|
+
description: "Custom fetch strategy - uses a custom handler function"
|
|
199
|
+
}), ee = e.discriminatedUnion("method", [Z, H, X]).meta({
|
|
200
|
+
title: "FetchStrategy",
|
|
201
|
+
description: "Fetch strategy for link data loading"
|
|
202
|
+
}), te = e.object({
|
|
203
|
+
/** Target doctype slug */
|
|
204
|
+
target: e.string().min(1),
|
|
205
|
+
/** Cardinality of the relationship */
|
|
206
|
+
cardinality: Y,
|
|
207
|
+
/** Backlink fieldname on the target doctype that points back to this link */
|
|
208
|
+
backlink: e.string().optional(),
|
|
209
|
+
/** Override default rendering component (AForm for 1:1, ATable for 1:many) */
|
|
210
|
+
component: e.string().optional(),
|
|
211
|
+
/** Fieldname of the corresponding Link field in the fields array */
|
|
212
|
+
fieldname: e.string().min(1).optional(),
|
|
213
|
+
/** Fetch strategy for loading nested data */
|
|
214
|
+
fetch: ee.optional(),
|
|
215
|
+
/** Whether to block workflow actions until nested data is loaded (default: true) */
|
|
216
|
+
blockWorkflows: e.boolean().optional()
|
|
217
|
+
}).meta({
|
|
218
|
+
title: "LinkDeclaration",
|
|
219
|
+
description: "Declares a relationship from one doctype to another"
|
|
220
|
+
}), ne = e.object({
|
|
221
|
+
/** Display label for the action */
|
|
222
|
+
label: e.string().min(1),
|
|
223
|
+
/** Fields that must have values before action can execute */
|
|
224
|
+
requiredFields: e.array(e.string()).optional(),
|
|
225
|
+
/** Workflow states where this action is available */
|
|
226
|
+
allowedStates: e.array(e.string()).optional(),
|
|
227
|
+
/** The state the record transitions to after this action executes */
|
|
228
|
+
nextState: e.string().optional(),
|
|
229
|
+
/** True for stateless command actions with no workflow effect at all (print, email, etc.) */
|
|
230
|
+
stateless: e.boolean().optional(),
|
|
231
|
+
/**
|
|
232
|
+
* True for an internal self-transition: the action runs within the current state without
|
|
233
|
+
* advancing the workflow (e.g. `save`, which mutates record data but stays put). Scoped by
|
|
234
|
+
* `allowedStates`, rendered as a self-loop in the graph, and has no `nextState`. Distinct from
|
|
235
|
+
* `stateless` (which has no workflow presence at all): a self-transition is graph-owned and,
|
|
236
|
+
* unlike a stateless command, persists record data on dispatch.
|
|
237
|
+
*/
|
|
238
|
+
selfTransition: e.boolean().optional(),
|
|
239
|
+
/** JS function body stored as a string; executed client-side via AsyncFunction with injected API surface */
|
|
240
|
+
clientHandler: e.string().optional()
|
|
241
|
+
}).meta({
|
|
242
|
+
title: "ActionDefinition",
|
|
243
|
+
description: "Action definition within a workflow"
|
|
244
|
+
}), ie = e.object({
|
|
245
|
+
/** Optional display label; the map key is the trigger's identity */
|
|
246
|
+
label: e.string().optional(),
|
|
247
|
+
/** Fieldnames whose edits fire this trigger (fires when any listed field changes) */
|
|
248
|
+
on: e.array(e.string()),
|
|
249
|
+
/** JS function body stored as a string; run client-side with `{ record, value, setError }`. Advisory. */
|
|
250
|
+
clientHandler: e.string()
|
|
251
|
+
}).meta({
|
|
252
|
+
title: "TriggerDefinition",
|
|
253
|
+
description: "Reactive field-validation trigger — advisory client-side"
|
|
254
|
+
});
|
|
255
|
+
function we(t, n) {
|
|
256
|
+
const i = t.allowedStates;
|
|
257
|
+
return !i || i.length === 0 ? !0 : i.includes(n);
|
|
258
|
+
}
|
|
259
|
+
const oe = e.record(
|
|
260
|
+
e.string(),
|
|
261
|
+
e.object({
|
|
262
|
+
position: e.object({ x: e.number(), y: e.number() }).optional(),
|
|
263
|
+
targetPosition: e.enum(["left", "top", "right", "bottom"]).optional(),
|
|
264
|
+
sourcePosition: e.enum(["left", "top", "right", "bottom"]).optional()
|
|
265
|
+
})
|
|
266
|
+
), ae = e.object({
|
|
267
|
+
/** List of workflow states */
|
|
268
|
+
states: e.array(e.string()).optional(),
|
|
269
|
+
/** Actions available in this workflow */
|
|
270
|
+
actions: e.record(e.string(), ne).optional(),
|
|
271
|
+
/** Reactive field-validation triggers (advisory, client-side), keyed by trigger name */
|
|
272
|
+
triggers: e.record(e.string(), ie).optional(),
|
|
273
|
+
/**
|
|
274
|
+
* DocBuilder node positions keyed by state name — authoring view-state. Persisted here so a
|
|
275
|
+
* doctype author's manual graph arrangement survives reloads; like `triggers`, it is client-only
|
|
276
|
+
* and never enters the runtime GraphQL SDL. See {@link (WorkflowLayout:variable)}.
|
|
277
|
+
*/
|
|
278
|
+
layout: oe.optional()
|
|
279
|
+
}).meta({
|
|
280
|
+
title: "WorkflowMeta",
|
|
281
|
+
description: "Workflow metadata - states and actions for a doctype"
|
|
282
|
+
}), _ = e.object({
|
|
283
|
+
/** Display name of the doctype */
|
|
284
|
+
name: e.string().min(1),
|
|
285
|
+
/** URL-friendly slug (kebab-case) */
|
|
286
|
+
slug: e.string().min(1).optional(),
|
|
287
|
+
/** Field definitions (including link fields with fieldtype: 'Link') */
|
|
288
|
+
fields: e.array(k),
|
|
289
|
+
/** Relationship links to other doctypes */
|
|
290
|
+
links: e.record(e.string(), te).optional(),
|
|
291
|
+
/** Workflow configuration */
|
|
292
|
+
workflow: ae.optional(),
|
|
293
|
+
/** Parent doctype for inheritance */
|
|
294
|
+
inherits: e.string().optional()
|
|
295
|
+
}).meta({
|
|
296
|
+
title: "DoctypeMeta",
|
|
297
|
+
description: "Doctype metadata - complete definition of a doctype"
|
|
298
|
+
});
|
|
299
|
+
function Oe(t) {
|
|
300
|
+
const n = k.safeParse(t);
|
|
301
|
+
return n.success ? { success: !0, errors: [] } : {
|
|
302
|
+
success: !1,
|
|
303
|
+
errors: n.error.issues.map((i) => ({
|
|
304
|
+
path: i.path,
|
|
305
|
+
message: i.message
|
|
306
|
+
}))
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function je(t) {
|
|
310
|
+
const n = _.safeParse(t);
|
|
311
|
+
return n.success ? { success: !0, errors: [] } : {
|
|
312
|
+
success: !1,
|
|
313
|
+
errors: n.error.issues.map((i) => ({
|
|
314
|
+
path: i.path,
|
|
315
|
+
message: i.message
|
|
316
|
+
}))
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function xe(t) {
|
|
320
|
+
return k.parse(t);
|
|
321
|
+
}
|
|
322
|
+
function Ne(t) {
|
|
323
|
+
return _.parse(t);
|
|
324
|
+
}
|
|
325
|
+
function Me(t) {
|
|
326
|
+
return t.replace(/_([a-z])/g, (n, i) => i.toUpperCase());
|
|
327
|
+
}
|
|
328
|
+
function Ee(t) {
|
|
329
|
+
return t.replace(/[A-Z]/g, (n) => `_${n.toLowerCase()}`);
|
|
330
|
+
}
|
|
331
|
+
function ve(t) {
|
|
332
|
+
return t.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join(" ");
|
|
333
|
+
}
|
|
334
|
+
function re(t) {
|
|
335
|
+
const n = t.replace(/([A-Z])/g, " $1").trim();
|
|
336
|
+
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
337
|
+
}
|
|
338
|
+
function se(t) {
|
|
339
|
+
return t.split(/[-_\s]+/).map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join("");
|
|
340
|
+
}
|
|
341
|
+
function h(t) {
|
|
342
|
+
return t.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
343
|
+
}
|
|
344
|
+
function Ue(t) {
|
|
345
|
+
return t.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase();
|
|
346
|
+
}
|
|
347
|
+
const le = {
|
|
348
|
+
String: { component: "ATextInput", fieldtype: "Data" },
|
|
349
|
+
Int: { component: "ANumericInput", fieldtype: "Int" },
|
|
350
|
+
Float: { component: "ANumericInput", fieldtype: "Float" },
|
|
351
|
+
Boolean: { component: "ACheckbox", fieldtype: "Check" },
|
|
352
|
+
ID: { component: "ATextInput", fieldtype: "Data" }
|
|
353
|
+
}, ce = {
|
|
354
|
+
// Arbitrary precision / large numbers — all numeric variants render with ANumericInput.
|
|
355
|
+
BigFloat: { component: "ANumericInput", fieldtype: "Decimal" },
|
|
356
|
+
BigDecimal: { component: "ANumericInput", fieldtype: "Decimal" },
|
|
357
|
+
Decimal: { component: "ANumericInput", fieldtype: "Decimal" },
|
|
358
|
+
BigInt: { component: "ANumericInput", fieldtype: "Int" },
|
|
359
|
+
Long: { component: "ANumericInput", fieldtype: "Int" },
|
|
360
|
+
// Identifiers
|
|
361
|
+
UUID: { component: "ATextInput", fieldtype: "Data" },
|
|
362
|
+
// Date / Time — no dedicated Time SFC exists; Time falls back to a plain text input.
|
|
363
|
+
DateTime: { component: "ADateTime", fieldtype: "Datetime" },
|
|
364
|
+
Datetime: { component: "ADateTime", fieldtype: "Datetime" },
|
|
365
|
+
Date: { component: "ADate", fieldtype: "Date" },
|
|
366
|
+
Time: { component: "ATextInput", fieldtype: "Time" },
|
|
367
|
+
Interval: { component: "ADuration", fieldtype: "Duration" },
|
|
368
|
+
Duration: { component: "ADuration", fieldtype: "Duration" },
|
|
369
|
+
// Structured data
|
|
370
|
+
JSON: { component: "ACodeEditor", fieldtype: "JSON" },
|
|
371
|
+
JSONObject: { component: "ACodeEditor", fieldtype: "JSON" },
|
|
372
|
+
JsonNode: { component: "ACodeEditor", fieldtype: "JSON" }
|
|
373
|
+
}, pe = /* @__PURE__ */ new Set(["Cursor"]);
|
|
374
|
+
function de(t) {
|
|
375
|
+
const n = { ...ce };
|
|
376
|
+
for (const [i, a] of Object.entries(le))
|
|
377
|
+
n[i] = a;
|
|
378
|
+
if (t)
|
|
379
|
+
for (const [i, a] of Object.entries(t))
|
|
380
|
+
n[i] = {
|
|
381
|
+
component: a.component ?? "ATextInput",
|
|
382
|
+
fieldtype: a.fieldtype ?? "Data"
|
|
383
|
+
};
|
|
384
|
+
return n;
|
|
385
|
+
}
|
|
386
|
+
const ue = [
|
|
387
|
+
"Connection",
|
|
388
|
+
"Edge",
|
|
389
|
+
"Input",
|
|
390
|
+
"Patch",
|
|
391
|
+
"Payload",
|
|
392
|
+
"Condition",
|
|
393
|
+
"Filter",
|
|
394
|
+
"OrderBy",
|
|
395
|
+
"Aggregate",
|
|
396
|
+
"AggregateResult",
|
|
397
|
+
"AggregateFilter",
|
|
398
|
+
"DeleteResponse",
|
|
399
|
+
"InsertResponse",
|
|
400
|
+
"UpdateResponse",
|
|
401
|
+
"MutationResponse"
|
|
402
|
+
], me = /* @__PURE__ */ new Set(["Query", "Mutation", "Subscription"]);
|
|
403
|
+
function fe(t, n) {
|
|
404
|
+
if (t.startsWith("__") || me.has(t) || t === "Node")
|
|
405
|
+
return !1;
|
|
406
|
+
for (const a of ue)
|
|
407
|
+
if (t.endsWith(a))
|
|
408
|
+
return !1;
|
|
409
|
+
const i = n.getFields();
|
|
410
|
+
return Object.keys(i).length !== 0;
|
|
411
|
+
}
|
|
412
|
+
const ye = /* @__PURE__ */ new Set(["nodeId", "__typename", "clientMutationId"]);
|
|
413
|
+
function ge(t, n, i) {
|
|
414
|
+
return !ye.has(t);
|
|
415
|
+
}
|
|
416
|
+
function D(t) {
|
|
417
|
+
let n = !1, i = !1, a = t;
|
|
418
|
+
if (L(a) && (n = !0, a = a.ofType), v(a) && (i = !0, a = a.ofType, L(a) && (a = a.ofType)), !U(a))
|
|
419
|
+
throw new Error(`Expected a named GraphQL type, got: ${String(a)}`);
|
|
420
|
+
return { namedType: a, required: n, isList: i };
|
|
421
|
+
}
|
|
422
|
+
function he(t) {
|
|
423
|
+
const i = t.getFields().edges;
|
|
424
|
+
if (!i) return;
|
|
425
|
+
const { namedType: a, isList: r } = D(i.type);
|
|
426
|
+
if (!r || !T(a)) return;
|
|
427
|
+
const d = a.getFields().node;
|
|
428
|
+
if (!d) return;
|
|
429
|
+
const { namedType: u } = D(d.type);
|
|
430
|
+
if (T(u))
|
|
431
|
+
return u.name;
|
|
432
|
+
}
|
|
433
|
+
function Te(t, n, i, a = {}) {
|
|
434
|
+
const { namedType: r, required: y, isList: d } = D(n.type), u = de(a.customScalars), o = {
|
|
435
|
+
kind: "field",
|
|
436
|
+
fieldname: t,
|
|
437
|
+
label: re(t),
|
|
438
|
+
component: "ATextInput"
|
|
439
|
+
};
|
|
440
|
+
if (y && (o.required = !0), M(r)) {
|
|
441
|
+
if (pe.has(r.name))
|
|
442
|
+
return o._unmapped = !0, a.includeUnmappedMeta && (o._graphqlType = r.name), o;
|
|
443
|
+
if (r.name === "ID") {
|
|
444
|
+
const m = se(t);
|
|
445
|
+
if (i.has(m))
|
|
446
|
+
return o.component = "AFormLink", o.doctype = h(m), o;
|
|
447
|
+
}
|
|
448
|
+
const l = u[r.name];
|
|
449
|
+
return l ? o.component = l.component : (o._unmapped = !0, a.includeUnmappedMeta && (o._graphqlType = r.name)), o;
|
|
450
|
+
}
|
|
451
|
+
if (E(r))
|
|
452
|
+
return o.component = "ADropdown", o.options = r.getValues().map((l) => l.name), o;
|
|
453
|
+
if (T(r)) {
|
|
454
|
+
if (!d && i.has(r.name))
|
|
455
|
+
return o.component = "AFormLink", o.doctype = h(r.name), o;
|
|
456
|
+
const l = he(r);
|
|
457
|
+
return l && i.has(l) ? (o.component = "ATable", o._isLink = !0, o.doctype = h(l), o.cardinality = "noneOrMany", o) : d && i.has(r.name) ? (o.component = "ATable", o._isLink = !0, o.doctype = h(r.name), o.cardinality = "noneOrMany", o) : (o._unmapped = !0, a.includeUnmappedMeta && (o._graphqlType = r.name), o);
|
|
458
|
+
}
|
|
459
|
+
return o._unmapped = !0, a.includeUnmappedMeta && (o._graphqlType = r.name), o;
|
|
460
|
+
}
|
|
461
|
+
function Pe(t, n = {}) {
|
|
462
|
+
const i = be(t), a = i.getTypeMap(), r = /* @__PURE__ */ new Set(), y = i.getQueryType(), d = i.getMutationType(), u = i.getSubscriptionType();
|
|
463
|
+
y && r.add(y.name), d && r.add(d.name), u && r.add(u.name);
|
|
464
|
+
const o = n.isEntityType ?? fe, l = /* @__PURE__ */ new Set();
|
|
465
|
+
for (const [c, p] of Object.entries(a))
|
|
466
|
+
T(p) && (r.has(c) || o(c, p) && l.add(c));
|
|
467
|
+
let m = l;
|
|
468
|
+
if (n.include) {
|
|
469
|
+
const c = new Set(n.include);
|
|
470
|
+
m = new Set([...l].filter((p) => c.has(p)));
|
|
471
|
+
}
|
|
472
|
+
if (n.exclude) {
|
|
473
|
+
const c = new Set(n.exclude);
|
|
474
|
+
m = new Set([...m].filter((p) => !c.has(p)));
|
|
475
|
+
}
|
|
476
|
+
const w = n.isEntityField ?? ge, I = [];
|
|
477
|
+
for (const c of m) {
|
|
478
|
+
const p = a[c];
|
|
479
|
+
if (!T(p)) continue;
|
|
480
|
+
const O = p.getFields(), C = n.typeOverrides?.[c], j = Object.entries(O).filter(([s, g]) => w(s, g, p)).map(([s, g]) => {
|
|
481
|
+
if (n.classifyField) {
|
|
482
|
+
const f = n.classifyField(s, g, p);
|
|
483
|
+
if (f != null)
|
|
484
|
+
return {
|
|
485
|
+
kind: "field",
|
|
486
|
+
fieldname: s,
|
|
487
|
+
label: f.label ?? s,
|
|
488
|
+
component: f.component ?? "ATextInput",
|
|
489
|
+
...f
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
const b = Te(s, g, l, n);
|
|
493
|
+
return C?.[s] ? Object.assign(b, C[s]) : b;
|
|
494
|
+
}), A = {}, x = j.filter((s) => s._isLink && s.doctype && s.cardinality ? (A[s.fieldname] = {
|
|
495
|
+
target: s.doctype,
|
|
496
|
+
cardinality: s.cardinality
|
|
497
|
+
}, !1) : !0).map((s) => {
|
|
498
|
+
if (!n.includeUnmappedMeta) {
|
|
499
|
+
const { _graphqlType: f, _unmapped: Ae, _isLink: Se, ...N } = s;
|
|
500
|
+
return Object.assign(N, { source: "introspected" });
|
|
501
|
+
}
|
|
502
|
+
const { _isLink: g, ...b } = s;
|
|
503
|
+
return Object.assign(b, { source: "introspected" });
|
|
504
|
+
}), S = {
|
|
505
|
+
name: c,
|
|
506
|
+
slug: h(c),
|
|
507
|
+
fields: x
|
|
508
|
+
};
|
|
509
|
+
Object.keys(A).length > 0 && (S.links = A), n.includeUnmappedMeta && (S._graphqlTypeName = c), I.push(S);
|
|
510
|
+
}
|
|
511
|
+
return I;
|
|
512
|
+
}
|
|
513
|
+
function be(t) {
|
|
514
|
+
return typeof t == "string" ? P(t) : q(t);
|
|
515
|
+
}
|
|
516
|
+
export {
|
|
517
|
+
ne as A,
|
|
518
|
+
V as B,
|
|
519
|
+
k as D,
|
|
520
|
+
Le as F,
|
|
521
|
+
le as G,
|
|
522
|
+
pe as I,
|
|
523
|
+
W as S,
|
|
524
|
+
z as T,
|
|
525
|
+
Ce as V,
|
|
526
|
+
ce as W,
|
|
527
|
+
_e as a,
|
|
528
|
+
R as b,
|
|
529
|
+
ie as c,
|
|
530
|
+
oe as d,
|
|
531
|
+
ae as e,
|
|
532
|
+
de as f,
|
|
533
|
+
re as g,
|
|
534
|
+
Ee as h,
|
|
535
|
+
Te as i,
|
|
536
|
+
Pe as j,
|
|
537
|
+
ge as k,
|
|
538
|
+
fe as l,
|
|
539
|
+
Q as m,
|
|
540
|
+
we as n,
|
|
541
|
+
J as o,
|
|
542
|
+
Ne as p,
|
|
543
|
+
xe as q,
|
|
544
|
+
Ue as r,
|
|
545
|
+
Ie as s,
|
|
546
|
+
Me as t,
|
|
547
|
+
ve as u,
|
|
548
|
+
se as v,
|
|
549
|
+
h as w,
|
|
550
|
+
je as x,
|
|
551
|
+
Oe as y
|
|
552
|
+
};
|
|
553
|
+
//# sourceMappingURL=index-Cq_yfoqI.js.map
|