@8ms/helpers 2.0.7 → 2.0.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.
Files changed (35) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/aws/ec2/AwsEc2Namespace.d.ts +1 -1
  3. package/aws/ec2/AwsEc2Namespace.js +0 -1
  4. package/aws/ecs/AwsEcsNamespace.d.ts +1 -1
  5. package/aws/ecs/AwsEcsNamespace.js +0 -1
  6. package/aws/glue/AwsGlueNamespace.d.ts +1 -1
  7. package/aws/glue/AwsGlueNamespace.js +0 -1
  8. package/aws/lambda/AwsLambdaNamespace.d.ts +1 -1
  9. package/aws/lambda/AwsLambdaNamespace.js +0 -1
  10. package/aws/s3/AwsS3Namespace.d.ts +1 -1
  11. package/aws/s3/AwsS3Namespace.js +0 -1
  12. package/aws/ses/AwsSesNamespace.d.ts +1 -1
  13. package/aws/ses/AwsSesNamespace.js +0 -1
  14. package/aws/sqs/AwsSqsNamespace.d.ts +1 -1
  15. package/aws/sqs/AwsSqsNamespace.js +0 -1
  16. package/aws/ssm/AwsSsmNamespace.d.ts +1 -1
  17. package/aws/ssm/AwsSsmNamespace.js +0 -1
  18. package/google/bigQuery/GoogleBigQueryNamespace.d.ts +1 -1
  19. package/google/bigQuery/GoogleBigQueryNamespace.js +0 -1
  20. package/google/sheets/GoogleSheetsNamespace.js +0 -3
  21. package/google/storage/GoogleCloudStorageNamespace.d.ts +1 -1
  22. package/google/storage/GoogleCloudStorageNamespace.js +0 -1
  23. package/googleAds/GoogleAdsNamespace.js +0 -2
  24. package/googlePageSpeed/GooglePageSpeedNamespace.d.ts +1 -1
  25. package/googlePageSpeed/GooglePageSpeedNamespace.js +0 -1
  26. package/littleWarden/LittleWardenNamespace.d.ts +1 -1
  27. package/littleWarden/LittleWardenNamespace.js +0 -1
  28. package/onePassword/OnePasswordNamespace.d.ts +1 -2
  29. package/onePassword/OnePasswordNamespace.js +2 -4
  30. package/openAi/OpenAiNamespace.js +0 -2
  31. package/package.json +1 -1
  32. package/prisma/PrismaNamespace.js +15 -8
  33. package/prisma/server.js +1 -0
  34. package/snapchat/SnapchatNamespace.js +2 -3
  35. package/upTimeRobot/UpTimeRobotNamespace.js +0 -2
Binary file
@@ -3,7 +3,7 @@ import { AwsConfig } from "../server";
3
3
  import type { EC2Client } from "@aws-sdk/client-ec2";
4
4
  export declare class AwsEc2Namespace extends BaseNamespace {
5
5
  client: EC2Client | null;
6
- config: AwsConfig;
6
+ config: AwsConfig | null;
7
7
  ensureInit: () => Promise<void>;
8
8
  startInstances: (instanceIds: string[], additionalInfo?: string, dryRun?: boolean) => Promise<any>;
9
9
  stopInstances: (instanceIds: string[], hibernate?: boolean, force?: boolean, dryRun?: boolean) => Promise<any>;
@@ -38,7 +38,6 @@ const _class_1 = require("../../_class");
38
38
  class AwsEc2Namespace extends _class_1.BaseNamespace {
39
39
  constructor() {
40
40
  super(...arguments);
41
- this.client = null;
42
41
  this.ensureInit = async () => {
43
42
  if (!this.client) {
44
43
  try {
@@ -26,7 +26,7 @@ type RunTaskProps = {
26
26
  };
27
27
  export declare class AwsEcsNamespace extends BaseNamespace {
28
28
  client: ECSClient | null;
29
- config: AwsConfig;
29
+ config: AwsConfig | null;
30
30
  ensureInit: () => Promise<void>;
31
31
  /**
32
32
  * https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ecs/command/ListClustersCommand/
@@ -39,7 +39,6 @@ const server_1 = require("../server");
39
39
  class AwsEcsNamespace extends _class_1.BaseNamespace {
40
40
  constructor() {
41
41
  super(...arguments);
42
- this.client = null;
43
42
  this.ensureInit = async () => {
44
43
  if (!this.client) {
45
44
  try {
@@ -3,7 +3,7 @@ import { AwsConfig } from "../server";
3
3
  import type { GlueClient } from "@aws-sdk/client-glue";
4
4
  export declare class AwsGlueNamespace extends BaseNamespace {
5
5
  client: GlueClient | null;
6
- config: AwsConfig;
6
+ config: AwsConfig | null;
7
7
  ensureInit: () => Promise<void>;
8
8
  /**
9
9
  * Invoke an AWS Glue Crawler by passing in the name of the Crawler.
@@ -39,7 +39,6 @@ const server_1 = require("../server");
39
39
  class AwsGlueNamespace extends _class_1.BaseNamespace {
40
40
  constructor() {
41
41
  super(...arguments);
42
- this.client = null;
43
42
  this.ensureInit = async () => {
44
43
  if (!this.client) {
45
44
  try {
@@ -9,7 +9,7 @@ type InvokeProps = {
9
9
  };
10
10
  export declare class AwsLambdaNamespace extends BaseNamespace {
11
11
  client: LambdaClient | null;
12
- config: AwsConfig;
12
+ config: AwsConfig | null;
13
13
  ensureInit: () => Promise<void>;
14
14
  /**
15
15
  * Invoke a AWS Lambda function by passing in the Function name and optional Payload data.
@@ -40,7 +40,6 @@ const api_1 = require("../../api");
40
40
  class AwsLambdaNamespace extends _class_1.BaseNamespace {
41
41
  constructor() {
42
42
  super(...arguments);
43
- this.client = null;
44
43
  this.ensureInit = async () => {
45
44
  if (!this.client) {
46
45
  try {
@@ -17,7 +17,7 @@ type WritePresignedPostProps = {
17
17
  };
18
18
  export declare class AwsS3Namespace extends BaseNamespace {
19
19
  client: S3Client | null;
20
- config: AwsConfig;
20
+ config: AwsConfig | null;
21
21
  ensureInit: () => Promise<void>;
22
22
  copy: (fromBucket: string, fromKey: string, toBucket: string, toKey: string) => Promise<void>;
23
23
  deleteFile: (bucket: string, key: string) => Promise<void>;
@@ -48,7 +48,6 @@ const axios_1 = __importDefault(require("axios"));
48
48
  class AwsS3Namespace extends _class_1.BaseNamespace {
49
49
  constructor() {
50
50
  super(...arguments);
51
- this.client = null;
52
51
  this.ensureInit = async () => {
53
52
  if (!this.client) {
54
53
  try {
@@ -11,7 +11,7 @@ type SendProps = {
11
11
  };
12
12
  export declare class AwsSesNamespace extends BaseNamespace {
13
13
  client: SESClient | null;
14
- config: AwsConfig;
14
+ config: AwsConfig | null;
15
15
  ensureInit: () => Promise<void>;
16
16
  send: (props: SendProps) => Promise<any>;
17
17
  }
@@ -38,7 +38,6 @@ const _class_1 = require("../../_class");
38
38
  class AwsSesNamespace extends _class_1.BaseNamespace {
39
39
  constructor() {
40
40
  super(...arguments);
41
- this.client = null;
42
41
  this.ensureInit = async () => {
43
42
  if (!this.client) {
44
43
  try {
@@ -25,7 +25,7 @@ type AddToQueue = {
25
25
  };
26
26
  export declare class AwsSqsNamespace extends BaseNamespace {
27
27
  client: SQSClient | null;
28
- config: AwsConfig;
28
+ config: AwsConfig | null;
29
29
  ensureInit: () => Promise<void>;
30
30
  addToQueue: (props: AddToQueue) => Promise<import("@aws-sdk/client-sqs").SendMessageCommandOutput>;
31
31
  deleteFromQueue: (queueUrl: string, recipientHandle: string) => Promise<import("@aws-sdk/client-sqs").DeleteMessageCommandOutput>;
@@ -38,7 +38,6 @@ const _class_1 = require("../../_class");
38
38
  class AwsSqsNamespace extends _class_1.BaseNamespace {
39
39
  constructor() {
40
40
  super(...arguments);
41
- this.client = null;
42
41
  this.ensureInit = async () => {
43
42
  if (!this.client) {
44
43
  try {
@@ -3,7 +3,7 @@ import { AwsConfig } from "../server";
3
3
  import type { SSMClient } from "@aws-sdk/client-ssm";
4
4
  export declare class AwsSsmNamespace extends BaseNamespace {
5
5
  client: SSMClient | null;
6
- config: AwsConfig;
6
+ config: AwsConfig | null;
7
7
  parameters: Map<string, any>;
8
8
  constructor(key: string, config: any);
9
9
  ensureInit: () => Promise<void>;
@@ -38,7 +38,6 @@ const _class_1 = require("../../_class");
38
38
  class AwsSsmNamespace extends _class_1.BaseNamespace {
39
39
  constructor(key, config) {
40
40
  super(key, config);
41
- this.client = null;
42
41
  this.ensureInit = async () => {
43
42
  if (!this.client) {
44
43
  try {
@@ -16,7 +16,7 @@ type Tables = {
16
16
  };
17
17
  export declare class GoogleBigQueryNamespace extends BaseNamespace {
18
18
  client: BigQuery | null;
19
- config: GoogleCloudConfig;
19
+ config: GoogleCloudConfig | null;
20
20
  ensureInit: () => Promise<void>;
21
21
  /**
22
22
  * Create a Dataset if it doesn't already exist.
@@ -39,7 +39,6 @@ const server_1 = require("../server");
39
39
  class GoogleBigQueryNamespace extends _class_1.BaseNamespace {
40
40
  constructor() {
41
41
  super(...arguments);
42
- this.client = null;
43
42
  this.ensureInit = async () => {
44
43
  if (!this.client) {
45
44
  try {
@@ -39,9 +39,6 @@ const server_1 = require("../server");
39
39
  class GoogleSheetsNamespace extends _class_1.BaseNamespace {
40
40
  constructor() {
41
41
  super(...arguments);
42
- // Stores auth only for Google Sheets
43
- this.client = null;
44
- this.config = null;
45
42
  this.ensureInit = async () => {
46
43
  if (!this.client) {
47
44
  try {
@@ -3,7 +3,7 @@ import type { Storage } from "@google-cloud/storage";
3
3
  import { GoogleCloudConfig } from "../server";
4
4
  export declare class GoogleCloudStorageNamespace extends BaseNamespace {
5
5
  client: Storage | null;
6
- config: GoogleCloudConfig;
6
+ config: GoogleCloudConfig | null;
7
7
  ensureInit: () => Promise<void>;
8
8
  /**
9
9
  * Copy a local file to Google Cloud Storage.
@@ -39,7 +39,6 @@ const server_1 = require("../server");
39
39
  class GoogleCloudStorageNamespace extends _class_1.BaseNamespace {
40
40
  constructor() {
41
41
  super(...arguments);
42
- this.client = null;
43
42
  this.ensureInit = async () => {
44
43
  if (!this.client) {
45
44
  try {
@@ -38,8 +38,6 @@ const _class_1 = require("../_class");
38
38
  class GoogleAdsNamespace extends _class_1.BaseNamespace {
39
39
  constructor() {
40
40
  super(...arguments);
41
- this.client = null;
42
- this.config = null;
43
41
  this.mccAccountId = "";
44
42
  this.refreshToken = "";
45
43
  this.ensureInit = async () => {
@@ -5,7 +5,7 @@ import { Category, GooglePageSpeedConfig, Strategy } from "./server";
5
5
  */
6
6
  export declare class GooglePageSpeedNamespace extends BaseNamespace {
7
7
  client: boolean | null;
8
- config: GooglePageSpeedConfig;
8
+ config: GooglePageSpeedConfig | null;
9
9
  ensureInit: () => Promise<void>;
10
10
  getReport: (url: string, category?: Category, strategy?: Strategy) => Promise<any>;
11
11
  }
@@ -10,7 +10,6 @@ const axios_1 = require("../axios");
10
10
  class GooglePageSpeedNamespace extends _class_1.BaseNamespace {
11
11
  constructor() {
12
12
  super(...arguments);
13
- this.client = null;
14
13
  this.ensureInit = async () => {
15
14
  if (!this.client) {
16
15
  try {
@@ -5,7 +5,7 @@ import { LittleWardenConfig } from "./server";
5
5
  */
6
6
  export declare class LittleWardenNamespace extends BaseNamespace {
7
7
  client: boolean | null;
8
- config: LittleWardenConfig;
8
+ config: LittleWardenConfig | null;
9
9
  ensureInit: () => Promise<void>;
10
10
  getReport: (urlId: string) => Promise<any>;
11
11
  }
@@ -9,7 +9,6 @@ const axios_1 = require("../axios");
9
9
  class LittleWardenNamespace extends _class_1.BaseNamespace {
10
10
  constructor() {
11
11
  super(...arguments);
12
- this.client = null;
13
12
  this.ensureInit = async () => {
14
13
  if (!this.client) {
15
14
  try {
@@ -3,8 +3,7 @@ import { BaseNamespace } from "../_class";
3
3
  import type { Client } from "@1password/sdk";
4
4
  export declare class OnePasswordNamespace extends BaseNamespace {
5
5
  client: Client | null;
6
- config: OnePasswordConfig;
7
- constructor(key: string, config: OnePasswordConfig);
6
+ config: OnePasswordConfig | null;
8
7
  ensureInit: () => Promise<void>;
9
8
  listVaults: () => Promise<import("@1password/sdk").VaultOverview[]>;
10
9
  getItem: (vaultId: string, itemId: string) => Promise<import("@1password/sdk").Item>;
@@ -36,9 +36,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.OnePasswordNamespace = void 0;
37
37
  const _class_1 = require("../_class");
38
38
  class OnePasswordNamespace extends _class_1.BaseNamespace {
39
- constructor(key, config) {
40
- super(key, config);
41
- this.client = null;
39
+ constructor() {
40
+ super(...arguments);
42
41
  // Async setup to only initialise where required
43
42
  this.ensureInit = async () => {
44
43
  if (!this.client) {
@@ -76,6 +75,5 @@ class OnePasswordNamespace extends _class_1.BaseNamespace {
76
75
  return this.client.items.list(vaultId);
77
76
  };
78
77
  }
79
- ;
80
78
  }
81
79
  exports.OnePasswordNamespace = OnePasswordNamespace;
@@ -6,8 +6,6 @@ const axios_1 = require("../axios");
6
6
  class OpenAiNamespace extends _class_1.BaseNamespace {
7
7
  constructor() {
8
8
  super(...arguments);
9
- this.client = null;
10
- this.config = null;
11
9
  /**
12
10
  * Renew the access token as it expires every 3 hours.
13
11
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "2.0.7",
4
+ "version": "2.0.9",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
@@ -38,24 +38,28 @@ const _class_1 = require("../_class");
38
38
  class PrismaNamespace extends _class_1.BaseNamespace {
39
39
  constructor() {
40
40
  super(...arguments);
41
- this.client = null;
42
- this.config = null;
43
41
  // Async setup to only initialise where required
44
42
  this.ensureInit = async () => {
45
43
  if (!this.client) {
46
- try {
47
- const { PrismaClient } = await Promise.resolve().then(() => __importStar(require("@prisma/client")));
48
- let adapter;
49
- if (this.config.isPlanetScale) {
44
+ let adapter;
45
+ if (this.config.isPlanetScale) {
46
+ try {
50
47
  const { PrismaPlanetScale } = await Promise.resolve().then(() => __importStar(require("@prisma/adapter-planetscale")));
51
48
  adapter = new PrismaPlanetScale({
52
49
  url: this.config.url,
53
50
  });
54
51
  }
52
+ catch (e) {
53
+ throw new Error("PlanetScale Client not installed");
54
+ }
55
+ }
56
+ try {
57
+ const { PrismaClient } = await Promise.resolve().then(() => __importStar(require("@prisma/client")));
55
58
  // Show the full query if debugging
56
59
  if (this.config.isDebug) {
57
60
  this.client = new PrismaClient({
58
61
  adapter,
62
+ datasourceUrl: this.config.url,
59
63
  log: [
60
64
  {
61
65
  emit: "event",
@@ -66,11 +70,14 @@ class PrismaNamespace extends _class_1.BaseNamespace {
66
70
  }
67
71
  // Standard prisma
68
72
  else {
69
- this.client = new PrismaClient({ adapter });
73
+ this.client = new PrismaClient({
74
+ adapter,
75
+ datasourceUrl: this.config.url,
76
+ });
70
77
  }
71
78
  }
72
79
  catch (e) {
73
- throw new Error("Prisma / PlanetScale Client not installed");
80
+ throw new Error("Prisma Client not installed");
74
81
  }
75
82
  }
76
83
  };
package/prisma/server.js CHANGED
@@ -21,6 +21,7 @@ const prismaClient = async (key = "default", config) => {
21
21
  }
22
22
  }
23
23
  const namespace = new PrismaNamespace_1.PrismaNamespace(key, config);
24
+ await namespace.ensureInit();
24
25
  prismaNamespaces.set(key, namespace);
25
26
  return namespace;
26
27
  };
@@ -7,8 +7,6 @@ const luxon_1 = require("luxon");
7
7
  class SnapchatNamespace extends _class_1.BaseNamespace {
8
8
  constructor() {
9
9
  super(...arguments);
10
- this.client = null;
11
- this.config = null;
12
10
  /**
13
11
  * Renew the access token as it expires every 3 hours.
14
12
  */
@@ -19,7 +17,8 @@ class SnapchatNamespace extends _class_1.BaseNamespace {
19
17
  const apiResponse = await (0, axios_1.post)(url);
20
18
  if (apiResponse.isSuccess()) {
21
19
  this.client = {
22
- expires: luxon_1.DateTime.now().toUnixInteger() + (3 * 60 * 60 * 1000),
20
+ expires: luxon_1.DateTime.now()
21
+ .toUnixInteger() + (3 * 60 * 60 * 1000),
23
22
  refreshToken: apiResponse.getBodyDefaultTo(["data", "access_token"], null)
24
23
  };
25
24
  }
@@ -14,8 +14,6 @@ const isArray_1 = __importDefault(require("lodash/isArray"));
14
14
  class UpTimeRobotNamespace extends _class_1.BaseNamespace {
15
15
  constructor() {
16
16
  super(...arguments);
17
- this.client = null;
18
- this.config = null;
19
17
  /**
20
18
  * Renew the access token as it expires every 3 hours.
21
19
  */