@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/handler.mjs
CHANGED
|
@@ -1191,6 +1191,16 @@ function createLimitPolicy({
|
|
|
1191
1191
|
return currentFunc();
|
|
1192
1192
|
};
|
|
1193
1193
|
}
|
|
1194
|
+
var ContentClientBase = class extends ApiClient {
|
|
1195
|
+
constructor(options, defaultBypassCache) {
|
|
1196
|
+
var _a, _b;
|
|
1197
|
+
super({
|
|
1198
|
+
...options,
|
|
1199
|
+
limitPolicy: (_a = options.limitPolicy) != null ? _a : createLimitPolicy({}),
|
|
1200
|
+
bypassCache: (_b = options.bypassCache) != null ? _b : defaultBypassCache
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
};
|
|
1194
1204
|
var SELECT_QUERY_PREFIX = "select.";
|
|
1195
1205
|
function appendCsv(out, key, values) {
|
|
1196
1206
|
if (values === void 0) {
|
|
@@ -1235,130 +1245,94 @@ function projectionToQuery(spec) {
|
|
|
1235
1245
|
}
|
|
1236
1246
|
return out;
|
|
1237
1247
|
}
|
|
1238
|
-
var
|
|
1239
|
-
var
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
projectId,
|
|
1259
|
-
...rewrittenFilters,
|
|
1260
|
-
...rewrittenSelect
|
|
1261
|
-
});
|
|
1262
|
-
return this.apiClient(fetchUri);
|
|
1263
|
-
}
|
|
1264
|
-
const edgeParams = {
|
|
1265
|
-
...originParams,
|
|
1266
|
-
projectId,
|
|
1267
|
-
diagnostics: typeof params.diagnostics === "boolean" ? params.diagnostics : params.diagnostics === "no-data" ? "no-data" : void 0,
|
|
1268
|
-
...rewrittenFilters,
|
|
1269
|
-
...rewrittenSelect
|
|
1270
|
-
};
|
|
1271
|
-
const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
|
|
1272
|
-
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
|
1273
|
-
}
|
|
1274
|
-
getCompositionByNodePath(options) {
|
|
1275
|
-
return this.getOneComposition(options);
|
|
1276
|
-
}
|
|
1277
|
-
getCompositionByNodeId(options) {
|
|
1278
|
-
return this.getOneComposition(options);
|
|
1279
|
-
}
|
|
1280
|
-
getCompositionBySlug(options) {
|
|
1281
|
-
return this.getOneComposition(options);
|
|
1282
|
-
}
|
|
1283
|
-
getCompositionById(options) {
|
|
1284
|
-
return this.getOneComposition(options);
|
|
1285
|
-
}
|
|
1286
|
-
getCompositionDefaults(options) {
|
|
1287
|
-
return this.getOneComposition(options);
|
|
1288
|
-
}
|
|
1289
|
-
/** Fetches historical versions of a composition or pattern */
|
|
1290
|
-
async getCompositionHistory(options) {
|
|
1291
|
-
const historyUrl = this.createUrl("/api/v1/canvas-history", {
|
|
1292
|
-
...options,
|
|
1293
|
-
projectId: this.options.projectId
|
|
1294
|
-
});
|
|
1295
|
-
return this.apiClient(historyUrl);
|
|
1296
|
-
}
|
|
1297
|
-
getOneComposition({
|
|
1298
|
-
skipDataResolution,
|
|
1299
|
-
diagnostics,
|
|
1300
|
-
...params
|
|
1301
|
-
}) {
|
|
1302
|
-
const { projectId } = this.options;
|
|
1303
|
-
if (skipDataResolution) {
|
|
1304
|
-
return this.apiClient(this.createUrl(CANVAS_URL, { ...params, projectId }));
|
|
1305
|
-
}
|
|
1306
|
-
const edgeParams = {
|
|
1307
|
-
...params,
|
|
1308
|
-
projectId,
|
|
1309
|
-
diagnostics: typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0
|
|
1248
|
+
var CANVAS_DRAFT_STATE = 0;
|
|
1249
|
+
var CANVAS_PUBLISHED_STATE = 64;
|
|
1250
|
+
var CANVAS_EDITOR_STATE = 63;
|
|
1251
|
+
var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
|
|
1252
|
+
var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
|
|
1253
|
+
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
1254
|
+
var SECRET_QUERY_STRING_PARAM = "secret";
|
|
1255
|
+
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1256
|
+
var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
|
|
1257
|
+
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
1258
|
+
function resolveCompositionSelector(args) {
|
|
1259
|
+
if ("compositionId" in args) {
|
|
1260
|
+
const { compositionId, editionId, versionId, ...readOptions } = args;
|
|
1261
|
+
return {
|
|
1262
|
+
readOptions,
|
|
1263
|
+
// raw mode matches on composition OR edition id via the compositionId param
|
|
1264
|
+
compositionId: editionId != null ? editionId : compositionId,
|
|
1265
|
+
versionId,
|
|
1266
|
+
hasCompositionId: true,
|
|
1267
|
+
pinnedEdition: editionId !== void 0
|
|
1310
1268
|
};
|
|
1311
|
-
const edgeUrl = this.createUrl("/api/v1/composition", edgeParams, this.edgeApiHost);
|
|
1312
|
-
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
|
1313
1269
|
}
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
}
|
|
1327
|
-
return { modified: response.headers.get("x-modified-at") };
|
|
1270
|
+
return { readOptions: args, hasCompositionId: false, pinnedEdition: false };
|
|
1271
|
+
}
|
|
1272
|
+
var DEFAULT_EDGE_API_HOST = "https://uniform.global";
|
|
1273
|
+
var DeliveryClientBase = class extends ContentClientBase {
|
|
1274
|
+
constructor(options) {
|
|
1275
|
+
var _a;
|
|
1276
|
+
super(
|
|
1277
|
+
options,
|
|
1278
|
+
/* defaultBypassCache */
|
|
1279
|
+
false
|
|
1280
|
+
);
|
|
1281
|
+
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : DEFAULT_EDGE_API_HOST;
|
|
1282
|
+
this.edgeRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
|
|
1328
1283
|
}
|
|
1329
|
-
/**
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
const { projectId } = this.options;
|
|
1333
|
-
await this.apiClient(fetchUri, {
|
|
1334
|
-
method: "DELETE",
|
|
1335
|
-
body: JSON.stringify({ ...body, projectId }),
|
|
1336
|
-
expectNoContent: true
|
|
1337
|
-
});
|
|
1284
|
+
/** Coerces the `diagnostics` option into the shape the edge endpoints accept. */
|
|
1285
|
+
coerceDiagnostics(diagnostics) {
|
|
1286
|
+
return typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0;
|
|
1338
1287
|
}
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1288
|
+
};
|
|
1289
|
+
var EDGE_SINGLE_URL = "/api/v1/composition";
|
|
1290
|
+
var EDGE_LIST_URL = "/api/v1/compositions";
|
|
1291
|
+
var CompositionDeliveryClient = class extends DeliveryClientBase {
|
|
1292
|
+
constructor(options) {
|
|
1293
|
+
super(options);
|
|
1344
1294
|
}
|
|
1345
|
-
/**
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1295
|
+
/** Fetches exactly one composition (throws `ApiClientError(404)` if absent). */
|
|
1296
|
+
get(args) {
|
|
1297
|
+
var _a;
|
|
1298
|
+
const { diagnostics, select, ...rest } = args;
|
|
1299
|
+
const { readOptions, compositionId, versionId, pinnedEdition } = resolveCompositionSelector(rest);
|
|
1300
|
+
const url = this.createUrl(
|
|
1301
|
+
EDGE_SINGLE_URL,
|
|
1302
|
+
{
|
|
1303
|
+
...readOptions,
|
|
1304
|
+
...projectionToQuery(select),
|
|
1305
|
+
// A pinned edition is folded into compositionId (raw matches edition or
|
|
1306
|
+
// composition id); there is no editionId query param on this endpoint.
|
|
1307
|
+
compositionId,
|
|
1308
|
+
versionId,
|
|
1309
|
+
projectId: this.options.projectId,
|
|
1310
|
+
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
1311
|
+
// editionId pins a specific edition for preview; otherwise locale-best.
|
|
1312
|
+
editions: pinnedEdition ? "raw" : "auto",
|
|
1313
|
+
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
1314
|
+
},
|
|
1315
|
+
this.edgeApiHost
|
|
1316
|
+
);
|
|
1317
|
+
return this.apiClient(url, this.edgeRequestInit);
|
|
1353
1318
|
}
|
|
1354
|
-
/**
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1319
|
+
/** Fetches a list of compositions, optionally filtered. */
|
|
1320
|
+
list(args = {}) {
|
|
1321
|
+
var _a;
|
|
1322
|
+
const { diagnostics, filters, select, ...rest } = args;
|
|
1323
|
+
const url = this.createUrl(
|
|
1324
|
+
EDGE_LIST_URL,
|
|
1325
|
+
{
|
|
1326
|
+
...rest,
|
|
1327
|
+
...rewriteFiltersForApi(filters),
|
|
1328
|
+
...projectionToQuery(select),
|
|
1329
|
+
projectId: this.options.projectId,
|
|
1330
|
+
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
1331
|
+
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
1332
|
+
},
|
|
1333
|
+
this.edgeApiHost
|
|
1334
|
+
);
|
|
1335
|
+
return this.apiClient(url, this.edgeRequestInit);
|
|
1362
1336
|
}
|
|
1363
1337
|
};
|
|
1364
1338
|
var _contentTypesUrl;
|
|
@@ -1467,14 +1441,18 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1467
1441
|
constructor(options) {
|
|
1468
1442
|
super(options);
|
|
1469
1443
|
}
|
|
1470
|
-
/** Fetches
|
|
1471
|
-
async
|
|
1444
|
+
/** Fetches a list of DataTypes for a project */
|
|
1445
|
+
async list(options) {
|
|
1472
1446
|
const { projectId } = this.options;
|
|
1473
1447
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8), { ...options, projectId });
|
|
1474
1448
|
return await this.apiClient(fetchUri);
|
|
1475
1449
|
}
|
|
1450
|
+
/** @deprecated Use {@link list} instead. */
|
|
1451
|
+
async get(options) {
|
|
1452
|
+
return this.list(options);
|
|
1453
|
+
}
|
|
1476
1454
|
/** Updates or creates (based on id) a DataType */
|
|
1477
|
-
async
|
|
1455
|
+
async save(body) {
|
|
1478
1456
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
|
|
1479
1457
|
await this.apiClient(fetchUri, {
|
|
1480
1458
|
method: "PUT",
|
|
@@ -1482,6 +1460,10 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1482
1460
|
expectNoContent: true
|
|
1483
1461
|
});
|
|
1484
1462
|
}
|
|
1463
|
+
/** @deprecated Use {@link save} instead. */
|
|
1464
|
+
async upsert(body) {
|
|
1465
|
+
return this.save(body);
|
|
1466
|
+
}
|
|
1485
1467
|
/** Deletes a DataType */
|
|
1486
1468
|
async remove(body) {
|
|
1487
1469
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
|
|
@@ -1494,15 +1476,6 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1494
1476
|
};
|
|
1495
1477
|
_url8 = /* @__PURE__ */ new WeakMap();
|
|
1496
1478
|
__privateAdd3(_DataTypeClient, _url8, "/api/v1/data-types");
|
|
1497
|
-
var CANVAS_DRAFT_STATE = 0;
|
|
1498
|
-
var CANVAS_EDITOR_STATE = 63;
|
|
1499
|
-
var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
|
|
1500
|
-
var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
|
|
1501
|
-
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
1502
|
-
var SECRET_QUERY_STRING_PARAM = "secret";
|
|
1503
|
-
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1504
|
-
var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
|
|
1505
|
-
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
1506
1479
|
var escapeCharacter = "\\";
|
|
1507
1480
|
var variablePrefix = "${";
|
|
1508
1481
|
var variableSuffix = "}";
|
|
@@ -1513,9 +1486,9 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1513
1486
|
let bufferStartIndex = 0;
|
|
1514
1487
|
let bufferEndIndex = 0;
|
|
1515
1488
|
let tokenCount = 0;
|
|
1516
|
-
const handleToken = (token, type) => {
|
|
1489
|
+
const handleToken = (token, type, offset) => {
|
|
1517
1490
|
tokenCount++;
|
|
1518
|
-
return onToken == null ? void 0 : onToken(token, type);
|
|
1491
|
+
return onToken == null ? void 0 : onToken(token, type, offset);
|
|
1519
1492
|
};
|
|
1520
1493
|
let state = "text";
|
|
1521
1494
|
for (let index = 0; index < serialized.length; index++) {
|
|
@@ -1526,7 +1499,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1526
1499
|
if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
|
|
1527
1500
|
if (serialized[index - 1] === escapeCharacter) {
|
|
1528
1501
|
bufferEndIndex -= escapeCharacter.length;
|
|
1529
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
1502
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
1530
1503
|
return tokenCount;
|
|
1531
1504
|
}
|
|
1532
1505
|
bufferStartIndex = index;
|
|
@@ -1535,12 +1508,12 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1535
1508
|
}
|
|
1536
1509
|
if (state === "variable") {
|
|
1537
1510
|
const textStart = bufferStartIndex - variablePrefix.length;
|
|
1538
|
-
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
|
|
1511
|
+
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text", textStart) === false) {
|
|
1539
1512
|
return tokenCount;
|
|
1540
1513
|
}
|
|
1541
1514
|
bufferStartIndex = bufferEndIndex;
|
|
1542
1515
|
} else if (bufferEndIndex > bufferStartIndex) {
|
|
1543
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
1516
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
1544
1517
|
return tokenCount;
|
|
1545
1518
|
}
|
|
1546
1519
|
bufferStartIndex = bufferEndIndex;
|
|
@@ -1558,7 +1531,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1558
1531
|
state = "text";
|
|
1559
1532
|
if (bufferEndIndex > bufferStartIndex) {
|
|
1560
1533
|
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
|
1561
|
-
if (handleToken(unescapedVariableName, "variable") === false) {
|
|
1534
|
+
if (handleToken(unescapedVariableName, "variable", bufferStartIndex) === false) {
|
|
1562
1535
|
return tokenCount;
|
|
1563
1536
|
}
|
|
1564
1537
|
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
|
@@ -1572,7 +1545,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
1572
1545
|
bufferStartIndex -= variablePrefix.length;
|
|
1573
1546
|
}
|
|
1574
1547
|
if (bufferStartIndex < serialized.length) {
|
|
1575
|
-
handleToken(serialized.substring(bufferStartIndex), state);
|
|
1548
|
+
handleToken(serialized.substring(bufferStartIndex), state, bufferStartIndex);
|
|
1576
1549
|
}
|
|
1577
1550
|
return tokenCount;
|
|
1578
1551
|
}
|
|
@@ -1621,6 +1594,48 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
|
|
|
1621
1594
|
_baseUrl = /* @__PURE__ */ new WeakMap();
|
|
1622
1595
|
__privateAdd3(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
|
|
1623
1596
|
var _url22;
|
|
1597
|
+
var _NotificationsClient = class _NotificationsClient2 extends ApiClient {
|
|
1598
|
+
constructor(options) {
|
|
1599
|
+
super(options);
|
|
1600
|
+
}
|
|
1601
|
+
/**
|
|
1602
|
+
* Lists notifications for the current user.
|
|
1603
|
+
*
|
|
1604
|
+
* @deprecated This API is experimental and may change without notice.
|
|
1605
|
+
*/
|
|
1606
|
+
async list(options) {
|
|
1607
|
+
const fetchUri = this.createUrl(__privateGet3(_NotificationsClient2, _url22), options);
|
|
1608
|
+
return await this.apiClient(fetchUri);
|
|
1609
|
+
}
|
|
1610
|
+
/**
|
|
1611
|
+
* Creates a notification for one or more recipients.
|
|
1612
|
+
*
|
|
1613
|
+
* @deprecated This API is experimental and may change without notice.
|
|
1614
|
+
*/
|
|
1615
|
+
async create(body) {
|
|
1616
|
+
const fetchUri = this.createUrl(__privateGet3(_NotificationsClient2, _url22));
|
|
1617
|
+
return await this.apiClient(fetchUri, {
|
|
1618
|
+
method: "POST",
|
|
1619
|
+
body: JSON.stringify(body)
|
|
1620
|
+
});
|
|
1621
|
+
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Updates the read state of the current user's notifications.
|
|
1624
|
+
*
|
|
1625
|
+
* @deprecated This API is experimental and may change without notice.
|
|
1626
|
+
*/
|
|
1627
|
+
async setReadState(body) {
|
|
1628
|
+
const fetchUri = this.createUrl(__privateGet3(_NotificationsClient2, _url22));
|
|
1629
|
+
await this.apiClient(fetchUri, {
|
|
1630
|
+
method: "PATCH",
|
|
1631
|
+
body: JSON.stringify(body),
|
|
1632
|
+
expectNoContent: true
|
|
1633
|
+
});
|
|
1634
|
+
}
|
|
1635
|
+
};
|
|
1636
|
+
_url22 = /* @__PURE__ */ new WeakMap();
|
|
1637
|
+
__privateAdd3(_NotificationsClient, _url22, "/api/v1/notifications");
|
|
1638
|
+
var _url32;
|
|
1624
1639
|
var _projectsUrl;
|
|
1625
1640
|
var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
1626
1641
|
constructor(options) {
|
|
@@ -1628,7 +1643,7 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1628
1643
|
}
|
|
1629
1644
|
/** Fetches single Project */
|
|
1630
1645
|
async get(options) {
|
|
1631
|
-
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2,
|
|
1646
|
+
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url32), { ...options });
|
|
1632
1647
|
return await this.apiClient(fetchUri);
|
|
1633
1648
|
}
|
|
1634
1649
|
/**
|
|
@@ -1636,31 +1651,43 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1636
1651
|
* When teamId is provided, returns a single team with its projects.
|
|
1637
1652
|
* When omitted, returns all accessible teams and their projects.
|
|
1638
1653
|
*/
|
|
1639
|
-
async
|
|
1654
|
+
async list(options) {
|
|
1640
1655
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
|
|
1641
1656
|
return await this.apiClient(fetchUri);
|
|
1642
1657
|
}
|
|
1658
|
+
/** @deprecated Use {@link list} instead. */
|
|
1659
|
+
async getProjects(options) {
|
|
1660
|
+
return this.list(options);
|
|
1661
|
+
}
|
|
1643
1662
|
/** Updates or creates (based on id) a Project */
|
|
1644
|
-
async
|
|
1645
|
-
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2,
|
|
1663
|
+
async save(body) {
|
|
1664
|
+
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url32));
|
|
1646
1665
|
return await this.apiClient(fetchUri, {
|
|
1647
1666
|
method: "PUT",
|
|
1648
1667
|
body: JSON.stringify({ ...body })
|
|
1649
1668
|
});
|
|
1650
1669
|
}
|
|
1670
|
+
/** @deprecated Use {@link save} instead. */
|
|
1671
|
+
async upsert(body) {
|
|
1672
|
+
return this.save(body);
|
|
1673
|
+
}
|
|
1651
1674
|
/** Deletes a Project */
|
|
1652
|
-
async
|
|
1653
|
-
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2,
|
|
1675
|
+
async remove(body) {
|
|
1676
|
+
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url32));
|
|
1654
1677
|
await this.apiClient(fetchUri, {
|
|
1655
1678
|
method: "DELETE",
|
|
1656
1679
|
body: JSON.stringify({ ...body }),
|
|
1657
1680
|
expectNoContent: true
|
|
1658
1681
|
});
|
|
1659
1682
|
}
|
|
1683
|
+
/** @deprecated Use {@link remove} instead. */
|
|
1684
|
+
async delete(body) {
|
|
1685
|
+
return this.remove(body);
|
|
1686
|
+
}
|
|
1660
1687
|
};
|
|
1661
|
-
|
|
1688
|
+
_url32 = /* @__PURE__ */ new WeakMap();
|
|
1662
1689
|
_projectsUrl = /* @__PURE__ */ new WeakMap();
|
|
1663
|
-
__privateAdd3(_ProjectClient,
|
|
1690
|
+
__privateAdd3(_ProjectClient, _url32, "/api/v1/project");
|
|
1664
1691
|
__privateAdd3(_ProjectClient, _projectsUrl, "/api/v1/projects");
|
|
1665
1692
|
var isAllowedReferrer = (referrer) => {
|
|
1666
1693
|
return Boolean(referrer == null ? void 0 : referrer.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|localhost:\d{4})\//));
|
|
@@ -2115,9 +2142,9 @@ function createLimitPolicy2({
|
|
|
2115
2142
|
}
|
|
2116
2143
|
|
|
2117
2144
|
// src/clients/canvas.ts
|
|
2118
|
-
var
|
|
2145
|
+
var buildCanvasClientOptions = (options) => {
|
|
2119
2146
|
const cache = resolveCanvasCache(options);
|
|
2120
|
-
return
|
|
2147
|
+
return {
|
|
2121
2148
|
projectId: env.getProjectId(),
|
|
2122
2149
|
apiHost: env.getApiHost(),
|
|
2123
2150
|
apiKey: env.getApiKey(),
|
|
@@ -2165,7 +2192,10 @@ var getCanvasClient = (options) => {
|
|
|
2165
2192
|
}
|
|
2166
2193
|
});
|
|
2167
2194
|
}
|
|
2168
|
-
}
|
|
2195
|
+
};
|
|
2196
|
+
};
|
|
2197
|
+
var getCompositionDeliveryClient = (options) => {
|
|
2198
|
+
return new CompositionDeliveryClient(buildCanvasClientOptions(options));
|
|
2169
2199
|
};
|
|
2170
2200
|
|
|
2171
2201
|
// src/clients/projectMap.ts
|
|
@@ -2404,6 +2434,35 @@ var _Route = class _Route2 {
|
|
|
2404
2434
|
}
|
|
2405
2435
|
return segment.slice(_Route2.dynamicSegmentPrefix.length);
|
|
2406
2436
|
}
|
|
2437
|
+
/**
|
|
2438
|
+
* Splits a path into the path portion and an optional `#fragment`
|
|
2439
|
+
* (everything after the first `#`).
|
|
2440
|
+
*
|
|
2441
|
+
* Variable expressions (`${...}`) may legitimately contain `#` characters
|
|
2442
|
+
* (e.g. JSON-pointer tokens like `${#jptr:/foo/_slug}`), so the fragment
|
|
2443
|
+
* delimiter is the first `#` that falls outside of a variable expression.
|
|
2444
|
+
*/
|
|
2445
|
+
static splitFragment(path) {
|
|
2446
|
+
let fragmentIndex = -1;
|
|
2447
|
+
parseVariableExpression(path, (token, type, offset) => {
|
|
2448
|
+
if (type === "variable") {
|
|
2449
|
+
return;
|
|
2450
|
+
}
|
|
2451
|
+
const hashOffset = token.indexOf("#");
|
|
2452
|
+
if (hashOffset === -1) {
|
|
2453
|
+
return;
|
|
2454
|
+
}
|
|
2455
|
+
fragmentIndex = offset + hashOffset;
|
|
2456
|
+
return false;
|
|
2457
|
+
});
|
|
2458
|
+
if (fragmentIndex === -1) {
|
|
2459
|
+
return { path, fragment: void 0 };
|
|
2460
|
+
}
|
|
2461
|
+
return {
|
|
2462
|
+
path: path.slice(0, fragmentIndex),
|
|
2463
|
+
fragment: path.slice(fragmentIndex + 1)
|
|
2464
|
+
};
|
|
2465
|
+
}
|
|
2407
2466
|
};
|
|
2408
2467
|
_routeInfo = /* @__PURE__ */ new WeakMap();
|
|
2409
2468
|
_Route_static = /* @__PURE__ */ new WeakSet();
|
|
@@ -2532,13 +2591,13 @@ var processCompositionChange = async (compositionId) => {
|
|
|
2532
2591
|
};
|
|
2533
2592
|
};
|
|
2534
2593
|
var getComposition = async ({ compositionId }) => {
|
|
2535
|
-
const canvasClient =
|
|
2594
|
+
const canvasClient = getCompositionDeliveryClient({
|
|
2536
2595
|
cache: {
|
|
2537
2596
|
type: "no-cache"
|
|
2538
2597
|
}
|
|
2539
2598
|
});
|
|
2540
2599
|
try {
|
|
2541
|
-
const composition = await canvasClient.
|
|
2600
|
+
const composition = await canvasClient.get({
|
|
2542
2601
|
compositionId
|
|
2543
2602
|
});
|
|
2544
2603
|
return composition;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CanvasClient, RouteClient, ComponentInstance } from '@uniformdev/canvas';
|
|
1
|
+
import { CanvasClient, CompositionDeliveryClient, RouteClient, ComponentInstance } from '@uniformdev/canvas';
|
|
2
2
|
import { CacheMode, CanvasCacheMode, ManifestCacheMode, ProjectMapCacheMode, RewriteRequestPathResult } from '@uniformdev/next-app-router-shared';
|
|
3
3
|
import { ManifestClient } from '@uniformdev/context/api';
|
|
4
4
|
import { ProjectMapClient } from '@uniformdev/project-map';
|
|
@@ -24,7 +24,12 @@ type DetectCacheMode = {
|
|
|
24
24
|
type ResolvableCacheOptions<TCacheMode extends CacheMode> = SpecificCacheMode<TCacheMode> | StateCacheMode | DetectCacheMode;
|
|
25
25
|
|
|
26
26
|
type GetCanvasClientOptions = ResolvableCacheOptions<CanvasCacheMode>;
|
|
27
|
+
type GetCompositionDeliveryClientOptions = GetCanvasClientOptions;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use {@link getCompositionDeliveryClient} instead
|
|
30
|
+
*/
|
|
27
31
|
declare const getCanvasClient: (options?: GetCanvasClientOptions) => CanvasClient;
|
|
32
|
+
declare const getCompositionDeliveryClient: (options?: GetCompositionDeliveryClientOptions) => CompositionDeliveryClient;
|
|
28
33
|
|
|
29
34
|
type GetManifestClientOptions = ResolvableCacheOptions<ManifestCacheMode>;
|
|
30
35
|
declare const getManifestClient: (options?: GetManifestClientOptions) => ManifestClient;
|
|
@@ -271,4 +276,4 @@ declare const findRouteMatch: (routes: CustomRoute[], path: string) => RouteMatc
|
|
|
271
276
|
|
|
272
277
|
declare const serverContext: <T>(defaultValue?: T) => [() => T | undefined, (v: T) => void];
|
|
273
278
|
|
|
274
|
-
export { type AwaitedUniformPageParameters, type CreateStaticParamsOptions, type CustomRoute, type GetCanvasClientOptions, type GetManifestClientOptions, type GetProjectMapClientOptions, type GetRouteClientOptions, type PlaygroundParameters, type RouteMatch, UniformCompositionProps, type UniformPageParameters, UniformPlayground, createUniformPlaygroundStaticParams, createUniformStaticParams, findRouteMatch, getCanvasClient, getManifest, getManifestClient, getProjectMapClient, getRouteClient, precomputeComposition, resolvePlaygroundRoute, serverContext };
|
|
279
|
+
export { type AwaitedUniformPageParameters, type CreateStaticParamsOptions, type CustomRoute, type GetCanvasClientOptions, type GetCompositionDeliveryClientOptions, type GetManifestClientOptions, type GetProjectMapClientOptions, type GetRouteClientOptions, type PlaygroundParameters, type RouteMatch, UniformCompositionProps, type UniformPageParameters, UniformPlayground, createUniformPlaygroundStaticParams, createUniformStaticParams, findRouteMatch, getCanvasClient, getCompositionDeliveryClient, getManifest, getManifestClient, getProjectMapClient, getRouteClient, precomputeComposition, resolvePlaygroundRoute, serverContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CanvasClient, RouteClient, ComponentInstance } from '@uniformdev/canvas';
|
|
1
|
+
import { CanvasClient, CompositionDeliveryClient, RouteClient, ComponentInstance } from '@uniformdev/canvas';
|
|
2
2
|
import { CacheMode, CanvasCacheMode, ManifestCacheMode, ProjectMapCacheMode, RewriteRequestPathResult } from '@uniformdev/next-app-router-shared';
|
|
3
3
|
import { ManifestClient } from '@uniformdev/context/api';
|
|
4
4
|
import { ProjectMapClient } from '@uniformdev/project-map';
|
|
@@ -24,7 +24,12 @@ type DetectCacheMode = {
|
|
|
24
24
|
type ResolvableCacheOptions<TCacheMode extends CacheMode> = SpecificCacheMode<TCacheMode> | StateCacheMode | DetectCacheMode;
|
|
25
25
|
|
|
26
26
|
type GetCanvasClientOptions = ResolvableCacheOptions<CanvasCacheMode>;
|
|
27
|
+
type GetCompositionDeliveryClientOptions = GetCanvasClientOptions;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use {@link getCompositionDeliveryClient} instead
|
|
30
|
+
*/
|
|
27
31
|
declare const getCanvasClient: (options?: GetCanvasClientOptions) => CanvasClient;
|
|
32
|
+
declare const getCompositionDeliveryClient: (options?: GetCompositionDeliveryClientOptions) => CompositionDeliveryClient;
|
|
28
33
|
|
|
29
34
|
type GetManifestClientOptions = ResolvableCacheOptions<ManifestCacheMode>;
|
|
30
35
|
declare const getManifestClient: (options?: GetManifestClientOptions) => ManifestClient;
|
|
@@ -271,4 +276,4 @@ declare const findRouteMatch: (routes: CustomRoute[], path: string) => RouteMatc
|
|
|
271
276
|
|
|
272
277
|
declare const serverContext: <T>(defaultValue?: T) => [() => T | undefined, (v: T) => void];
|
|
273
278
|
|
|
274
|
-
export { type AwaitedUniformPageParameters, type CreateStaticParamsOptions, type CustomRoute, type GetCanvasClientOptions, type GetManifestClientOptions, type GetProjectMapClientOptions, type GetRouteClientOptions, type PlaygroundParameters, type RouteMatch, UniformCompositionProps, type UniformPageParameters, UniformPlayground, createUniformPlaygroundStaticParams, createUniformStaticParams, findRouteMatch, getCanvasClient, getManifest, getManifestClient, getProjectMapClient, getRouteClient, precomputeComposition, resolvePlaygroundRoute, serverContext };
|
|
279
|
+
export { type AwaitedUniformPageParameters, type CreateStaticParamsOptions, type CustomRoute, type GetCanvasClientOptions, type GetCompositionDeliveryClientOptions, type GetManifestClientOptions, type GetProjectMapClientOptions, type GetRouteClientOptions, type PlaygroundParameters, type RouteMatch, UniformCompositionProps, type UniformPageParameters, UniformPlayground, createUniformPlaygroundStaticParams, createUniformStaticParams, findRouteMatch, getCanvasClient, getCompositionDeliveryClient, getManifest, getManifestClient, getProjectMapClient, getRouteClient, precomputeComposition, resolvePlaygroundRoute, serverContext };
|