@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/handler.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,40 +155,278 @@ 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
 
145
393
  // ../context/dist/api/api.mjs
146
394
  var import_p_limit = __toESM(require_p_limit(), 1);
147
395
  var __defProp2 = Object.defineProperty;
148
- var __typeError = (msg) => {
396
+ var __typeError2 = (msg) => {
149
397
  throw TypeError(msg);
150
398
  };
151
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
152
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
153
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
154
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
155
- 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);
399
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
400
+ var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
401
+ var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
402
+ var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
403
+ 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);
156
404
  var defaultLimitPolicy = (0, import_p_limit.default)(6);
405
+ var UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE = "Bearer token not valid or expired";
157
406
  var ApiClientError = class _ApiClientError extends Error {
158
407
  constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
159
408
  super(
160
409
  `${errorMessage}
161
410
  ${statusCode}${statusText ? " " + statusText : ""} (${fetchMethod} ${fetchUri}${requestId ? ` Request ID: ${requestId}` : ""})`
162
411
  );
163
- this.errorMessage = errorMessage;
164
- this.fetchMethod = fetchMethod;
165
- this.fetchUri = fetchUri;
166
- this.statusCode = statusCode;
167
- this.statusText = statusText;
168
- this.requestId = requestId;
412
+ __publicField2(this, "errorMessage", errorMessage);
413
+ __publicField2(this, "fetchMethod", fetchMethod);
414
+ __publicField2(this, "fetchUri", fetchUri);
415
+ __publicField2(this, "statusCode", statusCode);
416
+ __publicField2(this, "statusText", statusText);
417
+ __publicField2(this, "requestId", requestId);
169
418
  Object.setPrototypeOf(this, _ApiClientError.prototype);
170
419
  }
171
420
  };
421
+ var BearerTokenNotValidOrExpiredError = class _BearerTokenNotValidOrExpiredError extends ApiClientError {
422
+ constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
423
+ super(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId);
424
+ Object.setPrototypeOf(this, _BearerTokenNotValidOrExpiredError.prototype);
425
+ }
426
+ };
172
427
  var ApiClient = class _ApiClient {
173
428
  constructor(options) {
174
- __publicField(this, "options");
429
+ __publicField2(this, "options");
175
430
  var _a, _b, _c, _d, _e;
176
431
  if (!options.apiKey && !options.bearerToken) {
177
432
  throw new Error("You must provide an API key or a bearer token");
@@ -202,7 +457,7 @@ var ApiClient = class _ApiClient {
202
457
  }
203
458
  async apiClientWithResponse(fetchUri, options) {
204
459
  return this.options.limitPolicy(async () => {
205
- var _a;
460
+ var _a, _b;
206
461
  const coreHeaders = this.options.apiKey ? {
207
462
  "x-api-key": this.options.apiKey
208
463
  } : {
@@ -238,9 +493,19 @@ var ApiClient = class _ApiClient {
238
493
  } catch (e) {
239
494
  message = `General error`;
240
495
  }
496
+ if (apiResponse.status === 401 && message === UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE) {
497
+ throw new BearerTokenNotValidOrExpiredError(
498
+ message,
499
+ (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
500
+ fetchUri.toString(),
501
+ apiResponse.status,
502
+ apiResponse.statusText,
503
+ _ApiClient.getRequestId(apiResponse)
504
+ );
505
+ }
241
506
  throw new ApiClientError(
242
507
  message,
243
- (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
508
+ (_b = options == null ? void 0 : options.method) != null ? _b : "GET",
244
509
  fetchUri.toString(),
245
510
  apiResponse.status,
246
511
  apiResponse.statusText,
@@ -314,25 +579,39 @@ async function handleRateLimits(callApi) {
314
579
  }
315
580
  const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
316
581
  const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
317
- await new Promise((resolve) => setTimeout(resolve, resetWait + backoffWait));
582
+ await new Promise((resolve) => setTimeout(resolve, Math.max(0, resetWait + backoffWait)));
318
583
  backoffRetriesLeft -= 1;
319
584
  }
320
585
  return response;
321
586
  }
322
- var _url;
323
- var _AggregateClient = class _AggregateClient2 extends ApiClient {
324
- constructor(options) {
325
- super(options);
326
- }
327
- /** Fetches all aggregates for a project */
328
- async get(options) {
587
+ var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
588
+ function rewriteFiltersForApi(filters) {
589
+ return Object.entries(filters != null ? filters : {}).reduce(
590
+ (acc, [key, value]) => {
591
+ const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
592
+ const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
593
+ return {
594
+ ...acc,
595
+ [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
596
+ };
597
+ },
598
+ {}
599
+ );
600
+ }
601
+ var _url;
602
+ var _AggregateClient = class _AggregateClient2 extends ApiClient {
603
+ constructor(options) {
604
+ super(options);
605
+ }
606
+ /** Fetches all aggregates for a project */
607
+ async get(options) {
329
608
  const { projectId } = this.options;
330
- const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url), { ...options, projectId });
609
+ const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url), { ...options, projectId });
331
610
  return await this.apiClient(fetchUri);
332
611
  }
333
612
  /** Updates or creates (based on id) an Aggregate */
334
613
  async upsert(body) {
335
- const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url));
614
+ const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url));
336
615
  await this.apiClient(fetchUri, {
337
616
  method: "PUT",
338
617
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -341,7 +620,7 @@ var _AggregateClient = class _AggregateClient2 extends ApiClient {
341
620
  }
342
621
  /** Deletes an Aggregate */
343
622
  async remove(body) {
344
- const fetchUri = this.createUrl(__privateGet(_AggregateClient2, _url));
623
+ const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url));
345
624
  await this.apiClient(fetchUri, {
346
625
  method: "DELETE",
347
626
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -350,7 +629,7 @@ var _AggregateClient = class _AggregateClient2 extends ApiClient {
350
629
  }
351
630
  };
352
631
  _url = /* @__PURE__ */ new WeakMap();
353
- __privateAdd(_AggregateClient, _url, "/api/v2/aggregate");
632
+ __privateAdd2(_AggregateClient, _url, "/api/v2/aggregate");
354
633
  var _url2;
355
634
  var _DimensionClient = class _DimensionClient2 extends ApiClient {
356
635
  constructor(options) {
@@ -359,12 +638,12 @@ var _DimensionClient = class _DimensionClient2 extends ApiClient {
359
638
  /** Fetches the known score dimensions for a project */
360
639
  async get(options) {
361
640
  const { projectId } = this.options;
362
- const fetchUri = this.createUrl(__privateGet(_DimensionClient2, _url2), { ...options, projectId });
641
+ const fetchUri = this.createUrl(__privateGet2(_DimensionClient2, _url2), { ...options, projectId });
363
642
  return await this.apiClient(fetchUri);
364
643
  }
365
644
  };
366
645
  _url2 = /* @__PURE__ */ new WeakMap();
367
- __privateAdd(_DimensionClient, _url2, "/api/v2/dimension");
646
+ __privateAdd2(_DimensionClient, _url2, "/api/v2/dimension");
368
647
  var _url3;
369
648
  var _valueUrl;
370
649
  var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
@@ -374,12 +653,12 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
374
653
  /** Fetches all enrichments and values for a project, grouped by category */
375
654
  async get(options) {
376
655
  const { projectId } = this.options;
377
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3), { ...options, projectId });
656
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3), { ...options, projectId });
378
657
  return await this.apiClient(fetchUri);
379
658
  }
380
659
  /** Updates or creates (based on id) an enrichment category */
381
660
  async upsertCategory(body) {
382
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3));
661
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3));
383
662
  await this.apiClient(fetchUri, {
384
663
  method: "PUT",
385
664
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -388,7 +667,7 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
388
667
  }
389
668
  /** Deletes an enrichment category */
390
669
  async removeCategory(body) {
391
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _url3));
670
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3));
392
671
  await this.apiClient(fetchUri, {
393
672
  method: "DELETE",
394
673
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -397,7 +676,7 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
397
676
  }
398
677
  /** Updates or creates (based on id) an enrichment value within an enrichment category */
399
678
  async upsertValue(body) {
400
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _valueUrl));
679
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _valueUrl));
401
680
  await this.apiClient(fetchUri, {
402
681
  method: "PUT",
403
682
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -406,7 +685,7 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
406
685
  }
407
686
  /** Deletes an enrichment value within an enrichment category. The category is left alone. */
408
687
  async removeValue(body) {
409
- const fetchUri = this.createUrl(__privateGet(_EnrichmentClient2, _valueUrl));
688
+ const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _valueUrl));
410
689
  await this.apiClient(fetchUri, {
411
690
  method: "DELETE",
412
691
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -416,8 +695,8 @@ var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
416
695
  };
417
696
  _url3 = /* @__PURE__ */ new WeakMap();
418
697
  _valueUrl = /* @__PURE__ */ new WeakMap();
419
- __privateAdd(_EnrichmentClient, _url3, "/api/v1/enrichments");
420
- __privateAdd(_EnrichmentClient, _valueUrl, "/api/v1/enrichment-values");
698
+ __privateAdd2(_EnrichmentClient, _url3, "/api/v1/enrichments");
699
+ __privateAdd2(_EnrichmentClient, _valueUrl, "/api/v1/enrichment-values");
421
700
  var _url4;
422
701
  var _ManifestClient = class _ManifestClient2 extends ApiClient {
423
702
  constructor(options) {
@@ -426,7 +705,7 @@ var _ManifestClient = class _ManifestClient2 extends ApiClient {
426
705
  /** Fetches the Context manifest for a project */
427
706
  async get(options) {
428
707
  const { projectId } = this.options;
429
- const fetchUri = this.createUrl(__privateGet(_ManifestClient2, _url4), { ...options, projectId });
708
+ const fetchUri = this.createUrl(__privateGet2(_ManifestClient2, _url4), { ...options, projectId });
430
709
  return await this.apiClient(fetchUri);
431
710
  }
432
711
  /** Publishes the Context manifest for a project */
@@ -440,7 +719,7 @@ var _ManifestClient = class _ManifestClient2 extends ApiClient {
440
719
  }
441
720
  };
442
721
  _url4 = /* @__PURE__ */ new WeakMap();
443
- __privateAdd(_ManifestClient, _url4, "/api/v2/manifest");
722
+ __privateAdd2(_ManifestClient, _url4, "/api/v2/manifest");
444
723
  var _url5;
445
724
  var _QuirkClient = class _QuirkClient2 extends ApiClient {
446
725
  constructor(options) {
@@ -449,12 +728,12 @@ var _QuirkClient = class _QuirkClient2 extends ApiClient {
449
728
  /** Fetches all Quirks for a project */
450
729
  async get(options) {
451
730
  const { projectId } = this.options;
452
- const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5), { ...options, projectId });
731
+ const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5), { ...options, projectId });
453
732
  return await this.apiClient(fetchUri);
454
733
  }
455
734
  /** Updates or creates (based on id) a Quirk */
456
735
  async upsert(body) {
457
- const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5));
736
+ const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5));
458
737
  await this.apiClient(fetchUri, {
459
738
  method: "PUT",
460
739
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -463,7 +742,7 @@ var _QuirkClient = class _QuirkClient2 extends ApiClient {
463
742
  }
464
743
  /** Deletes a Quirk */
465
744
  async remove(body) {
466
- const fetchUri = this.createUrl(__privateGet(_QuirkClient2, _url5));
745
+ const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5));
467
746
  await this.apiClient(fetchUri, {
468
747
  method: "DELETE",
469
748
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -472,7 +751,7 @@ var _QuirkClient = class _QuirkClient2 extends ApiClient {
472
751
  }
473
752
  };
474
753
  _url5 = /* @__PURE__ */ new WeakMap();
475
- __privateAdd(_QuirkClient, _url5, "/api/v2/quirk");
754
+ __privateAdd2(_QuirkClient, _url5, "/api/v2/quirk");
476
755
  var _url6;
477
756
  var _SignalClient = class _SignalClient2 extends ApiClient {
478
757
  constructor(options) {
@@ -481,12 +760,12 @@ var _SignalClient = class _SignalClient2 extends ApiClient {
481
760
  /** Fetches all Signals for a project */
482
761
  async get(options) {
483
762
  const { projectId } = this.options;
484
- const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6), { ...options, projectId });
763
+ const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6), { ...options, projectId });
485
764
  return await this.apiClient(fetchUri);
486
765
  }
487
766
  /** Updates or creates (based on id) a Signal */
488
767
  async upsert(body) {
489
- const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6));
768
+ const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6));
490
769
  await this.apiClient(fetchUri, {
491
770
  method: "PUT",
492
771
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -495,434 +774,235 @@ var _SignalClient = class _SignalClient2 extends ApiClient {
495
774
  }
496
775
  /** Deletes a Signal */
497
776
  async remove(body) {
498
- const fetchUri = this.createUrl(__privateGet(_SignalClient2, _url6));
499
- await this.apiClient(fetchUri, {
500
- method: "DELETE",
501
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
502
- expectNoContent: true
503
- });
504
- }
505
- };
506
- _url6 = /* @__PURE__ */ new WeakMap();
507
- __privateAdd(_SignalClient, _url6, "/api/v2/signal");
508
- var _url7;
509
- var _TestClient = class _TestClient2 extends ApiClient {
510
- constructor(options) {
511
- super(options);
512
- }
513
- /** Fetches all Tests for a project */
514
- async get(options) {
515
- const { projectId } = this.options;
516
- const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7), { ...options, projectId });
517
- return await this.apiClient(fetchUri);
518
- }
519
- /** Updates or creates (based on id) a Test */
520
- async upsert(body) {
521
- const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7));
522
- await this.apiClient(fetchUri, {
523
- method: "PUT",
524
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
525
- expectNoContent: true
526
- });
527
- }
528
- /** Deletes a Test */
529
- async remove(body) {
530
- const fetchUri = this.createUrl(__privateGet(_TestClient2, _url7));
777
+ const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6));
531
778
  await this.apiClient(fetchUri, {
532
- method: "DELETE",
533
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
534
- expectNoContent: true
535
- });
536
- }
537
- };
538
- _url7 = /* @__PURE__ */ new WeakMap();
539
- __privateAdd(_TestClient, _url7, "/api/v2/test");
540
-
541
- // ../canvas/dist/index.mjs
542
- var __create2 = Object.create;
543
- var __defProp3 = Object.defineProperty;
544
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
545
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
546
- var __getProtoOf2 = Object.getPrototypeOf;
547
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
548
- var __typeError2 = (msg) => {
549
- throw TypeError(msg);
550
- };
551
- var __commonJS2 = (cb, mod) => function __require() {
552
- return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
553
- };
554
- var __copyProps2 = (to, from, except, desc) => {
555
- if (from && typeof from === "object" || typeof from === "function") {
556
- for (let key of __getOwnPropNames2(from))
557
- if (!__hasOwnProp2.call(to, key) && key !== except)
558
- __defProp3(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
559
- }
560
- return to;
561
- };
562
- var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
563
- // If the importer is in node compatibility mode or this is not an ESM
564
- // file that has been converted to a CommonJS file using a Babel-
565
- // compatible transform (i.e. "__esModule" has not been set), then set
566
- // "default" to the CommonJS "module.exports" for node compatibility.
567
- isNodeMode || !mod || !mod.__esModule ? __defProp3(target, "default", { value: mod, enumerable: true }) : target,
568
- mod
569
- ));
570
- var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
571
- var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
572
- 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);
573
- var require_yocto_queue2 = __commonJS2({
574
- "../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports, module) {
575
- "use strict";
576
- var Node = class {
577
- /// value;
578
- /// next;
579
- constructor(value) {
580
- this.value = value;
581
- this.next = void 0;
582
- }
583
- };
584
- var Queue = class {
585
- // TODO: Use private class fields when targeting Node.js 12.
586
- // #_head;
587
- // #_tail;
588
- // #_size;
589
- constructor() {
590
- this.clear();
591
- }
592
- enqueue(value) {
593
- const node = new Node(value);
594
- if (this._head) {
595
- this._tail.next = node;
596
- this._tail = node;
597
- } else {
598
- this._head = node;
599
- this._tail = node;
600
- }
601
- this._size++;
602
- }
603
- dequeue() {
604
- const current = this._head;
605
- if (!current) {
606
- return;
607
- }
608
- this._head = this._head.next;
609
- this._size--;
610
- return current.value;
611
- }
612
- clear() {
613
- this._head = void 0;
614
- this._tail = void 0;
615
- this._size = 0;
616
- }
617
- get size() {
618
- return this._size;
619
- }
620
- *[Symbol.iterator]() {
621
- let current = this._head;
622
- while (current) {
623
- yield current.value;
624
- current = current.next;
625
- }
626
- }
627
- };
628
- module.exports = Queue;
629
- }
630
- });
631
- var require_p_limit2 = __commonJS2({
632
- "../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports, module) {
633
- "use strict";
634
- var Queue = require_yocto_queue2();
635
- var pLimit2 = (concurrency) => {
636
- if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
637
- throw new TypeError("Expected `concurrency` to be a number from 1 and up");
638
- }
639
- const queue = new Queue();
640
- let activeCount = 0;
641
- const next = () => {
642
- activeCount--;
643
- if (queue.size > 0) {
644
- queue.dequeue()();
645
- }
646
- };
647
- const run = async (fn, resolve, ...args) => {
648
- activeCount++;
649
- const result = (async () => fn(...args))();
650
- resolve(result);
651
- try {
652
- await result;
653
- } catch (e) {
654
- }
655
- next();
656
- };
657
- const enqueue = (fn, resolve, ...args) => {
658
- queue.enqueue(run.bind(null, fn, resolve, ...args));
659
- (async () => {
660
- await Promise.resolve();
661
- if (activeCount < concurrency && queue.size > 0) {
662
- queue.dequeue()();
663
- }
664
- })();
665
- };
666
- const generator = (fn, ...args) => new Promise((resolve) => {
667
- enqueue(fn, resolve, ...args);
668
- });
669
- Object.defineProperties(generator, {
670
- activeCount: {
671
- get: () => activeCount
672
- },
673
- pendingCount: {
674
- get: () => queue.size
675
- },
676
- clearQueue: {
677
- value: () => {
678
- queue.clear();
679
- }
680
- }
681
- });
682
- return generator;
683
- };
684
- module.exports = pLimit2;
685
- }
686
- });
687
- var require_retry_operation = __commonJS2({
688
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports, module) {
689
- "use strict";
690
- function RetryOperation(timeouts, options) {
691
- if (typeof options === "boolean") {
692
- options = { forever: options };
693
- }
694
- this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
695
- this._timeouts = timeouts;
696
- this._options = options || {};
697
- this._maxRetryTime = options && options.maxRetryTime || Infinity;
698
- this._fn = null;
699
- this._errors = [];
700
- this._attempts = 1;
701
- this._operationTimeout = null;
702
- this._operationTimeoutCb = null;
703
- this._timeout = null;
704
- this._operationStart = null;
705
- this._timer = null;
706
- if (this._options.forever) {
707
- this._cachedTimeouts = this._timeouts.slice(0);
708
- }
709
- }
710
- module.exports = RetryOperation;
711
- RetryOperation.prototype.reset = function() {
712
- this._attempts = 1;
713
- this._timeouts = this._originalTimeouts.slice(0);
714
- };
715
- RetryOperation.prototype.stop = function() {
716
- if (this._timeout) {
717
- clearTimeout(this._timeout);
718
- }
719
- if (this._timer) {
720
- clearTimeout(this._timer);
721
- }
722
- this._timeouts = [];
723
- this._cachedTimeouts = null;
724
- };
725
- RetryOperation.prototype.retry = function(err) {
726
- if (this._timeout) {
727
- clearTimeout(this._timeout);
728
- }
729
- if (!err) {
730
- return false;
731
- }
732
- var currentTime = (/* @__PURE__ */ new Date()).getTime();
733
- if (err && currentTime - this._operationStart >= this._maxRetryTime) {
734
- this._errors.push(err);
735
- this._errors.unshift(new Error("RetryOperation timeout occurred"));
736
- return false;
737
- }
738
- this._errors.push(err);
739
- var timeout = this._timeouts.shift();
740
- if (timeout === void 0) {
741
- if (this._cachedTimeouts) {
742
- this._errors.splice(0, this._errors.length - 1);
743
- timeout = this._cachedTimeouts.slice(-1);
744
- } else {
745
- return false;
746
- }
747
- }
748
- var self = this;
749
- this._timer = setTimeout(function() {
750
- self._attempts++;
751
- if (self._operationTimeoutCb) {
752
- self._timeout = setTimeout(function() {
753
- self._operationTimeoutCb(self._attempts);
754
- }, self._operationTimeout);
755
- if (self._options.unref) {
756
- self._timeout.unref();
757
- }
758
- }
759
- self._fn(self._attempts);
760
- }, timeout);
761
- if (this._options.unref) {
762
- this._timer.unref();
763
- }
764
- return true;
765
- };
766
- RetryOperation.prototype.attempt = function(fn, timeoutOps) {
767
- this._fn = fn;
768
- if (timeoutOps) {
769
- if (timeoutOps.timeout) {
770
- this._operationTimeout = timeoutOps.timeout;
771
- }
772
- if (timeoutOps.cb) {
773
- this._operationTimeoutCb = timeoutOps.cb;
774
- }
775
- }
776
- var self = this;
777
- if (this._operationTimeoutCb) {
778
- this._timeout = setTimeout(function() {
779
- self._operationTimeoutCb();
780
- }, self._operationTimeout);
781
- }
782
- this._operationStart = (/* @__PURE__ */ new Date()).getTime();
783
- this._fn(this._attempts);
784
- };
785
- RetryOperation.prototype.try = function(fn) {
786
- console.log("Using RetryOperation.try() is deprecated");
787
- this.attempt(fn);
788
- };
789
- RetryOperation.prototype.start = function(fn) {
790
- console.log("Using RetryOperation.start() is deprecated");
791
- this.attempt(fn);
792
- };
793
- RetryOperation.prototype.start = RetryOperation.prototype.try;
794
- RetryOperation.prototype.errors = function() {
795
- return this._errors;
796
- };
797
- RetryOperation.prototype.attempts = function() {
798
- return this._attempts;
799
- };
800
- RetryOperation.prototype.mainError = function() {
801
- if (this._errors.length === 0) {
802
- return null;
803
- }
804
- var counts = {};
805
- var mainError = null;
806
- var mainErrorCount = 0;
807
- for (var i = 0; i < this._errors.length; i++) {
808
- var error = this._errors[i];
809
- var message = error.message;
810
- var count = (counts[message] || 0) + 1;
811
- counts[message] = count;
812
- if (count >= mainErrorCount) {
813
- mainError = error;
814
- mainErrorCount = count;
815
- }
816
- }
817
- return mainError;
818
- };
779
+ method: "DELETE",
780
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
781
+ expectNoContent: true
782
+ });
819
783
  }
820
- });
821
- var require_retry = __commonJS2({
822
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports) {
823
- "use strict";
824
- var RetryOperation = require_retry_operation();
825
- exports.operation = function(options) {
826
- var timeouts = exports.timeouts(options);
827
- return new RetryOperation(timeouts, {
828
- forever: options && (options.forever || options.retries === Infinity),
829
- unref: options && options.unref,
830
- maxRetryTime: options && options.maxRetryTime
831
- });
832
- };
833
- exports.timeouts = function(options) {
834
- if (options instanceof Array) {
835
- return [].concat(options);
836
- }
837
- var opts = {
838
- retries: 10,
839
- factor: 2,
840
- minTimeout: 1 * 1e3,
841
- maxTimeout: Infinity,
842
- randomize: false
843
- };
844
- for (var key in options) {
845
- opts[key] = options[key];
846
- }
847
- if (opts.minTimeout > opts.maxTimeout) {
848
- throw new Error("minTimeout is greater than maxTimeout");
849
- }
850
- var timeouts = [];
851
- for (var i = 0; i < opts.retries; i++) {
852
- timeouts.push(this.createTimeout(i, opts));
853
- }
854
- if (options && options.forever && !timeouts.length) {
855
- timeouts.push(this.createTimeout(i, opts));
784
+ };
785
+ _url6 = /* @__PURE__ */ new WeakMap();
786
+ __privateAdd2(_SignalClient, _url6, "/api/v2/signal");
787
+ var _url7;
788
+ var _TestClient = class _TestClient2 extends ApiClient {
789
+ constructor(options) {
790
+ super(options);
791
+ }
792
+ /** Fetches all Tests for a project */
793
+ async get(options) {
794
+ const { projectId } = this.options;
795
+ const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7), { ...options, projectId });
796
+ return await this.apiClient(fetchUri);
797
+ }
798
+ /** Updates or creates (based on id) a Test */
799
+ async upsert(body) {
800
+ const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7));
801
+ await this.apiClient(fetchUri, {
802
+ method: "PUT",
803
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
804
+ expectNoContent: true
805
+ });
806
+ }
807
+ /** Deletes a Test */
808
+ async remove(body) {
809
+ const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7));
810
+ await this.apiClient(fetchUri, {
811
+ method: "DELETE",
812
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
813
+ expectNoContent: true
814
+ });
815
+ }
816
+ };
817
+ _url7 = /* @__PURE__ */ new WeakMap();
818
+ __privateAdd2(_TestClient, _url7, "/api/v2/test");
819
+
820
+ // ../../node_modules/.pnpm/yocto-queue@1.2.2/node_modules/yocto-queue/index.js
821
+ var Node = class {
822
+ constructor(value) {
823
+ __publicField(this, "value");
824
+ __publicField(this, "next");
825
+ this.value = value;
826
+ }
827
+ };
828
+ var _head, _tail, _size;
829
+ var Queue = class {
830
+ constructor() {
831
+ __privateAdd(this, _head);
832
+ __privateAdd(this, _tail);
833
+ __privateAdd(this, _size);
834
+ this.clear();
835
+ }
836
+ enqueue(value) {
837
+ const node = new Node(value);
838
+ if (__privateGet(this, _head)) {
839
+ __privateGet(this, _tail).next = node;
840
+ __privateSet(this, _tail, node);
841
+ } else {
842
+ __privateSet(this, _head, node);
843
+ __privateSet(this, _tail, node);
844
+ }
845
+ __privateWrapper(this, _size)._++;
846
+ }
847
+ dequeue() {
848
+ const current = __privateGet(this, _head);
849
+ if (!current) {
850
+ return;
851
+ }
852
+ __privateSet(this, _head, __privateGet(this, _head).next);
853
+ __privateWrapper(this, _size)._--;
854
+ if (!__privateGet(this, _head)) {
855
+ __privateSet(this, _tail, void 0);
856
+ }
857
+ return current.value;
858
+ }
859
+ peek() {
860
+ if (!__privateGet(this, _head)) {
861
+ return;
862
+ }
863
+ return __privateGet(this, _head).value;
864
+ }
865
+ clear() {
866
+ __privateSet(this, _head, void 0);
867
+ __privateSet(this, _tail, void 0);
868
+ __privateSet(this, _size, 0);
869
+ }
870
+ get size() {
871
+ return __privateGet(this, _size);
872
+ }
873
+ *[Symbol.iterator]() {
874
+ let current = __privateGet(this, _head);
875
+ while (current) {
876
+ yield current.value;
877
+ current = current.next;
878
+ }
879
+ }
880
+ *drain() {
881
+ while (__privateGet(this, _head)) {
882
+ yield this.dequeue();
883
+ }
884
+ }
885
+ };
886
+ _head = new WeakMap();
887
+ _tail = new WeakMap();
888
+ _size = new WeakMap();
889
+
890
+ // ../../node_modules/.pnpm/p-limit@6.2.0/node_modules/p-limit/index.js
891
+ function pLimit2(concurrency) {
892
+ validateConcurrency(concurrency);
893
+ const queue = new Queue();
894
+ let activeCount = 0;
895
+ const resumeNext = () => {
896
+ if (activeCount < concurrency && queue.size > 0) {
897
+ queue.dequeue()();
898
+ activeCount++;
899
+ }
900
+ };
901
+ const next = () => {
902
+ activeCount--;
903
+ resumeNext();
904
+ };
905
+ const run = async (function_, resolve, arguments_) => {
906
+ const result = (async () => function_(...arguments_))();
907
+ resolve(result);
908
+ try {
909
+ await result;
910
+ } catch (e) {
911
+ }
912
+ next();
913
+ };
914
+ const enqueue = (function_, resolve, arguments_) => {
915
+ new Promise((internalResolve) => {
916
+ queue.enqueue(internalResolve);
917
+ }).then(
918
+ run.bind(void 0, function_, resolve, arguments_)
919
+ );
920
+ (async () => {
921
+ await Promise.resolve();
922
+ if (activeCount < concurrency) {
923
+ resumeNext();
856
924
  }
857
- timeouts.sort(function(a, b) {
858
- return a - b;
859
- });
860
- return timeouts;
861
- };
862
- exports.createTimeout = function(attempt, opts) {
863
- var random = opts.randomize ? Math.random() + 1 : 1;
864
- var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
865
- timeout = Math.min(timeout, opts.maxTimeout);
866
- return timeout;
867
- };
868
- exports.wrap = function(obj, options, methods) {
869
- if (options instanceof Array) {
870
- methods = options;
871
- options = null;
925
+ })();
926
+ };
927
+ const generator = (function_, ...arguments_) => new Promise((resolve) => {
928
+ enqueue(function_, resolve, arguments_);
929
+ });
930
+ Object.defineProperties(generator, {
931
+ activeCount: {
932
+ get: () => activeCount
933
+ },
934
+ pendingCount: {
935
+ get: () => queue.size
936
+ },
937
+ clearQueue: {
938
+ value() {
939
+ queue.clear();
872
940
  }
873
- if (!methods) {
874
- methods = [];
875
- for (var key in obj) {
876
- if (typeof obj[key] === "function") {
877
- methods.push(key);
941
+ },
942
+ concurrency: {
943
+ get: () => concurrency,
944
+ set(newConcurrency) {
945
+ validateConcurrency(newConcurrency);
946
+ concurrency = newConcurrency;
947
+ queueMicrotask(() => {
948
+ while (activeCount < concurrency && queue.size > 0) {
949
+ resumeNext();
878
950
  }
879
- }
880
- }
881
- for (var i = 0; i < methods.length; i++) {
882
- var method = methods[i];
883
- var original = obj[method];
884
- obj[method] = function retryWrapper(original2) {
885
- var op = exports.operation(options);
886
- var args = Array.prototype.slice.call(arguments, 1);
887
- var callback = args.pop();
888
- args.push(function(err) {
889
- if (op.retry(err)) {
890
- return;
891
- }
892
- if (err) {
893
- arguments[0] = op.mainError();
894
- }
895
- callback.apply(this, arguments);
896
- });
897
- op.attempt(function() {
898
- original2.apply(obj, args);
899
- });
900
- }.bind(obj, original);
901
- obj[method].options = options;
951
+ });
902
952
  }
903
- };
904
- }
905
- });
906
- var require_retry2 = __commonJS2({
907
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports, module) {
908
- "use strict";
909
- module.exports = require_retry();
953
+ }
954
+ });
955
+ return generator;
956
+ }
957
+ function validateConcurrency(concurrency) {
958
+ if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
959
+ throw new TypeError("Expected `concurrency` to be a number from 1 and up");
910
960
  }
911
- });
912
- var import_p_limit2 = __toESM2(require_p_limit2());
913
- var import_retry = __toESM2(require_retry2(), 1);
914
- var networkErrorMsgs = /* @__PURE__ */ new Set([
915
- "Failed to fetch",
961
+ }
962
+
963
+ // ../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
964
+ var import_retry = __toESM(require_retry2(), 1);
965
+
966
+ // ../../node_modules/.pnpm/is-network-error@1.3.2/node_modules/is-network-error/index.js
967
+ var objectToString = Object.prototype.toString;
968
+ var isError = (value) => objectToString.call(value) === "[object Error]";
969
+ var errorMessages = /* @__PURE__ */ new Set([
970
+ "network error",
916
971
  // Chrome
917
972
  "NetworkError when attempting to fetch resource.",
918
973
  // Firefox
919
974
  "The Internet connection appears to be offline.",
920
- // Safari
975
+ // Safari 16
921
976
  "Network request failed",
922
977
  // `cross-fetch`
923
- "fetch failed"
978
+ "fetch failed",
979
+ // Undici (Node.js)
980
+ "terminated",
924
981
  // Undici (Node.js)
982
+ " A network error occurred.",
983
+ // Bun (WebKit)
984
+ "Network connection lost"
985
+ // Cloudflare Workers (fetch)
925
986
  ]);
987
+ function isNetworkError(error) {
988
+ const isValid = error && isError(error) && error.name === "TypeError" && typeof error.message === "string";
989
+ if (!isValid) {
990
+ return false;
991
+ }
992
+ const { message, stack } = error;
993
+ if (message === "Load failed" || message.startsWith("Load failed (") && message.endsWith(")")) {
994
+ return stack === void 0 || "__sentry_captured__" in error;
995
+ }
996
+ if (message.startsWith("error sending request for url")) {
997
+ return true;
998
+ }
999
+ if (message === "Failed to fetch" || message.startsWith("Failed to fetch (") && message.endsWith(")")) {
1000
+ return true;
1001
+ }
1002
+ return errorMessages.has(message);
1003
+ }
1004
+
1005
+ // ../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
926
1006
  var AbortError = class extends Error {
927
1007
  constructor(message) {
928
1008
  super();
@@ -943,63 +1023,71 @@ var decorateErrorWithCounts = (error, attemptNumber, options) => {
943
1023
  error.retriesLeft = retriesLeft;
944
1024
  return error;
945
1025
  };
946
- var isNetworkError = (errorMessage) => networkErrorMsgs.has(errorMessage);
947
- var getDOMException = (errorMessage) => globalThis.DOMException === void 0 ? new Error(errorMessage) : new DOMException(errorMessage);
948
1026
  async function pRetry(input, options) {
949
1027
  return new Promise((resolve, reject) => {
950
- options = {
951
- onFailedAttempt() {
952
- },
953
- retries: 10,
954
- ...options
1028
+ var _a, _b, _c;
1029
+ options = { ...options };
1030
+ (_a = options.onFailedAttempt) != null ? _a : options.onFailedAttempt = () => {
955
1031
  };
1032
+ (_b = options.shouldRetry) != null ? _b : options.shouldRetry = () => true;
1033
+ (_c = options.retries) != null ? _c : options.retries = 10;
956
1034
  const operation = import_retry.default.operation(options);
1035
+ const abortHandler = () => {
1036
+ var _a2;
1037
+ operation.stop();
1038
+ reject((_a2 = options.signal) == null ? void 0 : _a2.reason);
1039
+ };
1040
+ if (options.signal && !options.signal.aborted) {
1041
+ options.signal.addEventListener("abort", abortHandler, { once: true });
1042
+ }
1043
+ const cleanUp = () => {
1044
+ var _a2;
1045
+ (_a2 = options.signal) == null ? void 0 : _a2.removeEventListener("abort", abortHandler);
1046
+ operation.stop();
1047
+ };
957
1048
  operation.attempt(async (attemptNumber) => {
958
1049
  try {
959
- resolve(await input(attemptNumber));
1050
+ const result = await input(attemptNumber);
1051
+ cleanUp();
1052
+ resolve(result);
960
1053
  } catch (error) {
961
- if (!(error instanceof Error)) {
962
- reject(new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`));
963
- return;
964
- }
965
- if (error instanceof AbortError) {
966
- operation.stop();
967
- reject(error.originalError);
968
- } else if (error instanceof TypeError && !isNetworkError(error.message)) {
969
- operation.stop();
970
- reject(error);
971
- } else {
1054
+ try {
1055
+ if (!(error instanceof Error)) {
1056
+ throw new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
1057
+ }
1058
+ if (error instanceof AbortError) {
1059
+ throw error.originalError;
1060
+ }
1061
+ if (error instanceof TypeError && !isNetworkError(error)) {
1062
+ throw error;
1063
+ }
972
1064
  decorateErrorWithCounts(error, attemptNumber, options);
973
- try {
974
- await options.onFailedAttempt(error);
975
- } catch (error2) {
976
- reject(error2);
977
- return;
1065
+ if (!await options.shouldRetry(error)) {
1066
+ operation.stop();
1067
+ reject(error);
978
1068
  }
1069
+ await options.onFailedAttempt(error);
979
1070
  if (!operation.retry(error)) {
980
- reject(operation.mainError());
1071
+ throw operation.mainError();
981
1072
  }
1073
+ } catch (finalError) {
1074
+ decorateErrorWithCounts(finalError, attemptNumber, options);
1075
+ cleanUp();
1076
+ reject(finalError);
982
1077
  }
983
1078
  }
984
1079
  });
985
- if (options.signal && !options.signal.aborted) {
986
- options.signal.addEventListener("abort", () => {
987
- operation.stop();
988
- const reason = options.signal.reason === void 0 ? getDOMException("The operation was aborted.") : options.signal.reason;
989
- reject(reason instanceof Error ? reason : getDOMException(reason));
990
- }, {
991
- once: true
992
- });
993
- }
994
1080
  });
995
1081
  }
1082
+
1083
+ // ../../node_modules/.pnpm/p-throttle@6.2.0/node_modules/p-throttle/index.js
996
1084
  var AbortError2 = class extends Error {
997
1085
  constructor() {
998
1086
  super("Throttled function aborted");
999
1087
  this.name = "AbortError";
1000
1088
  }
1001
1089
  };
1002
- function pThrottle({ limit, interval, strict }) {
1090
+ function pThrottle({ limit, interval, strict, onDelay }) {
1003
1091
  if (!Number.isFinite(limit)) {
1004
1092
  throw new TypeError("Expected `limit` to be a finite number");
1005
1093
  }
@@ -1027,32 +1115,38 @@ function pThrottle({ limit, interval, strict }) {
1027
1115
  const strictTicks = [];
1028
1116
  function strictDelay() {
1029
1117
  const now = Date.now();
1030
- if (strictTicks.length < limit) {
1031
- strictTicks.push(now);
1032
- return 0;
1118
+ if (strictTicks.length > 0 && now - strictTicks.at(-1) > interval) {
1119
+ strictTicks.length = 0;
1033
1120
  }
1034
- const earliestTime = strictTicks.shift() + interval;
1035
- if (now >= earliestTime) {
1121
+ if (strictTicks.length < limit) {
1036
1122
  strictTicks.push(now);
1037
1123
  return 0;
1038
1124
  }
1039
- strictTicks.push(earliestTime);
1040
- return earliestTime - now;
1125
+ const nextExecutionTime = strictTicks[0] + interval;
1126
+ strictTicks.shift();
1127
+ strictTicks.push(nextExecutionTime);
1128
+ return Math.max(0, nextExecutionTime - now);
1041
1129
  }
1042
1130
  const getDelay = strict ? strictDelay : windowedDelay;
1043
1131
  return (function_) => {
1044
- const throttled = function(...args) {
1132
+ const throttled = function(...arguments_) {
1045
1133
  if (!throttled.isEnabled) {
1046
- return (async () => function_.apply(this, args))();
1134
+ return (async () => function_.apply(this, arguments_))();
1047
1135
  }
1048
- let timeout;
1136
+ let timeoutId;
1049
1137
  return new Promise((resolve, reject) => {
1050
1138
  const execute = () => {
1051
- resolve(function_.apply(this, args));
1052
- queue.delete(timeout);
1139
+ resolve(function_.apply(this, arguments_));
1140
+ queue.delete(timeoutId);
1053
1141
  };
1054
- timeout = setTimeout(execute, getDelay());
1055
- queue.set(timeout, reject);
1142
+ const delay = getDelay();
1143
+ if (delay > 0) {
1144
+ timeoutId = setTimeout(execute, delay);
1145
+ queue.set(timeoutId, reject);
1146
+ onDelay == null ? void 0 : onDelay(...arguments_);
1147
+ } else {
1148
+ execute();
1149
+ }
1056
1150
  });
1057
1151
  };
1058
1152
  throttled.abort = () => {
@@ -1064,16 +1158,29 @@ function pThrottle({ limit, interval, strict }) {
1064
1158
  strictTicks.splice(0, strictTicks.length);
1065
1159
  };
1066
1160
  throttled.isEnabled = true;
1161
+ Object.defineProperty(throttled, "queueSize", {
1162
+ get() {
1163
+ return queue.size;
1164
+ }
1165
+ });
1067
1166
  return throttled;
1068
1167
  };
1069
1168
  }
1169
+
1170
+ // ../canvas/dist/index.mjs
1171
+ var __typeError3 = (msg) => {
1172
+ throw TypeError(msg);
1173
+ };
1174
+ var __accessCheck3 = (obj, member, msg) => member.has(obj) || __typeError3("Cannot " + msg);
1175
+ var __privateGet3 = (obj, member, getter) => (__accessCheck3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1176
+ 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);
1070
1177
  function createLimitPolicy({
1071
1178
  throttle = { interval: 1e3, limit: 10 },
1072
- retry: retry2 = { retries: 1, factor: 1.66 },
1179
+ retry: retry3 = { retries: 1, factor: 1.66 },
1073
1180
  limit = 10
1074
1181
  }) {
1075
1182
  const throttler = throttle ? pThrottle(throttle) : null;
1076
- const limiter = limit ? (0, import_p_limit2.default)(limit) : null;
1183
+ const limiter = limit ? pLimit2(limit) : null;
1077
1184
  return function limitPolicy(func) {
1078
1185
  let currentFunc = async () => await func();
1079
1186
  if (throttler) {
@@ -1084,13 +1191,13 @@ function createLimitPolicy({
1084
1191
  const limitFunc = currentFunc;
1085
1192
  currentFunc = () => limiter(limitFunc);
1086
1193
  }
1087
- if (retry2) {
1194
+ if (retry3) {
1088
1195
  const retryFunc = currentFunc;
1089
1196
  currentFunc = () => pRetry(retryFunc, {
1090
- ...retry2,
1197
+ ...retry3,
1091
1198
  onFailedAttempt: async (error) => {
1092
- if (retry2.onFailedAttempt) {
1093
- await retry2.onFailedAttempt(error);
1199
+ if (retry3.onFailedAttempt) {
1200
+ await retry3.onFailedAttempt(error);
1094
1201
  }
1095
1202
  if (error instanceof ApiClientError && typeof error.statusCode === "number" && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429 && error.statusCode !== 408) {
1096
1203
  throw error;
@@ -1101,19 +1208,49 @@ function createLimitPolicy({
1101
1208
  return currentFunc();
1102
1209
  };
1103
1210
  }
1104
- var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
1105
- function rewriteFilters(filters) {
1106
- return Object.entries(filters != null ? filters : {}).reduce(
1107
- (acc, [key, value]) => {
1108
- const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
1109
- const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
1110
- return {
1111
- ...acc,
1112
- [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
1113
- };
1114
- },
1115
- {}
1116
- );
1211
+ var SELECT_QUERY_PREFIX = "select.";
1212
+ function appendCsv(out, key, values) {
1213
+ if (values === void 0) {
1214
+ return;
1215
+ }
1216
+ out[key] = values.join(",");
1217
+ }
1218
+ function projectionToQuery(spec) {
1219
+ const out = {};
1220
+ if (!spec) {
1221
+ return out;
1222
+ }
1223
+ const { fields, fieldTypes, slots } = spec;
1224
+ const p = SELECT_QUERY_PREFIX;
1225
+ if (fields) {
1226
+ appendCsv(out, `${p}fields[only]`, fields.only);
1227
+ appendCsv(out, `${p}fields[except]`, fields.except);
1228
+ appendCsv(out, `${p}fields[locales]`, fields.locales);
1229
+ if (fields.blockDepth === "preserveAll" || typeof fields.blockDepth === "number") {
1230
+ out[`${p}fields[blockDepth]`] = String(fields.blockDepth);
1231
+ }
1232
+ }
1233
+ if (fieldTypes) {
1234
+ appendCsv(out, `${p}fieldTypes[only]`, fieldTypes.only);
1235
+ appendCsv(out, `${p}fieldTypes[except]`, fieldTypes.except);
1236
+ }
1237
+ if (slots) {
1238
+ appendCsv(out, `${p}slots[only]`, slots.only);
1239
+ appendCsv(out, `${p}slots[except]`, slots.except);
1240
+ if (typeof slots.depth === "number") {
1241
+ out[`${p}slots[depth]`] = String(slots.depth);
1242
+ }
1243
+ if (slots.named) {
1244
+ const slotNames = Object.keys(slots.named).sort();
1245
+ for (const slotName of slotNames) {
1246
+ const named = slots.named[slotName];
1247
+ if (named && typeof named.depth === "number") {
1248
+ out[`${p}slots.${slotName}[depth]`] = String(named.depth);
1249
+ }
1250
+ }
1251
+ }
1252
+ }
1253
+ return out;
1117
1254
  }
1118
1255
  var CANVAS_URL = "/api/v1/canvas";
1119
1256
  var CanvasClient = class extends ApiClient {
@@ -1129,17 +1266,24 @@ var CanvasClient = class extends ApiClient {
1129
1266
  /** Fetches lists of Canvas compositions, optionally by type */
1130
1267
  async getCompositionList(params = {}) {
1131
1268
  const { projectId } = this.options;
1132
- const { resolveData, filters, ...originParams } = params;
1133
- const rewrittenFilters = rewriteFilters(filters);
1269
+ const { resolveData, filters, select, ...originParams } = params;
1270
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1271
+ const rewrittenSelect = projectionToQuery(select);
1134
1272
  if (!resolveData) {
1135
- const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
1273
+ const fetchUri = this.createUrl(CANVAS_URL, {
1274
+ ...originParams,
1275
+ projectId,
1276
+ ...rewrittenFilters,
1277
+ ...rewrittenSelect
1278
+ });
1136
1279
  return this.apiClient(fetchUri);
1137
1280
  }
1138
1281
  const edgeParams = {
1139
1282
  ...originParams,
1140
1283
  projectId,
1141
1284
  diagnostics: typeof params.diagnostics === "boolean" ? params.diagnostics : params.diagnostics === "no-data" ? "no-data" : void 0,
1142
- ...rewrittenFilters
1285
+ ...rewrittenFilters,
1286
+ ...rewrittenSelect
1143
1287
  };
1144
1288
  const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
1145
1289
  return this.apiClient(edgeUrl, this.edgeApiRequestInit);
@@ -1244,20 +1388,26 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1244
1388
  }
1245
1389
  getContentTypes(options) {
1246
1390
  const { projectId } = this.options;
1247
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl), { ...options, projectId });
1391
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _contentTypesUrl), { ...options, projectId });
1248
1392
  return this.apiClient(fetchUri);
1249
1393
  }
1250
1394
  getEntries(options) {
1251
1395
  const { projectId } = this.options;
1252
- const { skipDataResolution, filters, ...params } = options;
1253
- const rewrittenFilters = rewriteFilters(filters);
1396
+ const { skipDataResolution, filters, select, ...params } = options;
1397
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1398
+ const rewrittenSelect = projectionToQuery(select);
1254
1399
  if (skipDataResolution) {
1255
- const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
1400
+ const url = this.createUrl(__privateGet3(_ContentClient2, _entriesUrl), {
1401
+ ...params,
1402
+ ...rewrittenFilters,
1403
+ ...rewrittenSelect,
1404
+ projectId
1405
+ });
1256
1406
  return this.apiClient(url);
1257
1407
  }
1258
1408
  const edgeUrl = this.createUrl(
1259
- __privateGet2(_ContentClient2, _entriesUrl),
1260
- { ...this.getEdgeOptions(params), ...rewrittenFilters },
1409
+ __privateGet3(_ContentClient2, _entriesUrl),
1410
+ { ...this.getEdgeOptions(params), ...rewrittenFilters, ...rewrittenSelect },
1261
1411
  this.edgeApiHost
1262
1412
  );
1263
1413
  return this.apiClient(
@@ -1274,7 +1424,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1274
1424
  return this.apiClient(historyUrl);
1275
1425
  }
1276
1426
  async upsertContentType(body, opts = {}) {
1277
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl));
1427
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _contentTypesUrl));
1278
1428
  if (typeof body.contentType.slugSettings === "object" && body.contentType.slugSettings !== null && Object.keys(body.contentType.slugSettings).length === 0) {
1279
1429
  delete body.contentType.slugSettings;
1280
1430
  }
@@ -1286,7 +1436,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1286
1436
  });
1287
1437
  }
1288
1438
  async upsertEntry(body, options) {
1289
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl));
1439
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _entriesUrl));
1290
1440
  const headers = {};
1291
1441
  if (options == null ? void 0 : options.ifUnmodifiedSince) {
1292
1442
  headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
@@ -1300,7 +1450,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1300
1450
  return { modified: response.headers.get("x-modified-at") };
1301
1451
  }
1302
1452
  async deleteContentType(body) {
1303
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl));
1453
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _contentTypesUrl));
1304
1454
  await this.apiClient(fetchUri, {
1305
1455
  method: "DELETE",
1306
1456
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1308,7 +1458,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1308
1458
  });
1309
1459
  }
1310
1460
  async deleteEntry(body) {
1311
- const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl));
1461
+ const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _entriesUrl));
1312
1462
  await this.apiClient(fetchUri, {
1313
1463
  method: "DELETE",
1314
1464
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1327,8 +1477,8 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1327
1477
  };
1328
1478
  _contentTypesUrl = /* @__PURE__ */ new WeakMap();
1329
1479
  _entriesUrl = /* @__PURE__ */ new WeakMap();
1330
- __privateAdd2(_ContentClient, _contentTypesUrl, "/api/v1/content-types");
1331
- __privateAdd2(_ContentClient, _entriesUrl, "/api/v1/entries");
1480
+ __privateAdd3(_ContentClient, _contentTypesUrl, "/api/v1/content-types");
1481
+ __privateAdd3(_ContentClient, _entriesUrl, "/api/v1/entries");
1332
1482
  var _url8;
1333
1483
  var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1334
1484
  constructor(options) {
@@ -1337,12 +1487,12 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1337
1487
  /** Fetches all DataTypes for a project */
1338
1488
  async get(options) {
1339
1489
  const { projectId } = this.options;
1340
- const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8), { ...options, projectId });
1490
+ const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8), { ...options, projectId });
1341
1491
  return await this.apiClient(fetchUri);
1342
1492
  }
1343
1493
  /** Updates or creates (based on id) a DataType */
1344
1494
  async upsert(body) {
1345
- const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8));
1495
+ const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
1346
1496
  await this.apiClient(fetchUri, {
1347
1497
  method: "PUT",
1348
1498
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1351,7 +1501,7 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1351
1501
  }
1352
1502
  /** Deletes a DataType */
1353
1503
  async remove(body) {
1354
- const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8));
1504
+ const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
1355
1505
  await this.apiClient(fetchUri, {
1356
1506
  method: "DELETE",
1357
1507
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1360,7 +1510,7 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1360
1510
  }
1361
1511
  };
1362
1512
  _url8 = /* @__PURE__ */ new WeakMap();
1363
- __privateAdd2(_DataTypeClient, _url8, "/api/v1/data-types");
1513
+ __privateAdd3(_DataTypeClient, _url8, "/api/v1/data-types");
1364
1514
  var CANVAS_DRAFT_STATE = 0;
1365
1515
  var CANVAS_EDITOR_STATE = 63;
1366
1516
  var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
@@ -1380,9 +1530,9 @@ function parseVariableExpression(serialized, onToken) {
1380
1530
  let bufferStartIndex = 0;
1381
1531
  let bufferEndIndex = 0;
1382
1532
  let tokenCount = 0;
1383
- const handleToken = (token, type) => {
1533
+ const handleToken = (token, type, offset) => {
1384
1534
  tokenCount++;
1385
- return onToken == null ? void 0 : onToken(token, type);
1535
+ return onToken == null ? void 0 : onToken(token, type, offset);
1386
1536
  };
1387
1537
  let state = "text";
1388
1538
  for (let index = 0; index < serialized.length; index++) {
@@ -1393,7 +1543,7 @@ function parseVariableExpression(serialized, onToken) {
1393
1543
  if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
1394
1544
  if (serialized[index - 1] === escapeCharacter) {
1395
1545
  bufferEndIndex -= escapeCharacter.length;
1396
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
1546
+ if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
1397
1547
  return tokenCount;
1398
1548
  }
1399
1549
  bufferStartIndex = index;
@@ -1402,12 +1552,12 @@ function parseVariableExpression(serialized, onToken) {
1402
1552
  }
1403
1553
  if (state === "variable") {
1404
1554
  const textStart = bufferStartIndex - variablePrefix.length;
1405
- if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
1555
+ if (handleToken(serialized.substring(textStart, bufferEndIndex), "text", textStart) === false) {
1406
1556
  return tokenCount;
1407
1557
  }
1408
1558
  bufferStartIndex = bufferEndIndex;
1409
1559
  } else if (bufferEndIndex > bufferStartIndex) {
1410
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
1560
+ if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
1411
1561
  return tokenCount;
1412
1562
  }
1413
1563
  bufferStartIndex = bufferEndIndex;
@@ -1425,7 +1575,7 @@ function parseVariableExpression(serialized, onToken) {
1425
1575
  state = "text";
1426
1576
  if (bufferEndIndex > bufferStartIndex) {
1427
1577
  const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
1428
- if (handleToken(unescapedVariableName, "variable") === false) {
1578
+ if (handleToken(unescapedVariableName, "variable", bufferStartIndex) === false) {
1429
1579
  return tokenCount;
1430
1580
  }
1431
1581
  bufferStartIndex = bufferEndIndex + variableSuffix.length;
@@ -1439,7 +1589,7 @@ function parseVariableExpression(serialized, onToken) {
1439
1589
  bufferStartIndex -= variablePrefix.length;
1440
1590
  }
1441
1591
  if (bufferStartIndex < serialized.length) {
1442
- handleToken(serialized.substring(bufferStartIndex), state);
1592
+ handleToken(serialized.substring(bufferStartIndex), state, bufferStartIndex);
1443
1593
  }
1444
1594
  return tokenCount;
1445
1595
  }
@@ -1456,7 +1606,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1456
1606
  * Gets a list of property type and hook names for the current team, including public integrations' hooks.
1457
1607
  */
1458
1608
  get(options) {
1459
- const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl), {
1609
+ const fetchUri = this.createUrl(__privateGet3(_IntegrationPropertyEditorsClient2, _baseUrl), {
1460
1610
  ...options,
1461
1611
  teamId: this.teamId
1462
1612
  });
@@ -1466,7 +1616,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1466
1616
  * Creates or updates a custom AI property editor on a Mesh app.
1467
1617
  */
1468
1618
  async deploy(body) {
1469
- const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl));
1619
+ const fetchUri = this.createUrl(__privateGet3(_IntegrationPropertyEditorsClient2, _baseUrl));
1470
1620
  await this.apiClient(fetchUri, {
1471
1621
  method: "PUT",
1472
1622
  body: JSON.stringify({ ...body, teamId: this.teamId }),
@@ -1477,7 +1627,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1477
1627
  * Removes a custom AI property editor from a Mesh app.
1478
1628
  */
1479
1629
  async delete(body) {
1480
- const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl));
1630
+ const fetchUri = this.createUrl(__privateGet3(_IntegrationPropertyEditorsClient2, _baseUrl));
1481
1631
  await this.apiClient(fetchUri, {
1482
1632
  method: "DELETE",
1483
1633
  body: JSON.stringify({ ...body, teamId: this.teamId }),
@@ -1486,20 +1636,30 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1486
1636
  }
1487
1637
  };
1488
1638
  _baseUrl = /* @__PURE__ */ new WeakMap();
1489
- __privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
1639
+ __privateAdd3(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
1490
1640
  var _url22;
1641
+ var _projectsUrl;
1491
1642
  var _ProjectClient = class _ProjectClient2 extends ApiClient {
1492
1643
  constructor(options) {
1493
1644
  super({ ...options, bypassCache: true });
1494
1645
  }
1495
1646
  /** Fetches single Project */
1496
1647
  async get(options) {
1497
- const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22), { ...options });
1648
+ const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22), { ...options });
1649
+ return await this.apiClient(fetchUri);
1650
+ }
1651
+ /**
1652
+ * Fetches projects grouped by team.
1653
+ * When teamId is provided, returns a single team with its projects.
1654
+ * When omitted, returns all accessible teams and their projects.
1655
+ */
1656
+ async getProjects(options) {
1657
+ const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
1498
1658
  return await this.apiClient(fetchUri);
1499
1659
  }
1500
1660
  /** Updates or creates (based on id) a Project */
1501
1661
  async upsert(body) {
1502
- const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
1662
+ const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
1503
1663
  return await this.apiClient(fetchUri, {
1504
1664
  method: "PUT",
1505
1665
  body: JSON.stringify({ ...body })
@@ -1507,7 +1667,7 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1507
1667
  }
1508
1668
  /** Deletes a Project */
1509
1669
  async delete(body) {
1510
- const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
1670
+ const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
1511
1671
  await this.apiClient(fetchUri, {
1512
1672
  method: "DELETE",
1513
1673
  body: JSON.stringify({ ...body }),
@@ -1516,9 +1676,13 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1516
1676
  }
1517
1677
  };
1518
1678
  _url22 = /* @__PURE__ */ new WeakMap();
1519
- __privateAdd2(_ProjectClient, _url22, "/api/v1/project");
1679
+ _projectsUrl = /* @__PURE__ */ new WeakMap();
1680
+ __privateAdd3(_ProjectClient, _url22, "/api/v1/project");
1681
+ __privateAdd3(_ProjectClient, _projectsUrl, "/api/v1/projects");
1520
1682
  var isAllowedReferrer = (referrer) => {
1521
- return Boolean(referrer == null ? void 0 : referrer.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|localhost:\d{4})\//));
1683
+ return Boolean(
1684
+ referrer == null ? void 0 : referrer.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|uniformcode.ai|localhost:\d{4})\//)
1685
+ );
1522
1686
  };
1523
1687
 
1524
1688
  // src/handler/createPreviewGETRouteHandler.ts
@@ -1529,6 +1693,9 @@ import { NextResponse } from "next/server";
1529
1693
  // src/config/helpers.ts
1530
1694
  import config from "@uniformdev/next-app-router/config/resolved";
1531
1695
  var getMiddlewareRuntimeCache = () => {
1696
+ if (process.env.NODE_ENV === "development" && !process.env.RUNTIME_CACHE_ENDPOINT) {
1697
+ return false;
1698
+ }
1532
1699
  if (typeof config.middlewareRuntimeCache === "boolean") {
1533
1700
  return config.middlewareRuntimeCache;
1534
1701
  }
@@ -1658,8 +1825,17 @@ var createPreviewGETRouteHandler = (options) => {
1658
1825
  };
1659
1826
  };
1660
1827
  function validateLocalRedirectUrl(pathToRedirectTo) {
1661
- if (pathToRedirectTo == null ? void 0 : pathToRedirectTo.match(/^[a-z]+:\/\//g)) {
1662
- throw new Error("Tried to redirect to absolute URL with protocol. Disallowing open redirect.");
1828
+ if (!pathToRedirectTo) {
1829
+ return;
1830
+ }
1831
+ let resolved;
1832
+ try {
1833
+ resolved = new URL(pathToRedirectTo, BASE_URL_EXAMPLE);
1834
+ } catch (e) {
1835
+ throw new Error("Invalid redirect path. Disallowing open redirect.");
1836
+ }
1837
+ if (resolved.origin !== BASE_URL_EXAMPLE) {
1838
+ throw new Error("Tried to redirect off-origin. Disallowing open redirect.");
1663
1839
  }
1664
1840
  }
1665
1841
  var resolveFullPathDefault = ({ slug, path }) => {
@@ -1756,6 +1932,9 @@ var isDevelopmentEnvironment = () => {
1756
1932
  };
1757
1933
 
1758
1934
  // src/clients/cache.ts
1935
+ var isSpecificCacheMode = (options) => {
1936
+ return "cache" in options;
1937
+ };
1759
1938
  var isStateCacheMode = (options) => {
1760
1939
  return "state" in options;
1761
1940
  };
@@ -1777,7 +1956,9 @@ var resolveCache = ({
1777
1956
  }) => {
1778
1957
  let cache = void 0;
1779
1958
  if (options) {
1780
- if (isStateCacheMode(options)) {
1959
+ if (isSpecificCacheMode(options)) {
1960
+ cache = options.cache;
1961
+ } else if (isStateCacheMode(options)) {
1781
1962
  if (options.state === CANVAS_DRAFT_STATE || options.state === CANVAS_EDITOR_STATE) {
1782
1963
  cache = {
1783
1964
  type: "no-cache",
@@ -1896,7 +2077,7 @@ function createLimiter(concurrency) {
1896
2077
  });
1897
2078
  };
1898
2079
  }
1899
- async function retry(fn, options) {
2080
+ async function retry2(fn, options) {
1900
2081
  let lastError;
1901
2082
  let delay = 1e3;
1902
2083
  for (let attempt = 1; attempt <= options.retries + 1; attempt++) {
@@ -1936,7 +2117,7 @@ function createLimitPolicy2({
1936
2117
  }
1937
2118
  if (retryOptions) {
1938
2119
  const retryFunc = currentFunc;
1939
- currentFunc = () => retry(retryFunc, {
2120
+ currentFunc = () => retry2(retryFunc, {
1940
2121
  ...retryOptions,
1941
2122
  onFailedAttempt: async (error) => {
1942
2123
  if (retryOptions.onFailedAttempt) {
@@ -2010,14 +2191,14 @@ var getCanvasClient = (options) => {
2010
2191
  import "server-only";
2011
2192
 
2012
2193
  // ../project-map/dist/index.mjs
2013
- var __typeError3 = (msg) => {
2194
+ var __typeError4 = (msg) => {
2014
2195
  throw TypeError(msg);
2015
2196
  };
2016
- var __accessCheck3 = (obj, member, msg) => member.has(obj) || __typeError3("Cannot " + msg);
2017
- var __privateGet3 = (obj, member, getter) => (__accessCheck3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
2018
- 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);
2019
- var __privateSet = (obj, member, value, setter) => (__accessCheck3(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
2020
- var __privateMethod = (obj, member, method) => (__accessCheck3(obj, member, "access private method"), method);
2197
+ var __accessCheck4 = (obj, member, msg) => member.has(obj) || __typeError4("Cannot " + msg);
2198
+ var __privateGet4 = (obj, member, getter) => (__accessCheck4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
2199
+ var __privateAdd4 = (obj, member, value) => member.has(obj) ? __typeError4("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2200
+ var __privateSet2 = (obj, member, value, setter) => (__accessCheck4(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
2201
+ var __privateMethod = (obj, member, method) => (__accessCheck4(obj, member, "access private method"), method);
2021
2202
  var ProjectMapClient = class extends ApiClient {
2022
2203
  constructor(options) {
2023
2204
  super(options);
@@ -2164,12 +2345,12 @@ var isDynamicRouteSegment_fn;
2164
2345
  var _Route = class _Route2 {
2165
2346
  constructor(route) {
2166
2347
  this.route = route;
2167
- __privateAdd3(this, _routeInfo);
2348
+ __privateAdd4(this, _routeInfo);
2168
2349
  var _a;
2169
- __privateSet(this, _routeInfo, __privateMethod(_a = _Route2, _Route_static, parseRouteOrPath_fn).call(_a, this.route));
2350
+ __privateSet2(this, _routeInfo, __privateMethod(_a = _Route2, _Route_static, parseRouteOrPath_fn).call(_a, this.route));
2170
2351
  }
2171
2352
  get dynamicSegmentCount() {
2172
- return __privateGet3(this, _routeInfo).segments.reduce(
2353
+ return __privateGet4(this, _routeInfo).segments.reduce(
2173
2354
  (count, segment) => {
2174
2355
  var _a;
2175
2356
  return __privateMethod(_a = _Route2, _Route_static, isDynamicRouteSegment_fn).call(_a, segment) ? count + 1 : count;
@@ -2181,7 +2362,7 @@ var _Route = class _Route2 {
2181
2362
  matches(path) {
2182
2363
  var _a, _b;
2183
2364
  const { segments: pathSegments, queryParams: pathQuery } = __privateMethod(_a = _Route2, _Route_static, parseRouteOrPath_fn).call(_a, path);
2184
- const { segments: routeSegments } = __privateGet3(this, _routeInfo);
2365
+ const { segments: routeSegments } = __privateGet4(this, _routeInfo);
2185
2366
  if (pathSegments.length !== routeSegments.length) {
2186
2367
  return { match: false };
2187
2368
  }
@@ -2202,7 +2383,7 @@ var _Route = class _Route2 {
2202
2383
  return { match: false };
2203
2384
  }
2204
2385
  }
2205
- for (const [key, value] of __privateGet3(this, _routeInfo).queryParams) {
2386
+ for (const [key, value] of __privateGet4(this, _routeInfo).queryParams) {
2206
2387
  possibleMatch.queryParams[key] = pathQuery.has(key) ? pathQuery.get(key) : value;
2207
2388
  }
2208
2389
  return possibleMatch;
@@ -2212,7 +2393,7 @@ var _Route = class _Route2 {
2212
2393
  */
2213
2394
  expand(options) {
2214
2395
  const { dynamicInputValues = {}, allowedQueryParams = [], doNotEscapeVariables = false } = options != null ? options : {};
2215
- const path = __privateGet3(this, _routeInfo).segments.map((segment) => {
2396
+ const path = __privateGet4(this, _routeInfo).segments.map((segment) => {
2216
2397
  const dynamicSegmentName = _Route2.getDynamicRouteSegmentName(segment);
2217
2398
  if (!dynamicSegmentName) {
2218
2399
  return segment;
@@ -2242,6 +2423,35 @@ var _Route = class _Route2 {
2242
2423
  }
2243
2424
  return segment.slice(_Route2.dynamicSegmentPrefix.length);
2244
2425
  }
2426
+ /**
2427
+ * Splits a path into the path portion and an optional `#fragment`
2428
+ * (everything after the first `#`).
2429
+ *
2430
+ * Variable expressions (`${...}`) may legitimately contain `#` characters
2431
+ * (e.g. JSON-pointer tokens like `${#jptr:/foo/_slug}`), so the fragment
2432
+ * delimiter is the first `#` that falls outside of a variable expression.
2433
+ */
2434
+ static splitFragment(path) {
2435
+ let fragmentIndex = -1;
2436
+ parseVariableExpression(path, (token, type, offset) => {
2437
+ if (type === "variable") {
2438
+ return;
2439
+ }
2440
+ const hashOffset = token.indexOf("#");
2441
+ if (hashOffset === -1) {
2442
+ return;
2443
+ }
2444
+ fragmentIndex = offset + hashOffset;
2445
+ return false;
2446
+ });
2447
+ if (fragmentIndex === -1) {
2448
+ return { path, fragment: void 0 };
2449
+ }
2450
+ return {
2451
+ path: path.slice(0, fragmentIndex),
2452
+ fragment: path.slice(fragmentIndex + 1)
2453
+ };
2454
+ }
2245
2455
  };
2246
2456
  _routeInfo = /* @__PURE__ */ new WeakMap();
2247
2457
  _Route_static = /* @__PURE__ */ new WeakSet();
@@ -2263,7 +2473,7 @@ isDynamicRouteSegment_fn = function(segment) {
2263
2473
  }
2264
2474
  return segment.startsWith(_Route.dynamicSegmentPrefix);
2265
2475
  };
2266
- __privateAdd3(_Route, _Route_static);
2476
+ __privateAdd4(_Route, _Route_static);
2267
2477
  _Route.dynamicSegmentPrefix = ":";
2268
2478
  function encodeRouteComponent(value, doNotEscapeVariables) {
2269
2479
  if (!doNotEscapeVariables) {