@uniformdev/canvas 20.50.2-alpha.1 → 20.50.2-alpha.117

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.esm.js CHANGED
@@ -380,7 +380,7 @@ var require_retry2 = __commonJS({
380
380
  });
381
381
 
382
382
  // src/CanvasClient.ts
383
- import { ApiClient } from "@uniformdev/context/api";
383
+ import { ApiClient, rewriteFiltersForApi } from "@uniformdev/context/api";
384
384
 
385
385
  // src/enhancement/createLimitPolicy.ts
386
386
  var import_p_limit = __toESM(require_p_limit());
@@ -584,22 +584,6 @@ function createLimitPolicy({
584
584
  }
585
585
  var nullLimitPolicy = async (func) => await func();
586
586
 
587
- // src/utils/rewriteFilters.ts
588
- var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
589
- function rewriteFilters(filters) {
590
- return Object.entries(filters != null ? filters : {}).reduce(
591
- (acc, [key, value]) => {
592
- const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
593
- const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
594
- return {
595
- ...acc,
596
- [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
597
- };
598
- },
599
- {}
600
- );
601
- }
602
-
603
587
  // src/CanvasClient.ts
604
588
  var CANVAS_URL = "/api/v1/canvas";
605
589
  var CanvasClient = class extends ApiClient {
@@ -616,7 +600,7 @@ var CanvasClient = class extends ApiClient {
616
600
  async getCompositionList(params = {}) {
617
601
  const { projectId } = this.options;
618
602
  const { resolveData, filters, ...originParams } = params;
619
- const rewrittenFilters = rewriteFilters(filters);
603
+ const rewrittenFilters = rewriteFiltersForApi(filters);
620
604
  if (!resolveData) {
621
605
  const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
622
606
  return this.apiClient(fetchUri);
@@ -770,7 +754,7 @@ var UncachedCategoryClient = class extends CategoryClient {
770
754
  };
771
755
 
772
756
  // src/ContentClient.ts
773
- import { ApiClient as ApiClient3 } from "@uniformdev/context/api";
757
+ import { ApiClient as ApiClient3, rewriteFiltersForApi as rewriteFiltersForApi2 } from "@uniformdev/context/api";
774
758
  var _contentTypesUrl, _entriesUrl;
775
759
  var _ContentClient = class _ContentClient extends ApiClient3 {
776
760
  constructor(options) {
@@ -786,7 +770,7 @@ var _ContentClient = class _ContentClient extends ApiClient3 {
786
770
  getEntries(options) {
787
771
  const { projectId } = this.options;
788
772
  const { skipDataResolution, filters, ...params } = options;
789
- const rewrittenFilters = rewriteFilters(filters);
773
+ const rewrittenFilters = rewriteFiltersForApi2(filters);
790
774
  if (skipDataResolution) {
791
775
  const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
792
776
  return this.apiClient(url);
@@ -1122,6 +1106,7 @@ var EDGE_CACHE_DISABLED = -1;
1122
1106
  var ASSET_PARAMETER_TYPE = "asset";
1123
1107
  var ASSETS_SOURCE_UNIFORM = "uniform-assets";
1124
1108
  var ASSETS_SOURCE_CUSTOM_URL = "custom-url";
1109
+ var REFERENCE_DATA_TYPE_ID = "uniformContentInternalReference";
1125
1110
 
1126
1111
  // src/utils/guards.ts
1127
1112
  function isRootEntryReference(root) {
@@ -1280,7 +1265,7 @@ function hasReferencedVariables(value) {
1280
1265
 
1281
1266
  // src/enhancement/walkNodeTree.ts
1282
1267
  function walkNodeTree(node, visitor, options) {
1283
- var _a, _b;
1268
+ var _a, _b, _c;
1284
1269
  const componentQueue = [
1285
1270
  {
1286
1271
  ancestorsAndSelf: Array.isArray(node) ? node : [{ node, type: "root" }],
@@ -1288,12 +1273,14 @@ function walkNodeTree(node, visitor, options) {
1288
1273
  }
1289
1274
  ];
1290
1275
  const childContexts = /* @__PURE__ */ new Map();
1276
+ const order = (_a = options == null ? void 0 : options.order) != null ? _a : "dfs";
1277
+ const takeNext = () => order === "bfs" ? componentQueue.shift() : componentQueue.pop();
1291
1278
  do {
1292
- const currentQueueEntry = componentQueue.pop();
1279
+ const currentQueueEntry = takeNext();
1293
1280
  if (!currentQueueEntry) continue;
1294
1281
  const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
1295
1282
  let visitDescendants = true;
1296
- let descendantContext = (_a = childContexts.get(currentComponent.node)) != null ? _a : currentQueueEntry.context;
1283
+ let descendantContext = (_b = childContexts.get(currentComponent.node)) != null ? _b : currentQueueEntry.context;
1297
1284
  let visitorInfo;
1298
1285
  if (currentComponent.type === "root" && isRootEntryReference(currentComponent) || currentComponent.type === "block") {
1299
1286
  visitorInfo = {
@@ -1480,39 +1467,11 @@ function walkNodeTree(node, visitor, options) {
1480
1467
  continue;
1481
1468
  }
1482
1469
  const slots = "slots" in currentComponent.node && currentComponent.node.slots;
1483
- if (slots) {
1484
- const slotKeys = Object.keys(slots);
1485
- for (let slotIndex = slotKeys.length - 1; slotIndex >= 0; slotIndex--) {
1486
- const slotKey = slotKeys[slotIndex];
1487
- const components = slots[slotKey];
1488
- for (let componentIndex = components.length - 1; componentIndex >= 0; componentIndex--) {
1489
- const enqueueingComponent = components[componentIndex];
1490
- const parentSlotIndexFn = () => {
1491
- const result = currentComponent.node.slots[slotKey].findIndex(
1492
- (x) => x === enqueueingComponent
1493
- );
1494
- return result;
1495
- };
1496
- componentQueue.push({
1497
- ancestorsAndSelf: [
1498
- {
1499
- type: "slot",
1500
- node: enqueueingComponent,
1501
- parentSlot: slotKey,
1502
- parentSlotIndexFn
1503
- },
1504
- ...currentQueueEntry.ancestorsAndSelf
1505
- ],
1506
- context: descendantContext
1507
- });
1508
- }
1509
- }
1510
- }
1470
+ const childEntries = [];
1511
1471
  const properties = getPropertiesValue(currentComponent.node);
1512
1472
  if (properties) {
1513
1473
  const propertyEntries = Object.entries(properties);
1514
- for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
1515
- const [propKey, propObject] = propertyEntries[propIndex];
1474
+ for (const [propKey, propObject] of propertyEntries) {
1516
1475
  if (!isNestedNodeType(propObject.type)) {
1517
1476
  continue;
1518
1477
  }
@@ -1532,13 +1491,12 @@ function walkNodeTree(node, visitor, options) {
1532
1491
  continue;
1533
1492
  }
1534
1493
  }
1535
- const blocks = (_b = propObject.value) != null ? _b : [];
1536
- for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
1537
- const enqueueingBlock = blocks[blockIndex];
1494
+ const blocks = (_c = propObject.value) != null ? _c : [];
1495
+ for (const enqueueingBlock of blocks) {
1538
1496
  const blockIndexFn = () => {
1539
1497
  return getBlockValue(currentComponent.node, propKey).findIndex((x) => x === enqueueingBlock);
1540
1498
  };
1541
- componentQueue.push({
1499
+ childEntries.push({
1542
1500
  ancestorsAndSelf: [
1543
1501
  {
1544
1502
  type: "block",
@@ -1553,6 +1511,36 @@ function walkNodeTree(node, visitor, options) {
1553
1511
  }
1554
1512
  }
1555
1513
  }
1514
+ if (slots) {
1515
+ const slotKeys = Object.keys(slots);
1516
+ for (const slotKey of slotKeys) {
1517
+ const components = slots[slotKey];
1518
+ for (const enqueueingComponent of components) {
1519
+ const parentSlotIndexFn = () => {
1520
+ const result = currentComponent.node.slots[slotKey].findIndex(
1521
+ (x) => x === enqueueingComponent
1522
+ );
1523
+ return result;
1524
+ };
1525
+ childEntries.push({
1526
+ ancestorsAndSelf: [
1527
+ {
1528
+ type: "slot",
1529
+ node: enqueueingComponent,
1530
+ parentSlot: slotKey,
1531
+ parentSlotIndexFn
1532
+ },
1533
+ ...currentQueueEntry.ancestorsAndSelf
1534
+ ],
1535
+ context: descendantContext
1536
+ });
1537
+ }
1538
+ }
1539
+ }
1540
+ if (order === "dfs") {
1541
+ childEntries.reverse();
1542
+ }
1543
+ componentQueue.push(...childEntries);
1556
1544
  } while (componentQueue.length > 0);
1557
1545
  }
1558
1546
  function isNestedNodeType(type) {
@@ -2627,10 +2615,47 @@ _baseUrl = new WeakMap();
2627
2615
  __privateAdd(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
2628
2616
  var IntegrationPropertyEditorsClient = _IntegrationPropertyEditorsClient;
2629
2617
 
2630
- // src/LocaleClient.ts
2618
+ // src/LabelClient.ts
2631
2619
  import { ApiClient as ApiClient8 } from "@uniformdev/context/api";
2620
+ var LABELS_URL = "/api/v1/labels";
2621
+ var LabelClient = class extends ApiClient8 {
2622
+ /** Fetches labels for the current project. */
2623
+ async getLabels(options) {
2624
+ const { projectId } = this.options;
2625
+ const fetchUri = this.createUrl(LABELS_URL, { ...options, projectId });
2626
+ return await this.apiClient(fetchUri);
2627
+ }
2628
+ /** Updates or creates a label. */
2629
+ async upsertLabel(body) {
2630
+ const { projectId } = this.options;
2631
+ const fetchUri = this.createUrl(LABELS_URL);
2632
+ await this.apiClient(fetchUri, {
2633
+ method: "PUT",
2634
+ body: JSON.stringify({ ...body, projectId }),
2635
+ expectNoContent: true
2636
+ });
2637
+ }
2638
+ /** Deletes a label by id. */
2639
+ async removeLabel(options) {
2640
+ const { projectId } = this.options;
2641
+ const fetchUri = this.createUrl(LABELS_URL);
2642
+ await this.apiClient(fetchUri, {
2643
+ method: "DELETE",
2644
+ body: JSON.stringify({ ...options, projectId }),
2645
+ expectNoContent: true
2646
+ });
2647
+ }
2648
+ };
2649
+ var UncachedLabelClient = class extends LabelClient {
2650
+ constructor(options) {
2651
+ super({ ...options, bypassCache: true });
2652
+ }
2653
+ };
2654
+
2655
+ // src/LocaleClient.ts
2656
+ import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
2632
2657
  var localesUrl = "/api/v1/locales";
2633
- var LocaleClient = class extends ApiClient8 {
2658
+ var LocaleClient = class extends ApiClient9 {
2634
2659
  constructor(options) {
2635
2660
  super(options);
2636
2661
  }
@@ -2685,6 +2710,12 @@ var isSelectComponentMessage = (message) => {
2685
2710
  var isReadyMessage = (message) => {
2686
2711
  return message.type === "ready";
2687
2712
  };
2713
+ var isSessionPendingMessage = (message) => {
2714
+ return message.type === "session-pending";
2715
+ };
2716
+ var isAwaitingReadyMessage = (message) => {
2717
+ return message.type === "awaiting-ready";
2718
+ };
2688
2719
  var isComponentActionMessage = (message) => {
2689
2720
  return message.type === "trigger-component-action";
2690
2721
  };
@@ -2787,6 +2818,14 @@ var createCanvasChannel = ({
2787
2818
  };
2788
2819
  postMessage(message);
2789
2820
  };
2821
+ const sessionPending = () => {
2822
+ const message = { type: "session-pending" };
2823
+ postMessage(message);
2824
+ };
2825
+ const awaitingReady = () => {
2826
+ const message = { type: "awaiting-ready" };
2827
+ postMessage(message);
2828
+ };
2790
2829
  const on = (types, handler) => {
2791
2830
  const handlerId = ++handlerCounter;
2792
2831
  handlers[handlerId] = {
@@ -2986,6 +3025,8 @@ var createCanvasChannel = ({
2986
3025
  return {
2987
3026
  broadcastTo: broadcastToItems,
2988
3027
  ready,
3028
+ sessionPending,
3029
+ awaitingReady,
2989
3030
  destroy,
2990
3031
  addBroadcastTarget,
2991
3032
  triggerComponentAction,
@@ -3016,10 +3057,10 @@ var createCanvasChannel = ({
3016
3057
  };
3017
3058
 
3018
3059
  // src/PreviewClient.ts
3019
- import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
3060
+ import { ApiClient as ApiClient10 } from "@uniformdev/context/api";
3020
3061
  var previewUrlsUrl = "/api/v1/preview-urls";
3021
3062
  var previewViewportsUrl = "/api/v1/preview-viewports";
3022
- var PreviewClient = class extends ApiClient9 {
3063
+ var PreviewClient = class extends ApiClient10 {
3023
3064
  constructor(options) {
3024
3065
  super(options);
3025
3066
  }
@@ -3082,9 +3123,9 @@ var PreviewClient = class extends ApiClient9 {
3082
3123
  };
3083
3124
 
3084
3125
  // src/ProjectClient.ts
3085
- import { ApiClient as ApiClient10 } from "@uniformdev/context/api";
3086
- var _url2;
3087
- var _ProjectClient = class _ProjectClient extends ApiClient10 {
3126
+ import { ApiClient as ApiClient11 } from "@uniformdev/context/api";
3127
+ var _url2, _projectsUrl;
3128
+ var _ProjectClient = class _ProjectClient extends ApiClient11 {
3088
3129
  constructor(options) {
3089
3130
  super({ ...options, bypassCache: true });
3090
3131
  }
@@ -3093,6 +3134,15 @@ var _ProjectClient = class _ProjectClient extends ApiClient10 {
3093
3134
  const fetchUri = this.createUrl(__privateGet(_ProjectClient, _url2), { ...options });
3094
3135
  return await this.apiClient(fetchUri);
3095
3136
  }
3137
+ /**
3138
+ * Fetches projects grouped by team.
3139
+ * When teamId is provided, returns a single team with its projects.
3140
+ * When omitted, returns all accessible teams and their projects.
3141
+ */
3142
+ async getProjects(options) {
3143
+ const fetchUri = this.createUrl(__privateGet(_ProjectClient, _projectsUrl), options ? { ...options } : {});
3144
+ return await this.apiClient(fetchUri);
3145
+ }
3096
3146
  /** Updates or creates (based on id) a Project */
3097
3147
  async upsert(body) {
3098
3148
  const fetchUri = this.createUrl(__privateGet(_ProjectClient, _url2));
@@ -3112,13 +3162,15 @@ var _ProjectClient = class _ProjectClient extends ApiClient10 {
3112
3162
  }
3113
3163
  };
3114
3164
  _url2 = new WeakMap();
3165
+ _projectsUrl = new WeakMap();
3115
3166
  __privateAdd(_ProjectClient, _url2, "/api/v1/project");
3167
+ __privateAdd(_ProjectClient, _projectsUrl, "/api/v1/projects");
3116
3168
  var ProjectClient = _ProjectClient;
3117
3169
 
3118
3170
  // src/PromptClient.ts
3119
- import { ApiClient as ApiClient11 } from "@uniformdev/context/api";
3171
+ import { ApiClient as ApiClient12 } from "@uniformdev/context/api";
3120
3172
  var PromptsUrl = "/api/v1/prompts";
3121
- var PromptClient = class extends ApiClient11 {
3173
+ var PromptClient = class extends ApiClient12 {
3122
3174
  constructor(options) {
3123
3175
  super(options);
3124
3176
  }
@@ -3149,9 +3201,9 @@ var PromptClient = class extends ApiClient11 {
3149
3201
  };
3150
3202
 
3151
3203
  // src/RelationshipClient.ts
3152
- import { ApiClient as ApiClient12 } from "@uniformdev/context/api";
3204
+ import { ApiClient as ApiClient13 } from "@uniformdev/context/api";
3153
3205
  var RELATIONSHIPS_URL = "/api/v1/relationships";
3154
- var RelationshipClient = class extends ApiClient12 {
3206
+ var RelationshipClient = class extends ApiClient13 {
3155
3207
  constructor(options) {
3156
3208
  super(options);
3157
3209
  this.get = async (options) => {
@@ -3163,9 +3215,9 @@ var RelationshipClient = class extends ApiClient12 {
3163
3215
  };
3164
3216
 
3165
3217
  // src/ReleaseClient.ts
3166
- import { ApiClient as ApiClient13 } from "@uniformdev/context/api";
3218
+ import { ApiClient as ApiClient14 } from "@uniformdev/context/api";
3167
3219
  var releasesUrl = "/api/v1/releases";
3168
- var ReleaseClient = class extends ApiClient13 {
3220
+ var ReleaseClient = class extends ApiClient14 {
3169
3221
  constructor(options) {
3170
3222
  super(options);
3171
3223
  }
@@ -3205,9 +3257,9 @@ var ReleaseClient = class extends ApiClient13 {
3205
3257
  };
3206
3258
 
3207
3259
  // src/ReleaseContentsClient.ts
3208
- import { ApiClient as ApiClient14 } from "@uniformdev/context/api";
3260
+ import { ApiClient as ApiClient15 } from "@uniformdev/context/api";
3209
3261
  var releaseContentsUrl2 = "/api/v1/release-contents";
3210
- var ReleaseContentsClient = class extends ApiClient14 {
3262
+ var ReleaseContentsClient = class extends ApiClient15 {
3211
3263
  constructor(options) {
3212
3264
  super(options);
3213
3265
  }
@@ -3229,9 +3281,9 @@ var ReleaseContentsClient = class extends ApiClient14 {
3229
3281
  };
3230
3282
 
3231
3283
  // src/RouteClient.ts
3232
- import { ApiClient as ApiClient15 } from "@uniformdev/context/api";
3284
+ import { ApiClient as ApiClient16 } from "@uniformdev/context/api";
3233
3285
  var ROUTE_URL = "/api/v1/route";
3234
- var RouteClient = class extends ApiClient15 {
3286
+ var RouteClient = class extends ApiClient16 {
3235
3287
  constructor(options) {
3236
3288
  var _a;
3237
3289
  if (!options.limitPolicy) {
@@ -3606,12 +3658,12 @@ function handleRichTextNodeBinding(object, options) {
3606
3658
  import { ApiClientError as ApiClientError2 } from "@uniformdev/context/api";
3607
3659
 
3608
3660
  // src/.version.ts
3609
- var version = "20.50.1";
3661
+ var version = "20.66.6";
3610
3662
 
3611
3663
  // src/WorkflowClient.ts
3612
- import { ApiClient as ApiClient16 } from "@uniformdev/context/api";
3664
+ import { ApiClient as ApiClient17 } from "@uniformdev/context/api";
3613
3665
  var workflowsUrl = "/api/v1/workflows";
3614
- var WorkflowClient = class extends ApiClient16 {
3666
+ var WorkflowClient = class extends ApiClient17 {
3615
3667
  constructor(options) {
3616
3668
  super(options);
3617
3669
  }
@@ -3715,11 +3767,13 @@ export {
3715
3767
  IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
3716
3768
  IntegrationPropertyEditorsClient,
3717
3769
  LOCALE_DYNAMIC_INPUT_NAME,
3770
+ LabelClient,
3718
3771
  LocaleClient,
3719
3772
  PLACEHOLDER_ID,
3720
3773
  PreviewClient,
3721
3774
  ProjectClient,
3722
3775
  PromptClient,
3776
+ REFERENCE_DATA_TYPE_ID,
3723
3777
  RelationshipClient,
3724
3778
  ReleaseClient,
3725
3779
  ReleaseContentsClient,
@@ -3728,6 +3782,7 @@ export {
3728
3782
  UncachedCanvasClient,
3729
3783
  UncachedCategoryClient,
3730
3784
  UncachedContentClient,
3785
+ UncachedLabelClient,
3731
3786
  UniqueBatchEntries,
3732
3787
  WorkflowClient,
3733
3788
  autoFixParameterGroups,
@@ -3774,6 +3829,7 @@ export {
3774
3829
  isAllowedReferrer,
3775
3830
  isAssetParamValue,
3776
3831
  isAssetParamValueItem,
3832
+ isAwaitingReadyMessage,
3777
3833
  isComponentActionMessage,
3778
3834
  isComponentPlaceholderId,
3779
3835
  isContextStorageUpdatedMessage,
@@ -3789,6 +3845,7 @@ export {
3789
3845
  isRootEntryReference,
3790
3846
  isSelectComponentMessage,
3791
3847
  isSelectParameterMessage,
3848
+ isSessionPendingMessage,
3792
3849
  isSuggestComponentMessage,
3793
3850
  isSystemComponentDefinition,
3794
3851
  isTriggerCompositionActionMessage,