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