payload 4.0.0-internal.293e026 → 4.0.0-internal.2fddfc0

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 (205) hide show
  1. package/dist/admin/fields/Row.d.ts +2 -2
  2. package/dist/admin/fields/Row.d.ts.map +1 -1
  3. package/dist/admin/fields/Row.js.map +1 -1
  4. package/dist/admin/forms/Description.d.ts +2 -2
  5. package/dist/admin/forms/Description.d.ts.map +1 -1
  6. package/dist/admin/forms/Description.js.map +1 -1
  7. package/dist/admin/forms/Field.d.ts +1 -3
  8. package/dist/admin/forms/Field.d.ts.map +1 -1
  9. package/dist/admin/forms/Field.js.map +1 -1
  10. package/dist/admin/types.d.ts +1 -1
  11. package/dist/admin/types.d.ts.map +1 -1
  12. package/dist/admin/types.js.map +1 -1
  13. package/dist/admin/views/document.d.ts +0 -4
  14. package/dist/admin/views/document.d.ts.map +1 -1
  15. package/dist/admin/views/document.js.map +1 -1
  16. package/dist/admin/views/list.d.ts +5 -0
  17. package/dist/admin/views/list.d.ts.map +1 -1
  18. package/dist/admin/views/list.js.map +1 -1
  19. package/dist/auth/baseFields/apiKey.d.ts +10 -2
  20. package/dist/auth/baseFields/apiKey.d.ts.map +1 -1
  21. package/dist/auth/baseFields/apiKey.js +35 -24
  22. package/dist/auth/baseFields/apiKey.js.map +1 -1
  23. package/dist/auth/getAuthFields.js +2 -2
  24. package/dist/auth/getAuthFields.js.map +1 -1
  25. package/dist/bin/generateImportMap/iterateCollections.d.ts.map +1 -1
  26. package/dist/bin/generateImportMap/iterateCollections.js +1 -0
  27. package/dist/bin/generateImportMap/iterateCollections.js.map +1 -1
  28. package/dist/bin/generateImportMap/iterateConfig.d.ts.map +1 -1
  29. package/dist/bin/generateImportMap/iterateConfig.js +12 -0
  30. package/dist/bin/generateImportMap/iterateConfig.js.map +1 -1
  31. package/dist/collections/config/sanitize.d.ts.map +1 -1
  32. package/dist/collections/config/sanitize.js +1 -11
  33. package/dist/collections/config/sanitize.js.map +1 -1
  34. package/dist/collections/config/types.d.ts +1 -0
  35. package/dist/collections/config/types.d.ts.map +1 -1
  36. package/dist/collections/config/types.js.map +1 -1
  37. package/dist/collections/endpoints/create.d.ts.map +1 -1
  38. package/dist/collections/endpoints/create.js +0 -2
  39. package/dist/collections/endpoints/create.js.map +1 -1
  40. package/dist/collections/endpoints/updateByID.d.ts.map +1 -1
  41. package/dist/collections/endpoints/updateByID.js +1 -2
  42. package/dist/collections/endpoints/updateByID.js.map +1 -1
  43. package/dist/collections/operations/count.d.ts.map +1 -1
  44. package/dist/collections/operations/count.js +1 -0
  45. package/dist/collections/operations/count.js.map +1 -1
  46. package/dist/collections/operations/create.d.ts +0 -1
  47. package/dist/collections/operations/create.d.ts.map +1 -1
  48. package/dist/collections/operations/create.js +14 -6
  49. package/dist/collections/operations/create.js.map +1 -1
  50. package/dist/collections/operations/local/update.d.ts +4 -8
  51. package/dist/collections/operations/local/update.d.ts.map +1 -1
  52. package/dist/collections/operations/local/update.js +1 -2
  53. package/dist/collections/operations/local/update.js.map +1 -1
  54. package/dist/collections/operations/update.d.ts +0 -1
  55. package/dist/collections/operations/update.d.ts.map +1 -1
  56. package/dist/collections/operations/update.js +8 -4
  57. package/dist/collections/operations/update.js.map +1 -1
  58. package/dist/collections/operations/updateByID.d.ts +0 -1
  59. package/dist/collections/operations/updateByID.d.ts.map +1 -1
  60. package/dist/collections/operations/updateByID.js +1 -5
  61. package/dist/collections/operations/updateByID.js.map +1 -1
  62. package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.d.ts +9 -0
  63. package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.d.ts.map +1 -0
  64. package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.js +170 -0
  65. package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.js.map +1 -0
  66. package/dist/collections/operations/utilities/update.d.ts +1 -2
  67. package/dist/collections/operations/utilities/update.d.ts.map +1 -1
  68. package/dist/collections/operations/utilities/update.js +48 -57
  69. package/dist/collections/operations/utilities/update.js.map +1 -1
  70. package/dist/config/orderable/index.d.ts.map +1 -1
  71. package/dist/config/orderable/index.js +23 -0
  72. package/dist/config/orderable/index.js.map +1 -1
  73. package/dist/config/types.d.ts +14 -17
  74. package/dist/config/types.d.ts.map +1 -1
  75. package/dist/config/types.js +1 -0
  76. package/dist/config/types.js.map +1 -1
  77. package/dist/errors/ValidationError.d.ts +1 -0
  78. package/dist/errors/ValidationError.d.ts.map +1 -1
  79. package/dist/errors/ValidationError.js.map +1 -1
  80. package/dist/exports/migrations.d.ts +5 -13
  81. package/dist/exports/migrations.d.ts.map +1 -1
  82. package/dist/exports/migrations.js +5 -13
  83. package/dist/exports/migrations.js.map +1 -1
  84. package/dist/exports/shared.d.ts +1 -1
  85. package/dist/exports/shared.d.ts.map +1 -1
  86. package/dist/exports/shared.js +1 -1
  87. package/dist/exports/shared.js.map +1 -1
  88. package/dist/fields/config/client.d.ts.map +1 -1
  89. package/dist/fields/config/client.js +10 -3
  90. package/dist/fields/config/client.js.map +1 -1
  91. package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
  92. package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
  93. package/dist/globals/config/sanitize.d.ts.map +1 -1
  94. package/dist/globals/config/sanitize.js +1 -6
  95. package/dist/globals/config/sanitize.js.map +1 -1
  96. package/dist/globals/endpoints/update.d.ts.map +1 -1
  97. package/dist/globals/endpoints/update.js +0 -2
  98. package/dist/globals/endpoints/update.js.map +1 -1
  99. package/dist/globals/operations/local/update.d.ts +4 -6
  100. package/dist/globals/operations/local/update.d.ts.map +1 -1
  101. package/dist/globals/operations/local/update.js +1 -2
  102. package/dist/globals/operations/local/update.js.map +1 -1
  103. package/dist/globals/operations/update.d.ts +0 -1
  104. package/dist/globals/operations/update.d.ts.map +1 -1
  105. package/dist/globals/operations/update.js +52 -58
  106. package/dist/globals/operations/update.js.map +1 -1
  107. package/dist/index.bundled.d.ts +123 -107
  108. package/dist/index.d.ts +5 -3
  109. package/dist/index.d.ts.map +1 -1
  110. package/dist/index.js +3 -2
  111. package/dist/index.js.map +1 -1
  112. package/dist/query-presets/config.d.ts.map +1 -1
  113. package/dist/query-presets/config.js +73 -34
  114. package/dist/query-presets/config.js.map +1 -1
  115. package/dist/query-presets/constraints.d.ts.map +1 -1
  116. package/dist/query-presets/constraints.js +2 -1
  117. package/dist/query-presets/constraints.js.map +1 -1
  118. package/dist/utilities/deepCopyObject.d.ts.map +1 -1
  119. package/dist/utilities/deepCopyObject.js +8 -0
  120. package/dist/utilities/deepCopyObject.js.map +1 -1
  121. package/dist/utilities/getFieldByPath.d.ts.map +1 -1
  122. package/dist/utilities/getFieldByPath.js.map +1 -1
  123. package/dist/utilities/getVersionsConfig.js.map +1 -1
  124. package/dist/utilities/mergeLocalizedData.d.ts +14 -4
  125. package/dist/utilities/mergeLocalizedData.d.ts.map +1 -1
  126. package/dist/utilities/mergeLocalizedData.js +49 -34
  127. package/dist/utilities/mergeLocalizedData.js.map +1 -1
  128. package/dist/utilities/mergeLocalizedData.spec.js +23 -23
  129. package/dist/utilities/mergeLocalizedData.spec.js.map +1 -1
  130. package/dist/utilities/parseParams/index.d.ts +2 -5
  131. package/dist/utilities/parseParams/index.d.ts.map +1 -1
  132. package/dist/utilities/parseParams/index.js.map +1 -1
  133. package/dist/utilities/parseParams/index.spec.js +0 -9
  134. package/dist/utilities/parseParams/index.spec.js.map +1 -1
  135. package/dist/utilities/traverseFields.d.ts.map +1 -1
  136. package/dist/utilities/traverseFields.js.map +1 -1
  137. package/dist/versions/baseFields.d.ts +1 -2
  138. package/dist/versions/baseFields.d.ts.map +1 -1
  139. package/dist/versions/baseFields.js +0 -13
  140. package/dist/versions/baseFields.js.map +1 -1
  141. package/dist/versions/buildCollectionFields.d.ts.map +1 -1
  142. package/dist/versions/buildCollectionFields.js +0 -2
  143. package/dist/versions/buildCollectionFields.js.map +1 -1
  144. package/dist/versions/buildGlobalFields.d.ts.map +1 -1
  145. package/dist/versions/buildGlobalFields.js +0 -2
  146. package/dist/versions/buildGlobalFields.js.map +1 -1
  147. package/dist/versions/buildSingleLocalePublishData.d.ts +32 -0
  148. package/dist/versions/buildSingleLocalePublishData.d.ts.map +1 -0
  149. package/dist/versions/buildSingleLocalePublishData.js +37 -0
  150. package/dist/versions/buildSingleLocalePublishData.js.map +1 -0
  151. package/dist/versions/saveVersion.d.ts +0 -2
  152. package/dist/versions/saveVersion.d.ts.map +1 -1
  153. package/dist/versions/saveVersion.js +12 -17
  154. package/dist/versions/saveVersion.js.map +1 -1
  155. package/dist/versions/schedule/job.d.ts.map +1 -1
  156. package/dist/versions/schedule/job.js +2 -9
  157. package/dist/versions/schedule/job.js.map +1 -1
  158. package/dist/versions/types.d.ts +2 -15
  159. package/dist/versions/types.d.ts.map +1 -1
  160. package/dist/versions/types.js.map +1 -1
  161. package/package.json +2 -2
  162. package/dist/database/migrations/templates/localizeStatus.d.ts +0 -10
  163. package/dist/database/migrations/templates/localizeStatus.d.ts.map +0 -1
  164. package/dist/database/migrations/templates/localizeStatus.js +0 -54
  165. package/dist/database/migrations/templates/localizeStatus.js.map +0 -1
  166. package/dist/versions/migrations/localizeStatus/index.d.ts +0 -12
  167. package/dist/versions/migrations/localizeStatus/index.d.ts.map +0 -1
  168. package/dist/versions/migrations/localizeStatus/index.js +0 -33
  169. package/dist/versions/migrations/localizeStatus/index.js.map +0 -1
  170. package/dist/versions/migrations/localizeStatus/mongo/down.d.ts +0 -9
  171. package/dist/versions/migrations/localizeStatus/mongo/down.d.ts.map +0 -1
  172. package/dist/versions/migrations/localizeStatus/mongo/down.js +0 -112
  173. package/dist/versions/migrations/localizeStatus/mongo/down.js.map +0 -1
  174. package/dist/versions/migrations/localizeStatus/mongo/index.d.ts +0 -8
  175. package/dist/versions/migrations/localizeStatus/mongo/index.d.ts.map +0 -1
  176. package/dist/versions/migrations/localizeStatus/mongo/index.js +0 -8
  177. package/dist/versions/migrations/localizeStatus/mongo/index.js.map +0 -1
  178. package/dist/versions/migrations/localizeStatus/mongo/up.d.ts +0 -9
  179. package/dist/versions/migrations/localizeStatus/mongo/up.d.ts.map +0 -1
  180. package/dist/versions/migrations/localizeStatus/mongo/up.js +0 -220
  181. package/dist/versions/migrations/localizeStatus/mongo/up.js.map +0 -1
  182. package/dist/versions/migrations/localizeStatus/sql/down.d.ts +0 -11
  183. package/dist/versions/migrations/localizeStatus/sql/down.d.ts.map +0 -1
  184. package/dist/versions/migrations/localizeStatus/sql/down.js +0 -213
  185. package/dist/versions/migrations/localizeStatus/sql/down.js.map +0 -1
  186. package/dist/versions/migrations/localizeStatus/sql/index.d.ts +0 -8
  187. package/dist/versions/migrations/localizeStatus/sql/index.d.ts.map +0 -1
  188. package/dist/versions/migrations/localizeStatus/sql/index.js +0 -8
  189. package/dist/versions/migrations/localizeStatus/sql/index.js.map +0 -1
  190. package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.d.ts +0 -13
  191. package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.d.ts.map +0 -1
  192. package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.js +0 -51
  193. package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.js.map +0 -1
  194. package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.d.ts +0 -13
  195. package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.d.ts.map +0 -1
  196. package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.js +0 -54
  197. package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.js.map +0 -1
  198. package/dist/versions/migrations/localizeStatus/sql/up.d.ts +0 -11
  199. package/dist/versions/migrations/localizeStatus/sql/up.d.ts.map +0 -1
  200. package/dist/versions/migrations/localizeStatus/sql/up.js +0 -277
  201. package/dist/versions/migrations/localizeStatus/sql/up.js.map +0 -1
  202. package/dist/versions/saveSnapshot.d.ts +0 -18
  203. package/dist/versions/saveSnapshot.d.ts.map +0 -1
  204. package/dist/versions/saveSnapshot.js +0 -38
  205. package/dist/versions/saveSnapshot.js.map +0 -1
@@ -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 { hasAutosaveEnabled, hasDraftsEnabled } from '../utilities/getVersionsConfig.js'\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 (hasDraftsEnabled(collection)) {\n if (config.localization) {\n fields.push(versionSnapshotField)\n\n fields.push({\n name: 'publishedLocale',\n type: 'select',\n admin: {\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 (hasAutosaveEnabled(collection)) {\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":["hasAutosaveEnabled","hasDraftsEnabled","versionSnapshotField","buildVersionCollectionFields","config","collection","flatten","fields","name","type","index","relationTo","slug","filter","field","flattenedFields","each","admin","disabled","localization","push","options","locales","map","locale","code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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 { hasAutosaveEnabled, hasDraftsEnabled } from '../utilities/getVersionsConfig.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 (hasDraftsEnabled(collection)) {\n if (config.localization) {\n fields.push({\n name: 'publishedLocale',\n type: 'select',\n admin: {\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 (hasAutosaveEnabled(collection)) {\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":["hasAutosaveEnabled","hasDraftsEnabled","buildVersionCollectionFields","config","collection","flatten","fields","name","type","index","relationTo","slug","filter","field","flattenedFields","each","admin","disabled","localization","push","options","locales","map","locale","code"],"mappings":"AAIA,SAASA,kBAAkB,EAAEC,gBAAgB,QAAQ,oCAAmC;AAExF,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,IAAIR,iBAAiBG,aAAa;QAChC,IAAID,OAAOe,YAAY,EAAE;YACvBZ,OAAOa,IAAI,CAAC;gBACVZ,MAAM;gBACNC,MAAM;gBACNQ,OAAO;oBACLC,UAAU;gBACZ;gBACAR,OAAO;gBACPW,SAASjB,OAAOe,YAAY,CAACG,OAAO,CAACC,GAAG,CAAC,CAACC;oBACxC,IAAI,OAAOA,WAAW,UAAU;wBAC9B,OAAOA;oBACT;oBAEA,OAAOA,OAAOC,IAAI;gBACpB;YACF;QACF;QAEAlB,OAAOa,IAAI,CAAC;YACVZ,MAAM;YACNC,MAAM;YACNQ,OAAO;gBACLC,UAAU;YACZ;YACAR,OAAO;QACT;QAEA,IAAIT,mBAAmBI,aAAa;YAClCE,OAAOa,IAAI,CAAC;gBACVZ,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;AAKvE,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,OAAO,GAAG,KAAK,EAChE,QAAQ,eAAe,EACvB,QAAQ,qBAAqB,EAC7B,UAAU,CAAC,KACV,IAAI,SAAS,CAAC,GAAG,cAAc,EAAE,GAAG,KAAK,EAoE3C,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,GAAG,KAAK,EAChE,QAAQ,eAAe,EACvB,QAAQ,qBAAqB,EAC7B,UAAU,CAAC,KACV,IAAI,SAAS,CAAC,GAAG,cAAc,EAAE,GAAG,KAAK,EAkE3C,CAAA"}
@@ -1,5 +1,4 @@
1
1
  import { hasAutosaveEnabled, hasDraftsEnabled } from '../utilities/getVersionsConfig.js';
2
- import { versionSnapshotField } from './baseFields.js';
3
2
  export const buildVersionGlobalFields = (config, global, flatten)=>{
4
3
  const fields = [
5
4
  {
@@ -29,7 +28,6 @@ export const buildVersionGlobalFields = (config, global, flatten)=>{
29
28
  ];
30
29
  if (hasDraftsEnabled(global)) {
31
30
  if (config.localization) {
32
- fields.push(versionSnapshotField);
33
31
  fields.push({
34
32
  name: 'publishedLocale',
35
33
  type: 'select',
@@ -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 { hasAutosaveEnabled, hasDraftsEnabled } from '../utilities/getVersionsConfig.js'\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 (hasDraftsEnabled(global)) {\n if (config.localization) {\n fields.push(versionSnapshotField)\n\n fields.push({\n name: 'publishedLocale',\n type: 'select',\n admin: {\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 (hasAutosaveEnabled(global)) {\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":["hasAutosaveEnabled","hasDraftsEnabled","versionSnapshotField","buildVersionGlobalFields","config","global","flatten","fields","name","type","flattenedFields","admin","disabled","index","localization","push","options","locales","map","locale","code"],"mappings":"AAIA,SAASA,kBAAkB,EAAEC,gBAAgB,QAAQ,oCAAmC;AACxF,SAASC,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,IAAIZ,iBAAiBI,SAAS;QAC5B,IAAID,OAAOU,YAAY,EAAE;YACvBP,OAAOQ,IAAI,CAACb;YAEZK,OAAOQ,IAAI,CAAC;gBACVP,MAAM;gBACNC,MAAM;gBACNE,OAAO;oBACLC,UAAU;gBACZ;gBACAC,OAAO;gBACPG,SAASZ,OAAOU,YAAY,CAACG,OAAO,CAACC,GAAG,CAAC,CAACC;oBACxC,IAAI,OAAOA,WAAW,UAAU;wBAC9B,OAAOA;oBACT;oBAEA,OAAOA,OAAOC,IAAI;gBACpB;YACF;QACF;QAEAb,OAAOQ,IAAI,CAAC;YACVP,MAAM;YACNC,MAAM;YACNE,OAAO;gBACLC,UAAU;YACZ;YACAC,OAAO;QACT;QAEA,IAAIb,mBAAmBK,SAAS;YAC9BE,OAAOQ,IAAI,CAAC;gBACVP,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 { hasAutosaveEnabled, hasDraftsEnabled } from '../utilities/getVersionsConfig.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 (hasDraftsEnabled(global)) {\n if (config.localization) {\n fields.push({\n name: 'publishedLocale',\n type: 'select',\n admin: {\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 (hasAutosaveEnabled(global)) {\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":["hasAutosaveEnabled","hasDraftsEnabled","buildVersionGlobalFields","config","global","flatten","fields","name","type","flattenedFields","admin","disabled","index","localization","push","options","locales","map","locale","code"],"mappings":"AAIA,SAASA,kBAAkB,EAAEC,gBAAgB,QAAQ,oCAAmC;AAExF,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,IAAIX,iBAAiBG,SAAS;QAC5B,IAAID,OAAOU,YAAY,EAAE;YACvBP,OAAOQ,IAAI,CAAC;gBACVP,MAAM;gBACNC,MAAM;gBACNE,OAAO;oBACLC,UAAU;gBACZ;gBACAC,OAAO;gBACPG,SAASZ,OAAOU,YAAY,CAACG,OAAO,CAACC,GAAG,CAAC,CAACC;oBACxC,IAAI,OAAOA,WAAW,UAAU;wBAC9B,OAAOA;oBACT;oBAEA,OAAOA,OAAOC,IAAI;gBACpB;YACF;QACF;QAEAb,OAAOQ,IAAI,CAAC;YACVP,MAAM;YACNC,MAAM;YACNE,OAAO;gBACLC,UAAU;YACZ;YACAC,OAAO;QACT;QAEA,IAAIZ,mBAAmBI,SAAS;YAC9BE,OAAOQ,IAAI,CAAC;gBACVP,MAAM;gBACNC,MAAM;gBACNI,OAAO;YACT;QACF;IACF;IAEA,OAAON;AACT,EAAC"}
@@ -0,0 +1,32 @@
1
+ import type { Field } from '../fields/config/types.js';
2
+ import type { SanitizedConfig } from '../index.js';
3
+ import type { JsonObject } from '../types/index.js';
4
+ type Args = {
5
+ config: SanitizedConfig;
6
+ /**
7
+ * The current main doc fetched with `locale: 'all'`.
8
+ * For collections, pass the result of `payload.db.findOne`.
9
+ * For globals, pass the result of `payload.db.findGlobal`.
10
+ */
11
+ currentDoc: JsonObject | null;
12
+ fields: Field[];
13
+ /**
14
+ * The locale being published (e.g. 'en').
15
+ */
16
+ locale: string;
17
+ /**
18
+ * The full locale-keyed result from `beforeChange` — used as the version data.
19
+ */
20
+ result: JsonObject;
21
+ };
22
+ /**
23
+ * Builds the data object to write to the main collection/global doc when publishing
24
+ * a single locale. The version row uses `result` as-is (all locales intact); the
25
+ * main doc must only contain previously-published locale data plus the new locale
26
+ * being published now.
27
+ *
28
+ * Returns the merged object (with `_status` set), ready for the DB write.
29
+ */
30
+ export declare function buildLocalizedPublishData({ config, currentDoc, fields, locale, result, }: Args): JsonObject;
31
+ export {};
32
+ //# sourceMappingURL=buildSingleLocalePublishData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildSingleLocalePublishData.d.ts","sourceRoot":"","sources":["../../src/versions/buildSingleLocalePublishData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAInD,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,eAAe,CAAA;IACvB;;;;OAIG;IACH,UAAU,EAAE,UAAU,GAAG,IAAI,CAAA;IAC7B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,EAAE,UAAU,CAAA;CACnB,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,MAAM,EACN,UAAU,EACV,MAAM,EACN,MAAM,EACN,MAAM,GACP,EAAE,IAAI,GAAG,UAAU,CAkCnB"}
@@ -0,0 +1,37 @@
1
+ import { mergeLocalizedData } from '../utilities/mergeLocalizedData.js';
2
+ /**
3
+ * Builds the data object to write to the main collection/global doc when publishing
4
+ * a single locale. The version row uses `result` as-is (all locales intact); the
5
+ * main doc must only contain previously-published locale data plus the new locale
6
+ * being published now.
7
+ *
8
+ * Returns the merged object (with `_status` set), ready for the DB write.
9
+ */ export function buildLocalizedPublishData({ config, currentDoc, fields, locale, result }) {
10
+ const currentDocStatus = currentDoc?._status && typeof currentDoc._status === 'object' ? currentDoc._status : {};
11
+ // Only carry forward locales that were previously published. The main doc can contain
12
+ // stale draft-locale data written by the initial create (which always inserts into the
13
+ // main collection, even when draft:true). Restricting to published locales prevents that
14
+ // data from leaking into the published doc.
15
+ const previouslyPublishedLocales = Object.entries(currentDocStatus).filter(([, status])=>status === 'published').map(([lc])=>lc);
16
+ const merged = mergeLocalizedData({
17
+ configBlockReferences: config.blocks,
18
+ dataWithLocales: result,
19
+ docWithLocales: currentDoc ?? {},
20
+ fields,
21
+ localesToPreserve: previouslyPublishedLocales,
22
+ localesToUpdate: [
23
+ locale
24
+ ]
25
+ });
26
+ // Build the _status map: retain existing per-locale statuses and mark the
27
+ // published locale as 'published'.
28
+ const resultStatus = result._status && typeof result._status === 'object' && !Array.isArray(result._status) ? result._status : {};
29
+ const mergedStatus = {
30
+ ...currentDocStatus
31
+ };
32
+ mergedStatus[locale] = resultStatus[locale] ?? 'published';
33
+ merged._status = mergedStatus;
34
+ return merged;
35
+ }
36
+
37
+ //# sourceMappingURL=buildSingleLocalePublishData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/versions/buildSingleLocalePublishData.ts"],"sourcesContent":["import type { Field } from '../fields/config/types.js'\nimport type { SanitizedConfig } from '../index.js'\nimport type { JsonObject } from '../types/index.js'\n\nimport { mergeLocalizedData } from '../utilities/mergeLocalizedData.js'\n\ntype Args = {\n config: SanitizedConfig\n /**\n * The current main doc fetched with `locale: 'all'`.\n * For collections, pass the result of `payload.db.findOne`.\n * For globals, pass the result of `payload.db.findGlobal`.\n */\n currentDoc: JsonObject | null\n fields: Field[]\n /**\n * The locale being published (e.g. 'en').\n */\n locale: string\n /**\n * The full locale-keyed result from `beforeChange` — used as the version data.\n */\n result: JsonObject\n}\n\n/**\n * Builds the data object to write to the main collection/global doc when publishing\n * a single locale. The version row uses `result` as-is (all locales intact); the\n * main doc must only contain previously-published locale data plus the new locale\n * being published now.\n *\n * Returns the merged object (with `_status` set), ready for the DB write.\n */\nexport function buildLocalizedPublishData({\n config,\n currentDoc,\n fields,\n locale,\n result,\n}: Args): JsonObject {\n const currentDocStatus =\n currentDoc?._status && typeof currentDoc._status === 'object'\n ? (currentDoc._status as Record<string, unknown>)\n : {}\n\n // Only carry forward locales that were previously published. The main doc can contain\n // stale draft-locale data written by the initial create (which always inserts into the\n // main collection, even when draft:true). Restricting to published locales prevents that\n // data from leaking into the published doc.\n const previouslyPublishedLocales = Object.entries(currentDocStatus)\n .filter(([, status]) => status === 'published')\n .map(([lc]) => lc)\n\n const merged = mergeLocalizedData({\n configBlockReferences: config.blocks,\n dataWithLocales: result,\n docWithLocales: currentDoc ?? {},\n fields,\n localesToPreserve: previouslyPublishedLocales,\n localesToUpdate: [locale],\n })\n\n // Build the _status map: retain existing per-locale statuses and mark the\n // published locale as 'published'.\n const resultStatus =\n result._status && typeof result._status === 'object' && !Array.isArray(result._status)\n ? (result._status as Record<string, unknown>)\n : {}\n const mergedStatus: Record<string, unknown> = { ...currentDocStatus }\n mergedStatus[locale] = resultStatus[locale] ?? 'published'\n merged._status = mergedStatus\n\n return merged\n}\n"],"names":["mergeLocalizedData","buildLocalizedPublishData","config","currentDoc","fields","locale","result","currentDocStatus","_status","previouslyPublishedLocales","Object","entries","filter","status","map","lc","merged","configBlockReferences","blocks","dataWithLocales","docWithLocales","localesToPreserve","localesToUpdate","resultStatus","Array","isArray","mergedStatus"],"mappings":"AAIA,SAASA,kBAAkB,QAAQ,qCAAoC;AAqBvE;;;;;;;CAOC,GACD,OAAO,SAASC,0BAA0B,EACxCC,MAAM,EACNC,UAAU,EACVC,MAAM,EACNC,MAAM,EACNC,MAAM,EACD;IACL,MAAMC,mBACJJ,YAAYK,WAAW,OAAOL,WAAWK,OAAO,KAAK,WAChDL,WAAWK,OAAO,GACnB,CAAC;IAEP,sFAAsF;IACtF,uFAAuF;IACvF,yFAAyF;IACzF,4CAA4C;IAC5C,MAAMC,6BAA6BC,OAAOC,OAAO,CAACJ,kBAC/CK,MAAM,CAAC,CAAC,GAAGC,OAAO,GAAKA,WAAW,aAClCC,GAAG,CAAC,CAAC,CAACC,GAAG,GAAKA;IAEjB,MAAMC,SAAShB,mBAAmB;QAChCiB,uBAAuBf,OAAOgB,MAAM;QACpCC,iBAAiBb;QACjBc,gBAAgBjB,cAAc,CAAC;QAC/BC;QACAiB,mBAAmBZ;QACnBa,iBAAiB;YAACjB;SAAO;IAC3B;IAEA,0EAA0E;IAC1E,mCAAmC;IACnC,MAAMkB,eACJjB,OAAOE,OAAO,IAAI,OAAOF,OAAOE,OAAO,KAAK,YAAY,CAACgB,MAAMC,OAAO,CAACnB,OAAOE,OAAO,IAChFF,OAAOE,OAAO,GACf,CAAC;IACP,MAAMkB,eAAwC;QAAE,GAAGnB,gBAAgB;IAAC;IACpEmB,YAAY,CAACrB,OAAO,GAAGkB,YAAY,CAAClB,OAAO,IAAI;IAC/CW,OAAOR,OAAO,GAAGkB;IAEjB,OAAOV;AACT"}
@@ -11,11 +11,9 @@ type Args<T extends JsonObject = JsonObject> = {
11
11
  id?: number | string;
12
12
  operation?: 'create' | 'restoreVersion' | 'update';
13
13
  payload: Payload;
14
- publishSpecificLocale?: string;
15
14
  req?: PayloadRequest;
16
15
  returning?: boolean;
17
16
  select?: SelectType;
18
- snapshot?: any;
19
17
  unpublish?: boolean;
20
18
  };
21
19
  export declare function saveVersion<TData extends JsonObject = JsonObject>(args: {
@@ -1 +1 @@
1
- {"version":3,"file":"saveVersion.d.ts","sourceRoot":"","sources":["../../src/versions/saveVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAA8C,OAAO,EAAE,MAAM,aAAa,CAAA;AACtF,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAU/E,KAAK,IAAI,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,IAAI;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,yBAAyB,CAAA;IACtC,cAAc,EAAE,CAAC,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,qBAAqB,CAAA;IAC9B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,QAAQ,GAAG,gBAAgB,GAAG,QAAQ,CAAA;IAClD,OAAO,EAAE,OAAO,CAAA;IAChB,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EA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,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,QAAQ,GAAG,gBAAgB,GAAG,QAAQ,CAAA;IAClD,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA;AAED,wBAAsB,WAAW,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU,EACrE,IAAI,EAAE;IAAE,SAAS,EAAE,KAAK,CAAA;CAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GACvC,OAAO,CAAC,IAAI,CAAC,CAAA;AAChB,wBAAsB,WAAW,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU,EACrE,IAAI,EAAE;IAAE,SAAS,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GACtC,OAAO,CAAC,UAAU,CAAC,CAAA;AACtB,wBAAsB,WAAW,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU,EACrE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,GACnC,OAAO,CAAC,UAAU,CAAC,CAAA"}
@@ -1,11 +1,10 @@
1
1
  import { deepCopyObjectSimple } from '../index.js';
2
- import { getVersionsMax } from '../utilities/getVersionsConfig.js';
2
+ import { getVersionsMax, hasLocalizeStatusEnabled } from '../utilities/getVersionsConfig.js';
3
3
  import { sanitizeInternalFields } from '../utilities/sanitizeInternalFields.js';
4
4
  import { getQueryDraftsSelect } from './drafts/getQueryDraftsSelect.js';
5
5
  import { enforceMaxVersions } from './enforceMaxVersions.js';
6
- import { saveSnapshot } from './saveSnapshot.js';
7
6
  import { updateLatestVersion } from './updateLatestVersion.js';
8
- export async function saveVersion({ id, autosave, collection, docWithLocales, draft, global, operation, payload, publishSpecificLocale, req, returning, select, snapshot, unpublish }) {
7
+ export async function saveVersion({ id, autosave, collection, docWithLocales, draft, global, operation, payload, req, returning, select, unpublish }) {
9
8
  let result;
10
9
  let createdNewVersion = false;
11
10
  const now = new Date().toISOString();
@@ -16,6 +15,16 @@ export async function saveVersion({ id, autosave, collection, docWithLocales, dr
16
15
  if (versionData._id) {
17
16
  delete versionData._id;
18
17
  }
18
+ // When localizeStatus is enabled, _status must be stored as a localized object.
19
+ // Callers like restoreVersion set it as a plain string — expand it here.
20
+ const entity = collection ?? global;
21
+ if (entity && payload.config.localization && hasLocalizeStatusEnabled(entity) && typeof versionData._status === 'string') {
22
+ const status = versionData._status;
23
+ versionData._status = Object.fromEntries(payload.config.localization.localeCodes.map((code)=>[
24
+ code,
25
+ status
26
+ ]));
27
+ }
19
28
  try {
20
29
  if (unpublish || autosave) {
21
30
  result = await updateLatestVersion({
@@ -37,7 +46,6 @@ export async function saveVersion({ id, autosave, collection, docWithLocales, dr
37
46
  createdAt: operation === 'restoreVersion' ? versionData.createdAt : now,
38
47
  globalSlug: undefined,
39
48
  parent: collection ? id : undefined,
40
- publishedLocale: publishSpecificLocale || undefined,
41
49
  req,
42
50
  returning,
43
51
  select: getQueryDraftsSelect({
@@ -54,19 +62,6 @@ export async function saveVersion({ id, autosave, collection, docWithLocales, dr
54
62
  createVersionArgs.globalSlug = global.slug;
55
63
  result = await payload.db.createGlobalVersion(createVersionArgs);
56
64
  }
57
- if (snapshot) {
58
- await saveSnapshot({
59
- id,
60
- autosave,
61
- collection,
62
- data: snapshot,
63
- global,
64
- payload,
65
- publishSpecificLocale,
66
- req,
67
- select
68
- });
69
- }
70
65
  }
71
66
  } catch (err) {
72
67
  let errorMessage;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/versions/saveVersion.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\nimport type { CreateGlobalVersionArgs, CreateVersionArgs, Payload } from '../index.js'\nimport type { JsonObject, PayloadRequest, SelectType } from '../types/index.js'\n\nimport { deepCopyObjectSimple } from '../index.js'\nimport { getVersionsMax } from '../utilities/getVersionsConfig.js'\nimport { sanitizeInternalFields } from '../utilities/sanitizeInternalFields.js'\nimport { getQueryDraftsSelect } from './drafts/getQueryDraftsSelect.js'\nimport { enforceMaxVersions } from './enforceMaxVersions.js'\nimport { saveSnapshot } from './saveSnapshot.js'\nimport { updateLatestVersion } from './updateLatestVersion.js'\n\ntype Args<T extends JsonObject = JsonObject> = {\n autosave?: boolean\n collection?: SanitizedCollectionConfig\n docWithLocales: T\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 returning?: boolean\n select?: SelectType\n snapshot?: any\n unpublish?: boolean\n}\n\nexport async function saveVersion<TData extends JsonObject = JsonObject>(\n args: { returning: false } & Args<TData>,\n): Promise<null>\nexport async function saveVersion<TData extends JsonObject = JsonObject>(\n args: { returning: true } & Args<TData>,\n): Promise<JsonObject>\nexport async function saveVersion<TData extends JsonObject = JsonObject>(\n args: Omit<Args<TData>, 'returning'>,\n): Promise<JsonObject>\nexport async function saveVersion<TData extends JsonObject = JsonObject>({\n id,\n autosave,\n collection,\n docWithLocales,\n draft,\n global,\n operation,\n payload,\n publishSpecificLocale,\n req,\n returning,\n select,\n snapshot,\n unpublish,\n}: Args<TData>): Promise<JsonObject | null> {\n let result: JsonObject | undefined\n let createdNewVersion = false\n const now = new Date().toISOString()\n const versionData: {\n _status?: 'draft'\n updatedAt?: string\n } & TData = deepCopyObjectSimple(docWithLocales)\n\n if ((collection?.timestamps || global) && draft) {\n versionData.updatedAt = now\n }\n\n if (versionData._id) {\n delete versionData._id\n }\n\n try {\n if (unpublish || autosave) {\n result = await updateLatestVersion({\n id,\n collection,\n global,\n now,\n payload,\n req,\n shouldUpdate: autosave ? (v) => 'autosave' in v && v.autosave === true : undefined,\n versionData,\n })\n }\n\n if (!result) {\n createdNewVersion = true\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 parent: collection ? id : undefined,\n publishedLocale: publishSpecificLocale || undefined,\n req,\n returning,\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 (snapshot) {\n await saveSnapshot<TData>({\n id,\n autosave,\n collection,\n data: snapshot,\n global,\n payload,\n publishSpecificLocale,\n req,\n select,\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 throw err\n }\n\n const max = getVersionsMax(collection || global!)\n\n if (createdNewVersion && max > 0) {\n await enforceMaxVersions({\n id,\n collection,\n global,\n max,\n payload,\n req,\n })\n }\n if (returning === false) {\n return null\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","getVersionsMax","sanitizeInternalFields","getQueryDraftsSelect","enforceMaxVersions","saveSnapshot","updateLatestVersion","saveVersion","id","autosave","collection","docWithLocales","draft","global","operation","payload","publishSpecificLocale","req","returning","select","snapshot","unpublish","result","createdNewVersion","now","Date","toISOString","versionData","timestamps","updatedAt","_id","shouldUpdate","v","undefined","createVersionArgs","Boolean","collectionSlug","createdAt","globalSlug","parent","publishedLocale","slug","db","createVersion","createGlobalVersion","data","err","errorMessage","labels","singular","label","logger","error","msg","max","createdVersion","version"],"mappings":"AAKA,SAASA,oBAAoB,QAAQ,cAAa;AAClD,SAASC,cAAc,QAAQ,oCAAmC;AAClE,SAASC,sBAAsB,QAAQ,yCAAwC;AAC/E,SAASC,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,mBAAmB,QAAQ,2BAA0B;AA4B9D,OAAO,eAAeC,YAAmD,EACvEC,EAAE,EACFC,QAAQ,EACRC,UAAU,EACVC,cAAc,EACdC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,OAAO,EACPC,qBAAqB,EACrBC,GAAG,EACHC,SAAS,EACTC,MAAM,EACNC,QAAQ,EACRC,SAAS,EACG;IACZ,IAAIC;IACJ,IAAIC,oBAAoB;IACxB,MAAMC,MAAM,IAAIC,OAAOC,WAAW;IAClC,MAAMC,cAGM3B,qBAAqBW;IAEjC,IAAI,AAACD,CAAAA,YAAYkB,cAAcf,MAAK,KAAMD,OAAO;QAC/Ce,YAAYE,SAAS,GAAGL;IAC1B;IAEA,IAAIG,YAAYG,GAAG,EAAE;QACnB,OAAOH,YAAYG,GAAG;IACxB;IAEA,IAAI;QACF,IAAIT,aAAaZ,UAAU;YACzBa,SAAS,MAAMhB,oBAAoB;gBACjCE;gBACAE;gBACAG;gBACAW;gBACAT;gBACAE;gBACAc,cAActB,WAAW,CAACuB,IAAM,cAAcA,KAAKA,EAAEvB,QAAQ,KAAK,OAAOwB;gBACzEN;YACF;QACF;QAEA,IAAI,CAACL,QAAQ;YACXC,oBAAoB;YAEpB,MAAMW,oBAAoB;gBACxBzB,UAAU0B,QAAQ1B;gBAClB2B,gBAAgBH;gBAChBI,WAAWvB,cAAc,mBAAmBa,YAAYU,SAAS,GAAGb;gBACpEc,YAAYL;gBACZM,QAAQ7B,aAAaF,KAAKyB;gBAC1BO,iBAAiBxB,yBAAyBi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,eAAe/C,EAAE,GAAG,AAACc,OAAeiB,MAAM;IAE1C,OAAOgB;AACT"}
1
+ {"version":3,"sources":["../../src/versions/saveVersion.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\nimport type { CreateGlobalVersionArgs, CreateVersionArgs, Payload } from '../index.js'\nimport type { JsonObject, PayloadRequest, SelectType } from '../types/index.js'\n\nimport { deepCopyObjectSimple } from '../index.js'\nimport { getVersionsMax, hasLocalizeStatusEnabled } from '../utilities/getVersionsConfig.js'\nimport { sanitizeInternalFields } from '../utilities/sanitizeInternalFields.js'\nimport { getQueryDraftsSelect } from './drafts/getQueryDraftsSelect.js'\nimport { enforceMaxVersions } from './enforceMaxVersions.js'\nimport { updateLatestVersion } from './updateLatestVersion.js'\n\ntype Args<T extends JsonObject = JsonObject> = {\n autosave?: boolean\n collection?: SanitizedCollectionConfig\n docWithLocales: T\n draft?: boolean\n global?: SanitizedGlobalConfig\n id?: number | string\n operation?: 'create' | 'restoreVersion' | 'update'\n payload: Payload\n req?: PayloadRequest\n returning?: boolean\n select?: SelectType\n unpublish?: boolean\n}\n\nexport async function saveVersion<TData extends JsonObject = JsonObject>(\n args: { returning: false } & Args<TData>,\n): Promise<null>\nexport async function saveVersion<TData extends JsonObject = JsonObject>(\n args: { returning: true } & Args<TData>,\n): Promise<JsonObject>\nexport async function saveVersion<TData extends JsonObject = JsonObject>(\n args: Omit<Args<TData>, 'returning'>,\n): Promise<JsonObject>\nexport async function saveVersion<TData extends JsonObject = JsonObject>({\n id,\n autosave,\n collection,\n docWithLocales,\n draft,\n global,\n operation,\n payload,\n req,\n returning,\n select,\n unpublish,\n}: Args<TData>): Promise<JsonObject | null> {\n let result: JsonObject | undefined\n let createdNewVersion = false\n const now = new Date().toISOString()\n const versionData: {\n _status?: 'draft'\n updatedAt?: string\n } & TData = deepCopyObjectSimple(docWithLocales)\n\n if ((collection?.timestamps || global) && draft) {\n versionData.updatedAt = now\n }\n\n if (versionData._id) {\n delete versionData._id\n }\n\n // When localizeStatus is enabled, _status must be stored as a localized object.\n // Callers like restoreVersion set it as a plain string — expand it here.\n const entity = collection ?? global\n if (\n entity &&\n payload.config.localization &&\n hasLocalizeStatusEnabled(entity) &&\n typeof versionData._status === 'string'\n ) {\n const status = versionData._status\n ;(versionData as JsonObject)._status = Object.fromEntries(\n payload.config.localization.localeCodes.map((code) => [code, status]),\n )\n }\n\n try {\n if (unpublish || autosave) {\n result = await updateLatestVersion({\n id,\n collection,\n global,\n now,\n payload,\n req,\n shouldUpdate: autosave ? (v) => 'autosave' in v && v.autosave === true : undefined,\n versionData,\n })\n }\n\n if (!result) {\n createdNewVersion = true\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 parent: collection ? id : undefined,\n req,\n returning,\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 } 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 throw err\n }\n\n const max = getVersionsMax(collection || global!)\n\n if (createdNewVersion && max > 0) {\n await enforceMaxVersions({\n id,\n collection,\n global,\n max,\n payload,\n req,\n })\n }\n if (returning === false) {\n return null\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","getVersionsMax","hasLocalizeStatusEnabled","sanitizeInternalFields","getQueryDraftsSelect","enforceMaxVersions","updateLatestVersion","saveVersion","id","autosave","collection","docWithLocales","draft","global","operation","payload","req","returning","select","unpublish","result","createdNewVersion","now","Date","toISOString","versionData","timestamps","updatedAt","_id","entity","config","localization","_status","status","Object","fromEntries","localeCodes","map","code","shouldUpdate","v","undefined","createVersionArgs","Boolean","collectionSlug","createdAt","globalSlug","parent","slug","db","createVersion","createGlobalVersion","err","errorMessage","labels","singular","label","logger","error","msg","max","createdVersion","version"],"mappings":"AAKA,SAASA,oBAAoB,QAAQ,cAAa;AAClD,SAASC,cAAc,EAAEC,wBAAwB,QAAQ,oCAAmC;AAC5F,SAASC,sBAAsB,QAAQ,yCAAwC;AAC/E,SAASC,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,mBAAmB,QAAQ,2BAA0B;AA0B9D,OAAO,eAAeC,YAAmD,EACvEC,EAAE,EACFC,QAAQ,EACRC,UAAU,EACVC,cAAc,EACdC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,OAAO,EACPC,GAAG,EACHC,SAAS,EACTC,MAAM,EACNC,SAAS,EACG;IACZ,IAAIC;IACJ,IAAIC,oBAAoB;IACxB,MAAMC,MAAM,IAAIC,OAAOC,WAAW;IAClC,MAAMC,cAGMzB,qBAAqBW;IAEjC,IAAI,AAACD,CAAAA,YAAYgB,cAAcb,MAAK,KAAMD,OAAO;QAC/Ca,YAAYE,SAAS,GAAGL;IAC1B;IAEA,IAAIG,YAAYG,GAAG,EAAE;QACnB,OAAOH,YAAYG,GAAG;IACxB;IAEA,gFAAgF;IAChF,yEAAyE;IACzE,MAAMC,SAASnB,cAAcG;IAC7B,IACEgB,UACAd,QAAQe,MAAM,CAACC,YAAY,IAC3B7B,yBAAyB2B,WACzB,OAAOJ,YAAYO,OAAO,KAAK,UAC/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D,EAAE,OAAOxC,OAAO2C,KAAK,KAAK,WAAW3C,OAAO2C,KAAK,GAAG3C,OAAOmC,IAAI,CAAC,CAAC,CAAC;QAC7I;QACAjC,QAAQ0C,MAAM,CAACC,KAAK,CAAC;YAAEN;YAAKO,KAAKN;QAAa;QAC9C,MAAMD;IACR;IAEA,MAAMQ,MAAM3D,eAAeS,cAAcG;IAEzC,IAAIQ,qBAAqBuC,MAAM,GAAG;QAChC,MAAMvD,mBAAmB;YACvBG;YACAE;YACAG;YACA+C;YACA7C;YACAC;QACF;IACF;IACA,IAAIC,cAAc,OAAO;QACvB,OAAO;IACT;IAEA,IAAI4C,iBAAiB,AAACzC,OAAe0C,OAAO;IAE5CD,iBAAiB1D,uBAAuB0D;IACxCA,eAAerD,EAAE,GAAG,AAACY,OAAe2B,MAAM;IAE1C,OAAOc;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../../../src/versions/schedule/job.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAA;AACxE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAE1D,KAAK,IAAI,GAAG;IACV,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,0CAIpC,IAAI,KAAG,UAAU,CAAC;IAAE,KAAK,EAAE,wBAAwB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CA+FvE,CAAA"}
1
+ {"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../../../src/versions/schedule/job.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAA;AACxE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAE1D,KAAK,IAAI,GAAG;IACV,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,0CAIpC,IAAI,KAAG,UAAU,CAAC;IAAE,KAAK,EAAE,wBAAwB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAmFvE,CAAA"}
@@ -13,13 +13,6 @@ export const getSchedulePublishTask = ({ adminUserSlug, collections, globals })=
13
13
  });
14
14
  user.collection = adminUserSlug;
15
15
  }
16
- let publishSpecificLocale;
17
- if (input?.type === 'publish' && input.locale && req.payload.config.localization) {
18
- const matchedLocale = req.payload.config.localization.locales.find(({ code })=>code === input.locale);
19
- if (matchedLocale) {
20
- publishSpecificLocale = input.locale;
21
- }
22
- }
23
16
  if (input.doc) {
24
17
  await req.payload.update({
25
18
  id: input.doc.value,
@@ -28,8 +21,8 @@ export const getSchedulePublishTask = ({ adminUserSlug, collections, globals })=
28
21
  _status
29
22
  },
30
23
  depth: 0,
24
+ locale: input.locale,
31
25
  overrideAccess: user === null,
32
- publishSpecificLocale: publishSpecificLocale,
33
26
  user
34
27
  });
35
28
  }
@@ -40,8 +33,8 @@ export const getSchedulePublishTask = ({ adminUserSlug, collections, globals })=
40
33
  _status
41
34
  },
42
35
  depth: 0,
36
+ locale: input.locale,
43
37
  overrideAccess: user === null,
44
- publishSpecificLocale: publishSpecificLocale,
45
38
  user
46
39
  });
47
40
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/versions/schedule/job.ts"],"sourcesContent":["import type { Field } from '../../fields/config/types.js'\nimport type { TypedUser } from '../../index.js'\nimport type { TaskConfig } from '../../queues/config/types/taskTypes.js'\nimport type { SchedulePublishTaskInput } from './types.js'\n\ntype Args = {\n adminUserSlug: string\n collections: string[]\n globals: string[]\n}\n\nexport const getSchedulePublishTask = ({\n adminUserSlug,\n collections,\n globals,\n}: Args): TaskConfig<{ input: SchedulePublishTaskInput; output: object }> => {\n return {\n slug: 'schedulePublish',\n handler: async ({ input, req }) => {\n const _status = input?.type === 'publish' || !input?.type ? 'published' : 'draft'\n\n const userID = input.user\n\n let user: null | TypedUser = null\n\n if (userID) {\n user = (await req.payload.findByID({\n id: userID,\n collection: adminUserSlug,\n depth: 0,\n })) as TypedUser\n\n user.collection = adminUserSlug\n }\n\n let publishSpecificLocale: string\n\n if (input?.type === 'publish' && input.locale && req.payload.config.localization) {\n const matchedLocale = req.payload.config.localization.locales.find(\n ({ code }) => code === input.locale,\n )\n\n if (matchedLocale) {\n publishSpecificLocale = input.locale\n }\n }\n\n if (input.doc) {\n await req.payload.update({\n id: input.doc.value,\n collection: input.doc.relationTo,\n data: {\n _status,\n },\n depth: 0,\n overrideAccess: user === null,\n publishSpecificLocale: publishSpecificLocale!,\n user,\n })\n }\n\n if (input.global) {\n await req.payload.updateGlobal({\n slug: input.global,\n data: {\n _status,\n },\n depth: 0,\n overrideAccess: user === null,\n publishSpecificLocale: publishSpecificLocale!,\n user,\n })\n }\n\n return {\n output: {},\n }\n },\n inputSchema: [\n {\n name: 'type',\n type: 'radio',\n defaultValue: 'publish',\n options: ['publish', 'unpublish'],\n },\n {\n name: 'locale',\n type: 'text',\n },\n ...(collections.length > 0\n ? [\n {\n name: 'doc',\n type: 'relationship',\n relationTo: collections,\n } satisfies Field,\n ]\n : []),\n {\n name: 'global',\n type: 'select',\n options: globals,\n },\n {\n name: 'user',\n type: 'relationship',\n relationTo: adminUserSlug,\n },\n ],\n }\n}\n"],"names":["getSchedulePublishTask","adminUserSlug","collections","globals","slug","handler","input","req","_status","type","userID","user","payload","findByID","id","collection","depth","publishSpecificLocale","locale","config","localization","matchedLocale","locales","find","code","doc","update","value","relationTo","data","overrideAccess","global","updateGlobal","output","inputSchema","name","defaultValue","options","length"],"mappings":"AAWA,OAAO,MAAMA,yBAAyB,CAAC,EACrCC,aAAa,EACbC,WAAW,EACXC,OAAO,EACF;IACL,OAAO;QACLC,MA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,MAAM;gBACN2B,cAAc;gBACdC,SAAS;oBAAC;oBAAW;iBAAY;YACnC;YACA;gBACEF,MAAM;gBACN1B,MAAM;YACR;eACIP,YAAYoC,MAAM,GAAG,IACrB;gBACE;oBACEH,MAAM;oBACN1B,MAAM;oBACNmB,YAAY1B;gBACd;aACD,GACD,EAAE;YACN;gBACEiC,MAAM;gBACN1B,MAAM;gBACN4B,SAASlC;YACX;YACA;gBACEgC,MAAM;gBACN1B,MAAM;gBACNmB,YAAY3B;YACd;SACD;IACH;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/versions/schedule/job.ts"],"sourcesContent":["import type { Field } from '../../fields/config/types.js'\nimport type { TypedUser } from '../../index.js'\nimport type { TaskConfig } from '../../queues/config/types/taskTypes.js'\nimport type { SchedulePublishTaskInput } from './types.js'\n\ntype Args = {\n adminUserSlug: string\n collections: string[]\n globals: string[]\n}\n\nexport const getSchedulePublishTask = ({\n adminUserSlug,\n collections,\n globals,\n}: Args): TaskConfig<{ input: SchedulePublishTaskInput; output: object }> => {\n return {\n slug: 'schedulePublish',\n handler: async ({ input, req }) => {\n const _status = input?.type === 'publish' || !input?.type ? 'published' : 'draft'\n\n const userID = input.user\n\n let user: null | TypedUser = null\n\n if (userID) {\n user = (await req.payload.findByID({\n id: userID,\n collection: adminUserSlug,\n depth: 0,\n })) as TypedUser\n\n user.collection = adminUserSlug\n }\n\n if (input.doc) {\n await req.payload.update({\n id: input.doc.value,\n collection: input.doc.relationTo,\n data: {\n _status,\n },\n depth: 0,\n locale: input.locale,\n overrideAccess: user === null,\n user,\n })\n }\n\n if (input.global) {\n await req.payload.updateGlobal({\n slug: input.global,\n data: {\n _status,\n },\n depth: 0,\n locale: input.locale,\n overrideAccess: user === null,\n user,\n })\n }\n\n return {\n output: {},\n }\n },\n inputSchema: [\n {\n name: 'type',\n type: 'radio',\n defaultValue: 'publish',\n options: ['publish', 'unpublish'],\n },\n {\n name: 'locale',\n type: 'text',\n },\n ...(collections.length > 0\n ? [\n {\n name: 'doc',\n type: 'relationship',\n relationTo: collections,\n } satisfies Field,\n ]\n : []),\n {\n name: 'global',\n type: 'select',\n options: globals,\n },\n {\n name: 'user',\n type: 'relationship',\n relationTo: adminUserSlug,\n },\n ],\n }\n}\n"],"names":["getSchedulePublishTask","adminUserSlug","collections","globals","slug","handler","input","req","_status","type","userID","user","payload","findByID","id","collection","depth","doc","update","value","relationTo","data","locale","overrideAccess","global","updateGlobal","output","inputSchema","name","defaultValue","options","length"],"mappings":"AAWA,OAAO,MAAMA,yBAAyB,CAAC,EACrCC,aAAa,EACbC,WAAW,EACXC,OAAO,EACF;IACL,OAAO;QACLC,MAAM;QACNC,SAAS,OAAO,EAAEC,KAAK,EAAEC,GAAG,EAAE;YAC5B,MAAMC,UAAUF,OAAOG,SAAS,aAAa,CAACH,OAAOG,OAAO,cAAc;YAE1E,MAAMC,SAASJ,MAAMK,IAAI;YAEzB,IAAIA,OAAyB;YAE7B,IAAID,QAAQ;gBACVC,OAAQ,MAAMJ,IAAIK,OAAO,CAACC,QAAQ,CAAC;oBACjCC,IAAIJ;oBACJK,YAAYd;oBACZe,OAAO;gBACT;gBAEAL,KAAKI,UAAU,GAAGd;YACpB;YAEA,IAAIK,MAAMW,GAAG,EAAE;gBACb,MAAMV,IAAIK,OAAO,CAACM,MAAM,CAAC;oBACvBJ,IAAIR,MAAMW,GAAG,CAACE,KAAK;oBACnBJ,YAAYT,MAAMW,GAAG,CAACG,UAAU;oBAChCC,MAAM;wBACJb;oBACF;oBACAQ,OAAO;oBACPM,QAAQhB,MAAMgB,MAAM;oBACpBC,gBAAgBZ,SAAS;oBACzBA;gBACF;YACF;YAEA,IAAIL,MAAMkB,MAAM,EAAE;gBAChB,MAAMjB,IAAIK,OAAO,CAACa,YAAY,CAAC;oBAC7BrB,MAAME,MAAMkB,MAAM;oBAClBH,MAAM;wBACJb;oBACF;oBACAQ,OAAO;oBACPM,QAAQhB,MAAMgB,MAAM;oBACpBC,gBAAgBZ,SAAS;oBACzBA;gBACF;YACF;YAEA,OAAO;gBACLe,QAAQ,CAAC;YACX;QACF;QACAC,aAAa;YACX;gBACEC,MAAM;gBACNnB,MAAM;gBACNoB,cAAc;gBACdC,SAAS;oBAAC;oBAAW;iBAAY;YACnC;YACA;gBACEF,MAAM;gBACNnB,MAAM;YACR;eACIP,YAAY6B,MAAM,GAAG,IACrB;gBACE;oBACEH,MAAM;oBACNnB,MAAM;oBACNW,YAAYlB;gBACd;aACD,GACD,EAAE;YACN;gBACE0B,MAAM;gBACNnB,MAAM;gBACNqB,SAAS3B;YACX;YACA;gBACEyB,MAAM;gBACNnB,MAAM;gBACNW,YAAYnB;YACd;SACD;IACH;AACF,EAAC"}
@@ -36,15 +36,6 @@ export type IncomingDrafts = {
36
36
  * To enable, set to true or pass an object with options.
37
37
  */
38
38
  autosave?: Autosave | boolean;
39
- /**
40
- * Localizes the status field.
41
- *
42
- * Only effective if the experimental `experimental.localizeStatus` is enabled.
43
- *
44
- * @experimental
45
- * @default false
46
- */
47
- localizeStatus?: boolean;
48
39
  /**
49
40
  * Allow for editors to schedule publish / unpublish events in the future.
50
41
  */
@@ -63,12 +54,8 @@ export type SanitizedDrafts = {
63
54
  */
64
55
  autosave: Autosave | false;
65
56
  /**
66
- * Localizes the status field.
67
- *
68
- * Only effective if the experimental `experimental.localizeStatus` is enabled.
69
- *
70
- * @experimental
71
- * @default false
57
+ * Automatically set to true when localization is configured and the collection/global
58
+ * has localized fields. Controls whether `_status` is stored per-locale.
72
59
  */
73
60
  localizeStatus?: boolean;
74
61
  /**
@@ -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;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OAGG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,cAAc,CAAA;IACjC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,WAAW,2BAA4B,SAAQ,IAAI,CAAC,0BAA0B,EAAE,QAAQ,CAAC;IAC7F;;;OAGG;IACH,MAAM,EAAE,KAAK,GAAG,eAAe,CAAA;IAC/B;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,CAAC,EAAE,OAAO,GAAG,cAAc,CAAA;IACjC;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,MAAM,EAAE,KAAK,GAAG,eAAe,CAAA;IAC/B;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,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 * Localizes the status field.\n *\n * Only effective if the experimental `experimental.localizeStatus` is enabled.\n *\n * @experimental\n * @default false\n */\n localizeStatus?: 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 * Localizes the status field.\n *\n * Only effective if the experimental `experimental.localizeStatus` is enabled.\n *\n * @experimental\n * @default false\n */\n localizeStatus?: 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 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 latest?: boolean\n parent: number | string\n publishedLocale?: string\n snapshot?: boolean\n updatedAt: string\n version: T\n}\n"],"names":[],"mappings":"AA2IA,WASC"}
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 * Automatically set to true when localization is configured and the collection/global\n * has localized fields. Controls whether `_status` is stored per-locale.\n */\n localizeStatus?: 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 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 latest?: boolean\n parent: number | string\n publishedLocale?: string\n snapshot?: boolean\n updatedAt: string\n version: T\n}\n"],"names":[],"mappings":"AA8HA,WASC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload",
3
- "version": "4.0.0-internal.293e026",
3
+ "version": "4.0.0-internal.2fddfc0",
4
4
  "description": "Node, React, Headless CMS and Application Framework built on Next.js",
5
5
  "keywords": [
6
6
  "admin panel",
@@ -118,7 +118,7 @@
118
118
  "undici": "7.25.0",
119
119
  "uuid": "14.0.0",
120
120
  "ws": "^8.16.0",
121
- "@payloadcms/translations": "4.0.0-internal.293e026"
121
+ "@payloadcms/translations": "4.0.0-internal.2fddfc0"
122
122
  },
123
123
  "devDependencies": {
124
124
  "@hyrious/esbuild-plugin-commonjs": "0.2.6",
@@ -1,10 +0,0 @@
1
- /**
2
- * Template for localizeStatus migration
3
- * Transforms version._status from single value to per-locale object
4
- */
5
- export declare const localizeStatusTemplate: (options: {
6
- collectionSlug?: string;
7
- dbType: "mongodb" | "postgres" | "sqlite";
8
- globalSlug?: string;
9
- }) => string;
10
- //# sourceMappingURL=localizeStatus.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"localizeStatus.d.ts","sourceRoot":"","sources":["../../../../src/database/migrations/templates/localizeStatus.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,sBAAsB,GAAI,SAAS;IAC9C,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAA;IACzC,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,KAAG,MAoDH,CAAA"}
@@ -1,54 +0,0 @@
1
- /**
2
- * Template for localizeStatus migration
3
- * Transforms version._status from single value to per-locale object
4
- */ export const localizeStatusTemplate = (options)=>{
5
- const { collectionSlug, dbType, globalSlug } = options;
6
- const entity = collectionSlug ? `collectionSlug: '${collectionSlug}'` : `globalSlug: '${globalSlug}'`;
7
- if (dbType === 'mongodb') {
8
- return `import { MigrateUpArgs, MigrateDownArgs } from '@payloadcms/db-mongodb'
9
- import { localizeStatus } from 'payload'
10
-
11
- export async function up({ payload, req }: MigrateUpArgs): Promise<void> {
12
- await localizeStatus.up({
13
- ${entity},
14
- payload,
15
- req,
16
- })
17
- }
18
-
19
- export async function down({ payload, req }: MigrateDownArgs): Promise<void> {
20
- await localizeStatus.down({
21
- ${entity},
22
- payload,
23
- req,
24
- })
25
- }
26
- `;
27
- }
28
- // SQL databases (Postgres, SQLite)
29
- return `import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-${dbType}'
30
- import { localizeStatus } from 'payload'
31
-
32
- export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
33
- await localizeStatus.up({
34
- ${entity},
35
- db,
36
- payload,
37
- req,
38
- sql,
39
- })
40
- }
41
-
42
- export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
43
- await localizeStatus.down({
44
- ${entity},
45
- db,
46
- payload,
47
- req,
48
- sql,
49
- })
50
- }
51
- `;
52
- };
53
-
54
- //# sourceMappingURL=localizeStatus.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/database/migrations/templates/localizeStatus.ts"],"sourcesContent":["/**\n * Template for localizeStatus migration\n * Transforms version._status from single value to per-locale object\n */\n\nexport const localizeStatusTemplate = (options: {\n collectionSlug?: string\n dbType: 'mongodb' | 'postgres' | 'sqlite'\n globalSlug?: string\n}): string => {\n const { collectionSlug, dbType, globalSlug } = options\n const entity = collectionSlug\n ? `collectionSlug: '${collectionSlug}'`\n : `globalSlug: '${globalSlug}'`\n\n if (dbType === 'mongodb') {\n return `import { MigrateUpArgs, MigrateDownArgs } from '@payloadcms/db-mongodb'\nimport { localizeStatus } from 'payload'\n\nexport async function up({ payload, req }: MigrateUpArgs): Promise<void> {\n await localizeStatus.up({\n ${entity},\n payload,\n req,\n })\n}\n\nexport async function down({ payload, req }: MigrateDownArgs): Promise<void> {\n await localizeStatus.down({\n ${entity},\n payload,\n req,\n })\n}\n`\n }\n\n // SQL databases (Postgres, SQLite)\n return `import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-${dbType}'\nimport { localizeStatus } from 'payload'\n\nexport async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {\n await localizeStatus.up({\n ${entity},\n db,\n payload,\n req,\n sql,\n })\n}\n\nexport async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {\n await localizeStatus.down({\n ${entity},\n db,\n payload,\n req,\n sql,\n })\n}\n`\n}\n"],"names":["localizeStatusTemplate","options","collectionSlug","dbType","globalSlug","entity"],"mappings":"AAAA;;;CAGC,GAED,OAAO,MAAMA,yBAAyB,CAACC;IAKrC,MAAM,EAAEC,cAAc,EAAEC,MAAM,EAAEC,UAAU,EAAE,GAAGH;IAC/C,MAAMI,SAASH,iBACX,CAAC,iBAAiB,EAAEA,eAAe,CAAC,CAAC,GACrC,CAAC,aAAa,EAAEE,WAAW,CAAC,CAAC;IAEjC,IAAID,WAAW,WAAW;QACxB,OAAO,CAAC;;;;;IAKR,EAAEE,OAAO;;;;;;;;IAQT,EAAEA,OAAO;;;;;AAKb,CAAC;IACC;IAEA,mCAAmC;IACnC,OAAO,CAAC,oEAAoE,EAAEF,OAAO;;;;;IAKnF,EAAEE,OAAO;;;;;;;;;;IAUT,EAAEA,OAAO;;;;;;;AAOb,CAAC;AACD,EAAC"}
@@ -1,12 +0,0 @@
1
- type LocalizeStatusMigration = {
2
- down: (args: any) => Promise<void>;
3
- up: (args: any) => Promise<void>;
4
- };
5
- /**
6
- * Main entry point for localizeStatus migration.
7
- * Detects database type and dispatches to appropriate implementation.
8
- */
9
- export declare const localizeStatus: LocalizeStatusMigration;
10
- export type { LocalizeStatusArgs as MongoLocalizeStatusArgs } from './mongo/index.js';
11
- export type { LocalizeStatusArgs as SqlLocalizeStatusArgs } from './sql/index.js';
12
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/versions/migrations/localizeStatus/index.ts"],"names":[],"mappings":"AAMA,KAAK,uBAAuB,GAAG;IAC7B,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAClC,EAAE,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACjC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,uBAgC5B,CAAA;AAED,YAAY,EAAE,kBAAkB,IAAI,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAErF,YAAY,EAAE,kBAAkB,IAAI,qBAAqB,EAAE,MAAM,gBAAgB,CAAA"}
@@ -1,33 +0,0 @@
1
- import { localizeStatus as mongoLocalizeStatus } from './mongo/index.js';
2
- import { localizeStatus as sqlLocalizeStatus } from './sql/index.js';
3
- /**
4
- * Main entry point for localizeStatus migration.
5
- * Detects database type and dispatches to appropriate implementation.
6
- */ export const localizeStatus = {
7
- async up (args) {
8
- // Detect database type by checking which parameters are present
9
- if ('db' in args && 'sql' in args) {
10
- // SQL database (Postgres, SQLite, etc.)
11
- return sqlLocalizeStatus.up(args);
12
- } else if ('payload' in args && !('db' in args)) {
13
- // MongoDB
14
- return mongoLocalizeStatus.up(args);
15
- } else {
16
- throw new Error('Unable to detect database type. Expected either { db, sql } for SQL databases ' + 'or { payload } for MongoDB.');
17
- }
18
- },
19
- async down (args) {
20
- // Detect database type by checking which parameters are present
21
- if ('db' in args && 'sql' in args) {
22
- // SQL database (Postgres, SQLite, etc.)
23
- return sqlLocalizeStatus.down(args);
24
- } else if ('payload' in args && !('db' in args)) {
25
- // MongoDB
26
- return mongoLocalizeStatus.down(args);
27
- } else {
28
- throw new Error('Unable to detect database type. Expected either { db, sql } for SQL databases ' + 'or { payload } for MongoDB.');
29
- }
30
- }
31
- };
32
-
33
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/versions/migrations/localizeStatus/index.ts"],"sourcesContent":["import type { LocalizeStatusArgs as MongoArgs } from './mongo/index.js'\nimport type { LocalizeStatusArgs as SqlArgs } from './sql/index.js'\n\nimport { localizeStatus as mongoLocalizeStatus } from './mongo/index.js'\nimport { localizeStatus as sqlLocalizeStatus } from './sql/index.js'\n\ntype LocalizeStatusMigration = {\n down: (args: any) => Promise<void>\n up: (args: any) => Promise<void>\n}\n\n/**\n * Main entry point for localizeStatus migration.\n * Detects database type and dispatches to appropriate implementation.\n */\nexport const localizeStatus: LocalizeStatusMigration = {\n async up(args: MongoArgs | SqlArgs): Promise<void> {\n // Detect database type by checking which parameters are present\n if ('db' in args && 'sql' in args) {\n // SQL database (Postgres, SQLite, etc.)\n return sqlLocalizeStatus.up(args)\n } else if ('payload' in args && !('db' in args)) {\n // MongoDB\n return mongoLocalizeStatus.up(args)\n } else {\n throw new Error(\n 'Unable to detect database type. Expected either { db, sql } for SQL databases ' +\n 'or { payload } for MongoDB.',\n )\n }\n },\n\n async down(args: MongoArgs | SqlArgs): Promise<void> {\n // Detect database type by checking which parameters are present\n if ('db' in args && 'sql' in args) {\n // SQL database (Postgres, SQLite, etc.)\n return sqlLocalizeStatus.down(args)\n } else if ('payload' in args && !('db' in args)) {\n // MongoDB\n return mongoLocalizeStatus.down(args)\n } else {\n throw new Error(\n 'Unable to detect database type. Expected either { db, sql } for SQL databases ' +\n 'or { payload } for MongoDB.',\n )\n }\n },\n}\n\nexport type { LocalizeStatusArgs as MongoLocalizeStatusArgs } from './mongo/index.js'\n// Re-export types for convenience\nexport type { LocalizeStatusArgs as SqlLocalizeStatusArgs } from './sql/index.js'\n"],"names":["localizeStatus","mongoLocalizeStatus","sqlLocalizeStatus","up","args","Error","down"],"mappings":"AAGA,SAASA,kBAAkBC,mBAAmB,QAAQ,mBAAkB;AACxE,SAASD,kBAAkBE,iBAAiB,QAAQ,iBAAgB;AAOpE;;;CAGC,GACD,OAAO,MAAMF,iBAA0C;IACrD,MAAMG,IAAGC,IAAyB;QAChC,gEAAgE;QAChE,IAAI,QAAQA,QAAQ,SAASA,MAAM;YACjC,wCAAwC;YACxC,OAAOF,kBAAkBC,EAAE,CAACC;QAC9B,OAAO,IAAI,aAAaA,QAAQ,CAAE,CAAA,QAAQA,IAAG,GAAI;YAC/C,UAAU;YACV,OAAOH,oBAAoBE,EAAE,CAACC;QAChC,OAAO;YACL,MAAM,IAAIC,MACR,mFACE;QAEN;IACF;IAEA,MAAMC,MAAKF,IAAyB;QAClC,gEAAgE;QAChE,IAAI,QAAQA,QAAQ,SAASA,MAAM;YACjC,wCAAwC;YACxC,OAAOF,kBAAkBI,IAAI,CAACF;QAChC,OAAO,IAAI,aAAaA,QAAQ,CAAE,CAAA,QAAQA,IAAG,GAAI;YAC/C,UAAU;YACV,OAAOH,oBAAoBK,IAAI,CAACF;QAClC,OAAO;YACL,MAAM,IAAIC,MACR,mFACE;QAEN;IACF;AACF,EAAC"}
@@ -1,9 +0,0 @@
1
- import type { Payload } from '../../../../types/index.js';
2
- export type LocalizeStatusArgs = {
3
- collectionSlug?: string;
4
- globalSlug?: string;
5
- payload: Payload;
6
- req?: any;
7
- };
8
- export declare function down(args: LocalizeStatusArgs): Promise<void>;
9
- //# sourceMappingURL=down.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"down.d.ts","sourceRoot":"","sources":["../../../../../src/versions/migrations/localizeStatus/mongo/down.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAIzD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,GAAG,CAAA;CACV,CAAA;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsIlE"}