@payloadcms/ui 3.0.3-canary.5abb7d5 → 3.1.1-canary.952fd26
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/exports/client/index.js +9 -9
- package/dist/exports/client/index.js.map +3 -3
- package/dist/fields/Blocks/index.d.ts.map +1 -1
- package/dist/fields/Blocks/index.js +1 -0
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts +2 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js +10 -0
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/index.d.ts +7 -1
- package/dist/forms/fieldSchemasToFormState/index.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/index.js +5 -0
- package/dist/forms/fieldSchemasToFormState/index.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/iterateFields.d.ts +3 -2
- package/dist/forms/fieldSchemasToFormState/iterateFields.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/iterateFields.js +2 -0
- package/dist/forms/fieldSchemasToFormState/iterateFields.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js +4 -3
- package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/types.d.ts +2 -1
- package/dist/forms/fieldSchemasToFormState/types.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/types.js.map +1 -1
- package/dist/providers/Locale/index.js +30 -29
- package/dist/providers/Locale/index.js.map +1 -1
- package/dist/utilities/buildClientFieldSchemaMap/index.d.ts +16 -0
- package/dist/utilities/buildClientFieldSchemaMap/index.d.ts.map +1 -0
- package/dist/utilities/buildClientFieldSchemaMap/index.js +72 -0
- package/dist/utilities/buildClientFieldSchemaMap/index.js.map +1 -0
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.d.ts +15 -0
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.d.ts.map +1 -0
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.js +129 -0
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.js.map +1 -0
- package/dist/utilities/buildFieldSchemaMap/traverseFields.d.ts.map +1 -1
- package/dist/utilities/buildFieldSchemaMap/traverseFields.js.map +1 -1
- package/dist/utilities/buildFormState.d.ts +1 -8
- package/dist/utilities/buildFormState.d.ts.map +1 -1
- package/dist/utilities/buildFormState.js +19 -41
- package/dist/utilities/buildFormState.js.map +1 -1
- package/dist/utilities/buildTableState.d.ts +1 -7
- package/dist/utilities/buildTableState.d.ts.map +1 -1
- package/dist/utilities/buildTableState.js +2 -21
- package/dist/utilities/buildTableState.js.map +1 -1
- package/dist/utilities/getClientConfig.d.ts +8 -0
- package/dist/utilities/getClientConfig.d.ts.map +1 -0
- package/dist/utilities/getClientConfig.js +25 -0
- package/dist/utilities/getClientConfig.js.map +1 -0
- package/dist/utilities/getClientSchemaMap.d.ts +11 -0
- package/dist/utilities/getClientSchemaMap.d.ts.map +1 -0
- package/dist/utilities/getClientSchemaMap.js +39 -0
- package/dist/utilities/getClientSchemaMap.js.map +1 -0
- package/dist/utilities/getSchemaMap.d.ts +9 -0
- package/dist/utilities/getSchemaMap.d.ts.map +1 -0
- package/dist/utilities/getSchemaMap.js +35 -0
- package/dist/utilities/getSchemaMap.js.map +1 -0
- package/dist/views/Edit/Auth/types.d.ts +2 -2
- package/dist/views/Edit/Auth/types.d.ts.map +1 -1
- package/dist/views/Edit/Auth/types.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildFormState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildFormState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"buildFormState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildFormState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAYnG,KAAK,2BAA2B,GAAG;IACjC,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,MAAM,CAAC,EAAE,KAAK,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IAC7F,KAAK,EAAE,SAAS,CAAA;CACjB,CAAA;AAED,KAAK,yBAAyB,GAAG;IAC/B,WAAW,CAAC,EAAE,KAAK,CAAA;IACnB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,GAAG,CACA;IACE,OAAO,EAAE,MAAM,CAAA;CAChB,GACD,WAAW,CACd,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,yBAAyB,GAAG,2BAA2B,CAAA;AAE1F,eAAO,MAAM,qBAAqB,SAC1B,kBAAkB,KACvB,OAAO,CAAC,oBAAoB,CAqD9B,CAAA;AAED,eAAO,MAAM,cAAc,SACnB,kBAAkB,KACvB,OAAO,CAAC,2BAA2B,CA4HrC,CAAA"}
|
|
@@ -2,45 +2,10 @@ import { formatErrors } from 'payload';
|
|
|
2
2
|
import { reduceFieldsToValues } from 'payload/shared';
|
|
3
3
|
import { fieldSchemasToFormState } from '../forms/fieldSchemasToFormState/index.js';
|
|
4
4
|
import { renderField } from '../forms/fieldSchemasToFormState/renderField.js';
|
|
5
|
-
import {
|
|
5
|
+
import { getClientConfig } from './getClientConfig.js';
|
|
6
|
+
import { getClientSchemaMap } from './getClientSchemaMap.js';
|
|
7
|
+
import { getSchemaMap } from './getSchemaMap.js';
|
|
6
8
|
import { handleFormStateLocking } from './handleFormStateLocking.js';
|
|
7
|
-
let cachedFieldMap = global._payload_fieldMap;
|
|
8
|
-
let cachedClientConfig = global._payload_clientConfig;
|
|
9
|
-
if (!cachedFieldMap) {
|
|
10
|
-
cachedFieldMap = global._payload_fieldMap = null;
|
|
11
|
-
}
|
|
12
|
-
if (!cachedClientConfig) {
|
|
13
|
-
cachedClientConfig = global._payload_clientConfig = null;
|
|
14
|
-
}
|
|
15
|
-
export const getFieldSchemaMap = args => {
|
|
16
|
-
const {
|
|
17
|
-
collectionSlug,
|
|
18
|
-
config,
|
|
19
|
-
globalSlug,
|
|
20
|
-
i18n
|
|
21
|
-
} = args;
|
|
22
|
-
if (process.env.NODE_ENV !== 'development') {
|
|
23
|
-
if (!cachedFieldMap) {
|
|
24
|
-
cachedFieldMap = new Map();
|
|
25
|
-
}
|
|
26
|
-
const cachedEntityFieldMap = cachedFieldMap.get(collectionSlug || globalSlug);
|
|
27
|
-
if (cachedEntityFieldMap) {
|
|
28
|
-
return cachedEntityFieldMap;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const {
|
|
32
|
-
fieldSchemaMap: entityFieldMap
|
|
33
|
-
} = buildFieldSchemaMap({
|
|
34
|
-
collectionSlug,
|
|
35
|
-
config,
|
|
36
|
-
globalSlug,
|
|
37
|
-
i18n: i18n
|
|
38
|
-
});
|
|
39
|
-
if (process.env.NODE_ENV !== 'development') {
|
|
40
|
-
cachedFieldMap.set(collectionSlug || globalSlug, entityFieldMap);
|
|
41
|
-
}
|
|
42
|
-
return entityFieldMap;
|
|
43
|
-
};
|
|
44
9
|
export const buildFormStateHandler = async args => {
|
|
45
10
|
const {
|
|
46
11
|
req
|
|
@@ -120,14 +85,26 @@ export const buildFormState = async args => {
|
|
|
120
85
|
if (!collectionSlug && !globalSlug) {
|
|
121
86
|
throw new Error('Either collectionSlug or globalSlug must be provided');
|
|
122
87
|
}
|
|
123
|
-
const
|
|
88
|
+
const schemaMap = getSchemaMap({
|
|
124
89
|
collectionSlug,
|
|
125
90
|
config,
|
|
126
91
|
globalSlug,
|
|
127
92
|
i18n
|
|
128
93
|
});
|
|
94
|
+
const clientSchemaMap = getClientSchemaMap({
|
|
95
|
+
collectionSlug,
|
|
96
|
+
config: getClientConfig({
|
|
97
|
+
config,
|
|
98
|
+
i18n,
|
|
99
|
+
importMap: req.payload.importMap
|
|
100
|
+
}),
|
|
101
|
+
globalSlug,
|
|
102
|
+
i18n,
|
|
103
|
+
payload,
|
|
104
|
+
schemaMap
|
|
105
|
+
});
|
|
129
106
|
const id = collectionSlug ? idFromArgs : undefined;
|
|
130
|
-
const fieldOrEntityConfig =
|
|
107
|
+
const fieldOrEntityConfig = schemaMap.get(schemaPath);
|
|
131
108
|
if (!fieldOrEntityConfig) {
|
|
132
109
|
throw new Error(`Could not find "${schemaPath}" in the fieldSchemaMap`);
|
|
133
110
|
}
|
|
@@ -151,10 +128,11 @@ export const buildFormState = async args => {
|
|
|
151
128
|
const fields = Array.isArray(fieldOrEntityConfig) ? fieldOrEntityConfig : 'fields' in fieldOrEntityConfig ? fieldOrEntityConfig.fields : [fieldOrEntityConfig];
|
|
152
129
|
const formStateResult = await fieldSchemasToFormState({
|
|
153
130
|
id,
|
|
131
|
+
clientFieldSchemaMap: clientSchemaMap,
|
|
154
132
|
collectionSlug,
|
|
155
133
|
data,
|
|
156
134
|
fields,
|
|
157
|
-
fieldSchemaMap,
|
|
135
|
+
fieldSchemaMap: schemaMap,
|
|
158
136
|
operation,
|
|
159
137
|
permissions: docPermissions?.fields || {},
|
|
160
138
|
preferences: docPreferences || {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildFormState.js","names":["formatErrors","reduceFieldsToValues","fieldSchemasToFormState","renderField","buildFieldSchemaMap","handleFormStateLocking","cachedFieldMap","global","_payload_fieldMap","cachedClientConfig","_payload_clientConfig","getFieldSchemaMap","args","collectionSlug","config","globalSlug","i18n","process","env","NODE_ENV","Map","cachedEntityFieldMap","get","fieldSchemaMap","entityFieldMap","set","buildFormStateHandler","req","incomingUserSlug","user","collection","adminUserSlug","payload","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","docs","length","res","buildFormState","err","logger","error","msg","message","id","idFromArgs","data","incomingData","docPermissions","docPreferences","formState","operation","renderAllFields","returnLockStatus","schemaPath","updateLastEdited","undefined","fieldOrEntityConfig","fields","type","Array","isArray","formStateResult","permissions","preferences","previousFormState","renderFieldFn","upload","file","lockedStateResult","lockedState","state"],"sources":["../../src/utilities/buildFormState.ts"],"sourcesContent":["import type { I18n, I18nClient } from '@payloadcms/translations'\nimport type {\n BuildFormStateArgs,\n ClientConfig,\n ClientUser,\n ErrorResult,\n FieldSchemaMap,\n FormState,\n SanitizedConfig,\n} from 'payload'\n\nimport { formatErrors } from 'payload'\nimport { reduceFieldsToValues } from 'payload/shared'\n\nimport { fieldSchemasToFormState } from '../forms/fieldSchemasToFormState/index.js'\nimport { renderField } from '../forms/fieldSchemasToFormState/renderField.js'\nimport { buildFieldSchemaMap } from './buildFieldSchemaMap/index.js'\nimport { handleFormStateLocking } from './handleFormStateLocking.js'\n\nlet cachedFieldMap = global._payload_fieldMap\nlet cachedClientConfig = global._payload_clientConfig\n\nif (!cachedFieldMap) {\n cachedFieldMap = global._payload_fieldMap = null\n}\n\nif (!cachedClientConfig) {\n cachedClientConfig = global._payload_clientConfig = null\n}\n\nexport const getFieldSchemaMap = (args: {\n collectionSlug?: string\n config: SanitizedConfig\n globalSlug?: string\n i18n: I18nClient\n}): FieldSchemaMap => {\n const { collectionSlug, config, globalSlug, i18n } = args\n\n if (process.env.NODE_ENV !== 'development') {\n if (!cachedFieldMap) {\n cachedFieldMap = new Map()\n }\n const cachedEntityFieldMap = cachedFieldMap.get(collectionSlug || globalSlug)\n if (cachedEntityFieldMap) {\n return cachedEntityFieldMap\n }\n }\n\n const { fieldSchemaMap: entityFieldMap } = buildFieldSchemaMap({\n collectionSlug,\n config,\n globalSlug,\n i18n: i18n as I18n,\n })\n\n if (process.env.NODE_ENV !== 'development') {\n cachedFieldMap.set(collectionSlug || globalSlug, entityFieldMap)\n }\n\n return entityFieldMap\n}\n\ntype BuildFormStateSuccessResult = {\n clientConfig?: ClientConfig\n errors?: never\n indexPath?: string\n lockedState?: { isLocked: boolean; lastEditedAt: string; user: ClientUser | number | string }\n state: FormState\n}\n\ntype BuildFormStateErrorResult = {\n lockedState?: never\n state?: never\n} & (\n | {\n message: string\n }\n | ErrorResult\n)\n\nexport type BuildFormStateResult = BuildFormStateErrorResult | BuildFormStateSuccessResult\n\nexport const buildFormStateHandler = async (\n args: BuildFormStateArgs,\n): Promise<BuildFormStateResult> => {\n const { req } = args\n\n const incomingUserSlug = req.user?.collection\n const adminUserSlug = req.payload.config.admin.user\n\n try {\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = req.payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await req.payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n\n const res = await buildFormState(args)\n return res\n } catch (err) {\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n if (err.message === 'Could not find field schema for given path') {\n return {\n message: err.message,\n }\n }\n\n if (err.message === 'Unauthorized') {\n return null\n }\n\n return formatErrors(err)\n }\n}\n\nexport const buildFormState = async (\n args: BuildFormStateArgs,\n): Promise<BuildFormStateSuccessResult> => {\n const {\n id: idFromArgs,\n collectionSlug,\n data: incomingData,\n docPermissions,\n docPreferences,\n formState,\n globalSlug,\n operation,\n renderAllFields,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n },\n returnLockStatus,\n schemaPath = collectionSlug || globalSlug,\n updateLastEdited,\n } = args\n\n let data = incomingData\n\n if (!collectionSlug && !globalSlug) {\n throw new Error('Either collectionSlug or globalSlug must be provided')\n }\n\n const fieldSchemaMap = getFieldSchemaMap({\n collectionSlug,\n config,\n globalSlug,\n i18n,\n })\n\n const id = collectionSlug ? idFromArgs : undefined\n const fieldOrEntityConfig = fieldSchemaMap.get(schemaPath)\n\n if (!fieldOrEntityConfig) {\n throw new Error(`Could not find \"${schemaPath}\" in the fieldSchemaMap`)\n }\n\n if (\n (!('fields' in fieldOrEntityConfig) ||\n !fieldOrEntityConfig.fields ||\n !fieldOrEntityConfig.fields.length) &&\n 'type' in fieldOrEntityConfig &&\n fieldOrEntityConfig.type !== 'blocks'\n ) {\n throw new Error(\n `The field found in fieldSchemaMap for \"${schemaPath}\" does not contain any subfields.`,\n )\n }\n\n // If there is a form state,\n // then we can deduce data from that form state\n if (formState) {\n data = reduceFieldsToValues(formState, true)\n }\n\n /**\n * When building state for sub schemas we need to adjust:\n * - `fields`\n * - `parentSchemaPath`\n * - `parentPath`\n *\n * Type assertion is fine because we wrap sub schemas in an array\n * so we can safely map over them within `fieldSchemasToFormState`\n */\n const fields = Array.isArray(fieldOrEntityConfig)\n ? fieldOrEntityConfig\n : 'fields' in fieldOrEntityConfig\n ? fieldOrEntityConfig.fields\n : [fieldOrEntityConfig]\n\n const formStateResult = await fieldSchemasToFormState({\n id,\n collectionSlug,\n data,\n fields,\n fieldSchemaMap,\n operation,\n permissions: docPermissions?.fields || {},\n preferences: docPreferences || { fields: {} },\n previousFormState: formState,\n renderAllFields,\n renderFieldFn: renderField,\n req,\n schemaPath,\n })\n\n // Maintain form state of auth / upload fields\n if (collectionSlug && formState) {\n if (payload.collections[collectionSlug]?.config?.upload && formState.file) {\n formStateResult.file = formState.file\n }\n }\n\n let lockedStateResult\n\n if (returnLockStatus) {\n lockedStateResult = await handleFormStateLocking({\n id,\n collectionSlug,\n globalSlug,\n req,\n updateLastEdited,\n })\n }\n\n return {\n lockedState: lockedStateResult,\n state: formStateResult,\n }\n}\n"],"mappings":"AAWA,SAASA,YAAY,QAAQ;AAC7B,SAASC,oBAAoB,QAAQ;AAErC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,WAAW,QAAQ;AAC5B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,sBAAsB,QAAQ;AAEvC,IAAIC,cAAA,GAAiBC,MAAA,CAAOC,iBAAiB;AAC7C,IAAIC,kBAAA,GAAqBF,MAAA,CAAOG,qBAAqB;AAErD,IAAI,CAACJ,cAAA,EAAgB;EACnBA,cAAA,GAAiBC,MAAA,CAAOC,iBAAiB,GAAG;AAC9C;AAEA,IAAI,CAACC,kBAAA,EAAoB;EACvBA,kBAAA,GAAqBF,MAAA,CAAOG,qBAAqB,GAAG;AACtD;AAEA,OAAO,MAAMC,iBAAA,GAAqBC,IAAA;EAMhC,MAAM;IAAEC,cAAc;IAAEC,MAAM;IAAEC,UAAU;IAAEC;EAAI,CAAE,GAAGJ,IAAA;EAErD,IAAIK,OAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;IAC1C,IAAI,CAACb,cAAA,EAAgB;MACnBA,cAAA,GAAiB,IAAIc,GAAA;IACvB;IACA,MAAMC,oBAAA,GAAuBf,cAAA,CAAegB,GAAG,CAACT,cAAA,IAAkBE,UAAA;IAClE,IAAIM,oBAAA,EAAsB;MACxB,OAAOA,oBAAA;IACT;EACF;EAEA,MAAM;IAAEE,cAAA,EAAgBC;EAAc,CAAE,GAAGpB,mBAAA,CAAoB;IAC7DS,cAAA;IACAC,MAAA;IACAC,UAAA;IACAC,IAAA,EAAMA;EACR;EAEA,IAAIC,OAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;IAC1Cb,cAAA,CAAemB,GAAG,CAACZ,cAAA,IAAkBE,UAAA,EAAYS,cAAA;EACnD;EAEA,OAAO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J,IAAA,GAAOtD,oBAAA,CAAqB0D,SAAA,EAAW;EACzC;EAEA;;;;;;;;;EASA,MAAMQ,MAAA,GAASE,KAAA,CAAMC,OAAO,CAACJ,mBAAA,IACzBA,mBAAA,GACA,YAAYA,mBAAA,GACVA,mBAAA,CAAoBC,MAAM,GAC1B,CAACD,mBAAA,CAAoB;EAE3B,MAAMK,eAAA,GAAkB,MAAMrE,uBAAA,CAAwB;IACpDmD,EAAA;IACAxC,cAAA;IACA0C,IAAA;IACAY,MAAA;IACA5C,cAAA;IACAqC,SAAA;IACAY,WAAA,EAAaf,cAAA,EAAgBU,MAAA,IAAU,CAAC;IACxCM,WAAA,EAAaf,cAAA,IAAkB;MAAES,MAAA,EAAQ,CAAC;IAAE;IAC5CO,iBAAA,EAAmBf,SAAA;IACnBE,eAAA;IACAc,aAAA,EAAexE,WAAA;IACfwB,GAAA;IACAoC;EACF;EAEA;EACA,IAAIlD,cAAA,IAAkB8C,SAAA,EAAW;IAC/B,IAAI3B,OAAA,CAAQG,WAAW,CAACtB,cAAA,CAAe,EAAEC,MAAA,EAAQ8D,MAAA,IAAUjB,SAAA,CAAUkB,IAAI,EAAE;MACzEN,eAAA,CAAgBM,IAAI,GAAGlB,SAAA,CAAUkB,IAAI;IACvC;EACF;EAEA,IAAIC,iBAAA;EAEJ,IAAIhB,gBAAA,EAAkB;IACpBgB,iBAAA,GAAoB,MAAMzE,sBAAA,CAAuB;MAC/CgD,EAAA;MACAxC,cAAA;MACAE,UAAA;MACAY,GAAA;MACAqC;IACF;EACF;EAEA,OAAO;IACLe,WAAA,EAAaD,iBAAA;IACbE,KAAA,EAAOT;EACT;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"buildFormState.js","names":["formatErrors","reduceFieldsToValues","fieldSchemasToFormState","renderField","getClientConfig","getClientSchemaMap","getSchemaMap","handleFormStateLocking","buildFormStateHandler","args","req","incomingUserSlug","user","collection","adminUserSlug","payload","config","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","docs","length","res","buildFormState","err","logger","error","msg","message","id","idFromArgs","collectionSlug","data","incomingData","docPermissions","docPreferences","formState","globalSlug","operation","renderAllFields","i18n","returnLockStatus","schemaPath","updateLastEdited","schemaMap","clientSchemaMap","importMap","undefined","fieldOrEntityConfig","get","fields","type","Array","isArray","formStateResult","clientFieldSchemaMap","fieldSchemaMap","permissions","preferences","previousFormState","renderFieldFn","upload","file","lockedStateResult","lockedState","state"],"sources":["../../src/utilities/buildFormState.ts"],"sourcesContent":["import type { BuildFormStateArgs, ClientConfig, ClientUser, ErrorResult, FormState } from 'payload'\n\nimport { formatErrors } from 'payload'\nimport { reduceFieldsToValues } from 'payload/shared'\n\nimport { fieldSchemasToFormState } from '../forms/fieldSchemasToFormState/index.js'\nimport { renderField } from '../forms/fieldSchemasToFormState/renderField.js'\nimport { getClientConfig } from './getClientConfig.js'\nimport { getClientSchemaMap } from './getClientSchemaMap.js'\nimport { getSchemaMap } from './getSchemaMap.js'\nimport { handleFormStateLocking } from './handleFormStateLocking.js'\n\ntype BuildFormStateSuccessResult = {\n clientConfig?: ClientConfig\n errors?: never\n indexPath?: string\n lockedState?: { isLocked: boolean; lastEditedAt: string; user: ClientUser | number | string }\n state: FormState\n}\n\ntype BuildFormStateErrorResult = {\n lockedState?: never\n state?: never\n} & (\n | {\n message: string\n }\n | ErrorResult\n)\n\nexport type BuildFormStateResult = BuildFormStateErrorResult | BuildFormStateSuccessResult\n\nexport const buildFormStateHandler = async (\n args: BuildFormStateArgs,\n): Promise<BuildFormStateResult> => {\n const { req } = args\n\n const incomingUserSlug = req.user?.collection\n const adminUserSlug = req.payload.config.admin.user\n\n try {\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = req.payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await req.payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n\n const res = await buildFormState(args)\n return res\n } catch (err) {\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n if (err.message === 'Could not find field schema for given path') {\n return {\n message: err.message,\n }\n }\n\n if (err.message === 'Unauthorized') {\n return null\n }\n\n return formatErrors(err)\n }\n}\n\nexport const buildFormState = async (\n args: BuildFormStateArgs,\n): Promise<BuildFormStateSuccessResult> => {\n const {\n id: idFromArgs,\n collectionSlug,\n data: incomingData,\n docPermissions,\n docPreferences,\n formState,\n globalSlug,\n operation,\n renderAllFields,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n },\n returnLockStatus,\n schemaPath = collectionSlug || globalSlug,\n updateLastEdited,\n } = args\n\n let data = incomingData\n\n if (!collectionSlug && !globalSlug) {\n throw new Error('Either collectionSlug or globalSlug must be provided')\n }\n\n const schemaMap = getSchemaMap({\n collectionSlug,\n config,\n globalSlug,\n i18n,\n })\n\n const clientSchemaMap = getClientSchemaMap({\n collectionSlug,\n config: getClientConfig({ config, i18n, importMap: req.payload.importMap }),\n globalSlug,\n i18n,\n payload,\n schemaMap,\n })\n\n const id = collectionSlug ? idFromArgs : undefined\n const fieldOrEntityConfig = schemaMap.get(schemaPath)\n\n if (!fieldOrEntityConfig) {\n throw new Error(`Could not find \"${schemaPath}\" in the fieldSchemaMap`)\n }\n\n if (\n (!('fields' in fieldOrEntityConfig) ||\n !fieldOrEntityConfig.fields ||\n !fieldOrEntityConfig.fields.length) &&\n 'type' in fieldOrEntityConfig &&\n fieldOrEntityConfig.type !== 'blocks'\n ) {\n throw new Error(\n `The field found in fieldSchemaMap for \"${schemaPath}\" does not contain any subfields.`,\n )\n }\n\n // If there is a form state,\n // then we can deduce data from that form state\n if (formState) {\n data = reduceFieldsToValues(formState, true)\n }\n\n /**\n * When building state for sub schemas we need to adjust:\n * - `fields`\n * - `parentSchemaPath`\n * - `parentPath`\n *\n * Type assertion is fine because we wrap sub schemas in an array\n * so we can safely map over them within `fieldSchemasToFormState`\n */\n const fields = Array.isArray(fieldOrEntityConfig)\n ? fieldOrEntityConfig\n : 'fields' in fieldOrEntityConfig\n ? fieldOrEntityConfig.fields\n : [fieldOrEntityConfig]\n\n const formStateResult = await fieldSchemasToFormState({\n id,\n clientFieldSchemaMap: clientSchemaMap,\n collectionSlug,\n data,\n fields,\n fieldSchemaMap: schemaMap,\n operation,\n permissions: docPermissions?.fields || {},\n preferences: docPreferences || { fields: {} },\n previousFormState: formState,\n renderAllFields,\n renderFieldFn: renderField,\n req,\n schemaPath,\n })\n\n // Maintain form state of auth / upload fields\n if (collectionSlug && formState) {\n if (payload.collections[collectionSlug]?.config?.upload && formState.file) {\n formStateResult.file = formState.file\n }\n }\n\n let lockedStateResult\n\n if (returnLockStatus) {\n lockedStateResult = await handleFormStateLocking({\n id,\n collectionSlug,\n globalSlug,\n req,\n updateLastEdited,\n })\n }\n\n return {\n lockedState: lockedStateResult,\n state: formStateResult,\n }\n}\n"],"mappings":"AAEA,SAASA,YAAY,QAAQ;AAC7B,SAASC,oBAAoB,QAAQ;AAErC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,WAAW,QAAQ;AAC5B,SAASC,eAAe,QAAQ;AAChC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,YAAY,QAAQ;AAC7B,SAASC,sBAAsB,QAAQ;AAsBvC,OAAO,MAAMC,qBAAA,GAAwB,MACnCC,IAAA;EAEA,MAAM;IAAEC;EAAG,CAAE,GAAGD,IAAA;EAEhB,MAAME,gBAAA,GAAmBD,GAAA,CAAIE,IAAI,EAAEC,UAAA;EACnC,MAAMC,aAAA,GAAgBJ,GAAA,CAAIK,OAAO,CAACC,MAAM,C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oBAAA,CAAqB2C,SAAA,EAAW;EACzC;EAEA;;;;;;;;;EASA,MAAMc,MAAA,GAASE,KAAA,CAAMC,OAAO,CAACL,mBAAA,IACzBA,mBAAA,GACA,YAAYA,mBAAA,GACVA,mBAAA,CAAoBE,MAAM,GAC1B,CAACF,mBAAA,CAAoB;EAE3B,MAAMM,eAAA,GAAkB,MAAM5D,uBAAA,CAAwB;IACpDmC,EAAA;IACA0B,oBAAA,EAAsBV,eAAA;IACtBd,cAAA;IACAC,IAAA;IACAkB,MAAA;IACAM,cAAA,EAAgBZ,SAAA;IAChBN,SAAA;IACAmB,WAAA,EAAavB,cAAA,EAAgBgB,MAAA,IAAU,CAAC;IACxCQ,WAAA,EAAavB,cAAA,IAAkB;MAAEe,MAAA,EAAQ,CAAC;IAAE;IAC5CS,iBAAA,EAAmBvB,SAAA;IACnBG,eAAA;IACAqB,aAAA,EAAejE,WAAA;IACfO,GAAA;IACAwC;EACF;EAEA;EACA,IAAIX,cAAA,IAAkBK,SAAA,EAAW;IAC/B,IAAI7B,OAAA,CAAQI,WAAW,CAACoB,cAAA,CAAe,EAAEvB,MAAA,EAAQqD,MAAA,IAAUzB,SAAA,CAAU0B,IAAI,EAAE;MACzER,eAAA,CAAgBQ,IAAI,GAAG1B,SAAA,CAAU0B,IAAI;IACvC;EACF;EAEA,IAAIC,iBAAA;EAEJ,IAAItB,gBAAA,EAAkB;IACpBsB,iBAAA,GAAoB,MAAMhE,sBAAA,CAAuB;MAC/C8B,EAAA;MACAE,cAAA;MACAM,UAAA;MACAnC,GAAA;MACAyC;IACF;EACF;EAEA,OAAO;IACLqB,WAAA,EAAaD,iBAAA;IACbE,KAAA,EAAOX;EACT;AACF","ignoreList":[]}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { BuildTableStateArgs, ClientConfig, ErrorResult, ImportMap, PaginatedDocs, SanitizedConfig } from 'payload';
|
|
1
|
+
import type { BuildTableStateArgs, ClientConfig, ErrorResult, PaginatedDocs } from 'payload';
|
|
3
2
|
import type { Column } from '../elements/Table/index.js';
|
|
4
3
|
import type { ListPreferences } from '../elements/TableColumns/index.js';
|
|
5
|
-
export declare const getClientConfig: (args: {
|
|
6
|
-
config: SanitizedConfig;
|
|
7
|
-
i18n: I18nClient;
|
|
8
|
-
importMap: ImportMap;
|
|
9
|
-
}) => ClientConfig;
|
|
10
4
|
type BuildTableStateSuccessResult = {
|
|
11
5
|
clientConfig?: ClientConfig;
|
|
12
6
|
data: PaginatedDocs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTableState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildTableState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"buildTableState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildTableState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EAEnB,YAAY,EACZ,WAAW,EACX,aAAa,EAEd,MAAM,SAAS,CAAA;AAKhB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AAKxE,KAAK,4BAA4B,GAAG;IAClC,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,IAAI,EAAE,aAAa,CAAA;IACnB,MAAM,CAAC,EAAE,KAAK,CAAA;IACd,WAAW,EAAE,eAAe,CAAA;IAC5B,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;IAC7C,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;CACvB,CAAA;AAED,KAAK,0BAA0B,GAAG;IAChC,IAAI,CAAC,EAAE,GAAG,CAAA;IACV,eAAe,CAAC,EAAE,KAAK,CAAA;IACvB,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,GAAG,CACA;IACE,OAAO,EAAE,MAAM,CAAA;CAChB,GACD,WAAW,CACd,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,0BAA0B,GAAG,4BAA4B,CAAA;AAE7F,eAAO,MAAM,sBAAsB,SAC3B,mBAAmB,KACxB,OAAO,CAAC,qBAAqB,CAqB/B,CAAA;AAED,eAAO,MAAM,eAAe,SACpB,mBAAmB,KACxB,OAAO,CAAC,4BAA4B,CA8KtC,CAAA"}
|
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
import { dequal } from 'dequal'; // TODO: Can we change this to dequal/lite ? If not, please add comment explaining why
|
|
2
|
-
import {
|
|
2
|
+
import { formatErrors } from 'payload';
|
|
3
|
+
import { getClientConfig } from './getClientConfig.js';
|
|
3
4
|
import { renderFilters, renderTable } from './renderTable.js';
|
|
4
|
-
let cachedClientConfig = global._payload_clientConfig;
|
|
5
|
-
if (!cachedClientConfig) {
|
|
6
|
-
cachedClientConfig = global._payload_clientConfig = null;
|
|
7
|
-
}
|
|
8
|
-
export const getClientConfig = args => {
|
|
9
|
-
const {
|
|
10
|
-
config,
|
|
11
|
-
i18n,
|
|
12
|
-
importMap
|
|
13
|
-
} = args;
|
|
14
|
-
if (cachedClientConfig && process.env.NODE_ENV !== 'development') {
|
|
15
|
-
return cachedClientConfig;
|
|
16
|
-
}
|
|
17
|
-
cachedClientConfig = createClientConfig({
|
|
18
|
-
config,
|
|
19
|
-
i18n,
|
|
20
|
-
importMap
|
|
21
|
-
});
|
|
22
|
-
return cachedClientConfig;
|
|
23
|
-
};
|
|
24
5
|
export const buildTableStateHandler = async args => {
|
|
25
6
|
const {
|
|
26
7
|
req
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTableState.js","names":["dequal","createClientConfig","formatErrors","renderFilters","renderTable","cachedClientConfig","global","_payload_clientConfig","getClientConfig","args","config","i18n","importMap","process","env","NODE_ENV","buildTableStateHandler","req","res","buildTableState","err","payload","logger","error","msg","message","collectionSlug","columns","docs","docsFromArgs","enableRowSelections","query","renderRowTypes","user","tableAppearance","incomingUserSlug","collection","adminUserSlug","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","length","clientConfig","collectionConfig","clientCollectionConfig","slug","preferencesKey","preferencesResult","where","and","key","equals","id","then","value","newPrefs","mergedPrefs","preferencesArgs","data","update","create","fields","parseInt","undefined","page","sort","columnState","Table","columnPreferences","useAsTitle","renderedFilters","preferences","state"],"sources":["../../src/utilities/buildTableState.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n BuildTableStateArgs,\n ClientCollectionConfig,\n ClientConfig,\n ErrorResult,\n ImportMap,\n PaginatedDocs,\n SanitizedCollectionConfig,\n SanitizedConfig,\n} from 'payload'\n\nimport { dequal } from 'dequal' // TODO: Can we change this to dequal/lite ? If not, please add comment explaining why\nimport { createClientConfig, formatErrors } from 'payload'\n\nimport type { Column } from '../elements/Table/index.js'\nimport type { ListPreferences } from '../elements/TableColumns/index.js'\n\nimport { renderFilters, renderTable } from './renderTable.js'\n\nlet cachedClientConfig = global._payload_clientConfig\n\nif (!cachedClientConfig) {\n cachedClientConfig = global._payload_clientConfig = null\n}\n\nexport const getClientConfig = (args: {\n config: SanitizedConfig\n i18n: I18nClient\n importMap: ImportMap\n}): ClientConfig => {\n const { config, i18n, importMap } = args\n\n if (cachedClientConfig && process.env.NODE_ENV !== 'development') {\n return cachedClientConfig\n }\n\n cachedClientConfig = createClientConfig({\n config,\n i18n,\n importMap,\n })\n\n return cachedClientConfig\n}\n\ntype BuildTableStateSuccessResult = {\n clientConfig?: ClientConfig\n data: PaginatedDocs\n errors?: never\n preferences: ListPreferences\n renderedFilters: Map<string, React.ReactNode>\n state: Column[]\n Table: React.ReactNode\n}\n\ntype BuildTableStateErrorResult = {\n data?: any\n renderedFilters?: never\n state?: never\n Table?: never\n} & (\n | {\n message: string\n }\n | ErrorResult\n)\n\nexport type BuildTableStateResult = BuildTableStateErrorResult | BuildTableStateSuccessResult\n\nexport const buildTableStateHandler = async (\n args: BuildTableStateArgs,\n): Promise<BuildTableStateResult> => {\n const { req } = args\n\n try {\n const res = await buildTableState(args)\n return res\n } catch (err) {\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n if (err.message === 'Could not find field schema for given path') {\n return {\n message: err.message,\n }\n }\n\n if (err.message === 'Unauthorized') {\n return null\n }\n\n return formatErrors(err)\n }\n}\n\nexport const buildTableState = async (\n args: BuildTableStateArgs,\n): Promise<BuildTableStateSuccessResult> => {\n const {\n collectionSlug,\n columns,\n docs: docsFromArgs,\n enableRowSelections,\n query,\n renderRowTypes,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n tableAppearance,\n } = args\n\n const incomingUserSlug = user?.collection\n\n const adminUserSlug = config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: payload.importMap,\n })\n\n let collectionConfig: SanitizedCollectionConfig\n let clientCollectionConfig: ClientCollectionConfig\n\n if (req.payload.collections[collectionSlug]) {\n collectionConfig = req.payload.collections[collectionSlug].config\n clientCollectionConfig = clientConfig.collections.find(\n (collection) => collection.slug === collectionSlug,\n )\n }\n\n // get prefs, then set update them using the columns that we just received\n const preferencesKey = `${collectionSlug}-list`\n\n const preferencesResult = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n pagination: false,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0] ?? { id: null, value: {} })\n\n let newPrefs = preferencesResult.value\n\n if (!preferencesResult.id || !dequal(columns, preferencesResult?.columns)) {\n const mergedPrefs = {\n ...(preferencesResult || {}),\n columns,\n }\n const preferencesArgs = {\n collection: 'payload-preferences',\n data: {\n key: preferencesKey,\n user: {\n collection: user.collection,\n value: user.id,\n },\n value: mergedPrefs,\n },\n depth: 0,\n req,\n }\n\n if (preferencesResult.id) {\n newPrefs = await payload\n .update({\n ...preferencesArgs,\n id: preferencesResult.id,\n })\n ?.then((res) => res.value as ListPreferences)\n } else {\n newPrefs = await payload.create(preferencesArgs)?.then((res) => res.value as ListPreferences)\n }\n }\n\n const fields = collectionConfig.fields\n\n let docs = docsFromArgs\n let data: PaginatedDocs\n\n // lookup docs, if desired, i.e. within `join` field which initialize with `depth: 0`\n\n if (!docs || query) {\n data = await payload.find({\n collection: collectionSlug,\n depth: 0,\n limit: query?.limit ? parseInt(query.limit, 10) : undefined,\n page: query?.page ? parseInt(query.page, 10) : undefined,\n sort: query?.sort,\n where: query?.where,\n })\n\n docs = data.docs\n }\n\n const { columnState, Table } = renderTable({\n collectionConfig: clientCollectionConfig,\n columnPreferences: undefined, // TODO, might not be needed\n columns,\n docs,\n enableRowSelections,\n fields,\n i18n: req.i18n,\n payload,\n renderRowTypes,\n tableAppearance,\n useAsTitle: collectionConfig.admin.useAsTitle,\n })\n\n const renderedFilters = renderFilters(fields, req.payload.importMap)\n\n return {\n data,\n preferences: newPrefs,\n renderedFilters,\n state: columnState,\n Table,\n }\n}\n"],"mappings":"AAYA,SAASA,MAAM,QAAQ,SAAQ,CAAC;AAChC,SAASC,kBAAkB,EAAEC,YAAY,QAAQ;AAKjD,SAASC,a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IACAE,KAAA,EAAON,WAAA;IACPC;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"buildTableState.js","names":["dequal","formatErrors","getClientConfig","renderFilters","renderTable","buildTableStateHandler","args","req","res","buildTableState","err","payload","logger","error","msg","message","collectionSlug","columns","docs","docsFromArgs","enableRowSelections","query","renderRowTypes","i18n","config","user","tableAppearance","incomingUserSlug","collection","adminUserSlug","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","length","clientConfig","importMap","collectionConfig","clientCollectionConfig","slug","preferencesKey","preferencesResult","where","and","key","equals","id","then","value","newPrefs","mergedPrefs","preferencesArgs","data","update","create","fields","parseInt","undefined","page","sort","columnState","Table","columnPreferences","useAsTitle","renderedFilters","preferences","state"],"sources":["../../src/utilities/buildTableState.ts"],"sourcesContent":["import type {\n BuildTableStateArgs,\n ClientCollectionConfig,\n ClientConfig,\n ErrorResult,\n PaginatedDocs,\n SanitizedCollectionConfig,\n} from 'payload'\n\nimport { dequal } from 'dequal' // TODO: Can we change this to dequal/lite ? If not, please add comment explaining why\nimport { formatErrors } from 'payload'\n\nimport type { Column } from '../elements/Table/index.js'\nimport type { ListPreferences } from '../elements/TableColumns/index.js'\n\nimport { getClientConfig } from './getClientConfig.js'\nimport { renderFilters, renderTable } from './renderTable.js'\n\ntype BuildTableStateSuccessResult = {\n clientConfig?: ClientConfig\n data: PaginatedDocs\n errors?: never\n preferences: ListPreferences\n renderedFilters: Map<string, React.ReactNode>\n state: Column[]\n Table: React.ReactNode\n}\n\ntype BuildTableStateErrorResult = {\n data?: any\n renderedFilters?: never\n state?: never\n Table?: never\n} & (\n | {\n message: string\n }\n | ErrorResult\n)\n\nexport type BuildTableStateResult = BuildTableStateErrorResult | BuildTableStateSuccessResult\n\nexport const buildTableStateHandler = async (\n args: BuildTableStateArgs,\n): Promise<BuildTableStateResult> => {\n const { req } = args\n\n try {\n const res = await buildTableState(args)\n return res\n } catch (err) {\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n if (err.message === 'Could not find field schema for given path') {\n return {\n message: err.message,\n }\n }\n\n if (err.message === 'Unauthorized') {\n return null\n }\n\n return formatErrors(err)\n }\n}\n\nexport const buildTableState = async (\n args: BuildTableStateArgs,\n): Promise<BuildTableStateSuccessResult> => {\n const {\n collectionSlug,\n columns,\n docs: docsFromArgs,\n enableRowSelections,\n query,\n renderRowTypes,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n tableAppearance,\n } = args\n\n const incomingUserSlug = user?.collection\n\n const adminUserSlug = config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: payload.importMap,\n })\n\n let collectionConfig: SanitizedCollectionConfig\n let clientCollectionConfig: ClientCollectionConfig\n\n if (req.payload.collections[collectionSlug]) {\n collectionConfig = req.payload.collections[collectionSlug].config\n clientCollectionConfig = clientConfig.collections.find(\n (collection) => collection.slug === collectionSlug,\n )\n }\n\n // get prefs, then set update them using the columns that we just received\n const preferencesKey = `${collectionSlug}-list`\n\n const preferencesResult = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n pagination: false,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0] ?? { id: null, value: {} })\n\n let newPrefs = preferencesResult.value\n\n if (!preferencesResult.id || !dequal(columns, preferencesResult?.columns)) {\n const mergedPrefs = {\n ...(preferencesResult || {}),\n columns,\n }\n const preferencesArgs = {\n collection: 'payload-preferences',\n data: {\n key: preferencesKey,\n user: {\n collection: user.collection,\n value: user.id,\n },\n value: mergedPrefs,\n },\n depth: 0,\n req,\n }\n\n if (preferencesResult.id) {\n newPrefs = await payload\n .update({\n ...preferencesArgs,\n id: preferencesResult.id,\n })\n ?.then((res) => res.value as ListPreferences)\n } else {\n newPrefs = await payload.create(preferencesArgs)?.then((res) => res.value as ListPreferences)\n }\n }\n\n const fields = collectionConfig.fields\n\n let docs = docsFromArgs\n let data: PaginatedDocs\n\n // lookup docs, if desired, i.e. within `join` field which initialize with `depth: 0`\n\n if (!docs || query) {\n data = await payload.find({\n collection: collectionSlug,\n depth: 0,\n limit: query?.limit ? parseInt(query.limit, 10) : undefined,\n page: query?.page ? parseInt(query.page, 10) : undefined,\n sort: query?.sort,\n where: query?.where,\n })\n\n docs = data.docs\n }\n\n const { columnState, Table } = renderTable({\n collectionConfig: clientCollectionConfig,\n columnPreferences: undefined, // TODO, might not be needed\n columns,\n docs,\n enableRowSelections,\n fields,\n i18n: req.i18n,\n payload,\n renderRowTypes,\n tableAppearance,\n useAsTitle: collectionConfig.admin.useAsTitle,\n })\n\n const renderedFilters = renderFilters(fields, req.payload.importMap)\n\n return {\n data,\n preferences: newPrefs,\n renderedFilters,\n state: columnState,\n Table,\n }\n}\n"],"mappings":"AASA,SAASA,MAAM,QAAQ,SAAQ,CAAC;AAChC,SAASC,YAAY,QAAQ;AAK7B,SAASC,eAAe,QAAQ;AAChC,SAASC,aAAa,EAAEC,WAAW,QAAQ;AA0B3C,OAAO,MAAMC,sBAAA,GAAyB,MACpCC,IAAA;EAEA,MAAM;IAAEC;EAAG,CAAE,GAAGD,IAAA;EAEhB,IAAI;IACF,MAAME,GAAA,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4C,IAAI,EAAE,MAAMD,SAAA;MAC/CE,IAAA,EAAM7C,KAAA,EAAO6C,IAAA;MACbjB,KAAA,EAAO5B,KAAA,EAAO4B;IAChB;IAEA/B,IAAA,GAAOyC,IAAA,CAAKzC,IAAI;EAClB;EAEA,MAAM;IAAEiD,WAAW;IAAEC;EAAK,CAAE,GAAGhE,WAAA,CAAY;IACzCwC,gBAAA,EAAkBC,sBAAA;IAClBwB,iBAAA,EAAmBL,SAAA;IACnB/C,OAAA;IACAC,IAAA;IACAE,mBAAA;IACA0C,MAAA;IACAvC,IAAA,EAAMhB,GAAA,CAAIgB,IAAI;IACdZ,OAAA;IACAW,cAAA;IACAI,eAAA;IACA4C,UAAA,EAAY1B,gBAAA,CAAiBd,KAAK,CAACwC;EACrC;EAEA,MAAMC,eAAA,GAAkBpE,aAAA,CAAc2D,MAAA,EAAQvD,GAAA,CAAII,OAAO,CAACgC,SAAS;EAEnE,OAAO;IACLgB,IAAA;IACAa,WAAA,EAAahB,QAAA;IACbe,eAAA;IACAE,KAAA,EAAON,WAAA;IACPC;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
+
import type { ClientConfig, ImportMap, SanitizedConfig } from 'payload';
|
|
3
|
+
export declare const getClientConfig: (args: {
|
|
4
|
+
config: SanitizedConfig;
|
|
5
|
+
i18n: I18nClient;
|
|
6
|
+
importMap: ImportMap;
|
|
7
|
+
}) => ClientConfig;
|
|
8
|
+
//# sourceMappingURL=getClientConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getClientConfig.d.ts","sourceRoot":"","sources":["../../src/utilities/getClientConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAWvE,eAAO,MAAM,eAAe,SACnB;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,KAAG,YAiB9E,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createClientConfig } from 'payload';
|
|
2
|
+
import { cache } from 'react';
|
|
3
|
+
let cachedClientConfig = global._payload_clientConfig;
|
|
4
|
+
if (!cachedClientConfig) {
|
|
5
|
+
cachedClientConfig = global._payload_clientConfig = null;
|
|
6
|
+
}
|
|
7
|
+
export const getClientConfig = cache(args => {
|
|
8
|
+
if (cachedClientConfig && !global._payload_doNotCacheClientConfig) {
|
|
9
|
+
return cachedClientConfig;
|
|
10
|
+
}
|
|
11
|
+
const {
|
|
12
|
+
config,
|
|
13
|
+
i18n,
|
|
14
|
+
importMap
|
|
15
|
+
} = args;
|
|
16
|
+
cachedClientConfig = createClientConfig({
|
|
17
|
+
config,
|
|
18
|
+
i18n,
|
|
19
|
+
importMap
|
|
20
|
+
});
|
|
21
|
+
global._payload_clientConfig = cachedClientConfig;
|
|
22
|
+
global._payload_doNotCacheClientConfig = false;
|
|
23
|
+
return cachedClientConfig;
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=getClientConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getClientConfig.js","names":["createClientConfig","cache","cachedClientConfig","global","_payload_clientConfig","getClientConfig","args","_payload_doNotCacheClientConfig","config","i18n","importMap"],"sources":["../../src/utilities/getClientConfig.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { ClientConfig, ImportMap, SanitizedConfig } from 'payload'\n\nimport { createClientConfig } from 'payload'\nimport { cache } from 'react'\n\nlet cachedClientConfig = global._payload_clientConfig\n\nif (!cachedClientConfig) {\n cachedClientConfig = global._payload_clientConfig = null\n}\n\nexport const getClientConfig = cache(\n (args: { config: SanitizedConfig; i18n: I18nClient; importMap: ImportMap }): ClientConfig => {\n if (cachedClientConfig && !global._payload_doNotCacheClientConfig) {\n return cachedClientConfig\n }\n const { config, i18n, importMap } = args\n\n cachedClientConfig = createClientConfig({\n config,\n i18n,\n importMap,\n })\n global._payload_clientConfig = cachedClientConfig\n\n global._payload_doNotCacheClientConfig = false\n\n return cachedClientConfig\n },\n)\n"],"mappings":"AAGA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,KAAK,QAAQ;AAEtB,IAAIC,kBAAA,GAAqBC,MAAA,CAAOC,qBAAqB;AAErD,IAAI,CAACF,kBAAA,EAAoB;EACvBA,kBAAA,GAAqBC,MAAA,CAAOC,qBAAqB,GAAG;AACtD;AAEA,OAAO,MAAMC,eAAA,GAAkBJ,KAAA,CAC5BK,IAAA;EACC,IAAIJ,kBAAA,IAAsB,CAACC,MAAA,CAAOI,+BAA+B,EAAE;IACjE,OAAOL,kBAAA;EACT;EACA,MAAM;IAAEM,MAAM;IAAEC,IAAI;IAAEC;EAAS,CAAE,GAAGJ,IAAA;EAEpCJ,kBAAA,GAAqBF,kBAAA,CAAmB;IACtCQ,MAAA;IACAC,IAAA;IACAC;EACF;EACAP,MAAA,CAAOC,qBAAqB,GAAGF,kBAAA;EAE/BC,MAAA,CAAOI,+BAA+B,GAAG;EAEzC,OAAOL,kBAAA;AACT","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
+
import type { ClientConfig, ClientFieldSchemaMap, FieldSchemaMap, Payload } from 'payload';
|
|
3
|
+
export declare const getClientSchemaMap: (args: {
|
|
4
|
+
collectionSlug?: string;
|
|
5
|
+
config: ClientConfig;
|
|
6
|
+
globalSlug?: string;
|
|
7
|
+
i18n: I18nClient;
|
|
8
|
+
payload: Payload;
|
|
9
|
+
schemaMap: FieldSchemaMap;
|
|
10
|
+
}) => ClientFieldSchemaMap;
|
|
11
|
+
//# sourceMappingURL=getClientSchemaMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getClientSchemaMap.d.ts","sourceRoot":"","sources":["../../src/utilities/getClientSchemaMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAY1F,eAAO,MAAM,kBAAkB,SACtB;IACL,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,YAAY,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,cAAc,CAAA;CAC1B,KAAG,oBAgCL,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { cache } from 'react';
|
|
2
|
+
import { buildClientFieldSchemaMap } from './buildClientFieldSchemaMap/index.js';
|
|
3
|
+
let cachedClientSchemaMap = global._payload_clientSchemaMap;
|
|
4
|
+
if (!cachedClientSchemaMap) {
|
|
5
|
+
cachedClientSchemaMap = global._payload_clientSchemaMap = null;
|
|
6
|
+
}
|
|
7
|
+
export const getClientSchemaMap = cache(args => {
|
|
8
|
+
const {
|
|
9
|
+
collectionSlug,
|
|
10
|
+
config,
|
|
11
|
+
globalSlug,
|
|
12
|
+
i18n,
|
|
13
|
+
payload,
|
|
14
|
+
schemaMap
|
|
15
|
+
} = args;
|
|
16
|
+
if (!cachedClientSchemaMap || global._payload_doNotCacheClientSchemaMap) {
|
|
17
|
+
cachedClientSchemaMap = new Map();
|
|
18
|
+
}
|
|
19
|
+
let cachedEntityClientFieldMap = cachedClientSchemaMap.get(collectionSlug || globalSlug);
|
|
20
|
+
if (cachedEntityClientFieldMap) {
|
|
21
|
+
return cachedEntityClientFieldMap;
|
|
22
|
+
}
|
|
23
|
+
cachedEntityClientFieldMap = new Map();
|
|
24
|
+
const {
|
|
25
|
+
clientFieldSchemaMap: entityClientFieldMap
|
|
26
|
+
} = buildClientFieldSchemaMap({
|
|
27
|
+
collectionSlug,
|
|
28
|
+
config,
|
|
29
|
+
globalSlug,
|
|
30
|
+
i18n: i18n,
|
|
31
|
+
payload,
|
|
32
|
+
schemaMap
|
|
33
|
+
});
|
|
34
|
+
cachedClientSchemaMap.set(collectionSlug || globalSlug, entityClientFieldMap);
|
|
35
|
+
global._payload_clientSchemaMap = cachedClientSchemaMap;
|
|
36
|
+
global._payload_doNotCacheClientSchemaMap = false;
|
|
37
|
+
return entityClientFieldMap;
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=getClientSchemaMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getClientSchemaMap.js","names":["cache","buildClientFieldSchemaMap","cachedClientSchemaMap","global","_payload_clientSchemaMap","getClientSchemaMap","args","collectionSlug","config","globalSlug","i18n","payload","schemaMap","_payload_doNotCacheClientSchemaMap","Map","cachedEntityClientFieldMap","get","clientFieldSchemaMap","entityClientFieldMap","set"],"sources":["../../src/utilities/getClientSchemaMap.ts"],"sourcesContent":["import type { I18n, I18nClient } from '@payloadcms/translations'\nimport type { ClientConfig, ClientFieldSchemaMap, FieldSchemaMap, Payload } from 'payload'\n\nimport { cache } from 'react'\n\nimport { buildClientFieldSchemaMap } from './buildClientFieldSchemaMap/index.js'\n\nlet cachedClientSchemaMap = global._payload_clientSchemaMap\n\nif (!cachedClientSchemaMap) {\n cachedClientSchemaMap = global._payload_clientSchemaMap = null\n}\n\nexport const getClientSchemaMap = cache(\n (args: {\n collectionSlug?: string\n config: ClientConfig\n globalSlug?: string\n i18n: I18nClient\n payload: Payload\n schemaMap: FieldSchemaMap\n }): ClientFieldSchemaMap => {\n const { collectionSlug, config, globalSlug, i18n, payload, schemaMap } = args\n\n if (!cachedClientSchemaMap || global._payload_doNotCacheClientSchemaMap) {\n cachedClientSchemaMap = new Map()\n }\n\n let cachedEntityClientFieldMap = cachedClientSchemaMap.get(collectionSlug || globalSlug)\n\n if (cachedEntityClientFieldMap) {\n return cachedEntityClientFieldMap\n }\n\n cachedEntityClientFieldMap = new Map()\n\n const { clientFieldSchemaMap: entityClientFieldMap } = buildClientFieldSchemaMap({\n collectionSlug,\n config,\n globalSlug,\n i18n: i18n as I18n,\n payload,\n schemaMap,\n })\n\n cachedClientSchemaMap.set(collectionSlug || globalSlug, entityClientFieldMap)\n\n global._payload_clientSchemaMap = cachedClientSchemaMap\n\n global._payload_doNotCacheClientSchemaMap = false\n\n return entityClientFieldMap\n },\n)\n"],"mappings":"AAGA,SAASA,KAAK,QAAQ;AAEtB,SAASC,yBAAyB,QAAQ;AAE1C,IAAIC,qBAAA,GAAwBC,MAAA,CAAOC,wBAAwB;AAE3D,IAAI,CAACF,qBAAA,EAAuB;EAC1BA,qBAAA,GAAwBC,MAAA,CAAOC,wBAAwB,GAAG;AAC5D;AAEA,OAAO,MAAMC,kBAAA,GAAqBL,KAAA,CAC/BM,IAAA;EAQC,MAAM;IAAEC,cAAc;IAAEC,MAAM;IAAEC,UAAU;IAAEC,IAAI;IAAEC,OAAO;IAAEC;EAAS,CAAE,GAAGN,IAAA;EAEzE,IAAI,CAACJ,qBAAA,IAAyBC,MAAA,CAAOU,kCAAkC,EAAE;IACvEX,qBAAA,GAAwB,IAAIY,GAAA;EAC9B;EAEA,IAAIC,0BAAA,GAA6Bb,qBAAA,CAAsBc,GAAG,CAACT,cAAA,IAAkBE,UAAA;EAE7E,IAAIM,0BAAA,EAA4B;IAC9B,OAAOA,0BAAA;EACT;EAEAA,0BAAA,GAA6B,IAAID,GAAA;EAEjC,MAAM;IAAEG,oBAAA,EAAsBC;EAAoB,CAAE,GAAGjB,yBAAA,CAA0B;IAC/EM,cAAA;IACAC,MAAA;IACAC,UAAA;IACAC,IAAA,EAAMA,IAAA;IACNC,OAAA;IACAC;EACF;EAEAV,qBAAA,CAAsBiB,GAAG,CAACZ,cAAA,IAAkBE,UAAA,EAAYS,oBAAA;EAExDf,MAAA,CAAOC,wBAAwB,GAAGF,qBAAA;EAElCC,MAAA,CAAOU,kCAAkC,GAAG;EAE5C,OAAOK,oBAAA;AACT","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
+
import type { FieldSchemaMap, SanitizedConfig } from 'payload';
|
|
3
|
+
export declare const getSchemaMap: (args: {
|
|
4
|
+
collectionSlug?: string;
|
|
5
|
+
config: SanitizedConfig;
|
|
6
|
+
globalSlug?: string;
|
|
7
|
+
i18n: I18nClient;
|
|
8
|
+
}) => FieldSchemaMap;
|
|
9
|
+
//# sourceMappingURL=getSchemaMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSchemaMap.d.ts","sourceRoot":"","sources":["../../src/utilities/getSchemaMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAY9D,eAAO,MAAM,YAAY,SAChB;IACL,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,eAAe,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,UAAU,CAAA;CACjB,KAAG,cA8BL,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { cache } from 'react';
|
|
2
|
+
import { buildFieldSchemaMap } from './buildFieldSchemaMap/index.js';
|
|
3
|
+
let cachedSchemaMap = global._payload_schemaMap;
|
|
4
|
+
if (!cachedSchemaMap) {
|
|
5
|
+
cachedSchemaMap = global._payload_schemaMap = null;
|
|
6
|
+
}
|
|
7
|
+
export const getSchemaMap = cache(args => {
|
|
8
|
+
const {
|
|
9
|
+
collectionSlug,
|
|
10
|
+
config,
|
|
11
|
+
globalSlug,
|
|
12
|
+
i18n
|
|
13
|
+
} = args;
|
|
14
|
+
if (!cachedSchemaMap || global._payload_doNotCacheSchemaMap) {
|
|
15
|
+
cachedSchemaMap = new Map();
|
|
16
|
+
}
|
|
17
|
+
let cachedEntityFieldMap = cachedSchemaMap.get(collectionSlug || globalSlug);
|
|
18
|
+
if (cachedEntityFieldMap) {
|
|
19
|
+
return cachedEntityFieldMap;
|
|
20
|
+
}
|
|
21
|
+
cachedEntityFieldMap = new Map();
|
|
22
|
+
const {
|
|
23
|
+
fieldSchemaMap: entityFieldMap
|
|
24
|
+
} = buildFieldSchemaMap({
|
|
25
|
+
collectionSlug,
|
|
26
|
+
config,
|
|
27
|
+
globalSlug,
|
|
28
|
+
i18n: i18n
|
|
29
|
+
});
|
|
30
|
+
cachedSchemaMap.set(collectionSlug || globalSlug, entityFieldMap);
|
|
31
|
+
global._payload_schemaMap = cachedSchemaMap;
|
|
32
|
+
global._payload_doNotCacheSchemaMap = false;
|
|
33
|
+
return entityFieldMap;
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=getSchemaMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSchemaMap.js","names":["cache","buildFieldSchemaMap","cachedSchemaMap","global","_payload_schemaMap","getSchemaMap","args","collectionSlug","config","globalSlug","i18n","_payload_doNotCacheSchemaMap","Map","cachedEntityFieldMap","get","fieldSchemaMap","entityFieldMap","set"],"sources":["../../src/utilities/getSchemaMap.ts"],"sourcesContent":["import type { I18n, I18nClient } from '@payloadcms/translations'\nimport type { FieldSchemaMap, SanitizedConfig } from 'payload'\n\nimport { cache } from 'react'\n\nimport { buildFieldSchemaMap } from './buildFieldSchemaMap/index.js'\n\nlet cachedSchemaMap = global._payload_schemaMap\n\nif (!cachedSchemaMap) {\n cachedSchemaMap = global._payload_schemaMap = null\n}\n\nexport const getSchemaMap = cache(\n (args: {\n collectionSlug?: string\n config: SanitizedConfig\n globalSlug?: string\n i18n: I18nClient\n }): FieldSchemaMap => {\n const { collectionSlug, config, globalSlug, i18n } = args\n\n if (!cachedSchemaMap || global._payload_doNotCacheSchemaMap) {\n cachedSchemaMap = new Map()\n }\n\n let cachedEntityFieldMap = cachedSchemaMap.get(collectionSlug || globalSlug)\n\n if (cachedEntityFieldMap) {\n return cachedEntityFieldMap\n }\n\n cachedEntityFieldMap = new Map()\n\n const { fieldSchemaMap: entityFieldMap } = buildFieldSchemaMap({\n collectionSlug,\n config,\n globalSlug,\n i18n: i18n as I18n,\n })\n\n cachedSchemaMap.set(collectionSlug || globalSlug, entityFieldMap)\n\n global._payload_schemaMap = cachedSchemaMap\n\n global._payload_doNotCacheSchemaMap = false\n\n return entityFieldMap\n },\n)\n"],"mappings":"AAGA,SAASA,KAAK,QAAQ;AAEtB,SAASC,mBAAmB,QAAQ;AAEpC,IAAIC,eAAA,GAAkBC,MAAA,CAAOC,kBAAkB;AAE/C,IAAI,CAACF,eAAA,EAAiB;EACpBA,eAAA,GAAkBC,MAAA,CAAOC,kBAAkB,GAAG;AAChD;AAEA,OAAO,MAAMC,YAAA,GAAeL,KAAA,CACzBM,IAAA;EAMC,MAAM;IAAEC,cAAc;IAAEC,MAAM;IAAEC,UAAU;IAAEC;EAAI,CAAE,GAAGJ,IAAA;EAErD,IAAI,CAACJ,eAAA,IAAmBC,MAAA,CAAOQ,4BAA4B,EAAE;IAC3DT,eAAA,GAAkB,IAAIU,GAAA;EACxB;EAEA,IAAIC,oBAAA,GAAuBX,eAAA,CAAgBY,GAAG,CAACP,cAAA,IAAkBE,UAAA;EAEjE,IAAII,oBAAA,EAAsB;IACxB,OAAOA,oBAAA;EACT;EAEAA,oBAAA,GAAuB,IAAID,GAAA;EAE3B,MAAM;IAAEG,cAAA,EAAgBC;EAAc,CAAE,GAAGf,mBAAA,CAAoB;IAC7DM,cAAA;IACAC,MAAA;IACAC,UAAA;IACAC,IAAA,EAAMA;EACR;EAEAR,eAAA,CAAgBe,GAAG,CAACV,cAAA,IAAkBE,UAAA,EAAYO,cAAA;EAElDb,MAAA,CAAOC,kBAAkB,GAAGF,eAAA;EAE5BC,MAAA,CAAOQ,4BAA4B,GAAG;EAEtC,OAAOK,cAAA;AACT","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SanitizedCollectionConfig
|
|
1
|
+
import type { SanitizedCollectionConfig } from 'payload';
|
|
2
2
|
export type Props = {
|
|
3
3
|
className?: string;
|
|
4
4
|
collectionSlug: SanitizedCollectionConfig['slug'];
|
|
@@ -12,6 +12,6 @@ export type Props = {
|
|
|
12
12
|
setValidateBeforeSubmit: (validate: boolean) => void;
|
|
13
13
|
useAPIKey?: boolean;
|
|
14
14
|
username: string;
|
|
15
|
-
verify?: boolean
|
|
15
|
+
verify?: boolean;
|
|
16
16
|
};
|
|
17
17
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/views/Edit/Auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/views/Edit/Auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAExD,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAA;IACjD,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,iBAAiB,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAC,mBAAmB,CAAC,CAAA;IACzE,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,qBAAqB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IAC/C,uBAAuB,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAA;IACpD,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/views/Edit/Auth/types.ts"],"sourcesContent":["import type { SanitizedCollectionConfig
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/views/Edit/Auth/types.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from 'payload'\n\nexport type Props = {\n className?: string\n collectionSlug: SanitizedCollectionConfig['slug']\n disableLocalStrategy?: boolean\n email: string\n loginWithUsername: SanitizedCollectionConfig['auth']['loginWithUsername']\n operation: 'create' | 'update'\n readOnly: boolean\n requirePassword?: boolean\n setSchemaPathSegments: (path: string[]) => void\n setValidateBeforeSubmit: (validate: boolean) => void\n useAPIKey?: boolean\n username: string\n verify?: boolean\n}\n"],"mappings":"AAEA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1-canary.952fd26",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"ts-essentials": "10.0.3",
|
|
134
134
|
"use-context-selector": "2.0.0",
|
|
135
135
|
"uuid": "10.0.0",
|
|
136
|
-
"@payloadcms/translations": "3.
|
|
136
|
+
"@payloadcms/translations": "3.1.1-canary.952fd26"
|
|
137
137
|
},
|
|
138
138
|
"devDependencies": {
|
|
139
139
|
"@babel/cli": "^7.24.5",
|
|
@@ -151,14 +151,14 @@
|
|
|
151
151
|
"esbuild": "0.23.1",
|
|
152
152
|
"esbuild-sass-plugin": "3.3.1",
|
|
153
153
|
"eslint-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
|
|
154
|
-
"payload": "3.
|
|
154
|
+
"payload": "3.1.1-canary.952fd26",
|
|
155
155
|
"@payloadcms/eslint-config": "3.0.0"
|
|
156
156
|
},
|
|
157
157
|
"peerDependencies": {
|
|
158
158
|
"next": "^15.0.0",
|
|
159
159
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
160
160
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
161
|
-
"payload": "3.
|
|
161
|
+
"payload": "3.1.1-canary.952fd26"
|
|
162
162
|
},
|
|
163
163
|
"engines": {
|
|
164
164
|
"node": "^18.20.2 || >=20.9.0"
|