@8ms/helpers 2.3.16 → 2.3.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/.yarn/install-state.gz +0 -0
- package/dist/drizzle/server/index.d.mts +23 -0
- package/dist/drizzle/server/index.mjs +65 -0
- package/dist/googleCloud/bigquery/server/index.d.mts +1 -1
- package/dist/googleCloud/server/index.d.mts +1 -1
- package/dist/googleCloud/sheets/server/index.d.mts +1 -1
- package/dist/googleCloud/storage/server/index.d.mts +1 -1
- package/package.json +7 -1
- /package/dist/{index-jtr7o55v.d.mts → index-DmCSxHCc.d.mts} +0 -0
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { t as BaseNamespace } from "../../index-DwB8X1lz.mjs";
|
|
2
|
+
import { MySql2Database } from "drizzle-orm/mysql2";
|
|
3
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
4
|
+
import { PlanetScaleDatabase } from "drizzle-orm/planetscale-serverless";
|
|
5
|
+
|
|
6
|
+
//#region src/drizzle/server/DrizzleNamespace.d.ts
|
|
7
|
+
declare class DrizzleNamespace extends BaseNamespace {
|
|
8
|
+
client: MySql2Database<any> | NodePgDatabase<any> | PlanetScaleDatabase<any>;
|
|
9
|
+
config: DrizzleConfig;
|
|
10
|
+
ensureInit: () => Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/drizzle/server/drizzle.d.ts
|
|
14
|
+
type DrizzleConfig = {
|
|
15
|
+
url: string;
|
|
16
|
+
isDebug: boolean;
|
|
17
|
+
isPlanetScale: boolean;
|
|
18
|
+
isMysql: boolean;
|
|
19
|
+
isPostgres: boolean;
|
|
20
|
+
};
|
|
21
|
+
declare const drizzleClient: (key?: string, config?: DrizzleConfig) => Promise<DrizzleNamespace>;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { DrizzleConfig, DrizzleNamespace, drizzleClient };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { getError } from "../../util/index.mjs";
|
|
2
|
+
import { BaseNamespace } from "../../_class/index.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/drizzle/server/DrizzleNamespace.ts
|
|
5
|
+
var DrizzleNamespace = class extends BaseNamespace {
|
|
6
|
+
ensureInit = async () => {
|
|
7
|
+
if (!this.client) {
|
|
8
|
+
let logger = void 0;
|
|
9
|
+
if (this.config.isDebug) {
|
|
10
|
+
const { DefaultLogger } = await import("drizzle-orm/logger");
|
|
11
|
+
logger = new DefaultLogger();
|
|
12
|
+
}
|
|
13
|
+
if (this.config.isPlanetScale) try {
|
|
14
|
+
const { drizzle } = await import("drizzle-orm/planetscale-serverless");
|
|
15
|
+
this.client = drizzle({
|
|
16
|
+
connection: { url: this.config.url },
|
|
17
|
+
logger
|
|
18
|
+
});
|
|
19
|
+
} catch (e) {
|
|
20
|
+
throw new Error(`PlanetScale driver not installed - ${getError(e)}`);
|
|
21
|
+
}
|
|
22
|
+
else if (this.config.isMysql) try {
|
|
23
|
+
const { drizzle } = await import("drizzle-orm/mysql2");
|
|
24
|
+
this.client = drizzle({
|
|
25
|
+
connection: this.config.url,
|
|
26
|
+
logger
|
|
27
|
+
});
|
|
28
|
+
} catch (e) {
|
|
29
|
+
throw new Error(`MySQL2 driver not installed - ${getError(e)}`);
|
|
30
|
+
}
|
|
31
|
+
else if (this.config.isPostgres) try {
|
|
32
|
+
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
33
|
+
this.client = drizzle({
|
|
34
|
+
connection: this.config.url,
|
|
35
|
+
logger
|
|
36
|
+
});
|
|
37
|
+
} catch (e) {
|
|
38
|
+
throw new Error(`Postgres (pg) driver not installed - ${getError(e)}`);
|
|
39
|
+
}
|
|
40
|
+
else throw new Error(`No database type configured — set DATABASE_IS_PLANETSCALE, DATABASE_IS_MYSQL or DATABASE_IS_POSTGRES to "true"`);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/drizzle/server/drizzle.ts
|
|
47
|
+
const drizzleNamespaces = /* @__PURE__ */ new Map();
|
|
48
|
+
const drizzleClient = async (key = "default", config) => {
|
|
49
|
+
if (drizzleNamespaces.has(key)) return drizzleNamespaces.get(key);
|
|
50
|
+
if (!config) if (key === "default") config = {
|
|
51
|
+
url: process.env.DATABASE_URL,
|
|
52
|
+
isDebug: "true" === process.env.DATABASE_IS_DEBUG,
|
|
53
|
+
isPlanetScale: "true" === process.env.DATABASE_IS_PLANETSCALE,
|
|
54
|
+
isMysql: "true" === process.env.DATABASE_IS_MYSQL,
|
|
55
|
+
isPostgres: "true" === process.env.DATABASE_IS_POSTGRES
|
|
56
|
+
};
|
|
57
|
+
else throw new Error(`Config required for namespace '${key}'`);
|
|
58
|
+
const namespace = new DrizzleNamespace(key, config);
|
|
59
|
+
await namespace.ensureInit();
|
|
60
|
+
drizzleNamespaces.set(key, namespace);
|
|
61
|
+
return namespace;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { DrizzleNamespace, drizzleClient };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as BaseNamespace } from "../../../index-DwB8X1lz.mjs";
|
|
2
|
-
import { t as GoogleCloudConfig } from "../../../index-
|
|
2
|
+
import { t as GoogleCloudConfig } from "../../../index-DmCSxHCc.mjs";
|
|
3
3
|
import { BigQuery, DatasetResource, QueryOptions } from "@google-cloud/bigquery";
|
|
4
4
|
import { GoogleAuthOptions } from "@google-cloud/common";
|
|
5
5
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as getConfig, t as GoogleCloudConfig } from "../../index-
|
|
1
|
+
import { n as getConfig, t as GoogleCloudConfig } from "../../index-DmCSxHCc.mjs";
|
|
2
2
|
export { GoogleCloudConfig, getConfig };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as BaseNamespace } from "../../../index-DwB8X1lz.mjs";
|
|
2
|
-
import { t as GoogleCloudConfig } from "../../../index-
|
|
2
|
+
import { t as GoogleCloudConfig } from "../../../index-DmCSxHCc.mjs";
|
|
3
3
|
import * as _googleapis_sheets0 from "@googleapis/sheets";
|
|
4
4
|
import { GoogleAuth } from "googleapis-common";
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as BaseNamespace } from "../../../index-DwB8X1lz.mjs";
|
|
2
|
-
import { t as GoogleCloudConfig } from "../../../index-
|
|
2
|
+
import { t as GoogleCloudConfig } from "../../../index-DmCSxHCc.mjs";
|
|
3
3
|
import * as _google_cloud_storage0 from "@google-cloud/storage";
|
|
4
4
|
import { Storage } from "@google-cloud/storage";
|
|
5
5
|
import { GoogleAuthOptions } from "@google-cloud/common";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@8ms/helpers",
|
|
3
3
|
"license": "UNLICENSED",
|
|
4
|
-
"version": "2.3.
|
|
4
|
+
"version": "2.3.17",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"@prisma/adapter-pg": "^7.0.0",
|
|
42
42
|
"@prisma/adapter-planetscale": "^7.0.0",
|
|
43
43
|
"@prisma/client": "^7.0.0",
|
|
44
|
+
"drizzle-orm": "^0.45.1",
|
|
44
45
|
"fs-extra": "^11.0.0",
|
|
45
46
|
"google-ads-api": "^23.0.0",
|
|
46
47
|
"googleapis-common": "^8.0.0",
|
|
@@ -112,6 +113,9 @@
|
|
|
112
113
|
"@prisma/client": {
|
|
113
114
|
"optional": true
|
|
114
115
|
},
|
|
116
|
+
"drizzle-orm": {
|
|
117
|
+
"optional": true
|
|
118
|
+
},
|
|
115
119
|
"fs-extra": {
|
|
116
120
|
"optional": true
|
|
117
121
|
},
|
|
@@ -170,6 +174,7 @@
|
|
|
170
174
|
"@types/react": "^19.2.14",
|
|
171
175
|
"babel-jest": "30.2.0",
|
|
172
176
|
"dotenv": "^17.3.1",
|
|
177
|
+
"drizzle-orm": "^0.45.1",
|
|
173
178
|
"fs-extra": "11.3.3",
|
|
174
179
|
"google-ads-api": "^23.0.0",
|
|
175
180
|
"googleapis-common": "^8.0.0",
|
|
@@ -211,6 +216,7 @@
|
|
|
211
216
|
"./crud": "./dist/crud/index.mjs",
|
|
212
217
|
"./crypto": "./dist/crypto/index.mjs",
|
|
213
218
|
"./date": "./dist/date/index.mjs",
|
|
219
|
+
"./drizzle/server": "./dist/drizzle/server/index.mjs",
|
|
214
220
|
"./environment": "./dist/environment/index.mjs",
|
|
215
221
|
"./eskimi": "./dist/eskimi/index.mjs",
|
|
216
222
|
"./eskimi/server": "./dist/eskimi/server/index.mjs",
|
|
File without changes
|