@uniformdev/next-app-router 20.74.6-alpha.3 → 20.74.6-alpha.5

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.
@@ -1398,6 +1398,16 @@ function createLimitPolicy({
1398
1398
  return currentFunc();
1399
1399
  };
1400
1400
  }
1401
+ var ContentClientBase = class extends ApiClient {
1402
+ constructor(options, defaultBypassCache) {
1403
+ var _a, _b;
1404
+ super({
1405
+ ...options,
1406
+ limitPolicy: (_a = options.limitPolicy) != null ? _a : createLimitPolicy({}),
1407
+ bypassCache: (_b = options.bypassCache) != null ? _b : defaultBypassCache
1408
+ });
1409
+ }
1410
+ };
1401
1411
  var SELECT_QUERY_PREFIX = "select.";
1402
1412
  function appendCsv(out, key, values) {
1403
1413
  if (values === void 0) {
@@ -1442,130 +1452,100 @@ function projectionToQuery(spec) {
1442
1452
  }
1443
1453
  return out;
1444
1454
  }
1445
- var CANVAS_URL = "/api/v1/canvas";
1446
- var CanvasClient = class extends ApiClient {
1447
- constructor(options) {
1448
- var _a;
1449
- if (!options.limitPolicy) {
1450
- options.limitPolicy = createLimitPolicy({});
1451
- }
1452
- super(options);
1453
- this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
1454
- this.edgeApiRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
1455
- }
1456
- /** Fetches lists of Canvas compositions, optionally by type */
1457
- async getCompositionList(params = {}) {
1458
- const { projectId } = this.options;
1459
- const { resolveData, filters, select, ...originParams } = params;
1460
- const rewrittenFilters = rewriteFiltersForApi(filters);
1461
- const rewrittenSelect = projectionToQuery(select);
1462
- if (!resolveData) {
1463
- const fetchUri = this.createUrl(CANVAS_URL, {
1464
- ...originParams,
1465
- projectId,
1466
- ...rewrittenFilters,
1467
- ...rewrittenSelect
1468
- });
1469
- return this.apiClient(fetchUri);
1470
- }
1471
- const edgeParams = {
1472
- ...originParams,
1473
- projectId,
1474
- diagnostics: typeof params.diagnostics === "boolean" ? params.diagnostics : params.diagnostics === "no-data" ? "no-data" : void 0,
1475
- ...rewrittenFilters,
1476
- ...rewrittenSelect
1477
- };
1478
- const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
1479
- return this.apiClient(edgeUrl, this.edgeApiRequestInit);
1480
- }
1481
- getCompositionByNodePath(options) {
1482
- return this.getOneComposition(options);
1483
- }
1484
- getCompositionByNodeId(options) {
1485
- return this.getOneComposition(options);
1486
- }
1487
- getCompositionBySlug(options) {
1488
- return this.getOneComposition(options);
1489
- }
1490
- getCompositionById(options) {
1491
- return this.getOneComposition(options);
1492
- }
1493
- getCompositionDefaults(options) {
1494
- return this.getOneComposition(options);
1495
- }
1496
- /** Fetches historical versions of a composition or pattern */
1497
- async getCompositionHistory(options) {
1498
- const historyUrl = this.createUrl("/api/v1/canvas-history", {
1499
- ...options,
1500
- projectId: this.options.projectId
1501
- });
1502
- return this.apiClient(historyUrl);
1503
- }
1504
- getOneComposition({
1505
- skipDataResolution,
1506
- diagnostics,
1507
- ...params
1508
- }) {
1509
- const { projectId } = this.options;
1510
- if (skipDataResolution) {
1511
- return this.apiClient(this.createUrl(CANVAS_URL, { ...params, projectId }));
1512
- }
1513
- const edgeParams = {
1514
- ...params,
1515
- projectId,
1516
- diagnostics: typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0
1455
+ var CANVAS_PERSONALIZE_TYPE = "$personalization";
1456
+ var CANVAS_TEST_TYPE = "$test";
1457
+ var CANVAS_BLOCK_PARAM_TYPE = "$block";
1458
+ var CANVAS_PERSONALIZE_SLOT = "pz";
1459
+ var CANVAS_TEST_SLOT = "test";
1460
+ var CANVAS_DRAFT_STATE = 0;
1461
+ var CANVAS_PUBLISHED_STATE = 64;
1462
+ var CANVAS_EDITOR_STATE = 63;
1463
+ var CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
1464
+ var CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
1465
+ var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
1466
+ var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
1467
+ var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
1468
+ var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
1469
+ var IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM = "is_incontext_editing_forced_settings";
1470
+ var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
1471
+ function resolveCompositionSelector(args) {
1472
+ if ("compositionId" in args) {
1473
+ const { compositionId, editionId, versionId, ...readOptions } = args;
1474
+ return {
1475
+ readOptions,
1476
+ // raw mode matches on composition OR edition id via the compositionId param
1477
+ compositionId: editionId != null ? editionId : compositionId,
1478
+ versionId,
1479
+ hasCompositionId: true,
1480
+ pinnedEdition: editionId !== void 0
1517
1481
  };
1518
- const edgeUrl = this.createUrl("/api/v1/composition", edgeParams, this.edgeApiHost);
1519
- return this.apiClient(edgeUrl, this.edgeApiRequestInit);
1520
1482
  }
1521
- /** Updates or creates a Canvas component definition */
1522
- async updateComposition(body, options) {
1523
- const fetchUri = this.createUrl(CANVAS_URL);
1524
- const headers = {};
1525
- if (options == null ? void 0 : options.ifUnmodifiedSince) {
1526
- headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
1527
- }
1528
- const { response } = await this.apiClientWithResponse(fetchUri, {
1529
- method: "PUT",
1530
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1531
- expectNoContent: true,
1532
- headers
1533
- });
1534
- return { modified: response.headers.get("x-modified-at") };
1483
+ return { readOptions: args, hasCompositionId: false, pinnedEdition: false };
1484
+ }
1485
+ var DEFAULT_EDGE_API_HOST = "https://uniform.global";
1486
+ var DeliveryClientBase = class extends ContentClientBase {
1487
+ constructor(options) {
1488
+ var _a;
1489
+ super(
1490
+ options,
1491
+ /* defaultBypassCache */
1492
+ false
1493
+ );
1494
+ this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : DEFAULT_EDGE_API_HOST;
1495
+ this.edgeRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
1535
1496
  }
1536
- /** Deletes a Canvas component definition */
1537
- async removeComposition(body) {
1538
- const fetchUri = this.createUrl(CANVAS_URL);
1539
- const { projectId } = this.options;
1540
- await this.apiClient(fetchUri, {
1541
- method: "DELETE",
1542
- body: JSON.stringify({ ...body, projectId }),
1543
- expectNoContent: true
1544
- });
1497
+ /** Coerces the `diagnostics` option into the shape the edge endpoints accept. */
1498
+ coerceDiagnostics(diagnostics) {
1499
+ return typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0;
1545
1500
  }
1546
- /** Fetches all Canvas component definitions */
1547
- async getComponentDefinitions(options) {
1548
- const { projectId } = this.options;
1549
- const fetchUri = this.createUrl("/api/v1/canvas-definitions", { ...options, projectId });
1550
- return this.apiClient(fetchUri);
1501
+ };
1502
+ var EDGE_SINGLE_URL = "/api/v1/composition";
1503
+ var EDGE_LIST_URL = "/api/v1/compositions";
1504
+ var CompositionDeliveryClient = class extends DeliveryClientBase {
1505
+ constructor(options) {
1506
+ super(options);
1551
1507
  }
1552
- /** Updates or creates a Canvas component definition */
1553
- async updateComponentDefinition(body) {
1554
- const fetchUri = this.createUrl("/api/v1/canvas-definitions");
1555
- await this.apiClient(fetchUri, {
1556
- method: "PUT",
1557
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1558
- expectNoContent: true
1559
- });
1508
+ /** Fetches exactly one composition (throws `ApiClientError(404)` if absent). */
1509
+ get(args) {
1510
+ var _a;
1511
+ const { diagnostics, select, ...rest } = args;
1512
+ const { readOptions, compositionId, versionId, pinnedEdition } = resolveCompositionSelector(rest);
1513
+ const url = this.createUrl(
1514
+ EDGE_SINGLE_URL,
1515
+ {
1516
+ ...readOptions,
1517
+ ...projectionToQuery(select),
1518
+ // A pinned edition is folded into compositionId (raw matches edition or
1519
+ // composition id); there is no editionId query param on this endpoint.
1520
+ compositionId,
1521
+ versionId,
1522
+ projectId: this.options.projectId,
1523
+ state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
1524
+ // editionId pins a specific edition for preview; otherwise locale-best.
1525
+ editions: pinnedEdition ? "raw" : "auto",
1526
+ diagnostics: this.coerceDiagnostics(diagnostics)
1527
+ },
1528
+ this.edgeApiHost
1529
+ );
1530
+ return this.apiClient(url, this.edgeRequestInit);
1560
1531
  }
1561
- /** Deletes a Canvas component definition */
1562
- async removeComponentDefinition(body) {
1563
- const fetchUri = this.createUrl("/api/v1/canvas-definitions");
1564
- await this.apiClient(fetchUri, {
1565
- method: "DELETE",
1566
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1567
- expectNoContent: true
1568
- });
1532
+ /** Fetches a list of compositions, optionally filtered. */
1533
+ list(args = {}) {
1534
+ var _a;
1535
+ const { diagnostics, filters, select, ...rest } = args;
1536
+ const url = this.createUrl(
1537
+ EDGE_LIST_URL,
1538
+ {
1539
+ ...rest,
1540
+ ...rewriteFiltersForApi(filters),
1541
+ ...projectionToQuery(select),
1542
+ projectId: this.options.projectId,
1543
+ state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
1544
+ diagnostics: this.coerceDiagnostics(diagnostics)
1545
+ },
1546
+ this.edgeApiHost
1547
+ );
1548
+ return this.apiClient(url, this.edgeRequestInit);
1569
1549
  }
1570
1550
  };
1571
1551
  var _contentTypesUrl;
@@ -1674,14 +1654,18 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1674
1654
  constructor(options) {
1675
1655
  super(options);
1676
1656
  }
1677
- /** Fetches all DataTypes for a project */
1678
- async get(options) {
1657
+ /** Fetches a list of DataTypes for a project */
1658
+ async list(options) {
1679
1659
  const { projectId } = this.options;
1680
1660
  const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8), { ...options, projectId });
1681
1661
  return await this.apiClient(fetchUri);
1682
1662
  }
1663
+ /** @deprecated Use {@link list} instead. */
1664
+ async get(options) {
1665
+ return this.list(options);
1666
+ }
1683
1667
  /** Updates or creates (based on id) a DataType */
1684
- async upsert(body) {
1668
+ async save(body) {
1685
1669
  const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
1686
1670
  await this.apiClient(fetchUri, {
1687
1671
  method: "PUT",
@@ -1689,6 +1673,10 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1689
1673
  expectNoContent: true
1690
1674
  });
1691
1675
  }
1676
+ /** @deprecated Use {@link save} instead. */
1677
+ async upsert(body) {
1678
+ return this.save(body);
1679
+ }
1692
1680
  /** Deletes a DataType */
1693
1681
  async remove(body) {
1694
1682
  const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
@@ -1726,22 +1714,6 @@ function getComponentPath(ancestorsAndSelf) {
1726
1714
  }
1727
1715
  return `.${path.join(".")}`;
1728
1716
  }
1729
- var CANVAS_PERSONALIZE_TYPE = "$personalization";
1730
- var CANVAS_TEST_TYPE = "$test";
1731
- var CANVAS_BLOCK_PARAM_TYPE = "$block";
1732
- var CANVAS_PERSONALIZE_SLOT = "pz";
1733
- var CANVAS_TEST_SLOT = "test";
1734
- var CANVAS_DRAFT_STATE = 0;
1735
- var CANVAS_PUBLISHED_STATE = 64;
1736
- var CANVAS_EDITOR_STATE = 63;
1737
- var CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
1738
- var CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
1739
- var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
1740
- var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
1741
- var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
1742
- var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
1743
- var IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM = "is_incontext_editing_forced_settings";
1744
- var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
1745
1717
  function isRootEntryReference(root) {
1746
1718
  return root.type === "root" && isEntryData(root.node);
1747
1719
  }
@@ -2343,20 +2315,28 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
2343
2315
  * When teamId is provided, returns a single team with its projects.
2344
2316
  * When omitted, returns all accessible teams and their projects.
2345
2317
  */
2346
- async getProjects(options) {
2318
+ async list(options) {
2347
2319
  const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
2348
2320
  return await this.apiClient(fetchUri);
2349
2321
  }
2322
+ /** @deprecated Use {@link list} instead. */
2323
+ async getProjects(options) {
2324
+ return this.list(options);
2325
+ }
2350
2326
  /** Updates or creates (based on id) a Project */
2351
- async upsert(body) {
2327
+ async save(body) {
2352
2328
  const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
2353
2329
  return await this.apiClient(fetchUri, {
2354
2330
  method: "PUT",
2355
2331
  body: JSON.stringify({ ...body })
2356
2332
  });
2357
2333
  }
2334
+ /** @deprecated Use {@link save} instead. */
2335
+ async upsert(body) {
2336
+ return this.save(body);
2337
+ }
2358
2338
  /** Deletes a Project */
2359
- async delete(body) {
2339
+ async remove(body) {
2360
2340
  const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
2361
2341
  await this.apiClient(fetchUri, {
2362
2342
  method: "DELETE",
@@ -2364,6 +2344,10 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
2364
2344
  expectNoContent: true
2365
2345
  });
2366
2346
  }
2347
+ /** @deprecated Use {@link remove} instead. */
2348
+ async delete(body) {
2349
+ return this.remove(body);
2350
+ }
2367
2351
  };
2368
2352
  _url22 = /* @__PURE__ */ new WeakMap();
2369
2353
  _projectsUrl = /* @__PURE__ */ new WeakMap();
@@ -2379,8 +2363,14 @@ var RouteClient = class extends ApiClient {
2379
2363
  super(options);
2380
2364
  this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
2381
2365
  }
2382
- /** Fetches lists of Canvas compositions, optionally by type */
2383
- async getRoute(options) {
2366
+ /**
2367
+ * Resolves a route to a composition, redirect, or not-found result.
2368
+ *
2369
+ * An optional `select` projection applies to the resolved composition when
2370
+ * the route matches one; redirect / notFound responses pass through
2371
+ * untouched.
2372
+ */
2373
+ async get(options) {
2384
2374
  const { projectId } = this.options;
2385
2375
  const { select, ...rest } = options != null ? options : {};
2386
2376
  const rewrittenSelect = projectionToQuery(select);
@@ -2390,6 +2380,10 @@ var RouteClient = class extends ApiClient {
2390
2380
  this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
2391
2381
  );
2392
2382
  }
2383
+ /** @deprecated use {@link RouteClient.get} instead (renamed). */
2384
+ async getRoute(options) {
2385
+ return this.get(options);
2386
+ }
2393
2387
  };
2394
2388
  var getDataSourceVariantFromRouteGetParams = (params, defaultPreviewState) => {
2395
2389
  var _a, _b;
@@ -2694,9 +2688,9 @@ function createLimitPolicy2({
2694
2688
  }
2695
2689
 
2696
2690
  // src/clients/canvas.ts
2697
- var getCanvasClient = (options) => {
2691
+ var buildCanvasClientOptions = (options) => {
2698
2692
  const cache = resolveCanvasCache(options);
2699
- return new CanvasClient({
2693
+ return {
2700
2694
  projectId: env.getProjectId(),
2701
2695
  apiHost: env.getApiHost(),
2702
2696
  apiKey: env.getApiKey(),
@@ -2744,7 +2738,10 @@ var getCanvasClient = (options) => {
2744
2738
  }
2745
2739
  });
2746
2740
  }
2747
- });
2741
+ };
2742
+ };
2743
+ var getCompositionDeliveryClient = (options) => {
2744
+ return new CompositionDeliveryClient(buildCanvasClientOptions(options));
2748
2745
  };
2749
2746
 
2750
2747
  // src/config/helpers.ts
@@ -2967,14 +2964,14 @@ var DefaultDataClient = class {
2967
2964
  if (oldCachedRoute) {
2968
2965
  waitUntil(
2969
2966
  (async () => {
2970
- const result2 = await routeClient.getRoute(route);
2967
+ const result2 = await routeClient.get(route);
2971
2968
  await cacheNewRoute(result2);
2972
2969
  })()
2973
2970
  );
2974
2971
  return oldCachedRoute;
2975
2972
  }
2976
2973
  }
2977
- const result = await routeClient.getRoute(route);
2974
+ const result = await routeClient.get(route);
2978
2975
  waitUntil(
2979
2976
  (async () => {
2980
2977
  await Promise.all([
@@ -5577,7 +5574,6 @@ var retrieveRouteByPath = async ({
5577
5574
  releaseId,
5578
5575
  locale
5579
5576
  }) => {
5580
- var _a;
5581
5577
  return await dataClient.getRoute({
5582
5578
  source: "middleware",
5583
5579
  searchParams,
@@ -5587,7 +5583,6 @@ var retrieveRouteByPath = async ({
5587
5583
  state,
5588
5584
  dataSourceVariant: getDataSourceVariantFromRouteGetParams({}, state),
5589
5585
  withComponentIDs: true,
5590
- withContentSourceMap: (_a = getServerConfig().experimental) == null ? void 0 : _a.vercelVisualEditing,
5591
5586
  releaseId,
5592
5587
  locale,
5593
5588
  ignoreRedirects: shouldIgnoreRedirects({ state })
@@ -5676,7 +5671,7 @@ var handlePlaygroundRequest = async ({
5676
5671
  { status: 400 }
5677
5672
  );
5678
5673
  }
5679
- const canvasClient = getCanvasClient({
5674
+ const canvasClient = getCompositionDeliveryClient({
5680
5675
  cache: {
5681
5676
  type: "no-cache"
5682
5677
  }
@@ -5686,7 +5681,7 @@ var handlePlaygroundRequest = async ({
5686
5681
  for (let i = 0; i < possibleStates.length; i++) {
5687
5682
  const state = possibleStates[i];
5688
5683
  try {
5689
- composition = await canvasClient.getCompositionById({
5684
+ composition = await canvasClient.get({
5690
5685
  compositionId: id,
5691
5686
  state,
5692
5687
  withComponentIDs: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/next-app-router",
3
- "version": "20.74.6-alpha.3+ac26410bba",
3
+ "version": "20.74.6-alpha.5+aaa8f352b2",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "scripts": {
6
6
  "build": "tsup",
@@ -100,12 +100,12 @@
100
100
  "vitest": "4.1.9"
101
101
  },
102
102
  "dependencies": {
103
- "@uniformdev/canvas-react": "20.74.6-alpha.3+ac26410bba",
104
- "@uniformdev/next-app-router-client": "20.74.6-alpha.3+ac26410bba",
105
- "@uniformdev/next-app-router-shared": "20.74.6-alpha.3+ac26410bba",
106
- "@uniformdev/redirect": "20.74.6-alpha.3+ac26410bba",
107
- "@uniformdev/richtext": "20.74.6-alpha.3+ac26410bba",
108
- "@uniformdev/webhooks": "20.74.6-alpha.3+ac26410bba",
103
+ "@uniformdev/canvas-react": "20.74.6-alpha.5+aaa8f352b2",
104
+ "@uniformdev/next-app-router-client": "20.74.6-alpha.5+aaa8f352b2",
105
+ "@uniformdev/next-app-router-shared": "20.74.6-alpha.5+aaa8f352b2",
106
+ "@uniformdev/redirect": "20.74.6-alpha.5+aaa8f352b2",
107
+ "@uniformdev/richtext": "20.74.6-alpha.5+aaa8f352b2",
108
+ "@uniformdev/webhooks": "20.74.6-alpha.5+aaa8f352b2",
109
109
  "@vercel/functions": "^3.7.2",
110
110
  "encoding": "^0.1.13",
111
111
  "server-only": "^0.0.1",
@@ -122,5 +122,5 @@
122
122
  "publishConfig": {
123
123
  "access": "public"
124
124
  },
125
- "gitHead": "ac26410bba86c828620eb1876847bbaffd639036"
125
+ "gitHead": "aaa8f352b2378d4ef9f062e364ebf7336145d95d"
126
126
  }