@uniformdev/next-app-router 20.80.2 → 20.81.1-alpha.10.sha-def425616f

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.
Files changed (48) hide show
  1. package/dist/{UniformComposition-DBO-oo7J.d.ts → UniformComposition-ChDH4dMd.d.ts} +12 -31
  2. package/dist/{UniformComposition-le6UEB_r.d.mts → UniformComposition-Doa1kKRm.d.mts} +12 -31
  3. package/dist/cache.d.mts +24 -6
  4. package/dist/cache.d.ts +24 -6
  5. package/dist/cache.js +396 -832
  6. package/dist/cache.mjs +391 -830
  7. package/dist/compat.d.mts +2 -4
  8. package/dist/compat.d.ts +2 -4
  9. package/dist/component.d.mts +10 -1
  10. package/dist/component.d.ts +10 -1
  11. package/dist/component.js +113 -617
  12. package/dist/component.mjs +112 -640
  13. package/dist/composition-CGU7iH-k.d.mts +37 -0
  14. package/dist/composition-CGU7iH-k.d.ts +37 -0
  15. package/dist/config/default.js +0 -1
  16. package/dist/config/default.mjs +0 -1
  17. package/dist/createCachedManifestProvider-2-2u3PYd.d.mts +84 -0
  18. package/dist/createCachedManifestProvider-BoorKD15.d.ts +84 -0
  19. package/dist/edge.d.mts +80 -0
  20. package/dist/edge.d.ts +80 -0
  21. package/dist/edge.js +1225 -0
  22. package/dist/edge.mjs +1191 -0
  23. package/dist/handler.d.mts +15 -2
  24. package/dist/handler.d.ts +15 -2
  25. package/dist/handler.js +134 -628
  26. package/dist/handler.mjs +132 -626
  27. package/dist/index.d.mts +81 -41
  28. package/dist/index.d.ts +81 -41
  29. package/dist/index.esm.js +2051 -5614
  30. package/dist/index.js +2092 -5651
  31. package/dist/index.mjs +2051 -5614
  32. package/dist/middleware.d.mts +60 -13
  33. package/dist/middleware.d.ts +60 -13
  34. package/dist/middleware.js +415 -5746
  35. package/dist/middleware.mjs +422 -5776
  36. package/dist/models-C8OdCO44.d.mts +72 -0
  37. package/dist/models-C8OdCO44.d.ts +72 -0
  38. package/dist/resolveRouteFromPath-CnfnaxY2.d.ts +80 -0
  39. package/dist/resolveRouteFromPath-_rauUskz.d.mts +80 -0
  40. package/dist/vercel.d.mts +37 -0
  41. package/dist/vercel.d.ts +37 -0
  42. package/dist/vercel.js +788 -0
  43. package/dist/vercel.mjs +759 -0
  44. package/package.json +37 -9
  45. package/dist/client-BElN_CWD.d.mts +0 -786
  46. package/dist/client-BElN_CWD.d.ts +0 -786
  47. package/dist/resolveRouteFromCode-BOvjIvM2.d.ts +0 -18
  48. package/dist/resolveRouteFromCode-CuJ4JHeb.d.mts +0 -18
package/dist/handler.js CHANGED
@@ -47,124 +47,6 @@ var __privateWrapper = (obj, member, setter, getter) => ({
47
47
  }
48
48
  });
49
49
 
50
- // ../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js
51
- var require_yocto_queue = __commonJS({
52
- "../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports2, module2) {
53
- "use strict";
54
- var Node2 = class {
55
- /// value;
56
- /// next;
57
- constructor(value) {
58
- this.value = value;
59
- this.next = void 0;
60
- }
61
- };
62
- var Queue2 = class {
63
- // TODO: Use private class fields when targeting Node.js 12.
64
- // #_head;
65
- // #_tail;
66
- // #_size;
67
- constructor() {
68
- this.clear();
69
- }
70
- enqueue(value) {
71
- const node = new Node2(value);
72
- if (this._head) {
73
- this._tail.next = node;
74
- this._tail = node;
75
- } else {
76
- this._head = node;
77
- this._tail = node;
78
- }
79
- this._size++;
80
- }
81
- dequeue() {
82
- const current = this._head;
83
- if (!current) {
84
- return;
85
- }
86
- this._head = this._head.next;
87
- this._size--;
88
- return current.value;
89
- }
90
- clear() {
91
- this._head = void 0;
92
- this._tail = void 0;
93
- this._size = 0;
94
- }
95
- get size() {
96
- return this._size;
97
- }
98
- *[Symbol.iterator]() {
99
- let current = this._head;
100
- while (current) {
101
- yield current.value;
102
- current = current.next;
103
- }
104
- }
105
- };
106
- module2.exports = Queue2;
107
- }
108
- });
109
-
110
- // ../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js
111
- var require_p_limit = __commonJS({
112
- "../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports2, module2) {
113
- "use strict";
114
- var Queue2 = require_yocto_queue();
115
- var pLimit3 = (concurrency) => {
116
- if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
117
- throw new TypeError("Expected `concurrency` to be a number from 1 and up");
118
- }
119
- const queue = new Queue2();
120
- let activeCount = 0;
121
- const next = () => {
122
- activeCount--;
123
- if (queue.size > 0) {
124
- queue.dequeue()();
125
- }
126
- };
127
- const run = async (fn, resolve, ...args) => {
128
- activeCount++;
129
- const result = (async () => fn(...args))();
130
- resolve(result);
131
- try {
132
- await result;
133
- } catch (e) {
134
- }
135
- next();
136
- };
137
- const enqueue = (fn, resolve, ...args) => {
138
- queue.enqueue(run.bind(null, fn, resolve, ...args));
139
- (async () => {
140
- await Promise.resolve();
141
- if (activeCount < concurrency && queue.size > 0) {
142
- queue.dequeue()();
143
- }
144
- })();
145
- };
146
- const generator = (fn, ...args) => new Promise((resolve) => {
147
- enqueue(fn, resolve, ...args);
148
- });
149
- Object.defineProperties(generator, {
150
- activeCount: {
151
- get: () => activeCount
152
- },
153
- pendingCount: {
154
- get: () => queue.size
155
- },
156
- clearQueue: {
157
- value: () => {
158
- queue.clear();
159
- }
160
- }
161
- });
162
- return generator;
163
- };
164
- module2.exports = pLimit3;
165
- }
166
- });
167
-
168
50
  // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js
169
51
  var require_retry_operation = __commonJS({
170
52
  "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports2, module2) {
@@ -405,432 +287,9 @@ __export(handler_exports, {
405
287
  });
406
288
  module.exports = __toCommonJS(handler_exports);
407
289
 
408
- // ../context/dist/api/api.mjs
409
- var import_p_limit = __toESM(require_p_limit(), 1);
410
- var __defProp2 = Object.defineProperty;
411
- var __typeError2 = (msg) => {
412
- throw TypeError(msg);
413
- };
414
- var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
415
- var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
416
- var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
417
- var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
418
- 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);
419
- var defaultLimitPolicy = (0, import_p_limit.default)(6);
420
- var UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE = "Bearer token not valid or expired";
421
- var ApiClientError = class _ApiClientError extends Error {
422
- constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
423
- super(
424
- `${errorMessage}
425
- ${statusCode}${statusText ? " " + statusText : ""} (${fetchMethod} ${fetchUri}${requestId ? ` Request ID: ${requestId}` : ""})`
426
- );
427
- __publicField2(this, "errorMessage", errorMessage);
428
- __publicField2(this, "fetchMethod", fetchMethod);
429
- __publicField2(this, "fetchUri", fetchUri);
430
- __publicField2(this, "statusCode", statusCode);
431
- __publicField2(this, "statusText", statusText);
432
- __publicField2(this, "requestId", requestId);
433
- Object.setPrototypeOf(this, _ApiClientError.prototype);
434
- }
435
- };
436
- var BearerTokenNotValidOrExpiredError = class _BearerTokenNotValidOrExpiredError extends ApiClientError {
437
- constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
438
- super(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId);
439
- Object.setPrototypeOf(this, _BearerTokenNotValidOrExpiredError.prototype);
440
- }
441
- };
442
- var ApiClient = class _ApiClient {
443
- constructor(options) {
444
- __publicField2(this, "options");
445
- var _a, _b, _c, _d, _e;
446
- if (!options.apiKey && !options.bearerToken) {
447
- throw new Error("You must provide an API key or a bearer token");
448
- }
449
- let leFetch = options.fetch;
450
- if (!leFetch) {
451
- if (typeof window !== "undefined") {
452
- leFetch = window.fetch.bind(window);
453
- } else if (typeof fetch !== "undefined") {
454
- leFetch = fetch;
455
- } else {
456
- throw new Error("You must provide or polyfill a fetch implementation when not in a browser");
457
- }
458
- }
459
- this.options = {
460
- ...options,
461
- fetch: leFetch,
462
- apiHost: this.ensureApiHost(options.apiHost),
463
- apiKey: (_a = options.apiKey) != null ? _a : null,
464
- projectId: (_b = options.projectId) != null ? _b : null,
465
- bearerToken: (_c = options.bearerToken) != null ? _c : null,
466
- limitPolicy: (_d = options.limitPolicy) != null ? _d : defaultLimitPolicy,
467
- bypassCache: (_e = options.bypassCache) != null ? _e : false
468
- };
469
- }
470
- async apiClient(fetchUri, options) {
471
- return (await this.apiClientWithResponse(fetchUri, options)).body;
472
- }
473
- async apiClientWithResponse(fetchUri, options) {
474
- return this.options.limitPolicy(async () => {
475
- var _a, _b;
476
- const coreHeaders = this.options.apiKey ? {
477
- "x-api-key": this.options.apiKey
478
- } : {
479
- Authorization: `Bearer ${this.options.bearerToken}`
480
- };
481
- if (this.options.bypassCache) {
482
- coreHeaders["x-bypass-cache"] = "true";
483
- }
484
- const { fetch: fetch2, signal } = this.options;
485
- const callApi = () => fetch2(fetchUri.toString(), {
486
- ...options,
487
- signal,
488
- headers: {
489
- ...options == null ? void 0 : options.headers,
490
- ...coreHeaders
491
- }
492
- });
493
- const apiResponse = await handleRateLimits(callApi);
494
- if (!apiResponse.ok) {
495
- let message = "";
496
- try {
497
- const responseText = await apiResponse.text();
498
- try {
499
- const parsed = JSON.parse(responseText);
500
- if (parsed.errorMessage) {
501
- message = Array.isArray(parsed.errorMessage) ? parsed.errorMessage.join(", ") : parsed.errorMessage;
502
- } else {
503
- message = responseText;
504
- }
505
- } catch (e) {
506
- message = responseText;
507
- }
508
- } catch (e) {
509
- message = `General error`;
510
- }
511
- if (apiResponse.status === 401 && message === UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE) {
512
- throw new BearerTokenNotValidOrExpiredError(
513
- message,
514
- (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
515
- fetchUri.toString(),
516
- apiResponse.status,
517
- apiResponse.statusText,
518
- _ApiClient.getRequestId(apiResponse)
519
- );
520
- }
521
- throw new ApiClientError(
522
- message,
523
- (_b = options == null ? void 0 : options.method) != null ? _b : "GET",
524
- fetchUri.toString(),
525
- apiResponse.status,
526
- apiResponse.statusText,
527
- _ApiClient.getRequestId(apiResponse)
528
- );
529
- }
530
- if (options == null ? void 0 : options.expectNoContent) {
531
- return { response: apiResponse, body: null };
532
- }
533
- return {
534
- response: apiResponse,
535
- body: await apiResponse.json()
536
- };
537
- });
538
- }
539
- createUrl(path, queryParams, hostOverride) {
540
- const url = new URL(`${hostOverride != null ? hostOverride : this.options.apiHost}${path}`);
541
- Object.entries(queryParams != null ? queryParams : {}).forEach(([key, value]) => {
542
- var _a;
543
- if (typeof value !== "undefined" && value !== null) {
544
- url.searchParams.append(key, Array.isArray(value) ? value.join(",") : (_a = value == null ? void 0 : value.toString()) != null ? _a : "");
545
- }
546
- });
547
- return url;
548
- }
549
- ensureApiHost(apiHost) {
550
- if (!apiHost) return "https://uniform.app";
551
- if (!(apiHost == null ? void 0 : apiHost.startsWith("http"))) {
552
- throw new Error('Your apiHost must start with "http"');
553
- }
554
- if (apiHost.indexOf("/", 8) > -1) {
555
- throw new Error("Your apiHost must not contain a path element after the domain");
556
- }
557
- if (apiHost.indexOf("?") > -1) {
558
- throw new Error("Your apiHost must not contain a query string");
559
- }
560
- if (apiHost == null ? void 0 : apiHost.endsWith("/")) {
561
- apiHost = apiHost.substring(0, apiHost.length - 1);
562
- }
563
- return apiHost;
564
- }
565
- static getRequestId(response) {
566
- const apigRequestId = response.headers.get("apigw-requestid");
567
- if (apigRequestId) {
568
- return apigRequestId;
569
- }
570
- return void 0;
571
- }
572
- };
573
- async function handleRateLimits(callApi) {
574
- var _a;
575
- const backoffRetries = 5;
576
- let backoffRetriesLeft = backoffRetries;
577
- let response;
578
- while (backoffRetriesLeft > 0) {
579
- response = await callApi();
580
- if (response.status !== 429) {
581
- break;
582
- }
583
- let resetWait = 0;
584
- try {
585
- const responseClone = response.clone();
586
- const dateHeader = responseClone.headers.get("date");
587
- const serverTime = dateHeader ? new Date(dateHeader).getTime() : void 0;
588
- const body = await responseClone.json();
589
- const resetTime = (_a = body == null ? void 0 : body.info) == null ? void 0 : _a.reset;
590
- if (typeof serverTime === "number" && typeof resetTime === "number") {
591
- resetWait = Math.max(0, Math.min(Math.round(1.1 * (resetTime - serverTime)), 1e4));
592
- }
593
- } catch (e) {
594
- }
595
- const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
596
- const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
597
- await new Promise((resolve) => setTimeout(resolve, Math.max(0, resetWait + backoffWait)));
598
- backoffRetriesLeft -= 1;
599
- }
600
- return response;
601
- }
602
- var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
603
- function rewriteFiltersForApi(filters) {
604
- return Object.entries(filters != null ? filters : {}).reduce(
605
- (acc, [key, value]) => {
606
- const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
607
- const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
608
- return {
609
- ...acc,
610
- [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
611
- };
612
- },
613
- {}
614
- );
615
- }
616
- var _url;
617
- var _AggregateClient = class _AggregateClient2 extends ApiClient {
618
- constructor(options) {
619
- super(options);
620
- }
621
- /** Fetches all aggregates for a project */
622
- async get(options) {
623
- const { projectId } = this.options;
624
- const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url), { ...options, projectId });
625
- return await this.apiClient(fetchUri);
626
- }
627
- /** Updates or creates (based on id) an Aggregate */
628
- async upsert(body) {
629
- const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url));
630
- await this.apiClient(fetchUri, {
631
- method: "PUT",
632
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
633
- expectNoContent: true
634
- });
635
- }
636
- /** Deletes an Aggregate */
637
- async remove(body) {
638
- const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url));
639
- await this.apiClient(fetchUri, {
640
- method: "DELETE",
641
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
642
- expectNoContent: true
643
- });
644
- }
645
- };
646
- _url = /* @__PURE__ */ new WeakMap();
647
- __privateAdd2(_AggregateClient, _url, "/api/v2/aggregate");
648
- var _url2;
649
- var _DimensionClient = class _DimensionClient2 extends ApiClient {
650
- constructor(options) {
651
- super(options);
652
- }
653
- /** Fetches the known score dimensions for a project */
654
- async get(options) {
655
- const { projectId } = this.options;
656
- const fetchUri = this.createUrl(__privateGet2(_DimensionClient2, _url2), { ...options, projectId });
657
- return await this.apiClient(fetchUri);
658
- }
659
- };
660
- _url2 = /* @__PURE__ */ new WeakMap();
661
- __privateAdd2(_DimensionClient, _url2, "/api/v2/dimension");
662
- var _url3;
663
- var _valueUrl;
664
- var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
665
- constructor(options) {
666
- super(options);
667
- }
668
- /** Fetches all enrichments and values for a project, grouped by category */
669
- async get(options) {
670
- const { projectId } = this.options;
671
- const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3), { ...options, projectId });
672
- return await this.apiClient(fetchUri);
673
- }
674
- /** Updates or creates (based on id) an enrichment category */
675
- async upsertCategory(body) {
676
- const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3));
677
- await this.apiClient(fetchUri, {
678
- method: "PUT",
679
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
680
- expectNoContent: true
681
- });
682
- }
683
- /** Deletes an enrichment category */
684
- async removeCategory(body) {
685
- const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3));
686
- await this.apiClient(fetchUri, {
687
- method: "DELETE",
688
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
689
- expectNoContent: true
690
- });
691
- }
692
- /** Updates or creates (based on id) an enrichment value within an enrichment category */
693
- async upsertValue(body) {
694
- const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _valueUrl));
695
- await this.apiClient(fetchUri, {
696
- method: "PUT",
697
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
698
- expectNoContent: true
699
- });
700
- }
701
- /** Deletes an enrichment value within an enrichment category. The category is left alone. */
702
- async removeValue(body) {
703
- const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _valueUrl));
704
- await this.apiClient(fetchUri, {
705
- method: "DELETE",
706
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
707
- expectNoContent: true
708
- });
709
- }
710
- };
711
- _url3 = /* @__PURE__ */ new WeakMap();
712
- _valueUrl = /* @__PURE__ */ new WeakMap();
713
- __privateAdd2(_EnrichmentClient, _url3, "/api/v1/enrichments");
714
- __privateAdd2(_EnrichmentClient, _valueUrl, "/api/v1/enrichment-values");
715
- var _url4;
716
- var _ManifestClient = class _ManifestClient2 extends ApiClient {
717
- constructor(options) {
718
- super(options);
719
- }
720
- /** Fetches the Context manifest for a project */
721
- async get(options) {
722
- const { projectId } = this.options;
723
- const fetchUri = this.createUrl(__privateGet2(_ManifestClient2, _url4), { ...options, projectId });
724
- return await this.apiClient(fetchUri);
725
- }
726
- /** Publishes the Context manifest for a project */
727
- async publish() {
728
- const { projectId } = this.options;
729
- const fetchUri = this.createUrl("/api/v1/publish", { siteId: projectId });
730
- await this.apiClient(fetchUri, {
731
- method: "POST",
732
- expectNoContent: true
733
- });
734
- }
735
- };
736
- _url4 = /* @__PURE__ */ new WeakMap();
737
- __privateAdd2(_ManifestClient, _url4, "/api/v2/manifest");
738
- var _url5;
739
- var _QuirkClient = class _QuirkClient2 extends ApiClient {
740
- constructor(options) {
741
- super(options);
742
- }
743
- /** Fetches all Quirks for a project */
744
- async get(options) {
745
- const { projectId } = this.options;
746
- const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5), { ...options, projectId });
747
- return await this.apiClient(fetchUri);
748
- }
749
- /** Updates or creates (based on id) a Quirk */
750
- async upsert(body) {
751
- const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5));
752
- await this.apiClient(fetchUri, {
753
- method: "PUT",
754
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
755
- expectNoContent: true
756
- });
757
- }
758
- /** Deletes a Quirk */
759
- async remove(body) {
760
- const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5));
761
- await this.apiClient(fetchUri, {
762
- method: "DELETE",
763
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
764
- expectNoContent: true
765
- });
766
- }
767
- };
768
- _url5 = /* @__PURE__ */ new WeakMap();
769
- __privateAdd2(_QuirkClient, _url5, "/api/v2/quirk");
770
- var _url6;
771
- var _SignalClient = class _SignalClient2 extends ApiClient {
772
- constructor(options) {
773
- super(options);
774
- }
775
- /** Fetches all Signals for a project */
776
- async get(options) {
777
- const { projectId } = this.options;
778
- const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6), { ...options, projectId });
779
- return await this.apiClient(fetchUri);
780
- }
781
- /** Updates or creates (based on id) a Signal */
782
- async upsert(body) {
783
- const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6));
784
- await this.apiClient(fetchUri, {
785
- method: "PUT",
786
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
787
- expectNoContent: true
788
- });
789
- }
790
- /** Deletes a Signal */
791
- async remove(body) {
792
- const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6));
793
- await this.apiClient(fetchUri, {
794
- method: "DELETE",
795
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
796
- expectNoContent: true
797
- });
798
- }
799
- };
800
- _url6 = /* @__PURE__ */ new WeakMap();
801
- __privateAdd2(_SignalClient, _url6, "/api/v2/signal");
802
- var _url7;
803
- var _TestClient = class _TestClient2 extends ApiClient {
804
- constructor(options) {
805
- super(options);
806
- }
807
- /** Fetches all Tests for a project */
808
- async get(options) {
809
- const { projectId } = this.options;
810
- const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7), { ...options, projectId });
811
- return await this.apiClient(fetchUri);
812
- }
813
- /** Updates or creates (based on id) a Test */
814
- async upsert(body) {
815
- const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7));
816
- await this.apiClient(fetchUri, {
817
- method: "PUT",
818
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
819
- expectNoContent: true
820
- });
821
- }
822
- /** Deletes a Test */
823
- async remove(body) {
824
- const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7));
825
- await this.apiClient(fetchUri, {
826
- method: "DELETE",
827
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
828
- expectNoContent: true
829
- });
830
- }
831
- };
832
- _url7 = /* @__PURE__ */ new WeakMap();
833
- __privateAdd2(_TestClient, _url7, "/api/v2/test");
290
+ // ../canvas/dist/index.mjs
291
+ var import_api = require("@uniformdev/context/api");
292
+ var import_api2 = require("@uniformdev/context/api");
834
293
 
835
294
  // ../../node_modules/.pnpm/yocto-queue@1.2.2/node_modules/yocto-queue/index.js
836
295
  var Node = class {
@@ -903,7 +362,7 @@ _tail = new WeakMap();
903
362
  _size = new WeakMap();
904
363
 
905
364
  // ../../node_modules/.pnpm/p-limit@6.2.0/node_modules/p-limit/index.js
906
- function pLimit2(concurrency) {
365
+ function pLimit(concurrency) {
907
366
  validateConcurrency(concurrency);
908
367
  const queue = new Queue();
909
368
  let activeCount = 0;
@@ -1183,19 +642,44 @@ function pThrottle({ limit, interval, strict, onDelay }) {
1183
642
  }
1184
643
 
1185
644
  // ../canvas/dist/index.mjs
1186
- var __typeError3 = (msg) => {
645
+ var import_api3 = require("@uniformdev/context/api");
646
+ var import_api4 = require("@uniformdev/context/api");
647
+ var import_api5 = require("@uniformdev/context/api");
648
+ var import_api6 = require("@uniformdev/context/api");
649
+ var import_api7 = require("@uniformdev/context/api");
650
+ var import_api8 = require("@uniformdev/context/api");
651
+ var import_api9 = require("@uniformdev/context/api");
652
+ var import_api10 = require("@uniformdev/context/api");
653
+ var import_api11 = require("@uniformdev/context/api");
654
+ var import_api12 = require("@uniformdev/context/api");
655
+ var import_api13 = require("@uniformdev/context/api");
656
+ var import_api14 = require("@uniformdev/context/api");
657
+ var import_api15 = require("@uniformdev/context/api");
658
+ var import_api16 = require("@uniformdev/context/api");
659
+ var import_api17 = require("@uniformdev/context/api");
660
+ var import_api18 = require("@uniformdev/context/api");
661
+ var import_api19 = require("@uniformdev/context/api");
662
+ var import_api20 = require("@uniformdev/context/api");
663
+ var import_api21 = require("@uniformdev/context/api");
664
+ var import_api22 = require("@uniformdev/context/api");
665
+ var import_api23 = require("@uniformdev/context/api");
666
+ var import_api24 = require("@uniformdev/context/api");
667
+ var import_api25 = require("@uniformdev/context/api");
668
+ var import_api26 = require("@uniformdev/context/api");
669
+ var import_api27 = require("@uniformdev/context/api");
670
+ var __typeError2 = (msg) => {
1187
671
  throw TypeError(msg);
1188
672
  };
1189
- var __accessCheck3 = (obj, member, msg) => member.has(obj) || __typeError3("Cannot " + msg);
1190
- var __privateGet3 = (obj, member, getter) => (__accessCheck3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1191
- 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);
673
+ var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
674
+ var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
675
+ 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);
1192
676
  function createLimitPolicy({
1193
677
  throttle = { interval: 1e3, limit: 10 },
1194
678
  retry: retry3 = { retries: 1, factor: 1.66 },
1195
679
  limit = 10
1196
680
  }) {
1197
681
  const throttler = throttle ? pThrottle(throttle) : null;
1198
- const limiter = limit ? pLimit2(limit) : null;
682
+ const limiter = limit ? pLimit(limit) : null;
1199
683
  return function limitPolicy(func) {
1200
684
  let currentFunc = async () => await func();
1201
685
  if (throttler) {
@@ -1214,7 +698,7 @@ function createLimitPolicy({
1214
698
  if (retry3.onFailedAttempt) {
1215
699
  await retry3.onFailedAttempt(error);
1216
700
  }
1217
- if (error instanceof ApiClientError && typeof error.statusCode === "number" && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429 && error.statusCode !== 408) {
701
+ if (error instanceof import_api2.ApiClientError && typeof error.statusCode === "number" && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429 && error.statusCode !== 408) {
1218
702
  throw error;
1219
703
  }
1220
704
  }
@@ -1223,7 +707,7 @@ function createLimitPolicy({
1223
707
  return currentFunc();
1224
708
  };
1225
709
  }
1226
- var ContentClientBase = class extends ApiClient {
710
+ var ContentClientBase = class extends import_api4.ApiClient {
1227
711
  constructor(options, defaultBypassCache) {
1228
712
  var _a, _b;
1229
713
  super({
@@ -1356,7 +840,7 @@ var CompositionDeliveryClient = class extends DeliveryClientBase {
1356
840
  EDGE_LIST_URL,
1357
841
  {
1358
842
  ...rest,
1359
- ...rewriteFiltersForApi(filters),
843
+ ...(0, import_api5.rewriteFiltersForApi)(filters),
1360
844
  ...projectionToQuery(select),
1361
845
  projectId: this.options.projectId,
1362
846
  state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
@@ -1369,7 +853,7 @@ var CompositionDeliveryClient = class extends DeliveryClientBase {
1369
853
  };
1370
854
  var _contentTypesUrl;
1371
855
  var _entriesUrl;
1372
- var _ContentClient = class _ContentClient2 extends ApiClient {
856
+ var _ContentClient = class _ContentClient2 extends import_api12.ApiClient {
1373
857
  constructor(options) {
1374
858
  var _a;
1375
859
  super(options);
@@ -1377,16 +861,16 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1377
861
  }
1378
862
  getContentTypes(options) {
1379
863
  const { projectId } = this.options;
1380
- const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _contentTypesUrl), { ...options, projectId });
864
+ const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl), { ...options, projectId });
1381
865
  return this.apiClient(fetchUri);
1382
866
  }
1383
867
  getEntries(options) {
1384
868
  const { projectId } = this.options;
1385
869
  const { skipDataResolution, filters, select, ...params } = options;
1386
- const rewrittenFilters = rewriteFiltersForApi(filters);
870
+ const rewrittenFilters = (0, import_api12.rewriteFiltersForApi)(filters);
1387
871
  const rewrittenSelect = projectionToQuery(select);
1388
872
  if (skipDataResolution) {
1389
- const url = this.createUrl(__privateGet3(_ContentClient2, _entriesUrl), {
873
+ const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), {
1390
874
  ...params,
1391
875
  ...rewrittenFilters,
1392
876
  ...rewrittenSelect,
@@ -1395,7 +879,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1395
879
  return this.apiClient(url);
1396
880
  }
1397
881
  const edgeUrl = this.createUrl(
1398
- __privateGet3(_ContentClient2, _entriesUrl),
882
+ __privateGet2(_ContentClient2, _entriesUrl),
1399
883
  { ...this.getEdgeOptions(params), ...rewrittenFilters, ...rewrittenSelect },
1400
884
  this.edgeApiHost
1401
885
  );
@@ -1413,7 +897,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1413
897
  return this.apiClient(historyUrl);
1414
898
  }
1415
899
  async upsertContentType(body, opts = {}) {
1416
- const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _contentTypesUrl));
900
+ const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl));
1417
901
  if (typeof body.contentType.slugSettings === "object" && body.contentType.slugSettings !== null && Object.keys(body.contentType.slugSettings).length === 0) {
1418
902
  delete body.contentType.slugSettings;
1419
903
  }
@@ -1425,7 +909,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1425
909
  });
1426
910
  }
1427
911
  async upsertEntry(body, options) {
1428
- const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _entriesUrl));
912
+ const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl));
1429
913
  const headers = {};
1430
914
  if (options == null ? void 0 : options.ifUnmodifiedSince) {
1431
915
  headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
@@ -1439,7 +923,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1439
923
  return { modified: response.headers.get("x-modified-at") };
1440
924
  }
1441
925
  async deleteContentType(body) {
1442
- const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _contentTypesUrl));
926
+ const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl));
1443
927
  await this.apiClient(fetchUri, {
1444
928
  method: "DELETE",
1445
929
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1447,7 +931,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1447
931
  });
1448
932
  }
1449
933
  async deleteEntry(body) {
1450
- const fetchUri = this.createUrl(__privateGet3(_ContentClient2, _entriesUrl));
934
+ const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl));
1451
935
  await this.apiClient(fetchUri, {
1452
936
  method: "DELETE",
1453
937
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1466,17 +950,17 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1466
950
  };
1467
951
  _contentTypesUrl = /* @__PURE__ */ new WeakMap();
1468
952
  _entriesUrl = /* @__PURE__ */ new WeakMap();
1469
- __privateAdd3(_ContentClient, _contentTypesUrl, "/api/v1/content-types");
1470
- __privateAdd3(_ContentClient, _entriesUrl, "/api/v1/entries");
1471
- var _url8;
1472
- var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
953
+ __privateAdd2(_ContentClient, _contentTypesUrl, "/api/v1/content-types");
954
+ __privateAdd2(_ContentClient, _entriesUrl, "/api/v1/entries");
955
+ var _url;
956
+ var _DataTypeClient = class _DataTypeClient2 extends import_api14.ApiClient {
1473
957
  constructor(options) {
1474
958
  super(options);
1475
959
  }
1476
960
  /** Fetches a list of DataTypes for a project */
1477
961
  async list(options) {
1478
962
  const { projectId } = this.options;
1479
- const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8), { ...options, projectId });
963
+ const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url), { ...options, projectId });
1480
964
  return await this.apiClient(fetchUri);
1481
965
  }
1482
966
  /** @deprecated Use {@link list} instead. */
@@ -1485,7 +969,7 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1485
969
  }
1486
970
  /** Updates or creates (based on id) a DataType */
1487
971
  async save(body) {
1488
- const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
972
+ const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url));
1489
973
  await this.apiClient(fetchUri, {
1490
974
  method: "PUT",
1491
975
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1498,7 +982,7 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1498
982
  }
1499
983
  /** Deletes a DataType */
1500
984
  async remove(body) {
1501
- const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
985
+ const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url));
1502
986
  await this.apiClient(fetchUri, {
1503
987
  method: "DELETE",
1504
988
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
@@ -1506,8 +990,8 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1506
990
  });
1507
991
  }
1508
992
  };
1509
- _url8 = /* @__PURE__ */ new WeakMap();
1510
- __privateAdd3(_DataTypeClient, _url8, "/api/v1/data-types");
993
+ _url = /* @__PURE__ */ new WeakMap();
994
+ __privateAdd2(_DataTypeClient, _url, "/api/v1/data-types");
1511
995
  var variablePrefix = "${";
1512
996
  var variableSuffix = "}";
1513
997
  var escapeCharacter = "\\";
@@ -1585,7 +1069,7 @@ function createVariableReference(variableName) {
1585
1069
  return `\${${variableName.replace(/([${}])/g, "\\$1")}}`;
1586
1070
  }
1587
1071
  var _baseUrl;
1588
- var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2 extends ApiClient {
1072
+ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2 extends import_api16.ApiClient {
1589
1073
  constructor(options) {
1590
1074
  super(options);
1591
1075
  this.teamId = options.teamId;
@@ -1594,7 +1078,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1594
1078
  * Gets a list of property type and hook names for the current team, including public integrations' hooks.
1595
1079
  */
1596
1080
  get(options) {
1597
- const fetchUri = this.createUrl(__privateGet3(_IntegrationPropertyEditorsClient2, _baseUrl), {
1081
+ const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl), {
1598
1082
  ...options,
1599
1083
  teamId: this.teamId
1600
1084
  });
@@ -1604,7 +1088,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1604
1088
  * Creates or updates a custom AI property editor on a Mesh app.
1605
1089
  */
1606
1090
  async deploy(body) {
1607
- const fetchUri = this.createUrl(__privateGet3(_IntegrationPropertyEditorsClient2, _baseUrl));
1091
+ const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl));
1608
1092
  await this.apiClient(fetchUri, {
1609
1093
  method: "PUT",
1610
1094
  body: JSON.stringify({ ...body, teamId: this.teamId }),
@@ -1615,7 +1099,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1615
1099
  * Removes a custom AI property editor from a Mesh app.
1616
1100
  */
1617
1101
  async delete(body) {
1618
- const fetchUri = this.createUrl(__privateGet3(_IntegrationPropertyEditorsClient2, _baseUrl));
1102
+ const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl));
1619
1103
  await this.apiClient(fetchUri, {
1620
1104
  method: "DELETE",
1621
1105
  body: JSON.stringify({ ...body, teamId: this.teamId }),
@@ -1624,16 +1108,16 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1624
1108
  }
1625
1109
  };
1626
1110
  _baseUrl = /* @__PURE__ */ new WeakMap();
1627
- __privateAdd3(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
1628
- var _url22;
1111
+ __privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
1112
+ var _url2;
1629
1113
  var _projectsUrl;
1630
- var _ProjectClient = class _ProjectClient2 extends ApiClient {
1114
+ var _ProjectClient = class _ProjectClient2 extends import_api20.ApiClient {
1631
1115
  constructor(options) {
1632
1116
  super({ ...options, bypassCache: true });
1633
1117
  }
1634
1118
  /** Fetches single Project */
1635
1119
  async get(options) {
1636
- const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22), { ...options });
1120
+ const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url2), { ...options });
1637
1121
  return await this.apiClient(fetchUri);
1638
1122
  }
1639
1123
  /**
@@ -1642,7 +1126,7 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1642
1126
  * When omitted, returns all accessible teams and their projects.
1643
1127
  */
1644
1128
  async list(options) {
1645
- const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
1129
+ const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
1646
1130
  return await this.apiClient(fetchUri);
1647
1131
  }
1648
1132
  /** @deprecated Use {@link list} instead. */
@@ -1651,7 +1135,7 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1651
1135
  }
1652
1136
  /** Updates or creates (based on id) a Project */
1653
1137
  async save(body) {
1654
- const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
1138
+ const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url2));
1655
1139
  return await this.apiClient(fetchUri, {
1656
1140
  method: "PUT",
1657
1141
  body: JSON.stringify({ ...body })
@@ -1663,7 +1147,7 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1663
1147
  }
1664
1148
  /** Deletes a Project */
1665
1149
  async remove(body) {
1666
- const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
1150
+ const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url2));
1667
1151
  await this.apiClient(fetchUri, {
1668
1152
  method: "DELETE",
1669
1153
  body: JSON.stringify({ ...body }),
@@ -1675,10 +1159,10 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1675
1159
  return this.remove(body);
1676
1160
  }
1677
1161
  };
1678
- _url22 = /* @__PURE__ */ new WeakMap();
1162
+ _url2 = /* @__PURE__ */ new WeakMap();
1679
1163
  _projectsUrl = /* @__PURE__ */ new WeakMap();
1680
- __privateAdd3(_ProjectClient, _url22, "/api/v1/project");
1681
- __privateAdd3(_ProjectClient, _projectsUrl, "/api/v1/projects");
1164
+ __privateAdd2(_ProjectClient, _url2, "/api/v1/project");
1165
+ __privateAdd2(_ProjectClient, _projectsUrl, "/api/v1/projects");
1682
1166
  var ALLOWED_REFERRER_ORIGIN = /^https:\/\/([\w-]+\.)*(uniform\.(app|wtf)|uniformcode\.ai)$|^https?:\/\/localhost:\d{4}$/;
1683
1167
  var isAllowedReferrer = (referrer) => {
1684
1168
  try {
@@ -1695,15 +1179,6 @@ var import_server = require("next/server");
1695
1179
 
1696
1180
  // src/config/helpers.ts
1697
1181
  var import_resolved = __toESM(require("@uniformdev/next-app-router/config/resolved"));
1698
- var getMiddlewareRuntimeCache = () => {
1699
- if (process.env.NODE_ENV === "development" && !process.env.RUNTIME_CACHE_ENDPOINT) {
1700
- return false;
1701
- }
1702
- if (typeof import_resolved.default.middlewareRuntimeCache === "boolean") {
1703
- return import_resolved.default.middlewareRuntimeCache;
1704
- }
1705
- return true;
1706
- };
1707
1182
  var getPlaygroundPath = () => {
1708
1183
  if (typeof import_resolved.default.playgroundPath === "string") {
1709
1184
  return import_resolved.default.playgroundPath;
@@ -1880,7 +1355,6 @@ var createPreviewOPTIONSRouteHandler = () => {
1880
1355
  };
1881
1356
 
1882
1357
  // src/handler/createPreviewPOSTRouteHandler.ts
1883
- var import_functions = require("@vercel/functions");
1884
1358
  var import_cache4 = require("next/cache");
1885
1359
 
1886
1360
  // src/handler/helpers.ts
@@ -1906,13 +1380,17 @@ var env = {
1906
1380
  };
1907
1381
 
1908
1382
  // src/utils/tag.ts
1383
+ var encodePathForTag = (path) => path.split("/").map((segment) => /[^\x00-\x7F]/.test(segment) ? encodeURIComponent(segment) : segment).join("/");
1909
1384
  var buildPathTag = (path) => {
1910
1385
  const actualPath = path.startsWith("/") ? path : `/${path}`;
1911
- return `path:${actualPath}`.toLowerCase();
1386
+ return `path:${encodePathForTag(actualPath)}`.toLowerCase();
1912
1387
  };
1913
1388
  var buildCompositionTag = (compositionId) => {
1914
1389
  return `composition:${compositionId}`.toLowerCase();
1915
1390
  };
1391
+ var buildCompositionSlugTag = (slug) => {
1392
+ return `composition-slug:${encodePathForTag(slug)}`.toLowerCase();
1393
+ };
1916
1394
 
1917
1395
  // src/utils/draft.ts
1918
1396
  var isDraftModeEnabled = ({
@@ -2016,6 +1494,7 @@ var determineFetchCacheOptions = (mode) => {
2016
1494
  };
2017
1495
 
2018
1496
  // src/clients/retry.ts
1497
+ var import_api28 = require("@uniformdev/context/api");
2019
1498
  function createThrottler(limit, interval) {
2020
1499
  let available = limit;
2021
1500
  let refillScheduled = false;
@@ -2126,7 +1605,7 @@ function createLimitPolicy2({
2126
1605
  if (retryOptions.onFailedAttempt) {
2127
1606
  await retryOptions.onFailedAttempt(error);
2128
1607
  }
2129
- if (error instanceof ApiClientError && typeof error.statusCode === "number" && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429 && error.statusCode !== 408) {
1608
+ if (error instanceof import_api28.ApiClientError && typeof error.statusCode === "number" && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429 && error.statusCode !== 408) {
2130
1609
  throw error;
2131
1610
  }
2132
1611
  }
@@ -2161,11 +1640,16 @@ var buildCanvasClientOptions = (options) => {
2161
1640
  if (requestedUrl) {
2162
1641
  const compositionIdKey = "compositionId";
2163
1642
  const compositionIdsKey = "compositionIDs";
1643
+ const slugKey = "slug";
2164
1644
  const compositionId = requestedUrl.searchParams.get(compositionIdKey);
2165
1645
  const compositionIds = requestedUrl.searchParams.get(compositionIdsKey);
1646
+ const slug = requestedUrl.searchParams.get(slugKey);
2166
1647
  if (compositionId) {
2167
1648
  tags.push(buildCompositionTag(compositionId));
2168
1649
  }
1650
+ if (slug) {
1651
+ tags.push(buildCompositionSlugTag(slug));
1652
+ }
2169
1653
  if (compositionIds) {
2170
1654
  const ids = compositionIds.split(",");
2171
1655
  for (let i = 0; i < ids.length; i++) {
@@ -2197,15 +1681,16 @@ var getCompositionDeliveryClient = (options) => {
2197
1681
  var import_server_only2 = require("server-only");
2198
1682
 
2199
1683
  // ../project-map/dist/index.mjs
2200
- var __typeError4 = (msg) => {
1684
+ var import_api29 = require("@uniformdev/context/api");
1685
+ var __typeError3 = (msg) => {
2201
1686
  throw TypeError(msg);
2202
1687
  };
2203
- var __accessCheck4 = (obj, member, msg) => member.has(obj) || __typeError4("Cannot " + msg);
2204
- var __privateGet4 = (obj, member, getter) => (__accessCheck4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
2205
- 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);
2206
- var __privateSet2 = (obj, member, value, setter) => (__accessCheck4(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
2207
- var __privateMethod = (obj, member, method) => (__accessCheck4(obj, member, "access private method"), method);
2208
- var ProjectMapClient = class extends ApiClient {
1688
+ var __accessCheck3 = (obj, member, msg) => member.has(obj) || __typeError3("Cannot " + msg);
1689
+ var __privateGet3 = (obj, member, getter) => (__accessCheck3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1690
+ 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);
1691
+ var __privateSet2 = (obj, member, value, setter) => (__accessCheck3(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
1692
+ var __privateMethod = (obj, member, method) => (__accessCheck3(obj, member, "access private method"), method);
1693
+ var ProjectMapClient = class extends import_api29.ApiClient {
2209
1694
  constructor(options) {
2210
1695
  super(options);
2211
1696
  this.getProjectMapDefinitions = async () => {
@@ -2351,12 +1836,12 @@ var isDynamicRouteSegment_fn;
2351
1836
  var _Route = class _Route2 {
2352
1837
  constructor(route) {
2353
1838
  this.route = route;
2354
- __privateAdd4(this, _routeInfo);
1839
+ __privateAdd3(this, _routeInfo);
2355
1840
  var _a;
2356
1841
  __privateSet2(this, _routeInfo, __privateMethod(_a = _Route2, _Route_static, parseRouteOrPath_fn).call(_a, this.route));
2357
1842
  }
2358
1843
  get dynamicSegmentCount() {
2359
- return __privateGet4(this, _routeInfo).segments.reduce(
1844
+ return __privateGet3(this, _routeInfo).segments.reduce(
2360
1845
  (count, segment) => {
2361
1846
  var _a;
2362
1847
  return __privateMethod(_a = _Route2, _Route_static, isDynamicRouteSegment_fn).call(_a, segment) ? count + 1 : count;
@@ -2368,7 +1853,7 @@ var _Route = class _Route2 {
2368
1853
  matches(path) {
2369
1854
  var _a, _b;
2370
1855
  const { segments: pathSegments, queryParams: pathQuery } = __privateMethod(_a = _Route2, _Route_static, parseRouteOrPath_fn).call(_a, path);
2371
- const { segments: routeSegments } = __privateGet4(this, _routeInfo);
1856
+ const { segments: routeSegments } = __privateGet3(this, _routeInfo);
2372
1857
  if (pathSegments.length !== routeSegments.length) {
2373
1858
  return { match: false };
2374
1859
  }
@@ -2389,7 +1874,7 @@ var _Route = class _Route2 {
2389
1874
  return { match: false };
2390
1875
  }
2391
1876
  }
2392
- for (const [key, value] of __privateGet4(this, _routeInfo).queryParams) {
1877
+ for (const [key, value] of __privateGet3(this, _routeInfo).queryParams) {
2393
1878
  possibleMatch.queryParams[key] = pathQuery.has(key) ? pathQuery.get(key) : value;
2394
1879
  }
2395
1880
  return possibleMatch;
@@ -2399,7 +1884,7 @@ var _Route = class _Route2 {
2399
1884
  */
2400
1885
  expand(options) {
2401
1886
  const { dynamicInputValues = {}, allowedQueryParams = [], doNotEscapeVariables = false } = options != null ? options : {};
2402
- const path = __privateGet4(this, _routeInfo).segments.map((segment) => {
1887
+ const path = __privateGet3(this, _routeInfo).segments.map((segment) => {
2403
1888
  const dynamicSegmentName = _Route2.getDynamicRouteSegmentName(segment);
2404
1889
  if (!dynamicSegmentName) {
2405
1890
  return segment;
@@ -2479,7 +1964,7 @@ isDynamicRouteSegment_fn = function(segment) {
2479
1964
  }
2480
1965
  return segment.startsWith(_Route.dynamicSegmentPrefix);
2481
1966
  };
2482
- __privateAdd4(_Route, _Route_static);
1967
+ __privateAdd3(_Route, _Route_static);
2483
1968
  _Route.dynamicSegmentPrefix = ":";
2484
1969
  function encodeRouteComponent(value, doNotEscapeVariables) {
2485
1970
  if (!doNotEscapeVariables) {
@@ -2552,7 +2037,7 @@ var isSvixMessage = async (request) => {
2552
2037
  validation: true
2553
2038
  };
2554
2039
  };
2555
- var processCompositionChange = async (compositionId) => {
2040
+ var processCompositionChange = async (compositionId, slug) => {
2556
2041
  const projectMapClient = getProjectMapClient({
2557
2042
  cache: {
2558
2043
  type: "no-cache"
@@ -2580,6 +2065,9 @@ var processCompositionChange = async (compositionId) => {
2580
2065
  }
2581
2066
  }
2582
2067
  tags.push(buildCompositionTag(compositionId));
2068
+ if (slug) {
2069
+ tags.push(buildCompositionSlugTag(slug));
2070
+ }
2583
2071
  return {
2584
2072
  tags,
2585
2073
  paths
@@ -2597,7 +2085,7 @@ var getComposition = async ({ compositionId }) => {
2597
2085
  });
2598
2086
  return composition;
2599
2087
  } catch (err) {
2600
- if (err instanceof ApiClientError && err.statusCode === 404) {
2088
+ if (err instanceof import_api26.ApiClientError && err.statusCode === 404) {
2601
2089
  return null;
2602
2090
  }
2603
2091
  throw err;
@@ -2629,6 +2117,16 @@ var buildProjectMapNodePaths = (path) => {
2629
2117
  paths
2630
2118
  };
2631
2119
  };
2120
+ var buildProjectMapNodeInvalidation = ({
2121
+ path,
2122
+ compositionId
2123
+ }) => {
2124
+ const result = buildProjectMapNodePaths(path);
2125
+ if (compositionId) {
2126
+ result.tags.push(buildCompositionTag(compositionId));
2127
+ }
2128
+ return result;
2129
+ };
2632
2130
  var getPathName = (url) => {
2633
2131
  try {
2634
2132
  const { pathname } = new URL(url);
@@ -2654,7 +2152,7 @@ var handleCompositionChanged = async (body) => {
2654
2152
  if (!parsed.success) {
2655
2153
  return void 0;
2656
2154
  }
2657
- return processCompositionChange(parsed.data.id);
2155
+ return processCompositionChange(parsed.data.id, parsed.data.slug);
2658
2156
  };
2659
2157
 
2660
2158
  // src/handler/messages/handleCompositionDeleted.ts
@@ -2664,7 +2162,7 @@ var handleCompositionDeleted = async (body) => {
2664
2162
  if (!parsed.success) {
2665
2163
  return void 0;
2666
2164
  }
2667
- return processCompositionChange(parsed.data.id);
2165
+ return processCompositionChange(parsed.data.id, parsed.data.slug);
2668
2166
  };
2669
2167
 
2670
2168
  // src/handler/messages/handleCompositionPublished.ts
@@ -2674,7 +2172,7 @@ var handleCompositionPublished = async (body) => {
2674
2172
  if (!parsed.success) {
2675
2173
  return void 0;
2676
2174
  }
2677
- return processCompositionChange(parsed.data.id);
2175
+ return processCompositionChange(parsed.data.id, parsed.data.slug);
2678
2176
  };
2679
2177
 
2680
2178
  // src/handler/messages/handleManifestPublished.ts
@@ -2698,7 +2196,10 @@ var handleProjectMapNodeDelete = async (body) => {
2698
2196
  }
2699
2197
  const tags = [];
2700
2198
  const paths = [];
2701
- const result = buildProjectMapNodePaths(parsed.data.path);
2199
+ const result = buildProjectMapNodeInvalidation({
2200
+ path: parsed.data.path,
2201
+ compositionId: parsed.data.composition_id
2202
+ });
2702
2203
  tags.push(...result.tags);
2703
2204
  if (result.paths) {
2704
2205
  paths.push(...result.paths);
@@ -2718,7 +2219,10 @@ var handleProjectMapNodeInsert = async (body) => {
2718
2219
  }
2719
2220
  const tags = [];
2720
2221
  const paths = [];
2721
- const result = buildProjectMapNodePaths(parsed.data.path);
2222
+ const result = buildProjectMapNodeInvalidation({
2223
+ path: parsed.data.path,
2224
+ compositionId: parsed.data.composition_id
2225
+ });
2722
2226
  tags.push(...result.tags);
2723
2227
  if (result.paths) {
2724
2228
  paths.push(...result.paths);
@@ -2738,12 +2242,18 @@ var handleProjectMapNodeUpdate = async (body) => {
2738
2242
  }
2739
2243
  const tags = [];
2740
2244
  const paths = [];
2741
- const currentResult = buildProjectMapNodePaths(parsed.data.path);
2245
+ const currentResult = buildProjectMapNodeInvalidation({
2246
+ path: parsed.data.path,
2247
+ compositionId: parsed.data.composition_id
2248
+ });
2742
2249
  tags.push(...currentResult.tags);
2743
2250
  if (currentResult.paths) {
2744
2251
  paths.push(...currentResult.paths);
2745
2252
  }
2746
- const previousResult = buildProjectMapNodePaths(parsed.data.previous_path);
2253
+ const previousResult = buildProjectMapNodeInvalidation({
2254
+ path: parsed.data.previous_path,
2255
+ compositionId: parsed.data.composition_id
2256
+ });
2747
2257
  tags.push(...previousResult.tags);
2748
2258
  if (previousResult.paths) {
2749
2259
  paths.push(...previousResult.paths);
@@ -2785,7 +2295,7 @@ var handleRedirectUpdate = async (body) => {
2785
2295
  };
2786
2296
 
2787
2297
  // src/handler/createPreviewPOSTRouteHandler.ts
2788
- var createPreviewPOSTRouteHandler = () => {
2298
+ var createPreviewPOSTRouteHandler = (options = {}) => {
2789
2299
  return async (request) => {
2790
2300
  let previewSecretPassed = false;
2791
2301
  if (process.env.UNIFORM_PREVIEW_SECRET) {
@@ -2813,12 +2323,12 @@ var createPreviewPOSTRouteHandler = () => {
2813
2323
  if (!validation) {
2814
2324
  return new Response("This looks like a webhook request but the validation failed.", { status: 401 });
2815
2325
  }
2816
- return handleSvixMessage(request);
2326
+ return handleSvixMessage(request, options);
2817
2327
  }
2818
2328
  return new Response("This is not a webhook request.", { status: 401 });
2819
2329
  };
2820
2330
  };
2821
- var handleSvixMessage = async (request) => {
2331
+ var handleSvixMessage = async (request, { onRevalidateTags }) => {
2822
2332
  const handlers = [
2823
2333
  handleProjectMapNodeUpdate,
2824
2334
  handleProjectMapNodeInsert,
@@ -2852,14 +2362,10 @@ var handleSvixMessage = async (request) => {
2852
2362
  }
2853
2363
  }
2854
2364
  if (tags == null ? void 0 : tags.length) {
2855
- const cache = getMiddlewareRuntimeCache() ? (0, import_functions.getCache)() : void 0;
2856
2365
  for (let i = 0; i < tags.length; i++) {
2857
- const tag = tags[i];
2858
- (0, import_cache4.revalidateTag)(tag, "max");
2859
- if (cache) {
2860
- await cache.expireTag(tag);
2861
- }
2366
+ (0, import_cache4.revalidateTag)(tags[i], "max");
2862
2367
  }
2368
+ await (onRevalidateTags == null ? void 0 : onRevalidateTags(tags));
2863
2369
  }
2864
2370
  if (paths == null ? void 0 : paths.length) {
2865
2371
  for (let i = 0; i < paths.length; i++) {