corebasic 1.0.219 → 1.0.221
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.
- package/dist/libs/dip/suffix/date.js +7 -7
- package/dist/libs/elabase.js +4 -4
- package/dist/libs/features.js +2 -2
- package/dist/libs/messaging.js +1 -1
- package/dist/libs/utils.js +24 -24
- package/libs/dip/suffix/date.ts +7 -7
- package/libs/elabase.ts +10 -10
- package/libs/features.ts +2 -2
- package/libs/messaging.ts +1 -1
- package/libs/utils.ts +25 -25
- package/package.json +1 -1
- package/tsconfig.json +1 -1
|
@@ -36,13 +36,13 @@ export function formatDate(value, format) {
|
|
|
36
36
|
// years and months and dates are already deduplicated
|
|
37
37
|
const separator = '|';
|
|
38
38
|
const replacements = {
|
|
39
|
-
YYYY:
|
|
40
|
-
YY:
|
|
41
|
-
MMMM:
|
|
42
|
-
MMM:
|
|
43
|
-
MM:
|
|
44
|
-
DD:
|
|
45
|
-
D:
|
|
39
|
+
YYYY: () => years.join(separator),
|
|
40
|
+
YY: () => years.map(y => String(y).slice(-2)).join(separator),
|
|
41
|
+
MMMM: () => months.map(m => MONTH_LONG[m]).join(separator),
|
|
42
|
+
MMM: () => months.map(m => MONTH_SHORT[m]).join(separator),
|
|
43
|
+
MM: () => months.map(m => String(m + 1).padStart(2, "0")).join(separator),
|
|
44
|
+
DD: () => dates.map(d => String(d).padStart(2, "0")).join(separator),
|
|
45
|
+
D: () => dates.join(separator),
|
|
46
46
|
};
|
|
47
47
|
return format.replace(/YYYY|MMMM|MMM|YY|MM|DD|D/g, token => replacements[token]());
|
|
48
48
|
}
|
package/dist/libs/elabase.js
CHANGED
|
@@ -466,7 +466,7 @@ let Essentials = {
|
|
|
466
466
|
};
|
|
467
467
|
function prepareResult(result) {
|
|
468
468
|
let res = result.content?.length === 1 ? result.content[0].items : result.content; // For raw, this resolves to result.content which is ArrayBuffer
|
|
469
|
-
res.metadata =
|
|
469
|
+
res.metadata = () => result.metadata;
|
|
470
470
|
if (result.metadata.executor === "raw")
|
|
471
471
|
setRawBatchIterator(res);
|
|
472
472
|
return res;
|
|
@@ -507,7 +507,7 @@ function parseBinaryResponse(result) {
|
|
|
507
507
|
}
|
|
508
508
|
function setRawBatchIterator(arrayBuffer) {
|
|
509
509
|
arrayBuffer.metadata().items.forEach(batch => {
|
|
510
|
-
batch.kv =
|
|
510
|
+
batch.kv = () => {
|
|
511
511
|
const batchItem = {
|
|
512
512
|
count: batch.count,
|
|
513
513
|
slice: Essentials.sliceArrayBuffer(arrayBuffer, batch.offset, batch.size),
|
|
@@ -636,7 +636,7 @@ function getRawKeyValue(arrayBuffer, offset) {
|
|
|
636
636
|
// Zero-copy view window bounded strictly to the key bytes
|
|
637
637
|
let _id = masterView.subarray(offset, offset + keySize);
|
|
638
638
|
let _id_string;
|
|
639
|
-
_id.toText =
|
|
639
|
+
_id.toText = () => {
|
|
640
640
|
// Fix: Pass the typed array view itself, NOT the underlying root buffer
|
|
641
641
|
_id_string = _id_string === undefined ? _id.buffer.slice(_id.byteOffset, _id.byteOffset + _id.byteLength) : _id_string;
|
|
642
642
|
return bufferToString(_id_string);
|
|
@@ -651,7 +651,7 @@ function getRawKeyValue(arrayBuffer, offset) {
|
|
|
651
651
|
offset += dataSize;
|
|
652
652
|
_val = Essentials.sliceArrayBuffer(arrayBuffer, _val.byteOffset, _val.byteLength);
|
|
653
653
|
// _val = _val.buffer.slice(_val.byteOffset, _val.byteOffset + _val.byteLength);
|
|
654
|
-
_val.toText =
|
|
654
|
+
_val.toText = () => bufferToString(_val);
|
|
655
655
|
return { _id, _val, next: offset };
|
|
656
656
|
}
|
|
657
657
|
// Axios usage
|
package/dist/libs/features.js
CHANGED
|
@@ -22,7 +22,7 @@ const getFeatureUrl = api => api.split(' ')[1];
|
|
|
22
22
|
const getFeature = name => features[name];
|
|
23
23
|
const DEPLOY_TOKEN_SECRET = process.env.DEPLOY_TOKEN_SECRET || "MY_SECRET_DEPLOY_TOKEN";
|
|
24
24
|
const SERVICE_ACCESS_TOKEN = jwt.sign({ app: process.env.APP_DEPLOYMENT_NAME }, DEPLOY_TOKEN_SECRET, { expiresIn: '365d' });
|
|
25
|
-
const NDCURVE_DEVELOPER_LICENSE_ACCESS_TOKEN = await (async (
|
|
25
|
+
const NDCURVE_DEVELOPER_LICENSE_ACCESS_TOKEN = await (async () => { if (process.env.NDCURVE_DEVELOPER_SERVICE)
|
|
26
26
|
try {
|
|
27
27
|
return (await Utils.fileToJson('file://', '/.ndcurve/developer.license.json')).accessToken?.trim();
|
|
28
28
|
}
|
|
@@ -75,7 +75,7 @@ export const send = async (meta, feature, data, params) => {
|
|
|
75
75
|
let response;
|
|
76
76
|
let req = { meta, body: payload, params, method };
|
|
77
77
|
req = JSON.parse(JSON.stringify(req));
|
|
78
|
-
let res = { json: payload => response = payload, end:
|
|
78
|
+
let res = { json: payload => response = payload, end: () => true };
|
|
79
79
|
await apiHandler(req, res);
|
|
80
80
|
return response;
|
|
81
81
|
}
|
package/dist/libs/messaging.js
CHANGED
|
@@ -125,7 +125,7 @@ export async function hdel(key, subkey) {
|
|
|
125
125
|
}
|
|
126
126
|
// Hydrate
|
|
127
127
|
export async function hydrate(callback) {
|
|
128
|
-
setTimeout(async (
|
|
128
|
+
setTimeout(async () => {
|
|
129
129
|
let { user, company, items } = await callback();
|
|
130
130
|
await publish(user, { event: "RPC_hydrate", data: { company, items }, txn: Utils.uid() });
|
|
131
131
|
}, 100);
|
package/dist/libs/utils.js
CHANGED
|
@@ -184,18 +184,18 @@ export function validityToMillisecs(start, validity) {
|
|
|
184
184
|
count = parseIntValue(count);
|
|
185
185
|
period = period.toLowerCase();
|
|
186
186
|
const timeline = {
|
|
187
|
-
year:
|
|
188
|
-
years:
|
|
189
|
-
month:
|
|
190
|
-
months:
|
|
191
|
-
day:
|
|
192
|
-
days:
|
|
193
|
-
week:
|
|
194
|
-
weeks:
|
|
195
|
-
hour:
|
|
196
|
-
hours:
|
|
197
|
-
minute:
|
|
198
|
-
minutes:
|
|
187
|
+
year: () => addYears(now, count),
|
|
188
|
+
years: () => addYears(now, count),
|
|
189
|
+
month: () => addMonths(now, count),
|
|
190
|
+
months: () => addMonths(now, count),
|
|
191
|
+
day: () => now.setDate(now.getDate() + count),
|
|
192
|
+
days: () => now.setDate(now.getDate() + count),
|
|
193
|
+
week: () => now.setDate(now.getDate() + (count * 7)),
|
|
194
|
+
weeks: () => now.setDate(now.getDate() + (count * 7)),
|
|
195
|
+
hour: () => now.setHours(now.getHours() + count),
|
|
196
|
+
hours: () => now.setHours(now.getHours() + count),
|
|
197
|
+
minute: () => now.setMinutes(now.getMinutes() + count),
|
|
198
|
+
minutes: () => now.setMinutes(now.getMinutes() + count),
|
|
199
199
|
};
|
|
200
200
|
timeline[period]();
|
|
201
201
|
return now.getTime();
|
|
@@ -206,18 +206,18 @@ export function validityToUTCMillisecs(start, validity) {
|
|
|
206
206
|
count = parseIntValue(count);
|
|
207
207
|
period = period.toLowerCase();
|
|
208
208
|
const timeline = {
|
|
209
|
-
year:
|
|
210
|
-
years:
|
|
211
|
-
month:
|
|
212
|
-
months:
|
|
213
|
-
day:
|
|
214
|
-
days:
|
|
215
|
-
week:
|
|
216
|
-
weeks:
|
|
217
|
-
hour:
|
|
218
|
-
hours:
|
|
219
|
-
minute:
|
|
220
|
-
minutes:
|
|
209
|
+
year: () => addUTCYears(now, count),
|
|
210
|
+
years: () => addUTCYears(now, count),
|
|
211
|
+
month: () => addUTCMonths(now, count),
|
|
212
|
+
months: () => addUTCMonths(now, count),
|
|
213
|
+
day: () => now.setUTCDate(now.getUTCDate() + count),
|
|
214
|
+
days: () => now.setUTCDate(now.getUTCDate() + count),
|
|
215
|
+
week: () => now.setUTCDate(now.getUTCDate() + (count * 7)),
|
|
216
|
+
weeks: () => now.setUTCDate(now.getUTCDate() + (count * 7)),
|
|
217
|
+
hour: () => now.setUTCHours(now.getUTCHours() + count),
|
|
218
|
+
hours: () => now.setUTCHours(now.getUTCHours() + count),
|
|
219
|
+
minute: () => now.setUTCMinutes(now.getUTCMinutes() + count),
|
|
220
|
+
minutes: () => now.setUTCMinutes(now.getUTCMinutes() + count),
|
|
221
221
|
};
|
|
222
222
|
timeline[period]();
|
|
223
223
|
return now.getTime();
|
package/libs/dip/suffix/date.ts
CHANGED
|
@@ -50,13 +50,13 @@ export function formatDate(value, format) {
|
|
|
50
50
|
const separator = '|'
|
|
51
51
|
|
|
52
52
|
const replacements = {
|
|
53
|
-
YYYY:
|
|
54
|
-
YY:
|
|
55
|
-
MMMM:
|
|
56
|
-
MMM:
|
|
57
|
-
MM:
|
|
58
|
-
DD:
|
|
59
|
-
D:
|
|
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 =
|
|
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 =
|
|
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
|
|
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:
|
|
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:
|
|
231
|
-
years:
|
|
232
|
-
month:
|
|
233
|
-
months:
|
|
234
|
-
day:
|
|
235
|
-
days:
|
|
236
|
-
week:
|
|
237
|
-
weeks:
|
|
238
|
-
hour:
|
|
239
|
-
hours:
|
|
240
|
-
minute:
|
|
241
|
-
minutes:
|
|
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:
|
|
257
|
-
years:
|
|
258
|
-
month:
|
|
259
|
-
months:
|
|
260
|
-
day:
|
|
261
|
-
days:
|
|
262
|
-
week:
|
|
263
|
-
weeks:
|
|
264
|
-
hour:
|
|
265
|
-
hours:
|
|
266
|
-
minute:
|
|
267
|
-
minutes:
|
|
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