@stonecrop/schema 0.13.7 → 0.13.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -15
- package/dist/cli.js +6 -6
- package/dist/{index-C08kwqyS.js → index-C5ANE_rn.js} +230 -231
- package/dist/index-C5ANE_rn.js.map +1 -0
- package/dist/{index-COp1U6eU.js → index-D66L9JNw.js} +220 -219
- package/dist/index-D66L9JNw.js.map +1 -0
- package/dist/index.js +30 -25
- package/dist/schema.d.ts +256 -91
- package/dist/src/converter/heuristics.d.ts.map +1 -1
- package/dist/src/converter/heuristics.js +1 -0
- package/dist/src/converter/index.d.ts.map +1 -1
- package/dist/src/converter/index.js +6 -4
- package/dist/src/converter/types.d.ts +6 -6
- package/dist/src/converter/types.d.ts.map +1 -1
- package/dist/src/doctype.d.ts +4 -35
- package/dist/src/doctype.d.ts.map +1 -1
- package/dist/src/doctype.js +2 -2
- package/dist/src/field.d.ts +163 -18
- package/dist/src/field.d.ts.map +1 -1
- package/dist/src/field.js +108 -72
- package/dist/src/index.d.ts +4 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -0
- package/dist/src/validation.d.ts +4 -5
- package/dist/src/validation.d.ts.map +1 -1
- package/dist/src/validation.js +5 -5
- package/package.json +1 -1
- package/dist/index-C08kwqyS.js.map +0 -1
- package/dist/index-COp1U6eU.js.map +0 -1
- package/dist/index-leHOZ3ll.js +0 -502
- package/dist/index-leHOZ3ll.js.map +0 -1
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { z as e } from "zod";
|
|
2
|
-
import { isScalarType as
|
|
3
|
-
const
|
|
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 = [
|
|
4
16
|
"Data",
|
|
5
17
|
// Short text, varchar
|
|
6
18
|
"Text",
|
|
@@ -39,16 +51,18 @@ const q = [
|
|
|
39
51
|
// Dropdown selection
|
|
40
52
|
"PrimaryKey",
|
|
41
53
|
// Primary key field — used by the middleware to identify the record's PK column
|
|
42
|
-
"Fieldset"
|
|
54
|
+
"Fieldset",
|
|
43
55
|
// UI grouping container — no DB column; children are flat columns
|
|
44
|
-
|
|
56
|
+
"Display"
|
|
57
|
+
// Computed/read-only field — no DB column; excluded from SQL SELECT
|
|
58
|
+
], J = e.string().min(1).meta({
|
|
45
59
|
title: "StonecropFieldType",
|
|
46
60
|
description: "Semantic field types for Stonecrop doctypes, consistent across forms and tables"
|
|
47
61
|
});
|
|
48
62
|
function Q(t) {
|
|
49
|
-
return
|
|
63
|
+
return V.includes(t);
|
|
50
64
|
}
|
|
51
|
-
const
|
|
65
|
+
const W = {
|
|
52
66
|
// Text
|
|
53
67
|
Data: { component: "ATextInput", fieldtype: "Data" },
|
|
54
68
|
Text: { component: "ATextInput", fieldtype: "Text" },
|
|
@@ -77,16 +91,17 @@ const J = {
|
|
|
77
91
|
Select: { component: "ADropdown", fieldtype: "Select" },
|
|
78
92
|
// Identity — PK fields are typically hidden; no interactive component is needed
|
|
79
93
|
PrimaryKey: { component: "ATextInput", fieldtype: "PrimaryKey" },
|
|
80
|
-
// Layout — UI grouping containers with no backing DB column
|
|
81
|
-
Fieldset: { component: "AFieldset", fieldtype: "Fieldset" }
|
|
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" }
|
|
82
97
|
};
|
|
83
|
-
function
|
|
84
|
-
return
|
|
98
|
+
function z(t) {
|
|
99
|
+
return W[t]?.component ?? "ATextInput";
|
|
85
100
|
}
|
|
86
|
-
function
|
|
87
|
-
return Q(t) ?
|
|
101
|
+
function Se(t) {
|
|
102
|
+
return Q(t) ? z(t) : "ATextInput";
|
|
88
103
|
}
|
|
89
|
-
const
|
|
104
|
+
const B = e.union([
|
|
90
105
|
e.string(),
|
|
91
106
|
// Link/Doctype target: "customer"
|
|
92
107
|
e.array(e.string()),
|
|
@@ -96,82 +111,58 @@ const z = e.union([
|
|
|
96
111
|
]).meta({
|
|
97
112
|
title: "FieldOptions",
|
|
98
113
|
description: "Field options - flexible bag for type-specific configuration"
|
|
99
|
-
}),
|
|
114
|
+
}), $ = e.looseObject({
|
|
100
115
|
/** Error message to display when validation fails */
|
|
101
116
|
errorMessage: e.string()
|
|
102
117
|
}).meta({
|
|
103
118
|
title: "FieldValidation",
|
|
104
119
|
description: "Validation configuration for form fields"
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
* - 'atMostOne': 0 or 1
|
|
149
|
-
* - 'noneOrMany': 0 or more
|
|
150
|
-
* - 'atLeastOne': 1 or more
|
|
151
|
-
*/
|
|
152
|
-
cardinality: e.enum(["one", "atMostOne", "noneOrMany", "atLeastOne"]).optional(),
|
|
153
|
-
/**
|
|
154
|
-
* Input mask pattern. Accepts either a plain mask string or a stringified
|
|
155
|
-
* arrow function that receives `locale` and returns a mask string.
|
|
156
|
-
*
|
|
157
|
-
* Plain pattern: `"##/##/####"`
|
|
158
|
-
*
|
|
159
|
-
* Function pattern: `"(locale) => locale === 'en-US' ? '(###) ###-####' : '####-######'"`
|
|
160
|
-
*/
|
|
161
|
-
mask: e.string().optional(),
|
|
162
|
-
// === VALIDATION ===
|
|
163
|
-
/** Validation configuration */
|
|
164
|
-
validation: B.optional(),
|
|
165
|
-
// === LAYOUT ===
|
|
166
|
-
/** Nested field definitions for Fieldset containers — UI grouping only, no DB column */
|
|
167
|
-
schema: e.array(e.record(e.string(), e.unknown())).optional()
|
|
168
|
-
}).meta({
|
|
169
|
-
title: "FieldMeta",
|
|
170
|
-
description: "Unified field metadata - the single source of truth for field definitions, works for both forms (AForm) and tables (ATable)"
|
|
171
|
-
}), $ = e.enum(["atMostOne", "one", "noneOrMany", "atLeastOne"]).meta({
|
|
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({
|
|
172
163
|
title: "Cardinality",
|
|
173
164
|
description: "Cardinality for relationship links between doctypes"
|
|
174
|
-
}),
|
|
165
|
+
}), Y = e.object({
|
|
175
166
|
/** Fetch method type */
|
|
176
167
|
method: e.literal("sync"),
|
|
177
168
|
/** Optional limit on number of records to fetch */
|
|
@@ -179,13 +170,13 @@ const z = e.union([
|
|
|
179
170
|
}).meta({
|
|
180
171
|
title: "SyncFetch",
|
|
181
172
|
description: "Sync fetch strategy - data is fetched in the initial query"
|
|
182
|
-
}),
|
|
173
|
+
}), Z = e.object({
|
|
183
174
|
/** Fetch method type */
|
|
184
175
|
method: e.literal("lazy")
|
|
185
176
|
}).meta({
|
|
186
177
|
title: "LazyFetch",
|
|
187
178
|
description: "Lazy fetch strategy - data is fetched on demand in a separate query"
|
|
188
|
-
}),
|
|
179
|
+
}), H = e.object({
|
|
189
180
|
/** Fetch method type */
|
|
190
181
|
method: e.literal("custom"),
|
|
191
182
|
/** Serialized handler function to invoke */
|
|
@@ -193,14 +184,14 @@ const z = e.union([
|
|
|
193
184
|
}).meta({
|
|
194
185
|
title: "CustomFetch",
|
|
195
186
|
description: "Custom fetch strategy - uses a custom handler function"
|
|
196
|
-
}),
|
|
187
|
+
}), X = e.discriminatedUnion("method", [Y, Z, H]).meta({
|
|
197
188
|
title: "FetchStrategy",
|
|
198
189
|
description: "Fetch strategy for link data loading"
|
|
199
|
-
}),
|
|
190
|
+
}), ee = e.object({
|
|
200
191
|
/** Target doctype slug */
|
|
201
192
|
target: e.string().min(1),
|
|
202
193
|
/** Cardinality of the relationship */
|
|
203
|
-
cardinality:
|
|
194
|
+
cardinality: K,
|
|
204
195
|
/** Backlink fieldname on the target doctype that points back to this link */
|
|
205
196
|
backlink: e.string().optional(),
|
|
206
197
|
/** Override default rendering component (AForm for 1:1, ATable for 1:many) */
|
|
@@ -208,13 +199,13 @@ const z = e.union([
|
|
|
208
199
|
/** Fieldname of the corresponding Link field in the fields array */
|
|
209
200
|
fieldname: e.string().min(1).optional(),
|
|
210
201
|
/** Fetch strategy for loading nested data */
|
|
211
|
-
fetch:
|
|
202
|
+
fetch: X.optional(),
|
|
212
203
|
/** Whether to block workflow actions until nested data is loaded (default: true) */
|
|
213
204
|
blockWorkflows: e.boolean().optional()
|
|
214
205
|
}).meta({
|
|
215
206
|
title: "LinkDeclaration",
|
|
216
207
|
description: "Declares a relationship from one doctype to another"
|
|
217
|
-
}),
|
|
208
|
+
}), te = e.object({
|
|
218
209
|
/** Display label for the action */
|
|
219
210
|
label: e.string().min(1),
|
|
220
211
|
/** Handler function name or path */
|
|
@@ -230,86 +221,86 @@ const z = e.union([
|
|
|
230
221
|
}).meta({
|
|
231
222
|
title: "ActionDefinition",
|
|
232
223
|
description: "Action definition within a workflow"
|
|
233
|
-
}),
|
|
224
|
+
}), ne = e.object({
|
|
234
225
|
/** List of workflow states */
|
|
235
226
|
states: e.array(e.string()).optional(),
|
|
236
227
|
/** Actions available in this workflow */
|
|
237
|
-
actions: e.record(e.string(),
|
|
228
|
+
actions: e.record(e.string(), te).optional()
|
|
238
229
|
}).meta({
|
|
239
230
|
title: "WorkflowMeta",
|
|
240
231
|
description: "Workflow metadata - states and actions for a doctype"
|
|
241
|
-
}),
|
|
232
|
+
}), _ = e.object({
|
|
242
233
|
/** Display name of the doctype */
|
|
243
234
|
name: e.string().min(1),
|
|
244
235
|
/** URL-friendly slug (kebab-case) */
|
|
245
236
|
slug: e.string().min(1).optional(),
|
|
246
237
|
/** Field definitions (including link fields with fieldtype: 'Link') */
|
|
247
|
-
fields: e.array(
|
|
238
|
+
fields: e.array(k),
|
|
248
239
|
/** Relationship links to other doctypes */
|
|
249
|
-
links: e.record(e.string(),
|
|
240
|
+
links: e.record(e.string(), ee).optional(),
|
|
250
241
|
/** Workflow configuration */
|
|
251
|
-
workflow:
|
|
242
|
+
workflow: ne.optional(),
|
|
252
243
|
/** Parent doctype for inheritance */
|
|
253
244
|
inherits: e.string().optional()
|
|
254
245
|
}).meta({
|
|
255
246
|
title: "DoctypeMeta",
|
|
256
247
|
description: "Doctype metadata - complete definition of a doctype"
|
|
257
248
|
});
|
|
258
|
-
function
|
|
259
|
-
const n =
|
|
249
|
+
function Ce(t) {
|
|
250
|
+
const n = k.safeParse(t);
|
|
260
251
|
return n.success ? { success: !0, errors: [] } : {
|
|
261
252
|
success: !1,
|
|
262
|
-
errors: n.error.issues.map((
|
|
263
|
-
path:
|
|
264
|
-
message:
|
|
253
|
+
errors: n.error.issues.map((o) => ({
|
|
254
|
+
path: o.path,
|
|
255
|
+
message: o.message
|
|
265
256
|
}))
|
|
266
257
|
};
|
|
267
258
|
}
|
|
268
|
-
function
|
|
269
|
-
const n =
|
|
259
|
+
function Le(t) {
|
|
260
|
+
const n = _.safeParse(t);
|
|
270
261
|
return n.success ? { success: !0, errors: [] } : {
|
|
271
262
|
success: !1,
|
|
272
|
-
errors: n.error.issues.map((
|
|
273
|
-
path:
|
|
274
|
-
message:
|
|
263
|
+
errors: n.error.issues.map((o) => ({
|
|
264
|
+
path: o.path,
|
|
265
|
+
message: o.message
|
|
275
266
|
}))
|
|
276
267
|
};
|
|
277
268
|
}
|
|
278
|
-
function
|
|
279
|
-
return
|
|
269
|
+
function _e(t) {
|
|
270
|
+
return k.parse(t);
|
|
280
271
|
}
|
|
281
|
-
function
|
|
282
|
-
return
|
|
272
|
+
function we(t) {
|
|
273
|
+
return _.parse(t);
|
|
283
274
|
}
|
|
284
|
-
function
|
|
285
|
-
return t.replace(/_([a-z])/g, (n,
|
|
275
|
+
function Oe(t) {
|
|
276
|
+
return t.replace(/_([a-z])/g, (n, o) => o.toUpperCase());
|
|
286
277
|
}
|
|
287
|
-
function
|
|
278
|
+
function Me(t) {
|
|
288
279
|
return t.replace(/[A-Z]/g, (n) => `_${n.toLowerCase()}`);
|
|
289
280
|
}
|
|
290
|
-
function
|
|
281
|
+
function Ee(t) {
|
|
291
282
|
return t.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join(" ");
|
|
292
283
|
}
|
|
293
|
-
function
|
|
284
|
+
function ie(t) {
|
|
294
285
|
const n = t.replace(/([A-Z])/g, " $1").trim();
|
|
295
286
|
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
296
287
|
}
|
|
297
|
-
function
|
|
288
|
+
function oe(t) {
|
|
298
289
|
return t.split(/[-_\s]+/).map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join("");
|
|
299
290
|
}
|
|
300
291
|
function h(t) {
|
|
301
292
|
return t.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
302
293
|
}
|
|
303
|
-
function
|
|
294
|
+
function xe(t) {
|
|
304
295
|
return t.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase();
|
|
305
296
|
}
|
|
306
|
-
const
|
|
297
|
+
const ae = {
|
|
307
298
|
String: { component: "ATextInput", fieldtype: "Data" },
|
|
308
299
|
Int: { component: "ANumericInput", fieldtype: "Int" },
|
|
309
300
|
Float: { component: "ANumericInput", fieldtype: "Float" },
|
|
310
301
|
Boolean: { component: "ACheckbox", fieldtype: "Check" },
|
|
311
302
|
ID: { component: "ATextInput", fieldtype: "Data" }
|
|
312
|
-
},
|
|
303
|
+
}, re = {
|
|
313
304
|
// Arbitrary precision / large numbers
|
|
314
305
|
BigFloat: { component: "ADecimalInput", fieldtype: "Decimal" },
|
|
315
306
|
BigDecimal: { component: "ADecimalInput", fieldtype: "Decimal" },
|
|
@@ -329,20 +320,20 @@ const ne = {
|
|
|
329
320
|
JSON: { component: "ACodeEditor", fieldtype: "JSON" },
|
|
330
321
|
JSONObject: { component: "ACodeEditor", fieldtype: "JSON" },
|
|
331
322
|
JsonNode: { component: "ACodeEditor", fieldtype: "JSON" }
|
|
332
|
-
},
|
|
333
|
-
function
|
|
334
|
-
const n = { ...
|
|
335
|
-
for (const [
|
|
336
|
-
n[
|
|
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;
|
|
337
328
|
if (t)
|
|
338
|
-
for (const [
|
|
339
|
-
n[
|
|
340
|
-
component:
|
|
341
|
-
fieldtype:
|
|
329
|
+
for (const [o, a] of Object.entries(t))
|
|
330
|
+
n[o] = {
|
|
331
|
+
component: a.component ?? "ATextInput",
|
|
332
|
+
fieldtype: a.fieldtype ?? "Data"
|
|
342
333
|
};
|
|
343
334
|
return n;
|
|
344
335
|
}
|
|
345
|
-
const
|
|
336
|
+
const ce = [
|
|
346
337
|
"Connection",
|
|
347
338
|
"Edge",
|
|
348
339
|
"Input",
|
|
@@ -358,145 +349,153 @@ const re = [
|
|
|
358
349
|
"InsertResponse",
|
|
359
350
|
"UpdateResponse",
|
|
360
351
|
"MutationResponse"
|
|
361
|
-
],
|
|
362
|
-
function
|
|
363
|
-
if (t.startsWith("__") ||
|
|
352
|
+
], pe = /* @__PURE__ */ new Set(["Query", "Mutation", "Subscription"]);
|
|
353
|
+
function de(t, n) {
|
|
354
|
+
if (t.startsWith("__") || pe.has(t) || t === "Node")
|
|
364
355
|
return !1;
|
|
365
|
-
for (const
|
|
366
|
-
if (t.endsWith(
|
|
356
|
+
for (const a of ce)
|
|
357
|
+
if (t.endsWith(a))
|
|
367
358
|
return !1;
|
|
368
|
-
const
|
|
369
|
-
return Object.keys(
|
|
359
|
+
const o = n.getFields();
|
|
360
|
+
return Object.keys(o).length !== 0;
|
|
370
361
|
}
|
|
371
|
-
const
|
|
372
|
-
function
|
|
373
|
-
return !
|
|
362
|
+
const me = /* @__PURE__ */ new Set(["nodeId", "__typename", "clientMutationId"]);
|
|
363
|
+
function ue(t, n, o) {
|
|
364
|
+
return !me.has(t);
|
|
374
365
|
}
|
|
375
|
-
function
|
|
376
|
-
let n = !1,
|
|
377
|
-
if (
|
|
378
|
-
throw new Error(`Expected a named GraphQL type, got: ${String(
|
|
379
|
-
return { namedType:
|
|
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 };
|
|
380
371
|
}
|
|
381
|
-
function
|
|
382
|
-
const
|
|
383
|
-
if (!
|
|
384
|
-
const { namedType:
|
|
385
|
-
if (!r || !
|
|
386
|
-
const d =
|
|
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;
|
|
387
378
|
if (!d) return;
|
|
388
|
-
const { namedType:
|
|
389
|
-
if (
|
|
390
|
-
return
|
|
379
|
+
const { namedType: m } = b(d.type);
|
|
380
|
+
if (T(m))
|
|
381
|
+
return m.name;
|
|
391
382
|
}
|
|
392
|
-
function
|
|
393
|
-
const { namedType: r, required: y, isList: d } =
|
|
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",
|
|
394
386
|
fieldname: t,
|
|
395
|
-
label:
|
|
387
|
+
label: ie(t),
|
|
396
388
|
component: "ATextInput",
|
|
397
389
|
fieldtype: "Data"
|
|
398
390
|
};
|
|
399
|
-
if (y && (i.required = !0),
|
|
400
|
-
if (
|
|
401
|
-
return i._unmapped = !0,
|
|
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;
|
|
402
394
|
if (r.name === "ID") {
|
|
403
|
-
const
|
|
404
|
-
if (
|
|
405
|
-
return i.component = "ALink", i.fieldtype = "Link", i.options = h(
|
|
395
|
+
const u = oe(t);
|
|
396
|
+
if (o.has(u))
|
|
397
|
+
return i.component = "ALink", i.fieldtype = "Link", i.options = h(u), i;
|
|
406
398
|
}
|
|
407
|
-
const
|
|
408
|
-
return
|
|
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;
|
|
409
401
|
}
|
|
410
|
-
if (
|
|
411
|
-
return i.component = "ADropdown", i.fieldtype = "Select", i.options = r.getValues().map((
|
|
412
|
-
if (
|
|
413
|
-
if (!d &&
|
|
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))
|
|
414
406
|
return i.component = "ALink", i.fieldtype = "Link", i.options = h(r.name), i;
|
|
415
|
-
const
|
|
416
|
-
return
|
|
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);
|
|
417
409
|
}
|
|
418
|
-
return i._unmapped = !0,
|
|
410
|
+
return i._unmapped = !0, a.includeUnmappedMeta && (i._graphqlType = r.name), i;
|
|
419
411
|
}
|
|
420
|
-
function
|
|
421
|
-
const
|
|
422
|
-
y && r.add(y.name), d && r.add(d.name),
|
|
423
|
-
const i = n.isEntityType ??
|
|
424
|
-
for (const [
|
|
425
|
-
|
|
426
|
-
let
|
|
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;
|
|
427
419
|
if (n.include) {
|
|
428
|
-
const
|
|
429
|
-
|
|
420
|
+
const c = new Set(n.include);
|
|
421
|
+
u = new Set([...s].filter((p) => c.has(p)));
|
|
430
422
|
}
|
|
431
423
|
if (n.exclude) {
|
|
432
|
-
const
|
|
433
|
-
|
|
424
|
+
const c = new Set(n.exclude);
|
|
425
|
+
u = new Set([...u].filter((p) => !c.has(p)));
|
|
434
426
|
}
|
|
435
|
-
const
|
|
436
|
-
for (const
|
|
437
|
-
const p =
|
|
438
|
-
if (!
|
|
439
|
-
const
|
|
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]) => {
|
|
440
432
|
if (n.classifyField) {
|
|
441
|
-
const f = n.classifyField(
|
|
433
|
+
const f = n.classifyField(l, g, p);
|
|
442
434
|
if (f != null)
|
|
443
435
|
return {
|
|
444
|
-
|
|
445
|
-
|
|
436
|
+
kind: "field",
|
|
437
|
+
fieldname: l,
|
|
438
|
+
label: f.label ?? l,
|
|
446
439
|
component: f.component ?? "ATextInput",
|
|
447
440
|
fieldtype: f.fieldtype ?? "Data",
|
|
448
441
|
...f
|
|
449
442
|
};
|
|
450
443
|
}
|
|
451
|
-
const
|
|
452
|
-
return
|
|
453
|
-
}),
|
|
454
|
-
target:
|
|
455
|
-
cardinality:
|
|
456
|
-
}, !1) : !0).map((
|
|
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) => {
|
|
457
450
|
if (!n.includeUnmappedMeta) {
|
|
458
|
-
const { _graphqlType: f, _unmapped:
|
|
459
|
-
return
|
|
451
|
+
const { _graphqlType: f, _unmapped: Te, _isLink: Fe, ...x } = l;
|
|
452
|
+
return x;
|
|
460
453
|
}
|
|
461
|
-
const { _isLink: g, ...
|
|
462
|
-
return
|
|
454
|
+
const { _isLink: g, ...F } = l;
|
|
455
|
+
return F;
|
|
463
456
|
}), S = {
|
|
464
|
-
name:
|
|
465
|
-
slug: h(
|
|
466
|
-
|
|
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
|
|
467
461
|
};
|
|
468
|
-
Object.keys(
|
|
462
|
+
Object.keys(A).length > 0 && (S.links = A), n.includeUnmappedMeta && (S._graphqlTypeName = c), I.push(S);
|
|
469
463
|
}
|
|
470
464
|
return I;
|
|
471
465
|
}
|
|
472
|
-
function
|
|
473
|
-
return typeof t == "string" ?
|
|
466
|
+
function ge(t) {
|
|
467
|
+
return typeof t == "string" ? U(t) : q(t);
|
|
474
468
|
}
|
|
475
469
|
export {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
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
|
|
501
500
|
};
|
|
502
|
-
//# sourceMappingURL=index-
|
|
501
|
+
//# sourceMappingURL=index-C5ANE_rn.js.map
|