@uniformdev/next-app-router 20.7.1-alpha.136 → 20.48.1-alpha.11

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 CHANGED
@@ -330,11 +330,25 @@ async function handleRateLimits(callApi) {
330
330
  }
331
331
  const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
332
332
  const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
333
- await new Promise((resolve) => setTimeout(resolve, resetWait + backoffWait));
333
+ await new Promise((resolve) => setTimeout(resolve, Math.max(0, resetWait + backoffWait)));
334
334
  backoffRetriesLeft -= 1;
335
335
  }
336
336
  return response;
337
337
  }
338
+ var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
339
+ function rewriteFiltersForApi(filters) {
340
+ return Object.entries(filters != null ? filters : {}).reduce(
341
+ (acc, [key, value]) => {
342
+ const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
343
+ const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
344
+ return {
345
+ ...acc,
346
+ [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
347
+ };
348
+ },
349
+ {}
350
+ );
351
+ }
338
352
  var _url;
339
353
  var _AggregateClient = class _AggregateClient2 extends ApiClient {
340
354
  constructor(options) {
@@ -1118,20 +1132,6 @@ function createLimitPolicy({
1118
1132
  return currentFunc();
1119
1133
  };
1120
1134
  }
1121
- var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
1122
- function rewriteFilters(filters) {
1123
- return Object.entries(filters != null ? filters : {}).reduce(
1124
- (acc, [key, value]) => {
1125
- const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
1126
- const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
1127
- return {
1128
- ...acc,
1129
- [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
1130
- };
1131
- },
1132
- {}
1133
- );
1134
- }
1135
1135
  var _contentTypesUrl;
1136
1136
  var _entriesUrl;
1137
1137
  var _ContentClient = class _ContentClient2 extends ApiClient {
@@ -1148,7 +1148,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1148
1148
  getEntries(options) {
1149
1149
  const { projectId } = this.options;
1150
1150
  const { skipDataResolution, filters, ...params } = options;
1151
- const rewrittenFilters = rewriteFilters(filters);
1151
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1152
1152
  if (skipDataResolution) {
1153
1153
  const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
1154
1154
  return this.apiClient(url);
@@ -1309,6 +1309,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1309
1309
  _baseUrl = /* @__PURE__ */ new WeakMap();
1310
1310
  __privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
1311
1311
  var _url22;
1312
+ var _projectsUrl;
1312
1313
  var _ProjectClient = class _ProjectClient2 extends ApiClient {
1313
1314
  constructor(options) {
1314
1315
  super({ ...options, bypassCache: true });
@@ -1318,6 +1319,15 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1318
1319
  const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22), { ...options });
1319
1320
  return await this.apiClient(fetchUri);
1320
1321
  }
1322
+ /**
1323
+ * Fetches projects grouped by team.
1324
+ * When teamId is provided, returns a single team with its projects.
1325
+ * When omitted, returns all accessible teams and their projects.
1326
+ */
1327
+ async getProjects(options) {
1328
+ const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
1329
+ return await this.apiClient(fetchUri);
1330
+ }
1321
1331
  /** Updates or creates (based on id) a Project */
1322
1332
  async upsert(body) {
1323
1333
  const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
@@ -1337,7 +1347,9 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1337
1347
  }
1338
1348
  };
1339
1349
  _url22 = /* @__PURE__ */ new WeakMap();
1350
+ _projectsUrl = /* @__PURE__ */ new WeakMap();
1340
1351
  __privateAdd2(_ProjectClient, _url22, "/api/v1/project");
1352
+ __privateAdd2(_ProjectClient, _projectsUrl, "/api/v1/projects");
1341
1353
  var ROUTE_URL = "/api/v1/route";
1342
1354
  var RouteClient = class extends ApiClient {
1343
1355
  constructor(options) {
@@ -1400,8 +1412,15 @@ var isIncontextEditingEnabled = ({
1400
1412
  var isDevelopmentEnvironment = () => {
1401
1413
  return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
1402
1414
  };
1415
+ var shouldIgnoreRedirects = ({ state }) => {
1416
+ const isNotPublished = state !== CANVAS_PUBLISHED_STATE;
1417
+ return isNotPublished ? true : void 0;
1418
+ };
1403
1419
 
1404
1420
  // src/clients/cache.ts
1421
+ var isSpecificCacheMode = (options) => {
1422
+ return "cache" in options;
1423
+ };
1405
1424
  var isStateCacheMode = (options) => {
1406
1425
  return "state" in options;
1407
1426
  };
@@ -1423,7 +1442,9 @@ var resolveCache = ({
1423
1442
  }) => {
1424
1443
  let cache = void 0;
1425
1444
  if (options) {
1426
- if (isStateCacheMode(options)) {
1445
+ if (isSpecificCacheMode(options)) {
1446
+ cache = options.cache;
1447
+ } else if (isStateCacheMode(options)) {
1427
1448
  if (options.state === CANVAS_DRAFT_STATE || options.state === CANVAS_EDITOR_STATE) {
1428
1449
  cache = {
1429
1450
  type: "no-cache",
@@ -1715,6 +1736,9 @@ var getRouteClient = (options) => {
1715
1736
  // src/config/helpers.ts
1716
1737
  var import_resolved = __toESM(require("@uniformdev/next-app-router/config/resolved"));
1717
1738
  var getMiddlewareRuntimeCache = () => {
1739
+ if (process.env.NODE_ENV === "development" && !process.env.RUNTIME_CACHE_ENDPOINT) {
1740
+ return false;
1741
+ }
1718
1742
  if (typeof import_resolved.default.middlewareRuntimeCache === "boolean") {
1719
1743
  return import_resolved.default.middlewareRuntimeCache;
1720
1744
  }
@@ -1740,7 +1764,10 @@ var DefaultDataClient = class {
1740
1764
  }
1741
1765
  }
1742
1766
  const manifest = await getManifest({
1743
- cache: {
1767
+ cache: isDevelopmentEnvironment() ? {
1768
+ type: "no-cache",
1769
+ bypassCache: true
1770
+ } : {
1744
1771
  type: "force-cache"
1745
1772
  }
1746
1773
  });
@@ -1843,12 +1870,13 @@ var DefaultDataClient = class {
1843
1870
  };
1844
1871
  }
1845
1872
  async getRoutePageState(options) {
1873
+ const shouldBypassCache = options.pageState.compositionState !== CANVAS_PUBLISHED_STATE || isDevelopmentEnvironment();
1846
1874
  const routeClient = getRouteClient({
1847
- cache: options.pageState.compositionState === CANVAS_PUBLISHED_STATE ? {
1848
- type: "force-cache"
1849
- } : {
1875
+ cache: shouldBypassCache ? {
1850
1876
  type: "no-cache",
1851
1877
  bypassCache: true
1878
+ } : {
1879
+ type: "force-cache"
1852
1880
  }
1853
1881
  });
1854
1882
  const originalRoute = {
@@ -1856,7 +1884,8 @@ var DefaultDataClient = class {
1856
1884
  state: options.pageState.compositionState,
1857
1885
  withComponentIDs: true,
1858
1886
  releaseId: options.pageState.releaseId,
1859
- locale: options.pageState.locale
1887
+ locale: options.pageState.locale,
1888
+ ignoreRedirects: shouldIgnoreRedirects({ state: options.pageState.compositionState })
1860
1889
  };
1861
1890
  const resolvedRoute = await this.getRouteFromApi({
1862
1891
  source: "pageState",
package/dist/cache.mjs CHANGED
@@ -317,11 +317,25 @@ async function handleRateLimits(callApi) {
317
317
  }
318
318
  const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
319
319
  const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
320
- await new Promise((resolve) => setTimeout(resolve, resetWait + backoffWait));
320
+ await new Promise((resolve) => setTimeout(resolve, Math.max(0, resetWait + backoffWait)));
321
321
  backoffRetriesLeft -= 1;
322
322
  }
323
323
  return response;
324
324
  }
325
+ var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
326
+ function rewriteFiltersForApi(filters) {
327
+ return Object.entries(filters != null ? filters : {}).reduce(
328
+ (acc, [key, value]) => {
329
+ const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
330
+ const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
331
+ return {
332
+ ...acc,
333
+ [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
334
+ };
335
+ },
336
+ {}
337
+ );
338
+ }
325
339
  var _url;
326
340
  var _AggregateClient = class _AggregateClient2 extends ApiClient {
327
341
  constructor(options) {
@@ -1105,20 +1119,6 @@ function createLimitPolicy({
1105
1119
  return currentFunc();
1106
1120
  };
1107
1121
  }
1108
- var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
1109
- function rewriteFilters(filters) {
1110
- return Object.entries(filters != null ? filters : {}).reduce(
1111
- (acc, [key, value]) => {
1112
- const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
1113
- const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
1114
- return {
1115
- ...acc,
1116
- [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
1117
- };
1118
- },
1119
- {}
1120
- );
1121
- }
1122
1122
  var _contentTypesUrl;
1123
1123
  var _entriesUrl;
1124
1124
  var _ContentClient = class _ContentClient2 extends ApiClient {
@@ -1135,7 +1135,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1135
1135
  getEntries(options) {
1136
1136
  const { projectId } = this.options;
1137
1137
  const { skipDataResolution, filters, ...params } = options;
1138
- const rewrittenFilters = rewriteFilters(filters);
1138
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1139
1139
  if (skipDataResolution) {
1140
1140
  const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
1141
1141
  return this.apiClient(url);
@@ -1296,6 +1296,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1296
1296
  _baseUrl = /* @__PURE__ */ new WeakMap();
1297
1297
  __privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
1298
1298
  var _url22;
1299
+ var _projectsUrl;
1299
1300
  var _ProjectClient = class _ProjectClient2 extends ApiClient {
1300
1301
  constructor(options) {
1301
1302
  super({ ...options, bypassCache: true });
@@ -1305,6 +1306,15 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1305
1306
  const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22), { ...options });
1306
1307
  return await this.apiClient(fetchUri);
1307
1308
  }
1309
+ /**
1310
+ * Fetches projects grouped by team.
1311
+ * When teamId is provided, returns a single team with its projects.
1312
+ * When omitted, returns all accessible teams and their projects.
1313
+ */
1314
+ async getProjects(options) {
1315
+ const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
1316
+ return await this.apiClient(fetchUri);
1317
+ }
1308
1318
  /** Updates or creates (based on id) a Project */
1309
1319
  async upsert(body) {
1310
1320
  const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
@@ -1324,7 +1334,9 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1324
1334
  }
1325
1335
  };
1326
1336
  _url22 = /* @__PURE__ */ new WeakMap();
1337
+ _projectsUrl = /* @__PURE__ */ new WeakMap();
1327
1338
  __privateAdd2(_ProjectClient, _url22, "/api/v1/project");
1339
+ __privateAdd2(_ProjectClient, _projectsUrl, "/api/v1/projects");
1328
1340
  var ROUTE_URL = "/api/v1/route";
1329
1341
  var RouteClient = class extends ApiClient {
1330
1342
  constructor(options) {
@@ -1387,8 +1399,15 @@ var isIncontextEditingEnabled = ({
1387
1399
  var isDevelopmentEnvironment = () => {
1388
1400
  return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
1389
1401
  };
1402
+ var shouldIgnoreRedirects = ({ state }) => {
1403
+ const isNotPublished = state !== CANVAS_PUBLISHED_STATE;
1404
+ return isNotPublished ? true : void 0;
1405
+ };
1390
1406
 
1391
1407
  // src/clients/cache.ts
1408
+ var isSpecificCacheMode = (options) => {
1409
+ return "cache" in options;
1410
+ };
1392
1411
  var isStateCacheMode = (options) => {
1393
1412
  return "state" in options;
1394
1413
  };
@@ -1410,7 +1429,9 @@ var resolveCache = ({
1410
1429
  }) => {
1411
1430
  let cache = void 0;
1412
1431
  if (options) {
1413
- if (isStateCacheMode(options)) {
1432
+ if (isSpecificCacheMode(options)) {
1433
+ cache = options.cache;
1434
+ } else if (isStateCacheMode(options)) {
1414
1435
  if (options.state === CANVAS_DRAFT_STATE || options.state === CANVAS_EDITOR_STATE) {
1415
1436
  cache = {
1416
1437
  type: "no-cache",
@@ -1702,6 +1723,9 @@ var getRouteClient = (options) => {
1702
1723
  // src/config/helpers.ts
1703
1724
  import config from "@uniformdev/next-app-router/config/resolved";
1704
1725
  var getMiddlewareRuntimeCache = () => {
1726
+ if (process.env.NODE_ENV === "development" && !process.env.RUNTIME_CACHE_ENDPOINT) {
1727
+ return false;
1728
+ }
1705
1729
  if (typeof config.middlewareRuntimeCache === "boolean") {
1706
1730
  return config.middlewareRuntimeCache;
1707
1731
  }
@@ -1727,7 +1751,10 @@ var DefaultDataClient = class {
1727
1751
  }
1728
1752
  }
1729
1753
  const manifest = await getManifest({
1730
- cache: {
1754
+ cache: isDevelopmentEnvironment() ? {
1755
+ type: "no-cache",
1756
+ bypassCache: true
1757
+ } : {
1731
1758
  type: "force-cache"
1732
1759
  }
1733
1760
  });
@@ -1830,12 +1857,13 @@ var DefaultDataClient = class {
1830
1857
  };
1831
1858
  }
1832
1859
  async getRoutePageState(options) {
1860
+ const shouldBypassCache = options.pageState.compositionState !== CANVAS_PUBLISHED_STATE || isDevelopmentEnvironment();
1833
1861
  const routeClient = getRouteClient({
1834
- cache: options.pageState.compositionState === CANVAS_PUBLISHED_STATE ? {
1835
- type: "force-cache"
1836
- } : {
1862
+ cache: shouldBypassCache ? {
1837
1863
  type: "no-cache",
1838
1864
  bypassCache: true
1865
+ } : {
1866
+ type: "force-cache"
1839
1867
  }
1840
1868
  });
1841
1869
  const originalRoute = {
@@ -1843,7 +1871,8 @@ var DefaultDataClient = class {
1843
1871
  state: options.pageState.compositionState,
1844
1872
  withComponentIDs: true,
1845
1873
  releaseId: options.pageState.releaseId,
1846
- locale: options.pageState.locale
1874
+ locale: options.pageState.locale,
1875
+ ignoreRedirects: shouldIgnoreRedirects({ state: options.pageState.compositionState })
1847
1876
  };
1848
1877
  const resolvedRoute = await this.getRouteFromApi({
1849
1878
  source: "pageState",
package/dist/component.js CHANGED
@@ -385,11 +385,25 @@ async function handleRateLimits(callApi) {
385
385
  }
386
386
  const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
387
387
  const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
388
- await new Promise((resolve) => setTimeout(resolve, resetWait + backoffWait));
388
+ await new Promise((resolve) => setTimeout(resolve, Math.max(0, resetWait + backoffWait)));
389
389
  backoffRetriesLeft -= 1;
390
390
  }
391
391
  return response;
392
392
  }
393
+ var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
394
+ function rewriteFiltersForApi(filters) {
395
+ return Object.entries(filters != null ? filters : {}).reduce(
396
+ (acc, [key, value]) => {
397
+ const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
398
+ const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
399
+ return {
400
+ ...acc,
401
+ [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
402
+ };
403
+ },
404
+ {}
405
+ );
406
+ }
393
407
  var _url;
394
408
  var _AggregateClient = class _AggregateClient2 extends ApiClient {
395
409
  constructor(options) {
@@ -982,20 +996,6 @@ var require_retry2 = __commonJS2({
982
996
  });
983
997
  var import_p_limit2 = __toESM2(require_p_limit2());
984
998
  var import_retry = __toESM2(require_retry2(), 1);
985
- var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
986
- function rewriteFilters(filters) {
987
- return Object.entries(filters != null ? filters : {}).reduce(
988
- (acc, [key, value]) => {
989
- const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
990
- const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
991
- return {
992
- ...acc,
993
- [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
994
- };
995
- },
996
- {}
997
- );
998
- }
999
999
  var _contentTypesUrl;
1000
1000
  var _entriesUrl;
1001
1001
  var _ContentClient = class _ContentClient2 extends ApiClient {
@@ -1012,7 +1012,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1012
1012
  getEntries(options) {
1013
1013
  const { projectId } = this.options;
1014
1014
  const { skipDataResolution, filters, ...params } = options;
1015
- const rewrittenFilters = rewriteFilters(filters);
1015
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1016
1016
  if (skipDataResolution) {
1017
1017
  const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
1018
1018
  return this.apiClient(url);
@@ -1169,6 +1169,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1169
1169
  _baseUrl = /* @__PURE__ */ new WeakMap();
1170
1170
  __privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
1171
1171
  var _url22;
1172
+ var _projectsUrl;
1172
1173
  var _ProjectClient = class _ProjectClient2 extends ApiClient {
1173
1174
  constructor(options) {
1174
1175
  super({ ...options, bypassCache: true });
@@ -1178,6 +1179,15 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1178
1179
  const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22), { ...options });
1179
1180
  return await this.apiClient(fetchUri);
1180
1181
  }
1182
+ /**
1183
+ * Fetches projects grouped by team.
1184
+ * When teamId is provided, returns a single team with its projects.
1185
+ * When omitted, returns all accessible teams and their projects.
1186
+ */
1187
+ async getProjects(options) {
1188
+ const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
1189
+ return await this.apiClient(fetchUri);
1190
+ }
1181
1191
  /** Updates or creates (based on id) a Project */
1182
1192
  async upsert(body) {
1183
1193
  const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
@@ -1197,7 +1207,9 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1197
1207
  }
1198
1208
  };
1199
1209
  _url22 = /* @__PURE__ */ new WeakMap();
1210
+ _projectsUrl = /* @__PURE__ */ new WeakMap();
1200
1211
  __privateAdd2(_ProjectClient, _url22, "/api/v1/project");
1212
+ __privateAdd2(_ProjectClient, _projectsUrl, "/api/v1/projects");
1201
1213
  var ATTRIBUTE_COMPONENT_ID = "data-uniform-component-id";
1202
1214
  var ATTRIBUTE_PARAMETER_ID = "data-uniform-parameter-id";
1203
1215
  var ATTRIBUTE_PARAMETER_TYPE = "data-uniform-parameter-type";
@@ -370,11 +370,25 @@ async function handleRateLimits(callApi) {
370
370
  }
371
371
  const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
372
372
  const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
373
- await new Promise((resolve) => setTimeout(resolve, resetWait + backoffWait));
373
+ await new Promise((resolve) => setTimeout(resolve, Math.max(0, resetWait + backoffWait)));
374
374
  backoffRetriesLeft -= 1;
375
375
  }
376
376
  return response;
377
377
  }
378
+ var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
379
+ function rewriteFiltersForApi(filters) {
380
+ return Object.entries(filters != null ? filters : {}).reduce(
381
+ (acc, [key, value]) => {
382
+ const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
383
+ const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
384
+ return {
385
+ ...acc,
386
+ [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
387
+ };
388
+ },
389
+ {}
390
+ );
391
+ }
378
392
  var _url;
379
393
  var _AggregateClient = class _AggregateClient2 extends ApiClient {
380
394
  constructor(options) {
@@ -967,20 +981,6 @@ var require_retry2 = __commonJS2({
967
981
  });
968
982
  var import_p_limit2 = __toESM2(require_p_limit2());
969
983
  var import_retry = __toESM2(require_retry2(), 1);
970
- var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
971
- function rewriteFilters(filters) {
972
- return Object.entries(filters != null ? filters : {}).reduce(
973
- (acc, [key, value]) => {
974
- const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
975
- const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
976
- return {
977
- ...acc,
978
- [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
979
- };
980
- },
981
- {}
982
- );
983
- }
984
984
  var _contentTypesUrl;
985
985
  var _entriesUrl;
986
986
  var _ContentClient = class _ContentClient2 extends ApiClient {
@@ -997,7 +997,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
997
997
  getEntries(options) {
998
998
  const { projectId } = this.options;
999
999
  const { skipDataResolution, filters, ...params } = options;
1000
- const rewrittenFilters = rewriteFilters(filters);
1000
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1001
1001
  if (skipDataResolution) {
1002
1002
  const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
1003
1003
  return this.apiClient(url);
@@ -1154,6 +1154,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1154
1154
  _baseUrl = /* @__PURE__ */ new WeakMap();
1155
1155
  __privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
1156
1156
  var _url22;
1157
+ var _projectsUrl;
1157
1158
  var _ProjectClient = class _ProjectClient2 extends ApiClient {
1158
1159
  constructor(options) {
1159
1160
  super({ ...options, bypassCache: true });
@@ -1163,6 +1164,15 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1163
1164
  const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22), { ...options });
1164
1165
  return await this.apiClient(fetchUri);
1165
1166
  }
1167
+ /**
1168
+ * Fetches projects grouped by team.
1169
+ * When teamId is provided, returns a single team with its projects.
1170
+ * When omitted, returns all accessible teams and their projects.
1171
+ */
1172
+ async getProjects(options) {
1173
+ const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
1174
+ return await this.apiClient(fetchUri);
1175
+ }
1166
1176
  /** Updates or creates (based on id) a Project */
1167
1177
  async upsert(body) {
1168
1178
  const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
@@ -1182,7 +1192,9 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1182
1192
  }
1183
1193
  };
1184
1194
  _url22 = /* @__PURE__ */ new WeakMap();
1195
+ _projectsUrl = /* @__PURE__ */ new WeakMap();
1185
1196
  __privateAdd2(_ProjectClient, _url22, "/api/v1/project");
1197
+ __privateAdd2(_ProjectClient, _projectsUrl, "/api/v1/projects");
1186
1198
  var ATTRIBUTE_COMPONENT_ID = "data-uniform-component-id";
1187
1199
  var ATTRIBUTE_PARAMETER_ID = "data-uniform-parameter-id";
1188
1200
  var ATTRIBUTE_PARAMETER_TYPE = "data-uniform-parameter-type";
package/dist/handler.js CHANGED
@@ -329,11 +329,25 @@ async function handleRateLimits(callApi) {
329
329
  }
330
330
  const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
331
331
  const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
332
- await new Promise((resolve) => setTimeout(resolve, resetWait + backoffWait));
332
+ await new Promise((resolve) => setTimeout(resolve, Math.max(0, resetWait + backoffWait)));
333
333
  backoffRetriesLeft -= 1;
334
334
  }
335
335
  return response;
336
336
  }
337
+ var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
338
+ function rewriteFiltersForApi(filters) {
339
+ return Object.entries(filters != null ? filters : {}).reduce(
340
+ (acc, [key, value]) => {
341
+ const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
342
+ const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
343
+ return {
344
+ ...acc,
345
+ [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
346
+ };
347
+ },
348
+ {}
349
+ );
350
+ }
337
351
  var _url;
338
352
  var _AggregateClient = class _AggregateClient2 extends ApiClient {
339
353
  constructor(options) {
@@ -1116,20 +1130,6 @@ function createLimitPolicy({
1116
1130
  return currentFunc();
1117
1131
  };
1118
1132
  }
1119
- var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
1120
- function rewriteFilters(filters) {
1121
- return Object.entries(filters != null ? filters : {}).reduce(
1122
- (acc, [key, value]) => {
1123
- const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
1124
- const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
1125
- return {
1126
- ...acc,
1127
- [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
1128
- };
1129
- },
1130
- {}
1131
- );
1132
- }
1133
1133
  var CANVAS_URL = "/api/v1/canvas";
1134
1134
  var CanvasClient = class extends ApiClient {
1135
1135
  constructor(options) {
@@ -1145,7 +1145,7 @@ var CanvasClient = class extends ApiClient {
1145
1145
  async getCompositionList(params = {}) {
1146
1146
  const { projectId } = this.options;
1147
1147
  const { resolveData, filters, ...originParams } = params;
1148
- const rewrittenFilters = rewriteFilters(filters);
1148
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1149
1149
  if (!resolveData) {
1150
1150
  const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
1151
1151
  return this.apiClient(fetchUri);
@@ -1265,7 +1265,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1265
1265
  getEntries(options) {
1266
1266
  const { projectId } = this.options;
1267
1267
  const { skipDataResolution, filters, ...params } = options;
1268
- const rewrittenFilters = rewriteFilters(filters);
1268
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1269
1269
  if (skipDataResolution) {
1270
1270
  const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
1271
1271
  return this.apiClient(url);
@@ -1415,13 +1415,19 @@ function parseVariableExpression(serialized, onToken) {
1415
1415
  bufferEndIndex = index + 1;
1416
1416
  continue;
1417
1417
  }
1418
- state = "variable";
1419
- if (bufferEndIndex > bufferStartIndex) {
1418
+ if (state === "variable") {
1419
+ const textStart = bufferStartIndex - variablePrefix.length;
1420
+ if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
1421
+ return tokenCount;
1422
+ }
1423
+ bufferStartIndex = bufferEndIndex;
1424
+ } else if (bufferEndIndex > bufferStartIndex) {
1420
1425
  if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
1421
1426
  return tokenCount;
1422
1427
  }
1423
1428
  bufferStartIndex = bufferEndIndex;
1424
1429
  }
1430
+ state = "variable";
1425
1431
  index += variablePrefix.length - 1;
1426
1432
  bufferStartIndex += variablePrefix.length;
1427
1433
  continue;
@@ -1443,11 +1449,11 @@ function parseVariableExpression(serialized, onToken) {
1443
1449
  }
1444
1450
  bufferEndIndex++;
1445
1451
  }
1446
- if (bufferEndIndex > bufferStartIndex) {
1447
- if (state === "variable") {
1448
- state = "text";
1449
- bufferStartIndex -= variablePrefix.length;
1450
- }
1452
+ if (state === "variable") {
1453
+ state = "text";
1454
+ bufferStartIndex -= variablePrefix.length;
1455
+ }
1456
+ if (bufferStartIndex < serialized.length) {
1451
1457
  handleToken(serialized.substring(bufferStartIndex), state);
1452
1458
  }
1453
1459
  return tokenCount;
@@ -1497,6 +1503,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1497
1503
  _baseUrl = /* @__PURE__ */ new WeakMap();
1498
1504
  __privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
1499
1505
  var _url22;
1506
+ var _projectsUrl;
1500
1507
  var _ProjectClient = class _ProjectClient2 extends ApiClient {
1501
1508
  constructor(options) {
1502
1509
  super({ ...options, bypassCache: true });
@@ -1506,6 +1513,15 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1506
1513
  const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22), { ...options });
1507
1514
  return await this.apiClient(fetchUri);
1508
1515
  }
1516
+ /**
1517
+ * Fetches projects grouped by team.
1518
+ * When teamId is provided, returns a single team with its projects.
1519
+ * When omitted, returns all accessible teams and their projects.
1520
+ */
1521
+ async getProjects(options) {
1522
+ const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
1523
+ return await this.apiClient(fetchUri);
1524
+ }
1509
1525
  /** Updates or creates (based on id) a Project */
1510
1526
  async upsert(body) {
1511
1527
  const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
@@ -1525,7 +1541,9 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1525
1541
  }
1526
1542
  };
1527
1543
  _url22 = /* @__PURE__ */ new WeakMap();
1544
+ _projectsUrl = /* @__PURE__ */ new WeakMap();
1528
1545
  __privateAdd2(_ProjectClient, _url22, "/api/v1/project");
1546
+ __privateAdd2(_ProjectClient, _projectsUrl, "/api/v1/projects");
1529
1547
  var isAllowedReferrer = (referrer) => {
1530
1548
  return Boolean(referrer == null ? void 0 : referrer.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|localhost:\d{4})\//));
1531
1549
  };
@@ -1538,6 +1556,9 @@ var import_server = require("next/server");
1538
1556
  // src/config/helpers.ts
1539
1557
  var import_resolved = __toESM(require("@uniformdev/next-app-router/config/resolved"));
1540
1558
  var getMiddlewareRuntimeCache = () => {
1559
+ if (process.env.NODE_ENV === "development" && !process.env.RUNTIME_CACHE_ENDPOINT) {
1560
+ return false;
1561
+ }
1541
1562
  if (typeof import_resolved.default.middlewareRuntimeCache === "boolean") {
1542
1563
  return import_resolved.default.middlewareRuntimeCache;
1543
1564
  }
@@ -1765,6 +1786,9 @@ var isDevelopmentEnvironment = () => {
1765
1786
  };
1766
1787
 
1767
1788
  // src/clients/cache.ts
1789
+ var isSpecificCacheMode = (options) => {
1790
+ return "cache" in options;
1791
+ };
1768
1792
  var isStateCacheMode = (options) => {
1769
1793
  return "state" in options;
1770
1794
  };
@@ -1786,7 +1810,9 @@ var resolveCache = ({
1786
1810
  }) => {
1787
1811
  let cache = void 0;
1788
1812
  if (options) {
1789
- if (isStateCacheMode(options)) {
1813
+ if (isSpecificCacheMode(options)) {
1814
+ cache = options.cache;
1815
+ } else if (isStateCacheMode(options)) {
1790
1816
  if (options.state === CANVAS_DRAFT_STATE || options.state === CANVAS_EDITOR_STATE) {
1791
1817
  cache = {
1792
1818
  type: "no-cache",