@lokalise/prisma-utils 1.0.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/LICENSE.md +13 -0
- package/README.md +16 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/prismaError.d.ts +13 -0
- package/dist/prismaError.js +9 -0
- package/dist/prismaError.js.map +1 -0
- package/dist/prismaTransaction.d.ts +27 -0
- package/dist/prismaTransaction.js +20 -0
- package/dist/prismaTransaction.js.map +1 -0
- package/package.json +66 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2024 Lokalise, Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Prisma utils
|
|
2
|
+
|
|
3
|
+
This package provides reusable helpers for Prisma query builder.
|
|
4
|
+
|
|
5
|
+
# Usage
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { prismaTransaction } from '@lokalise/prisma-utils'
|
|
9
|
+
|
|
10
|
+
const result: Either<unknown, [Item, Segment]> = await prismaTransaction(prisma, [
|
|
11
|
+
prisma.item.create({ data: TEST_ITEM_1 }),
|
|
12
|
+
prisma.segment.create({ data: TEST_SEGMENT_1 }),
|
|
13
|
+
])
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
This implementation will retry the transaction on P2034 error, which satisfies Prisma recommendations for distributed databases such as CockroachDB.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@lokalise/node-core"),o=r=>!!r&&i.isError(r)&&"code"in r&&typeof r.code=="string"&&r.code.startsWith("P"),a="P2025",R="P2034",c="P2002",I=async(r,n,t={retriesAllowed:3})=>{let e,s=0;for(;s<t.retriesAllowed&&(e=await _(r,n,t),!(e.result||!o(e.error)||e.error.code!==R));)s++;return e??{error:new Error("No transaction retry executed")}},_=async(r,n,t)=>{try{return{result:await r.$transaction(n,t)}}catch(e){return{error:e}}};exports.PRISMA_NOT_FOUND_ERROR=a;exports.PRISMA_SERIALIZATION_ERROR=R;exports.PRISMA_UNIQUE_CONSTRAINT_ERROR=c;exports.isPrismaClientKnownRequestError=o;exports.prismaTransaction=I;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/prismaError.ts","../src/prismaTransaction.ts"],"sourcesContent":["import { PrismaClientKnownRequestError } from '@prisma/client/runtime/library'\nimport { isError } from '@lokalise/node-core'\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","import type { Either } from '@lokalise/node-core'\n\nimport type { PrismaClient, Prisma } from '@prisma/client'\nimport type * as runtime from '@prisma/client/runtime/library'\n\nimport { isPrismaClientKnownRequestError, PRISMA_SERIALIZATION_ERROR } from './prismaError'\nimport type { Types } from '@prisma/client/runtime/library'\n\nexport type PrismaTransactionOptions = {\n\tretriesAllowed: number\n\tmaxWait?: number\n\ttimeout?: number\n\tisolationLevel?: string\n}\n\nexport type PrismaTransactionBasicOptions = Pick<\n\tPrismaTransactionOptions,\n\t'retriesAllowed' | 'isolationLevel'\n>\n\nexport type PrismaTransactionClient = Omit<PrismaClient, runtime.ITXClientDenyList>\n\nexport type PrismaTransactionFn<T> = (prisma: PrismaTransactionClient) => Promise<T>\n\ntype PrismaTransactionReturnType<T> = Either<\n\tunknown,\n\tT | Types.Utils.UnwrapTuple<Prisma.PrismaPromise<unknown>[]>\n>\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\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>(\n\tprisma: PrismaClient,\n\targ: PrismaTransactionFn<T>,\n\toptions: PrismaTransactionOptions = { retriesAllowed: 3 },\n): Promise<PrismaTransactionReturnType<T>> => {\n\tlet result: PrismaTransactionReturnType<T> | undefined = undefined\n\n\tlet retries = 0\n\twhile (retries < options.retriesAllowed) {\n\t\tresult = await executeTransactionTry(prisma, arg, options)\n\n\t\tif (\n\t\t\tresult.result ||\n\t\t\t!isPrismaClientKnownRequestError(result.error) ||\n\t\t\tresult.error.code !== PRISMA_SERIALIZATION_ERROR\n\t\t) {\n\t\t\tbreak\n\t\t}\n\n\t\tretries++\n\t}\n\n\treturn result ?? { error: new Error('No transaction retry executed') }\n}) as {\n\t<T>(\n\t\tprisma: PrismaClient,\n\t\tfn: PrismaTransactionFn<T>,\n\t\toptions?: PrismaTransactionOptions,\n\t): Promise<Either<unknown, T>>\n\t<T extends Prisma.PrismaPromise<unknown>[]>(\n\t\tprisma: PrismaClient,\n\t\targs: [...T],\n\t\toptions?: PrismaTransactionBasicOptions,\n\t): Promise<Either<unknown, runtime.Types.Utils.UnwrapTuple<T>>>\n}\n\nconst executeTransactionTry = async <T>(\n\tprisma: PrismaClient,\n\targ: PrismaTransactionFn<T>,\n\toptions: PrismaTransactionOptions,\n): Promise<PrismaTransactionReturnType<T>> => {\n\ttry {\n\t\treturn {\n\t\t\t// @ts-ignore\n\t\t\tresult: await prisma.$transaction<T>(arg, options),\n\t\t}\n\t} catch (error) {\n\t\treturn { error }\n\t}\n}\n"],"names":["isPrismaClientKnownRequestError","error","isError","PRISMA_NOT_FOUND_ERROR","PRISMA_SERIALIZATION_ERROR","PRISMA_UNIQUE_CONSTRAINT_ERROR","prismaTransaction","prisma","arg","options","result","retries","executeTransactionTry"],"mappings":"uHAUaA,EACZC,GAEA,CAAC,CAACA,GACFC,UAAQD,CAAK,GACb,SAAUA,GACV,OAAOA,EAAM,MAAS,UACtBA,EAAM,KAAK,WAAW,GAAG,EAMbE,EAAyB,QAOzBC,EAA6B,QAM7BC,EAAiC,QCEjCC,EAAqB,MACjCC,EACAC,EACAC,EAAoC,CAAE,eAAgB,KACT,CAC7C,IAAIC,EAEAC,EAAU,EACP,KAAAA,EAAUF,EAAQ,iBACxBC,EAAS,MAAME,EAAsBL,EAAQC,EAAKC,CAAO,EAGxD,EAAAC,EAAO,QACP,CAACV,EAAgCU,EAAO,KAAK,GAC7CA,EAAO,MAAM,OAASN,KAKvBO,IAGD,OAAOD,GAAU,CAAE,MAAO,IAAI,MAAM,+BAA+B,CAAE,CACtE,EAaME,EAAwB,MAC7BL,EACAC,EACAC,IAC6C,CACzC,GAAA,CACI,MAAA,CAEN,OAAQ,MAAMF,EAAO,aAAgBC,EAAKC,CAAO,CAAA,QAE1CR,EAAO,CACf,MAAO,CAAE,MAAAA,CAAM,CAChB,CACD"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PRISMA_NOT_FOUND_ERROR as I, PRISMA_SERIALIZATION_ERROR as _, PRISMA_UNIQUE_CONSTRAINT_ERROR as o, isPrismaClientKnownRequestError as O } from "./prismaError.js";
|
|
2
|
+
import { prismaTransaction as E } from "./prismaTransaction.js";
|
|
3
|
+
export {
|
|
4
|
+
I as PRISMA_NOT_FOUND_ERROR,
|
|
5
|
+
_ as PRISMA_SERIALIZATION_ERROR,
|
|
6
|
+
o as PRISMA_UNIQUE_CONSTRAINT_ERROR,
|
|
7
|
+
O as isPrismaClientKnownRequestError,
|
|
8
|
+
E as prismaTransaction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PrismaClientKnownRequestError } from '@prisma/client/runtime/library';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What is checked?
|
|
5
|
+
* 1. error is defined and not null
|
|
6
|
+
* 2. error is an `Error`
|
|
7
|
+
* 3. error contains the field code which is a string
|
|
8
|
+
* 4. code starts by `P` ([doc](https://www.prisma.io/docs/reference/api-reference/error-reference#error-codes))
|
|
9
|
+
*/
|
|
10
|
+
export declare const isPrismaClientKnownRequestError: (error: unknown) => error is PrismaClientKnownRequestError;
|
|
11
|
+
export declare const PRISMA_NOT_FOUND_ERROR = "P2025";
|
|
12
|
+
export declare const PRISMA_SERIALIZATION_ERROR = "P2034";
|
|
13
|
+
export declare const PRISMA_UNIQUE_CONSTRAINT_ERROR = "P2002";
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prismaError.js","sources":["../src/prismaError.ts"],"sourcesContent":["import { PrismaClientKnownRequestError } from '@prisma/client/runtime/library'\nimport { isError } from '@lokalise/node-core'\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;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Types } from '@prisma/client/runtime/library';
|
|
2
|
+
import { PrismaClient, Prisma } from '@prisma/client';
|
|
3
|
+
import { Either } from '@lokalise/node-core';
|
|
4
|
+
|
|
5
|
+
import type * as runtime from '@prisma/client/runtime/library';
|
|
6
|
+
export type PrismaTransactionOptions = {
|
|
7
|
+
retriesAllowed: number;
|
|
8
|
+
maxWait?: number;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
isolationLevel?: string;
|
|
11
|
+
};
|
|
12
|
+
export type PrismaTransactionBasicOptions = Pick<PrismaTransactionOptions, 'retriesAllowed' | 'isolationLevel'>;
|
|
13
|
+
export type PrismaTransactionClient = Omit<PrismaClient, runtime.ITXClientDenyList>;
|
|
14
|
+
export type PrismaTransactionFn<T> = (prisma: PrismaTransactionClient) => Promise<T>;
|
|
15
|
+
/**
|
|
16
|
+
* Perform a Prisma DB transaction with automatic retries if needed.
|
|
17
|
+
*
|
|
18
|
+
* @template T | T extends Prisma.PrismaPromise<unknown>[]
|
|
19
|
+
* @param {PrismaClient} prisma
|
|
20
|
+
* @param {PrismaTransactionFn<T> | Prisma.PrismaPromise<unknown>[]} arg operation to perform into the transaction
|
|
21
|
+
* @param {PrismaTransactionOptions | PrismaTransactionBasicOptions} options transaction configuration
|
|
22
|
+
* @return {Promise<PrismaTransactionReturnType<T>>}
|
|
23
|
+
*/
|
|
24
|
+
export declare const prismaTransaction: {
|
|
25
|
+
<T>(prisma: PrismaClient, fn: PrismaTransactionFn<T>, options?: PrismaTransactionOptions): Promise<Either<unknown, T>>;
|
|
26
|
+
<T_1 extends Prisma.PrismaPromise<unknown>[]>(prisma: PrismaClient, args: [...T_1], options?: PrismaTransactionBasicOptions): Promise<Either<unknown, runtime.UnwrapTuple<T_1>>>;
|
|
27
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isPrismaClientKnownRequestError as n, PRISMA_SERIALIZATION_ERROR as s } from "./prismaError.js";
|
|
2
|
+
const l = async (t, o, e = { retriesAllowed: 3 }) => {
|
|
3
|
+
let r, a = 0;
|
|
4
|
+
for (; a < e.retriesAllowed && (r = await i(t, o, e), !(r.result || !n(r.error) || r.error.code !== s)); )
|
|
5
|
+
a++;
|
|
6
|
+
return r ?? { error: new Error("No transaction retry executed") };
|
|
7
|
+
}, i = async (t, o, e) => {
|
|
8
|
+
try {
|
|
9
|
+
return {
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
result: await t.$transaction(o, e)
|
|
12
|
+
};
|
|
13
|
+
} catch (r) {
|
|
14
|
+
return { error: r };
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
l as prismaTransaction
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=prismaTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prismaTransaction.js","sources":["../src/prismaTransaction.ts"],"sourcesContent":["import type { Either } from '@lokalise/node-core'\n\nimport type { PrismaClient, Prisma } from '@prisma/client'\nimport type * as runtime from '@prisma/client/runtime/library'\n\nimport { isPrismaClientKnownRequestError, PRISMA_SERIALIZATION_ERROR } from './prismaError'\nimport type { Types } from '@prisma/client/runtime/library'\n\nexport type PrismaTransactionOptions = {\n\tretriesAllowed: number\n\tmaxWait?: number\n\ttimeout?: number\n\tisolationLevel?: string\n}\n\nexport type PrismaTransactionBasicOptions = Pick<\n\tPrismaTransactionOptions,\n\t'retriesAllowed' | 'isolationLevel'\n>\n\nexport type PrismaTransactionClient = Omit<PrismaClient, runtime.ITXClientDenyList>\n\nexport type PrismaTransactionFn<T> = (prisma: PrismaTransactionClient) => Promise<T>\n\ntype PrismaTransactionReturnType<T> = Either<\n\tunknown,\n\tT | Types.Utils.UnwrapTuple<Prisma.PrismaPromise<unknown>[]>\n>\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\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>(\n\tprisma: PrismaClient,\n\targ: PrismaTransactionFn<T>,\n\toptions: PrismaTransactionOptions = { retriesAllowed: 3 },\n): Promise<PrismaTransactionReturnType<T>> => {\n\tlet result: PrismaTransactionReturnType<T> | undefined = undefined\n\n\tlet retries = 0\n\twhile (retries < options.retriesAllowed) {\n\t\tresult = await executeTransactionTry(prisma, arg, options)\n\n\t\tif (\n\t\t\tresult.result ||\n\t\t\t!isPrismaClientKnownRequestError(result.error) ||\n\t\t\tresult.error.code !== PRISMA_SERIALIZATION_ERROR\n\t\t) {\n\t\t\tbreak\n\t\t}\n\n\t\tretries++\n\t}\n\n\treturn result ?? { error: new Error('No transaction retry executed') }\n}) as {\n\t<T>(\n\t\tprisma: PrismaClient,\n\t\tfn: PrismaTransactionFn<T>,\n\t\toptions?: PrismaTransactionOptions,\n\t): Promise<Either<unknown, T>>\n\t<T extends Prisma.PrismaPromise<unknown>[]>(\n\t\tprisma: PrismaClient,\n\t\targs: [...T],\n\t\toptions?: PrismaTransactionBasicOptions,\n\t): Promise<Either<unknown, runtime.Types.Utils.UnwrapTuple<T>>>\n}\n\nconst executeTransactionTry = async <T>(\n\tprisma: PrismaClient,\n\targ: PrismaTransactionFn<T>,\n\toptions: PrismaTransactionOptions,\n): Promise<PrismaTransactionReturnType<T>> => {\n\ttry {\n\t\treturn {\n\t\t\t// @ts-ignore\n\t\t\tresult: await prisma.$transaction<T>(arg, options),\n\t\t}\n\t} catch (error) {\n\t\treturn { error }\n\t}\n}\n"],"names":["prismaTransaction","prisma","arg","options","result","retries","executeTransactionTry","isPrismaClientKnownRequestError","PRISMA_SERIALIZATION_ERROR","error"],"mappings":";AAsCa,MAAAA,IAAqB,OACjCC,GACAC,GACAC,IAAoC,EAAE,gBAAgB,QACT;AAC7C,MAAIC,GAEAC,IAAU;AACP,SAAAA,IAAUF,EAAQ,mBACxBC,IAAS,MAAME,EAAsBL,GAAQC,GAAKC,CAAO,GAGxD,EAAAC,EAAO,UACP,CAACG,EAAgCH,EAAO,KAAK,KAC7CA,EAAO,MAAM,SAASI;AAKvB,IAAAH;AAGD,SAAOD,KAAU,EAAE,OAAO,IAAI,MAAM,+BAA+B,EAAE;AACtE,GAaME,IAAwB,OAC7BL,GACAC,GACAC,MAC6C;AACzC,MAAA;AACI,WAAA;AAAA;AAAA,MAEN,QAAQ,MAAMF,EAAO,aAAgBC,GAAKC,CAAO;AAAA,IAAA;AAAA,WAE1CM,GAAO;AACf,WAAO,EAAE,OAAAA,EAAM;AAAA,EAChB;AACD;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lokalise/prisma-utils",
|
|
3
|
+
"version": "1.0.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 .eslintcache",
|
|
30
|
+
"lint": "eslint --cache --max-warnings=0 && prettier --check --log-level warn src \\\"**/*.{json,md}\\\" && tsc --noEmit",
|
|
31
|
+
"lint:fix": "eslint --fix && prettier --write src \\\"**/*.{json,md}\\\"",
|
|
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
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@lokalise/node-core": "^9.16.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"prisma": "^5.12.1",
|
|
48
|
+
"@prisma/client": "^5.12.1"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@prisma/client": "^5.13.0",
|
|
52
|
+
"@lokalise/eslint-config": "*",
|
|
53
|
+
"@lokalise/prettier-config": "*",
|
|
54
|
+
"@lokalise/package-vite-config": "*",
|
|
55
|
+
"@vitest/coverage-v8": "^1.5.3",
|
|
56
|
+
"cross-env": "^7.0.3",
|
|
57
|
+
"dotenv-cli": "^7.4.1",
|
|
58
|
+
"prisma": "^5.13.0",
|
|
59
|
+
"prettier": "^3.2.5",
|
|
60
|
+
"rimraf": "^5.0.1",
|
|
61
|
+
"typescript": "5.4.5",
|
|
62
|
+
"vite": "^5.2.10",
|
|
63
|
+
"vitest": "^1.5.3"
|
|
64
|
+
},
|
|
65
|
+
"prettier": "@lokalise/prettier-config"
|
|
66
|
+
}
|