@uniformdev/next-app-router 20.81.0 → 20.81.1-alpha.11.sha-4446a46296
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/{UniformComposition-DBO-oo7J.d.ts → UniformComposition-ChDH4dMd.d.ts} +12 -31
- package/dist/{UniformComposition-le6UEB_r.d.mts → UniformComposition-Doa1kKRm.d.mts} +12 -31
- package/dist/cache.d.mts +24 -6
- package/dist/cache.d.ts +24 -6
- package/dist/cache.js +396 -832
- package/dist/cache.mjs +391 -830
- package/dist/compat.d.mts +2 -4
- package/dist/compat.d.ts +2 -4
- package/dist/component.d.mts +10 -1
- package/dist/component.d.ts +10 -1
- package/dist/component.js +113 -617
- package/dist/component.mjs +112 -640
- package/dist/composition-CGU7iH-k.d.mts +37 -0
- package/dist/composition-CGU7iH-k.d.ts +37 -0
- package/dist/config/default.js +0 -1
- package/dist/config/default.mjs +0 -1
- package/dist/createCachedManifestProvider-2-2u3PYd.d.mts +84 -0
- package/dist/createCachedManifestProvider-BoorKD15.d.ts +84 -0
- package/dist/edge.d.mts +80 -0
- package/dist/edge.d.ts +80 -0
- package/dist/edge.js +1231 -0
- package/dist/edge.mjs +1197 -0
- package/dist/handler.d.mts +15 -2
- package/dist/handler.d.ts +15 -2
- package/dist/handler.js +134 -628
- package/dist/handler.mjs +132 -626
- package/dist/index.d.mts +81 -41
- package/dist/index.d.ts +81 -41
- package/dist/index.esm.js +2132 -5651
- package/dist/index.js +2095 -5615
- package/dist/index.mjs +2132 -5651
- package/dist/middleware.d.mts +60 -13
- package/dist/middleware.d.ts +60 -13
- package/dist/middleware.js +416 -5741
- package/dist/middleware.mjs +423 -5771
- package/dist/models-C8OdCO44.d.mts +72 -0
- package/dist/models-C8OdCO44.d.ts +72 -0
- package/dist/resolveRouteFromPath-CnfnaxY2.d.ts +80 -0
- package/dist/resolveRouteFromPath-_rauUskz.d.mts +80 -0
- package/dist/vercel.d.mts +37 -0
- package/dist/vercel.d.ts +37 -0
- package/dist/vercel.js +788 -0
- package/dist/vercel.mjs +759 -0
- package/package.json +37 -9
- package/dist/client-BElN_CWD.d.mts +0 -786
- package/dist/client-BElN_CWD.d.ts +0 -786
- package/dist/resolveRouteFromCode-BOvjIvM2.d.ts +0 -18
- package/dist/resolveRouteFromCode-CuJ4JHeb.d.mts +0 -18
package/dist/cache.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) {
|
|
@@ -399,440 +281,16 @@ var require_retry2 = __commonJS({
|
|
|
399
281
|
// src/cache.ts
|
|
400
282
|
var cache_exports = {};
|
|
401
283
|
__export(cache_exports, {
|
|
402
|
-
|
|
284
|
+
resolveCompositionById: () => resolveCompositionById,
|
|
285
|
+
resolveCompositionBySlug: () => resolveCompositionBySlug,
|
|
286
|
+
resolveRouteFromCode: () => resolveRouteFromCode,
|
|
287
|
+
resolveRouteFromPath: () => resolveRouteFromPath
|
|
403
288
|
});
|
|
404
289
|
module.exports = __toCommonJS(cache_exports);
|
|
405
290
|
|
|
406
|
-
//
|
|
407
|
-
var
|
|
408
|
-
|
|
409
|
-
// ../context/dist/api/api.mjs
|
|
410
|
-
var import_p_limit = __toESM(require_p_limit(), 1);
|
|
411
|
-
var __defProp2 = Object.defineProperty;
|
|
412
|
-
var __typeError2 = (msg) => {
|
|
413
|
-
throw TypeError(msg);
|
|
414
|
-
};
|
|
415
|
-
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
416
|
-
var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
417
|
-
var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
|
|
418
|
-
var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
419
|
-
var __privateAdd2 = (obj, member, value) => member.has(obj) ? __typeError2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
420
|
-
var defaultLimitPolicy = (0, import_p_limit.default)(6);
|
|
421
|
-
var UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE = "Bearer token not valid or expired";
|
|
422
|
-
var ApiClientError = class _ApiClientError extends Error {
|
|
423
|
-
constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
|
|
424
|
-
super(
|
|
425
|
-
`${errorMessage}
|
|
426
|
-
${statusCode}${statusText ? " " + statusText : ""} (${fetchMethod} ${fetchUri}${requestId ? ` Request ID: ${requestId}` : ""})`
|
|
427
|
-
);
|
|
428
|
-
__publicField2(this, "errorMessage", errorMessage);
|
|
429
|
-
__publicField2(this, "fetchMethod", fetchMethod);
|
|
430
|
-
__publicField2(this, "fetchUri", fetchUri);
|
|
431
|
-
__publicField2(this, "statusCode", statusCode);
|
|
432
|
-
__publicField2(this, "statusText", statusText);
|
|
433
|
-
__publicField2(this, "requestId", requestId);
|
|
434
|
-
Object.setPrototypeOf(this, _ApiClientError.prototype);
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
var BearerTokenNotValidOrExpiredError = class _BearerTokenNotValidOrExpiredError extends ApiClientError {
|
|
438
|
-
constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
|
|
439
|
-
super(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId);
|
|
440
|
-
Object.setPrototypeOf(this, _BearerTokenNotValidOrExpiredError.prototype);
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
var ApiClient = class _ApiClient {
|
|
444
|
-
constructor(options) {
|
|
445
|
-
__publicField2(this, "options");
|
|
446
|
-
var _a, _b, _c, _d, _e;
|
|
447
|
-
if (!options.apiKey && !options.bearerToken) {
|
|
448
|
-
throw new Error("You must provide an API key or a bearer token");
|
|
449
|
-
}
|
|
450
|
-
let leFetch = options.fetch;
|
|
451
|
-
if (!leFetch) {
|
|
452
|
-
if (typeof window !== "undefined") {
|
|
453
|
-
leFetch = window.fetch.bind(window);
|
|
454
|
-
} else if (typeof fetch !== "undefined") {
|
|
455
|
-
leFetch = fetch;
|
|
456
|
-
} else {
|
|
457
|
-
throw new Error("You must provide or polyfill a fetch implementation when not in a browser");
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
this.options = {
|
|
461
|
-
...options,
|
|
462
|
-
fetch: leFetch,
|
|
463
|
-
apiHost: this.ensureApiHost(options.apiHost),
|
|
464
|
-
apiKey: (_a = options.apiKey) != null ? _a : null,
|
|
465
|
-
projectId: (_b = options.projectId) != null ? _b : null,
|
|
466
|
-
bearerToken: (_c = options.bearerToken) != null ? _c : null,
|
|
467
|
-
limitPolicy: (_d = options.limitPolicy) != null ? _d : defaultLimitPolicy,
|
|
468
|
-
bypassCache: (_e = options.bypassCache) != null ? _e : false
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
|
-
async apiClient(fetchUri, options) {
|
|
472
|
-
return (await this.apiClientWithResponse(fetchUri, options)).body;
|
|
473
|
-
}
|
|
474
|
-
async apiClientWithResponse(fetchUri, options) {
|
|
475
|
-
return this.options.limitPolicy(async () => {
|
|
476
|
-
var _a, _b;
|
|
477
|
-
const coreHeaders = this.options.apiKey ? {
|
|
478
|
-
"x-api-key": this.options.apiKey
|
|
479
|
-
} : {
|
|
480
|
-
Authorization: `Bearer ${this.options.bearerToken}`
|
|
481
|
-
};
|
|
482
|
-
if (this.options.bypassCache) {
|
|
483
|
-
coreHeaders["x-bypass-cache"] = "true";
|
|
484
|
-
}
|
|
485
|
-
const { fetch: fetch2, signal } = this.options;
|
|
486
|
-
const callApi = () => fetch2(fetchUri.toString(), {
|
|
487
|
-
...options,
|
|
488
|
-
signal,
|
|
489
|
-
headers: {
|
|
490
|
-
...options == null ? void 0 : options.headers,
|
|
491
|
-
...coreHeaders
|
|
492
|
-
}
|
|
493
|
-
});
|
|
494
|
-
const apiResponse = await handleRateLimits(callApi);
|
|
495
|
-
if (!apiResponse.ok) {
|
|
496
|
-
let message = "";
|
|
497
|
-
try {
|
|
498
|
-
const responseText = await apiResponse.text();
|
|
499
|
-
try {
|
|
500
|
-
const parsed = JSON.parse(responseText);
|
|
501
|
-
if (parsed.errorMessage) {
|
|
502
|
-
message = Array.isArray(parsed.errorMessage) ? parsed.errorMessage.join(", ") : parsed.errorMessage;
|
|
503
|
-
} else {
|
|
504
|
-
message = responseText;
|
|
505
|
-
}
|
|
506
|
-
} catch (e) {
|
|
507
|
-
message = responseText;
|
|
508
|
-
}
|
|
509
|
-
} catch (e) {
|
|
510
|
-
message = `General error`;
|
|
511
|
-
}
|
|
512
|
-
if (apiResponse.status === 401 && message === UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE) {
|
|
513
|
-
throw new BearerTokenNotValidOrExpiredError(
|
|
514
|
-
message,
|
|
515
|
-
(_a = options == null ? void 0 : options.method) != null ? _a : "GET",
|
|
516
|
-
fetchUri.toString(),
|
|
517
|
-
apiResponse.status,
|
|
518
|
-
apiResponse.statusText,
|
|
519
|
-
_ApiClient.getRequestId(apiResponse)
|
|
520
|
-
);
|
|
521
|
-
}
|
|
522
|
-
throw new ApiClientError(
|
|
523
|
-
message,
|
|
524
|
-
(_b = options == null ? void 0 : options.method) != null ? _b : "GET",
|
|
525
|
-
fetchUri.toString(),
|
|
526
|
-
apiResponse.status,
|
|
527
|
-
apiResponse.statusText,
|
|
528
|
-
_ApiClient.getRequestId(apiResponse)
|
|
529
|
-
);
|
|
530
|
-
}
|
|
531
|
-
if (options == null ? void 0 : options.expectNoContent) {
|
|
532
|
-
return { response: apiResponse, body: null };
|
|
533
|
-
}
|
|
534
|
-
return {
|
|
535
|
-
response: apiResponse,
|
|
536
|
-
body: await apiResponse.json()
|
|
537
|
-
};
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
createUrl(path, queryParams, hostOverride) {
|
|
541
|
-
const url = new URL(`${hostOverride != null ? hostOverride : this.options.apiHost}${path}`);
|
|
542
|
-
Object.entries(queryParams != null ? queryParams : {}).forEach(([key, value]) => {
|
|
543
|
-
var _a;
|
|
544
|
-
if (typeof value !== "undefined" && value !== null) {
|
|
545
|
-
url.searchParams.append(key, Array.isArray(value) ? value.join(",") : (_a = value == null ? void 0 : value.toString()) != null ? _a : "");
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
return url;
|
|
549
|
-
}
|
|
550
|
-
ensureApiHost(apiHost) {
|
|
551
|
-
if (!apiHost) return "https://uniform.app";
|
|
552
|
-
if (!(apiHost == null ? void 0 : apiHost.startsWith("http"))) {
|
|
553
|
-
throw new Error('Your apiHost must start with "http"');
|
|
554
|
-
}
|
|
555
|
-
if (apiHost.indexOf("/", 8) > -1) {
|
|
556
|
-
throw new Error("Your apiHost must not contain a path element after the domain");
|
|
557
|
-
}
|
|
558
|
-
if (apiHost.indexOf("?") > -1) {
|
|
559
|
-
throw new Error("Your apiHost must not contain a query string");
|
|
560
|
-
}
|
|
561
|
-
if (apiHost == null ? void 0 : apiHost.endsWith("/")) {
|
|
562
|
-
apiHost = apiHost.substring(0, apiHost.length - 1);
|
|
563
|
-
}
|
|
564
|
-
return apiHost;
|
|
565
|
-
}
|
|
566
|
-
static getRequestId(response) {
|
|
567
|
-
const apigRequestId = response.headers.get("apigw-requestid");
|
|
568
|
-
if (apigRequestId) {
|
|
569
|
-
return apigRequestId;
|
|
570
|
-
}
|
|
571
|
-
return void 0;
|
|
572
|
-
}
|
|
573
|
-
};
|
|
574
|
-
async function handleRateLimits(callApi) {
|
|
575
|
-
var _a;
|
|
576
|
-
const backoffRetries = 5;
|
|
577
|
-
let backoffRetriesLeft = backoffRetries;
|
|
578
|
-
let response;
|
|
579
|
-
while (backoffRetriesLeft > 0) {
|
|
580
|
-
response = await callApi();
|
|
581
|
-
if (response.status !== 429) {
|
|
582
|
-
break;
|
|
583
|
-
}
|
|
584
|
-
let resetWait = 0;
|
|
585
|
-
try {
|
|
586
|
-
const responseClone = response.clone();
|
|
587
|
-
const dateHeader = responseClone.headers.get("date");
|
|
588
|
-
const serverTime = dateHeader ? new Date(dateHeader).getTime() : void 0;
|
|
589
|
-
const body = await responseClone.json();
|
|
590
|
-
const resetTime = (_a = body == null ? void 0 : body.info) == null ? void 0 : _a.reset;
|
|
591
|
-
if (typeof serverTime === "number" && typeof resetTime === "number") {
|
|
592
|
-
resetWait = Math.max(0, Math.min(Math.round(1.1 * (resetTime - serverTime)), 1e4));
|
|
593
|
-
}
|
|
594
|
-
} catch (e) {
|
|
595
|
-
}
|
|
596
|
-
const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
|
|
597
|
-
const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
|
|
598
|
-
await new Promise((resolve) => setTimeout(resolve, Math.max(0, resetWait + backoffWait)));
|
|
599
|
-
backoffRetriesLeft -= 1;
|
|
600
|
-
}
|
|
601
|
-
return response;
|
|
602
|
-
}
|
|
603
|
-
var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
|
604
|
-
function rewriteFiltersForApi(filters) {
|
|
605
|
-
return Object.entries(filters != null ? filters : {}).reduce(
|
|
606
|
-
(acc, [key, value]) => {
|
|
607
|
-
const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
|
|
608
|
-
const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
|
|
609
|
-
return {
|
|
610
|
-
...acc,
|
|
611
|
-
[lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
|
|
612
|
-
};
|
|
613
|
-
},
|
|
614
|
-
{}
|
|
615
|
-
);
|
|
616
|
-
}
|
|
617
|
-
var _url;
|
|
618
|
-
var _AggregateClient = class _AggregateClient2 extends ApiClient {
|
|
619
|
-
constructor(options) {
|
|
620
|
-
super(options);
|
|
621
|
-
}
|
|
622
|
-
/** Fetches all aggregates for a project */
|
|
623
|
-
async get(options) {
|
|
624
|
-
const { projectId } = this.options;
|
|
625
|
-
const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url), { ...options, projectId });
|
|
626
|
-
return await this.apiClient(fetchUri);
|
|
627
|
-
}
|
|
628
|
-
/** Updates or creates (based on id) an Aggregate */
|
|
629
|
-
async upsert(body) {
|
|
630
|
-
const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url));
|
|
631
|
-
await this.apiClient(fetchUri, {
|
|
632
|
-
method: "PUT",
|
|
633
|
-
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
634
|
-
expectNoContent: true
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
/** Deletes an Aggregate */
|
|
638
|
-
async remove(body) {
|
|
639
|
-
const fetchUri = this.createUrl(__privateGet2(_AggregateClient2, _url));
|
|
640
|
-
await this.apiClient(fetchUri, {
|
|
641
|
-
method: "DELETE",
|
|
642
|
-
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
643
|
-
expectNoContent: true
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
};
|
|
647
|
-
_url = /* @__PURE__ */ new WeakMap();
|
|
648
|
-
__privateAdd2(_AggregateClient, _url, "/api/v2/aggregate");
|
|
649
|
-
var _url2;
|
|
650
|
-
var _DimensionClient = class _DimensionClient2 extends ApiClient {
|
|
651
|
-
constructor(options) {
|
|
652
|
-
super(options);
|
|
653
|
-
}
|
|
654
|
-
/** Fetches the known score dimensions for a project */
|
|
655
|
-
async get(options) {
|
|
656
|
-
const { projectId } = this.options;
|
|
657
|
-
const fetchUri = this.createUrl(__privateGet2(_DimensionClient2, _url2), { ...options, projectId });
|
|
658
|
-
return await this.apiClient(fetchUri);
|
|
659
|
-
}
|
|
660
|
-
};
|
|
661
|
-
_url2 = /* @__PURE__ */ new WeakMap();
|
|
662
|
-
__privateAdd2(_DimensionClient, _url2, "/api/v2/dimension");
|
|
663
|
-
var _url3;
|
|
664
|
-
var _valueUrl;
|
|
665
|
-
var _EnrichmentClient = class _EnrichmentClient2 extends ApiClient {
|
|
666
|
-
constructor(options) {
|
|
667
|
-
super(options);
|
|
668
|
-
}
|
|
669
|
-
/** Fetches all enrichments and values for a project, grouped by category */
|
|
670
|
-
async get(options) {
|
|
671
|
-
const { projectId } = this.options;
|
|
672
|
-
const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3), { ...options, projectId });
|
|
673
|
-
return await this.apiClient(fetchUri);
|
|
674
|
-
}
|
|
675
|
-
/** Updates or creates (based on id) an enrichment category */
|
|
676
|
-
async upsertCategory(body) {
|
|
677
|
-
const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3));
|
|
678
|
-
await this.apiClient(fetchUri, {
|
|
679
|
-
method: "PUT",
|
|
680
|
-
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
681
|
-
expectNoContent: true
|
|
682
|
-
});
|
|
683
|
-
}
|
|
684
|
-
/** Deletes an enrichment category */
|
|
685
|
-
async removeCategory(body) {
|
|
686
|
-
const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _url3));
|
|
687
|
-
await this.apiClient(fetchUri, {
|
|
688
|
-
method: "DELETE",
|
|
689
|
-
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
690
|
-
expectNoContent: true
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
/** Updates or creates (based on id) an enrichment value within an enrichment category */
|
|
694
|
-
async upsertValue(body) {
|
|
695
|
-
const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _valueUrl));
|
|
696
|
-
await this.apiClient(fetchUri, {
|
|
697
|
-
method: "PUT",
|
|
698
|
-
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
699
|
-
expectNoContent: true
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
/** Deletes an enrichment value within an enrichment category. The category is left alone. */
|
|
703
|
-
async removeValue(body) {
|
|
704
|
-
const fetchUri = this.createUrl(__privateGet2(_EnrichmentClient2, _valueUrl));
|
|
705
|
-
await this.apiClient(fetchUri, {
|
|
706
|
-
method: "DELETE",
|
|
707
|
-
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
708
|
-
expectNoContent: true
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
};
|
|
712
|
-
_url3 = /* @__PURE__ */ new WeakMap();
|
|
713
|
-
_valueUrl = /* @__PURE__ */ new WeakMap();
|
|
714
|
-
__privateAdd2(_EnrichmentClient, _url3, "/api/v1/enrichments");
|
|
715
|
-
__privateAdd2(_EnrichmentClient, _valueUrl, "/api/v1/enrichment-values");
|
|
716
|
-
var _url4;
|
|
717
|
-
var _ManifestClient = class _ManifestClient2 extends ApiClient {
|
|
718
|
-
constructor(options) {
|
|
719
|
-
super(options);
|
|
720
|
-
}
|
|
721
|
-
/** Fetches the Context manifest for a project */
|
|
722
|
-
async get(options) {
|
|
723
|
-
const { projectId } = this.options;
|
|
724
|
-
const fetchUri = this.createUrl(__privateGet2(_ManifestClient2, _url4), { ...options, projectId });
|
|
725
|
-
return await this.apiClient(fetchUri);
|
|
726
|
-
}
|
|
727
|
-
/** Publishes the Context manifest for a project */
|
|
728
|
-
async publish() {
|
|
729
|
-
const { projectId } = this.options;
|
|
730
|
-
const fetchUri = this.createUrl("/api/v1/publish", { siteId: projectId });
|
|
731
|
-
await this.apiClient(fetchUri, {
|
|
732
|
-
method: "POST",
|
|
733
|
-
expectNoContent: true
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
};
|
|
737
|
-
_url4 = /* @__PURE__ */ new WeakMap();
|
|
738
|
-
__privateAdd2(_ManifestClient, _url4, "/api/v2/manifest");
|
|
739
|
-
var ManifestClient = _ManifestClient;
|
|
740
|
-
var _url5;
|
|
741
|
-
var _QuirkClient = class _QuirkClient2 extends ApiClient {
|
|
742
|
-
constructor(options) {
|
|
743
|
-
super(options);
|
|
744
|
-
}
|
|
745
|
-
/** Fetches all Quirks for a project */
|
|
746
|
-
async get(options) {
|
|
747
|
-
const { projectId } = this.options;
|
|
748
|
-
const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5), { ...options, projectId });
|
|
749
|
-
return await this.apiClient(fetchUri);
|
|
750
|
-
}
|
|
751
|
-
/** Updates or creates (based on id) a Quirk */
|
|
752
|
-
async upsert(body) {
|
|
753
|
-
const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5));
|
|
754
|
-
await this.apiClient(fetchUri, {
|
|
755
|
-
method: "PUT",
|
|
756
|
-
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
757
|
-
expectNoContent: true
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
/** Deletes a Quirk */
|
|
761
|
-
async remove(body) {
|
|
762
|
-
const fetchUri = this.createUrl(__privateGet2(_QuirkClient2, _url5));
|
|
763
|
-
await this.apiClient(fetchUri, {
|
|
764
|
-
method: "DELETE",
|
|
765
|
-
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
766
|
-
expectNoContent: true
|
|
767
|
-
});
|
|
768
|
-
}
|
|
769
|
-
};
|
|
770
|
-
_url5 = /* @__PURE__ */ new WeakMap();
|
|
771
|
-
__privateAdd2(_QuirkClient, _url5, "/api/v2/quirk");
|
|
772
|
-
var _url6;
|
|
773
|
-
var _SignalClient = class _SignalClient2 extends ApiClient {
|
|
774
|
-
constructor(options) {
|
|
775
|
-
super(options);
|
|
776
|
-
}
|
|
777
|
-
/** Fetches all Signals for a project */
|
|
778
|
-
async get(options) {
|
|
779
|
-
const { projectId } = this.options;
|
|
780
|
-
const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6), { ...options, projectId });
|
|
781
|
-
return await this.apiClient(fetchUri);
|
|
782
|
-
}
|
|
783
|
-
/** Updates or creates (based on id) a Signal */
|
|
784
|
-
async upsert(body) {
|
|
785
|
-
const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6));
|
|
786
|
-
await this.apiClient(fetchUri, {
|
|
787
|
-
method: "PUT",
|
|
788
|
-
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
789
|
-
expectNoContent: true
|
|
790
|
-
});
|
|
791
|
-
}
|
|
792
|
-
/** Deletes a Signal */
|
|
793
|
-
async remove(body) {
|
|
794
|
-
const fetchUri = this.createUrl(__privateGet2(_SignalClient2, _url6));
|
|
795
|
-
await this.apiClient(fetchUri, {
|
|
796
|
-
method: "DELETE",
|
|
797
|
-
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
798
|
-
expectNoContent: true
|
|
799
|
-
});
|
|
800
|
-
}
|
|
801
|
-
};
|
|
802
|
-
_url6 = /* @__PURE__ */ new WeakMap();
|
|
803
|
-
__privateAdd2(_SignalClient, _url6, "/api/v2/signal");
|
|
804
|
-
var _url7;
|
|
805
|
-
var _TestClient = class _TestClient2 extends ApiClient {
|
|
806
|
-
constructor(options) {
|
|
807
|
-
super(options);
|
|
808
|
-
}
|
|
809
|
-
/** Fetches all Tests for a project */
|
|
810
|
-
async get(options) {
|
|
811
|
-
const { projectId } = this.options;
|
|
812
|
-
const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7), { ...options, projectId });
|
|
813
|
-
return await this.apiClient(fetchUri);
|
|
814
|
-
}
|
|
815
|
-
/** Updates or creates (based on id) a Test */
|
|
816
|
-
async upsert(body) {
|
|
817
|
-
const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7));
|
|
818
|
-
await this.apiClient(fetchUri, {
|
|
819
|
-
method: "PUT",
|
|
820
|
-
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
821
|
-
expectNoContent: true
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
/** Deletes a Test */
|
|
825
|
-
async remove(body) {
|
|
826
|
-
const fetchUri = this.createUrl(__privateGet2(_TestClient2, _url7));
|
|
827
|
-
await this.apiClient(fetchUri, {
|
|
828
|
-
method: "DELETE",
|
|
829
|
-
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
830
|
-
expectNoContent: true
|
|
831
|
-
});
|
|
832
|
-
}
|
|
833
|
-
};
|
|
834
|
-
_url7 = /* @__PURE__ */ new WeakMap();
|
|
835
|
-
__privateAdd2(_TestClient, _url7, "/api/v2/test");
|
|
291
|
+
// ../canvas/dist/index.mjs
|
|
292
|
+
var import_api = require("@uniformdev/context/api");
|
|
293
|
+
var import_api2 = require("@uniformdev/context/api");
|
|
836
294
|
|
|
837
295
|
// ../../node_modules/.pnpm/yocto-queue@1.2.2/node_modules/yocto-queue/index.js
|
|
838
296
|
var Node = class {
|
|
@@ -905,7 +363,7 @@ _tail = new WeakMap();
|
|
|
905
363
|
_size = new WeakMap();
|
|
906
364
|
|
|
907
365
|
// ../../node_modules/.pnpm/p-limit@6.2.0/node_modules/p-limit/index.js
|
|
908
|
-
function
|
|
366
|
+
function pLimit(concurrency) {
|
|
909
367
|
validateConcurrency(concurrency);
|
|
910
368
|
const queue = new Queue();
|
|
911
369
|
let activeCount = 0;
|
|
@@ -1185,19 +643,44 @@ function pThrottle({ limit, interval, strict, onDelay }) {
|
|
|
1185
643
|
}
|
|
1186
644
|
|
|
1187
645
|
// ../canvas/dist/index.mjs
|
|
1188
|
-
var
|
|
646
|
+
var import_api3 = require("@uniformdev/context/api");
|
|
647
|
+
var import_api4 = require("@uniformdev/context/api");
|
|
648
|
+
var import_api5 = require("@uniformdev/context/api");
|
|
649
|
+
var import_api6 = require("@uniformdev/context/api");
|
|
650
|
+
var import_api7 = require("@uniformdev/context/api");
|
|
651
|
+
var import_api8 = require("@uniformdev/context/api");
|
|
652
|
+
var import_api9 = require("@uniformdev/context/api");
|
|
653
|
+
var import_api10 = require("@uniformdev/context/api");
|
|
654
|
+
var import_api11 = require("@uniformdev/context/api");
|
|
655
|
+
var import_api12 = require("@uniformdev/context/api");
|
|
656
|
+
var import_api13 = require("@uniformdev/context/api");
|
|
657
|
+
var import_api14 = require("@uniformdev/context/api");
|
|
658
|
+
var import_api15 = require("@uniformdev/context/api");
|
|
659
|
+
var import_api16 = require("@uniformdev/context/api");
|
|
660
|
+
var import_api17 = require("@uniformdev/context/api");
|
|
661
|
+
var import_api18 = require("@uniformdev/context/api");
|
|
662
|
+
var import_api19 = require("@uniformdev/context/api");
|
|
663
|
+
var import_api20 = require("@uniformdev/context/api");
|
|
664
|
+
var import_api21 = require("@uniformdev/context/api");
|
|
665
|
+
var import_api22 = require("@uniformdev/context/api");
|
|
666
|
+
var import_api23 = require("@uniformdev/context/api");
|
|
667
|
+
var import_api24 = require("@uniformdev/context/api");
|
|
668
|
+
var import_api25 = require("@uniformdev/context/api");
|
|
669
|
+
var import_api26 = require("@uniformdev/context/api");
|
|
670
|
+
var import_api27 = require("@uniformdev/context/api");
|
|
671
|
+
var __typeError2 = (msg) => {
|
|
1189
672
|
throw TypeError(msg);
|
|
1190
673
|
};
|
|
1191
|
-
var
|
|
1192
|
-
var
|
|
1193
|
-
var
|
|
674
|
+
var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
|
|
675
|
+
var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
676
|
+
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);
|
|
1194
677
|
function createLimitPolicy({
|
|
1195
678
|
throttle = { interval: 1e3, limit: 10 },
|
|
1196
679
|
retry: retry3 = { retries: 1, factor: 1.66 },
|
|
1197
680
|
limit = 10
|
|
1198
681
|
}) {
|
|
1199
682
|
const throttler = throttle ? pThrottle(throttle) : null;
|
|
1200
|
-
const limiter = limit ?
|
|
683
|
+
const limiter = limit ? pLimit(limit) : null;
|
|
1201
684
|
return function limitPolicy(func) {
|
|
1202
685
|
let currentFunc = async () => await func();
|
|
1203
686
|
if (throttler) {
|
|
@@ -1216,7 +699,7 @@ function createLimitPolicy({
|
|
|
1216
699
|
if (retry3.onFailedAttempt) {
|
|
1217
700
|
await retry3.onFailedAttempt(error);
|
|
1218
701
|
}
|
|
1219
|
-
if (error instanceof ApiClientError && typeof error.statusCode === "number" && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429 && error.statusCode !== 408) {
|
|
702
|
+
if (error instanceof import_api2.ApiClientError && typeof error.statusCode === "number" && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429 && error.statusCode !== 408) {
|
|
1220
703
|
throw error;
|
|
1221
704
|
}
|
|
1222
705
|
}
|
|
@@ -1225,6 +708,16 @@ function createLimitPolicy({
|
|
|
1225
708
|
return currentFunc();
|
|
1226
709
|
};
|
|
1227
710
|
}
|
|
711
|
+
var ContentClientBase = class extends import_api4.ApiClient {
|
|
712
|
+
constructor(options, defaultBypassCache) {
|
|
713
|
+
var _a, _b;
|
|
714
|
+
super({
|
|
715
|
+
...options,
|
|
716
|
+
limitPolicy: (_a = options.limitPolicy) != null ? _a : createLimitPolicy({}),
|
|
717
|
+
bypassCache: (_b = options.bypassCache) != null ? _b : defaultBypassCache
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
};
|
|
1228
721
|
var SELECT_QUERY_PREFIX = "select.";
|
|
1229
722
|
function appendCsv(out, key, values) {
|
|
1230
723
|
if (values === void 0) {
|
|
@@ -1277,9 +770,89 @@ var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displa
|
|
|
1277
770
|
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
1278
771
|
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1279
772
|
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
773
|
+
function resolveCompositionSelector(args) {
|
|
774
|
+
if ("compositionId" in args) {
|
|
775
|
+
const { compositionId, editionId, versionId, ...readOptions } = args;
|
|
776
|
+
return {
|
|
777
|
+
readOptions,
|
|
778
|
+
// raw mode matches on composition OR edition id via the compositionId param
|
|
779
|
+
compositionId: editionId != null ? editionId : compositionId,
|
|
780
|
+
versionId,
|
|
781
|
+
hasCompositionId: true,
|
|
782
|
+
pinnedEdition: editionId !== void 0
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
return { readOptions: args, hasCompositionId: false, pinnedEdition: false };
|
|
786
|
+
}
|
|
787
|
+
var DEFAULT_EDGE_API_HOST = "https://uniform.global";
|
|
788
|
+
var DeliveryClientBase = class extends ContentClientBase {
|
|
789
|
+
constructor(options) {
|
|
790
|
+
var _a;
|
|
791
|
+
super(
|
|
792
|
+
options,
|
|
793
|
+
/* defaultBypassCache */
|
|
794
|
+
false
|
|
795
|
+
);
|
|
796
|
+
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : DEFAULT_EDGE_API_HOST;
|
|
797
|
+
this.edgeRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
|
|
798
|
+
}
|
|
799
|
+
/** Coerces the `diagnostics` option into the shape the edge endpoints accept. */
|
|
800
|
+
coerceDiagnostics(diagnostics) {
|
|
801
|
+
return typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0;
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
var EDGE_SINGLE_URL = "/api/v1/composition";
|
|
805
|
+
var EDGE_LIST_URL = "/api/v1/compositions";
|
|
806
|
+
var CompositionDeliveryClient = class extends DeliveryClientBase {
|
|
807
|
+
constructor(options) {
|
|
808
|
+
super(options);
|
|
809
|
+
}
|
|
810
|
+
/** Fetches exactly one composition (throws `ApiClientError(404)` if absent). */
|
|
811
|
+
get(args) {
|
|
812
|
+
var _a;
|
|
813
|
+
const { diagnostics, select, ...rest } = args;
|
|
814
|
+
const { readOptions, compositionId, versionId, pinnedEdition } = resolveCompositionSelector(rest);
|
|
815
|
+
const url = this.createUrl(
|
|
816
|
+
EDGE_SINGLE_URL,
|
|
817
|
+
{
|
|
818
|
+
...readOptions,
|
|
819
|
+
...projectionToQuery(select),
|
|
820
|
+
// A pinned edition is folded into compositionId (raw matches edition or
|
|
821
|
+
// composition id); there is no editionId query param on this endpoint.
|
|
822
|
+
compositionId,
|
|
823
|
+
versionId,
|
|
824
|
+
projectId: this.options.projectId,
|
|
825
|
+
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
826
|
+
// editionId pins a specific edition for preview; otherwise locale-best.
|
|
827
|
+
editions: pinnedEdition ? "raw" : "auto",
|
|
828
|
+
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
829
|
+
},
|
|
830
|
+
this.edgeApiHost
|
|
831
|
+
);
|
|
832
|
+
return this.apiClient(url, this.edgeRequestInit);
|
|
833
|
+
}
|
|
834
|
+
/** Fetches a list of compositions, optionally filtered. */
|
|
835
|
+
list(args = {}) {
|
|
836
|
+
var _a;
|
|
837
|
+
const { diagnostics, filters, select, ...rest } = args;
|
|
838
|
+
const url = this.createUrl(
|
|
839
|
+
EDGE_LIST_URL,
|
|
840
|
+
{
|
|
841
|
+
...rest,
|
|
842
|
+
...(0, import_api5.rewriteFiltersForApi)(filters),
|
|
843
|
+
...projectionToQuery(select),
|
|
844
|
+
projectId: this.options.projectId,
|
|
845
|
+
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
846
|
+
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
847
|
+
},
|
|
848
|
+
this.edgeApiHost
|
|
849
|
+
);
|
|
850
|
+
return this.apiClient(url, this.edgeRequestInit);
|
|
851
|
+
}
|
|
852
|
+
};
|
|
1280
853
|
var _contentTypesUrl;
|
|
1281
854
|
var _entriesUrl;
|
|
1282
|
-
var _ContentClient = class _ContentClient2 extends ApiClient {
|
|
855
|
+
var _ContentClient = class _ContentClient2 extends import_api12.ApiClient {
|
|
1283
856
|
constructor(options) {
|
|
1284
857
|
var _a;
|
|
1285
858
|
super(options);
|
|
@@ -1287,16 +860,16 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
|
|
|
1287
860
|
}
|
|
1288
861
|
getContentTypes(options) {
|
|
1289
862
|
const { projectId } = this.options;
|
|
1290
|
-
const fetchUri = this.createUrl(
|
|
863
|
+
const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl), { ...options, projectId });
|
|
1291
864
|
return this.apiClient(fetchUri);
|
|
1292
865
|
}
|
|
1293
866
|
getEntries(options) {
|
|
1294
867
|
const { projectId } = this.options;
|
|
1295
868
|
const { skipDataResolution, filters, select, ...params } = options;
|
|
1296
|
-
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
869
|
+
const rewrittenFilters = (0, import_api12.rewriteFiltersForApi)(filters);
|
|
1297
870
|
const rewrittenSelect = projectionToQuery(select);
|
|
1298
871
|
if (skipDataResolution) {
|
|
1299
|
-
const url = this.createUrl(
|
|
872
|
+
const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), {
|
|
1300
873
|
...params,
|
|
1301
874
|
...rewrittenFilters,
|
|
1302
875
|
...rewrittenSelect,
|
|
@@ -1305,7 +878,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
|
|
|
1305
878
|
return this.apiClient(url);
|
|
1306
879
|
}
|
|
1307
880
|
const edgeUrl = this.createUrl(
|
|
1308
|
-
|
|
881
|
+
__privateGet2(_ContentClient2, _entriesUrl),
|
|
1309
882
|
{ ...this.getEdgeOptions(params), ...rewrittenFilters, ...rewrittenSelect },
|
|
1310
883
|
this.edgeApiHost
|
|
1311
884
|
);
|
|
@@ -1323,7 +896,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
|
|
|
1323
896
|
return this.apiClient(historyUrl);
|
|
1324
897
|
}
|
|
1325
898
|
async upsertContentType(body, opts = {}) {
|
|
1326
|
-
const fetchUri = this.createUrl(
|
|
899
|
+
const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl));
|
|
1327
900
|
if (typeof body.contentType.slugSettings === "object" && body.contentType.slugSettings !== null && Object.keys(body.contentType.slugSettings).length === 0) {
|
|
1328
901
|
delete body.contentType.slugSettings;
|
|
1329
902
|
}
|
|
@@ -1335,7 +908,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
|
|
|
1335
908
|
});
|
|
1336
909
|
}
|
|
1337
910
|
async upsertEntry(body, options) {
|
|
1338
|
-
const fetchUri = this.createUrl(
|
|
911
|
+
const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl));
|
|
1339
912
|
const headers = {};
|
|
1340
913
|
if (options == null ? void 0 : options.ifUnmodifiedSince) {
|
|
1341
914
|
headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
|
|
@@ -1349,7 +922,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
|
|
|
1349
922
|
return { modified: response.headers.get("x-modified-at") };
|
|
1350
923
|
}
|
|
1351
924
|
async deleteContentType(body) {
|
|
1352
|
-
const fetchUri = this.createUrl(
|
|
925
|
+
const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _contentTypesUrl));
|
|
1353
926
|
await this.apiClient(fetchUri, {
|
|
1354
927
|
method: "DELETE",
|
|
1355
928
|
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
@@ -1357,7 +930,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
|
|
|
1357
930
|
});
|
|
1358
931
|
}
|
|
1359
932
|
async deleteEntry(body) {
|
|
1360
|
-
const fetchUri = this.createUrl(
|
|
933
|
+
const fetchUri = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl));
|
|
1361
934
|
await this.apiClient(fetchUri, {
|
|
1362
935
|
method: "DELETE",
|
|
1363
936
|
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
@@ -1376,17 +949,17 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
|
|
|
1376
949
|
};
|
|
1377
950
|
_contentTypesUrl = /* @__PURE__ */ new WeakMap();
|
|
1378
951
|
_entriesUrl = /* @__PURE__ */ new WeakMap();
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
var
|
|
1382
|
-
var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
952
|
+
__privateAdd2(_ContentClient, _contentTypesUrl, "/api/v1/content-types");
|
|
953
|
+
__privateAdd2(_ContentClient, _entriesUrl, "/api/v1/entries");
|
|
954
|
+
var _url;
|
|
955
|
+
var _DataTypeClient = class _DataTypeClient2 extends import_api14.ApiClient {
|
|
1383
956
|
constructor(options) {
|
|
1384
957
|
super(options);
|
|
1385
958
|
}
|
|
1386
959
|
/** Fetches a list of DataTypes for a project */
|
|
1387
960
|
async list(options) {
|
|
1388
961
|
const { projectId } = this.options;
|
|
1389
|
-
const fetchUri = this.createUrl(
|
|
962
|
+
const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url), { ...options, projectId });
|
|
1390
963
|
return await this.apiClient(fetchUri);
|
|
1391
964
|
}
|
|
1392
965
|
/** @deprecated Use {@link list} instead. */
|
|
@@ -1395,7 +968,7 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1395
968
|
}
|
|
1396
969
|
/** Updates or creates (based on id) a DataType */
|
|
1397
970
|
async save(body) {
|
|
1398
|
-
const fetchUri = this.createUrl(
|
|
971
|
+
const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url));
|
|
1399
972
|
await this.apiClient(fetchUri, {
|
|
1400
973
|
method: "PUT",
|
|
1401
974
|
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
@@ -1408,7 +981,7 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1408
981
|
}
|
|
1409
982
|
/** Deletes a DataType */
|
|
1410
983
|
async remove(body) {
|
|
1411
|
-
const fetchUri = this.createUrl(
|
|
984
|
+
const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url));
|
|
1412
985
|
await this.apiClient(fetchUri, {
|
|
1413
986
|
method: "DELETE",
|
|
1414
987
|
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
@@ -1416,10 +989,10 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1416
989
|
});
|
|
1417
990
|
}
|
|
1418
991
|
};
|
|
1419
|
-
|
|
1420
|
-
|
|
992
|
+
_url = /* @__PURE__ */ new WeakMap();
|
|
993
|
+
__privateAdd2(_DataTypeClient, _url, "/api/v1/data-types");
|
|
1421
994
|
var _baseUrl;
|
|
1422
|
-
var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2 extends ApiClient {
|
|
995
|
+
var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2 extends import_api16.ApiClient {
|
|
1423
996
|
constructor(options) {
|
|
1424
997
|
super(options);
|
|
1425
998
|
this.teamId = options.teamId;
|
|
@@ -1428,7 +1001,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
|
|
|
1428
1001
|
* Gets a list of property type and hook names for the current team, including public integrations' hooks.
|
|
1429
1002
|
*/
|
|
1430
1003
|
get(options) {
|
|
1431
|
-
const fetchUri = this.createUrl(
|
|
1004
|
+
const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl), {
|
|
1432
1005
|
...options,
|
|
1433
1006
|
teamId: this.teamId
|
|
1434
1007
|
});
|
|
@@ -1438,7 +1011,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
|
|
|
1438
1011
|
* Creates or updates a custom AI property editor on a Mesh app.
|
|
1439
1012
|
*/
|
|
1440
1013
|
async deploy(body) {
|
|
1441
|
-
const fetchUri = this.createUrl(
|
|
1014
|
+
const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl));
|
|
1442
1015
|
await this.apiClient(fetchUri, {
|
|
1443
1016
|
method: "PUT",
|
|
1444
1017
|
body: JSON.stringify({ ...body, teamId: this.teamId }),
|
|
@@ -1449,7 +1022,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
|
|
|
1449
1022
|
* Removes a custom AI property editor from a Mesh app.
|
|
1450
1023
|
*/
|
|
1451
1024
|
async delete(body) {
|
|
1452
|
-
const fetchUri = this.createUrl(
|
|
1025
|
+
const fetchUri = this.createUrl(__privateGet2(_IntegrationPropertyEditorsClient2, _baseUrl));
|
|
1453
1026
|
await this.apiClient(fetchUri, {
|
|
1454
1027
|
method: "DELETE",
|
|
1455
1028
|
body: JSON.stringify({ ...body, teamId: this.teamId }),
|
|
@@ -1458,16 +1031,16 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
|
|
|
1458
1031
|
}
|
|
1459
1032
|
};
|
|
1460
1033
|
_baseUrl = /* @__PURE__ */ new WeakMap();
|
|
1461
|
-
|
|
1462
|
-
var
|
|
1034
|
+
__privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
|
|
1035
|
+
var _url2;
|
|
1463
1036
|
var _projectsUrl;
|
|
1464
|
-
var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
1037
|
+
var _ProjectClient = class _ProjectClient2 extends import_api20.ApiClient {
|
|
1465
1038
|
constructor(options) {
|
|
1466
1039
|
super({ ...options, bypassCache: true });
|
|
1467
1040
|
}
|
|
1468
1041
|
/** Fetches single Project */
|
|
1469
1042
|
async get(options) {
|
|
1470
|
-
const fetchUri = this.createUrl(
|
|
1043
|
+
const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url2), { ...options });
|
|
1471
1044
|
return await this.apiClient(fetchUri);
|
|
1472
1045
|
}
|
|
1473
1046
|
/**
|
|
@@ -1476,7 +1049,7 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1476
1049
|
* When omitted, returns all accessible teams and their projects.
|
|
1477
1050
|
*/
|
|
1478
1051
|
async list(options) {
|
|
1479
|
-
const fetchUri = this.createUrl(
|
|
1052
|
+
const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
|
|
1480
1053
|
return await this.apiClient(fetchUri);
|
|
1481
1054
|
}
|
|
1482
1055
|
/** @deprecated Use {@link list} instead. */
|
|
@@ -1485,7 +1058,7 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1485
1058
|
}
|
|
1486
1059
|
/** Updates or creates (based on id) a Project */
|
|
1487
1060
|
async save(body) {
|
|
1488
|
-
const fetchUri = this.createUrl(
|
|
1061
|
+
const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url2));
|
|
1489
1062
|
return await this.apiClient(fetchUri, {
|
|
1490
1063
|
method: "PUT",
|
|
1491
1064
|
body: JSON.stringify({ ...body })
|
|
@@ -1497,7 +1070,7 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1497
1070
|
}
|
|
1498
1071
|
/** Deletes a Project */
|
|
1499
1072
|
async remove(body) {
|
|
1500
|
-
const fetchUri = this.createUrl(
|
|
1073
|
+
const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url2));
|
|
1501
1074
|
await this.apiClient(fetchUri, {
|
|
1502
1075
|
method: "DELETE",
|
|
1503
1076
|
body: JSON.stringify({ ...body }),
|
|
@@ -1509,12 +1082,12 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1509
1082
|
return this.remove(body);
|
|
1510
1083
|
}
|
|
1511
1084
|
};
|
|
1512
|
-
|
|
1085
|
+
_url2 = /* @__PURE__ */ new WeakMap();
|
|
1513
1086
|
_projectsUrl = /* @__PURE__ */ new WeakMap();
|
|
1514
|
-
|
|
1515
|
-
|
|
1087
|
+
__privateAdd2(_ProjectClient, _url2, "/api/v1/project");
|
|
1088
|
+
__privateAdd2(_ProjectClient, _projectsUrl, "/api/v1/projects");
|
|
1516
1089
|
var ROUTE_URL = "/api/v1/route";
|
|
1517
|
-
var RouteClient = class extends ApiClient {
|
|
1090
|
+
var RouteClient = class extends import_api25.ApiClient {
|
|
1518
1091
|
constructor(options) {
|
|
1519
1092
|
var _a;
|
|
1520
1093
|
if (!options.limitPolicy) {
|
|
@@ -1557,10 +1130,38 @@ var getDataSourceVariantFromRouteGetParams = (params, defaultPreviewState) => {
|
|
|
1557
1130
|
return dataSourceVariant;
|
|
1558
1131
|
};
|
|
1559
1132
|
|
|
1560
|
-
// src/
|
|
1561
|
-
var
|
|
1133
|
+
// src/cache.ts
|
|
1134
|
+
var import_cache5 = require("next/cache");
|
|
1135
|
+
|
|
1136
|
+
// src/utils/tag.ts
|
|
1137
|
+
var encodePathForTag = (path) => path.split("/").map((segment) => /[^\x00-\x7F]/.test(segment) ? encodeURIComponent(segment) : segment).join("/");
|
|
1138
|
+
var buildPathTag = (path) => {
|
|
1139
|
+
const actualPath = path.startsWith("/") ? path : `/${path}`;
|
|
1140
|
+
return `path:${encodePathForTag(actualPath)}`.toLowerCase();
|
|
1141
|
+
};
|
|
1142
|
+
var buildCompositionTag = (compositionId) => {
|
|
1143
|
+
return `composition:${compositionId}`.toLowerCase();
|
|
1144
|
+
};
|
|
1145
|
+
var buildCompositionSlugTag = (slug) => {
|
|
1146
|
+
return `composition-slug:${encodePathForTag(slug)}`.toLowerCase();
|
|
1147
|
+
};
|
|
1562
1148
|
|
|
1563
|
-
// src/clients/
|
|
1149
|
+
// src/clients/tags.ts
|
|
1150
|
+
var generateRouteCacheTags = ({ path }) => {
|
|
1151
|
+
const tags = ["route"];
|
|
1152
|
+
if (path) {
|
|
1153
|
+
const pathWithoutQuery = path.split("?")[0];
|
|
1154
|
+
const pieces = pathWithoutQuery.split("/");
|
|
1155
|
+
for (let i = 0; i < pieces.length; i++) {
|
|
1156
|
+
const segmentPieces = pieces.slice(0, i + 1);
|
|
1157
|
+
const segment = segmentPieces.join("/");
|
|
1158
|
+
tags.push(buildPathTag(segment));
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
return tags;
|
|
1162
|
+
};
|
|
1163
|
+
|
|
1164
|
+
// src/clients/canvas.ts
|
|
1564
1165
|
var import_server_only = require("server-only");
|
|
1565
1166
|
|
|
1566
1167
|
// src/utils/env.ts
|
|
@@ -1613,11 +1214,6 @@ var isStateCacheMode = (options) => {
|
|
|
1613
1214
|
var isDetectCacheMode = (options) => {
|
|
1614
1215
|
return "searchParams" in options && "draftModeEnabled" in options;
|
|
1615
1216
|
};
|
|
1616
|
-
var resolveManifestCache = (options) => {
|
|
1617
|
-
return resolveCache({
|
|
1618
|
-
options
|
|
1619
|
-
});
|
|
1620
|
-
};
|
|
1621
1217
|
var resolveCanvasCache = (options) => {
|
|
1622
1218
|
return resolveCache({
|
|
1623
1219
|
options
|
|
@@ -1685,6 +1281,7 @@ var determineFetchCacheOptions = (mode) => {
|
|
|
1685
1281
|
};
|
|
1686
1282
|
|
|
1687
1283
|
// src/clients/retry.ts
|
|
1284
|
+
var import_api28 = require("@uniformdev/context/api");
|
|
1688
1285
|
function createThrottler(limit, interval) {
|
|
1689
1286
|
let available = limit;
|
|
1690
1287
|
let refillScheduled = false;
|
|
@@ -1795,7 +1392,7 @@ function createLimitPolicy2({
|
|
|
1795
1392
|
if (retryOptions.onFailedAttempt) {
|
|
1796
1393
|
await retryOptions.onFailedAttempt(error);
|
|
1797
1394
|
}
|
|
1798
|
-
if (error instanceof ApiClientError && typeof error.statusCode === "number" && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429 && error.statusCode !== 408) {
|
|
1395
|
+
if (error instanceof import_api28.ApiClientError && typeof error.statusCode === "number" && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429 && error.statusCode !== 408) {
|
|
1799
1396
|
throw error;
|
|
1800
1397
|
}
|
|
1801
1398
|
}
|
|
@@ -1805,67 +1402,66 @@ function createLimitPolicy2({
|
|
|
1805
1402
|
};
|
|
1806
1403
|
}
|
|
1807
1404
|
|
|
1808
|
-
// src/
|
|
1809
|
-
var
|
|
1810
|
-
const
|
|
1811
|
-
return
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
// src/clients/tags.ts
|
|
1815
|
-
var generateRouteCacheTags = ({ path, old }) => {
|
|
1816
|
-
const tags = old ? ["route-old"] : ["route"];
|
|
1817
|
-
if (path) {
|
|
1818
|
-
const pathWithoutQuery = path.split("?")[0];
|
|
1819
|
-
const pieces = pathWithoutQuery.split("/");
|
|
1820
|
-
for (let i = 0; i < pieces.length; i++) {
|
|
1821
|
-
const segmentPieces = pieces.slice(0, i + 1);
|
|
1822
|
-
const segment = segmentPieces.join("/");
|
|
1823
|
-
tags.push(buildPathTag(segment));
|
|
1824
|
-
}
|
|
1825
|
-
}
|
|
1826
|
-
return tags;
|
|
1827
|
-
};
|
|
1828
|
-
var generateManifestCacheTags = () => {
|
|
1829
|
-
return ["manifest"];
|
|
1830
|
-
};
|
|
1831
|
-
|
|
1832
|
-
// src/clients/manifest.ts
|
|
1833
|
-
var getManifestClient = (options) => {
|
|
1834
|
-
const cache = resolveManifestCache(options);
|
|
1835
|
-
const manifestClient = new ManifestClient({
|
|
1405
|
+
// src/clients/canvas.ts
|
|
1406
|
+
var buildCanvasClientOptions = (options) => {
|
|
1407
|
+
const cache = resolveCanvasCache(options);
|
|
1408
|
+
return {
|
|
1409
|
+
projectId: env.getProjectId(),
|
|
1836
1410
|
apiHost: env.getApiHost(),
|
|
1837
1411
|
apiKey: env.getApiKey(),
|
|
1838
|
-
|
|
1412
|
+
edgeApiHost: env.getEdgeApiHost(),
|
|
1413
|
+
disableSWR: typeof cache.disableSWR !== "undefined" ? cache.disableSWR : true,
|
|
1839
1414
|
limitPolicy: createLimitPolicy2({
|
|
1840
1415
|
limit: 6
|
|
1841
1416
|
}),
|
|
1842
1417
|
fetch: (req, init) => {
|
|
1418
|
+
let requestedUrl;
|
|
1419
|
+
if (typeof req === "string") {
|
|
1420
|
+
requestedUrl = new URL(req);
|
|
1421
|
+
} else if (req instanceof URL) {
|
|
1422
|
+
requestedUrl = req;
|
|
1423
|
+
} else {
|
|
1424
|
+
requestedUrl = new URL(req.url);
|
|
1425
|
+
}
|
|
1426
|
+
const tags = [];
|
|
1427
|
+
if (requestedUrl) {
|
|
1428
|
+
const compositionIdKey = "compositionId";
|
|
1429
|
+
const compositionIdsKey = "compositionIDs";
|
|
1430
|
+
const slugKey = "slug";
|
|
1431
|
+
const compositionId = requestedUrl.searchParams.get(compositionIdKey);
|
|
1432
|
+
const compositionIds = requestedUrl.searchParams.get(compositionIdsKey);
|
|
1433
|
+
const slug = requestedUrl.searchParams.get(slugKey);
|
|
1434
|
+
if (compositionId) {
|
|
1435
|
+
tags.push(buildCompositionTag(compositionId));
|
|
1436
|
+
}
|
|
1437
|
+
if (slug) {
|
|
1438
|
+
tags.push(buildCompositionSlugTag(slug));
|
|
1439
|
+
}
|
|
1440
|
+
if (compositionIds) {
|
|
1441
|
+
const ids = compositionIds.split(",");
|
|
1442
|
+
for (let i = 0; i < ids.length; i++) {
|
|
1443
|
+
tags.push(buildCompositionTag(ids[i]));
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1843
1447
|
const { cache: fetchCache, revalidate } = determineFetchCacheOptions(cache);
|
|
1844
1448
|
return fetch(req, {
|
|
1845
1449
|
...init,
|
|
1450
|
+
cache: fetchCache,
|
|
1846
1451
|
headers: {
|
|
1847
1452
|
...init == null ? void 0 : init.headers,
|
|
1848
1453
|
"x-bypass-cache": typeof cache.bypassCache !== "undefined" ? cache.bypassCache.toString() : "false"
|
|
1849
1454
|
},
|
|
1850
|
-
cache: fetchCache,
|
|
1851
1455
|
next: {
|
|
1852
1456
|
revalidate,
|
|
1853
|
-
tags:
|
|
1457
|
+
tags: tags.length ? tags : void 0
|
|
1854
1458
|
}
|
|
1855
1459
|
});
|
|
1856
1460
|
}
|
|
1857
|
-
}
|
|
1858
|
-
return manifestClient;
|
|
1461
|
+
};
|
|
1859
1462
|
};
|
|
1860
|
-
var
|
|
1861
|
-
|
|
1862
|
-
if (options && isStateCacheMode(options)) {
|
|
1863
|
-
preview = options.state === CANVAS_DRAFT_STATE || options.state === CANVAS_EDITOR_STATE;
|
|
1864
|
-
}
|
|
1865
|
-
const manifestClient = getManifestClient(options);
|
|
1866
|
-
return manifestClient.get({
|
|
1867
|
-
preview
|
|
1868
|
-
});
|
|
1463
|
+
var getCompositionDeliveryClient = (options) => {
|
|
1464
|
+
return new CompositionDeliveryClient(buildCanvasClientOptions(options));
|
|
1869
1465
|
};
|
|
1870
1466
|
|
|
1871
1467
|
// src/clients/route.ts
|
|
@@ -1919,218 +1515,186 @@ var getRouteClient = (options) => {
|
|
|
1919
1515
|
return client;
|
|
1920
1516
|
};
|
|
1921
1517
|
|
|
1922
|
-
// src/config/helpers.ts
|
|
1923
|
-
var import_resolved = __toESM(require("@uniformdev/next-app-router/config/resolved"));
|
|
1924
|
-
var getMiddlewareRuntimeCache = () => {
|
|
1925
|
-
if (process.env.NODE_ENV === "development" && !process.env.RUNTIME_CACHE_ENDPOINT) {
|
|
1926
|
-
return false;
|
|
1927
|
-
}
|
|
1928
|
-
if (typeof import_resolved.default.middlewareRuntimeCache === "boolean") {
|
|
1929
|
-
return import_resolved.default.middlewareRuntimeCache;
|
|
1930
|
-
}
|
|
1931
|
-
return true;
|
|
1932
|
-
};
|
|
1933
|
-
var getDisableSwrMiddlewareCache = () => {
|
|
1934
|
-
var _a;
|
|
1935
|
-
if (typeof ((_a = import_resolved.default.experimental) == null ? void 0 : _a.disableSwrMiddlewareCache) === "boolean") {
|
|
1936
|
-
return import_resolved.default.experimental.disableSwrMiddlewareCache;
|
|
1937
|
-
}
|
|
1938
|
-
return false;
|
|
1939
|
-
};
|
|
1940
|
-
|
|
1941
1518
|
// src/data/client.ts
|
|
1942
|
-
var
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
}
|
|
1959
|
-
});
|
|
1960
|
-
if (cache) {
|
|
1961
|
-
(0, import_functions.waitUntil)(
|
|
1962
|
-
(async () => {
|
|
1963
|
-
await cache.set(MANIFEST_CACHE_KEY, manifest, {
|
|
1964
|
-
tags: generateManifestCacheTags()
|
|
1965
|
-
});
|
|
1966
|
-
})()
|
|
1967
|
-
);
|
|
1968
|
-
}
|
|
1969
|
-
return manifest;
|
|
1519
|
+
var DataClient = class {
|
|
1520
|
+
constructor({ fetchCache = true } = {}) {
|
|
1521
|
+
this.fetchCache = fetchCache;
|
|
1522
|
+
}
|
|
1523
|
+
async getRoute({ pageState }) {
|
|
1524
|
+
const routeClient = getRouteClient({ cache: this.resolveCache(pageState) });
|
|
1525
|
+
const parameters = {
|
|
1526
|
+
path: pageState.routePath,
|
|
1527
|
+
state: pageState.compositionState,
|
|
1528
|
+
dataSourceVariant: getDataSourceVariantFromRouteGetParams({}, pageState.compositionState),
|
|
1529
|
+
withComponentIDs: true,
|
|
1530
|
+
releaseId: pageState.releaseId,
|
|
1531
|
+
locale: pageState.locale,
|
|
1532
|
+
ignoreRedirects: shouldIgnoreRedirects({ state: pageState.compositionState })
|
|
1533
|
+
};
|
|
1534
|
+
return routeClient.get(parameters);
|
|
1970
1535
|
}
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
disableSwrCache
|
|
1536
|
+
/** Returns `null` when no composition matches the selector in the page state's composition state. */
|
|
1537
|
+
async getComposition({
|
|
1538
|
+
pageState,
|
|
1539
|
+
selector
|
|
1976
1540
|
}) {
|
|
1977
|
-
const
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
if (cache && result2.type === "composition" && !disableSwrCache) {
|
|
1990
|
-
const tags = generateRouteCacheTags({ path: route.path, old: true });
|
|
1991
|
-
await cache.set(oldCacheKey, result2, {
|
|
1992
|
-
tags
|
|
1993
|
-
});
|
|
1994
|
-
}
|
|
1995
|
-
};
|
|
1996
|
-
if (cache) {
|
|
1997
|
-
const [cachedRoute, oldCachedRoute] = await Promise.all([
|
|
1998
|
-
cache.get(newCacheKey),
|
|
1999
|
-
disableSwrCache ? null : cache.get(oldCacheKey)
|
|
2000
|
-
]);
|
|
2001
|
-
if (cachedRoute) {
|
|
2002
|
-
return cachedRoute;
|
|
2003
|
-
}
|
|
2004
|
-
if (oldCachedRoute) {
|
|
2005
|
-
(0, import_functions.waitUntil)(
|
|
2006
|
-
(async () => {
|
|
2007
|
-
const result2 = await routeClient.get(route);
|
|
2008
|
-
await cacheNewRoute(result2);
|
|
2009
|
-
})()
|
|
2010
|
-
);
|
|
2011
|
-
return oldCachedRoute;
|
|
1541
|
+
const client = getCompositionDeliveryClient({ cache: this.resolveCache(pageState) });
|
|
1542
|
+
try {
|
|
1543
|
+
return await client.get({
|
|
1544
|
+
...selector,
|
|
1545
|
+
state: pageState.compositionState,
|
|
1546
|
+
withComponentIDs: true,
|
|
1547
|
+
releaseId: pageState.releaseId,
|
|
1548
|
+
locale: pageState.locale
|
|
1549
|
+
});
|
|
1550
|
+
} catch (e) {
|
|
1551
|
+
if (e instanceof import_api26.ApiClientError && e.statusCode === 404) {
|
|
1552
|
+
return null;
|
|
2012
1553
|
}
|
|
1554
|
+
throw e;
|
|
2013
1555
|
}
|
|
2014
|
-
const result = await routeClient.get(route);
|
|
2015
|
-
(0, import_functions.waitUntil)(
|
|
2016
|
-
(async () => {
|
|
2017
|
-
await Promise.all([
|
|
2018
|
-
cacheNewRoute(result),
|
|
2019
|
-
disableSwrCache ? Promise.resolve() : cacheOldRoute(result)
|
|
2020
|
-
]);
|
|
2021
|
-
})()
|
|
2022
|
-
);
|
|
2023
|
-
return result;
|
|
2024
1556
|
}
|
|
2025
|
-
|
|
2026
|
-
if (
|
|
2027
|
-
return
|
|
1557
|
+
resolveCache(pageState) {
|
|
1558
|
+
if (pageState.compositionState !== CANVAS_PUBLISHED_STATE || isDevelopmentEnvironment()) {
|
|
1559
|
+
return { type: "no-cache", bypassCache: true };
|
|
2028
1560
|
}
|
|
2029
|
-
return this.
|
|
1561
|
+
return this.fetchCache ? { type: "force-cache" } : { type: "no-cache" };
|
|
2030
1562
|
}
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
1563
|
+
};
|
|
1564
|
+
|
|
1565
|
+
// src/data/deserializePageState.ts
|
|
1566
|
+
var import_next_app_router_shared = require("@uniformdev/next-app-router-shared");
|
|
1567
|
+
var deserializePageState = ({ code }) => (0, import_next_app_router_shared.deserializeEvaluationResult)({ input: code });
|
|
1568
|
+
|
|
1569
|
+
// src/data/pageStateFromSource.ts
|
|
1570
|
+
var pageStateFromSource = (source) => {
|
|
1571
|
+
var _a;
|
|
1572
|
+
return (_a = source.pageState) != null ? _a : deserializePageState({ code: source.code });
|
|
1573
|
+
};
|
|
1574
|
+
|
|
1575
|
+
// src/data/resolveCompositionForPageState.ts
|
|
1576
|
+
var resolveCompositionForPageState = async ({
|
|
1577
|
+
pageState,
|
|
1578
|
+
selector,
|
|
1579
|
+
matchedRoute,
|
|
1580
|
+
dataClient = new DataClient()
|
|
1581
|
+
}) => {
|
|
1582
|
+
const states = pageState.compositionState === CANVAS_EDITOR_STATE ? [CANVAS_EDITOR_STATE, CANVAS_DRAFT_STATE] : [pageState.compositionState];
|
|
1583
|
+
let composition = null;
|
|
1584
|
+
for (const state of states) {
|
|
1585
|
+
try {
|
|
1586
|
+
composition = await dataClient.getComposition({
|
|
1587
|
+
pageState: { ...pageState, compositionState: state },
|
|
1588
|
+
selector
|
|
2054
1589
|
});
|
|
1590
|
+
} catch (e) {
|
|
1591
|
+
console.warn(`Failed to get composition ${JSON.stringify(selector)} with state ${state}`, e);
|
|
2055
1592
|
}
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
};
|
|
2059
|
-
}
|
|
2060
|
-
async getRoutePageState(options) {
|
|
2061
|
-
const shouldBypassCache = options.pageState.compositionState !== CANVAS_PUBLISHED_STATE || isDevelopmentEnvironment();
|
|
2062
|
-
const routeClient = getRouteClient({
|
|
2063
|
-
cache: shouldBypassCache ? {
|
|
2064
|
-
type: "no-cache",
|
|
2065
|
-
bypassCache: true
|
|
2066
|
-
} : {
|
|
2067
|
-
type: "force-cache"
|
|
2068
|
-
}
|
|
2069
|
-
});
|
|
2070
|
-
const originalRoute = {
|
|
2071
|
-
path: options.pageState.routePath,
|
|
2072
|
-
state: options.pageState.compositionState,
|
|
2073
|
-
dataSourceVariant: getDataSourceVariantFromRouteGetParams({}, options.pageState.compositionState),
|
|
2074
|
-
withComponentIDs: true,
|
|
2075
|
-
releaseId: options.pageState.releaseId,
|
|
2076
|
-
locale: options.pageState.locale,
|
|
2077
|
-
ignoreRedirects: shouldIgnoreRedirects({ state: options.pageState.compositionState })
|
|
2078
|
-
};
|
|
2079
|
-
const resolvedRoute = await this.getRouteFromApi({
|
|
2080
|
-
source: "pageState",
|
|
2081
|
-
route: originalRoute,
|
|
2082
|
-
routeClient,
|
|
2083
|
-
enableRuntimeCache: false,
|
|
2084
|
-
disableSwrCache: false
|
|
2085
|
-
});
|
|
2086
|
-
if (resolvedRoute.type === "composition") {
|
|
2087
|
-
await this.enhanceRoute({
|
|
2088
|
-
source: "pageState",
|
|
2089
|
-
parameters: originalRoute,
|
|
2090
|
-
route: resolvedRoute,
|
|
2091
|
-
routeClient,
|
|
2092
|
-
keys: options.pageState.keys
|
|
2093
|
-
});
|
|
1593
|
+
if (composition) {
|
|
1594
|
+
break;
|
|
2094
1595
|
}
|
|
2095
|
-
return {
|
|
2096
|
-
route: resolvedRoute
|
|
2097
|
-
};
|
|
2098
1596
|
}
|
|
1597
|
+
if (!composition) {
|
|
1598
|
+
return { pageState, route: void 0 };
|
|
1599
|
+
}
|
|
1600
|
+
return {
|
|
1601
|
+
pageState: { ...pageState, compositionState: composition.state },
|
|
1602
|
+
route: {
|
|
1603
|
+
type: "composition",
|
|
1604
|
+
compositionApiResponse: composition,
|
|
1605
|
+
matchedRoute
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
2099
1608
|
};
|
|
2100
1609
|
|
|
2101
|
-
// src/data/
|
|
2102
|
-
var
|
|
2103
|
-
|
|
2104
|
-
dataClient
|
|
1610
|
+
// src/data/resolveRouteForPageState.ts
|
|
1611
|
+
var resolveRouteForPageState = async ({
|
|
1612
|
+
pageState: providedPageState,
|
|
1613
|
+
dataClient = new DataClient()
|
|
2105
1614
|
}) => {
|
|
2106
|
-
|
|
2107
|
-
const
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
1615
|
+
var _a, _b;
|
|
1616
|
+
const states = providedPageState.compositionState === CANVAS_EDITOR_STATE ? [CANVAS_EDITOR_STATE, CANVAS_DRAFT_STATE] : [providedPageState.compositionState];
|
|
1617
|
+
let pageState = providedPageState;
|
|
1618
|
+
let route = null;
|
|
1619
|
+
for (const state of states) {
|
|
1620
|
+
pageState = { ...providedPageState, compositionState: state };
|
|
1621
|
+
try {
|
|
1622
|
+
route = await dataClient.getRoute({ pageState });
|
|
1623
|
+
} catch (e) {
|
|
1624
|
+
console.warn(`Failed to retrieve route by path: ${pageState.routePath} with state ${state}`, e);
|
|
1625
|
+
}
|
|
1626
|
+
if (route && route.type !== "notFound") {
|
|
1627
|
+
break;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
if ((route == null ? void 0 : route.type) === "composition") {
|
|
1631
|
+
return { pageState: { ...pageState, locale: (_b = pageState.locale) != null ? _b : (_a = route.dynamicInputs) == null ? void 0 : _a.locale }, route };
|
|
1632
|
+
}
|
|
1633
|
+
if ((route == null ? void 0 : route.type) === "redirect") {
|
|
1634
|
+
return { pageState, route };
|
|
1635
|
+
}
|
|
1636
|
+
return { pageState, route: void 0 };
|
|
2119
1637
|
};
|
|
2120
1638
|
|
|
2121
1639
|
// src/cache.ts
|
|
2122
|
-
var
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
dataClient: providedDataClient
|
|
2130
|
-
});
|
|
1640
|
+
var tagScope = (result, requestedTags) => {
|
|
1641
|
+
var _a;
|
|
1642
|
+
const tags = [...requestedTags];
|
|
1643
|
+
if (((_a = result.route) == null ? void 0 : _a.type) === "composition") {
|
|
1644
|
+
tags.push(buildCompositionTag(result.route.compositionApiResponse.composition._id));
|
|
1645
|
+
}
|
|
1646
|
+
(0, import_cache5.cacheTag)(...tags);
|
|
2131
1647
|
return result;
|
|
2132
1648
|
};
|
|
1649
|
+
var createScopeDataClient = () => new DataClient({ fetchCache: false });
|
|
1650
|
+
var isPublished = (pageState) => pageState.compositionState === CANVAS_PUBLISHED_STATE;
|
|
1651
|
+
var resolveRouteCached = async (pageState) => {
|
|
1652
|
+
"use cache";
|
|
1653
|
+
return tagScope(
|
|
1654
|
+
await resolveRouteForPageState({ pageState, dataClient: createScopeDataClient() }),
|
|
1655
|
+
generateRouteCacheTags({ path: pageState.routePath })
|
|
1656
|
+
);
|
|
1657
|
+
};
|
|
1658
|
+
var resolveCompositionCached = async (pageState, selector, matchedRoute) => {
|
|
1659
|
+
"use cache";
|
|
1660
|
+
return tagScope(
|
|
1661
|
+
await resolveCompositionForPageState({
|
|
1662
|
+
pageState,
|
|
1663
|
+
selector,
|
|
1664
|
+
matchedRoute,
|
|
1665
|
+
dataClient: createScopeDataClient()
|
|
1666
|
+
}),
|
|
1667
|
+
[
|
|
1668
|
+
"compositionId" in selector ? buildCompositionTag(selector.compositionId) : buildCompositionSlugTag(selector.slug)
|
|
1669
|
+
]
|
|
1670
|
+
);
|
|
1671
|
+
};
|
|
1672
|
+
var resolveRoute = (pageState) => isPublished(pageState) ? resolveRouteCached(pageState) : resolveRouteForPageState({ pageState });
|
|
1673
|
+
var resolveComposition = (pageState, selector, matchedRoute) => {
|
|
1674
|
+
const route = matchedRoute != null ? matchedRoute : pageState.routePath;
|
|
1675
|
+
return isPublished(pageState) ? resolveCompositionCached(pageState, selector, route) : resolveCompositionForPageState({ pageState, selector, matchedRoute: route });
|
|
1676
|
+
};
|
|
1677
|
+
var resolveRouteFromCode = async ({
|
|
1678
|
+
code
|
|
1679
|
+
}) => resolveRoute(deserializePageState({ code }));
|
|
1680
|
+
var resolveRouteFromPath = async ({
|
|
1681
|
+
path,
|
|
1682
|
+
...source
|
|
1683
|
+
}) => resolveRoute({ ...pageStateFromSource(source), routePath: path });
|
|
1684
|
+
var resolveCompositionById = async ({
|
|
1685
|
+
compositionId,
|
|
1686
|
+
matchedRoute,
|
|
1687
|
+
...source
|
|
1688
|
+
}) => resolveComposition(pageStateFromSource(source), { compositionId }, matchedRoute);
|
|
1689
|
+
var resolveCompositionBySlug = async ({
|
|
1690
|
+
slug,
|
|
1691
|
+
matchedRoute,
|
|
1692
|
+
...source
|
|
1693
|
+
}) => resolveComposition(pageStateFromSource(source), { slug }, matchedRoute);
|
|
2133
1694
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2134
1695
|
0 && (module.exports = {
|
|
2135
|
-
|
|
1696
|
+
resolveCompositionById,
|
|
1697
|
+
resolveCompositionBySlug,
|
|
1698
|
+
resolveRouteFromCode,
|
|
1699
|
+
resolveRouteFromPath
|
|
2136
1700
|
});
|