@e-mc/types 0.10.6 → 0.11.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 +12 -10
- package/constant.d.ts +39 -10
- package/index.d.ts +35 -20
- package/index.js +86 -114
- package/lib/asset.d.ts +3 -3
- package/lib/cloud.d.ts +11 -4
- package/lib/compress.d.ts +12 -11
- package/lib/core.d.ts +31 -30
- package/lib/db.d.ts +20 -17
- package/lib/document.d.ts +17 -16
- package/lib/filemanager.d.ts +12 -11
- package/lib/http.d.ts +7 -6
- package/lib/image.d.ts +53 -43
- package/lib/index.d.ts +195 -170
- package/lib/logger.d.ts +7 -2
- package/lib/module.d.ts +31 -44
- package/lib/node.d.ts +9 -3
- package/lib/object.d.ts +1 -3
- package/lib/request.d.ts +96 -24
- package/lib/settings.d.ts +126 -90
- package/lib/squared.d.ts +26 -57
- package/lib/type.d.ts +11 -6
- package/lib/watch.d.ts +5 -5
- package/package.json +4 -3
- package/lib/compat-v4.d.ts +0 -116
package/index.js
CHANGED
|
@@ -44,11 +44,11 @@ exports.incrementUUID = incrementUUID;
|
|
|
44
44
|
exports.hashKey = hashKey;
|
|
45
45
|
exports.supported = supported;
|
|
46
46
|
exports.importESM = importESM;
|
|
47
|
-
const path = require("path");
|
|
48
|
-
const fs = require("fs");
|
|
49
|
-
const crypto = require("crypto");
|
|
47
|
+
const path = require("node:path");
|
|
48
|
+
const fs = require("node:fs");
|
|
49
|
+
const crypto = require("node:crypto");
|
|
50
50
|
const bytes = require("bytes");
|
|
51
|
-
const
|
|
51
|
+
const node_url_1 = require("node:url");
|
|
52
52
|
class AbortError extends Error {
|
|
53
53
|
constructor() {
|
|
54
54
|
super("This operation was aborted");
|
|
@@ -63,6 +63,21 @@ class AbortError extends Error {
|
|
|
63
63
|
return 20;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
const PATTERN_CHARS = {
|
|
67
|
+
'&': '\\x26',
|
|
68
|
+
'!': '\\x21',
|
|
69
|
+
'#': '\\x23',
|
|
70
|
+
'%': '\\x25',
|
|
71
|
+
',': '\\x2c',
|
|
72
|
+
':': '\\x3a',
|
|
73
|
+
';': '\\x3b',
|
|
74
|
+
'<': '\\x3c',
|
|
75
|
+
'=': '\\x3d',
|
|
76
|
+
'>': '\\x3e',
|
|
77
|
+
'@': '\\x40',
|
|
78
|
+
'`': '\\x60',
|
|
79
|
+
'~': '\\x7e'
|
|
80
|
+
};
|
|
66
81
|
const [VER_MAJOR, VER_MINOR, VER_PATCH] = process.version.substring(1).split('.').map(value => +value);
|
|
67
82
|
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;
|
|
68
83
|
const REGEXP_FUNCTION = /^(async\s+)?(function(?:\b|\s+)[\w_$]*\s*\(([^)]*)\)\s*\{(.*)\})$/s;
|
|
@@ -91,6 +106,9 @@ function fromObject(value, typedArray) {
|
|
|
91
106
|
if (value instanceof RegExp) {
|
|
92
107
|
return new RegExp(value);
|
|
93
108
|
}
|
|
109
|
+
if (value instanceof URL) {
|
|
110
|
+
return new URL(value);
|
|
111
|
+
}
|
|
94
112
|
if (typedArray) {
|
|
95
113
|
if (value instanceof Buffer) {
|
|
96
114
|
return Buffer.from(value);
|
|
@@ -331,6 +349,12 @@ function parseStringDefault(value) {
|
|
|
331
349
|
}
|
|
332
350
|
return null;
|
|
333
351
|
}
|
|
352
|
+
function checkFlags(value, flags) {
|
|
353
|
+
if (isObject(value)) {
|
|
354
|
+
value = value.flags;
|
|
355
|
+
}
|
|
356
|
+
return typeof value === 'number' && (value & flags) === flags;
|
|
357
|
+
}
|
|
334
358
|
const padStart = (value, char) => value > 9 ? value.toString() : char + value;
|
|
335
359
|
const convertScrypt = (key, iv, data) => crypto.scryptSync(key, iv, Math.ceil(data.length / 16) * 16);
|
|
336
360
|
const isFunction = (value) => typeof value === 'function';
|
|
@@ -455,83 +479,6 @@ var THRESHOLD;
|
|
|
455
479
|
THRESHOLD[THRESHOLD["WATCH_CHANGE"] = 100] = "WATCH_CHANGE";
|
|
456
480
|
})(THRESHOLD || (exports.THRESHOLD = THRESHOLD = {}));
|
|
457
481
|
exports.IMPORT_MAP = {
|
|
458
|
-
"@squared-functions/cloud": "@e-mc/cloud",
|
|
459
|
-
"@squared-functions/cloud/util": "@e-mc/cloud/util",
|
|
460
|
-
"@squared-functions/compress-v3": "@e-mc/compress",
|
|
461
|
-
"@squared-functions/core": "@e-mc/core",
|
|
462
|
-
"@squared-functions/db": "@e-mc/db",
|
|
463
|
-
"@squared-functions/db/pool": "@e-mc/db/pool",
|
|
464
|
-
"@squared-functions/db/util": "@e-mc/db/util",
|
|
465
|
-
"@squared-functions/document": "@e-mc/document",
|
|
466
|
-
"@squared-functions/document/parse": "@e-mc/document/parse",
|
|
467
|
-
"@squared-functions/document/parse/dom": "@e-mc/document/parse/dom",
|
|
468
|
-
"@squared-functions/document/transform": "@e-mc/document/transform",
|
|
469
|
-
"@squared-functions/document/asset": "@e-mc/document/asset",
|
|
470
|
-
"@squared-functions/document/util": "@e-mc/document/util",
|
|
471
|
-
"@squared-functions/file-manager": "@e-mc/file-manager",
|
|
472
|
-
"@squared-functions/file-manager/http/host": "@e-mc/request/http/host",
|
|
473
|
-
"@squared-functions/image-v3": "@e-mc/image",
|
|
474
|
-
"@squared-functions/module": "@e-mc/module",
|
|
475
|
-
"@squared-functions/task": "@e-mc/task",
|
|
476
|
-
"@squared-functions/types": "@e-mc/types",
|
|
477
|
-
"@squared-functions/watch": "@e-mc/watch",
|
|
478
|
-
"@squared-functions/watch/filegroup": "@e-mc/watch/filegroup",
|
|
479
|
-
"@squared-functions/document/android": "@pi-r/android",
|
|
480
|
-
"@squared-functions/document/android/extensions/app/manifest": "@pi-r/android/extensions/app/manifest",
|
|
481
|
-
"@squared-functions/document/android/extensions/gradle/dependencies": "@pi-r/android/extensions/gradle/dependencies",
|
|
482
|
-
"@squared-functions/document/android/extensions/gradle/settings": "@pi-r/android/extensions/gradle/settings",
|
|
483
|
-
"@squared-functions/document/android/extensions/task": "@pi-r/android/extensions/task",
|
|
484
|
-
"@squared-functions/document/chrome": "@pi-r/chrome",
|
|
485
|
-
"@squared-functions/image/jimp": "@pi-r/jimp",
|
|
486
|
-
"@squared-functions/image/jimp/util": "@pi-r/jimp/util",
|
|
487
|
-
"@squared-functions/image-v3/jimp": "@pi-r/jimp",
|
|
488
|
-
"@squared-functions/task/gulp": "@pi-r/gulp",
|
|
489
|
-
"@squared-functions/cloud/atlas": "@pi-r/atlas",
|
|
490
|
-
"@squared-functions/cloud/aws": "@pi-r/aws",
|
|
491
|
-
"@squared-functions/cloud/aws/download": "@pi-r/aws/download",
|
|
492
|
-
"@squared-functions/cloud/aws/upload": "@pi-r/aws/upload",
|
|
493
|
-
"@squared-functions/cloud/aws-v3": "@pi-r/aws-v3",
|
|
494
|
-
"@squared-functions/cloud/aws-v3/download": "@pi-r/aws-v3/download",
|
|
495
|
-
"@squared-functions/cloud/aws-v3/upload": "@pi-r/aws-v3/upload",
|
|
496
|
-
"@squared-functions/cloud/azure": "@pi-r/azure",
|
|
497
|
-
"@squared-functions/cloud/azure/download": "@pi-r/azure/download",
|
|
498
|
-
"@squared-functions/cloud/azure/upload": "@pi-r/azure/upload",
|
|
499
|
-
"@squared-functions/cloud/gcp": "@pi-r/gcp",
|
|
500
|
-
"@squared-functions/cloud/gcp/download": "@pi-r/gcp/download",
|
|
501
|
-
"@squared-functions/cloud/gcp/upload": "@pi-r/gcp/upload",
|
|
502
|
-
"@squared-functions/cloud/ibm": "@pi-r/ibm",
|
|
503
|
-
"@squared-functions/cloud/ibm/download": "@pi-r/ibm/download",
|
|
504
|
-
"@squared-functions/cloud/ibm/upload": "@pi-r/ibm/upload",
|
|
505
|
-
"@squared-functions/cloud/ibm-v1": "@pi-r/ibm",
|
|
506
|
-
"@squared-functions/cloud/ibm-v1/download": "@pi-r/ibm/download",
|
|
507
|
-
"@squared-functions/cloud/ibm-v1/upload": "@pi-r/ibm/upload",
|
|
508
|
-
"@squared-functions/cloud/minio": "@pi-r/minio",
|
|
509
|
-
"@squared-functions/cloud/minio/download": "@pi-r/minio/download",
|
|
510
|
-
"@squared-functions/cloud/minio/upload": "@pi-r/minio/upload",
|
|
511
|
-
"@squared-functions/cloud/oci": "@pi-r/oci",
|
|
512
|
-
"@squared-functions/cloud/oci/download": "@pi-r/oci/download",
|
|
513
|
-
"@squared-functions/cloud/oci/upload": "@pi-r/oci/upload",
|
|
514
|
-
"@squared-functions/db/mongodb": "@pi-r/mongodb",
|
|
515
|
-
"@squared-functions/db/mssql": "@pi-r/mssql",
|
|
516
|
-
"@squared-functions/db/mysql": "@pi-r/mysql",
|
|
517
|
-
"@squared-functions/db/oracle": "@pi-r/oracle",
|
|
518
|
-
"@squared-functions/db/postgres": "@pi-r/postgres",
|
|
519
|
-
"@squared-functions/db/redis": "@pi-r/redis",
|
|
520
|
-
"@squared-functions/document/packages/@babel/core": "@pi-r/babel",
|
|
521
|
-
"@squared-functions/document/packages/clean-css": "@pi-r/clean-css",
|
|
522
|
-
"@squared-functions/document/packages/eslint": "@pi-r/eslint",
|
|
523
|
-
"@squared-functions/document/packages/html-minifier": "@pi-r/html-minifier-terser",
|
|
524
|
-
"@squared-functions/document/packages/html-minifier-terser": "@pi-r/html-minifier-terser",
|
|
525
|
-
"@squared-functions/document/packages/html-validate": "@pi-r/html-validate",
|
|
526
|
-
"@squared-functions/document/packages/postcss": "@pi-r/postcss",
|
|
527
|
-
"@squared-functions/document/packages/posthtml": "@pi-r/posthtml",
|
|
528
|
-
"@squared-functions/document/packages/prettier": "@pi-r/prettier",
|
|
529
|
-
"@squared-functions/document/packages/rollup": "@pi-r/rollup",
|
|
530
|
-
"@squared-functions/document/packages/sass": "@pi-r/sass",
|
|
531
|
-
"@squared-functions/document/packages/stylelint": "@pi-r/stylelint",
|
|
532
|
-
"@squared-functions/document/packages/svgo": "@pi-r/svgo",
|
|
533
|
-
"@squared-functions/document/packages/terser": "@pi-r/terser",
|
|
534
|
-
"@squared-functions/document/packages/uglify-js": "@pi-r/uglify-js",
|
|
535
482
|
"atlas": "@pi-r/atlas",
|
|
536
483
|
"aws": "@pi-r/aws",
|
|
537
484
|
"aws-v3": "@pi-r/aws-v3",
|
|
@@ -539,8 +486,6 @@ exports.IMPORT_MAP = {
|
|
|
539
486
|
"azure": "@pi-r/azure",
|
|
540
487
|
"gcloud": "@pi-r/gcp",
|
|
541
488
|
"gcp": "@pi-r/gcp",
|
|
542
|
-
"ibm": "@pi-r/ibm",
|
|
543
|
-
"minio": "@pi-r/minio",
|
|
544
489
|
"oci": "@pi-r/oci",
|
|
545
490
|
"tinify": "@pi-r/tinify",
|
|
546
491
|
"mariadb": "@pi-r/mariadb",
|
|
@@ -554,8 +499,6 @@ exports.IMPORT_MAP = {
|
|
|
554
499
|
"clean-css": "@pi-r/clean-css",
|
|
555
500
|
"csso": "@pi-r/csso",
|
|
556
501
|
"eslint": "@pi-r/eslint",
|
|
557
|
-
"html-minifier": "@pi-r/html-minifier",
|
|
558
|
-
"html-minifier-terser": "@pi-r/html-minifier-terser",
|
|
559
502
|
"html-validate": "@pi-r/html-validate",
|
|
560
503
|
"postcss": "@pi-r/postcss",
|
|
561
504
|
"posthtml": "@pi-r/posthtml",
|
|
@@ -563,8 +506,12 @@ exports.IMPORT_MAP = {
|
|
|
563
506
|
"rollup": "@pi-r/rollup",
|
|
564
507
|
"sass": "@pi-r/sass",
|
|
565
508
|
"stylelint": "@pi-r/stylelint",
|
|
566
|
-
"svgo": "@pi-r/svgo",
|
|
567
509
|
"terser": "@pi-r/terser",
|
|
510
|
+
"ibm": "@pi-r/ibm",
|
|
511
|
+
"minio": "@pi-r/minio",
|
|
512
|
+
"html-minifier": "@pi-r/html-minifier",
|
|
513
|
+
"html-minifier-terser": "@pi-r/html-minifier-terser",
|
|
514
|
+
"svgo": "@pi-r/svgo",
|
|
568
515
|
"uglify-js": "@pi-r/uglify-js"
|
|
569
516
|
};
|
|
570
517
|
function createAbortError(reject) {
|
|
@@ -575,28 +522,28 @@ function hasBit(value, flags) {
|
|
|
575
522
|
return typeof value === 'number' && (value & flags) > 0;
|
|
576
523
|
}
|
|
577
524
|
function ignoreFlag(value) {
|
|
578
|
-
return
|
|
525
|
+
return checkFlags(value, 1);
|
|
579
526
|
}
|
|
580
527
|
function cloneFlag(value) {
|
|
581
|
-
return
|
|
528
|
+
return checkFlags(value, 2);
|
|
582
529
|
}
|
|
583
530
|
function usingFlag(value) {
|
|
584
|
-
return
|
|
531
|
+
return checkFlags(value, 4);
|
|
585
532
|
}
|
|
586
533
|
function watchFlag(value) {
|
|
587
|
-
return
|
|
534
|
+
return checkFlags(value, 8);
|
|
588
535
|
}
|
|
589
536
|
function modifiedFlag(value) {
|
|
590
|
-
return
|
|
537
|
+
return checkFlags(value, 16);
|
|
591
538
|
}
|
|
592
539
|
function processFlag(value) {
|
|
593
|
-
return
|
|
540
|
+
return checkFlags(value, 32);
|
|
594
541
|
}
|
|
595
542
|
function mainFlag(value) {
|
|
596
|
-
return
|
|
543
|
+
return checkFlags(value, 64);
|
|
597
544
|
}
|
|
598
545
|
function existsFlag(value) {
|
|
599
|
-
return
|
|
546
|
+
return checkFlags(value, 128);
|
|
600
547
|
}
|
|
601
548
|
function getLogCurrent() {
|
|
602
549
|
return LOG_CURRENT;
|
|
@@ -735,26 +682,30 @@ function formatTime(value, elapsed, char = ' ') {
|
|
|
735
682
|
return result.join(char);
|
|
736
683
|
}
|
|
737
684
|
function convertTime(value, format) {
|
|
738
|
-
let result;
|
|
685
|
+
let result = 0;
|
|
739
686
|
if (Array.isArray(value)) {
|
|
740
|
-
|
|
741
|
-
|
|
687
|
+
result = Math.ceil((value[0] * 1000000000 + value[1]) / 1000000);
|
|
688
|
+
}
|
|
689
|
+
else if (typeof value === 'bigint') {
|
|
690
|
+
result = Number(value / BigInt(1000000));
|
|
742
691
|
}
|
|
743
692
|
else {
|
|
744
|
-
|
|
693
|
+
return parseTime(value);
|
|
745
694
|
}
|
|
746
|
-
return result;
|
|
695
|
+
return format ? formatTime(result) : result;
|
|
747
696
|
}
|
|
748
697
|
function hasGlob(value) {
|
|
749
698
|
return REGEXP_GLOB.test(value);
|
|
750
699
|
}
|
|
751
|
-
function escapePattern(value,
|
|
700
|
+
function escapePattern(value, symbols) {
|
|
752
701
|
switch (typeof value) {
|
|
753
702
|
case 'string': {
|
|
754
703
|
let result = '', j = 0;
|
|
755
704
|
for (let i = 0, length = value.length, ch; i < length; ++i) {
|
|
756
705
|
switch (ch = value[i]) {
|
|
757
706
|
case '-':
|
|
707
|
+
ch = '\\x2d';
|
|
708
|
+
break;
|
|
758
709
|
case '.':
|
|
759
710
|
case '+':
|
|
760
711
|
case '*':
|
|
@@ -769,13 +720,16 @@ function escapePattern(value, lookBehind) {
|
|
|
769
720
|
case '}':
|
|
770
721
|
case '^':
|
|
771
722
|
case '$':
|
|
772
|
-
|
|
773
|
-
|
|
723
|
+
ch = '\\' + ch;
|
|
724
|
+
break;
|
|
725
|
+
default:
|
|
726
|
+
if (!(symbols && (ch = PATTERN_CHARS[ch]))) {
|
|
727
|
+
continue;
|
|
774
728
|
}
|
|
775
|
-
result += value.substring(j, i) + (ch === '-' ? '\\x2d' : '\\' + ch);
|
|
776
|
-
j = i + 1;
|
|
777
729
|
break;
|
|
778
730
|
}
|
|
731
|
+
result += value.substring(j, i) + ch;
|
|
732
|
+
j = i + 1;
|
|
779
733
|
}
|
|
780
734
|
return j > 0 ? result + value.substring(j) : value;
|
|
781
735
|
}
|
|
@@ -868,7 +822,7 @@ function cascadeObject(data, query, fallback) {
|
|
|
868
822
|
return fallback;
|
|
869
823
|
}
|
|
870
824
|
function cloneObject(data, options) {
|
|
871
|
-
let target, deep, deepIgnore, mergeArray,
|
|
825
|
+
let freezeDepth = -1, mergeDepth = Infinity, target, deep, deepIgnore, mergeArray, typedArray, inherited, nonenumerable, symbol, preserve;
|
|
872
826
|
if (options === true) {
|
|
873
827
|
deep = true;
|
|
874
828
|
}
|
|
@@ -878,14 +832,20 @@ function cloneObject(data, options) {
|
|
|
878
832
|
}
|
|
879
833
|
else if (options) {
|
|
880
834
|
({ target, deep, deepIgnore, mergeArray, typedArray, inherited, nonenumerable, symbol, preserve } = options);
|
|
835
|
+
if (typeof options.freezeDepth === 'number') {
|
|
836
|
+
freezeDepth = options.freezeDepth - 1;
|
|
837
|
+
}
|
|
838
|
+
else if (options.freezeDepth) {
|
|
839
|
+
freezeDepth = Infinity;
|
|
840
|
+
}
|
|
881
841
|
if (options.mergeDepth !== undefined) {
|
|
882
842
|
mergeDepth = options.mergeDepth - 1;
|
|
883
843
|
}
|
|
884
844
|
}
|
|
885
845
|
let nested;
|
|
886
|
-
if (deep) {
|
|
846
|
+
if (deep || freezeDepth > 0) {
|
|
887
847
|
deepIgnore ||= new WeakSet();
|
|
888
|
-
nested = { deep, deepIgnore, mergeArray, mergeDepth, typedArray, preserve };
|
|
848
|
+
nested = { deep, deepIgnore, freezeDepth, mergeArray, mergeDepth, typedArray, preserve };
|
|
889
849
|
}
|
|
890
850
|
if (Array.isArray(data)) {
|
|
891
851
|
deepIgnore?.add(data);
|
|
@@ -928,20 +888,23 @@ function cloneObject(data, options) {
|
|
|
928
888
|
}
|
|
929
889
|
const prop = target[attr];
|
|
930
890
|
if (preserve && isPlainObject(prop) && isPlainObject(merge)) {
|
|
931
|
-
(function recurse(current, next) {
|
|
891
|
+
(function recurse(current, next, depth) {
|
|
932
892
|
for (const item of getProperties(next, inherited, nonenumerable, symbol)) {
|
|
933
893
|
const b = next[item];
|
|
934
894
|
if (item in current) {
|
|
935
895
|
const a = current[item];
|
|
936
896
|
if (isPlainObject(a) && isPlainObject(b)) {
|
|
937
|
-
recurse(a, b);
|
|
897
|
+
recurse(a, b, depth - 1);
|
|
938
898
|
}
|
|
939
899
|
}
|
|
940
900
|
else if (!(mergeArray && mergeDepth >= 0 && mergedArray(current, item, b, mergeArray))) {
|
|
941
901
|
current[item] = b;
|
|
942
902
|
}
|
|
943
903
|
}
|
|
944
|
-
|
|
904
|
+
if (depth >= 0) {
|
|
905
|
+
Object.freeze(current);
|
|
906
|
+
}
|
|
907
|
+
})(prop, merge, freezeDepth - 1);
|
|
945
908
|
}
|
|
946
909
|
else if (!(mergeArray && mergeDepth >= 0 && mergedArray(target, attr, merge, mergeArray))) {
|
|
947
910
|
target[attr] = merge;
|
|
@@ -951,6 +914,9 @@ function cloneObject(data, options) {
|
|
|
951
914
|
else {
|
|
952
915
|
return deep ? fromObject(data, typedArray) : data;
|
|
953
916
|
}
|
|
917
|
+
if (freezeDepth >= 0) {
|
|
918
|
+
Object.freeze(target);
|
|
919
|
+
}
|
|
954
920
|
return target;
|
|
955
921
|
}
|
|
956
922
|
function coerceObject(data, parseString, cache) {
|
|
@@ -1076,10 +1042,12 @@ function errorValue(value, hint) {
|
|
|
1076
1042
|
return new Error(value + (hint ? ` (${hint})` : ''));
|
|
1077
1043
|
}
|
|
1078
1044
|
function errorMessage(title, value, hint) {
|
|
1079
|
-
return new Error((title
|
|
1045
|
+
return new Error((isString(title) || typeof title === 'number' ? title + ': ' : '') + value + (hint ? ` (${hint})` : ''));
|
|
1080
1046
|
}
|
|
1081
1047
|
function purgeMemory(percent) {
|
|
1082
1048
|
CACHE_COERCED = new WeakSet();
|
|
1049
|
+
INCREMENT_COUNT = 65536;
|
|
1050
|
+
LOG_CURRENT = null;
|
|
1083
1051
|
}
|
|
1084
1052
|
function incrementUUID(restart) {
|
|
1085
1053
|
if (restart || INCREMENT_COUNT === 65536) {
|
|
@@ -1096,10 +1064,14 @@ function hashKey(data, algorithm = 'md5', encoding = 'base64') {
|
|
|
1096
1064
|
return crypto.randomUUID();
|
|
1097
1065
|
}
|
|
1098
1066
|
}
|
|
1099
|
-
function supported(major, minor = 0, patch = 0, lts) {
|
|
1067
|
+
function supported(major, minor = 0, patch = 0, lts = false) {
|
|
1100
1068
|
if (VER_MAJOR < major) {
|
|
1101
1069
|
return false;
|
|
1102
1070
|
}
|
|
1071
|
+
if (typeof patch === 'boolean') {
|
|
1072
|
+
lts = patch;
|
|
1073
|
+
patch = 0;
|
|
1074
|
+
}
|
|
1103
1075
|
if (VER_MAJOR === major) {
|
|
1104
1076
|
if (VER_MINOR < minor) {
|
|
1105
1077
|
return false;
|
|
@@ -1113,7 +1085,7 @@ function supported(major, minor = 0, patch = 0, lts) {
|
|
|
1113
1085
|
}
|
|
1114
1086
|
async function importESM(name, isDefault, fromPath) {
|
|
1115
1087
|
if (fromPath && path.isAbsolute(name)) {
|
|
1116
|
-
name = (0,
|
|
1088
|
+
name = (0, node_url_1.pathToFileURL)(name).toString();
|
|
1117
1089
|
}
|
|
1118
1090
|
const result = import(name);
|
|
1119
1091
|
if (isDefault) {
|
|
@@ -1126,4 +1098,4 @@ async function importESM(name, isDefault, fromPath) {
|
|
|
1126
1098
|
}
|
|
1127
1099
|
exports.generateUUID = crypto.randomUUID.bind(crypto);
|
|
1128
1100
|
SUPPORTED_DOMEXCEPTION = supported(17);
|
|
1129
|
-
SUPPORTED_HASHSINGLE = supported(20, 12,
|
|
1101
|
+
SUPPORTED_HASHSINGLE = supported(20, 12, true) || supported(21, 7);
|
package/lib/asset.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface BinaryAction {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export interface StreamAction {
|
|
18
|
-
minStreamSize?:
|
|
18
|
+
minStreamSize?: number | string;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export interface FileData<T extends ExternalAsset> extends MimeTypeAction {
|
|
@@ -58,7 +58,7 @@ export interface ExternalAsset extends FileAsset, BundleAction, BinaryAction, St
|
|
|
58
58
|
id?: number;
|
|
59
59
|
url?: URL;
|
|
60
60
|
socketPath?: string;
|
|
61
|
-
buffer?:
|
|
61
|
+
buffer?: Buffer | null;
|
|
62
62
|
localUri?: string;
|
|
63
63
|
fetchType?: FetchType;
|
|
64
64
|
sourceUTF8?: string;
|
|
@@ -74,4 +74,4 @@ export interface ExternalAsset extends FileAsset, BundleAction, BinaryAction, St
|
|
|
74
74
|
invalid?: boolean;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
export type HashAlgorithm = "md5" | "sha1" | "sha256" | "sha224" | "sha384" | "sha512";
|
|
77
|
+
export type HashAlgorithm = "md5" | "sha1" | "sha256" | "sha224" | "sha384" | "sha512" | "ripemd" | "ripemd-160";
|
package/lib/cloud.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export interface UploadAction {
|
|
|
7
7
|
cloudUrl?: string;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
export interface RecursiveAction {
|
|
11
|
+
recursive?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
export interface CloudAsset<T = CloudStorage> extends ExternalAsset, UploadAction, StorageAction<T> {}
|
|
11
15
|
|
|
12
16
|
export interface CloudService<T = unknown, U = string> {
|
|
@@ -26,7 +30,7 @@ export interface CloudStorage<T = unknown, U = string> extends CloudService<T, U
|
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
export interface CloudStorageAdmin<T = unknown, U = string, V = unknown, W = unknown, X = unknown, Y = unknown> extends CloudStorageACL<U> {
|
|
29
|
-
emptyBucket?: boolean;
|
|
33
|
+
emptyBucket?: boolean | DeleteObjectsOptions;
|
|
30
34
|
configBucket?: {
|
|
31
35
|
create?: T;
|
|
32
36
|
policy?: V;
|
|
@@ -36,6 +40,7 @@ export interface CloudStorageAdmin<T = unknown, U = string, V = unknown, W = unk
|
|
|
36
40
|
cors?: X;
|
|
37
41
|
lifecycle?: Y;
|
|
38
42
|
};
|
|
43
|
+
/** @deprecated */
|
|
39
44
|
recursive?: boolean;
|
|
40
45
|
preservePath?: boolean;
|
|
41
46
|
}
|
|
@@ -43,14 +48,14 @@ export interface CloudStorageAdmin<T = unknown, U = string, V = unknown, W = unk
|
|
|
43
48
|
export interface CloudStorageAction<T = unknown, U = string, V = unknown, W = unknown, X = unknown, Y = unknown> extends Partial<LocationUri>, StreamAction {
|
|
44
49
|
active?: boolean;
|
|
45
50
|
overwrite?: boolean;
|
|
46
|
-
chunkSize?:
|
|
51
|
+
chunkSize?: number | string;
|
|
47
52
|
chunkLimit?: number;
|
|
48
53
|
flags?: number;
|
|
49
54
|
admin?: CloudStorageAdmin<T, U, V, W, X, Y>;
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
export interface CloudStorageUpload<T = unknown, U = string, V = unknown, W = string, X = unknown, Y = unknown, Z = unknown> extends CloudStorageACL<U>, CloudStorageAction<V, W, unknown, X, Y, Z> {
|
|
53
|
-
buffer?:
|
|
58
|
+
buffer?: Buffer | null;
|
|
54
59
|
contentType?: string;
|
|
55
60
|
metadata?: Record<string, string>;
|
|
56
61
|
tags?: Record<string, string> | false;
|
|
@@ -81,6 +86,8 @@ export interface BucketWebsiteOptions {
|
|
|
81
86
|
errorPath?: string;
|
|
82
87
|
}
|
|
83
88
|
|
|
89
|
+
export interface DeleteObjectsOptions extends RecursiveAction, PlainObject {}
|
|
90
|
+
|
|
84
91
|
export interface UploadData<T = unknown, U = string, V = unknown, W = string, X = unknown, Y = unknown, Z = unknown> extends BucketAction {
|
|
85
92
|
upload: CloudStorageUpload<T, U, V, W, X, Y, Z>;
|
|
86
93
|
localUri: string;
|
|
@@ -102,6 +109,6 @@ export interface UploadAssetOptions {
|
|
|
102
109
|
}
|
|
103
110
|
|
|
104
111
|
export type UploadContent = [Bufferable, string, string?];
|
|
105
|
-
export type CloudSource = "atlas" | "aws" | "aws-v3" | "az" | "azure" | "gcp" | "gcloud" | "
|
|
112
|
+
export type CloudSource = "atlas" | "aws" | "aws-v3" | "az" | "azure" | "gcp" | "gcloud" | "oci";
|
|
106
113
|
export type CloudFeatures = "storage" | "database";
|
|
107
114
|
export type CloudFunctions = "upload" | "download";
|
package/lib/compress.d.ts
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import type { CompressFormat as ICompressFormat } from './squared';
|
|
1
|
+
import type { CompressFormat as ICompressFormat, CompressLevel as ICompressLevel } from './squared';
|
|
2
2
|
|
|
3
3
|
import type { LogBaseOptions, LogTime } from './logger';
|
|
4
|
+
import type { ThrowsAction } from './module';
|
|
4
5
|
|
|
5
|
-
type ResultCallback<T =
|
|
6
|
-
type ResultData =
|
|
6
|
+
type ResultCallback<T = Buffer | Uint8Array | null> = (err: unknown, data?: T, ext?: string) => void;
|
|
7
|
+
type ResultData = Buffer | Uint8Array | string | null;
|
|
7
8
|
|
|
8
|
-
export interface CompressFormat extends ICompressFormat, LogBaseOptions {
|
|
9
|
+
export interface CompressFormat extends ICompressFormat, LogBaseOptions, ReadableOptions {
|
|
9
10
|
filename?: string;
|
|
11
|
+
mimeType?: string;
|
|
10
12
|
startTime?: LogTime;
|
|
11
13
|
etag?: string;
|
|
12
|
-
proxyUrl?: string | ((uri: string) => Undef<string>);
|
|
13
14
|
outExt?: string;
|
|
14
15
|
outFile?: string;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
export interface
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
18
|
+
export interface CompressLevel extends ICompressLevel, ReadableOptions {}
|
|
19
|
+
|
|
20
|
+
export interface ReadableOptions extends ThrowsAction {}
|
|
21
21
|
|
|
22
22
|
export type BufferLike = Buffer | Uint8Array | ArrayBuffer | SharedArrayBuffer | readonly number[];
|
|
23
|
-
export type TryFileCompressor = (data: string | Buffer, output: string, config: CompressFormat, callback?: ResultCallback<ResultData>) =>
|
|
23
|
+
export type TryFileCompressor = (data: string | Buffer, output: string, config: CompressFormat, callback?: ResultCallback<ResultData>) => Promise<ResultData | void>;
|
|
24
24
|
export type TryFileCompressorAsync = (data: string | Buffer, output: string, config: CompressFormat) => Promise<ResultData>;
|
|
25
|
-
export type BufferResult =
|
|
25
|
+
export type BufferResult = Buffer | Uint8Array | null;
|
|
26
|
+
export type PluginCompressor = FunctionArgs<[CompressFormat['options'], string?], FunctionArgs<[Buffer], Promise<Buffer | Uint8Array>>>;
|
package/lib/core.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint @typescript-eslint/no-explicit-any: "off" */
|
|
2
|
-
|
|
3
1
|
import type { DataSource, RequestBase } from './squared';
|
|
4
2
|
|
|
5
3
|
import type { IExternalConfig, IExternalFunction, IHost, IModule, ModuleConstructor } from './index';
|
|
@@ -20,7 +18,7 @@ export interface AddEventListenerOptions {
|
|
|
20
18
|
|
|
21
19
|
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> {
|
|
22
20
|
init(...args: unknown[]): this;
|
|
23
|
-
getUserSettings<X>():
|
|
21
|
+
getUserSettings<X>(): X | null;
|
|
24
22
|
set cacheDir(value: string);
|
|
25
23
|
get cacheDir(): string;
|
|
26
24
|
}
|
|
@@ -35,14 +33,15 @@ export interface IClientDb<T extends IHost, U extends ClientModule<ClientDbSetti
|
|
|
35
33
|
cacheExpires: number;
|
|
36
34
|
add(item: V, state?: number): void;
|
|
37
35
|
hasCache(source: string, sessionKey?: string): boolean;
|
|
38
|
-
hasCoerce(source: string, component: keyof DbCoerceSettings, uuidKey:
|
|
36
|
+
hasCoerce(source: string, component: keyof DbCoerceSettings, uuidKey: string | undefined): boolean;
|
|
39
37
|
hasCoerce(source: string, component: keyof DbCoerceSettings, credential?: unknown): boolean;
|
|
40
|
-
getQueryResult(source: string, credential: unknown, queryString: string, renewCache: boolean):
|
|
41
|
-
getQueryResult(source: string, credential: unknown, queryString: string, sessionKey?: string, renewCache?: boolean):
|
|
42
|
-
getQueryResult(source: string, credential: unknown, queryString: string, options?: CacheOptions | string, renewCache?: boolean):
|
|
38
|
+
getQueryResult(source: string, credential: unknown, queryString: string, renewCache: boolean): QueryResult | undefined;
|
|
39
|
+
getQueryResult(source: string, credential: unknown, queryString: string, sessionKey?: string, renewCache?: boolean): QueryResult | undefined;
|
|
40
|
+
getQueryResult(source: string, credential: unknown, queryString: string, options?: CacheOptions | string, renewCache?: boolean): QueryResult | undefined;
|
|
43
41
|
setQueryResult(source: string, credential: unknown, queryString: string, result: unknown, sessionKey?: string): QueryResult;
|
|
44
42
|
setQueryResult(source: string, credential: unknown, queryString: string, result: unknown, options?: CacheOptions | string): QueryResult;
|
|
45
|
-
|
|
43
|
+
getCacheResult(source: string, credential: unknown, queryString: string, cacheValue: CacheOptions, ignoreCache?: IntBool | FirstOf<number, number>): QueryResult | undefined;
|
|
44
|
+
applyState(items: V | V[], value: number, as?: boolean): void;
|
|
46
45
|
commit(items?: V[]): Promise<boolean>;
|
|
47
46
|
valueOfKey(credential: unknown, name: keyof W, component?: keyof X): unknown;
|
|
48
47
|
settingsOf(source: string, name: keyof W, component?: keyof X): unknown;
|
|
@@ -62,13 +61,13 @@ export interface ClientDbConstructor<T extends IHost = IHost, U extends ClientMo
|
|
|
62
61
|
readonly TRANSACTION_ABORT: number;
|
|
63
62
|
readonly TRANSACTION_FAIL: number;
|
|
64
63
|
loadSettings(settings: Pick<Settings, "process" | "memory">, password?: string): boolean;
|
|
65
|
-
getTimeout(value:
|
|
66
|
-
convertTime(value:
|
|
67
|
-
findResult(source: string, credential: unknown, queryString: string, timeout: number, sessionKey?: string | boolean, renewCache?: boolean):
|
|
64
|
+
getTimeout(value: number | string | TimeoutAction | undefined): number;
|
|
65
|
+
convertTime(value: number | string): number;
|
|
66
|
+
findResult(source: string, credential: unknown, queryString: string, timeout: number, sessionKey?: string | boolean, renewCache?: boolean): QueryResult | undefined;
|
|
68
67
|
storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, options: StoreResultOptions): QueryResult;
|
|
69
68
|
storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, sessionKey: string, sessionExpires: number): QueryResult;
|
|
70
69
|
storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, cache: DbCacheValue): QueryResult;
|
|
71
|
-
storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, cache:
|
|
70
|
+
storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, cache: DbCacheValue | undefined, options: StoreResultOptions): QueryResult;
|
|
72
71
|
purgeResult(prefix?: string): Promise<number>;
|
|
73
72
|
extractUUID(credential: unknown): string;
|
|
74
73
|
setPoolConfig(value: unknown): void;
|
|
@@ -91,14 +90,14 @@ export interface AbortComponentConstructor {
|
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
export interface IPermission {
|
|
94
|
-
setDiskRead(pathname?:
|
|
95
|
-
setDiskWrite(pathname?:
|
|
96
|
-
setUNCRead(pathname?:
|
|
97
|
-
setUNCWrite(pathname?:
|
|
98
|
-
getDiskRead():
|
|
99
|
-
getDiskWrite():
|
|
100
|
-
getUNCRead():
|
|
101
|
-
getUNCWrite():
|
|
93
|
+
setDiskRead(pathname?: string | string[], enabled?: boolean): void;
|
|
94
|
+
setDiskWrite(pathname?: string | string[], enabled?: boolean): void;
|
|
95
|
+
setUNCRead(pathname?: string | string[], enabled?: boolean): void;
|
|
96
|
+
setUNCWrite(pathname?: string | string[], enabled?: boolean): void;
|
|
97
|
+
getDiskRead(): string | string[];
|
|
98
|
+
getDiskWrite(): string | string[];
|
|
99
|
+
getUNCRead(): string | string[];
|
|
100
|
+
getUNCWrite(): string | string[];
|
|
102
101
|
hasDiskRead(pathname: string): boolean;
|
|
103
102
|
hasDiskWrite(pathname: string): boolean;
|
|
104
103
|
hasUNCRead(pathname: string): boolean;
|
|
@@ -110,12 +109,12 @@ export interface IPermission {
|
|
|
110
109
|
}
|
|
111
110
|
|
|
112
111
|
export interface PermissionConstructor {
|
|
113
|
-
create(settings: PermittedDirectories, freeze?: boolean):
|
|
114
|
-
create(settings: PermittedDirectories, parent:
|
|
112
|
+
create(settings: PermittedDirectories, freeze?: boolean): IPermission | null;
|
|
113
|
+
create(settings: PermittedDirectories, parent: IPermission | null, freeze?: boolean): IPermission | null;
|
|
115
114
|
validate(settings: unknown): settings is PermittedDirectories;
|
|
116
115
|
clone(permission: IPermission, freeze?: boolean): IPermission;
|
|
117
|
-
match(pathname: string, pattern:
|
|
118
|
-
toPosix(value:
|
|
116
|
+
match(pathname: string, pattern: string | string[]): boolean;
|
|
117
|
+
toPosix<T>(value: T): T extends Array<unknown> ? string | string[] : string;
|
|
119
118
|
readonly prototype: IPermission;
|
|
120
119
|
new(freeze?: boolean): IPermission;
|
|
121
120
|
}
|
|
@@ -131,20 +130,22 @@ export interface PermissionAction {
|
|
|
131
130
|
permission?: PermittedDirectories;
|
|
132
131
|
}
|
|
133
132
|
|
|
134
|
-
export interface HostInitConfig extends PlainObject, RequestBase<
|
|
133
|
+
export interface HostInitConfig<T extends HostInitLog = HostInitLog> extends PlainObject, RequestBase<T> {
|
|
135
134
|
username?: string;
|
|
135
|
+
remoteIp?: string;
|
|
136
136
|
ignoreModules?: string[];
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
export interface HostInitLog {
|
|
140
140
|
enabled?: boolean;
|
|
141
|
-
level?:
|
|
142
|
-
exclude?:
|
|
141
|
+
level?: number | string;
|
|
142
|
+
exclude?: string | string[];
|
|
143
143
|
useColor?: boolean;
|
|
144
|
+
silent?: boolean;
|
|
144
145
|
showProgress?: boolean;
|
|
145
146
|
}
|
|
146
147
|
|
|
147
|
-
export interface PermittedDirectories extends PermissionReadWrite<
|
|
148
|
+
export interface PermittedDirectories extends PermissionReadWrite<string | string[]> {
|
|
148
149
|
inherit?: boolean;
|
|
149
150
|
}
|
|
150
151
|
|
|
@@ -158,7 +159,7 @@ export interface StoreResultOptions {
|
|
|
158
159
|
export interface CacheOptions {
|
|
159
160
|
value?: DbCacheValue;
|
|
160
161
|
renewCache?: boolean;
|
|
161
|
-
exclusiveOf?:
|
|
162
|
+
exclusiveOf?: FirstOf<number, number>;
|
|
162
163
|
sessionKey?: string;
|
|
163
164
|
}
|
|
164
165
|
|
|
@@ -167,7 +168,7 @@ export interface ThreadInfo {
|
|
|
167
168
|
startTime: number;
|
|
168
169
|
username?: string;
|
|
169
170
|
sessionId?: string;
|
|
170
|
-
broadcastId?:
|
|
171
|
+
broadcastId?: string | string[];
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
export interface ThreadCountStat {
|