@uniformdev/next-app-router 20.50.2-alpha.1 → 20.50.2-alpha.39
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 +47 -21
- package/dist/cache.mjs +47 -21
- package/dist/component.js +27 -15
- package/dist/component.mjs +27 -15
- package/dist/handler.js +34 -17
- package/dist/handler.mjs +34 -17
- package/dist/index.esm.js +51 -24
- package/dist/index.js +51 -24
- package/dist/index.mjs +51 -24
- package/dist/middleware.js +68 -37
- package/dist/middleware.mjs +68 -37
- package/package.json +8 -8
package/dist/index.esm.js
CHANGED
|
@@ -325,6 +325,20 @@ async function handleRateLimits(callApi) {
|
|
|
325
325
|
}
|
|
326
326
|
return response;
|
|
327
327
|
}
|
|
328
|
+
var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
|
329
|
+
function rewriteFiltersForApi(filters) {
|
|
330
|
+
return Object.entries(filters != null ? filters : {}).reduce(
|
|
331
|
+
(acc, [key, value]) => {
|
|
332
|
+
const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
|
|
333
|
+
const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
|
|
334
|
+
return {
|
|
335
|
+
...acc,
|
|
336
|
+
[lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
|
|
337
|
+
};
|
|
338
|
+
},
|
|
339
|
+
{}
|
|
340
|
+
);
|
|
341
|
+
}
|
|
328
342
|
var _url;
|
|
329
343
|
var _AggregateClient = class _AggregateClient2 extends ApiClient {
|
|
330
344
|
constructor(options) {
|
|
@@ -1108,20 +1122,6 @@ function createLimitPolicy({
|
|
|
1108
1122
|
return currentFunc();
|
|
1109
1123
|
};
|
|
1110
1124
|
}
|
|
1111
|
-
var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
|
1112
|
-
function rewriteFilters(filters) {
|
|
1113
|
-
return Object.entries(filters != null ? filters : {}).reduce(
|
|
1114
|
-
(acc, [key, value]) => {
|
|
1115
|
-
const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
|
|
1116
|
-
const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
|
|
1117
|
-
return {
|
|
1118
|
-
...acc,
|
|
1119
|
-
[lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
|
|
1120
|
-
};
|
|
1121
|
-
},
|
|
1122
|
-
{}
|
|
1123
|
-
);
|
|
1124
|
-
}
|
|
1125
1125
|
var CANVAS_URL = "/api/v1/canvas";
|
|
1126
1126
|
var CanvasClient = class extends ApiClient {
|
|
1127
1127
|
constructor(options) {
|
|
@@ -1137,7 +1137,7 @@ var CanvasClient = class extends ApiClient {
|
|
|
1137
1137
|
async getCompositionList(params = {}) {
|
|
1138
1138
|
const { projectId } = this.options;
|
|
1139
1139
|
const { resolveData, filters, ...originParams } = params;
|
|
1140
|
-
const rewrittenFilters =
|
|
1140
|
+
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
1141
1141
|
if (!resolveData) {
|
|
1142
1142
|
const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
|
|
1143
1143
|
return this.apiClient(fetchUri);
|
|
@@ -1257,7 +1257,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
|
|
|
1257
1257
|
getEntries(options) {
|
|
1258
1258
|
const { projectId } = this.options;
|
|
1259
1259
|
const { skipDataResolution, filters, ...params } = options;
|
|
1260
|
-
const rewrittenFilters =
|
|
1260
|
+
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
1261
1261
|
if (skipDataResolution) {
|
|
1262
1262
|
const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
|
|
1263
1263
|
return this.apiClient(url);
|
|
@@ -1849,6 +1849,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
|
|
|
1849
1849
|
_baseUrl = /* @__PURE__ */ new WeakMap();
|
|
1850
1850
|
__privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
|
|
1851
1851
|
var _url22;
|
|
1852
|
+
var _projectsUrl;
|
|
1852
1853
|
var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
1853
1854
|
constructor(options) {
|
|
1854
1855
|
super({ ...options, bypassCache: true });
|
|
@@ -1858,6 +1859,15 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1858
1859
|
const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22), { ...options });
|
|
1859
1860
|
return await this.apiClient(fetchUri);
|
|
1860
1861
|
}
|
|
1862
|
+
/**
|
|
1863
|
+
* Fetches projects grouped by team.
|
|
1864
|
+
* When teamId is provided, returns a single team with its projects.
|
|
1865
|
+
* When omitted, returns all accessible teams and their projects.
|
|
1866
|
+
*/
|
|
1867
|
+
async getProjects(options) {
|
|
1868
|
+
const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
|
|
1869
|
+
return await this.apiClient(fetchUri);
|
|
1870
|
+
}
|
|
1861
1871
|
/** Updates or creates (based on id) a Project */
|
|
1862
1872
|
async upsert(body) {
|
|
1863
1873
|
const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
|
|
@@ -1877,7 +1887,9 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1877
1887
|
}
|
|
1878
1888
|
};
|
|
1879
1889
|
_url22 = /* @__PURE__ */ new WeakMap();
|
|
1890
|
+
_projectsUrl = /* @__PURE__ */ new WeakMap();
|
|
1880
1891
|
__privateAdd2(_ProjectClient, _url22, "/api/v1/project");
|
|
1892
|
+
__privateAdd2(_ProjectClient, _projectsUrl, "/api/v1/projects");
|
|
1881
1893
|
var ROUTE_URL = "/api/v1/route";
|
|
1882
1894
|
var RouteClient = class extends ApiClient {
|
|
1883
1895
|
constructor(options) {
|
|
@@ -1979,8 +1991,15 @@ var isIncontextEditingEnabled = ({
|
|
|
1979
1991
|
var isDevelopmentEnvironment = () => {
|
|
1980
1992
|
return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
|
|
1981
1993
|
};
|
|
1994
|
+
var shouldIgnoreRedirects = ({ state }) => {
|
|
1995
|
+
const isNotPublished = state !== CANVAS_PUBLISHED_STATE;
|
|
1996
|
+
return isNotPublished ? true : void 0;
|
|
1997
|
+
};
|
|
1982
1998
|
|
|
1983
1999
|
// src/clients/cache.ts
|
|
2000
|
+
var isSpecificCacheMode = (options) => {
|
|
2001
|
+
return "cache" in options;
|
|
2002
|
+
};
|
|
1984
2003
|
var isStateCacheMode = (options) => {
|
|
1985
2004
|
return "state" in options;
|
|
1986
2005
|
};
|
|
@@ -2007,7 +2026,9 @@ var resolveCache = ({
|
|
|
2007
2026
|
}) => {
|
|
2008
2027
|
let cache2 = void 0;
|
|
2009
2028
|
if (options) {
|
|
2010
|
-
if (
|
|
2029
|
+
if (isSpecificCacheMode(options)) {
|
|
2030
|
+
cache2 = options.cache;
|
|
2031
|
+
} else if (isStateCacheMode(options)) {
|
|
2011
2032
|
if (options.state === CANVAS_DRAFT_STATE || options.state === CANVAS_EDITOR_STATE) {
|
|
2012
2033
|
cache2 = {
|
|
2013
2034
|
type: "no-cache",
|
|
@@ -2763,7 +2784,7 @@ var createTestComponentProps = ({
|
|
|
2763
2784
|
const [testIndex] = (_a = component == null ? void 0 : component.indexes) != null ? _a : [];
|
|
2764
2785
|
return {
|
|
2765
2786
|
...common,
|
|
2766
|
-
index: testIndex
|
|
2787
|
+
index: testIndex,
|
|
2767
2788
|
test
|
|
2768
2789
|
};
|
|
2769
2790
|
};
|
|
@@ -3598,8 +3619,9 @@ var generatePossiblePageStates = ({
|
|
|
3598
3619
|
locale,
|
|
3599
3620
|
isPrefetch: void 0
|
|
3600
3621
|
};
|
|
3622
|
+
const allComponentIds = runnables.filter((r) => r.type === "test" || r.type === "personalization").map((r) => r._id);
|
|
3601
3623
|
const allStates = generateStatesRecursively(dependencyMap, void 0, initialState);
|
|
3602
|
-
return allStates.map((payload) => serializeEvaluationResult({ payload }));
|
|
3624
|
+
return allStates.map((payload) => serializeEvaluationResult({ payload, allComponentIds }));
|
|
3603
3625
|
};
|
|
3604
3626
|
function permutationsWithoutRepetition(options, k) {
|
|
3605
3627
|
if (k === 0) return [[]];
|
|
@@ -3648,7 +3670,10 @@ var DefaultDataClient = class {
|
|
|
3648
3670
|
}
|
|
3649
3671
|
}
|
|
3650
3672
|
const manifest = await getManifest({
|
|
3651
|
-
cache: {
|
|
3673
|
+
cache: isDevelopmentEnvironment() ? {
|
|
3674
|
+
type: "no-cache",
|
|
3675
|
+
bypassCache: true
|
|
3676
|
+
} : {
|
|
3652
3677
|
type: "force-cache"
|
|
3653
3678
|
}
|
|
3654
3679
|
});
|
|
@@ -3751,12 +3776,13 @@ var DefaultDataClient = class {
|
|
|
3751
3776
|
};
|
|
3752
3777
|
}
|
|
3753
3778
|
async getRoutePageState(options) {
|
|
3779
|
+
const shouldBypassCache = options.pageState.compositionState !== CANVAS_PUBLISHED_STATE || isDevelopmentEnvironment();
|
|
3754
3780
|
const routeClient = getRouteClient({
|
|
3755
|
-
cache:
|
|
3756
|
-
type: "force-cache"
|
|
3757
|
-
} : {
|
|
3781
|
+
cache: shouldBypassCache ? {
|
|
3758
3782
|
type: "no-cache",
|
|
3759
3783
|
bypassCache: true
|
|
3784
|
+
} : {
|
|
3785
|
+
type: "force-cache"
|
|
3760
3786
|
}
|
|
3761
3787
|
});
|
|
3762
3788
|
const originalRoute = {
|
|
@@ -3764,7 +3790,8 @@ var DefaultDataClient = class {
|
|
|
3764
3790
|
state: options.pageState.compositionState,
|
|
3765
3791
|
withComponentIDs: true,
|
|
3766
3792
|
releaseId: options.pageState.releaseId,
|
|
3767
|
-
locale: options.pageState.locale
|
|
3793
|
+
locale: options.pageState.locale,
|
|
3794
|
+
ignoreRedirects: shouldIgnoreRedirects({ state: options.pageState.compositionState })
|
|
3768
3795
|
};
|
|
3769
3796
|
const resolvedRoute = await this.getRouteFromApi({
|
|
3770
3797
|
source: "pageState",
|
package/dist/index.js
CHANGED
|
@@ -352,6 +352,20 @@ async function handleRateLimits(callApi) {
|
|
|
352
352
|
}
|
|
353
353
|
return response;
|
|
354
354
|
}
|
|
355
|
+
var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
|
356
|
+
function rewriteFiltersForApi(filters) {
|
|
357
|
+
return Object.entries(filters != null ? filters : {}).reduce(
|
|
358
|
+
(acc, [key, value]) => {
|
|
359
|
+
const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
|
|
360
|
+
const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
|
|
361
|
+
return {
|
|
362
|
+
...acc,
|
|
363
|
+
[lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
|
|
364
|
+
};
|
|
365
|
+
},
|
|
366
|
+
{}
|
|
367
|
+
);
|
|
368
|
+
}
|
|
355
369
|
var _url;
|
|
356
370
|
var _AggregateClient = class _AggregateClient2 extends ApiClient {
|
|
357
371
|
constructor(options) {
|
|
@@ -1135,20 +1149,6 @@ function createLimitPolicy({
|
|
|
1135
1149
|
return currentFunc();
|
|
1136
1150
|
};
|
|
1137
1151
|
}
|
|
1138
|
-
var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
|
1139
|
-
function rewriteFilters(filters) {
|
|
1140
|
-
return Object.entries(filters != null ? filters : {}).reduce(
|
|
1141
|
-
(acc, [key, value]) => {
|
|
1142
|
-
const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
|
|
1143
|
-
const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
|
|
1144
|
-
return {
|
|
1145
|
-
...acc,
|
|
1146
|
-
[lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
|
|
1147
|
-
};
|
|
1148
|
-
},
|
|
1149
|
-
{}
|
|
1150
|
-
);
|
|
1151
|
-
}
|
|
1152
1152
|
var CANVAS_URL = "/api/v1/canvas";
|
|
1153
1153
|
var CanvasClient = class extends ApiClient {
|
|
1154
1154
|
constructor(options) {
|
|
@@ -1164,7 +1164,7 @@ var CanvasClient = class extends ApiClient {
|
|
|
1164
1164
|
async getCompositionList(params = {}) {
|
|
1165
1165
|
const { projectId } = this.options;
|
|
1166
1166
|
const { resolveData, filters, ...originParams } = params;
|
|
1167
|
-
const rewrittenFilters =
|
|
1167
|
+
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
1168
1168
|
if (!resolveData) {
|
|
1169
1169
|
const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
|
|
1170
1170
|
return this.apiClient(fetchUri);
|
|
@@ -1284,7 +1284,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
|
|
|
1284
1284
|
getEntries(options) {
|
|
1285
1285
|
const { projectId } = this.options;
|
|
1286
1286
|
const { skipDataResolution, filters, ...params } = options;
|
|
1287
|
-
const rewrittenFilters =
|
|
1287
|
+
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
1288
1288
|
if (skipDataResolution) {
|
|
1289
1289
|
const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
|
|
1290
1290
|
return this.apiClient(url);
|
|
@@ -1876,6 +1876,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
|
|
|
1876
1876
|
_baseUrl = /* @__PURE__ */ new WeakMap();
|
|
1877
1877
|
__privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
|
|
1878
1878
|
var _url22;
|
|
1879
|
+
var _projectsUrl;
|
|
1879
1880
|
var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
1880
1881
|
constructor(options) {
|
|
1881
1882
|
super({ ...options, bypassCache: true });
|
|
@@ -1885,6 +1886,15 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1885
1886
|
const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22), { ...options });
|
|
1886
1887
|
return await this.apiClient(fetchUri);
|
|
1887
1888
|
}
|
|
1889
|
+
/**
|
|
1890
|
+
* Fetches projects grouped by team.
|
|
1891
|
+
* When teamId is provided, returns a single team with its projects.
|
|
1892
|
+
* When omitted, returns all accessible teams and their projects.
|
|
1893
|
+
*/
|
|
1894
|
+
async getProjects(options) {
|
|
1895
|
+
const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
|
|
1896
|
+
return await this.apiClient(fetchUri);
|
|
1897
|
+
}
|
|
1888
1898
|
/** Updates or creates (based on id) a Project */
|
|
1889
1899
|
async upsert(body) {
|
|
1890
1900
|
const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
|
|
@@ -1904,7 +1914,9 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1904
1914
|
}
|
|
1905
1915
|
};
|
|
1906
1916
|
_url22 = /* @__PURE__ */ new WeakMap();
|
|
1917
|
+
_projectsUrl = /* @__PURE__ */ new WeakMap();
|
|
1907
1918
|
__privateAdd2(_ProjectClient, _url22, "/api/v1/project");
|
|
1919
|
+
__privateAdd2(_ProjectClient, _projectsUrl, "/api/v1/projects");
|
|
1908
1920
|
var ROUTE_URL = "/api/v1/route";
|
|
1909
1921
|
var RouteClient = class extends ApiClient {
|
|
1910
1922
|
constructor(options) {
|
|
@@ -2006,8 +2018,15 @@ var isIncontextEditingEnabled = ({
|
|
|
2006
2018
|
var isDevelopmentEnvironment = () => {
|
|
2007
2019
|
return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
|
|
2008
2020
|
};
|
|
2021
|
+
var shouldIgnoreRedirects = ({ state }) => {
|
|
2022
|
+
const isNotPublished = state !== CANVAS_PUBLISHED_STATE;
|
|
2023
|
+
return isNotPublished ? true : void 0;
|
|
2024
|
+
};
|
|
2009
2025
|
|
|
2010
2026
|
// src/clients/cache.ts
|
|
2027
|
+
var isSpecificCacheMode = (options) => {
|
|
2028
|
+
return "cache" in options;
|
|
2029
|
+
};
|
|
2011
2030
|
var isStateCacheMode = (options) => {
|
|
2012
2031
|
return "state" in options;
|
|
2013
2032
|
};
|
|
@@ -2034,7 +2053,9 @@ var resolveCache = ({
|
|
|
2034
2053
|
}) => {
|
|
2035
2054
|
let cache2 = void 0;
|
|
2036
2055
|
if (options) {
|
|
2037
|
-
if (
|
|
2056
|
+
if (isSpecificCacheMode(options)) {
|
|
2057
|
+
cache2 = options.cache;
|
|
2058
|
+
} else if (isStateCacheMode(options)) {
|
|
2038
2059
|
if (options.state === CANVAS_DRAFT_STATE || options.state === CANVAS_EDITOR_STATE) {
|
|
2039
2060
|
cache2 = {
|
|
2040
2061
|
type: "no-cache",
|
|
@@ -2786,7 +2807,7 @@ var createTestComponentProps = ({
|
|
|
2786
2807
|
const [testIndex] = (_a = component == null ? void 0 : component.indexes) != null ? _a : [];
|
|
2787
2808
|
return {
|
|
2788
2809
|
...common,
|
|
2789
|
-
index: testIndex
|
|
2810
|
+
index: testIndex,
|
|
2790
2811
|
test
|
|
2791
2812
|
};
|
|
2792
2813
|
};
|
|
@@ -3619,8 +3640,9 @@ var generatePossiblePageStates = ({
|
|
|
3619
3640
|
locale,
|
|
3620
3641
|
isPrefetch: void 0
|
|
3621
3642
|
};
|
|
3643
|
+
const allComponentIds = runnables.filter((r) => r.type === "test" || r.type === "personalization").map((r) => r._id);
|
|
3622
3644
|
const allStates = generateStatesRecursively(dependencyMap, void 0, initialState);
|
|
3623
|
-
return allStates.map((payload) => (0, import_next_app_router_shared8.serializeEvaluationResult)({ payload }));
|
|
3645
|
+
return allStates.map((payload) => (0, import_next_app_router_shared8.serializeEvaluationResult)({ payload, allComponentIds }));
|
|
3624
3646
|
};
|
|
3625
3647
|
function permutationsWithoutRepetition(options, k) {
|
|
3626
3648
|
if (k === 0) return [[]];
|
|
@@ -3669,7 +3691,10 @@ var DefaultDataClient = class {
|
|
|
3669
3691
|
}
|
|
3670
3692
|
}
|
|
3671
3693
|
const manifest = await getManifest({
|
|
3672
|
-
cache: {
|
|
3694
|
+
cache: isDevelopmentEnvironment() ? {
|
|
3695
|
+
type: "no-cache",
|
|
3696
|
+
bypassCache: true
|
|
3697
|
+
} : {
|
|
3673
3698
|
type: "force-cache"
|
|
3674
3699
|
}
|
|
3675
3700
|
});
|
|
@@ -3772,12 +3797,13 @@ var DefaultDataClient = class {
|
|
|
3772
3797
|
};
|
|
3773
3798
|
}
|
|
3774
3799
|
async getRoutePageState(options) {
|
|
3800
|
+
const shouldBypassCache = options.pageState.compositionState !== CANVAS_PUBLISHED_STATE || isDevelopmentEnvironment();
|
|
3775
3801
|
const routeClient = getRouteClient({
|
|
3776
|
-
cache:
|
|
3777
|
-
type: "force-cache"
|
|
3778
|
-
} : {
|
|
3802
|
+
cache: shouldBypassCache ? {
|
|
3779
3803
|
type: "no-cache",
|
|
3780
3804
|
bypassCache: true
|
|
3805
|
+
} : {
|
|
3806
|
+
type: "force-cache"
|
|
3781
3807
|
}
|
|
3782
3808
|
});
|
|
3783
3809
|
const originalRoute = {
|
|
@@ -3785,7 +3811,8 @@ var DefaultDataClient = class {
|
|
|
3785
3811
|
state: options.pageState.compositionState,
|
|
3786
3812
|
withComponentIDs: true,
|
|
3787
3813
|
releaseId: options.pageState.releaseId,
|
|
3788
|
-
locale: options.pageState.locale
|
|
3814
|
+
locale: options.pageState.locale,
|
|
3815
|
+
ignoreRedirects: shouldIgnoreRedirects({ state: options.pageState.compositionState })
|
|
3789
3816
|
};
|
|
3790
3817
|
const resolvedRoute = await this.getRouteFromApi({
|
|
3791
3818
|
source: "pageState",
|
package/dist/index.mjs
CHANGED
|
@@ -325,6 +325,20 @@ async function handleRateLimits(callApi) {
|
|
|
325
325
|
}
|
|
326
326
|
return response;
|
|
327
327
|
}
|
|
328
|
+
var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
|
329
|
+
function rewriteFiltersForApi(filters) {
|
|
330
|
+
return Object.entries(filters != null ? filters : {}).reduce(
|
|
331
|
+
(acc, [key, value]) => {
|
|
332
|
+
const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
|
|
333
|
+
const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
|
|
334
|
+
return {
|
|
335
|
+
...acc,
|
|
336
|
+
[lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
|
|
337
|
+
};
|
|
338
|
+
},
|
|
339
|
+
{}
|
|
340
|
+
);
|
|
341
|
+
}
|
|
328
342
|
var _url;
|
|
329
343
|
var _AggregateClient = class _AggregateClient2 extends ApiClient {
|
|
330
344
|
constructor(options) {
|
|
@@ -1108,20 +1122,6 @@ function createLimitPolicy({
|
|
|
1108
1122
|
return currentFunc();
|
|
1109
1123
|
};
|
|
1110
1124
|
}
|
|
1111
|
-
var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
|
1112
|
-
function rewriteFilters(filters) {
|
|
1113
|
-
return Object.entries(filters != null ? filters : {}).reduce(
|
|
1114
|
-
(acc, [key, value]) => {
|
|
1115
|
-
const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
|
|
1116
|
-
const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
|
|
1117
|
-
return {
|
|
1118
|
-
...acc,
|
|
1119
|
-
[lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
|
|
1120
|
-
};
|
|
1121
|
-
},
|
|
1122
|
-
{}
|
|
1123
|
-
);
|
|
1124
|
-
}
|
|
1125
1125
|
var CANVAS_URL = "/api/v1/canvas";
|
|
1126
1126
|
var CanvasClient = class extends ApiClient {
|
|
1127
1127
|
constructor(options) {
|
|
@@ -1137,7 +1137,7 @@ var CanvasClient = class extends ApiClient {
|
|
|
1137
1137
|
async getCompositionList(params = {}) {
|
|
1138
1138
|
const { projectId } = this.options;
|
|
1139
1139
|
const { resolveData, filters, ...originParams } = params;
|
|
1140
|
-
const rewrittenFilters =
|
|
1140
|
+
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
1141
1141
|
if (!resolveData) {
|
|
1142
1142
|
const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
|
|
1143
1143
|
return this.apiClient(fetchUri);
|
|
@@ -1257,7 +1257,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
|
|
|
1257
1257
|
getEntries(options) {
|
|
1258
1258
|
const { projectId } = this.options;
|
|
1259
1259
|
const { skipDataResolution, filters, ...params } = options;
|
|
1260
|
-
const rewrittenFilters =
|
|
1260
|
+
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
1261
1261
|
if (skipDataResolution) {
|
|
1262
1262
|
const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
|
|
1263
1263
|
return this.apiClient(url);
|
|
@@ -1849,6 +1849,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
|
|
|
1849
1849
|
_baseUrl = /* @__PURE__ */ new WeakMap();
|
|
1850
1850
|
__privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
|
|
1851
1851
|
var _url22;
|
|
1852
|
+
var _projectsUrl;
|
|
1852
1853
|
var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
1853
1854
|
constructor(options) {
|
|
1854
1855
|
super({ ...options, bypassCache: true });
|
|
@@ -1858,6 +1859,15 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1858
1859
|
const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22), { ...options });
|
|
1859
1860
|
return await this.apiClient(fetchUri);
|
|
1860
1861
|
}
|
|
1862
|
+
/**
|
|
1863
|
+
* Fetches projects grouped by team.
|
|
1864
|
+
* When teamId is provided, returns a single team with its projects.
|
|
1865
|
+
* When omitted, returns all accessible teams and their projects.
|
|
1866
|
+
*/
|
|
1867
|
+
async getProjects(options) {
|
|
1868
|
+
const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
|
|
1869
|
+
return await this.apiClient(fetchUri);
|
|
1870
|
+
}
|
|
1861
1871
|
/** Updates or creates (based on id) a Project */
|
|
1862
1872
|
async upsert(body) {
|
|
1863
1873
|
const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
|
|
@@ -1877,7 +1887,9 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
1877
1887
|
}
|
|
1878
1888
|
};
|
|
1879
1889
|
_url22 = /* @__PURE__ */ new WeakMap();
|
|
1890
|
+
_projectsUrl = /* @__PURE__ */ new WeakMap();
|
|
1880
1891
|
__privateAdd2(_ProjectClient, _url22, "/api/v1/project");
|
|
1892
|
+
__privateAdd2(_ProjectClient, _projectsUrl, "/api/v1/projects");
|
|
1881
1893
|
var ROUTE_URL = "/api/v1/route";
|
|
1882
1894
|
var RouteClient = class extends ApiClient {
|
|
1883
1895
|
constructor(options) {
|
|
@@ -1979,8 +1991,15 @@ var isIncontextEditingEnabled = ({
|
|
|
1979
1991
|
var isDevelopmentEnvironment = () => {
|
|
1980
1992
|
return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
|
|
1981
1993
|
};
|
|
1994
|
+
var shouldIgnoreRedirects = ({ state }) => {
|
|
1995
|
+
const isNotPublished = state !== CANVAS_PUBLISHED_STATE;
|
|
1996
|
+
return isNotPublished ? true : void 0;
|
|
1997
|
+
};
|
|
1982
1998
|
|
|
1983
1999
|
// src/clients/cache.ts
|
|
2000
|
+
var isSpecificCacheMode = (options) => {
|
|
2001
|
+
return "cache" in options;
|
|
2002
|
+
};
|
|
1984
2003
|
var isStateCacheMode = (options) => {
|
|
1985
2004
|
return "state" in options;
|
|
1986
2005
|
};
|
|
@@ -2007,7 +2026,9 @@ var resolveCache = ({
|
|
|
2007
2026
|
}) => {
|
|
2008
2027
|
let cache2 = void 0;
|
|
2009
2028
|
if (options) {
|
|
2010
|
-
if (
|
|
2029
|
+
if (isSpecificCacheMode(options)) {
|
|
2030
|
+
cache2 = options.cache;
|
|
2031
|
+
} else if (isStateCacheMode(options)) {
|
|
2011
2032
|
if (options.state === CANVAS_DRAFT_STATE || options.state === CANVAS_EDITOR_STATE) {
|
|
2012
2033
|
cache2 = {
|
|
2013
2034
|
type: "no-cache",
|
|
@@ -2763,7 +2784,7 @@ var createTestComponentProps = ({
|
|
|
2763
2784
|
const [testIndex] = (_a = component == null ? void 0 : component.indexes) != null ? _a : [];
|
|
2764
2785
|
return {
|
|
2765
2786
|
...common,
|
|
2766
|
-
index: testIndex
|
|
2787
|
+
index: testIndex,
|
|
2767
2788
|
test
|
|
2768
2789
|
};
|
|
2769
2790
|
};
|
|
@@ -3598,8 +3619,9 @@ var generatePossiblePageStates = ({
|
|
|
3598
3619
|
locale,
|
|
3599
3620
|
isPrefetch: void 0
|
|
3600
3621
|
};
|
|
3622
|
+
const allComponentIds = runnables.filter((r) => r.type === "test" || r.type === "personalization").map((r) => r._id);
|
|
3601
3623
|
const allStates = generateStatesRecursively(dependencyMap, void 0, initialState);
|
|
3602
|
-
return allStates.map((payload) => serializeEvaluationResult({ payload }));
|
|
3624
|
+
return allStates.map((payload) => serializeEvaluationResult({ payload, allComponentIds }));
|
|
3603
3625
|
};
|
|
3604
3626
|
function permutationsWithoutRepetition(options, k) {
|
|
3605
3627
|
if (k === 0) return [[]];
|
|
@@ -3648,7 +3670,10 @@ var DefaultDataClient = class {
|
|
|
3648
3670
|
}
|
|
3649
3671
|
}
|
|
3650
3672
|
const manifest = await getManifest({
|
|
3651
|
-
cache: {
|
|
3673
|
+
cache: isDevelopmentEnvironment() ? {
|
|
3674
|
+
type: "no-cache",
|
|
3675
|
+
bypassCache: true
|
|
3676
|
+
} : {
|
|
3652
3677
|
type: "force-cache"
|
|
3653
3678
|
}
|
|
3654
3679
|
});
|
|
@@ -3751,12 +3776,13 @@ var DefaultDataClient = class {
|
|
|
3751
3776
|
};
|
|
3752
3777
|
}
|
|
3753
3778
|
async getRoutePageState(options) {
|
|
3779
|
+
const shouldBypassCache = options.pageState.compositionState !== CANVAS_PUBLISHED_STATE || isDevelopmentEnvironment();
|
|
3754
3780
|
const routeClient = getRouteClient({
|
|
3755
|
-
cache:
|
|
3756
|
-
type: "force-cache"
|
|
3757
|
-
} : {
|
|
3781
|
+
cache: shouldBypassCache ? {
|
|
3758
3782
|
type: "no-cache",
|
|
3759
3783
|
bypassCache: true
|
|
3784
|
+
} : {
|
|
3785
|
+
type: "force-cache"
|
|
3760
3786
|
}
|
|
3761
3787
|
});
|
|
3762
3788
|
const originalRoute = {
|
|
@@ -3764,7 +3790,8 @@ var DefaultDataClient = class {
|
|
|
3764
3790
|
state: options.pageState.compositionState,
|
|
3765
3791
|
withComponentIDs: true,
|
|
3766
3792
|
releaseId: options.pageState.releaseId,
|
|
3767
|
-
locale: options.pageState.locale
|
|
3793
|
+
locale: options.pageState.locale,
|
|
3794
|
+
ignoreRedirects: shouldIgnoreRedirects({ state: options.pageState.compositionState })
|
|
3768
3795
|
};
|
|
3769
3796
|
const resolvedRoute = await this.getRouteFromApi({
|
|
3770
3797
|
source: "pageState",
|