@lokalise/prisma-utils 1.2.0 → 1.4.0
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/errors/cockroachdbError.js.map +1 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/{prismaError.d.ts → errors/prismaError.d.ts} +2 -0
- package/dist/errors/prismaError.js +11 -0
- package/dist/errors/prismaError.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/isolation_level/isolationLevel.d.ts +3 -0
- package/dist/prismaTransaction.d.ts +3 -3
- package/dist/prismaTransaction.js +43 -31
- package/dist/prismaTransaction.js.map +1 -1
- package/dist/types.d.ts +8 -2
- package/package.json +63 -65
- package/dist/cockroachdbError.js.map +0 -1
- package/dist/prismaError.js +0 -9
- package/dist/prismaError.js.map +0 -1
- package/dist/types.js +0 -7
- package/dist/types.js.map +0 -1
- /package/dist/{cockroachdbError.d.ts → errors/cockroachdbError.d.ts} +0 -0
- /package/dist/{cockroachdbError.js → errors/cockroachdbError.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cockroachdbError.js","sources":["../../src/errors/cockroachdbError.ts"],"sourcesContent":["import type { PrismaClientKnownRequestError } from '@prisma/client/runtime/library'\n\n/**\n * https://www.cockroachlabs.com/docs/stable/transaction-retry-error-reference#:~:text=To%20indicate%20that%20a%20transaction,the%20string%20%22restart%20transaction%22%20.\n *\n * All transaction retry errors use the SQLSTATE error code 40001\n */\nconst COCKROACHDB_RETRY_TRANSACTION_CODE = '40001'\n\n/**\n * Check if the error is a CockroachDB transaction retry error\n *\n * @param error\n */\nexport const isCockroachDBRetryTransaction = (error: PrismaClientKnownRequestError): boolean => {\n const meta = error.meta\n if (!meta) return false\n\n return meta.code === COCKROACHDB_RETRY_TRANSACTION_CODE\n}\n"],"names":["COCKROACHDB_RETRY_TRANSACTION_CODE","isCockroachDBRetryTransaction","error","meta"],"mappings":"AAOA,MAAMA,IAAqC,SAO9BC,IAAgC,CAACC,MAAkD;AAC9F,QAAMC,IAAOD,EAAM;AACf,SAACC,IAEEA,EAAK,SAASH,IAFH;AAGpB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './prismaError';
|
|
@@ -8,6 +8,8 @@ import { PrismaClientKnownRequestError } from '@prisma/client/runtime/library';
|
|
|
8
8
|
* 4. code starts by `P` ([doc](https://www.prisma.io/docs/reference/api-reference/error-reference#error-codes))
|
|
9
9
|
*/
|
|
10
10
|
export declare const isPrismaClientKnownRequestError: (error: unknown) => error is PrismaClientKnownRequestError;
|
|
11
|
+
export declare const isPrismaTransactionClosedError: (error: PrismaClientKnownRequestError) => boolean;
|
|
11
12
|
export declare const PRISMA_NOT_FOUND_ERROR = "P2025";
|
|
12
13
|
export declare const PRISMA_SERIALIZATION_ERROR = "P2034";
|
|
13
14
|
export declare const PRISMA_UNIQUE_CONSTRAINT_ERROR = "P2002";
|
|
15
|
+
export declare const PRISMA_TRANSACTION_ERROR = "P2028";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isError as R } from "@lokalise/node-core";
|
|
2
|
+
const n = (s) => !!s && R(s) && "code" in s && typeof s.code == "string" && s.code.startsWith("P"), c = (s) => s.code === o && s.message.includes("Transaction already closed"), i = "P2025", P = "P2034", a = "P2002", o = "P2028";
|
|
3
|
+
export {
|
|
4
|
+
i as PRISMA_NOT_FOUND_ERROR,
|
|
5
|
+
P as PRISMA_SERIALIZATION_ERROR,
|
|
6
|
+
o as PRISMA_TRANSACTION_ERROR,
|
|
7
|
+
a as PRISMA_UNIQUE_CONSTRAINT_ERROR,
|
|
8
|
+
n as isPrismaClientKnownRequestError,
|
|
9
|
+
c as isPrismaTransactionClosedError
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=prismaError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prismaError.js","sources":["../../src/errors/prismaError.ts"],"sourcesContent":["import { isError } from '@lokalise/node-core'\nimport type { PrismaClientKnownRequestError } from '@prisma/client/runtime/library'\n\n/**\n * What is checked?\n * \t1. error is defined and not null\n * \t2. error is an `Error`\n * \t3. error contains the field code which is a string\n * \t4. code starts by `P` ([doc](https://www.prisma.io/docs/reference/api-reference/error-reference#error-codes))\n */\nexport const isPrismaClientKnownRequestError = (\n error: unknown,\n): error is PrismaClientKnownRequestError =>\n !!error &&\n isError(error) &&\n 'code' in error &&\n typeof error.code === 'string' &&\n error.code.startsWith('P')\n\nexport const isPrismaTransactionClosedError = (error: PrismaClientKnownRequestError): boolean =>\n error.code === PRISMA_TRANSACTION_ERROR && error.message.includes('Transaction already closed')\n\n/*\n * Prisma error code P2025 indicates that the operation failed because it depends on one or more\n * records that were required but not found\n */\nexport const PRISMA_NOT_FOUND_ERROR = 'P2025'\n\n/*\n * Prisma error code P2034 indicates a serialization error and that the transaction must be retried.\n * A different error code would indicate that an internal state error happened and that\n * the cluster itself is experiencing an issue which requires intervention\n */\nexport const PRISMA_SERIALIZATION_ERROR = 'P2034'\n\n/*\n * Prisma error code P2002 indicates that the operation failed because a unique constraint was\n * violated. This can happen if you try to create a record with a unique field that already exists\n */\nexport const PRISMA_UNIQUE_CONSTRAINT_ERROR = 'P2002'\n\n/*\n * Prisma error code P2028 indicates a transaction API error, essentially a placeholder for errors that do not fit into\n * a more specific category. You should look into the error message for more details\n */\nexport const PRISMA_TRANSACTION_ERROR = 'P2028'\n"],"names":["isPrismaClientKnownRequestError","error","isError","isPrismaTransactionClosedError","PRISMA_TRANSACTION_ERROR","PRISMA_NOT_FOUND_ERROR","PRISMA_SERIALIZATION_ERROR","PRISMA_UNIQUE_CONSTRAINT_ERROR"],"mappings":";AAUO,MAAMA,IAAkC,CAC7CC,MAEA,CAAC,CAACA,KACFC,EAAQD,CAAK,KACb,UAAUA,KACV,OAAOA,EAAM,QAAS,YACtBA,EAAM,KAAK,WAAW,GAAG,GAEdE,IAAiC,CAACF,MAC7CA,EAAM,SAASG,KAA4BH,EAAM,QAAQ,SAAS,4BAA4B,GAMnFI,IAAyB,SAOzBC,IAA6B,SAM7BC,IAAiC,SAMjCH,IAA2B;"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@lokalise/node-core"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@lokalise/node-core"),T=require("node:timers/promises"),c=e=>!!e&&i.isError(e)&&"code"in e&&typeof e.code=="string"&&e.code.startsWith("P"),R=e=>e.code===u&&e.message.includes("Transaction already closed"),A="P2025",l="P2034",m="P2002",u="P2028",O="40001",_=e=>{const r=e.meta;return r?r.code===O:!1},d={retriesAllowed:2,DbDriver:"CockroachDb",baseRetryDelayMs:100,maxRetryDelayMs:3e4,timeout:5e3,maxTimeout:3e4},y=async(e,r,o)=>{let t={...d,...o},s,a=0;do{if(a>0&&await T.setTimeout(E(a,t.baseRetryDelayMs,t.maxRetryDelayMs)),s=await I(e,r,t),s.result)break;const n=N(s,t.DbDriver);if(!n)break;n==="increase-timeout"&&(t=i.deepClone(t),t.timeout=Math.min(t.timeout*2,t.maxTimeout)),a++}while(a<=t.retriesAllowed);return s??{error:new Error("No transaction executed")}},I=async(e,r,o)=>{try{return{result:await e.$transaction(r,o)}}catch(t){return{error:t}}},E=(e,r,o)=>{const t=Math.pow(2,e-1)*r;return Math.min(t,o)},N=(e,r)=>{if(c(e.error)){const o=e.error;if(o.code===l||r==="CockroachDb"&&_(o))return!0;if(R(o))return"increase-timeout"}return!1};exports.PRISMA_NOT_FOUND_ERROR=A;exports.PRISMA_SERIALIZATION_ERROR=l;exports.PRISMA_TRANSACTION_ERROR=u;exports.PRISMA_UNIQUE_CONSTRAINT_ERROR=m;exports.isPrismaClientKnownRequestError=c;exports.isPrismaTransactionClosedError=R;exports.prismaTransaction=y;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/prismaError.ts","../src/
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/errors/prismaError.ts","../src/errors/cockroachdbError.ts","../src/prismaTransaction.ts"],"sourcesContent":["import { isError } from '@lokalise/node-core'\nimport type { PrismaClientKnownRequestError } from '@prisma/client/runtime/library'\n\n/**\n * What is checked?\n * \t1. error is defined and not null\n * \t2. error is an `Error`\n * \t3. error contains the field code which is a string\n * \t4. code starts by `P` ([doc](https://www.prisma.io/docs/reference/api-reference/error-reference#error-codes))\n */\nexport const isPrismaClientKnownRequestError = (\n error: unknown,\n): error is PrismaClientKnownRequestError =>\n !!error &&\n isError(error) &&\n 'code' in error &&\n typeof error.code === 'string' &&\n error.code.startsWith('P')\n\nexport const isPrismaTransactionClosedError = (error: PrismaClientKnownRequestError): boolean =>\n error.code === PRISMA_TRANSACTION_ERROR && error.message.includes('Transaction already closed')\n\n/*\n * Prisma error code P2025 indicates that the operation failed because it depends on one or more\n * records that were required but not found\n */\nexport const PRISMA_NOT_FOUND_ERROR = 'P2025'\n\n/*\n * Prisma error code P2034 indicates a serialization error and that the transaction must be retried.\n * A different error code would indicate that an internal state error happened and that\n * the cluster itself is experiencing an issue which requires intervention\n */\nexport const PRISMA_SERIALIZATION_ERROR = 'P2034'\n\n/*\n * Prisma error code P2002 indicates that the operation failed because a unique constraint was\n * violated. This can happen if you try to create a record with a unique field that already exists\n */\nexport const PRISMA_UNIQUE_CONSTRAINT_ERROR = 'P2002'\n\n/*\n * Prisma error code P2028 indicates a transaction API error, essentially a placeholder for errors that do not fit into\n * a more specific category. You should look into the error message for more details\n */\nexport const PRISMA_TRANSACTION_ERROR = 'P2028'\n","import type { PrismaClientKnownRequestError } from '@prisma/client/runtime/library'\n\n/**\n * https://www.cockroachlabs.com/docs/stable/transaction-retry-error-reference#:~:text=To%20indicate%20that%20a%20transaction,the%20string%20%22restart%20transaction%22%20.\n *\n * All transaction retry errors use the SQLSTATE error code 40001\n */\nconst COCKROACHDB_RETRY_TRANSACTION_CODE = '40001'\n\n/**\n * Check if the error is a CockroachDB transaction retry error\n *\n * @param error\n */\nexport const isCockroachDBRetryTransaction = (error: PrismaClientKnownRequestError): boolean => {\n const meta = error.meta\n if (!meta) return false\n\n return meta.code === COCKROACHDB_RETRY_TRANSACTION_CODE\n}\n","import { setTimeout } from 'node:timers/promises'\n\nimport type { Either } from '@lokalise/node-core'\nimport { deepClone } from '@lokalise/node-core'\nimport type { Prisma, PrismaClient } from '@prisma/client'\nimport type * as runtime from '@prisma/client/runtime/library'\n\nimport { isCockroachDBRetryTransaction } from './errors/cockroachdbError'\nimport {\n PRISMA_SERIALIZATION_ERROR,\n isPrismaClientKnownRequestError,\n isPrismaTransactionClosedError,\n} from './errors/prismaError'\nimport type {\n DbDriver,\n PrismaTransactionBasicOptions,\n PrismaTransactionFn,\n PrismaTransactionOptions,\n PrismaTransactionReturnType,\n} from './types'\n\nconst DEFAULT_OPTIONS = {\n retriesAllowed: 2, // first try + 2 retries = 3 tries\n DbDriver: 'CockroachDb',\n baseRetryDelayMs: 100,\n maxRetryDelayMs: 30000, // 30s\n timeout: 5000, // 5s\n maxTimeout: 30000, // 30s\n} satisfies Partial<PrismaTransactionOptions>\n\n/**\n * Perform a Prisma DB transaction with automatic retries if needed.\n *\n * @template T | T extends Prisma.PrismaPromise<unknown>[]\n * @param {PrismaClient} prisma\n * @param {PrismaTransactionFn<T> | Prisma.PrismaPromise<unknown>[]} arg\t operation to perform into the transaction\n * @param {PrismaTransactionOptions | PrismaTransactionBasicOptions} options transaction configuration\n * @return {Promise<PrismaTransactionReturnType<T>>}\n */\nexport const prismaTransaction = (async <T, P extends PrismaClient>(\n prisma: P,\n arg: PrismaTransactionFn<T, P> | Prisma.PrismaPromise<unknown>[],\n options?: PrismaTransactionOptions | PrismaTransactionBasicOptions,\n): Promise<PrismaTransactionReturnType<T>> => {\n let optionsWithDefaults = { ...DEFAULT_OPTIONS, ...options }\n let result: PrismaTransactionReturnType<T> | undefined = undefined\n\n let retries = 0\n do {\n if (retries > 0) {\n await setTimeout(\n calculateRetryDelay(\n retries,\n optionsWithDefaults.baseRetryDelayMs,\n optionsWithDefaults.maxRetryDelayMs,\n ),\n )\n }\n\n result = await executeTransactionTry(prisma, arg, optionsWithDefaults)\n if (result.result) break\n\n const retryAllowed = isRetryAllowed(result, optionsWithDefaults.DbDriver)\n if (!retryAllowed) break\n\n if (retryAllowed === 'increase-timeout') {\n optionsWithDefaults = deepClone(optionsWithDefaults)\n optionsWithDefaults.timeout = Math.min(\n optionsWithDefaults.timeout * 2,\n optionsWithDefaults.maxTimeout,\n )\n }\n\n retries++\n } while (retries <= optionsWithDefaults.retriesAllowed)\n\n return result ?? { error: new Error('No transaction executed') }\n}) as {\n <T, P extends PrismaClient>(\n prisma: P,\n fn: PrismaTransactionFn<T, P>,\n options?: PrismaTransactionOptions,\n ): Promise<Either<unknown, T>>\n <T extends Prisma.PrismaPromise<unknown>[], P extends PrismaClient>(\n prisma: P,\n args: [...T],\n options?: PrismaTransactionBasicOptions,\n ): Promise<Either<unknown, runtime.Types.Utils.UnwrapTuple<T>>>\n}\n\nconst executeTransactionTry = async <T, P extends PrismaClient>(\n prisma: P,\n arg: PrismaTransactionFn<T, P> | Prisma.PrismaPromise<unknown>[],\n options?: PrismaTransactionOptions,\n): Promise<PrismaTransactionReturnType<T>> => {\n try {\n return {\n // @ts-ignore\n result: await prisma.$transaction<T>(arg, options),\n }\n } catch (error) {\n return { error }\n }\n}\n\nconst calculateRetryDelay = (\n retries: number,\n baseRetryDelayMs: number,\n maxDelayMs: number,\n): number => {\n // exponential backoff -> 2^(retry-1) * baseRetryDelayMs\n const expDelay = Math.pow(2, retries - 1) * baseRetryDelayMs\n return Math.min(expDelay, maxDelayMs)\n}\n\ntype isRetryAllowedResult = boolean | 'increase-timeout'\n\nconst isRetryAllowed = <T>(\n result: PrismaTransactionReturnType<T>,\n dbDriver: DbDriver,\n): isRetryAllowedResult => {\n if (isPrismaClientKnownRequestError(result.error)) {\n const error = result.error\n if (error.code === PRISMA_SERIALIZATION_ERROR) return true\n if (dbDriver === 'CockroachDb' && isCockroachDBRetryTransaction(error)) return true\n if (isPrismaTransactionClosedError(error)) return 'increase-timeout'\n }\n\n return false\n}\n"],"names":["isPrismaClientKnownRequestError","error","isError","isPrismaTransactionClosedError","PRISMA_TRANSACTION_ERROR","PRISMA_NOT_FOUND_ERROR","PRISMA_SERIALIZATION_ERROR","PRISMA_UNIQUE_CONSTRAINT_ERROR","COCKROACHDB_RETRY_TRANSACTION_CODE","isCockroachDBRetryTransaction","meta","DEFAULT_OPTIONS","prismaTransaction","prisma","arg","options","optionsWithDefaults","result","retries","setTimeout","calculateRetryDelay","executeTransactionTry","retryAllowed","isRetryAllowed","deepClone","baseRetryDelayMs","maxDelayMs","expDelay","dbDriver"],"mappings":"yJAUaA,EACXC,GAEA,CAAC,CAACA,GACFC,UAAQD,CAAK,GACb,SAAUA,GACV,OAAOA,EAAM,MAAS,UACtBA,EAAM,KAAK,WAAW,GAAG,EAEdE,EAAkCF,GAC7CA,EAAM,OAASG,GAA4BH,EAAM,QAAQ,SAAS,4BAA4B,EAMnFI,EAAyB,QAOzBC,EAA6B,QAM7BC,EAAiC,QAMjCH,EAA2B,QCtClCI,EAAqC,QAO9BC,EAAiCR,GAAkD,CAC9F,MAAMS,EAAOT,EAAM,KACf,OAACS,EAEEA,EAAK,OAASF,EAFH,EAGpB,ECEMG,EAAkB,CACtB,eAAgB,EAChB,SAAU,cACV,iBAAkB,IAClB,gBAAiB,IACjB,QAAS,IACT,WAAY,GACd,EAWaC,EAAqB,MAChCC,EACAC,EACAC,IAC4C,CAC5C,IAAIC,EAAsB,CAAE,GAAGL,EAAiB,GAAGI,CAAQ,EACvDE,EAEAC,EAAU,EACX,EAAA,CAYD,GAXIA,EAAU,GACN,MAAAC,EAAA,WACJC,EACEF,EACAF,EAAoB,iBACpBA,EAAoB,eACtB,CAAA,EAIJC,EAAS,MAAMI,EAAsBR,EAAQC,EAAKE,CAAmB,EACjEC,EAAO,OAAQ,MAEnB,MAAMK,EAAeC,EAAeN,EAAQD,EAAoB,QAAQ,EACxE,GAAI,CAACM,EAAc,MAEfA,IAAiB,qBACnBN,EAAsBQ,EAAAA,UAAUR,CAAmB,EACnDA,EAAoB,QAAU,KAAK,IACjCA,EAAoB,QAAU,EAC9BA,EAAoB,UAAA,GAIxBE,GAAA,OACOA,GAAWF,EAAoB,gBAExC,OAAOC,GAAU,CAAE,MAAO,IAAI,MAAM,yBAAyB,CAAE,CACjE,EAaMI,EAAwB,MAC5BR,EACAC,EACAC,IAC4C,CACxC,GAAA,CACK,MAAA,CAEL,OAAQ,MAAMF,EAAO,aAAgBC,EAAKC,CAAO,CAAA,QAE5Cd,EAAO,CACd,MAAO,CAAE,MAAAA,CAAM,CACjB,CACF,EAEMmB,EAAsB,CAC1BF,EACAO,EACAC,IACW,CAEX,MAAMC,EAAW,KAAK,IAAI,EAAGT,EAAU,CAAC,EAAIO,EACrC,OAAA,KAAK,IAAIE,EAAUD,CAAU,CACtC,EAIMH,EAAiB,CACrBN,EACAW,IACyB,CACrB,GAAA5B,EAAgCiB,EAAO,KAAK,EAAG,CACjD,MAAMhB,EAAQgB,EAAO,MAErB,GADIhB,EAAM,OAASK,GACfsB,IAAa,eAAiBnB,EAA8BR,CAAK,EAAU,MAAA,GAC3E,GAAAE,EAA+BF,CAAK,EAAU,MAAA,kBACpD,CAEO,MAAA,EACT"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
1
|
+
export type * from './types';
|
|
2
|
+
export * from './errors';
|
|
3
3
|
export { prismaTransaction } from './prismaTransaction';
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { PRISMA_NOT_FOUND_ERROR as o, PRISMA_SERIALIZATION_ERROR as I,
|
|
2
|
-
import {
|
|
3
|
-
import { prismaTransaction as m } from "./prismaTransaction.js";
|
|
1
|
+
import { PRISMA_NOT_FOUND_ERROR as o, PRISMA_SERIALIZATION_ERROR as I, PRISMA_TRANSACTION_ERROR as _, PRISMA_UNIQUE_CONSTRAINT_ERROR as s, isPrismaClientKnownRequestError as A, isPrismaTransactionClosedError as O } from "./errors/prismaError.js";
|
|
2
|
+
import { prismaTransaction as E } from "./prismaTransaction.js";
|
|
4
3
|
export {
|
|
5
|
-
O as DbDriverEnum,
|
|
6
4
|
o as PRISMA_NOT_FOUND_ERROR,
|
|
7
5
|
I as PRISMA_SERIALIZATION_ERROR,
|
|
8
|
-
_ as
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
_ as PRISMA_TRANSACTION_ERROR,
|
|
7
|
+
s as PRISMA_UNIQUE_CONSTRAINT_ERROR,
|
|
8
|
+
A as isPrismaClientKnownRequestError,
|
|
9
|
+
O as isPrismaTransactionClosedError,
|
|
10
|
+
E as prismaTransaction
|
|
11
11
|
};
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Either } from '@lokalise/node-core';
|
|
2
|
-
import {
|
|
2
|
+
import { Prisma, PrismaClient } from '@prisma/client';
|
|
3
3
|
import { PrismaTransactionBasicOptions, PrismaTransactionFn, PrismaTransactionOptions } from './types';
|
|
4
4
|
|
|
5
5
|
import type * as runtime from '@prisma/client/runtime/library';
|
|
@@ -13,6 +13,6 @@ import type * as runtime from '@prisma/client/runtime/library';
|
|
|
13
13
|
* @return {Promise<PrismaTransactionReturnType<T>>}
|
|
14
14
|
*/
|
|
15
15
|
export declare const prismaTransaction: {
|
|
16
|
-
<T, P extends PrismaClient
|
|
17
|
-
<
|
|
16
|
+
<T, P extends PrismaClient>(prisma: P, fn: PrismaTransactionFn<T, P>, options?: PrismaTransactionOptions): Promise<Either<unknown, T>>;
|
|
17
|
+
<T extends Prisma.PrismaPromise<unknown>[], P extends PrismaClient>(prisma: P, args: [...T], options?: PrismaTransactionBasicOptions): Promise<Either<unknown, runtime.Types.Utils.UnwrapTuple<T>>>;
|
|
18
18
|
};
|
|
@@ -1,45 +1,57 @@
|
|
|
1
|
-
import { setTimeout as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { setTimeout as n } from "node:timers/promises";
|
|
2
|
+
import { deepClone as c } from "@lokalise/node-core";
|
|
3
|
+
import { isCockroachDBRetryTransaction as l } from "./errors/cockroachdbError.js";
|
|
4
|
+
import { isPrismaClientKnownRequestError as m, PRISMA_SERIALIZATION_ERROR as u, isPrismaTransactionClosedError as y } from "./errors/prismaError.js";
|
|
5
|
+
const D = {
|
|
6
|
+
retriesAllowed: 2,
|
|
7
|
+
// first try + 2 retries = 3 tries
|
|
6
8
|
DbDriver: "CockroachDb",
|
|
7
9
|
baseRetryDelayMs: 100,
|
|
8
|
-
maxRetryDelayMs: 3e4
|
|
10
|
+
maxRetryDelayMs: 3e4,
|
|
9
11
|
// 30s
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
timeout: 5e3,
|
|
13
|
+
// 5s
|
|
14
|
+
maxTimeout: 3e4
|
|
15
|
+
// 30s
|
|
16
|
+
}, b = async (t, o, e) => {
|
|
17
|
+
let r = { ...D, ...e }, a, i = 0;
|
|
18
|
+
do {
|
|
19
|
+
if (i > 0 && await n(
|
|
20
|
+
R(
|
|
21
|
+
i,
|
|
22
|
+
r.baseRetryDelayMs,
|
|
23
|
+
r.maxRetryDelayMs
|
|
24
|
+
)
|
|
25
|
+
), a = await f(t, o, r), a.result) break;
|
|
26
|
+
const s = w(a, r.DbDriver);
|
|
27
|
+
if (!s) break;
|
|
28
|
+
s === "increase-timeout" && (r = c(r), r.timeout = Math.min(
|
|
29
|
+
r.timeout * 2,
|
|
30
|
+
r.maxTimeout
|
|
31
|
+
)), i++;
|
|
32
|
+
} while (i <= r.retriesAllowed);
|
|
33
|
+
return a ?? { error: new Error("No transaction executed") };
|
|
34
|
+
}, f = async (t, o, e) => {
|
|
23
35
|
try {
|
|
24
36
|
return {
|
|
25
37
|
// @ts-ignore
|
|
26
|
-
result: await
|
|
38
|
+
result: await t.$transaction(o, e)
|
|
27
39
|
};
|
|
28
|
-
} catch (
|
|
29
|
-
return { error:
|
|
40
|
+
} catch (r) {
|
|
41
|
+
return { error: r };
|
|
30
42
|
}
|
|
31
|
-
},
|
|
32
|
-
const
|
|
33
|
-
return Math.min(
|
|
34
|
-
},
|
|
35
|
-
if (
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
|
|
43
|
+
}, R = (t, o, e) => {
|
|
44
|
+
const r = Math.pow(2, t - 1) * o;
|
|
45
|
+
return Math.min(r, e);
|
|
46
|
+
}, w = (t, o) => {
|
|
47
|
+
if (m(t.error)) {
|
|
48
|
+
const e = t.error;
|
|
49
|
+
if (e.code === u || o === "CockroachDb" && l(e)) return !0;
|
|
50
|
+
if (y(e)) return "increase-timeout";
|
|
39
51
|
}
|
|
40
52
|
return !1;
|
|
41
53
|
};
|
|
42
54
|
export {
|
|
43
|
-
|
|
55
|
+
b as prismaTransaction
|
|
44
56
|
};
|
|
45
57
|
//# sourceMappingURL=prismaTransaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prismaTransaction.js","sources":["../src/prismaTransaction.ts"],"sourcesContent":["import { setTimeout } from 'node:timers/promises'\n\nimport type { Either } from '@lokalise/node-core'\nimport type {
|
|
1
|
+
{"version":3,"file":"prismaTransaction.js","sources":["../src/prismaTransaction.ts"],"sourcesContent":["import { setTimeout } from 'node:timers/promises'\n\nimport type { Either } from '@lokalise/node-core'\nimport { deepClone } from '@lokalise/node-core'\nimport type { Prisma, PrismaClient } from '@prisma/client'\nimport type * as runtime from '@prisma/client/runtime/library'\n\nimport { isCockroachDBRetryTransaction } from './errors/cockroachdbError'\nimport {\n PRISMA_SERIALIZATION_ERROR,\n isPrismaClientKnownRequestError,\n isPrismaTransactionClosedError,\n} from './errors/prismaError'\nimport type {\n DbDriver,\n PrismaTransactionBasicOptions,\n PrismaTransactionFn,\n PrismaTransactionOptions,\n PrismaTransactionReturnType,\n} from './types'\n\nconst DEFAULT_OPTIONS = {\n retriesAllowed: 2, // first try + 2 retries = 3 tries\n DbDriver: 'CockroachDb',\n baseRetryDelayMs: 100,\n maxRetryDelayMs: 30000, // 30s\n timeout: 5000, // 5s\n maxTimeout: 30000, // 30s\n} satisfies Partial<PrismaTransactionOptions>\n\n/**\n * Perform a Prisma DB transaction with automatic retries if needed.\n *\n * @template T | T extends Prisma.PrismaPromise<unknown>[]\n * @param {PrismaClient} prisma\n * @param {PrismaTransactionFn<T> | Prisma.PrismaPromise<unknown>[]} arg\t operation to perform into the transaction\n * @param {PrismaTransactionOptions | PrismaTransactionBasicOptions} options transaction configuration\n * @return {Promise<PrismaTransactionReturnType<T>>}\n */\nexport const prismaTransaction = (async <T, P extends PrismaClient>(\n prisma: P,\n arg: PrismaTransactionFn<T, P> | Prisma.PrismaPromise<unknown>[],\n options?: PrismaTransactionOptions | PrismaTransactionBasicOptions,\n): Promise<PrismaTransactionReturnType<T>> => {\n let optionsWithDefaults = { ...DEFAULT_OPTIONS, ...options }\n let result: PrismaTransactionReturnType<T> | undefined = undefined\n\n let retries = 0\n do {\n if (retries > 0) {\n await setTimeout(\n calculateRetryDelay(\n retries,\n optionsWithDefaults.baseRetryDelayMs,\n optionsWithDefaults.maxRetryDelayMs,\n ),\n )\n }\n\n result = await executeTransactionTry(prisma, arg, optionsWithDefaults)\n if (result.result) break\n\n const retryAllowed = isRetryAllowed(result, optionsWithDefaults.DbDriver)\n if (!retryAllowed) break\n\n if (retryAllowed === 'increase-timeout') {\n optionsWithDefaults = deepClone(optionsWithDefaults)\n optionsWithDefaults.timeout = Math.min(\n optionsWithDefaults.timeout * 2,\n optionsWithDefaults.maxTimeout,\n )\n }\n\n retries++\n } while (retries <= optionsWithDefaults.retriesAllowed)\n\n return result ?? { error: new Error('No transaction executed') }\n}) as {\n <T, P extends PrismaClient>(\n prisma: P,\n fn: PrismaTransactionFn<T, P>,\n options?: PrismaTransactionOptions,\n ): Promise<Either<unknown, T>>\n <T extends Prisma.PrismaPromise<unknown>[], P extends PrismaClient>(\n prisma: P,\n args: [...T],\n options?: PrismaTransactionBasicOptions,\n ): Promise<Either<unknown, runtime.Types.Utils.UnwrapTuple<T>>>\n}\n\nconst executeTransactionTry = async <T, P extends PrismaClient>(\n prisma: P,\n arg: PrismaTransactionFn<T, P> | Prisma.PrismaPromise<unknown>[],\n options?: PrismaTransactionOptions,\n): Promise<PrismaTransactionReturnType<T>> => {\n try {\n return {\n // @ts-ignore\n result: await prisma.$transaction<T>(arg, options),\n }\n } catch (error) {\n return { error }\n }\n}\n\nconst calculateRetryDelay = (\n retries: number,\n baseRetryDelayMs: number,\n maxDelayMs: number,\n): number => {\n // exponential backoff -> 2^(retry-1) * baseRetryDelayMs\n const expDelay = Math.pow(2, retries - 1) * baseRetryDelayMs\n return Math.min(expDelay, maxDelayMs)\n}\n\ntype isRetryAllowedResult = boolean | 'increase-timeout'\n\nconst isRetryAllowed = <T>(\n result: PrismaTransactionReturnType<T>,\n dbDriver: DbDriver,\n): isRetryAllowedResult => {\n if (isPrismaClientKnownRequestError(result.error)) {\n const error = result.error\n if (error.code === PRISMA_SERIALIZATION_ERROR) return true\n if (dbDriver === 'CockroachDb' && isCockroachDBRetryTransaction(error)) return true\n if (isPrismaTransactionClosedError(error)) return 'increase-timeout'\n }\n\n return false\n}\n"],"names":["DEFAULT_OPTIONS","prismaTransaction","prisma","arg","options","optionsWithDefaults","result","retries","setTimeout","calculateRetryDelay","executeTransactionTry","retryAllowed","isRetryAllowed","deepClone","error","baseRetryDelayMs","maxDelayMs","expDelay","dbDriver","isPrismaClientKnownRequestError","PRISMA_SERIALIZATION_ERROR","isCockroachDBRetryTransaction","isPrismaTransactionClosedError"],"mappings":";;;;AAqBA,MAAMA,IAAkB;AAAA,EACtB,gBAAgB;AAAA;AAAA,EAChB,UAAU;AAAA,EACV,kBAAkB;AAAA,EAClB,iBAAiB;AAAA;AAAA,EACjB,SAAS;AAAA;AAAA,EACT,YAAY;AAAA;AACd,GAWaC,IAAqB,OAChCC,GACAC,GACAC,MAC4C;AAC5C,MAAIC,IAAsB,EAAE,GAAGL,GAAiB,GAAGI,EAAQ,GACvDE,GAEAC,IAAU;AACX,KAAA;AAYD,QAXIA,IAAU,KACN,MAAAC;AAAA,MACJC;AAAA,QACEF;AAAA,QACAF,EAAoB;AAAA,QACpBA,EAAoB;AAAA,MACtB;AAAA,IAAA,GAIJC,IAAS,MAAMI,EAAsBR,GAAQC,GAAKE,CAAmB,GACjEC,EAAO,OAAQ;AAEnB,UAAMK,IAAeC,EAAeN,GAAQD,EAAoB,QAAQ;AACxE,QAAI,CAACM,EAAc;AAEnB,IAAIA,MAAiB,uBACnBN,IAAsBQ,EAAUR,CAAmB,GACnDA,EAAoB,UAAU,KAAK;AAAA,MACjCA,EAAoB,UAAU;AAAA,MAC9BA,EAAoB;AAAA,IAAA,IAIxBE;AAAA,EAAA,SACOA,KAAWF,EAAoB;AAExC,SAAOC,KAAU,EAAE,OAAO,IAAI,MAAM,yBAAyB,EAAE;AACjE,GAaMI,IAAwB,OAC5BR,GACAC,GACAC,MAC4C;AACxC,MAAA;AACK,WAAA;AAAA;AAAA,MAEL,QAAQ,MAAMF,EAAO,aAAgBC,GAAKC,CAAO;AAAA,IAAA;AAAA,WAE5CU,GAAO;AACd,WAAO,EAAE,OAAAA,EAAM;AAAA,EACjB;AACF,GAEML,IAAsB,CAC1BF,GACAQ,GACAC,MACW;AAEX,QAAMC,IAAW,KAAK,IAAI,GAAGV,IAAU,CAAC,IAAIQ;AACrC,SAAA,KAAK,IAAIE,GAAUD,CAAU;AACtC,GAIMJ,IAAiB,CACrBN,GACAY,MACyB;AACrB,MAAAC,EAAgCb,EAAO,KAAK,GAAG;AACjD,UAAMQ,IAAQR,EAAO;AAErB,QADIQ,EAAM,SAASM,KACfF,MAAa,iBAAiBG,EAA8BP,CAAK,EAAU,QAAA;AAC3E,QAAAQ,EAA+BR,CAAK,EAAU,QAAA;AAAA,EACpD;AAEO,SAAA;AACT;"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { Either } from '@lokalise/node-core';
|
|
2
|
+
import { Prisma } from '@prisma/client';
|
|
3
|
+
import { CockroachDbIsolationLevel } from './isolation_level/isolationLevel';
|
|
4
|
+
|
|
1
5
|
import type * as runtime from '@prisma/client/runtime/library';
|
|
2
6
|
type ObjectValues<T> = T[keyof T];
|
|
3
7
|
export declare const DbDriverEnum: {
|
|
@@ -9,11 +13,13 @@ export type PrismaTransactionOptions = {
|
|
|
9
13
|
retriesAllowed?: number;
|
|
10
14
|
baseRetryDelayMs?: number;
|
|
11
15
|
maxRetryDelayMs?: number;
|
|
16
|
+
maxTimeout?: number;
|
|
12
17
|
maxWait?: number;
|
|
13
18
|
timeout?: number;
|
|
14
|
-
isolationLevel?:
|
|
19
|
+
isolationLevel?: CockroachDbIsolationLevel;
|
|
15
20
|
};
|
|
16
|
-
export type PrismaTransactionBasicOptions = Omit<PrismaTransactionOptions, 'maxWait' | 'timeout'>;
|
|
21
|
+
export type PrismaTransactionBasicOptions = Omit<PrismaTransactionOptions, 'maxWait' | 'timeout' | 'maxTimeout'>;
|
|
17
22
|
export type PrismaTransactionClient<P> = Omit<P, runtime.ITXClientDenyList>;
|
|
18
23
|
export type PrismaTransactionFn<T, P> = (prisma: PrismaTransactionClient<P>) => Promise<T>;
|
|
24
|
+
export type PrismaTransactionReturnType<T> = Either<unknown, T | runtime.Types.Utils.UnwrapTuple<Prisma.PrismaPromise<unknown>[]>>;
|
|
19
25
|
export {};
|
package/package.json
CHANGED
|
@@ -1,67 +1,65 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
"prettier": "@lokalise/prettier-config"
|
|
2
|
+
"name": "@lokalise/prisma-utils",
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"README.md",
|
|
9
|
+
"LICENSE.md"
|
|
10
|
+
],
|
|
11
|
+
"main": "./dist/index.cjs",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"homepage": "https://github.com/lokalise/shared-ts-libs",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git://github.com/lokalise/shared-ts-libs.git"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"require": "./dist/index.cjs",
|
|
23
|
+
"import": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "rimraf dist && npm run db:update-client && vite build",
|
|
28
|
+
"dev": "vite watch",
|
|
29
|
+
"clean": "rimraf dist",
|
|
30
|
+
"lint": "biome check . && tsc --project tsconfig.lint.json --noEmit",
|
|
31
|
+
"lint:fix": "biome check --write",
|
|
32
|
+
"docker:start:ci": "docker compose up -d cockroachdb",
|
|
33
|
+
"db:migration:dev": "dotenv -c test -- dotenv prisma migrate dev",
|
|
34
|
+
"db:update-client": "dotenv -c test prisma generate",
|
|
35
|
+
"db:wait": "while ! echo \"SELECT 1;\" | dotenv -c test -- prisma db execute --stdin; do sleep 1; done",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"test:migrate": "cross-env NODE_ENV=test dotenv -c test -- prisma migrate reset --force",
|
|
38
|
+
"pretest:ci": "npm run docker:start:ci && npm run db:wait && npm run test:migrate",
|
|
39
|
+
"test:ci": "npm run test -- --coverage",
|
|
40
|
+
"test:ci:teardown": "docker compose down",
|
|
41
|
+
"prepublishOnly": "npm run build",
|
|
42
|
+
"package-version": "echo $npm_package_version"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@lokalise/node-core": "^11.2.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@prisma/client": "^5.16.1",
|
|
49
|
+
"prisma": "^5.16.1"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@biomejs/biome": "^1.8.3",
|
|
53
|
+
"@lokalise/biome-config": "*",
|
|
54
|
+
"@lokalise/package-vite-config": "*",
|
|
55
|
+
"@prisma/client": "^5.14.0",
|
|
56
|
+
"@vitest/coverage-v8": "^1.6.0",
|
|
57
|
+
"cross-env": "^7.0.3",
|
|
58
|
+
"dotenv-cli": "^7.4.1",
|
|
59
|
+
"prisma": "^5.14.0",
|
|
60
|
+
"rimraf": "^5.0.7",
|
|
61
|
+
"typescript": "5.5.3",
|
|
62
|
+
"vite": "^5.3.3",
|
|
63
|
+
"vitest": "^1.6.0"
|
|
64
|
+
}
|
|
67
65
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cockroachdbError.js","sources":["../src/cockroachdbError.ts"],"sourcesContent":["import type { PrismaClientKnownRequestError } from '@prisma/client/runtime/library'\n\n/**\n * https://www.cockroachlabs.com/docs/stable/transaction-retry-error-reference#:~:text=To%20indicate%20that%20a%20transaction,the%20string%20%22restart%20transaction%22%20.\n *\n * All transaction retry errors use the SQLSTATE error code 40001\n */\nconst COCKROACHDB_RETRY_TRANSACTION_CODE = '40001'\n\n/**\n * Check if the error is a CockroachDB transaction retry error\n *\n * @param error\n */\nexport const isCockroachDBRetryTransaction = (error: PrismaClientKnownRequestError): boolean => {\n\tconst meta = error.meta\n\tif (!meta) return false\n\n\treturn meta.code === COCKROACHDB_RETRY_TRANSACTION_CODE\n}\n"],"names":["COCKROACHDB_RETRY_TRANSACTION_CODE","isCockroachDBRetryTransaction","error","meta"],"mappings":"AAOA,MAAMA,IAAqC,SAO9BC,IAAgC,CAACC,MAAkD;AAC/F,QAAMC,IAAOD,EAAM;AACnB,SAAKC,IAEEA,EAAK,SAASH,IAFH;AAGnB;"}
|
package/dist/prismaError.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { isError as t } from "@lokalise/node-core";
|
|
2
|
-
const o = (R) => !!R && t(R) && "code" in R && typeof R.code == "string" && R.code.startsWith("P"), n = "P2025", i = "P2034", I = "P2002";
|
|
3
|
-
export {
|
|
4
|
-
n as PRISMA_NOT_FOUND_ERROR,
|
|
5
|
-
i as PRISMA_SERIALIZATION_ERROR,
|
|
6
|
-
I as PRISMA_UNIQUE_CONSTRAINT_ERROR,
|
|
7
|
-
o as isPrismaClientKnownRequestError
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=prismaError.js.map
|
package/dist/prismaError.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prismaError.js","sources":["../src/prismaError.ts"],"sourcesContent":["import { isError } from '@lokalise/node-core'\nimport type { PrismaClientKnownRequestError } from '@prisma/client/runtime/library'\n\n/**\n * What is checked?\n * \t1. error is defined and not null\n * \t2. error is an `Error`\n * \t3. error contains the field code which is a string\n * \t4. code starts by `P` ([doc](https://www.prisma.io/docs/reference/api-reference/error-reference#error-codes))\n */\nexport const isPrismaClientKnownRequestError = (\n\terror: unknown,\n): error is PrismaClientKnownRequestError =>\n\t!!error &&\n\tisError(error) &&\n\t'code' in error &&\n\ttypeof error.code === 'string' &&\n\terror.code.startsWith('P')\n\n/*\n * Prisma error code P2025 indicates that the operation failed because it depends on one or more\n * records that were required but not found\n */\nexport const PRISMA_NOT_FOUND_ERROR = 'P2025'\n\n/*\n * Prisma error code P2034 indicates a serialization error and that the transaction must be retried.\n * A different error code would indicate that an internal state error happened and that\n * the cluster itself is experiencing an issue which requires intervention\n */\nexport const PRISMA_SERIALIZATION_ERROR = 'P2034'\n\n/*\n * Prisma error code P2002 indicates that the operation failed because a unique constraint was\n * violated. This can happen if you try to create a record with a unique field that already exists\n */\nexport const PRISMA_UNIQUE_CONSTRAINT_ERROR = 'P2002'\n"],"names":["isPrismaClientKnownRequestError","error","isError","PRISMA_NOT_FOUND_ERROR","PRISMA_SERIALIZATION_ERROR","PRISMA_UNIQUE_CONSTRAINT_ERROR"],"mappings":";AAUO,MAAMA,IAAkC,CAC9CC,MAEA,CAAC,CAACA,KACFC,EAAQD,CAAK,KACb,UAAUA,KACV,OAAOA,EAAM,QAAS,YACtBA,EAAM,KAAK,WAAW,GAAG,GAMbE,IAAyB,SAOzBC,IAA6B,SAM7BC,IAAiC;"}
|
package/dist/types.js
DELETED
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type * as runtime from '@prisma/client/runtime/library'\n\ntype ObjectValues<T> = T[keyof T]\n\nexport const DbDriverEnum = {\n\tCOCKROACHDB: 'CockroachDb',\n} as const\nexport type DbDriver = ObjectValues<typeof DbDriverEnum>\n\nexport type PrismaTransactionOptions = {\n\t// Prisma utils library custom options\n\tDbDriver?: DbDriver\n\tretriesAllowed?: number\n\tbaseRetryDelayMs?: number\n\tmaxRetryDelayMs?: number\n\n\t// Prisma $transaction options\n\tmaxWait?: number\n\ttimeout?: number\n\tisolationLevel?: string\n}\n\n// Prisma $transaction with array does not support maxWait and timeout options\nexport type PrismaTransactionBasicOptions = Omit<PrismaTransactionOptions, 'maxWait' | 'timeout'>\n\nexport type PrismaTransactionClient<P> = Omit<P, runtime.ITXClientDenyList>\n\nexport type PrismaTransactionFn<T, P> = (prisma: PrismaTransactionClient<P>) => Promise<T>\n"],"names":["DbDriverEnum"],"mappings":"AAIO,MAAMA,IAAe;AAAA,EAC3B,aAAa;AACd;"}
|
|
File without changes
|
|
File without changes
|