@e-mc/core 0.8.7 → 0.8.8

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.
Files changed (4) hide show
  1. package/LICENSE +3 -7
  2. package/README.md +10 -10
  3. package/index.js +19 -14
  4. package/package.json +4 -4
package/LICENSE CHANGED
@@ -1,11 +1,7 @@
1
1
  Copyright 2024 An Pham
2
2
 
3
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
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
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
6
 
7
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
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
@@ -1,7 +1,7 @@
1
1
  # @e-mc/core
2
2
 
3
3
  * NodeJS 14
4
- * ES2020
4
+ * ES2019
5
5
 
6
6
  ## General Usage
7
7
 
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/index.d.ts
12
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/index.d.ts
13
13
 
14
14
  ```typescript
15
15
  import type { DataSource, LogStatus } from "./squared";
@@ -165,14 +165,14 @@ interface IPermission {
165
165
 
166
166
  ## References
167
167
 
168
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/squared.d.ts
169
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/core.d.ts
170
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/db.d.ts
171
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/dom.d.ts
172
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/logger.d.ts
173
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/node.d.ts
174
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/settings.d.ts
168
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/squared.d.ts
169
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/core.d.ts
170
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/db.d.ts
171
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/dom.d.ts
172
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/logger.d.ts
173
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/node.d.ts
174
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/settings.d.ts
175
175
 
176
176
  ## LICENSE
177
177
 
178
- BSD 3-Clause
178
+ MIT
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?.config && count >= stored.config.max) {
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) {
@@ -484,8 +484,9 @@ class Host extends module_1.default {
484
484
  }
485
485
  restart(...args) { }
486
486
  isFatal(err) {
487
- const fatal = this.config.error?.fatal;
488
- return fatal ?? super.isFatal(err);
487
+ var _j;
488
+ const fatal = (_j = this.config.error) === null || _j === void 0 ? void 0 : _j.fatal;
489
+ return fatal !== null && fatal !== void 0 ? fatal : super.isFatal(err);
489
490
  }
490
491
  using(...items) {
491
492
  const data = this._usingObjects;
@@ -666,10 +667,11 @@ class Client extends module_1.default {
666
667
  this.module = (0, types_1.isPlainObject)(data) ? data : {};
667
668
  }
668
669
  init(...args) {
670
+ var _j;
669
671
  const { permission, extensions } = this.module;
670
672
  const cache_dir = this.settings.cache_dir;
671
673
  if (permission) {
672
- const result = Permission.create(permission, permission.inherit !== false ? this.host?.permission : null, true);
674
+ const result = Permission.create(permission, permission.inherit !== false ? (_j = this.host) === null || _j === void 0 ? void 0 : _j.permission : null, true);
673
675
  if (result) {
674
676
  this.permission = result;
675
677
  }
@@ -683,9 +685,10 @@ class Client extends module_1.default {
683
685
  return this;
684
686
  }
685
687
  getUserSettings() {
686
- const username = this.host?.username;
688
+ var _j, _k;
689
+ const username = (_j = this.host) === null || _j === void 0 ? void 0 : _j.username;
687
690
  let result;
688
- return username && (0, types_1.isPlainObject)(result = this.settings.users?.[username]) ? result : null;
691
+ return username && (0, types_1.isPlainObject)(result = (_k = this.settings.users) === null || _k === void 0 ? void 0 : _k[username]) ? result : null;
689
692
  }
690
693
  set cacheDir(value) {
691
694
  if (path.isAbsolute(value) && module_1.default.isDir(value)) {
@@ -791,13 +794,14 @@ class ClientDb extends Client {
791
794
  return result > 0 ? result : 0;
792
795
  }
793
796
  static findResult(source, credential, queryString, timeout, sessionKey, renewCache) {
797
+ var _j, _k, _l;
794
798
  const userKey = this.extractUUID(credential) || this.asHash(this.asString(credential));
795
799
  if (!userKey) {
796
800
  return;
797
801
  }
798
802
  queryString = this.asHash(queryString);
799
803
  if (timeout > 0) {
800
- const userCache = CACHE_USER[source]?.[userKey];
804
+ const userCache = (_j = CACHE_USER[source]) === null || _j === void 0 ? void 0 : _j[userKey];
801
805
  let stored;
802
806
  if (!(userCache && (stored = userCache[queryString]))) {
803
807
  return;
@@ -831,7 +835,7 @@ class ClientDb extends Client {
831
835
  delete userCache[queryString];
832
836
  }
833
837
  else if (sessionKey) {
834
- return CACHE_SESSION[source]?.[userKey + sessionKey]?.[queryString];
838
+ return (_l = (_k = CACHE_SESSION[source]) === null || _k === void 0 ? void 0 : _k[userKey + sessionKey]) === null || _l === void 0 ? void 0 : _l[queryString];
835
839
  }
836
840
  }
837
841
  static storeResult(source, credential, queryString, result, options, sessionKey, sessionExpires) {
@@ -1002,7 +1006,7 @@ class ClientDb extends Client {
1002
1006
  }
1003
1007
  }
1004
1008
  hasCache(source, sessionKey, override) {
1005
- return (0, types_1.isString)(sessionKey) || ClientDb.getTimeout(override ?? this.settingsOf(source, 'cache')) > 0;
1009
+ return (0, types_1.isString)(sessionKey) || ClientDb.getTimeout(override !== null && override !== void 0 ? override : this.settingsOf(source, 'cache')) > 0;
1006
1010
  }
1007
1011
  hasCoerce(source, component, override, credential) {
1008
1012
  if (override) {
@@ -1068,6 +1072,7 @@ class ClientDb extends Client {
1068
1072
  }
1069
1073
  }
1070
1074
  setQueryResult(source, credential, queryString, result, sessionKey) {
1075
+ var _j;
1071
1076
  if (!Array.isArray(result)) {
1072
1077
  result = result === undefined ? [] : [result];
1073
1078
  }
@@ -1076,7 +1081,7 @@ class ClientDb extends Client {
1076
1081
  }
1077
1082
  const uuidKey = ClientDb.extractUUID(credential);
1078
1083
  let options;
1079
- if (ClientDb.enabled("memory.settings.users", this.host?.username)) {
1084
+ if (ClientDb.enabled("memory.settings.users", (_j = this.host) === null || _j === void 0 ? void 0 : _j.username)) {
1080
1085
  let value, exclusiveOf;
1081
1086
  if ((0, types_1.isObject)(sessionKey)) {
1082
1087
  ({ value, sessionKey, exclusiveOf } = sessionKey);
@@ -1214,28 +1219,28 @@ class Permission {
1214
1219
  result.setDiskRead(disk_read);
1215
1220
  valid = true;
1216
1221
  }
1217
- else if (parent?.diskRead) {
1222
+ else if (parent === null || parent === void 0 ? void 0 : parent.diskRead) {
1218
1223
  result.setDiskRead(parent.getDiskRead());
1219
1224
  }
1220
1225
  if (readable(disk_write) && (!parent || parent.diskWrite)) {
1221
1226
  result.setDiskWrite(disk_write);
1222
1227
  valid = true;
1223
1228
  }
1224
- else if (parent?.diskWrite) {
1229
+ else if (parent === null || parent === void 0 ? void 0 : parent.diskWrite) {
1225
1230
  result.setDiskWrite(parent.getDiskWrite());
1226
1231
  }
1227
1232
  if (readable(unc_read) && (!parent || parent.uncRead)) {
1228
1233
  result.setUNCRead(unc_read);
1229
1234
  valid = true;
1230
1235
  }
1231
- else if (parent?.uncRead) {
1236
+ else if (parent === null || parent === void 0 ? void 0 : parent.uncRead) {
1232
1237
  result.setUNCRead(parent.getUNCRead());
1233
1238
  }
1234
1239
  if (readable(unc_write) && (!parent || parent.uncWrite)) {
1235
1240
  result.setUNCWrite(unc_write);
1236
1241
  valid = true;
1237
1242
  }
1238
- else if (parent?.uncWrite) {
1243
+ else if (parent === null || parent === void 0 ? void 0 : parent.uncWrite) {
1239
1244
  result.setUNCWrite(parent.getUNCWrite());
1240
1245
  }
1241
1246
  if (valid) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/core",
3
- "version": "0.8.7",
3
+ "version": "0.8.8",
4
4
  "description": "Core modules for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -17,11 +17,11 @@
17
17
  "squared-functions"
18
18
  ],
19
19
  "author": "An Pham <anpham6@gmail.com>",
20
- "license": "BSD 3-Clause",
20
+ "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/module": "0.8.7",
24
- "@e-mc/types": "0.8.7",
23
+ "@e-mc/module": "0.8.8",
24
+ "@e-mc/types": "0.8.8",
25
25
  "picomatch": "^3.0.1"
26
26
  }
27
27
  }