@stonecrop/schema 0.31.0 → 0.33.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/README.md +10 -10
- package/dist/cli.js +194 -121
- package/dist/cli.js.map +1 -1
- package/dist/converter-CLwduvT_.js +2102 -0
- package/dist/converter-CLwduvT_.js.map +1 -0
- package/dist/flatten-Bx2cfvw3.js +37 -0
- package/dist/flatten-Bx2cfvw3.js.map +1 -0
- package/dist/index.js +123 -117
- package/dist/index.js.map +1 -1
- package/dist/record-BQOOi83C.js +134 -0
- package/dist/record-BQOOi83C.js.map +1 -0
- package/dist/record.js +2 -6
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +34 -18
- package/dist/flatten-C1MjkzFh.js +0 -10
- package/dist/flatten-C1MjkzFh.js.map +0 -1
- package/dist/record-Bc0lI9Rq.js +0 -61
- package/dist/record-Bc0lI9Rq.js.map +0 -1
- package/dist/record.js.map +0 -1
- package/dist/schema.tsbuildinfo +0 -1
- package/dist/src/badge.d.ts +0 -74
- package/dist/src/badge.d.ts.map +0 -1
- package/dist/src/badge.js +0 -158
- package/dist/src/cli.d.ts +0 -3
- package/dist/src/cli.d.ts.map +0 -1
- package/dist/src/cli.js +0 -292
- package/dist/src/column-schema.d.ts +0 -163
- package/dist/src/column-schema.d.ts.map +0 -1
- package/dist/src/column-schema.js +0 -0
- package/dist/src/component-meta.d.ts +0 -96
- package/dist/src/component-meta.d.ts.map +0 -1
- package/dist/src/component-meta.js +0 -88
- package/dist/src/converter/aggregate.d.ts +0 -127
- package/dist/src/converter/aggregate.d.ts.map +0 -1
- package/dist/src/converter/aggregate.js +0 -235
- package/dist/src/converter/authored.d.ts +0 -43
- package/dist/src/converter/authored.d.ts.map +0 -1
- package/dist/src/converter/authored.js +0 -52
- package/dist/src/converter/heuristics.d.ts +0 -60
- package/dist/src/converter/heuristics.d.ts.map +0 -1
- package/dist/src/converter/heuristics.js +0 -304
- package/dist/src/converter/index.d.ts +0 -51
- package/dist/src/converter/index.d.ts.map +0 -1
- package/dist/src/converter/index.js +0 -195
- package/dist/src/converter/merge.d.ts +0 -102
- package/dist/src/converter/merge.d.ts.map +0 -1
- package/dist/src/converter/merge.js +0 -136
- package/dist/src/converter/scalars.d.ts +0 -46
- package/dist/src/converter/scalars.d.ts.map +0 -1
- package/dist/src/converter/scalars.js +0 -83
- package/dist/src/converter/types.d.ts +0 -157
- package/dist/src/converter/types.d.ts.map +0 -1
- package/dist/src/converter/types.js +0 -5
- package/dist/src/doctype.d.ts +0 -516
- package/dist/src/doctype.d.ts.map +0 -1
- package/dist/src/doctype.js +0 -343
- package/dist/src/field.d.ts +0 -423
- package/dist/src/field.d.ts.map +0 -1
- package/dist/src/field.js +0 -378
- package/dist/src/flatten.d.ts +0 -29
- package/dist/src/flatten.d.ts.map +0 -1
- package/dist/src/flatten.js +0 -38
- package/dist/src/index.d.ts +0 -16
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -20
- package/dist/src/mode.d.ts +0 -15
- package/dist/src/mode.d.ts.map +0 -1
- package/dist/src/mode.js +0 -0
- package/dist/src/naming.d.ts +0 -80
- package/dist/src/naming.d.ts.map +0 -1
- package/dist/src/naming.js +0 -106
- package/dist/src/record.d.ts +0 -29
- package/dist/src/record.d.ts.map +0 -1
- package/dist/src/record.js +0 -55
- package/dist/src/table.d.ts +0 -33
- package/dist/src/table.d.ts.map +0 -1
- package/dist/src/table.js +0 -25
- package/dist/src/validation.d.ts +0 -54
- package/dist/src/validation.d.ts.map +0 -1
- package/dist/src/validation.js +0 -60
- package/dist/validation-C9P__pRF.js +0 -994
- package/dist/validation-C9P__pRF.js.map +0 -1
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
|
-
}
|
package/dist/src/record.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { DoctypeField } from './field';
|
|
2
|
-
/**
|
|
3
|
-
* Reduce a record's *inline* link values to the ids that get persisted.
|
|
4
|
-
*
|
|
5
|
-
* The adapter returns an inline link as `{ id, displayText }`, so that is what a record holds
|
|
6
|
-
* everywhere it is read — the store, a list row, a form field. A column takes the id alone, so
|
|
7
|
-
* this is the single definition of the shape a record leaves in, and it belongs at the boundary
|
|
8
|
-
* a record crosses on its way to the server, never on the way into the store.
|
|
9
|
-
*
|
|
10
|
-
* Doing it on the way in destroys the text the adapter looked up: nothing else holds it, so the
|
|
11
|
-
* field that resolved a moment ago renders its raw id, and the same record then renders
|
|
12
|
-
* differently depending on whether anything had edited the form yet. That is the bug this exists
|
|
13
|
-
* to prevent, and its damage is a wrong render, not a throw.
|
|
14
|
-
*
|
|
15
|
-
* Only *inline* links may be reduced. An inline link's value is indistinguishable by inspection
|
|
16
|
-
* from an expanded one (`{ id, ...the whole target record }`), so `component` — which states
|
|
17
|
-
* which of the two a field is — is what tells them apart, via {@link componentLinkExpansion}.
|
|
18
|
-
* Reducing an expanded link would send the id in place of the record.
|
|
19
|
-
*
|
|
20
|
-
* Fieldsets are descended into in both shapes a record appears in: flat, as the store and the
|
|
21
|
-
* server hold it, and nested under the fieldset's own key, as a form emits it.
|
|
22
|
-
*
|
|
23
|
-
* @param fields - the doctype's top-level fields
|
|
24
|
-
* @param record - the record to reduce; not mutated
|
|
25
|
-
* @returns a shallow copy with every inline link reduced to its id
|
|
26
|
-
* @public
|
|
27
|
-
*/
|
|
28
|
-
export declare function unwrapInlineLinks(fields: readonly DoctypeField[], record: Record<string, any>): Record<string, any>;
|
|
29
|
-
//# sourceMappingURL=record.d.ts.map
|
package/dist/src/record.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/record.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAG3C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAWnH"}
|
package/dist/src/record.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { componentLinkExpansion } from './component-meta';
|
|
2
|
-
import { flattenFields } from './flatten';
|
|
3
|
-
/**
|
|
4
|
-
* Reduce a record's *inline* link values to the ids that get persisted.
|
|
5
|
-
*
|
|
6
|
-
* The adapter returns an inline link as `{ id, displayText }`, so that is what a record holds
|
|
7
|
-
* everywhere it is read — the store, a list row, a form field. A column takes the id alone, so
|
|
8
|
-
* this is the single definition of the shape a record leaves in, and it belongs at the boundary
|
|
9
|
-
* a record crosses on its way to the server, never on the way into the store.
|
|
10
|
-
*
|
|
11
|
-
* Doing it on the way in destroys the text the adapter looked up: nothing else holds it, so the
|
|
12
|
-
* field that resolved a moment ago renders its raw id, and the same record then renders
|
|
13
|
-
* differently depending on whether anything had edited the form yet. That is the bug this exists
|
|
14
|
-
* to prevent, and its damage is a wrong render, not a throw.
|
|
15
|
-
*
|
|
16
|
-
* Only *inline* links may be reduced. An inline link's value is indistinguishable by inspection
|
|
17
|
-
* from an expanded one (`{ id, ...the whole target record }`), so `component` — which states
|
|
18
|
-
* which of the two a field is — is what tells them apart, via {@link componentLinkExpansion}.
|
|
19
|
-
* Reducing an expanded link would send the id in place of the record.
|
|
20
|
-
*
|
|
21
|
-
* Fieldsets are descended into in both shapes a record appears in: flat, as the store and the
|
|
22
|
-
* server hold it, and nested under the fieldset's own key, as a form emits it.
|
|
23
|
-
*
|
|
24
|
-
* @param fields - the doctype's top-level fields
|
|
25
|
-
* @param record - the record to reduce; not mutated
|
|
26
|
-
* @returns a shallow copy with every inline link reduced to its id
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
|
-
export function unwrapInlineLinks(fields, record) {
|
|
30
|
-
const inline = new Set(flattenFields(fields)
|
|
31
|
-
.filter(field => field.kind === 'field' && Boolean(field.doctype))
|
|
32
|
-
.filter(field => componentLinkExpansion(field.component) === 'inline')
|
|
33
|
-
.map(field => field.fieldname));
|
|
34
|
-
if (inline.size === 0)
|
|
35
|
-
return record;
|
|
36
|
-
const fieldsets = new Set(fields.filter(field => field.kind === 'fieldset').map(field => field.fieldname));
|
|
37
|
-
return unwrapWith(inline, fieldsets, record);
|
|
38
|
-
}
|
|
39
|
-
function unwrapWith(inline, fieldsets, record) {
|
|
40
|
-
const result = { ...record };
|
|
41
|
-
for (const [key, value] of Object.entries(result)) {
|
|
42
|
-
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
43
|
-
continue;
|
|
44
|
-
if (inline.has(key)) {
|
|
45
|
-
// `'id' in value` rather than a truthiness test: an inline link that was never resolved
|
|
46
|
-
// is still a bare scalar, and reducing it a second time would be a no-op at best.
|
|
47
|
-
if ('id' in value)
|
|
48
|
-
result[key] = value.id;
|
|
49
|
-
}
|
|
50
|
-
else if (fieldsets.has(key)) {
|
|
51
|
-
result[key] = unwrapWith(inline, fieldsets, value);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return result;
|
|
55
|
-
}
|
package/dist/src/table.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
/**
|
|
3
|
-
* JSON-safe view configuration for table fields in doctype authoring.
|
|
4
|
-
*
|
|
5
|
-
* This is the authoring-time subset of `@stonecrop/atable`'s `TableConfig`. It covers
|
|
6
|
-
* the view discriminator and structural options that can be expressed in static JSON.
|
|
7
|
-
* `rowActions` (which requires function-typed handlers) stays in the runtime `TableConfig`.
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export declare const TableViewConfig: z.ZodObject<{
|
|
12
|
-
view: z.ZodOptional<z.ZodEnum<{
|
|
13
|
-
list: "list";
|
|
14
|
-
uncounted: "uncounted";
|
|
15
|
-
"list-expansion": "list-expansion";
|
|
16
|
-
tree: "tree";
|
|
17
|
-
gantt: "gantt";
|
|
18
|
-
"tree-gantt": "tree-gantt";
|
|
19
|
-
}>>;
|
|
20
|
-
fullWidth: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
-
defaultTreeExpansion: z.ZodOptional<z.ZodEnum<{
|
|
22
|
-
root: "root";
|
|
23
|
-
branch: "branch";
|
|
24
|
-
leaf: "leaf";
|
|
25
|
-
}>>;
|
|
26
|
-
dependencyGraph: z.ZodOptional<z.ZodBoolean>;
|
|
27
|
-
}, z.core.$strip>;
|
|
28
|
-
/**
|
|
29
|
-
* Table view configuration type inferred from Zod schema
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
export type TableViewConfig = z.infer<typeof TableViewConfig>;
|
|
33
|
-
//# sourceMappingURL=table.d.ts.map
|
package/dist/src/table.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;iBAiBzB,CAAA;AAEH;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA"}
|
package/dist/src/table.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
/**
|
|
3
|
-
* JSON-safe view configuration for table fields in doctype authoring.
|
|
4
|
-
*
|
|
5
|
-
* This is the authoring-time subset of `@stonecrop/atable`'s `TableConfig`. It covers
|
|
6
|
-
* the view discriminator and structural options that can be expressed in static JSON.
|
|
7
|
-
* `rowActions` (which requires function-typed handlers) stays in the runtime `TableConfig`.
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export const TableViewConfig = z
|
|
12
|
-
.object({
|
|
13
|
-
/** The table view type */
|
|
14
|
-
view: z.enum(['list', 'uncounted', 'list-expansion', 'tree', 'gantt', 'tree-gantt']).optional(),
|
|
15
|
-
/** Allow the table to use the full width of its container */
|
|
16
|
-
fullWidth: z.boolean().optional(),
|
|
17
|
-
/** Default expansion state for tree views */
|
|
18
|
-
defaultTreeExpansion: z.enum(['root', 'branch', 'leaf']).optional(),
|
|
19
|
-
/** Enable dependency graph connections for Gantt views */
|
|
20
|
-
dependencyGraph: z.boolean().optional(),
|
|
21
|
-
})
|
|
22
|
-
.meta({
|
|
23
|
-
title: 'TableViewConfig',
|
|
24
|
-
description: 'JSON-safe view configuration for table fields in doctype authoring',
|
|
25
|
-
});
|
package/dist/src/validation.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { DoctypeMeta } from './doctype';
|
|
2
|
-
/**
|
|
3
|
-
* Validation error with path information
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export interface ValidationError {
|
|
7
|
-
/** Path to the invalid property */
|
|
8
|
-
path: PropertyKey[];
|
|
9
|
-
/** Error message */
|
|
10
|
-
message: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Result of a validation operation
|
|
14
|
-
* @public
|
|
15
|
-
*/
|
|
16
|
-
export interface ValidationResult {
|
|
17
|
-
/** Whether validation passed */
|
|
18
|
-
success: boolean;
|
|
19
|
-
/** List of validation errors (empty if success) */
|
|
20
|
-
errors: ValidationError[];
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Validate a field definition against the DoctypeField discriminated union
|
|
24
|
-
* @param data - Data to validate
|
|
25
|
-
* @returns Validation result
|
|
26
|
-
* @public
|
|
27
|
-
*/
|
|
28
|
-
export declare function validateField(data: unknown): ValidationResult;
|
|
29
|
-
/**
|
|
30
|
-
* Validate a doctype definition
|
|
31
|
-
* @param data - Data to validate
|
|
32
|
-
* @returns Validation result
|
|
33
|
-
* @public
|
|
34
|
-
*/
|
|
35
|
-
export declare function validateDoctype(data: unknown): ValidationResult;
|
|
36
|
-
/**
|
|
37
|
-
* Parse and validate a field, throwing on failure
|
|
38
|
-
* @param data - Data to parse
|
|
39
|
-
* @returns Validated DoctypeField
|
|
40
|
-
* @throws ZodError if validation fails
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
export declare function parseField(data: unknown): import('./field').DoctypeField;
|
|
44
|
-
/**
|
|
45
|
-
* Parse and validate a doctype, throwing on failure
|
|
46
|
-
* @param data - Data to parse
|
|
47
|
-
* @returns Validated DoctypeMeta
|
|
48
|
-
* @throws ZodError if validation fails
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
|
-
export declare function parseDoctype(data: unknown): DoctypeMeta;
|
|
52
|
-
export type { DoctypeField, ValueField, FieldsetField, TableField } from './field';
|
|
53
|
-
export type { DoctypeMeta } from './doctype';
|
|
54
|
-
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,mCAAmC;IACnC,IAAI,EAAE,WAAW,EAAE,CAAA;IAEnB,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,OAAO,SAAS,EAAE,YAAY,CAExE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,CAEvD;AAGD,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAClF,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/src/validation.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { DoctypeFieldSchema } from './field';
|
|
2
|
-
import { DoctypeMeta } from './doctype';
|
|
3
|
-
/**
|
|
4
|
-
* Validate a field definition against the DoctypeField discriminated union
|
|
5
|
-
* @param data - Data to validate
|
|
6
|
-
* @returns Validation result
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export function validateField(data) {
|
|
10
|
-
const result = DoctypeFieldSchema.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 DoctypeField
|
|
45
|
-
* @throws ZodError if validation fails
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
48
|
-
export function parseField(data) {
|
|
49
|
-
return DoctypeFieldSchema.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
|
-
}
|