@builder-builder/builder 0.0.1
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 +38 -0
- package/dist/assert/assert.d.ts +28 -0
- package/dist/assert/assert.js +28 -0
- package/dist/assert/expectation.d.ts +20 -0
- package/dist/assert/expectation.js +21 -0
- package/dist/assert/index.d.ts +3 -0
- package/dist/assert/index.js +2 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.js +1 -0
- package/dist/core/builder.d.ts +61 -0
- package/dist/core/builder.js +72 -0
- package/dist/core/collection/collection.d.ts +33 -0
- package/dist/core/collection/collection.js +55 -0
- package/dist/core/collection/index.d.ts +4 -0
- package/dist/core/collection/index.js +2 -0
- package/dist/core/collection/method.d.ts +51 -0
- package/dist/core/collection/method.js +11 -0
- package/dist/core/component/component.d.ts +14 -0
- package/dist/core/component/component.js +17 -0
- package/dist/core/component/graph.d.ts +13 -0
- package/dist/core/component/graph.js +52 -0
- package/dist/core/component/index.d.ts +4 -0
- package/dist/core/component/index.js +2 -0
- package/dist/core/component/method.d.ts +13 -0
- package/dist/core/component/method.js +1 -0
- package/dist/core/graph.d.ts +8 -0
- package/dist/core/graph.js +1 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.js +4 -0
- package/dist/core/option/graph.d.ts +11 -0
- package/dist/core/option/graph.js +78 -0
- package/dist/core/option/index.d.ts +9 -0
- package/dist/core/option/index.js +5 -0
- package/dist/core/option/method.d.ts +52 -0
- package/dist/core/option/method.js +9 -0
- package/dist/core/option/option.d.ts +22 -0
- package/dist/core/option/option.js +49 -0
- package/dist/core/option/select.d.ts +17 -0
- package/dist/core/option/select.js +30 -0
- package/dist/core/option/toggle.d.ts +14 -0
- package/dist/core/option/toggle.js +27 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +6 -0
- package/dist/invariant.d.ts +1 -0
- package/dist/invariant.js +6 -0
- package/dist/paths.d.ts +14 -0
- package/dist/paths.js +8 -0
- package/dist/prettify.d.ts +3 -0
- package/dist/prettify.js +1 -0
- package/dist/resolve/index.d.ts +9 -0
- package/dist/resolve/index.js +5 -0
- package/dist/resolve/instance.d.ts +3 -0
- package/dist/resolve/instance.js +26 -0
- package/dist/resolve/models.d.ts +3 -0
- package/dist/resolve/models.js +10 -0
- package/dist/resolve/order.d.ts +18 -0
- package/dist/resolve/order.js +24 -0
- package/dist/resolve/render.d.ts +21 -0
- package/dist/resolve/render.js +182 -0
- package/dist/resolve/validate.d.ts +32 -0
- package/dist/resolve/validate.js +50 -0
- package/dist/schemas/description.d.ts +5 -0
- package/dist/schemas/description.js +3 -0
- package/dist/schemas/index.d.ts +10 -0
- package/dist/schemas/index.js +5 -0
- package/dist/schemas/layout.d.ts +52 -0
- package/dist/schemas/layout.js +6 -0
- package/dist/schemas/primitives.d.ts +9 -0
- package/dist/schemas/primitives.js +5 -0
- package/dist/schemas/serialise.d.ts +1077 -0
- package/dist/schemas/serialise.js +141 -0
- package/dist/schemas/ui.d.ts +96 -0
- package/dist/schemas/ui.js +23 -0
- package/dist/serialise/deserialise.d.ts +9 -0
- package/dist/serialise/deserialise.js +108 -0
- package/dist/serialise/index.d.ts +4 -0
- package/dist/serialise/index.js +3 -0
- package/dist/serialise/serialise.d.ts +10 -0
- package/dist/serialise/serialise.js +123 -0
- package/dist/ui.d.ts +18 -0
- package/dist/ui.js +35 -0
- package/package.json +70 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { resolveCollectionModels } from '../core/index.js';
|
|
3
|
+
import { readPath } from '../paths.js';
|
|
4
|
+
import { BuilderUI } from '../ui.js';
|
|
5
|
+
export function render(rootBuilder, rootModel, input) {
|
|
6
|
+
const items = v.is(v.instance(BuilderUI), input) ? input.items : input;
|
|
7
|
+
function walk(builder, model, collectionPath, labelContext, items) {
|
|
8
|
+
function composeLabel(label) {
|
|
9
|
+
if (labelContext.length === 0) {
|
|
10
|
+
return label;
|
|
11
|
+
}
|
|
12
|
+
const prefix = labelContext.join(', ');
|
|
13
|
+
if (label == null) {
|
|
14
|
+
return prefix;
|
|
15
|
+
}
|
|
16
|
+
return `${prefix}, ${label}`;
|
|
17
|
+
}
|
|
18
|
+
const layout = [];
|
|
19
|
+
const description = [];
|
|
20
|
+
items.forEach((item) => {
|
|
21
|
+
if (item.type === 'collection') {
|
|
22
|
+
const collection = findCollection(builder, model, item.name);
|
|
23
|
+
if (!collection) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const models = resolveCollectionModels(model, collection.name);
|
|
27
|
+
models.forEach((collectionModel, itemIndex) => {
|
|
28
|
+
const child = walk(collection.builder, collectionModel, [...collectionPath, item.name, itemIndex], [...labelContext, `${ordinal(itemIndex)} ${item.label}`], item.items);
|
|
29
|
+
layout.push(...child.layout);
|
|
30
|
+
description.push(...child.description);
|
|
31
|
+
});
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (item.type === 'page') {
|
|
35
|
+
const resolvedOptions = item.paths.flatMap((path) => {
|
|
36
|
+
const option = resolvePageOption(builder, model, path);
|
|
37
|
+
if (!option) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
const fullPath = [...collectionPath, ...path];
|
|
41
|
+
return [
|
|
42
|
+
{
|
|
43
|
+
option,
|
|
44
|
+
value: readPath(model, fullPath),
|
|
45
|
+
update: (updateModel, updateValue) => setPath(updateModel, fullPath, updateValue)
|
|
46
|
+
}
|
|
47
|
+
];
|
|
48
|
+
});
|
|
49
|
+
if (resolvedOptions.length === 0) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
layout.push({
|
|
53
|
+
label: composeLabel(item.label),
|
|
54
|
+
options: resolvedOptions
|
|
55
|
+
});
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (item.type === 'describe') {
|
|
59
|
+
const composedLabel = composeLabel(item.label);
|
|
60
|
+
if (composedLabel == null) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const values = item.paths.flatMap((path) => {
|
|
64
|
+
const value = resolveOptionValue(builder, model, path);
|
|
65
|
+
if (value === MISSING || value == null) {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
return [value];
|
|
69
|
+
});
|
|
70
|
+
if (values.length === 0) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
description.push([composedLabel, values.join(' ')]);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return { layout, description };
|
|
77
|
+
}
|
|
78
|
+
return walk(rootBuilder, rootModel, [], [], items);
|
|
79
|
+
}
|
|
80
|
+
export function ordinal(index) {
|
|
81
|
+
return ordinals[index] ?? `${index + 1}`;
|
|
82
|
+
}
|
|
83
|
+
const MISSING = {};
|
|
84
|
+
function resolvePageOption(builder, model, path) {
|
|
85
|
+
const optionName = path[path.length - 1];
|
|
86
|
+
const prefix = path.slice(0, -1);
|
|
87
|
+
let currentBuilder = builder;
|
|
88
|
+
let currentModel = model;
|
|
89
|
+
for (let pathIndex = 0; pathIndex < prefix.length; pathIndex += 2) {
|
|
90
|
+
if (!currentModel) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
const collection = findCollection(currentBuilder, currentModel, prefix[pathIndex]);
|
|
94
|
+
if (!collection) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
currentBuilder = collection.builder;
|
|
98
|
+
const collectionModels = resolveCollectionModels(model, collection.name);
|
|
99
|
+
currentModel = collectionModels[prefix[pathIndex + 1]];
|
|
100
|
+
}
|
|
101
|
+
if (!currentModel) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
return currentBuilder.options.reduce((found, entry) => {
|
|
105
|
+
if (found) {
|
|
106
|
+
return found;
|
|
107
|
+
}
|
|
108
|
+
const resolved = entry.resolve(currentModel);
|
|
109
|
+
return resolved?.name === optionName ? resolved : null;
|
|
110
|
+
}, null);
|
|
111
|
+
}
|
|
112
|
+
function resolveOptionValue(builder, model, path) {
|
|
113
|
+
const optionName = path[path.length - 1];
|
|
114
|
+
const prefix = path.slice(0, -1);
|
|
115
|
+
let currentBuilder = builder;
|
|
116
|
+
let currentModel = model;
|
|
117
|
+
for (let pathIndex = 0; pathIndex < prefix.length; pathIndex += 2) {
|
|
118
|
+
if (!currentModel) {
|
|
119
|
+
return MISSING;
|
|
120
|
+
}
|
|
121
|
+
const collection = findCollection(currentBuilder, currentModel, prefix[pathIndex]);
|
|
122
|
+
if (!collection) {
|
|
123
|
+
return MISSING;
|
|
124
|
+
}
|
|
125
|
+
currentBuilder = collection.builder;
|
|
126
|
+
const collectionModels = resolveCollectionModels(model, collection.name);
|
|
127
|
+
currentModel = collectionModels[prefix[pathIndex + 1]];
|
|
128
|
+
}
|
|
129
|
+
if (!currentModel) {
|
|
130
|
+
return MISSING;
|
|
131
|
+
}
|
|
132
|
+
let found = false;
|
|
133
|
+
currentBuilder.options.forEach((entry) => {
|
|
134
|
+
const option = entry.resolve(currentModel);
|
|
135
|
+
if (option && option.name === optionName) {
|
|
136
|
+
found = true;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
if (!found) {
|
|
140
|
+
return MISSING;
|
|
141
|
+
}
|
|
142
|
+
return currentModel[optionName];
|
|
143
|
+
}
|
|
144
|
+
function findCollection(builder, model, collectionName) {
|
|
145
|
+
return builder.collections.reduce((found, entry) => {
|
|
146
|
+
if (found) {
|
|
147
|
+
return found;
|
|
148
|
+
}
|
|
149
|
+
const collection = entry.resolve(model);
|
|
150
|
+
return collection?.name === collectionName ? collection : null;
|
|
151
|
+
}, null);
|
|
152
|
+
}
|
|
153
|
+
function setPath(container, path, value) {
|
|
154
|
+
const [head, ...tail] = path;
|
|
155
|
+
if (typeof head === 'number') {
|
|
156
|
+
const arrayContainer = container ? container : [];
|
|
157
|
+
arrayContainer[head] = tail.length === 0 ? value : setPath(arrayContainer[head], tail, value);
|
|
158
|
+
return arrayContainer;
|
|
159
|
+
}
|
|
160
|
+
const objectContainer = container ? container : {};
|
|
161
|
+
return {
|
|
162
|
+
...objectContainer,
|
|
163
|
+
[head]: tail.length === 0 ? value : setPath(objectContainer[head], tail, value)
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
const ordinals = [
|
|
167
|
+
'First',
|
|
168
|
+
'Second',
|
|
169
|
+
'Third',
|
|
170
|
+
'Fourth',
|
|
171
|
+
'Fifth',
|
|
172
|
+
'Sixth',
|
|
173
|
+
'Seventh',
|
|
174
|
+
'Eighth',
|
|
175
|
+
'Ninth',
|
|
176
|
+
'Tenth',
|
|
177
|
+
'Eleventh',
|
|
178
|
+
'Twelfth',
|
|
179
|
+
'Thirteenth',
|
|
180
|
+
'Fourteenth',
|
|
181
|
+
'Fifteenth'
|
|
182
|
+
];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { BuilderData, BuilderModel } from '../config';
|
|
2
|
+
import type { BuilderGeneric } from '../core/index';
|
|
3
|
+
declare const validated: unique symbol;
|
|
4
|
+
export type BuilderDataValidated = BuilderData & {
|
|
5
|
+
readonly [validated]: true;
|
|
6
|
+
};
|
|
7
|
+
export type BuilderErrorComponentMissing = {
|
|
8
|
+
readonly type: 'missing-component';
|
|
9
|
+
readonly component: string;
|
|
10
|
+
};
|
|
11
|
+
export type BuilderErrorComponentUnexpected = {
|
|
12
|
+
readonly type: 'unexpected-component';
|
|
13
|
+
readonly component: string;
|
|
14
|
+
};
|
|
15
|
+
export type BuilderErrorVariantMissing = {
|
|
16
|
+
readonly type: 'missing-variant';
|
|
17
|
+
readonly component: string;
|
|
18
|
+
readonly model: BuilderModel;
|
|
19
|
+
};
|
|
20
|
+
export type BuilderErrorVariantInvalid = {
|
|
21
|
+
readonly type: 'invalid-variant';
|
|
22
|
+
readonly component: string;
|
|
23
|
+
readonly model: BuilderModel;
|
|
24
|
+
};
|
|
25
|
+
export type BuilderErrorValidate = BuilderErrorComponentMissing | BuilderErrorComponentUnexpected | BuilderErrorVariantMissing | BuilderErrorVariantInvalid;
|
|
26
|
+
export type BuilderErrorsValidate = ReadonlyArray<BuilderErrorValidate>;
|
|
27
|
+
export type BuilderValidateResult = readonly [BuilderDataValidated, BuilderErrorsValidate];
|
|
28
|
+
export declare function validate(builder: BuilderGeneric, builderModels: BuilderData): BuilderValidateResult;
|
|
29
|
+
export declare namespace validate {
|
|
30
|
+
var strict: (builder: BuilderGeneric, builderModels: BuilderData) => BuilderValidateResult;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { models } from './models.js';
|
|
2
|
+
export function validate(builder, builderModels) {
|
|
3
|
+
const expected = models(builder);
|
|
4
|
+
let errors = [];
|
|
5
|
+
Object.entries(expected).forEach(([component, expectedModels]) => {
|
|
6
|
+
const componentModels = builderModels[component];
|
|
7
|
+
if (!componentModels) {
|
|
8
|
+
errors = [...errors, { type: 'missing-component', component }];
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const expectedKeys = new Map(expectedModels.map((variant) => [sortedKey(variant.model), variant.model]));
|
|
12
|
+
const actualKeys = new Set();
|
|
13
|
+
componentModels.forEach((variant) => {
|
|
14
|
+
const key = sortedKey(variant.model);
|
|
15
|
+
actualKeys.add(key);
|
|
16
|
+
if (!expectedKeys.has(key)) {
|
|
17
|
+
errors = [...errors, { type: 'invalid-variant', component, model: variant.model }];
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
expectedKeys.forEach((model, key) => {
|
|
21
|
+
if (!actualKeys.has(key)) {
|
|
22
|
+
errors = [...errors, { type: 'missing-variant', component, model }];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
Object.keys(builderModels).forEach((component) => {
|
|
27
|
+
if (!expected[component]) {
|
|
28
|
+
errors = [...errors, { type: 'unexpected-component', component }];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return [builderModels, errors];
|
|
32
|
+
}
|
|
33
|
+
validate.strict = function strict(builder, builderModels) {
|
|
34
|
+
const [data, errors] = validate(builder, builderModels);
|
|
35
|
+
if (errors.length > 0) {
|
|
36
|
+
throw new ValidateException(errors);
|
|
37
|
+
}
|
|
38
|
+
return [data, []];
|
|
39
|
+
};
|
|
40
|
+
function sortedKey(model) {
|
|
41
|
+
const entries = Object.entries(model).filter(([, value]) => value != null);
|
|
42
|
+
return JSON.stringify(entries.sort(([keyA], [keyB]) => keyA.localeCompare(keyB)));
|
|
43
|
+
}
|
|
44
|
+
class ValidateException extends Error {
|
|
45
|
+
errors;
|
|
46
|
+
constructor(errors) {
|
|
47
|
+
super(`Builder validation failed with ${String(errors.length)} error(s)`);
|
|
48
|
+
this.errors = errors;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
export declare const BuilderDescriptionItemSchema: v.SchemaWithPipe<readonly [v.TupleSchema<[v.StringSchema<undefined>, v.StringSchema<undefined>], undefined>, v.ReadonlyAction<[string, string]>]>;
|
|
3
|
+
export type BuilderDescriptionItem = v.InferOutput<typeof BuilderDescriptionItemSchema>;
|
|
4
|
+
export declare const BuilderDescriptionSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.TupleSchema<[v.StringSchema<undefined>, v.StringSchema<undefined>], undefined>, v.ReadonlyAction<[string, string]>]>, undefined>, v.ReadonlyAction<(readonly [string, string])[]>]>;
|
|
5
|
+
export type BuilderDescription = v.InferOutput<typeof BuilderDescriptionSchema>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { BuilderDescription, BuilderDescriptionItem } from './description';
|
|
2
|
+
export { BuilderDescriptionItemSchema, BuilderDescriptionSchema } from './description.js';
|
|
3
|
+
export type { BuilderLayout, BuilderLayoutOption, BuilderLayoutOptions, BuilderLayoutPage } from './layout';
|
|
4
|
+
export { BuilderLayoutOptionSchema, BuilderLayoutOptionsSchema, BuilderLayoutPageSchema, BuilderLayoutSchema } from './layout.js';
|
|
5
|
+
export type { BuilderPath, BuilderPaths, BuilderPrimitive, BuilderPrimitives } from './primitives';
|
|
6
|
+
export { BuilderPathSchema, BuilderPathsSchema, BuilderPrimitiveSchema, BuilderPrimitivesSchema } from './primitives.js';
|
|
7
|
+
export type { BuilderCollectionSerialised, BuilderCollectionConfigSerialised, BuilderCollectionEnableConfigSerialised, BuilderCollectionMatchConfigSerialised, BuilderCollectionUnlessConfigSerialised, BuilderCollectionWhenConfigSerialised, BuilderComponentSerialised, BuilderValuesSerialised, BuilderOptionSerialised, BuilderOptionEnableConfigSerialised, BuilderOptionMatchConfigSerialised, BuilderOptionUnlessConfigSerialised, BuilderOptionWhenConfigSerialised, BuilderSerialised, BuilderSelectTypeSerialised, BuilderToggleTypeSerialised, BuilderUISerialised, BuilderUIDescribeSerialised, BuilderUICollectionSerialised, BuilderUIItemSerialised, BuilderUIItemsSerialised, BuilderUIPageSerialised } from './serialise';
|
|
8
|
+
export { BuilderCollectionConfigSerialisedSchema, BuilderCollectionEnableConfigSerialisedSchema, BuilderCollectionMatchConfigSerialisedSchema, BuilderCollectionSerialisedSchema, BuilderCollectionUnlessConfigSerialisedSchema, BuilderCollectionWhenConfigSerialisedSchema, BuilderComponentSerialisedSchema, BuilderValuesSerialisedSchema, BuilderOptionEnableConfigSerialisedSchema, BuilderOptionMatchConfigSerialisedSchema, BuilderOptionSerialisedSchema, BuilderOptionUnlessConfigSerialisedSchema, BuilderOptionWhenConfigSerialisedSchema, BuilderSerialisedSchema, BuilderSelectTypeSerialisedSchema, BuilderToggleTypeSerialisedSchema, BuilderUIDescribeSerialisedSchema, BuilderUICollectionSerialisedSchema, BuilderUIItemSerialisedSchema, BuilderUIItemsSerialisedSchema, BuilderUIPageSerialisedSchema } from './serialise.js';
|
|
9
|
+
export type { BuilderUIDescribe, BuilderUICollection, BuilderUIItem, BuilderUIItems, BuilderUIPage } from './ui';
|
|
10
|
+
export { BuilderUIDescribeSchema, BuilderUICollectionSchema, BuilderUIItemSchema, BuilderUIItemsSchema, BuilderUIPageSchema } from './ui.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { BuilderDescriptionItemSchema, BuilderDescriptionSchema } from './description.js';
|
|
2
|
+
export { BuilderLayoutOptionSchema, BuilderLayoutOptionsSchema, BuilderLayoutPageSchema, BuilderLayoutSchema } from './layout.js';
|
|
3
|
+
export { BuilderPathSchema, BuilderPathsSchema, BuilderPrimitiveSchema, BuilderPrimitivesSchema } from './primitives.js';
|
|
4
|
+
export { BuilderCollectionConfigSerialisedSchema, BuilderCollectionEnableConfigSerialisedSchema, BuilderCollectionMatchConfigSerialisedSchema, BuilderCollectionSerialisedSchema, BuilderCollectionUnlessConfigSerialisedSchema, BuilderCollectionWhenConfigSerialisedSchema, BuilderComponentSerialisedSchema, BuilderValuesSerialisedSchema, BuilderOptionEnableConfigSerialisedSchema, BuilderOptionMatchConfigSerialisedSchema, BuilderOptionSerialisedSchema, BuilderOptionUnlessConfigSerialisedSchema, BuilderOptionWhenConfigSerialisedSchema, BuilderSerialisedSchema, BuilderSelectTypeSerialisedSchema, BuilderToggleTypeSerialisedSchema, BuilderUIDescribeSerialisedSchema, BuilderUICollectionSerialisedSchema, BuilderUIItemSerialisedSchema, BuilderUIItemsSerialisedSchema, BuilderUIPageSerialisedSchema } from './serialise.js';
|
|
5
|
+
export { BuilderUIDescribeSchema, BuilderUICollectionSchema, BuilderUIItemSchema, BuilderUIItemsSchema, BuilderUIPageSchema } from './ui.js';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
export declare const BuilderLayoutOptionSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
3
|
+
readonly path: v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>;
|
|
4
|
+
}, undefined>, v.ReadonlyAction<{
|
|
5
|
+
readonly path: readonly (string | number)[];
|
|
6
|
+
}>]>;
|
|
7
|
+
export type BuilderLayoutOption = v.InferOutput<typeof BuilderLayoutOptionSchema>;
|
|
8
|
+
export declare const BuilderLayoutOptionsSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
9
|
+
readonly path: v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>;
|
|
10
|
+
}, undefined>, v.ReadonlyAction<{
|
|
11
|
+
readonly path: readonly (string | number)[];
|
|
12
|
+
}>]>, undefined>, v.ReadonlyAction<Readonly<{
|
|
13
|
+
readonly path: readonly (string | number)[];
|
|
14
|
+
}>[]>]>;
|
|
15
|
+
export type BuilderLayoutOptions = v.InferOutput<typeof BuilderLayoutOptionsSchema>;
|
|
16
|
+
export declare const BuilderLayoutPageSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
17
|
+
readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
18
|
+
readonly options: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
19
|
+
readonly path: v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>;
|
|
20
|
+
}, undefined>, v.ReadonlyAction<{
|
|
21
|
+
readonly path: readonly (string | number)[];
|
|
22
|
+
}>]>, undefined>, v.ReadonlyAction<Readonly<{
|
|
23
|
+
readonly path: readonly (string | number)[];
|
|
24
|
+
}>[]>]>;
|
|
25
|
+
}, undefined>, v.ReadonlyAction<{
|
|
26
|
+
label: string | null;
|
|
27
|
+
readonly options: readonly Readonly<{
|
|
28
|
+
readonly path: readonly (string | number)[];
|
|
29
|
+
}>[];
|
|
30
|
+
}>]>;
|
|
31
|
+
export type BuilderLayoutPage = v.InferOutput<typeof BuilderLayoutPageSchema>;
|
|
32
|
+
export declare const BuilderLayoutSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
33
|
+
readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
34
|
+
readonly options: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
35
|
+
readonly path: v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>;
|
|
36
|
+
}, undefined>, v.ReadonlyAction<{
|
|
37
|
+
readonly path: readonly (string | number)[];
|
|
38
|
+
}>]>, undefined>, v.ReadonlyAction<Readonly<{
|
|
39
|
+
readonly path: readonly (string | number)[];
|
|
40
|
+
}>[]>]>;
|
|
41
|
+
}, undefined>, v.ReadonlyAction<{
|
|
42
|
+
label: string | null;
|
|
43
|
+
readonly options: readonly Readonly<{
|
|
44
|
+
readonly path: readonly (string | number)[];
|
|
45
|
+
}>[];
|
|
46
|
+
}>]>, undefined>, v.ReadonlyAction<Readonly<{
|
|
47
|
+
label: string | null;
|
|
48
|
+
readonly options: readonly Readonly<{
|
|
49
|
+
readonly path: readonly (string | number)[];
|
|
50
|
+
}>[];
|
|
51
|
+
}>[]>]>;
|
|
52
|
+
export type BuilderLayout = v.InferOutput<typeof BuilderLayoutSchema>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { BuilderPathSchema } from './primitives.js';
|
|
3
|
+
export const BuilderLayoutOptionSchema = v.pipe(v.object({ path: BuilderPathSchema }), v.readonly());
|
|
4
|
+
export const BuilderLayoutOptionsSchema = v.pipe(v.array(BuilderLayoutOptionSchema), v.readonly());
|
|
5
|
+
export const BuilderLayoutPageSchema = v.pipe(v.object({ label: v.nullable(v.string()), options: BuilderLayoutOptionsSchema }), v.readonly());
|
|
6
|
+
export const BuilderLayoutSchema = v.pipe(v.array(BuilderLayoutPageSchema), v.readonly());
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
export declare const BuilderPrimitiveSchema: v.NullableSchema<v.UnionSchema<[v.StringSchema<undefined>, v.BooleanSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
|
|
3
|
+
export type BuilderPrimitive = v.InferOutput<typeof BuilderPrimitiveSchema>;
|
|
4
|
+
export declare const BuilderPrimitivesSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.NullableSchema<v.UnionSchema<[v.StringSchema<undefined>, v.BooleanSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, undefined>, v.ReadonlyAction<(string | number | boolean | null)[]>]>;
|
|
5
|
+
export type BuilderPrimitives = v.InferOutput<typeof BuilderPrimitivesSchema>;
|
|
6
|
+
export declare const BuilderPathSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>;
|
|
7
|
+
export type BuilderPath = v.InferOutput<typeof BuilderPathSchema>;
|
|
8
|
+
export declare const BuilderPathsSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>, undefined>, v.ReadonlyAction<(readonly (string | number)[])[]>]>;
|
|
9
|
+
export type BuilderPaths = v.InferOutput<typeof BuilderPathsSchema>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
export const BuilderPrimitiveSchema = v.nullable(v.union([v.string(), v.boolean(), v.number()]));
|
|
3
|
+
export const BuilderPrimitivesSchema = v.pipe(v.array(BuilderPrimitiveSchema), v.readonly());
|
|
4
|
+
export const BuilderPathSchema = v.pipe(v.array(v.union([v.string(), v.number()])), v.readonly());
|
|
5
|
+
export const BuilderPathsSchema = v.pipe(v.array(BuilderPathSchema), v.readonly());
|