@8ms/helpers 2.0.0 → 2.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 (345) hide show
  1. package/.github/workflows/deploy_npmjs.yml +7 -0
  2. package/.yarn/install-state.gz +0 -0
  3. package/_class/BaseClass.d.ts +18 -0
  4. package/_class/BaseClass.js +53 -0
  5. package/_class/BaseNamespace.d.ts +9 -0
  6. package/_class/BaseNamespace.js +27 -0
  7. package/_class/index.d.ts +2 -0
  8. package/_class/index.js +7 -0
  9. package/adverity/getJobs.d.ts +15 -0
  10. package/adverity/getJobs.js +30 -0
  11. package/adverity/index.d.ts +112 -0
  12. package/adverity/index.js +61 -0
  13. package/api/ApiResponseClass.d.ts +35 -0
  14. package/api/ApiResponseClass.js +97 -0
  15. package/api/index.d.ts +22 -0
  16. package/api/index.js +44 -0
  17. package/array/index.d.ts +8 -0
  18. package/array/index.js +17 -0
  19. package/atInternet/index.d.ts +16 -0
  20. package/atInternet/index.js +18 -0
  21. package/aws/athenaExpress/AwsAthenaNamespace.d.ts +8 -0
  22. package/aws/athenaExpress/AwsAthenaNamespace.js +82 -0
  23. package/aws/athenaExpress/index.d.ts +10 -0
  24. package/aws/athenaExpress/index.js +40 -0
  25. package/aws/ec2/AwsEc2Namespace.d.ts +10 -0
  26. package/aws/ec2/AwsEc2Namespace.js +78 -0
  27. package/aws/ec2/index.d.ts +3 -0
  28. package/aws/ec2/index.js +16 -0
  29. package/aws/ecs/AwsEcsNamespace.d.ts +53 -0
  30. package/aws/ecs/AwsEcsNamespace.js +159 -0
  31. package/aws/ecs/index.d.ts +3 -0
  32. package/aws/ecs/index.js +16 -0
  33. package/aws/glue/AwsGlueNamespace.d.ts +12 -0
  34. package/aws/glue/AwsGlueNamespace.js +70 -0
  35. package/aws/glue/index.d.ts +3 -0
  36. package/aws/glue/index.js +16 -0
  37. package/aws/index.d.ts +9 -0
  38. package/aws/index.js +34 -0
  39. package/aws/isResponse200.d.ts +4 -0
  40. package/aws/isResponse200.js +16 -0
  41. package/aws/lambda/AwsLambdaNamespace.d.ts +21 -0
  42. package/aws/lambda/AwsLambdaNamespace.js +110 -0
  43. package/aws/lambda/index.d.ts +4 -0
  44. package/aws/lambda/index.js +21 -0
  45. package/aws/s3/AwsS3Namespace.d.ts +60 -0
  46. package/aws/s3/AwsS3Namespace.js +401 -0
  47. package/aws/s3/index.d.ts +25 -0
  48. package/aws/s3/index.js +36 -0
  49. package/aws/s3/payload.d.ts +42 -0
  50. package/aws/s3/payload.js +46 -0
  51. package/aws/ses/AwsSesNamespace.d.ts +18 -0
  52. package/aws/ses/AwsSesNamespace.js +69 -0
  53. package/aws/ses/SimpleEmail.d.ts +56 -0
  54. package/aws/ses/SimpleEmail.js +106 -0
  55. package/aws/ses/index.d.ts +4 -0
  56. package/aws/ses/index.js +18 -0
  57. package/aws/sqs/AwsSqsNamespace.d.ts +34 -0
  58. package/aws/sqs/AwsSqsNamespace.js +96 -0
  59. package/aws/sqs/index.d.ts +3 -0
  60. package/aws/sqs/index.js +16 -0
  61. package/aws/ssm/AwsSsmNamespace.d.ts +11 -0
  62. package/aws/ssm/AwsSsmNamespace.js +89 -0
  63. package/aws/ssm/index.d.ts +3 -0
  64. package/aws/ssm/index.js +16 -0
  65. package/axios/deleteRequest.d.ts +6 -0
  66. package/axios/deleteRequest.js +33 -0
  67. package/axios/get.d.ts +5 -0
  68. package/axios/get.js +31 -0
  69. package/axios/index.d.ts +3 -0
  70. package/axios/index.js +9 -0
  71. package/axios/post.d.ts +5 -0
  72. package/axios/post.js +32 -0
  73. package/boolean/getBoolean.d.ts +4 -0
  74. package/boolean/getBoolean.js +23 -0
  75. package/boolean/index.d.ts +1 -0
  76. package/boolean/index.js +5 -0
  77. package/brightData/index.d.ts +15 -0
  78. package/brightData/index.js +20 -0
  79. package/brightData/serpApi/buildGoogleSerpUrl.d.ts +32 -0
  80. package/brightData/serpApi/buildGoogleSerpUrl.js +116 -0
  81. package/brightData/serpApi/buildGoogleTrendsUrl.d.ts +22 -0
  82. package/brightData/serpApi/buildGoogleTrendsUrl.js +61 -0
  83. package/brightData/serpApi/getAsyncRequestId.d.ts +8 -0
  84. package/brightData/serpApi/getAsyncRequestId.js +36 -0
  85. package/brightData/serpApi/getAsyncResults.d.ts +7 -0
  86. package/brightData/serpApi/getAsyncResults.js +35 -0
  87. package/brightData/serpApi/getRealtime.d.ts +5 -0
  88. package/brightData/serpApi/getRealtime.js +30 -0
  89. package/brightData/serpApi/index.d.ts +14 -0
  90. package/brightData/serpApi/index.js +23 -0
  91. package/brightData/webScraperIde/getBatch.d.ts +7 -0
  92. package/brightData/webScraperIde/getBatch.js +28 -0
  93. package/brightData/webScraperIde/getRealtime.d.ts +7 -0
  94. package/brightData/webScraperIde/getRealtime.js +49 -0
  95. package/brightData/webScraperIde/index.d.ts +2 -0
  96. package/brightData/webScraperIde/index.js +7 -0
  97. package/cache/index.d.ts +2 -0
  98. package/cache/index.js +48 -0
  99. package/cache/test/cache.test.d.ts +1 -0
  100. package/cache/test/cache.test.js +10 -0
  101. package/crud/index.d.ts +6 -0
  102. package/crud/index.js +10 -0
  103. package/crypto/getDecrypt.d.ts +5 -0
  104. package/crypto/getDecrypt.js +47 -0
  105. package/crypto/getEncrypt.d.ts +5 -0
  106. package/crypto/getEncrypt.js +47 -0
  107. package/crypto/getRandom.d.ts +4 -0
  108. package/crypto/getRandom.js +12 -0
  109. package/crypto/getSha256.d.ts +5 -0
  110. package/crypto/getSha256.js +48 -0
  111. package/crypto/index.d.ts +4 -0
  112. package/crypto/index.js +11 -0
  113. package/date/calculation.d.ts +75 -0
  114. package/date/calculation.js +207 -0
  115. package/date/financialYear.d.ts +19 -0
  116. package/date/financialYear.js +85 -0
  117. package/date/format.d.ts +68 -0
  118. package/date/format.js +150 -0
  119. package/date/index.d.ts +35 -0
  120. package/date/index.js +57 -0
  121. package/environment/index.d.ts +32 -0
  122. package/environment/index.js +92 -0
  123. package/eskimi/getAgeGroup.d.ts +4 -0
  124. package/eskimi/getAgeGroup.js +15 -0
  125. package/eskimi/getData.d.ts +4 -0
  126. package/eskimi/getData.js +17 -0
  127. package/eskimi/getDevice.d.ts +4 -0
  128. package/eskimi/getDevice.js +15 -0
  129. package/eskimi/getGender.d.ts +4 -0
  130. package/eskimi/getGender.js +15 -0
  131. package/eskimi/index.d.ts +49 -0
  132. package/eskimi/index.js +96 -0
  133. package/file/createDirectory.d.ts +5 -0
  134. package/file/createDirectory.js +50 -0
  135. package/file/index.d.ts +1 -0
  136. package/file/index.js +5 -0
  137. package/geo/countries.d.ts +12 -0
  138. package/geo/countries.js +222 -0
  139. package/geo/index.d.ts +2 -0
  140. package/geo/index.js +7 -0
  141. package/geo/languages.d.ts +9 -0
  142. package/geo/languages.js +58 -0
  143. package/google/bigQuery/GoogleBigQueryNamespace.d.ts +51 -0
  144. package/google/bigQuery/GoogleBigQueryNamespace.js +165 -0
  145. package/google/bigQuery/index.d.ts +5 -0
  146. package/google/bigQuery/index.js +37 -0
  147. package/google/bigQuery/loadData.d.ts +19 -0
  148. package/google/bigQuery/loadData.js +18 -0
  149. package/google/index.d.ts +27 -0
  150. package/google/index.js +24 -0
  151. package/google/sheets/GoogleSheetsNamespace.d.ts +16 -0
  152. package/google/sheets/GoogleSheetsNamespace.js +81 -0
  153. package/google/sheets/getAssociatedData.d.ts +10 -0
  154. package/google/sheets/getAssociatedData.js +43 -0
  155. package/google/sheets/index.d.ts +8 -0
  156. package/google/sheets/index.js +37 -0
  157. package/google/storage/GoogleCloudStorageNamespace.d.ts +20 -0
  158. package/google/storage/GoogleCloudStorageNamespace.js +108 -0
  159. package/google/storage/index.d.ts +3 -0
  160. package/google/storage/index.js +30 -0
  161. package/googleAds/GoogleAdsNamespace.d.ts +11 -0
  162. package/googleAds/GoogleAdsNamespace.js +73 -0
  163. package/googleAds/index.d.ts +11 -0
  164. package/googleAds/index.js +30 -0
  165. package/googleAds/keywordPlanner/index.d.ts +40 -0
  166. package/googleAds/keywordPlanner/index.js +59 -0
  167. package/googlePageSpeed/GooglePageSpeedNamespace.d.ts +11 -0
  168. package/googlePageSpeed/GooglePageSpeedNamespace.js +35 -0
  169. package/googlePageSpeed/index.d.ts +17 -0
  170. package/googlePageSpeed/index.js +44 -0
  171. package/googleSearchIncidents/index.d.ts +69 -0
  172. package/googleSearchIncidents/index.js +46 -0
  173. package/greenDomain/index.d.ts +21 -0
  174. package/greenDomain/index.js +41 -0
  175. package/inngest/index.d.ts +6 -0
  176. package/inngest/index.js +10 -0
  177. package/json/getJsonNewline.d.ts +1 -0
  178. package/json/getJsonNewline.js +13 -0
  179. package/json/index.d.ts +2 -0
  180. package/json/index.js +7 -0
  181. package/json/isJson.d.ts +1 -0
  182. package/json/isJson.js +26 -0
  183. package/littleWarden/LittleWardenNamespace.d.ts +11 -0
  184. package/littleWarden/LittleWardenNamespace.js +38 -0
  185. package/littleWarden/getUrlStatus.d.ts +4 -0
  186. package/littleWarden/getUrlStatus.js +16 -0
  187. package/littleWarden/index.d.ts +29 -0
  188. package/littleWarden/index.js +74 -0
  189. package/lumar/api/buildRequest.d.ts +13 -0
  190. package/lumar/api/buildRequest.js +80 -0
  191. package/lumar/api/getData.d.ts +5 -0
  192. package/lumar/api/getData.js +13 -0
  193. package/lumar/api/index.d.ts +36 -0
  194. package/lumar/api/index.js +33 -0
  195. package/lumar/api/initClient.d.ts +6 -0
  196. package/lumar/api/initClient.js +26 -0
  197. package/lumar/graphql/columns.d.ts +28 -0
  198. package/lumar/graphql/columns.js +31 -0
  199. package/lumar/graphql/getData.d.ts +1 -0
  200. package/lumar/graphql/getData.js +20 -0
  201. package/lumar/graphql/index.d.ts +29 -0
  202. package/lumar/graphql/index.js +39 -0
  203. package/lumar/graphql/initClient.d.ts +5 -0
  204. package/lumar/graphql/initClient.js +25 -0
  205. package/lumar/graphql/queries/crawl.d.ts +5 -0
  206. package/lumar/graphql/queries/crawl.js +2 -0
  207. package/lumar/graphql/queries/getCrawls.d.ts +18 -0
  208. package/lumar/graphql/queries/getCrawls.js +33 -0
  209. package/lumar/graphql/queries/getReportDifferences.d.ts +24 -0
  210. package/lumar/graphql/queries/getReportDifferences.js +37 -0
  211. package/lumar/graphql/queries/getRows.d.ts +38 -0
  212. package/lumar/graphql/queries/getRows.js +57 -0
  213. package/lumar/graphql/queries/getTotals.d.ts +25 -0
  214. package/lumar/graphql/queries/getTotals.js +40 -0
  215. package/lumar/graphql/queries/row.d.ts +157 -0
  216. package/lumar/graphql/queries/row.js +2 -0
  217. package/lumar/graphql/reportTemplates.d.ts +67 -0
  218. package/lumar/graphql/reportTemplates.js +70 -0
  219. package/myTarget/request.d.ts +5 -0
  220. package/myTarget/request.js +17 -0
  221. package/nextAuth/index.d.ts +6 -0
  222. package/nextAuth/index.js +11 -0
  223. package/nextAuth/isSessionReady.d.ts +1 -0
  224. package/nextAuth/isSessionReady.js +13 -0
  225. package/nextJs/getIp.d.ts +6 -0
  226. package/nextJs/getIp.js +14 -0
  227. package/nextJs/getUserAgent.d.ts +6 -0
  228. package/nextJs/getUserAgent.js +8 -0
  229. package/nextJs/index.d.ts +2 -0
  230. package/nextJs/index.js +7 -0
  231. package/number/format.d.ts +12 -0
  232. package/number/format.js +20 -0
  233. package/number/formatCurrency.d.ts +5 -0
  234. package/number/formatCurrency.js +21 -0
  235. package/number/getDecimal.d.ts +4 -0
  236. package/number/getDecimal.js +12 -0
  237. package/number/getNumber.d.ts +4 -0
  238. package/number/getNumber.js +48 -0
  239. package/number/getPercentIncrease.d.ts +4 -0
  240. package/number/getPercentIncrease.js +16 -0
  241. package/number/getSafeDivide.d.ts +11 -0
  242. package/number/getSafeDivide.js +20 -0
  243. package/number/index.d.ts +6 -0
  244. package/number/index.js +15 -0
  245. package/object/index.d.ts +1 -0
  246. package/object/index.js +5 -0
  247. package/object/replaceKeys.d.ts +5 -0
  248. package/object/replaceKeys.js +25 -0
  249. package/onePassword/OnePasswordNamespace.d.ts +13 -0
  250. package/onePassword/OnePasswordNamespace.js +81 -0
  251. package/onePassword/index.d.ts +7 -0
  252. package/onePassword/index.js +25 -0
  253. package/openAi/OpenAiNamespace.d.ts +11 -0
  254. package/openAi/OpenAiNamespace.js +44 -0
  255. package/openAi/index.d.ts +5 -0
  256. package/openAi/index.js +30 -0
  257. package/package.json +2 -2
  258. package/prisma/PrismaNamespace.d.ts +8 -0
  259. package/prisma/PrismaNamespace.js +79 -0
  260. package/prisma/getDecimal.d.ts +4 -0
  261. package/prisma/getDecimal.js +23 -0
  262. package/prisma/index.d.ts +8 -0
  263. package/prisma/index.js +29 -0
  264. package/snapchat/SnapchatNamespace.d.ts +15 -0
  265. package/snapchat/SnapchatNamespace.js +30 -0
  266. package/snapchat/index.d.ts +7 -0
  267. package/snapchat/index.js +30 -0
  268. package/sorting/byNumberAscending.d.ts +4 -0
  269. package/sorting/byNumberAscending.js +19 -0
  270. package/sorting/byNumberDescending.d.ts +4 -0
  271. package/sorting/byNumberDescending.js +22 -0
  272. package/sorting/byStringAscending.d.ts +4 -0
  273. package/sorting/byStringAscending.js +16 -0
  274. package/sorting/byStringDescending.d.ts +4 -0
  275. package/sorting/byStringDescending.js +16 -0
  276. package/sorting/index.d.ts +4 -0
  277. package/sorting/index.js +11 -0
  278. package/stream/index.d.ts +1 -0
  279. package/stream/index.js +5 -0
  280. package/stream/sort.d.ts +13 -0
  281. package/stream/sort.js +51 -0
  282. package/string/getCapitalised.d.ts +5 -0
  283. package/string/getCapitalised.js +18 -0
  284. package/string/getClean.d.ts +18 -0
  285. package/string/getClean.js +51 -0
  286. package/string/getFolder.d.ts +4 -0
  287. package/string/getFolder.js +15 -0
  288. package/string/getProperCase.d.ts +11 -0
  289. package/string/getProperCase.js +25 -0
  290. package/string/getString.d.ts +4 -0
  291. package/string/getString.js +34 -0
  292. package/string/getStringFromStream.d.ts +5 -0
  293. package/string/getStringFromStream.js +17 -0
  294. package/string/getUnescaped.d.ts +6 -0
  295. package/string/getUnescaped.js +26 -0
  296. package/string/getWithoutAccents.d.ts +5 -0
  297. package/string/getWithoutAccents.js +13 -0
  298. package/string/getWithoutHtmlTags.d.ts +5 -0
  299. package/string/getWithoutHtmlTags.js +12 -0
  300. package/string/getWithoutPunctuation.d.ts +5 -0
  301. package/string/getWithoutPunctuation.js +13 -0
  302. package/string/getWithoutUnderscores.d.ts +4 -0
  303. package/string/getWithoutUnderscores.js +11 -0
  304. package/string/getWithoutWhitespaces.d.ts +5 -0
  305. package/string/getWithoutWhitespaces.js +13 -0
  306. package/string/index.d.ts +12 -0
  307. package/string/index.js +27 -0
  308. package/swr/index.d.ts +42 -0
  309. package/swr/index.js +59 -0
  310. package/upTimeRobot/UpTimeRobotNamespace.d.ts +31 -0
  311. package/upTimeRobot/UpTimeRobotNamespace.js +52 -0
  312. package/upTimeRobot/index.d.ts +38 -0
  313. package/upTimeRobot/index.js +63 -0
  314. package/url/index.d.ts +19 -0
  315. package/url/index.js +70 -0
  316. package/url/writeUrlContents.d.ts +6 -0
  317. package/url/writeUrlContents.js +75 -0
  318. package/util/defaultTo.d.ts +4 -0
  319. package/util/defaultTo.js +44 -0
  320. package/util/getBrotliCompressed.d.ts +5 -0
  321. package/util/getBrotliCompressed.js +23 -0
  322. package/util/getBrotliDecompressed.d.ts +5 -0
  323. package/util/getBrotliDecompressed.js +24 -0
  324. package/util/getClean.d.ts +11 -0
  325. package/util/getClean.js +23 -0
  326. package/util/getGzipCompressed.d.ts +5 -0
  327. package/util/getGzipCompressed.js +23 -0
  328. package/util/getGzipDecompressed.d.ts +5 -0
  329. package/util/getGzipDecompressed.js +24 -0
  330. package/util/getWithoutHash.d.ts +4 -0
  331. package/util/getWithoutHash.js +18 -0
  332. package/util/getWithoutParameter.d.ts +4 -0
  333. package/util/getWithoutParameter.js +18 -0
  334. package/util/index.d.ts +11 -0
  335. package/util/index.js +25 -0
  336. package/util/isUndefined.d.ts +4 -0
  337. package/util/isUndefined.js +13 -0
  338. package/util/promiseChunks.d.ts +5 -0
  339. package/util/promiseChunks.js +19 -0
  340. package/util/sleep.d.ts +1 -0
  341. package/util/sleep.js +7 -0
  342. package/webWorker/index.d.ts +5 -0
  343. package/webWorker/index.js +9 -0
  344. package/xml/getXml.d.ts +1 -0
  345. package/xml/getXml.js +18 -0
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFinancialYearWeeks = exports.getFinancialYearToYesterday = exports.getFinancialYearToDate = exports.getFinancialYear = void 0;
4
+ const _1 = require("./");
5
+ const luxon_1 = require("luxon");
6
+ /**
7
+ * Get the current financial year.
8
+ */
9
+ const getFinancialYear = (year) => {
10
+ // Either use the current year or a specified year
11
+ let financialYear = year;
12
+ if ("undefined" === typeof year) {
13
+ const todayInstance = (0, _1.getToday)();
14
+ // If today is before 1st of April, then use last year
15
+ if (todayInstance < (0, _1.getDate)(`${todayInstance.toFormat("yyyy")}-04-01`)) {
16
+ financialYear = Number(todayInstance.toFormat("yyyy")) - 1;
17
+ }
18
+ // On or after 1st of April, use this year
19
+ else {
20
+ financialYear = Number(todayInstance.toFormat("yyyy"));
21
+ }
22
+ }
23
+ // The year start needs to be 1st April this year - if its not a monday we need to shift this to the next monday.
24
+ let yearStartInstance = (0, _1.getDate)(`${financialYear}-04-01`);
25
+ // Get the previous Monday if the 1st of April isn't a Monday
26
+ if ("Mon" !== yearStartInstance.toFormat("EEE")) {
27
+ // Get the ISO Day of the week (Monday - 1 to Sunday - 7)
28
+ const dayOfWeek = Number(yearStartInstance.toFormat("E"));
29
+ // Calculate days to subtract to get to previous Monday
30
+ const daysToSubtract = dayOfWeek - 1;
31
+ yearStartInstance = yearStartInstance.minus({ days: daysToSubtract });
32
+ }
33
+ // The year-end needs to be 31st March next year
34
+ // We are specifying the date, so don't change the timezone
35
+ let yearEndInstance = (0, _1.getDate)(`${(financialYear + 1)}-03-31`);
36
+ // Get the next Sunday if the 31st of March isn't a Sunday
37
+ if ("Sun" !== yearEndInstance.toFormat("EEE")) {
38
+ // Get the ISO Day of the week (Monday - 1 to Sunday - 7)
39
+ const dayOfWeek = Number(yearEndInstance.toFormat("E"));
40
+ // Calculate days to add to get to next Sunday
41
+ const daysToAdd = 7 - dayOfWeek;
42
+ yearEndInstance = yearEndInstance.plus({ days: daysToAdd });
43
+ }
44
+ return {
45
+ end: yearEndInstance,
46
+ start: yearStartInstance,
47
+ };
48
+ };
49
+ exports.getFinancialYear = getFinancialYear;
50
+ /**
51
+ * Return the current financial year up to today.
52
+ */
53
+ const getFinancialYearToDate = () => {
54
+ const todayInstance = (0, _1.getToday)();
55
+ const thisFinancialYear = (0, exports.getFinancialYear)();
56
+ return {
57
+ end: todayInstance,
58
+ start: thisFinancialYear.start,
59
+ };
60
+ };
61
+ exports.getFinancialYearToDate = getFinancialYearToDate;
62
+ /**
63
+ * Return the current financial year up to yesterday.
64
+ * Timezone should always be London based
65
+ */
66
+ const getFinancialYearToYesterday = () => {
67
+ const yesterdayInstance = (0, _1.getYesterday)();
68
+ const thisFinancialYear = (0, exports.getFinancialYear)();
69
+ return {
70
+ end: yesterdayInstance,
71
+ start: thisFinancialYear.start,
72
+ };
73
+ };
74
+ exports.getFinancialYearToYesterday = getFinancialYearToYesterday;
75
+ /**
76
+ * Get the current financial year.
77
+ */
78
+ const getFinancialYearWeeks = (year) => {
79
+ const financialYear = (0, exports.getFinancialYear)(year);
80
+ const response = luxon_1.Interval
81
+ .fromDateTimes(financialYear.start, financialYear.end)
82
+ .splitBy({ weeks: 1 });
83
+ return response;
84
+ };
85
+ exports.getFinancialYearWeeks = getFinancialYearWeeks;
@@ -0,0 +1,68 @@
1
+ import { InputDate } from "./";
2
+ import { DateTime } from "luxon";
3
+ /**
4
+ * Convert a number of seconds into HH:MM:SS
5
+ * https://www.codevertiser.com/convert-seconds-to-hours-and-minutes-javascript/
6
+ */
7
+ export declare const getDurationHours: (seconds: number) => string;
8
+ /**
9
+ * Convert a number of seconds into MM:SS
10
+ * https://www.codevertiser.com/convert-seconds-to-hours-and-minutes-javascript/
11
+ */
12
+ export declare const getDurationMinutes: (seconds: number) => string;
13
+ /**
14
+ * Simple function takes any DateTime, String or Number and formats it.
15
+ */
16
+ export declare const format: (input: InputDate, dateFormat: string) => string;
17
+ /**
18
+ * Convert a Date into a dd number.
19
+ */
20
+ export declare const getDayNumber: (input: InputDate) => number;
21
+ /**
22
+ * Whenever we are displaying a month and year date in Codex, this will be the standardised format.
23
+ * Example: 1901-02-03 → 3 Feb 1901
24
+ */
25
+ export declare const getFullDate: (input: InputDate) => string;
26
+ /**
27
+ * Whenever we are displaying a month and year date in Codex, this will be the standardised format.
28
+ * Example: 1901-02-03 01:23:45 → 1:23am 3 Feb 1901
29
+ */
30
+ export declare const getFullDateTime: (input: InputDate) => string;
31
+ /**
32
+ * Returns a MMM YYYY value as a number for a given year.
33
+ * Example: 1901-02-03 → Feb 1901
34
+ */
35
+ export declare const getMonthYearString: (input: InputDate) => string;
36
+ /**
37
+ * Shorthand to get the current date.
38
+ */
39
+ export declare const getTodayYmdString: () => string;
40
+ /**
41
+ * Convert a Date into a YYYY number.
42
+ */
43
+ export declare const getYearNumber: (input: InputDate) => number;
44
+ /**
45
+ * Returns a YYYYMMDDHHIISS value as a number.
46
+ * Example: 1901-02-03 01:23:45 → 19010203012345
47
+ */
48
+ export declare const getYmdHisNumber: (input: InputDate) => number;
49
+ /**
50
+ * Returns a YYYY-MM-DD HH:MM:SS value as a string.
51
+ * Example: 1901-02-03 → 1901-02-03 00:00:00
52
+ */
53
+ export declare const getYmdHisString: (input: InputDate) => string;
54
+ /**
55
+ * Returns a YYYYMMDD value as a number.
56
+ * Example: 1901-02-03 → 19010203
57
+ */
58
+ export declare const getYmdNumber: (input: InputDate) => number;
59
+ /**
60
+ * Whenever we are displaying a YYYY-MM-DD date in Codex
61
+ * Example: 1901-02-03 → 1901-02-03
62
+ */
63
+ export declare const getYmdString: (input: InputDate) => string;
64
+ /**
65
+ * Convert an Excel date "e.g. 44216" into a JavaScript date object.
66
+ * https://stackoverflow.com/questions/16229494/converting-excel-date-serial-number-to-date-using-javascript
67
+ */
68
+ export declare const parseExcelDate: (serial: number) => DateTime<true> | DateTime<false>;
package/date/format.js ADDED
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseExcelDate = exports.getYmdString = exports.getYmdNumber = exports.getYmdHisString = exports.getYmdHisNumber = exports.getYearNumber = exports.getTodayYmdString = exports.getMonthYearString = exports.getFullDateTime = exports.getFullDate = exports.getDayNumber = exports.format = exports.getDurationMinutes = exports.getDurationHours = void 0;
4
+ const _1 = require("./");
5
+ const luxon_1 = require("luxon");
6
+ /**
7
+ * Convert a number of seconds into HH:MM:SS
8
+ * https://www.codevertiser.com/convert-seconds-to-hours-and-minutes-javascript/
9
+ */
10
+ const getDurationHours = (seconds) => {
11
+ let response = "00:00:00";
12
+ if (seconds > 0) {
13
+ const calculated = {
14
+ hours: Math.floor(seconds / 3600),
15
+ minutes: Math.floor((seconds % 3600) / 60),
16
+ seconds: seconds % 60,
17
+ };
18
+ const output = {
19
+ hours: calculated.hours < 10 ? "0" + calculated.hours : calculated.hours,
20
+ minutes: calculated.minutes < 10 ? "0" + calculated.minutes : calculated.minutes,
21
+ seconds: calculated.seconds < 10 ? "0" + calculated.seconds : calculated.seconds,
22
+ };
23
+ response = `${output.hours}:${output.minutes}:${output.seconds}`;
24
+ }
25
+ return response;
26
+ };
27
+ exports.getDurationHours = getDurationHours;
28
+ /**
29
+ * Convert a number of seconds into MM:SS
30
+ * https://www.codevertiser.com/convert-seconds-to-hours-and-minutes-javascript/
31
+ */
32
+ const getDurationMinutes = (seconds) => {
33
+ let response = "00:00";
34
+ if (seconds > 0) {
35
+ const calculated = {
36
+ minutes: Math.floor((seconds % 3600) / 60),
37
+ seconds: seconds % 60,
38
+ };
39
+ const output = {
40
+ minutes: calculated.minutes < 10 ? "0" + calculated.minutes : calculated.minutes,
41
+ seconds: calculated.seconds < 10 ? "0" + calculated.seconds : calculated.seconds,
42
+ };
43
+ response = `${output.minutes}:${output.seconds}`;
44
+ }
45
+ return response;
46
+ };
47
+ exports.getDurationMinutes = getDurationMinutes;
48
+ /**
49
+ * Simple function takes any DateTime, String or Number and formats it.
50
+ */
51
+ const format = (input, dateFormat) => {
52
+ const instance = (0, _1.getDate)(input);
53
+ return instance.toFormat(dateFormat);
54
+ };
55
+ exports.format = format;
56
+ /**
57
+ * Convert a Date into a dd number.
58
+ */
59
+ const getDayNumber = (input) => {
60
+ return Number((0, exports.format)(input, "dd"));
61
+ };
62
+ exports.getDayNumber = getDayNumber;
63
+ /**
64
+ * Whenever we are displaying a month and year date in Codex, this will be the standardised format.
65
+ * Example: 1901-02-03 → 3 Feb 1901
66
+ */
67
+ const getFullDate = (input) => {
68
+ return (0, exports.format)(input, "d MMM yyyy");
69
+ };
70
+ exports.getFullDate = getFullDate;
71
+ /**
72
+ * Whenever we are displaying a month and year date in Codex, this will be the standardised format.
73
+ * Example: 1901-02-03 01:23:45 → 1:23am 3 Feb 1901
74
+ */
75
+ const getFullDateTime = (input) => {
76
+ return (0, exports.format)(input, "d MMM yyyy h:mmaaa");
77
+ };
78
+ exports.getFullDateTime = getFullDateTime;
79
+ /**
80
+ * Returns a MMM YYYY value as a number for a given year.
81
+ * Example: 1901-02-03 → Feb 1901
82
+ */
83
+ const getMonthYearString = (input) => {
84
+ return (0, exports.format)(input, "MMM yyyy");
85
+ };
86
+ exports.getMonthYearString = getMonthYearString;
87
+ /**
88
+ * Shorthand to get the current date.
89
+ */
90
+ const getTodayYmdString = () => {
91
+ const today = (0, _1.getToday)();
92
+ return (0, exports.getYmdString)(today);
93
+ };
94
+ exports.getTodayYmdString = getTodayYmdString;
95
+ /**
96
+ * Convert a Date into a YYYY number.
97
+ */
98
+ const getYearNumber = (input) => {
99
+ return Number((0, exports.format)(input, "yyyy"));
100
+ };
101
+ exports.getYearNumber = getYearNumber;
102
+ /**
103
+ * Returns a YYYYMMDDHHIISS value as a number.
104
+ * Example: 1901-02-03 01:23:45 → 19010203012345
105
+ */
106
+ const getYmdHisNumber = (input) => {
107
+ return Number((0, exports.format)(input, "yyyyMMddHHmmss"));
108
+ };
109
+ exports.getYmdHisNumber = getYmdHisNumber;
110
+ /**
111
+ * Returns a YYYY-MM-DD HH:MM:SS value as a string.
112
+ * Example: 1901-02-03 → 1901-02-03 00:00:00
113
+ */
114
+ const getYmdHisString = (input) => {
115
+ return (0, exports.format)(input, "yyyy-MM-dd HH:mm:ss");
116
+ };
117
+ exports.getYmdHisString = getYmdHisString;
118
+ /**
119
+ * Returns a YYYYMMDD value as a number.
120
+ * Example: 1901-02-03 → 19010203
121
+ */
122
+ const getYmdNumber = (input) => {
123
+ return Number((0, exports.format)(input, "yyyyMMdd"));
124
+ };
125
+ exports.getYmdNumber = getYmdNumber;
126
+ /**
127
+ * Whenever we are displaying a YYYY-MM-DD date in Codex
128
+ * Example: 1901-02-03 → 1901-02-03
129
+ */
130
+ const getYmdString = (input) => {
131
+ return (0, exports.format)(input, "yyyy-MM-dd");
132
+ };
133
+ exports.getYmdString = getYmdString;
134
+ /**
135
+ * Convert an Excel date "e.g. 44216" into a JavaScript date object.
136
+ * https://stackoverflow.com/questions/16229494/converting-excel-date-serial-number-to-date-using-javascript
137
+ */
138
+ const parseExcelDate = (serial) => {
139
+ const utcDates = Math.floor(serial - 25569);
140
+ const utcValue = utcDates * 86400;
141
+ const dateInfo = new Date(utcValue * 1000);
142
+ const fractionalDay = serial - Math.floor(serial) + 0.0000001;
143
+ let totalSeconds = Math.floor(86400 * fractionalDay);
144
+ const seconds = totalSeconds % 60;
145
+ totalSeconds -= seconds;
146
+ const hours = Math.floor(totalSeconds / (60 * 60));
147
+ const minutes = Math.floor(totalSeconds / 60) % 60;
148
+ return luxon_1.DateTime.fromISO(`${dateInfo.getFullYear()}-${dateInfo.getMonth()}-${dateInfo.getDate()}T${hours}:${minutes}:${seconds}Z`);
149
+ };
150
+ exports.parseExcelDate = parseExcelDate;
@@ -0,0 +1,35 @@
1
+ import type { DateTime } from "luxon";
2
+ export type InputDate = Date | DateTime | string | number;
3
+ export type FinancialWeek = {
4
+ end: DateTime;
5
+ start: DateTime;
6
+ weekNumber: number;
7
+ year: number;
8
+ };
9
+ /**
10
+ * A timeframe has a start and an end date.
11
+ */
12
+ export type Timeframe = {
13
+ end: DateTime;
14
+ start: DateTime;
15
+ };
16
+ /**
17
+ * Used by Google Ads API.
18
+ */
19
+ export declare enum Month {
20
+ JANUARY = "JANUARY",
21
+ FEBRUARY = "FEBRUARY",
22
+ MARCH = "MARCH",
23
+ APRIL = "APRIL",
24
+ MAY = "MAY",
25
+ JUNE = "JUNE",
26
+ JULY = "JULY",
27
+ AUGUST = "AUGUST",
28
+ SEPTEMBER = "SEPTEMBER",
29
+ OCTOBER = "OCTOBER",
30
+ NOVEMBER = "NOVEMBER",
31
+ DECEMBER = "DECEMBER"
32
+ }
33
+ export { getUtcDate, getDate, getDatesBetween, getMax, getMin, getMonday, getSunday, getThisWeek, getLastWeek, getTwoWeeksAgo, getToday, getWeeksAgo, getYesterday, isThisWeek, isLastWeek, } from "./calculation";
34
+ export { getFinancialYear, getFinancialYearToDate, getFinancialYearToYesterday, getFinancialYearWeeks, } from "./financialYear";
35
+ export { format, getDayNumber, getFullDate, getFullDateTime, getDurationHours, getDurationMinutes, getMonthYearString, getTodayYmdString, getYearNumber, getYmdHisNumber, getYmdHisString, getYmdNumber, getYmdString, parseExcelDate } from "./format";
package/date/index.js ADDED
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseExcelDate = exports.getYmdString = exports.getYmdNumber = exports.getYmdHisString = exports.getYmdHisNumber = exports.getYearNumber = exports.getTodayYmdString = exports.getMonthYearString = exports.getDurationMinutes = exports.getDurationHours = exports.getFullDateTime = exports.getFullDate = exports.getDayNumber = exports.format = exports.getFinancialYearWeeks = exports.getFinancialYearToYesterday = exports.getFinancialYearToDate = exports.getFinancialYear = exports.isLastWeek = exports.isThisWeek = exports.getYesterday = exports.getWeeksAgo = exports.getToday = exports.getTwoWeeksAgo = exports.getLastWeek = exports.getThisWeek = exports.getSunday = exports.getMonday = exports.getMin = exports.getMax = exports.getDatesBetween = exports.getDate = exports.getUtcDate = exports.Month = void 0;
4
+ /**
5
+ * Used by Google Ads API.
6
+ */
7
+ var Month;
8
+ (function (Month) {
9
+ Month["JANUARY"] = "JANUARY";
10
+ Month["FEBRUARY"] = "FEBRUARY";
11
+ Month["MARCH"] = "MARCH";
12
+ Month["APRIL"] = "APRIL";
13
+ Month["MAY"] = "MAY";
14
+ Month["JUNE"] = "JUNE";
15
+ Month["JULY"] = "JULY";
16
+ Month["AUGUST"] = "AUGUST";
17
+ Month["SEPTEMBER"] = "SEPTEMBER";
18
+ Month["OCTOBER"] = "OCTOBER";
19
+ Month["NOVEMBER"] = "NOVEMBER";
20
+ Month["DECEMBER"] = "DECEMBER";
21
+ })(Month || (exports.Month = Month = {}));
22
+ var calculation_1 = require("./calculation");
23
+ Object.defineProperty(exports, "getUtcDate", { enumerable: true, get: function () { return calculation_1.getUtcDate; } });
24
+ Object.defineProperty(exports, "getDate", { enumerable: true, get: function () { return calculation_1.getDate; } });
25
+ Object.defineProperty(exports, "getDatesBetween", { enumerable: true, get: function () { return calculation_1.getDatesBetween; } });
26
+ Object.defineProperty(exports, "getMax", { enumerable: true, get: function () { return calculation_1.getMax; } });
27
+ Object.defineProperty(exports, "getMin", { enumerable: true, get: function () { return calculation_1.getMin; } });
28
+ Object.defineProperty(exports, "getMonday", { enumerable: true, get: function () { return calculation_1.getMonday; } });
29
+ Object.defineProperty(exports, "getSunday", { enumerable: true, get: function () { return calculation_1.getSunday; } });
30
+ Object.defineProperty(exports, "getThisWeek", { enumerable: true, get: function () { return calculation_1.getThisWeek; } });
31
+ Object.defineProperty(exports, "getLastWeek", { enumerable: true, get: function () { return calculation_1.getLastWeek; } });
32
+ Object.defineProperty(exports, "getTwoWeeksAgo", { enumerable: true, get: function () { return calculation_1.getTwoWeeksAgo; } });
33
+ Object.defineProperty(exports, "getToday", { enumerable: true, get: function () { return calculation_1.getToday; } });
34
+ Object.defineProperty(exports, "getWeeksAgo", { enumerable: true, get: function () { return calculation_1.getWeeksAgo; } });
35
+ Object.defineProperty(exports, "getYesterday", { enumerable: true, get: function () { return calculation_1.getYesterday; } });
36
+ Object.defineProperty(exports, "isThisWeek", { enumerable: true, get: function () { return calculation_1.isThisWeek; } });
37
+ Object.defineProperty(exports, "isLastWeek", { enumerable: true, get: function () { return calculation_1.isLastWeek; } });
38
+ var financialYear_1 = require("./financialYear");
39
+ Object.defineProperty(exports, "getFinancialYear", { enumerable: true, get: function () { return financialYear_1.getFinancialYear; } });
40
+ Object.defineProperty(exports, "getFinancialYearToDate", { enumerable: true, get: function () { return financialYear_1.getFinancialYearToDate; } });
41
+ Object.defineProperty(exports, "getFinancialYearToYesterday", { enumerable: true, get: function () { return financialYear_1.getFinancialYearToYesterday; } });
42
+ Object.defineProperty(exports, "getFinancialYearWeeks", { enumerable: true, get: function () { return financialYear_1.getFinancialYearWeeks; } });
43
+ var format_1 = require("./format");
44
+ Object.defineProperty(exports, "format", { enumerable: true, get: function () { return format_1.format; } });
45
+ Object.defineProperty(exports, "getDayNumber", { enumerable: true, get: function () { return format_1.getDayNumber; } });
46
+ Object.defineProperty(exports, "getFullDate", { enumerable: true, get: function () { return format_1.getFullDate; } });
47
+ Object.defineProperty(exports, "getFullDateTime", { enumerable: true, get: function () { return format_1.getFullDateTime; } });
48
+ Object.defineProperty(exports, "getDurationHours", { enumerable: true, get: function () { return format_1.getDurationHours; } });
49
+ Object.defineProperty(exports, "getDurationMinutes", { enumerable: true, get: function () { return format_1.getDurationMinutes; } });
50
+ Object.defineProperty(exports, "getMonthYearString", { enumerable: true, get: function () { return format_1.getMonthYearString; } });
51
+ Object.defineProperty(exports, "getTodayYmdString", { enumerable: true, get: function () { return format_1.getTodayYmdString; } });
52
+ Object.defineProperty(exports, "getYearNumber", { enumerable: true, get: function () { return format_1.getYearNumber; } });
53
+ Object.defineProperty(exports, "getYmdHisNumber", { enumerable: true, get: function () { return format_1.getYmdHisNumber; } });
54
+ Object.defineProperty(exports, "getYmdHisString", { enumerable: true, get: function () { return format_1.getYmdHisString; } });
55
+ Object.defineProperty(exports, "getYmdNumber", { enumerable: true, get: function () { return format_1.getYmdNumber; } });
56
+ Object.defineProperty(exports, "getYmdString", { enumerable: true, get: function () { return format_1.getYmdString; } });
57
+ Object.defineProperty(exports, "parseExcelDate", { enumerable: true, get: function () { return format_1.parseExcelDate; } });
@@ -0,0 +1,32 @@
1
+ export declare enum Environment {
2
+ DEVELOPMENT = "development",
3
+ STAGING = "staging",
4
+ PRODUCTION = "production"
5
+ }
6
+ export declare enum Platform {
7
+ AWS = "AWS",
8
+ VERCEL = "VERCEL"
9
+ }
10
+ /**
11
+ * Determine the environment we're using.
12
+ */
13
+ export declare const getEnvironment: () => Environment;
14
+ /**
15
+ * Check to see if we are working on AWS Lambda.
16
+ */
17
+ export declare const isAws: () => boolean;
18
+ export declare const isVercel: () => boolean;
19
+ /**
20
+ * Some code should only run on the server side to protect the data.
21
+ */
22
+ export declare const isServer: boolean;
23
+ /**
24
+ * Check the environment currently running.
25
+ */
26
+ export declare const isDevelopment: () => boolean;
27
+ export declare const isStaging: () => boolean;
28
+ export declare const isProduction: () => boolean;
29
+ /**
30
+ * Check to see if we are developing locally or on the hosted platform.
31
+ */
32
+ export declare const isLocalhost: () => boolean;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isLocalhost = exports.isProduction = exports.isStaging = exports.isDevelopment = exports.isServer = exports.isVercel = exports.isAws = exports.getEnvironment = exports.Platform = exports.Environment = void 0;
4
+ var Environment;
5
+ (function (Environment) {
6
+ Environment["DEVELOPMENT"] = "development";
7
+ Environment["STAGING"] = "staging";
8
+ Environment["PRODUCTION"] = "production";
9
+ })(Environment || (exports.Environment = Environment = {}));
10
+ var Platform;
11
+ (function (Platform) {
12
+ Platform["AWS"] = "AWS";
13
+ Platform["VERCEL"] = "VERCEL";
14
+ })(Platform || (exports.Platform = Platform = {}));
15
+ /**
16
+ * Determine the environment we're using.
17
+ */
18
+ const getEnvironment = () => {
19
+ let platformEnvironment = process.env.ENVIRONMENT;
20
+ let response;
21
+ // Custom - Backend/AWS
22
+ if (process.env.EMS_ENVIRONMENT) {
23
+ platformEnvironment = process.env.EMS_ENVIRONMENT;
24
+ }
25
+ // Custom - Frontend
26
+ else if (process.env.NEXT_PUBLIC_EMS_ENVIRONMENT) {
27
+ platformEnvironment = process.env.NEXT_PUBLIC_EMS_ENVIRONMENT;
28
+ }
29
+ // Vercel - Frontend
30
+ else if (process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF) {
31
+ platformEnvironment = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF;
32
+ }
33
+ // Vercel - Backend
34
+ else if (process.env.VERCEL_GIT_COMMIT_REF) {
35
+ platformEnvironment = process.env.VERCEL_GIT_COMMIT_REF;
36
+ }
37
+ const platformEnvironmentClean = platformEnvironment
38
+ .toLowerCase()
39
+ .trim();
40
+ switch (platformEnvironmentClean) {
41
+ case 'production':
42
+ response = Environment.PRODUCTION;
43
+ break;
44
+ case 'demo':
45
+ case 'preview':
46
+ case 'staging':
47
+ response = Environment.STAGING;
48
+ break;
49
+ default:
50
+ response = Environment.DEVELOPMENT;
51
+ }
52
+ return response;
53
+ };
54
+ exports.getEnvironment = getEnvironment;
55
+ /**
56
+ * Check to see if we are working on AWS Lambda.
57
+ */
58
+ const isAws = () => Platform.AWS === process.env["EMS_PLATFORM"];
59
+ exports.isAws = isAws;
60
+ const isVercel = () => undefined !== process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF;
61
+ exports.isVercel = isVercel;
62
+ /**
63
+ * Some code should only run on the server side to protect the data.
64
+ */
65
+ exports.isServer = typeof window === 'undefined';
66
+ /**
67
+ * Check the environment currently running.
68
+ */
69
+ const isDevelopment = () => Environment.DEVELOPMENT === (0, exports.getEnvironment)();
70
+ exports.isDevelopment = isDevelopment;
71
+ const isStaging = () => Environment.STAGING === (0, exports.getEnvironment)();
72
+ exports.isStaging = isStaging;
73
+ const isProduction = () => Environment.PRODUCTION === (0, exports.getEnvironment)();
74
+ exports.isProduction = isProduction;
75
+ /**
76
+ * Check to see if we are developing locally or on the hosted platform.
77
+ */
78
+ const isLocalhost = () => {
79
+ let response = false;
80
+ if ("true" === process.env["IS_LOCAL"]) {
81
+ response = true;
82
+ }
83
+ else if ((0, exports.isAws)()) {
84
+ response = "true" === process.env["AWS_SAM_LOCAL"];
85
+ }
86
+ else if ((0, exports.isVercel)()) {
87
+ // This value needs to only be included in Vercel but undefined in locally
88
+ response = undefined === process.env["NEXT_PUBLIC_VERCEL_GIT_REPO_ID"];
89
+ }
90
+ return response;
91
+ };
92
+ exports.isLocalhost = isLocalhost;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Map the Age Group and return the user-friendly string.
3
+ */
4
+ export declare const getAgeGroup: (input: number) => string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAgeGroup = void 0;
4
+ const _1 = require("./");
5
+ /**
6
+ * Map the Age Group and return the user-friendly string.
7
+ */
8
+ const getAgeGroup = (input) => {
9
+ const matches = _1.ageGroups.filter(group => group.id === input);
10
+ if (1 === matches.length) {
11
+ return matches[0].name;
12
+ }
13
+ return "Undefined";
14
+ };
15
+ exports.getAgeGroup = getAgeGroup;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Make the request to Eskimi API using the access token.
3
+ */
4
+ export declare const getData: (accessToken: string, data: object, url: string) => Promise<any>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getData = void 0;
4
+ const axios_1 = require("../axios");
5
+ /**
6
+ * Make the request to Eskimi API using the access token.
7
+ */
8
+ const getData = async (accessToken, data, url) => {
9
+ const response = await (0, axios_1.post)(url, data, {
10
+ headers: {
11
+ Authorization: `Bearer ${accessToken}`,
12
+ "Content-Type": "application/json",
13
+ },
14
+ });
15
+ return response.getBodyDefaultTo(["data"], null);
16
+ };
17
+ exports.getData = getData;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Map the Devices and return the user-friendly string.
3
+ */
4
+ export declare const getDevice: (input: number) => string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDevice = void 0;
4
+ const _1 = require("./");
5
+ /**
6
+ * Map the Devices and return the user-friendly string.
7
+ */
8
+ const getDevice = (input) => {
9
+ const matches = _1.devices.filter(device => device.id === input);
10
+ if (1 === matches.length) {
11
+ return matches[0].name;
12
+ }
13
+ return "Undefined";
14
+ };
15
+ exports.getDevice = getDevice;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Map the Gender and return the user-friendly string.
3
+ */
4
+ export declare const getGender: (input: number) => string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGender = void 0;
4
+ const _1 = require("./");
5
+ /**
6
+ * Map the Gender and return the user-friendly string.
7
+ */
8
+ const getGender = (input) => {
9
+ const matches = _1.genders.filter(gender => gender.id === input);
10
+ if (1 === matches.length) {
11
+ return matches[0].name;
12
+ }
13
+ return "Undefined";
14
+ };
15
+ exports.getGender = getGender;
@@ -0,0 +1,49 @@
1
+ import { z } from "zod/v4";
2
+ /**
3
+ * https://dsp-api.eskimi.com/docs/api/v1/#api-Report-GetCampaignReportByAgeGroups
4
+ */
5
+ export declare const endpoints: {
6
+ campaign: {
7
+ age: string;
8
+ gender: string;
9
+ list: string;
10
+ performance: string;
11
+ video: string;
12
+ };
13
+ site: {
14
+ list: string;
15
+ };
16
+ };
17
+ declare const campaignSchema: z.ZodObject<{
18
+ id: z.ZodNumber;
19
+ name: z.ZodString;
20
+ type: z.ZodNumber;
21
+ user_id: z.ZodNumber;
22
+ ad_domain: z.ZodString;
23
+ click_url: z.ZodString;
24
+ bid: z.ZodString;
25
+ budget: z.ZodAny;
26
+ dates: z.ZodAny;
27
+ creative_set_ids: z.ZodAny;
28
+ audience_ids: z.ZodAny;
29
+ ad_placement_type_ids: z.ZodAny;
30
+ ad_placement_position_ids: z.ZodAny;
31
+ operator_ids: z.ZodAny;
32
+ devices: z.ZodAny;
33
+ auto_start: z.ZodNumber;
34
+ created_at: z.ZodString;
35
+ }, z.core.$strip>;
36
+ export type CampaignSchemaType = z.infer<typeof campaignSchema>;
37
+ export declare const ageGroups: {
38
+ id: number;
39
+ name: string;
40
+ }[];
41
+ export declare const devices: {
42
+ id: number;
43
+ name: string;
44
+ }[];
45
+ export declare const genders: {
46
+ id: number;
47
+ name: string;
48
+ }[];
49
+ export {};