@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.
@@ -1381,16 +1381,6 @@ function createLimitPolicy({
1381
1381
  return currentFunc();
1382
1382
  };
1383
1383
  }
1384
- var ContentClientBase = class extends ApiClient {
1385
- constructor(options, defaultBypassCache) {
1386
- var _a, _b;
1387
- super({
1388
- ...options,
1389
- limitPolicy: (_a = options.limitPolicy) != null ? _a : createLimitPolicy({}),
1390
- bypassCache: (_b = options.bypassCache) != null ? _b : defaultBypassCache
1391
- });
1392
- }
1393
- };
1394
1384
  var SELECT_QUERY_PREFIX = "select.";
1395
1385
  function appendCsv(out, key, values) {
1396
1386
  if (values === void 0) {
@@ -1432,100 +1422,130 @@ function projectionToQuery(spec) {
1432
1422
  }
1433
1423
  return out;
1434
1424
  }
1435
- var CANVAS_PERSONALIZE_TYPE = "$personalization";
1436
- var CANVAS_TEST_TYPE = "$test";
1437
- var CANVAS_BLOCK_PARAM_TYPE = "$block";
1438
- var CANVAS_PERSONALIZE_SLOT = "pz";
1439
- var CANVAS_TEST_SLOT = "test";
1440
- var CANVAS_DRAFT_STATE = 0;
1441
- var CANVAS_PUBLISHED_STATE = 64;
1442
- var CANVAS_EDITOR_STATE = 63;
1443
- var CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
1444
- var CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
1445
- var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
1446
- var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
1447
- var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
1448
- var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
1449
- var IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM = "is_incontext_editing_forced_settings";
1450
- var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
1451
- function resolveCompositionSelector(args) {
1452
- if ("compositionId" in args) {
1453
- const { compositionId, editionId, versionId, ...readOptions } = args;
1454
- return {
1455
- readOptions,
1456
- // raw mode matches on composition OR edition id via the compositionId param
1457
- compositionId: editionId != null ? editionId : compositionId,
1458
- versionId,
1459
- hasCompositionId: true,
1460
- pinnedEdition: editionId !== void 0
1461
- };
1462
- }
1463
- return { readOptions: args, hasCompositionId: false, pinnedEdition: false };
1464
- }
1465
- var DEFAULT_EDGE_API_HOST = "https://uniform.global";
1466
- var DeliveryClientBase = class extends ContentClientBase {
1425
+ var CANVAS_URL = "/api/v1/canvas";
1426
+ var CanvasClient = class extends ApiClient {
1467
1427
  constructor(options) {
1468
1428
  var _a;
1469
- super(
1470
- options,
1471
- /* defaultBypassCache */
1472
- false
1473
- );
1474
- this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : DEFAULT_EDGE_API_HOST;
1475
- this.edgeRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
1429
+ if (!options.limitPolicy) {
1430
+ options.limitPolicy = createLimitPolicy({});
1431
+ }
1432
+ super(options);
1433
+ this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
1434
+ this.edgeApiRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
1476
1435
  }
1477
- /** Coerces the `diagnostics` option into the shape the edge endpoints accept. */
1478
- coerceDiagnostics(diagnostics) {
1479
- return typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0;
1436
+ /** Fetches lists of Canvas compositions, optionally by type */
1437
+ async getCompositionList(params = {}) {
1438
+ const { projectId } = this.options;
1439
+ const { resolveData, filters, select, ...originParams } = params;
1440
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1441
+ const rewrittenSelect = projectionToQuery(select);
1442
+ if (!resolveData) {
1443
+ const fetchUri = this.createUrl(CANVAS_URL, {
1444
+ ...originParams,
1445
+ projectId,
1446
+ ...rewrittenFilters,
1447
+ ...rewrittenSelect
1448
+ });
1449
+ return this.apiClient(fetchUri);
1450
+ }
1451
+ const edgeParams = {
1452
+ ...originParams,
1453
+ projectId,
1454
+ diagnostics: typeof params.diagnostics === "boolean" ? params.diagnostics : params.diagnostics === "no-data" ? "no-data" : void 0,
1455
+ ...rewrittenFilters,
1456
+ ...rewrittenSelect
1457
+ };
1458
+ const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
1459
+ return this.apiClient(edgeUrl, this.edgeApiRequestInit);
1480
1460
  }
1481
- };
1482
- var EDGE_SINGLE_URL = "/api/v1/composition";
1483
- var EDGE_LIST_URL = "/api/v1/compositions";
1484
- var CompositionDeliveryClient = class extends DeliveryClientBase {
1485
- constructor(options) {
1486
- super(options);
1461
+ getCompositionByNodePath(options) {
1462
+ return this.getOneComposition(options);
1487
1463
  }
1488
- /** Fetches exactly one composition (throws `ApiClientError(404)` if absent). */
1489
- get(args) {
1490
- var _a;
1491
- const { diagnostics, select, ...rest } = args;
1492
- const { readOptions, compositionId, versionId, pinnedEdition } = resolveCompositionSelector(rest);
1493
- const url = this.createUrl(
1494
- EDGE_SINGLE_URL,
1495
- {
1496
- ...readOptions,
1497
- ...projectionToQuery(select),
1498
- // A pinned edition is folded into compositionId (raw matches edition or
1499
- // composition id); there is no editionId query param on this endpoint.
1500
- compositionId,
1501
- versionId,
1502
- projectId: this.options.projectId,
1503
- state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
1504
- // editionId pins a specific edition for preview; otherwise locale-best.
1505
- editions: pinnedEdition ? "raw" : "auto",
1506
- diagnostics: this.coerceDiagnostics(diagnostics)
1507
- },
1508
- this.edgeApiHost
1509
- );
1510
- return this.apiClient(url, this.edgeRequestInit);
1464
+ getCompositionByNodeId(options) {
1465
+ return this.getOneComposition(options);
1511
1466
  }
1512
- /** Fetches a list of compositions, optionally filtered. */
1513
- list(args = {}) {
1514
- var _a;
1515
- const { diagnostics, filters, select, ...rest } = args;
1516
- const url = this.createUrl(
1517
- EDGE_LIST_URL,
1518
- {
1519
- ...rest,
1520
- ...rewriteFiltersForApi(filters),
1521
- ...projectionToQuery(select),
1522
- projectId: this.options.projectId,
1523
- state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
1524
- diagnostics: this.coerceDiagnostics(diagnostics)
1525
- },
1526
- this.edgeApiHost
1527
- );
1528
- return this.apiClient(url, this.edgeRequestInit);
1467
+ getCompositionBySlug(options) {
1468
+ return this.getOneComposition(options);
1469
+ }
1470
+ getCompositionById(options) {
1471
+ return this.getOneComposition(options);
1472
+ }
1473
+ getCompositionDefaults(options) {
1474
+ return this.getOneComposition(options);
1475
+ }
1476
+ /** Fetches historical versions of a composition or pattern */
1477
+ async getCompositionHistory(options) {
1478
+ const historyUrl = this.createUrl("/api/v1/canvas-history", {
1479
+ ...options,
1480
+ projectId: this.options.projectId
1481
+ });
1482
+ return this.apiClient(historyUrl);
1483
+ }
1484
+ getOneComposition({
1485
+ skipDataResolution,
1486
+ diagnostics,
1487
+ ...params
1488
+ }) {
1489
+ const { projectId } = this.options;
1490
+ if (skipDataResolution) {
1491
+ return this.apiClient(this.createUrl(CANVAS_URL, { ...params, projectId }));
1492
+ }
1493
+ const edgeParams = {
1494
+ ...params,
1495
+ projectId,
1496
+ diagnostics: typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0
1497
+ };
1498
+ const edgeUrl = this.createUrl("/api/v1/composition", edgeParams, this.edgeApiHost);
1499
+ return this.apiClient(edgeUrl, this.edgeApiRequestInit);
1500
+ }
1501
+ /** Updates or creates a Canvas component definition */
1502
+ async updateComposition(body, options) {
1503
+ const fetchUri = this.createUrl(CANVAS_URL);
1504
+ const headers = {};
1505
+ if (options == null ? void 0 : options.ifUnmodifiedSince) {
1506
+ headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
1507
+ }
1508
+ const { response } = await this.apiClientWithResponse(fetchUri, {
1509
+ method: "PUT",
1510
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1511
+ expectNoContent: true,
1512
+ headers
1513
+ });
1514
+ return { modified: response.headers.get("x-modified-at") };
1515
+ }
1516
+ /** Deletes a Canvas component definition */
1517
+ async removeComposition(body) {
1518
+ const fetchUri = this.createUrl(CANVAS_URL);
1519
+ const { projectId } = this.options;
1520
+ await this.apiClient(fetchUri, {
1521
+ method: "DELETE",
1522
+ body: JSON.stringify({ ...body, projectId }),
1523
+ expectNoContent: true
1524
+ });
1525
+ }
1526
+ /** Fetches all Canvas component definitions */
1527
+ async getComponentDefinitions(options) {
1528
+ const { projectId } = this.options;
1529
+ const fetchUri = this.createUrl("/api/v1/canvas-definitions", { ...options, projectId });
1530
+ return this.apiClient(fetchUri);
1531
+ }
1532
+ /** Updates or creates a Canvas component definition */
1533
+ async updateComponentDefinition(body) {
1534
+ const fetchUri = this.createUrl("/api/v1/canvas-definitions");
1535
+ await this.apiClient(fetchUri, {
1536
+ method: "PUT",
1537
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1538
+ expectNoContent: true
1539
+ });
1540
+ }
1541
+ /** Deletes a Canvas component definition */
1542
+ async removeComponentDefinition(body) {
1543
+ const fetchUri = this.createUrl("/api/v1/canvas-definitions");
1544
+ await this.apiClient(fetchUri, {
1545
+ method: "DELETE",
1546
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1547
+ expectNoContent: true
1548
+ });
1529
1549
  }
1530
1550
  };
1531
1551
  var _contentTypesUrl;
@@ -1634,18 +1654,14 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1634
1654
  constructor(options) {
1635
1655
  super(options);
1636
1656
  }
1637
- /** Fetches a list of DataTypes for a project */
1638
- async list(options) {
1657
+ /** Fetches all DataTypes for a project */
1658
+ async get(options) {
1639
1659
  const { projectId } = this.options;
1640
1660
  const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8), { ...options, projectId });
1641
1661
  return await this.apiClient(fetchUri);
1642
1662
  }
1643
- /** @deprecated Use {@link list} instead. */
1644
- async get(options) {
1645
- return this.list(options);
1646
- }
1647
1663
  /** Updates or creates (based on id) a DataType */
1648
- async save(body) {
1664
+ async upsert(body) {
1649
1665
  const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
1650
1666
  await this.apiClient(fetchUri, {
1651
1667
  method: "PUT",
@@ -1653,10 +1669,6 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1653
1669
  expectNoContent: true
1654
1670
  });
1655
1671
  }
1656
- /** @deprecated Use {@link save} instead. */
1657
- async upsert(body) {
1658
- return this.save(body);
1659
- }
1660
1672
  /** Deletes a DataType */
1661
1673
  async remove(body) {
1662
1674
  const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
@@ -1694,6 +1706,22 @@ function getComponentPath(ancestorsAndSelf) {
1694
1706
  }
1695
1707
  return `.${path.join(".")}`;
1696
1708
  }
1709
+ var CANVAS_PERSONALIZE_TYPE = "$personalization";
1710
+ var CANVAS_TEST_TYPE = "$test";
1711
+ var CANVAS_BLOCK_PARAM_TYPE = "$block";
1712
+ var CANVAS_PERSONALIZE_SLOT = "pz";
1713
+ var CANVAS_TEST_SLOT = "test";
1714
+ var CANVAS_DRAFT_STATE = 0;
1715
+ var CANVAS_PUBLISHED_STATE = 64;
1716
+ var CANVAS_EDITOR_STATE = 63;
1717
+ var CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
1718
+ var CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
1719
+ var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
1720
+ var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
1721
+ var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
1722
+ var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
1723
+ var IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM = "is_incontext_editing_forced_settings";
1724
+ var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
1697
1725
  function isRootEntryReference(root) {
1698
1726
  return root.type === "root" && isEntryData(root.node);
1699
1727
  }
@@ -2295,28 +2323,20 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
2295
2323
  * When teamId is provided, returns a single team with its projects.
2296
2324
  * When omitted, returns all accessible teams and their projects.
2297
2325
  */
2298
- async list(options) {
2326
+ async getProjects(options) {
2299
2327
  const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
2300
2328
  return await this.apiClient(fetchUri);
2301
2329
  }
2302
- /** @deprecated Use {@link list} instead. */
2303
- async getProjects(options) {
2304
- return this.list(options);
2305
- }
2306
2330
  /** Updates or creates (based on id) a Project */
2307
- async save(body) {
2331
+ async upsert(body) {
2308
2332
  const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
2309
2333
  return await this.apiClient(fetchUri, {
2310
2334
  method: "PUT",
2311
2335
  body: JSON.stringify({ ...body })
2312
2336
  });
2313
2337
  }
2314
- /** @deprecated Use {@link save} instead. */
2315
- async upsert(body) {
2316
- return this.save(body);
2317
- }
2318
2338
  /** Deletes a Project */
2319
- async remove(body) {
2339
+ async delete(body) {
2320
2340
  const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
2321
2341
  await this.apiClient(fetchUri, {
2322
2342
  method: "DELETE",
@@ -2324,10 +2344,6 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
2324
2344
  expectNoContent: true
2325
2345
  });
2326
2346
  }
2327
- /** @deprecated Use {@link remove} instead. */
2328
- async delete(body) {
2329
- return this.remove(body);
2330
- }
2331
2347
  };
2332
2348
  _url22 = /* @__PURE__ */ new WeakMap();
2333
2349
  _projectsUrl = /* @__PURE__ */ new WeakMap();
@@ -2343,14 +2359,8 @@ var RouteClient = class extends ApiClient {
2343
2359
  super(options);
2344
2360
  this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
2345
2361
  }
2346
- /**
2347
- * Resolves a route to a composition, redirect, or not-found result.
2348
- *
2349
- * An optional `select` projection applies to the resolved composition when
2350
- * the route matches one; redirect / notFound responses pass through
2351
- * untouched.
2352
- */
2353
- async get(options) {
2362
+ /** Fetches lists of Canvas compositions, optionally by type */
2363
+ async getRoute(options) {
2354
2364
  const { projectId } = this.options;
2355
2365
  const { select, ...rest } = options != null ? options : {};
2356
2366
  const rewrittenSelect = projectionToQuery(select);
@@ -2360,10 +2370,6 @@ var RouteClient = class extends ApiClient {
2360
2370
  this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
2361
2371
  );
2362
2372
  }
2363
- /** @deprecated use {@link RouteClient.get} instead (renamed). */
2364
- async getRoute(options) {
2365
- return this.get(options);
2366
- }
2367
2373
  };
2368
2374
  var getDataSourceVariantFromRouteGetParams = (params, defaultPreviewState) => {
2369
2375
  var _a, _b;
@@ -2670,7 +2676,7 @@ function createLimitPolicy2({
2670
2676
  // src/clients/canvas.ts
2671
2677
  var getCanvasClient = (options) => {
2672
2678
  const cache = resolveCanvasCache(options);
2673
- return new CompositionDeliveryClient({
2679
+ return new CanvasClient({
2674
2680
  projectId: env.getProjectId(),
2675
2681
  apiHost: env.getApiHost(),
2676
2682
  apiKey: env.getApiKey(),
@@ -2941,14 +2947,14 @@ var DefaultDataClient = class {
2941
2947
  if (oldCachedRoute) {
2942
2948
  waitUntil(
2943
2949
  (async () => {
2944
- const result2 = await routeClient.get(route);
2950
+ const result2 = await routeClient.getRoute(route);
2945
2951
  await cacheNewRoute(result2);
2946
2952
  })()
2947
2953
  );
2948
2954
  return oldCachedRoute;
2949
2955
  }
2950
2956
  }
2951
- const result = await routeClient.get(route);
2957
+ const result = await routeClient.getRoute(route);
2952
2958
  waitUntil(
2953
2959
  (async () => {
2954
2960
  await Promise.all([
@@ -5550,6 +5556,7 @@ var retrieveRouteByPath = async ({
5550
5556
  releaseId,
5551
5557
  locale
5552
5558
  }) => {
5559
+ var _a;
5553
5560
  return await dataClient.getRoute({
5554
5561
  source: "middleware",
5555
5562
  searchParams,
@@ -5559,6 +5566,7 @@ var retrieveRouteByPath = async ({
5559
5566
  state,
5560
5567
  dataSourceVariant: getDataSourceVariantFromRouteGetParams({}, state),
5561
5568
  withComponentIDs: true,
5569
+ withContentSourceMap: (_a = getServerConfig().experimental) == null ? void 0 : _a.vercelVisualEditing,
5562
5570
  releaseId,
5563
5571
  locale,
5564
5572
  ignoreRedirects: shouldIgnoreRedirects({ state })
@@ -5657,7 +5665,7 @@ var handlePlaygroundRequest = async ({
5657
5665
  for (let i = 0; i < possibleStates.length; i++) {
5658
5666
  const state = possibleStates[i];
5659
5667
  try {
5660
- composition = await canvasClient.get({
5668
+ composition = await canvasClient.getCompositionById({
5661
5669
  compositionId: id,
5662
5670
  state,
5663
5671
  withComponentIDs: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/next-app-router",
3
- "version": "20.50.2-alpha.167+74e60d5bb7",
3
+ "version": "20.50.2-alpha.180+0be2307590",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "scripts": {
6
6
  "build": "tsup",
@@ -98,12 +98,12 @@
98
98
  "vitest": "4.1.9"
99
99
  },
100
100
  "dependencies": {
101
- "@uniformdev/canvas-react": "20.50.2-alpha.167+74e60d5bb7",
102
- "@uniformdev/next-app-router-client": "20.50.2-alpha.167+74e60d5bb7",
103
- "@uniformdev/next-app-router-shared": "20.50.2-alpha.167+74e60d5bb7",
104
- "@uniformdev/redirect": "20.50.2-alpha.167+74e60d5bb7",
105
- "@uniformdev/richtext": "20.50.2-alpha.167+74e60d5bb7",
106
- "@uniformdev/webhooks": "20.50.2-alpha.167+74e60d5bb7",
101
+ "@uniformdev/canvas-react": "20.50.2-alpha.180+0be2307590",
102
+ "@uniformdev/next-app-router-client": "20.50.2-alpha.180+0be2307590",
103
+ "@uniformdev/next-app-router-shared": "20.50.2-alpha.180+0be2307590",
104
+ "@uniformdev/redirect": "20.50.2-alpha.180+0be2307590",
105
+ "@uniformdev/richtext": "20.50.2-alpha.180+0be2307590",
106
+ "@uniformdev/webhooks": "20.50.2-alpha.180+0be2307590",
107
107
  "@vercel/functions": "^3.7.2",
108
108
  "encoding": "^0.1.13",
109
109
  "server-only": "^0.0.1",
@@ -120,5 +120,5 @@
120
120
  "publishConfig": {
121
121
  "access": "public"
122
122
  },
123
- "gitHead": "74e60d5bb79fe1c4d446e4d3e6edf9f08850be4f"
123
+ "gitHead": "0be23075901a6fd0acd8166a2bea65fbd5589789"
124
124
  }