@uniformdev/canvas 19.61.1 → 19.62.1-alpha.127

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.js CHANGED
@@ -45,7 +45,7 @@ var __privateAdd = (obj, member, value) => {
45
45
 
46
46
  // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js
47
47
  var require_retry_operation = __commonJS({
48
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports, module2) {
48
+ "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports2, module2) {
49
49
  "use strict";
50
50
  function RetryOperation(timeouts, options) {
51
51
  if (typeof options === "boolean") {
@@ -181,18 +181,18 @@ var require_retry_operation = __commonJS({
181
181
 
182
182
  // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js
183
183
  var require_retry = __commonJS({
184
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports) {
184
+ "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports2) {
185
185
  "use strict";
186
186
  var RetryOperation = require_retry_operation();
187
- exports.operation = function(options) {
188
- var timeouts = exports.timeouts(options);
187
+ exports2.operation = function(options) {
188
+ var timeouts = exports2.timeouts(options);
189
189
  return new RetryOperation(timeouts, {
190
190
  forever: options && (options.forever || options.retries === Infinity),
191
191
  unref: options && options.unref,
192
192
  maxRetryTime: options && options.maxRetryTime
193
193
  });
194
194
  };
195
- exports.timeouts = function(options) {
195
+ exports2.timeouts = function(options) {
196
196
  if (options instanceof Array) {
197
197
  return [].concat(options);
198
198
  }
@@ -221,13 +221,13 @@ var require_retry = __commonJS({
221
221
  });
222
222
  return timeouts;
223
223
  };
224
- exports.createTimeout = function(attempt, opts) {
224
+ exports2.createTimeout = function(attempt, opts) {
225
225
  var random = opts.randomize ? Math.random() + 1 : 1;
226
226
  var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
227
227
  timeout = Math.min(timeout, opts.maxTimeout);
228
228
  return timeout;
229
229
  };
230
- exports.wrap = function(obj, options, methods) {
230
+ exports2.wrap = function(obj, options, methods) {
231
231
  if (options instanceof Array) {
232
232
  methods = options;
233
233
  options = null;
@@ -244,7 +244,7 @@ var require_retry = __commonJS({
244
244
  var method = methods[i];
245
245
  var original = obj[method];
246
246
  obj[method] = function retryWrapper(original2) {
247
- var op = exports.operation(options);
247
+ var op = exports2.operation(options);
248
248
  var args = Array.prototype.slice.call(arguments, 1);
249
249
  var callback = args.pop();
250
250
  args.push(function(err) {
@@ -268,7 +268,7 @@ var require_retry = __commonJS({
268
268
 
269
269
  // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js
270
270
  var require_retry2 = __commonJS({
271
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports, module2) {
271
+ "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports2, module2) {
272
272
  "use strict";
273
273
  module2.exports = require_retry();
274
274
  }
@@ -277,13 +277,16 @@ var require_retry2 = __commonJS({
277
277
  // src/index.ts
278
278
  var src_exports = {};
279
279
  __export(src_exports, {
280
+ ASSETS_SOURCE_CUSTOM_URL: () => ASSETS_SOURCE_CUSTOM_URL,
281
+ ASSETS_SOURCE_UNIFORM: () => ASSETS_SOURCE_UNIFORM,
282
+ ASSET_PARAMETER_TYPE: () => ASSET_PARAMETER_TYPE,
280
283
  ATTRIBUTE_COMPONENT_ID: () => ATTRIBUTE_COMPONENT_ID,
281
284
  ATTRIBUTE_MULTILINE: () => ATTRIBUTE_MULTILINE,
282
285
  ATTRIBUTE_PARAMETER_ID: () => ATTRIBUTE_PARAMETER_ID,
283
286
  ATTRIBUTE_PARAMETER_TYPE: () => ATTRIBUTE_PARAMETER_TYPE,
284
287
  ATTRIBUTE_PARAMETER_VALUE: () => ATTRIBUTE_PARAMETER_VALUE,
285
288
  ATTRIBUTE_PLACEHOLDER: () => ATTRIBUTE_PLACEHOLDER,
286
- ApiClientError: () => import_api9.ApiClientError,
289
+ ApiClientError: () => import_api13.ApiClientError,
287
290
  BatchEntry: () => BatchEntry,
288
291
  CANVAS_BLOCK_PARAM_TYPE: () => CANVAS_BLOCK_PARAM_TYPE,
289
292
  CANVAS_DRAFT_STATE: () => CANVAS_DRAFT_STATE,
@@ -297,6 +300,8 @@ __export(src_exports, {
297
300
  CANVAS_PERSONALIZE_SLOT: () => CANVAS_PERSONALIZE_SLOT,
298
301
  CANVAS_PERSONALIZE_TYPE: () => CANVAS_PERSONALIZE_TYPE,
299
302
  CANVAS_PUBLISHED_STATE: () => CANVAS_PUBLISHED_STATE,
303
+ CANVAS_SLOT_SECTION_SLOT: () => CANVAS_SLOT_SECTION_SLOT,
304
+ CANVAS_SLOT_SECTION_TYPE: () => CANVAS_SLOT_SECTION_TYPE,
300
305
  CANVAS_TEST_SLOT: () => CANVAS_TEST_SLOT,
301
306
  CANVAS_TEST_TYPE: () => CANVAS_TEST_TYPE,
302
307
  CANVAS_TEST_VARIANT_PARAM: () => CANVAS_TEST_VARIANT_PARAM,
@@ -309,21 +314,25 @@ __export(src_exports, {
309
314
  DataTypeClient: () => DataTypeClient,
310
315
  EDGE_CACHE_DISABLED: () => EDGE_CACHE_DISABLED,
311
316
  EDGE_DEFAULT_CACHE_TTL: () => EDGE_DEFAULT_CACHE_TTL,
312
- EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS: () => EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS,
313
317
  EDGE_MAX_CACHE_TTL: () => EDGE_MAX_CACHE_TTL,
314
- EDGE_MAX_L2_CACHE_TTL_IN_HOURS: () => EDGE_MAX_L2_CACHE_TTL_IN_HOURS,
315
318
  EDGE_MIN_CACHE_TTL: () => EDGE_MIN_CACHE_TTL,
316
- EDGE_MIN_L2_CACHE_TTL_IN_HOURS: () => EDGE_MIN_L2_CACHE_TTL_IN_HOURS,
317
319
  EMPTY_COMPOSITION: () => EMPTY_COMPOSITION,
318
320
  EnhancerBuilder: () => EnhancerBuilder,
319
321
  IN_CONTEXT_EDITOR_COMPONENT_END_ROLE: () => IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
320
322
  IN_CONTEXT_EDITOR_COMPONENT_START_ROLE: () => IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
321
323
  IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM: () => IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM,
322
324
  IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID: () => IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID,
325
+ IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM: () => IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM,
323
326
  IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM: () => IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM,
324
327
  IN_CONTEXT_EDITOR_QUERY_STRING_PARAM: () => IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
325
328
  IS_RENDERED_BY_UNIFORM_ATTRIBUTE: () => IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
329
+ LOCALE_DYNAMIC_INPUT_NAME: () => LOCALE_DYNAMIC_INPUT_NAME,
330
+ LocaleClient: () => LocaleClient,
326
331
  PLACEHOLDER_ID: () => PLACEHOLDER_ID,
332
+ PromptClient: () => PromptClient,
333
+ RelationshipClient: () => RelationshipClient,
334
+ ReleaseClient: () => ReleaseClient,
335
+ ReleaseContentsClient: () => ReleaseContentsClient,
327
336
  RouteClient: () => RouteClient,
328
337
  SECRET_QUERY_STRING_PARAM: () => SECRET_QUERY_STRING_PARAM,
329
338
  UncachedCanvasClient: () => UncachedCanvasClient,
@@ -342,25 +351,38 @@ __export(src_exports, {
342
351
  createVariableReference: () => createVariableReference,
343
352
  enhance: () => enhance,
344
353
  extractLocales: () => extractLocales,
354
+ findParameterInNodeTree: () => findParameterInNodeTree,
355
+ flattenValues: () => flattenValues,
345
356
  generateComponentPlaceholderId: () => generateComponentPlaceholderId,
346
357
  generateHash: () => generateHash,
347
358
  getBlockValue: () => getBlockValue,
348
359
  getChannelName: () => getChannelName,
349
360
  getComponentJsonPointer: () => getComponentJsonPointer,
350
361
  getComponentPath: () => getComponentPath,
362
+ getLocalizedPropertyValues: () => getLocalizedPropertyValues,
363
+ getNounForLocation: () => getNounForLocation,
364
+ getNounForNode: () => getNounForNode,
351
365
  getParameterAttributes: () => getParameterAttributes,
352
366
  getPropertiesValue: () => getPropertiesValue,
367
+ getPropertyValue: () => getPropertyValue,
353
368
  isAddComponentMessage: () => isAddComponentMessage,
354
369
  isAllowedReferrer: () => isAllowedReferrer,
370
+ isAssetParamValue: () => isAssetParamValue,
371
+ isAssetParamValueItem: () => isAssetParamValueItem,
355
372
  isComponentActionMessage: () => isComponentActionMessage,
356
373
  isComponentPlaceholderId: () => isComponentPlaceholderId,
357
374
  isDismissPlaceholderMessage: () => isDismissPlaceholderMessage,
375
+ isEntryData: () => isEntryData,
358
376
  isMovingComponentMessage: () => isMovingComponentMessage,
377
+ isNestedNodeType: () => isNestedNodeType,
359
378
  isOpenParameterEditorMessage: () => isOpenParameterEditorMessage,
360
379
  isReadyMessage: () => isReadyMessage,
361
380
  isReportRenderedCompositionsMessage: () => isReportRenderedCompositionsMessage,
381
+ isRequestComponentSuggestionMessage: () => isRequestComponentSuggestionMessage,
382
+ isRootEntryReference: () => isRootEntryReference,
362
383
  isSelectComponentMessage: () => isSelectComponentMessage,
363
384
  isSelectParameterMessage: () => isSelectParameterMessage,
385
+ isSuggestComponentMessage: () => isSuggestComponentMessage,
364
386
  isSystemComponentDefinition: () => isSystemComponentDefinition,
365
387
  isTriggerCompositionActionMessage: () => isTriggerCompositionActionMessage,
366
388
  isUpdateComponentParameterMessage: () => isUpdateComponentParameterMessage,
@@ -374,9 +396,9 @@ __export(src_exports, {
374
396
  mapSlotToPersonalizedVariations: () => mapSlotToPersonalizedVariations,
375
397
  mapSlotToTestVariations: () => mapSlotToTestVariations,
376
398
  nullLimitPolicy: () => nullLimitPolicy,
399
+ parseComponentPlaceholderId: () => parseComponentPlaceholderId,
377
400
  parseVariableExpression: () => parseVariableExpression,
378
401
  subscribeToComposition: () => subscribeToComposition,
379
- unstable_CompositionRelationshipClient: () => unstable_CompositionRelationshipClient,
380
402
  walkComponentTree: () => walkComponentTree,
381
403
  walkNodeTree: () => walkNodeTree
382
404
  });
@@ -590,12 +612,30 @@ var CanvasClient = class extends import_api2.ApiClient {
590
612
  }
591
613
  super(options);
592
614
  this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
615
+ this.edgeApiRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
593
616
  }
594
617
  /** Fetches lists of Canvas compositions, optionally by type */
595
- async getCompositionList(options) {
618
+ async getCompositionList(params = {}) {
596
619
  const { projectId } = this.options;
597
- const fetchUri = this.createUrl(CANVAS_URL, { ...options, projectId });
598
- return await this.apiClient(fetchUri);
620
+ const { resolveData, filters, ...originParams } = params;
621
+ const rewrittenFilters = Object.entries(filters != null ? filters : {}).reduce((acc, [key, value]) => {
622
+ const lhs = `filters.${key}` + (typeof value === "object" ? `[${Object.keys(value)[0]}]` : "");
623
+ let rhs = typeof value === "object" ? Object.values(value)[0] : value;
624
+ rhs = Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim();
625
+ return { ...acc, [lhs]: rhs };
626
+ }, {});
627
+ if (!resolveData) {
628
+ const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
629
+ return this.apiClient(fetchUri);
630
+ }
631
+ const edgeParams = {
632
+ ...originParams,
633
+ projectId,
634
+ ...params.diagnostics ? { diagnostics: "true" } : {},
635
+ ...rewrittenFilters
636
+ };
637
+ const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
638
+ return this.apiClient(edgeUrl, this.edgeApiRequestInit);
599
639
  }
600
640
  getCompositionByNodePath(options) {
601
641
  return this.getOneComposition(options);
@@ -613,12 +653,12 @@ var CanvasClient = class extends import_api2.ApiClient {
613
653
  return this.getOneComposition(options);
614
654
  }
615
655
  /** Fetches historical versions of a composition or pattern */
616
- async unstable_getCompositionHistory(options) {
617
- const edgeUrl = this.createUrl("/api/v1/canvas-history", {
656
+ async getCompositionHistory(options) {
657
+ const historyUrl = this.createUrl("/api/v1/canvas-history", {
618
658
  ...options,
619
659
  projectId: this.options.projectId
620
660
  });
621
- return this.apiClient(edgeUrl);
661
+ return this.apiClient(historyUrl);
622
662
  }
623
663
  getOneComposition({
624
664
  skipDataResolution,
@@ -635,7 +675,7 @@ var CanvasClient = class extends import_api2.ApiClient {
635
675
  ...diagnostics ? { diagnostics: "true" } : {}
636
676
  };
637
677
  const edgeUrl = this.createUrl("/api/v1/composition", edgeParams, this.edgeApiHost);
638
- return this.apiClient(edgeUrl);
678
+ return this.apiClient(edgeUrl, this.edgeApiRequestInit);
639
679
  }
640
680
  /** Updates or creates a Canvas component definition */
641
681
  async updateComposition(body) {
@@ -660,7 +700,7 @@ var CanvasClient = class extends import_api2.ApiClient {
660
700
  async getComponentDefinitions(options) {
661
701
  const { projectId } = this.options;
662
702
  const fetchUri = this.createUrl("/api/v1/canvas-definitions", { ...options, projectId });
663
- return await this.apiClient(fetchUri);
703
+ return this.apiClient(fetchUri);
664
704
  }
665
705
  /** Updates or creates a Canvas component definition */
666
706
  async updateComponentDefinition(body) {
@@ -730,73 +770,10 @@ var UncachedCategoryClient = class extends CategoryClient {
730
770
  }
731
771
  };
732
772
 
733
- // src/CompositionRelationshipClient.ts
734
- var import_api4 = require("@uniformdev/context/api");
735
- var COMPOSITION_RELATIONSHIP_URL = "/api/v1/composition-relationships";
736
- var unstable_CompositionRelationshipClient = class extends import_api4.ApiClient {
737
- constructor(options) {
738
- super(options);
739
- this.getDefinitionsRelationships = async ({
740
- definitionIds,
741
- withCompositions
742
- }) => {
743
- const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL, {
744
- type: "definition",
745
- projectId: this._options.projectId,
746
- definitionIds: definitionIds.join(","),
747
- withCompositions
748
- });
749
- return this.apiClient(url);
750
- };
751
- this.clearAllRelationships = async () => {
752
- const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL);
753
- return this.apiClient(url, {
754
- method: "POST",
755
- body: JSON.stringify({
756
- type: "clear",
757
- projectId: this._options.projectId
758
- })
759
- });
760
- };
761
- this.indexCompositionRelationships = async ({
762
- state,
763
- compositionId
764
- }) => {
765
- const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL);
766
- return this.apiClient(url, {
767
- method: "POST",
768
- body: JSON.stringify({
769
- type: "index",
770
- projectId: this._options.projectId,
771
- state,
772
- compositionId
773
- })
774
- });
775
- };
776
- this.getVersion = async () => {
777
- const url = this.createUrl("/api/v1/usage-tracking", {
778
- projectId: this._options.projectId
779
- });
780
- return this.apiClient(url).then((response) => response.version);
781
- };
782
- this.setVersion = async (version) => {
783
- const url = this.createUrl("/api/v1/usage-tracking");
784
- return this.apiClient(url, {
785
- method: "POST",
786
- body: JSON.stringify({
787
- projectId: this._options.projectId,
788
- version
789
- })
790
- });
791
- };
792
- this._options = options;
793
- }
794
- };
795
-
796
773
  // src/ContentClient.ts
797
- var import_api5 = require("@uniformdev/context/api");
774
+ var import_api4 = require("@uniformdev/context/api");
798
775
  var _contentTypesUrl, _entriesUrl;
799
- var _ContentClient = class _ContentClient extends import_api5.ApiClient {
776
+ var _ContentClient = class _ContentClient extends import_api4.ApiClient {
800
777
  constructor(options) {
801
778
  var _a;
802
779
  super(options);
@@ -809,16 +786,42 @@ var _ContentClient = class _ContentClient extends import_api5.ApiClient {
809
786
  }
810
787
  getEntries(options) {
811
788
  const { projectId } = this.options;
812
- const { skipDataResolution, ...params } = options;
813
- const fetchUri = skipDataResolution ? this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, projectId }) : this.createUrl(__privateGet(_ContentClient, _entriesUrl), this.getEdgeOptions(params), this.edgeApiHost);
814
- return this.apiClient(fetchUri);
789
+ const { skipDataResolution, filters, ...params } = options;
790
+ const rewrittenFilters = Object.entries(filters != null ? filters : {}).reduce((acc, [key, value]) => {
791
+ const lhs = `filters.${key}` + (typeof value === "object" ? `[${Object.keys(value)[0]}]` : "");
792
+ let rhs = typeof value === "object" ? Object.values(value)[0] : value;
793
+ rhs = Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim();
794
+ return { ...acc, [lhs]: rhs };
795
+ }, {});
796
+ if (skipDataResolution) {
797
+ const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
798
+ return this.apiClient(url);
799
+ }
800
+ const edgeUrl = this.createUrl(
801
+ __privateGet(_ContentClient, _entriesUrl),
802
+ { ...this.getEdgeOptions(params), ...rewrittenFilters },
803
+ this.edgeApiHost
804
+ );
805
+ return this.apiClient(
806
+ edgeUrl,
807
+ this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
808
+ );
809
+ }
810
+ /** Fetches historical versions of an entry */
811
+ async getEntryHistory(options) {
812
+ const historyUrl = this.createUrl("/api/v1/entries-history", {
813
+ ...options,
814
+ projectId: this.options.projectId
815
+ });
816
+ return this.apiClient(historyUrl);
815
817
  }
816
- async upsertContentType(body) {
818
+ async upsertContentType(body, opts = {}) {
817
819
  const fetchUri = this.createUrl(__privateGet(_ContentClient, _contentTypesUrl));
818
820
  await this.apiClient(fetchUri, {
819
821
  method: "PUT",
820
822
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
821
- expectNoContent: true
823
+ expectNoContent: true,
824
+ headers: opts.autogenerateDataTypes ? { "x-uniform-autogenerate-data-types": "true" } : {}
822
825
  });
823
826
  }
824
827
  async upsertEntry(body) {
@@ -867,10 +870,10 @@ var UncachedContentClient = class extends ContentClient {
867
870
  };
868
871
 
869
872
  // src/DataSourceClient.ts
870
- var import_api6 = require("@uniformdev/context/api");
873
+ var import_api5 = require("@uniformdev/context/api");
871
874
  var dataSourceUrl = "/api/v1/data-source";
872
875
  var dataSourcesUrl = "/api/v1/data-sources";
873
- var DataSourceClient = class extends import_api6.ApiClient {
876
+ var DataSourceClient = class extends import_api5.ApiClient {
874
877
  constructor(options) {
875
878
  super(options);
876
879
  }
@@ -907,9 +910,9 @@ var DataSourceClient = class extends import_api6.ApiClient {
907
910
  };
908
911
 
909
912
  // src/DataTypeClient.ts
910
- var import_api7 = require("@uniformdev/context/api");
913
+ var import_api6 = require("@uniformdev/context/api");
911
914
  var _url;
912
- var _DataTypeClient = class _DataTypeClient extends import_api7.ApiClient {
915
+ var _DataTypeClient = class _DataTypeClient extends import_api6.ApiClient {
913
916
  constructor(options) {
914
917
  super(options);
915
918
  }
@@ -1065,12 +1068,14 @@ function getComponentPath(ancestorsAndSelf) {
1065
1068
  var CANVAS_PERSONALIZE_TYPE = "$personalization";
1066
1069
  var CANVAS_TEST_TYPE = "$test";
1067
1070
  var CANVAS_LOCALIZATION_TYPE = "$localization";
1071
+ var CANVAS_SLOT_SECTION_TYPE = "$slotSection";
1068
1072
  var CANVAS_INTENT_TAG_PARAM = "intentTag";
1069
1073
  var CANVAS_LOCALE_TAG_PARAM = "locale";
1070
1074
  var CANVAS_BLOCK_PARAM_TYPE = "$block";
1071
1075
  var CANVAS_PERSONALIZE_SLOT = "pz";
1072
1076
  var CANVAS_TEST_SLOT = "test";
1073
1077
  var CANVAS_LOCALIZATION_SLOT = "localized";
1078
+ var CANVAS_SLOT_SECTION_SLOT = "$slotSectionItems";
1074
1079
  var CANVAS_DRAFT_STATE = 0;
1075
1080
  var CANVAS_PUBLISHED_STATE = 64;
1076
1081
  var CANVAS_EDITOR_STATE = 63;
@@ -1080,6 +1085,7 @@ var CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
1080
1085
  var SECRET_QUERY_STRING_PARAM = "secret";
1081
1086
  var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
1082
1087
  var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
1088
+ var IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM = "is_incontext_editing_forced_settings";
1083
1089
  var IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM = "is_config_check";
1084
1090
  var IN_CONTEXT_EDITOR_COMPONENT_START_ROLE = "uniform-component-start";
1085
1091
  var IN_CONTEXT_EDITOR_COMPONENT_END_ROLE = "uniform-component-end";
@@ -1091,31 +1097,79 @@ var EMPTY_COMPOSITION = {
1091
1097
  _name: "An empty composition used for contextual editing",
1092
1098
  type: "_empty_composition_type"
1093
1099
  };
1094
- var EDGE_MIN_CACHE_TTL = 15;
1095
- var EDGE_MAX_CACHE_TTL = 600;
1100
+ var EDGE_MIN_CACHE_TTL = 10;
1101
+ var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
1096
1102
  var EDGE_DEFAULT_CACHE_TTL = 30;
1097
1103
  var EDGE_CACHE_DISABLED = -1;
1098
- var EDGE_MIN_L2_CACHE_TTL_IN_HOURS = 1;
1099
- var EDGE_MAX_L2_CACHE_TTL_IN_HOURS = 4 * 7 * 24;
1100
- var EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS = 24;
1104
+ var ASSET_PARAMETER_TYPE = "asset";
1105
+ var ASSETS_SOURCE_UNIFORM = "uniform-assets";
1106
+ var ASSETS_SOURCE_CUSTOM_URL = "custom-url";
1101
1107
 
1102
- // src/utils/entryConverter.ts
1103
- function convertEntryToPutEntry(entry) {
1104
- return {
1105
- entry: {
1106
- type: entry.entry.type,
1107
- _dataResources: entry.entry._dataResources,
1108
- _id: entry.entry._id,
1109
- _slug: entry.entry._slug,
1110
- fields: entry.entry.fields
1111
- },
1112
- state: entry.state,
1113
- projectId: entry.projectId
1114
- };
1108
+ // src/utils/guards.ts
1109
+ function isRootEntryReference(root) {
1110
+ return root.type === "root" && isEntryData(root.node);
1111
+ }
1112
+ function isEntryData(entryData) {
1113
+ return Boolean(entryData && typeof entryData === "object" && "fields" in entryData);
1114
+ }
1115
+ function isAssetParamValue(value) {
1116
+ return Array.isArray(value) && (value.length > 0 ? isAssetParamValueItem(value[0]) : true);
1117
+ }
1118
+ function isAssetParamValueItem(item) {
1119
+ return Boolean(
1120
+ item instanceof Object && "_source" in item && "fields" in item && item.fields instanceof Object && "url" in item.fields && item.fields.url instanceof Object
1121
+ );
1115
1122
  }
1123
+
1124
+ // src/utils/properties.ts
1116
1125
  function getPropertiesValue(entity) {
1117
1126
  return "parameters" in entity && entity.parameters ? entity.parameters : "fields" in entity && entity.fields ? entity.fields : void 0;
1118
1127
  }
1128
+ function getPropertyValue(parameter) {
1129
+ return parameter ? parameter.value : parameter;
1130
+ }
1131
+ function getLocalizedPropertyValues(parameter) {
1132
+ if (!parameter) {
1133
+ return parameter;
1134
+ }
1135
+ const localizedValues = /* @__PURE__ */ new Map();
1136
+ if (typeof parameter.value !== "undefined") {
1137
+ localizedValues.set(void 0, parameter.value);
1138
+ }
1139
+ if (parameter.locales !== void 0) {
1140
+ for (const [locale, localeValue] of Object.entries(parameter.locales)) {
1141
+ localizedValues.set(locale, localeValue);
1142
+ }
1143
+ }
1144
+ return localizedValues;
1145
+ }
1146
+ function flattenValues(data, options = {}) {
1147
+ if (!data) {
1148
+ return data;
1149
+ } else if (Array.isArray(data) && options.toSingle) {
1150
+ return data.length > 0 ? flattenSingleNodeValues(data[0]) : void 0;
1151
+ } else if (Array.isArray(data)) {
1152
+ return data.map((node) => flattenSingleNodeValues(node, options));
1153
+ } else {
1154
+ return flattenSingleNodeValues(data, options);
1155
+ }
1156
+ }
1157
+ function flattenSingleNodeValues(data, options = {}) {
1158
+ const { levels = 1 } = options;
1159
+ const properties = getPropertiesValue(data);
1160
+ return properties ? Object.fromEntries(
1161
+ Object.entries(properties).map(([id, parameter]) => {
1162
+ const value = getPropertyValue(parameter);
1163
+ if (levels > 0 && Array.isArray(value) && // In the future ASSET_PARAMETER_TYPE will be a nested data type
1164
+ (isNestedNodeType(parameter.type) || parameter.type === ASSET_PARAMETER_TYPE)) {
1165
+ const nestedOptions = { ...options, levels: levels - 1 };
1166
+ return [id, value.map((item) => flattenValues(item, nestedOptions))];
1167
+ } else {
1168
+ return [id, value];
1169
+ }
1170
+ })
1171
+ ) : properties;
1172
+ }
1119
1173
 
1120
1174
  // src/enhancement/walkNodeTree.ts
1121
1175
  function walkNodeTree(node, visitor, options) {
@@ -1135,7 +1189,83 @@ function walkNodeTree(node, visitor, options) {
1135
1189
  let visitDescendants = true;
1136
1190
  let descendantContext = (_a = childContexts.get(currentComponent.node)) != null ? _a : currentQueueEntry.context;
1137
1191
  let visitorInfo;
1138
- if (currentComponent.type === "root" || currentComponent.type === "slot") {
1192
+ if (currentComponent.type === "root" && isRootEntryReference(currentComponent) || currentComponent.type === "block") {
1193
+ visitorInfo = {
1194
+ type: "entry",
1195
+ node: currentComponent.node,
1196
+ ancestorsAndSelf: currentQueueEntry.ancestorsAndSelf,
1197
+ actions: {
1198
+ replace: (replacementNode) => {
1199
+ Object.assign(currentComponent.node, replacementNode);
1200
+ const propertiesToCheck = ["fields", "_dataResources", "_author"];
1201
+ propertiesToCheck.forEach((property) => {
1202
+ if (!replacementNode[property]) {
1203
+ delete currentComponent.node[property];
1204
+ }
1205
+ });
1206
+ },
1207
+ remove: () => {
1208
+ const currentComponentLocation = currentQueueEntry.ancestorsAndSelf[0];
1209
+ const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
1210
+ if (currentComponentLocation.type === "block") {
1211
+ const { fieldName, blockIndex } = currentComponentLocation;
1212
+ const blockValue = getBlockValue(parentComponent.node, fieldName);
1213
+ blockValue.splice(blockIndex, 1);
1214
+ if (blockValue.length === 0) {
1215
+ const properties2 = getPropertiesValue(parentComponent.node);
1216
+ delete properties2[fieldName];
1217
+ }
1218
+ } else {
1219
+ throw new Error("Unknown node type");
1220
+ }
1221
+ },
1222
+ insertAfter: (nodes) => {
1223
+ const currentNodeInfo = currentQueueEntry.ancestorsAndSelf[0];
1224
+ if (currentNodeInfo.type !== "block") {
1225
+ throw new Error("Unknown type");
1226
+ }
1227
+ const { fieldName, blockIndex } = currentNodeInfo;
1228
+ const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
1229
+ const nodesToInsert = Array.isArray(nodes) ? nodes : [nodes];
1230
+ if (fieldName && typeof blockIndex !== "undefined") {
1231
+ getPropertiesValue(parentComponent.node)[fieldName].value.splice(
1232
+ blockIndex + 1,
1233
+ 0,
1234
+ ...nodesToInsert
1235
+ );
1236
+ componentQueue.unshift(
1237
+ ...nodesToInsert.map((enqueueingComponent) => ({
1238
+ ancestorsAndSelf: [
1239
+ {
1240
+ type: "block",
1241
+ node: enqueueingComponent,
1242
+ fieldName,
1243
+ get blockIndex() {
1244
+ const parentArray = getPropertiesValue(parentComponent.node)[fieldName].value;
1245
+ return parentArray.findIndex((x) => x === enqueueingComponent);
1246
+ }
1247
+ },
1248
+ // slice removes 'self' since we are inserting a peer of self
1249
+ ...currentQueueEntry.ancestorsAndSelf.slice(1)
1250
+ ],
1251
+ context: descendantContext
1252
+ }))
1253
+ );
1254
+ }
1255
+ },
1256
+ stopProcessingDescendants() {
1257
+ visitDescendants = false;
1258
+ },
1259
+ setDescendantsContext(context) {
1260
+ descendantContext = context;
1261
+ },
1262
+ setChildContext(child, context) {
1263
+ childContexts.set(child, context);
1264
+ }
1265
+ },
1266
+ context: descendantContext
1267
+ };
1268
+ } else {
1139
1269
  visitorInfo = {
1140
1270
  type: "component",
1141
1271
  node: currentComponent.node,
@@ -1226,82 +1356,6 @@ function walkNodeTree(node, visitor, options) {
1226
1356
  },
1227
1357
  context: descendantContext
1228
1358
  };
1229
- } else {
1230
- visitorInfo = {
1231
- type: "entry",
1232
- node: currentComponent.node,
1233
- ancestorsAndSelf: currentQueueEntry.ancestorsAndSelf,
1234
- actions: {
1235
- replace: (replacementNode) => {
1236
- Object.assign(currentComponent.node, replacementNode);
1237
- const propertiesToCheck = ["fields", "_dataResources", "_author"];
1238
- propertiesToCheck.forEach((property) => {
1239
- if (!replacementNode[property]) {
1240
- delete currentComponent.node[property];
1241
- }
1242
- });
1243
- },
1244
- remove: () => {
1245
- const currentComponentLocation = currentQueueEntry.ancestorsAndSelf[0];
1246
- const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
1247
- if (currentComponentLocation.type === "block") {
1248
- const { fieldName, blockIndex } = currentComponentLocation;
1249
- const blockValue = getBlockValue(parentComponent.node, fieldName);
1250
- blockValue.splice(blockIndex, 1);
1251
- if (blockValue.length === 0) {
1252
- const properties2 = getPropertiesValue(parentComponent.node);
1253
- delete properties2[fieldName];
1254
- }
1255
- } else {
1256
- throw new Error("Unknown node type");
1257
- }
1258
- },
1259
- insertAfter: (nodes) => {
1260
- const currentNodeInfo = currentQueueEntry.ancestorsAndSelf[0];
1261
- if (currentNodeInfo.type !== "block") {
1262
- throw new Error("Unknown type");
1263
- }
1264
- const { fieldName, blockIndex } = currentNodeInfo;
1265
- const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
1266
- const nodesToInsert = Array.isArray(nodes) ? nodes : [nodes];
1267
- if (fieldName && typeof blockIndex !== "undefined") {
1268
- getPropertiesValue(parentComponent.node)[fieldName].value.splice(
1269
- blockIndex + 1,
1270
- 0,
1271
- ...nodesToInsert
1272
- );
1273
- componentQueue.unshift(
1274
- ...nodesToInsert.map((enqueueingComponent) => ({
1275
- ancestorsAndSelf: [
1276
- {
1277
- type: "block",
1278
- node: enqueueingComponent,
1279
- fieldName,
1280
- get blockIndex() {
1281
- const parentArray = getPropertiesValue(parentComponent.node)[fieldName].value;
1282
- return parentArray.findIndex((x) => x === enqueueingComponent);
1283
- }
1284
- },
1285
- // slice removes 'self' since we are inserting a peer of self
1286
- ...currentQueueEntry.ancestorsAndSelf.slice(1)
1287
- ],
1288
- context: descendantContext
1289
- }))
1290
- );
1291
- }
1292
- },
1293
- stopProcessingDescendants() {
1294
- visitDescendants = false;
1295
- },
1296
- setDescendantsContext(context) {
1297
- descendantContext = context;
1298
- },
1299
- setChildContext(child, context) {
1300
- childContexts.set(child, context);
1301
- }
1302
- },
1303
- context: descendantContext
1304
- };
1305
1359
  }
1306
1360
  visitor(visitorInfo);
1307
1361
  if (!visitDescendants) {
@@ -1339,7 +1393,7 @@ function walkNodeTree(node, visitor, options) {
1339
1393
  const propertyEntries = Object.entries(properties);
1340
1394
  for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
1341
1395
  const [propKey, propObject] = propertyEntries[propIndex];
1342
- if (propObject.type !== CANVAS_BLOCK_PARAM_TYPE)
1396
+ if (!isNestedNodeType(propObject.type))
1343
1397
  continue;
1344
1398
  const blocks = (_b = propObject.value) != null ? _b : [];
1345
1399
  for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
@@ -1365,6 +1419,9 @@ function walkNodeTree(node, visitor, options) {
1365
1419
  }
1366
1420
  } while (componentQueue.length > 0);
1367
1421
  }
1422
+ function isNestedNodeType(type) {
1423
+ return type === CANVAS_BLOCK_PARAM_TYPE;
1424
+ }
1368
1425
  function getBlockValue(component, parameterName) {
1369
1426
  var _a;
1370
1427
  const parameter = (_a = getPropertiesValue(component)) == null ? void 0 : _a[parameterName];
@@ -1633,7 +1690,7 @@ function getComponentJsonPointer(ancestorsAndSelf) {
1633
1690
  if (currentLocation.type === "block") {
1634
1691
  const { fieldName: parameterName, blockIndex } = currentLocation;
1635
1692
  if (parameterName && blockIndex !== void 0) {
1636
- const noun = parentLocation && "type" in parentLocation && parentLocation.type === "block" ? "fields" : "parameters";
1693
+ const noun = getNounForLocation(parentLocation);
1637
1694
  path.push(`${noun}/${parameterName}/value/${blockIndex}`);
1638
1695
  }
1639
1696
  } else {
@@ -1647,6 +1704,40 @@ function getComponentJsonPointer(ancestorsAndSelf) {
1647
1704
  }
1648
1705
  return `/${path.join("/")}`;
1649
1706
  }
1707
+ function getNounForLocation(parentLocation) {
1708
+ let noun = "parameters";
1709
+ if (parentLocation && "type" in parentLocation) {
1710
+ if (parentLocation.type === "block" || isRootEntryReference(parentLocation)) {
1711
+ noun = "fields";
1712
+ }
1713
+ }
1714
+ return noun;
1715
+ }
1716
+ function getNounForNode(node) {
1717
+ let noun = "parameters";
1718
+ if (isEntryData(node)) {
1719
+ noun = "fields";
1720
+ }
1721
+ return noun;
1722
+ }
1723
+
1724
+ // src/enhancement/findInNodeTree.ts
1725
+ function findParameterInNodeTree(data, predicate) {
1726
+ const results = [];
1727
+ walkNodeTree(data, ({ node, ancestorsAndSelf }) => {
1728
+ const parameters = getPropertiesValue(node);
1729
+ if (parameters) {
1730
+ Object.entries(parameters).filter(([key, field]) => predicate(field, key, node)).forEach(([key, field]) => {
1731
+ results.push({
1732
+ key,
1733
+ pointer: (ancestorsAndSelf.length === 1 ? "" : getComponentJsonPointer(ancestorsAndSelf)) + `/${getNounForNode(node)}/${key}`,
1734
+ parameter: field
1735
+ });
1736
+ });
1737
+ }
1738
+ });
1739
+ return results;
1740
+ }
1650
1741
 
1651
1742
  // src/enhancement/localize.ts
1652
1743
  function extractLocales({ component }) {
@@ -1663,23 +1754,31 @@ function extractLocales({ component }) {
1663
1754
  });
1664
1755
  return variations;
1665
1756
  }
1666
- function localize({
1667
- composition,
1668
- locale
1669
- }) {
1670
- walkNodeTree(composition, ({ type, node, actions }) => {
1757
+ function localize(options) {
1758
+ const nodes = "nodes" in options ? options.nodes : options.composition;
1759
+ const locale = options.locale;
1760
+ walkNodeTree(nodes, ({ type, node, actions }) => {
1671
1761
  if (type !== "component") {
1672
- actions.stopProcessingDescendants();
1762
+ if (typeof locale === "string") {
1763
+ localizeProperties(node.fields, locale);
1764
+ }
1673
1765
  return;
1674
1766
  }
1767
+ const shouldRunPropertyLocalization = typeof locale === "string";
1675
1768
  if (node.type === CANVAS_LOCALIZATION_TYPE) {
1676
1769
  const locales = extractLocales({ component: node });
1677
- const resolvedLocale = typeof locale === "string" ? locale : locale({ component: node, locales });
1770
+ const resolvedLocale = typeof locale === "string" ? locale : locale == null ? void 0 : locale({ component: node, locales });
1678
1771
  let replaceComponent;
1679
1772
  if (resolvedLocale) {
1680
1773
  replaceComponent = locales[resolvedLocale];
1681
1774
  }
1682
1775
  if (replaceComponent == null ? void 0 : replaceComponent.length) {
1776
+ replaceComponent.forEach((component) => {
1777
+ removeLocaleProperty(component);
1778
+ if (shouldRunPropertyLocalization) {
1779
+ localizeProperties(getPropertiesValue(component), locale);
1780
+ }
1781
+ });
1683
1782
  const [first, ...rest] = replaceComponent;
1684
1783
  actions.replace(first);
1685
1784
  if (rest.length) {
@@ -1688,6 +1787,42 @@ function localize({
1688
1787
  } else {
1689
1788
  actions.remove();
1690
1789
  }
1790
+ } else if (shouldRunPropertyLocalization) {
1791
+ localizeProperties(getPropertiesValue(node), locale);
1792
+ }
1793
+ });
1794
+ }
1795
+ function removeLocaleProperty(component) {
1796
+ const properties = getPropertiesValue(component);
1797
+ const localeTagProperty = properties == null ? void 0 : properties[CANVAS_LOCALE_TAG_PARAM];
1798
+ if (localeTagProperty) {
1799
+ delete properties[CANVAS_LOCALE_TAG_PARAM];
1800
+ }
1801
+ if (properties && Object.keys(properties).length === 0) {
1802
+ if ("fields" in component) {
1803
+ delete component.fields;
1804
+ }
1805
+ if ("parameters" in component) {
1806
+ delete component.parameters;
1807
+ }
1808
+ }
1809
+ }
1810
+ function localizeProperties(properties, locale) {
1811
+ if (!properties) {
1812
+ return void 0;
1813
+ }
1814
+ Object.entries(properties).forEach(([key, property]) => {
1815
+ var _a;
1816
+ if (!locale) {
1817
+ delete property.locales;
1818
+ }
1819
+ const currentLocaleValue = locale ? (_a = property.locales) == null ? void 0 : _a[locale] : void 0;
1820
+ if (currentLocaleValue !== void 0) {
1821
+ property.value = currentLocaleValue;
1822
+ }
1823
+ delete property.locales;
1824
+ if (property.value === void 0) {
1825
+ delete properties[key];
1691
1826
  }
1692
1827
  });
1693
1828
  }
@@ -1837,6 +1972,39 @@ function walkComponentTree(component, visitor, initialContext) {
1837
1972
  } while (componentQueue.length > 0);
1838
1973
  }
1839
1974
 
1975
+ // src/LocaleClient.ts
1976
+ var import_api7 = require("@uniformdev/context/api");
1977
+ var localesUrl = "/api/v1/locales";
1978
+ var LocaleClient = class extends import_api7.ApiClient {
1979
+ constructor(options) {
1980
+ super(options);
1981
+ }
1982
+ /** Fetches all locales for a project */
1983
+ async get(options) {
1984
+ const { projectId } = this.options;
1985
+ const fetchUri = this.createUrl(localesUrl, { ...options, projectId });
1986
+ return await this.apiClient(fetchUri);
1987
+ }
1988
+ /** Updates or creates (based on id) a locale */
1989
+ async upsert(body) {
1990
+ const fetchUri = this.createUrl(localesUrl);
1991
+ await this.apiClient(fetchUri, {
1992
+ method: "PUT",
1993
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1994
+ expectNoContent: true
1995
+ });
1996
+ }
1997
+ /** Deletes a locale */
1998
+ async remove(body) {
1999
+ const fetchUri = this.createUrl(localesUrl);
2000
+ await this.apiClient(fetchUri, {
2001
+ method: "DELETE",
2002
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
2003
+ expectNoContent: true
2004
+ });
2005
+ }
2006
+ };
2007
+
1840
2008
  // src/utils/hash.ts
1841
2009
  var generateHash = ({
1842
2010
  composition,
@@ -1907,6 +2075,12 @@ var isOpenParameterEditorMessage = (message) => {
1907
2075
  var isUpdateComponentReferencesMessage = (message) => {
1908
2076
  return message.type === "update-component-references";
1909
2077
  };
2078
+ var isRequestComponentSuggestionMessage = (message) => {
2079
+ return message.type === "request-component-suggestion";
2080
+ };
2081
+ var isSuggestComponentMessage = (message) => {
2082
+ return message.type === "suggest-component";
2083
+ };
1910
2084
  var createCanvasChannel = ({
1911
2085
  listenTo,
1912
2086
  broadcastTo
@@ -1915,7 +2089,13 @@ var createCanvasChannel = ({
1915
2089
  const handlers = {};
1916
2090
  const broadcastToItems = [...broadcastTo];
1917
2091
  const postMessage = (message) => {
1918
- broadcastToItems.forEach((item) => item.postMessage(JSON.stringify(message), "*"));
2092
+ broadcastToItems.forEach((item) => item == null ? void 0 : item.postMessage(JSON.stringify(message), "*"));
2093
+ for (const handlerId in handlers) {
2094
+ const handler = handlers[handlerId];
2095
+ if (handler.types.includes(message.type)) {
2096
+ handler.handler(message, new MessageEvent(message.type));
2097
+ }
2098
+ }
1919
2099
  };
1920
2100
  const selectComponent = (id) => {
1921
2101
  const message = {
@@ -1924,7 +2104,7 @@ var createCanvasChannel = ({
1924
2104
  };
1925
2105
  postMessage(message);
1926
2106
  };
1927
- const ready = () => {
2107
+ const ready = (options) => {
1928
2108
  var _a, _b;
1929
2109
  if (typeof window === "undefined") {
1930
2110
  return;
@@ -1934,7 +2114,8 @@ var createCanvasChannel = ({
1934
2114
  const message = {
1935
2115
  type: "ready",
1936
2116
  framework,
1937
- version
2117
+ version,
2118
+ rsc: options == null ? void 0 : options.rsc
1938
2119
  };
1939
2120
  postMessage(message);
1940
2121
  };
@@ -2057,6 +2238,20 @@ var createCanvasChannel = ({
2057
2238
  };
2058
2239
  postMessage(message);
2059
2240
  };
2241
+ const requestComponentSuggestion = (options) => {
2242
+ const message = {
2243
+ ...options,
2244
+ type: "request-component-suggestion"
2245
+ };
2246
+ postMessage(message);
2247
+ };
2248
+ const suggestComponent = (options) => {
2249
+ const message = {
2250
+ ...options,
2251
+ type: "suggest-component"
2252
+ };
2253
+ postMessage(message);
2254
+ };
2060
2255
  const updateFeatureFlags = (options) => {
2061
2256
  const message = {
2062
2257
  ...options,
@@ -2110,7 +2305,9 @@ var createCanvasChannel = ({
2110
2305
  openParameterEditor,
2111
2306
  reportRenderedCompositions,
2112
2307
  editorStateUpdated,
2113
- updateComponentReferences
2308
+ updateComponentReferences,
2309
+ requestComponentSuggestion,
2310
+ suggestComponent
2114
2311
  };
2115
2312
  };
2116
2313
 
@@ -2192,10 +2389,166 @@ function subscribeToComposition({
2192
2389
  };
2193
2390
  }
2194
2391
 
2195
- // src/RouteClient.ts
2392
+ // src/PromptClient.ts
2196
2393
  var import_api8 = require("@uniformdev/context/api");
2394
+ var PromptsUrl = "/api/v1/prompts";
2395
+ var PromptClient = class extends import_api8.ApiClient {
2396
+ constructor(options) {
2397
+ super(options);
2398
+ }
2399
+ /** Fetches Prompts for a project */
2400
+ async get(options) {
2401
+ const { projectId } = this.options;
2402
+ const fetchUri = this.createUrl(PromptsUrl, { ...options, projectId });
2403
+ return await this.apiClient(fetchUri);
2404
+ }
2405
+ /** Updates or creates (based on id) a Prompt */
2406
+ async upsert(body) {
2407
+ const fetchUri = this.createUrl(PromptsUrl);
2408
+ await this.apiClient(fetchUri, {
2409
+ method: "PUT",
2410
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
2411
+ expectNoContent: true
2412
+ });
2413
+ }
2414
+ /** Deletes a Prompt */
2415
+ async remove(body) {
2416
+ const fetchUri = this.createUrl(PromptsUrl);
2417
+ await this.apiClient(fetchUri, {
2418
+ method: "DELETE",
2419
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
2420
+ expectNoContent: true
2421
+ });
2422
+ }
2423
+ };
2424
+
2425
+ // src/RelationshipClient.ts
2426
+ var import_api9 = require("@uniformdev/context/api");
2427
+ var RELATIONSHIPS_URL = "/api/v1/relationships";
2428
+ var RelationshipClient = class extends import_api9.ApiClient {
2429
+ constructor(options) {
2430
+ super(options);
2431
+ this.get = async (options) => {
2432
+ const { projectId } = this.options;
2433
+ const url = this.createUrl(RELATIONSHIPS_URL, { ...options, projectId });
2434
+ return this.apiClient(url);
2435
+ };
2436
+ this.clearProjectRelationships = async () => {
2437
+ const { projectId } = this.options;
2438
+ const url = this.createUrl(RELATIONSHIPS_URL);
2439
+ return this.apiClient(url, {
2440
+ method: "POST",
2441
+ body: JSON.stringify({
2442
+ action: "clear",
2443
+ projectId
2444
+ })
2445
+ });
2446
+ };
2447
+ this.indexRelationships = async ({ state, id, type }) => {
2448
+ const { projectId } = this.options;
2449
+ const url = this.createUrl(RELATIONSHIPS_URL);
2450
+ return this.apiClient(url, {
2451
+ method: "POST",
2452
+ body: JSON.stringify({
2453
+ action: "index",
2454
+ type,
2455
+ projectId,
2456
+ state,
2457
+ id
2458
+ })
2459
+ });
2460
+ };
2461
+ this.getVersion = async () => {
2462
+ const { projectId } = this.options;
2463
+ const url = this.createUrl("/api/v1/usage-tracking", {
2464
+ projectId
2465
+ });
2466
+ return this.apiClient(url).then((response) => response.version);
2467
+ };
2468
+ this.setVersion = async (version) => {
2469
+ const { projectId } = this.options;
2470
+ const url = this.createUrl("/api/v1/usage-tracking");
2471
+ return this.apiClient(url, {
2472
+ method: "POST",
2473
+ body: JSON.stringify({
2474
+ projectId,
2475
+ version
2476
+ })
2477
+ });
2478
+ };
2479
+ }
2480
+ };
2481
+
2482
+ // src/ReleaseClient.ts
2483
+ var import_api10 = require("@uniformdev/context/api");
2484
+ var releasesUrl = "/api/v1/releases";
2485
+ var ReleaseClient = class extends import_api10.ApiClient {
2486
+ constructor(options) {
2487
+ super(options);
2488
+ }
2489
+ /** Fetches all releases for a project */
2490
+ async get(options) {
2491
+ const { projectId } = this.options;
2492
+ const fetchUri = this.createUrl(releasesUrl, { ...options, projectId });
2493
+ return await this.apiClient(fetchUri);
2494
+ }
2495
+ /** Updates or creates (based on id) a release */
2496
+ async upsert(body) {
2497
+ const fetchUri = this.createUrl(releasesUrl);
2498
+ await this.apiClient(fetchUri, {
2499
+ method: "PUT",
2500
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
2501
+ expectNoContent: true
2502
+ });
2503
+ }
2504
+ /** Deletes a release */
2505
+ async remove(body) {
2506
+ const fetchUri = this.createUrl(releasesUrl);
2507
+ await this.apiClient(fetchUri, {
2508
+ method: "DELETE",
2509
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
2510
+ expectNoContent: true
2511
+ });
2512
+ }
2513
+ /** Readies or unreadies a release for merging */
2514
+ async ready(body) {
2515
+ const fetchUri = this.createUrl(releasesUrl);
2516
+ await this.apiClient(fetchUri, {
2517
+ method: "PATCH",
2518
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
2519
+ expectNoContent: true
2520
+ });
2521
+ }
2522
+ };
2523
+
2524
+ // src/ReleaseContentsClient.ts
2525
+ var import_api11 = require("@uniformdev/context/api");
2526
+ var releaseContentsUrl = "/api/v1/release-contents";
2527
+ var ReleaseContentsClient = class extends import_api11.ApiClient {
2528
+ constructor(options) {
2529
+ super(options);
2530
+ }
2531
+ /** Fetches all entities added to a release */
2532
+ async get(options) {
2533
+ const { projectId } = this.options;
2534
+ const fetchUri = this.createUrl(releaseContentsUrl, { ...options, projectId });
2535
+ return await this.apiClient(fetchUri);
2536
+ }
2537
+ /** Removes a release content from a release */
2538
+ async remove(body) {
2539
+ const fetchUri = this.createUrl(releaseContentsUrl);
2540
+ await this.apiClient(fetchUri, {
2541
+ method: "DELETE",
2542
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
2543
+ expectNoContent: true
2544
+ });
2545
+ }
2546
+ };
2547
+
2548
+ // src/RouteClient.ts
2549
+ var import_api12 = require("@uniformdev/context/api");
2197
2550
  var ROUTE_URL = "/api/v1/route";
2198
- var RouteClient = class extends import_api8.ApiClient {
2551
+ var RouteClient = class extends import_api12.ApiClient {
2199
2552
  constructor(options) {
2200
2553
  var _a;
2201
2554
  if (!options.limitPolicy) {
@@ -2208,10 +2561,16 @@ var RouteClient = class extends import_api8.ApiClient {
2208
2561
  async getRoute(options) {
2209
2562
  const { projectId } = this.options;
2210
2563
  const fetchUri = this.createUrl(ROUTE_URL, { ...options, projectId }, this.edgeApiHost);
2211
- return await this.apiClient(fetchUri);
2564
+ return await this.apiClient(
2565
+ fetchUri,
2566
+ this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
2567
+ );
2212
2568
  }
2213
2569
  };
2214
2570
 
2571
+ // src/types/locales.ts
2572
+ var LOCALE_DYNAMIC_INPUT_NAME = "locale";
2573
+
2215
2574
  // src/utils/createApiEnhancer.ts
2216
2575
  var createUniformApiEnhancer = ({ apiUrl }) => {
2217
2576
  return async (message) => {
@@ -2234,6 +2593,28 @@ var createUniformApiEnhancer = ({ apiUrl }) => {
2234
2593
  };
2235
2594
  };
2236
2595
 
2596
+ // src/utils/entryConverter.ts
2597
+ function convertEntryToPutEntry(entry) {
2598
+ return {
2599
+ entry: {
2600
+ type: entry.entry.type,
2601
+ _dataResources: entry.entry._dataResources,
2602
+ _id: entry.entry._id,
2603
+ _name: entry.entry._name,
2604
+ _slug: entry.entry._slug,
2605
+ _pattern: entry.entry._pattern,
2606
+ _overridability: entry.entry._overridability,
2607
+ _overrides: entry.entry._overrides,
2608
+ fields: entry.entry.fields,
2609
+ _locales: entry.entry._locales
2610
+ },
2611
+ pattern: entry.pattern,
2612
+ state: entry.state,
2613
+ projectId: entry.projectId,
2614
+ releaseId: entry.releaseId
2615
+ };
2616
+ }
2617
+
2237
2618
  // src/utils/getParameterAttributes.ts
2238
2619
  var ATTRIBUTE_COMPONENT_ID = "data-uniform-component-id";
2239
2620
  var ATTRIBUTE_PARAMETER_ID = "data-uniform-parameter-id";
@@ -2307,17 +2688,41 @@ function mapSlotToTestVariations(slot) {
2307
2688
  }
2308
2689
 
2309
2690
  // src/utils/placeholder.ts
2691
+ var SEPARATOR = "_";
2310
2692
  var isComponentPlaceholderId = (id) => {
2311
2693
  if (id === PLACEHOLDER_ID) {
2312
2694
  return true;
2313
2695
  }
2696
+ if (typeof id !== "string") {
2697
+ return false;
2698
+ }
2314
2699
  return id == null ? void 0 : id.startsWith(PLACEHOLDER_ID);
2315
2700
  };
2316
- var generateComponentPlaceholderId = (randomId, sdkVersion) => {
2701
+ var generateComponentPlaceholderId = (randomId, sdkVersion, parent) => {
2317
2702
  if (typeof sdkVersion === "undefined" || sdkVersion === 1) {
2318
2703
  return PLACEHOLDER_ID;
2319
2704
  }
2320
- return `${PLACEHOLDER_ID}_${randomId}`;
2705
+ let idParts = [PLACEHOLDER_ID, randomId];
2706
+ if (parent) {
2707
+ idParts = [...idParts, parent.nodeId, parent.slotId];
2708
+ }
2709
+ return idParts.join(SEPARATOR);
2710
+ };
2711
+ var parseComponentPlaceholderId = (id) => {
2712
+ if (!isComponentPlaceholderId(id)) {
2713
+ return;
2714
+ }
2715
+ const idParts = id.split(SEPARATOR);
2716
+ const result = {
2717
+ id: idParts[1]
2718
+ };
2719
+ if (idParts[2]) {
2720
+ result.parent = {
2721
+ nodeId: idParts[2],
2722
+ slotId: idParts[3]
2723
+ };
2724
+ }
2725
+ return result;
2321
2726
  };
2322
2727
 
2323
2728
  // src/utils/variables/parseVariableExpression.ts
@@ -2360,9 +2765,14 @@ function parseVariableExpression(serialized, onToken) {
2360
2765
  continue;
2361
2766
  }
2362
2767
  if (char === variableSuffix && state === "variable") {
2768
+ if (serialized[index - 1] === escapeCharacter) {
2769
+ bufferEndIndex++;
2770
+ continue;
2771
+ }
2363
2772
  state = "text";
2364
2773
  if (bufferEndIndex > bufferStartIndex) {
2365
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "variable") === false) {
2774
+ const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
2775
+ if (handleToken(unescapedVariableName, "variable") === false) {
2366
2776
  return tokenCount;
2367
2777
  }
2368
2778
  bufferStartIndex = bufferEndIndex + variableSuffix.length;
@@ -2422,7 +2832,7 @@ var import_immer = require("immer");
2422
2832
 
2423
2833
  // src/utils/variables/createVariableReference.ts
2424
2834
  function createVariableReference(variableName) {
2425
- return `\${${variableName}}`;
2835
+ return `\${${variableName.replace(/([${}])/g, "\\$1")}}`;
2426
2836
  }
2427
2837
 
2428
2838
  // src/utils/variables/bindVariablesToObject.ts
@@ -2503,10 +2913,13 @@ function handleRichTextNodeBinding(object, options) {
2503
2913
  }
2504
2914
 
2505
2915
  // src/index.ts
2506
- var import_api9 = require("@uniformdev/context/api");
2507
- var CanvasClientError = import_api9.ApiClientError;
2916
+ var import_api13 = require("@uniformdev/context/api");
2917
+ var CanvasClientError = import_api13.ApiClientError;
2508
2918
  // Annotate the CommonJS export names for ESM import in node:
2509
2919
  0 && (module.exports = {
2920
+ ASSETS_SOURCE_CUSTOM_URL,
2921
+ ASSETS_SOURCE_UNIFORM,
2922
+ ASSET_PARAMETER_TYPE,
2510
2923
  ATTRIBUTE_COMPONENT_ID,
2511
2924
  ATTRIBUTE_MULTILINE,
2512
2925
  ATTRIBUTE_PARAMETER_ID,
@@ -2527,6 +2940,8 @@ var CanvasClientError = import_api9.ApiClientError;
2527
2940
  CANVAS_PERSONALIZE_SLOT,
2528
2941
  CANVAS_PERSONALIZE_TYPE,
2529
2942
  CANVAS_PUBLISHED_STATE,
2943
+ CANVAS_SLOT_SECTION_SLOT,
2944
+ CANVAS_SLOT_SECTION_TYPE,
2530
2945
  CANVAS_TEST_SLOT,
2531
2946
  CANVAS_TEST_TYPE,
2532
2947
  CANVAS_TEST_VARIANT_PARAM,
@@ -2539,21 +2954,25 @@ var CanvasClientError = import_api9.ApiClientError;
2539
2954
  DataTypeClient,
2540
2955
  EDGE_CACHE_DISABLED,
2541
2956
  EDGE_DEFAULT_CACHE_TTL,
2542
- EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS,
2543
2957
  EDGE_MAX_CACHE_TTL,
2544
- EDGE_MAX_L2_CACHE_TTL_IN_HOURS,
2545
2958
  EDGE_MIN_CACHE_TTL,
2546
- EDGE_MIN_L2_CACHE_TTL_IN_HOURS,
2547
2959
  EMPTY_COMPOSITION,
2548
2960
  EnhancerBuilder,
2549
2961
  IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
2550
2962
  IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
2551
2963
  IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM,
2552
2964
  IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID,
2965
+ IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM,
2553
2966
  IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM,
2554
2967
  IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
2555
2968
  IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
2969
+ LOCALE_DYNAMIC_INPUT_NAME,
2970
+ LocaleClient,
2556
2971
  PLACEHOLDER_ID,
2972
+ PromptClient,
2973
+ RelationshipClient,
2974
+ ReleaseClient,
2975
+ ReleaseContentsClient,
2557
2976
  RouteClient,
2558
2977
  SECRET_QUERY_STRING_PARAM,
2559
2978
  UncachedCanvasClient,
@@ -2572,25 +2991,38 @@ var CanvasClientError = import_api9.ApiClientError;
2572
2991
  createVariableReference,
2573
2992
  enhance,
2574
2993
  extractLocales,
2994
+ findParameterInNodeTree,
2995
+ flattenValues,
2575
2996
  generateComponentPlaceholderId,
2576
2997
  generateHash,
2577
2998
  getBlockValue,
2578
2999
  getChannelName,
2579
3000
  getComponentJsonPointer,
2580
3001
  getComponentPath,
3002
+ getLocalizedPropertyValues,
3003
+ getNounForLocation,
3004
+ getNounForNode,
2581
3005
  getParameterAttributes,
2582
3006
  getPropertiesValue,
3007
+ getPropertyValue,
2583
3008
  isAddComponentMessage,
2584
3009
  isAllowedReferrer,
3010
+ isAssetParamValue,
3011
+ isAssetParamValueItem,
2585
3012
  isComponentActionMessage,
2586
3013
  isComponentPlaceholderId,
2587
3014
  isDismissPlaceholderMessage,
3015
+ isEntryData,
2588
3016
  isMovingComponentMessage,
3017
+ isNestedNodeType,
2589
3018
  isOpenParameterEditorMessage,
2590
3019
  isReadyMessage,
2591
3020
  isReportRenderedCompositionsMessage,
3021
+ isRequestComponentSuggestionMessage,
3022
+ isRootEntryReference,
2592
3023
  isSelectComponentMessage,
2593
3024
  isSelectParameterMessage,
3025
+ isSuggestComponentMessage,
2594
3026
  isSystemComponentDefinition,
2595
3027
  isTriggerCompositionActionMessage,
2596
3028
  isUpdateComponentParameterMessage,
@@ -2604,9 +3036,9 @@ var CanvasClientError = import_api9.ApiClientError;
2604
3036
  mapSlotToPersonalizedVariations,
2605
3037
  mapSlotToTestVariations,
2606
3038
  nullLimitPolicy,
3039
+ parseComponentPlaceholderId,
2607
3040
  parseVariableExpression,
2608
3041
  subscribeToComposition,
2609
- unstable_CompositionRelationshipClient,
2610
3042
  walkComponentTree,
2611
3043
  walkNodeTree
2612
3044
  });