@8ms/helpers 3.0.9 → 3.0.11

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.
Files changed (37) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +0 -2
  2. package/dist/_virtual/_rolldown/runtime.mjs +1 -22
  3. package/dist/aws/ses/server/SimpleEmail.cjs +12 -9
  4. package/dist/aws/ses/server/SimpleEmail.d.cts +3 -31
  5. package/dist/aws/ses/server/SimpleEmail.d.mts +3 -31
  6. package/dist/aws/ses/server/SimpleEmail.mjs +12 -9
  7. package/dist/date/index.cjs +1 -1
  8. package/dist/date/index.mjs +1 -1
  9. package/dist/prisma/server/{PrismaNamespace.cjs → Prisma.cjs} +12 -10
  10. package/dist/prisma/server/{prisma.d.mts → Prisma.d.cts} +15 -11
  11. package/dist/prisma/server/{prisma.d.cts → Prisma.d.mts} +15 -11
  12. package/dist/prisma/server/{PrismaNamespace.mjs → Prisma.mjs} +12 -10
  13. package/dist/prisma/server/index.cjs +2 -4
  14. package/dist/prisma/server/index.d.cts +2 -3
  15. package/dist/prisma/server/index.d.mts +2 -3
  16. package/dist/prisma/server/index.mjs +2 -3
  17. package/package.json +5 -16
  18. package/dist/node_modules/data-uri-to-buffer/dist/index.cjs +0 -37
  19. package/dist/node_modules/data-uri-to-buffer/dist/index.mjs +0 -37
  20. package/dist/node_modules/fetch-blob/file.cjs +0 -31
  21. package/dist/node_modules/fetch-blob/file.mjs +0 -31
  22. package/dist/node_modules/fetch-blob/from.cjs +0 -8
  23. package/dist/node_modules/fetch-blob/from.mjs +0 -9
  24. package/dist/node_modules/fetch-blob/index.cjs +0 -171
  25. package/dist/node_modules/fetch-blob/index.mjs +0 -172
  26. package/dist/node_modules/fetch-blob/streams.cjs +0 -45
  27. package/dist/node_modules/fetch-blob/streams.mjs +0 -41
  28. package/dist/node_modules/formdata-polyfill/esm.min.cjs +0 -83
  29. package/dist/node_modules/formdata-polyfill/esm.min.mjs +0 -82
  30. package/dist/node_modules/node-domexception/index.cjs +0 -18
  31. package/dist/node_modules/node-domexception/index.mjs +0 -15
  32. package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs +0 -3499
  33. package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.mjs +0 -3496
  34. package/dist/prisma/server/PrismaNamespace.d.cts +0 -11
  35. package/dist/prisma/server/PrismaNamespace.d.mts +0 -11
  36. package/dist/prisma/server/prisma.cjs +0 -21
  37. package/dist/prisma/server/prisma.mjs +0 -20
@@ -5,7 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
9
8
  var __copyProps = (to, from, except, desc) => {
10
9
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
10
  key = keys[i];
@@ -21,5 +20,4 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
20
  enumerable: true
22
21
  }) : target, mod));
23
22
  //#endregion
24
- exports.__commonJSMin = __commonJSMin;
25
23
  exports.__toESM = __toESM;
@@ -1,26 +1,5 @@
1
1
  import { createRequire } from "node:module";
2
2
  //#region \0rolldown/runtime.js
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
- key = keys[i];
13
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
21
- value: mod,
22
- enumerable: true
23
- }) : target, mod));
24
3
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
25
4
  //#endregion
26
- export { __commonJSMin, __require, __toESM };
5
+ export { __require };
@@ -39,7 +39,7 @@ var SimpleEmail = class extends require__class_BaseClass.BaseClass {
39
39
  this.attachments.push(attachment);
40
40
  return this;
41
41
  };
42
- addAttachmentFromdata = (filename, data, contentType) => {
42
+ addAttachmentFromData = (filename, data, contentType) => {
43
43
  return this.addAttachment({
44
44
  filename,
45
45
  data,
@@ -87,19 +87,19 @@ var SimpleEmail = class extends require__class_BaseClass.BaseClass {
87
87
  Body: {
88
88
  Html: {
89
89
  Charset: "UTF-8",
90
- Data: this.html
90
+ Data: this.html ?? ""
91
91
  },
92
92
  Text: {
93
93
  Charset: "UTF-8",
94
- Data: this.html
94
+ Data: this.html ?? ""
95
95
  }
96
96
  },
97
97
  Subject: {
98
98
  Charset: "UTF-8",
99
- Data: this.subject
99
+ Data: this.subject ?? ""
100
100
  }
101
101
  },
102
- Source: this.from
102
+ Source: this.from ?? ""
103
103
  };
104
104
  };
105
105
  _getRawEmailParams = async () => {
@@ -138,8 +138,8 @@ var SimpleEmail = class extends require__class_BaseClass.BaseClass {
138
138
  rawMessage += `--${boundary}--\r\n`;
139
139
  return {
140
140
  Destinations: allRecipients,
141
- RawMessage: { Data: rawMessage },
142
- Source: this.from
141
+ RawMessage: { Data: Buffer.from(rawMessage) },
142
+ Source: this.from ?? ""
143
143
  };
144
144
  };
145
145
  _isTextFile = (contentType) => {
@@ -158,7 +158,7 @@ var SimpleEmail = class extends require__class_BaseClass.BaseClass {
158
158
  if (this._isBase64(base64Data)) return Buffer.from(base64Data, "base64").toString("utf-8");
159
159
  return attachment.data;
160
160
  }
161
- if (attachment.url) return await (await (await Promise.resolve().then(() => require("../../../node_modules/node-fetch/src/index.cjs")).then((mod) => mod.default))(attachment.url)).text();
161
+ if (attachment.url) return await (await fetch(attachment.url)).text();
162
162
  throw new Error(`No valid data source provided for attachment: ${attachment.filename}`);
163
163
  };
164
164
  _getAttachmentData = async (attachment) => {
@@ -167,7 +167,10 @@ var SimpleEmail = class extends require__class_BaseClass.BaseClass {
167
167
  if (this._isBase64(cleanData)) return cleanData;
168
168
  return Buffer.from(attachment.data, "utf-8").toString("base64");
169
169
  }
170
- if (attachment.url) return (await (await (await Promise.resolve().then(() => require("../../../node_modules/node-fetch/src/index.cjs")).then((mod) => mod.default))(attachment.url)).buffer()).toString("base64");
170
+ if (attachment.url) {
171
+ const blobBytes = await (await fetch(attachment.url)).bytes();
172
+ return Buffer.from(blobBytes).toString("base64");
173
+ }
171
174
  throw new Error(`No valid data source provided for attachment: ${attachment.filename}`);
172
175
  };
173
176
  _isBase64 = (str) => {
@@ -1,4 +1,5 @@
1
1
  import { BaseClass } from "../../../_class/BaseClass.cjs";
2
+ import { SendEmailCommandInput, SendRawEmailCommandInput } from "@aws-sdk/client-ses";
2
3
 
3
4
  //#region src/aws/ses/server/SimpleEmail.d.ts
4
5
  type AttachmentSource = {
@@ -41,7 +42,7 @@ declare class SimpleEmail extends BaseClass {
41
42
  setSubject: (subject: string) => this;
42
43
  setAttachments: (attachments: AttachmentSource[]) => this;
43
44
  addAttachment: (attachment: AttachmentSource) => this;
44
- addAttachmentFromdata: (filename: string, data: string, contentType?: string) => this;
45
+ addAttachmentFromData: (filename: string, data: string, contentType?: string) => this;
45
46
  addAttachmentFromUrl: (filename: string, url: string, contentType?: string) => this;
46
47
  clearAttachments: () => this;
47
48
  pushBcc: (recipient: string | string[]) => this;
@@ -50,36 +51,7 @@ declare class SimpleEmail extends BaseClass {
50
51
  setBcc: (recipient: string | string[]) => this;
51
52
  setCc: (recipient: string | string[]) => this;
52
53
  setTo: (recipient: string | string[]) => this;
53
- getSendParam: () => Promise<{
54
- Destinations: string[];
55
- RawMessage: {
56
- Data: string;
57
- };
58
- Source: string | undefined;
59
- } | {
60
- Destination: {
61
- BccAddresses: string[];
62
- CcAddresses: string[];
63
- ToAddresses: string[];
64
- };
65
- Message: {
66
- Body: {
67
- Html: {
68
- Charset: string;
69
- Data: string | undefined;
70
- };
71
- Text: {
72
- Charset: string;
73
- Data: string | undefined;
74
- };
75
- };
76
- Subject: {
77
- Charset: string;
78
- Data: string | undefined;
79
- };
80
- };
81
- Source: string | undefined;
82
- }>;
54
+ getSendParam: () => Promise<SendEmailCommandInput | SendRawEmailCommandInput>;
83
55
  private _getRawEmailParams;
84
56
  private _isTextFile;
85
57
  private _getAttachmentTextData;
@@ -1,4 +1,5 @@
1
1
  import { BaseClass } from "../../../_class/BaseClass.mjs";
2
+ import { SendEmailCommandInput, SendRawEmailCommandInput } from "@aws-sdk/client-ses";
2
3
 
3
4
  //#region src/aws/ses/server/SimpleEmail.d.ts
4
5
  type AttachmentSource = {
@@ -41,7 +42,7 @@ declare class SimpleEmail extends BaseClass {
41
42
  setSubject: (subject: string) => this;
42
43
  setAttachments: (attachments: AttachmentSource[]) => this;
43
44
  addAttachment: (attachment: AttachmentSource) => this;
44
- addAttachmentFromdata: (filename: string, data: string, contentType?: string) => this;
45
+ addAttachmentFromData: (filename: string, data: string, contentType?: string) => this;
45
46
  addAttachmentFromUrl: (filename: string, url: string, contentType?: string) => this;
46
47
  clearAttachments: () => this;
47
48
  pushBcc: (recipient: string | string[]) => this;
@@ -50,36 +51,7 @@ declare class SimpleEmail extends BaseClass {
50
51
  setBcc: (recipient: string | string[]) => this;
51
52
  setCc: (recipient: string | string[]) => this;
52
53
  setTo: (recipient: string | string[]) => this;
53
- getSendParam: () => Promise<{
54
- Destinations: string[];
55
- RawMessage: {
56
- Data: string;
57
- };
58
- Source: string | undefined;
59
- } | {
60
- Destination: {
61
- BccAddresses: string[];
62
- CcAddresses: string[];
63
- ToAddresses: string[];
64
- };
65
- Message: {
66
- Body: {
67
- Html: {
68
- Charset: string;
69
- Data: string | undefined;
70
- };
71
- Text: {
72
- Charset: string;
73
- Data: string | undefined;
74
- };
75
- };
76
- Subject: {
77
- Charset: string;
78
- Data: string | undefined;
79
- };
80
- };
81
- Source: string | undefined;
82
- }>;
54
+ getSendParam: () => Promise<SendEmailCommandInput | SendRawEmailCommandInput>;
83
55
  private _getRawEmailParams;
84
56
  private _isTextFile;
85
57
  private _getAttachmentTextData;
@@ -38,7 +38,7 @@ var SimpleEmail = class extends BaseClass {
38
38
  this.attachments.push(attachment);
39
39
  return this;
40
40
  };
41
- addAttachmentFromdata = (filename, data, contentType) => {
41
+ addAttachmentFromData = (filename, data, contentType) => {
42
42
  return this.addAttachment({
43
43
  filename,
44
44
  data,
@@ -86,19 +86,19 @@ var SimpleEmail = class extends BaseClass {
86
86
  Body: {
87
87
  Html: {
88
88
  Charset: "UTF-8",
89
- Data: this.html
89
+ Data: this.html ?? ""
90
90
  },
91
91
  Text: {
92
92
  Charset: "UTF-8",
93
- Data: this.html
93
+ Data: this.html ?? ""
94
94
  }
95
95
  },
96
96
  Subject: {
97
97
  Charset: "UTF-8",
98
- Data: this.subject
98
+ Data: this.subject ?? ""
99
99
  }
100
100
  },
101
- Source: this.from
101
+ Source: this.from ?? ""
102
102
  };
103
103
  };
104
104
  _getRawEmailParams = async () => {
@@ -137,8 +137,8 @@ var SimpleEmail = class extends BaseClass {
137
137
  rawMessage += `--${boundary}--\r\n`;
138
138
  return {
139
139
  Destinations: allRecipients,
140
- RawMessage: { Data: rawMessage },
141
- Source: this.from
140
+ RawMessage: { Data: Buffer.from(rawMessage) },
141
+ Source: this.from ?? ""
142
142
  };
143
143
  };
144
144
  _isTextFile = (contentType) => {
@@ -157,7 +157,7 @@ var SimpleEmail = class extends BaseClass {
157
157
  if (this._isBase64(base64Data)) return Buffer.from(base64Data, "base64").toString("utf-8");
158
158
  return attachment.data;
159
159
  }
160
- if (attachment.url) return await (await (await import("../../../node_modules/node-fetch/src/index.mjs").then((mod) => mod.default))(attachment.url)).text();
160
+ if (attachment.url) return await (await fetch(attachment.url)).text();
161
161
  throw new Error(`No valid data source provided for attachment: ${attachment.filename}`);
162
162
  };
163
163
  _getAttachmentData = async (attachment) => {
@@ -166,7 +166,10 @@ var SimpleEmail = class extends BaseClass {
166
166
  if (this._isBase64(cleanData)) return cleanData;
167
167
  return Buffer.from(attachment.data, "utf-8").toString("base64");
168
168
  }
169
- if (attachment.url) return (await (await (await import("../../../node_modules/node-fetch/src/index.mjs").then((mod) => mod.default))(attachment.url)).buffer()).toString("base64");
169
+ if (attachment.url) {
170
+ const blobBytes = await (await fetch(attachment.url)).bytes();
171
+ return Buffer.from(blobBytes).toString("base64");
172
+ }
170
173
  throw new Error(`No valid data source provided for attachment: ${attachment.filename}`);
171
174
  };
172
175
  _isBase64 = (str) => {
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_date_calculation = require("./calculation.cjs");
3
2
  const require_date_date = require("./date.cjs");
3
+ const require_date_calculation = require("./calculation.cjs");
4
4
  const require_date_financialYear = require("./financialYear.cjs");
5
5
  const require_date_format = require("./format.cjs");
6
6
  exports.defaultDate = require_date_date.defaultDate;
@@ -1,5 +1,5 @@
1
- import { differenceInBusinessDays, differenceInMinutes, getDatesBetween, getLastWeek, getLuxonDate, getMax, getMin, getMonday, getMonthsBetween, getSunday, getThisWeek, getToday, getTwoWeeksAgo, getUnix, getWeeksAgo, getYesterday, isFriday, isLastWeek, isMonday, isSaturday, isSunday, isThisWeek, isThursday, isTuesday, isWednesday, isWeekend } from "./calculation.mjs";
2
1
  import { defaultDate, defaultDateNumber, defaultDateTime, month } from "./date.mjs";
2
+ import { differenceInBusinessDays, differenceInMinutes, getDatesBetween, getLastWeek, getLuxonDate, getMax, getMin, getMonday, getMonthsBetween, getSunday, getThisWeek, getToday, getTwoWeeksAgo, getUnix, getWeeksAgo, getYesterday, isFriday, isLastWeek, isMonday, isSaturday, isSunday, isThisWeek, isThursday, isTuesday, isWednesday, isWeekend } from "./calculation.mjs";
3
3
  import { getFinancialYear, getFinancialYearToDate, getFinancialYearToYesterday, getFinancialYearWeeks } from "./financialYear.mjs";
4
4
  import { format, getDayNumber, getDurationHours, getDurationMinutes, getFullDate, getFullDateTime, getLuxonDateFromExcel, getMonthYearString, getTodayYmdHisNumber, getTodayYmdHisString, getTodayYmdNumber, getTodayYmdString, getYearMonthString, getYearNumber, getYmdHisNumber, getYmdHisString, getYmdNumber, getYmdString } from "./format.mjs";
5
5
  export { defaultDate, defaultDateNumber, defaultDateTime, differenceInBusinessDays, differenceInMinutes, format, getDatesBetween, getDayNumber, getDurationHours, getDurationMinutes, getFinancialYear, getFinancialYearToDate, getFinancialYearToYesterday, getFinancialYearWeeks, getFullDate, getFullDateTime, getLastWeek, getLuxonDate, getLuxonDateFromExcel, getMax, getMin, getMonday, getMonthYearString, getMonthsBetween, getSunday, getThisWeek, getToday, getTodayYmdHisNumber, getTodayYmdHisString, getTodayYmdNumber, getTodayYmdString, getTwoWeeksAgo, getUnix, getWeeksAgo, getYearMonthString, getYearNumber, getYesterday, getYmdHisNumber, getYmdHisString, getYmdNumber, getYmdString, isFriday, isLastWeek, isMonday, isSaturday, isSunday, isThisWeek, isThursday, isTuesday, isWednesday, isWeekend, month };
@@ -1,24 +1,24 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_util_getError = require("../../util/getError.cjs");
3
3
  const require__class_BaseNamespace = require("../../_class/BaseNamespace.cjs");
4
- //#region src/prisma/server/PrismaNamespace.ts
5
- var PrismaNamespace = class extends require__class_BaseNamespace.BaseNamespace {
6
- ensureInit = async () => {
4
+ //#region src/prisma/server/Prisma.ts
5
+ var Prisma = class extends require__class_BaseNamespace.BaseNamespace {
6
+ init = async (config) => {
7
7
  if (!this.client) {
8
8
  let adapter = null;
9
- if (this.config.isPlanetScale) try {
9
+ if (config.isPlanetScale) try {
10
10
  const { PrismaPlanetScale } = await import("@prisma/adapter-planetscale");
11
- adapter = new PrismaPlanetScale({ url: this.config.url });
11
+ adapter = new PrismaPlanetScale({ url: config.url });
12
12
  } catch (e) {
13
13
  throw new Error(`PlanetScale adapter not installed - ${require_util_getError.getError(e)}`);
14
14
  }
15
- if (this.config.isMysql) try {
15
+ if (config.isMysql) try {
16
16
  const { PrismaMariaDb } = await import("@prisma/adapter-mariadb");
17
- adapter = new PrismaMariaDb(this.config.url);
17
+ adapter = new PrismaMariaDb(config.url);
18
18
  } catch (e) {
19
19
  throw new Error(`MariaDB adapter not installed - ${require_util_getError.getError(e)}`);
20
20
  }
21
- if (this.config.isPostgres) try {
21
+ if (config.isPostgres) try {
22
22
  const { PrismaPg } = await import("@prisma/adapter-pg");
23
23
  adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL });
24
24
  } catch (e) {
@@ -26,7 +26,7 @@ var PrismaNamespace = class extends require__class_BaseNamespace.BaseNamespace {
26
26
  }
27
27
  try {
28
28
  const { PrismaClient } = await import("@prisma/client");
29
- if (this.config.isDebug) this.client = new PrismaClient({
29
+ if (config.isDebug) this.client = new PrismaClient({
30
30
  adapter,
31
31
  log: [{
32
32
  emit: "event",
@@ -34,11 +34,13 @@ var PrismaNamespace = class extends require__class_BaseNamespace.BaseNamespace {
34
34
  }]
35
35
  });
36
36
  else this.client = new PrismaClient({ adapter });
37
+ this.config = config;
37
38
  } catch (e) {
38
39
  throw new Error(`Prisma Client not installed - ${require_util_getError.getError(e)}`);
39
40
  }
40
41
  }
42
+ return this;
41
43
  };
42
44
  };
43
45
  //#endregion
44
- exports.PrismaNamespace = PrismaNamespace;
46
+ exports.Prisma = Prisma;
@@ -1,13 +1,6 @@
1
- import { PrismaNamespace } from "./PrismaNamespace.mjs";
1
+ import { BaseNamespace } from "../../_class/BaseNamespace.cjs";
2
2
 
3
- //#region src/prisma/server/prisma.d.ts
4
- type PrismaConfig = {
5
- url: string;
6
- isDebug: boolean;
7
- isPlanetScale: boolean;
8
- isMysql: boolean;
9
- isPostgres: boolean;
10
- };
3
+ //#region src/prisma/server/Prisma.d.ts
11
4
  /**
12
5
  * Minimal interface representing a Prisma Client instance.
13
6
  * Consumers of this library will have their own generated PrismaClient
@@ -19,6 +12,17 @@ interface PrismaClientLike {
19
12
  $transaction(...args: any[]): Promise<any>;
20
13
  [key: string]: any;
21
14
  }
22
- declare const prismaClient: (key?: string, config?: PrismaConfig) => Promise<PrismaNamespace>;
15
+ type PrismaConfig = {
16
+ isDebug: boolean;
17
+ isPlanetScale: boolean;
18
+ isMysql: boolean;
19
+ isPostgres: boolean;
20
+ url: string;
21
+ };
22
+ declare class Prisma extends BaseNamespace {
23
+ client: PrismaClientLike;
24
+ config: PrismaConfig;
25
+ init: (config: PrismaConfig) => Promise<this>;
26
+ }
23
27
  //#endregion
24
- export { PrismaClientLike, PrismaConfig, prismaClient };
28
+ export { Prisma, PrismaClientLike };
@@ -1,13 +1,6 @@
1
- import { PrismaNamespace } from "./PrismaNamespace.cjs";
1
+ import { BaseNamespace } from "../../_class/BaseNamespace.mjs";
2
2
 
3
- //#region src/prisma/server/prisma.d.ts
4
- type PrismaConfig = {
5
- url: string;
6
- isDebug: boolean;
7
- isPlanetScale: boolean;
8
- isMysql: boolean;
9
- isPostgres: boolean;
10
- };
3
+ //#region src/prisma/server/Prisma.d.ts
11
4
  /**
12
5
  * Minimal interface representing a Prisma Client instance.
13
6
  * Consumers of this library will have their own generated PrismaClient
@@ -19,6 +12,17 @@ interface PrismaClientLike {
19
12
  $transaction(...args: any[]): Promise<any>;
20
13
  [key: string]: any;
21
14
  }
22
- declare const prismaClient: (key?: string, config?: PrismaConfig) => Promise<PrismaNamespace>;
15
+ type PrismaConfig = {
16
+ isDebug: boolean;
17
+ isPlanetScale: boolean;
18
+ isMysql: boolean;
19
+ isPostgres: boolean;
20
+ url: string;
21
+ };
22
+ declare class Prisma extends BaseNamespace {
23
+ client: PrismaClientLike;
24
+ config: PrismaConfig;
25
+ init: (config: PrismaConfig) => Promise<this>;
26
+ }
23
27
  //#endregion
24
- export { PrismaClientLike, PrismaConfig, prismaClient };
28
+ export { Prisma, PrismaClientLike };
@@ -1,23 +1,23 @@
1
1
  import { getError } from "../../util/getError.mjs";
2
2
  import { BaseNamespace } from "../../_class/BaseNamespace.mjs";
3
- //#region src/prisma/server/PrismaNamespace.ts
4
- var PrismaNamespace = class extends BaseNamespace {
5
- ensureInit = async () => {
3
+ //#region src/prisma/server/Prisma.ts
4
+ var Prisma = class extends BaseNamespace {
5
+ init = async (config) => {
6
6
  if (!this.client) {
7
7
  let adapter = null;
8
- if (this.config.isPlanetScale) try {
8
+ if (config.isPlanetScale) try {
9
9
  const { PrismaPlanetScale } = await import("@prisma/adapter-planetscale");
10
- adapter = new PrismaPlanetScale({ url: this.config.url });
10
+ adapter = new PrismaPlanetScale({ url: config.url });
11
11
  } catch (e) {
12
12
  throw new Error(`PlanetScale adapter not installed - ${getError(e)}`);
13
13
  }
14
- if (this.config.isMysql) try {
14
+ if (config.isMysql) try {
15
15
  const { PrismaMariaDb } = await import("@prisma/adapter-mariadb");
16
- adapter = new PrismaMariaDb(this.config.url);
16
+ adapter = new PrismaMariaDb(config.url);
17
17
  } catch (e) {
18
18
  throw new Error(`MariaDB adapter not installed - ${getError(e)}`);
19
19
  }
20
- if (this.config.isPostgres) try {
20
+ if (config.isPostgres) try {
21
21
  const { PrismaPg } = await import("@prisma/adapter-pg");
22
22
  adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL });
23
23
  } catch (e) {
@@ -25,7 +25,7 @@ var PrismaNamespace = class extends BaseNamespace {
25
25
  }
26
26
  try {
27
27
  const { PrismaClient } = await import("@prisma/client");
28
- if (this.config.isDebug) this.client = new PrismaClient({
28
+ if (config.isDebug) this.client = new PrismaClient({
29
29
  adapter,
30
30
  log: [{
31
31
  emit: "event",
@@ -33,11 +33,13 @@ var PrismaNamespace = class extends BaseNamespace {
33
33
  }]
34
34
  });
35
35
  else this.client = new PrismaClient({ adapter });
36
+ this.config = config;
36
37
  } catch (e) {
37
38
  throw new Error(`Prisma Client not installed - ${getError(e)}`);
38
39
  }
39
40
  }
41
+ return this;
40
42
  };
41
43
  };
42
44
  //#endregion
43
- export { PrismaNamespace };
45
+ export { Prisma };
@@ -1,5 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_prisma_server_PrismaNamespace = require("./PrismaNamespace.cjs");
3
- const require_prisma_server_prisma = require("./prisma.cjs");
4
- exports.PrismaNamespace = require_prisma_server_PrismaNamespace.PrismaNamespace;
5
- exports.prismaClient = require_prisma_server_prisma.prismaClient;
2
+ const require_prisma_server_Prisma = require("./Prisma.cjs");
3
+ exports.Prisma = require_prisma_server_Prisma.Prisma;
@@ -1,3 +1,2 @@
1
- import { PrismaClientLike, PrismaConfig, prismaClient } from "./prisma.cjs";
2
- import { PrismaNamespace } from "./PrismaNamespace.cjs";
3
- export { PrismaClientLike, PrismaConfig, PrismaNamespace, prismaClient };
1
+ import { Prisma, PrismaClientLike } from "./Prisma.cjs";
2
+ export { Prisma, PrismaClientLike };
@@ -1,3 +1,2 @@
1
- import { PrismaClientLike, PrismaConfig, prismaClient } from "./prisma.mjs";
2
- import { PrismaNamespace } from "./PrismaNamespace.mjs";
3
- export { PrismaClientLike, PrismaConfig, PrismaNamespace, prismaClient };
1
+ import { Prisma, PrismaClientLike } from "./Prisma.mjs";
2
+ export { Prisma, PrismaClientLike };
@@ -1,3 +1,2 @@
1
- import { PrismaNamespace } from "./PrismaNamespace.mjs";
2
- import { prismaClient } from "./prisma.mjs";
3
- export { PrismaNamespace, prismaClient };
1
+ import { Prisma } from "./Prisma.mjs";
2
+ export { Prisma };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "3.0.9",
4
+ "version": "3.0.11",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
@@ -207,7 +207,6 @@
207
207
  "jest": "^30.3.0",
208
208
  "mysql2": "^3.22.2",
209
209
  "next": "^16.2.3",
210
- "node-fetch": "^3.3.2",
211
210
  "pg": "^8.20.0",
212
211
  "react": "^19.2.5",
213
212
  "react-intersection-observer": "^10.0.3",
@@ -987,13 +986,9 @@
987
986
  "import": "./dist/prisma/server/index.mjs",
988
987
  "require": "./dist/prisma/server/index.cjs"
989
988
  },
990
- "./prisma/server/prisma": {
991
- "import": "./dist/prisma/server/prisma.mjs",
992
- "require": "./dist/prisma/server/prisma.cjs"
993
- },
994
- "./prisma/server/PrismaNamespace": {
995
- "import": "./dist/prisma/server/PrismaNamespace.mjs",
996
- "require": "./dist/prisma/server/PrismaNamespace.cjs"
989
+ "./prisma/server/Prisma": {
990
+ "import": "./dist/prisma/server/Prisma.mjs",
991
+ "require": "./dist/prisma/server/Prisma.cjs"
997
992
  },
998
993
  "./snapchat/server": {
999
994
  "import": "./dist/snapchat/server/index.mjs",
@@ -1218,12 +1213,6 @@
1218
1213
  "./package.json": "./package.json"
1219
1214
  },
1220
1215
  "inlinedDependencies": {
1221
- "@smithy/types": "4.14.2",
1222
- "data-uri-to-buffer": "4.0.1",
1223
- "fetch-blob": "3.2.0",
1224
- "formdata-polyfill": "4.0.10",
1225
- "node-domexception": "1.0.0",
1226
- "node-fetch": "3.3.2",
1227
- "web-streams-polyfill": "3.3.3"
1216
+ "@smithy/types": "4.14.2"
1228
1217
  }
1229
1218
  }
@@ -1,37 +0,0 @@
1
- //#region node_modules/data-uri-to-buffer/dist/index.js
2
- /**
3
- * Returns a `Buffer` instance from the given data URI `uri`.
4
- *
5
- * @param {String} uri Data URI to turn into a Buffer instance
6
- * @returns {Buffer} Buffer instance from Data URI
7
- * @api public
8
- */
9
- function dataUriToBuffer(uri) {
10
- if (!/^data:/i.test(uri)) throw new TypeError("`uri` does not appear to be a Data URI (must begin with \"data:\")");
11
- uri = uri.replace(/\r?\n/g, "");
12
- const firstComma = uri.indexOf(",");
13
- if (firstComma === -1 || firstComma <= 4) throw new TypeError("malformed data: URI");
14
- const meta = uri.substring(5, firstComma).split(";");
15
- let charset = "";
16
- let base64 = false;
17
- const type = meta[0] || "text/plain";
18
- let typeFull = type;
19
- for (let i = 1; i < meta.length; i++) if (meta[i] === "base64") base64 = true;
20
- else if (meta[i]) {
21
- typeFull += `;${meta[i]}`;
22
- if (meta[i].indexOf("charset=") === 0) charset = meta[i].substring(8);
23
- }
24
- if (!meta[0] && !charset.length) {
25
- typeFull += ";charset=US-ASCII";
26
- charset = "US-ASCII";
27
- }
28
- const encoding = base64 ? "base64" : "ascii";
29
- const data = unescape(uri.substring(firstComma + 1));
30
- const buffer = Buffer.from(data, encoding);
31
- buffer.type = type;
32
- buffer.typeFull = typeFull;
33
- buffer.charset = charset;
34
- return buffer;
35
- }
36
- //#endregion
37
- exports.default = dataUriToBuffer;
@@ -1,37 +0,0 @@
1
- //#region node_modules/data-uri-to-buffer/dist/index.js
2
- /**
3
- * Returns a `Buffer` instance from the given data URI `uri`.
4
- *
5
- * @param {String} uri Data URI to turn into a Buffer instance
6
- * @returns {Buffer} Buffer instance from Data URI
7
- * @api public
8
- */
9
- function dataUriToBuffer(uri) {
10
- if (!/^data:/i.test(uri)) throw new TypeError("`uri` does not appear to be a Data URI (must begin with \"data:\")");
11
- uri = uri.replace(/\r?\n/g, "");
12
- const firstComma = uri.indexOf(",");
13
- if (firstComma === -1 || firstComma <= 4) throw new TypeError("malformed data: URI");
14
- const meta = uri.substring(5, firstComma).split(";");
15
- let charset = "";
16
- let base64 = false;
17
- const type = meta[0] || "text/plain";
18
- let typeFull = type;
19
- for (let i = 1; i < meta.length; i++) if (meta[i] === "base64") base64 = true;
20
- else if (meta[i]) {
21
- typeFull += `;${meta[i]}`;
22
- if (meta[i].indexOf("charset=") === 0) charset = meta[i].substring(8);
23
- }
24
- if (!meta[0] && !charset.length) {
25
- typeFull += ";charset=US-ASCII";
26
- charset = "US-ASCII";
27
- }
28
- const encoding = base64 ? "base64" : "ascii";
29
- const data = unescape(uri.substring(firstComma + 1));
30
- const buffer = Buffer.from(data, encoding);
31
- buffer.type = type;
32
- buffer.typeFull = typeFull;
33
- buffer.charset = charset;
34
- return buffer;
35
- }
36
- //#endregion
37
- export { dataUriToBuffer as default };