@uniformdev/next-app-router 20.72.3-alpha.5 → 20.72.3-alpha.52
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-BV6YnA2a.d.ts → UniformComposition-BWxMuY7i.d.ts} +2 -2
- package/dist/{UniformComposition-scIgVvIH.d.mts → UniformComposition-Bo6UsTDC.d.mts} +2 -2
- package/dist/cache.d.mts +2 -2
- package/dist/cache.d.ts +2 -2
- package/dist/cache.js +67 -20
- package/dist/cache.mjs +67 -20
- package/dist/{client-BlKZeE6C.d.mts → client-DRMp2gpi.d.mts} +1 -0
- package/dist/{client-BlKZeE6C.d.ts → client-DRMp2gpi.d.ts} +1 -0
- package/dist/compat.d.mts +3 -3
- package/dist/compat.d.ts +3 -3
- package/dist/component.js +49 -12
- package/dist/component.mjs +49 -12
- package/dist/handler.js +157 -153
- package/dist/handler.mjs +157 -153
- package/dist/index.d.mts +12 -7
- package/dist/index.d.ts +12 -7
- package/dist/index.esm.js +195 -54
- package/dist/index.js +196 -54
- package/dist/index.mjs +195 -54
- package/dist/middleware.d.mts +1 -1
- package/dist/middleware.d.ts +1 -1
- package/dist/middleware.js +172 -160
- package/dist/middleware.mjs +172 -160
- package/dist/{resolveRouteFromCode-3u61IwOW.d.ts → resolveRouteFromCode-Bhz8EJBu.d.ts} +1 -1
- package/dist/{resolveRouteFromCode-_CdAMtVM.d.mts → resolveRouteFromCode-C0dkUV2T.d.mts} +1 -1
- package/package.json +11 -9
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
|
}
|
|
@@ -2341,20 +2330,28 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
2341
2330
|
* When teamId is provided, returns a single team with its projects.
|
|
2342
2331
|
* When omitted, returns all accessible teams and their projects.
|
|
2343
2332
|
*/
|
|
2344
|
-
async
|
|
2333
|
+
async list(options) {
|
|
2345
2334
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
|
|
2346
2335
|
return await this.apiClient(fetchUri);
|
|
2347
2336
|
}
|
|
2337
|
+
/** @deprecated Use {@link list} instead. */
|
|
2338
|
+
async getProjects(options) {
|
|
2339
|
+
return this.list(options);
|
|
2340
|
+
}
|
|
2348
2341
|
/** Updates or creates (based on id) a Project */
|
|
2349
|
-
async
|
|
2342
|
+
async save(body) {
|
|
2350
2343
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
|
|
2351
2344
|
return await this.apiClient(fetchUri, {
|
|
2352
2345
|
method: "PUT",
|
|
2353
2346
|
body: JSON.stringify({ ...body })
|
|
2354
2347
|
});
|
|
2355
2348
|
}
|
|
2349
|
+
/** @deprecated Use {@link save} instead. */
|
|
2350
|
+
async upsert(body) {
|
|
2351
|
+
return this.save(body);
|
|
2352
|
+
}
|
|
2356
2353
|
/** Deletes a Project */
|
|
2357
|
-
async
|
|
2354
|
+
async remove(body) {
|
|
2358
2355
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
|
|
2359
2356
|
await this.apiClient(fetchUri, {
|
|
2360
2357
|
method: "DELETE",
|
|
@@ -2362,6 +2359,10 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
2362
2359
|
expectNoContent: true
|
|
2363
2360
|
});
|
|
2364
2361
|
}
|
|
2362
|
+
/** @deprecated Use {@link remove} instead. */
|
|
2363
|
+
async delete(body) {
|
|
2364
|
+
return this.remove(body);
|
|
2365
|
+
}
|
|
2365
2366
|
};
|
|
2366
2367
|
_url22 = /* @__PURE__ */ new WeakMap();
|
|
2367
2368
|
_projectsUrl = /* @__PURE__ */ new WeakMap();
|
|
@@ -2377,8 +2378,14 @@ var RouteClient = class extends ApiClient {
|
|
|
2377
2378
|
super(options);
|
|
2378
2379
|
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
|
|
2379
2380
|
}
|
|
2380
|
-
/**
|
|
2381
|
-
|
|
2381
|
+
/**
|
|
2382
|
+
* Resolves a route to a composition, redirect, or not-found result.
|
|
2383
|
+
*
|
|
2384
|
+
* An optional `select` projection applies to the resolved composition when
|
|
2385
|
+
* the route matches one; redirect / notFound responses pass through
|
|
2386
|
+
* untouched.
|
|
2387
|
+
*/
|
|
2388
|
+
async get(options) {
|
|
2382
2389
|
const { projectId } = this.options;
|
|
2383
2390
|
const { select, ...rest } = options != null ? options : {};
|
|
2384
2391
|
const rewrittenSelect = projectionToQuery(select);
|
|
@@ -2388,6 +2395,10 @@ var RouteClient = class extends ApiClient {
|
|
|
2388
2395
|
this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
|
|
2389
2396
|
);
|
|
2390
2397
|
}
|
|
2398
|
+
/** @deprecated use {@link RouteClient.get} instead (renamed). */
|
|
2399
|
+
async getRoute(options) {
|
|
2400
|
+
return this.get(options);
|
|
2401
|
+
}
|
|
2391
2402
|
};
|
|
2392
2403
|
var getDataSourceVariantFromRouteGetParams = (params, defaultPreviewState) => {
|
|
2393
2404
|
var _a, _b;
|
|
@@ -2690,9 +2701,9 @@ function createLimitPolicy2({
|
|
|
2690
2701
|
}
|
|
2691
2702
|
|
|
2692
2703
|
// src/clients/canvas.ts
|
|
2693
|
-
var
|
|
2704
|
+
var buildCanvasClientOptions = (options) => {
|
|
2694
2705
|
const cache = resolveCanvasCache(options);
|
|
2695
|
-
return
|
|
2706
|
+
return {
|
|
2696
2707
|
projectId: env.getProjectId(),
|
|
2697
2708
|
apiHost: env.getApiHost(),
|
|
2698
2709
|
apiKey: env.getApiKey(),
|
|
@@ -2740,7 +2751,10 @@ var getCanvasClient = (options) => {
|
|
|
2740
2751
|
}
|
|
2741
2752
|
});
|
|
2742
2753
|
}
|
|
2743
|
-
}
|
|
2754
|
+
};
|
|
2755
|
+
};
|
|
2756
|
+
var getCompositionDeliveryClient = (options) => {
|
|
2757
|
+
return new CompositionDeliveryClient(buildCanvasClientOptions(options));
|
|
2744
2758
|
};
|
|
2745
2759
|
|
|
2746
2760
|
// src/config/helpers.ts
|
|
@@ -2963,14 +2977,14 @@ var DefaultDataClient = class {
|
|
|
2963
2977
|
if (oldCachedRoute) {
|
|
2964
2978
|
(0, import_functions.waitUntil)(
|
|
2965
2979
|
(async () => {
|
|
2966
|
-
const result2 = await routeClient.
|
|
2980
|
+
const result2 = await routeClient.get(route);
|
|
2967
2981
|
await cacheNewRoute(result2);
|
|
2968
2982
|
})()
|
|
2969
2983
|
);
|
|
2970
2984
|
return oldCachedRoute;
|
|
2971
2985
|
}
|
|
2972
2986
|
}
|
|
2973
|
-
const result = await routeClient.
|
|
2987
|
+
const result = await routeClient.get(route);
|
|
2974
2988
|
(0, import_functions.waitUntil)(
|
|
2975
2989
|
(async () => {
|
|
2976
2990
|
await Promise.all([
|
|
@@ -5568,7 +5582,6 @@ var retrieveRouteByPath = async ({
|
|
|
5568
5582
|
releaseId,
|
|
5569
5583
|
locale
|
|
5570
5584
|
}) => {
|
|
5571
|
-
var _a;
|
|
5572
5585
|
return await dataClient.getRoute({
|
|
5573
5586
|
source: "middleware",
|
|
5574
5587
|
searchParams,
|
|
@@ -5578,7 +5591,6 @@ var retrieveRouteByPath = async ({
|
|
|
5578
5591
|
state,
|
|
5579
5592
|
dataSourceVariant: getDataSourceVariantFromRouteGetParams({}, state),
|
|
5580
5593
|
withComponentIDs: true,
|
|
5581
|
-
withContentSourceMap: (_a = getServerConfig().experimental) == null ? void 0 : _a.vercelVisualEditing,
|
|
5582
5594
|
releaseId,
|
|
5583
5595
|
locale,
|
|
5584
5596
|
ignoreRedirects: shouldIgnoreRedirects({ state })
|
|
@@ -5667,7 +5679,7 @@ var handlePlaygroundRequest = async ({
|
|
|
5667
5679
|
{ status: 400 }
|
|
5668
5680
|
);
|
|
5669
5681
|
}
|
|
5670
|
-
const canvasClient =
|
|
5682
|
+
const canvasClient = getCompositionDeliveryClient({
|
|
5671
5683
|
cache: {
|
|
5672
5684
|
type: "no-cache"
|
|
5673
5685
|
}
|
|
@@ -5677,7 +5689,7 @@ var handlePlaygroundRequest = async ({
|
|
|
5677
5689
|
for (let i = 0; i < possibleStates.length; i++) {
|
|
5678
5690
|
const state = possibleStates[i];
|
|
5679
5691
|
try {
|
|
5680
|
-
composition = await canvasClient.
|
|
5692
|
+
composition = await canvasClient.get({
|
|
5681
5693
|
compositionId: id,
|
|
5682
5694
|
state,
|
|
5683
5695
|
withComponentIDs: true
|