@uniformdev/canvas 19.38.2 → 19.38.3-alpha.70

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.d.ts CHANGED
@@ -181,19 +181,15 @@ interface components$4 {
181
181
  value: unknown;
182
182
  /** @description The type of the parameter. Determines how it is displayed when editing, and tells the consumer how to process it. */
183
183
  type: string;
184
+ /** @deprecated */
184
185
  connectedData?: components$4["schemas"]["DataElementConnectionDefinition"];
185
186
  };
186
- /**
187
- * @description Defines a connection to a data element on a data resource.
188
- *
189
- * NOTE: This is considered an internal data structure and is not guaranteed to be stable.
190
- * Future updates that do not break the edgehanced/data-bound state of a composition may be made without notice.
191
- */
187
+ /** @description Defines a connection to a dynamic token on a data resource. */
192
188
  DataElementConnectionDefinition: {
193
- /** @description A JSON Pointer expression that defines the data element to connect the parameter to. */
189
+ /** @description A JSON Pointer expression that defines the data resource dynamic token value. */
194
190
  pointer: string;
195
191
  /**
196
- * @description The syntax used to select the data element to bind to
192
+ * @description The syntax used to select the dynamic token to bind to
197
193
  * @enum {string}
198
194
  */
199
195
  syntax: "jptr";
@@ -833,19 +829,15 @@ interface external$a {
833
829
  value: unknown;
834
830
  /** @description The type of the parameter. Determines how it is displayed when editing, and tells the consumer how to process it. */
835
831
  type: string;
832
+ /** @deprecated */
836
833
  connectedData?: external$a["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataElementConnectionDefinition"];
837
834
  };
838
- /**
839
- * @description Defines a connection to a data element on a data resource.
840
- *
841
- * NOTE: This is considered an internal data structure and is not guaranteed to be stable.
842
- * Future updates that do not break the edgehanced/data-bound state of a composition may be made without notice.
843
- */
835
+ /** @description Defines a connection to a dynamic token on a data resource. */
844
836
  DataElementConnectionDefinition: {
845
- /** @description A JSON Pointer expression that defines the data element to connect the parameter to. */
837
+ /** @description A JSON Pointer expression that defines the data resource dynamic token value. */
846
838
  pointer: string;
847
839
  /**
848
- * @description The syntax used to select the data element to bind to
840
+ * @description The syntax used to select the dynamic token to bind to
849
841
  * @enum {string}
850
842
  */
851
843
  syntax: "jptr";
@@ -1486,19 +1478,15 @@ interface external$9 {
1486
1478
  value: unknown;
1487
1479
  /** @description The type of the parameter. Determines how it is displayed when editing, and tells the consumer how to process it. */
1488
1480
  type: string;
1481
+ /** @deprecated */
1489
1482
  connectedData?: external$9["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataElementConnectionDefinition"];
1490
1483
  };
1491
- /**
1492
- * @description Defines a connection to a data element on a data resource.
1493
- *
1494
- * NOTE: This is considered an internal data structure and is not guaranteed to be stable.
1495
- * Future updates that do not break the edgehanced/data-bound state of a composition may be made without notice.
1496
- */
1484
+ /** @description Defines a connection to a dynamic token on a data resource. */
1497
1485
  DataElementConnectionDefinition: {
1498
- /** @description A JSON Pointer expression that defines the data element to connect the parameter to. */
1486
+ /** @description A JSON Pointer expression that defines the data resource dynamic token value. */
1499
1487
  pointer: string;
1500
1488
  /**
1501
- * @description The syntax used to select the data element to bind to
1489
+ * @description The syntax used to select the dynamic token to bind to
1502
1490
  * @enum {string}
1503
1491
  */
1504
1492
  syntax: "jptr";
@@ -2135,19 +2123,15 @@ interface external$8 {
2135
2123
  value: unknown;
2136
2124
  /** @description The type of the parameter. Determines how it is displayed when editing, and tells the consumer how to process it. */
2137
2125
  type: string;
2126
+ /** @deprecated */
2138
2127
  connectedData?: external$8["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataElementConnectionDefinition"];
2139
2128
  };
2140
- /**
2141
- * @description Defines a connection to a data element on a data resource.
2142
- *
2143
- * NOTE: This is considered an internal data structure and is not guaranteed to be stable.
2144
- * Future updates that do not break the edgehanced/data-bound state of a composition may be made without notice.
2145
- */
2129
+ /** @description Defines a connection to a dynamic token on a data resource. */
2146
2130
  DataElementConnectionDefinition: {
2147
- /** @description A JSON Pointer expression that defines the data element to connect the parameter to. */
2131
+ /** @description A JSON Pointer expression that defines the data resource dynamic token value. */
2148
2132
  pointer: string;
2149
2133
  /**
2150
- * @description The syntax used to select the data element to bind to
2134
+ * @description The syntax used to select the dynamic token to bind to
2151
2135
  * @enum {string}
2152
2136
  */
2153
2137
  syntax: "jptr";
@@ -2727,19 +2711,15 @@ interface external$7 {
2727
2711
  value: unknown;
2728
2712
  /** @description The type of the parameter. Determines how it is displayed when editing, and tells the consumer how to process it. */
2729
2713
  type: string;
2714
+ /** @deprecated */
2730
2715
  connectedData?: external$7["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataElementConnectionDefinition"];
2731
2716
  };
2732
- /**
2733
- * @description Defines a connection to a data element on a data resource.
2734
- *
2735
- * NOTE: This is considered an internal data structure and is not guaranteed to be stable.
2736
- * Future updates that do not break the edgehanced/data-bound state of a composition may be made without notice.
2737
- */
2717
+ /** @description Defines a connection to a dynamic token on a data resource. */
2738
2718
  DataElementConnectionDefinition: {
2739
- /** @description A JSON Pointer expression that defines the data element to connect the parameter to. */
2719
+ /** @description A JSON Pointer expression that defines the data resource dynamic token value. */
2740
2720
  pointer: string;
2741
2721
  /**
2742
- * @description The syntax used to select the data element to bind to
2722
+ * @description The syntax used to select the dynamic token to bind to
2743
2723
  * @enum {string}
2744
2724
  */
2745
2725
  syntax: "jptr";
@@ -3354,19 +3334,15 @@ interface external$6 {
3354
3334
  value: unknown;
3355
3335
  /** @description The type of the parameter. Determines how it is displayed when editing, and tells the consumer how to process it. */
3356
3336
  type: string;
3337
+ /** @deprecated */
3357
3338
  connectedData?: external$6["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataElementConnectionDefinition"];
3358
3339
  };
3359
- /**
3360
- * @description Defines a connection to a data element on a data resource.
3361
- *
3362
- * NOTE: This is considered an internal data structure and is not guaranteed to be stable.
3363
- * Future updates that do not break the edgehanced/data-bound state of a composition may be made without notice.
3364
- */
3340
+ /** @description Defines a connection to a dynamic token on a data resource. */
3365
3341
  DataElementConnectionDefinition: {
3366
- /** @description A JSON Pointer expression that defines the data element to connect the parameter to. */
3342
+ /** @description A JSON Pointer expression that defines the data resource dynamic token value. */
3367
3343
  pointer: string;
3368
3344
  /**
3369
- * @description The syntax used to select the data element to bind to
3345
+ * @description The syntax used to select the dynamic token to bind to
3370
3346
  * @enum {string}
3371
3347
  */
3372
3348
  syntax: "jptr";
@@ -4406,19 +4382,15 @@ interface external$5 {
4406
4382
  value: unknown;
4407
4383
  /** @description The type of the parameter. Determines how it is displayed when editing, and tells the consumer how to process it. */
4408
4384
  type: string;
4385
+ /** @deprecated */
4409
4386
  connectedData?: external$5["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataElementConnectionDefinition"];
4410
4387
  };
4411
- /**
4412
- * @description Defines a connection to a data element on a data resource.
4413
- *
4414
- * NOTE: This is considered an internal data structure and is not guaranteed to be stable.
4415
- * Future updates that do not break the edgehanced/data-bound state of a composition may be made without notice.
4416
- */
4388
+ /** @description Defines a connection to a dynamic token on a data resource. */
4417
4389
  DataElementConnectionDefinition: {
4418
- /** @description A JSON Pointer expression that defines the data element to connect the parameter to. */
4390
+ /** @description A JSON Pointer expression that defines the data resource dynamic token value. */
4419
4391
  pointer: string;
4420
4392
  /**
4421
- * @description The syntax used to select the data element to bind to
4393
+ * @description The syntax used to select the dynamic token to bind to
4422
4394
  * @enum {string}
4423
4395
  */
4424
4396
  syntax: "jptr";
@@ -5249,19 +5221,15 @@ interface external$3 {
5249
5221
  value: unknown;
5250
5222
  /** @description The type of the parameter. Determines how it is displayed when editing, and tells the consumer how to process it. */
5251
5223
  type: string;
5224
+ /** @deprecated */
5252
5225
  connectedData?: external$3["../../../lambda/functions/uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataElementConnectionDefinition"];
5253
5226
  };
5254
- /**
5255
- * @description Defines a connection to a data element on a data resource.
5256
- *
5257
- * NOTE: This is considered an internal data structure and is not guaranteed to be stable.
5258
- * Future updates that do not break the edgehanced/data-bound state of a composition may be made without notice.
5259
- */
5227
+ /** @description Defines a connection to a dynamic token on a data resource. */
5260
5228
  DataElementConnectionDefinition: {
5261
- /** @description A JSON Pointer expression that defines the data element to connect the parameter to. */
5229
+ /** @description A JSON Pointer expression that defines the data resource dynamic token value. */
5262
5230
  pointer: string;
5263
5231
  /**
5264
- * @description The syntax used to select the data element to bind to
5232
+ * @description The syntax used to select the dynamic token to bind to
5265
5233
  * @enum {string}
5266
5234
  */
5267
5235
  syntax: "jptr";
@@ -6756,19 +6724,15 @@ interface external$2 {
6756
6724
  value: unknown;
6757
6725
  /** @description The type of the parameter. Determines how it is displayed when editing, and tells the consumer how to process it. */
6758
6726
  type: string;
6727
+ /** @deprecated */
6759
6728
  connectedData?: external$2["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataElementConnectionDefinition"];
6760
6729
  };
6761
- /**
6762
- * @description Defines a connection to a data element on a data resource.
6763
- *
6764
- * NOTE: This is considered an internal data structure and is not guaranteed to be stable.
6765
- * Future updates that do not break the edgehanced/data-bound state of a composition may be made without notice.
6766
- */
6730
+ /** @description Defines a connection to a dynamic token on a data resource. */
6767
6731
  DataElementConnectionDefinition: {
6768
- /** @description A JSON Pointer expression that defines the data element to connect the parameter to. */
6732
+ /** @description A JSON Pointer expression that defines the data resource dynamic token value. */
6769
6733
  pointer: string;
6770
6734
  /**
6771
- * @description The syntax used to select the data element to bind to
6735
+ * @description The syntax used to select the dynamic token to bind to
6772
6736
  * @enum {string}
6773
6737
  */
6774
6738
  syntax: "jptr";
@@ -7794,7 +7758,7 @@ type ComponentParameterContextualEditing<TValue = unknown> = ComponentParameter<
7794
7758
  isEditable?: boolean;
7795
7759
  };
7796
7760
  };
7797
- /** Defines a connection to a data element on a data resource. */
7761
+ /** Defines a connection to a dynamic token on a data resource. */
7798
7762
  type DataElementConnectionDefinition = SharedComponents['DataElementConnectionDefinition'];
7799
7763
  /** Variable values for a data resource. */
7800
7764
  type DataResourceVariables = SharedComponents['DataResourceVariables'];
@@ -7872,7 +7836,7 @@ type CompositionPatternIssue = CompositionIssueCore & {
7872
7836
  type: 'pattern';
7873
7837
  code: NonNullable<ComponentInstance['_patternError']>;
7874
7838
  };
7875
- /** An error while binding a data element from a data resource to a component parameter (i.e. a missing property in the data resource) */
7839
+ /** An error while binding a dynamic token from a data resource to a component parameter (i.e. a missing property in the data resource) */
7876
7840
  type DataElementBindingIssue = CompositionIssueCore & {
7877
7841
  type: 'binding';
7878
7842
  parameterName: string;
@@ -8606,7 +8570,7 @@ type ProjectMapLinkComponentParameterValue = ProjectMapLinkParamValue | undefine
8606
8570
  type LinkComponentParameterValue = LinkParamValue;
8607
8571
 
8608
8572
  type RichTextBuiltInFormat = 'code' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'superscript' | 'subscript';
8609
- type RichTextBuiltInElement = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'unorderedList' | 'orderedList' | 'link' | 'quote' | 'code';
8573
+ type RichTextBuiltInElement = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'unorderedList' | 'orderedList' | 'link' | 'quote' | 'code' | 'variable';
8610
8574
  type RichTextParamConfiguration = {
8611
8575
  required?: boolean;
8612
8576
  formatting?: {
@@ -9062,50 +9026,6 @@ declare class RouteClient extends ApiClient<RouteClientOptions> {
9062
9026
  getRoute(options?: Omit<RouteGetParameters, 'projectId'>): Promise<ResolvedRouteGetResponse>;
9063
9027
  }
9064
9028
 
9065
- type BindVariablesResult<TValue> = {
9066
- boundCount: number;
9067
- result: TValue;
9068
- errors?: string[];
9069
- };
9070
- type BindVariablesToObjectOptions<T> = {
9071
- /** The object to bind variables to. Only strings or objects are bound. */
9072
- value: T;
9073
- } & Omit<BindVariablesOptions, 'value'>;
9074
- /**
9075
- * Binds composition variables to an object whose string keys may have variable expressions in them.
9076
- * Binding is recursive.
9077
- */
9078
- declare function bindVariablesToObject<T>(options: BindVariablesToObjectOptions<T>): BindVariablesResult<T>;
9079
-
9080
- type BindVariablesOptions = {
9081
- /** Current variable values table */
9082
- variables: DataResourceVariables;
9083
- /** String value to bind variables to */
9084
- value: string;
9085
- /**
9086
- * Text prefix for any variable binding errors that might be returned
9087
- * @default "Variable"
9088
- */
9089
- errorPrefix?: string;
9090
- /**
9091
- * Optionally provide overridden binding behaviour with a function.
9092
- * Default behaviour:
9093
- * - If variable is not defined, its expression is replaced by empty string and an error is returned
9094
- * - If variable is defined, its expression is replaced by its value
9095
- * @param variableName The variable name referred to in the `value` string. This is the name inside the ${} expression.
9096
- * @param variables The current variables table.
9097
- * @param errors Errors array. Push to it to add errors to the result.
9098
- * @returns New value for the variable reference expression, will replace the whole ${} in the result.
9099
- */
9100
- handleBinding?: (variableName: string, variables: DataResourceVariables, errors: string[]) => string;
9101
- };
9102
- /**
9103
- * Binds variables to a string that could have variable values in it.
9104
- * Variables are referenced in the string as ${variableName}.
9105
- * Literal variable values are escaped with a backslash, e.g. \${literal}
9106
- */
9107
- declare function bindVariables({ variables, value, errorPrefix, handleBinding, }: BindVariablesOptions): BindVariablesResult<string>;
9108
-
9109
9029
  /** Public ID of Canvas personalization component type */
9110
9030
  declare const CANVAS_PERSONALIZE_TYPE = "$personalization";
9111
9031
  /** Public ID of Canvas A/B test component type */
@@ -9346,6 +9266,63 @@ declare function mapSlotToPersonalizedVariations(slot: ComponentInstance[] | und
9346
9266
  */
9347
9267
  declare function mapSlotToTestVariations(slot: ComponentInstance[] | undefined): Array<ComponentInstance & TestVariant>;
9348
9268
 
9269
+ type BindVariablesResult<TValue> = {
9270
+ /** Number of dynamic expressions that attempted to be bound (regardless of the success of the binding) */
9271
+ boundCount: number;
9272
+ /** Result object after the binding */
9273
+ result: TValue;
9274
+ /** Any errors that occurred resolving bound values */
9275
+ errors?: Array<string | Error>;
9276
+ };
9277
+ type BindVariablesToObjectOptions<T> = {
9278
+ /** The object to bind variables to. Only strings or objects are bound. */
9279
+ value: T;
9280
+ } & Omit<BindVariablesOptions, 'value'>;
9281
+ /**
9282
+ * Binds composition variables to an object whose string keys may have variable expressions in them.
9283
+ * Binding is recursive.
9284
+ */
9285
+ declare function bindVariablesToObject<T>(options: BindVariablesToObjectOptions<T>): BindVariablesResult<T>;
9286
+
9287
+ type BindVariablesOptions = {
9288
+ /** Current variable values table */
9289
+ variables: Record<string, unknown>;
9290
+ /** String value to bind variables to */
9291
+ value: string;
9292
+ /**
9293
+ * Text prefix for any variable binding errors that might be returned
9294
+ * @default "Variable"
9295
+ */
9296
+ errorPrefix?: string;
9297
+ /**
9298
+ * Optionally provide overridden binding behaviour with a function.
9299
+ * Default behaviour:
9300
+ * - If variable is not defined, its expression is replaced by empty string and an error is returned
9301
+ * - If variable is defined, its expression is replaced by its value
9302
+ * @param variableName The variable name referred to in the `value` string. This is the name inside the ${} expression.
9303
+ * @param variables The current variables table.
9304
+ * @param errors Errors array. Push to it to add errors to the result.
9305
+ * @returns New value for the variable reference expression, will replace the whole ${} in the result. If non-string value is returned, then:
9306
+ * - If the original string value contains ONLY the variable reference (i.e. "${foo}") then the value will be used literally, e.g. the property becomes an array, etc
9307
+ * - If the original value contains other text, then the value will be string-interpolated as a fallback (i.e. [object Object], 'array,elements', etc)
9308
+ */
9309
+ handleBinding?: (variableName: string, variables: Record<string, unknown>, errors: Array<string | Error>) => unknown;
9310
+ };
9311
+ /**
9312
+ * Binds variables to a string that could have variable values in it.
9313
+ * Variables are referenced in the string as ${variableName}.
9314
+ * Literal variable values are escaped with a backslash, e.g. \${literal}
9315
+ */
9316
+ declare function bindVariables({ variables, value, errorPrefix, handleBinding, }: BindVariablesOptions): BindVariablesResult<unknown>;
9317
+
9318
+ declare function createVariableReference(variableName: string): string;
9319
+
9320
+ /**
9321
+ * Parses an expression that may contain Uniform variables and invokes a callback for each text or variable token found
9322
+ * @returns the number of tokens found in the string (variable or text)
9323
+ */
9324
+ declare function parseVariableExpression(serialized: string, onToken?: (token: string, type: 'text' | 'variable') => void | false): number;
9325
+
9349
9326
  declare const CanvasClientError: typeof ApiClientError;
9350
9327
 
9351
- export { ATTRIBUTE_COMPONENT_ID, ATTRIBUTE_MULTILINE, ATTRIBUTE_PARAMETER_ID, ATTRIBUTE_PARAMETER_TYPE, ATTRIBUTE_PARAMETER_VALUE, ATTRIBUTE_PLACEHOLDER, AddComponentMessage, BatchEnhancer, BatchEntry, BatchInvalidationPayload, BindVariablesOptions, BindVariablesResult, BindVariablesToObjectOptions, CANVAS_DRAFT_STATE, CANVAS_ENRICHMENT_TAG_PARAM, CANVAS_INTENT_TAG_PARAM, CANVAS_LOCALE_TAG_PARAM, CANVAS_LOCALIZATION_SLOT, CANVAS_LOCALIZATION_TYPE, CANVAS_PERSONALIZATION_PARAM, CANVAS_PERSONALIZE_SLOT, CANVAS_PERSONALIZE_TYPE, CANVAS_PUBLISHED_STATE, CANVAS_TEST_SLOT, CANVAS_TEST_TYPE, CANVAS_TEST_VARIANT_PARAM, CanvasClient, CanvasClientError, CanvasDefinitions, CategoriesDeleteParameters, CategoriesGetParameters, CategoriesGetResponse, CategoriesPutParameters, Category, CategoryClient, Channel, ChannelMessage, ChannelSubscription, ChildEnhancerBuilder, ComponentDefinition, ComponentDefinitionDeleteParameters, ComponentDefinitionGetParameters, ComponentDefinitionGetResponse, ComponentDefinitionParameter, ComponentDefinitionPermission, ComponentDefinitionPutParameters, ComponentDefinitionSlot, ComponentDefinitionSlugSettings, ComponentDefinitionVariant, ComponentEnhancer, ComponentEnhancerFunction, ComponentEnhancerOptions, ComponentInstance, ComponentInstanceHistoryEntry, ComponentInstanceHistoryGetParameters, ComponentInstanceHistoryGetResponse, ComponentLocationReference, ComponentOverridability, ComponentOverride, ComponentOverrides, ComponentParameter, ComponentParameterContextualEditing, ComponentParameterEnhancer, ComponentParameterEnhancerFunction, ComponentParameterEnhancerOptions, CompositionDataDiagnostic, CompositionDeleteParameters, CompositionDiagnostics, CompositionGetByComponentIdParameters, CompositionGetByIdParameters, CompositionGetByNodeIdParameters, CompositionGetByNodePathParameters, CompositionGetBySlugParameters, CompositionGetListResponse, CompositionGetOrderBy, CompositionGetParameters, CompositionGetResponse, CompositionGetValidResponses, CompositionIssue, CompositionPatternIssue, CompositionPutParameters, CompositionRelationshipsClientOptions, CompositionRelationshipsDDefinitionGetResponse, CompositionRelationshipsDefinitionApi, CompositionRelationshipsDefinitionGetParameters, CompositionResolvedGetResponse, CompositionUIStatus, ContextualEditingComponentReference, DataElementBindingIssue, DataElementConnectionDefinition, DataResolutionConfigIssue, DataResolutionOption, DataResolutionOptionNegative, DataResolutionOptionPositive, DataResolutionParameters, DataResourceDefinition, DataResourceDefinitions, DataResourceIssue, DataResourceVariables, DataSource, DataSourceClient, DataSourceDeleteParameters, DataSourceGetParameters, DataSourceGetResponse, DataSourcePutParameters, DataSourcesGetParameters, DataSourcesGetResponse, DataType, DataTypeClient, DataTypeDeleteParameters, DataTypeGetParameters, DataTypeGetResponse, DataTypePutParameters, DataVariableDefinition, DismissPlaceholderMessage, DynamicInputIssue, EDGE_CACHE_DISABLED, EDGE_DEFAULT_CACHE_TTL, EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS, EDGE_MAX_CACHE_TTL, EDGE_MAX_L2_CACHE_TTL_IN_HOURS, EDGE_MIN_CACHE_TTL, EDGE_MIN_L2_CACHE_TTL_IN_HOURS, EMPTY_COMPOSITION, EnhancerBuilder, EnhancerContext, EnhancerError, EventNames, GetParameterAttributesProps, IN_CONTEXT_EDITOR_COMPONENT_END_ROLE, IN_CONTEXT_EDITOR_COMPONENT_START_ROLE, IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID, IN_CONTEXT_EDITOR_QUERY_STRING_PARAM, IS_RENDERED_BY_UNIFORM_ATTRIBUTE, InvalidationPayload, InvalidationResult, LimitPolicy, LinkComponentParameterValue, LinkParamConfiguration, LinkParamValue, LinkParameterType, LinkTypeConfiguration, MessageHandler, MoveComponentMessage, NonProjectMapLinkParamValue, OverrideOptions, PLACEHOLDER_ID, PreviewEventBus, PreviewPanelSettings, ProjectMapLinkComponentParameterValue, ProjectMapLinkParamValue, ReadyMessage, ReportRenderedCompositionsMessage, ResolvedRouteGetResponse, RichTextBuiltInElement, RichTextBuiltInFormat, RichTextParamConfiguration, RichTextParamValue, RootComponentInstance, RouteClient, RouteDynamicInputs, RouteGetParameters, RouteGetResponse, RouteGetResponseComposition, RouteGetResponseEdgehancedComposition, RouteGetResponseNotFound, RouteGetResponseRedirect, SelectComponentMessage, SelectParameterMessage, SpecificProjectMap, SubscribeToCompositionOptions, TriggerCompositionActionMessage, UncachedCanvasClient, UncachedCategoryClient, UniqueBatchEntries, UnsubscribeCallback, UpdateComponentParameterMessage, UpdateCompositionInternalMessage, UpdateCompositionMessage, UpdateContextualEditingStateInternalMessage, UpdatePreviewSettingsMessage, UsageTrackingApi, UsageTrackingGetParameters, UsageTrackingGetResponse, UsageTrackingPostParameters, UsageTrackingPostResponse, WalkComponentTreeActions, bindVariables, bindVariablesToObject, compose, createBatchEnhancer, createCanvasChannel, createEventBus, createLimitPolicy, createUniformApiEnhancer, enhance, extractLocales, generateHash, getChannelName, getComponentJsonPointer, getComponentPath, getParameterAttributes, isAddComponentMessage, isDismissPlaceholderMessage, isMovingComponentMessage, isReadyMessage, isReportRenderedCompositionsMessage, isSelectComponentMessage, isSelectParameterMessage, isSystemComponentDefinition, isTriggerCompositionActionMessage, isUpdateComponentParameterMessage, isUpdateCompositionInternalMessage, isUpdateCompositionMessage, isUpdateContextualEditingStateInternalMessage, isUpdatePreviewSettingsMessage, localize, mapSlotToPersonalizedVariations, mapSlotToTestVariations, nullLimitPolicy, subscribeToComposition, unstable_CompositionRelationshipClient, walkComponentTree };
9328
+ export { ATTRIBUTE_COMPONENT_ID, ATTRIBUTE_MULTILINE, ATTRIBUTE_PARAMETER_ID, ATTRIBUTE_PARAMETER_TYPE, ATTRIBUTE_PARAMETER_VALUE, ATTRIBUTE_PLACEHOLDER, AddComponentMessage, BatchEnhancer, BatchEntry, BatchInvalidationPayload, BindVariablesOptions, BindVariablesResult, BindVariablesToObjectOptions, CANVAS_DRAFT_STATE, CANVAS_ENRICHMENT_TAG_PARAM, CANVAS_INTENT_TAG_PARAM, CANVAS_LOCALE_TAG_PARAM, CANVAS_LOCALIZATION_SLOT, CANVAS_LOCALIZATION_TYPE, CANVAS_PERSONALIZATION_PARAM, CANVAS_PERSONALIZE_SLOT, CANVAS_PERSONALIZE_TYPE, CANVAS_PUBLISHED_STATE, CANVAS_TEST_SLOT, CANVAS_TEST_TYPE, CANVAS_TEST_VARIANT_PARAM, CanvasClient, CanvasClientError, CanvasDefinitions, CategoriesDeleteParameters, CategoriesGetParameters, CategoriesGetResponse, CategoriesPutParameters, Category, CategoryClient, Channel, ChannelMessage, ChannelSubscription, ChildEnhancerBuilder, ComponentDefinition, ComponentDefinitionDeleteParameters, ComponentDefinitionGetParameters, ComponentDefinitionGetResponse, ComponentDefinitionParameter, ComponentDefinitionPermission, ComponentDefinitionPutParameters, ComponentDefinitionSlot, ComponentDefinitionSlugSettings, ComponentDefinitionVariant, ComponentEnhancer, ComponentEnhancerFunction, ComponentEnhancerOptions, ComponentInstance, ComponentInstanceHistoryEntry, ComponentInstanceHistoryGetParameters, ComponentInstanceHistoryGetResponse, ComponentLocationReference, ComponentOverridability, ComponentOverride, ComponentOverrides, ComponentParameter, ComponentParameterContextualEditing, ComponentParameterEnhancer, ComponentParameterEnhancerFunction, ComponentParameterEnhancerOptions, CompositionDataDiagnostic, CompositionDeleteParameters, CompositionDiagnostics, CompositionGetByComponentIdParameters, CompositionGetByIdParameters, CompositionGetByNodeIdParameters, CompositionGetByNodePathParameters, CompositionGetBySlugParameters, CompositionGetListResponse, CompositionGetOrderBy, CompositionGetParameters, CompositionGetResponse, CompositionGetValidResponses, CompositionIssue, CompositionPatternIssue, CompositionPutParameters, CompositionRelationshipsClientOptions, CompositionRelationshipsDDefinitionGetResponse, CompositionRelationshipsDefinitionApi, CompositionRelationshipsDefinitionGetParameters, CompositionResolvedGetResponse, CompositionUIStatus, ContextualEditingComponentReference, DataElementBindingIssue, DataElementConnectionDefinition, DataResolutionConfigIssue, DataResolutionOption, DataResolutionOptionNegative, DataResolutionOptionPositive, DataResolutionParameters, DataResourceDefinition, DataResourceDefinitions, DataResourceIssue, DataResourceVariables, DataSource, DataSourceClient, DataSourceDeleteParameters, DataSourceGetParameters, DataSourceGetResponse, DataSourcePutParameters, DataSourcesGetParameters, DataSourcesGetResponse, DataType, DataTypeClient, DataTypeDeleteParameters, DataTypeGetParameters, DataTypeGetResponse, DataTypePutParameters, DataVariableDefinition, DismissPlaceholderMessage, DynamicInputIssue, EDGE_CACHE_DISABLED, EDGE_DEFAULT_CACHE_TTL, EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS, EDGE_MAX_CACHE_TTL, EDGE_MAX_L2_CACHE_TTL_IN_HOURS, EDGE_MIN_CACHE_TTL, EDGE_MIN_L2_CACHE_TTL_IN_HOURS, EMPTY_COMPOSITION, EnhancerBuilder, EnhancerContext, EnhancerError, EventNames, GetParameterAttributesProps, IN_CONTEXT_EDITOR_COMPONENT_END_ROLE, IN_CONTEXT_EDITOR_COMPONENT_START_ROLE, IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID, IN_CONTEXT_EDITOR_QUERY_STRING_PARAM, IS_RENDERED_BY_UNIFORM_ATTRIBUTE, InvalidationPayload, InvalidationResult, LimitPolicy, LinkComponentParameterValue, LinkParamConfiguration, LinkParamValue, LinkParameterType, LinkTypeConfiguration, MessageHandler, MoveComponentMessage, NonProjectMapLinkParamValue, OverrideOptions, PLACEHOLDER_ID, PreviewEventBus, PreviewPanelSettings, ProjectMapLinkComponentParameterValue, ProjectMapLinkParamValue, ReadyMessage, ReportRenderedCompositionsMessage, ResolvedRouteGetResponse, RichTextBuiltInElement, RichTextBuiltInFormat, RichTextParamConfiguration, RichTextParamValue, RootComponentInstance, RouteClient, RouteDynamicInputs, RouteGetParameters, RouteGetResponse, RouteGetResponseComposition, RouteGetResponseEdgehancedComposition, RouteGetResponseNotFound, RouteGetResponseRedirect, SelectComponentMessage, SelectParameterMessage, SpecificProjectMap, SubscribeToCompositionOptions, TriggerCompositionActionMessage, UncachedCanvasClient, UncachedCategoryClient, UniqueBatchEntries, UnsubscribeCallback, UpdateComponentParameterMessage, UpdateCompositionInternalMessage, UpdateCompositionMessage, UpdateContextualEditingStateInternalMessage, UpdatePreviewSettingsMessage, UsageTrackingApi, UsageTrackingGetParameters, UsageTrackingGetResponse, UsageTrackingPostParameters, UsageTrackingPostResponse, WalkComponentTreeActions, bindVariables, bindVariablesToObject, compose, createBatchEnhancer, createCanvasChannel, createEventBus, createLimitPolicy, createUniformApiEnhancer, createVariableReference, enhance, extractLocales, generateHash, getChannelName, getComponentJsonPointer, getComponentPath, getParameterAttributes, isAddComponentMessage, isDismissPlaceholderMessage, isMovingComponentMessage, isReadyMessage, isReportRenderedCompositionsMessage, isSelectComponentMessage, isSelectParameterMessage, isSystemComponentDefinition, isTriggerCompositionActionMessage, isUpdateComponentParameterMessage, isUpdateCompositionInternalMessage, isUpdateCompositionMessage, isUpdateContextualEditingStateInternalMessage, isUpdatePreviewSettingsMessage, localize, mapSlotToPersonalizedVariations, mapSlotToTestVariations, nullLimitPolicy, parseVariableExpression, subscribeToComposition, unstable_CompositionRelationshipClient, walkComponentTree };
package/dist/index.esm.js CHANGED
@@ -1658,80 +1658,6 @@ var RouteClient = class extends ApiClient6 {
1658
1658
  }
1659
1659
  };
1660
1660
 
1661
- // src/utils/bindVariables.ts
1662
- function bindVariables({
1663
- variables,
1664
- value,
1665
- errorPrefix = "Variable",
1666
- handleBinding
1667
- }) {
1668
- let boundCount = 0;
1669
- const errors = [];
1670
- const defaultHandleBinding = (variableName, variables2, errors2) => {
1671
- const variableValue = variables2[variableName];
1672
- if (variableValue === void 0) {
1673
- errors2.push(`${errorPrefix} "${variableName}" is not defined`);
1674
- return "";
1675
- }
1676
- return variableValue;
1677
- };
1678
- const result = value.replace(/(?<!\\)\${([^}]+)}/g, (_match, variableName) => {
1679
- const variableValue = (handleBinding != null ? handleBinding : defaultHandleBinding)(variableName, variables, errors);
1680
- boundCount++;
1681
- return variableValue;
1682
- });
1683
- return { result, boundCount, errors: errors.length > 0 ? errors : void 0 };
1684
- }
1685
-
1686
- // src/utils/bindVariablesToObject.ts
1687
- import { produce } from "immer";
1688
- function bindVariablesToObject(options) {
1689
- return bindVariablesToObjectRecursive(options);
1690
- }
1691
- function bindVariablesToObjectRecursive({
1692
- value,
1693
- recursivePath,
1694
- ...bindVariablesOptions
1695
- }) {
1696
- let boundCount = 0;
1697
- const errors = [];
1698
- if (typeof value === "string") {
1699
- return bindVariables({ ...bindVariablesOptions, value });
1700
- }
1701
- if (typeof value !== "object" || value === null) {
1702
- return { boundCount: 0, result: value };
1703
- }
1704
- const result = produce(value, (draft) => {
1705
- Object.entries(draft).forEach(([property, oldValue]) => {
1706
- const currentObjectPath = recursivePath ? `${recursivePath}.${property}` : property;
1707
- if (typeof oldValue === "string") {
1708
- const bindResult = bindVariables({ ...bindVariablesOptions, value: oldValue });
1709
- if (oldValue !== bindResult.result || bindResult.errors) {
1710
- boundCount += bindResult.boundCount;
1711
- draft[property] = bindResult.result;
1712
- if (bindResult.errors) {
1713
- errors.push(...bindResult.errors.map((e) => `${currentObjectPath}: ${e}`));
1714
- }
1715
- }
1716
- return;
1717
- }
1718
- const childBind = bindVariablesToObjectRecursive({
1719
- ...bindVariablesOptions,
1720
- value: oldValue,
1721
- recursivePath: currentObjectPath
1722
- });
1723
- if (childBind.boundCount || childBind.errors) {
1724
- boundCount += childBind.boundCount;
1725
- draft[property] = childBind.result;
1726
- if (childBind.errors) {
1727
- errors.push(...childBind.errors.map((e) => `${currentObjectPath}: ${e}`));
1728
- }
1729
- }
1730
- });
1731
- });
1732
- return { boundCount, result, errors: errors.length > 0 ? errors : void 0 };
1733
- }
1734
-
1735
1661
  // src/utils/createApiEnhancer.ts
1736
1662
  var createUniformApiEnhancer = ({ apiUrl }) => {
1737
1663
  return async (message) => {
@@ -1821,6 +1747,180 @@ function mapSlotToTestVariations(slot) {
1821
1747
  });
1822
1748
  }
1823
1749
 
1750
+ // src/utils/variables/parseVariableExpression.ts
1751
+ var escapeCharacter = "\\";
1752
+ var variablePrefix = "${";
1753
+ var variableSuffix = "}";
1754
+ function parseVariableExpression(serialized, onToken) {
1755
+ let bufferStartIndex = 0;
1756
+ let bufferEndIndex = 0;
1757
+ let tokenCount = 0;
1758
+ const handleToken = (token, type) => {
1759
+ tokenCount++;
1760
+ return onToken == null ? void 0 : onToken(token, type);
1761
+ };
1762
+ let state = "text";
1763
+ for (let index = 0; index < serialized.length; index++) {
1764
+ const char = serialized[index];
1765
+ if (bufferStartIndex > bufferEndIndex) {
1766
+ bufferEndIndex = bufferStartIndex;
1767
+ }
1768
+ if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
1769
+ if (serialized[index - 1] === escapeCharacter) {
1770
+ bufferEndIndex -= escapeCharacter.length;
1771
+ if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
1772
+ return tokenCount;
1773
+ }
1774
+ bufferStartIndex = index;
1775
+ bufferEndIndex = index + 1;
1776
+ continue;
1777
+ }
1778
+ state = "variable";
1779
+ if (bufferEndIndex > bufferStartIndex) {
1780
+ if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
1781
+ return tokenCount;
1782
+ }
1783
+ bufferStartIndex = bufferEndIndex;
1784
+ }
1785
+ index += variablePrefix.length - 1;
1786
+ bufferStartIndex += variablePrefix.length;
1787
+ continue;
1788
+ }
1789
+ if (char === variableSuffix && state === "variable") {
1790
+ state = "text";
1791
+ if (bufferEndIndex > bufferStartIndex) {
1792
+ if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "variable") === false) {
1793
+ return tokenCount;
1794
+ }
1795
+ bufferStartIndex = bufferEndIndex + variableSuffix.length;
1796
+ }
1797
+ continue;
1798
+ }
1799
+ bufferEndIndex++;
1800
+ }
1801
+ if (bufferEndIndex > bufferStartIndex) {
1802
+ if (state === "variable") {
1803
+ state = "text";
1804
+ bufferStartIndex -= variablePrefix.length;
1805
+ }
1806
+ handleToken(serialized.substring(bufferStartIndex), state);
1807
+ }
1808
+ return tokenCount;
1809
+ }
1810
+
1811
+ // src/utils/variables/bindVariables.ts
1812
+ function bindVariables({
1813
+ variables,
1814
+ value,
1815
+ errorPrefix = "Variable",
1816
+ handleBinding
1817
+ }) {
1818
+ let boundCount = 0;
1819
+ let tokenCount = 0;
1820
+ const errors = [];
1821
+ const defaultHandleBinding = (variableName, variables2, errors2) => {
1822
+ const variableValue = variables2[variableName];
1823
+ if (variableValue === void 0) {
1824
+ errors2.push(`${errorPrefix} "${variableName}" is not defined`);
1825
+ return "";
1826
+ }
1827
+ return variableValue;
1828
+ };
1829
+ const result = [];
1830
+ parseVariableExpression(value, (token, tokenType) => {
1831
+ tokenCount++;
1832
+ if (tokenType === "text") {
1833
+ result.push(token);
1834
+ return;
1835
+ }
1836
+ const variableValue = (handleBinding != null ? handleBinding : defaultHandleBinding)(token, variables, errors);
1837
+ boundCount++;
1838
+ result.push(variableValue);
1839
+ });
1840
+ return {
1841
+ result: tokenCount === 1 ? result[0] : result.join(""),
1842
+ boundCount,
1843
+ errors: errors.length > 0 ? errors : void 0
1844
+ };
1845
+ }
1846
+
1847
+ // src/utils/variables/bindVariablesToObject.ts
1848
+ import { produce } from "immer";
1849
+
1850
+ // src/utils/variables/createVariableReference.ts
1851
+ function createVariableReference(variableName) {
1852
+ return `\${${variableName}}`;
1853
+ }
1854
+
1855
+ // src/utils/variables/bindVariablesToObject.ts
1856
+ function bindVariablesToObject(options) {
1857
+ return bindVariablesToObjectRecursive(options);
1858
+ }
1859
+ function bindVariablesToObjectRecursive({
1860
+ value,
1861
+ recursivePath,
1862
+ ...bindVariablesOptions
1863
+ }) {
1864
+ let boundCount = 0;
1865
+ const errors = [];
1866
+ if (typeof value === "string") {
1867
+ return bindVariables({ ...bindVariablesOptions, value });
1868
+ }
1869
+ if (typeof value !== "object" || value === null) {
1870
+ return { boundCount: 0, result: value };
1871
+ }
1872
+ const richTextNodeResult = handleRichTextNodeBinding(value, bindVariablesOptions);
1873
+ if (richTextNodeResult !== void 0) {
1874
+ return richTextNodeResult;
1875
+ }
1876
+ const result = produce(value, (draft) => {
1877
+ Object.entries(draft).forEach(([property, oldValue]) => {
1878
+ const currentObjectPath = recursivePath ? `${recursivePath}.${property}` : property;
1879
+ if (typeof oldValue === "string") {
1880
+ const bindResult = bindVariables({ ...bindVariablesOptions, value: oldValue });
1881
+ if (oldValue !== bindResult.result || bindResult.errors) {
1882
+ boundCount += bindResult.boundCount;
1883
+ draft[property] = bindResult.result;
1884
+ if (bindResult.errors) {
1885
+ errors.push(...bindResult.errors.map((e) => `${currentObjectPath}: ${e}`));
1886
+ }
1887
+ }
1888
+ return;
1889
+ }
1890
+ const childBind = bindVariablesToObjectRecursive({
1891
+ ...bindVariablesOptions,
1892
+ value: oldValue,
1893
+ recursivePath: currentObjectPath
1894
+ });
1895
+ if (childBind.boundCount || childBind.errors) {
1896
+ boundCount += childBind.boundCount;
1897
+ draft[property] = childBind.result;
1898
+ if (childBind.errors) {
1899
+ errors.push(...childBind.errors);
1900
+ }
1901
+ }
1902
+ });
1903
+ });
1904
+ return { boundCount, result, errors: errors.length > 0 ? errors : void 0 };
1905
+ }
1906
+ function handleRichTextNodeBinding(object, options) {
1907
+ if ("type" in object && object.type === "variable" && "reference" in object && typeof object.reference === "string" && "version" in object && object.version === 1) {
1908
+ const value = createVariableReference(object.reference);
1909
+ const bindResult = bindVariables({ ...options, value });
1910
+ const bindResultAsTextNode = {
1911
+ detail: 0,
1912
+ format: 0,
1913
+ mode: "normal",
1914
+ style: "",
1915
+ text: bindResult.result,
1916
+ type: "text",
1917
+ version: 1
1918
+ };
1919
+ return { ...bindResult, result: bindResultAsTextNode };
1920
+ }
1921
+ return void 0;
1922
+ }
1923
+
1824
1924
  // src/index.ts
1825
1925
  import { ApiClientError as ApiClientError2 } from "@uniformdev/context/api";
1826
1926
  var CanvasClientError = ApiClientError2;
@@ -1879,6 +1979,7 @@ export {
1879
1979
  createEventBus,
1880
1980
  createLimitPolicy,
1881
1981
  createUniformApiEnhancer,
1982
+ createVariableReference,
1882
1983
  enhance,
1883
1984
  extractLocales,
1884
1985
  generateHash,
@@ -1904,6 +2005,7 @@ export {
1904
2005
  mapSlotToPersonalizedVariations,
1905
2006
  mapSlotToTestVariations,
1906
2007
  nullLimitPolicy,
2008
+ parseVariableExpression,
1907
2009
  subscribeToComposition,
1908
2010
  unstable_CompositionRelationshipClient,
1909
2011
  walkComponentTree