@stonecrop/schema 0.7.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.
- package/dist/index.cjs +26 -0
- package/dist/index.d.ts +781 -0
- package/dist/index.js +6144 -0
- package/package.json +36 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,781 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Action definition within a workflow
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare const ActionDefinition: z.ZodObject<{
|
|
8
|
+
/** Display label for the action */
|
|
9
|
+
label: z.ZodString;
|
|
10
|
+
/** Handler function name or path */
|
|
11
|
+
handler: z.ZodString;
|
|
12
|
+
/** Fields that must have values before action can execute */
|
|
13
|
+
requiredFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
14
|
+
/** Workflow states where this action is available */
|
|
15
|
+
allowedStates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
16
|
+
/** Whether to show a confirmation dialog */
|
|
17
|
+
confirm: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
/** Additional arguments for the action */
|
|
19
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
label: string;
|
|
22
|
+
handler: string;
|
|
23
|
+
requiredFields?: string[] | undefined;
|
|
24
|
+
allowedStates?: string[] | undefined;
|
|
25
|
+
confirm?: boolean | undefined;
|
|
26
|
+
args?: Record<string, unknown> | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
label: string;
|
|
29
|
+
handler: string;
|
|
30
|
+
requiredFields?: string[] | undefined;
|
|
31
|
+
allowedStates?: string[] | undefined;
|
|
32
|
+
confirm?: boolean | undefined;
|
|
33
|
+
args?: Record<string, unknown> | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
|
|
36
|
+
export declare type ActionDefinition = z.infer<typeof ActionDefinition>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Converts camelCase to Title Case label
|
|
40
|
+
* @param camelCase - Camel case string
|
|
41
|
+
* @returns Title case label
|
|
42
|
+
* @public
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* camelToLabel('userEmail') // 'User Email'
|
|
46
|
+
* camelToLabel('firstName') // 'First Name'
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function camelToLabel(camelCase: string): string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Converts camelCase to snake_case
|
|
53
|
+
* @param camelCase - Camel case string
|
|
54
|
+
* @returns Snake case string
|
|
55
|
+
* @public
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* camelToSnake('userEmail') // 'user_email'
|
|
59
|
+
* camelToSnake('createdAt') // 'created_at'
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function camelToSnake(camelCase: string): string;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Extended field with conversion metadata (only used during schema-tools output)
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export declare interface ConversionFieldMeta extends FieldMeta {
|
|
69
|
+
_pgType?: string;
|
|
70
|
+
_unmapped?: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Options for DDL to doctype conversion
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
export declare interface ConversionOptions {
|
|
78
|
+
/** Schema to filter tables by */
|
|
79
|
+
schema?: string;
|
|
80
|
+
/** Tables to exclude */
|
|
81
|
+
exclude?: string[];
|
|
82
|
+
/** Override type mappings */
|
|
83
|
+
typeOverrides?: Record<string, Partial<FieldMeta>>;
|
|
84
|
+
/** How to handle inherited fields */
|
|
85
|
+
inheritanceMode: 'flatten' | 'reference';
|
|
86
|
+
/** Include unmapped type metadata in output */
|
|
87
|
+
includeUnmappedMeta?: boolean;
|
|
88
|
+
/** Use camelCase for field names (default: false, keeps snake_case) */
|
|
89
|
+
useCamelCase?: boolean;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Output of schema conversion - uses DoctypeMeta but with optional conversion metadata
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
export declare interface ConvertedDoctype extends Omit<DoctypeMeta, 'fields'> {
|
|
97
|
+
fields: ConversionFieldMeta[];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Convert PostgreSQL DDL to Stonecrop doctype schemas
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
export declare function convertSchema(sql: string, options?: ConversionOptions): ConvertedDoctype[];
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Converts SQL column name to Stonecrop field naming convention
|
|
108
|
+
* Handles special cases like ID suffixes
|
|
109
|
+
* @param sqlName - SQL column name (snake_case)
|
|
110
|
+
* @returns Field name and label
|
|
111
|
+
* @public
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* convertSQLName('user_email')
|
|
115
|
+
* // { fieldname: 'userEmail', label: 'User Email', originalName: 'user_email' }
|
|
116
|
+
*
|
|
117
|
+
* convertSQLName('user_id')
|
|
118
|
+
* // { fieldname: 'userId', label: 'User', originalName: 'user_id' }
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export declare function convertSQLName(sqlName: string): NameConversion;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Batch converts multiple SQL column names
|
|
125
|
+
* @param sqlNames - Array of SQL column names
|
|
126
|
+
* @returns Array of name conversions
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
export declare function convertSQLNames(sqlNames: string[]): NameConversion[];
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Creates a bidirectional mapping between SQL and Stonecrop names
|
|
133
|
+
* @param sqlNames - Array of SQL column names
|
|
134
|
+
* @returns Mapping object with both directions
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
export declare function createNameMapping(sqlNames: string[]): {
|
|
138
|
+
sqlToFieldname: Map<string, string>;
|
|
139
|
+
fieldnameToSQL: Map<string, string>;
|
|
140
|
+
conversions: NameConversion[];
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Doctype metadata - complete definition of a doctype
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
147
|
+
declare const DoctypeMeta: z.ZodObject<{
|
|
148
|
+
/** Display name of the doctype */
|
|
149
|
+
name: z.ZodString;
|
|
150
|
+
/** URL-friendly slug (kebab-case) */
|
|
151
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
152
|
+
/** Database table name */
|
|
153
|
+
tableName: z.ZodOptional<z.ZodString>;
|
|
154
|
+
/** Field definitions */
|
|
155
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
156
|
+
fieldname: z.ZodString;
|
|
157
|
+
fieldtype: z.ZodEnum<["Data", "Text", "Int", "Float", "Decimal", "Check", "Date", "Time", "Datetime", "Duration", "DateRange", "JSON", "Code", "Link", "Doctype", "Attach", "Currency", "Quantity", "Select"]>;
|
|
158
|
+
component: z.ZodOptional<z.ZodString>;
|
|
159
|
+
label: z.ZodOptional<z.ZodString>;
|
|
160
|
+
width: z.ZodOptional<z.ZodString>;
|
|
161
|
+
align: z.ZodOptional<z.ZodEnum<["left", "center", "right", "start", "end"]>>;
|
|
162
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
163
|
+
readOnly: z.ZodOptional<z.ZodBoolean>;
|
|
164
|
+
edit: z.ZodOptional<z.ZodBoolean>;
|
|
165
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
166
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
167
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
168
|
+
options: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
169
|
+
mask: z.ZodOptional<z.ZodString>;
|
|
170
|
+
validation: z.ZodOptional<z.ZodObject<{
|
|
171
|
+
errorMessage: z.ZodString;
|
|
172
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
173
|
+
errorMessage: z.ZodString;
|
|
174
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
175
|
+
errorMessage: z.ZodString;
|
|
176
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
177
|
+
}, "strip", z.ZodTypeAny, {
|
|
178
|
+
fieldname: string;
|
|
179
|
+
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
180
|
+
value?: unknown;
|
|
181
|
+
options?: string | string[] | Record<string, unknown> | undefined;
|
|
182
|
+
validation?: z.objectOutputType<{
|
|
183
|
+
errorMessage: z.ZodString;
|
|
184
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
185
|
+
component?: string | undefined;
|
|
186
|
+
label?: string | undefined;
|
|
187
|
+
width?: string | undefined;
|
|
188
|
+
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
189
|
+
required?: boolean | undefined;
|
|
190
|
+
readOnly?: boolean | undefined;
|
|
191
|
+
edit?: boolean | undefined;
|
|
192
|
+
hidden?: boolean | undefined;
|
|
193
|
+
default?: unknown;
|
|
194
|
+
mask?: string | undefined;
|
|
195
|
+
}, {
|
|
196
|
+
fieldname: string;
|
|
197
|
+
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
198
|
+
value?: unknown;
|
|
199
|
+
options?: string | string[] | Record<string, unknown> | undefined;
|
|
200
|
+
validation?: z.objectInputType<{
|
|
201
|
+
errorMessage: z.ZodString;
|
|
202
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
203
|
+
component?: string | undefined;
|
|
204
|
+
label?: string | undefined;
|
|
205
|
+
width?: string | undefined;
|
|
206
|
+
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
207
|
+
required?: boolean | undefined;
|
|
208
|
+
readOnly?: boolean | undefined;
|
|
209
|
+
edit?: boolean | undefined;
|
|
210
|
+
hidden?: boolean | undefined;
|
|
211
|
+
default?: unknown;
|
|
212
|
+
mask?: string | undefined;
|
|
213
|
+
}>, "many">;
|
|
214
|
+
/** Workflow configuration */
|
|
215
|
+
workflow: z.ZodOptional<z.ZodObject<{
|
|
216
|
+
/** List of workflow states */
|
|
217
|
+
states: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
218
|
+
/** Actions available in this workflow */
|
|
219
|
+
actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
220
|
+
/** Display label for the action */
|
|
221
|
+
label: z.ZodString;
|
|
222
|
+
/** Handler function name or path */
|
|
223
|
+
handler: z.ZodString;
|
|
224
|
+
/** Fields that must have values before action can execute */
|
|
225
|
+
requiredFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
226
|
+
/** Workflow states where this action is available */
|
|
227
|
+
allowedStates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
228
|
+
/** Whether to show a confirmation dialog */
|
|
229
|
+
confirm: z.ZodOptional<z.ZodBoolean>;
|
|
230
|
+
/** Additional arguments for the action */
|
|
231
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
232
|
+
}, "strip", z.ZodTypeAny, {
|
|
233
|
+
label: string;
|
|
234
|
+
handler: string;
|
|
235
|
+
requiredFields?: string[] | undefined;
|
|
236
|
+
allowedStates?: string[] | undefined;
|
|
237
|
+
confirm?: boolean | undefined;
|
|
238
|
+
args?: Record<string, unknown> | undefined;
|
|
239
|
+
}, {
|
|
240
|
+
label: string;
|
|
241
|
+
handler: string;
|
|
242
|
+
requiredFields?: string[] | undefined;
|
|
243
|
+
allowedStates?: string[] | undefined;
|
|
244
|
+
confirm?: boolean | undefined;
|
|
245
|
+
args?: Record<string, unknown> | undefined;
|
|
246
|
+
}>>>;
|
|
247
|
+
}, "strip", z.ZodTypeAny, {
|
|
248
|
+
states?: string[] | undefined;
|
|
249
|
+
actions?: Record<string, {
|
|
250
|
+
label: string;
|
|
251
|
+
handler: string;
|
|
252
|
+
requiredFields?: string[] | undefined;
|
|
253
|
+
allowedStates?: string[] | undefined;
|
|
254
|
+
confirm?: boolean | undefined;
|
|
255
|
+
args?: Record<string, unknown> | undefined;
|
|
256
|
+
}> | undefined;
|
|
257
|
+
}, {
|
|
258
|
+
states?: string[] | undefined;
|
|
259
|
+
actions?: Record<string, {
|
|
260
|
+
label: string;
|
|
261
|
+
handler: string;
|
|
262
|
+
requiredFields?: string[] | undefined;
|
|
263
|
+
allowedStates?: string[] | undefined;
|
|
264
|
+
confirm?: boolean | undefined;
|
|
265
|
+
args?: Record<string, unknown> | undefined;
|
|
266
|
+
}> | undefined;
|
|
267
|
+
}>>;
|
|
268
|
+
/** Parent doctype for inheritance */
|
|
269
|
+
inherits: z.ZodOptional<z.ZodString>;
|
|
270
|
+
/** Doctype to use for list views */
|
|
271
|
+
listDoctype: z.ZodOptional<z.ZodString>;
|
|
272
|
+
/** Parent doctype for child tables */
|
|
273
|
+
parentDoctype: z.ZodOptional<z.ZodString>;
|
|
274
|
+
}, "strip", z.ZodTypeAny, {
|
|
275
|
+
name: string;
|
|
276
|
+
fields: {
|
|
277
|
+
fieldname: string;
|
|
278
|
+
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
279
|
+
value?: unknown;
|
|
280
|
+
options?: string | string[] | Record<string, unknown> | undefined;
|
|
281
|
+
validation?: z.objectOutputType<{
|
|
282
|
+
errorMessage: z.ZodString;
|
|
283
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
284
|
+
component?: string | undefined;
|
|
285
|
+
label?: string | undefined;
|
|
286
|
+
width?: string | undefined;
|
|
287
|
+
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
288
|
+
required?: boolean | undefined;
|
|
289
|
+
readOnly?: boolean | undefined;
|
|
290
|
+
edit?: boolean | undefined;
|
|
291
|
+
hidden?: boolean | undefined;
|
|
292
|
+
default?: unknown;
|
|
293
|
+
mask?: string | undefined;
|
|
294
|
+
}[];
|
|
295
|
+
slug?: string | undefined;
|
|
296
|
+
tableName?: string | undefined;
|
|
297
|
+
workflow?: {
|
|
298
|
+
states?: string[] | undefined;
|
|
299
|
+
actions?: Record<string, {
|
|
300
|
+
label: string;
|
|
301
|
+
handler: string;
|
|
302
|
+
requiredFields?: string[] | undefined;
|
|
303
|
+
allowedStates?: string[] | undefined;
|
|
304
|
+
confirm?: boolean | undefined;
|
|
305
|
+
args?: Record<string, unknown> | undefined;
|
|
306
|
+
}> | undefined;
|
|
307
|
+
} | undefined;
|
|
308
|
+
inherits?: string | undefined;
|
|
309
|
+
listDoctype?: string | undefined;
|
|
310
|
+
parentDoctype?: string | undefined;
|
|
311
|
+
}, {
|
|
312
|
+
name: string;
|
|
313
|
+
fields: {
|
|
314
|
+
fieldname: string;
|
|
315
|
+
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
316
|
+
value?: unknown;
|
|
317
|
+
options?: string | string[] | Record<string, unknown> | undefined;
|
|
318
|
+
validation?: z.objectInputType<{
|
|
319
|
+
errorMessage: z.ZodString;
|
|
320
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
321
|
+
component?: string | undefined;
|
|
322
|
+
label?: string | undefined;
|
|
323
|
+
width?: string | undefined;
|
|
324
|
+
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
325
|
+
required?: boolean | undefined;
|
|
326
|
+
readOnly?: boolean | undefined;
|
|
327
|
+
edit?: boolean | undefined;
|
|
328
|
+
hidden?: boolean | undefined;
|
|
329
|
+
default?: unknown;
|
|
330
|
+
mask?: string | undefined;
|
|
331
|
+
}[];
|
|
332
|
+
slug?: string | undefined;
|
|
333
|
+
tableName?: string | undefined;
|
|
334
|
+
workflow?: {
|
|
335
|
+
states?: string[] | undefined;
|
|
336
|
+
actions?: Record<string, {
|
|
337
|
+
label: string;
|
|
338
|
+
handler: string;
|
|
339
|
+
requiredFields?: string[] | undefined;
|
|
340
|
+
allowedStates?: string[] | undefined;
|
|
341
|
+
confirm?: boolean | undefined;
|
|
342
|
+
args?: Record<string, unknown> | undefined;
|
|
343
|
+
}> | undefined;
|
|
344
|
+
} | undefined;
|
|
345
|
+
inherits?: string | undefined;
|
|
346
|
+
listDoctype?: string | undefined;
|
|
347
|
+
parentDoctype?: string | undefined;
|
|
348
|
+
}>;
|
|
349
|
+
|
|
350
|
+
declare type DoctypeMeta = z.infer<typeof DoctypeMeta>;
|
|
351
|
+
export { DoctypeMeta }
|
|
352
|
+
export { DoctypeMeta as DoctypeMetaType }
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Unified field metadata - the single source of truth for field definitions.
|
|
356
|
+
* Works for both forms (AForm) and tables (ATable).
|
|
357
|
+
*
|
|
358
|
+
* Core principle: "Text" is "Text" regardless of rendering context.
|
|
359
|
+
*
|
|
360
|
+
* @public
|
|
361
|
+
*/
|
|
362
|
+
declare const FieldMeta: z.ZodObject<{
|
|
363
|
+
/** Unique identifier for the field within its doctype */
|
|
364
|
+
fieldname: z.ZodString;
|
|
365
|
+
/** Semantic field type - determines behavior and default component */
|
|
366
|
+
fieldtype: z.ZodEnum<["Data", "Text", "Int", "Float", "Decimal", "Check", "Date", "Time", "Datetime", "Duration", "DateRange", "JSON", "Code", "Link", "Doctype", "Attach", "Currency", "Quantity", "Select"]>;
|
|
367
|
+
/** Vue component to render this field. If not specified, derived from TYPE_MAP */
|
|
368
|
+
component: z.ZodOptional<z.ZodString>;
|
|
369
|
+
/** Human-readable label for the field */
|
|
370
|
+
label: z.ZodOptional<z.ZodString>;
|
|
371
|
+
/** Width of the field (CSS value, e.g., "40ch", "200px") */
|
|
372
|
+
width: z.ZodOptional<z.ZodString>;
|
|
373
|
+
/** Text alignment within the field */
|
|
374
|
+
align: z.ZodOptional<z.ZodEnum<["left", "center", "right", "start", "end"]>>;
|
|
375
|
+
/** Whether the field is required */
|
|
376
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
377
|
+
/** Whether the field is read-only */
|
|
378
|
+
readOnly: z.ZodOptional<z.ZodBoolean>;
|
|
379
|
+
/** Whether the field is editable (for table cells) */
|
|
380
|
+
edit: z.ZodOptional<z.ZodBoolean>;
|
|
381
|
+
/** Whether the field is hidden from the UI */
|
|
382
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
383
|
+
/** Current value of the field */
|
|
384
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
385
|
+
/** Default value for new records */
|
|
386
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
387
|
+
/**
|
|
388
|
+
* Type-specific options:
|
|
389
|
+
* - Link: target doctype slug ("customer")
|
|
390
|
+
* - Doctype: child doctype slug ("sales-order-item")
|
|
391
|
+
* - Select: choices array (["Draft", "Submitted"])
|
|
392
|
+
* - Decimal: { precision, scale }
|
|
393
|
+
* - Code: { language }
|
|
394
|
+
*/
|
|
395
|
+
options: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
396
|
+
/** Input mask pattern (e.g., "##/##/####" for dates) */
|
|
397
|
+
mask: z.ZodOptional<z.ZodString>;
|
|
398
|
+
/** Validation configuration */
|
|
399
|
+
validation: z.ZodOptional<z.ZodObject<{
|
|
400
|
+
/** Error message to display when validation fails */
|
|
401
|
+
errorMessage: z.ZodString;
|
|
402
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
403
|
+
/** Error message to display when validation fails */
|
|
404
|
+
errorMessage: z.ZodString;
|
|
405
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
406
|
+
/** Error message to display when validation fails */
|
|
407
|
+
errorMessage: z.ZodString;
|
|
408
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
409
|
+
}, "strip", z.ZodTypeAny, {
|
|
410
|
+
fieldname: string;
|
|
411
|
+
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
412
|
+
value?: unknown;
|
|
413
|
+
options?: string | string[] | Record<string, unknown> | undefined;
|
|
414
|
+
validation?: z.objectOutputType<{
|
|
415
|
+
/** Error message to display when validation fails */
|
|
416
|
+
errorMessage: z.ZodString;
|
|
417
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
418
|
+
component?: string | undefined;
|
|
419
|
+
label?: string | undefined;
|
|
420
|
+
width?: string | undefined;
|
|
421
|
+
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
422
|
+
required?: boolean | undefined;
|
|
423
|
+
readOnly?: boolean | undefined;
|
|
424
|
+
edit?: boolean | undefined;
|
|
425
|
+
hidden?: boolean | undefined;
|
|
426
|
+
default?: unknown;
|
|
427
|
+
mask?: string | undefined;
|
|
428
|
+
}, {
|
|
429
|
+
fieldname: string;
|
|
430
|
+
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
431
|
+
value?: unknown;
|
|
432
|
+
options?: string | string[] | Record<string, unknown> | undefined;
|
|
433
|
+
validation?: z.objectInputType<{
|
|
434
|
+
/** Error message to display when validation fails */
|
|
435
|
+
errorMessage: z.ZodString;
|
|
436
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
437
|
+
component?: string | undefined;
|
|
438
|
+
label?: string | undefined;
|
|
439
|
+
width?: string | undefined;
|
|
440
|
+
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
441
|
+
required?: boolean | undefined;
|
|
442
|
+
readOnly?: boolean | undefined;
|
|
443
|
+
edit?: boolean | undefined;
|
|
444
|
+
hidden?: boolean | undefined;
|
|
445
|
+
default?: unknown;
|
|
446
|
+
mask?: string | undefined;
|
|
447
|
+
}>;
|
|
448
|
+
|
|
449
|
+
declare type FieldMeta = z.infer<typeof FieldMeta>;
|
|
450
|
+
export { FieldMeta }
|
|
451
|
+
export { FieldMeta as FieldMetaType }
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Field options - flexible bag for type-specific configuration.
|
|
455
|
+
*
|
|
456
|
+
* Usage by fieldtype:
|
|
457
|
+
* - Link/Doctype: target doctype slug as string ("customer", "sales-order-item")
|
|
458
|
+
* - Select: array of choices (["Draft", "Submitted", "Cancelled"])
|
|
459
|
+
* - Decimal: config object ({ precision: 10, scale: 2 })
|
|
460
|
+
* - Code: config object ({ language: "python" })
|
|
461
|
+
*
|
|
462
|
+
* @public
|
|
463
|
+
*/
|
|
464
|
+
declare const FieldOptions: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
|
|
465
|
+
|
|
466
|
+
declare type FieldOptions = z.infer<typeof FieldOptions>;
|
|
467
|
+
export { FieldOptions }
|
|
468
|
+
export { FieldOptions as FieldOptionsType }
|
|
469
|
+
|
|
470
|
+
/* Excluded from this release type: FieldTemplate */
|
|
471
|
+
|
|
472
|
+
declare interface FieldTemplate_2 {
|
|
473
|
+
component: string;
|
|
474
|
+
fieldtype: StonecropFieldType;
|
|
475
|
+
_unmapped?: boolean;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Validation configuration for form fields
|
|
480
|
+
* @public
|
|
481
|
+
*/
|
|
482
|
+
export declare const FieldValidation: z.ZodObject<{
|
|
483
|
+
/** Error message to display when validation fails */
|
|
484
|
+
errorMessage: z.ZodString;
|
|
485
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
486
|
+
/** Error message to display when validation fails */
|
|
487
|
+
errorMessage: z.ZodString;
|
|
488
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
489
|
+
/** Error message to display when validation fails */
|
|
490
|
+
errorMessage: z.ZodString;
|
|
491
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
492
|
+
|
|
493
|
+
export declare type FieldValidation = z.infer<typeof FieldValidation>;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Get the default component for a field type
|
|
497
|
+
* @param fieldtype - The semantic field type
|
|
498
|
+
* @returns The default component name
|
|
499
|
+
* @public
|
|
500
|
+
*/
|
|
501
|
+
export declare function getDefaultComponent(fieldtype: StonecropFieldType): string;
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Options for column to field mapping
|
|
505
|
+
* @public
|
|
506
|
+
*/
|
|
507
|
+
export declare interface MapColumnOptions {
|
|
508
|
+
/** Include unmapped type metadata in output */
|
|
509
|
+
includeUnmappedMeta?: boolean;
|
|
510
|
+
/** Use camelCase for field names (default: false, keeps snake_case) */
|
|
511
|
+
useCamelCase?: boolean;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Map a parsed column to a Stonecrop field definition
|
|
516
|
+
* @public
|
|
517
|
+
*/
|
|
518
|
+
export declare function mapColumnToField(column: ParsedColumn, _tableRegistry: Map<string, ParsedTable>, options?: MapColumnOptions): ConversionFieldMeta;
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Result of name conversion
|
|
522
|
+
* @public
|
|
523
|
+
*/
|
|
524
|
+
export declare interface NameConversion {
|
|
525
|
+
/** Converted fieldname (camelCase) */
|
|
526
|
+
fieldname: string;
|
|
527
|
+
/** Human-readable label */
|
|
528
|
+
label: string;
|
|
529
|
+
/** Original SQL name */
|
|
530
|
+
originalName: string;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Normalize raw PostgreSQL type string to canonical PostgresType
|
|
535
|
+
* @public
|
|
536
|
+
*/
|
|
537
|
+
export declare function normalizeType(rawType: string): PostgresType;
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Intermediate representation of a parsed column (from DDL)
|
|
541
|
+
* @public
|
|
542
|
+
*/
|
|
543
|
+
export declare interface ParsedColumn {
|
|
544
|
+
name: string;
|
|
545
|
+
dataType: string;
|
|
546
|
+
normalizedType: PostgresType;
|
|
547
|
+
nullable: boolean;
|
|
548
|
+
isGenerated: boolean;
|
|
549
|
+
defaultValue?: string;
|
|
550
|
+
arrayDimensions: number;
|
|
551
|
+
reference?: {
|
|
552
|
+
schema?: string;
|
|
553
|
+
table: string;
|
|
554
|
+
column: string;
|
|
555
|
+
onDelete?: 'CASCADE' | 'SET NULL' | 'RESTRICT' | 'NO ACTION';
|
|
556
|
+
};
|
|
557
|
+
precision?: number;
|
|
558
|
+
scale?: number;
|
|
559
|
+
length?: number;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Parse PostgreSQL DDL and extract table definitions
|
|
564
|
+
* @public
|
|
565
|
+
*/
|
|
566
|
+
export declare function parseDDL(sql: string): ParsedTable[];
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* Parse and validate a doctype, throwing on failure
|
|
570
|
+
* @param data - Data to parse
|
|
571
|
+
* @returns Validated DoctypeMeta
|
|
572
|
+
* @throws ZodError if validation fails
|
|
573
|
+
* @public
|
|
574
|
+
*/
|
|
575
|
+
export declare function parseDoctype(data: unknown): DoctypeMeta;
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Intermediate representation of a parsed table (from DDL)
|
|
579
|
+
* @public
|
|
580
|
+
*/
|
|
581
|
+
export declare interface ParsedTable {
|
|
582
|
+
name: string;
|
|
583
|
+
schema?: string;
|
|
584
|
+
columns: ParsedColumn[];
|
|
585
|
+
inherits?: string[];
|
|
586
|
+
/** Table comment from COMMENT ON TABLE statement */
|
|
587
|
+
comment?: string;
|
|
588
|
+
/** Doctype name extracted from comment (if using @doctype convention) */
|
|
589
|
+
doctypeName?: string;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Parse and validate a field, throwing on failure
|
|
594
|
+
* @param data - Data to parse
|
|
595
|
+
* @returns Validated FieldMeta
|
|
596
|
+
* @throws ZodError if validation fails
|
|
597
|
+
* @public
|
|
598
|
+
*/
|
|
599
|
+
export declare function parseField(data: unknown): FieldMeta;
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Mapping from PostgreSQL types to Stonecrop field types
|
|
603
|
+
* @public
|
|
604
|
+
*/
|
|
605
|
+
export declare const PG_TYPE_MAP: Record<PostgresType, FieldTemplate_2>;
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* PostgreSQL types we handle during conversion
|
|
609
|
+
* @public
|
|
610
|
+
*/
|
|
611
|
+
export declare const PostgresType: z.ZodEnum<["text", "varchar", "char", "citext", "smallint", "integer", "bigint", "serial", "bigserial", "smallserial", "numeric", "decimal", "real", "double precision", "money", "boolean", "date", "time", "timetz", "timestamp", "timestamptz", "interval", "int4range", "int8range", "numrange", "daterange", "tsrange", "tstzrange", "bytea", "uuid", "json", "jsonb", "bit", "varbit", "xml", "unit", "cube", "unknown"]>;
|
|
612
|
+
|
|
613
|
+
export declare type PostgresType = z.infer<typeof PostgresType>;
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Converts snake_case to camelCase
|
|
617
|
+
* @param snakeCase - Snake case string
|
|
618
|
+
* @returns Camel case string
|
|
619
|
+
* @public
|
|
620
|
+
* @example
|
|
621
|
+
* ```typescript
|
|
622
|
+
* snakeToCamel('user_email') // 'userEmail'
|
|
623
|
+
* snakeToCamel('created_at') // 'createdAt'
|
|
624
|
+
* ```
|
|
625
|
+
*/
|
|
626
|
+
export declare function snakeToCamel(snakeCase: string): string;
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Converts snake_case to Title Case label
|
|
630
|
+
* @param snakeCase - Snake case string
|
|
631
|
+
* @returns Title case label
|
|
632
|
+
* @public
|
|
633
|
+
* @example
|
|
634
|
+
* ```typescript
|
|
635
|
+
* snakeToLabel('user_email') // 'User Email'
|
|
636
|
+
* snakeToLabel('first_name') // 'First Name'
|
|
637
|
+
* ```
|
|
638
|
+
*/
|
|
639
|
+
export declare function snakeToLabel(snakeCase: string): string;
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Stonecrop field types - the semantic type of the field.
|
|
643
|
+
* These are consistent across forms and tables.
|
|
644
|
+
* @public
|
|
645
|
+
*/
|
|
646
|
+
declare const StonecropFieldType: z.ZodEnum<["Data", "Text", "Int", "Float", "Decimal", "Check", "Date", "Time", "Datetime", "Duration", "DateRange", "JSON", "Code", "Link", "Doctype", "Attach", "Currency", "Quantity", "Select"]>;
|
|
647
|
+
|
|
648
|
+
declare type StonecropFieldType = z.infer<typeof StonecropFieldType>;
|
|
649
|
+
export { StonecropFieldType }
|
|
650
|
+
export { StonecropFieldType as StonecropFieldTypeValue }
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Convert table name to PascalCase doctype name
|
|
654
|
+
* @param tableName - SQL table name (snake_case)
|
|
655
|
+
* @returns PascalCase name
|
|
656
|
+
* @public
|
|
657
|
+
*/
|
|
658
|
+
export declare function toPascalCase(tableName: string): string;
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Convert to kebab-case slug
|
|
662
|
+
* @param name - Name to convert
|
|
663
|
+
* @returns kebab-case slug
|
|
664
|
+
* @public
|
|
665
|
+
*/
|
|
666
|
+
export declare function toSlug(name: string): string;
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* PostgreSQL type aliases to canonical types
|
|
670
|
+
* @public
|
|
671
|
+
*/
|
|
672
|
+
export declare const TYPE_ALIASES: Record<string, PostgresType>;
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Mapping from StonecropFieldType to default Vue component.
|
|
676
|
+
* Components can be overridden in the field definition.
|
|
677
|
+
* @public
|
|
678
|
+
*/
|
|
679
|
+
export declare const TYPE_MAP: Record<StonecropFieldType, FieldTemplate>;
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Validate a doctype definition
|
|
683
|
+
* @param data - Data to validate
|
|
684
|
+
* @returns Validation result
|
|
685
|
+
* @public
|
|
686
|
+
*/
|
|
687
|
+
export declare function validateDoctype(data: unknown): ValidationResult;
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Validate a field definition
|
|
691
|
+
* @param data - Data to validate
|
|
692
|
+
* @returns Validation result
|
|
693
|
+
* @public
|
|
694
|
+
*/
|
|
695
|
+
export declare function validateField(data: unknown): ValidationResult;
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Validation error with path information
|
|
699
|
+
* @public
|
|
700
|
+
*/
|
|
701
|
+
export declare interface ValidationError {
|
|
702
|
+
/** Path to the invalid property */
|
|
703
|
+
path: (string | number)[];
|
|
704
|
+
/** Error message */
|
|
705
|
+
message: string;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Result of a validation operation
|
|
710
|
+
* @public
|
|
711
|
+
*/
|
|
712
|
+
export declare interface ValidationResult {
|
|
713
|
+
/** Whether validation passed */
|
|
714
|
+
success: boolean;
|
|
715
|
+
/** List of validation errors (empty if success) */
|
|
716
|
+
errors: ValidationError[];
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Workflow metadata - states and actions for a doctype
|
|
721
|
+
* @public
|
|
722
|
+
*/
|
|
723
|
+
declare const WorkflowMeta: z.ZodObject<{
|
|
724
|
+
/** List of workflow states */
|
|
725
|
+
states: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
726
|
+
/** Actions available in this workflow */
|
|
727
|
+
actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
728
|
+
/** Display label for the action */
|
|
729
|
+
label: z.ZodString;
|
|
730
|
+
/** Handler function name or path */
|
|
731
|
+
handler: z.ZodString;
|
|
732
|
+
/** Fields that must have values before action can execute */
|
|
733
|
+
requiredFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
734
|
+
/** Workflow states where this action is available */
|
|
735
|
+
allowedStates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
736
|
+
/** Whether to show a confirmation dialog */
|
|
737
|
+
confirm: z.ZodOptional<z.ZodBoolean>;
|
|
738
|
+
/** Additional arguments for the action */
|
|
739
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
740
|
+
}, "strip", z.ZodTypeAny, {
|
|
741
|
+
label: string;
|
|
742
|
+
handler: string;
|
|
743
|
+
requiredFields?: string[] | undefined;
|
|
744
|
+
allowedStates?: string[] | undefined;
|
|
745
|
+
confirm?: boolean | undefined;
|
|
746
|
+
args?: Record<string, unknown> | undefined;
|
|
747
|
+
}, {
|
|
748
|
+
label: string;
|
|
749
|
+
handler: string;
|
|
750
|
+
requiredFields?: string[] | undefined;
|
|
751
|
+
allowedStates?: string[] | undefined;
|
|
752
|
+
confirm?: boolean | undefined;
|
|
753
|
+
args?: Record<string, unknown> | undefined;
|
|
754
|
+
}>>>;
|
|
755
|
+
}, "strip", z.ZodTypeAny, {
|
|
756
|
+
states?: string[] | undefined;
|
|
757
|
+
actions?: Record<string, {
|
|
758
|
+
label: string;
|
|
759
|
+
handler: string;
|
|
760
|
+
requiredFields?: string[] | undefined;
|
|
761
|
+
allowedStates?: string[] | undefined;
|
|
762
|
+
confirm?: boolean | undefined;
|
|
763
|
+
args?: Record<string, unknown> | undefined;
|
|
764
|
+
}> | undefined;
|
|
765
|
+
}, {
|
|
766
|
+
states?: string[] | undefined;
|
|
767
|
+
actions?: Record<string, {
|
|
768
|
+
label: string;
|
|
769
|
+
handler: string;
|
|
770
|
+
requiredFields?: string[] | undefined;
|
|
771
|
+
allowedStates?: string[] | undefined;
|
|
772
|
+
confirm?: boolean | undefined;
|
|
773
|
+
args?: Record<string, unknown> | undefined;
|
|
774
|
+
}> | undefined;
|
|
775
|
+
}>;
|
|
776
|
+
|
|
777
|
+
declare type WorkflowMeta = z.infer<typeof WorkflowMeta>;
|
|
778
|
+
export { WorkflowMeta }
|
|
779
|
+
export { WorkflowMeta as WorkflowMetaType }
|
|
780
|
+
|
|
781
|
+
export { }
|