@payloadcms/db-mongodb 4.0.0-internal.38b7f1d → 4.0.0-internal.40de3ec

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 (70) hide show
  1. package/dist/connect.d.ts.map +1 -1
  2. package/dist/connect.js +1 -2
  3. package/dist/connect.js.map +1 -1
  4. package/dist/createMigration.d.ts.map +1 -1
  5. package/dist/createMigration.js +5 -44
  6. package/dist/createMigration.js.map +1 -1
  7. package/dist/deleteOne.js.map +1 -1
  8. package/dist/index.d.ts +1 -7
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +0 -6
  11. package/dist/index.js.map +1 -1
  12. package/dist/models/buildCollectionSchema.d.ts.map +1 -1
  13. package/dist/models/buildGlobalModel.d.ts.map +1 -1
  14. package/dist/models/buildSchema.d.ts.map +1 -1
  15. package/dist/models/buildSchema.js +1 -1
  16. package/dist/models/buildSchema.js.map +1 -1
  17. package/dist/queries/buildQuery.d.ts.map +1 -1
  18. package/dist/queries/buildSortParam.d.ts.map +1 -1
  19. package/dist/queries/getBuildQueryPlugin.d.ts.map +1 -1
  20. package/dist/queries/getLocalizedSortProperty.d.ts.map +1 -1
  21. package/dist/queries/getLocalizedSortProperty.js +1 -1
  22. package/dist/queries/getLocalizedSortProperty.js.map +1 -1
  23. package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
  24. package/dist/queries/sanitizeQueryValue.js +2 -3
  25. package/dist/queries/sanitizeQueryValue.js.map +1 -1
  26. package/dist/updateGlobal.d.ts.map +1 -1
  27. package/dist/updateGlobal.js +10 -7
  28. package/dist/updateGlobal.js.map +1 -1
  29. package/dist/updateGlobalVersion.d.ts.map +1 -1
  30. package/dist/updateGlobalVersion.js +10 -7
  31. package/dist/updateGlobalVersion.js.map +1 -1
  32. package/dist/updateJobs.d.ts.map +1 -1
  33. package/dist/updateJobs.js +11 -8
  34. package/dist/updateJobs.js.map +1 -1
  35. package/dist/updateMany.d.ts.map +1 -1
  36. package/dist/updateMany.js +11 -8
  37. package/dist/updateMany.js.map +1 -1
  38. package/dist/updateOne.d.ts.map +1 -1
  39. package/dist/updateOne.js +10 -7
  40. package/dist/updateOne.js.map +1 -1
  41. package/dist/updateVersion.d.ts.map +1 -1
  42. package/dist/updateVersion.js +10 -7
  43. package/dist/updateVersion.js.map +1 -1
  44. package/dist/utilities/aggregatePaginate.d.ts.map +1 -1
  45. package/dist/utilities/buildJoinAggregation.d.ts.map +1 -1
  46. package/dist/utilities/buildProjectionFromSelect.d.ts.map +1 -1
  47. package/dist/utilities/buildProjectionFromSelect.js +1 -1
  48. package/dist/utilities/buildProjectionFromSelect.js.map +1 -1
  49. package/dist/utilities/getDBName.d.ts.map +1 -1
  50. package/dist/utilities/getEntity.d.ts.map +1 -1
  51. package/dist/utilities/handleError.d.ts.map +1 -1
  52. package/dist/utilities/isObjectID.d.ts.map +1 -1
  53. package/dist/utilities/transform.d.ts.map +1 -1
  54. package/dist/utilities/transform.js +10 -34
  55. package/dist/utilities/transform.js.map +1 -1
  56. package/dist/utilities/transform.spec.js +3 -3
  57. package/dist/utilities/transform.spec.js.map +1 -1
  58. package/package.json +5 -5
  59. package/dist/migrateFieldDelocalized.d.ts +0 -10
  60. package/dist/migrateFieldDelocalized.d.ts.map +0 -1
  61. package/dist/migrateFieldDelocalized.js +0 -40
  62. package/dist/migrateFieldDelocalized.js.map +0 -1
  63. package/dist/migrateFieldLocalized.d.ts +0 -10
  64. package/dist/migrateFieldLocalized.d.ts.map +0 -1
  65. package/dist/migrateFieldLocalized.js +0 -43
  66. package/dist/migrateFieldLocalized.js.map +0 -1
  67. package/dist/migrateVersionsEnabled.d.ts +0 -9
  68. package/dist/migrateVersionsEnabled.d.ts.map +0 -1
  69. package/dist/migrateVersionsEnabled.js +0 -52
  70. package/dist/migrateVersionsEnabled.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/db-mongodb",
3
- "version": "4.0.0-internal.38b7f1d",
3
+ "version": "4.0.0-internal.40de3ec",
4
4
  "description": "The officially supported MongoDB database adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -43,7 +43,7 @@
43
43
  "predefinedMigrations"
44
44
  ],
45
45
  "dependencies": {
46
- "mongoose": "8.15.1",
46
+ "mongoose": "8.22.1",
47
47
  "mongoose-paginate-v2": "1.9.4",
48
48
  "prompts": "2.4.2",
49
49
  "uuid": "14.0.0"
@@ -51,13 +51,13 @@
51
51
  "devDependencies": {
52
52
  "@types/mongoose-aggregate-paginate-v2": "1.0.12",
53
53
  "@types/prompts": "^2.4.5",
54
- "mongodb": "6.16.0",
54
+ "mongodb": "6.20.0",
55
55
  "mongodb-memory-server": "10.1.4",
56
56
  "@payloadcms/eslint-config": "3.28.0",
57
- "payload": "4.0.0-internal.38b7f1d"
57
+ "payload": "4.0.0-internal.40de3ec"
58
58
  },
59
59
  "peerDependencies": {
60
- "payload": "4.0.0-internal.38b7f1d"
60
+ "payload": "4.0.0-internal.40de3ec"
61
61
  },
62
62
  "scripts": {
63
63
  "build": "pnpm build:types && pnpm build:swc",
@@ -1,10 +0,0 @@
1
- import type { PayloadRequest } from 'payload';
2
- import type { MongooseAdapter } from './index.js';
3
- export declare function migrateFieldDelocalized(this: MongooseAdapter, args: {
4
- defaultLocale: string;
5
- entity: 'collection' | 'global';
6
- fieldPath: string;
7
- req: PayloadRequest;
8
- slug: string;
9
- }): Promise<void>;
10
- //# sourceMappingURL=migrateFieldDelocalized.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrateFieldDelocalized.d.ts","sourceRoot":"","sources":["../src/migrateFieldDelocalized.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAUjD,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE;IACJ,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,YAAY,GAAG,QAAQ,CAAA;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,GACA,OAAO,CAAC,IAAI,CAAC,CA6Cf"}
@@ -1,40 +0,0 @@
1
- import { getCollection } from './utilities/getEntity.js';
2
- function getValueAtPath(doc, path) {
3
- return path.split('.').reduce((obj, key)=>obj?.[key], doc);
4
- }
5
- const BATCH_SIZE = 1000;
6
- export async function migrateFieldDelocalized(args) {
7
- const { slug, defaultLocale, entity, fieldPath } = args;
8
- const { payload } = this;
9
- payload.logger.warn(`[config-migration] Delocalizing field "${fieldPath}" on ${entity} "${slug}" — keeping only "${defaultLocale}" value`);
10
- if (entity === 'collection') {
11
- const { Model } = getCollection({
12
- adapter: this,
13
- collectionSlug: slug
14
- });
15
- const nativeCollection = Model.collection;
16
- let page = 1;
17
- let hasMore = true;
18
- while(hasMore){
19
- const docs = await nativeCollection.find({}).skip((page - 1) * BATCH_SIZE).limit(BATCH_SIZE).toArray();
20
- for (const doc of docs){
21
- const currentValue = getValueAtPath(doc, fieldPath);
22
- if (currentValue !== null && currentValue !== undefined && typeof currentValue === 'object' && !Array.isArray(currentValue)) {
23
- const defaultValue = currentValue[defaultLocale] ?? null;
24
- const update = {};
25
- update[fieldPath] = defaultValue;
26
- await nativeCollection.updateOne({
27
- _id: doc._id
28
- }, {
29
- $set: update
30
- });
31
- }
32
- }
33
- hasMore = docs.length === BATCH_SIZE;
34
- page++;
35
- }
36
- }
37
- payload.logger.info(`[config-migration] Done delocalizing field "${fieldPath}" on ${entity} "${slug}"`);
38
- }
39
-
40
- //# sourceMappingURL=migrateFieldDelocalized.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/migrateFieldDelocalized.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { getCollection } from './utilities/getEntity.js'\n\nfunction getValueAtPath(doc: Record<string, unknown>, path: string): unknown {\n return path.split('.').reduce((obj: any, key) => obj?.[key], doc)\n}\n\nconst BATCH_SIZE = 1000\n\nexport async function migrateFieldDelocalized(\n this: MongooseAdapter,\n args: {\n defaultLocale: string\n entity: 'collection' | 'global'\n fieldPath: string\n req: PayloadRequest\n slug: string\n },\n): Promise<void> {\n const { slug, defaultLocale, entity, fieldPath } = args\n const { payload } = this\n\n payload.logger.warn(\n `[config-migration] Delocalizing field \"${fieldPath}\" on ${entity} \"${slug}\" — keeping only \"${defaultLocale}\" value`,\n )\n\n if (entity === 'collection') {\n const { Model } = getCollection({ adapter: this, collectionSlug: slug })\n const nativeCollection = Model.collection\n\n let page = 1\n let hasMore = true\n\n while (hasMore) {\n const docs = await nativeCollection\n .find({})\n .skip((page - 1) * BATCH_SIZE)\n .limit(BATCH_SIZE)\n .toArray()\n\n for (const doc of docs) {\n const currentValue = getValueAtPath(doc as any, fieldPath)\n if (\n currentValue !== null &&\n currentValue !== undefined &&\n typeof currentValue === 'object' &&\n !Array.isArray(currentValue)\n ) {\n const defaultValue = (currentValue as Record<string, unknown>)[defaultLocale] ?? null\n const update: Record<string, unknown> = {}\n update[fieldPath] = defaultValue\n await nativeCollection.updateOne({ _id: doc._id }, { $set: update })\n }\n }\n\n hasMore = docs.length === BATCH_SIZE\n page++\n }\n }\n\n payload.logger.info(\n `[config-migration] Done delocalizing field \"${fieldPath}\" on ${entity} \"${slug}\"`,\n )\n}\n"],"names":["getCollection","getValueAtPath","doc","path","split","reduce","obj","key","BATCH_SIZE","migrateFieldDelocalized","args","slug","defaultLocale","entity","fieldPath","payload","logger","warn","Model","adapter","collectionSlug","nativeCollection","collection","page","hasMore","docs","find","skip","limit","toArray","currentValue","undefined","Array","isArray","defaultValue","update","updateOne","_id","$set","length","info"],"mappings":"AAIA,SAASA,aAAa,QAAQ,2BAA0B;AAExD,SAASC,eAAeC,GAA4B,EAAEC,IAAY;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QAAQC,MAAM,CAACwB,IAAI,CACjB,CAAC,4CAA4C,EAAE1B,UAAU,KAAK,EAAED,OAAO,EAAE,EAAEF,KAAK,CAAC,CAAC;AAEtF"}
@@ -1,10 +0,0 @@
1
- import type { PayloadRequest } from 'payload';
2
- import type { MongooseAdapter } from './index.js';
3
- export declare function migrateFieldLocalized(this: MongooseAdapter, args: {
4
- defaultLocale: string;
5
- entity: 'collection' | 'global';
6
- fieldPath: string;
7
- req: PayloadRequest;
8
- slug: string;
9
- }): Promise<void>;
10
- //# sourceMappingURL=migrateFieldLocalized.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrateFieldLocalized.d.ts","sourceRoot":"","sources":["../src/migrateFieldLocalized.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAUjD,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE;IACJ,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,YAAY,GAAG,QAAQ,CAAA;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,GACA,OAAO,CAAC,IAAI,CAAC,CA8Cf"}
@@ -1,43 +0,0 @@
1
- import { getCollection } from './utilities/getEntity.js';
2
- function getValueAtPath(doc, path) {
3
- return path.split('.').reduce((obj, key)=>obj?.[key], doc);
4
- }
5
- const BATCH_SIZE = 1000;
6
- export async function migrateFieldLocalized(args) {
7
- const { slug, defaultLocale, entity, fieldPath } = args;
8
- const { payload } = this;
9
- payload.logger.info(`[config-migration] Localizing field "${fieldPath}" on ${entity} "${slug}" → locale "${defaultLocale}"`);
10
- if (entity === 'collection') {
11
- const { Model } = getCollection({
12
- adapter: this,
13
- collectionSlug: slug
14
- });
15
- const nativeCollection = Model.collection;
16
- let page = 1;
17
- let hasMore = true;
18
- while(hasMore){
19
- const docs = await nativeCollection.find({}).skip((page - 1) * BATCH_SIZE).limit(BATCH_SIZE).toArray();
20
- for (const doc of docs){
21
- const currentValue = getValueAtPath(doc, fieldPath);
22
- // Skip if already in localized shape
23
- if (currentValue !== null && currentValue !== undefined && typeof currentValue === 'object' && !Array.isArray(currentValue)) {
24
- continue;
25
- }
26
- const update = {};
27
- update[fieldPath] = {
28
- [defaultLocale]: currentValue
29
- };
30
- await nativeCollection.updateOne({
31
- _id: doc._id
32
- }, {
33
- $set: update
34
- });
35
- }
36
- hasMore = docs.length === BATCH_SIZE;
37
- page++;
38
- }
39
- }
40
- payload.logger.info(`[config-migration] Done localizing field "${fieldPath}" on ${entity} "${slug}"`);
41
- }
42
-
43
- //# sourceMappingURL=migrateFieldLocalized.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/migrateFieldLocalized.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { getCollection } from './utilities/getEntity.js'\n\nfunction getValueAtPath(doc: Record<string, unknown>, path: string): unknown {\n return path.split('.').reduce((obj: any, key) => obj?.[key], doc)\n}\n\nconst BATCH_SIZE = 1000\n\nexport async function migrateFieldLocalized(\n this: MongooseAdapter,\n args: {\n defaultLocale: string\n entity: 'collection' | 'global'\n fieldPath: string\n req: PayloadRequest\n slug: string\n },\n): Promise<void> {\n const { slug, defaultLocale, entity, fieldPath } = args\n const { payload } = this\n\n payload.logger.info(\n `[config-migration] Localizing field \"${fieldPath}\" on ${entity} \"${slug}\" → locale \"${defaultLocale}\"`,\n )\n\n if (entity === 'collection') {\n const { Model } = getCollection({ adapter: this, collectionSlug: slug })\n const nativeCollection = Model.collection\n\n let page = 1\n let hasMore = true\n\n while (hasMore) {\n const docs = await nativeCollection\n .find({})\n .skip((page - 1) * BATCH_SIZE)\n .limit(BATCH_SIZE)\n .toArray()\n\n for (const doc of docs) {\n const currentValue = getValueAtPath(doc as any, fieldPath)\n // Skip if already in localized shape\n if (\n currentValue !== null &&\n currentValue !== undefined &&\n typeof currentValue === 'object' &&\n !Array.isArray(currentValue)\n ) {\n continue\n }\n const update: Record<string, unknown> = {}\n update[fieldPath] = { [defaultLocale]: currentValue }\n await nativeCollection.updateOne({ _id: doc._id }, { $set: update })\n }\n\n hasMore = docs.length === BATCH_SIZE\n page++\n }\n }\n\n payload.logger.info(\n `[config-migration] Done localizing field \"${fieldPath}\" on ${entity} \"${slug}\"`,\n )\n}\n"],"names":["getCollection","getValueAtPath","doc","path","split","reduce","obj","key","BATCH_SIZE","migrateFieldLocalized","args","slug","defaultLocale","entity","fieldPath","payload","logger","info","Model","adapter","collectionSlug","nativeCollection","collection","page","hasMore","docs","find","skip","limit","toArray","currentValue","undefined","Array","isArray","update","updateOne","_id","$set","length"],"mappings":"AAIA,SAASA,aAAa,QAAQ,2BAA0B;AAExD,SAASC,eAAeC,GAA4B,EAAEC,IAAY;IAChE,OAAOA,KAAKC,KAAK,CAAC,KAAKC,MAAM,CAAC,CAACC,KAAUC,MAAQD,KAAK,CAACC,IAAI,EAAEL;AAC/D;AAEA,MAAMM,aAAa;AAEnB,OAAO,eAAeC,sBAEpBC,IAMC;IAED,MAAM,EAAEC,IAAI,EAAEC,aAAa,EAAEC,MAAM,EAAEC,SAAS,EAAE,GAAGJ;IACnD,MAAM,EAAEK,OAAO,EAAE,GAAG,IAAI;IAExBA,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,qCAAqC,EAAEH,UAAU,KAAK,EAAED,OAAO,EAAE,EAAEF,KAAK,YAAY,EAAEC,cAAc,CAAC,CAAC;IAGzG,IAAIC,WAAW,cAAc;QAC3B,MAAM,EAAEK,KAAK,EAAE,GAAGlB,cAAc;YAAEmB,SAAS,IAAI;YAAEC,gBAAgBT;QAAK;QACtE,MAAMU,mBAAmBH,MAAMI,UAAU;QAEzC,IAAIC,OAAO;QACX,IAAIC,UAAU;QAEd,MAAOA,QAAS;YACd,MAAMC,OAAO,MAAMJ,iBAChBK,IAAI,CAAC,CAAC,GACNC,IAAI,CAAC,AAACJ,CAAAA,OAAO,CAAA,IAAKf,YAClBoB,KAAK,CAACpB,YACNqB,OAAO;YAEV,KAAK,MAAM3B,OAAOuB,KAAM;gBACtB,MAAMK,eAAe7B,eAAeC,KAAYY;gBAChD,qCAAqC;gBACrC,IACEgB,iBAAiB,QACjBA,iBAAiBC,aACjB,OAAOD,iBAAiB,YACxB,CAACE,MAAMC,OAAO,CAACH,eACf;oBACA;gBACF;gBACA,MAAMI,SAAkC,CAAC;gBACzCA,MAAM,CAACpB,UAAU,GAAG;oBAAE,CAACF,cAAc,EAAEkB;gBAAa;gBACpD,MAAMT,iBAAiBc,SAAS,CAAC;oBAAEC,KAAKlC,IAAIkC,GAAG;gBAAC,GAAG;oBAAEC,MAAMH;gBAAO;YACpE;YAEAV,UAAUC,KAAKa,MAAM,KAAK9B;YAC1Be;QACF;IACF;IAEAR,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,0CAA0C,EAAEH,UAAU,KAAK,EAAED,OAAO,EAAE,EAAEF,KAAK,CAAC,CAAC;AAEpF"}
@@ -1,9 +0,0 @@
1
- import type { PayloadRequest } from 'payload';
2
- import type { MongooseAdapter } from './index.js';
3
- export declare function migrateVersionsEnabled(this: MongooseAdapter, args: {
4
- entity: 'collection' | 'global';
5
- initialStatus: 'draft' | 'published';
6
- req: PayloadRequest;
7
- slug: string;
8
- }): Promise<void>;
9
- //# sourceMappingURL=migrateVersionsEnabled.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrateVersionsEnabled.d.ts","sourceRoot":"","sources":["../src/migrateVersionsEnabled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE;IACJ,MAAM,EAAE,YAAY,GAAG,QAAQ,CAAA;IAC/B,aAAa,EAAE,OAAO,GAAG,WAAW,CAAA;IACpC,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,GACA,OAAO,CAAC,IAAI,CAAC,CAsCf"}
@@ -1,52 +0,0 @@
1
- import { batchTransform } from 'payload/migrations';
2
- const BATCH_SIZE = 1000;
3
- export async function migrateVersionsEnabled(args) {
4
- const { slug, entity, initialStatus, req } = args;
5
- const { payload } = this;
6
- payload.logger.info(`[config-migration] MongoDB: creating version entries for ${entity} "${slug}" with _status: ${initialStatus}`);
7
- if (entity === 'collection') {
8
- await batchTransform({
9
- batchSize: BATCH_SIZE,
10
- fetcher: ({ limit, page })=>payload.db.find({
11
- collection: slug,
12
- limit,
13
- page,
14
- pagination: true,
15
- req
16
- }),
17
- transform: async (doc)=>{
18
- await payload.db.createVersion({
19
- autosave: false,
20
- collectionSlug: slug,
21
- createdAt: doc.createdAt ?? new Date().toISOString(),
22
- parent: doc.id,
23
- req,
24
- updatedAt: doc.updatedAt ?? new Date().toISOString(),
25
- versionData: {
26
- ...doc,
27
- _status: initialStatus
28
- }
29
- });
30
- }
31
- });
32
- } else {
33
- const globalDoc = await payload.db.findGlobal({
34
- slug,
35
- req
36
- });
37
- await payload.db.createGlobalVersion({
38
- autosave: false,
39
- createdAt: globalDoc.createdAt ?? new Date().toISOString(),
40
- globalSlug: slug,
41
- req,
42
- updatedAt: globalDoc.updatedAt ?? new Date().toISOString(),
43
- versionData: {
44
- ...globalDoc,
45
- _status: initialStatus
46
- }
47
- });
48
- }
49
- payload.logger.info(`[config-migration] MongoDB: done creating version entries for "${slug}"`);
50
- }
51
-
52
- //# sourceMappingURL=migrateVersionsEnabled.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/migrateVersionsEnabled.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport { batchTransform } from 'payload/migrations'\n\nimport type { MongooseAdapter } from './index.js'\n\nconst BATCH_SIZE = 1000\n\nexport async function migrateVersionsEnabled(\n this: MongooseAdapter,\n args: {\n entity: 'collection' | 'global'\n initialStatus: 'draft' | 'published'\n req: PayloadRequest\n slug: string\n },\n): Promise<void> {\n const { slug, entity, initialStatus, req } = args\n const { payload } = this\n\n payload.logger.info(\n `[config-migration] MongoDB: creating version entries for ${entity} \"${slug}\" with _status: ${initialStatus}`,\n )\n\n if (entity === 'collection') {\n await batchTransform({\n batchSize: BATCH_SIZE,\n fetcher: ({ limit, page }: { limit: number; page: number }) =>\n payload.db.find({ collection: slug, limit, page, pagination: true, req }),\n transform: async (doc: any) => {\n await payload.db.createVersion({\n autosave: false,\n collectionSlug: slug as any,\n createdAt: doc.createdAt ?? new Date().toISOString(),\n parent: doc.id,\n req,\n updatedAt: doc.updatedAt ?? new Date().toISOString(),\n versionData: { ...doc, _status: initialStatus },\n })\n },\n })\n } else {\n const globalDoc = await payload.db.findGlobal({ slug, req })\n await payload.db.createGlobalVersion({\n autosave: false,\n createdAt: globalDoc.createdAt ?? new Date().toISOString(),\n globalSlug: slug as any,\n req,\n updatedAt: globalDoc.updatedAt ?? new Date().toISOString(),\n versionData: { ...globalDoc, _status: initialStatus },\n })\n }\n\n payload.logger.info(`[config-migration] MongoDB: done creating version entries for \"${slug}\"`)\n}\n"],"names":["batchTransform","BATCH_SIZE","migrateVersionsEnabled","args","slug","entity","initialStatus","req","payload","logger","info","batchSize","fetcher","limit","page","db","find","collection","pagination","transform","doc","createVersion","autosave","collectionSlug","createdAt","Date","toISOString","parent","id","updatedAt","versionData","_status","globalDoc","findGlobal","createGlobalVersion","globalSlug"],"mappings":"AAEA,SAASA,cAAc,QAAQ,qBAAoB;AAInD,MAAMC,aAAa;AAEnB,OAAO,eAAeC,uBAEpBC,IAKC;IAED,MAAM,EAAEC,IAAI,EAAEC,MAAM,EAAEC,aAAa,EAAEC,GAAG,EAAE,GAAGJ;IAC7C,MAAM,EAAEK,OAAO,EAAE,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