@payloadcms/ui 3.22.0 → 3.23.0-canary.597254e

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.
Files changed (54) hide show
  1. package/dist/elements/DatePicker/types.d.ts +1 -1
  2. package/dist/elements/DatePicker/types.d.ts.map +1 -1
  3. package/dist/elements/DatePicker/types.js.map +1 -1
  4. package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.d.ts.map +1 -1
  5. package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.js +17 -1
  6. package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.js.map +1 -1
  7. package/dist/elements/PublishButton/ScheduleDrawer/index.d.ts.map +1 -1
  8. package/dist/elements/PublishButton/ScheduleDrawer/index.js +52 -7
  9. package/dist/elements/PublishButton/ScheduleDrawer/index.js.map +1 -1
  10. package/dist/elements/PublishButton/ScheduleDrawer/types.d.ts +1 -0
  11. package/dist/elements/PublishButton/ScheduleDrawer/types.d.ts.map +1 -1
  12. package/dist/elements/PublishButton/ScheduleDrawer/types.js.map +1 -1
  13. package/dist/elements/TimezonePicker/index.d.ts +5 -0
  14. package/dist/elements/TimezonePicker/index.d.ts.map +1 -0
  15. package/dist/elements/TimezonePicker/index.js +50 -0
  16. package/dist/elements/TimezonePicker/index.js.map +1 -0
  17. package/dist/elements/TimezonePicker/index.scss +51 -0
  18. package/dist/elements/TimezonePicker/types.d.ts +8 -0
  19. package/dist/elements/TimezonePicker/types.d.ts.map +1 -0
  20. package/dist/elements/TimezonePicker/types.js +2 -0
  21. package/dist/elements/TimezonePicker/types.js.map +1 -0
  22. package/dist/elements/WhereBuilder/Condition/Select/formatOptions.d.ts +6 -0
  23. package/dist/elements/WhereBuilder/Condition/Select/formatOptions.d.ts.map +1 -0
  24. package/dist/elements/WhereBuilder/Condition/Select/formatOptions.js +12 -0
  25. package/dist/elements/WhereBuilder/Condition/Select/formatOptions.js.map +1 -0
  26. package/dist/elements/WhereBuilder/Condition/Select/index.d.ts.map +1 -1
  27. package/dist/elements/WhereBuilder/Condition/Select/index.js +1 -9
  28. package/dist/elements/WhereBuilder/Condition/Select/index.js.map +1 -1
  29. package/dist/exports/client/index.d.ts +2 -0
  30. package/dist/exports/client/index.d.ts.map +1 -1
  31. package/dist/exports/client/index.js +23 -23
  32. package/dist/exports/client/index.js.map +4 -4
  33. package/dist/exports/shared/index.js +2 -2
  34. package/dist/exports/shared/index.js.map +4 -4
  35. package/dist/fields/DateTime/index.d.ts +1 -2
  36. package/dist/fields/DateTime/index.d.ts.map +1 -1
  37. package/dist/fields/DateTime/index.js +73 -8
  38. package/dist/fields/DateTime/index.js.map +1 -1
  39. package/dist/forms/Form/mergeServerFormState.d.ts.map +1 -1
  40. package/dist/forms/Form/mergeServerFormState.js +1 -0
  41. package/dist/forms/Form/mergeServerFormState.js.map +1 -1
  42. package/dist/providers/DocumentInfo/index.d.ts.map +1 -1
  43. package/dist/providers/DocumentInfo/index.js +11 -2
  44. package/dist/providers/DocumentInfo/index.js.map +1 -1
  45. package/dist/styles.css +1 -1
  46. package/dist/utilities/formatDate.d.ts +2 -1
  47. package/dist/utilities/formatDate.d.ts.map +1 -1
  48. package/dist/utilities/formatDate.js +15 -3
  49. package/dist/utilities/formatDate.js.map +1 -1
  50. package/dist/utilities/schedulePublishHandler.d.ts +2 -1
  51. package/dist/utilities/schedulePublishHandler.d.ts.map +1 -1
  52. package/dist/utilities/schedulePublishHandler.js +3 -1
  53. package/dist/utilities/schedulePublishHandler.js.map +1 -1
  54. package/package.json +6 -5
@@ -3,8 +3,9 @@ type FormatDateArgs = {
3
3
  date: Date | number | string | undefined;
4
4
  i18n: I18n<any, any>;
5
5
  pattern: string;
6
+ timezone?: string;
6
7
  };
7
- export declare const formatDate: ({ date, i18n, pattern }: FormatDateArgs) => string;
8
+ export declare const formatDate: ({ date, i18n, pattern, timezone }: FormatDateArgs) => string;
8
9
  type FormatTimeToNowArgs = {
9
10
  date: Date | number | string | undefined;
10
11
  i18n: I18n<any, any>;
@@ -1 +1 @@
1
- {"version":3,"file":"formatDate.d.ts","sourceRoot":"","sources":["../../src/utilities/formatDate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAIpD,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACxC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,UAAU,4BAA6B,cAAc,KAAG,MAKpE,CAAA;AAED,KAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACxC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,eAAe,mBAAoB,mBAAmB,KAAG,MAKrE,CAAA"}
1
+ {"version":3,"file":"formatDate.d.ts","sourceRoot":"","sources":["../../src/utilities/formatDate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAKpD,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACxC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,UAAU,sCAAuC,cAAc,KAAG,MAoB9E,CAAA;AAED,KAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACxC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,eAAe,mBAAoB,mBAAmB,KAAG,MAKrE,CAAA"}
@@ -1,10 +1,22 @@
1
- import { format, formatDistanceToNow } from 'date-fns';
1
+ import { TZDateMini as TZDate } from '@date-fns/tz/date/mini';
2
+ import { format, formatDistanceToNow, transpose } from 'date-fns';
2
3
  export const formatDate = ({
3
4
  date,
4
5
  i18n,
5
- pattern
6
+ pattern,
7
+ timezone
6
8
  }) => {
7
- const theDate = new Date(date);
9
+ const theDate = new TZDate(new Date(date));
10
+ if (timezone) {
11
+ const DateWithOriginalTz = TZDate.tz(timezone);
12
+ const modifiedDate = theDate.withTimeZone(timezone);
13
+ // Transpose the date to the selected timezone
14
+ const dateWithTimezone = transpose(modifiedDate, DateWithOriginalTz);
15
+ // Transpose the date to the user's timezone - this is necessary because the react-datepicker component insists on displaying the date in the user's timezone
16
+ return i18n.dateFNS ? format(dateWithTimezone, pattern, {
17
+ locale: i18n.dateFNS
18
+ }) : `${i18n.t('general:loading')}...`;
19
+ }
8
20
  return i18n.dateFNS ? format(theDate, pattern, {
9
21
  locale: i18n.dateFNS
10
22
  }) : `${i18n.t('general:loading')}...`;
@@ -1 +1 @@
1
- {"version":3,"file":"formatDate.js","names":["format","formatDistanceToNow","formatDate","date","i18n","pattern","theDate","Date","dateFNS","locale","t","formatTimeToNow"],"sources":["../../src/utilities/formatDate.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\n\nimport { format, formatDistanceToNow } from 'date-fns'\n\ntype FormatDateArgs = {\n date: Date | number | string | undefined\n i18n: I18n<any, any>\n pattern: string\n}\n\nexport const formatDate = ({ date, i18n, pattern }: FormatDateArgs): string => {\n const theDate = new Date(date)\n return i18n.dateFNS\n ? format(theDate, pattern, { locale: i18n.dateFNS })\n : `${i18n.t('general:loading')}...`\n}\n\ntype FormatTimeToNowArgs = {\n date: Date | number | string | undefined\n i18n: I18n<any, any>\n}\n\nexport const formatTimeToNow = ({ date, i18n }: FormatTimeToNowArgs): string => {\n const theDate = new Date(date)\n return i18n?.dateFNS\n ? formatDistanceToNow(theDate, { locale: i18n.dateFNS })\n : `${i18n.t('general:loading')}...`\n}\n"],"mappings":"AAEA,SAASA,MAAM,EAAEC,mBAAmB,QAAQ;AAQ5C,OAAO,MAAMC,UAAA,GAAaA,CAAC;EAAEC,IAAI;EAAEC,IAAI;EAAEC;AAAO,CAAkB;EAChE,MAAMC,OAAA,GAAU,IAAIC,IAAA,CAAKJ,IAAA;EACzB,OAAOC,IAAA,CAAKI,OAAO,GACfR,MAAA,CAAOM,OAAA,EAASD,OAAA,EAAS;IAAEI,MAAA,EAAQL,IAAA,CAAKI;EAAQ,KAChD,GAAGJ,IAAA,CAAKM,CAAC,CAAC,uBAAuB;AACvC;AAOA,OAAO,MAAMC,eAAA,GAAkBA,CAAC;EAAER,IAAI;EAAEC;AAAI,CAAuB;EACjE,MAAME,OAAA,GAAU,IAAIC,IAAA,CAAKJ,IAAA;EACzB,OAAOC,IAAA,EAAMI,OAAA,GACTP,mBAAA,CAAoBK,OAAA,EAAS;IAAEG,MAAA,EAAQL,IAAA,CAAKI;EAAQ,KACpD,GAAGJ,IAAA,CAAKM,CAAC,CAAC,uBAAuB;AACvC","ignoreList":[]}
1
+ {"version":3,"file":"formatDate.js","names":["TZDateMini","TZDate","format","formatDistanceToNow","transpose","formatDate","date","i18n","pattern","timezone","theDate","Date","DateWithOriginalTz","tz","modifiedDate","withTimeZone","dateWithTimezone","dateFNS","locale","t","formatTimeToNow"],"sources":["../../src/utilities/formatDate.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\n\nimport { TZDateMini as TZDate } from '@date-fns/tz/date/mini'\nimport { format, formatDistanceToNow, transpose } from 'date-fns'\n\ntype FormatDateArgs = {\n date: Date | number | string | undefined\n i18n: I18n<any, any>\n pattern: string\n timezone?: string\n}\n\nexport const formatDate = ({ date, i18n, pattern, timezone }: FormatDateArgs): string => {\n const theDate = new TZDate(new Date(date))\n\n if (timezone) {\n const DateWithOriginalTz = TZDate.tz(timezone)\n\n const modifiedDate = theDate.withTimeZone(timezone)\n\n // Transpose the date to the selected timezone\n const dateWithTimezone = transpose(modifiedDate, DateWithOriginalTz)\n\n // Transpose the date to the user's timezone - this is necessary because the react-datepicker component insists on displaying the date in the user's timezone\n return i18n.dateFNS\n ? format(dateWithTimezone, pattern, { locale: i18n.dateFNS })\n : `${i18n.t('general:loading')}...`\n }\n\n return i18n.dateFNS\n ? format(theDate, pattern, { locale: i18n.dateFNS })\n : `${i18n.t('general:loading')}...`\n}\n\ntype FormatTimeToNowArgs = {\n date: Date | number | string | undefined\n i18n: I18n<any, any>\n}\n\nexport const formatTimeToNow = ({ date, i18n }: FormatTimeToNowArgs): string => {\n const theDate = new Date(date)\n return i18n?.dateFNS\n ? formatDistanceToNow(theDate, { locale: i18n.dateFNS })\n : `${i18n.t('general:loading')}...`\n}\n"],"mappings":"AAEA,SAASA,UAAA,IAAcC,MAAM,QAAQ;AACrC,SAASC,MAAM,EAAEC,mBAAmB,EAAEC,SAAS,QAAQ;AASvD,OAAO,MAAMC,UAAA,GAAaA,CAAC;EAAEC,IAAI;EAAEC,IAAI;EAAEC,OAAO;EAAEC;AAAQ,CAAkB;EAC1E,MAAMC,OAAA,GAAU,IAAIT,MAAA,CAAO,IAAIU,IAAA,CAAKL,IAAA;EAEpC,IAAIG,QAAA,EAAU;IACZ,MAAMG,kBAAA,GAAqBX,MAAA,CAAOY,EAAE,CAACJ,QAAA;IAErC,MAAMK,YAAA,GAAeJ,OAAA,CAAQK,YAAY,CAACN,QAAA;IAE1C;IACA,MAAMO,gBAAA,GAAmBZ,SAAA,CAAUU,YAAA,EAAcF,kBAAA;IAEjD;IACA,OAAOL,IAAA,CAAKU,OAAO,GACff,MAAA,CAAOc,gBAAA,EAAkBR,OAAA,EAAS;MAAEU,MAAA,EAAQX,IAAA,CAAKU;IAAQ,KACzD,GAAGV,IAAA,CAAKY,CAAC,CAAC,uBAAuB;EACvC;EAEA,OAAOZ,IAAA,CAAKU,OAAO,GACff,MAAA,CAAOQ,OAAA,EAASF,OAAA,EAAS;IAAEU,MAAA,EAAQX,IAAA,CAAKU;EAAQ,KAChD,GAAGV,IAAA,CAAKY,CAAC,CAAC,uBAAuB;AACvC;AAOA,OAAO,MAAMC,eAAA,GAAkBA,CAAC;EAAEd,IAAI;EAAEC;AAAI,CAAuB;EACjE,MAAMG,OAAA,GAAU,IAAIC,IAAA,CAAKL,IAAA;EACzB,OAAOC,IAAA,EAAMU,OAAA,GACTd,mBAAA,CAAoBO,OAAA,EAAS;IAAEQ,MAAA,EAAQX,IAAA,CAAKU;EAAQ,KACpD,GAAGV,IAAA,CAAKY,CAAC,CAAC,uBAAuB;AACvC","ignoreList":[]}
@@ -6,8 +6,9 @@ export type SchedulePublishHandlerArgs = {
6
6
  */
7
7
  deleteID?: number | string;
8
8
  req: PayloadRequest;
9
+ timezone?: string;
9
10
  } & SchedulePublishTaskInput;
10
- export declare const schedulePublishHandler: ({ type, date, deleteID, doc, global, locale, req, }: SchedulePublishHandlerArgs) => Promise<{
11
+ export declare const schedulePublishHandler: ({ type, date, deleteID, doc, global, locale, req, timezone, }: SchedulePublishHandlerArgs) => Promise<{
11
12
  error: any;
12
13
  message?: undefined;
13
14
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"schedulePublishHandler.d.ts","sourceRoot":"","sources":["../../src/utilities/schedulePublishHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAEvE,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,CAAC,EAAE,IAAI,CAAA;IACX;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B,GAAG,EAAE,cAAc,CAAA;CACpB,GAAG,wBAAwB,CAAA;AAE5B,eAAO,MAAM,sBAAsB,wDAQhC,0BAA0B;;;;;;EAkE5B,CAAA"}
1
+ {"version":3,"file":"schedulePublishHandler.d.ts","sourceRoot":"","sources":["../../src/utilities/schedulePublishHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAEvE,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,CAAC,EAAE,IAAI,CAAA;IACX;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B,GAAG,EAAE,cAAc,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG,wBAAwB,CAAA;AAE5B,eAAO,MAAM,sBAAsB,kEAShC,0BAA0B;;;;;;EAmE5B,CAAA"}
@@ -5,7 +5,8 @@ export const schedulePublishHandler = async ({
5
5
  doc,
6
6
  global,
7
7
  locale,
8
- req
8
+ req,
9
+ timezone
9
10
  }) => {
10
11
  const {
11
12
  i18n,
@@ -48,6 +49,7 @@ export const schedulePublishHandler = async ({
48
49
  doc,
49
50
  global,
50
51
  locale,
52
+ timezone,
51
53
  user: user.id
52
54
  },
53
55
  task: 'schedulePublish',
@@ -1 +1 @@
1
- {"version":3,"file":"schedulePublishHandler.js","names":["schedulePublishHandler","type","date","deleteID","doc","global","locale","req","i18n","payload","user","incomingUserSlug","collection","adminUserSlug","config","admin","Error","adminAccessFunction","collections","access","canAccessAdmin","delete","where","id","equals","jobs","queue","input","task","waitUntil","err","error","value","relationTo","logger","message","t"],"sources":["../../src/utilities/schedulePublishHandler.ts"],"sourcesContent":["import type { PayloadRequest, SchedulePublishTaskInput } from 'payload'\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 req: PayloadRequest\n} & SchedulePublishTaskInput\n\nexport const schedulePublishHandler = async ({\n type,\n date,\n deleteID,\n doc,\n global,\n locale,\n req,\n}: SchedulePublishHandlerArgs) => {\n const { i18n, payload, user } = req\n\n const incomingUserSlug = user?.collection\n\n const adminUserSlug = payload.config.admin.user\n\n if (!incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n\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\n try {\n if (deleteID) {\n await payload.delete({\n collection: 'payload-jobs',\n req,\n where: { id: { equals: deleteID } },\n })\n }\n\n await payload.jobs.queue({\n input: {\n type,\n doc,\n global,\n locale,\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(error)\n payload.logger.error(err)\n\n return {\n error,\n }\n }\n\n return { message: i18n.t('general:success') }\n}\n"],"mappings":"AAWA,OAAO,MAAMA,sBAAA,GAAyB,MAAAA,CAAO;EAC3CC,IAAI;EACJC,IAAI;EACJC,QAAQ;EACRC,GAAG;EACHC,MAAM;EACNC,MAAM;EACNC;AAAG,CACwB;EAC3B,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC;EAAI,CAAE,GAAGH,GAAA;EAEhC,MAAMI,gBAAA,GAAmBD,IAAA,EAAME,UAAA;EAE/B,MAAMC,aAAA,GAAgBJ,OAAA,CAAQK,MAAM,CAACC,KAAK,CAACL,IAAI;EAE/C,IAAI,CAACC,gBAAA,EAAkB;IACrB,MAAM,IAAIK,KAAA,CAAM;EAClB;EAEA,MAAMC,mBAAA,GAAsBR,OAAA,CAAQS,WAAW,CAACP,gBAAA,CAAiB,CAACG,MAAM,CAACK,MAAM,EAAEJ,KAAA;EAEjF;EACA,IAAIE,mBAAA,EAAqB;IACvB,MAAMG,cAAA,GAAiB,MAAMH,mBAAA,CAAoB;MAAEV;IAAI;IAEvD,IAAI,CAACa,cAAA,EAAgB;MACnB,MAAM,IAAIJ,KAAA,CAAM;IAClB;IACA;EACF,OAAO,IAAIH,aAAA,KAAkBF,gBAAA,EAAkB;IAC7C,MAAM,IAAIK,KAAA,CAAM;EAClB;EAEA,IAAI;IACF,IAAIb,QAAA,EAAU;MACZ,MAAMM,OAAA,CAAQY,MAAM,CAAC;QACnBT,UAAA,EAAY;QACZL,GAAA;QACAe,KAAA,EAAO;UAAEC,EAAA,EAAI;YAAEC,MAAA,EAAQrB;UAAS;QAAE;MACpC;IACF;IAEA,MAAMM,OAAA,CAAQgB,IAAI,CAACC,KAAK,CAAC;MACvBC,KAAA,EAAO;QACL1B,IAAA;QACAG,GAAA;QACAC,MAAA;QACAC,MAAA;QACAI,IAAA,EAAMA,IAAA,CAAKa;MACb;MACAK,IAAA,EAAM;MACNC,SAAA,EAAW3B;IACb;EACF,EAAE,OAAO4B,GAAA,EAAK;IACZ,IAAIC,KAAA;IAEJ,IAAI5B,QAAA,EAAU;MACZ4B,KAAA,GAAQ,kDAAkD5B,QAAA,EAAU;IACtE,OAAO;MACL4B,KAAA,GAAQ,oBAAoB9B,IAAA,OAAW;MACvC,IAAIG,GAAA,EAAK;QACP2B,KAAA,IAAS,oBAAoB3B,GAAA,CAAI4B,KAAK,kBAAkB5B,GAAA,CAAI6B,UAAU,EAAE;MAC1E;IACF;IAEAxB,OAAA,CAAQyB,MAAM,CAACH,KAAK,CAACA,KAAA;IACrBtB,OAAA,CAAQyB,MAAM,CAACH,KAAK,CAACD,GAAA;IAErB,OAAO;MACLC;IACF;EACF;EAEA,OAAO;IAAEI,OAAA,EAAS3B,IAAA,CAAK4B,CAAC,CAAC;EAAmB;AAC9C","ignoreList":[]}
1
+ {"version":3,"file":"schedulePublishHandler.js","names":["schedulePublishHandler","type","date","deleteID","doc","global","locale","req","timezone","i18n","payload","user","incomingUserSlug","collection","adminUserSlug","config","admin","Error","adminAccessFunction","collections","access","canAccessAdmin","delete","where","id","equals","jobs","queue","input","task","waitUntil","err","error","value","relationTo","logger","message","t"],"sources":["../../src/utilities/schedulePublishHandler.ts"],"sourcesContent":["import type { PayloadRequest, SchedulePublishTaskInput } from 'payload'\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 req: PayloadRequest\n timezone?: string\n} & SchedulePublishTaskInput\n\nexport const schedulePublishHandler = async ({\n type,\n date,\n deleteID,\n doc,\n global,\n locale,\n req,\n timezone,\n}: SchedulePublishHandlerArgs) => {\n const { i18n, payload, user } = req\n\n const incomingUserSlug = user?.collection\n\n const adminUserSlug = payload.config.admin.user\n\n if (!incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n\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\n try {\n if (deleteID) {\n await payload.delete({\n collection: 'payload-jobs',\n req,\n where: { id: { equals: deleteID } },\n })\n }\n\n await payload.jobs.queue({\n input: {\n type,\n doc,\n global,\n locale,\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(error)\n payload.logger.error(err)\n\n return {\n error,\n }\n }\n\n return { message: i18n.t('general:success') }\n}\n"],"mappings":"AAYA,OAAO,MAAMA,sBAAA,GAAyB,MAAAA,CAAO;EAC3CC,IAAI;EACJC,IAAI;EACJC,QAAQ;EACRC,GAAG;EACHC,MAAM;EACNC,MAAM;EACNC,GAAG;EACHC;AAAQ,CACmB;EAC3B,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC;EAAI,CAAE,GAAGJ,GAAA;EAEhC,MAAMK,gBAAA,GAAmBD,IAAA,EAAME,UAAA;EAE/B,MAAMC,aAAA,GAAgBJ,OAAA,CAAQK,MAAM,CAACC,KAAK,CAACL,IAAI;EAE/C,IAAI,CAACC,gBAAA,EAAkB;IACrB,MAAM,IAAIK,KAAA,CAAM;EAClB;EAEA,MAAMC,mBAAA,GAAsBR,OAAA,CAAQS,WAAW,CAACP,gBAAA,CAAiB,CAACG,MAAM,CAACK,MAAM,EAAEJ,KAAA;EAEjF;EACA,IAAIE,mBAAA,EAAqB;IACvB,MAAMG,cAAA,GAAiB,MAAMH,mBAAA,CAAoB;MAAEX;IAAI;IAEvD,IAAI,CAACc,cAAA,EAAgB;MACnB,MAAM,IAAIJ,KAAA,CAAM;IAClB;IACA;EACF,OAAO,IAAIH,aAAA,KAAkBF,gBAAA,EAAkB;IAC7C,MAAM,IAAIK,KAAA,CAAM;EAClB;EAEA,IAAI;IACF,IAAId,QAAA,EAAU;MACZ,MAAMO,OAAA,CAAQY,MAAM,CAAC;QACnBT,UAAA,EAAY;QACZN,GAAA;QACAgB,KAAA,EAAO;UAAEC,EAAA,EAAI;YAAEC,MAAA,EAAQtB;UAAS;QAAE;MACpC;IACF;IAEA,MAAMO,OAAA,CAAQgB,IAAI,CAACC,KAAK,CAAC;MACvBC,KAAA,EAAO;QACL3B,IAAA;QACAG,GAAA;QACAC,MAAA;QACAC,MAAA;QACAE,QAAA;QACAG,IAAA,EAAMA,IAAA,CAAKa;MACb;MACAK,IAAA,EAAM;MACNC,SAAA,EAAW5B;IACb;EACF,EAAE,OAAO6B,GAAA,EAAK;IACZ,IAAIC,KAAA;IAEJ,IAAI7B,QAAA,EAAU;MACZ6B,KAAA,GAAQ,kDAAkD7B,QAAA,EAAU;IACtE,OAAO;MACL6B,KAAA,GAAQ,oBAAoB/B,IAAA,OAAW;MACvC,IAAIG,GAAA,EAAK;QACP4B,KAAA,IAAS,oBAAoB5B,GAAA,CAAI6B,KAAK,kBAAkB7B,GAAA,CAAI8B,UAAU,EAAE;MAC1E;IACF;IAEAxB,OAAA,CAAQyB,MAAM,CAACH,KAAK,CAACA,KAAA;IACrBtB,OAAA,CAAQyB,MAAM,CAACH,KAAK,CAACD,GAAA;IAErB,OAAO;MACLC;IACF;EACF;EAEA,OAAO;IAAEI,OAAA,EAAS3B,IAAA,CAAK4B,CAAC,CAAC;EAAmB;AAC9C","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/ui",
3
- "version": "3.22.0",
3
+ "version": "3.23.0-canary.597254e",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "repository": {
6
6
  "type": "git",
@@ -111,6 +111,7 @@
111
111
  "dist"
112
112
  ],
113
113
  "dependencies": {
114
+ "@date-fns/tz": "1.2.0",
114
115
  "@dnd-kit/core": "6.0.8",
115
116
  "@dnd-kit/sortable": "7.0.2",
116
117
  "@faceless-ui/modal": "3.0.0-beta.2",
@@ -131,7 +132,7 @@
131
132
  "ts-essentials": "10.0.3",
132
133
  "use-context-selector": "2.0.0",
133
134
  "uuid": "10.0.0",
134
- "@payloadcms/translations": "3.22.0"
135
+ "@payloadcms/translations": "3.23.0-canary.597254e"
135
136
  },
136
137
  "devDependencies": {
137
138
  "@babel/cli": "7.26.4",
@@ -147,14 +148,14 @@
147
148
  "esbuild": "0.24.2",
148
149
  "esbuild-sass-plugin": "3.3.1",
149
150
  "eslint-plugin-react-compiler": "19.0.0-beta-714736e-20250131",
150
- "payload": "3.22.0",
151
- "@payloadcms/eslint-config": "3.9.0"
151
+ "@payloadcms/eslint-config": "3.9.0",
152
+ "payload": "3.23.0-canary.597254e"
152
153
  },
153
154
  "peerDependencies": {
154
155
  "next": "^15.0.0",
155
156
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
156
157
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
157
- "payload": "3.22.0"
158
+ "payload": "3.23.0-canary.597254e"
158
159
  },
159
160
  "engines": {
160
161
  "node": "^18.20.2 || >=20.9.0"