@e-mc/types 0.5.4 → 0.6.1
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/LICENSE +1 -1
- package/README.md +1 -1
- package/constant.d.ts +13 -1
- package/index.js +42 -104
- package/lib/core.d.ts +1 -1
- package/lib/db.d.ts +1 -1
- package/lib/http.d.ts +7 -2
- package/lib/index.d.ts +4 -3
- package/lib/settings.d.ts +8 -0
- package/lib/squared.d.ts +3 -1
- package/lib/watch.d.ts +1 -0
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright 2023
|
|
1
|
+
Copyright 2023 Studio Trigger
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
package/constant.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const enum INTERNAL {
|
|
2
|
-
VERSION = '0.
|
|
2
|
+
VERSION = '0.6.1',
|
|
3
3
|
TEMP_DIR = 'tmp',
|
|
4
4
|
CJS = '__cjs__'
|
|
5
5
|
}
|
|
@@ -245,4 +245,16 @@ export const enum SETTINGS_KEY_NAME {
|
|
|
245
245
|
ERROR_FATAL = "error.fatal",
|
|
246
246
|
BROADCAST_OUT = "broadcast.out",
|
|
247
247
|
LOGGER_LEVEL = "logger.level"
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export const enum CACHE_SIZE {
|
|
251
|
+
CORE_CLIENTDB_PARTITION_SIZE = 16,
|
|
252
|
+
CORE_CLIENTDB_PARTITION_MULT = 2,
|
|
253
|
+
CLOUD_PARTITION_SIZE = 16,
|
|
254
|
+
CLOUD_PARTITION_MULT = 2,
|
|
255
|
+
DB_PARTITION_SIZE = 16,
|
|
256
|
+
DB_PARTITION_MULT = 2,
|
|
257
|
+
FILE_MANAGER_DISK_LIMIT = '1gb',
|
|
258
|
+
FILE_MANAGER_MEMORY_LIMIT = '100mb',
|
|
259
|
+
FILE_MANAGER_MEMORY_LIMIT_ALL = '512mb'
|
|
248
260
|
}
|
package/index.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateUUID = exports.randomString = exports.decryptUTF8 = exports.encryptUTF8 = exports.getEncoding = exports.asFunction = exports.coerceObject = exports.cloneObject = exports.cascadeObject = exports.
|
|
4
|
-
exports.generateUUID = exports.
|
|
3
|
+
exports.errorMessage = exports.errorValue = exports.validateUUID = exports.randomString = exports.decryptUTF8 = exports.encryptUTF8 = exports.getEncoding = exports.asFunction = exports.coerceObject = exports.cloneObject = exports.cascadeObject = exports.formatSize = exports.renameExt = exports.escapePattern = exports.hasGlob = exports.convertTime = exports.formatTime = exports.parseExpires = exports.parseTime = exports.isEmpty = exports.isString = exports.isObject = exports.isPlainObject = exports.isArray = exports.setTempDir = exports.getTempDir = exports.setLogCurrent = exports.getLogCurrent = exports.existsFlag = exports.mainFlag = exports.processFlag = exports.modifiedFlag = exports.watchFlag = exports.usingFlag = exports.cloneFlag = exports.ignoreFlag = exports.hasBit = exports.createAbortError = exports.THRESHOLD = exports.IMPORT_MAP = exports.WATCH_EVENT = exports.DB_TRANSACTION = exports.DB_TYPE = exports.FETCH_TYPE = exports.DOWNLOAD_TYPE = exports.ERR_CODE = exports.ASSET_FLAG = exports.FILE_TYPE = exports.STATUS_TYPE = exports.LOG_TYPE = void 0;
|
|
4
|
+
exports.generateUUID = exports.purgeMemory = void 0;
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const fs = require("fs");
|
|
7
7
|
const crypto = require("crypto");
|
|
8
|
+
const uuid = require("uuid");
|
|
8
9
|
const bytes = require("bytes");
|
|
9
10
|
class AbortError extends Error {
|
|
10
11
|
constructor() {
|
|
11
|
-
super("The operation was aborted"
|
|
12
|
+
super("The operation was aborted");
|
|
12
13
|
this.code = 'ABORT_ERR';
|
|
13
14
|
this.name = 'AbortError';
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
const REGEXP_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
17
|
-
const REGEXP_FUNCTION = /^(async\s+)?(function(?:\b|\s+)[\w_$]
|
|
18
|
-
const REGEXP_FUNCTION_ARROW = /^(async\s+)?(\s*\(([^)]*)\)\s*=>\s*(?:\{([\S\s]*)\}|(?!\s|{)((?:(?<!return\s+)(?:"[^"\n]*"|'[^'\n]*'|`[^`]*`|[^\n;"'`]))*;)))$/;
|
|
18
|
+
const REGEXP_FUNCTION = /^(async\s+)?(function(?:\b|\s+)([\w_$]*)\s*\(([^)]*)\)\s*\{([\S\s]*)\})$/;
|
|
19
19
|
const ASYNC_FUNCTION = Object.getPrototypeOf(async () => { }).constructor;
|
|
20
20
|
let CACHE_COERCED = new WeakSet();
|
|
21
21
|
let LOG_CURRENT = null;
|
|
22
|
-
let TEMP_DIR = path.join(process.cwd(), "tmp"
|
|
23
|
-
let INCREMENT_COUNT = 65536;
|
|
24
|
-
let INCREMENT_PREFIX = '';
|
|
22
|
+
let TEMP_DIR = path.join(process.cwd(), "tmp");
|
|
25
23
|
function fromObject(value, typedArray) {
|
|
26
24
|
if (isObject(value)) {
|
|
27
25
|
if (value instanceof Map) {
|
|
@@ -243,18 +241,6 @@ var WATCH_EVENT;
|
|
|
243
241
|
WATCH_EVENT["CLOSE"] = "close";
|
|
244
242
|
WATCH_EVENT["ERROR"] = "error";
|
|
245
243
|
})(WATCH_EVENT || (exports.WATCH_EVENT = WATCH_EVENT = {}));
|
|
246
|
-
var READDIR_SORT;
|
|
247
|
-
(function (READDIR_SORT) {
|
|
248
|
-
READDIR_SORT[READDIR_SORT["FILE"] = 0] = "FILE";
|
|
249
|
-
READDIR_SORT[READDIR_SORT["DIRECTORY"] = 1] = "DIRECTORY";
|
|
250
|
-
READDIR_SORT[READDIR_SORT["DESCENDING"] = 2] = "DESCENDING";
|
|
251
|
-
})(READDIR_SORT || (exports.READDIR_SORT = READDIR_SORT = {}));
|
|
252
|
-
var THRESHOLD;
|
|
253
|
-
(function (THRESHOLD) {
|
|
254
|
-
THRESHOLD[THRESHOLD["FILEMANAGER_INTERVAL"] = 100] = "FILEMANAGER_INTERVAL";
|
|
255
|
-
THRESHOLD[THRESHOLD["WATCH_INTERVAL"] = 500] = "WATCH_INTERVAL";
|
|
256
|
-
THRESHOLD[THRESHOLD["WATCH_CHANGE"] = 100] = "WATCH_CHANGE";
|
|
257
|
-
})(THRESHOLD || (exports.THRESHOLD = THRESHOLD = {}));
|
|
258
244
|
var IMPORT_MAP;
|
|
259
245
|
(function (IMPORT_MAP) {
|
|
260
246
|
IMPORT_MAP["@squared-functions/cloud"] = "@e-mc/cloud";
|
|
@@ -322,8 +308,8 @@ var IMPORT_MAP;
|
|
|
322
308
|
IMPORT_MAP["@squared-functions/document/packages/@babel/core"] = "@pi-r/babel";
|
|
323
309
|
IMPORT_MAP["@squared-functions/document/packages/clean-css"] = "@pi-r/clean-css";
|
|
324
310
|
IMPORT_MAP["@squared-functions/document/packages/eslint"] = "@pi-r/eslint";
|
|
325
|
-
IMPORT_MAP["@squared-functions/document/packages/html-minifier"] = "@pi-r/html-minifier";
|
|
326
311
|
IMPORT_MAP["@squared-functions/document/packages/html-minifier-terser"] = "@pi-r/html-minifier-terser";
|
|
312
|
+
IMPORT_MAP["@squared-functions/document/packages/html-minifier"] = "@pi-r/html-minifier";
|
|
327
313
|
IMPORT_MAP["@squared-functions/document/packages/html-validate"] = "@pi-r/html-validate";
|
|
328
314
|
IMPORT_MAP["@squared-functions/document/packages/postcss"] = "@pi-r/postcss";
|
|
329
315
|
IMPORT_MAP["@squared-functions/document/packages/posthtml"] = "@pi-r/posthtml";
|
|
@@ -335,6 +321,12 @@ var IMPORT_MAP;
|
|
|
335
321
|
IMPORT_MAP["@squared-functions/document/packages/terser"] = "@pi-r/terser";
|
|
336
322
|
IMPORT_MAP["@squared-functions/document/packages/uglify-js"] = "@pi-r/uglify-js";
|
|
337
323
|
})(IMPORT_MAP || (exports.IMPORT_MAP = IMPORT_MAP = {}));
|
|
324
|
+
var THRESHOLD;
|
|
325
|
+
(function (THRESHOLD) {
|
|
326
|
+
THRESHOLD[THRESHOLD["FILEMANAGER_INTERVAL"] = 100] = "FILEMANAGER_INTERVAL";
|
|
327
|
+
THRESHOLD[THRESHOLD["WATCH_INTERVAL"] = 500] = "WATCH_INTERVAL";
|
|
328
|
+
THRESHOLD[THRESHOLD["WATCH_CHANGE"] = 100] = "WATCH_CHANGE";
|
|
329
|
+
})(THRESHOLD || (exports.THRESHOLD = THRESHOLD = {}));
|
|
338
330
|
function createAbortError() {
|
|
339
331
|
return new AbortError();
|
|
340
332
|
}
|
|
@@ -344,35 +336,35 @@ function hasBit(value, flags) {
|
|
|
344
336
|
}
|
|
345
337
|
exports.hasBit = hasBit;
|
|
346
338
|
function ignoreFlag(value) {
|
|
347
|
-
return typeof value === 'number' && (value & 1
|
|
339
|
+
return typeof value === 'number' && (value & 1) === 1;
|
|
348
340
|
}
|
|
349
341
|
exports.ignoreFlag = ignoreFlag;
|
|
350
342
|
function cloneFlag(value) {
|
|
351
|
-
return typeof value === 'number' && (value & 2
|
|
343
|
+
return typeof value === 'number' && (value & 2) === 2;
|
|
352
344
|
}
|
|
353
345
|
exports.cloneFlag = cloneFlag;
|
|
354
346
|
function usingFlag(value) {
|
|
355
|
-
return typeof value === 'number' && (value & 4
|
|
347
|
+
return typeof value === 'number' && (value & 4) === 4;
|
|
356
348
|
}
|
|
357
349
|
exports.usingFlag = usingFlag;
|
|
358
350
|
function watchFlag(value) {
|
|
359
|
-
return typeof value === 'number' && (value & 8
|
|
351
|
+
return typeof value === 'number' && (value & 8) === 8;
|
|
360
352
|
}
|
|
361
353
|
exports.watchFlag = watchFlag;
|
|
362
354
|
function modifiedFlag(value) {
|
|
363
|
-
return typeof value === 'number' && (value & 16
|
|
355
|
+
return typeof value === 'number' && (value & 16) === 16;
|
|
364
356
|
}
|
|
365
357
|
exports.modifiedFlag = modifiedFlag;
|
|
366
358
|
function processFlag(value) {
|
|
367
|
-
return typeof value === 'number' && (value & 32
|
|
359
|
+
return typeof value === 'number' && (value & 32) === 32;
|
|
368
360
|
}
|
|
369
361
|
exports.processFlag = processFlag;
|
|
370
362
|
function mainFlag(value) {
|
|
371
|
-
return typeof value === 'number' && (value & 64
|
|
363
|
+
return typeof value === 'number' && (value & 64) === 64;
|
|
372
364
|
}
|
|
373
365
|
exports.mainFlag = mainFlag;
|
|
374
366
|
function existsFlag(value) {
|
|
375
|
-
return typeof value === 'number' && (value & 128
|
|
367
|
+
return typeof value === 'number' && (value & 128) === 128;
|
|
376
368
|
}
|
|
377
369
|
exports.existsFlag = existsFlag;
|
|
378
370
|
function getLogCurrent() {
|
|
@@ -404,7 +396,7 @@ function isArray(value) {
|
|
|
404
396
|
}
|
|
405
397
|
exports.isArray = isArray;
|
|
406
398
|
function isPlainObject(value) {
|
|
407
|
-
return typeof value === 'object'
|
|
399
|
+
return value && typeof value === 'object' ? value.constructor === Object || Object.getPrototypeOf(value) === null : false;
|
|
408
400
|
}
|
|
409
401
|
exports.isPlainObject = isPlainObject;
|
|
410
402
|
function isObject(value) {
|
|
@@ -431,25 +423,25 @@ function parseTime(value, start = 0) {
|
|
|
431
423
|
}
|
|
432
424
|
switch (match[2]) {
|
|
433
425
|
case 'y':
|
|
434
|
-
result += n * 31449600000
|
|
426
|
+
result += n * 31449600000;
|
|
435
427
|
break;
|
|
436
428
|
case 'M':
|
|
437
|
-
result += n * 2592000000
|
|
429
|
+
result += n * 2592000000;
|
|
438
430
|
break;
|
|
439
431
|
case 'w':
|
|
440
|
-
result += n * 604800000
|
|
432
|
+
result += n * 604800000;
|
|
441
433
|
break;
|
|
442
434
|
case 'd':
|
|
443
|
-
result += n * 86400000
|
|
435
|
+
result += n * 86400000;
|
|
444
436
|
break;
|
|
445
437
|
case 'h':
|
|
446
|
-
result += n * 3600000
|
|
438
|
+
result += n * 3600000;
|
|
447
439
|
break;
|
|
448
440
|
case 'm':
|
|
449
|
-
result += n * 60000
|
|
441
|
+
result += n * 60000;
|
|
450
442
|
break;
|
|
451
443
|
case 's':
|
|
452
|
-
result += n * 1000
|
|
444
|
+
result += n * 1000;
|
|
453
445
|
break;
|
|
454
446
|
case 'ms':
|
|
455
447
|
result += Math.ceil(n);
|
|
@@ -461,7 +453,7 @@ function parseTime(value, start = 0) {
|
|
|
461
453
|
}
|
|
462
454
|
}
|
|
463
455
|
else if (seconds > 0) {
|
|
464
|
-
return Math.ceil(seconds * 1000
|
|
456
|
+
return Math.ceil(seconds * 1000) + start;
|
|
465
457
|
}
|
|
466
458
|
return 0;
|
|
467
459
|
}
|
|
@@ -484,18 +476,18 @@ function formatTime(value, elapsed, char = ' ') {
|
|
|
484
476
|
if (value < 1000) {
|
|
485
477
|
return value + 'ms';
|
|
486
478
|
}
|
|
487
|
-
const h = Math.floor(value / 3600000
|
|
479
|
+
const h = Math.floor(value / 3600000);
|
|
488
480
|
if (h > 0) {
|
|
489
|
-
value -= h * 3600000
|
|
481
|
+
value -= h * 3600000;
|
|
490
482
|
result.push(h + 'h');
|
|
491
483
|
}
|
|
492
|
-
const m = Math.floor(value / 60000
|
|
484
|
+
const m = Math.floor(value / 60000);
|
|
493
485
|
if (m > 0) {
|
|
494
|
-
value -= m * 60000
|
|
486
|
+
value -= m * 60000;
|
|
495
487
|
result.push(m + 'm');
|
|
496
488
|
}
|
|
497
489
|
if (value > 0) {
|
|
498
|
-
result.push(value < 100 ? value + 'ms' : (value / 1000
|
|
490
|
+
result.push(value < 100 ? value + 'ms' : (value / 1000).toPrecision(value <= 9950 ? 2 : 3).replace(/\.?0+$/, '') + 's');
|
|
499
491
|
}
|
|
500
492
|
return result.join(char);
|
|
501
493
|
}
|
|
@@ -571,40 +563,9 @@ function renameExt(value, ext, when) {
|
|
|
571
563
|
}
|
|
572
564
|
exports.renameExt = renameExt;
|
|
573
565
|
function formatSize(value, options) {
|
|
574
|
-
|
|
575
|
-
return (bytes(value, options) || ('0' + (options?.unitSeparator || '') + 'B'));
|
|
576
|
-
}
|
|
577
|
-
return (bytes(value) || 0);
|
|
566
|
+
return (typeof value === 'number' ? bytes(value, options) : bytes(value));
|
|
578
567
|
}
|
|
579
568
|
exports.formatSize = formatSize;
|
|
580
|
-
function alignSize(value, kb = 0, factor = 0) {
|
|
581
|
-
if (value === undefined) {
|
|
582
|
-
return NaN;
|
|
583
|
-
}
|
|
584
|
-
let result = 0;
|
|
585
|
-
switch (typeof value) {
|
|
586
|
-
case 'number':
|
|
587
|
-
if (value < 0) {
|
|
588
|
-
return NaN;
|
|
589
|
-
}
|
|
590
|
-
result = Math.ceil(factor > 0 ? value * Math.pow(1024, factor) : value);
|
|
591
|
-
break;
|
|
592
|
-
case 'string':
|
|
593
|
-
result = formatSize(value);
|
|
594
|
-
if (result < 0) {
|
|
595
|
-
return NaN;
|
|
596
|
-
}
|
|
597
|
-
break;
|
|
598
|
-
default:
|
|
599
|
-
return NaN;
|
|
600
|
-
}
|
|
601
|
-
if (kb > 0) {
|
|
602
|
-
kb = Math.ceil(kb) * 1024;
|
|
603
|
-
return Math.ceil(result / kb) * kb;
|
|
604
|
-
}
|
|
605
|
-
return result;
|
|
606
|
-
}
|
|
607
|
-
exports.alignSize = alignSize;
|
|
608
569
|
function cascadeObject(data, query, fallback) {
|
|
609
570
|
if (isObject(data) && isString(query)) {
|
|
610
571
|
const names = query.trim().split(/(?<!\\)\./).map(item => item.includes('.') ? item.replace(/\\(?=\.)/g, '') : item);
|
|
@@ -762,7 +723,7 @@ function coerceObject(data, parseString, cache) {
|
|
|
762
723
|
}
|
|
763
724
|
default: {
|
|
764
725
|
const text = match[2].trim();
|
|
765
|
-
let values = [];
|
|
726
|
+
let values = [];
|
|
766
727
|
if (text.startsWith('[') && text.endsWith(']')) {
|
|
767
728
|
values = JSON.parse(text);
|
|
768
729
|
}
|
|
@@ -836,10 +797,10 @@ function asFunction(value, sync = true) {
|
|
|
836
797
|
return value;
|
|
837
798
|
}
|
|
838
799
|
let match;
|
|
839
|
-
if (isString(value) && (match = REGEXP_FUNCTION.exec(value = value.trim())
|
|
800
|
+
if (isString(value) && (match = REGEXP_FUNCTION.exec(value = value.trim()))) {
|
|
840
801
|
if (!sync || match[1]) {
|
|
841
|
-
const args = match[
|
|
842
|
-
args.push(match[
|
|
802
|
+
const args = match[4].trim().split(/\s*,\s*/);
|
|
803
|
+
args.push(match[5]);
|
|
843
804
|
return new ASYNC_FUNCTION(...args);
|
|
844
805
|
}
|
|
845
806
|
try {
|
|
@@ -855,22 +816,7 @@ function asFunction(value, sync = true) {
|
|
|
855
816
|
}
|
|
856
817
|
exports.asFunction = asFunction;
|
|
857
818
|
function getEncoding(value, fallback = 'utf-8') {
|
|
858
|
-
|
|
859
|
-
switch (value = value.trim().toLowerCase()) {
|
|
860
|
-
case 'utf8':
|
|
861
|
-
case 'utf-8':
|
|
862
|
-
case 'utf16le':
|
|
863
|
-
return value;
|
|
864
|
-
case 'utf-16le':
|
|
865
|
-
case 'utf16':
|
|
866
|
-
case 'utf-16':
|
|
867
|
-
return 'utf16le';
|
|
868
|
-
}
|
|
869
|
-
if (Buffer.isEncoding(value)) {
|
|
870
|
-
return value;
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
return fallback;
|
|
819
|
+
return typeof value === 'string' && Buffer.isEncoding(value = value.trim().toLowerCase()) ? value : fallback;
|
|
874
820
|
}
|
|
875
821
|
exports.getEncoding = getEncoding;
|
|
876
822
|
function encryptUTF8(algorithm, key, iv, data, encoding = 'hex') {
|
|
@@ -955,12 +901,4 @@ function purgeMemory(percent) {
|
|
|
955
901
|
CACHE_COERCED = new WeakSet();
|
|
956
902
|
}
|
|
957
903
|
exports.purgeMemory = purgeMemory;
|
|
958
|
-
function
|
|
959
|
-
if (restart || INCREMENT_COUNT === 65536) {
|
|
960
|
-
INCREMENT_COUNT = 0;
|
|
961
|
-
INCREMENT_PREFIX = (0, exports.generateUUID)().substring(0, 33);
|
|
962
|
-
}
|
|
963
|
-
return INCREMENT_PREFIX + (INCREMENT_COUNT++).toString(16).padStart(4, '0');
|
|
964
|
-
}
|
|
965
|
-
exports.incrementUUID = incrementUUID;
|
|
966
|
-
exports.generateUUID = typeof crypto.randomUUID === 'function' ? crypto.randomUUID.bind(crypto) : require('uuid').v4;
|
|
904
|
+
exports.generateUUID = typeof crypto.randomUUID === 'function' ? crypto.randomUUID.bind(crypto) : uuid.v4;
|
package/lib/core.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface IdentifierAction {
|
|
|
12
12
|
uuidKey?: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export interface IClient<T extends IHost, U extends ClientModule, V extends FunctionType = FunctionType> extends IModule<T>, IExternalConfig<U, U extends ClientModule<infer W> ? W : unknown>, IExternalFunction<V> {
|
|
15
|
+
export interface IClient<T extends IHost, U extends ClientModule, V extends FunctionType<any, any> = FunctionType> extends IModule<T>, IExternalConfig<U, U extends ClientModule<infer W> ? W : unknown>, IExternalFunction<V> {
|
|
16
16
|
init(...args: unknown[]): this;
|
|
17
17
|
set cacheDir(value: string);
|
|
18
18
|
get cacheDir(): string;
|
package/lib/db.d.ts
CHANGED
|
@@ -97,7 +97,7 @@ export interface TimeoutAction {
|
|
|
97
97
|
timeout?: NumString;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
export type DbSource = "mongodb" | "
|
|
100
|
+
export type DbSource = "mariadb" | "mongodb" | "mssql" | "mysql" | "oracle" | "postgres" | "redis";
|
|
101
101
|
export type QueryResult = unknown[];
|
|
102
102
|
export type BatchQueryResult = Null<QueryResult>[];
|
|
103
103
|
export type CheckObjectCallback = (item: DataSource, data: unknown) => Null<QueryResult>;
|
package/lib/http.d.ts
CHANGED
|
@@ -50,6 +50,8 @@ export const enum HTTP_STATUS {
|
|
|
50
50
|
TOO_MANY_REQUESTS = 429,
|
|
51
51
|
REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
|
|
52
52
|
UNAVAILABLE_FOR_LEGAL_REASONS = 451,
|
|
53
|
+
SSL_CERTIFICATE_ERROR = 495,
|
|
54
|
+
SSL_CERTIFICATE_REQUIRED = 496,
|
|
53
55
|
CLIENT_CLOSED_REQUEST = 499,
|
|
54
56
|
INTERNAL_SERVER_ERROR = 500,
|
|
55
57
|
NOT_IMPLEMENTED = 501,
|
|
@@ -64,7 +66,10 @@ export const enum HTTP_STATUS {
|
|
|
64
66
|
NETWORK_AUTHENTICATION_REQUIRED = 511,
|
|
65
67
|
WEB_SERVER_IS_DOWN = 521,
|
|
66
68
|
CONNECTION_TIMED_OUT = 522,
|
|
67
|
-
|
|
69
|
+
ORIGIN_IS_UNREACHABLE = 523,
|
|
70
|
+
A_TIMEOUT_OCCURRED = 524,
|
|
71
|
+
SSL_HANDSHAKE_FAILED = 525,
|
|
72
|
+
INVALID_SSL_CERTIFICATE = 526
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
export const enum QUERY_RESULT {
|
|
@@ -84,4 +89,4 @@ export type HttpRequestClient = ClientRequest | ClientHttp2Stream;
|
|
|
84
89
|
export type HttpOutgoingHeaders = ObjectMap<OutgoingHttpHeaders>;
|
|
85
90
|
export type HttpProtocolVersion = 1 | 2 | 3;
|
|
86
91
|
export type InternetProtocolVersion = 0 | 4 | 6;
|
|
87
|
-
export type LookupCallback = (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family?: number) => void;
|
|
92
|
+
export type LookupCallback = (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family?: number) => void;
|
package/lib/index.d.ts
CHANGED
|
@@ -206,7 +206,6 @@ declare namespace functions {
|
|
|
206
206
|
Db: Null<IDb>;
|
|
207
207
|
assets: U[];
|
|
208
208
|
config: StandardMap;
|
|
209
|
-
imports?: StringMap;
|
|
210
209
|
init(assets: U[], config?: HostInitConfig): this;
|
|
211
210
|
customize(options?: CustomizeDocument): void;
|
|
212
211
|
findConfig(data: object, name: string, type?: string): PluginConfig;
|
|
@@ -241,6 +240,8 @@ declare namespace functions {
|
|
|
241
240
|
watchModified?(watch: IFileGroup<U>, assets?: U[]): PostFinalizeCallback;
|
|
242
241
|
set dataSource(value: DataSource[]);
|
|
243
242
|
get dataSource(): DataSource[];
|
|
243
|
+
set imports(value);
|
|
244
|
+
get imports(): StringMap;
|
|
244
245
|
get watching(): boolean;
|
|
245
246
|
}
|
|
246
247
|
|
|
@@ -280,8 +281,8 @@ declare namespace functions {
|
|
|
280
281
|
}
|
|
281
282
|
|
|
282
283
|
interface WatchConstructor<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset, V extends WatchModule = WatchModule, W extends FunctionType<unknown, any> = ModifiedPostFinalizeListener<U>> extends ModuleConstructor {
|
|
283
|
-
createServer(port: number, active: boolean):
|
|
284
|
-
createServer(port: number, secure?: Null<SecureOptions>, active?: boolean):
|
|
284
|
+
createServer(port: number, active: boolean): Null<ws.Server>;
|
|
285
|
+
createServer(port: number, secure?: Null<SecureOptions>, active?: boolean): Null<ws.Server>;
|
|
285
286
|
shutdown(): void;
|
|
286
287
|
setTimeout(value: NumString): void;
|
|
287
288
|
checkTimeout(client: ws): boolean;
|
package/lib/settings.d.ts
CHANGED
|
@@ -89,6 +89,7 @@ export interface DownloadModule<T = PlainObject> extends HandlerSettings<T> {
|
|
|
89
89
|
expires?: NumString;
|
|
90
90
|
aria2?: {
|
|
91
91
|
bin?: string | false;
|
|
92
|
+
exec?: ExecAction;
|
|
92
93
|
update_status?: NumString | { interval?: NumString; broadcast_only?: boolean };
|
|
93
94
|
max_concurrent_downloads?: NumString;
|
|
94
95
|
max_connection_per_server?: NumString;
|
|
@@ -121,6 +122,7 @@ export interface DocumentGroup<T = { imports?: StringMap } & AnyObject, U = T> {
|
|
|
121
122
|
transform?: T;
|
|
122
123
|
view_engine?: U;
|
|
123
124
|
pages?: ObjectMap<AnyObject>;
|
|
125
|
+
imports?: StringMap;
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
export interface DocumentComponent<T = boolean, U = T, V = U> extends Omit<DocumentGroup<T, U>, "pages"> {
|
|
@@ -149,6 +151,7 @@ export type DocumentComponentOptions = DocumentComponent<DocumentComponentOption
|
|
|
149
151
|
export interface ClientDBSettings extends ClientSettings, PurgeAction {
|
|
150
152
|
session_expires?: number;
|
|
151
153
|
user_key?: ObjectMap<DbSourceOptions>;
|
|
154
|
+
imports?: StringMap;
|
|
152
155
|
}
|
|
153
156
|
|
|
154
157
|
export interface MemoryModule<T = MemorySettings> extends HandlerSettings<T>, Record<string, Undef<T | ObjectMap<PurgeBase>>> {}
|
|
@@ -419,6 +422,11 @@ export interface ExecOptions extends SpawnOptions {
|
|
|
419
422
|
warn?: StringOfArray;
|
|
420
423
|
}
|
|
421
424
|
|
|
425
|
+
export interface ExecAction {
|
|
426
|
+
uid?: NumString;
|
|
427
|
+
gid?: NumString;
|
|
428
|
+
}
|
|
429
|
+
|
|
422
430
|
export interface PurgeAction {
|
|
423
431
|
purge?: PurgeComponent;
|
|
424
432
|
}
|
package/lib/squared.d.ts
CHANGED
|
@@ -222,7 +222,8 @@ export interface CompressFormat extends CompressLevel {
|
|
|
222
222
|
|
|
223
223
|
export interface WatchInterval<T = FileAsset> {
|
|
224
224
|
id?: string;
|
|
225
|
-
interval?:
|
|
225
|
+
interval?: NumString;
|
|
226
|
+
start?: NumString;
|
|
226
227
|
expires?: NumString;
|
|
227
228
|
main?: boolean;
|
|
228
229
|
reload?: WatchReload;
|
|
@@ -238,6 +239,7 @@ export interface WebSocketResponse {
|
|
|
238
239
|
event?: string;
|
|
239
240
|
socketId?: StringOfArray;
|
|
240
241
|
type?: string;
|
|
242
|
+
encoding?: BufferEncoding;
|
|
241
243
|
value?: unknown;
|
|
242
244
|
timeStamp?: number;
|
|
243
245
|
status?: LogStatus[];
|
package/lib/watch.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ export interface IFileGroup<T extends ExternalAsset = ExternalAsset> extends IAb
|
|
|
50
50
|
set lastModified(value: unknown);
|
|
51
51
|
get lastModified(): string;
|
|
52
52
|
get expires(): number;
|
|
53
|
+
get started(): boolean;
|
|
53
54
|
get expired(): boolean;
|
|
54
55
|
get paused(): boolean;
|
|
55
56
|
get abortable(): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Type definitions for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "
|
|
12
|
+
"url": "https://github.com/anpham6/e-mc.git",
|
|
13
13
|
"directory": "src/types"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
"uuid": "^9.0.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"typescript": "5.
|
|
27
|
+
"typescript": "5.1.6"
|
|
28
28
|
}
|
|
29
29
|
}
|