payload 3.51.0 → 3.52.0-internal.8a9caef

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 (39) hide show
  1. package/dist/collections/operations/create.d.ts.map +1 -1
  2. package/dist/collections/operations/create.js +1 -0
  3. package/dist/collections/operations/create.js.map +1 -1
  4. package/dist/collections/operations/utilities/update.d.ts.map +1 -1
  5. package/dist/collections/operations/utilities/update.js +1 -0
  6. package/dist/collections/operations/utilities/update.js.map +1 -1
  7. package/dist/config/client.d.ts.map +1 -1
  8. package/dist/config/client.js +3 -0
  9. package/dist/config/client.js.map +1 -1
  10. package/dist/config/types.d.ts +6 -0
  11. package/dist/config/types.d.ts.map +1 -1
  12. package/dist/config/types.js.map +1 -1
  13. package/dist/database/types.d.ts +2 -0
  14. package/dist/database/types.d.ts.map +1 -1
  15. package/dist/database/types.js.map +1 -1
  16. package/dist/globals/operations/update.d.ts.map +1 -1
  17. package/dist/globals/operations/update.js +1 -0
  18. package/dist/globals/operations/update.js.map +1 -1
  19. package/dist/versions/baseFields.d.ts +2 -0
  20. package/dist/versions/baseFields.d.ts.map +1 -1
  21. package/dist/versions/baseFields.js +23 -0
  22. package/dist/versions/baseFields.js.map +1 -1
  23. package/dist/versions/buildCollectionFields.d.ts.map +1 -1
  24. package/dist/versions/buildCollectionFields.js +16 -1
  25. package/dist/versions/buildCollectionFields.js.map +1 -1
  26. package/dist/versions/buildGlobalFields.d.ts.map +1 -1
  27. package/dist/versions/buildGlobalFields.js +16 -1
  28. package/dist/versions/buildGlobalFields.js.map +1 -1
  29. package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts.map +1 -1
  30. package/dist/versions/drafts/replaceWithDraftIfAvailable.js +6 -0
  31. package/dist/versions/drafts/replaceWithDraftIfAvailable.js.map +1 -1
  32. package/dist/versions/saveVersion.d.ts +2 -1
  33. package/dist/versions/saveVersion.d.ts.map +1 -1
  34. package/dist/versions/saveVersion.js +64 -31
  35. package/dist/versions/saveVersion.js.map +1 -1
  36. package/dist/versions/types.d.ts +1 -0
  37. package/dist/versions/types.d.ts.map +1 -1
  38. package/dist/versions/types.js.map +1 -1
  39. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/versions/baseFields.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type { CheckboxField, Field, Option } from '../fields/config/types.js'\n\nexport const statuses: Option[] = [\n {\n label: ({ t }) => t('version:draft'),\n value: 'draft',\n },\n {\n label: ({ t }) => t('version:published'),\n value: 'published',\n },\n]\n\nexport const baseVersionFields: Field[] = [\n {\n name: '_status',\n type: 'select',\n admin: {\n components: {\n Field: false,\n },\n disableBulkEdit: true,\n },\n defaultValue: 'draft',\n index: true,\n label: ({ t }) => t('version:status'),\n options: statuses,\n },\n]\n\n// When publishing a specific locale,\n// we need to create a new draft which acts as a\n// \"snapshot\" to retain all existing draft data.\n// This field will be used to exclude any snapshot versions\n// from the admin Versions list\nexport const versionSnapshotField: CheckboxField = {\n name: 'snapshot',\n type: 'checkbox',\n admin: {\n disableBulkEdit: true,\n disabled: true,\n },\n index: true,\n}\n"],"names":["statuses","label","t","value","baseVersionFields","name","type","admin","components","Field","disableBulkEdit","defaultValue","index","options","versionSnapshotField","disabled"],"mappings":"AAAA,oBAAoB;AAGpB,OAAO,MAAMA,WAAqB;IAChC;QACEC,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;QACpBC,OAAO;IACT;IACA;QACEF,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;QACpBC,OAAO;IACT;CACD,CAAA;AAED,OAAO,MAAMC,oBAA6B;IACxC;QACEC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,YAAY;gBACVC,OAAO;YACT;YACAC,iBAAiB;QACnB;QACAC,cAAc;QACdC,OAAO;QACPX,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;QACpBW,SAASb;IACX;CACD,CAAA;AAED,qCAAqC;AACrC,gDAAgD;AAChD,gDAAgD;AAChD,2DAA2D;AAC3D,+BAA+B;AAC/B,OAAO,MAAMc,uBAAsC;IACjDT,MAAM;IACNC,MAAM;IACNC,OAAO;QACLG,iBAAiB;QACjBK,UAAU;IACZ;IACAH,OAAO;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/versions/baseFields.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { CheckboxField, Field, Option } from '../fields/config/types.js'\n\nexport const statuses: Option[] = [\n {\n label: ({ t }) => t('version:draft'),\n value: 'draft',\n },\n {\n label: ({ t }) => t('version:published'),\n value: 'published',\n },\n]\n\nexport const baseVersionFields: Field[] = [\n {\n name: '_status',\n type: 'select',\n admin: {\n components: {\n Field: false,\n },\n disableBulkEdit: true,\n },\n defaultValue: 'draft',\n index: true,\n label: ({ t }) => t('version:status'),\n options: statuses,\n },\n]\n\n// When publishing a specific locale,\n// we need to create a new draft which acts as a\n// \"snapshot\" to retain all existing draft data.\n// This field will be used to exclude any snapshot versions\n// from the admin Versions list\nexport const versionSnapshotField: CheckboxField = {\n name: 'snapshot',\n type: 'checkbox',\n admin: {\n disableBulkEdit: true,\n disabled: true,\n },\n index: true,\n}\n\nexport function buildLocaleStatusField(config: SanitizedConfig): Field[] {\n if (!config.localization || !config.localization.locales) {\n return []\n }\n\n return config.localization.locales.map((locale) => {\n const code = typeof locale === 'string' ? locale : locale.code\n\n return {\n name: code,\n type: 'select',\n index: true,\n options: [\n { label: ({ t }) => t('version:draft'), value: 'draft' },\n { label: ({ t }) => t('version:published'), value: 'published' },\n ],\n }\n })\n}\n"],"names":["statuses","label","t","value","baseVersionFields","name","type","admin","components","Field","disableBulkEdit","defaultValue","index","options","versionSnapshotField","disabled","buildLocaleStatusField","config","localization","locales","map","locale","code"],"mappings":"AAAA,oBAAoB;AAIpB,OAAO,MAAMA,WAAqB;IAChC;QACEC,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;QACpBC,OAAO;IACT;IACA;QACEF,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;QACpBC,OAAO;IACT;CACD,CAAA;AAED,OAAO,MAAMC,oBAA6B;IACxC;QACEC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,YAAY;gBACVC,OAAO;YACT;YACAC,iBAAiB;QACnB;QACAC,cAAc;QACdC,OAAO;QACPX,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;QACpBW,SAASb;IACX;CACD,CAAA;AAED,qCAAqC;AACrC,gDAAgD;AAChD,gDAAgD;AAChD,2DAA2D;AAC3D,+BAA+B;AAC/B,OAAO,MAAMc,uBAAsC;IACjDT,MAAM;IACNC,MAAM;IACNC,OAAO;QACLG,iBAAiB;QACjBK,UAAU;IACZ;IACAH,OAAO;AACT,EAAC;AAED,OAAO,SAASI,uBAAuBC,MAAuB;IAC5D,IAAI,CAACA,OAAOC,YAAY,IAAI,CAACD,OAAOC,YAAY,CAACC,OAAO,EAAE;QACxD,OAAO,EAAE;IACX;IAEA,OAAOF,OAAOC,YAAY,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC;QACtC,MAAMC,OAAO,OAAOD,WAAW,WAAWA,SAASA,OAAOC,IAAI;QAE9D,OAAO;YACLjB,MAAMiB;YACNhB,MAAM;YACNM,OAAO;YACPC,SAAS;gBACP;oBAAEZ,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;oBAAkBC,OAAO;gBAAQ;gBACvD;oBAAEF,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;oBAAsBC,OAAO;gBAAY;aAChE;QACH;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"buildCollectionFields.d.ts","sourceRoot":"","sources":["../../src/versions/buildCollectionFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAItE,eAAO,MAAM,4BAA4B,GAAI,CAAC,SAAS,OAAO,kBACpD,eAAe,cACX,yBAAyB,YAC3B,CAAC,KACV,IAAI,SAAS,CAAC,GAAG,cAAc,EAAE,GAAG,KAAK,EA2E3C,CAAA"}
1
+ {"version":3,"file":"buildCollectionFields.d.ts","sourceRoot":"","sources":["../../src/versions/buildCollectionFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAItE,eAAO,MAAM,4BAA4B,GAAI,CAAC,SAAS,OAAO,kBACpD,eAAe,cACX,yBAAyB,YAC3B,CAAC,KACV,IAAI,SAAS,CAAC,GAAG,cAAc,EAAE,GAAG,KAAK,EA4F3C,CAAA"}
@@ -1,4 +1,4 @@
1
- import { versionSnapshotField } from './baseFields.js';
1
+ import { buildLocaleStatusField, versionSnapshotField } from './baseFields.js';
2
2
  export const buildVersionCollectionFields = (config, collection, flatten)=>{
3
3
  const fields = [
4
4
  {
@@ -50,6 +50,21 @@ export const buildVersionCollectionFields = (config, collection, flatten)=>{
50
50
  return locale.code;
51
51
  })
52
52
  });
53
+ if (config.localization.enableStatusLocalization) {
54
+ const localeStatusFields = buildLocaleStatusField(config);
55
+ fields.push({
56
+ name: 'localeStatus',
57
+ type: 'group',
58
+ admin: {
59
+ disableBulkEdit: true,
60
+ disabled: true
61
+ },
62
+ fields: localeStatusFields,
63
+ ...flatten && {
64
+ flattenedFields: localeStatusFields
65
+ }
66
+ });
67
+ }
53
68
  }
54
69
  fields.push({
55
70
  name: 'latest',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/versions/buildCollectionFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { Field, FlattenedField } from '../fields/config/types.js'\n\nimport { versionSnapshotField } from './baseFields.js'\n\nexport const buildVersionCollectionFields = <T extends boolean = false>(\n config: SanitizedConfig,\n collection: SanitizedCollectionConfig,\n flatten?: T,\n): true extends T ? FlattenedField[] : Field[] => {\n const fields: FlattenedField[] = [\n {\n name: 'parent',\n type: 'relationship',\n index: true,\n relationTo: collection.slug,\n },\n {\n name: 'version',\n type: 'group',\n fields: collection.fields.filter((field) => !('name' in field) || field.name !== 'id'),\n ...(flatten && {\n flattenedFields: collection.flattenedFields.filter((each) => each.name !== 'id'),\n })!,\n },\n {\n name: 'createdAt',\n type: 'date',\n admin: {\n disabled: true,\n },\n index: true,\n },\n {\n name: 'updatedAt',\n type: 'date',\n admin: {\n disabled: true,\n },\n index: true,\n },\n ]\n\n if (collection?.versions?.drafts) {\n if (config.localization) {\n fields.push(versionSnapshotField)\n\n fields.push({\n name: 'publishedLocale',\n type: 'select',\n admin: {\n disableBulkEdit: true,\n disabled: true,\n },\n index: true,\n options: config.localization.locales.map((locale) => {\n if (typeof locale === 'string') {\n return locale\n }\n\n return locale.code\n }),\n })\n }\n\n fields.push({\n name: 'latest',\n type: 'checkbox',\n admin: {\n disabled: true,\n },\n index: true,\n })\n\n if (collection?.versions?.drafts?.autosave) {\n fields.push({\n name: 'autosave',\n type: 'checkbox',\n index: true,\n })\n }\n }\n\n return fields as true extends T ? FlattenedField[] : Field[]\n}\n"],"names":["versionSnapshotField","buildVersionCollectionFields","config","collection","flatten","fields","name","type","index","relationTo","slug","filter","field","flattenedFields","each","admin","disabled","versions","drafts","localization","push","disableBulkEdit","options","locales","map","locale","code","autosave"],"mappings":"AAIA,SAASA,oBAAoB,QAAQ,kBAAiB;AAEtD,OAAO,MAAMC,+BAA+B,CAC1CC,QACAC,YACAC;IAEA,MAAMC,SAA2B;QAC/B;YACEC,MAAM;YACNC,MAAM;YACNC,OAAO;YACPC,YAAYN,WAAWO,IAAI;QAC7B;QACA;YACEJ,MAAM;YACNC,MAAM;YACNF,QAAQF,WAAWE,MAAM,CAACM,MAAM,CAAC,CAACC,QAAU,CAAE,CAAA,UAAUA,KAAI,KAAMA,MAAMN,IAAI,KAAK;YACjF,GAAIF,WAAW;gBACbS,iBAAiBV,WAAWU,eAAe,CAACF,MAAM,CAAC,CAACG,OAASA,KAAKR,IAAI,KAAK;YAC7E,CAAC;QACH;QACA;YACEA,MAAM;YACNC,MAAM;YACNQ,OAAO;gBACLC,UAAU;YACZ;YACAR,OAAO;QACT;QACA;YACEF,MAAM;YACNC,MAAM;YACNQ,OAAO;gBACLC,UAAU;YACZ;YACAR,OAAO;QACT;KACD;IAED,IAAIL,YAAYc,UAAUC,QAAQ;QAChC,IAAIhB,OAAOiB,YAAY,EAAE;YACvBd,OAAOe,IAAI,CAACpB;YAEZK,OAAOe,IAAI,CAAC;gBACVd,MAAM;gBACNC,MAAM;gBACNQ,OAAO;oBACLM,iBAAiB;oBACjBL,UAAU;gBACZ;gBACAR,OAAO;gBACPc,SAASpB,OAAOiB,YAAY,CAACI,OAAO,CAACC,GAAG,CAAC,CAACC;oBACxC,IAAI,OAAOA,WAAW,UAAU;wBAC9B,OAAOA;oBACT;oBAEA,OAAOA,OAAOC,IAAI;gBACpB;YACF;QACF;QAEArB,OAAOe,IAAI,CAAC;YACVd,MAAM;YACNC,MAAM;YACNQ,OAAO;gBACLC,UAAU;YACZ;YACAR,OAAO;QACT;QAEA,IAAIL,YAAYc,UAAUC,QAAQS,UAAU;YAC1CtB,OAAOe,IAAI,CAAC;gBACVd,MAAM;gBACNC,MAAM;gBACNC,OAAO;YACT;QACF;IACF;IAEA,OAAOH;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/versions/buildCollectionFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { Field, FlattenedField } from '../fields/config/types.js'\n\nimport { buildLocaleStatusField, versionSnapshotField } from './baseFields.js'\n\nexport const buildVersionCollectionFields = <T extends boolean = false>(\n config: SanitizedConfig,\n collection: SanitizedCollectionConfig,\n flatten?: T,\n): true extends T ? FlattenedField[] : Field[] => {\n const fields: FlattenedField[] = [\n {\n name: 'parent',\n type: 'relationship',\n index: true,\n relationTo: collection.slug,\n },\n {\n name: 'version',\n type: 'group',\n fields: collection.fields.filter((field) => !('name' in field) || field.name !== 'id'),\n ...(flatten && {\n flattenedFields: collection.flattenedFields.filter((each) => each.name !== 'id'),\n })!,\n },\n {\n name: 'createdAt',\n type: 'date',\n admin: {\n disabled: true,\n },\n index: true,\n },\n {\n name: 'updatedAt',\n type: 'date',\n admin: {\n disabled: true,\n },\n index: true,\n },\n ]\n\n if (collection?.versions?.drafts) {\n if (config.localization) {\n fields.push(versionSnapshotField)\n\n fields.push({\n name: 'publishedLocale',\n type: 'select',\n admin: {\n disableBulkEdit: true,\n disabled: true,\n },\n index: true,\n options: config.localization.locales.map((locale) => {\n if (typeof locale === 'string') {\n return locale\n }\n\n return locale.code\n }),\n })\n\n if (config.localization.enableStatusLocalization) {\n const localeStatusFields = buildLocaleStatusField(config)\n\n fields.push({\n name: 'localeStatus',\n type: 'group',\n admin: {\n disableBulkEdit: true,\n disabled: true,\n },\n fields: localeStatusFields,\n ...(flatten && {\n flattenedFields: localeStatusFields as FlattenedField[],\n })!,\n })\n }\n }\n\n fields.push({\n name: 'latest',\n type: 'checkbox',\n admin: {\n disabled: true,\n },\n index: true,\n })\n\n if (collection?.versions?.drafts?.autosave) {\n fields.push({\n name: 'autosave',\n type: 'checkbox',\n index: true,\n })\n }\n }\n\n return fields as true extends T ? FlattenedField[] : Field[]\n}\n"],"names":["buildLocaleStatusField","versionSnapshotField","buildVersionCollectionFields","config","collection","flatten","fields","name","type","index","relationTo","slug","filter","field","flattenedFields","each","admin","disabled","versions","drafts","localization","push","disableBulkEdit","options","locales","map","locale","code","enableSt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GAAIxB,WAAW;wBACbS,iBAAiBe;oBACnB,CAAC;gBACH;YACF;QACF;QAEAvB,OAAOe,IAAI,CAAC;YACVd,MAAM;YACNC,MAAM;YACNQ,OAAO;gBACLC,UAAU;YACZ;YACAR,OAAO;QACT;QAEA,IAAIL,YAAYc,UAAUC,QAAQW,UAAU;YAC1CxB,OAAOe,IAAI,CAAC;gBACVd,MAAM;gBACNC,MAAM;gBACNC,OAAO;YACT;QACF;IACF;IAEA,OAAOH;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"buildGlobalFields.d.ts","sourceRoot":"","sources":["../../src/versions/buildGlobalFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAIvE,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,OAAO,kBAChD,eAAe,UACf,qBAAqB,YACnB,CAAC,KACV,IAAI,SAAS,CAAC,GAAG,cAAc,EAAE,GAAG,KAAK,EAqE3C,CAAA"}
1
+ {"version":3,"file":"buildGlobalFields.d.ts","sourceRoot":"","sources":["../../src/versions/buildGlobalFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAIvE,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,OAAO,kBAChD,eAAe,UACf,qBAAqB,YACnB,CAAC,KACV,IAAI,SAAS,CAAC,GAAG,cAAc,EAAE,GAAG,KAAK,EAsF3C,CAAA"}
@@ -1,4 +1,4 @@
1
- import { versionSnapshotField } from './baseFields.js';
1
+ import { buildLocaleStatusField, versionSnapshotField } from './baseFields.js';
2
2
  export const buildVersionGlobalFields = (config, global, flatten)=>{
3
3
  const fields = [
4
4
  {
@@ -44,6 +44,21 @@ export const buildVersionGlobalFields = (config, global, flatten)=>{
44
44
  return locale.code;
45
45
  })
46
46
  });
47
+ if (config.localization.enableStatusLocalization) {
48
+ const localeStatusFields = buildLocaleStatusField(config);
49
+ fields.push({
50
+ name: 'localeStatus',
51
+ type: 'group',
52
+ admin: {
53
+ disableBulkEdit: true,
54
+ disabled: true
55
+ },
56
+ fields: localeStatusFields,
57
+ ...flatten && {
58
+ flattenedFields: localeStatusFields
59
+ }
60
+ });
61
+ }
47
62
  }
48
63
  fields.push({
49
64
  name: 'latest',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/versions/buildGlobalFields.ts"],"sourcesContent":["import type { SanitizedConfig } from '../config/types.js'\nimport type { Field, FlattenedField } from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\n\nimport { versionSnapshotField } from './baseFields.js'\n\nexport const buildVersionGlobalFields = <T extends boolean = false>(\n config: SanitizedConfig,\n global: SanitizedGlobalConfig,\n flatten?: T,\n): true extends T ? FlattenedField[] : Field[] => {\n const fields: FlattenedField[] = [\n {\n name: 'version',\n type: 'group',\n fields: global.fields,\n ...(flatten && {\n flattenedFields: global.flattenedFields,\n })!,\n },\n {\n name: 'createdAt',\n type: 'date',\n admin: {\n disabled: true,\n },\n index: true,\n },\n {\n name: 'updatedAt',\n type: 'date',\n admin: {\n disabled: true,\n },\n index: true,\n },\n ]\n\n if (global?.versions?.drafts) {\n if (config.localization) {\n fields.push(versionSnapshotField)\n\n fields.push({\n name: 'publishedLocale',\n type: 'select',\n admin: {\n disableBulkEdit: true,\n disabled: true,\n },\n index: true,\n options: config.localization.locales.map((locale) => {\n if (typeof locale === 'string') {\n return locale\n }\n\n return locale.code\n }),\n })\n }\n\n fields.push({\n name: 'latest',\n type: 'checkbox',\n admin: {\n disabled: true,\n },\n index: true,\n })\n\n if (global?.versions?.drafts?.autosave) {\n fields.push({\n name: 'autosave',\n type: 'checkbox',\n index: true,\n })\n }\n }\n\n return fields as true extends T ? FlattenedField[] : Field[]\n}\n"],"names":["versionSnapshotField","buildVersionGlobalFields","config","global","flatten","fields","name","type","flattenedFields","admin","disabled","index","versions","drafts","localization","push","disableBulkEdit","options","locales","map","locale","code","autosave"],"mappings":"AAIA,SAASA,oBAAoB,QAAQ,kBAAiB;AAEtD,OAAO,MAAMC,2BAA2B,CACtCC,QACAC,QACAC;IAEA,MAAMC,SAA2B;QAC/B;YACEC,MAAM;YACNC,MAAM;YACNF,QAAQF,OAAOE,MAAM;YACrB,GAAID,WAAW;gBACbI,iBAAiBL,OAAOK,eAAe;YACzC,CAAC;QACH;QACA;YACEF,MAAM;YACNC,MAAM;YACNE,OAAO;gBACLC,UAAU;YACZ;YACAC,OAAO;QACT;QACA;YACEL,MAAM;YACNC,MAAM;YACNE,OAAO;gBACLC,UAAU;YACZ;YACAC,OAAO;QACT;KACD;IAED,IAAIR,QAAQS,UAAUC,QAAQ;QAC5B,IAAIX,OAAOY,YAAY,EAAE;YACvBT,OAAOU,IAAI,CAACf;YAEZK,OAAOU,IAAI,CAAC;gBACVT,MAAM;gBACNC,MAAM;gBACNE,OAAO;oBACLO,iBAAiB;oBACjBN,UAAU;gBACZ;gBACAC,OAAO;gBACPM,SAASf,OAAOY,YAAY,CAACI,OAAO,CAACC,GAAG,CAAC,CAACC;oBACxC,IAAI,OAAOA,WAAW,UAAU;wBAC9B,OAAOA;oBACT;oBAEA,OAAOA,OAAOC,IAAI;gBACpB;YACF;QACF;QAEAhB,OAAOU,IAAI,CAAC;YACVT,MAAM;YACNC,MAAM;YACNE,OAAO;gBACLC,UAAU;YACZ;YACAC,OAAO;QACT;QAEA,IAAIR,QAAQS,UAAUC,QAAQS,UAAU;YACtCjB,OAAOU,IAAI,CAAC;gBACVT,MAAM;gBACNC,MAAM;gBACNI,OAAO;YACT;QACF;IACF;IAEA,OAAON;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/versions/buildGlobalFields.ts"],"sourcesContent":["import type { SanitizedConfig } from '../config/types.js'\nimport type { Field, FlattenedField } from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\n\nimport { buildLocaleStatusField, versionSnapshotField } from './baseFields.js'\n\nexport const buildVersionGlobalFields = <T extends boolean = false>(\n config: SanitizedConfig,\n global: SanitizedGlobalConfig,\n flatten?: T,\n): true extends T ? FlattenedField[] : Field[] => {\n const fields: FlattenedField[] = [\n {\n name: 'version',\n type: 'group',\n fields: global.fields,\n ...(flatten && {\n flattenedFields: global.flattenedFields,\n })!,\n },\n {\n name: 'createdAt',\n type: 'date',\n admin: {\n disabled: true,\n },\n index: true,\n },\n {\n name: 'updatedAt',\n type: 'date',\n admin: {\n disabled: true,\n },\n index: true,\n },\n ]\n\n if (global?.versions?.drafts) {\n if (config.localization) {\n fields.push(versionSnapshotField)\n\n fields.push({\n name: 'publishedLocale',\n type: 'select',\n admin: {\n disableBulkEdit: true,\n disabled: true,\n },\n index: true,\n options: config.localization.locales.map((locale) => {\n if (typeof locale === 'string') {\n return locale\n }\n\n return locale.code\n }),\n })\n\n if (config.localization.enableStatusLocalization) {\n const localeStatusFields = buildLocaleStatusField(config)\n\n fields.push({\n name: 'localeStatus',\n type: 'group',\n admin: {\n disableBulkEdit: true,\n disabled: true,\n },\n fields: localeStatusFields,\n ...(flatten && {\n flattenedFields: localeStatusFields as FlattenedField[],\n })!,\n })\n }\n }\n\n fields.push({\n name: 'latest',\n type: 'checkbox',\n admin: {\n disabled: true,\n },\n index: true,\n })\n\n if (global?.versions?.drafts?.autosave) {\n fields.push({\n name: 'autosave',\n type: 'checkbox',\n index: true,\n })\n }\n }\n\n return fields as true extends T ? FlattenedField[] : Field[]\n}\n"],"names":["buildLocaleStatusField","versionSnapshotField","buildVersionGlobalFields","config","global","flatten","fields","name","type","flattenedFields","admin","disabled","index","versions","drafts","localization","push","disableBulkEdit","options","locales","map","locale","code","enableStatusLocalization","localeStatusFields","autosave"],"mappings":"AAIA,SAASA,sBAAsB,EAAEC,oBAAoB,QAAQ,kBAAiB;AAE9E,OAAO,MAAMC,2BAA2B,CACtCC,QACAC,QACAC;IAEA,MAAMC,SAA2B;QAC/B;YACEC,MAAM;YACNC,MAAM;YACNF,QAAQF,OAAOE,MAAM;YACrB,GAAID,WAAW;gBACbI,iBAAiBL,OAAOK,eAAe;YACzC,CAAC;QACH;QACA;YACEF,MAAM;YACNC,MAAM;YACNE,OAAO;gBACLC,UAAU;YACZ;YACAC,OAAO;QACT;QACA;YACEL,MAAM;YACNC,MAAM;YACNE,OAAO;gBACLC,UAAU;YACZ;YACAC,OAAO;QACT;KACD;IAED,IAAIR,QAAQS,UAAUC,QAAQ;QAC5B,IAAIX,OAAOY,YAAY,EAAE;YACvBT,OAAOU,IAAI,CAACf;YAEZK,OAAOU,IAAI,CAAC;gBACVT,MAAM;gBACNC,MAAM;gBACNE,OAAO;oBACLO,iBAAiB;oBACjBN,UAAU;gBACZ;gBACAC,OAAO;gBACPM,SAASf,OAAOY,YAAY,CAACI,OAAO,CAACC,GAAG,CAAC,CAACC;oBACxC,IAAI,OAAOA,WAAW,UAAU;wBAC9B,OAAOA;oBACT;oBAEA,OAAOA,OAAOC,IAAI;gBACpB;YACF;YAEA,IAAInB,OAAOY,YAAY,CAACQ,wBAAwB,EAAE;gBAChD,MAAMC,qBAAqBxB,uBAAuBG;gBAElDG,OAAOU,IAAI,CAAC;oBACVT,MAAM;oBACNC,MAAM;oBACNE,OAAO;wBACLO,iBAAiB;wBACjBN,UAAU;oBACZ;oBACAL,QAAQkB;oBACR,GAAInB,WAAW;wBACbI,iBAAiBe;oBACnB,CAAC;gBACH;YACF;QACF;QAEAlB,OAAOU,IAAI,CAAC;YACVT,MAAM;YACNC,MAAM;YACNE,OAAO;gBACLC,UAAU;YACZ;YACAC,OAAO;QACT;QAEA,IAAIR,QAAQS,UAAUC,QAAQW,UAAU;YACtCnB,OAAOU,IAAI,CAAC;gBACVT,MAAM;gBACNC,MAAM;gBACNI,OAAO;YACT;QACF;IACF;IAEA,OAAON;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"replaceWithDraftIfAvailable.d.ts","sourceRoot":"","sources":["../../../src/versions/drafts/replaceWithDraftIfAvailable.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAC9F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAS,MAAM,sBAAsB,CAAA;AAS7E,KAAK,SAAS,CAAC,CAAC,IAAI;IAClB,YAAY,EAAE,YAAY,CAAA;IAC1B,GAAG,EAAE,CAAC,CAAA;IACN,MAAM,EAAE,yBAAyB,GAAG,qBAAqB,CAAA;IACzD,UAAU,EAAE,YAAY,GAAG,QAAQ,CAAA;IACnC,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,2BAA2B,GAAU,CAAC,SAAS,UAAU,2DAOnE,SAAS,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAyF1B,CAAA"}
1
+ {"version":3,"file":"replaceWithDraftIfAvailable.d.ts","sourceRoot":"","sources":["../../../src/versions/drafts/replaceWithDraftIfAvailable.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAC9F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAS,MAAM,sBAAsB,CAAA;AAS7E,KAAK,SAAS,CAAC,CAAC,IAAI;IAClB,YAAY,EAAE,YAAY,CAAA;IAC1B,GAAG,EAAE,CAAC,CAAA;IACN,MAAM,EAAE,yBAAyB,GAAG,qBAAqB,CAAA;IACzD,UAAU,EAAE,YAAY,GAAG,QAAQ,CAAA;IACnC,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,2BAA2B,GAAU,CAAC,SAAS,UAAU,2DAOnE,SAAS,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CA+F1B,CAAA"}
@@ -76,6 +76,12 @@ export const replaceWithDraftIfAvailable = async ({ accessResult, doc, entity, e
76
76
  if (!draft.version) {
77
77
  draft.version = {};
78
78
  }
79
+ // Lift locale status from version data if available
80
+ const localeStatus = draft.localeStatus || {};
81
+ if (locale && localeStatus[locale]) {
82
+ ;
83
+ draft.version['_status'] = localeStatus[locale];
84
+ }
79
85
  // Disregard all other draft content at this point,
80
86
  // Only interested in the version itself.
81
87
  // Operations will handle firing hooks, etc.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/versions/drafts/replaceWithDraftIfAvailable.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type { SanitizedCollectionConfig, TypeWithID } from '../../collections/config/types.js'\nimport type { AccessResult } from '../../config/types.js'\nimport type { FindGlobalVersionsArgs, FindVersionsArgs } from '../../database/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { PayloadRequest, SelectType, Where } from '../../types/index.js'\n\nimport { hasWhereAccessResult } from '../../auth/index.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { docHasTimestamps } from '../../types/index.js'\nimport { sanitizeInternalFields } from '../../utilities/sanitizeInternalFields.js'\nimport { appendVersionToQueryKey } from './appendVersionToQueryKey.js'\nimport { getQueryDraftsSelect } from './getQueryDraftsSelect.js'\n\ntype Arguments<T> = {\n accessResult: AccessResult\n doc: T\n entity: SanitizedCollectionConfig | SanitizedGlobalConfig\n entityType: 'collection' | 'global'\n overrideAccess: boolean\n req: PayloadRequest\n select?: SelectType\n}\n\nexport const replaceWithDraftIfAvailable = async <T extends TypeWithID>({\n accessResult,\n doc,\n entity,\n entityType,\n req,\n select,\n}: Arguments<T>): Promise<T> => {\n const { locale } = req\n\n const queryToBuild: Where = {\n and: [\n {\n 'version._status': {\n equals: 'draft',\n },\n },\n ],\n }\n\n if (entityType === 'collection') {\n queryToBuild.and!.push({\n parent: {\n equals: doc.id,\n },\n })\n }\n\n if (docHasTimestamps(doc)) {\n queryToBuild.and!.push({\n or: [\n {\n updatedAt: {\n greater_than: doc.updatedAt,\n },\n },\n {\n latest: {\n equals: true,\n },\n },\n ],\n })\n }\n\n let versionAccessResult: undefined | Where\n\n if (hasWhereAccessResult(accessResult)) {\n versionAccessResult = appendVersionToQueryKey(accessResult)\n }\n\n const findVersionsArgs: FindGlobalVersionsArgs & FindVersionsArgs = {\n collection: entity.slug,\n global: entity.slug,\n limit: 1,\n locale: locale!,\n pagination: false,\n req,\n select: getQueryDraftsSelect({ select }),\n sort: '-updatedAt',\n where: combineQueries(queryToBuild, versionAccessResult!),\n }\n\n let versionDocs\n if (entityType === 'global') {\n versionDocs = (await req.payload.db.findGlobalVersions<T>(findVersionsArgs)).docs\n } else {\n versionDocs = (await req.payload.db.findVersions<T>(findVersionsArgs)).docs\n }\n\n let draft = versionDocs[0]\n\n if (!draft) {\n return doc\n }\n\n draft = sanitizeInternalFields(draft)\n\n // Patch globalType onto version doc\n if (entityType === 'global' && 'globalType' in doc) {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n draft.version.globalType = doc.globalType\n }\n\n // handle when .version wasn't selected due to projection\n if (!draft.version) {\n draft.version = {} as T\n }\n\n // Disregard all other draft content at this point,\n // Only interested in the version itself.\n // Operations will handle firing hooks, etc.\n\n draft.version.id = doc.id\n\n return draft.version\n}\n"],"names":["hasWhereAccessResult","combineQueries","docHasTimestamps","sanitizeInternalFields","appendVersionToQueryKey","getQueryDraftsSelect","replaceWithDraftIfAvailable","accessResult","doc","entity","entityType","req","select","locale","queryToBuild","and","equals","push","parent","id","or","updatedAt","greater_than","latest","versionAccessResult","findVersionsArgs","collection","slug","global","limit","pagination","sort","where","versionDocs","payload","db","findGlobalVersions","docs","findVersions","draft","version","globalType"],"mappings":"AAAA,oBAAoB;AAOpB,SAASA,oBAAoB,QAAQ,sBAAqB;AAC1D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,gBAAgB,QAAQ,uBAAsB;AACvD,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,oBAAoB,QAAQ,4BAA2B;AAYhE,OAAO,MAAMC,8BAA8B,OAA6B,EACtEC,YAAY,EACZC,GAAG,EACHC,MAAM,EACNC,UAAU,EACVC,GAAG,EACHC,MAAM,EACO;IACb,MAAM,EAAEC,MAAM,EAAE,GAAGF;IAEnB,MAAMG,eAAsB;QAC1BC,KAAK;YACH;gBACE,mBAAmB;oBACjBC,QAAQ;gBACV;YACF;SACD;IACH;IAEA,IAAIN,eAAe,cAAc;QAC/BI,aAAaC,GAAG,CAAEE,IAAI,CAAC;YACrBC,QAAQ;gBACNF,QAAQR,IAAIW,EAAE;YAChB;QACF;IACF;IAEA,IAAIjB,iBAAiBM,MAAM;QACzBM,aAAaC,GAAG,CAAEE,IAAI,CAAC;YACrBG,IAAI;gBACF;oBACEC,WAAW;wBACTC,cAAcd,IAAIa,SAAS;oBAC7B;gBACF;gBACA;oBACEE,QAAQ;wBACNP,QAAQ;oBACV;gBACF;aACD;QACH;IACF;IAEA,IAAIQ;IAEJ,IAAIxB,qBAAqBO,eAAe;QACtCiB,sBAAsBpB,wBAAwBG;IAChD;IAEA,MAAMkB,mBAA8D;QAClEC,YAAYjB,OAAOkB,IAAI;QACvBC,QAAQnB,OAAOkB,IAAI;QACnBE,OAAO;QACPhB,QAAQA;QACRiB,YAAY;QACZnB;QACAC,QAAQP,qBAAqB;YAAEO;QAAO;QACtCmB,MAAM;QACNC,OAAO/B,eAAea,cAAcU;IACtC;IAEA,IAAIS;IACJ,IAAIvB,eAAe,UAAU;QAC3BuB,cAAc,AAAC,CAAA,MAAMtB,IAAIuB,OAAO,CAACC,EAAE,CAACC,kBAAkB,CAAIX,iBAAgB,EAAGY,IAAI;IACnF,OAAO;QACLJ,cAAc,AAAC,CAAA,MAAMtB,IAAIuB,OAAO,CAACC,EAAE,CAACG,YAAY,CAAIb,iBAAgB,EAAGY,IAAI;IAC7E;IAEA,IAAIE,QAAQN,WAAW,CAAC,EAAE;IAE1B,IAAI,CAACM,OAAO;QACV,OAAO/B;IACT;IAEA+B,QAAQpC,uBAAuBoC;IAE/B,oCAAoC;IACpC,IAAI7B,eAAe,YAAY,gBAAgBF,KAAK;QAClD,oFAAoF;QACpF+B,MAAMC,OAAO,CAACC,UAAU,GAAGjC,IAAIiC,UAAU;IAC3C;IAEA,yDAAyD;IACzD,IAAI,CAACF,MAAMC,OAAO,EAAE;QAClBD,MAAMC,OAAO,GAAG,CAAC;IACnB;IAEA,mDAAmD;IACnD,yCAAyC;IACzC,4CAA4C;IAE5CD,MAAMC,OAAO,CAACrB,EAAE,GAAGX,IAAIW,EAAE;IAEzB,OAAOoB,MAAMC,OAAO;AACtB,EAAC"}
1
+ {"version":3,"sources":["../../../src/versions/drafts/replaceWithDraftIfAvailable.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type { SanitizedCollectionConfig, TypeWithID } from '../../collections/config/types.js'\nimport type { AccessResult } from '../../config/types.js'\nimport type { FindGlobalVersionsArgs, FindVersionsArgs } from '../../database/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { PayloadRequest, SelectType, Where } from '../../types/index.js'\n\nimport { hasWhereAccessResult } from '../../auth/index.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { docHasTimestamps } from '../../types/index.js'\nimport { sanitizeInternalFields } from '../../utilities/sanitizeInternalFields.js'\nimport { appendVersionToQueryKey } from './appendVersionToQueryKey.js'\nimport { getQueryDraftsSelect } from './getQueryDraftsSelect.js'\n\ntype Arguments<T> = {\n accessResult: AccessResult\n doc: T\n entity: SanitizedCollectionConfig | SanitizedGlobalConfig\n entityType: 'collection' | 'global'\n overrideAccess: boolean\n req: PayloadRequest\n select?: SelectType\n}\n\nexport const replaceWithDraftIfAvailable = async <T extends TypeWithID>({\n accessResult,\n doc,\n entity,\n entityType,\n req,\n select,\n}: Arguments<T>): Promise<T> => {\n const { locale } = req\n\n const queryToBuild: Where = {\n and: [\n {\n 'version._status': {\n equals: 'draft',\n },\n },\n ],\n }\n\n if (entityType === 'collection') {\n queryToBuild.and!.push({\n parent: {\n equals: doc.id,\n },\n })\n }\n\n if (docHasTimestamps(doc)) {\n queryToBuild.and!.push({\n or: [\n {\n updatedAt: {\n greater_than: doc.updatedAt,\n },\n },\n {\n latest: {\n equals: true,\n },\n },\n ],\n })\n }\n\n let versionAccessResult: undefined | Where\n\n if (hasWhereAccessResult(accessResult)) {\n versionAccessResult = appendVersionToQueryKey(accessResult)\n }\n\n const findVersionsArgs: FindGlobalVersionsArgs & FindVersionsArgs = {\n collection: entity.slug,\n global: entity.slug,\n limit: 1,\n locale: locale!,\n pagination: false,\n req,\n select: getQueryDraftsSelect({ select }),\n sort: '-updatedAt',\n where: combineQueries(queryToBuild, versionAccessResult!),\n }\n\n let versionDocs\n if (entityType === 'global') {\n versionDocs = (await req.payload.db.findGlobalVersions<T>(findVersionsArgs)).docs\n } else {\n versionDocs = (await req.payload.db.findVersions<T>(findVersionsArgs)).docs\n }\n\n let draft = versionDocs[0]\n\n if (!draft) {\n return doc\n }\n\n draft = sanitizeInternalFields(draft)\n\n // Patch globalType onto version doc\n if (entityType === 'global' && 'globalType' in doc) {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n draft.version.globalType = doc.globalType\n }\n\n // handle when .version wasn't selected due to projection\n if (!draft.version) {\n draft.version = {} as T\n }\n\n // Lift locale status from version data if available\n const localeStatus = draft.localeStatus || {}\n if (locale && localeStatus[locale]) {\n ;(draft.version as { _status?: string })['_status'] = localeStatus[locale]\n }\n\n // Disregard all other draft content at this point,\n // Only interested in the version itself.\n // Operations will handle firing hooks, etc.\n\n draft.version.id = doc.id\n\n return draft.version\n}\n"],"names":["hasWhereAccessResult","combineQueries","docHasTimestamps","sanitizeInternalFields","appendVersionToQueryKey","getQueryDraftsSelect","replaceWithDraftIfAvailable","accessResult","doc","entity","entityType","req","select","locale","queryToBuild","and","equals","push","parent","id","or","updatedAt","greater_than","latest","versionAccessResult","findVersionsArgs","collection","slug","global","limit","pagination","sort","where","versionDocs","payload","db","findGlobalVersions","docs","findVersions","draft","version","globalType","localeStatus"],"mappings":"AAAA,oBAAoB;AAOpB,SAASA,oBAAoB,QAAQ,sBAAqB;AAC1D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,gBAAgB,QAAQ,uBAAsB;AACvD,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,oBAAoB,QAAQ,4BAA2B;AAYhE,OAAO,MAAMC,8BAA8B,OAA6B,EACtEC,YAAY,EACZC,GAAG,EACHC,MAAM,EACNC,UAAU,EACVC,GAAG,EACHC,MAAM,EACO;IACb,MAAM,EAAEC,MAAM,EAAE,GAAGF;IAEnB,MAAMG,eAAsB;QAC1BC,KAAK;YACH;gBACE,mBAAmB;oBACjBC,QAAQ;gBACV;YACF;SACD;IACH;IAEA,IAAIN,eAAe,cAAc;QAC/BI,aAAaC,GAAG,CAAEE,IAAI,CAAC;YACrBC,QAAQ;gBACNF,QAAQR,IAAIW,EAAE;YAChB;QACF;IACF;IAEA,IAAIjB,iBAAiBM,MAAM;QACzBM,aAAaC,GAAG,CAAEE,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AEA,mDAAmD;IACnD,yCAAyC;IACzC,4CAA4C;IAE5C0B,MAAMC,OAAO,CAACrB,EAAE,GAAGX,IAAIW,EAAE;IAEzB,OAAOoB,MAAMC,OAAO;AACtB,EAAC"}
@@ -9,6 +9,7 @@ type Args = {
9
9
  draft?: boolean;
10
10
  global?: SanitizedGlobalConfig;
11
11
  id?: number | string;
12
+ locale?: null | string;
12
13
  operation?: 'create' | 'restoreVersion' | 'update';
13
14
  payload: Payload;
14
15
  publishSpecificLocale?: string;
@@ -16,6 +17,6 @@ type Args = {
16
17
  select?: SelectType;
17
18
  snapshot?: any;
18
19
  };
19
- export declare const saveVersion: ({ id, autosave, collection, docWithLocales: doc, draft, global, operation, payload, publishSpecificLocale, req, select, snapshot, }: Args) => Promise<TypeWithID>;
20
+ export declare const saveVersion: ({ id, autosave, collection, docWithLocales: doc, draft, global, locale, operation, payload, publishSpecificLocale, req, select, snapshot, }: Args) => Promise<TypeWithID>;
20
21
  export {};
21
22
  //# sourceMappingURL=saveVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"saveVersion.d.ts","sourceRoot":"","sources":["../../src/versions/saveVersion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAC3F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAA8C,OAAO,EAAE,MAAM,aAAa,CAAA;AACtF,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAOnE,KAAK,IAAI,GAAG;IACV,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,yBAAyB,CAAA;IACtC,cAAc,EAAE,GAAG,CAAA;IACnB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,qBAAqB,CAAA;IAC9B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,C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eAAO,MAAM,WAAW,gJAcrB,IAAI,KAAG,OAAO,CAAC,UAAU,CAqN3B,CAAA"}
@@ -1,9 +1,8 @@
1
- // @ts-strict-ignore
2
1
  import { deepCopyObjectSimple } from '../index.js';
3
2
  import { sanitizeInternalFields } from '../utilities/sanitizeInternalFields.js';
4
3
  import { getQueryDraftsSelect } from './drafts/getQueryDraftsSelect.js';
5
4
  import { enforceMaxVersions } from './enforceMaxVersions.js';
6
- export const saveVersion = async ({ id, autosave, collection, docWithLocales: doc, draft, global, operation, payload, publishSpecificLocale, req, select, snapshot })=>{
5
+ export const saveVersion = async ({ id, autosave, collection, docWithLocales: doc, draft, global, locale, operation, payload, publishSpecificLocale, req, select, snapshot })=>{
7
6
  let result;
8
7
  let createNewVersion = true;
9
8
  const now = new Date().toISOString();
@@ -18,39 +17,39 @@ export const saveVersion = async ({ id, autosave, collection, docWithLocales: do
18
17
  delete versionData._id;
19
18
  }
20
19
  try {
21
- if (autosave) {
22
- let docs;
23
- const findVersionArgs = {
20
+ let docs;
21
+ const findVersionArgs = {
22
+ limit: 1,
23
+ pagination: false,
24
+ req,
25
+ sort: '-updatedAt'
26
+ };
27
+ if (collection) {
28
+ ;
29
+ ({ docs } = await payload.db.findVersions({
30
+ ...findVersionArgs,
31
+ collection: collection.slug,
24
32
  limit: 1,
25
33
  pagination: false,
26
34
  req,
27
- sort: '-updatedAt'
28
- };
29
- if (collection) {
30
- ;
31
- ({ docs } = await payload.db.findVersions({
32
- ...findVersionArgs,
33
- collection: collection.slug,
34
- limit: 1,
35
- pagination: false,
36
- req,
37
- where: {
38
- parent: {
39
- equals: id
40
- }
35
+ where: {
36
+ parent: {
37
+ equals: id
41
38
  }
42
- }));
43
- } else {
44
- ;
45
- ({ docs } = await payload.db.findGlobalVersions({
46
- ...findVersionArgs,
47
- global: global.slug,
48
- limit: 1,
49
- pagination: false,
50
- req
51
- }));
52
- }
53
- const [latestVersion] = docs;
39
+ }
40
+ }));
41
+ } else {
42
+ ;
43
+ ({ docs } = await payload.db.findGlobalVersions({
44
+ ...findVersionArgs,
45
+ global: global.slug,
46
+ limit: 1,
47
+ pagination: false,
48
+ req
49
+ }));
50
+ }
51
+ const [latestVersion] = docs;
52
+ if (autosave) {
54
53
  // overwrite the latest version if it's set to autosave
55
54
  if (latestVersion && 'autosave' in latestVersion && latestVersion.autosave === true) {
56
55
  createNewVersion = false;
@@ -84,11 +83,45 @@ export const saveVersion = async ({ id, autosave, collection, docWithLocales: do
84
83
  }
85
84
  }
86
85
  if (createNewVersion) {
86
+ let localeStatus = {};
87
+ const localizationEnabled = payload.config.localization && payload.config.localization.locales.length > 0;
88
+ if (localizationEnabled && payload.config.localization !== false && payload.config.localization.enableStatusLocalization) {
89
+ const allLocales = (payload.config.localization && payload.config.localization?.locales || []).map((locale)=>typeof locale === 'string' ? locale : locale.code);
90
+ // If `publish all`, set all locales to published
91
+ if (versionData._status === 'published' && !publishSpecificLocale) {
92
+ localeStatus = Object.fromEntries(allLocales.map((code)=>[
93
+ code,
94
+ 'published'
95
+ ]));
96
+ } else if (publishSpecificLocale || locale && versionData._status === 'draft') {
97
+ const status = publishSpecificLocale ? 'published' : 'draft';
98
+ const incomingLocale = String(publishSpecificLocale || locale);
99
+ const existing = latestVersion?.localeStatus;
100
+ // If no locale statuses are set, set it and set all others to draft
101
+ if (!existing) {
102
+ localeStatus = {
103
+ ...Object.fromEntries(allLocales.filter((code)=>code !== incomingLocale).map((code)=>[
104
+ code,
105
+ 'draft'
106
+ ])),
107
+ [incomingLocale]: status
108
+ };
109
+ } else {
110
+ // If locales already exist, update the status for the incoming locale
111
+ const { [incomingLocale]: _, ...rest } = existing;
112
+ localeStatus = {
113
+ ...rest,
114
+ [incomingLocale]: status
115
+ };
116
+ }
117
+ }
118
+ }
87
119
  const createVersionArgs = {
88
120
  autosave: Boolean(autosave),
89
121
  collectionSlug: undefined,
90
122
  createdAt: operation === 'restoreVersion' ? versionData.createdAt : now,
91
123
  globalSlug: undefined,
124
+ localeStatus,
92
125
  parent: collection ? id : undefined,
93
126
  publishedLocale: publishSpecificLocale || undefined,
94
127
  req,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/versions/saveVersion.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type { SanitizedCollectionConfig, TypeWithID } from '../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\nimport type { CreateGlobalVersionArgs, CreateVersionArgs, Payload } from '../index.js'\nimport type { PayloadRequest, SelectType } from '../types/index.js'\n\nimport { deepCopyObjectSimple } from '../index.js'\nimport { sanitizeInternalFields } from '../utilities/sanitizeInternalFields.js'\nimport { getQueryDraftsSelect } from './drafts/getQueryDraftsSelect.js'\nimport { enforceMaxVersions } from './enforceMaxVersions.js'\n\ntype Args = {\n autosave?: boolean\n collection?: SanitizedCollectionConfig\n docWithLocales: any\n draft?: boolean\n global?: SanitizedGlobalConfig\n id?: number | string\n operation?: 'create' | 'restoreVersion' | 'update'\n payload: Payload\n publishSpecificLocale?: string\n req?: PayloadRequest\n select?: SelectType\n snapshot?: any\n}\n\nexport const saveVersion = async ({\n id,\n autosave,\n collection,\n docWithLocales: doc,\n draft,\n global,\n operation,\n payload,\n publishSpecificLocale,\n req,\n select,\n snapshot,\n}: Args): Promise<TypeWithID> => {\n let result: TypeWithID | undefined\n let createNewVersion = true\n const now = new Date().toISOString()\n const versionData = deepCopyObjectSimple(doc)\n if (draft) {\n versionData._status = 'draft'\n }\n\n if (collection?.timestamps && draft) {\n versionData.updatedAt = now\n }\n\n if (versionData._id) {\n delete versionData._id\n }\n\n try {\n if (autosave) {\n let docs\n const findVersionArgs = {\n limit: 1,\n pagination: false,\n req,\n sort: '-updatedAt',\n }\n\n if (collection) {\n ;({ docs } = await payload.db.findVersions({\n ...findVersionArgs,\n collection: collection.slug,\n limit: 1,\n pagination: false,\n req,\n where: {\n parent: {\n equals: id,\n },\n },\n }))\n } else {\n ;({ docs } = await payload.db.findGlobalVersions({\n ...findVersionArgs,\n global: global!.slug,\n limit: 1,\n pagination: false,\n req,\n }))\n }\n const [latestVersion] = docs\n\n // overwrite the latest version if it's set to autosave\n if (latestVersion && 'autosave' in latestVersion && latestVersion.autosave === true) {\n createNewVersion = false\n\n const data: Record<string, unknown> = {\n createdAt: new Date(latestVersion.createdAt).toISOString(),\n latest: true,\n parent: id,\n updatedAt: now,\n version: {\n ...versionData,\n },\n }\n\n const updateVersionArgs = {\n id: latestVersion.id,\n req,\n versionData: data as TypeWithID,\n }\n\n if (collection) {\n result = await payload.db.updateVersion({\n ...updateVersionArgs,\n collection: collection.slug,\n req,\n })\n } else {\n result = await payload.db.updateGlobalVersion({\n ...updateVersionArgs,\n global: global!.slug,\n req,\n })\n }\n }\n }\n\n if (createNewVersion) {\n const createVersionArgs = {\n autosave: Boolean(autosave),\n collectionSlug: undefined as string | undefined,\n createdAt: operation === 'restoreVersion' ? versionData.createdAt : now,\n globalSlug: undefined as string | undefined,\n parent: collection ? id : undefined,\n publishedLocale: publishSpecificLocale || undefined,\n req,\n select: getQueryDraftsSelect({ select }),\n updatedAt: now,\n versionData,\n }\n\n if (collection) {\n createVersionArgs.collectionSlug = collection.slug\n result = await payload.db.createVersion(createVersionArgs as CreateVersionArgs)\n }\n\n if (global) {\n createVersionArgs.globalSlug = global.slug\n result = await payload.db.createGlobalVersion(createVersionArgs as CreateGlobalVersionArgs)\n }\n\n if (publishSpecificLocale && snapshot) {\n const snapshotData = deepCopyObjectSimple(snapshot)\n if (snapshotData._id) {\n delete snapshotData._id\n }\n\n snapshotData._status = 'draft'\n\n const snapshotDate = new Date().toISOString()\n\n const updatedArgs = {\n ...createVersionArgs,\n createdAt: snapshotDate,\n returning: false,\n snapshot: true,\n updatedAt: snapshotDate,\n versionData: snapshotData,\n } as CreateGlobalVersionArgs & CreateVersionArgs\n\n if (collection) {\n await payload.db.createVersion(updatedArgs)\n }\n if (global) {\n await payload.db.createGlobalVersion(updatedArgs)\n }\n }\n }\n } catch (err) {\n let errorMessage: string | undefined\n\n if (collection) {\n errorMessage = `There was an error while saving a version for the ${typeof collection.labels.singular === 'string' ? collection.labels.singular : collection.slug} with ID ${id}.`\n }\n if (global) {\n errorMessage = `There was an error while saving a version for the global ${typeof global.label === 'string' ? global.label : global.slug}.`\n }\n payload.logger.error({ err, msg: errorMessage })\n return undefined!\n }\n\n const max = collection ? collection.versions.maxPerDoc : global!.versions.max\n\n if (createNewVersion && max > 0) {\n await enforceMaxVersions({\n id,\n collection,\n global,\n max,\n payload,\n req,\n })\n }\n\n let createdVersion = (result as any).version\n\n createdVersion = sanitizeInternalFields(createdVersion)\n createdVersion.id = (result as any).parent\n\n return createdVersion\n}\n"],"names":["deepCopyObjectSimple","sanitizeInternalFields","getQueryDraftsSelect","enforceMaxVersions","saveVersion","id","autosave","collection","docWithLocales","doc","draft","global","operation","payload","publishSpecificLocale","req","select","snapshot","result","createNewVersion","now","Date","toISOString","versionData","_status","timestamps","updatedAt","_id","docs","findVersionArgs","limit","pagination","sort","db","findVersions","slug","where","parent","equals","findGlobalVersions","latestVersion","data","createdAt","latest","version","updateVersionArgs","updateVersion","updateGlobalVersion","createVersionArgs","Boolean","collectionSlug","undefined","globalSlug","publishedLocale","createVersion","createGlobalVersion","snapshotData","snapshotDate","updatedArgs","returning","err","errorMessage","labels","singular","label","logger","error","msg","max","versions","maxPerDoc","createdVersion"],"mappings":"AAAA,oBAAoB;AAMpB,SAASA,oBAAoB,QAAQ,cAAa;AAClD,SAASC,sBAAsB,QAAQ,yCAAwC;AAC/E,SAASC,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,kBAAkB,QAAQ,0BAAyB;AAiB5D,OAAO,MAAMC,cAAc,OAAO,EAChCC,EAAE,EACFC,QAAQ,EACRC,UAAU,EACVC,gBAAgBC,GAAG,EACnBC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,OAAO,EACPC,qBAAqB,EACrBC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACH;IACL,IAAIC;IACJ,IAAIC,mBAAmB;IACvB,MAA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QoB,EAAE,CAACqB,aAAa,CAACI;gBACjC;gBACA,IAAI/C,QAAQ;oBACV,MAAME,QAAQoB,EAAE,CAACsB,mBAAmB,CAACG;gBACvC;YACF;QACF;IACF,EAAE,OAAOE,KAAK;QACZ,IAAIC;QAEJ,IAAItD,YAAY;YACdsD,eAAe,CAAC,kDAAkD,EAAE,OAAOtD,WAAWuD,MAAM,CAACC,QAAQ,KAAK,WAAWxD,WAAWuD,MAAM,CAACC,QAAQ,GAAGxD,WAAW4B,IAAI,CAAC,SAAS,EAAE9B,GAAG,CAAC,CAAC;QACpL;QACA,IAAIM,QAAQ;YACVkD,eAAe,CAAC,yDAAyD,EAAE,OAAOlD,OAAOqD,KAAK,KAAK,WAAWrD,OAAOqD,KAAK,GAAGrD,OAAOwB,IAAI,CAAC,CAAC,CAAC;QAC7I;QACAtB,QAAQoD,MAAM,CAACC,KAAK,CAAC;YAAEN;YAAKO,KAAKN;QAAa;QAC9C,OAAOV;IACT;IAEA,MAAMiB,MAAM7D,aAAaA,WAAW8D,QAAQ,CAACC,SAAS,GAAG3D,OAAQ0D,QAAQ,CAACD,GAAG;IAE7E,IAAIjD,oBAAoBiD,MAAM,GAAG;QAC/B,MAAMjE,mBAAmB;YACvBE;YACAE;YACAI;YACAyD;YACAvD;YACAE;QACF;IACF;IAEA,IAAIwD,iBAAiB,AAACrD,OAAe0B,OAAO;IAE5C2B,iBAAiBtE,uBAAuBsE;IACxCA,eAAelE,EAAE,GAAG,AAACa,OAAemB,MAAM;IAE1C,OAAOkC;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/versions/saveVersion.ts"],"sourcesContent":["import { version } from 'os'\n\n// @ts-strict-ignore\nimport type { SanitizedCollectionConfig, TypeWithID } from '../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\nimport type { CreateGlobalVersionArgs, CreateVersionArgs, Payload } from '../index.js'\nimport type { PayloadRequest, SelectType } from '../types/index.js'\n\nimport { deepCopyObjectSimple } from '../index.js'\nimport { sanitizeInternalFields } from '../utilities/sanitizeInternalFields.js'\nimport { getQueryDraftsSelect } from './drafts/getQueryDraftsSelect.js'\nimport { enforceMaxVersions } from './enforceMaxVersions.js'\n\ntype Args = {\n autosave?: boolean\n collection?: SanitizedCollectionConfig\n docWithLocales: any\n draft?: boolean\n global?: SanitizedGlobalConfig\n id?: number | string\n locale?: null | string\n operation?: 'create' | 'restoreVersion' | 'update'\n payload: Payload\n publishSpecificLocale?: string\n req?: PayloadRequest\n select?: SelectType\n snapshot?: any\n}\n\nexport const saveVersion = async ({\n id,\n autosave,\n collection,\n docWithLocales: doc,\n draft,\n global,\n locale,\n operation,\n payload,\n publishSpecificLocale,\n req,\n select,\n snapshot,\n}: Args): Promise<TypeWithID> => {\n let result: TypeWithID | undefined\n let createNewVersion = true\n const now = new Date().toISOString()\n const versionData = deepCopyObjectSimple(doc)\n\n if (draft) {\n versionData._status = 'draft'\n }\n\n if (collection?.timestamps && draft) {\n versionData.updatedAt = now\n }\n\n if (versionData._id) {\n delete versionData._id\n }\n\n try {\n let docs\n const findVersionArgs = {\n limit: 1,\n pagination: false,\n req,\n sort: '-updatedAt',\n }\n\n if (collection) {\n ;({ docs } = await payload.db.findVersions({\n ...findVersionArgs,\n collection: collection.slug,\n limit: 1,\n pagination: false,\n req,\n where: {\n parent: {\n equals: id,\n },\n },\n }))\n } else {\n ;({ docs } = await payload.db.findGlobalVersions({\n ...findVersionArgs,\n global: global!.slug,\n limit: 1,\n pagination: false,\n req,\n }))\n }\n const [latestVersion] = docs\n\n if (autosave) {\n // overwrite the latest version if it's set to autosave\n if (latestVersion && 'autosave' in latestVersion && latestVersion.autosave === true) {\n createNewVersion = false\n\n const data: Record<string, unknown> = {\n createdAt: new Date(latestVersion.createdAt).toISOString(),\n latest: true,\n parent: id,\n updatedAt: now,\n version: {\n ...versionData,\n },\n }\n\n const updateVersionArgs = {\n id: latestVersion.id,\n req,\n versionData: data as TypeWithID,\n }\n\n if (collection) {\n result = await payload.db.updateVersion({\n ...updateVersionArgs,\n collection: collection.slug,\n req,\n })\n } else {\n result = await payload.db.updateGlobalVersion({\n ...updateVersionArgs,\n global: global!.slug,\n req,\n })\n }\n }\n }\n\n if (createNewVersion) {\n let localeStatus = {}\n const localizationEnabled =\n payload.config.localization && payload.config.localization.locales.length > 0\n\n if (\n localizationEnabled &&\n payload.config.localization !== false &&\n payload.config.localization.enableStatusLocalization\n ) {\n const allLocales = (\n (payload.config.localization && payload.config.localization?.locales) ||\n []\n ).map((locale) => (typeof locale === 'string' ? locale : locale.code))\n\n // If `publish all`, set all locales to published\n if (versionData._status === 'published' && !publishSpecificLocale) {\n localeStatus = Object.fromEntries(allLocales.map((code) => [code, 'published']))\n } else if (publishSpecificLocale || (locale && versionData._status === 'draft')) {\n const status: 'draft' | 'published' = publishSpecificLocale ? 'published' : 'draft'\n const incomingLocale = String(publishSpecificLocale || locale)\n const existing = latestVersion?.localeStatus\n\n // If no locale statuses are set, set it and set all others to draft\n if (!existing) {\n localeStatus = {\n ...Object.fromEntries(\n allLocales.filter((code) => code !== incomingLocale).map((code) => [code, 'draft']),\n ),\n [incomingLocale]: status,\n }\n } else {\n // If locales already exist, update the status for the incoming locale\n const { [incomingLocale]: _, ...rest } = existing\n localeStatus = {\n ...rest,\n [incomingLocale]: status,\n }\n }\n }\n }\n\n const createVersionArgs = {\n autosave: Boolean(autosave),\n collectionSlug: undefined as string | undefined,\n createdAt: operation === 'restoreVersion' ? versionData.createdAt : now,\n globalSlug: undefined as string | undefined,\n localeStatus,\n parent: collection ? id : undefined,\n publishedLocale: publishSpecificLocale || undefined,\n req,\n select: getQueryDraftsSelect({ select }),\n updatedAt: now,\n versionData,\n }\n\n if (collection) {\n createVersionArgs.collectionSlug = collection.slug\n result = await payload.db.createVersion(createVersionArgs as CreateVersionArgs)\n }\n\n if (global) {\n createVersionArgs.globalSlug = global.slug\n result = await payload.db.createGlobalVersion(createVersionArgs as CreateGlobalVersionArgs)\n }\n\n if (publishSpecificLocale && snapshot) {\n const snapshotData = deepCopyObjectSimple(snapshot)\n if (snapshotData._id) {\n delete snapshotData._id\n }\n\n snapshotData._status = 'draft'\n\n const snapshotDate = new Date().toISOString()\n\n const updatedArgs = {\n ...createVersionArgs,\n createdAt: snapshotDate,\n returning: false,\n snapshot: true,\n updatedAt: snapshotDate,\n versionData: snapshotData,\n } as CreateGlobalVersionArgs & CreateVersionArgs\n\n if (collection) {\n await payload.db.createVersion(updatedArgs)\n }\n if (global) {\n await payload.db.createGlobalVersion(updatedArgs)\n }\n }\n }\n } catch (err) {\n let errorMessage: string | undefined\n\n if (collection) {\n errorMessage = `There was an error while saving a version for the ${typeof collection.labels.singular === 'string' ? collection.labels.singular : collection.slug} with ID ${id}.`\n }\n if (global) {\n errorMessage = `There was an error while saving a version for the global ${typeof global.label === 'string' ? global.label : global.slug}.`\n }\n payload.logger.error({ err, msg: errorMessage })\n return undefined!\n }\n\n const max = collection ? collection.versions.maxPerDoc : global!.versions.max\n\n if (createNewVersion && max > 0) {\n await enforceMaxVersions({\n id,\n collection,\n global,\n max,\n payload,\n req,\n })\n }\n\n let createdVersion = (result as any).version\n\n createdVersion = sanitizeInternalFields(createdVersion)\n createdVersion.id = (result as any).parent\n\n return createdVersion\n}\n"],"names":["deepCopyObjectSimple","sanitizeInternalFields","getQueryDraftsSelect","enforceMaxVersions","saveVersion","id","autosave","collection","docWithLocales","doc","draft","global","locale","operation","payload","publishSpecificLocale","req","select","snapshot","result","createNewVersion","now","Date","toISOString","versionData","_status","timestamps","updatedAt","_id","docs","findVersionArgs","limit","pagination","sort","db","findVersions","slug","where","parent","equals","findGlobalVersions","latestVersion","data","createdAt","latest","version","updateVersionArgs","updateVersion","updateGlobalVersion","localeStatus","localizationEnabled","config","localization","locales","length","enableStatusLocalization","allLocales","map","code","Object","fromEntries","status","incomingLocale","String","existing","filter","_","rest","createVersionArgs","Boolean","collectionSlug","undefined","globalSlug","publishedLocale","createVersion","createGlobalVersion","snapshotData","snapshotDate","updatedArgs","returning","err","errorMessage","labels","singular","label","logger","error","msg","max","versions","maxPerDoc","createdVersion"],"mappings":"AAQA,SAASA,oBAAoB,QAAQ,cAAa;AAClD,SAASC,sBAAsB,QAAQ,yCAAwC;AAC/E,SAASC,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,kBAAkB,QAAQ,0BAAyB;AAkB5D,OAAO,MAAMC,cAAc,OAAO,EAChCC,EAAE,EACFC,QAAQ,EACRC,UAAU,EACVC,gBAAgBC,GAAG,EACnBC,KAAK,EACLC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,OAAO,EACPC,qBAAqB,EACrBC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACH;IACL,IAAIC;IACJ,IAAIC,mBAAmB;IACvB,MAAMC,MAAM,IAAIC,OAAOC,WAAW;IAClC,MAAMC,cAAcxB,qBAAqBS;IAEzC,IAAIC,OAAO;QACTc,YAAYC,OAAO,GAAG;IACxB;IAEA,IAAIlB,YAAYmB,cAAchB,OAAO;QACnCc,YAAYG,SAAS,GAAGN;IAC1B;IAEA,IAAIG,YAAYI,GAAG,EAAE;QACnB,OAAOJ,YAAYI,GAAG;IACxB;IAEA,IAAI;QACF,IAAIC;QACJ,MAAMC,kBAAkB;YACtBC,OAAO;YACPC,YAAY;YACZhB;YACAiB,MAAM;QACR;QAEA,IAAI1B,YAAY;;YACZ,CAAA,EAAEsB,IAAI,EAAE,GAAG,MAAMf,QAAQoB,EAAE,CAACC,YAAY,CAAC;gBACzC,GAAGL,eAAe;gBAClBvB,YAAYA,WAAW6B,IAAI;gBAC3BL,OAAO;gBACPC,YAAY;gBACZhB;gBACAqB,OAAO;oBACLC,QAAQ;wBACNC,QAAQlC;oBACV;gBACF;YACF,EAAC;QACH,OAAO;;YACH,CAAA,EAAEwB,IAAI,EAAE,GAAG,MAAMf,QAAQoB,EAAE,CAACM,kBAAkB,CAAC;gBAC/C,GAAGV,eAAe;gBAClBnB,QAAQA,OAAQyB,IAAI;gBACpBL,OAAO;gBACPC,Y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;IAEA,IAAI2E,iBAAiB,AAACxE,OAAe0B,OAAO;IAE5C8C,iBAAiB1F,uBAAuB0F;IACxCA,eAAetF,EAAE,GAAG,AAACc,OAAemB,MAAM;IAE1C,OAAOqD;AACT,EAAC"}
@@ -114,6 +114,7 @@ export type SanitizedGlobalVersions = {
114
114
  export type TypeWithVersion<T> = {
115
115
  createdAt: string;
116
116
  id: string;
117
+ localeStatus: Record<string, 'draft' | 'published'>;
117
118
  parent: number | string;
118
119
  publishedLocale?: string;
119
120
  snapshot?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/versions/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACrB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAA;IAC7B;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,GAAG,eAAe,CAAA;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAAA;IAC1B;;OAEG;IACH,eAAe,EAAE,OAAO,GAAG,eAAe,CAAA;IAC1C;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,cAAc,CAAA;IACjC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M,CAAA;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,CAAC,CAAA;CACX,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/versions/types.ts"],"sourcesContent":["export type Autosave = {\n /**\n * Define an `interval` in milliseconds to automatically save progress while documents are edited.\n * Document updates are \"debounced\" at this interval.\n *\n * @default 800\n */\n interval?: number\n /**\n * When set to `true`, the \"Save as draft\" button will be displayed even while autosave is enabled.\n * By default, this button is hidden to avoid redundancy with autosave behavior.\n *\n * @default false\n */\n showSaveDraftButton?: boolean\n}\n\nexport type SchedulePublish = {\n /**\n * Define a date format to use for the time picker.\n *\n * @example 'hh:mm' will give a 24 hour clock\n *\n * @default 'h:mm aa' which is a 12 hour clock\n */\n timeFormat?: string\n /**\n * Intervals for the time picker.\n *\n * @default 5\n */\n timeIntervals?: number\n}\n\nexport type IncomingDrafts = {\n /**\n * Enable autosave to automatically save progress while documents are edited.\n * To enable, set to true or pass an object with options.\n */\n autosave?: Autosave | boolean\n /**\n * Allow for editors to schedule publish / unpublish events in the future.\n */\n schedulePublish?: boolean | SchedulePublish\n /**\n * Set validate to true to validate draft documents when saved.\n *\n * @default false\n */\n validate?: boolean\n}\n\nexport type SanitizedDrafts = {\n /**\n * Enable autosave to automatically save progress while documents are edited.\n * To enable, set to true or pass an object with options.\n */\n autosave: Autosave | false\n /**\n * Allow for editors to schedule publish / unpublish events in the future.\n */\n schedulePublish: boolean | SchedulePublish\n /**\n * Set validate to true to validate draft documents when saved.\n *\n * @default false\n */\n validate: boolean\n}\n\nexport type IncomingCollectionVersions = {\n /**\n * Enable Drafts mode for this collection.\n * To enable, set to true or pass an object with draft options.\n */\n drafts?: boolean | IncomingDrafts\n /**\n * Use this setting to control how many versions to keep on a document by document basis.\n * Must be an integer. Use 0 to save all versions.\n *\n * @default 100\n */\n maxPerDoc?: number\n}\n\nexport interface SanitizedCollectionVersions extends Omit<IncomingCollectionVersions, 'drafts'> {\n /**\n * Enable Drafts mode for this collection.\n * To enable, set to true or pass an object with draft options.\n */\n drafts: false | SanitizedDrafts\n /**\n * Use this setting to control how many versions to keep on a document by document basis.\n * Must be an integer. Use 0 to save all versions.\n *\n * @default 100\n */\n maxPerDoc: number\n}\n\nexport type IncomingGlobalVersions = {\n drafts?: boolean | IncomingDrafts\n /**\n * Use this setting to control how many versions to keep on a global by global basis.\n * Must be an integer.\n */\n max?: number\n}\n\nexport type SanitizedGlobalVersions = {\n /**\n * Enable Drafts mode for this global. To enable, set to true or pass an object with draft options\n */\n drafts: false | SanitizedDrafts\n /**\n * Use this setting to control how many versions to keep on a global by global basis.\n * Must be an integer.\n */\n max: number\n}\n\nexport type TypeWithVersion<T> = {\n createdAt: string\n id: string\n parent: number | string\n publishedLocale?: string\n snapshot?: boolean\n updatedAt: string\n version: T\n}\n"],"names":[],"mappings":"AAyHA,WAQC"}
1
+ {"version":3,"sources":["../../src/versions/types.ts"],"sourcesContent":["export type Autosave = {\n /**\n * Define an `interval` in milliseconds to automatically save progress while documents are edited.\n * Document updates are \"debounced\" at this interval.\n *\n * @default 800\n */\n interval?: number\n /**\n * When set to `true`, the \"Save as draft\" button will be displayed even while autosave is enabled.\n * By default, this button is hidden to avoid redundancy with autosave behavior.\n *\n * @default false\n */\n showSaveDraftButton?: boolean\n}\n\nexport type SchedulePublish = {\n /**\n * Define a date format to use for the time picker.\n *\n * @example 'hh:mm' will give a 24 hour clock\n *\n * @default 'h:mm aa' which is a 12 hour clock\n */\n timeFormat?: string\n /**\n * Intervals for the time picker.\n *\n * @default 5\n */\n timeIntervals?: number\n}\n\nexport type IncomingDrafts = {\n /**\n * Enable autosave to automatically save progress while documents are edited.\n * To enable, set to true or pass an object with options.\n */\n autosave?: Autosave | boolean\n /**\n * Allow for editors to schedule publish / unpublish events in the future.\n */\n schedulePublish?: boolean | SchedulePublish\n /**\n * Set validate to true to validate draft documents when saved.\n *\n * @default false\n */\n validate?: boolean\n}\n\nexport type SanitizedDrafts = {\n /**\n * Enable autosave to automatically save progress while documents are edited.\n * To enable, set to true or pass an object with options.\n */\n autosave: Autosave | false\n /**\n * Allow for editors to schedule publish / unpublish events in the future.\n */\n schedulePublish: boolean | SchedulePublish\n /**\n * Set validate to true to validate draft documents when saved.\n *\n * @default false\n */\n validate: boolean\n}\n\nexport type IncomingCollectionVersions = {\n /**\n * Enable Drafts mode for this collection.\n * To enable, set to true or pass an object with draft options.\n */\n drafts?: boolean | IncomingDrafts\n /**\n * Use this setting to control how many versions to keep on a document by document basis.\n * Must be an integer. Use 0 to save all versions.\n *\n * @default 100\n */\n maxPerDoc?: number\n}\n\nexport interface SanitizedCollectionVersions extends Omit<IncomingCollectionVersions, 'drafts'> {\n /**\n * Enable Drafts mode for this collection.\n * To enable, set to true or pass an object with draft options.\n */\n drafts: false | SanitizedDrafts\n /**\n * Use this setting to control how many versions to keep on a document by document basis.\n * Must be an integer. Use 0 to save all versions.\n *\n * @default 100\n */\n maxPerDoc: number\n}\n\nexport type IncomingGlobalVersions = {\n drafts?: boolean | IncomingDrafts\n /**\n * Use this setting to control how many versions to keep on a global by global basis.\n * Must be an integer.\n */\n max?: number\n}\n\nexport type SanitizedGlobalVersions = {\n /**\n * Enable Drafts mode for this global. To enable, set to true or pass an object with draft options\n */\n drafts: false | SanitizedDrafts\n /**\n * Use this setting to control how many versions to keep on a global by global basis.\n * Must be an integer.\n */\n max: number\n}\n\nexport type TypeWithVersion<T> = {\n createdAt: string\n id: string\n localeStatus: Record<string, 'draft' | 'published'>\n parent: number | string\n publishedLocale?: string\n snapshot?: boolean\n updatedAt: string\n version: T\n}\n"],"names":[],"mappings":"AAyHA,WASC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload",
3
- "version": "3.51.0",
3
+ "version": "3.52.0-internal.8a9caef",
4
4
  "description": "Node, React, Headless CMS and Application Framework built on Next.js",
5
5
  "keywords": [
6
6
  "admin panel",
@@ -101,7 +101,7 @@
101
101
  "undici": "7.10.0",
102
102
  "uuid": "10.0.0",
103
103
  "ws": "^8.16.0",
104
- "@payloadcms/translations": "3.51.0"
104
+ "@payloadcms/translations": "3.52.0-internal.8a9caef"
105
105
  },
106
106
  "devDependencies": {
107
107
  "@hyrious/esbuild-plugin-commonjs": "0.2.6",