corebasic 1.0.227 → 1.0.229

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.
@@ -450,10 +450,11 @@ function execute(arg) {
450
450
  return config.useDipper ? dipper(arg)
451
451
  : axios
452
452
  .post(arg.DIP_URL ?? fullurl, buildHybridRequest({ ...arg, DIP_URL: undefined }), { responseType: 'arraybuffer', timeout: timeout ?? 5000, headers: { "Content-Type": "application/dip" } })
453
- .then(result => {
453
+ .then(dip_result => {
454
454
  // console.log(res.status);
455
455
  // console.log(JSON.stringify(res.header, null, 4));
456
456
  // console.log(JSON.stringify(res.body, null, 4));
457
+ const result = dip_result;
457
458
  result.getSliceAsText = (offset, length) => Cpp.getSliceAsText(result.data, offset, length);
458
459
  result.getSliceAsArrayBuffer = (offset, length) => Cpp.getSliceAsArrayBuffer(result.data, offset, length);
459
460
  result["Content-Type"] = result.headers["content-type"];
@@ -14,7 +14,7 @@ export const start = (arg) => {
14
14
  clientId: appName,
15
15
  brokers: arg?.brokers ?? ['redpanda-0.redpanda.redpanda.svc.cluster.local:9093'], // ['107.155.108.78:9092'] ['127.0.0.1:29092']
16
16
  sasl: arg?.sasl == false ? undefined : {
17
- mechanism: 'SCRAM-SHA-512',
17
+ mechanism: 'scram-sha-512', // earlier 'SCRAM-SHA-512'
18
18
  username: process.env.KAFKA_USERNAME,
19
19
  password: process.env.KAFKA_PASSWORD
20
20
  },
@@ -4,8 +4,7 @@ import crypto from "node:crypto";
4
4
  import { readFile, writeFile } from 'fs/promises';
5
5
  export let pipeline = { execute: execute };
6
6
  export function log(...args) {
7
- let res = [];
8
- args.forEach(arg => res.push(typeof arg === "object" ? JSON.stringify(arg, null, '\t') : arg));
7
+ const res = args.map(arg => typeof arg === "object" ? JSON.stringify(arg, null, '\t') : arg);
9
8
  console.log(...res);
10
9
  }
11
10
  let UID_COUNTER = crypto.randomBytes(3).readUIntBE(0, 3);
@@ -23,7 +22,7 @@ export function uid() {
23
22
  export function isEmpty(str) {
24
23
  if (!str)
25
24
  return true;
26
- return str.match(/\S/) ? false : true; // matches a non space character
25
+ return String(str).match(/\S/) ? false : true; // matches a non space character
27
26
  }
28
27
  export let GLOBAL_META = { company: "GLOBAL", outlet: "GLOBAL" };
29
28
  export function isEmptyJson(json) {
@@ -70,7 +69,12 @@ export function toAppDate(date) {
70
69
  }
71
70
  export function toDate(arg, currentTime) {
72
71
  let st = arg.split('/');
73
- let temp = new Date(parseInt(st[2]), parseInt(st[1]) - 1, parseInt(st[0]));
72
+ if (st.length !== 3)
73
+ throw new Error("Invalid arg in Utils.toDate()");
74
+ const day = st[0];
75
+ const month = st[1];
76
+ const year = st[2];
77
+ let temp = new Date(parseInt(year), parseInt(month) - 1, parseInt(day));
74
78
  temp.setHours(0);
75
79
  temp.setMinutes(0);
76
80
  temp.setSeconds(0);
@@ -99,43 +103,44 @@ export function getDatesBetweenTwoDates(start, end) {
99
103
  }
100
104
  return arr;
101
105
  }
102
- export function deepCopy(obj) {
103
- if (Object.prototype.toString.call(obj) === '[object Array]') {
104
- let out = [], i = 0, len = obj.length;
105
- for (; i < len; i++) {
106
- if (Object.prototype.toString.call(obj[i]) === '[object Date]')
107
- out[i] = new Date(obj[i]);
108
- else
109
- out[i] = arguments.callee(obj[i]);
110
- }
111
- return out;
112
- }
113
- if (typeof obj === 'object') {
114
- let out = {}, i;
115
- for (i in obj) {
116
- if (Object.prototype.toString.call(obj[i]) === '[object Date]')
117
- out[i] = new Date(obj[i]);
118
- else
119
- out[i] = arguments.callee(obj[i]);
120
- }
121
- return out;
122
- }
123
- return obj;
124
- }
106
+ // export function deepCopy(obj) {
107
+ // if (Object.prototype.toString.call(obj) === '[object Array]') {
108
+ // let out = [], i = 0, len = obj.length;
109
+ // for ( ; i < len; i++ ) {
110
+ // if (Object.prototype.toString.call(obj[i]) === '[object Date]')
111
+ // out[i] = new Date(obj[i])
112
+ // else
113
+ // out[i] = arguments.callee(obj[i]);
114
+ // }
115
+ // return out;
116
+ // }
117
+ // if (typeof obj === 'object') {
118
+ // let out = {}, i;
119
+ // for ( i in obj ) {
120
+ // if (Object.prototype.toString.call(obj[i]) === '[object Date]')
121
+ // out[i] = new Date(obj[i])
122
+ // else
123
+ // out[i] = arguments.callee(obj[i]);
124
+ // }
125
+ // return out;
126
+ // }
127
+ // return obj;
128
+ // }
125
129
  export function formatAMPM(date) {
126
130
  let hours = date.getHours();
127
131
  let minutes = date.getMinutes();
128
132
  let ampm = hours >= 12 ? 'pm' : 'am';
129
133
  hours = hours % 12;
130
134
  hours = hours ? hours : 12; // the hour '0' should be '12'
131
- minutes = minutes < 10 ? '0' + minutes : minutes;
132
- let strTime = hours + ':' + minutes + ' ' + ampm;
135
+ let strTime = hours + ':' + (minutes < 10 ? '0' + minutes : minutes) + ' ' + ampm;
133
136
  return strTime;
134
137
  }
135
138
  export function sum(array) {
136
139
  let res = 0;
137
- for (let i in array)
138
- res += parseFloat(array[i]) ? parseFloat(array[i]) : 0;
140
+ for (let i in array) {
141
+ const val = parseFloat(String(array[i] ?? 0));
142
+ res += val ? val : 0;
143
+ }
139
144
  return res;
140
145
  }
141
146
  export function addMonths(date, monthsToAdd) {
@@ -180,9 +185,11 @@ export function addUTCHours(date, hoursToAdd) {
180
185
  }
181
186
  export function validityToMillisecs(start, validity) {
182
187
  const now = new Date(start);
183
- let [count, period] = validity.trim().split(' ').filter(item => item.trim());
184
- count = parseIntValue(count);
185
- period = period.toLowerCase();
188
+ const parts = validity.trim().split(' ').filter(item => item.trim());
189
+ if (parts.length !== 2)
190
+ throw new Error("Invalid validity string in validityToUTCMillisecs()");
191
+ const count = parseIntValue(parts[0]);
192
+ const period = parts[1].toLowerCase();
186
193
  const timeline = {
187
194
  year: () => addYears(now, count),
188
195
  years: () => addYears(now, count),
@@ -202,9 +209,11 @@ export function validityToMillisecs(start, validity) {
202
209
  }
203
210
  export function validityToUTCMillisecs(start, validity) {
204
211
  const now = new Date(start);
205
- let [count, period] = validity.trim().split(' ').filter(item => item.trim());
206
- count = parseIntValue(count);
207
- period = period.toLowerCase();
212
+ const parts = validity.trim().split(' ').filter(item => item.trim());
213
+ if (parts.length !== 2)
214
+ throw new Error("Invalid validity string in validityToUTCMillisecs()");
215
+ const count = parseIntValue(parts[0]);
216
+ const period = parts[1].toLowerCase();
208
217
  const timeline = {
209
218
  year: () => addUTCYears(now, count),
210
219
  years: () => addUTCYears(now, count),
@@ -258,7 +267,7 @@ export async function fileToJson(path, file) {
258
267
  let commaIndex = -1;
259
268
  for (let index = 0; index < jsonString.length; index++) {
260
269
  const currentCharacter = jsonString[index];
261
- const nextCharacter = jsonString[index + 1];
270
+ const nextCharacter = jsonString[index + 1] ?? "";
262
271
  if (!isInsideComment && currentCharacter === '"') {
263
272
  // Enter or exit string
264
273
  const escaped = isEscaped(jsonString, index);
@@ -359,7 +368,8 @@ function startPipeline(pipeline, index, data, errfn) {
359
368
  index = index == undefined ? 0 : index;
360
369
  if (index == pipeline.length)
361
370
  return;
362
- pipeline[index](data).then(data => startPipeline(pipeline, index + 1, data)).catch(err => { if (errfn)
371
+ const item = pipeline[index];
372
+ item(data).then((data) => startPipeline(pipeline, index + 1, data, errfn)).catch((err) => { if (errfn)
363
373
  errfn(err); });
364
374
  }
365
375
  // ---------------------------
package/libs/cpp.ts CHANGED
@@ -180,7 +180,7 @@ export function arrayBufferToString(buffer) {
180
180
 
181
181
 
182
182
  // Matches QString Response::getSliceAsText
183
- export function getSliceAsText(rawTextBuffer, offset, length) {
183
+ export function getSliceAsText(rawTextBuffer, offset: number, length: number): string {
184
184
  // Reuses the identical slice boundary logic from above
185
185
  try {
186
186
  const slice = getSliceAsArrayBuffer(rawTextBuffer, offset, length);
@@ -191,7 +191,7 @@ export function getSliceAsText(rawTextBuffer, offset, length) {
191
191
  }
192
192
 
193
193
  // Matches QByteArray Response::getSliceAsArrayBuffer
194
- export function getSliceAsArrayBuffer(rawTextBuffer, offset, length) {
194
+ export function getSliceAsArrayBuffer(rawTextBuffer, offset: number, length: number): Buffer {
195
195
  const totalSize = rawTextBuffer.length;
196
196
 
197
197
  if (offset < 0 || offset >= totalSize) {
package/libs/elabase.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  // @ts-ignore
2
2
  import axios from 'axios'
3
+ // @ts-ignore
4
+ import type { AxiosResponse } from "axios";
3
5
  import {default as dipper, shard_stats as ShardStats} from './dipper.ts'
4
6
  import * as Utils from './utils.ts'
5
7
  import * as Cpp from './cpp.ts'
@@ -560,13 +562,22 @@ function execute(arg) {
560
562
  return config.useDipper ? dipper(arg)
561
563
  : axios
562
564
  .post(arg.DIP_URL ?? fullurl, buildHybridRequest({...arg, DIP_URL: undefined}), { responseType: 'arraybuffer', timeout: timeout ?? 5000, headers: {"Content-Type": "application/dip"} })
563
- .then(result => {
565
+ .then(dip_result => {
564
566
  // console.log(res.status);
565
567
  // console.log(JSON.stringify(res.header, null, 4));
566
568
  // console.log(JSON.stringify(res.body, null, 4));
567
569
 
568
- result.getSliceAsText = (offset, length) => Cpp.getSliceAsText(result.data, offset, length)
569
- result.getSliceAsArrayBuffer = (offset, length) => Cpp.getSliceAsArrayBuffer(result.data, offset, length)
570
+ type DipResponse = AxiosResponse & {
571
+ body: any;
572
+ getSliceAsText(offset: number, length: number): string;
573
+ getSliceAsArrayBuffer(offset: number, length: number): Buffer;
574
+ "Content-Type"?: string;
575
+ };
576
+
577
+ const result = dip_result as DipResponse
578
+
579
+ result.getSliceAsText = (offset: number, length: number): string => Cpp.getSliceAsText(result.data, offset, length)
580
+ result.getSliceAsArrayBuffer = (offset: number, length: number): Buffer => Cpp.getSliceAsArrayBuffer(result.data, offset, length)
570
581
  result["Content-Type"] = result.headers["content-type"]
571
582
  result.body = result.data
572
583
  if (result.headers["content-type"].includes("application/json"))
package/libs/kafka.ts CHANGED
@@ -18,7 +18,7 @@ export const start = (arg) => {
18
18
  clientId: appName,
19
19
  brokers: arg?.brokers ?? ['redpanda-0.redpanda.redpanda.svc.cluster.local:9093'], // ['107.155.108.78:9092'] ['127.0.0.1:29092']
20
20
  sasl: arg?.sasl == false ? undefined : {
21
- mechanism: 'SCRAM-SHA-512',
21
+ mechanism: 'scram-sha-512', // earlier 'SCRAM-SHA-512'
22
22
  username: process.env.KAFKA_USERNAME,
23
23
  password: process.env.KAFKA_PASSWORD
24
24
  },
package/libs/session.ts CHANGED
@@ -78,7 +78,8 @@ export const start = (expressApp, allowedUrls) => {
78
78
  app.post("/refreshToken", (req, res) => {
79
79
  try {
80
80
  let { userId, clientId, refreshToken } = req.body
81
- const decoded = jwt.verify(refreshToken, REFRESH_TOKEN_SECRET)
81
+ type Decoded = {userId: string, clientId: string}
82
+ const decoded = jwt.verify(refreshToken, REFRESH_TOKEN_SECRET) as Decoded
82
83
  if (decoded.userId === userId && decoded.clientId === clientId) {
83
84
  let now = Utils.now()
84
85
  let _accessTokenExpiry = new Date(now); _accessTokenExpiry.setDate(_accessTokenExpiry.getDate() + 1);
package/libs/utils.ts CHANGED
@@ -6,9 +6,8 @@ import {readFile,writeFile} from 'fs/promises';
6
6
 
7
7
  export let pipeline = { execute: execute }
8
8
 
9
- export function log(...args) {
10
- let res = []
11
- args.forEach(arg => res.push(typeof arg === "object" ? JSON.stringify(arg,null,'\t') : arg))
9
+ export function log(...args: unknown[]): void {
10
+ const res = args.map(arg => typeof arg === "object" ? JSON.stringify(arg, null,'\t') : arg)
12
11
  console.log(...res)
13
12
  }
14
13
 
@@ -32,21 +31,21 @@ export function uid(): string {
32
31
  return buf.toString("hex");
33
32
  }
34
33
 
35
- export function isEmpty(str): boolean { // returns true for undefined
34
+ export function isEmpty(str: undefined | number | string): boolean { // returns true for undefined
36
35
  if(!str)
37
36
  return true
38
- return str.match(/\S/) ? false : true // matches a non space character
37
+ return String(str).match(/\S/) ? false : true // matches a non space character
39
38
  }
40
39
 
41
40
  export let GLOBAL_META = { company: "GLOBAL", outlet: "GLOBAL" }
42
41
 
43
- export function isEmptyJson(json): boolean {
42
+ export function isEmptyJson(json: object): boolean {
44
43
  for (let i in json)
45
44
  return false
46
45
  return true
47
46
  }
48
47
 
49
- export function uniqueObjects(array, key) {
48
+ export function uniqueObjects<T extends Record<string, unknown>>(array: T[], key: keyof T): T[] {
50
49
  // remove duplicates from array of objects with key
51
50
  return [
52
51
  ...new Map(
@@ -99,7 +98,14 @@ export function toDate(arg: string, currentTime?: boolean): Date | undefined { /
99
98
 
100
99
  let st = arg.split('/')
101
100
 
102
- let temp = new Date(parseInt(st[2]), parseInt(st[1]) - 1, parseInt(st[0]));
101
+ if (st.length !== 3)
102
+ throw new Error("Invalid arg in Utils.toDate()")
103
+
104
+ const day = st[0]!
105
+ const month = st[1]!
106
+ const year = st[2]!
107
+
108
+ let temp = new Date(parseInt(year), parseInt(month) - 1, parseInt(day));
103
109
  temp.setHours(0) ; temp.setMinutes(0); temp.setSeconds(0); temp.setMilliseconds(0)
104
110
 
105
111
  if (currentTime) {
@@ -117,7 +123,7 @@ export function toDate(arg: string, currentTime?: boolean): Date | undefined { /
117
123
 
118
124
 
119
125
 
120
- export function getDatesBetweenTwoDates(start, end) {
126
+ export function getDatesBetweenTwoDates(start: number | Date, end: number | Date) {
121
127
  let arr = [];
122
128
  let dt = new Date(start);
123
129
 
@@ -133,45 +139,46 @@ export function getDatesBetweenTwoDates(start, end) {
133
139
  return arr;
134
140
  }
135
141
 
136
- export function deepCopy(obj) {
137
- if (Object.prototype.toString.call(obj) === '[object Array]') {
138
- let out = [], i = 0, len = obj.length;
139
- for ( ; i < len; i++ ) {
140
- if (Object.prototype.toString.call(obj[i]) === '[object Date]')
141
- out[i] = new Date(obj[i])
142
- else
143
- out[i] = arguments.callee(obj[i]);
144
- }
145
- return out;
146
- }
147
- if (typeof obj === 'object') {
148
- let out = {}, i;
149
- for ( i in obj ) {
150
- if (Object.prototype.toString.call(obj[i]) === '[object Date]')
151
- out[i] = new Date(obj[i])
152
- else
153
- out[i] = arguments.callee(obj[i]);
154
- }
155
- return out;
156
- }
157
- return obj;
158
- }
159
-
160
-
161
- export function formatAMPM(date) {
142
+ // export function deepCopy(obj) {
143
+ // if (Object.prototype.toString.call(obj) === '[object Array]') {
144
+ // let out = [], i = 0, len = obj.length;
145
+ // for ( ; i < len; i++ ) {
146
+ // if (Object.prototype.toString.call(obj[i]) === '[object Date]')
147
+ // out[i] = new Date(obj[i])
148
+ // else
149
+ // out[i] = arguments.callee(obj[i]);
150
+ // }
151
+ // return out;
152
+ // }
153
+ // if (typeof obj === 'object') {
154
+ // let out = {}, i;
155
+ // for ( i in obj ) {
156
+ // if (Object.prototype.toString.call(obj[i]) === '[object Date]')
157
+ // out[i] = new Date(obj[i])
158
+ // else
159
+ // out[i] = arguments.callee(obj[i]);
160
+ // }
161
+ // return out;
162
+ // }
163
+ // return obj;
164
+ // }
165
+
166
+
167
+ export function formatAMPM(date: Date): string {
162
168
  let hours = date.getHours();
163
169
  let minutes = date.getMinutes();
164
170
  let ampm = hours >= 12 ? 'pm' : 'am';
165
171
  hours = hours % 12;
166
172
  hours = hours ? hours : 12; // the hour '0' should be '12'
167
- minutes = minutes < 10 ? '0'+minutes : minutes;
168
- let strTime = hours + ':' + minutes + ' ' + ampm;
173
+ let strTime = hours + ':' + (minutes < 10 ? '0'+minutes : minutes) + ' ' + ampm;
169
174
  return strTime;
170
175
  }
171
- export function sum(array) { // Eg: sum([10,20,undefined, NaN, 40])
176
+ export function sum(array: Array<number | string | undefined>) { // Eg: sum([10,20,undefined, NaN, 40])
172
177
  let res = 0
173
- for (let i in array)
174
- res += parseFloat(array[i]) ? parseFloat(array[i]) : 0
178
+ for (let i in array) {
179
+ const val = parseFloat(String(array[i] ?? 0))
180
+ res += val ? val : 0
181
+ }
175
182
  return res;
176
183
  }
177
184
 
@@ -219,12 +226,16 @@ export function addUTCHours(date: Date, hoursToAdd: number): Date {
219
226
  return date
220
227
  }
221
228
 
222
- export function validityToMillisecs(start, validity) { // start is in ms
229
+ export function validityToMillisecs(start: number, validity: string) { // start is in ms
223
230
  const now = new Date(start)
224
231
 
225
- let [count, period] = validity.trim().split(' ').filter(item => item.trim())
226
- count = parseIntValue(count)
227
- period = period.toLowerCase()
232
+ const parts = validity.trim().split(' ').filter(item => item.trim())
233
+
234
+ if (parts.length !== 2)
235
+ throw new Error("Invalid validity string in validityToUTCMillisecs()");
236
+
237
+ const count = parseIntValue(parts[0])
238
+ const period = parts[1]!.toLowerCase()
228
239
 
229
240
  const timeline = {
230
241
  year: () => addYears(now, count),
@@ -241,16 +252,20 @@ export function validityToMillisecs(start, validity) { // start is in ms
241
252
  minutes: () => now.setMinutes(now.getMinutes() + count),
242
253
  }
243
254
 
244
- timeline[period]()
255
+ timeline[period as keyof typeof timeline]()
245
256
 
246
257
  return now.getTime()
247
258
  }
248
- export function validityToUTCMillisecs(start, validity) { // start is in ms
259
+ export function validityToUTCMillisecs(start: number, validity: string) { // start is in ms
249
260
  const now = new Date(start)
250
261
 
251
- let [count, period] = validity.trim().split(' ').filter(item => item.trim())
252
- count = parseIntValue(count)
253
- period = period.toLowerCase()
262
+ const parts = validity.trim().split(' ').filter(item => item.trim())
263
+
264
+ if (parts.length !== 2)
265
+ throw new Error("Invalid validity string in validityToUTCMillisecs()");
266
+
267
+ const count = parseIntValue(parts[0])
268
+ const period = parts[1]!.toLowerCase()
254
269
 
255
270
  const timeline = {
256
271
  year: () => addUTCYears(now, count),
@@ -267,7 +282,7 @@ export function validityToUTCMillisecs(start, validity) { // start is in ms
267
282
  minutes: () => now.setUTCMinutes(now.getUTCMinutes() + count),
268
283
  }
269
284
 
270
- timeline[period]()
285
+ timeline[period as keyof typeof timeline]()
271
286
 
272
287
  return now.getTime()
273
288
  }
@@ -276,7 +291,7 @@ export function validityToUTCMillisecs(start, validity) { // start is in ms
276
291
  // ----------------
277
292
  // JSON
278
293
  // ----------------
279
- export async function fileToJson(path, file) {
294
+ export async function fileToJson(path: string | URL, file: string) {
280
295
  let data = (await readFile(new URL(file, path).toString().replace('file://',''), 'utf8'))
281
296
  // return JSON.parse((JSON as Record<string, any>).minify(data))
282
297
 
@@ -288,9 +303,9 @@ export async function fileToJson(path, file) {
288
303
  const stripWithoutWhitespace = () => '';
289
304
 
290
305
  // Replace all characters except ASCII spaces, tabs and line endings with regular spaces to ensure valid JSON output.
291
- const stripWithWhitespace = (string, start, end?: number) => string.slice(start, end).replace(/[^ \t\r\n]/g, ' ');
306
+ const stripWithWhitespace = (string: string, start: number, end?: number): string => string.slice(start, end).replace(/[^ \t\r\n]/g, ' ');
292
307
 
293
- const isEscaped = (jsonString, quotePosition) => {
308
+ const isEscaped = (jsonString: string, quotePosition: number): boolean => {
294
309
  let index = quotePosition - 1;
295
310
  let backslashCount = 0;
296
311
 
@@ -302,7 +317,7 @@ export async function fileToJson(path, file) {
302
317
  return Boolean(backslashCount % 2);
303
318
  };
304
319
 
305
- function stripJsonComments(jsonString, {whitespace = true, trailingCommas = false} = {}) {
320
+ function stripJsonComments(jsonString: string, {whitespace = true, trailingCommas = false} = {}): string {
306
321
  if (typeof jsonString !== 'string') {
307
322
  throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof jsonString}\``);
308
323
  }
@@ -318,8 +333,8 @@ export async function fileToJson(path, file) {
318
333
  let commaIndex = -1;
319
334
 
320
335
  for (let index = 0; index < jsonString.length; index++) {
321
- const currentCharacter = jsonString[index];
322
- const nextCharacter = jsonString[index + 1];
336
+ const currentCharacter = jsonString[index]!;
337
+ const nextCharacter = jsonString[index + 1] ?? "";
323
338
 
324
339
  if (!isInsideComment && currentCharacter === '"') {
325
340
  // Enter or exit string
@@ -406,10 +421,10 @@ export async function fileToJson(path, file) {
406
421
  // File
407
422
  // ----------------
408
423
 
409
- export async function fileToString(file) {
424
+ export async function fileToString(file: string | URL): Promise<string> {
410
425
  return await readFile(file, 'utf8')
411
426
  }
412
- export async function stringToFile(file, data) {
427
+ export async function stringToFile(file: string, data: string) {
413
428
  return await writeFile(file, data)
414
429
  }
415
430
 
@@ -418,23 +433,25 @@ export async function stringToFile(file, data) {
418
433
  // ----------------
419
434
 
420
435
 
421
- function execute(pipeline, errfn?: Function) {
422
- startPipeline(pipeline, 0, undefined, errfn)
436
+ function execute<T>(pipeline: Array<(data: T) => Promise<T>>, errfn?: (err: unknown) => void) {
437
+ startPipeline(pipeline, 0, undefined as T, errfn)
423
438
  }
424
439
 
425
- function startPipeline(pipeline, index, data, errfn?: Function) {
440
+ function startPipeline<T>(pipeline: Array<(data: T) => Promise<T>>, index: number, data: T, errfn?: (err: unknown) => void) {
426
441
  index = index == undefined ? 0 : index
427
442
  if (index == pipeline.length)
428
443
  return
429
- pipeline[index](data).then(data => startPipeline(pipeline, index + 1, data)).catch(err => { if (errfn) errfn(err) } )
444
+
445
+ const item = pipeline[index]
446
+ item!(data).then((data: T) => startPipeline(pipeline, index + 1, data, errfn)).catch((err: unknown) => { if (errfn) errfn(err) } )
430
447
  }
431
448
 
432
449
 
433
450
  // ---------------------------
434
451
  // Express Middleware Exclude
435
452
  // ---------------------------
436
- export const excludeMiddleware = function(middleware, ...paths) {
437
- return function(req, res, next) {
453
+ export const excludeMiddleware = function(middleware: (...args: unknown[]) => void, ...paths: string[]) {
454
+ return function(req: {path: string}, res: unknown, next: () => void) {
438
455
  const pathCheck = paths.some(path => {
439
456
  let url = req.path.split('/')
440
457
  let cmp = path.split('/')
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.227",
4
+ "version": "1.0.229",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "./index.ts",
package/tsconfig.json CHANGED
@@ -38,7 +38,7 @@
38
38
  // "noPropertyAccessFromIndexSignature": true,
39
39
 
40
40
  // Recommended Options
41
- "strict": false,
41
+ "strict": true,
42
42
  "jsx": "react-jsx",
43
43
  "verbatimModuleSyntax": true,
44
44
  "isolatedModules": true,