@payloadcms/ui 3.89.0-internal.95c9cba → 3.89.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.d.ts +13 -0
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.d.ts.map +1 -0
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.js +41 -0
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.js.map +1 -0
- package/dist/elements/PublishButton/ScheduleDrawer/index.d.ts.map +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/index.js +8 -54
- package/dist/elements/PublishButton/ScheduleDrawer/index.js.map +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/types.d.ts +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/types.d.ts.map +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/types.js.map +1 -1
- package/dist/exports/client/index.js +24 -24
- package/dist/exports/client/index.js.map +4 -4
- package/dist/providers/LivePreview/index.d.ts.map +1 -1
- package/dist/providers/LivePreview/index.js +13 -6
- package/dist/providers/LivePreview/index.js.map +1 -1
- package/dist/providers/ServerFunctions/index.d.ts +5 -1
- package/dist/providers/ServerFunctions/index.d.ts.map +1 -1
- package/dist/providers/ServerFunctions/index.js +15 -0
- package/dist/providers/ServerFunctions/index.js.map +1 -1
- package/dist/utilities/formatAbsoluteURL.d.ts +1 -1
- package/dist/utilities/formatAbsoluteURL.d.ts.map +1 -1
- package/dist/utilities/formatAbsoluteURL.js +18 -8
- package/dist/utilities/formatAbsoluteURL.js.map +1 -1
- package/dist/utilities/formatAbsoluteURL.spec.js +27 -0
- package/dist/utilities/formatAbsoluteURL.spec.js.map +1 -0
- package/dist/utilities/isAbsoluteURL.d.ts +3 -0
- package/dist/utilities/isAbsoluteURL.d.ts.map +1 -0
- package/dist/utilities/isAbsoluteURL.js +15 -0
- package/dist/utilities/isAbsoluteURL.js.map +1 -0
- package/dist/utilities/isAbsoluteURL.spec.js +11 -0
- package/dist/utilities/isAbsoluteURL.spec.js.map +1 -0
- package/dist/utilities/isHttpURL.d.ts +3 -0
- package/dist/utilities/isHttpURL.d.ts.map +1 -0
- package/dist/utilities/isHttpURL.js +12 -0
- package/dist/utilities/isHttpURL.js.map +1 -0
- package/dist/utilities/isHttpURL.spec.js +25 -0
- package/dist/utilities/isHttpURL.spec.js.map +1 -0
- package/dist/utilities/schedulePublishHandler.d.ts +8 -1
- package/dist/utilities/schedulePublishHandler.d.ts.map +1 -1
- package/dist/utilities/schedulePublishHandler.js +74 -4
- package/dist/utilities/schedulePublishHandler.js.map +1 -1
- package/package.json +5 -4
|
@@ -1,4 +1,68 @@
|
|
|
1
|
-
import { canAccessAdmin } from 'payload';
|
|
1
|
+
import { canAccessAdmin, docAccessOperation, docAccessOperationGlobal, Forbidden } from 'payload';
|
|
2
|
+
import { hasScheduledPublishEnabled } from 'payload/shared';
|
|
3
|
+
import { buildUpcomingScheduleWhere } from '../elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.js';
|
|
4
|
+
export const getUpcomingScheduledPublishHandler = async ({
|
|
5
|
+
id,
|
|
6
|
+
collectionSlug,
|
|
7
|
+
globalSlug,
|
|
8
|
+
req
|
|
9
|
+
}) => {
|
|
10
|
+
const {
|
|
11
|
+
payload
|
|
12
|
+
} = req;
|
|
13
|
+
await canAccessAdmin({
|
|
14
|
+
req
|
|
15
|
+
});
|
|
16
|
+
const collectionConfig = collectionSlug ? payload.collections[collectionSlug]?.config : undefined;
|
|
17
|
+
const globalConfig = globalSlug ? payload.config.globals.find(({
|
|
18
|
+
slug
|
|
19
|
+
}) => slug === globalSlug) : undefined;
|
|
20
|
+
const entityConfig = collectionConfig || globalConfig;
|
|
21
|
+
const hasValidTarget = Boolean(entityConfig && hasScheduledPublishEnabled(entityConfig) && (collectionConfig && id !== undefined && !globalSlug || globalConfig && !collectionSlug));
|
|
22
|
+
if (!hasValidTarget) {
|
|
23
|
+
throw new Forbidden(req.t);
|
|
24
|
+
}
|
|
25
|
+
const hasPublishPermission = collectionConfig ? (await docAccessOperation({
|
|
26
|
+
id,
|
|
27
|
+
collection: {
|
|
28
|
+
config: collectionConfig
|
|
29
|
+
},
|
|
30
|
+
data: {
|
|
31
|
+
_status: 'published'
|
|
32
|
+
},
|
|
33
|
+
req
|
|
34
|
+
})).update : (await docAccessOperationGlobal({
|
|
35
|
+
data: {
|
|
36
|
+
_status: 'published'
|
|
37
|
+
},
|
|
38
|
+
globalConfig,
|
|
39
|
+
req
|
|
40
|
+
})).update;
|
|
41
|
+
if (!hasPublishPermission) {
|
|
42
|
+
throw new Forbidden(req.t);
|
|
43
|
+
}
|
|
44
|
+
const {
|
|
45
|
+
docs
|
|
46
|
+
} = await payload.db.find({
|
|
47
|
+
collection: 'payload-jobs',
|
|
48
|
+
limit: 0,
|
|
49
|
+
sort: 'waitUntil',
|
|
50
|
+
where: buildUpcomingScheduleWhere({
|
|
51
|
+
id,
|
|
52
|
+
collectionSlug,
|
|
53
|
+
globalSlug
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
return docs.map(job => ({
|
|
57
|
+
id: job.id,
|
|
58
|
+
input: {
|
|
59
|
+
type: job.input?.type === 'unpublish' ? 'unpublish' : 'publish',
|
|
60
|
+
locale: job.input?.locale,
|
|
61
|
+
timezone: job.input?.timezone
|
|
62
|
+
},
|
|
63
|
+
waitUntil: job.waitUntil
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
2
66
|
export const schedulePublishHandler = async ({
|
|
3
67
|
type,
|
|
4
68
|
date,
|
|
@@ -23,9 +87,15 @@ export const schedulePublishHandler = async ({
|
|
|
23
87
|
collection: 'payload-jobs',
|
|
24
88
|
req,
|
|
25
89
|
where: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
90
|
+
and: [{
|
|
91
|
+
id: {
|
|
92
|
+
equals: deleteID
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
taskSlug: {
|
|
96
|
+
equals: 'schedulePublish'
|
|
97
|
+
}
|
|
98
|
+
}]
|
|
29
99
|
}
|
|
30
100
|
});
|
|
31
101
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedulePublishHandler.js","names":["canAccessAdmin","
|
|
1
|
+
{"version":3,"file":"schedulePublishHandler.js","names":["canAccessAdmin","docAccessOperation","docAccessOperationGlobal","Forbidden","hasScheduledPublishEnabled","buildUpcomingScheduleWhere","getUpcomingScheduledPublishHandler","id","collectionSlug","globalSlug","req","payload","collectionConfig","collections","config","undefined","globalConfig","globals","find","slug","entityConfig","hasValidTarget","Boolean","t","hasPublishPermission","collection","data","_status","update","docs","db","limit","sort","where","map","job","input","type","locale","timezone","waitUntil","schedulePublishHandler","date","deleteID","doc","global","localeToPublish","i18n","user","delete","and","equals","taskSlug","jobs","queue","task","err","error","value","relationTo","logger","message"],"sources":["../../src/utilities/schedulePublishHandler.ts"],"sourcesContent":["import type { SchedulePublishTaskInput, ServerFunction } from 'payload'\n\nimport { canAccessAdmin, docAccessOperation, docAccessOperationGlobal, 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'\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 = collectionConfig\n ? (\n await docAccessOperation({\n id,\n collection: { config: collectionConfig },\n data: { _status: 'published' },\n req,\n })\n ).update\n : (\n await docAccessOperationGlobal({\n data: { _status: 'published' },\n globalConfig,\n req,\n })\n ).update\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 req,\n where: {\n and: [{ id: { equals: deleteID } }, { taskSlug: { equals: 'schedulePublish' } }],\n },\n })\n }\n\n await payload.jobs.queue({\n input: {\n type,\n doc,\n global,\n locale: localeToPublish,\n timezone,\n user: user.id,\n },\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,kBAAkB,EAAEC,wBAAwB,EAAEC,SAAS,QAAQ;AACxF,SAASC,0BAA0B,QAAQ;AAI3C,SAASC,0BAA0B,QAAQ;AAkB3C,OAAO,MAAMC,kCAAA,GAGT,MAAAA,CAAO;EAAEC,EAAE;EAAEC,cAAc;EAAEC,UAAU;EAAEC;AAAG,CAAE;EAChD,MAAM;IAAEC;EAAO,CAAE,GAAGD,GAAA;EAEpB,MAAMV,cAAA,CAAe;IAAEU;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,IACEhB,0BAAA,CAA2BgB,YAAA,MAC1BR,gBAAC,IAAoBL,EAAA,KAAOQ,SAAA,IAAa,CAACN,UAAA,IAAgBO,YAAA,IAAgB,CAACR,cAAc;EAG9F,IAAI,CAACa,cAAA,EAAgB;IACnB,MAAM,IAAIlB,SAAA,CAAUO,GAAA,CAAIa,CAAC;EAC3B;EAEA,MAAMC,oBAAA,GAAuBZ,gBAAA,GACzB,CACE,MAAMX,kBAAA,CAAmB;IACvBM,EAAA;IACAkB,UAAA,EAAY;MAAEX,MAAA,EAAQF;IAAiB;IACvCc,IAAA,EAAM;MAAEC,OAAA,EAAS;IAAY;IAC7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;YAAE3C,EAAA,EAAI;cAAE4C,MAAA,EAAQR;YAAS;UAAE,GAAG;YAAES,QAAA,EAAU;cAAED,MAAA,EAAQ;YAAkB;UAAE;QAChF;MACF;IACF;IAEA,MAAMxC,OAAA,CAAQ0C,IAAI,CAACC,KAAK,CAAC;MACvBlB,KAAA,EAAO;QACLC,IAAA;QACAO,GAAA;QACAC,MAAA;QACAP,MAAA,EAAQQ,eAAA;QACRP,QAAA;QACAS,IAAA,EAAMA,IAAA,CAAKzC;MACb;MACAgD,IAAA,EAAM;MACNf,SAAA,EAAWE;IACb;EACF,EAAE,OAAOc,GAAA,EAAK;IACZ,IAAIC,KAAA;IAEJ,IAAId,QAAA,EAAU;MACZc,KAAA,GAAQ,kDAAkDd,QAAA,EAAU;IACtE,OAAO;MACLc,KAAA,GAAQ,oBAAoBpB,IAAA,OAAW;MACvC,IAAIO,GAAA,EAAK;QACPa,KAAA,IAAS,oBAAoBb,GAAA,CAAIc,KAAK,kBAAkBd,GAAA,CAAIe,UAAU,EAAE;MAC1E;IACF;IAEAhD,OAAA,CAAQiD,MAAM,CAACH,KAAK,CAAC;MAAED;IAAI,GAAGC,KAAA;IAE9B,OAAO;MACLA;IACF;EACF;EAEA,OAAO;IAAEI,OAAA,EAASd,IAAA,CAAKxB,CAAC,CAAC;EAAmB;AAC9C","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/ui",
|
|
3
|
-
"version": "3.89.0
|
|
3
|
+
"version": "3.89.0",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -122,6 +122,7 @@
|
|
|
122
122
|
"@faceless-ui/scroll-info": "2.0.0",
|
|
123
123
|
"@faceless-ui/window-info": "3.0.1",
|
|
124
124
|
"@monaco-editor/react": "4.7.0",
|
|
125
|
+
"@swc/helpers": ">=0.5.17",
|
|
125
126
|
"bson-objectid": "2.0.4",
|
|
126
127
|
"date-fns": "4.1.0",
|
|
127
128
|
"dequal": "2.0.3",
|
|
@@ -136,7 +137,7 @@
|
|
|
136
137
|
"ts-essentials": "10.0.3",
|
|
137
138
|
"use-context-selector": "2.0.0",
|
|
138
139
|
"uuid": "13.0.2",
|
|
139
|
-
"@payloadcms/translations": "3.89.0
|
|
140
|
+
"@payloadcms/translations": "3.89.0"
|
|
140
141
|
},
|
|
141
142
|
"devDependencies": {
|
|
142
143
|
"@babel/cli": "7.27.2",
|
|
@@ -151,13 +152,13 @@
|
|
|
151
152
|
"esbuild": "0.27.1",
|
|
152
153
|
"esbuild-sass-plugin": "3.3.1",
|
|
153
154
|
"@payloadcms/eslint-config": "3.28.0",
|
|
154
|
-
"payload": "3.89.0
|
|
155
|
+
"payload": "3.89.0"
|
|
155
156
|
},
|
|
156
157
|
"peerDependencies": {
|
|
157
158
|
"next": ">=15.2.9 <15.3.0 || >=15.3.9 <15.4.0 || >=15.4.11 <15.5.0 || >=16.2.6 <17.0.0",
|
|
158
159
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
159
160
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
160
|
-
"payload": "3.89.0
|
|
161
|
+
"payload": "3.89.0"
|
|
161
162
|
},
|
|
162
163
|
"engines": {
|
|
163
164
|
"node": "^18.20.2 || >=20.9.0"
|