@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,28 @@
1
+ import { TimeframePredefined } from './constants';
2
+ /**
3
+ * A date can be either a number (YYYYMMDD), string (YYYY-MM-DD) or Date instance.
4
+ */
5
+ export declare type DateType = number | string | Date;
6
+ export declare type FinancialYearType = {
7
+ end: Date;
8
+ start: Date;
9
+ };
10
+ export declare type FinancialYearWeekType = {
11
+ end: Date;
12
+ financialWeek: number;
13
+ financialYear: number;
14
+ start: Date;
15
+ };
16
+ /**
17
+ * A timeframe has a start and an end date.
18
+ */
19
+ export declare type TimeframeType = {
20
+ end: DateType;
21
+ start: DateType;
22
+ };
23
+ export declare type DurationType = {
24
+ hours: number;
25
+ minutes: number;
26
+ seconds: number;
27
+ };
28
+ export declare type TimeframePredefinedType = typeof TimeframePredefined.NONE | typeof TimeframePredefined.CUSTOM | typeof TimeframePredefined.LAST_WEEK | typeof TimeframePredefined.THIS_WEEK;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ export declare const Environment: {
2
+ DEVELOPMENT: string;
3
+ STAGING: string;
4
+ PRODUCTION: string;
5
+ };
6
+ export declare const Platform: {
7
+ AWS: string;
8
+ VERCEL: string;
9
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Platform = exports.Environment = void 0;
4
+ exports.Environment = {
5
+ DEVELOPMENT: 'development',
6
+ STAGING: 'staging',
7
+ PRODUCTION: 'production',
8
+ };
9
+ exports.Platform = {
10
+ AWS: 'aws',
11
+ VERCEL: 'vercel',
12
+ };
@@ -0,0 +1,8 @@
1
+ import { EnvironmentType, PlatformType } from './types';
2
+ /**
3
+ * Determine the environment we're using.
4
+ */
5
+ declare const getEnvironment: ({ platform }: {
6
+ platform: PlatformType;
7
+ }) => EnvironmentType;
8
+ export default getEnvironment;
@@ -0,0 +1,31 @@
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 constants_1 = require("./constants");
7
+ var isVercel_1 = __importDefault(require("./isVercel"));
8
+ /**
9
+ * Determine the environment we're using.
10
+ */
11
+ var getEnvironment = function (_a) {
12
+ var platform = _a.platform;
13
+ var platformEnvironment = process.env.ENVIRONMENT;
14
+ var response;
15
+ if ((0, isVercel_1.default)({ platform: platform })) {
16
+ platformEnvironment = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF;
17
+ }
18
+ switch (platformEnvironment) {
19
+ case 'development':
20
+ response = constants_1.Environment.DEVELOPMENT;
21
+ break;
22
+ case 'preview':
23
+ case 'staging':
24
+ response = constants_1.Environment.STAGING;
25
+ break;
26
+ default:
27
+ response = constants_1.Environment.PRODUCTION;
28
+ }
29
+ return response;
30
+ };
31
+ exports.default = getEnvironment;
@@ -0,0 +1,11 @@
1
+ import { Environment, Platform } from './constants';
2
+ import getEnvironment from './getEnvironment';
3
+ import isAws from './isAws';
4
+ import isDevelopment from './isDevelopment';
5
+ import isLocalhost from './isLocalhost';
6
+ import isProduction from './isProduction';
7
+ import isStaging from './isStaging';
8
+ import isVercel from './isVercel';
9
+ import { EnvironmentType } from './types';
10
+ export type { EnvironmentType, };
11
+ export { Environment, Platform, getEnvironment, isAws, isDevelopment, isLocalhost, isProduction, isStaging, isVercel, };
@@ -0,0 +1,23 @@
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.isVercel = exports.isStaging = exports.isProduction = exports.isLocalhost = exports.isDevelopment = exports.isAws = exports.getEnvironment = exports.Platform = exports.Environment = void 0;
7
+ var constants_1 = require("./constants");
8
+ Object.defineProperty(exports, "Environment", { enumerable: true, get: function () { return constants_1.Environment; } });
9
+ Object.defineProperty(exports, "Platform", { enumerable: true, get: function () { return constants_1.Platform; } });
10
+ var getEnvironment_1 = __importDefault(require("./getEnvironment"));
11
+ exports.getEnvironment = getEnvironment_1.default;
12
+ var isAws_1 = __importDefault(require("./isAws"));
13
+ exports.isAws = isAws_1.default;
14
+ var isDevelopment_1 = __importDefault(require("./isDevelopment"));
15
+ exports.isDevelopment = isDevelopment_1.default;
16
+ var isLocalhost_1 = __importDefault(require("./isLocalhost"));
17
+ exports.isLocalhost = isLocalhost_1.default;
18
+ var isProduction_1 = __importDefault(require("./isProduction"));
19
+ exports.isProduction = isProduction_1.default;
20
+ var isStaging_1 = __importDefault(require("./isStaging"));
21
+ exports.isStaging = isStaging_1.default;
22
+ var isVercel_1 = __importDefault(require("./isVercel"));
23
+ exports.isVercel = isVercel_1.default;
@@ -0,0 +1,8 @@
1
+ import { PlatformType } from './types';
2
+ /**
3
+ * Check to see if we are working on AWS Lambda.
4
+ */
5
+ declare const isAws: ({ platform }: {
6
+ platform: PlatformType;
7
+ }) => boolean;
8
+ export default isAws;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var constants_1 = require("./constants");
4
+ /**
5
+ * Check to see if we are working on AWS Lambda.
6
+ */
7
+ var isAws = function (_a) {
8
+ var platform = _a.platform;
9
+ return constants_1.Platform.AWS === platform;
10
+ };
11
+ exports.default = isAws;
@@ -0,0 +1,5 @@
1
+ import { PlatformType } from './types';
2
+ declare const isDevelopment: ({ platform }: {
3
+ platform: PlatformType;
4
+ }) => boolean;
5
+ export default isDevelopment;
@@ -0,0 +1,12 @@
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 constants_1 = require("./constants");
7
+ var getEnvironment_1 = __importDefault(require("./getEnvironment"));
8
+ var isDevelopment = function (_a) {
9
+ var platform = _a.platform;
10
+ return constants_1.Environment.DEVELOPMENT === (0, getEnvironment_1.default)({ platform: platform });
11
+ };
12
+ exports.default = isDevelopment;
@@ -0,0 +1,8 @@
1
+ import { PlatformType } from './types';
2
+ /**
3
+ * Check to see if we are developing locally or on the hosted platform.
4
+ */
5
+ declare const isLocalhost: ({ platform }: {
6
+ platform: PlatformType;
7
+ }) => boolean;
8
+ export default isLocalhost;
@@ -0,0 +1,23 @@
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 isAws_1 = __importDefault(require("./isAws"));
7
+ var isVercel_1 = __importDefault(require("./isVercel"));
8
+ /**
9
+ * Check to see if we are developing locally or on the hosted platform.
10
+ */
11
+ var isLocalhost = function (_a) {
12
+ var platform = _a.platform;
13
+ var response = false;
14
+ if ((0, isAws_1.default)({ platform: platform })) {
15
+ response = 'true' === process.env['AWS_SAM_LOCAL'];
16
+ }
17
+ else if ((0, isVercel_1.default)({ platform: platform })) {
18
+ // This value needs to only be included in Vercel but undefined in locally
19
+ response = undefined === process.env['NEXT_PUBLIC_VERCEL_GIT_REPO_ID'];
20
+ }
21
+ return response;
22
+ };
23
+ exports.default = isLocalhost;
@@ -0,0 +1,5 @@
1
+ import { PlatformType } from './types';
2
+ declare const isProduction: ({ platform }: {
3
+ platform: PlatformType;
4
+ }) => boolean;
5
+ export default isProduction;
@@ -0,0 +1,12 @@
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 constants_1 = require("./constants");
7
+ var getEnvironment_1 = __importDefault(require("./getEnvironment"));
8
+ var isProduction = function (_a) {
9
+ var platform = _a.platform;
10
+ return constants_1.Environment.PRODUCTION === (0, getEnvironment_1.default)({ platform: platform });
11
+ };
12
+ exports.default = isProduction;
@@ -0,0 +1,5 @@
1
+ import { PlatformType } from './types';
2
+ declare const isStaging: ({ platform }: {
3
+ platform: PlatformType;
4
+ }) => boolean;
5
+ export default isStaging;
@@ -0,0 +1,12 @@
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 constants_1 = require("./constants");
7
+ var getEnvironment_1 = __importDefault(require("./getEnvironment"));
8
+ var isStaging = function (_a) {
9
+ var platform = _a.platform;
10
+ return constants_1.Environment.STAGING === (0, getEnvironment_1.default)({ platform: platform });
11
+ };
12
+ exports.default = isStaging;
@@ -0,0 +1,8 @@
1
+ import { PlatformType } from './types';
2
+ /**
3
+ * Check to see if we are working on Vercel.
4
+ */
5
+ declare const isVercel: ({ platform }: {
6
+ platform: PlatformType;
7
+ }) => boolean;
8
+ export default isVercel;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var constants_1 = require("./constants");
4
+ /**
5
+ * Check to see if we are working on Vercel.
6
+ */
7
+ var isVercel = function (_a) {
8
+ var platform = _a.platform;
9
+ return constants_1.Platform.VERCEL === platform;
10
+ };
11
+ exports.default = isVercel;
@@ -0,0 +1,3 @@
1
+ import { Environment, Platform } from './constants';
2
+ export declare type EnvironmentType = typeof Environment.DEVELOPMENT | typeof Environment.STAGING | typeof Environment.PRODUCTION;
3
+ export declare type PlatformType = typeof Platform.AWS | typeof Platform.VERCEL;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ import { AwsConfigType } from '../aws';
2
+ import { CredentialsType } from './types';
3
+ /**
4
+ * Fetch the data from Parameter Store and return the data ready to be used with Google API.
5
+ */
6
+ declare const getCredentials: ({ SsmLib, awsConfig, parameterName }: {
7
+ SsmLib: any;
8
+ awsConfig: AwsConfigType;
9
+ parameterName: string;
10
+ }) => Promise<CredentialsType>;
11
+ export default getCredentials;
@@ -0,0 +1,77 @@
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 ssm_1 = require("../aws/ssm");
40
+ /**
41
+ * Fetch the data from Parameter Store and return the data ready to be used with Google API.
42
+ */
43
+ var getCredentials = function (_a) {
44
+ var SsmLib = _a.SsmLib, awsConfig = _a.awsConfig, parameterName = _a.parameterName;
45
+ return __awaiter(void 0, void 0, void 0, function () {
46
+ var ssmClient, parameter, privateKey;
47
+ return __generator(this, function (_b) {
48
+ switch (_b.label) {
49
+ case 0:
50
+ ssmClient = (0, ssm_1.getClient)({ SsmLib: SsmLib, config: awsConfig });
51
+ return [4 /*yield*/, (0, ssm_1.getParameter)({
52
+ SsmLib: SsmLib,
53
+ client: ssmClient,
54
+ name: parameterName,
55
+ withDecryption: true,
56
+ isJson: true,
57
+ })];
58
+ case 1:
59
+ parameter = _b.sent();
60
+ privateKey = parameter.privateKey.replace(/\\n/g, '\n');
61
+ return [2 /*return*/, {
62
+ type: 'service_account',
63
+ project_id: parameter.projectId,
64
+ private_key_id: 'private_key_id',
65
+ private_key: privateKey,
66
+ client_email: parameter.clientEmail,
67
+ client_id: parameter.clientId,
68
+ auth_uri: 'https://accounts.google.com/o/oauth2/auth',
69
+ token_uri: 'https://oauth2.googleapis.com/token',
70
+ auth_provider_x509_cert_url: 'https://www.googleapis.com/oauth2/v1/certs',
71
+ client_x509_cert_url: parameter.x509CertUrl,
72
+ }];
73
+ }
74
+ });
75
+ });
76
+ };
77
+ exports.default = getCredentials;
@@ -0,0 +1,4 @@
1
+ import getCredentials from './getCredentials';
2
+ import { CredentialsType } from './types';
3
+ export type { CredentialsType, };
4
+ export { getCredentials, };
@@ -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.getCredentials = void 0;
7
+ var getCredentials_1 = __importDefault(require("./getCredentials"));
8
+ exports.getCredentials = getCredentials_1.default;
@@ -0,0 +1,12 @@
1
+ export declare type CredentialsType = {
2
+ type: string;
3
+ project_id: string;
4
+ private_key_id: string;
5
+ private_key: string;
6
+ client_email: string;
7
+ client_id: string;
8
+ auth_uri: string;
9
+ token_uri: string;
10
+ auth_provider_x509_cert_url: string;
11
+ client_x509_cert_url: string;
12
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ import { AwsConfigType } from '../aws';
2
+ import { ClientType } from './types';
3
+ declare type GetClientType = {
4
+ GoogleAdsLib: any;
5
+ SsmLib: any;
6
+ awsConfig: AwsConfigType;
7
+ parameterName: string;
8
+ };
9
+ /**
10
+ * Shorthand function to get the Google Ads Client.
11
+ * Library: google-ads-api
12
+ */
13
+ declare const getClient: ({ GoogleAdsLib, SsmLib, awsConfig, parameterName }: GetClientType) => Promise<ClientType>;
14
+ export default getClient;
@@ -0,0 +1,80 @@
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 ssm_1 = require("../aws/ssm");
40
+ var googleAdsClient = undefined;
41
+ /**
42
+ * Shorthand function to get the Google Ads Client.
43
+ * Library: google-ads-api
44
+ */
45
+ var getClient = function (_a) {
46
+ var GoogleAdsLib = _a.GoogleAdsLib, SsmLib = _a.SsmLib, awsConfig = _a.awsConfig, parameterName = _a.parameterName;
47
+ return __awaiter(void 0, void 0, void 0, function () {
48
+ var ssmClient, parameter, GoogleAdsApi;
49
+ return __generator(this, function (_b) {
50
+ switch (_b.label) {
51
+ case 0:
52
+ if (!(undefined === googleAdsClient)) return [3 /*break*/, 2];
53
+ ssmClient = (0, ssm_1.getClient)({ SsmLib: SsmLib, config: awsConfig });
54
+ return [4 /*yield*/, (0, ssm_1.getParameter)({
55
+ SsmLib: SsmLib,
56
+ client: ssmClient,
57
+ name: parameterName,
58
+ withDecryption: true,
59
+ isJson: true,
60
+ })];
61
+ case 1:
62
+ parameter = _b.sent();
63
+ GoogleAdsApi = GoogleAdsLib.GoogleAdsApi;
64
+ // Create a new client instance
65
+ googleAdsClient = {
66
+ instance: new GoogleAdsApi({
67
+ client_id: parameter.clientId,
68
+ client_secret: parameter.clientSecret,
69
+ developer_token: parameter.developerToken,
70
+ }),
71
+ mccAccountId: parameter.mccAccountId,
72
+ refreshToken: parameter.refreshToken,
73
+ };
74
+ _b.label = 2;
75
+ case 2: return [2 /*return*/, googleAdsClient];
76
+ }
77
+ });
78
+ });
79
+ };
80
+ exports.default = getClient;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Return the Google Ads Client with the specified customer set.
3
+ */
4
+ declare const getCustomer: ({ client, customerId }: {
5
+ client: any;
6
+ customerId: string;
7
+ }) => Promise<any>;
8
+ export default getCustomer;
@@ -0,0 +1,56 @@
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
+ /**
40
+ * Return the Google Ads Client with the specified customer set.
41
+ */
42
+ var getCustomer = function (_a) {
43
+ var client = _a.client, customerId = _a.customerId;
44
+ return __awaiter(void 0, void 0, void 0, function () {
45
+ var customer;
46
+ return __generator(this, function (_b) {
47
+ customer = client.instance.Customer({
48
+ customer_id: customerId,
49
+ login_customer_id: client.mccAccountId,
50
+ refresh_token: client.refreshToken,
51
+ });
52
+ return [2 /*return*/, customer];
53
+ });
54
+ });
55
+ };
56
+ exports.default = getCustomer;
@@ -0,0 +1,5 @@
1
+ import { ClientType } from './types';
2
+ import getClient from './getClient';
3
+ import getCustomer from './getCustomer';
4
+ export type { ClientType };
5
+ export { getClient, getCustomer, };
@@ -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.getCustomer = exports.getClient = void 0;
7
+ var getClient_1 = __importDefault(require("./getClient"));
8
+ exports.getClient = getClient_1.default;
9
+ var getCustomer_1 = __importDefault(require("./getCustomer"));
10
+ exports.getCustomer = getCustomer_1.default;
@@ -0,0 +1,5 @@
1
+ export declare type ClientType = {
2
+ instance: any;
3
+ mccAccountId: string;
4
+ refreshToken: string;
5
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,26 @@
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, };