corebasic 1.0.211 → 1.0.213

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 (167) hide show
  1. package/dist/index.js +10 -0
  2. package/dist/libs/ObjectId.js +114 -0
  3. package/dist/libs/auth.js +103 -0
  4. package/dist/libs/compression.js +11 -0
  5. package/dist/libs/cpp.js +154 -0
  6. package/dist/libs/dip/suffix/date.js +89 -0
  7. package/dist/libs/dip/suffix/index.js +227 -0
  8. package/dist/libs/dip/suffix/policy.js +113 -0
  9. package/dist/libs/dip/suffix/query.js +279 -0
  10. package/dist/libs/dip/suffix/suffix.js +99 -0
  11. package/dist/libs/dip/suffix/tests/date.test.js +187 -0
  12. package/dist/libs/dip/suffix/tests/index.test.js +441 -0
  13. package/dist/libs/dip/suffix/tests/policy.applySuffixPolicy.test.js +489 -0
  14. package/dist/libs/dip/suffix/tests/policy.test.js +329 -0
  15. package/dist/libs/dip/suffix/tests/suffix.test.js +316 -0
  16. package/dist/libs/dip.js +102 -0
  17. package/dist/libs/dipper.js +73 -0
  18. package/dist/libs/elabase.js +656 -0
  19. package/dist/libs/features.js +366 -0
  20. package/dist/libs/kafka.js +121 -0
  21. package/dist/libs/messaging.js +130 -0
  22. package/dist/libs/mobilecodes.js +562 -0
  23. package/dist/libs/session.js +96 -0
  24. package/dist/libs/utils.js +297 -0
  25. package/index.ts +23 -0
  26. package/libs/{auth.js → auth.ts} +3 -3
  27. package/libs/{compression.js → compression.ts} +1 -1
  28. package/libs/dip/suffix/date.ts +121 -0
  29. package/libs/dip/suffix/{index.js → index.ts} +7 -18
  30. package/libs/dip/suffix/{policy.js → policy.ts} +2 -2
  31. package/libs/dip/suffix/{suffix.js → suffix.ts} +2 -2
  32. package/libs/dip/suffix/tests/{date.test.js → date.test.ts} +1 -1
  33. package/libs/dip/suffix/tests/{index.test.js → index.test.ts} +1 -1
  34. package/libs/dip/suffix/tests/{policy.applySuffixPolicy.test.js → policy.applySuffixPolicy.test.ts} +1 -1
  35. package/libs/dip/suffix/tests/{policy.test.js → policy.test.ts} +1 -1
  36. package/libs/dip/suffix/tests/{suffix.test.js → suffix.test.ts} +1 -1
  37. package/libs/{dip.js → dip.ts} +1 -1
  38. package/libs/{elabase.js → elabase.ts} +4 -4
  39. package/libs/{features.js → features.ts} +5 -5
  40. package/libs/{messaging.js → messaging.ts} +1 -1
  41. package/libs/{session.js → session.ts} +2 -2
  42. package/libs/{utils.js → utils.ts} +80 -9
  43. package/package.json +3 -2
  44. package/tsc/@typescript/typescript-linux-x64/LICENSE +55 -0
  45. package/tsc/@typescript/typescript-linux-x64/NOTICE.txt +436 -0
  46. package/tsc/@typescript/typescript-linux-x64/README.md +3 -0
  47. package/tsc/@typescript/typescript-linux-x64/lib/lib.d.ts +20 -0
  48. package/tsc/@typescript/typescript-linux-x64/lib/lib.decorators.d.ts +382 -0
  49. package/tsc/@typescript/typescript-linux-x64/lib/lib.decorators.legacy.d.ts +20 -0
  50. package/tsc/@typescript/typescript-linux-x64/lib/lib.dom.asynciterable.d.ts +18 -0
  51. package/tsc/@typescript/typescript-linux-x64/lib/lib.dom.d.ts +45125 -0
  52. package/tsc/@typescript/typescript-linux-x64/lib/lib.dom.iterable.d.ts +18 -0
  53. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.collection.d.ts +159 -0
  54. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.core.d.ts +595 -0
  55. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.d.ts +26 -0
  56. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.generator.d.ts +75 -0
  57. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.iterable.d.ts +603 -0
  58. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.promise.d.ts +79 -0
  59. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.proxy.d.ts +126 -0
  60. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.reflect.d.ts +142 -0
  61. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.symbol.d.ts +44 -0
  62. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2015.symbol.wellknown.d.ts +324 -0
  63. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2016.array.include.d.ts +114 -0
  64. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2016.d.ts +19 -0
  65. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2016.full.d.ts +21 -0
  66. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2016.intl.d.ts +29 -0
  67. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.arraybuffer.d.ts +19 -0
  68. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.d.ts +24 -0
  69. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.date.d.ts +29 -0
  70. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.full.d.ts +21 -0
  71. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.intl.d.ts +42 -0
  72. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.object.d.ts +47 -0
  73. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.sharedmemory.d.ts +133 -0
  74. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.string.d.ts +47 -0
  75. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2017.typedarrays.d.ts +51 -0
  76. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2018.asyncgenerator.d.ts +75 -0
  77. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2018.asynciterable.d.ts +51 -0
  78. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2018.d.ts +22 -0
  79. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2018.full.d.ts +22 -0
  80. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2018.intl.d.ts +81 -0
  81. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2018.promise.d.ts +28 -0
  82. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2018.regexp.d.ts +35 -0
  83. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2019.array.d.ts +77 -0
  84. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2019.d.ts +22 -0
  85. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2019.full.d.ts +22 -0
  86. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2019.intl.d.ts +21 -0
  87. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2019.object.d.ts +31 -0
  88. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2019.string.d.ts +35 -0
  89. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2019.symbol.d.ts +22 -0
  90. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.bigint.d.ts +763 -0
  91. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.d.ts +25 -0
  92. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.date.d.ts +40 -0
  93. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.full.d.ts +22 -0
  94. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.intl.d.ts +472 -0
  95. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.number.d.ts +26 -0
  96. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.promise.d.ts +45 -0
  97. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.sharedmemory.d.ts +97 -0
  98. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.string.d.ts +42 -0
  99. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2020.symbol.wellknown.d.ts +39 -0
  100. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2021.d.ts +21 -0
  101. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2021.full.d.ts +22 -0
  102. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2021.intl.d.ts +164 -0
  103. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2021.promise.d.ts +46 -0
  104. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2021.string.d.ts +31 -0
  105. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2021.weakref.d.ts +76 -0
  106. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2022.array.d.ts +119 -0
  107. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2022.d.ts +23 -0
  108. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2022.error.d.ts +73 -0
  109. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2022.full.d.ts +22 -0
  110. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2022.intl.d.ts +143 -0
  111. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2022.object.d.ts +24 -0
  112. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2022.regexp.d.ts +37 -0
  113. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2022.string.d.ts +23 -0
  114. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2023.array.d.ts +922 -0
  115. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2023.collection.d.ts +19 -0
  116. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2023.d.ts +20 -0
  117. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2023.full.d.ts +22 -0
  118. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2023.intl.d.ts +62 -0
  119. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.arraybuffer.d.ts +63 -0
  120. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.collection.d.ts +27 -0
  121. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.d.ts +24 -0
  122. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.full.d.ts +22 -0
  123. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.object.d.ts +27 -0
  124. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.promise.d.ts +33 -0
  125. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.regexp.d.ts +23 -0
  126. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.sharedmemory.d.ts +66 -0
  127. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2024.string.d.ts +27 -0
  128. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2025.collection.d.ts +94 -0
  129. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2025.d.ts +23 -0
  130. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2025.float16.d.ts +443 -0
  131. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2025.full.d.ts +22 -0
  132. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2025.intl.d.ts +200 -0
  133. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2025.iterator.d.ts +146 -0
  134. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2025.promise.d.ts +32 -0
  135. package/tsc/@typescript/typescript-linux-x64/lib/lib.es2025.regexp.d.ts +30 -0
  136. package/tsc/@typescript/typescript-linux-x64/lib/lib.es5.d.ts +4599 -0
  137. package/tsc/@typescript/typescript-linux-x64/lib/lib.es6.d.ts +21 -0
  138. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.array.d.ts +33 -0
  139. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.collection.d.ts +47 -0
  140. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.d.ts +27 -0
  141. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.date.d.ts +21 -0
  142. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.decorators.d.ts +26 -0
  143. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.disposable.d.ts +191 -0
  144. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.error.d.ts +22 -0
  145. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.full.d.ts +22 -0
  146. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.intl.d.ts +107 -0
  147. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.sharedmemory.d.ts +23 -0
  148. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.temporal.d.ts +485 -0
  149. package/tsc/@typescript/typescript-linux-x64/lib/lib.esnext.typedarrays.d.ts +90 -0
  150. package/tsc/@typescript/typescript-linux-x64/lib/lib.scripthost.d.ts +320 -0
  151. package/tsc/@typescript/typescript-linux-x64/lib/lib.webworker.asynciterable.d.ts +18 -0
  152. package/tsc/@typescript/typescript-linux-x64/lib/lib.webworker.d.ts +15606 -0
  153. package/tsc/@typescript/typescript-linux-x64/lib/lib.webworker.importscripts.d.ts +21 -0
  154. package/tsc/@typescript/typescript-linux-x64/lib/lib.webworker.iterable.d.ts +18 -0
  155. package/tsc/@typescript/typescript-linux-x64/lib/tsc +0 -0
  156. package/tsc/@typescript/typescript-linux-x64/lib/tsc.sig +11 -0
  157. package/tsc/@typescript/typescript-linux-x64/package.json +45 -0
  158. package/tsc/notes +14 -0
  159. package/tsconfig.json +48 -0
  160. package/index.js +0 -23
  161. package/libs/dip/suffix/date.js +0 -103
  162. /package/libs/{ObjectId.js → ObjectId.ts} +0 -0
  163. /package/libs/{cpp.js → cpp.ts} +0 -0
  164. /package/libs/dip/suffix/{query.js → query.ts} +0 -0
  165. /package/libs/{dipper.js → dipper.ts} +0 -0
  166. /package/libs/{kafka.js → kafka.ts} +0 -0
  167. /package/libs/{mobilecodes.js → mobilecodes.ts} +0 -0
@@ -0,0 +1,297 @@
1
+ import * as ObjectId from './ObjectId.js';
2
+ import * as Mobile from './mobilecodes.js';
3
+ // Parse JSON file: fileToJson
4
+ import { readFile, writeFile } from 'fs/promises';
5
+ import 'jsonminify';
6
+ // S3 Object Storage
7
+ import { S3Client, ListBucketsCommand, ListObjectsV2Command, GetObjectCommand, PutObjectCommand, CreateBucketCommand, DeleteObjectCommand } from '@aws-sdk/client-s3';
8
+ import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
9
+ let bucketName = process.env.APP_DEPLOYMENT_NAME ?? ((global?.app?.name ?? "app") + '-dev');
10
+ let _ = (async () => { try {
11
+ const data = await S3.send(new CreateBucketCommand({ Bucket: bucketName }));
12
+ }
13
+ catch { } })(); // Create Bucket
14
+ export let pipeline = { execute: execute };
15
+ export function log(...args) {
16
+ let res = [];
17
+ args.forEach(arg => res.push(typeof arg === "object" ? JSON.stringify(arg, null, '\t') : arg));
18
+ console.log(...res);
19
+ }
20
+ export function uid() {
21
+ return ObjectId.ObjectId();
22
+ }
23
+ export function isEmpty(str) {
24
+ if (!str)
25
+ return true;
26
+ return str.match(/\S/) ? false : true; // matches a non space character
27
+ }
28
+ export let GLOBAL_META = { company: "GLOBAL", outlet: "GLOBAL" };
29
+ export function isEmptyJson(json) {
30
+ for (var i in json)
31
+ return false;
32
+ return true;
33
+ }
34
+ export function uniqueObjects(array, key) {
35
+ // remove duplicates from array of objects with key
36
+ return [
37
+ ...new Map(array.map(item => [item[key], item])).values()
38
+ ];
39
+ }
40
+ // --------------
41
+ // Parse Numbers
42
+ // --------------
43
+ export function parseFloatValue(val) {
44
+ return parseFloat(val) ? parseFloat(val) : 0;
45
+ }
46
+ export function parseIntValue(val) {
47
+ return parseInt(val) ? parseInt(val) : 0;
48
+ }
49
+ // ----------------
50
+ // Dates
51
+ // ----------------
52
+ export function now() {
53
+ return new Date();
54
+ }
55
+ export function toAppDate(date) {
56
+ if (Object.prototype.toString.call(date) === '[object String]')
57
+ date = new Date(date);
58
+ var temp = date;
59
+ if (isNaN(temp) || date === '')
60
+ return '';
61
+ var day = temp.getDate().toString();
62
+ if (day.length === 1)
63
+ day = "0" + day;
64
+ var month = (temp.getMonth() + 1).toString();
65
+ if (month.length == 1)
66
+ month = "0" + month;
67
+ return (day + "/" + month + "/" + temp.getFullYear().toString());
68
+ }
69
+ export function toDate(arg, currentTime) {
70
+ var st = arg.split('/');
71
+ var temp = new Date(st[2], parseInt(st[1]) - 1, st[0]);
72
+ temp.setHours(0);
73
+ temp.setMinutes(0);
74
+ temp.setSeconds(0);
75
+ temp.setMilliseconds(0);
76
+ if (currentTime) {
77
+ var curdate = getCurrentDate();
78
+ temp.setHours(curdate.getHours());
79
+ temp.setMinutes(curdate.getMinutes());
80
+ temp.setSeconds(curdate.getSeconds());
81
+ temp.setMilliseconds(curdate.getMilliseconds());
82
+ }
83
+ if (isNaN(temp))
84
+ return undefined;
85
+ return temp;
86
+ }
87
+ export function getDatesBetweenTwoDates(start, end) {
88
+ var arr = [];
89
+ var dt = new Date(start);
90
+ dt.setHours(0);
91
+ dt.setMinutes(0);
92
+ dt.setSeconds(0);
93
+ dt.setMilliseconds(0);
94
+ while (dt <= end) {
95
+ arr.push(new Date(dt));
96
+ dt.setDate(dt.getDate() + 1);
97
+ }
98
+ return arr;
99
+ }
100
+ export function deepCopy(obj) {
101
+ if (Object.prototype.toString.call(obj) === '[object Array]') {
102
+ var out = [], i = 0, len = obj.length;
103
+ for (; i < len; i++) {
104
+ if (Object.prototype.toString.call(obj[i]) === '[object Date]')
105
+ out[i] = new Date(obj[i]);
106
+ else
107
+ out[i] = arguments.callee(obj[i]);
108
+ }
109
+ return out;
110
+ }
111
+ if (typeof obj === 'object') {
112
+ var out = {}, i;
113
+ for (i in obj) {
114
+ if (Object.prototype.toString.call(obj[i]) === '[object Date]')
115
+ out[i] = new Date(obj[i]);
116
+ else
117
+ out[i] = arguments.callee(obj[i]);
118
+ }
119
+ return out;
120
+ }
121
+ return obj;
122
+ }
123
+ export function formatAMPM(date) {
124
+ var hours = date.getHours();
125
+ var minutes = date.getMinutes();
126
+ var ampm = hours >= 12 ? 'pm' : 'am';
127
+ hours = hours % 12;
128
+ hours = hours ? hours : 12; // the hour '0' should be '12'
129
+ minutes = minutes < 10 ? '0' + minutes : minutes;
130
+ var strTime = hours + ':' + minutes + ' ' + ampm;
131
+ return strTime;
132
+ }
133
+ export function sum(array) {
134
+ var res = 0;
135
+ for (var i in array)
136
+ res += parseFloat(array[i]) ? parseFloat(array[i]) : 0;
137
+ return res;
138
+ }
139
+ export function addMonths(date, monthsToAdd) {
140
+ const day = date.getDate();
141
+ date.setMonth(date.getMonth() + monthsToAdd);
142
+ // If the day rolled over, clamp to last day of target month
143
+ if (date.getDate() !== day) {
144
+ date.setDate(0);
145
+ }
146
+ return date;
147
+ }
148
+ export function addYears(date, yearsToAdd) {
149
+ return addMonths(date, yearsToAdd * 12);
150
+ }
151
+ export function addUTCMonths(date, monthsToAdd) {
152
+ const day = date.getUTCDate();
153
+ date.setUTCMonth(date.getUTCMonth() + monthsToAdd);
154
+ // If the day rolled over, clamp to last day of target month
155
+ if (date.getUTCDate() !== day) {
156
+ date.setUTCDate(0);
157
+ }
158
+ return date;
159
+ }
160
+ export function addUTCYears(date, yearsToAdd) {
161
+ return addUTCMonths(date, yearsToAdd * 12);
162
+ }
163
+ export function addDays(date, daysToAdd) {
164
+ date.setDate(date.getDate() + daysToAdd);
165
+ return date;
166
+ }
167
+ export function addHours(date, hoursToAdd) {
168
+ date.setHours(date.getHours() + hoursToAdd);
169
+ return date;
170
+ }
171
+ export function addUTCDays(date, daysToAdd) {
172
+ date.setUTCDate(date.getUTCDate() + daysToAdd);
173
+ return date;
174
+ }
175
+ export function addUTCHours(date, hoursToAdd) {
176
+ date.setUTCHours(date.getUTCHours() + hoursToAdd);
177
+ return date;
178
+ }
179
+ export function validityToMillisecs(start, validity) {
180
+ const now = new Date(start);
181
+ let [count, period] = validity.trim().split(' ').filter(item => item.trim());
182
+ count = parseIntValue(count);
183
+ period = period.toLowerCase();
184
+ const timeline = {
185
+ year: _ => addYears(now, count),
186
+ years: _ => addYears(now, count),
187
+ month: _ => addMonths(now, count),
188
+ months: _ => addMonths(now, count),
189
+ day: _ => now.setDate(now.getDate() + count),
190
+ days: _ => now.setDate(now.getDate() + count),
191
+ week: _ => now.setDate(now.getDate() + (count * 7)),
192
+ weeks: _ => now.setDate(now.getDate() + (count * 7)),
193
+ hour: _ => now.setHours(now.getHours() + count),
194
+ hours: _ => now.setHours(now.getHours() + count),
195
+ minute: _ => now.setMinutes(now.getMinutes() + count),
196
+ minutes: _ => now.setMinutes(now.getMinutes() + count),
197
+ };
198
+ timeline[period]();
199
+ return now.getTime();
200
+ }
201
+ export function validityToUTCMillisecs(start, validity) {
202
+ const now = new Date(start);
203
+ let [count, period] = validity.trim().split(' ').filter(item => item.trim());
204
+ count = parseIntValue(count);
205
+ period = period.toLowerCase();
206
+ const timeline = {
207
+ year: _ => addUTCYears(now, count),
208
+ years: _ => addUTCYears(now, count),
209
+ month: _ => addUTCMonths(now, count),
210
+ months: _ => addUTCMonths(now, count),
211
+ day: _ => now.setUTCDate(now.getUTCDate() + count),
212
+ days: _ => now.setUTCDate(now.getUTCDate() + count),
213
+ week: _ => now.setUTCDate(now.getUTCDate() + (count * 7)),
214
+ weeks: _ => now.setUTCDate(now.getUTCDate() + (count * 7)),
215
+ hour: _ => now.setUTCHours(now.getUTCHours() + count),
216
+ hours: _ => now.setUTCHours(now.getUTCHours() + count),
217
+ minute: _ => now.setUTCMinutes(now.getUTCMinutes() + count),
218
+ minutes: _ => now.setUTCMinutes(now.getUTCMinutes() + count),
219
+ };
220
+ timeline[period]();
221
+ return now.getTime();
222
+ }
223
+ // ----------------
224
+ // JSON
225
+ // ----------------
226
+ export async function fileToJson(path, file) {
227
+ let data = (await readFile(new URL(file, path).toString().replace('file://', ''), 'utf8'));
228
+ return JSON.parse(JSON.minify(data));
229
+ }
230
+ // ----------------
231
+ // File
232
+ // ----------------
233
+ export async function fileToString(file) {
234
+ return await readFile(file, 'utf8');
235
+ }
236
+ export async function stringToFile(file, data) {
237
+ return await writeFile(file, data);
238
+ }
239
+ // ----------------
240
+ // Pipeline Execute
241
+ // ----------------
242
+ function execute(pipeline, errfn) {
243
+ startPipeline(pipeline, 0, undefined, errfn);
244
+ }
245
+ function startPipeline(pipeline, index, data, errfn) {
246
+ index = index == undefined ? 0 : index;
247
+ if (index == pipeline.length)
248
+ return;
249
+ pipeline[index](data).then(data => startPipeline(pipeline, index + 1, data)).catch(err => { if (errfn)
250
+ errfn(err); });
251
+ }
252
+ // -----------------
253
+ // S3 Object Storage
254
+ // -----------------
255
+ export async function getUrl(path, expiry = 3600) {
256
+ return await getSignedUrl(S3, new GetObjectCommand({ Bucket: bucketName, Key: path }), { expiresIn: expiry });
257
+ }
258
+ export async function putUrl(path, expiry = 3600) {
259
+ return await getSignedUrl(S3, new PutObjectCommand({ Bucket: bucketName, Key: path }), { expiresIn: expiry });
260
+ }
261
+ // ---------------------------
262
+ // Express Middleware Exclude
263
+ // ---------------------------
264
+ export const excludeMiddleware = function (middleware, ...paths) {
265
+ return function (req, res, next) {
266
+ const pathCheck = paths.some(path => {
267
+ let url = req.path.split('/');
268
+ let cmp = path.split('/');
269
+ if (url.length !== cmp.length)
270
+ return false;
271
+ let f = cmp.map((p, index) => p.startsWith(":") ? url[index] : p).join('/');
272
+ return f === req.path;
273
+ });
274
+ pathCheck ? next() : middleware(req, res, next);
275
+ };
276
+ };
277
+ // --------------------
278
+ // Parse Mobile Number
279
+ // --------------------
280
+ export function parseMob(mob, code) {
281
+ code = code ?? "IN";
282
+ if (isEmpty(mob))
283
+ return mob;
284
+ if (mob.startsWith("MOB_"))
285
+ return mob;
286
+ mob = mob.trim().replace(/(,| |-|\+)/g, ''); // remove comma, space, hyphen and plus
287
+ mob = mob.startsWith("0") ? mob.replace(/^0*/, '') : mob; // remove starting n zeroes
288
+ let prefix = Mobile.codes[code].phone;
289
+ if (!mob.startsWith(prefix)) {
290
+ mob = `${prefix}${mob}`;
291
+ }
292
+ else { // mob.startsWith(prefix)
293
+ if (mob.length < Mobile.codes[code].phoneLength + prefix.length) // mob just happens to start with prefix
294
+ mob = `${prefix}${mob}`;
295
+ }
296
+ return mob;
297
+ }
package/index.ts ADDED
@@ -0,0 +1,23 @@
1
+
2
+
3
+ import * as Elabase from './libs/elabase.ts'
4
+ import * as Dip from './libs/dip.ts'
5
+ import * as Kafka from './libs/kafka.ts'
6
+ import * as Utils from './libs/utils.ts'
7
+ import * as Session from './libs/session.ts'
8
+ import * as Auth from './libs/auth.ts'
9
+ import * as Features from './libs/features.ts'
10
+ import * as Messaging from './libs/messaging.ts'
11
+ import * as Compression from './libs/compression.ts'
12
+
13
+ export {
14
+ Elabase,
15
+ Dip,
16
+ Kafka,
17
+ Utils,
18
+ Session,
19
+ Auth,
20
+ Features,
21
+ Messaging,
22
+ Compression
23
+ }
@@ -1,9 +1,9 @@
1
1
  import axios from 'axios'
2
2
  import otpGenerator from 'otp-generator'
3
3
 
4
- import * as Dip from './dip.js'
5
- import * as Utils from './utils.js'
6
- import * as Session from './session.js'
4
+ import * as Dip from './dip.ts'
5
+ import * as Utils from './utils.ts'
6
+ import * as Session from './session.ts'
7
7
 
8
8
  let validateFn, validateErrMessage
9
9
  export const validate = (callback, errMessage) => {
@@ -1,4 +1,4 @@
1
- import * as Utils from './utils.js'
1
+ import * as Utils from './utils.ts'
2
2
  import compression from 'compression'
3
3
 
4
4
  // Compression Notes
@@ -0,0 +1,121 @@
1
+ import {getNormalizedBounds} from './index.ts'
2
+ import {addUTCYears, addUTCMonths, addUTCDays} from '../../utils.ts'
3
+
4
+
5
+ const MONTH_SHORT = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
6
+ const MONTH_LONG = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
7
+
8
+
9
+ export function formatDate(value, format) {
10
+
11
+ const dateObj = value instanceof Date ? value : new Date(value)
12
+
13
+ if (Number.isNaN(dateObj.getTime()))
14
+ throw new Error(`Error: Invalid date: ${value} in suffix policy specified for key in Dip`)
15
+
16
+
17
+ const utcMs = dateObj.getTime();
18
+
19
+
20
+ // Constant millisecond values for the extreme timezone edges
21
+ const TWELVE_HOURS_MS = 43200000; // 12 * 60 * 60 * 1000
22
+ const FOURTEEN_HOURS_MS = 50400000; // 14 * 60 * 60 * 1000
23
+
24
+ // Create dates for the absolute furthest west, UTC, and furthest east
25
+ const dWest = new Date(utcMs - TWELVE_HOURS_MS);
26
+ const dEast = new Date(utcMs + FOURTEEN_HOURS_MS);
27
+
28
+ // Extract individual components using UTC methods
29
+ const y1 = dWest.getUTCFullYear(), m1 = dWest.getUTCMonth(), d1 = dWest.getUTCDate();
30
+ const y2 = dateObj.getUTCFullYear(), m2 = dateObj.getUTCMonth(), d2 = dateObj.getUTCDate();
31
+ const y3 = dEast.getUTCFullYear(), m3 = dEast.getUTCMonth(), d3 = dEast.getUTCDate();
32
+
33
+ // Fast, loop-free deduplication using inline conditions
34
+ const years = [y1];
35
+ if (y2 !== y1) years.push(y2);
36
+ if (y3 !== y2 && y3 !== y1) years.push(y3);
37
+
38
+ const months = [m1];
39
+ if (m2 !== m1) months.push(m2);
40
+ if (m3 !== m2 && m3 !== m1) months.push(m3);
41
+
42
+ const dates = [d1];
43
+ if (d2 !== d1) dates.push(d2);
44
+ if (d3 !== d2 && d3 !== d1) dates.push(d3);
45
+
46
+
47
+
48
+ // years and months and dates are already deduplicated
49
+
50
+ const separator = '|'
51
+
52
+ const replacements = {
53
+ YYYY: _ => years.join(separator),
54
+ YY: _ => years.map(y => String(y).slice(-2)).join(separator),
55
+ MMMM: _ => months.map(m => MONTH_LONG[m]).join(separator),
56
+ MMM: _ => months.map(m => MONTH_SHORT[m]).join(separator),
57
+ MM: _ => months.map(m => String(m + 1).padStart(2, "0")).join(separator),
58
+ DD: _ => dates.map(d => String(d).padStart(2, "0")).join(separator),
59
+ D: _ => dates.join(separator),
60
+ };
61
+
62
+ return format.replace(/YYYY|MMMM|MMM|YY|MM|DD|D/g, token => replacements[token]());
63
+ }
64
+
65
+
66
+ // 📋 Supported Formats
67
+ // YYYY: 4-digit year (e.g., 2026)
68
+ // YY: 2-digit year (e.g., 26)
69
+ // MMMM: Full month name (e.g., July)
70
+ // MMM: Short month name (e.g., Jul)
71
+ // MM: 2-digit padded month (e.g., 07)
72
+ // DD: 2-digit padded day (e.g., 09)
73
+ // D: Unpadded day (e.g., 9)
74
+
75
+
76
+
77
+ // // let a = new Date()
78
+ // // let a = "2026-11-1"
79
+ // let a = new Date().getTime()
80
+ // let b = formatDate(a, "YYYY/DD-MMMM")
81
+ // console.log(b)
82
+ //
83
+
84
+
85
+
86
+ export function fillDates(bounds_t, format) {
87
+ const result = [];
88
+
89
+ let step;
90
+ if (format.includes("D"))
91
+ step = "day";
92
+ else if (format.includes("M"))
93
+ step = "month";
94
+ else
95
+ step = "year";
96
+
97
+ let bounds = { ...bounds_t, from: new Date(bounds_t.from), to: new Date(bounds_t.to) }
98
+
99
+ bounds = getNormalizedBounds(bounds, "date")
100
+
101
+ while (bounds.from <= bounds.to) {
102
+ result.push(formatDate(bounds.from, format));
103
+
104
+ switch (step) {
105
+ case "day":
106
+ addUTCDays(bounds.from, 1)
107
+ break;
108
+ case "month":
109
+ addUTCMonths(bounds.from, 1)
110
+ break;
111
+ case "year":
112
+ addUTCYears(bounds.from, 1)
113
+ break;
114
+ }
115
+ }
116
+
117
+ return [...new Set(result)];
118
+ }
119
+
120
+
121
+
@@ -203,8 +203,8 @@ export function extractBounds(values) {
203
203
  };
204
204
  }
205
205
 
206
- // Converts exclusive bounds ($gt/$lt) into inclusive bounds. Mutates if date type
207
- export function getNormalizedBounds(bounds_t, type, step) {
206
+ // Converts exclusive bounds ($gt/$lt) into inclusive bounds
207
+ export function getNormalizedBounds(bounds_t, type) {
208
208
  let bounds = {...bounds_t}
209
209
 
210
210
  if (type === "number") {
@@ -213,22 +213,11 @@ export function getNormalizedBounds(bounds_t, type, step) {
213
213
  if (bounds.toOp === "$lt")
214
214
  bounds.to--;
215
215
  } else if (type === "date") {
216
- if (step === "day") {
217
- if (bounds.fromOp === "$gt")
218
- bounds.from.setDate(bounds.from.getDate() + 1);
219
- if (bounds.toOp === "$lt")
220
- bounds.to.setDate(bounds.to.getDate() - 1);
221
- } else if (step === "month") {
222
- if (bounds.fromOp === "$gt")
223
- bounds.from.setMonth(bounds.from.getMonth() + 1);
224
- if (bounds.toOp === "$lt")
225
- bounds.to.setMonth(bounds.to.getMonth() - 1);
226
- } else {
227
- if (bounds.fromOp === "$gt")
228
- bounds.from.setFullYear(bounds.from.getFullYear() + 1);
229
- if (bounds.toOp === "$lt")
230
- bounds.to.setFullYear(bounds.to.getFullYear() - 1);
231
- }
216
+ if (bounds.fromOp === "$gt")
217
+ bounds.from = new Date(bounds.from.getTime() + 1);
218
+
219
+ if (bounds.toOp === "$lt")
220
+ bounds.to = new Date(bounds.to.getTime() - 1);
232
221
  }
233
222
 
234
223
  return bounds
@@ -1,5 +1,5 @@
1
- import {entries, reduceRanges, extractBounds} from './index.js'
2
- import {suffix} from './suffix.js'
1
+ import {entries, reduceRanges, extractBounds} from './index.ts'
2
+ import {suffix} from './suffix.ts'
3
3
 
4
4
 
5
5
 
@@ -1,5 +1,5 @@
1
- import {entries, reduceRanges, extractBounds, getNormalizedBounds} from './index.js'
2
- import {formatDate, fillDates} from './date.js'
1
+ import {entries, reduceRanges, extractBounds, getNormalizedBounds} from './index.ts'
2
+ import {formatDate, fillDates} from './date.ts'
3
3
 
4
4
 
5
5
 
@@ -1,7 +1,7 @@
1
1
  import { describe, test } from "node:test";
2
2
  import assert from "node:assert/strict";
3
3
 
4
- import { formatDate, fillDates } from "../date.js";
4
+ import { formatDate, fillDates } from "../date.ts";
5
5
 
6
6
 
7
7
  describe("formatDate()", () => {
@@ -1,7 +1,7 @@
1
1
  import { describe, test } from "node:test";
2
2
  import assert from "node:assert/strict";
3
3
 
4
- import {reduceRanges, extractBounds} from "../index.js";
4
+ import {reduceRanges, extractBounds} from "../index.ts";
5
5
 
6
6
 
7
7
 
@@ -1,6 +1,6 @@
1
1
  import { describe, test } from "node:test";
2
2
  import assert from "node:assert/strict";
3
- import {applySuffixPolicy} from "../policy.js";
3
+ import {applySuffixPolicy} from "../policy.ts";
4
4
 
5
5
  // -----------------------------------------------------------------------------
6
6
  // applySuffixPolicy()
@@ -1,6 +1,6 @@
1
1
  import { describe, test } from "node:test";
2
2
  import assert from "node:assert/strict";
3
- import {matchPolicy, overlaps, contains, intersects, applySuffixPolicy} from "../policy.js";
3
+ import {matchPolicy, overlaps, contains, intersects, applySuffixPolicy} from "../policy.ts";
4
4
 
5
5
 
6
6
  /* ============================================================
@@ -1,7 +1,7 @@
1
1
  import { describe, test } from "node:test";
2
2
  import assert from "node:assert/strict";
3
3
 
4
- import { suffix } from "../suffix.js";
4
+ import { suffix } from "../suffix.ts";
5
5
 
6
6
 
7
7
  describe("suffix()", () => {
@@ -1,4 +1,4 @@
1
- import * as Elabase from './elabase.js'
1
+ import * as Elabase from './elabase.ts'
2
2
 
3
3
  export const start = Elabase.start
4
4
 
@@ -1,8 +1,8 @@
1
1
  import axios from 'axios'
2
- import {default as dipper, shard_stats as ShardStats} from './dipper.js'
3
- import * as Utils from './utils.js'
4
- import * as Cpp from './cpp.js'
5
- import {applySuffixPolicy} from './dip/suffix/policy.js'
2
+ import {default as dipper, shard_stats as ShardStats} from './dipper.ts'
3
+ import * as Utils from './utils.ts'
4
+ import * as Cpp from './cpp.ts'
5
+ import {applySuffixPolicy} from './dip/suffix/policy.ts'
6
6
 
7
7
 
8
8
 
@@ -1,8 +1,8 @@
1
- import * as Dip from './dip.js'
2
- import * as Kafka from './kafka.js'
3
- import * as Utils from './utils.js'
4
- import * as Session from './session.js'
5
- import * as Messaging from './messaging.js'
1
+ import * as Dip from './dip.ts'
2
+ import * as Kafka from './kafka.ts'
3
+ import * as Utils from './utils.ts'
4
+ import * as Session from './session.ts'
5
+ import * as Messaging from './messaging.ts'
6
6
  import axios from 'axios'
7
7
  import jwt from 'jsonwebtoken'
8
8
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  import axios from 'axios'
3
3
  import { createClient } from 'redis';
4
- import * as Utils from './utils.js'
4
+ import * as Utils from './utils.ts'
5
5
 
6
6
  const url = process.env.REDIS_URL || "redis://localhost:6380"
7
7
 
@@ -1,6 +1,6 @@
1
1
  import jwt from 'jsonwebtoken'
2
- import * as Utils from './utils.js'
3
- import * as Features from './features.js'
2
+ import * as Utils from './utils.ts'
3
+ import * as Features from './features.ts'
4
4
  let app
5
5
 
6
6