utilitas 1989.9.4 → 1989.9.8
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/index.mjs +38 -74
- package/lib/cache.mjs +2 -2
- package/lib/dbio.mjs +2 -2
- package/lib/email.mjs +2 -2
- package/lib/encryption.mjs +1 -1
- package/lib/event.mjs +11 -13
- package/lib/network.mjs +3 -3
- package/lib/sentinel.mjs +2 -2
- package/lib/shell.mjs +2 -2
- package/lib/shot.mjs +3 -3
- package/lib/sms.mjs +2 -2
- package/lib/storage.mjs +2 -2
- package/lib/tape.mjs +2 -2
- package/lib/uoid.mjs +3 -3
- package/lib/utilitas.mjs +2 -2
- package/package.json +2 -2
package/index.mjs
CHANGED
|
@@ -1,75 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
import sentinel from './lib/sentinel.mjs';
|
|
24
|
-
import sentry from '@sentry/node';
|
|
25
|
-
import shell from './lib/shell.mjs';
|
|
26
|
-
import shot from './lib/shot.mjs';
|
|
27
|
-
import sms from './lib/sms.mjs';
|
|
28
|
-
import storage from './lib/storage.mjs';
|
|
29
|
-
import tape from './lib/tape.mjs';
|
|
30
|
-
import telesign from 'telesignsdk';
|
|
31
|
-
import twilio from 'twilio';
|
|
32
|
-
import uoid from './lib/uoid.mjs';
|
|
33
|
-
import utilitas from './lib/utilitas.mjs';
|
|
34
|
-
import winston from 'winston';
|
|
35
|
-
import winstonPapertrail from 'winston-papertrail-mproved';
|
|
1
|
+
// dependencies
|
|
2
|
+
export * as base64url from 'base64url';
|
|
3
|
+
export * as fetch from 'node-fetch';
|
|
4
|
+
export * as fileType from 'file-type';
|
|
5
|
+
export * as geoIp from 'fast-geoip';
|
|
6
|
+
export * as ini from 'ini';
|
|
7
|
+
export * as jwt from 'jsonwebtoken';
|
|
8
|
+
export * as mailgun from 'mailgun-js';
|
|
9
|
+
export * as mailjet from 'node-mailjet';
|
|
10
|
+
export * as math from 'mathjs';
|
|
11
|
+
export * as mysql from 'mysql2/promise';
|
|
12
|
+
export * as ping from 'ping';
|
|
13
|
+
export * as publicIp from 'public-ip';
|
|
14
|
+
export * as qs from 'qs';
|
|
15
|
+
export * as redis from 'ioredis';
|
|
16
|
+
export * as sentry from '@sentry/node';
|
|
17
|
+
export * as telesign from 'telesignsdk';
|
|
18
|
+
export * as twilio from 'twilio';
|
|
19
|
+
export * as uuid from 'uuid';
|
|
20
|
+
export * as winston from 'winston';
|
|
21
|
+
export * as winstonPapertrail from 'winston-papertrail-mproved';
|
|
22
|
+
export { default as colors } from 'colors/safe.js';
|
|
36
23
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
redis,
|
|
54
|
-
sentry,
|
|
55
|
-
telesign,
|
|
56
|
-
twilio,
|
|
57
|
-
uuid,
|
|
58
|
-
winston,
|
|
59
|
-
winstonPapertrail,
|
|
60
|
-
// features
|
|
61
|
-
cache,
|
|
62
|
-
dbio,
|
|
63
|
-
email,
|
|
64
|
-
encryption,
|
|
65
|
-
event,
|
|
66
|
-
network,
|
|
67
|
-
sentinel,
|
|
68
|
-
shell,
|
|
69
|
-
shot,
|
|
70
|
-
sms,
|
|
71
|
-
storage,
|
|
72
|
-
tape,
|
|
73
|
-
uoid,
|
|
74
|
-
utilitas,
|
|
75
|
-
};
|
|
24
|
+
// features
|
|
25
|
+
export * as cache from './lib/cache.mjs';
|
|
26
|
+
export * as dbio from './lib/dbio.mjs';
|
|
27
|
+
export * as email from './lib/email.mjs';
|
|
28
|
+
export * as encryption from './lib/encryption.mjs';
|
|
29
|
+
export * as event from './lib/event.mjs';
|
|
30
|
+
export * as network from './lib/network.mjs';
|
|
31
|
+
export * as sentinel from './lib/sentinel.mjs';
|
|
32
|
+
export * as shell from './lib/shell.mjs';
|
|
33
|
+
export * as shot from './lib/shot.mjs';
|
|
34
|
+
export * as sms from './lib/sms.mjs';
|
|
35
|
+
export * as storage from './lib/storage.mjs';
|
|
36
|
+
export * as tape from './lib/tape.mjs';
|
|
37
|
+
export * as uoid from './lib/uoid.mjs';
|
|
38
|
+
export * as utilitas from './lib/utilitas.mjs';
|
|
39
|
+
export * as default from './lib/utilitas.mjs';
|
package/lib/cache.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import utilitas from './utilitas.mjs';
|
|
1
|
+
import * as utilitas from './utilitas.mjs';
|
|
2
2
|
|
|
3
3
|
const log = (content) => { return utilitas.modLog(content, 'cache'); };
|
|
4
4
|
|
|
@@ -21,7 +21,7 @@ const init = async (options) => {
|
|
|
21
21
|
return redis;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
export
|
|
24
|
+
export {
|
|
25
25
|
init,
|
|
26
26
|
// set,
|
|
27
27
|
// get,
|
package/lib/dbio.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import utilitas from './utilitas.mjs';
|
|
1
|
+
import * as utilitas from './utilitas.mjs';
|
|
2
2
|
|
|
3
3
|
const defaultPort = 3306;
|
|
4
4
|
const orders = { '+': 'ASC', '-': 'DESC' };
|
|
@@ -261,7 +261,7 @@ const deleteAll = async (table, options) => {
|
|
|
261
261
|
return await execute(assembleDelete(table));
|
|
262
262
|
};
|
|
263
263
|
|
|
264
|
-
export
|
|
264
|
+
export {
|
|
265
265
|
assembleInsert,
|
|
266
266
|
assembleQuery,
|
|
267
267
|
assembleSet,
|
package/lib/email.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import utilitas from './utilitas.mjs';
|
|
1
|
+
import * as utilitas from './utilitas.mjs';
|
|
2
2
|
|
|
3
3
|
const log = (content) => { return utilitas.modLog(content, 'email'); };
|
|
4
4
|
|
|
@@ -88,7 +88,7 @@ const send = async (email, subject, text, html, args, options) => {
|
|
|
88
88
|
}, html ? { html } : {}));
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
export
|
|
91
|
+
export {
|
|
92
92
|
getSenderName,
|
|
93
93
|
init,
|
|
94
94
|
rawSend,
|
package/lib/encryption.mjs
CHANGED
package/lib/event.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
2
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
|
+
import * as utilitas from './utilitas.mjs';
|
|
3
4
|
import fs from 'fs';
|
|
4
5
|
import path from 'path';
|
|
5
|
-
import utilitas from './utilitas.mjs';
|
|
6
6
|
|
|
7
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
8
|
const jobs = {};
|
|
@@ -74,19 +74,17 @@ const load = async (module, options = {}) => {
|
|
|
74
74
|
|
|
75
75
|
const bulk = async (absDir, options) => {
|
|
76
76
|
options = options || {};
|
|
77
|
-
const pms = [];
|
|
78
77
|
log(`SERVICES: ${absDir}`);
|
|
79
|
-
(fs.readdirSync(absDir) || []).filter(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
const [files, pmsRun] = [(fs.readdirSync(absDir) || []).filter(
|
|
79
|
+
file => /\.mjs$/i.test(file) && !file.startsWith('.')
|
|
80
|
+
), []];
|
|
81
|
+
for (let file of files) {
|
|
83
82
|
const mod = await import(path.join(absDir, file));
|
|
84
|
-
if (mod.run) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return await Promise.all(pms);
|
|
83
|
+
if (!mod.run) { continue; }
|
|
84
|
+
mod.name = mod.name || file.replace(/^(.*)\.mjs$/i, '$1');
|
|
85
|
+
pmsRun.push(load(mod, options));
|
|
86
|
+
}
|
|
87
|
+
return await Promise.all(pmsRun);
|
|
90
88
|
};
|
|
91
89
|
|
|
92
90
|
const end = async () => {
|
|
@@ -103,7 +101,7 @@ const end = async () => {
|
|
|
103
101
|
log('Terminated.');
|
|
104
102
|
};
|
|
105
103
|
|
|
106
|
-
export
|
|
104
|
+
export {
|
|
107
105
|
bulk,
|
|
108
106
|
end,
|
|
109
107
|
list,
|
package/lib/network.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import * as shell from './shell.mjs';
|
|
2
|
+
import * as utilitas from './utilitas.mjs';
|
|
1
3
|
import fetch from 'node-fetch';
|
|
2
4
|
import geoIp from 'fast-geoip';
|
|
3
5
|
import libPing from 'ping';
|
|
4
6
|
import publicIp from 'public-ip';
|
|
5
|
-
import shell from './shell.mjs';
|
|
6
|
-
import utilitas from './utilitas.mjs';
|
|
7
7
|
|
|
8
8
|
const log = (content) => { return utilitas.modLog(content, 'network'); };
|
|
9
9
|
|
|
@@ -94,7 +94,7 @@ const getCurrentPosition = async () => {
|
|
|
94
94
|
return Object.assign(loc, { ip });
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
export
|
|
97
|
+
export {
|
|
98
98
|
getCurrentPosition,
|
|
99
99
|
httping,
|
|
100
100
|
pickFastestHost,
|
package/lib/sentinel.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import utilitas from './utilitas.mjs';
|
|
1
|
+
import * as utilitas from './utilitas.mjs';
|
|
2
2
|
|
|
3
3
|
const log = (str, opts) => { return utilitas.modLog(str, 'sentinel', opts); };
|
|
4
4
|
|
|
@@ -21,6 +21,6 @@ const init = async (options) => {
|
|
|
21
21
|
return sentry;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
export
|
|
24
|
+
export {
|
|
25
25
|
init,
|
|
26
26
|
};
|
package/lib/shell.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import * as utilitas from './utilitas.mjs';
|
|
1
2
|
import childProcess from 'child_process';
|
|
2
3
|
import util from 'util';
|
|
3
|
-
import utilitas from './utilitas.mjs';
|
|
4
4
|
|
|
5
5
|
const log = (content) => { return utilitas.modLog(content, 'shell'); };
|
|
6
6
|
const vF = (cmd, cbf) => { log(`Can not run in browser: ${cmd}`); cbf(); };
|
|
@@ -34,7 +34,7 @@ const assertExist = async (bin, er, code = 500) => {
|
|
|
34
34
|
utilitas.assert(await exist(bin), er || `Command not found: ${bin}.`, code);
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
export
|
|
37
|
+
export {
|
|
38
38
|
assertExist,
|
|
39
39
|
exec,
|
|
40
40
|
exist,
|
package/lib/shot.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fileType from 'file-type';
|
|
2
|
+
import * as storage from './storage.mjs';
|
|
3
|
+
import * as utilitas from './utilitas.mjs';
|
|
2
4
|
import fetch from 'node-fetch';
|
|
3
|
-
import storage from './storage.mjs';
|
|
4
|
-
import utilitas from './utilitas.mjs';
|
|
5
5
|
|
|
6
6
|
const defFetchOpt = { redirect: 'follow', follow: 3, timeout: 1000 * 10 };
|
|
7
7
|
|
|
@@ -67,7 +67,7 @@ const get = async (url, options) => {
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export
|
|
70
|
+
export {
|
|
71
71
|
checkVersion,
|
|
72
72
|
get,
|
|
73
73
|
getCurrentPosition,
|
package/lib/sms.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import * as utilitas from './utilitas.mjs';
|
|
1
2
|
import util from 'util';
|
|
2
|
-
import utilitas from './utilitas.mjs';
|
|
3
3
|
|
|
4
4
|
const defaultTeleSignApi = 'https://rest-api.telesign.com';
|
|
5
5
|
const defaultTimeout = 1000 * 10 // 10 secs
|
|
@@ -60,7 +60,7 @@ const send = async (phone, message) => {
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
export
|
|
63
|
+
export {
|
|
64
64
|
init,
|
|
65
65
|
send,
|
|
66
66
|
};
|
package/lib/storage.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import * as utilitas from './utilitas.mjs';
|
|
2
3
|
import fs from 'fs';
|
|
3
4
|
import ini from 'ini';
|
|
4
5
|
import os from 'os';
|
|
5
6
|
import path from 'path';
|
|
6
|
-
import utilitas from './utilitas.mjs';
|
|
7
7
|
|
|
8
8
|
const [encoding, mode] = ['utf8', '0644'];
|
|
9
9
|
|
|
@@ -149,7 +149,7 @@ const exists = async (fp) => {
|
|
|
149
149
|
try { return await fs.promises.stat(fp); } catch (_) { return null; }
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
-
export
|
|
152
|
+
export {
|
|
153
153
|
assertPath,
|
|
154
154
|
encodeBase64DataURL,
|
|
155
155
|
exists,
|
package/lib/tape.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import utilitas from './utilitas.mjs';
|
|
1
|
+
import * as utilitas from './utilitas.mjs';
|
|
2
2
|
|
|
3
3
|
// https://github.com/winstonjs/winston#logging-levels
|
|
4
4
|
// const levels = ['error', 'warn', 'info', 'http', 'verbose', 'debug', 'silly'];
|
|
@@ -88,7 +88,7 @@ const end = async () => {
|
|
|
88
88
|
}, 1000);
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
export
|
|
91
|
+
export {
|
|
92
92
|
end,
|
|
93
93
|
getLogger,
|
|
94
94
|
init,
|
package/lib/uoid.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
|
+
import * as encryption from './encryption.mjs';
|
|
3
|
+
import * as utilitas from './utilitas.mjs';
|
|
2
4
|
import * as uuid from 'uuid';
|
|
3
|
-
import encryption from './encryption.mjs';
|
|
4
|
-
import utilitas from './utilitas.mjs';
|
|
5
5
|
|
|
6
6
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
7
|
const uuidRegTxt = '[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}';
|
|
@@ -30,7 +30,7 @@ const getRfcUrlNamespaceUuid = (url) => {
|
|
|
30
30
|
return uuid.v5(url, uuid.v5.URL);
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
export
|
|
33
|
+
export {
|
|
34
34
|
uuidRegTxt,
|
|
35
35
|
create,
|
|
36
36
|
getRfcUrlNamespaceUuid,
|
package/lib/utilitas.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
|
+
import * as storage from './storage.mjs';
|
|
2
3
|
import colors from 'colors/safe.js';
|
|
3
4
|
import path from 'path';
|
|
4
|
-
import storage from './storage.mjs';
|
|
5
5
|
|
|
6
6
|
Object.values = Object.values || ((obj) => {
|
|
7
7
|
return Object.keys(obj).map((key) => {
|
|
@@ -613,7 +613,7 @@ const purgeEmoji = (any, replace = '') => {
|
|
|
613
613
|
);
|
|
614
614
|
};
|
|
615
615
|
|
|
616
|
-
export
|
|
616
|
+
export {
|
|
617
617
|
arrayEqual,
|
|
618
618
|
assembleApiUrl,
|
|
619
619
|
assembleUrl,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "utilitas",
|
|
3
3
|
"description": "Just another common utility for Node.js.",
|
|
4
|
-
"version": "1989.9.
|
|
4
|
+
"version": "1989.9.8",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/Leask/utilitas",
|
|
7
7
|
"main": "index.mjs",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@sentry/node": "^6.16.1",
|
|
26
26
|
"base64url": "^3.0.1",
|
|
27
27
|
"colors": "1.4.0",
|
|
28
|
-
"fast-geoip": "^1.1.
|
|
28
|
+
"fast-geoip": "^1.1.55",
|
|
29
29
|
"file-type": "^17.1.1",
|
|
30
30
|
"ini": "github:Leask/ini",
|
|
31
31
|
"ioredis": "^4.28.3",
|