@payloadcms/ui 4.0.0-beta.1 → 4.0.0-beta.3
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/css/preflight.css +21 -2
- package/dist/elements/BulkUpload/FormsManager/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/index.js +1 -34
- package/dist/elements/BulkUpload/FormsManager/index.js.map +1 -1
- package/dist/elements/CloseModalOnRouteChange/index.d.ts.map +1 -1
- package/dist/elements/CloseModalOnRouteChange/index.js +27 -19
- package/dist/elements/CloseModalOnRouteChange/index.js.map +1 -1
- package/dist/elements/DatePicker/DatePicker.js +6 -2
- package/dist/elements/DatePicker/DatePicker.js.map +1 -1
- package/dist/elements/DatePicker/index.css +35 -25
- package/dist/elements/DocumentControls/index.js.map +1 -1
- package/dist/elements/DocumentFields/index.css +2 -2
- package/dist/elements/DocumentHeader/Tabs/tabs/index.js.map +1 -1
- package/dist/elements/FieldSelect/reduceFieldOptions.js.map +1 -1
- package/dist/elements/ListDrawer/Provider.d.ts.map +1 -1
- package/dist/elements/ListDrawer/Provider.js.map +1 -1
- package/dist/elements/LivePreview/Window/index.css +7 -1
- package/dist/elements/Nav/SidebarTabs/index.client.js +1 -1
- package/dist/elements/Nav/SidebarTabs/index.client.js.map +1 -1
- package/dist/elements/PublishButton/index.js.map +1 -1
- package/dist/elements/SchedulePublishButton/index.js.map +1 -1
- package/dist/elements/SegmentedControl/index.css +50 -7
- package/dist/elements/Table/DefaultCell/fields/File/index.d.ts.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/File/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/index.d.ts.map +1 -1
- package/dist/elements/Table/DefaultCell/index.js +6 -1
- package/dist/elements/Table/DefaultCell/index.js.map +1 -1
- package/dist/elements/Table/index.js.map +1 -1
- package/dist/exports/client/{CodeEditor-S7MOGZSR.js → CodeEditor-I6PL55BF.js} +2 -2
- package/dist/exports/client/{DatePicker-POZJVQP4.js → DatePicker-RFCB5VGD.js} +2 -2
- package/dist/exports/client/{chunk-2AY67NFV.js → chunk-O2RR6XEH.js} +2 -2
- package/dist/exports/client/chunk-O2RR6XEH.js.map +7 -0
- package/dist/exports/client/{chunk-Z42OBP5U.js → chunk-R7M6BG75.js} +1 -1
- package/dist/exports/client/{chunk-Z42OBP5U.js.map → chunk-R7M6BG75.js.map} +1 -1
- package/dist/exports/client/index.js +15 -15
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/shared/index.js +2 -2
- package/dist/exports/shared/index.js.map +3 -3
- package/dist/fields/Upload/Input.d.ts.map +1 -1
- package/dist/fields/Upload/Input.js +3 -1
- package/dist/fields/Upload/Input.js.map +1 -1
- package/dist/forms/Form/reduceToSerializableFields.d.ts +9 -4
- package/dist/forms/Form/reduceToSerializableFields.d.ts.map +1 -1
- package/dist/forms/Form/reduceToSerializableFields.js +34 -7
- package/dist/forms/Form/reduceToSerializableFields.js.map +1 -1
- package/dist/icons/Table/index.css +5 -1
- package/dist/layouts/Root/index.d.ts +1 -1
- package/dist/layouts/Root/index.d.ts.map +1 -1
- package/dist/layouts/Root/index.js +4 -15
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/providers/RouteCache/index.d.ts.map +1 -1
- package/dist/providers/RouteCache/index.js +37 -25
- package/dist/providers/RouteCache/index.js.map +1 -1
- package/dist/providers/ServerFunctions/index.d.ts.map +1 -1
- package/dist/providers/ServerFunctions/index.js +34 -23
- package/dist/providers/ServerFunctions/index.js.map +1 -1
- package/dist/styles.css +22 -3
- package/dist/templates/Default/index.css +0 -1
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.d.ts.map +1 -1
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.js +32 -6
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.js.map +1 -1
- package/dist/utilities/getDisplayedFieldValue.d.ts +8 -2
- package/dist/utilities/getDisplayedFieldValue.d.ts.map +1 -1
- package/dist/utilities/getDisplayedFieldValue.js +11 -1
- package/dist/utilities/getDisplayedFieldValue.js.map +1 -1
- package/dist/utilities/getHasScheduledPublish.js.map +1 -1
- package/dist/utilities/handleLivePreview.js.map +1 -1
- package/dist/utilities/handleServerFunctions.d.ts +2 -10
- package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
- package/dist/utilities/handleServerFunctions.js +3 -7
- package/dist/utilities/handleServerFunctions.js.map +1 -1
- package/dist/utilities/hasSavePermission.js.map +1 -1
- package/dist/utilities/schedulePublishHandler.js.map +1 -1
- package/dist/utilities/serverFunctionRegistry.d.ts +2 -7
- package/dist/utilities/serverFunctionRegistry.d.ts.map +1 -1
- package/dist/utilities/serverFunctionRegistry.js +2 -7
- package/dist/utilities/serverFunctionRegistry.js.map +1 -1
- package/dist/views/Edit/index.js.map +1 -1
- package/dist/widgets/RecentlyViewed/getDocuments.d.ts.map +1 -1
- package/dist/widgets/RecentlyViewed/getDocuments.js +4 -1
- package/dist/widgets/RecentlyViewed/getDocuments.js.map +1 -1
- package/dist/widgets/RecentlyViewed/index.client.d.ts.map +1 -1
- package/dist/widgets/RecentlyViewed/index.client.js +7 -2
- package/dist/widgets/RecentlyViewed/index.client.js.map +1 -1
- package/package.json +16 -16
- package/dist/exports/client/chunk-2AY67NFV.js.map +0 -7
- /package/dist/exports/client/{CodeEditor-S7MOGZSR.js.map → CodeEditor-I6PL55BF.js.map} +0 -0
- /package/dist/exports/client/{DatePicker-POZJVQP4.js.map → DatePicker-RFCB5VGD.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../src/utilities/buildClientFieldSchemaMap/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAEV,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,OAAO,EACP,gBAAgB,EACjB,MAAM,SAAS,CAAA;AAKhB,KAAK,IAAI,GAAG;IACV,eAAe,EAAE,oBAAoB,CAAA;IACrC,MAAM,EAAE,YAAY,CAAA;IACpB,MAAM,EAAE,CAAC,WAAW,GAAG,gBAAgB,CAAC,EAAE,CAAA;IAC1C,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;IACxB,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,cAAc,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,cAAc,sGASxB,IAAI,
|
|
1
|
+
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../src/utilities/buildClientFieldSchemaMap/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAEV,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,OAAO,EACP,gBAAgB,EACjB,MAAM,SAAS,CAAA;AAKhB,KAAK,IAAI,GAAG;IACV,eAAe,EAAE,oBAAoB,CAAA;IACrC,MAAM,EAAE,YAAY,CAAA;IACpB,MAAM,EAAE,CAAC,WAAW,GAAG,gBAAgB,CAAC,EAAE,CAAA;IAC1C,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;IACxB,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,cAAc,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,cAAc,sGASxB,IAAI,SA2LN,CAAA"}
|
|
@@ -104,12 +104,9 @@ export const traverseFields = ({
|
|
|
104
104
|
// 2. convert them to client fields
|
|
105
105
|
// 3. add them to the client schema map
|
|
106
106
|
// So these would basically be all fields that are not part of the client config already
|
|
107
|
-
const richTextFieldSchemaMap =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
richTextFieldSchemaMap.set(path, subField);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
107
|
+
const richTextFieldSchemaMap = getRichTextSubFieldsByPath({
|
|
108
|
+
schemaMap
|
|
109
|
+
}).get(schemaPath) ?? new Map();
|
|
113
110
|
// Now loop through them, convert each entry to a client field and add it to the client schema map.
|
|
114
111
|
// Schema map values are a union: Block | Field | Tab | { fields: Field[] }.
|
|
115
112
|
// Each variant needs different conversion to strip server-only properties.
|
|
@@ -187,4 +184,33 @@ export const traverseFields = ({
|
|
|
187
184
|
}
|
|
188
185
|
}
|
|
189
186
|
};
|
|
187
|
+
const richTextSubFieldsCache = new WeakMap();
|
|
188
|
+
/**
|
|
189
|
+
* Groups the schema map entries by the rich text field they belong to,
|
|
190
|
+
* so each rich text field does not have to scan the whole schema map.
|
|
191
|
+
*/
|
|
192
|
+
function getRichTextSubFieldsByPath({
|
|
193
|
+
schemaMap
|
|
194
|
+
}) {
|
|
195
|
+
const cachedSubFieldsByPath = richTextSubFieldsCache.get(schemaMap);
|
|
196
|
+
if (cachedSubFieldsByPath) {
|
|
197
|
+
return cachedSubFieldsByPath;
|
|
198
|
+
}
|
|
199
|
+
const subFieldsByPath = new Map();
|
|
200
|
+
for (const [path, field] of schemaMap) {
|
|
201
|
+
if ('type' in field && field.type === 'richText') {
|
|
202
|
+
subFieldsByPath.set(path, new Map());
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
for (const [path, field] of schemaMap) {
|
|
206
|
+
let separatorIndex = path.indexOf('.');
|
|
207
|
+
// A sub-field of a nested rich text field belongs to each of its rich text ancestors
|
|
208
|
+
while (separatorIndex !== -1) {
|
|
209
|
+
subFieldsByPath.get(path.slice(0, separatorIndex))?.set(path, field);
|
|
210
|
+
separatorIndex = path.indexOf('.', separatorIndex + 1);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
richTextSubFieldsCache.set(schemaMap, subFieldsByPath);
|
|
214
|
+
return subFieldsByPath;
|
|
215
|
+
}
|
|
190
216
|
//# sourceMappingURL=traverseFields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverseFields.js","names":["createClientBlocks","createClientFields","fieldAffectsData","getFieldPaths","tabHasName","traverseFields","clientSchemaMap","config","fields","i18n","parentIndexPath","parentSchemaPath","payload","schemaMap","index","field","entries","indexPath","schemaPath","set","type","blocks","map","_block","block","blocksMap","find","slug","blockSchemaPath","richTextFieldSchemaMap","Map","path","subField","startsWith","clientBlocks","defaultIDType","db","importMap","clientFields","disableAddingID","isNamedTab","tabs","tab"],"sources":["../../../src/utilities/buildClientFieldSchemaMap/traverseFields.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type {\n ClientBlock,\n ClientConfig,\n ClientField,\n ClientFieldSchemaMap,\n FieldSchemaMap,\n Payload,\n TabAsFieldClient,\n} from 'payload'\n\nimport { createClientBlocks, createClientFields } from 'payload'\nimport { fieldAffectsData, getFieldPaths, tabHasName } from 'payload/shared'\n\ntype Args = {\n clientSchemaMap: ClientFieldSchemaMap\n config: ClientConfig\n fields: (ClientField | TabAsFieldClient)[]\n i18n: I18n<any, any>\n parentIndexPath: string\n parentSchemaPath: string\n payload: Payload\n schemaMap: FieldSchemaMap\n}\n\nexport const traverseFields = ({\n clientSchemaMap,\n config,\n fields,\n i18n,\n parentIndexPath,\n parentSchemaPath,\n payload,\n schemaMap,\n}: Args) => {\n for (const [index, field] of fields.entries()) {\n const { indexPath, schemaPath } = getFieldPaths({\n field,\n index,\n parentIndexPath,\n parentSchemaPath,\n })\n\n clientSchemaMap.set(schemaPath, field)\n\n switch (field.type) {\n case 'array': {\n traverseFields({\n clientSchemaMap,\n config,\n fields: field.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: schemaPath,\n payload,\n schemaMap,\n })\n\n break\n }\n\n case 'blocks':\n field.blocks.map((_block) => {\n const block =\n typeof _block === 'string'\n ? config.blocksMap\n ? config.blocksMap[_block]\n : config.blocks.find((block) => typeof block !== 'string' && block.slug === _block)\n : _block\n\n const blockSchemaPath = `${schemaPath}.${block.slug}`\n\n clientSchemaMap.set(blockSchemaPath, block)\n traverseFields({\n clientSchemaMap,\n config,\n fields: block.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: schemaPath + '.' + block.slug,\n payload,\n schemaMap,\n })\n })\n\n break\n\n case 'collapsible':\n case 'row': {\n traverseFields({\n clientSchemaMap,\n config,\n fields: field.fields,\n i18n,\n parentIndexPath: indexPath,\n parentSchemaPath: schemaPath,\n payload,\n schemaMap,\n })\n break\n }\n\n case 'group': {\n if (fieldAffectsData(field)) {\n traverseFields({\n clientSchemaMap,\n config,\n fields: field.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: schemaPath,\n payload,\n schemaMap,\n })\n } else {\n traverseFields({\n clientSchemaMap,\n config,\n fields: field.fields,\n i18n,\n parentIndexPath: indexPath,\n parentSchemaPath: schemaPath,\n payload,\n schemaMap,\n })\n }\n break\n }\n\n case 'richText': {\n // richText sub-fields are not part of the ClientConfig or the Config.\n // They only exist in the field schema map.\n // Thus, we need to\n // 1. get them from the field schema map\n // 2. convert them to client fields\n // 3. add them to the client schema map\n\n // So these would basically be all fields that are not part of the client config already\n const richTextFieldSchemaMap: FieldSchemaMap = new Map()\n for (const [path, subField] of schemaMap.entries()) {\n if (path.startsWith(`${schemaPath}.`)) {\n richTextFieldSchemaMap.set(path, subField)\n }\n }\n\n // Now loop through them, convert each entry to a client field and add it to the client schema map.\n // Schema map values are a union: Block | Field | Tab | { fields: Field[] }.\n // Each variant needs different conversion to strip server-only properties.\n for (const [path, subField] of richTextFieldSchemaMap.entries()) {\n if ('slug' in subField) {\n const clientBlocks = createClientBlocks({\n blocks: [subField],\n defaultIDType: payload.config.db.defaultIDType,\n i18n,\n importMap: payload.importMap,\n })\n\n clientSchemaMap.set(path, clientBlocks[0] as ClientBlock)\n continue\n }\n\n if ('type' in subField) {\n const clientFields = createClientFields({\n defaultIDType: payload.config.db.defaultIDType,\n disableAddingID: true,\n fields: [subField],\n i18n,\n importMap: payload.importMap,\n })\n\n clientSchemaMap.set(path, clientFields[0])\n continue\n }\n\n if ('fields' in subField) {\n const clientFields = createClientFields({\n defaultIDType: payload.config.db.defaultIDType,\n disableAddingID: true,\n fields: subField.fields,\n i18n,\n importMap: payload.importMap,\n })\n\n clientSchemaMap.set(path, { fields: clientFields })\n continue\n }\n\n subField satisfies never\n }\n break\n }\n\n case 'tab': {\n const isNamedTab = tabHasName(field)\n\n traverseFields({\n clientSchemaMap,\n config,\n fields: field.fields,\n i18n,\n parentIndexPath: isNamedTab ? '' : indexPath,\n parentSchemaPath: schemaPath,\n payload,\n schemaMap,\n })\n\n break\n }\n\n case 'tabs': {\n traverseFields({\n clientSchemaMap,\n config,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n i18n,\n parentIndexPath: indexPath,\n parentSchemaPath: schemaPath,\n payload,\n schemaMap,\n })\n\n break\n }\n }\n }\n}\n"],"mappings":"AAWA,SAASA,kBAAkB,EAAEC,kBAAkB,QAAQ;AACvD,SAASC,gBAAgB,EAAEC,aAAa,EAAEC,UAAU,QAAQ;AAa5D,OAAO,MAAMC,cAAA,GAAiBA,CAAC;EAC7BC,eAAe;EACfC,MAAM;EACNC,MAAM;EACNC,IAAI;EACJC,eAAe;EACfC,gBAAgB;EAChBC,OAAO;EACPC;AAAS,CACJ;EACL,KAAK,MAAM,CAACC,KAAA,EAAOC,KAAA,CAAM,IAAIP,MAAA,CAAOQ,OAAO,IAAI;IAC7C,MAAM;MAAEC,SAAS;MAAEC;IAAU,CAAE,GAAGf,aAAA,CAAc;MAC9CY,KAAA;MACAD,KAAA;MACAJ,eAAA;MACAC;IACF;IAEAL,eAAA,CAAgBa,GAAG,CAACD,UAAA,EAAYH,KAAA;IAEhC,QAAQA,KAAA,CAAMK,IAAI;MAChB,KAAK;QAAS;UACZf,cAAA,CAAe;YACbC,eAAA;YACAC,MAAA;YACAC,MAAA,EAA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EAAE;cACzC;YACF;YAEA,IAAI,YAAYN,QAAA,EAAU;cACxB,MAAMM,YAAA,GAAerC,kBAAA,CAAmB;gBACtCkC,aAAA,EAAevB,OAAA,CAAQL,MAAM,CAAC6B,EAAE,CAACD,aAAa;gBAC9CI,eAAA,EAAiB;gBACjB/B,MAAA,EAAQwB,QAAA,CAASxB,MAAM;gBACvBC,IAAA;gBACA4B,SAAA,EAAWzB,OAAA,CAAQyB;cACrB;cAEA/B,eAAA,CAAgBa,GAAG,CAACY,IAAA,EAAM;gBAAEvB,MAAA,EAAQ8B;cAAa;cACjD;YACF;YAEAN,QAAA;UACF;UACA;QACF;MAEA,KAAK;QAAO;UACV,MAAMQ,UAAA,GAAapC,UAAA,CAAWW,KAAA;UAE9BV,cAAA,CAAe;YACbC,eAAA;YACAC,MAAA;YACAC,MAAA,EAAQO,KAAA,CAAMP,MAAM;YACpBC,IAAA;YACAC,eAAA,EAAiB8B,UAAA,GAAa,KAAKvB,SAAA;YACnCN,gBAAA,EAAkBO,UAAA;YAClBN,OAAA;YACAC;UACF;UAEA;QACF;MAEA,KAAK;QAAQ;UACXR,cAAA,CAAe;YACbC,eAAA;YACAC,MAAA;YACAC,MAAA,EAAQO,KAAA,CAAM0B,IAAI,CAACnB,GAAG,CAAEoB,GAAA,KAAS;cAAE,GAAGA,GAAG;cAAEtB,IAAA,EAAM;YAAM;YACvDX,IAAA;YACAC,eAAA,EAAiBO,SAAA;YACjBN,gBAAA,EAAkBO,UAAA;YAClBN,OAAA;YACAC;UACF;UAEA;QACF;IACF;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"traverseFields.js","names":["createClientBlocks","createClientFields","fieldAffectsData","getFieldPaths","tabHasName","traverseFields","clientSchemaMap","config","fields","i18n","parentIndexPath","parentSchemaPath","payload","schemaMap","index","field","entries","indexPath","schemaPath","set","type","blocks","map","_block","block","blocksMap","find","slug","blockSchemaPath","richTextFieldSchemaMap","getRichTextSubFieldsByPath","get","Map","path","subField","clientBlocks","defaultIDType","db","importMap","clientFields","disableAddingID","isNamedTab","tabs","tab","richTextSubFieldsCache","WeakMap","cachedSubFieldsByPath","subFieldsByPath","separatorIndex","indexOf","slice"],"sources":["../../../src/utilities/buildClientFieldSchemaMap/traverseFields.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type {\n ClientBlock,\n ClientConfig,\n ClientField,\n ClientFieldSchemaMap,\n FieldSchemaMap,\n Payload,\n TabAsFieldClient,\n} from 'payload'\n\nimport { createClientBlocks, createClientFields } from 'payload'\nimport { fieldAffectsData, getFieldPaths, tabHasName } from 'payload/shared'\n\ntype Args = {\n clientSchemaMap: ClientFieldSchemaMap\n config: ClientConfig\n fields: (ClientField | TabAsFieldClient)[]\n i18n: I18n<any, any>\n parentIndexPath: string\n parentSchemaPath: string\n payload: Payload\n schemaMap: FieldSchemaMap\n}\n\nexport const traverseFields = ({\n clientSchemaMap,\n config,\n fields,\n i18n,\n parentIndexPath,\n parentSchemaPath,\n payload,\n schemaMap,\n}: Args) => {\n for (const [index, field] of fields.entries()) {\n const { indexPath, schemaPath } = getFieldPaths({\n field,\n index,\n parentIndexPath,\n parentSchemaPath,\n })\n\n clientSchemaMap.set(schemaPath, field)\n\n switch (field.type) {\n case 'array': {\n traverseFields({\n clientSchemaMap,\n config,\n fields: field.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: schemaPath,\n payload,\n schemaMap,\n })\n\n break\n }\n\n case 'blocks':\n field.blocks.map((_block) => {\n const block =\n typeof _block === 'string'\n ? config.blocksMap\n ? config.blocksMap[_block]\n : config.blocks.find((block) => typeof block !== 'string' && block.slug === _block)\n : _block\n\n const blockSchemaPath = `${schemaPath}.${block.slug}`\n\n clientSchemaMap.set(blockSchemaPath, block)\n traverseFields({\n clientSchemaMap,\n config,\n fields: block.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: schemaPath + '.' + block.slug,\n payload,\n schemaMap,\n })\n })\n\n break\n\n case 'collapsible':\n case 'row': {\n traverseFields({\n clientSchemaMap,\n config,\n fields: field.fields,\n i18n,\n parentIndexPath: indexPath,\n parentSchemaPath: schemaPath,\n payload,\n schemaMap,\n })\n break\n }\n\n case 'group': {\n if (fieldAffectsData(field)) {\n traverseFields({\n clientSchemaMap,\n config,\n fields: field.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: schemaPath,\n payload,\n schemaMap,\n })\n } else {\n traverseFields({\n clientSchemaMap,\n config,\n fields: field.fields,\n i18n,\n parentIndexPath: indexPath,\n parentSchemaPath: schemaPath,\n payload,\n schemaMap,\n })\n }\n break\n }\n\n case 'richText': {\n // richText sub-fields are not part of the ClientConfig or the Config.\n // They only exist in the field schema map.\n // Thus, we need to\n // 1. get them from the field schema map\n // 2. convert them to client fields\n // 3. add them to the client schema map\n\n // So these would basically be all fields that are not part of the client config already\n const richTextFieldSchemaMap: FieldSchemaMap =\n getRichTextSubFieldsByPath({ schemaMap }).get(schemaPath) ?? new Map()\n\n // Now loop through them, convert each entry to a client field and add it to the client schema map.\n // Schema map values are a union: Block | Field | Tab | { fields: Field[] }.\n // Each variant needs different conversion to strip server-only properties.\n for (const [path, subField] of richTextFieldSchemaMap.entries()) {\n if ('slug' in subField) {\n const clientBlocks = createClientBlocks({\n blocks: [subField],\n defaultIDType: payload.config.db.defaultIDType,\n i18n,\n importMap: payload.importMap,\n })\n\n clientSchemaMap.set(path, clientBlocks[0] as ClientBlock)\n continue\n }\n\n if ('type' in subField) {\n const clientFields = createClientFields({\n defaultIDType: payload.config.db.defaultIDType,\n disableAddingID: true,\n fields: [subField],\n i18n,\n importMap: payload.importMap,\n })\n\n clientSchemaMap.set(path, clientFields[0])\n continue\n }\n\n if ('fields' in subField) {\n const clientFields = createClientFields({\n defaultIDType: payload.config.db.defaultIDType,\n disableAddingID: true,\n fields: subField.fields,\n i18n,\n importMap: payload.importMap,\n })\n\n clientSchemaMap.set(path, { fields: clientFields })\n continue\n }\n\n subField satisfies never\n }\n break\n }\n\n case 'tab': {\n const isNamedTab = tabHasName(field)\n\n traverseFields({\n clientSchemaMap,\n config,\n fields: field.fields,\n i18n,\n parentIndexPath: isNamedTab ? '' : indexPath,\n parentSchemaPath: schemaPath,\n payload,\n schemaMap,\n })\n\n break\n }\n\n case 'tabs': {\n traverseFields({\n clientSchemaMap,\n config,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n i18n,\n parentIndexPath: indexPath,\n parentSchemaPath: schemaPath,\n payload,\n schemaMap,\n })\n\n break\n }\n }\n }\n}\n\nconst richTextSubFieldsCache = new WeakMap<FieldSchemaMap, Map<string, FieldSchemaMap>>()\n\n/**\n * Groups the schema map entries by the rich text field they belong to,\n * so each rich text field does not have to scan the whole schema map.\n */\nfunction getRichTextSubFieldsByPath({\n schemaMap,\n}: {\n schemaMap: FieldSchemaMap\n}): Map<string, FieldSchemaMap> {\n const cachedSubFieldsByPath = richTextSubFieldsCache.get(schemaMap)\n\n if (cachedSubFieldsByPath) {\n return cachedSubFieldsByPath\n }\n\n const subFieldsByPath = new Map<string, FieldSchemaMap>()\n\n for (const [path, field] of schemaMap) {\n if ('type' in field && field.type === 'richText') {\n subFieldsByPath.set(path, new Map())\n }\n }\n\n for (const [path, field] of schemaMap) {\n let separatorIndex = path.indexOf('.')\n\n // A sub-field of a nested rich text field belongs to each of its rich text ancestors\n while (separatorIndex !== -1) {\n subFieldsByPath.get(path.slice(0, separatorIndex))?.set(path, field)\n separatorIndex = path.indexOf('.', separatorIndex + 1)\n }\n }\n\n richTextSubFieldsCache.set(schemaMap, subFieldsByPath)\n\n return subFieldsByPath\n}\n"],"mappings":"AAWA,SAASA,kBAAkB,EAAEC,kBAAkB,QAAQ;AACvD,SAASC,gBAAgB,EAAEC,aAAa,EAAEC,UAAU,QAAQ;AAa5D,OAAO,MAAMC,cAAA,GAAiBA,CAAC;EAC7BC,eAAe;EACfC,MAAM;EACNC,MAAM;EACNC,IAAI;EACJC,eAAe;EACfC,gBAAgB;EAChBC,OAAO;EACPC;AA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AAA;AAEnC;;;;AAIA,SAASf,2BAA2B;EAClCjB;AAAS,CAGV;EACC,MAAMiC,qBAAA,GAAwBF,sBAAA,CAAuBb,GAAG,CAAClB,SAAA;EAEzD,IAAIiC,qBAAA,EAAuB;IACzB,OAAOA,qBAAA;EACT;EAEA,MAAMC,eAAA,GAAkB,IAAIf,GAAA;EAE5B,KAAK,MAAM,CAACC,IAAA,EAAMlB,KAAA,CAAM,IAAIF,SAAA,EAAW;IACrC,IAAI,UAAUE,KAAA,IAASA,KAAA,CAAMK,IAAI,KAAK,YAAY;MAChD2B,eAAA,CAAgB5B,GAAG,CAACc,IAAA,EAAM,IAAID,GAAA;IAChC;EACF;EAEA,KAAK,MAAM,CAACC,IAAA,EAAMlB,KAAA,CAAM,IAAIF,SAAA,EAAW;IACrC,IAAImC,cAAA,GAAiBf,IAAA,CAAKgB,OAAO,CAAC;IAElC;IACA,OAAOD,cAAA,KAAmB,CAAC,GAAG;MAC5BD,eAAA,CAAgBhB,GAAG,CAACE,IAAA,CAAKiB,KAAK,CAAC,GAAGF,cAAA,IAAkB7B,GAAA,CAAIc,IAAA,EAAMlB,KAAA;MAC9DiC,cAAA,GAAiBf,IAAA,CAAKgB,OAAO,CAAC,KAAKD,cAAA,GAAiB;IACtD;EACF;EAEAJ,sBAAA,CAAuBzB,GAAG,CAACN,SAAA,EAAWkC,eAAA;EAEtC,OAAOA,eAAA;AACT","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
-
import type { ClientField } from 'payload';
|
|
2
|
+
import type { ClientCollectionConfig, ClientField } from 'payload';
|
|
3
3
|
/**
|
|
4
4
|
* Returns the appropriate display value for a field.
|
|
5
5
|
* - For select and radio fields:
|
|
@@ -7,7 +7,13 @@ import type { ClientField } from 'payload';
|
|
|
7
7
|
* - Translates localized label objects based on the current language.
|
|
8
8
|
* - Returns string labels directly.
|
|
9
9
|
* - Falls back to the option value if no valid label is found.
|
|
10
|
+
* - Formats upload file sizes for display.
|
|
10
11
|
* - For all other field types, returns `cellData` unchanged.
|
|
11
12
|
*/
|
|
12
|
-
export declare const getDisplayedFieldValue: (cellData
|
|
13
|
+
export declare const getDisplayedFieldValue: ({ cellData, collectionConfig, field, i18n, }: {
|
|
14
|
+
cellData: any;
|
|
15
|
+
collectionConfig?: ClientCollectionConfig | null;
|
|
16
|
+
field: ClientField;
|
|
17
|
+
i18n: I18nClient;
|
|
18
|
+
}) => any;
|
|
13
19
|
//# sourceMappingURL=getDisplayedFieldValue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDisplayedFieldValue.d.ts","sourceRoot":"","sources":["../../src/utilities/getDisplayedFieldValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"getDisplayedFieldValue.d.ts","sourceRoot":"","sources":["../../src/utilities/getDisplayedFieldValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAOlE;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,iDAKhC;IACD,QAAQ,EAAE,GAAG,CAAA;IACb,gBAAgB,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAA;IAChD,KAAK,EAAE,WAAW,CAAA;IAClB,IAAI,EAAE,UAAU,CAAA;CACjB,QA0BA,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getTranslation } from '@payloadcms/translations';
|
|
2
|
+
import { formatFilesize } from 'payload/shared';
|
|
2
3
|
import { isValidReactElement } from './isValidReactElement.js';
|
|
3
4
|
/**
|
|
4
5
|
* Returns the appropriate display value for a field.
|
|
@@ -7,9 +8,18 @@ import { isValidReactElement } from './isValidReactElement.js';
|
|
|
7
8
|
* - Translates localized label objects based on the current language.
|
|
8
9
|
* - Returns string labels directly.
|
|
9
10
|
* - Falls back to the option value if no valid label is found.
|
|
11
|
+
* - Formats upload file sizes for display.
|
|
10
12
|
* - For all other field types, returns `cellData` unchanged.
|
|
11
13
|
*/
|
|
12
|
-
export const getDisplayedFieldValue = (
|
|
14
|
+
export const getDisplayedFieldValue = ({
|
|
15
|
+
cellData,
|
|
16
|
+
collectionConfig,
|
|
17
|
+
field,
|
|
18
|
+
i18n
|
|
19
|
+
}) => {
|
|
20
|
+
if (collectionConfig?.upload && field.type === 'number' && 'name' in field && field.name === 'filesize' && typeof cellData === 'number') {
|
|
21
|
+
return formatFilesize(cellData);
|
|
22
|
+
}
|
|
13
23
|
if ((field?.type === 'select' || field?.type === 'radio') && Array.isArray(field.options)) {
|
|
14
24
|
const selectedOption = field.options.find(opt => typeof opt === 'object' ? opt.value === cellData : opt === cellData);
|
|
15
25
|
if (selectedOption) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDisplayedFieldValue.js","names":["getTranslation","isValidReactElement","getDisplayedFieldValue","cellData","field","i18n","type","Array","isArray","options","selectedOption","find","opt","value","label"],"sources":["../../src/utilities/getDisplayedFieldValue.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { ClientField } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\n\nimport { isValidReactElement } from './isValidReactElement.js'\n\n/**\n * Returns the appropriate display value for a field.\n * - For select and radio fields:\n * - Returns JSX elements as-is.\n * - Translates localized label objects based on the current language.\n * - Returns string labels directly.\n * - Falls back to the option value if no valid label is found.\n * - For all other field types, returns `cellData` unchanged.\n */\nexport const getDisplayedFieldValue = (cellData: any
|
|
1
|
+
{"version":3,"file":"getDisplayedFieldValue.js","names":["getTranslation","formatFilesize","isValidReactElement","getDisplayedFieldValue","cellData","collectionConfig","field","i18n","upload","type","name","Array","isArray","options","selectedOption","find","opt","value","label"],"sources":["../../src/utilities/getDisplayedFieldValue.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { ClientCollectionConfig, ClientField } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { formatFilesize } from 'payload/shared'\n\nimport { isValidReactElement } from './isValidReactElement.js'\n\n/**\n * Returns the appropriate display value for a field.\n * - For select and radio fields:\n * - Returns JSX elements as-is.\n * - Translates localized label objects based on the current language.\n * - Returns string labels directly.\n * - Falls back to the option value if no valid label is found.\n * - Formats upload file sizes for display.\n * - For all other field types, returns `cellData` unchanged.\n */\nexport const getDisplayedFieldValue = ({\n cellData,\n collectionConfig,\n field,\n i18n,\n}: {\n cellData: any\n collectionConfig?: ClientCollectionConfig | null\n field: ClientField\n i18n: I18nClient\n}) => {\n if (\n collectionConfig?.upload &&\n field.type === 'number' &&\n 'name' in field &&\n field.name === 'filesize' &&\n typeof cellData === 'number'\n ) {\n return formatFilesize(cellData)\n }\n\n if ((field?.type === 'select' || field?.type === 'radio') && Array.isArray(field.options)) {\n const selectedOption = field.options.find((opt) =>\n typeof opt === 'object' ? opt.value === cellData : opt === cellData,\n )\n\n if (selectedOption) {\n if (typeof selectedOption === 'object' && 'label' in selectedOption) {\n return isValidReactElement(selectedOption.label)\n ? selectedOption.label // Return JSX directly\n : getTranslation(selectedOption.label, i18n) || selectedOption.value // Use translation or fallback to value\n }\n return selectedOption // If option is a string, return it directly\n }\n }\n return cellData // Default fallback if no match found\n}\n"],"mappings":"AAGA,SAASA,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAE/B,SAASC,mBAAmB,QAAQ;AAEpC;;;;;;;;;;AAUA,OAAO,MAAMC,sBAAA,GAAyBA,CAAC;EACrCC,QAAQ;EACRC,gBAAgB;EAChBC,KAAK;EACLC;AAAI,CAML;EACC,IACEF,gBAAA,EAAkBG,MAAA,IAClBF,KAAA,CAAMG,IAAI,KAAK,YACf,UAAUH,KAAA,IACVA,KAAA,CAAMI,IAAI,KAAK,cACf,OAAON,QAAA,KAAa,UACpB;IACA,OAAOH,cAAA,CAAeG,QAAA;EACxB;EAEA,IAAI,CAACE,KAAA,EAAOG,IAAA,KAAS,YAAYH,KAAA,EAAOG,IAAA,KAAS,OAAM,KAAME,KAAA,CAAMC,OAAO,CAACN,KAAA,CAAMO,OAAO,GAAG;IACzF,MAAMC,cAAA,GAAiBR,KAAA,CAAMO,OAAO,CAACE,IAAI,CAAEC,GAAA,IACzC,OAAOA,GAAA,KAAQ,WAAWA,GAAA,CAAIC,KAAK,KAAKb,QAAA,GAAWY,GAAA,KAAQZ,QAAA;IAG7D,IAAIU,cAAA,EAAgB;MAClB,IAAI,OAAOA,cAAA,KAAmB,YAAY,WAAWA,cAAA,EAAgB;QACnE,OAAOZ,mBAAA,CAAoBY,cAAA,CAAeI,KAAK,IAC3CJ,cAAA,CAAeI,KAAK,CAAC;QAAA,EACrBlB,cAAA,CAAec,cAAA,CAAeI,KAAK,EAAEX,IAAA,KAASO,cAAA,CAAeG,KAAK,CAAC;AAAA;MACzE;MACA,OAAOH,cAAA,CAAe;AAAA;IACxB;EACF;EACA,OAAOV,QAAA,CAAS;AAAA;AAClB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getHasScheduledPublish.js","names":["hasScheduledPublishEnabled","buildUpcomingScheduleWhere","sanitizeID","getHasScheduledPublish","id","idArg","collectionConfig","globalConfig","hasPublishPermission","payload","entityConfig","collectionSlug","slug","globalSlug","canSchedulePublish","Boolean","totalDocs","db","count","collection","where"],"sources":["../../src/utilities/getHasScheduledPublish.ts"],"sourcesContent":["import type { Payload, SanitizedCollectionConfig, SanitizedGlobalConfig } from 'payload'\n\nimport { hasScheduledPublishEnabled } from 'payload/shared'\n\nimport { buildUpcomingScheduleWhere } from '../elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.js'\nimport { sanitizeID } from './sanitizeID.js'\n\ntype Args = {\n collectionConfig?: SanitizedCollectionConfig\n globalConfig?: SanitizedGlobalConfig\n hasPublishPermission?: boolean\n id?: number | string\n payload: Payload\n}\n\nexport const getHasScheduledPublish = async ({\n id: idArg,\n collectionConfig,\n globalConfig,\n hasPublishPermission,\n payload,\n}: Args): Promise<boolean> => {\n const entityConfig = collectionConfig || globalConfig\n const id = sanitizeID(idArg)\n const collectionSlug = collectionConfig?.slug\n const globalSlug = globalConfig?.slug\n\n const canSchedulePublish = Boolean(\n hasScheduledPublishEnabled(entityConfig) &&\n
|
|
1
|
+
{"version":3,"file":"getHasScheduledPublish.js","names":["hasScheduledPublishEnabled","buildUpcomingScheduleWhere","sanitizeID","getHasScheduledPublish","id","idArg","collectionConfig","globalConfig","hasPublishPermission","payload","entityConfig","collectionSlug","slug","globalSlug","canSchedulePublish","Boolean","totalDocs","db","count","collection","where"],"sources":["../../src/utilities/getHasScheduledPublish.ts"],"sourcesContent":["import type { Payload, SanitizedCollectionConfig, SanitizedGlobalConfig } from 'payload'\n\nimport { hasScheduledPublishEnabled } from 'payload/shared'\n\nimport { buildUpcomingScheduleWhere } from '../elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.js'\nimport { sanitizeID } from './sanitizeID.js'\n\ntype Args = {\n collectionConfig?: SanitizedCollectionConfig\n globalConfig?: SanitizedGlobalConfig\n hasPublishPermission?: boolean\n id?: number | string\n payload: Payload\n}\n\nexport const getHasScheduledPublish = async ({\n id: idArg,\n collectionConfig,\n globalConfig,\n hasPublishPermission,\n payload,\n}: Args): Promise<boolean> => {\n const entityConfig = collectionConfig || globalConfig\n const id = sanitizeID(idArg)\n const collectionSlug = collectionConfig?.slug\n const globalSlug = globalConfig?.slug\n\n const canSchedulePublish = Boolean(\n hasScheduledPublishEnabled(entityConfig) &&\n hasPublishPermission &&\n (globalSlug || (collectionSlug && id)),\n )\n\n if (!canSchedulePublish) {\n return false\n }\n\n try {\n const { totalDocs } = await payload.db.count({\n collection: 'payload-jobs',\n where: buildUpcomingScheduleWhere({ id, collectionSlug, globalSlug }),\n })\n\n return totalDocs > 0\n } catch {\n return false\n }\n}\n"],"mappings":"AAEA,SAASA,0BAA0B,QAAQ;AAE3C,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,UAAU,QAAQ;AAU3B,OAAO,MAAMC,sBAAA,GAAyB,MAAAA,CAAO;EAC3CC,EAAA,EAAIC,KAAK;EACTC,gBAAgB;EAChBC,YAAY;EACZC,oBAAoB;EACpBC;AAAO,CACF;EACL,MAAMC,YAAA,GAAeJ,gBAAA,IAAoBC,YAAA;EACzC,MAAMH,EAAA,GAAKF,UAAA,CAAWG,KAAA;EACtB,MAAMM,cAAA,GAAiBL,gBAAA,EAAkBM,IAAA;EACzC,MAAMC,UAAA,GAAaN,YAAA,EAAcK,IAAA;EAEjC,MAAME,kBAAA,GAAqBC,OAAA,CACzBf,0BAAA,CAA2BU,YAAA,KAC3BF,oBAAA,KACCK,UAAA,IAAeF,cAAA,IAAkBP,EAAE;EAGtC,IAAI,CAACU,kBAAA,EAAoB;IACvB,OAAO;EACT;EAEA,IAAI;IACF,MAAM;MAAEE;IAAS,CAAE,GAAG,MAAMP,OAAA,CAAQQ,EAAE,CAACC,KAAK,CAAC;MAC3CC,UAAA,EAAY;MACZC,KAAA,EAAOnB,0BAAA,CAA2B;QAAEG,EAAA;QAAIO,cAAA;QAAgBE;MAAW;IACrE;IAEA,OAAOG,SAAA,GAAY;EACrB,EAAE,MAAM;IACN,OAAO;EACT;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleLivePreview.js","names":["getLivePreviewConfig","collectionConfig","config","globalConfig","isLivePreviewEnabled","admin","livePreview","Boolean","globals","includes","slug","collections","handleLivePreview","collectionSlug","data","globalSlug","operation","req","payload","undefined","find","g","enabled","livePreviewConfig","livePreviewURL","url","result","locale","code","label","err","logger","error","msg"],"sources":["../../src/utilities/handleLivePreview.ts"],"sourcesContent":["import type {\n CollectionConfig,\n GlobalConfig,\n LivePreviewConfig,\n LivePreviewURLType,\n Operation,\n PayloadRequest,\n SanitizedConfig,\n} from 'payload'\n\nexport const getLivePreviewConfig = ({\n collectionConfig,\n config,\n globalConfig,\n isLivePreviewEnabled,\n}: {\n collectionConfig?: CollectionConfig\n config: SanitizedConfig\n globalConfig?: GlobalConfig\n isLivePreviewEnabled: boolean\n}) => ({\n ...(isLivePreviewEnabled ? config.admin.livePreview : {}),\n ...(collectionConfig?.admin?.livePreview || {}),\n ...(globalConfig?.admin?.livePreview || {}),\n})\n\n/**\n * Multi-level check to determine whether live preview is enabled on a collection or global.\n * For example, live preview can be enabled at both the root config level, or on the entity's config.\n * If a collectionConfig/globalConfig is provided, checks if it is enabled at the root level,\n * or on the entity's own config.\n */\nexport const isLivePreviewEnabled = ({\n collectionConfig,\n config,\n globalConfig,\n}: {\n collectionConfig?: CollectionConfig\n config: SanitizedConfig\n globalConfig?: GlobalConfig\n}): boolean => {\n if (globalConfig) {\n return Boolean(\n config.admin?.livePreview?.globals?.includes(globalConfig.slug) ||\n
|
|
1
|
+
{"version":3,"file":"handleLivePreview.js","names":["getLivePreviewConfig","collectionConfig","config","globalConfig","isLivePreviewEnabled","admin","livePreview","Boolean","globals","includes","slug","collections","handleLivePreview","collectionSlug","data","globalSlug","operation","req","payload","undefined","find","g","enabled","livePreviewConfig","livePreviewURL","url","result","locale","code","label","err","logger","error","msg"],"sources":["../../src/utilities/handleLivePreview.ts"],"sourcesContent":["import type {\n CollectionConfig,\n GlobalConfig,\n LivePreviewConfig,\n LivePreviewURLType,\n Operation,\n PayloadRequest,\n SanitizedConfig,\n} from 'payload'\n\nexport const getLivePreviewConfig = ({\n collectionConfig,\n config,\n globalConfig,\n isLivePreviewEnabled,\n}: {\n collectionConfig?: CollectionConfig\n config: SanitizedConfig\n globalConfig?: GlobalConfig\n isLivePreviewEnabled: boolean\n}) => ({\n ...(isLivePreviewEnabled ? config.admin.livePreview : {}),\n ...(collectionConfig?.admin?.livePreview || {}),\n ...(globalConfig?.admin?.livePreview || {}),\n})\n\n/**\n * Multi-level check to determine whether live preview is enabled on a collection or global.\n * For example, live preview can be enabled at both the root config level, or on the entity's config.\n * If a collectionConfig/globalConfig is provided, checks if it is enabled at the root level,\n * or on the entity's own config.\n */\nexport const isLivePreviewEnabled = ({\n collectionConfig,\n config,\n globalConfig,\n}: {\n collectionConfig?: CollectionConfig\n config: SanitizedConfig\n globalConfig?: GlobalConfig\n}): boolean => {\n if (globalConfig) {\n return Boolean(\n config.admin?.livePreview?.globals?.includes(globalConfig.slug) ||\n globalConfig.admin?.livePreview,\n )\n }\n\n if (collectionConfig) {\n return Boolean(\n config.admin?.livePreview?.collections?.includes(collectionConfig.slug) ||\n collectionConfig.admin?.livePreview,\n )\n }\n}\n\n/**\n * 1. Looks up the relevant live preview config, which could have been enabled:\n * a. At the root level, e.g. `collections: ['posts']`\n * b. On the collection or global config, e.g. `admin: { livePreview: { ... } }`\n * 2. Determines if live preview is enabled, and if not, early returns.\n * 3. Merges the config with the root config, if necessary.\n * 4. Executes the `url` function, if necessary.\n *\n * Notice: internal function only. Subject to change at any time. Use at your own risk.\n */\nexport const handleLivePreview = async ({\n collectionSlug,\n config,\n data,\n globalSlug,\n operation,\n req,\n}: {\n collectionSlug?: string\n config: SanitizedConfig\n data: Record<string, unknown>\n globalSlug?: string\n operation?: Operation\n req: PayloadRequest\n}): Promise<{\n isLivePreviewEnabled?: boolean\n livePreviewConfig?: LivePreviewConfig\n livePreviewURL?: LivePreviewURLType\n}> => {\n const collectionConfig = collectionSlug\n ? req.payload.collections[collectionSlug]?.config\n : undefined\n\n const globalConfig = globalSlug ? config.globals.find((g) => g.slug === globalSlug) : undefined\n\n const enabled = isLivePreviewEnabled({\n collectionConfig,\n config,\n globalConfig,\n })\n\n if (!enabled) {\n return {}\n }\n\n const livePreviewConfig = getLivePreviewConfig({\n collectionConfig,\n config,\n globalConfig,\n isLivePreviewEnabled: enabled,\n })\n\n let livePreviewURL: string | undefined\n\n if (typeof livePreviewConfig?.url === 'string') {\n livePreviewURL = livePreviewConfig.url\n }\n\n if (typeof livePreviewConfig?.url === 'function' && operation !== 'create') {\n try {\n const result = await livePreviewConfig.url({\n collectionConfig,\n data,\n globalConfig,\n locale: { code: req.locale, label: '' },\n payload: req.payload,\n req,\n })\n\n if (typeof result === 'string') {\n livePreviewURL = result\n }\n } catch (err) {\n req.payload.logger.error({\n err,\n msg: `There was an error executing the live preview URL function for ${collectionSlug || globalSlug}`,\n })\n }\n }\n\n return { isLivePreviewEnabled: enabled, livePreviewConfig, livePreviewURL }\n}\n"],"mappings":"AAUA,OAAO,MAAMA,oBAAA,GAAuBA,CAAC;EACnCC,gBAAgB;EAChBC,MAAM;EACNC,YAAY;EACZC;AAAoB,CAMrB,MAAM;EACL,IAAIA,oBAAA,GAAuBF,MAAA,CAAOG,KAAK,CAACC,WAAW,GAAG,CAAC,CAAC;EACxD,IAAIL,gBAAA,EAAkBI,KAAA,EAAOC,WAAA,IAAe,CAAC,CAAC;EAC9C,IAAIH,YAAA,EAAcE,KAAA,EAAOC,WAAA,IAAe,CAAC,CAAC;AAC5C;AAEA;;;;;;AAMA,OAAO,MAAMF,oBAAA,GAAuBA,CAAC;EACnCH,gBAAgB;EAChBC,MAAM;EACNC;AAAY,CAKb;EACC,IAAIA,YAAA,EAAc;IAChB,OAAOI,OAAA,CACLL,MAAA,CAAOG,KAAK,EAAEC,WAAA,EAAaE,OAAA,EAASC,QAAA,CAASN,YAAA,CAAaO,IAAI,KAC9DP,YAAA,CAAaE,KAAK,EAAEC,WAAA;EAExB;EAEA,IAAIL,gBAAA,EAAkB;IACpB,OAAOM,OAAA,CACLL,MAAA,CAAOG,KAAK,EAAEC,WAAA,EAAaK,WAAA,EAAaF,QAAA,CAASR,gBAAA,CAAiBS,IAAI,KACtET,gBAAA,CAAiBI,KAAK,EAAEC,WAAA;EAE5B;AACF;AAEA;;;;;;;;;;AAUA,OAAO,MAAMM,iBAAA,GAAoB,MAAAA,CAAO;EACtCC,c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AAkBE,UAAA;MAC3F;IACF;EACF;EAEA,OAAO;IAAEX,oBAAA,EAAsBkB,OAAA;IAASC,iBAAA;IAAmBC;EAAe;AAC5E","ignoreList":[]}
|
|
@@ -15,21 +15,13 @@ type CreateServerFunctionHandlerArgs = {
|
|
|
15
15
|
* for adapter-specific functions; today both adapters run the shared set only.
|
|
16
16
|
*/
|
|
17
17
|
serverFunctions?: Record<string, ServerFunction<any, any>>;
|
|
18
|
-
/**
|
|
19
|
-
* Post-processes each handler's return value before it goes over the wire.
|
|
20
|
-
* The TanStack Start adapter passes `serializeForRsc` to convert React
|
|
21
|
-
* elements into RSC handles; Next.js ships them natively and omits this.
|
|
22
|
-
*/
|
|
23
|
-
transformResult?: (result: unknown) => Promise<unknown> | unknown;
|
|
24
18
|
};
|
|
25
19
|
/**
|
|
26
20
|
* Factory for the framework-agnostic `handleServerFunctions` entry point.
|
|
27
21
|
*
|
|
28
22
|
* All adapters dispatch from the shared registry (`sharedServerFunctions`) and
|
|
29
|
-
*
|
|
30
|
-
* — so there is a single dispatch implementation and the handler sets cannot
|
|
31
|
-
* drift between frameworks.
|
|
23
|
+
* inject their own admin context. Each framework owns its native response transport.
|
|
32
24
|
*/
|
|
33
|
-
export declare const createServerFunctionHandler: ({ initAdminContext, serverFunctions,
|
|
25
|
+
export declare const createServerFunctionHandler: ({ initAdminContext, serverFunctions, }: CreateServerFunctionHandlerArgs) => ServerFunctionHandler;
|
|
34
26
|
export {};
|
|
35
27
|
//# sourceMappingURL=handleServerFunctions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAEZ,SAAS,EACT,eAAe,EACf,cAAc,EACd,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAIhB,KAAK,kBAAkB,GAAG,CAAC,IAAI,EAAE;IAC/B,aAAa,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IACzD,SAAS,EAAE,SAAS,CAAA;CACrB,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;AAE3B,KAAK,+BAA+B,GAAG;IACrC;;;;OAIG;IACH,gBAAgB,EAAE,kBAAkB,CAAA;IACpC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAEZ,SAAS,EACT,eAAe,EACf,cAAc,EACd,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAIhB,KAAK,kBAAkB,GAAG,CAAC,IAAI,EAAE;IAC/B,aAAa,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IACzD,SAAS,EAAE,SAAS,CAAA;CACrB,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;AAE3B,KAAK,+BAA+B,GAAG;IACrC;;;;OAIG;IACH,gBAAgB,EAAE,kBAAkB,CAAA;IACpC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;CAC3D,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,2CAGrC,+BAA+B,KAAG,qBAqCpC,CAAA"}
|
|
@@ -3,14 +3,11 @@ import { sharedServerFunctions } from './serverFunctionRegistry.js';
|
|
|
3
3
|
* Factory for the framework-agnostic `handleServerFunctions` entry point.
|
|
4
4
|
*
|
|
5
5
|
* All adapters dispatch from the shared registry (`sharedServerFunctions`) and
|
|
6
|
-
*
|
|
7
|
-
* — so there is a single dispatch implementation and the handler sets cannot
|
|
8
|
-
* drift between frameworks.
|
|
6
|
+
* inject their own admin context. Each framework owns its native response transport.
|
|
9
7
|
*/
|
|
10
8
|
export const createServerFunctionHandler = ({
|
|
11
9
|
initAdminContext,
|
|
12
|
-
serverFunctions
|
|
13
|
-
transformResult
|
|
10
|
+
serverFunctions
|
|
14
11
|
}) => {
|
|
15
12
|
const baseServerFunctions = serverFunctions ? {
|
|
16
13
|
...sharedServerFunctions,
|
|
@@ -47,8 +44,7 @@ export const createServerFunctionHandler = ({
|
|
|
47
44
|
if (!fn) {
|
|
48
45
|
throw new Error(`Unknown Server Function: ${fnKey}`);
|
|
49
46
|
}
|
|
50
|
-
|
|
51
|
-
return transformResult ? await transformResult(result) : result;
|
|
47
|
+
return await fn(augmentedArgs);
|
|
52
48
|
};
|
|
53
49
|
};
|
|
54
50
|
//# sourceMappingURL=handleServerFunctions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunctions.js","names":["sharedServerFunctions","createServerFunctionHandler","initAdminContext","serverFunctions","
|
|
1
|
+
{"version":3,"file":"handleServerFunctions.js","names":["sharedServerFunctions","createServerFunctionHandler","initAdminContext","serverFunctions","baseServerFunctions","args","name","fnKey","fnArgs","config","configPromise","importMap","extraServerFunctions","cookies","locale","permissions","req","user","augmentedArgs","fn","Error"],"sources":["../../src/utilities/handleServerFunctions.ts"],"sourcesContent":["import type {\n AdminContext,\n DefaultServerFunctionArgs,\n ImportMap,\n SanitizedConfig,\n ServerFunction,\n ServerFunctionHandler,\n} from 'payload'\n\nimport { sharedServerFunctions } from './serverFunctionRegistry.js'\n\ntype InitAdminContextFn = (args: {\n configPromise: Promise<SanitizedConfig> | SanitizedConfig\n importMap: ImportMap\n}) => Promise<AdminContext>\n\ntype CreateServerFunctionHandlerArgs = {\n /**\n * Framework-specific admin context creation. The adapter closes over its own\n * `ServerAdapter` / request source (Next.js: `initAdminContext` + `nextServerAdapter`;\n * TanStack Start: its `getRequest()`-based `initAdminContext`).\n */\n initAdminContext: InitAdminContextFn\n /**\n * Additional handlers registered alongside `sharedServerFunctions`. Reserved\n * for adapter-specific functions; today both adapters run the shared set only.\n */\n serverFunctions?: Record<string, ServerFunction<any, any>>\n}\n\n/**\n * Factory for the framework-agnostic `handleServerFunctions` entry point.\n *\n * All adapters dispatch from the shared registry (`sharedServerFunctions`) and\n * inject their own admin context. Each framework owns its native response transport.\n */\nexport const createServerFunctionHandler = ({\n initAdminContext,\n serverFunctions,\n}: CreateServerFunctionHandlerArgs): ServerFunctionHandler => {\n const baseServerFunctions: Record<string, ServerFunction<any, any>> = serverFunctions\n ? { ...sharedServerFunctions, ...serverFunctions }\n : sharedServerFunctions\n\n return async (args) => {\n const {\n name: fnKey,\n args: fnArgs,\n config: configPromise,\n importMap,\n serverFunctions: extraServerFunctions,\n } = args\n\n const { cookies, locale, permissions, req, user } = await initAdminContext({\n configPromise,\n importMap,\n })\n\n const augmentedArgs: DefaultServerFunctionArgs = {\n ...fnArgs,\n cookies,\n importMap,\n locale,\n permissions,\n req,\n user,\n }\n\n const fn = extraServerFunctions?.[fnKey] || baseServerFunctions[fnKey]\n\n if (!fn) {\n throw new Error(`Unknown Server Function: ${fnKey}`)\n }\n\n return await fn(augmentedArgs)\n }\n}\n"],"mappings":"AASA,SAASA,qBAAqB,QAAQ;AAqBtC;;;;;;AAMA,OAAO,MAAMC,2BAAA,GAA8BA,CAAC;EAC1CC,gBAAgB;EAChBC;AAAe,CACiB;EAChC,MAAMC,mBAAA,GAAgED,eAAA,GAClE;IAAE,GAAGH,qBAAqB;IAAE,GAAGG;EAAgB,IAC/CH,qBAAA;EAEJ,OAAO,MAAOK,IAAA;IACZ,MAAM;MACJC,IAAA,EAAMC,KAAK;MACXF,IAAA,EAAMG,MAAM;MACZC,MAAA,EAAQC,aAAa;MACrBC,SAAS;MACTR,eAAA,EAAiBS;IAAoB,CACtC,GAAGP,IAAA;IAEJ,MAAM;MAAEQ,OAAO;MAAEC,MAAM;MAAEC,WAAW;MAAEC,GAAG;MAAEC;IAAI,CAAE,GAAG,MAAMf,gBAAA,CAAiB;MACzEQ,aAAA;MACAC;IACF;IAEA,MAAMO,aAAA,GAA2C;MAC/C,GAAGV,MAAM;MACTK,OAAA;MACAF,SAAA;MACAG,MAAA;MACAC,WAAA;MACAC,GAAA;MACAC;IACF;IAEA,MAAME,EAAA,GAAKP,oBAAA,GAAuBL,KAAA,CAAM,IAAIH,mBAAmB,CAACG,KAAA,CAAM;IAEtE,IAAI,CAACY,EAAA,EAAI;MACP,MAAM,IAAIC,KAAA,CAAM,4BAA4Bb,KAAA,EAAO;IACrD;IAEA,OAAO,MAAMY,EAAA,CAAGD,aAAA;EAClB;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasSavePermission.js","names":["hasSavePermission","args","collectionSlug","docPermissions","globalSlug","isEditing","Boolean","update","create"],"sources":["../../src/utilities/hasSavePermission.ts"],"sourcesContent":["import type {\n SanitizedCollectionPermission,\n SanitizedDocumentPermissions,\n SanitizedGlobalPermission,\n} from 'payload'\n\nexport const hasSavePermission = (args: {\n /*\n * Pass either `collectionSlug` or `globalSlug`\n */\n collectionSlug?: string\n docPermissions: SanitizedDocumentPermissions\n /*\n * Pass either `collectionSlug` or `globalSlug`\n */\n globalSlug?: string\n isEditing: boolean\n}) => {\n const { collectionSlug, docPermissions, globalSlug, isEditing } = args\n\n if (collectionSlug) {\n return Boolean(\n (isEditing && docPermissions?.update) ||\n
|
|
1
|
+
{"version":3,"file":"hasSavePermission.js","names":["hasSavePermission","args","collectionSlug","docPermissions","globalSlug","isEditing","Boolean","update","create"],"sources":["../../src/utilities/hasSavePermission.ts"],"sourcesContent":["import type {\n SanitizedCollectionPermission,\n SanitizedDocumentPermissions,\n SanitizedGlobalPermission,\n} from 'payload'\n\nexport const hasSavePermission = (args: {\n /*\n * Pass either `collectionSlug` or `globalSlug`\n */\n collectionSlug?: string\n docPermissions: SanitizedDocumentPermissions\n /*\n * Pass either `collectionSlug` or `globalSlug`\n */\n globalSlug?: string\n isEditing: boolean\n}) => {\n const { collectionSlug, docPermissions, globalSlug, isEditing } = args\n\n if (collectionSlug) {\n return Boolean(\n (isEditing && docPermissions?.update) ||\n (!isEditing && (docPermissions as SanitizedCollectionPermission)?.create),\n )\n }\n\n if (globalSlug) {\n return Boolean((docPermissions as SanitizedGlobalPermission)?.update)\n }\n\n return false\n}\n"],"mappings":"AAMA,OAAO,MAAMA,iBAAA,GAAqBC,IAAA;EAYhC,MAAM;IAAEC,cAAc;IAAEC,cAAc;IAAEC,UAAU;IAAEC;EAAS,CAAE,GAAGJ,IAAA;EAElE,IAAIC,cAAA,EAAgB;IAClB,OAAOI,OAAA,CACLD,SAAC,IAAaF,cAAA,EAAgBI,MAAA,IAC7B,CAACF,SAAA,IAAcF,cAAA,EAAkDK,MAAA;EAEtE;EAEA,IAAIJ,UAAA,EAAY;IACd,OAAOE,OAAA,CAASH,cAAA,EAA8CI,MAAA;EAChE;EAEA,OAAO;AACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedulePublishHandler.js","names":["canAccessAdmin","Forbidden","hasScheduledPublishEnabled","buildUpcomingScheduleWhere","getDocumentPermissions","getUpcomingScheduledPublishHandler","id","collectionSlug","globalSlug","req","payload","collectionConfig","collections","config","undefined","globalConfig","globals","find","slug","entityConfig","hasValidTarget","Boolean","t","hasPublishPermission","data","docs","db","collection","limit","sort","where","map","job","input","type","locale","timezone","waitUntil","schedulePublishHandler","date","deleteID","doc","global","localeToPublish","i18n","user","delete","overrideAccess","and","equals","taskSlug","message","jobs","queue","relationTo","value","task","err","error","logger"],"sources":["../../src/utilities/schedulePublishHandler.ts"],"sourcesContent":["import type { SchedulePublishTaskInput, ServerFunction } from 'payload'\n\nimport { canAccessAdmin, Forbidden } from 'payload'\nimport { hasScheduledPublishEnabled } from 'payload/shared'\n\nimport type { UpcomingEvent } from '../elements/PublishButton/ScheduleDrawer/types.js'\n\nimport { buildUpcomingScheduleWhere } from '../elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.js'\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\n\nexport type SchedulePublishHandlerArgs = {\n date?: Date\n /**\n * The job id to delete to remove a scheduled publish event\n */\n deleteID?: number | string\n localeToPublish?: string\n timezone?: string\n} & Pick<SchedulePublishTaskInput, 'doc' | 'global' | 'type'>\n\nexport type GetUpcomingScheduledPublishHandlerArgs = {\n collectionSlug?: string\n globalSlug?: string\n id?: number | string\n}\n\nexport const getUpcomingScheduledPublishHandler: ServerFunction<\n GetUpcomingScheduledPublishHandlerArgs,\n Promise<UpcomingEvent[]>\n> = async ({ id, collectionSlug, globalSlug, req }) => {\n const { payload } = req\n\n await canAccessAdmin({ req })\n\n const collectionConfig = collectionSlug ? payload.collections[collectionSlug]?.config : undefined\n const globalConfig = globalSlug\n ? payload.config.globals.find(({ slug }) => slug === globalSlug)\n : undefined\n const entityConfig = collectionConfig || globalConfig\n const hasValidTarget = Boolean(\n entityConfig &&\n
|
|
1
|
+
{"version":3,"file":"schedulePublishHandler.js","names":["canAccessAdmin","Forbidden","hasScheduledPublishEnabled","buildUpcomingScheduleWhere","getDocumentPermissions","getUpcomingScheduledPublishHandler","id","collectionSlug","globalSlug","req","payload","collectionConfig","collections","config","undefined","globalConfig","globals","find","slug","entityConfig","hasValidTarget","Boolean","t","hasPublishPermission","data","docs","db","collection","limit","sort","where","map","job","input","type","locale","timezone","waitUntil","schedulePublishHandler","date","deleteID","doc","global","localeToPublish","i18n","user","delete","overrideAccess","and","equals","taskSlug","message","jobs","queue","relationTo","value","task","err","error","logger"],"sources":["../../src/utilities/schedulePublishHandler.ts"],"sourcesContent":["import type { SchedulePublishTaskInput, ServerFunction } from 'payload'\n\nimport { canAccessAdmin, Forbidden } from 'payload'\nimport { hasScheduledPublishEnabled } from 'payload/shared'\n\nimport type { UpcomingEvent } from '../elements/PublishButton/ScheduleDrawer/types.js'\n\nimport { buildUpcomingScheduleWhere } from '../elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.js'\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\n\nexport type SchedulePublishHandlerArgs = {\n date?: Date\n /**\n * The job id to delete to remove a scheduled publish event\n */\n deleteID?: number | string\n localeToPublish?: string\n timezone?: string\n} & Pick<SchedulePublishTaskInput, 'doc' | 'global' | 'type'>\n\nexport type GetUpcomingScheduledPublishHandlerArgs = {\n collectionSlug?: string\n globalSlug?: string\n id?: number | string\n}\n\nexport const getUpcomingScheduledPublishHandler: ServerFunction<\n GetUpcomingScheduledPublishHandlerArgs,\n Promise<UpcomingEvent[]>\n> = async ({ id, collectionSlug, globalSlug, req }) => {\n const { payload } = req\n\n await canAccessAdmin({ req })\n\n const collectionConfig = collectionSlug ? payload.collections[collectionSlug]?.config : undefined\n const globalConfig = globalSlug\n ? payload.config.globals.find(({ slug }) => slug === globalSlug)\n : undefined\n const entityConfig = collectionConfig || globalConfig\n const hasValidTarget = Boolean(\n entityConfig &&\n hasScheduledPublishEnabled(entityConfig) &&\n ((collectionConfig && id !== undefined && !globalSlug) || (globalConfig && !collectionSlug)),\n )\n\n if (!hasValidTarget) {\n throw new Forbidden(req.t)\n }\n\n const { hasPublishPermission } = await getDocumentPermissions({\n id,\n collectionConfig,\n data: {},\n globalConfig,\n req,\n })\n\n if (!hasPublishPermission) {\n throw new Forbidden(req.t)\n }\n\n const { docs } = await payload.db.find<UpcomingEvent>({\n collection: 'payload-jobs',\n limit: 0,\n sort: 'waitUntil',\n where: buildUpcomingScheduleWhere({ id, collectionSlug, globalSlug }),\n })\n\n return docs.map((job) => ({\n id: job.id,\n input: {\n type: job.input?.type === 'unpublish' ? 'unpublish' : 'publish',\n locale: job.input?.locale,\n timezone: job.input?.timezone,\n },\n waitUntil: job.waitUntil,\n }))\n}\n\nexport const schedulePublishHandler: ServerFunction<SchedulePublishHandlerArgs> = async ({\n type,\n date,\n deleteID,\n doc,\n global,\n localeToPublish,\n req,\n timezone,\n}) => {\n const { i18n, payload, user } = req\n\n await canAccessAdmin({ req })\n\n try {\n if (deleteID) {\n await payload.delete({\n collection: 'payload-jobs',\n overrideAccess: true,\n req,\n where: {\n and: [{ id: { equals: deleteID } }, { taskSlug: { equals: 'schedulePublish' } }],\n },\n })\n\n return { message: i18n.t('general:success') }\n }\n\n await payload.jobs.queue({\n input: {\n type,\n doc,\n global,\n locale: localeToPublish,\n timezone,\n user:\n user && user.collection\n ? {\n relationTo: user.collection,\n value: user.id,\n }\n : undefined,\n },\n overrideAccess: true,\n task: 'schedulePublish',\n waitUntil: date,\n })\n } catch (err) {\n let error\n\n if (deleteID) {\n error = `Error deleting scheduled publish event with ID ${deleteID}`\n } else {\n error = `Error scheduling ${type} for `\n if (doc) {\n error += `document with ID ${doc.value} in collection ${doc.relationTo}`\n }\n }\n\n payload.logger.error({ err }, error)\n\n return {\n error,\n }\n }\n\n return { message: i18n.t('general:success') }\n}\n"],"mappings":"AAEA,SAASA,cAAc,EAAEC,SAAS,QAAQ;AAC1C,SAASC,0BAA0B,QAAQ;AAI3C,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,sBAAsB,QAAQ;AAkBvC,OAAO,MAAMC,kCAAA,GAGT,MAAAA,CAAO;EAAEC,EAAE;EAAEC,cAAc;EAAEC,UAAU;EAAEC;AAAG,CAAE;EAChD,MAAM;IAAEC;EAAO,CAAE,GAAGD,GAAA;EAEpB,MAAMT,cAAA,CAAe;IAAES;EAAI;EAE3B,MAAME,gBAAA,GAAmBJ,cAAA,GAAiBG,OAAA,CAAQE,WAAW,CAACL,cAAA,CAAe,EAAEM,MAAA,GAASC,SAAA;EACxF,MAAMC,YAAA,GAAeP,UAAA,GACjBE,OAAA,CAAQG,MAAM,CAACG,OAAO,CAACC,IAAI,CAAC,CAAC;IAAEC;EAAI,CAAE,KAAKA,IAAA,KAASV,UAAA,IACnDM,SAAA;EACJ,MAAMK,YAAA,GAAeR,gBAAA,IAAoBI,YAAA;EACzC,MAAMK,cAAA,GAAiBC,OAAA,CACrBF,YAAA,IACAjB,0BAAA,CAA2BiB,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List":[]}
|
|
@@ -6,13 +6,8 @@ import type { ServerFunction } from 'payload';
|
|
|
6
6
|
* from this single registry via `createServerFunctionHandler`, so a handler
|
|
7
7
|
* added here reaches every framework and the adapter lists can't drift.
|
|
8
8
|
*
|
|
9
|
-
* Handlers may return
|
|
10
|
-
*
|
|
11
|
-
* render-list, the render-field / render-widget output). Adapters ship those
|
|
12
|
-
* over the wire as RSC payloads: Next.js does this natively, while the TanStack
|
|
13
|
-
* Start adapter passes a `transformResult` (`serializeForRsc`) to
|
|
14
|
-
* `createServerFunctionHandler` that converts elements into
|
|
15
|
-
* `renderServerComponent` handles.
|
|
9
|
+
* Handlers may return React elements alongside ordinary data. Each framework
|
|
10
|
+
* adapter sends the complete result through its native React Flight transport.
|
|
16
11
|
*/
|
|
17
12
|
export declare const sharedServerFunctions: Record<string, ServerFunction<any, any>>;
|
|
18
13
|
//# sourceMappingURL=serverFunctionRegistry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverFunctionRegistry.d.ts","sourceRoot":"","sources":["../../src/utilities/serverFunctionRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAmB7C
|
|
1
|
+
{"version":3,"file":"serverFunctionRegistry.d.ts","sourceRoot":"","sources":["../../src/utilities/serverFunctionRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAmB7C;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,CAgB1E,CAAA"}
|
|
@@ -18,13 +18,8 @@ import { switchLanguageHandler } from './switchLanguageHandler.js';
|
|
|
18
18
|
* from this single registry via `createServerFunctionHandler`, so a handler
|
|
19
19
|
* added here reaches every framework and the adapter lists can't drift.
|
|
20
20
|
*
|
|
21
|
-
* Handlers may return
|
|
22
|
-
*
|
|
23
|
-
* render-list, the render-field / render-widget output). Adapters ship those
|
|
24
|
-
* over the wire as RSC payloads: Next.js does this natively, while the TanStack
|
|
25
|
-
* Start adapter passes a `transformResult` (`serializeForRsc`) to
|
|
26
|
-
* `createServerFunctionHandler` that converts elements into
|
|
27
|
-
* `renderServerComponent` handles.
|
|
21
|
+
* Handlers may return React elements alongside ordinary data. Each framework
|
|
22
|
+
* adapter sends the complete result through its native React Flight transport.
|
|
28
23
|
*/
|
|
29
24
|
export const sharedServerFunctions = {
|
|
30
25
|
'copy-data-from-locale': copyDataFromLocaleHandler,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverFunctionRegistry.js","names":["renderTabHandler","_internal_renderFieldHandler","getDefaultLayoutHandler","renderWidgetHandler","renderDocumentHandler","renderDocumentSlotsHandler","renderListHandler","getDashboardDocumentsHandler","buildFormStateHandler","buildTableStateHandler","copyDataFromLocaleHandler","getUpcomingScheduledPublishHandler","schedulePublishHandler","slugifyHandler","switchLanguageHandler","sharedServerFunctions","slugify"],"sources":["../../src/utilities/serverFunctionRegistry.ts"],"sourcesContent":["import type { ServerFunction } from 'payload'\n\nimport { renderTabHandler } from '../elements/Nav/SidebarTabs/renderTabServerFn.js'\nimport { _internal_renderFieldHandler } from '../forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.js'\nimport { getDefaultLayoutHandler, renderWidgetHandler } from '../views/Dashboard/serverFunctions.js'\nimport { renderDocumentHandler } from '../views/Document/handleServerFunction.js'\nimport { renderDocumentSlotsHandler } from '../views/Document/renderDocumentSlots.js'\nimport { renderListHandler } from '../views/List/handleServerFunction.js'\nimport { getDashboardDocumentsHandler } from '../widgets/RecentlyViewed/getDocuments.js'\nimport { buildFormStateHandler } from './buildFormState.js'\nimport { buildTableStateHandler } from './buildTableState.js'\nimport { copyDataFromLocaleHandler } from './copyDataFromLocale.js'\nimport {\n getUpcomingScheduledPublishHandler,\n schedulePublishHandler,\n} from './schedulePublishHandler.js'\nimport { slugifyHandler } from './slugify.js'\nimport { switchLanguageHandler } from './switchLanguageHandler.js'\n\n/**\n * The complete, framework-agnostic set of Payload server functions.\n *\n * Every adapter (`@payloadcms/next`, `@payloadcms/tanstack-start`) dispatches\n * from this single registry via `createServerFunctionHandler`, so a handler\n * added here reaches every framework and the adapter lists can't drift.\n *\n * Handlers may return
|
|
1
|
+
{"version":3,"file":"serverFunctionRegistry.js","names":["renderTabHandler","_internal_renderFieldHandler","getDefaultLayoutHandler","renderWidgetHandler","renderDocumentHandler","renderDocumentSlotsHandler","renderListHandler","getDashboardDocumentsHandler","buildFormStateHandler","buildTableStateHandler","copyDataFromLocaleHandler","getUpcomingScheduledPublishHandler","schedulePublishHandler","slugifyHandler","switchLanguageHandler","sharedServerFunctions","slugify"],"sources":["../../src/utilities/serverFunctionRegistry.ts"],"sourcesContent":["import type { ServerFunction } from 'payload'\n\nimport { renderTabHandler } from '../elements/Nav/SidebarTabs/renderTabServerFn.js'\nimport { _internal_renderFieldHandler } from '../forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.js'\nimport { getDefaultLayoutHandler, renderWidgetHandler } from '../views/Dashboard/serverFunctions.js'\nimport { renderDocumentHandler } from '../views/Document/handleServerFunction.js'\nimport { renderDocumentSlotsHandler } from '../views/Document/renderDocumentSlots.js'\nimport { renderListHandler } from '../views/List/handleServerFunction.js'\nimport { getDashboardDocumentsHandler } from '../widgets/RecentlyViewed/getDocuments.js'\nimport { buildFormStateHandler } from './buildFormState.js'\nimport { buildTableStateHandler } from './buildTableState.js'\nimport { copyDataFromLocaleHandler } from './copyDataFromLocale.js'\nimport {\n getUpcomingScheduledPublishHandler,\n schedulePublishHandler,\n} from './schedulePublishHandler.js'\nimport { slugifyHandler } from './slugify.js'\nimport { switchLanguageHandler } from './switchLanguageHandler.js'\n\n/**\n * The complete, framework-agnostic set of Payload server functions.\n *\n * Every adapter (`@payloadcms/next`, `@payloadcms/tanstack-start`) dispatches\n * from this single registry via `createServerFunctionHandler`, so a handler\n * added here reaches every framework and the adapter lists can't drift.\n *\n * Handlers may return React elements alongside ordinary data. Each framework\n * adapter sends the complete result through its native React Flight transport.\n */\nexport const sharedServerFunctions: Record<string, ServerFunction<any, any>> = {\n 'copy-data-from-locale': copyDataFromLocaleHandler,\n 'form-state': buildFormStateHandler,\n 'get-dashboard-documents': getDashboardDocumentsHandler,\n 'get-default-layout': getDefaultLayoutHandler,\n 'get-upcoming-scheduled-publish': getUpcomingScheduledPublishHandler,\n 'render-document': renderDocumentHandler,\n 'render-document-slots': renderDocumentSlotsHandler,\n 'render-field': _internal_renderFieldHandler,\n 'render-list': renderListHandler,\n 'render-tab': renderTabHandler,\n 'render-widget': renderWidgetHandler,\n 'schedule-publish': schedulePublishHandler,\n slugify: slugifyHandler,\n 'switch-language': switchLanguageHandler,\n 'table-state': buildTableStateHandler,\n}\n"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ;AACjC,SAASC,4BAA4B,QAAQ;AAC7C,SAASC,uBAAuB,EAAEC,mBAAmB,QAAQ;AAC7D,SAASC,qBAAqB,QAAQ;AACtC,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,iBAAiB,QAAQ;AAClC,SAASC,4BAA4B,QAAQ;AAC7C,SAASC,qBAAqB,QAAQ;AACtC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,yBAAyB,QAAQ;AAC1C,SACEC,kCAAkC,EAClCC,sBAAsB,QACjB;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,qBAAqB,QAAQ;AAEtC;;;;;;;;;;AAUA,OAAO,MAAMC,qBAAA,GAAkE;EAC7E,yBAAyBL,yBAAA;EACzB,cAAcF,qBAAA;EACd,2BAA2BD,4BAAA;EAC3B,sBAAsBL,uBAAA;EACtB,kCAAkCS,kCAAA;EAClC,mBAAmBP,qBAAA;EACnB,yBAAyBC,0BAAA;EACzB,gBAAgBJ,4BAAA;EAChB,eAAeK,iBAAA;EACf,cAAcN,gBAAA;EACd,iBAAiBG,mBAAA;EACjB,oBAAoBS,sBAAA;EACpBI,OAAA,EAASH,cAAA;EACT,mBAAmBC,qBAAA;EACnB,eAAeL;AACjB","ignoreList":[]}
|