@8ms/helpers 2.0.26 → 2.0.28
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/.yarn/install-state.gz +0 -0
- package/package.json +1 -1
- package/prisma/PrismaNamespace.js +10 -8
- package/util/getError.d.ts +1 -0
- package/util/getError.js +14 -0
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -35,22 +35,23 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.PrismaNamespace = void 0;
|
|
37
37
|
const _class_1 = require("../_class");
|
|
38
|
+
const getError_1 = require("../util/getError");
|
|
38
39
|
class PrismaNamespace extends _class_1.BaseNamespace {
|
|
39
40
|
constructor() {
|
|
40
41
|
super(...arguments);
|
|
41
42
|
// Async setup to only initialise where required
|
|
42
43
|
this.ensureInit = async () => {
|
|
43
44
|
if (!this.client) {
|
|
44
|
-
let
|
|
45
|
+
let planetScaleAdapter = null;
|
|
45
46
|
if (this.config.isPlanetScale) {
|
|
46
47
|
try {
|
|
47
48
|
const { PrismaPlanetScale } = await Promise.resolve().then(() => __importStar(require("@prisma/adapter-planetscale")));
|
|
48
|
-
|
|
49
|
+
planetScaleAdapter = new PrismaPlanetScale({
|
|
49
50
|
url: this.config.url,
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
53
|
catch (e) {
|
|
53
|
-
throw new Error(
|
|
54
|
+
throw new Error(`PlanetScale Client not installed - ${(0, getError_1.getError)(e)}`);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
try {
|
|
@@ -58,8 +59,8 @@ class PrismaNamespace extends _class_1.BaseNamespace {
|
|
|
58
59
|
// Show the full query if debugging
|
|
59
60
|
if (this.config.isDebug) {
|
|
60
61
|
this.client = new PrismaClient({
|
|
61
|
-
adapter,
|
|
62
|
-
datasourceUrl: this.config.url,
|
|
62
|
+
adapter: planetScaleAdapter,
|
|
63
|
+
datasourceUrl: planetScaleAdapter ? undefined : this.config.url,
|
|
63
64
|
log: [
|
|
64
65
|
{
|
|
65
66
|
emit: "event",
|
|
@@ -71,16 +72,17 @@ class PrismaNamespace extends _class_1.BaseNamespace {
|
|
|
71
72
|
// Standard prisma
|
|
72
73
|
else {
|
|
73
74
|
this.client = new PrismaClient({
|
|
74
|
-
adapter,
|
|
75
|
-
datasourceUrl: this.config.url,
|
|
75
|
+
adapter: planetScaleAdapter,
|
|
76
|
+
datasourceUrl: planetScaleAdapter ? undefined : this.config.url,
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
catch (e) {
|
|
80
|
-
throw new Error(
|
|
81
|
+
throw new Error(`Prisma Client not installed - ${(0, getError_1.getError)(e)}`);
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
exports.PrismaNamespace = PrismaNamespace;
|
|
88
|
+
;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getError: (error: any) => string;
|
package/util/getError.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getError = void 0;
|
|
4
|
+
const getError = (error) => {
|
|
5
|
+
let response = "";
|
|
6
|
+
if (typeof error === "string") {
|
|
7
|
+
response = error.toUpperCase();
|
|
8
|
+
}
|
|
9
|
+
else if (error instanceof Error) {
|
|
10
|
+
response = error.message;
|
|
11
|
+
}
|
|
12
|
+
return response;
|
|
13
|
+
};
|
|
14
|
+
exports.getError = getError;
|