@stonecrop/schema 0.13.12 → 0.13.14
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/index-D68mWfHm.js +510 -0
- package/dist/index-D68mWfHm.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-_3q9Bzka.js +512 -0
- package/dist/index-_3q9Bzka.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
import { z as e } from "zod";
|
|
2
|
+
import { isScalarType as E, isEnumType as N, isObjectType as T, isNonNullType as L, isListType as v, isNamedType as P, buildSchema as U, 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
|
+
], J = e.string().min(1).meta({
|
|
59
|
+
title: "StonecropFieldType",
|
|
60
|
+
description: "Semantic field types for Stonecrop doctypes, consistent across forms and tables"
|
|
61
|
+
});
|
|
62
|
+
function Q(t) {
|
|
63
|
+
return V.includes(t);
|
|
64
|
+
}
|
|
65
|
+
const W = {
|
|
66
|
+
// Text
|
|
67
|
+
Data: { component: "ATextInput", fieldtype: "Data" },
|
|
68
|
+
Text: { component: "ATextInput", fieldtype: "Text" },
|
|
69
|
+
// Numeric
|
|
70
|
+
Int: { component: "ANumericInput", fieldtype: "Int" },
|
|
71
|
+
Float: { component: "ANumericInput", fieldtype: "Float" },
|
|
72
|
+
Decimal: { component: "ADecimalInput", fieldtype: "Decimal" },
|
|
73
|
+
// Boolean
|
|
74
|
+
Check: { component: "ACheckbox", fieldtype: "Check" },
|
|
75
|
+
// Date/Time
|
|
76
|
+
Date: { component: "ADate", fieldtype: "Date" },
|
|
77
|
+
Time: { component: "ATimeInput", fieldtype: "Time" },
|
|
78
|
+
Datetime: { component: "ADatetimePicker", fieldtype: "Datetime" },
|
|
79
|
+
Duration: { component: "ADurationInput", fieldtype: "Duration" },
|
|
80
|
+
DateRange: { component: "ADateRangePicker", fieldtype: "DateRange" },
|
|
81
|
+
// Structured
|
|
82
|
+
JSON: { component: "ACodeEditor", fieldtype: "JSON" },
|
|
83
|
+
Code: { component: "ACodeEditor", fieldtype: "Code" },
|
|
84
|
+
// Relational
|
|
85
|
+
Link: { component: "ALink", fieldtype: "Link" },
|
|
86
|
+
// Files
|
|
87
|
+
Attach: { component: "AFileAttach", fieldtype: "Attach" },
|
|
88
|
+
// Specialized
|
|
89
|
+
Currency: { component: "ACurrencyInput", fieldtype: "Currency" },
|
|
90
|
+
Quantity: { component: "AQuantityInput", fieldtype: "Quantity" },
|
|
91
|
+
Select: { component: "ADropdown", fieldtype: "Select" },
|
|
92
|
+
// Identity — PK fields are typically hidden; no interactive component is needed
|
|
93
|
+
PrimaryKey: { component: "ATextInput", fieldtype: "PrimaryKey" },
|
|
94
|
+
// Layout — UI grouping containers and computed fields with no backing DB column
|
|
95
|
+
Fieldset: { component: "AFieldset", fieldtype: "Fieldset" },
|
|
96
|
+
Display: { component: "ATextInput", fieldtype: "Display" }
|
|
97
|
+
};
|
|
98
|
+
function z(t) {
|
|
99
|
+
return W[t]?.component ?? "ATextInput";
|
|
100
|
+
}
|
|
101
|
+
function be(t) {
|
|
102
|
+
return Q(t) ? z(t) : "ATextInput";
|
|
103
|
+
}
|
|
104
|
+
const B = e.union([
|
|
105
|
+
e.string(),
|
|
106
|
+
// Link/Doctype target: "customer"
|
|
107
|
+
e.array(e.string()),
|
|
108
|
+
// Select choices: ["A", "B", "C"]
|
|
109
|
+
e.record(e.string(), e.unknown())
|
|
110
|
+
// Config: \{ precision: 10, scale: 2 \}
|
|
111
|
+
]).meta({
|
|
112
|
+
title: "FieldOptions",
|
|
113
|
+
description: "Field options - flexible bag for type-specific configuration"
|
|
114
|
+
}), $ = e.looseObject({
|
|
115
|
+
/** Error message to display when validation fails */
|
|
116
|
+
errorMessage: e.string()
|
|
117
|
+
}).meta({
|
|
118
|
+
title: "FieldValidation",
|
|
119
|
+
description: "Validation configuration for form fields"
|
|
120
|
+
});
|
|
121
|
+
function G(t) {
|
|
122
|
+
if (typeof t != "object" || t === null || Array.isArray(t)) return t;
|
|
123
|
+
const n = t;
|
|
124
|
+
return "kind" in n ? t : "schema" in n ? { kind: "fieldset", ...n } : "columns" in n ? { kind: "table", ...n } : { kind: "field", ...n };
|
|
125
|
+
}
|
|
126
|
+
function K() {
|
|
127
|
+
const t = e.object({
|
|
128
|
+
kind: e.literal("field"),
|
|
129
|
+
fieldname: e.string().min(1),
|
|
130
|
+
fieldtype: J,
|
|
131
|
+
component: e.string().optional(),
|
|
132
|
+
label: e.string().optional(),
|
|
133
|
+
width: e.string().optional(),
|
|
134
|
+
align: e.enum(["left", "center", "right", "start", "end"]).optional(),
|
|
135
|
+
edit: e.boolean().optional(),
|
|
136
|
+
mask: e.string().optional(),
|
|
137
|
+
mode: e.enum(["edit", "read", "display"]).optional(),
|
|
138
|
+
options: B.optional(),
|
|
139
|
+
required: e.boolean().optional(),
|
|
140
|
+
readOnly: e.boolean().optional(),
|
|
141
|
+
hidden: e.boolean().optional(),
|
|
142
|
+
default: e.unknown().optional(),
|
|
143
|
+
validation: $.optional(),
|
|
144
|
+
cardinality: e.enum(["atMostOne", "one", "noneOrMany", "atLeastOne"]).optional()
|
|
145
|
+
}).meta({ title: "ValueField" }), n = e.object({
|
|
146
|
+
kind: e.literal("table"),
|
|
147
|
+
fieldname: e.string().min(1),
|
|
148
|
+
component: e.string().optional(),
|
|
149
|
+
label: e.string().optional(),
|
|
150
|
+
// Validates that each column has fieldname; allows all other ColumnSchema properties
|
|
151
|
+
columns: e.array(e.object({ fieldname: e.string().min(1) }).passthrough()),
|
|
152
|
+
config: R.optional(),
|
|
153
|
+
mode: e.enum(["edit", "read", "display"]).optional()
|
|
154
|
+
}).meta({ title: "TableField" });
|
|
155
|
+
let o = e.never();
|
|
156
|
+
const a = e.object({
|
|
157
|
+
kind: e.literal("fieldset"),
|
|
158
|
+
fieldname: e.string().min(1),
|
|
159
|
+
component: e.string().optional(),
|
|
160
|
+
label: e.string().optional(),
|
|
161
|
+
collapsible: e.boolean().optional(),
|
|
162
|
+
mode: e.enum(["edit", "read", "display"]).optional(),
|
|
163
|
+
schema: e.lazy(() => o.array())
|
|
164
|
+
}).meta({ title: "FieldsetField" }), r = e.discriminatedUnion("kind", [t, a, n]);
|
|
165
|
+
return o = e.preprocess(G, r), { ValueFieldSchema: t, TableFieldSchema: n, FieldsetFieldSchema: a, DoctypeFieldSchema: o };
|
|
166
|
+
}
|
|
167
|
+
const F = K(), ke = F.ValueFieldSchema, Ie = F.FieldsetFieldSchema, Ce = F.TableFieldSchema, k = F.DoctypeFieldSchema, Y = e.enum(["atMostOne", "one", "noneOrMany", "atLeastOne"]).meta({
|
|
168
|
+
title: "Cardinality",
|
|
169
|
+
description: "Cardinality for relationship links between doctypes"
|
|
170
|
+
}), Z = e.object({
|
|
171
|
+
/** Fetch method type */
|
|
172
|
+
method: e.literal("sync"),
|
|
173
|
+
/** Optional limit on number of records to fetch */
|
|
174
|
+
limit: e.number().int().positive().optional()
|
|
175
|
+
}).meta({
|
|
176
|
+
title: "SyncFetch",
|
|
177
|
+
description: "Sync fetch strategy - data is fetched in the initial query"
|
|
178
|
+
}), H = e.object({
|
|
179
|
+
/** Fetch method type */
|
|
180
|
+
method: e.literal("lazy")
|
|
181
|
+
}).meta({
|
|
182
|
+
title: "LazyFetch",
|
|
183
|
+
description: "Lazy fetch strategy - data is fetched on demand in a separate query"
|
|
184
|
+
}), X = e.object({
|
|
185
|
+
/** Fetch method type */
|
|
186
|
+
method: e.literal("custom"),
|
|
187
|
+
/** Serialized handler function to invoke */
|
|
188
|
+
handler: e.string()
|
|
189
|
+
}).meta({
|
|
190
|
+
title: "CustomFetch",
|
|
191
|
+
description: "Custom fetch strategy - uses a custom handler function"
|
|
192
|
+
}), ee = e.discriminatedUnion("method", [Z, H, X]).meta({
|
|
193
|
+
title: "FetchStrategy",
|
|
194
|
+
description: "Fetch strategy for link data loading"
|
|
195
|
+
}), te = e.object({
|
|
196
|
+
/** Target doctype slug */
|
|
197
|
+
target: e.string().min(1),
|
|
198
|
+
/** Cardinality of the relationship */
|
|
199
|
+
cardinality: Y,
|
|
200
|
+
/** Backlink fieldname on the target doctype that points back to this link */
|
|
201
|
+
backlink: e.string().optional(),
|
|
202
|
+
/** Override default rendering component (AForm for 1:1, ATable for 1:many) */
|
|
203
|
+
component: e.string().optional(),
|
|
204
|
+
/** Fieldname of the corresponding Link field in the fields array */
|
|
205
|
+
fieldname: e.string().min(1).optional(),
|
|
206
|
+
/** Fetch strategy for loading nested data */
|
|
207
|
+
fetch: ee.optional(),
|
|
208
|
+
/** Whether to block workflow actions until nested data is loaded (default: true) */
|
|
209
|
+
blockWorkflows: e.boolean().optional()
|
|
210
|
+
}).meta({
|
|
211
|
+
title: "LinkDeclaration",
|
|
212
|
+
description: "Declares a relationship from one doctype to another"
|
|
213
|
+
}), ne = e.object({
|
|
214
|
+
/** Display label for the action */
|
|
215
|
+
label: e.string().min(1),
|
|
216
|
+
/** Handler function name or path */
|
|
217
|
+
handler: e.string().min(1),
|
|
218
|
+
/** Fields that must have values before action can execute */
|
|
219
|
+
requiredFields: e.array(e.string()).optional(),
|
|
220
|
+
/** Workflow states where this action is available */
|
|
221
|
+
allowedStates: e.array(e.string()).optional(),
|
|
222
|
+
/** Additional arguments for the action */
|
|
223
|
+
args: e.record(e.string(), e.unknown()).optional(),
|
|
224
|
+
/** The state the record transitions to after this action executes */
|
|
225
|
+
nextState: e.string().optional(),
|
|
226
|
+
/** True for side-effect actions that do not change workflow state (save, print, email, etc.) */
|
|
227
|
+
stateless: e.boolean().optional(),
|
|
228
|
+
/** JS function body stored as a string; executed client-side via AsyncFunction with injected API surface */
|
|
229
|
+
clientHandler: e.string().optional()
|
|
230
|
+
}).meta({
|
|
231
|
+
title: "ActionDefinition",
|
|
232
|
+
description: "Action definition within a workflow"
|
|
233
|
+
}), ie = e.object({
|
|
234
|
+
/** List of workflow states */
|
|
235
|
+
states: e.array(e.string()).optional(),
|
|
236
|
+
/** Actions available in this workflow */
|
|
237
|
+
actions: e.record(e.string(), ne).optional()
|
|
238
|
+
}).meta({
|
|
239
|
+
title: "WorkflowMeta",
|
|
240
|
+
description: "Workflow metadata - states and actions for a doctype"
|
|
241
|
+
}), _ = e.object({
|
|
242
|
+
/** Display name of the doctype */
|
|
243
|
+
name: e.string().min(1),
|
|
244
|
+
/** URL-friendly slug (kebab-case) */
|
|
245
|
+
slug: e.string().min(1).optional(),
|
|
246
|
+
/** Field definitions (including link fields with fieldtype: 'Link') */
|
|
247
|
+
fields: e.array(k),
|
|
248
|
+
/** Relationship links to other doctypes */
|
|
249
|
+
links: e.record(e.string(), te).optional(),
|
|
250
|
+
/** Workflow configuration */
|
|
251
|
+
workflow: ie.optional(),
|
|
252
|
+
/** Parent doctype for inheritance */
|
|
253
|
+
inherits: e.string().optional()
|
|
254
|
+
}).meta({
|
|
255
|
+
title: "DoctypeMeta",
|
|
256
|
+
description: "Doctype metadata - complete definition of a doctype"
|
|
257
|
+
});
|
|
258
|
+
function Le(t) {
|
|
259
|
+
const n = k.safeParse(t);
|
|
260
|
+
return n.success ? { success: !0, errors: [] } : {
|
|
261
|
+
success: !1,
|
|
262
|
+
errors: n.error.issues.map((o) => ({
|
|
263
|
+
path: o.path,
|
|
264
|
+
message: o.message
|
|
265
|
+
}))
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function _e(t) {
|
|
269
|
+
const n = _.safeParse(t);
|
|
270
|
+
return n.success ? { success: !0, errors: [] } : {
|
|
271
|
+
success: !1,
|
|
272
|
+
errors: n.error.issues.map((o) => ({
|
|
273
|
+
path: o.path,
|
|
274
|
+
message: o.message
|
|
275
|
+
}))
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function we(t) {
|
|
279
|
+
return k.parse(t);
|
|
280
|
+
}
|
|
281
|
+
function Oe(t) {
|
|
282
|
+
return _.parse(t);
|
|
283
|
+
}
|
|
284
|
+
function je(t) {
|
|
285
|
+
return t.replace(/_([a-z])/g, (n, o) => o.toUpperCase());
|
|
286
|
+
}
|
|
287
|
+
function Me(t) {
|
|
288
|
+
return t.replace(/[A-Z]/g, (n) => `_${n.toLowerCase()}`);
|
|
289
|
+
}
|
|
290
|
+
function xe(t) {
|
|
291
|
+
return t.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join(" ");
|
|
292
|
+
}
|
|
293
|
+
function oe(t) {
|
|
294
|
+
const n = t.replace(/([A-Z])/g, " $1").trim();
|
|
295
|
+
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
296
|
+
}
|
|
297
|
+
function ae(t) {
|
|
298
|
+
return t.split(/[-_\s]+/).map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join("");
|
|
299
|
+
}
|
|
300
|
+
function h(t) {
|
|
301
|
+
return t.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
302
|
+
}
|
|
303
|
+
function Ee(t) {
|
|
304
|
+
return t.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase();
|
|
305
|
+
}
|
|
306
|
+
const re = {
|
|
307
|
+
String: { component: "ATextInput", fieldtype: "Data" },
|
|
308
|
+
Int: { component: "ANumericInput", fieldtype: "Int" },
|
|
309
|
+
Float: { component: "ANumericInput", fieldtype: "Float" },
|
|
310
|
+
Boolean: { component: "ACheckbox", fieldtype: "Check" },
|
|
311
|
+
ID: { component: "ATextInput", fieldtype: "Data" }
|
|
312
|
+
}, le = {
|
|
313
|
+
// Arbitrary precision / large numbers
|
|
314
|
+
BigFloat: { component: "ADecimalInput", fieldtype: "Decimal" },
|
|
315
|
+
BigDecimal: { component: "ADecimalInput", fieldtype: "Decimal" },
|
|
316
|
+
Decimal: { component: "ADecimalInput", fieldtype: "Decimal" },
|
|
317
|
+
BigInt: { component: "ANumericInput", fieldtype: "Int" },
|
|
318
|
+
Long: { component: "ANumericInput", fieldtype: "Int" },
|
|
319
|
+
// Identifiers
|
|
320
|
+
UUID: { component: "ATextInput", fieldtype: "Data" },
|
|
321
|
+
// Date / Time
|
|
322
|
+
DateTime: { component: "ADatetimePicker", fieldtype: "Datetime" },
|
|
323
|
+
Datetime: { component: "ADatetimePicker", fieldtype: "Datetime" },
|
|
324
|
+
Date: { component: "ADate", fieldtype: "Date" },
|
|
325
|
+
Time: { component: "ATimeInput", fieldtype: "Time" },
|
|
326
|
+
Interval: { component: "ADurationInput", fieldtype: "Duration" },
|
|
327
|
+
Duration: { component: "ADurationInput", fieldtype: "Duration" },
|
|
328
|
+
// Structured data
|
|
329
|
+
JSON: { component: "ACodeEditor", fieldtype: "JSON" },
|
|
330
|
+
JSONObject: { component: "ACodeEditor", fieldtype: "JSON" },
|
|
331
|
+
JsonNode: { component: "ACodeEditor", fieldtype: "JSON" }
|
|
332
|
+
}, se = /* @__PURE__ */ new Set(["Cursor"]);
|
|
333
|
+
function ce(t) {
|
|
334
|
+
const n = { ...le };
|
|
335
|
+
for (const [o, a] of Object.entries(re))
|
|
336
|
+
n[o] = a;
|
|
337
|
+
if (t)
|
|
338
|
+
for (const [o, a] of Object.entries(t))
|
|
339
|
+
n[o] = {
|
|
340
|
+
component: a.component ?? "ATextInput",
|
|
341
|
+
fieldtype: a.fieldtype ?? "Data"
|
|
342
|
+
};
|
|
343
|
+
return n;
|
|
344
|
+
}
|
|
345
|
+
const pe = [
|
|
346
|
+
"Connection",
|
|
347
|
+
"Edge",
|
|
348
|
+
"Input",
|
|
349
|
+
"Patch",
|
|
350
|
+
"Payload",
|
|
351
|
+
"Condition",
|
|
352
|
+
"Filter",
|
|
353
|
+
"OrderBy",
|
|
354
|
+
"Aggregate",
|
|
355
|
+
"AggregateResult",
|
|
356
|
+
"AggregateFilter",
|
|
357
|
+
"DeleteResponse",
|
|
358
|
+
"InsertResponse",
|
|
359
|
+
"UpdateResponse",
|
|
360
|
+
"MutationResponse"
|
|
361
|
+
], de = /* @__PURE__ */ new Set(["Query", "Mutation", "Subscription"]);
|
|
362
|
+
function ue(t, n) {
|
|
363
|
+
if (t.startsWith("__") || de.has(t) || t === "Node")
|
|
364
|
+
return !1;
|
|
365
|
+
for (const a of pe)
|
|
366
|
+
if (t.endsWith(a))
|
|
367
|
+
return !1;
|
|
368
|
+
const o = n.getFields();
|
|
369
|
+
return Object.keys(o).length !== 0;
|
|
370
|
+
}
|
|
371
|
+
const me = /* @__PURE__ */ new Set(["nodeId", "__typename", "clientMutationId"]);
|
|
372
|
+
function fe(t, n, o) {
|
|
373
|
+
return !me.has(t);
|
|
374
|
+
}
|
|
375
|
+
function b(t) {
|
|
376
|
+
let n = !1, o = !1, a = t;
|
|
377
|
+
if (L(a) && (n = !0, a = a.ofType), v(a) && (o = !0, a = a.ofType, L(a) && (a = a.ofType)), !P(a))
|
|
378
|
+
throw new Error(`Expected a named GraphQL type, got: ${String(a)}`);
|
|
379
|
+
return { namedType: a, required: n, isList: o };
|
|
380
|
+
}
|
|
381
|
+
function ye(t) {
|
|
382
|
+
const o = t.getFields().edges;
|
|
383
|
+
if (!o) return;
|
|
384
|
+
const { namedType: a, isList: r } = b(o.type);
|
|
385
|
+
if (!r || !T(a)) return;
|
|
386
|
+
const d = a.getFields().node;
|
|
387
|
+
if (!d) return;
|
|
388
|
+
const { namedType: u } = b(d.type);
|
|
389
|
+
if (T(u))
|
|
390
|
+
return u.name;
|
|
391
|
+
}
|
|
392
|
+
function ge(t, n, o, a = {}) {
|
|
393
|
+
const { namedType: r, required: y, isList: d } = b(n.type), u = ce(a.customScalars), i = {
|
|
394
|
+
kind: "field",
|
|
395
|
+
fieldname: t,
|
|
396
|
+
label: oe(t),
|
|
397
|
+
component: "ATextInput",
|
|
398
|
+
fieldtype: "Data"
|
|
399
|
+
};
|
|
400
|
+
if (y && (i.required = !0), E(r)) {
|
|
401
|
+
if (se.has(r.name))
|
|
402
|
+
return i._unmapped = !0, a.includeUnmappedMeta && (i._graphqlType = r.name), i;
|
|
403
|
+
if (r.name === "ID") {
|
|
404
|
+
const m = ae(t);
|
|
405
|
+
if (o.has(m))
|
|
406
|
+
return i.component = "ALink", i.fieldtype = "Link", i.options = h(m), i;
|
|
407
|
+
}
|
|
408
|
+
const s = u[r.name];
|
|
409
|
+
return s ? (i.component = s.component, i.fieldtype = s.fieldtype) : (i._unmapped = !0, a.includeUnmappedMeta && (i._graphqlType = r.name)), i;
|
|
410
|
+
}
|
|
411
|
+
if (N(r))
|
|
412
|
+
return i.component = "ADropdown", i.fieldtype = "Select", i.options = r.getValues().map((s) => s.name), i;
|
|
413
|
+
if (T(r)) {
|
|
414
|
+
if (!d && o.has(r.name))
|
|
415
|
+
return i.component = "ALink", i.fieldtype = "Link", i.options = h(r.name), i;
|
|
416
|
+
const s = ye(r);
|
|
417
|
+
return s && o.has(s) ? (i.component = "ATable", i._isLink = !0, i.options = h(s), i.cardinality = "noneOrMany", delete i.fieldtype, i) : d && o.has(r.name) ? (i.component = "ATable", i._isLink = !0, i.options = h(r.name), i.cardinality = "noneOrMany", delete i.fieldtype, i) : (i._unmapped = !0, a.includeUnmappedMeta && (i._graphqlType = r.name), i);
|
|
418
|
+
}
|
|
419
|
+
return i._unmapped = !0, a.includeUnmappedMeta && (i._graphqlType = r.name), i;
|
|
420
|
+
}
|
|
421
|
+
function Ne(t, n = {}) {
|
|
422
|
+
const o = he(t), a = o.getTypeMap(), r = /* @__PURE__ */ new Set(), y = o.getQueryType(), d = o.getMutationType(), u = o.getSubscriptionType();
|
|
423
|
+
y && r.add(y.name), d && r.add(d.name), u && r.add(u.name);
|
|
424
|
+
const i = n.isEntityType ?? ue, s = /* @__PURE__ */ new Set();
|
|
425
|
+
for (const [c, p] of Object.entries(a))
|
|
426
|
+
T(p) && (r.has(c) || i(c, p) && s.add(c));
|
|
427
|
+
let m = s;
|
|
428
|
+
if (n.include) {
|
|
429
|
+
const c = new Set(n.include);
|
|
430
|
+
m = new Set([...s].filter((p) => c.has(p)));
|
|
431
|
+
}
|
|
432
|
+
if (n.exclude) {
|
|
433
|
+
const c = new Set(n.exclude);
|
|
434
|
+
m = new Set([...m].filter((p) => !c.has(p)));
|
|
435
|
+
}
|
|
436
|
+
const w = n.isEntityField ?? fe, I = [];
|
|
437
|
+
for (const c of m) {
|
|
438
|
+
const p = a[c];
|
|
439
|
+
if (!T(p)) continue;
|
|
440
|
+
const O = p.getFields(), C = n.typeOverrides?.[c], j = Object.entries(O).filter(([l, g]) => w(l, g, p)).map(([l, g]) => {
|
|
441
|
+
if (n.classifyField) {
|
|
442
|
+
const f = n.classifyField(l, g, p);
|
|
443
|
+
if (f != null)
|
|
444
|
+
return {
|
|
445
|
+
kind: "field",
|
|
446
|
+
fieldname: l,
|
|
447
|
+
label: f.label ?? l,
|
|
448
|
+
component: f.component ?? "ATextInput",
|
|
449
|
+
fieldtype: f.fieldtype ?? "Data",
|
|
450
|
+
...f
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
const A = ge(l, g, s, n);
|
|
454
|
+
return C?.[l] ? Object.assign(A, C[l]) : A;
|
|
455
|
+
}), D = {}, M = j.filter((l) => l._isLink && typeof l.options == "string" && l.cardinality ? (D[l.fieldname] = {
|
|
456
|
+
target: l.options,
|
|
457
|
+
cardinality: l.cardinality
|
|
458
|
+
}, !1) : !0).map((l) => {
|
|
459
|
+
if (!n.includeUnmappedMeta) {
|
|
460
|
+
const { _graphqlType: f, _unmapped: Ae, _isLink: Fe, ...x } = l;
|
|
461
|
+
return x;
|
|
462
|
+
}
|
|
463
|
+
const { _isLink: g, ...A } = l;
|
|
464
|
+
return A;
|
|
465
|
+
}), S = {
|
|
466
|
+
name: c,
|
|
467
|
+
slug: h(c),
|
|
468
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- safe: heuristics always set a fieldtype default ('Data'); the optional fieldtype on GraphQLConversionFieldMeta is for intermediate processing, not because output fields lack fieldtype
|
|
469
|
+
fields: M
|
|
470
|
+
};
|
|
471
|
+
Object.keys(D).length > 0 && (S.links = D), n.includeUnmappedMeta && (S._graphqlTypeName = c), I.push(S);
|
|
472
|
+
}
|
|
473
|
+
return I;
|
|
474
|
+
}
|
|
475
|
+
function he(t) {
|
|
476
|
+
return typeof t == "string" ? U(t) : q(t);
|
|
477
|
+
}
|
|
478
|
+
export {
|
|
479
|
+
ne as A,
|
|
480
|
+
V as B,
|
|
481
|
+
k as D,
|
|
482
|
+
Ie as F,
|
|
483
|
+
re as G,
|
|
484
|
+
se as I,
|
|
485
|
+
J as S,
|
|
486
|
+
W as T,
|
|
487
|
+
ke as V,
|
|
488
|
+
le as W,
|
|
489
|
+
Ce as a,
|
|
490
|
+
R as b,
|
|
491
|
+
ie as c,
|
|
492
|
+
ce as d,
|
|
493
|
+
oe as e,
|
|
494
|
+
Me as f,
|
|
495
|
+
ge as g,
|
|
496
|
+
Ne as h,
|
|
497
|
+
fe as i,
|
|
498
|
+
ue as j,
|
|
499
|
+
z as k,
|
|
500
|
+
Q as l,
|
|
501
|
+
we as m,
|
|
502
|
+
Ee as n,
|
|
503
|
+
xe as o,
|
|
504
|
+
Oe as p,
|
|
505
|
+
h as q,
|
|
506
|
+
be as r,
|
|
507
|
+
je as s,
|
|
508
|
+
ae as t,
|
|
509
|
+
Le as u,
|
|
510
|
+
_e as v
|
|
511
|
+
};
|
|
512
|
+
//# sourceMappingURL=index-Dk593rMz.js.map
|