@uniformdev/next-app-router 20.50.2-alpha.2 → 20.50.2-alpha.77
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 -38
- package/dist/middleware.mjs +68 -38
- package/package.json +9 -9
package/dist/middleware.js
CHANGED
|
@@ -530,6 +530,20 @@ async function handleRateLimits(callApi) {
|
|
|
530
530
|
}
|
|
531
531
|
return response;
|
|
532
532
|
}
|
|
533
|
+
var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
|
534
|
+
function rewriteFiltersForApi(filters) {
|
|
535
|
+
return Object.entries(filters != null ? filters : {}).reduce(
|
|
536
|
+
(acc, [key, value]) => {
|
|
537
|
+
const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
|
|
538
|
+
const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
|
|
539
|
+
return {
|
|
540
|
+
...acc,
|
|
541
|
+
[lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
|
|
542
|
+
};
|
|
543
|
+
},
|
|
544
|
+
{}
|
|
545
|
+
);
|
|
546
|
+
}
|
|
533
547
|
var _url;
|
|
534
548
|
var _AggregateClient = class _AggregateClient2 extends ApiClient {
|
|
535
549
|
constructor(options) {
|
|
@@ -1313,20 +1327,6 @@ function createLimitPolicy({
|
|
|
1313
1327
|
return currentFunc();
|
|
1314
1328
|
};
|
|
1315
1329
|
}
|
|
1316
|
-
var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
|
1317
|
-
function rewriteFilters(filters) {
|
|
1318
|
-
return Object.entries(filters != null ? filters : {}).reduce(
|
|
1319
|
-
(acc, [key, value]) => {
|
|
1320
|
-
const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
|
|
1321
|
-
const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
|
|
1322
|
-
return {
|
|
1323
|
-
...acc,
|
|
1324
|
-
[lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
|
|
1325
|
-
};
|
|
1326
|
-
},
|
|
1327
|
-
{}
|
|
1328
|
-
);
|
|
1329
|
-
}
|
|
1330
1330
|
var CANVAS_URL = "/api/v1/canvas";
|
|
1331
1331
|
var CanvasClient = class extends ApiClient {
|
|
1332
1332
|
constructor(options) {
|
|
@@ -1342,7 +1342,7 @@ var CanvasClient = class extends ApiClient {
|
|
|
1342
1342
|
async getCompositionList(params = {}) {
|
|
1343
1343
|
const { projectId } = this.options;
|
|
1344
1344
|
const { resolveData, filters, ...originParams } = params;
|
|
1345
|
-
const rewrittenFilters =
|
|
1345
|
+
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
1346
1346
|
if (!resolveData) {
|
|
1347
1347
|
const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
|
|
1348
1348
|
return this.apiClient(fetchUri);
|
|
@@ -1462,7 +1462,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
|
|
|
1462
1462
|
getEntries(options) {
|
|
1463
1463
|
const { projectId } = this.options;
|
|
1464
1464
|
const { skipDataResolution, filters, ...params } = options;
|
|
1465
|
-
const rewrittenFilters =
|
|
1465
|
+
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
1466
1466
|
if (skipDataResolution) {
|
|
1467
1467
|
const url = this.createUrl(__privateGet3(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
|
|
1468
1468
|
return this.apiClient(url);
|
|
@@ -2197,6 +2197,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
|
|
|
2197
2197
|
_baseUrl = /* @__PURE__ */ new WeakMap();
|
|
2198
2198
|
__privateAdd3(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
|
|
2199
2199
|
var _url22;
|
|
2200
|
+
var _projectsUrl;
|
|
2200
2201
|
var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
2201
2202
|
constructor(options) {
|
|
2202
2203
|
super({ ...options, bypassCache: true });
|
|
@@ -2206,6 +2207,15 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
2206
2207
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22), { ...options });
|
|
2207
2208
|
return await this.apiClient(fetchUri);
|
|
2208
2209
|
}
|
|
2210
|
+
/**
|
|
2211
|
+
* Fetches projects grouped by team.
|
|
2212
|
+
* When teamId is provided, returns a single team with its projects.
|
|
2213
|
+
* When omitted, returns all accessible teams and their projects.
|
|
2214
|
+
*/
|
|
2215
|
+
async getProjects(options) {
|
|
2216
|
+
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
|
|
2217
|
+
return await this.apiClient(fetchUri);
|
|
2218
|
+
}
|
|
2209
2219
|
/** Updates or creates (based on id) a Project */
|
|
2210
2220
|
async upsert(body) {
|
|
2211
2221
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
|
|
@@ -2225,7 +2235,9 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
2225
2235
|
}
|
|
2226
2236
|
};
|
|
2227
2237
|
_url22 = /* @__PURE__ */ new WeakMap();
|
|
2238
|
+
_projectsUrl = /* @__PURE__ */ new WeakMap();
|
|
2228
2239
|
__privateAdd3(_ProjectClient, _url22, "/api/v1/project");
|
|
2240
|
+
__privateAdd3(_ProjectClient, _projectsUrl, "/api/v1/projects");
|
|
2229
2241
|
var ROUTE_URL = "/api/v1/route";
|
|
2230
2242
|
var RouteClient = class extends ApiClient {
|
|
2231
2243
|
constructor(options) {
|
|
@@ -2339,8 +2351,15 @@ var isIncontextEditingEnabled = ({
|
|
|
2339
2351
|
var isDevelopmentEnvironment = () => {
|
|
2340
2352
|
return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
|
|
2341
2353
|
};
|
|
2354
|
+
var shouldIgnoreRedirects = ({ state }) => {
|
|
2355
|
+
const isNotPublished = state !== CANVAS_PUBLISHED_STATE;
|
|
2356
|
+
return isNotPublished ? true : void 0;
|
|
2357
|
+
};
|
|
2342
2358
|
|
|
2343
2359
|
// src/clients/cache.ts
|
|
2360
|
+
var isSpecificCacheMode = (options) => {
|
|
2361
|
+
return "cache" in options;
|
|
2362
|
+
};
|
|
2344
2363
|
var isStateCacheMode = (options) => {
|
|
2345
2364
|
return "state" in options;
|
|
2346
2365
|
};
|
|
@@ -2362,7 +2381,9 @@ var resolveCache = ({
|
|
|
2362
2381
|
}) => {
|
|
2363
2382
|
let cache = void 0;
|
|
2364
2383
|
if (options) {
|
|
2365
|
-
if (
|
|
2384
|
+
if (isSpecificCacheMode(options)) {
|
|
2385
|
+
cache = options.cache;
|
|
2386
|
+
} else if (isStateCacheMode(options)) {
|
|
2366
2387
|
if (options.state === CANVAS_DRAFT_STATE || options.state === CANVAS_EDITOR_STATE) {
|
|
2367
2388
|
cache = {
|
|
2368
2389
|
type: "no-cache",
|
|
@@ -2757,7 +2778,10 @@ var DefaultDataClient = class {
|
|
|
2757
2778
|
}
|
|
2758
2779
|
}
|
|
2759
2780
|
const manifest = await getManifest({
|
|
2760
|
-
cache: {
|
|
2781
|
+
cache: isDevelopmentEnvironment() ? {
|
|
2782
|
+
type: "no-cache",
|
|
2783
|
+
bypassCache: true
|
|
2784
|
+
} : {
|
|
2761
2785
|
type: "force-cache"
|
|
2762
2786
|
}
|
|
2763
2787
|
});
|
|
@@ -2860,12 +2884,13 @@ var DefaultDataClient = class {
|
|
|
2860
2884
|
};
|
|
2861
2885
|
}
|
|
2862
2886
|
async getRoutePageState(options) {
|
|
2887
|
+
const shouldBypassCache = options.pageState.compositionState !== CANVAS_PUBLISHED_STATE || isDevelopmentEnvironment();
|
|
2863
2888
|
const routeClient = getRouteClient({
|
|
2864
|
-
cache:
|
|
2865
|
-
type: "force-cache"
|
|
2866
|
-
} : {
|
|
2889
|
+
cache: shouldBypassCache ? {
|
|
2867
2890
|
type: "no-cache",
|
|
2868
2891
|
bypassCache: true
|
|
2892
|
+
} : {
|
|
2893
|
+
type: "force-cache"
|
|
2869
2894
|
}
|
|
2870
2895
|
});
|
|
2871
2896
|
const originalRoute = {
|
|
@@ -2873,7 +2898,8 @@ var DefaultDataClient = class {
|
|
|
2873
2898
|
state: options.pageState.compositionState,
|
|
2874
2899
|
withComponentIDs: true,
|
|
2875
2900
|
releaseId: options.pageState.releaseId,
|
|
2876
|
-
locale: options.pageState.locale
|
|
2901
|
+
locale: options.pageState.locale,
|
|
2902
|
+
ignoreRedirects: shouldIgnoreRedirects({ state: options.pageState.compositionState })
|
|
2877
2903
|
};
|
|
2878
2904
|
const resolvedRoute = await this.getRouteFromApi({
|
|
2879
2905
|
source: "pageState",
|
|
@@ -3391,7 +3417,6 @@ var ManifestInstance = class {
|
|
|
3391
3417
|
constructor({
|
|
3392
3418
|
manifest,
|
|
3393
3419
|
evaluator = new GroupCriteriaEvaluator({}),
|
|
3394
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3395
3420
|
onLogMessage = () => {
|
|
3396
3421
|
}
|
|
3397
3422
|
}) {
|
|
@@ -5422,7 +5447,8 @@ var retrieveRouteByPath = async ({
|
|
|
5422
5447
|
withComponentIDs: true,
|
|
5423
5448
|
withContentSourceMap: (_a = getServerConfig().experimental) == null ? void 0 : _a.vercelVisualEditing,
|
|
5424
5449
|
releaseId,
|
|
5425
|
-
locale
|
|
5450
|
+
locale,
|
|
5451
|
+
ignoreRedirects: shouldIgnoreRedirects({ state })
|
|
5426
5452
|
}
|
|
5427
5453
|
});
|
|
5428
5454
|
};
|
|
@@ -5549,7 +5575,7 @@ var handlePlaygroundRequest = async ({
|
|
|
5549
5575
|
})
|
|
5550
5576
|
});
|
|
5551
5577
|
const context = await onDemandContext.getContext();
|
|
5552
|
-
const { components, rules } = await extractAndEvaluateRunnables({
|
|
5578
|
+
const { components, rules, allComponentIds } = await extractAndEvaluateRunnables({
|
|
5553
5579
|
composition: composition.composition,
|
|
5554
5580
|
routePath: id,
|
|
5555
5581
|
state: composition.state,
|
|
@@ -5589,7 +5615,8 @@ var handlePlaygroundRequest = async ({
|
|
|
5589
5615
|
isPrefetch: void 0
|
|
5590
5616
|
};
|
|
5591
5617
|
const code = (0, import_next_app_router_shared5.serializeEvaluationResult)({
|
|
5592
|
-
payload: pageState
|
|
5618
|
+
payload: pageState,
|
|
5619
|
+
allComponentIds
|
|
5593
5620
|
});
|
|
5594
5621
|
let pathToRewriteTo = await (options.rewriteDestinationPath ? options.rewriteDestinationPath({ code, pageState, source: "playground" }) : void 0);
|
|
5595
5622
|
if (!pathToRewriteTo) {
|
|
@@ -5603,15 +5630,16 @@ var handleRouteRequest = async ({
|
|
|
5603
5630
|
dataClient,
|
|
5604
5631
|
options
|
|
5605
5632
|
}) => {
|
|
5606
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
5633
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
5634
|
+
const releaseId = (_b = (_a = options.release) == null ? void 0 : _a.id) != null ? _b : draftModeEnabled ? request.nextUrl.searchParams.get("releaseId") || void 0 : void 0;
|
|
5607
5635
|
const states = await determineState({
|
|
5608
5636
|
searchParams: request.nextUrl.searchParams,
|
|
5609
5637
|
draftModeEnabled
|
|
5610
5638
|
});
|
|
5611
|
-
const requestPath = (
|
|
5639
|
+
const requestPath = (_d = await ((_c = options.rewriteRequestPath) == null ? void 0 : _c.call(options, {
|
|
5612
5640
|
request,
|
|
5613
5641
|
url: new URL(request.url)
|
|
5614
|
-
}))) != null ?
|
|
5642
|
+
}))) != null ? _d : {
|
|
5615
5643
|
path: `${request.nextUrl.pathname}${request.nextUrl.search}`
|
|
5616
5644
|
};
|
|
5617
5645
|
const serverConfig = getServerConfig();
|
|
@@ -5622,7 +5650,7 @@ var handleRouteRequest = async ({
|
|
|
5622
5650
|
searchParams: request.nextUrl.searchParams,
|
|
5623
5651
|
draftModeEnabled,
|
|
5624
5652
|
dataClient,
|
|
5625
|
-
releaseId
|
|
5653
|
+
releaseId,
|
|
5626
5654
|
locale: options.locale
|
|
5627
5655
|
}),
|
|
5628
5656
|
createOnDemandContext({
|
|
@@ -5634,10 +5662,10 @@ var handleRouteRequest = async ({
|
|
|
5634
5662
|
})
|
|
5635
5663
|
})
|
|
5636
5664
|
]);
|
|
5637
|
-
if (!(routeResult == null ? void 0 : routeResult.route) || ((
|
|
5665
|
+
if (!(routeResult == null ? void 0 : routeResult.route) || ((_e = routeResult == null ? void 0 : routeResult.route) == null ? void 0 : _e.type) === "notFound") {
|
|
5638
5666
|
return import_server.NextResponse.rewrite(new URL("/404", request.url));
|
|
5639
5667
|
}
|
|
5640
|
-
if (((
|
|
5668
|
+
if (((_f = routeResult == null ? void 0 : routeResult.route) == null ? void 0 : _f.type) === "redirect") {
|
|
5641
5669
|
return handleRedirect({ request, route: routeResult.route });
|
|
5642
5670
|
}
|
|
5643
5671
|
const { route } = routeResult;
|
|
@@ -5671,14 +5699,14 @@ var handleRouteRequest = async ({
|
|
|
5671
5699
|
isDraftModeEnabled: draftModeEnabled
|
|
5672
5700
|
});
|
|
5673
5701
|
const isPrefetch = isPrefetchRequest(request);
|
|
5674
|
-
const { components, rules } = await extractAndEvaluateRunnables({
|
|
5702
|
+
const { components, rules, allComponentIds } = await extractAndEvaluateRunnables({
|
|
5675
5703
|
composition: route.compositionApiResponse.composition,
|
|
5676
5704
|
routePath,
|
|
5677
5705
|
state,
|
|
5678
5706
|
context,
|
|
5679
5707
|
matchedRoute: route.matchedRoute,
|
|
5680
|
-
dynamicInputs: (
|
|
5681
|
-
releaseId
|
|
5708
|
+
dynamicInputs: (_g = route.dynamicInputs) != null ? _g : {},
|
|
5709
|
+
releaseId,
|
|
5682
5710
|
defaultConsent: determineDefaultConsent({
|
|
5683
5711
|
serverConfig,
|
|
5684
5712
|
defaultConsent: options.defaultConsent
|
|
@@ -5696,7 +5724,7 @@ var handleRouteRequest = async ({
|
|
|
5696
5724
|
compositionState: state,
|
|
5697
5725
|
components,
|
|
5698
5726
|
keys: requestPath.keys,
|
|
5699
|
-
releaseId
|
|
5727
|
+
releaseId,
|
|
5700
5728
|
defaultConsent: determineDefaultConsent({
|
|
5701
5729
|
serverConfig,
|
|
5702
5730
|
defaultConsent: options.defaultConsent
|
|
@@ -5707,7 +5735,8 @@ var handleRouteRequest = async ({
|
|
|
5707
5735
|
isPrefetch: isPrefetch || void 0
|
|
5708
5736
|
};
|
|
5709
5737
|
const code = (0, import_next_app_router_shared5.serializeEvaluationResult)({
|
|
5710
|
-
payload: pageState
|
|
5738
|
+
payload: pageState,
|
|
5739
|
+
allComponentIds
|
|
5711
5740
|
});
|
|
5712
5741
|
let pathToRewriteTo = await (options.rewriteDestinationPath ? options.rewriteDestinationPath({ code, pageState, source: "route" }) : void 0);
|
|
5713
5742
|
if (!pathToRewriteTo) {
|
|
@@ -5767,7 +5796,8 @@ var extractAndEvaluateRunnables = async ({
|
|
|
5767
5796
|
}
|
|
5768
5797
|
}
|
|
5769
5798
|
});
|
|
5770
|
-
|
|
5799
|
+
const allComponentIds = extracted.filter((r) => r.type === "test" || r.type === "personalization").map((r) => r._id);
|
|
5800
|
+
return { ...result, allComponentIds };
|
|
5771
5801
|
};
|
|
5772
5802
|
var handleRedirect = ({ request, route }) => {
|
|
5773
5803
|
const href = resolveRedirectHref({
|
package/dist/middleware.mjs
CHANGED
|
@@ -515,6 +515,20 @@ async function handleRateLimits(callApi) {
|
|
|
515
515
|
}
|
|
516
516
|
return response;
|
|
517
517
|
}
|
|
518
|
+
var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
|
519
|
+
function rewriteFiltersForApi(filters) {
|
|
520
|
+
return Object.entries(filters != null ? filters : {}).reduce(
|
|
521
|
+
(acc, [key, value]) => {
|
|
522
|
+
const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
|
|
523
|
+
const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
|
|
524
|
+
return {
|
|
525
|
+
...acc,
|
|
526
|
+
[lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
|
|
527
|
+
};
|
|
528
|
+
},
|
|
529
|
+
{}
|
|
530
|
+
);
|
|
531
|
+
}
|
|
518
532
|
var _url;
|
|
519
533
|
var _AggregateClient = class _AggregateClient2 extends ApiClient {
|
|
520
534
|
constructor(options) {
|
|
@@ -1298,20 +1312,6 @@ function createLimitPolicy({
|
|
|
1298
1312
|
return currentFunc();
|
|
1299
1313
|
};
|
|
1300
1314
|
}
|
|
1301
|
-
var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
|
1302
|
-
function rewriteFilters(filters) {
|
|
1303
|
-
return Object.entries(filters != null ? filters : {}).reduce(
|
|
1304
|
-
(acc, [key, value]) => {
|
|
1305
|
-
const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
|
|
1306
|
-
const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
|
|
1307
|
-
return {
|
|
1308
|
-
...acc,
|
|
1309
|
-
[lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
|
|
1310
|
-
};
|
|
1311
|
-
},
|
|
1312
|
-
{}
|
|
1313
|
-
);
|
|
1314
|
-
}
|
|
1315
1315
|
var CANVAS_URL = "/api/v1/canvas";
|
|
1316
1316
|
var CanvasClient = class extends ApiClient {
|
|
1317
1317
|
constructor(options) {
|
|
@@ -1327,7 +1327,7 @@ var CanvasClient = class extends ApiClient {
|
|
|
1327
1327
|
async getCompositionList(params = {}) {
|
|
1328
1328
|
const { projectId } = this.options;
|
|
1329
1329
|
const { resolveData, filters, ...originParams } = params;
|
|
1330
|
-
const rewrittenFilters =
|
|
1330
|
+
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
1331
1331
|
if (!resolveData) {
|
|
1332
1332
|
const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
|
|
1333
1333
|
return this.apiClient(fetchUri);
|
|
@@ -1447,7 +1447,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
|
|
|
1447
1447
|
getEntries(options) {
|
|
1448
1448
|
const { projectId } = this.options;
|
|
1449
1449
|
const { skipDataResolution, filters, ...params } = options;
|
|
1450
|
-
const rewrittenFilters =
|
|
1450
|
+
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
1451
1451
|
if (skipDataResolution) {
|
|
1452
1452
|
const url = this.createUrl(__privateGet3(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
|
|
1453
1453
|
return this.apiClient(url);
|
|
@@ -2182,6 +2182,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
|
|
|
2182
2182
|
_baseUrl = /* @__PURE__ */ new WeakMap();
|
|
2183
2183
|
__privateAdd3(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
|
|
2184
2184
|
var _url22;
|
|
2185
|
+
var _projectsUrl;
|
|
2185
2186
|
var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
2186
2187
|
constructor(options) {
|
|
2187
2188
|
super({ ...options, bypassCache: true });
|
|
@@ -2191,6 +2192,15 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
2191
2192
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22), { ...options });
|
|
2192
2193
|
return await this.apiClient(fetchUri);
|
|
2193
2194
|
}
|
|
2195
|
+
/**
|
|
2196
|
+
* Fetches projects grouped by team.
|
|
2197
|
+
* When teamId is provided, returns a single team with its projects.
|
|
2198
|
+
* When omitted, returns all accessible teams and their projects.
|
|
2199
|
+
*/
|
|
2200
|
+
async getProjects(options) {
|
|
2201
|
+
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
|
|
2202
|
+
return await this.apiClient(fetchUri);
|
|
2203
|
+
}
|
|
2194
2204
|
/** Updates or creates (based on id) a Project */
|
|
2195
2205
|
async upsert(body) {
|
|
2196
2206
|
const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
|
|
@@ -2210,7 +2220,9 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
|
|
|
2210
2220
|
}
|
|
2211
2221
|
};
|
|
2212
2222
|
_url22 = /* @__PURE__ */ new WeakMap();
|
|
2223
|
+
_projectsUrl = /* @__PURE__ */ new WeakMap();
|
|
2213
2224
|
__privateAdd3(_ProjectClient, _url22, "/api/v1/project");
|
|
2225
|
+
__privateAdd3(_ProjectClient, _projectsUrl, "/api/v1/projects");
|
|
2214
2226
|
var ROUTE_URL = "/api/v1/route";
|
|
2215
2227
|
var RouteClient = class extends ApiClient {
|
|
2216
2228
|
constructor(options) {
|
|
@@ -2326,8 +2338,15 @@ var isIncontextEditingEnabled = ({
|
|
|
2326
2338
|
var isDevelopmentEnvironment = () => {
|
|
2327
2339
|
return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
|
|
2328
2340
|
};
|
|
2341
|
+
var shouldIgnoreRedirects = ({ state }) => {
|
|
2342
|
+
const isNotPublished = state !== CANVAS_PUBLISHED_STATE;
|
|
2343
|
+
return isNotPublished ? true : void 0;
|
|
2344
|
+
};
|
|
2329
2345
|
|
|
2330
2346
|
// src/clients/cache.ts
|
|
2347
|
+
var isSpecificCacheMode = (options) => {
|
|
2348
|
+
return "cache" in options;
|
|
2349
|
+
};
|
|
2331
2350
|
var isStateCacheMode = (options) => {
|
|
2332
2351
|
return "state" in options;
|
|
2333
2352
|
};
|
|
@@ -2349,7 +2368,9 @@ var resolveCache = ({
|
|
|
2349
2368
|
}) => {
|
|
2350
2369
|
let cache = void 0;
|
|
2351
2370
|
if (options) {
|
|
2352
|
-
if (
|
|
2371
|
+
if (isSpecificCacheMode(options)) {
|
|
2372
|
+
cache = options.cache;
|
|
2373
|
+
} else if (isStateCacheMode(options)) {
|
|
2353
2374
|
if (options.state === CANVAS_DRAFT_STATE || options.state === CANVAS_EDITOR_STATE) {
|
|
2354
2375
|
cache = {
|
|
2355
2376
|
type: "no-cache",
|
|
@@ -2744,7 +2765,10 @@ var DefaultDataClient = class {
|
|
|
2744
2765
|
}
|
|
2745
2766
|
}
|
|
2746
2767
|
const manifest = await getManifest({
|
|
2747
|
-
cache: {
|
|
2768
|
+
cache: isDevelopmentEnvironment() ? {
|
|
2769
|
+
type: "no-cache",
|
|
2770
|
+
bypassCache: true
|
|
2771
|
+
} : {
|
|
2748
2772
|
type: "force-cache"
|
|
2749
2773
|
}
|
|
2750
2774
|
});
|
|
@@ -2847,12 +2871,13 @@ var DefaultDataClient = class {
|
|
|
2847
2871
|
};
|
|
2848
2872
|
}
|
|
2849
2873
|
async getRoutePageState(options) {
|
|
2874
|
+
const shouldBypassCache = options.pageState.compositionState !== CANVAS_PUBLISHED_STATE || isDevelopmentEnvironment();
|
|
2850
2875
|
const routeClient = getRouteClient({
|
|
2851
|
-
cache:
|
|
2852
|
-
type: "force-cache"
|
|
2853
|
-
} : {
|
|
2876
|
+
cache: shouldBypassCache ? {
|
|
2854
2877
|
type: "no-cache",
|
|
2855
2878
|
bypassCache: true
|
|
2879
|
+
} : {
|
|
2880
|
+
type: "force-cache"
|
|
2856
2881
|
}
|
|
2857
2882
|
});
|
|
2858
2883
|
const originalRoute = {
|
|
@@ -2860,7 +2885,8 @@ var DefaultDataClient = class {
|
|
|
2860
2885
|
state: options.pageState.compositionState,
|
|
2861
2886
|
withComponentIDs: true,
|
|
2862
2887
|
releaseId: options.pageState.releaseId,
|
|
2863
|
-
locale: options.pageState.locale
|
|
2888
|
+
locale: options.pageState.locale,
|
|
2889
|
+
ignoreRedirects: shouldIgnoreRedirects({ state: options.pageState.compositionState })
|
|
2864
2890
|
};
|
|
2865
2891
|
const resolvedRoute = await this.getRouteFromApi({
|
|
2866
2892
|
source: "pageState",
|
|
@@ -3383,7 +3409,6 @@ var ManifestInstance = class {
|
|
|
3383
3409
|
constructor({
|
|
3384
3410
|
manifest,
|
|
3385
3411
|
evaluator = new GroupCriteriaEvaluator({}),
|
|
3386
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3387
3412
|
onLogMessage = () => {
|
|
3388
3413
|
}
|
|
3389
3414
|
}) {
|
|
@@ -5414,7 +5439,8 @@ var retrieveRouteByPath = async ({
|
|
|
5414
5439
|
withComponentIDs: true,
|
|
5415
5440
|
withContentSourceMap: (_a = getServerConfig().experimental) == null ? void 0 : _a.vercelVisualEditing,
|
|
5416
5441
|
releaseId,
|
|
5417
|
-
locale
|
|
5442
|
+
locale,
|
|
5443
|
+
ignoreRedirects: shouldIgnoreRedirects({ state })
|
|
5418
5444
|
}
|
|
5419
5445
|
});
|
|
5420
5446
|
};
|
|
@@ -5541,7 +5567,7 @@ var handlePlaygroundRequest = async ({
|
|
|
5541
5567
|
})
|
|
5542
5568
|
});
|
|
5543
5569
|
const context = await onDemandContext.getContext();
|
|
5544
|
-
const { components, rules } = await extractAndEvaluateRunnables({
|
|
5570
|
+
const { components, rules, allComponentIds } = await extractAndEvaluateRunnables({
|
|
5545
5571
|
composition: composition.composition,
|
|
5546
5572
|
routePath: id,
|
|
5547
5573
|
state: composition.state,
|
|
@@ -5581,7 +5607,8 @@ var handlePlaygroundRequest = async ({
|
|
|
5581
5607
|
isPrefetch: void 0
|
|
5582
5608
|
};
|
|
5583
5609
|
const code = serializeEvaluationResult({
|
|
5584
|
-
payload: pageState
|
|
5610
|
+
payload: pageState,
|
|
5611
|
+
allComponentIds
|
|
5585
5612
|
});
|
|
5586
5613
|
let pathToRewriteTo = await (options.rewriteDestinationPath ? options.rewriteDestinationPath({ code, pageState, source: "playground" }) : void 0);
|
|
5587
5614
|
if (!pathToRewriteTo) {
|
|
@@ -5595,15 +5622,16 @@ var handleRouteRequest = async ({
|
|
|
5595
5622
|
dataClient,
|
|
5596
5623
|
options
|
|
5597
5624
|
}) => {
|
|
5598
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
5625
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
5626
|
+
const releaseId = (_b = (_a = options.release) == null ? void 0 : _a.id) != null ? _b : draftModeEnabled ? request.nextUrl.searchParams.get("releaseId") || void 0 : void 0;
|
|
5599
5627
|
const states = await determineState({
|
|
5600
5628
|
searchParams: request.nextUrl.searchParams,
|
|
5601
5629
|
draftModeEnabled
|
|
5602
5630
|
});
|
|
5603
|
-
const requestPath = (
|
|
5631
|
+
const requestPath = (_d = await ((_c = options.rewriteRequestPath) == null ? void 0 : _c.call(options, {
|
|
5604
5632
|
request,
|
|
5605
5633
|
url: new URL(request.url)
|
|
5606
|
-
}))) != null ?
|
|
5634
|
+
}))) != null ? _d : {
|
|
5607
5635
|
path: `${request.nextUrl.pathname}${request.nextUrl.search}`
|
|
5608
5636
|
};
|
|
5609
5637
|
const serverConfig = getServerConfig();
|
|
@@ -5614,7 +5642,7 @@ var handleRouteRequest = async ({
|
|
|
5614
5642
|
searchParams: request.nextUrl.searchParams,
|
|
5615
5643
|
draftModeEnabled,
|
|
5616
5644
|
dataClient,
|
|
5617
|
-
releaseId
|
|
5645
|
+
releaseId,
|
|
5618
5646
|
locale: options.locale
|
|
5619
5647
|
}),
|
|
5620
5648
|
createOnDemandContext({
|
|
@@ -5626,10 +5654,10 @@ var handleRouteRequest = async ({
|
|
|
5626
5654
|
})
|
|
5627
5655
|
})
|
|
5628
5656
|
]);
|
|
5629
|
-
if (!(routeResult == null ? void 0 : routeResult.route) || ((
|
|
5657
|
+
if (!(routeResult == null ? void 0 : routeResult.route) || ((_e = routeResult == null ? void 0 : routeResult.route) == null ? void 0 : _e.type) === "notFound") {
|
|
5630
5658
|
return NextResponse.rewrite(new URL("/404", request.url));
|
|
5631
5659
|
}
|
|
5632
|
-
if (((
|
|
5660
|
+
if (((_f = routeResult == null ? void 0 : routeResult.route) == null ? void 0 : _f.type) === "redirect") {
|
|
5633
5661
|
return handleRedirect({ request, route: routeResult.route });
|
|
5634
5662
|
}
|
|
5635
5663
|
const { route } = routeResult;
|
|
@@ -5663,14 +5691,14 @@ var handleRouteRequest = async ({
|
|
|
5663
5691
|
isDraftModeEnabled: draftModeEnabled
|
|
5664
5692
|
});
|
|
5665
5693
|
const isPrefetch = isPrefetchRequest(request);
|
|
5666
|
-
const { components, rules } = await extractAndEvaluateRunnables({
|
|
5694
|
+
const { components, rules, allComponentIds } = await extractAndEvaluateRunnables({
|
|
5667
5695
|
composition: route.compositionApiResponse.composition,
|
|
5668
5696
|
routePath,
|
|
5669
5697
|
state,
|
|
5670
5698
|
context,
|
|
5671
5699
|
matchedRoute: route.matchedRoute,
|
|
5672
|
-
dynamicInputs: (
|
|
5673
|
-
releaseId
|
|
5700
|
+
dynamicInputs: (_g = route.dynamicInputs) != null ? _g : {},
|
|
5701
|
+
releaseId,
|
|
5674
5702
|
defaultConsent: determineDefaultConsent({
|
|
5675
5703
|
serverConfig,
|
|
5676
5704
|
defaultConsent: options.defaultConsent
|
|
@@ -5688,7 +5716,7 @@ var handleRouteRequest = async ({
|
|
|
5688
5716
|
compositionState: state,
|
|
5689
5717
|
components,
|
|
5690
5718
|
keys: requestPath.keys,
|
|
5691
|
-
releaseId
|
|
5719
|
+
releaseId,
|
|
5692
5720
|
defaultConsent: determineDefaultConsent({
|
|
5693
5721
|
serverConfig,
|
|
5694
5722
|
defaultConsent: options.defaultConsent
|
|
@@ -5699,7 +5727,8 @@ var handleRouteRequest = async ({
|
|
|
5699
5727
|
isPrefetch: isPrefetch || void 0
|
|
5700
5728
|
};
|
|
5701
5729
|
const code = serializeEvaluationResult({
|
|
5702
|
-
payload: pageState
|
|
5730
|
+
payload: pageState,
|
|
5731
|
+
allComponentIds
|
|
5703
5732
|
});
|
|
5704
5733
|
let pathToRewriteTo = await (options.rewriteDestinationPath ? options.rewriteDestinationPath({ code, pageState, source: "route" }) : void 0);
|
|
5705
5734
|
if (!pathToRewriteTo) {
|
|
@@ -5759,7 +5788,8 @@ var extractAndEvaluateRunnables = async ({
|
|
|
5759
5788
|
}
|
|
5760
5789
|
}
|
|
5761
5790
|
});
|
|
5762
|
-
|
|
5791
|
+
const allComponentIds = extracted.filter((r) => r.type === "test" || r.type === "personalization").map((r) => r._id);
|
|
5792
|
+
return { ...result, allComponentIds };
|
|
5763
5793
|
};
|
|
5764
5794
|
var handleRedirect = ({ request, route }) => {
|
|
5765
5795
|
const href = resolveRedirectHref({
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/next-app-router",
|
|
3
|
-
"version": "20.50.2-alpha.
|
|
3
|
+
"version": "20.50.2-alpha.77+51415ad3dd",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsup",
|
|
7
7
|
"dev": "tsup --watch",
|
|
8
8
|
"lint": "eslint \"src/**/*.{ts,tsx}\" --fix",
|
|
9
|
-
"test": "vitest"
|
|
9
|
+
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"sideEffects": false,
|
|
12
12
|
"main": "dist/index.js",
|
|
@@ -99,12 +99,12 @@
|
|
|
99
99
|
"vitest": "3.2.4"
|
|
100
100
|
},
|
|
101
101
|
"dependencies": {
|
|
102
|
-
"@uniformdev/canvas-react": "20.50.2-alpha.
|
|
103
|
-
"@uniformdev/next-app-router-client": "20.50.2-alpha.
|
|
104
|
-
"@uniformdev/next-app-router-shared": "20.50.2-alpha.
|
|
105
|
-
"@uniformdev/redirect": "20.50.2-alpha.
|
|
106
|
-
"@uniformdev/richtext": "20.50.2-alpha.
|
|
107
|
-
"@uniformdev/webhooks": "20.50.2-alpha.
|
|
102
|
+
"@uniformdev/canvas-react": "20.50.2-alpha.77+51415ad3dd",
|
|
103
|
+
"@uniformdev/next-app-router-client": "20.50.2-alpha.77+51415ad3dd",
|
|
104
|
+
"@uniformdev/next-app-router-shared": "20.50.2-alpha.77+51415ad3dd",
|
|
105
|
+
"@uniformdev/redirect": "20.50.2-alpha.77+51415ad3dd",
|
|
106
|
+
"@uniformdev/richtext": "20.50.2-alpha.77+51415ad3dd",
|
|
107
|
+
"@uniformdev/webhooks": "20.50.2-alpha.77+51415ad3dd",
|
|
108
108
|
"@vercel/functions": "^2.2.2",
|
|
109
109
|
"encoding": "^0.1.13",
|
|
110
110
|
"server-only": "^0.0.1",
|
|
@@ -121,5 +121,5 @@
|
|
|
121
121
|
"publishConfig": {
|
|
122
122
|
"access": "public"
|
|
123
123
|
},
|
|
124
|
-
"gitHead": "
|
|
124
|
+
"gitHead": "51415ad3ddc2e973a8c52fc4116df82182f9c44b"
|
|
125
125
|
}
|