@uniformdev/canvas 20.49.2 → 20.49.3-alpha.47

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.mjs CHANGED
@@ -1,560 +1,25 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
1
  var __typeError = (msg) => {
8
2
  throw TypeError(msg);
9
3
  };
10
- var __commonJS = (cb, mod) => function __require() {
11
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
4
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
30
5
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
31
6
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
32
7
 
33
- // ../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js
34
- var require_yocto_queue = __commonJS({
35
- "../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports, module) {
36
- "use strict";
37
- var Node = class {
38
- /// value;
39
- /// next;
40
- constructor(value) {
41
- this.value = value;
42
- this.next = void 0;
43
- }
44
- };
45
- var Queue = class {
46
- // TODO: Use private class fields when targeting Node.js 12.
47
- // #_head;
48
- // #_tail;
49
- // #_size;
50
- constructor() {
51
- this.clear();
52
- }
53
- enqueue(value) {
54
- const node = new Node(value);
55
- if (this._head) {
56
- this._tail.next = node;
57
- this._tail = node;
58
- } else {
59
- this._head = node;
60
- this._tail = node;
61
- }
62
- this._size++;
63
- }
64
- dequeue() {
65
- const current = this._head;
66
- if (!current) {
67
- return;
68
- }
69
- this._head = this._head.next;
70
- this._size--;
71
- return current.value;
72
- }
73
- clear() {
74
- this._head = void 0;
75
- this._tail = void 0;
76
- this._size = 0;
77
- }
78
- get size() {
79
- return this._size;
80
- }
81
- *[Symbol.iterator]() {
82
- let current = this._head;
83
- while (current) {
84
- yield current.value;
85
- current = current.next;
86
- }
87
- }
88
- };
89
- module.exports = Queue;
90
- }
91
- });
92
-
93
- // ../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js
94
- var require_p_limit = __commonJS({
95
- "../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports, module) {
96
- "use strict";
97
- var Queue = require_yocto_queue();
98
- var pLimit2 = (concurrency) => {
99
- if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
100
- throw new TypeError("Expected `concurrency` to be a number from 1 and up");
101
- }
102
- const queue = new Queue();
103
- let activeCount = 0;
104
- const next = () => {
105
- activeCount--;
106
- if (queue.size > 0) {
107
- queue.dequeue()();
108
- }
109
- };
110
- const run = async (fn, resolve, ...args) => {
111
- activeCount++;
112
- const result = (async () => fn(...args))();
113
- resolve(result);
114
- try {
115
- await result;
116
- } catch (e) {
117
- }
118
- next();
119
- };
120
- const enqueue = (fn, resolve, ...args) => {
121
- queue.enqueue(run.bind(null, fn, resolve, ...args));
122
- (async () => {
123
- await Promise.resolve();
124
- if (activeCount < concurrency && queue.size > 0) {
125
- queue.dequeue()();
126
- }
127
- })();
128
- };
129
- const generator = (fn, ...args) => new Promise((resolve) => {
130
- enqueue(fn, resolve, ...args);
131
- });
132
- Object.defineProperties(generator, {
133
- activeCount: {
134
- get: () => activeCount
135
- },
136
- pendingCount: {
137
- get: () => queue.size
138
- },
139
- clearQueue: {
140
- value: () => {
141
- queue.clear();
142
- }
143
- }
144
- });
145
- return generator;
146
- };
147
- module.exports = pLimit2;
148
- }
149
- });
150
-
151
- // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js
152
- var require_retry_operation = __commonJS({
153
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports, module) {
154
- "use strict";
155
- function RetryOperation(timeouts, options) {
156
- if (typeof options === "boolean") {
157
- options = { forever: options };
158
- }
159
- this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
160
- this._timeouts = timeouts;
161
- this._options = options || {};
162
- this._maxRetryTime = options && options.maxRetryTime || Infinity;
163
- this._fn = null;
164
- this._errors = [];
165
- this._attempts = 1;
166
- this._operationTimeout = null;
167
- this._operationTimeoutCb = null;
168
- this._timeout = null;
169
- this._operationStart = null;
170
- this._timer = null;
171
- if (this._options.forever) {
172
- this._cachedTimeouts = this._timeouts.slice(0);
173
- }
174
- }
175
- module.exports = RetryOperation;
176
- RetryOperation.prototype.reset = function() {
177
- this._attempts = 1;
178
- this._timeouts = this._originalTimeouts.slice(0);
179
- };
180
- RetryOperation.prototype.stop = function() {
181
- if (this._timeout) {
182
- clearTimeout(this._timeout);
183
- }
184
- if (this._timer) {
185
- clearTimeout(this._timer);
186
- }
187
- this._timeouts = [];
188
- this._cachedTimeouts = null;
189
- };
190
- RetryOperation.prototype.retry = function(err) {
191
- if (this._timeout) {
192
- clearTimeout(this._timeout);
193
- }
194
- if (!err) {
195
- return false;
196
- }
197
- var currentTime = (/* @__PURE__ */ new Date()).getTime();
198
- if (err && currentTime - this._operationStart >= this._maxRetryTime) {
199
- this._errors.push(err);
200
- this._errors.unshift(new Error("RetryOperation timeout occurred"));
201
- return false;
202
- }
203
- this._errors.push(err);
204
- var timeout = this._timeouts.shift();
205
- if (timeout === void 0) {
206
- if (this._cachedTimeouts) {
207
- this._errors.splice(0, this._errors.length - 1);
208
- timeout = this._cachedTimeouts.slice(-1);
209
- } else {
210
- return false;
211
- }
212
- }
213
- var self = this;
214
- this._timer = setTimeout(function() {
215
- self._attempts++;
216
- if (self._operationTimeoutCb) {
217
- self._timeout = setTimeout(function() {
218
- self._operationTimeoutCb(self._attempts);
219
- }, self._operationTimeout);
220
- if (self._options.unref) {
221
- self._timeout.unref();
222
- }
223
- }
224
- self._fn(self._attempts);
225
- }, timeout);
226
- if (this._options.unref) {
227
- this._timer.unref();
228
- }
229
- return true;
230
- };
231
- RetryOperation.prototype.attempt = function(fn, timeoutOps) {
232
- this._fn = fn;
233
- if (timeoutOps) {
234
- if (timeoutOps.timeout) {
235
- this._operationTimeout = timeoutOps.timeout;
236
- }
237
- if (timeoutOps.cb) {
238
- this._operationTimeoutCb = timeoutOps.cb;
239
- }
240
- }
241
- var self = this;
242
- if (this._operationTimeoutCb) {
243
- this._timeout = setTimeout(function() {
244
- self._operationTimeoutCb();
245
- }, self._operationTimeout);
246
- }
247
- this._operationStart = (/* @__PURE__ */ new Date()).getTime();
248
- this._fn(this._attempts);
249
- };
250
- RetryOperation.prototype.try = function(fn) {
251
- console.log("Using RetryOperation.try() is deprecated");
252
- this.attempt(fn);
253
- };
254
- RetryOperation.prototype.start = function(fn) {
255
- console.log("Using RetryOperation.start() is deprecated");
256
- this.attempt(fn);
257
- };
258
- RetryOperation.prototype.start = RetryOperation.prototype.try;
259
- RetryOperation.prototype.errors = function() {
260
- return this._errors;
261
- };
262
- RetryOperation.prototype.attempts = function() {
263
- return this._attempts;
264
- };
265
- RetryOperation.prototype.mainError = function() {
266
- if (this._errors.length === 0) {
267
- return null;
268
- }
269
- var counts = {};
270
- var mainError = null;
271
- var mainErrorCount = 0;
272
- for (var i = 0; i < this._errors.length; i++) {
273
- var error = this._errors[i];
274
- var message = error.message;
275
- var count = (counts[message] || 0) + 1;
276
- counts[message] = count;
277
- if (count >= mainErrorCount) {
278
- mainError = error;
279
- mainErrorCount = count;
280
- }
281
- }
282
- return mainError;
283
- };
284
- }
285
- });
286
-
287
- // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js
288
- var require_retry = __commonJS({
289
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports) {
290
- "use strict";
291
- var RetryOperation = require_retry_operation();
292
- exports.operation = function(options) {
293
- var timeouts = exports.timeouts(options);
294
- return new RetryOperation(timeouts, {
295
- forever: options && (options.forever || options.retries === Infinity),
296
- unref: options && options.unref,
297
- maxRetryTime: options && options.maxRetryTime
298
- });
299
- };
300
- exports.timeouts = function(options) {
301
- if (options instanceof Array) {
302
- return [].concat(options);
303
- }
304
- var opts = {
305
- retries: 10,
306
- factor: 2,
307
- minTimeout: 1 * 1e3,
308
- maxTimeout: Infinity,
309
- randomize: false
310
- };
311
- for (var key in options) {
312
- opts[key] = options[key];
313
- }
314
- if (opts.minTimeout > opts.maxTimeout) {
315
- throw new Error("minTimeout is greater than maxTimeout");
316
- }
317
- var timeouts = [];
318
- for (var i = 0; i < opts.retries; i++) {
319
- timeouts.push(this.createTimeout(i, opts));
320
- }
321
- if (options && options.forever && !timeouts.length) {
322
- timeouts.push(this.createTimeout(i, opts));
323
- }
324
- timeouts.sort(function(a, b) {
325
- return a - b;
326
- });
327
- return timeouts;
328
- };
329
- exports.createTimeout = function(attempt, opts) {
330
- var random = opts.randomize ? Math.random() + 1 : 1;
331
- var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
332
- timeout = Math.min(timeout, opts.maxTimeout);
333
- return timeout;
334
- };
335
- exports.wrap = function(obj, options, methods) {
336
- if (options instanceof Array) {
337
- methods = options;
338
- options = null;
339
- }
340
- if (!methods) {
341
- methods = [];
342
- for (var key in obj) {
343
- if (typeof obj[key] === "function") {
344
- methods.push(key);
345
- }
346
- }
347
- }
348
- for (var i = 0; i < methods.length; i++) {
349
- var method = methods[i];
350
- var original = obj[method];
351
- obj[method] = function retryWrapper(original2) {
352
- var op = exports.operation(options);
353
- var args = Array.prototype.slice.call(arguments, 1);
354
- var callback = args.pop();
355
- args.push(function(err) {
356
- if (op.retry(err)) {
357
- return;
358
- }
359
- if (err) {
360
- arguments[0] = op.mainError();
361
- }
362
- callback.apply(this, arguments);
363
- });
364
- op.attempt(function() {
365
- original2.apply(obj, args);
366
- });
367
- }.bind(obj, original);
368
- obj[method].options = options;
369
- }
370
- };
371
- }
372
- });
373
-
374
- // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js
375
- var require_retry2 = __commonJS({
376
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports, module) {
377
- "use strict";
378
- module.exports = require_retry();
379
- }
380
- });
381
-
382
8
  // src/CanvasClient.ts
383
- import { ApiClient } from "@uniformdev/context/api";
9
+ import { ApiClient, rewriteFiltersForApi } from "@uniformdev/context/api";
384
10
 
385
11
  // src/enhancement/createLimitPolicy.ts
386
- var import_p_limit = __toESM(require_p_limit());
387
12
  import { ApiClientError } from "@uniformdev/context/api";
388
-
389
- // ../../node_modules/.pnpm/p-retry@5.1.2/node_modules/p-retry/index.js
390
- var import_retry = __toESM(require_retry2(), 1);
391
- var networkErrorMsgs = /* @__PURE__ */ new Set([
392
- "Failed to fetch",
393
- // Chrome
394
- "NetworkError when attempting to fetch resource.",
395
- // Firefox
396
- "The Internet connection appears to be offline.",
397
- // Safari
398
- "Network request failed",
399
- // `cross-fetch`
400
- "fetch failed"
401
- // Undici (Node.js)
402
- ]);
403
- var AbortError = class extends Error {
404
- constructor(message) {
405
- super();
406
- if (message instanceof Error) {
407
- this.originalError = message;
408
- ({ message } = message);
409
- } else {
410
- this.originalError = new Error(message);
411
- this.originalError.stack = this.stack;
412
- }
413
- this.name = "AbortError";
414
- this.message = message;
415
- }
416
- };
417
- var decorateErrorWithCounts = (error, attemptNumber, options) => {
418
- const retriesLeft = options.retries - (attemptNumber - 1);
419
- error.attemptNumber = attemptNumber;
420
- error.retriesLeft = retriesLeft;
421
- return error;
422
- };
423
- var isNetworkError = (errorMessage) => networkErrorMsgs.has(errorMessage);
424
- var getDOMException = (errorMessage) => globalThis.DOMException === void 0 ? new Error(errorMessage) : new DOMException(errorMessage);
425
- async function pRetry(input, options) {
426
- return new Promise((resolve, reject) => {
427
- options = {
428
- onFailedAttempt() {
429
- },
430
- retries: 10,
431
- ...options
432
- };
433
- const operation = import_retry.default.operation(options);
434
- operation.attempt(async (attemptNumber) => {
435
- try {
436
- resolve(await input(attemptNumber));
437
- } catch (error) {
438
- if (!(error instanceof Error)) {
439
- reject(new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`));
440
- return;
441
- }
442
- if (error instanceof AbortError) {
443
- operation.stop();
444
- reject(error.originalError);
445
- } else if (error instanceof TypeError && !isNetworkError(error.message)) {
446
- operation.stop();
447
- reject(error);
448
- } else {
449
- decorateErrorWithCounts(error, attemptNumber, options);
450
- try {
451
- await options.onFailedAttempt(error);
452
- } catch (error2) {
453
- reject(error2);
454
- return;
455
- }
456
- if (!operation.retry(error)) {
457
- reject(operation.mainError());
458
- }
459
- }
460
- }
461
- });
462
- if (options.signal && !options.signal.aborted) {
463
- options.signal.addEventListener("abort", () => {
464
- operation.stop();
465
- const reason = options.signal.reason === void 0 ? getDOMException("The operation was aborted.") : options.signal.reason;
466
- reject(reason instanceof Error ? reason : getDOMException(reason));
467
- }, {
468
- once: true
469
- });
470
- }
471
- });
472
- }
473
-
474
- // ../../node_modules/.pnpm/p-throttle@5.0.0/node_modules/p-throttle/index.js
475
- var AbortError2 = class extends Error {
476
- constructor() {
477
- super("Throttled function aborted");
478
- this.name = "AbortError";
479
- }
480
- };
481
- function pThrottle({ limit, interval, strict }) {
482
- if (!Number.isFinite(limit)) {
483
- throw new TypeError("Expected `limit` to be a finite number");
484
- }
485
- if (!Number.isFinite(interval)) {
486
- throw new TypeError("Expected `interval` to be a finite number");
487
- }
488
- const queue = /* @__PURE__ */ new Map();
489
- let currentTick = 0;
490
- let activeCount = 0;
491
- function windowedDelay() {
492
- const now = Date.now();
493
- if (now - currentTick > interval) {
494
- activeCount = 1;
495
- currentTick = now;
496
- return 0;
497
- }
498
- if (activeCount < limit) {
499
- activeCount++;
500
- } else {
501
- currentTick += interval;
502
- activeCount = 1;
503
- }
504
- return currentTick - now;
505
- }
506
- const strictTicks = [];
507
- function strictDelay() {
508
- const now = Date.now();
509
- if (strictTicks.length < limit) {
510
- strictTicks.push(now);
511
- return 0;
512
- }
513
- const earliestTime = strictTicks.shift() + interval;
514
- if (now >= earliestTime) {
515
- strictTicks.push(now);
516
- return 0;
517
- }
518
- strictTicks.push(earliestTime);
519
- return earliestTime - now;
520
- }
521
- const getDelay = strict ? strictDelay : windowedDelay;
522
- return (function_) => {
523
- const throttled = function(...args) {
524
- if (!throttled.isEnabled) {
525
- return (async () => function_.apply(this, args))();
526
- }
527
- let timeout;
528
- return new Promise((resolve, reject) => {
529
- const execute = () => {
530
- resolve(function_.apply(this, args));
531
- queue.delete(timeout);
532
- };
533
- timeout = setTimeout(execute, getDelay());
534
- queue.set(timeout, reject);
535
- });
536
- };
537
- throttled.abort = () => {
538
- for (const timeout of queue.keys()) {
539
- clearTimeout(timeout);
540
- queue.get(timeout)(new AbortError2());
541
- }
542
- queue.clear();
543
- strictTicks.splice(0, strictTicks.length);
544
- };
545
- throttled.isEnabled = true;
546
- return throttled;
547
- };
548
- }
549
-
550
- // src/enhancement/createLimitPolicy.ts
13
+ import pLimit from "p-limit";
14
+ import pRetry from "p-retry";
15
+ import pThrottle from "p-throttle";
551
16
  function createLimitPolicy({
552
17
  throttle = { interval: 1e3, limit: 10 },
553
- retry: retry2 = { retries: 1, factor: 1.66 },
18
+ retry = { retries: 1, factor: 1.66 },
554
19
  limit = 10
555
20
  }) {
556
21
  const throttler = throttle ? pThrottle(throttle) : null;
557
- const limiter = limit ? (0, import_p_limit.default)(limit) : null;
22
+ const limiter = limit ? pLimit(limit) : null;
558
23
  return function limitPolicy(func) {
559
24
  let currentFunc = async () => await func();
560
25
  if (throttler) {
@@ -565,13 +30,13 @@ function createLimitPolicy({
565
30
  const limitFunc = currentFunc;
566
31
  currentFunc = () => limiter(limitFunc);
567
32
  }
568
- if (retry2) {
33
+ if (retry) {
569
34
  const retryFunc = currentFunc;
570
35
  currentFunc = () => pRetry(retryFunc, {
571
- ...retry2,
36
+ ...retry,
572
37
  onFailedAttempt: async (error) => {
573
- if (retry2.onFailedAttempt) {
574
- await retry2.onFailedAttempt(error);
38
+ if (retry.onFailedAttempt) {
39
+ await retry.onFailedAttempt(error);
575
40
  }
576
41
  if (error instanceof ApiClientError && typeof error.statusCode === "number" && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429 && error.statusCode !== 408) {
577
42
  throw error;
@@ -584,20 +49,52 @@ function createLimitPolicy({
584
49
  }
585
50
  var nullLimitPolicy = async (func) => await func();
586
51
 
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
- );
52
+ // src/projection/types.ts
53
+ var SELECT_QUERY_PREFIX = "select.";
54
+
55
+ // src/projection/projectionToQuery.ts
56
+ function appendCsv(out, key, values) {
57
+ if (values === void 0) {
58
+ return;
59
+ }
60
+ out[key] = values.join(",");
61
+ }
62
+ function projectionToQuery(spec) {
63
+ const out = {};
64
+ if (!spec) {
65
+ return out;
66
+ }
67
+ const { fields, fieldTypes, slots } = spec;
68
+ const p = SELECT_QUERY_PREFIX;
69
+ if (fields) {
70
+ appendCsv(out, `${p}fields[only]`, fields.only);
71
+ appendCsv(out, `${p}fields[except]`, fields.except);
72
+ appendCsv(out, `${p}fields[locales]`, fields.locales);
73
+ if (fields.blockDepth === "preserveAll" || typeof fields.blockDepth === "number") {
74
+ out[`${p}fields[blockDepth]`] = String(fields.blockDepth);
75
+ }
76
+ }
77
+ if (fieldTypes) {
78
+ appendCsv(out, `${p}fieldTypes[only]`, fieldTypes.only);
79
+ appendCsv(out, `${p}fieldTypes[except]`, fieldTypes.except);
80
+ }
81
+ if (slots) {
82
+ appendCsv(out, `${p}slots[only]`, slots.only);
83
+ appendCsv(out, `${p}slots[except]`, slots.except);
84
+ if (typeof slots.depth === "number") {
85
+ out[`${p}slots[depth]`] = String(slots.depth);
86
+ }
87
+ if (slots.named) {
88
+ const slotNames = Object.keys(slots.named).sort();
89
+ for (const slotName of slotNames) {
90
+ const named = slots.named[slotName];
91
+ if (named && typeof named.depth === "number") {
92
+ out[`${p}slots.${slotName}[depth]`] = String(named.depth);
93
+ }
94
+ }
95
+ }
96
+ }
97
+ return out;
601
98
  }
602
99
 
603
100
  // src/CanvasClient.ts
@@ -615,17 +112,24 @@ var CanvasClient = class extends ApiClient {
615
112
  /** Fetches lists of Canvas compositions, optionally by type */
616
113
  async getCompositionList(params = {}) {
617
114
  const { projectId } = this.options;
618
- const { resolveData, filters, ...originParams } = params;
619
- const rewrittenFilters = rewriteFilters(filters);
115
+ const { resolveData, filters, select, ...originParams } = params;
116
+ const rewrittenFilters = rewriteFiltersForApi(filters);
117
+ const rewrittenSelect = projectionToQuery(select);
620
118
  if (!resolveData) {
621
- const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
119
+ const fetchUri = this.createUrl(CANVAS_URL, {
120
+ ...originParams,
121
+ projectId,
122
+ ...rewrittenFilters,
123
+ ...rewrittenSelect
124
+ });
622
125
  return this.apiClient(fetchUri);
623
126
  }
624
127
  const edgeParams = {
625
128
  ...originParams,
626
129
  projectId,
627
130
  diagnostics: typeof params.diagnostics === "boolean" ? params.diagnostics : params.diagnostics === "no-data" ? "no-data" : void 0,
628
- ...rewrittenFilters
131
+ ...rewrittenFilters,
132
+ ...rewrittenSelect
629
133
  };
630
134
  const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
631
135
  return this.apiClient(edgeUrl, this.edgeApiRequestInit);
@@ -770,7 +274,7 @@ var UncachedCategoryClient = class extends CategoryClient {
770
274
  };
771
275
 
772
276
  // src/ContentClient.ts
773
- import { ApiClient as ApiClient3 } from "@uniformdev/context/api";
277
+ import { ApiClient as ApiClient3, rewriteFiltersForApi as rewriteFiltersForApi2 } from "@uniformdev/context/api";
774
278
  var _contentTypesUrl, _entriesUrl;
775
279
  var _ContentClient = class _ContentClient extends ApiClient3 {
776
280
  constructor(options) {
@@ -785,15 +289,21 @@ var _ContentClient = class _ContentClient extends ApiClient3 {
785
289
  }
786
290
  getEntries(options) {
787
291
  const { projectId } = this.options;
788
- const { skipDataResolution, filters, ...params } = options;
789
- const rewrittenFilters = rewriteFilters(filters);
292
+ const { skipDataResolution, filters, select, ...params } = options;
293
+ const rewrittenFilters = rewriteFiltersForApi2(filters);
294
+ const rewrittenSelect = projectionToQuery(select);
790
295
  if (skipDataResolution) {
791
- const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
296
+ const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), {
297
+ ...params,
298
+ ...rewrittenFilters,
299
+ ...rewrittenSelect,
300
+ projectId
301
+ });
792
302
  return this.apiClient(url);
793
303
  }
794
304
  const edgeUrl = this.createUrl(
795
305
  __privateGet(_ContentClient, _entriesUrl),
796
- { ...this.getEdgeOptions(params), ...rewrittenFilters },
306
+ { ...this.getEdgeOptions(params), ...rewrittenFilters, ...rewrittenSelect },
797
307
  this.edgeApiHost
798
308
  );
799
309
  return this.apiClient(
@@ -1122,6 +632,7 @@ var EDGE_CACHE_DISABLED = -1;
1122
632
  var ASSET_PARAMETER_TYPE = "asset";
1123
633
  var ASSETS_SOURCE_UNIFORM = "uniform-assets";
1124
634
  var ASSETS_SOURCE_CUSTOM_URL = "custom-url";
635
+ var REFERENCE_DATA_TYPE_ID = "uniformContentInternalReference";
1125
636
 
1126
637
  // src/utils/guards.ts
1127
638
  function isRootEntryReference(root) {
@@ -1200,9 +711,9 @@ function parseVariableExpression(serialized, onToken) {
1200
711
  let bufferStartIndex = 0;
1201
712
  let bufferEndIndex = 0;
1202
713
  let tokenCount = 0;
1203
- const handleToken = (token, type) => {
714
+ const handleToken = (token, type, offset) => {
1204
715
  tokenCount++;
1205
- return onToken == null ? void 0 : onToken(token, type);
716
+ return onToken == null ? void 0 : onToken(token, type, offset);
1206
717
  };
1207
718
  let state = "text";
1208
719
  for (let index = 0; index < serialized.length; index++) {
@@ -1213,7 +724,7 @@ function parseVariableExpression(serialized, onToken) {
1213
724
  if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
1214
725
  if (serialized[index - 1] === escapeCharacter) {
1215
726
  bufferEndIndex -= escapeCharacter.length;
1216
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
727
+ if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
1217
728
  return tokenCount;
1218
729
  }
1219
730
  bufferStartIndex = index;
@@ -1222,12 +733,12 @@ function parseVariableExpression(serialized, onToken) {
1222
733
  }
1223
734
  if (state === "variable") {
1224
735
  const textStart = bufferStartIndex - variablePrefix.length;
1225
- if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
736
+ if (handleToken(serialized.substring(textStart, bufferEndIndex), "text", textStart) === false) {
1226
737
  return tokenCount;
1227
738
  }
1228
739
  bufferStartIndex = bufferEndIndex;
1229
740
  } else if (bufferEndIndex > bufferStartIndex) {
1230
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
741
+ if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
1231
742
  return tokenCount;
1232
743
  }
1233
744
  bufferStartIndex = bufferEndIndex;
@@ -1245,7 +756,7 @@ function parseVariableExpression(serialized, onToken) {
1245
756
  state = "text";
1246
757
  if (bufferEndIndex > bufferStartIndex) {
1247
758
  const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
1248
- if (handleToken(unescapedVariableName, "variable") === false) {
759
+ if (handleToken(unescapedVariableName, "variable", bufferStartIndex) === false) {
1249
760
  return tokenCount;
1250
761
  }
1251
762
  bufferStartIndex = bufferEndIndex + variableSuffix.length;
@@ -1259,7 +770,7 @@ function parseVariableExpression(serialized, onToken) {
1259
770
  bufferStartIndex -= variablePrefix.length;
1260
771
  }
1261
772
  if (bufferStartIndex < serialized.length) {
1262
- handleToken(serialized.substring(bufferStartIndex), state);
773
+ handleToken(serialized.substring(bufferStartIndex), state, bufferStartIndex);
1263
774
  }
1264
775
  return tokenCount;
1265
776
  }
@@ -1280,7 +791,7 @@ function hasReferencedVariables(value) {
1280
791
 
1281
792
  // src/enhancement/walkNodeTree.ts
1282
793
  function walkNodeTree(node, visitor, options) {
1283
- var _a, _b;
794
+ var _a, _b, _c;
1284
795
  const componentQueue = [
1285
796
  {
1286
797
  ancestorsAndSelf: Array.isArray(node) ? node : [{ node, type: "root" }],
@@ -1288,12 +799,14 @@ function walkNodeTree(node, visitor, options) {
1288
799
  }
1289
800
  ];
1290
801
  const childContexts = /* @__PURE__ */ new Map();
802
+ const order = (_a = options == null ? void 0 : options.order) != null ? _a : "dfs";
803
+ const takeNext = () => order === "bfs" ? componentQueue.shift() : componentQueue.pop();
1291
804
  do {
1292
- const currentQueueEntry = componentQueue.pop();
805
+ const currentQueueEntry = takeNext();
1293
806
  if (!currentQueueEntry) continue;
1294
807
  const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
1295
808
  let visitDescendants = true;
1296
- let descendantContext = (_a = childContexts.get(currentComponent.node)) != null ? _a : currentQueueEntry.context;
809
+ let descendantContext = (_b = childContexts.get(currentComponent.node)) != null ? _b : currentQueueEntry.context;
1297
810
  let visitorInfo;
1298
811
  if (currentComponent.type === "root" && isRootEntryReference(currentComponent) || currentComponent.type === "block") {
1299
812
  visitorInfo = {
@@ -1480,39 +993,11 @@ function walkNodeTree(node, visitor, options) {
1480
993
  continue;
1481
994
  }
1482
995
  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
- }
996
+ const childEntries = [];
1511
997
  const properties = getPropertiesValue(currentComponent.node);
1512
998
  if (properties) {
1513
999
  const propertyEntries = Object.entries(properties);
1514
- for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
1515
- const [propKey, propObject] = propertyEntries[propIndex];
1000
+ for (const [propKey, propObject] of propertyEntries) {
1516
1001
  if (!isNestedNodeType(propObject.type)) {
1517
1002
  continue;
1518
1003
  }
@@ -1532,13 +1017,12 @@ function walkNodeTree(node, visitor, options) {
1532
1017
  continue;
1533
1018
  }
1534
1019
  }
1535
- const blocks = (_b = propObject.value) != null ? _b : [];
1536
- for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
1537
- const enqueueingBlock = blocks[blockIndex];
1020
+ const blocks = (_c = propObject.value) != null ? _c : [];
1021
+ for (const enqueueingBlock of blocks) {
1538
1022
  const blockIndexFn = () => {
1539
1023
  return getBlockValue(currentComponent.node, propKey).findIndex((x) => x === enqueueingBlock);
1540
1024
  };
1541
- componentQueue.push({
1025
+ childEntries.push({
1542
1026
  ancestorsAndSelf: [
1543
1027
  {
1544
1028
  type: "block",
@@ -1553,6 +1037,36 @@ function walkNodeTree(node, visitor, options) {
1553
1037
  }
1554
1038
  }
1555
1039
  }
1040
+ if (slots) {
1041
+ const slotKeys = Object.keys(slots);
1042
+ for (const slotKey of slotKeys) {
1043
+ const components = slots[slotKey];
1044
+ for (const enqueueingComponent of components) {
1045
+ const parentSlotIndexFn = () => {
1046
+ const result = currentComponent.node.slots[slotKey].findIndex(
1047
+ (x) => x === enqueueingComponent
1048
+ );
1049
+ return result;
1050
+ };
1051
+ childEntries.push({
1052
+ ancestorsAndSelf: [
1053
+ {
1054
+ type: "slot",
1055
+ node: enqueueingComponent,
1056
+ parentSlot: slotKey,
1057
+ parentSlotIndexFn
1058
+ },
1059
+ ...currentQueueEntry.ancestorsAndSelf
1060
+ ],
1061
+ context: descendantContext
1062
+ });
1063
+ }
1064
+ }
1065
+ }
1066
+ if (order === "dfs") {
1067
+ childEntries.reverse();
1068
+ }
1069
+ componentQueue.push(...childEntries);
1556
1070
  } while (componentQueue.length > 0);
1557
1071
  }
1558
1072
  function isNestedNodeType(type) {
@@ -1978,7 +1492,7 @@ function getLocaleMatch(index, locale, greedy) {
1978
1492
  }
1979
1493
  const match = index[locale];
1980
1494
  if (match === void 0 && greedy) {
1981
- return Object.values(index)[0];
1495
+ return Object.values(index).find((value) => value !== void 0);
1982
1496
  }
1983
1497
  return match;
1984
1498
  }
@@ -2241,11 +1755,34 @@ var stringOperatorEvaluators = {
2241
1755
  endswith: endsWithEvaluator,
2242
1756
  empty: emptyEvaluator
2243
1757
  };
1758
+ var numericOperatorEvaluators = {
1759
+ gt: (left, right) => left > right,
1760
+ lt: (left, right) => left < right
1761
+ };
1762
+ function evaluateNumericOperator(criteria, matchValue) {
1763
+ const { op, value } = criteria;
1764
+ const evaluator = numericOperatorEvaluators[op];
1765
+ if (!evaluator) {
1766
+ return null;
1767
+ }
1768
+ if (typeof matchValue === "string" && matchValue.trim() === "" || typeof value === "string" && value.trim() === "") {
1769
+ return false;
1770
+ }
1771
+ const leftNum = Number(matchValue);
1772
+ const rightNum = Number(value);
1773
+ if (isNaN(leftNum) || isNaN(rightNum)) {
1774
+ return false;
1775
+ }
1776
+ return evaluator(leftNum, rightNum);
1777
+ }
2244
1778
  function evaluateStringMatch(criteria, matchValue, allow) {
2245
1779
  const { op, value } = criteria;
2246
1780
  if (allow && !allow.has(op)) {
2247
1781
  return null;
2248
1782
  }
1783
+ if (op in numericOperatorEvaluators) {
1784
+ return evaluateNumericOperator(criteria, matchValue);
1785
+ }
2249
1786
  let opMatch = op;
2250
1787
  const negation = op.startsWith("!");
2251
1788
  if (negation) {
@@ -2294,17 +1831,49 @@ var dynamicTokenVisibilityOperators = /* @__PURE__ */ new Set([
2294
1831
  "endswith",
2295
1832
  "!endswith",
2296
1833
  "empty",
2297
- "!empty"
1834
+ "!empty",
1835
+ "gt",
1836
+ "lt"
2298
1837
  ]);
2299
1838
  var CANVAS_VIZ_DYNAMIC_TOKEN_RULE = "$dt";
1839
+ function toStringValue(value) {
1840
+ if (typeof value === "string") {
1841
+ return value;
1842
+ }
1843
+ if (typeof value === "number" || typeof value === "boolean") {
1844
+ return String(value);
1845
+ }
1846
+ return "";
1847
+ }
1848
+ function toStringCriteriaValue(value) {
1849
+ if (Array.isArray(value)) {
1850
+ return value.map((v) => toStringValue(v));
1851
+ }
1852
+ return toStringValue(value);
1853
+ }
1854
+ function isUnbound(value) {
1855
+ if (value === void 0 || value === null) {
1856
+ return true;
1857
+ }
1858
+ if (typeof value === "string") {
1859
+ return hasReferencedVariables(value) > 0;
1860
+ }
1861
+ return false;
1862
+ }
2300
1863
  function createDynamicTokenVisibilityRule() {
2301
1864
  return {
2302
1865
  [CANVAS_VIZ_DYNAMIC_TOKEN_RULE]: (criterion) => {
2303
- var _a;
2304
- if (typeof criterion.source !== "string" || hasReferencedVariables(criterion.source)) {
1866
+ const { source, value } = criterion;
1867
+ if (isUnbound(source)) {
2305
1868
  return null;
2306
1869
  }
2307
- return evaluateStringMatch(criterion, (_a = criterion.source) != null ? _a : "", dynamicTokenVisibilityOperators);
1870
+ const stringSource = toStringValue(source);
1871
+ const stringValue = toStringCriteriaValue(value);
1872
+ const stringCriterion = {
1873
+ ...criterion,
1874
+ value: stringValue
1875
+ };
1876
+ return evaluateStringMatch(stringCriterion, stringSource, dynamicTokenVisibilityOperators);
2308
1877
  }
2309
1878
  };
2310
1879
  }
@@ -2363,8 +1932,7 @@ function extractLocales({ component }) {
2363
1932
  return variations;
2364
1933
  }
2365
1934
  function localize(options) {
2366
- const nodes = options.nodes;
2367
- const locale = options.locale;
1935
+ const { nodes, locale, keepLocalesFor } = options;
2368
1936
  if (!locale) {
2369
1937
  return;
2370
1938
  }
@@ -2372,7 +1940,7 @@ function localize(options) {
2372
1940
  walkNodeTree(nodes, (context) => {
2373
1941
  const { type, node, actions } = context;
2374
1942
  if (type !== "component") {
2375
- localizeProperties(node, locale, vizControlLocaleRule);
1943
+ localizeProperties(node, locale, vizControlLocaleRule, keepLocalesFor);
2376
1944
  return;
2377
1945
  }
2378
1946
  const result = evaluateWalkTreeNodeVisibility({
@@ -2393,7 +1961,7 @@ function localize(options) {
2393
1961
  if (replaceComponent == null ? void 0 : replaceComponent.length) {
2394
1962
  replaceComponent.forEach((component) => {
2395
1963
  removeLocaleProperty(component);
2396
- localizeProperties(component, locale, vizControlLocaleRule);
1964
+ localizeProperties(component, locale, vizControlLocaleRule, keepLocalesFor);
2397
1965
  });
2398
1966
  const [first, ...rest] = replaceComponent;
2399
1967
  actions.replace(first);
@@ -2404,7 +1972,7 @@ function localize(options) {
2404
1972
  actions.remove();
2405
1973
  }
2406
1974
  } else {
2407
- localizeProperties(node, locale, vizControlLocaleRule);
1975
+ localizeProperties(node, locale, vizControlLocaleRule, keepLocalesFor);
2408
1976
  }
2409
1977
  });
2410
1978
  }
@@ -2423,7 +1991,7 @@ function removeLocaleProperty(component) {
2423
1991
  }
2424
1992
  }
2425
1993
  }
2426
- function localizeProperties(node, locale, rules) {
1994
+ function localizeProperties(node, locale, rules, keepLocalesFor) {
2427
1995
  const properties = getPropertiesValue(node);
2428
1996
  if (!properties) {
2429
1997
  return void 0;
@@ -2442,10 +2010,16 @@ function localizeProperties(node, locale, rules) {
2442
2010
  if (currentLocaleConditionalValues !== void 0) {
2443
2011
  propertyValue.conditions = currentLocaleConditionalValues;
2444
2012
  }
2445
- delete propertyValue.locales;
2446
- delete propertyValue.localesConditions;
2013
+ const preserveLocales = (keepLocalesFor == null ? void 0 : keepLocalesFor(propertyId)) === true;
2014
+ if (!preserveLocales) {
2015
+ delete propertyValue.locales;
2016
+ delete propertyValue.localesConditions;
2017
+ }
2447
2018
  if (propertyValue.value === void 0 && propertyValue.conditions === void 0) {
2448
- delete properties[propertyId];
2019
+ const hasLocales = preserveLocales && (propertyValue.locales || propertyValue.localesConditions);
2020
+ if (!hasLocales) {
2021
+ delete properties[propertyId];
2022
+ }
2449
2023
  }
2450
2024
  });
2451
2025
  evaluateWalkTreePropertyCriteria({
@@ -2572,10 +2146,47 @@ _baseUrl = new WeakMap();
2572
2146
  __privateAdd(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
2573
2147
  var IntegrationPropertyEditorsClient = _IntegrationPropertyEditorsClient;
2574
2148
 
2575
- // src/LocaleClient.ts
2149
+ // src/LabelClient.ts
2576
2150
  import { ApiClient as ApiClient8 } from "@uniformdev/context/api";
2151
+ var LABELS_URL = "/api/v1/labels";
2152
+ var LabelClient = class extends ApiClient8 {
2153
+ /** Fetches labels for the current project. */
2154
+ async getLabels(options) {
2155
+ const { projectId } = this.options;
2156
+ const fetchUri = this.createUrl(LABELS_URL, { ...options, projectId });
2157
+ return await this.apiClient(fetchUri);
2158
+ }
2159
+ /** Updates or creates a label. */
2160
+ async upsertLabel(body) {
2161
+ const { projectId } = this.options;
2162
+ const fetchUri = this.createUrl(LABELS_URL);
2163
+ await this.apiClient(fetchUri, {
2164
+ method: "PUT",
2165
+ body: JSON.stringify({ ...body, projectId }),
2166
+ expectNoContent: true
2167
+ });
2168
+ }
2169
+ /** Deletes a label by id. */
2170
+ async removeLabel(options) {
2171
+ const { projectId } = this.options;
2172
+ const fetchUri = this.createUrl(LABELS_URL);
2173
+ await this.apiClient(fetchUri, {
2174
+ method: "DELETE",
2175
+ body: JSON.stringify({ ...options, projectId }),
2176
+ expectNoContent: true
2177
+ });
2178
+ }
2179
+ };
2180
+ var UncachedLabelClient = class extends LabelClient {
2181
+ constructor(options) {
2182
+ super({ ...options, bypassCache: true });
2183
+ }
2184
+ };
2185
+
2186
+ // src/LocaleClient.ts
2187
+ import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
2577
2188
  var localesUrl = "/api/v1/locales";
2578
- var LocaleClient = class extends ApiClient8 {
2189
+ var LocaleClient = class extends ApiClient9 {
2579
2190
  constructor(options) {
2580
2191
  super(options);
2581
2192
  }
@@ -2630,6 +2241,12 @@ var isSelectComponentMessage = (message) => {
2630
2241
  var isReadyMessage = (message) => {
2631
2242
  return message.type === "ready";
2632
2243
  };
2244
+ var isSessionPendingMessage = (message) => {
2245
+ return message.type === "session-pending";
2246
+ };
2247
+ var isAwaitingReadyMessage = (message) => {
2248
+ return message.type === "awaiting-ready";
2249
+ };
2633
2250
  var isComponentActionMessage = (message) => {
2634
2251
  return message.type === "trigger-component-action";
2635
2252
  };
@@ -2732,6 +2349,14 @@ var createCanvasChannel = ({
2732
2349
  };
2733
2350
  postMessage(message);
2734
2351
  };
2352
+ const sessionPending = () => {
2353
+ const message = { type: "session-pending" };
2354
+ postMessage(message);
2355
+ };
2356
+ const awaitingReady = () => {
2357
+ const message = { type: "awaiting-ready" };
2358
+ postMessage(message);
2359
+ };
2735
2360
  const on = (types, handler) => {
2736
2361
  const handlerId = ++handlerCounter;
2737
2362
  handlers[handlerId] = {
@@ -2931,6 +2556,8 @@ var createCanvasChannel = ({
2931
2556
  return {
2932
2557
  broadcastTo: broadcastToItems,
2933
2558
  ready,
2559
+ sessionPending,
2560
+ awaitingReady,
2934
2561
  destroy,
2935
2562
  addBroadcastTarget,
2936
2563
  triggerComponentAction,
@@ -2961,10 +2588,10 @@ var createCanvasChannel = ({
2961
2588
  };
2962
2589
 
2963
2590
  // src/PreviewClient.ts
2964
- import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
2591
+ import { ApiClient as ApiClient10 } from "@uniformdev/context/api";
2965
2592
  var previewUrlsUrl = "/api/v1/preview-urls";
2966
2593
  var previewViewportsUrl = "/api/v1/preview-viewports";
2967
- var PreviewClient = class extends ApiClient9 {
2594
+ var PreviewClient = class extends ApiClient10 {
2968
2595
  constructor(options) {
2969
2596
  super(options);
2970
2597
  }
@@ -3027,9 +2654,9 @@ var PreviewClient = class extends ApiClient9 {
3027
2654
  };
3028
2655
 
3029
2656
  // src/ProjectClient.ts
3030
- import { ApiClient as ApiClient10 } from "@uniformdev/context/api";
3031
- var _url2;
3032
- var _ProjectClient = class _ProjectClient extends ApiClient10 {
2657
+ import { ApiClient as ApiClient11 } from "@uniformdev/context/api";
2658
+ var _url2, _projectsUrl;
2659
+ var _ProjectClient = class _ProjectClient extends ApiClient11 {
3033
2660
  constructor(options) {
3034
2661
  super({ ...options, bypassCache: true });
3035
2662
  }
@@ -3038,6 +2665,15 @@ var _ProjectClient = class _ProjectClient extends ApiClient10 {
3038
2665
  const fetchUri = this.createUrl(__privateGet(_ProjectClient, _url2), { ...options });
3039
2666
  return await this.apiClient(fetchUri);
3040
2667
  }
2668
+ /**
2669
+ * Fetches projects grouped by team.
2670
+ * When teamId is provided, returns a single team with its projects.
2671
+ * When omitted, returns all accessible teams and their projects.
2672
+ */
2673
+ async getProjects(options) {
2674
+ const fetchUri = this.createUrl(__privateGet(_ProjectClient, _projectsUrl), options ? { ...options } : {});
2675
+ return await this.apiClient(fetchUri);
2676
+ }
3041
2677
  /** Updates or creates (based on id) a Project */
3042
2678
  async upsert(body) {
3043
2679
  const fetchUri = this.createUrl(__privateGet(_ProjectClient, _url2));
@@ -3057,13 +2693,197 @@ var _ProjectClient = class _ProjectClient extends ApiClient10 {
3057
2693
  }
3058
2694
  };
3059
2695
  _url2 = new WeakMap();
2696
+ _projectsUrl = new WeakMap();
3060
2697
  __privateAdd(_ProjectClient, _url2, "/api/v1/project");
2698
+ __privateAdd(_ProjectClient, _projectsUrl, "/api/v1/projects");
3061
2699
  var ProjectClient = _ProjectClient;
3062
2700
 
2701
+ // src/projection/matchesProjectionPattern.ts
2702
+ var DISALLOWED_PATTERN_CHARS = /[,&=?#[\]\s]/;
2703
+ var REGEX_METACHAR = /[\\^$.|?*+()[\]{}]/g;
2704
+ function isValidProjectionPattern(pattern) {
2705
+ if (typeof pattern !== "string" || pattern.length === 0) {
2706
+ return false;
2707
+ }
2708
+ if (DISALLOWED_PATTERN_CHARS.test(pattern)) {
2709
+ return false;
2710
+ }
2711
+ return true;
2712
+ }
2713
+ function compilePattern(pattern) {
2714
+ let regexSource = "^";
2715
+ for (const ch of pattern) {
2716
+ if (ch === "*") {
2717
+ regexSource += ".*";
2718
+ } else {
2719
+ regexSource += ch.replace(REGEX_METACHAR, "\\$&");
2720
+ }
2721
+ }
2722
+ regexSource += "$";
2723
+ return new RegExp(regexSource);
2724
+ }
2725
+ var PATTERN_CACHE_MAX = 1024;
2726
+ var patternRegexCache = /* @__PURE__ */ new Map();
2727
+ function matchesProjectionPattern(pattern, value) {
2728
+ let re = patternRegexCache.get(pattern);
2729
+ if (re === void 0) {
2730
+ if (!isValidProjectionPattern(pattern)) {
2731
+ throw new Error(`Invalid projection pattern: ${JSON.stringify(pattern)}`);
2732
+ }
2733
+ re = compilePattern(pattern);
2734
+ if (patternRegexCache.size >= PATTERN_CACHE_MAX) {
2735
+ const oldest = patternRegexCache.keys().next().value;
2736
+ if (oldest !== void 0) patternRegexCache.delete(oldest);
2737
+ }
2738
+ patternRegexCache.set(pattern, re);
2739
+ }
2740
+ return re.test(value);
2741
+ }
2742
+
2743
+ // src/projection/queryToProjection.ts
2744
+ var TOP_LEVEL_OPERATOR_KEY = /^(fields|fieldTypes|slots)\[([A-Za-z]+)\]$/;
2745
+ var SLOTS_NAMED_KEY = /^slots\.([A-Za-z0-9_-]+)\[([A-Za-z]+)\]$/;
2746
+ function toStringValue2(value) {
2747
+ if (Array.isArray(value)) {
2748
+ return value.join(",");
2749
+ }
2750
+ return value;
2751
+ }
2752
+ function parseCsv(value) {
2753
+ const str = toStringValue2(value);
2754
+ if (!str) {
2755
+ return [];
2756
+ }
2757
+ return str.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
2758
+ }
2759
+ function parseDepth(value, key) {
2760
+ const str = toStringValue2(value);
2761
+ if (str === void 0 || str === "") {
2762
+ throw new Error(`Invalid select projection: '${key}' requires a non-negative integer value`);
2763
+ }
2764
+ if (!/^\d+$/.test(str)) {
2765
+ throw new Error(
2766
+ `Invalid select projection: '${key}' must be a non-negative integer (got ${JSON.stringify(str)})`
2767
+ );
2768
+ }
2769
+ return Number(str);
2770
+ }
2771
+ function parseBlockDepth(value, key) {
2772
+ const str = toStringValue2(value);
2773
+ if (str === "preserveAll") {
2774
+ return "preserveAll";
2775
+ }
2776
+ if (str === void 0 || str === "" || !/^\d+$/.test(str)) {
2777
+ throw new Error(
2778
+ `Invalid select projection: '${key}' must be a non-negative integer or 'preserveAll' (got ${JSON.stringify(str)})`
2779
+ );
2780
+ }
2781
+ return Number(str);
2782
+ }
2783
+ function extractSelectKeys(source) {
2784
+ if (source instanceof URLSearchParams) {
2785
+ let out2;
2786
+ for (const [key, value] of source.entries()) {
2787
+ if (!key.startsWith(SELECT_QUERY_PREFIX)) continue;
2788
+ out2 != null ? out2 : out2 = {};
2789
+ out2[key] = out2[key] === void 0 ? value : `${out2[key]},${value}`;
2790
+ }
2791
+ return out2;
2792
+ }
2793
+ let out;
2794
+ for (const key in source) {
2795
+ if (!key.startsWith(SELECT_QUERY_PREFIX)) continue;
2796
+ out != null ? out : out = {};
2797
+ out[key] = source[key];
2798
+ }
2799
+ return out;
2800
+ }
2801
+ function queryToProjection(source) {
2802
+ var _a, _b, _c, _d, _e;
2803
+ if (!source) {
2804
+ return void 0;
2805
+ }
2806
+ const query = extractSelectKeys(source);
2807
+ if (!query) {
2808
+ return void 0;
2809
+ }
2810
+ const spec = {};
2811
+ for (const [rawKey, value] of Object.entries(query)) {
2812
+ const key = rawKey.slice(SELECT_QUERY_PREFIX.length);
2813
+ const namedMatch = SLOTS_NAMED_KEY.exec(key);
2814
+ if (namedMatch) {
2815
+ const [, slotName, operator2] = namedMatch;
2816
+ if (operator2 !== "depth") {
2817
+ throw new Error(
2818
+ `Invalid select projection: unsupported operator '${operator2}' for slots.${slotName}`
2819
+ );
2820
+ }
2821
+ const slots = (_a = spec.slots) != null ? _a : spec.slots = {};
2822
+ const named = (_b = slots.named) != null ? _b : slots.named = {};
2823
+ named[slotName] = { ...named[slotName], depth: parseDepth(value, rawKey) };
2824
+ continue;
2825
+ }
2826
+ const topMatch = TOP_LEVEL_OPERATOR_KEY.exec(key);
2827
+ if (!topMatch) {
2828
+ throw new Error(`Invalid select projection key: ${JSON.stringify(rawKey)}`);
2829
+ }
2830
+ const [, bucket, operator] = topMatch;
2831
+ if (bucket === "fields") {
2832
+ const fields = (_c = spec.fields) != null ? _c : spec.fields = {};
2833
+ switch (operator) {
2834
+ case "only":
2835
+ fields.only = parseCsv(value);
2836
+ break;
2837
+ case "except":
2838
+ fields.except = parseCsv(value);
2839
+ break;
2840
+ case "locales":
2841
+ fields.locales = parseCsv(value);
2842
+ break;
2843
+ case "blockDepth":
2844
+ fields.blockDepth = parseBlockDepth(value, rawKey);
2845
+ break;
2846
+ default:
2847
+ throw new Error(`Invalid select projection: unsupported operator 'fields[${operator}]'`);
2848
+ }
2849
+ } else if (bucket === "fieldTypes") {
2850
+ const fieldTypes = (_d = spec.fieldTypes) != null ? _d : spec.fieldTypes = {};
2851
+ switch (operator) {
2852
+ case "only":
2853
+ fieldTypes.only = parseCsv(value);
2854
+ break;
2855
+ case "except":
2856
+ fieldTypes.except = parseCsv(value);
2857
+ break;
2858
+ default:
2859
+ throw new Error(`Invalid select projection: unsupported operator 'fieldTypes[${operator}]'`);
2860
+ }
2861
+ } else if (bucket === "slots") {
2862
+ const slots = (_e = spec.slots) != null ? _e : spec.slots = {};
2863
+ switch (operator) {
2864
+ case "only":
2865
+ slots.only = parseCsv(value);
2866
+ break;
2867
+ case "except":
2868
+ slots.except = parseCsv(value);
2869
+ break;
2870
+ case "depth":
2871
+ slots.depth = parseDepth(value, rawKey);
2872
+ break;
2873
+ default:
2874
+ throw new Error(`Invalid select projection: unsupported operator 'slots[${operator}]'`);
2875
+ }
2876
+ } else {
2877
+ throw new Error(`Invalid select projection key: ${JSON.stringify(rawKey)}`);
2878
+ }
2879
+ }
2880
+ return spec;
2881
+ }
2882
+
3063
2883
  // src/PromptClient.ts
3064
- import { ApiClient as ApiClient11 } from "@uniformdev/context/api";
2884
+ import { ApiClient as ApiClient12 } from "@uniformdev/context/api";
3065
2885
  var PromptsUrl = "/api/v1/prompts";
3066
- var PromptClient = class extends ApiClient11 {
2886
+ var PromptClient = class extends ApiClient12 {
3067
2887
  constructor(options) {
3068
2888
  super(options);
3069
2889
  }
@@ -3094,9 +2914,9 @@ var PromptClient = class extends ApiClient11 {
3094
2914
  };
3095
2915
 
3096
2916
  // src/RelationshipClient.ts
3097
- import { ApiClient as ApiClient12 } from "@uniformdev/context/api";
2917
+ import { ApiClient as ApiClient13 } from "@uniformdev/context/api";
3098
2918
  var RELATIONSHIPS_URL = "/api/v1/relationships";
3099
- var RelationshipClient = class extends ApiClient12 {
2919
+ var RelationshipClient = class extends ApiClient13 {
3100
2920
  constructor(options) {
3101
2921
  super(options);
3102
2922
  this.get = async (options) => {
@@ -3108,9 +2928,9 @@ var RelationshipClient = class extends ApiClient12 {
3108
2928
  };
3109
2929
 
3110
2930
  // src/ReleaseClient.ts
3111
- import { ApiClient as ApiClient13 } from "@uniformdev/context/api";
2931
+ import { ApiClient as ApiClient14 } from "@uniformdev/context/api";
3112
2932
  var releasesUrl = "/api/v1/releases";
3113
- var ReleaseClient = class extends ApiClient13 {
2933
+ var ReleaseClient = class extends ApiClient14 {
3114
2934
  constructor(options) {
3115
2935
  super(options);
3116
2936
  }
@@ -3150,9 +2970,9 @@ var ReleaseClient = class extends ApiClient13 {
3150
2970
  };
3151
2971
 
3152
2972
  // src/ReleaseContentsClient.ts
3153
- import { ApiClient as ApiClient14 } from "@uniformdev/context/api";
2973
+ import { ApiClient as ApiClient15 } from "@uniformdev/context/api";
3154
2974
  var releaseContentsUrl2 = "/api/v1/release-contents";
3155
- var ReleaseContentsClient = class extends ApiClient14 {
2975
+ var ReleaseContentsClient = class extends ApiClient15 {
3156
2976
  constructor(options) {
3157
2977
  super(options);
3158
2978
  }
@@ -3174,9 +2994,9 @@ var ReleaseContentsClient = class extends ApiClient14 {
3174
2994
  };
3175
2995
 
3176
2996
  // src/RouteClient.ts
3177
- import { ApiClient as ApiClient15 } from "@uniformdev/context/api";
2997
+ import { ApiClient as ApiClient16 } from "@uniformdev/context/api";
3178
2998
  var ROUTE_URL = "/api/v1/route";
3179
- var RouteClient = class extends ApiClient15 {
2999
+ var RouteClient = class extends ApiClient16 {
3180
3000
  constructor(options) {
3181
3001
  var _a;
3182
3002
  if (!options.limitPolicy) {
@@ -3188,7 +3008,9 @@ var RouteClient = class extends ApiClient15 {
3188
3008
  /** Fetches lists of Canvas compositions, optionally by type */
3189
3009
  async getRoute(options) {
3190
3010
  const { projectId } = this.options;
3191
- const fetchUri = this.createUrl(ROUTE_URL, { ...options, projectId }, this.edgeApiHost);
3011
+ const { select, ...rest } = options != null ? options : {};
3012
+ const rewrittenSelect = projectionToQuery(select);
3013
+ const fetchUri = this.createUrl(ROUTE_URL, { ...rest, projectId, ...rewrittenSelect }, this.edgeApiHost);
3192
3014
  return await this.apiClient(
3193
3015
  fetchUri,
3194
3016
  this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
@@ -3352,7 +3174,9 @@ var getParameterAttributes = ({
3352
3174
 
3353
3175
  // src/utils/isAllowedReferrer.ts
3354
3176
  var isAllowedReferrer = (referrer) => {
3355
- return Boolean(referrer == null ? void 0 : referrer.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|localhost:\d{4})\//));
3177
+ return Boolean(
3178
+ referrer == null ? void 0 : referrer.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|uniformcode.ai|localhost:\d{4})\//)
3179
+ );
3356
3180
  };
3357
3181
 
3358
3182
  // src/utils/isSystemComponentDefinition.ts
@@ -3551,12 +3375,12 @@ function handleRichTextNodeBinding(object, options) {
3551
3375
  import { ApiClientError as ApiClientError2 } from "@uniformdev/context/api";
3552
3376
 
3553
3377
  // src/.version.ts
3554
- var version = "20.49.2";
3378
+ var version = "20.74.3";
3555
3379
 
3556
3380
  // src/WorkflowClient.ts
3557
- import { ApiClient as ApiClient16 } from "@uniformdev/context/api";
3381
+ import { ApiClient as ApiClient17 } from "@uniformdev/context/api";
3558
3382
  var workflowsUrl = "/api/v1/workflows";
3559
- var WorkflowClient = class extends ApiClient16 {
3383
+ var WorkflowClient = class extends ApiClient17 {
3560
3384
  constructor(options) {
3561
3385
  super(options);
3562
3386
  }
@@ -3660,19 +3484,23 @@ export {
3660
3484
  IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
3661
3485
  IntegrationPropertyEditorsClient,
3662
3486
  LOCALE_DYNAMIC_INPUT_NAME,
3487
+ LabelClient,
3663
3488
  LocaleClient,
3664
3489
  PLACEHOLDER_ID,
3665
3490
  PreviewClient,
3666
3491
  ProjectClient,
3667
3492
  PromptClient,
3493
+ REFERENCE_DATA_TYPE_ID,
3668
3494
  RelationshipClient,
3669
3495
  ReleaseClient,
3670
3496
  ReleaseContentsClient,
3671
3497
  RouteClient,
3672
3498
  SECRET_QUERY_STRING_PARAM,
3499
+ SELECT_QUERY_PREFIX,
3673
3500
  UncachedCanvasClient,
3674
3501
  UncachedCategoryClient,
3675
3502
  UncachedContentClient,
3503
+ UncachedLabelClient,
3676
3504
  UniqueBatchEntries,
3677
3505
  WorkflowClient,
3678
3506
  autoFixParameterGroups,
@@ -3719,6 +3547,7 @@ export {
3719
3547
  isAllowedReferrer,
3720
3548
  isAssetParamValue,
3721
3549
  isAssetParamValueItem,
3550
+ isAwaitingReadyMessage,
3722
3551
  isComponentActionMessage,
3723
3552
  isComponentPlaceholderId,
3724
3553
  isContextStorageUpdatedMessage,
@@ -3734,6 +3563,7 @@ export {
3734
3563
  isRootEntryReference,
3735
3564
  isSelectComponentMessage,
3736
3565
  isSelectParameterMessage,
3566
+ isSessionPendingMessage,
3737
3567
  isSuggestComponentMessage,
3738
3568
  isSystemComponentDefinition,
3739
3569
  isTriggerCompositionActionMessage,
@@ -3748,10 +3578,13 @@ export {
3748
3578
  localize,
3749
3579
  mapSlotToPersonalizedVariations,
3750
3580
  mapSlotToTestVariations,
3581
+ matchesProjectionPattern,
3751
3582
  mergeAssetConfigWithDefaults,
3752
3583
  nullLimitPolicy,
3753
3584
  parseComponentPlaceholderId,
3754
3585
  parseVariableExpression,
3586
+ projectionToQuery,
3587
+ queryToProjection,
3755
3588
  version,
3756
3589
  walkNodeTree,
3757
3590
  walkPropertyValues