@e-mc/core 0.7.2 → 0.7.4
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 +4 -8
- package/README.md +1 -1
- package/index.js +16 -12
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
Copyright 2023
|
|
1
|
+
Copyright 2023 Sukina
|
|
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
|
|
|
5
|
-
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
-
|
|
11
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
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.4",
|
|
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.4",
|
|
24
|
+
"@e-mc/types": "0.7.4",
|
|
25
25
|
"picomatch": "^3.0.1"
|
|
26
26
|
}
|
|
27
27
|
}
|