@8ms/helpers 1.42.13 → 1.42.15

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 (47) hide show
  1. package/dist/api/ApiResponse.cjs +11 -11
  2. package/dist/api/ApiResponse.mjs +11 -11
  3. package/dist/api/isError.cjs +2 -2
  4. package/dist/api/isError.mjs +2 -2
  5. package/dist/api/isSuccess.cjs +2 -2
  6. package/dist/api/isSuccess.mjs +2 -2
  7. package/dist/api/response.cjs +2 -1
  8. package/dist/api/response.mjs +2 -2
  9. package/dist/aws/s3/readFile.cjs +9 -9
  10. package/dist/aws/s3/readFile.mjs +9 -9
  11. package/dist/aws/s3cache/getCache.cjs +2 -2
  12. package/dist/aws/s3cache/getCache.mjs +2 -2
  13. package/dist/axios/delete.cjs +2 -0
  14. package/dist/axios/delete.mjs +2 -0
  15. package/dist/axios/get.cjs +2 -0
  16. package/dist/axios/get.mjs +2 -0
  17. package/dist/axios/post.cjs +3 -1
  18. package/dist/axios/post.mjs +3 -1
  19. package/dist/brightData/serpApi/getAsyncRequestId.cjs +2 -2
  20. package/dist/brightData/serpApi/getAsyncRequestId.mjs +2 -2
  21. package/dist/brightData/webScraperIde/getRealtime.cjs +5 -5
  22. package/dist/brightData/webScraperIde/getRealtime.mjs +5 -5
  23. package/dist/date/getPredefinedTimeframe.cjs +4 -4
  24. package/dist/date/getPredefinedTimeframe.mjs +4 -4
  25. package/dist/environment/getEnvironment.cjs +4 -4
  26. package/dist/environment/getEnvironment.mjs +4 -4
  27. package/dist/environment/isAws.cjs +2 -2
  28. package/dist/environment/isAws.mjs +2 -2
  29. package/dist/environment/isDevelopment.cjs +2 -2
  30. package/dist/environment/isDevelopment.mjs +2 -2
  31. package/dist/environment/isProduction.cjs +2 -2
  32. package/dist/environment/isProduction.mjs +2 -2
  33. package/dist/environment/isStaging.cjs +2 -2
  34. package/dist/environment/isStaging.mjs +2 -2
  35. package/dist/google/bigQuery/loadData.cjs +1 -1
  36. package/dist/google/bigQuery/loadData.mjs +4 -4
  37. package/dist/googleAds/keywordPlanner/request.cjs +2 -1
  38. package/dist/googleAds/keywordPlanner/request.mjs +2 -2
  39. package/dist/littleWarden/isAllGood.cjs +2 -2
  40. package/dist/littleWarden/isAllGood.mjs +2 -2
  41. package/dist/littleWarden/isDanger.cjs +2 -2
  42. package/dist/littleWarden/isDanger.mjs +2 -2
  43. package/dist/littleWarden/isWarning.cjs +2 -2
  44. package/dist/littleWarden/isWarning.mjs +2 -2
  45. package/dist/url/writeUrlContents.cjs +2 -2
  46. package/dist/url/writeUrlContents.mjs +2 -2
  47. package/package.json +1 -1
@@ -1,17 +1,17 @@
1
1
  const require_util_defaultTo = require("../util/defaultTo.cjs");
2
- const require_api_index = require("./index.cjs");
2
+ require("./index.cjs");
3
3
  //#region src/api/ApiResponse.ts
4
4
  /**
5
5
  * Class version of the API to enable quicker instances.
6
6
  */
7
7
  var ApiResponse = class {
8
8
  constructor({ body, error, state } = {}) {
9
- this.state = require_api_index.State.IDLE;
9
+ this.state = "IDLE";
10
10
  this.body = null;
11
11
  this.error = null;
12
12
  this.body = body || null;
13
13
  this.error = error || null;
14
- this.state = state || require_api_index.State.IDLE;
14
+ this.state = state || "IDLE";
15
15
  return this;
16
16
  }
17
17
  fromJson({ input }) {
@@ -44,34 +44,34 @@ var ApiResponse = class {
44
44
  return this.state;
45
45
  }
46
46
  isError() {
47
- return this.state === require_api_index.State.ERROR;
47
+ return this.state === "ERROR";
48
48
  }
49
49
  isIdle() {
50
- return this.state === require_api_index.State.IDLE;
50
+ return this.state === "IDLE";
51
51
  }
52
52
  isPending() {
53
- return this.state === require_api_index.State.PENDING;
53
+ return this.state === "PENDING";
54
54
  }
55
55
  isSuccess() {
56
- return this.state === require_api_index.State.SUCCESS;
56
+ return this.state === "SUCCESS";
57
57
  }
58
58
  setToIdle() {
59
- this.state = require_api_index.State.IDLE;
59
+ this.state = "IDLE";
60
60
  return this;
61
61
  }
62
62
  setToPending() {
63
- this.state = require_api_index.State.PENDING;
63
+ this.state = "PENDING";
64
64
  return this;
65
65
  }
66
66
  setToError({ body, error }) {
67
67
  this.body = body || null;
68
68
  this.error = error;
69
- this.state = require_api_index.State.ERROR;
69
+ this.state = "ERROR";
70
70
  return this;
71
71
  }
72
72
  setToSuccess({ body }) {
73
73
  this.body = body;
74
- this.state = require_api_index.State.SUCCESS;
74
+ this.state = "SUCCESS";
75
75
  return this;
76
76
  }
77
77
  setBody({ body }) {
@@ -1,17 +1,17 @@
1
1
  import defaultTo from "../util/defaultTo.mjs";
2
- import { State } from "./index.mjs";
2
+ import "./index.mjs";
3
3
  //#region src/api/ApiResponse.ts
4
4
  /**
5
5
  * Class version of the API to enable quicker instances.
6
6
  */
7
7
  var ApiResponse = class {
8
8
  constructor({ body, error, state } = {}) {
9
- this.state = State.IDLE;
9
+ this.state = "IDLE";
10
10
  this.body = null;
11
11
  this.error = null;
12
12
  this.body = body || null;
13
13
  this.error = error || null;
14
- this.state = state || State.IDLE;
14
+ this.state = state || "IDLE";
15
15
  return this;
16
16
  }
17
17
  fromJson({ input }) {
@@ -44,34 +44,34 @@ var ApiResponse = class {
44
44
  return this.state;
45
45
  }
46
46
  isError() {
47
- return this.state === State.ERROR;
47
+ return this.state === "ERROR";
48
48
  }
49
49
  isIdle() {
50
- return this.state === State.IDLE;
50
+ return this.state === "IDLE";
51
51
  }
52
52
  isPending() {
53
- return this.state === State.PENDING;
53
+ return this.state === "PENDING";
54
54
  }
55
55
  isSuccess() {
56
- return this.state === State.SUCCESS;
56
+ return this.state === "SUCCESS";
57
57
  }
58
58
  setToIdle() {
59
- this.state = State.IDLE;
59
+ this.state = "IDLE";
60
60
  return this;
61
61
  }
62
62
  setToPending() {
63
- this.state = State.PENDING;
63
+ this.state = "PENDING";
64
64
  return this;
65
65
  }
66
66
  setToError({ body, error }) {
67
67
  this.body = body || null;
68
68
  this.error = error;
69
- this.state = State.ERROR;
69
+ this.state = "ERROR";
70
70
  return this;
71
71
  }
72
72
  setToSuccess({ body }) {
73
73
  this.body = body;
74
- this.state = State.SUCCESS;
74
+ this.state = "SUCCESS";
75
75
  return this;
76
76
  }
77
77
  setBody({ body }) {
@@ -1,7 +1,7 @@
1
- const require_api_index = require("./index.cjs");
1
+ require("./index.cjs");
2
2
  //#region src/api/isError.ts
3
3
  const isError = (props) => {
4
- return require_api_index.State.ERROR === props.response.state;
4
+ return "ERROR" === props.response.state;
5
5
  };
6
6
  //#endregion
7
7
  module.exports = isError;
@@ -1,7 +1,7 @@
1
- import { State } from "./index.mjs";
1
+ import "./index.mjs";
2
2
  //#region src/api/isError.ts
3
3
  const isError = (props) => {
4
- return State.ERROR === props.response.state;
4
+ return "ERROR" === props.response.state;
5
5
  };
6
6
  //#endregion
7
7
  export { isError as default };
@@ -1,7 +1,7 @@
1
- const require_api_index = require("./index.cjs");
1
+ require("./index.cjs");
2
2
  //#region src/api/isSuccess.ts
3
3
  const isSuccess = (props) => {
4
- return require_api_index.State.SUCCESS === props.response.state;
4
+ return "SUCCESS" === props.response.state;
5
5
  };
6
6
  //#endregion
7
7
  module.exports = isSuccess;
@@ -1,7 +1,7 @@
1
- import { State } from "./index.mjs";
1
+ import "./index.mjs";
2
2
  //#region src/api/isSuccess.ts
3
3
  const isSuccess = (props) => {
4
- return State.SUCCESS === props.response.state;
4
+ return "SUCCESS" === props.response.state;
5
5
  };
6
6
  //#endregion
7
7
  export { isSuccess as default };
@@ -1,8 +1,9 @@
1
+ require("./index.cjs");
1
2
  //#region src/api/response.ts
2
3
  const response = {
3
4
  body: null,
4
5
  error: null,
5
- state: require("./index.cjs").State.IDLE
6
+ state: "IDLE"
6
7
  };
7
8
  //#endregion
8
9
  module.exports = response;
@@ -1,9 +1,9 @@
1
- import { State } from "./index.mjs";
1
+ import "./index.mjs";
2
2
  //#region src/api/response.ts
3
3
  const response = {
4
4
  body: null,
5
5
  error: null,
6
- state: State.IDLE
6
+ state: "IDLE"
7
7
  };
8
8
  //#endregion
9
9
  export { response as default };
@@ -6,7 +6,7 @@ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
6
6
  const require_aws_isResponse200 = require("../isResponse200.cjs");
7
7
  const require_date_getDate = require("../../date/getDate.cjs");
8
8
  const require_date_getToday = require("../../date/getToday.cjs");
9
- const require_date_index = require("../../date/index.cjs");
9
+ require("../../date/index.cjs");
10
10
  const require_string_getStringFromStream = require("../../string/getStringFromStream.cjs");
11
11
  const require_aws_s3_isFileExists = require("./isFileExists.cjs");
12
12
  let date_fns = require("date-fns");
@@ -18,13 +18,13 @@ const readFileDefault = {
18
18
  now: void 0,
19
19
  modified: {
20
20
  unix: null,
21
- [require_date_index.DurationComparison.VS_NOW]: {
21
+ ["VS_NOW"]: {
22
22
  months: 0,
23
23
  days: 0,
24
24
  hours: 0,
25
25
  minutes: 0
26
26
  },
27
- [require_date_index.DurationComparison.VS_MIDNIGHT]: {
27
+ ["VS_MIDNIGHT"]: {
28
28
  hours: 0,
29
29
  minutes: 0
30
30
  }
@@ -53,12 +53,12 @@ const readFile = async ({ bucket, key, isJson }) => {
53
53
  setMidnight: false
54
54
  });
55
55
  response.modified.unix = (0, date_fns.getUnixTime)(modified);
56
- response.modified[require_date_index.DurationComparison.VS_NOW].months = (0, date_fns.differenceInMonths)(now, modified);
57
- response.modified[require_date_index.DurationComparison.VS_NOW].days = (0, date_fns.differenceInDays)(now, modified);
58
- response.modified[require_date_index.DurationComparison.VS_NOW].hours = (0, date_fns.differenceInHours)(now, modified);
59
- response.modified[require_date_index.DurationComparison.VS_NOW].minutes = (0, date_fns.differenceInMinutes)(now, modified);
60
- response.modified[require_date_index.DurationComparison.VS_MIDNIGHT].hours = (0, date_fns.getHours)(now);
61
- response.modified[require_date_index.DurationComparison.VS_MIDNIGHT].minutes = (0, date_fns.getMinutes)(now);
56
+ response.modified["VS_NOW"].months = (0, date_fns.differenceInMonths)(now, modified);
57
+ response.modified["VS_NOW"].days = (0, date_fns.differenceInDays)(now, modified);
58
+ response.modified["VS_NOW"].hours = (0, date_fns.differenceInHours)(now, modified);
59
+ response.modified["VS_NOW"].minutes = (0, date_fns.differenceInMinutes)(now, modified);
60
+ response.modified["VS_MIDNIGHT"].hours = (0, date_fns.getHours)(now);
61
+ response.modified["VS_MIDNIGHT"].minutes = (0, date_fns.getMinutes)(now);
62
62
  response.body = await require_string_getStringFromStream({ stream: apiResponse.Body });
63
63
  if (false !== isJson) response.body = JSON.parse(response.body) || void 0;
64
64
  }
@@ -1,7 +1,7 @@
1
1
  import isResponse200 from "../isResponse200.mjs";
2
2
  import getDate from "../../date/getDate.mjs";
3
3
  import getToday from "../../date/getToday.mjs";
4
- import { DurationComparison } from "../../date/index.mjs";
4
+ import "../../date/index.mjs";
5
5
  import getStringFromStream from "../../string/getStringFromStream.mjs";
6
6
  import isFileExists from "./isFileExists.mjs";
7
7
  import { differenceInDays, differenceInHours, differenceInMinutes, differenceInMonths, getHours, getMinutes, getUnixTime } from "date-fns";
@@ -12,13 +12,13 @@ const readFileDefault = {
12
12
  now: void 0,
13
13
  modified: {
14
14
  unix: null,
15
- [DurationComparison.VS_NOW]: {
15
+ ["VS_NOW"]: {
16
16
  months: 0,
17
17
  days: 0,
18
18
  hours: 0,
19
19
  minutes: 0
20
20
  },
21
- [DurationComparison.VS_MIDNIGHT]: {
21
+ ["VS_MIDNIGHT"]: {
22
22
  hours: 0,
23
23
  minutes: 0
24
24
  }
@@ -47,12 +47,12 @@ const readFile = async ({ bucket, key, isJson }) => {
47
47
  setMidnight: false
48
48
  });
49
49
  response.modified.unix = getUnixTime(modified);
50
- response.modified[DurationComparison.VS_NOW].months = differenceInMonths(now, modified);
51
- response.modified[DurationComparison.VS_NOW].days = differenceInDays(now, modified);
52
- response.modified[DurationComparison.VS_NOW].hours = differenceInHours(now, modified);
53
- response.modified[DurationComparison.VS_NOW].minutes = differenceInMinutes(now, modified);
54
- response.modified[DurationComparison.VS_MIDNIGHT].hours = getHours(now);
55
- response.modified[DurationComparison.VS_MIDNIGHT].minutes = getMinutes(now);
50
+ response.modified["VS_NOW"].months = differenceInMonths(now, modified);
51
+ response.modified["VS_NOW"].days = differenceInDays(now, modified);
52
+ response.modified["VS_NOW"].hours = differenceInHours(now, modified);
53
+ response.modified["VS_NOW"].minutes = differenceInMinutes(now, modified);
54
+ response.modified["VS_MIDNIGHT"].hours = getHours(now);
55
+ response.modified["VS_MIDNIGHT"].minutes = getMinutes(now);
56
56
  response.body = await getStringFromStream({ stream: apiResponse.Body });
57
57
  if (false !== isJson) response.body = JSON.parse(response.body) || void 0;
58
58
  }
@@ -1,4 +1,4 @@
1
- const require_date_index = require("../../date/index.cjs");
1
+ require("../../date/index.cjs");
2
2
  const require_aws_s3_readGzip = require("../s3/readGzip.cjs");
3
3
  const require_aws_s3cache_getKey = require("./getKey.cjs");
4
4
  //#region src/aws/s3cache/getCache.ts
@@ -17,7 +17,7 @@ const getCache = async ({ bucket, cache, fileName, folder }) => {
17
17
  key: s3CacheKey,
18
18
  isJson: true
19
19
  });
20
- if (void 0 !== cached.body && (require_date_index.Interval.FOREVER === cache.timeframe || cached.modified[cache.from][cache.timeframe] < cache.duration)) response = cached.body;
20
+ if (void 0 !== cached.body && ("FOREVER" === cache.timeframe || cached.modified[cache.from][cache.timeframe] < cache.duration)) response = cached.body;
21
21
  } catch (error) {}
22
22
  return response;
23
23
  };
@@ -1,4 +1,4 @@
1
- import { Interval } from "../../date/index.mjs";
1
+ import "../../date/index.mjs";
2
2
  import readGzip from "../s3/readGzip.mjs";
3
3
  import getKey from "./getKey.mjs";
4
4
  //#region src/aws/s3cache/getCache.ts
@@ -17,7 +17,7 @@ const getCache = async ({ bucket, cache, fileName, folder }) => {
17
17
  key: s3CacheKey,
18
18
  isJson: true
19
19
  });
20
- if (void 0 !== cached.body && (Interval.FOREVER === cache.timeframe || cached.modified[cache.from][cache.timeframe] < cache.duration)) response = cached.body;
20
+ if (void 0 !== cached.body && ("FOREVER" === cache.timeframe || cached.modified[cache.from][cache.timeframe] < cache.duration)) response = cached.body;
21
21
  } catch (error) {}
22
22
  return response;
23
23
  };
@@ -7,6 +7,8 @@ const require_api_ApiResponse = require("../api/ApiResponse.cjs");
7
7
  const deleteRequest = async (props) => {
8
8
  const { default: ky } = await import("ky");
9
9
  return await ky.delete(props.url, {
10
+ retry: 0,
11
+ timeout: false,
10
12
  throwHttpErrors: false,
11
13
  ...props.config
12
14
  }).then(async (response) => {
@@ -7,6 +7,8 @@ import ApiResponse from "../api/ApiResponse.mjs";
7
7
  const deleteRequest = async (props) => {
8
8
  const { default: ky } = await import("ky");
9
9
  return await ky.delete(props.url, {
10
+ retry: 0,
11
+ timeout: false,
10
12
  throwHttpErrors: false,
11
13
  ...props.config
12
14
  }).then(async (response) => {
@@ -6,6 +6,8 @@ const require_api_ApiResponse = require("../api/ApiResponse.cjs");
6
6
  const get = async ({ config = {}, url }) => {
7
7
  const { default: ky } = await import("ky");
8
8
  return await ky.get(url, {
9
+ retry: 0,
10
+ timeout: false,
9
11
  throwHttpErrors: false,
10
12
  ...config
11
13
  }).then(async (response) => {
@@ -6,6 +6,8 @@ import ApiResponse from "../api/ApiResponse.mjs";
6
6
  const get = async ({ config = {}, url }) => {
7
7
  const { default: ky } = await import("ky");
8
8
  return await ky.get(url, {
9
+ retry: 0,
10
+ timeout: false,
9
11
  throwHttpErrors: false,
10
12
  ...config
11
13
  }).then(async (response) => {
@@ -6,8 +6,10 @@ const require_api_ApiResponse = require("../api/ApiResponse.cjs");
6
6
  const post = async ({ config = {}, data = {}, url }) => {
7
7
  const { default: ky } = await import("ky");
8
8
  return await ky.post(url, {
9
- throwHttpErrors: false,
10
9
  json: data,
10
+ retry: 0,
11
+ timeout: false,
12
+ throwHttpErrors: false,
11
13
  ...config
12
14
  }).then(async (response) => {
13
15
  const data = await response.json();
@@ -6,8 +6,10 @@ import ApiResponse from "../api/ApiResponse.mjs";
6
6
  const post = async ({ config = {}, data = {}, url }) => {
7
7
  const { default: ky } = await import("ky");
8
8
  return await ky.post(url, {
9
- throwHttpErrors: false,
10
9
  json: data,
10
+ retry: 0,
11
+ timeout: false,
12
+ throwHttpErrors: false,
11
13
  ...config
12
14
  }).then(async (response) => {
13
15
  const data = await response.json();
@@ -1,7 +1,7 @@
1
1
  const require_axios_post = require("../../axios/post.cjs");
2
2
  const require_brightData_getCustomerId = require("../getCustomerId.cjs");
3
3
  const require_brightData_getZone = require("../getZone.cjs");
4
- const require_brightData_serpApi_type = require("./type.cjs");
4
+ require("./type.cjs");
5
5
  //#region src/brightData/serpApi/getAsyncRequestId.ts
6
6
  /**
7
7
  * Make an async request to the SERP API using the Bright Data proxy.
@@ -15,7 +15,7 @@ const getAsyncRequestId = async (props) => {
15
15
  const customerId = require_brightData_getCustomerId({ auth: props.auth });
16
16
  const zone = require_brightData_getZone({ auth: props.auth });
17
17
  switch (props.type) {
18
- case require_brightData_serpApi_type.Type.GOOGLE_TRENDS:
18
+ case "GOOGLE_TRENDS":
19
19
  url = `https://api.brightdata.com/serp/trends?customer=${customerId}&zone=${zone}`;
20
20
  break;
21
21
  default: url = `https://api.brightdata.com/serp/req?customer=${customerId}&zone=${zone}`;
@@ -1,7 +1,7 @@
1
1
  import post from "../../axios/post.mjs";
2
2
  import getCustomerId from "../getCustomerId.mjs";
3
3
  import getZone from "../getZone.mjs";
4
- import { Type } from "./type.mjs";
4
+ import "./type.mjs";
5
5
  //#region src/brightData/serpApi/getAsyncRequestId.ts
6
6
  /**
7
7
  * Make an async request to the SERP API using the Bright Data proxy.
@@ -15,7 +15,7 @@ const getAsyncRequestId = async (props) => {
15
15
  const customerId = getCustomerId({ auth: props.auth });
16
16
  const zone = getZone({ auth: props.auth });
17
17
  switch (props.type) {
18
- case Type.GOOGLE_TRENDS:
18
+ case "GOOGLE_TRENDS":
19
19
  url = `https://api.brightdata.com/serp/trends?customer=${customerId}&zone=${zone}`;
20
20
  break;
21
21
  default: url = `https://api.brightdata.com/serp/req?customer=${customerId}&zone=${zone}`;
@@ -1,4 +1,4 @@
1
- const require_api_index = require("../../api/index.cjs");
1
+ require("../../api/index.cjs");
2
2
  const require_axios_post = require("../../axios/post.cjs");
3
3
  const require_axios_get = require("../../axios/get.cjs");
4
4
  const require_util_sleep = require("../../util/sleep.cjs");
@@ -22,16 +22,16 @@ const getRealtime = async (props) => {
22
22
  keys: ["response_id"]
23
23
  });
24
24
  if ("" !== responseId) {
25
- let state = require_api_index.State.PENDING;
26
- while (require_api_index.State.PENDING === state) {
25
+ let state = "PENDING";
26
+ while ("PENDING" === state) {
27
27
  const resultUrl = `https://api.brightdata.com/dca/get_result?response_id=${responseId}`;
28
28
  const resultResponse = await require_axios_get({
29
29
  config: { headers: { Authorization: `Bearer ${props.auth.apiKey}` } },
30
30
  url: resultUrl
31
31
  });
32
- if (resultResponse.isSuccess()) if (void 0 !== resultResponse.body.pending && true === resultResponse.body.pending) state = require_api_index.State.PENDING;
32
+ if (resultResponse.isSuccess()) if (void 0 !== resultResponse.body.pending && true === resultResponse.body.pending) state = "PENDING";
33
33
  else {
34
- state = require_api_index.State.SUCCESS;
34
+ state = "SUCCESS";
35
35
  response = resultResponse.getBody();
36
36
  }
37
37
  await require_util_sleep({ seconds: 1 });
@@ -1,4 +1,4 @@
1
- import { State } from "../../api/index.mjs";
1
+ import "../../api/index.mjs";
2
2
  import post from "../../axios/post.mjs";
3
3
  import get from "../../axios/get.mjs";
4
4
  import sleep from "../../util/sleep.mjs";
@@ -22,16 +22,16 @@ const getRealtime = async (props) => {
22
22
  keys: ["response_id"]
23
23
  });
24
24
  if ("" !== responseId) {
25
- let state = State.PENDING;
26
- while (State.PENDING === state) {
25
+ let state = "PENDING";
26
+ while ("PENDING" === state) {
27
27
  const resultUrl = `https://api.brightdata.com/dca/get_result?response_id=${responseId}`;
28
28
  const resultResponse = await get({
29
29
  config: { headers: { Authorization: `Bearer ${props.auth.apiKey}` } },
30
30
  url: resultUrl
31
31
  });
32
- if (resultResponse.isSuccess()) if (void 0 !== resultResponse.body.pending && true === resultResponse.body.pending) state = State.PENDING;
32
+ if (resultResponse.isSuccess()) if (void 0 !== resultResponse.body.pending && true === resultResponse.body.pending) state = "PENDING";
33
33
  else {
34
- state = State.SUCCESS;
34
+ state = "SUCCESS";
35
35
  response = resultResponse.getBody();
36
36
  }
37
37
  await sleep({ seconds: 1 });
@@ -1,14 +1,14 @@
1
1
  const require_date_isLastWeek = require("./isLastWeek.cjs");
2
2
  const require_date_isThisWeek = require("./isThisWeek.cjs");
3
- const require_date_index = require("./index.cjs");
3
+ require("./index.cjs");
4
4
  //#region src/date/getPredefinedTimeframe.ts
5
5
  /**
6
6
  * Check to see the date matches a predefined time frame
7
7
  */
8
8
  const getPredefinedTimeframe = ({ timeframe }) => {
9
- let response = require_date_index.PredefinedTimeframe.CUSTOM;
10
- if (require_date_isLastWeek(timeframe)) response = require_date_index.PredefinedTimeframe.LAST_WEEK;
11
- else if (require_date_isThisWeek(timeframe)) response = require_date_index.PredefinedTimeframe.THIS_WEEK;
9
+ let response = "CUSTOM";
10
+ if (require_date_isLastWeek(timeframe)) response = "LAST_WEEK";
11
+ else if (require_date_isThisWeek(timeframe)) response = "THIS_WEEK";
12
12
  return response;
13
13
  };
14
14
  //#endregion
@@ -1,14 +1,14 @@
1
1
  import isLastWeek from "./isLastWeek.mjs";
2
2
  import isThisWeek from "./isThisWeek.mjs";
3
- import { PredefinedTimeframe } from "./index.mjs";
3
+ import "./index.mjs";
4
4
  //#region src/date/getPredefinedTimeframe.ts
5
5
  /**
6
6
  * Check to see the date matches a predefined time frame
7
7
  */
8
8
  const getPredefinedTimeframe = ({ timeframe }) => {
9
- let response = PredefinedTimeframe.CUSTOM;
10
- if (isLastWeek(timeframe)) response = PredefinedTimeframe.LAST_WEEK;
11
- else if (isThisWeek(timeframe)) response = PredefinedTimeframe.THIS_WEEK;
9
+ let response = "CUSTOM";
10
+ if (isLastWeek(timeframe)) response = "LAST_WEEK";
11
+ else if (isThisWeek(timeframe)) response = "THIS_WEEK";
12
12
  return response;
13
13
  };
14
14
  //#endregion
@@ -1,4 +1,4 @@
1
- const require_environment_index = require("./index.cjs");
1
+ require("./index.cjs");
2
2
  //#region src/environment/getEnvironment.ts
3
3
  /**
4
4
  * Determine the environment we're using.
@@ -12,14 +12,14 @@ const getEnvironment = () => {
12
12
  else if (process.env.VERCEL_GIT_COMMIT_REF) platformEnvironment = process.env.VERCEL_GIT_COMMIT_REF;
13
13
  switch (platformEnvironment.toLowerCase().trim()) {
14
14
  case "development":
15
- response = require_environment_index.Environment.DEVELOPMENT;
15
+ response = "development";
16
16
  break;
17
17
  case "demo":
18
18
  case "preview":
19
19
  case "staging":
20
- response = require_environment_index.Environment.STAGING;
20
+ response = "staging";
21
21
  break;
22
- default: response = require_environment_index.Environment.PRODUCTION;
22
+ default: response = "production";
23
23
  }
24
24
  return response;
25
25
  };
@@ -1,4 +1,4 @@
1
- import { Environment } from "./index.mjs";
1
+ import "./index.mjs";
2
2
  //#region src/environment/getEnvironment.ts
3
3
  /**
4
4
  * Determine the environment we're using.
@@ -12,14 +12,14 @@ const getEnvironment = () => {
12
12
  else if (process.env.VERCEL_GIT_COMMIT_REF) platformEnvironment = process.env.VERCEL_GIT_COMMIT_REF;
13
13
  switch (platformEnvironment.toLowerCase().trim()) {
14
14
  case "development":
15
- response = Environment.DEVELOPMENT;
15
+ response = "development";
16
16
  break;
17
17
  case "demo":
18
18
  case "preview":
19
19
  case "staging":
20
- response = Environment.STAGING;
20
+ response = "staging";
21
21
  break;
22
- default: response = Environment.PRODUCTION;
22
+ default: response = "production";
23
23
  }
24
24
  return response;
25
25
  };
@@ -1,8 +1,8 @@
1
- const require_environment_index = require("./index.cjs");
1
+ require("./index.cjs");
2
2
  //#region src/environment/isAws.ts
3
3
  /**
4
4
  * Check to see if we are working on AWS Lambda.
5
5
  */
6
- const isAws = () => require_environment_index.Platform.AWS === process.env["EMS_PLATFORM"];
6
+ const isAws = () => "AWS" === process.env["EMS_PLATFORM"];
7
7
  //#endregion
8
8
  module.exports = isAws;
@@ -1,8 +1,8 @@
1
- import { Platform } from "./index.mjs";
1
+ import "./index.mjs";
2
2
  //#region src/environment/isAws.ts
3
3
  /**
4
4
  * Check to see if we are working on AWS Lambda.
5
5
  */
6
- const isAws = () => Platform.AWS === process.env["EMS_PLATFORM"];
6
+ const isAws = () => "AWS" === process.env["EMS_PLATFORM"];
7
7
  //#endregion
8
8
  export { isAws as default };
@@ -1,6 +1,6 @@
1
- const require_environment_index = require("./index.cjs");
1
+ require("./index.cjs");
2
2
  const require_environment_getEnvironment = require("./getEnvironment.cjs");
3
3
  //#region src/environment/isDevelopment.ts
4
- const isDevelopment = () => require_environment_index.Environment.DEVELOPMENT === require_environment_getEnvironment();
4
+ const isDevelopment = () => "development" === require_environment_getEnvironment();
5
5
  //#endregion
6
6
  module.exports = isDevelopment;
@@ -1,6 +1,6 @@
1
- import { Environment } from "./index.mjs";
1
+ import "./index.mjs";
2
2
  import getEnvironment from "./getEnvironment.mjs";
3
3
  //#region src/environment/isDevelopment.ts
4
- const isDevelopment = () => Environment.DEVELOPMENT === getEnvironment();
4
+ const isDevelopment = () => "development" === getEnvironment();
5
5
  //#endregion
6
6
  export { isDevelopment as default };
@@ -1,6 +1,6 @@
1
- const require_environment_index = require("./index.cjs");
1
+ require("./index.cjs");
2
2
  const require_environment_getEnvironment = require("./getEnvironment.cjs");
3
3
  //#region src/environment/isProduction.ts
4
- const isProduction = () => require_environment_index.Environment.PRODUCTION === require_environment_getEnvironment();
4
+ const isProduction = () => "production" === require_environment_getEnvironment();
5
5
  //#endregion
6
6
  module.exports = isProduction;
@@ -1,6 +1,6 @@
1
- import { Environment } from "./index.mjs";
1
+ import "./index.mjs";
2
2
  import getEnvironment from "./getEnvironment.mjs";
3
3
  //#region src/environment/isProduction.ts
4
- const isProduction = () => Environment.PRODUCTION === getEnvironment();
4
+ const isProduction = () => "production" === getEnvironment();
5
5
  //#endregion
6
6
  export { isProduction as default };
@@ -1,6 +1,6 @@
1
- const require_environment_index = require("./index.cjs");
1
+ require("./index.cjs");
2
2
  const require_environment_getEnvironment = require("./getEnvironment.cjs");
3
3
  //#region src/environment/isStaging.ts
4
- const isStaging = () => require_environment_index.Environment.STAGING === require_environment_getEnvironment();
4
+ const isStaging = () => "staging" === require_environment_getEnvironment();
5
5
  //#endregion
6
6
  module.exports = isStaging;
@@ -1,6 +1,6 @@
1
- import { Environment } from "./index.mjs";
1
+ import "./index.mjs";
2
2
  import getEnvironment from "./getEnvironment.mjs";
3
3
  //#region src/environment/isStaging.ts
4
- const isStaging = () => Environment.STAGING === getEnvironment();
4
+ const isStaging = () => "staging" === getEnvironment();
5
5
  //#endregion
6
6
  export { isStaging as default };
@@ -1,6 +1,6 @@
1
- const require_google_storage_getClient = require("../storage/getClient.cjs");
2
1
  const require_google_bigQuery_getClient = require("./getClient.cjs");
3
2
  const require_google_bigQuery_IsTableExists = require("./IsTableExists.cjs");
3
+ const require_google_storage_getClient = require("../storage/getClient.cjs");
4
4
  //#region src/google/bigQuery/loadData.ts
5
5
  /**
6
6
  * Load data into a given table.
@@ -1,6 +1,6 @@
1
- import getClient from "../storage/getClient.mjs";
2
- import getClient$1 from "./getClient.mjs";
1
+ import getClient from "./getClient.mjs";
3
2
  import isTableExists from "./IsTableExists.mjs";
3
+ import getClient$1 from "../storage/getClient.mjs";
4
4
  //#region src/google/bigQuery/loadData.ts
5
5
  /**
6
6
  * Load data into a given table.
@@ -11,8 +11,8 @@ const loadData = async ({ file, table }) => {
11
11
  projectId: table.projectId,
12
12
  tableId: table.tableId
13
13
  })) {
14
- let bigqueryClient = await getClient$1({ projectId: table.projectId });
15
- let storageClient = await getClient({ projectId: file.projectId });
14
+ let bigqueryClient = await getClient({ projectId: table.projectId });
15
+ let storageClient = await getClient$1({ projectId: file.projectId });
16
16
  await bigqueryClient.dataset(table.datasetId).table(table.tableId).load(storageClient.bucket(file.bucket).file(file.key), file.metadata);
17
17
  }
18
18
  };
@@ -1,10 +1,11 @@
1
+ require("./index.cjs");
1
2
  //#region src/googleAds/keywordPlanner/request.ts
2
3
  const request = {
3
4
  countries: [],
4
5
  customerId: "",
5
6
  historicalMetricsOptions: null,
6
7
  includeAdultKeywords: false,
7
- keywordPlanNetwork: require("./index.cjs").Network.GOOGLE_SEARCH_ONLY,
8
+ keywordPlanNetwork: 2,
8
9
  queries: [],
9
10
  language: null
10
11
  };
@@ -1,11 +1,11 @@
1
- import { Network } from "./index.mjs";
1
+ import "./index.mjs";
2
2
  //#region src/googleAds/keywordPlanner/request.ts
3
3
  const request = {
4
4
  countries: [],
5
5
  customerId: "",
6
6
  historicalMetricsOptions: null,
7
7
  includeAdultKeywords: false,
8
- keywordPlanNetwork: Network.GOOGLE_SEARCH_ONLY,
8
+ keywordPlanNetwork: 2,
9
9
  queries: [],
10
10
  language: null
11
11
  };
@@ -1,11 +1,11 @@
1
- const require_littleWarden_index = require("./index.cjs");
1
+ require("./index.cjs");
2
2
  //#region src/littleWarden/isAllGood.ts
3
3
  /**
4
4
  * Check if the field is All Good.
5
5
  */
6
6
  const isAllGood = ({ field }) => {
7
7
  let response = false;
8
- if (void 0 !== field && void 0 !== field["status"]) response = require_littleWarden_index.State.ALL_GOOD === field["status"];
8
+ if (void 0 !== field && void 0 !== field["status"]) response = "all_good" === field["status"];
9
9
  return response;
10
10
  };
11
11
  //#endregion
@@ -1,11 +1,11 @@
1
- import { State } from "./index.mjs";
1
+ import "./index.mjs";
2
2
  //#region src/littleWarden/isAllGood.ts
3
3
  /**
4
4
  * Check if the field is All Good.
5
5
  */
6
6
  const isAllGood = ({ field }) => {
7
7
  let response = false;
8
- if (void 0 !== field && void 0 !== field["status"]) response = State.ALL_GOOD === field["status"];
8
+ if (void 0 !== field && void 0 !== field["status"]) response = "all_good" === field["status"];
9
9
  return response;
10
10
  };
11
11
  //#endregion
@@ -1,11 +1,11 @@
1
- const require_littleWarden_index = require("./index.cjs");
1
+ require("./index.cjs");
2
2
  //#region src/littleWarden/isDanger.ts
3
3
  /**
4
4
  * Check if the field is Danger.
5
5
  */
6
6
  const isDanger = ({ field }) => {
7
7
  let response = false;
8
- if (void 0 !== field && void 0 !== field["status"]) response = require_littleWarden_index.State.DANGER === field["status"];
8
+ if (void 0 !== field && void 0 !== field["status"]) response = "danger" === field["status"];
9
9
  return response;
10
10
  };
11
11
  //#endregion
@@ -1,11 +1,11 @@
1
- import { State } from "./index.mjs";
1
+ import "./index.mjs";
2
2
  //#region src/littleWarden/isDanger.ts
3
3
  /**
4
4
  * Check if the field is Danger.
5
5
  */
6
6
  const isDanger = ({ field }) => {
7
7
  let response = false;
8
- if (void 0 !== field && void 0 !== field["status"]) response = State.DANGER === field["status"];
8
+ if (void 0 !== field && void 0 !== field["status"]) response = "danger" === field["status"];
9
9
  return response;
10
10
  };
11
11
  //#endregion
@@ -1,11 +1,11 @@
1
- const require_littleWarden_index = require("./index.cjs");
1
+ require("./index.cjs");
2
2
  //#region src/littleWarden/isWarning.ts
3
3
  /**
4
4
  * Check if the field is Warning.
5
5
  */
6
6
  const isWarning = ({ field }) => {
7
7
  let response = false;
8
- if (void 0 !== field && void 0 !== field["status"]) response = require_littleWarden_index.State.WARNING === field["status"];
8
+ if (void 0 !== field && void 0 !== field["status"]) response = "warning" === field["status"];
9
9
  return response;
10
10
  };
11
11
  //#endregion
@@ -1,11 +1,11 @@
1
- import { State } from "./index.mjs";
1
+ import "./index.mjs";
2
2
  //#region src/littleWarden/isWarning.ts
3
3
  /**
4
4
  * Check if the field is Warning.
5
5
  */
6
6
  const isWarning = ({ field }) => {
7
7
  let response = false;
8
- if (void 0 !== field && void 0 !== field["status"]) response = State.WARNING === field["status"];
8
+ if (void 0 !== field && void 0 !== field["status"]) response = "warning" === field["status"];
9
9
  return response;
10
10
  };
11
11
  //#endregion
@@ -1,6 +1,7 @@
1
1
  require("../_virtual/_rolldown/runtime.cjs");
2
2
  const require_file_createDirectory = require("../file/createDirectory.cjs");
3
3
  let stream = require("stream");
4
+ let fs = require("fs");
4
5
  //#region src/url/writeUrlContents.ts
5
6
  /**
6
7
  * Downloads a given URL's contents to a local file.
@@ -9,9 +10,8 @@ let stream = require("stream");
9
10
  */
10
11
  const saveUrlContents = async ({ filePath, url }) => {
11
12
  const { default: ky } = await import("ky");
12
- const fs = await import("fs-extra");
13
13
  await require_file_createDirectory({ filePath });
14
- const writer = fs.createWriteStream(filePath);
14
+ const writer = (0, fs.createWriteStream)(filePath);
15
15
  const response = await ky.get(url);
16
16
  const stream$1 = stream.Readable.fromWeb(response.body);
17
17
  await new Promise((resolve, reject) => {
@@ -1,5 +1,6 @@
1
1
  import createDirectory from "../file/createDirectory.mjs";
2
2
  import { Readable } from "stream";
3
+ import { createWriteStream } from "fs";
3
4
  //#region src/url/writeUrlContents.ts
4
5
  /**
5
6
  * Downloads a given URL's contents to a local file.
@@ -8,9 +9,8 @@ import { Readable } from "stream";
8
9
  */
9
10
  const saveUrlContents = async ({ filePath, url }) => {
10
11
  const { default: ky } = await import("ky");
11
- const fs = await import("fs-extra");
12
12
  await createDirectory({ filePath });
13
- const writer = fs.createWriteStream(filePath);
13
+ const writer = createWriteStream(filePath);
14
14
  const response = await ky.get(url);
15
15
  const stream = Readable.fromWeb(response.body);
16
16
  await new Promise((resolve, reject) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "1.42.13",
4
+ "version": "1.42.15",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"