@stonecrop/graphql-middleware 0.11.2 → 0.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/graphql-middleware.d.ts +2 -0
- package/dist/index.js +137 -131
- package/dist/index.js.map +1 -1
- package/dist/plugin/postgraphile.js +10 -3
- package/dist/src/plugin/postgraphile.d.ts.map +1 -1
- package/dist/src/types/query.d.ts +2 -0
- package/dist/src/types/query.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -286,6 +286,8 @@ export declare interface MergeNestedResultsParams {
|
|
|
286
286
|
meta: DoctypeMeta;
|
|
287
287
|
/** Lookup function to get doctype metadata by slug */
|
|
288
288
|
getMeta: (slug: string) => DoctypeMeta | undefined;
|
|
289
|
+
/** Function to derive the reverse connection field name from link params */
|
|
290
|
+
reverseConnectionNameFn?: (params: ReverseConnectionParams) => string;
|
|
289
291
|
}
|
|
290
292
|
|
|
291
293
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { readdirSync as
|
|
1
|
+
import { readdirSync as W, statSync as _, readFileSync as P } from "node:fs";
|
|
2
2
|
import { join as U } from "node:path";
|
|
3
3
|
import { validateDoctype as E, parseDoctype as I, toPascalCase as A, snakeToCamel as H } from "@stonecrop/schema";
|
|
4
4
|
import { loadOne as M, object as R, constant as Q, lambda as V } from "postgraphile/grafast";
|
|
5
5
|
import { extendSchema as z, gql as J } from "postgraphile/utils";
|
|
6
6
|
import j from "pluralize";
|
|
7
|
-
const
|
|
7
|
+
const N = /* @__PURE__ */ new Map();
|
|
8
8
|
class O extends Error {
|
|
9
9
|
constructor(t, n) {
|
|
10
|
-
const
|
|
10
|
+
const c = n.map((o) => ` ${o.path.join(".")}: ${o.message}`).join(`
|
|
11
11
|
`);
|
|
12
12
|
super(`Invalid doctype definition in ${t}:
|
|
13
|
-
${
|
|
13
|
+
${c}`), this.file = t, this.errors = n, this.name = "DoctypeValidationError";
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
function G(e, t = {}) {
|
|
17
|
-
const n =
|
|
18
|
-
for (const
|
|
19
|
-
const o = U(e,
|
|
20
|
-
_(o).isDirectory() ? G(o, t) :
|
|
17
|
+
const n = W(e);
|
|
18
|
+
for (const c of n) {
|
|
19
|
+
const o = U(e, c);
|
|
20
|
+
_(o).isDirectory() ? G(o, t) : c.endsWith(".json") && Y(o, t);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
function Y(e, t) {
|
|
24
24
|
const n = P(e, "utf-8");
|
|
25
|
-
let
|
|
25
|
+
let c;
|
|
26
26
|
try {
|
|
27
|
-
|
|
27
|
+
c = JSON.parse(n);
|
|
28
28
|
} catch (s) {
|
|
29
|
-
const
|
|
29
|
+
const i = {
|
|
30
30
|
path: [],
|
|
31
31
|
message: `Invalid JSON: ${s instanceof Error ? s.message : String(s)}`
|
|
32
32
|
};
|
|
33
33
|
if (t.continueOnError) {
|
|
34
|
-
t.onError?.(e, [
|
|
34
|
+
t.onError?.(e, [i]);
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
throw new O(e, [
|
|
37
|
+
throw new O(e, [i]);
|
|
38
38
|
}
|
|
39
|
-
const o = E(
|
|
39
|
+
const o = E(c);
|
|
40
40
|
if (!o.success) {
|
|
41
41
|
if (t.continueOnError) {
|
|
42
42
|
t.onError?.(e, o.errors);
|
|
@@ -44,12 +44,12 @@ function Y(e, t) {
|
|
|
44
44
|
}
|
|
45
45
|
throw new O(e, o.errors);
|
|
46
46
|
}
|
|
47
|
-
const r = I(
|
|
48
|
-
|
|
47
|
+
const r = I(c);
|
|
48
|
+
N.set(r.name, r);
|
|
49
49
|
}
|
|
50
50
|
function be(e, t = {}) {
|
|
51
|
-
for (const [n,
|
|
52
|
-
const o = { ...
|
|
51
|
+
for (const [n, c] of Object.entries(e)) {
|
|
52
|
+
const o = { ...c, name: n }, r = E(o);
|
|
53
53
|
if (!r.success) {
|
|
54
54
|
if (t.continueOnError) {
|
|
55
55
|
t.onError?.(n, r.errors);
|
|
@@ -58,30 +58,30 @@ function be(e, t = {}) {
|
|
|
58
58
|
throw new O(n, r.errors);
|
|
59
59
|
}
|
|
60
60
|
const s = I(o);
|
|
61
|
-
|
|
61
|
+
N.set(s.name, s);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
return
|
|
64
|
+
function k(e) {
|
|
65
|
+
return N.get(e);
|
|
66
66
|
}
|
|
67
67
|
function K() {
|
|
68
|
-
return Array.from(
|
|
68
|
+
return Array.from(N.values());
|
|
69
69
|
}
|
|
70
70
|
function Me(e) {
|
|
71
|
-
return
|
|
71
|
+
return N.has(e);
|
|
72
72
|
}
|
|
73
73
|
function Re() {
|
|
74
|
-
|
|
74
|
+
N.clear();
|
|
75
75
|
}
|
|
76
76
|
function Oe() {
|
|
77
77
|
const e = [];
|
|
78
|
-
for (const t of
|
|
79
|
-
t.inherits && !
|
|
78
|
+
for (const t of N.values()) {
|
|
79
|
+
t.inherits && !N.has(t.inherits) && e.push({
|
|
80
80
|
path: [t.name, "inherits"],
|
|
81
81
|
message: `References unknown doctype: ${t.inherits}`
|
|
82
82
|
});
|
|
83
83
|
for (const n of t.fields)
|
|
84
|
-
n.fieldtype === "Link" && typeof n.options == "string" && (
|
|
84
|
+
n.fieldtype === "Link" && typeof n.options == "string" && (N.has(n.options) || e.push({
|
|
85
85
|
path: [t.name, "fields", n.fieldname, "options"],
|
|
86
86
|
message: `Link references unknown doctype: ${n.options}`
|
|
87
87
|
}));
|
|
@@ -98,29 +98,29 @@ function Z(e) {
|
|
|
98
98
|
function Ae(e) {
|
|
99
99
|
return b.has(e);
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function Fe() {
|
|
102
102
|
b.clear();
|
|
103
103
|
}
|
|
104
104
|
const ee = async (e, t) => {
|
|
105
|
-
const [n] = e, { doctype:
|
|
106
|
-
for (const r of
|
|
105
|
+
const [n] = e, { doctype: c } = t, o = [];
|
|
106
|
+
for (const r of c.fields)
|
|
107
107
|
r.required && (n[r.fieldname] === void 0 || n[r.fieldname] === null) && o.push(r.label ?? r.fieldname);
|
|
108
108
|
if (o.length > 0)
|
|
109
109
|
throw new Error(`Missing required fields: ${o.join(", ")}`);
|
|
110
110
|
return { valid: !0 };
|
|
111
111
|
}, te = async (e, t) => {
|
|
112
|
-
const [n] = e, { doctype:
|
|
113
|
-
for (const r of
|
|
112
|
+
const [n] = e, { doctype: c } = t, o = [];
|
|
113
|
+
for (const r of c.fields) {
|
|
114
114
|
const s = n[r.fieldname];
|
|
115
115
|
if (s == null) continue;
|
|
116
|
-
const
|
|
117
|
-
|
|
116
|
+
const i = ne(r, s);
|
|
117
|
+
i && o.push(i);
|
|
118
118
|
}
|
|
119
|
-
if (
|
|
120
|
-
for (const [r, s] of Object.entries(
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
123
|
-
s.cardinality === "noneOrMany" || s.cardinality === "atLeastOne" ? Array.isArray(
|
|
119
|
+
if (c.links)
|
|
120
|
+
for (const [r, s] of Object.entries(c.links)) {
|
|
121
|
+
const i = n[r];
|
|
122
|
+
if (i == null) continue;
|
|
123
|
+
s.cardinality === "noneOrMany" || s.cardinality === "atLeastOne" ? Array.isArray(i) || o.push(`${r}: expected array, got ${typeof i}`) : (typeof i != "object" || Array.isArray(i)) && o.push(`${r}: expected object, got ${typeof i}`);
|
|
124
124
|
}
|
|
125
125
|
if (o.length > 0)
|
|
126
126
|
throw new Error(`Field type validation failed:
|
|
@@ -129,8 +129,8 @@ ${o.join(`
|
|
|
129
129
|
return { valid: !0 };
|
|
130
130
|
};
|
|
131
131
|
function ne(e, t) {
|
|
132
|
-
const { fieldname: n, fieldtype:
|
|
133
|
-
switch (
|
|
132
|
+
const { fieldname: n, fieldtype: c, cardinality: o } = e;
|
|
133
|
+
switch (c) {
|
|
134
134
|
case "Int":
|
|
135
135
|
if (typeof t != "number" || !Number.isInteger(t))
|
|
136
136
|
return `${n}: expected integer, got ${typeof t}`;
|
|
@@ -171,12 +171,12 @@ const oe = async () => ({ ok: !0 }), re = {
|
|
|
171
171
|
validateFieldTypes: te,
|
|
172
172
|
noop: oe
|
|
173
173
|
};
|
|
174
|
-
function
|
|
174
|
+
function Be() {
|
|
175
175
|
for (const [e, t] of Object.entries(re))
|
|
176
176
|
X(e, t);
|
|
177
177
|
}
|
|
178
|
-
const
|
|
179
|
-
const t = e.inflection?.recordFieldName ?? ie, n = e.inflection?.connectionFieldName ?? ce,
|
|
178
|
+
const De = (e) => {
|
|
179
|
+
const t = e.inflection?.recordFieldName ?? ie, n = e.inflection?.connectionFieldName ?? ce, c = e.inflection?.orderByTypeName ?? se, o = e.inflection?.recordArgName ?? ae, r = e.inflection?.recordArgType ?? le, s = e.inflection?.reverseConnectionName ?? F;
|
|
180
180
|
return z(() => ({
|
|
181
181
|
typeDefs: J`
|
|
182
182
|
type StonecropFieldMeta {
|
|
@@ -260,60 +260,65 @@ const Fe = (e) => {
|
|
|
260
260
|
objects: {
|
|
261
261
|
Query: {
|
|
262
262
|
plans: {
|
|
263
|
-
stonecropMeta(
|
|
264
|
-
return V(l, (y) =>
|
|
263
|
+
stonecropMeta(i, { $doctype: l }) {
|
|
264
|
+
return V(l, (y) => k(y) ?? null);
|
|
265
265
|
},
|
|
266
266
|
stonecropAllMeta() {
|
|
267
267
|
return Q(K());
|
|
268
268
|
},
|
|
269
|
-
stonecropRecord(
|
|
269
|
+
stonecropRecord(i, { $doctype: l, $id: y, $options: p }) {
|
|
270
270
|
return M(
|
|
271
271
|
R({ doctype: l, id: y, options: p }),
|
|
272
272
|
async (d) => await Promise.all(
|
|
273
|
-
d.map(async (
|
|
274
|
-
const
|
|
275
|
-
if (!
|
|
276
|
-
throw new Error(`Unknown doctype: ${
|
|
277
|
-
if (!
|
|
278
|
-
throw new Error(`Doctype ${
|
|
279
|
-
const a =
|
|
280
|
-
|
|
273
|
+
d.map(async (f) => {
|
|
274
|
+
const u = k(f.doctype);
|
|
275
|
+
if (!u)
|
|
276
|
+
throw new Error(`Unknown doctype: ${f.doctype}`);
|
|
277
|
+
if (!u.tableName)
|
|
278
|
+
throw new Error(`Doctype ${f.doctype} has no table mapping`);
|
|
279
|
+
const a = f.options ?? {}, h = ue(
|
|
280
|
+
u,
|
|
281
281
|
t,
|
|
282
282
|
o,
|
|
283
283
|
r,
|
|
284
|
-
|
|
284
|
+
k,
|
|
285
285
|
a.includeNested ? {
|
|
286
286
|
includeNested: a.includeNested,
|
|
287
287
|
maxDepth: a.maxDepth
|
|
288
288
|
} : void 0,
|
|
289
289
|
s
|
|
290
290
|
), g = await e.executor.query(h, {
|
|
291
|
-
[o(
|
|
291
|
+
[o(u.tableName)]: f.id
|
|
292
292
|
});
|
|
293
|
-
let S = ge({ result: g, meta:
|
|
294
|
-
a.includeNested && S &&
|
|
295
|
-
|
|
293
|
+
let S = ge({ result: g, meta: u, recordFieldName: t });
|
|
294
|
+
a.includeNested && S && u.links && (S = ye({
|
|
295
|
+
record: S,
|
|
296
|
+
meta: u,
|
|
297
|
+
getMeta: k,
|
|
298
|
+
reverseConnectionNameFn: s
|
|
299
|
+
}));
|
|
300
|
+
const m = Array.isArray(a.includeNested) && u.links ? a.includeNested.filter((w) => !(w in u.links)) : void 0;
|
|
296
301
|
return {
|
|
297
302
|
data: S,
|
|
298
|
-
doctype:
|
|
303
|
+
doctype: f.doctype,
|
|
299
304
|
...m ? { unknownLinks: m } : {}
|
|
300
305
|
};
|
|
301
306
|
})
|
|
302
307
|
)
|
|
303
308
|
);
|
|
304
309
|
},
|
|
305
|
-
stonecropRecords(
|
|
310
|
+
stonecropRecords(i, { $doctype: l, $filters: y, $orderBy: p, $limit: d, $offset: f }) {
|
|
306
311
|
return M(
|
|
307
312
|
R({
|
|
308
313
|
doctype: l,
|
|
309
314
|
filters: y,
|
|
310
315
|
orderBy: p,
|
|
311
316
|
limit: d,
|
|
312
|
-
offset:
|
|
317
|
+
offset: f
|
|
313
318
|
}),
|
|
314
|
-
async (
|
|
315
|
-
|
|
316
|
-
const h =
|
|
319
|
+
async (u) => await Promise.all(
|
|
320
|
+
u.map(async (a) => {
|
|
321
|
+
const h = k(a.doctype);
|
|
317
322
|
if (!h)
|
|
318
323
|
throw new Error(`Unknown doctype: ${a.doctype}`);
|
|
319
324
|
if (!h.tableName)
|
|
@@ -326,7 +331,7 @@ const Fe = (e) => {
|
|
|
326
331
|
orderBy: a.orderBy
|
|
327
332
|
},
|
|
328
333
|
n,
|
|
329
|
-
|
|
334
|
+
c
|
|
330
335
|
), S = await e.executor.query(g, {
|
|
331
336
|
limit: a.limit,
|
|
332
337
|
offset: a.offset,
|
|
@@ -345,7 +350,7 @@ const Fe = (e) => {
|
|
|
345
350
|
},
|
|
346
351
|
Mutation: {
|
|
347
352
|
plans: {
|
|
348
|
-
stonecropAction(
|
|
353
|
+
stonecropAction(i, { $doctype: l, $action: y, $args: p }) {
|
|
349
354
|
return M(
|
|
350
355
|
R({
|
|
351
356
|
doctype: l,
|
|
@@ -353,20 +358,20 @@ const Fe = (e) => {
|
|
|
353
358
|
actionArgs: p
|
|
354
359
|
}),
|
|
355
360
|
async (d) => await Promise.all(
|
|
356
|
-
d.map(async (
|
|
357
|
-
const
|
|
358
|
-
if (!
|
|
361
|
+
d.map(async (f) => {
|
|
362
|
+
const u = k(f.doctype);
|
|
363
|
+
if (!u)
|
|
359
364
|
return {
|
|
360
365
|
success: !1,
|
|
361
366
|
data: null,
|
|
362
|
-
error: `Unknown doctype: ${
|
|
367
|
+
error: `Unknown doctype: ${f.doctype}`
|
|
363
368
|
};
|
|
364
|
-
const a =
|
|
369
|
+
const a = u.workflow?.actions?.[f.action];
|
|
365
370
|
if (!a)
|
|
366
371
|
return {
|
|
367
372
|
success: !1,
|
|
368
373
|
data: null,
|
|
369
|
-
error: `Unknown action: ${
|
|
374
|
+
error: `Unknown action: ${f.action} on ${f.doctype}`
|
|
370
375
|
};
|
|
371
376
|
const h = a.handler, g = Z(h);
|
|
372
377
|
if (!g)
|
|
@@ -376,13 +381,13 @@ const Fe = (e) => {
|
|
|
376
381
|
error: `Handler not registered: ${h}`
|
|
377
382
|
};
|
|
378
383
|
const S = {
|
|
379
|
-
doctype:
|
|
384
|
+
doctype: u,
|
|
380
385
|
executor: e.executor
|
|
381
386
|
};
|
|
382
387
|
try {
|
|
383
388
|
return {
|
|
384
389
|
success: !0,
|
|
385
|
-
data: await g(
|
|
390
|
+
data: await g(f.actionArgs ?? [], S),
|
|
386
391
|
error: null
|
|
387
392
|
};
|
|
388
393
|
} catch (m) {
|
|
@@ -417,107 +422,107 @@ function ae(e) {
|
|
|
417
422
|
function le(e) {
|
|
418
423
|
return "UUID!";
|
|
419
424
|
}
|
|
420
|
-
function
|
|
421
|
-
const t = j.plural(e.target.replace(/-/g, "_")), n = A(t),
|
|
425
|
+
function F(e) {
|
|
426
|
+
const t = j.plural(e.target.replace(/-/g, "_")), n = A(t), c = e.backlink || e.doctype, o = c.charAt(0).toUpperCase() + c.slice(1);
|
|
422
427
|
return `${n}By${o}Id`;
|
|
423
428
|
}
|
|
424
|
-
function
|
|
429
|
+
function B(e) {
|
|
425
430
|
return e === "noneOrMany" || e === "atLeastOne";
|
|
426
431
|
}
|
|
427
432
|
const q = 50, de = /* @__PURE__ */ new Set(["Link"]);
|
|
428
|
-
function
|
|
433
|
+
function D(e) {
|
|
429
434
|
return e.fields.filter((t) => !de.has(t.fieldtype)).map((t) => t.fieldname).join(`
|
|
430
435
|
`);
|
|
431
436
|
}
|
|
432
437
|
function T(e) {
|
|
433
|
-
return e.fetch !== void 0 ? e.fetch :
|
|
438
|
+
return e.fetch !== void 0 ? e.fetch : B(e.cardinality) ? { method: "sync", limit: q } : { method: "lazy" };
|
|
434
439
|
}
|
|
435
440
|
function fe(e) {
|
|
436
441
|
return e.blockWorkflows !== void 0 ? e.blockWorkflows : T(e).method === "sync";
|
|
437
442
|
}
|
|
438
|
-
function
|
|
439
|
-
const { links: t, meta: n, includeSet:
|
|
440
|
-
if (
|
|
443
|
+
function C(e) {
|
|
444
|
+
const { links: t, meta: n, includeSet: c, getMeta: o, seen: r, depth: s, maxDepth: i, reverseConnectionNameFn: l } = e;
|
|
445
|
+
if (i !== void 0 && s >= i) return "";
|
|
441
446
|
const y = [];
|
|
442
447
|
for (const [p, d] of Object.entries(t)) {
|
|
443
|
-
if (
|
|
444
|
-
const
|
|
445
|
-
if (
|
|
448
|
+
if (i !== void 0 && s >= i) break;
|
|
449
|
+
const f = fe(d), u = d.blockWorkflows === !0;
|
|
450
|
+
if (c && !c.has(p) && !u)
|
|
446
451
|
continue;
|
|
447
452
|
const a = T(d);
|
|
448
|
-
if (
|
|
453
|
+
if (f === !1 || a.method !== "sync" && !u)
|
|
449
454
|
continue;
|
|
450
455
|
const g = o(d.target);
|
|
451
456
|
if (!g) continue;
|
|
452
457
|
const S = r.has(d.target);
|
|
453
458
|
S || r.add(d.target);
|
|
454
|
-
const m =
|
|
459
|
+
const m = D(g);
|
|
455
460
|
let w = "";
|
|
456
|
-
if (!S && g.links && g.tableName && (
|
|
457
|
-
const $ =
|
|
461
|
+
if (!S && g.links && g.tableName && (i === void 0 || s + 1 < i)) {
|
|
462
|
+
const $ = C({
|
|
458
463
|
links: g.links,
|
|
459
464
|
meta: g,
|
|
460
465
|
includeSet: null,
|
|
461
466
|
getMeta: o,
|
|
462
467
|
seen: r,
|
|
463
468
|
depth: s + 1,
|
|
464
|
-
maxDepth:
|
|
469
|
+
maxDepth: i,
|
|
465
470
|
reverseConnectionNameFn: l
|
|
466
471
|
});
|
|
467
472
|
$ && (w = `
|
|
468
473
|
` + $), r.delete(d.target);
|
|
469
474
|
}
|
|
470
|
-
const
|
|
471
|
-
if (
|
|
475
|
+
const v = m + w;
|
|
476
|
+
if (B(d.cardinality)) {
|
|
472
477
|
const $ = {
|
|
473
478
|
doctype: n.slug || n.name,
|
|
474
479
|
linkName: p,
|
|
475
480
|
backlink: d.backlink,
|
|
476
481
|
target: d.target
|
|
477
|
-
},
|
|
482
|
+
}, L = l ? l($) : F($), x = a.method === "sync" && a.limit !== void 0 ? `first: ${a.limit}` : a.method === "sync" ? `first: ${q}` : "";
|
|
478
483
|
y.push(`
|
|
479
|
-
${
|
|
484
|
+
${L}${x ? `(${x})` : ""} {
|
|
480
485
|
nodes {
|
|
481
|
-
${
|
|
486
|
+
${v}
|
|
482
487
|
}
|
|
483
488
|
}`);
|
|
484
489
|
} else
|
|
485
490
|
y.push(`
|
|
486
491
|
${p} {
|
|
487
|
-
${
|
|
492
|
+
${v}
|
|
488
493
|
}`);
|
|
489
494
|
}
|
|
490
495
|
return y.join("");
|
|
491
496
|
}
|
|
492
|
-
function ue(e, t, n,
|
|
493
|
-
const
|
|
494
|
-
let d =
|
|
497
|
+
function ue(e, t, n, c, o, r, s) {
|
|
498
|
+
const i = t(e.tableName), l = n(e.tableName), y = c(e.tableName), p = /* @__PURE__ */ new Set([e.slug || e.name]);
|
|
499
|
+
let d = D(e);
|
|
495
500
|
if (r?.includeNested && e.links) {
|
|
496
|
-
const
|
|
501
|
+
const f = Array.isArray(r.includeNested) ? new Set(r.includeNested) : null, u = C({
|
|
497
502
|
links: e.links,
|
|
498
503
|
meta: e,
|
|
499
|
-
includeSet:
|
|
504
|
+
includeSet: f,
|
|
500
505
|
getMeta: o,
|
|
501
506
|
seen: p,
|
|
502
507
|
depth: 0,
|
|
503
508
|
maxDepth: r.maxDepth,
|
|
504
509
|
reverseConnectionNameFn: s
|
|
505
510
|
});
|
|
506
|
-
|
|
507
|
-
` +
|
|
511
|
+
u && (d += `
|
|
512
|
+
` + u);
|
|
508
513
|
}
|
|
509
514
|
return `
|
|
510
515
|
query GetRecord($${l}: ${y}) {
|
|
511
|
-
${
|
|
516
|
+
${i}(${l}: $${l}) {
|
|
512
517
|
${d}
|
|
513
518
|
}
|
|
514
519
|
}
|
|
515
520
|
`;
|
|
516
521
|
}
|
|
517
|
-
function pe(e, t, n,
|
|
518
|
-
const o =
|
|
519
|
-
t.limit && (
|
|
520
|
-
const y =
|
|
522
|
+
function pe(e, t, n, c) {
|
|
523
|
+
const o = D(e), r = n(e.tableName), s = c(e.tableName), i = [], l = [];
|
|
524
|
+
t.limit && (i.push("$limit: Int"), l.push("first: $limit")), t.offset && (i.push("$offset: Int"), l.push("offset: $offset")), t.orderBy && (i.push(`$orderBy: [${s}!]`), l.push("orderBy: $orderBy"));
|
|
525
|
+
const y = i.length > 0 ? `(${i.join(", ")})` : "", p = l.length > 0 ? `(${l.join(", ")})` : "";
|
|
521
526
|
return `
|
|
522
527
|
query GetRecords${y} {
|
|
523
528
|
${r}${p} {
|
|
@@ -529,30 +534,31 @@ function pe(e, t, n, i) {
|
|
|
529
534
|
`;
|
|
530
535
|
}
|
|
531
536
|
function ye(e) {
|
|
532
|
-
const { record: t, meta: n, getMeta:
|
|
537
|
+
const { record: t, meta: n, getMeta: c, reverseConnectionNameFn: o } = e;
|
|
533
538
|
if (!n.links) return t;
|
|
534
|
-
const
|
|
535
|
-
for (const [
|
|
536
|
-
if (
|
|
537
|
-
if (!i
|
|
538
|
-
const
|
|
539
|
+
const r = { ...t };
|
|
540
|
+
for (const [s, i] of Object.entries(n.links))
|
|
541
|
+
if (B(i.cardinality)) {
|
|
542
|
+
if (!c(i.target)) continue;
|
|
543
|
+
const p = {
|
|
539
544
|
doctype: n.slug || n.name,
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
d
|
|
545
|
+
linkName: s,
|
|
546
|
+
backlink: i.backlink || s,
|
|
547
|
+
target: i.target
|
|
548
|
+
}, d = o ? o(p) : F(p), f = r[d];
|
|
549
|
+
f?.nodes ? (r[s] = f.nodes, delete r[d]) : (r[s] = [], delete r[d]);
|
|
544
550
|
}
|
|
545
|
-
return
|
|
551
|
+
return r;
|
|
546
552
|
}
|
|
547
553
|
function ge(e) {
|
|
548
|
-
const { result: t, meta: n, recordFieldName:
|
|
554
|
+
const { result: t, meta: n, recordFieldName: c } = e, o = c(n.tableName);
|
|
549
555
|
return t[o];
|
|
550
556
|
}
|
|
551
557
|
function me(e) {
|
|
552
|
-
const { result: t, meta: n, connectionFieldName:
|
|
558
|
+
const { result: t, meta: n, connectionFieldName: c } = e, o = c(n.tableName);
|
|
553
559
|
return t[o]?.nodes ?? [];
|
|
554
560
|
}
|
|
555
|
-
const
|
|
561
|
+
const ve = J`
|
|
556
562
|
type StonecropFieldMeta {
|
|
557
563
|
fieldname: String!
|
|
558
564
|
fieldtype: String!
|
|
@@ -631,29 +637,29 @@ export {
|
|
|
631
637
|
pe as buildListQuery,
|
|
632
638
|
ue as buildRecordQuery,
|
|
633
639
|
re as builtinHandlers,
|
|
634
|
-
|
|
640
|
+
Fe as clearHandlers,
|
|
635
641
|
Re as clearRegistry,
|
|
636
|
-
|
|
642
|
+
De as createStonecropPlugin,
|
|
637
643
|
ce as defaultConnectionFieldName,
|
|
638
644
|
se as defaultOrderByTypeName,
|
|
639
645
|
ae as defaultRecordArgName,
|
|
640
646
|
le as defaultRecordArgType,
|
|
641
647
|
ie as defaultRecordFieldName,
|
|
642
|
-
|
|
648
|
+
F as defaultReverseConnectionName,
|
|
643
649
|
me as extractListResult,
|
|
644
650
|
ge as extractSingleResult,
|
|
645
651
|
K as getAllMeta,
|
|
646
652
|
Z as getHandler,
|
|
647
|
-
|
|
653
|
+
k as getMeta,
|
|
648
654
|
Ae as hasHandler,
|
|
649
655
|
Me as hasMeta,
|
|
650
656
|
G as loadDoctypes,
|
|
651
657
|
be as loadDoctypesFromObject,
|
|
652
658
|
ye as mergeNestedResults,
|
|
653
|
-
|
|
654
|
-
|
|
659
|
+
D as queryableFieldNames,
|
|
660
|
+
Be as registerBuiltinHandlers,
|
|
655
661
|
X as registerHandler,
|
|
656
|
-
|
|
662
|
+
ve as typeDefs,
|
|
657
663
|
Oe as validateReferences
|
|
658
664
|
};
|
|
659
665
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/registry/doctypes.ts","../src/registry/actions.ts","../src/plugin/postgraphile.ts","../src/typeDefs.ts"],"sourcesContent":["import { readFileSync, readdirSync, statSync } from 'node:fs'\nimport { join } from 'node:path'\n\nimport { parseDoctype, validateDoctype } from '@stonecrop/schema'\nimport type { DoctypeMeta, ValidationError } from '@stonecrop/schema'\n\nconst doctypeRegistry: Map<string, DoctypeMeta> = new Map()\n\n/**\n * Error thrown when a doctype definition fails validation\n * @public\n */\nexport class DoctypeValidationError extends Error {\n\tconstructor(\n\t\t/** File path or name where the validation error occurred */\n\t\tpublic readonly file: string,\n\t\t/** List of validation errors found */\n\t\tpublic readonly errors: ValidationError[]\n\t) {\n\t\tconst errorMessages = errors.map(e => ` ${e.path.join('.')}: ${e.message}`).join('\\n')\n\t\tsuper(`Invalid doctype definition in ${file}:\\n${errorMessages}`)\n\t\tthis.name = 'DoctypeValidationError'\n\t}\n}\n\n/**\n * Options for loading doctype definitions\n * @public\n */\nexport interface LoadDoctypesOptions {\n\t/** Continue loading other files if one fails validation */\n\tcontinueOnError?: boolean\n\t/** Callback for validation errors when continueOnError is true */\n\tonError?: (file: string, errors: ValidationError[]) => void\n}\n\n/**\n * Load doctype definitions from a directory of JSON files\n * @param dir - Directory path containing doctype JSON files\n * @param options - Options for loading doctypes (continueOnError, onError callback)\n * @public\n */\nexport function loadDoctypes(dir: string, options: LoadDoctypesOptions = {}): void {\n\tconst entries = readdirSync(dir)\n\n\tfor (const entry of entries) {\n\t\tconst fullPath = join(dir, entry)\n\t\tconst stat = statSync(fullPath)\n\n\t\tif (stat.isDirectory()) {\n\t\t\tloadDoctypes(fullPath, options)\n\t\t} else if (entry.endsWith('.json')) {\n\t\t\tloadDoctypeFile(fullPath, options)\n\t\t}\n\t}\n}\n\n/**\n * Load and validate a single doctype file\n */\nfunction loadDoctypeFile(filePath: string, options: LoadDoctypesOptions): void {\n\tconst content = readFileSync(filePath, 'utf-8')\n\tlet data: unknown\n\n\ttry {\n\t\tdata = JSON.parse(content)\n\t} catch (err) {\n\t\tconst parseError: ValidationError = {\n\t\t\tpath: [],\n\t\t\tmessage: `Invalid JSON: ${err instanceof Error ? err.message : String(err)}`,\n\t\t}\n\n\t\tif (options.continueOnError) {\n\t\t\toptions.onError?.(filePath, [parseError])\n\t\t\treturn\n\t\t}\n\t\tthrow new DoctypeValidationError(filePath, [parseError])\n\t}\n\n\tconst result = validateDoctype(data)\n\n\tif (!result.success) {\n\t\tif (options.continueOnError) {\n\t\t\toptions.onError?.(filePath, result.errors)\n\t\t\treturn\n\t\t}\n\t\tthrow new DoctypeValidationError(filePath, result.errors)\n\t}\n\n\tconst doctype = parseDoctype(data)\n\tdoctypeRegistry.set(doctype.name, doctype)\n}\n\n/**\n * Load doctypes from an object (for programmatic use)\n * @param doctypes - Object mapping doctype names to doctype definitions\n * @param options - Options for loading doctypes (continueOnError, onError callback)\n * @public\n */\nexport function loadDoctypesFromObject(doctypes: Record<string, unknown>, options: LoadDoctypesOptions = {}): void {\n\tfor (const [name, data] of Object.entries(doctypes)) {\n\t\tconst withName = { ...(data as object), name }\n\t\tconst result = validateDoctype(withName)\n\n\t\tif (!result.success) {\n\t\t\tif (options.continueOnError) {\n\t\t\t\toptions.onError?.(name, result.errors)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tthrow new DoctypeValidationError(name, result.errors)\n\t\t}\n\n\t\tconst doctype = parseDoctype(withName)\n\t\tdoctypeRegistry.set(doctype.name, doctype)\n\t}\n}\n\n/**\n * Get a doctype by name\n * @param name - Name of the doctype to retrieve\n * @public\n */\nexport function getMeta(name: string): DoctypeMeta | undefined {\n\treturn doctypeRegistry.get(name)\n}\n\n/**\n * Get all loaded doctypes\n * @public\n */\nexport function getAllMeta(): DoctypeMeta[] {\n\treturn Array.from(doctypeRegistry.values())\n}\n\n/**\n * Check if a doctype is registered\n * @param name - Name of the doctype to check\n * @public\n */\nexport function hasMeta(name: string): boolean {\n\treturn doctypeRegistry.has(name)\n}\n\n/**\n * Clear all registered doctypes\n * @public\n */\nexport function clearRegistry(): void {\n\tdoctypeRegistry.clear()\n}\n\n/**\n * Validate cross-doctype references (Link fields, inherits, etc.)\n * Call after all doctypes are loaded.\n * @public\n */\nexport function validateReferences(): ValidationError[] {\n\tconst errors: ValidationError[] = []\n\n\tfor (const doctype of doctypeRegistry.values()) {\n\t\t// Check inherits reference\n\t\tif (doctype.inherits && !doctypeRegistry.has(doctype.inherits)) {\n\t\t\terrors.push({\n\t\t\t\tpath: [doctype.name, 'inherits'],\n\t\t\t\tmessage: `References unknown doctype: ${doctype.inherits}`,\n\t\t\t})\n\t\t}\n\n\t\t// Check Link field targets\n\t\tfor (const field of doctype.fields) {\n\t\t\tif (field.fieldtype === 'Link' && typeof field.options === 'string') {\n\t\t\t\tif (!doctypeRegistry.has(field.options)) {\n\t\t\t\t\terrors.push({\n\t\t\t\t\t\tpath: [doctype.name, 'fields', field.fieldname, 'options'],\n\t\t\t\t\t\tmessage: `Link references unknown doctype: ${field.options}`,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn errors\n}\n","import type { DoctypeMeta, FieldMeta } from '@stonecrop/schema'\nimport type { ActionHandler, ActionContext } from '../types'\n\nconst handlerRegistry: Map<string, ActionHandler> = new Map()\n\n/**\n * Register an action handler\n * @param name - Unique name for the action handler\n * @param handler - Action handler function to register\n * @public\n */\nexport function registerHandler(name: string, handler: ActionHandler): void {\n\thandlerRegistry.set(name, handler)\n}\n\n/**\n * Get a registered handler by name\n * @param name - Name of the action handler to retrieve\n * @public\n */\nexport function getHandler(name: string): ActionHandler | undefined {\n\treturn handlerRegistry.get(name)\n}\n\n/**\n * Check if a handler is registered\n * @param name - Name of the action handler to check\n * @public\n */\nexport function hasHandler(name: string): boolean {\n\treturn handlerRegistry.has(name)\n}\n\n/**\n * Clear all registered handlers\n * @public\n */\nexport function clearHandlers(): void {\n\thandlerRegistry.clear()\n}\n\n// =============================================================================\n// Built-in Handlers\n// =============================================================================\n\n/**\n * Validate that all required fields are present in a record\n */\nconst validateRequiredFields: ActionHandler = async (args, context) => {\n\tconst [record] = args as [Record<string, unknown>]\n\tconst { doctype } = context\n\n\tconst missing: string[] = []\n\tfor (const field of doctype.fields) {\n\t\tif (field.required && (record[field.fieldname] === undefined || record[field.fieldname] === null)) {\n\t\t\tmissing.push(field.label ?? field.fieldname)\n\t\t}\n\t}\n\n\tif (missing.length > 0) {\n\t\tthrow new Error(`Missing required fields: ${missing.join(', ')}`)\n\t}\n\n\treturn { valid: true }\n}\n\n/**\n * Validate field types match expected types\n */\nconst validateFieldTypes: ActionHandler = async (args, context) => {\n\tconst [record] = args as [Record<string, unknown>]\n\tconst { doctype } = context\n\n\tconst errors: string[] = []\n\n\tfor (const field of doctype.fields) {\n\t\tconst value = record[field.fieldname]\n\t\tif (value === undefined || value === null) continue\n\n\t\tconst error = validateFieldValue(field, value)\n\t\tif (error) errors.push(error)\n\t}\n\n\t// Validate link fields\n\tif (doctype.links) {\n\t\tfor (const [fieldname, link] of Object.entries(doctype.links)) {\n\t\t\tconst value = record[fieldname]\n\t\t\tif (value === undefined || value === null) continue\n\n\t\t\tconst isMany = link.cardinality === 'noneOrMany' || link.cardinality === 'atLeastOne'\n\t\t\tif (isMany) {\n\t\t\t\tif (!Array.isArray(value)) {\n\t\t\t\t\terrors.push(`${fieldname}: expected array, got ${typeof value}`)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (typeof value !== 'object' || Array.isArray(value)) {\n\t\t\t\t\terrors.push(`${fieldname}: expected object, got ${typeof value}`)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (errors.length > 0) {\n\t\tthrow new Error(`Field type validation failed:\\n${errors.join('\\n')}`)\n\t}\n\n\treturn { valid: true }\n}\n\n/**\n * Validate a single field value against its expected type\n */\nfunction validateFieldValue(field: FieldMeta, value: unknown): string | null {\n\tconst { fieldname, fieldtype, cardinality } = field\n\n\tswitch (fieldtype) {\n\t\tcase 'Int':\n\t\t\tif (typeof value !== 'number' || !Number.isInteger(value)) {\n\t\t\t\treturn `${fieldname}: expected integer, got ${typeof value}`\n\t\t\t}\n\t\t\tbreak\n\n\t\tcase 'Float':\n\t\tcase 'Decimal':\n\t\tcase 'Currency':\n\t\tcase 'Quantity':\n\t\t\tif (typeof value !== 'number' && typeof value !== 'string') {\n\t\t\t\treturn `${fieldname}: expected number, got ${typeof value}`\n\t\t\t}\n\t\t\tbreak\n\n\t\tcase 'Check':\n\t\t\tif (typeof value !== 'boolean') {\n\t\t\t\treturn `${fieldname}: expected boolean, got ${typeof value}`\n\t\t\t}\n\t\t\tbreak\n\n\t\tcase 'Data':\n\t\tcase 'Text':\n\t\tcase 'Code':\n\t\tcase 'Link':\n\t\t\tif (typeof value !== 'string') {\n\t\t\t\treturn `${fieldname}: expected string, got ${typeof value}`\n\t\t\t}\n\t\t\tbreak\n\n\t\tcase 'Date':\n\t\tcase 'Time':\n\t\tcase 'Datetime':\n\t\t\tif (typeof value !== 'string' && !(value instanceof Date)) {\n\t\t\t\treturn `${fieldname}: expected date string or Date, got ${typeof value}`\n\t\t\t}\n\t\t\tbreak\n\n\t\tcase 'JSON':\n\t\t\tif (typeof value !== 'object') {\n\t\t\t\treturn `${fieldname}: expected object, got ${typeof value}`\n\t\t\t}\n\t\t\tbreak\n\t}\n\n\treturn null\n}\n\n/**\n * No-op handler for testing or placeholder actions\n */\nconst noop: ActionHandler = async () => {\n\treturn { ok: true }\n}\n\n/**\n * Built-in handlers available for registration\n * @public\n */\nexport const builtinHandlers: Record<string, ActionHandler> = {\n\tvalidateRequiredFields,\n\tvalidateFieldTypes,\n\tnoop,\n}\n\n/**\n * Register all built-in handlers\n * @public\n */\nexport function registerBuiltinHandlers(): void {\n\tfor (const [name, handler] of Object.entries(builtinHandlers)) {\n\t\tregisterHandler(name, handler)\n\t}\n}\n","import type { DoctypeMeta, LinkDeclaration, LazyFetch, SyncFetch } from '@stonecrop/schema'\nimport { snakeToCamel, toPascalCase } from '@stonecrop/schema'\nimport { constant, lambda, object, loadOne } from 'postgraphile/grafast'\nimport { GraphileConfig } from 'postgraphile/graphile-build'\nimport { extendSchema, gql } from 'postgraphile/utils'\nimport pluralize from 'pluralize'\n\nimport { getHandler, registerHandler } from '../registry/actions'\nimport { getMeta, getAllMeta } from '../registry/doctypes'\nimport type {\n\tActionContext,\n\tGraphQLExecutor,\n\tReverseConnectionParams,\n\tBuildRecordQueryOptions,\n\tBuildNestedSelectionsParams,\n\tBuildListQueryArgs,\n\tMergeNestedResultsParams,\n\tExtractSingleResultParams,\n\tExtractListResultParams,\n} from '../types'\n\n/**\n * Inflection callbacks for mapping table names to GraphQL query field names.\n * Override these when using a non-Amber inflection preset (e.g., V4, SimplifyInflection).\n *\n * Defaults match the PostGraphile Amber preset conventions.\n * @public\n */\nexport interface StonecropInflectionConfig {\n\t/**\n\t * Given a table name, return the GraphQL field name for fetching a single record by ID.\n\t * @example Amber default: \"sales_orders\" → \"salesOrderById\"\n\t * @example V4 preset: \"sales_orders\" → \"salesOrderByRowId\"\n\t */\n\trecordFieldName?: (tableName: string) => string\n\n\t/**\n\t * Given a table name, return the GraphQL field name for fetching a list/connection.\n\t * @example Amber default: \"sales_orders\" → \"allSalesOrders\"\n\t * @example SimplifyInflection: \"sales_orders\" → \"salesOrders\"\n\t */\n\tconnectionFieldName?: (tableName: string) => string\n\n\t/**\n\t * Given a table name, return the GraphQL OrderBy enum type name.\n\t * @example Amber default: \"sales_orders\" → \"SalesOrdersOrderBy\"\n\t */\n\torderByTypeName?: (tableName: string) => string\n\n\t/**\n\t * Given a table name, return the GraphQL argument name used to look up a record by PK.\n\t * @example Amber default (Relay Global ID): \"sales_orders\" → \"id\"\n\t * @example row_id PK: \"sales_orders\" → \"rowId\"\n\t */\n\trecordArgName?: (tableName: string) => string\n\n\t/**\n\t * Given a table name, return the GraphQL variable type for the PK argument.\n\t * @example Default UUID PK: \"sales_orders\" → \"UUID!\"\n\t * @example Integer PK: \"sales_orders\" → \"Int!\"\n\t */\n\trecordArgType?: (tableName: string) => string\n\n\t/**\n\t * Derive the GraphQL connection field name for a reverse-FK link.\n\t * PostGraphile convention: `{targetPlural}By{FkColumnPascal}Id`\n\t * - When backlink is provided: FK column is derived from the backlink field\n\t * - When backlink is absent: FK column is derived from the parent doctype\n\t * @example Recipe → RecipeTasksByRecipeId\n\t */\n\treverseConnectionName?: (params: {\n\t\t/** Parent doctype slug */\n\t\tdoctype: string\n\t\t/** Link key on the parent */\n\t\tlinkName: string\n\t\t/** Link field on the target that points back to the parent (optional) */\n\t\tbacklink?: string\n\t\t/** Target doctype slug */\n\t\ttarget: string\n\t}) => string\n}\n\n/**\n * Options for stonecropRecord queries\n * @public\n */\nexport interface StonecropRecordOptions {\n\t/** Include nested/related records */\n\tincludeNested?: boolean | string[]\n\t/** Maximum nesting depth */\n\tmaxDepth?: number\n}\n\n/**\n * Options for creating a Stonecrop PostGraphile plugin\n * @public\n */\nexport interface StonecropPluginOptions {\n\t/** GraphQL executor for running queries/mutations */\n\texecutor: GraphQLExecutor\n\n\t/**\n\t * Override inflection conventions for mapping table names to GraphQL field names.\n\t * Defaults to PostGraphile Amber preset conventions.\n\t */\n\tinflection?: StonecropInflectionConfig\n}\n\n/**\n * Create a PostGraphile plugin that extends the GraphQL schema with Stonecrop functionality\n * @param options - Plugin configuration options\n * @returns A PostGraphile plugin\n * @public\n */\nexport const createStonecropPlugin = (options: StonecropPluginOptions): GraphileConfig.Plugin => {\n\t// Resolve inflection callbacks with Amber defaults\n\tconst recordFieldName = options.inflection?.recordFieldName ?? defaultRecordFieldName\n\tconst connectionFieldName = options.inflection?.connectionFieldName ?? defaultConnectionFieldName\n\tconst orderByTypeName = options.inflection?.orderByTypeName ?? defaultOrderByTypeName\n\tconst recordArgName = options.inflection?.recordArgName ?? defaultRecordArgName\n\tconst recordArgType = options.inflection?.recordArgType ?? defaultRecordArgType\n\tconst reverseConnectionName = options.inflection?.reverseConnectionName ?? defaultReverseConnectionName\n\n\treturn extendSchema(() => {\n\t\treturn {\n\t\t\ttypeDefs: gql`\n\t\t\t\ttype StonecropFieldMeta {\n\t\t\t\t\tfieldname: String!\n\t\t\t\t\tfieldtype: String!\n\t\t\t\t\tcomponent: String\n\t\t\t\t\tlabel: String\n\t\t\t\t\twidth: String\n\t\t\t\t\talign: String\n\t\t\t\t\trequired: Boolean\n\t\t\t\t\treadOnly: Boolean\n\t\t\t\t\tedit: Boolean\n\t\t\t\t\thidden: Boolean\n\t\t\t\t\tdefault: JSON\n\t\t\t\t\toptions: JSON\n\t\t\t\t\tmask: String\n\t\t\t\t\tprecision: Int\n\t\t\t\t\tscale: Int\n\t\t\t\t\tmode: String\n\t\t\t\t\tvalidation: JSON\n\t\t\t\t}\n\n\t\t\t\ttype StonecropWorkflowAction {\n\t\t\t\t\tlabel: String!\n\t\t\t\t\thandler: String!\n\t\t\t\t\trequiredFields: [String!]\n\t\t\t\t\tallowedStates: [String!]\n\t\t\t\t\tconfirm: Boolean\n\t\t\t\t\targs: JSON\n\t\t\t\t}\n\n\t\t\t\ttype StonecropWorkflowMeta {\n\t\t\t\t\tstates: [String!]\n\t\t\t\t\tactions: [StonecropWorkflowAction!]\n\t\t\t\t}\n\n\t\t\t\ttype StonecropDoctypeMeta {\n\t\t\t\t\tname: String!\n\t\t\t\t\tslug: String\n\t\t\t\t\ttableName: String\n\t\t\t\t\tfields: [StonecropFieldMeta!]!\n\t\t\t\t\tworkflow: StonecropWorkflowMeta\n\t\t\t\t\tinherits: String\n\t\t\t\t}\n\n\t\t\t\ttype StonecropRecordResult {\n\t\t\t\t\tdata: JSON\n\t\t\t\t\tdoctype: String!\n\t\t\t\t\tunknownLinks: [String!]\n\t\t\t\t}\n\n\t\t\t\ttype StonecropRecordsResult {\n\t\t\t\t\tdata: [JSON!]!\n\t\t\t\t\tdoctype: String!\n\t\t\t\t\tcount: Int!\n\t\t\t\t}\n\n\t\t\t\ttype StonecropActionResult {\n\t\t\t\t\tsuccess: Boolean!\n\t\t\t\t\tdata: JSON\n\t\t\t\t\terror: String\n\t\t\t\t}\n\n\t\t\t\textend type Query {\n\t\t\t\t\tstonecropMeta(doctype: String!): StonecropDoctypeMeta\n\t\t\t\t\tstonecropAllMeta: [StonecropDoctypeMeta!]!\n\t\t\t\t\tstonecropRecord(doctype: String!, id: String!, options: JSON): StonecropRecordResult\n\t\t\t\t\tstonecropRecords(\n\t\t\t\t\t\tdoctype: String!\n\t\t\t\t\t\tfilters: JSON\n\t\t\t\t\t\torderBy: String\n\t\t\t\t\t\tlimit: Int\n\t\t\t\t\t\toffset: Int\n\t\t\t\t\t): StonecropRecordsResult\n\t\t\t\t}\n\n\t\t\t\textend type Mutation {\n\t\t\t\t\tstonecropAction(doctype: String!, action: String!, args: JSON): StonecropActionResult!\n\t\t\t\t}\n\t\t\t`,\n\n\t\t\tobjects: {\n\t\t\t\tQuery: {\n\t\t\t\t\tplans: {\n\t\t\t\t\t\tstonecropMeta(_: any, { $doctype }: any) {\n\t\t\t\t\t\t\treturn lambda($doctype, (doctype: unknown) => {\n\t\t\t\t\t\t\t\tconst meta = getMeta(doctype as string)\n\t\t\t\t\t\t\t\treturn meta ?? null\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\tstonecropAllMeta() {\n\t\t\t\t\t\t\treturn constant(getAllMeta())\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\tstonecropRecord(_: any, { $doctype, $id, $options }: any) {\n\t\t\t\t\t\t\treturn loadOne(\n\t\t\t\t\t\t\t\tobject({ doctype: $doctype, id: $id, options: $options }),\n\t\t\t\t\t\t\t\tasync (specs: readonly any[]) => {\n\t\t\t\t\t\t\t\t\treturn await Promise.all(\n\t\t\t\t\t\t\t\t\t\tspecs.map(async spec => {\n\t\t\t\t\t\t\t\t\t\t\tconst meta = getMeta(spec.doctype)\n\t\t\t\t\t\t\t\t\t\t\tif (!meta) {\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new Error(`Unknown doctype: ${spec.doctype}`)\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tif (!meta.tableName) {\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new Error(`Doctype ${spec.doctype} has no table mapping`)\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tconst recordOptions = spec.options ?? {}\n\n\t\t\t\t\t\t\t\t\t\t\tconst query = buildRecordQuery(\n\t\t\t\t\t\t\t\t\t\t\t\tmeta,\n\t\t\t\t\t\t\t\t\t\t\t\trecordFieldName,\n\t\t\t\t\t\t\t\t\t\t\t\trecordArgName,\n\t\t\t\t\t\t\t\t\t\t\t\trecordArgType,\n\t\t\t\t\t\t\t\t\t\t\t\tgetMeta,\n\t\t\t\t\t\t\t\t\t\t\t\trecordOptions.includeNested\n\t\t\t\t\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tincludeNested: recordOptions.includeNested,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tmaxDepth: recordOptions.maxDepth,\n\t\t\t\t\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\t\t\t\t\treverseConnectionName\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\tconst result = await options.executor.query(query, {\n\t\t\t\t\t\t\t\t\t\t\t\t[recordArgName(meta.tableName!)]: spec.id,\n\t\t\t\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\t\t\t\tlet data = extractSingleResult({ result, meta, recordFieldName })\n\n\t\t\t\t\t\t\t\t\t\t\tif (recordOptions.includeNested && data && meta.links) {\n\t\t\t\t\t\t\t\t\t\t\t\tdata = mergeNestedResults({ record: data as Record<string, unknown>, meta, getMeta })\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tconst unknownLinks =\n\t\t\t\t\t\t\t\t\t\t\t\tArray.isArray(recordOptions.includeNested) && meta.links\n\t\t\t\t\t\t\t\t\t\t\t\t\t? recordOptions.includeNested.filter((name: string) => !(name in meta.links!))\n\t\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\n\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\t\t\t\t\t\tdoctype: spec.doctype,\n\t\t\t\t\t\t\t\t\t\t\t\t...(unknownLinks ? { unknownLinks } : {}),\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\tstonecropRecords(_: any, { $doctype, $filters, $orderBy, $limit, $offset }: any) {\n\t\t\t\t\t\t\treturn loadOne(\n\t\t\t\t\t\t\t\tobject({\n\t\t\t\t\t\t\t\t\tdoctype: $doctype,\n\t\t\t\t\t\t\t\t\tfilters: $filters,\n\t\t\t\t\t\t\t\t\torderBy: $orderBy,\n\t\t\t\t\t\t\t\t\tlimit: $limit,\n\t\t\t\t\t\t\t\t\toffset: $offset,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\tasync (specs: readonly any[]) => {\n\t\t\t\t\t\t\t\t\treturn await Promise.all(\n\t\t\t\t\t\t\t\t\t\tspecs.map(async spec => {\n\t\t\t\t\t\t\t\t\t\t\tconst meta = getMeta(spec.doctype)\n\t\t\t\t\t\t\t\t\t\t\tif (!meta) {\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new Error(`Unknown doctype: ${spec.doctype}`)\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tif (!meta.tableName) {\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new Error(`Doctype ${spec.doctype} has no table mapping`)\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tconst query = buildListQuery(\n\t\t\t\t\t\t\t\t\t\t\t\tmeta,\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tlimit: spec.limit,\n\t\t\t\t\t\t\t\t\t\t\t\t\toffset: spec.offset,\n\t\t\t\t\t\t\t\t\t\t\t\t\torderBy: spec.orderBy,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\tconnectionFieldName,\n\t\t\t\t\t\t\t\t\t\t\t\torderByTypeName\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\tconst result = await options.executor.query(query, {\n\t\t\t\t\t\t\t\t\t\t\t\tlimit: spec.limit,\n\t\t\t\t\t\t\t\t\t\t\t\toffset: spec.offset,\n\t\t\t\t\t\t\t\t\t\t\t\torderBy: spec.orderBy,\n\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t\tconst data = extractListResult({ result, meta, connectionFieldName })\n\n\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\t\t\t\t\t\tdoctype: spec.doctype,\n\t\t\t\t\t\t\t\t\t\t\t\tcount: data.length,\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\n\t\t\t\tMutation: {\n\t\t\t\t\tplans: {\n\t\t\t\t\t\tstonecropAction(_: any, { $doctype, $action, $args: $actionArgs }: any) {\n\t\t\t\t\t\t\treturn loadOne(\n\t\t\t\t\t\t\t\tobject({\n\t\t\t\t\t\t\t\t\tdoctype: $doctype,\n\t\t\t\t\t\t\t\t\taction: $action,\n\t\t\t\t\t\t\t\t\tactionArgs: $actionArgs,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\tasync (specs: readonly any[]) => {\n\t\t\t\t\t\t\t\t\treturn await Promise.all(\n\t\t\t\t\t\t\t\t\t\tspecs.map(async spec => {\n\t\t\t\t\t\t\t\t\t\t\tconst meta = getMeta(spec.doctype)\n\t\t\t\t\t\t\t\t\t\t\tif (!meta) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: null,\n\t\t\t\t\t\t\t\t\t\t\t\t\terror: `Unknown doctype: ${spec.doctype}`,\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tconst actionDef = meta.workflow?.actions?.[spec.action]\n\t\t\t\t\t\t\t\t\t\t\tif (!actionDef) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: null,\n\t\t\t\t\t\t\t\t\t\t\t\t\terror: `Unknown action: ${spec.action} on ${spec.doctype}`,\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tconst handlerName = actionDef.handler\n\t\t\t\t\t\t\t\t\t\t\tconst handler = getHandler(handlerName)\n\t\t\t\t\t\t\t\t\t\t\tif (!handler) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: null,\n\t\t\t\t\t\t\t\t\t\t\t\t\terror: `Handler not registered: ${handlerName}`,\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tconst actionContext: ActionContext = {\n\t\t\t\t\t\t\t\t\t\t\t\tdoctype: meta,\n\t\t\t\t\t\t\t\t\t\t\t\texecutor: options.executor,\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\t\tconst result = await handler(spec.actionArgs ?? [], actionContext)\n\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: result,\n\t\t\t\t\t\t\t\t\t\t\t\t\terror: null,\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: null,\n\t\t\t\t\t\t\t\t\t\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t})\n}\n\n// =============================================================================\n// Inflection helpers — default to PostGraphile Amber preset conventions\n// Uses `pluralize` for proper English singularization (handles irregular\n// plurals like statuses→status, categories→category, addresses→address).\n// snakeToCamel / toPascalCase are imported from @stonecrop/schema.\n// =============================================================================\n\n/**\n * Amber default: sales_orders → salesOrderById\n * Uses `pluralize` for proper singularization of irregular plurals.\n * Override via `StonecropInflectionConfig.recordFieldName` for non-standard PK columns.\n * @public\n */\nfunction defaultRecordFieldName(tableName: string): string {\n\tconst singular = pluralize.singular(tableName)\n\treturn `${snakeToCamel(singular)}ById`\n}\n\n/**\n * Amber default: sales_orders → allSalesOrders\n * @public\n */\nfunction defaultConnectionFieldName(tableName: string): string {\n\treturn `all${toPascalCase(tableName)}`\n}\n\n/**\n * Amber default: sales_orders → SalesOrdersOrderBy\n * @public\n */\nfunction defaultOrderByTypeName(tableName: string): string {\n\treturn `${toPascalCase(tableName)}OrderBy`\n}\n\n/**\n * Default PK argument name: 'id' (standard Relay Global ID pattern).\n * Override via `StonecropInflectionConfig.recordArgName` when using row_id columns;\n * PostGraphile Amber generates `rowId: UUID!` for those fields.\n * @public\n */\nfunction defaultRecordArgName(_tableName: string): string {\n\treturn 'id'\n}\n\n/**\n * Default PK argument type: 'UUID!' (PostGraphile Amber default for UUID PKs).\n * Override via `StonecropInflectionConfig.recordArgType` when using non-UUID PKs\n * such as integer serials or Relay Global IDs ('ID!').\n * @public\n */\nfunction defaultRecordArgType(_tableName: string): string {\n\treturn 'UUID!'\n}\n\n/**\n * Default reverse connection name: derives PostGraphile's connection field convention.\n * PostGraphile convention: `{targetPlural}By{FkColumnPascal}Id`\n * - When backlink is defined: FK column is derived from the backlink field name\n * - When backlink is absent: FK column is derived from the parent doctype's table name\n * @public\n */\nfunction defaultReverseConnectionName(params: {\n\tdoctype: string\n\tlinkName: string\n\tbacklink?: string\n\ttarget: string\n}): string {\n\tconst targetPlural = pluralize.plural(params.target.replace(/-/g, '_'))\n\tconst targetPascal = toPascalCase(targetPlural)\n\t// Use backlink if provided, otherwise derive from parent table name\n\tconst fkSource = params.backlink || params.doctype\n\t// FK column name: uppercase first char, preserve rest of camelCase\n\tconst fkPascal = fkSource.charAt(0).toUpperCase() + fkSource.slice(1)\n\treturn `${targetPascal}By${fkPascal}Id`\n}\n\n/**\n * Check if a cardinality represents a \"many\" relationship\n */\nfunction isManyCardinality(cardinality: string): boolean {\n\treturn cardinality === 'noneOrMany' || cardinality === 'atLeastOne'\n}\n\n// =============================================================================\n// Query builders — generate GraphQL queries to send to the underlying schema\n// =============================================================================\n\nconst DEFAULT_SYNC_LIMIT = 50\n\n/**\n * Fieldtypes that map to GraphQL object/connection types and require sub-selections.\n * These fields are excluded from generated query field selections.\n * @public\n */\nconst RELATION_FIELDTYPES = new Set(['Link'])\n\n/**\n * Filter fields to only those directly queryable as scalars, excluding Link and Doctype\n * relation fields that require GraphQL sub-selections.\n * @public\n */\nfunction queryableFieldNames(meta: DoctypeMeta): string {\n\treturn meta.fields\n\t\t.filter(f => !RELATION_FIELDTYPES.has(f.fieldtype))\n\t\t.map(f => f.fieldname)\n\t\t.join('\\n ')\n}\n\n/**\n * Get the effective fetch strategy for a link, applying cardinality-based defaults.\n */\nfunction getEffectiveFetchStrategy(link: LinkDeclaration): SyncFetch | LazyFetch {\n\tif (link.fetch !== undefined) {\n\t\treturn link.fetch as SyncFetch | LazyFetch\n\t}\n\n\tif (isManyCardinality(link.cardinality)) {\n\t\treturn { method: 'sync', limit: DEFAULT_SYNC_LIMIT }\n\t} else {\n\t\treturn { method: 'lazy' }\n\t}\n}\n\n/**\n * Get the effective blockWorkflows value for a link.\n */\nfunction getEffectiveBlockWorkflows(link: LinkDeclaration): boolean {\n\tif (link.blockWorkflows !== undefined) {\n\t\treturn link.blockWorkflows\n\t}\n\tconst effectiveFetch = getEffectiveFetchStrategy(link)\n\treturn effectiveFetch.method === 'sync'\n}\n\n/**\n * Build nested sub-selections for descendant links\n */\nfunction buildNestedSelections(params: BuildNestedSelectionsParams): string {\n\tconst { links, meta, includeSet, getMeta, seen, depth, maxDepth, reverseConnectionNameFn } = params\n\n\tif (maxDepth !== undefined && depth >= maxDepth) return ''\n\n\tconst selections: string[] = []\n\n\tfor (const [fieldname, link] of Object.entries(links)) {\n\t\tif (maxDepth !== undefined && depth >= maxDepth) break\n\n\t\tconst effectiveBlockWorkflows = getEffectiveBlockWorkflows(link)\n\t\tconst linkBlockWorkflowsExplicitTrue = link.blockWorkflows === true\n\n\t\tif (includeSet && !includeSet.has(fieldname) && !linkBlockWorkflowsExplicitTrue) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst effectiveFetch = getEffectiveFetchStrategy(link)\n\t\tconst shouldSkip =\n\t\t\teffectiveBlockWorkflows === false || (effectiveFetch.method !== 'sync' && !linkBlockWorkflowsExplicitTrue)\n\t\tif (shouldSkip) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst targetMeta = getMeta(link.target)\n\t\tif (!targetMeta) continue\n\n\t\tconst alreadySeen = seen.has(link.target)\n\t\tif (alreadySeen) {\n\t\t} else {\n\t\t\tseen.add(link.target)\n\t\t}\n\t\tconst scalarFields = queryableFieldNames(targetMeta)\n\n\t\tlet nestedLinks = ''\n\t\tif (!alreadySeen && targetMeta.links && targetMeta.tableName && (maxDepth === undefined || depth + 1 < maxDepth)) {\n\t\t\tconst innerSelections = buildNestedSelections({\n\t\t\t\tlinks: targetMeta.links,\n\t\t\t\tmeta: targetMeta,\n\t\t\t\tincludeSet: null,\n\t\t\t\tgetMeta,\n\t\t\t\tseen,\n\t\t\t\tdepth: depth + 1,\n\t\t\t\tmaxDepth,\n\t\t\t\treverseConnectionNameFn,\n\t\t\t})\n\t\t\tif (innerSelections) {\n\t\t\t\tnestedLinks = '\\n ' + innerSelections\n\t\t\t}\n\t\t\tseen.delete(link.target)\n\t\t}\n\n\t\tconst fullSelection = scalarFields + nestedLinks\n\n\t\tif (isManyCardinality(link.cardinality)) {\n\t\t\tconst reverseParams: ReverseConnectionParams = {\n\t\t\t\tdoctype: meta.slug || meta.name,\n\t\t\t\tlinkName: fieldname,\n\t\t\t\tbacklink: link.backlink,\n\t\t\t\ttarget: link.target,\n\t\t\t}\n\t\t\tconst connectionField = reverseConnectionNameFn\n\t\t\t\t? reverseConnectionNameFn(reverseParams)\n\t\t\t\t: defaultReverseConnectionName(reverseParams)\n\t\t\tconst limitArg =\n\t\t\t\teffectiveFetch.method === 'sync' && effectiveFetch.limit !== undefined\n\t\t\t\t\t? `first: ${effectiveFetch.limit}`\n\t\t\t\t\t: effectiveFetch.method === 'sync'\n\t\t\t\t\t? `first: ${DEFAULT_SYNC_LIMIT}`\n\t\t\t\t\t: ''\n\t\t\tselections.push(`\n\t\t\t${connectionField}${limitArg ? `(${limitArg})` : ''} {\n\t\t\t\tnodes {\n\t\t\t\t\t${fullSelection}\n\t\t\t\t}\n\t\t\t}`)\n\t\t} else {\n\t\t\tselections.push(`\n\t\t\t${fieldname} {\n\t\t\t\t${fullSelection}\n\t\t\t}`)\n\t\t}\n\t}\n\n\treturn selections.join('')\n}\n\n/**\n * Build a GraphQL query to fetch a single record by ID.\n * When includeNested is set, recursively includes descendant link sub-selections.\n * @public\n */\nfunction buildRecordQuery(\n\tmeta: DoctypeMeta,\n\trecordFieldName: (t: string) => string,\n\trecordArgName: (t: string) => string,\n\trecordArgType: (t: string) => string,\n\tgetMeta: (slug: string) => DoctypeMeta | undefined,\n\toptions?: BuildRecordQueryOptions,\n\treverseConnectionNameFn?: (params: ReverseConnectionParams) => string\n): string {\n\tconst queryName = recordFieldName(meta.tableName!)\n\tconst argName = recordArgName(meta.tableName!)\n\tconst argType = recordArgType(meta.tableName!)\n\n\tconst seen = new Set<string>([meta.slug || meta.name])\n\n\tlet selection = queryableFieldNames(meta)\n\n\tif (options?.includeNested && meta.links) {\n\t\tconst includeSet = Array.isArray(options.includeNested) ? new Set(options.includeNested) : null\n\n\t\tconst nestedSelections = buildNestedSelections({\n\t\t\tlinks: meta.links,\n\t\t\tmeta,\n\t\t\tincludeSet,\n\t\t\tgetMeta,\n\t\t\tseen,\n\t\t\tdepth: 0,\n\t\t\tmaxDepth: options.maxDepth,\n\t\t\treverseConnectionNameFn,\n\t\t})\n\n\t\tif (nestedSelections) {\n\t\t\tselection += '\\n ' + nestedSelections\n\t\t}\n\t}\n\n\treturn `\n\t\tquery GetRecord($${argName}: ${argType}) {\n\t\t\t${queryName}(${argName}: $${argName}) {\n\t\t\t\t${selection}\n\t\t\t}\n\t\t}\n\t`\n}\n\n/**\n * Build a GraphQL connection query to fetch a list of records.\n * Only declares variables ($limit, $offset, $orderBy) that are actually used in the query,\n * avoiding GraphQL spec §5.8.3 violations from unused variable declarations.\n * Excludes Link and Doctype relation fields from the selection set.\n * @public\n */\nfunction buildListQuery(\n\tmeta: DoctypeMeta,\n\targs: BuildListQueryArgs,\n\tconnectionFieldName: (t: string) => string,\n\torderByTypeName: (t: string) => string\n): string {\n\tconst fieldNames = queryableFieldNames(meta)\n\tconst connectionName = connectionFieldName(meta.tableName!)\n\tconst orderByType = orderByTypeName(meta.tableName!)\n\n\tconst varDecls: string[] = []\n\tconst queryArgs: string[] = []\n\tif (args.limit) {\n\t\tvarDecls.push('$limit: Int')\n\t\tqueryArgs.push(`first: $limit`)\n\t}\n\tif (args.offset) {\n\t\tvarDecls.push('$offset: Int')\n\t\tqueryArgs.push(`offset: $offset`)\n\t}\n\tif (args.orderBy) {\n\t\tvarDecls.push(`$orderBy: [${orderByType}!]`)\n\t\tqueryArgs.push(`orderBy: $orderBy`)\n\t}\n\n\tconst varStr = varDecls.length > 0 ? `(${varDecls.join(', ')})` : ''\n\tconst argsStr = queryArgs.length > 0 ? `(${queryArgs.join(', ')})` : ''\n\n\treturn `\n\t\tquery GetRecords${varStr} {\n\t\t\t${connectionName}${argsStr} {\n\t\t\t\tnodes {\n\t\t\t\t${fieldNames}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t`\n}\n\n/**\n * Merge nested connection results into flat arrays.\n * For `noneOrMany`/`atLeastOne` links, the query returns `{ nodes: [...] }`.\n * This flattens them to just `[]` for easier consumption.\n * @public\n */\nfunction mergeNestedResults(params: MergeNestedResultsParams): Record<string, unknown> {\n\tconst { record, meta, getMeta } = params\n\tif (!meta.links) return record\n\n\tconst merged = { ...record }\n\n\tfor (const [fieldname, link] of Object.entries(meta.links)) {\n\t\tconst isMany = isManyCardinality(link.cardinality)\n\n\t\tif (isMany) {\n\t\t\tconst targetMeta = getMeta(link.target)\n\t\t\tif (!targetMeta) continue\n\n\t\t\tconst reverseParams: ReverseConnectionParams = {\n\t\t\t\tdoctype: meta.slug || meta.name,\n\t\t\t\tlinkName: fieldname,\n\t\t\t\tbacklink: link.backlink || fieldname,\n\t\t\t\ttarget: link.target,\n\t\t\t}\n\t\t\tconst connectionField = defaultReverseConnectionName(reverseParams)\n\t\t\tconst connectionResult = merged[connectionField] as { nodes?: unknown[] } | undefined\n\t\t\tif (connectionResult?.nodes) {\n\t\t\t\tmerged[fieldname] = connectionResult.nodes\n\t\t\t\tdelete merged[connectionField]\n\t\t\t} else {\n\t\t\t\tmerged[fieldname] = []\n\t\t\t\tdelete merged[connectionField]\n\t\t\t}\n\t\t}\n\t}\n\n\treturn merged\n}\n\n/**\n * Extract a single record from a PostGraphile query result using the record field name.\n * @public\n */\nfunction extractSingleResult(params: ExtractSingleResultParams): unknown {\n\tconst { result, meta, recordFieldName } = params\n\tconst queryName = recordFieldName(meta.tableName!)\n\treturn (result as Record<string, unknown>)[queryName]\n}\n\n/**\n * Extract the list of nodes from a PostGraphile connection query result.\n * Returns an empty array if the connection field is absent.\n * @public\n */\nfunction extractListResult(params: ExtractListResultParams): unknown[] {\n\tconst { result, meta, connectionFieldName } = params\n\tconst connectionName = connectionFieldName(meta.tableName!)\n\tconst connection = (result as Record<string, unknown>)[connectionName] as {\n\t\tnodes: unknown[]\n\t}\n\treturn connection?.nodes ?? []\n}\n\n// =============================================================================\n// Exported for testing and advanced usage\n// =============================================================================\n\nexport {\n\tdefaultRecordFieldName,\n\tdefaultConnectionFieldName,\n\tdefaultOrderByTypeName,\n\tdefaultRecordArgName,\n\tdefaultRecordArgType,\n\tdefaultReverseConnectionName,\n\tbuildRecordQuery,\n\tbuildListQuery,\n\tqueryableFieldNames,\n\tRELATION_FIELDTYPES,\n\textractSingleResult,\n\textractListResult,\n\tmergeNestedResults,\n}\n","import { gql } from 'postgraphile/utils'\n\n/**\n * GraphQL type definitions for Stonecrop's middleware API.\n * Includes stonecropMeta, stonecropRecord, stonecropRecords, stonecropAction, and related types.\n * @public\n */\nexport const typeDefs = gql`\n\ttype StonecropFieldMeta {\n\t\tfieldname: String!\n\t\tfieldtype: String!\n\t\tcomponent: String\n\t\tlabel: String\n\t\twidth: String\n\t\talign: String\n\t\trequired: Boolean\n\t\treadOnly: Boolean\n\t\tedit: Boolean\n\t\thidden: Boolean\n\t\tdefault: JSON\n\t\toptions: JSON\n\t\tmask: String\n\t\tprecision: Int\n\t\tscale: Int\n\t\tmode: String\n\t\tvalidation: JSON\n\t}\n\n\ttype StonecropWorkflowAction {\n\t\tlabel: String!\n\t\thandler: String!\n\t\trequiredFields: [String!]\n\t\tallowedStates: [String!]\n\t\tconfirm: Boolean\n\t\targs: JSON\n\t}\n\n\ttype StonecropWorkflowMeta {\n\t\tstates: [String!]\n\t\tactions: [StonecropWorkflowAction!]\n\t}\n\n\ttype StonecropDoctypeMeta {\n\t\tname: String!\n\t\tslug: String\n\t\ttableName: String\n\t\tfields: [StonecropFieldMeta!]!\n\t\tworkflow: StonecropWorkflowMeta\n\t\tinherits: String\n\t}\n\n\ttype StonecropRecordResult {\n\t\tdata: JSON\n\t\tdoctype: String!\n\t\tunknownLinks: [String!]\n\t}\n\n\ttype StonecropRecordsResult {\n\t\tdata: [JSON!]!\n\t\tdoctype: String!\n\t\tcount: Int!\n\t}\n\n\ttype StonecropActionResult {\n\t\tsuccess: Boolean!\n\t\tdata: JSON\n\t\terror: String\n\t}\n\n\textend type Query {\n\t\tstonecropMeta(doctype: String!): StonecropDoctypeMeta\n\t\tstonecropAllMeta: [StonecropDoctypeMeta!]!\n\t\tstonecropRecord(doctype: String!, id: String!, options: JSON): StonecropRecordResult\n\t\tstonecropRecords(doctype: String!, filters: JSON, orderBy: String, limit: Int, offset: Int): StonecropRecordsResult\n\t}\n\n\textend type Mutation {\n\t\tstonecropAction(doctype: String!, action: String!, args: JSON): StonecropActionResult!\n\t}\n`\n"],"names":["doctypeRegistry","DoctypeValidationError","file","errors","errorMessages","e","loadDoctypes","dir","options","entries","readdirSync","entry","fullPath","join","statSync","loadDoctypeFile","filePath","content","readFileSync","data","err","parseError","result","validateDoctype","doctype","parseDoctype","loadDoctypesFromObject","doctypes","name","withName","getMeta","getAllMeta","hasMeta","clearRegistry","validateReferences","field","handlerRegistry","registerHandler","handler","getHandler","hasHandler","clearHandlers","validateRequiredFields","args","context","record","missing","validateFieldTypes","value","error","validateFieldValue","fieldname","link","fieldtype","cardinality","noop","builtinHandlers","registerBuiltinHandlers","createStonecropPlugin","recordFieldName","defaultRecordFieldName","connectionFieldName","defaultConnectionFieldName","orderByTypeName","defaultOrderByTypeName","recordArgName","defaultRecordArgName","recordArgType","defaultRecordArgType","reverseConnectionName","defaultReverseConnectionName","extendSchema","gql","_","$doctype","lambda","constant","$id","$options","loadOne","object","specs","spec","meta","recordOptions","query","buildRecordQuery","extractSingleResult","mergeNestedResults","unknownLinks","$filters","$orderBy","$limit","$offset","buildListQuery","extractListResult","$action","$actionArgs","actionDef","handlerName","actionContext","tableName","singular","pluralize","snakeToCamel","toPascalCase","_tableName","params","targetPlural","targetPascal","fkSource","fkPascal","isManyCardinality","DEFAULT_SYNC_LIMIT","RELATION_FIELDTYPES","queryableFieldNames","f","getEffectiveFetchStrategy","getEffectiveBlockWorkflows","buildNestedSelections","links","includeSet","seen","depth","maxDepth","reverseConnectionNameFn","selections","effectiveBlockWorkflows","linkBlockWorkflowsExplicitTrue","effectiveFetch","targetMeta","alreadySeen","scalarFields","nestedLinks","innerSelections","fullSelection","reverseParams","connectionField","limitArg","queryName","argName","argType","selection","nestedSelections","fieldNames","connectionName","orderByType","varDecls","queryArgs","varStr","argsStr","merged","connectionResult","typeDefs"],"mappings":";;;;;;AAMA,MAAMA,wBAAgD,IAAA;AAM/C,MAAMC,UAA+B,MAAM;AAAA,EACjD,YAEiBC,GAEAC,GACf;AACD,UAAMC,IAAgBD,EAAO,IAAI,CAAAE,MAAK,KAAKA,EAAE,KAAK,KAAK,GAAG,CAAC,KAAKA,EAAE,OAAO,EAAE,EAAE,KAAK;AAAA,CAAI;AACtF,UAAM,iCAAiCH,CAAI;AAAA,EAAME,CAAa,EAAE,GALhD,KAAA,OAAAF,GAEA,KAAA,SAAAC,GAIhB,KAAK,OAAO;A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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/registry/doctypes.ts","../src/registry/actions.ts","../src/plugin/postgraphile.ts","../src/typeDefs.ts"],"sourcesContent":["import { readFileSync, readdirSync, statSync } from 'node:fs'\nimport { join } from 'node:path'\n\nimport { parseDoctype, validateDoctype } from '@stonecrop/schema'\nimport type { DoctypeMeta, ValidationError } from '@stonecrop/schema'\n\nconst doctypeRegistry: Map<string, DoctypeMeta> = new Map()\n\n/**\n * Error thrown when a doctype definition fails validation\n * @public\n */\nexport class DoctypeValidationError extends Error {\n\tconstructor(\n\t\t/** File path or name where the validation error occurred */\n\t\tpublic readonly file: string,\n\t\t/** List of validation errors found */\n\t\tpublic readonly errors: ValidationError[]\n\t) {\n\t\tconst errorMessages = errors.map(e => ` ${e.path.join('.')}: ${e.message}`).join('\\n')\n\t\tsuper(`Invalid doctype definition in ${file}:\\n${errorMessages}`)\n\t\tthis.name = 'DoctypeValidationError'\n\t}\n}\n\n/**\n * Options for loading doctype definitions\n * @public\n */\nexport interface LoadDoctypesOptions {\n\t/** Continue loading other files if one fails validation */\n\tcontinueOnError?: boolean\n\t/** Callback for validation errors when continueOnError is true */\n\tonError?: (file: string, errors: ValidationError[]) => void\n}\n\n/**\n * Load doctype definitions from a directory of JSON files\n * @param dir - Directory path containing doctype JSON files\n * @param options - Options for loading doctypes (continueOnError, onError callback)\n * @public\n */\nexport function loadDoctypes(dir: string, options: LoadDoctypesOptions = {}): void {\n\tconst entries = readdirSync(dir)\n\n\tfor (const entry of entries) {\n\t\tconst fullPath = join(dir, entry)\n\t\tconst stat = statSync(fullPath)\n\n\t\tif (stat.isDirectory()) {\n\t\t\tloadDoctypes(fullPath, options)\n\t\t} else if (entry.endsWith('.json')) {\n\t\t\tloadDoctypeFile(fullPath, options)\n\t\t}\n\t}\n}\n\n/**\n * Load and validate a single doctype file\n */\nfunction loadDoctypeFile(filePath: string, options: LoadDoctypesOptions): void {\n\tconst content = readFileSync(filePath, 'utf-8')\n\tlet data: unknown\n\n\ttry {\n\t\tdata = JSON.parse(content)\n\t} catch (err) {\n\t\tconst parseError: ValidationError = {\n\t\t\tpath: [],\n\t\t\tmessage: `Invalid JSON: ${err instanceof Error ? err.message : String(err)}`,\n\t\t}\n\n\t\tif (options.continueOnError) {\n\t\t\toptions.onError?.(filePath, [parseError])\n\t\t\treturn\n\t\t}\n\t\tthrow new DoctypeValidationError(filePath, [parseError])\n\t}\n\n\tconst result = validateDoctype(data)\n\n\tif (!result.success) {\n\t\tif (options.continueOnError) {\n\t\t\toptions.onError?.(filePath, result.errors)\n\t\t\treturn\n\t\t}\n\t\tthrow new DoctypeValidationError(filePath, result.errors)\n\t}\n\n\tconst doctype = parseDoctype(data)\n\tdoctypeRegistry.set(doctype.name, doctype)\n}\n\n/**\n * Load doctypes from an object (for programmatic use)\n * @param doctypes - Object mapping doctype names to doctype definitions\n * @param options - Options for loading doctypes (continueOnError, onError callback)\n * @public\n */\nexport function loadDoctypesFromObject(doctypes: Record<string, unknown>, options: LoadDoctypesOptions = {}): void {\n\tfor (const [name, data] of Object.entries(doctypes)) {\n\t\tconst withName = { ...(data as object), name }\n\t\tconst result = validateDoctype(withName)\n\n\t\tif (!result.success) {\n\t\t\tif (options.continueOnError) {\n\t\t\t\toptions.onError?.(name, result.errors)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tthrow new DoctypeValidationError(name, result.errors)\n\t\t}\n\n\t\tconst doctype = parseDoctype(withName)\n\t\tdoctypeRegistry.set(doctype.name, doctype)\n\t}\n}\n\n/**\n * Get a doctype by name\n * @param name - Name of the doctype to retrieve\n * @public\n */\nexport function getMeta(name: string): DoctypeMeta | undefined {\n\treturn doctypeRegistry.get(name)\n}\n\n/**\n * Get all loaded doctypes\n * @public\n */\nexport function getAllMeta(): DoctypeMeta[] {\n\treturn Array.from(doctypeRegistry.values())\n}\n\n/**\n * Check if a doctype is registered\n * @param name - Name of the doctype to check\n * @public\n */\nexport function hasMeta(name: string): boolean {\n\treturn doctypeRegistry.has(name)\n}\n\n/**\n * Clear all registered doctypes\n * @public\n */\nexport function clearRegistry(): void {\n\tdoctypeRegistry.clear()\n}\n\n/**\n * Validate cross-doctype references (Link fields, inherits, etc.)\n * Call after all doctypes are loaded.\n * @public\n */\nexport function validateReferences(): ValidationError[] {\n\tconst errors: ValidationError[] = []\n\n\tfor (const doctype of doctypeRegistry.values()) {\n\t\t// Check inherits reference\n\t\tif (doctype.inherits && !doctypeRegistry.has(doctype.inherits)) {\n\t\t\terrors.push({\n\t\t\t\tpath: [doctype.name, 'inherits'],\n\t\t\t\tmessage: `References unknown doctype: ${doctype.inherits}`,\n\t\t\t})\n\t\t}\n\n\t\t// Check Link field targets\n\t\tfor (const field of doctype.fields) {\n\t\t\tif (field.fieldtype === 'Link' && typeof field.options === 'string') {\n\t\t\t\tif (!doctypeRegistry.has(field.options)) {\n\t\t\t\t\terrors.push({\n\t\t\t\t\t\tpath: [doctype.name, 'fields', field.fieldname, 'options'],\n\t\t\t\t\t\tmessage: `Link references unknown doctype: ${field.options}`,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn errors\n}\n","import type { DoctypeMeta, FieldMeta } from '@stonecrop/schema'\nimport type { ActionHandler, ActionContext } from '../types'\n\nconst handlerRegistry: Map<string, ActionHandler> = new Map()\n\n/**\n * Register an action handler\n * @param name - Unique name for the action handler\n * @param handler - Action handler function to register\n * @public\n */\nexport function registerHandler(name: string, handler: ActionHandler): void {\n\thandlerRegistry.set(name, handler)\n}\n\n/**\n * Get a registered handler by name\n * @param name - Name of the action handler to retrieve\n * @public\n */\nexport function getHandler(name: string): ActionHandler | undefined {\n\treturn handlerRegistry.get(name)\n}\n\n/**\n * Check if a handler is registered\n * @param name - Name of the action handler to check\n * @public\n */\nexport function hasHandler(name: string): boolean {\n\treturn handlerRegistry.has(name)\n}\n\n/**\n * Clear all registered handlers\n * @public\n */\nexport function clearHandlers(): void {\n\thandlerRegistry.clear()\n}\n\n// =============================================================================\n// Built-in Handlers\n// =============================================================================\n\n/**\n * Validate that all required fields are present in a record\n */\nconst validateRequiredFields: ActionHandler = async (args, context) => {\n\tconst [record] = args as [Record<string, unknown>]\n\tconst { doctype } = context\n\n\tconst missing: string[] = []\n\tfor (const field of doctype.fields) {\n\t\tif (field.required && (record[field.fieldname] === undefined || record[field.fieldname] === null)) {\n\t\t\tmissing.push(field.label ?? field.fieldname)\n\t\t}\n\t}\n\n\tif (missing.length > 0) {\n\t\tthrow new Error(`Missing required fields: ${missing.join(', ')}`)\n\t}\n\n\treturn { valid: true }\n}\n\n/**\n * Validate field types match expected types\n */\nconst validateFieldTypes: ActionHandler = async (args, context) => {\n\tconst [record] = args as [Record<string, unknown>]\n\tconst { doctype } = context\n\n\tconst errors: string[] = []\n\n\tfor (const field of doctype.fields) {\n\t\tconst value = record[field.fieldname]\n\t\tif (value === undefined || value === null) continue\n\n\t\tconst error = validateFieldValue(field, value)\n\t\tif (error) errors.push(error)\n\t}\n\n\t// Validate link fields\n\tif (doctype.links) {\n\t\tfor (const [fieldname, link] of Object.entries(doctype.links)) {\n\t\t\tconst value = record[fieldname]\n\t\t\tif (value === undefined || value === null) continue\n\n\t\t\tconst isMany = link.cardinality === 'noneOrMany' || link.cardinality === 'atLeastOne'\n\t\t\tif (isMany) {\n\t\t\t\tif (!Array.isArray(value)) {\n\t\t\t\t\terrors.push(`${fieldname}: expected array, got ${typeof value}`)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (typeof value !== 'object' || Array.isArray(value)) {\n\t\t\t\t\terrors.push(`${fieldname}: expected object, got ${typeof value}`)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (errors.length > 0) {\n\t\tthrow new Error(`Field type validation failed:\\n${errors.join('\\n')}`)\n\t}\n\n\treturn { valid: true }\n}\n\n/**\n * Validate a single field value against its expected type\n */\nfunction validateFieldValue(field: FieldMeta, value: unknown): string | null {\n\tconst { fieldname, fieldtype, cardinality } = field\n\n\tswitch (fieldtype) {\n\t\tcase 'Int':\n\t\t\tif (typeof value !== 'number' || !Number.isInteger(value)) {\n\t\t\t\treturn `${fieldname}: expected integer, got ${typeof value}`\n\t\t\t}\n\t\t\tbreak\n\n\t\tcase 'Float':\n\t\tcase 'Decimal':\n\t\tcase 'Currency':\n\t\tcase 'Quantity':\n\t\t\tif (typeof value !== 'number' && typeof value !== 'string') {\n\t\t\t\treturn `${fieldname}: expected number, got ${typeof value}`\n\t\t\t}\n\t\t\tbreak\n\n\t\tcase 'Check':\n\t\t\tif (typeof value !== 'boolean') {\n\t\t\t\treturn `${fieldname}: expected boolean, got ${typeof value}`\n\t\t\t}\n\t\t\tbreak\n\n\t\tcase 'Data':\n\t\tcase 'Text':\n\t\tcase 'Code':\n\t\tcase 'Link':\n\t\t\tif (typeof value !== 'string') {\n\t\t\t\treturn `${fieldname}: expected string, got ${typeof value}`\n\t\t\t}\n\t\t\tbreak\n\n\t\tcase 'Date':\n\t\tcase 'Time':\n\t\tcase 'Datetime':\n\t\t\tif (typeof value !== 'string' && !(value instanceof Date)) {\n\t\t\t\treturn `${fieldname}: expected date string or Date, got ${typeof value}`\n\t\t\t}\n\t\t\tbreak\n\n\t\tcase 'JSON':\n\t\t\tif (typeof value !== 'object') {\n\t\t\t\treturn `${fieldname}: expected object, got ${typeof value}`\n\t\t\t}\n\t\t\tbreak\n\t}\n\n\treturn null\n}\n\n/**\n * No-op handler for testing or placeholder actions\n */\nconst noop: ActionHandler = async () => {\n\treturn { ok: true }\n}\n\n/**\n * Built-in handlers available for registration\n * @public\n */\nexport const builtinHandlers: Record<string, ActionHandler> = {\n\tvalidateRequiredFields,\n\tvalidateFieldTypes,\n\tnoop,\n}\n\n/**\n * Register all built-in handlers\n * @public\n */\nexport function registerBuiltinHandlers(): void {\n\tfor (const [name, handler] of Object.entries(builtinHandlers)) {\n\t\tregisterHandler(name, handler)\n\t}\n}\n","import type { DoctypeMeta, LinkDeclaration, LazyFetch, SyncFetch } from '@stonecrop/schema'\nimport { snakeToCamel, toPascalCase } from '@stonecrop/schema'\nimport { constant, lambda, object, loadOne } from 'postgraphile/grafast'\nimport { GraphileConfig } from 'postgraphile/graphile-build'\nimport { extendSchema, gql } from 'postgraphile/utils'\nimport pluralize from 'pluralize'\n\nimport { getHandler, registerHandler } from '../registry/actions'\nimport { getMeta, getAllMeta } from '../registry/doctypes'\nimport type {\n\tActionContext,\n\tGraphQLExecutor,\n\tReverseConnectionParams,\n\tBuildRecordQueryOptions,\n\tBuildNestedSelectionsParams,\n\tBuildListQueryArgs,\n\tMergeNestedResultsParams,\n\tExtractSingleResultParams,\n\tExtractListResultParams,\n} from '../types'\n\n/**\n * Inflection callbacks for mapping table names to GraphQL query field names.\n * Override these when using a non-Amber inflection preset (e.g., V4, SimplifyInflection).\n *\n * Defaults match the PostGraphile Amber preset conventions.\n * @public\n */\nexport interface StonecropInflectionConfig {\n\t/**\n\t * Given a table name, return the GraphQL field name for fetching a single record by ID.\n\t * @example Amber default: \"sales_orders\" → \"salesOrderById\"\n\t * @example V4 preset: \"sales_orders\" → \"salesOrderByRowId\"\n\t */\n\trecordFieldName?: (tableName: string) => string\n\n\t/**\n\t * Given a table name, return the GraphQL field name for fetching a list/connection.\n\t * @example Amber default: \"sales_orders\" → \"allSalesOrders\"\n\t * @example SimplifyInflection: \"sales_orders\" → \"salesOrders\"\n\t */\n\tconnectionFieldName?: (tableName: string) => string\n\n\t/**\n\t * Given a table name, return the GraphQL OrderBy enum type name.\n\t * @example Amber default: \"sales_orders\" → \"SalesOrdersOrderBy\"\n\t */\n\torderByTypeName?: (tableName: string) => string\n\n\t/**\n\t * Given a table name, return the GraphQL argument name used to look up a record by PK.\n\t * @example Amber default (Relay Global ID): \"sales_orders\" → \"id\"\n\t * @example row_id PK: \"sales_orders\" → \"rowId\"\n\t */\n\trecordArgName?: (tableName: string) => string\n\n\t/**\n\t * Given a table name, return the GraphQL variable type for the PK argument.\n\t * @example Default UUID PK: \"sales_orders\" → \"UUID!\"\n\t * @example Integer PK: \"sales_orders\" → \"Int!\"\n\t */\n\trecordArgType?: (tableName: string) => string\n\n\t/**\n\t * Derive the GraphQL connection field name for a reverse-FK link.\n\t * PostGraphile convention: `{targetPlural}By{FkColumnPascal}Id`\n\t * - When backlink is provided: FK column is derived from the backlink field\n\t * - When backlink is absent: FK column is derived from the parent doctype\n\t * @example Recipe → RecipeTasksByRecipeId\n\t */\n\treverseConnectionName?: (params: {\n\t\t/** Parent doctype slug */\n\t\tdoctype: string\n\t\t/** Link key on the parent */\n\t\tlinkName: string\n\t\t/** Link field on the target that points back to the parent (optional) */\n\t\tbacklink?: string\n\t\t/** Target doctype slug */\n\t\ttarget: string\n\t}) => string\n}\n\n/**\n * Options for stonecropRecord queries\n * @public\n */\nexport interface StonecropRecordOptions {\n\t/** Include nested/related records */\n\tincludeNested?: boolean | string[]\n\t/** Maximum nesting depth */\n\tmaxDepth?: number\n}\n\n/**\n * Options for creating a Stonecrop PostGraphile plugin\n * @public\n */\nexport interface StonecropPluginOptions {\n\t/** GraphQL executor for running queries/mutations */\n\texecutor: GraphQLExecutor\n\n\t/**\n\t * Override inflection conventions for mapping table names to GraphQL field names.\n\t * Defaults to PostGraphile Amber preset conventions.\n\t */\n\tinflection?: StonecropInflectionConfig\n}\n\n/**\n * Create a PostGraphile plugin that extends the GraphQL schema with Stonecrop functionality\n * @param options - Plugin configuration options\n * @returns A PostGraphile plugin\n * @public\n */\nexport const createStonecropPlugin = (options: StonecropPluginOptions): GraphileConfig.Plugin => {\n\t// Resolve inflection callbacks with Amber defaults\n\tconst recordFieldName = options.inflection?.recordFieldName ?? defaultRecordFieldName\n\tconst connectionFieldName = options.inflection?.connectionFieldName ?? defaultConnectionFieldName\n\tconst orderByTypeName = options.inflection?.orderByTypeName ?? defaultOrderByTypeName\n\tconst recordArgName = options.inflection?.recordArgName ?? defaultRecordArgName\n\tconst recordArgType = options.inflection?.recordArgType ?? defaultRecordArgType\n\tconst reverseConnectionName = options.inflection?.reverseConnectionName ?? defaultReverseConnectionName\n\n\treturn extendSchema(() => {\n\t\treturn {\n\t\t\ttypeDefs: gql`\n\t\t\t\ttype StonecropFieldMeta {\n\t\t\t\t\tfieldname: String!\n\t\t\t\t\tfieldtype: String!\n\t\t\t\t\tcomponent: String\n\t\t\t\t\tlabel: String\n\t\t\t\t\twidth: String\n\t\t\t\t\talign: String\n\t\t\t\t\trequired: Boolean\n\t\t\t\t\treadOnly: Boolean\n\t\t\t\t\tedit: Boolean\n\t\t\t\t\thidden: Boolean\n\t\t\t\t\tdefault: JSON\n\t\t\t\t\toptions: JSON\n\t\t\t\t\tmask: String\n\t\t\t\t\tprecision: Int\n\t\t\t\t\tscale: Int\n\t\t\t\t\tmode: String\n\t\t\t\t\tvalidation: JSON\n\t\t\t\t}\n\n\t\t\t\ttype StonecropWorkflowAction {\n\t\t\t\t\tlabel: String!\n\t\t\t\t\thandler: String!\n\t\t\t\t\trequiredFields: [String!]\n\t\t\t\t\tallowedStates: [String!]\n\t\t\t\t\tconfirm: Boolean\n\t\t\t\t\targs: JSON\n\t\t\t\t}\n\n\t\t\t\ttype StonecropWorkflowMeta {\n\t\t\t\t\tstates: [String!]\n\t\t\t\t\tactions: [StonecropWorkflowAction!]\n\t\t\t\t}\n\n\t\t\t\ttype StonecropDoctypeMeta {\n\t\t\t\t\tname: String!\n\t\t\t\t\tslug: String\n\t\t\t\t\ttableName: String\n\t\t\t\t\tfields: [StonecropFieldMeta!]!\n\t\t\t\t\tworkflow: StonecropWorkflowMeta\n\t\t\t\t\tinherits: String\n\t\t\t\t}\n\n\t\t\t\ttype StonecropRecordResult {\n\t\t\t\t\tdata: JSON\n\t\t\t\t\tdoctype: String!\n\t\t\t\t\tunknownLinks: [String!]\n\t\t\t\t}\n\n\t\t\t\ttype StonecropRecordsResult {\n\t\t\t\t\tdata: [JSON!]!\n\t\t\t\t\tdoctype: String!\n\t\t\t\t\tcount: Int!\n\t\t\t\t}\n\n\t\t\t\ttype StonecropActionResult {\n\t\t\t\t\tsuccess: Boolean!\n\t\t\t\t\tdata: JSON\n\t\t\t\t\terror: String\n\t\t\t\t}\n\n\t\t\t\textend type Query {\n\t\t\t\t\tstonecropMeta(doctype: String!): StonecropDoctypeMeta\n\t\t\t\t\tstonecropAllMeta: [StonecropDoctypeMeta!]!\n\t\t\t\t\tstonecropRecord(doctype: String!, id: String!, options: JSON): StonecropRecordResult\n\t\t\t\t\tstonecropRecords(\n\t\t\t\t\t\tdoctype: String!\n\t\t\t\t\t\tfilters: JSON\n\t\t\t\t\t\torderBy: String\n\t\t\t\t\t\tlimit: Int\n\t\t\t\t\t\toffset: Int\n\t\t\t\t\t): StonecropRecordsResult\n\t\t\t\t}\n\n\t\t\t\textend type Mutation {\n\t\t\t\t\tstonecropAction(doctype: String!, action: String!, args: JSON): StonecropActionResult!\n\t\t\t\t}\n\t\t\t`,\n\n\t\t\tobjects: {\n\t\t\t\tQuery: {\n\t\t\t\t\tplans: {\n\t\t\t\t\t\tstonecropMeta(_: any, { $doctype }: any) {\n\t\t\t\t\t\t\treturn lambda($doctype, (doctype: unknown) => {\n\t\t\t\t\t\t\t\tconst meta = getMeta(doctype as string)\n\t\t\t\t\t\t\t\treturn meta ?? null\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\tstonecropAllMeta() {\n\t\t\t\t\t\t\treturn constant(getAllMeta())\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\tstonecropRecord(_: any, { $doctype, $id, $options }: any) {\n\t\t\t\t\t\t\treturn loadOne(\n\t\t\t\t\t\t\t\tobject({ doctype: $doctype, id: $id, options: $options }),\n\t\t\t\t\t\t\t\tasync (specs: readonly any[]) => {\n\t\t\t\t\t\t\t\t\treturn await Promise.all(\n\t\t\t\t\t\t\t\t\t\tspecs.map(async spec => {\n\t\t\t\t\t\t\t\t\t\t\tconst meta = getMeta(spec.doctype)\n\t\t\t\t\t\t\t\t\t\t\tif (!meta) {\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new Error(`Unknown doctype: ${spec.doctype}`)\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tif (!meta.tableName) {\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new Error(`Doctype ${spec.doctype} has no table mapping`)\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tconst recordOptions = spec.options ?? {}\n\n\t\t\t\t\t\t\t\t\t\t\tconst query = buildRecordQuery(\n\t\t\t\t\t\t\t\t\t\t\t\tmeta,\n\t\t\t\t\t\t\t\t\t\t\t\trecordFieldName,\n\t\t\t\t\t\t\t\t\t\t\t\trecordArgName,\n\t\t\t\t\t\t\t\t\t\t\t\trecordArgType,\n\t\t\t\t\t\t\t\t\t\t\t\tgetMeta,\n\t\t\t\t\t\t\t\t\t\t\t\trecordOptions.includeNested\n\t\t\t\t\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tincludeNested: recordOptions.includeNested,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tmaxDepth: recordOptions.maxDepth,\n\t\t\t\t\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\t\t\t\t\treverseConnectionName\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\tconst result = await options.executor.query(query, {\n\t\t\t\t\t\t\t\t\t\t\t\t[recordArgName(meta.tableName!)]: spec.id,\n\t\t\t\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\t\t\t\tlet data = extractSingleResult({ result, meta, recordFieldName })\n\n\t\t\t\t\t\t\t\t\t\t\tif (recordOptions.includeNested && data && meta.links) {\n\t\t\t\t\t\t\t\t\t\t\t\tdata = mergeNestedResults({\n\t\t\t\t\t\t\t\t\t\t\t\t\trecord: data as Record<string, unknown>,\n\t\t\t\t\t\t\t\t\t\t\t\t\tmeta,\n\t\t\t\t\t\t\t\t\t\t\t\t\tgetMeta,\n\t\t\t\t\t\t\t\t\t\t\t\t\treverseConnectionNameFn: reverseConnectionName,\n\t\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tconst unknownLinks =\n\t\t\t\t\t\t\t\t\t\t\t\tArray.isArray(recordOptions.includeNested) && meta.links\n\t\t\t\t\t\t\t\t\t\t\t\t\t? recordOptions.includeNested.filter((name: string) => !(name in meta.links!))\n\t\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\n\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\t\t\t\t\t\tdoctype: spec.doctype,\n\t\t\t\t\t\t\t\t\t\t\t\t...(unknownLinks ? { unknownLinks } : {}),\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\tstonecropRecords(_: any, { $doctype, $filters, $orderBy, $limit, $offset }: any) {\n\t\t\t\t\t\t\treturn loadOne(\n\t\t\t\t\t\t\t\tobject({\n\t\t\t\t\t\t\t\t\tdoctype: $doctype,\n\t\t\t\t\t\t\t\t\tfilters: $filters,\n\t\t\t\t\t\t\t\t\torderBy: $orderBy,\n\t\t\t\t\t\t\t\t\tlimit: $limit,\n\t\t\t\t\t\t\t\t\toffset: $offset,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\tasync (specs: readonly any[]) => {\n\t\t\t\t\t\t\t\t\treturn await Promise.all(\n\t\t\t\t\t\t\t\t\t\tspecs.map(async spec => {\n\t\t\t\t\t\t\t\t\t\t\tconst meta = getMeta(spec.doctype)\n\t\t\t\t\t\t\t\t\t\t\tif (!meta) {\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new Error(`Unknown doctype: ${spec.doctype}`)\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tif (!meta.tableName) {\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new Error(`Doctype ${spec.doctype} has no table mapping`)\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tconst query = buildListQuery(\n\t\t\t\t\t\t\t\t\t\t\t\tmeta,\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tlimit: spec.limit,\n\t\t\t\t\t\t\t\t\t\t\t\t\toffset: spec.offset,\n\t\t\t\t\t\t\t\t\t\t\t\t\torderBy: spec.orderBy,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\tconnectionFieldName,\n\t\t\t\t\t\t\t\t\t\t\t\torderByTypeName\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\tconst result = await options.executor.query(query, {\n\t\t\t\t\t\t\t\t\t\t\t\tlimit: spec.limit,\n\t\t\t\t\t\t\t\t\t\t\t\toffset: spec.offset,\n\t\t\t\t\t\t\t\t\t\t\t\torderBy: spec.orderBy,\n\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t\tconst data = extractListResult({ result, meta, connectionFieldName })\n\n\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\t\t\t\t\t\tdoctype: spec.doctype,\n\t\t\t\t\t\t\t\t\t\t\t\tcount: data.length,\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\n\t\t\t\tMutation: {\n\t\t\t\t\tplans: {\n\t\t\t\t\t\tstonecropAction(_: any, { $doctype, $action, $args: $actionArgs }: any) {\n\t\t\t\t\t\t\treturn loadOne(\n\t\t\t\t\t\t\t\tobject({\n\t\t\t\t\t\t\t\t\tdoctype: $doctype,\n\t\t\t\t\t\t\t\t\taction: $action,\n\t\t\t\t\t\t\t\t\tactionArgs: $actionArgs,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\tasync (specs: readonly any[]) => {\n\t\t\t\t\t\t\t\t\treturn await Promise.all(\n\t\t\t\t\t\t\t\t\t\tspecs.map(async spec => {\n\t\t\t\t\t\t\t\t\t\t\tconst meta = getMeta(spec.doctype)\n\t\t\t\t\t\t\t\t\t\t\tif (!meta) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: null,\n\t\t\t\t\t\t\t\t\t\t\t\t\terror: `Unknown doctype: ${spec.doctype}`,\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tconst actionDef = meta.workflow?.actions?.[spec.action]\n\t\t\t\t\t\t\t\t\t\t\tif (!actionDef) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: null,\n\t\t\t\t\t\t\t\t\t\t\t\t\terror: `Unknown action: ${spec.action} on ${spec.doctype}`,\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tconst handlerName = actionDef.handler\n\t\t\t\t\t\t\t\t\t\t\tconst handler = getHandler(handlerName)\n\t\t\t\t\t\t\t\t\t\t\tif (!handler) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: null,\n\t\t\t\t\t\t\t\t\t\t\t\t\terror: `Handler not registered: ${handlerName}`,\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tconst actionContext: ActionContext = {\n\t\t\t\t\t\t\t\t\t\t\t\tdoctype: meta,\n\t\t\t\t\t\t\t\t\t\t\t\texecutor: options.executor,\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\t\tconst result = await handler(spec.actionArgs ?? [], actionContext)\n\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: result,\n\t\t\t\t\t\t\t\t\t\t\t\t\terror: null,\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: null,\n\t\t\t\t\t\t\t\t\t\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t})\n}\n\n// =============================================================================\n// Inflection helpers — default to PostGraphile Amber preset conventions\n// Uses `pluralize` for proper English singularization (handles irregular\n// plurals like statuses→status, categories→category, addresses→address).\n// snakeToCamel / toPascalCase are imported from @stonecrop/schema.\n// =============================================================================\n\n/**\n * Amber default: sales_orders → salesOrderById\n * Uses `pluralize` for proper singularization of irregular plurals.\n * Override via `StonecropInflectionConfig.recordFieldName` for non-standard PK columns.\n * @public\n */\nfunction defaultRecordFieldName(tableName: string): string {\n\tconst singular = pluralize.singular(tableName)\n\treturn `${snakeToCamel(singular)}ById`\n}\n\n/**\n * Amber default: sales_orders → allSalesOrders\n * @public\n */\nfunction defaultConnectionFieldName(tableName: string): string {\n\treturn `all${toPascalCase(tableName)}`\n}\n\n/**\n * Amber default: sales_orders → SalesOrdersOrderBy\n * @public\n */\nfunction defaultOrderByTypeName(tableName: string): string {\n\treturn `${toPascalCase(tableName)}OrderBy`\n}\n\n/**\n * Default PK argument name: 'id' (standard Relay Global ID pattern).\n * Override via `StonecropInflectionConfig.recordArgName` when using row_id columns;\n * PostGraphile Amber generates `rowId: UUID!` for those fields.\n * @public\n */\nfunction defaultRecordArgName(_tableName: string): string {\n\treturn 'id'\n}\n\n/**\n * Default PK argument type: 'UUID!' (PostGraphile Amber default for UUID PKs).\n * Override via `StonecropInflectionConfig.recordArgType` when using non-UUID PKs\n * such as integer serials or Relay Global IDs ('ID!').\n * @public\n */\nfunction defaultRecordArgType(_tableName: string): string {\n\treturn 'UUID!'\n}\n\n/**\n * Default reverse connection name: derives PostGraphile's connection field convention.\n * PostGraphile convention: `{targetPlural}By{FkColumnPascal}Id`\n * - When backlink is defined: FK column is derived from the backlink field name\n * - When backlink is absent: FK column is derived from the parent doctype's table name\n * @public\n */\nfunction defaultReverseConnectionName(params: {\n\tdoctype: string\n\tlinkName: string\n\tbacklink?: string\n\ttarget: string\n}): string {\n\tconst targetPlural = pluralize.plural(params.target.replace(/-/g, '_'))\n\tconst targetPascal = toPascalCase(targetPlural)\n\t// Use backlink if provided, otherwise derive from parent table name\n\tconst fkSource = params.backlink || params.doctype\n\t// FK column name: uppercase first char, preserve rest of camelCase\n\tconst fkPascal = fkSource.charAt(0).toUpperCase() + fkSource.slice(1)\n\treturn `${targetPascal}By${fkPascal}Id`\n}\n\n/**\n * Check if a cardinality represents a \"many\" relationship\n */\nfunction isManyCardinality(cardinality: string): boolean {\n\treturn cardinality === 'noneOrMany' || cardinality === 'atLeastOne'\n}\n\n// =============================================================================\n// Query builders — generate GraphQL queries to send to the underlying schema\n// =============================================================================\n\nconst DEFAULT_SYNC_LIMIT = 50\n\n/**\n * Fieldtypes that map to GraphQL object/connection types and require sub-selections.\n * These fields are excluded from generated query field selections.\n * @public\n */\nconst RELATION_FIELDTYPES = new Set(['Link'])\n\n/**\n * Filter fields to only those directly queryable as scalars, excluding Link and Doctype\n * relation fields that require GraphQL sub-selections.\n * @public\n */\nfunction queryableFieldNames(meta: DoctypeMeta): string {\n\treturn meta.fields\n\t\t.filter(f => !RELATION_FIELDTYPES.has(f.fieldtype))\n\t\t.map(f => f.fieldname)\n\t\t.join('\\n ')\n}\n\n/**\n * Get the effective fetch strategy for a link, applying cardinality-based defaults.\n */\nfunction getEffectiveFetchStrategy(link: LinkDeclaration): SyncFetch | LazyFetch {\n\tif (link.fetch !== undefined) {\n\t\treturn link.fetch as SyncFetch | LazyFetch\n\t}\n\n\tif (isManyCardinality(link.cardinality)) {\n\t\treturn { method: 'sync', limit: DEFAULT_SYNC_LIMIT }\n\t} else {\n\t\treturn { method: 'lazy' }\n\t}\n}\n\n/**\n * Get the effective blockWorkflows value for a link.\n */\nfunction getEffectiveBlockWorkflows(link: LinkDeclaration): boolean {\n\tif (link.blockWorkflows !== undefined) {\n\t\treturn link.blockWorkflows\n\t}\n\tconst effectiveFetch = getEffectiveFetchStrategy(link)\n\treturn effectiveFetch.method === 'sync'\n}\n\n/**\n * Build nested sub-selections for descendant links\n */\nfunction buildNestedSelections(params: BuildNestedSelectionsParams): string {\n\tconst { links, meta, includeSet, getMeta, seen, depth, maxDepth, reverseConnectionNameFn } = params\n\n\tif (maxDepth !== undefined && depth >= maxDepth) return ''\n\n\tconst selections: string[] = []\n\n\tfor (const [fieldname, link] of Object.entries(links)) {\n\t\tif (maxDepth !== undefined && depth >= maxDepth) break\n\n\t\tconst effectiveBlockWorkflows = getEffectiveBlockWorkflows(link)\n\t\tconst linkBlockWorkflowsExplicitTrue = link.blockWorkflows === true\n\n\t\tif (includeSet && !includeSet.has(fieldname) && !linkBlockWorkflowsExplicitTrue) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst effectiveFetch = getEffectiveFetchStrategy(link)\n\t\tconst shouldSkip =\n\t\t\teffectiveBlockWorkflows === false || (effectiveFetch.method !== 'sync' && !linkBlockWorkflowsExplicitTrue)\n\t\tif (shouldSkip) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst targetMeta = getMeta(link.target)\n\t\tif (!targetMeta) continue\n\n\t\tconst alreadySeen = seen.has(link.target)\n\t\tif (alreadySeen) {\n\t\t} else {\n\t\t\tseen.add(link.target)\n\t\t}\n\t\tconst scalarFields = queryableFieldNames(targetMeta)\n\n\t\tlet nestedLinks = ''\n\t\tif (!alreadySeen && targetMeta.links && targetMeta.tableName && (maxDepth === undefined || depth + 1 < maxDepth)) {\n\t\t\tconst innerSelections = buildNestedSelections({\n\t\t\t\tlinks: targetMeta.links,\n\t\t\t\tmeta: targetMeta,\n\t\t\t\tincludeSet: null,\n\t\t\t\tgetMeta,\n\t\t\t\tseen,\n\t\t\t\tdepth: depth + 1,\n\t\t\t\tmaxDepth,\n\t\t\t\treverseConnectionNameFn,\n\t\t\t})\n\t\t\tif (innerSelections) {\n\t\t\t\tnestedLinks = '\\n ' + innerSelections\n\t\t\t}\n\t\t\tseen.delete(link.target)\n\t\t}\n\n\t\tconst fullSelection = scalarFields + nestedLinks\n\n\t\tif (isManyCardinality(link.cardinality)) {\n\t\t\tconst reverseParams: ReverseConnectionParams = {\n\t\t\t\tdoctype: meta.slug || meta.name,\n\t\t\t\tlinkName: fieldname,\n\t\t\t\tbacklink: link.backlink,\n\t\t\t\ttarget: link.target,\n\t\t\t}\n\t\t\tconst connectionField = reverseConnectionNameFn\n\t\t\t\t? reverseConnectionNameFn(reverseParams)\n\t\t\t\t: defaultReverseConnectionName(reverseParams)\n\t\t\tconst limitArg =\n\t\t\t\teffectiveFetch.method === 'sync' && effectiveFetch.limit !== undefined\n\t\t\t\t\t? `first: ${effectiveFetch.limit}`\n\t\t\t\t\t: effectiveFetch.method === 'sync'\n\t\t\t\t\t? `first: ${DEFAULT_SYNC_LIMIT}`\n\t\t\t\t\t: ''\n\t\t\tselections.push(`\n\t\t\t${connectionField}${limitArg ? `(${limitArg})` : ''} {\n\t\t\t\tnodes {\n\t\t\t\t\t${fullSelection}\n\t\t\t\t}\n\t\t\t}`)\n\t\t} else {\n\t\t\tselections.push(`\n\t\t\t${fieldname} {\n\t\t\t\t${fullSelection}\n\t\t\t}`)\n\t\t}\n\t}\n\n\treturn selections.join('')\n}\n\n/**\n * Build a GraphQL query to fetch a single record by ID.\n * When includeNested is set, recursively includes descendant link sub-selections.\n * @public\n */\nfunction buildRecordQuery(\n\tmeta: DoctypeMeta,\n\trecordFieldName: (t: string) => string,\n\trecordArgName: (t: string) => string,\n\trecordArgType: (t: string) => string,\n\tgetMeta: (slug: string) => DoctypeMeta | undefined,\n\toptions?: BuildRecordQueryOptions,\n\treverseConnectionNameFn?: (params: ReverseConnectionParams) => string\n): string {\n\tconst queryName = recordFieldName(meta.tableName!)\n\tconst argName = recordArgName(meta.tableName!)\n\tconst argType = recordArgType(meta.tableName!)\n\n\tconst seen = new Set<string>([meta.slug || meta.name])\n\n\tlet selection = queryableFieldNames(meta)\n\n\tif (options?.includeNested && meta.links) {\n\t\tconst includeSet = Array.isArray(options.includeNested) ? new Set(options.includeNested) : null\n\n\t\tconst nestedSelections = buildNestedSelections({\n\t\t\tlinks: meta.links,\n\t\t\tmeta,\n\t\t\tincludeSet,\n\t\t\tgetMeta,\n\t\t\tseen,\n\t\t\tdepth: 0,\n\t\t\tmaxDepth: options.maxDepth,\n\t\t\treverseConnectionNameFn,\n\t\t})\n\n\t\tif (nestedSelections) {\n\t\t\tselection += '\\n ' + nestedSelections\n\t\t}\n\t}\n\n\treturn `\n\t\tquery GetRecord($${argName}: ${argType}) {\n\t\t\t${queryName}(${argName}: $${argName}) {\n\t\t\t\t${selection}\n\t\t\t}\n\t\t}\n\t`\n}\n\n/**\n * Build a GraphQL connection query to fetch a list of records.\n * Only declares variables ($limit, $offset, $orderBy) that are actually used in the query,\n * avoiding GraphQL spec §5.8.3 violations from unused variable declarations.\n * Excludes Link and Doctype relation fields from the selection set.\n * @public\n */\nfunction buildListQuery(\n\tmeta: DoctypeMeta,\n\targs: BuildListQueryArgs,\n\tconnectionFieldName: (t: string) => string,\n\torderByTypeName: (t: string) => string\n): string {\n\tconst fieldNames = queryableFieldNames(meta)\n\tconst connectionName = connectionFieldName(meta.tableName!)\n\tconst orderByType = orderByTypeName(meta.tableName!)\n\n\tconst varDecls: string[] = []\n\tconst queryArgs: string[] = []\n\tif (args.limit) {\n\t\tvarDecls.push('$limit: Int')\n\t\tqueryArgs.push(`first: $limit`)\n\t}\n\tif (args.offset) {\n\t\tvarDecls.push('$offset: Int')\n\t\tqueryArgs.push(`offset: $offset`)\n\t}\n\tif (args.orderBy) {\n\t\tvarDecls.push(`$orderBy: [${orderByType}!]`)\n\t\tqueryArgs.push(`orderBy: $orderBy`)\n\t}\n\n\tconst varStr = varDecls.length > 0 ? `(${varDecls.join(', ')})` : ''\n\tconst argsStr = queryArgs.length > 0 ? `(${queryArgs.join(', ')})` : ''\n\n\treturn `\n\t\tquery GetRecords${varStr} {\n\t\t\t${connectionName}${argsStr} {\n\t\t\t\tnodes {\n\t\t\t\t${fieldNames}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t`\n}\n\n/**\n * Merge nested connection results into flat arrays.\n * For `noneOrMany`/`atLeastOne` links, the query returns `{ nodes: [...] }`.\n * This flattens them to just `[]` for easier consumption.\n * @public\n */\nfunction mergeNestedResults(params: MergeNestedResultsParams): Record<string, unknown> {\n\tconst { record, meta, getMeta, reverseConnectionNameFn } = params\n\tif (!meta.links) return record\n\n\tconst merged = { ...record }\n\n\tfor (const [fieldname, link] of Object.entries(meta.links)) {\n\t\tconst isMany = isManyCardinality(link.cardinality)\n\n\t\tif (isMany) {\n\t\t\tconst targetMeta = getMeta(link.target)\n\t\t\tif (!targetMeta) continue\n\n\t\t\tconst reverseParams: ReverseConnectionParams = {\n\t\t\t\tdoctype: meta.slug || meta.name,\n\t\t\t\tlinkName: fieldname,\n\t\t\t\tbacklink: link.backlink || fieldname,\n\t\t\t\ttarget: link.target,\n\t\t\t}\n\t\t\tconst connectionField = reverseConnectionNameFn\n\t\t\t\t? reverseConnectionNameFn(reverseParams)\n\t\t\t\t: defaultReverseConnectionName(reverseParams)\n\t\t\tconst connectionResult = merged[connectionField] as { nodes?: unknown[] } | undefined\n\t\t\tif (connectionResult?.nodes) {\n\t\t\t\tmerged[fieldname] = connectionResult.nodes\n\t\t\t\tdelete merged[connectionField]\n\t\t\t} else {\n\t\t\t\tmerged[fieldname] = []\n\t\t\t\tdelete merged[connectionField]\n\t\t\t}\n\t\t}\n\t}\n\n\treturn merged\n}\n\n/**\n * Extract a single record from a PostGraphile query result using the record field name.\n * @public\n */\nfunction extractSingleResult(params: ExtractSingleResultParams): unknown {\n\tconst { result, meta, recordFieldName } = params\n\tconst queryName = recordFieldName(meta.tableName!)\n\treturn (result as Record<string, unknown>)[queryName]\n}\n\n/**\n * Extract the list of nodes from a PostGraphile connection query result.\n * Returns an empty array if the connection field is absent.\n * @public\n */\nfunction extractListResult(params: ExtractListResultParams): unknown[] {\n\tconst { result, meta, connectionFieldName } = params\n\tconst connectionName = connectionFieldName(meta.tableName!)\n\tconst connection = (result as Record<string, unknown>)[connectionName] as {\n\t\tnodes: unknown[]\n\t}\n\treturn connection?.nodes ?? []\n}\n\n// =============================================================================\n// Exported for testing and advanced usage\n// =============================================================================\n\nexport {\n\tdefaultRecordFieldName,\n\tdefaultConnectionFieldName,\n\tdefaultOrderByTypeName,\n\tdefaultRecordArgName,\n\tdefaultRecordArgType,\n\tdefaultReverseConnectionName,\n\tbuildRecordQuery,\n\tbuildListQuery,\n\tqueryableFieldNames,\n\tRELATION_FIELDTYPES,\n\textractSingleResult,\n\textractListResult,\n\tmergeNestedResults,\n}\n","import { gql } from 'postgraphile/utils'\n\n/**\n * GraphQL type definitions for Stonecrop's middleware API.\n * Includes stonecropMeta, stonecropRecord, stonecropRecords, stonecropAction, and related types.\n * @public\n */\nexport const typeDefs = gql`\n\ttype StonecropFieldMeta {\n\t\tfieldname: String!\n\t\tfieldtype: String!\n\t\tcomponent: String\n\t\tlabel: String\n\t\twidth: String\n\t\talign: String\n\t\trequired: Boolean\n\t\treadOnly: Boolean\n\t\tedit: Boolean\n\t\thidden: Boolean\n\t\tdefault: JSON\n\t\toptions: JSON\n\t\tmask: String\n\t\tprecision: Int\n\t\tscale: Int\n\t\tmode: String\n\t\tvalidation: JSON\n\t}\n\n\ttype StonecropWorkflowAction {\n\t\tlabel: String!\n\t\thandler: String!\n\t\trequiredFields: [String!]\n\t\tallowedStates: [String!]\n\t\tconfirm: Boolean\n\t\targs: JSON\n\t}\n\n\ttype StonecropWorkflowMeta {\n\t\tstates: [String!]\n\t\tactions: [StonecropWorkflowAction!]\n\t}\n\n\ttype StonecropDoctypeMeta {\n\t\tname: String!\n\t\tslug: String\n\t\ttableName: String\n\t\tfields: [StonecropFieldMeta!]!\n\t\tworkflow: StonecropWorkflowMeta\n\t\tinherits: String\n\t}\n\n\ttype StonecropRecordResult {\n\t\tdata: JSON\n\t\tdoctype: String!\n\t\tunknownLinks: [String!]\n\t}\n\n\ttype StonecropRecordsResult {\n\t\tdata: [JSON!]!\n\t\tdoctype: String!\n\t\tcount: Int!\n\t}\n\n\ttype StonecropActionResult {\n\t\tsuccess: Boolean!\n\t\tdata: JSON\n\t\terror: String\n\t}\n\n\textend type Query {\n\t\tstonecropMeta(doctype: String!): StonecropDoctypeMeta\n\t\tstonecropAllMeta: [StonecropDoctypeMeta!]!\n\t\tstonecropRecord(doctype: String!, id: String!, options: JSON): StonecropRecordResult\n\t\tstonecropRecords(doctype: String!, filters: JSON, orderBy: String, limit: Int, offset: Int): StonecropRecordsResult\n\t}\n\n\textend type Mutation {\n\t\tstonecropAction(doctype: String!, action: String!, args: JSON): StonecropActionResult!\n\t}\n`\n"],"names":["doctypeRegistry","DoctypeValidationError","file","errors","errorMessages","e","loadDoctypes","dir","options","entries","readdirSync","entry","fullPath","join","statSync","loadDoctypeFile","filePath","content","readFileSync","data","err","parseError","result","validateDoctype","doctype","parseDoctype","loadDoctypesFromObject","doctypes","name","withName","getMeta","getAllMeta","hasMeta","clearRegistry","validateReferences","field","handlerRegistry","registerHandler","handler","getHandler","hasHandler","clearHandlers","validateRequiredFields","args","context","record","missing","validateFieldTypes","value","error","validateFieldValue","fieldname","link","fieldtype","cardinality","noop","builtinHandlers","registerBuiltinHandlers","createStonecropPlugin","recordFieldName","defaultRecordFieldName","connectionFieldName","defaultConnectionFieldName","orderByTypeName","defaultOrderByTypeName","recordArgName","defaultRecordArgName","recordArgType","defaultRecordArgType","reverseConnectionName","defaultReverseConnectionName","extendSchema","gql","_","$doctype","lambda","constant","$id","$options","loadOne","object","specs","spec","meta","recordOptions","query","buildRecordQuery","extractSingleResult","mergeNestedResults","unknownLinks","$filters","$orderBy","$limit","$offset","buildListQuery","extractListResult","$action","$actionArgs","actionDef","handlerName","actionContext","tableName","singular","pluralize","snakeToCamel","toPascalCase","_tableName","params","targetPlural","targetPascal","fkSource","fkPascal","isManyCardinality","DEFAULT_SYNC_LIMIT","RELATION_FIELDTYPES","queryableFieldNames","f","getEffectiveFetchStrategy","getEffectiveBlockWorkflows","buildNestedSelections","links","includeSet","seen","depth","maxDepth","reverseConnectionNameFn","selections","effectiveBlockWorkflows","linkBlockWorkflowsExplicitTrue","effectiveFetch","targetMeta","alreadySeen","scalarFields","nestedLinks","innerSelections","fullSelection","reverseParams","connectionField","limitArg","queryName","argName","argType","selection","nestedSelections","fieldNames","connectionName","orderByType","varDecls","queryArgs","varStr","argsStr","merged","connectionResult","typeDefs"],"mappings":";;;;;;AAMA,MAAMA,wBAAgD,IAAA;AAM/C,MAAMC,UAA+B,MAAM;AAAA,EACjD,YAEiBC,GAEAC,GACf;AACD,UAAMC,IAAgBD,EAAO,IAAI,CAAAE,MAAK,KAAKA,EAAE,KAAK,KAAK,GAAG,CAAC,KAAKA,EAAE,OAAO,EAAE,EAAE,KAAK;AAAA,CAAI;AACtF,UAAM,iCAAiCH,CAAI;AAAA,EAAME,CAAa,EAAE,GALhD,KAAA,OAAAF,GAEA,KAAA,SAAAC,GAIhB,KAAK,OAAO;AAAA,EACb;AACD;AAmBO,SAASG,EAAaC,GAAaC,IAA+B,IAAU;AAClF,QAAMC,IAAUC,EAAYH,CAAG;AAE/B,aAAWI,KAASF,GAAS;AAC5B,UAAMG,IAAWC,EAAKN,GAAKI,CAAK;AAGhC,IAFaG,EAASF,CAAQ,EAErB,gBACRN,EAAaM,GAAUJ,CAAO,IACpBG,EAAM,SAAS,OAAO,KAChCI,EAAgBH,GAAUJ,CAAO;AAAA,EAEnC;AACD;AAKA,SAASO,EAAgBC,GAAkBR,GAAoC;AAC9E,QAAMS,IAAUC,EAAaF,GAAU,OAAO;AAC9C,MAAIG;AAEJ,MAAI;AACH,IAAAA,IAAO,KAAK,MAAMF,CAAO;AAAA,EAC1B,SAASG,GAAK;AACb,UAAMC,IAA8B;AAAA,MACnC,MAAM,CAAA;AAAA,MACN,SAAS,iBAAiBD,aAAe,QAAQA,EAAI,UAAU,OAAOA,CAAG,CAAC;AAAA,IAAA;AAG3E,QAAIZ,EAAQ,iBAAiB;AAC5B,MAAAA,EAAQ,UAAUQ,GAAU,CAACK,CAAU,CAAC;AACxC;AAAA,IACD;AACA,UAAM,IAAIpB,EAAuBe,GAAU,CAACK,CAAU,CAAC;AAAA,EACxD;AAEA,QAAMC,IAASC,EAAgBJ,CAAI;AAEnC,MAAI,CAACG,EAAO,SAAS;AACp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,QAAArF,GAAQ,MAAA6D,GAAM,qBAAAtB,EAAA,IAAwB8C,GACxCsC,IAAiBpF,EAAoBsB,EAAK,SAAU;AAI1D,SAHoB7D,EAAmC2H,CAAc,GAGlD,SAAS,CAAA;AAC7B;AC3wBO,MAAMQ,KAAWjF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
|
|
@@ -133,7 +133,12 @@ export const createStonecropPlugin = (options) => {
|
|
|
133
133
|
});
|
|
134
134
|
let data = extractSingleResult({ result, meta, recordFieldName });
|
|
135
135
|
if (recordOptions.includeNested && data && meta.links) {
|
|
136
|
-
data = mergeNestedResults({
|
|
136
|
+
data = mergeNestedResults({
|
|
137
|
+
record: data,
|
|
138
|
+
meta,
|
|
139
|
+
getMeta,
|
|
140
|
+
reverseConnectionNameFn: reverseConnectionName,
|
|
141
|
+
});
|
|
137
142
|
}
|
|
138
143
|
const unknownLinks = Array.isArray(recordOptions.includeNested) && meta.links
|
|
139
144
|
? recordOptions.includeNested.filter((name) => !(name in meta.links))
|
|
@@ -519,7 +524,7 @@ function buildListQuery(meta, args, connectionFieldName, orderByTypeName) {
|
|
|
519
524
|
* @public
|
|
520
525
|
*/
|
|
521
526
|
function mergeNestedResults(params) {
|
|
522
|
-
const { record, meta, getMeta } = params;
|
|
527
|
+
const { record, meta, getMeta, reverseConnectionNameFn } = params;
|
|
523
528
|
if (!meta.links)
|
|
524
529
|
return record;
|
|
525
530
|
const merged = { ...record };
|
|
@@ -535,7 +540,9 @@ function mergeNestedResults(params) {
|
|
|
535
540
|
backlink: link.backlink || fieldname,
|
|
536
541
|
target: link.target,
|
|
537
542
|
};
|
|
538
|
-
const connectionField =
|
|
543
|
+
const connectionField = reverseConnectionNameFn
|
|
544
|
+
? reverseConnectionNameFn(reverseParams)
|
|
545
|
+
: defaultReverseConnectionName(reverseParams);
|
|
539
546
|
const connectionResult = merged[connectionField];
|
|
540
547
|
if (connectionResult?.nodes) {
|
|
541
548
|
merged[fieldname] = connectionResult.nodes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgraphile.d.ts","sourceRoot":"","sources":["../../../src/plugin/postgraphile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAyC,MAAM,mBAAmB,CAAA;AAG3F,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAM5D,OAAO,KAAK,EAEX,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EAEvB,kBAAkB,EAClB,wBAAwB,EACxB,yBAAyB,EACzB,uBAAuB,EACvB,MAAM,UAAU,CAAA;AAEjB;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB;IACzC;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;IAE/C;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;IAEnD;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;IAE/C;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;IAE7C;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;IAE7C;;;;;;OAMG;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BAAS,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,EAAE,CAOrE;AAMD,OAAO,EACN,sBAAsB,EACtB,0BAA0B,EAC1B,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,4BAA4B,EAC5B,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,GAClB,CAAA"}
|
|
@@ -102,6 +102,8 @@ export interface MergeNestedResultsParams {
|
|
|
102
102
|
meta: DoctypeMeta;
|
|
103
103
|
/** Lookup function to get doctype metadata by slug */
|
|
104
104
|
getMeta: (slug: string) => DoctypeMeta | undefined;
|
|
105
|
+
/** Function to derive the reverse connection field name from link params */
|
|
106
|
+
reverseConnectionNameFn?: (params: ReverseConnectionParams) => string;
|
|
105
107
|
}
|
|
106
108
|
/**
|
|
107
109
|
* Parameters for extractSingleResult
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/types/query.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAErE;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACvC,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAA;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACvC,qCAAqC;IACrC,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;IAClC,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACtC,uBAAuB;IACvB,IAAI,EAAE,WAAW,CAAA;IACjB,i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IACjB,sBAAsB;IACtB,IAAI,EAAE,kBAAkB,CAAA;IACxB,qEAAqE;IACrE,mBAAmB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;IAClD,iEAAiE;IACjE,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;CAC9C;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACxC,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,uBAAuB;IACvB,IAAI,EAAE,WAAW,CAAA;IACjB,sDAAsD;IACtD,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAA;IAClD,4EAA4E;IAC5E,uBAAuB,CAAC,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,MAAM,CAAA;CACrE;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACzC,2BAA2B;IAC3B,MAAM,EAAE,OAAO,CAAA;IACf,uBAAuB;IACvB,IAAI,EAAE,WAAW,CAAA;IACjB,iEAAiE;IACjE,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;CAC9C;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACvC,2BAA2B;IAC3B,MAAM,EAAE,OAAO,CAAA;IACf,uBAAuB;IACvB,IAAI,EAAE,WAAW,CAAA;IACjB,qEAAqE;IACrE,mBAAmB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;CAClD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stonecrop/graphql-middleware",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/graphql-middleware.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"graphql": "^16.12.0",
|
|
18
18
|
"pluralize": "^8.0.0",
|
|
19
19
|
"postgraphile": "^5.0.0-rc.7",
|
|
20
|
-
"@stonecrop/schema": "0.11.
|
|
20
|
+
"@stonecrop/schema": "0.11.3"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@rushstack/heft": "^1.2.0",
|