@uniformdev/next-app-router 20.72.2-alpha.3 → 20.72.3-alpha.14
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 +95 -23
- package/dist/cache.mjs +95 -23
- package/dist/component.js +78 -16
- package/dist/component.mjs +79 -17
- package/dist/handler.js +209 -150
- package/dist/handler.mjs +209 -150
- package/dist/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.esm.js +250 -52
- package/dist/index.js +251 -52
- package/dist/index.mjs +250 -52
- package/dist/middleware.js +200 -163
- package/dist/middleware.mjs +200 -163
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -408,6 +408,7 @@ __export(index_exports, {
|
|
|
408
408
|
expireMiddlewareCacheTag: () => expireMiddlewareCacheTag,
|
|
409
409
|
findRouteMatch: () => findRouteMatch,
|
|
410
410
|
getCanvasClient: () => getCanvasClient,
|
|
411
|
+
getCompositionDeliveryClient: () => getCompositionDeliveryClient,
|
|
411
412
|
getManifest: () => getManifest,
|
|
412
413
|
getManifestClient: () => getManifestClient,
|
|
413
414
|
getProjectMapClient: () => getProjectMapClient,
|
|
@@ -1225,6 +1226,16 @@ function createLimitPolicy({
|
|
|
1225
1226
|
return currentFunc();
|
|
1226
1227
|
};
|
|
1227
1228
|
}
|
|
1229
|
+
var ContentClientBase = class extends ApiClient {
|
|
1230
|
+
constructor(options, defaultBypassCache) {
|
|
1231
|
+
var _a, _b;
|
|
1232
|
+
super({
|
|
1233
|
+
...options,
|
|
1234
|
+
limitPolicy: (_a = options.limitPolicy) != null ? _a : createLimitPolicy({}),
|
|
1235
|
+
bypassCache: (_b = options.bypassCache) != null ? _b : defaultBypassCache
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
};
|
|
1228
1239
|
var SELECT_QUERY_PREFIX = "select.";
|
|
1229
1240
|
function appendCsv(out, key, values) {
|
|
1230
1241
|
if (values === void 0) {
|
|
@@ -1269,7 +1280,105 @@ function projectionToQuery(spec) {
|
|
|
1269
1280
|
}
|
|
1270
1281
|
return out;
|
|
1271
1282
|
}
|
|
1272
|
-
var
|
|
1283
|
+
var CANVAS_PERSONALIZE_TYPE = "$personalization";
|
|
1284
|
+
var CANVAS_TEST_TYPE = "$test";
|
|
1285
|
+
var CANVAS_BLOCK_PARAM_TYPE = "$block";
|
|
1286
|
+
var CANVAS_PERSONALIZE_SLOT = "pz";
|
|
1287
|
+
var CANVAS_TEST_SLOT = "test";
|
|
1288
|
+
var CANVAS_DRAFT_STATE = 0;
|
|
1289
|
+
var CANVAS_PUBLISHED_STATE = 64;
|
|
1290
|
+
var CANVAS_EDITOR_STATE = 63;
|
|
1291
|
+
var CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
|
|
1292
|
+
var CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
|
|
1293
|
+
var CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
|
|
1294
|
+
var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
|
|
1295
|
+
var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
|
|
1296
|
+
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
1297
|
+
var CANVAS_CONTEXTUAL_EDITING_PARAM = "$contextualEditing";
|
|
1298
|
+
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1299
|
+
var PLACEHOLDER_ID = "placeholder";
|
|
1300
|
+
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
1301
|
+
function resolveCompositionSelector(args) {
|
|
1302
|
+
if ("compositionId" in args) {
|
|
1303
|
+
const { compositionId, editionId, versionId, ...readOptions } = args;
|
|
1304
|
+
return {
|
|
1305
|
+
readOptions,
|
|
1306
|
+
// raw mode matches on composition OR edition id via the compositionId param
|
|
1307
|
+
compositionId: editionId != null ? editionId : compositionId,
|
|
1308
|
+
versionId,
|
|
1309
|
+
hasCompositionId: true,
|
|
1310
|
+
pinnedEdition: editionId !== void 0
|
|
1311
|
+
};
|
|
1312
|
+
}
|
|
1313
|
+
return { readOptions: args, hasCompositionId: false, pinnedEdition: false };
|
|
1314
|
+
}
|
|
1315
|
+
var DEFAULT_EDGE_API_HOST = "https://uniform.global";
|
|
1316
|
+
var DeliveryClientBase = class extends ContentClientBase {
|
|
1317
|
+
constructor(options) {
|
|
1318
|
+
var _a;
|
|
1319
|
+
super(
|
|
1320
|
+
options,
|
|
1321
|
+
/* defaultBypassCache */
|
|
1322
|
+
false
|
|
1323
|
+
);
|
|
1324
|
+
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : DEFAULT_EDGE_API_HOST;
|
|
1325
|
+
this.edgeRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
|
|
1326
|
+
}
|
|
1327
|
+
/** Coerces the `diagnostics` option into the shape the edge endpoints accept. */
|
|
1328
|
+
coerceDiagnostics(diagnostics) {
|
|
1329
|
+
return typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0;
|
|
1330
|
+
}
|
|
1331
|
+
};
|
|
1332
|
+
var EDGE_SINGLE_URL = "/api/v1/composition";
|
|
1333
|
+
var EDGE_LIST_URL = "/api/v1/compositions";
|
|
1334
|
+
var CompositionDeliveryClient = class extends DeliveryClientBase {
|
|
1335
|
+
constructor(options) {
|
|
1336
|
+
super(options);
|
|
1337
|
+
}
|
|
1338
|
+
/** Fetches exactly one composition (throws `ApiClientError(404)` if absent). */
|
|
1339
|
+
get(args) {
|
|
1340
|
+
var _a;
|
|
1341
|
+
const { diagnostics, select, ...rest } = args;
|
|
1342
|
+
const { readOptions, compositionId, versionId, pinnedEdition } = resolveCompositionSelector(rest);
|
|
1343
|
+
const url = this.createUrl(
|
|
1344
|
+
EDGE_SINGLE_URL,
|
|
1345
|
+
{
|
|
1346
|
+
...readOptions,
|
|
1347
|
+
...projectionToQuery(select),
|
|
1348
|
+
// A pinned edition is folded into compositionId (raw matches edition or
|
|
1349
|
+
// composition id); there is no editionId query param on this endpoint.
|
|
1350
|
+
compositionId,
|
|
1351
|
+
versionId,
|
|
1352
|
+
projectId: this.options.projectId,
|
|
1353
|
+
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
1354
|
+
// editionId pins a specific edition for preview; otherwise locale-best.
|
|
1355
|
+
editions: pinnedEdition ? "raw" : "auto",
|
|
1356
|
+
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
1357
|
+
},
|
|
1358
|
+
this.edgeApiHost
|
|
1359
|
+
);
|
|
1360
|
+
return this.apiClient(url, this.edgeRequestInit);
|
|
1361
|
+
}
|
|
1362
|
+
/** Fetches a list of compositions, optionally filtered. */
|
|
1363
|
+
list(args = {}) {
|
|
1364
|
+
var _a;
|
|
1365
|
+
const { diagnostics, filters, select, ...rest } = args;
|
|
1366
|
+
const url = this.createUrl(
|
|
1367
|
+
EDGE_LIST_URL,
|
|
1368
|
+
{
|
|
1369
|
+
...rest,
|
|
1370
|
+
...rewriteFiltersForApi(filters),
|
|
1371
|
+
...projectionToQuery(select),
|
|
1372
|
+
projectId: this.options.projectId,
|
|
1373
|
+
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
1374
|
+
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
1375
|
+
},
|
|
1376
|
+
this.edgeApiHost
|
|
1377
|
+
);
|
|
1378
|
+
return this.apiClient(url, this.edgeRequestInit);
|
|
1379
|
+
}
|
|
1380
|
+
};
|
|
1381
|
+
var CANVAS_URL2 = "/api/v1/canvas";
|
|
1273
1382
|
var CanvasClient = class extends ApiClient {
|
|
1274
1383
|
constructor(options) {
|
|
1275
1384
|
var _a;
|
|
@@ -1287,7 +1396,7 @@ var CanvasClient = class extends ApiClient {
|
|
|
1287
1396
|
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
1288
1397
|
const rewrittenSelect = projectionToQuery(select);
|
|
1289
1398
|
if (!resolveData) {
|
|
1290
|
-
const fetchUri = this.createUrl(
|
|
1399
|
+
const fetchUri = this.createUrl(CANVAS_URL2, {
|
|
1291
1400
|
...originParams,
|
|
1292
1401
|
projectId,
|
|
1293
1402
|
...rewrittenFilters,
|
|
@@ -1335,7 +1444,7 @@ var CanvasClient = class extends ApiClient {
|
|
|
1335
1444
|
}) {
|
|
1336
1445
|
const { projectId } = this.options;
|
|
1337
1446
|
if (skipDataResolution) {
|
|
1338
|
-
return this.apiClient(this.createUrl(
|
|
1447
|
+
return this.apiClient(this.createUrl(CANVAS_URL2, { ...params, projectId }));
|
|
1339
1448
|
}
|
|
1340
1449
|
const edgeParams = {
|
|
1341
1450
|
...params,
|
|
@@ -1347,7 +1456,7 @@ var CanvasClient = class extends ApiClient {
|
|
|
1347
1456
|
}
|
|
1348
1457
|
/** Updates or creates a Canvas component definition */
|
|
1349
1458
|
async updateComposition(body, options) {
|
|
1350
|
-
const fetchUri = this.createUrl(
|
|
1459
|
+
const fetchUri = this.createUrl(CANVAS_URL2);
|
|
1351
1460
|
const headers = {};
|
|
1352
1461
|
if (options == null ? void 0 : options.ifUnmodifiedSince) {
|
|
1353
1462
|
headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
|
|
@@ -1362,7 +1471,7 @@ var CanvasClient = class extends ApiClient {
|
|
|
1362
1471
|
}
|
|
1363
1472
|
/** Deletes a Canvas component definition */
|
|
1364
1473
|
async removeComposition(body) {
|
|
1365
|
-
const fetchUri = this.createUrl(
|
|
1474
|
+
const fetchUri = this.createUrl(CANVAS_URL2);
|
|
1366
1475
|
const { projectId } = this.options;
|
|
1367
1476
|
await this.apiClient(fetchUri, {
|
|
1368
1477
|
method: "DELETE",
|
|
@@ -1501,14 +1610,18 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1501
1610
|
constructor(options) {
|
|
1502
1611
|
super(options);
|
|
1503
1612
|
}
|
|
1504
|
-
/** Fetches
|
|
1505
|
-
async
|
|
1613
|
+
/** Fetches a list of DataTypes for a project */
|
|
1614
|
+
async list(options) {
|
|
1506
1615
|
const { projectId } = this.options;
|
|
1507
1616
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8), { ...options, projectId });
|
|
1508
1617
|
return await this.apiClient(fetchUri);
|
|
1509
1618
|
}
|
|
1619
|
+
/** @deprecated Use {@link list} instead. */
|
|
1620
|
+
async get(options) {
|
|
1621
|
+
return this.list(options);
|
|
1622
|
+
}
|
|
1510
1623
|
/** Updates or creates (based on id) a DataType */
|
|
1511
|
-
async
|
|
1624
|
+
async save(body) {
|
|
1512
1625
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
|
|
1513
1626
|
await this.apiClient(fetchUri, {
|
|
1514
1627
|
method: "PUT",
|
|
@@ -1516,6 +1629,10 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1516
1629
|
expectNoContent: true
|
|
1517
1630
|
});
|
|
1518
1631
|
}
|
|
1632
|
+
/** @deprecated Use {@link save} instead. */
|
|
1633
|
+
async upsert(body) {
|
|
1634
|
+
return this.save(body);
|
|
1635
|
+
}
|
|
1519
1636
|
/** Deletes a DataType */
|
|
1520
1637
|
async remove(body) {
|
|
1521
1638
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
|
|
@@ -1553,24 +1670,6 @@ function getComponentPath(ancestorsAndSelf) {
|
|
|
1553
1670
|
}
|
|
1554
1671
|
return `.${path.join(".")}`;
|
|
1555
1672
|
}
|
|
1556
|
-
var CANVAS_PERSONALIZE_TYPE = "$personalization";
|
|
1557
|
-
var CANVAS_TEST_TYPE = "$test";
|
|
1558
|
-
var CANVAS_BLOCK_PARAM_TYPE = "$block";
|
|
1559
|
-
var CANVAS_PERSONALIZE_SLOT = "pz";
|
|
1560
|
-
var CANVAS_TEST_SLOT = "test";
|
|
1561
|
-
var CANVAS_DRAFT_STATE = 0;
|
|
1562
|
-
var CANVAS_PUBLISHED_STATE = 64;
|
|
1563
|
-
var CANVAS_EDITOR_STATE = 63;
|
|
1564
|
-
var CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
|
|
1565
|
-
var CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
|
|
1566
|
-
var CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
|
|
1567
|
-
var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
|
|
1568
|
-
var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
|
|
1569
|
-
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
1570
|
-
var CANVAS_CONTEXTUAL_EDITING_PARAM = "$contextualEditing";
|
|
1571
|
-
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1572
|
-
var PLACEHOLDER_ID = "placeholder";
|
|
1573
|
-
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
1574
1673
|
function isRootEntryReference(root) {
|
|
1575
1674
|
return root.type === "root" && isEntryData(root.node);
|
|
1576
1675
|
}
|
|
@@ -1590,9 +1689,9 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1590
1689
|
let bufferStartIndex = 0;
|
|
1591
1690
|
let bufferEndIndex = 0;
|
|
1592
1691
|
let tokenCount = 0;
|
|
1593
|
-
const handleToken = (token, type) => {
|
|
1692
|
+
const handleToken = (token, type, offset) => {
|
|
1594
1693
|
tokenCount++;
|
|
1595
|
-
return onToken == null ? void 0 : onToken(token, type);
|
|
1694
|
+
return onToken == null ? void 0 : onToken(token, type, offset);
|
|
1596
1695
|
};
|
|
1597
1696
|
let state = "text";
|
|
1598
1697
|
for (let index = 0; index < serialized.length; index++) {
|
|
@@ -1603,7 +1702,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1603
1702
|
if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
|
|
1604
1703
|
if (serialized[index - 1] === escapeCharacter) {
|
|
1605
1704
|
bufferEndIndex -= escapeCharacter.length;
|
|
1606
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
1705
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
1607
1706
|
return tokenCount;
|
|
1608
1707
|
}
|
|
1609
1708
|
bufferStartIndex = index;
|
|
@@ -1612,12 +1711,12 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1612
1711
|
}
|
|
1613
1712
|
if (state === "variable") {
|
|
1614
1713
|
const textStart = bufferStartIndex - variablePrefix.length;
|
|
1615
|
-
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
|
|
1714
|
+
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text", textStart) === false) {
|
|
1616
1715
|
return tokenCount;
|
|
1617
1716
|
}
|
|
1618
1717
|
bufferStartIndex = bufferEndIndex;
|
|
1619
1718
|
} else if (bufferEndIndex > bufferStartIndex) {
|
|
1620
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
1719
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
1621
1720
|
return tokenCount;
|
|
1622
1721
|
}
|
|
1623
1722
|
bufferStartIndex = bufferEndIndex;
|
|
@@ -1635,7 +1734,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1635
1734
|
state = "text";
|
|
1636
1735
|
if (bufferEndIndex > bufferStartIndex) {
|
|
1637
1736
|
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
|
1638
|
-
if (handleToken(unescapedVariableName, "variable") === false) {
|
|
1737
|
+
if (handleToken(unescapedVariableName, "variable", bufferStartIndex) === false) {
|
|
1639
1738
|
return tokenCount;
|
|
1640
1739
|
}
|
|
1641
1740
|
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
|
@@ -1649,7 +1748,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1649
1748
|
bufferStartIndex -= variablePrefix.length;
|
|
1650
1749
|
}
|
|
1651
1750
|
if (bufferStartIndex < serialized.length) {
|
|
1652
|
-
handleToken(serialized.substring(bufferStartIndex), state);
|
|
1751
|
+
handleToken(serialized.substring(bufferStartIndex), state, bufferStartIndex);
|
|
1653
1752
|
}
|
|
1654
1753
|
return tokenCount;
|
|
1655
1754
|
}
|
|
@@ -2012,6 +2111,48 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
|
|
|
2012
2111
|
_baseUrl = /* @__PURE__ */ new WeakMap();
|
|
2013
2112
|
__privateAdd3(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
|
|
2014
2113
|
var _url22;
|
|
2114
|
+
var _NotificationsClient = class _NotificationsClient2 extends ApiClient {
|
|
2115
|
+
constructor(options) {
|
|
2116
|
+
super(options);
|
|
2117
|
+
}
|
|
2118
|
+
/**
|
|
2119
|
+
* Lists notifications for the current user.
|
|
2120
|
+
*
|
|
2121
|
+
* @deprecated This API is experimental and may change without notice.
|
|
2122
|
+
*/
|
|
2123
|
+
async list(options) {
|
|
2124
|
+
const fetchUri = this.createUrl(__privateGet3(_NotificationsClient2, _url22), options);
|
|
2125
|
+
return await this.apiClient(fetchUri);
|
|
2126
|
+
}
|
|
2127
|
+
/**
|
|
2128
|
+
* Creates a notification for one or more recipients.
|
|
2129
|
+
*
|
|
2130
|
+
* @deprecated This API is experimental and may change without notice.
|
|
2131
|
+
*/
|
|
2132
|
+
async create(body) {
|
|
2133
|
+
const fetchUri = this.createUrl(__privateGet3(_NotificationsClient2, _url22));
|
|
2134
|
+
return await this.apiClient(fetchUri, {
|
|
2135
|
+
method: "POST",
|
|
2136
|
+
body: JSON.stringify(body)
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
/**
|
|
2140
|
+
* Updates the read state of the current user's notifications.
|
|
2141
|
+
*
|
|
2142
|
+
* @deprecated This API is experimental and may change without notice.
|
|
2143
|
+
*/
|
|
2144
|
+
async setReadState(body) {
|
|
2145
|
+
const fetchUri = this.createUrl(__privateGet3(_NotificationsClient2, _url22));
|
|
2146
|
+
await this.apiClient(fetchUri, {
|
|
2147
|
+
method: "PATCH",
|
|
2148
|
+
body: JSON.stringify(body),
|
|
2149
|
+
expectNoContent: true
|
|
2150
|
+
});
|
|
2151
|
+
}
|
|
2152
|
+
};
|
|
2153
|
+
_url22 = /* @__PURE__ */ new WeakMap();
|
|
2154
|
+
__privateAdd3(_NotificationsClient, _url22, "/api/v1/notifications");
|
|
2155
|
+
var _url32;
|
|
2015
2156
|
var _projectsUrl;
|
|
2016
2157
|
var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
2017
2158
|
constructor(options) {
|
|
@@ -2019,7 +2160,7 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
2019
2160
|
}
|
|
2020
2161
|
/** Fetches single Project */
|
|
2021
2162
|
async get(options) {
|
|
2022
|
-
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2,
|
|
2163
|
+
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url32), { ...options });
|
|
2023
2164
|
return await this.apiClient(fetchUri);
|
|
2024
2165
|
}
|
|
2025
2166
|
/**
|
|
@@ -2027,31 +2168,43 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
2027
2168
|
* When teamId is provided, returns a single team with its projects.
|
|
2028
2169
|
* When omitted, returns all accessible teams and their projects.
|
|
2029
2170
|
*/
|
|
2030
|
-
async
|
|
2171
|
+
async list(options) {
|
|
2031
2172
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
|
|
2032
2173
|
return await this.apiClient(fetchUri);
|
|
2033
2174
|
}
|
|
2175
|
+
/** @deprecated Use {@link list} instead. */
|
|
2176
|
+
async getProjects(options) {
|
|
2177
|
+
return this.list(options);
|
|
2178
|
+
}
|
|
2034
2179
|
/** Updates or creates (based on id) a Project */
|
|
2035
|
-
async
|
|
2036
|
-
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2,
|
|
2180
|
+
async save(body) {
|
|
2181
|
+
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url32));
|
|
2037
2182
|
return await this.apiClient(fetchUri, {
|
|
2038
2183
|
method: "PUT",
|
|
2039
2184
|
body: JSON.stringify({ ...body })
|
|
2040
2185
|
});
|
|
2041
2186
|
}
|
|
2187
|
+
/** @deprecated Use {@link save} instead. */
|
|
2188
|
+
async upsert(body) {
|
|
2189
|
+
return this.save(body);
|
|
2190
|
+
}
|
|
2042
2191
|
/** Deletes a Project */
|
|
2043
|
-
async
|
|
2044
|
-
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2,
|
|
2192
|
+
async remove(body) {
|
|
2193
|
+
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url32));
|
|
2045
2194
|
await this.apiClient(fetchUri, {
|
|
2046
2195
|
method: "DELETE",
|
|
2047
2196
|
body: JSON.stringify({ ...body }),
|
|
2048
2197
|
expectNoContent: true
|
|
2049
2198
|
});
|
|
2050
2199
|
}
|
|
2200
|
+
/** @deprecated Use {@link remove} instead. */
|
|
2201
|
+
async delete(body) {
|
|
2202
|
+
return this.remove(body);
|
|
2203
|
+
}
|
|
2051
2204
|
};
|
|
2052
|
-
|
|
2205
|
+
_url32 = /* @__PURE__ */ new WeakMap();
|
|
2053
2206
|
_projectsUrl = /* @__PURE__ */ new WeakMap();
|
|
2054
|
-
__privateAdd3(_ProjectClient,
|
|
2207
|
+
__privateAdd3(_ProjectClient, _url32, "/api/v1/project");
|
|
2055
2208
|
__privateAdd3(_ProjectClient, _projectsUrl, "/api/v1/projects");
|
|
2056
2209
|
var ROUTE_URL = "/api/v1/route";
|
|
2057
2210
|
var RouteClient = class extends ApiClient {
|
|
@@ -2063,8 +2216,14 @@ var RouteClient = class extends ApiClient {
|
|
|
2063
2216
|
super(options);
|
|
2064
2217
|
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
|
|
2065
2218
|
}
|
|
2066
|
-
/**
|
|
2067
|
-
|
|
2219
|
+
/**
|
|
2220
|
+
* Resolves a route to a composition, redirect, or not-found result.
|
|
2221
|
+
*
|
|
2222
|
+
* An optional `select` projection applies to the resolved composition when
|
|
2223
|
+
* the route matches one; redirect / notFound responses pass through
|
|
2224
|
+
* untouched.
|
|
2225
|
+
*/
|
|
2226
|
+
async get(options) {
|
|
2068
2227
|
const { projectId } = this.options;
|
|
2069
2228
|
const { select, ...rest } = options != null ? options : {};
|
|
2070
2229
|
const rewrittenSelect = projectionToQuery(select);
|
|
@@ -2074,6 +2233,10 @@ var RouteClient = class extends ApiClient {
|
|
|
2074
2233
|
this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
|
|
2075
2234
|
);
|
|
2076
2235
|
}
|
|
2236
|
+
/** @deprecated use {@link RouteClient.get} instead (renamed). */
|
|
2237
|
+
async getRoute(options) {
|
|
2238
|
+
return this.get(options);
|
|
2239
|
+
}
|
|
2077
2240
|
};
|
|
2078
2241
|
var getDataSourceVariantFromRouteGetParams = (params, defaultPreviewState) => {
|
|
2079
2242
|
var _a, _b;
|
|
@@ -2380,9 +2543,9 @@ function createLimitPolicy2({
|
|
|
2380
2543
|
}
|
|
2381
2544
|
|
|
2382
2545
|
// src/clients/canvas.ts
|
|
2383
|
-
var
|
|
2546
|
+
var buildCanvasClientOptions = (options) => {
|
|
2384
2547
|
const cache2 = resolveCanvasCache(options);
|
|
2385
|
-
return
|
|
2548
|
+
return {
|
|
2386
2549
|
projectId: env.getProjectId(),
|
|
2387
2550
|
apiHost: env.getApiHost(),
|
|
2388
2551
|
apiKey: env.getApiKey(),
|
|
@@ -2430,7 +2593,13 @@ var getCanvasClient = (options) => {
|
|
|
2430
2593
|
}
|
|
2431
2594
|
});
|
|
2432
2595
|
}
|
|
2433
|
-
}
|
|
2596
|
+
};
|
|
2597
|
+
};
|
|
2598
|
+
var getCanvasClient = (options) => {
|
|
2599
|
+
return new CanvasClient(buildCanvasClientOptions(options));
|
|
2600
|
+
};
|
|
2601
|
+
var getCompositionDeliveryClient = (options) => {
|
|
2602
|
+
return new CompositionDeliveryClient(buildCanvasClientOptions(options));
|
|
2434
2603
|
};
|
|
2435
2604
|
|
|
2436
2605
|
// src/clients/manifest.ts
|
|
@@ -2729,6 +2898,35 @@ var _Route = class _Route2 {
|
|
|
2729
2898
|
}
|
|
2730
2899
|
return segment.slice(_Route2.dynamicSegmentPrefix.length);
|
|
2731
2900
|
}
|
|
2901
|
+
/**
|
|
2902
|
+
* Splits a path into the path portion and an optional `#fragment`
|
|
2903
|
+
* (everything after the first `#`).
|
|
2904
|
+
*
|
|
2905
|
+
* Variable expressions (`${...}`) may legitimately contain `#` characters
|
|
2906
|
+
* (e.g. JSON-pointer tokens like `${#jptr:/foo/_slug}`), so the fragment
|
|
2907
|
+
* delimiter is the first `#` that falls outside of a variable expression.
|
|
2908
|
+
*/
|
|
2909
|
+
static splitFragment(path) {
|
|
2910
|
+
let fragmentIndex = -1;
|
|
2911
|
+
parseVariableExpression(path, (token, type, offset) => {
|
|
2912
|
+
if (type === "variable") {
|
|
2913
|
+
return;
|
|
2914
|
+
}
|
|
2915
|
+
const hashOffset = token.indexOf("#");
|
|
2916
|
+
if (hashOffset === -1) {
|
|
2917
|
+
return;
|
|
2918
|
+
}
|
|
2919
|
+
fragmentIndex = offset + hashOffset;
|
|
2920
|
+
return false;
|
|
2921
|
+
});
|
|
2922
|
+
if (fragmentIndex === -1) {
|
|
2923
|
+
return { path, fragment: void 0 };
|
|
2924
|
+
}
|
|
2925
|
+
return {
|
|
2926
|
+
path: path.slice(0, fragmentIndex),
|
|
2927
|
+
fragment: path.slice(fragmentIndex + 1)
|
|
2928
|
+
};
|
|
2929
|
+
}
|
|
2732
2930
|
};
|
|
2733
2931
|
_routeInfo = /* @__PURE__ */ new WeakMap();
|
|
2734
2932
|
_Route_static = /* @__PURE__ */ new WeakSet();
|
|
@@ -3435,14 +3633,14 @@ var import_react7 = __toESM(require("react"));
|
|
|
3435
3633
|
var import_next_app_router_shared5 = require("@uniformdev/next-app-router-shared");
|
|
3436
3634
|
var resolvePlaygroundRoute = async ({ code }) => {
|
|
3437
3635
|
const pageState = (0, import_next_app_router_shared5.deserializeEvaluationResult)({ input: code });
|
|
3438
|
-
const canvasClient =
|
|
3636
|
+
const canvasClient = getCompositionDeliveryClient({
|
|
3439
3637
|
cache: {
|
|
3440
3638
|
type: "no-cache"
|
|
3441
3639
|
}
|
|
3442
3640
|
});
|
|
3443
3641
|
let composition = void 0;
|
|
3444
3642
|
try {
|
|
3445
|
-
composition = await canvasClient.
|
|
3643
|
+
composition = await canvasClient.get({
|
|
3446
3644
|
compositionId: pageState.routePath,
|
|
3447
3645
|
state: pageState.compositionState,
|
|
3448
3646
|
withComponentIDs: true
|
|
@@ -3588,7 +3786,7 @@ var createUniformPlaygroundStaticParams = async (options) => {
|
|
|
3588
3786
|
const routeClient = getRouteClient({
|
|
3589
3787
|
state
|
|
3590
3788
|
});
|
|
3591
|
-
route = await routeClient.
|
|
3789
|
+
route = await routeClient.get({
|
|
3592
3790
|
path: firstPath,
|
|
3593
3791
|
withComponentIDs: true,
|
|
3594
3792
|
state: CANVAS_DRAFT_STATE
|
|
@@ -3641,7 +3839,7 @@ async function processRoutePath({
|
|
|
3641
3839
|
});
|
|
3642
3840
|
const rewrittenPath = await (rewrite == null ? void 0 : rewrite({ path }));
|
|
3643
3841
|
const resolvedPath = (_a = rewrittenPath == null ? void 0 : rewrittenPath.path) != null ? _a : path;
|
|
3644
|
-
const route = await routeClient.
|
|
3842
|
+
const route = await routeClient.get({
|
|
3645
3843
|
path: resolvedPath,
|
|
3646
3844
|
withComponentIDs: true,
|
|
3647
3845
|
state: CANVAS_PUBLISHED_STATE
|
|
@@ -3894,14 +4092,14 @@ var DefaultDataClient = class {
|
|
|
3894
4092
|
if (oldCachedRoute) {
|
|
3895
4093
|
(0, import_functions.waitUntil)(
|
|
3896
4094
|
(async () => {
|
|
3897
|
-
const result2 = await routeClient.
|
|
4095
|
+
const result2 = await routeClient.get(route);
|
|
3898
4096
|
await cacheNewRoute(result2);
|
|
3899
4097
|
})()
|
|
3900
4098
|
);
|
|
3901
4099
|
return oldCachedRoute;
|
|
3902
4100
|
}
|
|
3903
4101
|
}
|
|
3904
|
-
const result = await routeClient.
|
|
4102
|
+
const result = await routeClient.get(route);
|
|
3905
4103
|
(0, import_functions.waitUntil)(
|
|
3906
4104
|
(async () => {
|
|
3907
4105
|
await Promise.all([
|
|
@@ -4171,6 +4369,7 @@ var createCompositionCache = () => {
|
|
|
4171
4369
|
expireMiddlewareCacheTag,
|
|
4172
4370
|
findRouteMatch,
|
|
4173
4371
|
getCanvasClient,
|
|
4372
|
+
getCompositionDeliveryClient,
|
|
4174
4373
|
getManifest,
|
|
4175
4374
|
getManifestClient,
|
|
4176
4375
|
getProjectMapClient,
|