@8ms/helpers 2.4.15 → 2.4.17
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/drizzle/server/DrizzleNamespace.cjs +30 -7
- package/dist/drizzle/server/DrizzleNamespace.d.cts +1 -0
- package/dist/drizzle/server/DrizzleNamespace.mjs +30 -7
- package/dist/drizzle/server/drizzle.cjs +9 -9
- package/dist/drizzle/server/drizzle.d.cts +13 -6
- package/dist/drizzle/server/drizzle.d.mts +13 -6
- package/dist/drizzle/server/drizzle.mjs +9 -9
- package/dist/environment/environment.cjs +1 -1
- package/dist/environment/environment.mjs +1 -1
- package/dist/onePassword/server/OnePasswordNamespace.cjs +2 -1
- package/dist/onePassword/server/OnePasswordNamespace.mjs +2 -1
- package/package.json +17 -7
|
@@ -10,11 +10,16 @@ var DrizzleNamespace = class extends require__class_BaseNamespace.BaseNamespace
|
|
|
10
10
|
const { DefaultLogger } = await import("drizzle-orm/logger");
|
|
11
11
|
logger = new DefaultLogger();
|
|
12
12
|
}
|
|
13
|
+
let casing = void 0;
|
|
14
|
+
if ("snake" === this.config?.casing) casing = "snake_case";
|
|
15
|
+
else if ("camel" === this.config?.casing) casing = "camelCase";
|
|
13
16
|
if (this.config.isPlanetScale) try {
|
|
14
17
|
const { drizzle } = await import("drizzle-orm/planetscale-serverless");
|
|
15
18
|
this.client = drizzle({
|
|
19
|
+
casing,
|
|
16
20
|
connection: { url: this.config.url },
|
|
17
21
|
relations: this.config?.relations,
|
|
22
|
+
schema: this.config?.schema,
|
|
18
23
|
logger
|
|
19
24
|
});
|
|
20
25
|
} catch (e) {
|
|
@@ -22,19 +27,37 @@ var DrizzleNamespace = class extends require__class_BaseNamespace.BaseNamespace
|
|
|
22
27
|
}
|
|
23
28
|
else if (this.config.isMysql) try {
|
|
24
29
|
const { drizzle } = await import("drizzle-orm/mysql2");
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
const pool = (await import("mysql2/promise")).createPool({
|
|
31
|
+
uri: this.config.url,
|
|
32
|
+
connectionLimit: this.config.pool?.max ?? 10,
|
|
33
|
+
idleTimeout: this.config.pool?.idleTimeoutMs ?? 3e4,
|
|
34
|
+
connectTimeout: this.config.pool?.connectTimeoutMs ?? 5e3,
|
|
35
|
+
waitForConnections: true,
|
|
36
|
+
queueLimit: 0
|
|
37
|
+
});
|
|
38
|
+
this.client = drizzle(pool, {
|
|
39
|
+
schema: this.config.schema,
|
|
40
|
+
relations: this.config.relations,
|
|
41
|
+
casing,
|
|
42
|
+
logger,
|
|
43
|
+
mode: "default"
|
|
29
44
|
});
|
|
30
45
|
} catch (e) {
|
|
31
46
|
throw new Error(`MySQL2 driver not installed - ${require_util_getError.getError(e)}`);
|
|
32
47
|
}
|
|
33
48
|
else if (this.config.isPostgres) try {
|
|
34
49
|
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
50
|
+
const { Pool } = await import("pg");
|
|
51
|
+
const pool = new Pool({
|
|
52
|
+
connectionString: this.config.url,
|
|
53
|
+
max: this.config.pool?.max ?? 10,
|
|
54
|
+
idleTimeoutMillis: this.config.pool?.idleTimeoutMs ?? 3e4,
|
|
55
|
+
connectionTimeoutMillis: this.config.pool?.connectTimeoutMs ?? 5e3
|
|
56
|
+
});
|
|
57
|
+
this.client = drizzle(pool, {
|
|
58
|
+
schema: this.config.schema,
|
|
59
|
+
relations: this.config.relations,
|
|
60
|
+
casing,
|
|
38
61
|
logger
|
|
39
62
|
});
|
|
40
63
|
} catch (e) {
|
|
@@ -9,11 +9,16 @@ var DrizzleNamespace = class extends BaseNamespace {
|
|
|
9
9
|
const { DefaultLogger } = await import("drizzle-orm/logger");
|
|
10
10
|
logger = new DefaultLogger();
|
|
11
11
|
}
|
|
12
|
+
let casing = void 0;
|
|
13
|
+
if ("snake" === this.config?.casing) casing = "snake_case";
|
|
14
|
+
else if ("camel" === this.config?.casing) casing = "camelCase";
|
|
12
15
|
if (this.config.isPlanetScale) try {
|
|
13
16
|
const { drizzle } = await import("drizzle-orm/planetscale-serverless");
|
|
14
17
|
this.client = drizzle({
|
|
18
|
+
casing,
|
|
15
19
|
connection: { url: this.config.url },
|
|
16
20
|
relations: this.config?.relations,
|
|
21
|
+
schema: this.config?.schema,
|
|
17
22
|
logger
|
|
18
23
|
});
|
|
19
24
|
} catch (e) {
|
|
@@ -21,19 +26,37 @@ var DrizzleNamespace = class extends BaseNamespace {
|
|
|
21
26
|
}
|
|
22
27
|
else if (this.config.isMysql) try {
|
|
23
28
|
const { drizzle } = await import("drizzle-orm/mysql2");
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
const pool = (await import("mysql2/promise")).createPool({
|
|
30
|
+
uri: this.config.url,
|
|
31
|
+
connectionLimit: this.config.pool?.max ?? 10,
|
|
32
|
+
idleTimeout: this.config.pool?.idleTimeoutMs ?? 3e4,
|
|
33
|
+
connectTimeout: this.config.pool?.connectTimeoutMs ?? 5e3,
|
|
34
|
+
waitForConnections: true,
|
|
35
|
+
queueLimit: 0
|
|
36
|
+
});
|
|
37
|
+
this.client = drizzle(pool, {
|
|
38
|
+
schema: this.config.schema,
|
|
39
|
+
relations: this.config.relations,
|
|
40
|
+
casing,
|
|
41
|
+
logger,
|
|
42
|
+
mode: "default"
|
|
28
43
|
});
|
|
29
44
|
} catch (e) {
|
|
30
45
|
throw new Error(`MySQL2 driver not installed - ${getError(e)}`);
|
|
31
46
|
}
|
|
32
47
|
else if (this.config.isPostgres) try {
|
|
33
48
|
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
49
|
+
const { Pool } = await import("pg");
|
|
50
|
+
const pool = new Pool({
|
|
51
|
+
connectionString: this.config.url,
|
|
52
|
+
max: this.config.pool?.max ?? 10,
|
|
53
|
+
idleTimeoutMillis: this.config.pool?.idleTimeoutMs ?? 3e4,
|
|
54
|
+
connectionTimeoutMillis: this.config.pool?.connectTimeoutMs ?? 5e3
|
|
55
|
+
});
|
|
56
|
+
this.client = drizzle(pool, {
|
|
57
|
+
schema: this.config.schema,
|
|
58
|
+
relations: this.config.relations,
|
|
59
|
+
casing,
|
|
37
60
|
logger
|
|
38
61
|
});
|
|
39
62
|
} catch (e) {
|
|
@@ -4,16 +4,16 @@ const require_drizzle_server_DrizzleNamespace = require("./DrizzleNamespace.cjs"
|
|
|
4
4
|
const drizzleNamespaces = /* @__PURE__ */ new Map();
|
|
5
5
|
const drizzleClient = async (key = "default", config) => {
|
|
6
6
|
if (drizzleNamespaces.has(key)) return drizzleNamespaces.get(key);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
url
|
|
10
|
-
isDebug
|
|
11
|
-
isPlanetScale
|
|
12
|
-
isMysql
|
|
13
|
-
isPostgres
|
|
14
|
-
};
|
|
7
|
+
let finalConfig = config ?? {};
|
|
8
|
+
if (key === "default") {
|
|
9
|
+
finalConfig.url = process.env.DATABASE_URL;
|
|
10
|
+
finalConfig.isDebug = "true" === process.env.DATABASE_IS_DEBUG;
|
|
11
|
+
finalConfig.isPlanetScale = "true" === process.env.DATABASE_IS_PLANETSCALE;
|
|
12
|
+
finalConfig.isMysql = "true" === process.env.DATABASE_IS_MYSQL;
|
|
13
|
+
finalConfig.isPostgres = "true" === process.env.DATABASE_IS_POSTGRES;
|
|
14
|
+
} else if ("default" !== key && config) finalConfig = config;
|
|
15
15
|
else throw new Error(`Config required for namespace '${key}'`);
|
|
16
|
-
const namespace = new require_drizzle_server_DrizzleNamespace.DrizzleNamespace(key,
|
|
16
|
+
const namespace = new require_drizzle_server_DrizzleNamespace.DrizzleNamespace(key, finalConfig);
|
|
17
17
|
await namespace.ensureInit();
|
|
18
18
|
drizzleNamespaces.set(key, namespace);
|
|
19
19
|
return namespace;
|
|
@@ -2,13 +2,20 @@ import { DrizzleNamespace } from "./DrizzleNamespace.cjs";
|
|
|
2
2
|
import { defineRelations } from "drizzle-orm";
|
|
3
3
|
|
|
4
4
|
//#region src/drizzle/server/drizzle.d.ts
|
|
5
|
-
type DrizzleConfig = {
|
|
5
|
+
type DrizzleConfig<TSchema extends Record<string, unknown> = Record<string, unknown>> = {
|
|
6
|
+
schema?: TSchema;
|
|
6
7
|
relations?: ReturnType<typeof defineRelations>;
|
|
7
|
-
url
|
|
8
|
-
isDebug
|
|
9
|
-
isPlanetScale
|
|
10
|
-
isMysql
|
|
11
|
-
isPostgres
|
|
8
|
+
url?: string;
|
|
9
|
+
isDebug?: boolean;
|
|
10
|
+
isPlanetScale?: boolean;
|
|
11
|
+
isMysql?: boolean;
|
|
12
|
+
isPostgres?: boolean;
|
|
13
|
+
casing?: "snake" | "camel";
|
|
14
|
+
pool?: {
|
|
15
|
+
max?: number;
|
|
16
|
+
idleTimeoutMs?: number;
|
|
17
|
+
connectTimeoutMs?: number;
|
|
18
|
+
};
|
|
12
19
|
};
|
|
13
20
|
declare const drizzleClient: <TClient = any>(key?: string, config?: DrizzleConfig) => Promise<DrizzleNamespace<TClient>>;
|
|
14
21
|
//#endregion
|
|
@@ -2,13 +2,20 @@ import { DrizzleNamespace } from "./DrizzleNamespace.mjs";
|
|
|
2
2
|
import { defineRelations } from "drizzle-orm";
|
|
3
3
|
|
|
4
4
|
//#region src/drizzle/server/drizzle.d.ts
|
|
5
|
-
type DrizzleConfig = {
|
|
5
|
+
type DrizzleConfig<TSchema extends Record<string, unknown> = Record<string, unknown>> = {
|
|
6
|
+
schema?: TSchema;
|
|
6
7
|
relations?: ReturnType<typeof defineRelations>;
|
|
7
|
-
url
|
|
8
|
-
isDebug
|
|
9
|
-
isPlanetScale
|
|
10
|
-
isMysql
|
|
11
|
-
isPostgres
|
|
8
|
+
url?: string;
|
|
9
|
+
isDebug?: boolean;
|
|
10
|
+
isPlanetScale?: boolean;
|
|
11
|
+
isMysql?: boolean;
|
|
12
|
+
isPostgres?: boolean;
|
|
13
|
+
casing?: "snake" | "camel";
|
|
14
|
+
pool?: {
|
|
15
|
+
max?: number;
|
|
16
|
+
idleTimeoutMs?: number;
|
|
17
|
+
connectTimeoutMs?: number;
|
|
18
|
+
};
|
|
12
19
|
};
|
|
13
20
|
declare const drizzleClient: <TClient = any>(key?: string, config?: DrizzleConfig) => Promise<DrizzleNamespace<TClient>>;
|
|
14
21
|
//#endregion
|
|
@@ -3,16 +3,16 @@ import { DrizzleNamespace } from "./DrizzleNamespace.mjs";
|
|
|
3
3
|
const drizzleNamespaces = /* @__PURE__ */ new Map();
|
|
4
4
|
const drizzleClient = async (key = "default", config) => {
|
|
5
5
|
if (drizzleNamespaces.has(key)) return drizzleNamespaces.get(key);
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
url
|
|
9
|
-
isDebug
|
|
10
|
-
isPlanetScale
|
|
11
|
-
isMysql
|
|
12
|
-
isPostgres
|
|
13
|
-
};
|
|
6
|
+
let finalConfig = config ?? {};
|
|
7
|
+
if (key === "default") {
|
|
8
|
+
finalConfig.url = process.env.DATABASE_URL;
|
|
9
|
+
finalConfig.isDebug = "true" === process.env.DATABASE_IS_DEBUG;
|
|
10
|
+
finalConfig.isPlanetScale = "true" === process.env.DATABASE_IS_PLANETSCALE;
|
|
11
|
+
finalConfig.isMysql = "true" === process.env.DATABASE_IS_MYSQL;
|
|
12
|
+
finalConfig.isPostgres = "true" === process.env.DATABASE_IS_POSTGRES;
|
|
13
|
+
} else if ("default" !== key && config) finalConfig = config;
|
|
14
14
|
else throw new Error(`Config required for namespace '${key}'`);
|
|
15
|
-
const namespace = new DrizzleNamespace(key,
|
|
15
|
+
const namespace = new DrizzleNamespace(key, finalConfig);
|
|
16
16
|
await namespace.ensureInit();
|
|
17
17
|
drizzleNamespaces.set(key, namespace);
|
|
18
18
|
return namespace;
|
|
@@ -19,7 +19,7 @@ const getEnvironment = () => {
|
|
|
19
19
|
else if (process.env.NEXT_PUBLIC_EMS_ENVIRONMENT) platformEnvironment = process.env.NEXT_PUBLIC_EMS_ENVIRONMENT;
|
|
20
20
|
else if (process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF) platformEnvironment = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF;
|
|
21
21
|
else if (process.env.VERCEL_GIT_COMMIT_REF) platformEnvironment = process.env.VERCEL_GIT_COMMIT_REF;
|
|
22
|
-
switch (platformEnvironment.toLowerCase().trim()) {
|
|
22
|
+
switch (String(platformEnvironment).toLowerCase().trim()) {
|
|
23
23
|
case "production":
|
|
24
24
|
response = environment.PRODUCTION;
|
|
25
25
|
break;
|
|
@@ -18,7 +18,7 @@ const getEnvironment = () => {
|
|
|
18
18
|
else if (process.env.NEXT_PUBLIC_EMS_ENVIRONMENT) platformEnvironment = process.env.NEXT_PUBLIC_EMS_ENVIRONMENT;
|
|
19
19
|
else if (process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF) platformEnvironment = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF;
|
|
20
20
|
else if (process.env.VERCEL_GIT_COMMIT_REF) platformEnvironment = process.env.VERCEL_GIT_COMMIT_REF;
|
|
21
|
-
switch (platformEnvironment.toLowerCase().trim()) {
|
|
21
|
+
switch (String(platformEnvironment).toLowerCase().trim()) {
|
|
22
22
|
case "production":
|
|
23
23
|
response = environment.PRODUCTION;
|
|
24
24
|
break;
|
|
@@ -11,7 +11,8 @@ var OnePasswordNamespace = class extends require__class_BaseNamespace.BaseNamesp
|
|
|
11
11
|
integrationVersion: this.config.integrationVersion || "v1.0.0"
|
|
12
12
|
});
|
|
13
13
|
} catch (e) {
|
|
14
|
-
throw new Error("
|
|
14
|
+
if (e instanceof Error) throw new Error("Error initialising 1Password client", e);
|
|
15
|
+
throw new Error("An unexpected error occurred during 1Password setup");
|
|
15
16
|
}
|
|
16
17
|
};
|
|
17
18
|
listVaults = async () => {
|
|
@@ -10,7 +10,8 @@ var OnePasswordNamespace = class extends BaseNamespace {
|
|
|
10
10
|
integrationVersion: this.config.integrationVersion || "v1.0.0"
|
|
11
11
|
});
|
|
12
12
|
} catch (e) {
|
|
13
|
-
throw new Error("
|
|
13
|
+
if (e instanceof Error) throw new Error("Error initialising 1Password client", e);
|
|
14
|
+
throw new Error("An unexpected error occurred during 1Password setup");
|
|
14
15
|
}
|
|
15
16
|
};
|
|
16
17
|
listVaults = async () => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@8ms/helpers",
|
|
3
3
|
"license": "UNLICENSED",
|
|
4
|
-
"version": "2.4.
|
|
4
|
+
"version": "2.4.17",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
|
|
@@ -42,7 +42,9 @@
|
|
|
42
42
|
"@prisma/client": "^7.0.0",
|
|
43
43
|
"drizzle-orm": "*",
|
|
44
44
|
"googleapis-common": "^8.0.0",
|
|
45
|
+
"mysql2": "^3.0.0",
|
|
45
46
|
"next": "^16.0.0",
|
|
47
|
+
"pg": "^8.0.0",
|
|
46
48
|
"react": "^19.0.0",
|
|
47
49
|
"react-intersection-observer": "^10.0.0",
|
|
48
50
|
"stream-chain": "^3.0.0",
|
|
@@ -124,9 +126,15 @@
|
|
|
124
126
|
"googleapis-common": {
|
|
125
127
|
"optional": true
|
|
126
128
|
},
|
|
129
|
+
"mysql2": {
|
|
130
|
+
"optional": true
|
|
131
|
+
},
|
|
127
132
|
"next": {
|
|
128
133
|
"optional": true
|
|
129
134
|
},
|
|
135
|
+
"pg": {
|
|
136
|
+
"optional": true
|
|
137
|
+
},
|
|
130
138
|
"react": {
|
|
131
139
|
"optional": true
|
|
132
140
|
},
|
|
@@ -165,7 +173,7 @@
|
|
|
165
173
|
"@prisma/adapter-planetscale": "^7.7.0",
|
|
166
174
|
"@prisma/client": "^7.7.0",
|
|
167
175
|
"@types/babel__core": "^7.20.5",
|
|
168
|
-
"@types/fs-extra": "11.0.4",
|
|
176
|
+
"@types/fs-extra": "^11.0.4",
|
|
169
177
|
"@types/jest": "30.0.0",
|
|
170
178
|
"@types/luxon": "3.7.1",
|
|
171
179
|
"@types/node": "^24.12.2",
|
|
@@ -173,18 +181,20 @@
|
|
|
173
181
|
"babel-jest": "30.3.0",
|
|
174
182
|
"dotenv": "^17.4.1",
|
|
175
183
|
"drizzle-orm": "beta",
|
|
176
|
-
"fs-extra": "11.3.4",
|
|
184
|
+
"fs-extra": "^11.3.4",
|
|
177
185
|
"googleapis-common": "^8.0.1",
|
|
178
|
-
"jest": "30.3.0",
|
|
186
|
+
"jest": "^30.3.0",
|
|
187
|
+
"mysql2": "^3.22.2",
|
|
179
188
|
"next": "^16.2.3",
|
|
180
|
-
"node-fetch": "3.3.2",
|
|
189
|
+
"node-fetch": "^3.3.2",
|
|
190
|
+
"pg": "^8.20.0",
|
|
181
191
|
"react": "^19.2.5",
|
|
182
192
|
"react-intersection-observer": "^10.0.3",
|
|
183
193
|
"stream-chain": "^3.6.1",
|
|
184
194
|
"swr": "^2.4.1",
|
|
185
|
-
"ts-node": "10.9.2",
|
|
195
|
+
"ts-node": "^10.9.2",
|
|
186
196
|
"tsdown": "^0.21.7",
|
|
187
|
-
"tslib": "2.8.
|
|
197
|
+
"tslib": "^2.8.0",
|
|
188
198
|
"typescript": "^6.0.2"
|
|
189
199
|
},
|
|
190
200
|
"exports": {
|