@player-ui/player 0.3.1-next.1 → 0.3.1
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/index.cjs.js +899 -336
- package/dist/index.d.ts +275 -93
- package/dist/index.esm.js +890 -334
- package/dist/player.dev.js +11429 -0
- package/dist/player.prod.js +2 -0
- package/package.json +16 -5
- package/src/binding/binding.ts +8 -0
- package/src/binding/index.ts +14 -4
- package/src/binding/resolver.ts +2 -4
- package/src/binding-grammar/custom/index.ts +17 -9
- package/src/controllers/constants/index.ts +9 -5
- package/src/controllers/{data.ts → data/controller.ts} +62 -61
- package/src/controllers/data/index.ts +1 -0
- package/src/controllers/data/utils.ts +42 -0
- package/src/controllers/flow/controller.ts +16 -12
- package/src/controllers/flow/flow.ts +6 -1
- package/src/controllers/index.ts +1 -1
- package/src/controllers/validation/binding-tracker.ts +42 -19
- package/src/controllers/validation/controller.ts +375 -148
- package/src/controllers/view/asset-transform.ts +4 -1
- package/src/controllers/view/controller.ts +20 -3
- package/src/data/dependency-tracker.ts +14 -0
- package/src/data/local-model.ts +25 -1
- package/src/data/model.ts +60 -8
- package/src/data/noop-model.ts +2 -0
- package/src/expressions/evaluator-functions.ts +24 -2
- package/src/expressions/evaluator.ts +38 -34
- package/src/expressions/index.ts +1 -0
- package/src/expressions/parser.ts +116 -44
- package/src/expressions/types.ts +50 -17
- package/src/expressions/utils.ts +143 -1
- package/src/player.ts +60 -46
- package/src/plugins/default-exp-plugin.ts +57 -0
- package/src/plugins/flow-exp-plugin.ts +2 -2
- package/src/schema/schema.ts +28 -9
- package/src/string-resolver/index.ts +26 -9
- package/src/types.ts +6 -3
- package/src/validator/binding-map-splice.ts +59 -0
- package/src/validator/index.ts +1 -0
- package/src/validator/types.ts +11 -3
- package/src/validator/validation-middleware.ts +58 -6
- package/src/view/parser/index.ts +51 -3
- package/src/view/plugins/applicability.ts +1 -1
- package/src/view/plugins/string-resolver.ts +35 -9
- package/src/view/plugins/template-plugin.ts +1 -6
- package/src/view/resolver/index.ts +119 -54
- package/src/view/resolver/types.ts +48 -7
package/dist/index.d.ts
CHANGED
|
@@ -58,6 +58,13 @@ interface BindingParserOptions {
|
|
|
58
58
|
* Get the result of evaluating an expression
|
|
59
59
|
*/
|
|
60
60
|
evaluate: (exp: string) => any;
|
|
61
|
+
/**
|
|
62
|
+
* Without readOnly, if a binding such as this is used: arr[key='does not exist'],
|
|
63
|
+
* then an object with that key will be created.
|
|
64
|
+
* This is done to make assignment such as arr[key='abc'].val = 'foo' work smoothly.
|
|
65
|
+
* Setting readOnly to true will prevent this behavior, avoiding unintended data changes.
|
|
66
|
+
*/
|
|
67
|
+
readOnly?: boolean;
|
|
61
68
|
}
|
|
62
69
|
declare type Getter = (path: BindingInstance) => any;
|
|
63
70
|
declare type RawBindingSegment = number | string;
|
|
@@ -116,6 +123,8 @@ declare function getBindingSegments(binding: BindingLike): Array<string | number
|
|
|
116
123
|
declare function findInArray<T extends Record<string | number, object>>(array: Array<T>, key: string | number, value: T): number | undefined;
|
|
117
124
|
|
|
118
125
|
declare const SIMPLE_BINDING_REGEX: RegExp;
|
|
126
|
+
declare const BINDING_BRACKETS_REGEX: RegExp;
|
|
127
|
+
declare type BeforeResolveNodeContext = Required<NormalizedResult> & ResolveBindingASTOptions;
|
|
119
128
|
/** A parser for creating bindings from a string */
|
|
120
129
|
declare class BindingParser {
|
|
121
130
|
private cache;
|
|
@@ -123,7 +132,7 @@ declare class BindingParser {
|
|
|
123
132
|
private parserOptions;
|
|
124
133
|
hooks: {
|
|
125
134
|
skipOptimization: SyncBailHook<[string], boolean, Record<string, any>>;
|
|
126
|
-
beforeResolveNode: SyncWaterfallHook<[AnyNode,
|
|
135
|
+
beforeResolveNode: SyncWaterfallHook<[AnyNode, BeforeResolveNodeContext], Record<string, any>>;
|
|
127
136
|
};
|
|
128
137
|
constructor(options?: Partial<BindingParserOptions>);
|
|
129
138
|
/**
|
|
@@ -165,6 +174,10 @@ interface DataModelOptions {
|
|
|
165
174
|
* A flag to set to ignore any default value in the schema, and just use the raw value
|
|
166
175
|
*/
|
|
167
176
|
ignoreDefaultValue?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* A flag to indicate that this update should happen silently
|
|
179
|
+
*/
|
|
180
|
+
silent?: boolean;
|
|
168
181
|
/** Other context associated with this request */
|
|
169
182
|
context?: {
|
|
170
183
|
/** The data model to use when getting other data from the context of this request */
|
|
@@ -174,16 +187,19 @@ interface DataModelOptions {
|
|
|
174
187
|
interface DataModelWithParser<Options = DataModelOptions> {
|
|
175
188
|
get(binding: BindingLike, options?: Options): any;
|
|
176
189
|
set(transaction: [BindingLike, any][], options?: Options): Updates;
|
|
190
|
+
delete(binding: BindingLike, options?: Options): void;
|
|
177
191
|
}
|
|
178
192
|
interface DataModelImpl<Options = DataModelOptions> {
|
|
179
193
|
get(binding: BindingInstance, options?: Options): any;
|
|
180
194
|
set(transaction: BatchSetTransaction, options?: Options): Updates;
|
|
195
|
+
delete(binding: BindingInstance, options?: Options): void;
|
|
181
196
|
}
|
|
182
197
|
interface DataModelMiddleware {
|
|
183
198
|
/** The name of the middleware */
|
|
184
199
|
name?: string;
|
|
185
200
|
set(transaction: BatchSetTransaction, options?: DataModelOptions, next?: DataModelImpl): Updates;
|
|
186
201
|
get(binding: BindingInstance, options?: DataModelOptions, next?: DataModelImpl): any;
|
|
202
|
+
delete?(binding: BindingInstance, options?: DataModelOptions, next?: DataModelImpl): void;
|
|
187
203
|
reset?(): void;
|
|
188
204
|
}
|
|
189
205
|
/** Wrap the inputs of the DataModel with calls to parse raw binding inputs */
|
|
@@ -208,6 +224,7 @@ declare class PipelinedDataModel implements DataModelImpl {
|
|
|
208
224
|
reset(model?: {}): void;
|
|
209
225
|
set(transaction: BatchSetTransaction, options?: DataModelOptions): Updates;
|
|
210
226
|
get(binding: BindingInstance, options?: DataModelOptions): any;
|
|
227
|
+
delete(binding: BindingInstance, options?: DataModelOptions): void;
|
|
211
228
|
}
|
|
212
229
|
|
|
213
230
|
declare type DependencySets = 'core' | 'children';
|
|
@@ -246,6 +263,7 @@ declare class DependencyMiddleware extends DependencyTracker implements DataMode
|
|
|
246
263
|
constructor();
|
|
247
264
|
set(transaction: BatchSetTransaction, options?: DataModelOptions, next?: DataModelImpl | undefined): Updates;
|
|
248
265
|
get(binding: BindingInstance, options?: DataModelOptions, next?: DataModelImpl | undefined): any;
|
|
266
|
+
delete(binding: BindingInstance, options?: DataModelOptions, next?: DataModelImpl | undefined): void | undefined;
|
|
249
267
|
}
|
|
250
268
|
/** A data-model that tracks dependencies of read/written data */
|
|
251
269
|
declare class DependencyModel<Options = DataModelOptions> extends DependencyTracker implements DataModelImpl<Options> {
|
|
@@ -253,6 +271,7 @@ declare class DependencyModel<Options = DataModelOptions> extends DependencyTrac
|
|
|
253
271
|
constructor(rootModel: DataModelImpl<Options>);
|
|
254
272
|
set(transaction: BatchSetTransaction, options?: Options): Updates;
|
|
255
273
|
get(binding: BindingInstance, options?: Options): any;
|
|
274
|
+
delete(binding: BindingInstance, options?: Options): void;
|
|
256
275
|
}
|
|
257
276
|
|
|
258
277
|
/**
|
|
@@ -262,6 +281,7 @@ declare class DependencyModel<Options = DataModelOptions> extends DependencyTrac
|
|
|
262
281
|
declare class NOOPDataModel implements DataModelImpl {
|
|
263
282
|
get(): undefined;
|
|
264
283
|
set(): never[];
|
|
284
|
+
delete(): void;
|
|
265
285
|
}
|
|
266
286
|
/** You only really need 1 instance of the NOOP model */
|
|
267
287
|
declare const NOOP_MODEL: NOOPDataModel;
|
|
@@ -277,6 +297,7 @@ declare class LocalModel implements DataModelImpl {
|
|
|
277
297
|
reset(model?: {}): void;
|
|
278
298
|
get(binding?: BindingInstance): any;
|
|
279
299
|
set(transaction: BatchSetTransaction): Updates;
|
|
300
|
+
delete(binding: BindingInstance): void;
|
|
280
301
|
}
|
|
281
302
|
|
|
282
303
|
declare type LogFn = (...args: Array<any>) => void;
|
|
@@ -345,8 +366,13 @@ declare class ProxyLogger implements Logger {
|
|
|
345
366
|
readonly error: (...args: any[]) => void;
|
|
346
367
|
}
|
|
347
368
|
|
|
369
|
+
declare type ExpressionObjectType = {
|
|
370
|
+
/** The expression to eval */
|
|
371
|
+
value: BasicExpressionTypes;
|
|
372
|
+
};
|
|
348
373
|
declare type ExpressionLiteralType = string | number | boolean | undefined | null;
|
|
349
|
-
declare type
|
|
374
|
+
declare type BasicExpressionTypes = ExpressionLiteralType | ExpressionObjectType | Array<ExpressionLiteralType | ExpressionObjectType>;
|
|
375
|
+
declare type ExpressionType = BasicExpressionTypes | ExpressionNode;
|
|
350
376
|
interface OperatorProcessingOptions {
|
|
351
377
|
/**
|
|
352
378
|
* When set to a falsy value, the arguments passed to the handler will be raw AST Nodes
|
|
@@ -370,11 +396,28 @@ declare type ExpressionHandler<T extends readonly unknown[] = unknown[], R = voi
|
|
|
370
396
|
declare const ExpNodeOpaqueIdentifier: unique symbol;
|
|
371
397
|
/** Checks if the input is an already processed Expression node */
|
|
372
398
|
declare function isExpressionNode(x: any): x is ExpressionNode;
|
|
399
|
+
interface NodePosition {
|
|
400
|
+
/** The character location */
|
|
401
|
+
character: number;
|
|
402
|
+
}
|
|
403
|
+
interface NodeLocation {
|
|
404
|
+
/** The start of the node */
|
|
405
|
+
start: NodePosition;
|
|
406
|
+
/** The end of the node */
|
|
407
|
+
end: NodePosition;
|
|
408
|
+
}
|
|
373
409
|
interface BaseNode<T> {
|
|
374
410
|
/** The thing to discriminate the AST type on */
|
|
375
411
|
type: T;
|
|
376
412
|
/** How to tell this apart from other objects */
|
|
377
413
|
__id: typeof ExpNodeOpaqueIdentifier;
|
|
414
|
+
/** The location of the node in the source expression string */
|
|
415
|
+
location?: NodeLocation;
|
|
416
|
+
/**
|
|
417
|
+
* The error that occurred while parsing this node
|
|
418
|
+
* This is only set if the parsing mode is set to non-strict
|
|
419
|
+
*/
|
|
420
|
+
error?: Error;
|
|
378
421
|
}
|
|
379
422
|
/** A helper interface for nodes that container left and right children */
|
|
380
423
|
interface DirectionalNode {
|
|
@@ -393,11 +436,7 @@ interface BinaryNode extends BaseNode<'BinaryExpression'>, DirectionalNode {
|
|
|
393
436
|
/** The operation to perform on the nodes */
|
|
394
437
|
operator: string;
|
|
395
438
|
}
|
|
396
|
-
interface LogicalNode extends BaseNode<'LogicalExpression'
|
|
397
|
-
/** The left hand side of the equation */
|
|
398
|
-
left: any;
|
|
399
|
-
/** The right hand side of the equation */
|
|
400
|
-
right: any;
|
|
439
|
+
interface LogicalNode extends BaseNode<'LogicalExpression'>, DirectionalNode {
|
|
401
440
|
/** The logical operation to perform on the nodes */
|
|
402
441
|
operator: string;
|
|
403
442
|
}
|
|
@@ -405,7 +444,7 @@ interface UnaryNode extends BaseNode<'UnaryExpression'> {
|
|
|
405
444
|
/** The operation to perform on the node */
|
|
406
445
|
operator: string;
|
|
407
446
|
/** The single argument that the operation should be performed on */
|
|
408
|
-
argument:
|
|
447
|
+
argument: ExpressionNode;
|
|
409
448
|
}
|
|
410
449
|
declare type ThisNode = BaseNode<'ThisExpression'>;
|
|
411
450
|
interface ModelRefNode extends BaseNode<'ModelRef'> {
|
|
@@ -416,9 +455,9 @@ interface ObjectNode extends BaseNode<'Object'> {
|
|
|
416
455
|
/** */
|
|
417
456
|
attributes: Array<{
|
|
418
457
|
/** The property name of the object */
|
|
419
|
-
key:
|
|
458
|
+
key: ExpressionNode;
|
|
420
459
|
/** the associated value */
|
|
421
|
-
value:
|
|
460
|
+
value: ExpressionNode;
|
|
422
461
|
}>;
|
|
423
462
|
}
|
|
424
463
|
interface MemberExpressionNode extends BaseNode<'MemberExpression'> {
|
|
@@ -443,13 +482,13 @@ interface CompoundNode extends BaseNode<'Compound'> {
|
|
|
443
482
|
}
|
|
444
483
|
interface CallExpressionNode extends BaseNode<'CallExpression'> {
|
|
445
484
|
/** The arguments to the function */
|
|
446
|
-
args:
|
|
485
|
+
args: ExpressionNode[];
|
|
447
486
|
/** The function name */
|
|
448
487
|
callTarget: IdentifierNode;
|
|
449
488
|
}
|
|
450
489
|
interface ArrayExpressionNode extends BaseNode<'ArrayExpression'> {
|
|
451
490
|
/** The items in an array */
|
|
452
|
-
elements:
|
|
491
|
+
elements: ExpressionNode[];
|
|
453
492
|
}
|
|
454
493
|
interface IdentifierNode extends BaseNode<'Identifier'> {
|
|
455
494
|
/** The variable name */
|
|
@@ -466,6 +505,10 @@ declare type ExpressionNodeType = ExpressionNode['type'];
|
|
|
466
505
|
interface HookOptions extends ExpressionContext {
|
|
467
506
|
/** Given an expression node */
|
|
468
507
|
resolveNode: (node: ExpressionNode) => any;
|
|
508
|
+
/** Enabling this flag skips calling the onError hook, and just throws errors back to the caller.
|
|
509
|
+
* The caller is responsible for handling the error.
|
|
510
|
+
*/
|
|
511
|
+
throwErrors?: boolean;
|
|
469
512
|
}
|
|
470
513
|
declare type ExpressionEvaluatorOptions = Omit<HookOptions, 'resolveNode' | 'evaluate'>;
|
|
471
514
|
declare type ExpressionEvaluatorFunction = (exp: ExpressionType, options?: ExpressionEvaluatorOptions) => any;
|
|
@@ -477,6 +520,10 @@ declare class ExpressionEvaluator {
|
|
|
477
520
|
readonly hooks: {
|
|
478
521
|
/** Resolve an AST node for an expression to a value */
|
|
479
522
|
resolve: SyncWaterfallHook<[any, ExpressionNode, HookOptions], Record<string, any>>;
|
|
523
|
+
/** Gets the options that will be passed in calls to the resolve hook */
|
|
524
|
+
resolveOptions: SyncWaterfallHook<[HookOptions], Record<string, any>>;
|
|
525
|
+
/** Allows users to change the expression to be evaluated before processing */
|
|
526
|
+
beforeEvaluate: SyncWaterfallHook<[ExpressionType, HookOptions], Record<string, any>>;
|
|
480
527
|
/**
|
|
481
528
|
* An optional means of handling an error in the expression execution
|
|
482
529
|
* Return true if handled, to stop propagation of the error
|
|
@@ -492,7 +539,7 @@ declare class ExpressionEvaluator {
|
|
|
492
539
|
};
|
|
493
540
|
reset(): void;
|
|
494
541
|
constructor(defaultOptions: ExpressionEvaluatorOptions);
|
|
495
|
-
evaluate(
|
|
542
|
+
evaluate(expr: ExpressionType, options?: ExpressionEvaluatorOptions): any;
|
|
496
543
|
addExpressionFunction<T extends readonly unknown[], R>(name: string, handler: ExpressionHandler<T, R>): void;
|
|
497
544
|
addBinaryOperator(operator: string, handler: BinaryOperator): void;
|
|
498
545
|
addUnaryOperator(operator: string, handler: UnaryOperator): void;
|
|
@@ -505,6 +552,20 @@ declare class ExpressionEvaluator {
|
|
|
505
552
|
|
|
506
553
|
/** Generates a function by removing the first context argument */
|
|
507
554
|
declare function withoutContext<T extends unknown[], Return>(fn: (...args: T) => Return): ExpressionHandler<T, Return>;
|
|
555
|
+
/** Get the node in the expression that's closest to the desired position */
|
|
556
|
+
declare function findClosestNodeAtPosition(node: ExpressionNode, position: NodePosition): ExpressionNode | undefined;
|
|
557
|
+
/** Checks if the expression is a simple type */
|
|
558
|
+
declare function isObjectExpression(expr: ExpressionType): expr is ExpressionObjectType;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* An expression to AST parser based on JSEP: http://jsep.from.so/
|
|
562
|
+
*/
|
|
563
|
+
|
|
564
|
+
/** Parse out an expression from the string */
|
|
565
|
+
declare function parseExpression(expr: string, options?: {
|
|
566
|
+
/** If true (the default), will throw on invalid expressions */
|
|
567
|
+
strict?: boolean;
|
|
568
|
+
}): ExpressionNode;
|
|
508
569
|
|
|
509
570
|
declare type FormatOptions = Omit<Formatting.Reference, 'type'>;
|
|
510
571
|
/**
|
|
@@ -576,6 +637,8 @@ declare class FlowInstance {
|
|
|
576
637
|
resolveTransitionNode: SyncWaterfallHook<[NavigationFlowState], Record<string, any>>;
|
|
577
638
|
/** A callback when a transition from 1 state to another was made */
|
|
578
639
|
transition: SyncHook<[NamedState | undefined, NamedState], Record<string, any>>;
|
|
640
|
+
/** A callback to run actions after a transition occurs */
|
|
641
|
+
afterTransition: SyncHook<[FlowInstance], Record<string, any>>;
|
|
579
642
|
};
|
|
580
643
|
constructor(id: string, flow: NavigationFlow, options?: {
|
|
581
644
|
/** Logger instance to use */
|
|
@@ -743,24 +806,95 @@ declare class Parser {
|
|
|
743
806
|
};
|
|
744
807
|
parseView(value: AnyAssetType): Node.View;
|
|
745
808
|
createASTNode(node: Node.Node | null, value: any): Node.Node | null;
|
|
809
|
+
/**
|
|
810
|
+
* Checks if there are templated values in the object
|
|
811
|
+
*
|
|
812
|
+
* @param obj - The Parsed Object to check to see if we have a template array type for
|
|
813
|
+
* @param localKey - The key being checked
|
|
814
|
+
*/
|
|
815
|
+
private hasTemplateValues;
|
|
746
816
|
parseObject(obj: object, type?: Node.ChildrenTypes, options?: ParseObjectOptions): Node.Node | null;
|
|
747
817
|
}
|
|
748
818
|
|
|
819
|
+
interface ConstantsProvider {
|
|
820
|
+
/**
|
|
821
|
+
* Function to add constants to the providers store
|
|
822
|
+
* - @param data values to add to the constants store
|
|
823
|
+
*/
|
|
824
|
+
addConstants(data: Record<string, any>, namespace: string): void;
|
|
825
|
+
/**
|
|
826
|
+
* Function to retrieve constants from the providers store
|
|
827
|
+
* - @param key Key used for the store access
|
|
828
|
+
* - @param namespace namespace values were loaded under (defined in the plugin)
|
|
829
|
+
* - @param fallback Optional - if key doesn't exist in namespace what to return (will return unknown if not provided)
|
|
830
|
+
*/
|
|
831
|
+
getConstants(key: any, namespace: string, fallback?: any): any;
|
|
832
|
+
/**
|
|
833
|
+
* Function to set values to temporarily override certain keys in the perminant store
|
|
834
|
+
* - @param data values to override store with
|
|
835
|
+
* - @param namespace namespace to override
|
|
836
|
+
*/
|
|
837
|
+
setTemporaryValues(data: any, namespace: string): void;
|
|
838
|
+
/**
|
|
839
|
+
* Clears any temporary values that were previously set
|
|
840
|
+
*/
|
|
841
|
+
clearTemporaryValues(): void;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Key/Value store for constants and context for Player
|
|
845
|
+
*/
|
|
846
|
+
declare class ConstantsController implements ConstantsProvider {
|
|
847
|
+
/**
|
|
848
|
+
* Data store is basically a map of namespaces to DataModels to provide some data isolation
|
|
849
|
+
*/
|
|
850
|
+
private store;
|
|
851
|
+
/**
|
|
852
|
+
* Separate store for temporary flow specific overrides.
|
|
853
|
+
* They are kept in a separate data model to make clearing it easier between flows
|
|
854
|
+
* and so there is no confusion on what is static and what is temporary
|
|
855
|
+
*/
|
|
856
|
+
private tempStore;
|
|
857
|
+
constructor();
|
|
858
|
+
addConstants(data: any, namespace: string): void;
|
|
859
|
+
getConstants(key: string, namespace: string, fallback?: any): any;
|
|
860
|
+
setTemporaryValues(data: any, namespace: string): void;
|
|
861
|
+
clearTemporaryValues(namespace?: string): void;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
interface ValidationGetResolveOptions {
|
|
865
|
+
/**
|
|
866
|
+
* If we should ignore any non-blocking validations in the return
|
|
867
|
+
* @default true
|
|
868
|
+
*/
|
|
869
|
+
ignoreNonBlocking?: boolean;
|
|
870
|
+
}
|
|
871
|
+
interface PlayerUtils {
|
|
872
|
+
findPlugin<Plugin = unknown>(symbol: symbol): Plugin | undefined;
|
|
873
|
+
}
|
|
749
874
|
declare namespace Resolve {
|
|
750
875
|
interface Validation {
|
|
751
876
|
/** Fetch the data-type for the given binding */
|
|
752
877
|
type(binding: BindingLike): Schema.DataType | undefined;
|
|
753
878
|
/** Get all currently applicable validation errors */
|
|
754
|
-
getAll(): Map<BindingInstance, ValidationResponse> | undefined;
|
|
879
|
+
getAll(options?: ValidationGetResolveOptions): Map<BindingInstance, ValidationResponse> | undefined;
|
|
755
880
|
/** Internal Method to lookup if there is a validation for the given binding */
|
|
756
|
-
_getValidationForBinding(binding: BindingLike):
|
|
881
|
+
_getValidationForBinding(binding: BindingLike): {
|
|
882
|
+
/** Get the validation for the given binding */
|
|
883
|
+
get: (options?: ValidationGetResolveOptions) => ValidationResponse | undefined;
|
|
884
|
+
/** Get all validations for the given binding */
|
|
885
|
+
getAll: (options?: ValidationGetResolveOptions) => Array<ValidationResponse>;
|
|
886
|
+
} | undefined;
|
|
757
887
|
/** Get field level error for the specific binding */
|
|
758
888
|
get(binding: BindingLike, options?: {
|
|
759
889
|
/** If this binding should also be tracked for validations */
|
|
760
|
-
track
|
|
761
|
-
}): ValidationResponse | undefined;
|
|
890
|
+
track?: boolean;
|
|
891
|
+
} & ValidationGetResolveOptions): ValidationResponse | undefined;
|
|
892
|
+
getValidationsForBinding(binding: BindingLike, options?: {
|
|
893
|
+
/** If this binding should also be tracked for validations */
|
|
894
|
+
track?: boolean;
|
|
895
|
+
} & ValidationGetResolveOptions): Array<ValidationResponse>;
|
|
762
896
|
/** Get errors for all children regardless of section */
|
|
763
|
-
getChildren(type
|
|
897
|
+
getChildren(type?: Validation.DisplayTarget): Array<ValidationResponse>;
|
|
764
898
|
/** Get errors for all children solely in this section */
|
|
765
899
|
getValidationsForSection(): Array<ValidationResponse>;
|
|
766
900
|
/** Track errors for this binding, and notify the node of changes */
|
|
@@ -774,6 +908,8 @@ declare namespace Resolve {
|
|
|
774
908
|
interface BaseOptions {
|
|
775
909
|
/** A logger to use */
|
|
776
910
|
logger?: Logger;
|
|
911
|
+
/** Utils for various useful operations */
|
|
912
|
+
utils?: PlayerUtils;
|
|
777
913
|
/** An optional set of validation features */
|
|
778
914
|
validation?: Validation;
|
|
779
915
|
/** Parse a raw valy into an AST node */
|
|
@@ -782,6 +918,8 @@ declare namespace Resolve {
|
|
|
782
918
|
transition?: TransitionFunction;
|
|
783
919
|
/** The hub for data invariants and metaData associated with the data model */
|
|
784
920
|
schema: SchemaController;
|
|
921
|
+
/** The constants for messages */
|
|
922
|
+
constants?: ConstantsProvider;
|
|
785
923
|
}
|
|
786
924
|
interface NodeDataOptions {
|
|
787
925
|
/** The data to set or get data from */
|
|
@@ -908,8 +1046,10 @@ declare class Resolver {
|
|
|
908
1046
|
constructor(root: Node.Node, options: Resolve.ResolverOptions);
|
|
909
1047
|
getSourceNode(convertedAST: Node.Node): Node.Node | undefined;
|
|
910
1048
|
update(changes?: Set<BindingInstance>): any;
|
|
1049
|
+
getResolveCache(): Map<Node.Node, Resolve.ResolvedNode>;
|
|
911
1050
|
private getNodeID;
|
|
912
1051
|
private getPreviousResult;
|
|
1052
|
+
private cloneNode;
|
|
913
1053
|
private computeTree;
|
|
914
1054
|
}
|
|
915
1055
|
|
|
@@ -961,6 +1101,8 @@ declare class TemplatePlugin implements ViewPlugin {
|
|
|
961
1101
|
|
|
962
1102
|
/** A plugin that resolves all string references for each node */
|
|
963
1103
|
declare class StringResolverPlugin implements ViewPlugin {
|
|
1104
|
+
private propertiesToSkipCache;
|
|
1105
|
+
constructor();
|
|
964
1106
|
applyResolver(resolver: Resolver): void;
|
|
965
1107
|
apply(view: View): void;
|
|
966
1108
|
}
|
|
@@ -1040,6 +1182,8 @@ declare class Builder {
|
|
|
1040
1182
|
interface BindingTracker {
|
|
1041
1183
|
/** Get the bindings currently being tracked for validation */
|
|
1042
1184
|
getBindings(): Set<BindingInstance>;
|
|
1185
|
+
/** Add a binding to the tracked set */
|
|
1186
|
+
trackBinding(binding: BindingInstance): void;
|
|
1043
1187
|
}
|
|
1044
1188
|
interface Options$1 {
|
|
1045
1189
|
/** Parse a binding from a view */
|
|
@@ -1057,12 +1201,21 @@ declare class ValidationBindingTrackerViewPlugin implements ViewPlugin, BindingT
|
|
|
1057
1201
|
constructor(options: Options$1);
|
|
1058
1202
|
/** Fetch the tracked bindings in the current view */
|
|
1059
1203
|
getBindings(): Set<BindingInstance>;
|
|
1204
|
+
/** Add a binding to the tracked set */
|
|
1205
|
+
trackBinding(binding: BindingInstance): void;
|
|
1060
1206
|
/** Attach hooks to the given resolver */
|
|
1061
1207
|
applyResolver(resolver: Resolver): void;
|
|
1062
1208
|
apply(view: ViewInstance): void;
|
|
1063
1209
|
}
|
|
1064
1210
|
|
|
1065
|
-
declare
|
|
1211
|
+
declare const SCHEMA_VALIDATION_PROVIDER_NAME = "schema";
|
|
1212
|
+
declare const VIEW_VALIDATION_PROVIDER_NAME = "view";
|
|
1213
|
+
declare const VALIDATION_PROVIDER_NAME_SYMBOL: unique symbol;
|
|
1214
|
+
declare type ValidationObjectWithSource = ValidationObjectWithHandler & {
|
|
1215
|
+
/** The name of the validation */
|
|
1216
|
+
[VALIDATION_PROVIDER_NAME_SYMBOL]: string;
|
|
1217
|
+
};
|
|
1218
|
+
declare type SimpleValidatorContext = Omit<ValidatorContext, 'validation' | 'schemaType'>;
|
|
1066
1219
|
interface BaseActiveValidation<T> {
|
|
1067
1220
|
/** The validation is being actively shown */
|
|
1068
1221
|
state: 'active';
|
|
@@ -1081,7 +1234,9 @@ declare type StatefulWarning = {
|
|
|
1081
1234
|
/** A common key to differentiate between errors and warnings */
|
|
1082
1235
|
type: 'warning';
|
|
1083
1236
|
/** The underlying validation this tracks */
|
|
1084
|
-
value:
|
|
1237
|
+
value: ValidationObjectWithSource;
|
|
1238
|
+
/** If this is currently preventing navigation from continuing */
|
|
1239
|
+
isBlockingNavigation: boolean;
|
|
1085
1240
|
} & ({
|
|
1086
1241
|
/** warnings start with no state, but can active or dismissed */
|
|
1087
1242
|
state: 'none' | 'dismissed';
|
|
@@ -1091,24 +1246,29 @@ declare type StatefulError = {
|
|
|
1091
1246
|
/** A common key to differentiate between errors and warnings */
|
|
1092
1247
|
type: 'error';
|
|
1093
1248
|
/** The underlying validation this tracks */
|
|
1094
|
-
value:
|
|
1249
|
+
value: ValidationObjectWithSource;
|
|
1250
|
+
/** If this is currently preventing navigation from continuing */
|
|
1251
|
+
isBlockingNavigation: boolean;
|
|
1095
1252
|
} & ({
|
|
1096
1253
|
/** Errors start with no state an can be activated */
|
|
1097
1254
|
state: 'none';
|
|
1098
1255
|
} | ActiveError);
|
|
1099
1256
|
declare type StatefulValidationObject = StatefulWarning | StatefulError;
|
|
1100
|
-
declare type ValidationRunner = (obj:
|
|
1257
|
+
declare type ValidationRunner = (obj: ValidationObjectWithHandler) => {
|
|
1101
1258
|
/** A validation message */
|
|
1102
1259
|
message: string;
|
|
1103
1260
|
} | undefined;
|
|
1104
1261
|
/** A class that manages validating bindings across phases */
|
|
1105
1262
|
declare class ValidatedBinding {
|
|
1106
|
-
|
|
1263
|
+
currentPhase?: Validation.Trigger;
|
|
1107
1264
|
private applicableValidations;
|
|
1108
1265
|
private validationsByState;
|
|
1266
|
+
get allValidations(): Array<StatefulValidationObject>;
|
|
1109
1267
|
weakBindings: Set<BindingInstance>;
|
|
1110
1268
|
private onDismiss?;
|
|
1111
|
-
constructor(possibleValidations: Array<
|
|
1269
|
+
constructor(possibleValidations: Array<ValidationObjectWithSource>, onDismiss?: () => void, log?: Logger, weakBindings?: Set<BindingInstance>);
|
|
1270
|
+
private checkIfBlocking;
|
|
1271
|
+
getAll(): Array<ValidationResponse>;
|
|
1112
1272
|
get(): ValidationResponse | undefined;
|
|
1113
1273
|
private runApplicableValidations;
|
|
1114
1274
|
update(phase: Validation.Trigger, canDismiss: boolean, runner: ValidationRunner): void;
|
|
@@ -1140,27 +1300,42 @@ declare class ValidationController implements BindingTracker {
|
|
|
1140
1300
|
onAddValidation: SyncWaterfallHook<[ValidationResponse, BindingInstance], Record<string, any>>;
|
|
1141
1301
|
/** The inverse of onAddValidation, this is called when a validation is removed from the list */
|
|
1142
1302
|
onRemoveValidation: SyncWaterfallHook<[ValidationResponse, BindingInstance], Record<string, any>>;
|
|
1303
|
+
resolveValidationProviders: SyncWaterfallHook<[{
|
|
1304
|
+
/** The name of the provider */
|
|
1305
|
+
source: string;
|
|
1306
|
+
/** The provider itself */
|
|
1307
|
+
provider: ValidationProvider;
|
|
1308
|
+
}[]], {
|
|
1309
|
+
/** The view this is triggered for */
|
|
1310
|
+
view?: ViewInstance | undefined;
|
|
1311
|
+
}>;
|
|
1312
|
+
/** A hook called when a binding is added to the tracker */
|
|
1313
|
+
onTrackBinding: SyncHook<[BindingInstance], Record<string, any>>;
|
|
1143
1314
|
};
|
|
1144
1315
|
private tracker;
|
|
1145
1316
|
private validations;
|
|
1146
1317
|
private validatorRegistry?;
|
|
1147
1318
|
private schema;
|
|
1148
1319
|
private providers;
|
|
1320
|
+
private viewValidationProvider?;
|
|
1149
1321
|
private options?;
|
|
1150
1322
|
private weakBindingTracker;
|
|
1151
|
-
private lastActiveBindings;
|
|
1152
1323
|
constructor(schema: SchemaController, options?: SimpleValidatorContext);
|
|
1153
1324
|
setOptions(options: SimpleValidatorContext): void;
|
|
1154
1325
|
/** Return the middleware for the data-model to stop propagation of invalid data */
|
|
1155
1326
|
getDataMiddleware(): Array<DataModelMiddleware>;
|
|
1327
|
+
private getValidationProviders;
|
|
1328
|
+
reset(): void;
|
|
1156
1329
|
onView(view: ViewInstance): void;
|
|
1157
|
-
|
|
1158
|
-
|
|
1330
|
+
updateValidationsForBinding(binding: BindingInstance, trigger: Validation.Trigger, validationContext?: SimpleValidatorContext, onDismiss?: () => void): void;
|
|
1331
|
+
validationRunner(validationObj: ValidationObjectWithHandler, binding: BindingInstance, context?: SimpleValidatorContext | undefined): {
|
|
1332
|
+
message: string;
|
|
1333
|
+
} | undefined;
|
|
1159
1334
|
private updateValidationsForView;
|
|
1160
|
-
private setCompare;
|
|
1161
1335
|
private get activeBindings();
|
|
1162
1336
|
getValidator(type: string): ValidatorFunction<unknown> | undefined;
|
|
1163
1337
|
getBindings(): Set<BindingInstance>;
|
|
1338
|
+
trackBinding(binding: BindingInstance): void;
|
|
1164
1339
|
/** Executes all known validations for the tracked bindings using the given model */
|
|
1165
1340
|
validateView(trigger?: Validation.Trigger): {
|
|
1166
1341
|
/** Indicating if the view can proceed without error */
|
|
@@ -1168,6 +1343,7 @@ declare class ValidationController implements BindingTracker {
|
|
|
1168
1343
|
/** the validations that are preventing the view from continuing */
|
|
1169
1344
|
validations?: Map<BindingInstance, ValidationResponse>;
|
|
1170
1345
|
};
|
|
1346
|
+
/** Get the current tracked validation for the given binding */
|
|
1171
1347
|
getValidationForBinding(binding: BindingInstance): ValidatedBinding | undefined;
|
|
1172
1348
|
forView(parser: BindingFactory): Resolve.Validation;
|
|
1173
1349
|
}
|
|
@@ -1203,6 +1379,16 @@ interface TransformFunctions {
|
|
|
1203
1379
|
}
|
|
1204
1380
|
declare type TransformRegistry = Registry<TransformFunctions>;
|
|
1205
1381
|
|
|
1382
|
+
/** Wrapper for the Data Controller Class that prevents writes */
|
|
1383
|
+
declare class ReadOnlyDataController implements DataModelWithParser<DataModelOptions> {
|
|
1384
|
+
private controller;
|
|
1385
|
+
private logger?;
|
|
1386
|
+
constructor(controller: DataController, logger?: Logger);
|
|
1387
|
+
get(binding: BindingLike, options?: DataModelOptions | undefined): any;
|
|
1388
|
+
set(transaction: [BindingLike, any][], options?: DataModelOptions | undefined): Updates;
|
|
1389
|
+
delete(binding: BindingLike, options?: DataModelOptions | undefined): void;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1206
1392
|
/** The status for a flow's execution state */
|
|
1207
1393
|
declare type PlayerFlowStatus = 'not-started' | 'in-progress' | 'completed' | 'error';
|
|
1208
1394
|
/** Common interface for the state of Player's flow execution */
|
|
@@ -1251,8 +1437,11 @@ declare type InProgressState = BaseFlowState<'in-progress'> & PlayerFlowExecutio
|
|
|
1251
1437
|
};
|
|
1252
1438
|
/** The flow completed properly */
|
|
1253
1439
|
declare type CompletedState = BaseFlowState<'completed'> & PlayerFlowExecutionData & FlowResult & {
|
|
1254
|
-
/**
|
|
1255
|
-
|
|
1440
|
+
/** Readonly Player controllers to provide Player functionality after the flow has ended */
|
|
1441
|
+
controllers: {
|
|
1442
|
+
/** A read only instance of the Data Controller */
|
|
1443
|
+
data: ReadOnlyDataController;
|
|
1444
|
+
};
|
|
1256
1445
|
};
|
|
1257
1446
|
/** The flow finished but not successfully */
|
|
1258
1447
|
declare type ErrorState = BaseFlowState<'error'> & {
|
|
@@ -1275,7 +1464,7 @@ declare class DataController implements DataModelWithParser<DataModelOptions> {
|
|
|
1275
1464
|
onDelete: SyncHook<[any], Record<string, any>>;
|
|
1276
1465
|
onSet: SyncHook<[BatchSetTransaction], Record<string, any>>;
|
|
1277
1466
|
onGet: SyncHook<[any, any], Record<string, any>>;
|
|
1278
|
-
onUpdate: SyncHook<[Updates], Record<string, any>>;
|
|
1467
|
+
onUpdate: SyncHook<[Updates, DataModelOptions | undefined], Record<string, any>>;
|
|
1279
1468
|
format: SyncWaterfallHook<[any, BindingInstance], Record<string, any>>;
|
|
1280
1469
|
deformat: SyncWaterfallHook<[any, BindingInstance], Record<string, any>>;
|
|
1281
1470
|
serialize: SyncWaterfallHook<[any], Record<string, any>>;
|
|
@@ -1298,11 +1487,9 @@ declare class DataController implements DataModelWithParser<DataModelOptions> {
|
|
|
1298
1487
|
set(transaction: RawSetTransaction, options?: DataModelOptions): Updates;
|
|
1299
1488
|
private resolve;
|
|
1300
1489
|
get(binding: BindingLike, options?: DataModelOptions): any;
|
|
1301
|
-
delete(binding: BindingLike): void;
|
|
1302
|
-
getTrash(): Set<BindingInstance>;
|
|
1303
|
-
private addToTrash;
|
|
1304
|
-
private deleteData;
|
|
1490
|
+
delete(binding: BindingLike, options?: DataModelOptions): void;
|
|
1305
1491
|
serialize(): object;
|
|
1492
|
+
makeReadOnly(): ReadOnlyDataController;
|
|
1306
1493
|
}
|
|
1307
1494
|
|
|
1308
1495
|
interface ViewControllerOptions {
|
|
@@ -1349,51 +1536,6 @@ declare class AssetTransformCorePlugin {
|
|
|
1349
1536
|
apply(viewController: ViewController): void;
|
|
1350
1537
|
}
|
|
1351
1538
|
|
|
1352
|
-
interface ConstantsProvider {
|
|
1353
|
-
/**
|
|
1354
|
-
* Function to add constants to the providers store
|
|
1355
|
-
* - @param data values to add to the constants store
|
|
1356
|
-
*/
|
|
1357
|
-
addConstants(data: Record<string, any>, namespace: string): void;
|
|
1358
|
-
/**
|
|
1359
|
-
* Function to retreive constants from the providers store
|
|
1360
|
-
* - @param key Key used for the store access
|
|
1361
|
-
* - @param namespace namespace values were loaded under (defined in the plugin)
|
|
1362
|
-
* - @param fallback Optional - if key doesn't exist in namespace what to return (will return unknown if not provided)
|
|
1363
|
-
*/
|
|
1364
|
-
getConstants(key: any, namespace: string, fallback?: any): any;
|
|
1365
|
-
/**
|
|
1366
|
-
* Function to set values to temporarily override certain keys in the perminant store
|
|
1367
|
-
* - @param data values to override store with
|
|
1368
|
-
* - @param namespace namespace to override
|
|
1369
|
-
*/
|
|
1370
|
-
setTemporaryValues(data: any, namespace: string): void;
|
|
1371
|
-
/**
|
|
1372
|
-
* Clears any temporary values that were previously set
|
|
1373
|
-
*/
|
|
1374
|
-
clearTemporaryValues(): void;
|
|
1375
|
-
}
|
|
1376
|
-
/**
|
|
1377
|
-
* Key/Value store for constants and context for Player
|
|
1378
|
-
*/
|
|
1379
|
-
declare class ConstantsController implements ConstantsProvider {
|
|
1380
|
-
/**
|
|
1381
|
-
* Data store is basically a map of namespaces to DataModels to provide some data isolation
|
|
1382
|
-
*/
|
|
1383
|
-
private store;
|
|
1384
|
-
/**
|
|
1385
|
-
* Separate store for temporary flow specific overrides.
|
|
1386
|
-
* They are kept in a separate data model to make clearing it easier between flows
|
|
1387
|
-
* and so there is no confusion on what is static and what is temporary
|
|
1388
|
-
*/
|
|
1389
|
-
private tempStore;
|
|
1390
|
-
constructor();
|
|
1391
|
-
addConstants(data: any, namespace: string): void;
|
|
1392
|
-
getConstants(key: string, namespace: string, fallback?: any): any;
|
|
1393
|
-
setTemporaryValues(data: any, namespace: string): void;
|
|
1394
|
-
clearTemporaryValues(): void;
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
1539
|
interface BaseValidationResponse<T = Validation.Severity> {
|
|
1398
1540
|
/** The validation message to show to the user */
|
|
1399
1541
|
message: string;
|
|
@@ -1414,9 +1556,13 @@ declare type ErrorValidationResponse = BaseValidationResponse<'error'>;
|
|
|
1414
1556
|
declare type ValidationResponse = ErrorValidationResponse | WarningValidationResponse;
|
|
1415
1557
|
declare type RequiredValidationKeys = 'severity' | 'trigger';
|
|
1416
1558
|
declare type ValidationObject = Validation.Reference & Required<Pick<Validation.Reference, RequiredValidationKeys>>;
|
|
1559
|
+
declare type ValidationObjectWithHandler = ValidationObject & {
|
|
1560
|
+
/** A predefined handler for this validation object */
|
|
1561
|
+
handler?: ValidatorFunction;
|
|
1562
|
+
};
|
|
1417
1563
|
interface ValidationProvider {
|
|
1418
|
-
getValidationsForBinding?(binding: BindingInstance): Array<
|
|
1419
|
-
getValidationsForView?(): Array<
|
|
1564
|
+
getValidationsForBinding?(binding: BindingInstance): Array<ValidationObjectWithHandler> | undefined;
|
|
1565
|
+
getValidationsForView?(): Array<ValidationObjectWithHandler> | undefined;
|
|
1420
1566
|
}
|
|
1421
1567
|
interface ValidatorContext {
|
|
1422
1568
|
/** The data to set or get data from */
|
|
@@ -1431,13 +1577,24 @@ interface ValidatorContext {
|
|
|
1431
1577
|
validation: ValidationObject;
|
|
1432
1578
|
/** The constants for messages */
|
|
1433
1579
|
constants: ConstantsProvider;
|
|
1580
|
+
/** The type in the schema that triggered the validation if there is one */
|
|
1581
|
+
schemaType: Schema.DataType | undefined;
|
|
1434
1582
|
}
|
|
1435
1583
|
declare type ValidatorFunction<Options = unknown> = (context: ValidatorContext, value: any, options?: Options) => Omit<BaseValidationResponse, 'severity'> | undefined;
|
|
1436
1584
|
|
|
1585
|
+
/**
|
|
1586
|
+
* A BindingInstance with an indicator of whether or not it's a strong binding
|
|
1587
|
+
*/
|
|
1588
|
+
declare type StrongOrWeakBinding = {
|
|
1589
|
+
/** BindingInstance in question */
|
|
1590
|
+
binding: BindingInstance;
|
|
1591
|
+
/** Boolean indicating whether the relevant BindingInstance is a strong binding */
|
|
1592
|
+
isStrong: boolean;
|
|
1593
|
+
};
|
|
1437
1594
|
/**
|
|
1438
1595
|
* Returns a validation object if the data is invalid or an set of BindingsInstances if the binding itself is a weak ref of another invalid validation
|
|
1439
1596
|
*/
|
|
1440
|
-
declare type MiddlewareChecker = (binding: BindingInstance, model: DataModelImpl) => ValidationResponse | Set<
|
|
1597
|
+
declare type MiddlewareChecker = (binding: BindingInstance, model: DataModelImpl) => ValidationResponse | Set<StrongOrWeakBinding> | undefined;
|
|
1441
1598
|
/**
|
|
1442
1599
|
* Middleware for the data-model that caches the results of invalid data
|
|
1443
1600
|
*/
|
|
@@ -1445,12 +1602,16 @@ declare class ValidationMiddleware implements DataModelMiddleware {
|
|
|
1445
1602
|
validator: MiddlewareChecker;
|
|
1446
1603
|
shadowModelPaths: Map<BindingInstance, any>;
|
|
1447
1604
|
private logger?;
|
|
1605
|
+
private shouldIncludeInvalid?;
|
|
1448
1606
|
constructor(validator: MiddlewareChecker, options?: {
|
|
1449
1607
|
/** A logger instance */
|
|
1450
1608
|
logger?: Logger;
|
|
1609
|
+
/** Optional function to include data staged in shadowModel */
|
|
1610
|
+
shouldIncludeInvalid?: (options?: DataModelOptions) => boolean;
|
|
1451
1611
|
});
|
|
1452
1612
|
set(transaction: BatchSetTransaction, options?: DataModelOptions, next?: DataModelImpl): Updates;
|
|
1453
1613
|
get(binding: BindingInstance, options?: DataModelOptions, next?: DataModelImpl): any;
|
|
1614
|
+
delete(binding: BindingInstance, options?: DataModelOptions, next?: DataModelImpl): void | undefined;
|
|
1454
1615
|
}
|
|
1455
1616
|
|
|
1456
1617
|
/** A registry that tracks validators */
|
|
@@ -1463,8 +1624,17 @@ declare class ValidatorRegistry {
|
|
|
1463
1624
|
register<T>(name: string, handler: ValidatorFunction<T>): void;
|
|
1464
1625
|
}
|
|
1465
1626
|
|
|
1627
|
+
/**
|
|
1628
|
+
* Remove a binding, and any children from from the map
|
|
1629
|
+
* If the binding is an array-item, then it will be spliced from the array and the others will be shifted down
|
|
1630
|
+
*
|
|
1631
|
+
* @param sourceMap - A map of bindings to values
|
|
1632
|
+
* @param binding - The binding to remove from the map
|
|
1633
|
+
*/
|
|
1634
|
+
declare function removeBindingAndChildrenFromMap<T>(sourceMap: Map<BindingInstance, T>, binding: BindingInstance): Map<BindingInstance, T>;
|
|
1635
|
+
|
|
1466
1636
|
/** Expand the authored schema into a set of paths -> DataTypes */
|
|
1467
|
-
declare function parse(schema: Schema.Schema): Map<string, Schema.
|
|
1637
|
+
declare function parse(schema: Schema.Schema): Map<string, Schema.DataTypes>;
|
|
1468
1638
|
/**
|
|
1469
1639
|
* The Schema is the central hub for all data invariants, and metaData associated with the data-model itself
|
|
1470
1640
|
* Outside of the types defined in the JSON payload, it doesn't manage or keep any state.
|
|
@@ -1473,18 +1643,18 @@ declare function parse(schema: Schema.Schema): Map<string, Schema.DataType>;
|
|
|
1473
1643
|
declare class SchemaController implements ValidationProvider {
|
|
1474
1644
|
private formatters;
|
|
1475
1645
|
private types;
|
|
1476
|
-
readonly schema: Map<string, Schema.
|
|
1646
|
+
readonly schema: Map<string, Schema.DataTypes>;
|
|
1477
1647
|
private bindingSchemaNormalizedCache;
|
|
1478
1648
|
readonly hooks: {
|
|
1479
|
-
resolveTypeForBinding: SyncWaterfallHook<[Schema.
|
|
1649
|
+
resolveTypeForBinding: SyncWaterfallHook<[Schema.DataTypes | undefined, BindingInstance], Record<string, any>>;
|
|
1480
1650
|
};
|
|
1481
1651
|
constructor(schema?: Schema.Schema);
|
|
1482
1652
|
addFormatters(fns: Array<FormatType<any, any, FormatOptions>>): void;
|
|
1483
1653
|
addDataTypes(types: Array<Schema.DataType<any>>): void;
|
|
1484
1654
|
getValidationsForBinding(binding: BindingInstance): Array<ValidationObject> | undefined;
|
|
1485
1655
|
private normalizeBinding;
|
|
1486
|
-
getType(binding: BindingInstance): Schema.
|
|
1487
|
-
getApparentType(binding: BindingInstance): Schema.
|
|
1656
|
+
getType(binding: BindingInstance): Schema.DataTypes | undefined;
|
|
1657
|
+
getApparentType(binding: BindingInstance): Schema.DataTypes | undefined;
|
|
1488
1658
|
getTypeDefinition(dataType: string): Schema.DataType<any> | undefined;
|
|
1489
1659
|
getFormatterForType(formatReference: Formatting.Reference): FormatDefinition<unknown, unknown> | undefined;
|
|
1490
1660
|
/**
|
|
@@ -1495,10 +1665,20 @@ declare class SchemaController implements ValidationProvider {
|
|
|
1495
1665
|
}
|
|
1496
1666
|
|
|
1497
1667
|
interface Options {
|
|
1498
|
-
/**
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1668
|
+
/**
|
|
1669
|
+
* The model to use when resolving refs
|
|
1670
|
+
* Passing `false` will skip trying to resolve any direct model refs ({{foo}})
|
|
1671
|
+
*/
|
|
1672
|
+
model: false | DataModelWithParser;
|
|
1673
|
+
/**
|
|
1674
|
+
* A function to evaluate an expression
|
|
1675
|
+
* Passing `false` will skip trying to evaluate any expressions (@[ foo() ]@)
|
|
1676
|
+
*/
|
|
1677
|
+
evaluate: false | ((exp: Expression) => any);
|
|
1678
|
+
/**
|
|
1679
|
+
* Optionaly resolve binding without formatting in case Type format applies
|
|
1680
|
+
*/
|
|
1681
|
+
formatted?: boolean;
|
|
1502
1682
|
}
|
|
1503
1683
|
/** Search the given string for the coordinates of the next expression to resolve */
|
|
1504
1684
|
declare function findNextExp(str: string): {
|
|
@@ -1525,6 +1705,8 @@ interface PlayerPlugin {
|
|
|
1525
1705
|
*/
|
|
1526
1706
|
apply: (player: Player) => void;
|
|
1527
1707
|
}
|
|
1708
|
+
interface ExtendedPlayerPlugin<Assets = void, Views = void, Expressions = void, DataTypes = void> {
|
|
1709
|
+
}
|
|
1528
1710
|
interface PlayerConfigOptions {
|
|
1529
1711
|
/** A set of plugins to load */
|
|
1530
1712
|
plugins?: PlayerPlugin[];
|
|
@@ -1611,4 +1793,4 @@ declare class FlowExpPlugin implements PlayerPlugin {
|
|
|
1611
1793
|
apply(player: Player): void;
|
|
1612
1794
|
}
|
|
1613
1795
|
|
|
1614
|
-
export { AnyAssetType, ApplicabilityPlugin, ArrayExpressionNode, AssetTransformCorePlugin, AssignmentNode, BaseFlowState, BaseNode, BatchSetTransaction, BeforeTransformFunction, BinaryNode, BinaryOperator, BinaryOperatorAdvanced, BinaryOperatorBasic, BindingFactory, BindingInstance, BindingLike, BindingParser, BindingParserOptions, BindingTracker, Builder, CallExpressionNode, CompletedState, CompoundNode, ConditionalExpressionNode, ConsoleLogger, ConstantsController, ConstantsProvider, ControllerState, DataController, DataModelImpl, DataModelMiddleware, DataModelOptions, DataModelWithParser, DataPipeline, DependencyMiddleware, DependencyModel, DependencySets, DependencyTracker, DirectionalNode, EMPTY_NODE, ErrorState, ErrorValidationResponse, ExpNodeOpaqueIdentifier, ExpressionContext, ExpressionEvaluator, ExpressionEvaluatorFunction, ExpressionEvaluatorOptions, ExpressionHandler, ExpressionLiteralType, ExpressionNode, ExpressionNodeType, ExpressionType, FlowController, FlowExpPlugin, FlowInstance, FormatDefinition, FormatFunction, FormatHandler, FormatOptions, FormatType, Getter, HookOptions, IdentifierNode, InProgressState, LiteralNode, LocalModel, LocalStateStore, LogFn, Logger, LoggerProvider, LogicalNode, MemberExpressionNode, MiddlewareChecker, ModelRefNode, ModificationNode, NOOPDataModel, NOOP_MODEL, NOT_STARTED_STATE, NamedState, Node, NodeType, NoopLogger, NotStartedState, ObjectNode, OperatorProcessingOptions, Options, ParseObjectOptions, Parser, PipelinedDataModel, Player, PlayerConfigOptions, PlayerFlowExecutionData, PlayerFlowState, PlayerFlowStatus, PlayerInfo, PlayerPlugin, ProxyLogger, ROOT_BINDING, RawBinding, RawBindingSegment, RawSetTransaction, RawSetType, Resolve, Resolver, SIMPLE_BINDING_REGEX, SchemaController, Severity, StatefulValidationObject, Store, StringResolverPlugin, SwitchPlugin, TapableLogger, TemplatePlugin, ThisNode, TransformFunction, TransformFunctions, TransformRegistry, TransitionFunction, TransitionOptions, UnaryNode, UnaryOperator, Updates, ValidationBindingTrackerViewPlugin, ValidationController, ValidationMiddleware, ValidationObject, ValidationProvider, ValidationResponse, ValidatorContext, ValidatorFunction, ValidatorRegistry, ViewController, ViewControllerOptions, ViewInstance, ViewPlugin, WarningValidationResponse, caresAboutDataChanges, constructModelForPipeline, findInArray, findNextExp, getBindingSegments, isBinding, isExpressionNode, maybeConvertToNum, parse, resolveDataRefs, resolveDataRefsInString, resolveExpressionsInString, severities, toModel, toNodeResolveOptions, withParser, withoutContext };
|
|
1796
|
+
export { AnyAssetType, ApplicabilityPlugin, ArrayExpressionNode, AssetTransformCorePlugin, AssignmentNode, BINDING_BRACKETS_REGEX, BaseFlowState, BaseNode, BasicExpressionTypes, BatchSetTransaction, BeforeTransformFunction, BinaryNode, BinaryOperator, BinaryOperatorAdvanced, BinaryOperatorBasic, BindingFactory, BindingInstance, BindingLike, BindingParser, BindingParserOptions, BindingTracker, Builder, CallExpressionNode, CompletedState, CompoundNode, ConditionalExpressionNode, ConsoleLogger, ConstantsController, ConstantsProvider, ControllerState, DataController, DataModelImpl, DataModelMiddleware, DataModelOptions, DataModelWithParser, DataPipeline, DependencyMiddleware, DependencyModel, DependencySets, DependencyTracker, DirectionalNode, EMPTY_NODE, ErrorState, ErrorValidationResponse, ExpNodeOpaqueIdentifier, ExpressionContext, ExpressionEvaluator, ExpressionEvaluatorFunction, ExpressionEvaluatorOptions, ExpressionHandler, ExpressionLiteralType, ExpressionNode, ExpressionNodeType, ExpressionObjectType, ExpressionType, ExtendedPlayerPlugin, FlowController, FlowExpPlugin, FlowInstance, FormatDefinition, FormatFunction, FormatHandler, FormatOptions, FormatType, Getter, HookOptions, IdentifierNode, InProgressState, LiteralNode, LocalModel, LocalStateStore, LogFn, Logger, LoggerProvider, LogicalNode, MemberExpressionNode, MiddlewareChecker, ModelRefNode, ModificationNode, NOOPDataModel, NOOP_MODEL, NOT_STARTED_STATE, NamedState, Node, NodeLocation, NodePosition, NodeType, NoopLogger, NotStartedState, ObjectNode, OperatorProcessingOptions, Options, ParseObjectOptions, Parser, PipelinedDataModel, Player, PlayerConfigOptions, PlayerFlowExecutionData, PlayerFlowState, PlayerFlowStatus, PlayerInfo, PlayerPlugin, PlayerUtils, ProxyLogger, ROOT_BINDING, RawBinding, RawBindingSegment, RawSetTransaction, RawSetType, Resolve, Resolver, SCHEMA_VALIDATION_PROVIDER_NAME, SIMPLE_BINDING_REGEX, SchemaController, Severity, StatefulValidationObject, Store, StringResolverPlugin, StrongOrWeakBinding, SwitchPlugin, TapableLogger, TemplatePlugin, ThisNode, TransformFunction, TransformFunctions, TransformRegistry, TransitionFunction, TransitionOptions, UnaryNode, UnaryOperator, Updates, VALIDATION_PROVIDER_NAME_SYMBOL, VIEW_VALIDATION_PROVIDER_NAME, ValidationBindingTrackerViewPlugin, ValidationController, ValidationGetResolveOptions, ValidationMiddleware, ValidationObject, ValidationObjectWithHandler, ValidationObjectWithSource, ValidationProvider, ValidationResponse, ValidatorContext, ValidatorFunction, ValidatorRegistry, ViewController, ViewControllerOptions, ViewInstance, ViewPlugin, WarningValidationResponse, caresAboutDataChanges, constructModelForPipeline, findClosestNodeAtPosition, findInArray, findNextExp, getBindingSegments, isBinding, isExpressionNode, isObjectExpression, maybeConvertToNum, parse, parseExpression, removeBindingAndChildrenFromMap, resolveDataRefs, resolveDataRefsInString, resolveExpressionsInString, severities, toModel, toNodeResolveOptions, withParser, withoutContext };
|