@stonecrop/graphql-middleware 0.10.11 → 0.10.12

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/index.js CHANGED
@@ -1,126 +1,126 @@
1
- import { readdirSync as A, statSync as E, readFileSync as x } from "node:fs";
1
+ import { readdirSync as B, statSync as x, readFileSync as E } from "node:fs";
2
2
  import { join as M } from "node:path";
3
3
  import { validateDoctype as R, parseDoctype as k, toPascalCase as O, snakeToCamel as F } from "@stonecrop/schema";
4
- import { loadOne as w, object as b, constant as j, lambda as q } from "postgraphile/grafast";
4
+ import { loadOne as b, object as w, constant as j, lambda as q } from "postgraphile/grafast";
5
5
  import { extendSchema as I, gql as T } from "postgraphile/utils";
6
6
  import J from "pluralize";
7
7
  const u = /* @__PURE__ */ new Map();
8
8
  class D extends Error {
9
- constructor(t, r) {
9
+ constructor(e, r) {
10
10
  const o = r.map((n) => ` ${n.path.join(".")}: ${n.message}`).join(`
11
11
  `);
12
- super(`Invalid doctype definition in ${t}:
13
- ${o}`), this.file = t, this.errors = r, this.name = "DoctypeValidationError";
12
+ super(`Invalid doctype definition in ${e}:
13
+ ${o}`), this.file = e, this.errors = r, this.name = "DoctypeValidationError";
14
14
  }
15
15
  }
16
- function L(e, t = {}) {
17
- const r = A(e);
16
+ function L(t, e = {}) {
17
+ const r = B(t);
18
18
  for (const o of r) {
19
- const n = M(e, o);
20
- E(n).isDirectory() ? L(n, t) : o.endsWith(".json") && C(n, t);
19
+ const n = M(t, o);
20
+ x(n).isDirectory() ? L(n, e) : o.endsWith(".json") && C(n, e);
21
21
  }
22
22
  }
23
- function C(e, t) {
24
- const r = x(e, "utf-8");
23
+ function C(t, e) {
24
+ const r = E(t, "utf-8");
25
25
  let o;
26
26
  try {
27
27
  o = JSON.parse(r);
28
- } catch (i) {
29
- const a = {
28
+ } catch (a) {
29
+ const i = {
30
30
  path: [],
31
- message: `Invalid JSON: ${i instanceof Error ? i.message : String(i)}`
31
+ message: `Invalid JSON: ${a instanceof Error ? a.message : String(a)}`
32
32
  };
33
- if (t.continueOnError) {
34
- t.onError?.(e, [a]);
33
+ if (e.continueOnError) {
34
+ e.onError?.(t, [i]);
35
35
  return;
36
36
  }
37
- throw new D(e, [a]);
37
+ throw new D(t, [i]);
38
38
  }
39
39
  const n = R(o);
40
40
  if (!n.success) {
41
- if (t.continueOnError) {
42
- t.onError?.(e, n.errors);
41
+ if (e.continueOnError) {
42
+ e.onError?.(t, n.errors);
43
43
  return;
44
44
  }
45
- throw new D(e, n.errors);
45
+ throw new D(t, n.errors);
46
46
  }
47
47
  const c = k(o);
48
48
  u.set(c.name, c);
49
49
  }
50
- function de(e, t = {}) {
51
- for (const [r, o] of Object.entries(e)) {
50
+ function le(t, e = {}) {
51
+ for (const [r, o] of Object.entries(t)) {
52
52
  const n = { ...o, name: r }, c = R(n);
53
53
  if (!c.success) {
54
- if (t.continueOnError) {
55
- t.onError?.(r, c.errors);
54
+ if (e.continueOnError) {
55
+ e.onError?.(r, c.errors);
56
56
  continue;
57
57
  }
58
58
  throw new D(r, c.errors);
59
59
  }
60
- const i = k(n);
61
- u.set(i.name, i);
60
+ const a = k(n);
61
+ u.set(a.name, a);
62
62
  }
63
63
  }
64
- function h(e) {
65
- return u.get(e);
64
+ function h(t) {
65
+ return u.get(t);
66
66
  }
67
67
  function H() {
68
68
  return Array.from(u.values());
69
69
  }
70
- function fe(e) {
71
- return u.has(e);
70
+ function fe(t) {
71
+ return u.has(t);
72
72
  }
73
73
  function ue() {
74
74
  u.clear();
75
75
  }
76
- function pe() {
77
- const e = [];
78
- for (const t of u.values()) {
79
- t.inherits && !u.has(t.inherits) && e.push({
80
- path: [t.name, "inherits"],
81
- message: `References unknown doctype: ${t.inherits}`
82
- }), t.listDoctype && !u.has(t.listDoctype) && e.push({
83
- path: [t.name, "listDoctype"],
84
- message: `References unknown doctype: ${t.listDoctype}`
85
- }), t.parentDoctype && !u.has(t.parentDoctype) && e.push({
86
- path: [t.name, "parentDoctype"],
87
- message: `References unknown doctype: ${t.parentDoctype}`
76
+ function ye() {
77
+ const t = [];
78
+ for (const e of u.values()) {
79
+ e.inherits && !u.has(e.inherits) && t.push({
80
+ path: [e.name, "inherits"],
81
+ message: `References unknown doctype: ${e.inherits}`
82
+ }), e.listDoctype && !u.has(e.listDoctype) && t.push({
83
+ path: [e.name, "listDoctype"],
84
+ message: `References unknown doctype: ${e.listDoctype}`
85
+ }), e.parentDoctype && !u.has(e.parentDoctype) && t.push({
86
+ path: [e.name, "parentDoctype"],
87
+ message: `References unknown doctype: ${e.parentDoctype}`
88
88
  });
89
- for (const r of t.fields)
90
- r.fieldtype === "Link" && typeof r.options == "string" && (u.has(r.options) || e.push({
91
- path: [t.name, "fields", r.fieldname, "options"],
89
+ for (const r of e.fields)
90
+ r.fieldtype === "Link" && typeof r.options == "string" && (u.has(r.options) || t.push({
91
+ path: [e.name, "fields", r.fieldname, "options"],
92
92
  message: `Link references unknown doctype: ${r.options}`
93
93
  }));
94
94
  }
95
- return e;
95
+ return t;
96
96
  }
97
97
  const $ = /* @__PURE__ */ new Map();
98
- function _(e, t) {
99
- $.set(e, t);
98
+ function _(t, e) {
99
+ $.set(t, e);
100
100
  }
101
- function U(e) {
102
- return $.get(e);
101
+ function U(t) {
102
+ return $.get(t);
103
103
  }
104
- function ye(e) {
105
- return $.has(e);
104
+ function pe(t) {
105
+ return $.has(t);
106
106
  }
107
107
  function me() {
108
108
  $.clear();
109
109
  }
110
- const Q = async (e, t) => {
111
- const [r] = e, { doctype: o } = t, n = [];
110
+ const Q = async (t, e) => {
111
+ const [r] = t, { doctype: o } = e, n = [];
112
112
  for (const c of o.fields)
113
113
  c.required && (r[c.fieldname] === void 0 || r[c.fieldname] === null) && n.push(c.label ?? c.fieldname);
114
114
  if (n.length > 0)
115
115
  throw new Error(`Missing required fields: ${n.join(", ")}`);
116
116
  return { valid: !0 };
117
- }, P = async (e, t) => {
118
- const [r] = e, { doctype: o } = t, n = [];
117
+ }, P = async (t, e) => {
118
+ const [r] = t, { doctype: o } = e, n = [];
119
119
  for (const c of o.fields) {
120
- const i = r[c.fieldname];
121
- if (i == null) continue;
122
- const a = V(c.fieldname, i, c.fieldtype);
123
- a && n.push(a);
120
+ const a = r[c.fieldname];
121
+ if (a == null) continue;
122
+ const i = V(c, a);
123
+ i && n.push(i);
124
124
  }
125
125
  if (n.length > 0)
126
126
  throw new Error(`Field type validation failed:
@@ -128,58 +128,62 @@ ${n.join(`
128
128
  `)}`);
129
129
  return { valid: !0 };
130
130
  };
131
- function V(e, t, r) {
132
- switch (r) {
131
+ function V(t, e) {
132
+ const { fieldname: r, fieldtype: o, cardinality: n } = t;
133
+ switch (o) {
133
134
  case "Int":
134
- if (typeof t != "number" || !Number.isInteger(t))
135
- return `${e}: expected integer, got ${typeof t}`;
135
+ if (typeof e != "number" || !Number.isInteger(e))
136
+ return `${r}: expected integer, got ${typeof e}`;
136
137
  break;
137
138
  case "Float":
138
139
  case "Decimal":
139
140
  case "Currency":
140
141
  case "Quantity":
141
- if (typeof t != "number" && typeof t != "string")
142
- return `${e}: expected number, got ${typeof t}`;
142
+ if (typeof e != "number" && typeof e != "string")
143
+ return `${r}: expected number, got ${typeof e}`;
143
144
  break;
144
145
  case "Check":
145
- if (typeof t != "boolean")
146
- return `${e}: expected boolean, got ${typeof t}`;
146
+ if (typeof e != "boolean")
147
+ return `${r}: expected boolean, got ${typeof e}`;
147
148
  break;
148
149
  case "Data":
149
150
  case "Text":
150
151
  case "Code":
151
152
  case "Link":
152
- if (typeof t != "string")
153
- return `${e}: expected string, got ${typeof t}`;
153
+ if (typeof e != "string")
154
+ return `${r}: expected string, got ${typeof e}`;
154
155
  break;
155
156
  case "Date":
156
157
  case "Time":
157
158
  case "Datetime":
158
- if (typeof t != "string" && !(t instanceof Date))
159
- return `${e}: expected date string or Date, got ${typeof t}`;
159
+ if (typeof e != "string" && !(e instanceof Date))
160
+ return `${r}: expected date string or Date, got ${typeof e}`;
160
161
  break;
161
162
  case "JSON":
162
- if (typeof t != "object")
163
- return `${e}: expected object, got ${typeof t}`;
163
+ if (typeof e != "object")
164
+ return `${r}: expected object, got ${typeof e}`;
164
165
  break;
165
- case "Table":
166
- if (!Array.isArray(t))
167
- return `${e}: expected array, got ${typeof t}`;
166
+ case "Doctype":
167
+ if (n === "many") {
168
+ if (!Array.isArray(e))
169
+ return `${r}: expected array, got ${typeof e}`;
170
+ } else if (typeof e != "object" || Array.isArray(e))
171
+ return `${r}: expected object, got ${typeof e}`;
168
172
  break;
169
173
  }
170
174
  return null;
171
175
  }
172
- const W = async () => ({ ok: !0 }), v = {
176
+ const W = async () => ({ ok: !0 }), G = {
173
177
  validateRequiredFields: Q,
174
178
  validateFieldTypes: P,
175
179
  noop: W
176
180
  };
177
181
  function ge() {
178
- for (const [e, t] of Object.entries(v))
179
- _(e, t);
182
+ for (const [t, e] of Object.entries(G))
183
+ _(t, e);
180
184
  }
181
- const Se = (e) => {
182
- const t = e.inflection?.recordFieldName ?? G, r = e.inflection?.connectionFieldName ?? z, o = e.inflection?.orderByTypeName ?? Y, n = e.inflection?.recordArgName ?? K, c = e.inflection?.recordArgType ?? X;
185
+ const Se = (t) => {
186
+ const e = t.inflection?.recordFieldName ?? z, r = t.inflection?.connectionFieldName ?? Y, o = t.inflection?.orderByTypeName ?? K, n = t.inflection?.recordArgName ?? X, c = t.inflection?.recordArgType ?? Z;
183
187
  return I(() => ({
184
188
  typeDefs: T`
185
189
  type StonecropFieldMeta {
@@ -264,41 +268,41 @@ const Se = (e) => {
264
268
  objects: {
265
269
  Query: {
266
270
  plans: {
267
- stonecropMeta(i, { $doctype: a }) {
268
- return q(a, (d) => h(d) ?? null);
271
+ stonecropMeta(a, { $doctype: i }) {
272
+ return q(i, (l) => h(l) ?? null);
269
273
  },
270
274
  stonecropAllMeta() {
271
275
  return j(H());
272
276
  },
273
- stonecropRecord(i, { $doctype: a, $id: d }) {
274
- return w(b({ doctype: a, id: d }), async (p) => await Promise.all(
275
- p.map(async (f) => {
276
- const l = h(f.doctype);
277
- if (!l)
277
+ stonecropRecord(a, { $doctype: i, $id: l }) {
278
+ return b(w({ doctype: i, id: l }), async (y) => await Promise.all(
279
+ y.map(async (f) => {
280
+ const d = h(f.doctype);
281
+ if (!d)
278
282
  throw new Error(`Unknown doctype: ${f.doctype}`);
279
- if (!l.tableName)
283
+ if (!d.tableName)
280
284
  throw new Error(`Doctype ${f.doctype} has no table mapping`);
281
- const y = ee(l, t, n, c), s = await e.executor.query(y, {
282
- [n(l.tableName)]: f.id
285
+ const p = ee(d, e, n, c), s = await t.executor.query(p, {
286
+ [n(d.tableName)]: f.id
283
287
  });
284
288
  return {
285
- data: re(s, l, t),
289
+ data: re(s, d, e),
286
290
  doctype: f.doctype
287
291
  };
288
292
  })
289
293
  ));
290
294
  },
291
- stonecropRecords(i, { $doctype: a, $filters: d, $orderBy: p, $limit: f, $offset: l }) {
292
- return w(
293
- b({
294
- doctype: a,
295
- filters: d,
296
- orderBy: p,
295
+ stonecropRecords(a, { $doctype: i, $filters: l, $orderBy: y, $limit: f, $offset: d }) {
296
+ return b(
297
+ w({
298
+ doctype: i,
299
+ filters: l,
300
+ orderBy: y,
297
301
  limit: f,
298
- offset: l
302
+ offset: d
299
303
  }),
300
- async (y) => await Promise.all(
301
- y.map(async (s) => {
304
+ async (p) => await Promise.all(
305
+ p.map(async (s) => {
302
306
  const m = h(s.doctype);
303
307
  if (!m)
304
308
  throw new Error(`Unknown doctype: ${s.doctype}`);
@@ -313,7 +317,7 @@ const Se = (e) => {
313
317
  },
314
318
  r,
315
319
  o
316
- ), N = await e.executor.query(S, {
320
+ ), N = await t.executor.query(S, {
317
321
  limit: s.limit,
318
322
  offset: s.offset,
319
323
  orderBy: s.orderBy
@@ -331,28 +335,28 @@ const Se = (e) => {
331
335
  },
332
336
  Mutation: {
333
337
  plans: {
334
- stonecropAction(i, { $doctype: a, $action: d, $args: p }) {
335
- return w(
336
- b({
337
- doctype: a,
338
- action: d,
339
- actionArgs: p
338
+ stonecropAction(a, { $doctype: i, $action: l, $args: y }) {
339
+ return b(
340
+ w({
341
+ doctype: i,
342
+ action: l,
343
+ actionArgs: y
340
344
  }),
341
345
  async (f) => await Promise.all(
342
- f.map(async (l) => {
343
- const y = h(l.doctype);
344
- if (!y)
346
+ f.map(async (d) => {
347
+ const p = h(d.doctype);
348
+ if (!p)
345
349
  return {
346
350
  success: !1,
347
351
  data: null,
348
- error: `Unknown doctype: ${l.doctype}`
352
+ error: `Unknown doctype: ${d.doctype}`
349
353
  };
350
- const s = y.workflow?.actions?.[l.action];
354
+ const s = p.workflow?.actions?.[d.action];
351
355
  if (!s)
352
356
  return {
353
357
  success: !1,
354
358
  data: null,
355
- error: `Unknown action: ${l.action} on ${l.doctype}`
359
+ error: `Unknown action: ${d.action} on ${d.doctype}`
356
360
  };
357
361
  const m = s.handler, S = U(m);
358
362
  if (!S)
@@ -362,13 +366,13 @@ const Se = (e) => {
362
366
  error: `Handler not registered: ${m}`
363
367
  };
364
368
  const N = {
365
- doctype: y,
366
- executor: e.executor
369
+ doctype: p,
370
+ executor: t.executor
367
371
  };
368
372
  try {
369
373
  return {
370
374
  success: !0,
371
- data: await S(l.actionArgs ?? [], N),
375
+ data: await S(d.actionArgs ?? [], N),
372
376
  error: null
373
377
  };
374
378
  } catch (g) {
@@ -387,43 +391,43 @@ const Se = (e) => {
387
391
  }
388
392
  }));
389
393
  };
390
- function G(e) {
391
- const t = J.singular(e);
392
- return `${F(t)}ById`;
394
+ function z(t) {
395
+ const e = J.singular(t);
396
+ return `${F(e)}ById`;
393
397
  }
394
- function z(e) {
395
- return `all${O(e)}`;
398
+ function Y(t) {
399
+ return `all${O(t)}`;
396
400
  }
397
- function Y(e) {
398
- return `${O(e)}OrderBy`;
401
+ function K(t) {
402
+ return `${O(t)}OrderBy`;
399
403
  }
400
- function K(e) {
404
+ function X(t) {
401
405
  return "id";
402
406
  }
403
- function X(e) {
407
+ function Z(t) {
404
408
  return "UUID!";
405
409
  }
406
- const Z = /* @__PURE__ */ new Set(["Link", "Doctype"]);
407
- function B(e) {
408
- return e.fields.filter((t) => !Z.has(t.fieldtype)).map((t) => t.fieldname).join(`
410
+ const v = /* @__PURE__ */ new Set(["Link", "Doctype"]);
411
+ function A(t) {
412
+ return t.fields.filter((e) => !v.has(e.fieldtype)).map((e) => e.fieldname).join(`
409
413
  `);
410
414
  }
411
- function ee(e, t, r, o) {
412
- const n = B(e), c = t(e.tableName), i = r(e.tableName), a = o(e.tableName);
415
+ function ee(t, e, r, o) {
416
+ const n = A(t), c = e(t.tableName), a = r(t.tableName), i = o(t.tableName);
413
417
  return `
414
- query GetRecord($${i}: ${a}) {
415
- ${c}(${i}: $${i}) {
418
+ query GetRecord($${a}: ${i}) {
419
+ ${c}(${a}: $${a}) {
416
420
  ${n}
417
421
  }
418
422
  }
419
423
  `;
420
424
  }
421
- function te(e, t, r, o) {
422
- const n = B(e), c = r(e.tableName), i = o(e.tableName), a = [], d = [];
423
- t.limit && (a.push("$limit: Int"), d.push("first: $limit")), t.offset && (a.push("$offset: Int"), d.push("offset: $offset")), t.orderBy && (a.push(`$orderBy: [${i}!]`), d.push("orderBy: $orderBy"));
424
- const p = a.length > 0 ? `(${a.join(", ")})` : "", f = d.length > 0 ? `(${d.join(", ")})` : "";
425
+ function te(t, e, r, o) {
426
+ const n = A(t), c = r(t.tableName), a = o(t.tableName), i = [], l = [];
427
+ e.limit && (i.push("$limit: Int"), l.push("first: $limit")), e.offset && (i.push("$offset: Int"), l.push("offset: $offset")), e.orderBy && (i.push(`$orderBy: [${a}!]`), l.push("orderBy: $orderBy"));
428
+ const y = i.length > 0 ? `(${i.join(", ")})` : "", f = l.length > 0 ? `(${l.join(", ")})` : "";
425
429
  return `
426
- query GetRecords${p} {
430
+ query GetRecords${y} {
427
431
  ${c}${f} {
428
432
  nodes {
429
433
  ${n}
@@ -432,38 +436,38 @@ function te(e, t, r, o) {
432
436
  }
433
437
  `;
434
438
  }
435
- function re(e, t, r) {
436
- const o = r(t.tableName);
437
- return e[o];
439
+ function re(t, e, r) {
440
+ const o = r(e.tableName);
441
+ return t[o];
438
442
  }
439
- function ne(e, t, r) {
440
- const o = r(t.tableName);
441
- return e[o]?.nodes ?? [];
443
+ function ne(t, e, r) {
444
+ const o = r(e.tableName);
445
+ return t[o]?.nodes ?? [];
442
446
  }
443
447
  export {
444
448
  D as DoctypeValidationError,
445
- Z as RELATION_FIELDTYPES,
449
+ v as RELATION_FIELDTYPES,
446
450
  te as buildListQuery,
447
451
  ee as buildRecordQuery,
448
- v as builtinHandlers,
452
+ G as builtinHandlers,
449
453
  me as clearHandlers,
450
454
  ue as clearRegistry,
451
455
  Se as createStonecropPlugin,
452
- z as defaultConnectionFieldName,
453
- Y as defaultOrderByTypeName,
454
- K as defaultRecordArgName,
455
- X as defaultRecordArgType,
456
- G as defaultRecordFieldName,
456
+ Y as defaultConnectionFieldName,
457
+ K as defaultOrderByTypeName,
458
+ X as defaultRecordArgName,
459
+ Z as defaultRecordArgType,
460
+ z as defaultRecordFieldName,
457
461
  H as getAllMeta,
458
462
  U as getHandler,
459
463
  h as getMeta,
460
- ye as hasHandler,
464
+ pe as hasHandler,
461
465
  fe as hasMeta,
462
466
  L as loadDoctypes,
463
- de as loadDoctypesFromObject,
464
- B as queryableFieldNames,
467
+ le as loadDoctypesFromObject,
468
+ A as queryableFieldNames,
465
469
  ge as registerBuiltinHandlers,
466
470
  _ as registerHandler,
467
- pe as validateReferences
471
+ ye as validateReferences
468
472
  };
469
473
  //# 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"],"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 listDoctype reference\n\t\tif (doctype.listDoctype && !doctypeRegistry.has(doctype.listDoctype)) {\n\t\t\terrors.push({\n\t\t\t\tpath: [doctype.name, 'listDoctype'],\n\t\t\t\tmessage: `References unknown doctype: ${doctype.listDoctype}`,\n\t\t\t})\n\t\t}\n\n\t\t// Check parentDoctype reference\n\t\tif (doctype.parentDoctype && !doctypeRegistry.has(doctype.parentDoctype)) {\n\t\t\terrors.push({\n\t\t\t\tpath: [doctype.name, 'parentDoctype'],\n\t\t\t\tmessage: `References unknown doctype: ${doctype.parentDoctype}`,\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 } 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.fieldname, value, field.fieldtype)\n\t\tif (error) errors.push(error)\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(fieldname: string, value: unknown, fieldtype: string): string | null {\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\n\t\tcase 'Table':\n\t\t\tif (!Array.isArray(value)) {\n\t\t\t\treturn `${fieldname}: expected array, 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 } 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 { ActionContext, GraphQLExecutor } 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\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\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 StonecropActionDefinition {\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: JSON\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\tlistDoctype: String\n\t\t\t\t\tparentDoctype: 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}\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!): 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 }: any) {\n\t\t\t\t\t\t\treturn loadOne(object({ doctype: $doctype, id: $id }), async (specs: readonly any[]) => {\n\t\t\t\t\t\t\t\treturn await Promise.all(\n\t\t\t\t\t\t\t\t\tspecs.map(async spec => {\n\t\t\t\t\t\t\t\t\t\tconst meta = getMeta(spec.doctype)\n\t\t\t\t\t\t\t\t\t\tif (!meta) {\n\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}\n\n\t\t\t\t\t\t\t\t\t\tif (!meta.tableName) {\n\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}\n\n\t\t\t\t\t\t\t\t\t\tconst query = buildRecordQuery(meta, recordFieldName, recordArgName, recordArgType)\n\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[recordArgName(meta.tableName!)]: spec.id,\n\t\t\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\tdata: extractSingleResult(result, meta, recordFieldName),\n\t\t\t\t\t\t\t\t\t\t\tdoctype: spec.doctype,\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// Query builders — generate GraphQL queries to send to the underlying schema\n// =============================================================================\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', 'Doctype'])\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 * Build a GraphQL query to fetch a single record by ID.\n * Excludes Link and Doctype relation fields from the selection set.\n * The PK argument name and type are configurable via `StonecropInflectionConfig.recordArgName`\n * and `StonecropInflectionConfig.recordArgType` to match the target schema's conventions\n * (e.g. `rowId: UUID!` for PostGraphile Amber with row_id columns).\n * @public\n */\nfunction buildRecordQuery(\n\tmeta: DoctypeMeta,\n\trecordFieldName: (t: string) => string,\n\trecordArgName: (t: string) => string,\n\trecordArgType: (t: string) => string\n): string {\n\tconst fieldNames = queryableFieldNames(meta)\n\tconst queryName = recordFieldName(meta.tableName!)\n\tconst argName = recordArgName(meta.tableName!)\n\tconst argType = recordArgType(meta.tableName!)\n\n\treturn `\n\t\tquery GetRecord($${argName}: ${argType}) {\n\t\t\t${queryName}(${argName}: $${argName}) {\n\t\t\t\t${fieldNames}\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: { limit?: number; offset?: number; orderBy?: string },\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 * Extract a single record from a PostGraphile query result using the record field name.\n * @internal\n */\nfunction extractSingleResult(result: unknown, meta: DoctypeMeta, recordFieldName: (t: string) => string): unknown {\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 * @internal\n */\nfunction extractListResult(result: unknown, meta: DoctypeMeta, connectionFieldName: (t: string) => string): unknown[] {\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\tbuildRecordQuery,\n\tbuildListQuery,\n\tqueryableFieldNames,\n\tRELATION_FIELDTYPES,\n\textractSingleResult,\n\textractListResult,\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","fieldtype","noop","builtinHandlers","registerBuiltinHandlers","createStonecropPlugin","recordFieldName","defaultRecordFieldName","connectionFieldName","defaultConnectionFieldName","orderByTypeName","defaultOrderByTypeName","recordArgName","defaultRecordArgName","recordArgType","defaultRecordArgType","extendSchema","gql","_","$doctype","lambda","constant","$id","loadOne","object","specs","spec","meta","query","buildRecordQuery","extractSingleResult","$filters","$orderBy","$limit","$offset","buildListQuery","extractListResult","$action","$actionArgs","actionDef","handlerName","actionContext","tableName","singular","pluralize","snakeToCamel","toPascalCase","_tableName","RELATION_FIELDTYPES","queryableFieldNames","f","fieldNames","queryName","argName","argType","connectionName","orderByType","varDecls","queryArgs","varStr","argsStr"],"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,U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iB/C,EAAoBmB,EAAK,SAAU,GACpD6B,IAAc9C,EAAgBiB,EAAK,SAAU,GAE7C8B,IAAqB,CAAA,GACrBC,IAAsB,CAAA;AAC5B,EAAIlE,EAAK,UACRiE,EAAS,KAAK,aAAa,GAC3BC,EAAU,KAAK,eAAe,IAE3BlE,EAAK,WACRiE,EAAS,KAAK,cAAc,GAC5BC,EAAU,KAAK,iBAAiB,IAE7BlE,EAAK,YACRiE,EAAS,KAAK,cAAcD,CAAW,IAAI,GAC3CE,EAAU,KAAK,mBAAmB;AAGnC,QAAMC,IAASF,EAAS,SAAS,IAAI,IAAIA,EAAS,KAAK,IAAI,CAAC,MAAM,IAC5DG,IAAUF,EAAU,SAAS,IAAI,IAAIA,EAAU,KAAK,IAAI,CAAC,MAAM;AAErE,SAAO;AAAA,oBACYC,CAAM;AAAA,KACrBJ,CAAc,GAAGK,CAAO;AAAA;AAAA,MAEvBT,CAAU;AAAA;AAAA;AAAA;AAAA;AAKhB;AAMA,SAASrB,GAAoB3D,GAAiBwD,GAAmBrB,GAAiD;AACjH,QAAM8C,IAAY9C,EAAgBqB,EAAK,SAAU;AACjD,SAAQxD,EAAmCiF,CAAS;AACrD;AAOA,SAAShB,GAAkBjE,GAAiBwD,GAAmBnB,GAAuD;AACrH,QAAM+C,IAAiB/C,EAAoBmB,EAAK,SAAU;AAI1D,SAHoBxD,EAAmCoF,CAAc,GAGlD,SAAS,CAAA;AAC7B;"}
1
+ {"version":3,"file":"index.js","sources":["../src/registry/doctypes.ts","../src/registry/actions.ts","../src/plugin/postgraphile.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 listDoctype reference\n\t\tif (doctype.listDoctype && !doctypeRegistry.has(doctype.listDoctype)) {\n\t\t\terrors.push({\n\t\t\t\tpath: [doctype.name, 'listDoctype'],\n\t\t\t\tmessage: `References unknown doctype: ${doctype.listDoctype}`,\n\t\t\t})\n\t\t}\n\n\t\t// Check parentDoctype reference\n\t\tif (doctype.parentDoctype && !doctypeRegistry.has(doctype.parentDoctype)) {\n\t\t\terrors.push({\n\t\t\t\tpath: [doctype.name, 'parentDoctype'],\n\t\t\t\tmessage: `References unknown doctype: ${doctype.parentDoctype}`,\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\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\n\t\tcase 'Doctype':\n\t\t\tif (cardinality === 'many') {\n\t\t\t\tif (!Array.isArray(value)) {\n\t\t\t\t\treturn `${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\treturn `${fieldname}: expected object, got ${typeof value}`\n\t\t\t\t}\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 } 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 { ActionContext, GraphQLExecutor } 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\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\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 StonecropActionDefinition {\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: JSON\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\tlistDoctype: String\n\t\t\t\t\tparentDoctype: 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}\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!): 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 }: any) {\n\t\t\t\t\t\t\treturn loadOne(object({ doctype: $doctype, id: $id }), async (specs: readonly any[]) => {\n\t\t\t\t\t\t\t\treturn await Promise.all(\n\t\t\t\t\t\t\t\t\tspecs.map(async spec => {\n\t\t\t\t\t\t\t\t\t\tconst meta = getMeta(spec.doctype)\n\t\t\t\t\t\t\t\t\t\tif (!meta) {\n\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}\n\n\t\t\t\t\t\t\t\t\t\tif (!meta.tableName) {\n\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}\n\n\t\t\t\t\t\t\t\t\t\tconst query = buildRecordQuery(meta, recordFieldName, recordArgName, recordArgType)\n\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[recordArgName(meta.tableName!)]: spec.id,\n\t\t\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\tdata: extractSingleResult(result, meta, recordFieldName),\n\t\t\t\t\t\t\t\t\t\t\tdoctype: spec.doctype,\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// Query builders — generate GraphQL queries to send to the underlying schema\n// =============================================================================\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', 'Doctype'])\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 * Build a GraphQL query to fetch a single record by ID.\n * Excludes Link and Doctype relation fields from the selection set.\n * The PK argument name and type are configurable via `StonecropInflectionConfig.recordArgName`\n * and `StonecropInflectionConfig.recordArgType` to match the target schema's conventions\n * (e.g. `rowId: UUID!` for PostGraphile Amber with row_id columns).\n * @public\n */\nfunction buildRecordQuery(\n\tmeta: DoctypeMeta,\n\trecordFieldName: (t: string) => string,\n\trecordArgName: (t: string) => string,\n\trecordArgType: (t: string) => string\n): string {\n\tconst fieldNames = queryableFieldNames(meta)\n\tconst queryName = recordFieldName(meta.tableName!)\n\tconst argName = recordArgName(meta.tableName!)\n\tconst argType = recordArgType(meta.tableName!)\n\n\treturn `\n\t\tquery GetRecord($${argName}: ${argType}) {\n\t\t\t${queryName}(${argName}: $${argName}) {\n\t\t\t\t${fieldNames}\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: { limit?: number; offset?: number; orderBy?: string },\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 * Extract a single record from a PostGraphile query result using the record field name.\n * @internal\n */\nfunction extractSingleResult(result: unknown, meta: DoctypeMeta, recordFieldName: (t: string) => string): unknown {\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 * @internal\n */\nfunction extractListResult(result: unknown, meta: DoctypeMeta, connectionFieldName: (t: string) => string): unknown[] {\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\tbuildRecordQuery,\n\tbuildListQuery,\n\tqueryableFieldNames,\n\tRELATION_FIELDTYPES,\n\textractSingleResult,\n\textractListResult,\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","fieldtype","cardinality","noop","builtinHandlers","registerBuiltinHandlers","createStonecropPlugin","recordFieldName","defaultRecordFieldName","connectionFieldName","defaultConnectionFieldName","orderByTypeName","defaultOrderByTypeName","recordArgName","defaultRecordArgName","recordArgType","defaultRecordArgType","extendSchema","gql","_","$doctype","lambda","constant","$id","loadOne","object","specs","spec","meta","query","buildRecordQuery","extractSingleResult","$filters","$orderBy","$limit","$offset","buildListQuery","extractListResult","$action","$actionArgs","actionDef","handlerName","actionContext","tableName","singular","pluralize","snakeToCamel","toPascalCase","_tableName","RELATION_FIELDTYPES","queryableFieldNames","f","fieldNames","queryName","argName","argType","connectionName","orderByType","varDecls","queryArgs","varStr","argsStr"],"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,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xC,EAAca,EAAK,SAAU;AAE7C,SAAO;AAAA,qBACa0B,CAAO,KAAKC,CAAO;AAAA,KACnCF,CAAS,IAAIC,CAAO,MAAMA,CAAO;AAAA,MAChCF,CAAU;AAAA;AAAA;AAAA;AAIhB;AASA,SAAShB,GACRR,GACApC,GACAiB,GACAE,GACS;AACT,QAAMyC,IAAaF,EAAoBtB,CAAI,GACrC4B,IAAiB/C,EAAoBmB,EAAK,SAAU,GACpD6B,IAAc9C,EAAgBiB,EAAK,SAAU,GAE7C8B,IAAqB,CAAA,GACrBC,IAAsB,CAAA;AAC5B,EAAInE,EAAK,UACRkE,EAAS,KAAK,aAAa,GAC3BC,EAAU,KAAK,eAAe,IAE3BnE,EAAK,WACRkE,EAAS,KAAK,cAAc,GAC5BC,EAAU,KAAK,iBAAiB,IAE7BnE,EAAK,YACRkE,EAAS,KAAK,cAAcD,CAAW,IAAI,GAC3CE,EAAU,KAAK,mBAAmB;AAGnC,QAAMC,IAASF,EAAS,SAAS,IAAI,IAAIA,EAAS,KAAK,IAAI,CAAC,MAAM,IAC5DG,IAAUF,EAAU,SAAS,IAAI,IAAIA,EAAU,KAAK,IAAI,CAAC,MAAM;AAErE,SAAO;AAAA,oBACYC,CAAM;AAAA,KACrBJ,CAAc,GAAGK,CAAO;AAAA;AAAA,MAEvBT,CAAU;AAAA;AAAA;AAAA;AAAA;AAKhB;AAMA,SAASrB,GAAoB5D,GAAiByD,GAAmBrB,GAAiD;AACjH,QAAM8C,IAAY9C,EAAgBqB,EAAK,SAAU;AACjD,SAAQzD,EAAmCkF,CAAS;AACrD;AAOA,SAAShB,GAAkBlE,GAAiByD,GAAmBnB,GAAuD;AACrH,QAAM+C,IAAiB/C,EAAoBmB,EAAK,SAAU;AAI1D,SAHoBzD,EAAmCqF,CAAc,GAGlD,SAAS,CAAA;AAC7B;"}
@@ -62,7 +62,7 @@ const validateFieldTypes = async (args, context) => {
62
62
  const value = record[field.fieldname];
63
63
  if (value === undefined || value === null)
64
64
  continue;
65
- const error = validateFieldValue(field.fieldname, value, field.fieldtype);
65
+ const error = validateFieldValue(field, value);
66
66
  if (error)
67
67
  errors.push(error);
68
68
  }
@@ -74,7 +74,8 @@ const validateFieldTypes = async (args, context) => {
74
74
  /**
75
75
  * Validate a single field value against its expected type
76
76
  */
77
- function validateFieldValue(fieldname, value, fieldtype) {
77
+ function validateFieldValue(field, value) {
78
+ const { fieldname, fieldtype, cardinality } = field;
78
79
  switch (fieldtype) {
79
80
  case 'Int':
80
81
  if (typeof value !== 'number' || !Number.isInteger(value)) {
@@ -114,9 +115,16 @@ function validateFieldValue(fieldname, value, fieldtype) {
114
115
  return `${fieldname}: expected object, got ${typeof value}`;
115
116
  }
116
117
  break;
117
- case 'Table':
118
- if (!Array.isArray(value)) {
119
- return `${fieldname}: expected array, got ${typeof value}`;
118
+ case 'Doctype':
119
+ if (cardinality === 'many') {
120
+ if (!Array.isArray(value)) {
121
+ return `${fieldname}: expected array, got ${typeof value}`;
122
+ }
123
+ }
124
+ else {
125
+ if (typeof value !== 'object' || Array.isArray(value)) {
126
+ return `${fieldname}: expected object, got ${typeof value}`;
127
+ }
120
128
  }
121
129
  break;
122
130
  }
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/registry/actions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,UAAU,CAAA;AAI5D;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAE1E;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAElE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AAqHD;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAIzD,CAAA;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAI9C"}
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/registry/actions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,UAAU,CAAA;AAI5D;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAE1E;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAElE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AA6HD;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAIzD,CAAA;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAI9C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stonecrop/graphql-middleware",
3
- "version": "0.10.11",
3
+ "version": "0.10.12",
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.10.11"
20
+ "@stonecrop/schema": "0.10.12"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@rushstack/heft": "^1.2.0",