corebasic 1.0.218 → 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.
- package/dist/libs/dip/suffix/suffix.js +10 -9
- package/dist/libs/dipper.js +2 -1
- package/dist/libs/elabase.js +2 -2
- package/libs/dip/suffix/date.ts +12 -12
- package/libs/dip/suffix/index.ts +14 -6
- package/libs/dip/suffix/suffix.ts +11 -10
- package/libs/dipper.ts +3 -2
- package/libs/elabase.ts +18 -15
- 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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { entries, reduceRanges, extractBounds, getNormalizedBounds } from './index.js';
|
|
2
2
|
import { formatDate, fillDates } from './date.js';
|
|
3
|
+
import * as Dip from '../../elabase.js';
|
|
3
4
|
const EXPLICIT_SUFFIX_POLICY_TYPES = new Set(["string", "date", "number"]);
|
|
4
5
|
export async function suffix(doc, policies, insertMode, arg) {
|
|
5
6
|
let suffixes = [""];
|
|
@@ -26,17 +27,17 @@ export async function suffix(doc, policies, insertMode, arg) {
|
|
|
26
27
|
if (policy_type === "date") {
|
|
27
28
|
keys = keys.map(key => formatDate(key, format));
|
|
28
29
|
if (ranges.length) {
|
|
29
|
-
|
|
30
|
-
const from =
|
|
31
|
-
const to =
|
|
32
|
-
const fromOp =
|
|
33
|
-
const toOp =
|
|
30
|
+
const bounds = extractBounds(reduceRanges(ranges));
|
|
31
|
+
const from = bounds.from ?? policy.min; // policy.min is always inclusive i.e $gte
|
|
32
|
+
const to = bounds.to ?? policy.max; // policy.max is always inclusive i.e $lte
|
|
33
|
+
const fromOp = bounds.from ? bounds.fromOp : "$gte"; // policy.min is $gte
|
|
34
|
+
const toOp = bounds.to ? bounds.toOp : "$lte"; // policy.max is $lte
|
|
34
35
|
if (from === undefined || to === undefined) {
|
|
35
36
|
keys = []; // Fall back to Dip.operation("ls").
|
|
36
37
|
console.warn(`Warn: Missing suffix policy min/max bound for ${policy_type} range specified for key ${policy.key} in Dip`);
|
|
37
38
|
}
|
|
38
39
|
else {
|
|
39
|
-
ranges = fillDates({ from, to, fromOp, toOp }, format);
|
|
40
|
+
let ranges = fillDates({ from, to, fromOp, toOp }, format);
|
|
40
41
|
if (!ranges.length && policy.inferRange)
|
|
41
42
|
ranges = [...new Set([from === undefined ? undefined : formatDate(from, format), to === undefined ? undefined : formatDate(to, format)].filter(item => item))];
|
|
42
43
|
// console.log(ranges)
|
|
@@ -51,9 +52,9 @@ export async function suffix(doc, policies, insertMode, arg) {
|
|
|
51
52
|
keys = [...new Set(keys)];
|
|
52
53
|
}
|
|
53
54
|
else if (policy_type === "number" && ranges.length) {
|
|
54
|
-
|
|
55
|
-
const from =
|
|
56
|
-
const to =
|
|
55
|
+
const bounds = getNormalizedBounds(extractBounds(reduceRanges(ranges)), "number");
|
|
56
|
+
const from = bounds.from ?? policy.min; // policy.min is always inclusive i.e $gte
|
|
57
|
+
const to = bounds.to ?? policy.max; // policy.max is always inclusive i.e $lte
|
|
57
58
|
if (from === undefined || to === undefined) {
|
|
58
59
|
keys = []; // Fall back to Dip.operation("ls").
|
|
59
60
|
console.warn(`Warn: Missing suffix policy min/max bound for ${policy_type} range specified for key ${policy.key} in Dip`);
|
package/dist/libs/dipper.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-ignore
|
|
1
2
|
import axios from 'axios';
|
|
2
3
|
// import {curly} from 'node-libcurl'
|
|
3
4
|
function hashStr(str) {
|
|
@@ -68,6 +69,6 @@ export default async function dipper(arg) {
|
|
|
68
69
|
export const shard_stats = () => {
|
|
69
70
|
let total = Object.values(shard_hits).reduce((partial, value) => partial + value, 0);
|
|
70
71
|
let result = {};
|
|
71
|
-
Object.entries(shard_hits).forEach(([key, value]) => result[key] =
|
|
72
|
+
Object.entries(shard_hits).forEach(([key, value]) => result[key] = (value * 100 / total).toFixed(2));
|
|
72
73
|
return result;
|
|
73
74
|
};
|
package/dist/libs/elabase.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as Cpp from './cpp.js';
|
|
|
6
6
|
import { applySuffixPolicy } from './dip/suffix/policy.js';
|
|
7
7
|
export const shard_stats = ShardStats;
|
|
8
8
|
let Events = {
|
|
9
|
-
send: function () { }
|
|
9
|
+
send: function (topic, data) { }
|
|
10
10
|
};
|
|
11
11
|
const url = process.env.DIP_URL || "http://127.0.0.1"; // Set DIP_URL to "http://dip" (Prod) or http://dip-dev (Dev) in CI/CD
|
|
12
12
|
let port = process.env.DIP_PORT || 9401;
|
|
@@ -50,7 +50,7 @@ class DipMeta {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
export const isDipMeta = meta => meta instanceof DipMeta;
|
|
53
|
-
export const globalMeta = args => {
|
|
53
|
+
export const globalMeta = (args) => {
|
|
54
54
|
return new DipMeta({ ...args, company: "GLOBAL", outlet: "GLOBAL" });
|
|
55
55
|
};
|
|
56
56
|
export const companyMeta = (company, args) => {
|
package/libs/dip/suffix/date.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {getNormalizedBounds} from './index.ts'
|
|
1
|
+
import {getNormalizedBounds, type Bounds} from './index.ts'
|
|
2
2
|
import {addUTCYears, addUTCMonths, addUTCDays} from '../../utils.ts'
|
|
3
3
|
|
|
4
4
|
|
|
@@ -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]());
|
|
@@ -94,7 +94,7 @@ export function fillDates(bounds_t, format) {
|
|
|
94
94
|
else
|
|
95
95
|
step = "year";
|
|
96
96
|
|
|
97
|
-
let bounds = { ...bounds_t, from: new Date(bounds_t.from), to: new Date(bounds_t.to) }
|
|
97
|
+
let bounds: Bounds = { ...bounds_t, from: new Date(bounds_t.from), to: new Date(bounds_t.to) }
|
|
98
98
|
|
|
99
99
|
bounds = getNormalizedBounds(bounds, "date")
|
|
100
100
|
|
|
@@ -103,13 +103,13 @@ export function fillDates(bounds_t, format) {
|
|
|
103
103
|
|
|
104
104
|
switch (step) {
|
|
105
105
|
case "day":
|
|
106
|
-
addUTCDays(bounds.from, 1)
|
|
106
|
+
addUTCDays(bounds.from as Date, 1)
|
|
107
107
|
break;
|
|
108
108
|
case "month":
|
|
109
|
-
addUTCMonths(bounds.from, 1)
|
|
109
|
+
addUTCMonths(bounds.from as Date, 1)
|
|
110
110
|
break;
|
|
111
111
|
case "year":
|
|
112
|
-
addUTCYears(bounds.from, 1)
|
|
112
|
+
addUTCYears(bounds.from as Date, 1)
|
|
113
113
|
break;
|
|
114
114
|
}
|
|
115
115
|
}
|
package/libs/dip/suffix/index.ts
CHANGED
|
@@ -160,11 +160,19 @@ export function reduceRanges(values) {
|
|
|
160
160
|
return other;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
export type Bounds = {
|
|
164
|
+
values: any[],
|
|
165
|
+
from: number | string | Date;
|
|
166
|
+
to: number | string | Date;
|
|
167
|
+
fromOp: "$gt" | "$gte";
|
|
168
|
+
toOp: "$lt" | "$lte";
|
|
169
|
+
}
|
|
170
|
+
|
|
163
171
|
// reduceRanges() resolves conflicting bounds before extractBounds() runs.
|
|
164
172
|
// extractBounds() receives at most one lower bound and atmost one upper bound. reduceRanges() ensures this
|
|
165
173
|
// The for loop in extractBounds() may look slightly misleading because it looks like it is designed to resolve conflicts: but reduceRanges() has already done the conflict resolution.
|
|
166
174
|
// NOTE CRITICAL: extractBounds() MUST ONLY BE RUN ON THE OUTPUT OF reduceRanges()
|
|
167
|
-
export function extractBounds(values) {
|
|
175
|
+
export function extractBounds(values): Bounds {
|
|
168
176
|
let lower = null;
|
|
169
177
|
let upper = null;
|
|
170
178
|
let lowerOp = null
|
|
@@ -204,20 +212,20 @@ export function extractBounds(values) {
|
|
|
204
212
|
}
|
|
205
213
|
|
|
206
214
|
// Converts exclusive bounds ($gt/$lt) into inclusive bounds
|
|
207
|
-
export function getNormalizedBounds(bounds_t, type) {
|
|
215
|
+
export function getNormalizedBounds(bounds_t: Bounds, type): Bounds {
|
|
208
216
|
let bounds = {...bounds_t}
|
|
209
217
|
|
|
210
218
|
if (type === "number") {
|
|
211
219
|
if (bounds.fromOp === "$gt")
|
|
212
|
-
bounds.from++;
|
|
220
|
+
(bounds.from as number)++;
|
|
213
221
|
if (bounds.toOp === "$lt")
|
|
214
|
-
bounds.to--;
|
|
222
|
+
(bounds.to as number)--;
|
|
215
223
|
} else if (type === "date") {
|
|
216
224
|
if (bounds.fromOp === "$gt")
|
|
217
|
-
bounds.from = new Date(bounds.from.getTime() + 1);
|
|
225
|
+
bounds.from = new Date((bounds.from as Date).getTime() + 1);
|
|
218
226
|
|
|
219
227
|
if (bounds.toOp === "$lt")
|
|
220
|
-
bounds.to = new Date(bounds.to.getTime() - 1);
|
|
228
|
+
bounds.to = new Date((bounds.to as Date).getTime() - 1);
|
|
221
229
|
}
|
|
222
230
|
|
|
223
231
|
return bounds
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {entries, reduceRanges, extractBounds, getNormalizedBounds} from './index.ts'
|
|
1
|
+
import {entries, reduceRanges, extractBounds, getNormalizedBounds, type Bounds} from './index.ts'
|
|
2
2
|
import {formatDate, fillDates} from './date.ts'
|
|
3
|
+
import * as Dip from '../../elabase.ts'
|
|
3
4
|
|
|
4
5
|
type Arg = { db?: string; collection?: string; [key: string]: any }
|
|
5
6
|
|
|
@@ -37,16 +38,16 @@ export async function suffix(doc, policies, insertMode?: boolean, arg?: Arg) {
|
|
|
37
38
|
if (policy_type === "date") {
|
|
38
39
|
keys = keys.map(key => formatDate(key, format))
|
|
39
40
|
if (ranges.length) {
|
|
40
|
-
|
|
41
|
-
const from =
|
|
42
|
-
const to =
|
|
43
|
-
const fromOp =
|
|
44
|
-
const toOp =
|
|
41
|
+
const bounds = extractBounds(reduceRanges(ranges))
|
|
42
|
+
const from = bounds.from ?? policy.min // policy.min is always inclusive i.e $gte
|
|
43
|
+
const to = bounds.to ?? policy.max // policy.max is always inclusive i.e $lte
|
|
44
|
+
const fromOp = bounds.from ? bounds.fromOp : "$gte" // policy.min is $gte
|
|
45
|
+
const toOp = bounds.to ? bounds.toOp : "$lte" // policy.max is $lte
|
|
45
46
|
if (from === undefined || to === undefined) {
|
|
46
47
|
keys = [] // Fall back to Dip.operation("ls").
|
|
47
48
|
console.warn(`Warn: Missing suffix policy min/max bound for ${policy_type} range specified for key ${policy.key} in Dip`)
|
|
48
49
|
} else {
|
|
49
|
-
ranges = fillDates({from, to, fromOp, toOp}, format)
|
|
50
|
+
let ranges = fillDates({from, to, fromOp, toOp}, format)
|
|
50
51
|
if (!ranges.length && policy.inferRange)
|
|
51
52
|
ranges = [...new Set([from === undefined ? undefined : formatDate(from, format), to === undefined ? undefined : formatDate(to, format)].filter(item => item))]
|
|
52
53
|
// console.log(ranges)
|
|
@@ -59,9 +60,9 @@ export async function suffix(doc, policies, insertMode?: boolean, arg?: Arg) {
|
|
|
59
60
|
}
|
|
60
61
|
keys = [...new Set(keys)];
|
|
61
62
|
} else if (policy_type === "number" && ranges.length) {
|
|
62
|
-
|
|
63
|
-
const from =
|
|
64
|
-
const to =
|
|
63
|
+
const bounds = getNormalizedBounds(extractBounds(reduceRanges(ranges)), "number")
|
|
64
|
+
const from = bounds.from ?? policy.min // policy.min is always inclusive i.e $gte
|
|
65
|
+
const to = bounds.to ?? policy.max // policy.max is always inclusive i.e $lte
|
|
65
66
|
if (from === undefined || to === undefined) {
|
|
66
67
|
keys = [] // Fall back to Dip.operation("ls").
|
|
67
68
|
console.warn(`Warn: Missing suffix policy min/max bound for ${policy_type} range specified for key ${policy.key} in Dip`)
|
package/libs/dipper.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-ignore
|
|
1
2
|
import axios from 'axios'
|
|
2
3
|
// import {curly} from 'node-libcurl'
|
|
3
4
|
|
|
@@ -84,8 +85,8 @@ export default async function dipper(arg) {
|
|
|
84
85
|
|
|
85
86
|
|
|
86
87
|
export const shard_stats = () => {
|
|
87
|
-
let total = Object.values(shard_hits).reduce( (partial, value) => partial + value, 0)
|
|
88
|
+
let total: number = (Object.values(shard_hits) as number[]).reduce( (partial: number, value: number) => partial + value, 0)
|
|
88
89
|
let result = {}
|
|
89
|
-
Object.entries(shard_hits).forEach( ([key,value]) => result[key] =
|
|
90
|
+
Object.entries(shard_hits).forEach( ([key, value]) => result[key] = ((value as number) * 100 / total).toFixed(2) )
|
|
90
91
|
return result
|
|
91
92
|
}
|
package/libs/elabase.ts
CHANGED
|
@@ -13,7 +13,7 @@ export const shard_stats = ShardStats
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
let Events = {
|
|
16
|
-
send: function() { }
|
|
16
|
+
send: function(topic?: string, data?: any) { }
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
|
|
@@ -63,6 +63,9 @@ function deepFreeze(obj) {
|
|
|
63
63
|
return obj;
|
|
64
64
|
}
|
|
65
65
|
class DipMeta {
|
|
66
|
+
declare company?: string;
|
|
67
|
+
declare outlet?: string;
|
|
68
|
+
|
|
66
69
|
constructor(obj) {
|
|
67
70
|
Object.assign(this, deepFreeze(obj));
|
|
68
71
|
Object.freeze(this);
|
|
@@ -70,10 +73,10 @@ class DipMeta {
|
|
|
70
73
|
}
|
|
71
74
|
export const isDipMeta = meta => meta instanceof DipMeta
|
|
72
75
|
|
|
73
|
-
export const globalMeta = args => {
|
|
76
|
+
export const globalMeta = (args?: any) => {
|
|
74
77
|
return new DipMeta({ ...args, company: "GLOBAL", outlet: "GLOBAL" })
|
|
75
78
|
}
|
|
76
|
-
export const companyMeta = (company, args) => {
|
|
79
|
+
export const companyMeta = (company, args?: any) => {
|
|
77
80
|
if (typeof company !== "string" && !Array.isArray(company))
|
|
78
81
|
throw new Error("Error: Invalid company provided in Dip.companyMeta()")
|
|
79
82
|
if (!company || (typeof company === "string" && company.trim() === "") || company === "GLOBAL" || (Array.isArray(company) && (!company.length || company.some(item => typeof item !== "string" || item.trim() === "" || item === "GLOBAL")) ))
|
|
@@ -81,7 +84,7 @@ export const companyMeta = (company, args) => {
|
|
|
81
84
|
|
|
82
85
|
return new DipMeta({...args, outlet: "GLOBAL", company})
|
|
83
86
|
}
|
|
84
|
-
export const outletMeta = (outlet, args) => {
|
|
87
|
+
export const outletMeta = (outlet, args?: any) => {
|
|
85
88
|
if (typeof outlet !== "string" && !Array.isArray(outlet))
|
|
86
89
|
throw new Error("Error: Invalid outlet provided in Dip.outletMeta()")
|
|
87
90
|
if (!outlet || (typeof outlet === "string" && outlet.trim() === "") || outlet === "GLOBAL" || (Array.isArray(outlet) && (!outlet.length || outlet.some(item => typeof item !== "string" || item.trim() === "" || item === "GLOBAL")) ))
|
|
@@ -90,7 +93,7 @@ export const outletMeta = (outlet, args) => {
|
|
|
90
93
|
return new DipMeta({...args, company: "GLOBAL", outlet})
|
|
91
94
|
}
|
|
92
95
|
|
|
93
|
-
export const customMeta = (company, outlet, args) => {
|
|
96
|
+
export const customMeta = (company, outlet, args?: any) => {
|
|
94
97
|
|
|
95
98
|
if (typeof company !== "string" && !Array.isArray(company))
|
|
96
99
|
throw new Error("Error: Invalid company provided in Dip.customMeta()")
|
|
@@ -212,7 +215,7 @@ export function batchSubmit(batch_id, arg) {
|
|
|
212
215
|
const port = arg?.port
|
|
213
216
|
const timeout = arg?.timeout
|
|
214
217
|
delete batches[batch_id]
|
|
215
|
-
return new Promise((resolve, reject) => resolve())
|
|
218
|
+
return new Promise<void>((resolve, reject) => resolve())
|
|
216
219
|
.then(() => execute({ "batch": txns, version: arg?.version, raw, engine, compression: arg?.compression, executor, syncMode, port, timeout }))
|
|
217
220
|
.then (result => {
|
|
218
221
|
Events.send("Dip.batchSubmit", { response: result })
|
|
@@ -279,7 +282,7 @@ function validate_topology(meta, collection, fn_name) {
|
|
|
279
282
|
return new_meta
|
|
280
283
|
}
|
|
281
284
|
|
|
282
|
-
function check_core_meta(config, meta, suffix) {
|
|
285
|
+
function check_core_meta(config, meta, suffix?: string) {
|
|
283
286
|
if (config.company !== meta.company && typeof config.company !== "object")
|
|
284
287
|
throw new Error(`Error: Incompatible meta.company config for collection: ${collection}${suffix ? ' suffix: ' + suffix : ''}${fn_name ? ` ${fn_name}` : ''}`)
|
|
285
288
|
if (config.outlet !== meta.outlet && typeof config.outlet !== "object")
|
|
@@ -344,7 +347,7 @@ export const insert = async (meta, collection, value, options?: any, extras?: an
|
|
|
344
347
|
batches[meta.batch].push(arg)
|
|
345
348
|
return
|
|
346
349
|
}
|
|
347
|
-
return new Promise((resolve, reject) => resolve())
|
|
350
|
+
return new Promise<void>((resolve, reject) => resolve())
|
|
348
351
|
.then(() => execute(arg))
|
|
349
352
|
.then(result => {
|
|
350
353
|
Events.send("Dip.insert", { collection: collectionArray(collection), response: result })
|
|
@@ -383,7 +386,7 @@ export const query = async (meta, collection, query, options?: any, extras?: any
|
|
|
383
386
|
batches[meta.batch].push(arg)
|
|
384
387
|
return
|
|
385
388
|
}
|
|
386
|
-
return new Promise((resolve, reject) => resolve())
|
|
389
|
+
return new Promise<void>((resolve, reject) => resolve())
|
|
387
390
|
.then(() => execute(arg))
|
|
388
391
|
}
|
|
389
392
|
|
|
@@ -436,7 +439,7 @@ export const update = async (meta, collection, query, update, options?: any, ext
|
|
|
436
439
|
batches[meta.batch].push(arg)
|
|
437
440
|
return
|
|
438
441
|
}
|
|
439
|
-
return new Promise((resolve, reject) => resolve())
|
|
442
|
+
return new Promise<void>((resolve, reject) => resolve())
|
|
440
443
|
.then(() => execute(arg))
|
|
441
444
|
.then (result => {
|
|
442
445
|
Events.send("Dip.update", { collection: collectionArray(collection), response: result })
|
|
@@ -479,7 +482,7 @@ export const remove = async (meta, collection, query, options?: any, extras?: an
|
|
|
479
482
|
batches[meta.batch].push(arg)
|
|
480
483
|
return
|
|
481
484
|
}
|
|
482
|
-
return new Promise((resolve, reject) => resolve())
|
|
485
|
+
return new Promise<void>((resolve, reject) => resolve())
|
|
483
486
|
.then(() => execute(arg))
|
|
484
487
|
.then(result => {
|
|
485
488
|
Events.send("Dip.remove", { collection: collectionArray(collection), response: result })
|
|
@@ -560,7 +563,7 @@ let Essentials = {
|
|
|
560
563
|
|
|
561
564
|
function prepareResult(result) {
|
|
562
565
|
let res = result.content?.length === 1 ? result.content[0].items : result.content // For raw, this resolves to result.content which is ArrayBuffer
|
|
563
|
-
res.metadata =
|
|
566
|
+
res.metadata = () => result.metadata
|
|
564
567
|
if (result.metadata.executor === "raw")
|
|
565
568
|
setRawBatchIterator(res)
|
|
566
569
|
return res
|
|
@@ -612,7 +615,7 @@ function parseBinaryResponse(result) {
|
|
|
612
615
|
|
|
613
616
|
function setRawBatchIterator(arrayBuffer) {
|
|
614
617
|
arrayBuffer.metadata().items.forEach(batch => {
|
|
615
|
-
batch.kv =
|
|
618
|
+
batch.kv = () => {
|
|
616
619
|
const batchItem = {
|
|
617
620
|
count: batch.count,
|
|
618
621
|
slice: Essentials.sliceArrayBuffer(arrayBuffer, batch.offset, batch.size),
|
|
@@ -771,7 +774,7 @@ function getRawKeyValue(arrayBuffer, offset) {
|
|
|
771
774
|
// Zero-copy view window bounded strictly to the key bytes
|
|
772
775
|
let _id = masterView.subarray(offset, offset + keySize);
|
|
773
776
|
let _id_string
|
|
774
|
-
_id.toText =
|
|
777
|
+
_id.toText = () => {
|
|
775
778
|
// Fix: Pass the typed array view itself, NOT the underlying root buffer
|
|
776
779
|
_id_string = _id_string === undefined ? _id.buffer.slice(_id.byteOffset, _id.byteOffset + _id.byteLength) : _id_string
|
|
777
780
|
return bufferToString(_id_string)
|
|
@@ -789,7 +792,7 @@ function getRawKeyValue(arrayBuffer, offset) {
|
|
|
789
792
|
|
|
790
793
|
_val = Essentials.sliceArrayBuffer(arrayBuffer, _val.byteOffset, _val.byteLength)
|
|
791
794
|
// _val = _val.buffer.slice(_val.byteOffset, _val.byteOffset + _val.byteLength);
|
|
792
|
-
_val.toText =
|
|
795
|
+
_val.toText = () => bufferToString(_val)
|
|
793
796
|
return { _id, _val, next: offset };
|
|
794
797
|
}
|
|
795
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