@uniformdev/next-app-router 20.49.2 → 20.49.3-alpha.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -4,6 +4,10 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __typeError = (msg) => {
8
+ throw TypeError(msg);
9
+ };
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
11
  var __commonJS = (cb, mod) => function __require() {
8
12
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
13
  };
@@ -23,12 +27,25 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
27
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
28
  mod
25
29
  ));
30
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
31
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
32
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
33
+ 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);
34
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
35
+ var __privateWrapper = (obj, member, setter, getter) => ({
36
+ set _(value) {
37
+ __privateSet(obj, member, value, setter);
38
+ },
39
+ get _() {
40
+ return __privateGet(obj, member, getter);
41
+ }
42
+ });
26
43
 
27
44
  // ../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js
28
45
  var require_yocto_queue = __commonJS({
29
46
  "../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports, module) {
30
47
  "use strict";
31
- var Node = class {
48
+ var Node2 = class {
32
49
  /// value;
33
50
  /// next;
34
51
  constructor(value) {
@@ -36,7 +53,7 @@ var require_yocto_queue = __commonJS({
36
53
  this.next = void 0;
37
54
  }
38
55
  };
39
- var Queue = class {
56
+ var Queue2 = class {
40
57
  // TODO: Use private class fields when targeting Node.js 12.
41
58
  // #_head;
42
59
  // #_tail;
@@ -45,7 +62,7 @@ var require_yocto_queue = __commonJS({
45
62
  this.clear();
46
63
  }
47
64
  enqueue(value) {
48
- const node = new Node(value);
65
+ const node = new Node2(value);
49
66
  if (this._head) {
50
67
  this._tail.next = node;
51
68
  this._tail = node;
@@ -80,7 +97,7 @@ var require_yocto_queue = __commonJS({
80
97
  }
81
98
  }
82
99
  };
83
- module.exports = Queue;
100
+ module.exports = Queue2;
84
101
  }
85
102
  });
86
103
 
@@ -88,12 +105,12 @@ var require_yocto_queue = __commonJS({
88
105
  var require_p_limit = __commonJS({
89
106
  "../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports, module) {
90
107
  "use strict";
91
- var Queue = require_yocto_queue();
92
- var pLimit2 = (concurrency) => {
108
+ var Queue2 = require_yocto_queue();
109
+ var pLimit3 = (concurrency) => {
93
110
  if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
94
111
  throw new TypeError("Expected `concurrency` to be a number from 1 and up");
95
112
  }
96
- const queue = new Queue();
113
+ const queue = new Queue2();
97
114
  let activeCount = 0;
98
115
  const next = () => {
99
116
  activeCount--;
@@ -138,7 +155,238 @@ var require_p_limit = __commonJS({
138
155
  });
139
156
  return generator;
140
157
  };
141
- module.exports = pLimit2;
158
+ module.exports = pLimit3;
159
+ }
160
+ });
161
+
162
+ // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js
163
+ var require_retry_operation = __commonJS({
164
+ "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports, module) {
165
+ "use strict";
166
+ function RetryOperation(timeouts, options) {
167
+ if (typeof options === "boolean") {
168
+ options = { forever: options };
169
+ }
170
+ this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
171
+ this._timeouts = timeouts;
172
+ this._options = options || {};
173
+ this._maxRetryTime = options && options.maxRetryTime || Infinity;
174
+ this._fn = null;
175
+ this._errors = [];
176
+ this._attempts = 1;
177
+ this._operationTimeout = null;
178
+ this._operationTimeoutCb = null;
179
+ this._timeout = null;
180
+ this._operationStart = null;
181
+ this._timer = null;
182
+ if (this._options.forever) {
183
+ this._cachedTimeouts = this._timeouts.slice(0);
184
+ }
185
+ }
186
+ module.exports = RetryOperation;
187
+ RetryOperation.prototype.reset = function() {
188
+ this._attempts = 1;
189
+ this._timeouts = this._originalTimeouts.slice(0);
190
+ };
191
+ RetryOperation.prototype.stop = function() {
192
+ if (this._timeout) {
193
+ clearTimeout(this._timeout);
194
+ }
195
+ if (this._timer) {
196
+ clearTimeout(this._timer);
197
+ }
198
+ this._timeouts = [];
199
+ this._cachedTimeouts = null;
200
+ };
201
+ RetryOperation.prototype.retry = function(err) {
202
+ if (this._timeout) {
203
+ clearTimeout(this._timeout);
204
+ }
205
+ if (!err) {
206
+ return false;
207
+ }
208
+ var currentTime = (/* @__PURE__ */ new Date()).getTime();
209
+ if (err && currentTime - this._operationStart >= this._maxRetryTime) {
210
+ this._errors.push(err);
211
+ this._errors.unshift(new Error("RetryOperation timeout occurred"));
212
+ return false;
213
+ }
214
+ this._errors.push(err);
215
+ var timeout = this._timeouts.shift();
216
+ if (timeout === void 0) {
217
+ if (this._cachedTimeouts) {
218
+ this._errors.splice(0, this._errors.length - 1);
219
+ timeout = this._cachedTimeouts.slice(-1);
220
+ } else {
221
+ return false;
222
+ }
223
+ }
224
+ var self = this;
225
+ this._timer = setTimeout(function() {
226
+ self._attempts++;
227
+ if (self._operationTimeoutCb) {
228
+ self._timeout = setTimeout(function() {
229
+ self._operationTimeoutCb(self._attempts);
230
+ }, self._operationTimeout);
231
+ if (self._options.unref) {
232
+ self._timeout.unref();
233
+ }
234
+ }
235
+ self._fn(self._attempts);
236
+ }, timeout);
237
+ if (this._options.unref) {
238
+ this._timer.unref();
239
+ }
240
+ return true;
241
+ };
242
+ RetryOperation.prototype.attempt = function(fn, timeoutOps) {
243
+ this._fn = fn;
244
+ if (timeoutOps) {
245
+ if (timeoutOps.timeout) {
246
+ this._operationTimeout = timeoutOps.timeout;
247
+ }
248
+ if (timeoutOps.cb) {
249
+ this._operationTimeoutCb = timeoutOps.cb;
250
+ }
251
+ }
252
+ var self = this;
253
+ if (this._operationTimeoutCb) {
254
+ this._timeout = setTimeout(function() {
255
+ self._operationTimeoutCb();
256
+ }, self._operationTimeout);
257
+ }
258
+ this._operationStart = (/* @__PURE__ */ new Date()).getTime();
259
+ this._fn(this._attempts);
260
+ };
261
+ RetryOperation.prototype.try = function(fn) {
262
+ console.log("Using RetryOperation.try() is deprecated");
263
+ this.attempt(fn);
264
+ };
265
+ RetryOperation.prototype.start = function(fn) {
266
+ console.log("Using RetryOperation.start() is deprecated");
267
+ this.attempt(fn);
268
+ };
269
+ RetryOperation.prototype.start = RetryOperation.prototype.try;
270
+ RetryOperation.prototype.errors = function() {
271
+ return this._errors;
272
+ };
273
+ RetryOperation.prototype.attempts = function() {
274
+ return this._attempts;
275
+ };
276
+ RetryOperation.prototype.mainError = function() {
277
+ if (this._errors.length === 0) {
278
+ return null;
279
+ }
280
+ var counts = {};
281
+ var mainError = null;
282
+ var mainErrorCount = 0;
283
+ for (var i = 0; i < this._errors.length; i++) {
284
+ var error = this._errors[i];
285
+ var message = error.message;
286
+ var count = (counts[message] || 0) + 1;
287
+ counts[message] = count;
288
+ if (count >= mainErrorCount) {
289
+ mainError = error;
290
+ mainErrorCount = count;
291
+ }
292
+ }
293
+ return mainError;
294
+ };
295
+ }
296
+ });
297
+
298
+ // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js
299
+ var require_retry = __commonJS({
300
+ "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports) {
301
+ "use strict";
302
+ var RetryOperation = require_retry_operation();
303
+ exports.operation = function(options) {
304
+ var timeouts = exports.timeouts(options);
305
+ return new RetryOperation(timeouts, {
306
+ forever: options && (options.forever || options.retries === Infinity),
307
+ unref: options && options.unref,
308
+ maxRetryTime: options && options.maxRetryTime
309
+ });
310
+ };
311
+ exports.timeouts = function(options) {
312
+ if (options instanceof Array) {
313
+ return [].concat(options);
314
+ }
315
+ var opts = {
316
+ retries: 10,
317
+ factor: 2,
318
+ minTimeout: 1 * 1e3,
319
+ maxTimeout: Infinity,
320
+ randomize: false
321
+ };
322
+ for (var key in options) {
323
+ opts[key] = options[key];
324
+ }
325
+ if (opts.minTimeout > opts.maxTimeout) {
326
+ throw new Error("minTimeout is greater than maxTimeout");
327
+ }
328
+ var timeouts = [];
329
+ for (var i = 0; i < opts.retries; i++) {
330
+ timeouts.push(this.createTimeout(i, opts));
331
+ }
332
+ if (options && options.forever && !timeouts.length) {
333
+ timeouts.push(this.createTimeout(i, opts));
334
+ }
335
+ timeouts.sort(function(a, b) {
336
+ return a - b;
337
+ });
338
+ return timeouts;
339
+ };
340
+ exports.createTimeout = function(attempt, opts) {
341
+ var random = opts.randomize ? Math.random() + 1 : 1;
342
+ var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
343
+ timeout = Math.min(timeout, opts.maxTimeout);
344
+ return timeout;
345
+ };
346
+ exports.wrap = function(obj, options, methods) {
347
+ if (options instanceof Array) {
348
+ methods = options;
349
+ options = null;
350
+ }
351
+ if (!methods) {
352
+ methods = [];
353
+ for (var key in obj) {
354
+ if (typeof obj[key] === "function") {
355
+ methods.push(key);
356
+ }
357
+ }
358
+ }
359
+ for (var i = 0; i < methods.length; i++) {
360
+ var method = methods[i];
361
+ var original = obj[method];
362
+ obj[method] = function retryWrapper(original2) {
363
+ var op = exports.operation(options);
364
+ var args = Array.prototype.slice.call(arguments, 1);
365
+ var callback = args.pop();
366
+ args.push(function(err) {
367
+ if (op.retry(err)) {
368
+ return;
369
+ }
370
+ if (err) {
371
+ arguments[0] = op.mainError();
372
+ }
373
+ callback.apply(this, arguments);
374
+ });
375
+ op.attempt(function() {
376
+ original2.apply(obj, args);
377
+ });
378
+ }.bind(obj, original);
379
+ obj[method].options = options;
380
+ }
381
+ };
382
+ }
383
+ });
384
+
385
+ // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js
386
+ var require_retry2 = __commonJS({
387
+ "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports, module) {
388
+ "use strict";
389
+ module.exports = require_retry();
142
390
  }
143
391
  });
144
392
 
@@ -151,33 +399,40 @@ import "server-only";
151
399
  // ../context/dist/api/api.mjs
152
400
  var import_p_limit = __toESM(require_p_limit(), 1);
153
401
  var __defProp2 = Object.defineProperty;
154
- var __typeError = (msg) => {
402
+ var __typeError2 = (msg) => {
155
403
  throw TypeError(msg);
156
404
  };
157
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
158
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
159
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
160
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
161
- 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);
405
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
406
+ var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
407
+ var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
408
+ var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
409
+ 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);
162
410
  var defaultLimitPolicy = (0, import_p_limit.default)(6);
411
+ var UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE = "Bearer token not valid or expired";
163
412
  var ApiClientError = class _ApiClientError extends Error {
164
413
  constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
165
414
  super(
166
415
  `${errorMessage}
167
416
  ${statusCode}${statusText ? " " + statusText : ""} (${fetchMethod} ${fetchUri}${requestId ? ` Request ID: ${requestId}` : ""})`
168
417
  );
169
- this.errorMessage = errorMessage;
170
- this.fetchMethod = fetchMethod;
171
- this.fetchUri = fetchUri;
172
- this.statusCode = statusCode;
173
- this.statusText = statusText;
174
- this.requestId = requestId;
418
+ __publicField2(this, "errorMessage", errorMessage);
419
+ __publicField2(this, "fetchMethod", fetchMethod);
420
+ __publicField2(this, "fetchUri", fetchUri);
421
+ __publicField2(this, "statusCode", statusCode);
422
+ __publicField2(this, "statusText", statusText);
423
+ __publicField2(this, "requestId", requestId);
175
424
  Object.setPrototypeOf(this, _ApiClientError.prototype);
176
425
  }
177
426
  };
427
+ var BearerTokenNotValidOrExpiredError = class _BearerTokenNotValidOrExpiredError extends ApiClientError {
428
+ constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
429
+ super(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId);
430
+ Object.setPrototypeOf(this, _BearerTokenNotValidOrExpiredError.prototype);
431
+ }
432
+ };
178
433
  var ApiClient = class _ApiClient {
179
434
  constructor(options) {
180
- __publicField(this, "options");
435
+ __publicField2(this, "options");
181
436
  var _a, _b, _c, _d, _e;
182
437
  if (!options.apiKey && !options.bearerToken) {
183
438
  throw new Error("You must provide an API key or a bearer token");
@@ -208,7 +463,7 @@ var ApiClient = class _ApiClient {
208
463
  }
209
464
  async apiClientWithResponse(fetchUri, options) {
210
465
  return this.options.limitPolicy(async () => {
211
- var _a;
466
+ var _a, _b;
212
467
  const coreHeaders = this.options.apiKey ? {
213
468
  "x-api-key": this.options.apiKey
214
469
  } : {
@@ -244,9 +499,19 @@ var ApiClient = class _ApiClient {
244
499
  } catch (e) {
245
500
  message = `General error`;
246
501
  }
502
+ if (apiResponse.status === 401 && message === UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE) {
503
+ throw new BearerTokenNotValidOrExpiredError(
504
+ message,
505
+ (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
506
+ fetchUri.toString(),
507
+ apiResponse.status,
508
+ apiResponse.statusText,
509
+ _ApiClient.getRequestId(apiResponse)
510
+ );
511
+ }
247
512
  throw new ApiClientError(
248
513
  message,
249
- (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
514
+ (_b = options == null ? void 0 : options.method) != null ? _b : "GET",
250
515
  fetchUri.toString(),
251
516
  apiResponse.status,
252
517
  apiResponse.statusText,
@@ -320,25 +585,39 @@ async function handleRateLimits(callApi) {
320
585
  }
321
586
  const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
322
587
  const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
323
- await new Promise((resolve) => setTimeout(resolve, resetWait + backoffWait));
588
+ await new Promise((resolve) => setTimeout(resolve, Math.max(0, resetWait + backoffWait)));
324
589
  backoffRetriesLeft -= 1;
325
590
  }
326
591
  return response;
327
592
  }
328
- var _url;
329
- var _AggregateClient = class _AggregateClient2 extends ApiClient {
330
- constructor(options) {
331
- super(options);
332
- }
593
+ var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
594
+ function rewriteFiltersForApi(filters) {
595
+ return Object.entries(filters != null ? filters : {}).reduce(
596
+ (acc, [key, value]) => {
597
+ const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
598
+ const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
599
+ return {
600
+ ...acc,
601
+ [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
602
+ };
603
+ },
604
+ {}
605
+ );
606
+ }
607
+ var _url;
608
+ var _AggregateClient = class _AggregateClient2 extends ApiClient {
609
+ constructor(options) {
610
+ super(options);
611
+ }
333
612
  /** Fetches all aggregates for a project */
334
613
  async get(options) {
335
614
  const { projectId } = this.options;
336
- const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url), { ...options, projectId });
615
+ const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url), { ...options, projectId });
337
616
  return await this.apiClient(fetchUri);
338
617
  }
339
618
  /** Updates or creates (based on id) an Aggregate */
340
619
  async upsert(body) {
341
- const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url));
620
+ const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url));
342
621
  await this.apiClient(fetchUri, {
343
622
  method: "PUT",
344
623
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -347,7 +626,7 @@ var _AggregateClient = class _AggregateClient2 extends ApiClient {
347
626
  }
348
627
  /** Deletes an Aggregate */
349
628
  async remove(body) {
350
- const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url));
629
+ const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url));
351
630
  await this.apiClient(fetchUri, {
352
631
  method: "DELETE",
353
632
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -356,7 +635,7 @@ var _AggregateClient = class _AggregateClient2 extends ApiClient {
356
635
  }
357
636
  };
358
637
  _url = /* @__PURE__ */ new WeakMap();
359
- __privateAdd(_AggregateClient, _url, "/api/v2/aggregate");
638
+ __privateAdd2(_AggregateClient, _url, "/api/v2/aggregate");
360
639
  var _url2;
361
640
  var _DimensionClient = class _DimensionClient2 extends ApiClient {
362
641
  constructor(options) {
@@ -365,12 +644,12 @@ var _DimensionClient = class _DimensionClient2 extends ApiClient {
365
644
  /** Fetches the known score dimensions for a project */
366
645
  async get(options) {
367
646
  const { projectId } = this.options;
368
- const fetchUri = this.createUrl(__privateGet(_DimensionClient2, _url2), { ...options, projectId });
647
+ const fetchUri = this.createUrl(__privateGet2(_DimensionClient2, _url2), { ...options, projectId });
369
648
  return await this.apiClient(fetchUri);
370
649
  }
371
650
  };
372
651
  _url2 = /* @__PURE__ */ new WeakMap();
373
- __privateAdd(_DimensionClient, _url2, "/api/v2/dimension");
652
+ __privateAdd2(_DimensionClient, _url2, "/api/v2/dimension");
374
653
  var _url3;
375
654
  var _valueUrl;
376
655
  var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
@@ -380,12 +659,12 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
380
659
  /** Fetches all enrichments and values for a project, grouped by category */
381
660
  async get(options) {
382
661
  const { projectId } = this.options;
383
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3), { ...options, projectId });
662
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3), { ...options, projectId });
384
663
  return await this.apiClient(fetchUri);
385
664
  }
386
665
  /** Updates or creates (based on id) an enrichment category */
387
666
  async upsertCategory(body) {
388
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3));
667
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3));
389
668
  await this.apiClient(fetchUri, {
390
669
  method: "PUT",
391
670
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -394,7 +673,7 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
394
673
  }
395
674
  /** Deletes an enrichment category */
396
675
  async removeCategory(body) {
397
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3));
676
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3));
398
677
  await this.apiClient(fetchUri, {
399
678
  method: "DELETE",
400
679
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -403,7 +682,7 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
403
682
  }
404
683
  /** Updates or creates (based on id) an enrichment value within an enrichment category */
405
684
  async upsertValue(body) {
406
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _valueUrl));
685
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _valueUrl));
407
686
  await this.apiClient(fetchUri, {
408
687
  method: "PUT",
409
688
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -412,7 +691,7 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
412
691
  }
413
692
  /** Deletes an enrichment value within an enrichment category. The category is left alone. */
414
693
  async removeValue(body) {
415
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _valueUrl));
694
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _valueUrl));
416
695
  await this.apiClient(fetchUri, {
417
696
  method: "DELETE",
418
697
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -422,8 +701,8 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
422
701
  };
423
702
  _url3 = /* @__PURE__ */ new WeakMap();
424
703
  _valueUrl = /* @__PURE__ */ new WeakMap();
425
- __privateAdd(_EnrichmentClient, _url3, "/api/v1/enrichments");
426
- __privateAdd(_EnrichmentClient, _valueUrl, "/api/v1/enrichment-values");
704
+ __privateAdd2(_EnrichmentClient, _url3, "/api/v1/enrichments");
705
+ __privateAdd2(_EnrichmentClient, _valueUrl, "/api/v1/enrichment-values");
427
706
  var _url4;
428
707
  var _ManifestClient = class _ManifestClient2 extends ApiClient {
429
708
  constructor(options) {
@@ -432,7 +711,7 @@ var _ManifestClient = class _ManifestClient2 extends ApiClient {
432
711
  /** Fetches the Context manifest for a project */
433
712
  async get(options) {
434
713
  const { projectId } = this.options;
435
- const fetchUri = this.createUrl(__privateGet(_ManifestClient2, _url4), { ...options, projectId });
714
+ const fetchUri = this.createUrl(__privateGet2(_ManifestClient2, _url4), { ...options, projectId });
436
715
  return await this.apiClient(fetchUri);
437
716
  }
438
717
  /** Publishes the Context manifest for a project */
@@ -446,7 +725,7 @@ var _ManifestClient = class _ManifestClient2 extends ApiClient {
446
725
  }
447
726
  };
448
727
  _url4 = /* @__PURE__ */ new WeakMap();
449
- __privateAdd(_ManifestClient, _url4, "/api/v2/manifest");
728
+ __privateAdd2(_ManifestClient, _url4, "/api/v2/manifest");
450
729
  var ManifestClient = _ManifestClient;
451
730
  var _url5;
452
731
  var _QuirkClient = class _QuirkClient2 extends ApiClient {
@@ -456,12 +735,12 @@ var _QuirkClient = class _QuirkClient2 extends ApiClient {
456
735
  /** Fetches all Quirks for a project */
457
736
  async get(options) {
458
737
  const { projectId } = this.options;
459
- const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5), { ...options, projectId });
738
+ const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5), { ...options, projectId });
460
739
  return await this.apiClient(fetchUri);
461
740
  }
462
741
  /** Updates or creates (based on id) a Quirk */
463
742
  async upsert(body) {
464
- const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5));
743
+ const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5));
465
744
  await this.apiClient(fetchUri, {
466
745
  method: "PUT",
467
746
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -470,7 +749,7 @@ var _QuirkClient = class _QuirkClient2 extends ApiClient {
470
749
  }
471
750
  /** Deletes a Quirk */
472
751
  async remove(body) {
473
- const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5));
752
+ const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5));
474
753
  await this.apiClient(fetchUri, {
475
754
  method: "DELETE",
476
755
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -479,7 +758,7 @@ var _QuirkClient = class _QuirkClient2 extends ApiClient {
479
758
  }
480
759
  };
481
760
  _url5 = /* @__PURE__ */ new WeakMap();
482
- __privateAdd(_QuirkClient, _url5, "/api/v2/quirk");
761
+ __privateAdd2(_QuirkClient, _url5, "/api/v2/quirk");
483
762
  var _url6;
484
763
  var _SignalClient = class _SignalClient2 extends ApiClient {
485
764
  constructor(options) {
@@ -488,12 +767,12 @@ var _SignalClient = class _SignalClient2 extends ApiClient {
488
767
  /** Fetches all Signals for a project */
489
768
  async get(options) {
490
769
  const { projectId } = this.options;
491
- const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6), { ...options, projectId });
770
+ const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6), { ...options, projectId });
492
771
  return await this.apiClient(fetchUri);
493
772
  }
494
773
  /** Updates or creates (based on id) a Signal */
495
774
  async upsert(body) {
496
- const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6));
775
+ const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6));
497
776
  await this.apiClient(fetchUri, {
498
777
  method: "PUT",
499
778
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -502,7 +781,7 @@ var _SignalClient = class _SignalClient2 extends ApiClient {
502
781
  }
503
782
  /** Deletes a Signal */
504
783
  async remove(body) {
505
- const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6));
784
+ const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6));
506
785
  await this.apiClient(fetchUri, {
507
786
  method: "DELETE",
508
787
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -511,7 +790,7 @@ var _SignalClient = class _SignalClient2 extends ApiClient {
511
790
  }
512
791
  };
513
792
  _url6 = /* @__PURE__ */ new WeakMap();
514
- __privateAdd(_SignalClient, _url6, "/api/v2/signal");
793
+ __privateAdd2(_SignalClient, _url6, "/api/v2/signal");
515
794
  var _url7;
516
795
  var _TestClient = class _TestClient2 extends ApiClient {
517
796
  constructor(options) {
@@ -520,12 +799,12 @@ var _TestClient = class _TestClient2 extends ApiClient {
520
799
  /** Fetches all Tests for a project */
521
800
  async get(options) {
522
801
  const { projectId } = this.options;
523
- const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7), { ...options, projectId });
802
+ const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7), { ...options, projectId });
524
803
  return await this.apiClient(fetchUri);
525
804
  }
526
805
  /** Updates or creates (based on id) a Test */
527
806
  async upsert(body) {
528
- const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7));
807
+ const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7));
529
808
  await this.apiClient(fetchUri, {
530
809
  method: "PUT",
531
810
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -534,7 +813,7 @@ var _TestClient = class _TestClient2 extends ApiClient {
534
813
  }
535
814
  /** Deletes a Test */
536
815
  async remove(body) {
537
- const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7));
816
+ const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7));
538
817
  await this.apiClient(fetchUri, {
539
818
  method: "DELETE",
540
819
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -542,394 +821,195 @@ var _TestClient = class _TestClient2 extends ApiClient {
542
821
  });
543
822
  }
544
823
  };
545
- _url7 = /* @__PURE__ */ new WeakMap();
546
- __privateAdd(_TestClient, _url7, "/api/v2/test");
547
-
548
- // ../canvas/dist/index.mjs
549
- var __create2 = Object.create;
550
- var __defProp3 = Object.defineProperty;
551
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
552
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
553
- var __getProtoOf2 = Object.getPrototypeOf;
554
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
555
- var __typeError2 = (msg) => {
556
- throw TypeError(msg);
557
- };
558
- var __commonJS2 = (cb, mod) => function __require() {
559
- return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
560
- };
561
- var __copyProps2 = (to, from, except, desc) => {
562
- if (from && typeof from === "object" || typeof from === "function") {
563
- for (let key of __getOwnPropNames2(from))
564
- if (!__hasOwnProp2.call(to, key) && key !== except)
565
- __defProp3(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
566
- }
567
- return to;
568
- };
569
- var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
570
- // If the importer is in node compatibility mode or this is not an ESM
571
- // file that has been converted to a CommonJS file using a Babel-
572
- // compatible transform (i.e. "__esModule" has not been set), then set
573
- // "default" to the CommonJS "module.exports" for node compatibility.
574
- isNodeMode || !mod || !mod.__esModule ? __defProp3(target, "default", { value: mod, enumerable: true }) : target,
575
- mod
576
- ));
577
- var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
578
- var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
579
- 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);
580
- var require_yocto_queue2 = __commonJS2({
581
- "../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports, module) {
582
- "use strict";
583
- var Node = class {
584
- /// value;
585
- /// next;
586
- constructor(value) {
587
- this.value = value;
588
- this.next = void 0;
589
- }
590
- };
591
- var Queue = class {
592
- // TODO: Use private class fields when targeting Node.js 12.
593
- // #_head;
594
- // #_tail;
595
- // #_size;
596
- constructor() {
597
- this.clear();
598
- }
599
- enqueue(value) {
600
- const node = new Node(value);
601
- if (this._head) {
602
- this._tail.next = node;
603
- this._tail = node;
604
- } else {
605
- this._head = node;
606
- this._tail = node;
607
- }
608
- this._size++;
609
- }
610
- dequeue() {
611
- const current = this._head;
612
- if (!current) {
613
- return;
614
- }
615
- this._head = this._head.next;
616
- this._size--;
617
- return current.value;
618
- }
619
- clear() {
620
- this._head = void 0;
621
- this._tail = void 0;
622
- this._size = 0;
623
- }
624
- get size() {
625
- return this._size;
626
- }
627
- *[Symbol.iterator]() {
628
- let current = this._head;
629
- while (current) {
630
- yield current.value;
631
- current = current.next;
632
- }
633
- }
634
- };
635
- module.exports = Queue;
636
- }
637
- });
638
- var require_p_limit2 = __commonJS2({
639
- "../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports, module) {
640
- "use strict";
641
- var Queue = require_yocto_queue2();
642
- var pLimit2 = (concurrency) => {
643
- if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
644
- throw new TypeError("Expected `concurrency` to be a number from 1 and up");
645
- }
646
- const queue = new Queue();
647
- let activeCount = 0;
648
- const next = () => {
649
- activeCount--;
650
- if (queue.size > 0) {
651
- queue.dequeue()();
652
- }
653
- };
654
- const run = async (fn, resolve, ...args) => {
655
- activeCount++;
656
- const result = (async () => fn(...args))();
657
- resolve(result);
658
- try {
659
- await result;
660
- } catch (e) {
661
- }
662
- next();
663
- };
664
- const enqueue = (fn, resolve, ...args) => {
665
- queue.enqueue(run.bind(null, fn, resolve, ...args));
666
- (async () => {
667
- await Promise.resolve();
668
- if (activeCount < concurrency && queue.size > 0) {
669
- queue.dequeue()();
670
- }
671
- })();
672
- };
673
- const generator = (fn, ...args) => new Promise((resolve) => {
674
- enqueue(fn, resolve, ...args);
675
- });
676
- Object.defineProperties(generator, {
677
- activeCount: {
678
- get: () => activeCount
679
- },
680
- pendingCount: {
681
- get: () => queue.size
682
- },
683
- clearQueue: {
684
- value: () => {
685
- queue.clear();
686
- }
687
- }
688
- });
689
- return generator;
690
- };
691
- module.exports = pLimit2;
692
- }
693
- });
694
- var require_retry_operation = __commonJS2({
695
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports, module) {
696
- "use strict";
697
- function RetryOperation(timeouts, options) {
698
- if (typeof options === "boolean") {
699
- options = { forever: options };
700
- }
701
- this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
702
- this._timeouts = timeouts;
703
- this._options = options || {};
704
- this._maxRetryTime = options && options.maxRetryTime || Infinity;
705
- this._fn = null;
706
- this._errors = [];
707
- this._attempts = 1;
708
- this._operationTimeout = null;
709
- this._operationTimeoutCb = null;
710
- this._timeout = null;
711
- this._operationStart = null;
712
- this._timer = null;
713
- if (this._options.forever) {
714
- this._cachedTimeouts = this._timeouts.slice(0);
715
- }
716
- }
717
- module.exports = RetryOperation;
718
- RetryOperation.prototype.reset = function() {
719
- this._attempts = 1;
720
- this._timeouts = this._originalTimeouts.slice(0);
721
- };
722
- RetryOperation.prototype.stop = function() {
723
- if (this._timeout) {
724
- clearTimeout(this._timeout);
725
- }
726
- if (this._timer) {
727
- clearTimeout(this._timer);
728
- }
729
- this._timeouts = [];
730
- this._cachedTimeouts = null;
731
- };
732
- RetryOperation.prototype.retry = function(err) {
733
- if (this._timeout) {
734
- clearTimeout(this._timeout);
735
- }
736
- if (!err) {
737
- return false;
738
- }
739
- var currentTime = (/* @__PURE__ */ new Date()).getTime();
740
- if (err && currentTime - this._operationStart >= this._maxRetryTime) {
741
- this._errors.push(err);
742
- this._errors.unshift(new Error("RetryOperation timeout occurred"));
743
- return false;
744
- }
745
- this._errors.push(err);
746
- var timeout = this._timeouts.shift();
747
- if (timeout === void 0) {
748
- if (this._cachedTimeouts) {
749
- this._errors.splice(0, this._errors.length - 1);
750
- timeout = this._cachedTimeouts.slice(-1);
751
- } else {
752
- return false;
753
- }
754
- }
755
- var self = this;
756
- this._timer = setTimeout(function() {
757
- self._attempts++;
758
- if (self._operationTimeoutCb) {
759
- self._timeout = setTimeout(function() {
760
- self._operationTimeoutCb(self._attempts);
761
- }, self._operationTimeout);
762
- if (self._options.unref) {
763
- self._timeout.unref();
764
- }
765
- }
766
- self._fn(self._attempts);
767
- }, timeout);
768
- if (this._options.unref) {
769
- this._timer.unref();
770
- }
771
- return true;
772
- };
773
- RetryOperation.prototype.attempt = function(fn, timeoutOps) {
774
- this._fn = fn;
775
- if (timeoutOps) {
776
- if (timeoutOps.timeout) {
777
- this._operationTimeout = timeoutOps.timeout;
778
- }
779
- if (timeoutOps.cb) {
780
- this._operationTimeoutCb = timeoutOps.cb;
781
- }
782
- }
783
- var self = this;
784
- if (this._operationTimeoutCb) {
785
- this._timeout = setTimeout(function() {
786
- self._operationTimeoutCb();
787
- }, self._operationTimeout);
788
- }
789
- this._operationStart = (/* @__PURE__ */ new Date()).getTime();
790
- this._fn(this._attempts);
791
- };
792
- RetryOperation.prototype.try = function(fn) {
793
- console.log("Using RetryOperation.try() is deprecated");
794
- this.attempt(fn);
795
- };
796
- RetryOperation.prototype.start = function(fn) {
797
- console.log("Using RetryOperation.start() is deprecated");
798
- this.attempt(fn);
799
- };
800
- RetryOperation.prototype.start = RetryOperation.prototype.try;
801
- RetryOperation.prototype.errors = function() {
802
- return this._errors;
803
- };
804
- RetryOperation.prototype.attempts = function() {
805
- return this._attempts;
806
- };
807
- RetryOperation.prototype.mainError = function() {
808
- if (this._errors.length === 0) {
809
- return null;
810
- }
811
- var counts = {};
812
- var mainError = null;
813
- var mainErrorCount = 0;
814
- for (var i = 0; i < this._errors.length; i++) {
815
- var error = this._errors[i];
816
- var message = error.message;
817
- var count = (counts[message] || 0) + 1;
818
- counts[message] = count;
819
- if (count >= mainErrorCount) {
820
- mainError = error;
821
- mainErrorCount = count;
822
- }
823
- }
824
- return mainError;
825
- };
826
- }
827
- });
828
- var require_retry = __commonJS2({
829
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports) {
830
- "use strict";
831
- var RetryOperation = require_retry_operation();
832
- exports.operation = function(options) {
833
- var timeouts = exports.timeouts(options);
834
- return new RetryOperation(timeouts, {
835
- forever: options && (options.forever || options.retries === Infinity),
836
- unref: options && options.unref,
837
- maxRetryTime: options && options.maxRetryTime
838
- });
839
- };
840
- exports.timeouts = function(options) {
841
- if (options instanceof Array) {
842
- return [].concat(options);
843
- }
844
- var opts = {
845
- retries: 10,
846
- factor: 2,
847
- minTimeout: 1 * 1e3,
848
- maxTimeout: Infinity,
849
- randomize: false
850
- };
851
- for (var key in options) {
852
- opts[key] = options[key];
853
- }
854
- if (opts.minTimeout > opts.maxTimeout) {
855
- throw new Error("minTimeout is greater than maxTimeout");
856
- }
857
- var timeouts = [];
858
- for (var i = 0; i < opts.retries; i++) {
859
- timeouts.push(this.createTimeout(i, opts));
860
- }
861
- if (options && options.forever && !timeouts.length) {
862
- timeouts.push(this.createTimeout(i, opts));
824
+ _url7 = /* @__PURE__ */ new WeakMap();
825
+ __privateAdd2(_TestClient, _url7, "/api/v2/test");
826
+
827
+ // ../../node_modules/.pnpm/yocto-queue@1.2.2/node_modules/yocto-queue/index.js
828
+ var Node = class {
829
+ constructor(value) {
830
+ __publicField(this, "value");
831
+ __publicField(this, "next");
832
+ this.value = value;
833
+ }
834
+ };
835
+ var _head, _tail, _size;
836
+ var Queue = class {
837
+ constructor() {
838
+ __privateAdd(this, _head);
839
+ __privateAdd(this, _tail);
840
+ __privateAdd(this, _size);
841
+ this.clear();
842
+ }
843
+ enqueue(value) {
844
+ const node = new Node(value);
845
+ if (__privateGet(this, _head)) {
846
+ __privateGet(this, _tail).next = node;
847
+ __privateSet(this, _tail, node);
848
+ } else {
849
+ __privateSet(this, _head, node);
850
+ __privateSet(this, _tail, node);
851
+ }
852
+ __privateWrapper(this, _size)._++;
853
+ }
854
+ dequeue() {
855
+ const current = __privateGet(this, _head);
856
+ if (!current) {
857
+ return;
858
+ }
859
+ __privateSet(this, _head, __privateGet(this, _head).next);
860
+ __privateWrapper(this, _size)._--;
861
+ if (!__privateGet(this, _head)) {
862
+ __privateSet(this, _tail, void 0);
863
+ }
864
+ return current.value;
865
+ }
866
+ peek() {
867
+ if (!__privateGet(this, _head)) {
868
+ return;
869
+ }
870
+ return __privateGet(this, _head).value;
871
+ }
872
+ clear() {
873
+ __privateSet(this, _head, void 0);
874
+ __privateSet(this, _tail, void 0);
875
+ __privateSet(this, _size, 0);
876
+ }
877
+ get size() {
878
+ return __privateGet(this, _size);
879
+ }
880
+ *[Symbol.iterator]() {
881
+ let current = __privateGet(this, _head);
882
+ while (current) {
883
+ yield current.value;
884
+ current = current.next;
885
+ }
886
+ }
887
+ *drain() {
888
+ while (__privateGet(this, _head)) {
889
+ yield this.dequeue();
890
+ }
891
+ }
892
+ };
893
+ _head = new WeakMap();
894
+ _tail = new WeakMap();
895
+ _size = new WeakMap();
896
+
897
+ // ../../node_modules/.pnpm/p-limit@6.2.0/node_modules/p-limit/index.js
898
+ function pLimit2(concurrency) {
899
+ validateConcurrency(concurrency);
900
+ const queue = new Queue();
901
+ let activeCount = 0;
902
+ const resumeNext = () => {
903
+ if (activeCount < concurrency && queue.size > 0) {
904
+ queue.dequeue()();
905
+ activeCount++;
906
+ }
907
+ };
908
+ const next = () => {
909
+ activeCount--;
910
+ resumeNext();
911
+ };
912
+ const run = async (function_, resolve, arguments_) => {
913
+ const result = (async () => function_(...arguments_))();
914
+ resolve(result);
915
+ try {
916
+ await result;
917
+ } catch (e) {
918
+ }
919
+ next();
920
+ };
921
+ const enqueue = (function_, resolve, arguments_) => {
922
+ new Promise((internalResolve) => {
923
+ queue.enqueue(internalResolve);
924
+ }).then(
925
+ run.bind(void 0, function_, resolve, arguments_)
926
+ );
927
+ (async () => {
928
+ await Promise.resolve();
929
+ if (activeCount < concurrency) {
930
+ resumeNext();
863
931
  }
864
- timeouts.sort(function(a, b) {
865
- return a - b;
866
- });
867
- return timeouts;
868
- };
869
- exports.createTimeout = function(attempt, opts) {
870
- var random = opts.randomize ? Math.random() + 1 : 1;
871
- var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
872
- timeout = Math.min(timeout, opts.maxTimeout);
873
- return timeout;
874
- };
875
- exports.wrap = function(obj, options, methods) {
876
- if (options instanceof Array) {
877
- methods = options;
878
- options = null;
932
+ })();
933
+ };
934
+ const generator = (function_, ...arguments_) => new Promise((resolve) => {
935
+ enqueue(function_, resolve, arguments_);
936
+ });
937
+ Object.defineProperties(generator, {
938
+ activeCount: {
939
+ get: () => activeCount
940
+ },
941
+ pendingCount: {
942
+ get: () => queue.size
943
+ },
944
+ clearQueue: {
945
+ value() {
946
+ queue.clear();
879
947
  }
880
- if (!methods) {
881
- methods = [];
882
- for (var key in obj) {
883
- if (typeof obj[key] === "function") {
884
- methods.push(key);
948
+ },
949
+ concurrency: {
950
+ get: () => concurrency,
951
+ set(newConcurrency) {
952
+ validateConcurrency(newConcurrency);
953
+ concurrency = newConcurrency;
954
+ queueMicrotask(() => {
955
+ while (activeCount < concurrency && queue.size > 0) {
956
+ resumeNext();
885
957
  }
886
- }
887
- }
888
- for (var i = 0; i < methods.length; i++) {
889
- var method = methods[i];
890
- var original = obj[method];
891
- obj[method] = function retryWrapper(original2) {
892
- var op = exports.operation(options);
893
- var args = Array.prototype.slice.call(arguments, 1);
894
- var callback = args.pop();
895
- args.push(function(err) {
896
- if (op.retry(err)) {
897
- return;
898
- }
899
- if (err) {
900
- arguments[0] = op.mainError();
901
- }
902
- callback.apply(this, arguments);
903
- });
904
- op.attempt(function() {
905
- original2.apply(obj, args);
906
- });
907
- }.bind(obj, original);
908
- obj[method].options = options;
958
+ });
909
959
  }
910
- };
911
- }
912
- });
913
- var require_retry2 = __commonJS2({
914
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports, module) {
915
- "use strict";
916
- module.exports = require_retry();
960
+ }
961
+ });
962
+ return generator;
963
+ }
964
+ function validateConcurrency(concurrency) {
965
+ if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
966
+ throw new TypeError("Expected `concurrency` to be a number from 1 and up");
917
967
  }
918
- });
919
- var import_p_limit2 = __toESM2(require_p_limit2());
920
- var import_retry = __toESM2(require_retry2(), 1);
921
- var networkErrorMsgs = /* @__PURE__ */ new Set([
922
- "Failed to fetch",
968
+ }
969
+
970
+ // ../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
971
+ var import_retry = __toESM(require_retry2(), 1);
972
+
973
+ // ../../node_modules/.pnpm/is-network-error@1.3.2/node_modules/is-network-error/index.js
974
+ var objectToString = Object.prototype.toString;
975
+ var isError = (value) => objectToString.call(value) === "[object Error]";
976
+ var errorMessages = /* @__PURE__ */ new Set([
977
+ "network error",
923
978
  // Chrome
924
979
  "NetworkError when attempting to fetch resource.",
925
980
  // Firefox
926
981
  "The Internet connection appears to be offline.",
927
- // Safari
982
+ // Safari 16
928
983
  "Network request failed",
929
984
  // `cross-fetch`
930
- "fetch failed"
985
+ "fetch failed",
986
+ // Undici (Node.js)
987
+ "terminated",
931
988
  // Undici (Node.js)
989
+ " A network error occurred.",
990
+ // Bun (WebKit)
991
+ "Network connection lost"
992
+ // Cloudflare Workers (fetch)
932
993
  ]);
994
+ function isNetworkError(error) {
995
+ const isValid = error && isError(error) && error.name === "TypeError" && typeof error.message === "string";
996
+ if (!isValid) {
997
+ return false;
998
+ }
999
+ const { message, stack } = error;
1000
+ if (message === "Load failed" || message.startsWith("Load failed (") && message.endsWith(")")) {
1001
+ return stack === void 0 || "__sentry_captured__" in error;
1002
+ }
1003
+ if (message.startsWith("error sending request for url")) {
1004
+ return true;
1005
+ }
1006
+ if (message === "Failed to fetch" || message.startsWith("Failed to fetch (") && message.endsWith(")")) {
1007
+ return true;
1008
+ }
1009
+ return errorMessages.has(message);
1010
+ }
1011
+
1012
+ // ../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
933
1013
  var AbortError = class extends Error {
934
1014
  constructor(message) {
935
1015
  super();
@@ -950,63 +1030,71 @@ var decorateErrorWithCounts = (error, attemptNumber, options) => {
950
1030
  error.retriesLeft = retriesLeft;
951
1031
  return error;
952
1032
  };
953
- var isNetworkError = (errorMessage) => networkErrorMsgs.has(errorMessage);
954
- var getDOMException = (errorMessage) => globalThis.DOMException === void 0 ? new Error(errorMessage) : new DOMException(errorMessage);
955
1033
  async function pRetry(input, options) {
956
1034
  return new Promise((resolve, reject) => {
957
- options = {
958
- onFailedAttempt() {
959
- },
960
- retries: 10,
961
- ...options
1035
+ var _a, _b, _c;
1036
+ options = { ...options };
1037
+ (_a = options.onFailedAttempt) != null ? _a : options.onFailedAttempt = () => {
962
1038
  };
1039
+ (_b = options.shouldRetry) != null ? _b : options.shouldRetry = () => true;
1040
+ (_c = options.retries) != null ? _c : options.retries = 10;
963
1041
  const operation = import_retry.default.operation(options);
1042
+ const abortHandler = () => {
1043
+ var _a2;
1044
+ operation.stop();
1045
+ reject((_a2 = options.signal) == null ? void 0 : _a2.reason);
1046
+ };
1047
+ if (options.signal && !options.signal.aborted) {
1048
+ options.signal.addEventListener("abort", abortHandler, { once: true });
1049
+ }
1050
+ const cleanUp = () => {
1051
+ var _a2;
1052
+ (_a2 = options.signal) == null ? void 0 : _a2.removeEventListener("abort", abortHandler);
1053
+ operation.stop();
1054
+ };
964
1055
  operation.attempt(async (attemptNumber) => {
965
1056
  try {
966
- resolve(await input(attemptNumber));
1057
+ const result = await input(attemptNumber);
1058
+ cleanUp();
1059
+ resolve(result);
967
1060
  } catch (error) {
968
- if (!(error instanceof Error)) {
969
- reject(new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`));
970
- return;
971
- }
972
- if (error instanceof AbortError) {
973
- operation.stop();
974
- reject(error.originalError);
975
- } else if (error instanceof TypeError && !isNetworkError(error.message)) {
976
- operation.stop();
977
- reject(error);
978
- } else {
1061
+ try {
1062
+ if (!(error instanceof Error)) {
1063
+ throw new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
1064
+ }
1065
+ if (error instanceof AbortError) {
1066
+ throw error.originalError;
1067
+ }
1068
+ if (error instanceof TypeError && !isNetworkError(error)) {
1069
+ throw error;
1070
+ }
979
1071
  decorateErrorWithCounts(error, attemptNumber, options);
980
- try {
981
- await options.onFailedAttempt(error);
982
- } catch (error2) {
983
- reject(error2);
984
- return;
1072
+ if (!await options.shouldRetry(error)) {
1073
+ operation.stop();
1074
+ reject(error);
985
1075
  }
1076
+ await options.onFailedAttempt(error);
986
1077
  if (!operation.retry(error)) {
987
- reject(operation.mainError());
1078
+ throw operation.mainError();
988
1079
  }
1080
+ } catch (finalError) {
1081
+ decorateErrorWithCounts(finalError, attemptNumber, options);
1082
+ cleanUp();
1083
+ reject(finalError);
989
1084
  }
990
1085
  }
991
1086
  });
992
- if (options.signal && !options.signal.aborted) {
993
- options.signal.addEventListener("abort", () => {
994
- operation.stop();
995
- const reason = options.signal.reason === void 0 ? getDOMException("The operation was aborted.") : options.signal.reason;
996
- reject(reason instanceof Error ? reason : getDOMException(reason));
997
- }, {
998
- once: true
999
- });
1000
- }
1001
1087
  });
1002
1088
  }
1089
+
1090
+ // ../../node_modules/.pnpm/p-throttle@6.2.0/node_modules/p-throttle/index.js
1003
1091
  var AbortError2 = class extends Error {
1004
1092
  constructor() {
1005
1093
  super("Throttled function aborted");
1006
1094
  this.name = "AbortError";
1007
1095
  }
1008
1096
  };
1009
- function pThrottle({ limit, interval, strict }) {
1097
+ function pThrottle({ limit, interval, strict, onDelay }) {
1010
1098
  if (!Number.isFinite(limit)) {
1011
1099
  throw new TypeError("Expected `limit` to be a finite number");
1012
1100
  }
@@ -1034,32 +1122,38 @@ function pThrottle({ limit, interval, strict }) {
1034
1122
  const strictTicks = [];
1035
1123
  function strictDelay() {
1036
1124
  const now = Date.now();
1037
- if (strictTicks.length < limit) {
1038
- strictTicks.push(now);
1039
- return 0;
1125
+ if (strictTicks.length > 0 && now - strictTicks.at(-1) > interval) {
1126
+ strictTicks.length = 0;
1040
1127
  }
1041
- const earliestTime = strictTicks.shift() + interval;
1042
- if (now >= earliestTime) {
1128
+ if (strictTicks.length < limit) {
1043
1129
  strictTicks.push(now);
1044
1130
  return 0;
1045
1131
  }
1046
- strictTicks.push(earliestTime);
1047
- return earliestTime - now;
1132
+ const nextExecutionTime = strictTicks[0] + interval;
1133
+ strictTicks.shift();
1134
+ strictTicks.push(nextExecutionTime);
1135
+ return Math.max(0, nextExecutionTime - now);
1048
1136
  }
1049
1137
  const getDelay = strict ? strictDelay : windowedDelay;
1050
1138
  return (function_) => {
1051
- const throttled = function(...args) {
1139
+ const throttled = function(...arguments_) {
1052
1140
  if (!throttled.isEnabled) {
1053
- return (async () => function_.apply(this, args))();
1141
+ return (async () => function_.apply(this, arguments_))();
1054
1142
  }
1055
- let timeout;
1143
+ let timeoutId;
1056
1144
  return new Promise((resolve, reject) => {
1057
1145
  const execute = () => {
1058
- resolve(function_.apply(this, args));
1059
- queue.delete(timeout);
1146
+ resolve(function_.apply(this, arguments_));
1147
+ queue.delete(timeoutId);
1060
1148
  };
1061
- timeout = setTimeout(execute, getDelay());
1062
- queue.set(timeout, reject);
1149
+ const delay = getDelay();
1150
+ if (delay > 0) {
1151
+ timeoutId = setTimeout(execute, delay);
1152
+ queue.set(timeoutId, reject);
1153
+ onDelay == null ? void 0 : onDelay(...arguments_);
1154
+ } else {
1155
+ execute();
1156
+ }
1063
1157
  });
1064
1158
  };
1065
1159
  throttled.abort = () => {
@@ -1071,16 +1165,29 @@ function pThrottle({ limit, interval, strict }) {
1071
1165
  strictTicks.splice(0, strictTicks.length);
1072
1166
  };
1073
1167
  throttled.isEnabled = true;
1168
+ Object.defineProperty(throttled, "queueSize", {
1169
+ get() {
1170
+ return queue.size;
1171
+ }
1172
+ });
1074
1173
  return throttled;
1075
1174
  };
1076
1175
  }
1176
+
1177
+ // ../canvas/dist/index.mjs
1178
+ var __typeError3 = (msg) => {
1179
+ throw TypeError(msg);
1180
+ };
1181
+ var __accessCheck3 = (obj, member, msg) => member.has(obj) || __typeError3("Cannot " + msg);
1182
+ var __privateGet3 = (obj, member, getter) => (__accessCheck3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1183
+ 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);
1077
1184
  function createLimitPolicy({
1078
1185
  throttle = { interval: 1e3, limit: 10 },
1079
- retry: retry2 = { retries: 1, factor: 1.66 },
1186
+ retry: retry3 = { retries: 1, factor: 1.66 },
1080
1187
  limit = 10
1081
1188
  }) {
1082
1189
  const throttler = throttle ? pThrottle(throttle) : null;
1083
- const limiter = limit ? (0, import_p_limit2.default)(limit) : null;
1190
+ const limiter = limit ? pLimit2(limit) : null;
1084
1191
  return function limitPolicy(func) {
1085
1192
  let currentFunc = async () => await func();
1086
1193
  if (throttler) {
@@ -1091,13 +1198,13 @@ function createLimitPolicy({
1091
1198
  const limitFunc = currentFunc;
1092
1199
  currentFunc = () => limiter(limitFunc);
1093
1200
  }
1094
- if (retry2) {
1201
+ if (retry3) {
1095
1202
  const retryFunc = currentFunc;
1096
1203
  currentFunc = () => pRetry(retryFunc, {
1097
- ...retry2,
1204
+ ...retry3,
1098
1205
  onFailedAttempt: async (error) => {
1099
- if (retry2.onFailedAttempt) {
1100
- await retry2.onFailedAttempt(error);
1206
+ if (retry3.onFailedAttempt) {
1207
+ await retry3.onFailedAttempt(error);
1101
1208
  }
1102
1209
  if (error instanceof ApiClientError && typeof error.statusCode === "number" && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429 && error.statusCode !== 408) {
1103
1210
  throw error;
@@ -1108,19 +1215,49 @@ function createLimitPolicy({
1108
1215
  return currentFunc();
1109
1216
  };
1110
1217
  }
1111
- var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
1112
- function rewriteFilters(filters) {
1113
- return Object.entries(filters != null ? filters : {}).reduce(
1114
- (acc, [key, value]) => {
1115
- const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
1116
- const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
1117
- return {
1118
- ...acc,
1119
- [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
1120
- };
1121
- },
1122
- {}
1123
- );
1218
+ var SELECT_QUERY_PREFIX = "select.";
1219
+ function appendCsv(out, key, values) {
1220
+ if (values === void 0) {
1221
+ return;
1222
+ }
1223
+ out[key] = values.join(",");
1224
+ }
1225
+ function projectionToQuery(spec) {
1226
+ const out = {};
1227
+ if (!spec) {
1228
+ return out;
1229
+ }
1230
+ const { fields, fieldTypes, slots } = spec;
1231
+ const p = SELECT_QUERY_PREFIX;
1232
+ if (fields) {
1233
+ appendCsv(out, `${p}fields[only]`, fields.only);
1234
+ appendCsv(out, `${p}fields[except]`, fields.except);
1235
+ appendCsv(out, `${p}fields[locales]`, fields.locales);
1236
+ if (fields.blockDepth === "preserveAll" || typeof fields.blockDepth === "number") {
1237
+ out[`${p}fields[blockDepth]`] = String(fields.blockDepth);
1238
+ }
1239
+ }
1240
+ if (fieldTypes) {
1241
+ appendCsv(out, `${p}fieldTypes[only]`, fieldTypes.only);
1242
+ appendCsv(out, `${p}fieldTypes[except]`, fieldTypes.except);
1243
+ }
1244
+ if (slots) {
1245
+ appendCsv(out, `${p}slots[only]`, slots.only);
1246
+ appendCsv(out, `${p}slots[except]`, slots.except);
1247
+ if (typeof slots.depth === "number") {
1248
+ out[`${p}slots[depth]`] = String(slots.depth);
1249
+ }
1250
+ if (slots.named) {
1251
+ const slotNames = Object.keys(slots.named).sort();
1252
+ for (const slotName of slotNames) {
1253
+ const named = slots.named[slotName];
1254
+ if (named && typeof named.depth === "number") {
1255
+ out[`${p}slots.${slotName}[depth]`] = String(named.depth);
1256
+ }
1257
+ }
1258
+ }
1259
+ }
1260
+ return out;
1124
1261
  }
1125
1262
  var CANVAS_URL = "/api/v1/canvas";
1126
1263
  var CanvasClient = class extends ApiClient {
@@ -1136,17 +1273,24 @@ var CanvasClient = class extends ApiClient {
1136
1273
  /** Fetches lists of Canvas compositions, optionally by type */
1137
1274
  async getCompositionList(params = {}) {
1138
1275
  const { projectId } = this.options;
1139
- const { resolveData, filters, ...originParams } = params;
1140
- const rewrittenFilters = rewriteFilters(filters);
1276
+ const { resolveData, filters, select, ...originParams } = params;
1277
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1278
+ const rewrittenSelect = projectionToQuery(select);
1141
1279
  if (!resolveData) {
1142
- const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
1280
+ const fetchUri = this.createUrl(CANVAS_URL, {
1281
+ ...originParams,
1282
+ projectId,
1283
+ ...rewrittenFilters,
1284
+ ...rewrittenSelect
1285
+ });
1143
1286
  return this.apiClient(fetchUri);
1144
1287
  }
1145
1288
  const edgeParams = {
1146
1289
  ...originParams,
1147
1290
  projectId,
1148
1291
  diagnostics: typeof params.diagnostics === "boolean" ? params.diagnostics : params.diagnostics === "no-data" ? "no-data" : void 0,
1149
- ...rewrittenFilters
1292
+ ...rewrittenFilters,
1293
+ ...rewrittenSelect
1150
1294
  };
1151
1295
  const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
1152
1296
  return this.apiClient(edgeUrl, this.edgeApiRequestInit);
@@ -1251,20 +1395,26 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1251
1395
  }
1252
1396
  getContentTypes(options) {
1253
1397
  const { projectId } = this.options;
1254
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl), { ...options, projectId });
1398
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _contentTypesUrl), { ...options, projectId });
1255
1399
  return this.apiClient(fetchUri);
1256
1400
  }
1257
1401
  getEntries(options) {
1258
1402
  const { projectId } = this.options;
1259
- const { skipDataResolution, filters, ...params } = options;
1260
- const rewrittenFilters = rewriteFilters(filters);
1403
+ const { skipDataResolution, filters, select, ...params } = options;
1404
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1405
+ const rewrittenSelect = projectionToQuery(select);
1261
1406
  if (skipDataResolution) {
1262
- const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
1407
+ const url = this.createUrl(__privateGet3(_ContentClient2, _entriesUrl), {
1408
+ ...params,
1409
+ ...rewrittenFilters,
1410
+ ...rewrittenSelect,
1411
+ projectId
1412
+ });
1263
1413
  return this.apiClient(url);
1264
1414
  }
1265
1415
  const edgeUrl = this.createUrl(
1266
- __privateGet2(_ContentClient2, _entriesUrl),
1267
- { ...this.getEdgeOptions(params), ...rewrittenFilters },
1416
+ __privateGet3(_ContentClient2, _entriesUrl),
1417
+ { ...this.getEdgeOptions(params), ...rewrittenFilters, ...rewrittenSelect },
1268
1418
  this.edgeApiHost
1269
1419
  );
1270
1420
  return this.apiClient(
@@ -1281,7 +1431,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1281
1431
  return this.apiClient(historyUrl);
1282
1432
  }
1283
1433
  async upsertContentType(body, opts = {}) {
1284
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl));
1434
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _contentTypesUrl));
1285
1435
  if (typeof body.contentType.slugSettings === "object" && body.contentType.slugSettings !== null && Object.keys(body.contentType.slugSettings).length === 0) {
1286
1436
  delete body.contentType.slugSettings;
1287
1437
  }
@@ -1293,7 +1443,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1293
1443
  });
1294
1444
  }
1295
1445
  async upsertEntry(body, options) {
1296
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl));
1446
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _entriesUrl));
1297
1447
  const headers = {};
1298
1448
  if (options == null ? void 0 : options.ifUnmodifiedSince) {
1299
1449
  headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
@@ -1307,7 +1457,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1307
1457
  return { modified: response.headers.get("x-modified-at") };
1308
1458
  }
1309
1459
  async deleteContentType(body) {
1310
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl));
1460
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _contentTypesUrl));
1311
1461
  await this.apiClient(fetchUri, {
1312
1462
  method: "DELETE",
1313
1463
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1315,7 +1465,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1315
1465
  });
1316
1466
  }
1317
1467
  async deleteEntry(body) {
1318
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl));
1468
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _entriesUrl));
1319
1469
  await this.apiClient(fetchUri, {
1320
1470
  method: "DELETE",
1321
1471
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1334,8 +1484,8 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1334
1484
  };
1335
1485
  _contentTypesUrl = /* @__PURE__ */ new WeakMap();
1336
1486
  _entriesUrl = /* @__PURE__ */ new WeakMap();
1337
- __privateAdd2(_ContentClient, _contentTypesUrl, "/api/v1/content-types");
1338
- __privateAdd2(_ContentClient, _entriesUrl, "/api/v1/entries");
1487
+ __privateAdd3(_ContentClient, _contentTypesUrl, "/api/v1/content-types");
1488
+ __privateAdd3(_ContentClient, _entriesUrl, "/api/v1/entries");
1339
1489
  var _url8;
1340
1490
  var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1341
1491
  constructor(options) {
@@ -1344,12 +1494,12 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1344
1494
  /** Fetches all DataTypes for a project */
1345
1495
  async get(options) {
1346
1496
  const { projectId } = this.options;
1347
- const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8), { ...options, projectId });
1497
+ const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8), { ...options, projectId });
1348
1498
  return await this.apiClient(fetchUri);
1349
1499
  }
1350
1500
  /** Updates or creates (based on id) a DataType */
1351
1501
  async upsert(body) {
1352
- const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8));
1502
+ const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
1353
1503
  await this.apiClient(fetchUri, {
1354
1504
  method: "PUT",
1355
1505
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1358,7 +1508,7 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1358
1508
  }
1359
1509
  /** Deletes a DataType */
1360
1510
  async remove(body) {
1361
- const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8));
1511
+ const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
1362
1512
  await this.apiClient(fetchUri, {
1363
1513
  method: "DELETE",
1364
1514
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1367,7 +1517,7 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1367
1517
  }
1368
1518
  };
1369
1519
  _url8 = /* @__PURE__ */ new WeakMap();
1370
- __privateAdd2(_DataTypeClient, _url8, "/api/v1/data-types");
1520
+ __privateAdd3(_DataTypeClient, _url8, "/api/v1/data-types");
1371
1521
  function getComponentPath(ancestorsAndSelf) {
1372
1522
  const path = [];
1373
1523
  for (let i = ancestorsAndSelf.length - 1; i >= 0; i--) {
@@ -1430,9 +1580,9 @@ function parseVariableExpression(serialized, onToken) {
1430
1580
  let bufferStartIndex = 0;
1431
1581
  let bufferEndIndex = 0;
1432
1582
  let tokenCount = 0;
1433
- const handleToken = (token, type) => {
1583
+ const handleToken = (token, type, offset) => {
1434
1584
  tokenCount++;
1435
- return onToken == null ? void 0 : onToken(token, type);
1585
+ return onToken == null ? void 0 : onToken(token, type, offset);
1436
1586
  };
1437
1587
  let state = "text";
1438
1588
  for (let index = 0; index < serialized.length; index++) {
@@ -1443,7 +1593,7 @@ function parseVariableExpression(serialized, onToken) {
1443
1593
  if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
1444
1594
  if (serialized[index - 1] === escapeCharacter) {
1445
1595
  bufferEndIndex -= escapeCharacter.length;
1446
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
1596
+ if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
1447
1597
  return tokenCount;
1448
1598
  }
1449
1599
  bufferStartIndex = index;
@@ -1452,12 +1602,12 @@ function parseVariableExpression(serialized, onToken) {
1452
1602
  }
1453
1603
  if (state === "variable") {
1454
1604
  const textStart = bufferStartIndex - variablePrefix.length;
1455
- if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
1605
+ if (handleToken(serialized.substring(textStart, bufferEndIndex), "text", textStart) === false) {
1456
1606
  return tokenCount;
1457
1607
  }
1458
1608
  bufferStartIndex = bufferEndIndex;
1459
1609
  } else if (bufferEndIndex > bufferStartIndex) {
1460
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
1610
+ if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
1461
1611
  return tokenCount;
1462
1612
  }
1463
1613
  bufferStartIndex = bufferEndIndex;
@@ -1475,7 +1625,7 @@ function parseVariableExpression(serialized, onToken) {
1475
1625
  state = "text";
1476
1626
  if (bufferEndIndex > bufferStartIndex) {
1477
1627
  const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
1478
- if (handleToken(unescapedVariableName, "variable") === false) {
1628
+ if (handleToken(unescapedVariableName, "variable", bufferStartIndex) === false) {
1479
1629
  return tokenCount;
1480
1630
  }
1481
1631
  bufferStartIndex = bufferEndIndex + variableSuffix.length;
@@ -1489,7 +1639,7 @@ function parseVariableExpression(serialized, onToken) {
1489
1639
  bufferStartIndex -= variablePrefix.length;
1490
1640
  }
1491
1641
  if (bufferStartIndex < serialized.length) {
1492
- handleToken(serialized.substring(bufferStartIndex), state);
1642
+ handleToken(serialized.substring(bufferStartIndex), state, bufferStartIndex);
1493
1643
  }
1494
1644
  return tokenCount;
1495
1645
  }
@@ -1506,7 +1656,7 @@ function hasReferencedVariables(value) {
1506
1656
  return variableTokenCount;
1507
1657
  }
1508
1658
  function walkNodeTree(node, visitor, options) {
1509
- var _a, _b;
1659
+ var _a, _b, _c;
1510
1660
  const componentQueue = [
1511
1661
  {
1512
1662
  ancestorsAndSelf: Array.isArray(node) ? node : [{ node, type: "root" }],
@@ -1514,12 +1664,14 @@ function walkNodeTree(node, visitor, options) {
1514
1664
  }
1515
1665
  ];
1516
1666
  const childContexts = /* @__PURE__ */ new Map();
1667
+ const order = (_a = options == null ? void 0 : options.order) != null ? _a : "dfs";
1668
+ const takeNext = () => order === "bfs" ? componentQueue.shift() : componentQueue.pop();
1517
1669
  do {
1518
- const currentQueueEntry = componentQueue.pop();
1670
+ const currentQueueEntry = takeNext();
1519
1671
  if (!currentQueueEntry) continue;
1520
1672
  const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
1521
1673
  let visitDescendants = true;
1522
- let descendantContext = (_a = childContexts.get(currentComponent.node)) != null ? _a : currentQueueEntry.context;
1674
+ let descendantContext = (_b = childContexts.get(currentComponent.node)) != null ? _b : currentQueueEntry.context;
1523
1675
  let visitorInfo;
1524
1676
  if (currentComponent.type === "root" && isRootEntryReference(currentComponent) || currentComponent.type === "block") {
1525
1677
  visitorInfo = {
@@ -1706,39 +1858,11 @@ function walkNodeTree(node, visitor, options) {
1706
1858
  continue;
1707
1859
  }
1708
1860
  const slots = "slots" in currentComponent.node && currentComponent.node.slots;
1709
- if (slots) {
1710
- const slotKeys = Object.keys(slots);
1711
- for (let slotIndex = slotKeys.length - 1; slotIndex >= 0; slotIndex--) {
1712
- const slotKey = slotKeys[slotIndex];
1713
- const components = slots[slotKey];
1714
- for (let componentIndex = components.length - 1; componentIndex >= 0; componentIndex--) {
1715
- const enqueueingComponent = components[componentIndex];
1716
- const parentSlotIndexFn = () => {
1717
- const result = currentComponent.node.slots[slotKey].findIndex(
1718
- (x) => x === enqueueingComponent
1719
- );
1720
- return result;
1721
- };
1722
- componentQueue.push({
1723
- ancestorsAndSelf: [
1724
- {
1725
- type: "slot",
1726
- node: enqueueingComponent,
1727
- parentSlot: slotKey,
1728
- parentSlotIndexFn
1729
- },
1730
- ...currentQueueEntry.ancestorsAndSelf
1731
- ],
1732
- context: descendantContext
1733
- });
1734
- }
1735
- }
1736
- }
1861
+ const childEntries = [];
1737
1862
  const properties = getPropertiesValue(currentComponent.node);
1738
1863
  if (properties) {
1739
1864
  const propertyEntries = Object.entries(properties);
1740
- for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
1741
- const [propKey, propObject] = propertyEntries[propIndex];
1865
+ for (const [propKey, propObject] of propertyEntries) {
1742
1866
  if (!isNestedNodeType(propObject.type)) {
1743
1867
  continue;
1744
1868
  }
@@ -1758,13 +1882,12 @@ function walkNodeTree(node, visitor, options) {
1758
1882
  continue;
1759
1883
  }
1760
1884
  }
1761
- const blocks = (_b = propObject.value) != null ? _b : [];
1762
- for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
1763
- const enqueueingBlock = blocks[blockIndex];
1885
+ const blocks = (_c = propObject.value) != null ? _c : [];
1886
+ for (const enqueueingBlock of blocks) {
1764
1887
  const blockIndexFn = () => {
1765
1888
  return getBlockValue(currentComponent.node, propKey).findIndex((x) => x === enqueueingBlock);
1766
1889
  };
1767
- componentQueue.push({
1890
+ childEntries.push({
1768
1891
  ancestorsAndSelf: [
1769
1892
  {
1770
1893
  type: "block",
@@ -1779,6 +1902,36 @@ function walkNodeTree(node, visitor, options) {
1779
1902
  }
1780
1903
  }
1781
1904
  }
1905
+ if (slots) {
1906
+ const slotKeys = Object.keys(slots);
1907
+ for (const slotKey of slotKeys) {
1908
+ const components = slots[slotKey];
1909
+ for (const enqueueingComponent of components) {
1910
+ const parentSlotIndexFn = () => {
1911
+ const result = currentComponent.node.slots[slotKey].findIndex(
1912
+ (x) => x === enqueueingComponent
1913
+ );
1914
+ return result;
1915
+ };
1916
+ childEntries.push({
1917
+ ancestorsAndSelf: [
1918
+ {
1919
+ type: "slot",
1920
+ node: enqueueingComponent,
1921
+ parentSlot: slotKey,
1922
+ parentSlotIndexFn
1923
+ },
1924
+ ...currentQueueEntry.ancestorsAndSelf
1925
+ ],
1926
+ context: descendantContext
1927
+ });
1928
+ }
1929
+ }
1930
+ }
1931
+ if (order === "dfs") {
1932
+ childEntries.reverse();
1933
+ }
1934
+ componentQueue.push(...childEntries);
1782
1935
  } while (componentQueue.length > 0);
1783
1936
  }
1784
1937
  function isNestedNodeType(type) {
@@ -1817,7 +1970,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1817
1970
  * Gets a list of property type and hook names for the current team, including public integrations' hooks.
1818
1971
  */
1819
1972
  get(options) {
1820
- const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl), {
1973
+ const fetchUri = this.createUrl(__privateGet3(_IntegrationPropertyEditorsClient2, _baseUrl), {
1821
1974
  ...options,
1822
1975
  teamId: this.teamId
1823
1976
  });
@@ -1827,7 +1980,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1827
1980
  * Creates or updates a custom AI property editor on a Mesh app.
1828
1981
  */
1829
1982
  async deploy(body) {
1830
- const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl));
1983
+ const fetchUri = this.createUrl(__privateGet3(_IntegrationPropertyEditorsClient2, _baseUrl));
1831
1984
  await this.apiClient(fetchUri, {
1832
1985
  method: "PUT",
1833
1986
  body: JSON.stringify({ ...body, teamId: this.teamId }),
@@ -1838,7 +1991,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1838
1991
  * Removes a custom AI property editor from a Mesh app.
1839
1992
  */
1840
1993
  async delete(body) {
1841
- const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl));
1994
+ const fetchUri = this.createUrl(__privateGet3(_IntegrationPropertyEditorsClient2, _baseUrl));
1842
1995
  await this.apiClient(fetchUri, {
1843
1996
  method: "DELETE",
1844
1997
  body: JSON.stringify({ ...body, teamId: this.teamId }),
@@ -1847,20 +2000,30 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1847
2000
  }
1848
2001
  };
1849
2002
  _baseUrl = /* @__PURE__ */ new WeakMap();
1850
- __privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
2003
+ __privateAdd3(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
1851
2004
  var _url22;
2005
+ var _projectsUrl;
1852
2006
  var _ProjectClient = class _ProjectClient2 extends ApiClient {
1853
2007
  constructor(options) {
1854
2008
  super({ ...options, bypassCache: true });
1855
2009
  }
1856
2010
  /** Fetches single Project */
1857
2011
  async get(options) {
1858
- const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22), { ...options });
2012
+ const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22), { ...options });
2013
+ return await this.apiClient(fetchUri);
2014
+ }
2015
+ /**
2016
+ * Fetches projects grouped by team.
2017
+ * When teamId is provided, returns a single team with its projects.
2018
+ * When omitted, returns all accessible teams and their projects.
2019
+ */
2020
+ async getProjects(options) {
2021
+ const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
1859
2022
  return await this.apiClient(fetchUri);
1860
2023
  }
1861
2024
  /** Updates or creates (based on id) a Project */
1862
2025
  async upsert(body) {
1863
- const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
2026
+ const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
1864
2027
  return await this.apiClient(fetchUri, {
1865
2028
  method: "PUT",
1866
2029
  body: JSON.stringify({ ...body })
@@ -1868,7 +2031,7 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1868
2031
  }
1869
2032
  /** Deletes a Project */
1870
2033
  async delete(body) {
1871
- const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
2034
+ const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
1872
2035
  await this.apiClient(fetchUri, {
1873
2036
  method: "DELETE",
1874
2037
  body: JSON.stringify({ ...body }),
@@ -1877,7 +2040,9 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1877
2040
  }
1878
2041
  };
1879
2042
  _url22 = /* @__PURE__ */ new WeakMap();
1880
- __privateAdd2(_ProjectClient, _url22, "/api/v1/project");
2043
+ _projectsUrl = /* @__PURE__ */ new WeakMap();
2044
+ __privateAdd3(_ProjectClient, _url22, "/api/v1/project");
2045
+ __privateAdd3(_ProjectClient, _projectsUrl, "/api/v1/projects");
1881
2046
  var ROUTE_URL = "/api/v1/route";
1882
2047
  var RouteClient = class extends ApiClient {
1883
2048
  constructor(options) {
@@ -1891,13 +2056,26 @@ var RouteClient = class extends ApiClient {
1891
2056
  /** Fetches lists of Canvas compositions, optionally by type */
1892
2057
  async getRoute(options) {
1893
2058
  const { projectId } = this.options;
1894
- const fetchUri = this.createUrl(ROUTE_URL, { ...options, projectId }, this.edgeApiHost);
2059
+ const { select, ...rest } = options != null ? options : {};
2060
+ const rewrittenSelect = projectionToQuery(select);
2061
+ const fetchUri = this.createUrl(ROUTE_URL, { ...rest, projectId, ...rewrittenSelect }, this.edgeApiHost);
1895
2062
  return await this.apiClient(
1896
2063
  fetchUri,
1897
2064
  this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
1898
2065
  );
1899
2066
  }
1900
2067
  };
2068
+ var getDataSourceVariantFromRouteGetParams = (params, defaultPreviewState) => {
2069
+ var _a, _b;
2070
+ const dataSourceVariant = (
2071
+ // support explicit 'undefined' as a way to opt out of data resources variant
2072
+ "dataSourceVariant" in params ? params.dataSourceVariant : (
2073
+ // in case of DRAFT state we still want to fetch unpublished data
2074
+ ((_b = (_a = params == null ? void 0 : params.state) != null ? _a : defaultPreviewState) != null ? _b : CANVAS_PUBLISHED_STATE) !== CANVAS_PUBLISHED_STATE ? "unpublished" : void 0
2075
+ )
2076
+ );
2077
+ return dataSourceVariant;
2078
+ };
1901
2079
  function mapSlotToPersonalizedVariations(slot) {
1902
2080
  if (!slot) return [];
1903
2081
  return slot.map((v, i) => {
@@ -1979,8 +2157,15 @@ var isIncontextEditingEnabled = ({
1979
2157
  var isDevelopmentEnvironment = () => {
1980
2158
  return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
1981
2159
  };
2160
+ var shouldIgnoreRedirects = ({ state }) => {
2161
+ const isNotPublished = state !== CANVAS_PUBLISHED_STATE;
2162
+ return isNotPublished ? true : void 0;
2163
+ };
1982
2164
 
1983
2165
  // src/clients/cache.ts
2166
+ var isSpecificCacheMode = (options) => {
2167
+ return "cache" in options;
2168
+ };
1984
2169
  var isStateCacheMode = (options) => {
1985
2170
  return "state" in options;
1986
2171
  };
@@ -2007,7 +2192,9 @@ var resolveCache = ({
2007
2192
  }) => {
2008
2193
  let cache2 = void 0;
2009
2194
  if (options) {
2010
- if (isStateCacheMode(options)) {
2195
+ if (isSpecificCacheMode(options)) {
2196
+ cache2 = options.cache;
2197
+ } else if (isStateCacheMode(options)) {
2011
2198
  if (options.state === CANVAS_DRAFT_STATE || options.state === CANVAS_EDITOR_STATE) {
2012
2199
  cache2 = {
2013
2200
  type: "no-cache",
@@ -2126,7 +2313,7 @@ function createLimiter(concurrency) {
2126
2313
  });
2127
2314
  };
2128
2315
  }
2129
- async function retry(fn, options) {
2316
+ async function retry2(fn, options) {
2130
2317
  let lastError;
2131
2318
  let delay = 1e3;
2132
2319
  for (let attempt = 1; attempt <= options.retries + 1; attempt++) {
@@ -2166,7 +2353,7 @@ function createLimitPolicy2({
2166
2353
  }
2167
2354
  if (retryOptions) {
2168
2355
  const retryFunc = currentFunc;
2169
- currentFunc = () => retry(retryFunc, {
2356
+ currentFunc = () => retry2(retryFunc, {
2170
2357
  ...retryOptions,
2171
2358
  onFailedAttempt: async (error) => {
2172
2359
  if (retryOptions.onFailedAttempt) {
@@ -2300,14 +2487,14 @@ var getManifest = async (options) => {
2300
2487
  import "server-only";
2301
2488
 
2302
2489
  // ../project-map/dist/index.mjs
2303
- var __typeError3 = (msg) => {
2490
+ var __typeError4 = (msg) => {
2304
2491
  throw TypeError(msg);
2305
2492
  };
2306
- var __accessCheck3 = (obj, member, msg) => member.has(obj) || __typeError3("Cannot " + msg);
2307
- var __privateGet3 = (obj, member, getter) => (__accessCheck3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
2308
- 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);
2309
- var __privateSet = (obj, member, value, setter) => (__accessCheck3(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
2310
- var __privateMethod = (obj, member, method) => (__accessCheck3(obj, member, "access private method"), method);
2493
+ var __accessCheck4 = (obj, member, msg) => member.has(obj) || __typeError4("Cannot " + msg);
2494
+ var __privateGet4 = (obj, member, getter) => (__accessCheck4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
2495
+ 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);
2496
+ var __privateSet2 = (obj, member, value, setter) => (__accessCheck4(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
2497
+ var __privateMethod = (obj, member, method) => (__accessCheck4(obj, member, "access private method"), method);
2311
2498
  var ProjectMapClient = class extends ApiClient {
2312
2499
  constructor(options) {
2313
2500
  super(options);
@@ -2454,12 +2641,12 @@ var isDynamicRouteSegment_fn;
2454
2641
  var _Route = class _Route2 {
2455
2642
  constructor(route) {
2456
2643
  this.route = route;
2457
- __privateAdd3(this, _routeInfo);
2644
+ __privateAdd4(this, _routeInfo);
2458
2645
  var _a;
2459
- __privateSet(this, _routeInfo, __privateMethod(_a = _Route2, _Route_static, parseRouteOrPath_fn).call(_a, this.route));
2646
+ __privateSet2(this, _routeInfo, __privateMethod(_a = _Route2, _Route_static, parseRouteOrPath_fn).call(_a, this.route));
2460
2647
  }
2461
2648
  get dynamicSegmentCount() {
2462
- return __privateGet3(this, _routeInfo).segments.reduce(
2649
+ return __privateGet4(this, _routeInfo).segments.reduce(
2463
2650
  (count, segment) => {
2464
2651
  var _a;
2465
2652
  return __privateMethod(_a = _Route2, _Route_static, isDynamicRouteSegment_fn).call(_a, segment) ? count + 1 : count;
@@ -2471,7 +2658,7 @@ var _Route = class _Route2 {
2471
2658
  matches(path) {
2472
2659
  var _a, _b;
2473
2660
  const { segments: pathSegments, queryParams: pathQuery } = __privateMethod(_a = _Route2, _Route_static, parseRouteOrPath_fn).call(_a, path);
2474
- const { segments: routeSegments } = __privateGet3(this, _routeInfo);
2661
+ const { segments: routeSegments } = __privateGet4(this, _routeInfo);
2475
2662
  if (pathSegments.length !== routeSegments.length) {
2476
2663
  return { match: false };
2477
2664
  }
@@ -2492,7 +2679,7 @@ var _Route = class _Route2 {
2492
2679
  return { match: false };
2493
2680
  }
2494
2681
  }
2495
- for (const [key, value] of __privateGet3(this, _routeInfo).queryParams) {
2682
+ for (const [key, value] of __privateGet4(this, _routeInfo).queryParams) {
2496
2683
  possibleMatch.queryParams[key] = pathQuery.has(key) ? pathQuery.get(key) : value;
2497
2684
  }
2498
2685
  return possibleMatch;
@@ -2502,7 +2689,7 @@ var _Route = class _Route2 {
2502
2689
  */
2503
2690
  expand(options) {
2504
2691
  const { dynamicInputValues = {}, allowedQueryParams = [], doNotEscapeVariables = false } = options != null ? options : {};
2505
- const path = __privateGet3(this, _routeInfo).segments.map((segment) => {
2692
+ const path = __privateGet4(this, _routeInfo).segments.map((segment) => {
2506
2693
  const dynamicSegmentName = _Route2.getDynamicRouteSegmentName(segment);
2507
2694
  if (!dynamicSegmentName) {
2508
2695
  return segment;
@@ -2532,6 +2719,35 @@ var _Route = class _Route2 {
2532
2719
  }
2533
2720
  return segment.slice(_Route2.dynamicSegmentPrefix.length);
2534
2721
  }
2722
+ /**
2723
+ * Splits a path into the path portion and an optional `#fragment`
2724
+ * (everything after the first `#`).
2725
+ *
2726
+ * Variable expressions (`${...}`) may legitimately contain `#` characters
2727
+ * (e.g. JSON-pointer tokens like `${#jptr:/foo/_slug}`), so the fragment
2728
+ * delimiter is the first `#` that falls outside of a variable expression.
2729
+ */
2730
+ static splitFragment(path) {
2731
+ let fragmentIndex = -1;
2732
+ parseVariableExpression(path, (token, type, offset) => {
2733
+ if (type === "variable") {
2734
+ return;
2735
+ }
2736
+ const hashOffset = token.indexOf("#");
2737
+ if (hashOffset === -1) {
2738
+ return;
2739
+ }
2740
+ fragmentIndex = offset + hashOffset;
2741
+ return false;
2742
+ });
2743
+ if (fragmentIndex === -1) {
2744
+ return { path, fragment: void 0 };
2745
+ }
2746
+ return {
2747
+ path: path.slice(0, fragmentIndex),
2748
+ fragment: path.slice(fragmentIndex + 1)
2749
+ };
2750
+ }
2535
2751
  };
2536
2752
  _routeInfo = /* @__PURE__ */ new WeakMap();
2537
2753
  _Route_static = /* @__PURE__ */ new WeakSet();
@@ -2553,7 +2769,7 @@ isDynamicRouteSegment_fn = function(segment) {
2553
2769
  }
2554
2770
  return segment.startsWith(_Route.dynamicSegmentPrefix);
2555
2771
  };
2556
- __privateAdd3(_Route, _Route_static);
2772
+ __privateAdd4(_Route, _Route_static);
2557
2773
  _Route.dynamicSegmentPrefix = ":";
2558
2774
  function encodeRouteComponent(value, doNotEscapeVariables) {
2559
2775
  if (!doNotEscapeVariables) {
@@ -2749,6 +2965,13 @@ var createTestComponentProps = ({
2749
2965
  test
2750
2966
  }) => {
2751
2967
  var _a;
2968
+ if (pageState.isPrefetch) {
2969
+ return {
2970
+ ...common,
2971
+ index: void 0,
2972
+ test
2973
+ };
2974
+ }
2752
2975
  const component = resolveComponentFromPageState({
2753
2976
  pageState,
2754
2977
  componentId
@@ -2756,7 +2979,7 @@ var createTestComponentProps = ({
2756
2979
  const [testIndex] = (_a = component == null ? void 0 : component.indexes) != null ? _a : [];
2757
2980
  return {
2758
2981
  ...common,
2759
- index: testIndex != null ? testIndex : 0,
2982
+ index: testIndex,
2760
2983
  test
2761
2984
  };
2762
2985
  };
@@ -2787,6 +3010,7 @@ var applyEditableParameters = ({
2787
3010
  };
2788
3011
 
2789
3012
  // src/components/Test.tsx
3013
+ import { ClientTest } from "@uniformdev/next-app-router-client";
2790
3014
  import { createElement, Fragment } from "react";
2791
3015
 
2792
3016
  // src/components/ContextTestTransfer.tsx
@@ -2799,7 +3023,14 @@ var ContextTestTransfer = ({ event }) => {
2799
3023
  // src/components/Test.tsx
2800
3024
  var Test = ({ index, slots, test, component, context: compositionContext }) => {
2801
3025
  var _a, _b, _c, _d, _e, _f;
2802
- 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;
3026
+ if (typeof index !== "number") {
3027
+ return createElement(ClientTest, {
3028
+ slots,
3029
+ test,
3030
+ context: compositionContext
3031
+ });
3032
+ }
3033
+ const indexToShow = (_b = (_a = slots == null ? void 0 : slots[CANVAS_TEST_SLOT]) == null ? void 0 : _a.items[index]) != null ? _b : null;
2803
3034
  const event = {
2804
3035
  name: test.name,
2805
3036
  control: (_d = (_c = test.variations[index]) == null ? void 0 : _c.control) != null ? _d : false,
@@ -2856,6 +3087,9 @@ var getQuirkSerialization = () => {
2856
3087
  return true;
2857
3088
  };
2858
3089
  var getMiddlewareRuntimeCache = () => {
3090
+ if (process.env.NODE_ENV === "development" && !process.env.RUNTIME_CACHE_ENDPOINT) {
3091
+ return false;
3092
+ }
2859
3093
  if (typeof config.middlewareRuntimeCache === "boolean") {
2860
3094
  return config.middlewareRuntimeCache;
2861
3095
  }
@@ -3577,10 +3811,12 @@ var generatePossiblePageStates = ({
3577
3811
  defaultConsent: void 0,
3578
3812
  previewMode: void 0,
3579
3813
  rules: void 0,
3580
- locale
3814
+ locale,
3815
+ isPrefetch: void 0
3581
3816
  };
3817
+ const allComponentIds = runnables.filter((r) => r.type === "test" || r.type === "personalization").map((r) => r._id);
3582
3818
  const allStates = generateStatesRecursively(dependencyMap, void 0, initialState);
3583
- return allStates.map((payload) => serializeEvaluationResult({ payload }));
3819
+ return allStates.map((payload) => serializeEvaluationResult({ payload, allComponentIds }));
3584
3820
  };
3585
3821
  function permutationsWithoutRepetition(options, k) {
3586
3822
  if (k === 0) return [[]];
@@ -3629,7 +3865,10 @@ var DefaultDataClient = class {
3629
3865
  }
3630
3866
  }
3631
3867
  const manifest = await getManifest({
3632
- cache: {
3868
+ cache: isDevelopmentEnvironment() ? {
3869
+ type: "no-cache",
3870
+ bypassCache: true
3871
+ } : {
3633
3872
  type: "force-cache"
3634
3873
  }
3635
3874
  });
@@ -3732,20 +3971,23 @@ var DefaultDataClient = class {
3732
3971
  };
3733
3972
  }
3734
3973
  async getRoutePageState(options) {
3974
+ const shouldBypassCache = options.pageState.compositionState !== CANVAS_PUBLISHED_STATE || isDevelopmentEnvironment();
3735
3975
  const routeClient = getRouteClient({
3736
- cache: options.pageState.compositionState === CANVAS_PUBLISHED_STATE ? {
3737
- type: "force-cache"
3738
- } : {
3976
+ cache: shouldBypassCache ? {
3739
3977
  type: "no-cache",
3740
3978
  bypassCache: true
3979
+ } : {
3980
+ type: "force-cache"
3741
3981
  }
3742
3982
  });
3743
3983
  const originalRoute = {
3744
3984
  path: options.pageState.routePath,
3745
3985
  state: options.pageState.compositionState,
3986
+ dataSourceVariant: getDataSourceVariantFromRouteGetParams({}, options.pageState.compositionState),
3746
3987
  withComponentIDs: true,
3747
3988
  releaseId: options.pageState.releaseId,
3748
- locale: options.pageState.locale
3989
+ locale: options.pageState.locale,
3990
+ ignoreRedirects: shouldIgnoreRedirects({ state: options.pageState.compositionState })
3749
3991
  };
3750
3992
  const resolvedRoute = await this.getRouteFromApi({
3751
3993
  source: "pageState",