@payloadcms/drizzle 3.83.0-canary.1 → 3.83.0-canary.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"beginTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/beginTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAM/C,eAAO,MAAM,gBAAgB,EAAE,gBA2D9B,CAAA"}
1
+ {"version":3,"file":"beginTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/beginTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAM/C,eAAO,MAAM,gBAAgB,EAAE,gBAgE9B,CAAA"}
@@ -7,6 +7,7 @@ export const beginTransaction = async function beginTransaction(options) {
7
7
  let resolve;
8
8
  let transaction;
9
9
  let transactionReady;
10
+ let transactionFailed;
10
11
  // Await initialization here
11
12
  // Prevent race conditions where the adapter may be
12
13
  // re-initializing, and `this.drizzle` is potentially undefined
@@ -30,12 +31,16 @@ export const beginTransaction = async function beginTransaction(options) {
30
31
  };
31
32
  transactionReady();
32
33
  });
33
- }, options || this.transactionOptions).catch(()=>{
34
- // swallow
34
+ }, options || this.transactionOptions).catch((err)=>{
35
+ // Connection failed before callback ran - reject instead of hanging forever
36
+ transactionFailed(err);
35
37
  });
36
38
  // Need to wait until the transaction is ready
37
39
  // before binding its `resolve` and `reject` methods below
38
- await new Promise((resolve)=>transactionReady = resolve);
40
+ await new Promise((res, rej)=>{
41
+ transactionReady = res;
42
+ transactionFailed = rej;
43
+ });
39
44
  this.sessions[id] = {
40
45
  db: transaction,
41
46
  reject,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/transactions/beginTransaction.ts"],"sourcesContent":["import type { BeginTransaction } from 'payload'\n\nimport { v4 as uuid } from 'uuid'\n\nimport type { DrizzleAdapter, DrizzleTransaction } from '../types.js'\n\nexport const beginTransaction: BeginTransaction = async function beginTransaction(\n this: DrizzleAdapter,\n options: DrizzleAdapter['transactionOptions'],\n) {\n let id\n try {\n id = uuid()\n\n let reject: () => Promise<void>\n let resolve: () => Promise<void>\n let transaction: DrizzleTransaction\n\n let transactionReady: () => void\n\n // Await initialization here\n // Prevent race conditions where the adapter may be\n // re-initializing, and `this.drizzle` is potentially undefined\n await this.initializing\n\n // Drizzle only exposes a transactions API that is sufficient if you\n // can directly pass around the `tx` argument. But our operations are spread\n // over many files and we don't want to pass the `tx` around like that,\n // so instead, we \"lift\" up the `resolve` and `reject` methods\n // and will call them in our respective transaction methods\n const done = this.drizzle\n .transaction(async (tx) => {\n transaction = tx\n await new Promise<void>((res, rej) => {\n resolve = () => {\n res()\n return done\n }\n reject = () => {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n rej()\n return done\n }\n transactionReady()\n })\n }, options || this.transactionOptions)\n .catch(() => {\n // swallow\n })\n\n // Need to wait until the transaction is ready\n // before binding its `resolve` and `reject` methods below\n await new Promise<void>((resolve) => (transactionReady = resolve))\n\n this.sessions[id] = {\n db: transaction,\n reject,\n resolve,\n }\n } catch (err) {\n this.payload.logger.error({ err, msg: `Error: cannot begin transaction: ${err.message}` })\n throw new Error(`Error: cannot begin transaction: ${err.message}`)\n }\n\n return id\n}\n"],"names":["v4","uuid","beginTransaction","options","id","reject","resolve","transaction","transactionReady","initializing","done","drizzle","tx","Promise","res","rej","transactionOptions","catch","sessions","db","err","payload","logger","error","msg","message","Error"],"mappings":"AAEA,SAASA,MAAMC,IAAI,QAAQ,OAAM;AAIjC,OAAO,MAAMC,mBAAqC,eAAeA,iBAE/DC,OAA6C;IAE7C,IAAIC;IACJ,IAAI;QACFA,KAAKH;QAEL,IAAII;QACJ,IAAIC;QACJ,IAAIC;QAEJ,IAAIC;QAEJ,4BAA4B;QAC5B,mDAAmD;QACnD,+DAA+D;QAC/D,MAAM,IAAI,CAACC,YAAY;QAEvB,oEAAoE;QACpE,4EAA4E;QAC5E,uEAAuE;QACvE,8DAA8D;QAC9D,2DAA2D;QAC3D,MAAMC,OAAO,IAAI,CAACC,OAAO,CACtBJ,WAAW,CAAC,OAAOK;YAClBL,cAAcK;YACd,MAAM,IAAIC,QAAc,CAACC,KAAKC;gBAC5BT,UAAU;oBACRQ;oBACA,OAAOJ;gBACT;gBACAL,SAAS;oBACP,2EAA2E;oBAC3EU;oBACA,OAAOL;gBACT;gBACAF;YACF;QACF,GAAGL,WAAW,IAAI,CAACa,kBAAkB,EACpCC,KAAK,CAAC;QACL,UAAU;QACZ;QAEF,8CAA8C;QAC9C,0DAA0D;QAC1D,MAAM,IAAIJ,QAAc,CAACP,UAAaE,mBAAmBF;QAEzD,IAAI,CAACY,QAAQ,CAACd,GAAG,GAAG;YAClBe,IAAIZ;YACJF;YACAC;QACF;IACF,EAAE,OAAOc,KAAK;QACZ,IAAI,CAACC,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC;YAAEH;YAAKI,KAAK,CAAC,iCAAiC,EAAEJ,IAAIK,OAAO,EAAE;QAAC;QACxF,MAAM,IAAIC,MAAM,CAAC,iCAAiC,EAAEN,IAAIK,OAAO,EAAE;IACnE;IAEA,OAAOrB;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/transactions/beginTransaction.ts"],"sourcesContent":["import type { BeginTransaction } from 'payload'\n\nimport { v4 as uuid } from 'uuid'\n\nimport type { DrizzleAdapter, DrizzleTransaction } from '../types.js'\n\nexport const beginTransaction: BeginTransaction = async function beginTransaction(\n this: DrizzleAdapter,\n options: DrizzleAdapter['transactionOptions'],\n) {\n let id\n try {\n id = uuid()\n\n let reject: () => Promise<void>\n let resolve: () => Promise<void>\n let transaction: DrizzleTransaction\n\n let transactionReady: () => void\n let transactionFailed: (err: unknown) => void\n\n // Await initialization here\n // Prevent race conditions where the adapter may be\n // re-initializing, and `this.drizzle` is potentially undefined\n await this.initializing\n\n // Drizzle only exposes a transactions API that is sufficient if you\n // can directly pass around the `tx` argument. But our operations are spread\n // over many files and we don't want to pass the `tx` around like that,\n // so instead, we \"lift\" up the `resolve` and `reject` methods\n // and will call them in our respective transaction methods\n const done = this.drizzle\n .transaction(async (tx) => {\n transaction = tx\n await new Promise<void>((res, rej) => {\n resolve = () => {\n res()\n return done\n }\n reject = () => {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n rej()\n return done\n }\n transactionReady()\n })\n }, options || this.transactionOptions)\n .catch((err) => {\n // Connection failed before callback ran - reject instead of hanging forever\n transactionFailed(err)\n })\n\n // Need to wait until the transaction is ready\n // before binding its `resolve` and `reject` methods below\n await new Promise<void>((res, rej) => {\n transactionReady = res\n transactionFailed = rej\n })\n\n this.sessions[id] = {\n db: transaction,\n reject,\n resolve,\n }\n } catch (err) {\n this.payload.logger.error({ err, msg: `Error: cannot begin transaction: ${err.message}` })\n throw new Error(`Error: cannot begin transaction: ${err.message}`)\n }\n\n return id\n}\n"],"names":["v4","uuid","beginTransaction","options","id","reject","resolve","transaction","transactionReady","transactionFailed","initializing","done","drizzle","tx","Promise","res","rej","transactionOptions","catch","err","sessions","db","payload","logger","error","msg","message","Error"],"mappings":"AAEA,SAASA,MAAMC,IAAI,QAAQ,OAAM;AAIjC,OAAO,MAAMC,mBAAqC,eAAeA,iBAE/DC,OAA6C;IAE7C,IAAIC;IACJ,IAAI;QACFA,KAAKH;QAEL,IAAII;QACJ,IAAIC;QACJ,IAAIC;QAEJ,IAAIC;QACJ,IAAIC;QAEJ,4BAA4B;QAC5B,mDAAmD;QACnD,+DAA+D;QAC/D,MAAM,IAAI,CAACC,YAAY;QAEvB,oEAAoE;QACpE,4EAA4E;QAC5E,uEAAuE;QACvE,8DAA8D;QAC9D,2DAA2D;QAC3D,MAAMC,OAAO,IAAI,CAACC,OAAO,CACtBL,WAAW,CAAC,OAAOM;YAClBN,cAAcM;YACd,MAAM,IAAIC,QAAc,CAACC,KAAKC;gBAC5BV,UAAU;oBACRS;oBACA,OAAOJ;gBACT;gBACAN,SAAS;oBACP,2EAA2E;oBAC3EW;oBACA,OAAOL;gBACT;gBACAH;YACF;QACF,GAAGL,WAAW,IAAI,CAACc,kBAAkB,EACpCC,KAAK,CAAC,CAACC;YACN,4EAA4E;YAC5EV,kBAAkBU;QACpB;QAEF,8CAA8C;QAC9C,0DAA0D;QAC1D,MAAM,IAAIL,QAAc,CAACC,KAAKC;YAC5BR,mBAAmBO;YACnBN,oBAAoBO;QACtB;QAEA,IAAI,CAACI,QAAQ,CAAChB,GAAG,GAAG;YAClBiB,IAAId;YACJF;YACAC;QACF;IACF,EAAE,OAAOa,KAAK;QACZ,IAAI,CAACG,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC;YAAEL;YAAKM,KAAK,CAAC,iCAAiC,EAAEN,IAAIO,OAAO,EAAE;QAAC;QACxF,MAAM,IAAIC,MAAM,CAAC,iCAAiC,EAAER,IAAIO,OAAO,EAAE;IACnE;IAEA,OAAOtB;AACT,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/drizzle",
3
- "version": "3.83.0-canary.1",
3
+ "version": "3.83.0-canary.2",
4
4
  "description": "A library of shared functions used by different payload database adapters",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -60,10 +60,10 @@
60
60
  "@types/pg": "8.20.0",
61
61
  "@types/to-snake-case": "1.0.0",
62
62
  "@payloadcms/eslint-config": "3.28.0",
63
- "payload": "3.83.0-canary.1"
63
+ "payload": "3.83.0-canary.2"
64
64
  },
65
65
  "peerDependencies": {
66
- "payload": "3.83.0-canary.1"
66
+ "payload": "3.83.0-canary.2"
67
67
  },
68
68
  "scripts": {
69
69
  "build": "pnpm build:swc && pnpm build:types",