@payloadcms/ui 4.0.0-canary.36 → 4.0.0-canary.37
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/elements/Banner/index.css +4 -0
- package/dist/elements/Banner/index.d.ts.map +1 -1
- package/dist/elements/Banner/index.js +1 -0
- package/dist/elements/Banner/index.js.map +1 -1
- package/dist/elements/Nav/getNavPrefs.d.ts.map +1 -1
- package/dist/elements/Nav/getNavPrefs.js +2 -0
- package/dist/elements/Nav/getNavPrefs.js.map +1 -1
- package/dist/elements/PublishButton/index.d.ts.map +1 -1
- package/dist/elements/PublishButton/index.js +11 -25
- package/dist/elements/PublishButton/index.js.map +1 -1
- package/dist/layouts/Root/index.d.ts +3 -6
- package/dist/layouts/Root/index.d.ts.map +1 -1
- package/dist/layouts/Root/index.js +2 -4
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/getDocPreferences.d.ts.map +1 -1
- package/dist/utilities/getDocPreferences.js +1 -0
- package/dist/utilities/getDocPreferences.js.map +1 -1
- package/dist/utilities/getPreferences.d.ts.map +1 -1
- package/dist/utilities/getPreferences.js +1 -0
- package/dist/utilities/getPreferences.js.map +1 -1
- package/dist/utilities/getVersions.d.ts.map +1 -1
- package/dist/utilities/getVersions.js +8 -0
- package/dist/utilities/getVersions.js.map +1 -1
- package/dist/utilities/schedulePublishHandler.d.ts.map +1 -1
- package/dist/utilities/schedulePublishHandler.js +2 -0
- package/dist/utilities/schedulePublishHandler.js.map +1 -1
- package/dist/utilities/upsertPreferences.d.ts.map +1 -1
- package/dist/utilities/upsertPreferences.js +3 -0
- package/dist/utilities/upsertPreferences.js.map +1 -1
- package/dist/views/Document/handleServerFunction.d.ts.map +1 -1
- package/dist/views/Document/handleServerFunction.js +1 -0
- package/dist/views/Document/handleServerFunction.js.map +1 -1
- package/dist/views/List/enrichDocsWithVersionStatus.d.ts.map +1 -1
- package/dist/views/List/enrichDocsWithVersionStatus.js +1 -0
- package/dist/views/List/enrichDocsWithVersionStatus.js.map +1 -1
- package/dist/views/List/handleServerFunction.d.ts.map +1 -1
- package/dist/views/List/handleServerFunction.js +1 -0
- package/dist/views/List/handleServerFunction.js.map +1 -1
- package/dist/views/NotFound/client.d.ts +2 -0
- package/dist/views/NotFound/client.d.ts.map +1 -0
- package/dist/views/NotFound/client.js +4 -0
- package/dist/views/NotFound/client.js.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/generateLabelFromValue.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/generateLabelFromValue.js +1 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/generateLabelFromValue.js.map +1 -1
- package/package.json +10 -5
- package/dist/utilities/getRequestLocale.d.ts +0 -7
- package/dist/utilities/getRequestLocale.d.ts.map +0 -1
- package/dist/utilities/getRequestLocale.js +0 -20
- package/dist/utilities/getRequestLocale.js.map +0 -1
- package/dist/utilities/initReq.d.ts +0 -16
- package/dist/utilities/initReq.d.ts.map +0 -1
- package/dist/utilities/initReq.js +0 -146
- package/dist/utilities/initReq.js.map +0 -1
- package/dist/utilities/selectiveCache.d.ts +0 -12
- package/dist/utilities/selectiveCache.d.ts.map +0 -1
- package/dist/utilities/selectiveCache.js +0 -37
- package/dist/utilities/selectiveCache.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/ui",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.37",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -167,6 +167,11 @@
|
|
|
167
167
|
"types": "./dist/views/NotFound/page.d.ts",
|
|
168
168
|
"default": "./dist/views/NotFound/page.js"
|
|
169
169
|
},
|
|
170
|
+
"./views/NotFound/client": {
|
|
171
|
+
"import": "./dist/views/NotFound/client.js",
|
|
172
|
+
"types": "./dist/views/NotFound/client.d.ts",
|
|
173
|
+
"default": "./dist/views/NotFound/client.js"
|
|
174
|
+
},
|
|
170
175
|
"./views/Root/getCustomViewByRoute": {
|
|
171
176
|
"import": "./dist/views/Root/getCustomViewByRoute.js",
|
|
172
177
|
"types": "./dist/views/Root/getCustomViewByRoute.d.ts",
|
|
@@ -290,7 +295,7 @@
|
|
|
290
295
|
"ts-essentials": "10.0.3",
|
|
291
296
|
"use-context-selector": "2.0.0",
|
|
292
297
|
"uuid": "14.0.0",
|
|
293
|
-
"@payloadcms/translations": "4.0.0-canary.
|
|
298
|
+
"@payloadcms/translations": "4.0.0-canary.37"
|
|
294
299
|
},
|
|
295
300
|
"devDependencies": {
|
|
296
301
|
"@babel/cli": "7.27.2",
|
|
@@ -304,13 +309,13 @@
|
|
|
304
309
|
"babel-plugin-react-compiler": "19.1.0-rc.3",
|
|
305
310
|
"esbuild": "0.27.1",
|
|
306
311
|
"esbuild-sass-plugin": "3.3.1",
|
|
307
|
-
"
|
|
308
|
-
"
|
|
312
|
+
"payload": "4.0.0-canary.37",
|
|
313
|
+
"@payloadcms/eslint-config": "3.28.0"
|
|
309
314
|
},
|
|
310
315
|
"peerDependencies": {
|
|
311
316
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
312
317
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
313
|
-
"payload": "4.0.0-canary.
|
|
318
|
+
"payload": "4.0.0-canary.37"
|
|
314
319
|
},
|
|
315
320
|
"engines": {
|
|
316
321
|
"node": ">=24.15.0"
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Locale, PayloadRequest } from 'payload';
|
|
2
|
-
type GetRequestLocalesArgs = {
|
|
3
|
-
req: PayloadRequest;
|
|
4
|
-
};
|
|
5
|
-
export declare function getRequestLocale({ req }: GetRequestLocalesArgs): Promise<Locale>;
|
|
6
|
-
export {};
|
|
7
|
-
//# sourceMappingURL=getRequestLocale.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getRequestLocale.d.ts","sourceRoot":"","sources":["../../src/utilities/getRequestLocale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAMrD,KAAK,qBAAqB,GAAG;IAC3B,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,wBAAsB,gBAAgB,CAAC,EAAE,GAAG,EAAE,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,CA8BtF"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { findLocaleFromCode } from './findLocaleFromCode.js';
|
|
2
|
-
import { getPreferences } from './getPreferences.js';
|
|
3
|
-
import { upsertPreferences } from './upsertPreferences.js';
|
|
4
|
-
export async function getRequestLocale({
|
|
5
|
-
req
|
|
6
|
-
}) {
|
|
7
|
-
if (req.payload.config.localization) {
|
|
8
|
-
const localeFromParams = req.query.locale;
|
|
9
|
-
if (req.user && localeFromParams) {
|
|
10
|
-
await upsertPreferences({
|
|
11
|
-
key: 'locale',
|
|
12
|
-
req,
|
|
13
|
-
value: localeFromParams
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return req.user && findLocaleFromCode(req.payload.config.localization, localeFromParams || (await getPreferences('locale', req.payload, req.user.id, req.user.collection))?.value) || findLocaleFromCode(req.payload.config.localization, req.payload.config.localization.defaultLocale || 'en');
|
|
17
|
-
}
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=getRequestLocale.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getRequestLocale.js","names":["findLocaleFromCode","getPreferences","upsertPreferences","getRequestLocale","req","payload","config","localization","localeFromParams","query","locale","user","key","value","id","collection","defaultLocale","undefined"],"sources":["../../src/utilities/getRequestLocale.ts"],"sourcesContent":["import type { Locale, PayloadRequest } from 'payload'\n\nimport { findLocaleFromCode } from './findLocaleFromCode.js'\nimport { getPreferences } from './getPreferences.js'\nimport { upsertPreferences } from './upsertPreferences.js'\n\ntype GetRequestLocalesArgs = {\n req: PayloadRequest\n}\n\nexport async function getRequestLocale({ req }: GetRequestLocalesArgs): Promise<Locale> {\n if (req.payload.config.localization) {\n const localeFromParams = req.query.locale as string | undefined\n\n if (req.user && localeFromParams) {\n await upsertPreferences<Locale['code']>({ key: 'locale', req, value: localeFromParams })\n }\n\n return (\n (req.user &&\n findLocaleFromCode(\n req.payload.config.localization,\n localeFromParams ||\n (\n await getPreferences<Locale['code']>(\n 'locale',\n req.payload,\n req.user.id,\n req.user.collection,\n )\n )?.value,\n )) ||\n findLocaleFromCode(\n req.payload.config.localization,\n req.payload.config.localization.defaultLocale || 'en',\n )\n )\n }\n\n return undefined\n}\n"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,QAAQ;AAMlC,OAAO,eAAeC,iBAAiB;EAAEC;AAAG,CAAyB;EACnE,IAAIA,GAAA,CAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;IACnC,MAAMC,gBAAA,GAAmBJ,GAAA,CAAIK,KAAK,CAACC,MAAM;IAEzC,IAAIN,GAAA,CAAIO,IAAI,IAAIH,gBAAA,EAAkB;MAChC,MAAMN,iBAAA,CAAkC;QAAEU,GAAA,EAAK;QAAUR,GAAA;QAAKS,KAAA,EAAOL;MAAiB;IACxF;IAEA,OACEJ,GAAC,CAAIO,IAAI,IACPX,kBAAA,CACEI,GAAA,CAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAC/BC,gBAAA,IAEI,OAAMP,cAAA,CACJ,UACAG,GAAA,CAAIC,OAAO,EACXD,GAAA,CAAIO,IAAI,CAACG,EAAE,EACXV,GAAA,CAAIO,IAAI,CAACI,UAAU,CACrB,GACCF,KAAA,KAETb,kBAAA,CACEI,GAAA,CAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAC/BH,GAAA,CAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,CAACS,aAAa,IAAI;EAGvD;EAEA,OAAOC,SAAA;AACT","ignoreList":[]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ImportMap, InitReqResult, SanitizedConfig, ServerAdapter } from 'payload';
|
|
2
|
-
import { createLocalReq } from 'payload';
|
|
3
|
-
/**
|
|
4
|
-
* Initializes a full request object, including the `req` object and access control.
|
|
5
|
-
* Reads headers/cookies through the supplied `serverAdapter` so the function is
|
|
6
|
-
* framework-agnostic; the consuming framework wires its own adapter.
|
|
7
|
-
*/
|
|
8
|
-
export declare const initReq: ({ canSetHeaders, configPromise, importMap, key, overrides, serverAdapter, }: {
|
|
9
|
-
canSetHeaders?: boolean;
|
|
10
|
-
configPromise: Promise<SanitizedConfig> | SanitizedConfig;
|
|
11
|
-
importMap: ImportMap;
|
|
12
|
-
key: string;
|
|
13
|
-
overrides?: Parameters<typeof createLocalReq>[0];
|
|
14
|
-
serverAdapter: ServerAdapter;
|
|
15
|
-
}) => Promise<InitReqResult>;
|
|
16
|
-
//# sourceMappingURL=initReq.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initReq.d.ts","sourceRoot":"","sources":["../../src/utilities/initReq.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EAEb,eAAe,EACf,aAAa,EACd,MAAM,SAAS,CAAA;AAGhB,OAAO,EACL,cAAc,EAMf,MAAM,SAAS,CAAA;AAchB;;;;GAIG;AACH,eAAO,MAAM,OAAO,gFAOjB;IACD,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IACzD,SAAS,EAAE,SAAS,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;IAChD,aAAa,EAAE,aAAa,CAAA;CAC7B,KAAG,OAAO,CAAC,aAAa,CA2HxB,CAAA"}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { initI18n } from '@payloadcms/translations';
|
|
2
|
-
import { createLocalReq, executeAuthStrategies, getAccessResults, getPayload, getRequestLanguage, parseCookies } from 'payload';
|
|
3
|
-
import { applyUserReadAccess } from 'payload/internal';
|
|
4
|
-
import { getRequestLocale } from './getRequestLocale.js';
|
|
5
|
-
import { selectiveCache } from './selectiveCache.js';
|
|
6
|
-
const partialReqCache = selectiveCache('partialReq');
|
|
7
|
-
const reqCache = selectiveCache('req');
|
|
8
|
-
/**
|
|
9
|
-
* Initializes a full request object, including the `req` object and access control.
|
|
10
|
-
* Reads headers/cookies through the supplied `serverAdapter` so the function is
|
|
11
|
-
* framework-agnostic; the consuming framework wires its own adapter.
|
|
12
|
-
*/
|
|
13
|
-
export const initReq = async function ({
|
|
14
|
-
canSetHeaders,
|
|
15
|
-
configPromise,
|
|
16
|
-
importMap,
|
|
17
|
-
key,
|
|
18
|
-
overrides,
|
|
19
|
-
serverAdapter
|
|
20
|
-
}) {
|
|
21
|
-
const headers = await serverAdapter.getHeaders();
|
|
22
|
-
const cookies = parseCookies(headers);
|
|
23
|
-
const getPartialResult = async () => {
|
|
24
|
-
const config = await configPromise;
|
|
25
|
-
const payload = await getPayload({
|
|
26
|
-
config,
|
|
27
|
-
cron: true,
|
|
28
|
-
importMap
|
|
29
|
-
});
|
|
30
|
-
const languageCode = getRequestLanguage({
|
|
31
|
-
config,
|
|
32
|
-
cookies,
|
|
33
|
-
headers
|
|
34
|
-
});
|
|
35
|
-
const i18n = await initI18n({
|
|
36
|
-
config: config.i18n,
|
|
37
|
-
context: 'client',
|
|
38
|
-
language: languageCode
|
|
39
|
-
});
|
|
40
|
-
const {
|
|
41
|
-
responseHeaders,
|
|
42
|
-
user
|
|
43
|
-
} = await executeAuthStrategies({
|
|
44
|
-
canSetHeaders,
|
|
45
|
-
headers,
|
|
46
|
-
payload
|
|
47
|
-
});
|
|
48
|
-
return {
|
|
49
|
-
i18n,
|
|
50
|
-
languageCode,
|
|
51
|
-
payload,
|
|
52
|
-
responseHeaders,
|
|
53
|
-
user
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
const partialResult = await partialReqCache.get(getPartialResult, 'global');
|
|
57
|
-
const getResult = async () => {
|
|
58
|
-
const {
|
|
59
|
-
i18n,
|
|
60
|
-
languageCode,
|
|
61
|
-
payload,
|
|
62
|
-
responseHeaders,
|
|
63
|
-
user
|
|
64
|
-
} = partialResult;
|
|
65
|
-
const {
|
|
66
|
-
req: reqOverrides,
|
|
67
|
-
...optionsOverrides
|
|
68
|
-
} = overrides || {};
|
|
69
|
-
const hasOptionsUserOverride = Object.hasOwn(optionsOverrides, 'user');
|
|
70
|
-
const hasReqUserOverride = Object.hasOwn(reqOverrides ?? {}, 'user');
|
|
71
|
-
const hasUserOverride = hasOptionsUserOverride || hasReqUserOverride;
|
|
72
|
-
const userOverride = hasOptionsUserOverride ? optionsOverrides.user : reqOverrides?.user;
|
|
73
|
-
const req = await createLocalReq({
|
|
74
|
-
req: {
|
|
75
|
-
headers,
|
|
76
|
-
host: headers.get('host'),
|
|
77
|
-
i18n: i18n,
|
|
78
|
-
responseHeaders,
|
|
79
|
-
server: serverAdapter,
|
|
80
|
-
user,
|
|
81
|
-
...(reqOverrides || {})
|
|
82
|
-
},
|
|
83
|
-
...(optionsOverrides || {})
|
|
84
|
-
}, payload);
|
|
85
|
-
if (hasUserOverride && userOverride == null) {
|
|
86
|
-
req.user = null;
|
|
87
|
-
}
|
|
88
|
-
let userWithReadAccess = req.user;
|
|
89
|
-
const locale = await getRequestLocale({
|
|
90
|
-
req
|
|
91
|
-
});
|
|
92
|
-
req.locale = locale?.code;
|
|
93
|
-
if (!hasUserOverride && req.user) {
|
|
94
|
-
try {
|
|
95
|
-
const collectionSlug = req.user.collection ?? payload.config.admin.user;
|
|
96
|
-
const collection = payload.collections[collectionSlug]?.config;
|
|
97
|
-
if (!collection?.auth) {
|
|
98
|
-
throw new Error('Authenticated user collection not found');
|
|
99
|
-
}
|
|
100
|
-
userWithReadAccess = await applyUserReadAccess({
|
|
101
|
-
collection,
|
|
102
|
-
depth: collection.auth.depth,
|
|
103
|
-
overrideAccess: false,
|
|
104
|
-
req,
|
|
105
|
-
showHiddenFields: false,
|
|
106
|
-
user: req.user
|
|
107
|
-
});
|
|
108
|
-
} catch (error) {
|
|
109
|
-
payload.logger.error({
|
|
110
|
-
err: error
|
|
111
|
-
});
|
|
112
|
-
req.user = null;
|
|
113
|
-
userWithReadAccess = null;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const permissions = await getAccessResults({
|
|
117
|
-
req
|
|
118
|
-
});
|
|
119
|
-
return {
|
|
120
|
-
cookies,
|
|
121
|
-
headers,
|
|
122
|
-
languageCode,
|
|
123
|
-
locale,
|
|
124
|
-
permissions,
|
|
125
|
-
req,
|
|
126
|
-
user: userWithReadAccess
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
return reqCache.get(getResult, key, overrides).then(result => {
|
|
130
|
-
// Shallow-copy req before returning to prevent
|
|
131
|
-
// mutations from propagating to the cached req object.
|
|
132
|
-
// This ensures parallel operations using the same cache key don't affect each other.
|
|
133
|
-
return {
|
|
134
|
-
...result,
|
|
135
|
-
req: {
|
|
136
|
-
...result.req,
|
|
137
|
-
...(result.req?.context ? {
|
|
138
|
-
context: {
|
|
139
|
-
...result.req.context
|
|
140
|
-
}
|
|
141
|
-
} : {})
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
});
|
|
145
|
-
};
|
|
146
|
-
//# sourceMappingURL=initReq.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initReq.js","names":["initI18n","createLocalReq","executeAuthStrategies","getAccessResults","getPayload","getRequestLanguage","parseCookies","applyUserReadAccess","getRequestLocale","selectiveCache","partialReqCache","reqCache","initReq","canSetHeaders","configPromise","importMap","key","overrides","serverAdapter","headers","getHeaders","cookies","getPartialResult","config","payload","cron","languageCode","i18n","context","language","responseHeaders","user","partialResult","get","getResult","req","reqOverrides","optionsOverrides","hasOptionsUserOverride","Object","hasOwn","hasReqUserOverride","hasUserOverride","userOverride","host","server","userWithReadAccess","locale","code","collectionSlug","collection","admin","collections","auth","Error","depth","overrideAccess","showHiddenFields","error","logger","err","permissions","then","result"],"sources":["../../src/utilities/initReq.ts"],"sourcesContent":["import type { I18n, I18nClient } from '@payloadcms/translations'\nimport type {\n ImportMap,\n InitReqResult,\n PayloadRequest,\n SanitizedConfig,\n ServerAdapter,\n} from 'payload'\n\nimport { initI18n } from '@payloadcms/translations'\nimport {\n createLocalReq,\n executeAuthStrategies,\n getAccessResults,\n getPayload,\n getRequestLanguage,\n parseCookies,\n} from 'payload'\nimport { applyUserReadAccess } from 'payload/internal'\n\nimport { getRequestLocale } from './getRequestLocale.js'\nimport { selectiveCache } from './selectiveCache.js'\n\ntype PartialResult = {\n i18n: I18nClient\n} & Pick<InitReqResult, 'languageCode'> &\n Pick<PayloadRequest, 'payload' | 'responseHeaders' | 'user'>\n\nconst partialReqCache = selectiveCache<PartialResult>('partialReq')\nconst reqCache = selectiveCache<InitReqResult>('req')\n\n/**\n * Initializes a full request object, including the `req` object and access control.\n * Reads headers/cookies through the supplied `serverAdapter` so the function is\n * framework-agnostic; the consuming framework wires its own adapter.\n */\nexport const initReq = async function ({\n canSetHeaders,\n configPromise,\n importMap,\n key,\n overrides,\n serverAdapter,\n}: {\n canSetHeaders?: boolean\n configPromise: Promise<SanitizedConfig> | SanitizedConfig\n importMap: ImportMap\n key: string\n overrides?: Parameters<typeof createLocalReq>[0]\n serverAdapter: ServerAdapter\n}): Promise<InitReqResult> {\n const headers = await serverAdapter.getHeaders()\n const cookies = parseCookies(headers)\n\n const getPartialResult = async () => {\n const config = await configPromise\n const payload = await getPayload({ config, cron: true, importMap })\n const languageCode = getRequestLanguage({\n config,\n cookies,\n headers,\n })\n\n const i18n: I18nClient = await initI18n({\n config: config.i18n,\n context: 'client',\n language: languageCode,\n })\n\n const { responseHeaders, user } = await executeAuthStrategies({\n canSetHeaders,\n headers,\n payload,\n })\n\n return {\n i18n,\n languageCode,\n payload,\n responseHeaders,\n user,\n }\n }\n\n const partialResult = await partialReqCache.get(getPartialResult, 'global')\n\n const getResult = async () => {\n const { i18n, languageCode, payload, responseHeaders, user } = partialResult\n\n const { req: reqOverrides, ...optionsOverrides } = overrides || {}\n const hasOptionsUserOverride = Object.hasOwn(optionsOverrides, 'user')\n const hasReqUserOverride = Object.hasOwn(reqOverrides ?? {}, 'user')\n const hasUserOverride = hasOptionsUserOverride || hasReqUserOverride\n const userOverride = hasOptionsUserOverride ? optionsOverrides.user : reqOverrides?.user\n\n const req = await createLocalReq(\n {\n req: {\n headers,\n host: headers.get('host'),\n i18n: i18n as I18n,\n responseHeaders,\n server: serverAdapter,\n user,\n ...(reqOverrides || {}),\n },\n ...(optionsOverrides || {}),\n },\n payload,\n )\n\n if (hasUserOverride && userOverride == null) {\n req.user = null\n }\n\n let userWithReadAccess = req.user\n\n const locale = await getRequestLocale({ req })\n req.locale = locale?.code\n\n if (!hasUserOverride && req.user) {\n try {\n const collectionSlug = req.user.collection ?? payload.config.admin.user\n const collection = payload.collections[collectionSlug]?.config\n\n if (!collection?.auth) {\n throw new Error('Authenticated user collection not found')\n }\n\n userWithReadAccess = await applyUserReadAccess({\n collection,\n depth: collection.auth.depth,\n overrideAccess: false,\n req,\n showHiddenFields: false,\n user: req.user,\n })\n } catch (error) {\n payload.logger.error({ err: error })\n req.user = null\n userWithReadAccess = null\n }\n }\n\n const permissions = await getAccessResults({ req })\n\n return {\n cookies,\n headers,\n languageCode,\n locale,\n permissions,\n req,\n user: userWithReadAccess,\n }\n }\n\n return reqCache.get(getResult, key, overrides).then((result) => {\n // Shallow-copy req before returning to prevent\n // mutations from propagating to the cached req object.\n // This ensures parallel operations using the same cache key don't affect each other.\n return {\n ...result,\n req: {\n ...result.req,\n ...(result.req?.context\n ? {\n context: { ...result.req.context },\n }\n : {}),\n },\n }\n })\n}\n"],"mappings":"AASA,SAASA,QAAQ,QAAQ;AACzB,SACEC,cAAc,EACdC,qBAAqB,EACrBC,gBAAgB,EAChBC,UAAU,EACVC,kBAAkB,EAClBC,YAAY,QACP;AACP,SAASC,mBAAmB,QAAQ;AAEpC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAO/B,MAAMC,eAAA,GAAkBD,cAAA,CAA8B;AACtD,MAAME,QAAA,GAAWF,cAAA,CAA8B;AAE/C;;;;;AAKA,OAAO,MAAMG,OAAA,GAAU,eAAAA,CAAgB;EACrCC,aAAa;EACbC,aAAa;EACbC,SAAS;EACTC,GAAG;EACHC,SAAS;EACTC;AAAa,CAQd;EACC,MAAMC,OAAA,GAAU,MAAMD,aAAA,CAAcE,UAAU;EAC9C,MAAMC,OAAA,GAAUf,YAAA,CAAaa,OAAA;EAE7B,MAAMG,gBAAA,GAAmB,MAAAA,CAAA;IACvB,MAAMC,MAAA,GAAS,MAAMT,aAAA;IACrB,MAAMU,OAAA,GAAU,MAAMpB,UAAA,CAAW;MAAEmB,MAAA;MAAQE,IAAA,EAAM;MAAMV;IAAU;IACjE,MAAMW,YAAA,GAAerB,kBAAA,CAAmB;MACtCkB,MAAA;MACAF,OAAA;MACAF;IACF;IAEA,MAAMQ,IAAA,GAAmB,MAAM3B,QAAA,CAAS;MACtCuB,MAAA,EAAQA,MAAA,CAAOI,IAAI;MACnBC,OAAA,EAAS;MACTC,QAAA,EAAUH;IACZ;IAEA,MAAM;MAAEI,eAAe;MAAEC;IAAI,CAAE,GAAG,MAAM7B,qBAAA,CAAsB;MAC5DW,aAAA;MACAM,OAAA;MACAK;IACF;IAEA,OAAO;MACLG,IAAA;MACAD,YAAA;MACAF,OAAA;MACAM,eAAA;MACAC;IACF;EACF;EAEA,MAAMC,aAAA,GAAgB,MAAMtB,eAAA,CA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
/**
|
|
3
|
-
* Creates a selective cache function that provides more control over React's request-level caching behavior.
|
|
4
|
-
*
|
|
5
|
-
* @param namespace - A namespace to group related cached values
|
|
6
|
-
* @returns A function that manages cached values within the specified namespace
|
|
7
|
-
*/
|
|
8
|
-
export declare function selectiveCache<TValue extends object = CachedValue>(namespace: string): {
|
|
9
|
-
get: (factory: () => Promise<TValue>, ...cacheArgs: any[]) => Promise<TValue>;
|
|
10
|
-
};
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=selectiveCache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selectiveCache.d.ts","sourceRoot":"","sources":["../../src/utilities/selectiveCache.ts"],"names":[],"mappings":"AAEA,KAAK,WAAW,GAAG,MAAM,CAAA;AAazB;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,SAAS,MAAM,GAAG,WAAW,EAAE,SAAS,EAAE,MAAM;IAgCjF,GAAG,YAlB6B,MAAM,OAAO,CAAC,MAAM,CAAC,0BAAiB,OAAO,CAAC,MAAM,CAAC;EAoBxF"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { cache } from 'react';
|
|
2
|
-
// Module-scoped cache container that holds all cached, stable containers
|
|
3
|
-
// - these may hold the stable value, or a promise to the stable value
|
|
4
|
-
const globalCacheContainer = {};
|
|
5
|
-
/**
|
|
6
|
-
* Creates a selective cache function that provides more control over React's request-level caching behavior.
|
|
7
|
-
*
|
|
8
|
-
* @param namespace - A namespace to group related cached values
|
|
9
|
-
* @returns A function that manages cached values within the specified namespace
|
|
10
|
-
*/
|
|
11
|
-
export function selectiveCache(namespace) {
|
|
12
|
-
if (!globalCacheContainer[namespace]) {
|
|
13
|
-
globalCacheContainer[namespace] = cache((...args) => ({
|
|
14
|
-
value: null
|
|
15
|
-
}));
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Gets or creates a cached value for a specific key within the namespace
|
|
19
|
-
*
|
|
20
|
-
* @param key - The key to identify the cached value
|
|
21
|
-
* @param factory - A function that produces the value if not cached
|
|
22
|
-
* @returns The cached or newly created value
|
|
23
|
-
*/
|
|
24
|
-
const getCached = async (factory, ...cacheArgs) => {
|
|
25
|
-
const stableObjectFn = globalCacheContainer[namespace];
|
|
26
|
-
const stableObject = stableObjectFn(...cacheArgs);
|
|
27
|
-
if (stableObject?.value && 'then' in stableObject.value && typeof stableObject.value?.then === 'function') {
|
|
28
|
-
return await stableObject.value;
|
|
29
|
-
}
|
|
30
|
-
stableObject.value = factory();
|
|
31
|
-
return await stableObject.value;
|
|
32
|
-
};
|
|
33
|
-
return {
|
|
34
|
-
get: getCached
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=selectiveCache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selectiveCache.js","names":["cache","globalCacheContainer","selectiveCache","namespace","args","value","getCached","factory","cacheArgs","stableObjectFn","stableObject","then","get"],"sources":["../../src/utilities/selectiveCache.ts"],"sourcesContent":["import { cache } from 'react'\n\ntype CachedValue = object\n\n// Module-scoped cache container that holds all cached, stable containers\n// - these may hold the stable value, or a promise to the stable value\nconst globalCacheContainer: Record<\n string,\n <TValue extends object = CachedValue>(\n ...args: unknown[]\n ) => {\n value: null | Promise<TValue> | TValue\n }\n> = {}\n\n/**\n * Creates a selective cache function that provides more control over React's request-level caching behavior.\n *\n * @param namespace - A namespace to group related cached values\n * @returns A function that manages cached values within the specified namespace\n */\nexport function selectiveCache<TValue extends object = CachedValue>(namespace: string) {\n if (!globalCacheContainer[namespace]) {\n globalCacheContainer[namespace] = cache((...args) => ({\n value: null,\n }))\n }\n\n /**\n * Gets or creates a cached value for a specific key within the namespace\n *\n * @param key - The key to identify the cached value\n * @param factory - A function that produces the value if not cached\n * @returns The cached or newly created value\n */\n const getCached = async (factory: () => Promise<TValue>, ...cacheArgs): Promise<TValue> => {\n const stableObjectFn = globalCacheContainer[namespace]\n const stableObject = stableObjectFn<TValue>(...cacheArgs)\n\n if (\n stableObject?.value &&\n 'then' in stableObject.value &&\n typeof stableObject.value?.then === 'function'\n ) {\n return await stableObject.value\n }\n\n stableObject.value = factory()\n\n return await stableObject.value\n }\n\n return {\n get: getCached,\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ;AAItB;AACA;AACA,MAAMC,oBAAA,GAOF,CAAC;AAEL;;;;;;AAMA,OAAO,SAASC,eAAoDC,SAAiB;EACnF,IAAI,CAACF,oBAAoB,CAACE,SAAA,CAAU,EAAE;IACpCF,oBAAoB,CAACE,SAAA,CAAU,GAAGH,KAAA,CAAM,CAAC,GAAGI,IAAA,MAAU;MACpDC,KAAA,EAAO;IACT;EACF;EAEA;;;;;;;EAOA,MAAMC,SAAA,GAAY,MAAAA,CAAOC,OAAA,EAAgC,GAAGC,SAAA;IAC1D,MAAMC,cAAA,GAAiBR,oBAAoB,CAACE,SAAA,CAAU;IACtD,MAAMO,YAAA,GAAeD,cAAA,IAA0BD,SAAA;IAE/C,IACEE,YAAA,EAAcL,KAAA,IACd,UAAUK,YAAA,CAAaL,KAAK,IAC5B,OAAOK,YAAA,CAAaL,KAAK,EAAEM,IAAA,KAAS,YACpC;MACA,OAAO,MAAMD,YAAA,CAAaL,KAAK;IACjC;IAEAK,YAAA,CAAaL,KAAK,GAAGE,OAAA;IAErB,OAAO,MAAMG,YAAA,CAAaL,KAAK;EACjC;EAEA,OAAO;IACLO,GAAA,EAAKN;EACP;AACF","ignoreList":[]}
|