utilitas 1989.9.5 → 1989.9.9
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 -75
- 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 +6 -4
- 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 +6 -4
- package/lib/utilitas.mjs +5 -3
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1,76 +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
|
-
utilitas as default,
|
|
64
|
-
email,
|
|
65
|
-
encryption,
|
|
66
|
-
event,
|
|
67
|
-
network,
|
|
68
|
-
sentinel,
|
|
69
|
-
shell,
|
|
70
|
-
shot,
|
|
71
|
-
sms,
|
|
72
|
-
storage,
|
|
73
|
-
tape,
|
|
74
|
-
uoid,
|
|
75
|
-
utilitas,
|
|
76
|
-
};
|
|
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,10 @@
|
|
|
1
|
-
import { fileURLToPath } from 'url';
|
|
2
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import * as utilitas from './utilitas.mjs';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import path from 'path';
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
const fileURLToPath = (await import('url')).fileURLToPath
|
|
7
|
+
|| ((url) => { return new URL('', url).pathname; });
|
|
6
8
|
|
|
7
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
10
|
const jobs = {};
|
|
@@ -79,7 +81,7 @@ const bulk = async (absDir, options) => {
|
|
|
79
81
|
file => /\.mjs$/i.test(file) && !file.startsWith('.')
|
|
80
82
|
), []];
|
|
81
83
|
for (let file of files) {
|
|
82
|
-
const mod =
|
|
84
|
+
const mod = await import(path.join(absDir, file));
|
|
83
85
|
if (!mod.run) { continue; }
|
|
84
86
|
mod.name = mod.name || file.replace(/^(.*)\.mjs$/i, '$1');
|
|
85
87
|
pmsRun.push(load(mod, options));
|
|
@@ -101,7 +103,7 @@ const end = async () => {
|
|
|
101
103
|
log('Terminated.');
|
|
102
104
|
};
|
|
103
105
|
|
|
104
|
-
export
|
|
106
|
+
export {
|
|
105
107
|
bulk,
|
|
106
108
|
end,
|
|
107
109
|
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,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as encryption from './encryption.mjs';
|
|
2
|
+
import * as utilitas from './utilitas.mjs';
|
|
2
3
|
import * as uuid from 'uuid';
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
const fileURLToPath = (await import('url')).fileURLToPath
|
|
6
|
+
|| ((url) => { return new URL('', url).pathname; });
|
|
5
7
|
|
|
6
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
9
|
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 +32,7 @@ const getRfcUrlNamespaceUuid = (url) => {
|
|
|
30
32
|
return uuid.v5(url, uuid.v5.URL);
|
|
31
33
|
};
|
|
32
34
|
|
|
33
|
-
export
|
|
35
|
+
export {
|
|
34
36
|
uuidRegTxt,
|
|
35
37
|
create,
|
|
36
38
|
getRfcUrlNamespaceUuid,
|
package/lib/utilitas.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as storage from './storage.mjs';
|
|
2
2
|
import colors from 'colors/safe.js';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import storage from './storage.mjs';
|
|
5
4
|
|
|
6
5
|
Object.values = Object.values || ((obj) => {
|
|
7
6
|
return Object.keys(obj).map((key) => {
|
|
@@ -13,6 +12,9 @@ RegExp.escape = RegExp.escape || ((str) => { //$& means the whole matched string
|
|
|
13
12
|
return String(str).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
14
13
|
}); // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
|
|
15
14
|
|
|
15
|
+
const fileURLToPath = (await import('url')).fileURLToPath
|
|
16
|
+
|| ((url) => { return new URL('', url).pathname; });
|
|
17
|
+
|
|
16
18
|
const __filename = fileURLToPath(import.meta.url);
|
|
17
19
|
const invalidTime = 'Invalid time.';
|
|
18
20
|
|
|
@@ -613,7 +615,7 @@ const purgeEmoji = (any, replace = '') => {
|
|
|
613
615
|
);
|
|
614
616
|
};
|
|
615
617
|
|
|
616
|
-
export
|
|
618
|
+
export {
|
|
617
619
|
arrayEqual,
|
|
618
620
|
assembleApiUrl,
|
|
619
621
|
assembleUrl,
|