@stonecrop/graphql-middleware 0.8.12 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { DoctypeMeta } from '@stonecrop/schema';
|
|
1
2
|
import { GraphileConfig as GraphileConfig_2 } from 'postgraphile/graphile-build';
|
|
2
|
-
import {
|
|
3
|
+
import { ValidationError } from '@stonecrop/schema';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Context passed to action handlers
|
|
@@ -89,218 +90,7 @@ export declare function defaultOrderByTypeName(tableName: string): string;
|
|
|
89
90
|
*/
|
|
90
91
|
export declare function defaultRecordFieldName(tableName: string): string;
|
|
91
92
|
|
|
92
|
-
|
|
93
|
-
* Doctype metadata - complete definition of a doctype
|
|
94
|
-
* @public
|
|
95
|
-
*/
|
|
96
|
-
export declare const DoctypeMeta: z.ZodObject<{
|
|
97
|
-
/** Display name of the doctype */
|
|
98
|
-
name: z.ZodString;
|
|
99
|
-
/** URL-friendly slug (kebab-case) */
|
|
100
|
-
slug: z.ZodOptional<z.ZodString>;
|
|
101
|
-
/** Database table name */
|
|
102
|
-
tableName: z.ZodOptional<z.ZodString>;
|
|
103
|
-
/** Field definitions */
|
|
104
|
-
fields: z.ZodArray<z.ZodObject<{
|
|
105
|
-
fieldname: z.ZodString;
|
|
106
|
-
fieldtype: z.ZodEnum<["Data", "Text", "Int", "Float", "Decimal", "Check", "Date", "Time", "Datetime", "Duration", "DateRange", "JSON", "Code", "Link", "Doctype", "Attach", "Currency", "Quantity", "Select"]>;
|
|
107
|
-
component: z.ZodOptional<z.ZodString>;
|
|
108
|
-
label: z.ZodOptional<z.ZodString>;
|
|
109
|
-
width: z.ZodOptional<z.ZodString>;
|
|
110
|
-
align: z.ZodOptional<z.ZodEnum<["left", "center", "right", "start", "end"]>>;
|
|
111
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
112
|
-
readOnly: z.ZodOptional<z.ZodBoolean>;
|
|
113
|
-
edit: z.ZodOptional<z.ZodBoolean>;
|
|
114
|
-
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
115
|
-
value: z.ZodOptional<z.ZodUnknown>;
|
|
116
|
-
default: z.ZodOptional<z.ZodUnknown>;
|
|
117
|
-
options: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
118
|
-
mask: z.ZodOptional<z.ZodString>;
|
|
119
|
-
validation: z.ZodOptional<z.ZodObject<{
|
|
120
|
-
errorMessage: z.ZodString;
|
|
121
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
122
|
-
errorMessage: z.ZodString;
|
|
123
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
124
|
-
errorMessage: z.ZodString;
|
|
125
|
-
}, z.ZodTypeAny, "passthrough">>>;
|
|
126
|
-
}, "strip", z.ZodTypeAny, {
|
|
127
|
-
fieldname: string;
|
|
128
|
-
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
129
|
-
value?: unknown;
|
|
130
|
-
options?: string | string[] | Record<string, unknown> | undefined;
|
|
131
|
-
validation?: z.objectOutputType<{
|
|
132
|
-
errorMessage: z.ZodString;
|
|
133
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
134
|
-
component?: string | undefined;
|
|
135
|
-
label?: string | undefined;
|
|
136
|
-
width?: string | undefined;
|
|
137
|
-
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
138
|
-
required?: boolean | undefined;
|
|
139
|
-
readOnly?: boolean | undefined;
|
|
140
|
-
edit?: boolean | undefined;
|
|
141
|
-
hidden?: boolean | undefined;
|
|
142
|
-
default?: unknown;
|
|
143
|
-
mask?: string | undefined;
|
|
144
|
-
}, {
|
|
145
|
-
fieldname: string;
|
|
146
|
-
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
147
|
-
value?: unknown;
|
|
148
|
-
options?: string | string[] | Record<string, unknown> | undefined;
|
|
149
|
-
validation?: z.objectInputType<{
|
|
150
|
-
errorMessage: z.ZodString;
|
|
151
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
152
|
-
component?: string | undefined;
|
|
153
|
-
label?: string | undefined;
|
|
154
|
-
width?: string | undefined;
|
|
155
|
-
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
156
|
-
required?: boolean | undefined;
|
|
157
|
-
readOnly?: boolean | undefined;
|
|
158
|
-
edit?: boolean | undefined;
|
|
159
|
-
hidden?: boolean | undefined;
|
|
160
|
-
default?: unknown;
|
|
161
|
-
mask?: string | undefined;
|
|
162
|
-
}>, "many">;
|
|
163
|
-
/** Workflow configuration */
|
|
164
|
-
workflow: z.ZodOptional<z.ZodObject<{
|
|
165
|
-
/** List of workflow states */
|
|
166
|
-
states: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
167
|
-
/** Actions available in this workflow */
|
|
168
|
-
actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
169
|
-
/** Display label for the action */
|
|
170
|
-
label: z.ZodString;
|
|
171
|
-
/** Handler function name or path */
|
|
172
|
-
handler: z.ZodString;
|
|
173
|
-
/** Fields that must have values before action can execute */
|
|
174
|
-
requiredFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
175
|
-
/** Workflow states where this action is available */
|
|
176
|
-
allowedStates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
177
|
-
/** Whether to show a confirmation dialog */
|
|
178
|
-
confirm: z.ZodOptional<z.ZodBoolean>;
|
|
179
|
-
/** Additional arguments for the action */
|
|
180
|
-
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
181
|
-
}, "strip", z.ZodTypeAny, {
|
|
182
|
-
label: string;
|
|
183
|
-
handler: string;
|
|
184
|
-
requiredFields?: string[] | undefined;
|
|
185
|
-
allowedStates?: string[] | undefined;
|
|
186
|
-
confirm?: boolean | undefined;
|
|
187
|
-
args?: Record<string, unknown> | undefined;
|
|
188
|
-
}, {
|
|
189
|
-
label: string;
|
|
190
|
-
handler: string;
|
|
191
|
-
requiredFields?: string[] | undefined;
|
|
192
|
-
allowedStates?: string[] | undefined;
|
|
193
|
-
confirm?: boolean | undefined;
|
|
194
|
-
args?: Record<string, unknown> | undefined;
|
|
195
|
-
}>>>;
|
|
196
|
-
}, "strip", z.ZodTypeAny, {
|
|
197
|
-
states?: string[] | undefined;
|
|
198
|
-
actions?: Record<string, {
|
|
199
|
-
label: string;
|
|
200
|
-
handler: string;
|
|
201
|
-
requiredFields?: string[] | undefined;
|
|
202
|
-
allowedStates?: string[] | undefined;
|
|
203
|
-
confirm?: boolean | undefined;
|
|
204
|
-
args?: Record<string, unknown> | undefined;
|
|
205
|
-
}> | undefined;
|
|
206
|
-
}, {
|
|
207
|
-
states?: string[] | undefined;
|
|
208
|
-
actions?: Record<string, {
|
|
209
|
-
label: string;
|
|
210
|
-
handler: string;
|
|
211
|
-
requiredFields?: string[] | undefined;
|
|
212
|
-
allowedStates?: string[] | undefined;
|
|
213
|
-
confirm?: boolean | undefined;
|
|
214
|
-
args?: Record<string, unknown> | undefined;
|
|
215
|
-
}> | undefined;
|
|
216
|
-
}>>;
|
|
217
|
-
/** Parent doctype for inheritance */
|
|
218
|
-
inherits: z.ZodOptional<z.ZodString>;
|
|
219
|
-
/** Doctype to use for list views */
|
|
220
|
-
listDoctype: z.ZodOptional<z.ZodString>;
|
|
221
|
-
/** Parent doctype for child tables */
|
|
222
|
-
parentDoctype: z.ZodOptional<z.ZodString>;
|
|
223
|
-
}, "strip", z.ZodTypeAny, {
|
|
224
|
-
name: string;
|
|
225
|
-
fields: {
|
|
226
|
-
fieldname: string;
|
|
227
|
-
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
228
|
-
value?: unknown;
|
|
229
|
-
options?: string | string[] | Record<string, unknown> | undefined;
|
|
230
|
-
validation?: z.objectOutputType<{
|
|
231
|
-
errorMessage: z.ZodString;
|
|
232
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
233
|
-
component?: string | undefined;
|
|
234
|
-
label?: string | undefined;
|
|
235
|
-
width?: string | undefined;
|
|
236
|
-
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
237
|
-
required?: boolean | undefined;
|
|
238
|
-
readOnly?: boolean | undefined;
|
|
239
|
-
edit?: boolean | undefined;
|
|
240
|
-
hidden?: boolean | undefined;
|
|
241
|
-
default?: unknown;
|
|
242
|
-
mask?: string | undefined;
|
|
243
|
-
}[];
|
|
244
|
-
slug?: string | undefined;
|
|
245
|
-
tableName?: string | undefined;
|
|
246
|
-
workflow?: {
|
|
247
|
-
states?: string[] | undefined;
|
|
248
|
-
actions?: Record<string, {
|
|
249
|
-
label: string;
|
|
250
|
-
handler: string;
|
|
251
|
-
requiredFields?: string[] | undefined;
|
|
252
|
-
allowedStates?: string[] | undefined;
|
|
253
|
-
confirm?: boolean | undefined;
|
|
254
|
-
args?: Record<string, unknown> | undefined;
|
|
255
|
-
}> | undefined;
|
|
256
|
-
} | undefined;
|
|
257
|
-
inherits?: string | undefined;
|
|
258
|
-
listDoctype?: string | undefined;
|
|
259
|
-
parentDoctype?: string | undefined;
|
|
260
|
-
}, {
|
|
261
|
-
name: string;
|
|
262
|
-
fields: {
|
|
263
|
-
fieldname: string;
|
|
264
|
-
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
265
|
-
value?: unknown;
|
|
266
|
-
options?: string | string[] | Record<string, unknown> | undefined;
|
|
267
|
-
validation?: z.objectInputType<{
|
|
268
|
-
errorMessage: z.ZodString;
|
|
269
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
270
|
-
component?: string | undefined;
|
|
271
|
-
label?: string | undefined;
|
|
272
|
-
width?: string | undefined;
|
|
273
|
-
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
274
|
-
required?: boolean | undefined;
|
|
275
|
-
readOnly?: boolean | undefined;
|
|
276
|
-
edit?: boolean | undefined;
|
|
277
|
-
hidden?: boolean | undefined;
|
|
278
|
-
default?: unknown;
|
|
279
|
-
mask?: string | undefined;
|
|
280
|
-
}[];
|
|
281
|
-
slug?: string | undefined;
|
|
282
|
-
tableName?: string | undefined;
|
|
283
|
-
workflow?: {
|
|
284
|
-
states?: string[] | undefined;
|
|
285
|
-
actions?: Record<string, {
|
|
286
|
-
label: string;
|
|
287
|
-
handler: string;
|
|
288
|
-
requiredFields?: string[] | undefined;
|
|
289
|
-
allowedStates?: string[] | undefined;
|
|
290
|
-
confirm?: boolean | undefined;
|
|
291
|
-
args?: Record<string, unknown> | undefined;
|
|
292
|
-
}> | undefined;
|
|
293
|
-
} | undefined;
|
|
294
|
-
inherits?: string | undefined;
|
|
295
|
-
listDoctype?: string | undefined;
|
|
296
|
-
parentDoctype?: string | undefined;
|
|
297
|
-
}>;
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Doctype metadata type inferred from Zod schema
|
|
301
|
-
* @public
|
|
302
|
-
*/
|
|
303
|
-
export declare type DoctypeMeta = z.infer<typeof DoctypeMeta>;
|
|
93
|
+
export { DoctypeMeta }
|
|
304
94
|
|
|
305
95
|
/**
|
|
306
96
|
* Error thrown when a doctype definition fails validation
|
|
@@ -478,15 +268,6 @@ export declare interface StonecropPluginOptions {
|
|
|
478
268
|
*/
|
|
479
269
|
export declare function validateReferences(): ValidationError[];
|
|
480
270
|
|
|
481
|
-
|
|
482
|
-
* Validation error with path information
|
|
483
|
-
* @public
|
|
484
|
-
*/
|
|
485
|
-
export declare interface ValidationError {
|
|
486
|
-
/** Path to the invalid property */
|
|
487
|
-
path: (string | number)[];
|
|
488
|
-
/** Error message */
|
|
489
|
-
message: string;
|
|
490
|
-
}
|
|
271
|
+
export { ValidationError }
|
|
491
272
|
|
|
492
273
|
export { }
|
package/package.json
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stonecrop/graphql-middleware",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"
|
|
6
|
-
"module": "./dist/index.js",
|
|
7
|
-
"types": "./dist/src/index.d.ts",
|
|
5
|
+
"types": "./dist/graphql-middleware.d.ts",
|
|
8
6
|
"exports": {
|
|
9
7
|
".": {
|
|
10
|
-
"types": "./dist/
|
|
11
|
-
"import": "./dist/index.js"
|
|
12
|
-
"require": "./dist/index.cjs"
|
|
8
|
+
"types": "./dist/graphql-middleware.d.ts",
|
|
9
|
+
"import": "./dist/index.js"
|
|
13
10
|
}
|
|
14
11
|
},
|
|
15
12
|
"files": [
|
|
16
13
|
"dist"
|
|
17
14
|
],
|
|
15
|
+
"description": "GraphQL middleware for PostGraphile and Stonecrop schema",
|
|
16
|
+
"sideEffects": false,
|
|
18
17
|
"dependencies": {
|
|
19
18
|
"graphql": "^16.12.0",
|
|
20
19
|
"pluralize": "^8.0.0",
|
|
21
20
|
"postgraphile": "^5.0.0-rc.7",
|
|
22
|
-
"@stonecrop/schema": "0.
|
|
21
|
+
"@stonecrop/schema": "0.9.0"
|
|
23
22
|
},
|
|
24
23
|
"devDependencies": {
|
|
25
24
|
"@rushstack/heft": "^1.2.0",
|
|
@@ -34,7 +33,6 @@
|
|
|
34
33
|
},
|
|
35
34
|
"scripts": {
|
|
36
35
|
"_phase:build": "heft build && vite build && rushx docs",
|
|
37
|
-
"prepublish": "heft build && vite build && rushx docs",
|
|
38
36
|
"build": "heft build && vite build && rushx docs",
|
|
39
37
|
"docs": "bash ../common/scripts/run-docs.sh graphql_middleware",
|
|
40
38
|
"test": "vitest run --coverage.enabled false",
|
package/dist/index.cjs
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("node:fs"),J=require("node:path"),h=require("@stonecrop/schema"),k=require("postgraphile/utils"),p=require("postgraphile/grafast"),L=require("pluralize"),f=new Map;class b extends Error{constructor(t,r){const o=r.map(n=>` ${n.path.join(".")}: ${n.message}`).join(`
|
|
2
|
-
`);super(`Invalid doctype definition in ${t}:
|
|
3
|
-
${o}`),this.file=t,this.errors=r,this.name="DoctypeValidationError"}}function E(e,t={}){const r=D.readdirSync(e);for(const o of r){const n=J.join(e,o);D.statSync(n).isDirectory()?E(n,t):o.endsWith(".json")&&_(n,t)}}function _(e,t){const r=D.readFileSync(e,"utf-8");let o;try{o=JSON.parse(r)}catch(s){const c={path:[],message:`Invalid JSON: ${s instanceof Error?s.message:String(s)}`};if(t.continueOnError){t.onError?.(e,[c]);return}throw new b(e,[c])}const n=h.validateDoctype(o);if(!n.success){if(t.continueOnError){t.onError?.(e,n.errors);return}throw new b(e,n.errors)}const a=h.parseDoctype(o);f.set(a.name,a)}function C(e,t={}){for(const[r,o]of Object.entries(e)){const n={...o,name:r},a=h.validateDoctype(n);if(!a.success){if(t.continueOnError){t.onError?.(r,a.errors);continue}throw new b(r,a.errors)}const s=h.parseDoctype(n);f.set(s.name,s)}}function $(e){return f.get(e)}function F(){return Array.from(f.values())}function P(e){return f.has(e)}function Q(){f.clear()}function U(){const e=[];for(const t of f.values()){t.inherits&&!f.has(t.inherits)&&e.push({path:[t.name,"inherits"],message:`References unknown doctype: ${t.inherits}`}),t.listDoctype&&!f.has(t.listDoctype)&&e.push({path:[t.name,"listDoctype"],message:`References unknown doctype: ${t.listDoctype}`}),t.parentDoctype&&!f.has(t.parentDoctype)&&e.push({path:[t.name,"parentDoctype"],message:`References unknown doctype: ${t.parentDoctype}`});for(const r of t.fields)r.fieldtype==="Link"&&typeof r.options=="string"&&(f.has(r.options)||e.push({path:[t.name,"fields",r.fieldname,"options"],message:`Link references unknown doctype: ${r.options}`}))}return e}const N=new Map;function M(e,t){N.set(e,t)}function q(e){return N.get(e)}function v(e){return N.has(e)}function V(){N.clear()}const W=async(e,t)=>{const[r]=e,{doctype:o}=t,n=[];for(const a of o.fields)a.required&&(r[a.fieldname]===void 0||r[a.fieldname]===null)&&n.push(a.label??a.fieldname);if(n.length>0)throw new Error(`Missing required fields: ${n.join(", ")}`);return{valid:!0}},G=async(e,t)=>{const[r]=e,{doctype:o}=t,n=[];for(const a of o.fields){const s=r[a.fieldname];if(s==null)continue;const c=Y(a.fieldname,s,a.fieldtype);c&&n.push(c)}if(n.length>0)throw new Error(`Field type validation failed:
|
|
4
|
-
${n.join(`
|
|
5
|
-
`)}`);return{valid:!0}};function Y(e,t,r){switch(r){case"Int":if(typeof t!="number"||!Number.isInteger(t))return`${e}: expected integer, got ${typeof t}`;break;case"Float":case"Decimal":case"Currency":case"Quantity":if(typeof t!="number"&&typeof t!="string")return`${e}: expected number, got ${typeof t}`;break;case"Check":if(typeof t!="boolean")return`${e}: expected boolean, got ${typeof t}`;break;case"Data":case"Text":case"Code":case"Link":if(typeof t!="string")return`${e}: expected string, got ${typeof t}`;break;case"Date":case"Time":case"Datetime":if(typeof t!="string"&&!(t instanceof Date))return`${e}: expected date string or Date, got ${typeof t}`;break;case"JSON":if(typeof t!="object")return`${e}: expected object, got ${typeof t}`;break;case"Table":if(!Array.isArray(t))return`${e}: expected array, got ${typeof t}`;break}return null}const z=async()=>({ok:!0}),A={validateRequiredFields:W,validateFieldTypes:G,noop:z};function K(){for(const[e,t]of Object.entries(A))M(e,t)}const X=e=>{const t=e.inflection?.recordFieldName??B,r=e.inflection?.connectionFieldName??j,o=e.inflection?.orderByTypeName??x,n=e.inflection?.recordArgName??Z,a=e.inflection?.recordArgType??ee;return k.extendSchema(()=>({typeDefs:k.gql`
|
|
6
|
-
type StonecropFieldMeta {
|
|
7
|
-
fieldname: String!
|
|
8
|
-
fieldtype: String!
|
|
9
|
-
label: String
|
|
10
|
-
required: Boolean
|
|
11
|
-
options: JSON
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type StonecropActionDefinition {
|
|
15
|
-
label: String!
|
|
16
|
-
handler: String!
|
|
17
|
-
requiredFields: [String!]
|
|
18
|
-
allowedStates: [String!]
|
|
19
|
-
confirm: Boolean
|
|
20
|
-
args: JSON
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
type StonecropWorkflowMeta {
|
|
24
|
-
states: [String!]
|
|
25
|
-
actions: JSON
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
type StonecropDoctypeMeta {
|
|
29
|
-
name: String!
|
|
30
|
-
tableName: String
|
|
31
|
-
fields: [StonecropFieldMeta!]!
|
|
32
|
-
workflow: StonecropWorkflowMeta
|
|
33
|
-
listDoctype: String
|
|
34
|
-
parentDoctype: String
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
type StonecropRecordResult {
|
|
38
|
-
data: JSON
|
|
39
|
-
doctype: String!
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
type StonecropRecordsResult {
|
|
43
|
-
data: [JSON!]!
|
|
44
|
-
doctype: String!
|
|
45
|
-
count: Int!
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
type StonecropActionResult {
|
|
49
|
-
success: Boolean!
|
|
50
|
-
data: JSON
|
|
51
|
-
error: String
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
extend type Query {
|
|
55
|
-
stonecropMeta(doctype: String!): StonecropDoctypeMeta
|
|
56
|
-
stonecropAllMeta: [StonecropDoctypeMeta!]!
|
|
57
|
-
stonecropRecord(doctype: String!, id: String!): StonecropRecordResult
|
|
58
|
-
stonecropRecords(
|
|
59
|
-
doctype: String!
|
|
60
|
-
filters: JSON
|
|
61
|
-
orderBy: String
|
|
62
|
-
limit: Int
|
|
63
|
-
offset: Int
|
|
64
|
-
): StonecropRecordsResult
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
extend type Mutation {
|
|
68
|
-
stonecropAction(doctype: String!, action: String!, args: JSON): StonecropActionResult!
|
|
69
|
-
}
|
|
70
|
-
`,objects:{Query:{plans:{stonecropMeta(s,{$doctype:c}){return p.lambda(c,d=>$(d)??null)},stonecropAllMeta(){return p.constant(F())},stonecropRecord(s,{$doctype:c,$id:d}){return p.loadOne(p.object({doctype:c,id:d}),async y=>await Promise.all(y.map(async u=>{const l=$(u.doctype);if(!l)throw new Error(`Unknown doctype: ${u.doctype}`);if(!l.tableName)throw new Error(`Doctype ${u.doctype} has no table mapping`);const g=I(l,t,n,a),i=await e.executor.query(g,{[n(l.tableName)]:u.id});return{data:te(i,l,t),doctype:u.doctype}})))},stonecropRecords(s,{$doctype:c,$filters:d,$orderBy:y,$limit:u,$offset:l}){return p.loadOne(p.object({doctype:c,filters:d,orderBy:y,limit:u,offset:l}),async g=>await Promise.all(g.map(async i=>{const m=$(i.doctype);if(!m)throw new Error(`Unknown doctype: ${i.doctype}`);if(!m.tableName)throw new Error(`Doctype ${i.doctype} has no table mapping`);const w=H(m,{limit:i.limit,offset:i.offset,orderBy:i.orderBy},r,o),S=await e.executor.query(w,{limit:i.limit,offset:i.offset,orderBy:i.orderBy}),O=re(S,m,r);return{data:O,doctype:i.doctype,count:O.length}})))}}},Mutation:{plans:{stonecropAction(s,{$doctype:c,$action:d,$args:y}){return p.loadOne(p.object({doctype:c,action:d,actionArgs:y}),async u=>await Promise.all(u.map(async l=>{const g=$(l.doctype);if(!g)return{success:!1,data:null,error:`Unknown doctype: ${l.doctype}`};const i=g.workflow?.actions?.[l.action];if(!i)return{success:!1,data:null,error:`Unknown action: ${l.action} on ${l.doctype}`};const m=q(i.handler);if(!m)return{success:!1,data:null,error:`Handler not registered: ${i.handler}`};const w={doctype:g,executor:e.executor};try{return{success:!0,data:await m(l.actionArgs??[],w),error:null}}catch(S){return{success:!1,data:null,error:S instanceof Error?S.message:String(S)}}})))}}}}}))};function B(e){const t=L.singular(e);return`${h.snakeToCamel(t)}ById`}function j(e){return`all${h.toPascalCase(e)}`}function x(e){return`${h.toPascalCase(e)}OrderBy`}function Z(e){return"id"}function ee(e){return"UUID!"}const T=new Set(["Link","Doctype"]);function R(e){return e.fields.filter(t=>!T.has(t.fieldtype)).map(t=>t.fieldname).join(`
|
|
71
|
-
`)}function I(e,t,r,o){const n=R(e),a=t(e.tableName),s=r(e.tableName),c=o(e.tableName);return`
|
|
72
|
-
query GetRecord($${s}: ${c}) {
|
|
73
|
-
${a}(${s}: $${s}) {
|
|
74
|
-
${n}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
`}function H(e,t,r,o){const n=R(e),a=r(e.tableName),s=o(e.tableName),c=[],d=[];t.limit&&(c.push("$limit: Int"),d.push("first: $limit")),t.offset&&(c.push("$offset: Int"),d.push("offset: $offset")),t.orderBy&&(c.push(`$orderBy: [${s}!]`),d.push("orderBy: $orderBy"));const y=c.length>0?`(${c.join(", ")})`:"",u=d.length>0?`(${d.join(", ")})`:"";return`
|
|
78
|
-
query GetRecords${y} {
|
|
79
|
-
${a}${u} {
|
|
80
|
-
nodes {
|
|
81
|
-
${n}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
`}function te(e,t,r){const o=r(t.tableName);return e[o]}function re(e,t,r){const o=r(t.tableName);return e[o]?.nodes??[]}exports.DoctypeValidationError=b;exports.RELATION_FIELDTYPES=T;exports.buildListQuery=H;exports.buildRecordQuery=I;exports.builtinHandlers=A;exports.clearHandlers=V;exports.clearRegistry=Q;exports.createStonecropPlugin=X;exports.defaultConnectionFieldName=j;exports.defaultOrderByTypeName=x;exports.defaultRecordFieldName=B;exports.getAllMeta=F;exports.getHandler=q;exports.getMeta=$;exports.hasHandler=v;exports.hasMeta=P;exports.loadDoctypes=E;exports.loadDoctypesFromObject=C;exports.queryableFieldNames=R;exports.registerBuiltinHandlers=K;exports.registerHandler=M;exports.validateReferences=U;
|
|
86
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","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 { extendSchema, gql } from 'postgraphile/utils'\nimport { constant, lambda, object, loadOne } from 'postgraphile/grafast'\nimport { GraphileConfig } from 'postgraphile/graphile-build'\n\nimport pluralize from 'pluralize'\n\nimport { snakeToCamel, toPascalCase } from '@stonecrop/schema'\nimport { getHandler } from '../registry/actions'\nimport { getMeta, getAllMeta } from '../registry/doctypes'\nimport type { DoctypeMeta } from '@stonecrop/schema'\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\tlabel: String\n\t\t\t\t\trequired: Boolean\n\t\t\t\t\toptions: 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\ttableName: String\n\t\t\t\t\tfields: [StonecropFieldMeta!]!\n\t\t\t\t\tworkflow: StonecropWorkflowMeta\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\n\t\t\t\t\t\t\t\t\t\t\tconst handler = getHandler(actionDef.handler)\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: ${actionDef.handler}`,\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 * @internal\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 * @internal\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","actionContext","tableName","singular","pluralize","snakeToCamel","toPascalCase","_tableName","RELATION_FIELDTYPES","queryableFieldNames","f","fieldNames","queryName","argName","argType","connectionName","orderByType","varDecls","queryArgs","varStr","argsStr"],"mappings":"0PAMMA,MAAgD,IAM/C,MAAMC,UAA+B,KAAM,CACjD,YAEiBC,EAEAC,EACf,CACD,MAAMC,EAAgBD,EAAO,IAAIE,GAAK,KAAKA,EAAE,KAAK,KAAK,GAAG,CAAC,KAAKA,EAAE,OAAO,EAAE,EAAE,KAAK;AAAA,CAAI,EACtF,MAAM,iCAAiCH,CAAI;AAAA,EAAME,CAAa,EAAE,EALhD,KAAA,KAAAF,EAEA,KAAA,OAAAC,EAIhB,KAAK,KAAO,wBACb,CACD,CAmBO,SAASG,EAAaC,EAAaC,EAA+B,GAAU,CAClF,MAAMC,EAAUC,EAAAA,YAAYH,CAAG,EAE/B,UAAWI,KAASF,EAAS,CAC5B,MAAMG,EAAWC,EAAAA,KAAKN,EAAKI,CAAK,EACnBG,EAAAA,SAASF,CAAQ,EAErB,cACRN,EAAaM,EAAUJ,CAAO,EACpBG,EAAM,SAAS,OAAO,GAChCI,EAAgBH,EAAUJ,CAAO,CAE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