@stonecrop/schema 0.11.0 → 0.11.2
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-CLc5mUMQ.js.map +1 -1
- package/dist/schema.d.ts +11 -2
- package/dist/src/doctype.d.ts +10 -2
- package/dist/src/doctype.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/cli.cjs +0 -41
- package/dist/cli.cjs.map +0 -1
- package/dist/converter-DNwpowpq.js +0 -459
- package/dist/converter-DNwpowpq.js.map +0 -1
- package/dist/index-0qWNlDQ5.js +0 -450
- package/dist/index-0qWNlDQ5.js.map +0 -1
- package/dist/index-2UVTfbcY.js +0 -448
- package/dist/index-2UVTfbcY.js.map +0 -1
- package/dist/index-9QjWZ_PC.js +0 -449
- package/dist/index-9QjWZ_PC.js.map +0 -1
- package/dist/index-BCADNO5M.js +0 -449
- package/dist/index-BCADNO5M.js.map +0 -1
- package/dist/index-BRQJGVFR.js +0 -453
- package/dist/index-BRQJGVFR.js.map +0 -1
- package/dist/index-BatnoC-J.js +0 -429
- package/dist/index-BatnoC-J.js.map +0 -1
- package/dist/index-BhMd2_xl.js +0 -454
- package/dist/index-BhMd2_xl.js.map +0 -1
- package/dist/index-COrltkHl.js +0 -401
- package/dist/index-COrltkHl.js.map +0 -1
- package/dist/index-CvN9xK1B.js +0 -453
- package/dist/index-CvN9xK1B.js.map +0 -1
- package/dist/index-CzoRIy1-.js +0 -408
- package/dist/index-CzoRIy1-.js.map +0 -1
- package/dist/index-D6Up-BP5.js +0 -435
- package/dist/index-D6Up-BP5.js.map +0 -1
- package/dist/index-DIb_Z0wI.js +0 -476
- package/dist/index-DIb_Z0wI.js.map +0 -1
- package/dist/index-DNROIEMe.js +0 -449
- package/dist/index-DNROIEMe.js.map +0 -1
- package/dist/index-DUFcQC-H.js +0 -449
- package/dist/index-DUFcQC-H.js.map +0 -1
- package/dist/index-DmD8vmuB.js +0 -449
- package/dist/index-DmD8vmuB.js.map +0 -1
- package/dist/index-XZZbfFxT.js +0 -434
- package/dist/index-XZZbfFxT.js.map +0 -1
- package/dist/index-aeXXzPET.cjs +0 -2
- package/dist/index-aeXXzPET.cjs.map +0 -1
- package/dist/index-neVkjlgB.js +0 -446
- package/dist/index-neVkjlgB.js.map +0 -1
- package/dist/index-xdlVWldg.js +0 -408
- package/dist/index-xdlVWldg.js.map +0 -1
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +0 -1
- package/dist/jsonschema.js +0 -225
- package/dist/src/cli.js +0 -210
- package/dist/src/converter/heuristics.js +0 -256
- package/dist/src/converter/index.js +0 -164
- package/dist/src/converter/scalars.js +0 -86
- package/dist/src/converter/types.js +0 -5
- package/dist/src/doctype.js +0 -67
- package/dist/src/field.js +0 -108
- package/dist/src/fieldtype.js +0 -75
- package/dist/src/index.js +0 -12
- package/dist/src/jsonschema.d.ts +0 -95
- package/dist/src/jsonschema.d.ts.map +0 -1
- package/dist/src/naming.js +0 -106
- package/dist/src/tsdoc-metadata.json +0 -11
- package/dist/src/validation.js +0 -60
package/dist/src/fieldtype.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
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 const StonecropFieldType = z
|
|
8
|
-
.enum([
|
|
9
|
-
'Data', // Short text, varchar
|
|
10
|
-
'Text', // Long text
|
|
11
|
-
'Int', // Integer
|
|
12
|
-
'Float', // Floating point (IEEE 754)
|
|
13
|
-
'Decimal', // Arbitrary precision decimal
|
|
14
|
-
'Check', // Boolean/checkbox
|
|
15
|
-
'Date', // Date only
|
|
16
|
-
'Time', // Time only
|
|
17
|
-
'Datetime', // Date and time
|
|
18
|
-
'Duration', // Time interval
|
|
19
|
-
'DateRange', // Date range
|
|
20
|
-
'JSON', // JSON data
|
|
21
|
-
'Code', // Code/source (with syntax highlighting)
|
|
22
|
-
'Link', // Reference to another doctype
|
|
23
|
-
'Doctype', // Child doctype (1:1 nested form or 1:many table via cardinality)
|
|
24
|
-
'Attach', // File attachment
|
|
25
|
-
'Currency', // Currency value
|
|
26
|
-
'Quantity', // Quantity with unit
|
|
27
|
-
'Select', // Dropdown selection
|
|
28
|
-
])
|
|
29
|
-
.meta({
|
|
30
|
-
title: 'StonecropFieldType',
|
|
31
|
-
description: 'Semantic field types for Stonecrop doctypes, consistent across forms and tables',
|
|
32
|
-
});
|
|
33
|
-
/**
|
|
34
|
-
* Mapping from StonecropFieldType to default Vue component.
|
|
35
|
-
* Components can be overridden in the field definition.
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
38
|
-
export const TYPE_MAP = {
|
|
39
|
-
// Text
|
|
40
|
-
Data: { component: 'ATextInput', fieldtype: 'Data' },
|
|
41
|
-
Text: { component: 'ATextInput', fieldtype: 'Text' },
|
|
42
|
-
// Numeric
|
|
43
|
-
Int: { component: 'ANumericInput', fieldtype: 'Int' },
|
|
44
|
-
Float: { component: 'ANumericInput', fieldtype: 'Float' },
|
|
45
|
-
Decimal: { component: 'ADecimalInput', fieldtype: 'Decimal' },
|
|
46
|
-
// Boolean
|
|
47
|
-
Check: { component: 'ACheckbox', fieldtype: 'Check' },
|
|
48
|
-
// Date/Time
|
|
49
|
-
Date: { component: 'ADate', fieldtype: 'Date' },
|
|
50
|
-
Time: { component: 'ATimeInput', fieldtype: 'Time' },
|
|
51
|
-
Datetime: { component: 'ADatetimePicker', fieldtype: 'Datetime' },
|
|
52
|
-
Duration: { component: 'ADurationInput', fieldtype: 'Duration' },
|
|
53
|
-
DateRange: { component: 'ADateRangePicker', fieldtype: 'DateRange' },
|
|
54
|
-
// Structured
|
|
55
|
-
JSON: { component: 'ACodeEditor', fieldtype: 'JSON' },
|
|
56
|
-
Code: { component: 'ACodeEditor', fieldtype: 'Code' },
|
|
57
|
-
// Relational
|
|
58
|
-
Link: { component: 'ALink', fieldtype: 'Link' },
|
|
59
|
-
Doctype: { component: 'AForm', fieldtype: 'Doctype' },
|
|
60
|
-
// Files
|
|
61
|
-
Attach: { component: 'AFileAttach', fieldtype: 'Attach' },
|
|
62
|
-
// Specialized
|
|
63
|
-
Currency: { component: 'ACurrencyInput', fieldtype: 'Currency' },
|
|
64
|
-
Quantity: { component: 'AQuantityInput', fieldtype: 'Quantity' },
|
|
65
|
-
Select: { component: 'ADropdown', fieldtype: 'Select' },
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Get the default component for a field type
|
|
69
|
-
* @param fieldtype - The semantic field type
|
|
70
|
-
* @returns The default component name
|
|
71
|
-
* @public
|
|
72
|
-
*/
|
|
73
|
-
export function getDefaultComponent(fieldtype) {
|
|
74
|
-
return TYPE_MAP[fieldtype]?.component ?? 'ATextInput';
|
|
75
|
-
}
|
package/dist/src/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// Field types
|
|
2
|
-
export { StonecropFieldType, TYPE_MAP, getDefaultComponent } from './fieldtype';
|
|
3
|
-
// Field schema
|
|
4
|
-
export { FieldMeta, FieldOptions, FieldValidation } from './field';
|
|
5
|
-
// Doctype schema
|
|
6
|
-
export { DoctypeMeta, WorkflowMeta, ActionDefinition, } from './doctype';
|
|
7
|
-
// Validation helpers
|
|
8
|
-
export { validateField, validateDoctype, parseField, parseDoctype, } from './validation';
|
|
9
|
-
// GraphQL to Doctype conversion
|
|
10
|
-
export { convertGraphQLSchema, GQL_SCALAR_MAP, WELL_KNOWN_SCALARS, INTERNAL_SCALARS, buildScalarMap, defaultIsEntityType, defaultIsEntityField, classifyFieldType, } from './converter';
|
|
11
|
-
// Naming utilities
|
|
12
|
-
export { toSlug, toPascalCase, pascalToSnake, snakeToCamel, camelToSnake, snakeToLabel, camelToLabel } from './naming';
|
package/dist/src/jsonschema.d.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import type { DoctypeMeta } from './doctype';
|
|
2
|
-
/**
|
|
3
|
-
* JSON Schema representation for a doctype
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export interface DoctypeJSONSchema {
|
|
7
|
-
/** JSON Schema for the doctype structure */
|
|
8
|
-
schema: Record<string, unknown>;
|
|
9
|
-
/** Metadata from the doctype definition */
|
|
10
|
-
meta: {
|
|
11
|
-
name: string;
|
|
12
|
-
slug?: string;
|
|
13
|
-
tableName?: string;
|
|
14
|
-
inherits?: string;
|
|
15
|
-
listDoctype?: string;
|
|
16
|
-
parentDoctype?: string;
|
|
17
|
-
};
|
|
18
|
-
/** Workflow metadata if present */
|
|
19
|
-
workflow?: {
|
|
20
|
-
states?: string[];
|
|
21
|
-
actions?: Record<string, Record<string, unknown>>;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Convert a DoctypeMeta to JSON Schema
|
|
26
|
-
*
|
|
27
|
-
* @param doctype - The doctype definition to convert
|
|
28
|
-
* @returns JSON Schema representation of the doctype
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* import { DoctypeMeta, toJSONSchema } from '@stonecrop/schema'
|
|
33
|
-
*
|
|
34
|
-
* const taskDoctype = DoctypeMeta.parse({
|
|
35
|
-
* name: 'Task',
|
|
36
|
-
* fields: [
|
|
37
|
-
* { fieldname: 'title', fieldtype: 'Data', required: true },
|
|
38
|
-
* { fieldname: 'status', fieldtype: 'Select', options: ['Open', 'Closed'] }
|
|
39
|
-
* ]
|
|
40
|
-
* })
|
|
41
|
-
*
|
|
42
|
-
* const jsonSchema = toJSONSchema(taskDoctype)
|
|
43
|
-
* // => {
|
|
44
|
-
* // schema: { type: 'object', properties: { title: {...}, status: {...} }, required: ['title'] },
|
|
45
|
-
* // meta: { name: 'Task' }
|
|
46
|
-
* // }
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
|
-
export declare function toJSONSchema(doctype: DoctypeMeta): DoctypeJSONSchema;
|
|
52
|
-
/**
|
|
53
|
-
* Generate a collection of JSON Schemas from multiple doctypes
|
|
54
|
-
*
|
|
55
|
-
* @param doctypes - Array of doctype definitions
|
|
56
|
-
* @returns Map of doctype name to JSON Schema
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```typescript
|
|
60
|
-
* import { DoctypeMeta, toSchemasCollection } from '@stonecrop/schema'
|
|
61
|
-
*
|
|
62
|
-
* const doctypes = [
|
|
63
|
-
* DoctypeMeta.parse({ name: 'Task', fields: [...] }),
|
|
64
|
-
* DoctypeMeta.parse({ name: 'Customer', fields: [...] }),
|
|
65
|
-
* ]
|
|
66
|
-
*
|
|
67
|
-
* const collection = toSchemasCollection(doctypes)
|
|
68
|
-
* // => { Task: {...}, Customer: {...} }
|
|
69
|
-
* ```
|
|
70
|
-
*
|
|
71
|
-
* @public
|
|
72
|
-
*/
|
|
73
|
-
export declare function toSchemasCollection(doctypes: DoctypeMeta[]): Record<string, DoctypeJSONSchema>;
|
|
74
|
-
/**
|
|
75
|
-
* Generate OpenAPI schema components from doctypes
|
|
76
|
-
*
|
|
77
|
-
* @param doctypes - Array of doctype definitions
|
|
78
|
-
* @returns OpenAPI 3.1 compatible components object
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```typescript
|
|
82
|
-
* import { DoctypeMeta, toOpenAPIComponents } from '@stonecrop/schema'
|
|
83
|
-
*
|
|
84
|
-
* const doctypes = [DoctypeMeta.parse({ name: 'Task', fields: [...] })]
|
|
85
|
-
*
|
|
86
|
-
* const components = toOpenAPIComponents(doctypes)
|
|
87
|
-
* // => { schemas: { Task: {...} } }
|
|
88
|
-
* ```
|
|
89
|
-
*
|
|
90
|
-
* @public
|
|
91
|
-
*/
|
|
92
|
-
export declare function toOpenAPIComponents(doctypes: DoctypeMeta[]): {
|
|
93
|
-
schemas: Record<string, Record<string, unknown>>;
|
|
94
|
-
};
|
|
95
|
-
//# sourceMappingURL=jsonschema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonschema.d.ts","sourceRoot":"","sources":["../../src/jsonschema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAkC,MAAM,WAAW,CAAA;AAI5E;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IACjC,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAE/B,2CAA2C;IAC3C,IAAI,EAAE;QACL,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,aAAa,CAAC,EAAE,MAAM,CAAA;KACtB,CAAA;IAED,mCAAmC;IACnC,QAAQ,CAAC,EAAE;QACV,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;KACjD,CAAA;CACD;AAuGD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,iBAAiB,CAmDpE;AAsBD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAQ9F;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAAE,CASjH"}
|
package/dist/src/naming.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
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 function snakeToCamel(snakeCase) {
|
|
18
|
-
return snakeCase.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Converts camelCase to snake_case
|
|
22
|
-
* @param camelCase - Camel case string
|
|
23
|
-
* @returns Snake case string
|
|
24
|
-
* @public
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* camelToSnake('userEmail') // 'user_email'
|
|
28
|
-
* camelToSnake('createdAt') // 'created_at'
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export function camelToSnake(camelCase) {
|
|
32
|
-
return camelCase.replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Converts snake_case to Title Case label
|
|
36
|
-
* @param snakeCase - Snake case string
|
|
37
|
-
* @returns Title case label
|
|
38
|
-
* @public
|
|
39
|
-
* @example
|
|
40
|
-
* ```typescript
|
|
41
|
-
* snakeToLabel('user_email') // 'User Email'
|
|
42
|
-
* snakeToLabel('first_name') // 'First Name'
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
export function snakeToLabel(snakeCase) {
|
|
46
|
-
return snakeCase
|
|
47
|
-
.split('_')
|
|
48
|
-
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
49
|
-
.join(' ');
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Converts camelCase to Title Case label
|
|
53
|
-
* @param camelCase - Camel case string
|
|
54
|
-
* @returns Title case label
|
|
55
|
-
* @public
|
|
56
|
-
* @example
|
|
57
|
-
* ```typescript
|
|
58
|
-
* camelToLabel('userEmail') // 'User Email'
|
|
59
|
-
* camelToLabel('firstName') // 'First Name'
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
|
-
export function camelToLabel(camelCase) {
|
|
63
|
-
const withSpaces = camelCase.replace(/([A-Z])/g, ' $1').trim();
|
|
64
|
-
return withSpaces.charAt(0).toUpperCase() + withSpaces.slice(1);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Convert table name to PascalCase doctype name
|
|
68
|
-
* @param tableName - SQL table name (snake_case)
|
|
69
|
-
* @returns PascalCase name
|
|
70
|
-
* @public
|
|
71
|
-
*/
|
|
72
|
-
export function toPascalCase(tableName) {
|
|
73
|
-
return tableName
|
|
74
|
-
.split(/[-_\s]+/)
|
|
75
|
-
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
76
|
-
.join('');
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Convert to kebab-case slug
|
|
80
|
-
* @param name - Name to convert
|
|
81
|
-
* @returns kebab-case slug
|
|
82
|
-
* @public
|
|
83
|
-
*/
|
|
84
|
-
export function toSlug(name) {
|
|
85
|
-
return name
|
|
86
|
-
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
87
|
-
.replace(/[\s_]+/g, '-')
|
|
88
|
-
.toLowerCase();
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Convert PascalCase to snake_case (e.g., for deriving table names from type names)
|
|
92
|
-
* @param pascal - PascalCase string
|
|
93
|
-
* @returns snake_case string
|
|
94
|
-
* @public
|
|
95
|
-
* @example
|
|
96
|
-
* ```typescript
|
|
97
|
-
* pascalToSnake('SalesOrder') // 'sales_order'
|
|
98
|
-
* pascalToSnake('SalesOrderItem') // 'sales_order_item'
|
|
99
|
-
* ```
|
|
100
|
-
*/
|
|
101
|
-
export function pascalToSnake(pascal) {
|
|
102
|
-
return pascal
|
|
103
|
-
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
104
|
-
.replace(/[\s-]+/g, '_')
|
|
105
|
-
.toLowerCase();
|
|
106
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/src/validation.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
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
|
-
}
|