@8ms/helpers 1.1.0 → 1.1.3

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.
@@ -1,5 +1,5 @@
1
1
  import { response, ResponseType } from './response';
2
- import { states, StateType } from './states';
2
+ import { states, StatesType } from './states';
3
3
  import { unexpectedError } from './unexpectedError';
4
- export type { ResponseType, StateType, };
4
+ export type { ResponseType, StatesType, };
5
5
  export { response, states, unexpectedError, };
@@ -1,7 +1,7 @@
1
- import { StateType } from './states';
1
+ import { StatesType } from './states';
2
2
  export declare type ResponseType = {
3
3
  body: any | null;
4
4
  error: string | null;
5
- status: StateType;
5
+ state: StatesType;
6
6
  };
7
7
  export declare const response: ResponseType;
@@ -5,5 +5,5 @@ var states_1 = require("./states");
5
5
  exports.response = {
6
6
  body: null,
7
7
  error: null,
8
- status: states_1.states.IDLE,
8
+ state: states_1.states.IDLE,
9
9
  };
@@ -5,4 +5,4 @@ export declare const states: {
5
5
  SUCCESS: string;
6
6
  VALIDATION_ERROR: string;
7
7
  };
8
- export declare type StateType = typeof states.ERROR | typeof states.IDLE | typeof states.PENDING | typeof states.SUCCESS | typeof states.VALIDATION_ERROR;
8
+ export declare type StatesType = typeof states.ERROR | typeof states.IDLE | typeof states.PENDING | typeof states.SUCCESS | typeof states.VALIDATION_ERROR;
@@ -1,3 +1,3 @@
1
- import { RequestType } from './types';
1
+ import { RequestType } from './request';
2
2
  export type { RequestType, };
3
3
  export {};
File without changes
File without changes
@@ -70,7 +70,7 @@ var getSignedUrl = function (_a) {
70
70
  case 1:
71
71
  awsResponse = _b.sent();
72
72
  if (awsResponse && 'string' === typeof awsResponse) {
73
- response.status = api_1.states.SUCCESS;
73
+ response.state = api_1.states.SUCCESS;
74
74
  response.body = awsResponse;
75
75
  }
76
76
  return [2 /*return*/, response];
@@ -76,7 +76,7 @@ var writePresignedPost = function (_a) {
76
76
  upload = _a.sent();
77
77
  // Uploaded to S3
78
78
  if (upload.ok) {
79
- response.status = api_1.states.SUCCESS;
79
+ response.state = api_1.states.SUCCESS;
80
80
  response.body = {
81
81
  url: "https://".concat(bucket, ".s3.").concat(config.region, ".amazonaws.com/").concat(fileName),
82
82
  };
@@ -84,7 +84,7 @@ var writePresignedPost = function (_a) {
84
84
  }
85
85
  // Failed to upload to S3
86
86
  else {
87
- response.status = api_1.states.ERROR;
87
+ response.state = api_1.states.ERROR;
88
88
  response.error = 'Failed to upload file, please try again.';
89
89
  reject(response);
90
90
  }
@@ -180,17 +180,17 @@ var SimpleEmail = /** @class */ (function (_super) {
180
180
  case 2:
181
181
  apiResponse_1 = _b.sent();
182
182
  if ((0, isResponse200_1.default)({ apiResponse: apiResponse_1 })) {
183
- response.status = api_1.states.SUCCESS;
183
+ response.state = api_1.states.SUCCESS;
184
184
  }
185
185
  else {
186
- response.status = api_1.states.ERROR;
186
+ response.state = api_1.states.ERROR;
187
187
  // @ts-ignore
188
188
  response.error = "An unexpected error occurred.";
189
189
  }
190
190
  return [3 /*break*/, 4];
191
191
  case 3:
192
192
  error_1 = _b.sent();
193
- response.status = api_1.states.ERROR;
193
+ response.state = api_1.states.ERROR;
194
194
  // @ts-ignore
195
195
  response.error = error_1.message;
196
196
  return [3 /*break*/, 4];
package/dist/axios/get.js CHANGED
@@ -54,8 +54,8 @@ var get = function (_a) {
54
54
  switch (_c.label) {
55
55
  case 0:
56
56
  if (!(200 === response.status)) return [3 /*break*/, 12];
57
- if (!(undefined !== response.data.body && undefined !== response.data.error && undefined !== response.data.status)) return [3 /*break*/, 8];
58
- if (!(api_1.states.SUCCESS === response.data.status)) return [3 /*break*/, 4];
57
+ if (!(undefined !== response.data.body && undefined !== response.data.error && undefined !== response.data.state)) return [3 /*break*/, 8];
58
+ if (!(api_1.states.SUCCESS === response.data.state)) return [3 /*break*/, 4];
59
59
  if (!onSuccess) return [3 /*break*/, 2];
60
60
  return [4 /*yield*/, onSuccess(response.data.body)];
61
61
  case 1:
@@ -57,8 +57,8 @@ var post = function (_a) {
57
57
  switch (_c.label) {
58
58
  case 0:
59
59
  if (!(200 === response.status)) return [3 /*break*/, 12];
60
- if (!(undefined !== response.data.body && undefined !== response.data.error && undefined !== response.data.status)) return [3 /*break*/, 8];
61
- if (!(api_1.states.SUCCESS === response.data.status)) return [3 /*break*/, 4];
60
+ if (!(undefined !== response.data.body && undefined !== response.data.error && undefined !== response.data.state)) return [3 /*break*/, 8];
61
+ if (!(api_1.states.SUCCESS === response.data.state)) return [3 /*break*/, 4];
62
62
  if (!onSuccess) return [3 /*break*/, 2];
63
63
  return [4 /*yield*/, onSuccess(response.data.body)];
64
64
  case 1:
@@ -1,3 +1,3 @@
1
- import { states, StateType } from './states';
2
- export type { StateType, };
1
+ import { states, StatesType } from './states';
2
+ export type { StatesType, };
3
3
  export { states, };
@@ -4,4 +4,4 @@ export declare const states: {
4
4
  UPDATE: string;
5
5
  DELETE: string;
6
6
  };
7
- export declare type StateType = typeof states.CREATE | typeof states.READ | typeof states.UPDATE | typeof states.DELETE;
7
+ export declare type StatesType = typeof states.CREATE | typeof states.READ | typeof states.UPDATE | typeof states.DELETE;
@@ -1,4 +1,12 @@
1
- import { GetAccessTokenType } from './accessToken';
1
+ import { ConfigType } from '../aws';
2
+ export declare type GetAccessTokenType = {
3
+ SsmLib: any;
4
+ awsConfig: ConfigType;
5
+ force: boolean;
6
+ ssmName: string;
7
+ ssmWithDecryption: boolean;
8
+ ssmIsJson: boolean;
9
+ };
2
10
  /**
3
11
  * Retrieve the access token from SSM Parameter Store.
4
12
  */
@@ -1,14 +1,13 @@
1
1
  import { ageGroups } from './ageGroups';
2
+ import { CampaignType } from './campaign';
2
3
  import { devices } from './devices';
3
4
  import { endpoints } from './endpoints';
4
5
  import { genders } from './genders';
5
- import getAccessToken from './getAccessToken';
6
+ import getAccessToken, { GetAccessTokenType } from './getAccessToken';
6
7
  import getAgeGroup from './getAgeGroup';
7
8
  import getCampaignIds from './getCampaignIds';
8
9
  import getDevice from './getDevice';
9
10
  import getGender from './getGender';
10
11
  import request from './request';
11
- import { GetAccessTokenType } from './accessToken';
12
- import { CampaignType } from './campaign';
13
12
  export type { CampaignType, GetAccessTokenType, };
14
13
  export { ageGroups, devices, endpoints, genders, getAccessToken, getAgeGroup, getCampaignIds, getDevice, getGender, request, };
@@ -1,3 +1,3 @@
1
- import { states, StatesType } from './states';
2
- export type { StatesType, };
3
- export { states, };
1
+ import { workerStates, WorkerStatesType } from './workerStates';
2
+ export type { WorkerStatesType, };
3
+ export { workerStates, };
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.states = void 0;
4
- var states_1 = require("./states");
5
- Object.defineProperty(exports, "states", { enumerable: true, get: function () { return states_1.states; } });
3
+ exports.workerStates = void 0;
4
+ var workerStates_1 = require("./workerStates");
5
+ Object.defineProperty(exports, "workerStates", { enumerable: true, get: function () { return workerStates_1.workerStates; } });
@@ -0,0 +1,6 @@
1
+ export declare const workerStates: {
2
+ ERROR: string;
3
+ SUCCESS: string;
4
+ PROGRESS: string;
5
+ };
6
+ export declare type WorkerStatesType = typeof workerStates.SUCCESS | typeof workerStates.ERROR | typeof workerStates.PROGRESS;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.states = void 0;
4
- exports.states = {
3
+ exports.workerStates = void 0;
4
+ exports.workerStates = {
5
5
  ERROR: 'error',
6
6
  SUCCESS: 'success',
7
7
  PROGRESS: 'progress',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
- "version": "1.1.0",
3
+ "version": "1.1.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
@@ -24,12 +24,12 @@
24
24
  "@babel/preset-flow": "7.16.7",
25
25
  "@babel/preset-typescript": "7.16.7",
26
26
  "@types/jest": "27.4.1",
27
- "@types/lodash": "4.14.180",
28
- "@types/node": "17.0.21",
27
+ "@types/lodash": "4.14.181",
28
+ "@types/node": "17.0.23",
29
29
  "babel-jest": "27.5.1",
30
30
  "jest": "27.5.1",
31
31
  "ts-node": "10.7.0",
32
32
  "tslib": "2.3.1",
33
- "typescript": "4.6.2"
33
+ "typescript": "4.6.3"
34
34
  }
35
35
  }
@@ -1,9 +0,0 @@
1
- import { ConfigType } from '../aws';
2
- export declare type GetAccessTokenType = {
3
- SsmLib: any;
4
- awsConfig: ConfigType;
5
- force: boolean;
6
- ssmName: string;
7
- ssmWithDecryption: boolean;
8
- ssmIsJson: boolean;
9
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +0,0 @@
1
- export declare const states: {
2
- ERROR: string;
3
- SUCCESS: string;
4
- PROGRESS: string;
5
- };
6
- export declare type StatesType = typeof states.SUCCESS | typeof states.ERROR | typeof states.PROGRESS;