@builder-builder/builder 0.0.14 → 0.0.16
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/bb.d.ts +9 -5
- package/dist/bb.js +12 -5
- package/dist/check.d.ts +2 -2
- package/dist/entities/builder/builder.d.ts +19 -5
- package/dist/entities/builder/builder.js +24 -5
- package/dist/entities/builder/index.d.ts +1 -2
- package/dist/entities/builder/index.js +1 -2
- package/dist/entities/collection/collection.d.ts +7 -1
- package/dist/entities/collection/collection.js +9 -2
- package/dist/entities/collection/config.d.ts +6 -1
- package/dist/entities/collection/config.js +9 -2
- package/dist/entities/component/component.d.ts +41 -1
- package/dist/entities/component/component.js +9 -2
- package/dist/entities/component/details.d.ts +11 -2
- package/dist/entities/component/details.js +9 -2
- package/dist/entities/component/field.d.ts +10 -1
- package/dist/entities/component/field.js +13 -3
- package/dist/entities/index.d.ts +5 -1
- package/dist/entities/index.js +2 -0
- package/dist/entities/kind.d.ts +1 -1
- package/dist/entities/model/methods.d.ts +3 -3
- package/dist/entities/model/model.d.ts +5 -1
- package/dist/entities/model/model.js +10 -3
- package/dist/entities/model/models.js +9 -5
- package/dist/entities/option/option.d.ts +41 -1
- package/dist/entities/option/option.js +9 -2
- package/dist/entities/option/select.d.ts +7 -1
- package/dist/entities/option/select.js +17 -6
- package/dist/entities/option/toggle.d.ts +7 -1
- package/dist/entities/option/toggle.js +16 -4
- package/dist/entities/option/values.d.ts +6 -0
- package/dist/entities/pricing/expression.d.ts +70 -0
- package/dist/entities/pricing/expression.js +43 -0
- package/dist/entities/pricing/index.d.ts +6 -0
- package/dist/entities/pricing/index.js +3 -0
- package/dist/entities/pricing/pricing.d.ts +17 -0
- package/dist/entities/pricing/pricing.js +21 -0
- package/dist/entities/pricing/rates.d.ts +3 -0
- package/dist/entities/pricing/rates.js +3 -0
- package/dist/entities/serialise.d.ts +549 -495
- package/dist/entities/serialise.js +65 -41
- package/dist/entities/tags.d.ts +3 -0
- package/dist/entities/tags.js +2 -0
- package/dist/entities/ui/describe.d.ts +10 -1
- package/dist/entities/ui/describe.js +9 -2
- package/dist/entities/ui/input.d.ts +10 -1
- package/dist/entities/ui/input.js +17 -5
- package/dist/entities/ui/page.d.ts +10 -1
- package/dist/entities/ui/page.js +9 -2
- package/dist/entities/ui/pages.d.ts +5 -1
- package/dist/entities/ui/pages.js +9 -2
- package/dist/entities/ui/ui.d.ts +6 -1
- package/dist/entities/ui/ui.js +27 -12
- package/dist/entities/validated.d.ts +3 -1
- package/dist/environment.d.ts +1 -1
- package/dist/exception.d.ts +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/instance.d.ts +9 -0
- package/dist/instance.js +3 -1
- package/dist/mappers/index.d.ts +3 -2
- package/dist/mappers/index.js +2 -1
- package/dist/mappers/price.d.ts +3 -0
- package/dist/mappers/price.js +111 -0
- package/dist/validate/builder.js +16 -7
- package/dist/validate/errors.d.ts +19 -1
- package/dist/validate/errors.js +15 -0
- package/dist/validate/index.d.ts +3 -1
- package/dist/validate/index.js +1 -0
- package/dist/validate/model.js +5 -62
- package/dist/validate/paths.d.ts +5 -0
- package/dist/validate/paths.js +68 -0
- package/dist/validate/pricing.d.ts +8 -0
- package/dist/validate/pricing.js +127 -0
- package/dist/validate/ui.js +60 -1
- package/dist/validate/variants.js +4 -0
- package/package.json +1 -10
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -53
- package/dist/codegen/index.d.ts +0 -7
- package/dist/codegen/index.js +0 -212
- package/dist/codegen/template.d.ts +0 -5
- package/dist/codegen/template.js +0 -17
- package/dist/entities/builder/factory.d.ts +0 -7
- package/dist/entities/builder/factory.js +0 -4
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
import { paramable } from '../../references.js';
|
|
3
3
|
import { serialisable } from '../../serialisable.js';
|
|
4
|
+
import { BuilderTagsSchema } from '../tags.js';
|
|
4
5
|
import { BuilderComponentFieldsSerialisedSchema } from './field.js';
|
|
5
6
|
export class BuilderComponentDetails {
|
|
6
7
|
fields;
|
|
7
|
-
|
|
8
|
+
tags;
|
|
9
|
+
constructor(fields, tags) {
|
|
8
10
|
this.fields = fields;
|
|
11
|
+
this.tags = tags;
|
|
12
|
+
}
|
|
13
|
+
tag(...tags) {
|
|
14
|
+
return new BuilderComponentDetails(this.fields, tags);
|
|
9
15
|
}
|
|
10
16
|
}
|
|
11
17
|
export const BuilderComponentDetailsSchema = v.instance(BuilderComponentDetails);
|
|
12
18
|
export const BuilderComponentDetailsSerialisedSchema = serialisable(v.object({
|
|
13
|
-
fields: paramable(BuilderComponentFieldsSerialisedSchema)
|
|
19
|
+
fields: paramable(BuilderComponentFieldsSerialisedSchema),
|
|
20
|
+
tags: v.optional(BuilderTagsSchema)
|
|
14
21
|
}));
|
|
15
22
|
export function componentDetails(...fields) {
|
|
16
23
|
return new BuilderComponentDetails(fields);
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import type { BuilderPrimitive } from '../../primitive';
|
|
2
|
+
import type { BuilderTags } from '../tags';
|
|
2
3
|
import * as v from 'valibot';
|
|
3
4
|
export declare const BuilderComponentFieldValueTypeSchema: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
4
5
|
export type BuilderComponentFieldValueType = v.InferOutput<typeof BuilderComponentFieldValueTypeSchema>;
|
|
5
6
|
export declare class BuilderComponentField<const Name extends string = string, const ValueSchema extends v.GenericSchema<BuilderPrimitive> = v.GenericSchema<BuilderPrimitive>> {
|
|
7
|
+
#private;
|
|
6
8
|
readonly value: v.InferOutput<ValueSchema>;
|
|
7
9
|
readonly type: "component-field";
|
|
8
10
|
readonly name: Name;
|
|
9
11
|
readonly valueType: BuilderComponentFieldValueType;
|
|
10
12
|
readonly valueSchema: ValueSchema;
|
|
11
13
|
readonly isOptional: boolean;
|
|
12
|
-
|
|
14
|
+
readonly tags?: BuilderTags;
|
|
15
|
+
constructor(name: Name, valueType: BuilderComponentFieldValueType, optional?: boolean, tags?: BuilderTags);
|
|
13
16
|
optional(): BuilderComponentField<Name, v.NullableSchema<ValueSchema, undefined>>;
|
|
17
|
+
tag(...tags: Array<string>): BuilderComponentField<Name, ValueSchema>;
|
|
14
18
|
}
|
|
15
19
|
export declare function detailString<const Name extends string>(name: Name): BuilderComponentField<Name, v.StringSchema<undefined>>;
|
|
16
20
|
export declare function detailNumber<const Name extends string>(name: Name): BuilderComponentField<Name, v.NumberSchema<undefined>>;
|
|
@@ -23,11 +27,13 @@ export declare const BuilderComponentFieldSerialisedSchema: v.SchemaWithPipe<rea
|
|
|
23
27
|
readonly name: v.StringSchema<undefined>;
|
|
24
28
|
readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
25
29
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
30
|
+
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
26
31
|
}, undefined>, v.ReadonlyAction<{
|
|
27
32
|
type: "component-field";
|
|
28
33
|
name: string;
|
|
29
34
|
valueType: "string" | "number" | "boolean";
|
|
30
35
|
isOptional: boolean;
|
|
36
|
+
tags?: readonly string[] | undefined;
|
|
31
37
|
}>]>;
|
|
32
38
|
export type BuilderComponentFieldSerialised = v.InferOutput<typeof BuilderComponentFieldSerialisedSchema>;
|
|
33
39
|
export declare const BuilderComponentFieldsSerialisedSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
@@ -35,16 +41,19 @@ export declare const BuilderComponentFieldsSerialisedSchema: v.SchemaWithPipe<re
|
|
|
35
41
|
readonly name: v.StringSchema<undefined>;
|
|
36
42
|
readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
37
43
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
44
|
+
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
38
45
|
}, undefined>, v.ReadonlyAction<{
|
|
39
46
|
type: "component-field";
|
|
40
47
|
name: string;
|
|
41
48
|
valueType: "string" | "number" | "boolean";
|
|
42
49
|
isOptional: boolean;
|
|
50
|
+
tags?: readonly string[] | undefined;
|
|
43
51
|
}>]>, undefined>, v.ReadonlyAction<Readonly<{
|
|
44
52
|
type: "component-field";
|
|
45
53
|
name: string;
|
|
46
54
|
valueType: "string" | "number" | "boolean";
|
|
47
55
|
isOptional: boolean;
|
|
56
|
+
tags?: readonly string[] | undefined;
|
|
48
57
|
}>[]>]>;
|
|
49
58
|
export type BuilderComponentFieldsSerialised = v.InferOutput<typeof BuilderComponentFieldsSerialisedSchema>;
|
|
50
59
|
export declare function detailValueSchema(valueType: BuilderComponentFieldValueType, optional: boolean): v.GenericSchema<BuilderPrimitive>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
import { serialisable } from '../../serialisable.js';
|
|
3
|
+
import { BuilderTagsSchema } from '../tags.js';
|
|
3
4
|
export const BuilderComponentFieldValueTypeSchema = v.picklist(['string', 'boolean', 'number']);
|
|
4
5
|
export class BuilderComponentField {
|
|
5
6
|
type = 'component-field';
|
|
@@ -7,14 +8,22 @@ export class BuilderComponentField {
|
|
|
7
8
|
valueType;
|
|
8
9
|
valueSchema;
|
|
9
10
|
isOptional;
|
|
10
|
-
|
|
11
|
+
tags;
|
|
12
|
+
constructor(name, valueType, optional = false, tags) {
|
|
11
13
|
this.name = name;
|
|
12
14
|
this.valueType = valueType;
|
|
13
15
|
this.valueSchema = detailValueSchema(valueType, optional);
|
|
14
16
|
this.isOptional = optional;
|
|
17
|
+
this.tags = tags;
|
|
18
|
+
}
|
|
19
|
+
#next(patch) {
|
|
20
|
+
return new BuilderComponentField(this.name, this.valueType, patch.optional ?? this.isOptional, patch.tags ?? this.tags);
|
|
15
21
|
}
|
|
16
22
|
optional() {
|
|
17
|
-
return
|
|
23
|
+
return this.#next({ optional: true });
|
|
24
|
+
}
|
|
25
|
+
tag(...tags) {
|
|
26
|
+
return this.#next({ tags });
|
|
18
27
|
}
|
|
19
28
|
}
|
|
20
29
|
export function detailString(name) {
|
|
@@ -32,7 +41,8 @@ export const BuilderComponentFieldSerialisedSchema = serialisable(v.object({
|
|
|
32
41
|
type: v.literal('component-field'),
|
|
33
42
|
name: v.string(),
|
|
34
43
|
valueType: BuilderComponentFieldValueTypeSchema,
|
|
35
|
-
isOptional: v.boolean()
|
|
44
|
+
isOptional: v.boolean(),
|
|
45
|
+
tags: v.optional(BuilderTagsSchema)
|
|
36
46
|
}));
|
|
37
47
|
export const BuilderComponentFieldsSerialisedSchema = v.pipe(v.array(BuilderComponentFieldSerialisedSchema), v.readonly());
|
|
38
48
|
export function detailValueSchema(valueType, optional) {
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -7,14 +7,18 @@ export type { BuilderModelEntrySerialised } from './entry';
|
|
|
7
7
|
export type { BuilderInstanceOf, BuilderModelGeneric, BuilderModels, BuilderModelSerialised, BuilderModelState, BuilderModelStateEmpty, BuilderModelStateOf } from './model/index';
|
|
8
8
|
export { BuilderModel, BuilderModelSchema, BuilderModelSerialisedSchema, model, modelsMerge } from './model/index.js';
|
|
9
9
|
export type { BuilderOptionPayload, BuilderOptions, BuilderOptionSerialised, BuilderOptionsSerialised, BuilderOptionValues, BuilderOptionValuesSerialised, BuilderOptionWhen, BuilderOptionWhenSerialised, BuilderSelectTypeLabels, BuilderSelectTypeSerialised, BuilderSelectTypeValues, BuilderToggleTypeSerialised, BuilderToggleValueType } from './option/index';
|
|
10
|
+
export type { BuilderPricingExpression, BuilderPricingLookupKey, BuilderPricingReduce, BuilderPricingSerialised, BuilderRates } from './pricing/index';
|
|
10
11
|
export type { BuilderRefEntities, BuilderRefEntity } from './refs.js';
|
|
12
|
+
export type { BuilderTags } from './tags';
|
|
11
13
|
export type { BuilderDescription, BuilderDescriptionItem, BuilderUIDescribeSerialised, BuilderUIInputMetadata, BuilderUIInputMetadataSerialised, BuilderUIInputs, BuilderUIInputsSerialised, BuilderUIInputSerialised, BuilderUIItem, BuilderUIItems, BuilderUIItemSerialised, BuilderUIItemsSerialised, BuilderUIPageSerialised, BuilderUIPagesSerialised, BuilderUIs, BuilderUIsSerialised, BuilderUISerialised } from './ui/index';
|
|
12
|
-
export type { BuilderCollectionConfigValidated, BuilderCollectionsValidated, BuilderCollectionValidated, BuilderComponentDetailsValidated, BuilderComponentsValidated, BuilderComponentValidated, BuilderComponentVariantsValidated, BuilderInstancesValidated, BuilderInstanceValidated, BuilderModelValidated, BuilderOptionsValidated, BuilderOptionValidated, BuilderOptionValuesValidated, BuilderUIDescribeValidated, BuilderUIItemsValidated, BuilderUIPageValidated, BuilderUIValidated, BuilderValidated } from './validated';
|
|
14
|
+
export type { BuilderCollectionConfigValidated, BuilderCollectionsValidated, BuilderCollectionValidated, BuilderComponentDetailsValidated, BuilderComponentsValidated, BuilderComponentValidated, BuilderComponentVariantsValidated, BuilderInstancesValidated, BuilderInstanceValidated, BuilderModelValidated, BuilderOptionsValidated, BuilderOptionValidated, BuilderOptionValuesValidated, BuilderPricingValidated, BuilderUIDescribeValidated, BuilderUIItemsValidated, BuilderUIPageValidated, BuilderUIValidated, BuilderValidated } from './validated';
|
|
13
15
|
export type { BuilderEnableConfig, BuilderMatchConfig, BuilderMatchSelectMap, BuilderUnlessConfig, BuilderWhen, BuilderWhenConfig, BuilderWhenSerialised } from './when';
|
|
14
16
|
export { Builder, builder, BuilderSchema, BuilderSerialisedSchema } from './builder/index.js';
|
|
15
17
|
export { BuilderCollection, BuilderCollectionConfig, BuilderCollectionConfigSchema, BuilderCollectionConfigSerialisedSchema, BuilderCollectionSchema, BuilderCollectionSelectMapSerialisedSchema, BuilderCollectionSerialisedSchema, BuilderCollectionsSerialisedSchema, BuilderCollectionWhenSerialisedSchema, collectionConfig, collectionExpectation, collectionWhen } from './collection/index.js';
|
|
16
18
|
export { BuilderComponent, BuilderComponentDetails, BuilderComponentDetailsSchema, BuilderComponentDetailsSerialisedSchema, BuilderComponentField, BuilderComponentFieldSchema, BuilderComponentFieldSerialisedSchema, BuilderComponentFieldsSchema, BuilderComponentFieldsSerialisedSchema, BuilderComponentFieldValueTypeSchema, BuilderComponentSchema, BuilderComponentSelectMapSerialisedSchema, BuilderComponentSerialisedSchema, BuilderComponentsSerialisedSchema, BuilderComponentWhenSerialisedSchema, componentDetails, componentExpectation, componentWhen, detailBoolean, detailNumber, detailString, detailValueSchema } from './component/index.js';
|
|
17
19
|
export { parameter, ref } from '../references.js';
|
|
20
|
+
export { BuilderPricing, BuilderPricingExpressionSchema, BuilderPricingLookupKeySchema, BuilderPricingReduceSchema, BuilderPricingSchema, BuilderPricingSerialisedSchema, BuilderRatesSchema, pricing } from './pricing/index.js';
|
|
21
|
+
export { BuilderTagsSchema } from './tags.js';
|
|
18
22
|
export { BuilderExpectation, BuilderExpectationKindSchema, BuilderExpectationSchema, BuilderExpectationSerialisedSchema, BuilderExpectationsSchema, BuilderExpectationsSerialisedSchema } from './expectation.js';
|
|
19
23
|
export { BuilderEntityKindSchema, BuilderEntitySerialisedSchema } from './kind.js';
|
|
20
24
|
export { BuilderOption, BuilderOptionSchema, BuilderOptionSelectMapSerialisedSchema, BuilderOptionSerialisedSchema, BuilderOptionsSerialisedSchema, BuilderOptionValuesSchema, BuilderOptionValuesSerialisedSchema, BuilderOptionWhenSerialisedSchema, BuilderSelectType, BuilderSelectTypeSchema, BuilderSelectTypeSerialisedSchema, BuilderToggleType, BuilderToggleTypeSchema, BuilderToggleTypeSerialisedSchema, optionExpectation, optionValueSchema, optionWhen, select, toggleBoolean, toggleNumber, toggleString } from './option/index.js';
|
package/dist/entities/index.js
CHANGED
|
@@ -3,6 +3,8 @@ export { Builder, builder, BuilderSchema, BuilderSerialisedSchema } from './buil
|
|
|
3
3
|
export { BuilderCollection, BuilderCollectionConfig, BuilderCollectionConfigSchema, BuilderCollectionConfigSerialisedSchema, BuilderCollectionSchema, BuilderCollectionSelectMapSerialisedSchema, BuilderCollectionSerialisedSchema, BuilderCollectionsSerialisedSchema, BuilderCollectionWhenSerialisedSchema, collectionConfig, collectionExpectation, collectionWhen } from './collection/index.js';
|
|
4
4
|
export { BuilderComponent, BuilderComponentDetails, BuilderComponentDetailsSchema, BuilderComponentDetailsSerialisedSchema, BuilderComponentField, BuilderComponentFieldSchema, BuilderComponentFieldSerialisedSchema, BuilderComponentFieldsSchema, BuilderComponentFieldsSerialisedSchema, BuilderComponentFieldValueTypeSchema, BuilderComponentSchema, BuilderComponentSelectMapSerialisedSchema, BuilderComponentSerialisedSchema, BuilderComponentsSerialisedSchema, BuilderComponentWhenSerialisedSchema, componentDetails, componentExpectation, componentWhen, detailBoolean, detailNumber, detailString, detailValueSchema } from './component/index.js';
|
|
5
5
|
export { parameter, ref } from '../references.js';
|
|
6
|
+
export { BuilderPricing, BuilderPricingExpressionSchema, BuilderPricingLookupKeySchema, BuilderPricingReduceSchema, BuilderPricingSchema, BuilderPricingSerialisedSchema, BuilderRatesSchema, pricing } from './pricing/index.js';
|
|
7
|
+
export { BuilderTagsSchema } from './tags.js';
|
|
6
8
|
export { BuilderExpectation, BuilderExpectationKindSchema, BuilderExpectationSchema, BuilderExpectationSerialisedSchema, BuilderExpectationsSchema, BuilderExpectationsSerialisedSchema } from './expectation.js';
|
|
7
9
|
export { BuilderEntityKindSchema, BuilderEntitySerialisedSchema } from './kind.js';
|
|
8
10
|
export { BuilderOption, BuilderOptionSchema, BuilderOptionSelectMapSerialisedSchema, BuilderOptionSerialisedSchema, BuilderOptionsSerialisedSchema, BuilderOptionValuesSchema, BuilderOptionValuesSerialisedSchema, BuilderOptionWhenSerialisedSchema, BuilderSelectType, BuilderSelectTypeSchema, BuilderSelectTypeSerialisedSchema, BuilderToggleType, BuilderToggleTypeSchema, BuilderToggleTypeSerialisedSchema, optionExpectation, optionValueSchema, optionWhen, select, toggleBoolean, toggleNumber, toggleString } from './option/index.js';
|
package/dist/entities/kind.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { EntitiesMap } from './serialise';
|
|
|
2
2
|
import * as v from 'valibot';
|
|
3
3
|
import { entitiesMap } from './serialise.js';
|
|
4
4
|
export type BuilderEntityKind = keyof typeof entitiesMap;
|
|
5
|
-
export declare const BuilderEntityKindSchema: v.PicklistSchema<readonly ("string" | "number" | "boolean" | "builder" | "model" | "ui" | "select" | "toggle" | "path" | "
|
|
5
|
+
export declare const BuilderEntityKindSchema: v.PicklistSchema<readonly ("string" | "number" | "boolean" | "builder" | "model" | "pricing" | "ui" | "select" | "toggle" | "path" | "optionSelectMap" | "optionWhen" | "componentDetails" | "componentSelectMap" | "componentWhen" | "collectionConfig" | "collectionSelectMap" | "collectionWhen" | "uiDescribe" | "uiItems" | "uiPage" | "uiPages" | "uiInput" | "pricingRates" | "expectations" | "paths")[], undefined>;
|
|
6
6
|
export type BuilderEntitySerialised = {
|
|
7
7
|
[Kind in keyof EntitiesMap]: v.InferOutput<EntitiesMap[Kind]['serialised']>;
|
|
8
8
|
}[keyof EntitiesMap];
|
|
@@ -46,12 +46,12 @@ type CollectionInstanceOf<Collection extends BuilderCollection> = [Collection['p
|
|
|
46
46
|
type CollectionShape<Collection extends BuilderCollection, Item> = Collection['payload'] extends BuilderCollectionConfig ? Collection['payload']['min'] extends number ? Collection['payload']['max'] extends number ? number extends Collection['payload']['min'] ? ReadonlyArray<Item> : number extends Collection['payload']['max'] ? ReadonlyArray<Item> : Collection['payload']['min'] extends Collection['payload']['max'] ? CollectionTuple<Item, Collection['payload']['min']> : ReadonlyArray<Item> : ReadonlyArray<Item> : ReadonlyArray<Item> : ReadonlyArray<Item>;
|
|
47
47
|
type CollectionTuple<Item, Length extends number, Result extends ReadonlyArray<Item> = []> = Result['length'] extends Length ? Result : CollectionTuple<Item, Length, [...Result, Item]>;
|
|
48
48
|
export declare function builderOptionMethod(): ((name: string, payload: Paramable<BuilderOptionValues>) => BuilderOption<string, Paramable<import("..").BuilderSelectType<readonly [string, ...string[]], import("valibot").GenericSchema<string | null>> | import("..").BuilderToggleType<import("valibot").GenericSchema<string | number | boolean | null>>>, Paramable<readonly (readonly (string | number)[])[]>>) & {
|
|
49
|
-
when(paths: Paramable<BuilderPaths>, name: string, payload: Paramable<BuilderOptionWhen>): BuilderOption<string, Paramable<BuilderOptionWhen>, readonly (readonly (string | number)[])[] | import("../..").BuilderRef
|
|
49
|
+
when(paths: Paramable<BuilderPaths>, name: string, payload: Paramable<BuilderOptionWhen>): BuilderOption<string, Paramable<BuilderOptionWhen>, readonly (readonly (string | number)[])[] | BuilderParameter<string> | import("../..").BuilderRef>;
|
|
50
50
|
};
|
|
51
51
|
export declare function builderComponentMethod(): ((name: string, payload?: Paramable<BuilderComponentDetails>) => BuilderComponent<string, Paramable<BuilderComponentDetails<Paramable<readonly import("..").BuilderComponentField<string, import("valibot").GenericSchema<string | number | boolean | null>>[]>>>, Paramable<readonly (readonly (string | number)[])[]>>) & {
|
|
52
|
-
when(paths: Paramable<BuilderPaths>, name: string, payload?: Paramable<BuilderComponentWhen>): BuilderComponent<string, Paramable<BuilderComponentWhen>, readonly (readonly (string | number)[])[] | import("../..").BuilderRef
|
|
52
|
+
when(paths: Paramable<BuilderPaths>, name: string, payload?: Paramable<BuilderComponentWhen>): BuilderComponent<string, Paramable<BuilderComponentWhen>, readonly (readonly (string | number)[])[] | BuilderParameter<string> | import("../..").BuilderRef>;
|
|
53
53
|
};
|
|
54
54
|
export declare function builderCollectionMethod(): ((name: string, payload: Paramable<BuilderCollectionConfig>) => BuilderCollection<string, Paramable<BuilderCollectionConfig<Paramable<import("./model").BuilderModelGeneric>, Paramable<number>, Paramable<number>>>, Paramable<readonly (readonly (string | number)[])[]>>) & {
|
|
55
|
-
when(paths: Paramable<BuilderPaths>, name: string, payload: Paramable<BuilderCollectionWhen>): BuilderCollection<string, Paramable<BuilderCollectionWhen>, readonly (readonly (string | number)[])[] | import("../..").BuilderRef
|
|
55
|
+
when(paths: Paramable<BuilderPaths>, name: string, payload: Paramable<BuilderCollectionWhen>): BuilderCollection<string, Paramable<BuilderCollectionWhen>, readonly (readonly (string | number)[])[] | BuilderParameter<string> | import("../..").BuilderRef>;
|
|
56
56
|
};
|
|
57
57
|
export {};
|
|
@@ -5,6 +5,7 @@ import type { BuilderCollections, BuilderCollectionsSerialised } from '../collec
|
|
|
5
5
|
import type { BuilderComponents, BuilderComponentsSerialised } from '../component/index';
|
|
6
6
|
import type { BuilderExpectation, BuilderExpectations, BuilderExpectationsSerialised } from '../expectation';
|
|
7
7
|
import type { BuilderOptions, BuilderOptionsSerialised } from '../option/index';
|
|
8
|
+
import type { BuilderTags } from '../tags';
|
|
8
9
|
import type { BuilderModelStateAsserted } from './expectation';
|
|
9
10
|
import type { BuilderCollectionMethod, BuilderComponentMethod, BuilderOptionMethod } from './methods';
|
|
10
11
|
import type { BuilderModels, BuilderModelsMerge, BuilderModelsSerialised } from './models';
|
|
@@ -18,7 +19,9 @@ export declare class BuilderModel<State extends BuilderModelState = BuilderModel
|
|
|
18
19
|
readonly components: State['components'];
|
|
19
20
|
readonly collections: State['collections'];
|
|
20
21
|
readonly expectations: BuilderExpectations;
|
|
21
|
-
|
|
22
|
+
readonly tags?: BuilderTags;
|
|
23
|
+
constructor(models?: BuilderModels, options?: BuilderOptions, components?: BuilderComponents, collections?: BuilderCollections, expectations?: BuilderExpectations, tags?: BuilderTags);
|
|
24
|
+
tag(...tags: Array<string>): BuilderModel<State>;
|
|
22
25
|
get option(): BuilderOptionMethod<State>;
|
|
23
26
|
get component(): BuilderComponentMethod<State>;
|
|
24
27
|
get collection(): BuilderCollectionMethod<State>;
|
|
@@ -33,6 +36,7 @@ export interface BuilderModelSerialised {
|
|
|
33
36
|
readonly components: BuilderComponentsSerialised;
|
|
34
37
|
readonly collections: BuilderCollectionsSerialised;
|
|
35
38
|
readonly expectations: BuilderExpectationsSerialised;
|
|
39
|
+
readonly tags?: BuilderTags;
|
|
36
40
|
}
|
|
37
41
|
export declare const BuilderModelSerialisedSchema: v.GenericSchema<BuilderModelSerialised>;
|
|
38
42
|
export type BuilderModelStateOf<Input extends Paramable<BuilderModelGeneric>> = Input extends BuilderModel<infer State extends BuilderModelState> ? State : BuilderModelStateEmpty;
|
|
@@ -4,6 +4,7 @@ import { BuilderCollectionsSerialisedSchema } from '../collection/index.js';
|
|
|
4
4
|
import { BuilderComponentsSerialisedSchema } from '../component/index.js';
|
|
5
5
|
import { BuilderExpectationsSerialisedSchema } from '../expectation.js';
|
|
6
6
|
import { BuilderOptionsSerialisedSchema } from '../option/index.js';
|
|
7
|
+
import { BuilderTagsSchema } from '../tags.js';
|
|
7
8
|
import { builderCollectionMethod, builderComponentMethod, builderOptionMethod } from './methods.js';
|
|
8
9
|
import { BuilderModelsSerialisedSchema } from './models.js';
|
|
9
10
|
export class BuilderModel {
|
|
@@ -12,12 +13,17 @@ export class BuilderModel {
|
|
|
12
13
|
components;
|
|
13
14
|
collections;
|
|
14
15
|
expectations;
|
|
15
|
-
|
|
16
|
+
tags;
|
|
17
|
+
constructor(models = [], options = [], components = [], collections = [], expectations = [], tags) {
|
|
16
18
|
this.models = models;
|
|
17
19
|
this.options = options;
|
|
18
20
|
this.components = components;
|
|
19
21
|
this.collections = collections;
|
|
20
22
|
this.expectations = expectations;
|
|
23
|
+
this.tags = tags;
|
|
24
|
+
}
|
|
25
|
+
tag(...tags) {
|
|
26
|
+
return new BuilderModel(this.models, this.options, this.components, this.collections, this.expectations, tags);
|
|
21
27
|
}
|
|
22
28
|
get option() {
|
|
23
29
|
const method = builderOptionMethod();
|
|
@@ -57,7 +63,7 @@ export class BuilderModel {
|
|
|
57
63
|
return this.#next({ expectations: [...this.expectations, ...expectations] });
|
|
58
64
|
}
|
|
59
65
|
#next(patch) {
|
|
60
|
-
return new BuilderModel(this.models, patch.options ?? this.options, patch.components ?? this.components, patch.collections ?? this.collections, patch.expectations ?? this.expectations);
|
|
66
|
+
return new BuilderModel(this.models, patch.options ?? this.options, patch.components ?? this.components, patch.collections ?? this.collections, patch.expectations ?? this.expectations, this.tags);
|
|
61
67
|
}
|
|
62
68
|
}
|
|
63
69
|
export function model(...parts) {
|
|
@@ -69,5 +75,6 @@ export const BuilderModelSerialisedSchema = serialisable(v.object({
|
|
|
69
75
|
options: BuilderOptionsSerialisedSchema,
|
|
70
76
|
components: BuilderComponentsSerialisedSchema,
|
|
71
77
|
collections: BuilderCollectionsSerialisedSchema,
|
|
72
|
-
expectations: BuilderExpectationsSerialisedSchema
|
|
78
|
+
expectations: BuilderExpectationsSerialisedSchema,
|
|
79
|
+
tags: v.optional(BuilderTagsSchema)
|
|
73
80
|
}));
|
|
@@ -3,12 +3,16 @@ import { paramable } from '../../references.js';
|
|
|
3
3
|
import { BuilderModelSerialisedSchema } from './model.js';
|
|
4
4
|
export const BuilderModelsSerialisedSchema = v.pipe(v.array(paramable(v.lazy(() => BuilderModelSerialisedSchema))), v.readonly());
|
|
5
5
|
export function modelsMerge(model) {
|
|
6
|
-
const
|
|
6
|
+
const flat = flattenModels(model);
|
|
7
7
|
return {
|
|
8
8
|
models: [],
|
|
9
|
-
options:
|
|
10
|
-
components:
|
|
11
|
-
collections:
|
|
12
|
-
expectations:
|
|
9
|
+
options: flat.flatMap((entry) => entry.options),
|
|
10
|
+
components: flat.flatMap((entry) => entry.components),
|
|
11
|
+
collections: flat.flatMap((entry) => entry.collections),
|
|
12
|
+
expectations: flat.flatMap((entry) => entry.expectations),
|
|
13
|
+
tags: Array.from(new Set(flat.flatMap((entry) => entry.tags ?? [])))
|
|
13
14
|
};
|
|
14
15
|
}
|
|
16
|
+
function flattenModels(model) {
|
|
17
|
+
return [model, ...model.models.flatMap(flattenModels)];
|
|
18
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BuilderPaths } from '../../paths';
|
|
2
2
|
import type { Paramable } from '../../references';
|
|
3
|
+
import type { BuilderTags } from '../tags';
|
|
3
4
|
import type { BuilderWhenSerialised } from '../when';
|
|
4
5
|
import type { BuilderOptionValues, BuilderOptionValuesSerialised } from './values';
|
|
5
6
|
import type { BuilderOptionWhen } from './when';
|
|
@@ -10,7 +11,9 @@ export declare class BuilderOption<const Name extends string = string, const Pay
|
|
|
10
11
|
readonly name: Name;
|
|
11
12
|
readonly payload: Payload;
|
|
12
13
|
readonly paths?: Paths;
|
|
13
|
-
|
|
14
|
+
readonly tags?: BuilderTags;
|
|
15
|
+
constructor(name: Name, payload: Payload, paths?: Paths, tags?: BuilderTags);
|
|
16
|
+
tag(...tags: Array<string>): BuilderOption<Name, Payload, Paths>;
|
|
14
17
|
}
|
|
15
18
|
export declare const BuilderOptionSchema: v.InstanceSchema<typeof BuilderOption, undefined>;
|
|
16
19
|
export type BuilderOptions = ReadonlyArray<BuilderOption>;
|
|
@@ -22,11 +25,13 @@ export declare const BuilderOptionWhenSerialisedSchema: v.GenericSchema<BuilderW
|
|
|
22
25
|
optionLabels: {
|
|
23
26
|
[x: string]: string;
|
|
24
27
|
};
|
|
28
|
+
tags?: readonly string[] | undefined;
|
|
25
29
|
}>> | Readonly<Readonly<{
|
|
26
30
|
type: "toggle";
|
|
27
31
|
valueType: "string" | "number" | "boolean";
|
|
28
32
|
defaultValue: string | number | boolean | null;
|
|
29
33
|
isOptional: boolean;
|
|
34
|
+
tags?: readonly string[] | undefined;
|
|
30
35
|
}>>>>;
|
|
31
36
|
export type BuilderOptionWhenSerialised = BuilderWhenSerialised<BuilderOptionValuesSerialised>;
|
|
32
37
|
export declare const BuilderOptionSelectMapSerialisedSchema: v.GenericSchema<import("..").BuilderMatchSelectMap<Readonly<{
|
|
@@ -41,11 +46,13 @@ export declare const BuilderOptionSelectMapSerialisedSchema: v.GenericSchema<imp
|
|
|
41
46
|
optionLabels: {
|
|
42
47
|
[x: string]: string;
|
|
43
48
|
};
|
|
49
|
+
tags?: readonly string[] | undefined;
|
|
44
50
|
}>> | Readonly<Readonly<{
|
|
45
51
|
type: "toggle";
|
|
46
52
|
valueType: "string" | "number" | "boolean";
|
|
47
53
|
defaultValue: string | number | boolean | null;
|
|
48
54
|
isOptional: boolean;
|
|
55
|
+
tags?: readonly string[] | undefined;
|
|
49
56
|
}>>>>;
|
|
50
57
|
export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
51
58
|
readonly name: v.StringSchema<undefined>;
|
|
@@ -69,6 +76,7 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
69
76
|
readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
70
77
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
71
78
|
readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
79
|
+
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
72
80
|
}, undefined>, v.ReadonlyAction<{
|
|
73
81
|
type: "select";
|
|
74
82
|
readonly options: readonly [string, ...string[]];
|
|
@@ -77,16 +85,19 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
77
85
|
optionLabels: {
|
|
78
86
|
[x: string]: string;
|
|
79
87
|
};
|
|
88
|
+
tags?: readonly string[] | undefined;
|
|
80
89
|
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
81
90
|
readonly type: v.LiteralSchema<"toggle", undefined>;
|
|
82
91
|
readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
83
92
|
readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
|
|
84
93
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
94
|
+
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
85
95
|
}, undefined>, v.ReadonlyAction<{
|
|
86
96
|
type: "toggle";
|
|
87
97
|
valueType: "string" | "number" | "boolean";
|
|
88
98
|
defaultValue: string | number | boolean | null;
|
|
89
99
|
isOptional: boolean;
|
|
100
|
+
tags?: readonly string[] | undefined;
|
|
90
101
|
}>]>], undefined>, v.ReadonlyAction<Readonly<{
|
|
91
102
|
type: "select";
|
|
92
103
|
readonly options: readonly [string, ...string[]];
|
|
@@ -95,11 +106,13 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
95
106
|
optionLabels: {
|
|
96
107
|
[x: string]: string;
|
|
97
108
|
};
|
|
109
|
+
tags?: readonly string[] | undefined;
|
|
98
110
|
}> | Readonly<{
|
|
99
111
|
type: "toggle";
|
|
100
112
|
valueType: "string" | "number" | "boolean";
|
|
101
113
|
defaultValue: string | number | boolean | null;
|
|
102
114
|
isOptional: boolean;
|
|
115
|
+
tags?: readonly string[] | undefined;
|
|
103
116
|
}>>]>, v.GenericSchema<BuilderWhenSerialised<Readonly<Readonly<{
|
|
104
117
|
type: "select";
|
|
105
118
|
readonly options: readonly [string, ...string[]];
|
|
@@ -108,11 +121,13 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
108
121
|
optionLabels: {
|
|
109
122
|
[x: string]: string;
|
|
110
123
|
};
|
|
124
|
+
tags?: readonly string[] | undefined;
|
|
111
125
|
}>> | Readonly<Readonly<{
|
|
112
126
|
type: "toggle";
|
|
113
127
|
valueType: "string" | "number" | "boolean";
|
|
114
128
|
defaultValue: string | number | boolean | null;
|
|
115
129
|
isOptional: boolean;
|
|
130
|
+
tags?: readonly string[] | undefined;
|
|
116
131
|
}>>>>], undefined>], undefined>;
|
|
117
132
|
readonly paths: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
118
133
|
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
@@ -129,6 +144,7 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
129
144
|
type: "ref";
|
|
130
145
|
id: string;
|
|
131
146
|
}>]>, 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)[])[]>]>], undefined>, undefined>;
|
|
147
|
+
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
132
148
|
}, undefined>, v.ReadonlyAction<{
|
|
133
149
|
name: string;
|
|
134
150
|
payload: Readonly<{
|
|
@@ -146,11 +162,13 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
146
162
|
optionLabels: {
|
|
147
163
|
[x: string]: string;
|
|
148
164
|
};
|
|
165
|
+
tags?: readonly string[] | undefined;
|
|
149
166
|
}>> | Readonly<Readonly<{
|
|
150
167
|
type: "toggle";
|
|
151
168
|
valueType: "string" | "number" | "boolean";
|
|
152
169
|
defaultValue: string | number | boolean | null;
|
|
153
170
|
isOptional: boolean;
|
|
171
|
+
tags?: readonly string[] | undefined;
|
|
154
172
|
}>> | BuilderWhenSerialised<Readonly<Readonly<{
|
|
155
173
|
type: "select";
|
|
156
174
|
readonly options: readonly [string, ...string[]];
|
|
@@ -159,11 +177,13 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
159
177
|
optionLabels: {
|
|
160
178
|
[x: string]: string;
|
|
161
179
|
};
|
|
180
|
+
tags?: readonly string[] | undefined;
|
|
162
181
|
}>> | Readonly<Readonly<{
|
|
163
182
|
type: "toggle";
|
|
164
183
|
valueType: "string" | "number" | "boolean";
|
|
165
184
|
defaultValue: string | number | boolean | null;
|
|
166
185
|
isOptional: boolean;
|
|
186
|
+
tags?: readonly string[] | undefined;
|
|
167
187
|
}>>>;
|
|
168
188
|
paths?: readonly (readonly (string | number)[])[] | Readonly<{
|
|
169
189
|
type: "parameter";
|
|
@@ -173,6 +193,7 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
173
193
|
type: "ref";
|
|
174
194
|
id: string;
|
|
175
195
|
}> | undefined;
|
|
196
|
+
tags?: readonly string[] | undefined;
|
|
176
197
|
}>]>;
|
|
177
198
|
export type BuilderOptionSerialised = v.InferOutput<typeof BuilderOptionSerialisedSchema>;
|
|
178
199
|
export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
@@ -197,6 +218,7 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
197
218
|
readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
198
219
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
199
220
|
readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
221
|
+
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
200
222
|
}, undefined>, v.ReadonlyAction<{
|
|
201
223
|
type: "select";
|
|
202
224
|
readonly options: readonly [string, ...string[]];
|
|
@@ -205,16 +227,19 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
205
227
|
optionLabels: {
|
|
206
228
|
[x: string]: string;
|
|
207
229
|
};
|
|
230
|
+
tags?: readonly string[] | undefined;
|
|
208
231
|
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
209
232
|
readonly type: v.LiteralSchema<"toggle", undefined>;
|
|
210
233
|
readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
211
234
|
readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
|
|
212
235
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
236
|
+
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
213
237
|
}, undefined>, v.ReadonlyAction<{
|
|
214
238
|
type: "toggle";
|
|
215
239
|
valueType: "string" | "number" | "boolean";
|
|
216
240
|
defaultValue: string | number | boolean | null;
|
|
217
241
|
isOptional: boolean;
|
|
242
|
+
tags?: readonly string[] | undefined;
|
|
218
243
|
}>]>], undefined>, v.ReadonlyAction<Readonly<{
|
|
219
244
|
type: "select";
|
|
220
245
|
readonly options: readonly [string, ...string[]];
|
|
@@ -223,11 +248,13 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
223
248
|
optionLabels: {
|
|
224
249
|
[x: string]: string;
|
|
225
250
|
};
|
|
251
|
+
tags?: readonly string[] | undefined;
|
|
226
252
|
}> | Readonly<{
|
|
227
253
|
type: "toggle";
|
|
228
254
|
valueType: "string" | "number" | "boolean";
|
|
229
255
|
defaultValue: string | number | boolean | null;
|
|
230
256
|
isOptional: boolean;
|
|
257
|
+
tags?: readonly string[] | undefined;
|
|
231
258
|
}>>]>, v.GenericSchema<BuilderWhenSerialised<Readonly<Readonly<{
|
|
232
259
|
type: "select";
|
|
233
260
|
readonly options: readonly [string, ...string[]];
|
|
@@ -236,11 +263,13 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
236
263
|
optionLabels: {
|
|
237
264
|
[x: string]: string;
|
|
238
265
|
};
|
|
266
|
+
tags?: readonly string[] | undefined;
|
|
239
267
|
}>> | Readonly<Readonly<{
|
|
240
268
|
type: "toggle";
|
|
241
269
|
valueType: "string" | "number" | "boolean";
|
|
242
270
|
defaultValue: string | number | boolean | null;
|
|
243
271
|
isOptional: boolean;
|
|
272
|
+
tags?: readonly string[] | undefined;
|
|
244
273
|
}>>>>], undefined>], undefined>;
|
|
245
274
|
readonly paths: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
246
275
|
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
@@ -257,6 +286,7 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
257
286
|
type: "ref";
|
|
258
287
|
id: string;
|
|
259
288
|
}>]>, 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)[])[]>]>], undefined>, undefined>;
|
|
289
|
+
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
260
290
|
}, undefined>, v.ReadonlyAction<{
|
|
261
291
|
name: string;
|
|
262
292
|
payload: Readonly<{
|
|
@@ -274,11 +304,13 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
274
304
|
optionLabels: {
|
|
275
305
|
[x: string]: string;
|
|
276
306
|
};
|
|
307
|
+
tags?: readonly string[] | undefined;
|
|
277
308
|
}>> | Readonly<Readonly<{
|
|
278
309
|
type: "toggle";
|
|
279
310
|
valueType: "string" | "number" | "boolean";
|
|
280
311
|
defaultValue: string | number | boolean | null;
|
|
281
312
|
isOptional: boolean;
|
|
313
|
+
tags?: readonly string[] | undefined;
|
|
282
314
|
}>> | BuilderWhenSerialised<Readonly<Readonly<{
|
|
283
315
|
type: "select";
|
|
284
316
|
readonly options: readonly [string, ...string[]];
|
|
@@ -287,11 +319,13 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
287
319
|
optionLabels: {
|
|
288
320
|
[x: string]: string;
|
|
289
321
|
};
|
|
322
|
+
tags?: readonly string[] | undefined;
|
|
290
323
|
}>> | Readonly<Readonly<{
|
|
291
324
|
type: "toggle";
|
|
292
325
|
valueType: "string" | "number" | "boolean";
|
|
293
326
|
defaultValue: string | number | boolean | null;
|
|
294
327
|
isOptional: boolean;
|
|
328
|
+
tags?: readonly string[] | undefined;
|
|
295
329
|
}>>>;
|
|
296
330
|
paths?: readonly (readonly (string | number)[])[] | Readonly<{
|
|
297
331
|
type: "parameter";
|
|
@@ -301,6 +335,7 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
301
335
|
type: "ref";
|
|
302
336
|
id: string;
|
|
303
337
|
}> | undefined;
|
|
338
|
+
tags?: readonly string[] | undefined;
|
|
304
339
|
}>]>, undefined>, v.ReadonlyAction<Readonly<{
|
|
305
340
|
name: string;
|
|
306
341
|
payload: Readonly<{
|
|
@@ -318,11 +353,13 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
318
353
|
optionLabels: {
|
|
319
354
|
[x: string]: string;
|
|
320
355
|
};
|
|
356
|
+
tags?: readonly string[] | undefined;
|
|
321
357
|
}>> | Readonly<Readonly<{
|
|
322
358
|
type: "toggle";
|
|
323
359
|
valueType: "string" | "number" | "boolean";
|
|
324
360
|
defaultValue: string | number | boolean | null;
|
|
325
361
|
isOptional: boolean;
|
|
362
|
+
tags?: readonly string[] | undefined;
|
|
326
363
|
}>> | BuilderWhenSerialised<Readonly<Readonly<{
|
|
327
364
|
type: "select";
|
|
328
365
|
readonly options: readonly [string, ...string[]];
|
|
@@ -331,11 +368,13 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
331
368
|
optionLabels: {
|
|
332
369
|
[x: string]: string;
|
|
333
370
|
};
|
|
371
|
+
tags?: readonly string[] | undefined;
|
|
334
372
|
}>> | Readonly<Readonly<{
|
|
335
373
|
type: "toggle";
|
|
336
374
|
valueType: "string" | "number" | "boolean";
|
|
337
375
|
defaultValue: string | number | boolean | null;
|
|
338
376
|
isOptional: boolean;
|
|
377
|
+
tags?: readonly string[] | undefined;
|
|
339
378
|
}>>>;
|
|
340
379
|
paths?: readonly (readonly (string | number)[])[] | Readonly<{
|
|
341
380
|
type: "parameter";
|
|
@@ -345,5 +384,6 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
345
384
|
type: "ref";
|
|
346
385
|
id: string;
|
|
347
386
|
}> | undefined;
|
|
387
|
+
tags?: readonly string[] | undefined;
|
|
348
388
|
}>[]>]>;
|
|
349
389
|
export type BuilderOptionsSerialised = v.InferOutput<typeof BuilderOptionsSerialisedSchema>;
|
|
@@ -2,16 +2,22 @@ import * as v from 'valibot';
|
|
|
2
2
|
import { BuilderPathsSchema } from '../../paths.js';
|
|
3
3
|
import { paramable } from '../../references.js';
|
|
4
4
|
import { serialisable } from '../../serialisable.js';
|
|
5
|
+
import { BuilderTagsSchema } from '../tags.js';
|
|
5
6
|
import { createSelectMapSerialisedSchema, createWhenSerialisedSchema } from '../when.js';
|
|
6
7
|
import { BuilderOptionValuesSerialisedSchema } from './values.js';
|
|
7
8
|
export class BuilderOption {
|
|
8
9
|
name;
|
|
9
10
|
payload;
|
|
10
11
|
paths;
|
|
11
|
-
|
|
12
|
+
tags;
|
|
13
|
+
constructor(name, payload, paths, tags) {
|
|
12
14
|
this.name = name;
|
|
13
15
|
this.payload = payload;
|
|
14
16
|
this.paths = paths;
|
|
17
|
+
this.tags = tags;
|
|
18
|
+
}
|
|
19
|
+
tag(...tags) {
|
|
20
|
+
return new BuilderOption(this.name, this.payload, this.paths, tags);
|
|
15
21
|
}
|
|
16
22
|
}
|
|
17
23
|
export const BuilderOptionSchema = v.instance(BuilderOption);
|
|
@@ -20,6 +26,7 @@ export const BuilderOptionSelectMapSerialisedSchema = createSelectMapSerialisedS
|
|
|
20
26
|
export const BuilderOptionSerialisedSchema = serialisable(v.object({
|
|
21
27
|
name: v.string(),
|
|
22
28
|
payload: paramable(v.union([BuilderOptionValuesSerialisedSchema, BuilderOptionWhenSerialisedSchema])),
|
|
23
|
-
paths: v.optional(paramable(BuilderPathsSchema))
|
|
29
|
+
paths: v.optional(paramable(BuilderPathsSchema)),
|
|
30
|
+
tags: v.optional(BuilderTagsSchema)
|
|
24
31
|
}));
|
|
25
32
|
export const BuilderOptionsSerialisedSchema = v.pipe(v.array(BuilderOptionSerialisedSchema), v.readonly());
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { BuilderTags } from '../tags';
|
|
1
2
|
import * as v from 'valibot';
|
|
2
3
|
export type BuilderSelectTypeLabels<Values extends BuilderSelectTypeValues> = Partial<Record<Values[number], string>>;
|
|
3
4
|
export type BuilderSelectTypeValues = readonly [string, ...ReadonlyArray<string>];
|
|
4
5
|
export declare class BuilderSelectType<const Values extends BuilderSelectTypeValues = BuilderSelectTypeValues, const ValueSchema extends v.GenericSchema<string | null> = v.GenericSchema<string | null>> {
|
|
6
|
+
#private;
|
|
5
7
|
readonly value: v.InferOutput<ValueSchema>;
|
|
6
8
|
readonly type: "select";
|
|
7
9
|
readonly options: Values;
|
|
@@ -9,10 +11,12 @@ export declare class BuilderSelectType<const Values extends BuilderSelectTypeVal
|
|
|
9
11
|
readonly defaultValue: v.InferOutput<ValueSchema>;
|
|
10
12
|
readonly isOptional: boolean;
|
|
11
13
|
readonly optionLabels: BuilderSelectTypeLabels<Values>;
|
|
12
|
-
|
|
14
|
+
readonly tags?: BuilderTags;
|
|
15
|
+
constructor(values: Values, defaultValue: v.InferOutput<ValueSchema>, optional?: boolean, optionLabels?: BuilderSelectTypeLabels<Values>, tags?: BuilderTags);
|
|
13
16
|
default(newDefault: v.InferOutput<ValueSchema>): BuilderSelectType<Values, ValueSchema>;
|
|
14
17
|
optional(): BuilderSelectType<Values, v.NullableSchema<ValueSchema, undefined>>;
|
|
15
18
|
labels(optionLabels: BuilderSelectTypeLabels<Values>): BuilderSelectType<Values, ValueSchema>;
|
|
19
|
+
tag(...tags: Array<string>): BuilderSelectType<Values, ValueSchema>;
|
|
16
20
|
}
|
|
17
21
|
type SelectSchema<Values extends BuilderSelectTypeValues> = v.UnionSchema<{
|
|
18
22
|
[K in keyof Values]: v.LiteralSchema<Values[K], undefined>;
|
|
@@ -25,6 +29,7 @@ export declare const BuilderSelectTypeSerialisedSchema: v.SchemaWithPipe<readonl
|
|
|
25
29
|
readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
26
30
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
27
31
|
readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
32
|
+
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
28
33
|
}, undefined>, v.ReadonlyAction<{
|
|
29
34
|
type: "select";
|
|
30
35
|
readonly options: readonly [string, ...string[]];
|
|
@@ -33,6 +38,7 @@ export declare const BuilderSelectTypeSerialisedSchema: v.SchemaWithPipe<readonl
|
|
|
33
38
|
optionLabels: {
|
|
34
39
|
[x: string]: string;
|
|
35
40
|
};
|
|
41
|
+
tags?: readonly string[] | undefined;
|
|
36
42
|
}>]>;
|
|
37
43
|
export type BuilderSelectTypeSerialised = v.InferOutput<typeof BuilderSelectTypeSerialisedSchema>;
|
|
38
44
|
export declare function selectValueSchema(options: ReadonlyArray<string>, optional: boolean): v.GenericSchema<string | null>;
|