@8ms/helpers 2.1.3 → 2.2.9

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.
@@ -5,28 +5,33 @@ on:
5
5
  jobs:
6
6
  publish:
7
7
  runs-on: ubuntu-latest
8
+ permissions:
9
+ contents: read
10
+
8
11
  steps:
9
12
  - uses: actions/checkout@v4.2.1
10
13
 
11
14
  - name: Enable Corepack
12
15
  run: corepack enable
13
16
 
14
- - uses: actions/setup-node@v4.0.4
17
+ - name: Install pnpm
18
+ uses: pnpm/action-setup@v4
15
19
  with:
16
- node-version: 20
17
- cache: 'yarn'
18
-
19
- - run: yarn set version berry
20
+ run_install: false
20
21
 
21
- # Install ALL dependencies (including devDependencies with TypeScript)
22
- - run: yarn install --immutable
22
+ - uses: actions/setup-node@v4.0.4
23
+ with:
24
+ node-version: 24
25
+ cache: 'pnpm'
26
+ registry-url: 'https://registry.npmjs.org'
23
27
 
24
- # Build the project (TypeScript now available)
25
- - run: yarn build
28
+ - name: Install dependencies
29
+ run: pnpm install --frozen-lockfile
26
30
 
27
- # Optional: prune to production-only after build
28
- - run: yarn workspaces focus --production
31
+ - name: Build
32
+ run: pnpm build
29
33
 
30
- - uses: JS-DevTools/npm-publish@v3.1.1
31
- with:
32
- token: ${{ secrets.NPM_TOKEN }}
34
+ - name: Publish to npm
35
+ run: npm publish --access public
36
+ env:
37
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -275,6 +275,7 @@ class SimpleEmail extends _class_1.BaseClass {
275
275
  "pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
276
276
  // Data
277
277
  "csv": "text/csv",
278
+ "tsv": "text/tab-separated-values",
278
279
  "json": "application/json",
279
280
  "xml": "application/xml",
280
281
  "txt": "text/plain",
package/package.json CHANGED
@@ -1,187 +1,197 @@
1
1
  {
2
- "name": "@8ms/helpers",
3
- "license": "UNLICENSED",
4
- "version": "2.1.3",
5
- "repository": {
2
+ "name": "@8ms/helpers",
3
+ "license": "UNLICENSED",
4
+ "version": "2.2.9",
5
+ "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
7
+ "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
8
8
  },
9
- "main": "index.js",
10
- "types": "index.d.ts",
11
- "scripts": {
9
+ "main": "index.js",
10
+ "types": "index.d.ts",
11
+ "scripts": {
12
12
  "build": "tsc",
13
- "jest": "jest --watch"
13
+ "jest": "jest --watch"
14
14
  },
15
- "engines": {
16
- "node": "22"
15
+ "packageManager": "pnpm@9.15.0",
16
+ "engines": {
17
+ "node": "24"
17
18
  },
18
- "dependencies": {
19
- "axios": "^1.9.0",
20
- "lodash": "^4.17.21",
21
- "luxon": "^3.6.1",
22
- "zod": "^4.0.5"
19
+ "dependencies": {
20
+ "axios": "^1.13.5",
21
+ "lodash": "^4.17.23",
22
+ "luxon": "^3.7.2",
23
+ "zod": "^4.3.6"
23
24
  },
24
- "peerDependencies": {
25
- "@1password/sdk": "<1.0.0",
26
- "@aws-sdk/client-ec2": "^3.0.0",
27
- "@aws-sdk/client-ecs": "^3.0.0",
28
- "@aws-sdk/client-glue": "^3.0.0",
29
- "@aws-sdk/client-lambda": "^3.0.0",
30
- "@aws-sdk/client-s3": "^3.0.0",
31
- "@aws-sdk/client-ses": "^3.0.0",
32
- "@aws-sdk/client-sqs": "^3.0.0",
33
- "@aws-sdk/client-ssm": "^3.0.0",
34
- "@aws-sdk/lib-storage": "^3.0.0",
25
+ "peerDependencies": {
26
+ "@1password/sdk": "<1.0.0",
27
+ "@aws-sdk/client-ec2": "^3.0.0",
28
+ "@aws-sdk/client-ecs": "^3.0.0",
29
+ "@aws-sdk/client-glue": "^3.0.0",
30
+ "@aws-sdk/client-lambda": "^3.0.0",
31
+ "@aws-sdk/client-s3": "^3.0.0",
32
+ "@aws-sdk/client-ses": "^3.0.0",
33
+ "@aws-sdk/client-sqs": "^3.0.0",
34
+ "@aws-sdk/client-ssm": "^3.0.0",
35
+ "@aws-sdk/lib-storage": "^3.0.0",
35
36
  "@aws-sdk/s3-request-presigner": "^3.0.0",
36
- "@google-cloud/bigquery": "^8.0.0",
37
- "@google-cloud/storage": "^7.0.0",
38
- "@googleapis/sheets": "^11.0.0",
39
- "@planetscale/database": "^1.0.0",
40
- "@prisma/adapter-planetscale": "^6.0.0",
41
- "@prisma/client": "^6.0.0",
42
- "athena-express": "^7.0.0",
43
- "aws-sdk": "^2.0.0",
44
- "crypto-js": "^4.0.0",
45
- "fs-extra": "^11.0.0",
46
- "google-ads-api": "^20.0.0",
47
- "next": "^15.0.0",
48
- "react": "^19.0.0",
49
- "react-intersection-observer": "^9.0.0",
50
- "stream-chain": "^3.0.0",
51
- "stream-json": "^1.0.0",
52
- "swr": "^2.0.0"
37
+ "@google-cloud/bigquery": "^8.0.0",
38
+ "@google-cloud/common": "^6.0.0",
39
+ "@google-cloud/storage": "^7.0.0",
40
+ "@googleapis/sheets": "^13.0.0",
41
+ "@planetscale/database": "^1.0.0",
42
+ "@prisma/adapter-mariadb": "^7.0.0",
43
+ "@prisma/adapter-pg": "^7.0.0",
44
+ "@prisma/adapter-planetscale": "^7.0.0",
45
+ "@prisma/client": "^7.0.0",
46
+ "crypto-js": "^4.0.0",
47
+ "fs-extra": "^11.0.0",
48
+ "google-ads-api": "^23.0.0",
49
+ "googleapis-common": "^8.0.0",
50
+ "next": "^16.0.0",
51
+ "react": "^19.0.0",
52
+ "react-intersection-observer": "^10.0.0",
53
+ "stream-chain": "^3.0.0",
54
+ "stream-json": "^1.0.0",
55
+ "swr": "^2.0.0"
53
56
  },
54
57
  "peerDependenciesMeta": {
55
- "@1password/sdk": {
58
+ "@1password/sdk": {
56
59
  "optional": true
57
60
  },
58
- "@aws-sdk/client-ec2": {
61
+ "@aws-sdk/client-ec2": {
59
62
  "optional": true
60
63
  },
61
- "@aws-sdk/client-ecs": {
64
+ "@aws-sdk/client-ecs": {
62
65
  "optional": true
63
66
  },
64
- "@aws-sdk/client-glue": {
67
+ "@aws-sdk/client-glue": {
65
68
  "optional": true
66
69
  },
67
- "@aws-sdk/client-lambda": {
70
+ "@aws-sdk/client-lambda": {
68
71
  "optional": true
69
72
  },
70
- "@aws-sdk/client-s3": {
73
+ "@aws-sdk/client-s3": {
71
74
  "optional": true
72
75
  },
73
- "@aws-sdk/client-ses": {
76
+ "@aws-sdk/client-ses": {
74
77
  "optional": true
75
78
  },
76
- "@aws-sdk/client-sqs": {
79
+ "@aws-sdk/client-sqs": {
77
80
  "optional": true
78
81
  },
79
- "@aws-sdk/client-ssm": {
82
+ "@aws-sdk/client-ssm": {
80
83
  "optional": true
81
84
  },
82
- "@aws-sdk/lib-storage": {
85
+ "@aws-sdk/lib-storage": {
83
86
  "optional": true
84
87
  },
85
88
  "@aws-sdk/s3-request-presigner": {
86
89
  "optional": true
87
90
  },
88
- "@google-cloud/bigquery": {
91
+ "@google-cloud/bigquery": {
89
92
  "optional": true
90
93
  },
91
- "@google-cloud/storage": {
94
+ "@google-cloud/common": {
92
95
  "optional": true
93
96
  },
94
- "@googleapis/sheets": {
97
+ "@google-cloud/storage": {
95
98
  "optional": true
96
99
  },
97
- "@planetscale/database": {
100
+ "@googleapis/sheets": {
98
101
  "optional": true
99
102
  },
100
- "@prisma/adapter-planetscale": {
103
+ "@planetscale/database": {
101
104
  "optional": true
102
105
  },
103
- "@prisma/client": {
106
+ "@prisma/adapter-mariadb": {
104
107
  "optional": true
105
108
  },
106
- "athena-express": {
109
+ "@prisma/adapter-pg": {
107
110
  "optional": true
108
111
  },
109
- "aws-sdk": {
112
+ "@prisma/adapter-planetscale": {
110
113
  "optional": true
111
114
  },
112
- "crypto-js": {
115
+ "@prisma/client": {
113
116
  "optional": true
114
117
  },
115
- "fs-extra": {
118
+ "crypto-js": {
116
119
  "optional": true
117
120
  },
118
- "google-ads-api": {
121
+ "fs-extra": {
119
122
  "optional": true
120
123
  },
121
- "next": {
124
+ "google-ads-api": {
122
125
  "optional": true
123
126
  },
124
- "react": {
127
+ "googleapis-common": {
125
128
  "optional": true
126
129
  },
127
- "stream-chain": {
130
+ "next": {
128
131
  "optional": true
129
132
  },
130
- "stream-json": {
133
+ "react": {
131
134
  "optional": true
132
135
  },
133
- "swr": {
136
+ "stream-chain": {
137
+ "optional": true
138
+ },
139
+ "stream-json": {
140
+ "optional": true
141
+ },
142
+ "swr": {
134
143
  "optional": true
135
144
  }
136
145
  },
137
- "devDependencies": {
138
- "@1password/sdk": "<1.0.0",
139
- "@aws-sdk/client-ec2": "^3.0.0",
140
- "@aws-sdk/client-ecs": "^3.0.0",
141
- "@aws-sdk/client-glue": "^3.0.0",
142
- "@aws-sdk/client-lambda": "^3.0.0",
143
- "@aws-sdk/client-s3": "^3.0.0",
144
- "@aws-sdk/client-ses": "^3.0.0",
145
- "@aws-sdk/client-sqs": "^3.0.0",
146
- "@aws-sdk/client-ssm": "^3.0.0",
147
- "@aws-sdk/lib-storage": "^3.0.0",
148
- "@aws-sdk/s3-request-presigner": "^3.0.0",
149
- "@babel/core": "7.27.4",
150
- "@babel/preset-env": "7.27.2",
151
- "@babel/preset-flow": "7.27.1",
152
- "@babel/preset-typescript": "7.27.1",
153
- "@google-cloud/bigquery": "^8.0.0",
154
- "@google-cloud/storage": "^7.0.0",
155
- "@googleapis/sheets": "^11.0.0",
156
- "@planetscale/database": "^1.0.0",
157
- "@prisma/adapter-planetscale": "^6.0.0",
158
- "@prisma/client": "^6.0.0",
159
- "@types/babel__core": "7",
160
- "@types/crypto-js": "^4.0.0",
161
- "@types/fs-extra": "11.0.4",
162
- "@types/jest": "30.0.0",
163
- "@types/lodash": "4.17.20",
164
- "@types/luxon": "3.6.2",
165
- "@types/node": "22.16.3",
166
- "@types/react": "19",
167
- "athena-express": "^7.0.0",
168
- "aws-sdk": "^2.0.0",
169
- "babel-jest": "30.0.0",
170
- "crypto-js": "^4.0.0",
171
- "dotenv": "^17.0.0",
172
- "fs-extra": "11.3.0",
173
- "google-ads-api": "^20.0.0",
174
- "jest": "30.0.4",
175
- "next": "^15.0.0",
176
- "node-fetch": "3.3.2",
177
- "react": "^19.0.0",
178
- "react-intersection-observer": "^9.0.0",
179
- "stream-chain": "^3.0.0",
180
- "stream-json": "^1.9.0",
181
- "swr": "^2.0.0",
182
- "ts-node": "10.9.2",
183
- "tslib": "2.8.1",
184
- "typescript": "^5.0.0"
185
- },
186
- "packageManager": "yarn@4.9.4"
146
+ "devDependencies": {
147
+ "@1password/sdk": "^0.4.0",
148
+ "@aws-sdk/client-ec2": "^3.992.0",
149
+ "@aws-sdk/client-ecs": "^3.992.0",
150
+ "@aws-sdk/client-glue": "^3.992.0",
151
+ "@aws-sdk/client-lambda": "^3.992.0",
152
+ "@aws-sdk/client-s3": "^3.992.0",
153
+ "@aws-sdk/client-ses": "^3.992.0",
154
+ "@aws-sdk/client-sqs": "^3.992.0",
155
+ "@aws-sdk/client-ssm": "^3.992.0",
156
+ "@aws-sdk/lib-storage": "^3.992.0",
157
+ "@aws-sdk/s3-request-presigner": "^3.992.0",
158
+ "@babel/core": "7.29.0",
159
+ "@babel/preset-env": "7.29.0",
160
+ "@babel/preset-flow": "7.27.1",
161
+ "@babel/preset-typescript": "7.28.5",
162
+ "@google-cloud/bigquery": "^8.1.1",
163
+ "@google-cloud/common": "^6.0.0",
164
+ "@google-cloud/storage": "^7.19.0",
165
+ "@googleapis/sheets": "^13.0.1",
166
+ "@planetscale/database": "^1.19.0",
167
+ "@prisma/adapter-mariadb": "^7.4.0",
168
+ "@prisma/adapter-pg": "^7.4.0",
169
+ "@prisma/adapter-planetscale": "^7.4.0",
170
+ "@prisma/client": "^7.4.0",
171
+ "@types/babel__core": "^7.20.5",
172
+ "@types/crypto-js": "^4.2.2",
173
+ "@types/fs-extra": "11.0.4",
174
+ "@types/jest": "30.0.0",
175
+ "@types/lodash": "^4.17.23",
176
+ "@types/luxon": "3.7.1",
177
+ "@types/node": "^24.10.13",
178
+ "@types/react": "^19.2.14",
179
+ "babel-jest": "30.2.0",
180
+ "crypto-js": "^4.2.0",
181
+ "dotenv": "^17.3.1",
182
+ "fs-extra": "11.3.3",
183
+ "google-ads-api": "^23.0.0",
184
+ "googleapis-common": "^8.0.0",
185
+ "jest": "30.2.0",
186
+ "next": "^16.1.6",
187
+ "node-fetch": "3.3.2",
188
+ "react": "^19.2.4",
189
+ "react-intersection-observer": "^10.0.2",
190
+ "stream-chain": "^3.4.0",
191
+ "stream-json": "^1.9.1",
192
+ "swr": "^2.4.0",
193
+ "ts-node": "10.9.2",
194
+ "tslib": "2.8.1",
195
+ "typescript": "^5.9.3"
196
+ }
187
197
  }
@@ -1,8 +1,8 @@
1
- import { PrismaConfig } from "./server";
1
+ import type { PrismaConfig } from "./server";
2
2
  import { BaseNamespace } from "../_class";
3
- import type { PrismaClient } from "@prisma/client";
3
+ import type { PrismaClientLike } from "./server";
4
4
  export declare class PrismaNamespace extends BaseNamespace {
5
- client: PrismaClient;
5
+ client: PrismaClientLike;
6
6
  config: PrismaConfig;
7
7
  ensureInit: () => Promise<void>;
8
8
  }
@@ -42,39 +42,54 @@ class PrismaNamespace extends _class_1.BaseNamespace {
42
42
  // Async setup to only initialise where required
43
43
  this.ensureInit = async () => {
44
44
  if (!this.client) {
45
- let planetScaleAdapter = null;
45
+ let adapter = null;
46
46
  if (this.config.isPlanetScale) {
47
47
  try {
48
48
  const { PrismaPlanetScale } = await Promise.resolve().then(() => __importStar(require("@prisma/adapter-planetscale")));
49
- planetScaleAdapter = new PrismaPlanetScale({
49
+ adapter = new PrismaPlanetScale({
50
50
  url: this.config.url,
51
51
  });
52
52
  }
53
53
  catch (e) {
54
- throw new Error(`PlanetScale Client not installed - ${(0, getError_1.getError)(e)}`);
54
+ throw new Error(`PlanetScale adapter not installed - ${(0, getError_1.getError)(e)}`);
55
+ }
56
+ }
57
+ if (this.config.isMysql) {
58
+ try {
59
+ const { PrismaMariaDb } = await Promise.resolve().then(() => __importStar(require("@prisma/adapter-mariadb")));
60
+ adapter = new PrismaMariaDb(this.config.url);
61
+ }
62
+ catch (e) {
63
+ throw new Error(`MariaDB adapter not installed - ${(0, getError_1.getError)(e)}`);
64
+ }
65
+ }
66
+ else {
67
+ // Prisma v7 requires a driver adapter — use the one matching your database
68
+ // e.g. @prisma/adapter-pg for Postgres, @prisma/adapter-mysql2 for MySQL
69
+ try {
70
+ const { PrismaPg } = await Promise.resolve().then(() => __importStar(require("@prisma/adapter-pg")));
71
+ adapter = new PrismaPg({
72
+ connectionString: process.env.DATABASE_URL,
73
+ });
74
+ }
75
+ catch (e) {
76
+ throw new Error(`Postgres adapter not installed - ${(0, getError_1.getError)(e)}`);
55
77
  }
56
78
  }
57
79
  try {
58
- const { PrismaClient } = await Promise.resolve().then(() => __importStar(require("@prisma/client")));
80
+ // In Prisma v7, the client is generated to a custom output path
81
+ // @ts-ignore
82
+ const { PrismaClient } = await Promise.resolve().then(() => __importStar(require("../../generated/prisma/client")));
59
83
  // Show the full query if debugging
60
84
  if (this.config.isDebug) {
61
85
  this.client = new PrismaClient({
62
- adapter: planetScaleAdapter,
63
- datasourceUrl: planetScaleAdapter ? undefined : this.config.url,
64
- log: [
65
- {
66
- emit: "event",
67
- level: "query",
68
- },
69
- ],
86
+ adapter,
87
+ log: [{ emit: "event", level: "query" }],
70
88
  });
71
89
  }
72
90
  // Standard prisma
73
91
  else {
74
- this.client = new PrismaClient({
75
- adapter: planetScaleAdapter,
76
- datasourceUrl: planetScaleAdapter ? undefined : this.config.url,
77
- });
92
+ this.client = new PrismaClient({ adapter });
78
93
  }
79
94
  }
80
95
  catch (e) {
@@ -85,4 +100,3 @@ class PrismaNamespace extends _class_1.BaseNamespace {
85
100
  }
86
101
  }
87
102
  exports.PrismaNamespace = PrismaNamespace;
88
- ;
@@ -3,6 +3,19 @@ export type PrismaConfig = {
3
3
  url: string;
4
4
  isDebug: boolean;
5
5
  isPlanetScale: boolean;
6
+ isMysql: boolean;
7
+ isPostgres: boolean;
6
8
  };
9
+ /**
10
+ * Minimal interface representing a Prisma Client instance.
11
+ * Consumers of this library will have their own generated PrismaClient
12
+ * that satisfies this interface.
13
+ */
14
+ export interface PrismaClientLike {
15
+ $connect(): Promise<void>;
16
+ $disconnect(): Promise<void>;
17
+ $transaction(...args: any[]): Promise<any>;
18
+ [key: string]: any;
19
+ }
7
20
  export declare const prismaClient: (key?: string, config?: PrismaConfig) => Promise<PrismaNamespace>;
8
21
  export { getDecimal } from "./getDecimal";
package/prisma/server.js CHANGED
@@ -14,6 +14,8 @@ const prismaClient = async (key = "default", config) => {
14
14
  url: process.env.DATABASE_URL,
15
15
  isDebug: 'true' === process.env.DATABASE_IS_DEBUG,
16
16
  isPlanetScale: 'true' === process.env.DATABASE_IS_PLANETSCALE,
17
+ isMysql: 'true' === process.env.DATABASE_IS_MYSQL,
18
+ isPostgres: 'true' === process.env.DATABASE_IS_POSTGRES,
17
19
  };
18
20
  }
19
21
  else {
Binary file