@uniformdev/next-app-router 20.72.3-alpha.3 → 20.72.3-alpha.45
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 +67 -20
- package/dist/cache.mjs +67 -20
- 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 +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.esm.js +195 -54
- package/dist/index.js +196 -54
- package/dist/index.mjs +195 -54
- package/dist/middleware.js +172 -160
- package/dist/middleware.mjs +172 -160
- package/package.json +8 -8
package/dist/index.mjs
CHANGED
|
@@ -408,6 +408,7 @@ var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cann
|
|
|
408
408
|
var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
409
409
|
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);
|
|
410
410
|
var defaultLimitPolicy = (0, import_p_limit.default)(6);
|
|
411
|
+
var UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE = "Bearer token not valid or expired";
|
|
411
412
|
var ApiClientError = class _ApiClientError extends Error {
|
|
412
413
|
constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
|
|
413
414
|
super(
|
|
@@ -423,6 +424,12 @@ var ApiClientError = class _ApiClientError extends Error {
|
|
|
423
424
|
Object.setPrototypeOf(this, _ApiClientError.prototype);
|
|
424
425
|
}
|
|
425
426
|
};
|
|
427
|
+
var BearerTokenNotValidOrExpiredError = class _BearerTokenNotValidOrExpiredError extends ApiClientError {
|
|
428
|
+
constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
|
|
429
|
+
super(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId);
|
|
430
|
+
Object.setPrototypeOf(this, _BearerTokenNotValidOrExpiredError.prototype);
|
|
431
|
+
}
|
|
432
|
+
};
|
|
426
433
|
var ApiClient = class _ApiClient {
|
|
427
434
|
constructor(options) {
|
|
428
435
|
__publicField2(this, "options");
|
|
@@ -456,7 +463,7 @@ var ApiClient = class _ApiClient {
|
|
|
456
463
|
}
|
|
457
464
|
async apiClientWithResponse(fetchUri, options) {
|
|
458
465
|
return this.options.limitPolicy(async () => {
|
|
459
|
-
var _a;
|
|
466
|
+
var _a, _b;
|
|
460
467
|
const coreHeaders = this.options.apiKey ? {
|
|
461
468
|
"x-api-key": this.options.apiKey
|
|
462
469
|
} : {
|
|
@@ -492,9 +499,19 @@ var ApiClient = class _ApiClient {
|
|
|
492
499
|
} catch (e) {
|
|
493
500
|
message = `General error`;
|
|
494
501
|
}
|
|
502
|
+
if (apiResponse.status === 401 && message === UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE) {
|
|
503
|
+
throw new BearerTokenNotValidOrExpiredError(
|
|
504
|
+
message,
|
|
505
|
+
(_a = options == null ? void 0 : options.method) != null ? _a : "GET",
|
|
506
|
+
fetchUri.toString(),
|
|
507
|
+
apiResponse.status,
|
|
508
|
+
apiResponse.statusText,
|
|
509
|
+
_ApiClient.getRequestId(apiResponse)
|
|
510
|
+
);
|
|
511
|
+
}
|
|
495
512
|
throw new ApiClientError(
|
|
496
513
|
message,
|
|
497
|
-
(
|
|
514
|
+
(_b = options == null ? void 0 : options.method) != null ? _b : "GET",
|
|
498
515
|
fetchUri.toString(),
|
|
499
516
|
apiResponse.status,
|
|
500
517
|
apiResponse.statusText,
|
|
@@ -1198,6 +1215,16 @@ function createLimitPolicy({
|
|
|
1198
1215
|
return currentFunc();
|
|
1199
1216
|
};
|
|
1200
1217
|
}
|
|
1218
|
+
var ContentClientBase = class extends ApiClient {
|
|
1219
|
+
constructor(options, defaultBypassCache) {
|
|
1220
|
+
var _a, _b;
|
|
1221
|
+
super({
|
|
1222
|
+
...options,
|
|
1223
|
+
limitPolicy: (_a = options.limitPolicy) != null ? _a : createLimitPolicy({}),
|
|
1224
|
+
bypassCache: (_b = options.bypassCache) != null ? _b : defaultBypassCache
|
|
1225
|
+
});
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1201
1228
|
var SELECT_QUERY_PREFIX = "select.";
|
|
1202
1229
|
function appendCsv(out, key, values) {
|
|
1203
1230
|
if (values === void 0) {
|
|
@@ -1242,7 +1269,105 @@ function projectionToQuery(spec) {
|
|
|
1242
1269
|
}
|
|
1243
1270
|
return out;
|
|
1244
1271
|
}
|
|
1245
|
-
var
|
|
1272
|
+
var CANVAS_PERSONALIZE_TYPE = "$personalization";
|
|
1273
|
+
var CANVAS_TEST_TYPE = "$test";
|
|
1274
|
+
var CANVAS_BLOCK_PARAM_TYPE = "$block";
|
|
1275
|
+
var CANVAS_PERSONALIZE_SLOT = "pz";
|
|
1276
|
+
var CANVAS_TEST_SLOT = "test";
|
|
1277
|
+
var CANVAS_DRAFT_STATE = 0;
|
|
1278
|
+
var CANVAS_PUBLISHED_STATE = 64;
|
|
1279
|
+
var CANVAS_EDITOR_STATE = 63;
|
|
1280
|
+
var CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
|
|
1281
|
+
var CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
|
|
1282
|
+
var CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
|
|
1283
|
+
var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
|
|
1284
|
+
var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
|
|
1285
|
+
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
1286
|
+
var CANVAS_CONTEXTUAL_EDITING_PARAM = "$contextualEditing";
|
|
1287
|
+
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1288
|
+
var PLACEHOLDER_ID = "placeholder";
|
|
1289
|
+
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
1290
|
+
function resolveCompositionSelector(args) {
|
|
1291
|
+
if ("compositionId" in args) {
|
|
1292
|
+
const { compositionId, editionId, versionId, ...readOptions } = args;
|
|
1293
|
+
return {
|
|
1294
|
+
readOptions,
|
|
1295
|
+
// raw mode matches on composition OR edition id via the compositionId param
|
|
1296
|
+
compositionId: editionId != null ? editionId : compositionId,
|
|
1297
|
+
versionId,
|
|
1298
|
+
hasCompositionId: true,
|
|
1299
|
+
pinnedEdition: editionId !== void 0
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
return { readOptions: args, hasCompositionId: false, pinnedEdition: false };
|
|
1303
|
+
}
|
|
1304
|
+
var DEFAULT_EDGE_API_HOST = "https://uniform.global";
|
|
1305
|
+
var DeliveryClientBase = class extends ContentClientBase {
|
|
1306
|
+
constructor(options) {
|
|
1307
|
+
var _a;
|
|
1308
|
+
super(
|
|
1309
|
+
options,
|
|
1310
|
+
/* defaultBypassCache */
|
|
1311
|
+
false
|
|
1312
|
+
);
|
|
1313
|
+
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : DEFAULT_EDGE_API_HOST;
|
|
1314
|
+
this.edgeRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
|
|
1315
|
+
}
|
|
1316
|
+
/** Coerces the `diagnostics` option into the shape the edge endpoints accept. */
|
|
1317
|
+
coerceDiagnostics(diagnostics) {
|
|
1318
|
+
return typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0;
|
|
1319
|
+
}
|
|
1320
|
+
};
|
|
1321
|
+
var EDGE_SINGLE_URL = "/api/v1/composition";
|
|
1322
|
+
var EDGE_LIST_URL = "/api/v1/compositions";
|
|
1323
|
+
var CompositionDeliveryClient = class extends DeliveryClientBase {
|
|
1324
|
+
constructor(options) {
|
|
1325
|
+
super(options);
|
|
1326
|
+
}
|
|
1327
|
+
/** Fetches exactly one composition (throws `ApiClientError(404)` if absent). */
|
|
1328
|
+
get(args) {
|
|
1329
|
+
var _a;
|
|
1330
|
+
const { diagnostics, select, ...rest } = args;
|
|
1331
|
+
const { readOptions, compositionId, versionId, pinnedEdition } = resolveCompositionSelector(rest);
|
|
1332
|
+
const url = this.createUrl(
|
|
1333
|
+
EDGE_SINGLE_URL,
|
|
1334
|
+
{
|
|
1335
|
+
...readOptions,
|
|
1336
|
+
...projectionToQuery(select),
|
|
1337
|
+
// A pinned edition is folded into compositionId (raw matches edition or
|
|
1338
|
+
// composition id); there is no editionId query param on this endpoint.
|
|
1339
|
+
compositionId,
|
|
1340
|
+
versionId,
|
|
1341
|
+
projectId: this.options.projectId,
|
|
1342
|
+
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
1343
|
+
// editionId pins a specific edition for preview; otherwise locale-best.
|
|
1344
|
+
editions: pinnedEdition ? "raw" : "auto",
|
|
1345
|
+
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
1346
|
+
},
|
|
1347
|
+
this.edgeApiHost
|
|
1348
|
+
);
|
|
1349
|
+
return this.apiClient(url, this.edgeRequestInit);
|
|
1350
|
+
}
|
|
1351
|
+
/** Fetches a list of compositions, optionally filtered. */
|
|
1352
|
+
list(args = {}) {
|
|
1353
|
+
var _a;
|
|
1354
|
+
const { diagnostics, filters, select, ...rest } = args;
|
|
1355
|
+
const url = this.createUrl(
|
|
1356
|
+
EDGE_LIST_URL,
|
|
1357
|
+
{
|
|
1358
|
+
...rest,
|
|
1359
|
+
...rewriteFiltersForApi(filters),
|
|
1360
|
+
...projectionToQuery(select),
|
|
1361
|
+
projectId: this.options.projectId,
|
|
1362
|
+
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
1363
|
+
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
1364
|
+
},
|
|
1365
|
+
this.edgeApiHost
|
|
1366
|
+
);
|
|
1367
|
+
return this.apiClient(url, this.edgeRequestInit);
|
|
1368
|
+
}
|
|
1369
|
+
};
|
|
1370
|
+
var CANVAS_URL2 = "/api/v1/canvas";
|
|
1246
1371
|
var CanvasClient = class extends ApiClient {
|
|
1247
1372
|
constructor(options) {
|
|
1248
1373
|
var _a;
|
|
@@ -1260,7 +1385,7 @@ var CanvasClient = class extends ApiClient {
|
|
|
1260
1385
|
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
1261
1386
|
const rewrittenSelect = projectionToQuery(select);
|
|
1262
1387
|
if (!resolveData) {
|
|
1263
|
-
const fetchUri = this.createUrl(
|
|
1388
|
+
const fetchUri = this.createUrl(CANVAS_URL2, {
|
|
1264
1389
|
...originParams,
|
|
1265
1390
|
projectId,
|
|
1266
1391
|
...rewrittenFilters,
|
|
@@ -1308,7 +1433,7 @@ var CanvasClient = class extends ApiClient {
|
|
|
1308
1433
|
}) {
|
|
1309
1434
|
const { projectId } = this.options;
|
|
1310
1435
|
if (skipDataResolution) {
|
|
1311
|
-
return this.apiClient(this.createUrl(
|
|
1436
|
+
return this.apiClient(this.createUrl(CANVAS_URL2, { ...params, projectId }));
|
|
1312
1437
|
}
|
|
1313
1438
|
const edgeParams = {
|
|
1314
1439
|
...params,
|
|
@@ -1320,7 +1445,7 @@ var CanvasClient = class extends ApiClient {
|
|
|
1320
1445
|
}
|
|
1321
1446
|
/** Updates or creates a Canvas component definition */
|
|
1322
1447
|
async updateComposition(body, options) {
|
|
1323
|
-
const fetchUri = this.createUrl(
|
|
1448
|
+
const fetchUri = this.createUrl(CANVAS_URL2);
|
|
1324
1449
|
const headers = {};
|
|
1325
1450
|
if (options == null ? void 0 : options.ifUnmodifiedSince) {
|
|
1326
1451
|
headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
|
|
@@ -1335,7 +1460,7 @@ var CanvasClient = class extends ApiClient {
|
|
|
1335
1460
|
}
|
|
1336
1461
|
/** Deletes a Canvas component definition */
|
|
1337
1462
|
async removeComposition(body) {
|
|
1338
|
-
const fetchUri = this.createUrl(
|
|
1463
|
+
const fetchUri = this.createUrl(CANVAS_URL2);
|
|
1339
1464
|
const { projectId } = this.options;
|
|
1340
1465
|
await this.apiClient(fetchUri, {
|
|
1341
1466
|
method: "DELETE",
|
|
@@ -1474,14 +1599,18 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1474
1599
|
constructor(options) {
|
|
1475
1600
|
super(options);
|
|
1476
1601
|
}
|
|
1477
|
-
/** Fetches
|
|
1478
|
-
async
|
|
1602
|
+
/** Fetches a list of DataTypes for a project */
|
|
1603
|
+
async list(options) {
|
|
1479
1604
|
const { projectId } = this.options;
|
|
1480
1605
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8), { ...options, projectId });
|
|
1481
1606
|
return await this.apiClient(fetchUri);
|
|
1482
1607
|
}
|
|
1608
|
+
/** @deprecated Use {@link list} instead. */
|
|
1609
|
+
async get(options) {
|
|
1610
|
+
return this.list(options);
|
|
1611
|
+
}
|
|
1483
1612
|
/** Updates or creates (based on id) a DataType */
|
|
1484
|
-
async
|
|
1613
|
+
async save(body) {
|
|
1485
1614
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
|
|
1486
1615
|
await this.apiClient(fetchUri, {
|
|
1487
1616
|
method: "PUT",
|
|
@@ -1489,6 +1618,10 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1489
1618
|
expectNoContent: true
|
|
1490
1619
|
});
|
|
1491
1620
|
}
|
|
1621
|
+
/** @deprecated Use {@link save} instead. */
|
|
1622
|
+
async upsert(body) {
|
|
1623
|
+
return this.save(body);
|
|
1624
|
+
}
|
|
1492
1625
|
/** Deletes a DataType */
|
|
1493
1626
|
async remove(body) {
|
|
1494
1627
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
|
|
@@ -1526,24 +1659,6 @@ function getComponentPath(ancestorsAndSelf) {
|
|
|
1526
1659
|
}
|
|
1527
1660
|
return `.${path.join(".")}`;
|
|
1528
1661
|
}
|
|
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
1662
|
function isRootEntryReference(root) {
|
|
1548
1663
|
return root.type === "root" && isEntryData(root.node);
|
|
1549
1664
|
}
|
|
@@ -1563,9 +1678,9 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1563
1678
|
let bufferStartIndex = 0;
|
|
1564
1679
|
let bufferEndIndex = 0;
|
|
1565
1680
|
let tokenCount = 0;
|
|
1566
|
-
const handleToken = (token, type) => {
|
|
1681
|
+
const handleToken = (token, type, offset) => {
|
|
1567
1682
|
tokenCount++;
|
|
1568
|
-
return onToken == null ? void 0 : onToken(token, type);
|
|
1683
|
+
return onToken == null ? void 0 : onToken(token, type, offset);
|
|
1569
1684
|
};
|
|
1570
1685
|
let state = "text";
|
|
1571
1686
|
for (let index = 0; index < serialized.length; index++) {
|
|
@@ -1576,7 +1691,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1576
1691
|
if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
|
|
1577
1692
|
if (serialized[index - 1] === escapeCharacter) {
|
|
1578
1693
|
bufferEndIndex -= escapeCharacter.length;
|
|
1579
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
1694
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
1580
1695
|
return tokenCount;
|
|
1581
1696
|
}
|
|
1582
1697
|
bufferStartIndex = index;
|
|
@@ -1585,12 +1700,12 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1585
1700
|
}
|
|
1586
1701
|
if (state === "variable") {
|
|
1587
1702
|
const textStart = bufferStartIndex - variablePrefix.length;
|
|
1588
|
-
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
|
|
1703
|
+
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text", textStart) === false) {
|
|
1589
1704
|
return tokenCount;
|
|
1590
1705
|
}
|
|
1591
1706
|
bufferStartIndex = bufferEndIndex;
|
|
1592
1707
|
} else if (bufferEndIndex > bufferStartIndex) {
|
|
1593
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
1708
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
1594
1709
|
return tokenCount;
|
|
1595
1710
|
}
|
|
1596
1711
|
bufferStartIndex = bufferEndIndex;
|
|
@@ -1608,7 +1723,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1608
1723
|
state = "text";
|
|
1609
1724
|
if (bufferEndIndex > bufferStartIndex) {
|
|
1610
1725
|
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
|
1611
|
-
if (handleToken(unescapedVariableName, "variable") === false) {
|
|
1726
|
+
if (handleToken(unescapedVariableName, "variable", bufferStartIndex) === false) {
|
|
1612
1727
|
return tokenCount;
|
|
1613
1728
|
}
|
|
1614
1729
|
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
|
@@ -1622,7 +1737,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1622
1737
|
bufferStartIndex -= variablePrefix.length;
|
|
1623
1738
|
}
|
|
1624
1739
|
if (bufferStartIndex < serialized.length) {
|
|
1625
|
-
handleToken(serialized.substring(bufferStartIndex), state);
|
|
1740
|
+
handleToken(serialized.substring(bufferStartIndex), state, bufferStartIndex);
|
|
1626
1741
|
}
|
|
1627
1742
|
return tokenCount;
|
|
1628
1743
|
}
|
|
@@ -2000,20 +2115,28 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
2000
2115
|
* When teamId is provided, returns a single team with its projects.
|
|
2001
2116
|
* When omitted, returns all accessible teams and their projects.
|
|
2002
2117
|
*/
|
|
2003
|
-
async
|
|
2118
|
+
async list(options) {
|
|
2004
2119
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
|
|
2005
2120
|
return await this.apiClient(fetchUri);
|
|
2006
2121
|
}
|
|
2122
|
+
/** @deprecated Use {@link list} instead. */
|
|
2123
|
+
async getProjects(options) {
|
|
2124
|
+
return this.list(options);
|
|
2125
|
+
}
|
|
2007
2126
|
/** Updates or creates (based on id) a Project */
|
|
2008
|
-
async
|
|
2127
|
+
async save(body) {
|
|
2009
2128
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
|
|
2010
2129
|
return await this.apiClient(fetchUri, {
|
|
2011
2130
|
method: "PUT",
|
|
2012
2131
|
body: JSON.stringify({ ...body })
|
|
2013
2132
|
});
|
|
2014
2133
|
}
|
|
2134
|
+
/** @deprecated Use {@link save} instead. */
|
|
2135
|
+
async upsert(body) {
|
|
2136
|
+
return this.save(body);
|
|
2137
|
+
}
|
|
2015
2138
|
/** Deletes a Project */
|
|
2016
|
-
async
|
|
2139
|
+
async remove(body) {
|
|
2017
2140
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
|
|
2018
2141
|
await this.apiClient(fetchUri, {
|
|
2019
2142
|
method: "DELETE",
|
|
@@ -2021,6 +2144,10 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
2021
2144
|
expectNoContent: true
|
|
2022
2145
|
});
|
|
2023
2146
|
}
|
|
2147
|
+
/** @deprecated Use {@link remove} instead. */
|
|
2148
|
+
async delete(body) {
|
|
2149
|
+
return this.remove(body);
|
|
2150
|
+
}
|
|
2024
2151
|
};
|
|
2025
2152
|
_url22 = /* @__PURE__ */ new WeakMap();
|
|
2026
2153
|
_projectsUrl = /* @__PURE__ */ new WeakMap();
|
|
@@ -2036,8 +2163,14 @@ var RouteClient = class extends ApiClient {
|
|
|
2036
2163
|
super(options);
|
|
2037
2164
|
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
|
|
2038
2165
|
}
|
|
2039
|
-
/**
|
|
2040
|
-
|
|
2166
|
+
/**
|
|
2167
|
+
* Resolves a route to a composition, redirect, or not-found result.
|
|
2168
|
+
*
|
|
2169
|
+
* An optional `select` projection applies to the resolved composition when
|
|
2170
|
+
* the route matches one; redirect / notFound responses pass through
|
|
2171
|
+
* untouched.
|
|
2172
|
+
*/
|
|
2173
|
+
async get(options) {
|
|
2041
2174
|
const { projectId } = this.options;
|
|
2042
2175
|
const { select, ...rest } = options != null ? options : {};
|
|
2043
2176
|
const rewrittenSelect = projectionToQuery(select);
|
|
@@ -2047,6 +2180,10 @@ var RouteClient = class extends ApiClient {
|
|
|
2047
2180
|
this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
|
|
2048
2181
|
);
|
|
2049
2182
|
}
|
|
2183
|
+
/** @deprecated use {@link RouteClient.get} instead (renamed). */
|
|
2184
|
+
async getRoute(options) {
|
|
2185
|
+
return this.get(options);
|
|
2186
|
+
}
|
|
2050
2187
|
};
|
|
2051
2188
|
var getDataSourceVariantFromRouteGetParams = (params, defaultPreviewState) => {
|
|
2052
2189
|
var _a, _b;
|
|
@@ -2353,9 +2490,9 @@ function createLimitPolicy2({
|
|
|
2353
2490
|
}
|
|
2354
2491
|
|
|
2355
2492
|
// src/clients/canvas.ts
|
|
2356
|
-
var
|
|
2493
|
+
var buildCanvasClientOptions = (options) => {
|
|
2357
2494
|
const cache2 = resolveCanvasCache(options);
|
|
2358
|
-
return
|
|
2495
|
+
return {
|
|
2359
2496
|
projectId: env.getProjectId(),
|
|
2360
2497
|
apiHost: env.getApiHost(),
|
|
2361
2498
|
apiKey: env.getApiKey(),
|
|
@@ -2403,7 +2540,13 @@ var getCanvasClient = (options) => {
|
|
|
2403
2540
|
}
|
|
2404
2541
|
});
|
|
2405
2542
|
}
|
|
2406
|
-
}
|
|
2543
|
+
};
|
|
2544
|
+
};
|
|
2545
|
+
var getCanvasClient = (options) => {
|
|
2546
|
+
return new CanvasClient(buildCanvasClientOptions(options));
|
|
2547
|
+
};
|
|
2548
|
+
var getCompositionDeliveryClient = (options) => {
|
|
2549
|
+
return new CompositionDeliveryClient(buildCanvasClientOptions(options));
|
|
2407
2550
|
};
|
|
2408
2551
|
|
|
2409
2552
|
// src/clients/manifest.ts
|
|
@@ -2712,18 +2855,15 @@ var _Route = class _Route2 {
|
|
|
2712
2855
|
*/
|
|
2713
2856
|
static splitFragment(path) {
|
|
2714
2857
|
let fragmentIndex = -1;
|
|
2715
|
-
|
|
2716
|
-
parseVariableExpression(path, (token, type) => {
|
|
2858
|
+
parseVariableExpression(path, (token, type, offset) => {
|
|
2717
2859
|
if (type === "variable") {
|
|
2718
|
-
length += createVariableReference(token).length;
|
|
2719
2860
|
return;
|
|
2720
2861
|
}
|
|
2721
2862
|
const hashOffset = token.indexOf("#");
|
|
2722
2863
|
if (hashOffset === -1) {
|
|
2723
|
-
length += token.length;
|
|
2724
2864
|
return;
|
|
2725
2865
|
}
|
|
2726
|
-
fragmentIndex =
|
|
2866
|
+
fragmentIndex = offset + hashOffset;
|
|
2727
2867
|
return false;
|
|
2728
2868
|
});
|
|
2729
2869
|
if (fragmentIndex === -1) {
|
|
@@ -3444,14 +3584,14 @@ import React6 from "react";
|
|
|
3444
3584
|
import { deserializeEvaluationResult as deserializeEvaluationResult2 } from "@uniformdev/next-app-router-shared";
|
|
3445
3585
|
var resolvePlaygroundRoute = async ({ code }) => {
|
|
3446
3586
|
const pageState = deserializeEvaluationResult2({ input: code });
|
|
3447
|
-
const canvasClient =
|
|
3587
|
+
const canvasClient = getCompositionDeliveryClient({
|
|
3448
3588
|
cache: {
|
|
3449
3589
|
type: "no-cache"
|
|
3450
3590
|
}
|
|
3451
3591
|
});
|
|
3452
3592
|
let composition = void 0;
|
|
3453
3593
|
try {
|
|
3454
|
-
composition = await canvasClient.
|
|
3594
|
+
composition = await canvasClient.get({
|
|
3455
3595
|
compositionId: pageState.routePath,
|
|
3456
3596
|
state: pageState.compositionState,
|
|
3457
3597
|
withComponentIDs: true
|
|
@@ -3599,7 +3739,7 @@ var createUniformPlaygroundStaticParams = async (options) => {
|
|
|
3599
3739
|
const routeClient = getRouteClient({
|
|
3600
3740
|
state
|
|
3601
3741
|
});
|
|
3602
|
-
route = await routeClient.
|
|
3742
|
+
route = await routeClient.get({
|
|
3603
3743
|
path: firstPath,
|
|
3604
3744
|
withComponentIDs: true,
|
|
3605
3745
|
state: CANVAS_DRAFT_STATE
|
|
@@ -3652,7 +3792,7 @@ async function processRoutePath({
|
|
|
3652
3792
|
});
|
|
3653
3793
|
const rewrittenPath = await (rewrite == null ? void 0 : rewrite({ path }));
|
|
3654
3794
|
const resolvedPath = (_a = rewrittenPath == null ? void 0 : rewrittenPath.path) != null ? _a : path;
|
|
3655
|
-
const route = await routeClient.
|
|
3795
|
+
const route = await routeClient.get({
|
|
3656
3796
|
path: resolvedPath,
|
|
3657
3797
|
withComponentIDs: true,
|
|
3658
3798
|
state: CANVAS_PUBLISHED_STATE
|
|
@@ -3905,14 +4045,14 @@ var DefaultDataClient = class {
|
|
|
3905
4045
|
if (oldCachedRoute) {
|
|
3906
4046
|
waitUntil(
|
|
3907
4047
|
(async () => {
|
|
3908
|
-
const result2 = await routeClient.
|
|
4048
|
+
const result2 = await routeClient.get(route);
|
|
3909
4049
|
await cacheNewRoute(result2);
|
|
3910
4050
|
})()
|
|
3911
4051
|
);
|
|
3912
4052
|
return oldCachedRoute;
|
|
3913
4053
|
}
|
|
3914
4054
|
}
|
|
3915
|
-
const result = await routeClient.
|
|
4055
|
+
const result = await routeClient.get(route);
|
|
3916
4056
|
waitUntil(
|
|
3917
4057
|
(async () => {
|
|
3918
4058
|
await Promise.all([
|
|
@@ -4185,6 +4325,7 @@ export {
|
|
|
4185
4325
|
expireMiddlewareCacheTag,
|
|
4186
4326
|
findRouteMatch,
|
|
4187
4327
|
getCanvasClient,
|
|
4328
|
+
getCompositionDeliveryClient,
|
|
4188
4329
|
getManifest,
|
|
4189
4330
|
getManifestClient,
|
|
4190
4331
|
getProjectMapClient,
|