@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/cache.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,7 +161,238 @@ 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
 
@@ -161,33 +409,40 @@ var import_next_app_router_shared = require("@uniformdev/next-app-router-shared"
161
409
  // ../context/dist/api/api.mjs
162
410
  var import_p_limit = __toESM(require_p_limit(), 1);
163
411
  var __defProp2 = Object.defineProperty;
164
- var __typeError = (msg) => {
412
+ var __typeError2 = (msg) => {
165
413
  throw TypeError(msg);
166
414
  };
167
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
168
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
169
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
170
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
171
- 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);
415
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
416
+ var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
417
+ var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
418
+ var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
419
+ 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);
172
420
  var defaultLimitPolicy = (0, import_p_limit.default)(6);
421
+ var UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE = "Bearer token not valid or expired";
173
422
  var ApiClientError = class _ApiClientError extends Error {
174
423
  constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
175
424
  super(
176
425
  `${errorMessage}
177
426
  ${statusCode}${statusText ? " " + statusText : ""} (${fetchMethod} ${fetchUri}${requestId ? ` Request ID: ${requestId}` : ""})`
178
427
  );
179
- this.errorMessage = errorMessage;
180
- this.fetchMethod = fetchMethod;
181
- this.fetchUri = fetchUri;
182
- this.statusCode = statusCode;
183
- this.statusText = statusText;
184
- this.requestId = requestId;
428
+ __publicField2(this, "errorMessage", errorMessage);
429
+ __publicField2(this, "fetchMethod", fetchMethod);
430
+ __publicField2(this, "fetchUri", fetchUri);
431
+ __publicField2(this, "statusCode", statusCode);
432
+ __publicField2(this, "statusText", statusText);
433
+ __publicField2(this, "requestId", requestId);
185
434
  Object.setPrototypeOf(this, _ApiClientError.prototype);
186
435
  }
187
436
  };
437
+ var BearerTokenNotValidOrExpiredError = class _BearerTokenNotValidOrExpiredError extends ApiClientError {
438
+ constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
439
+ super(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId);
440
+ Object.setPrototypeOf(this, _BearerTokenNotValidOrExpiredError.prototype);
441
+ }
442
+ };
188
443
  var ApiClient = class _ApiClient {
189
444
  constructor(options) {
190
- __publicField(this, "options");
445
+ __publicField2(this, "options");
191
446
  var _a, _b, _c, _d, _e;
192
447
  if (!options.apiKey && !options.bearerToken) {
193
448
  throw new Error("You must provide an API key or a bearer token");
@@ -218,7 +473,7 @@ var ApiClient = class _ApiClient {
218
473
  }
219
474
  async apiClientWithResponse(fetchUri, options) {
220
475
  return this.options.limitPolicy(async () => {
221
- var _a;
476
+ var _a, _b;
222
477
  const coreHeaders = this.options.apiKey ? {
223
478
  "x-api-key": this.options.apiKey
224
479
  } : {
@@ -254,9 +509,19 @@ var ApiClient = class _ApiClient {
254
509
  } catch (e) {
255
510
  message = `General error`;
256
511
  }
512
+ if (apiResponse.status === 401 && message === UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE) {
513
+ throw new BearerTokenNotValidOrExpiredError(
514
+ message,
515
+ (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
516
+ fetchUri.toString(),
517
+ apiResponse.status,
518
+ apiResponse.statusText,
519
+ _ApiClient.getRequestId(apiResponse)
520
+ );
521
+ }
257
522
  throw new ApiClientError(
258
523
  message,
259
- (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
524
+ (_b = options == null ? void 0 : options.method) != null ? _b : "GET",
260
525
  fetchUri.toString(),
261
526
  apiResponse.status,
262
527
  apiResponse.statusText,
@@ -330,25 +595,39 @@ async function handleRateLimits(callApi) {
330
595
  }
331
596
  const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
332
597
  const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
333
- await new Promise((resolve) => setTimeout(resolve, resetWait + backoffWait));
598
+ await new Promise((resolve) => setTimeout(resolve, Math.max(0, resetWait + backoffWait)));
334
599
  backoffRetriesLeft -= 1;
335
600
  }
336
601
  return response;
337
602
  }
338
- var _url;
339
- var _AggregateClient = class _AggregateClient2 extends ApiClient {
340
- constructor(options) {
341
- super(options);
342
- }
343
- /** Fetches all aggregates for a project */
344
- async get(options) {
603
+ var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
604
+ function rewriteFiltersForApi(filters) {
605
+ return Object.entries(filters != null ? filters : {}).reduce(
606
+ (acc, [key, value]) => {
607
+ const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
608
+ const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
609
+ return {
610
+ ...acc,
611
+ [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
612
+ };
613
+ },
614
+ {}
615
+ );
616
+ }
617
+ var _url;
618
+ var _AggregateClient = class _AggregateClient2 extends ApiClient {
619
+ constructor(options) {
620
+ super(options);
621
+ }
622
+ /** Fetches all aggregates for a project */
623
+ async get(options) {
345
624
  const { projectId } = this.options;
346
- const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url), { ...options, projectId });
625
+ const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url), { ...options, projectId });
347
626
  return await this.apiClient(fetchUri);
348
627
  }
349
628
  /** Updates or creates (based on id) an Aggregate */
350
629
  async upsert(body) {
351
- const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url));
630
+ const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url));
352
631
  await this.apiClient(fetchUri, {
353
632
  method: "PUT",
354
633
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -357,7 +636,7 @@ var _AggregateClient = class _AggregateClient2 extends ApiClient {
357
636
  }
358
637
  /** Deletes an Aggregate */
359
638
  async remove(body) {
360
- const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url));
639
+ const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url));
361
640
  await this.apiClient(fetchUri, {
362
641
  method: "DELETE",
363
642
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -366,7 +645,7 @@ var _AggregateClient = class _AggregateClient2 extends ApiClient {
366
645
  }
367
646
  };
368
647
  _url = /* @__PURE__ */ new WeakMap();
369
- __privateAdd(_AggregateClient, _url, "/api/v2/aggregate");
648
+ __privateAdd2(_AggregateClient, _url, "/api/v2/aggregate");
370
649
  var _url2;
371
650
  var _DimensionClient = class _DimensionClient2 extends ApiClient {
372
651
  constructor(options) {
@@ -375,12 +654,12 @@ var _DimensionClient = class _DimensionClient2 extends ApiClient {
375
654
  /** Fetches the known score dimensions for a project */
376
655
  async get(options) {
377
656
  const { projectId } = this.options;
378
- const fetchUri = this.createUrl(__privateGet(_DimensionClient2, _url2), { ...options, projectId });
657
+ const fetchUri = this.createUrl(__privateGet2(_DimensionClient2, _url2), { ...options, projectId });
379
658
  return await this.apiClient(fetchUri);
380
659
  }
381
660
  };
382
661
  _url2 = /* @__PURE__ */ new WeakMap();
383
- __privateAdd(_DimensionClient, _url2, "/api/v2/dimension");
662
+ __privateAdd2(_DimensionClient, _url2, "/api/v2/dimension");
384
663
  var _url3;
385
664
  var _valueUrl;
386
665
  var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
@@ -390,12 +669,12 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
390
669
  /** Fetches all enrichments and values for a project, grouped by category */
391
670
  async get(options) {
392
671
  const { projectId } = this.options;
393
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3), { ...options, projectId });
672
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3), { ...options, projectId });
394
673
  return await this.apiClient(fetchUri);
395
674
  }
396
675
  /** Updates or creates (based on id) an enrichment category */
397
676
  async upsertCategory(body) {
398
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3));
677
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3));
399
678
  await this.apiClient(fetchUri, {
400
679
  method: "PUT",
401
680
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -404,7 +683,7 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
404
683
  }
405
684
  /** Deletes an enrichment category */
406
685
  async removeCategory(body) {
407
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3));
686
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3));
408
687
  await this.apiClient(fetchUri, {
409
688
  method: "DELETE",
410
689
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -413,7 +692,7 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
413
692
  }
414
693
  /** Updates or creates (based on id) an enrichment value within an enrichment category */
415
694
  async upsertValue(body) {
416
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _valueUrl));
695
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _valueUrl));
417
696
  await this.apiClient(fetchUri, {
418
697
  method: "PUT",
419
698
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -422,7 +701,7 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
422
701
  }
423
702
  /** Deletes an enrichment value within an enrichment category. The category is left alone. */
424
703
  async removeValue(body) {
425
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _valueUrl));
704
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _valueUrl));
426
705
  await this.apiClient(fetchUri, {
427
706
  method: "DELETE",
428
707
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -432,8 +711,8 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
432
711
  };
433
712
  _url3 = /* @__PURE__ */ new WeakMap();
434
713
  _valueUrl = /* @__PURE__ */ new WeakMap();
435
- __privateAdd(_EnrichmentClient, _url3, "/api/v1/enrichments");
436
- __privateAdd(_EnrichmentClient, _valueUrl, "/api/v1/enrichment-values");
714
+ __privateAdd2(_EnrichmentClient, _url3, "/api/v1/enrichments");
715
+ __privateAdd2(_EnrichmentClient, _valueUrl, "/api/v1/enrichment-values");
437
716
  var _url4;
438
717
  var _ManifestClient = class _ManifestClient2 extends ApiClient {
439
718
  constructor(options) {
@@ -442,7 +721,7 @@ var _ManifestClient = class _ManifestClient2 extends ApiClient {
442
721
  /** Fetches the Context manifest for a project */
443
722
  async get(options) {
444
723
  const { projectId } = this.options;
445
- const fetchUri = this.createUrl(__privateGet(_ManifestClient2, _url4), { ...options, projectId });
724
+ const fetchUri = this.createUrl(__privateGet2(_ManifestClient2, _url4), { ...options, projectId });
446
725
  return await this.apiClient(fetchUri);
447
726
  }
448
727
  /** Publishes the Context manifest for a project */
@@ -456,7 +735,7 @@ var _ManifestClient = class _ManifestClient2 extends ApiClient {
456
735
  }
457
736
  };
458
737
  _url4 = /* @__PURE__ */ new WeakMap();
459
- __privateAdd(_ManifestClient, _url4, "/api/v2/manifest");
738
+ __privateAdd2(_ManifestClient, _url4, "/api/v2/manifest");
460
739
  var ManifestClient = _ManifestClient;
461
740
  var _url5;
462
741
  var _QuirkClient = class _QuirkClient2 extends ApiClient {
@@ -466,12 +745,12 @@ var _QuirkClient = class _QuirkClient2 extends ApiClient {
466
745
  /** Fetches all Quirks for a project */
467
746
  async get(options) {
468
747
  const { projectId } = this.options;
469
- const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5), { ...options, projectId });
748
+ const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5), { ...options, projectId });
470
749
  return await this.apiClient(fetchUri);
471
750
  }
472
751
  /** Updates or creates (based on id) a Quirk */
473
752
  async upsert(body) {
474
- const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5));
753
+ const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5));
475
754
  await this.apiClient(fetchUri, {
476
755
  method: "PUT",
477
756
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -480,7 +759,7 @@ var _QuirkClient = class _QuirkClient2 extends ApiClient {
480
759
  }
481
760
  /** Deletes a Quirk */
482
761
  async remove(body) {
483
- const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5));
762
+ const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5));
484
763
  await this.apiClient(fetchUri, {
485
764
  method: "DELETE",
486
765
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -489,457 +768,258 @@ var _QuirkClient = class _QuirkClient2 extends ApiClient {
489
768
  }
490
769
  };
491
770
  _url5 = /* @__PURE__ */ new WeakMap();
492
- __privateAdd(_QuirkClient, _url5, "/api/v2/quirk");
771
+ __privateAdd2(_QuirkClient, _url5, "/api/v2/quirk");
493
772
  var _url6;
494
773
  var _SignalClient = class _SignalClient2 extends ApiClient {
495
774
  constructor(options) {
496
775
  super(options);
497
776
  }
498
- /** Fetches all Signals for a project */
499
- async get(options) {
500
- const { projectId } = this.options;
501
- const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6), { ...options, projectId });
502
- return await this.apiClient(fetchUri);
503
- }
504
- /** Updates or creates (based on id) a Signal */
505
- async upsert(body) {
506
- const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6));
507
- await this.apiClient(fetchUri, {
508
- method: "PUT",
509
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
510
- expectNoContent: true
511
- });
512
- }
513
- /** Deletes a Signal */
514
- async remove(body) {
515
- const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6));
516
- await this.apiClient(fetchUri, {
517
- method: "DELETE",
518
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
519
- expectNoContent: true
520
- });
521
- }
522
- };
523
- _url6 = /* @__PURE__ */ new WeakMap();
524
- __privateAdd(_SignalClient, _url6, "/api/v2/signal");
525
- var _url7;
526
- var _TestClient = class _TestClient2 extends ApiClient {
527
- constructor(options) {
528
- super(options);
529
- }
530
- /** Fetches all Tests for a project */
531
- async get(options) {
532
- const { projectId } = this.options;
533
- const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7), { ...options, projectId });
534
- return await this.apiClient(fetchUri);
535
- }
536
- /** Updates or creates (based on id) a Test */
537
- async upsert(body) {
538
- const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7));
539
- await this.apiClient(fetchUri, {
540
- method: "PUT",
541
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
542
- expectNoContent: true
543
- });
544
- }
545
- /** Deletes a Test */
546
- async remove(body) {
547
- const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7));
548
- await this.apiClient(fetchUri, {
549
- method: "DELETE",
550
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
551
- expectNoContent: true
552
- });
553
- }
554
- };
555
- _url7 = /* @__PURE__ */ new WeakMap();
556
- __privateAdd(_TestClient, _url7, "/api/v2/test");
557
-
558
- // ../canvas/dist/index.mjs
559
- var __create2 = Object.create;
560
- var __defProp3 = Object.defineProperty;
561
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
562
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
563
- var __getProtoOf2 = Object.getPrototypeOf;
564
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
565
- var __typeError2 = (msg) => {
566
- throw TypeError(msg);
567
- };
568
- var __commonJS2 = (cb, mod) => function __require() {
569
- return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
570
- };
571
- var __copyProps2 = (to, from, except, desc) => {
572
- if (from && typeof from === "object" || typeof from === "function") {
573
- for (let key of __getOwnPropNames2(from))
574
- if (!__hasOwnProp2.call(to, key) && key !== except)
575
- __defProp3(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
576
- }
577
- return to;
578
- };
579
- var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
580
- // If the importer is in node compatibility mode or this is not an ESM
581
- // file that has been converted to a CommonJS file using a Babel-
582
- // compatible transform (i.e. "__esModule" has not been set), then set
583
- // "default" to the CommonJS "module.exports" for node compatibility.
584
- isNodeMode || !mod || !mod.__esModule ? __defProp3(target, "default", { value: mod, enumerable: true }) : target,
585
- mod
586
- ));
587
- var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
588
- var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
589
- 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);
590
- var require_yocto_queue2 = __commonJS2({
591
- "../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports2, module2) {
592
- "use strict";
593
- var Node = class {
594
- /// value;
595
- /// next;
596
- constructor(value) {
597
- this.value = value;
598
- this.next = void 0;
599
- }
600
- };
601
- var Queue = class {
602
- // TODO: Use private class fields when targeting Node.js 12.
603
- // #_head;
604
- // #_tail;
605
- // #_size;
606
- constructor() {
607
- this.clear();
608
- }
609
- enqueue(value) {
610
- const node = new Node(value);
611
- if (this._head) {
612
- this._tail.next = node;
613
- this._tail = node;
614
- } else {
615
- this._head = node;
616
- this._tail = node;
617
- }
618
- this._size++;
619
- }
620
- dequeue() {
621
- const current = this._head;
622
- if (!current) {
623
- return;
624
- }
625
- this._head = this._head.next;
626
- this._size--;
627
- return current.value;
628
- }
629
- clear() {
630
- this._head = void 0;
631
- this._tail = void 0;
632
- this._size = 0;
633
- }
634
- get size() {
635
- return this._size;
636
- }
637
- *[Symbol.iterator]() {
638
- let current = this._head;
639
- while (current) {
640
- yield current.value;
641
- current = current.next;
642
- }
643
- }
644
- };
645
- module2.exports = Queue;
646
- }
647
- });
648
- var require_p_limit2 = __commonJS2({
649
- "../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports2, module2) {
650
- "use strict";
651
- var Queue = require_yocto_queue2();
652
- var pLimit2 = (concurrency) => {
653
- if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
654
- throw new TypeError("Expected `concurrency` to be a number from 1 and up");
655
- }
656
- const queue = new Queue();
657
- let activeCount = 0;
658
- const next = () => {
659
- activeCount--;
660
- if (queue.size > 0) {
661
- queue.dequeue()();
662
- }
663
- };
664
- const run = async (fn, resolve, ...args) => {
665
- activeCount++;
666
- const result = (async () => fn(...args))();
667
- resolve(result);
668
- try {
669
- await result;
670
- } catch (e) {
671
- }
672
- next();
673
- };
674
- const enqueue = (fn, resolve, ...args) => {
675
- queue.enqueue(run.bind(null, fn, resolve, ...args));
676
- (async () => {
677
- await Promise.resolve();
678
- if (activeCount < concurrency && queue.size > 0) {
679
- queue.dequeue()();
680
- }
681
- })();
682
- };
683
- const generator = (fn, ...args) => new Promise((resolve) => {
684
- enqueue(fn, resolve, ...args);
685
- });
686
- Object.defineProperties(generator, {
687
- activeCount: {
688
- get: () => activeCount
689
- },
690
- pendingCount: {
691
- get: () => queue.size
692
- },
693
- clearQueue: {
694
- value: () => {
695
- queue.clear();
696
- }
697
- }
698
- });
699
- return generator;
700
- };
701
- module2.exports = pLimit2;
702
- }
703
- });
704
- var require_retry_operation = __commonJS2({
705
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports2, module2) {
706
- "use strict";
707
- function RetryOperation(timeouts, options) {
708
- if (typeof options === "boolean") {
709
- options = { forever: options };
710
- }
711
- this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
712
- this._timeouts = timeouts;
713
- this._options = options || {};
714
- this._maxRetryTime = options && options.maxRetryTime || Infinity;
715
- this._fn = null;
716
- this._errors = [];
717
- this._attempts = 1;
718
- this._operationTimeout = null;
719
- this._operationTimeoutCb = null;
720
- this._timeout = null;
721
- this._operationStart = null;
722
- this._timer = null;
723
- if (this._options.forever) {
724
- this._cachedTimeouts = this._timeouts.slice(0);
725
- }
726
- }
727
- module2.exports = RetryOperation;
728
- RetryOperation.prototype.reset = function() {
729
- this._attempts = 1;
730
- this._timeouts = this._originalTimeouts.slice(0);
731
- };
732
- RetryOperation.prototype.stop = function() {
733
- if (this._timeout) {
734
- clearTimeout(this._timeout);
735
- }
736
- if (this._timer) {
737
- clearTimeout(this._timer);
738
- }
739
- this._timeouts = [];
740
- this._cachedTimeouts = null;
741
- };
742
- RetryOperation.prototype.retry = function(err) {
743
- if (this._timeout) {
744
- clearTimeout(this._timeout);
745
- }
746
- if (!err) {
747
- return false;
748
- }
749
- var currentTime = (/* @__PURE__ */ new Date()).getTime();
750
- if (err && currentTime - this._operationStart >= this._maxRetryTime) {
751
- this._errors.push(err);
752
- this._errors.unshift(new Error("RetryOperation timeout occurred"));
753
- return false;
754
- }
755
- this._errors.push(err);
756
- var timeout = this._timeouts.shift();
757
- if (timeout === void 0) {
758
- if (this._cachedTimeouts) {
759
- this._errors.splice(0, this._errors.length - 1);
760
- timeout = this._cachedTimeouts.slice(-1);
761
- } else {
762
- return false;
763
- }
764
- }
765
- var self = this;
766
- this._timer = setTimeout(function() {
767
- self._attempts++;
768
- if (self._operationTimeoutCb) {
769
- self._timeout = setTimeout(function() {
770
- self._operationTimeoutCb(self._attempts);
771
- }, self._operationTimeout);
772
- if (self._options.unref) {
773
- self._timeout.unref();
774
- }
775
- }
776
- self._fn(self._attempts);
777
- }, timeout);
778
- if (this._options.unref) {
779
- this._timer.unref();
780
- }
781
- return true;
782
- };
783
- RetryOperation.prototype.attempt = function(fn, timeoutOps) {
784
- this._fn = fn;
785
- if (timeoutOps) {
786
- if (timeoutOps.timeout) {
787
- this._operationTimeout = timeoutOps.timeout;
788
- }
789
- if (timeoutOps.cb) {
790
- this._operationTimeoutCb = timeoutOps.cb;
791
- }
792
- }
793
- var self = this;
794
- if (this._operationTimeoutCb) {
795
- this._timeout = setTimeout(function() {
796
- self._operationTimeoutCb();
797
- }, self._operationTimeout);
798
- }
799
- this._operationStart = (/* @__PURE__ */ new Date()).getTime();
800
- this._fn(this._attempts);
801
- };
802
- RetryOperation.prototype.try = function(fn) {
803
- console.log("Using RetryOperation.try() is deprecated");
804
- this.attempt(fn);
805
- };
806
- RetryOperation.prototype.start = function(fn) {
807
- console.log("Using RetryOperation.start() is deprecated");
808
- this.attempt(fn);
809
- };
810
- RetryOperation.prototype.start = RetryOperation.prototype.try;
811
- RetryOperation.prototype.errors = function() {
812
- return this._errors;
813
- };
814
- RetryOperation.prototype.attempts = function() {
815
- return this._attempts;
816
- };
817
- RetryOperation.prototype.mainError = function() {
818
- if (this._errors.length === 0) {
819
- return null;
820
- }
821
- var counts = {};
822
- var mainError = null;
823
- var mainErrorCount = 0;
824
- for (var i = 0; i < this._errors.length; i++) {
825
- var error = this._errors[i];
826
- var message = error.message;
827
- var count = (counts[message] || 0) + 1;
828
- counts[message] = count;
829
- if (count >= mainErrorCount) {
830
- mainError = error;
831
- mainErrorCount = count;
832
- }
833
- }
834
- return mainError;
835
- };
777
+ /** Fetches all Signals for a project */
778
+ async get(options) {
779
+ const { projectId } = this.options;
780
+ const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6), { ...options, projectId });
781
+ return await this.apiClient(fetchUri);
836
782
  }
837
- });
838
- var require_retry = __commonJS2({
839
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports2) {
840
- "use strict";
841
- var RetryOperation = require_retry_operation();
842
- exports2.operation = function(options) {
843
- var timeouts = exports2.timeouts(options);
844
- return new RetryOperation(timeouts, {
845
- forever: options && (options.forever || options.retries === Infinity),
846
- unref: options && options.unref,
847
- maxRetryTime: options && options.maxRetryTime
848
- });
849
- };
850
- exports2.timeouts = function(options) {
851
- if (options instanceof Array) {
852
- return [].concat(options);
853
- }
854
- var opts = {
855
- retries: 10,
856
- factor: 2,
857
- minTimeout: 1 * 1e3,
858
- maxTimeout: Infinity,
859
- randomize: false
860
- };
861
- for (var key in options) {
862
- opts[key] = options[key];
863
- }
864
- if (opts.minTimeout > opts.maxTimeout) {
865
- throw new Error("minTimeout is greater than maxTimeout");
866
- }
867
- var timeouts = [];
868
- for (var i = 0; i < opts.retries; i++) {
869
- timeouts.push(this.createTimeout(i, opts));
870
- }
871
- if (options && options.forever && !timeouts.length) {
872
- timeouts.push(this.createTimeout(i, opts));
783
+ /** Updates or creates (based on id) a Signal */
784
+ async upsert(body) {
785
+ const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6));
786
+ await this.apiClient(fetchUri, {
787
+ method: "PUT",
788
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
789
+ expectNoContent: true
790
+ });
791
+ }
792
+ /** Deletes a Signal */
793
+ async remove(body) {
794
+ const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6));
795
+ await this.apiClient(fetchUri, {
796
+ method: "DELETE",
797
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
798
+ expectNoContent: true
799
+ });
800
+ }
801
+ };
802
+ _url6 = /* @__PURE__ */ new WeakMap();
803
+ __privateAdd2(_SignalClient, _url6, "/api/v2/signal");
804
+ var _url7;
805
+ var _TestClient = class _TestClient2 extends ApiClient {
806
+ constructor(options) {
807
+ super(options);
808
+ }
809
+ /** Fetches all Tests for a project */
810
+ async get(options) {
811
+ const { projectId } = this.options;
812
+ const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7), { ...options, projectId });
813
+ return await this.apiClient(fetchUri);
814
+ }
815
+ /** Updates or creates (based on id) a Test */
816
+ async upsert(body) {
817
+ const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7));
818
+ await this.apiClient(fetchUri, {
819
+ method: "PUT",
820
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
821
+ expectNoContent: true
822
+ });
823
+ }
824
+ /** Deletes a Test */
825
+ async remove(body) {
826
+ const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7));
827
+ await this.apiClient(fetchUri, {
828
+ method: "DELETE",
829
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
830
+ expectNoContent: true
831
+ });
832
+ }
833
+ };
834
+ _url7 = /* @__PURE__ */ new WeakMap();
835
+ __privateAdd2(_TestClient, _url7, "/api/v2/test");
836
+
837
+ // ../../node_modules/.pnpm/yocto-queue@1.2.2/node_modules/yocto-queue/index.js
838
+ var Node = class {
839
+ constructor(value) {
840
+ __publicField(this, "value");
841
+ __publicField(this, "next");
842
+ this.value = value;
843
+ }
844
+ };
845
+ var _head, _tail, _size;
846
+ var Queue = class {
847
+ constructor() {
848
+ __privateAdd(this, _head);
849
+ __privateAdd(this, _tail);
850
+ __privateAdd(this, _size);
851
+ this.clear();
852
+ }
853
+ enqueue(value) {
854
+ const node = new Node(value);
855
+ if (__privateGet(this, _head)) {
856
+ __privateGet(this, _tail).next = node;
857
+ __privateSet(this, _tail, node);
858
+ } else {
859
+ __privateSet(this, _head, node);
860
+ __privateSet(this, _tail, node);
861
+ }
862
+ __privateWrapper(this, _size)._++;
863
+ }
864
+ dequeue() {
865
+ const current = __privateGet(this, _head);
866
+ if (!current) {
867
+ return;
868
+ }
869
+ __privateSet(this, _head, __privateGet(this, _head).next);
870
+ __privateWrapper(this, _size)._--;
871
+ if (!__privateGet(this, _head)) {
872
+ __privateSet(this, _tail, void 0);
873
+ }
874
+ return current.value;
875
+ }
876
+ peek() {
877
+ if (!__privateGet(this, _head)) {
878
+ return;
879
+ }
880
+ return __privateGet(this, _head).value;
881
+ }
882
+ clear() {
883
+ __privateSet(this, _head, void 0);
884
+ __privateSet(this, _tail, void 0);
885
+ __privateSet(this, _size, 0);
886
+ }
887
+ get size() {
888
+ return __privateGet(this, _size);
889
+ }
890
+ *[Symbol.iterator]() {
891
+ let current = __privateGet(this, _head);
892
+ while (current) {
893
+ yield current.value;
894
+ current = current.next;
895
+ }
896
+ }
897
+ *drain() {
898
+ while (__privateGet(this, _head)) {
899
+ yield this.dequeue();
900
+ }
901
+ }
902
+ };
903
+ _head = new WeakMap();
904
+ _tail = new WeakMap();
905
+ _size = new WeakMap();
906
+
907
+ // ../../node_modules/.pnpm/p-limit@6.2.0/node_modules/p-limit/index.js
908
+ function pLimit2(concurrency) {
909
+ validateConcurrency(concurrency);
910
+ const queue = new Queue();
911
+ let activeCount = 0;
912
+ const resumeNext = () => {
913
+ if (activeCount < concurrency && queue.size > 0) {
914
+ queue.dequeue()();
915
+ activeCount++;
916
+ }
917
+ };
918
+ const next = () => {
919
+ activeCount--;
920
+ resumeNext();
921
+ };
922
+ const run = async (function_, resolve, arguments_) => {
923
+ const result = (async () => function_(...arguments_))();
924
+ resolve(result);
925
+ try {
926
+ await result;
927
+ } catch (e) {
928
+ }
929
+ next();
930
+ };
931
+ const enqueue = (function_, resolve, arguments_) => {
932
+ new Promise((internalResolve) => {
933
+ queue.enqueue(internalResolve);
934
+ }).then(
935
+ run.bind(void 0, function_, resolve, arguments_)
936
+ );
937
+ (async () => {
938
+ await Promise.resolve();
939
+ if (activeCount < concurrency) {
940
+ resumeNext();
873
941
  }
874
- timeouts.sort(function(a, b) {
875
- return a - b;
876
- });
877
- return timeouts;
878
- };
879
- exports2.createTimeout = function(attempt, opts) {
880
- var random = opts.randomize ? Math.random() + 1 : 1;
881
- var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
882
- timeout = Math.min(timeout, opts.maxTimeout);
883
- return timeout;
884
- };
885
- exports2.wrap = function(obj, options, methods) {
886
- if (options instanceof Array) {
887
- methods = options;
888
- options = null;
942
+ })();
943
+ };
944
+ const generator = (function_, ...arguments_) => new Promise((resolve) => {
945
+ enqueue(function_, resolve, arguments_);
946
+ });
947
+ Object.defineProperties(generator, {
948
+ activeCount: {
949
+ get: () => activeCount
950
+ },
951
+ pendingCount: {
952
+ get: () => queue.size
953
+ },
954
+ clearQueue: {
955
+ value() {
956
+ queue.clear();
889
957
  }
890
- if (!methods) {
891
- methods = [];
892
- for (var key in obj) {
893
- if (typeof obj[key] === "function") {
894
- methods.push(key);
958
+ },
959
+ concurrency: {
960
+ get: () => concurrency,
961
+ set(newConcurrency) {
962
+ validateConcurrency(newConcurrency);
963
+ concurrency = newConcurrency;
964
+ queueMicrotask(() => {
965
+ while (activeCount < concurrency && queue.size > 0) {
966
+ resumeNext();
895
967
  }
896
- }
897
- }
898
- for (var i = 0; i < methods.length; i++) {
899
- var method = methods[i];
900
- var original = obj[method];
901
- obj[method] = function retryWrapper(original2) {
902
- var op = exports2.operation(options);
903
- var args = Array.prototype.slice.call(arguments, 1);
904
- var callback = args.pop();
905
- args.push(function(err) {
906
- if (op.retry(err)) {
907
- return;
908
- }
909
- if (err) {
910
- arguments[0] = op.mainError();
911
- }
912
- callback.apply(this, arguments);
913
- });
914
- op.attempt(function() {
915
- original2.apply(obj, args);
916
- });
917
- }.bind(obj, original);
918
- obj[method].options = options;
968
+ });
919
969
  }
920
- };
921
- }
922
- });
923
- var require_retry2 = __commonJS2({
924
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports2, module2) {
925
- "use strict";
926
- module2.exports = require_retry();
970
+ }
971
+ });
972
+ return generator;
973
+ }
974
+ function validateConcurrency(concurrency) {
975
+ if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
976
+ throw new TypeError("Expected `concurrency` to be a number from 1 and up");
927
977
  }
928
- });
929
- var import_p_limit2 = __toESM2(require_p_limit2());
930
- var import_retry = __toESM2(require_retry2(), 1);
931
- var networkErrorMsgs = /* @__PURE__ */ new Set([
932
- "Failed to fetch",
978
+ }
979
+
980
+ // ../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
981
+ var import_retry = __toESM(require_retry2(), 1);
982
+
983
+ // ../../node_modules/.pnpm/is-network-error@1.3.2/node_modules/is-network-error/index.js
984
+ var objectToString = Object.prototype.toString;
985
+ var isError = (value) => objectToString.call(value) === "[object Error]";
986
+ var errorMessages = /* @__PURE__ */ new Set([
987
+ "network error",
933
988
  // Chrome
934
989
  "NetworkError when attempting to fetch resource.",
935
990
  // Firefox
936
991
  "The Internet connection appears to be offline.",
937
- // Safari
992
+ // Safari 16
938
993
  "Network request failed",
939
994
  // `cross-fetch`
940
- "fetch failed"
995
+ "fetch failed",
996
+ // Undici (Node.js)
997
+ "terminated",
941
998
  // Undici (Node.js)
999
+ " A network error occurred.",
1000
+ // Bun (WebKit)
1001
+ "Network connection lost"
1002
+ // Cloudflare Workers (fetch)
942
1003
  ]);
1004
+ function isNetworkError(error) {
1005
+ const isValid = error && isError(error) && error.name === "TypeError" && typeof error.message === "string";
1006
+ if (!isValid) {
1007
+ return false;
1008
+ }
1009
+ const { message, stack } = error;
1010
+ if (message === "Load failed" || message.startsWith("Load failed (") && message.endsWith(")")) {
1011
+ return stack === void 0 || "__sentry_captured__" in error;
1012
+ }
1013
+ if (message.startsWith("error sending request for url")) {
1014
+ return true;
1015
+ }
1016
+ if (message === "Failed to fetch" || message.startsWith("Failed to fetch (") && message.endsWith(")")) {
1017
+ return true;
1018
+ }
1019
+ return errorMessages.has(message);
1020
+ }
1021
+
1022
+ // ../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
943
1023
  var AbortError = class extends Error {
944
1024
  constructor(message) {
945
1025
  super();
@@ -960,63 +1040,71 @@ var decorateErrorWithCounts = (error, attemptNumber, options) => {
960
1040
  error.retriesLeft = retriesLeft;
961
1041
  return error;
962
1042
  };
963
- var isNetworkError = (errorMessage) => networkErrorMsgs.has(errorMessage);
964
- var getDOMException = (errorMessage) => globalThis.DOMException === void 0 ? new Error(errorMessage) : new DOMException(errorMessage);
965
1043
  async function pRetry(input, options) {
966
1044
  return new Promise((resolve, reject) => {
967
- options = {
968
- onFailedAttempt() {
969
- },
970
- retries: 10,
971
- ...options
1045
+ var _a, _b, _c;
1046
+ options = { ...options };
1047
+ (_a = options.onFailedAttempt) != null ? _a : options.onFailedAttempt = () => {
972
1048
  };
1049
+ (_b = options.shouldRetry) != null ? _b : options.shouldRetry = () => true;
1050
+ (_c = options.retries) != null ? _c : options.retries = 10;
973
1051
  const operation = import_retry.default.operation(options);
1052
+ const abortHandler = () => {
1053
+ var _a2;
1054
+ operation.stop();
1055
+ reject((_a2 = options.signal) == null ? void 0 : _a2.reason);
1056
+ };
1057
+ if (options.signal && !options.signal.aborted) {
1058
+ options.signal.addEventListener("abort", abortHandler, { once: true });
1059
+ }
1060
+ const cleanUp = () => {
1061
+ var _a2;
1062
+ (_a2 = options.signal) == null ? void 0 : _a2.removeEventListener("abort", abortHandler);
1063
+ operation.stop();
1064
+ };
974
1065
  operation.attempt(async (attemptNumber) => {
975
1066
  try {
976
- resolve(await input(attemptNumber));
1067
+ const result = await input(attemptNumber);
1068
+ cleanUp();
1069
+ resolve(result);
977
1070
  } catch (error) {
978
- if (!(error instanceof Error)) {
979
- reject(new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`));
980
- return;
981
- }
982
- if (error instanceof AbortError) {
983
- operation.stop();
984
- reject(error.originalError);
985
- } else if (error instanceof TypeError && !isNetworkError(error.message)) {
986
- operation.stop();
987
- reject(error);
988
- } else {
1071
+ try {
1072
+ if (!(error instanceof Error)) {
1073
+ throw new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
1074
+ }
1075
+ if (error instanceof AbortError) {
1076
+ throw error.originalError;
1077
+ }
1078
+ if (error instanceof TypeError && !isNetworkError(error)) {
1079
+ throw error;
1080
+ }
989
1081
  decorateErrorWithCounts(error, attemptNumber, options);
990
- try {
991
- await options.onFailedAttempt(error);
992
- } catch (error2) {
993
- reject(error2);
994
- return;
1082
+ if (!await options.shouldRetry(error)) {
1083
+ operation.stop();
1084
+ reject(error);
995
1085
  }
1086
+ await options.onFailedAttempt(error);
996
1087
  if (!operation.retry(error)) {
997
- reject(operation.mainError());
1088
+ throw operation.mainError();
998
1089
  }
1090
+ } catch (finalError) {
1091
+ decorateErrorWithCounts(finalError, attemptNumber, options);
1092
+ cleanUp();
1093
+ reject(finalError);
999
1094
  }
1000
1095
  }
1001
1096
  });
1002
- if (options.signal && !options.signal.aborted) {
1003
- options.signal.addEventListener("abort", () => {
1004
- operation.stop();
1005
- const reason = options.signal.reason === void 0 ? getDOMException("The operation was aborted.") : options.signal.reason;
1006
- reject(reason instanceof Error ? reason : getDOMException(reason));
1007
- }, {
1008
- once: true
1009
- });
1010
- }
1011
1097
  });
1012
1098
  }
1099
+
1100
+ // ../../node_modules/.pnpm/p-throttle@6.2.0/node_modules/p-throttle/index.js
1013
1101
  var AbortError2 = class extends Error {
1014
1102
  constructor() {
1015
1103
  super("Throttled function aborted");
1016
1104
  this.name = "AbortError";
1017
1105
  }
1018
1106
  };
1019
- function pThrottle({ limit, interval, strict }) {
1107
+ function pThrottle({ limit, interval, strict, onDelay }) {
1020
1108
  if (!Number.isFinite(limit)) {
1021
1109
  throw new TypeError("Expected `limit` to be a finite number");
1022
1110
  }
@@ -1044,32 +1132,38 @@ function pThrottle({ limit, interval, strict }) {
1044
1132
  const strictTicks = [];
1045
1133
  function strictDelay() {
1046
1134
  const now = Date.now();
1047
- if (strictTicks.length < limit) {
1048
- strictTicks.push(now);
1049
- return 0;
1135
+ if (strictTicks.length > 0 && now - strictTicks.at(-1) > interval) {
1136
+ strictTicks.length = 0;
1050
1137
  }
1051
- const earliestTime = strictTicks.shift() + interval;
1052
- if (now >= earliestTime) {
1138
+ if (strictTicks.length < limit) {
1053
1139
  strictTicks.push(now);
1054
1140
  return 0;
1055
1141
  }
1056
- strictTicks.push(earliestTime);
1057
- return earliestTime - now;
1142
+ const nextExecutionTime = strictTicks[0] + interval;
1143
+ strictTicks.shift();
1144
+ strictTicks.push(nextExecutionTime);
1145
+ return Math.max(0, nextExecutionTime - now);
1058
1146
  }
1059
1147
  const getDelay = strict ? strictDelay : windowedDelay;
1060
1148
  return (function_) => {
1061
- const throttled = function(...args) {
1149
+ const throttled = function(...arguments_) {
1062
1150
  if (!throttled.isEnabled) {
1063
- return (async () => function_.apply(this, args))();
1151
+ return (async () => function_.apply(this, arguments_))();
1064
1152
  }
1065
- let timeout;
1153
+ let timeoutId;
1066
1154
  return new Promise((resolve, reject) => {
1067
1155
  const execute = () => {
1068
- resolve(function_.apply(this, args));
1069
- queue.delete(timeout);
1156
+ resolve(function_.apply(this, arguments_));
1157
+ queue.delete(timeoutId);
1070
1158
  };
1071
- timeout = setTimeout(execute, getDelay());
1072
- queue.set(timeout, reject);
1159
+ const delay = getDelay();
1160
+ if (delay > 0) {
1161
+ timeoutId = setTimeout(execute, delay);
1162
+ queue.set(timeoutId, reject);
1163
+ onDelay == null ? void 0 : onDelay(...arguments_);
1164
+ } else {
1165
+ execute();
1166
+ }
1073
1167
  });
1074
1168
  };
1075
1169
  throttled.abort = () => {
@@ -1081,16 +1175,29 @@ function pThrottle({ limit, interval, strict }) {
1081
1175
  strictTicks.splice(0, strictTicks.length);
1082
1176
  };
1083
1177
  throttled.isEnabled = true;
1178
+ Object.defineProperty(throttled, "queueSize", {
1179
+ get() {
1180
+ return queue.size;
1181
+ }
1182
+ });
1084
1183
  return throttled;
1085
1184
  };
1086
1185
  }
1186
+
1187
+ // ../canvas/dist/index.mjs
1188
+ var __typeError3 = (msg) => {
1189
+ throw TypeError(msg);
1190
+ };
1191
+ var __accessCheck3 = (obj, member, msg) => member.has(obj) || __typeError3("Cannot " + msg);
1192
+ var __privateGet3 = (obj, member, getter) => (__accessCheck3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1193
+ 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);
1087
1194
  function createLimitPolicy({
1088
1195
  throttle = { interval: 1e3, limit: 10 },
1089
- retry: retry2 = { retries: 1, factor: 1.66 },
1196
+ retry: retry3 = { retries: 1, factor: 1.66 },
1090
1197
  limit = 10
1091
1198
  }) {
1092
1199
  const throttler = throttle ? pThrottle(throttle) : null;
1093
- const limiter = limit ? (0, import_p_limit2.default)(limit) : null;
1200
+ const limiter = limit ? pLimit2(limit) : null;
1094
1201
  return function limitPolicy(func) {
1095
1202
  let currentFunc = async () => await func();
1096
1203
  if (throttler) {
@@ -1101,13 +1208,13 @@ function createLimitPolicy({
1101
1208
  const limitFunc = currentFunc;
1102
1209
  currentFunc = () => limiter(limitFunc);
1103
1210
  }
1104
- if (retry2) {
1211
+ if (retry3) {
1105
1212
  const retryFunc = currentFunc;
1106
1213
  currentFunc = () => pRetry(retryFunc, {
1107
- ...retry2,
1214
+ ...retry3,
1108
1215
  onFailedAttempt: async (error) => {
1109
- if (retry2.onFailedAttempt) {
1110
- await retry2.onFailedAttempt(error);
1216
+ if (retry3.onFailedAttempt) {
1217
+ await retry3.onFailedAttempt(error);
1111
1218
  }
1112
1219
  if (error instanceof ApiClientError && typeof error.statusCode === "number" && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429 && error.statusCode !== 408) {
1113
1220
  throw error;
@@ -1118,19 +1225,49 @@ function createLimitPolicy({
1118
1225
  return currentFunc();
1119
1226
  };
1120
1227
  }
1121
- var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
1122
- function rewriteFilters(filters) {
1123
- return Object.entries(filters != null ? filters : {}).reduce(
1124
- (acc, [key, value]) => {
1125
- const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
1126
- const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
1127
- return {
1128
- ...acc,
1129
- [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
1130
- };
1131
- },
1132
- {}
1133
- );
1228
+ var SELECT_QUERY_PREFIX = "select.";
1229
+ function appendCsv(out, key, values) {
1230
+ if (values === void 0) {
1231
+ return;
1232
+ }
1233
+ out[key] = values.join(",");
1234
+ }
1235
+ function projectionToQuery(spec) {
1236
+ const out = {};
1237
+ if (!spec) {
1238
+ return out;
1239
+ }
1240
+ const { fields, fieldTypes, slots } = spec;
1241
+ const p = SELECT_QUERY_PREFIX;
1242
+ if (fields) {
1243
+ appendCsv(out, `${p}fields[only]`, fields.only);
1244
+ appendCsv(out, `${p}fields[except]`, fields.except);
1245
+ appendCsv(out, `${p}fields[locales]`, fields.locales);
1246
+ if (fields.blockDepth === "preserveAll" || typeof fields.blockDepth === "number") {
1247
+ out[`${p}fields[blockDepth]`] = String(fields.blockDepth);
1248
+ }
1249
+ }
1250
+ if (fieldTypes) {
1251
+ appendCsv(out, `${p}fieldTypes[only]`, fieldTypes.only);
1252
+ appendCsv(out, `${p}fieldTypes[except]`, fieldTypes.except);
1253
+ }
1254
+ if (slots) {
1255
+ appendCsv(out, `${p}slots[only]`, slots.only);
1256
+ appendCsv(out, `${p}slots[except]`, slots.except);
1257
+ if (typeof slots.depth === "number") {
1258
+ out[`${p}slots[depth]`] = String(slots.depth);
1259
+ }
1260
+ if (slots.named) {
1261
+ const slotNames = Object.keys(slots.named).sort();
1262
+ for (const slotName of slotNames) {
1263
+ const named = slots.named[slotName];
1264
+ if (named && typeof named.depth === "number") {
1265
+ out[`${p}slots.${slotName}[depth]`] = String(named.depth);
1266
+ }
1267
+ }
1268
+ }
1269
+ }
1270
+ return out;
1134
1271
  }
1135
1272
  var _contentTypesUrl;
1136
1273
  var _entriesUrl;
@@ -1142,20 +1279,26 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1142
1279
  }
1143
1280
  getContentTypes(options) {
1144
1281
  const { projectId } = this.options;
1145
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl), { ...options, projectId });
1282
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _contentTypesUrl), { ...options, projectId });
1146
1283
  return this.apiClient(fetchUri);
1147
1284
  }
1148
1285
  getEntries(options) {
1149
1286
  const { projectId } = this.options;
1150
- const { skipDataResolution, filters, ...params } = options;
1151
- const rewrittenFilters = rewriteFilters(filters);
1287
+ const { skipDataResolution, filters, select, ...params } = options;
1288
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1289
+ const rewrittenSelect = projectionToQuery(select);
1152
1290
  if (skipDataResolution) {
1153
- const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
1291
+ const url = this.createUrl(__privateGet3(_ContentClient2, _entriesUrl), {
1292
+ ...params,
1293
+ ...rewrittenFilters,
1294
+ ...rewrittenSelect,
1295
+ projectId
1296
+ });
1154
1297
  return this.apiClient(url);
1155
1298
  }
1156
1299
  const edgeUrl = this.createUrl(
1157
- __privateGet2(_ContentClient2, _entriesUrl),
1158
- { ...this.getEdgeOptions(params), ...rewrittenFilters },
1300
+ __privateGet3(_ContentClient2, _entriesUrl),
1301
+ { ...this.getEdgeOptions(params), ...rewrittenFilters, ...rewrittenSelect },
1159
1302
  this.edgeApiHost
1160
1303
  );
1161
1304
  return this.apiClient(
@@ -1172,7 +1315,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1172
1315
  return this.apiClient(historyUrl);
1173
1316
  }
1174
1317
  async upsertContentType(body, opts = {}) {
1175
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl));
1318
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _contentTypesUrl));
1176
1319
  if (typeof body.contentType.slugSettings === "object" && body.contentType.slugSettings !== null && Object.keys(body.contentType.slugSettings).length === 0) {
1177
1320
  delete body.contentType.slugSettings;
1178
1321
  }
@@ -1184,7 +1327,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1184
1327
  });
1185
1328
  }
1186
1329
  async upsertEntry(body, options) {
1187
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl));
1330
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _entriesUrl));
1188
1331
  const headers = {};
1189
1332
  if (options == null ? void 0 : options.ifUnmodifiedSince) {
1190
1333
  headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
@@ -1198,7 +1341,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1198
1341
  return { modified: response.headers.get("x-modified-at") };
1199
1342
  }
1200
1343
  async deleteContentType(body) {
1201
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl));
1344
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _contentTypesUrl));
1202
1345
  await this.apiClient(fetchUri, {
1203
1346
  method: "DELETE",
1204
1347
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1206,7 +1349,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1206
1349
  });
1207
1350
  }
1208
1351
  async deleteEntry(body) {
1209
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl));
1352
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _entriesUrl));
1210
1353
  await this.apiClient(fetchUri, {
1211
1354
  method: "DELETE",
1212
1355
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1225,8 +1368,8 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1225
1368
  };
1226
1369
  _contentTypesUrl = /* @__PURE__ */ new WeakMap();
1227
1370
  _entriesUrl = /* @__PURE__ */ new WeakMap();
1228
- __privateAdd2(_ContentClient, _contentTypesUrl, "/api/v1/content-types");
1229
- __privateAdd2(_ContentClient, _entriesUrl, "/api/v1/entries");
1371
+ __privateAdd3(_ContentClient, _contentTypesUrl, "/api/v1/content-types");
1372
+ __privateAdd3(_ContentClient, _entriesUrl, "/api/v1/entries");
1230
1373
  var _url8;
1231
1374
  var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1232
1375
  constructor(options) {
@@ -1235,12 +1378,12 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1235
1378
  /** Fetches all DataTypes for a project */
1236
1379
  async get(options) {
1237
1380
  const { projectId } = this.options;
1238
- const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8), { ...options, projectId });
1381
+ const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8), { ...options, projectId });
1239
1382
  return await this.apiClient(fetchUri);
1240
1383
  }
1241
1384
  /** Updates or creates (based on id) a DataType */
1242
1385
  async upsert(body) {
1243
- const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8));
1386
+ const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
1244
1387
  await this.apiClient(fetchUri, {
1245
1388
  method: "PUT",
1246
1389
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1249,7 +1392,7 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1249
1392
  }
1250
1393
  /** Deletes a DataType */
1251
1394
  async remove(body) {
1252
- const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8));
1395
+ const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
1253
1396
  await this.apiClient(fetchUri, {
1254
1397
  method: "DELETE",
1255
1398
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1258,7 +1401,7 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1258
1401
  }
1259
1402
  };
1260
1403
  _url8 = /* @__PURE__ */ new WeakMap();
1261
- __privateAdd2(_DataTypeClient, _url8, "/api/v1/data-types");
1404
+ __privateAdd3(_DataTypeClient, _url8, "/api/v1/data-types");
1262
1405
  var CANVAS_DRAFT_STATE = 0;
1263
1406
  var CANVAS_PUBLISHED_STATE = 64;
1264
1407
  var CANVAS_EDITOR_STATE = 63;
@@ -1277,7 +1420,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1277
1420
  * Gets a list of property type and hook names for the current team, including public integrations' hooks.
1278
1421
  */
1279
1422
  get(options) {
1280
- const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl), {
1423
+ const fetchUri = this.createUrl(__privateGet3(_IntegrationPropertyEditorsClient2, _baseUrl), {
1281
1424
  ...options,
1282
1425
  teamId: this.teamId
1283
1426
  });
@@ -1287,7 +1430,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1287
1430
  * Creates or updates a custom AI property editor on a Mesh app.
1288
1431
  */
1289
1432
  async deploy(body) {
1290
- const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl));
1433
+ const fetchUri = this.createUrl(__privateGet3(_IntegrationPropertyEditorsClient2, _baseUrl));
1291
1434
  await this.apiClient(fetchUri, {
1292
1435
  method: "PUT",
1293
1436
  body: JSON.stringify({ ...body, teamId: this.teamId }),
@@ -1298,7 +1441,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1298
1441
  * Removes a custom AI property editor from a Mesh app.
1299
1442
  */
1300
1443
  async delete(body) {
1301
- const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl));
1444
+ const fetchUri = this.createUrl(__privateGet3(_IntegrationPropertyEditorsClient2, _baseUrl));
1302
1445
  await this.apiClient(fetchUri, {
1303
1446
  method: "DELETE",
1304
1447
  body: JSON.stringify({ ...body, teamId: this.teamId }),
@@ -1307,20 +1450,30 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1307
1450
  }
1308
1451
  };
1309
1452
  _baseUrl = /* @__PURE__ */ new WeakMap();
1310
- __privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
1453
+ __privateAdd3(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
1311
1454
  var _url22;
1455
+ var _projectsUrl;
1312
1456
  var _ProjectClient = class _ProjectClient2 extends ApiClient {
1313
1457
  constructor(options) {
1314
1458
  super({ ...options, bypassCache: true });
1315
1459
  }
1316
1460
  /** Fetches single Project */
1317
1461
  async get(options) {
1318
- const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22), { ...options });
1462
+ const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22), { ...options });
1463
+ return await this.apiClient(fetchUri);
1464
+ }
1465
+ /**
1466
+ * Fetches projects grouped by team.
1467
+ * When teamId is provided, returns a single team with its projects.
1468
+ * When omitted, returns all accessible teams and their projects.
1469
+ */
1470
+ async getProjects(options) {
1471
+ const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
1319
1472
  return await this.apiClient(fetchUri);
1320
1473
  }
1321
1474
  /** Updates or creates (based on id) a Project */
1322
1475
  async upsert(body) {
1323
- const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
1476
+ const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
1324
1477
  return await this.apiClient(fetchUri, {
1325
1478
  method: "PUT",
1326
1479
  body: JSON.stringify({ ...body })
@@ -1328,7 +1481,7 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1328
1481
  }
1329
1482
  /** Deletes a Project */
1330
1483
  async delete(body) {
1331
- const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
1484
+ const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
1332
1485
  await this.apiClient(fetchUri, {
1333
1486
  method: "DELETE",
1334
1487
  body: JSON.stringify({ ...body }),
@@ -1337,7 +1490,9 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1337
1490
  }
1338
1491
  };
1339
1492
  _url22 = /* @__PURE__ */ new WeakMap();
1340
- __privateAdd2(_ProjectClient, _url22, "/api/v1/project");
1493
+ _projectsUrl = /* @__PURE__ */ new WeakMap();
1494
+ __privateAdd3(_ProjectClient, _url22, "/api/v1/project");
1495
+ __privateAdd3(_ProjectClient, _projectsUrl, "/api/v1/projects");
1341
1496
  var ROUTE_URL = "/api/v1/route";
1342
1497
  var RouteClient = class extends ApiClient {
1343
1498
  constructor(options) {
@@ -1351,13 +1506,26 @@ var RouteClient = class extends ApiClient {
1351
1506
  /** Fetches lists of Canvas compositions, optionally by type */
1352
1507
  async getRoute(options) {
1353
1508
  const { projectId } = this.options;
1354
- const fetchUri = this.createUrl(ROUTE_URL, { ...options, projectId }, this.edgeApiHost);
1509
+ const { select, ...rest } = options != null ? options : {};
1510
+ const rewrittenSelect = projectionToQuery(select);
1511
+ const fetchUri = this.createUrl(ROUTE_URL, { ...rest, projectId, ...rewrittenSelect }, this.edgeApiHost);
1355
1512
  return await this.apiClient(
1356
1513
  fetchUri,
1357
1514
  this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
1358
1515
  );
1359
1516
  }
1360
1517
  };
1518
+ var getDataSourceVariantFromRouteGetParams = (params, defaultPreviewState) => {
1519
+ var _a, _b;
1520
+ const dataSourceVariant = (
1521
+ // support explicit 'undefined' as a way to opt out of data resources variant
1522
+ "dataSourceVariant" in params ? params.dataSourceVariant : (
1523
+ // in case of DRAFT state we still want to fetch unpublished data
1524
+ ((_b = (_a = params == null ? void 0 : params.state) != null ? _a : defaultPreviewState) != null ? _b : CANVAS_PUBLISHED_STATE) !== CANVAS_PUBLISHED_STATE ? "unpublished" : void 0
1525
+ )
1526
+ );
1527
+ return dataSourceVariant;
1528
+ };
1361
1529
 
1362
1530
  // src/data/client.ts
1363
1531
  var import_functions = require("@vercel/functions");
@@ -1400,8 +1568,15 @@ var isIncontextEditingEnabled = ({
1400
1568
  var isDevelopmentEnvironment = () => {
1401
1569
  return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
1402
1570
  };
1571
+ var shouldIgnoreRedirects = ({ state }) => {
1572
+ const isNotPublished = state !== CANVAS_PUBLISHED_STATE;
1573
+ return isNotPublished ? true : void 0;
1574
+ };
1403
1575
 
1404
1576
  // src/clients/cache.ts
1577
+ var isSpecificCacheMode = (options) => {
1578
+ return "cache" in options;
1579
+ };
1405
1580
  var isStateCacheMode = (options) => {
1406
1581
  return "state" in options;
1407
1582
  };
@@ -1423,7 +1598,9 @@ var resolveCache = ({
1423
1598
  }) => {
1424
1599
  let cache = void 0;
1425
1600
  if (options) {
1426
- if (isStateCacheMode(options)) {
1601
+ if (isSpecificCacheMode(options)) {
1602
+ cache = options.cache;
1603
+ } else if (isStateCacheMode(options)) {
1427
1604
  if (options.state === CANVAS_DRAFT_STATE || options.state === CANVAS_EDITOR_STATE) {
1428
1605
  cache = {
1429
1606
  type: "no-cache",
@@ -1542,7 +1719,7 @@ function createLimiter(concurrency) {
1542
1719
  });
1543
1720
  };
1544
1721
  }
1545
- async function retry(fn, options) {
1722
+ async function retry2(fn, options) {
1546
1723
  let lastError;
1547
1724
  let delay = 1e3;
1548
1725
  for (let attempt = 1; attempt <= options.retries + 1; attempt++) {
@@ -1582,7 +1759,7 @@ function createLimitPolicy2({
1582
1759
  }
1583
1760
  if (retryOptions) {
1584
1761
  const retryFunc = currentFunc;
1585
- currentFunc = () => retry(retryFunc, {
1762
+ currentFunc = () => retry2(retryFunc, {
1586
1763
  ...retryOptions,
1587
1764
  onFailedAttempt: async (error) => {
1588
1765
  if (retryOptions.onFailedAttempt) {
@@ -1715,6 +1892,9 @@ var getRouteClient = (options) => {
1715
1892
  // src/config/helpers.ts
1716
1893
  var import_resolved = __toESM(require("@uniformdev/next-app-router/config/resolved"));
1717
1894
  var getMiddlewareRuntimeCache = () => {
1895
+ if (process.env.NODE_ENV === "development" && !process.env.RUNTIME_CACHE_ENDPOINT) {
1896
+ return false;
1897
+ }
1718
1898
  if (typeof import_resolved.default.middlewareRuntimeCache === "boolean") {
1719
1899
  return import_resolved.default.middlewareRuntimeCache;
1720
1900
  }
@@ -1740,7 +1920,10 @@ var DefaultDataClient = class {
1740
1920
  }
1741
1921
  }
1742
1922
  const manifest = await getManifest({
1743
- cache: {
1923
+ cache: isDevelopmentEnvironment() ? {
1924
+ type: "no-cache",
1925
+ bypassCache: true
1926
+ } : {
1744
1927
  type: "force-cache"
1745
1928
  }
1746
1929
  });
@@ -1843,20 +2026,23 @@ var DefaultDataClient = class {
1843
2026
  };
1844
2027
  }
1845
2028
  async getRoutePageState(options) {
2029
+ const shouldBypassCache = options.pageState.compositionState !== CANVAS_PUBLISHED_STATE || isDevelopmentEnvironment();
1846
2030
  const routeClient = getRouteClient({
1847
- cache: options.pageState.compositionState === CANVAS_PUBLISHED_STATE ? {
1848
- type: "force-cache"
1849
- } : {
2031
+ cache: shouldBypassCache ? {
1850
2032
  type: "no-cache",
1851
2033
  bypassCache: true
2034
+ } : {
2035
+ type: "force-cache"
1852
2036
  }
1853
2037
  });
1854
2038
  const originalRoute = {
1855
2039
  path: options.pageState.routePath,
1856
2040
  state: options.pageState.compositionState,
2041
+ dataSourceVariant: getDataSourceVariantFromRouteGetParams({}, options.pageState.compositionState),
1857
2042
  withComponentIDs: true,
1858
2043
  releaseId: options.pageState.releaseId,
1859
- locale: options.pageState.locale
2044
+ locale: options.pageState.locale,
2045
+ ignoreRedirects: shouldIgnoreRedirects({ state: options.pageState.compositionState })
1860
2046
  };
1861
2047
  const resolvedRoute = await this.getRouteFromApi({
1862
2048
  source: "pageState",