@player-tools/fluent 0.12.1--canary.241.6077
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/cjs/index.cjs +2396 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/index.legacy-esm.js +2276 -0
- package/dist/index.mjs +2276 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +38 -0
- package/src/core/base-builder/__tests__/fluent-builder-base.test.ts +2423 -0
- package/src/core/base-builder/__tests__/fluent-partial.test.ts +179 -0
- package/src/core/base-builder/__tests__/id-generator.test.ts +658 -0
- package/src/core/base-builder/__tests__/registry.test.ts +534 -0
- package/src/core/base-builder/__tests__/resolution-mixed-arrays.test.ts +319 -0
- package/src/core/base-builder/__tests__/resolution-pipeline.test.ts +416 -0
- package/src/core/base-builder/__tests__/resolution-switches.test.ts +468 -0
- package/src/core/base-builder/__tests__/resolution-templates.test.ts +255 -0
- package/src/core/base-builder/__tests__/switch.test.ts +815 -0
- package/src/core/base-builder/__tests__/template.test.ts +596 -0
- package/src/core/base-builder/__tests__/value-extraction.test.ts +200 -0
- package/src/core/base-builder/__tests__/value-storage.test.ts +459 -0
- package/src/core/base-builder/conditional/index.ts +64 -0
- package/src/core/base-builder/context.ts +152 -0
- package/src/core/base-builder/errors.ts +69 -0
- package/src/core/base-builder/fluent-builder-base.ts +308 -0
- package/src/core/base-builder/guards.ts +137 -0
- package/src/core/base-builder/id/generator.ts +290 -0
- package/src/core/base-builder/id/registry.ts +152 -0
- package/src/core/base-builder/index.ts +72 -0
- package/src/core/base-builder/resolution/path-resolver.ts +116 -0
- package/src/core/base-builder/resolution/pipeline.ts +103 -0
- package/src/core/base-builder/resolution/steps/__tests__/nested-asset-wrappers.test.ts +206 -0
- package/src/core/base-builder/resolution/steps/asset-id.ts +77 -0
- package/src/core/base-builder/resolution/steps/asset-wrappers.ts +64 -0
- package/src/core/base-builder/resolution/steps/builders.ts +84 -0
- package/src/core/base-builder/resolution/steps/mixed-arrays.ts +95 -0
- package/src/core/base-builder/resolution/steps/nested-asset-wrappers.ts +124 -0
- package/src/core/base-builder/resolution/steps/static-values.ts +35 -0
- package/src/core/base-builder/resolution/steps/switches.ts +71 -0
- package/src/core/base-builder/resolution/steps/templates.ts +40 -0
- package/src/core/base-builder/resolution/value-resolver.ts +333 -0
- package/src/core/base-builder/storage/auxiliary-storage.ts +82 -0
- package/src/core/base-builder/storage/value-storage.ts +282 -0
- package/src/core/base-builder/types.ts +266 -0
- package/src/core/base-builder/utils.ts +10 -0
- package/src/core/flow/__tests__/index.test.ts +292 -0
- package/src/core/flow/index.ts +118 -0
- package/src/core/index.ts +8 -0
- package/src/core/mocks/generated/action.builder.ts +92 -0
- package/src/core/mocks/generated/choice-item.builder.ts +120 -0
- package/src/core/mocks/generated/choice.builder.ts +134 -0
- package/src/core/mocks/generated/collection.builder.ts +93 -0
- package/src/core/mocks/generated/field-collection.builder.ts +86 -0
- package/src/core/mocks/generated/index.ts +10 -0
- package/src/core/mocks/generated/info.builder.ts +64 -0
- package/src/core/mocks/generated/input.builder.ts +63 -0
- package/src/core/mocks/generated/overview-collection.builder.ts +65 -0
- package/src/core/mocks/generated/splash-collection.builder.ts +93 -0
- package/src/core/mocks/generated/text.builder.ts +47 -0
- package/src/core/mocks/index.ts +1 -0
- package/src/core/mocks/types/action.ts +92 -0
- package/src/core/mocks/types/choice.ts +129 -0
- package/src/core/mocks/types/collection.ts +140 -0
- package/src/core/mocks/types/info.ts +7 -0
- package/src/core/mocks/types/input.ts +7 -0
- package/src/core/mocks/types/text.ts +5 -0
- package/src/core/schema/__tests__/index.test.ts +127 -0
- package/src/core/schema/index.ts +195 -0
- package/src/core/schema/types.ts +7 -0
- package/src/core/switch/__tests__/index.test.ts +156 -0
- package/src/core/switch/index.ts +81 -0
- package/src/core/tagged-template/README.md +448 -0
- package/src/core/tagged-template/__tests__/extract-bindings-from-schema.test.ts +207 -0
- package/src/core/tagged-template/__tests__/index.test.ts +190 -0
- package/src/core/tagged-template/__tests__/schema-std-integration.test.ts +580 -0
- package/src/core/tagged-template/binding.ts +95 -0
- package/src/core/tagged-template/expression.ts +92 -0
- package/src/core/tagged-template/extract-bindings-from-schema.ts +120 -0
- package/src/core/tagged-template/index.ts +5 -0
- package/src/core/tagged-template/std.ts +472 -0
- package/src/core/tagged-template/types.ts +123 -0
- package/src/core/template/__tests__/index.test.ts +380 -0
- package/src/core/template/index.ts +196 -0
- package/src/core/utils/index.ts +160 -0
- package/src/fp/README.md +411 -0
- package/src/fp/__tests__/index.test.ts +1178 -0
- package/src/fp/index.ts +386 -0
- package/src/gen/common.ts +15 -0
- package/src/index.ts +5 -0
- package/src/types.ts +203 -0
- package/types/core/base-builder/conditional/index.d.ts +21 -0
- package/types/core/base-builder/context.d.ts +39 -0
- package/types/core/base-builder/errors.d.ts +45 -0
- package/types/core/base-builder/fluent-builder-base.d.ts +147 -0
- package/types/core/base-builder/guards.d.ts +58 -0
- package/types/core/base-builder/id/generator.d.ts +69 -0
- package/types/core/base-builder/id/registry.d.ts +93 -0
- package/types/core/base-builder/index.d.ts +9 -0
- package/types/core/base-builder/resolution/path-resolver.d.ts +15 -0
- package/types/core/base-builder/resolution/pipeline.d.ts +27 -0
- package/types/core/base-builder/resolution/steps/asset-id.d.ts +14 -0
- package/types/core/base-builder/resolution/steps/asset-wrappers.d.ts +14 -0
- package/types/core/base-builder/resolution/steps/builders.d.ts +14 -0
- package/types/core/base-builder/resolution/steps/mixed-arrays.d.ts +14 -0
- package/types/core/base-builder/resolution/steps/nested-asset-wrappers.d.ts +14 -0
- package/types/core/base-builder/resolution/steps/static-values.d.ts +14 -0
- package/types/core/base-builder/resolution/steps/switches.d.ts +15 -0
- package/types/core/base-builder/resolution/steps/templates.d.ts +14 -0
- package/types/core/base-builder/resolution/value-resolver.d.ts +62 -0
- package/types/core/base-builder/storage/auxiliary-storage.d.ts +50 -0
- package/types/core/base-builder/storage/value-storage.d.ts +82 -0
- package/types/core/base-builder/types.d.ts +183 -0
- package/types/core/base-builder/utils.d.ts +2 -0
- package/types/core/flow/index.d.ts +23 -0
- package/types/core/index.d.ts +8 -0
- package/types/core/mocks/index.d.ts +2 -0
- package/types/core/mocks/types/action.d.ts +58 -0
- package/types/core/mocks/types/choice.d.ts +95 -0
- package/types/core/mocks/types/collection.d.ts +102 -0
- package/types/core/mocks/types/info.d.ts +7 -0
- package/types/core/mocks/types/input.d.ts +7 -0
- package/types/core/mocks/types/text.d.ts +5 -0
- package/types/core/schema/index.d.ts +34 -0
- package/types/core/schema/types.d.ts +5 -0
- package/types/core/switch/index.d.ts +21 -0
- package/types/core/tagged-template/binding.d.ts +19 -0
- package/types/core/tagged-template/expression.d.ts +11 -0
- package/types/core/tagged-template/extract-bindings-from-schema.d.ts +7 -0
- package/types/core/tagged-template/index.d.ts +6 -0
- package/types/core/tagged-template/std.d.ts +174 -0
- package/types/core/tagged-template/types.d.ts +69 -0
- package/types/core/template/index.d.ts +97 -0
- package/types/core/utils/index.d.ts +47 -0
- package/types/fp/index.d.ts +149 -0
- package/types/gen/common.d.ts +6 -0
- package/types/index.d.ts +3 -0
- package/types/types.d.ts +163 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages auxiliary data storage for builders
|
|
3
|
+
*
|
|
4
|
+
* Auxiliary data is metadata that doesn't appear in the final built object
|
|
5
|
+
* but is used during the build process. This includes:
|
|
6
|
+
* - Templates (stored under "__templates__")
|
|
7
|
+
* - Switches (stored under "__switches__")
|
|
8
|
+
* - Custom metadata
|
|
9
|
+
*
|
|
10
|
+
* This separation keeps builder state clean and makes the build process more explicit
|
|
11
|
+
*/
|
|
12
|
+
export declare class AuxiliaryStorage {
|
|
13
|
+
private data;
|
|
14
|
+
/**
|
|
15
|
+
* Sets auxiliary data with a given key
|
|
16
|
+
*/
|
|
17
|
+
set<T>(key: string, value: T): void;
|
|
18
|
+
/**
|
|
19
|
+
* Gets auxiliary data with type assertion
|
|
20
|
+
* The caller is responsible for knowing the correct type
|
|
21
|
+
*/
|
|
22
|
+
get<T>(key: string): T | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Pushes an item to an auxiliary data array
|
|
25
|
+
* Creates the array if it doesn't exist
|
|
26
|
+
*/
|
|
27
|
+
push<T>(key: string, item: T): void;
|
|
28
|
+
/**
|
|
29
|
+
* Gets an auxiliary data array
|
|
30
|
+
* Returns empty array if doesn't exist or isn't an array
|
|
31
|
+
*/
|
|
32
|
+
getArray<T>(key: string): T[];
|
|
33
|
+
/**
|
|
34
|
+
* Checks if auxiliary data exists for a key
|
|
35
|
+
*/
|
|
36
|
+
has(key: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Deletes auxiliary data for a key
|
|
39
|
+
*/
|
|
40
|
+
delete(key: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Clears all auxiliary data
|
|
43
|
+
*/
|
|
44
|
+
clear(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Clones the auxiliary storage, creating an independent copy
|
|
47
|
+
*/
|
|
48
|
+
clone(): AuxiliaryStorage;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=auxiliary-storage.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { BaseBuildContext, FluentBuilder, MixedArrayMetadata } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Manages storage for builder property values
|
|
4
|
+
*
|
|
5
|
+
* Values are stored in three different maps based on their type:
|
|
6
|
+
* - values: Static values (strings, numbers, plain objects without builders)
|
|
7
|
+
* - builders: FluentBuilder instances and objects containing builders
|
|
8
|
+
* - mixedArrays: Arrays containing both static values and builders
|
|
9
|
+
*
|
|
10
|
+
* This separation allows efficient resolution during the build process
|
|
11
|
+
*/
|
|
12
|
+
export declare class ValueStorage<T> {
|
|
13
|
+
private values;
|
|
14
|
+
private builders;
|
|
15
|
+
private mixedArrays;
|
|
16
|
+
constructor(initial?: Partial<T>);
|
|
17
|
+
/**
|
|
18
|
+
* Sets a property value, intelligently routing it to the appropriate storage
|
|
19
|
+
*
|
|
20
|
+
* This method performs runtime type checking to determine how to store the value:
|
|
21
|
+
* - FluentBuilder instances → builders Map
|
|
22
|
+
* - Arrays with builders → mixedArrays Map
|
|
23
|
+
* - Objects with builders → builders Map
|
|
24
|
+
* - Everything else → values (static storage)
|
|
25
|
+
*/
|
|
26
|
+
set<K extends keyof T>(key: K, value: unknown): void;
|
|
27
|
+
/**
|
|
28
|
+
* Handles array value storage, detecting mixed arrays with builders
|
|
29
|
+
*/
|
|
30
|
+
private handleArrayValue;
|
|
31
|
+
/**
|
|
32
|
+
* Sets a static value with proper type handling
|
|
33
|
+
*/
|
|
34
|
+
private setStaticValue;
|
|
35
|
+
/**
|
|
36
|
+
* Checks if an object contains any builders recursively
|
|
37
|
+
* Handles circular references gracefully
|
|
38
|
+
*/
|
|
39
|
+
private containsBuilder;
|
|
40
|
+
/**
|
|
41
|
+
* Checks if a property has been set
|
|
42
|
+
*/
|
|
43
|
+
has<K extends keyof T>(key: K): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Peeks at a property value without resolving builders
|
|
46
|
+
* Returns the raw value if it's static, the array if it's mixed, or undefined if it's a builder
|
|
47
|
+
*/
|
|
48
|
+
peek<K extends keyof T>(key: K): T[K] | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Gets builder for a property if one is set
|
|
51
|
+
*/
|
|
52
|
+
peekBuilder<K extends keyof T, C extends BaseBuildContext>(key: K): FluentBuilder<T[K], C> | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Gets the type of value stored for a property
|
|
55
|
+
*/
|
|
56
|
+
getValueType<K extends keyof T>(key: K): "static" | "builder" | "mixed-array" | "unset";
|
|
57
|
+
/**
|
|
58
|
+
* Gets all static values for the build pipeline
|
|
59
|
+
*/
|
|
60
|
+
getValues(): Readonly<Partial<T>>;
|
|
61
|
+
/**
|
|
62
|
+
* Gets all builder entries for the build pipeline
|
|
63
|
+
*/
|
|
64
|
+
getBuilders(): ReadonlyMap<string, FluentBuilder<unknown, BaseBuildContext> | Record<string, unknown>>;
|
|
65
|
+
/**
|
|
66
|
+
* Gets all mixed array entries for the build pipeline
|
|
67
|
+
*/
|
|
68
|
+
getMixedArrays(): ReadonlyMap<string, MixedArrayMetadata>;
|
|
69
|
+
/**
|
|
70
|
+
* Unsets a property, removing it from storage
|
|
71
|
+
*/
|
|
72
|
+
unset<K extends keyof T>(key: K): void;
|
|
73
|
+
/**
|
|
74
|
+
* Clears all properties from storage
|
|
75
|
+
*/
|
|
76
|
+
clear(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Clones the storage, creating an independent copy
|
|
79
|
+
*/
|
|
80
|
+
clone(): ValueStorage<T>;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=value-storage.d.ts.map
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { Asset, AssetWrapper } from "@player-ui/types";
|
|
2
|
+
import type { TaggedTemplateValue } from "../tagged-template/types";
|
|
3
|
+
/**
|
|
4
|
+
* Unique symbol to identify FluentBuilder instances
|
|
5
|
+
* Used for runtime type checking of builder objects
|
|
6
|
+
*/
|
|
7
|
+
export declare const FLUENT_BUILDER_SYMBOL: unique symbol;
|
|
8
|
+
/**
|
|
9
|
+
* Constants for branch type discriminators
|
|
10
|
+
* Use these instead of string literals to prevent typos
|
|
11
|
+
*/
|
|
12
|
+
export declare const BranchTypes: {
|
|
13
|
+
readonly SLOT: "slot";
|
|
14
|
+
readonly ARRAY_ITEM: "array-item";
|
|
15
|
+
readonly TEMPLATE: "template";
|
|
16
|
+
readonly SWITCH: "switch";
|
|
17
|
+
readonly CUSTOM: "custom";
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Constants for internal storage keys
|
|
21
|
+
* Used by AuxiliaryStorage to store templates and switches
|
|
22
|
+
*/
|
|
23
|
+
export declare const StorageKeys: {
|
|
24
|
+
readonly TEMPLATES: "__templates__";
|
|
25
|
+
readonly SWITCHES: "__switches__";
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Constants for common property keys used in asset building
|
|
29
|
+
*/
|
|
30
|
+
export declare const PropertyKeys: {
|
|
31
|
+
readonly ID: "id";
|
|
32
|
+
readonly TYPE: "type";
|
|
33
|
+
readonly VALUE: "value";
|
|
34
|
+
readonly BINDING: "binding";
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Core interface for all fluent builders
|
|
38
|
+
* Provides build(), peek(), and has() methods for all builder types
|
|
39
|
+
*/
|
|
40
|
+
export interface FluentBuilder<T, C extends BaseBuildContext = BaseBuildContext> {
|
|
41
|
+
readonly [FLUENT_BUILDER_SYMBOL]: true;
|
|
42
|
+
build(context?: C): T;
|
|
43
|
+
peek<K extends keyof T>(key: K): T[K] | undefined;
|
|
44
|
+
has<K extends keyof T>(key: K): boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Type-erased asset builder interface for generic asset handling
|
|
48
|
+
*/
|
|
49
|
+
export type AnyAssetBuilder<C extends BaseBuildContext = BaseBuildContext> = {
|
|
50
|
+
readonly [FLUENT_BUILDER_SYMBOL]: true;
|
|
51
|
+
build(context?: C): Asset;
|
|
52
|
+
peek(key: string): unknown;
|
|
53
|
+
has(key: string): boolean;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Parameters for creating nested build contexts
|
|
57
|
+
* Used by nested context generators to create child contexts
|
|
58
|
+
*/
|
|
59
|
+
export interface NestedContextParams<C extends BaseBuildContext> {
|
|
60
|
+
readonly parentContext: C;
|
|
61
|
+
readonly parameterName: string;
|
|
62
|
+
readonly index?: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Function type for custom nested context generation
|
|
66
|
+
* Allows users to customize how child contexts are created
|
|
67
|
+
*/
|
|
68
|
+
export type NestedContextGenerator<C extends BaseBuildContext> = (params: NestedContextParams<C>) => C;
|
|
69
|
+
/**
|
|
70
|
+
* Metadata about an asset used for ID generation and context tracking
|
|
71
|
+
*/
|
|
72
|
+
export interface AssetMetadata {
|
|
73
|
+
readonly type?: string;
|
|
74
|
+
readonly binding?: string;
|
|
75
|
+
readonly value?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Base build context interface containing common fields for all builders
|
|
79
|
+
* Extended by specific builder implementations for custom context needs
|
|
80
|
+
*/
|
|
81
|
+
export interface BaseBuildContext {
|
|
82
|
+
readonly parentId?: string;
|
|
83
|
+
readonly parameterName?: string;
|
|
84
|
+
readonly index?: number;
|
|
85
|
+
readonly branch?: IdBranch;
|
|
86
|
+
readonly nestedContextGenerator?: NestedContextGenerator<BaseBuildContext>;
|
|
87
|
+
readonly assetMetadata?: AssetMetadata;
|
|
88
|
+
readonly [key: string]: unknown;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Slot branch for named properties (e.g., "label", "action")
|
|
92
|
+
* Creates IDs like: parent-label, parent-action
|
|
93
|
+
*/
|
|
94
|
+
export interface SlotBranch {
|
|
95
|
+
type: "slot";
|
|
96
|
+
name: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Array item branch for indexed elements
|
|
100
|
+
* Creates IDs like: parent-0, parent-1
|
|
101
|
+
*/
|
|
102
|
+
export interface ArrayItemBranch {
|
|
103
|
+
type: "array-item";
|
|
104
|
+
index: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Template branch for template placeholders
|
|
108
|
+
* Creates IDs like: parent-_index_, parent-_index1_
|
|
109
|
+
*/
|
|
110
|
+
export interface TemplateBranch {
|
|
111
|
+
type: "template";
|
|
112
|
+
depth?: number;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Switch branch for conditional cases
|
|
116
|
+
* Creates IDs like: parent-staticSwitch-0, parent-dynamicSwitch-1
|
|
117
|
+
*/
|
|
118
|
+
export interface SwitchBranch {
|
|
119
|
+
type: "switch";
|
|
120
|
+
index: number;
|
|
121
|
+
kind: "static" | "dynamic";
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Custom branch for user-defined ID patterns
|
|
125
|
+
*/
|
|
126
|
+
export interface CustomBranch {
|
|
127
|
+
type: "custom";
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Union of all branch types for type-safe ID generation
|
|
131
|
+
*/
|
|
132
|
+
export type IdBranch = SlotBranch | ArrayItemBranch | TemplateBranch | SwitchBranch | CustomBranch;
|
|
133
|
+
/**
|
|
134
|
+
* Metadata for arrays containing mixed static values and builders
|
|
135
|
+
* Tracks which indices contain builders for selective resolution
|
|
136
|
+
*/
|
|
137
|
+
export interface MixedArrayMetadata {
|
|
138
|
+
readonly array: readonly unknown[];
|
|
139
|
+
readonly builderIndices: ReadonlySet<number>;
|
|
140
|
+
readonly objectIndices: ReadonlySet<number>;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Metadata for template storage in FluentBuilderBase
|
|
144
|
+
*/
|
|
145
|
+
export interface TemplateMetadata {
|
|
146
|
+
readonly data: string;
|
|
147
|
+
readonly output: string;
|
|
148
|
+
readonly dynamic?: boolean;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Path type for targeting where to inject values in nested structures
|
|
152
|
+
* Example: ["actions", 0, "label"] targets actions[0].label
|
|
153
|
+
*/
|
|
154
|
+
export type ValuePath = ReadonlyArray<string | number>;
|
|
155
|
+
/**
|
|
156
|
+
* Metadata for switch storage in FluentBuilderBase
|
|
157
|
+
*/
|
|
158
|
+
export interface SwitchMetadata<C extends BaseBuildContext = BaseBuildContext> {
|
|
159
|
+
readonly path: ValuePath;
|
|
160
|
+
readonly switchFn: (context: C, globalCaseIndex?: number) => unknown;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Helper type for conditional property values in if/ifElse methods
|
|
164
|
+
* Allows passing unwrapped Asset builders to AssetWrapper properties
|
|
165
|
+
* Enables: .if(() => true, "label", text().withValue("..."))
|
|
166
|
+
* Instead of: .if(() => true, "label", { asset: text().withValue("...") })
|
|
167
|
+
*/
|
|
168
|
+
export type ConditionalValue<T, C extends BaseBuildContext> = T extends AssetWrapper<infer A> | undefined ? T | FluentBuilder<T, C> | FluentBuilder<A, C> | A | Array<FluentBuilder<A, C> | A> | (() => T | FluentBuilder<T, C> | FluentBuilder<A, C> | A | Array<FluentBuilder<A, C> | A>) : T extends Array<AssetWrapper<infer A>> ? T | Array<AssetWrapper<A> | FluentBuilder<AssetWrapper<A>, C> | FluentBuilder<A, C> | A> | (() => T | Array<AssetWrapper<A> | FluentBuilder<AssetWrapper<A>, C> | FluentBuilder<A, C> | A>) : // Case 3: Other properties
|
|
169
|
+
T | FluentBuilder<T, C> | (() => T | FluentBuilder<T, C>);
|
|
170
|
+
/**
|
|
171
|
+
* Transforms property types to allow TaggedTemplateValue for scalars
|
|
172
|
+
* and FluentBuilder for AssetWrapper properties.
|
|
173
|
+
*/
|
|
174
|
+
export type FluentPartialValue<T, C extends BaseBuildContext = BaseBuildContext> = T extends string ? T | TaggedTemplateValue<string> : T extends number ? T | TaggedTemplateValue<number> : T extends boolean ? T | TaggedTemplateValue<boolean> : T extends bigint ? T | TaggedTemplateValue<bigint> : T extends AssetWrapper<infer A> ? T | FluentBuilder<A, C> | A : T extends Array<AssetWrapper<infer A>> ? Array<AssetWrapper<A> | FluentBuilder<A, C> | A> : T extends Array<infer E> ? Array<FluentPartialValue<E, C>> : T extends object ? {
|
|
175
|
+
[K in keyof T]: FluentPartialValue<T[K], C>;
|
|
176
|
+
} : T;
|
|
177
|
+
/**
|
|
178
|
+
* Partial type for builder constructors that allows TaggedTemplateValue for scalars.
|
|
179
|
+
*/
|
|
180
|
+
export type FluentPartial<T, C extends BaseBuildContext = BaseBuildContext> = {
|
|
181
|
+
[K in keyof T]?: FluentPartialValue<T[K], C>;
|
|
182
|
+
};
|
|
183
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Asset, Flow, DataModel, Navigation, Schema } from "@player-ui/types";
|
|
2
|
+
import { BaseBuildContext } from "../base-builder";
|
|
3
|
+
/**
|
|
4
|
+
* Core options for creating a Player-UI Flow
|
|
5
|
+
*/
|
|
6
|
+
interface CoreFlowOptions<T extends Asset = Asset, C extends BaseBuildContext = BaseBuildContext> {
|
|
7
|
+
id?: string;
|
|
8
|
+
views: Array<T | {
|
|
9
|
+
build(context?: C): T;
|
|
10
|
+
} | ((ctx: C) => T)>;
|
|
11
|
+
data?: DataModel;
|
|
12
|
+
schema?: Schema.Schema;
|
|
13
|
+
navigation: Navigation;
|
|
14
|
+
context?: C;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Options for creating a Player-UI Flow
|
|
18
|
+
* Allows additional properties to be passed through to the final Flow
|
|
19
|
+
*/
|
|
20
|
+
export type FlowOptions<T extends Asset = Asset, C extends BaseBuildContext = BaseBuildContext> = CoreFlowOptions<T, C> & Omit<Flow<T>, keyof CoreFlowOptions<T, C> | "views">;
|
|
21
|
+
export declare function flow<T extends Asset = Asset>(options: FlowOptions<T>): Flow<T>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Asset, AssetWrapper, Binding, Expression } from "@player-ui/types";
|
|
2
|
+
export interface SimpleModifier<Type extends string> {
|
|
3
|
+
/** THe mofifier type */
|
|
4
|
+
type: Type;
|
|
5
|
+
}
|
|
6
|
+
export declare const ActionRoles: readonly ["primary", "secondary", "tertiary", "upsell", "back", "link", "inline-link", "tertiary-button"];
|
|
7
|
+
export type ActionRole = (typeof ActionRoles)[number];
|
|
8
|
+
/**
|
|
9
|
+
* User actions can be represented in several places.
|
|
10
|
+
* Each view typically has one or more actions that allow the user to navigate away from that view.
|
|
11
|
+
* In addition, several asset types can have actions that apply to that asset only.
|
|
12
|
+
*/
|
|
13
|
+
export interface ActionAsset<AnyAsset extends Asset = Asset> extends Asset<"action"> {
|
|
14
|
+
/** The transition value of the action in the state machine */
|
|
15
|
+
value?: string;
|
|
16
|
+
/** A text-like asset for the action's label */
|
|
17
|
+
label?: AssetWrapper<AnyAsset>;
|
|
18
|
+
/** An optional expression to execute before transitioning */
|
|
19
|
+
exp?: Expression;
|
|
20
|
+
/** An optional string that describes the action for screen-readers */
|
|
21
|
+
accessibility?: string;
|
|
22
|
+
/** An optional confirmation dialog to show before executing the action */
|
|
23
|
+
confirmation?: {
|
|
24
|
+
/** message asking for confirmation */
|
|
25
|
+
message: string;
|
|
26
|
+
/** label for the confirm button */
|
|
27
|
+
affirmativeLabel: string;
|
|
28
|
+
/** label for the deny button */
|
|
29
|
+
negativeLabel?: string;
|
|
30
|
+
};
|
|
31
|
+
/** Additional optional data to assist with the action interactions on the page */
|
|
32
|
+
metaData?: ActionMetaData;
|
|
33
|
+
/** Triggers the listed bindings to be validated */
|
|
34
|
+
validate?: Array<Binding> | Binding;
|
|
35
|
+
}
|
|
36
|
+
export interface ActionMetaData {
|
|
37
|
+
/** beacon to send when the action runs */
|
|
38
|
+
beacon?: string | Record<string, unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* A semantic hint to render the action in different user contexts
|
|
41
|
+
*/
|
|
42
|
+
role?: ActionRole;
|
|
43
|
+
/** Force transition to the next view without checking for validation TODO need to update this to support an expression */
|
|
44
|
+
skipValidation?: boolean;
|
|
45
|
+
/** Size of the button */
|
|
46
|
+
size?: "small" | "medium" | "large";
|
|
47
|
+
/** true to indicate the button should be disabled */
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
/** true to indicate that the button label should be hidden */
|
|
50
|
+
hideLabel?: boolean;
|
|
51
|
+
/** true to indicate that the button icon should be hidden */
|
|
52
|
+
hideIcon?: boolean;
|
|
53
|
+
/** true to indicate that the action should display as a button instead of a link */
|
|
54
|
+
showAsButton?: boolean;
|
|
55
|
+
/** true to indicate to take container width, responsive: Full Width on mobile */
|
|
56
|
+
fullWidth?: boolean | "responsive";
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=action.d.ts.map
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { Asset, AssetWrapper, Binding } from "@player-ui/types";
|
|
2
|
+
export declare const ALL_CATEGORIES: readonly ["recommended"];
|
|
3
|
+
export type ChoiceItemCategory = (typeof ALL_CATEGORIES)[number];
|
|
4
|
+
/** Any modifier that can appear on a choice */
|
|
5
|
+
export type ChoiceModifier = {
|
|
6
|
+
/** The default type */
|
|
7
|
+
type: "tag";
|
|
8
|
+
/** A compact modifier renders a radio button as a dropdown */
|
|
9
|
+
value: "compact";
|
|
10
|
+
};
|
|
11
|
+
/** Optional tag to set choice as readonly */
|
|
12
|
+
export type ChoiceInputModifier = {
|
|
13
|
+
/** The default type */
|
|
14
|
+
type: "input";
|
|
15
|
+
/** modifier to set the choices to readonly */
|
|
16
|
+
value: "readonly";
|
|
17
|
+
};
|
|
18
|
+
export type ChoiceItemMetadata = {
|
|
19
|
+
/** optional category for the choice item to determine its purpose:
|
|
20
|
+
* recommended: this choice item is recommended for the user over or in addition to other items
|
|
21
|
+
*/
|
|
22
|
+
category?: ChoiceItemCategory;
|
|
23
|
+
};
|
|
24
|
+
export interface ChoiceItem<AnyAsset extends Asset = Asset> {
|
|
25
|
+
/** The id associated with the choice item */
|
|
26
|
+
id: string;
|
|
27
|
+
/** The id used for replay tests. */
|
|
28
|
+
automationId?: string;
|
|
29
|
+
/** The label describing the choice. */
|
|
30
|
+
label?: AssetWrapper<AnyAsset>;
|
|
31
|
+
/** The icon describing the choice. */
|
|
32
|
+
icon?: AssetWrapper<AnyAsset>;
|
|
33
|
+
/** The help for the choice. */
|
|
34
|
+
help?: AssetWrapper<AnyAsset>;
|
|
35
|
+
/** Support the legacy choiceHelp prop. No storybook docs for this; deprecated in favour of the "help" field. */
|
|
36
|
+
choiceHelp?: AssetWrapper<AnyAsset>;
|
|
37
|
+
/** The description of the choice. */
|
|
38
|
+
description?: AssetWrapper<AnyAsset>;
|
|
39
|
+
/** The footer of the choice. */
|
|
40
|
+
footer?: AssetWrapper<AnyAsset>;
|
|
41
|
+
/**
|
|
42
|
+
* The value to set when this choice is selected
|
|
43
|
+
*/
|
|
44
|
+
value?: string | number | boolean | null;
|
|
45
|
+
/** The details shown when a user selects the choice item */
|
|
46
|
+
choiceDetail?: AssetWrapper<AnyAsset>;
|
|
47
|
+
/**
|
|
48
|
+
* Any modifiers for the current item. No storybook docs for this as "readonly" (the only modifier) shouldn't be used anymore.
|
|
49
|
+
*/
|
|
50
|
+
modifiers?: Array<ChoiceInputModifier>;
|
|
51
|
+
/** MetaData for the choiceItem */
|
|
52
|
+
metaData?: ChoiceItemMetadata;
|
|
53
|
+
}
|
|
54
|
+
export interface ChoiceMetaData {
|
|
55
|
+
/** Display the asset a little differently based on the role, monthselector only applies to multiselect asset */
|
|
56
|
+
role?: "tiles" | "monthselector";
|
|
57
|
+
/** used to set tiles to jumbo manually */
|
|
58
|
+
tileSize?: "jumbo" | undefined;
|
|
59
|
+
/** should The placeholder be disabled or not */
|
|
60
|
+
placeholderSelectable?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Choice assets are more specific type of data collection element
|
|
64
|
+
* where user is presented with a number of predefined choices and
|
|
65
|
+
* asked to select a single answer.
|
|
66
|
+
*/
|
|
67
|
+
export interface ChoiceAsset<AnyAsset extends Asset = Asset> extends Asset<"choice"> {
|
|
68
|
+
/** The binding used to keep track of the selected Choice */
|
|
69
|
+
binding: Binding;
|
|
70
|
+
/** The choiceItems used as options */
|
|
71
|
+
choices?: Array<ChoiceItem<AnyAsset>>;
|
|
72
|
+
/** The label describing the choice field. */
|
|
73
|
+
label?: AssetWrapper<AnyAsset>;
|
|
74
|
+
/** choice help providing additional info that could be helpful */
|
|
75
|
+
help?: AssetWrapper<AnyAsset>;
|
|
76
|
+
/** choice note */
|
|
77
|
+
note?: AssetWrapper;
|
|
78
|
+
/** placeholder string to show by default for the choice */
|
|
79
|
+
placeholder?: string;
|
|
80
|
+
/** any accessibility text to be added as an aria label.*/
|
|
81
|
+
accessibility?: string;
|
|
82
|
+
/** The info that appears underneath the choice */
|
|
83
|
+
additionalInfo?: AssetWrapper<AnyAsset>;
|
|
84
|
+
/** The resulting Text that appears underneath the choice */
|
|
85
|
+
resultText?: AssetWrapper<AnyAsset>;
|
|
86
|
+
/** */
|
|
87
|
+
modifiers?: Array<ChoiceModifier | ChoiceInputModifier>;
|
|
88
|
+
/** Additional metaData for the Choice */
|
|
89
|
+
metaData?: ChoiceMetaData;
|
|
90
|
+
/** The main action associated with choices */
|
|
91
|
+
action?: AssetWrapper<AnyAsset>;
|
|
92
|
+
/** The main image associated with choices */
|
|
93
|
+
image?: AssetWrapper<AnyAsset>;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=choice.d.ts.map
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { Asset, AssetWrapper } from "@player-ui/types";
|
|
2
|
+
import { ActionAsset } from "./action";
|
|
3
|
+
/** A Modifier to apply 'highlight' styling to the collection */
|
|
4
|
+
export interface CalloutModifier {
|
|
5
|
+
/** the type of modifier */
|
|
6
|
+
type: "callout";
|
|
7
|
+
/** specification on why the callout needs to be highlighted--this determines the coloring */
|
|
8
|
+
value: "support" | "legal";
|
|
9
|
+
}
|
|
10
|
+
export interface TagModifier {
|
|
11
|
+
/** the type of modifier */
|
|
12
|
+
type: "tag";
|
|
13
|
+
/** the value for the tag */
|
|
14
|
+
value: "block";
|
|
15
|
+
}
|
|
16
|
+
export interface CollectionMetaData {
|
|
17
|
+
/** the role of the collection */
|
|
18
|
+
role?: "section" | "ocr-surface" | "ocr-instructions-lighting" | "ocr-instructions-positioning" | "swd-head-start-text" | "premium" | "address";
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A collection is a group of assets
|
|
22
|
+
*
|
|
23
|
+
* @asset
|
|
24
|
+
*/
|
|
25
|
+
export interface Collection<AnyAsset extends Asset = Asset> extends Asset<"collection"> {
|
|
26
|
+
/** The collection items to show */
|
|
27
|
+
values?: Array<AssetWrapper<AnyAsset>>;
|
|
28
|
+
/** The additional information to show */
|
|
29
|
+
additionalInfo?: AssetWrapper<AnyAsset>;
|
|
30
|
+
/** The result text to show */
|
|
31
|
+
resultText?: AssetWrapper<AnyAsset> | Array<AssetWrapper<AnyAsset>>;
|
|
32
|
+
/** The label defining the collection */
|
|
33
|
+
label?: AssetWrapper<AnyAsset>;
|
|
34
|
+
/** Actions attached to the collection */
|
|
35
|
+
actions?: Array<AssetWrapper<ActionAsset>>;
|
|
36
|
+
/** Extra data associated with the collection */
|
|
37
|
+
metaData?: CollectionMetaData;
|
|
38
|
+
/** Ways to modify how the component looks */
|
|
39
|
+
modifiers?: Array<CalloutModifier | TagModifier>;
|
|
40
|
+
}
|
|
41
|
+
export interface FieldCollectionMetaData {
|
|
42
|
+
/** the role of the field collection */
|
|
43
|
+
role?: "section" | "address" | "name" | "phone";
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A field collection is a group of field assets
|
|
47
|
+
*
|
|
48
|
+
* @asset
|
|
49
|
+
*/
|
|
50
|
+
export interface FieldCollection<AnyAsset extends Asset = Asset> extends Asset<"fieldCollection"> {
|
|
51
|
+
/** The collection items to show */
|
|
52
|
+
values?: Array<AssetWrapper<AnyAsset>>;
|
|
53
|
+
/** The additional information to show */
|
|
54
|
+
additionalInfo?: AssetWrapper<AnyAsset>;
|
|
55
|
+
/** The result text to show */
|
|
56
|
+
resultText?: AssetWrapper<AnyAsset>;
|
|
57
|
+
/** The label defining the collection */
|
|
58
|
+
label?: AssetWrapper<AnyAsset>;
|
|
59
|
+
/** Extra data associated with the collection */
|
|
60
|
+
metaData?: FieldCollectionMetaData;
|
|
61
|
+
/** Actions attached to the collection */
|
|
62
|
+
actions?: Array<AssetWrapper<ActionAsset>>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The OverviewCollection asset
|
|
66
|
+
*
|
|
67
|
+
* @asset
|
|
68
|
+
*/
|
|
69
|
+
export interface OverviewCollection<AnyAsset extends Asset = Asset> extends Asset<"overviewCollection"> {
|
|
70
|
+
/** The collection items to show */
|
|
71
|
+
values?: Array<AssetWrapper<AnyAsset>>;
|
|
72
|
+
/** The label defining the collection */
|
|
73
|
+
label?: AssetWrapper<AnyAsset>;
|
|
74
|
+
/** Actions attached to the collection */
|
|
75
|
+
actions?: Array<AssetWrapper<ActionAsset>>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* SplashCollection asset is very similar to the basic Collection, which is a group of assets.
|
|
79
|
+
* It can also contain an image. It is intended to display read-only data.
|
|
80
|
+
*/
|
|
81
|
+
export interface SplashCollection<AnyAsset extends Asset = Asset> extends Asset<"splashCollection"> {
|
|
82
|
+
/** Extra data associated with the Asset */
|
|
83
|
+
metaData?: {
|
|
84
|
+
/** Changes the style slightly */
|
|
85
|
+
role?: "promotional";
|
|
86
|
+
};
|
|
87
|
+
/** Asset container for an image */
|
|
88
|
+
splash?: AssetWrapper<AnyAsset>;
|
|
89
|
+
/** Label, typically a single text asset */
|
|
90
|
+
label?: AssetWrapper<AnyAsset>;
|
|
91
|
+
/** Array of assets, typically text assets */
|
|
92
|
+
values?: Array<AssetWrapper<AnyAsset>>;
|
|
93
|
+
/** @deprecated additionalInfo in splash collection is no longer supported */
|
|
94
|
+
additionalInfo?: AssetWrapper<AnyAsset>;
|
|
95
|
+
/** @deprecated resultText in splash collection is no longer supported */
|
|
96
|
+
resultText?: AssetWrapper<AnyAsset>;
|
|
97
|
+
/** @deprecated actions in splash collection is no longer supported */
|
|
98
|
+
actions?: Array<AssetWrapper<ActionAsset>>;
|
|
99
|
+
}
|
|
100
|
+
export type CollectionType = Collection | FieldCollection | OverviewCollection | SplashCollection;
|
|
101
|
+
export type CollectionValue = AssetWrapper<Asset<string>>;
|
|
102
|
+
//# sourceMappingURL=collection.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Schema } from "@player-ui/types";
|
|
2
|
+
import { SyncWaterfallHook } from "tapable-ts";
|
|
3
|
+
import { SchemaGeneratorInput } from "./types";
|
|
4
|
+
/** Symbol to indicate that a schema node should be generated with a different name */
|
|
5
|
+
export declare const SchemaTypeName: unique symbol;
|
|
6
|
+
export type LoggingInterface = Pick<Console, "warn" | "error" | "log">;
|
|
7
|
+
/**
|
|
8
|
+
* Generator for `Schema.Schema` Objects
|
|
9
|
+
*/
|
|
10
|
+
export declare class SchemaGenerator {
|
|
11
|
+
private children;
|
|
12
|
+
private generatedDataTypes;
|
|
13
|
+
private typeNameCache;
|
|
14
|
+
private logger;
|
|
15
|
+
hooks: {
|
|
16
|
+
createSchemaNode: SyncWaterfallHook<[node: Schema.DataType<unknown>, originalProperty: Record<string | symbol, unknown>], Record<string, any>>;
|
|
17
|
+
};
|
|
18
|
+
constructor(logger?: LoggingInterface);
|
|
19
|
+
/**
|
|
20
|
+
* Converts an object to a `Schema.Schema` representation
|
|
21
|
+
* Optimized to minimize object operations and memory allocations
|
|
22
|
+
*/
|
|
23
|
+
toSchema: (schema: SchemaGeneratorInput) => Schema.Schema;
|
|
24
|
+
private processChild;
|
|
25
|
+
/**
|
|
26
|
+
* Cached type name generation
|
|
27
|
+
*/
|
|
28
|
+
private makePlaceholderType;
|
|
29
|
+
/**
|
|
30
|
+
* Cached array type name generation
|
|
31
|
+
*/
|
|
32
|
+
private makePlaceholderArrayType;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|