@e-mc/core 0.7.3 → 0.7.5
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/index.js +16 -12
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright
|
|
1
|
+
Copyright 2024 An Pham
|
|
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/index.js
CHANGED
|
@@ -179,7 +179,7 @@ function deleteSourceResult(source, target) {
|
|
|
179
179
|
function incrementSourceCount(source, target, cacheData, queryString) {
|
|
180
180
|
const count = ++target[3];
|
|
181
181
|
const stored = CACHE_SOURCE[source];
|
|
182
|
-
if (stored
|
|
182
|
+
if ((stored === null || stored === void 0 ? void 0 : stored.config) && count >= stored.config.max) {
|
|
183
183
|
clearSourceResult(target);
|
|
184
184
|
deleteSourceResult(source, target);
|
|
185
185
|
if (cacheData && queryString) {
|
|
@@ -480,8 +480,9 @@ class Host extends module_1.default {
|
|
|
480
480
|
}
|
|
481
481
|
restart(...args) { }
|
|
482
482
|
isFatal(err) {
|
|
483
|
-
|
|
484
|
-
|
|
483
|
+
var _j;
|
|
484
|
+
const fatal = (_j = this.config.error) === null || _j === void 0 ? void 0 : _j.fatal;
|
|
485
|
+
return fatal !== null && fatal !== void 0 ? fatal : super.isFatal(err);
|
|
485
486
|
}
|
|
486
487
|
using(...items) {
|
|
487
488
|
const data = this._usingObjects;
|
|
@@ -662,10 +663,11 @@ class Client extends module_1.default {
|
|
|
662
663
|
this.module = (0, types_1.isPlainObject)(data) ? data : {};
|
|
663
664
|
}
|
|
664
665
|
init(...args) {
|
|
666
|
+
var _j;
|
|
665
667
|
const { permission, extensions } = this.module;
|
|
666
668
|
const cache_dir = this.settings.cache_dir;
|
|
667
669
|
if (permission) {
|
|
668
|
-
const result = Permission.create(permission, permission.inherit !== false ? this.host
|
|
670
|
+
const result = Permission.create(permission, permission.inherit !== false ? (_j = this.host) === null || _j === void 0 ? void 0 : _j.permission : null, true);
|
|
669
671
|
if (result) {
|
|
670
672
|
this.permission = result;
|
|
671
673
|
}
|
|
@@ -782,13 +784,14 @@ class ClientDb extends Client {
|
|
|
782
784
|
return result > 0 ? result : 0;
|
|
783
785
|
}
|
|
784
786
|
static findResult(source, credential, queryString, timeout, sessionKey, renewCache) {
|
|
787
|
+
var _j, _k, _l;
|
|
785
788
|
const userKey = this.extractUUID(credential) || this.asHash(this.asString(credential));
|
|
786
789
|
if (!userKey) {
|
|
787
790
|
return;
|
|
788
791
|
}
|
|
789
792
|
queryString = this.asHash(queryString);
|
|
790
793
|
if (timeout > 0) {
|
|
791
|
-
const userCache = CACHE_USER[source]
|
|
794
|
+
const userCache = (_j = CACHE_USER[source]) === null || _j === void 0 ? void 0 : _j[userKey];
|
|
792
795
|
let stored;
|
|
793
796
|
if (!(userCache && (stored = userCache[queryString]))) {
|
|
794
797
|
return;
|
|
@@ -822,7 +825,7 @@ class ClientDb extends Client {
|
|
|
822
825
|
delete userCache[queryString];
|
|
823
826
|
}
|
|
824
827
|
else if (sessionKey) {
|
|
825
|
-
return CACHE_SESSION[source]
|
|
828
|
+
return (_l = (_k = CACHE_SESSION[source]) === null || _k === void 0 ? void 0 : _k[userKey + sessionKey]) === null || _l === void 0 ? void 0 : _l[queryString];
|
|
826
829
|
}
|
|
827
830
|
}
|
|
828
831
|
static storeResult(source, credential, queryString, result, options, sessionKey, sessionExpires) {
|
|
@@ -993,7 +996,7 @@ class ClientDb extends Client {
|
|
|
993
996
|
}
|
|
994
997
|
}
|
|
995
998
|
hasCache(source, sessionKey, override) {
|
|
996
|
-
return (0, types_1.isString)(sessionKey) || ClientDb.getTimeout(override
|
|
999
|
+
return (0, types_1.isString)(sessionKey) || ClientDb.getTimeout(override !== null && override !== void 0 ? override : this.settingsOf(source, 'cache')) > 0;
|
|
997
1000
|
}
|
|
998
1001
|
hasCoerce(source, component, override, credential) {
|
|
999
1002
|
if (override) {
|
|
@@ -1048,6 +1051,7 @@ class ClientDb extends Client {
|
|
|
1048
1051
|
return ClientDb.findResult(this.moduleName + '_' + source, uuidKey || credential, queryString, value === 0 ? 0 : ClientDb.getTimeout(value || this.settingsOf(source, 'cache')), sessionKey, renewCache);
|
|
1049
1052
|
}
|
|
1050
1053
|
setQueryResult(source, credential, queryString, result, sessionKey) {
|
|
1054
|
+
var _j;
|
|
1051
1055
|
if (!Array.isArray(result)) {
|
|
1052
1056
|
result = result === undefined ? [] : [result];
|
|
1053
1057
|
}
|
|
@@ -1056,7 +1060,7 @@ class ClientDb extends Client {
|
|
|
1056
1060
|
}
|
|
1057
1061
|
const uuidKey = ClientDb.extractUUID(credential);
|
|
1058
1062
|
let options;
|
|
1059
|
-
if (ClientDb.enabled("memory.settings.users", this.host
|
|
1063
|
+
if (ClientDb.enabled("memory.settings.users", (_j = this.host) === null || _j === void 0 ? void 0 : _j.username)) {
|
|
1060
1064
|
let value;
|
|
1061
1065
|
if ((0, types_1.isObject)(sessionKey)) {
|
|
1062
1066
|
({ value, sessionKey } = sessionKey);
|
|
@@ -1188,28 +1192,28 @@ class Permission {
|
|
|
1188
1192
|
result.setDiskRead(disk_read);
|
|
1189
1193
|
valid = true;
|
|
1190
1194
|
}
|
|
1191
|
-
else if (parent
|
|
1195
|
+
else if (parent === null || parent === void 0 ? void 0 : parent.diskRead) {
|
|
1192
1196
|
result.setDiskRead(parent.getDiskRead());
|
|
1193
1197
|
}
|
|
1194
1198
|
if (readable(disk_write) && (!parent || parent.diskWrite)) {
|
|
1195
1199
|
result.setDiskWrite(disk_write);
|
|
1196
1200
|
valid = true;
|
|
1197
1201
|
}
|
|
1198
|
-
else if (parent
|
|
1202
|
+
else if (parent === null || parent === void 0 ? void 0 : parent.diskWrite) {
|
|
1199
1203
|
result.setDiskWrite(parent.getDiskWrite());
|
|
1200
1204
|
}
|
|
1201
1205
|
if (readable(unc_read) && (!parent || parent.uncRead)) {
|
|
1202
1206
|
result.setUNCRead(unc_read);
|
|
1203
1207
|
valid = true;
|
|
1204
1208
|
}
|
|
1205
|
-
else if (parent
|
|
1209
|
+
else if (parent === null || parent === void 0 ? void 0 : parent.uncRead) {
|
|
1206
1210
|
result.setUNCRead(parent.getUNCRead());
|
|
1207
1211
|
}
|
|
1208
1212
|
if (readable(unc_write) && (!parent || parent.uncWrite)) {
|
|
1209
1213
|
result.setUNCWrite(unc_write);
|
|
1210
1214
|
valid = true;
|
|
1211
1215
|
}
|
|
1212
|
-
else if (parent
|
|
1216
|
+
else if (parent === null || parent === void 0 ? void 0 : parent.uncWrite) {
|
|
1213
1217
|
result.setUNCWrite(parent.getUNCWrite());
|
|
1214
1218
|
}
|
|
1215
1219
|
if (valid) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "Core modules for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/module": "0.7.
|
|
24
|
-
"@e-mc/types": "0.7.
|
|
23
|
+
"@e-mc/module": "0.7.5",
|
|
24
|
+
"@e-mc/types": "0.7.5",
|
|
25
25
|
"picomatch": "^3.0.1"
|
|
26
26
|
}
|
|
27
27
|
}
|