@8ms/helpers 1.33.2 → 1.35.1

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 (112) hide show
  1. package/.github/workflows/deploy_npmjs.yml +4 -4
  2. package/api/ApiResponse.d.ts +2 -2
  3. package/api/ApiResponse.js +11 -11
  4. package/api/index.d.ts +8 -0
  5. package/api/index.js +12 -0
  6. package/api/isError.d.ts +2 -2
  7. package/api/isError.js +3 -6
  8. package/api/isSuccess.d.ts +1 -1
  9. package/api/isSuccess.js +3 -6
  10. package/api/response.d.ts +1 -1
  11. package/api/response.js +2 -5
  12. package/aws/s3/listFilesIteratively.d.ts +9 -0
  13. package/aws/s3/listFilesIteratively.js +44 -0
  14. package/aws/s3/readBuffer.d.ts +1 -1
  15. package/aws/s3/readBuffer.js +6 -19
  16. package/aws/s3/readFile.d.ts +3 -2
  17. package/aws/s3/readFile.js +13 -10
  18. package/aws/s3cache/getCache.d.ts +2 -2
  19. package/aws/s3cache/getCache.js +2 -2
  20. package/aws/s3cache/index.d.ts +6 -0
  21. package/aws/s3cache/updateCache.d.ts +1 -1
  22. package/brightData/webScraperIde/getRealtime.js +5 -5
  23. package/crud/index.d.ts +6 -0
  24. package/crud/index.js +10 -0
  25. package/date/getDate.d.ts +1 -1
  26. package/date/getDatesBetween.d.ts +1 -1
  27. package/date/getFinancialYear.d.ts +1 -1
  28. package/date/getFinancialYear.js +3 -6
  29. package/date/getFinancialYearToDate.d.ts +1 -1
  30. package/date/getFinancialYearToYesterday.d.ts +1 -1
  31. package/date/getFinancialYearWeeks.d.ts +1 -1
  32. package/date/getFinancialYearWeeks.js +1 -2
  33. package/date/getLastWeek.d.ts +1 -1
  34. package/date/getMax.d.ts +1 -1
  35. package/date/getMin.d.ts +1 -1
  36. package/date/getMonday.d.ts +3 -3
  37. package/date/getMonday.js +3 -5
  38. package/date/getPredefinedTimeframe.d.ts +2 -3
  39. package/date/getPredefinedTimeframe.js +4 -4
  40. package/date/getSunday.d.ts +1 -1
  41. package/date/getThisWeek.d.ts +1 -1
  42. package/date/getTwoWeeksAgo.d.ts +1 -1
  43. package/date/getWeeksAgo.d.ts +1 -1
  44. package/date/index.d.ts +55 -0
  45. package/date/index.js +36 -0
  46. package/date/isLastWeek.d.ts +1 -1
  47. package/date/isThisWeek.d.ts +2 -2
  48. package/date/isThisWeek.js +1 -1
  49. package/environment/getEnvironment.d.ts +1 -1
  50. package/environment/getEnvironment.js +8 -8
  51. package/environment/index.d.ts +9 -0
  52. package/environment/index.js +14 -0
  53. package/environment/isAws.js +2 -5
  54. package/environment/isDevelopment.js +2 -2
  55. package/environment/isProduction.js +2 -2
  56. package/environment/isStaging.js +2 -2
  57. package/googleAds/keywordPlanner/index.d.ts +238 -0
  58. package/googleAds/keywordPlanner/index.js +245 -0
  59. package/{google → googleAds}/keywordPlanner/request.d.ts +1 -3
  60. package/{google → googleAds}/keywordPlanner/request.js +2 -5
  61. package/{google → googleAds}/keywordPlanner/response.d.ts +1 -1
  62. package/littleWarden/index.d.ts +5 -0
  63. package/littleWarden/index.js +9 -0
  64. package/littleWarden/isAllGood.js +3 -6
  65. package/littleWarden/isDanger.js +2 -5
  66. package/littleWarden/isWarning.js +2 -5
  67. package/package.json +27 -26
  68. package/util/promiseChunks.d.ts +10 -0
  69. package/util/promiseChunks.js +18 -0
  70. package/webWorker/index.d.ts +5 -0
  71. package/webWorker/index.js +9 -0
  72. package/api/states.d.ts +0 -9
  73. package/api/states.js +0 -10
  74. package/api/unexpectedError.d.ts +0 -2
  75. package/api/unexpectedError.js +0 -4
  76. package/aws/s3cache/cache.d.ts +0 -7
  77. package/crud/actions.d.ts +0 -8
  78. package/crud/actions.js +0 -10
  79. package/date/date.d.ts +0 -4
  80. package/date/date.js +0 -2
  81. package/date/duration.d.ts +0 -5
  82. package/date/duration.js +0 -2
  83. package/date/durationComparisons.d.ts +0 -5
  84. package/date/durationComparisons.js +0 -7
  85. package/date/durations.d.ts +0 -8
  86. package/date/durations.js +0 -10
  87. package/date/financialYear.d.ts +0 -4
  88. package/date/financialYear.js +0 -2
  89. package/date/financialYearWeek.d.ts +0 -6
  90. package/date/financialYearWeek.js +0 -2
  91. package/date/predefinedTimeframes.d.ts +0 -7
  92. package/date/predefinedTimeframes.js +0 -9
  93. package/date/timeframe.d.ts +0 -8
  94. package/date/timeframe.js +0 -2
  95. package/date/timeframes.d.ts +0 -4
  96. package/date/timeframes.js +0 -7
  97. package/environment/environments.d.ts +0 -7
  98. package/environment/environments.js +0 -8
  99. package/environment/platforms.d.ts +0 -6
  100. package/environment/platforms.js +0 -7
  101. package/google/keywordPlanner/countries.d.ts +0 -222
  102. package/google/keywordPlanner/countries.js +0 -223
  103. package/google/keywordPlanner/months.d.ts +0 -16
  104. package/google/keywordPlanner/months.js +0 -17
  105. package/google/keywordPlanner/networks.d.ts +0 -6
  106. package/google/keywordPlanner/networks.js +0 -7
  107. package/littleWarden/states.d.ts +0 -7
  108. package/littleWarden/states.js +0 -8
  109. package/webWorker/states.d.ts +0 -7
  110. package/webWorker/states.js +0 -8
  111. /package/aws/s3cache/{cache.js → index.js} +0 -0
  112. /package/{google → googleAds}/keywordPlanner/response.js +0 -0
@@ -6,12 +6,12 @@ jobs:
6
6
  publish:
7
7
  runs-on: ubuntu-latest
8
8
  steps:
9
- - uses: actions/checkout@v3
10
- - uses: actions/setup-node@v3
9
+ - uses: actions/checkout@v4.2.1
10
+ - uses: actions/setup-node@v4.0.4
11
11
  with:
12
- node-version: 18
12
+ node-version: 20
13
13
  - run: yarn
14
14
  - run: yarn build
15
- - uses: JS-DevTools/npm-publish@v1
15
+ - uses: JS-DevTools/npm-publish@v3.1.1
16
16
  with:
17
17
  token: ${{ secrets.NPM_TOKEN }}
@@ -1,5 +1,5 @@
1
- import { Response } from './response';
2
- import { State } from './states';
1
+ import { Response } from "./response";
2
+ import { State } from "./";
3
3
  type Constructor = {
4
4
  body?: any;
5
5
  error?: any;
@@ -4,18 +4,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const defaultTo_1 = __importDefault(require("../util/defaultTo"));
7
- const states_1 = __importDefault(require("./states"));
7
+ const _1 = require("./");
8
8
  /**
9
9
  * Class version of the API to enable quicker instances.
10
10
  */
11
11
  class ApiResponse {
12
12
  constructor({ body, error, state } = {}) {
13
- this.state = states_1.default.IDLE;
13
+ this.state = _1.State.IDLE;
14
14
  this.body = null;
15
15
  this.error = null;
16
16
  this.body = body || null;
17
17
  this.error = error || null;
18
- this.state = state || states_1.default.IDLE;
18
+ this.state = state || _1.State.IDLE;
19
19
  return this;
20
20
  }
21
21
  fromJson({ input }) {
@@ -48,34 +48,34 @@ class ApiResponse {
48
48
  return this.state;
49
49
  }
50
50
  isError() {
51
- return this.state === states_1.default.ERROR;
51
+ return this.state === _1.State.ERROR;
52
52
  }
53
53
  isIdle() {
54
- return this.state === states_1.default.IDLE;
54
+ return this.state === _1.State.IDLE;
55
55
  }
56
56
  isPending() {
57
- return this.state === states_1.default.PENDING;
57
+ return this.state === _1.State.PENDING;
58
58
  }
59
59
  isSuccess() {
60
- return this.state === states_1.default.SUCCESS;
60
+ return this.state === _1.State.SUCCESS;
61
61
  }
62
62
  setToIdle() {
63
- this.state = states_1.default.IDLE;
63
+ this.state = _1.State.IDLE;
64
64
  return this;
65
65
  }
66
66
  setToPending() {
67
- this.state = states_1.default.PENDING;
67
+ this.state = _1.State.PENDING;
68
68
  return this;
69
69
  }
70
70
  setToError({ body, error }) {
71
71
  this.body = body || null;
72
72
  this.error = error;
73
- this.state = states_1.default.ERROR;
73
+ this.state = _1.State.ERROR;
74
74
  return this;
75
75
  }
76
76
  setToSuccess({ body }) {
77
77
  this.body = body;
78
- this.state = states_1.default.SUCCESS;
78
+ this.state = _1.State.SUCCESS;
79
79
  return this;
80
80
  }
81
81
  setBody({ body }) {
package/api/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export declare enum State {
2
+ ERROR = "ERROR",
3
+ IDLE = "IDLE",
4
+ PENDING = "PENDING",
5
+ SUCCESS = "SUCCESS",
6
+ VALIDATION_ERROR = "VALIDATION_ERROR"
7
+ }
8
+ export declare const unexpectedError: string;
package/api/index.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unexpectedError = exports.State = void 0;
4
+ var State;
5
+ (function (State) {
6
+ State["ERROR"] = "ERROR";
7
+ State["IDLE"] = "IDLE";
8
+ State["PENDING"] = "PENDING";
9
+ State["SUCCESS"] = "SUCCESS";
10
+ State["VALIDATION_ERROR"] = "VALIDATION_ERROR";
11
+ })(State || (exports.State = State = {}));
12
+ exports.unexpectedError = "An unexpected error occurred, please try again.";
package/api/isError.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Response } from './response';
1
+ import { Response } from "./response";
2
2
  type IsError = {
3
3
  response: Response;
4
4
  };
5
- declare const isError: ({ response }: IsError) => boolean;
5
+ declare const isError: (props: IsError) => boolean;
6
6
  export default isError;
package/api/isError.js CHANGED
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const states_1 = __importDefault(require("./states"));
7
- const isError = ({ response }) => {
8
- return states_1.default.ERROR === response.state;
3
+ const _1 = require("./");
4
+ const isError = (props) => {
5
+ return _1.State.ERROR === props.response.state;
9
6
  };
10
7
  exports.default = isError;
@@ -2,5 +2,5 @@ import { Response } from './response';
2
2
  type IsSuccess = {
3
3
  response: Response;
4
4
  };
5
- declare const isSuccess: ({ response }: IsSuccess) => boolean;
5
+ declare const isSuccess: (props: IsSuccess) => boolean;
6
6
  export default isSuccess;
package/api/isSuccess.js CHANGED
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const states_1 = __importDefault(require("./states"));
7
- const isSuccess = ({ response }) => {
8
- return states_1.default.SUCCESS === response.state;
3
+ const _1 = require("./");
4
+ const isSuccess = (props) => {
5
+ return _1.State.SUCCESS === props.response.state;
9
6
  };
10
7
  exports.default = isSuccess;
package/api/response.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { State } from './states';
1
+ import { State } from "./";
2
2
  export type Response = {
3
3
  body: any | null;
4
4
  error: string | null;
package/api/response.js CHANGED
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const states_1 = __importDefault(require("./states"));
3
+ const _1 = require("./");
7
4
  const response = {
8
5
  body: null,
9
6
  error: null,
10
- state: states_1.default.IDLE,
7
+ state: _1.State.IDLE,
11
8
  };
12
9
  exports.default = response;
@@ -0,0 +1,9 @@
1
+ type ListFilesIteratively = {
2
+ bucket: string;
3
+ folder: string;
4
+ };
5
+ /**
6
+ * Fetch all the files within a given directory recursively
7
+ */
8
+ declare const listFilesIteratively: (props: ListFilesIteratively) => Promise<string[]>;
9
+ export default listFilesIteratively;
@@ -0,0 +1,44 @@
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
+ const listFolders_1 = __importDefault(require("./listFolders"));
7
+ const listFiles_1 = __importDefault(require("./listFiles"));
8
+ /**
9
+ * Sub function
10
+ */
11
+ const iterateFolders = async (props) => {
12
+ let response = [];
13
+ const folders = await (0, listFolders_1.default)({
14
+ bucket: props.bucket,
15
+ folder: props.folder,
16
+ });
17
+ for (let i = 0; i < folders.length; i++) {
18
+ const subFolderFiles = await iterateFolders({
19
+ bucket: props.bucket,
20
+ folder: `${props.folder}/${folders[i]}`,
21
+ });
22
+ const files = await (0, listFiles_1.default)({
23
+ bucket: props.bucket,
24
+ folder: `${props.folder}/${folders[i]}`,
25
+ });
26
+ response = [
27
+ ...response,
28
+ ...files,
29
+ ...subFolderFiles,
30
+ ];
31
+ }
32
+ return response;
33
+ };
34
+ /**
35
+ * Fetch all the files within a given directory recursively
36
+ */
37
+ const listFilesIteratively = async (props) => {
38
+ const response = await iterateFolders({
39
+ bucket: props.bucket,
40
+ folder: props.folder,
41
+ });
42
+ return response;
43
+ };
44
+ exports.default = listFilesIteratively;
@@ -1,4 +1,4 @@
1
- import { Modified } from './readFile';
1
+ import { Modified } from "./readFile";
2
2
  export type ReadBufferResponse = Modified & {
3
3
  buffer: any;
4
4
  };
@@ -3,30 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const date_fns_1 = require("date-fns");
7
6
  const isResponse200_1 = __importDefault(require("../isResponse200"));
7
+ const readFile_1 = require("./readFile");
8
8
  /**
9
9
  * Similar function to reading the S3 file, but instead of a text file return a buffer.
10
10
  */
11
11
  const readBuffer = async ({ bucket, key }) => {
12
12
  let response = {
13
+ ...readFile_1.readFileDefault,
13
14
  buffer: undefined,
14
- now: (0, date_fns_1.getUnixTime)(new Date()),
15
- modified: {
16
- unix: null,
17
- vsNow: {
18
- months: 0,
19
- days: 0,
20
- hours: 0,
21
- minutes: 0,
22
- },
23
- vsMidnight: {
24
- hours: 0,
25
- minutes: 0,
26
- },
27
- },
28
15
  };
29
- const { GetObjectCommand } = require('@aws-sdk/client-s3');
16
+ const { GetObjectCommand } = require("@aws-sdk/client-s3");
30
17
  const apiResponse = await global.awsS3Client.send(new GetObjectCommand({
31
18
  Bucket: bucket,
32
19
  Key: key,
@@ -37,11 +24,11 @@ const readBuffer = async ({ bucket, key }) => {
37
24
  // Store the response
38
25
  response.buffer = await new Promise((resolve, reject) => {
39
26
  // @ts-ignore
40
- apiResponse.Body.on('data', (chunk) => chunks.push(chunk));
27
+ apiResponse.Body.on("data", (chunk) => chunks.push(chunk));
41
28
  // @ts-ignore
42
- apiResponse.Body.on('error', (err) => reject(err));
29
+ apiResponse.Body.on("error", (err) => reject(err));
43
30
  // @ts-ignore
44
- apiResponse.Body.on('end', () => resolve(Buffer.concat(chunks)));
31
+ apiResponse.Body.on("end", () => resolve(Buffer.concat(chunks)));
45
32
  });
46
33
  }
47
34
  else {
@@ -1,14 +1,15 @@
1
+ import { DurationComparison } from "../../date";
1
2
  export type Modified = {
2
3
  now: number;
3
4
  modified: {
4
5
  unix: null | number;
5
- vsNow: {
6
+ [DurationComparison.VS_NOW]: {
6
7
  months: number;
7
8
  days: number;
8
9
  hours: number;
9
10
  minutes: number;
10
11
  };
11
- vsMidnight: {
12
+ [DurationComparison.VS_MIDNIGHT]: {
12
13
  hours: number;
13
14
  minutes: number;
14
15
  };
@@ -17,18 +17,19 @@ const getStringFromStream_1 = __importDefault(require("../../string/getStringFro
17
17
  const isResponse200_1 = __importDefault(require("../isResponse200"));
18
18
  const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
19
19
  const isFileExists_1 = __importDefault(require("./isFileExists"));
20
+ const date_1 = require("../../date");
20
21
  exports.readFileDefault = {
21
22
  body: undefined,
22
23
  now: undefined,
23
24
  modified: {
24
25
  unix: null,
25
- vsNow: {
26
+ [date_1.DurationComparison.VS_NOW]: {
26
27
  months: 0,
27
28
  days: 0,
28
29
  hours: 0,
29
30
  minutes: 0,
30
31
  },
31
- vsMidnight: {
32
+ [date_1.DurationComparison.VS_MIDNIGHT]: {
32
33
  hours: 0,
33
34
  minutes: 0,
34
35
  },
@@ -49,7 +50,7 @@ const readFile = async ({ bucket, key, isJson }) => {
49
50
  });
50
51
  // Only fetch the file if it exists
51
52
  if (doesFileExist) {
52
- const { GetObjectCommand } = require('@aws-sdk/client-s3');
53
+ const { GetObjectCommand } = require("@aws-sdk/client-s3");
53
54
  const apiResponse = await global.awsS3Client.send(new GetObjectCommand({
54
55
  Bucket: bucket,
55
56
  Key: key,
@@ -60,15 +61,17 @@ const readFile = async ({ bucket, key, isJson }) => {
60
61
  // Convert the date to unix
61
62
  response.modified.unix = (0, date_fns_7.getUnixTime)(modified);
62
63
  // Compare now to unix
63
- response.modified.vsNow.months = (0, date_fns_4.differenceInMonths)(now, modified);
64
- response.modified.vsNow.days = (0, date_fns_1.differenceInDays)(now, modified);
65
- response.modified.vsNow.hours = (0, date_fns_2.differenceInHours)(now, modified);
66
- response.modified.vsNow.minutes = (0, date_fns_3.differenceInMinutes)(now, modified);
64
+ response.modified[date_1.DurationComparison.VS_NOW].months = (0, date_fns_4.differenceInMonths)(now, modified);
65
+ response.modified[date_1.DurationComparison.VS_NOW].days = (0, date_fns_1.differenceInDays)(now, modified);
66
+ response.modified[date_1.DurationComparison.VS_NOW].hours = (0, date_fns_2.differenceInHours)(now, modified);
67
+ response.modified[date_1.DurationComparison.VS_NOW].minutes = (0, date_fns_3.differenceInMinutes)(now, modified);
67
68
  // Compare now to midnight
68
- response.modified.vsMidnight.hours = (0, date_fns_5.getHours)(now);
69
- response.modified.vsMidnight.minutes = (0, date_fns_6.getMinutes)(now);
69
+ response.modified[date_1.DurationComparison.VS_MIDNIGHT].hours = (0, date_fns_5.getHours)(now);
70
+ response.modified[date_1.DurationComparison.VS_MIDNIGHT].minutes = (0, date_fns_6.getMinutes)(now);
70
71
  // Convert stream into a string
71
- response.body = await (0, getStringFromStream_1.default)({ stream: apiResponse.Body });
72
+ response.body = await (0, getStringFromStream_1.default)({
73
+ stream: apiResponse.Body
74
+ });
72
75
  // If we need to return JSON, parse it. On error return undefined
73
76
  if (false !== isJson) {
74
77
  response.body = JSON.parse(response.body) || undefined;
@@ -1,5 +1,5 @@
1
- import { Cache } from './cache';
2
- import { GetKey } from './getKey';
1
+ import { Cache } from "./";
2
+ import { GetKey } from "./getKey";
3
3
  type GetCache = GetKey & {
4
4
  bucket: string;
5
5
  cache: Cache;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const durations_1 = __importDefault(require("../../date/durations"));
6
+ const date_1 = require("../../date");
7
7
  const getKey_1 = __importDefault(require("./getKey"));
8
8
  const readGzip_1 = __importDefault(require("../s3/readGzip"));
9
9
  /**
@@ -23,7 +23,7 @@ const getCache = async ({ bucket, cache, fileName, folder }) => {
23
23
  isJson: true,
24
24
  });
25
25
  // Cache exists and is still within our caching timeframe
26
- if (undefined !== cached.body && (durations_1.default.FOREVER === cache.timeframe || cached.modified[cache.from][cache.timeframe] < cache.duration)) {
26
+ if (undefined !== cached.body && (date_1.Interval.FOREVER === cache.timeframe || cached.modified[cache.from][cache.timeframe] < cache.duration)) {
27
27
  response = cached.body;
28
28
  }
29
29
  }
@@ -0,0 +1,6 @@
1
+ import { DurationComparison, Interval } from "../../date";
2
+ export type Cache = {
3
+ duration: number;
4
+ from: DurationComparison;
5
+ timeframe: Interval;
6
+ };
@@ -1,6 +1,6 @@
1
1
  import { GetKey } from './getKey';
2
2
  type UpdateCache = GetKey & {
3
- bucket: any;
3
+ bucket: string;
4
4
  data: any;
5
5
  };
6
6
  /**
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const post_1 = __importDefault(require("../../axios/post"));
7
- const states_1 = __importDefault(require("../../api/states"));
7
+ const api_1 = require("../../api");
8
8
  const get_1 = __importDefault(require("../../axios/get"));
9
9
  const sleep_1 = __importDefault(require("../../util/sleep"));
10
10
  /**
@@ -30,8 +30,8 @@ const getRealtime = async (props) => {
30
30
  keys: ["response_id"],
31
31
  });
32
32
  if ("" !== responseId) {
33
- let state = states_1.default.PENDING;
34
- while (states_1.default.PENDING === state) {
33
+ let state = api_1.State.PENDING;
34
+ while (api_1.State.PENDING === state) {
35
35
  const resultUrl = `https://api.brightdata.com/dca/get_result?response_id=${responseId}`;
36
36
  // Use fetch with the agent option to make an HTTP request through the proxy
37
37
  // Replace <target_url> with the URL you want to request
@@ -46,10 +46,10 @@ const getRealtime = async (props) => {
46
46
  if (resultResponse.isSuccess()) {
47
47
  if (undefined !== resultResponse.body.pending &&
48
48
  true === resultResponse.body.pending) {
49
- state = states_1.default.PENDING;
49
+ state = api_1.State.PENDING;
50
50
  }
51
51
  else {
52
- state = states_1.default.SUCCESS;
52
+ state = api_1.State.SUCCESS;
53
53
  response = resultResponse.getBody();
54
54
  }
55
55
  }
@@ -0,0 +1,6 @@
1
+ export declare enum Action {
2
+ CREATE = "CREATE",
3
+ READ = "READ",
4
+ UPDATE = "UPDATE",
5
+ DELETE = "DELETE"
6
+ }
package/crud/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Action = void 0;
4
+ var Action;
5
+ (function (Action) {
6
+ Action["CREATE"] = "CREATE";
7
+ Action["READ"] = "READ";
8
+ Action["UPDATE"] = "UPDATE";
9
+ Action["DELETE"] = "DELETE";
10
+ })(Action || (exports.Action = Action = {}));
package/date/getDate.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { DateType } from "./date";
1
+ import { DateType } from "./";
2
2
  import { GetMidnight } from "./getMidnight";
3
3
  import { GetTimeZoned } from "./getTimeZoned";
4
4
  export type GetDate = GetTimeZoned & GetMidnight & {
@@ -1,4 +1,4 @@
1
- import { DateType } from "./date";
1
+ import { DateType } from "./";
2
2
  type GetDatesBetween = {
3
3
  end: DateType;
4
4
  start: DateType;
@@ -1,4 +1,4 @@
1
- import { FinancialYear } from './financialYear';
1
+ import { FinancialYear } from "./";
2
2
  type GetFinancialYearType = {
3
3
  year?: number;
4
4
  };
@@ -4,9 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const date_fns_1 = require("date-fns");
7
- const date_fns_2 = require("date-fns");
8
- const date_fns_3 = require("date-fns");
9
- const date_fns_4 = require("date-fns");
10
7
  const getDate_1 = __importDefault(require("./getDate"));
11
8
  const getToday_1 = __importDefault(require("./getToday"));
12
9
  /**
@@ -41,11 +38,11 @@ const getFinancialYear = (props = {}) => {
41
38
  });
42
39
  // Get the previous Monday if the 1st of April isn't a Monday
43
40
  if (!(0, date_fns_1.isMonday)(yearStart)) {
44
- yearStart = (0, date_fns_4.previousMonday)(yearStart);
41
+ yearStart = (0, date_fns_1.previousMonday)(yearStart);
45
42
  }
46
43
  // Get the next Sunday if the 31st of March isn't a Sunday
47
- if (!(0, date_fns_2.isSunday)(yearEnd)) {
48
- yearEnd = (0, date_fns_3.nextSunday)(yearEnd);
44
+ if (!(0, date_fns_1.isSunday)(yearEnd)) {
45
+ yearEnd = (0, date_fns_1.nextSunday)(yearEnd);
49
46
  }
50
47
  return {
51
48
  end: yearEnd,
@@ -1,4 +1,4 @@
1
- import { FinancialYear } from './financialYear';
1
+ import { FinancialYear } from './';
2
2
  /**
3
3
  * Return the current financial year up to today.
4
4
  * Timezone should always be London based
@@ -1,4 +1,4 @@
1
- import { FinancialYear } from './financialYear';
1
+ import { FinancialYear } from './';
2
2
  /**
3
3
  * Return the current financial year up to yesterday.
4
4
  * Timezone should always be London based
@@ -1,4 +1,4 @@
1
- import { FinancialYearWeekType } from "./financialYearWeek";
1
+ import { FinancialYearWeekType } from "./";
2
2
  type GetFinancialYearWeeks = {
3
3
  year?: number;
4
4
  };
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const date_fns_1 = require("date-fns");
7
- const date_fns_2 = require("date-fns");
8
7
  const getFinancialYear_1 = __importDefault(require("./getFinancialYear"));
9
8
  const getTimeZoned_1 = __importDefault(require("./getTimeZoned"));
10
9
  /**
@@ -14,7 +13,7 @@ const getFinancialYearWeeks = (props = {}) => {
14
13
  const financialYear = (0, getFinancialYear_1.default)({
15
14
  year: props.year
16
15
  });
17
- const weeks = (0, date_fns_2.eachWeekOfInterval)(financialYear, {
16
+ const weeks = (0, date_fns_1.eachWeekOfInterval)(financialYear, {
18
17
  weekStartsOn: 1
19
18
  });
20
19
  let response = weeks.map((week, index) => {
@@ -1,6 +1,6 @@
1
1
  import { GetMidnight } from "./getMidnight";
2
2
  import { GetTimeZoned } from "./getTimeZoned";
3
- import { Timeframe } from "./timeframe";
3
+ import { Timeframe } from "./";
4
4
  type GetLastWeek = GetTimeZoned & GetMidnight;
5
5
  /**
6
6
  * Return an object of start/end predefined date of Last Week.
package/date/getMax.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { DateType } from "./date";
1
+ import { DateType } from "./";
2
2
  import { GetMidnight } from "./getMidnight";
3
3
  import { GetTimeZoned } from "./getTimeZoned";
4
4
  type GetMax = GetTimeZoned & GetMidnight & {
package/date/getMin.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { DateType } from './date';
1
+ import { DateType } from './';
2
2
  import { GetMidnight } from './getMidnight';
3
3
  import { GetTimeZoned } from './getTimeZoned';
4
4
  type GetMin = GetTimeZoned & GetMidnight & {
@@ -1,6 +1,6 @@
1
- import { DateType } from './date';
2
- import { GetMidnight } from './getMidnight';
3
- import { GetTimeZoned } from './getTimeZoned';
1
+ import { DateType } from "./";
2
+ import { GetMidnight } from "./getMidnight";
3
+ import { GetTimeZoned } from "./getTimeZoned";
4
4
  type GetMonday = GetTimeZoned & GetMidnight & {
5
5
  input?: DateType;
6
6
  isUtc?: boolean;
package/date/getMonday.js CHANGED
@@ -4,8 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const date_fns_1 = require("date-fns");
7
- const date_fns_2 = require("date-fns");
8
- const date_fns_3 = require("date-fns");
9
7
  const getDate_1 = __importDefault(require("./getDate"));
10
8
  const getMidnight_1 = __importDefault(require("./getMidnight"));
11
9
  const getToday_1 = __importDefault(require("./getToday"));
@@ -30,14 +28,14 @@ const getMonday = (props) => {
30
28
  });
31
29
  // console.log('dateInstance', dateInstance);
32
30
  }
33
- if (!(0, date_fns_2.isMonday)(dateInstance)) {
31
+ if (!(0, date_fns_1.isMonday)(dateInstance)) {
34
32
  // Get the ISO Day of week (Monday - 1 to Sunday - 7)
35
33
  const isoDay = (0, date_fns_1.getISODay)(dateInstance);
36
34
  // Move back to Monday
37
- dateInstance = (0, date_fns_3.subDays)(dateInstance, isoDay - 1);
35
+ dateInstance = (0, date_fns_1.subDays)(dateInstance, isoDay - 1);
38
36
  }
39
37
  // Move it back a given number of weeks
40
- dateInstance = (0, date_fns_3.subDays)(dateInstance, 7 * props.weeksAgo);
38
+ dateInstance = (0, date_fns_1.subDays)(dateInstance, 7 * props.weeksAgo);
41
39
  // console.log('dateInstance', dateInstance);
42
40
  dateInstance = (0, getMidnight_1.default)({
43
41
  input: dateInstance,
@@ -1,9 +1,8 @@
1
- import { PredefinedTimeframes } from './predefinedTimeframes';
2
- import { Timeframe } from './timeframe';
1
+ import { PredefinedTimeframe, Timeframe } from "./";
3
2
  /**
4
3
  * Check to see the date matches a predefined time frame
5
4
  */
6
5
  declare const getPredefinedTimeframe: ({ timeframe }: {
7
6
  timeframe: Timeframe;
8
- }) => PredefinedTimeframes;
7
+ }) => PredefinedTimeframe;
9
8
  export default getPredefinedTimeframe;