@uniformdev/canvas 20.80.1 → 20.80.2-alpha.14.sha-1c81418f05

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.mts CHANGED
@@ -7086,6 +7086,17 @@ interface components$e {
7086
7086
  * * The route with the most path segments wins
7087
7087
  * * If several matches have the same number of segments, the one with the fewest dynamic segments wins
7088
7088
  * * If still ambiguous, the first matching route arbitrarily wins
7089
+ *
7090
+ * Invalid paths:
7091
+ * The request fails with HTTP 400 when the path, ignoring its query string and trailing slashes:
7092
+ * * contains consecutive slashes (for example "/en//about" or "//en/about")
7093
+ * * has a path segment that is too long to match any route. The limit depends on the characters used,
7094
+ * and is generally 150-220 characters per segment.
7095
+ *
7096
+ * Probe paths:
7097
+ * On uniform.global, paths ending in an archive, backup or database file extension (for example "/site.zip",
7098
+ * "/config.php.bak" or "/db.sql") return `{ "type": "notFound" }` without being matched, even where a dynamic
7099
+ * project map node or redirect would match them.
7089
7100
  */
7090
7101
  path: string;
7091
7102
  /** Specify a project map ID to fetch route from. If not specified, the default project map for the projectId is used */
@@ -10099,6 +10110,17 @@ interface components$b {
10099
10110
  * * The route with the most path segments wins
10100
10111
  * * If several matches have the same number of segments, the one with the fewest dynamic segments wins
10101
10112
  * * If still ambiguous, the first matching route arbitrarily wins
10113
+ *
10114
+ * Invalid paths:
10115
+ * The request fails with HTTP 400 when the path, ignoring its query string and trailing slashes:
10116
+ * * contains consecutive slashes (for example "/en//about" or "//en/about")
10117
+ * * has a path segment that is too long to match any route. The limit depends on the characters used,
10118
+ * and is generally 150-220 characters per segment.
10119
+ *
10120
+ * Probe paths:
10121
+ * On uniform.global, paths ending in an archive, backup or database file extension (for example "/site.zip",
10122
+ * "/config.php.bak" or "/db.sql") return `{ "type": "notFound" }` without being matched, even where a dynamic
10123
+ * project map node or redirect would match them.
10102
10124
  */
10103
10125
  path: string;
10104
10126
  /** Specify a project map ID to fetch route from. If not specified, the default project map for the projectId is used */
@@ -10272,6 +10294,17 @@ interface paths$a {
10272
10294
  * * The route with the most path segments wins
10273
10295
  * * If several matches have the same number of segments, the one with the fewest dynamic segments wins
10274
10296
  * * If still ambiguous, the first matching route arbitrarily wins
10297
+ *
10298
+ * Invalid paths:
10299
+ * The request fails with HTTP 400 when the path, ignoring its query string and trailing slashes:
10300
+ * * contains consecutive slashes (for example "/en//about" or "//en/about")
10301
+ * * has a path segment that is too long to match any route. The limit depends on the characters used,
10302
+ * and is generally 150-220 characters per segment.
10303
+ *
10304
+ * Probe paths:
10305
+ * On uniform.global, paths ending in an archive, backup or database file extension (for example "/site.zip",
10306
+ * "/config.php.bak" or "/db.sql") return `{ "type": "notFound" }` without being matched, even where a dynamic
10307
+ * project map node or redirect would match them.
10275
10308
  */
10276
10309
  path: components$a["parameters"]["path"];
10277
10310
  /** Specify a project map ID to fetch route from. If not specified, the default project map for the projectId is used */
@@ -11146,6 +11179,17 @@ interface components$a {
11146
11179
  * * The route with the most path segments wins
11147
11180
  * * If several matches have the same number of segments, the one with the fewest dynamic segments wins
11148
11181
  * * If still ambiguous, the first matching route arbitrarily wins
11182
+ *
11183
+ * Invalid paths:
11184
+ * The request fails with HTTP 400 when the path, ignoring its query string and trailing slashes:
11185
+ * * contains consecutive slashes (for example "/en//about" or "//en/about")
11186
+ * * has a path segment that is too long to match any route. The limit depends on the characters used,
11187
+ * and is generally 150-220 characters per segment.
11188
+ *
11189
+ * Probe paths:
11190
+ * On uniform.global, paths ending in an archive, backup or database file extension (for example "/site.zip",
11191
+ * "/config.php.bak" or "/db.sql") return `{ "type": "notFound" }` without being matched, even where a dynamic
11192
+ * project map node or redirect would match them.
11149
11193
  */
11150
11194
  path: string;
11151
11195
  /** Specify a project map ID to fetch route from. If not specified, the default project map for the projectId is used */
@@ -16094,7 +16138,7 @@ declare function hasReferencedVariables(value: string | undefined): number;
16094
16138
  */
16095
16139
  declare function parseVariableExpression(serialized: string, onToken?: (token: string, type: 'text' | 'variable', offset: number) => void | false): number;
16096
16140
 
16097
- declare const version = "20.80.1";
16141
+ declare const version = "20.81.0";
16098
16142
 
16099
16143
  /** API client to enable managing workflow definitions */
16100
16144
  declare class WorkflowClient extends ApiClient {
package/dist/index.d.ts CHANGED
@@ -7086,6 +7086,17 @@ interface components$e {
7086
7086
  * * The route with the most path segments wins
7087
7087
  * * If several matches have the same number of segments, the one with the fewest dynamic segments wins
7088
7088
  * * If still ambiguous, the first matching route arbitrarily wins
7089
+ *
7090
+ * Invalid paths:
7091
+ * The request fails with HTTP 400 when the path, ignoring its query string and trailing slashes:
7092
+ * * contains consecutive slashes (for example "/en//about" or "//en/about")
7093
+ * * has a path segment that is too long to match any route. The limit depends on the characters used,
7094
+ * and is generally 150-220 characters per segment.
7095
+ *
7096
+ * Probe paths:
7097
+ * On uniform.global, paths ending in an archive, backup or database file extension (for example "/site.zip",
7098
+ * "/config.php.bak" or "/db.sql") return `{ "type": "notFound" }` without being matched, even where a dynamic
7099
+ * project map node or redirect would match them.
7089
7100
  */
7090
7101
  path: string;
7091
7102
  /** Specify a project map ID to fetch route from. If not specified, the default project map for the projectId is used */
@@ -10099,6 +10110,17 @@ interface components$b {
10099
10110
  * * The route with the most path segments wins
10100
10111
  * * If several matches have the same number of segments, the one with the fewest dynamic segments wins
10101
10112
  * * If still ambiguous, the first matching route arbitrarily wins
10113
+ *
10114
+ * Invalid paths:
10115
+ * The request fails with HTTP 400 when the path, ignoring its query string and trailing slashes:
10116
+ * * contains consecutive slashes (for example "/en//about" or "//en/about")
10117
+ * * has a path segment that is too long to match any route. The limit depends on the characters used,
10118
+ * and is generally 150-220 characters per segment.
10119
+ *
10120
+ * Probe paths:
10121
+ * On uniform.global, paths ending in an archive, backup or database file extension (for example "/site.zip",
10122
+ * "/config.php.bak" or "/db.sql") return `{ "type": "notFound" }` without being matched, even where a dynamic
10123
+ * project map node or redirect would match them.
10102
10124
  */
10103
10125
  path: string;
10104
10126
  /** Specify a project map ID to fetch route from. If not specified, the default project map for the projectId is used */
@@ -10272,6 +10294,17 @@ interface paths$a {
10272
10294
  * * The route with the most path segments wins
10273
10295
  * * If several matches have the same number of segments, the one with the fewest dynamic segments wins
10274
10296
  * * If still ambiguous, the first matching route arbitrarily wins
10297
+ *
10298
+ * Invalid paths:
10299
+ * The request fails with HTTP 400 when the path, ignoring its query string and trailing slashes:
10300
+ * * contains consecutive slashes (for example "/en//about" or "//en/about")
10301
+ * * has a path segment that is too long to match any route. The limit depends on the characters used,
10302
+ * and is generally 150-220 characters per segment.
10303
+ *
10304
+ * Probe paths:
10305
+ * On uniform.global, paths ending in an archive, backup or database file extension (for example "/site.zip",
10306
+ * "/config.php.bak" or "/db.sql") return `{ "type": "notFound" }` without being matched, even where a dynamic
10307
+ * project map node or redirect would match them.
10275
10308
  */
10276
10309
  path: components$a["parameters"]["path"];
10277
10310
  /** Specify a project map ID to fetch route from. If not specified, the default project map for the projectId is used */
@@ -11146,6 +11179,17 @@ interface components$a {
11146
11179
  * * The route with the most path segments wins
11147
11180
  * * If several matches have the same number of segments, the one with the fewest dynamic segments wins
11148
11181
  * * If still ambiguous, the first matching route arbitrarily wins
11182
+ *
11183
+ * Invalid paths:
11184
+ * The request fails with HTTP 400 when the path, ignoring its query string and trailing slashes:
11185
+ * * contains consecutive slashes (for example "/en//about" or "//en/about")
11186
+ * * has a path segment that is too long to match any route. The limit depends on the characters used,
11187
+ * and is generally 150-220 characters per segment.
11188
+ *
11189
+ * Probe paths:
11190
+ * On uniform.global, paths ending in an archive, backup or database file extension (for example "/site.zip",
11191
+ * "/config.php.bak" or "/db.sql") return `{ "type": "notFound" }` without being matched, even where a dynamic
11192
+ * project map node or redirect would match them.
11149
11193
  */
11150
11194
  path: string;
11151
11195
  /** Specify a project map ID to fetch route from. If not specified, the default project map for the projectId is used */
@@ -16094,7 +16138,7 @@ declare function hasReferencedVariables(value: string | undefined): number;
16094
16138
  */
16095
16139
  declare function parseVariableExpression(serialized: string, onToken?: (token: string, type: 'text' | 'variable', offset: number) => void | false): number;
16096
16140
 
16097
- declare const version = "20.80.1";
16141
+ declare const version = "20.81.0";
16098
16142
 
16099
16143
  /** API client to enable managing workflow definitions */
16100
16144
  declare class WorkflowClient extends ApiClient {
package/dist/index.esm.js CHANGED
@@ -1261,10 +1261,12 @@ function flattenSingleNodeValues(data, options = {}) {
1261
1261
  ) : properties;
1262
1262
  }
1263
1263
 
1264
- // src/utils/variables/parseVariableExpression.ts
1265
- var escapeCharacter = "\\";
1264
+ // src/utils/variables/variableSyntax.ts
1266
1265
  var variablePrefix = "${";
1267
1266
  var variableSuffix = "}";
1267
+
1268
+ // src/utils/variables/parseVariableExpression.ts
1269
+ var escapeCharacter = "\\";
1268
1270
  function parseVariableExpression(serialized, onToken) {
1269
1271
  if (typeof serialized !== "string") {
1270
1272
  throw new TypeError("Variable expression must be a string");
@@ -2263,7 +2265,11 @@ function evaluateWalkTreePropertyCriteria({
2263
2265
  delete properties[propertyName];
2264
2266
  }
2265
2267
  } else {
2266
- const { currentValue, remainingConditionalValues } = evaluatePropertyCriteria({
2268
+ const { currentValue, remainingConditionalValues } = property.conditions === void 0 ? (
2269
+ // most properties have no conditions: this is what evaluatePropertyCriteria returns for them,
2270
+ // without the cost of calling it for every property
2271
+ { currentValue: property.value, remainingConditionalValues: void 0 }
2272
+ ) : evaluatePropertyCriteria({
2267
2273
  baseValue: property.value,
2268
2274
  conditionalValues: property.conditions,
2269
2275
  rules,
@@ -3893,6 +3899,9 @@ function bindVariables({
3893
3899
  errorPrefix = "Variable",
3894
3900
  handleBinding
3895
3901
  }) {
3902
+ if (!value.includes(variablePrefix)) {
3903
+ return { result: value, boundCount: 0, errors: void 0 };
3904
+ }
3896
3905
  let boundCount = 0;
3897
3906
  let tokenCount = 0;
3898
3907
  const errors = [];
@@ -3923,13 +3932,15 @@ function bindVariables({
3923
3932
  }
3924
3933
 
3925
3934
  // src/utils/variables/bindVariablesToObject.ts
3926
- import { isDraft, produce } from "immer";
3927
3935
  function bindVariablesToObject(options) {
3928
- return bindVariablesToObjectRecursive(options);
3936
+ const { value } = options;
3937
+ const bindableObjects = typeof value === "object" && value !== null ? findBindableObjects(value) : void 0;
3938
+ return bindVariablesToObjectRecursive({ ...options, bindableObjects });
3929
3939
  }
3930
3940
  function bindVariablesToObjectRecursive({
3931
3941
  value,
3932
3942
  recursivePath,
3943
+ bindableObjects,
3933
3944
  ...bindVariablesOptions
3934
3945
  }) {
3935
3946
  let boundCount = 0;
@@ -3944,50 +3955,93 @@ function bindVariablesToObjectRecursive({
3944
3955
  if (richTextNodeResult !== void 0) {
3945
3956
  return richTextNodeResult;
3946
3957
  }
3947
- const produceToUse = !isDraft(value) ? produce : (produceValue, producer) => {
3948
- producer(produceValue);
3949
- return produceValue;
3958
+ if (bindableObjects && !bindableObjects.has(value)) {
3959
+ return { boundCount: 0, result: value };
3960
+ }
3961
+ let copy;
3962
+ const assign = (property, boundValue) => {
3963
+ copy != null ? copy : copy = Array.isArray(value) ? value.slice() : Object.assign(Object.create(Object.getPrototypeOf(value)), value);
3964
+ copy[property] = boundValue;
3950
3965
  };
3951
- const result = produceToUse(value, (draft) => {
3952
- Object.entries(draft).forEach(([property, oldValue]) => {
3953
- const currentObjectPath = recursivePath ? `${recursivePath}.${property}` : property;
3954
- if (typeof oldValue === "string") {
3955
- const bindResult = bindVariables({ ...bindVariablesOptions, value: oldValue });
3956
- if (oldValue !== bindResult.result || bindResult.errors) {
3957
- boundCount += bindResult.boundCount;
3958
- draft[property] = bindResult.result;
3959
- if (bindResult.errors) {
3960
- errors.push(
3961
- ...bindResult.errors.map((e) => {
3962
- if (typeof e === "string") {
3963
- return `${currentObjectPath}: ${e}`;
3964
- }
3965
- e.message = `${currentObjectPath}: ${e.message}`;
3966
- return e;
3967
- })
3968
- );
3969
- }
3970
- }
3966
+ Object.entries(value).forEach(([property, oldValue]) => {
3967
+ const currentObjectPath = recursivePath ? `${recursivePath}.${property}` : property;
3968
+ if (typeof oldValue === "string") {
3969
+ if (!oldValue.includes(variablePrefix)) {
3971
3970
  return;
3972
3971
  }
3973
- const childBind = bindVariablesToObjectRecursive({
3974
- ...bindVariablesOptions,
3975
- value: oldValue,
3976
- recursivePath: currentObjectPath
3977
- });
3978
- if (childBind.boundCount || childBind.errors) {
3979
- boundCount += childBind.boundCount;
3980
- draft[property] = childBind.result;
3981
- if (childBind.errors) {
3982
- errors.push(...childBind.errors);
3972
+ const bindResult = bindVariables({ ...bindVariablesOptions, value: oldValue });
3973
+ if (oldValue !== bindResult.result || bindResult.errors) {
3974
+ boundCount += bindResult.boundCount;
3975
+ assign(property, bindResult.result);
3976
+ if (bindResult.errors) {
3977
+ errors.push(
3978
+ ...bindResult.errors.map((e) => {
3979
+ if (typeof e === "string") {
3980
+ return `${currentObjectPath}: ${e}`;
3981
+ }
3982
+ e.message = `${currentObjectPath}: ${e.message}`;
3983
+ return e;
3984
+ })
3985
+ );
3983
3986
  }
3984
3987
  }
3988
+ return;
3989
+ }
3990
+ const childBind = bindVariablesToObjectRecursive({
3991
+ ...bindVariablesOptions,
3992
+ value: oldValue,
3993
+ recursivePath: currentObjectPath,
3994
+ bindableObjects
3985
3995
  });
3996
+ if (childBind.boundCount || childBind.errors) {
3997
+ boundCount += childBind.boundCount;
3998
+ assign(property, childBind.result);
3999
+ if (childBind.errors) {
4000
+ errors.push(...childBind.errors);
4001
+ }
4002
+ }
3986
4003
  });
4004
+ const result = copy != null ? copy : value;
3987
4005
  return { boundCount, result, errors: errors.length > 0 ? errors : void 0 };
3988
4006
  }
4007
+ function findBindableObjects(root) {
4008
+ const bindable = /* @__PURE__ */ new Set();
4009
+ const visit = (value) => {
4010
+ if (typeof value === "string") {
4011
+ return value.includes(variablePrefix);
4012
+ }
4013
+ if (typeof value !== "object" || value === null) {
4014
+ return false;
4015
+ }
4016
+ if (bindable.has(value)) {
4017
+ return true;
4018
+ }
4019
+ let found = isRichTextVariableNode(value);
4020
+ if (!found) {
4021
+ if (Array.isArray(value)) {
4022
+ for (let i = 0; i < value.length; i++) {
4023
+ found = visit(value[i]) || found;
4024
+ }
4025
+ } else {
4026
+ const keys = Object.keys(value);
4027
+ for (let i = 0; i < keys.length; i++) {
4028
+ found = visit(value[keys[i]]) || found;
4029
+ }
4030
+ }
4031
+ }
4032
+ if (found) {
4033
+ bindable.add(value);
4034
+ }
4035
+ return found;
4036
+ };
4037
+ visit(root);
4038
+ return bindable;
4039
+ }
4040
+ function isRichTextVariableNode(object) {
4041
+ return "type" in object && object.type === "variable" && "reference" in object && typeof object.reference === "string" && "version" in object && object.version === 1;
4042
+ }
3989
4043
  function handleRichTextNodeBinding(object, options) {
3990
- if ("type" in object && object.type === "variable" && "reference" in object && typeof object.reference === "string" && "version" in object && object.version === 1) {
4044
+ if (isRichTextVariableNode(object)) {
3991
4045
  const value = createVariableReference(object.reference);
3992
4046
  const bindResult = bindVariables({ ...options, value });
3993
4047
  const bindResultAsTextNode = {
@@ -4008,7 +4062,7 @@ function handleRichTextNodeBinding(object, options) {
4008
4062
  import { ApiClientError as ApiClientError5 } from "@uniformdev/context/api";
4009
4063
 
4010
4064
  // src/.version.ts
4011
- var version = "20.80.1";
4065
+ var version = "20.81.0";
4012
4066
 
4013
4067
  // src/WorkflowClient.ts
4014
4068
  import { ApiClient as ApiClient18 } from "@uniformdev/context/api";
package/dist/index.js CHANGED
@@ -1476,10 +1476,12 @@ function flattenSingleNodeValues(data, options = {}) {
1476
1476
  ) : properties;
1477
1477
  }
1478
1478
 
1479
- // src/utils/variables/parseVariableExpression.ts
1480
- var escapeCharacter = "\\";
1479
+ // src/utils/variables/variableSyntax.ts
1481
1480
  var variablePrefix = "${";
1482
1481
  var variableSuffix = "}";
1482
+
1483
+ // src/utils/variables/parseVariableExpression.ts
1484
+ var escapeCharacter = "\\";
1483
1485
  function parseVariableExpression(serialized, onToken) {
1484
1486
  if (typeof serialized !== "string") {
1485
1487
  throw new TypeError("Variable expression must be a string");
@@ -2478,7 +2480,11 @@ function evaluateWalkTreePropertyCriteria({
2478
2480
  delete properties[propertyName];
2479
2481
  }
2480
2482
  } else {
2481
- const { currentValue, remainingConditionalValues } = evaluatePropertyCriteria({
2483
+ const { currentValue, remainingConditionalValues } = property.conditions === void 0 ? (
2484
+ // most properties have no conditions: this is what evaluatePropertyCriteria returns for them,
2485
+ // without the cost of calling it for every property
2486
+ { currentValue: property.value, remainingConditionalValues: void 0 }
2487
+ ) : evaluatePropertyCriteria({
2482
2488
  baseValue: property.value,
2483
2489
  conditionalValues: property.conditions,
2484
2490
  rules,
@@ -4108,6 +4114,9 @@ function bindVariables({
4108
4114
  errorPrefix = "Variable",
4109
4115
  handleBinding
4110
4116
  }) {
4117
+ if (!value.includes(variablePrefix)) {
4118
+ return { result: value, boundCount: 0, errors: void 0 };
4119
+ }
4111
4120
  let boundCount = 0;
4112
4121
  let tokenCount = 0;
4113
4122
  const errors = [];
@@ -4138,13 +4147,15 @@ function bindVariables({
4138
4147
  }
4139
4148
 
4140
4149
  // src/utils/variables/bindVariablesToObject.ts
4141
- var import_immer = require("immer");
4142
4150
  function bindVariablesToObject(options) {
4143
- return bindVariablesToObjectRecursive(options);
4151
+ const { value } = options;
4152
+ const bindableObjects = typeof value === "object" && value !== null ? findBindableObjects(value) : void 0;
4153
+ return bindVariablesToObjectRecursive({ ...options, bindableObjects });
4144
4154
  }
4145
4155
  function bindVariablesToObjectRecursive({
4146
4156
  value,
4147
4157
  recursivePath,
4158
+ bindableObjects,
4148
4159
  ...bindVariablesOptions
4149
4160
  }) {
4150
4161
  let boundCount = 0;
@@ -4159,50 +4170,93 @@ function bindVariablesToObjectRecursive({
4159
4170
  if (richTextNodeResult !== void 0) {
4160
4171
  return richTextNodeResult;
4161
4172
  }
4162
- const produceToUse = !(0, import_immer.isDraft)(value) ? import_immer.produce : (produceValue, producer) => {
4163
- producer(produceValue);
4164
- return produceValue;
4173
+ if (bindableObjects && !bindableObjects.has(value)) {
4174
+ return { boundCount: 0, result: value };
4175
+ }
4176
+ let copy;
4177
+ const assign = (property, boundValue) => {
4178
+ copy != null ? copy : copy = Array.isArray(value) ? value.slice() : Object.assign(Object.create(Object.getPrototypeOf(value)), value);
4179
+ copy[property] = boundValue;
4165
4180
  };
4166
- const result = produceToUse(value, (draft) => {
4167
- Object.entries(draft).forEach(([property, oldValue]) => {
4168
- const currentObjectPath = recursivePath ? `${recursivePath}.${property}` : property;
4169
- if (typeof oldValue === "string") {
4170
- const bindResult = bindVariables({ ...bindVariablesOptions, value: oldValue });
4171
- if (oldValue !== bindResult.result || bindResult.errors) {
4172
- boundCount += bindResult.boundCount;
4173
- draft[property] = bindResult.result;
4174
- if (bindResult.errors) {
4175
- errors.push(
4176
- ...bindResult.errors.map((e) => {
4177
- if (typeof e === "string") {
4178
- return `${currentObjectPath}: ${e}`;
4179
- }
4180
- e.message = `${currentObjectPath}: ${e.message}`;
4181
- return e;
4182
- })
4183
- );
4184
- }
4185
- }
4181
+ Object.entries(value).forEach(([property, oldValue]) => {
4182
+ const currentObjectPath = recursivePath ? `${recursivePath}.${property}` : property;
4183
+ if (typeof oldValue === "string") {
4184
+ if (!oldValue.includes(variablePrefix)) {
4186
4185
  return;
4187
4186
  }
4188
- const childBind = bindVariablesToObjectRecursive({
4189
- ...bindVariablesOptions,
4190
- value: oldValue,
4191
- recursivePath: currentObjectPath
4192
- });
4193
- if (childBind.boundCount || childBind.errors) {
4194
- boundCount += childBind.boundCount;
4195
- draft[property] = childBind.result;
4196
- if (childBind.errors) {
4197
- errors.push(...childBind.errors);
4187
+ const bindResult = bindVariables({ ...bindVariablesOptions, value: oldValue });
4188
+ if (oldValue !== bindResult.result || bindResult.errors) {
4189
+ boundCount += bindResult.boundCount;
4190
+ assign(property, bindResult.result);
4191
+ if (bindResult.errors) {
4192
+ errors.push(
4193
+ ...bindResult.errors.map((e) => {
4194
+ if (typeof e === "string") {
4195
+ return `${currentObjectPath}: ${e}`;
4196
+ }
4197
+ e.message = `${currentObjectPath}: ${e.message}`;
4198
+ return e;
4199
+ })
4200
+ );
4198
4201
  }
4199
4202
  }
4203
+ return;
4204
+ }
4205
+ const childBind = bindVariablesToObjectRecursive({
4206
+ ...bindVariablesOptions,
4207
+ value: oldValue,
4208
+ recursivePath: currentObjectPath,
4209
+ bindableObjects
4200
4210
  });
4211
+ if (childBind.boundCount || childBind.errors) {
4212
+ boundCount += childBind.boundCount;
4213
+ assign(property, childBind.result);
4214
+ if (childBind.errors) {
4215
+ errors.push(...childBind.errors);
4216
+ }
4217
+ }
4201
4218
  });
4219
+ const result = copy != null ? copy : value;
4202
4220
  return { boundCount, result, errors: errors.length > 0 ? errors : void 0 };
4203
4221
  }
4222
+ function findBindableObjects(root) {
4223
+ const bindable = /* @__PURE__ */ new Set();
4224
+ const visit = (value) => {
4225
+ if (typeof value === "string") {
4226
+ return value.includes(variablePrefix);
4227
+ }
4228
+ if (typeof value !== "object" || value === null) {
4229
+ return false;
4230
+ }
4231
+ if (bindable.has(value)) {
4232
+ return true;
4233
+ }
4234
+ let found = isRichTextVariableNode(value);
4235
+ if (!found) {
4236
+ if (Array.isArray(value)) {
4237
+ for (let i = 0; i < value.length; i++) {
4238
+ found = visit(value[i]) || found;
4239
+ }
4240
+ } else {
4241
+ const keys = Object.keys(value);
4242
+ for (let i = 0; i < keys.length; i++) {
4243
+ found = visit(value[keys[i]]) || found;
4244
+ }
4245
+ }
4246
+ }
4247
+ if (found) {
4248
+ bindable.add(value);
4249
+ }
4250
+ return found;
4251
+ };
4252
+ visit(root);
4253
+ return bindable;
4254
+ }
4255
+ function isRichTextVariableNode(object) {
4256
+ return "type" in object && object.type === "variable" && "reference" in object && typeof object.reference === "string" && "version" in object && object.version === 1;
4257
+ }
4204
4258
  function handleRichTextNodeBinding(object, options) {
4205
- if ("type" in object && object.type === "variable" && "reference" in object && typeof object.reference === "string" && "version" in object && object.version === 1) {
4259
+ if (isRichTextVariableNode(object)) {
4206
4260
  const value = createVariableReference(object.reference);
4207
4261
  const bindResult = bindVariables({ ...options, value });
4208
4262
  const bindResultAsTextNode = {
@@ -4223,7 +4277,7 @@ function handleRichTextNodeBinding(object, options) {
4223
4277
  var import_api27 = require("@uniformdev/context/api");
4224
4278
 
4225
4279
  // src/.version.ts
4226
- var version = "20.80.1";
4280
+ var version = "20.81.0";
4227
4281
 
4228
4282
  // src/WorkflowClient.ts
4229
4283
  var import_api26 = require("@uniformdev/context/api");
package/dist/index.mjs CHANGED
@@ -1261,10 +1261,12 @@ function flattenSingleNodeValues(data, options = {}) {
1261
1261
  ) : properties;
1262
1262
  }
1263
1263
 
1264
- // src/utils/variables/parseVariableExpression.ts
1265
- var escapeCharacter = "\\";
1264
+ // src/utils/variables/variableSyntax.ts
1266
1265
  var variablePrefix = "${";
1267
1266
  var variableSuffix = "}";
1267
+
1268
+ // src/utils/variables/parseVariableExpression.ts
1269
+ var escapeCharacter = "\\";
1268
1270
  function parseVariableExpression(serialized, onToken) {
1269
1271
  if (typeof serialized !== "string") {
1270
1272
  throw new TypeError("Variable expression must be a string");
@@ -2263,7 +2265,11 @@ function evaluateWalkTreePropertyCriteria({
2263
2265
  delete properties[propertyName];
2264
2266
  }
2265
2267
  } else {
2266
- const { currentValue, remainingConditionalValues } = evaluatePropertyCriteria({
2268
+ const { currentValue, remainingConditionalValues } = property.conditions === void 0 ? (
2269
+ // most properties have no conditions: this is what evaluatePropertyCriteria returns for them,
2270
+ // without the cost of calling it for every property
2271
+ { currentValue: property.value, remainingConditionalValues: void 0 }
2272
+ ) : evaluatePropertyCriteria({
2267
2273
  baseValue: property.value,
2268
2274
  conditionalValues: property.conditions,
2269
2275
  rules,
@@ -3893,6 +3899,9 @@ function bindVariables({
3893
3899
  errorPrefix = "Variable",
3894
3900
  handleBinding
3895
3901
  }) {
3902
+ if (!value.includes(variablePrefix)) {
3903
+ return { result: value, boundCount: 0, errors: void 0 };
3904
+ }
3896
3905
  let boundCount = 0;
3897
3906
  let tokenCount = 0;
3898
3907
  const errors = [];
@@ -3923,13 +3932,15 @@ function bindVariables({
3923
3932
  }
3924
3933
 
3925
3934
  // src/utils/variables/bindVariablesToObject.ts
3926
- import { isDraft, produce } from "immer";
3927
3935
  function bindVariablesToObject(options) {
3928
- return bindVariablesToObjectRecursive(options);
3936
+ const { value } = options;
3937
+ const bindableObjects = typeof value === "object" && value !== null ? findBindableObjects(value) : void 0;
3938
+ return bindVariablesToObjectRecursive({ ...options, bindableObjects });
3929
3939
  }
3930
3940
  function bindVariablesToObjectRecursive({
3931
3941
  value,
3932
3942
  recursivePath,
3943
+ bindableObjects,
3933
3944
  ...bindVariablesOptions
3934
3945
  }) {
3935
3946
  let boundCount = 0;
@@ -3944,50 +3955,93 @@ function bindVariablesToObjectRecursive({
3944
3955
  if (richTextNodeResult !== void 0) {
3945
3956
  return richTextNodeResult;
3946
3957
  }
3947
- const produceToUse = !isDraft(value) ? produce : (produceValue, producer) => {
3948
- producer(produceValue);
3949
- return produceValue;
3958
+ if (bindableObjects && !bindableObjects.has(value)) {
3959
+ return { boundCount: 0, result: value };
3960
+ }
3961
+ let copy;
3962
+ const assign = (property, boundValue) => {
3963
+ copy != null ? copy : copy = Array.isArray(value) ? value.slice() : Object.assign(Object.create(Object.getPrototypeOf(value)), value);
3964
+ copy[property] = boundValue;
3950
3965
  };
3951
- const result = produceToUse(value, (draft) => {
3952
- Object.entries(draft).forEach(([property, oldValue]) => {
3953
- const currentObjectPath = recursivePath ? `${recursivePath}.${property}` : property;
3954
- if (typeof oldValue === "string") {
3955
- const bindResult = bindVariables({ ...bindVariablesOptions, value: oldValue });
3956
- if (oldValue !== bindResult.result || bindResult.errors) {
3957
- boundCount += bindResult.boundCount;
3958
- draft[property] = bindResult.result;
3959
- if (bindResult.errors) {
3960
- errors.push(
3961
- ...bindResult.errors.map((e) => {
3962
- if (typeof e === "string") {
3963
- return `${currentObjectPath}: ${e}`;
3964
- }
3965
- e.message = `${currentObjectPath}: ${e.message}`;
3966
- return e;
3967
- })
3968
- );
3969
- }
3970
- }
3966
+ Object.entries(value).forEach(([property, oldValue]) => {
3967
+ const currentObjectPath = recursivePath ? `${recursivePath}.${property}` : property;
3968
+ if (typeof oldValue === "string") {
3969
+ if (!oldValue.includes(variablePrefix)) {
3971
3970
  return;
3972
3971
  }
3973
- const childBind = bindVariablesToObjectRecursive({
3974
- ...bindVariablesOptions,
3975
- value: oldValue,
3976
- recursivePath: currentObjectPath
3977
- });
3978
- if (childBind.boundCount || childBind.errors) {
3979
- boundCount += childBind.boundCount;
3980
- draft[property] = childBind.result;
3981
- if (childBind.errors) {
3982
- errors.push(...childBind.errors);
3972
+ const bindResult = bindVariables({ ...bindVariablesOptions, value: oldValue });
3973
+ if (oldValue !== bindResult.result || bindResult.errors) {
3974
+ boundCount += bindResult.boundCount;
3975
+ assign(property, bindResult.result);
3976
+ if (bindResult.errors) {
3977
+ errors.push(
3978
+ ...bindResult.errors.map((e) => {
3979
+ if (typeof e === "string") {
3980
+ return `${currentObjectPath}: ${e}`;
3981
+ }
3982
+ e.message = `${currentObjectPath}: ${e.message}`;
3983
+ return e;
3984
+ })
3985
+ );
3983
3986
  }
3984
3987
  }
3988
+ return;
3989
+ }
3990
+ const childBind = bindVariablesToObjectRecursive({
3991
+ ...bindVariablesOptions,
3992
+ value: oldValue,
3993
+ recursivePath: currentObjectPath,
3994
+ bindableObjects
3985
3995
  });
3996
+ if (childBind.boundCount || childBind.errors) {
3997
+ boundCount += childBind.boundCount;
3998
+ assign(property, childBind.result);
3999
+ if (childBind.errors) {
4000
+ errors.push(...childBind.errors);
4001
+ }
4002
+ }
3986
4003
  });
4004
+ const result = copy != null ? copy : value;
3987
4005
  return { boundCount, result, errors: errors.length > 0 ? errors : void 0 };
3988
4006
  }
4007
+ function findBindableObjects(root) {
4008
+ const bindable = /* @__PURE__ */ new Set();
4009
+ const visit = (value) => {
4010
+ if (typeof value === "string") {
4011
+ return value.includes(variablePrefix);
4012
+ }
4013
+ if (typeof value !== "object" || value === null) {
4014
+ return false;
4015
+ }
4016
+ if (bindable.has(value)) {
4017
+ return true;
4018
+ }
4019
+ let found = isRichTextVariableNode(value);
4020
+ if (!found) {
4021
+ if (Array.isArray(value)) {
4022
+ for (let i = 0; i < value.length; i++) {
4023
+ found = visit(value[i]) || found;
4024
+ }
4025
+ } else {
4026
+ const keys = Object.keys(value);
4027
+ for (let i = 0; i < keys.length; i++) {
4028
+ found = visit(value[keys[i]]) || found;
4029
+ }
4030
+ }
4031
+ }
4032
+ if (found) {
4033
+ bindable.add(value);
4034
+ }
4035
+ return found;
4036
+ };
4037
+ visit(root);
4038
+ return bindable;
4039
+ }
4040
+ function isRichTextVariableNode(object) {
4041
+ return "type" in object && object.type === "variable" && "reference" in object && typeof object.reference === "string" && "version" in object && object.version === 1;
4042
+ }
3989
4043
  function handleRichTextNodeBinding(object, options) {
3990
- if ("type" in object && object.type === "variable" && "reference" in object && typeof object.reference === "string" && "version" in object && object.version === 1) {
4044
+ if (isRichTextVariableNode(object)) {
3991
4045
  const value = createVariableReference(object.reference);
3992
4046
  const bindResult = bindVariables({ ...options, value });
3993
4047
  const bindResultAsTextNode = {
@@ -4008,7 +4062,7 @@ function handleRichTextNodeBinding(object, options) {
4008
4062
  import { ApiClientError as ApiClientError5 } from "@uniformdev/context/api";
4009
4063
 
4010
4064
  // src/.version.ts
4011
- var version = "20.80.1";
4065
+ var version = "20.81.0";
4012
4066
 
4013
4067
  // src/WorkflowClient.ts
4014
4068
  import { ApiClient as ApiClient18 } from "@uniformdev/context/api";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas",
3
- "version": "20.80.1",
3
+ "version": "20.80.2-alpha.14.sha-1c81418f05",
4
4
  "description": "Common functionality and types for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -36,9 +36,9 @@
36
36
  "svix": "1.96.0"
37
37
  },
38
38
  "dependencies": {
39
- "@uniformdev/assets": "20.80.1",
40
- "@uniformdev/context": "20.80.1",
41
- "@uniformdev/richtext": "20.80.1",
39
+ "@uniformdev/assets": "20.80.2-alpha.14.sha-1c81418f05",
40
+ "@uniformdev/context": "20.80.2-alpha.14.sha-1c81418f05",
41
+ "@uniformdev/richtext": "20.80.2-alpha.14.sha-1c81418f05",
42
42
  "immer": "10.2.0",
43
43
  "p-limit": "6.2.0",
44
44
  "p-retry": "6.2.1",
@@ -50,5 +50,5 @@
50
50
  "publishConfig": {
51
51
  "access": "public"
52
52
  },
53
- "gitHead": "0a5bcf5305aba6240860bccc568afbdc9790d68c"
53
+ "gitHead": "1c81418f0511232cde31935227eaec24af063252"
54
54
  }