@stonecrop/schema 0.12.8 → 0.13.1

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 (87) hide show
  1. package/README.md +0 -2
  2. package/dist/cli.cjs +41 -0
  3. package/dist/cli.cjs.map +1 -0
  4. package/dist/cli.js +1 -1
  5. package/dist/cli.js.map +1 -1
  6. package/dist/converter/heuristics.js +258 -0
  7. package/dist/converter/index.js +181 -0
  8. package/dist/converter/scalars.js +86 -0
  9. package/dist/converter/types.js +5 -0
  10. package/dist/converter-CYNFRwPg.js +512 -0
  11. package/dist/converter-CYNFRwPg.js.map +1 -0
  12. package/dist/converter-DNwpowpq.js +459 -0
  13. package/dist/converter-DNwpowpq.js.map +1 -0
  14. package/dist/doctype.js +152 -0
  15. package/dist/field.js +110 -0
  16. package/dist/fieldtype.js +97 -0
  17. package/dist/index-0qWNlDQ5.js +450 -0
  18. package/dist/index-0qWNlDQ5.js.map +1 -0
  19. package/dist/index-2UVTfbcY.js +448 -0
  20. package/dist/index-2UVTfbcY.js.map +1 -0
  21. package/dist/index-9QjWZ_PC.js +449 -0
  22. package/dist/index-9QjWZ_PC.js.map +1 -0
  23. package/dist/index-BCADNO5M.js +449 -0
  24. package/dist/index-BCADNO5M.js.map +1 -0
  25. package/dist/index-BRQJGVFR.js +453 -0
  26. package/dist/index-BRQJGVFR.js.map +1 -0
  27. package/dist/index-BatnoC-J.js +429 -0
  28. package/dist/index-BatnoC-J.js.map +1 -0
  29. package/dist/index-BdCmYHg0.js +493 -0
  30. package/dist/index-BdCmYHg0.js.map +1 -0
  31. package/dist/index-BhMd2_xl.js +454 -0
  32. package/dist/index-BhMd2_xl.js.map +1 -0
  33. package/dist/index-CLc5mUMQ.js +478 -0
  34. package/dist/index-CLc5mUMQ.js.map +1 -0
  35. package/dist/index-COrltkHl.js +401 -0
  36. package/dist/index-COrltkHl.js.map +1 -0
  37. package/dist/index-CvN9xK1B.js +453 -0
  38. package/dist/index-CvN9xK1B.js.map +1 -0
  39. package/dist/index-CzoRIy1-.js +408 -0
  40. package/dist/index-CzoRIy1-.js.map +1 -0
  41. package/dist/index-D6Up-BP5.js +435 -0
  42. package/dist/index-D6Up-BP5.js.map +1 -0
  43. package/dist/index-DIb_Z0wI.js +476 -0
  44. package/dist/index-DIb_Z0wI.js.map +1 -0
  45. package/dist/index-DNROIEMe.js +449 -0
  46. package/dist/index-DNROIEMe.js.map +1 -0
  47. package/dist/index-DUFcQC-H.js +449 -0
  48. package/dist/index-DUFcQC-H.js.map +1 -0
  49. package/dist/index-DdC5tpt-.js +488 -0
  50. package/dist/index-DdC5tpt-.js.map +1 -0
  51. package/dist/index-DmD8vmuB.js +449 -0
  52. package/dist/index-DmD8vmuB.js.map +1 -0
  53. package/dist/index-XZZbfFxT.js +434 -0
  54. package/dist/index-XZZbfFxT.js.map +1 -0
  55. package/dist/index-aeXXzPET.cjs +2 -0
  56. package/dist/index-aeXXzPET.cjs.map +1 -0
  57. package/dist/index-neVkjlgB.js +446 -0
  58. package/dist/index-neVkjlgB.js.map +1 -0
  59. package/dist/index-xdlVWldg.js +408 -0
  60. package/dist/index-xdlVWldg.js.map +1 -0
  61. package/dist/index.cjs +2 -0
  62. package/dist/index.cjs.map +1 -0
  63. package/dist/index.js +1 -1
  64. package/dist/jsonschema.js +225 -0
  65. package/dist/naming.js +106 -0
  66. package/dist/schema.d.ts +1 -12
  67. package/dist/src/cli.d.ts +0 -12
  68. package/dist/src/cli.d.ts.map +1 -1
  69. package/dist/src/cli.js +1 -0
  70. package/dist/src/converter/index.d.ts.map +1 -1
  71. package/dist/src/converter/index.js +1 -6
  72. package/dist/src/converter/types.d.ts +0 -10
  73. package/dist/src/converter/types.d.ts.map +1 -1
  74. package/dist/src/doctype.d.ts +0 -1
  75. package/dist/src/doctype.d.ts.map +1 -1
  76. package/dist/src/doctype.js +0 -2
  77. package/dist/src/fieldtype.d.ts +1 -1
  78. package/dist/src/fieldtype.d.ts.map +1 -1
  79. package/dist/src/fieldtype.js +3 -0
  80. package/dist/src/jsonschema.d.ts +95 -0
  81. package/dist/src/jsonschema.d.ts.map +1 -0
  82. package/dist/src/schema-field.d.ts +66 -0
  83. package/dist/src/schema-field.d.ts.map +1 -0
  84. package/dist/src/schema-field.js +0 -0
  85. package/dist/src/tsdoc-metadata.json +11 -0
  86. package/dist/validation.js +60 -0
  87. package/package.json +7 -1
@@ -0,0 +1,86 @@
1
+ /**
2
+ * GraphQL Scalar Type Mappings
3
+ *
4
+ * Maps standard GraphQL scalars and well-known custom scalars to Stonecrop field types.
5
+ * Source-agnostic — covers scalars commonly emitted by PostGraphile, Hasura, Apollo, etc.
6
+ *
7
+ * Users can extend these via the `customScalars` option in `GraphQLConversionOptions`.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ /**
12
+ * Mapping from standard GraphQL scalar types to Stonecrop field types.
13
+ * These are defined by the GraphQL specification and are always available.
14
+ *
15
+ * @public
16
+ */
17
+ export const GQL_SCALAR_MAP = {
18
+ String: { component: 'ATextInput', fieldtype: 'Data' },
19
+ Int: { component: 'ANumericInput', fieldtype: 'Int' },
20
+ Float: { component: 'ANumericInput', fieldtype: 'Float' },
21
+ Boolean: { component: 'ACheckbox', fieldtype: 'Check' },
22
+ ID: { component: 'ATextInput', fieldtype: 'Data' },
23
+ };
24
+ /**
25
+ * Mapping from well-known custom GraphQL scalars to Stonecrop field types.
26
+ * These cover scalars commonly used across GraphQL servers (PostGraphile, Hasura, etc.)
27
+ * without baking in knowledge of any specific server.
28
+ *
29
+ * Entries here have lower precedence than `customScalars` from options, but higher
30
+ * precedence than unknown/unmapped scalars.
31
+ *
32
+ * @public
33
+ */
34
+ export const WELL_KNOWN_SCALARS = {
35
+ // Arbitrary precision / large numbers
36
+ BigFloat: { component: 'ADecimalInput', fieldtype: 'Decimal' },
37
+ BigDecimal: { component: 'ADecimalInput', fieldtype: 'Decimal' },
38
+ Decimal: { component: 'ADecimalInput', fieldtype: 'Decimal' },
39
+ BigInt: { component: 'ANumericInput', fieldtype: 'Int' },
40
+ Long: { component: 'ANumericInput', fieldtype: 'Int' },
41
+ // Identifiers
42
+ UUID: { component: 'ATextInput', fieldtype: 'Data' },
43
+ // Date / Time
44
+ DateTime: { component: 'ADatetimePicker', fieldtype: 'Datetime' },
45
+ Datetime: { component: 'ADatetimePicker', fieldtype: 'Datetime' },
46
+ Date: { component: 'ADate', fieldtype: 'Date' },
47
+ Time: { component: 'ATimeInput', fieldtype: 'Time' },
48
+ Interval: { component: 'ADurationInput', fieldtype: 'Duration' },
49
+ Duration: { component: 'ADurationInput', fieldtype: 'Duration' },
50
+ // Structured data
51
+ JSON: { component: 'ACodeEditor', fieldtype: 'JSON' },
52
+ JSONObject: { component: 'ACodeEditor', fieldtype: 'JSON' },
53
+ JsonNode: { component: 'ACodeEditor', fieldtype: 'JSON' },
54
+ };
55
+ /**
56
+ * Set of scalar type names that are internal to GraphQL servers and should be skipped
57
+ * during field conversion (they don't represent meaningful data fields).
58
+ *
59
+ * @public
60
+ */
61
+ export const INTERNAL_SCALARS = new Set(['Cursor']);
62
+ /**
63
+ * Build a merged scalar map from the built-in maps and user-provided custom scalars.
64
+ * Precedence (highest to lowest): customScalars → GQL_SCALAR_MAP → WELL_KNOWN_SCALARS
65
+ *
66
+ * @param customScalars - User-provided scalar overrides
67
+ * @returns Merged scalar map
68
+ * @public
69
+ */
70
+ export function buildScalarMap(customScalars) {
71
+ const merged = { ...WELL_KNOWN_SCALARS };
72
+ // Standard scalars override well-known
73
+ for (const [key, value] of Object.entries(GQL_SCALAR_MAP)) {
74
+ merged[key] = value;
75
+ }
76
+ // Custom scalars override everything
77
+ if (customScalars) {
78
+ for (const [key, value] of Object.entries(customScalars)) {
79
+ merged[key] = {
80
+ component: value.component ?? 'ATextInput',
81
+ fieldtype: value.fieldtype ?? 'Data',
82
+ };
83
+ }
84
+ }
85
+ return merged;
86
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Types for the GraphQL introspection to Stonecrop schema converter.
3
+ * Source-agnostic — works with any GraphQL server (PostGraphile, Hasura, Apollo, etc.)
4
+ * @packageDocumentation
5
+ */
@@ -0,0 +1,512 @@
1
+ import { z as e } from "zod";
2
+ import { buildClientSchema as t, buildSchema as n, isEnumType as r, isListType as i, isNonNullType as a, isObjectType as o, isScalarType as s } from "graphql";
3
+ //#region src/fieldtype.ts
4
+ var c = [
5
+ "Data",
6
+ "Text",
7
+ "Int",
8
+ "Float",
9
+ "Decimal",
10
+ "Check",
11
+ "Date",
12
+ "Time",
13
+ "Datetime",
14
+ "Duration",
15
+ "DateRange",
16
+ "JSON",
17
+ "Code",
18
+ "Link",
19
+ "Attach",
20
+ "Currency",
21
+ "Quantity",
22
+ "Select"
23
+ ], l = e.string().min(1).meta({
24
+ title: "StonecropFieldType",
25
+ description: "Semantic field types for Stonecrop doctypes, consistent across forms and tables"
26
+ });
27
+ function u(e) {
28
+ return c.includes(e);
29
+ }
30
+ var d = {
31
+ Data: {
32
+ component: "ATextInput",
33
+ fieldtype: "Data"
34
+ },
35
+ Text: {
36
+ component: "ATextInput",
37
+ fieldtype: "Text"
38
+ },
39
+ Int: {
40
+ component: "ANumericInput",
41
+ fieldtype: "Int"
42
+ },
43
+ Float: {
44
+ component: "ANumericInput",
45
+ fieldtype: "Float"
46
+ },
47
+ Decimal: {
48
+ component: "ADecimalInput",
49
+ fieldtype: "Decimal"
50
+ },
51
+ Check: {
52
+ component: "ACheckbox",
53
+ fieldtype: "Check"
54
+ },
55
+ Date: {
56
+ component: "ADate",
57
+ fieldtype: "Date"
58
+ },
59
+ Time: {
60
+ component: "ATimeInput",
61
+ fieldtype: "Time"
62
+ },
63
+ Datetime: {
64
+ component: "ADatetimePicker",
65
+ fieldtype: "Datetime"
66
+ },
67
+ Duration: {
68
+ component: "ADurationInput",
69
+ fieldtype: "Duration"
70
+ },
71
+ DateRange: {
72
+ component: "ADateRangePicker",
73
+ fieldtype: "DateRange"
74
+ },
75
+ JSON: {
76
+ component: "ACodeEditor",
77
+ fieldtype: "JSON"
78
+ },
79
+ Code: {
80
+ component: "ACodeEditor",
81
+ fieldtype: "Code"
82
+ },
83
+ Link: {
84
+ component: "ALink",
85
+ fieldtype: "Link"
86
+ },
87
+ Attach: {
88
+ component: "AFileAttach",
89
+ fieldtype: "Attach"
90
+ },
91
+ Currency: {
92
+ component: "ACurrencyInput",
93
+ fieldtype: "Currency"
94
+ },
95
+ Quantity: {
96
+ component: "AQuantityInput",
97
+ fieldtype: "Quantity"
98
+ },
99
+ Select: {
100
+ component: "ADropdown",
101
+ fieldtype: "Select"
102
+ }
103
+ };
104
+ function f(e) {
105
+ return d[e]?.component ?? "ATextInput";
106
+ }
107
+ function p(e) {
108
+ return u(e) ? f(e) : "ATextInput";
109
+ }
110
+ //#endregion
111
+ //#region src/field.ts
112
+ var m = e.union([
113
+ e.string(),
114
+ e.array(e.string()),
115
+ e.record(e.string(), e.unknown())
116
+ ]).meta({
117
+ title: "FieldOptions",
118
+ description: "Field options - flexible bag for type-specific configuration"
119
+ }), h = e.looseObject({ errorMessage: e.string() }).meta({
120
+ title: "FieldValidation",
121
+ description: "Validation configuration for form fields"
122
+ }), g = e.object({
123
+ fieldname: e.string().min(1),
124
+ fieldtype: l,
125
+ component: e.string().optional(),
126
+ label: e.string().optional(),
127
+ width: e.string().optional(),
128
+ align: e.enum([
129
+ "left",
130
+ "center",
131
+ "right",
132
+ "start",
133
+ "end"
134
+ ]).optional(),
135
+ required: e.boolean().optional(),
136
+ readOnly: e.boolean().optional(),
137
+ edit: e.boolean().optional(),
138
+ hidden: e.boolean().optional(),
139
+ value: e.unknown().optional(),
140
+ default: e.unknown().optional(),
141
+ options: m.optional(),
142
+ cardinality: e.enum([
143
+ "one",
144
+ "atMostOne",
145
+ "noneOrMany",
146
+ "atLeastOne"
147
+ ]).optional(),
148
+ mask: e.string().optional(),
149
+ validation: h.optional()
150
+ }).meta({
151
+ title: "FieldMeta",
152
+ description: "Unified field metadata - the single source of truth for field definitions, works for both forms (AForm) and tables (ATable)"
153
+ }), _ = e.enum([
154
+ "atMostOne",
155
+ "one",
156
+ "noneOrMany",
157
+ "atLeastOne"
158
+ ]).meta({
159
+ title: "Cardinality",
160
+ description: "Cardinality for relationship links between doctypes"
161
+ }), v = e.object({
162
+ method: e.literal("sync"),
163
+ limit: e.number().int().positive().optional()
164
+ }).meta({
165
+ title: "SyncFetch",
166
+ description: "Sync fetch strategy - data is fetched in the initial query"
167
+ }), y = e.object({ method: e.literal("lazy") }).meta({
168
+ title: "LazyFetch",
169
+ description: "Lazy fetch strategy - data is fetched on demand in a separate query"
170
+ }), b = e.object({
171
+ method: e.literal("custom"),
172
+ handler: e.string()
173
+ }).meta({
174
+ title: "CustomFetch",
175
+ description: "Custom fetch strategy - uses a custom handler function"
176
+ }), x = e.discriminatedUnion("method", [
177
+ v,
178
+ y,
179
+ b
180
+ ]).meta({
181
+ title: "FetchStrategy",
182
+ description: "Fetch strategy for link data loading"
183
+ }), S = e.object({
184
+ target: e.string().min(1),
185
+ cardinality: _,
186
+ backlink: e.string().optional(),
187
+ component: e.string().optional(),
188
+ fieldname: e.string().min(1).optional(),
189
+ fetch: x.optional(),
190
+ blockWorkflows: e.boolean().optional()
191
+ }).meta({
192
+ title: "LinkDeclaration",
193
+ description: "Declares a relationship from one doctype to another"
194
+ }), C = e.object({
195
+ label: e.string().min(1),
196
+ handler: e.string().min(1),
197
+ requiredFields: e.array(e.string()).optional(),
198
+ allowedStates: e.array(e.string()).optional(),
199
+ confirm: e.boolean().optional(),
200
+ args: e.record(e.string(), e.unknown()).optional()
201
+ }).meta({
202
+ title: "ActionDefinition",
203
+ description: "Action definition within a workflow"
204
+ }), w = e.object({
205
+ states: e.array(e.string()).optional(),
206
+ actions: e.record(e.string(), C).optional()
207
+ }).meta({
208
+ title: "WorkflowMeta",
209
+ description: "Workflow metadata - states and actions for a doctype"
210
+ }), T = e.object({
211
+ name: e.string().min(1),
212
+ slug: e.string().min(1).optional(),
213
+ tableName: e.string().optional(),
214
+ fields: e.array(g),
215
+ links: e.record(e.string(), S).optional(),
216
+ workflow: w.optional(),
217
+ inherits: e.string().optional()
218
+ }).meta({
219
+ title: "DoctypeMeta",
220
+ description: "Doctype metadata - complete definition of a doctype"
221
+ });
222
+ //#endregion
223
+ //#region src/validation.ts
224
+ function E(e) {
225
+ let t = g.safeParse(e);
226
+ return t.success ? {
227
+ success: !0,
228
+ errors: []
229
+ } : {
230
+ success: !1,
231
+ errors: t.error.issues.map((e) => ({
232
+ path: e.path,
233
+ message: e.message
234
+ }))
235
+ };
236
+ }
237
+ function D(e) {
238
+ let t = T.safeParse(e);
239
+ return t.success ? {
240
+ success: !0,
241
+ errors: []
242
+ } : {
243
+ success: !1,
244
+ errors: t.error.issues.map((e) => ({
245
+ path: e.path,
246
+ message: e.message
247
+ }))
248
+ };
249
+ }
250
+ function O(e) {
251
+ return g.parse(e);
252
+ }
253
+ function k(e) {
254
+ return T.parse(e);
255
+ }
256
+ //#endregion
257
+ //#region src/naming.ts
258
+ function A(e) {
259
+ return e.replace(/_([a-z])/g, (e, t) => t.toUpperCase());
260
+ }
261
+ function j(e) {
262
+ return e.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`);
263
+ }
264
+ function M(e) {
265
+ return e.split("_").map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" ");
266
+ }
267
+ function N(e) {
268
+ let t = e.replace(/([A-Z])/g, " $1").trim();
269
+ return t.charAt(0).toUpperCase() + t.slice(1);
270
+ }
271
+ function P(e) {
272
+ return e.split(/[-_\s]+/).map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join("");
273
+ }
274
+ function F(e) {
275
+ return e.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
276
+ }
277
+ function I(e) {
278
+ return e.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase();
279
+ }
280
+ //#endregion
281
+ //#region src/converter/scalars.ts
282
+ var L = {
283
+ String: {
284
+ component: "ATextInput",
285
+ fieldtype: "Data"
286
+ },
287
+ Int: {
288
+ component: "ANumericInput",
289
+ fieldtype: "Int"
290
+ },
291
+ Float: {
292
+ component: "ANumericInput",
293
+ fieldtype: "Float"
294
+ },
295
+ Boolean: {
296
+ component: "ACheckbox",
297
+ fieldtype: "Check"
298
+ },
299
+ ID: {
300
+ component: "ATextInput",
301
+ fieldtype: "Data"
302
+ }
303
+ }, R = {
304
+ BigFloat: {
305
+ component: "ADecimalInput",
306
+ fieldtype: "Decimal"
307
+ },
308
+ BigDecimal: {
309
+ component: "ADecimalInput",
310
+ fieldtype: "Decimal"
311
+ },
312
+ Decimal: {
313
+ component: "ADecimalInput",
314
+ fieldtype: "Decimal"
315
+ },
316
+ BigInt: {
317
+ component: "ANumericInput",
318
+ fieldtype: "Int"
319
+ },
320
+ Long: {
321
+ component: "ANumericInput",
322
+ fieldtype: "Int"
323
+ },
324
+ UUID: {
325
+ component: "ATextInput",
326
+ fieldtype: "Data"
327
+ },
328
+ DateTime: {
329
+ component: "ADatetimePicker",
330
+ fieldtype: "Datetime"
331
+ },
332
+ Datetime: {
333
+ component: "ADatetimePicker",
334
+ fieldtype: "Datetime"
335
+ },
336
+ Date: {
337
+ component: "ADate",
338
+ fieldtype: "Date"
339
+ },
340
+ Time: {
341
+ component: "ATimeInput",
342
+ fieldtype: "Time"
343
+ },
344
+ Interval: {
345
+ component: "ADurationInput",
346
+ fieldtype: "Duration"
347
+ },
348
+ Duration: {
349
+ component: "ADurationInput",
350
+ fieldtype: "Duration"
351
+ },
352
+ JSON: {
353
+ component: "ACodeEditor",
354
+ fieldtype: "JSON"
355
+ },
356
+ JSONObject: {
357
+ component: "ACodeEditor",
358
+ fieldtype: "JSON"
359
+ },
360
+ JsonNode: {
361
+ component: "ACodeEditor",
362
+ fieldtype: "JSON"
363
+ }
364
+ }, z = new Set(["Cursor"]);
365
+ function B(e) {
366
+ let t = { ...R };
367
+ for (let [e, n] of Object.entries(L)) t[e] = n;
368
+ if (e) for (let [n, r] of Object.entries(e)) t[n] = {
369
+ component: r.component ?? "ATextInput",
370
+ fieldtype: r.fieldtype ?? "Data"
371
+ };
372
+ return t;
373
+ }
374
+ //#endregion
375
+ //#region src/converter/heuristics.ts
376
+ var V = [
377
+ "Connection",
378
+ "Edge",
379
+ "Input",
380
+ "Patch",
381
+ "Payload",
382
+ "Condition",
383
+ "Filter",
384
+ "OrderBy",
385
+ "Aggregate",
386
+ "AggregateResult",
387
+ "AggregateFilter",
388
+ "DeleteResponse",
389
+ "InsertResponse",
390
+ "UpdateResponse",
391
+ "MutationResponse"
392
+ ], H = new Set([
393
+ "Query",
394
+ "Mutation",
395
+ "Subscription"
396
+ ]);
397
+ function U(e, t) {
398
+ if (e.startsWith("__") || H.has(e) || e === "Node") return !1;
399
+ for (let t of V) if (e.endsWith(t)) return !1;
400
+ let n = t.getFields();
401
+ return Object.keys(n).length !== 0;
402
+ }
403
+ var W = new Set([
404
+ "nodeId",
405
+ "__typename",
406
+ "clientMutationId"
407
+ ]);
408
+ function G(e, t, n) {
409
+ return !W.has(e);
410
+ }
411
+ function K(e) {
412
+ let t = !1, n = !1, r = e;
413
+ return a(r) && (t = !0, r = r.ofType), i(r) && (n = !0, r = r.ofType, a(r) && (r = r.ofType)), {
414
+ namedType: r,
415
+ required: t,
416
+ isList: n
417
+ };
418
+ }
419
+ function q(e) {
420
+ let t = e.getFields().edges;
421
+ if (!t) return;
422
+ let { namedType: n, isList: r } = K(t.type);
423
+ if (!r || !o(n)) return;
424
+ let i = n.getFields().node;
425
+ if (!i) return;
426
+ let { namedType: a } = K(i.type);
427
+ if (o(a)) return a.name;
428
+ }
429
+ function J(e, t, n, i = {}) {
430
+ let { namedType: a, required: c, isList: l } = K(t.type), u = B(i.customScalars), d = {
431
+ fieldname: e,
432
+ label: N(e),
433
+ component: "ATextInput",
434
+ fieldtype: "Data"
435
+ };
436
+ if (c && (d.required = !0), s(a)) {
437
+ if (z.has(a.name)) return d._unmapped = !0, i.includeUnmappedMeta && (d._graphqlType = a.name), d;
438
+ let e = u[a.name];
439
+ return e ? (d.component = e.component, d.fieldtype = e.fieldtype) : (d._unmapped = !0, i.includeUnmappedMeta && (d._graphqlType = a.name)), d;
440
+ }
441
+ if (r(a)) return d.component = "ADropdown", d.fieldtype = "Select", d.options = a.getValues().map((e) => e.name), d;
442
+ if (o(a)) {
443
+ if (!l && n.has(a.name)) return d.component = "ALink", d.fieldtype = "Link", d.options = F(a.name), d;
444
+ let e = q(a);
445
+ return e && n.has(e) ? (d.component = "ATable", d._isLink = !0, d.options = F(e), d.cardinality = "noneOrMany", delete d.fieldtype, d) : l && n.has(a.name) ? (d.component = "ATable", d._isLink = !0, d.options = F(a.name), d.cardinality = "noneOrMany", delete d.fieldtype, d) : (d._unmapped = !0, i.includeUnmappedMeta && (d._graphqlType = a.name), d);
446
+ }
447
+ return d._unmapped = !0, i.includeUnmappedMeta && (d._graphqlType = a.name), d;
448
+ }
449
+ //#endregion
450
+ //#region src/converter/index.ts
451
+ function Y(e, t = {}) {
452
+ let n = X(e), r = n.getTypeMap(), i = /* @__PURE__ */ new Set(), a = n.getQueryType(), s = n.getMutationType(), c = n.getSubscriptionType();
453
+ a && i.add(a.name), s && i.add(s.name), c && i.add(c.name);
454
+ let l = t.isEntityType ?? U, u = /* @__PURE__ */ new Set();
455
+ for (let [e, t] of Object.entries(r)) o(t) && (i.has(e) || l(e, t) && u.add(e));
456
+ let d = u;
457
+ if (t.include) {
458
+ let e = new Set(t.include);
459
+ d = new Set([...u].filter((t) => e.has(t)));
460
+ }
461
+ if (t.exclude) {
462
+ let e = new Set(t.exclude);
463
+ d = new Set([...d].filter((t) => !e.has(t)));
464
+ }
465
+ let f = t.isEntityField ?? G, p = t.deriveTableName ?? ((e) => I(e)), m = [];
466
+ for (let e of d) {
467
+ let n = r[e];
468
+ if (!o(n)) continue;
469
+ let i = n.getFields(), a = t.typeOverrides?.[e], s = Object.entries(i).filter(([e, t]) => f(e, t, n)).map(([e, r]) => {
470
+ if (t.classifyField) {
471
+ let i = t.classifyField(e, r, n);
472
+ if (i != null) return {
473
+ fieldname: e,
474
+ label: i.label ?? e,
475
+ component: i.component ?? "ATextInput",
476
+ fieldtype: i.fieldtype ?? "Data",
477
+ ...i
478
+ };
479
+ }
480
+ let i = J(e, r, u, t);
481
+ return a?.[e] ? {
482
+ ...i,
483
+ ...a[e]
484
+ } : i;
485
+ }), c = {}, l = s.filter((e) => e._isLink && typeof e.options == "string" && e.cardinality ? (c[e.fieldname] = {
486
+ target: e.options,
487
+ cardinality: e.cardinality
488
+ }, !1) : !0).map((e) => {
489
+ if (!t.includeUnmappedMeta) {
490
+ let { _graphqlType: t, _unmapped: n, _isLink: r, ...i } = e;
491
+ return i;
492
+ }
493
+ let { _isLink: n, ...r } = e;
494
+ return r;
495
+ }), d = {
496
+ name: e,
497
+ slug: F(e),
498
+ fields: l
499
+ };
500
+ Object.keys(c).length > 0 && (d.links = c);
501
+ let h = p(e);
502
+ h && (d.tableName = h), t.includeUnmappedMeta && (d._graphqlTypeName = e), m.push(d);
503
+ }
504
+ return m;
505
+ }
506
+ function X(e) {
507
+ return typeof e == "string" ? n(e) : t(e);
508
+ }
509
+ //#endregion
510
+ export { f as C, d as S, p as T, O as _, L as a, c as b, B as c, I as d, A as f, k as g, F as h, U as i, N as l, P as m, J as n, z as o, M as p, G as r, R as s, Y as t, j as u, D as v, u as w, l as x, E as y };
511
+
512
+ //# sourceMappingURL=converter-CYNFRwPg.js.map