@8ms/helpers 2.3.15 → 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/aws/s3/server/index.mjs +2 -2
- package/dist/axios/index.mjs +4 -4
- 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/dist/lodash/index.d.mts +4 -1
- package/dist/lodash/index.mjs +5 -1
- package/dist/url/server/index.mjs +2 -2
- 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
|
|
@@ -4,7 +4,7 @@ import { getFolder, getStringFromStream } from "../../../string/index.mjs";
|
|
|
4
4
|
import { n as isResponse200, t as getConfig } from "../../../server-Bwy4JI8Z.mjs";
|
|
5
5
|
import { getBrotliCompressed, getBrotliDecompressed, getGzipCompressed, getGzipDecompressed } from "../../../util/server/index.mjs";
|
|
6
6
|
import { z } from "zod/v4";
|
|
7
|
-
import
|
|
7
|
+
import axios from "axios";
|
|
8
8
|
|
|
9
9
|
//#region src/aws/s3/server/AwsS3Namespace.ts
|
|
10
10
|
var AwsS3Namespace = class extends BaseNamespace {
|
|
@@ -293,7 +293,7 @@ var AwsS3Namespace = class extends BaseNamespace {
|
|
|
293
293
|
*/
|
|
294
294
|
urlContents = async (bucket, key, url) => {
|
|
295
295
|
await this.ensureInit();
|
|
296
|
-
return
|
|
296
|
+
return axios(url, {
|
|
297
297
|
responseType: "arraybuffer",
|
|
298
298
|
responseEncoding: "binary"
|
|
299
299
|
}).then(async (response) => {
|
package/dist/axios/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { u as ApiResponseClass } from "../api-DGKJDAfb.mjs";
|
|
2
|
-
import
|
|
2
|
+
import axios from "axios";
|
|
3
3
|
|
|
4
4
|
//#region src/axios/deleteRequest.ts
|
|
5
5
|
/**
|
|
@@ -7,7 +7,7 @@ import get$1 from "axios";
|
|
|
7
7
|
* Can't use the function name delete as it's reserved
|
|
8
8
|
*/
|
|
9
9
|
const deleteRequest = async (url, config = {}) => {
|
|
10
|
-
return await
|
|
10
|
+
return await axios.delete(url, config).then(async (response) => {
|
|
11
11
|
if (void 0 !== response.data.body && void 0 !== response.data.error && void 0 !== response.data.state) return new ApiResponseClass(response.data);
|
|
12
12
|
else if (response.status >= 200 && response.status <= 299) return new ApiResponseClass().setToSuccess(response.data);
|
|
13
13
|
return new ApiResponseClass().setToError(response.data, response.statusText);
|
|
@@ -22,7 +22,7 @@ const deleteRequest = async (url, config = {}) => {
|
|
|
22
22
|
* Make a GET request.
|
|
23
23
|
*/
|
|
24
24
|
const get = async (url, config = {}) => {
|
|
25
|
-
return await
|
|
25
|
+
return await axios.get(url, config).then(async (response) => {
|
|
26
26
|
if (void 0 !== response.data.body && void 0 !== response.data.error && void 0 !== response.data.state) return new ApiResponseClass(response.data);
|
|
27
27
|
else if (response.status >= 200 && response.status <= 299) return new ApiResponseClass().setToSuccess(response.data);
|
|
28
28
|
return new ApiResponseClass().setToError(response.data, response.statusText);
|
|
@@ -37,7 +37,7 @@ const get = async (url, config = {}) => {
|
|
|
37
37
|
* Make a POST request.
|
|
38
38
|
*/
|
|
39
39
|
const post = async (url, data = {}, config = {}) => {
|
|
40
|
-
return await
|
|
40
|
+
return await axios.post(url, data, config).then(async (response) => {
|
|
41
41
|
if (void 0 !== response.data.body && void 0 !== response.data.error && void 0 !== response.data.state) return new ApiResponseClass(response.data);
|
|
42
42
|
else if (response.status >= 200 && response.status <= 299) return new ApiResponseClass().setToSuccess(response.data);
|
|
43
43
|
return new ApiResponseClass().setToError(response.data, response.statusText);
|
|
@@ -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/dist/lodash/index.d.mts
CHANGED
|
@@ -19,6 +19,9 @@ declare const isEmpty: (value: unknown) => boolean;
|
|
|
19
19
|
//#region src/lodash/isEqual.d.ts
|
|
20
20
|
declare const isEqual: (a: unknown, b: unknown) => boolean;
|
|
21
21
|
//#endregion
|
|
22
|
+
//#region src/lodash/isFunction.d.ts
|
|
23
|
+
declare const isFunction: (value: any) => value is Function;
|
|
24
|
+
//#endregion
|
|
22
25
|
//#region src/lodash/isObject.d.ts
|
|
23
26
|
declare const isObject: (value: unknown) => value is object;
|
|
24
27
|
//#endregion
|
|
@@ -39,4 +42,4 @@ declare const uniq: (arr: any[]) => any[];
|
|
|
39
42
|
//#region src/lodash/uniqBy.d.ts
|
|
40
43
|
declare const uniqBy: <T>(collection: T[], iteratee: ((item: T) => unknown) | string) => T[];
|
|
41
44
|
//#endregion
|
|
42
|
-
export { chunk, flatten, isDate, isEmpty, isEqual, isObject, merge, orderBy, set, trim, unescape, uniq, uniqBy };
|
|
45
|
+
export { chunk, flatten, isDate, isEmpty, isEqual, isFunction, isObject, merge, orderBy, set, trim, unescape, uniq, uniqBy };
|
package/dist/lodash/index.mjs
CHANGED
|
@@ -84,6 +84,10 @@ const isEqual = (a, b) => {
|
|
|
84
84
|
return false;
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/lodash/isFunction.ts
|
|
89
|
+
const isFunction = (value) => typeof value === "function";
|
|
90
|
+
|
|
87
91
|
//#endregion
|
|
88
92
|
//#region src/lodash/isObject.ts
|
|
89
93
|
const isObject = (value) => {
|
|
@@ -169,4 +173,4 @@ const uniqBy = (collection, iteratee) => {
|
|
|
169
173
|
};
|
|
170
174
|
|
|
171
175
|
//#endregion
|
|
172
|
-
export { chunk, flatten, isDate, isEmpty, isEqual, isObject, merge, orderBy, set, trim, unescape, uniq, uniqBy };
|
|
176
|
+
export { chunk, flatten, isDate, isEmpty, isEqual, isFunction, isObject, merge, orderBy, set, trim, unescape, uniq, uniqBy };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createDirectory } from "../../file/server/index.mjs";
|
|
2
|
-
import
|
|
2
|
+
import axios from "axios";
|
|
3
3
|
|
|
4
4
|
//#region src/url/server/writeUrlContents.ts
|
|
5
5
|
/**
|
|
@@ -11,7 +11,7 @@ const writeUrlContents = async (filePath, url) => {
|
|
|
11
11
|
const fs = await import("fs-extra");
|
|
12
12
|
await createDirectory(filePath);
|
|
13
13
|
const writer = fs.createWriteStream(filePath);
|
|
14
|
-
await
|
|
14
|
+
await axios({
|
|
15
15
|
method: "get",
|
|
16
16
|
url,
|
|
17
17
|
responseType: "stream"
|
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
|