@stonecrop/schema 0.14.0 → 0.15.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/package.json +14 -9
- package/dist/cli.cjs +0 -41
- package/dist/cli.cjs.map +0 -1
- package/dist/converter/heuristics.js +0 -258
- package/dist/converter/index.js +0 -181
- package/dist/converter/scalars.js +0 -86
- package/dist/converter/types.js +0 -5
- package/dist/converter-CYNFRwPg.js +0 -512
- package/dist/converter-CYNFRwPg.js.map +0 -1
- package/dist/converter-DNwpowpq.js +0 -459
- package/dist/converter-DNwpowpq.js.map +0 -1
- package/dist/doctype.js +0 -152
- package/dist/field.js +0 -110
- package/dist/fieldtype.js +0 -97
- package/dist/index--rNo7Kel.js +0 -494
- package/dist/index--rNo7Kel.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-BJjSlCSo.js +0 -496
- package/dist/index-BJjSlCSo.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-BbG7Mzvg.js +0 -495
- package/dist/index-BbG7Mzvg.js.map +0 -1
- package/dist/index-BdCmYHg0.js +0 -493
- package/dist/index-BdCmYHg0.js.map +0 -1
- package/dist/index-BhMd2_xl.js +0 -454
- package/dist/index-BhMd2_xl.js.map +0 -1
- package/dist/index-BzhZpuzA.js +0 -556
- package/dist/index-BzhZpuzA.js.map +0 -1
- package/dist/index-C1oC7Xwz.js +0 -552
- package/dist/index-C1oC7Xwz.js.map +0 -1
- package/dist/index-C5ANE_rn.js +0 -501
- package/dist/index-C5ANE_rn.js.map +0 -1
- package/dist/index-C8F23K8c.js +0 -555
- package/dist/index-C8F23K8c.js.map +0 -1
- package/dist/index-CD5wQNH-.js +0 -516
- package/dist/index-CD5wQNH-.js.map +0 -1
- package/dist/index-CLc5mUMQ.js +0 -478
- package/dist/index-CLc5mUMQ.js.map +0 -1
- package/dist/index-CMeexvC6.js +0 -459
- package/dist/index-CMeexvC6.js.map +0 -1
- package/dist/index-COrltkHl.js +0 -401
- package/dist/index-COrltkHl.js.map +0 -1
- package/dist/index-CX662Zb2.js +0 -551
- package/dist/index-CX662Zb2.js.map +0 -1
- package/dist/index-Cq_yfoqI.js +0 -553
- package/dist/index-Cq_yfoqI.js.map +0 -1
- package/dist/index-Cu-6609R.js +0 -493
- package/dist/index-Cu-6609R.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-D66L9JNw.js +0 -506
- package/dist/index-D66L9JNw.js.map +0 -1
- package/dist/index-D68mWfHm.js +0 -510
- package/dist/index-D68mWfHm.js.map +0 -1
- package/dist/index-D6Up-BP5.js +0 -435
- package/dist/index-D6Up-BP5.js.map +0 -1
- package/dist/index-D8R5ppAg.js +0 -529
- package/dist/index-D8R5ppAg.js.map +0 -1
- package/dist/index-D9qPYlSk.js +0 -491
- package/dist/index-D9qPYlSk.js.map +0 -1
- package/dist/index-DCjAX4l-.js +0 -516
- package/dist/index-DCjAX4l-.js.map +0 -1
- package/dist/index-DE0b6fs6.js +0 -515
- package/dist/index-DE0b6fs6.js.map +0 -1
- package/dist/index-DEkR-1RC.js +0 -496
- package/dist/index-DEkR-1RC.js.map +0 -1
- package/dist/index-DIY_FLR2.js +0 -516
- package/dist/index-DIY_FLR2.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-DT-NJBvW.js +0 -510
- package/dist/index-DT-NJBvW.js.map +0 -1
- package/dist/index-DUFcQC-H.js +0 -449
- package/dist/index-DUFcQC-H.js.map +0 -1
- package/dist/index-DVVTsJNb.js +0 -495
- package/dist/index-DVVTsJNb.js.map +0 -1
- package/dist/index-DYy5E1cU.js +0 -508
- package/dist/index-DYy5E1cU.js.map +0 -1
- package/dist/index-DdC5tpt-.js +0 -488
- package/dist/index-DdC5tpt-.js.map +0 -1
- package/dist/index-Dk593rMz.js +0 -512
- package/dist/index-Dk593rMz.js.map +0 -1
- package/dist/index-DmD8vmuB.js +0 -449
- package/dist/index-DmD8vmuB.js.map +0 -1
- package/dist/index-DpCFgELB.js +0 -514
- package/dist/index-DpCFgELB.js.map +0 -1
- package/dist/index-DqxTn6jG.js +0 -488
- package/dist/index-DqxTn6jG.js.map +0 -1
- package/dist/index-DyK5-0kh.js +0 -514
- package/dist/index-DyK5-0kh.js.map +0 -1
- package/dist/index-Vd0_gZjr.js +0 -451
- package/dist/index-Vd0_gZjr.js.map +0 -1
- package/dist/index-XSSAHj8g.js +0 -495
- package/dist/index-XSSAHj8g.js.map +0 -1
- package/dist/index-XZZbfFxT.js +0 -434
- package/dist/index-XZZbfFxT.js.map +0 -1
- package/dist/index-YP0m26Y5.js +0 -555
- package/dist/index-YP0m26Y5.js.map +0 -1
- package/dist/index-_3q9Bzka.js +0 -512
- package/dist/index-_3q9Bzka.js.map +0 -1
- package/dist/index-aeXXzPET.cjs +0 -2
- package/dist/index-aeXXzPET.cjs.map +0 -1
- package/dist/index-glU_Uw7z.js +0 -543
- package/dist/index-glU_Uw7z.js.map +0 -1
- package/dist/index-i0Uz8G2K.js +0 -554
- package/dist/index-i0Uz8G2K.js.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/naming.js +0 -106
- package/dist/src/fieldtype.d.ts +0 -63
- package/dist/src/fieldtype.d.ts.map +0 -1
- package/dist/src/fieldtype.js +0 -106
- package/dist/src/jsonschema.d.ts +0 -95
- package/dist/src/jsonschema.d.ts.map +0 -1
- package/dist/src/schema-field.d.ts +0 -66
- package/dist/src/schema-field.d.ts.map +0 -1
- package/dist/src/schema-field.js +0 -0
- package/dist/src/tsdoc-metadata.json +0 -11
- package/dist/validation.js +0 -60
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"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Minimal field shape representing the intersection of form field properties
|
|
3
|
-
* (fieldname, hidden, etc.) and table column properties (cellComponent, pinned, format, etc.)
|
|
4
|
-
* so that a doctype's fields array can be passed directly to table components without
|
|
5
|
-
* requiring callers to pre-build TableColumn objects.
|
|
6
|
-
*
|
|
7
|
-
* Notes on specific properties:
|
|
8
|
-
* - `align` uses an explicit string union rather than CanvasTextAlign — this
|
|
9
|
-
* package is used server-side by the CLI where browser DOM types are absent.
|
|
10
|
-
* - `format` is a serialized function string; the table store's getFormattedValue
|
|
11
|
-
* already handles typeof format === 'string' via Function(...).
|
|
12
|
-
* - `mask` is intentionally omitted — ACell has mask commented out as a TODO
|
|
13
|
-
* and TableColumn.mask is function-typed only; including it here would create
|
|
14
|
-
* an incompatible type.
|
|
15
|
-
* - `modalComponent` is string-only (no function variant) — functions cannot
|
|
16
|
-
* appear in schema JSON.
|
|
17
|
-
*
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
export interface ColumnSchema {
|
|
21
|
-
/** Unique identifier for the field within its doctype. Maps to `name` on `TableColumn`. */
|
|
22
|
-
fieldname: string;
|
|
23
|
-
/** Semantic field type (e.g. `'Data'`, `'Int'`, `'Date'`, `'Check'`). Fields without a `fieldtype` are treated as non-scalar (nested table/fieldset) and excluded by `schemaToColumns`. */
|
|
24
|
-
fieldtype?: string;
|
|
25
|
-
/** Human-readable column header. */
|
|
26
|
-
label?: string;
|
|
27
|
-
/** When `true`, the field is excluded from the derived columns by `schemaToColumns`. */
|
|
28
|
-
hidden?: boolean;
|
|
29
|
-
/** Horizontal text alignment for the column cell and header. */
|
|
30
|
-
align?: 'left' | 'right' | 'center' | 'start' | 'end';
|
|
31
|
-
/** Whether the column cell is editable in the table. */
|
|
32
|
-
edit?: boolean;
|
|
33
|
-
/** CSS width of the column (e.g. `'20ch'`, `'200px'`). */
|
|
34
|
-
width?: string;
|
|
35
|
-
/** When `true`, the column is pinned to the left side of the table. */
|
|
36
|
-
pinned?: boolean;
|
|
37
|
-
/** When `true`, the column can be resized by dragging the header edge. */
|
|
38
|
-
resizable?: boolean;
|
|
39
|
-
/** When `true`, clicking the column header sorts the table by this column. */
|
|
40
|
-
sortable?: boolean;
|
|
41
|
-
/** When `true`, a filter control is rendered in the column header. */
|
|
42
|
-
filterable?: boolean;
|
|
43
|
-
/** The type of filter control to render. Defaults are derived from `fieldtype` when absent. */
|
|
44
|
-
filterType?: 'text' | 'select' | 'number' | 'date' | 'dateRange' | 'checkbox' | 'component';
|
|
45
|
-
/** Static option list for `filterType: 'select'`. When absent, options are derived from unique row values. */
|
|
46
|
-
filterOptions?: any[];
|
|
47
|
-
/** Registered component name used when `filterType` is `'component'`. */
|
|
48
|
-
filterComponent?: string;
|
|
49
|
-
/** Registered component name rendered inside the table cell instead of the default display. */
|
|
50
|
-
cellComponent?: string;
|
|
51
|
-
/** Props passed to `cellComponent`. */
|
|
52
|
-
cellComponentProps?: Record<string, any>;
|
|
53
|
-
/** Registered component name rendered in the cell's modal editor. String-only — functions cannot appear in schema JSON. */
|
|
54
|
-
modalComponent?: string;
|
|
55
|
-
/** Extra props passed to `modalComponent` in addition to the standard cell props. */
|
|
56
|
-
modalComponentExtraProps?: Record<string, any>;
|
|
57
|
-
/** Serialized function string used to format the cell value for display. Deserialized at render time by the table store's `getFormattedValue`. */
|
|
58
|
-
format?: string;
|
|
59
|
-
/** When `true`, this column is treated as a Gantt bar column. */
|
|
60
|
-
isGantt?: boolean;
|
|
61
|
-
/** Registered component name used to render Gantt bars in this column. */
|
|
62
|
-
ganttComponent?: string;
|
|
63
|
-
/** Number of columns this cell spans in the table layout. */
|
|
64
|
-
colspan?: number;
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=schema-field.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-field.d.ts","sourceRoot":"","sources":["../../src/schema-field.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,YAAY;IAC5B,2FAA2F;IAC3F,SAAS,EAAE,MAAM,CAAA;IACjB,2LAA2L;IAC3L,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,wFAAwF;IACxF,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAA;IACrD,wDAAwD;IACxD,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,uEAAuE;IACvE,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,sEAAsE;IACtE,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,+FAA+F;IAC/F,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,CAAA;IAC3F,8GAA8G;IAC9G,aAAa,CAAC,EAAE,GAAG,EAAE,CAAA;IACrB,yEAAyE;IACzE,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,+FAA+F;IAC/F,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,uCAAuC;IACvC,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACxC,2HAA2H;IAC3H,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,qFAAqF;IACrF,wBAAwB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9C,kJAAkJ;IAClJ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iEAAiE;IACjE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,0EAA0E;IAC1E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB"}
|
package/dist/src/schema-field.js
DELETED
|
File without changes
|
|
@@ -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/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
|
-
}
|