@payloadcms/drizzle 3.65.0-internal.098b771 → 3.65.0-internal.19683e7
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/transactions/commitTransaction.d.ts.map +1 -1
- package/dist/transactions/commitTransaction.js +9 -8
- package/dist/transactions/commitTransaction.js.map +1 -1
- package/dist/transactions/rollbackTransaction.d.ts.map +1 -1
- package/dist/transactions/rollbackTransaction.js +5 -3
- package/dist/transactions/rollbackTransaction.js.map +1 -1
- package/dist/utilities/getTransaction.d.ts +3 -0
- package/dist/utilities/getTransaction.d.ts.map +1 -1
- package/dist/utilities/getTransaction.js +3 -0
- package/dist/utilities/getTransaction.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commitTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/commitTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"commitTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/commitTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD,eAAO,MAAM,iBAAiB,EAAE,iBAqB/B,CAAA"}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
export const commitTransaction = async function commitTransaction(
|
|
2
|
-
|
|
3
|
-
return;
|
|
4
|
-
}
|
|
1
|
+
export const commitTransaction = async function commitTransaction(incomingID = '') {
|
|
2
|
+
const transactionID = incomingID instanceof Promise ? await incomingID : incomingID;
|
|
5
3
|
// if the session was deleted it has already been aborted
|
|
6
|
-
if (!this.sessions[
|
|
4
|
+
if (!this.sessions[transactionID]) {
|
|
7
5
|
return;
|
|
8
6
|
}
|
|
7
|
+
const session = this.sessions[transactionID];
|
|
8
|
+
// Delete from registry FIRST to prevent race conditions
|
|
9
|
+
// This ensures other operations can't retrieve this session while we're ending it
|
|
10
|
+
delete this.sessions[transactionID];
|
|
9
11
|
try {
|
|
10
|
-
await
|
|
12
|
+
await session.resolve();
|
|
11
13
|
} catch (_) {
|
|
12
|
-
await
|
|
14
|
+
await session.reject();
|
|
13
15
|
}
|
|
14
|
-
delete this.sessions[id];
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
//# sourceMappingURL=commitTransaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transactions/commitTransaction.ts"],"sourcesContent":["import type { CommitTransaction } from 'payload'\n\nexport const commitTransaction: CommitTransaction = async function commitTransaction(
|
|
1
|
+
{"version":3,"sources":["../../src/transactions/commitTransaction.ts"],"sourcesContent":["import type { CommitTransaction } from 'payload'\n\nexport const commitTransaction: CommitTransaction = async function commitTransaction(\n incomingID = '',\n) {\n const transactionID = incomingID instanceof Promise ? await incomingID : incomingID\n\n // if the session was deleted it has already been aborted\n if (!this.sessions[transactionID]) {\n return\n }\n\n const session = this.sessions[transactionID]\n\n // Delete from registry FIRST to prevent race conditions\n // This ensures other operations can't retrieve this session while we're ending it\n delete this.sessions[transactionID]\n\n try {\n await session.resolve()\n } catch (_) {\n await session.reject()\n }\n}\n"],"names":["commitTransaction","incomingID","transactionID","Promise","sessions","session","resolve","_","reject"],"mappings":"AAEA,OAAO,MAAMA,oBAAuC,eAAeA,kBACjEC,aAAa,EAAE;IAEf,MAAMC,gBAAgBD,sBAAsBE,UAAU,MAAMF,aAAaA;IAEzE,yDAAyD;IACzD,IAAI,CAAC,IAAI,CAACG,QAAQ,CAACF,cAAc,EAAE;QACjC;IACF;IAEA,MAAMG,UAAU,IAAI,CAACD,QAAQ,CAACF,cAAc;IAE5C,wDAAwD;IACxD,kFAAkF;IAClF,OAAO,IAAI,CAACE,QAAQ,CAACF,cAAc;IAEnC,IAAI;QACF,MAAMG,QAAQC,OAAO;IACvB,EAAE,OAAOC,GAAG;QACV,MAAMF,QAAQG,MAAM;IACtB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollbackTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/rollbackTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElD,eAAO,MAAM,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"rollbackTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/rollbackTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElD,eAAO,MAAM,mBAAmB,EAAE,mBAmBjC,CAAA"}
|
|
@@ -5,10 +5,12 @@ export const rollbackTransaction = async function rollbackTransaction(incomingID
|
|
|
5
5
|
if (!this.sessions[transactionID]) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//
|
|
8
|
+
const session = this.sessions[transactionID];
|
|
9
|
+
// Delete from registry FIRST to prevent race conditions
|
|
10
|
+
// This ensures other operations can't retrieve this session while we're ending it
|
|
11
11
|
delete this.sessions[transactionID];
|
|
12
|
+
// end the session promise in failure by calling reject
|
|
13
|
+
await session.reject();
|
|
12
14
|
};
|
|
13
15
|
|
|
14
16
|
//# sourceMappingURL=rollbackTransaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transactions/rollbackTransaction.ts"],"sourcesContent":["import type { RollbackTransaction } from 'payload'\n\nexport const rollbackTransaction: RollbackTransaction = async function rollbackTransaction(\n incomingID = '',\n) {\n const transactionID = incomingID instanceof Promise ? await incomingID : incomingID\n\n // if multiple operations are using the same transaction, the first will flow through and delete the session.\n // subsequent calls should be ignored.\n if (!this.sessions[transactionID]) {\n return\n }\n\n
|
|
1
|
+
{"version":3,"sources":["../../src/transactions/rollbackTransaction.ts"],"sourcesContent":["import type { RollbackTransaction } from 'payload'\n\nexport const rollbackTransaction: RollbackTransaction = async function rollbackTransaction(\n incomingID = '',\n) {\n const transactionID = incomingID instanceof Promise ? await incomingID : incomingID\n\n // if multiple operations are using the same transaction, the first will flow through and delete the session.\n // subsequent calls should be ignored.\n if (!this.sessions[transactionID]) {\n return\n }\n\n const session = this.sessions[transactionID]\n\n // Delete from registry FIRST to prevent race conditions\n // This ensures other operations can't retrieve this session while we're ending it\n delete this.sessions[transactionID]\n\n // end the session promise in failure by calling reject\n await session.reject()\n}\n"],"names":["rollbackTransaction","incomingID","transactionID","Promise","sessions","session","reject"],"mappings":"AAEA,OAAO,MAAMA,sBAA2C,eAAeA,oBACrEC,aAAa,EAAE;IAEf,MAAMC,gBAAgBD,sBAAsBE,UAAU,MAAMF,aAAaA;IAEzE,6GAA6G;IAC7G,sCAAsC;IACtC,IAAI,CAAC,IAAI,CAACG,QAAQ,CAACF,cAAc,EAAE;QACjC;IACF;IAEA,MAAMG,UAAU,IAAI,CAACD,QAAQ,CAACF,cAAc;IAE5C,wDAAwD;IACxD,kFAAkF;IAClF,OAAO,IAAI,CAACE,QAAQ,CAACF,cAAc;IAEnC,uDAAuD;IACvD,MAAMG,QAAQC,MAAM;AACtB,EAAC"}
|
|
@@ -2,6 +2,9 @@ import type { PayloadRequest } from 'payload';
|
|
|
2
2
|
import type { DrizzleAdapter } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Returns current db transaction instance from req or adapter.drizzle itself
|
|
5
|
+
*
|
|
6
|
+
* If a transaction session doesn't exist (e.g., it was already committed/rolled back),
|
|
7
|
+
* falls back to the default adapter.drizzle instance to prevent errors.
|
|
5
8
|
*/
|
|
6
9
|
export declare const getTransaction: <T extends DrizzleAdapter = DrizzleAdapter>(adapter: T, req?: Partial<PayloadRequest>) => Promise<T["drizzle"]>;
|
|
7
10
|
//# sourceMappingURL=getTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTransaction.d.ts","sourceRoot":"","sources":["../../src/utilities/getTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD
|
|
1
|
+
{"version":3,"file":"getTransaction.d.ts","sourceRoot":"","sources":["../../src/utilities/getTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAU,CAAC,SAAS,cAAc,4BAClD,CAAC,QACJ,OAAO,CAAC,cAAc,CAAC,KAC5B,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAMtB,CAAA"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns current db transaction instance from req or adapter.drizzle itself
|
|
3
|
+
*
|
|
4
|
+
* If a transaction session doesn't exist (e.g., it was already committed/rolled back),
|
|
5
|
+
* falls back to the default adapter.drizzle instance to prevent errors.
|
|
3
6
|
*/ export const getTransaction = async (adapter, req)=>{
|
|
4
7
|
if (!req?.transactionID) {
|
|
5
8
|
return adapter.drizzle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/getTransaction.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport type { DrizzleAdapter } from '../types.js'\n\n/**\n * Returns current db transaction instance from req or adapter.drizzle itself\n */\nexport const getTransaction = async <T extends DrizzleAdapter = DrizzleAdapter>(\n adapter: T,\n req?: Partial<PayloadRequest>,\n): Promise<T['drizzle']> => {\n if (!req?.transactionID) {\n return adapter.drizzle\n }\n\n return (adapter.sessions[await req.transactionID]?.db as T['drizzle']) || adapter.drizzle\n}\n"],"names":["getTransaction","adapter","req","transactionID","drizzle","sessions","db"],"mappings":"AAIA
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/getTransaction.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport type { DrizzleAdapter } from '../types.js'\n\n/**\n * Returns current db transaction instance from req or adapter.drizzle itself\n *\n * If a transaction session doesn't exist (e.g., it was already committed/rolled back),\n * falls back to the default adapter.drizzle instance to prevent errors.\n */\nexport const getTransaction = async <T extends DrizzleAdapter = DrizzleAdapter>(\n adapter: T,\n req?: Partial<PayloadRequest>,\n): Promise<T['drizzle']> => {\n if (!req?.transactionID) {\n return adapter.drizzle\n }\n\n return (adapter.sessions[await req.transactionID]?.db as T['drizzle']) || adapter.drizzle\n}\n"],"names":["getTransaction","adapter","req","transactionID","drizzle","sessions","db"],"mappings":"AAIA;;;;;CAKC,GACD,OAAO,MAAMA,iBAAiB,OAC5BC,SACAC;IAEA,IAAI,CAACA,KAAKC,eAAe;QACvB,OAAOF,QAAQG,OAAO;IACxB;IAEA,OAAO,AAACH,QAAQI,QAAQ,CAAC,MAAMH,IAAIC,aAAa,CAAC,EAAEG,MAAuBL,QAAQG,OAAO;AAC3F,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/drizzle",
|
|
3
|
-
"version": "3.65.0-internal.
|
|
3
|
+
"version": "3.65.0-internal.19683e7",
|
|
4
4
|
"description": "A library of shared functions used by different payload database adapters",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"console-table-printer": "2.12.1",
|
|
52
52
|
"dequal": "2.0.3",
|
|
53
|
-
"drizzle-orm": "0.44.
|
|
53
|
+
"drizzle-orm": "0.44.7",
|
|
54
54
|
"prompts": "2.4.2",
|
|
55
55
|
"to-snake-case": "1.0.0",
|
|
56
56
|
"uuid": "9.0.0"
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
"@libsql/client": "0.14.0",
|
|
60
60
|
"@types/pg": "8.10.2",
|
|
61
61
|
"@types/to-snake-case": "1.0.0",
|
|
62
|
-
"
|
|
63
|
-
"
|
|
62
|
+
"@payloadcms/eslint-config": "3.28.0",
|
|
63
|
+
"payload": "3.65.0-internal.19683e7"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"payload": "3.65.0-internal.
|
|
66
|
+
"payload": "3.65.0-internal.19683e7"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"build": "pnpm build:swc && pnpm build:types",
|