@stonecrop/schema 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.
- package/dist/cli.cjs +1 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -0
- package/dist/converter/heuristics.js +254 -0
- package/dist/converter/index.js +164 -0
- package/dist/converter/scalars.js +86 -0
- package/dist/converter/types.js +5 -0
- package/dist/doctype.js +52 -0
- package/dist/field.js +82 -0
- package/dist/fieldtype.js +70 -0
- package/dist/index-COrltkHl.js +1 -0
- package/dist/index-COrltkHl.js.map +1 -0
- package/dist/index-aeXXzPET.cjs +1 -0
- package/dist/index-aeXXzPET.cjs.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/naming.js +106 -0
- package/dist/{index.d.ts → schema.d.ts} +10 -2
- package/dist/schema.tsbuildinfo +1 -0
- package/dist/src/cli.d.ts +15 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/converter/heuristics.d.ts +60 -0
- package/dist/src/converter/heuristics.d.ts.map +1 -0
- package/dist/src/converter/index.d.ts +47 -0
- package/dist/src/converter/index.d.ts.map +1 -0
- package/dist/src/converter/scalars.d.ts +46 -0
- package/dist/src/converter/scalars.d.ts.map +1 -0
- package/dist/src/converter/types.d.ts +145 -0
- package/dist/src/converter/types.d.ts.map +1 -0
- package/dist/src/doctype.d.ts +312 -0
- package/dist/src/doctype.d.ts.map +1 -0
- package/dist/src/field.d.ts +137 -0
- package/dist/src/field.d.ts.map +1 -0
- package/dist/src/fieldtype.d.ts +41 -0
- package/dist/src/fieldtype.d.ts.map +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/naming.d.ts +80 -0
- package/dist/src/naming.d.ts.map +1 -0
- package/dist/src/tsdoc-metadata.json +11 -0
- package/dist/src/validation.d.ts +55 -0
- package/dist/src/validation.d.ts.map +1 -0
- package/dist/validation.js +60 -0
- package/package.json +5 -5
- package/dist/cli.d.ts +0 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Field options - flexible bag for type-specific configuration.
|
|
4
|
+
*
|
|
5
|
+
* Usage by fieldtype:
|
|
6
|
+
* - Link/Doctype: target doctype slug as string ("customer", "sales-order-item")
|
|
7
|
+
* - Select: array of choices (["Draft", "Submitted", "Cancelled"])
|
|
8
|
+
* - Decimal: config object (\{ precision: 10, scale: 2 \})
|
|
9
|
+
* - Code: config object (\{ language: "python" \})
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare const FieldOptions: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
|
|
14
|
+
/**
|
|
15
|
+
* Field options type inferred from Zod schema
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export type FieldOptions = z.infer<typeof FieldOptions>;
|
|
19
|
+
/**
|
|
20
|
+
* Validation configuration for form fields
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare const FieldValidation: z.ZodObject<{
|
|
24
|
+
/** Error message to display when validation fails */
|
|
25
|
+
errorMessage: z.ZodString;
|
|
26
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
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">>;
|
|
33
|
+
/**
|
|
34
|
+
* Field validation type inferred from Zod schema
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export type FieldValidation = z.infer<typeof FieldValidation>;
|
|
38
|
+
/**
|
|
39
|
+
* Unified field metadata - the single source of truth for field definitions.
|
|
40
|
+
* Works for both forms (AForm) and tables (ATable).
|
|
41
|
+
*
|
|
42
|
+
* Core principle: "Text" is "Text" regardless of rendering context.
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
export declare const FieldMeta: z.ZodObject<{
|
|
47
|
+
/** Unique identifier for the field within its doctype */
|
|
48
|
+
fieldname: z.ZodString;
|
|
49
|
+
/** Semantic field type - determines behavior and default component */
|
|
50
|
+
fieldtype: z.ZodEnum<["Data", "Text", "Int", "Float", "Decimal", "Check", "Date", "Time", "Datetime", "Duration", "DateRange", "JSON", "Code", "Link", "Doctype", "Attach", "Currency", "Quantity", "Select"]>;
|
|
51
|
+
/** Vue component to render this field. If not specified, derived from TYPE_MAP */
|
|
52
|
+
component: z.ZodOptional<z.ZodString>;
|
|
53
|
+
/** Human-readable label for the field */
|
|
54
|
+
label: z.ZodOptional<z.ZodString>;
|
|
55
|
+
/** Width of the field (CSS value, e.g., "40ch", "200px") */
|
|
56
|
+
width: z.ZodOptional<z.ZodString>;
|
|
57
|
+
/** Text alignment within the field */
|
|
58
|
+
align: z.ZodOptional<z.ZodEnum<["left", "center", "right", "start", "end"]>>;
|
|
59
|
+
/** Whether the field is required */
|
|
60
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
61
|
+
/** Whether the field is read-only */
|
|
62
|
+
readOnly: z.ZodOptional<z.ZodBoolean>;
|
|
63
|
+
/** Whether the field is editable (for table cells) */
|
|
64
|
+
edit: z.ZodOptional<z.ZodBoolean>;
|
|
65
|
+
/** Whether the field is hidden from the UI */
|
|
66
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
67
|
+
/** Current value of the field */
|
|
68
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
69
|
+
/** Default value for new records */
|
|
70
|
+
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
|
+
/** Input mask pattern (e.g., "##/##/####" for dates) */
|
|
81
|
+
mask: z.ZodOptional<z.ZodString>;
|
|
82
|
+
/** Validation configuration */
|
|
83
|
+
validation: z.ZodOptional<z.ZodObject<{
|
|
84
|
+
/** Error message to display when validation fails */
|
|
85
|
+
errorMessage: z.ZodString;
|
|
86
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
87
|
+
/** Error message to display when validation fails */
|
|
88
|
+
errorMessage: z.ZodString;
|
|
89
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
90
|
+
/** Error message to display when validation fails */
|
|
91
|
+
errorMessage: z.ZodString;
|
|
92
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
93
|
+
}, "strip", z.ZodTypeAny, {
|
|
94
|
+
fieldname: string;
|
|
95
|
+
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
96
|
+
value?: unknown;
|
|
97
|
+
options?: string | string[] | Record<string, unknown> | undefined;
|
|
98
|
+
validation?: z.objectOutputType<{
|
|
99
|
+
/** Error message to display when validation fails */
|
|
100
|
+
errorMessage: z.ZodString;
|
|
101
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
102
|
+
component?: string | undefined;
|
|
103
|
+
label?: string | undefined;
|
|
104
|
+
width?: string | undefined;
|
|
105
|
+
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
106
|
+
required?: boolean | undefined;
|
|
107
|
+
readOnly?: boolean | undefined;
|
|
108
|
+
edit?: boolean | undefined;
|
|
109
|
+
hidden?: boolean | undefined;
|
|
110
|
+
default?: unknown;
|
|
111
|
+
mask?: string | undefined;
|
|
112
|
+
}, {
|
|
113
|
+
fieldname: string;
|
|
114
|
+
fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
|
|
115
|
+
value?: unknown;
|
|
116
|
+
options?: string | string[] | Record<string, unknown> | undefined;
|
|
117
|
+
validation?: z.objectInputType<{
|
|
118
|
+
/** Error message to display when validation fails */
|
|
119
|
+
errorMessage: z.ZodString;
|
|
120
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
121
|
+
component?: string | undefined;
|
|
122
|
+
label?: string | undefined;
|
|
123
|
+
width?: string | undefined;
|
|
124
|
+
align?: "left" | "center" | "right" | "start" | "end" | undefined;
|
|
125
|
+
required?: boolean | undefined;
|
|
126
|
+
readOnly?: boolean | undefined;
|
|
127
|
+
edit?: boolean | undefined;
|
|
128
|
+
hidden?: boolean | undefined;
|
|
129
|
+
default?: unknown;
|
|
130
|
+
mask?: string | undefined;
|
|
131
|
+
}>;
|
|
132
|
+
/**
|
|
133
|
+
* Field metadata type inferred from Zod schema
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
136
|
+
export type FieldMeta = z.infer<typeof FieldMeta>;
|
|
137
|
+
//# sourceMappingURL=field.d.ts.map
|
|
@@ -0,0 +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,oGAIvB,CAAA;AAEF;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAEvD;;;GAGG;AACH,eAAO,MAAM,eAAe;IAE1B,qDAAqD;;;IAArD,qDAAqD;;;IAArD,qDAAqD;;gCAGxC,CAAA;AAEf;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAE7D;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS;IAGrB,yDAAyD;;IAGzD,sEAAsE;;IAKtE,kFAAkF;;IAKlF,yCAAyC;;IAGzC,4DAA4D;;IAG5D,sCAAsC;;IAKtC,oCAAoC;;IAGpC,qCAAqC;;IAGrC,sDAAsD;;IAGtD,8CAA8C;;IAK9C,iCAAiC;;IAGjC,oCAAoC;;IAKpC;;;;;;;OAOG;;IAGH,wDAAwD;;IAKxD,+BAA+B;;QAnF9B,qDAAqD;;;QAArD,qDAAqD;;;QAArD,qDAAqD;;;;;;;;;QAArD,qDAAqD;;;;;;;;;;;;;;;;;;;QAArD,qDAAqD;;;;;;;;;;;;;EAqFrD,CAAA;AAEF;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Stonecrop field types - the semantic type of the field.
|
|
4
|
+
* These are consistent across forms and tables.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
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"]>;
|
|
8
|
+
/**
|
|
9
|
+
* Stonecrop field type enum inferred from Zod schema
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export type StonecropFieldType = z.infer<typeof StonecropFieldType>;
|
|
13
|
+
/**
|
|
14
|
+
* Field template for TYPE_MAP entries.
|
|
15
|
+
* Defines the default component and semantic field type for a field.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export interface FieldTemplate {
|
|
19
|
+
/**
|
|
20
|
+
* The Vue component name to render this field (e.g., 'ATextInput', 'ADropdown')
|
|
21
|
+
*/
|
|
22
|
+
component: string;
|
|
23
|
+
/**
|
|
24
|
+
* The semantic field type (e.g., 'Data', 'Int', 'Select')
|
|
25
|
+
*/
|
|
26
|
+
fieldtype: StonecropFieldType;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Mapping from StonecropFieldType to default Vue component.
|
|
30
|
+
* Components can be overridden in the field definition.
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export declare const TYPE_MAP: Record<StonecropFieldType, FieldTemplate>;
|
|
34
|
+
/**
|
|
35
|
+
* Get the default component for a field type
|
|
36
|
+
* @param fieldtype - The semantic field type
|
|
37
|
+
* @returns The default component name
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare function getDefaultComponent(fieldtype: StonecropFieldType): string;
|
|
41
|
+
//# sourceMappingURL=fieldtype.d.ts.map
|
|
@@ -0,0 +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,qMAoB7B,CAAA;AAEF;;;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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { StonecropFieldType, TYPE_MAP, getDefaultComponent } from './fieldtype';
|
|
2
|
+
export { FieldMeta, FieldOptions, FieldValidation } from './field';
|
|
3
|
+
export { DoctypeMeta, WorkflowMeta, ActionDefinition } from './doctype';
|
|
4
|
+
export { validateField, validateDoctype, parseField, parseDoctype, type ValidationResult, type ValidationError, } from './validation';
|
|
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
|
+
export { toSlug, toPascalCase, pascalToSnake, snakeToCamel, camelToSnake, snakeToLabel, camelToLabel } from './naming';
|
|
7
|
+
export type { StonecropFieldType as StonecropFieldTypeValue } from './fieldtype';
|
|
8
|
+
export type { FieldMeta as FieldMetaType, FieldOptions as FieldOptionsType } from './field';
|
|
9
|
+
export type { FieldTemplate } from './fieldtype';
|
|
10
|
+
export type { DoctypeMeta as DoctypeMetaType, WorkflowMeta as WorkflowMetaType } from './doctype';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAGvE,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"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Naming Convention Utilities
|
|
3
|
+
* Converts between various naming conventions (snake_case, camelCase, PascalCase, kebab-case)
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Converts snake_case to camelCase
|
|
8
|
+
* @param snakeCase - Snake case string
|
|
9
|
+
* @returns Camel case string
|
|
10
|
+
* @public
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* snakeToCamel('user_email') // 'userEmail'
|
|
14
|
+
* snakeToCamel('created_at') // 'createdAt'
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function snakeToCamel(snakeCase: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Converts camelCase to snake_case
|
|
20
|
+
* @param camelCase - Camel case string
|
|
21
|
+
* @returns Snake case string
|
|
22
|
+
* @public
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* camelToSnake('userEmail') // 'user_email'
|
|
26
|
+
* camelToSnake('createdAt') // 'created_at'
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function camelToSnake(camelCase: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Converts snake_case to Title Case label
|
|
32
|
+
* @param snakeCase - Snake case string
|
|
33
|
+
* @returns Title case label
|
|
34
|
+
* @public
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* snakeToLabel('user_email') // 'User Email'
|
|
38
|
+
* snakeToLabel('first_name') // 'First Name'
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function snakeToLabel(snakeCase: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* Converts camelCase to Title Case label
|
|
44
|
+
* @param camelCase - Camel case string
|
|
45
|
+
* @returns Title case label
|
|
46
|
+
* @public
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* camelToLabel('userEmail') // 'User Email'
|
|
50
|
+
* camelToLabel('firstName') // 'First Name'
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function camelToLabel(camelCase: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Convert table name to PascalCase doctype name
|
|
56
|
+
* @param tableName - SQL table name (snake_case)
|
|
57
|
+
* @returns PascalCase name
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare function toPascalCase(tableName: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Convert to kebab-case slug
|
|
63
|
+
* @param name - Name to convert
|
|
64
|
+
* @returns kebab-case slug
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
export declare function toSlug(name: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* Convert PascalCase to snake_case (e.g., for deriving table names from type names)
|
|
70
|
+
* @param pascal - PascalCase string
|
|
71
|
+
* @returns snake_case string
|
|
72
|
+
* @public
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* pascalToSnake('SalesOrder') // 'sales_order'
|
|
76
|
+
* pascalToSnake('SalesOrderItem') // 'sales_order_item'
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare function pascalToSnake(pascal: string): string;
|
|
80
|
+
//# sourceMappingURL=naming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../src/naming.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAKtD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGtD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAKtD;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK3C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKpD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.57.0"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { FieldMeta } from './field';
|
|
2
|
+
import { DoctypeMeta } from './doctype';
|
|
3
|
+
/**
|
|
4
|
+
* Validation error with path information
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface ValidationError {
|
|
8
|
+
/** Path to the invalid property */
|
|
9
|
+
path: (string | number)[];
|
|
10
|
+
/** Error message */
|
|
11
|
+
message: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Result of a validation operation
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export interface ValidationResult {
|
|
18
|
+
/** Whether validation passed */
|
|
19
|
+
success: boolean;
|
|
20
|
+
/** List of validation errors (empty if success) */
|
|
21
|
+
errors: ValidationError[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Validate a field definition
|
|
25
|
+
* @param data - Data to validate
|
|
26
|
+
* @returns Validation result
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export declare function validateField(data: unknown): ValidationResult;
|
|
30
|
+
/**
|
|
31
|
+
* Validate a doctype definition
|
|
32
|
+
* @param data - Data to validate
|
|
33
|
+
* @returns Validation result
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare function validateDoctype(data: unknown): ValidationResult;
|
|
37
|
+
/**
|
|
38
|
+
* Parse and validate a field, throwing on failure
|
|
39
|
+
* @param data - Data to parse
|
|
40
|
+
* @returns Validated FieldMeta
|
|
41
|
+
* @throws ZodError if validation fails
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare function parseField(data: unknown): FieldMeta;
|
|
45
|
+
/**
|
|
46
|
+
* Parse and validate a doctype, throwing on failure
|
|
47
|
+
* @param data - Data to parse
|
|
48
|
+
* @returns Validated DoctypeMeta
|
|
49
|
+
* @throws ZodError if validation fails
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
export declare function parseDoctype(data: unknown): DoctypeMeta;
|
|
53
|
+
export type { FieldMeta } from './field';
|
|
54
|
+
export type { DoctypeMeta } from './doctype';
|
|
55
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,mCAAmC;IACnC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IAEzB,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAA;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC,gCAAgC;IAChC,OAAO,EAAE,OAAO,CAAA;IAEhB,mDAAmD;IACnD,MAAM,EAAE,eAAe,EAAE,CAAA;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAc7D;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAc/D;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,CAEnD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,CAEvD;AAGD,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACxC,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { FieldMeta } from './field';
|
|
2
|
+
import { DoctypeMeta } from './doctype';
|
|
3
|
+
/**
|
|
4
|
+
* Validate a field definition
|
|
5
|
+
* @param data - Data to validate
|
|
6
|
+
* @returns Validation result
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export function validateField(data) {
|
|
10
|
+
const result = FieldMeta.safeParse(data);
|
|
11
|
+
if (result.success) {
|
|
12
|
+
return { success: true, errors: [] };
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
success: false,
|
|
16
|
+
errors: result.error.issues.map(issue => ({
|
|
17
|
+
path: issue.path,
|
|
18
|
+
message: issue.message,
|
|
19
|
+
})),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Validate a doctype definition
|
|
24
|
+
* @param data - Data to validate
|
|
25
|
+
* @returns Validation result
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export function validateDoctype(data) {
|
|
29
|
+
const result = DoctypeMeta.safeParse(data);
|
|
30
|
+
if (result.success) {
|
|
31
|
+
return { success: true, errors: [] };
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
success: false,
|
|
35
|
+
errors: result.error.issues.map(issue => ({
|
|
36
|
+
path: issue.path,
|
|
37
|
+
message: issue.message,
|
|
38
|
+
})),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Parse and validate a field, throwing on failure
|
|
43
|
+
* @param data - Data to parse
|
|
44
|
+
* @returns Validated FieldMeta
|
|
45
|
+
* @throws ZodError if validation fails
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
export function parseField(data) {
|
|
49
|
+
return FieldMeta.parse(data);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Parse and validate a doctype, throwing on failure
|
|
53
|
+
* @param data - Data to parse
|
|
54
|
+
* @returns Validated DoctypeMeta
|
|
55
|
+
* @throws ZodError if validation fails
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export function parseDoctype(data) {
|
|
59
|
+
return DoctypeMeta.parse(data);
|
|
60
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stonecrop/schema",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
7
|
+
"types": "./dist/src/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
10
|
+
"types": "./dist/src/index.d.ts",
|
|
11
11
|
"import": "./dist/index.js",
|
|
12
12
|
"require": "./dist/index.cjs"
|
|
13
13
|
}
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"zod": "^3.25.76"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@
|
|
26
|
+
"@microsoft/api-documenter": "^7.28.2",
|
|
27
|
+
"@rushstack/heft": "^1.2.0",
|
|
27
28
|
"@types/node": "^22.19.5",
|
|
28
29
|
"@vitest/coverage-istanbul": "^4.0.18",
|
|
29
30
|
"jsdom": "^28.1.0",
|
|
30
31
|
"typescript": "^5.9.3",
|
|
31
32
|
"vite": "^7.3.1",
|
|
32
|
-
"vite-plugin-dts": "^4.5.4",
|
|
33
33
|
"vitest": "^4.0.18",
|
|
34
34
|
"stonecrop-rig": "0.7.0"
|
|
35
35
|
},
|
package/dist/cli.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { }
|