@builder-builder/builder 0.0.23 → 0.0.25
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/client/client.d.ts +3 -1
- package/dist/client/client.js +30 -18
- package/dist/client/index.d.ts +1 -4
- package/dist/client/index.js +1 -2
- package/dist/client/public.d.ts +4 -0
- package/dist/client/public.js +2 -0
- package/dist/client/schema.d.ts +23 -14
- package/dist/client/schema.js +9 -2
- package/dist/entities/collection/collection.d.ts +2 -2
- package/dist/entities/collection/config.d.ts +1 -1
- package/dist/entities/collection/config.js +1 -1
- package/dist/entities/component/component.d.ts +2 -2
- package/dist/entities/component/config.d.ts +1 -1
- package/dist/entities/component/config.js +1 -1
- package/dist/entities/expectation.d.ts +1 -1
- package/dist/entities/kind.d.ts +3 -3
- package/dist/entities/kind.js +3 -3
- package/dist/entities/option/option.d.ts +2 -2
- package/dist/entities/option/select.d.ts +1 -1
- package/dist/entities/option/select.js +7 -5
- package/dist/entities/option/toggle.d.ts +1 -1
- package/dist/entities/option/toggle.js +1 -1
- package/dist/entities/paths.d.ts +2 -2
- package/dist/entities/pricing/rates.d.ts +1 -1
- package/dist/entities/serialise.d.ts +3 -3
- package/dist/entities/ui/describe.d.ts +1 -1
- package/dist/entities/ui/describe.js +2 -2
- package/dist/entities/ui/input.d.ts +1 -1
- package/dist/entities/ui/page.d.ts +1 -1
- package/dist/entities/ui/page.js +2 -2
- package/dist/entities/ui/pages.d.ts +2 -2
- package/dist/entities/ui/pages.js +2 -2
- package/dist/errors/check.d.ts +2 -3
- package/dist/errors/check.js +5 -10
- package/dist/errors/errors.d.ts +231 -158
- package/dist/errors/errors.js +143 -173
- package/dist/errors/exception.d.ts +6 -4
- package/dist/errors/exception.js +11 -66
- package/dist/errors/index.d.ts +2 -4
- package/dist/errors/index.js +2 -2
- package/dist/errors/public.d.ts +2 -0
- package/dist/errors/public.js +1 -0
- package/dist/index.d.ts +4 -36
- package/dist/index.js +4 -19
- package/dist/mappers/price.js +1 -1
- package/dist/mappers/render/render.js +7 -7
- package/dist/mappers/resolve.js +5 -5
- package/dist/mappers/variants/option-graph.js +11 -4
- package/dist/mappers/variants/variants.js +7 -6
- package/dist/public.d.ts +37 -0
- package/dist/public.js +19 -0
- package/dist/validate/brand.js +2 -4
- package/dist/validate/builder.d.ts +2 -2
- package/dist/validate/builder.js +3 -3
- package/dist/validate/expectations.d.ts +2 -2
- package/dist/validate/expectations.js +1 -1
- package/dist/validate/index.d.ts +0 -1
- package/dist/validate/instance.d.ts +2 -2
- package/dist/validate/instance.js +6 -6
- package/dist/validate/model.d.ts +4 -4
- package/dist/validate/model.js +118 -101
- package/dist/validate/paths.d.ts +2 -2
- package/dist/validate/paths.js +45 -21
- package/dist/validate/pricing.d.ts +4 -4
- package/dist/validate/pricing.js +26 -13
- package/dist/validate/resolve.d.ts +2 -2
- package/dist/validate/resolve.js +14 -3
- package/dist/validate/ui.d.ts +4 -4
- package/dist/validate/ui.js +3 -3
- package/dist/validate/variants.d.ts +2 -2
- package/dist/validate/variants.js +16 -16
- package/package.json +11 -7
- package/dist/private.d.ts +0 -3
- package/dist/private.js +0 -3
package/dist/client/client.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { BuilderBuilderClientOptions, BuilderBuilderGetResponse } from './schema.js';
|
|
1
|
+
import type { BuilderBuilderClientOptions, BuilderBuilderGetResponse, BuilderBuilderPriceResponse } from './schema.js';
|
|
2
|
+
import type { BuilderInstance } from '../instance.js';
|
|
2
3
|
export type BuilderBuilderClient = {
|
|
3
4
|
builder: {
|
|
4
5
|
get(id: string): Promise<BuilderBuilderGetResponse>;
|
|
6
|
+
price(id: string, instance: BuilderInstance): Promise<BuilderBuilderPriceResponse>;
|
|
5
7
|
};
|
|
6
8
|
};
|
|
7
9
|
export declare function client(options: BuilderBuilderClientOptions): BuilderBuilderClient;
|
package/dist/client/client.js
CHANGED
|
@@ -1,26 +1,38 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
import { BuilderException } from '../errors/index.js';
|
|
3
|
-
import { BuilderBuilderClientOptionsSchema, BuilderBuilderGetResponseSchema } from './schema.js';
|
|
3
|
+
import { BuilderBuilderClientOptionsSchema, BuilderBuilderGetResponseSchema, BuilderBuilderPriceResponseSchema } from './schema.js';
|
|
4
4
|
export function client(options) {
|
|
5
|
-
const { url, apiKey } = v.parse(BuilderBuilderClientOptionsSchema, options);
|
|
5
|
+
const { url, apiKey, headers } = v.parse(BuilderBuilderClientOptionsSchema, options);
|
|
6
|
+
const baseHeaders = {
|
|
7
|
+
...headers,
|
|
8
|
+
'X-Builder-Builder-Key': apiKey
|
|
9
|
+
};
|
|
6
10
|
return {
|
|
7
11
|
builder: {
|
|
8
|
-
get:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
body: await response.text()
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return v.parse(BuilderBuilderGetResponseSchema, await response.json());
|
|
23
|
-
}
|
|
12
|
+
get: (id) => request(BuilderBuilderGetResponseSchema, `${url}/api/builder/${id}`, {
|
|
13
|
+
headers: baseHeaders
|
|
14
|
+
}),
|
|
15
|
+
price: (id, instance) => request(BuilderBuilderPriceResponseSchema, `${url}/api/builder/${id}/price`, {
|
|
16
|
+
method: 'POST',
|
|
17
|
+
headers: {
|
|
18
|
+
...baseHeaders,
|
|
19
|
+
'Content-Type': 'application/json'
|
|
20
|
+
},
|
|
21
|
+
body: JSON.stringify({ instance })
|
|
22
|
+
})
|
|
24
23
|
}
|
|
25
24
|
};
|
|
26
25
|
}
|
|
26
|
+
async function request(schema, requestUrl, init) {
|
|
27
|
+
const response = await fetch(requestUrl, init);
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
throw new BuilderException({
|
|
30
|
+
category: 'request',
|
|
31
|
+
url: requestUrl,
|
|
32
|
+
status: response.status,
|
|
33
|
+
statusText: response.statusText,
|
|
34
|
+
body: await response.text()
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return v.parse(schema, await response.json());
|
|
38
|
+
}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export type { BuilderBuilderClient } from './client.js';
|
|
3
|
-
export { BuilderBuilderClientOptionsSchema, BuilderBuilderGetResponseSchema } from './schema.js';
|
|
4
|
-
export { client } from './client.js';
|
|
1
|
+
export * from './public.js';
|
package/dist/client/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { client } from './client.js';
|
|
1
|
+
export * from './public.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { BuilderBuilderClientOptions, BuilderBuilderGetResponse, BuilderBuilderPriceRequest, BuilderBuilderPriceResponse } from './schema.js';
|
|
2
|
+
export type { BuilderBuilderClient } from './client.js';
|
|
3
|
+
export { BuilderBuilderClientOptionsSchema, BuilderBuilderGetResponseSchema, BuilderBuilderPriceRequestSchema, BuilderBuilderPriceResponseSchema } from './schema.js';
|
|
4
|
+
export { client } from './client.js';
|
package/dist/client/schema.d.ts
CHANGED
|
@@ -2,14 +2,15 @@ import * as v from 'valibot';
|
|
|
2
2
|
export declare const BuilderBuilderClientOptionsSchema: v.ObjectSchema<{
|
|
3
3
|
readonly url: v.StringSchema<undefined>;
|
|
4
4
|
readonly apiKey: v.StringSchema<undefined>;
|
|
5
|
+
readonly headers: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>, undefined>;
|
|
5
6
|
}, undefined>;
|
|
6
7
|
export type BuilderBuilderClientOptions = v.InferOutput<typeof BuilderBuilderClientOptionsSchema>;
|
|
7
8
|
export declare const BuilderBuilderGetResponseSchema: v.ObjectSchema<{
|
|
8
9
|
readonly name: v.StringSchema<undefined>;
|
|
9
|
-
readonly serialised: v.GenericSchema<import("../
|
|
10
|
+
readonly serialised: v.GenericSchema<import("../public.js").BuilderSerialised>;
|
|
10
11
|
readonly references: v.ArraySchema<v.ObjectSchema<{
|
|
11
12
|
readonly id: v.StringSchema<undefined>;
|
|
12
|
-
readonly serialised: v.GenericSchema<string | number | boolean | readonly (string | number)[] | readonly (readonly (string | number)[])[] | import("../
|
|
13
|
+
readonly serialised: v.GenericSchema<string | number | boolean | readonly (string | number)[] | readonly (readonly (string | number)[])[] | import("../public.js").BuilderSerialised | import("../public.js").BuilderModelSerialised | Readonly<{
|
|
13
14
|
type: "select";
|
|
14
15
|
readonly options: readonly [string, ...string[]];
|
|
15
16
|
defaultValue: string | null;
|
|
@@ -24,7 +25,7 @@ export declare const BuilderBuilderGetResponseSchema: v.ObjectSchema<{
|
|
|
24
25
|
defaultValue: string | number | boolean | null;
|
|
25
26
|
isOptional: boolean;
|
|
26
27
|
tags?: readonly string[] | undefined;
|
|
27
|
-
}> | import("../
|
|
28
|
+
}> | import("../public.js").BuilderMatchSelectMap<Readonly<{
|
|
28
29
|
type: "parameter";
|
|
29
30
|
id: string;
|
|
30
31
|
name: string;
|
|
@@ -43,7 +44,7 @@ export declare const BuilderBuilderGetResponseSchema: v.ObjectSchema<{
|
|
|
43
44
|
defaultValue: string | number | boolean | null;
|
|
44
45
|
isOptional: boolean;
|
|
45
46
|
tags?: readonly string[] | undefined;
|
|
46
|
-
}>>> | import("../
|
|
47
|
+
}>>> | import("../public.js").BuilderWhenSerialised<Readonly<Readonly<{
|
|
47
48
|
type: "select";
|
|
48
49
|
readonly options: readonly [string, ...string[]];
|
|
49
50
|
defaultValue: string | null;
|
|
@@ -74,7 +75,7 @@ export declare const BuilderBuilderGetResponseSchema: v.ObjectSchema<{
|
|
|
74
75
|
tags?: readonly string[] | undefined;
|
|
75
76
|
}>[];
|
|
76
77
|
tags?: readonly string[] | undefined;
|
|
77
|
-
}> | import("../
|
|
78
|
+
}> | import("../public.js").BuilderMatchSelectMap<Readonly<{
|
|
78
79
|
type: "parameter";
|
|
79
80
|
id: string;
|
|
80
81
|
name: string;
|
|
@@ -94,7 +95,7 @@ export declare const BuilderBuilderGetResponseSchema: v.ObjectSchema<{
|
|
|
94
95
|
tags?: readonly string[] | undefined;
|
|
95
96
|
}>[];
|
|
96
97
|
tags?: readonly string[] | undefined;
|
|
97
|
-
}>> | import("../
|
|
98
|
+
}>> | import("../public.js").BuilderWhenSerialised<Readonly<{
|
|
98
99
|
fields: Readonly<{
|
|
99
100
|
type: "parameter";
|
|
100
101
|
id: string;
|
|
@@ -118,7 +119,7 @@ export declare const BuilderBuilderGetResponseSchema: v.ObjectSchema<{
|
|
|
118
119
|
}> | Readonly<{
|
|
119
120
|
type: "ref";
|
|
120
121
|
id: string;
|
|
121
|
-
}> | import("../
|
|
122
|
+
}> | import("../public.js").BuilderModelSerialised;
|
|
122
123
|
min: number | Readonly<{
|
|
123
124
|
type: "parameter";
|
|
124
125
|
id: string;
|
|
@@ -136,7 +137,7 @@ export declare const BuilderBuilderGetResponseSchema: v.ObjectSchema<{
|
|
|
136
137
|
id: string;
|
|
137
138
|
}>;
|
|
138
139
|
tags?: readonly string[] | undefined;
|
|
139
|
-
}> | import("../
|
|
140
|
+
}> | import("../public.js").BuilderMatchSelectMap<Readonly<{
|
|
140
141
|
type: "parameter";
|
|
141
142
|
id: string;
|
|
142
143
|
name: string;
|
|
@@ -148,7 +149,7 @@ export declare const BuilderBuilderGetResponseSchema: v.ObjectSchema<{
|
|
|
148
149
|
}> | Readonly<{
|
|
149
150
|
type: "ref";
|
|
150
151
|
id: string;
|
|
151
|
-
}> | import("../
|
|
152
|
+
}> | import("../public.js").BuilderModelSerialised;
|
|
152
153
|
min: number | Readonly<{
|
|
153
154
|
type: "parameter";
|
|
154
155
|
id: string;
|
|
@@ -166,7 +167,7 @@ export declare const BuilderBuilderGetResponseSchema: v.ObjectSchema<{
|
|
|
166
167
|
id: string;
|
|
167
168
|
}>;
|
|
168
169
|
tags?: readonly string[] | undefined;
|
|
169
|
-
}>> | import("../
|
|
170
|
+
}>> | import("../public.js").BuilderWhenSerialised<Readonly<{
|
|
170
171
|
model: Readonly<{
|
|
171
172
|
type: "parameter";
|
|
172
173
|
id: string;
|
|
@@ -174,7 +175,7 @@ export declare const BuilderBuilderGetResponseSchema: v.ObjectSchema<{
|
|
|
174
175
|
}> | Readonly<{
|
|
175
176
|
type: "ref";
|
|
176
177
|
id: string;
|
|
177
|
-
}> | import("../
|
|
178
|
+
}> | import("../public.js").BuilderModelSerialised;
|
|
178
179
|
min: number | Readonly<{
|
|
179
180
|
type: "parameter";
|
|
180
181
|
id: string;
|
|
@@ -192,7 +193,7 @@ export declare const BuilderBuilderGetResponseSchema: v.ObjectSchema<{
|
|
|
192
193
|
id: string;
|
|
193
194
|
}>;
|
|
194
195
|
tags?: readonly string[] | undefined;
|
|
195
|
-
}>> | import("../
|
|
196
|
+
}>> | import("../public.js").BuilderUISerialised | Readonly<{
|
|
196
197
|
type: "input";
|
|
197
198
|
path: readonly (string | number)[] | Readonly<{
|
|
198
199
|
type: "parameter";
|
|
@@ -355,14 +356,14 @@ export declare const BuilderBuilderGetResponseSchema: v.ObjectSchema<{
|
|
|
355
356
|
tags?: readonly string[] | undefined;
|
|
356
357
|
}>)[];
|
|
357
358
|
tags?: readonly string[] | undefined;
|
|
358
|
-
}> | import("../
|
|
359
|
+
}> | import("../public.js").BuilderUIPagesSerialised | readonly (Readonly<{
|
|
359
360
|
type: "parameter";
|
|
360
361
|
id: string;
|
|
361
362
|
name: string;
|
|
362
363
|
}> | Readonly<{
|
|
363
364
|
type: "ref";
|
|
364
365
|
id: string;
|
|
365
|
-
}> | import("../entities/index.js").BuilderUIItemSerialised)[] | import("../
|
|
366
|
+
}> | import("../entities/index.js").BuilderUIItemSerialised)[] | import("../public.js").BuilderPricingSerialised | import("../entities/index.js").BuilderRates | readonly Readonly<{
|
|
366
367
|
name: string;
|
|
367
368
|
kind: "option" | "component" | "collection";
|
|
368
369
|
}>[]>;
|
|
@@ -394,3 +395,11 @@ export declare const BuilderBuilderGetResponseSchema: v.ObjectSchema<{
|
|
|
394
395
|
}>]>;
|
|
395
396
|
}, undefined>;
|
|
396
397
|
export type BuilderBuilderGetResponse = v.InferOutput<typeof BuilderBuilderGetResponseSchema>;
|
|
398
|
+
export declare const BuilderBuilderPriceRequestSchema: v.ObjectSchema<{
|
|
399
|
+
readonly instance: v.GenericSchema<import("../instance.js").BuilderInstance>;
|
|
400
|
+
}, undefined>;
|
|
401
|
+
export type BuilderBuilderPriceRequest = v.InferOutput<typeof BuilderBuilderPriceRequestSchema>;
|
|
402
|
+
export declare const BuilderBuilderPriceResponseSchema: v.ObjectSchema<{
|
|
403
|
+
readonly price: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
|
|
404
|
+
}, undefined>;
|
|
405
|
+
export type BuilderBuilderPriceResponse = v.InferOutput<typeof BuilderBuilderPriceResponseSchema>;
|
package/dist/client/schema.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
import { BuilderReferencesSchema, BuilderSerialisedSchema } from '../entities/index.js';
|
|
3
|
-
import { BuilderVariantsSchema } from '../instance.js';
|
|
3
|
+
import { BuilderInstanceSchema, BuilderVariantsSchema } from '../instance.js';
|
|
4
4
|
export const BuilderBuilderClientOptionsSchema = v.object({
|
|
5
5
|
url: v.string(),
|
|
6
|
-
apiKey: v.string()
|
|
6
|
+
apiKey: v.string(),
|
|
7
|
+
headers: v.optional(v.record(v.string(), v.string()))
|
|
7
8
|
});
|
|
8
9
|
export const BuilderBuilderGetResponseSchema = v.object({
|
|
9
10
|
name: v.string(),
|
|
@@ -11,3 +12,9 @@ export const BuilderBuilderGetResponseSchema = v.object({
|
|
|
11
12
|
references: BuilderReferencesSchema,
|
|
12
13
|
variants: BuilderVariantsSchema
|
|
13
14
|
});
|
|
15
|
+
export const BuilderBuilderPriceRequestSchema = v.object({
|
|
16
|
+
instance: BuilderInstanceSchema
|
|
17
|
+
});
|
|
18
|
+
export const BuilderBuilderPriceResponseSchema = v.object({
|
|
19
|
+
price: v.nullable(v.number())
|
|
20
|
+
});
|
|
@@ -86,7 +86,7 @@ export type BuilderCollectionSerialised = {
|
|
|
86
86
|
export declare const BuilderCollectionSerialisedSchema: v.GenericSchema<BuilderCollectionSerialised>;
|
|
87
87
|
export declare const BuilderCollectionsSerialisedSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.GenericSchema<BuilderCollectionSerialised>, undefined>, v.ReadonlyAction<BuilderCollectionSerialised[]>]>;
|
|
88
88
|
export type BuilderCollectionsSerialised = ReadonlyArray<BuilderCollectionSerialised>;
|
|
89
|
-
export declare const validateCollectionWhen: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").
|
|
89
|
+
export declare const validateCollectionWhen: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
90
90
|
readonly type: "enable";
|
|
91
91
|
readonly payload: {
|
|
92
92
|
readonly model: {
|
|
@@ -603,7 +603,7 @@ export declare const validateCollectionWhen: (input: unknown, references?: impor
|
|
|
603
603
|
readonly tags?: readonly string[] | undefined;
|
|
604
604
|
};
|
|
605
605
|
}>;
|
|
606
|
-
export declare const validateCollectionSelectMap: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").
|
|
606
|
+
export declare const validateCollectionSelectMap: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
607
607
|
readonly [x: string]: {
|
|
608
608
|
readonly model: {
|
|
609
609
|
readonly models: readonly (/*elided*/ any & import("../../validate").BuilderValidatedBrand)[];
|
|
@@ -189,7 +189,7 @@ export declare const BuilderCollectionConfigsSerialisedSchema: v.SchemaWithPipe<
|
|
|
189
189
|
}>[]>]>;
|
|
190
190
|
export type BuilderCollectionConfigsSerialised = v.InferOutput<typeof BuilderCollectionConfigsSerialisedSchema>;
|
|
191
191
|
export declare function collectionConfig<Model extends Paramable<BuilderModelGeneric> = Paramable<BuilderModelGeneric>, Min extends Paramable<number> = Paramable<number>, Max extends Paramable<number> = Paramable<number>>(model: Model, min: Min, max: Max): BuilderCollectionConfig<Model, Min, Max>;
|
|
192
|
-
export declare const validateCollectionConfig: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").
|
|
192
|
+
export declare const validateCollectionConfig: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
193
193
|
readonly model: {
|
|
194
194
|
readonly models: readonly (/*elided*/ any & import("../../validate").BuilderValidatedBrand)[];
|
|
195
195
|
readonly options: readonly {
|
|
@@ -413,7 +413,7 @@ export declare const BuilderComponentsSerialisedSchema: v.SchemaWithPipe<readonl
|
|
|
413
413
|
tags?: readonly string[] | undefined;
|
|
414
414
|
}>[]>]>;
|
|
415
415
|
export type BuilderComponentsSerialised = v.InferOutput<typeof BuilderComponentsSerialisedSchema>;
|
|
416
|
-
export declare const validateComponentWhen: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").
|
|
416
|
+
export declare const validateComponentWhen: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
417
417
|
readonly type: "enable";
|
|
418
418
|
readonly payload: {
|
|
419
419
|
readonly fields: readonly {
|
|
@@ -455,7 +455,7 @@ export declare const validateComponentWhen: (input: unknown, references?: import
|
|
|
455
455
|
readonly tags?: readonly string[] | undefined;
|
|
456
456
|
};
|
|
457
457
|
}>;
|
|
458
|
-
export declare const validateComponentSelectMap: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").
|
|
458
|
+
export declare const validateComponentSelectMap: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
459
459
|
readonly [x: string]: {
|
|
460
460
|
readonly fields: readonly {
|
|
461
461
|
readonly type: "component-field";
|
|
@@ -133,7 +133,7 @@ export declare const BuilderComponentConfigsSerialisedSchema: v.SchemaWithPipe<r
|
|
|
133
133
|
}>[]>]>;
|
|
134
134
|
export type BuilderComponentConfigsSerialised = v.InferOutput<typeof BuilderComponentConfigsSerialisedSchema>;
|
|
135
135
|
export declare function componentConfig<const Fields extends BuilderComponentFields>(...fields: Fields): BuilderComponentConfig<Fields>;
|
|
136
|
-
export declare const validateComponentConfig: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../
|
|
136
|
+
export declare const validateComponentConfig: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors/errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
137
137
|
readonly fields: readonly {
|
|
138
138
|
readonly type: "component-field";
|
|
139
139
|
readonly name: string;
|
|
@@ -30,7 +30,7 @@ export declare const BuilderExpectationsSerialisedSchema: v.SchemaWithPipe<reado
|
|
|
30
30
|
kind: "option" | "component" | "collection";
|
|
31
31
|
}>[]>]>;
|
|
32
32
|
export type BuilderExpectationsSerialised = v.InferOutput<typeof BuilderExpectationsSerialisedSchema>;
|
|
33
|
-
export declare const validateExpectations: (input: unknown, references?: import("./references.js").BuilderReferences, errors?: import("../errors/errors.js").
|
|
33
|
+
export declare const validateExpectations: (input: unknown, references?: import("./references.js").BuilderReferences, errors?: import("../errors/errors.js").BuilderErrorsScope) => import("./validated.js").ValidationResult<readonly ({
|
|
34
34
|
readonly name: string;
|
|
35
35
|
readonly kind: "option" | "component" | "collection";
|
|
36
36
|
} & import("../validate/brand.js").BuilderValidatedBrand)[]>;
|
package/dist/entities/kind.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import type { BuilderReferences } from './references';
|
|
|
2
2
|
import type { EntitiesMap } from './serialise';
|
|
3
3
|
import type { BuilderValidatedMap, ValidationResult } from './validated';
|
|
4
4
|
import type * as v from 'valibot';
|
|
5
|
-
import {
|
|
5
|
+
import { BuilderErrorsScope } from '../errors/index.js';
|
|
6
6
|
export declare const builderEntityKinds: readonly ["builder", "model", "select", "toggle", "optionSelectMap", "optionWhen", "componentConfig", "componentSelectMap", "componentWhen", "collectionConfig", "collectionSelectMap", "collectionWhen", "ui", "uiDescribe", "uiItems", "uiPage", "uiPages", "uiInput", "pricing", "pricingRates", "expectations", "paths", "path", "number", "string", "boolean"];
|
|
7
7
|
export type BuilderEntityKind = (typeof builderEntityKinds)[number];
|
|
8
8
|
export type BuilderEntitySerialised = {
|
|
9
9
|
[Kind in BuilderEntityKind]: v.InferOutput<EntitiesMap[Kind]['serialised']>;
|
|
10
10
|
}[BuilderEntityKind];
|
|
11
|
-
export type EntityValidate<Kind extends BuilderEntityKind> = (input: BuilderValidatedMap[Kind], errors:
|
|
12
|
-
export declare function createEntityValidator<Kind extends BuilderEntityKind>(kind: Kind, schema: v.GenericSchema, validate?: EntityValidate<Kind>): (input: unknown, references?: BuilderReferences, errors?:
|
|
11
|
+
export type EntityValidate<Kind extends BuilderEntityKind> = (input: BuilderValidatedMap[Kind], errors: BuilderErrorsScope, references: BuilderReferences) => void;
|
|
12
|
+
export declare function createEntityValidator<Kind extends BuilderEntityKind>(kind: Kind, schema: v.GenericSchema, validate?: EntityValidate<Kind>): (input: unknown, references?: BuilderReferences, errors?: BuilderErrorsScope) => ValidationResult<BuilderValidatedMap[Kind]>;
|
package/dist/entities/kind.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BuilderErrorsScope, check } from '../errors/index.js';
|
|
2
2
|
export const builderEntityKinds = [
|
|
3
3
|
'builder',
|
|
4
4
|
'model',
|
|
@@ -28,9 +28,9 @@ export const builderEntityKinds = [
|
|
|
28
28
|
'boolean'
|
|
29
29
|
];
|
|
30
30
|
export function createEntityValidator(kind, schema, validate) {
|
|
31
|
-
return (input, references = [], errors = new
|
|
31
|
+
return (input, references = [], errors = new BuilderErrorsScope(input)) => {
|
|
32
32
|
if (!check.is(schema, input)) {
|
|
33
|
-
errors.
|
|
33
|
+
errors.entityInvalid(kind);
|
|
34
34
|
return [input, errors.errors];
|
|
35
35
|
}
|
|
36
36
|
validate?.(input, errors, references);
|
|
@@ -387,7 +387,7 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
387
387
|
tags?: readonly string[] | undefined;
|
|
388
388
|
}>[]>]>;
|
|
389
389
|
export type BuilderOptionsSerialised = v.InferOutput<typeof BuilderOptionsSerialisedSchema>;
|
|
390
|
-
export declare const validateOptionWhen: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").
|
|
390
|
+
export declare const validateOptionWhen: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
391
391
|
readonly type: "enable";
|
|
392
392
|
readonly payload: {
|
|
393
393
|
readonly type: "select";
|
|
@@ -447,7 +447,7 @@ export declare const validateOptionWhen: (input: unknown, references?: import(".
|
|
|
447
447
|
readonly tags?: readonly string[] | undefined;
|
|
448
448
|
};
|
|
449
449
|
}>;
|
|
450
|
-
export declare const validateOptionSelectMap: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").
|
|
450
|
+
export declare const validateOptionSelectMap: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
451
451
|
readonly [x: string]: {
|
|
452
452
|
readonly type: "select";
|
|
453
453
|
readonly options: readonly [string, ...string[]];
|
|
@@ -42,7 +42,7 @@ export declare const BuilderSelectConfigSerialisedSchema: v.SchemaWithPipe<reado
|
|
|
42
42
|
}>]>;
|
|
43
43
|
export type BuilderSelectConfigSerialised = v.InferOutput<typeof BuilderSelectConfigSerialisedSchema>;
|
|
44
44
|
export declare function selectValueSchema(options: ReadonlyArray<string>, optional: boolean): v.GenericSchema<string | null>;
|
|
45
|
-
export declare const validateSelect: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").
|
|
45
|
+
export declare const validateSelect: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
46
46
|
readonly type: "select";
|
|
47
47
|
readonly options: readonly [string, ...string[]];
|
|
48
48
|
readonly defaultValue: string | null;
|
|
@@ -55,11 +55,13 @@ export function selectValueSchema(options, optional) {
|
|
|
55
55
|
}
|
|
56
56
|
export const validateSelect = createEntityValidator('select', BuilderSelectConfigSerialisedSchema, (input, errors) => {
|
|
57
57
|
if (input.defaultValue != null && !input.options.includes(input.defaultValue)) {
|
|
58
|
-
errors.
|
|
58
|
+
errors.scope('defaultValue', () => errors.entityInvalidSelectDefault());
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
errors.scope('optionLabels', () => {
|
|
61
|
+
Object.keys(input.optionLabels).forEach((key) => {
|
|
62
|
+
if (!input.options.includes(key)) {
|
|
63
|
+
errors.scope(key, () => errors.entityInvalidSelectLabel());
|
|
64
|
+
}
|
|
65
|
+
});
|
|
64
66
|
});
|
|
65
67
|
});
|
|
@@ -36,7 +36,7 @@ export declare const BuilderToggleConfigSerialisedSchema: v.SchemaWithPipe<reado
|
|
|
36
36
|
}>]>;
|
|
37
37
|
export type BuilderToggleConfigSerialised = v.InferOutput<typeof BuilderToggleConfigSerialisedSchema>;
|
|
38
38
|
export declare function toggleValueSchema(valueType: BuilderToggleValueType, optional: boolean): v.GenericSchema;
|
|
39
|
-
export declare const validateToggle: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../
|
|
39
|
+
export declare const validateToggle: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors/errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
40
40
|
readonly type: "toggle";
|
|
41
41
|
readonly valueType: "string" | "number" | "boolean";
|
|
42
42
|
readonly defaultValue: string | number | boolean | null;
|
|
@@ -60,6 +60,6 @@ export const validateToggle = createEntityValidator('toggle', BuilderToggleConfi
|
|
|
60
60
|
}
|
|
61
61
|
const valueSchema = toggleValueSchema(input.valueType, input.isOptional);
|
|
62
62
|
if (!check.is(valueSchema, input.defaultValue)) {
|
|
63
|
-
errors.
|
|
63
|
+
errors.scope('defaultValue', () => errors.entityInvalidToggleDefault());
|
|
64
64
|
}
|
|
65
65
|
});
|
package/dist/entities/paths.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export declare const BuilderPathSchema: v.SchemaWithPipe<readonly [v.ArraySchema
|
|
|
3
3
|
export type BuilderPath = v.InferOutput<typeof BuilderPathSchema>;
|
|
4
4
|
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)[])[]>]>;
|
|
5
5
|
export type BuilderPaths = v.InferOutput<typeof BuilderPathsSchema>;
|
|
6
|
-
export declare const validatePath: (input: unknown, references?: import("./references.js").BuilderReferences, errors?: import("../errors/errors.js").
|
|
7
|
-
export declare const validatePaths: (input: unknown, references?: import("./references.js").BuilderReferences, errors?: import("../errors/errors.js").
|
|
6
|
+
export declare const validatePath: (input: unknown, references?: import("./references.js").BuilderReferences, errors?: import("../errors/errors.js").BuilderErrorsScope) => import("./validated.js").ValidationResult<readonly (string | number)[]>;
|
|
7
|
+
export declare const validatePaths: (input: unknown, references?: import("./references.js").BuilderReferences, errors?: import("../errors/errors.js").BuilderErrorsScope) => import("./validated.js").ValidationResult<readonly (readonly (string | number)[])[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
export type BuilderRates = Record<string, Record<string, number>>;
|
|
3
3
|
export declare const BuilderRatesSchema: v.GenericSchema<BuilderRates>;
|
|
4
|
-
export declare const validatePricingRates: (input: unknown, references?: import("../references.js").BuilderReferences, errors?: import("../../errors/errors.js").
|
|
4
|
+
export declare const validatePricingRates: (input: unknown, references?: import("../references.js").BuilderReferences, errors?: import("../../errors/errors.js").BuilderErrorsScope) => import("../validated.js").ValidationResult<{
|
|
5
5
|
readonly [x: string]: {
|
|
6
6
|
readonly [x: string]: number;
|
|
7
7
|
} & import("../../validate/brand.js").BuilderValidatedBrand;
|
|
@@ -1217,9 +1217,9 @@ export declare const entitiesMap: {
|
|
|
1217
1217
|
readonly serialised: v.BooleanSchema<undefined>;
|
|
1218
1218
|
};
|
|
1219
1219
|
};
|
|
1220
|
-
export declare const validateNumber: (input: unknown, references?: import("./references").BuilderReferences, errors?: import("../
|
|
1221
|
-
export declare const validateString: (input: unknown, references?: import("./references").BuilderReferences, errors?: import("../
|
|
1222
|
-
export declare const validateBoolean: (input: unknown, references?: import("./references").BuilderReferences, errors?: import("../
|
|
1220
|
+
export declare const validateNumber: (input: unknown, references?: import("./references").BuilderReferences, errors?: import("../errors/errors").BuilderErrorsScope) => import("./validated").ValidationResult<number>;
|
|
1221
|
+
export declare const validateString: (input: unknown, references?: import("./references").BuilderReferences, errors?: import("../errors/errors").BuilderErrorsScope) => import("./validated").ValidationResult<string>;
|
|
1222
|
+
export declare const validateBoolean: (input: unknown, references?: import("./references").BuilderReferences, errors?: import("../errors/errors").BuilderErrorsScope) => import("./validated").ValidationResult<boolean>;
|
|
1223
1223
|
export type EntitiesMap = typeof entitiesMap;
|
|
1224
1224
|
export type EntitiesSerialisedSchemas = EntitiesMap[BuilderEntityKind]['serialised'];
|
|
1225
1225
|
export declare const BuilderEntityKindSchema: v.PicklistSchema<readonly ["builder", "model", "select", "toggle", "optionSelectMap", "optionWhen", "componentConfig", "componentSelectMap", "componentWhen", "collectionConfig", "collectionSelectMap", "collectionWhen", "ui", "uiDescribe", "uiItems", "uiPage", "uiPages", "uiInput", "pricing", "pricingRates", "expectations", "paths", "path", "number", "string", "boolean"], undefined>;
|
|
@@ -287,7 +287,7 @@ export declare const BuilderUIDescribeSerialisedSchema: v.SchemaWithPipe<readonl
|
|
|
287
287
|
tags?: readonly string[] | undefined;
|
|
288
288
|
}>]>;
|
|
289
289
|
export type BuilderUIDescribeSerialised = v.InferOutput<typeof BuilderUIDescribeSerialisedSchema>;
|
|
290
|
-
export declare const validateUIDescribe: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").
|
|
290
|
+
export declare const validateUIDescribe: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
291
291
|
readonly type: "describe";
|
|
292
292
|
readonly label: string;
|
|
293
293
|
readonly inputs: readonly {
|
|
@@ -29,9 +29,9 @@ export const BuilderUIDescribeSerialisedSchema = serialisable(v.object({
|
|
|
29
29
|
}));
|
|
30
30
|
export const validateUIDescribe = createEntityValidator('uiDescribe', BuilderUIDescribeSerialisedSchema, (input, errors) => {
|
|
31
31
|
if (!isParamable(input.label) && input.label.length === 0) {
|
|
32
|
-
errors.
|
|
32
|
+
errors.entityEmptyLabel();
|
|
33
33
|
}
|
|
34
34
|
if (!isParamable(input.inputs) && input.inputs.length === 0) {
|
|
35
|
-
errors.
|
|
35
|
+
errors.entityEmptyInputs();
|
|
36
36
|
}
|
|
37
37
|
});
|
|
@@ -333,7 +333,7 @@ export declare const BuilderUIInputsSerialisedSchema: v.SchemaWithPipe<readonly
|
|
|
333
333
|
tags?: readonly string[] | undefined;
|
|
334
334
|
}>)[]>]>;
|
|
335
335
|
export type BuilderUIInputsSerialised = v.InferOutput<typeof BuilderUIInputsSerialisedSchema>;
|
|
336
|
-
export declare const validateUIInput: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").
|
|
336
|
+
export declare const validateUIInput: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
337
337
|
readonly type: "input";
|
|
338
338
|
readonly path: readonly (string | number)[];
|
|
339
339
|
readonly displayName?: string | undefined;
|
|
@@ -283,7 +283,7 @@ export declare const BuilderUIPageSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
283
283
|
tags?: readonly string[] | undefined;
|
|
284
284
|
}>]>;
|
|
285
285
|
export type BuilderUIPageSerialised = v.InferOutput<typeof BuilderUIPageSerialisedSchema>;
|
|
286
|
-
export declare const validateUIPage: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").
|
|
286
|
+
export declare const validateUIPage: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
287
287
|
readonly type: "page";
|
|
288
288
|
readonly label: string;
|
|
289
289
|
readonly inputs: readonly {
|
package/dist/entities/ui/page.js
CHANGED
|
@@ -27,9 +27,9 @@ export const BuilderUIPageSerialisedSchema = serialisable(v.object({
|
|
|
27
27
|
}));
|
|
28
28
|
export const validateUIPage = createEntityValidator('uiPage', BuilderUIPageSerialisedSchema, (input, errors) => {
|
|
29
29
|
if (!isParamable(input.label) && input.label.length === 0) {
|
|
30
|
-
errors.
|
|
30
|
+
errors.entityEmptyLabel();
|
|
31
31
|
}
|
|
32
32
|
if (!isParamable(input.inputs) && input.inputs.length === 0) {
|
|
33
|
-
errors.
|
|
33
|
+
errors.entityEmptyInputs();
|
|
34
34
|
}
|
|
35
35
|
});
|
|
@@ -48,7 +48,7 @@ export declare const BuilderUIItemsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
48
48
|
type: "ref";
|
|
49
49
|
id: string;
|
|
50
50
|
}> | BuilderUIItemSerialised)[]>]>;
|
|
51
|
-
export declare const validateUIPages: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").
|
|
51
|
+
export declare const validateUIPages: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
52
52
|
readonly type: "pages";
|
|
53
53
|
readonly name: string;
|
|
54
54
|
readonly label: string;
|
|
@@ -117,7 +117,7 @@ export declare const validateUIPages: (input: unknown, references?: import("..")
|
|
|
117
117
|
})[];
|
|
118
118
|
readonly tags?: readonly string[] | undefined;
|
|
119
119
|
}>;
|
|
120
|
-
export declare const validateUIItems: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").
|
|
120
|
+
export declare const validateUIItems: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").BuilderErrorsScope) => import("..").ValidationResult<readonly ({
|
|
121
121
|
readonly type: "page";
|
|
122
122
|
readonly label: string;
|
|
123
123
|
readonly inputs: readonly {
|
|
@@ -37,10 +37,10 @@ export const BuilderUIItemSerialisedSchema = v.union([
|
|
|
37
37
|
export const BuilderUIItemsSerialisedSchema = v.pipe(v.array(paramable(BuilderUIItemSerialisedSchema)), v.readonly());
|
|
38
38
|
export const validateUIPages = createEntityValidator('uiPages', BuilderUIPagesSerialisedSchema, (input, errors) => {
|
|
39
39
|
if (input.name.length === 0) {
|
|
40
|
-
errors.
|
|
40
|
+
errors.entityEmptyName();
|
|
41
41
|
}
|
|
42
42
|
if (!isParamable(input.label) && input.label.length === 0) {
|
|
43
|
-
errors.
|
|
43
|
+
errors.entityEmptyLabel();
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
export const validateUIItems = createEntityValidator('uiItems', BuilderUIItemsSerialisedSchema);
|
package/dist/errors/check.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
declare class Check {
|
|
3
|
-
|
|
4
|
-
falsy(input: unknown, message: `${string}! ❌`): void;
|
|
3
|
+
invariant<Input>(input: Input): asserts input is Exclude<Input, null | undefined | '' | 0 | false>;
|
|
5
4
|
is<const Schema extends v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>>(schema: Schema, input: unknown): input is v.InferOutput<Schema>;
|
|
6
|
-
assert<const Schema extends v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>>(schema: Schema, input: unknown
|
|
5
|
+
assert<const Schema extends v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>>(schema: Schema, input: unknown): asserts input is v.InferOutput<Schema>;
|
|
7
6
|
}
|
|
8
7
|
export declare const check: Check;
|
|
9
8
|
export {};
|