@e-mc/core 0.5.5 → 0.5.7
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/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/README.md
CHANGED
package/index.js
CHANGED
|
@@ -193,7 +193,7 @@ function deleteSourceResult(source, target) {
|
|
|
193
193
|
function incrementSourceCount(source, target, cacheData, queryString) {
|
|
194
194
|
const count = ++target[3];
|
|
195
195
|
const stored = CACHE_SOURCE[source];
|
|
196
|
-
if (stored
|
|
196
|
+
if ((stored === null || stored === void 0 ? void 0 : stored.config) && count >= stored.config.max) {
|
|
197
197
|
clearSourceResult(target);
|
|
198
198
|
deleteSourceResult(source, target);
|
|
199
199
|
if (cacheData && queryString) {
|
|
@@ -493,8 +493,9 @@ class Host extends module_1.default {
|
|
|
493
493
|
}
|
|
494
494
|
restart(...args) { }
|
|
495
495
|
isFatal(err) {
|
|
496
|
-
|
|
497
|
-
|
|
496
|
+
var _j;
|
|
497
|
+
const fatal = (_j = this.config.error) === null || _j === void 0 ? void 0 : _j.fatal;
|
|
498
|
+
return fatal !== null && fatal !== void 0 ? fatal : super.isFatal(err);
|
|
498
499
|
}
|
|
499
500
|
using(...items) {
|
|
500
501
|
const data = this._usingObjects;
|
|
@@ -675,10 +676,11 @@ class Client extends module_1.default {
|
|
|
675
676
|
this.module = (0, types_1.isPlainObject)(data) ? data : {};
|
|
676
677
|
}
|
|
677
678
|
init(...args) {
|
|
679
|
+
var _j;
|
|
678
680
|
const { permission, extensions } = this.module;
|
|
679
681
|
const cache_dir = this.settings.cache_dir;
|
|
680
682
|
if (permission) {
|
|
681
|
-
const result = Permission.create(permission, permission.inherit !== false ? this.host
|
|
683
|
+
const result = Permission.create(permission, permission.inherit !== false ? (_j = this.host) === null || _j === void 0 ? void 0 : _j.permission : null, true);
|
|
682
684
|
if (result) {
|
|
683
685
|
this.permission = result;
|
|
684
686
|
}
|
|
@@ -795,11 +797,12 @@ class ClientDb extends Client {
|
|
|
795
797
|
return result > 0 ? result : 0;
|
|
796
798
|
}
|
|
797
799
|
static findResult(source, credential, queryString, timeout, sessionKey, renewCache) {
|
|
800
|
+
var _j, _k, _l;
|
|
798
801
|
const userKey = this.extractUUID(credential) || this.asHash(this.asString(credential));
|
|
799
802
|
if (userKey) {
|
|
800
803
|
queryString = this.asHash(queryString);
|
|
801
804
|
if (timeout > 0) {
|
|
802
|
-
const userCache = CACHE_USER[source]
|
|
805
|
+
const userCache = (_j = CACHE_USER[source]) === null || _j === void 0 ? void 0 : _j[userKey];
|
|
803
806
|
let stored;
|
|
804
807
|
if (userCache && (stored = userCache[queryString])) {
|
|
805
808
|
const [expires, result] = stored;
|
|
@@ -832,7 +835,7 @@ class ClientDb extends Client {
|
|
|
832
835
|
}
|
|
833
836
|
}
|
|
834
837
|
else if (sessionKey) {
|
|
835
|
-
return CACHE_SESSION[source]
|
|
838
|
+
return (_l = (_k = CACHE_SESSION[source]) === null || _k === void 0 ? void 0 : _k[userKey + sessionKey]) === null || _l === void 0 ? void 0 : _l[queryString];
|
|
836
839
|
}
|
|
837
840
|
}
|
|
838
841
|
}
|
|
@@ -1001,7 +1004,7 @@ class ClientDb extends Client {
|
|
|
1001
1004
|
}
|
|
1002
1005
|
}
|
|
1003
1006
|
hasCache(source, sessionKey, override) {
|
|
1004
|
-
return (0, types_1.isString)(sessionKey) || ClientDb.getTimeout(override
|
|
1007
|
+
return (0, types_1.isString)(sessionKey) || ClientDb.getTimeout(override !== null && override !== void 0 ? override : this.settingsOf(source, 'cache')) > 0;
|
|
1005
1008
|
}
|
|
1006
1009
|
hasCoerce(source, component, override, credential) {
|
|
1007
1010
|
if (override) {
|
|
@@ -1056,6 +1059,7 @@ class ClientDb extends Client {
|
|
|
1056
1059
|
return ClientDb.findResult(this.moduleName + '_' + source, uuidKey || credential, queryString, value === 0 ? 0 : ClientDb.getTimeout(value || this.settingsOf(source, 'cache')), sessionKey, renewCache);
|
|
1057
1060
|
}
|
|
1058
1061
|
setQueryResult(source, credential, queryString, result, sessionKey) {
|
|
1062
|
+
var _j;
|
|
1059
1063
|
if (!Array.isArray(result)) {
|
|
1060
1064
|
result = result === undefined ? [] : [result];
|
|
1061
1065
|
}
|
|
@@ -1064,7 +1068,7 @@ class ClientDb extends Client {
|
|
|
1064
1068
|
}
|
|
1065
1069
|
const uuidKey = ClientDb.extractUUID(credential);
|
|
1066
1070
|
let options;
|
|
1067
|
-
if (ClientDb.enabled("memory.settings.users", this.host
|
|
1071
|
+
if (ClientDb.enabled("memory.settings.users", (_j = this.host) === null || _j === void 0 ? void 0 : _j.username)) {
|
|
1068
1072
|
let value;
|
|
1069
1073
|
if ((0, types_1.isObject)(sessionKey)) {
|
|
1070
1074
|
({ value, sessionKey } = sessionKey);
|
|
@@ -1196,28 +1200,28 @@ class Permission {
|
|
|
1196
1200
|
result.setDiskRead(disk_read);
|
|
1197
1201
|
valid = true;
|
|
1198
1202
|
}
|
|
1199
|
-
else if (parent
|
|
1203
|
+
else if (parent === null || parent === void 0 ? void 0 : parent.diskRead) {
|
|
1200
1204
|
result.setDiskRead(parent.getDiskRead());
|
|
1201
1205
|
}
|
|
1202
1206
|
if (readable(disk_write) && (!parent || parent.diskWrite)) {
|
|
1203
1207
|
result.setDiskWrite(disk_write);
|
|
1204
1208
|
valid = true;
|
|
1205
1209
|
}
|
|
1206
|
-
else if (parent
|
|
1210
|
+
else if (parent === null || parent === void 0 ? void 0 : parent.diskWrite) {
|
|
1207
1211
|
result.setDiskWrite(parent.getDiskWrite());
|
|
1208
1212
|
}
|
|
1209
1213
|
if (readable(unc_read) && (!parent || parent.uncRead)) {
|
|
1210
1214
|
result.setUNCRead(unc_read);
|
|
1211
1215
|
valid = true;
|
|
1212
1216
|
}
|
|
1213
|
-
else if (parent
|
|
1217
|
+
else if (parent === null || parent === void 0 ? void 0 : parent.uncRead) {
|
|
1214
1218
|
result.setUNCRead(parent.getUNCRead());
|
|
1215
1219
|
}
|
|
1216
1220
|
if (readable(unc_write) && (!parent || parent.uncWrite)) {
|
|
1217
1221
|
result.setUNCWrite(unc_write);
|
|
1218
1222
|
valid = true;
|
|
1219
1223
|
}
|
|
1220
|
-
else if (parent
|
|
1224
|
+
else if (parent === null || parent === void 0 ? void 0 : parent.uncWrite) {
|
|
1221
1225
|
result.setUNCWrite(parent.getUNCWrite());
|
|
1222
1226
|
}
|
|
1223
1227
|
if (valid) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
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.5.
|
|
24
|
-
"@e-mc/types": "0.5.
|
|
23
|
+
"@e-mc/module": "0.5.7",
|
|
24
|
+
"@e-mc/types": "0.5.7",
|
|
25
25
|
"picomatch": "^2.3.1"
|
|
26
26
|
}
|
|
27
27
|
}
|