@builder-builder/builder 0.0.1 → 0.0.3
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { invariant } from '../../invariant.js';
|
|
2
2
|
import { BuilderComponent } from './component.js';
|
|
3
|
+
const EMPTY_MODEL = '{}';
|
|
3
4
|
export class BuilderComponentGraph {
|
|
4
5
|
paths;
|
|
5
6
|
constructor(paths = []) {
|
|
@@ -42,7 +43,7 @@ export class BuilderComponentGraph {
|
|
|
42
43
|
graphPath.models.forEach((item) => {
|
|
43
44
|
const picked = Object.fromEntries(Object.entries(item).filter(([key, value]) => keys.has(key) && value != null));
|
|
44
45
|
const identity = JSON.stringify(picked);
|
|
45
|
-
if (!seen.has(identity)) {
|
|
46
|
+
if (identity !== EMPTY_MODEL && !seen.has(identity)) {
|
|
46
47
|
seen.add(identity);
|
|
47
48
|
models.push(picked);
|
|
48
49
|
}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { BuilderCollectionConfig, BuilderCollectionEnableConfig, BuilderCollectionEntries, BuilderCollectionMatchConfig, BuilderCollectionMethod, BuilderCollectionModelOf, BuilderCollectionNamesOf, BuilderCollectionOf, BuilderCollectionUnlessConfig, BuilderCollectionWhenConfig, BuilderTupleOf } from './collection/index';
|
|
2
2
|
export type { BuilderComponentEntries, BuilderComponentMap, BuilderComponentMethod, BuilderComponentNamesOf } from './component/index';
|
|
3
|
-
export type { BuilderOptionEnableConfig, BuilderOptionEntries, BuilderOptionGraphs, BuilderOptionMatchConfig, BuilderOptionMethod, BuilderOptionUnlessConfig, BuilderOptionValues, BuilderOptionWhenConfig, BuilderSelectTypeGeneric, BuilderSelectTypeLabels, BuilderSelectTypeValues, BuilderToggleTypeGeneric, BuilderOptionValueSchema } from './option/index';
|
|
3
|
+
export type { BuilderOptionEnableConfig, BuilderOptionEntries, BuilderOptionGraphs, BuilderOptionMatchConfig, BuilderOptionMethod, BuilderOptionUnlessConfig, BuilderOptionValues, BuilderOptionValuesMap, BuilderOptionWhenConfig, BuilderSelectTypeGeneric, BuilderSelectTypeLabels, BuilderSelectTypeValues, BuilderToggleTypeGeneric, BuilderOptionValueSchema } from './option/index';
|
|
4
4
|
export type { BuilderStateMerge, BuilderFactory, BuilderGeneric, BuilderModelOf, BuilderPart, BuilderParts, BuilderState, BuilderStateEmpty, BuilderStateOf, BuilderSelectMap, BuilderSelectMapGeneric } from './builder';
|
|
5
5
|
export { BuilderCollection, collection, resolveCollectionModels, resolveCollectionNames } from './collection/index.js';
|
|
6
6
|
export { BuilderComponent, BuilderComponentGraph } from './component/index.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { BuilderOptionEnableConfig, BuilderOptionMatchConfig, BuilderOptionMethod, BuilderOptionUnlessConfig, BuilderOptionWhenConfig } from './method';
|
|
2
2
|
export type { BuilderOptionGraphs } from './graph';
|
|
3
|
-
export type { BuilderOptionEntries, BuilderOptionValues, BuilderSelectTypeGeneric, BuilderToggleTypeGeneric, BuilderOptionValueSchema } from './option';
|
|
3
|
+
export type { BuilderOptionEntries, BuilderOptionValues, BuilderOptionValuesMap, BuilderSelectTypeGeneric, BuilderToggleTypeGeneric, BuilderOptionValueSchema } from './option';
|
|
4
4
|
export type { BuilderSelectTypeLabels, BuilderSelectTypeValues } from './select';
|
|
5
5
|
export { enable, match, unless } from './method.js';
|
|
6
6
|
export { BuilderOptionGraph } from './graph.js';
|
|
@@ -2,13 +2,13 @@ import type { BuilderPrimitive } from '../../config';
|
|
|
2
2
|
import type { BuilderPath, BuilderPaths, BuilderResolvePath, BuilderValidPath } from '../../paths';
|
|
3
3
|
import type { BuilderStateMerge, BuilderState } from '../builder';
|
|
4
4
|
import type { Builder } from '../builder';
|
|
5
|
-
import type { BuilderOptionValues } from './option';
|
|
5
|
+
import type { BuilderOptionValues, BuilderOptionValuesMap } from './option';
|
|
6
6
|
import type { BuilderOption } from './option';
|
|
7
7
|
export type BuilderOptionEnableConfig<Values extends BuilderOptionValues = BuilderOptionValues> = {
|
|
8
8
|
readonly type: 'enable';
|
|
9
9
|
readonly values: Values;
|
|
10
10
|
};
|
|
11
|
-
export type BuilderOptionMatchConfig<SelectMap extends
|
|
11
|
+
export type BuilderOptionMatchConfig<SelectMap extends BuilderOptionValuesMap = BuilderOptionValuesMap, MatchPath extends BuilderPath = BuilderPath> = {
|
|
12
12
|
readonly type: 'match';
|
|
13
13
|
readonly matchPath: MatchPath;
|
|
14
14
|
readonly selectMap: SelectMap;
|
|
@@ -19,7 +19,7 @@ export type BuilderOptionUnlessConfig<Values extends BuilderOptionValues = Build
|
|
|
19
19
|
readonly disabledValues: ReadonlyArray<BuilderPrimitive>;
|
|
20
20
|
readonly values: Values;
|
|
21
21
|
};
|
|
22
|
-
export type BuilderOptionWhenConfig = BuilderOptionEnableConfig<BuilderOptionValues> | BuilderOptionMatchConfig<
|
|
22
|
+
export type BuilderOptionWhenConfig = BuilderOptionEnableConfig<BuilderOptionValues> | BuilderOptionMatchConfig<BuilderOptionValuesMap> | BuilderOptionUnlessConfig<BuilderOptionValues>;
|
|
23
23
|
export type BuilderOptionWhenConfigValues<Config extends BuilderOptionWhenConfig> = Config extends BuilderOptionEnableConfig<infer Values> ? Values : Config extends BuilderOptionUnlessConfig<infer Values> ? Values : Config extends BuilderOptionMatchConfig<infer SelectMapType> ? NonNullable<SelectMapType[keyof SelectMapType]> & BuilderOptionValues : never;
|
|
24
24
|
export type BuilderOptionMethod<State extends BuilderState> = {
|
|
25
25
|
<const Name extends string, const Values extends BuilderOptionValues>(name: Name, values: Values): Builder<BuilderStateMerge<State, {
|
|
@@ -36,7 +36,7 @@ export type BuilderOptionMethod<State extends BuilderState> = {
|
|
|
36
36
|
}>>;
|
|
37
37
|
};
|
|
38
38
|
export declare function enable<const Values extends BuilderOptionValues>(values: Values): BuilderOptionEnableConfig<Values>;
|
|
39
|
-
export declare function match<const MatchPath extends BuilderPath, const SelectMap extends
|
|
39
|
+
export declare function match<const MatchPath extends BuilderPath, const SelectMap extends BuilderOptionValuesMap>(matchPath: MatchPath, selectMap: SelectMap): BuilderOptionMatchConfig<SelectMap, MatchPath>;
|
|
40
40
|
export declare function unless<const Values extends BuilderOptionValues, const UnlessPath extends BuilderPath>(unlessPath: UnlessPath, disabledValues: ReadonlyArray<BuilderPrimitive>, values: Values): BuilderOptionUnlessConfig<Values, UnlessPath>;
|
|
41
41
|
type OptionConfigNullable<Config extends BuilderOptionWhenConfig> = Config extends BuilderOptionUnlessConfig ? null : Config extends BuilderOptionMatchConfig<infer SelectMapType> ? null extends SelectMapType[keyof SelectMapType] ? null : never : never;
|
|
42
42
|
type OptionGatePathNullable<Model, Path extends BuilderPath> = null extends BuilderResolvePath<Model, Path> ? null : never;
|
|
@@ -46,7 +46,7 @@ type OptionGatePathsNullable<Model, GatePaths extends BuilderPaths> = GatePaths
|
|
|
46
46
|
] ? OptionGatePathNullable<Model, Head> | OptionGatePathsNullable<Model, Tail> : never;
|
|
47
47
|
type OptionWhenNullability<Model, GatePaths extends BuilderPaths, Config extends BuilderOptionWhenConfig> = OptionGatePathsNullable<Model, GatePaths> | OptionConfigNullable<Config>;
|
|
48
48
|
type MatchKeyOfConfig<Model, Config extends BuilderOptionWhenConfig> = Config extends BuilderOptionMatchConfig<any, infer MatchPath> ? BuilderResolvePath<Model, MatchPath> & string : string;
|
|
49
|
-
type WhenConfigConstrained<Model, Config extends BuilderOptionWhenConfig> = Config extends BuilderOptionMatchConfig<any, infer MatchPath> ? BuilderOptionMatchConfig<Record<MatchKeyOfConfig<Model, Config>,
|
|
49
|
+
type WhenConfigConstrained<Model, Config extends BuilderOptionWhenConfig> = Config extends BuilderOptionMatchConfig<any, infer MatchPath> ? BuilderOptionMatchConfig<Record<MatchKeyOfConfig<Model, Config>, BuilderOptionValuesMap[string]>, MatchPath & Readonly<BuilderValidPath<Model>>> : Config extends BuilderOptionUnlessConfig ? Config & {
|
|
50
50
|
readonly unlessPath: Readonly<BuilderValidPath<Model>>;
|
|
51
51
|
} : Config;
|
|
52
52
|
export {};
|
|
@@ -7,6 +7,7 @@ export type BuilderOptionValueSchema = v.GenericSchema<string | number | boolean
|
|
|
7
7
|
export type BuilderSelectTypeGeneric = BuilderSelectType<BuilderSelectTypeValues, BuilderOptionValueSchema>;
|
|
8
8
|
export type BuilderToggleTypeGeneric = BuilderToggleType<BuilderOptionValueSchema>;
|
|
9
9
|
export type BuilderOptionValues = BuilderSelectTypeGeneric | BuilderToggleTypeGeneric;
|
|
10
|
+
export type BuilderOptionValuesMap = Record<string, BuilderOptionValues | null>;
|
|
10
11
|
export type BuilderOptionEntries = ReadonlyArray<BuilderOption>;
|
|
11
12
|
export declare class BuilderOption<const Name extends string = string, const Values extends BuilderOptionValues = BuilderOptionValues> {
|
|
12
13
|
readonly model: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { BuilderModelAsserted, BuilderUIModelAsserted } from './assert/assert';
|
|
2
2
|
export type { BuilderExpectations } from './assert/index';
|
|
3
3
|
export type { BuilderData, BuilderModel, BuilderModelMutable, BuilderModels, BuilderPrimitive, BuilderPrimitives, BuilderVariant, BuilderVariants } from './config';
|
|
4
|
-
export type { Builder, BuilderCollectionConfig, BuilderCollectionEntries, BuilderCollectionModelOf, BuilderCollectionNamesOf, BuilderCollectionOf, BuilderComponentEntries, BuilderComponentNamesOf, BuilderFactory, BuilderGeneric, BuilderModelOf, BuilderOptionEntries, BuilderOptionValues, BuilderPart, BuilderParts, BuilderSelectTypeLabels, BuilderSelectTypeValues, BuilderState, BuilderStateOf } from './core/index';
|
|
4
|
+
export type { Builder, BuilderCollectionConfig, BuilderCollectionEntries, BuilderCollectionModelOf, BuilderCollectionNamesOf, BuilderCollectionOf, BuilderComponentEntries, BuilderComponentNamesOf, BuilderFactory, BuilderGeneric, BuilderModelOf, BuilderOptionEntries, BuilderOptionValues, BuilderOptionValuesMap, BuilderPart, BuilderParts, BuilderSelectTypeLabels, BuilderSelectTypeValues, BuilderState, BuilderStateOf } from './core/index';
|
|
5
5
|
export type { BuilderModelPaths, BuilderResolvePath, BuilderValidPath } from './paths';
|
|
6
6
|
export type { BuilderPath, BuilderPaths } from './schemas/index';
|
|
7
7
|
export type { BuilderDataValidated, BuilderDescription, BuilderDescriptionItem, BuilderErrorComponentMissing, BuilderErrorComponentUnexpected, BuilderErrorsValidate, BuilderErrorValidate, BuilderErrorVariantInvalid, BuilderErrorVariantMissing, BuilderLayout, BuilderLayoutOption, BuilderLayoutOptions, BuilderLayoutPage, BuilderOrder, BuilderRenderLayoutOption, BuilderRenderLayoutOptions, BuilderRenderPage, BuilderRenderPages, BuilderRenderResult, BuilderValidateResult } from './resolve/index';
|