@e-mc/core 0.8.0 → 0.8.2

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 CHANGED
@@ -1,11 +1,11 @@
1
- Copyright 2023 An Pham
2
-
3
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
-
5
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
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
-
1
+ Copyright 2023 An Pham
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
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
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.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  ### @e-mc/core
2
2
 
3
+ https://e-mc.readthedocs.io
4
+
3
5
  ### LICENSE
4
6
 
5
7
  BSD 3-Clause
package/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import type { HostConstructor, ModuleConstructor } from '../types/lib';
2
- import type { AbortComponentConstructor, ClientConstructor, ClientDbConstructor, PermissionConstructor } from '../types/lib/core';
3
-
4
- declare namespace core {
5
- const Module: ModuleConstructor;
6
- const Host: HostConstructor;
7
- const Client: ClientConstructor;
8
- const ClientDb: ClientDbConstructor;
9
- const AbortComponent: AbortComponentConstructor;
10
- const Permission: PermissionConstructor;
11
- }
12
-
1
+ import type { HostConstructor, ModuleConstructor } from '../types/lib';
2
+ import type { AbortComponentConstructor, ClientConstructor, ClientDbConstructor, PermissionConstructor } from '../types/lib/core';
3
+
4
+ declare namespace core {
5
+ const Module: ModuleConstructor;
6
+ const Host: HostConstructor;
7
+ const Client: ClientConstructor;
8
+ const ClientDb: ClientDbConstructor;
9
+ const AbortComponent: AbortComponentConstructor;
10
+ const Permission: PermissionConstructor;
11
+ }
12
+
13
13
  export = core;
package/index.js CHANGED
@@ -216,6 +216,10 @@ function updateHostQueue(host, position, priority, broadcast) {
216
216
  host.formatMessage(2 /* LOG_TYPE.NODE */, 'QUEUE', ["Thread limit exceeded" /* ERR_MESSAGE.THREAD */ + ` (position #${position + 1})`, host.username], 'Priority: ' + priority, { type: 2 /* LOG_TYPE.NODE */, ...module_1.default.LOG_STYLE_WARN });
217
217
  }
218
218
  }
219
+ function isInvalidRange(result, range) {
220
+ const [lower, upper = 0] = range;
221
+ return result.length <= lower || upper > 0 && result.length > upper;
222
+ }
219
223
  function asPosix(value) {
220
224
  value = path.normalize(value.trim());
221
225
  return PLATFORM_WIN32 ? value.replace(/(?:^\\|\\+)/g, '/') : value;
@@ -767,7 +771,7 @@ class ClientDb extends Client {
767
771
  result = convertSeconds(value);
768
772
  break;
769
773
  case 'object':
770
- if (value && typeof (result = value.timeout) === 'string') {
774
+ if (value !== null && typeof (result = value.timeout) === 'string') {
771
775
  result = convertSeconds(value.timeout);
772
776
  value.timeout = result;
773
777
  }
@@ -1030,7 +1034,7 @@ class ClientDb extends Client {
1030
1034
  return this.settingsOf(source, 'coerce', component) === true || component === 'options' && this.settingsOf(source, 'coerce') === true;
1031
1035
  }
1032
1036
  getQueryResult(source, credential, queryString, options, renewCache) {
1033
- let sessionKey, value;
1037
+ let sessionKey, value, exclusiveOf;
1034
1038
  switch (typeof options) {
1035
1039
  case 'boolean':
1036
1040
  renewCache = options;
@@ -1039,8 +1043,16 @@ class ClientDb extends Client {
1039
1043
  sessionKey = options;
1040
1044
  break;
1041
1045
  case 'object':
1042
- if (options) {
1043
- ({ value, sessionKey, renewCache } = options);
1046
+ if (options !== null) {
1047
+ ({ value, sessionKey, renewCache, exclusiveOf } = options);
1048
+ if (Array.isArray(exclusiveOf)) {
1049
+ const ignoreCache = exclusiveOf[2];
1050
+ if (ignoreCache === 1) {
1051
+ return;
1052
+ }
1053
+ renewCache || (renewCache = ignoreCache === 0);
1054
+ queryString += '_' + exclusiveOf.toString();
1055
+ }
1044
1056
  }
1045
1057
  break;
1046
1058
  }
@@ -1051,7 +1063,10 @@ class ClientDb extends Client {
1051
1063
  value = cache;
1052
1064
  }
1053
1065
  }
1054
- return ClientDb.findResult(this.moduleName + '_' + source, uuidKey || credential, queryString, value === 0 ? 0 : ClientDb.getTimeout(value || this.settingsOf(source, 'cache')), sessionKey, renewCache);
1066
+ const result = ClientDb.findResult(this.moduleName + '_' + source, uuidKey || credential, queryString, value === 0 ? 0 : ClientDb.getTimeout(value || this.settingsOf(source, 'cache')), sessionKey, renewCache);
1067
+ if (!exclusiveOf || !isInvalidRange(result, exclusiveOf)) {
1068
+ return result;
1069
+ }
1055
1070
  }
1056
1071
  setQueryResult(source, credential, queryString, result, sessionKey) {
1057
1072
  if (!Array.isArray(result)) {
@@ -1063,9 +1078,15 @@ class ClientDb extends Client {
1063
1078
  const uuidKey = ClientDb.extractUUID(credential);
1064
1079
  let options;
1065
1080
  if (ClientDb.enabled("memory.settings.users" /* KEY_NAME.MEMORY_SETTINGS_USERS */, this.host?.username)) {
1066
- let value;
1081
+ let value, exclusiveOf;
1067
1082
  if ((0, types_1.isObject)(sessionKey)) {
1068
- ({ value, sessionKey } = sessionKey);
1083
+ ({ value, sessionKey, exclusiveOf } = sessionKey);
1084
+ }
1085
+ if (Array.isArray(exclusiveOf)) {
1086
+ if (isInvalidRange(result, exclusiveOf)) {
1087
+ return result;
1088
+ }
1089
+ queryString += '_' + exclusiveOf.toString();
1069
1090
  }
1070
1091
  if (uuidKey) {
1071
1092
  const cache = this.settingsKey(uuidKey, 'cache');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/core",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
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": "BSD 3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/module": "0.8.0",
24
- "@e-mc/types": "0.8.0",
23
+ "@e-mc/module": "0.8.2",
24
+ "@e-mc/types": "0.8.2",
25
25
  "picomatch": "^3.0.1"
26
26
  }
27
27
  }