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

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