@stonecrop/schema 0.14.0 → 0.15.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 (138) hide show
  1. package/package.json +14 -9
  2. package/dist/cli.cjs +0 -41
  3. package/dist/cli.cjs.map +0 -1
  4. package/dist/converter/heuristics.js +0 -258
  5. package/dist/converter/index.js +0 -181
  6. package/dist/converter/scalars.js +0 -86
  7. package/dist/converter/types.js +0 -5
  8. package/dist/converter-CYNFRwPg.js +0 -512
  9. package/dist/converter-CYNFRwPg.js.map +0 -1
  10. package/dist/converter-DNwpowpq.js +0 -459
  11. package/dist/converter-DNwpowpq.js.map +0 -1
  12. package/dist/doctype.js +0 -152
  13. package/dist/field.js +0 -110
  14. package/dist/fieldtype.js +0 -97
  15. package/dist/index--rNo7Kel.js +0 -494
  16. package/dist/index--rNo7Kel.js.map +0 -1
  17. package/dist/index-0qWNlDQ5.js +0 -450
  18. package/dist/index-0qWNlDQ5.js.map +0 -1
  19. package/dist/index-2UVTfbcY.js +0 -448
  20. package/dist/index-2UVTfbcY.js.map +0 -1
  21. package/dist/index-9QjWZ_PC.js +0 -449
  22. package/dist/index-9QjWZ_PC.js.map +0 -1
  23. package/dist/index-BCADNO5M.js +0 -449
  24. package/dist/index-BCADNO5M.js.map +0 -1
  25. package/dist/index-BJjSlCSo.js +0 -496
  26. package/dist/index-BJjSlCSo.js.map +0 -1
  27. package/dist/index-BRQJGVFR.js +0 -453
  28. package/dist/index-BRQJGVFR.js.map +0 -1
  29. package/dist/index-BatnoC-J.js +0 -429
  30. package/dist/index-BatnoC-J.js.map +0 -1
  31. package/dist/index-BbG7Mzvg.js +0 -495
  32. package/dist/index-BbG7Mzvg.js.map +0 -1
  33. package/dist/index-BdCmYHg0.js +0 -493
  34. package/dist/index-BdCmYHg0.js.map +0 -1
  35. package/dist/index-BhMd2_xl.js +0 -454
  36. package/dist/index-BhMd2_xl.js.map +0 -1
  37. package/dist/index-BzhZpuzA.js +0 -556
  38. package/dist/index-BzhZpuzA.js.map +0 -1
  39. package/dist/index-C1oC7Xwz.js +0 -552
  40. package/dist/index-C1oC7Xwz.js.map +0 -1
  41. package/dist/index-C5ANE_rn.js +0 -501
  42. package/dist/index-C5ANE_rn.js.map +0 -1
  43. package/dist/index-C8F23K8c.js +0 -555
  44. package/dist/index-C8F23K8c.js.map +0 -1
  45. package/dist/index-CD5wQNH-.js +0 -516
  46. package/dist/index-CD5wQNH-.js.map +0 -1
  47. package/dist/index-CLc5mUMQ.js +0 -478
  48. package/dist/index-CLc5mUMQ.js.map +0 -1
  49. package/dist/index-CMeexvC6.js +0 -459
  50. package/dist/index-CMeexvC6.js.map +0 -1
  51. package/dist/index-COrltkHl.js +0 -401
  52. package/dist/index-COrltkHl.js.map +0 -1
  53. package/dist/index-CX662Zb2.js +0 -551
  54. package/dist/index-CX662Zb2.js.map +0 -1
  55. package/dist/index-Cq_yfoqI.js +0 -553
  56. package/dist/index-Cq_yfoqI.js.map +0 -1
  57. package/dist/index-Cu-6609R.js +0 -493
  58. package/dist/index-Cu-6609R.js.map +0 -1
  59. package/dist/index-CvN9xK1B.js +0 -453
  60. package/dist/index-CvN9xK1B.js.map +0 -1
  61. package/dist/index-CzoRIy1-.js +0 -408
  62. package/dist/index-CzoRIy1-.js.map +0 -1
  63. package/dist/index-D66L9JNw.js +0 -506
  64. package/dist/index-D66L9JNw.js.map +0 -1
  65. package/dist/index-D68mWfHm.js +0 -510
  66. package/dist/index-D68mWfHm.js.map +0 -1
  67. package/dist/index-D6Up-BP5.js +0 -435
  68. package/dist/index-D6Up-BP5.js.map +0 -1
  69. package/dist/index-D8R5ppAg.js +0 -529
  70. package/dist/index-D8R5ppAg.js.map +0 -1
  71. package/dist/index-D9qPYlSk.js +0 -491
  72. package/dist/index-D9qPYlSk.js.map +0 -1
  73. package/dist/index-DCjAX4l-.js +0 -516
  74. package/dist/index-DCjAX4l-.js.map +0 -1
  75. package/dist/index-DE0b6fs6.js +0 -515
  76. package/dist/index-DE0b6fs6.js.map +0 -1
  77. package/dist/index-DEkR-1RC.js +0 -496
  78. package/dist/index-DEkR-1RC.js.map +0 -1
  79. package/dist/index-DIY_FLR2.js +0 -516
  80. package/dist/index-DIY_FLR2.js.map +0 -1
  81. package/dist/index-DIb_Z0wI.js +0 -476
  82. package/dist/index-DIb_Z0wI.js.map +0 -1
  83. package/dist/index-DNROIEMe.js +0 -449
  84. package/dist/index-DNROIEMe.js.map +0 -1
  85. package/dist/index-DT-NJBvW.js +0 -510
  86. package/dist/index-DT-NJBvW.js.map +0 -1
  87. package/dist/index-DUFcQC-H.js +0 -449
  88. package/dist/index-DUFcQC-H.js.map +0 -1
  89. package/dist/index-DVVTsJNb.js +0 -495
  90. package/dist/index-DVVTsJNb.js.map +0 -1
  91. package/dist/index-DYy5E1cU.js +0 -508
  92. package/dist/index-DYy5E1cU.js.map +0 -1
  93. package/dist/index-DdC5tpt-.js +0 -488
  94. package/dist/index-DdC5tpt-.js.map +0 -1
  95. package/dist/index-Dk593rMz.js +0 -512
  96. package/dist/index-Dk593rMz.js.map +0 -1
  97. package/dist/index-DmD8vmuB.js +0 -449
  98. package/dist/index-DmD8vmuB.js.map +0 -1
  99. package/dist/index-DpCFgELB.js +0 -514
  100. package/dist/index-DpCFgELB.js.map +0 -1
  101. package/dist/index-DqxTn6jG.js +0 -488
  102. package/dist/index-DqxTn6jG.js.map +0 -1
  103. package/dist/index-DyK5-0kh.js +0 -514
  104. package/dist/index-DyK5-0kh.js.map +0 -1
  105. package/dist/index-Vd0_gZjr.js +0 -451
  106. package/dist/index-Vd0_gZjr.js.map +0 -1
  107. package/dist/index-XSSAHj8g.js +0 -495
  108. package/dist/index-XSSAHj8g.js.map +0 -1
  109. package/dist/index-XZZbfFxT.js +0 -434
  110. package/dist/index-XZZbfFxT.js.map +0 -1
  111. package/dist/index-YP0m26Y5.js +0 -555
  112. package/dist/index-YP0m26Y5.js.map +0 -1
  113. package/dist/index-_3q9Bzka.js +0 -512
  114. package/dist/index-_3q9Bzka.js.map +0 -1
  115. package/dist/index-aeXXzPET.cjs +0 -2
  116. package/dist/index-aeXXzPET.cjs.map +0 -1
  117. package/dist/index-glU_Uw7z.js +0 -543
  118. package/dist/index-glU_Uw7z.js.map +0 -1
  119. package/dist/index-i0Uz8G2K.js +0 -554
  120. package/dist/index-i0Uz8G2K.js.map +0 -1
  121. package/dist/index-neVkjlgB.js +0 -446
  122. package/dist/index-neVkjlgB.js.map +0 -1
  123. package/dist/index-xdlVWldg.js +0 -408
  124. package/dist/index-xdlVWldg.js.map +0 -1
  125. package/dist/index.cjs +0 -2
  126. package/dist/index.cjs.map +0 -1
  127. package/dist/jsonschema.js +0 -225
  128. package/dist/naming.js +0 -106
  129. package/dist/src/fieldtype.d.ts +0 -63
  130. package/dist/src/fieldtype.d.ts.map +0 -1
  131. package/dist/src/fieldtype.js +0 -106
  132. package/dist/src/jsonschema.d.ts +0 -95
  133. package/dist/src/jsonschema.d.ts.map +0 -1
  134. package/dist/src/schema-field.d.ts +0 -66
  135. package/dist/src/schema-field.d.ts.map +0 -1
  136. package/dist/src/schema-field.js +0 -0
  137. package/dist/src/tsdoc-metadata.json +0 -11
  138. package/dist/validation.js +0 -60
@@ -1,501 +0,0 @@
1
- import { z as e } from "zod";
2
- import { isScalarType as j, 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 Se(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() {
122
- const t = e.object({
123
- kind: e.literal("field"),
124
- fieldname: e.string().min(1),
125
- fieldtype: J,
126
- component: e.string().optional(),
127
- label: e.string().optional(),
128
- width: e.string().optional(),
129
- align: e.enum(["left", "center", "right", "start", "end"]).optional(),
130
- edit: e.boolean().optional(),
131
- mask: e.string().optional(),
132
- mode: e.enum(["edit", "read", "display"]).optional(),
133
- options: B.optional(),
134
- required: e.boolean().optional(),
135
- readOnly: e.boolean().optional(),
136
- hidden: e.boolean().optional(),
137
- default: e.unknown().optional(),
138
- validation: $.optional(),
139
- cardinality: e.enum(["atMostOne", "one", "noneOrMany", "atLeastOne"]).optional()
140
- }).meta({ title: "ValueField" }), n = e.object({
141
- kind: e.literal("table"),
142
- fieldname: e.string().min(1),
143
- component: e.string().optional(),
144
- label: e.string().optional(),
145
- // Validates that each column has fieldname; allows all other ColumnSchema properties
146
- columns: e.array(e.object({ fieldname: e.string().min(1) }).passthrough()),
147
- config: R.optional(),
148
- mode: e.enum(["edit", "read", "display"]).optional()
149
- }).meta({ title: "TableField" });
150
- let o = e.never();
151
- const a = e.object({
152
- kind: e.literal("fieldset"),
153
- fieldname: e.string().min(1),
154
- component: e.string().optional(),
155
- label: e.string().optional(),
156
- collapsible: e.boolean().optional(),
157
- mode: e.enum(["edit", "read", "display"]).optional(),
158
- schema: e.lazy(() => o.array())
159
- }).meta({ title: "FieldsetField" });
160
- return o = e.discriminatedUnion("kind", [t, a, n]), { ValueFieldSchema: t, TableFieldSchema: n, FieldsetFieldSchema: a, DoctypeFieldSchema: o };
161
- }
162
- const D = G(), be = D.ValueFieldSchema, ke = D.FieldsetFieldSchema, Ie = D.TableFieldSchema, k = D.DoctypeFieldSchema, K = e.enum(["atMostOne", "one", "noneOrMany", "atLeastOne"]).meta({
163
- title: "Cardinality",
164
- description: "Cardinality for relationship links between doctypes"
165
- }), Y = e.object({
166
- /** Fetch method type */
167
- method: e.literal("sync"),
168
- /** Optional limit on number of records to fetch */
169
- limit: e.number().int().positive().optional()
170
- }).meta({
171
- title: "SyncFetch",
172
- description: "Sync fetch strategy - data is fetched in the initial query"
173
- }), Z = e.object({
174
- /** Fetch method type */
175
- method: e.literal("lazy")
176
- }).meta({
177
- title: "LazyFetch",
178
- description: "Lazy fetch strategy - data is fetched on demand in a separate query"
179
- }), H = e.object({
180
- /** Fetch method type */
181
- method: e.literal("custom"),
182
- /** Serialized handler function to invoke */
183
- handler: e.string()
184
- }).meta({
185
- title: "CustomFetch",
186
- description: "Custom fetch strategy - uses a custom handler function"
187
- }), X = e.discriminatedUnion("method", [Y, Z, H]).meta({
188
- title: "FetchStrategy",
189
- description: "Fetch strategy for link data loading"
190
- }), ee = e.object({
191
- /** Target doctype slug */
192
- target: e.string().min(1),
193
- /** Cardinality of the relationship */
194
- cardinality: K,
195
- /** Backlink fieldname on the target doctype that points back to this link */
196
- backlink: e.string().optional(),
197
- /** Override default rendering component (AForm for 1:1, ATable for 1:many) */
198
- component: e.string().optional(),
199
- /** Fieldname of the corresponding Link field in the fields array */
200
- fieldname: e.string().min(1).optional(),
201
- /** Fetch strategy for loading nested data */
202
- fetch: X.optional(),
203
- /** Whether to block workflow actions until nested data is loaded (default: true) */
204
- blockWorkflows: e.boolean().optional()
205
- }).meta({
206
- title: "LinkDeclaration",
207
- description: "Declares a relationship from one doctype to another"
208
- }), te = e.object({
209
- /** Display label for the action */
210
- label: e.string().min(1),
211
- /** Handler function name or path */
212
- handler: e.string().min(1),
213
- /** Fields that must have values before action can execute */
214
- requiredFields: e.array(e.string()).optional(),
215
- /** Workflow states where this action is available */
216
- allowedStates: e.array(e.string()).optional(),
217
- /** Whether to show a confirmation dialog */
218
- confirm: e.boolean().optional(),
219
- /** Additional arguments for the action */
220
- args: e.record(e.string(), e.unknown()).optional()
221
- }).meta({
222
- title: "ActionDefinition",
223
- description: "Action definition within a workflow"
224
- }), ne = e.object({
225
- /** List of workflow states */
226
- states: e.array(e.string()).optional(),
227
- /** Actions available in this workflow */
228
- actions: e.record(e.string(), te).optional()
229
- }).meta({
230
- title: "WorkflowMeta",
231
- description: "Workflow metadata - states and actions for a doctype"
232
- }), _ = e.object({
233
- /** Display name of the doctype */
234
- name: e.string().min(1),
235
- /** URL-friendly slug (kebab-case) */
236
- slug: e.string().min(1).optional(),
237
- /** Field definitions (including link fields with fieldtype: 'Link') */
238
- fields: e.array(k),
239
- /** Relationship links to other doctypes */
240
- links: e.record(e.string(), ee).optional(),
241
- /** Workflow configuration */
242
- workflow: ne.optional(),
243
- /** Parent doctype for inheritance */
244
- inherits: e.string().optional()
245
- }).meta({
246
- title: "DoctypeMeta",
247
- description: "Doctype metadata - complete definition of a doctype"
248
- });
249
- function Ce(t) {
250
- const n = k.safeParse(t);
251
- return n.success ? { success: !0, errors: [] } : {
252
- success: !1,
253
- errors: n.error.issues.map((o) => ({
254
- path: o.path,
255
- message: o.message
256
- }))
257
- };
258
- }
259
- function Le(t) {
260
- const n = _.safeParse(t);
261
- return n.success ? { success: !0, errors: [] } : {
262
- success: !1,
263
- errors: n.error.issues.map((o) => ({
264
- path: o.path,
265
- message: o.message
266
- }))
267
- };
268
- }
269
- function _e(t) {
270
- return k.parse(t);
271
- }
272
- function we(t) {
273
- return _.parse(t);
274
- }
275
- function Oe(t) {
276
- return t.replace(/_([a-z])/g, (n, o) => o.toUpperCase());
277
- }
278
- function Me(t) {
279
- return t.replace(/[A-Z]/g, (n) => `_${n.toLowerCase()}`);
280
- }
281
- function Ee(t) {
282
- return t.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join(" ");
283
- }
284
- function ie(t) {
285
- const n = t.replace(/([A-Z])/g, " $1").trim();
286
- return n.charAt(0).toUpperCase() + n.slice(1);
287
- }
288
- function oe(t) {
289
- return t.split(/[-_\s]+/).map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join("");
290
- }
291
- function h(t) {
292
- return t.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
293
- }
294
- function xe(t) {
295
- return t.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase();
296
- }
297
- const ae = {
298
- String: { component: "ATextInput", fieldtype: "Data" },
299
- Int: { component: "ANumericInput", fieldtype: "Int" },
300
- Float: { component: "ANumericInput", fieldtype: "Float" },
301
- Boolean: { component: "ACheckbox", fieldtype: "Check" },
302
- ID: { component: "ATextInput", fieldtype: "Data" }
303
- }, re = {
304
- // Arbitrary precision / large numbers
305
- BigFloat: { component: "ADecimalInput", fieldtype: "Decimal" },
306
- BigDecimal: { component: "ADecimalInput", fieldtype: "Decimal" },
307
- Decimal: { component: "ADecimalInput", fieldtype: "Decimal" },
308
- BigInt: { component: "ANumericInput", fieldtype: "Int" },
309
- Long: { component: "ANumericInput", fieldtype: "Int" },
310
- // Identifiers
311
- UUID: { component: "ATextInput", fieldtype: "Data" },
312
- // Date / Time
313
- DateTime: { component: "ADatetimePicker", fieldtype: "Datetime" },
314
- Datetime: { component: "ADatetimePicker", fieldtype: "Datetime" },
315
- Date: { component: "ADate", fieldtype: "Date" },
316
- Time: { component: "ATimeInput", fieldtype: "Time" },
317
- Interval: { component: "ADurationInput", fieldtype: "Duration" },
318
- Duration: { component: "ADurationInput", fieldtype: "Duration" },
319
- // Structured data
320
- JSON: { component: "ACodeEditor", fieldtype: "JSON" },
321
- JSONObject: { component: "ACodeEditor", fieldtype: "JSON" },
322
- JsonNode: { component: "ACodeEditor", fieldtype: "JSON" }
323
- }, le = /* @__PURE__ */ new Set(["Cursor"]);
324
- function se(t) {
325
- const n = { ...re };
326
- for (const [o, a] of Object.entries(ae))
327
- n[o] = a;
328
- if (t)
329
- for (const [o, a] of Object.entries(t))
330
- n[o] = {
331
- component: a.component ?? "ATextInput",
332
- fieldtype: a.fieldtype ?? "Data"
333
- };
334
- return n;
335
- }
336
- const ce = [
337
- "Connection",
338
- "Edge",
339
- "Input",
340
- "Patch",
341
- "Payload",
342
- "Condition",
343
- "Filter",
344
- "OrderBy",
345
- "Aggregate",
346
- "AggregateResult",
347
- "AggregateFilter",
348
- "DeleteResponse",
349
- "InsertResponse",
350
- "UpdateResponse",
351
- "MutationResponse"
352
- ], pe = /* @__PURE__ */ new Set(["Query", "Mutation", "Subscription"]);
353
- function de(t, n) {
354
- if (t.startsWith("__") || pe.has(t) || t === "Node")
355
- return !1;
356
- for (const a of ce)
357
- if (t.endsWith(a))
358
- return !1;
359
- const o = n.getFields();
360
- return Object.keys(o).length !== 0;
361
- }
362
- const me = /* @__PURE__ */ new Set(["nodeId", "__typename", "clientMutationId"]);
363
- function ue(t, n, o) {
364
- return !me.has(t);
365
- }
366
- function b(t) {
367
- let n = !1, o = !1, a = t;
368
- if (L(a) && (n = !0, a = a.ofType), v(a) && (o = !0, a = a.ofType, L(a) && (a = a.ofType)), !P(a))
369
- throw new Error(`Expected a named GraphQL type, got: ${String(a)}`);
370
- return { namedType: a, required: n, isList: o };
371
- }
372
- function fe(t) {
373
- const o = t.getFields().edges;
374
- if (!o) return;
375
- const { namedType: a, isList: r } = b(o.type);
376
- if (!r || !T(a)) return;
377
- const d = a.getFields().node;
378
- if (!d) return;
379
- const { namedType: m } = b(d.type);
380
- if (T(m))
381
- return m.name;
382
- }
383
- function ye(t, n, o, a = {}) {
384
- const { namedType: r, required: y, isList: d } = b(n.type), m = se(a.customScalars), i = {
385
- kind: "field",
386
- fieldname: t,
387
- label: ie(t),
388
- component: "ATextInput",
389
- fieldtype: "Data"
390
- };
391
- if (y && (i.required = !0), j(r)) {
392
- if (le.has(r.name))
393
- return i._unmapped = !0, a.includeUnmappedMeta && (i._graphqlType = r.name), i;
394
- if (r.name === "ID") {
395
- const u = oe(t);
396
- if (o.has(u))
397
- return i.component = "ALink", i.fieldtype = "Link", i.options = h(u), i;
398
- }
399
- const s = m[r.name];
400
- return s ? (i.component = s.component, i.fieldtype = s.fieldtype) : (i._unmapped = !0, a.includeUnmappedMeta && (i._graphqlType = r.name)), i;
401
- }
402
- if (N(r))
403
- return i.component = "ADropdown", i.fieldtype = "Select", i.options = r.getValues().map((s) => s.name), i;
404
- if (T(r)) {
405
- if (!d && o.has(r.name))
406
- return i.component = "ALink", i.fieldtype = "Link", i.options = h(r.name), i;
407
- const s = fe(r);
408
- 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);
409
- }
410
- return i._unmapped = !0, a.includeUnmappedMeta && (i._graphqlType = r.name), i;
411
- }
412
- function je(t, n = {}) {
413
- const o = ge(t), a = o.getTypeMap(), r = /* @__PURE__ */ new Set(), y = o.getQueryType(), d = o.getMutationType(), m = o.getSubscriptionType();
414
- y && r.add(y.name), d && r.add(d.name), m && r.add(m.name);
415
- const i = n.isEntityType ?? de, s = /* @__PURE__ */ new Set();
416
- for (const [c, p] of Object.entries(a))
417
- T(p) && (r.has(c) || i(c, p) && s.add(c));
418
- let u = s;
419
- if (n.include) {
420
- const c = new Set(n.include);
421
- u = new Set([...s].filter((p) => c.has(p)));
422
- }
423
- if (n.exclude) {
424
- const c = new Set(n.exclude);
425
- u = new Set([...u].filter((p) => !c.has(p)));
426
- }
427
- const w = n.isEntityField ?? ue, I = [];
428
- for (const c of u) {
429
- const p = a[c];
430
- if (!T(p)) continue;
431
- const O = p.getFields(), C = n.typeOverrides?.[c], M = Object.entries(O).filter(([l, g]) => w(l, g, p)).map(([l, g]) => {
432
- if (n.classifyField) {
433
- const f = n.classifyField(l, g, p);
434
- if (f != null)
435
- return {
436
- kind: "field",
437
- fieldname: l,
438
- label: f.label ?? l,
439
- component: f.component ?? "ATextInput",
440
- fieldtype: f.fieldtype ?? "Data",
441
- ...f
442
- };
443
- }
444
- const F = ye(l, g, s, n);
445
- return C?.[l] ? Object.assign(F, C[l]) : F;
446
- }), A = {}, E = M.filter((l) => l._isLink && typeof l.options == "string" && l.cardinality ? (A[l.fieldname] = {
447
- target: l.options,
448
- cardinality: l.cardinality
449
- }, !1) : !0).map((l) => {
450
- if (!n.includeUnmappedMeta) {
451
- const { _graphqlType: f, _unmapped: Te, _isLink: Fe, ...x } = l;
452
- return x;
453
- }
454
- const { _isLink: g, ...F } = l;
455
- return F;
456
- }), S = {
457
- name: c,
458
- slug: h(c),
459
- // 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
460
- fields: E
461
- };
462
- Object.keys(A).length > 0 && (S.links = A), n.includeUnmappedMeta && (S._graphqlTypeName = c), I.push(S);
463
- }
464
- return I;
465
- }
466
- function ge(t) {
467
- return typeof t == "string" ? U(t) : q(t);
468
- }
469
- export {
470
- V as B,
471
- k as D,
472
- ke as F,
473
- ae as G,
474
- le as I,
475
- J as S,
476
- W as T,
477
- be as V,
478
- re as W,
479
- Ie as a,
480
- R as b,
481
- se as c,
482
- ie as d,
483
- Me as e,
484
- ye as f,
485
- je as g,
486
- ue as h,
487
- de as i,
488
- z as j,
489
- Q as k,
490
- _e as l,
491
- xe as m,
492
- Ee as n,
493
- h as o,
494
- we as p,
495
- Ce as q,
496
- Se as r,
497
- Oe as s,
498
- oe as t,
499
- Le as v
500
- };
501
- //# sourceMappingURL=index-C5ANE_rn.js.map