@uniformdev/next-app-router 20.72.3-alpha.2 → 20.72.3-alpha.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cache.js +114 -25
- package/dist/cache.mjs +114 -25
- package/dist/component.js +111 -32
- package/dist/component.mjs +97 -18
- package/dist/handler.js +204 -158
- package/dist/handler.mjs +204 -158
- package/dist/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.esm.js +242 -59
- package/dist/index.js +243 -59
- package/dist/index.mjs +242 -59
- package/dist/middleware.js +219 -165
- package/dist/middleware.mjs +219 -165
- package/package.json +8 -8
package/dist/middleware.js
CHANGED
|
@@ -606,6 +606,7 @@ var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cann
|
|
|
606
606
|
var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
607
607
|
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);
|
|
608
608
|
var defaultLimitPolicy = (0, import_p_limit.default)(6);
|
|
609
|
+
var UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE = "Bearer token not valid or expired";
|
|
609
610
|
var ApiClientError = class _ApiClientError extends Error {
|
|
610
611
|
constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
|
|
611
612
|
super(
|
|
@@ -621,6 +622,12 @@ var ApiClientError = class _ApiClientError extends Error {
|
|
|
621
622
|
Object.setPrototypeOf(this, _ApiClientError.prototype);
|
|
622
623
|
}
|
|
623
624
|
};
|
|
625
|
+
var BearerTokenNotValidOrExpiredError = class _BearerTokenNotValidOrExpiredError extends ApiClientError {
|
|
626
|
+
constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
|
|
627
|
+
super(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId);
|
|
628
|
+
Object.setPrototypeOf(this, _BearerTokenNotValidOrExpiredError.prototype);
|
|
629
|
+
}
|
|
630
|
+
};
|
|
624
631
|
var ApiClient = class _ApiClient {
|
|
625
632
|
constructor(options) {
|
|
626
633
|
__publicField2(this, "options");
|
|
@@ -654,7 +661,7 @@ var ApiClient = class _ApiClient {
|
|
|
654
661
|
}
|
|
655
662
|
async apiClientWithResponse(fetchUri, options) {
|
|
656
663
|
return this.options.limitPolicy(async () => {
|
|
657
|
-
var _a;
|
|
664
|
+
var _a, _b;
|
|
658
665
|
const coreHeaders = this.options.apiKey ? {
|
|
659
666
|
"x-api-key": this.options.apiKey
|
|
660
667
|
} : {
|
|
@@ -690,9 +697,19 @@ var ApiClient = class _ApiClient {
|
|
|
690
697
|
} catch (e) {
|
|
691
698
|
message = `General error`;
|
|
692
699
|
}
|
|
700
|
+
if (apiResponse.status === 401 && message === UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE) {
|
|
701
|
+
throw new BearerTokenNotValidOrExpiredError(
|
|
702
|
+
message,
|
|
703
|
+
(_a = options == null ? void 0 : options.method) != null ? _a : "GET",
|
|
704
|
+
fetchUri.toString(),
|
|
705
|
+
apiResponse.status,
|
|
706
|
+
apiResponse.statusText,
|
|
707
|
+
_ApiClient.getRequestId(apiResponse)
|
|
708
|
+
);
|
|
709
|
+
}
|
|
693
710
|
throw new ApiClientError(
|
|
694
711
|
message,
|
|
695
|
-
(
|
|
712
|
+
(_b = options == null ? void 0 : options.method) != null ? _b : "GET",
|
|
696
713
|
fetchUri.toString(),
|
|
697
714
|
apiResponse.status,
|
|
698
715
|
apiResponse.statusText,
|
|
@@ -1396,6 +1413,16 @@ function createLimitPolicy({
|
|
|
1396
1413
|
return currentFunc();
|
|
1397
1414
|
};
|
|
1398
1415
|
}
|
|
1416
|
+
var ContentClientBase = class extends ApiClient {
|
|
1417
|
+
constructor(options, defaultBypassCache) {
|
|
1418
|
+
var _a, _b;
|
|
1419
|
+
super({
|
|
1420
|
+
...options,
|
|
1421
|
+
limitPolicy: (_a = options.limitPolicy) != null ? _a : createLimitPolicy({}),
|
|
1422
|
+
bypassCache: (_b = options.bypassCache) != null ? _b : defaultBypassCache
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
};
|
|
1399
1426
|
var SELECT_QUERY_PREFIX = "select.";
|
|
1400
1427
|
function appendCsv(out, key, values) {
|
|
1401
1428
|
if (values === void 0) {
|
|
@@ -1440,130 +1467,100 @@ function projectionToQuery(spec) {
|
|
|
1440
1467
|
}
|
|
1441
1468
|
return out;
|
|
1442
1469
|
}
|
|
1443
|
-
var
|
|
1444
|
-
var
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
const edgeParams = {
|
|
1470
|
-
...originParams,
|
|
1471
|
-
projectId,
|
|
1472
|
-
diagnostics: typeof params.diagnostics === "boolean" ? params.diagnostics : params.diagnostics === "no-data" ? "no-data" : void 0,
|
|
1473
|
-
...rewrittenFilters,
|
|
1474
|
-
...rewrittenSelect
|
|
1475
|
-
};
|
|
1476
|
-
const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
|
|
1477
|
-
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
|
1478
|
-
}
|
|
1479
|
-
getCompositionByNodePath(options) {
|
|
1480
|
-
return this.getOneComposition(options);
|
|
1481
|
-
}
|
|
1482
|
-
getCompositionByNodeId(options) {
|
|
1483
|
-
return this.getOneComposition(options);
|
|
1484
|
-
}
|
|
1485
|
-
getCompositionBySlug(options) {
|
|
1486
|
-
return this.getOneComposition(options);
|
|
1487
|
-
}
|
|
1488
|
-
getCompositionById(options) {
|
|
1489
|
-
return this.getOneComposition(options);
|
|
1490
|
-
}
|
|
1491
|
-
getCompositionDefaults(options) {
|
|
1492
|
-
return this.getOneComposition(options);
|
|
1493
|
-
}
|
|
1494
|
-
/** Fetches historical versions of a composition or pattern */
|
|
1495
|
-
async getCompositionHistory(options) {
|
|
1496
|
-
const historyUrl = this.createUrl("/api/v1/canvas-history", {
|
|
1497
|
-
...options,
|
|
1498
|
-
projectId: this.options.projectId
|
|
1499
|
-
});
|
|
1500
|
-
return this.apiClient(historyUrl);
|
|
1501
|
-
}
|
|
1502
|
-
getOneComposition({
|
|
1503
|
-
skipDataResolution,
|
|
1504
|
-
diagnostics,
|
|
1505
|
-
...params
|
|
1506
|
-
}) {
|
|
1507
|
-
const { projectId } = this.options;
|
|
1508
|
-
if (skipDataResolution) {
|
|
1509
|
-
return this.apiClient(this.createUrl(CANVAS_URL, { ...params, projectId }));
|
|
1510
|
-
}
|
|
1511
|
-
const edgeParams = {
|
|
1512
|
-
...params,
|
|
1513
|
-
projectId,
|
|
1514
|
-
diagnostics: typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0
|
|
1470
|
+
var CANVAS_PERSONALIZE_TYPE = "$personalization";
|
|
1471
|
+
var CANVAS_TEST_TYPE = "$test";
|
|
1472
|
+
var CANVAS_BLOCK_PARAM_TYPE = "$block";
|
|
1473
|
+
var CANVAS_PERSONALIZE_SLOT = "pz";
|
|
1474
|
+
var CANVAS_TEST_SLOT = "test";
|
|
1475
|
+
var CANVAS_DRAFT_STATE = 0;
|
|
1476
|
+
var CANVAS_PUBLISHED_STATE = 64;
|
|
1477
|
+
var CANVAS_EDITOR_STATE = 63;
|
|
1478
|
+
var CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
|
|
1479
|
+
var CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
|
|
1480
|
+
var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
|
|
1481
|
+
var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
|
|
1482
|
+
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
1483
|
+
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1484
|
+
var IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM = "is_incontext_editing_forced_settings";
|
|
1485
|
+
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
1486
|
+
function resolveCompositionSelector(args) {
|
|
1487
|
+
if ("compositionId" in args) {
|
|
1488
|
+
const { compositionId, editionId, versionId, ...readOptions } = args;
|
|
1489
|
+
return {
|
|
1490
|
+
readOptions,
|
|
1491
|
+
// raw mode matches on composition OR edition id via the compositionId param
|
|
1492
|
+
compositionId: editionId != null ? editionId : compositionId,
|
|
1493
|
+
versionId,
|
|
1494
|
+
hasCompositionId: true,
|
|
1495
|
+
pinnedEdition: editionId !== void 0
|
|
1515
1496
|
};
|
|
1516
|
-
const edgeUrl = this.createUrl("/api/v1/composition", edgeParams, this.edgeApiHost);
|
|
1517
|
-
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
|
1518
1497
|
}
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
}
|
|
1532
|
-
return { modified: response.headers.get("x-modified-at") };
|
|
1498
|
+
return { readOptions: args, hasCompositionId: false, pinnedEdition: false };
|
|
1499
|
+
}
|
|
1500
|
+
var DEFAULT_EDGE_API_HOST = "https://uniform.global";
|
|
1501
|
+
var DeliveryClientBase = class extends ContentClientBase {
|
|
1502
|
+
constructor(options) {
|
|
1503
|
+
var _a;
|
|
1504
|
+
super(
|
|
1505
|
+
options,
|
|
1506
|
+
/* defaultBypassCache */
|
|
1507
|
+
false
|
|
1508
|
+
);
|
|
1509
|
+
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : DEFAULT_EDGE_API_HOST;
|
|
1510
|
+
this.edgeRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
|
|
1533
1511
|
}
|
|
1534
|
-
/**
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
const { projectId } = this.options;
|
|
1538
|
-
await this.apiClient(fetchUri, {
|
|
1539
|
-
method: "DELETE",
|
|
1540
|
-
body: JSON.stringify({ ...body, projectId }),
|
|
1541
|
-
expectNoContent: true
|
|
1542
|
-
});
|
|
1512
|
+
/** Coerces the `diagnostics` option into the shape the edge endpoints accept. */
|
|
1513
|
+
coerceDiagnostics(diagnostics) {
|
|
1514
|
+
return typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0;
|
|
1543
1515
|
}
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1516
|
+
};
|
|
1517
|
+
var EDGE_SINGLE_URL = "/api/v1/composition";
|
|
1518
|
+
var EDGE_LIST_URL = "/api/v1/compositions";
|
|
1519
|
+
var CompositionDeliveryClient = class extends DeliveryClientBase {
|
|
1520
|
+
constructor(options) {
|
|
1521
|
+
super(options);
|
|
1549
1522
|
}
|
|
1550
|
-
/**
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1523
|
+
/** Fetches exactly one composition (throws `ApiClientError(404)` if absent). */
|
|
1524
|
+
get(args) {
|
|
1525
|
+
var _a;
|
|
1526
|
+
const { diagnostics, select, ...rest } = args;
|
|
1527
|
+
const { readOptions, compositionId, versionId, pinnedEdition } = resolveCompositionSelector(rest);
|
|
1528
|
+
const url = this.createUrl(
|
|
1529
|
+
EDGE_SINGLE_URL,
|
|
1530
|
+
{
|
|
1531
|
+
...readOptions,
|
|
1532
|
+
...projectionToQuery(select),
|
|
1533
|
+
// A pinned edition is folded into compositionId (raw matches edition or
|
|
1534
|
+
// composition id); there is no editionId query param on this endpoint.
|
|
1535
|
+
compositionId,
|
|
1536
|
+
versionId,
|
|
1537
|
+
projectId: this.options.projectId,
|
|
1538
|
+
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
1539
|
+
// editionId pins a specific edition for preview; otherwise locale-best.
|
|
1540
|
+
editions: pinnedEdition ? "raw" : "auto",
|
|
1541
|
+
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
1542
|
+
},
|
|
1543
|
+
this.edgeApiHost
|
|
1544
|
+
);
|
|
1545
|
+
return this.apiClient(url, this.edgeRequestInit);
|
|
1558
1546
|
}
|
|
1559
|
-
/**
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1547
|
+
/** Fetches a list of compositions, optionally filtered. */
|
|
1548
|
+
list(args = {}) {
|
|
1549
|
+
var _a;
|
|
1550
|
+
const { diagnostics, filters, select, ...rest } = args;
|
|
1551
|
+
const url = this.createUrl(
|
|
1552
|
+
EDGE_LIST_URL,
|
|
1553
|
+
{
|
|
1554
|
+
...rest,
|
|
1555
|
+
...rewriteFiltersForApi(filters),
|
|
1556
|
+
...projectionToQuery(select),
|
|
1557
|
+
projectId: this.options.projectId,
|
|
1558
|
+
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
1559
|
+
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
1560
|
+
},
|
|
1561
|
+
this.edgeApiHost
|
|
1562
|
+
);
|
|
1563
|
+
return this.apiClient(url, this.edgeRequestInit);
|
|
1567
1564
|
}
|
|
1568
1565
|
};
|
|
1569
1566
|
var _contentTypesUrl;
|
|
@@ -1672,14 +1669,18 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1672
1669
|
constructor(options) {
|
|
1673
1670
|
super(options);
|
|
1674
1671
|
}
|
|
1675
|
-
/** Fetches
|
|
1676
|
-
async
|
|
1672
|
+
/** Fetches a list of DataTypes for a project */
|
|
1673
|
+
async list(options) {
|
|
1677
1674
|
const { projectId } = this.options;
|
|
1678
1675
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8), { ...options, projectId });
|
|
1679
1676
|
return await this.apiClient(fetchUri);
|
|
1680
1677
|
}
|
|
1678
|
+
/** @deprecated Use {@link list} instead. */
|
|
1679
|
+
async get(options) {
|
|
1680
|
+
return this.list(options);
|
|
1681
|
+
}
|
|
1681
1682
|
/** Updates or creates (based on id) a DataType */
|
|
1682
|
-
async
|
|
1683
|
+
async save(body) {
|
|
1683
1684
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
|
|
1684
1685
|
await this.apiClient(fetchUri, {
|
|
1685
1686
|
method: "PUT",
|
|
@@ -1687,6 +1688,10 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1687
1688
|
expectNoContent: true
|
|
1688
1689
|
});
|
|
1689
1690
|
}
|
|
1691
|
+
/** @deprecated Use {@link save} instead. */
|
|
1692
|
+
async upsert(body) {
|
|
1693
|
+
return this.save(body);
|
|
1694
|
+
}
|
|
1690
1695
|
/** Deletes a DataType */
|
|
1691
1696
|
async remove(body) {
|
|
1692
1697
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
|
|
@@ -1724,22 +1729,6 @@ function getComponentPath(ancestorsAndSelf) {
|
|
|
1724
1729
|
}
|
|
1725
1730
|
return `.${path.join(".")}`;
|
|
1726
1731
|
}
|
|
1727
|
-
var CANVAS_PERSONALIZE_TYPE = "$personalization";
|
|
1728
|
-
var CANVAS_TEST_TYPE = "$test";
|
|
1729
|
-
var CANVAS_BLOCK_PARAM_TYPE = "$block";
|
|
1730
|
-
var CANVAS_PERSONALIZE_SLOT = "pz";
|
|
1731
|
-
var CANVAS_TEST_SLOT = "test";
|
|
1732
|
-
var CANVAS_DRAFT_STATE = 0;
|
|
1733
|
-
var CANVAS_PUBLISHED_STATE = 64;
|
|
1734
|
-
var CANVAS_EDITOR_STATE = 63;
|
|
1735
|
-
var CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
|
|
1736
|
-
var CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
|
|
1737
|
-
var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
|
|
1738
|
-
var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
|
|
1739
|
-
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
1740
|
-
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1741
|
-
var IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM = "is_incontext_editing_forced_settings";
|
|
1742
|
-
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
1743
1732
|
function isRootEntryReference(root) {
|
|
1744
1733
|
return root.type === "root" && isEntryData(root.node);
|
|
1745
1734
|
}
|
|
@@ -1759,9 +1748,9 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1759
1748
|
let bufferStartIndex = 0;
|
|
1760
1749
|
let bufferEndIndex = 0;
|
|
1761
1750
|
let tokenCount = 0;
|
|
1762
|
-
const handleToken = (token, type) => {
|
|
1751
|
+
const handleToken = (token, type, offset) => {
|
|
1763
1752
|
tokenCount++;
|
|
1764
|
-
return onToken == null ? void 0 : onToken(token, type);
|
|
1753
|
+
return onToken == null ? void 0 : onToken(token, type, offset);
|
|
1765
1754
|
};
|
|
1766
1755
|
let state = "text";
|
|
1767
1756
|
for (let index = 0; index < serialized.length; index++) {
|
|
@@ -1772,7 +1761,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1772
1761
|
if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
|
|
1773
1762
|
if (serialized[index - 1] === escapeCharacter) {
|
|
1774
1763
|
bufferEndIndex -= escapeCharacter.length;
|
|
1775
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
1764
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
1776
1765
|
return tokenCount;
|
|
1777
1766
|
}
|
|
1778
1767
|
bufferStartIndex = index;
|
|
@@ -1781,12 +1770,12 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1781
1770
|
}
|
|
1782
1771
|
if (state === "variable") {
|
|
1783
1772
|
const textStart = bufferStartIndex - variablePrefix.length;
|
|
1784
|
-
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
|
|
1773
|
+
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text", textStart) === false) {
|
|
1785
1774
|
return tokenCount;
|
|
1786
1775
|
}
|
|
1787
1776
|
bufferStartIndex = bufferEndIndex;
|
|
1788
1777
|
} else if (bufferEndIndex > bufferStartIndex) {
|
|
1789
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
1778
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
1790
1779
|
return tokenCount;
|
|
1791
1780
|
}
|
|
1792
1781
|
bufferStartIndex = bufferEndIndex;
|
|
@@ -1804,7 +1793,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1804
1793
|
state = "text";
|
|
1805
1794
|
if (bufferEndIndex > bufferStartIndex) {
|
|
1806
1795
|
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
|
1807
|
-
if (handleToken(unescapedVariableName, "variable") === false) {
|
|
1796
|
+
if (handleToken(unescapedVariableName, "variable", bufferStartIndex) === false) {
|
|
1808
1797
|
return tokenCount;
|
|
1809
1798
|
}
|
|
1810
1799
|
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
|
@@ -1818,7 +1807,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1818
1807
|
bufferStartIndex -= variablePrefix.length;
|
|
1819
1808
|
}
|
|
1820
1809
|
if (bufferStartIndex < serialized.length) {
|
|
1821
|
-
handleToken(serialized.substring(bufferStartIndex), state);
|
|
1810
|
+
handleToken(serialized.substring(bufferStartIndex), state, bufferStartIndex);
|
|
1822
1811
|
}
|
|
1823
1812
|
return tokenCount;
|
|
1824
1813
|
}
|
|
@@ -2326,6 +2315,48 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
|
|
|
2326
2315
|
_baseUrl = /* @__PURE__ */ new WeakMap();
|
|
2327
2316
|
__privateAdd3(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
|
|
2328
2317
|
var _url22;
|
|
2318
|
+
var _NotificationsClient = class _NotificationsClient2 extends ApiClient {
|
|
2319
|
+
constructor(options) {
|
|
2320
|
+
super(options);
|
|
2321
|
+
}
|
|
2322
|
+
/**
|
|
2323
|
+
* Lists notifications for the current user.
|
|
2324
|
+
*
|
|
2325
|
+
* @deprecated This API is experimental and may change without notice.
|
|
2326
|
+
*/
|
|
2327
|
+
async list(options) {
|
|
2328
|
+
const fetchUri = this.createUrl(__privateGet3(_NotificationsClient2, _url22), options);
|
|
2329
|
+
return await this.apiClient(fetchUri);
|
|
2330
|
+
}
|
|
2331
|
+
/**
|
|
2332
|
+
* Creates a notification for one or more recipients.
|
|
2333
|
+
*
|
|
2334
|
+
* @deprecated This API is experimental and may change without notice.
|
|
2335
|
+
*/
|
|
2336
|
+
async create(body) {
|
|
2337
|
+
const fetchUri = this.createUrl(__privateGet3(_NotificationsClient2, _url22));
|
|
2338
|
+
return await this.apiClient(fetchUri, {
|
|
2339
|
+
method: "POST",
|
|
2340
|
+
body: JSON.stringify(body)
|
|
2341
|
+
});
|
|
2342
|
+
}
|
|
2343
|
+
/**
|
|
2344
|
+
* Updates the read state of the current user's notifications.
|
|
2345
|
+
*
|
|
2346
|
+
* @deprecated This API is experimental and may change without notice.
|
|
2347
|
+
*/
|
|
2348
|
+
async setReadState(body) {
|
|
2349
|
+
const fetchUri = this.createUrl(__privateGet3(_NotificationsClient2, _url22));
|
|
2350
|
+
await this.apiClient(fetchUri, {
|
|
2351
|
+
method: "PATCH",
|
|
2352
|
+
body: JSON.stringify(body),
|
|
2353
|
+
expectNoContent: true
|
|
2354
|
+
});
|
|
2355
|
+
}
|
|
2356
|
+
};
|
|
2357
|
+
_url22 = /* @__PURE__ */ new WeakMap();
|
|
2358
|
+
__privateAdd3(_NotificationsClient, _url22, "/api/v1/notifications");
|
|
2359
|
+
var _url32;
|
|
2329
2360
|
var _projectsUrl;
|
|
2330
2361
|
var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
2331
2362
|
constructor(options) {
|
|
@@ -2333,7 +2364,7 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
2333
2364
|
}
|
|
2334
2365
|
/** Fetches single Project */
|
|
2335
2366
|
async get(options) {
|
|
2336
|
-
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2,
|
|
2367
|
+
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url32), { ...options });
|
|
2337
2368
|
return await this.apiClient(fetchUri);
|
|
2338
2369
|
}
|
|
2339
2370
|
/**
|
|
@@ -2341,31 +2372,43 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
2341
2372
|
* When teamId is provided, returns a single team with its projects.
|
|
2342
2373
|
* When omitted, returns all accessible teams and their projects.
|
|
2343
2374
|
*/
|
|
2344
|
-
async
|
|
2375
|
+
async list(options) {
|
|
2345
2376
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
|
|
2346
2377
|
return await this.apiClient(fetchUri);
|
|
2347
2378
|
}
|
|
2379
|
+
/** @deprecated Use {@link list} instead. */
|
|
2380
|
+
async getProjects(options) {
|
|
2381
|
+
return this.list(options);
|
|
2382
|
+
}
|
|
2348
2383
|
/** Updates or creates (based on id) a Project */
|
|
2349
|
-
async
|
|
2350
|
-
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2,
|
|
2384
|
+
async save(body) {
|
|
2385
|
+
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url32));
|
|
2351
2386
|
return await this.apiClient(fetchUri, {
|
|
2352
2387
|
method: "PUT",
|
|
2353
2388
|
body: JSON.stringify({ ...body })
|
|
2354
2389
|
});
|
|
2355
2390
|
}
|
|
2391
|
+
/** @deprecated Use {@link save} instead. */
|
|
2392
|
+
async upsert(body) {
|
|
2393
|
+
return this.save(body);
|
|
2394
|
+
}
|
|
2356
2395
|
/** Deletes a Project */
|
|
2357
|
-
async
|
|
2358
|
-
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2,
|
|
2396
|
+
async remove(body) {
|
|
2397
|
+
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url32));
|
|
2359
2398
|
await this.apiClient(fetchUri, {
|
|
2360
2399
|
method: "DELETE",
|
|
2361
2400
|
body: JSON.stringify({ ...body }),
|
|
2362
2401
|
expectNoContent: true
|
|
2363
2402
|
});
|
|
2364
2403
|
}
|
|
2404
|
+
/** @deprecated Use {@link remove} instead. */
|
|
2405
|
+
async delete(body) {
|
|
2406
|
+
return this.remove(body);
|
|
2407
|
+
}
|
|
2365
2408
|
};
|
|
2366
|
-
|
|
2409
|
+
_url32 = /* @__PURE__ */ new WeakMap();
|
|
2367
2410
|
_projectsUrl = /* @__PURE__ */ new WeakMap();
|
|
2368
|
-
__privateAdd3(_ProjectClient,
|
|
2411
|
+
__privateAdd3(_ProjectClient, _url32, "/api/v1/project");
|
|
2369
2412
|
__privateAdd3(_ProjectClient, _projectsUrl, "/api/v1/projects");
|
|
2370
2413
|
var ROUTE_URL = "/api/v1/route";
|
|
2371
2414
|
var RouteClient = class extends ApiClient {
|
|
@@ -2377,8 +2420,14 @@ var RouteClient = class extends ApiClient {
|
|
|
2377
2420
|
super(options);
|
|
2378
2421
|
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
|
|
2379
2422
|
}
|
|
2380
|
-
/**
|
|
2381
|
-
|
|
2423
|
+
/**
|
|
2424
|
+
* Resolves a route to a composition, redirect, or not-found result.
|
|
2425
|
+
*
|
|
2426
|
+
* An optional `select` projection applies to the resolved composition when
|
|
2427
|
+
* the route matches one; redirect / notFound responses pass through
|
|
2428
|
+
* untouched.
|
|
2429
|
+
*/
|
|
2430
|
+
async get(options) {
|
|
2382
2431
|
const { projectId } = this.options;
|
|
2383
2432
|
const { select, ...rest } = options != null ? options : {};
|
|
2384
2433
|
const rewrittenSelect = projectionToQuery(select);
|
|
@@ -2388,6 +2437,10 @@ var RouteClient = class extends ApiClient {
|
|
|
2388
2437
|
this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
|
|
2389
2438
|
);
|
|
2390
2439
|
}
|
|
2440
|
+
/** @deprecated use {@link RouteClient.get} instead (renamed). */
|
|
2441
|
+
async getRoute(options) {
|
|
2442
|
+
return this.get(options);
|
|
2443
|
+
}
|
|
2391
2444
|
};
|
|
2392
2445
|
var getDataSourceVariantFromRouteGetParams = (params, defaultPreviewState) => {
|
|
2393
2446
|
var _a, _b;
|
|
@@ -2690,9 +2743,9 @@ function createLimitPolicy2({
|
|
|
2690
2743
|
}
|
|
2691
2744
|
|
|
2692
2745
|
// src/clients/canvas.ts
|
|
2693
|
-
var
|
|
2746
|
+
var buildCanvasClientOptions = (options) => {
|
|
2694
2747
|
const cache = resolveCanvasCache(options);
|
|
2695
|
-
return
|
|
2748
|
+
return {
|
|
2696
2749
|
projectId: env.getProjectId(),
|
|
2697
2750
|
apiHost: env.getApiHost(),
|
|
2698
2751
|
apiKey: env.getApiKey(),
|
|
@@ -2740,7 +2793,10 @@ var getCanvasClient = (options) => {
|
|
|
2740
2793
|
}
|
|
2741
2794
|
});
|
|
2742
2795
|
}
|
|
2743
|
-
}
|
|
2796
|
+
};
|
|
2797
|
+
};
|
|
2798
|
+
var getCompositionDeliveryClient = (options) => {
|
|
2799
|
+
return new CompositionDeliveryClient(buildCanvasClientOptions(options));
|
|
2744
2800
|
};
|
|
2745
2801
|
|
|
2746
2802
|
// src/config/helpers.ts
|
|
@@ -2963,14 +3019,14 @@ var DefaultDataClient = class {
|
|
|
2963
3019
|
if (oldCachedRoute) {
|
|
2964
3020
|
(0, import_functions.waitUntil)(
|
|
2965
3021
|
(async () => {
|
|
2966
|
-
const result2 = await routeClient.
|
|
3022
|
+
const result2 = await routeClient.get(route);
|
|
2967
3023
|
await cacheNewRoute(result2);
|
|
2968
3024
|
})()
|
|
2969
3025
|
);
|
|
2970
3026
|
return oldCachedRoute;
|
|
2971
3027
|
}
|
|
2972
3028
|
}
|
|
2973
|
-
const result = await routeClient.
|
|
3029
|
+
const result = await routeClient.get(route);
|
|
2974
3030
|
(0, import_functions.waitUntil)(
|
|
2975
3031
|
(async () => {
|
|
2976
3032
|
await Promise.all([
|
|
@@ -5568,7 +5624,6 @@ var retrieveRouteByPath = async ({
|
|
|
5568
5624
|
releaseId,
|
|
5569
5625
|
locale
|
|
5570
5626
|
}) => {
|
|
5571
|
-
var _a;
|
|
5572
5627
|
return await dataClient.getRoute({
|
|
5573
5628
|
source: "middleware",
|
|
5574
5629
|
searchParams,
|
|
@@ -5578,7 +5633,6 @@ var retrieveRouteByPath = async ({
|
|
|
5578
5633
|
state,
|
|
5579
5634
|
dataSourceVariant: getDataSourceVariantFromRouteGetParams({}, state),
|
|
5580
5635
|
withComponentIDs: true,
|
|
5581
|
-
withContentSourceMap: (_a = getServerConfig().experimental) == null ? void 0 : _a.vercelVisualEditing,
|
|
5582
5636
|
releaseId,
|
|
5583
5637
|
locale,
|
|
5584
5638
|
ignoreRedirects: shouldIgnoreRedirects({ state })
|
|
@@ -5667,7 +5721,7 @@ var handlePlaygroundRequest = async ({
|
|
|
5667
5721
|
{ status: 400 }
|
|
5668
5722
|
);
|
|
5669
5723
|
}
|
|
5670
|
-
const canvasClient =
|
|
5724
|
+
const canvasClient = getCompositionDeliveryClient({
|
|
5671
5725
|
cache: {
|
|
5672
5726
|
type: "no-cache"
|
|
5673
5727
|
}
|
|
@@ -5677,7 +5731,7 @@ var handlePlaygroundRequest = async ({
|
|
|
5677
5731
|
for (let i = 0; i < possibleStates.length; i++) {
|
|
5678
5732
|
const state = possibleStates[i];
|
|
5679
5733
|
try {
|
|
5680
|
-
composition = await canvasClient.
|
|
5734
|
+
composition = await canvasClient.get({
|
|
5681
5735
|
compositionId: id,
|
|
5682
5736
|
state,
|
|
5683
5737
|
withComponentIDs: true
|