@uniformdev/next-app-router 20.49.1 → 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.js CHANGED
@@ -5,6 +5,10 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __typeError = (msg) => {
9
+ throw TypeError(msg);
10
+ };
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
12
  var __commonJS = (cb, mod) => function __require() {
9
13
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
14
  };
@@ -29,12 +33,25 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
33
  mod
30
34
  ));
31
35
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
37
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
38
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
39
+ 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);
40
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
41
+ var __privateWrapper = (obj, member, setter, getter) => ({
42
+ set _(value) {
43
+ __privateSet(obj, member, value, setter);
44
+ },
45
+ get _() {
46
+ return __privateGet(obj, member, getter);
47
+ }
48
+ });
32
49
 
33
50
  // ../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js
34
51
  var require_yocto_queue = __commonJS({
35
52
  "../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports2, module2) {
36
53
  "use strict";
37
- var Node = class {
54
+ var Node2 = class {
38
55
  /// value;
39
56
  /// next;
40
57
  constructor(value) {
@@ -42,7 +59,7 @@ var require_yocto_queue = __commonJS({
42
59
  this.next = void 0;
43
60
  }
44
61
  };
45
- var Queue = class {
62
+ var Queue2 = class {
46
63
  // TODO: Use private class fields when targeting Node.js 12.
47
64
  // #_head;
48
65
  // #_tail;
@@ -51,7 +68,7 @@ var require_yocto_queue = __commonJS({
51
68
  this.clear();
52
69
  }
53
70
  enqueue(value) {
54
- const node = new Node(value);
71
+ const node = new Node2(value);
55
72
  if (this._head) {
56
73
  this._tail.next = node;
57
74
  this._tail = node;
@@ -86,7 +103,7 @@ var require_yocto_queue = __commonJS({
86
103
  }
87
104
  }
88
105
  };
89
- module2.exports = Queue;
106
+ module2.exports = Queue2;
90
107
  }
91
108
  });
92
109
 
@@ -94,12 +111,12 @@ var require_yocto_queue = __commonJS({
94
111
  var require_p_limit = __commonJS({
95
112
  "../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports2, module2) {
96
113
  "use strict";
97
- var Queue = require_yocto_queue();
98
- var pLimit2 = (concurrency) => {
114
+ var Queue2 = require_yocto_queue();
115
+ var pLimit3 = (concurrency) => {
99
116
  if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
100
117
  throw new TypeError("Expected `concurrency` to be a number from 1 and up");
101
118
  }
102
- const queue = new Queue();
119
+ const queue = new Queue2();
103
120
  let activeCount = 0;
104
121
  const next = () => {
105
122
  activeCount--;
@@ -144,13 +161,244 @@ var require_p_limit = __commonJS({
144
161
  });
145
162
  return generator;
146
163
  };
147
- module2.exports = pLimit2;
164
+ module2.exports = pLimit3;
165
+ }
166
+ });
167
+
168
+ // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js
169
+ var require_retry_operation = __commonJS({
170
+ "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports2, module2) {
171
+ "use strict";
172
+ function RetryOperation(timeouts, options) {
173
+ if (typeof options === "boolean") {
174
+ options = { forever: options };
175
+ }
176
+ this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
177
+ this._timeouts = timeouts;
178
+ this._options = options || {};
179
+ this._maxRetryTime = options && options.maxRetryTime || Infinity;
180
+ this._fn = null;
181
+ this._errors = [];
182
+ this._attempts = 1;
183
+ this._operationTimeout = null;
184
+ this._operationTimeoutCb = null;
185
+ this._timeout = null;
186
+ this._operationStart = null;
187
+ this._timer = null;
188
+ if (this._options.forever) {
189
+ this._cachedTimeouts = this._timeouts.slice(0);
190
+ }
191
+ }
192
+ module2.exports = RetryOperation;
193
+ RetryOperation.prototype.reset = function() {
194
+ this._attempts = 1;
195
+ this._timeouts = this._originalTimeouts.slice(0);
196
+ };
197
+ RetryOperation.prototype.stop = function() {
198
+ if (this._timeout) {
199
+ clearTimeout(this._timeout);
200
+ }
201
+ if (this._timer) {
202
+ clearTimeout(this._timer);
203
+ }
204
+ this._timeouts = [];
205
+ this._cachedTimeouts = null;
206
+ };
207
+ RetryOperation.prototype.retry = function(err) {
208
+ if (this._timeout) {
209
+ clearTimeout(this._timeout);
210
+ }
211
+ if (!err) {
212
+ return false;
213
+ }
214
+ var currentTime = (/* @__PURE__ */ new Date()).getTime();
215
+ if (err && currentTime - this._operationStart >= this._maxRetryTime) {
216
+ this._errors.push(err);
217
+ this._errors.unshift(new Error("RetryOperation timeout occurred"));
218
+ return false;
219
+ }
220
+ this._errors.push(err);
221
+ var timeout = this._timeouts.shift();
222
+ if (timeout === void 0) {
223
+ if (this._cachedTimeouts) {
224
+ this._errors.splice(0, this._errors.length - 1);
225
+ timeout = this._cachedTimeouts.slice(-1);
226
+ } else {
227
+ return false;
228
+ }
229
+ }
230
+ var self = this;
231
+ this._timer = setTimeout(function() {
232
+ self._attempts++;
233
+ if (self._operationTimeoutCb) {
234
+ self._timeout = setTimeout(function() {
235
+ self._operationTimeoutCb(self._attempts);
236
+ }, self._operationTimeout);
237
+ if (self._options.unref) {
238
+ self._timeout.unref();
239
+ }
240
+ }
241
+ self._fn(self._attempts);
242
+ }, timeout);
243
+ if (this._options.unref) {
244
+ this._timer.unref();
245
+ }
246
+ return true;
247
+ };
248
+ RetryOperation.prototype.attempt = function(fn, timeoutOps) {
249
+ this._fn = fn;
250
+ if (timeoutOps) {
251
+ if (timeoutOps.timeout) {
252
+ this._operationTimeout = timeoutOps.timeout;
253
+ }
254
+ if (timeoutOps.cb) {
255
+ this._operationTimeoutCb = timeoutOps.cb;
256
+ }
257
+ }
258
+ var self = this;
259
+ if (this._operationTimeoutCb) {
260
+ this._timeout = setTimeout(function() {
261
+ self._operationTimeoutCb();
262
+ }, self._operationTimeout);
263
+ }
264
+ this._operationStart = (/* @__PURE__ */ new Date()).getTime();
265
+ this._fn(this._attempts);
266
+ };
267
+ RetryOperation.prototype.try = function(fn) {
268
+ console.log("Using RetryOperation.try() is deprecated");
269
+ this.attempt(fn);
270
+ };
271
+ RetryOperation.prototype.start = function(fn) {
272
+ console.log("Using RetryOperation.start() is deprecated");
273
+ this.attempt(fn);
274
+ };
275
+ RetryOperation.prototype.start = RetryOperation.prototype.try;
276
+ RetryOperation.prototype.errors = function() {
277
+ return this._errors;
278
+ };
279
+ RetryOperation.prototype.attempts = function() {
280
+ return this._attempts;
281
+ };
282
+ RetryOperation.prototype.mainError = function() {
283
+ if (this._errors.length === 0) {
284
+ return null;
285
+ }
286
+ var counts = {};
287
+ var mainError = null;
288
+ var mainErrorCount = 0;
289
+ for (var i = 0; i < this._errors.length; i++) {
290
+ var error = this._errors[i];
291
+ var message = error.message;
292
+ var count = (counts[message] || 0) + 1;
293
+ counts[message] = count;
294
+ if (count >= mainErrorCount) {
295
+ mainError = error;
296
+ mainErrorCount = count;
297
+ }
298
+ }
299
+ return mainError;
300
+ };
301
+ }
302
+ });
303
+
304
+ // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js
305
+ var require_retry = __commonJS({
306
+ "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports2) {
307
+ "use strict";
308
+ var RetryOperation = require_retry_operation();
309
+ exports2.operation = function(options) {
310
+ var timeouts = exports2.timeouts(options);
311
+ return new RetryOperation(timeouts, {
312
+ forever: options && (options.forever || options.retries === Infinity),
313
+ unref: options && options.unref,
314
+ maxRetryTime: options && options.maxRetryTime
315
+ });
316
+ };
317
+ exports2.timeouts = function(options) {
318
+ if (options instanceof Array) {
319
+ return [].concat(options);
320
+ }
321
+ var opts = {
322
+ retries: 10,
323
+ factor: 2,
324
+ minTimeout: 1 * 1e3,
325
+ maxTimeout: Infinity,
326
+ randomize: false
327
+ };
328
+ for (var key in options) {
329
+ opts[key] = options[key];
330
+ }
331
+ if (opts.minTimeout > opts.maxTimeout) {
332
+ throw new Error("minTimeout is greater than maxTimeout");
333
+ }
334
+ var timeouts = [];
335
+ for (var i = 0; i < opts.retries; i++) {
336
+ timeouts.push(this.createTimeout(i, opts));
337
+ }
338
+ if (options && options.forever && !timeouts.length) {
339
+ timeouts.push(this.createTimeout(i, opts));
340
+ }
341
+ timeouts.sort(function(a, b) {
342
+ return a - b;
343
+ });
344
+ return timeouts;
345
+ };
346
+ exports2.createTimeout = function(attempt, opts) {
347
+ var random = opts.randomize ? Math.random() + 1 : 1;
348
+ var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
349
+ timeout = Math.min(timeout, opts.maxTimeout);
350
+ return timeout;
351
+ };
352
+ exports2.wrap = function(obj, options, methods) {
353
+ if (options instanceof Array) {
354
+ methods = options;
355
+ options = null;
356
+ }
357
+ if (!methods) {
358
+ methods = [];
359
+ for (var key in obj) {
360
+ if (typeof obj[key] === "function") {
361
+ methods.push(key);
362
+ }
363
+ }
364
+ }
365
+ for (var i = 0; i < methods.length; i++) {
366
+ var method = methods[i];
367
+ var original = obj[method];
368
+ obj[method] = function retryWrapper(original2) {
369
+ var op = exports2.operation(options);
370
+ var args = Array.prototype.slice.call(arguments, 1);
371
+ var callback = args.pop();
372
+ args.push(function(err) {
373
+ if (op.retry(err)) {
374
+ return;
375
+ }
376
+ if (err) {
377
+ arguments[0] = op.mainError();
378
+ }
379
+ callback.apply(this, arguments);
380
+ });
381
+ op.attempt(function() {
382
+ original2.apply(obj, args);
383
+ });
384
+ }.bind(obj, original);
385
+ obj[method].options = options;
386
+ }
387
+ };
388
+ }
389
+ });
390
+
391
+ // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js
392
+ var require_retry2 = __commonJS({
393
+ "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports2, module2) {
394
+ "use strict";
395
+ module2.exports = require_retry();
148
396
  }
149
397
  });
150
398
 
151
399
  // src/index.ts
152
- var src_exports = {};
153
- __export(src_exports, {
400
+ var index_exports = {};
401
+ __export(index_exports, {
154
402
  DefaultDataClient: () => DefaultDataClient,
155
403
  UniformComposition: () => UniformComposition,
156
404
  UniformPlayground: () => UniformPlayground,
@@ -169,7 +417,7 @@ __export(src_exports, {
169
417
  resolveRouteFromCode: () => resolveRouteFromCode,
170
418
  serverContext: () => serverContext
171
419
  });
172
- module.exports = __toCommonJS(src_exports);
420
+ module.exports = __toCommonJS(index_exports);
173
421
  var import_server_only5 = require("server-only");
174
422
 
175
423
  // src/clients/canvas.ts
@@ -178,33 +426,40 @@ var import_server_only = require("server-only");
178
426
  // ../context/dist/api/api.mjs
179
427
  var import_p_limit = __toESM(require_p_limit(), 1);
180
428
  var __defProp2 = Object.defineProperty;
181
- var __typeError = (msg) => {
429
+ var __typeError2 = (msg) => {
182
430
  throw TypeError(msg);
183
431
  };
184
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
185
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
186
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
187
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
188
- 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);
432
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
433
+ var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
434
+ var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
435
+ var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
436
+ var __privateAdd2 = (obj, member, value) => member.has(obj) ? __typeError2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
189
437
  var defaultLimitPolicy = (0, import_p_limit.default)(6);
438
+ var UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE = "Bearer token not valid or expired";
190
439
  var ApiClientError = class _ApiClientError extends Error {
191
440
  constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
192
441
  super(
193
442
  `${errorMessage}
194
443
  ${statusCode}${statusText ? " " + statusText : ""} (${fetchMethod} ${fetchUri}${requestId ? ` Request ID: ${requestId}` : ""})`
195
444
  );
196
- this.errorMessage = errorMessage;
197
- this.fetchMethod = fetchMethod;
198
- this.fetchUri = fetchUri;
199
- this.statusCode = statusCode;
200
- this.statusText = statusText;
201
- this.requestId = requestId;
445
+ __publicField2(this, "errorMessage", errorMessage);
446
+ __publicField2(this, "fetchMethod", fetchMethod);
447
+ __publicField2(this, "fetchUri", fetchUri);
448
+ __publicField2(this, "statusCode", statusCode);
449
+ __publicField2(this, "statusText", statusText);
450
+ __publicField2(this, "requestId", requestId);
202
451
  Object.setPrototypeOf(this, _ApiClientError.prototype);
203
452
  }
204
453
  };
454
+ var BearerTokenNotValidOrExpiredError = class _BearerTokenNotValidOrExpiredError extends ApiClientError {
455
+ constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
456
+ super(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId);
457
+ Object.setPrototypeOf(this, _BearerTokenNotValidOrExpiredError.prototype);
458
+ }
459
+ };
205
460
  var ApiClient = class _ApiClient {
206
461
  constructor(options) {
207
- __publicField(this, "options");
462
+ __publicField2(this, "options");
208
463
  var _a, _b, _c, _d, _e;
209
464
  if (!options.apiKey && !options.bearerToken) {
210
465
  throw new Error("You must provide an API key or a bearer token");
@@ -235,7 +490,7 @@ var ApiClient = class _ApiClient {
235
490
  }
236
491
  async apiClientWithResponse(fetchUri, options) {
237
492
  return this.options.limitPolicy(async () => {
238
- var _a;
493
+ var _a, _b;
239
494
  const coreHeaders = this.options.apiKey ? {
240
495
  "x-api-key": this.options.apiKey
241
496
  } : {
@@ -271,9 +526,19 @@ var ApiClient = class _ApiClient {
271
526
  } catch (e) {
272
527
  message = `General error`;
273
528
  }
529
+ if (apiResponse.status === 401 && message === UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE) {
530
+ throw new BearerTokenNotValidOrExpiredError(
531
+ message,
532
+ (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
533
+ fetchUri.toString(),
534
+ apiResponse.status,
535
+ apiResponse.statusText,
536
+ _ApiClient.getRequestId(apiResponse)
537
+ );
538
+ }
274
539
  throw new ApiClientError(
275
540
  message,
276
- (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
541
+ (_b = options == null ? void 0 : options.method) != null ? _b : "GET",
277
542
  fetchUri.toString(),
278
543
  apiResponse.status,
279
544
  apiResponse.statusText,
@@ -347,25 +612,39 @@ async function handleRateLimits(callApi) {
347
612
  }
348
613
  const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
349
614
  const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
350
- await new Promise((resolve) => setTimeout(resolve, resetWait + backoffWait));
615
+ await new Promise((resolve) => setTimeout(resolve, Math.max(0, resetWait + backoffWait)));
351
616
  backoffRetriesLeft -= 1;
352
617
  }
353
618
  return response;
354
619
  }
355
- var _url;
356
- var _AggregateClient = class _AggregateClient2 extends ApiClient {
357
- constructor(options) {
358
- super(options);
359
- }
620
+ var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
621
+ function rewriteFiltersForApi(filters) {
622
+ return Object.entries(filters != null ? filters : {}).reduce(
623
+ (acc, [key, value]) => {
624
+ const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
625
+ const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
626
+ return {
627
+ ...acc,
628
+ [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
629
+ };
630
+ },
631
+ {}
632
+ );
633
+ }
634
+ var _url;
635
+ var _AggregateClient = class _AggregateClient2 extends ApiClient {
636
+ constructor(options) {
637
+ super(options);
638
+ }
360
639
  /** Fetches all aggregates for a project */
361
640
  async get(options) {
362
641
  const { projectId } = this.options;
363
- const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url), { ...options, projectId });
642
+ const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url), { ...options, projectId });
364
643
  return await this.apiClient(fetchUri);
365
644
  }
366
645
  /** Updates or creates (based on id) an Aggregate */
367
646
  async upsert(body) {
368
- const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url));
647
+ const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url));
369
648
  await this.apiClient(fetchUri, {
370
649
  method: "PUT",
371
650
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -374,7 +653,7 @@ var _AggregateClient = class _AggregateClient2 extends ApiClient {
374
653
  }
375
654
  /** Deletes an Aggregate */
376
655
  async remove(body) {
377
- const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url));
656
+ const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url));
378
657
  await this.apiClient(fetchUri, {
379
658
  method: "DELETE",
380
659
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -383,7 +662,7 @@ var _AggregateClient = class _AggregateClient2 extends ApiClient {
383
662
  }
384
663
  };
385
664
  _url = /* @__PURE__ */ new WeakMap();
386
- __privateAdd(_AggregateClient, _url, "/api/v2/aggregate");
665
+ __privateAdd2(_AggregateClient, _url, "/api/v2/aggregate");
387
666
  var _url2;
388
667
  var _DimensionClient = class _DimensionClient2 extends ApiClient {
389
668
  constructor(options) {
@@ -392,12 +671,12 @@ var _DimensionClient = class _DimensionClient2 extends ApiClient {
392
671
  /** Fetches the known score dimensions for a project */
393
672
  async get(options) {
394
673
  const { projectId } = this.options;
395
- const fetchUri = this.createUrl(__privateGet(_DimensionClient2, _url2), { ...options, projectId });
674
+ const fetchUri = this.createUrl(__privateGet2(_DimensionClient2, _url2), { ...options, projectId });
396
675
  return await this.apiClient(fetchUri);
397
676
  }
398
677
  };
399
678
  _url2 = /* @__PURE__ */ new WeakMap();
400
- __privateAdd(_DimensionClient, _url2, "/api/v2/dimension");
679
+ __privateAdd2(_DimensionClient, _url2, "/api/v2/dimension");
401
680
  var _url3;
402
681
  var _valueUrl;
403
682
  var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
@@ -407,12 +686,12 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
407
686
  /** Fetches all enrichments and values for a project, grouped by category */
408
687
  async get(options) {
409
688
  const { projectId } = this.options;
410
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3), { ...options, projectId });
689
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3), { ...options, projectId });
411
690
  return await this.apiClient(fetchUri);
412
691
  }
413
692
  /** Updates or creates (based on id) an enrichment category */
414
693
  async upsertCategory(body) {
415
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3));
694
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3));
416
695
  await this.apiClient(fetchUri, {
417
696
  method: "PUT",
418
697
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -421,7 +700,7 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
421
700
  }
422
701
  /** Deletes an enrichment category */
423
702
  async removeCategory(body) {
424
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3));
703
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3));
425
704
  await this.apiClient(fetchUri, {
426
705
  method: "DELETE",
427
706
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -430,7 +709,7 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
430
709
  }
431
710
  /** Updates or creates (based on id) an enrichment value within an enrichment category */
432
711
  async upsertValue(body) {
433
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _valueUrl));
712
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _valueUrl));
434
713
  await this.apiClient(fetchUri, {
435
714
  method: "PUT",
436
715
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -439,7 +718,7 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
439
718
  }
440
719
  /** Deletes an enrichment value within an enrichment category. The category is left alone. */
441
720
  async removeValue(body) {
442
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _valueUrl));
721
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _valueUrl));
443
722
  await this.apiClient(fetchUri, {
444
723
  method: "DELETE",
445
724
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -449,8 +728,8 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
449
728
  };
450
729
  _url3 = /* @__PURE__ */ new WeakMap();
451
730
  _valueUrl = /* @__PURE__ */ new WeakMap();
452
- __privateAdd(_EnrichmentClient, _url3, "/api/v1/enrichments");
453
- __privateAdd(_EnrichmentClient, _valueUrl, "/api/v1/enrichment-values");
731
+ __privateAdd2(_EnrichmentClient, _url3, "/api/v1/enrichments");
732
+ __privateAdd2(_EnrichmentClient, _valueUrl, "/api/v1/enrichment-values");
454
733
  var _url4;
455
734
  var _ManifestClient = class _ManifestClient2 extends ApiClient {
456
735
  constructor(options) {
@@ -459,7 +738,7 @@ var _ManifestClient = class _ManifestClient2 extends ApiClient {
459
738
  /** Fetches the Context manifest for a project */
460
739
  async get(options) {
461
740
  const { projectId } = this.options;
462
- const fetchUri = this.createUrl(__privateGet(_ManifestClient2, _url4), { ...options, projectId });
741
+ const fetchUri = this.createUrl(__privateGet2(_ManifestClient2, _url4), { ...options, projectId });
463
742
  return await this.apiClient(fetchUri);
464
743
  }
465
744
  /** Publishes the Context manifest for a project */
@@ -473,7 +752,7 @@ var _ManifestClient = class _ManifestClient2 extends ApiClient {
473
752
  }
474
753
  };
475
754
  _url4 = /* @__PURE__ */ new WeakMap();
476
- __privateAdd(_ManifestClient, _url4, "/api/v2/manifest");
755
+ __privateAdd2(_ManifestClient, _url4, "/api/v2/manifest");
477
756
  var ManifestClient = _ManifestClient;
478
757
  var _url5;
479
758
  var _QuirkClient = class _QuirkClient2 extends ApiClient {
@@ -483,12 +762,12 @@ var _QuirkClient = class _QuirkClient2 extends ApiClient {
483
762
  /** Fetches all Quirks for a project */
484
763
  async get(options) {
485
764
  const { projectId } = this.options;
486
- const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5), { ...options, projectId });
765
+ const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5), { ...options, projectId });
487
766
  return await this.apiClient(fetchUri);
488
767
  }
489
768
  /** Updates or creates (based on id) a Quirk */
490
769
  async upsert(body) {
491
- const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5));
770
+ const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5));
492
771
  await this.apiClient(fetchUri, {
493
772
  method: "PUT",
494
773
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -497,7 +776,7 @@ var _QuirkClient = class _QuirkClient2 extends ApiClient {
497
776
  }
498
777
  /** Deletes a Quirk */
499
778
  async remove(body) {
500
- const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5));
779
+ const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5));
501
780
  await this.apiClient(fetchUri, {
502
781
  method: "DELETE",
503
782
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -506,7 +785,7 @@ var _QuirkClient = class _QuirkClient2 extends ApiClient {
506
785
  }
507
786
  };
508
787
  _url5 = /* @__PURE__ */ new WeakMap();
509
- __privateAdd(_QuirkClient, _url5, "/api/v2/quirk");
788
+ __privateAdd2(_QuirkClient, _url5, "/api/v2/quirk");
510
789
  var _url6;
511
790
  var _SignalClient = class _SignalClient2 extends ApiClient {
512
791
  constructor(options) {
@@ -515,12 +794,12 @@ var _SignalClient = class _SignalClient2 extends ApiClient {
515
794
  /** Fetches all Signals for a project */
516
795
  async get(options) {
517
796
  const { projectId } = this.options;
518
- const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6), { ...options, projectId });
797
+ const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6), { ...options, projectId });
519
798
  return await this.apiClient(fetchUri);
520
799
  }
521
800
  /** Updates or creates (based on id) a Signal */
522
801
  async upsert(body) {
523
- const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6));
802
+ const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6));
524
803
  await this.apiClient(fetchUri, {
525
804
  method: "PUT",
526
805
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -529,7 +808,7 @@ var _SignalClient = class _SignalClient2 extends ApiClient {
529
808
  }
530
809
  /** Deletes a Signal */
531
810
  async remove(body) {
532
- const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6));
811
+ const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6));
533
812
  await this.apiClient(fetchUri, {
534
813
  method: "DELETE",
535
814
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -538,7 +817,7 @@ var _SignalClient = class _SignalClient2 extends ApiClient {
538
817
  }
539
818
  };
540
819
  _url6 = /* @__PURE__ */ new WeakMap();
541
- __privateAdd(_SignalClient, _url6, "/api/v2/signal");
820
+ __privateAdd2(_SignalClient, _url6, "/api/v2/signal");
542
821
  var _url7;
543
822
  var _TestClient = class _TestClient2 extends ApiClient {
544
823
  constructor(options) {
@@ -547,12 +826,12 @@ var _TestClient = class _TestClient2 extends ApiClient {
547
826
  /** Fetches all Tests for a project */
548
827
  async get(options) {
549
828
  const { projectId } = this.options;
550
- const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7), { ...options, projectId });
829
+ const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7), { ...options, projectId });
551
830
  return await this.apiClient(fetchUri);
552
831
  }
553
832
  /** Updates or creates (based on id) a Test */
554
833
  async upsert(body) {
555
- const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7));
834
+ const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7));
556
835
  await this.apiClient(fetchUri, {
557
836
  method: "PUT",
558
837
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -561,7 +840,7 @@ var _TestClient = class _TestClient2 extends ApiClient {
561
840
  }
562
841
  /** Deletes a Test */
563
842
  async remove(body) {
564
- const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7));
843
+ const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7));
565
844
  await this.apiClient(fetchUri, {
566
845
  method: "DELETE",
567
846
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -570,393 +849,194 @@ var _TestClient = class _TestClient2 extends ApiClient {
570
849
  }
571
850
  };
572
851
  _url7 = /* @__PURE__ */ new WeakMap();
573
- __privateAdd(_TestClient, _url7, "/api/v2/test");
852
+ __privateAdd2(_TestClient, _url7, "/api/v2/test");
574
853
 
575
- // ../canvas/dist/index.mjs
576
- var __create2 = Object.create;
577
- var __defProp3 = Object.defineProperty;
578
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
579
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
580
- var __getProtoOf2 = Object.getPrototypeOf;
581
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
582
- var __typeError2 = (msg) => {
583
- throw TypeError(msg);
584
- };
585
- var __commonJS2 = (cb, mod) => function __require() {
586
- return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
587
- };
588
- var __copyProps2 = (to, from, except, desc) => {
589
- if (from && typeof from === "object" || typeof from === "function") {
590
- for (let key of __getOwnPropNames2(from))
591
- if (!__hasOwnProp2.call(to, key) && key !== except)
592
- __defProp3(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
854
+ // ../../node_modules/.pnpm/yocto-queue@1.2.2/node_modules/yocto-queue/index.js
855
+ var Node = class {
856
+ constructor(value) {
857
+ __publicField(this, "value");
858
+ __publicField(this, "next");
859
+ this.value = value;
593
860
  }
594
- return to;
595
861
  };
596
- var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
597
- // If the importer is in node compatibility mode or this is not an ESM
598
- // file that has been converted to a CommonJS file using a Babel-
599
- // compatible transform (i.e. "__esModule" has not been set), then set
600
- // "default" to the CommonJS "module.exports" for node compatibility.
601
- isNodeMode || !mod || !mod.__esModule ? __defProp3(target, "default", { value: mod, enumerable: true }) : target,
602
- mod
603
- ));
604
- var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
605
- var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
606
- var __privateAdd2 = (obj, member, value) => member.has(obj) ? __typeError2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
607
- var require_yocto_queue2 = __commonJS2({
608
- "../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports2, module2) {
609
- "use strict";
610
- var Node = class {
611
- /// value;
612
- /// next;
613
- constructor(value) {
614
- this.value = value;
615
- this.next = void 0;
616
- }
617
- };
618
- var Queue = class {
619
- // TODO: Use private class fields when targeting Node.js 12.
620
- // #_head;
621
- // #_tail;
622
- // #_size;
623
- constructor() {
624
- this.clear();
625
- }
626
- enqueue(value) {
627
- const node = new Node(value);
628
- if (this._head) {
629
- this._tail.next = node;
630
- this._tail = node;
631
- } else {
632
- this._head = node;
633
- this._tail = node;
634
- }
635
- this._size++;
636
- }
637
- dequeue() {
638
- const current = this._head;
639
- if (!current) {
640
- return;
641
- }
642
- this._head = this._head.next;
643
- this._size--;
644
- return current.value;
645
- }
646
- clear() {
647
- this._head = void 0;
648
- this._tail = void 0;
649
- this._size = 0;
650
- }
651
- get size() {
652
- return this._size;
653
- }
654
- *[Symbol.iterator]() {
655
- let current = this._head;
656
- while (current) {
657
- yield current.value;
658
- current = current.next;
659
- }
660
- }
661
- };
662
- module2.exports = Queue;
663
- }
664
- });
665
- var require_p_limit2 = __commonJS2({
666
- "../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports2, module2) {
667
- "use strict";
668
- var Queue = require_yocto_queue2();
669
- var pLimit2 = (concurrency) => {
670
- if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
671
- throw new TypeError("Expected `concurrency` to be a number from 1 and up");
672
- }
673
- const queue = new Queue();
674
- let activeCount = 0;
675
- const next = () => {
676
- activeCount--;
677
- if (queue.size > 0) {
678
- queue.dequeue()();
679
- }
680
- };
681
- const run = async (fn, resolve, ...args) => {
682
- activeCount++;
683
- const result = (async () => fn(...args))();
684
- resolve(result);
685
- try {
686
- await result;
687
- } catch (e) {
688
- }
689
- next();
690
- };
691
- const enqueue = (fn, resolve, ...args) => {
692
- queue.enqueue(run.bind(null, fn, resolve, ...args));
693
- (async () => {
694
- await Promise.resolve();
695
- if (activeCount < concurrency && queue.size > 0) {
696
- queue.dequeue()();
697
- }
698
- })();
699
- };
700
- const generator = (fn, ...args) => new Promise((resolve) => {
701
- enqueue(fn, resolve, ...args);
702
- });
703
- Object.defineProperties(generator, {
704
- activeCount: {
705
- get: () => activeCount
706
- },
707
- pendingCount: {
708
- get: () => queue.size
709
- },
710
- clearQueue: {
711
- value: () => {
712
- queue.clear();
713
- }
714
- }
715
- });
716
- return generator;
717
- };
718
- module2.exports = pLimit2;
719
- }
720
- });
721
- var require_retry_operation = __commonJS2({
722
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports2, module2) {
723
- "use strict";
724
- function RetryOperation(timeouts, options) {
725
- if (typeof options === "boolean") {
726
- options = { forever: options };
727
- }
728
- this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
729
- this._timeouts = timeouts;
730
- this._options = options || {};
731
- this._maxRetryTime = options && options.maxRetryTime || Infinity;
732
- this._fn = null;
733
- this._errors = [];
734
- this._attempts = 1;
735
- this._operationTimeout = null;
736
- this._operationTimeoutCb = null;
737
- this._timeout = null;
738
- this._operationStart = null;
739
- this._timer = null;
740
- if (this._options.forever) {
741
- this._cachedTimeouts = this._timeouts.slice(0);
742
- }
743
- }
744
- module2.exports = RetryOperation;
745
- RetryOperation.prototype.reset = function() {
746
- this._attempts = 1;
747
- this._timeouts = this._originalTimeouts.slice(0);
748
- };
749
- RetryOperation.prototype.stop = function() {
750
- if (this._timeout) {
751
- clearTimeout(this._timeout);
752
- }
753
- if (this._timer) {
754
- clearTimeout(this._timer);
755
- }
756
- this._timeouts = [];
757
- this._cachedTimeouts = null;
758
- };
759
- RetryOperation.prototype.retry = function(err) {
760
- if (this._timeout) {
761
- clearTimeout(this._timeout);
762
- }
763
- if (!err) {
764
- return false;
765
- }
766
- var currentTime = (/* @__PURE__ */ new Date()).getTime();
767
- if (err && currentTime - this._operationStart >= this._maxRetryTime) {
768
- this._errors.push(err);
769
- this._errors.unshift(new Error("RetryOperation timeout occurred"));
770
- return false;
771
- }
772
- this._errors.push(err);
773
- var timeout = this._timeouts.shift();
774
- if (timeout === void 0) {
775
- if (this._cachedTimeouts) {
776
- this._errors.splice(0, this._errors.length - 1);
777
- timeout = this._cachedTimeouts.slice(-1);
778
- } else {
779
- return false;
780
- }
781
- }
782
- var self = this;
783
- this._timer = setTimeout(function() {
784
- self._attempts++;
785
- if (self._operationTimeoutCb) {
786
- self._timeout = setTimeout(function() {
787
- self._operationTimeoutCb(self._attempts);
788
- }, self._operationTimeout);
789
- if (self._options.unref) {
790
- self._timeout.unref();
791
- }
792
- }
793
- self._fn(self._attempts);
794
- }, timeout);
795
- if (this._options.unref) {
796
- this._timer.unref();
797
- }
798
- return true;
799
- };
800
- RetryOperation.prototype.attempt = function(fn, timeoutOps) {
801
- this._fn = fn;
802
- if (timeoutOps) {
803
- if (timeoutOps.timeout) {
804
- this._operationTimeout = timeoutOps.timeout;
805
- }
806
- if (timeoutOps.cb) {
807
- this._operationTimeoutCb = timeoutOps.cb;
808
- }
809
- }
810
- var self = this;
811
- if (this._operationTimeoutCb) {
812
- this._timeout = setTimeout(function() {
813
- self._operationTimeoutCb();
814
- }, self._operationTimeout);
815
- }
816
- this._operationStart = (/* @__PURE__ */ new Date()).getTime();
817
- this._fn(this._attempts);
818
- };
819
- RetryOperation.prototype.try = function(fn) {
820
- console.log("Using RetryOperation.try() is deprecated");
821
- this.attempt(fn);
822
- };
823
- RetryOperation.prototype.start = function(fn) {
824
- console.log("Using RetryOperation.start() is deprecated");
825
- this.attempt(fn);
826
- };
827
- RetryOperation.prototype.start = RetryOperation.prototype.try;
828
- RetryOperation.prototype.errors = function() {
829
- return this._errors;
830
- };
831
- RetryOperation.prototype.attempts = function() {
832
- return this._attempts;
833
- };
834
- RetryOperation.prototype.mainError = function() {
835
- if (this._errors.length === 0) {
836
- return null;
837
- }
838
- var counts = {};
839
- var mainError = null;
840
- var mainErrorCount = 0;
841
- for (var i = 0; i < this._errors.length; i++) {
842
- var error = this._errors[i];
843
- var message = error.message;
844
- var count = (counts[message] || 0) + 1;
845
- counts[message] = count;
846
- if (count >= mainErrorCount) {
847
- mainError = error;
848
- mainErrorCount = count;
849
- }
850
- }
851
- return mainError;
852
- };
853
- }
854
- });
855
- var require_retry = __commonJS2({
856
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports2) {
857
- "use strict";
858
- var RetryOperation = require_retry_operation();
859
- exports2.operation = function(options) {
860
- var timeouts = exports2.timeouts(options);
861
- return new RetryOperation(timeouts, {
862
- forever: options && (options.forever || options.retries === Infinity),
863
- unref: options && options.unref,
864
- maxRetryTime: options && options.maxRetryTime
865
- });
866
- };
867
- exports2.timeouts = function(options) {
868
- if (options instanceof Array) {
869
- return [].concat(options);
870
- }
871
- var opts = {
872
- retries: 10,
873
- factor: 2,
874
- minTimeout: 1 * 1e3,
875
- maxTimeout: Infinity,
876
- randomize: false
877
- };
878
- for (var key in options) {
879
- opts[key] = options[key];
880
- }
881
- if (opts.minTimeout > opts.maxTimeout) {
882
- throw new Error("minTimeout is greater than maxTimeout");
883
- }
884
- var timeouts = [];
885
- for (var i = 0; i < opts.retries; i++) {
886
- timeouts.push(this.createTimeout(i, opts));
887
- }
888
- if (options && options.forever && !timeouts.length) {
889
- timeouts.push(this.createTimeout(i, opts));
862
+ var _head, _tail, _size;
863
+ var Queue = class {
864
+ constructor() {
865
+ __privateAdd(this, _head);
866
+ __privateAdd(this, _tail);
867
+ __privateAdd(this, _size);
868
+ this.clear();
869
+ }
870
+ enqueue(value) {
871
+ const node = new Node(value);
872
+ if (__privateGet(this, _head)) {
873
+ __privateGet(this, _tail).next = node;
874
+ __privateSet(this, _tail, node);
875
+ } else {
876
+ __privateSet(this, _head, node);
877
+ __privateSet(this, _tail, node);
878
+ }
879
+ __privateWrapper(this, _size)._++;
880
+ }
881
+ dequeue() {
882
+ const current = __privateGet(this, _head);
883
+ if (!current) {
884
+ return;
885
+ }
886
+ __privateSet(this, _head, __privateGet(this, _head).next);
887
+ __privateWrapper(this, _size)._--;
888
+ if (!__privateGet(this, _head)) {
889
+ __privateSet(this, _tail, void 0);
890
+ }
891
+ return current.value;
892
+ }
893
+ peek() {
894
+ if (!__privateGet(this, _head)) {
895
+ return;
896
+ }
897
+ return __privateGet(this, _head).value;
898
+ }
899
+ clear() {
900
+ __privateSet(this, _head, void 0);
901
+ __privateSet(this, _tail, void 0);
902
+ __privateSet(this, _size, 0);
903
+ }
904
+ get size() {
905
+ return __privateGet(this, _size);
906
+ }
907
+ *[Symbol.iterator]() {
908
+ let current = __privateGet(this, _head);
909
+ while (current) {
910
+ yield current.value;
911
+ current = current.next;
912
+ }
913
+ }
914
+ *drain() {
915
+ while (__privateGet(this, _head)) {
916
+ yield this.dequeue();
917
+ }
918
+ }
919
+ };
920
+ _head = new WeakMap();
921
+ _tail = new WeakMap();
922
+ _size = new WeakMap();
923
+
924
+ // ../../node_modules/.pnpm/p-limit@6.2.0/node_modules/p-limit/index.js
925
+ function pLimit2(concurrency) {
926
+ validateConcurrency(concurrency);
927
+ const queue = new Queue();
928
+ let activeCount = 0;
929
+ const resumeNext = () => {
930
+ if (activeCount < concurrency && queue.size > 0) {
931
+ queue.dequeue()();
932
+ activeCount++;
933
+ }
934
+ };
935
+ const next = () => {
936
+ activeCount--;
937
+ resumeNext();
938
+ };
939
+ const run = async (function_, resolve, arguments_) => {
940
+ const result = (async () => function_(...arguments_))();
941
+ resolve(result);
942
+ try {
943
+ await result;
944
+ } catch (e) {
945
+ }
946
+ next();
947
+ };
948
+ const enqueue = (function_, resolve, arguments_) => {
949
+ new Promise((internalResolve) => {
950
+ queue.enqueue(internalResolve);
951
+ }).then(
952
+ run.bind(void 0, function_, resolve, arguments_)
953
+ );
954
+ (async () => {
955
+ await Promise.resolve();
956
+ if (activeCount < concurrency) {
957
+ resumeNext();
890
958
  }
891
- timeouts.sort(function(a, b) {
892
- return a - b;
893
- });
894
- return timeouts;
895
- };
896
- exports2.createTimeout = function(attempt, opts) {
897
- var random = opts.randomize ? Math.random() + 1 : 1;
898
- var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
899
- timeout = Math.min(timeout, opts.maxTimeout);
900
- return timeout;
901
- };
902
- exports2.wrap = function(obj, options, methods) {
903
- if (options instanceof Array) {
904
- methods = options;
905
- options = null;
959
+ })();
960
+ };
961
+ const generator = (function_, ...arguments_) => new Promise((resolve) => {
962
+ enqueue(function_, resolve, arguments_);
963
+ });
964
+ Object.defineProperties(generator, {
965
+ activeCount: {
966
+ get: () => activeCount
967
+ },
968
+ pendingCount: {
969
+ get: () => queue.size
970
+ },
971
+ clearQueue: {
972
+ value() {
973
+ queue.clear();
906
974
  }
907
- if (!methods) {
908
- methods = [];
909
- for (var key in obj) {
910
- if (typeof obj[key] === "function") {
911
- methods.push(key);
975
+ },
976
+ concurrency: {
977
+ get: () => concurrency,
978
+ set(newConcurrency) {
979
+ validateConcurrency(newConcurrency);
980
+ concurrency = newConcurrency;
981
+ queueMicrotask(() => {
982
+ while (activeCount < concurrency && queue.size > 0) {
983
+ resumeNext();
912
984
  }
913
- }
914
- }
915
- for (var i = 0; i < methods.length; i++) {
916
- var method = methods[i];
917
- var original = obj[method];
918
- obj[method] = function retryWrapper(original2) {
919
- var op = exports2.operation(options);
920
- var args = Array.prototype.slice.call(arguments, 1);
921
- var callback = args.pop();
922
- args.push(function(err) {
923
- if (op.retry(err)) {
924
- return;
925
- }
926
- if (err) {
927
- arguments[0] = op.mainError();
928
- }
929
- callback.apply(this, arguments);
930
- });
931
- op.attempt(function() {
932
- original2.apply(obj, args);
933
- });
934
- }.bind(obj, original);
935
- obj[method].options = options;
985
+ });
936
986
  }
937
- };
938
- }
939
- });
940
- var require_retry2 = __commonJS2({
941
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports2, module2) {
942
- "use strict";
943
- module2.exports = require_retry();
987
+ }
988
+ });
989
+ return generator;
990
+ }
991
+ function validateConcurrency(concurrency) {
992
+ if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
993
+ throw new TypeError("Expected `concurrency` to be a number from 1 and up");
944
994
  }
945
- });
946
- var import_p_limit2 = __toESM2(require_p_limit2());
947
- var import_retry = __toESM2(require_retry2(), 1);
948
- var networkErrorMsgs = /* @__PURE__ */ new Set([
949
- "Failed to fetch",
995
+ }
996
+
997
+ // ../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
998
+ var import_retry = __toESM(require_retry2(), 1);
999
+
1000
+ // ../../node_modules/.pnpm/is-network-error@1.3.2/node_modules/is-network-error/index.js
1001
+ var objectToString = Object.prototype.toString;
1002
+ var isError = (value) => objectToString.call(value) === "[object Error]";
1003
+ var errorMessages = /* @__PURE__ */ new Set([
1004
+ "network error",
950
1005
  // Chrome
951
1006
  "NetworkError when attempting to fetch resource.",
952
1007
  // Firefox
953
1008
  "The Internet connection appears to be offline.",
954
- // Safari
1009
+ // Safari 16
955
1010
  "Network request failed",
956
1011
  // `cross-fetch`
957
- "fetch failed"
1012
+ "fetch failed",
1013
+ // Undici (Node.js)
1014
+ "terminated",
958
1015
  // Undici (Node.js)
1016
+ " A network error occurred.",
1017
+ // Bun (WebKit)
1018
+ "Network connection lost"
1019
+ // Cloudflare Workers (fetch)
959
1020
  ]);
1021
+ function isNetworkError(error) {
1022
+ const isValid = error && isError(error) && error.name === "TypeError" && typeof error.message === "string";
1023
+ if (!isValid) {
1024
+ return false;
1025
+ }
1026
+ const { message, stack } = error;
1027
+ if (message === "Load failed" || message.startsWith("Load failed (") && message.endsWith(")")) {
1028
+ return stack === void 0 || "__sentry_captured__" in error;
1029
+ }
1030
+ if (message.startsWith("error sending request for url")) {
1031
+ return true;
1032
+ }
1033
+ if (message === "Failed to fetch" || message.startsWith("Failed to fetch (") && message.endsWith(")")) {
1034
+ return true;
1035
+ }
1036
+ return errorMessages.has(message);
1037
+ }
1038
+
1039
+ // ../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
960
1040
  var AbortError = class extends Error {
961
1041
  constructor(message) {
962
1042
  super();
@@ -977,63 +1057,71 @@ var decorateErrorWithCounts = (error, attemptNumber, options) => {
977
1057
  error.retriesLeft = retriesLeft;
978
1058
  return error;
979
1059
  };
980
- var isNetworkError = (errorMessage) => networkErrorMsgs.has(errorMessage);
981
- var getDOMException = (errorMessage) => globalThis.DOMException === void 0 ? new Error(errorMessage) : new DOMException(errorMessage);
982
1060
  async function pRetry(input, options) {
983
1061
  return new Promise((resolve, reject) => {
984
- options = {
985
- onFailedAttempt() {
986
- },
987
- retries: 10,
988
- ...options
1062
+ var _a, _b, _c;
1063
+ options = { ...options };
1064
+ (_a = options.onFailedAttempt) != null ? _a : options.onFailedAttempt = () => {
989
1065
  };
1066
+ (_b = options.shouldRetry) != null ? _b : options.shouldRetry = () => true;
1067
+ (_c = options.retries) != null ? _c : options.retries = 10;
990
1068
  const operation = import_retry.default.operation(options);
1069
+ const abortHandler = () => {
1070
+ var _a2;
1071
+ operation.stop();
1072
+ reject((_a2 = options.signal) == null ? void 0 : _a2.reason);
1073
+ };
1074
+ if (options.signal && !options.signal.aborted) {
1075
+ options.signal.addEventListener("abort", abortHandler, { once: true });
1076
+ }
1077
+ const cleanUp = () => {
1078
+ var _a2;
1079
+ (_a2 = options.signal) == null ? void 0 : _a2.removeEventListener("abort", abortHandler);
1080
+ operation.stop();
1081
+ };
991
1082
  operation.attempt(async (attemptNumber) => {
992
1083
  try {
993
- resolve(await input(attemptNumber));
1084
+ const result = await input(attemptNumber);
1085
+ cleanUp();
1086
+ resolve(result);
994
1087
  } catch (error) {
995
- if (!(error instanceof Error)) {
996
- reject(new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`));
997
- return;
998
- }
999
- if (error instanceof AbortError) {
1000
- operation.stop();
1001
- reject(error.originalError);
1002
- } else if (error instanceof TypeError && !isNetworkError(error.message)) {
1003
- operation.stop();
1004
- reject(error);
1005
- } else {
1088
+ try {
1089
+ if (!(error instanceof Error)) {
1090
+ throw new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
1091
+ }
1092
+ if (error instanceof AbortError) {
1093
+ throw error.originalError;
1094
+ }
1095
+ if (error instanceof TypeError && !isNetworkError(error)) {
1096
+ throw error;
1097
+ }
1006
1098
  decorateErrorWithCounts(error, attemptNumber, options);
1007
- try {
1008
- await options.onFailedAttempt(error);
1009
- } catch (error2) {
1010
- reject(error2);
1011
- return;
1099
+ if (!await options.shouldRetry(error)) {
1100
+ operation.stop();
1101
+ reject(error);
1012
1102
  }
1103
+ await options.onFailedAttempt(error);
1013
1104
  if (!operation.retry(error)) {
1014
- reject(operation.mainError());
1105
+ throw operation.mainError();
1015
1106
  }
1107
+ } catch (finalError) {
1108
+ decorateErrorWithCounts(finalError, attemptNumber, options);
1109
+ cleanUp();
1110
+ reject(finalError);
1016
1111
  }
1017
1112
  }
1018
1113
  });
1019
- if (options.signal && !options.signal.aborted) {
1020
- options.signal.addEventListener("abort", () => {
1021
- operation.stop();
1022
- const reason = options.signal.reason === void 0 ? getDOMException("The operation was aborted.") : options.signal.reason;
1023
- reject(reason instanceof Error ? reason : getDOMException(reason));
1024
- }, {
1025
- once: true
1026
- });
1027
- }
1028
1114
  });
1029
1115
  }
1116
+
1117
+ // ../../node_modules/.pnpm/p-throttle@6.2.0/node_modules/p-throttle/index.js
1030
1118
  var AbortError2 = class extends Error {
1031
1119
  constructor() {
1032
1120
  super("Throttled function aborted");
1033
1121
  this.name = "AbortError";
1034
1122
  }
1035
1123
  };
1036
- function pThrottle({ limit, interval, strict }) {
1124
+ function pThrottle({ limit, interval, strict, onDelay }) {
1037
1125
  if (!Number.isFinite(limit)) {
1038
1126
  throw new TypeError("Expected `limit` to be a finite number");
1039
1127
  }
@@ -1061,32 +1149,38 @@ function pThrottle({ limit, interval, strict }) {
1061
1149
  const strictTicks = [];
1062
1150
  function strictDelay() {
1063
1151
  const now = Date.now();
1064
- if (strictTicks.length < limit) {
1065
- strictTicks.push(now);
1066
- return 0;
1152
+ if (strictTicks.length > 0 && now - strictTicks.at(-1) > interval) {
1153
+ strictTicks.length = 0;
1067
1154
  }
1068
- const earliestTime = strictTicks.shift() + interval;
1069
- if (now >= earliestTime) {
1155
+ if (strictTicks.length < limit) {
1070
1156
  strictTicks.push(now);
1071
1157
  return 0;
1072
1158
  }
1073
- strictTicks.push(earliestTime);
1074
- return earliestTime - now;
1159
+ const nextExecutionTime = strictTicks[0] + interval;
1160
+ strictTicks.shift();
1161
+ strictTicks.push(nextExecutionTime);
1162
+ return Math.max(0, nextExecutionTime - now);
1075
1163
  }
1076
1164
  const getDelay = strict ? strictDelay : windowedDelay;
1077
1165
  return (function_) => {
1078
- const throttled = function(...args) {
1166
+ const throttled = function(...arguments_) {
1079
1167
  if (!throttled.isEnabled) {
1080
- return (async () => function_.apply(this, args))();
1168
+ return (async () => function_.apply(this, arguments_))();
1081
1169
  }
1082
- let timeout;
1170
+ let timeoutId;
1083
1171
  return new Promise((resolve, reject) => {
1084
1172
  const execute = () => {
1085
- resolve(function_.apply(this, args));
1086
- queue.delete(timeout);
1173
+ resolve(function_.apply(this, arguments_));
1174
+ queue.delete(timeoutId);
1087
1175
  };
1088
- timeout = setTimeout(execute, getDelay());
1089
- queue.set(timeout, reject);
1176
+ const delay = getDelay();
1177
+ if (delay > 0) {
1178
+ timeoutId = setTimeout(execute, delay);
1179
+ queue.set(timeoutId, reject);
1180
+ onDelay == null ? void 0 : onDelay(...arguments_);
1181
+ } else {
1182
+ execute();
1183
+ }
1090
1184
  });
1091
1185
  };
1092
1186
  throttled.abort = () => {
@@ -1098,16 +1192,29 @@ function pThrottle({ limit, interval, strict }) {
1098
1192
  strictTicks.splice(0, strictTicks.length);
1099
1193
  };
1100
1194
  throttled.isEnabled = true;
1195
+ Object.defineProperty(throttled, "queueSize", {
1196
+ get() {
1197
+ return queue.size;
1198
+ }
1199
+ });
1101
1200
  return throttled;
1102
1201
  };
1103
1202
  }
1203
+
1204
+ // ../canvas/dist/index.mjs
1205
+ var __typeError3 = (msg) => {
1206
+ throw TypeError(msg);
1207
+ };
1208
+ var __accessCheck3 = (obj, member, msg) => member.has(obj) || __typeError3("Cannot " + msg);
1209
+ var __privateGet3 = (obj, member, getter) => (__accessCheck3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1210
+ var __privateAdd3 = (obj, member, value) => member.has(obj) ? __typeError3("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1104
1211
  function createLimitPolicy({
1105
1212
  throttle = { interval: 1e3, limit: 10 },
1106
- retry: retry2 = { retries: 1, factor: 1.66 },
1213
+ retry: retry3 = { retries: 1, factor: 1.66 },
1107
1214
  limit = 10
1108
1215
  }) {
1109
1216
  const throttler = throttle ? pThrottle(throttle) : null;
1110
- const limiter = limit ? (0, import_p_limit2.default)(limit) : null;
1217
+ const limiter = limit ? pLimit2(limit) : null;
1111
1218
  return function limitPolicy(func) {
1112
1219
  let currentFunc = async () => await func();
1113
1220
  if (throttler) {
@@ -1118,13 +1225,13 @@ function createLimitPolicy({
1118
1225
  const limitFunc = currentFunc;
1119
1226
  currentFunc = () => limiter(limitFunc);
1120
1227
  }
1121
- if (retry2) {
1228
+ if (retry3) {
1122
1229
  const retryFunc = currentFunc;
1123
1230
  currentFunc = () => pRetry(retryFunc, {
1124
- ...retry2,
1231
+ ...retry3,
1125
1232
  onFailedAttempt: async (error) => {
1126
- if (retry2.onFailedAttempt) {
1127
- await retry2.onFailedAttempt(error);
1233
+ if (retry3.onFailedAttempt) {
1234
+ await retry3.onFailedAttempt(error);
1128
1235
  }
1129
1236
  if (error instanceof ApiClientError && typeof error.statusCode === "number" && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429 && error.statusCode !== 408) {
1130
1237
  throw error;
@@ -1135,19 +1242,49 @@ function createLimitPolicy({
1135
1242
  return currentFunc();
1136
1243
  };
1137
1244
  }
1138
- var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
1139
- function rewriteFilters(filters) {
1140
- return Object.entries(filters != null ? filters : {}).reduce(
1141
- (acc, [key, value]) => {
1142
- const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
1143
- const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
1144
- return {
1145
- ...acc,
1146
- [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
1147
- };
1148
- },
1149
- {}
1150
- );
1245
+ var SELECT_QUERY_PREFIX = "select.";
1246
+ function appendCsv(out, key, values) {
1247
+ if (values === void 0) {
1248
+ return;
1249
+ }
1250
+ out[key] = values.join(",");
1251
+ }
1252
+ function projectionToQuery(spec) {
1253
+ const out = {};
1254
+ if (!spec) {
1255
+ return out;
1256
+ }
1257
+ const { fields, fieldTypes, slots } = spec;
1258
+ const p = SELECT_QUERY_PREFIX;
1259
+ if (fields) {
1260
+ appendCsv(out, `${p}fields[only]`, fields.only);
1261
+ appendCsv(out, `${p}fields[except]`, fields.except);
1262
+ appendCsv(out, `${p}fields[locales]`, fields.locales);
1263
+ if (fields.blockDepth === "preserveAll" || typeof fields.blockDepth === "number") {
1264
+ out[`${p}fields[blockDepth]`] = String(fields.blockDepth);
1265
+ }
1266
+ }
1267
+ if (fieldTypes) {
1268
+ appendCsv(out, `${p}fieldTypes[only]`, fieldTypes.only);
1269
+ appendCsv(out, `${p}fieldTypes[except]`, fieldTypes.except);
1270
+ }
1271
+ if (slots) {
1272
+ appendCsv(out, `${p}slots[only]`, slots.only);
1273
+ appendCsv(out, `${p}slots[except]`, slots.except);
1274
+ if (typeof slots.depth === "number") {
1275
+ out[`${p}slots[depth]`] = String(slots.depth);
1276
+ }
1277
+ if (slots.named) {
1278
+ const slotNames = Object.keys(slots.named).sort();
1279
+ for (const slotName of slotNames) {
1280
+ const named = slots.named[slotName];
1281
+ if (named && typeof named.depth === "number") {
1282
+ out[`${p}slots.${slotName}[depth]`] = String(named.depth);
1283
+ }
1284
+ }
1285
+ }
1286
+ }
1287
+ return out;
1151
1288
  }
1152
1289
  var CANVAS_URL = "/api/v1/canvas";
1153
1290
  var CanvasClient = class extends ApiClient {
@@ -1163,17 +1300,24 @@ var CanvasClient = class extends ApiClient {
1163
1300
  /** Fetches lists of Canvas compositions, optionally by type */
1164
1301
  async getCompositionList(params = {}) {
1165
1302
  const { projectId } = this.options;
1166
- const { resolveData, filters, ...originParams } = params;
1167
- const rewrittenFilters = rewriteFilters(filters);
1303
+ const { resolveData, filters, select, ...originParams } = params;
1304
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1305
+ const rewrittenSelect = projectionToQuery(select);
1168
1306
  if (!resolveData) {
1169
- const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
1307
+ const fetchUri = this.createUrl(CANVAS_URL, {
1308
+ ...originParams,
1309
+ projectId,
1310
+ ...rewrittenFilters,
1311
+ ...rewrittenSelect
1312
+ });
1170
1313
  return this.apiClient(fetchUri);
1171
1314
  }
1172
1315
  const edgeParams = {
1173
1316
  ...originParams,
1174
1317
  projectId,
1175
1318
  diagnostics: typeof params.diagnostics === "boolean" ? params.diagnostics : params.diagnostics === "no-data" ? "no-data" : void 0,
1176
- ...rewrittenFilters
1319
+ ...rewrittenFilters,
1320
+ ...rewrittenSelect
1177
1321
  };
1178
1322
  const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
1179
1323
  return this.apiClient(edgeUrl, this.edgeApiRequestInit);
@@ -1278,20 +1422,26 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1278
1422
  }
1279
1423
  getContentTypes(options) {
1280
1424
  const { projectId } = this.options;
1281
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl), { ...options, projectId });
1425
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _contentTypesUrl), { ...options, projectId });
1282
1426
  return this.apiClient(fetchUri);
1283
1427
  }
1284
1428
  getEntries(options) {
1285
1429
  const { projectId } = this.options;
1286
- const { skipDataResolution, filters, ...params } = options;
1287
- const rewrittenFilters = rewriteFilters(filters);
1430
+ const { skipDataResolution, filters, select, ...params } = options;
1431
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1432
+ const rewrittenSelect = projectionToQuery(select);
1288
1433
  if (skipDataResolution) {
1289
- const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
1434
+ const url = this.createUrl(__privateGet3(_ContentClient2, _entriesUrl), {
1435
+ ...params,
1436
+ ...rewrittenFilters,
1437
+ ...rewrittenSelect,
1438
+ projectId
1439
+ });
1290
1440
  return this.apiClient(url);
1291
1441
  }
1292
1442
  const edgeUrl = this.createUrl(
1293
- __privateGet2(_ContentClient2, _entriesUrl),
1294
- { ...this.getEdgeOptions(params), ...rewrittenFilters },
1443
+ __privateGet3(_ContentClient2, _entriesUrl),
1444
+ { ...this.getEdgeOptions(params), ...rewrittenFilters, ...rewrittenSelect },
1295
1445
  this.edgeApiHost
1296
1446
  );
1297
1447
  return this.apiClient(
@@ -1308,7 +1458,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1308
1458
  return this.apiClient(historyUrl);
1309
1459
  }
1310
1460
  async upsertContentType(body, opts = {}) {
1311
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl));
1461
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _contentTypesUrl));
1312
1462
  if (typeof body.contentType.slugSettings === "object" && body.contentType.slugSettings !== null && Object.keys(body.contentType.slugSettings).length === 0) {
1313
1463
  delete body.contentType.slugSettings;
1314
1464
  }
@@ -1320,7 +1470,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1320
1470
  });
1321
1471
  }
1322
1472
  async upsertEntry(body, options) {
1323
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl));
1473
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _entriesUrl));
1324
1474
  const headers = {};
1325
1475
  if (options == null ? void 0 : options.ifUnmodifiedSince) {
1326
1476
  headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
@@ -1334,7 +1484,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1334
1484
  return { modified: response.headers.get("x-modified-at") };
1335
1485
  }
1336
1486
  async deleteContentType(body) {
1337
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl));
1487
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _contentTypesUrl));
1338
1488
  await this.apiClient(fetchUri, {
1339
1489
  method: "DELETE",
1340
1490
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1342,7 +1492,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1342
1492
  });
1343
1493
  }
1344
1494
  async deleteEntry(body) {
1345
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl));
1495
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _entriesUrl));
1346
1496
  await this.apiClient(fetchUri, {
1347
1497
  method: "DELETE",
1348
1498
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1361,8 +1511,8 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1361
1511
  };
1362
1512
  _contentTypesUrl = /* @__PURE__ */ new WeakMap();
1363
1513
  _entriesUrl = /* @__PURE__ */ new WeakMap();
1364
- __privateAdd2(_ContentClient, _contentTypesUrl, "/api/v1/content-types");
1365
- __privateAdd2(_ContentClient, _entriesUrl, "/api/v1/entries");
1514
+ __privateAdd3(_ContentClient, _contentTypesUrl, "/api/v1/content-types");
1515
+ __privateAdd3(_ContentClient, _entriesUrl, "/api/v1/entries");
1366
1516
  var _url8;
1367
1517
  var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1368
1518
  constructor(options) {
@@ -1371,12 +1521,12 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1371
1521
  /** Fetches all DataTypes for a project */
1372
1522
  async get(options) {
1373
1523
  const { projectId } = this.options;
1374
- const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8), { ...options, projectId });
1524
+ const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8), { ...options, projectId });
1375
1525
  return await this.apiClient(fetchUri);
1376
1526
  }
1377
1527
  /** Updates or creates (based on id) a DataType */
1378
1528
  async upsert(body) {
1379
- const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8));
1529
+ const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
1380
1530
  await this.apiClient(fetchUri, {
1381
1531
  method: "PUT",
1382
1532
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1385,7 +1535,7 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1385
1535
  }
1386
1536
  /** Deletes a DataType */
1387
1537
  async remove(body) {
1388
- const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8));
1538
+ const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
1389
1539
  await this.apiClient(fetchUri, {
1390
1540
  method: "DELETE",
1391
1541
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1394,7 +1544,7 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1394
1544
  }
1395
1545
  };
1396
1546
  _url8 = /* @__PURE__ */ new WeakMap();
1397
- __privateAdd2(_DataTypeClient, _url8, "/api/v1/data-types");
1547
+ __privateAdd3(_DataTypeClient, _url8, "/api/v1/data-types");
1398
1548
  function getComponentPath(ancestorsAndSelf) {
1399
1549
  const path = [];
1400
1550
  for (let i = ancestorsAndSelf.length - 1; i >= 0; i--) {
@@ -1457,9 +1607,9 @@ function parseVariableExpression(serialized, onToken) {
1457
1607
  let bufferStartIndex = 0;
1458
1608
  let bufferEndIndex = 0;
1459
1609
  let tokenCount = 0;
1460
- const handleToken = (token, type) => {
1610
+ const handleToken = (token, type, offset) => {
1461
1611
  tokenCount++;
1462
- return onToken == null ? void 0 : onToken(token, type);
1612
+ return onToken == null ? void 0 : onToken(token, type, offset);
1463
1613
  };
1464
1614
  let state = "text";
1465
1615
  for (let index = 0; index < serialized.length; index++) {
@@ -1470,7 +1620,7 @@ function parseVariableExpression(serialized, onToken) {
1470
1620
  if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
1471
1621
  if (serialized[index - 1] === escapeCharacter) {
1472
1622
  bufferEndIndex -= escapeCharacter.length;
1473
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
1623
+ if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
1474
1624
  return tokenCount;
1475
1625
  }
1476
1626
  bufferStartIndex = index;
@@ -1479,12 +1629,12 @@ function parseVariableExpression(serialized, onToken) {
1479
1629
  }
1480
1630
  if (state === "variable") {
1481
1631
  const textStart = bufferStartIndex - variablePrefix.length;
1482
- if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
1632
+ if (handleToken(serialized.substring(textStart, bufferEndIndex), "text", textStart) === false) {
1483
1633
  return tokenCount;
1484
1634
  }
1485
1635
  bufferStartIndex = bufferEndIndex;
1486
1636
  } else if (bufferEndIndex > bufferStartIndex) {
1487
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
1637
+ if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
1488
1638
  return tokenCount;
1489
1639
  }
1490
1640
  bufferStartIndex = bufferEndIndex;
@@ -1502,7 +1652,7 @@ function parseVariableExpression(serialized, onToken) {
1502
1652
  state = "text";
1503
1653
  if (bufferEndIndex > bufferStartIndex) {
1504
1654
  const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
1505
- if (handleToken(unescapedVariableName, "variable") === false) {
1655
+ if (handleToken(unescapedVariableName, "variable", bufferStartIndex) === false) {
1506
1656
  return tokenCount;
1507
1657
  }
1508
1658
  bufferStartIndex = bufferEndIndex + variableSuffix.length;
@@ -1516,7 +1666,7 @@ function parseVariableExpression(serialized, onToken) {
1516
1666
  bufferStartIndex -= variablePrefix.length;
1517
1667
  }
1518
1668
  if (bufferStartIndex < serialized.length) {
1519
- handleToken(serialized.substring(bufferStartIndex), state);
1669
+ handleToken(serialized.substring(bufferStartIndex), state, bufferStartIndex);
1520
1670
  }
1521
1671
  return tokenCount;
1522
1672
  }
@@ -1533,7 +1683,7 @@ function hasReferencedVariables(value) {
1533
1683
  return variableTokenCount;
1534
1684
  }
1535
1685
  function walkNodeTree(node, visitor, options) {
1536
- var _a, _b;
1686
+ var _a, _b, _c;
1537
1687
  const componentQueue = [
1538
1688
  {
1539
1689
  ancestorsAndSelf: Array.isArray(node) ? node : [{ node, type: "root" }],
@@ -1541,12 +1691,14 @@ function walkNodeTree(node, visitor, options) {
1541
1691
  }
1542
1692
  ];
1543
1693
  const childContexts = /* @__PURE__ */ new Map();
1694
+ const order = (_a = options == null ? void 0 : options.order) != null ? _a : "dfs";
1695
+ const takeNext = () => order === "bfs" ? componentQueue.shift() : componentQueue.pop();
1544
1696
  do {
1545
- const currentQueueEntry = componentQueue.pop();
1697
+ const currentQueueEntry = takeNext();
1546
1698
  if (!currentQueueEntry) continue;
1547
1699
  const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
1548
1700
  let visitDescendants = true;
1549
- let descendantContext = (_a = childContexts.get(currentComponent.node)) != null ? _a : currentQueueEntry.context;
1701
+ let descendantContext = (_b = childContexts.get(currentComponent.node)) != null ? _b : currentQueueEntry.context;
1550
1702
  let visitorInfo;
1551
1703
  if (currentComponent.type === "root" && isRootEntryReference(currentComponent) || currentComponent.type === "block") {
1552
1704
  visitorInfo = {
@@ -1733,39 +1885,11 @@ function walkNodeTree(node, visitor, options) {
1733
1885
  continue;
1734
1886
  }
1735
1887
  const slots = "slots" in currentComponent.node && currentComponent.node.slots;
1736
- if (slots) {
1737
- const slotKeys = Object.keys(slots);
1738
- for (let slotIndex = slotKeys.length - 1; slotIndex >= 0; slotIndex--) {
1739
- const slotKey = slotKeys[slotIndex];
1740
- const components = slots[slotKey];
1741
- for (let componentIndex = components.length - 1; componentIndex >= 0; componentIndex--) {
1742
- const enqueueingComponent = components[componentIndex];
1743
- const parentSlotIndexFn = () => {
1744
- const result = currentComponent.node.slots[slotKey].findIndex(
1745
- (x) => x === enqueueingComponent
1746
- );
1747
- return result;
1748
- };
1749
- componentQueue.push({
1750
- ancestorsAndSelf: [
1751
- {
1752
- type: "slot",
1753
- node: enqueueingComponent,
1754
- parentSlot: slotKey,
1755
- parentSlotIndexFn
1756
- },
1757
- ...currentQueueEntry.ancestorsAndSelf
1758
- ],
1759
- context: descendantContext
1760
- });
1761
- }
1762
- }
1763
- }
1888
+ const childEntries = [];
1764
1889
  const properties = getPropertiesValue(currentComponent.node);
1765
1890
  if (properties) {
1766
1891
  const propertyEntries = Object.entries(properties);
1767
- for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
1768
- const [propKey, propObject] = propertyEntries[propIndex];
1892
+ for (const [propKey, propObject] of propertyEntries) {
1769
1893
  if (!isNestedNodeType(propObject.type)) {
1770
1894
  continue;
1771
1895
  }
@@ -1785,13 +1909,12 @@ function walkNodeTree(node, visitor, options) {
1785
1909
  continue;
1786
1910
  }
1787
1911
  }
1788
- const blocks = (_b = propObject.value) != null ? _b : [];
1789
- for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
1790
- const enqueueingBlock = blocks[blockIndex];
1912
+ const blocks = (_c = propObject.value) != null ? _c : [];
1913
+ for (const enqueueingBlock of blocks) {
1791
1914
  const blockIndexFn = () => {
1792
1915
  return getBlockValue(currentComponent.node, propKey).findIndex((x) => x === enqueueingBlock);
1793
1916
  };
1794
- componentQueue.push({
1917
+ childEntries.push({
1795
1918
  ancestorsAndSelf: [
1796
1919
  {
1797
1920
  type: "block",
@@ -1806,6 +1929,36 @@ function walkNodeTree(node, visitor, options) {
1806
1929
  }
1807
1930
  }
1808
1931
  }
1932
+ if (slots) {
1933
+ const slotKeys = Object.keys(slots);
1934
+ for (const slotKey of slotKeys) {
1935
+ const components = slots[slotKey];
1936
+ for (const enqueueingComponent of components) {
1937
+ const parentSlotIndexFn = () => {
1938
+ const result = currentComponent.node.slots[slotKey].findIndex(
1939
+ (x) => x === enqueueingComponent
1940
+ );
1941
+ return result;
1942
+ };
1943
+ childEntries.push({
1944
+ ancestorsAndSelf: [
1945
+ {
1946
+ type: "slot",
1947
+ node: enqueueingComponent,
1948
+ parentSlot: slotKey,
1949
+ parentSlotIndexFn
1950
+ },
1951
+ ...currentQueueEntry.ancestorsAndSelf
1952
+ ],
1953
+ context: descendantContext
1954
+ });
1955
+ }
1956
+ }
1957
+ }
1958
+ if (order === "dfs") {
1959
+ childEntries.reverse();
1960
+ }
1961
+ componentQueue.push(...childEntries);
1809
1962
  } while (componentQueue.length > 0);
1810
1963
  }
1811
1964
  function isNestedNodeType(type) {
@@ -1844,7 +1997,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1844
1997
  * Gets a list of property type and hook names for the current team, including public integrations' hooks.
1845
1998
  */
1846
1999
  get(options) {
1847
- const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl), {
2000
+ const fetchUri = this.createUrl(__privateGet3(_IntegrationPropertyEditorsClient2, _baseUrl), {
1848
2001
  ...options,
1849
2002
  teamId: this.teamId
1850
2003
  });
@@ -1854,7 +2007,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1854
2007
  * Creates or updates a custom AI property editor on a Mesh app.
1855
2008
  */
1856
2009
  async deploy(body) {
1857
- const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl));
2010
+ const fetchUri = this.createUrl(__privateGet3(_IntegrationPropertyEditorsClient2, _baseUrl));
1858
2011
  await this.apiClient(fetchUri, {
1859
2012
  method: "PUT",
1860
2013
  body: JSON.stringify({ ...body, teamId: this.teamId }),
@@ -1865,7 +2018,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1865
2018
  * Removes a custom AI property editor from a Mesh app.
1866
2019
  */
1867
2020
  async delete(body) {
1868
- const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl));
2021
+ const fetchUri = this.createUrl(__privateGet3(_IntegrationPropertyEditorsClient2, _baseUrl));
1869
2022
  await this.apiClient(fetchUri, {
1870
2023
  method: "DELETE",
1871
2024
  body: JSON.stringify({ ...body, teamId: this.teamId }),
@@ -1874,20 +2027,30 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1874
2027
  }
1875
2028
  };
1876
2029
  _baseUrl = /* @__PURE__ */ new WeakMap();
1877
- __privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
2030
+ __privateAdd3(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
1878
2031
  var _url22;
2032
+ var _projectsUrl;
1879
2033
  var _ProjectClient = class _ProjectClient2 extends ApiClient {
1880
2034
  constructor(options) {
1881
2035
  super({ ...options, bypassCache: true });
1882
2036
  }
1883
2037
  /** Fetches single Project */
1884
2038
  async get(options) {
1885
- const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22), { ...options });
2039
+ const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22), { ...options });
2040
+ return await this.apiClient(fetchUri);
2041
+ }
2042
+ /**
2043
+ * Fetches projects grouped by team.
2044
+ * When teamId is provided, returns a single team with its projects.
2045
+ * When omitted, returns all accessible teams and their projects.
2046
+ */
2047
+ async getProjects(options) {
2048
+ const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
1886
2049
  return await this.apiClient(fetchUri);
1887
2050
  }
1888
2051
  /** Updates or creates (based on id) a Project */
1889
2052
  async upsert(body) {
1890
- const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
2053
+ const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
1891
2054
  return await this.apiClient(fetchUri, {
1892
2055
  method: "PUT",
1893
2056
  body: JSON.stringify({ ...body })
@@ -1895,7 +2058,7 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1895
2058
  }
1896
2059
  /** Deletes a Project */
1897
2060
  async delete(body) {
1898
- const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
2061
+ const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
1899
2062
  await this.apiClient(fetchUri, {
1900
2063
  method: "DELETE",
1901
2064
  body: JSON.stringify({ ...body }),
@@ -1904,7 +2067,9 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1904
2067
  }
1905
2068
  };
1906
2069
  _url22 = /* @__PURE__ */ new WeakMap();
1907
- __privateAdd2(_ProjectClient, _url22, "/api/v1/project");
2070
+ _projectsUrl = /* @__PURE__ */ new WeakMap();
2071
+ __privateAdd3(_ProjectClient, _url22, "/api/v1/project");
2072
+ __privateAdd3(_ProjectClient, _projectsUrl, "/api/v1/projects");
1908
2073
  var ROUTE_URL = "/api/v1/route";
1909
2074
  var RouteClient = class extends ApiClient {
1910
2075
  constructor(options) {
@@ -1918,13 +2083,26 @@ var RouteClient = class extends ApiClient {
1918
2083
  /** Fetches lists of Canvas compositions, optionally by type */
1919
2084
  async getRoute(options) {
1920
2085
  const { projectId } = this.options;
1921
- const fetchUri = this.createUrl(ROUTE_URL, { ...options, projectId }, this.edgeApiHost);
2086
+ const { select, ...rest } = options != null ? options : {};
2087
+ const rewrittenSelect = projectionToQuery(select);
2088
+ const fetchUri = this.createUrl(ROUTE_URL, { ...rest, projectId, ...rewrittenSelect }, this.edgeApiHost);
1922
2089
  return await this.apiClient(
1923
2090
  fetchUri,
1924
2091
  this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
1925
2092
  );
1926
2093
  }
1927
2094
  };
2095
+ var getDataSourceVariantFromRouteGetParams = (params, defaultPreviewState) => {
2096
+ var _a, _b;
2097
+ const dataSourceVariant = (
2098
+ // support explicit 'undefined' as a way to opt out of data resources variant
2099
+ "dataSourceVariant" in params ? params.dataSourceVariant : (
2100
+ // in case of DRAFT state we still want to fetch unpublished data
2101
+ ((_b = (_a = params == null ? void 0 : params.state) != null ? _a : defaultPreviewState) != null ? _b : CANVAS_PUBLISHED_STATE) !== CANVAS_PUBLISHED_STATE ? "unpublished" : void 0
2102
+ )
2103
+ );
2104
+ return dataSourceVariant;
2105
+ };
1928
2106
  function mapSlotToPersonalizedVariations(slot) {
1929
2107
  if (!slot) return [];
1930
2108
  return slot.map((v, i) => {
@@ -2006,8 +2184,15 @@ var isIncontextEditingEnabled = ({
2006
2184
  var isDevelopmentEnvironment = () => {
2007
2185
  return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
2008
2186
  };
2187
+ var shouldIgnoreRedirects = ({ state }) => {
2188
+ const isNotPublished = state !== CANVAS_PUBLISHED_STATE;
2189
+ return isNotPublished ? true : void 0;
2190
+ };
2009
2191
 
2010
2192
  // src/clients/cache.ts
2193
+ var isSpecificCacheMode = (options) => {
2194
+ return "cache" in options;
2195
+ };
2011
2196
  var isStateCacheMode = (options) => {
2012
2197
  return "state" in options;
2013
2198
  };
@@ -2034,7 +2219,9 @@ var resolveCache = ({
2034
2219
  }) => {
2035
2220
  let cache2 = void 0;
2036
2221
  if (options) {
2037
- if (isStateCacheMode(options)) {
2222
+ if (isSpecificCacheMode(options)) {
2223
+ cache2 = options.cache;
2224
+ } else if (isStateCacheMode(options)) {
2038
2225
  if (options.state === CANVAS_DRAFT_STATE || options.state === CANVAS_EDITOR_STATE) {
2039
2226
  cache2 = {
2040
2227
  type: "no-cache",
@@ -2153,7 +2340,7 @@ function createLimiter(concurrency) {
2153
2340
  });
2154
2341
  };
2155
2342
  }
2156
- async function retry(fn, options) {
2343
+ async function retry2(fn, options) {
2157
2344
  let lastError;
2158
2345
  let delay = 1e3;
2159
2346
  for (let attempt = 1; attempt <= options.retries + 1; attempt++) {
@@ -2193,7 +2380,7 @@ function createLimitPolicy2({
2193
2380
  }
2194
2381
  if (retryOptions) {
2195
2382
  const retryFunc = currentFunc;
2196
- currentFunc = () => retry(retryFunc, {
2383
+ currentFunc = () => retry2(retryFunc, {
2197
2384
  ...retryOptions,
2198
2385
  onFailedAttempt: async (error) => {
2199
2386
  if (retryOptions.onFailedAttempt) {
@@ -2327,14 +2514,14 @@ var getManifest = async (options) => {
2327
2514
  var import_server_only3 = require("server-only");
2328
2515
 
2329
2516
  // ../project-map/dist/index.mjs
2330
- var __typeError3 = (msg) => {
2517
+ var __typeError4 = (msg) => {
2331
2518
  throw TypeError(msg);
2332
2519
  };
2333
- var __accessCheck3 = (obj, member, msg) => member.has(obj) || __typeError3("Cannot " + msg);
2334
- var __privateGet3 = (obj, member, getter) => (__accessCheck3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
2335
- var __privateAdd3 = (obj, member, value) => member.has(obj) ? __typeError3("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2336
- var __privateSet = (obj, member, value, setter) => (__accessCheck3(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
2337
- var __privateMethod = (obj, member, method) => (__accessCheck3(obj, member, "access private method"), method);
2520
+ var __accessCheck4 = (obj, member, msg) => member.has(obj) || __typeError4("Cannot " + msg);
2521
+ var __privateGet4 = (obj, member, getter) => (__accessCheck4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
2522
+ var __privateAdd4 = (obj, member, value) => member.has(obj) ? __typeError4("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2523
+ var __privateSet2 = (obj, member, value, setter) => (__accessCheck4(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
2524
+ var __privateMethod = (obj, member, method) => (__accessCheck4(obj, member, "access private method"), method);
2338
2525
  var ProjectMapClient = class extends ApiClient {
2339
2526
  constructor(options) {
2340
2527
  super(options);
@@ -2481,12 +2668,12 @@ var isDynamicRouteSegment_fn;
2481
2668
  var _Route = class _Route2 {
2482
2669
  constructor(route) {
2483
2670
  this.route = route;
2484
- __privateAdd3(this, _routeInfo);
2671
+ __privateAdd4(this, _routeInfo);
2485
2672
  var _a;
2486
- __privateSet(this, _routeInfo, __privateMethod(_a = _Route2, _Route_static, parseRouteOrPath_fn).call(_a, this.route));
2673
+ __privateSet2(this, _routeInfo, __privateMethod(_a = _Route2, _Route_static, parseRouteOrPath_fn).call(_a, this.route));
2487
2674
  }
2488
2675
  get dynamicSegmentCount() {
2489
- return __privateGet3(this, _routeInfo).segments.reduce(
2676
+ return __privateGet4(this, _routeInfo).segments.reduce(
2490
2677
  (count, segment) => {
2491
2678
  var _a;
2492
2679
  return __privateMethod(_a = _Route2, _Route_static, isDynamicRouteSegment_fn).call(_a, segment) ? count + 1 : count;
@@ -2498,7 +2685,7 @@ var _Route = class _Route2 {
2498
2685
  matches(path) {
2499
2686
  var _a, _b;
2500
2687
  const { segments: pathSegments, queryParams: pathQuery } = __privateMethod(_a = _Route2, _Route_static, parseRouteOrPath_fn).call(_a, path);
2501
- const { segments: routeSegments } = __privateGet3(this, _routeInfo);
2688
+ const { segments: routeSegments } = __privateGet4(this, _routeInfo);
2502
2689
  if (pathSegments.length !== routeSegments.length) {
2503
2690
  return { match: false };
2504
2691
  }
@@ -2519,7 +2706,7 @@ var _Route = class _Route2 {
2519
2706
  return { match: false };
2520
2707
  }
2521
2708
  }
2522
- for (const [key, value] of __privateGet3(this, _routeInfo).queryParams) {
2709
+ for (const [key, value] of __privateGet4(this, _routeInfo).queryParams) {
2523
2710
  possibleMatch.queryParams[key] = pathQuery.has(key) ? pathQuery.get(key) : value;
2524
2711
  }
2525
2712
  return possibleMatch;
@@ -2529,7 +2716,7 @@ var _Route = class _Route2 {
2529
2716
  */
2530
2717
  expand(options) {
2531
2718
  const { dynamicInputValues = {}, allowedQueryParams = [], doNotEscapeVariables = false } = options != null ? options : {};
2532
- const path = __privateGet3(this, _routeInfo).segments.map((segment) => {
2719
+ const path = __privateGet4(this, _routeInfo).segments.map((segment) => {
2533
2720
  const dynamicSegmentName = _Route2.getDynamicRouteSegmentName(segment);
2534
2721
  if (!dynamicSegmentName) {
2535
2722
  return segment;
@@ -2559,6 +2746,35 @@ var _Route = class _Route2 {
2559
2746
  }
2560
2747
  return segment.slice(_Route2.dynamicSegmentPrefix.length);
2561
2748
  }
2749
+ /**
2750
+ * Splits a path into the path portion and an optional `#fragment`
2751
+ * (everything after the first `#`).
2752
+ *
2753
+ * Variable expressions (`${...}`) may legitimately contain `#` characters
2754
+ * (e.g. JSON-pointer tokens like `${#jptr:/foo/_slug}`), so the fragment
2755
+ * delimiter is the first `#` that falls outside of a variable expression.
2756
+ */
2757
+ static splitFragment(path) {
2758
+ let fragmentIndex = -1;
2759
+ parseVariableExpression(path, (token, type, offset) => {
2760
+ if (type === "variable") {
2761
+ return;
2762
+ }
2763
+ const hashOffset = token.indexOf("#");
2764
+ if (hashOffset === -1) {
2765
+ return;
2766
+ }
2767
+ fragmentIndex = offset + hashOffset;
2768
+ return false;
2769
+ });
2770
+ if (fragmentIndex === -1) {
2771
+ return { path, fragment: void 0 };
2772
+ }
2773
+ return {
2774
+ path: path.slice(0, fragmentIndex),
2775
+ fragment: path.slice(fragmentIndex + 1)
2776
+ };
2777
+ }
2562
2778
  };
2563
2779
  _routeInfo = /* @__PURE__ */ new WeakMap();
2564
2780
  _Route_static = /* @__PURE__ */ new WeakSet();
@@ -2580,7 +2796,7 @@ isDynamicRouteSegment_fn = function(segment) {
2580
2796
  }
2581
2797
  return segment.startsWith(_Route.dynamicSegmentPrefix);
2582
2798
  };
2583
- __privateAdd3(_Route, _Route_static);
2799
+ __privateAdd4(_Route, _Route_static);
2584
2800
  _Route.dynamicSegmentPrefix = ":";
2585
2801
  function encodeRouteComponent(value, doNotEscapeVariables) {
2586
2802
  if (!doNotEscapeVariables) {
@@ -2678,7 +2894,7 @@ var getRouteClient = (options) => {
2678
2894
 
2679
2895
  // src/components/UniformComposition.tsx
2680
2896
  var import_core = require("@uniformdev/canvas-react/core");
2681
- var import_next_app_router_client4 = require("@uniformdev/next-app-router-client");
2897
+ var import_next_app_router_client5 = require("@uniformdev/next-app-router-client");
2682
2898
  var import_next_app_router_shared4 = require("@uniformdev/next-app-router-shared");
2683
2899
  var import_navigation = require("next/navigation");
2684
2900
  var import_react6 = __toESM(require("react"));
@@ -2772,6 +2988,13 @@ var createTestComponentProps = ({
2772
2988
  test
2773
2989
  }) => {
2774
2990
  var _a;
2991
+ if (pageState.isPrefetch) {
2992
+ return {
2993
+ ...common,
2994
+ index: void 0,
2995
+ test
2996
+ };
2997
+ }
2775
2998
  const component = (0, import_next_app_router_shared2.resolveComponentFromPageState)({
2776
2999
  pageState,
2777
3000
  componentId
@@ -2779,7 +3002,7 @@ var createTestComponentProps = ({
2779
3002
  const [testIndex] = (_a = component == null ? void 0 : component.indexes) != null ? _a : [];
2780
3003
  return {
2781
3004
  ...common,
2782
- index: testIndex != null ? testIndex : 0,
3005
+ index: testIndex,
2783
3006
  test
2784
3007
  };
2785
3008
  };
@@ -2810,6 +3033,7 @@ var applyEditableParameters = ({
2810
3033
  };
2811
3034
 
2812
3035
  // src/components/Test.tsx
3036
+ var import_next_app_router_client2 = require("@uniformdev/next-app-router-client");
2813
3037
  var import_react2 = require("react");
2814
3038
 
2815
3039
  // src/components/ContextTestTransfer.tsx
@@ -2822,7 +3046,14 @@ var ContextTestTransfer = ({ event }) => {
2822
3046
  // src/components/Test.tsx
2823
3047
  var Test = ({ index, slots, test, component, context: compositionContext }) => {
2824
3048
  var _a, _b, _c, _d, _e, _f;
2825
- const indexToShow = typeof index === "number" ? (_b = (_a = slots == null ? void 0 : slots[CANVAS_TEST_SLOT]) == null ? void 0 : _a.items[index]) != null ? _b : null : null;
3049
+ if (typeof index !== "number") {
3050
+ return (0, import_react2.createElement)(import_next_app_router_client2.ClientTest, {
3051
+ slots,
3052
+ test,
3053
+ context: compositionContext
3054
+ });
3055
+ }
3056
+ const indexToShow = (_b = (_a = slots == null ? void 0 : slots[CANVAS_TEST_SLOT]) == null ? void 0 : _a.items[index]) != null ? _b : null;
2826
3057
  const event = {
2827
3058
  name: test.name,
2828
3059
  control: (_d = (_c = test.variations[index]) == null ? void 0 : _c.control) != null ? _d : false,
@@ -2854,7 +3085,7 @@ var UniformCompositionWrapper = ({
2854
3085
  };
2855
3086
 
2856
3087
  // src/components/UniformContext.tsx
2857
- var import_next_app_router_client2 = require("@uniformdev/next-app-router-client");
3088
+ var import_next_app_router_client3 = require("@uniformdev/next-app-router-client");
2858
3089
  var import_react4 = __toESM(require("react"));
2859
3090
 
2860
3091
  // src/config/helpers.ts
@@ -2879,6 +3110,9 @@ var getQuirkSerialization = () => {
2879
3110
  return true;
2880
3111
  };
2881
3112
  var getMiddlewareRuntimeCache = () => {
3113
+ if (process.env.NODE_ENV === "development" && !process.env.RUNTIME_CACHE_ENDPOINT) {
3114
+ return false;
3115
+ }
2882
3116
  if (typeof import_resolved.default.middlewareRuntimeCache === "boolean") {
2883
3117
  return import_resolved.default.middlewareRuntimeCache;
2884
3118
  }
@@ -2904,7 +3138,7 @@ var UniformContext = async ({ clientContextComponent, result }) => {
2904
3138
  dynamicInputs: route.dynamicInputs,
2905
3139
  matchedRoute: route.matchedRoute
2906
3140
  } : void 0;
2907
- const ContextComponent = clientContextComponent || import_next_app_router_client2.DefaultUniformClientContext;
3141
+ const ContextComponent = clientContextComponent || import_next_app_router_client3.DefaultUniformClientContext;
2908
3142
  const disableDevTools = getDisabledDevTools();
2909
3143
  const defaultConsent = (_a = result == null ? void 0 : result.pageState.defaultConsent) != null ? _a : getDefaultConsent();
2910
3144
  const experimentalQuirkSerialization = getQuirkSerialization();
@@ -2921,14 +3155,14 @@ var UniformContext = async ({ clientContextComponent, result }) => {
2921
3155
  };
2922
3156
 
2923
3157
  // src/components/VisibilityRulesWrapper.tsx
2924
- var import_next_app_router_client3 = require("@uniformdev/next-app-router-client");
3158
+ var import_next_app_router_client4 = require("@uniformdev/next-app-router-client");
2925
3159
  var import_react5 = __toESM(require("react"));
2926
3160
  var VisibilityRulesWrapper = ({
2927
3161
  parameter,
2928
3162
  initialIsVisible,
2929
3163
  children
2930
3164
  }) => {
2931
- return /* @__PURE__ */ import_react5.default.createElement(import_next_app_router_client3.VisibilityRulesWrapperClient, { parameter, initialIsVisible }, children);
3165
+ return /* @__PURE__ */ import_react5.default.createElement(import_next_app_router_client4.VisibilityRulesWrapperClient, { parameter, initialIsVisible }, children);
2932
3166
  };
2933
3167
 
2934
3168
  // src/components/UniformComposition.tsx
@@ -2991,7 +3225,7 @@ async function UniformCompositionInner({
2991
3225
  route
2992
3226
  }
2993
3227
  }
2994
- )), (pageState.compositionState === CANVAS_EDITOR_STATE || pageState.compositionState === CANVAS_DRAFT_STATE) && /* @__PURE__ */ import_react6.default.createElement(import_next_app_router_client4.UniformScript, null));
3228
+ )), (pageState.compositionState === CANVAS_EDITOR_STATE || pageState.compositionState === CANVAS_DRAFT_STATE) && /* @__PURE__ */ import_react6.default.createElement(import_next_app_router_client5.UniformScript, null));
2995
3229
  }
2996
3230
  var resolveComponents = ({
2997
3231
  target,
@@ -3087,7 +3321,7 @@ var resolveComponents = ({
3087
3321
  }
3088
3322
  let tagElement = null;
3089
3323
  if (enrichmentTags == null ? void 0 : enrichmentTags.length) {
3090
- tagElement = (0, import_react6.createElement)(import_next_app_router_client4.ContextUpdateTransfer, {
3324
+ tagElement = (0, import_react6.createElement)(import_next_app_router_client5.ContextUpdateTransfer, {
3091
3325
  key: `${slotName}-${componentIndex}-tags`,
3092
3326
  update: {
3093
3327
  enrichments: enrichmentTags
@@ -3162,7 +3396,7 @@ var createResolvedComponent = ({
3162
3396
  componentId: component._id,
3163
3397
  pageState
3164
3398
  });
3165
- return (0, import_react6.createElement)(import_next_app_router_client4.Personalize, { ...personalizeProps, key });
3399
+ return (0, import_react6.createElement)(import_next_app_router_client5.Personalize, { ...personalizeProps, key });
3166
3400
  }
3167
3401
  if (component.type === CANVAS_TEST_TYPE) {
3168
3402
  const extractedTest = extractTest({
@@ -3598,10 +3832,12 @@ var generatePossiblePageStates = ({
3598
3832
  defaultConsent: void 0,
3599
3833
  previewMode: void 0,
3600
3834
  rules: void 0,
3601
- locale
3835
+ locale,
3836
+ isPrefetch: void 0
3602
3837
  };
3838
+ const allComponentIds = runnables.filter((r) => r.type === "test" || r.type === "personalization").map((r) => r._id);
3603
3839
  const allStates = generateStatesRecursively(dependencyMap, void 0, initialState);
3604
- return allStates.map((payload) => (0, import_next_app_router_shared8.serializeEvaluationResult)({ payload }));
3840
+ return allStates.map((payload) => (0, import_next_app_router_shared8.serializeEvaluationResult)({ payload, allComponentIds }));
3605
3841
  };
3606
3842
  function permutationsWithoutRepetition(options, k) {
3607
3843
  if (k === 0) return [[]];
@@ -3650,7 +3886,10 @@ var DefaultDataClient = class {
3650
3886
  }
3651
3887
  }
3652
3888
  const manifest = await getManifest({
3653
- cache: {
3889
+ cache: isDevelopmentEnvironment() ? {
3890
+ type: "no-cache",
3891
+ bypassCache: true
3892
+ } : {
3654
3893
  type: "force-cache"
3655
3894
  }
3656
3895
  });
@@ -3753,20 +3992,23 @@ var DefaultDataClient = class {
3753
3992
  };
3754
3993
  }
3755
3994
  async getRoutePageState(options) {
3995
+ const shouldBypassCache = options.pageState.compositionState !== CANVAS_PUBLISHED_STATE || isDevelopmentEnvironment();
3756
3996
  const routeClient = getRouteClient({
3757
- cache: options.pageState.compositionState === CANVAS_PUBLISHED_STATE ? {
3758
- type: "force-cache"
3759
- } : {
3997
+ cache: shouldBypassCache ? {
3760
3998
  type: "no-cache",
3761
3999
  bypassCache: true
4000
+ } : {
4001
+ type: "force-cache"
3762
4002
  }
3763
4003
  });
3764
4004
  const originalRoute = {
3765
4005
  path: options.pageState.routePath,
3766
4006
  state: options.pageState.compositionState,
4007
+ dataSourceVariant: getDataSourceVariantFromRouteGetParams({}, options.pageState.compositionState),
3767
4008
  withComponentIDs: true,
3768
4009
  releaseId: options.pageState.releaseId,
3769
- locale: options.pageState.locale
4010
+ locale: options.pageState.locale,
4011
+ ignoreRedirects: shouldIgnoreRedirects({ state: options.pageState.compositionState })
3770
4012
  };
3771
4013
  const resolvedRoute = await this.getRouteFromApi({
3772
4014
  source: "pageState",