@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.esm.js
CHANGED
|
@@ -1198,6 +1198,16 @@ function createLimitPolicy({
|
|
|
1198
1198
|
return currentFunc();
|
|
1199
1199
|
};
|
|
1200
1200
|
}
|
|
1201
|
+
var ContentClientBase = class extends ApiClient {
|
|
1202
|
+
constructor(options, defaultBypassCache) {
|
|
1203
|
+
var _a, _b;
|
|
1204
|
+
super({
|
|
1205
|
+
...options,
|
|
1206
|
+
limitPolicy: (_a = options.limitPolicy) != null ? _a : createLimitPolicy({}),
|
|
1207
|
+
bypassCache: (_b = options.bypassCache) != null ? _b : defaultBypassCache
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
};
|
|
1201
1211
|
var SELECT_QUERY_PREFIX = "select.";
|
|
1202
1212
|
function appendCsv(out, key, values) {
|
|
1203
1213
|
if (values === void 0) {
|
|
@@ -1242,7 +1252,105 @@ function projectionToQuery(spec) {
|
|
|
1242
1252
|
}
|
|
1243
1253
|
return out;
|
|
1244
1254
|
}
|
|
1245
|
-
var
|
|
1255
|
+
var CANVAS_PERSONALIZE_TYPE = "$personalization";
|
|
1256
|
+
var CANVAS_TEST_TYPE = "$test";
|
|
1257
|
+
var CANVAS_BLOCK_PARAM_TYPE = "$block";
|
|
1258
|
+
var CANVAS_PERSONALIZE_SLOT = "pz";
|
|
1259
|
+
var CANVAS_TEST_SLOT = "test";
|
|
1260
|
+
var CANVAS_DRAFT_STATE = 0;
|
|
1261
|
+
var CANVAS_PUBLISHED_STATE = 64;
|
|
1262
|
+
var CANVAS_EDITOR_STATE = 63;
|
|
1263
|
+
var CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
|
|
1264
|
+
var CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
|
|
1265
|
+
var CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
|
|
1266
|
+
var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
|
|
1267
|
+
var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
|
|
1268
|
+
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
1269
|
+
var CANVAS_CONTEXTUAL_EDITING_PARAM = "$contextualEditing";
|
|
1270
|
+
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1271
|
+
var PLACEHOLDER_ID = "placeholder";
|
|
1272
|
+
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
1273
|
+
function resolveCompositionSelector(args) {
|
|
1274
|
+
if ("compositionId" in args) {
|
|
1275
|
+
const { compositionId, editionId, versionId, ...readOptions } = args;
|
|
1276
|
+
return {
|
|
1277
|
+
readOptions,
|
|
1278
|
+
// raw mode matches on composition OR edition id via the compositionId param
|
|
1279
|
+
compositionId: editionId != null ? editionId : compositionId,
|
|
1280
|
+
versionId,
|
|
1281
|
+
hasCompositionId: true,
|
|
1282
|
+
pinnedEdition: editionId !== void 0
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
return { readOptions: args, hasCompositionId: false, pinnedEdition: false };
|
|
1286
|
+
}
|
|
1287
|
+
var DEFAULT_EDGE_API_HOST = "https://uniform.global";
|
|
1288
|
+
var DeliveryClientBase = class extends ContentClientBase {
|
|
1289
|
+
constructor(options) {
|
|
1290
|
+
var _a;
|
|
1291
|
+
super(
|
|
1292
|
+
options,
|
|
1293
|
+
/* defaultBypassCache */
|
|
1294
|
+
false
|
|
1295
|
+
);
|
|
1296
|
+
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : DEFAULT_EDGE_API_HOST;
|
|
1297
|
+
this.edgeRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
|
|
1298
|
+
}
|
|
1299
|
+
/** Coerces the `diagnostics` option into the shape the edge endpoints accept. */
|
|
1300
|
+
coerceDiagnostics(diagnostics) {
|
|
1301
|
+
return typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0;
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
var EDGE_SINGLE_URL = "/api/v1/composition";
|
|
1305
|
+
var EDGE_LIST_URL = "/api/v1/compositions";
|
|
1306
|
+
var CompositionDeliveryClient = class extends DeliveryClientBase {
|
|
1307
|
+
constructor(options) {
|
|
1308
|
+
super(options);
|
|
1309
|
+
}
|
|
1310
|
+
/** Fetches exactly one composition (throws `ApiClientError(404)` if absent). */
|
|
1311
|
+
get(args) {
|
|
1312
|
+
var _a;
|
|
1313
|
+
const { diagnostics, select, ...rest } = args;
|
|
1314
|
+
const { readOptions, compositionId, versionId, pinnedEdition } = resolveCompositionSelector(rest);
|
|
1315
|
+
const url = this.createUrl(
|
|
1316
|
+
EDGE_SINGLE_URL,
|
|
1317
|
+
{
|
|
1318
|
+
...readOptions,
|
|
1319
|
+
...projectionToQuery(select),
|
|
1320
|
+
// A pinned edition is folded into compositionId (raw matches edition or
|
|
1321
|
+
// composition id); there is no editionId query param on this endpoint.
|
|
1322
|
+
compositionId,
|
|
1323
|
+
versionId,
|
|
1324
|
+
projectId: this.options.projectId,
|
|
1325
|
+
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
1326
|
+
// editionId pins a specific edition for preview; otherwise locale-best.
|
|
1327
|
+
editions: pinnedEdition ? "raw" : "auto",
|
|
1328
|
+
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
1329
|
+
},
|
|
1330
|
+
this.edgeApiHost
|
|
1331
|
+
);
|
|
1332
|
+
return this.apiClient(url, this.edgeRequestInit);
|
|
1333
|
+
}
|
|
1334
|
+
/** Fetches a list of compositions, optionally filtered. */
|
|
1335
|
+
list(args = {}) {
|
|
1336
|
+
var _a;
|
|
1337
|
+
const { diagnostics, filters, select, ...rest } = args;
|
|
1338
|
+
const url = this.createUrl(
|
|
1339
|
+
EDGE_LIST_URL,
|
|
1340
|
+
{
|
|
1341
|
+
...rest,
|
|
1342
|
+
...rewriteFiltersForApi(filters),
|
|
1343
|
+
...projectionToQuery(select),
|
|
1344
|
+
projectId: this.options.projectId,
|
|
1345
|
+
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
1346
|
+
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
1347
|
+
},
|
|
1348
|
+
this.edgeApiHost
|
|
1349
|
+
);
|
|
1350
|
+
return this.apiClient(url, this.edgeRequestInit);
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
var CANVAS_URL2 = "/api/v1/canvas";
|
|
1246
1354
|
var CanvasClient = class extends ApiClient {
|
|
1247
1355
|
constructor(options) {
|
|
1248
1356
|
var _a;
|
|
@@ -1260,7 +1368,7 @@ var CanvasClient = class extends ApiClient {
|
|
|
1260
1368
|
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
1261
1369
|
const rewrittenSelect = projectionToQuery(select);
|
|
1262
1370
|
if (!resolveData) {
|
|
1263
|
-
const fetchUri = this.createUrl(
|
|
1371
|
+
const fetchUri = this.createUrl(CANVAS_URL2, {
|
|
1264
1372
|
...originParams,
|
|
1265
1373
|
projectId,
|
|
1266
1374
|
...rewrittenFilters,
|
|
@@ -1308,7 +1416,7 @@ var CanvasClient = class extends ApiClient {
|
|
|
1308
1416
|
}) {
|
|
1309
1417
|
const { projectId } = this.options;
|
|
1310
1418
|
if (skipDataResolution) {
|
|
1311
|
-
return this.apiClient(this.createUrl(
|
|
1419
|
+
return this.apiClient(this.createUrl(CANVAS_URL2, { ...params, projectId }));
|
|
1312
1420
|
}
|
|
1313
1421
|
const edgeParams = {
|
|
1314
1422
|
...params,
|
|
@@ -1320,7 +1428,7 @@ var CanvasClient = class extends ApiClient {
|
|
|
1320
1428
|
}
|
|
1321
1429
|
/** Updates or creates a Canvas component definition */
|
|
1322
1430
|
async updateComposition(body, options) {
|
|
1323
|
-
const fetchUri = this.createUrl(
|
|
1431
|
+
const fetchUri = this.createUrl(CANVAS_URL2);
|
|
1324
1432
|
const headers = {};
|
|
1325
1433
|
if (options == null ? void 0 : options.ifUnmodifiedSince) {
|
|
1326
1434
|
headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
|
|
@@ -1335,7 +1443,7 @@ var CanvasClient = class extends ApiClient {
|
|
|
1335
1443
|
}
|
|
1336
1444
|
/** Deletes a Canvas component definition */
|
|
1337
1445
|
async removeComposition(body) {
|
|
1338
|
-
const fetchUri = this.createUrl(
|
|
1446
|
+
const fetchUri = this.createUrl(CANVAS_URL2);
|
|
1339
1447
|
const { projectId } = this.options;
|
|
1340
1448
|
await this.apiClient(fetchUri, {
|
|
1341
1449
|
method: "DELETE",
|
|
@@ -1474,14 +1582,18 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1474
1582
|
constructor(options) {
|
|
1475
1583
|
super(options);
|
|
1476
1584
|
}
|
|
1477
|
-
/** Fetches
|
|
1478
|
-
async
|
|
1585
|
+
/** Fetches a list of DataTypes for a project */
|
|
1586
|
+
async list(options) {
|
|
1479
1587
|
const { projectId } = this.options;
|
|
1480
1588
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8), { ...options, projectId });
|
|
1481
1589
|
return await this.apiClient(fetchUri);
|
|
1482
1590
|
}
|
|
1591
|
+
/** @deprecated Use {@link list} instead. */
|
|
1592
|
+
async get(options) {
|
|
1593
|
+
return this.list(options);
|
|
1594
|
+
}
|
|
1483
1595
|
/** Updates or creates (based on id) a DataType */
|
|
1484
|
-
async
|
|
1596
|
+
async save(body) {
|
|
1485
1597
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
|
|
1486
1598
|
await this.apiClient(fetchUri, {
|
|
1487
1599
|
method: "PUT",
|
|
@@ -1489,6 +1601,10 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1489
1601
|
expectNoContent: true
|
|
1490
1602
|
});
|
|
1491
1603
|
}
|
|
1604
|
+
/** @deprecated Use {@link save} instead. */
|
|
1605
|
+
async upsert(body) {
|
|
1606
|
+
return this.save(body);
|
|
1607
|
+
}
|
|
1492
1608
|
/** Deletes a DataType */
|
|
1493
1609
|
async remove(body) {
|
|
1494
1610
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
|
|
@@ -1526,24 +1642,6 @@ function getComponentPath(ancestorsAndSelf) {
|
|
|
1526
1642
|
}
|
|
1527
1643
|
return `.${path.join(".")}`;
|
|
1528
1644
|
}
|
|
1529
|
-
var CANVAS_PERSONALIZE_TYPE = "$personalization";
|
|
1530
|
-
var CANVAS_TEST_TYPE = "$test";
|
|
1531
|
-
var CANVAS_BLOCK_PARAM_TYPE = "$block";
|
|
1532
|
-
var CANVAS_PERSONALIZE_SLOT = "pz";
|
|
1533
|
-
var CANVAS_TEST_SLOT = "test";
|
|
1534
|
-
var CANVAS_DRAFT_STATE = 0;
|
|
1535
|
-
var CANVAS_PUBLISHED_STATE = 64;
|
|
1536
|
-
var CANVAS_EDITOR_STATE = 63;
|
|
1537
|
-
var CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
|
|
1538
|
-
var CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
|
|
1539
|
-
var CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
|
|
1540
|
-
var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
|
|
1541
|
-
var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
|
|
1542
|
-
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
1543
|
-
var CANVAS_CONTEXTUAL_EDITING_PARAM = "$contextualEditing";
|
|
1544
|
-
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1545
|
-
var PLACEHOLDER_ID = "placeholder";
|
|
1546
|
-
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
1547
1645
|
function isRootEntryReference(root) {
|
|
1548
1646
|
return root.type === "root" && isEntryData(root.node);
|
|
1549
1647
|
}
|
|
@@ -1563,9 +1661,9 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1563
1661
|
let bufferStartIndex = 0;
|
|
1564
1662
|
let bufferEndIndex = 0;
|
|
1565
1663
|
let tokenCount = 0;
|
|
1566
|
-
const handleToken = (token, type) => {
|
|
1664
|
+
const handleToken = (token, type, offset) => {
|
|
1567
1665
|
tokenCount++;
|
|
1568
|
-
return onToken == null ? void 0 : onToken(token, type);
|
|
1666
|
+
return onToken == null ? void 0 : onToken(token, type, offset);
|
|
1569
1667
|
};
|
|
1570
1668
|
let state = "text";
|
|
1571
1669
|
for (let index = 0; index < serialized.length; index++) {
|
|
@@ -1576,7 +1674,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1576
1674
|
if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
|
|
1577
1675
|
if (serialized[index - 1] === escapeCharacter) {
|
|
1578
1676
|
bufferEndIndex -= escapeCharacter.length;
|
|
1579
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
1677
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
1580
1678
|
return tokenCount;
|
|
1581
1679
|
}
|
|
1582
1680
|
bufferStartIndex = index;
|
|
@@ -1585,12 +1683,12 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1585
1683
|
}
|
|
1586
1684
|
if (state === "variable") {
|
|
1587
1685
|
const textStart = bufferStartIndex - variablePrefix.length;
|
|
1588
|
-
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
|
|
1686
|
+
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text", textStart) === false) {
|
|
1589
1687
|
return tokenCount;
|
|
1590
1688
|
}
|
|
1591
1689
|
bufferStartIndex = bufferEndIndex;
|
|
1592
1690
|
} else if (bufferEndIndex > bufferStartIndex) {
|
|
1593
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
1691
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
1594
1692
|
return tokenCount;
|
|
1595
1693
|
}
|
|
1596
1694
|
bufferStartIndex = bufferEndIndex;
|
|
@@ -1608,7 +1706,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1608
1706
|
state = "text";
|
|
1609
1707
|
if (bufferEndIndex > bufferStartIndex) {
|
|
1610
1708
|
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
|
1611
|
-
if (handleToken(unescapedVariableName, "variable") === false) {
|
|
1709
|
+
if (handleToken(unescapedVariableName, "variable", bufferStartIndex) === false) {
|
|
1612
1710
|
return tokenCount;
|
|
1613
1711
|
}
|
|
1614
1712
|
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
|
@@ -1622,7 +1720,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1622
1720
|
bufferStartIndex -= variablePrefix.length;
|
|
1623
1721
|
}
|
|
1624
1722
|
if (bufferStartIndex < serialized.length) {
|
|
1625
|
-
handleToken(serialized.substring(bufferStartIndex), state);
|
|
1723
|
+
handleToken(serialized.substring(bufferStartIndex), state, bufferStartIndex);
|
|
1626
1724
|
}
|
|
1627
1725
|
return tokenCount;
|
|
1628
1726
|
}
|
|
@@ -1985,6 +2083,48 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
|
|
|
1985
2083
|
_baseUrl = /* @__PURE__ */ new WeakMap();
|
|
1986
2084
|
__privateAdd3(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
|
|
1987
2085
|
var _url22;
|
|
2086
|
+
var _NotificationsClient = class _NotificationsClient2 extends ApiClient {
|
|
2087
|
+
constructor(options) {
|
|
2088
|
+
super(options);
|
|
2089
|
+
}
|
|
2090
|
+
/**
|
|
2091
|
+
* Lists notifications for the current user.
|
|
2092
|
+
*
|
|
2093
|
+
* @deprecated This API is experimental and may change without notice.
|
|
2094
|
+
*/
|
|
2095
|
+
async list(options) {
|
|
2096
|
+
const fetchUri = this.createUrl(__privateGet3(_NotificationsClient2, _url22), options);
|
|
2097
|
+
return await this.apiClient(fetchUri);
|
|
2098
|
+
}
|
|
2099
|
+
/**
|
|
2100
|
+
* Creates a notification for one or more recipients.
|
|
2101
|
+
*
|
|
2102
|
+
* @deprecated This API is experimental and may change without notice.
|
|
2103
|
+
*/
|
|
2104
|
+
async create(body) {
|
|
2105
|
+
const fetchUri = this.createUrl(__privateGet3(_NotificationsClient2, _url22));
|
|
2106
|
+
return await this.apiClient(fetchUri, {
|
|
2107
|
+
method: "POST",
|
|
2108
|
+
body: JSON.stringify(body)
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
2111
|
+
/**
|
|
2112
|
+
* Updates the read state of the current user's notifications.
|
|
2113
|
+
*
|
|
2114
|
+
* @deprecated This API is experimental and may change without notice.
|
|
2115
|
+
*/
|
|
2116
|
+
async setReadState(body) {
|
|
2117
|
+
const fetchUri = this.createUrl(__privateGet3(_NotificationsClient2, _url22));
|
|
2118
|
+
await this.apiClient(fetchUri, {
|
|
2119
|
+
method: "PATCH",
|
|
2120
|
+
body: JSON.stringify(body),
|
|
2121
|
+
expectNoContent: true
|
|
2122
|
+
});
|
|
2123
|
+
}
|
|
2124
|
+
};
|
|
2125
|
+
_url22 = /* @__PURE__ */ new WeakMap();
|
|
2126
|
+
__privateAdd3(_NotificationsClient, _url22, "/api/v1/notifications");
|
|
2127
|
+
var _url32;
|
|
1988
2128
|
var _projectsUrl;
|
|
1989
2129
|
var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
1990
2130
|
constructor(options) {
|
|
@@ -1992,7 +2132,7 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1992
2132
|
}
|
|
1993
2133
|
/** Fetches single Project */
|
|
1994
2134
|
async get(options) {
|
|
1995
|
-
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2,
|
|
2135
|
+
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url32), { ...options });
|
|
1996
2136
|
return await this.apiClient(fetchUri);
|
|
1997
2137
|
}
|
|
1998
2138
|
/**
|
|
@@ -2000,31 +2140,43 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
2000
2140
|
* When teamId is provided, returns a single team with its projects.
|
|
2001
2141
|
* When omitted, returns all accessible teams and their projects.
|
|
2002
2142
|
*/
|
|
2003
|
-
async
|
|
2143
|
+
async list(options) {
|
|
2004
2144
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
|
|
2005
2145
|
return await this.apiClient(fetchUri);
|
|
2006
2146
|
}
|
|
2147
|
+
/** @deprecated Use {@link list} instead. */
|
|
2148
|
+
async getProjects(options) {
|
|
2149
|
+
return this.list(options);
|
|
2150
|
+
}
|
|
2007
2151
|
/** Updates or creates (based on id) a Project */
|
|
2008
|
-
async
|
|
2009
|
-
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2,
|
|
2152
|
+
async save(body) {
|
|
2153
|
+
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url32));
|
|
2010
2154
|
return await this.apiClient(fetchUri, {
|
|
2011
2155
|
method: "PUT",
|
|
2012
2156
|
body: JSON.stringify({ ...body })
|
|
2013
2157
|
});
|
|
2014
2158
|
}
|
|
2159
|
+
/** @deprecated Use {@link save} instead. */
|
|
2160
|
+
async upsert(body) {
|
|
2161
|
+
return this.save(body);
|
|
2162
|
+
}
|
|
2015
2163
|
/** Deletes a Project */
|
|
2016
|
-
async
|
|
2017
|
-
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2,
|
|
2164
|
+
async remove(body) {
|
|
2165
|
+
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url32));
|
|
2018
2166
|
await this.apiClient(fetchUri, {
|
|
2019
2167
|
method: "DELETE",
|
|
2020
2168
|
body: JSON.stringify({ ...body }),
|
|
2021
2169
|
expectNoContent: true
|
|
2022
2170
|
});
|
|
2023
2171
|
}
|
|
2172
|
+
/** @deprecated Use {@link remove} instead. */
|
|
2173
|
+
async delete(body) {
|
|
2174
|
+
return this.remove(body);
|
|
2175
|
+
}
|
|
2024
2176
|
};
|
|
2025
|
-
|
|
2177
|
+
_url32 = /* @__PURE__ */ new WeakMap();
|
|
2026
2178
|
_projectsUrl = /* @__PURE__ */ new WeakMap();
|
|
2027
|
-
__privateAdd3(_ProjectClient,
|
|
2179
|
+
__privateAdd3(_ProjectClient, _url32, "/api/v1/project");
|
|
2028
2180
|
__privateAdd3(_ProjectClient, _projectsUrl, "/api/v1/projects");
|
|
2029
2181
|
var ROUTE_URL = "/api/v1/route";
|
|
2030
2182
|
var RouteClient = class extends ApiClient {
|
|
@@ -2036,8 +2188,14 @@ var RouteClient = class extends ApiClient {
|
|
|
2036
2188
|
super(options);
|
|
2037
2189
|
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
|
|
2038
2190
|
}
|
|
2039
|
-
/**
|
|
2040
|
-
|
|
2191
|
+
/**
|
|
2192
|
+
* Resolves a route to a composition, redirect, or not-found result.
|
|
2193
|
+
*
|
|
2194
|
+
* An optional `select` projection applies to the resolved composition when
|
|
2195
|
+
* the route matches one; redirect / notFound responses pass through
|
|
2196
|
+
* untouched.
|
|
2197
|
+
*/
|
|
2198
|
+
async get(options) {
|
|
2041
2199
|
const { projectId } = this.options;
|
|
2042
2200
|
const { select, ...rest } = options != null ? options : {};
|
|
2043
2201
|
const rewrittenSelect = projectionToQuery(select);
|
|
@@ -2047,6 +2205,10 @@ var RouteClient = class extends ApiClient {
|
|
|
2047
2205
|
this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
|
|
2048
2206
|
);
|
|
2049
2207
|
}
|
|
2208
|
+
/** @deprecated use {@link RouteClient.get} instead (renamed). */
|
|
2209
|
+
async getRoute(options) {
|
|
2210
|
+
return this.get(options);
|
|
2211
|
+
}
|
|
2050
2212
|
};
|
|
2051
2213
|
var getDataSourceVariantFromRouteGetParams = (params, defaultPreviewState) => {
|
|
2052
2214
|
var _a, _b;
|
|
@@ -2353,9 +2515,9 @@ function createLimitPolicy2({
|
|
|
2353
2515
|
}
|
|
2354
2516
|
|
|
2355
2517
|
// src/clients/canvas.ts
|
|
2356
|
-
var
|
|
2518
|
+
var buildCanvasClientOptions = (options) => {
|
|
2357
2519
|
const cache2 = resolveCanvasCache(options);
|
|
2358
|
-
return
|
|
2520
|
+
return {
|
|
2359
2521
|
projectId: env.getProjectId(),
|
|
2360
2522
|
apiHost: env.getApiHost(),
|
|
2361
2523
|
apiKey: env.getApiKey(),
|
|
@@ -2403,7 +2565,13 @@ var getCanvasClient = (options) => {
|
|
|
2403
2565
|
}
|
|
2404
2566
|
});
|
|
2405
2567
|
}
|
|
2406
|
-
}
|
|
2568
|
+
};
|
|
2569
|
+
};
|
|
2570
|
+
var getCanvasClient = (options) => {
|
|
2571
|
+
return new CanvasClient(buildCanvasClientOptions(options));
|
|
2572
|
+
};
|
|
2573
|
+
var getCompositionDeliveryClient = (options) => {
|
|
2574
|
+
return new CompositionDeliveryClient(buildCanvasClientOptions(options));
|
|
2407
2575
|
};
|
|
2408
2576
|
|
|
2409
2577
|
// src/clients/manifest.ts
|
|
@@ -2702,6 +2870,35 @@ var _Route = class _Route2 {
|
|
|
2702
2870
|
}
|
|
2703
2871
|
return segment.slice(_Route2.dynamicSegmentPrefix.length);
|
|
2704
2872
|
}
|
|
2873
|
+
/**
|
|
2874
|
+
* Splits a path into the path portion and an optional `#fragment`
|
|
2875
|
+
* (everything after the first `#`).
|
|
2876
|
+
*
|
|
2877
|
+
* Variable expressions (`${...}`) may legitimately contain `#` characters
|
|
2878
|
+
* (e.g. JSON-pointer tokens like `${#jptr:/foo/_slug}`), so the fragment
|
|
2879
|
+
* delimiter is the first `#` that falls outside of a variable expression.
|
|
2880
|
+
*/
|
|
2881
|
+
static splitFragment(path) {
|
|
2882
|
+
let fragmentIndex = -1;
|
|
2883
|
+
parseVariableExpression(path, (token, type, offset) => {
|
|
2884
|
+
if (type === "variable") {
|
|
2885
|
+
return;
|
|
2886
|
+
}
|
|
2887
|
+
const hashOffset = token.indexOf("#");
|
|
2888
|
+
if (hashOffset === -1) {
|
|
2889
|
+
return;
|
|
2890
|
+
}
|
|
2891
|
+
fragmentIndex = offset + hashOffset;
|
|
2892
|
+
return false;
|
|
2893
|
+
});
|
|
2894
|
+
if (fragmentIndex === -1) {
|
|
2895
|
+
return { path, fragment: void 0 };
|
|
2896
|
+
}
|
|
2897
|
+
return {
|
|
2898
|
+
path: path.slice(0, fragmentIndex),
|
|
2899
|
+
fragment: path.slice(fragmentIndex + 1)
|
|
2900
|
+
};
|
|
2901
|
+
}
|
|
2705
2902
|
};
|
|
2706
2903
|
_routeInfo = /* @__PURE__ */ new WeakMap();
|
|
2707
2904
|
_Route_static = /* @__PURE__ */ new WeakSet();
|
|
@@ -3412,14 +3609,14 @@ import React6 from "react";
|
|
|
3412
3609
|
import { deserializeEvaluationResult as deserializeEvaluationResult2 } from "@uniformdev/next-app-router-shared";
|
|
3413
3610
|
var resolvePlaygroundRoute = async ({ code }) => {
|
|
3414
3611
|
const pageState = deserializeEvaluationResult2({ input: code });
|
|
3415
|
-
const canvasClient =
|
|
3612
|
+
const canvasClient = getCompositionDeliveryClient({
|
|
3416
3613
|
cache: {
|
|
3417
3614
|
type: "no-cache"
|
|
3418
3615
|
}
|
|
3419
3616
|
});
|
|
3420
3617
|
let composition = void 0;
|
|
3421
3618
|
try {
|
|
3422
|
-
composition = await canvasClient.
|
|
3619
|
+
composition = await canvasClient.get({
|
|
3423
3620
|
compositionId: pageState.routePath,
|
|
3424
3621
|
state: pageState.compositionState,
|
|
3425
3622
|
withComponentIDs: true
|
|
@@ -3567,7 +3764,7 @@ var createUniformPlaygroundStaticParams = async (options) => {
|
|
|
3567
3764
|
const routeClient = getRouteClient({
|
|
3568
3765
|
state
|
|
3569
3766
|
});
|
|
3570
|
-
route = await routeClient.
|
|
3767
|
+
route = await routeClient.get({
|
|
3571
3768
|
path: firstPath,
|
|
3572
3769
|
withComponentIDs: true,
|
|
3573
3770
|
state: CANVAS_DRAFT_STATE
|
|
@@ -3620,7 +3817,7 @@ async function processRoutePath({
|
|
|
3620
3817
|
});
|
|
3621
3818
|
const rewrittenPath = await (rewrite == null ? void 0 : rewrite({ path }));
|
|
3622
3819
|
const resolvedPath = (_a = rewrittenPath == null ? void 0 : rewrittenPath.path) != null ? _a : path;
|
|
3623
|
-
const route = await routeClient.
|
|
3820
|
+
const route = await routeClient.get({
|
|
3624
3821
|
path: resolvedPath,
|
|
3625
3822
|
withComponentIDs: true,
|
|
3626
3823
|
state: CANVAS_PUBLISHED_STATE
|
|
@@ -3873,14 +4070,14 @@ var DefaultDataClient = class {
|
|
|
3873
4070
|
if (oldCachedRoute) {
|
|
3874
4071
|
waitUntil(
|
|
3875
4072
|
(async () => {
|
|
3876
|
-
const result2 = await routeClient.
|
|
4073
|
+
const result2 = await routeClient.get(route);
|
|
3877
4074
|
await cacheNewRoute(result2);
|
|
3878
4075
|
})()
|
|
3879
4076
|
);
|
|
3880
4077
|
return oldCachedRoute;
|
|
3881
4078
|
}
|
|
3882
4079
|
}
|
|
3883
|
-
const result = await routeClient.
|
|
4080
|
+
const result = await routeClient.get(route);
|
|
3884
4081
|
waitUntil(
|
|
3885
4082
|
(async () => {
|
|
3886
4083
|
await Promise.all([
|
|
@@ -4153,6 +4350,7 @@ export {
|
|
|
4153
4350
|
expireMiddlewareCacheTag,
|
|
4154
4351
|
findRouteMatch,
|
|
4155
4352
|
getCanvasClient,
|
|
4353
|
+
getCompositionDeliveryClient,
|
|
4156
4354
|
getManifest,
|
|
4157
4355
|
getManifestClient,
|
|
4158
4356
|
getProjectMapClient,
|