aiiinotate 0.10.1 → 0.10.3
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/cli/utils/io.js +8 -1
- package/config/.env.template +1 -1
- package/package.json +1 -1
- package/src/constants.js +6 -0
- package/src/utils/utils.js +7 -0
- package/import_manifest_file.txt +0 -1
package/cli/utils/io.js
CHANGED
|
@@ -64,9 +64,16 @@ function fileArrayValidate (fileArr) {
|
|
|
64
64
|
* @returns {Promise<string[]>}
|
|
65
65
|
*/
|
|
66
66
|
async function parseImportInputFile(file) {
|
|
67
|
+
// ensure input file exists
|
|
68
|
+
const [ fileAbs, ok ] = fileOk(file);
|
|
69
|
+
if (!ok) {
|
|
70
|
+
console.error(`could not read import file: ${file}. exiting...`);
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
|
|
67
74
|
// read `file` split it by lines, remove empty lines
|
|
68
75
|
const fileArr =
|
|
69
|
-
fileRead(
|
|
76
|
+
fileRead(fileAbs)
|
|
70
77
|
.split("\n")
|
|
71
78
|
.filter(l => !l.match(/^\s*$/g));
|
|
72
79
|
return [ ...new Set(fileArrayValidate(fileArr)) ];
|
package/config/.env.template
CHANGED
|
@@ -18,7 +18,7 @@ AIIINOTATE_SCHEME=http
|
|
|
18
18
|
AIIINOTATE_LOG_TARGET=stdout
|
|
19
19
|
# directory to save logs to (if AIIINOTATE_LOG_TARGET enables logging to file)
|
|
20
20
|
AIIINOTATE_LOG_DIR=
|
|
21
|
-
# log level. "debug"|"info"|"
|
|
21
|
+
# log level. "trace"|"debug"|"info"|"warn"|"error"|"fatal"
|
|
22
22
|
AIIINOTATE_LOG_LEVEL=debug
|
|
23
23
|
|
|
24
24
|
|
package/package.json
CHANGED
package/src/constants.js
CHANGED
|
@@ -42,6 +42,12 @@ if (Object.values(env_mapper).some(e => e==null)) {
|
|
|
42
42
|
process.exit(1);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
const allowedLogLevels = [ "trace", "debug", "info", "warn", "error", "fatal" ];
|
|
46
|
+
if (!allowedLogLevels.includes(LOG_LEVEL)) {
|
|
47
|
+
console.error(`SETUP ERROR: env variable AIIINOTATE_LOG_TARGET must be set to one of ${allowedLogLevels.map(x => "\"" + x + "\"").join(", ")}. Got "${LOG_LEVEL}". Exiting...`)
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
|
|
45
51
|
// enforce value constraints on variables
|
|
46
52
|
const allowedLogTargets = [ "file", "stdout", "stdout+file", "off" ];
|
|
47
53
|
if (!allowedLogTargets.includes(LOG_TARGET)) {
|
package/src/utils/utils.js
CHANGED
|
@@ -287,6 +287,9 @@ const recursiveSort = (x) => {
|
|
|
287
287
|
* - to avoid the cache to grow unbounded, we define a max size after which
|
|
288
288
|
* we delete the greatest items in the cache.
|
|
289
289
|
*
|
|
290
|
+
* cache structure:
|
|
291
|
+
* Map<[key:string]: { timestamp: Date, promise: Promise }>
|
|
292
|
+
*
|
|
290
293
|
* NOTE: LIMITATIONS:
|
|
291
294
|
* - `memoize` converts `fn` to an async function to work with both
|
|
292
295
|
* sync/async patterns, remember to await !
|
|
@@ -304,7 +307,11 @@ const memoize = (fn, timeout = 2000, maxSize = 200) => {
|
|
|
304
307
|
if (timeout <= 0 || maxSize <= 0) {
|
|
305
308
|
throw new Error("memoize: 'timeout' and 'maxSize' must be greater than 0.")
|
|
306
309
|
}
|
|
310
|
+
|
|
311
|
+
// each key is mapped to an object storing the timestamp of cache item cration + the function result as a promise.
|
|
312
|
+
/** @type {Map<[key:string], { timestamp: Date, promise: Promise }>} */
|
|
307
313
|
const cache = new Map();
|
|
314
|
+
|
|
308
315
|
return async (...args) => {
|
|
309
316
|
// if cache.size > cacheSize, remove the oldest items.
|
|
310
317
|
const extraCount = cache.size - maxSize;
|
package/import_manifest_file.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
./wit1923_man1937.json
|