@8ms/helpers 1.0.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 (251) hide show
  1. package/dist/Class/BaseClass.d.ts +19 -0
  2. package/dist/Class/BaseClass.js +78 -0
  3. package/dist/Class/index.d.ts +3 -0
  4. package/dist/Class/index.js +8 -0
  5. package/dist/api/constants.d.ts +13 -0
  6. package/dist/api/constants.js +16 -0
  7. package/dist/api/index.d.ts +4 -0
  8. package/dist/api/index.js +7 -0
  9. package/dist/api/types.d.ts +6 -0
  10. package/dist/api/types.js +2 -0
  11. package/dist/array/getArray.d.ts +7 -0
  12. package/dist/array/getArray.js +14 -0
  13. package/dist/array/index.d.ts +3 -0
  14. package/dist/array/index.js +8 -0
  15. package/dist/atInternet/index.d.ts +3 -0
  16. package/dist/atInternet/index.js +2 -0
  17. package/dist/atInternet/types.d.ts +30 -0
  18. package/dist/atInternet/types.js +2 -0
  19. package/dist/aws/athenaExpress/getClient.d.ts +13 -0
  20. package/dist/aws/athenaExpress/getClient.js +23 -0
  21. package/dist/aws/athenaExpress/index.d.ts +4 -0
  22. package/dist/aws/athenaExpress/index.js +10 -0
  23. package/dist/aws/athenaExpress/request.d.ts +8 -0
  24. package/dist/aws/athenaExpress/request.js +54 -0
  25. package/dist/aws/glue/getClient.d.ts +10 -0
  26. package/dist/aws/glue/getClient.js +16 -0
  27. package/dist/aws/glue/index.d.ts +4 -0
  28. package/dist/aws/glue/index.js +10 -0
  29. package/dist/aws/glue/invoke.d.ts +10 -0
  30. package/dist/aws/glue/invoke.js +71 -0
  31. package/dist/aws/index.d.ts +4 -0
  32. package/dist/aws/index.js +8 -0
  33. package/dist/aws/isResponse200.d.ts +7 -0
  34. package/dist/aws/isResponse200.js +16 -0
  35. package/dist/aws/lambda/getClient.d.ts +10 -0
  36. package/dist/aws/lambda/getClient.js +16 -0
  37. package/dist/aws/lambda/index.d.ts +4 -0
  38. package/dist/aws/lambda/index.js +10 -0
  39. package/dist/aws/lambda/invoke.d.ts +20 -0
  40. package/dist/aws/lambda/invoke.js +91 -0
  41. package/dist/aws/s3/deleteDirectory.d.ts +10 -0
  42. package/dist/aws/s3/deleteDirectory.js +83 -0
  43. package/dist/aws/s3/deleteFile.d.ts +10 -0
  44. package/dist/aws/s3/deleteFile.js +61 -0
  45. package/dist/aws/s3/deleteFiles.d.ts +10 -0
  46. package/dist/aws/s3/deleteFiles.js +65 -0
  47. package/dist/aws/s3/getClient.d.ts +10 -0
  48. package/dist/aws/s3/getClient.js +16 -0
  49. package/dist/aws/s3/getPresignedPost.d.ts +21 -0
  50. package/dist/aws/s3/getPresignedPost.js +66 -0
  51. package/dist/aws/s3/getSignedUrl.d.ts +15 -0
  52. package/dist/aws/s3/getSignedUrl.js +70 -0
  53. package/dist/aws/s3/index.d.ts +15 -0
  54. package/dist/aws/s3/index.js +30 -0
  55. package/dist/aws/s3/listFiles.d.ts +10 -0
  56. package/dist/aws/s3/listFiles.js +77 -0
  57. package/dist/aws/s3/listFolders.d.ts +10 -0
  58. package/dist/aws/s3/listFolders.js +76 -0
  59. package/dist/aws/s3/readBuffer.d.ts +11 -0
  60. package/dist/aws/s3/readBuffer.js +100 -0
  61. package/dist/aws/s3/readFile.d.ts +12 -0
  62. package/dist/aws/s3/readFile.js +114 -0
  63. package/dist/aws/s3/types.d.ts +22 -0
  64. package/dist/aws/s3/types.js +2 -0
  65. package/dist/aws/s3/writeFile.d.ts +11 -0
  66. package/dist/aws/s3/writeFile.js +64 -0
  67. package/dist/aws/s3/writeGlueJsonFile.d.ts +13 -0
  68. package/dist/aws/s3/writeGlueJsonFile.js +64 -0
  69. package/dist/aws/s3/writePresignedPost.d.ts +15 -0
  70. package/dist/aws/s3/writePresignedPost.js +87 -0
  71. package/dist/aws/s3cache/getCache.d.ts +17 -0
  72. package/dist/aws/s3cache/getCache.js +62 -0
  73. package/dist/aws/s3cache/getKey.d.ts +12 -0
  74. package/dist/aws/s3cache/getKey.js +19 -0
  75. package/dist/aws/s3cache/index.d.ts +7 -0
  76. package/dist/aws/s3cache/index.js +14 -0
  77. package/dist/aws/s3cache/saveCache.d.ts +12 -0
  78. package/dist/aws/s3cache/saveCache.js +59 -0
  79. package/dist/aws/s3cache/types.d.ts +6 -0
  80. package/dist/aws/s3cache/types.js +2 -0
  81. package/dist/aws/s3cache/updateCache.d.ts +12 -0
  82. package/dist/aws/s3cache/updateCache.js +66 -0
  83. package/dist/aws/ses/SimpleEmail.d.ts +53 -0
  84. package/dist/aws/ses/SimpleEmail.js +209 -0
  85. package/dist/aws/ses/getClient.d.ts +10 -0
  86. package/dist/aws/ses/getClient.js +16 -0
  87. package/dist/aws/ses/index.d.ts +4 -0
  88. package/dist/aws/ses/index.js +10 -0
  89. package/dist/aws/ssm/getClient.d.ts +10 -0
  90. package/dist/aws/ssm/getClient.js +16 -0
  91. package/dist/aws/ssm/getParameter.d.ts +12 -0
  92. package/dist/aws/ssm/getParameter.js +85 -0
  93. package/dist/aws/ssm/index.d.ts +4 -0
  94. package/dist/aws/ssm/index.js +10 -0
  95. package/dist/aws/types.d.ts +5 -0
  96. package/dist/aws/types.js +2 -0
  97. package/dist/boolean/getBoolean.d.ts +5 -0
  98. package/dist/boolean/getBoolean.js +16 -0
  99. package/dist/boolean/index.d.ts +3 -0
  100. package/dist/boolean/index.js +8 -0
  101. package/dist/crud/constants.d.ts +6 -0
  102. package/dist/crud/constants.js +9 -0
  103. package/dist/crud/index.d.ts +4 -0
  104. package/dist/crud/index.js +5 -0
  105. package/dist/crud/types.d.ts +2 -0
  106. package/dist/crud/types.js +2 -0
  107. package/dist/crypto/getDecrypt.d.ts +11 -0
  108. package/dist/crypto/getDecrypt.js +13 -0
  109. package/dist/crypto/getEncrypt.d.ts +11 -0
  110. package/dist/crypto/getEncrypt.js +13 -0
  111. package/dist/crypto/getRandom.d.ts +7 -0
  112. package/dist/crypto/getRandom.js +12 -0
  113. package/dist/crypto/getSha256.d.ts +8 -0
  114. package/dist/crypto/getSha256.js +12 -0
  115. package/dist/crypto/index.d.ts +6 -0
  116. package/dist/crypto/index.js +14 -0
  117. package/dist/date/constants.d.ts +21 -0
  118. package/dist/date/constants.js +24 -0
  119. package/dist/date/format.d.ts +9 -0
  120. package/dist/date/format.js +15 -0
  121. package/dist/date/getDate.d.ts +8 -0
  122. package/dist/date/getDate.js +40 -0
  123. package/dist/date/getDurationHours.d.ts +8 -0
  124. package/dist/date/getDurationHours.js +28 -0
  125. package/dist/date/getDurationMinutes.d.ts +8 -0
  126. package/dist/date/getDurationMinutes.js +27 -0
  127. package/dist/date/getFinancialYear.d.ts +8 -0
  128. package/dist/date/getFinancialYear.js +48 -0
  129. package/dist/date/getFinancialYearToDate.d.ts +6 -0
  130. package/dist/date/getFinancialYearToDate.js +15 -0
  131. package/dist/date/getFinancialYearWeeks.d.ts +8 -0
  132. package/dist/date/getFinancialYearWeeks.js +26 -0
  133. package/dist/date/getLastWeek.d.ts +6 -0
  134. package/dist/date/getLastWeek.js +16 -0
  135. package/dist/date/getMax.d.ts +8 -0
  136. package/dist/date/getMax.js +19 -0
  137. package/dist/date/getMonday.d.ts +11 -0
  138. package/dist/date/getMonday.js +29 -0
  139. package/dist/date/getNumber.d.ts +8 -0
  140. package/dist/date/getNumber.js +16 -0
  141. package/dist/date/getPredefinedTimeframe.d.ts +8 -0
  142. package/dist/date/getPredefinedTimeframe.js +25 -0
  143. package/dist/date/getSunday.d.ts +11 -0
  144. package/dist/date/getSunday.js +29 -0
  145. package/dist/date/getThisWeek.d.ts +6 -0
  146. package/dist/date/getThisWeek.js +16 -0
  147. package/dist/date/getToday.d.ts +6 -0
  148. package/dist/date/getToday.js +12 -0
  149. package/dist/date/getTwoWeeksAgo.d.ts +6 -0
  150. package/dist/date/getTwoWeeksAgo.js +16 -0
  151. package/dist/date/getWeeksAgo.d.ts +6 -0
  152. package/dist/date/getWeeksAgo.js +17 -0
  153. package/dist/date/getYesterday.d.ts +5 -0
  154. package/dist/date/getYesterday.js +12 -0
  155. package/dist/date/index.d.ts +24 -0
  156. package/dist/date/index.js +51 -0
  157. package/dist/date/isDateValid.d.ts +7 -0
  158. package/dist/date/isDateValid.js +24 -0
  159. package/dist/date/isLastWeek.d.ts +6 -0
  160. package/dist/date/isLastWeek.js +15 -0
  161. package/dist/date/isThisWeek.d.ts +6 -0
  162. package/dist/date/isThisWeek.js +15 -0
  163. package/dist/date/parseExcelDate.d.ts +8 -0
  164. package/dist/date/parseExcelDate.js +20 -0
  165. package/dist/date/types.d.ts +28 -0
  166. package/dist/date/types.js +2 -0
  167. package/dist/environment/constants.d.ts +9 -0
  168. package/dist/environment/constants.js +12 -0
  169. package/dist/environment/getEnvironment.d.ts +8 -0
  170. package/dist/environment/getEnvironment.js +31 -0
  171. package/dist/environment/index.d.ts +11 -0
  172. package/dist/environment/index.js +23 -0
  173. package/dist/environment/isAws.d.ts +8 -0
  174. package/dist/environment/isAws.js +11 -0
  175. package/dist/environment/isDevelopment.d.ts +5 -0
  176. package/dist/environment/isDevelopment.js +12 -0
  177. package/dist/environment/isLocalhost.d.ts +8 -0
  178. package/dist/environment/isLocalhost.js +23 -0
  179. package/dist/environment/isProduction.d.ts +5 -0
  180. package/dist/environment/isProduction.js +12 -0
  181. package/dist/environment/isStaging.d.ts +5 -0
  182. package/dist/environment/isStaging.js +12 -0
  183. package/dist/environment/isVercel.d.ts +8 -0
  184. package/dist/environment/isVercel.js +11 -0
  185. package/dist/environment/types.d.ts +3 -0
  186. package/dist/environment/types.js +2 -0
  187. package/dist/google/getCredentials.d.ts +11 -0
  188. package/dist/google/getCredentials.js +77 -0
  189. package/dist/google/index.d.ts +4 -0
  190. package/dist/google/index.js +8 -0
  191. package/dist/google/types.d.ts +12 -0
  192. package/dist/google/types.js +2 -0
  193. package/dist/googleAds/getClient.d.ts +14 -0
  194. package/dist/googleAds/getClient.js +80 -0
  195. package/dist/googleAds/getCustomer.d.ts +8 -0
  196. package/dist/googleAds/getCustomer.js +56 -0
  197. package/dist/googleAds/index.d.ts +5 -0
  198. package/dist/googleAds/index.js +10 -0
  199. package/dist/googleAds/types.d.ts +5 -0
  200. package/dist/googleAds/types.js +2 -0
  201. package/dist/index.d.ts +26 -0
  202. package/dist/index.js +72 -0
  203. package/dist/nextAuth/constants.d.ts +5 -0
  204. package/dist/nextAuth/constants.js +8 -0
  205. package/dist/nextAuth/index.d.ts +3 -0
  206. package/dist/nextAuth/index.js +5 -0
  207. package/dist/prisma/getClient.d.ts +6 -0
  208. package/dist/prisma/getClient.js +41 -0
  209. package/dist/prisma/index.d.ts +3 -0
  210. package/dist/prisma/index.js +8 -0
  211. package/dist/string/getCleanFolder.d.ts +5 -0
  212. package/dist/string/getCleanFolder.js +12 -0
  213. package/dist/string/getStringFromStream.d.ts +6 -0
  214. package/dist/string/getStringFromStream.js +16 -0
  215. package/dist/string/index.d.ts +4 -0
  216. package/dist/string/index.js +10 -0
  217. package/dist/swr/index.d.ts +8 -0
  218. package/dist/swr/index.js +18 -0
  219. package/dist/swr/isAllData.d.ts +5 -0
  220. package/dist/swr/isAllData.js +19 -0
  221. package/dist/swr/isAnyError.d.ts +5 -0
  222. package/dist/swr/isAnyError.js +19 -0
  223. package/dist/swr/isAnyLoading.d.ts +5 -0
  224. package/dist/swr/isAnyLoading.js +21 -0
  225. package/dist/swr/isData.d.ts +5 -0
  226. package/dist/swr/isData.js +7 -0
  227. package/dist/swr/isError.d.ts +5 -0
  228. package/dist/swr/isError.js +7 -0
  229. package/dist/swr/isLoading.d.ts +5 -0
  230. package/dist/swr/isLoading.js +12 -0
  231. package/dist/url/buildParameters.d.ts +8 -0
  232. package/dist/url/buildParameters.js +23 -0
  233. package/dist/url/buildRelative.d.ts +8 -0
  234. package/dist/url/buildRelative.js +14 -0
  235. package/dist/url/buildUrl.d.ts +12 -0
  236. package/dist/url/buildUrl.js +30 -0
  237. package/dist/url/index.d.ts +8 -0
  238. package/dist/url/index.js +16 -0
  239. package/dist/url/isAbsolute.d.ts +7 -0
  240. package/dist/url/isAbsolute.js +16 -0
  241. package/dist/url/isRelative.d.ts +7 -0
  242. package/dist/url/isRelative.js +11 -0
  243. package/dist/url/types.d.ts +6 -0
  244. package/dist/url/types.js +2 -0
  245. package/dist/util/defaultTo.d.ts +5 -0
  246. package/dist/util/defaultTo.js +34 -0
  247. package/dist/util/index.d.ts +4 -0
  248. package/dist/util/index.js +10 -0
  249. package/dist/util/sleep.d.ts +4 -0
  250. package/dist/util/sleep.js +7 -0
  251. package/package.json +27 -0
@@ -0,0 +1,10 @@
1
+ import { AwsConfigType } from '../types';
2
+ /**
3
+ * Shorthand function to get the SES Client.
4
+ * Library: @aws-sdk/client-ses
5
+ */
6
+ declare const getClient: ({ SesLib, config }: {
7
+ SesLib: any;
8
+ config: AwsConfigType;
9
+ }) => any;
10
+ export default getClient;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var sesClient = undefined;
4
+ /**
5
+ * Shorthand function to get the SES Client.
6
+ * Library: @aws-sdk/client-ses
7
+ */
8
+ var getClient = function (_a) {
9
+ var SesLib = _a.SesLib, config = _a.config;
10
+ if (undefined === sesClient) {
11
+ var SESClient = SesLib.SESClient;
12
+ sesClient = new SESClient(config);
13
+ }
14
+ return sesClient;
15
+ };
16
+ exports.default = getClient;
@@ -0,0 +1,4 @@
1
+ import getClient from './getClient';
2
+ import SimpleEmail from './SimpleEmail';
3
+ export type {};
4
+ export { getClient, SimpleEmail, };
@@ -0,0 +1,10 @@
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
+ exports.SimpleEmail = exports.getClient = void 0;
7
+ var getClient_1 = __importDefault(require("./getClient"));
8
+ exports.getClient = getClient_1.default;
9
+ var SimpleEmail_1 = __importDefault(require("./SimpleEmail"));
10
+ exports.SimpleEmail = SimpleEmail_1.default;
@@ -0,0 +1,10 @@
1
+ import { AwsConfigType } from '../types';
2
+ /**
3
+ * Shorthand function to get the Lambda Client.
4
+ * Library: @aws-sdk/client-ssm
5
+ */
6
+ declare const getClient: ({ SsmLib, config }: {
7
+ SsmLib: any;
8
+ config: AwsConfigType;
9
+ }) => any;
10
+ export default getClient;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var ssmClient = undefined;
4
+ /**
5
+ * Shorthand function to get the Lambda Client.
6
+ * Library: @aws-sdk/client-ssm
7
+ */
8
+ var getClient = function (_a) {
9
+ var SsmLib = _a.SsmLib, config = _a.config;
10
+ if (undefined === ssmClient) {
11
+ var SSMClient = SsmLib.SSMClient;
12
+ ssmClient = new SSMClient(config);
13
+ }
14
+ return ssmClient;
15
+ };
16
+ exports.default = getClient;
@@ -0,0 +1,12 @@
1
+ declare type GetParameterType = {
2
+ SsmLib: any;
3
+ client: any;
4
+ name: string;
5
+ withDecryption: boolean;
6
+ isJson: boolean;
7
+ };
8
+ /**
9
+ * Get a parameter and decryption if necessary (secure string)
10
+ */
11
+ declare const getParameter: ({ SsmLib, client, name, withDecryption, isJson }: GetParameterType) => Promise<any>;
12
+ export default getParameter;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ var ssmParameters = {};
40
+ /**
41
+ * Get a parameter and decryption if necessary (secure string)
42
+ */
43
+ var getParameter = function (_a) {
44
+ var SsmLib = _a.SsmLib, client = _a.client, name = _a.name, withDecryption = _a.withDecryption, isJson = _a.isJson;
45
+ return __awaiter(void 0, void 0, void 0, function () {
46
+ var response, GetParameterCommand, apiResponse, error_1;
47
+ return __generator(this, function (_b) {
48
+ switch (_b.label) {
49
+ case 0:
50
+ response = undefined;
51
+ if (!(undefined === ssmParameters[name])) return [3 /*break*/, 5];
52
+ _b.label = 1;
53
+ case 1:
54
+ _b.trys.push([1, 3, , 4]);
55
+ GetParameterCommand = SsmLib.GetParameterCommand;
56
+ return [4 /*yield*/, client.send(new GetParameterCommand({
57
+ Name: name,
58
+ WithDecryption: withDecryption || true,
59
+ }))];
60
+ case 2:
61
+ apiResponse = _b.sent();
62
+ if (apiResponse.Parameter.Value) {
63
+ response = apiResponse.Parameter.Value;
64
+ ssmParameters[name] = response;
65
+ if (isJson && undefined !== response) {
66
+ response = JSON.parse(response) || undefined;
67
+ ssmParameters[name] = response;
68
+ }
69
+ }
70
+ return [3 /*break*/, 4];
71
+ case 3:
72
+ error_1 = _b.sent();
73
+ // @ts-ignore
74
+ console.log("SSM Error: ".concat(error_1.message));
75
+ return [3 /*break*/, 4];
76
+ case 4: return [3 /*break*/, 6];
77
+ case 5:
78
+ response = ssmParameters[name];
79
+ _b.label = 6;
80
+ case 6: return [2 /*return*/, response];
81
+ }
82
+ });
83
+ });
84
+ };
85
+ exports.default = getParameter;
@@ -0,0 +1,4 @@
1
+ import getClient from './getClient';
2
+ import getParameter from './getParameter';
3
+ export type {};
4
+ export { getClient, getParameter, };
@@ -0,0 +1,10 @@
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
+ exports.getParameter = exports.getClient = void 0;
7
+ var getClient_1 = __importDefault(require("./getClient"));
8
+ exports.getClient = getClient_1.default;
9
+ var getParameter_1 = __importDefault(require("./getParameter"));
10
+ exports.getParameter = getParameter_1.default;
@@ -0,0 +1,5 @@
1
+ export declare type AwsConfigType = {
2
+ accessKeyId: string;
3
+ region: string;
4
+ secretAccessKey: string;
5
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Convert an input from a variety of forms into boolean.
3
+ */
4
+ declare const getBoolean: (input: any) => boolean;
5
+ export default getBoolean;
@@ -0,0 +1,16 @@
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
+ var isBoolean_1 = __importDefault(require("lodash/isBoolean"));
7
+ /**
8
+ * Convert an input from a variety of forms into boolean.
9
+ */
10
+ var getBoolean = function (input) {
11
+ if ((0, isBoolean_1.default)(input)) {
12
+ return input;
13
+ }
14
+ return 'true' === input || 1 === input || '1' === input || 'yes' === input || 'y' === input;
15
+ };
16
+ exports.default = getBoolean;
@@ -0,0 +1,3 @@
1
+ import getBoolean from './getBoolean';
2
+ export type {};
3
+ export { getBoolean, };
@@ -0,0 +1,8 @@
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
+ exports.getBoolean = void 0;
7
+ var getBoolean_1 = __importDefault(require("./getBoolean"));
8
+ exports.getBoolean = getBoolean_1.default;
@@ -0,0 +1,6 @@
1
+ export declare const CrudStatus: {
2
+ CREATE: string;
3
+ READ: string;
4
+ UPDATE: string;
5
+ DELETE: string;
6
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CrudStatus = void 0;
4
+ exports.CrudStatus = {
5
+ CREATE: 'create',
6
+ READ: 'read',
7
+ UPDATE: 'update',
8
+ DELETE: 'delete',
9
+ };
@@ -0,0 +1,4 @@
1
+ import { CrudStatus } from './constants';
2
+ import { CrudType } from './types';
3
+ export type { CrudType, };
4
+ export { CrudStatus, };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CrudStatus = void 0;
4
+ var constants_1 = require("./constants");
5
+ Object.defineProperty(exports, "CrudStatus", { enumerable: true, get: function () { return constants_1.CrudStatus; } });
@@ -0,0 +1,2 @@
1
+ import { CrudStatus } from './constants';
2
+ export declare type CrudType = typeof CrudStatus.CREATE | typeof CrudStatus.READ | typeof CrudStatus.UPDATE | typeof CrudStatus.DELETE;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Decrypt an encoding string using a salt
3
+ * Library: crypto-js
4
+ */
5
+ declare const getDecrypt: ({ CryptoLib, appSalt, salt, value }: {
6
+ CryptoLib: any;
7
+ value: string;
8
+ salt: string;
9
+ appSalt: string;
10
+ }) => string;
11
+ export default getDecrypt;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Decrypt an encoding string using a salt
5
+ * Library: crypto-js
6
+ */
7
+ var getDecrypt = function (_a) {
8
+ var CryptoLib = _a.CryptoLib, appSalt = _a.appSalt, salt = _a.salt, value = _a.value;
9
+ var customSalt = "".concat(appSalt, "-").concat(salt);
10
+ return CryptoLib.AES.decrypt(value, customSalt)
11
+ .toString(CryptoLib.enc.Utf8);
12
+ };
13
+ exports.default = getDecrypt;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Encrypt an encoding string using a salt
3
+ * Library: crypto-js
4
+ */
5
+ declare const getEncrypt: ({ CryptoLib, appSalt, salt, value }: {
6
+ CryptoLib: any;
7
+ value: string;
8
+ salt: string;
9
+ appSalt: string;
10
+ }) => string;
11
+ export default getEncrypt;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Encrypt an encoding string using a salt
5
+ * Library: crypto-js
6
+ */
7
+ var getEncrypt = function (_a) {
8
+ var CryptoLib = _a.CryptoLib, appSalt = _a.appSalt, salt = _a.salt, value = _a.value;
9
+ var customSalt = "".concat(appSalt, "-").concat(salt);
10
+ return CryptoLib.AES.encrypt(value, customSalt)
11
+ .toString();
12
+ };
13
+ exports.default = getEncrypt;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Create a random string and return a number of characters from it
3
+ */
4
+ declare const getRandom: ({ length }: {
5
+ length: number;
6
+ }) => string;
7
+ export default getRandom;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Create a random string and return a number of characters from it
5
+ */
6
+ var getRandom = function (_a) {
7
+ var length = _a.length;
8
+ return Math.random()
9
+ .toString(36)
10
+ .substr(0, length);
11
+ };
12
+ exports.default = getRandom;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Encrypt a string using sha256
3
+ */
4
+ declare const getSha256: ({ CryptoLib, input }: {
5
+ CryptoLib: any;
6
+ input: string;
7
+ }) => string;
8
+ export default getSha256;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Encrypt a string using sha256
5
+ */
6
+ var getSha256 = function (_a) {
7
+ var CryptoLib = _a.CryptoLib, input = _a.input;
8
+ var sha256 = CryptoLib.sha256;
9
+ return sha256(input)
10
+ .toString();
11
+ };
12
+ exports.default = getSha256;
@@ -0,0 +1,6 @@
1
+ import getDecrypt from './getDecrypt';
2
+ import getEncrypt from './getEncrypt';
3
+ import getRandom from './getRandom';
4
+ import getSha256 from './getSha256';
5
+ export type {};
6
+ export { getDecrypt, getEncrypt, getRandom, getSha256, };
@@ -0,0 +1,14 @@
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
+ exports.getSha256 = exports.getRandom = exports.getEncrypt = exports.getDecrypt = void 0;
7
+ var getDecrypt_1 = __importDefault(require("./getDecrypt"));
8
+ exports.getDecrypt = getDecrypt_1.default;
9
+ var getEncrypt_1 = __importDefault(require("./getEncrypt"));
10
+ exports.getEncrypt = getEncrypt_1.default;
11
+ var getRandom_1 = __importDefault(require("./getRandom"));
12
+ exports.getRandom = getRandom_1.default;
13
+ var getSha256_1 = __importDefault(require("./getSha256"));
14
+ exports.getSha256 = getSha256_1.default;
@@ -0,0 +1,21 @@
1
+ export declare const Duration: {
2
+ FOREVER: string;
3
+ MONTHS: string;
4
+ DAYS: string;
5
+ HOURS: string;
6
+ MINUTES: string;
7
+ };
8
+ export declare const DurationComparison: {
9
+ VS_NOW: string;
10
+ VS_MIDNIGHT: string;
11
+ };
12
+ export declare const Timeframe: {
13
+ CURRENT: string;
14
+ COMPARISON: string;
15
+ };
16
+ export declare const TimeframePredefined: {
17
+ NONE: string;
18
+ CUSTOM: string;
19
+ THIS_WEEK: string;
20
+ LAST_WEEK: string;
21
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TimeframePredefined = exports.Timeframe = exports.DurationComparison = exports.Duration = void 0;
4
+ exports.Duration = {
5
+ FOREVER: 'forever',
6
+ MONTHS: 'months',
7
+ DAYS: 'days',
8
+ HOURS: 'hours',
9
+ MINUTES: 'minutes',
10
+ };
11
+ exports.DurationComparison = {
12
+ VS_NOW: 'vsNow',
13
+ VS_MIDNIGHT: 'vsMidnight',
14
+ };
15
+ exports.Timeframe = {
16
+ CURRENT: 'current',
17
+ COMPARISON: 'comparison',
18
+ };
19
+ exports.TimeframePredefined = {
20
+ NONE: 'none',
21
+ CUSTOM: 'custom',
22
+ THIS_WEEK: 'thisWeek',
23
+ LAST_WEEK: 'lastWeek',
24
+ };
@@ -0,0 +1,9 @@
1
+ import { DateType } from './types';
2
+ /**
3
+ * Convert a (number | string | Date) into a "yyyy-MM-dd" string or a specified format.
4
+ */
5
+ declare const format: ({ input, dateFormat }: {
6
+ input: DateType;
7
+ dateFormat?: string;
8
+ }) => string;
9
+ export default format;
@@ -0,0 +1,15 @@
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
+ var format_1 = __importDefault(require("date-fns/format"));
7
+ var getDate_1 = __importDefault(require("./getDate"));
8
+ /**
9
+ * Convert a (number | string | Date) into a "yyyy-MM-dd" string or a specified format.
10
+ */
11
+ var format = function (_a) {
12
+ var input = _a.input, dateFormat = _a.dateFormat;
13
+ return (0, format_1.default)((0, getDate_1.default)({ input: input }), dateFormat || 'yyyy-MM-dd');
14
+ };
15
+ exports.default = format;
@@ -0,0 +1,8 @@
1
+ import { DateType } from './types';
2
+ /**
3
+ * Convert a (number | string | Date) into a Date object.
4
+ */
5
+ declare const getDate: ({ input }: {
6
+ input: DateType;
7
+ }) => any;
8
+ export default getDate;
@@ -0,0 +1,40 @@
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
+ var addHours_1 = __importDefault(require("date-fns/addHours"));
7
+ var parse_1 = __importDefault(require("date-fns/parse"));
8
+ var subHours_1 = __importDefault(require("date-fns/subHours"));
9
+ /**
10
+ * Convert a (number | string | Date) into a Date object.
11
+ */
12
+ var getDate = function (_a) {
13
+ var input = _a.input;
14
+ var date;
15
+ if (input instanceof Date) {
16
+ date = new Date(input.valueOf());
17
+ }
18
+ else if ('string' === typeof input) {
19
+ var dateString = input.toString() + ' 00:00:00';
20
+ date = (0, parse_1.default)(dateString, 'yyyy-MM-dd HH:mm:ss', new Date());
21
+ }
22
+ else if ('number' === typeof input) {
23
+ var dateString = input.toString() + ' 00:00:00';
24
+ date = (0, parse_1.default)(dateString, 'yyyyMMdd HH:mm:ss', new Date());
25
+ }
26
+ // Behind an hour (going back to DST)
27
+ if (date.getTimezoneOffset() < 0) {
28
+ date = (0, addHours_1.default)(date, 1);
29
+ }
30
+ // Forward an hour (going into BST)
31
+ else if (date.getTimezoneOffset() > 0) {
32
+ date = (0, subHours_1.default)(date, 1);
33
+ }
34
+ // Otherwise set to UTC hours
35
+ else {
36
+ date.setHours(0, 0, 0, 0);
37
+ }
38
+ return date;
39
+ };
40
+ exports.default = getDate;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Convert a number 1000 seconds into HH:MM:SS
3
+ * https://stackoverflow.com/a/1322771
4
+ */
5
+ declare const getDurationHours: ({ seconds }: {
6
+ seconds: number;
7
+ }) => string;
8
+ export default getDurationHours;
@@ -0,0 +1,28 @@
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
+ var intervalToDuration_1 = __importDefault(require("date-fns/intervalToDuration"));
7
+ /**
8
+ * Convert a number 1000 seconds into HH:MM:SS
9
+ * https://stackoverflow.com/a/1322771
10
+ */
11
+ var getDurationHours = function (_a) {
12
+ var seconds = _a.seconds;
13
+ var response = '00:00:00';
14
+ if (seconds > 0) {
15
+ var duration = (0, intervalToDuration_1.default)({
16
+ start: 0,
17
+ end: seconds * 1000,
18
+ });
19
+ var output = {
20
+ hours: duration.hours < 10 ? '0' + duration.hours : duration.hours,
21
+ minutes: duration.minutes < 10 ? '0' + duration.minutes : duration.minutes,
22
+ seconds: duration.seconds < 10 ? '0' + duration.seconds : duration.seconds,
23
+ };
24
+ response = "".concat(output.hours, ":").concat(output.minutes, ":").concat(output.seconds);
25
+ }
26
+ return response;
27
+ };
28
+ exports.default = getDurationHours;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Convert a number 1000 seconds into MM:SS
3
+ * https://stackoverflow.com/a/1322771
4
+ */
5
+ declare const getDurationMinutes: ({ seconds }: {
6
+ seconds: number;
7
+ }) => string;
8
+ export default getDurationMinutes;
@@ -0,0 +1,27 @@
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
+ var intervalToDuration_1 = __importDefault(require("date-fns/intervalToDuration"));
7
+ /**
8
+ * Convert a number 1000 seconds into MM:SS
9
+ * https://stackoverflow.com/a/1322771
10
+ */
11
+ var getDurationMinutes = function (_a) {
12
+ var seconds = _a.seconds;
13
+ var response = '00:00';
14
+ if (seconds > 0) {
15
+ var duration = (0, intervalToDuration_1.default)({
16
+ start: 0,
17
+ end: seconds * 1000,
18
+ });
19
+ var output = {
20
+ minutes: duration.minutes < 10 ? '0' + duration.minutes : duration.minutes,
21
+ seconds: duration.seconds < 10 ? '0' + duration.seconds : duration.seconds,
22
+ };
23
+ response = "".concat(output.minutes, ":").concat(output.seconds);
24
+ }
25
+ return response;
26
+ };
27
+ exports.default = getDurationMinutes;
@@ -0,0 +1,8 @@
1
+ import { FinancialYearType } from './types';
2
+ /**
3
+ * Get the current financial year.
4
+ */
5
+ declare const getFinancialYear: ({ year }: {
6
+ year: number;
7
+ }) => FinancialYearType;
8
+ export default getFinancialYear;