@stonecrop/schema 0.10.2 → 0.10.4
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/cli.js +1 -1
- package/dist/doctype.js +18 -3
- package/dist/field.js +18 -5
- package/dist/fieldtype.js +7 -2
- package/dist/{index-CzoRIy1-.js → index-BatnoC-J.js} +90 -69
- package/dist/index-BatnoC-J.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/schema.d.ts +177 -347
- package/dist/src/doctype.d.ts +108 -247
- package/dist/src/doctype.d.ts.map +1 -1
- package/dist/src/field.d.ts +33 -86
- package/dist/src/field.d.ts.map +1 -1
- package/dist/src/fieldtype.d.ts +21 -1
- package/dist/src/fieldtype.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/validation.d.ts +1 -1
- package/dist/src/validation.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/index-CzoRIy1-.js.map +0 -1
package/dist/src/doctype.d.ts
CHANGED
|
@@ -4,33 +4,13 @@ import { z } from 'zod';
|
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
6
|
export declare const ActionDefinition: z.ZodObject<{
|
|
7
|
-
/** Display label for the action */
|
|
8
7
|
label: z.ZodString;
|
|
9
|
-
/** Handler function name or path */
|
|
10
8
|
handler: z.ZodString;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/** Workflow states where this action is available */
|
|
14
|
-
allowedStates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
15
|
-
/** Whether to show a confirmation dialog */
|
|
9
|
+
requiredFields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
|
+
allowedStates: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
16
11
|
confirm: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
-
/** Additional arguments for the action */
|
|
18
12
|
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
19
|
-
},
|
|
20
|
-
label: string;
|
|
21
|
-
handler: string;
|
|
22
|
-
requiredFields?: string[] | undefined;
|
|
23
|
-
allowedStates?: string[] | undefined;
|
|
24
|
-
confirm?: boolean | undefined;
|
|
25
|
-
args?: Record<string, unknown> | undefined;
|
|
26
|
-
}, {
|
|
27
|
-
label: string;
|
|
28
|
-
handler: string;
|
|
29
|
-
requiredFields?: string[] | undefined;
|
|
30
|
-
allowedStates?: string[] | undefined;
|
|
31
|
-
confirm?: boolean | undefined;
|
|
32
|
-
args?: Record<string, unknown> | undefined;
|
|
33
|
-
}>;
|
|
13
|
+
}, z.core.$strip>;
|
|
34
14
|
/**
|
|
35
15
|
* Action definition type inferred from Zod schema
|
|
36
16
|
* @public
|
|
@@ -41,58 +21,16 @@ export type ActionDefinition = z.infer<typeof ActionDefinition>;
|
|
|
41
21
|
* @public
|
|
42
22
|
*/
|
|
43
23
|
export declare const WorkflowMeta: z.ZodObject<{
|
|
44
|
-
|
|
45
|
-
states: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
46
|
-
/** Actions available in this workflow */
|
|
24
|
+
states: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
47
25
|
actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
48
|
-
/** Display label for the action */
|
|
49
26
|
label: z.ZodString;
|
|
50
|
-
/** Handler function name or path */
|
|
51
27
|
handler: z.ZodString;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/** Workflow states where this action is available */
|
|
55
|
-
allowedStates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
56
|
-
/** Whether to show a confirmation dialog */
|
|
28
|
+
requiredFields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
29
|
+
allowedStates: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
57
30
|
confirm: z.ZodOptional<z.ZodBoolean>;
|
|
58
|
-
/** Additional arguments for the action */
|
|
59
31
|
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
handler: string;
|
|
63
|
-
requiredFields?: string[] | undefined;
|
|
64
|
-
allowedStates?: string[] | undefined;
|
|
65
|
-
confirm?: boolean | undefined;
|
|
66
|
-
args?: Record<string, unknown> | undefined;
|
|
67
|
-
}, {
|
|
68
|
-
label: string;
|
|
69
|
-
handler: string;
|
|
70
|
-
requiredFields?: string[] | undefined;
|
|
71
|
-
allowedStates?: string[] | undefined;
|
|
72
|
-
confirm?: boolean | undefined;
|
|
73
|
-
args?: Record<string, unknown> | undefined;
|
|
74
|
-
}>>>;
|
|
75
|
-
}, "strip", z.ZodTypeAny, {
|
|
76
|
-
states?: string[] | undefined;
|
|
77
|
-
actions?: Record<string, {
|
|
78
|
-
label: string;
|
|
79
|
-
handler: string;
|
|
80
|
-
requiredFields?: string[] | undefined;
|
|
81
|
-
allowedStates?: string[] | undefined;
|
|
82
|
-
confirm?: boolean | undefined;
|
|
83
|
-
args?: Record<string, unknown> | undefined;
|
|
84
|
-
}> | undefined;
|
|
85
|
-
}, {
|
|
86
|
-
states?: string[] | undefined;
|
|
87
|
-
actions?: Record<string, {
|
|
88
|
-
label: string;
|
|
89
|
-
handler: string;
|
|
90
|
-
requiredFields?: string[] | undefined;
|
|
91
|
-
allowedStates?: string[] | undefined;
|
|
92
|
-
confirm?: boolean | undefined;
|
|
93
|
-
args?: Record<string, unknown> | undefined;
|
|
94
|
-
}> | undefined;
|
|
95
|
-
}>;
|
|
32
|
+
}, z.core.$strip>>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
96
34
|
/**
|
|
97
35
|
* Workflow metadata type inferred from Zod schema
|
|
98
36
|
* @public
|
|
@@ -103,218 +41,80 @@ export type WorkflowMeta = z.infer<typeof WorkflowMeta>;
|
|
|
103
41
|
* @public
|
|
104
42
|
*/
|
|
105
43
|
export declare const DoctypeMeta: z.ZodObject<{
|
|
106
|
-
/** Display name of the doctype */
|
|
107
44
|
name: z.ZodString;
|
|
108
|
-
/** URL-friendly slug (kebab-case) */
|
|
109
45
|
slug: z.ZodOptional<z.ZodString>;
|
|
110
|
-
/** Database table name */
|
|
111
46
|
tableName: z.ZodOptional<z.ZodString>;
|
|
112
|
-
/** Field definitions */
|
|
113
47
|
fields: z.ZodArray<z.ZodObject<{
|
|
114
48
|
fieldname: z.ZodString;
|
|
115
|
-
fieldtype: z.ZodEnum<
|
|
49
|
+
fieldtype: z.ZodEnum<{
|
|
50
|
+
Data: "Data";
|
|
51
|
+
Text: "Text";
|
|
52
|
+
Int: "Int";
|
|
53
|
+
Float: "Float";
|
|
54
|
+
Decimal: "Decimal";
|
|
55
|
+
Check: "Check";
|
|
56
|
+
Date: "Date";
|
|
57
|
+
Time: "Time";
|
|
58
|
+
Datetime: "Datetime";
|
|
59
|
+
Duration: "Duration";
|
|
60
|
+
DateRange: "DateRange";
|
|
61
|
+
JSON: "JSON";
|
|
62
|
+
Code: "Code";
|
|
63
|
+
Link: "Link";
|
|
64
|
+
Doctype: "Doctype";
|
|
65
|
+
Attach: "Attach";
|
|
66
|
+
Currency: "Currency";
|
|
67
|
+
Quantity: "Quantity";
|
|
68
|
+
Select: "Select";
|
|
69
|
+
}>;
|
|
116
70
|
component: z.ZodOptional<z.ZodString>;
|
|
117
71
|
label: z.ZodOptional<z.ZodString>;
|
|
118
72
|
width: z.ZodOptional<z.ZodString>;
|
|
119
|
-
align: z.ZodOptional<z.ZodEnum<
|
|
73
|
+
align: z.ZodOptional<z.ZodEnum<{
|
|
74
|
+
left: "left";
|
|
75
|
+
center: "center";
|
|
76
|
+
right: "right";
|
|
77
|
+
start: "start";
|
|
78
|
+
end: "end";
|
|
79
|
+
}>>;
|
|
120
80
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
121
81
|
readOnly: z.ZodOptional<z.ZodBoolean>;
|
|
122
82
|
edit: z.ZodOptional<z.ZodBoolean>;
|
|
123
83
|
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
124
84
|
value: z.ZodOptional<z.ZodUnknown>;
|
|
125
85
|
default: z.ZodOptional<z.ZodUnknown>;
|
|
126
|
-
options: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString
|
|
86
|
+
options: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
127
87
|
mask: z.ZodOptional<z.ZodString>;
|
|
128
88
|
validation: z.ZodOptional<z.ZodObject<{
|
|
129
89
|
errorMessage: z.ZodString;
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
133
|
-
errorMessage: z.ZodString;
|
|
134
|
-
}, z.ZodTypeAny, "passthrough">>>;
|
|
135
|
-
}, "strip", z.ZodTypeAny, {
|
|
136
|
-
fieldname: string;
|
|
137
|
-
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
138
|
-
value?: unknown;
|
|
139
|
-
options?: string | string[] | Record<string, unknown> | undefined;
|
|
140
|
-
validation?: z.objectOutputType<{
|
|
141
|
-
errorMessage: z.ZodString;
|
|
142
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
143
|
-
component?: string | undefined;
|
|
144
|
-
label?: string | undefined;
|
|
145
|
-
width?: string | undefined;
|
|
146
|
-
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
147
|
-
required?: boolean | undefined;
|
|
148
|
-
readOnly?: boolean | undefined;
|
|
149
|
-
edit?: boolean | undefined;
|
|
150
|
-
hidden?: boolean | undefined;
|
|
151
|
-
default?: unknown;
|
|
152
|
-
mask?: string | undefined;
|
|
153
|
-
}, {
|
|
154
|
-
fieldname: string;
|
|
155
|
-
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
156
|
-
value?: unknown;
|
|
157
|
-
options?: string | string[] | Record<string, unknown> | undefined;
|
|
158
|
-
validation?: z.objectInputType<{
|
|
159
|
-
errorMessage: z.ZodString;
|
|
160
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
161
|
-
component?: string | undefined;
|
|
162
|
-
label?: string | undefined;
|
|
163
|
-
width?: string | undefined;
|
|
164
|
-
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
165
|
-
required?: boolean | undefined;
|
|
166
|
-
readOnly?: boolean | undefined;
|
|
167
|
-
edit?: boolean | undefined;
|
|
168
|
-
hidden?: boolean | undefined;
|
|
169
|
-
default?: unknown;
|
|
170
|
-
mask?: string | undefined;
|
|
171
|
-
}>, "many">;
|
|
172
|
-
/** Workflow configuration */
|
|
90
|
+
}, z.core.$loose>>;
|
|
91
|
+
}, z.core.$strip>>;
|
|
173
92
|
workflow: z.ZodOptional<z.ZodObject<{
|
|
174
|
-
|
|
175
|
-
states: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
176
|
-
/** Actions available in this workflow */
|
|
93
|
+
states: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
177
94
|
actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
178
|
-
/** Display label for the action */
|
|
179
95
|
label: z.ZodString;
|
|
180
|
-
/** Handler function name or path */
|
|
181
96
|
handler: z.ZodString;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
/** Workflow states where this action is available */
|
|
185
|
-
allowedStates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
186
|
-
/** Whether to show a confirmation dialog */
|
|
97
|
+
requiredFields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
98
|
+
allowedStates: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
187
99
|
confirm: z.ZodOptional<z.ZodBoolean>;
|
|
188
|
-
/** Additional arguments for the action */
|
|
189
100
|
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
190
|
-
},
|
|
191
|
-
|
|
192
|
-
handler: string;
|
|
193
|
-
requiredFields?: string[] | undefined;
|
|
194
|
-
allowedStates?: string[] | undefined;
|
|
195
|
-
confirm?: boolean | undefined;
|
|
196
|
-
args?: Record<string, unknown> | undefined;
|
|
197
|
-
}, {
|
|
198
|
-
label: string;
|
|
199
|
-
handler: string;
|
|
200
|
-
requiredFields?: string[] | undefined;
|
|
201
|
-
allowedStates?: string[] | undefined;
|
|
202
|
-
confirm?: boolean | undefined;
|
|
203
|
-
args?: Record<string, unknown> | undefined;
|
|
204
|
-
}>>>;
|
|
205
|
-
}, "strip", z.ZodTypeAny, {
|
|
206
|
-
states?: string[] | undefined;
|
|
207
|
-
actions?: Record<string, {
|
|
208
|
-
label: string;
|
|
209
|
-
handler: string;
|
|
210
|
-
requiredFields?: string[] | undefined;
|
|
211
|
-
allowedStates?: string[] | undefined;
|
|
212
|
-
confirm?: boolean | undefined;
|
|
213
|
-
args?: Record<string, unknown> | undefined;
|
|
214
|
-
}> | undefined;
|
|
215
|
-
}, {
|
|
216
|
-
states?: string[] | undefined;
|
|
217
|
-
actions?: Record<string, {
|
|
218
|
-
label: string;
|
|
219
|
-
handler: string;
|
|
220
|
-
requiredFields?: string[] | undefined;
|
|
221
|
-
allowedStates?: string[] | undefined;
|
|
222
|
-
confirm?: boolean | undefined;
|
|
223
|
-
args?: Record<string, unknown> | undefined;
|
|
224
|
-
}> | undefined;
|
|
225
|
-
}>>;
|
|
226
|
-
/** Parent doctype for inheritance */
|
|
101
|
+
}, z.core.$strip>>>;
|
|
102
|
+
}, z.core.$strip>>;
|
|
227
103
|
inherits: z.ZodOptional<z.ZodString>;
|
|
228
|
-
/** Doctype to use for list views */
|
|
229
104
|
listDoctype: z.ZodOptional<z.ZodString>;
|
|
230
|
-
/** Parent doctype for child tables */
|
|
231
105
|
parentDoctype: z.ZodOptional<z.ZodString>;
|
|
232
|
-
},
|
|
233
|
-
name: string;
|
|
234
|
-
fields: {
|
|
235
|
-
fieldname: string;
|
|
236
|
-
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
237
|
-
value?: unknown;
|
|
238
|
-
options?: string | string[] | Record<string, unknown> | undefined;
|
|
239
|
-
validation?: z.objectOutputType<{
|
|
240
|
-
errorMessage: z.ZodString;
|
|
241
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
242
|
-
component?: string | undefined;
|
|
243
|
-
label?: string | undefined;
|
|
244
|
-
width?: string | undefined;
|
|
245
|
-
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
246
|
-
required?: boolean | undefined;
|
|
247
|
-
readOnly?: boolean | undefined;
|
|
248
|
-
edit?: boolean | undefined;
|
|
249
|
-
hidden?: boolean | undefined;
|
|
250
|
-
default?: unknown;
|
|
251
|
-
mask?: string | undefined;
|
|
252
|
-
}[];
|
|
253
|
-
slug?: string | undefined;
|
|
254
|
-
tableName?: string | undefined;
|
|
255
|
-
workflow?: {
|
|
256
|
-
states?: string[] | undefined;
|
|
257
|
-
actions?: Record<string, {
|
|
258
|
-
label: string;
|
|
259
|
-
handler: string;
|
|
260
|
-
requiredFields?: string[] | undefined;
|
|
261
|
-
allowedStates?: string[] | undefined;
|
|
262
|
-
confirm?: boolean | undefined;
|
|
263
|
-
args?: Record<string, unknown> | undefined;
|
|
264
|
-
}> | undefined;
|
|
265
|
-
} | undefined;
|
|
266
|
-
inherits?: string | undefined;
|
|
267
|
-
listDoctype?: string | undefined;
|
|
268
|
-
parentDoctype?: string | undefined;
|
|
269
|
-
}, {
|
|
270
|
-
name: string;
|
|
271
|
-
fields: {
|
|
272
|
-
fieldname: string;
|
|
273
|
-
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
274
|
-
value?: unknown;
|
|
275
|
-
options?: string | string[] | Record<string, unknown> | undefined;
|
|
276
|
-
validation?: z.objectInputType<{
|
|
277
|
-
errorMessage: z.ZodString;
|
|
278
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
279
|
-
component?: string | undefined;
|
|
280
|
-
label?: string | undefined;
|
|
281
|
-
width?: string | undefined;
|
|
282
|
-
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
283
|
-
required?: boolean | undefined;
|
|
284
|
-
readOnly?: boolean | undefined;
|
|
285
|
-
edit?: boolean | undefined;
|
|
286
|
-
hidden?: boolean | undefined;
|
|
287
|
-
default?: unknown;
|
|
288
|
-
mask?: string | undefined;
|
|
289
|
-
}[];
|
|
290
|
-
slug?: string | undefined;
|
|
291
|
-
tableName?: string | undefined;
|
|
292
|
-
workflow?: {
|
|
293
|
-
states?: string[] | undefined;
|
|
294
|
-
actions?: Record<string, {
|
|
295
|
-
label: string;
|
|
296
|
-
handler: string;
|
|
297
|
-
requiredFields?: string[] | undefined;
|
|
298
|
-
allowedStates?: string[] | undefined;
|
|
299
|
-
confirm?: boolean | undefined;
|
|
300
|
-
args?: Record<string, unknown> | undefined;
|
|
301
|
-
}> | undefined;
|
|
302
|
-
} | undefined;
|
|
303
|
-
inherits?: string | undefined;
|
|
304
|
-
listDoctype?: string | undefined;
|
|
305
|
-
parentDoctype?: string | undefined;
|
|
306
|
-
}>;
|
|
106
|
+
}, z.core.$strip>;
|
|
307
107
|
/**
|
|
308
108
|
* Doctype metadata type inferred from Zod schema
|
|
309
109
|
* @public
|
|
310
110
|
*/
|
|
311
111
|
export type DoctypeMeta = z.infer<typeof DoctypeMeta>;
|
|
312
112
|
/**
|
|
313
|
-
*
|
|
113
|
+
* Context for identifying what doctype/record we're working with.
|
|
314
114
|
* Used by graphql-middleware and graphql-client to resolve schema metadata.
|
|
315
115
|
* @public
|
|
316
116
|
*/
|
|
317
|
-
export interface
|
|
117
|
+
export interface DoctypeContext {
|
|
318
118
|
/** Doctype name (e.g., 'Task', 'Customer') */
|
|
319
119
|
doctype: string;
|
|
320
120
|
/** Optional record ID for viewing/editing a specific record */
|
|
@@ -322,4 +122,65 @@ export interface RouteContext {
|
|
|
322
122
|
/** Additional context properties */
|
|
323
123
|
[key: string]: unknown;
|
|
324
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Base interface for doctype metadata passed to DataClient methods.
|
|
127
|
+
* Only requires properties needed for record fetching.
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
export interface DoctypeRef {
|
|
131
|
+
/** Doctype name (e.g., 'Task', 'Customer') */
|
|
132
|
+
name: string;
|
|
133
|
+
/** URL-friendly slug (e.g., 'task', 'customer') */
|
|
134
|
+
slug?: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Interface for data clients that fetch doctype metadata and records.
|
|
138
|
+
* Implemented by \@stonecrop/graphql-client's StonecropClient.
|
|
139
|
+
* Custom implementations can use any backend (REST, local storage, etc.).
|
|
140
|
+
*
|
|
141
|
+
* @typeParam T - Doctype reference type for record operations (defaults to DoctypeRef)
|
|
142
|
+
* @typeParam M - Doctype metadata return type for getMeta (defaults to DoctypeMeta)
|
|
143
|
+
* @public
|
|
144
|
+
*/
|
|
145
|
+
export interface DataClient<T extends DoctypeRef = DoctypeRef, M = DoctypeMeta> {
|
|
146
|
+
/**
|
|
147
|
+
* Fetch doctype metadata
|
|
148
|
+
* @param context - Doctype context identifying the doctype
|
|
149
|
+
* @returns Doctype metadata or null if not found
|
|
150
|
+
*/
|
|
151
|
+
getMeta(context: DoctypeContext): Promise<M | null>;
|
|
152
|
+
/**
|
|
153
|
+
* Fetch a single record by ID
|
|
154
|
+
* @param doctype - Doctype reference (name and optional slug)
|
|
155
|
+
* @param recordId - Record ID to fetch
|
|
156
|
+
* @returns Record data or null if not found
|
|
157
|
+
*/
|
|
158
|
+
getRecord(doctype: T, recordId: string): Promise<Record<string, unknown> | null>;
|
|
159
|
+
/**
|
|
160
|
+
* Fetch multiple records
|
|
161
|
+
* @param doctype - Doctype reference (name and optional slug)
|
|
162
|
+
* @param options - Optional filters, pagination, sorting
|
|
163
|
+
* @returns Array of record data
|
|
164
|
+
*/
|
|
165
|
+
getRecords(doctype: T, options?: {
|
|
166
|
+
filters?: Record<string, unknown>;
|
|
167
|
+
orderBy?: string;
|
|
168
|
+
limit?: number;
|
|
169
|
+
offset?: number;
|
|
170
|
+
}): Promise<Record<string, unknown>[]>;
|
|
171
|
+
/**
|
|
172
|
+
* Execute a doctype action (e.g., SUBMIT, APPROVE, save).
|
|
173
|
+
* All state changes flow through this single mutation endpoint.
|
|
174
|
+
*
|
|
175
|
+
* @param doctype - Doctype reference (name and optional slug)
|
|
176
|
+
* @param action - Action name to execute (e.g., 'SUBMIT', 'APPROVE', 'save')
|
|
177
|
+
* @param args - Action arguments (typically record ID and/or form data)
|
|
178
|
+
* @returns Action result with success status, response data, and any error
|
|
179
|
+
*/
|
|
180
|
+
runAction(doctype: T, action: string, args?: unknown[]): Promise<{
|
|
181
|
+
success: boolean;
|
|
182
|
+
data: unknown;
|
|
183
|
+
error: string | null;
|
|
184
|
+
}>;
|
|
185
|
+
}
|
|
325
186
|
//# sourceMappingURL=doctype.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctype.d.ts","sourceRoot":"","sources":["../../src/doctype.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB;;;GAGG;AACH,eAAO,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"doctype.d.ts","sourceRoot":"","sources":["../../src/doctype.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;iBAuB1B,CAAA;AAEH;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAE/D;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;iBAWtB,CAAA;AAEH;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAEvD;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6BrB,CAAA;AAEH;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAA;AAErD;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC9B,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAA;IACf,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oCAAoC;IACpC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAC1B,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAA;IACZ,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAAE,CAAC,GAAG,WAAW;IAC7E;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;IAEnD;;;;;OAKG;IACH,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;IAEhF;;;;;OAKG;IACH,UAAU,CACT,OAAO,EAAE,CAAC,EACV,OAAO,CAAC,EAAE;QACT,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QACjC,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,MAAM,CAAC,EAAE,MAAM,CAAA;KACf,GACC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IAErC;;;;;;;;OAQG;IACH,SAAS,CACR,OAAO,EAAE,CAAC,EACV,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,OAAO,EAAE,GACd,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAA;CACrE"}
|
package/dist/src/field.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { z } from 'zod';
|
|
|
10
10
|
*
|
|
11
11
|
* @public
|
|
12
12
|
*/
|
|
13
|
-
export declare const FieldOptions: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString
|
|
13
|
+
export declare const FieldOptions: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
|
|
14
14
|
/**
|
|
15
15
|
* Field options type inferred from Zod schema
|
|
16
16
|
* @public
|
|
@@ -23,13 +23,7 @@ export type FieldOptions = z.infer<typeof FieldOptions>;
|
|
|
23
23
|
export declare const FieldValidation: z.ZodObject<{
|
|
24
24
|
/** Error message to display when validation fails */
|
|
25
25
|
errorMessage: z.ZodString;
|
|
26
|
-
},
|
|
27
|
-
/** Error message to display when validation fails */
|
|
28
|
-
errorMessage: z.ZodString;
|
|
29
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
30
|
-
/** Error message to display when validation fails */
|
|
31
|
-
errorMessage: z.ZodString;
|
|
32
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
26
|
+
}, z.core.$loose>;
|
|
33
27
|
/**
|
|
34
28
|
* Field validation type inferred from Zod schema
|
|
35
29
|
* @public
|
|
@@ -44,98 +38,51 @@ export type FieldValidation = z.infer<typeof FieldValidation>;
|
|
|
44
38
|
* @public
|
|
45
39
|
*/
|
|
46
40
|
export declare const FieldMeta: z.ZodObject<{
|
|
47
|
-
/** Unique identifier for the field within its doctype */
|
|
48
41
|
fieldname: z.ZodString;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
fieldtype: z.ZodEnum<{
|
|
43
|
+
Data: "Data";
|
|
44
|
+
Text: "Text";
|
|
45
|
+
Int: "Int";
|
|
46
|
+
Float: "Float";
|
|
47
|
+
Decimal: "Decimal";
|
|
48
|
+
Check: "Check";
|
|
49
|
+
Date: "Date";
|
|
50
|
+
Time: "Time";
|
|
51
|
+
Datetime: "Datetime";
|
|
52
|
+
Duration: "Duration";
|
|
53
|
+
DateRange: "DateRange";
|
|
54
|
+
JSON: "JSON";
|
|
55
|
+
Code: "Code";
|
|
56
|
+
Link: "Link";
|
|
57
|
+
Doctype: "Doctype";
|
|
58
|
+
Attach: "Attach";
|
|
59
|
+
Currency: "Currency";
|
|
60
|
+
Quantity: "Quantity";
|
|
61
|
+
Select: "Select";
|
|
62
|
+
}>;
|
|
52
63
|
component: z.ZodOptional<z.ZodString>;
|
|
53
|
-
/** Human-readable label for the field */
|
|
54
64
|
label: z.ZodOptional<z.ZodString>;
|
|
55
|
-
/** Width of the field (CSS value, e.g., "40ch", "200px") */
|
|
56
65
|
width: z.ZodOptional<z.ZodString>;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
align: z.ZodOptional<z.ZodEnum<{
|
|
67
|
+
left: "left";
|
|
68
|
+
center: "center";
|
|
69
|
+
right: "right";
|
|
70
|
+
start: "start";
|
|
71
|
+
end: "end";
|
|
72
|
+
}>>;
|
|
60
73
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
61
|
-
/** Whether the field is read-only */
|
|
62
74
|
readOnly: z.ZodOptional<z.ZodBoolean>;
|
|
63
|
-
/** Whether the field is editable (for table cells) */
|
|
64
75
|
edit: z.ZodOptional<z.ZodBoolean>;
|
|
65
|
-
/** Whether the field is hidden from the UI */
|
|
66
76
|
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
67
|
-
/** Current value of the field */
|
|
68
77
|
value: z.ZodOptional<z.ZodUnknown>;
|
|
69
|
-
/** Default value for new records */
|
|
70
78
|
default: z.ZodOptional<z.ZodUnknown>;
|
|
71
|
-
|
|
72
|
-
* Type-specific options:
|
|
73
|
-
* - Link: target doctype slug ("customer")
|
|
74
|
-
* - Doctype: child doctype slug ("sales-order-item")
|
|
75
|
-
* - Select: choices array (["Draft", "Submitted"])
|
|
76
|
-
* - Decimal: \{ precision, scale \}
|
|
77
|
-
* - Code: \{ language \}
|
|
78
|
-
*/
|
|
79
|
-
options: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
80
|
-
/**
|
|
81
|
-
* Input mask pattern. Accepts either a plain mask string or a stringified
|
|
82
|
-
* arrow function that receives `locale` and returns a mask string.
|
|
83
|
-
*
|
|
84
|
-
* Plain pattern: `"##/##/####"`
|
|
85
|
-
*
|
|
86
|
-
* Function pattern: `"(locale) => locale === 'en-US' ? '(###) ###-####' : '####-######'"`
|
|
87
|
-
*/
|
|
79
|
+
options: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
88
80
|
mask: z.ZodOptional<z.ZodString>;
|
|
89
|
-
/** Validation configuration */
|
|
90
81
|
validation: z.ZodOptional<z.ZodObject<{
|
|
91
82
|
/** Error message to display when validation fails */
|
|
92
83
|
errorMessage: z.ZodString;
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
errorMessage: z.ZodString;
|
|
96
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
97
|
-
/** Error message to display when validation fails */
|
|
98
|
-
errorMessage: z.ZodString;
|
|
99
|
-
}, z.ZodTypeAny, "passthrough">>>;
|
|
100
|
-
}, "strip", z.ZodTypeAny, {
|
|
101
|
-
fieldname: string;
|
|
102
|
-
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
103
|
-
value?: unknown;
|
|
104
|
-
options?: string | string[] | Record<string, unknown> | undefined;
|
|
105
|
-
validation?: z.objectOutputType<{
|
|
106
|
-
/** Error message to display when validation fails */
|
|
107
|
-
errorMessage: z.ZodString;
|
|
108
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
109
|
-
component?: string | undefined;
|
|
110
|
-
label?: string | undefined;
|
|
111
|
-
width?: string | undefined;
|
|
112
|
-
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
113
|
-
required?: boolean | undefined;
|
|
114
|
-
readOnly?: boolean | undefined;
|
|
115
|
-
edit?: boolean | undefined;
|
|
116
|
-
hidden?: boolean | undefined;
|
|
117
|
-
default?: unknown;
|
|
118
|
-
mask?: string | undefined;
|
|
119
|
-
}, {
|
|
120
|
-
fieldname: string;
|
|
121
|
-
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
122
|
-
value?: unknown;
|
|
123
|
-
options?: string | string[] | Record<string, unknown> | undefined;
|
|
124
|
-
validation?: z.objectInputType<{
|
|
125
|
-
/** Error message to display when validation fails */
|
|
126
|
-
errorMessage: z.ZodString;
|
|
127
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
128
|
-
component?: string | undefined;
|
|
129
|
-
label?: string | undefined;
|
|
130
|
-
width?: string | undefined;
|
|
131
|
-
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
132
|
-
required?: boolean | undefined;
|
|
133
|
-
readOnly?: boolean | undefined;
|
|
134
|
-
edit?: boolean | undefined;
|
|
135
|
-
hidden?: boolean | undefined;
|
|
136
|
-
default?: unknown;
|
|
137
|
-
mask?: string | undefined;
|
|
138
|
-
}>;
|
|
84
|
+
}, z.core.$loose>>;
|
|
85
|
+
}, z.core.$strip>;
|
|
139
86
|
/**
|
|
140
87
|
* Field metadata type inferred from Zod schema
|
|
141
88
|
* @public
|
package/dist/src/field.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,qGAStB,CAAA;AAEH;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAEvD;;;GAGG;AACH,eAAO,MAAM,eAAe;IAE1B,qDAAqD;;iBAMpD,CAAA;AAEH;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAE7D;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAtBpB,qDAAqD;;;iBAqGpD,CAAA;AAEH;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA"}
|
package/dist/src/fieldtype.d.ts
CHANGED
|
@@ -4,7 +4,27 @@ import { z } from 'zod';
|
|
|
4
4
|
* These are consistent across forms and tables.
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
export declare const StonecropFieldType: z.ZodEnum<
|
|
7
|
+
export declare const StonecropFieldType: z.ZodEnum<{
|
|
8
|
+
Data: "Data";
|
|
9
|
+
Text: "Text";
|
|
10
|
+
Int: "Int";
|
|
11
|
+
Float: "Float";
|
|
12
|
+
Decimal: "Decimal";
|
|
13
|
+
Check: "Check";
|
|
14
|
+
Date: "Date";
|
|
15
|
+
Time: "Time";
|
|
16
|
+
Datetime: "Datetime";
|
|
17
|
+
Duration: "Duration";
|
|
18
|
+
DateRange: "DateRange";
|
|
19
|
+
JSON: "JSON";
|
|
20
|
+
Code: "Code";
|
|
21
|
+
Link: "Link";
|
|
22
|
+
Doctype: "Doctype";
|
|
23
|
+
Attach: "Attach";
|
|
24
|
+
Currency: "Currency";
|
|
25
|
+
Quantity: "Quantity";
|
|
26
|
+
Select: "Select";
|
|
27
|
+
}>;
|
|
8
28
|
/**
|
|
9
29
|
* Stonecrop field type enum inferred from Zod schema
|
|
10
30
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldtype.d.ts","sourceRoot":"","sources":["../../src/fieldtype.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"fieldtype.d.ts","sourceRoot":"","sources":["../../src/fieldtype.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;EAyB5B,CAAA;AAEH;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAEnE;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,SAAS,EAAE,kBAAkB,CAAA;CAC7B;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAmC9D,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,kBAAkB,GAAG,MAAM,CAEzE"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { StonecropFieldType, TYPE_MAP, getDefaultComponent } from './fieldtype';
|
|
2
2
|
export { FieldMeta, FieldOptions, FieldValidation } from './field';
|
|
3
|
-
export { DoctypeMeta, WorkflowMeta, ActionDefinition, type
|
|
3
|
+
export { DoctypeMeta, WorkflowMeta, ActionDefinition, type DoctypeContext, type DoctypeRef, type DataClient, } from './doctype';
|
|
4
4
|
export { validateField, validateDoctype, parseField, parseDoctype, type ValidationResult, type ValidationError, } from './validation';
|
|
5
5
|
export { convertGraphQLSchema, GQL_SCALAR_MAP, WELL_KNOWN_SCALARS, INTERNAL_SCALARS, buildScalarMap, defaultIsEntityType, defaultIsEntityField, classifyFieldType, type IntrospectionSource, type GraphQLConversionOptions, type GraphQLConversionFieldMeta, type ConvertedGraphQLDoctype, } from './converter';
|
|
6
6
|
export { toSlug, toPascalCase, pascalToSnake, snakeToCamel, camelToSnake, snakeToLabel, camelToLabel } from './naming';
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAG/E,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGlE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAG/E,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGlE,OAAO,EACN,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,UAAU,GACf,MAAM,WAAW,CAAA;AAGlB,OAAO,EACN,aAAa,EACb,eAAe,EACf,UAAU,EACV,YAAY,EACZ,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACpB,MAAM,cAAc,CAAA;AAGrB,OAAO,EACN,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,GAC5B,MAAM,aAAa,CAAA;AAGpB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGtH,YAAY,EAAE,kBAAkB,IAAI,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAChF,YAAY,EAAE,SAAS,IAAI,aAAa,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC3F,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,YAAY,EAAE,WAAW,IAAI,eAAe,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAA"}
|