@8ms/helpers 1.1.25 → 1.1.29

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.
@@ -49,9 +49,7 @@ var getCache = function (_a) {
49
49
  case 0:
50
50
  client = (0, s3_1.getClient)({ S3Lib: S3Lib, config: config });
51
51
  return [4 /*yield*/, (0, s3_1.readFile)({ S3Lib: S3Lib, bucket: bucket, client: client, key: key, isJson: isJson })];
52
- case 1:
53
- _b.sent();
54
- return [2 /*return*/];
52
+ case 1: return [2 /*return*/, _b.sent()];
55
53
  }
56
54
  });
57
55
  });
@@ -1,12 +1,10 @@
1
- import { PlatformsType } from '../../environment/platforms';
2
1
  /**
3
2
  * Take an input and return the key.
4
3
  * Always in the "_cache" folder with the "environment" followed by the optional folder then the key.
5
4
  */
6
- declare const getKey: ({ CryptoLib, fileName, folder, platform }: {
5
+ declare const getKey: ({ CryptoLib, fileName, folder }: {
7
6
  CryptoLib: any;
8
7
  fileName: any;
9
8
  folder: string;
10
- platform: PlatformsType;
11
9
  }) => string;
12
10
  export default getKey;
@@ -11,9 +11,9 @@ var environment_1 = require("../../environment");
11
11
  * Always in the "_cache" folder with the "environment" followed by the optional folder then the key.
12
12
  */
13
13
  var getKey = function (_a) {
14
- var CryptoLib = _a.CryptoLib, fileName = _a.fileName, folder = _a.folder, platform = _a.platform;
14
+ var CryptoLib = _a.CryptoLib, fileName = _a.fileName, folder = _a.folder;
15
15
  var fileNameString = (0, getSha256_1.default)({ CryptoLib: CryptoLib, input: fileName });
16
16
  var folderPath = (0, trimStart_1.default)('' === folder ? '' : "".concat(folder, "/"), '/');
17
- return "cache/".concat((0, environment_1.getEnvironment)({ platform: platform }), "/").concat(folderPath).concat(fileNameString, ".json");
17
+ return "cache/".concat((0, environment_1.getEnvironment)(), "/").concat(folderPath).concat(fileNameString, ".json");
18
18
  };
19
19
  exports.default = getKey;
@@ -1,9 +1,6 @@
1
1
  import { EnvironmentsType } from './environments';
2
- import { PlatformsType } from './platforms';
3
2
  /**
4
3
  * Determine the environment we're using.
5
4
  */
6
- declare const getEnvironment: ({ platform }: {
7
- platform: PlatformsType;
8
- }) => EnvironmentsType;
5
+ declare const getEnvironment: () => EnvironmentsType;
9
6
  export default getEnvironment;
@@ -8,17 +8,22 @@ var isVercel_1 = __importDefault(require("./isVercel"));
8
8
  /**
9
9
  * Determine the environment we're using.
10
10
  */
11
- var getEnvironment = function (_a) {
12
- var platform = _a.platform;
11
+ var getEnvironment = function () {
13
12
  var platformEnvironment = process.env.ENVIRONMENT;
14
13
  var response;
15
- if ((0, isVercel_1.default)({ platform: platform })) {
14
+ // If an EMS_ENVIRONMENT (aws) is defined then use this
15
+ if (undefined !== process.env.EMS_ENVIRONMENT) {
16
+ platformEnvironment = process.env.EMS_ENVIRONMENT;
17
+ }
18
+ // For Vercel use the git commit reference (branch)
19
+ if ((0, isVercel_1.default)()) {
16
20
  platformEnvironment = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF;
17
21
  }
18
22
  switch (platformEnvironment) {
19
23
  case 'development':
20
24
  response = environments_1.environments.DEVELOPMENT;
21
25
  break;
26
+ case 'demo':
22
27
  case 'preview':
23
28
  case 'staging':
24
29
  response = environments_1.environments.STAGING;
@@ -1,8 +1,5 @@
1
- import { PlatformsType } from './platforms';
2
1
  /**
3
2
  * Check to see if we are working on AWS Lambda.
4
3
  */
5
- declare const isAws: ({ platform }: {
6
- platform: PlatformsType;
7
- }) => boolean;
4
+ declare const isAws: () => boolean;
8
5
  export default isAws;
@@ -4,8 +4,5 @@ var platforms_1 = require("./platforms");
4
4
  /**
5
5
  * Check to see if we are working on AWS Lambda.
6
6
  */
7
- var isAws = function (_a) {
8
- var platform = _a.platform;
9
- return platforms_1.platforms.AWS === platform;
10
- };
7
+ var isAws = function () { return platforms_1.platforms.AWS === process.env['EMS_PLATFORM']; };
11
8
  exports.default = isAws;
@@ -1,5 +1,2 @@
1
- import { PlatformsType } from './platforms';
2
- declare const isDevelopment: ({ platform }: {
3
- platform: PlatformsType;
4
- }) => boolean;
1
+ declare const isDevelopment: () => boolean;
5
2
  export default isDevelopment;
@@ -5,8 +5,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var environments_1 = require("./environments");
7
7
  var getEnvironment_1 = __importDefault(require("./getEnvironment"));
8
- var isDevelopment = function (_a) {
9
- var platform = _a.platform;
10
- return environments_1.environments.DEVELOPMENT === (0, getEnvironment_1.default)({ platform: platform });
11
- };
8
+ var isDevelopment = function () { return environments_1.environments.DEVELOPMENT === (0, getEnvironment_1.default)(); };
12
9
  exports.default = isDevelopment;
@@ -1,8 +1,5 @@
1
- import { PlatformsType } from './platforms';
2
1
  /**
3
2
  * Check to see if we are developing locally or on the hosted platform.
4
3
  */
5
- declare const isLocalhost: ({ platform }: {
6
- platform: PlatformsType;
7
- }) => boolean;
4
+ declare const isLocalhost: () => boolean;
8
5
  export default isLocalhost;
@@ -8,13 +8,12 @@ var isVercel_1 = __importDefault(require("./isVercel"));
8
8
  /**
9
9
  * Check to see if we are developing locally or on the hosted platform.
10
10
  */
11
- var isLocalhost = function (_a) {
12
- var platform = _a.platform;
11
+ var isLocalhost = function () {
13
12
  var response = false;
14
- if ((0, isAws_1.default)({ platform: platform })) {
13
+ if ((0, isAws_1.default)()) {
15
14
  response = 'true' === process.env['AWS_SAM_LOCAL'];
16
15
  }
17
- else if ((0, isVercel_1.default)({ platform: platform })) {
16
+ else if ((0, isVercel_1.default)()) {
18
17
  // This value needs to only be included in Vercel but undefined in locally
19
18
  response = undefined === process.env['NEXT_PUBLIC_VERCEL_GIT_REPO_ID'];
20
19
  }
@@ -1,5 +1,2 @@
1
- import { PlatformsType } from './platforms';
2
- declare const isProduction: ({ platform }: {
3
- platform: PlatformsType;
4
- }) => boolean;
1
+ declare const isProduction: () => boolean;
5
2
  export default isProduction;
@@ -5,8 +5,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var environments_1 = require("./environments");
7
7
  var getEnvironment_1 = __importDefault(require("./getEnvironment"));
8
- var isProduction = function (_a) {
9
- var platform = _a.platform;
10
- return environments_1.environments.PRODUCTION === (0, getEnvironment_1.default)({ platform: platform });
11
- };
8
+ var isProduction = function () { return environments_1.environments.PRODUCTION === (0, getEnvironment_1.default)(); };
12
9
  exports.default = isProduction;
@@ -1,5 +1,2 @@
1
- import { PlatformsType } from './platforms';
2
- declare const isStaging: ({ platform }: {
3
- platform: PlatformsType;
4
- }) => boolean;
1
+ declare const isStaging: () => boolean;
5
2
  export default isStaging;
@@ -5,8 +5,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var environments_1 = require("./environments");
7
7
  var getEnvironment_1 = __importDefault(require("./getEnvironment"));
8
- var isStaging = function (_a) {
9
- var platform = _a.platform;
10
- return environments_1.environments.STAGING === (0, getEnvironment_1.default)({ platform: platform });
11
- };
8
+ var isStaging = function () { return environments_1.environments.STAGING === (0, getEnvironment_1.default)(); };
12
9
  exports.default = isStaging;
@@ -1,8 +1,5 @@
1
- import { PlatformsType } from './platforms';
2
1
  /**
3
2
  * Check to see if we are working on Vercel.
4
3
  */
5
- declare const isVercel: ({ platform }: {
6
- platform: PlatformsType;
7
- }) => boolean;
4
+ declare const isVercel: () => boolean;
8
5
  export default isVercel;
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var platforms_1 = require("./platforms");
4
3
  /**
5
4
  * Check to see if we are working on Vercel.
6
5
  */
7
- var isVercel = function (_a) {
8
- var platform = _a.platform;
9
- return platforms_1.platforms.VERCEL === platform;
10
- };
6
+ var isVercel = function () { return undefined !== process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF; };
11
7
  exports.default = isVercel;
@@ -1,12 +1,10 @@
1
- import { PlatformsType } from '../environment/platforms';
2
1
  import { UrlType } from './url';
3
2
  declare type BuildUrlType = {
4
3
  path: string;
5
- platform: PlatformsType;
6
4
  url: UrlType;
7
5
  };
8
6
  /**
9
7
  * Get the current base url.
10
8
  */
11
- declare const buildUrl: ({ path, platform, url }: BuildUrlType) => string;
9
+ declare const buildUrl: ({ path, url }: BuildUrlType) => string;
12
10
  export default buildUrl;
@@ -11,15 +11,15 @@ var isStaging_1 = __importDefault(require("../environment/isStaging"));
11
11
  * Get the current base url.
12
12
  */
13
13
  var buildUrl = function (_a) {
14
- var path = _a.path, platform = _a.platform, url = _a.url;
14
+ var path = _a.path, url = _a.url;
15
15
  var response;
16
- if ((0, isDevelopment_1.default)({ platform: platform }) && (0, isLocalhost_1.default)({ platform: platform })) {
16
+ if ((0, isDevelopment_1.default)() && (0, isLocalhost_1.default)()) {
17
17
  response = url.localhost;
18
18
  }
19
- else if ((0, isStaging_1.default)({ platform: platform })) {
19
+ else if ((0, isStaging_1.default)()) {
20
20
  response = url.staging;
21
21
  }
22
- else if ((0, isProduction_1.default)({ platform: platform })) {
22
+ else if ((0, isProduction_1.default)()) {
23
23
  response = url.production;
24
24
  }
25
25
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
- "version": "1.1.25",
3
+ "version": "1.1.29",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
package/dist/index.d.ts DELETED
@@ -1,26 +0,0 @@
1
- import * as api from './api';
2
- import * as array from './array';
3
- import * as atInternet from './atInternet';
4
- import * as aws from './aws';
5
- import * as athenaExpress from './aws/athenaExpress';
6
- import * as glue from './aws/glue';
7
- import * as lambda from './aws/lambda';
8
- import * as s3 from './aws/s3';
9
- import * as s3cache from './aws/s3cache';
10
- import * as ses from './aws/ses';
11
- import * as ssm from './aws/ssm';
12
- import * as boolean from './boolean';
13
- import * as Class from './Class';
14
- import * as crud from './crud';
15
- import * as crypto from './crypto';
16
- import * as date from './date';
17
- import * as environment from './environment';
18
- import * as google from './google';
19
- import * as googleAds from './googleAds';
20
- import * as nextAuth from './nextAuth';
21
- import * as prisma from './prisma';
22
- import * as string from './string';
23
- import * as swr from './swr';
24
- import * as url from './url';
25
- import * as util from './util';
26
- export { api, array, atInternet, aws, athenaExpress, glue, lambda, s3, s3cache, ses, ssm, boolean, Class, crud, crypto, date, environment, google, googleAds, nextAuth, prisma, string, swr, url, util, };
package/dist/index.js DELETED
@@ -1,76 +0,0 @@
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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.util = exports.url = exports.swr = exports.string = exports.prisma = exports.nextAuth = exports.googleAds = exports.google = exports.environment = exports.date = exports.crypto = exports.crud = exports.Class = exports.boolean = exports.ssm = exports.ses = exports.s3cache = exports.s3 = exports.lambda = exports.glue = exports.athenaExpress = exports.aws = exports.atInternet = exports.array = exports.api = void 0;
27
- var api = __importStar(require("./api"));
28
- exports.api = api;
29
- var array = __importStar(require("./array"));
30
- exports.array = array;
31
- var atInternet = __importStar(require("./atInternet"));
32
- exports.atInternet = atInternet;
33
- var aws = __importStar(require("./aws"));
34
- exports.aws = aws;
35
- var athenaExpress = __importStar(require("./aws/athenaExpress"));
36
- exports.athenaExpress = athenaExpress;
37
- var glue = __importStar(require("./aws/glue"));
38
- exports.glue = glue;
39
- var lambda = __importStar(require("./aws/lambda"));
40
- exports.lambda = lambda;
41
- var s3 = __importStar(require("./aws/s3"));
42
- exports.s3 = s3;
43
- var s3cache = __importStar(require("./aws/s3cache"));
44
- exports.s3cache = s3cache;
45
- var ses = __importStar(require("./aws/ses"));
46
- exports.ses = ses;
47
- var ssm = __importStar(require("./aws/ssm"));
48
- exports.ssm = ssm;
49
- var boolean = __importStar(require("./boolean"));
50
- exports.boolean = boolean;
51
- var Class = __importStar(require("./Class"));
52
- exports.Class = Class;
53
- var crud = __importStar(require("./crud"));
54
- exports.crud = crud;
55
- var crypto = __importStar(require("./crypto"));
56
- exports.crypto = crypto;
57
- var date = __importStar(require("./date"));
58
- exports.date = date;
59
- var environment = __importStar(require("./environment"));
60
- exports.environment = environment;
61
- var google = __importStar(require("./google"));
62
- exports.google = google;
63
- var googleAds = __importStar(require("./googleAds"));
64
- exports.googleAds = googleAds;
65
- var nextAuth = __importStar(require("./nextAuth"));
66
- exports.nextAuth = nextAuth;
67
- var prisma = __importStar(require("./prisma"));
68
- exports.prisma = prisma;
69
- var string = __importStar(require("./string"));
70
- exports.string = string;
71
- var swr = __importStar(require("./swr"));
72
- exports.swr = swr;
73
- var url = __importStar(require("./url"));
74
- exports.url = url;
75
- var util = __importStar(require("./util"));
76
- exports.util = util;