@builder-builder/builder 0.0.7 → 0.0.9
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/check.d.ts +2 -1
- package/dist/check.js +6 -2
- package/dist/entities/builder/builder.d.ts +494 -0
- package/dist/entities/builder/builder.js +84 -0
- package/dist/entities/builder/builders.d.ts +20 -0
- package/dist/entities/builder/builders.js +18 -0
- package/dist/entities/builder/expectation.d.ts +12 -0
- package/dist/entities/builder/index.d.ts +7 -0
- package/dist/entities/builder/index.js +3 -0
- package/dist/entities/builder/methods.d.ts +58 -0
- package/dist/entities/builder/methods.js +30 -0
- package/dist/entities/builder/parameter.d.ts +62 -0
- package/dist/entities/builder/parameter.js +18 -0
- package/dist/entities/builder/state.d.ts +26 -0
- package/dist/entities/builder/validate.d.ts +3 -0
- package/dist/entities/builder/validate.js +108 -0
- package/dist/entities/collection/collection.d.ts +37 -0
- package/dist/entities/collection/collection.js +42 -0
- package/dist/entities/collection/config.d.ts +1094 -0
- package/dist/entities/collection/config.js +23 -0
- package/dist/entities/collection/expectation.d.ts +7 -0
- package/dist/entities/collection/expectation.js +4 -0
- package/dist/entities/collection/index.d.ts +8 -0
- package/dist/entities/collection/index.js +4 -0
- package/dist/entities/collection/when.d.ts +9 -0
- package/dist/entities/collection/when.js +2 -0
- package/dist/entities/component/component.d.ts +403 -0
- package/dist/entities/component/component.js +24 -0
- package/dist/entities/component/details.d.ts +82 -0
- package/dist/entities/component/details.js +17 -0
- package/dist/entities/component/expectation.d.ts +8 -0
- package/dist/entities/component/expectation.js +7 -0
- package/dist/entities/component/index.d.ts +8 -0
- package/dist/entities/component/index.js +4 -0
- package/dist/entities/component/when.d.ts +11 -0
- package/dist/entities/component/when.js +20 -0
- package/dist/entities/errors.d.ts +21 -0
- package/dist/entities/expectation.d.ts +44 -0
- package/dist/entities/expectation.js +23 -0
- package/dist/entities/index.d.ts +18 -0
- package/dist/entities/index.js +9 -0
- package/dist/entities/option/expectation.d.ts +2 -0
- package/dist/entities/option/expectation.js +4 -0
- package/dist/entities/option/index.d.ts +11 -0
- package/dist/entities/option/index.js +6 -0
- package/dist/entities/option/option.d.ts +347 -0
- package/dist/entities/option/option.js +24 -0
- package/dist/entities/option/select.d.ts +49 -0
- package/dist/entities/option/select.js +40 -0
- package/dist/entities/option/toggle.d.ts +39 -0
- package/dist/entities/option/toggle.js +42 -0
- package/dist/entities/option/values.d.ts +63 -0
- package/dist/entities/option/values.js +8 -0
- package/dist/entities/option/when.d.ts +9 -0
- package/dist/entities/option/when.js +2 -0
- package/dist/entities/serialise.d.ts +3801 -0
- package/dist/entities/serialise.js +41 -0
- package/dist/entities/ui/describe.d.ts +100 -0
- package/dist/entities/ui/describe.js +22 -0
- package/dist/entities/ui/index.d.ts +14 -0
- package/dist/entities/ui/index.js +7 -0
- package/dist/entities/ui/label.d.ts +18 -0
- package/dist/entities/ui/label.js +12 -0
- package/dist/entities/ui/page.d.ts +96 -0
- package/dist/entities/ui/page.js +20 -0
- package/dist/entities/ui/pages.d.ts +431 -0
- package/dist/entities/ui/pages.js +29 -0
- package/dist/entities/ui/parameter.d.ts +7 -0
- package/dist/entities/ui/parameter.js +29 -0
- package/dist/entities/ui/ui.d.ts +1582 -0
- package/dist/entities/ui/ui.js +53 -0
- package/dist/entities/ui/uis.d.ts +10 -0
- package/dist/entities/ui/uis.js +20 -0
- package/dist/entities/ui/validate.d.ts +8 -0
- package/dist/entities/ui/validate.js +21 -0
- package/dist/entities/validate.d.ts +28 -0
- package/dist/entities/validate.js +1 -0
- package/dist/entities/when.d.ts +176 -0
- package/dist/entities/when.js +47 -0
- package/dist/exception.d.ts +8 -0
- package/dist/exception.js +7 -0
- package/dist/index.d.ts +38 -13
- package/dist/index.js +23 -5
- package/dist/mappers/assert/builder.d.ts +2 -0
- package/dist/mappers/assert/builder.js +46 -0
- package/dist/mappers/assert/expectation.d.ts +2 -0
- package/dist/mappers/assert/expectation.js +23 -0
- package/dist/mappers/assert/index.d.ts +6 -0
- package/dist/mappers/assert/index.js +4 -0
- package/dist/mappers/assert/model.d.ts +13 -0
- package/dist/mappers/assert/model.js +47 -0
- package/dist/mappers/assert/models.d.ts +33 -0
- package/dist/mappers/assert/models.js +74 -0
- package/dist/mappers/assert/ui.d.ts +2 -0
- package/dist/mappers/assert/ui.js +22 -0
- package/dist/mappers/index.d.ts +7 -0
- package/dist/mappers/index.js +4 -0
- package/dist/mappers/instance/index.d.ts +1 -0
- package/dist/mappers/instance/index.js +1 -0
- package/dist/mappers/instance/instance.d.ts +4 -0
- package/dist/mappers/instance/instance.js +33 -0
- package/dist/mappers/models/component-graph.d.ts +9 -0
- package/dist/{core/component/graph.js → mappers/models/component-graph.js} +3 -3
- package/dist/{core → mappers/models}/graph.d.ts +4 -1
- package/dist/mappers/models/graph.js +17 -0
- package/dist/mappers/models/index.d.ts +1 -0
- package/dist/mappers/models/index.js +1 -0
- package/dist/mappers/models/models.d.ts +3 -0
- package/dist/mappers/models/models.js +37 -0
- package/dist/mappers/models/option-graph.d.ts +9 -0
- package/dist/mappers/models/option-graph.js +77 -0
- package/dist/mappers/order/index.d.ts +2 -0
- package/dist/mappers/order/index.js +1 -0
- package/dist/mappers/order/order.d.ts +14 -0
- package/dist/mappers/order/order.js +31 -0
- package/dist/mappers/render/index.d.ts +4 -0
- package/dist/mappers/render/index.js +2 -0
- package/dist/mappers/render/ordinal.d.ts +1 -0
- package/dist/mappers/render/ordinal.js +20 -0
- package/dist/mappers/render/pages.d.ts +15 -0
- package/dist/mappers/render/pages.js +1 -0
- package/dist/mappers/render/render.d.ts +8 -0
- package/dist/mappers/render/render.js +124 -0
- package/dist/mappers/resolve.d.ts +9 -0
- package/dist/mappers/resolve.js +57 -0
- package/dist/model.d.ts +8 -8
- package/dist/paths.d.ts +5 -16
- package/dist/paths.js +3 -0
- package/dist/primitive.d.ts +5 -0
- package/dist/{schemas/primitives.js → primitive.js} +0 -2
- package/dist/references.d.ts +60 -0
- package/dist/references.js +26 -0
- package/dist/serialisable.d.ts +10 -0
- package/dist/serialisable.js +5 -0
- package/dist/walker/index.d.ts +2 -0
- package/dist/walker/index.js +1 -0
- package/dist/walker/walkable.d.ts +4 -0
- package/dist/walker/walkable.js +4 -0
- package/dist/walker/walker.d.ts +18 -0
- package/dist/walker/walker.js +103 -0
- package/dist/walker/walkers.d.ts +8 -0
- package/dist/walker/walkers.js +51 -0
- package/package.json +8 -2
- package/dist/core/builder.d.ts +0 -74
- package/dist/core/builder.js +0 -109
- package/dist/core/collection/collection.d.ts +0 -32
- package/dist/core/collection/collection.js +0 -37
- package/dist/core/collection/index.d.ts +0 -4
- package/dist/core/collection/index.js +0 -2
- package/dist/core/collection/method.d.ts +0 -30
- package/dist/core/collection/method.js +0 -11
- package/dist/core/component/component.d.ts +0 -9
- package/dist/core/component/component.js +0 -10
- package/dist/core/component/graph.d.ts +0 -9
- package/dist/core/component/index.d.ts +0 -4
- package/dist/core/component/index.js +0 -2
- package/dist/core/component/method.d.ts +0 -11
- package/dist/core/expectation.d.ts +0 -42
- package/dist/core/expectation.js +0 -18
- package/dist/core/graph.js +0 -3
- package/dist/core/index.d.ts +0 -14
- package/dist/core/index.js +0 -7
- package/dist/core/option/graph.d.ts +0 -10
- package/dist/core/option/graph.js +0 -78
- package/dist/core/option/index.d.ts +0 -10
- package/dist/core/option/index.js +0 -5
- package/dist/core/option/method.d.ts +0 -70
- package/dist/core/option/method.js +0 -13
- package/dist/core/option/option.d.ts +0 -30
- package/dist/core/option/option.js +0 -42
- package/dist/core/option/select.d.ts +0 -22
- package/dist/core/option/select.js +0 -34
- package/dist/core/option/toggle.d.ts +0 -16
- package/dist/core/option/toggle.js +0 -29
- package/dist/core/parameter.d.ts +0 -48
- package/dist/core/parameter.js +0 -31
- package/dist/core/validate.d.ts +0 -26
- package/dist/core/validate.js +0 -43
- package/dist/core/when/config.d.ts +0 -20
- package/dist/core/when/config.js +0 -4
- package/dist/core/when/constrain.d.ts +0 -14
- package/dist/core/when/index.d.ts +0 -5
- package/dist/core/when/index.js +0 -2
- package/dist/core/when/nullability.d.ts +0 -18
- package/dist/core/when/resolve.d.ts +0 -18
- package/dist/core/when/resolve.js +0 -22
- package/dist/resolve/index.d.ts +0 -10
- package/dist/resolve/index.js +0 -5
- package/dist/resolve/instance.d.ts +0 -35
- package/dist/resolve/instance.js +0 -80
- package/dist/resolve/models.d.ts +0 -3
- package/dist/resolve/models.js +0 -20
- package/dist/resolve/order.d.ts +0 -21
- package/dist/resolve/order.js +0 -27
- package/dist/resolve/render.d.ts +0 -23
- package/dist/resolve/render.js +0 -171
- package/dist/resolve/validate.d.ts +0 -37
- package/dist/resolve/validate.js +0 -47
- package/dist/schemas/description.d.ts +0 -5
- package/dist/schemas/description.js +0 -3
- package/dist/schemas/index.d.ts +0 -6
- package/dist/schemas/index.js +0 -3
- package/dist/schemas/primitives.d.ts +0 -9
- package/dist/schemas/ui.d.ts +0 -96
- package/dist/schemas/ui.js +0 -23
- package/dist/serialise/deserialise.d.ts +0 -14
- package/dist/serialise/deserialise.js +0 -119
- package/dist/serialise/index.d.ts +0 -6
- package/dist/serialise/index.js +0 -4
- package/dist/serialise/schemas.d.ts +0 -1946
- package/dist/serialise/schemas.js +0 -150
- package/dist/serialise/serialise.d.ts +0 -13
- package/dist/serialise/serialise.js +0 -147
- package/dist/serialise/validate.d.ts +0 -26
- package/dist/serialise/validate.js +0 -148
- package/dist/ui.d.ts +0 -19
- package/dist/ui.js +0 -44
- /package/dist/{core/component/method.js → entities/builder/expectation.js} +0 -0
- /package/dist/{core/when/constrain.js → entities/builder/state.js} +0 -0
- /package/dist/{core/when/nullability.js → entities/errors.js} +0 -0
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { BuilderPrimitive } from '../../model';
|
|
2
|
-
import type { BuilderPath, BuilderResolvePath, BuilderValidPath, BuilderValidPaths } from '../../paths';
|
|
3
|
-
import type { BuilderMerge, BuilderState } from '../builder';
|
|
4
|
-
import type { BuilderWhenEnableConfig, BuilderWhenMatchConfig, BuilderWhenUnlessConfig, WhenNullability, WhenPathsNullable } from '../when/index';
|
|
5
|
-
import type { BuilderOption, BuilderOptionValueType, BuilderOptionValues, BuilderOptionValuesMap } from './option';
|
|
6
|
-
import { BuilderParameter } from '../parameter.js';
|
|
7
|
-
export type BuilderOptionEnableConfig<Values extends BuilderOptionValues | BuilderParameter = BuilderOptionValues | BuilderParameter> = BuilderWhenEnableConfig<OptionPayload<Values>>;
|
|
8
|
-
export type BuilderOptionMatchConfig<SelectMap extends BuilderOptionValuesMap | BuilderParameter = BuilderOptionValuesMap | BuilderParameter, MatchPath extends BuilderPath = BuilderPath> = BuilderWhenMatchConfig<SelectMap, MatchPath>;
|
|
9
|
-
export type BuilderOptionUnlessConfig<Values extends BuilderOptionValues | BuilderParameter = BuilderOptionValues | BuilderParameter, UnlessPath extends BuilderPath = BuilderPath> = BuilderWhenUnlessConfig<OptionPayload<Values>, UnlessPath>;
|
|
10
|
-
export type BuilderOptionWhenConfig = BuilderOptionEnableConfig | BuilderOptionMatchConfig | BuilderOptionUnlessConfig;
|
|
11
|
-
export type BuilderOptionWhenConfigValues<Config extends BuilderOptionWhenConfig> = Config extends {
|
|
12
|
-
readonly values: infer Values;
|
|
13
|
-
} ? Values extends BuilderOptionValues ? Values : never : Config extends BuilderOptionMatchConfig<infer SelectMapType> ? SelectMapType extends BuilderOptionValuesMap ? NonNullable<SelectMapType[keyof SelectMapType]> & BuilderOptionValues : never : never;
|
|
14
|
-
export type BuilderOptionMethod<State extends BuilderState> = {
|
|
15
|
-
<const Name extends string, const Values extends BuilderOptionValues>(name: Name, values: Values): BuilderMerge<State, {
|
|
16
|
-
model: State['model'] & {
|
|
17
|
-
[K in Name]: BuilderOptionValueType<Values>;
|
|
18
|
-
};
|
|
19
|
-
options: [...State['options'], BuilderOption<Name, Values>];
|
|
20
|
-
}>;
|
|
21
|
-
<const Name extends string>(name: Name, values: BuilderParameter): BuilderMerge<State, {
|
|
22
|
-
model: State['model'] & {
|
|
23
|
-
[K in Name]: string;
|
|
24
|
-
};
|
|
25
|
-
options: [...State['options'], BuilderOption<Name, BuilderParameter>];
|
|
26
|
-
}>;
|
|
27
|
-
when: {
|
|
28
|
-
<const GatePaths extends BuilderValidPaths<State['model']>, const Name extends string>(gatePaths: GatePaths, name: Name, config: BuilderParameter): BuilderMerge<State, {
|
|
29
|
-
model: State['model'] & {
|
|
30
|
-
[K in Name]: string | WhenPathsNullable<State['model'], GatePaths>;
|
|
31
|
-
};
|
|
32
|
-
options: [...State['options'], BuilderOption<Name, BuilderParameter>];
|
|
33
|
-
}>;
|
|
34
|
-
<const GatePaths extends BuilderValidPaths<State['model']>, const Name extends string, const Config extends BuilderOptionWhenConfig>(gatePaths: GatePaths, name: Name, config: Config & ValidOptionWhenConfig<State['model'], Config>): BuilderMerge<State, OptionWhenResult<State, GatePaths, Name, Config>>;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
export declare const enable: typeof createEnable & {
|
|
38
|
-
parameter: () => BuilderParameter;
|
|
39
|
-
};
|
|
40
|
-
export declare const match: typeof createMatch & {
|
|
41
|
-
parameter: () => BuilderParameter;
|
|
42
|
-
};
|
|
43
|
-
export declare const unless: typeof createUnless & {
|
|
44
|
-
parameter: () => BuilderParameter;
|
|
45
|
-
};
|
|
46
|
-
type OptionPayload<Values extends BuilderOptionValues | BuilderParameter = BuilderOptionValues | BuilderParameter> = {
|
|
47
|
-
readonly values: Values;
|
|
48
|
-
};
|
|
49
|
-
type WhenParameterOf<Config extends BuilderOptionWhenConfig> = Config extends {
|
|
50
|
-
readonly values: infer Values;
|
|
51
|
-
} ? Values extends BuilderParameter ? Values : never : never;
|
|
52
|
-
type OptionWhenResult<State extends BuilderState, GatePaths extends BuilderValidPaths<State['model']>, Name extends string, Config extends BuilderOptionWhenConfig> = WhenParameterOf<Config> extends never ? {
|
|
53
|
-
model: State['model'] & {
|
|
54
|
-
[K in Name]: BuilderOptionValueType<BuilderOptionWhenConfigValues<Config>> | WhenNullability<State['model'], GatePaths, Config>;
|
|
55
|
-
};
|
|
56
|
-
options: [...State['options'], BuilderOption<Name, BuilderOptionWhenConfigValues<Config>>];
|
|
57
|
-
} : {
|
|
58
|
-
model: State['model'] & {
|
|
59
|
-
[K in Name]: string | null;
|
|
60
|
-
};
|
|
61
|
-
options: [...State['options'], BuilderOption<Name, WhenParameterOf<Config>>];
|
|
62
|
-
};
|
|
63
|
-
type WhenMatchKeyOf<Model, Config extends BuilderOptionWhenConfig> = Config extends BuilderOptionMatchConfig<any, infer MatchPath> ? BuilderResolvePath<Model, MatchPath> & string : string;
|
|
64
|
-
type ValidOptionWhenConfig<Model, Config extends BuilderOptionWhenConfig> = Config extends BuilderOptionMatchConfig<infer SelectMap, infer MatchPath> ? SelectMap extends BuilderParameter ? BuilderOptionMatchConfig<SelectMap, MatchPath & Readonly<BuilderValidPath<Model>>> : BuilderOptionMatchConfig<Record<WhenMatchKeyOf<Model, Config>, BuilderOptionValuesMap[string]>, MatchPath & Readonly<BuilderValidPath<Model>>> : Config extends BuilderOptionUnlessConfig<infer Values, infer UnlessPath> ? Values extends BuilderParameter ? BuilderOptionUnlessConfig<Values, UnlessPath & Readonly<BuilderValidPath<Model>>> : Config & {
|
|
65
|
-
readonly unlessPath: Readonly<BuilderValidPath<Model>>;
|
|
66
|
-
} : Config;
|
|
67
|
-
declare function createEnable<const Values extends BuilderOptionValues>(values: Values): BuilderOptionEnableConfig<Values>;
|
|
68
|
-
declare function createMatch<const MatchPath extends BuilderPath, const SelectMap extends BuilderOptionValuesMap>(matchPath: MatchPath, selectMap: SelectMap): BuilderOptionMatchConfig<SelectMap, MatchPath>;
|
|
69
|
-
declare function createUnless<const Values extends BuilderOptionValues, const UnlessPath extends BuilderPath>(unlessPath: UnlessPath, disabledValues: ReadonlyArray<BuilderPrimitive>, values: Values): BuilderOptionUnlessConfig<Values, UnlessPath>;
|
|
70
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BuilderParameter } from '../parameter.js';
|
|
2
|
-
export const enable = Object.assign(createEnable, { parameter: () => new BuilderParameter() });
|
|
3
|
-
export const match = Object.assign(createMatch, { parameter: () => new BuilderParameter() });
|
|
4
|
-
export const unless = Object.assign(createUnless, { parameter: () => new BuilderParameter() });
|
|
5
|
-
function createEnable(values) {
|
|
6
|
-
return { type: 'enable', values };
|
|
7
|
-
}
|
|
8
|
-
function createMatch(matchPath, selectMap) {
|
|
9
|
-
return { type: 'match', matchPath, selectMap };
|
|
10
|
-
}
|
|
11
|
-
function createUnless(unlessPath, disabledValues, values) {
|
|
12
|
-
return { type: 'unless', unlessPath, disabledValues, values };
|
|
13
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { BuilderPaths } from '../../paths';
|
|
2
|
-
import type { BuilderParameter } from '../parameter';
|
|
3
|
-
import type { BuilderOptionWhenConfig } from './method';
|
|
4
|
-
import type { BuilderSelectTypeValues } from './select';
|
|
5
|
-
import * as v from 'valibot';
|
|
6
|
-
import { BuilderSelectType } from './select.js';
|
|
7
|
-
import { BuilderToggleType } from './toggle.js';
|
|
8
|
-
export declare const BuilderOptionValuesSchema: v.UnionSchema<[v.InstanceSchema<typeof BuilderSelectType, undefined>, v.InstanceSchema<typeof BuilderToggleType, undefined>], undefined>;
|
|
9
|
-
export type BuilderOptionValues = v.InferOutput<typeof BuilderOptionValuesSchema>;
|
|
10
|
-
export declare const BuilderOptionValuesMapSchema: v.RecordSchema<v.StringSchema<undefined>, v.NullableSchema<v.UnionSchema<[v.InstanceSchema<typeof BuilderSelectType, undefined>, v.InstanceSchema<typeof BuilderToggleType, undefined>], undefined>, undefined>, undefined>;
|
|
11
|
-
export type BuilderOptionValuesMap = v.InferOutput<typeof BuilderOptionValuesMapSchema>;
|
|
12
|
-
export type BuilderOptionValueSchema = v.GenericSchema<string | number | boolean | null>;
|
|
13
|
-
export type BuilderSelectTypeGeneric = BuilderSelectType<BuilderSelectTypeValues, BuilderOptionValueSchema>;
|
|
14
|
-
export type BuilderToggleTypeGeneric = BuilderToggleType<BuilderOptionValueSchema>;
|
|
15
|
-
export type BuilderOptionValueType<Values> = Values extends BuilderParameter ? string : Values extends {
|
|
16
|
-
readonly value: infer Value;
|
|
17
|
-
} ? Value : never;
|
|
18
|
-
export type BuilderOptionEntries = ReadonlyArray<BuilderOption>;
|
|
19
|
-
export declare class BuilderOption<const Name extends string = string, const Values extends BuilderOptionValues | BuilderParameter = BuilderOptionValues | BuilderParameter> {
|
|
20
|
-
readonly model: {
|
|
21
|
-
[K in Name]: BuilderOptionValueType<Values>;
|
|
22
|
-
};
|
|
23
|
-
readonly name: Name;
|
|
24
|
-
readonly values: Values;
|
|
25
|
-
readonly gatePaths: BuilderPaths;
|
|
26
|
-
readonly config: BuilderOptionWhenConfig | null;
|
|
27
|
-
constructor(name: Name, values: Values, gatePaths?: BuilderPaths, config?: BuilderOptionWhenConfig | null);
|
|
28
|
-
resolve(model: unknown): BuilderOption<Name, BuilderOptionValues> | null;
|
|
29
|
-
dependencyKeys(): ReadonlyArray<string>;
|
|
30
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as v from 'valibot';
|
|
2
|
-
import { check } from '../../check.js';
|
|
3
|
-
import { resolve } from '../when/index.js';
|
|
4
|
-
import { BuilderSelectType } from './select.js';
|
|
5
|
-
import { BuilderToggleType } from './toggle.js';
|
|
6
|
-
export const BuilderOptionValuesSchema = v.union([
|
|
7
|
-
v.instance(BuilderSelectType),
|
|
8
|
-
v.instance(BuilderToggleType)
|
|
9
|
-
]);
|
|
10
|
-
export const BuilderOptionValuesMapSchema = v.record(v.string(), v.nullable(BuilderOptionValuesSchema));
|
|
11
|
-
export class BuilderOption {
|
|
12
|
-
name;
|
|
13
|
-
values;
|
|
14
|
-
gatePaths;
|
|
15
|
-
config;
|
|
16
|
-
constructor(name, values, gatePaths = [], config = null) {
|
|
17
|
-
this.name = name;
|
|
18
|
-
this.values = values;
|
|
19
|
-
this.gatePaths = gatePaths;
|
|
20
|
-
this.config = config;
|
|
21
|
-
}
|
|
22
|
-
resolve(model) {
|
|
23
|
-
check.assert(BuilderOptionValuesSchema, this.values);
|
|
24
|
-
return resolve(this, model, (selectMap, matchValue) => {
|
|
25
|
-
check.assert(BuilderOptionValuesMapSchema, selectMap);
|
|
26
|
-
const entry = selectMap[matchValue];
|
|
27
|
-
return entry ? new BuilderOption(this.name, entry) : null;
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
dependencyKeys() {
|
|
31
|
-
const keys = new Set(this.gatePaths.map(([first]) => String(first)));
|
|
32
|
-
if (this.config?.type === 'match') {
|
|
33
|
-
const [firstMatchSegment] = this.config.matchPath;
|
|
34
|
-
keys.add(String(firstMatchSegment));
|
|
35
|
-
}
|
|
36
|
-
else if (this.config?.type === 'unless') {
|
|
37
|
-
const [firstUnlessSegment] = this.config.unlessPath;
|
|
38
|
-
keys.add(String(firstUnlessSegment));
|
|
39
|
-
}
|
|
40
|
-
return Array.from(keys);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { BuilderOptionValueSchema } from './option';
|
|
2
|
-
import * as v from 'valibot';
|
|
3
|
-
import { BuilderParameter } from '../parameter.js';
|
|
4
|
-
export type BuilderSelectTypeValues = readonly [string, ...ReadonlyArray<string>];
|
|
5
|
-
export type BuilderSelectTypeLabels<Values extends BuilderSelectTypeValues> = Partial<Record<Values[number], string>>;
|
|
6
|
-
export declare class BuilderSelectType<const Values extends BuilderSelectTypeValues = BuilderSelectTypeValues, const ValueSchema extends BuilderOptionValueSchema = BuilderOptionValueSchema> {
|
|
7
|
-
readonly value: v.InferOutput<ValueSchema>;
|
|
8
|
-
readonly options: Values;
|
|
9
|
-
readonly valueSchema: ValueSchema;
|
|
10
|
-
readonly defaultValue: v.InferOutput<ValueSchema>;
|
|
11
|
-
readonly isOptional: boolean;
|
|
12
|
-
readonly optionLabels: BuilderSelectTypeLabels<Values>;
|
|
13
|
-
constructor(values: Values, valueSchema: ValueSchema, defaultValue: v.InferOutput<ValueSchema>, optional?: boolean, optionLabels?: BuilderSelectTypeLabels<Values>);
|
|
14
|
-
default(newDefault: v.InferOutput<ValueSchema>): BuilderSelectType<Values, ValueSchema>;
|
|
15
|
-
optional(): BuilderSelectType<Values, v.NullableSchema<ValueSchema, undefined>>;
|
|
16
|
-
labels(optionLabels: BuilderSelectTypeLabels<Values>): BuilderSelectType<Values, ValueSchema>;
|
|
17
|
-
}
|
|
18
|
-
declare function createSelect<const Values extends BuilderSelectTypeValues>(values: Values): BuilderSelectType<Values, v.UnionSchema<v.LiteralSchema<Values[number], undefined>[], undefined>>;
|
|
19
|
-
export declare const select: typeof createSelect & {
|
|
20
|
-
parameter: () => BuilderParameter;
|
|
21
|
-
};
|
|
22
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as v from 'valibot';
|
|
2
|
-
import { BuilderParameter } from '../parameter.js';
|
|
3
|
-
export class BuilderSelectType {
|
|
4
|
-
options;
|
|
5
|
-
valueSchema;
|
|
6
|
-
defaultValue;
|
|
7
|
-
isOptional;
|
|
8
|
-
optionLabels;
|
|
9
|
-
constructor(values, valueSchema, defaultValue, optional = false, optionLabels = {}) {
|
|
10
|
-
this.options = values;
|
|
11
|
-
this.valueSchema = valueSchema;
|
|
12
|
-
this.defaultValue = defaultValue;
|
|
13
|
-
this.isOptional = optional;
|
|
14
|
-
this.optionLabels = optionLabels;
|
|
15
|
-
}
|
|
16
|
-
default(newDefault) {
|
|
17
|
-
return new BuilderSelectType(this.options, this.valueSchema, newDefault, this.isOptional, this.optionLabels);
|
|
18
|
-
}
|
|
19
|
-
optional() {
|
|
20
|
-
const { options, defaultValue } = this;
|
|
21
|
-
return new BuilderSelectType(options, v.nullable(this.valueSchema), defaultValue, true, this.optionLabels);
|
|
22
|
-
}
|
|
23
|
-
labels(optionLabels) {
|
|
24
|
-
return new BuilderSelectType(this.options, this.valueSchema, this.defaultValue, this.isOptional, optionLabels);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function createSelect(values) {
|
|
28
|
-
const [defaultValue] = values;
|
|
29
|
-
const valueSchema = v.union(values.map((value) => v.literal(value)));
|
|
30
|
-
return new BuilderSelectType(values, valueSchema, defaultValue, false);
|
|
31
|
-
}
|
|
32
|
-
export const select = Object.assign(createSelect, {
|
|
33
|
-
parameter: () => new BuilderParameter()
|
|
34
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { BuilderOptionValueSchema } from './option';
|
|
2
|
-
import * as v from 'valibot';
|
|
3
|
-
export type BuilderToggleValueType = 'string' | 'boolean' | 'number';
|
|
4
|
-
export declare class BuilderToggleType<const ValueSchema extends BuilderOptionValueSchema = BuilderOptionValueSchema> {
|
|
5
|
-
readonly value: v.InferOutput<ValueSchema>;
|
|
6
|
-
readonly valueType: BuilderToggleValueType;
|
|
7
|
-
readonly valueSchema: ValueSchema;
|
|
8
|
-
readonly defaultValue: v.InferOutput<ValueSchema>;
|
|
9
|
-
readonly isOptional: boolean;
|
|
10
|
-
constructor(valueType: BuilderToggleValueType, valueSchema: ValueSchema, defaultValue: v.InferOutput<ValueSchema>, optional?: boolean);
|
|
11
|
-
default(newDefault: v.InferOutput<ValueSchema>): BuilderToggleType<ValueSchema>;
|
|
12
|
-
optional(): BuilderToggleType<v.NullableSchema<ValueSchema, undefined>>;
|
|
13
|
-
}
|
|
14
|
-
export declare function toggleString(): BuilderToggleType<v.StringSchema<undefined>>;
|
|
15
|
-
export declare function toggleBoolean(): BuilderToggleType<v.BooleanSchema<undefined>>;
|
|
16
|
-
export declare function toggleNumber(): BuilderToggleType<v.NumberSchema<undefined>>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as v from 'valibot';
|
|
2
|
-
export class BuilderToggleType {
|
|
3
|
-
valueType;
|
|
4
|
-
valueSchema;
|
|
5
|
-
defaultValue;
|
|
6
|
-
isOptional;
|
|
7
|
-
constructor(valueType, valueSchema, defaultValue, optional) {
|
|
8
|
-
this.valueType = valueType;
|
|
9
|
-
this.valueSchema = valueSchema;
|
|
10
|
-
this.defaultValue = defaultValue;
|
|
11
|
-
this.isOptional = optional || false;
|
|
12
|
-
}
|
|
13
|
-
default(newDefault) {
|
|
14
|
-
return new BuilderToggleType(this.valueType, this.valueSchema, newDefault, this.isOptional);
|
|
15
|
-
}
|
|
16
|
-
optional() {
|
|
17
|
-
const { valueType, valueSchema, defaultValue } = this;
|
|
18
|
-
return new BuilderToggleType(valueType, v.nullable(valueSchema), defaultValue, true);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
export function toggleString() {
|
|
22
|
-
return new BuilderToggleType('string', v.string(), '');
|
|
23
|
-
}
|
|
24
|
-
export function toggleBoolean() {
|
|
25
|
-
return new BuilderToggleType('boolean', v.boolean(), false);
|
|
26
|
-
}
|
|
27
|
-
export function toggleNumber() {
|
|
28
|
-
return new BuilderToggleType('number', v.number(), 0);
|
|
29
|
-
}
|
package/dist/core/parameter.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { BuilderValidPath } from '../paths';
|
|
2
|
-
import type { BuilderState, BuilderStateMerge } from './builder';
|
|
3
|
-
import type { BuilderOption, BuilderOptionEnableConfig, BuilderOptionEntries, BuilderOptionMatchConfig, BuilderOptionUnlessConfig, BuilderOptionValues, BuilderOptionWhenConfig } from './option/index';
|
|
4
|
-
import type { WhenConfigNullable } from './when/index';
|
|
5
|
-
import * as v from 'valibot';
|
|
6
|
-
export declare class BuilderParameter {
|
|
7
|
-
readonly parameter: true;
|
|
8
|
-
}
|
|
9
|
-
export declare const BuilderParameterSchema: v.InstanceSchema<typeof BuilderParameter, undefined>;
|
|
10
|
-
export type ParameterisedOptions<Options extends BuilderOptionEntries> = {
|
|
11
|
-
[K in keyof Options]: Options[K] extends BuilderOption<infer Name, infer Values> ? Values extends BuilderParameter ? BuilderOption<Name, Values> : never : never;
|
|
12
|
-
}[number];
|
|
13
|
-
export type BuilderBindings<State extends BuilderState> = {
|
|
14
|
-
readonly [P in ParameterisedOptions<State['options']> as P['name']]?: ValidBinding<State['model']>;
|
|
15
|
-
};
|
|
16
|
-
export type ReplaceOption<Options extends BuilderOptionEntries, BoundNames extends string> = Options extends readonly [
|
|
17
|
-
infer Head extends BuilderOption,
|
|
18
|
-
...infer Tail extends BuilderOptionEntries
|
|
19
|
-
] ? Head extends BuilderOption<infer Name, infer Values> ? Values extends BuilderParameter ? Name extends BoundNames ? [...ReplaceOption<Tail, BoundNames>] : [Head, ...ReplaceOption<Tail, BoundNames>] : [Head, ...ReplaceOption<Tail, BoundNames>] : [Head, ...ReplaceOption<Tail, BoundNames>] : [];
|
|
20
|
-
export type BuilderBoundState<State extends BuilderState, Bindings extends Record<string, unknown>> = BuilderStateMerge<State, {
|
|
21
|
-
options: ReplaceOption<State['options'], Extract<keyof Bindings, string>>;
|
|
22
|
-
model: Omit<State['model'], keyof Bindings> & {
|
|
23
|
-
[K in Extract<keyof Bindings, string>]: BindingModelType<Bindings[K]>;
|
|
24
|
-
};
|
|
25
|
-
}>;
|
|
26
|
-
export declare function extractValues(config: BuilderOptionWhenConfig): BuilderOptionValues;
|
|
27
|
-
export declare function bindOptions<Bindings extends Record<string, unknown>>(options: BuilderOptionEntries, bindings: Bindings): BuilderOptionEntries;
|
|
28
|
-
type ValidEnableConfig = BuilderOptionEnableConfig<BuilderOptionEnableConfig['values']>;
|
|
29
|
-
type ValidMatchConfig<Model> = BuilderOptionMatchConfig<BuilderOptionMatchConfig['selectMap'], Readonly<BuilderValidPath<Model>>>;
|
|
30
|
-
type ValidUnlessConfig<Model> = BuilderOptionUnlessConfig<BuilderOptionUnlessConfig['values'], Readonly<BuilderValidPath<Model>>>;
|
|
31
|
-
type ValidBinding<Model> = BuilderOptionValues | ValidEnableConfig | ValidMatchConfig<Model> | ValidUnlessConfig<Model>;
|
|
32
|
-
type BindingConfigNullable<Binding> = Binding extends {
|
|
33
|
-
readonly type: string;
|
|
34
|
-
} ? WhenConfigNullable<Binding> : never;
|
|
35
|
-
type BindingValueType<Binding> = Binding extends {
|
|
36
|
-
readonly type: 'match';
|
|
37
|
-
readonly selectMap: infer SelectMap extends Record<string, unknown>;
|
|
38
|
-
} ? NonNullable<SelectMap[keyof SelectMap]> extends {
|
|
39
|
-
readonly value: infer Value;
|
|
40
|
-
} ? Value : string : Binding extends {
|
|
41
|
-
readonly values: infer Values;
|
|
42
|
-
} ? Values extends {
|
|
43
|
-
readonly value: infer Value;
|
|
44
|
-
} ? Value : string : Binding extends {
|
|
45
|
-
readonly value: infer Value;
|
|
46
|
-
} ? Value : string;
|
|
47
|
-
type BindingModelType<Binding> = BindingValueType<Binding> | BindingConfigNullable<Binding>;
|
|
48
|
-
export {};
|
package/dist/core/parameter.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import * as v from 'valibot';
|
|
2
|
-
import { BuilderWhenConfigSchema } from './when/index.js';
|
|
3
|
-
export class BuilderParameter {
|
|
4
|
-
parameter = true;
|
|
5
|
-
}
|
|
6
|
-
export const BuilderParameterSchema = v.instance(BuilderParameter);
|
|
7
|
-
export function extractValues(config) {
|
|
8
|
-
if (config.type === 'match') {
|
|
9
|
-
return Object.values(config.selectMap).find((value) => value !== null);
|
|
10
|
-
}
|
|
11
|
-
return config.values;
|
|
12
|
-
}
|
|
13
|
-
export function bindOptions(options, bindings) {
|
|
14
|
-
return options.map((option) => {
|
|
15
|
-
const binding = bindings[option.name];
|
|
16
|
-
if (binding == null) {
|
|
17
|
-
return option;
|
|
18
|
-
}
|
|
19
|
-
return bindOption(option, binding);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
function createOption(option, values, config) {
|
|
23
|
-
const OptionConstructor = option.constructor;
|
|
24
|
-
return new OptionConstructor(option.name, values, option.gatePaths, config);
|
|
25
|
-
}
|
|
26
|
-
function bindOption(option, binding) {
|
|
27
|
-
if (v.is(BuilderWhenConfigSchema, binding)) {
|
|
28
|
-
return createOption(option, extractValues(binding), binding);
|
|
29
|
-
}
|
|
30
|
-
return createOption(option, binding, option.config);
|
|
31
|
-
}
|
package/dist/core/validate.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { BuilderGeneric } from './builder';
|
|
2
|
-
declare const validated: unique symbol;
|
|
3
|
-
export type BuilderValidated = BuilderGeneric & {
|
|
4
|
-
readonly [validated]: true;
|
|
5
|
-
};
|
|
6
|
-
export type BuilderValidateErrorUnmetExpectation = {
|
|
7
|
-
readonly kind: 'unmet-expectation';
|
|
8
|
-
readonly expectationKind: 'option' | 'component' | 'collection';
|
|
9
|
-
readonly name: string;
|
|
10
|
-
};
|
|
11
|
-
export type BuilderValidateErrorUnboundParameter = {
|
|
12
|
-
readonly kind: 'unbound-parameter';
|
|
13
|
-
readonly name: string;
|
|
14
|
-
};
|
|
15
|
-
export type BuilderValidateError = BuilderValidateErrorUnmetExpectation | BuilderValidateErrorUnboundParameter;
|
|
16
|
-
export type BuilderValidateErrors = ReadonlyArray<BuilderValidateError>;
|
|
17
|
-
export type BuilderValidateResult = readonly [BuilderValidated, BuilderValidateErrors];
|
|
18
|
-
export type BuilderValidateOptions = {
|
|
19
|
-
readonly strict: true;
|
|
20
|
-
};
|
|
21
|
-
export declare class BuilderValidateException extends Error {
|
|
22
|
-
readonly errors: BuilderValidateErrors;
|
|
23
|
-
constructor(errors: BuilderValidateErrors);
|
|
24
|
-
}
|
|
25
|
-
export declare function validateBuilder(builder: BuilderGeneric, options?: BuilderValidateOptions): BuilderValidateResult;
|
|
26
|
-
export {};
|
package/dist/core/validate.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as v from 'valibot';
|
|
2
|
-
import { BuilderParameterSchema } from './parameter.js';
|
|
3
|
-
export class BuilderValidateException extends Error {
|
|
4
|
-
errors;
|
|
5
|
-
constructor(errors) {
|
|
6
|
-
super('builder validation failed');
|
|
7
|
-
this.errors = errors;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export function validateBuilder(builder, options) {
|
|
11
|
-
const expectationErrors = validateExpectations(builder.expectations, builder);
|
|
12
|
-
const parameterErrors = validateParameters(builder.options);
|
|
13
|
-
const errors = [...expectationErrors, ...parameterErrors];
|
|
14
|
-
if (options?.strict && errors.length > 0) {
|
|
15
|
-
throw new BuilderValidateException(errors);
|
|
16
|
-
}
|
|
17
|
-
return [builder, errors];
|
|
18
|
-
}
|
|
19
|
-
function validateExpectations(expectations, entries) {
|
|
20
|
-
return expectations.flatMap((expectation) => {
|
|
21
|
-
const lookup = expectation.kind === 'option'
|
|
22
|
-
? entries.options
|
|
23
|
-
: expectation.kind === 'component'
|
|
24
|
-
? entries.components
|
|
25
|
-
: entries.collections;
|
|
26
|
-
const exists = lookup.some((entry) => entry.name === expectation.name);
|
|
27
|
-
if (exists) {
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
return [
|
|
31
|
-
{
|
|
32
|
-
kind: 'unmet-expectation',
|
|
33
|
-
expectationKind: expectation.kind,
|
|
34
|
-
name: expectation.name
|
|
35
|
-
}
|
|
36
|
-
];
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
function validateParameters(options) {
|
|
40
|
-
return options
|
|
41
|
-
.filter((option) => v.is(BuilderParameterSchema, option.values))
|
|
42
|
-
.map((option) => ({ kind: 'unbound-parameter', name: option.name }));
|
|
43
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { BuilderPrimitive } from '../../model';
|
|
2
|
-
import type { BuilderPath } from '../../paths';
|
|
3
|
-
import * as v from 'valibot';
|
|
4
|
-
export declare const BuilderWhenConfigSchema: v.ObjectSchema<{
|
|
5
|
-
readonly type: v.PicklistSchema<["enable", "match", "unless"], undefined>;
|
|
6
|
-
}, undefined>;
|
|
7
|
-
export type BuilderWhenConfig = v.InferOutput<typeof BuilderWhenConfigSchema>;
|
|
8
|
-
export type BuilderWhenEnableConfig<Payload> = {
|
|
9
|
-
readonly type: 'enable';
|
|
10
|
-
} & Payload;
|
|
11
|
-
export type BuilderWhenMatchConfig<SelectMap = Record<string, unknown>, MatchPath extends BuilderPath = BuilderPath> = {
|
|
12
|
-
readonly type: 'match';
|
|
13
|
-
readonly matchPath: MatchPath;
|
|
14
|
-
readonly selectMap: SelectMap;
|
|
15
|
-
};
|
|
16
|
-
export type BuilderWhenUnlessConfig<Payload, UnlessPath extends BuilderPath = BuilderPath> = {
|
|
17
|
-
readonly type: 'unless';
|
|
18
|
-
readonly unlessPath: UnlessPath;
|
|
19
|
-
readonly disabledValues: ReadonlyArray<BuilderPrimitive>;
|
|
20
|
-
} & Payload;
|
package/dist/core/when/config.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { BuilderValidPath } from '../../paths';
|
|
2
|
-
export type WhenConfigConstrained<Model, Config extends {
|
|
3
|
-
readonly type: string;
|
|
4
|
-
}> = Config extends {
|
|
5
|
-
readonly type: 'match';
|
|
6
|
-
readonly matchPath: infer MatchPath;
|
|
7
|
-
} ? Config & {
|
|
8
|
-
readonly matchPath: MatchPath & Readonly<BuilderValidPath<Model>>;
|
|
9
|
-
} : Config extends {
|
|
10
|
-
readonly type: 'unless';
|
|
11
|
-
readonly unlessPath: infer UnlessPath;
|
|
12
|
-
} ? Config & {
|
|
13
|
-
readonly unlessPath: UnlessPath & Readonly<BuilderValidPath<Model>>;
|
|
14
|
-
} : Config;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export type { BuilderWhenConfig, BuilderWhenEnableConfig, BuilderWhenMatchConfig, BuilderWhenUnlessConfig } from './config';
|
|
2
|
-
export { BuilderWhenConfigSchema } from './config.js';
|
|
3
|
-
export type { WhenConfigNullable, WhenNullability, WhenPathsNullable } from './nullability';
|
|
4
|
-
export type { WhenConfigConstrained } from './constrain';
|
|
5
|
-
export { resolve } from './resolve.js';
|
package/dist/core/when/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { BuilderPath, BuilderPaths, BuilderResolvePath } from '../../paths';
|
|
2
|
-
export type WhenConfigNullable<Config extends {
|
|
3
|
-
readonly type: string;
|
|
4
|
-
}> = Config extends {
|
|
5
|
-
readonly type: 'unless';
|
|
6
|
-
} ? null : Config extends {
|
|
7
|
-
readonly type: 'match';
|
|
8
|
-
readonly selectMap: infer SelectMap;
|
|
9
|
-
} ? null extends SelectMap[keyof SelectMap] ? null : never : never;
|
|
10
|
-
export type WhenPathsNullable<Model, GatePaths extends BuilderPaths> = GatePaths extends readonly [
|
|
11
|
-
infer Head extends BuilderPath,
|
|
12
|
-
...infer Tail extends BuilderPaths
|
|
13
|
-
] ? WhenPathNullable<Model, Head> | WhenPathsNullable<Model, Tail> : never;
|
|
14
|
-
export type WhenNullability<Model, GatePaths extends BuilderPaths, Config extends {
|
|
15
|
-
readonly type: string;
|
|
16
|
-
}> = WhenPathsNullable<Model, GatePaths> | WhenConfigNullable<Config>;
|
|
17
|
-
type WhenPathNullable<Model, Path extends BuilderPath> = null extends BuilderResolvePath<Model, Path> ? null : never;
|
|
18
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { BuilderPath, BuilderPaths } from '../../paths';
|
|
2
|
-
export declare function resolve<Entry extends Resolvable>(entry: Entry, model: unknown, onMatch: (selectMap: unknown, matchValue: string) => Entry | null): Entry | null;
|
|
3
|
-
type ResolvableConfig = {
|
|
4
|
-
readonly type: 'enable';
|
|
5
|
-
} | {
|
|
6
|
-
readonly type: 'match';
|
|
7
|
-
readonly matchPath: BuilderPath;
|
|
8
|
-
readonly selectMap: unknown;
|
|
9
|
-
} | {
|
|
10
|
-
readonly type: 'unless';
|
|
11
|
-
readonly unlessPath: BuilderPath;
|
|
12
|
-
readonly disabledValues: ReadonlyArray<unknown>;
|
|
13
|
-
};
|
|
14
|
-
interface Resolvable {
|
|
15
|
-
readonly gatePaths: BuilderPaths;
|
|
16
|
-
readonly config: ResolvableConfig | null;
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { readPath } from '../../paths.js';
|
|
2
|
-
export function resolve(entry, model, onMatch) {
|
|
3
|
-
if (entry.config === null) {
|
|
4
|
-
return entry;
|
|
5
|
-
}
|
|
6
|
-
if (!entry.gatePaths.every((path) => !!readPath(model, path))) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
switch (entry.config.type) {
|
|
10
|
-
case 'enable': {
|
|
11
|
-
return entry;
|
|
12
|
-
}
|
|
13
|
-
case 'match': {
|
|
14
|
-
const matchValue = String(readPath(model, entry.config.matchPath));
|
|
15
|
-
return onMatch(entry.config.selectMap, matchValue);
|
|
16
|
-
}
|
|
17
|
-
case 'unless': {
|
|
18
|
-
const value = readPath(model, entry.config.unlessPath);
|
|
19
|
-
return !entry.config.disabledValues.includes(value) ? entry : null;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
package/dist/resolve/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type { BuilderOrder } from './order';
|
|
2
|
-
export type { BuilderRenderOption, BuilderRenderOptions, BuilderRenderPage, BuilderRenderPages, BuilderRenderResult } from './render';
|
|
3
|
-
export type { BuilderDataValidated, BuilderDataError, BuilderDataErrors, BuilderDataErrorComponentMissing, BuilderDataErrorComponentUnexpected, BuilderDataErrorVariantInvalid, BuilderDataErrorVariantMissing, BuilderDataValidateResult } from './validate';
|
|
4
|
-
export type { BuilderModelValidated, BuilderModelValidateError, BuilderModelValidateErrors, BuilderModelValidateErrorInvalidCollection, BuilderModelValidateErrorInvalidOption, BuilderModelValidateOptions, BuilderModelValidateResult } from './instance';
|
|
5
|
-
export type { BuilderDescription, BuilderDescriptionItem } from '../schemas/index';
|
|
6
|
-
export { instance, BuilderModelValidateException } from './instance.js';
|
|
7
|
-
export { models } from './models.js';
|
|
8
|
-
export { order } from './order.js';
|
|
9
|
-
export { ordinal, render } from './render.js';
|
|
10
|
-
export { validate, BuilderDataValidateError } from './validate.js';
|
package/dist/resolve/index.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { BuilderGeneric, BuilderModelOf } from '../core/index';
|
|
2
|
-
import type { BuilderModel, BuilderModelInput } from '../model';
|
|
3
|
-
declare const modelValidated: unique symbol;
|
|
4
|
-
export type BuilderModelValidated = BuilderModel & {
|
|
5
|
-
readonly [modelValidated]: true;
|
|
6
|
-
};
|
|
7
|
-
export type BuilderModelValidateErrorInvalidOption = {
|
|
8
|
-
readonly kind: 'invalid-option';
|
|
9
|
-
readonly name: string;
|
|
10
|
-
readonly value: unknown;
|
|
11
|
-
};
|
|
12
|
-
export type BuilderModelValidateErrorInvalidCollection = {
|
|
13
|
-
readonly kind: 'invalid-collection';
|
|
14
|
-
readonly name: string;
|
|
15
|
-
readonly detail: string;
|
|
16
|
-
};
|
|
17
|
-
export type BuilderModelValidateError = BuilderModelValidateErrorInvalidOption | BuilderModelValidateErrorInvalidCollection;
|
|
18
|
-
export type BuilderModelValidateErrors = ReadonlyArray<BuilderModelValidateError>;
|
|
19
|
-
export type BuilderModelValidateResult = readonly [
|
|
20
|
-
BuilderModelValidated,
|
|
21
|
-
BuilderModelValidateErrors
|
|
22
|
-
];
|
|
23
|
-
export type BuilderModelValidateOptions = {
|
|
24
|
-
readonly strict: true;
|
|
25
|
-
};
|
|
26
|
-
export declare class BuilderModelValidateException extends Error {
|
|
27
|
-
readonly errors: BuilderModelValidateErrors;
|
|
28
|
-
constructor(errors: BuilderModelValidateErrors);
|
|
29
|
-
}
|
|
30
|
-
export declare function validateInstance(builder: BuilderGeneric, model: BuilderModel, options?: BuilderModelValidateOptions): BuilderModelValidateResult;
|
|
31
|
-
export declare const instance: typeof createInstance & {
|
|
32
|
-
validate: typeof validateInstance;
|
|
33
|
-
};
|
|
34
|
-
declare function createInstance<const Builder extends BuilderGeneric>(builder: Builder, partial?: BuilderModelInput): BuilderModelOf<Builder> & BuilderModelValidated;
|
|
35
|
-
export {};
|