@uniformdev/next-app-router 20.74.6-alpha.2 → 20.74.7-alpha.3
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 +48 -18
- package/dist/cache.mjs +48 -18
- package/dist/component.js +30 -10
- package/dist/component.mjs +30 -10
- package/dist/config.d.mts +5 -5
- package/dist/config.d.ts +5 -5
- package/dist/config.js +12 -16
- package/dist/config.mjs +12 -16
- package/dist/handler.js +127 -139
- package/dist/handler.mjs +127 -139
- package/dist/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.esm.js +167 -40
- package/dist/index.js +168 -40
- package/dist/index.mjs +167 -40
- package/dist/middleware.js +146 -151
- package/dist/middleware.mjs +146 -151
- package/package.json +10 -10
package/dist/handler.js
CHANGED
|
@@ -1223,6 +1223,16 @@ function createLimitPolicy({
|
|
|
1223
1223
|
return currentFunc();
|
|
1224
1224
|
};
|
|
1225
1225
|
}
|
|
1226
|
+
var ContentClientBase = class extends ApiClient {
|
|
1227
|
+
constructor(options, defaultBypassCache) {
|
|
1228
|
+
var _a, _b;
|
|
1229
|
+
super({
|
|
1230
|
+
...options,
|
|
1231
|
+
limitPolicy: (_a = options.limitPolicy) != null ? _a : createLimitPolicy({}),
|
|
1232
|
+
bypassCache: (_b = options.bypassCache) != null ? _b : defaultBypassCache
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
};
|
|
1226
1236
|
var SELECT_QUERY_PREFIX = "select.";
|
|
1227
1237
|
function appendCsv(out, key, values) {
|
|
1228
1238
|
if (values === void 0) {
|
|
@@ -1267,130 +1277,94 @@ function projectionToQuery(spec) {
|
|
|
1267
1277
|
}
|
|
1268
1278
|
return out;
|
|
1269
1279
|
}
|
|
1270
|
-
var
|
|
1271
|
-
var
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
projectId,
|
|
1291
|
-
...rewrittenFilters,
|
|
1292
|
-
...rewrittenSelect
|
|
1293
|
-
});
|
|
1294
|
-
return this.apiClient(fetchUri);
|
|
1295
|
-
}
|
|
1296
|
-
const edgeParams = {
|
|
1297
|
-
...originParams,
|
|
1298
|
-
projectId,
|
|
1299
|
-
diagnostics: typeof params.diagnostics === "boolean" ? params.diagnostics : params.diagnostics === "no-data" ? "no-data" : void 0,
|
|
1300
|
-
...rewrittenFilters,
|
|
1301
|
-
...rewrittenSelect
|
|
1302
|
-
};
|
|
1303
|
-
const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
|
|
1304
|
-
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
|
1305
|
-
}
|
|
1306
|
-
getCompositionByNodePath(options) {
|
|
1307
|
-
return this.getOneComposition(options);
|
|
1308
|
-
}
|
|
1309
|
-
getCompositionByNodeId(options) {
|
|
1310
|
-
return this.getOneComposition(options);
|
|
1311
|
-
}
|
|
1312
|
-
getCompositionBySlug(options) {
|
|
1313
|
-
return this.getOneComposition(options);
|
|
1314
|
-
}
|
|
1315
|
-
getCompositionById(options) {
|
|
1316
|
-
return this.getOneComposition(options);
|
|
1317
|
-
}
|
|
1318
|
-
getCompositionDefaults(options) {
|
|
1319
|
-
return this.getOneComposition(options);
|
|
1320
|
-
}
|
|
1321
|
-
/** Fetches historical versions of a composition or pattern */
|
|
1322
|
-
async getCompositionHistory(options) {
|
|
1323
|
-
const historyUrl = this.createUrl("/api/v1/canvas-history", {
|
|
1324
|
-
...options,
|
|
1325
|
-
projectId: this.options.projectId
|
|
1326
|
-
});
|
|
1327
|
-
return this.apiClient(historyUrl);
|
|
1328
|
-
}
|
|
1329
|
-
getOneComposition({
|
|
1330
|
-
skipDataResolution,
|
|
1331
|
-
diagnostics,
|
|
1332
|
-
...params
|
|
1333
|
-
}) {
|
|
1334
|
-
const { projectId } = this.options;
|
|
1335
|
-
if (skipDataResolution) {
|
|
1336
|
-
return this.apiClient(this.createUrl(CANVAS_URL, { ...params, projectId }));
|
|
1337
|
-
}
|
|
1338
|
-
const edgeParams = {
|
|
1339
|
-
...params,
|
|
1340
|
-
projectId,
|
|
1341
|
-
diagnostics: typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0
|
|
1280
|
+
var CANVAS_DRAFT_STATE = 0;
|
|
1281
|
+
var CANVAS_PUBLISHED_STATE = 64;
|
|
1282
|
+
var CANVAS_EDITOR_STATE = 63;
|
|
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 SECRET_QUERY_STRING_PARAM = "secret";
|
|
1287
|
+
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1288
|
+
var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
|
|
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
|
|
1342
1300
|
};
|
|
1343
|
-
const edgeUrl = this.createUrl("/api/v1/composition", edgeParams, this.edgeApiHost);
|
|
1344
|
-
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
|
1345
1301
|
}
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
}
|
|
1359
|
-
return { modified: response.headers.get("x-modified-at") };
|
|
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;
|
|
1360
1315
|
}
|
|
1361
|
-
/**
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
const { projectId } = this.options;
|
|
1365
|
-
await this.apiClient(fetchUri, {
|
|
1366
|
-
method: "DELETE",
|
|
1367
|
-
body: JSON.stringify({ ...body, projectId }),
|
|
1368
|
-
expectNoContent: true
|
|
1369
|
-
});
|
|
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;
|
|
1370
1319
|
}
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
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);
|
|
1376
1326
|
}
|
|
1377
|
-
/**
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
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);
|
|
1385
1350
|
}
|
|
1386
|
-
/**
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
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);
|
|
1394
1368
|
}
|
|
1395
1369
|
};
|
|
1396
1370
|
var _contentTypesUrl;
|
|
@@ -1499,14 +1473,18 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1499
1473
|
constructor(options) {
|
|
1500
1474
|
super(options);
|
|
1501
1475
|
}
|
|
1502
|
-
/** Fetches
|
|
1503
|
-
async
|
|
1476
|
+
/** Fetches a list of DataTypes for a project */
|
|
1477
|
+
async list(options) {
|
|
1504
1478
|
const { projectId } = this.options;
|
|
1505
1479
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8), { ...options, projectId });
|
|
1506
1480
|
return await this.apiClient(fetchUri);
|
|
1507
1481
|
}
|
|
1482
|
+
/** @deprecated Use {@link list} instead. */
|
|
1483
|
+
async get(options) {
|
|
1484
|
+
return this.list(options);
|
|
1485
|
+
}
|
|
1508
1486
|
/** Updates or creates (based on id) a DataType */
|
|
1509
|
-
async
|
|
1487
|
+
async save(body) {
|
|
1510
1488
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
|
|
1511
1489
|
await this.apiClient(fetchUri, {
|
|
1512
1490
|
method: "PUT",
|
|
@@ -1514,6 +1492,10 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1514
1492
|
expectNoContent: true
|
|
1515
1493
|
});
|
|
1516
1494
|
}
|
|
1495
|
+
/** @deprecated Use {@link save} instead. */
|
|
1496
|
+
async upsert(body) {
|
|
1497
|
+
return this.save(body);
|
|
1498
|
+
}
|
|
1517
1499
|
/** Deletes a DataType */
|
|
1518
1500
|
async remove(body) {
|
|
1519
1501
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
|
|
@@ -1526,15 +1508,6 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1526
1508
|
};
|
|
1527
1509
|
_url8 = /* @__PURE__ */ new WeakMap();
|
|
1528
1510
|
__privateAdd3(_DataTypeClient, _url8, "/api/v1/data-types");
|
|
1529
|
-
var CANVAS_DRAFT_STATE = 0;
|
|
1530
|
-
var CANVAS_EDITOR_STATE = 63;
|
|
1531
|
-
var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
|
|
1532
|
-
var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
|
|
1533
|
-
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
1534
|
-
var SECRET_QUERY_STRING_PARAM = "secret";
|
|
1535
|
-
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1536
|
-
var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
|
|
1537
|
-
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
1538
1511
|
var escapeCharacter = "\\";
|
|
1539
1512
|
var variablePrefix = "${";
|
|
1540
1513
|
var variableSuffix = "}";
|
|
@@ -1668,20 +1641,28 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1668
1641
|
* When teamId is provided, returns a single team with its projects.
|
|
1669
1642
|
* When omitted, returns all accessible teams and their projects.
|
|
1670
1643
|
*/
|
|
1671
|
-
async
|
|
1644
|
+
async list(options) {
|
|
1672
1645
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
|
|
1673
1646
|
return await this.apiClient(fetchUri);
|
|
1674
1647
|
}
|
|
1648
|
+
/** @deprecated Use {@link list} instead. */
|
|
1649
|
+
async getProjects(options) {
|
|
1650
|
+
return this.list(options);
|
|
1651
|
+
}
|
|
1675
1652
|
/** Updates or creates (based on id) a Project */
|
|
1676
|
-
async
|
|
1653
|
+
async save(body) {
|
|
1677
1654
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
|
|
1678
1655
|
return await this.apiClient(fetchUri, {
|
|
1679
1656
|
method: "PUT",
|
|
1680
1657
|
body: JSON.stringify({ ...body })
|
|
1681
1658
|
});
|
|
1682
1659
|
}
|
|
1660
|
+
/** @deprecated Use {@link save} instead. */
|
|
1661
|
+
async upsert(body) {
|
|
1662
|
+
return this.save(body);
|
|
1663
|
+
}
|
|
1683
1664
|
/** Deletes a Project */
|
|
1684
|
-
async
|
|
1665
|
+
async remove(body) {
|
|
1685
1666
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
|
|
1686
1667
|
await this.apiClient(fetchUri, {
|
|
1687
1668
|
method: "DELETE",
|
|
@@ -1689,6 +1670,10 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1689
1670
|
expectNoContent: true
|
|
1690
1671
|
});
|
|
1691
1672
|
}
|
|
1673
|
+
/** @deprecated Use {@link remove} instead. */
|
|
1674
|
+
async delete(body) {
|
|
1675
|
+
return this.remove(body);
|
|
1676
|
+
}
|
|
1692
1677
|
};
|
|
1693
1678
|
_url22 = /* @__PURE__ */ new WeakMap();
|
|
1694
1679
|
_projectsUrl = /* @__PURE__ */ new WeakMap();
|
|
@@ -2149,9 +2134,9 @@ function createLimitPolicy2({
|
|
|
2149
2134
|
}
|
|
2150
2135
|
|
|
2151
2136
|
// src/clients/canvas.ts
|
|
2152
|
-
var
|
|
2137
|
+
var buildCanvasClientOptions = (options) => {
|
|
2153
2138
|
const cache = resolveCanvasCache(options);
|
|
2154
|
-
return
|
|
2139
|
+
return {
|
|
2155
2140
|
projectId: env.getProjectId(),
|
|
2156
2141
|
apiHost: env.getApiHost(),
|
|
2157
2142
|
apiKey: env.getApiKey(),
|
|
@@ -2199,7 +2184,10 @@ var getCanvasClient = (options) => {
|
|
|
2199
2184
|
}
|
|
2200
2185
|
});
|
|
2201
2186
|
}
|
|
2202
|
-
}
|
|
2187
|
+
};
|
|
2188
|
+
};
|
|
2189
|
+
var getCompositionDeliveryClient = (options) => {
|
|
2190
|
+
return new CompositionDeliveryClient(buildCanvasClientOptions(options));
|
|
2203
2191
|
};
|
|
2204
2192
|
|
|
2205
2193
|
// src/clients/projectMap.ts
|
|
@@ -2595,13 +2583,13 @@ var processCompositionChange = async (compositionId) => {
|
|
|
2595
2583
|
};
|
|
2596
2584
|
};
|
|
2597
2585
|
var getComposition = async ({ compositionId }) => {
|
|
2598
|
-
const canvasClient =
|
|
2586
|
+
const canvasClient = getCompositionDeliveryClient({
|
|
2599
2587
|
cache: {
|
|
2600
2588
|
type: "no-cache"
|
|
2601
2589
|
}
|
|
2602
2590
|
});
|
|
2603
2591
|
try {
|
|
2604
|
-
const composition = await canvasClient.
|
|
2592
|
+
const composition = await canvasClient.get({
|
|
2605
2593
|
compositionId
|
|
2606
2594
|
});
|
|
2607
2595
|
return composition;
|
|
@@ -2864,7 +2852,7 @@ var handleSvixMessage = async (request) => {
|
|
|
2864
2852
|
const cache = getMiddlewareRuntimeCache() ? (0, import_functions.getCache)() : void 0;
|
|
2865
2853
|
for (let i = 0; i < tags.length; i++) {
|
|
2866
2854
|
const tag = tags[i];
|
|
2867
|
-
(0, import_cache4.revalidateTag)(tag);
|
|
2855
|
+
(0, import_cache4.revalidateTag)(tag, "max");
|
|
2868
2856
|
if (cache) {
|
|
2869
2857
|
await cache.expireTag(tag);
|
|
2870
2858
|
}
|