@8ms/helpers 2.2.9 → 2.2.10

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 (176) hide show
  1. package/_class/BaseClass.js +43 -52
  2. package/_class/BaseNamespace.js +17 -20
  3. package/_class/index.js +2 -7
  4. package/adverity/getJobs.js +7 -11
  5. package/adverity/index.js +51 -54
  6. package/adverity/server.js +1 -5
  7. package/api/ApiResponseClass.js +84 -88
  8. package/api/functions.js +13 -22
  9. package/api/index.js +3 -19
  10. package/api/types.js +5 -9
  11. package/array/index.js +3 -11
  12. package/atInternet/index.js +10 -13
  13. package/aws/ec2/AwsEc2Namespace.js +34 -74
  14. package/aws/ec2/server.js +5 -9
  15. package/aws/ecs/AwsEcsNamespace.js +110 -150
  16. package/aws/ecs/server.js +5 -9
  17. package/aws/glue/AwsGlueNamespace.js +26 -66
  18. package/aws/glue/server.js +5 -9
  19. package/aws/isResponse200.js +3 -7
  20. package/aws/lambda/AwsLambdaNamespace.js +62 -102
  21. package/aws/lambda/server.js +6 -11
  22. package/aws/s3/AwsS3Namespace.js +347 -390
  23. package/aws/s3/payload.js +29 -32
  24. package/aws/s3/server.js +9 -14
  25. package/aws/server.js +5 -10
  26. package/aws/ses/AwsSesNamespace.js +36 -76
  27. package/aws/ses/SimpleEmail.js +267 -304
  28. package/aws/ses/server.js +6 -11
  29. package/aws/sqs/AwsSqsNamespace.js +49 -89
  30. package/aws/sqs/server.js +5 -9
  31. package/aws/ssm/AwsSsmNamespace.js +43 -79
  32. package/aws/ssm/server.js +5 -9
  33. package/axios/deleteRequest.js +8 -15
  34. package/axios/get.js +8 -15
  35. package/axios/index.js +3 -9
  36. package/axios/post.js +8 -15
  37. package/boolean/index.js +3 -10
  38. package/brightData/serpApi/buildGoogleSerpUrl.js +1 -5
  39. package/brightData/serpApi/buildGoogleTrendsUrl.js +1 -5
  40. package/brightData/serpApi/getAsyncRequestId.js +8 -12
  41. package/brightData/serpApi/getAsyncResults.js +8 -12
  42. package/brightData/serpApi/getRealtime.js +3 -7
  43. package/brightData/serpApi/server.js +6 -14
  44. package/brightData/server.js +2 -7
  45. package/brightData/webScraperIde/getBatch.js +3 -7
  46. package/brightData/webScraperIde/getRealtime.js +11 -15
  47. package/brightData/webScraperIde/server.js +2 -7
  48. package/cache/server.js +2 -7
  49. package/cache/test/cache.test.js +4 -6
  50. package/crud/index.js +1 -4
  51. package/crypto/getDecrypt.js +2 -39
  52. package/crypto/getEncrypt.js +2 -39
  53. package/crypto/getRandom.js +1 -5
  54. package/crypto/getSha256.js +4 -41
  55. package/crypto/index.js +4 -11
  56. package/date/calculation.js +70 -99
  57. package/date/financialYear.js +16 -23
  58. package/date/format.js +40 -61
  59. package/date/index.js +4 -20
  60. package/date/type.js +4 -7
  61. package/environment/index.js +15 -25
  62. package/eskimi/getAgeGroup.js +3 -7
  63. package/eskimi/getData.js +3 -7
  64. package/eskimi/getDevice.js +3 -7
  65. package/eskimi/getGender.js +3 -7
  66. package/eskimi/server.js +23 -26
  67. package/file/index.js +8 -46
  68. package/geo/countries.js +1 -4
  69. package/geo/index.js +2 -7
  70. package/geo/languages.js +1 -4
  71. package/google/bigQuery/GoogleBigQueryNamespace.js +108 -148
  72. package/google/bigQuery/loadData.js +1 -5
  73. package/google/bigQuery/server.js +8 -14
  74. package/google/server.js +1 -5
  75. package/google/sheets/GoogleSheetsNamespace.js +34 -74
  76. package/google/sheets/getAssociatedData.js +1 -5
  77. package/google/sheets/server.js +8 -14
  78. package/google/storage/GoogleCloudStorageNamespace.js +62 -102
  79. package/google/storage/server.js +6 -10
  80. package/googleAds/GoogleAdsNamespace.js +28 -68
  81. package/googleAds/keywordPlanner/server.js +32 -35
  82. package/googleAds/server.js +6 -10
  83. package/googlePageSpeed/GooglePageSpeedNamespace.js +21 -28
  84. package/googlePageSpeed/server.js +8 -12
  85. package/googleSearchIncidents/server.js +28 -32
  86. package/greenDomain/server.js +17 -21
  87. package/inngest/server.js +1 -4
  88. package/json/getJsonNewline.js +3 -7
  89. package/json/index.js +2 -7
  90. package/json/isJson.js +1 -5
  91. package/littleWarden/LittleWardenNamespace.js +24 -31
  92. package/littleWarden/getUrlStatus.js +3 -7
  93. package/littleWarden/server.js +14 -22
  94. package/lumar/api/buildRequest.js +14 -18
  95. package/lumar/api/getData.js +3 -7
  96. package/lumar/api/initClient.js +3 -7
  97. package/lumar/api/server.js +6 -12
  98. package/lumar/graphql/columns.js +1 -4
  99. package/lumar/graphql/getData.js +3 -7
  100. package/lumar/graphql/initClient.js +3 -7
  101. package/lumar/graphql/queries/crawl.js +1 -2
  102. package/lumar/graphql/queries/getCrawls.js +1 -3
  103. package/lumar/graphql/queries/getReportDifferences.js +3 -5
  104. package/lumar/graphql/queries/getRows.js +1 -3
  105. package/lumar/graphql/queries/getTotals.js +1 -3
  106. package/lumar/graphql/queries/row.js +1 -2
  107. package/lumar/graphql/reportTemplates.js +1 -4
  108. package/lumar/graphql/server.js +7 -15
  109. package/myTarget/server.js +3 -7
  110. package/nextAuth/index.js +2 -6
  111. package/nextAuth/isSessionReady.js +1 -5
  112. package/nextJs/client/LazyLoad.js +5 -12
  113. package/nextJs/client.js +1 -5
  114. package/nextJs/index.js +2 -7
  115. package/number/format.js +3 -7
  116. package/number/formatCurrency.js +1 -5
  117. package/number/getDecimal.js +3 -7
  118. package/number/getNumber.js +3 -7
  119. package/number/getPercentIncrease.js +4 -8
  120. package/number/getSafeDivide.js +6 -10
  121. package/number/index.js +6 -15
  122. package/object/index.js +1 -5
  123. package/object/replaceKeys.js +3 -7
  124. package/onePassword/OnePasswordNamespace.js +36 -76
  125. package/onePassword/server.js +3 -7
  126. package/openAi/OpenAiNamespace.js +32 -39
  127. package/openAi/server.js +6 -10
  128. package/package.json +7 -1
  129. package/prisma/PrismaNamespace.js +53 -93
  130. package/prisma/getDecimal.js +5 -12
  131. package/prisma/server.js +4 -9
  132. package/snapchat/SnapchatNamespace.js +20 -27
  133. package/snapchat/server.js +6 -10
  134. package/sorting/byNumberAscending.js +1 -5
  135. package/sorting/byNumberDescending.js +1 -5
  136. package/sorting/byStringAscending.js +1 -5
  137. package/sorting/byStringDescending.js +1 -5
  138. package/sorting/index.js +4 -11
  139. package/stream/server.js +1 -5
  140. package/stream/sort.js +1 -5
  141. package/string/getCapitalised.js +3 -7
  142. package/string/getClean.js +17 -21
  143. package/string/getFolder.js +3 -10
  144. package/string/getProperCase.js +4 -8
  145. package/string/getString.js +8 -15
  146. package/string/getStringFromStream.js +1 -5
  147. package/string/getUnescaped.js +3 -10
  148. package/string/getWithoutAccents.js +1 -5
  149. package/string/getWithoutHtmlTags.js +1 -5
  150. package/string/getWithoutPunctuation.js +1 -5
  151. package/string/getWithoutUnderscores.js +1 -5
  152. package/string/getWithoutWhitespaces.js +1 -5
  153. package/string/index.js +12 -27
  154. package/string/reservedWords.js +5 -9
  155. package/swr/index.js +9 -18
  156. package/upTimeRobot/UpTimeRobotNamespace.js +32 -42
  157. package/upTimeRobot/server.js +11 -15
  158. package/url/index.js +12 -23
  159. package/url/server.js +1 -5
  160. package/url/writeUrlContents.js +6 -46
  161. package/util/defaultTo.js +5 -12
  162. package/util/getBrotliCompressed.js +3 -10
  163. package/util/getBrotliDecompressed.js +3 -10
  164. package/util/getClean.js +5 -9
  165. package/util/getError.js +1 -5
  166. package/util/getGzipCompressed.js +3 -10
  167. package/util/getGzipDecompressed.js +3 -10
  168. package/util/getWithoutHash.js +1 -5
  169. package/util/getWithoutParameter.js +1 -5
  170. package/util/index.js +7 -17
  171. package/util/isUndefined.js +3 -7
  172. package/util/promiseChunks.js +6 -10
  173. package/util/server.js +4 -11
  174. package/util/sleep.js +1 -5
  175. package/webWorker/index.js +1 -4
  176. package/xml/getXml.js +3 -7
@@ -1,79 +1,39 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.OnePasswordNamespace = void 0;
37
- const _class_1 = require("../_class");
38
- class OnePasswordNamespace extends _class_1.BaseNamespace {
39
- constructor() {
40
- super(...arguments);
41
- // Async setup to only initialise where required
42
- this.ensureInit = async () => {
43
- if (!this.client) {
44
- try {
45
- const { createClient } = await Promise.resolve().then(() => __importStar(require("@1password/sdk")));
46
- this.client = await createClient({
47
- auth: this.config.serviceAccountToken,
48
- integrationName: this.config.integrationName || "8MS Helper TS",
49
- integrationVersion: this.config.integrationVersion || "v1.0.0",
50
- });
51
- }
52
- catch (e) {
53
- throw new Error("1Password SDK not installed");
54
- }
1
+ import { BaseNamespace } from "../_class";
2
+ export class OnePasswordNamespace extends BaseNamespace {
3
+ // Async setup to only initialise where required
4
+ ensureInit = async () => {
5
+ if (!this.client) {
6
+ try {
7
+ const { createClient } = await import("@1password/sdk");
8
+ this.client = await createClient({
9
+ auth: this.config.serviceAccountToken,
10
+ integrationName: this.config.integrationName || "8MS Helper TS",
11
+ integrationVersion: this.config.integrationVersion || "v1.0.0",
12
+ });
55
13
  }
56
- };
57
- this.listVaults = async () => {
58
- await this.ensureInit();
59
- return this.client.vaults.list();
60
- };
61
- this.getItem = async (vaultId, itemId) => {
62
- await this.ensureInit();
63
- return this.client.items.get(vaultId, itemId);
64
- };
65
- this.getJsonNote = async (vaultId, itemId) => {
66
- let response = null;
67
- const item = await this.getItem(vaultId, itemId);
68
- if (item && "undefined" !== typeof item.notes) {
69
- response = JSON.parse(item.notes);
14
+ catch (e) {
15
+ throw new Error("1Password SDK not installed");
70
16
  }
71
- return response;
72
- };
73
- this.listItems = async (vaultId) => {
74
- await this.ensureInit();
75
- return this.client.items.list(vaultId);
76
- };
77
- }
17
+ }
18
+ };
19
+ listVaults = async () => {
20
+ await this.ensureInit();
21
+ return this.client.vaults.list();
22
+ };
23
+ getItem = async (vaultId, itemId) => {
24
+ await this.ensureInit();
25
+ return this.client.items.get(vaultId, itemId);
26
+ };
27
+ getJsonNote = async (vaultId, itemId) => {
28
+ let response = null;
29
+ const item = await this.getItem(vaultId, itemId);
30
+ if (item && "undefined" !== typeof item.notes) {
31
+ response = JSON.parse(item.notes);
32
+ }
33
+ return response;
34
+ };
35
+ listItems = async (vaultId) => {
36
+ await this.ensureInit();
37
+ return this.client.items.list(vaultId);
38
+ };
78
39
  }
79
- exports.OnePasswordNamespace = OnePasswordNamespace;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.onePasswordClient = void 0;
4
- const OnePasswordNamespace_1 = require("./OnePasswordNamespace");
1
+ import { OnePasswordNamespace } from "./OnePasswordNamespace";
5
2
  const onePasswordNamespaces = new Map();
6
3
  // Main client that is used by system
7
- const onePasswordClient = async (key = "default", config) => {
4
+ export const onePasswordClient = async (key = "default", config) => {
8
5
  if (onePasswordNamespaces.has(key)) {
9
6
  return onePasswordNamespaces.get(key);
10
7
  }
@@ -18,8 +15,7 @@ const onePasswordClient = async (key = "default", config) => {
18
15
  throw new Error(`Config required for namespace '${key}'`);
19
16
  }
20
17
  }
21
- const namespace = new OnePasswordNamespace_1.OnePasswordNamespace(key, config);
18
+ const namespace = new OnePasswordNamespace(key, config);
22
19
  onePasswordNamespaces.set(key, namespace);
23
20
  return namespace;
24
21
  };
25
- exports.onePasswordClient = onePasswordClient;
@@ -1,42 +1,35 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OpenAiNamespace = void 0;
4
- const _class_1 = require("../_class");
5
- const axios_1 = require("../axios");
6
- class OpenAiNamespace extends _class_1.BaseNamespace {
7
- constructor() {
8
- super(...arguments);
9
- /**
10
- * Renew the access token as it expires every 3 hours.
11
- */
12
- this.ensureInit = async () => {
13
- if (!this.client) {
14
- this.client = true;
15
- }
16
- };
17
- this.completion = async (prompt, temperature = 1, maxTokens = null, model = "gpt-3.5-turbo") => {
18
- let response = null;
19
- // Make the API request
20
- const apiResponse = await (0, axios_1.post)(`https://api.openai.com/v1/chat/completions`, {
21
- max_tokens: maxTokens,
22
- model,
23
- messages: [
24
- {
25
- role: "user",
26
- content: prompt,
27
- }
28
- ],
29
- temperature: 1,
30
- }, {
31
- headers: {
32
- Authorization: `Bearer ${this.config.apiKey}`,
1
+ import { BaseNamespace } from "../_class";
2
+ import { post } from "../axios";
3
+ export class OpenAiNamespace extends BaseNamespace {
4
+ /**
5
+ * Renew the access token as it expires every 3 hours.
6
+ */
7
+ ensureInit = async () => {
8
+ if (!this.client) {
9
+ this.client = true;
10
+ }
11
+ };
12
+ completion = async (prompt, temperature = 1, maxTokens = null, model = "gpt-3.5-turbo") => {
13
+ let response = null;
14
+ // Make the API request
15
+ const apiResponse = await post(`https://api.openai.com/v1/chat/completions`, {
16
+ max_tokens: maxTokens,
17
+ model,
18
+ messages: [
19
+ {
20
+ role: "user",
21
+ content: prompt,
33
22
  }
34
- });
35
- if (apiResponse.isSuccess()) {
36
- response = apiResponse.getBody();
23
+ ],
24
+ temperature: 1,
25
+ }, {
26
+ headers: {
27
+ Authorization: `Bearer ${this.config.apiKey}`,
37
28
  }
38
- return response;
39
- };
40
- }
29
+ });
30
+ if (apiResponse.isSuccess()) {
31
+ response = apiResponse.getBody();
32
+ }
33
+ return response;
34
+ };
41
35
  }
42
- exports.OpenAiNamespace = OpenAiNamespace;
package/openAi/server.js CHANGED
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.openAiClient = void 0;
4
- const OpenAiNamespace_1 = require("./OpenAiNamespace");
5
- const server_1 = require("../onePassword/server");
1
+ import { OpenAiNamespace } from "./OpenAiNamespace";
2
+ import { onePasswordClient } from "../onePassword/server";
6
3
  const openAiNamespaces = new Map();
7
- const openAiClient = async (key = "default", config, vaultId, itemId) => {
4
+ export const openAiClient = async (key = "default", config, vaultId, itemId) => {
8
5
  if (openAiNamespaces.has(key)) {
9
6
  return openAiNamespaces.get(key);
10
7
  }
@@ -13,18 +10,17 @@ const openAiClient = async (key = "default", config, vaultId, itemId) => {
13
10
  instanceConfig = config;
14
11
  }
15
12
  else if (vaultId && itemId) {
16
- instanceConfig = await (await (0, server_1.onePasswordClient)())
13
+ instanceConfig = await (await onePasswordClient())
17
14
  .getJsonNote(vaultId, itemId);
18
15
  }
19
16
  else if (process.env.OPEN_AI_VAULT_ID && process.env.OPEN_AI_ITEM_ID) {
20
- instanceConfig = await (await (0, server_1.onePasswordClient)())
17
+ instanceConfig = await (await onePasswordClient())
21
18
  .getJsonNote(process.env.OPEN_AI_VAULT_ID, process.env.OPEN_AI_ITEM_ID);
22
19
  }
23
20
  else {
24
21
  throw new Error(`Config required for namespace '${key}'`);
25
22
  }
26
- const namespace = new OpenAiNamespace_1.OpenAiNamespace(key, instanceConfig);
23
+ const namespace = new OpenAiNamespace(key, instanceConfig);
27
24
  openAiNamespaces.set(key, namespace);
28
25
  return namespace;
29
26
  };
30
- exports.openAiClient = openAiClient;
package/package.json CHANGED
@@ -1,13 +1,19 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "2.2.9",
4
+ "version": "2.2.10",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
8
8
  },
9
9
  "main": "index.js",
10
10
  "types": "index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./index.d.ts",
14
+ "default": "./index.js"
15
+ }
16
+ },
11
17
  "scripts": {
12
18
  "build": "tsc",
13
19
  "jest": "jest --watch"
@@ -1,102 +1,62 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.PrismaNamespace = void 0;
37
- const _class_1 = require("../_class");
38
- const getError_1 = require("../util/getError");
39
- class PrismaNamespace extends _class_1.BaseNamespace {
40
- constructor() {
41
- super(...arguments);
42
- // Async setup to only initialise where required
43
- this.ensureInit = async () => {
44
- if (!this.client) {
45
- let adapter = null;
46
- if (this.config.isPlanetScale) {
47
- try {
48
- const { PrismaPlanetScale } = await Promise.resolve().then(() => __importStar(require("@prisma/adapter-planetscale")));
49
- adapter = new PrismaPlanetScale({
50
- url: this.config.url,
51
- });
52
- }
53
- catch (e) {
54
- throw new Error(`PlanetScale adapter not installed - ${(0, getError_1.getError)(e)}`);
55
- }
1
+ import { BaseNamespace } from "../_class";
2
+ import { getError } from "../util/getError";
3
+ export class PrismaNamespace extends BaseNamespace {
4
+ // Async setup to only initialise where required
5
+ ensureInit = async () => {
6
+ if (!this.client) {
7
+ let adapter = null;
8
+ if (this.config.isPlanetScale) {
9
+ try {
10
+ const { PrismaPlanetScale } = await import("@prisma/adapter-planetscale");
11
+ adapter = new PrismaPlanetScale({
12
+ url: this.config.url,
13
+ });
14
+ }
15
+ catch (e) {
16
+ throw new Error(`PlanetScale adapter not installed - ${getError(e)}`);
56
17
  }
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
- }
18
+ }
19
+ if (this.config.isMysql) {
20
+ try {
21
+ const { PrismaMariaDb } = await import("@prisma/adapter-mariadb");
22
+ adapter = new PrismaMariaDb(this.config.url);
65
23
  }
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)}`);
77
- }
24
+ catch (e) {
25
+ throw new Error(`MariaDB adapter not installed - ${getError(e)}`);
78
26
  }
27
+ }
28
+ else {
29
+ // Prisma v7 requires a driver adapter — use the one matching your database
30
+ // e.g. @prisma/adapter-pg for Postgres, @prisma/adapter-mysql2 for MySQL
79
31
  try {
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")));
83
- // Show the full query if debugging
84
- if (this.config.isDebug) {
85
- this.client = new PrismaClient({
86
- adapter,
87
- log: [{ emit: "event", level: "query" }],
88
- });
89
- }
90
- // Standard prisma
91
- else {
92
- this.client = new PrismaClient({ adapter });
93
- }
32
+ const { PrismaPg } = await import("@prisma/adapter-pg");
33
+ adapter = new PrismaPg({
34
+ connectionString: process.env.DATABASE_URL,
35
+ });
94
36
  }
95
37
  catch (e) {
96
- throw new Error(`Prisma Client not installed - ${(0, getError_1.getError)(e)}`);
38
+ throw new Error(`Postgres adapter not installed - ${getError(e)}`);
39
+ }
40
+ }
41
+ try {
42
+ // In Prisma v7, the client is generated to a custom output path
43
+ // @ts-ignore
44
+ const { PrismaClient } = await import("../../generated/prisma/client");
45
+ // Show the full query if debugging
46
+ if (this.config.isDebug) {
47
+ this.client = new PrismaClient({
48
+ adapter,
49
+ log: [{ emit: "event", level: "query" }],
50
+ });
51
+ }
52
+ // Standard prisma
53
+ else {
54
+ this.client = new PrismaClient({ adapter });
97
55
  }
98
56
  }
99
- };
100
- }
57
+ catch (e) {
58
+ throw new Error(`Prisma Client not installed - ${getError(e)}`);
59
+ }
60
+ }
61
+ };
101
62
  }
102
- exports.PrismaNamespace = PrismaNamespace;
@@ -1,23 +1,16 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getDecimal = void 0;
7
- const getDecimal_1 = require("../number/getDecimal");
8
- const isArray_1 = __importDefault(require("lodash/isArray"));
1
+ import { getDecimal as getNumberDecimal } from "../number/getDecimal";
2
+ import isArray from "lodash/isArray";
9
3
  /**
10
4
  * Fetch the number from a prisma decimal (comes through as an object).
11
5
  */
12
- const getDecimal = (input, dp = 2) => {
6
+ export const getDecimal = (input, dp = 2) => {
13
7
  let numberString = "";
14
8
  // Prisma value
15
- if ((0, isArray_1.default)(input?.d)) {
9
+ if (isArray(input?.d)) {
16
10
  numberString = input.absoluteValue();
17
11
  }
18
12
  else {
19
13
  numberString = input.toString();
20
14
  }
21
- return (0, getDecimal_1.getDecimal)(numberString, dp);
15
+ return getNumberDecimal(numberString, dp);
22
16
  };
23
- exports.getDecimal = getDecimal;
package/prisma/server.js CHANGED
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDecimal = exports.prismaClient = void 0;
4
- const PrismaNamespace_1 = require("./PrismaNamespace");
1
+ import { PrismaNamespace } from "./PrismaNamespace";
5
2
  const prismaNamespaces = new Map();
6
3
  // Main client that is used by system
7
- const prismaClient = async (key = "default", config) => {
4
+ export const prismaClient = async (key = "default", config) => {
8
5
  if (prismaNamespaces.has(key)) {
9
6
  return prismaNamespaces.get(key);
10
7
  }
@@ -22,11 +19,9 @@ const prismaClient = async (key = "default", config) => {
22
19
  throw new Error(`Config required for namespace '${key}'`);
23
20
  }
24
21
  }
25
- const namespace = new PrismaNamespace_1.PrismaNamespace(key, config);
22
+ const namespace = new PrismaNamespace(key, config);
26
23
  await namespace.ensureInit();
27
24
  prismaNamespaces.set(key, namespace);
28
25
  return namespace;
29
26
  };
30
- exports.prismaClient = prismaClient;
31
- var getDecimal_1 = require("./getDecimal");
32
- Object.defineProperty(exports, "getDecimal", { enumerable: true, get: function () { return getDecimal_1.getDecimal; } });
27
+ export { getDecimal } from "./getDecimal";
@@ -1,29 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SnapchatNamespace = void 0;
4
- const _class_1 = require("../_class");
5
- const axios_1 = require("../axios");
6
- const luxon_1 = require("luxon");
7
- class SnapchatNamespace extends _class_1.BaseNamespace {
8
- constructor() {
9
- super(...arguments);
10
- /**
11
- * Renew the access token as it expires every 3 hours.
12
- */
13
- this.ensureInit = async () => {
14
- if (!this.client) {
15
- // Build the token request for Snapchat
16
- const url = `https://accounts.snapchat.com/login/oauth2/access_token?client_id=${this.config.clientId}&client_secret=${this.config.clientSecret}&grant_type=refresh_token&refresh_token=${this.config.refreshToken}`;
17
- const apiResponse = await (0, axios_1.post)(url);
18
- if (apiResponse.isSuccess()) {
19
- this.client = {
20
- expires: luxon_1.DateTime.now()
21
- .toUnixInteger() + (3 * 60 * 60 * 1000),
22
- refreshToken: apiResponse.getBodyDefaultTo(["data", "access_token"], null)
23
- };
24
- }
1
+ import { BaseNamespace } from "../_class";
2
+ import { post } from "../axios";
3
+ import { DateTime } from "luxon";
4
+ export class SnapchatNamespace extends BaseNamespace {
5
+ /**
6
+ * Renew the access token as it expires every 3 hours.
7
+ */
8
+ ensureInit = async () => {
9
+ if (!this.client) {
10
+ // Build the token request for Snapchat
11
+ const url = `https://accounts.snapchat.com/login/oauth2/access_token?client_id=${this.config.clientId}&client_secret=${this.config.clientSecret}&grant_type=refresh_token&refresh_token=${this.config.refreshToken}`;
12
+ const apiResponse = await post(url);
13
+ if (apiResponse.isSuccess()) {
14
+ this.client = {
15
+ expires: DateTime.now()
16
+ .toUnixInteger() + (3 * 60 * 60 * 1000),
17
+ refreshToken: apiResponse.getBodyDefaultTo(["data", "access_token"], null)
18
+ };
25
19
  }
26
- };
27
- }
20
+ }
21
+ };
28
22
  }
29
- exports.SnapchatNamespace = SnapchatNamespace;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.snapchatClient = void 0;
4
- const SnapchatNamespace_1 = require("./SnapchatNamespace");
5
- const server_1 = require("../onePassword/server");
1
+ import { SnapchatNamespace } from "./SnapchatNamespace";
2
+ import { onePasswordClient } from "../onePassword/server";
6
3
  const snapchatNamespaces = new Map();
7
- const snapchatClient = async (key = "default", config, vaultId, itemId) => {
4
+ export const snapchatClient = async (key = "default", config, vaultId, itemId) => {
8
5
  if (snapchatNamespaces.has(key)) {
9
6
  return snapchatNamespaces.get(key);
10
7
  }
@@ -13,18 +10,17 @@ const snapchatClient = async (key = "default", config, vaultId, itemId) => {
13
10
  instanceConfig = config;
14
11
  }
15
12
  else if (vaultId && itemId) {
16
- instanceConfig = await (await (0, server_1.onePasswordClient)())
13
+ instanceConfig = await (await onePasswordClient())
17
14
  .getJsonNote(vaultId, itemId);
18
15
  }
19
16
  else if (process.env.SNAPCHAT_VAULT_ID && process.env.SNAPCHAT_ITEM_ID) {
20
- instanceConfig = await (await (0, server_1.onePasswordClient)())
17
+ instanceConfig = await (await onePasswordClient())
21
18
  .getJsonNote(process.env.SNAPCHAT_VAULT_ID, process.env.SNAPCHAT_ITEM_ID);
22
19
  }
23
20
  else {
24
21
  throw new Error(`Config required for namespace '${key}'`);
25
22
  }
26
- const namespace = new SnapchatNamespace_1.SnapchatNamespace(key, instanceConfig);
23
+ const namespace = new SnapchatNamespace(key, instanceConfig);
27
24
  snapchatNamespaces.set(key, namespace);
28
25
  return namespace;
29
26
  };
30
- exports.snapchatClient = snapchatClient;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.byNumberAscending = void 0;
4
1
  /**
5
2
  * Take two values, ensure they are numbers and return the sorting value.
6
3
  */
7
- const byNumberAscending = (valueA, valueB) => {
4
+ export const byNumberAscending = (valueA, valueB) => {
8
5
  const a = Number(valueA);
9
6
  const b = Number(valueB);
10
7
  // Handle NaN cases
@@ -16,4 +13,3 @@ const byNumberAscending = (valueA, valueB) => {
16
13
  return -1;
17
14
  return a - b;
18
15
  };
19
- exports.byNumberAscending = byNumberAscending;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.byNumberDescending = void 0;
4
1
  /**
5
2
  * Take two values, ensure they are numbers and return the sorting value.
6
3
  */
7
- const byNumberDescending = (valueA, valueB) => {
4
+ export const byNumberDescending = (valueA, valueB) => {
8
5
  const a = Number(valueA);
9
6
  const b = Number(valueB);
10
7
  // Handle NaN cases
@@ -19,4 +16,3 @@ const byNumberDescending = (valueA, valueB) => {
19
16
  }
20
17
  return b - a;
21
18
  };
22
- exports.byNumberDescending = byNumberDescending;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.byStringAscending = void 0;
4
1
  /**
5
2
  * Take two values, clean the strings and return the sorting value.
6
3
  */
7
- const byStringAscending = (valueA, valueB) => {
4
+ export const byStringAscending = (valueA, valueB) => {
8
5
  const valueAClean = valueA.toString()
9
6
  .trim()
10
7
  .toLowerCase();
@@ -13,4 +10,3 @@ const byStringAscending = (valueA, valueB) => {
13
10
  .toLowerCase();
14
11
  return valueAClean.localeCompare(valueBClean);
15
12
  };
16
- exports.byStringAscending = byStringAscending;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.byStringDescending = void 0;
4
1
  /**
5
2
  * Take two values, clean the strings and return the sorting value.
6
3
  */
7
- const byStringDescending = (valueA, valueB) => {
4
+ export const byStringDescending = (valueA, valueB) => {
8
5
  const valueAClean = valueA.toString()
9
6
  .trim()
10
7
  .toLowerCase();
@@ -13,4 +10,3 @@ const byStringDescending = (valueA, valueB) => {
13
10
  .toLowerCase();
14
11
  return valueBClean.localeCompare(valueAClean);
15
12
  };
16
- exports.byStringDescending = byStringDescending;