@stonecrop/graphql-middleware 0.8.8 → 0.8.10

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.
@@ -0,0 +1,1222 @@
1
+ import { GraphileConfig as GraphileConfig_2 } from 'postgraphile/graphile-build';
2
+ import { GraphQLField } from 'graphql';
3
+ import { GraphQLObjectType } from 'graphql';
4
+ import type { IntrospectionQuery } from 'graphql';
5
+ import { z } from 'zod';
6
+
7
+ /**
8
+ * Context passed to action handlers
9
+ * @public
10
+ */
11
+ export declare interface ActionContext {
12
+ /** Doctype metadata for the action being executed */
13
+ doctype: DoctypeMeta;
14
+ /** GraphQL executor for running queries/mutations within the action */
15
+ executor: GraphQLExecutor;
16
+ /** Additional context properties */
17
+ [key: string]: unknown;
18
+ }
19
+
20
+ /**
21
+ * Action definition within a workflow
22
+ * @public
23
+ */
24
+ export declare const ActionDefinition: z.ZodObject<{
25
+ /** Display label for the action */
26
+ label: z.ZodString;
27
+ /** Handler function name or path */
28
+ handler: z.ZodString;
29
+ /** Fields that must have values before action can execute */
30
+ requiredFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
31
+ /** Workflow states where this action is available */
32
+ allowedStates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
33
+ /** Whether to show a confirmation dialog */
34
+ confirm: z.ZodOptional<z.ZodBoolean>;
35
+ /** Additional arguments for the action */
36
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
37
+ }, "strip", z.ZodTypeAny, {
38
+ label: string;
39
+ handler: string;
40
+ requiredFields?: string[] | undefined;
41
+ allowedStates?: string[] | undefined;
42
+ confirm?: boolean | undefined;
43
+ args?: Record<string, unknown> | undefined;
44
+ }, {
45
+ label: string;
46
+ handler: string;
47
+ requiredFields?: string[] | undefined;
48
+ allowedStates?: string[] | undefined;
49
+ confirm?: boolean | undefined;
50
+ args?: Record<string, unknown> | undefined;
51
+ }>;
52
+
53
+ /**
54
+ * Action definition type inferred from Zod schema
55
+ * @public
56
+ */
57
+ export declare type ActionDefinition = z.infer<typeof ActionDefinition>;
58
+
59
+ /**
60
+ * Action handler function signature
61
+ * @public
62
+ */
63
+ export declare type ActionHandler = (args: unknown[], context: ActionContext) => Promise<unknown>;
64
+
65
+ /**
66
+ * Build a GraphQL connection query to fetch a list of records.
67
+ * Only declares variables ($limit, $offset, $orderBy) that are actually used in the query,
68
+ * avoiding GraphQL spec §5.8.3 violations from unused variable declarations.
69
+ * Excludes Link and Doctype relation fields from the selection set.
70
+ * @internal
71
+ */
72
+ export declare function buildListQuery(meta: DoctypeMeta, args: {
73
+ limit?: number;
74
+ offset?: number;
75
+ orderBy?: string;
76
+ }, connectionFieldName: (t: string) => string, orderByTypeName: (t: string) => string): string;
77
+
78
+ /**
79
+ * Build a GraphQL query to fetch a single record by ID.
80
+ * Excludes Link and Doctype relation fields from the selection set.
81
+ * @internal
82
+ */
83
+ export declare function buildRecordQuery(meta: DoctypeMeta, recordFieldName: (t: string) => string): string;
84
+
85
+ /**
86
+ * Built-in handlers available for registration
87
+ * @public
88
+ */
89
+ export declare const builtinHandlers: Record<string, ActionHandler>;
90
+
91
+ /**
92
+ * Converts camelCase to Title Case label
93
+ * @param camelCase - Camel case string
94
+ * @returns Title case label
95
+ * @public
96
+ * @example
97
+ * ```typescript
98
+ * camelToLabel('userEmail') // 'User Email'
99
+ * camelToLabel('firstName') // 'First Name'
100
+ * ```
101
+ */
102
+ export declare function camelToLabel(camelCase: string): string;
103
+
104
+ /**
105
+ * Converts camelCase to snake_case
106
+ * @param camelCase - Camel case string
107
+ * @returns Snake case string
108
+ * @public
109
+ * @example
110
+ * ```typescript
111
+ * camelToSnake('userEmail') // 'user_email'
112
+ * camelToSnake('createdAt') // 'created_at'
113
+ * ```
114
+ */
115
+ export declare function camelToSnake(camelCase: string): string;
116
+
117
+ /**
118
+ * Classify a single GraphQL field into a Stonecrop field definition.
119
+ *
120
+ * Classification rules (in order):
121
+ * 1. Scalar types → look up in merged scalar map
122
+ * 2. Enum types → `Select` with enum values as options
123
+ * 3. Object types that are entities → `Link` with slug as options
124
+ * 4. Object types that are Connections → `Doctype` with node type slug as options
125
+ * 5. List of entity type → `Doctype` with item type slug as options
126
+ * 6. Anything else → `Data` with `_unmapped: true`
127
+ *
128
+ * @param fieldName - The GraphQL field name
129
+ * @param field - The GraphQL field definition
130
+ * @param entityTypes - Set of type names classified as entities
131
+ * @param options - Conversion options (for custom scalars, unmapped meta, etc.)
132
+ * @returns The Stonecrop field definition
133
+ * @public
134
+ */
135
+ export declare function classifyFieldType(fieldName: string, field: GraphQLField<unknown, unknown>, entityTypes: Set<string>, options?: GraphQLConversionOptions): GraphQLConversionFieldMeta;
136
+
137
+ /**
138
+ * Clear all registered handlers
139
+ * @public
140
+ */
141
+ export declare function clearHandlers(): void;
142
+
143
+ /**
144
+ * Clear all registered doctypes
145
+ * @public
146
+ */
147
+ export declare function clearRegistry(): void;
148
+
149
+ /**
150
+ * Output of GraphQL schema conversion — one per entity type.
151
+ *
152
+ * @public
153
+ */
154
+ export declare interface ConvertedGraphQLDoctype extends Omit<DoctypeMeta, 'fields'> {
155
+ /** Field definitions with optional GraphQL conversion metadata */
156
+ fields: GraphQLConversionFieldMeta[];
157
+ /** Original GraphQL type name (for debugging/reference) */
158
+ _graphqlTypeName?: string;
159
+ }
160
+
161
+ /**
162
+ * Convert a GraphQL schema to Stonecrop doctype schemas.
163
+ *
164
+ * Accepts either an `IntrospectionQuery` result object or an SDL string.
165
+ * Entity types are identified using heuristics (or a custom `isEntityType` function)
166
+ * and converted to `DoctypeMeta`-compatible JSON objects.
167
+ *
168
+ * @param source - GraphQL introspection result or SDL string
169
+ * @param options - Conversion options for controlling output format and behavior
170
+ * @returns Array of converted Stonecrop doctype definitions
171
+ *
172
+ * @example
173
+ * ```typescript
174
+ * // From introspection result (fetched from any GraphQL server)
175
+ * const introspection = await fetchIntrospection('http://localhost:5000/graphql')
176
+ * const doctypes = convertGraphQLSchema(introspection)
177
+ *
178
+ * // From SDL string
179
+ * const sdl = fs.readFileSync('schema.graphql', 'utf-8')
180
+ * const doctypes = convertGraphQLSchema(sdl)
181
+ *
182
+ * // With PostGraphile custom scalars
183
+ * const doctypes = convertGraphQLSchema(introspection, {
184
+ * customScalars: {
185
+ * BigFloat: { component: 'ADecimalInput', fieldtype: 'Decimal' }
186
+ * }
187
+ * })
188
+ * ```
189
+ *
190
+ * @public
191
+ */
192
+ export declare function convertGraphQLSchema(source: IntrospectionSource, options?: GraphQLConversionOptions): ConvertedGraphQLDoctype[];
193
+
194
+ /**
195
+ * Create a PostGraphile plugin that extends the GraphQL schema with Stonecrop functionality
196
+ * @param options - Plugin configuration options
197
+ * @returns A PostGraphile plugin
198
+ * @public
199
+ */
200
+ export declare const createStonecropPlugin: (options: StonecropPluginOptions) => GraphileConfig_2.Plugin;
201
+
202
+ /**
203
+ * Amber default: sales_orders → allSalesOrders
204
+ * @internal
205
+ */
206
+ export declare function defaultConnectionFieldName(tableName: string): string;
207
+
208
+ /**
209
+ * Default heuristic to filter fields on entity types.
210
+ * Skips internal fields that don't represent meaningful data.
211
+ *
212
+ * @param fieldName - The GraphQL field name
213
+ * @param _field - The GraphQL field definition (unused in default implementation)
214
+ * @param _parentType - The parent entity type (unused in default implementation)
215
+ * @returns `true` if this field should be included
216
+ * @public
217
+ */
218
+ export declare function defaultIsEntityField(fieldName: string, _field: GraphQLField<unknown, unknown>, _parentType: GraphQLObjectType): boolean;
219
+
220
+ /**
221
+ * Default heuristic to determine if a GraphQL object type represents an entity.
222
+ * An entity type becomes a Stonecrop doctype.
223
+ *
224
+ * This heuristic excludes:
225
+ * - Introspection types (`__*`)
226
+ * - Root operation types (`Query`, `Mutation`, `Subscription`)
227
+ * - Types with synthetic suffixes (e.g., `*Connection`, `*Edge`, `*Input`)
228
+ * - Types starting with `Node` interface marker (exact match only)
229
+ *
230
+ * @param typeName - The GraphQL type name
231
+ * @param type - The GraphQL object type definition
232
+ * @returns `true` if this type should become a Stonecrop doctype
233
+ * @public
234
+ */
235
+ export declare function defaultIsEntityType(typeName: string, type: GraphQLObjectType): boolean;
236
+
237
+ /**
238
+ * Amber default: sales_orders → SalesOrdersOrderBy
239
+ * @internal
240
+ */
241
+ export declare function defaultOrderByTypeName(tableName: string): string;
242
+
243
+ /**
244
+ * Amber default: sales_orders → salesOrderById
245
+ * Uses `pluralize` for proper singularization of irregular plurals.
246
+ * Override via `StonecropInflectionConfig.recordFieldName` for non-standard PK columns.
247
+ * @internal
248
+ */
249
+ export declare function defaultRecordFieldName(tableName: string): string;
250
+
251
+ /**
252
+ * Doctype metadata - complete definition of a doctype
253
+ * @public
254
+ */
255
+ export declare const DoctypeMeta: z.ZodObject<{
256
+ /** Display name of the doctype */
257
+ name: z.ZodString;
258
+ /** URL-friendly slug (kebab-case) */
259
+ slug: z.ZodOptional<z.ZodString>;
260
+ /** Database table name */
261
+ tableName: z.ZodOptional<z.ZodString>;
262
+ /** Field definitions */
263
+ fields: z.ZodArray<z.ZodObject<{
264
+ fieldname: z.ZodString;
265
+ fieldtype: z.ZodEnum<["Data", "Text", "Int", "Float", "Decimal", "Check", "Date", "Time", "Datetime", "Duration", "DateRange", "JSON", "Code", "Link", "Doctype", "Attach", "Currency", "Quantity", "Select"]>;
266
+ component: z.ZodOptional<z.ZodString>;
267
+ label: z.ZodOptional<z.ZodString>;
268
+ width: z.ZodOptional<z.ZodString>;
269
+ align: z.ZodOptional<z.ZodEnum<["left", "center", "right", "start", "end"]>>;
270
+ required: z.ZodOptional<z.ZodBoolean>;
271
+ readOnly: z.ZodOptional<z.ZodBoolean>;
272
+ edit: z.ZodOptional<z.ZodBoolean>;
273
+ hidden: z.ZodOptional<z.ZodBoolean>;
274
+ value: z.ZodOptional<z.ZodUnknown>;
275
+ default: z.ZodOptional<z.ZodUnknown>;
276
+ options: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
277
+ mask: z.ZodOptional<z.ZodString>;
278
+ validation: z.ZodOptional<z.ZodObject<{
279
+ errorMessage: z.ZodString;
280
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
281
+ errorMessage: z.ZodString;
282
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
283
+ errorMessage: z.ZodString;
284
+ }, z.ZodTypeAny, "passthrough">>>;
285
+ }, "strip", z.ZodTypeAny, {
286
+ fieldname: string;
287
+ fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
288
+ value?: unknown;
289
+ options?: string | string[] | Record<string, unknown> | undefined;
290
+ validation?: z.objectOutputType<{
291
+ errorMessage: z.ZodString;
292
+ }, z.ZodTypeAny, "passthrough"> | undefined;
293
+ component?: string | undefined;
294
+ label?: string | undefined;
295
+ width?: string | undefined;
296
+ align?: "left" | "center" | "right" | "start" | "end" | undefined;
297
+ required?: boolean | undefined;
298
+ readOnly?: boolean | undefined;
299
+ edit?: boolean | undefined;
300
+ hidden?: boolean | undefined;
301
+ default?: unknown;
302
+ mask?: string | undefined;
303
+ }, {
304
+ fieldname: string;
305
+ fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
306
+ value?: unknown;
307
+ options?: string | string[] | Record<string, unknown> | undefined;
308
+ validation?: z.objectInputType<{
309
+ errorMessage: z.ZodString;
310
+ }, z.ZodTypeAny, "passthrough"> | undefined;
311
+ component?: string | undefined;
312
+ label?: string | undefined;
313
+ width?: string | undefined;
314
+ align?: "left" | "center" | "right" | "start" | "end" | undefined;
315
+ required?: boolean | undefined;
316
+ readOnly?: boolean | undefined;
317
+ edit?: boolean | undefined;
318
+ hidden?: boolean | undefined;
319
+ default?: unknown;
320
+ mask?: string | undefined;
321
+ }>, "many">;
322
+ /** Workflow configuration */
323
+ workflow: z.ZodOptional<z.ZodObject<{
324
+ /** List of workflow states */
325
+ states: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
326
+ /** Actions available in this workflow */
327
+ actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
328
+ /** Display label for the action */
329
+ label: z.ZodString;
330
+ /** Handler function name or path */
331
+ handler: z.ZodString;
332
+ /** Fields that must have values before action can execute */
333
+ requiredFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
334
+ /** Workflow states where this action is available */
335
+ allowedStates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
336
+ /** Whether to show a confirmation dialog */
337
+ confirm: z.ZodOptional<z.ZodBoolean>;
338
+ /** Additional arguments for the action */
339
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
340
+ }, "strip", z.ZodTypeAny, {
341
+ label: string;
342
+ handler: string;
343
+ requiredFields?: string[] | undefined;
344
+ allowedStates?: string[] | undefined;
345
+ confirm?: boolean | undefined;
346
+ args?: Record<string, unknown> | undefined;
347
+ }, {
348
+ label: string;
349
+ handler: string;
350
+ requiredFields?: string[] | undefined;
351
+ allowedStates?: string[] | undefined;
352
+ confirm?: boolean | undefined;
353
+ args?: Record<string, unknown> | undefined;
354
+ }>>>;
355
+ }, "strip", z.ZodTypeAny, {
356
+ states?: string[] | undefined;
357
+ actions?: Record<string, {
358
+ label: string;
359
+ handler: string;
360
+ requiredFields?: string[] | undefined;
361
+ allowedStates?: string[] | undefined;
362
+ confirm?: boolean | undefined;
363
+ args?: Record<string, unknown> | undefined;
364
+ }> | undefined;
365
+ }, {
366
+ states?: string[] | undefined;
367
+ actions?: Record<string, {
368
+ label: string;
369
+ handler: string;
370
+ requiredFields?: string[] | undefined;
371
+ allowedStates?: string[] | undefined;
372
+ confirm?: boolean | undefined;
373
+ args?: Record<string, unknown> | undefined;
374
+ }> | undefined;
375
+ }>>;
376
+ /** Parent doctype for inheritance */
377
+ inherits: z.ZodOptional<z.ZodString>;
378
+ /** Doctype to use for list views */
379
+ listDoctype: z.ZodOptional<z.ZodString>;
380
+ /** Parent doctype for child tables */
381
+ parentDoctype: z.ZodOptional<z.ZodString>;
382
+ }, "strip", z.ZodTypeAny, {
383
+ name: string;
384
+ fields: {
385
+ fieldname: string;
386
+ fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
387
+ value?: unknown;
388
+ options?: string | string[] | Record<string, unknown> | undefined;
389
+ validation?: z.objectOutputType<{
390
+ errorMessage: z.ZodString;
391
+ }, z.ZodTypeAny, "passthrough"> | undefined;
392
+ component?: string | undefined;
393
+ label?: string | undefined;
394
+ width?: string | undefined;
395
+ align?: "left" | "center" | "right" | "start" | "end" | undefined;
396
+ required?: boolean | undefined;
397
+ readOnly?: boolean | undefined;
398
+ edit?: boolean | undefined;
399
+ hidden?: boolean | undefined;
400
+ default?: unknown;
401
+ mask?: string | undefined;
402
+ }[];
403
+ slug?: string | undefined;
404
+ tableName?: string | undefined;
405
+ workflow?: {
406
+ states?: string[] | undefined;
407
+ actions?: Record<string, {
408
+ label: string;
409
+ handler: string;
410
+ requiredFields?: string[] | undefined;
411
+ allowedStates?: string[] | undefined;
412
+ confirm?: boolean | undefined;
413
+ args?: Record<string, unknown> | undefined;
414
+ }> | undefined;
415
+ } | undefined;
416
+ inherits?: string | undefined;
417
+ listDoctype?: string | undefined;
418
+ parentDoctype?: string | undefined;
419
+ }, {
420
+ name: string;
421
+ fields: {
422
+ fieldname: string;
423
+ fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
424
+ value?: unknown;
425
+ options?: string | string[] | Record<string, unknown> | undefined;
426
+ validation?: z.objectInputType<{
427
+ errorMessage: z.ZodString;
428
+ }, z.ZodTypeAny, "passthrough"> | undefined;
429
+ component?: string | undefined;
430
+ label?: string | undefined;
431
+ width?: string | undefined;
432
+ align?: "left" | "center" | "right" | "start" | "end" | undefined;
433
+ required?: boolean | undefined;
434
+ readOnly?: boolean | undefined;
435
+ edit?: boolean | undefined;
436
+ hidden?: boolean | undefined;
437
+ default?: unknown;
438
+ mask?: string | undefined;
439
+ }[];
440
+ slug?: string | undefined;
441
+ tableName?: string | undefined;
442
+ workflow?: {
443
+ states?: string[] | undefined;
444
+ actions?: Record<string, {
445
+ label: string;
446
+ handler: string;
447
+ requiredFields?: string[] | undefined;
448
+ allowedStates?: string[] | undefined;
449
+ confirm?: boolean | undefined;
450
+ args?: Record<string, unknown> | undefined;
451
+ }> | undefined;
452
+ } | undefined;
453
+ inherits?: string | undefined;
454
+ listDoctype?: string | undefined;
455
+ parentDoctype?: string | undefined;
456
+ }>;
457
+
458
+ /**
459
+ * Doctype metadata type inferred from Zod schema
460
+ * @public
461
+ */
462
+ export declare type DoctypeMeta = z.infer<typeof DoctypeMeta>;
463
+
464
+ /**
465
+ * Error thrown when a doctype definition fails validation
466
+ * @public
467
+ */
468
+ export declare class DoctypeValidationError extends Error {
469
+ /** File path or name where the validation error occurred */
470
+ readonly file: string;
471
+ /** List of validation errors found */
472
+ readonly errors: ValidationError[];
473
+ constructor(
474
+ /** File path or name where the validation error occurred */
475
+ file: string,
476
+ /** List of validation errors found */
477
+ errors: ValidationError[]);
478
+ }
479
+
480
+ /**
481
+ * Unified field metadata - the single source of truth for field definitions.
482
+ * Works for both forms (AForm) and tables (ATable).
483
+ *
484
+ * Core principle: "Text" is "Text" regardless of rendering context.
485
+ *
486
+ * @public
487
+ */
488
+ export declare const FieldMeta: z.ZodObject<{
489
+ /** Unique identifier for the field within its doctype */
490
+ fieldname: z.ZodString;
491
+ /** Semantic field type - determines behavior and default component */
492
+ fieldtype: z.ZodEnum<["Data", "Text", "Int", "Float", "Decimal", "Check", "Date", "Time", "Datetime", "Duration", "DateRange", "JSON", "Code", "Link", "Doctype", "Attach", "Currency", "Quantity", "Select"]>;
493
+ /** Vue component to render this field. If not specified, derived from TYPE_MAP */
494
+ component: z.ZodOptional<z.ZodString>;
495
+ /** Human-readable label for the field */
496
+ label: z.ZodOptional<z.ZodString>;
497
+ /** Width of the field (CSS value, e.g., "40ch", "200px") */
498
+ width: z.ZodOptional<z.ZodString>;
499
+ /** Text alignment within the field */
500
+ align: z.ZodOptional<z.ZodEnum<["left", "center", "right", "start", "end"]>>;
501
+ /** Whether the field is required */
502
+ required: z.ZodOptional<z.ZodBoolean>;
503
+ /** Whether the field is read-only */
504
+ readOnly: z.ZodOptional<z.ZodBoolean>;
505
+ /** Whether the field is editable (for table cells) */
506
+ edit: z.ZodOptional<z.ZodBoolean>;
507
+ /** Whether the field is hidden from the UI */
508
+ hidden: z.ZodOptional<z.ZodBoolean>;
509
+ /** Current value of the field */
510
+ value: z.ZodOptional<z.ZodUnknown>;
511
+ /** Default value for new records */
512
+ default: z.ZodOptional<z.ZodUnknown>;
513
+ /**
514
+ * Type-specific options:
515
+ * - Link: target doctype slug ("customer")
516
+ * - Doctype: child doctype slug ("sales-order-item")
517
+ * - Select: choices array (["Draft", "Submitted"])
518
+ * - Decimal: \{ precision, scale \}
519
+ * - Code: \{ language \}
520
+ */
521
+ options: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
522
+ /** Input mask pattern (e.g., "##/##/####" for dates) */
523
+ mask: z.ZodOptional<z.ZodString>;
524
+ /** Validation configuration */
525
+ validation: z.ZodOptional<z.ZodObject<{
526
+ /** Error message to display when validation fails */
527
+ errorMessage: z.ZodString;
528
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
529
+ /** Error message to display when validation fails */
530
+ errorMessage: z.ZodString;
531
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
532
+ /** Error message to display when validation fails */
533
+ errorMessage: z.ZodString;
534
+ }, z.ZodTypeAny, "passthrough">>>;
535
+ }, "strip", z.ZodTypeAny, {
536
+ fieldname: string;
537
+ fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
538
+ value?: unknown;
539
+ options?: string | string[] | Record<string, unknown> | undefined;
540
+ validation?: z.objectOutputType<{
541
+ /** Error message to display when validation fails */
542
+ errorMessage: z.ZodString;
543
+ }, z.ZodTypeAny, "passthrough"> | undefined;
544
+ component?: string | undefined;
545
+ label?: string | undefined;
546
+ width?: string | undefined;
547
+ align?: "left" | "center" | "right" | "start" | "end" | undefined;
548
+ required?: boolean | undefined;
549
+ readOnly?: boolean | undefined;
550
+ edit?: boolean | undefined;
551
+ hidden?: boolean | undefined;
552
+ default?: unknown;
553
+ mask?: string | undefined;
554
+ }, {
555
+ fieldname: string;
556
+ fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
557
+ value?: unknown;
558
+ options?: string | string[] | Record<string, unknown> | undefined;
559
+ validation?: z.objectInputType<{
560
+ /** Error message to display when validation fails */
561
+ errorMessage: z.ZodString;
562
+ }, z.ZodTypeAny, "passthrough"> | undefined;
563
+ component?: string | undefined;
564
+ label?: string | undefined;
565
+ width?: string | undefined;
566
+ align?: "left" | "center" | "right" | "start" | "end" | undefined;
567
+ required?: boolean | undefined;
568
+ readOnly?: boolean | undefined;
569
+ edit?: boolean | undefined;
570
+ hidden?: boolean | undefined;
571
+ default?: unknown;
572
+ mask?: string | undefined;
573
+ }>;
574
+
575
+ /**
576
+ * Field metadata type inferred from Zod schema
577
+ * @public
578
+ */
579
+ export declare type FieldMeta = z.infer<typeof FieldMeta>;
580
+
581
+ /**
582
+ * Field options - flexible bag for type-specific configuration.
583
+ *
584
+ * Usage by fieldtype:
585
+ * - Link/Doctype: target doctype slug as string ("customer", "sales-order-item")
586
+ * - Select: array of choices (["Draft", "Submitted", "Cancelled"])
587
+ * - Decimal: config object (\{ precision: 10, scale: 2 \})
588
+ * - Code: config object (\{ language: "python" \})
589
+ *
590
+ * @public
591
+ */
592
+ export declare const FieldOptions: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
593
+
594
+ /**
595
+ * Field options type inferred from Zod schema
596
+ * @public
597
+ */
598
+ export declare type FieldOptions = z.infer<typeof FieldOptions>;
599
+
600
+ /**
601
+ * Field template for TYPE_MAP entries.
602
+ * Defines the default component and semantic field type for a field.
603
+ * @public
604
+ */
605
+ declare interface FieldTemplate {
606
+ /**
607
+ * The Vue component name to render this field (e.g., 'ATextInput', 'ADropdown')
608
+ */
609
+ component: string;
610
+ /**
611
+ * The semantic field type (e.g., 'Data', 'Int', 'Select')
612
+ */
613
+ fieldtype: StonecropFieldType;
614
+ }
615
+
616
+ /**
617
+ * Validation configuration for form fields
618
+ * @public
619
+ */
620
+ export declare const FieldValidation: z.ZodObject<{
621
+ /** Error message to display when validation fails */
622
+ errorMessage: z.ZodString;
623
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
624
+ /** Error message to display when validation fails */
625
+ errorMessage: z.ZodString;
626
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
627
+ /** Error message to display when validation fails */
628
+ errorMessage: z.ZodString;
629
+ }, z.ZodTypeAny, "passthrough">>;
630
+
631
+ /**
632
+ * Field validation type inferred from Zod schema
633
+ * @public
634
+ */
635
+ export declare type FieldValidation = z.infer<typeof FieldValidation>;
636
+
637
+ /**
638
+ * Get all loaded doctypes
639
+ * @public
640
+ */
641
+ export declare function getAllMeta(): DoctypeMeta[];
642
+
643
+ /**
644
+ * Get the default component for a field type
645
+ * @param fieldtype - The semantic field type
646
+ * @returns The default component name
647
+ * @public
648
+ */
649
+ export declare function getDefaultComponent(fieldtype: StonecropFieldType): string;
650
+
651
+ /**
652
+ * Get a registered handler by name
653
+ * @param name - Name of the action handler to retrieve
654
+ * @public
655
+ */
656
+ export declare function getHandler(name: string): ActionHandler | undefined;
657
+
658
+ /**
659
+ * Get a doctype by name
660
+ * @param name - Name of the doctype to retrieve
661
+ * @public
662
+ */
663
+ export declare function getMeta(name: string): DoctypeMeta | undefined;
664
+
665
+ /**
666
+ * Mapping from standard GraphQL scalar types to Stonecrop field types.
667
+ * These are defined by the GraphQL specification and are always available.
668
+ *
669
+ * @public
670
+ */
671
+ export declare const GQL_SCALAR_MAP: Record<string, FieldTemplate>;
672
+
673
+ /**
674
+ * Extended field metadata with optional GraphQL conversion metadata.
675
+ * Only present when `includeUnmappedMeta` is enabled.
676
+ *
677
+ * @public
678
+ */
679
+ export declare interface GraphQLConversionFieldMeta extends FieldMeta {
680
+ /** Original GraphQL type name (for debugging/reference) */
681
+ _graphqlType?: string;
682
+ /** Marks fields that couldn't be automatically mapped */
683
+ _unmapped?: boolean;
684
+ }
685
+
686
+ /**
687
+ * Options for converting a GraphQL schema to Stonecrop doctype schemas.
688
+ * All hooks are optional — sensible defaults are provided for common GraphQL patterns.
689
+ *
690
+ * @public
691
+ */
692
+ export declare interface GraphQLConversionOptions {
693
+ /**
694
+ * GraphQL type names to exclude from conversion.
695
+ * Applied after `isEntityType` filtering.
696
+ */
697
+ exclude?: string[];
698
+ /**
699
+ * Whitelist of GraphQL type names to convert.
700
+ * When provided, only these types are considered (after `isEntityType` filtering).
701
+ */
702
+ include?: string[];
703
+ /**
704
+ * Per-type, per-field overrides for the converted field definitions.
705
+ * Outer key is the GraphQL type name, inner key is the field name.
706
+ *
707
+ * @example
708
+ * ```typescript
709
+ * {
710
+ * SalesOrder: {
711
+ * totalAmount: { fieldtype: 'Currency', component: 'ACurrencyInput' }
712
+ * }
713
+ * }
714
+ * ```
715
+ */
716
+ typeOverrides?: Record<string, Record<string, Partial<FieldMeta>>>;
717
+ /**
718
+ * Map custom or non-standard GraphQL scalar types to Stonecrop field types.
719
+ * Merged with the built-in scalar maps (GQL_SCALAR_MAP + WELL_KNOWN_SCALARS).
720
+ * User-provided entries take highest precedence.
721
+ *
722
+ * @example
723
+ * ```typescript
724
+ * {
725
+ * MyCustomMoney: { component: 'ACurrencyInput', fieldtype: 'Currency' },
726
+ * PostGISPoint: { component: 'ATextInput', fieldtype: 'Data' }
727
+ * }
728
+ * ```
729
+ */
730
+ customScalars?: Record<string, Partial<FieldTemplate>>;
731
+ /**
732
+ * Custom function to determine if a GraphQL object type represents an entity (→ doctype).
733
+ * When provided, replaces the default heuristic entirely.
734
+ *
735
+ * The default heuristic excludes types matching synthetic patterns:
736
+ * `*Connection`, `*Edge`, `*Input`, `*Patch`, `*Payload`, `*Condition`,
737
+ * `*Filter`, `*OrderBy`, `*Aggregate`, `Query`, `Mutation`, `Subscription`, `__*`.
738
+ *
739
+ * @param typeName - The GraphQL type name
740
+ * @param type - The full GraphQL object type definition
741
+ * @returns `true` if this type should become a Stonecrop doctype
742
+ */
743
+ isEntityType?: (typeName: string, type: GraphQLObjectType) => boolean;
744
+ /**
745
+ * Custom function to filter which fields on an entity type are included.
746
+ * When provided, replaces the default field filter.
747
+ *
748
+ * The default filter excludes `nodeId`, `__typename`, and `clientMutationId`.
749
+ *
750
+ * @param fieldName - The GraphQL field name
751
+ * @param field - The full GraphQL field definition
752
+ * @param parentType - The parent entity type
753
+ * @returns `true` if this field should be included
754
+ */
755
+ isEntityField?: (fieldName: string, field: GraphQLField<unknown, unknown>, parentType: GraphQLObjectType) => boolean;
756
+ /**
757
+ * Escape hatch: fully override the classification of a specific field.
758
+ * When this returns a non-null value, it is used as the field definition
759
+ * (merged with the field name). Return `null` to fall through to default classification.
760
+ *
761
+ * @param fieldName - The GraphQL field name
762
+ * @param field - The full GraphQL field definition
763
+ * @param parentType - The parent entity type
764
+ * @returns Partial field meta to use, or `null` for default behavior
765
+ */
766
+ classifyField?: (fieldName: string, field: GraphQLField<unknown, unknown>, parentType: GraphQLObjectType) => Partial<FieldMeta> | null;
767
+ /**
768
+ * Custom function to derive the database table name from a GraphQL type name.
769
+ * The default converts PascalCase to snake_case (e.g., `SalesOrder` → `sales_order`).
770
+ *
771
+ * Return `undefined` to omit `tableName` from the output.
772
+ *
773
+ * @param typeName - The GraphQL type name
774
+ * @returns The derived table name, or `undefined`
775
+ */
776
+ deriveTableName?: (typeName: string) => string | undefined;
777
+ /**
778
+ * Include `_graphqlType` and `_unmapped` metadata on converted fields.
779
+ * Useful for debugging conversions. Defaults to `false`.
780
+ */
781
+ includeUnmappedMeta?: boolean;
782
+ }
783
+
784
+ /**
785
+ * GraphQL executor interface for running queries/mutations
786
+ * @public
787
+ */
788
+ export declare interface GraphQLExecutor {
789
+ /** Execute a GraphQL query */
790
+ query<T = unknown>(query: string, variables?: Record<string, unknown>): Promise<T>;
791
+ /** Execute a GraphQL mutation */
792
+ mutate<T = unknown>(mutation: string, variables?: Record<string, unknown>): Promise<T>;
793
+ }
794
+
795
+ /**
796
+ * Check if a handler is registered
797
+ * @param name - Name of the action handler to check
798
+ * @public
799
+ */
800
+ export declare function hasHandler(name: string): boolean;
801
+
802
+ /**
803
+ * Check if a doctype is registered
804
+ * @param name - Name of the doctype to check
805
+ * @public
806
+ */
807
+ export declare function hasMeta(name: string): boolean;
808
+
809
+ /**
810
+ * Input source for the GraphQL schema converter.
811
+ * Accepts either a standard GraphQL introspection result or an SDL string.
812
+ *
813
+ * - `IntrospectionQuery`: The raw result of a GraphQL introspection query (from any server)
814
+ * - `string`: An SDL (Schema Definition Language) string
815
+ *
816
+ * Note: URL fetching is intentionally not supported in the library API.
817
+ * Use the CLI (`stonecrop-schema generate --endpoint <url>`) for endpoint fetching,
818
+ * or fetch the introspection result yourself and pass it in.
819
+ *
820
+ * @public
821
+ */
822
+ export declare type IntrospectionSource = IntrospectionQuery | string;
823
+
824
+ /**
825
+ * Load doctype definitions from a directory of JSON files
826
+ * @param dir - Directory path containing doctype JSON files
827
+ * @param options - Options for loading doctypes (continueOnError, onError callback)
828
+ * @public
829
+ */
830
+ export declare function loadDoctypes(dir: string, options?: LoadDoctypesOptions): void;
831
+
832
+ /**
833
+ * Load doctypes from an object (for programmatic use)
834
+ * @param doctypes - Object mapping doctype names to doctype definitions
835
+ * @param options - Options for loading doctypes (continueOnError, onError callback)
836
+ * @public
837
+ */
838
+ export declare function loadDoctypesFromObject(doctypes: Record<string, unknown>, options?: LoadDoctypesOptions): void;
839
+
840
+ /**
841
+ * Options for loading doctype definitions
842
+ * @public
843
+ */
844
+ export declare interface LoadDoctypesOptions {
845
+ /** Continue loading other files if one fails validation */
846
+ continueOnError?: boolean;
847
+ /** Callback for validation errors when continueOnError is true */
848
+ onError?: (file: string, errors: ValidationError[]) => void;
849
+ }
850
+
851
+ /**
852
+ * Parse and validate a doctype, throwing on failure
853
+ * @param data - Data to parse
854
+ * @returns Validated DoctypeMeta
855
+ * @throws ZodError if validation fails
856
+ * @public
857
+ */
858
+ export declare function parseDoctype(data: unknown): DoctypeMeta;
859
+
860
+ /**
861
+ * Parse and validate a field, throwing on failure
862
+ * @param data - Data to parse
863
+ * @returns Validated FieldMeta
864
+ * @throws ZodError if validation fails
865
+ * @public
866
+ */
867
+ export declare function parseField(data: unknown): FieldMeta;
868
+
869
+ /**
870
+ * Convert PascalCase to snake_case (e.g., for deriving table names from type names)
871
+ * @param pascal - PascalCase string
872
+ * @returns snake_case string
873
+ * @public
874
+ * @example
875
+ * ```typescript
876
+ * pascalToSnake('SalesOrder') // 'sales_order'
877
+ * pascalToSnake('SalesOrderItem') // 'sales_order_item'
878
+ * ```
879
+ */
880
+ export declare function pascalToSnake(pascal: string): string;
881
+
882
+ /**
883
+ * Filter fields to only those directly queryable as scalars, excluding Link and Doctype
884
+ * relation fields that require GraphQL sub-selections.
885
+ * @internal
886
+ */
887
+ export declare function queryableFieldNames(meta: DoctypeMeta): string;
888
+
889
+ /**
890
+ * Register all built-in handlers
891
+ * @public
892
+ */
893
+ export declare function registerBuiltinHandlers(): void;
894
+
895
+ /**
896
+ * Register an action handler
897
+ * @param name - Unique name for the action handler
898
+ * @param handler - Action handler function to register
899
+ * @public
900
+ */
901
+ export declare function registerHandler(name: string, handler: ActionHandler): void;
902
+
903
+ /**
904
+ * Fieldtypes that map to GraphQL object/connection types and require sub-selections.
905
+ * These fields are excluded from generated query field selections.
906
+ * @internal
907
+ */
908
+ export declare const RELATION_FIELDTYPES: Set<string>;
909
+
910
+ /**
911
+ * Route context for identifying what doctype/record we're working with
912
+ * @public
913
+ */
914
+ export declare interface RouteContext {
915
+ /** Doctype name (e.g., 'Task', 'Customer') */
916
+ doctype: string;
917
+ /** Optional record ID for viewing/editing a specific record */
918
+ recordId?: string;
919
+ /** Additional context properties */
920
+ [key: string]: unknown;
921
+ }
922
+
923
+ /**
924
+ * Converts snake_case to camelCase
925
+ * @param snakeCase - Snake case string
926
+ * @returns Camel case string
927
+ * @public
928
+ * @example
929
+ * ```typescript
930
+ * snakeToCamel('user_email') // 'userEmail'
931
+ * snakeToCamel('created_at') // 'createdAt'
932
+ * ```
933
+ */
934
+ export declare function snakeToCamel(snakeCase: string): string;
935
+
936
+ /**
937
+ * Converts snake_case to Title Case label
938
+ * @param snakeCase - Snake case string
939
+ * @returns Title case label
940
+ * @public
941
+ * @example
942
+ * ```typescript
943
+ * snakeToLabel('user_email') // 'User Email'
944
+ * snakeToLabel('first_name') // 'First Name'
945
+ * ```
946
+ */
947
+ export declare function snakeToLabel(snakeCase: string): string;
948
+
949
+ /**
950
+ * Client for interacting with Stonecrop GraphQL API
951
+ * @public
952
+ */
953
+ export declare class StonecropClient implements GraphQLExecutor {
954
+ private endpoint;
955
+ private headers;
956
+ private metaCache;
957
+ constructor(options: StonecropClientOptions);
958
+ /**
959
+ * Execute a GraphQL query
960
+ * @param query - GraphQL query string
961
+ * @param variables - Query variables
962
+ */
963
+ query<T = unknown>(query: string, variables?: Record<string, unknown>): Promise<T>;
964
+ /**
965
+ * Execute a GraphQL mutation
966
+ * @param mutation - GraphQL mutation string
967
+ * @param variables - Mutation variables
968
+ */
969
+ mutate<T = unknown>(mutation: string, variables?: Record<string, unknown>): Promise<T>;
970
+ /**
971
+ * Get doctype metadata
972
+ * @param context - Route context containing doctype name
973
+ */
974
+ getMeta(context: RouteContext): Promise<DoctypeMeta | null>;
975
+ /**
976
+ * Get all doctype metadata
977
+ */
978
+ getAllMeta(): Promise<DoctypeMeta[]>;
979
+ /**
980
+ * Get a single record by ID
981
+ * @param doctype - Doctype metadata
982
+ * @param recordId - Record ID to fetch
983
+ */
984
+ getRecord(doctype: DoctypeMeta, recordId: string): Promise<Record<string, unknown> | null>;
985
+ /**
986
+ * Get multiple records with optional filtering and pagination
987
+ * @param doctype - Doctype metadata
988
+ * @param options - Query options (filters, orderBy, limit, offset)
989
+ */
990
+ getRecords(doctype: DoctypeMeta, options?: {
991
+ filters?: Record<string, unknown>;
992
+ orderBy?: string;
993
+ limit?: number;
994
+ offset?: number;
995
+ }): Promise<Record<string, unknown>[]>;
996
+ /**
997
+ * Execute a doctype action
998
+ * @param doctype - Doctype metadata
999
+ * @param action - Action name to execute
1000
+ * @param args - Action arguments
1001
+ */
1002
+ runAction(doctype: DoctypeMeta, action: string, args?: unknown[]): Promise<{
1003
+ success: boolean;
1004
+ data: unknown;
1005
+ error: string | null;
1006
+ }>;
1007
+ /**
1008
+ * Clear the cached doctype metadata
1009
+ */
1010
+ clearMetaCache(): void;
1011
+ }
1012
+
1013
+ /**
1014
+ * Options for creating a Stonecrop client
1015
+ * @public
1016
+ */
1017
+ export declare interface StonecropClientOptions {
1018
+ /** GraphQL endpoint URL */
1019
+ endpoint: string;
1020
+ /** Additional HTTP headers to include in requests */
1021
+ headers?: Record<string, string>;
1022
+ }
1023
+
1024
+ /**
1025
+ * Stonecrop field types - the semantic type of the field.
1026
+ * These are consistent across forms and tables.
1027
+ * @public
1028
+ */
1029
+ export declare const StonecropFieldType: z.ZodEnum<["Data", "Text", "Int", "Float", "Decimal", "Check", "Date", "Time", "Datetime", "Duration", "DateRange", "JSON", "Code", "Link", "Doctype", "Attach", "Currency", "Quantity", "Select"]>;
1030
+
1031
+ /**
1032
+ * Stonecrop field type enum inferred from Zod schema
1033
+ * @public
1034
+ */
1035
+ export declare type StonecropFieldType = z.infer<typeof StonecropFieldType>;
1036
+
1037
+ /**
1038
+ * Inflection callbacks for mapping table names to GraphQL query field names.
1039
+ * Override these when using a non-Amber inflection preset (e.g., V4, SimplifyInflection).
1040
+ *
1041
+ * Defaults match the PostGraphile Amber preset conventions.
1042
+ * @public
1043
+ */
1044
+ export declare interface StonecropInflectionConfig {
1045
+ /**
1046
+ * Given a table name, return the GraphQL field name for fetching a single record by ID.
1047
+ * @example Amber default: "sales_orders" → "salesOrderById"
1048
+ * @example V4 preset: "sales_orders" → "salesOrderByRowId"
1049
+ */
1050
+ recordFieldName?: (tableName: string) => string;
1051
+ /**
1052
+ * Given a table name, return the GraphQL field name for fetching a list/connection.
1053
+ * @example Amber default: "sales_orders" → "allSalesOrders"
1054
+ * @example SimplifyInflection: "sales_orders" → "salesOrders"
1055
+ */
1056
+ connectionFieldName?: (tableName: string) => string;
1057
+ /**
1058
+ * Given a table name, return the GraphQL OrderBy enum type name.
1059
+ * @example Amber default: "sales_orders" → "SalesOrdersOrderBy"
1060
+ */
1061
+ orderByTypeName?: (tableName: string) => string;
1062
+ }
1063
+
1064
+ /**
1065
+ * Options for creating a Stonecrop PostGraphile plugin
1066
+ * @public
1067
+ */
1068
+ export declare interface StonecropPluginOptions {
1069
+ /** GraphQL executor for running queries/mutations */
1070
+ executor: GraphQLExecutor;
1071
+ /**
1072
+ * Override inflection conventions for mapping table names to GraphQL field names.
1073
+ * Defaults to PostGraphile Amber preset conventions.
1074
+ */
1075
+ inflection?: StonecropInflectionConfig;
1076
+ }
1077
+
1078
+ /**
1079
+ * Convert table name to PascalCase doctype name
1080
+ * @param tableName - SQL table name (snake_case)
1081
+ * @returns PascalCase name
1082
+ * @public
1083
+ */
1084
+ export declare function toPascalCase(tableName: string): string;
1085
+
1086
+ /**
1087
+ * Convert to kebab-case slug
1088
+ * @param name - Name to convert
1089
+ * @returns kebab-case slug
1090
+ * @public
1091
+ */
1092
+ export declare function toSlug(name: string): string;
1093
+
1094
+ /**
1095
+ * Mapping from StonecropFieldType to default Vue component.
1096
+ * Components can be overridden in the field definition.
1097
+ * @public
1098
+ */
1099
+ export declare const TYPE_MAP: Record<StonecropFieldType, FieldTemplate>;
1100
+
1101
+ /**
1102
+ * Validate a doctype definition
1103
+ * @param data - Data to validate
1104
+ * @returns Validation result
1105
+ * @public
1106
+ */
1107
+ export declare function validateDoctype(data: unknown): ValidationResult;
1108
+
1109
+ /**
1110
+ * Validate a field definition
1111
+ * @param data - Data to validate
1112
+ * @returns Validation result
1113
+ * @public
1114
+ */
1115
+ export declare function validateField(data: unknown): ValidationResult;
1116
+
1117
+ /**
1118
+ * Validate cross-doctype references (Link fields, inherits, etc.)
1119
+ * Call after all doctypes are loaded.
1120
+ * @public
1121
+ */
1122
+ export declare function validateReferences(): ValidationError[];
1123
+
1124
+ /**
1125
+ * Validation error with path information
1126
+ * @public
1127
+ */
1128
+ export declare interface ValidationError {
1129
+ /** Path to the invalid property */
1130
+ path: (string | number)[];
1131
+ /** Error message */
1132
+ message: string;
1133
+ }
1134
+
1135
+ /**
1136
+ * Result of a validation operation
1137
+ * @public
1138
+ */
1139
+ export declare interface ValidationResult {
1140
+ /** Whether validation passed */
1141
+ success: boolean;
1142
+ /** List of validation errors (empty if success) */
1143
+ errors: ValidationError[];
1144
+ }
1145
+
1146
+ /**
1147
+ * Mapping from well-known custom GraphQL scalars to Stonecrop field types.
1148
+ * These cover scalars commonly used across GraphQL servers (PostGraphile, Hasura, etc.)
1149
+ * without baking in knowledge of any specific server.
1150
+ *
1151
+ * Entries here have lower precedence than `customScalars` from options, but higher
1152
+ * precedence than unknown/unmapped scalars.
1153
+ *
1154
+ * @public
1155
+ */
1156
+ export declare const WELL_KNOWN_SCALARS: Record<string, FieldTemplate>;
1157
+
1158
+ /**
1159
+ * Workflow metadata - states and actions for a doctype
1160
+ * @public
1161
+ */
1162
+ export declare const WorkflowMeta: z.ZodObject<{
1163
+ /** List of workflow states */
1164
+ states: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1165
+ /** Actions available in this workflow */
1166
+ actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
1167
+ /** Display label for the action */
1168
+ label: z.ZodString;
1169
+ /** Handler function name or path */
1170
+ handler: z.ZodString;
1171
+ /** Fields that must have values before action can execute */
1172
+ requiredFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1173
+ /** Workflow states where this action is available */
1174
+ allowedStates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1175
+ /** Whether to show a confirmation dialog */
1176
+ confirm: z.ZodOptional<z.ZodBoolean>;
1177
+ /** Additional arguments for the action */
1178
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1179
+ }, "strip", z.ZodTypeAny, {
1180
+ label: string;
1181
+ handler: string;
1182
+ requiredFields?: string[] | undefined;
1183
+ allowedStates?: string[] | undefined;
1184
+ confirm?: boolean | undefined;
1185
+ args?: Record<string, unknown> | undefined;
1186
+ }, {
1187
+ label: string;
1188
+ handler: string;
1189
+ requiredFields?: string[] | undefined;
1190
+ allowedStates?: string[] | undefined;
1191
+ confirm?: boolean | undefined;
1192
+ args?: Record<string, unknown> | undefined;
1193
+ }>>>;
1194
+ }, "strip", z.ZodTypeAny, {
1195
+ states?: string[] | undefined;
1196
+ actions?: Record<string, {
1197
+ label: string;
1198
+ handler: string;
1199
+ requiredFields?: string[] | undefined;
1200
+ allowedStates?: string[] | undefined;
1201
+ confirm?: boolean | undefined;
1202
+ args?: Record<string, unknown> | undefined;
1203
+ }> | undefined;
1204
+ }, {
1205
+ states?: string[] | undefined;
1206
+ actions?: Record<string, {
1207
+ label: string;
1208
+ handler: string;
1209
+ requiredFields?: string[] | undefined;
1210
+ allowedStates?: string[] | undefined;
1211
+ confirm?: boolean | undefined;
1212
+ args?: Record<string, unknown> | undefined;
1213
+ }> | undefined;
1214
+ }>;
1215
+
1216
+ /**
1217
+ * Workflow metadata type inferred from Zod schema
1218
+ * @public
1219
+ */
1220
+ export declare type WorkflowMeta = z.infer<typeof WorkflowMeta>;
1221
+
1222
+ export { }