@uniformdev/canvas 20.50.2-alpha.9 → 20.50.2-alpha.96

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,7 +1106,6 @@ 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";
1125
- var REFERENCE_DATA_TYPE_ID = "uniformContentInternalReference";
1126
1109
 
1127
1110
  // src/utils/guards.ts
1128
1111
  function isRootEntryReference(root) {
@@ -1281,7 +1264,7 @@ function hasReferencedVariables(value) {
1281
1264
 
1282
1265
  // src/enhancement/walkNodeTree.ts
1283
1266
  function walkNodeTree(node, visitor, options) {
1284
- var _a, _b;
1267
+ var _a, _b, _c;
1285
1268
  const componentQueue = [
1286
1269
  {
1287
1270
  ancestorsAndSelf: Array.isArray(node) ? node : [{ node, type: "root" }],
@@ -1289,12 +1272,14 @@ function walkNodeTree(node, visitor, options) {
1289
1272
  }
1290
1273
  ];
1291
1274
  const childContexts = /* @__PURE__ */ new Map();
1275
+ const order = (_a = options == null ? void 0 : options.order) != null ? _a : "dfs";
1276
+ const takeNext = () => order === "bfs" ? componentQueue.shift() : componentQueue.pop();
1292
1277
  do {
1293
- const currentQueueEntry = componentQueue.pop();
1278
+ const currentQueueEntry = takeNext();
1294
1279
  if (!currentQueueEntry) continue;
1295
1280
  const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
1296
1281
  let visitDescendants = true;
1297
- let descendantContext = (_a = childContexts.get(currentComponent.node)) != null ? _a : currentQueueEntry.context;
1282
+ let descendantContext = (_b = childContexts.get(currentComponent.node)) != null ? _b : currentQueueEntry.context;
1298
1283
  let visitorInfo;
1299
1284
  if (currentComponent.type === "root" && isRootEntryReference(currentComponent) || currentComponent.type === "block") {
1300
1285
  visitorInfo = {
@@ -1481,39 +1466,11 @@ function walkNodeTree(node, visitor, options) {
1481
1466
  continue;
1482
1467
  }
1483
1468
  const slots = "slots" in currentComponent.node && currentComponent.node.slots;
1484
- if (slots) {
1485
- const slotKeys = Object.keys(slots);
1486
- for (let slotIndex = slotKeys.length - 1; slotIndex >= 0; slotIndex--) {
1487
- const slotKey = slotKeys[slotIndex];
1488
- const components = slots[slotKey];
1489
- for (let componentIndex = components.length - 1; componentIndex >= 0; componentIndex--) {
1490
- const enqueueingComponent = components[componentIndex];
1491
- const parentSlotIndexFn = () => {
1492
- const result = currentComponent.node.slots[slotKey].findIndex(
1493
- (x) => x === enqueueingComponent
1494
- );
1495
- return result;
1496
- };
1497
- componentQueue.push({
1498
- ancestorsAndSelf: [
1499
- {
1500
- type: "slot",
1501
- node: enqueueingComponent,
1502
- parentSlot: slotKey,
1503
- parentSlotIndexFn
1504
- },
1505
- ...currentQueueEntry.ancestorsAndSelf
1506
- ],
1507
- context: descendantContext
1508
- });
1509
- }
1510
- }
1511
- }
1469
+ const childEntries = [];
1512
1470
  const properties = getPropertiesValue(currentComponent.node);
1513
1471
  if (properties) {
1514
1472
  const propertyEntries = Object.entries(properties);
1515
- for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
1516
- const [propKey, propObject] = propertyEntries[propIndex];
1473
+ for (const [propKey, propObject] of propertyEntries) {
1517
1474
  if (!isNestedNodeType(propObject.type)) {
1518
1475
  continue;
1519
1476
  }
@@ -1533,13 +1490,12 @@ function walkNodeTree(node, visitor, options) {
1533
1490
  continue;
1534
1491
  }
1535
1492
  }
1536
- const blocks = (_b = propObject.value) != null ? _b : [];
1537
- for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
1538
- const enqueueingBlock = blocks[blockIndex];
1493
+ const blocks = (_c = propObject.value) != null ? _c : [];
1494
+ for (const enqueueingBlock of blocks) {
1539
1495
  const blockIndexFn = () => {
1540
1496
  return getBlockValue(currentComponent.node, propKey).findIndex((x) => x === enqueueingBlock);
1541
1497
  };
1542
- componentQueue.push({
1498
+ childEntries.push({
1543
1499
  ancestorsAndSelf: [
1544
1500
  {
1545
1501
  type: "block",
@@ -1554,6 +1510,36 @@ function walkNodeTree(node, visitor, options) {
1554
1510
  }
1555
1511
  }
1556
1512
  }
1513
+ if (slots) {
1514
+ const slotKeys = Object.keys(slots);
1515
+ for (const slotKey of slotKeys) {
1516
+ const components = slots[slotKey];
1517
+ for (const enqueueingComponent of components) {
1518
+ const parentSlotIndexFn = () => {
1519
+ const result = currentComponent.node.slots[slotKey].findIndex(
1520
+ (x) => x === enqueueingComponent
1521
+ );
1522
+ return result;
1523
+ };
1524
+ childEntries.push({
1525
+ ancestorsAndSelf: [
1526
+ {
1527
+ type: "slot",
1528
+ node: enqueueingComponent,
1529
+ parentSlot: slotKey,
1530
+ parentSlotIndexFn
1531
+ },
1532
+ ...currentQueueEntry.ancestorsAndSelf
1533
+ ],
1534
+ context: descendantContext
1535
+ });
1536
+ }
1537
+ }
1538
+ }
1539
+ if (order === "dfs") {
1540
+ childEntries.reverse();
1541
+ }
1542
+ componentQueue.push(...childEntries);
1557
1543
  } while (componentQueue.length > 0);
1558
1544
  }
1559
1545
  function isNestedNodeType(type) {
@@ -2628,10 +2614,47 @@ _baseUrl = new WeakMap();
2628
2614
  __privateAdd(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
2629
2615
  var IntegrationPropertyEditorsClient = _IntegrationPropertyEditorsClient;
2630
2616
 
2631
- // src/LocaleClient.ts
2617
+ // src/LabelClient.ts
2632
2618
  import { ApiClient as ApiClient8 } from "@uniformdev/context/api";
2619
+ var LABELS_URL = "/api/v1/labels";
2620
+ var LabelClient = class extends ApiClient8 {
2621
+ /** Fetches labels for the current project. */
2622
+ async getLabels(options) {
2623
+ const { projectId } = this.options;
2624
+ const fetchUri = this.createUrl(LABELS_URL, { ...options, projectId });
2625
+ return await this.apiClient(fetchUri);
2626
+ }
2627
+ /** Updates or creates a label. */
2628
+ async upsertLabel(body) {
2629
+ const { projectId } = this.options;
2630
+ const fetchUri = this.createUrl(LABELS_URL);
2631
+ await this.apiClient(fetchUri, {
2632
+ method: "PUT",
2633
+ body: JSON.stringify({ ...body, projectId }),
2634
+ expectNoContent: true
2635
+ });
2636
+ }
2637
+ /** Deletes a label by id. */
2638
+ async removeLabel(options) {
2639
+ const { projectId } = this.options;
2640
+ const fetchUri = this.createUrl(LABELS_URL);
2641
+ await this.apiClient(fetchUri, {
2642
+ method: "DELETE",
2643
+ body: JSON.stringify({ ...options, projectId }),
2644
+ expectNoContent: true
2645
+ });
2646
+ }
2647
+ };
2648
+ var UncachedLabelClient = class extends LabelClient {
2649
+ constructor(options) {
2650
+ super({ ...options, bypassCache: true });
2651
+ }
2652
+ };
2653
+
2654
+ // src/LocaleClient.ts
2655
+ import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
2633
2656
  var localesUrl = "/api/v1/locales";
2634
- var LocaleClient = class extends ApiClient8 {
2657
+ var LocaleClient = class extends ApiClient9 {
2635
2658
  constructor(options) {
2636
2659
  super(options);
2637
2660
  }
@@ -2686,6 +2709,12 @@ var isSelectComponentMessage = (message) => {
2686
2709
  var isReadyMessage = (message) => {
2687
2710
  return message.type === "ready";
2688
2711
  };
2712
+ var isSessionPendingMessage = (message) => {
2713
+ return message.type === "session-pending";
2714
+ };
2715
+ var isAwaitingReadyMessage = (message) => {
2716
+ return message.type === "awaiting-ready";
2717
+ };
2689
2718
  var isComponentActionMessage = (message) => {
2690
2719
  return message.type === "trigger-component-action";
2691
2720
  };
@@ -2788,6 +2817,14 @@ var createCanvasChannel = ({
2788
2817
  };
2789
2818
  postMessage(message);
2790
2819
  };
2820
+ const sessionPending = () => {
2821
+ const message = { type: "session-pending" };
2822
+ postMessage(message);
2823
+ };
2824
+ const awaitingReady = () => {
2825
+ const message = { type: "awaiting-ready" };
2826
+ postMessage(message);
2827
+ };
2791
2828
  const on = (types, handler) => {
2792
2829
  const handlerId = ++handlerCounter;
2793
2830
  handlers[handlerId] = {
@@ -2987,6 +3024,8 @@ var createCanvasChannel = ({
2987
3024
  return {
2988
3025
  broadcastTo: broadcastToItems,
2989
3026
  ready,
3027
+ sessionPending,
3028
+ awaitingReady,
2990
3029
  destroy,
2991
3030
  addBroadcastTarget,
2992
3031
  triggerComponentAction,
@@ -3017,10 +3056,10 @@ var createCanvasChannel = ({
3017
3056
  };
3018
3057
 
3019
3058
  // src/PreviewClient.ts
3020
- import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
3059
+ import { ApiClient as ApiClient10 } from "@uniformdev/context/api";
3021
3060
  var previewUrlsUrl = "/api/v1/preview-urls";
3022
3061
  var previewViewportsUrl = "/api/v1/preview-viewports";
3023
- var PreviewClient = class extends ApiClient9 {
3062
+ var PreviewClient = class extends ApiClient10 {
3024
3063
  constructor(options) {
3025
3064
  super(options);
3026
3065
  }
@@ -3083,9 +3122,9 @@ var PreviewClient = class extends ApiClient9 {
3083
3122
  };
3084
3123
 
3085
3124
  // src/ProjectClient.ts
3086
- import { ApiClient as ApiClient10 } from "@uniformdev/context/api";
3087
- var _url2;
3088
- var _ProjectClient = class _ProjectClient extends ApiClient10 {
3125
+ import { ApiClient as ApiClient11 } from "@uniformdev/context/api";
3126
+ var _url2, _projectsUrl;
3127
+ var _ProjectClient = class _ProjectClient extends ApiClient11 {
3089
3128
  constructor(options) {
3090
3129
  super({ ...options, bypassCache: true });
3091
3130
  }
@@ -3094,6 +3133,15 @@ var _ProjectClient = class _ProjectClient extends ApiClient10 {
3094
3133
  const fetchUri = this.createUrl(__privateGet(_ProjectClient, _url2), { ...options });
3095
3134
  return await this.apiClient(fetchUri);
3096
3135
  }
3136
+ /**
3137
+ * Fetches projects grouped by team.
3138
+ * When teamId is provided, returns a single team with its projects.
3139
+ * When omitted, returns all accessible teams and their projects.
3140
+ */
3141
+ async getProjects(options) {
3142
+ const fetchUri = this.createUrl(__privateGet(_ProjectClient, _projectsUrl), options ? { ...options } : {});
3143
+ return await this.apiClient(fetchUri);
3144
+ }
3097
3145
  /** Updates or creates (based on id) a Project */
3098
3146
  async upsert(body) {
3099
3147
  const fetchUri = this.createUrl(__privateGet(_ProjectClient, _url2));
@@ -3113,13 +3161,15 @@ var _ProjectClient = class _ProjectClient extends ApiClient10 {
3113
3161
  }
3114
3162
  };
3115
3163
  _url2 = new WeakMap();
3164
+ _projectsUrl = new WeakMap();
3116
3165
  __privateAdd(_ProjectClient, _url2, "/api/v1/project");
3166
+ __privateAdd(_ProjectClient, _projectsUrl, "/api/v1/projects");
3117
3167
  var ProjectClient = _ProjectClient;
3118
3168
 
3119
3169
  // src/PromptClient.ts
3120
- import { ApiClient as ApiClient11 } from "@uniformdev/context/api";
3170
+ import { ApiClient as ApiClient12 } from "@uniformdev/context/api";
3121
3171
  var PromptsUrl = "/api/v1/prompts";
3122
- var PromptClient = class extends ApiClient11 {
3172
+ var PromptClient = class extends ApiClient12 {
3123
3173
  constructor(options) {
3124
3174
  super(options);
3125
3175
  }
@@ -3150,9 +3200,9 @@ var PromptClient = class extends ApiClient11 {
3150
3200
  };
3151
3201
 
3152
3202
  // src/RelationshipClient.ts
3153
- import { ApiClient as ApiClient12 } from "@uniformdev/context/api";
3203
+ import { ApiClient as ApiClient13 } from "@uniformdev/context/api";
3154
3204
  var RELATIONSHIPS_URL = "/api/v1/relationships";
3155
- var RelationshipClient = class extends ApiClient12 {
3205
+ var RelationshipClient = class extends ApiClient13 {
3156
3206
  constructor(options) {
3157
3207
  super(options);
3158
3208
  this.get = async (options) => {
@@ -3164,9 +3214,9 @@ var RelationshipClient = class extends ApiClient12 {
3164
3214
  };
3165
3215
 
3166
3216
  // src/ReleaseClient.ts
3167
- import { ApiClient as ApiClient13 } from "@uniformdev/context/api";
3217
+ import { ApiClient as ApiClient14 } from "@uniformdev/context/api";
3168
3218
  var releasesUrl = "/api/v1/releases";
3169
- var ReleaseClient = class extends ApiClient13 {
3219
+ var ReleaseClient = class extends ApiClient14 {
3170
3220
  constructor(options) {
3171
3221
  super(options);
3172
3222
  }
@@ -3206,9 +3256,9 @@ var ReleaseClient = class extends ApiClient13 {
3206
3256
  };
3207
3257
 
3208
3258
  // src/ReleaseContentsClient.ts
3209
- import { ApiClient as ApiClient14 } from "@uniformdev/context/api";
3259
+ import { ApiClient as ApiClient15 } from "@uniformdev/context/api";
3210
3260
  var releaseContentsUrl2 = "/api/v1/release-contents";
3211
- var ReleaseContentsClient = class extends ApiClient14 {
3261
+ var ReleaseContentsClient = class extends ApiClient15 {
3212
3262
  constructor(options) {
3213
3263
  super(options);
3214
3264
  }
@@ -3230,9 +3280,9 @@ var ReleaseContentsClient = class extends ApiClient14 {
3230
3280
  };
3231
3281
 
3232
3282
  // src/RouteClient.ts
3233
- import { ApiClient as ApiClient15 } from "@uniformdev/context/api";
3283
+ import { ApiClient as ApiClient16 } from "@uniformdev/context/api";
3234
3284
  var ROUTE_URL = "/api/v1/route";
3235
- var RouteClient = class extends ApiClient15 {
3285
+ var RouteClient = class extends ApiClient16 {
3236
3286
  constructor(options) {
3237
3287
  var _a;
3238
3288
  if (!options.limitPolicy) {
@@ -3607,12 +3657,12 @@ function handleRichTextNodeBinding(object, options) {
3607
3657
  import { ApiClientError as ApiClientError2 } from "@uniformdev/context/api";
3608
3658
 
3609
3659
  // src/.version.ts
3610
- var version = "20.50.1";
3660
+ var version = "20.63.0";
3611
3661
 
3612
3662
  // src/WorkflowClient.ts
3613
- import { ApiClient as ApiClient16 } from "@uniformdev/context/api";
3663
+ import { ApiClient as ApiClient17 } from "@uniformdev/context/api";
3614
3664
  var workflowsUrl = "/api/v1/workflows";
3615
- var WorkflowClient = class extends ApiClient16 {
3665
+ var WorkflowClient = class extends ApiClient17 {
3616
3666
  constructor(options) {
3617
3667
  super(options);
3618
3668
  }
@@ -3716,12 +3766,12 @@ export {
3716
3766
  IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
3717
3767
  IntegrationPropertyEditorsClient,
3718
3768
  LOCALE_DYNAMIC_INPUT_NAME,
3769
+ LabelClient,
3719
3770
  LocaleClient,
3720
3771
  PLACEHOLDER_ID,
3721
3772
  PreviewClient,
3722
3773
  ProjectClient,
3723
3774
  PromptClient,
3724
- REFERENCE_DATA_TYPE_ID,
3725
3775
  RelationshipClient,
3726
3776
  ReleaseClient,
3727
3777
  ReleaseContentsClient,
@@ -3730,6 +3780,7 @@ export {
3730
3780
  UncachedCanvasClient,
3731
3781
  UncachedCategoryClient,
3732
3782
  UncachedContentClient,
3783
+ UncachedLabelClient,
3733
3784
  UniqueBatchEntries,
3734
3785
  WorkflowClient,
3735
3786
  autoFixParameterGroups,
@@ -3776,6 +3827,7 @@ export {
3776
3827
  isAllowedReferrer,
3777
3828
  isAssetParamValue,
3778
3829
  isAssetParamValueItem,
3830
+ isAwaitingReadyMessage,
3779
3831
  isComponentActionMessage,
3780
3832
  isComponentPlaceholderId,
3781
3833
  isContextStorageUpdatedMessage,
@@ -3791,6 +3843,7 @@ export {
3791
3843
  isRootEntryReference,
3792
3844
  isSelectComponentMessage,
3793
3845
  isSelectParameterMessage,
3846
+ isSessionPendingMessage,
3794
3847
  isSuggestComponentMessage,
3795
3848
  isSystemComponentDefinition,
3796
3849
  isTriggerCompositionActionMessage,