@payloadcms/db-mongodb 4.0.0-internal.078835b → 4.0.0-internal.0b9bec1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/migration-utils.d.ts +1 -0
- package/dist/exports/migration-utils.d.ts.map +1 -1
- package/dist/exports/migration-utils.js +1 -0
- package/dist/exports/migration-utils.js.map +1 -1
- package/dist/predefinedMigrations/jobs-processing-lease-v4.d.ts +5 -0
- package/dist/predefinedMigrations/jobs-processing-lease-v4.d.ts.map +1 -0
- package/dist/predefinedMigrations/jobs-processing-lease-v4.js +12 -0
- package/dist/predefinedMigrations/jobs-processing-lease-v4.js.map +1 -0
- package/dist/predefinedMigrations/migrateJobsProcessingLease.d.ts +6 -0
- package/dist/predefinedMigrations/migrateJobsProcessingLease.d.ts.map +1 -0
- package/dist/predefinedMigrations/migrateJobsProcessingLease.js +82 -0
- package/dist/predefinedMigrations/migrateJobsProcessingLease.js.map +1 -0
- package/dist/predefinedMigrations/migrateJobsProcessingLease.spec.js +131 -0
- package/dist/predefinedMigrations/migrateJobsProcessingLease.spec.js.map +1 -0
- package/dist/updateJobs.d.ts.map +1 -1
- package/dist/updateJobs.js +70 -13
- package/dist/updateJobs.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { migrateJobsProcessingLease } from '../predefinedMigrations/migrateJobsProcessingLease.js';
|
|
1
2
|
export { localizeStatus, migrateLocalizeStatus, } from '../predefinedMigrations/migrateLocalizeStatus.js';
|
|
2
3
|
export { migrateRelationshipsV2_V3 } from '../predefinedMigrations/migrateRelationshipsV2_V3.js';
|
|
3
4
|
export { migrateVersionsV1_V2 } from '../predefinedMigrations/migrateVersionsV1_V2.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-utils.d.ts","sourceRoot":"","sources":["../../src/exports/migration-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,qBAAqB,GACtB,MAAM,kDAAkD,CAAA;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sDAAsD,CAAA;AAChG,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAA"}
|
|
1
|
+
{"version":3,"file":"migration-utils.d.ts","sourceRoot":"","sources":["../../src/exports/migration-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uDAAuD,CAAA;AAClG,OAAO,EACL,cAAc,EACd,qBAAqB,GACtB,MAAM,kDAAkD,CAAA;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sDAAsD,CAAA;AAChG,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { migrateJobsProcessingLease } from '../predefinedMigrations/migrateJobsProcessingLease.js';
|
|
1
2
|
export { localizeStatus, migrateLocalizeStatus } from '../predefinedMigrations/migrateLocalizeStatus.js';
|
|
2
3
|
export { migrateRelationshipsV2_V3 } from '../predefinedMigrations/migrateRelationshipsV2_V3.js';
|
|
3
4
|
export { migrateVersionsV1_V2 } from '../predefinedMigrations/migrateVersionsV1_V2.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/migration-utils.ts"],"sourcesContent":["export {\n localizeStatus,\n migrateLocalizeStatus,\n} from '../predefinedMigrations/migrateLocalizeStatus.js'\nexport { migrateRelationshipsV2_V3 } from '../predefinedMigrations/migrateRelationshipsV2_V3.js'\nexport { migrateVersionsV1_V2 } from '../predefinedMigrations/migrateVersionsV1_V2.js'\n"],"names":["localizeStatus","migrateLocalizeStatus","migrateRelationshipsV2_V3","migrateVersionsV1_V2"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/exports/migration-utils.ts"],"sourcesContent":["export { migrateJobsProcessingLease } from '../predefinedMigrations/migrateJobsProcessingLease.js'\nexport {\n localizeStatus,\n migrateLocalizeStatus,\n} from '../predefinedMigrations/migrateLocalizeStatus.js'\nexport { migrateRelationshipsV2_V3 } from '../predefinedMigrations/migrateRelationshipsV2_V3.js'\nexport { migrateVersionsV1_V2 } from '../predefinedMigrations/migrateVersionsV1_V2.js'\n"],"names":["migrateJobsProcessingLease","localizeStatus","migrateLocalizeStatus","migrateRelationshipsV2_V3","migrateVersionsV1_V2"],"mappings":"AAAA,SAASA,0BAA0B,QAAQ,wDAAuD;AAClG,SACEC,cAAc,EACdC,qBAAqB,QAChB,mDAAkD;AACzD,SAASC,yBAAyB,QAAQ,uDAAsD;AAChG,SAASC,oBAAoB,QAAQ,kDAAiD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare const imports = "import { migrateJobsProcessingLease } from '@payloadcms/db-mongodb/migration-utils'";
|
|
2
|
+
declare const upSQL = "await migrateJobsProcessingLease({\n direction: 'up',\n req,\n})";
|
|
3
|
+
declare const downSQL = "await migrateJobsProcessingLease({\n direction: 'down',\n req,\n})";
|
|
4
|
+
export { downSQL, imports, upSQL };
|
|
5
|
+
//# sourceMappingURL=jobs-processing-lease-v4.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs-processing-lease-v4.d.ts","sourceRoot":"","sources":["../../src/predefinedMigrations/jobs-processing-lease-v4.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,OAAO,wFAAwF,CAAA;AACrG,QAAA,MAAM,KAAK,uEAGR,CAAA;AACH,QAAA,MAAM,OAAO,yEAGV,CAAA;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const imports = `import { migrateJobsProcessingLease } from '@payloadcms/db-mongodb/migration-utils'`;
|
|
2
|
+
const upSQL = `await migrateJobsProcessingLease({
|
|
3
|
+
direction: 'up',
|
|
4
|
+
req,
|
|
5
|
+
})`;
|
|
6
|
+
const downSQL = `await migrateJobsProcessingLease({
|
|
7
|
+
direction: 'down',
|
|
8
|
+
req,
|
|
9
|
+
})`;
|
|
10
|
+
export { downSQL, imports, upSQL };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=jobs-processing-lease-v4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/predefinedMigrations/jobs-processing-lease-v4.ts"],"sourcesContent":["const imports = `import { migrateJobsProcessingLease } from '@payloadcms/db-mongodb/migration-utils'`\nconst upSQL = `await migrateJobsProcessingLease({\n direction: 'up',\n req,\n})`\nconst downSQL = `await migrateJobsProcessingLease({\n direction: 'down',\n req,\n})`\n\nexport { downSQL, imports, upSQL }\n"],"names":["imports","upSQL","downSQL"],"mappings":"AAAA,MAAMA,UAAU,CAAC,mFAAmF,CAAC;AACrG,MAAMC,QAAQ,CAAC;;;EAGb,CAAC;AACH,MAAMC,UAAU,CAAC;;;EAGf,CAAC;AAEH,SAASA,OAAO,EAAEF,OAAO,EAAEC,KAAK,GAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrateJobsProcessingLease.d.ts","sourceRoot":"","sources":["../../src/predefinedMigrations/migrateJobsProcessingLease.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAO7C,wBAAsB,0BAA0B,CAAC,EAC/C,SAAS,EACT,GAAG,GACJ,EAAE;IACD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;CACpB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0ChB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { getCollection } from '../utilities/getEntity.js';
|
|
2
|
+
import { getSession } from '../utilities/getSession.js';
|
|
3
|
+
export async function migrateJobsProcessingLease({ direction, req }) {
|
|
4
|
+
const adapter = req.payload.db;
|
|
5
|
+
const { Model } = getCollection({
|
|
6
|
+
adapter,
|
|
7
|
+
collectionSlug: 'payload-jobs'
|
|
8
|
+
});
|
|
9
|
+
const session = await getSession(adapter, req);
|
|
10
|
+
const indexes = await Model.collection.indexes({
|
|
11
|
+
session
|
|
12
|
+
});
|
|
13
|
+
if (direction === 'up') {
|
|
14
|
+
await Model.collection.updateMany({
|
|
15
|
+
processing: true
|
|
16
|
+
}, {
|
|
17
|
+
$set: {
|
|
18
|
+
processingUntil: new Date(0)
|
|
19
|
+
}
|
|
20
|
+
}, {
|
|
21
|
+
session
|
|
22
|
+
});
|
|
23
|
+
await Model.collection.updateMany({}, {
|
|
24
|
+
$unset: {
|
|
25
|
+
processing: ''
|
|
26
|
+
}
|
|
27
|
+
}, {
|
|
28
|
+
session
|
|
29
|
+
});
|
|
30
|
+
const processingIndex = indexes.find((index)=>index.key.processing === 1);
|
|
31
|
+
if (processingIndex?.name) {
|
|
32
|
+
await Model.collection.dropIndex(processingIndex.name, {
|
|
33
|
+
session
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
await Model.collection.createIndex({
|
|
37
|
+
processingUntil: 1
|
|
38
|
+
}, {
|
|
39
|
+
session
|
|
40
|
+
});
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
await Model.collection.updateMany({}, {
|
|
44
|
+
$set: {
|
|
45
|
+
processing: false
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
session
|
|
49
|
+
});
|
|
50
|
+
await Model.collection.updateMany({
|
|
51
|
+
processingUntil: {
|
|
52
|
+
$ne: null
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
$set: {
|
|
56
|
+
processing: true
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
session
|
|
60
|
+
});
|
|
61
|
+
await Model.collection.updateMany({}, {
|
|
62
|
+
$unset: {
|
|
63
|
+
processingToken: '',
|
|
64
|
+
processingUntil: ''
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
session
|
|
68
|
+
});
|
|
69
|
+
const processingUntilIndex = indexes.find((index)=>index.key.processingUntil === 1);
|
|
70
|
+
if (processingUntilIndex?.name) {
|
|
71
|
+
await Model.collection.dropIndex(processingUntilIndex.name, {
|
|
72
|
+
session
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
await Model.collection.createIndex({
|
|
76
|
+
processing: 1
|
|
77
|
+
}, {
|
|
78
|
+
session
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=migrateJobsProcessingLease.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/predefinedMigrations/migrateJobsProcessingLease.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { getCollection } from '../utilities/getEntity.js'\nimport { getSession } from '../utilities/getSession.js'\n\nexport async function migrateJobsProcessingLease({\n direction,\n req,\n}: {\n direction: 'down' | 'up'\n req: PayloadRequest\n}): Promise<void> {\n const adapter = req.payload.db as MongooseAdapter\n const { Model } = getCollection({ adapter, collectionSlug: 'payload-jobs' })\n const session = await getSession(adapter, req)\n const indexes = await Model.collection.indexes({ session })\n\n if (direction === 'up') {\n await Model.collection.updateMany(\n { processing: true },\n { $set: { processingUntil: new Date(0) } },\n { session },\n )\n await Model.collection.updateMany({}, { $unset: { processing: '' } }, { session })\n\n const processingIndex = indexes.find((index) => index.key.processing === 1)\n if (processingIndex?.name) {\n await Model.collection.dropIndex(processingIndex.name, { session })\n }\n\n await Model.collection.createIndex({ processingUntil: 1 }, { session })\n\n return\n }\n\n await Model.collection.updateMany({}, { $set: { processing: false } }, { session })\n await Model.collection.updateMany(\n { processingUntil: { $ne: null } },\n { $set: { processing: true } },\n { session },\n )\n await Model.collection.updateMany(\n {},\n { $unset: { processingToken: '', processingUntil: '' } },\n { session },\n )\n\n const processingUntilIndex = indexes.find((index) => index.key.processingUntil === 1)\n if (processingUntilIndex?.name) {\n await Model.collection.dropIndex(processingUntilIndex.name, { session })\n }\n\n await Model.collection.createIndex({ processing: 1 }, { session })\n}\n"],"names":["getCollection","getSession","migrateJobsProcessingLease","direction","req","adapter","payload","db","Model","collectionSlug","session","indexes","collection","updateMany","processing","$set","processingUntil","Date","$unset","processingIndex","find","index","key","name","dropIndex","createIndex","$ne","processingToken","processingUntilIndex"],"mappings":"AAIA,SAASA,aAAa,QAAQ,4BAA2B;AACzD,SAASC,UAAU,QAAQ,6BAA4B;AAEvD,OAAO,eAAeC,2BAA2B,EAC/CC,SAAS,EACTC,GAAG,EAIJ;IACC,MAAMC,UAAUD,IAAIE,OAAO,CAACC,EAAE;IAC9B,MAAM,EAAEC,KAAK,EAAE,GAAGR,cAAc;QAAEK;QAASI,gBAAgB;IAAe;IAC1E,MAAMC,UAAU,MAAMT,WAAWI,SAASD;IAC1C,MAAMO,UAAU,MAAMH,MAAMI,UAAU,CAACD,OAAO,CAAC;QAAED;IAAQ;IAEzD,IAAIP,cAAc,MAAM;QACtB,MAAMK,MAAMI,UAAU,CAACC,UAAU,CAC/B;YAAEC,YAAY;QAAK,GACnB;YAAEC,MAAM;gBAAEC,iBAAiB,IAAIC,KAAK;YAAG;QAAE,GACzC;YAAEP;QAAQ;QAEZ,MAAMF,MAAMI,UAAU,CAACC,UAAU,CAAC,CAAC,GAAG;YAAEK,QAAQ;gBAAEJ,YAAY;YAAG;QAAE,GAAG;YAAEJ;QAAQ;QAEhF,MAAMS,kBAAkBR,QAAQS,IAAI,CAAC,CAACC,QAAUA,MAAMC,GAAG,CAACR,UAAU,KAAK;QACzE,IAAIK,iBAAiBI,MAAM;YACzB,MAAMf,MAAMI,UAAU,CAACY,SAAS,CAACL,gBAAgBI,IAAI,EAAE;gBAAEb;YAAQ;QACnE;QAEA,MAAMF,MAAMI,UAAU,CAACa,WAAW,CAAC;YAAET,iBAAiB;QAAE,GAAG;YAAEN;QAAQ;QAErE;IACF;IAEA,MAAMF,MAAMI,UAAU,CAACC,UAAU,CAAC,CAAC,GAAG;QAAEE,MAAM;YAAED,YAAY;QAAM;IAAE,GAAG;QAAEJ;IAAQ;IACjF,MAAMF,MAAMI,UAAU,CAACC,UAAU,CAC/B;QAAEG,iBAAiB;YAAEU,KAAK;QAAK;IAAE,GACjC;QAAEX,MAAM;YAAED,YAAY;QAAK;IAAE,GAC7B;QAAEJ;IAAQ;IAEZ,MAAMF,MAAMI,UAAU,CAACC,UAAU,CAC/B,CAAC,GACD;QAAEK,QAAQ;YAAES,iBAAiB;YAAIX,iBAAiB;QAAG;IAAE,GACvD;QAAEN;IAAQ;IAGZ,MAAMkB,uBAAuBjB,QAAQS,IAAI,CAAC,CAACC,QAAUA,MAAMC,GAAG,CAACN,eAAe,KAAK;IACnF,IAAIY,sBAAsBL,MAAM;QAC9B,MAAMf,MAAMI,UAAU,CAACY,SAAS,CAACI,qBAAqBL,IAAI,EAAE;YAAEb;QAAQ;IACxE;IAEA,MAAMF,MAAMI,UAAU,CAACa,WAAW,CAAC;QAAEX,YAAY;IAAE,GAAG;QAAEJ;IAAQ;AAClE"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
const mocks = vi.hoisted(()=>({
|
|
3
|
+
collection: {
|
|
4
|
+
createIndex: vi.fn().mockResolvedValue(undefined),
|
|
5
|
+
dropIndex: vi.fn().mockResolvedValue(undefined),
|
|
6
|
+
indexes: vi.fn(),
|
|
7
|
+
updateMany: vi.fn().mockResolvedValue(undefined)
|
|
8
|
+
},
|
|
9
|
+
getSession: vi.fn().mockResolvedValue(undefined)
|
|
10
|
+
}));
|
|
11
|
+
vi.mock('../utilities/getEntity.js', ()=>({
|
|
12
|
+
getCollection: ()=>({
|
|
13
|
+
Model: {
|
|
14
|
+
collection: mocks.collection
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
}));
|
|
18
|
+
vi.mock('../utilities/getSession.js', ()=>({
|
|
19
|
+
getSession: mocks.getSession
|
|
20
|
+
}));
|
|
21
|
+
import { migrateJobsProcessingLease } from './migrateJobsProcessingLease.js';
|
|
22
|
+
describe('MongoDB jobs processing lease migration', ()=>{
|
|
23
|
+
const req = {
|
|
24
|
+
payload: {
|
|
25
|
+
db: {}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
afterEach(()=>{
|
|
29
|
+
vi.clearAllMocks();
|
|
30
|
+
});
|
|
31
|
+
it('should migrate active jobs to expired leases', async ()=>{
|
|
32
|
+
mocks.collection.indexes.mockResolvedValue([
|
|
33
|
+
{
|
|
34
|
+
key: {
|
|
35
|
+
_id: 1
|
|
36
|
+
},
|
|
37
|
+
name: '_id_'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
key: {
|
|
41
|
+
processing: 1
|
|
42
|
+
},
|
|
43
|
+
name: 'processing_1'
|
|
44
|
+
}
|
|
45
|
+
]);
|
|
46
|
+
await migrateJobsProcessingLease({
|
|
47
|
+
direction: 'up',
|
|
48
|
+
req
|
|
49
|
+
});
|
|
50
|
+
expect(mocks.collection.updateMany).toHaveBeenNthCalledWith(1, {
|
|
51
|
+
processing: true
|
|
52
|
+
}, {
|
|
53
|
+
$set: {
|
|
54
|
+
processingUntil: new Date(0)
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
session: undefined
|
|
58
|
+
});
|
|
59
|
+
expect(mocks.collection.updateMany).toHaveBeenNthCalledWith(2, {}, {
|
|
60
|
+
$unset: {
|
|
61
|
+
processing: ''
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
session: undefined
|
|
65
|
+
});
|
|
66
|
+
expect(mocks.collection.dropIndex).toHaveBeenCalledWith('processing_1', {
|
|
67
|
+
session: undefined
|
|
68
|
+
});
|
|
69
|
+
expect(mocks.collection.createIndex).toHaveBeenCalledWith({
|
|
70
|
+
processingUntil: 1
|
|
71
|
+
}, {
|
|
72
|
+
session: undefined
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
it('should restore the processing field when migrating down', async ()=>{
|
|
76
|
+
mocks.collection.indexes.mockResolvedValue([
|
|
77
|
+
{
|
|
78
|
+
key: {
|
|
79
|
+
_id: 1
|
|
80
|
+
},
|
|
81
|
+
name: '_id_'
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
key: {
|
|
85
|
+
processingUntil: 1
|
|
86
|
+
},
|
|
87
|
+
name: 'processingUntil_1'
|
|
88
|
+
}
|
|
89
|
+
]);
|
|
90
|
+
await migrateJobsProcessingLease({
|
|
91
|
+
direction: 'down',
|
|
92
|
+
req
|
|
93
|
+
});
|
|
94
|
+
expect(mocks.collection.updateMany).toHaveBeenNthCalledWith(1, {}, {
|
|
95
|
+
$set: {
|
|
96
|
+
processing: false
|
|
97
|
+
}
|
|
98
|
+
}, {
|
|
99
|
+
session: undefined
|
|
100
|
+
});
|
|
101
|
+
expect(mocks.collection.updateMany).toHaveBeenNthCalledWith(2, {
|
|
102
|
+
processingUntil: {
|
|
103
|
+
$ne: null
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
$set: {
|
|
107
|
+
processing: true
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
session: undefined
|
|
111
|
+
});
|
|
112
|
+
expect(mocks.collection.updateMany).toHaveBeenNthCalledWith(3, {}, {
|
|
113
|
+
$unset: {
|
|
114
|
+
processingToken: '',
|
|
115
|
+
processingUntil: ''
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
session: undefined
|
|
119
|
+
});
|
|
120
|
+
expect(mocks.collection.dropIndex).toHaveBeenCalledWith('processingUntil_1', {
|
|
121
|
+
session: undefined
|
|
122
|
+
});
|
|
123
|
+
expect(mocks.collection.createIndex).toHaveBeenCalledWith({
|
|
124
|
+
processing: 1
|
|
125
|
+
}, {
|
|
126
|
+
session: undefined
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
//# sourceMappingURL=migrateJobsProcessingLease.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/predefinedMigrations/migrateJobsProcessingLease.spec.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport { afterEach, describe, expect, it, vi } from 'vitest'\n\nconst mocks = vi.hoisted(() => ({\n collection: {\n createIndex: vi.fn().mockResolvedValue(undefined),\n dropIndex: vi.fn().mockResolvedValue(undefined),\n indexes: vi.fn(),\n updateMany: vi.fn().mockResolvedValue(undefined),\n },\n getSession: vi.fn().mockResolvedValue(undefined),\n}))\n\nvi.mock('../utilities/getEntity.js', () => ({\n getCollection: () => ({ Model: { collection: mocks.collection } }),\n}))\n\nvi.mock('../utilities/getSession.js', () => ({\n getSession: mocks.getSession,\n}))\n\nimport { migrateJobsProcessingLease } from './migrateJobsProcessingLease.js'\n\ndescribe('MongoDB jobs processing lease migration', () => {\n const req = { payload: { db: {} } } as PayloadRequest\n\n afterEach(() => {\n vi.clearAllMocks()\n })\n\n it('should migrate active jobs to expired leases', async () => {\n mocks.collection.indexes.mockResolvedValue([\n { key: { _id: 1 }, name: '_id_' },\n { key: { processing: 1 }, name: 'processing_1' },\n ])\n\n await migrateJobsProcessingLease({ direction: 'up', req })\n\n expect(mocks.collection.updateMany).toHaveBeenNthCalledWith(\n 1,\n { processing: true },\n { $set: { processingUntil: new Date(0) } },\n { session: undefined },\n )\n expect(mocks.collection.updateMany).toHaveBeenNthCalledWith(\n 2,\n {},\n { $unset: { processing: '' } },\n { session: undefined },\n )\n expect(mocks.collection.dropIndex).toHaveBeenCalledWith('processing_1', {\n session: undefined,\n })\n expect(mocks.collection.createIndex).toHaveBeenCalledWith(\n { processingUntil: 1 },\n { session: undefined },\n )\n })\n\n it('should restore the processing field when migrating down', async () => {\n mocks.collection.indexes.mockResolvedValue([\n { key: { _id: 1 }, name: '_id_' },\n { key: { processingUntil: 1 }, name: 'processingUntil_1' },\n ])\n\n await migrateJobsProcessingLease({ direction: 'down', req })\n\n expect(mocks.collection.updateMany).toHaveBeenNthCalledWith(\n 1,\n {},\n { $set: { processing: false } },\n { session: undefined },\n )\n expect(mocks.collection.updateMany).toHaveBeenNthCalledWith(\n 2,\n { processingUntil: { $ne: null } },\n { $set: { processing: true } },\n { session: undefined },\n )\n expect(mocks.collection.updateMany).toHaveBeenNthCalledWith(\n 3,\n {},\n { $unset: { processingToken: '', processingUntil: '' } },\n { session: undefined },\n )\n expect(mocks.collection.dropIndex).toHaveBeenCalledWith('processingUntil_1', {\n session: undefined,\n })\n expect(mocks.collection.createIndex).toHaveBeenCalledWith(\n { processing: 1 },\n { session: undefined },\n )\n })\n})\n"],"names":["afterEach","describe","expect","it","vi","mocks","hoisted","collection","createIndex","fn","mockResolvedValue","undefined","dropIndex","indexes","updateMany","getSession","mock","getCollection","Model","migrateJobsProcessingLease","req","payload","db","clearAllMocks","key","_id","name","processing","direction","toHaveBeenNthCalledWith","$set","processingUntil","Date","session","$unset","toHaveBeenCalledWith","$ne","processingToken"],"mappings":"AAEA,SAASA,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,SAAQ;AAE5D,MAAMC,QAAQD,GAAGE,OAAO,CAAC,IAAO,CAAA;QAC9BC,YAAY;YACVC,aAAaJ,GAAGK,EAAE,GAAGC,iBAAiB,CAACC;YACvCC,WAAWR,GAAGK,EAAE,GAAGC,iBAAiB,CAACC;YACrCE,SAAST,GAAGK,EAAE;YACdK,YAAYV,GAAGK,EAAE,GAAGC,iBAAiB,CAACC;QACxC;QACAI,YAAYX,GAAGK,EAAE,GAAGC,iBAAiB,CAACC;IACxC,CAAA;AAEAP,GAAGY,IAAI,CAAC,6BAA6B,IAAO,CAAA;QAC1CC,eAAe,IAAO,CAAA;gBAAEC,OAAO;oBAAEX,YAAYF,MAAME,UAAU;gBAAC;YAAE,CAAA;IAClE,CAAA;AAEAH,GAAGY,IAAI,CAAC,8BAA8B,IAAO,CAAA;QAC3CD,YAAYV,MAAMU,UAAU;IAC9B,CAAA;AAEA,SAASI,0BAA0B,QAAQ,kCAAiC;AAE5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D;YAAEC,MAAM;gBAAEH,YAAY;YAAM;QAAE,GAC9B;YAAEM,SAAStB;QAAU;QAEvBT,OAAOG,MAAME,UAAU,CAACO,UAAU,EAAEe,uBAAuB,CACzD,GACA;YAAEE,iBAAiB;gBAAEK,KAAK;YAAK;QAAE,GACjC;YAAEN,MAAM;gBAAEH,YAAY;YAAK;QAAE,GAC7B;YAAEM,SAAStB;QAAU;QAEvBT,OAAOG,MAAME,UAAU,CAACO,UAAU,EAAEe,uBAAuB,CACzD,GACA,CAAC,GACD;YAAEK,QAAQ;gBAAEG,iBAAiB;gBAAIN,iBAAiB;YAAG;QAAE,GACvD;YAAEE,SAAStB;QAAU;QAEvBT,OAAOG,MAAME,UAAU,CAACK,SAAS,EAAEuB,oBAAoB,CAAC,qBAAqB;YAC3EF,SAAStB;QACX;QACAT,OAAOG,MAAME,UAAU,CAACC,WAAW,EAAE2B,oBAAoB,CACvD;YAAER,YAAY;QAAE,GAChB;YAAEM,SAAStB;QAAU;IAEzB;AACF"}
|
package/dist/updateJobs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateJobs.d.ts","sourceRoot":"","sources":["../src/updateJobs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAO,UAAU,EAAS,MAAM,SAAS,CAAA;AAWrD,eAAO,MAAM,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"updateJobs.d.ts","sourceRoot":"","sources":["../src/updateJobs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAO,UAAU,EAAS,MAAM,SAAS,CAAA;AAWrD,eAAO,MAAM,UAAU,EAAE,UAiLxB,CAAA"}
|
package/dist/updateJobs.js
CHANGED
|
@@ -24,7 +24,7 @@ export const updateJobs = async function updateMany({ id, data, limit, req, retu
|
|
|
24
24
|
sort: sortArg || collectionConfig.defaultSort,
|
|
25
25
|
timestamps: true
|
|
26
26
|
});
|
|
27
|
-
|
|
27
|
+
const query = await buildQuery({
|
|
28
28
|
adapter: this,
|
|
29
29
|
collectionSlug: collectionConfig.slug,
|
|
30
30
|
fields: collectionConfig.flattenedFields,
|
|
@@ -90,25 +90,82 @@ export const updateJobs = async function updateMany({ id, data, limit, req, retu
|
|
|
90
90
|
doc
|
|
91
91
|
] : [];
|
|
92
92
|
}
|
|
93
|
-
} else {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
} else if (limit === 1) {
|
|
94
|
+
/**
|
|
95
|
+
* Select, update, and return one job atomically in a single database call.
|
|
96
|
+
* We can only do this with limit === 1, which can be expressed as findOne.
|
|
97
|
+
*/ const doc = await Model.findOneAndUpdate(query, updateData, {
|
|
98
|
+
...findOptions,
|
|
99
|
+
projection: returning === false ? {
|
|
100
|
+
_id: 1
|
|
101
|
+
} : undefined,
|
|
102
|
+
sort
|
|
103
|
+
});
|
|
104
|
+
if (returning === false) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
result = doc ? [
|
|
108
|
+
doc
|
|
109
|
+
] : [];
|
|
110
|
+
} else if (typeof limit === 'number' && limit > 1) {
|
|
111
|
+
const candidates = await Model.find(query, {}, {
|
|
112
|
+
...findOptions,
|
|
113
|
+
limit,
|
|
114
|
+
projection: {
|
|
115
|
+
_id: 1
|
|
116
|
+
},
|
|
117
|
+
sort
|
|
118
|
+
});
|
|
119
|
+
if (candidates.length === 0) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
const candidateIDs = candidates.map((candidate)=>candidate._id);
|
|
123
|
+
if (typeof data.processingToken === 'string') {
|
|
124
|
+
/**
|
|
125
|
+
* `processingToken` identifies this claim update. `processing: true` cannot, because every
|
|
126
|
+
* worker writes the same value. The token lets us reliably find the jobs this update won.
|
|
127
|
+
*/ const claimQuery = {
|
|
128
|
+
$and: [
|
|
129
|
+
query,
|
|
130
|
+
{
|
|
131
|
+
_id: {
|
|
132
|
+
$in: candidateIDs
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
};
|
|
137
|
+
await Model.updateMany(claimQuery, updateData, baseOptions);
|
|
138
|
+
if (returning === false) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
const claimedJobsQuery = {
|
|
142
|
+
_id: {
|
|
143
|
+
$in: candidateIDs
|
|
100
144
|
},
|
|
145
|
+
processingToken: {
|
|
146
|
+
$eq: data.processingToken
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
result = await Model.find(claimedJobsQuery, {}, {
|
|
150
|
+
...findOptions,
|
|
101
151
|
sort
|
|
102
152
|
});
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
query = {
|
|
153
|
+
} else {
|
|
154
|
+
const limitedUpdateQuery = {
|
|
107
155
|
_id: {
|
|
108
|
-
$in:
|
|
156
|
+
$in: candidateIDs
|
|
109
157
|
}
|
|
110
158
|
};
|
|
159
|
+
await Model.updateMany(limitedUpdateQuery, updateData, baseOptions);
|
|
160
|
+
if (returning === false) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
result = await Model.find(limitedUpdateQuery, {}, {
|
|
164
|
+
...findOptions,
|
|
165
|
+
sort
|
|
166
|
+
});
|
|
111
167
|
}
|
|
168
|
+
} else {
|
|
112
169
|
await Model.updateMany(query, updateData, baseOptions);
|
|
113
170
|
if (returning === false) {
|
|
114
171
|
return null;
|
package/dist/updateJobs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateJobs.ts"],"sourcesContent":["import type { QueryOptions, UpdateQuery } from 'mongoose'\nimport type { Job, UpdateJobs, Where } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { handleError } from './utilities/handleError.js'\nimport { transform } from './utilities/transform.js'\n\nexport const updateJobs: UpdateJobs = async function updateMany(\n this: MongooseAdapter,\n { id, data, limit, req, returning, sort: sortArg, where: whereArg },\n) {\n if (\n !(data?.log as object[])?.length &&\n !(data.log && typeof data.log === 'object' && '$push' in data.log)\n ) {\n delete data.log\n }\n\n const where = id ? { id: { equals: id } } : (whereArg as Where)\n\n const { collectionConfig, Model } = getCollection({\n adapter: this,\n collectionSlug: 'payload-jobs',\n })\n\n const sort: Record<string, unknown> | undefined = buildSortParam({\n adapter: this,\n config: this.payload.config,\n fields: collectionConfig.flattenedFields,\n sort: sortArg || collectionConfig.defaultSort,\n timestamps: true,\n })\n\n
|
|
1
|
+
{"version":3,"sources":["../src/updateJobs.ts"],"sourcesContent":["import type { QueryOptions, UpdateQuery } from 'mongoose'\nimport type { Job, UpdateJobs, Where } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { handleError } from './utilities/handleError.js'\nimport { transform } from './utilities/transform.js'\n\nexport const updateJobs: UpdateJobs = async function updateMany(\n this: MongooseAdapter,\n { id, data, limit, req, returning, sort: sortArg, where: whereArg },\n) {\n if (\n !(data?.log as object[])?.length &&\n !(data.log && typeof data.log === 'object' && '$push' in data.log)\n ) {\n delete data.log\n }\n\n const where = id ? { id: { equals: id } } : (whereArg as Where)\n\n const { collectionConfig, Model } = getCollection({\n adapter: this,\n collectionSlug: 'payload-jobs',\n })\n\n const sort: Record<string, unknown> | undefined = buildSortParam({\n adapter: this,\n config: this.payload.config,\n fields: collectionConfig.flattenedFields,\n sort: sortArg || collectionConfig.defaultSort,\n timestamps: true,\n })\n\n const query = await buildQuery({\n adapter: this,\n collectionSlug: collectionConfig.slug,\n fields: collectionConfig.flattenedFields,\n where,\n })\n\n let updateData: UpdateQuery<any> = data\n\n const $inc: Record<string, number> = {}\n const $push: Record<string, { $each: any[] } | any> = {}\n const $addToSet: Record<string, { $each: any[] } | any> = {}\n const $pull: Record<string, { $in: any[] } | any> = {}\n\n transform({\n $addToSet,\n $inc,\n $pull,\n $push,\n adapter: this,\n data,\n fields: collectionConfig.fields,\n operation: 'write',\n })\n\n const updateOps: UpdateQuery<any> = {}\n\n if (Object.keys($inc).length) {\n updateOps.$inc = $inc\n }\n if (Object.keys($push).length) {\n updateOps.$push = $push\n }\n if (Object.keys($addToSet).length) {\n updateOps.$addToSet = $addToSet\n }\n if (Object.keys($pull).length) {\n updateOps.$pull = $pull\n }\n if (Object.keys(updateOps).length) {\n updateOps.$set = updateData\n updateData = updateOps\n }\n\n const baseOptions = {\n session: await getSession(this, req),\n // Timestamps are manually added by the write transform\n timestamps: false,\n } satisfies QueryOptions\n\n const findOptions: QueryOptions = {\n ...baseOptions,\n lean: true,\n new: true,\n }\n\n let result: Job[] = []\n\n try {\n if (id) {\n if (returning === false) {\n await Model.updateOne(query, updateData, baseOptions)\n transform({ adapter: this, data, fields: collectionConfig.fields, operation: 'read' })\n\n return null\n } else {\n const doc = await Model.findOneAndUpdate(query, updateData, findOptions)\n result = doc ? [doc] : []\n }\n } else if (limit === 1) {\n /**\n * Select, update, and return one job atomically in a single database call.\n * We can only do this with limit === 1, which can be expressed as findOne.\n */\n const doc = await Model.findOneAndUpdate(query, updateData, {\n ...findOptions,\n projection: returning === false ? { _id: 1 } : undefined,\n sort,\n })\n\n if (returning === false) {\n return null\n }\n\n result = doc ? [doc] : []\n } else if (typeof limit === 'number' && limit > 1) {\n const candidates = await Model.find(\n query,\n {},\n { ...findOptions, limit, projection: { _id: 1 }, sort },\n )\n\n if (candidates.length === 0) {\n return null\n }\n\n const candidateIDs = candidates.map((candidate) => candidate._id)\n\n if (typeof data.processingToken === 'string') {\n /**\n * `processingToken` identifies this claim update. `processing: true` cannot, because every\n * worker writes the same value. The token lets us reliably find the jobs this update won.\n */\n const claimQuery = {\n $and: [query, { _id: { $in: candidateIDs } }],\n }\n\n await Model.updateMany(claimQuery, updateData, baseOptions)\n\n if (returning === false) {\n return null\n }\n\n const claimedJobsQuery = {\n _id: { $in: candidateIDs },\n processingToken: { $eq: data.processingToken },\n }\n\n result = await Model.find(claimedJobsQuery, {}, { ...findOptions, sort })\n } else {\n const limitedUpdateQuery = { _id: { $in: candidateIDs } }\n\n await Model.updateMany(limitedUpdateQuery, updateData, baseOptions)\n\n if (returning === false) {\n return null\n }\n\n result = await Model.find(limitedUpdateQuery, {}, { ...findOptions, sort })\n }\n } else {\n await Model.updateMany(query, updateData, baseOptions)\n\n if (returning === false) {\n return null\n }\n\n result = await Model.find(query, {}, { ...findOptions, sort })\n }\n } catch (error) {\n handleError({ collection: collectionConfig.slug, error, req })\n }\n\n transform({\n adapter: this,\n data: result,\n fields: collectionConfig.fields,\n operation: 'read',\n })\n\n return result\n}\n"],"names":["buildQuery","buildSortParam","getCollection","getSession","handleError","transform","updateJobs","updateMany","id","data","limit","req","returning","sort","sortArg","where","whereArg","log","length","equals","collectionConfig","Model","adapter","collectionSlug","config","payload","fields","flattenedFields","defaultSort","timestamps","query","slug","updateData","$inc","$push","$addToSet","$pull","operation","updateOps","Object","keys","$set","baseOptions","session","findOptions","lean","new","result","updateOne","doc","findOneAndUpdate","projection","_id","undefined","candidates","find","candidateIDs","map","candidate","processingToken","claimQuery","$and","$in","claimedJobsQuery","$eq","limitedUpdateQuery","error","collection"],"mappings":"AAKA,SAASA,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,WAAW,QAAQ,6BAA4B;AACxD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,aAAyB,eAAeC,WAEnD,EAAEC,EAAE,EAAEC,IAAI,EAAEC,KAAK,EAAEC,GAAG,EAAEC,SAAS,EAAEC,MAAMC,OAAO,EAAEC,OAAOC,QAA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;QACRiB,SAAS,IAAI;QACbb,MAAMsC;QACNrB,QAAQN,iBAAiBM,MAAM;QAC/BW,WAAW;IACb;IAEA,OAAOU;AACT,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/db-mongodb",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.0b9bec1",
|
|
4
4
|
"description": "The officially supported MongoDB database adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -54,10 +54,10 @@
|
|
|
54
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.
|
|
57
|
+
"payload": "4.0.0-internal.0b9bec1"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"payload": "4.0.0-internal.
|
|
60
|
+
"payload": "4.0.0-internal.0b9bec1"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "pnpm build:types && pnpm build:swc",
|