@uniformdev/next-app-router 20.72.3-alpha.2 → 20.72.3-alpha.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cache.js +114 -25
- package/dist/cache.mjs +114 -25
- package/dist/component.js +111 -32
- package/dist/component.mjs +97 -18
- package/dist/handler.js +204 -158
- package/dist/handler.mjs +204 -158
- package/dist/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.esm.js +242 -59
- package/dist/index.js +243 -59
- package/dist/index.mjs +242 -59
- package/dist/middleware.js +219 -165
- package/dist/middleware.mjs +219 -165
- package/package.json +8 -8
package/dist/index.esm.js
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
|
}
|
|
@@ -1985,6 +2100,48 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
|
|
|
1985
2100
|
_baseUrl = /* @__PURE__ */ new WeakMap();
|
|
1986
2101
|
__privateAdd3(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
|
|
1987
2102
|
var _url22;
|
|
2103
|
+
var _NotificationsClient = class _NotificationsClient2 extends ApiClient {
|
|
2104
|
+
constructor(options) {
|
|
2105
|
+
super(options);
|
|
2106
|
+
}
|
|
2107
|
+
/**
|
|
2108
|
+
* Lists notifications for the current user.
|
|
2109
|
+
*
|
|
2110
|
+
* @deprecated This API is experimental and may change without notice.
|
|
2111
|
+
*/
|
|
2112
|
+
async list(options) {
|
|
2113
|
+
const fetchUri = this.createUrl(__privateGet3(_NotificationsClient2, _url22), options);
|
|
2114
|
+
return await this.apiClient(fetchUri);
|
|
2115
|
+
}
|
|
2116
|
+
/**
|
|
2117
|
+
* Creates a notification for one or more recipients.
|
|
2118
|
+
*
|
|
2119
|
+
* @deprecated This API is experimental and may change without notice.
|
|
2120
|
+
*/
|
|
2121
|
+
async create(body) {
|
|
2122
|
+
const fetchUri = this.createUrl(__privateGet3(_NotificationsClient2, _url22));
|
|
2123
|
+
return await this.apiClient(fetchUri, {
|
|
2124
|
+
method: "POST",
|
|
2125
|
+
body: JSON.stringify(body)
|
|
2126
|
+
});
|
|
2127
|
+
}
|
|
2128
|
+
/**
|
|
2129
|
+
* Updates the read state of the current user's notifications.
|
|
2130
|
+
*
|
|
2131
|
+
* @deprecated This API is experimental and may change without notice.
|
|
2132
|
+
*/
|
|
2133
|
+
async setReadState(body) {
|
|
2134
|
+
const fetchUri = this.createUrl(__privateGet3(_NotificationsClient2, _url22));
|
|
2135
|
+
await this.apiClient(fetchUri, {
|
|
2136
|
+
method: "PATCH",
|
|
2137
|
+
body: JSON.stringify(body),
|
|
2138
|
+
expectNoContent: true
|
|
2139
|
+
});
|
|
2140
|
+
}
|
|
2141
|
+
};
|
|
2142
|
+
_url22 = /* @__PURE__ */ new WeakMap();
|
|
2143
|
+
__privateAdd3(_NotificationsClient, _url22, "/api/v1/notifications");
|
|
2144
|
+
var _url32;
|
|
1988
2145
|
var _projectsUrl;
|
|
1989
2146
|
var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
1990
2147
|
constructor(options) {
|
|
@@ -1992,7 +2149,7 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1992
2149
|
}
|
|
1993
2150
|
/** Fetches single Project */
|
|
1994
2151
|
async get(options) {
|
|
1995
|
-
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2,
|
|
2152
|
+
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url32), { ...options });
|
|
1996
2153
|
return await this.apiClient(fetchUri);
|
|
1997
2154
|
}
|
|
1998
2155
|
/**
|
|
@@ -2000,31 +2157,43 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
2000
2157
|
* When teamId is provided, returns a single team with its projects.
|
|
2001
2158
|
* When omitted, returns all accessible teams and their projects.
|
|
2002
2159
|
*/
|
|
2003
|
-
async
|
|
2160
|
+
async list(options) {
|
|
2004
2161
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
|
|
2005
2162
|
return await this.apiClient(fetchUri);
|
|
2006
2163
|
}
|
|
2164
|
+
/** @deprecated Use {@link list} instead. */
|
|
2165
|
+
async getProjects(options) {
|
|
2166
|
+
return this.list(options);
|
|
2167
|
+
}
|
|
2007
2168
|
/** Updates or creates (based on id) a Project */
|
|
2008
|
-
async
|
|
2009
|
-
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2,
|
|
2169
|
+
async save(body) {
|
|
2170
|
+
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url32));
|
|
2010
2171
|
return await this.apiClient(fetchUri, {
|
|
2011
2172
|
method: "PUT",
|
|
2012
2173
|
body: JSON.stringify({ ...body })
|
|
2013
2174
|
});
|
|
2014
2175
|
}
|
|
2176
|
+
/** @deprecated Use {@link save} instead. */
|
|
2177
|
+
async upsert(body) {
|
|
2178
|
+
return this.save(body);
|
|
2179
|
+
}
|
|
2015
2180
|
/** Deletes a Project */
|
|
2016
|
-
async
|
|
2017
|
-
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2,
|
|
2181
|
+
async remove(body) {
|
|
2182
|
+
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url32));
|
|
2018
2183
|
await this.apiClient(fetchUri, {
|
|
2019
2184
|
method: "DELETE",
|
|
2020
2185
|
body: JSON.stringify({ ...body }),
|
|
2021
2186
|
expectNoContent: true
|
|
2022
2187
|
});
|
|
2023
2188
|
}
|
|
2189
|
+
/** @deprecated Use {@link remove} instead. */
|
|
2190
|
+
async delete(body) {
|
|
2191
|
+
return this.remove(body);
|
|
2192
|
+
}
|
|
2024
2193
|
};
|
|
2025
|
-
|
|
2194
|
+
_url32 = /* @__PURE__ */ new WeakMap();
|
|
2026
2195
|
_projectsUrl = /* @__PURE__ */ new WeakMap();
|
|
2027
|
-
__privateAdd3(_ProjectClient,
|
|
2196
|
+
__privateAdd3(_ProjectClient, _url32, "/api/v1/project");
|
|
2028
2197
|
__privateAdd3(_ProjectClient, _projectsUrl, "/api/v1/projects");
|
|
2029
2198
|
var ROUTE_URL = "/api/v1/route";
|
|
2030
2199
|
var RouteClient = class extends ApiClient {
|
|
@@ -2036,8 +2205,14 @@ var RouteClient = class extends ApiClient {
|
|
|
2036
2205
|
super(options);
|
|
2037
2206
|
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
|
|
2038
2207
|
}
|
|
2039
|
-
/**
|
|
2040
|
-
|
|
2208
|
+
/**
|
|
2209
|
+
* Resolves a route to a composition, redirect, or not-found result.
|
|
2210
|
+
*
|
|
2211
|
+
* An optional `select` projection applies to the resolved composition when
|
|
2212
|
+
* the route matches one; redirect / notFound responses pass through
|
|
2213
|
+
* untouched.
|
|
2214
|
+
*/
|
|
2215
|
+
async get(options) {
|
|
2041
2216
|
const { projectId } = this.options;
|
|
2042
2217
|
const { select, ...rest } = options != null ? options : {};
|
|
2043
2218
|
const rewrittenSelect = projectionToQuery(select);
|
|
@@ -2047,6 +2222,10 @@ var RouteClient = class extends ApiClient {
|
|
|
2047
2222
|
this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
|
|
2048
2223
|
);
|
|
2049
2224
|
}
|
|
2225
|
+
/** @deprecated use {@link RouteClient.get} instead (renamed). */
|
|
2226
|
+
async getRoute(options) {
|
|
2227
|
+
return this.get(options);
|
|
2228
|
+
}
|
|
2050
2229
|
};
|
|
2051
2230
|
var getDataSourceVariantFromRouteGetParams = (params, defaultPreviewState) => {
|
|
2052
2231
|
var _a, _b;
|
|
@@ -2353,9 +2532,9 @@ function createLimitPolicy2({
|
|
|
2353
2532
|
}
|
|
2354
2533
|
|
|
2355
2534
|
// src/clients/canvas.ts
|
|
2356
|
-
var
|
|
2535
|
+
var buildCanvasClientOptions = (options) => {
|
|
2357
2536
|
const cache2 = resolveCanvasCache(options);
|
|
2358
|
-
return
|
|
2537
|
+
return {
|
|
2359
2538
|
projectId: env.getProjectId(),
|
|
2360
2539
|
apiHost: env.getApiHost(),
|
|
2361
2540
|
apiKey: env.getApiKey(),
|
|
@@ -2403,7 +2582,13 @@ var getCanvasClient = (options) => {
|
|
|
2403
2582
|
}
|
|
2404
2583
|
});
|
|
2405
2584
|
}
|
|
2406
|
-
}
|
|
2585
|
+
};
|
|
2586
|
+
};
|
|
2587
|
+
var getCanvasClient = (options) => {
|
|
2588
|
+
return new CanvasClient(buildCanvasClientOptions(options));
|
|
2589
|
+
};
|
|
2590
|
+
var getCompositionDeliveryClient = (options) => {
|
|
2591
|
+
return new CompositionDeliveryClient(buildCanvasClientOptions(options));
|
|
2407
2592
|
};
|
|
2408
2593
|
|
|
2409
2594
|
// src/clients/manifest.ts
|
|
@@ -2712,18 +2897,15 @@ var _Route = class _Route2 {
|
|
|
2712
2897
|
*/
|
|
2713
2898
|
static splitFragment(path) {
|
|
2714
2899
|
let fragmentIndex = -1;
|
|
2715
|
-
|
|
2716
|
-
parseVariableExpression(path, (token, type) => {
|
|
2900
|
+
parseVariableExpression(path, (token, type, offset) => {
|
|
2717
2901
|
if (type === "variable") {
|
|
2718
|
-
length += createVariableReference(token).length;
|
|
2719
2902
|
return;
|
|
2720
2903
|
}
|
|
2721
2904
|
const hashOffset = token.indexOf("#");
|
|
2722
2905
|
if (hashOffset === -1) {
|
|
2723
|
-
length += token.length;
|
|
2724
2906
|
return;
|
|
2725
2907
|
}
|
|
2726
|
-
fragmentIndex =
|
|
2908
|
+
fragmentIndex = offset + hashOffset;
|
|
2727
2909
|
return false;
|
|
2728
2910
|
});
|
|
2729
2911
|
if (fragmentIndex === -1) {
|
|
@@ -3444,14 +3626,14 @@ import React6 from "react";
|
|
|
3444
3626
|
import { deserializeEvaluationResult as deserializeEvaluationResult2 } from "@uniformdev/next-app-router-shared";
|
|
3445
3627
|
var resolvePlaygroundRoute = async ({ code }) => {
|
|
3446
3628
|
const pageState = deserializeEvaluationResult2({ input: code });
|
|
3447
|
-
const canvasClient =
|
|
3629
|
+
const canvasClient = getCompositionDeliveryClient({
|
|
3448
3630
|
cache: {
|
|
3449
3631
|
type: "no-cache"
|
|
3450
3632
|
}
|
|
3451
3633
|
});
|
|
3452
3634
|
let composition = void 0;
|
|
3453
3635
|
try {
|
|
3454
|
-
composition = await canvasClient.
|
|
3636
|
+
composition = await canvasClient.get({
|
|
3455
3637
|
compositionId: pageState.routePath,
|
|
3456
3638
|
state: pageState.compositionState,
|
|
3457
3639
|
withComponentIDs: true
|
|
@@ -3599,7 +3781,7 @@ var createUniformPlaygroundStaticParams = async (options) => {
|
|
|
3599
3781
|
const routeClient = getRouteClient({
|
|
3600
3782
|
state
|
|
3601
3783
|
});
|
|
3602
|
-
route = await routeClient.
|
|
3784
|
+
route = await routeClient.get({
|
|
3603
3785
|
path: firstPath,
|
|
3604
3786
|
withComponentIDs: true,
|
|
3605
3787
|
state: CANVAS_DRAFT_STATE
|
|
@@ -3652,7 +3834,7 @@ async function processRoutePath({
|
|
|
3652
3834
|
});
|
|
3653
3835
|
const rewrittenPath = await (rewrite == null ? void 0 : rewrite({ path }));
|
|
3654
3836
|
const resolvedPath = (_a = rewrittenPath == null ? void 0 : rewrittenPath.path) != null ? _a : path;
|
|
3655
|
-
const route = await routeClient.
|
|
3837
|
+
const route = await routeClient.get({
|
|
3656
3838
|
path: resolvedPath,
|
|
3657
3839
|
withComponentIDs: true,
|
|
3658
3840
|
state: CANVAS_PUBLISHED_STATE
|
|
@@ -3905,14 +4087,14 @@ var DefaultDataClient = class {
|
|
|
3905
4087
|
if (oldCachedRoute) {
|
|
3906
4088
|
waitUntil(
|
|
3907
4089
|
(async () => {
|
|
3908
|
-
const result2 = await routeClient.
|
|
4090
|
+
const result2 = await routeClient.get(route);
|
|
3909
4091
|
await cacheNewRoute(result2);
|
|
3910
4092
|
})()
|
|
3911
4093
|
);
|
|
3912
4094
|
return oldCachedRoute;
|
|
3913
4095
|
}
|
|
3914
4096
|
}
|
|
3915
|
-
const result = await routeClient.
|
|
4097
|
+
const result = await routeClient.get(route);
|
|
3916
4098
|
waitUntil(
|
|
3917
4099
|
(async () => {
|
|
3918
4100
|
await Promise.all([
|
|
@@ -4185,6 +4367,7 @@ export {
|
|
|
4185
4367
|
expireMiddlewareCacheTag,
|
|
4186
4368
|
findRouteMatch,
|
|
4187
4369
|
getCanvasClient,
|
|
4370
|
+
getCompositionDeliveryClient,
|
|
4188
4371
|
getManifest,
|
|
4189
4372
|
getManifestClient,
|
|
4190
4373
|
getProjectMapClient,
|