@lokalise/prisma-utils 3.2.2 → 4.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/dist/errors/cockroachdbError.js +2 -5
- package/dist/errors/cockroachdbError.js.map +1 -0
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +2 -4
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/prismaError.js +10 -14
- package/dist/errors/prismaError.js.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -11
- package/dist/index.js.map +1 -0
- package/dist/isolation_level/isolationLevel.js +2 -2
- package/dist/isolation_level/isolationLevel.js.map +1 -0
- package/dist/plugins/CollectionScheduler.js +4 -7
- package/dist/plugins/CollectionScheduler.js.map +1 -0
- package/dist/plugins/MetricsCollector.js +6 -9
- package/dist/plugins/MetricsCollector.js.map +1 -0
- package/dist/plugins/prismaMetricsPlugin.d.ts +1 -1
- package/dist/plugins/prismaMetricsPlugin.js +8 -11
- package/dist/plugins/prismaMetricsPlugin.js.map +1 -0
- package/dist/prismaClientFactory.d.ts +1 -1
- package/dist/prismaClientFactory.js +2 -5
- package/dist/prismaClientFactory.js.map +1 -0
- package/dist/prismaTransaction.d.ts +1 -1
- package/dist/prismaTransaction.js +14 -16
- package/dist/prismaTransaction.js.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.js +2 -4
- package/dist/types.js.map +1 -0
- package/package.json +17 -15
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isCockroachDBRetryTransaction = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* https://www.cockroachlabs.com/docs/stable/transaction-retry-error-reference#:~:text=To%20indicate%20that%20a%20transaction,the%20string%20%22restart%20transaction%22%20.
|
|
6
3
|
*
|
|
@@ -12,10 +9,10 @@ const COCKROACHDB_RETRY_TRANSACTION_CODE = '40001';
|
|
|
12
9
|
*
|
|
13
10
|
* @param error
|
|
14
11
|
*/
|
|
15
|
-
const isCockroachDBRetryTransaction = (error) => {
|
|
12
|
+
export const isCockroachDBRetryTransaction = (error) => {
|
|
16
13
|
const meta = error.meta;
|
|
17
14
|
if (!meta)
|
|
18
15
|
return false;
|
|
19
16
|
return meta.code === COCKROACHDB_RETRY_TRANSACTION_CODE;
|
|
20
17
|
};
|
|
21
|
-
|
|
18
|
+
//# sourceMappingURL=cockroachdbError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cockroachdbError.js","sourceRoot":"","sources":["../../src/errors/cockroachdbError.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,kCAAkC,GAAG,OAAO,CAAA;AAElD;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,KAAoC,EAAW,EAAE;IAC7F,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAA;IACvB,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAA;IAEvB,OAAO,IAAI,CAAC,IAAI,KAAK,kCAAkC,CAAA;AACzD,CAAC,CAAA"}
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './prismaError';
|
|
1
|
+
export * from './prismaError.js';
|
package/dist/errors/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PRISMA_SERVER_CLOSED_CONNECTION_ERROR = exports.PRISMA_TRANSACTION_ERROR = exports.PRISMA_UNIQUE_CONSTRAINT_ERROR = exports.PRISMA_SERIALIZATION_ERROR = exports.PRISMA_NOT_FOUND_ERROR = exports.isPrismaTransactionClosedError = exports.isPrismaClientKnownRequestError = void 0;
|
|
4
|
-
const node_core_1 = require("@lokalise/node-core");
|
|
1
|
+
import { isError } from '@lokalise/node-core';
|
|
5
2
|
/**
|
|
6
3
|
* What is checked?
|
|
7
4
|
* 1. error is defined and not null
|
|
@@ -9,37 +6,36 @@ const node_core_1 = require("@lokalise/node-core");
|
|
|
9
6
|
* 3. error contains the field code which is a string
|
|
10
7
|
* 4. code starts by `P` ([doc](https://www.prisma.io/docs/reference/api-reference/error-reference#error-codes))
|
|
11
8
|
*/
|
|
12
|
-
const isPrismaClientKnownRequestError = (error) => !!error &&
|
|
13
|
-
|
|
9
|
+
export const isPrismaClientKnownRequestError = (error) => !!error &&
|
|
10
|
+
isError(error) &&
|
|
14
11
|
'code' in error &&
|
|
15
12
|
typeof error.code === 'string' &&
|
|
16
13
|
error.code.startsWith('P');
|
|
17
|
-
|
|
18
|
-
const isPrismaTransactionClosedError = (error) => error.code === exports.PRISMA_TRANSACTION_ERROR &&
|
|
14
|
+
export const isPrismaTransactionClosedError = (error) => error.code === PRISMA_TRANSACTION_ERROR &&
|
|
19
15
|
error.message.toLowerCase().includes('transaction already closed');
|
|
20
|
-
exports.isPrismaTransactionClosedError = isPrismaTransactionClosedError;
|
|
21
16
|
/**
|
|
22
17
|
* Prisma error code P2025 indicates that the operation failed because it depends on one or more
|
|
23
18
|
* records that were required but not found
|
|
24
19
|
*/
|
|
25
|
-
|
|
20
|
+
export const PRISMA_NOT_FOUND_ERROR = 'P2025';
|
|
26
21
|
/**
|
|
27
22
|
* Prisma error code P2034 indicates a serialization error and that the transaction must be retried.
|
|
28
23
|
* A different error code would indicate that an internal state error happened and that
|
|
29
24
|
* the cluster itself is experiencing an issue which requires intervention
|
|
30
25
|
*/
|
|
31
|
-
|
|
26
|
+
export const PRISMA_SERIALIZATION_ERROR = 'P2034';
|
|
32
27
|
/**
|
|
33
28
|
* Prisma error code P2002 indicates that the operation failed because a unique constraint was
|
|
34
29
|
* violated. This can happen if you try to create a record with a unique field that already exists
|
|
35
30
|
*/
|
|
36
|
-
|
|
31
|
+
export const PRISMA_UNIQUE_CONSTRAINT_ERROR = 'P2002';
|
|
37
32
|
/**
|
|
38
33
|
* Prisma error code P2028 indicates a transaction API error, essentially a placeholder for errors that do not fit into
|
|
39
34
|
* a more specific category. You should look into the error message for more details
|
|
40
35
|
*/
|
|
41
|
-
|
|
36
|
+
export const PRISMA_TRANSACTION_ERROR = 'P2028';
|
|
42
37
|
/**
|
|
43
38
|
* Prisma error code P1017 indicates that the connection to the database server was prematurely terminated by the server
|
|
44
39
|
*/
|
|
45
|
-
|
|
40
|
+
export const PRISMA_SERVER_CLOSED_CONNECTION_ERROR = 'P1017';
|
|
41
|
+
//# sourceMappingURL=prismaError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prismaError.js","sourceRoot":"","sources":["../../src/errors/prismaError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAG7C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAC7C,KAAc,EAC0B,EAAE,CAC1C,CAAC,CAAC,KAAK;IACP,OAAO,CAAC,KAAK,CAAC;IACd,MAAM,IAAI,KAAK;IACf,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;IAC9B,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;AAE5B,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,KAAoC,EAAW,EAAE,CAC9F,KAAK,CAAC,IAAI,KAAK,wBAAwB;IACvC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC,CAAA;AAEpE;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAA;AAE7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAA;AAEjD;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,OAAO,CAAA;AAErD;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,OAAO,CAAA;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,OAAO,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type * from './types';
|
|
2
|
-
export * from './errors';
|
|
3
|
-
export { prismaTransaction } from './prismaTransaction';
|
|
4
|
-
export { prismaClientFactory } from './prismaClientFactory';
|
|
5
|
-
export { prismaMetricsPlugin, type PrismaMetricsPluginOptions } from './plugins/prismaMetricsPlugin';
|
|
1
|
+
export type * from './types.js';
|
|
2
|
+
export * from './errors/index.js';
|
|
3
|
+
export { prismaTransaction } from './prismaTransaction.js';
|
|
4
|
+
export { prismaClientFactory } from './prismaClientFactory.js';
|
|
5
|
+
export { prismaMetricsPlugin, type PrismaMetricsPluginOptions, } from './plugins/prismaMetricsPlugin.js';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var prismaTransaction_1 = require("./prismaTransaction");
|
|
7
|
-
Object.defineProperty(exports, "prismaTransaction", { enumerable: true, get: function () { return prismaTransaction_1.prismaTransaction; } });
|
|
8
|
-
var prismaClientFactory_1 = require("./prismaClientFactory");
|
|
9
|
-
Object.defineProperty(exports, "prismaClientFactory", { enumerable: true, get: function () { return prismaClientFactory_1.prismaClientFactory; } });
|
|
10
|
-
var prismaMetricsPlugin_1 = require("./plugins/prismaMetricsPlugin");
|
|
11
|
-
Object.defineProperty(exports, "prismaMetricsPlugin", { enumerable: true, get: function () { return prismaMetricsPlugin_1.prismaMetricsPlugin; } });
|
|
1
|
+
export * from './errors/index.js';
|
|
2
|
+
export { prismaTransaction } from './prismaTransaction.js';
|
|
3
|
+
export { prismaClientFactory } from './prismaClientFactory.js';
|
|
4
|
+
export { prismaMetricsPlugin, } from './plugins/prismaMetricsPlugin.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,mBAAmB,CAAA;AAEjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EACL,mBAAmB,GAEpB,MAAM,kCAAkC,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=isolationLevel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isolationLevel.js","sourceRoot":"","sources":["../../src/isolation_level/isolationLevel.ts"],"names":[],"mappings":""}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.PromiseBasedCollectionScheduler = void 0;
|
|
4
|
-
const promises_1 = require("node:timers/promises");
|
|
5
|
-
class PromiseBasedCollectionScheduler {
|
|
1
|
+
import { setTimeout } from 'node:timers/promises';
|
|
2
|
+
export class PromiseBasedCollectionScheduler {
|
|
6
3
|
active = true;
|
|
7
4
|
collectionIntervalInMs;
|
|
8
5
|
collect;
|
|
@@ -12,7 +9,7 @@ class PromiseBasedCollectionScheduler {
|
|
|
12
9
|
}
|
|
13
10
|
async start() {
|
|
14
11
|
while (this.active) {
|
|
15
|
-
await
|
|
12
|
+
await setTimeout(this.collectionIntervalInMs);
|
|
16
13
|
await this.collect();
|
|
17
14
|
}
|
|
18
15
|
}
|
|
@@ -20,4 +17,4 @@ class PromiseBasedCollectionScheduler {
|
|
|
20
17
|
this.active = false;
|
|
21
18
|
}
|
|
22
19
|
}
|
|
23
|
-
|
|
20
|
+
//# sourceMappingURL=CollectionScheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CollectionScheduler.js","sourceRoot":"","sources":["../../src/plugins/CollectionScheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAOjD,MAAM,OAAO,+BAA+B;IAClC,MAAM,GAAG,IAAI,CAAA;IACJ,sBAAsB,CAAQ;IAC9B,OAAO,CAAqB;IAE7C,YAAY,sBAA8B,EAAE,OAA4B;QACtE,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAA;QACpD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,UAAU,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;YAC7C,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;QACtB,CAAC;IACH,CAAC;IAED,IAAI;QACF,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;CACF"}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MetricsCollector = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const prometheus = tslib_1.__importStar(require("prom-client"));
|
|
1
|
+
import * as prometheus from 'prom-client';
|
|
6
2
|
function registerMetrics(_prefix, jsonMetrics) {
|
|
7
3
|
const metrics = {
|
|
8
4
|
counters: {},
|
|
@@ -44,7 +40,7 @@ function getMetricKeys(_prefix, jsonMetrics) {
|
|
|
44
40
|
metricKeys.push(...jsonMetrics.histograms.map((metric) => metric.key));
|
|
45
41
|
return metricKeys;
|
|
46
42
|
}
|
|
47
|
-
class MetricsCollector {
|
|
43
|
+
export class MetricsCollector {
|
|
48
44
|
prisma;
|
|
49
45
|
options;
|
|
50
46
|
registry;
|
|
@@ -157,11 +153,12 @@ class MetricsCollector {
|
|
|
157
153
|
* If metrics are already registered, we just return them to avoid triggering a Prometheus error.
|
|
158
154
|
*/
|
|
159
155
|
getRegisteredMetrics(registry, metricNames) {
|
|
160
|
-
if (!metricNames.length
|
|
156
|
+
if (!metricNames.length)
|
|
161
157
|
return;
|
|
162
|
-
}
|
|
163
158
|
/* c8 ignore start */
|
|
164
159
|
const retrievedMetrics = registry.getMetricsAsArray();
|
|
160
|
+
if (!retrievedMetrics.length)
|
|
161
|
+
return;
|
|
165
162
|
const returnValue = {
|
|
166
163
|
counters: {},
|
|
167
164
|
histograms: {},
|
|
@@ -188,4 +185,4 @@ class MetricsCollector {
|
|
|
188
185
|
return this.prisma.$metrics.json();
|
|
189
186
|
}
|
|
190
187
|
}
|
|
191
|
-
|
|
188
|
+
//# sourceMappingURL=MetricsCollector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MetricsCollector.js","sourceRoot":"","sources":["../../src/plugins/MetricsCollector.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,UAAU,MAAM,aAAa,CAAA;AAmBzC,SAAS,eAAe,CAAC,OAAe,EAAE,WAAoB;IAC5D,MAAM,OAAO,GAAiC;QAC5C,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,EAAE;QACV,UAAU,EAAE,EAAE;QACd,IAAI,EAAE,EAAE;KACT,CAAA;IACD,KAAK,MAAM,MAAM,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;QAC1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC;YACpD,IAAI,EAAE,MAAM,CAAC,GAAG;YAChB,IAAI,EAAE,MAAM,CAAC,WAAW;YACxB,UAAU,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAU;SACnD,CAAC,CAAA;QACF,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC;IAED,KAAK,MAAM,MAAM,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AAI,CAAC,QAAQ,EAAE,KAAK,OAAO,EAAE,CAAC;gBACvC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,IAAqB,CAAC,GAAG,MAAM,CAAA;YAC3D,CAAC;YACD,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,WAAW,EAAE,CAAC;gBAC3C,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,IAAqB,CAAC,GAAG,MAAM,CAAA;YAC/D,CAAC;QACH,CAAC;QAED,OAAO,WAAsD,CAAA;QAC7D,oBAAoB;IACtB,CAAC;IAEO,cAAc;QACpB,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAA;IACpC,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FastifyPluginCallback } from 'fastify';
|
|
2
2
|
import 'fastify-metrics';
|
|
3
3
|
import type { PrismaClient } from '@prisma/client';
|
|
4
|
-
import type { MetricCollectorOptions } from './MetricsCollector';
|
|
4
|
+
import type { MetricCollectorOptions } from './MetricsCollector.js';
|
|
5
5
|
declare module 'fastify' {
|
|
6
6
|
interface FastifyInstance {
|
|
7
7
|
prismaMetrics: {
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
require("fastify-metrics");
|
|
6
|
-
const fastify_plugin_1 = tslib_1.__importDefault(require("fastify-plugin"));
|
|
7
|
-
const CollectionScheduler_1 = require("./CollectionScheduler");
|
|
8
|
-
const MetricsCollector_1 = require("./MetricsCollector");
|
|
1
|
+
import 'fastify-metrics';
|
|
2
|
+
import fp from 'fastify-plugin';
|
|
3
|
+
import { PromiseBasedCollectionScheduler } from './CollectionScheduler.js';
|
|
4
|
+
import { MetricsCollector } from './MetricsCollector.js';
|
|
9
5
|
function plugin(fastify, pluginOptions, next) {
|
|
10
6
|
if (!fastify.metrics) {
|
|
11
7
|
return next(new Error('No Prometheus Client found, Prisma metrics plugin requires `fastify-metrics` plugin to be registered'));
|
|
@@ -19,11 +15,11 @@ function plugin(fastify, pluginOptions, next) {
|
|
|
19
15
|
metricsPrefix: 'prisma',
|
|
20
16
|
};
|
|
21
17
|
try {
|
|
22
|
-
const collector = new
|
|
18
|
+
const collector = new MetricsCollector(options.prisma, options, fastify.metrics.client.register, fastify.log);
|
|
23
19
|
const collectFn = async () => await collector.collect(options.metricsPrefix);
|
|
24
20
|
let scheduler;
|
|
25
21
|
if (options.collectionOptions.type === 'interval') {
|
|
26
|
-
scheduler = new
|
|
22
|
+
scheduler = new PromiseBasedCollectionScheduler(options.collectionOptions.intervalInMs, collectFn);
|
|
27
23
|
// Void is set so the scheduler can run indefinitely
|
|
28
24
|
void scheduler.start();
|
|
29
25
|
}
|
|
@@ -46,7 +42,8 @@ function plugin(fastify, pluginOptions, next) {
|
|
|
46
42
|
}
|
|
47
43
|
/* c8 ignore stop */
|
|
48
44
|
}
|
|
49
|
-
|
|
45
|
+
export const prismaMetricsPlugin = fp(plugin, {
|
|
50
46
|
fastify: '5.x',
|
|
51
47
|
name: 'prisma-metrics-plugin',
|
|
52
48
|
});
|
|
49
|
+
//# sourceMappingURL=prismaMetricsPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prismaMetricsPlugin.js","sourceRoot":"","sources":["../../src/plugins/prismaMetricsPlugin.ts"],"names":[],"mappings":"AACA,OAAO,iBAAiB,CAAA;AACxB,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAI/B,OAAO,EAAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAA;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAuBxD,SAAS,MAAM,CACb,OAAwB,EACxB,aAAyC,EACzC,IAA2B;IAE3B,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,IAAI,CACT,IAAI,KAAK,CACP,sGAAsG,CACvG,CACF,CAAA;IACH,CA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AC;IACD,oBAAoB;AACtB,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAC9B,EAAE,CAA6B,MAAM,EAAE;IACrC,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,uBAAuB;CAC9B,CAAC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Prisma, PrismaClient } from '@prisma/client';
|
|
2
|
-
import type { PrismaClientFactoryOptions } from './types';
|
|
2
|
+
import type { PrismaClientFactoryOptions } from './types.js';
|
|
3
3
|
type PrismaClientConstructor<P extends PrismaClient> = new (options: Prisma.PrismaClientOptions) => P;
|
|
4
4
|
export declare const prismaClientFactory: <P extends PrismaClient>(PrismaClient: PrismaClientConstructor<P>, options?: PrismaClientFactoryOptions) => P;
|
|
5
5
|
export {};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prismaClientFactory = void 0;
|
|
4
1
|
const defaultOptions = {
|
|
5
2
|
transactionOptions: { isolationLevel: 'ReadCommitted' },
|
|
6
3
|
};
|
|
7
|
-
const prismaClientFactory = (PrismaClient, options = {}) => {
|
|
4
|
+
export const prismaClientFactory = (PrismaClient, options = {}) => {
|
|
8
5
|
options.transactionOptions = {
|
|
9
6
|
...defaultOptions.transactionOptions,
|
|
10
7
|
...options.transactionOptions,
|
|
@@ -12,4 +9,4 @@ const prismaClientFactory = (PrismaClient, options = {}) => {
|
|
|
12
9
|
//@ts-expect-error - ReadCommitted is not accepted by Prisma atm
|
|
13
10
|
return new PrismaClient(options);
|
|
14
11
|
};
|
|
15
|
-
|
|
12
|
+
//# sourceMappingURL=prismaClientFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prismaClientFactory.js","sourceRoot":"","sources":["../src/prismaClientFactory.ts"],"names":[],"mappings":"AAGA,MAAM,cAAc,GAA+B;IACjD,kBAAkB,EAAE,EAAE,cAAc,EAAE,eAAe,EAAE;CACxD,CAAA;AAMD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,YAAwC,EACxC,UAAsC,EAAE,EACrC,EAAE;IACL,OAAO,CAAC,kBAAkB,GAAG;QAC3B,GAAG,cAAc,CAAC,kBAAkB;QACpC,GAAG,OAAO,CAAC,kBAAkB;KAC9B,CAAA;IAED,gEAAgE;IAChE,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAA;AAClC,CAAC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Either } from '@lokalise/node-core';
|
|
2
2
|
import type { Prisma, PrismaClient } from '@prisma/client';
|
|
3
3
|
import type * as runtime from '@prisma/client/runtime/library';
|
|
4
|
-
import type { PrismaTransactionBasicOptions, PrismaTransactionFn, PrismaTransactionOptions } from './types';
|
|
4
|
+
import type { PrismaTransactionBasicOptions, PrismaTransactionFn, PrismaTransactionOptions } from './types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Perform a Prisma DB transaction with automatic retries if needed.
|
|
7
7
|
*
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const node_core_1 = require("@lokalise/node-core");
|
|
6
|
-
const cockroachdbError_1 = require("./errors/cockroachdbError");
|
|
7
|
-
const prismaError_1 = require("./errors/prismaError");
|
|
1
|
+
import { setTimeout } from 'node:timers/promises';
|
|
2
|
+
import { deepClone } from '@lokalise/node-core';
|
|
3
|
+
import { isCockroachDBRetryTransaction } from './errors/cockroachdbError.js';
|
|
4
|
+
import { PRISMA_SERIALIZATION_ERROR, PRISMA_SERVER_CLOSED_CONNECTION_ERROR, PRISMA_TRANSACTION_ERROR, isPrismaClientKnownRequestError, isPrismaTransactionClosedError, } from './errors/prismaError.js';
|
|
8
5
|
const DEFAULT_OPTIONS = {
|
|
9
6
|
retriesAllowed: 2, // first try + 2 retries = 3 tries
|
|
10
7
|
dbDriver: 'CockroachDb',
|
|
@@ -22,13 +19,13 @@ const DEFAULT_OPTIONS = {
|
|
|
22
19
|
* @param {PrismaTransactionOptions | PrismaTransactionBasicOptions} options transaction configuration
|
|
23
20
|
* @return {Promise<PrismaTransactionReturnType<T>>}
|
|
24
21
|
*/
|
|
25
|
-
|
|
22
|
+
export const prismaTransaction = (async (prisma, arg, options) => {
|
|
26
23
|
let optionsWithDefaults = { ...DEFAULT_OPTIONS, ...options };
|
|
27
24
|
let result = undefined;
|
|
28
25
|
let retries = 0;
|
|
29
26
|
do {
|
|
30
27
|
if (retries > 0) {
|
|
31
|
-
await
|
|
28
|
+
await setTimeout(calculateRetryDelay(retries, optionsWithDefaults.baseRetryDelayMs, optionsWithDefaults.maxRetryDelayMs));
|
|
32
29
|
}
|
|
33
30
|
result = await executeTransactionTry(prisma, arg, optionsWithDefaults);
|
|
34
31
|
if (result.result)
|
|
@@ -37,7 +34,7 @@ exports.prismaTransaction = (async (prisma, arg, options) => {
|
|
|
37
34
|
if (!retryAllowed)
|
|
38
35
|
break;
|
|
39
36
|
if (retryAllowed === 'increase-timeout') {
|
|
40
|
-
optionsWithDefaults =
|
|
37
|
+
optionsWithDefaults = deepClone(optionsWithDefaults);
|
|
41
38
|
optionsWithDefaults.timeout = Math.min(optionsWithDefaults.timeout * 2, optionsWithDefaults.maxTimeout);
|
|
42
39
|
}
|
|
43
40
|
retries++;
|
|
@@ -61,23 +58,24 @@ const calculateRetryDelay = (retries, baseRetryDelayMs, maxDelayMs) => {
|
|
|
61
58
|
return Math.min(expDelay, maxDelayMs);
|
|
62
59
|
};
|
|
63
60
|
const PrismaCodesToRetry = [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
PRISMA_SERIALIZATION_ERROR,
|
|
62
|
+
PRISMA_SERVER_CLOSED_CONNECTION_ERROR,
|
|
63
|
+
PRISMA_TRANSACTION_ERROR,
|
|
67
64
|
];
|
|
68
65
|
const isRetryAllowed = (result, dbDriver) => {
|
|
69
|
-
if (
|
|
66
|
+
if (isPrismaClientKnownRequestError(result.error)) {
|
|
70
67
|
const error = result.error;
|
|
71
68
|
// in case transaction is closed (timeout), retry increasing the timeout
|
|
72
69
|
// this should be the first check as the code error is PRISMA_TRANSACTION_ERROR covered also in the next check
|
|
73
|
-
if (
|
|
70
|
+
if (isPrismaTransactionClosedError(error))
|
|
74
71
|
return 'increase-timeout';
|
|
75
72
|
// retry if the error code is in the list of codes to retry
|
|
76
73
|
if (PrismaCodesToRetry.includes(error.code))
|
|
77
74
|
return true;
|
|
78
75
|
// retry if the error is a CockroachDB retry transaction error
|
|
79
|
-
if (dbDriver === 'CockroachDb' &&
|
|
76
|
+
if (dbDriver === 'CockroachDb' && isCockroachDBRetryTransaction(error))
|
|
80
77
|
return true;
|
|
81
78
|
}
|
|
82
79
|
return false;
|
|
83
80
|
};
|
|
81
|
+
//# sourceMappingURL=prismaTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prismaTransaction.js","sourceRoot":"","sources":["../src/prismaTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAGjD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAI/C,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAA;AAC5E,OAAO,EACL,0BAA0B,EAC1B,qCAAqC,EACrC,wBAAwB,EACxB,+BAA+B,EAC/B,8BAA8B,GAC/B,MAAM,yBAAyB,CAAA;AAShC,MAAM,eAAe,GAAG;IACtB,cAAc,EAAE,CAAC,EAAE,kCAAkC;IACrD,QAAQ,EAAE,aAAa;IACvB,gBAAgB,EAAE,GAAG;IACrB,eAAe,EAAE,KAAK,EAAE,MAAM;IAC9B,OAAO,EAAE,IAAI,EAAE,KAAK;IACpB,UAAU,EAAE,KAAK,EAAE,MAAM;CACkB,CAAA;AAE7C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAA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AE,OAAO,CAAC;SACnD,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,KAAK,EAAE,CAAA;IAClB,CAAC;AACH,CAAC,CAAA;AAED,MAAM,mBAAmB,GAAG,CAC1B,OAAe,EACf,gBAAwB,EACxB,UAAkB,EACV,EAAE;IACV,wDAAwD;IACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,gBAAgB,CAAA;IAC5D,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;AACvC,CAAC,CAAA;AAED,MAAM,kBAAkB,GAAG;IACzB,0BAA0B;IAC1B,qCAAqC;IACrC,wBAAwB;CACzB,CAAA;AAGD,MAAM,cAAc,GAAG,CACrB,MAAsC,EACtC,QAAkB,EACI,EAAE;IACxB,IAAI,+BAA+B,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;QAC1B,wEAAwE;QACxE,8GAA8G;QAC9G,IAAI,8BAA8B,CAAC,KAAK,CAAC;YAAE,OAAO,kBAAkB,CAAA;QACpE,2DAA2D;QAC3D,IAAI,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAA;QACxD,8DAA8D;QAC9D,IAAI,QAAQ,KAAK,aAAa,IAAI,6BAA6B,CAAC,KAAK,CAAC;YAAE,OAAO,IAAI,CAAA;IACrF,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Either } from '@lokalise/node-core';
|
|
2
2
|
import type { Prisma } from '@prisma/client';
|
|
3
3
|
import type * as runtime from '@prisma/client/runtime/library';
|
|
4
|
-
import type { CockroachDbIsolationLevel } from './isolation_level/isolationLevel';
|
|
4
|
+
import type { CockroachDbIsolationLevel } from './isolation_level/isolationLevel.js';
|
|
5
5
|
type ObjectValues<T> = T[keyof T];
|
|
6
6
|
export declare const DbDriverEnum: {
|
|
7
7
|
readonly COCKROACHDB: "CockroachDb";
|
package/dist/types.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,WAAW,EAAE,aAAa;CAClB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lokalise/prisma-utils",
|
|
3
|
-
"version": "
|
|
4
|
-
"type": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"files": ["dist", "README.md", "LICENSE.md"],
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
|
-
"
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./dist/index.js",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
9
12
|
"homepage": "https://github.com/lokalise/shared-ts-libs",
|
|
10
13
|
"repository": {
|
|
11
14
|
"type": "git",
|
|
12
15
|
"url": "https://github.com/lokalise/shared-ts-libs.git"
|
|
13
16
|
},
|
|
14
17
|
"scripts": {
|
|
15
|
-
"build": "rimraf dist && npm run db:update-client && tsc",
|
|
16
|
-
"dev": "vite watch",
|
|
18
|
+
"build": "rimraf dist && npm run db:update-client && tsc --project tsconfig.build.json",
|
|
17
19
|
"clean": "rimraf dist",
|
|
18
|
-
"lint": "biome check . && tsc
|
|
20
|
+
"lint": "biome check . && tsc",
|
|
19
21
|
"lint:fix": "biome check --write",
|
|
20
22
|
"docker:start:ci": "docker compose up -d cockroachdb",
|
|
21
|
-
"db:migration:dev": "
|
|
22
|
-
"db:update-client": "
|
|
23
|
-
"db:wait": "while ! echo \"SELECT 1;\" |
|
|
23
|
+
"db:migration:dev": "prisma migrate dev",
|
|
24
|
+
"db:update-client": "prisma generate",
|
|
25
|
+
"db:wait": "while ! echo \"SELECT 1;\" | prisma db execute --stdin; do sleep 1; done",
|
|
24
26
|
"test": "vitest run",
|
|
25
|
-
"test:migrate": "cross-env NODE_ENV=test
|
|
27
|
+
"test:migrate": "cross-env NODE_ENV=test prisma migrate reset --force",
|
|
26
28
|
"pretest:ci": "npm run docker:start:ci && npm run db:wait && npm run test:migrate",
|
|
27
29
|
"test:ci": "npm run test -- --coverage",
|
|
28
30
|
"test:ci:teardown": "docker compose down",
|
|
@@ -41,14 +43,14 @@
|
|
|
41
43
|
"@biomejs/biome": "^1.9.4",
|
|
42
44
|
"@lokalise/biome-config": "^1.5.0",
|
|
43
45
|
"@lokalise/backend-http-client": "^2.3.0",
|
|
44
|
-
"@lokalise/fastify-extras": "^
|
|
46
|
+
"@lokalise/fastify-extras": "^26.1.1",
|
|
47
|
+
"@lokalise/tsconfig": "^1.0.2",
|
|
45
48
|
"@prisma/client": "^6.0.1",
|
|
46
|
-
"@vitest/coverage-v8": "^
|
|
49
|
+
"@vitest/coverage-v8": "^3.0.7",
|
|
47
50
|
"cross-env": "^7.0.3",
|
|
48
|
-
"dotenv-cli": "^7.4.1",
|
|
49
51
|
"prisma": "^6.0.1",
|
|
50
52
|
"rimraf": "^6.0.1",
|
|
51
|
-
"typescript": "5.
|
|
52
|
-
"vitest": "^
|
|
53
|
+
"typescript": "5.8.2",
|
|
54
|
+
"vitest": "^3.0.7"
|
|
53
55
|
}
|
|
54
56
|
}
|