@uniformdev/next-app-router 20.50.2-alpha.167 → 20.50.2-alpha.180
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 +18 -48
- package/dist/cache.mjs +18 -48
- package/dist/component.js +10 -30
- package/dist/component.mjs +10 -30
- package/dist/handler.js +135 -120
- package/dist/handler.mjs +135 -120
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +150 -144
- package/dist/index.js +150 -144
- package/dist/index.mjs +150 -144
- package/dist/middleware.js +148 -140
- package/dist/middleware.mjs +148 -140
- package/package.json +8 -8
package/dist/handler.js
CHANGED
|
@@ -1206,16 +1206,6 @@ function createLimitPolicy({
|
|
|
1206
1206
|
return currentFunc();
|
|
1207
1207
|
};
|
|
1208
1208
|
}
|
|
1209
|
-
var ContentClientBase = class extends ApiClient {
|
|
1210
|
-
constructor(options, defaultBypassCache) {
|
|
1211
|
-
var _a, _b;
|
|
1212
|
-
super({
|
|
1213
|
-
...options,
|
|
1214
|
-
limitPolicy: (_a = options.limitPolicy) != null ? _a : createLimitPolicy({}),
|
|
1215
|
-
bypassCache: (_b = options.bypassCache) != null ? _b : defaultBypassCache
|
|
1216
|
-
});
|
|
1217
|
-
}
|
|
1218
|
-
};
|
|
1219
1209
|
var SELECT_QUERY_PREFIX = "select.";
|
|
1220
1210
|
function appendCsv(out, key, values) {
|
|
1221
1211
|
if (values === void 0) {
|
|
@@ -1257,94 +1247,130 @@ function projectionToQuery(spec) {
|
|
|
1257
1247
|
}
|
|
1258
1248
|
return out;
|
|
1259
1249
|
}
|
|
1260
|
-
var
|
|
1261
|
-
var
|
|
1262
|
-
var CANVAS_EDITOR_STATE = 63;
|
|
1263
|
-
var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
|
|
1264
|
-
var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
|
|
1265
|
-
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
1266
|
-
var SECRET_QUERY_STRING_PARAM = "secret";
|
|
1267
|
-
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1268
|
-
var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
|
|
1269
|
-
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
1270
|
-
function resolveCompositionSelector(args) {
|
|
1271
|
-
if ("compositionId" in args) {
|
|
1272
|
-
const { compositionId, editionId, versionId, ...readOptions } = args;
|
|
1273
|
-
return {
|
|
1274
|
-
readOptions,
|
|
1275
|
-
// raw mode matches on composition OR edition id via the compositionId param
|
|
1276
|
-
compositionId: editionId != null ? editionId : compositionId,
|
|
1277
|
-
versionId,
|
|
1278
|
-
hasCompositionId: true,
|
|
1279
|
-
pinnedEdition: editionId !== void 0
|
|
1280
|
-
};
|
|
1281
|
-
}
|
|
1282
|
-
return { readOptions: args, hasCompositionId: false, pinnedEdition: false };
|
|
1283
|
-
}
|
|
1284
|
-
var DEFAULT_EDGE_API_HOST = "https://uniform.global";
|
|
1285
|
-
var DeliveryClientBase = class extends ContentClientBase {
|
|
1250
|
+
var CANVAS_URL = "/api/v1/canvas";
|
|
1251
|
+
var CanvasClient = class extends ApiClient {
|
|
1286
1252
|
constructor(options) {
|
|
1287
1253
|
var _a;
|
|
1288
|
-
|
|
1289
|
-
options
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
);
|
|
1293
|
-
this.
|
|
1294
|
-
this.edgeRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
|
|
1254
|
+
if (!options.limitPolicy) {
|
|
1255
|
+
options.limitPolicy = createLimitPolicy({});
|
|
1256
|
+
}
|
|
1257
|
+
super(options);
|
|
1258
|
+
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
|
|
1259
|
+
this.edgeApiRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
|
|
1295
1260
|
}
|
|
1296
|
-
/**
|
|
1297
|
-
|
|
1298
|
-
|
|
1261
|
+
/** Fetches lists of Canvas compositions, optionally by type */
|
|
1262
|
+
async getCompositionList(params = {}) {
|
|
1263
|
+
const { projectId } = this.options;
|
|
1264
|
+
const { resolveData, filters, select, ...originParams } = params;
|
|
1265
|
+
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
1266
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
1267
|
+
if (!resolveData) {
|
|
1268
|
+
const fetchUri = this.createUrl(CANVAS_URL, {
|
|
1269
|
+
...originParams,
|
|
1270
|
+
projectId,
|
|
1271
|
+
...rewrittenFilters,
|
|
1272
|
+
...rewrittenSelect
|
|
1273
|
+
});
|
|
1274
|
+
return this.apiClient(fetchUri);
|
|
1275
|
+
}
|
|
1276
|
+
const edgeParams = {
|
|
1277
|
+
...originParams,
|
|
1278
|
+
projectId,
|
|
1279
|
+
diagnostics: typeof params.diagnostics === "boolean" ? params.diagnostics : params.diagnostics === "no-data" ? "no-data" : void 0,
|
|
1280
|
+
...rewrittenFilters,
|
|
1281
|
+
...rewrittenSelect
|
|
1282
|
+
};
|
|
1283
|
+
const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
|
|
1284
|
+
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
|
1299
1285
|
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
var EDGE_LIST_URL = "/api/v1/compositions";
|
|
1303
|
-
var CompositionDeliveryClient = class extends DeliveryClientBase {
|
|
1304
|
-
constructor(options) {
|
|
1305
|
-
super(options);
|
|
1286
|
+
getCompositionByNodePath(options) {
|
|
1287
|
+
return this.getOneComposition(options);
|
|
1306
1288
|
}
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
var _a;
|
|
1310
|
-
const { diagnostics, select, ...rest } = args;
|
|
1311
|
-
const { readOptions, compositionId, versionId, pinnedEdition } = resolveCompositionSelector(rest);
|
|
1312
|
-
const url = this.createUrl(
|
|
1313
|
-
EDGE_SINGLE_URL,
|
|
1314
|
-
{
|
|
1315
|
-
...readOptions,
|
|
1316
|
-
...projectionToQuery(select),
|
|
1317
|
-
// A pinned edition is folded into compositionId (raw matches edition or
|
|
1318
|
-
// composition id); there is no editionId query param on this endpoint.
|
|
1319
|
-
compositionId,
|
|
1320
|
-
versionId,
|
|
1321
|
-
projectId: this.options.projectId,
|
|
1322
|
-
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
1323
|
-
// editionId pins a specific edition for preview; otherwise locale-best.
|
|
1324
|
-
editions: pinnedEdition ? "raw" : "auto",
|
|
1325
|
-
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
1326
|
-
},
|
|
1327
|
-
this.edgeApiHost
|
|
1328
|
-
);
|
|
1329
|
-
return this.apiClient(url, this.edgeRequestInit);
|
|
1289
|
+
getCompositionByNodeId(options) {
|
|
1290
|
+
return this.getOneComposition(options);
|
|
1330
1291
|
}
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
);
|
|
1347
|
-
|
|
1292
|
+
getCompositionBySlug(options) {
|
|
1293
|
+
return this.getOneComposition(options);
|
|
1294
|
+
}
|
|
1295
|
+
getCompositionById(options) {
|
|
1296
|
+
return this.getOneComposition(options);
|
|
1297
|
+
}
|
|
1298
|
+
getCompositionDefaults(options) {
|
|
1299
|
+
return this.getOneComposition(options);
|
|
1300
|
+
}
|
|
1301
|
+
/** Fetches historical versions of a composition or pattern */
|
|
1302
|
+
async getCompositionHistory(options) {
|
|
1303
|
+
const historyUrl = this.createUrl("/api/v1/canvas-history", {
|
|
1304
|
+
...options,
|
|
1305
|
+
projectId: this.options.projectId
|
|
1306
|
+
});
|
|
1307
|
+
return this.apiClient(historyUrl);
|
|
1308
|
+
}
|
|
1309
|
+
getOneComposition({
|
|
1310
|
+
skipDataResolution,
|
|
1311
|
+
diagnostics,
|
|
1312
|
+
...params
|
|
1313
|
+
}) {
|
|
1314
|
+
const { projectId } = this.options;
|
|
1315
|
+
if (skipDataResolution) {
|
|
1316
|
+
return this.apiClient(this.createUrl(CANVAS_URL, { ...params, projectId }));
|
|
1317
|
+
}
|
|
1318
|
+
const edgeParams = {
|
|
1319
|
+
...params,
|
|
1320
|
+
projectId,
|
|
1321
|
+
diagnostics: typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0
|
|
1322
|
+
};
|
|
1323
|
+
const edgeUrl = this.createUrl("/api/v1/composition", edgeParams, this.edgeApiHost);
|
|
1324
|
+
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
|
1325
|
+
}
|
|
1326
|
+
/** Updates or creates a Canvas component definition */
|
|
1327
|
+
async updateComposition(body, options) {
|
|
1328
|
+
const fetchUri = this.createUrl(CANVAS_URL);
|
|
1329
|
+
const headers = {};
|
|
1330
|
+
if (options == null ? void 0 : options.ifUnmodifiedSince) {
|
|
1331
|
+
headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
|
|
1332
|
+
}
|
|
1333
|
+
const { response } = await this.apiClientWithResponse(fetchUri, {
|
|
1334
|
+
method: "PUT",
|
|
1335
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1336
|
+
expectNoContent: true,
|
|
1337
|
+
headers
|
|
1338
|
+
});
|
|
1339
|
+
return { modified: response.headers.get("x-modified-at") };
|
|
1340
|
+
}
|
|
1341
|
+
/** Deletes a Canvas component definition */
|
|
1342
|
+
async removeComposition(body) {
|
|
1343
|
+
const fetchUri = this.createUrl(CANVAS_URL);
|
|
1344
|
+
const { projectId } = this.options;
|
|
1345
|
+
await this.apiClient(fetchUri, {
|
|
1346
|
+
method: "DELETE",
|
|
1347
|
+
body: JSON.stringify({ ...body, projectId }),
|
|
1348
|
+
expectNoContent: true
|
|
1349
|
+
});
|
|
1350
|
+
}
|
|
1351
|
+
/** Fetches all Canvas component definitions */
|
|
1352
|
+
async getComponentDefinitions(options) {
|
|
1353
|
+
const { projectId } = this.options;
|
|
1354
|
+
const fetchUri = this.createUrl("/api/v1/canvas-definitions", { ...options, projectId });
|
|
1355
|
+
return this.apiClient(fetchUri);
|
|
1356
|
+
}
|
|
1357
|
+
/** Updates or creates a Canvas component definition */
|
|
1358
|
+
async updateComponentDefinition(body) {
|
|
1359
|
+
const fetchUri = this.createUrl("/api/v1/canvas-definitions");
|
|
1360
|
+
await this.apiClient(fetchUri, {
|
|
1361
|
+
method: "PUT",
|
|
1362
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1363
|
+
expectNoContent: true
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
/** Deletes a Canvas component definition */
|
|
1367
|
+
async removeComponentDefinition(body) {
|
|
1368
|
+
const fetchUri = this.createUrl("/api/v1/canvas-definitions");
|
|
1369
|
+
await this.apiClient(fetchUri, {
|
|
1370
|
+
method: "DELETE",
|
|
1371
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1372
|
+
expectNoContent: true
|
|
1373
|
+
});
|
|
1348
1374
|
}
|
|
1349
1375
|
};
|
|
1350
1376
|
var _contentTypesUrl;
|
|
@@ -1453,18 +1479,14 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1453
1479
|
constructor(options) {
|
|
1454
1480
|
super(options);
|
|
1455
1481
|
}
|
|
1456
|
-
/** Fetches
|
|
1457
|
-
async
|
|
1482
|
+
/** Fetches all DataTypes for a project */
|
|
1483
|
+
async get(options) {
|
|
1458
1484
|
const { projectId } = this.options;
|
|
1459
1485
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8), { ...options, projectId });
|
|
1460
1486
|
return await this.apiClient(fetchUri);
|
|
1461
1487
|
}
|
|
1462
|
-
/** @deprecated Use {@link list} instead. */
|
|
1463
|
-
async get(options) {
|
|
1464
|
-
return this.list(options);
|
|
1465
|
-
}
|
|
1466
1488
|
/** Updates or creates (based on id) a DataType */
|
|
1467
|
-
async
|
|
1489
|
+
async upsert(body) {
|
|
1468
1490
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
|
|
1469
1491
|
await this.apiClient(fetchUri, {
|
|
1470
1492
|
method: "PUT",
|
|
@@ -1472,10 +1494,6 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1472
1494
|
expectNoContent: true
|
|
1473
1495
|
});
|
|
1474
1496
|
}
|
|
1475
|
-
/** @deprecated Use {@link save} instead. */
|
|
1476
|
-
async upsert(body) {
|
|
1477
|
-
return this.save(body);
|
|
1478
|
-
}
|
|
1479
1497
|
/** Deletes a DataType */
|
|
1480
1498
|
async remove(body) {
|
|
1481
1499
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
|
|
@@ -1488,6 +1506,15 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1488
1506
|
};
|
|
1489
1507
|
_url8 = /* @__PURE__ */ new WeakMap();
|
|
1490
1508
|
__privateAdd3(_DataTypeClient, _url8, "/api/v1/data-types");
|
|
1509
|
+
var CANVAS_DRAFT_STATE = 0;
|
|
1510
|
+
var CANVAS_EDITOR_STATE = 63;
|
|
1511
|
+
var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
|
|
1512
|
+
var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
|
|
1513
|
+
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
1514
|
+
var SECRET_QUERY_STRING_PARAM = "secret";
|
|
1515
|
+
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1516
|
+
var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
|
|
1517
|
+
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
1491
1518
|
var escapeCharacter = "\\";
|
|
1492
1519
|
var variablePrefix = "${";
|
|
1493
1520
|
var variableSuffix = "}";
|
|
@@ -1621,28 +1648,20 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1621
1648
|
* When teamId is provided, returns a single team with its projects.
|
|
1622
1649
|
* When omitted, returns all accessible teams and their projects.
|
|
1623
1650
|
*/
|
|
1624
|
-
async
|
|
1651
|
+
async getProjects(options) {
|
|
1625
1652
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
|
|
1626
1653
|
return await this.apiClient(fetchUri);
|
|
1627
1654
|
}
|
|
1628
|
-
/** @deprecated Use {@link list} instead. */
|
|
1629
|
-
async getProjects(options) {
|
|
1630
|
-
return this.list(options);
|
|
1631
|
-
}
|
|
1632
1655
|
/** Updates or creates (based on id) a Project */
|
|
1633
|
-
async
|
|
1656
|
+
async upsert(body) {
|
|
1634
1657
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
|
|
1635
1658
|
return await this.apiClient(fetchUri, {
|
|
1636
1659
|
method: "PUT",
|
|
1637
1660
|
body: JSON.stringify({ ...body })
|
|
1638
1661
|
});
|
|
1639
1662
|
}
|
|
1640
|
-
/** @deprecated Use {@link save} instead. */
|
|
1641
|
-
async upsert(body) {
|
|
1642
|
-
return this.save(body);
|
|
1643
|
-
}
|
|
1644
1663
|
/** Deletes a Project */
|
|
1645
|
-
async
|
|
1664
|
+
async delete(body) {
|
|
1646
1665
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
|
|
1647
1666
|
await this.apiClient(fetchUri, {
|
|
1648
1667
|
method: "DELETE",
|
|
@@ -1650,10 +1669,6 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1650
1669
|
expectNoContent: true
|
|
1651
1670
|
});
|
|
1652
1671
|
}
|
|
1653
|
-
/** @deprecated Use {@link remove} instead. */
|
|
1654
|
-
async delete(body) {
|
|
1655
|
-
return this.remove(body);
|
|
1656
|
-
}
|
|
1657
1672
|
};
|
|
1658
1673
|
_url22 = /* @__PURE__ */ new WeakMap();
|
|
1659
1674
|
_projectsUrl = /* @__PURE__ */ new WeakMap();
|
|
@@ -2114,7 +2129,7 @@ function createLimitPolicy2({
|
|
|
2114
2129
|
// src/clients/canvas.ts
|
|
2115
2130
|
var getCanvasClient = (options) => {
|
|
2116
2131
|
const cache = resolveCanvasCache(options);
|
|
2117
|
-
return new
|
|
2132
|
+
return new CanvasClient({
|
|
2118
2133
|
projectId: env.getProjectId(),
|
|
2119
2134
|
apiHost: env.getApiHost(),
|
|
2120
2135
|
apiKey: env.getApiKey(),
|
|
@@ -2535,7 +2550,7 @@ var getComposition = async ({ compositionId }) => {
|
|
|
2535
2550
|
}
|
|
2536
2551
|
});
|
|
2537
2552
|
try {
|
|
2538
|
-
const composition = await canvasClient.
|
|
2553
|
+
const composition = await canvasClient.getCompositionById({
|
|
2539
2554
|
compositionId
|
|
2540
2555
|
});
|
|
2541
2556
|
return composition;
|
package/dist/handler.mjs
CHANGED
|
@@ -1191,16 +1191,6 @@ 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
|
-
};
|
|
1204
1194
|
var SELECT_QUERY_PREFIX = "select.";
|
|
1205
1195
|
function appendCsv(out, key, values) {
|
|
1206
1196
|
if (values === void 0) {
|
|
@@ -1242,94 +1232,130 @@ function projectionToQuery(spec) {
|
|
|
1242
1232
|
}
|
|
1243
1233
|
return out;
|
|
1244
1234
|
}
|
|
1245
|
-
var
|
|
1246
|
-
var
|
|
1247
|
-
var CANVAS_EDITOR_STATE = 63;
|
|
1248
|
-
var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
|
|
1249
|
-
var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
|
|
1250
|
-
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
1251
|
-
var SECRET_QUERY_STRING_PARAM = "secret";
|
|
1252
|
-
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1253
|
-
var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
|
|
1254
|
-
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
1255
|
-
function resolveCompositionSelector(args) {
|
|
1256
|
-
if ("compositionId" in args) {
|
|
1257
|
-
const { compositionId, editionId, versionId, ...readOptions } = args;
|
|
1258
|
-
return {
|
|
1259
|
-
readOptions,
|
|
1260
|
-
// raw mode matches on composition OR edition id via the compositionId param
|
|
1261
|
-
compositionId: editionId != null ? editionId : compositionId,
|
|
1262
|
-
versionId,
|
|
1263
|
-
hasCompositionId: true,
|
|
1264
|
-
pinnedEdition: editionId !== void 0
|
|
1265
|
-
};
|
|
1266
|
-
}
|
|
1267
|
-
return { readOptions: args, hasCompositionId: false, pinnedEdition: false };
|
|
1268
|
-
}
|
|
1269
|
-
var DEFAULT_EDGE_API_HOST = "https://uniform.global";
|
|
1270
|
-
var DeliveryClientBase = class extends ContentClientBase {
|
|
1235
|
+
var CANVAS_URL = "/api/v1/canvas";
|
|
1236
|
+
var CanvasClient = class extends ApiClient {
|
|
1271
1237
|
constructor(options) {
|
|
1272
1238
|
var _a;
|
|
1273
|
-
|
|
1274
|
-
options
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
);
|
|
1278
|
-
this.
|
|
1279
|
-
this.edgeRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
|
|
1239
|
+
if (!options.limitPolicy) {
|
|
1240
|
+
options.limitPolicy = createLimitPolicy({});
|
|
1241
|
+
}
|
|
1242
|
+
super(options);
|
|
1243
|
+
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
|
|
1244
|
+
this.edgeApiRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
|
|
1280
1245
|
}
|
|
1281
|
-
/**
|
|
1282
|
-
|
|
1283
|
-
|
|
1246
|
+
/** Fetches lists of Canvas compositions, optionally by type */
|
|
1247
|
+
async getCompositionList(params = {}) {
|
|
1248
|
+
const { projectId } = this.options;
|
|
1249
|
+
const { resolveData, filters, select, ...originParams } = params;
|
|
1250
|
+
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
1251
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
1252
|
+
if (!resolveData) {
|
|
1253
|
+
const fetchUri = this.createUrl(CANVAS_URL, {
|
|
1254
|
+
...originParams,
|
|
1255
|
+
projectId,
|
|
1256
|
+
...rewrittenFilters,
|
|
1257
|
+
...rewrittenSelect
|
|
1258
|
+
});
|
|
1259
|
+
return this.apiClient(fetchUri);
|
|
1260
|
+
}
|
|
1261
|
+
const edgeParams = {
|
|
1262
|
+
...originParams,
|
|
1263
|
+
projectId,
|
|
1264
|
+
diagnostics: typeof params.diagnostics === "boolean" ? params.diagnostics : params.diagnostics === "no-data" ? "no-data" : void 0,
|
|
1265
|
+
...rewrittenFilters,
|
|
1266
|
+
...rewrittenSelect
|
|
1267
|
+
};
|
|
1268
|
+
const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
|
|
1269
|
+
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
|
1284
1270
|
}
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
var EDGE_LIST_URL = "/api/v1/compositions";
|
|
1288
|
-
var CompositionDeliveryClient = class extends DeliveryClientBase {
|
|
1289
|
-
constructor(options) {
|
|
1290
|
-
super(options);
|
|
1271
|
+
getCompositionByNodePath(options) {
|
|
1272
|
+
return this.getOneComposition(options);
|
|
1291
1273
|
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
var _a;
|
|
1295
|
-
const { diagnostics, select, ...rest } = args;
|
|
1296
|
-
const { readOptions, compositionId, versionId, pinnedEdition } = resolveCompositionSelector(rest);
|
|
1297
|
-
const url = this.createUrl(
|
|
1298
|
-
EDGE_SINGLE_URL,
|
|
1299
|
-
{
|
|
1300
|
-
...readOptions,
|
|
1301
|
-
...projectionToQuery(select),
|
|
1302
|
-
// A pinned edition is folded into compositionId (raw matches edition or
|
|
1303
|
-
// composition id); there is no editionId query param on this endpoint.
|
|
1304
|
-
compositionId,
|
|
1305
|
-
versionId,
|
|
1306
|
-
projectId: this.options.projectId,
|
|
1307
|
-
state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
|
|
1308
|
-
// editionId pins a specific edition for preview; otherwise locale-best.
|
|
1309
|
-
editions: pinnedEdition ? "raw" : "auto",
|
|
1310
|
-
diagnostics: this.coerceDiagnostics(diagnostics)
|
|
1311
|
-
},
|
|
1312
|
-
this.edgeApiHost
|
|
1313
|
-
);
|
|
1314
|
-
return this.apiClient(url, this.edgeRequestInit);
|
|
1274
|
+
getCompositionByNodeId(options) {
|
|
1275
|
+
return this.getOneComposition(options);
|
|
1315
1276
|
}
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
);
|
|
1332
|
-
|
|
1277
|
+
getCompositionBySlug(options) {
|
|
1278
|
+
return this.getOneComposition(options);
|
|
1279
|
+
}
|
|
1280
|
+
getCompositionById(options) {
|
|
1281
|
+
return this.getOneComposition(options);
|
|
1282
|
+
}
|
|
1283
|
+
getCompositionDefaults(options) {
|
|
1284
|
+
return this.getOneComposition(options);
|
|
1285
|
+
}
|
|
1286
|
+
/** Fetches historical versions of a composition or pattern */
|
|
1287
|
+
async getCompositionHistory(options) {
|
|
1288
|
+
const historyUrl = this.createUrl("/api/v1/canvas-history", {
|
|
1289
|
+
...options,
|
|
1290
|
+
projectId: this.options.projectId
|
|
1291
|
+
});
|
|
1292
|
+
return this.apiClient(historyUrl);
|
|
1293
|
+
}
|
|
1294
|
+
getOneComposition({
|
|
1295
|
+
skipDataResolution,
|
|
1296
|
+
diagnostics,
|
|
1297
|
+
...params
|
|
1298
|
+
}) {
|
|
1299
|
+
const { projectId } = this.options;
|
|
1300
|
+
if (skipDataResolution) {
|
|
1301
|
+
return this.apiClient(this.createUrl(CANVAS_URL, { ...params, projectId }));
|
|
1302
|
+
}
|
|
1303
|
+
const edgeParams = {
|
|
1304
|
+
...params,
|
|
1305
|
+
projectId,
|
|
1306
|
+
diagnostics: typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0
|
|
1307
|
+
};
|
|
1308
|
+
const edgeUrl = this.createUrl("/api/v1/composition", edgeParams, this.edgeApiHost);
|
|
1309
|
+
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
|
1310
|
+
}
|
|
1311
|
+
/** Updates or creates a Canvas component definition */
|
|
1312
|
+
async updateComposition(body, options) {
|
|
1313
|
+
const fetchUri = this.createUrl(CANVAS_URL);
|
|
1314
|
+
const headers = {};
|
|
1315
|
+
if (options == null ? void 0 : options.ifUnmodifiedSince) {
|
|
1316
|
+
headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
|
|
1317
|
+
}
|
|
1318
|
+
const { response } = await this.apiClientWithResponse(fetchUri, {
|
|
1319
|
+
method: "PUT",
|
|
1320
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1321
|
+
expectNoContent: true,
|
|
1322
|
+
headers
|
|
1323
|
+
});
|
|
1324
|
+
return { modified: response.headers.get("x-modified-at") };
|
|
1325
|
+
}
|
|
1326
|
+
/** Deletes a Canvas component definition */
|
|
1327
|
+
async removeComposition(body) {
|
|
1328
|
+
const fetchUri = this.createUrl(CANVAS_URL);
|
|
1329
|
+
const { projectId } = this.options;
|
|
1330
|
+
await this.apiClient(fetchUri, {
|
|
1331
|
+
method: "DELETE",
|
|
1332
|
+
body: JSON.stringify({ ...body, projectId }),
|
|
1333
|
+
expectNoContent: true
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
/** Fetches all Canvas component definitions */
|
|
1337
|
+
async getComponentDefinitions(options) {
|
|
1338
|
+
const { projectId } = this.options;
|
|
1339
|
+
const fetchUri = this.createUrl("/api/v1/canvas-definitions", { ...options, projectId });
|
|
1340
|
+
return this.apiClient(fetchUri);
|
|
1341
|
+
}
|
|
1342
|
+
/** Updates or creates a Canvas component definition */
|
|
1343
|
+
async updateComponentDefinition(body) {
|
|
1344
|
+
const fetchUri = this.createUrl("/api/v1/canvas-definitions");
|
|
1345
|
+
await this.apiClient(fetchUri, {
|
|
1346
|
+
method: "PUT",
|
|
1347
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1348
|
+
expectNoContent: true
|
|
1349
|
+
});
|
|
1350
|
+
}
|
|
1351
|
+
/** Deletes a Canvas component definition */
|
|
1352
|
+
async removeComponentDefinition(body) {
|
|
1353
|
+
const fetchUri = this.createUrl("/api/v1/canvas-definitions");
|
|
1354
|
+
await this.apiClient(fetchUri, {
|
|
1355
|
+
method: "DELETE",
|
|
1356
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
1357
|
+
expectNoContent: true
|
|
1358
|
+
});
|
|
1333
1359
|
}
|
|
1334
1360
|
};
|
|
1335
1361
|
var _contentTypesUrl;
|
|
@@ -1438,18 +1464,14 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1438
1464
|
constructor(options) {
|
|
1439
1465
|
super(options);
|
|
1440
1466
|
}
|
|
1441
|
-
/** Fetches
|
|
1442
|
-
async
|
|
1467
|
+
/** Fetches all DataTypes for a project */
|
|
1468
|
+
async get(options) {
|
|
1443
1469
|
const { projectId } = this.options;
|
|
1444
1470
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8), { ...options, projectId });
|
|
1445
1471
|
return await this.apiClient(fetchUri);
|
|
1446
1472
|
}
|
|
1447
|
-
/** @deprecated Use {@link list} instead. */
|
|
1448
|
-
async get(options) {
|
|
1449
|
-
return this.list(options);
|
|
1450
|
-
}
|
|
1451
1473
|
/** Updates or creates (based on id) a DataType */
|
|
1452
|
-
async
|
|
1474
|
+
async upsert(body) {
|
|
1453
1475
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
|
|
1454
1476
|
await this.apiClient(fetchUri, {
|
|
1455
1477
|
method: "PUT",
|
|
@@ -1457,10 +1479,6 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1457
1479
|
expectNoContent: true
|
|
1458
1480
|
});
|
|
1459
1481
|
}
|
|
1460
|
-
/** @deprecated Use {@link save} instead. */
|
|
1461
|
-
async upsert(body) {
|
|
1462
|
-
return this.save(body);
|
|
1463
|
-
}
|
|
1464
1482
|
/** Deletes a DataType */
|
|
1465
1483
|
async remove(body) {
|
|
1466
1484
|
const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
|
|
@@ -1473,6 +1491,15 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
|
|
|
1473
1491
|
};
|
|
1474
1492
|
_url8 = /* @__PURE__ */ new WeakMap();
|
|
1475
1493
|
__privateAdd3(_DataTypeClient, _url8, "/api/v1/data-types");
|
|
1494
|
+
var CANVAS_DRAFT_STATE = 0;
|
|
1495
|
+
var CANVAS_EDITOR_STATE = 63;
|
|
1496
|
+
var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
|
|
1497
|
+
var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
|
|
1498
|
+
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
1499
|
+
var SECRET_QUERY_STRING_PARAM = "secret";
|
|
1500
|
+
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1501
|
+
var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
|
|
1502
|
+
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
1476
1503
|
var escapeCharacter = "\\";
|
|
1477
1504
|
var variablePrefix = "${";
|
|
1478
1505
|
var variableSuffix = "}";
|
|
@@ -1606,28 +1633,20 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1606
1633
|
* When teamId is provided, returns a single team with its projects.
|
|
1607
1634
|
* When omitted, returns all accessible teams and their projects.
|
|
1608
1635
|
*/
|
|
1609
|
-
async
|
|
1636
|
+
async getProjects(options) {
|
|
1610
1637
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
|
|
1611
1638
|
return await this.apiClient(fetchUri);
|
|
1612
1639
|
}
|
|
1613
|
-
/** @deprecated Use {@link list} instead. */
|
|
1614
|
-
async getProjects(options) {
|
|
1615
|
-
return this.list(options);
|
|
1616
|
-
}
|
|
1617
1640
|
/** Updates or creates (based on id) a Project */
|
|
1618
|
-
async
|
|
1641
|
+
async upsert(body) {
|
|
1619
1642
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
|
|
1620
1643
|
return await this.apiClient(fetchUri, {
|
|
1621
1644
|
method: "PUT",
|
|
1622
1645
|
body: JSON.stringify({ ...body })
|
|
1623
1646
|
});
|
|
1624
1647
|
}
|
|
1625
|
-
/** @deprecated Use {@link save} instead. */
|
|
1626
|
-
async upsert(body) {
|
|
1627
|
-
return this.save(body);
|
|
1628
|
-
}
|
|
1629
1648
|
/** Deletes a Project */
|
|
1630
|
-
async
|
|
1649
|
+
async delete(body) {
|
|
1631
1650
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
|
|
1632
1651
|
await this.apiClient(fetchUri, {
|
|
1633
1652
|
method: "DELETE",
|
|
@@ -1635,10 +1654,6 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1635
1654
|
expectNoContent: true
|
|
1636
1655
|
});
|
|
1637
1656
|
}
|
|
1638
|
-
/** @deprecated Use {@link remove} instead. */
|
|
1639
|
-
async delete(body) {
|
|
1640
|
-
return this.remove(body);
|
|
1641
|
-
}
|
|
1642
1657
|
};
|
|
1643
1658
|
_url22 = /* @__PURE__ */ new WeakMap();
|
|
1644
1659
|
_projectsUrl = /* @__PURE__ */ new WeakMap();
|
|
@@ -2099,7 +2114,7 @@ function createLimitPolicy2({
|
|
|
2099
2114
|
// src/clients/canvas.ts
|
|
2100
2115
|
var getCanvasClient = (options) => {
|
|
2101
2116
|
const cache = resolveCanvasCache(options);
|
|
2102
|
-
return new
|
|
2117
|
+
return new CanvasClient({
|
|
2103
2118
|
projectId: env.getProjectId(),
|
|
2104
2119
|
apiHost: env.getApiHost(),
|
|
2105
2120
|
apiKey: env.getApiKey(),
|
|
@@ -2520,7 +2535,7 @@ var getComposition = async ({ compositionId }) => {
|
|
|
2520
2535
|
}
|
|
2521
2536
|
});
|
|
2522
2537
|
try {
|
|
2523
|
-
const composition = await canvasClient.
|
|
2538
|
+
const composition = await canvasClient.getCompositionById({
|
|
2524
2539
|
compositionId
|
|
2525
2540
|
});
|
|
2526
2541
|
return composition;
|