corebasic 1.0.219 → 1.0.220

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.
@@ -50,13 +50,13 @@ export function formatDate(value, format) {
50
50
  const separator = '|'
51
51
 
52
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),
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
60
  };
61
61
 
62
62
  return format.replace(/YYYY|MMMM|MMM|YY|MM|DD|D/g, token => replacements[token]());
package/libs/elabase.ts CHANGED
@@ -215,7 +215,7 @@ export function batchSubmit(batch_id, arg) {
215
215
  const port = arg?.port
216
216
  const timeout = arg?.timeout
217
217
  delete batches[batch_id]
218
- return new Promise((resolve, reject) => resolve())
218
+ return new Promise<void>((resolve, reject) => resolve())
219
219
  .then(() => execute({ "batch": txns, version: arg?.version, raw, engine, compression: arg?.compression, executor, syncMode, port, timeout }))
220
220
  .then (result => {
221
221
  Events.send("Dip.batchSubmit", { response: result })
@@ -282,7 +282,7 @@ function validate_topology(meta, collection, fn_name) {
282
282
  return new_meta
283
283
  }
284
284
 
285
- function check_core_meta(config, meta, suffix) {
285
+ function check_core_meta(config, meta, suffix?: string) {
286
286
  if (config.company !== meta.company && typeof config.company !== "object")
287
287
  throw new Error(`Error: Incompatible meta.company config for collection: ${collection}${suffix ? ' suffix: ' + suffix : ''}${fn_name ? ` ${fn_name}` : ''}`)
288
288
  if (config.outlet !== meta.outlet && typeof config.outlet !== "object")
@@ -347,7 +347,7 @@ export const insert = async (meta, collection, value, options?: any, extras?: an
347
347
  batches[meta.batch].push(arg)
348
348
  return
349
349
  }
350
- return new Promise((resolve, reject) => resolve())
350
+ return new Promise<void>((resolve, reject) => resolve())
351
351
  .then(() => execute(arg))
352
352
  .then(result => {
353
353
  Events.send("Dip.insert", { collection: collectionArray(collection), response: result })
@@ -386,7 +386,7 @@ export const query = async (meta, collection, query, options?: any, extras?: any
386
386
  batches[meta.batch].push(arg)
387
387
  return
388
388
  }
389
- return new Promise((resolve, reject) => resolve())
389
+ return new Promise<void>((resolve, reject) => resolve())
390
390
  .then(() => execute(arg))
391
391
  }
392
392
 
@@ -439,7 +439,7 @@ export const update = async (meta, collection, query, update, options?: any, ext
439
439
  batches[meta.batch].push(arg)
440
440
  return
441
441
  }
442
- return new Promise((resolve, reject) => resolve())
442
+ return new Promise<void>((resolve, reject) => resolve())
443
443
  .then(() => execute(arg))
444
444
  .then (result => {
445
445
  Events.send("Dip.update", { collection: collectionArray(collection), response: result })
@@ -482,7 +482,7 @@ export const remove = async (meta, collection, query, options?: any, extras?: an
482
482
  batches[meta.batch].push(arg)
483
483
  return
484
484
  }
485
- return new Promise((resolve, reject) => resolve())
485
+ return new Promise<void>((resolve, reject) => resolve())
486
486
  .then(() => execute(arg))
487
487
  .then(result => {
488
488
  Events.send("Dip.remove", { collection: collectionArray(collection), response: result })
@@ -563,7 +563,7 @@ let Essentials = {
563
563
 
564
564
  function prepareResult(result) {
565
565
  let res = result.content?.length === 1 ? result.content[0].items : result.content // For raw, this resolves to result.content which is ArrayBuffer
566
- res.metadata = _ => result.metadata
566
+ res.metadata = () => result.metadata
567
567
  if (result.metadata.executor === "raw")
568
568
  setRawBatchIterator(res)
569
569
  return res
@@ -615,7 +615,7 @@ function parseBinaryResponse(result) {
615
615
 
616
616
  function setRawBatchIterator(arrayBuffer) {
617
617
  arrayBuffer.metadata().items.forEach(batch => {
618
- batch.kv = _ => {
618
+ batch.kv = () => {
619
619
  const batchItem = {
620
620
  count: batch.count,
621
621
  slice: Essentials.sliceArrayBuffer(arrayBuffer, batch.offset, batch.size),
@@ -774,7 +774,7 @@ function getRawKeyValue(arrayBuffer, offset) {
774
774
  // Zero-copy view window bounded strictly to the key bytes
775
775
  let _id = masterView.subarray(offset, offset + keySize);
776
776
  let _id_string
777
- _id.toText = _ => {
777
+ _id.toText = () => {
778
778
  // Fix: Pass the typed array view itself, NOT the underlying root buffer
779
779
  _id_string = _id_string === undefined ? _id.buffer.slice(_id.byteOffset, _id.byteOffset + _id.byteLength) : _id_string
780
780
  return bufferToString(_id_string)
@@ -792,7 +792,7 @@ function getRawKeyValue(arrayBuffer, offset) {
792
792
 
793
793
  _val = Essentials.sliceArrayBuffer(arrayBuffer, _val.byteOffset, _val.byteLength)
794
794
  // _val = _val.buffer.slice(_val.byteOffset, _val.byteOffset + _val.byteLength);
795
- _val.toText = _ => bufferToString(_val)
795
+ _val.toText = () => bufferToString(_val)
796
796
  return { _id, _val, next: offset };
797
797
  }
798
798
 
package/libs/features.ts CHANGED
@@ -18,7 +18,7 @@ const getFeature = name => features[name]
18
18
  const DEPLOY_TOKEN_SECRET = process.env.DEPLOY_TOKEN_SECRET || "MY_SECRET_DEPLOY_TOKEN"
19
19
  const SERVICE_ACCESS_TOKEN = jwt.sign({app: process.env.APP_DEPLOYMENT_NAME}, DEPLOY_TOKEN_SECRET, { expiresIn: '365d' });
20
20
 
21
- const NDCURVE_DEVELOPER_LICENSE_ACCESS_TOKEN = await (async _ => { if(process.env.NDCURVE_DEVELOPER_SERVICE)try{ return (await Utils.fileToJson('file://', '/.ndcurve/developer.license.json')).accessToken?.trim() }catch{}})();
21
+ const NDCURVE_DEVELOPER_LICENSE_ACCESS_TOKEN = await (async () => { if(process.env.NDCURVE_DEVELOPER_SERVICE)try{ return (await Utils.fileToJson('file://', '/.ndcurve/developer.license.json')).accessToken?.trim() }catch{}})();
22
22
 
23
23
  async function loadLocalFeatures() { // For Local Testing
24
24
  let data = {}
@@ -74,7 +74,7 @@ export const send = async (meta, feature, data, params) => {
74
74
  let response;
75
75
  let req = {meta,body: payload, params,method}
76
76
  req = JSON.parse(JSON.stringify(req))
77
- let res = {json: payload => response = payload, end: _ => true }
77
+ let res = {json: payload => response = payload, end: () => true }
78
78
  await apiHandler(req, res);
79
79
  return response
80
80
  }
package/libs/messaging.ts CHANGED
@@ -146,7 +146,7 @@ export async function hdel(key, subkey) {
146
146
  // Hydrate
147
147
 
148
148
  export async function hydrate(callback) {
149
- setTimeout(async _ => {
149
+ setTimeout(async () => {
150
150
  let {user,company,items} = await callback()
151
151
  await publish(user, {event: "RPC_hydrate", data: { company, items }, txn: Utils.uid() })
152
152
  }, 100)
package/libs/utils.ts CHANGED
@@ -95,7 +95,7 @@ export function toAppDate(date: Date): string { // New
95
95
  }
96
96
 
97
97
 
98
- export function toDate(arg: string, currentTime?: boolean): Date { // New
98
+ export function toDate(arg: string, currentTime?: boolean): Date | undefined { // New
99
99
 
100
100
  let st = arg.split('/')
101
101
 
@@ -227,18 +227,18 @@ export function validityToMillisecs(start, validity) { // start is in ms
227
227
  period = period.toLowerCase()
228
228
 
229
229
  const timeline = {
230
- year: _ => addYears(now, count),
231
- years: _ => addYears(now, count),
232
- month: _ => addMonths(now, count),
233
- months: _ => addMonths(now, count),
234
- day: _ => now.setDate(now.getDate() + count),
235
- days: _ => now.setDate(now.getDate() + count),
236
- week: _ => now.setDate(now.getDate() + (count * 7)),
237
- weeks: _ => now.setDate(now.getDate() + (count * 7)),
238
- hour: _ => now.setHours(now.getHours() + count),
239
- hours: _ => now.setHours(now.getHours() + count),
240
- minute: _ => now.setMinutes(now.getMinutes() + count),
241
- minutes: _ => now.setMinutes(now.getMinutes() + count),
230
+ year: () => addYears(now, count),
231
+ years: () => addYears(now, count),
232
+ month: () => addMonths(now, count),
233
+ months: () => addMonths(now, count),
234
+ day: () => now.setDate(now.getDate() + count),
235
+ days: () => now.setDate(now.getDate() + count),
236
+ week: () => now.setDate(now.getDate() + (count * 7)),
237
+ weeks: () => now.setDate(now.getDate() + (count * 7)),
238
+ hour: () => now.setHours(now.getHours() + count),
239
+ hours: () => now.setHours(now.getHours() + count),
240
+ minute: () => now.setMinutes(now.getMinutes() + count),
241
+ minutes: () => now.setMinutes(now.getMinutes() + count),
242
242
  }
243
243
 
244
244
  timeline[period]()
@@ -253,18 +253,18 @@ export function validityToUTCMillisecs(start, validity) { // start is in ms
253
253
  period = period.toLowerCase()
254
254
 
255
255
  const timeline = {
256
- year: _ => addUTCYears(now, count),
257
- years: _ => addUTCYears(now, count),
258
- month: _ => addUTCMonths(now, count),
259
- months: _ => addUTCMonths(now, count),
260
- day: _ => now.setUTCDate(now.getUTCDate() + count),
261
- days: _ => now.setUTCDate(now.getUTCDate() + count),
262
- week: _ => now.setUTCDate(now.getUTCDate() + (count * 7)),
263
- weeks: _ => now.setUTCDate(now.getUTCDate() + (count * 7)),
264
- hour: _ => now.setUTCHours(now.getUTCHours() + count),
265
- hours: _ => now.setUTCHours(now.getUTCHours() + count),
266
- minute: _ => now.setUTCMinutes(now.getUTCMinutes() + count),
267
- minutes: _ => now.setUTCMinutes(now.getUTCMinutes() + count),
256
+ year: () => addUTCYears(now, count),
257
+ years: () => addUTCYears(now, count),
258
+ month: () => addUTCMonths(now, count),
259
+ months: () => addUTCMonths(now, count),
260
+ day: () => now.setUTCDate(now.getUTCDate() + count),
261
+ days: () => now.setUTCDate(now.getUTCDate() + count),
262
+ week: () => now.setUTCDate(now.getUTCDate() + (count * 7)),
263
+ weeks: () => now.setUTCDate(now.getUTCDate() + (count * 7)),
264
+ hour: () => now.setUTCHours(now.getUTCHours() + count),
265
+ hours: () => now.setUTCHours(now.getUTCHours() + count),
266
+ minute: () => now.setUTCMinutes(now.getUTCMinutes() + count),
267
+ minutes: () => now.setUTCMinutes(now.getUTCMinutes() + count),
268
268
  }
269
269
 
270
270
  timeline[period]()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.219",
4
+ "version": "1.0.220",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "./index.ts",
package/tsconfig.json CHANGED
@@ -26,7 +26,7 @@
26
26
  "declarationMap": false,
27
27
 
28
28
  // Stricter Typechecking Options
29
- "noUncheckedIndexedAccess": false,
29
+ "noUncheckedIndexedAccess": true,
30
30
  "exactOptionalPropertyTypes": false,
31
31
 
32
32
  // Style Options