@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,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 class BuilderSelectType {
|
|
4
5
|
type = 'select';
|
|
5
6
|
options;
|
|
@@ -7,22 +8,31 @@ export class BuilderSelectType {
|
|
|
7
8
|
defaultValue;
|
|
8
9
|
isOptional;
|
|
9
10
|
optionLabels;
|
|
10
|
-
|
|
11
|
+
tags;
|
|
12
|
+
constructor(values, defaultValue, optional = false, optionLabels = {}, tags) {
|
|
11
13
|
this.options = values;
|
|
12
14
|
this.valueSchema = selectValueSchema(values, optional);
|
|
13
15
|
this.defaultValue = defaultValue;
|
|
14
16
|
this.isOptional = optional;
|
|
15
17
|
this.optionLabels = optionLabels;
|
|
18
|
+
this.tags = tags;
|
|
19
|
+
}
|
|
20
|
+
#next(patch) {
|
|
21
|
+
return new BuilderSelectType(this.options, 'defaultValue' in patch
|
|
22
|
+
? patch.defaultValue
|
|
23
|
+
: this.defaultValue, patch.optional ?? this.isOptional, patch.optionLabels ?? this.optionLabels, patch.tags ?? this.tags);
|
|
16
24
|
}
|
|
17
25
|
default(newDefault) {
|
|
18
|
-
return
|
|
26
|
+
return this.#next({ defaultValue: newDefault });
|
|
19
27
|
}
|
|
20
28
|
optional() {
|
|
21
|
-
|
|
22
|
-
return new BuilderSelectType(options, defaultValue, true, this.optionLabels);
|
|
29
|
+
return this.#next({ optional: true });
|
|
23
30
|
}
|
|
24
31
|
labels(optionLabels) {
|
|
25
|
-
return
|
|
32
|
+
return this.#next({ optionLabels });
|
|
33
|
+
}
|
|
34
|
+
tag(...tags) {
|
|
35
|
+
return this.#next({ tags });
|
|
26
36
|
}
|
|
27
37
|
}
|
|
28
38
|
export function select(values) {
|
|
@@ -35,7 +45,8 @@ export const BuilderSelectTypeSerialisedSchema = serialisable(v.object({
|
|
|
35
45
|
options: v.pipe(v.tupleWithRest([v.string()], v.string()), v.readonly()),
|
|
36
46
|
defaultValue: v.nullable(v.string()),
|
|
37
47
|
isOptional: v.boolean(),
|
|
38
|
-
optionLabels: v.record(v.string(), v.string())
|
|
48
|
+
optionLabels: v.record(v.string(), v.string()),
|
|
49
|
+
tags: v.optional(BuilderTagsSchema)
|
|
39
50
|
}));
|
|
40
51
|
export function selectValueSchema(options, optional) {
|
|
41
52
|
const baseSchema = v.union(options.map((value) => v.literal(value)));
|
|
@@ -1,17 +1,21 @@
|
|
|
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 BuilderToggleValueTypeSchema: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
4
5
|
export type BuilderToggleValueType = v.InferOutput<typeof BuilderToggleValueTypeSchema>;
|
|
5
6
|
export declare class BuilderToggleType<const ValueSchema extends v.GenericSchema<BuilderPrimitive> = v.GenericSchema<BuilderPrimitive>> {
|
|
7
|
+
#private;
|
|
6
8
|
readonly value: v.InferOutput<ValueSchema>;
|
|
7
9
|
readonly type: "toggle";
|
|
8
10
|
readonly valueType: BuilderToggleValueType;
|
|
9
11
|
readonly valueSchema: ValueSchema;
|
|
10
12
|
readonly defaultValue: v.InferOutput<ValueSchema>;
|
|
11
13
|
readonly isOptional: boolean;
|
|
12
|
-
|
|
14
|
+
readonly tags?: BuilderTags;
|
|
15
|
+
constructor(valueType: BuilderToggleValueType, defaultValue: v.InferOutput<ValueSchema>, optional?: boolean, tags?: BuilderTags);
|
|
13
16
|
default(newDefault: v.InferOutput<ValueSchema>): BuilderToggleType<ValueSchema>;
|
|
14
17
|
optional(): BuilderToggleType<v.NullableSchema<ValueSchema, undefined>>;
|
|
18
|
+
tag(...tags: Array<string>): BuilderToggleType<ValueSchema>;
|
|
15
19
|
}
|
|
16
20
|
export declare function toggleString(): BuilderToggleType<v.StringSchema<undefined>>;
|
|
17
21
|
export declare function toggleBoolean(): BuilderToggleType<v.BooleanSchema<undefined>>;
|
|
@@ -22,11 +26,13 @@ export declare const BuilderToggleTypeSerialisedSchema: v.SchemaWithPipe<readonl
|
|
|
22
26
|
readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
23
27
|
readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
|
|
24
28
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
29
|
+
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
25
30
|
}, undefined>, v.ReadonlyAction<{
|
|
26
31
|
type: "toggle";
|
|
27
32
|
valueType: "string" | "number" | "boolean";
|
|
28
33
|
defaultValue: string | number | boolean | null;
|
|
29
34
|
isOptional: boolean;
|
|
35
|
+
tags?: readonly string[] | undefined;
|
|
30
36
|
}>]>;
|
|
31
37
|
export type BuilderToggleTypeSerialised = v.InferOutput<typeof BuilderToggleTypeSerialisedSchema>;
|
|
32
38
|
export declare function toggleValueSchema(valueType: BuilderToggleValueType, optional: boolean): v.GenericSchema;
|
|
@@ -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 BuilderToggleValueTypeSchema = v.picklist(['string', 'boolean', 'number']);
|
|
4
5
|
export class BuilderToggleType {
|
|
5
6
|
type = 'toggle';
|
|
@@ -7,17 +8,27 @@ export class BuilderToggleType {
|
|
|
7
8
|
valueSchema;
|
|
8
9
|
defaultValue;
|
|
9
10
|
isOptional;
|
|
10
|
-
|
|
11
|
+
tags;
|
|
12
|
+
constructor(valueType, defaultValue, optional, tags) {
|
|
11
13
|
this.valueType = valueType;
|
|
12
14
|
this.valueSchema = toggleValueSchema(valueType, optional || false);
|
|
13
15
|
this.defaultValue = defaultValue;
|
|
14
16
|
this.isOptional = optional || false;
|
|
17
|
+
this.tags = tags;
|
|
18
|
+
}
|
|
19
|
+
#next(patch) {
|
|
20
|
+
return new BuilderToggleType(this.valueType, 'defaultValue' in patch
|
|
21
|
+
? patch.defaultValue
|
|
22
|
+
: this.defaultValue, patch.optional ?? this.isOptional, patch.tags ?? this.tags);
|
|
15
23
|
}
|
|
16
24
|
default(newDefault) {
|
|
17
|
-
return
|
|
25
|
+
return this.#next({ defaultValue: newDefault });
|
|
18
26
|
}
|
|
19
27
|
optional() {
|
|
20
|
-
return
|
|
28
|
+
return this.#next({ optional: true });
|
|
29
|
+
}
|
|
30
|
+
tag(...tags) {
|
|
31
|
+
return this.#next({ tags });
|
|
21
32
|
}
|
|
22
33
|
}
|
|
23
34
|
export function toggleString() {
|
|
@@ -34,7 +45,8 @@ export const BuilderToggleTypeSerialisedSchema = serialisable(v.object({
|
|
|
34
45
|
type: v.literal('toggle'),
|
|
35
46
|
valueType: BuilderToggleValueTypeSchema,
|
|
36
47
|
defaultValue: v.nullable(v.union([v.boolean(), v.string(), v.number()])),
|
|
37
|
-
isOptional: v.boolean()
|
|
48
|
+
isOptional: v.boolean(),
|
|
49
|
+
tags: v.optional(BuilderTagsSchema)
|
|
38
50
|
}));
|
|
39
51
|
export function toggleValueSchema(valueType, optional) {
|
|
40
52
|
const baseSchema = valueType === 'string' ? v.string() : valueType === 'boolean' ? v.boolean() : v.number();
|
|
@@ -7,6 +7,7 @@ export declare const BuilderOptionValuesSerialisedSchema: v.SchemaWithPipe<reado
|
|
|
7
7
|
readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
8
8
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
9
9
|
readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
10
|
+
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
10
11
|
}, undefined>, v.ReadonlyAction<{
|
|
11
12
|
type: "select";
|
|
12
13
|
readonly options: readonly [string, ...string[]];
|
|
@@ -15,16 +16,19 @@ export declare const BuilderOptionValuesSerialisedSchema: v.SchemaWithPipe<reado
|
|
|
15
16
|
optionLabels: {
|
|
16
17
|
[x: string]: string;
|
|
17
18
|
};
|
|
19
|
+
tags?: readonly string[] | undefined;
|
|
18
20
|
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
19
21
|
readonly type: v.LiteralSchema<"toggle", undefined>;
|
|
20
22
|
readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
21
23
|
readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
|
|
22
24
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
25
|
+
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
23
26
|
}, undefined>, v.ReadonlyAction<{
|
|
24
27
|
type: "toggle";
|
|
25
28
|
valueType: "string" | "number" | "boolean";
|
|
26
29
|
defaultValue: string | number | boolean | null;
|
|
27
30
|
isOptional: boolean;
|
|
31
|
+
tags?: readonly string[] | undefined;
|
|
28
32
|
}>]>], undefined>, v.ReadonlyAction<Readonly<{
|
|
29
33
|
type: "select";
|
|
30
34
|
readonly options: readonly [string, ...string[]];
|
|
@@ -33,11 +37,13 @@ export declare const BuilderOptionValuesSerialisedSchema: v.SchemaWithPipe<reado
|
|
|
33
37
|
optionLabels: {
|
|
34
38
|
[x: string]: string;
|
|
35
39
|
};
|
|
40
|
+
tags?: readonly string[] | undefined;
|
|
36
41
|
}> | Readonly<{
|
|
37
42
|
type: "toggle";
|
|
38
43
|
valueType: "string" | "number" | "boolean";
|
|
39
44
|
defaultValue: string | number | boolean | null;
|
|
40
45
|
isOptional: boolean;
|
|
46
|
+
tags?: readonly string[] | undefined;
|
|
41
47
|
}>>]>;
|
|
42
48
|
export type BuilderOptionValuesSerialised = v.InferOutput<typeof BuilderOptionValuesSerialisedSchema>;
|
|
43
49
|
export declare function optionValueSchema(payload: BuilderOptionValuesSerialised): v.GenericSchema;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Paramable, ParamableSerialised } from '../../references';
|
|
2
|
+
import * as v from 'valibot';
|
|
3
|
+
export declare const BuilderPricingReduceSchema: v.PicklistSchema<["product", "sum", "first"], undefined>;
|
|
4
|
+
export type BuilderPricingReduce = v.InferOutput<typeof BuilderPricingReduceSchema>;
|
|
5
|
+
export type BuilderPricingLookupKey = {
|
|
6
|
+
readonly kind: 'variantTags';
|
|
7
|
+
} | {
|
|
8
|
+
readonly kind: 'option';
|
|
9
|
+
readonly name: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const BuilderPricingLookupKeySchema: v.GenericSchema<BuilderPricingLookupKey>;
|
|
12
|
+
export type BuilderPricingExpression = number | {
|
|
13
|
+
readonly kind: 'variantPrice';
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: 'lookup';
|
|
16
|
+
readonly rate: string;
|
|
17
|
+
readonly key: BuilderPricingLookupKey;
|
|
18
|
+
readonly reduce?: BuilderPricingReduce;
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'variants';
|
|
21
|
+
readonly tag?: string;
|
|
22
|
+
readonly expression: Paramable<BuilderPricingExpression>;
|
|
23
|
+
readonly reduce?: BuilderPricingReduce;
|
|
24
|
+
} | {
|
|
25
|
+
readonly kind: 'add';
|
|
26
|
+
readonly left: Paramable<BuilderPricingExpression>;
|
|
27
|
+
readonly right: Paramable<BuilderPricingExpression>;
|
|
28
|
+
} | {
|
|
29
|
+
readonly kind: 'sub';
|
|
30
|
+
readonly left: Paramable<BuilderPricingExpression>;
|
|
31
|
+
readonly right: Paramable<BuilderPricingExpression>;
|
|
32
|
+
} | {
|
|
33
|
+
readonly kind: 'mul';
|
|
34
|
+
readonly left: Paramable<BuilderPricingExpression>;
|
|
35
|
+
readonly right: Paramable<BuilderPricingExpression>;
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: 'div';
|
|
38
|
+
readonly left: Paramable<BuilderPricingExpression>;
|
|
39
|
+
readonly right: Paramable<BuilderPricingExpression>;
|
|
40
|
+
};
|
|
41
|
+
export type BuilderPricingExpressionSerialised = number | {
|
|
42
|
+
readonly kind: 'variantPrice';
|
|
43
|
+
} | {
|
|
44
|
+
readonly kind: 'lookup';
|
|
45
|
+
readonly rate: string;
|
|
46
|
+
readonly key: BuilderPricingLookupKey;
|
|
47
|
+
readonly reduce?: BuilderPricingReduce;
|
|
48
|
+
} | {
|
|
49
|
+
readonly kind: 'variants';
|
|
50
|
+
readonly tag?: string;
|
|
51
|
+
readonly expression: ParamableSerialised<BuilderPricingExpressionSerialised>;
|
|
52
|
+
readonly reduce?: BuilderPricingReduce;
|
|
53
|
+
} | {
|
|
54
|
+
readonly kind: 'add';
|
|
55
|
+
readonly left: ParamableSerialised<BuilderPricingExpressionSerialised>;
|
|
56
|
+
readonly right: ParamableSerialised<BuilderPricingExpressionSerialised>;
|
|
57
|
+
} | {
|
|
58
|
+
readonly kind: 'sub';
|
|
59
|
+
readonly left: ParamableSerialised<BuilderPricingExpressionSerialised>;
|
|
60
|
+
readonly right: ParamableSerialised<BuilderPricingExpressionSerialised>;
|
|
61
|
+
} | {
|
|
62
|
+
readonly kind: 'mul';
|
|
63
|
+
readonly left: ParamableSerialised<BuilderPricingExpressionSerialised>;
|
|
64
|
+
readonly right: ParamableSerialised<BuilderPricingExpressionSerialised>;
|
|
65
|
+
} | {
|
|
66
|
+
readonly kind: 'div';
|
|
67
|
+
readonly left: ParamableSerialised<BuilderPricingExpressionSerialised>;
|
|
68
|
+
readonly right: ParamableSerialised<BuilderPricingExpressionSerialised>;
|
|
69
|
+
};
|
|
70
|
+
export declare const BuilderPricingExpressionSchema: v.GenericSchema<BuilderPricingExpression>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { paramable } from '../../references.js';
|
|
3
|
+
export const BuilderPricingReduceSchema = v.picklist(['product', 'sum', 'first']);
|
|
4
|
+
export const BuilderPricingLookupKeySchema = v.variant('kind', [
|
|
5
|
+
v.object({ kind: v.literal('variantTags') }),
|
|
6
|
+
v.object({ kind: v.literal('option'), name: v.string() })
|
|
7
|
+
]);
|
|
8
|
+
export const BuilderPricingExpressionSchema = v.lazy(() => v.union([
|
|
9
|
+
v.number(),
|
|
10
|
+
v.object({ kind: v.literal('variantPrice') }),
|
|
11
|
+
v.object({
|
|
12
|
+
kind: v.literal('lookup'),
|
|
13
|
+
rate: v.string(),
|
|
14
|
+
key: BuilderPricingLookupKeySchema,
|
|
15
|
+
reduce: v.optional(BuilderPricingReduceSchema)
|
|
16
|
+
}),
|
|
17
|
+
v.object({
|
|
18
|
+
kind: v.literal('variants'),
|
|
19
|
+
tag: v.optional(v.string()),
|
|
20
|
+
expression: paramable(BuilderPricingExpressionSchema),
|
|
21
|
+
reduce: v.optional(BuilderPricingReduceSchema)
|
|
22
|
+
}),
|
|
23
|
+
v.object({
|
|
24
|
+
kind: v.literal('add'),
|
|
25
|
+
left: paramable(BuilderPricingExpressionSchema),
|
|
26
|
+
right: paramable(BuilderPricingExpressionSchema)
|
|
27
|
+
}),
|
|
28
|
+
v.object({
|
|
29
|
+
kind: v.literal('sub'),
|
|
30
|
+
left: paramable(BuilderPricingExpressionSchema),
|
|
31
|
+
right: paramable(BuilderPricingExpressionSchema)
|
|
32
|
+
}),
|
|
33
|
+
v.object({
|
|
34
|
+
kind: v.literal('mul'),
|
|
35
|
+
left: paramable(BuilderPricingExpressionSchema),
|
|
36
|
+
right: paramable(BuilderPricingExpressionSchema)
|
|
37
|
+
}),
|
|
38
|
+
v.object({
|
|
39
|
+
kind: v.literal('div'),
|
|
40
|
+
left: paramable(BuilderPricingExpressionSchema),
|
|
41
|
+
right: paramable(BuilderPricingExpressionSchema)
|
|
42
|
+
})
|
|
43
|
+
]));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { BuilderPricingExpression, BuilderPricingLookupKey, BuilderPricingReduce } from './expression';
|
|
2
|
+
export type { BuilderRates } from './rates';
|
|
3
|
+
export type { BuilderPricingSerialised } from './pricing';
|
|
4
|
+
export { BuilderPricingExpressionSchema, BuilderPricingLookupKeySchema, BuilderPricingReduceSchema } from './expression.js';
|
|
5
|
+
export { BuilderRatesSchema } from './rates.js';
|
|
6
|
+
export { BuilderPricing, BuilderPricingSchema, BuilderPricingSerialisedSchema, pricing } from './pricing.js';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { BuilderPricingExpressionSchema, BuilderPricingLookupKeySchema, BuilderPricingReduceSchema } from './expression.js';
|
|
2
|
+
export { BuilderRatesSchema } from './rates.js';
|
|
3
|
+
export { BuilderPricing, BuilderPricingSchema, BuilderPricingSerialisedSchema, pricing } from './pricing.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Paramable, ParamableSerialised } from '../../references';
|
|
2
|
+
import type { BuilderPricingExpression } from './expression';
|
|
3
|
+
import type { BuilderRates } from './rates';
|
|
4
|
+
import * as v from 'valibot';
|
|
5
|
+
export declare class BuilderPricing {
|
|
6
|
+
readonly type: 'pricing';
|
|
7
|
+
readonly rates: ReadonlyArray<Paramable<BuilderRates>>;
|
|
8
|
+
readonly formula: BuilderPricingExpression | null;
|
|
9
|
+
constructor(formula?: BuilderPricingExpression | null, rates?: ReadonlyArray<Paramable<BuilderRates>>);
|
|
10
|
+
}
|
|
11
|
+
export declare const BuilderPricingSchema: v.InstanceSchema<typeof BuilderPricing, undefined>;
|
|
12
|
+
export interface BuilderPricingSerialised {
|
|
13
|
+
readonly rates: ReadonlyArray<ParamableSerialised<BuilderRates>>;
|
|
14
|
+
readonly formula: BuilderPricingExpression | null;
|
|
15
|
+
}
|
|
16
|
+
export declare const BuilderPricingSerialisedSchema: v.GenericSchema<BuilderPricingSerialised>;
|
|
17
|
+
export declare function pricing(formula?: BuilderPricingExpression | null, rates?: ReadonlyArray<Paramable<BuilderRates>>): BuilderPricing;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { paramable } from '../../references.js';
|
|
3
|
+
import { serialisable } from '../../serialisable.js';
|
|
4
|
+
import { BuilderPricingExpressionSchema } from './expression.js';
|
|
5
|
+
import { BuilderRatesSchema } from './rates.js';
|
|
6
|
+
export class BuilderPricing {
|
|
7
|
+
rates;
|
|
8
|
+
formula;
|
|
9
|
+
constructor(formula = null, rates) {
|
|
10
|
+
this.formula = formula;
|
|
11
|
+
this.rates = rates ?? [];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export const BuilderPricingSchema = v.instance(BuilderPricing);
|
|
15
|
+
export const BuilderPricingSerialisedSchema = serialisable(v.object({
|
|
16
|
+
rates: v.pipe(v.array(paramable(BuilderRatesSchema)), v.readonly()),
|
|
17
|
+
formula: v.nullable(BuilderPricingExpressionSchema)
|
|
18
|
+
}));
|
|
19
|
+
export function pricing(formula = null, rates) {
|
|
20
|
+
return new BuilderPricing(formula, rates);
|
|
21
|
+
}
|