@e-mc/types 0.7.1 → 0.7.3

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,7 @@
1
- Copyright 2023 An Pham
1
+ Copyright 2023 Sukina
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,5 +1,7 @@
1
- ### @e-mc/types
1
+ # @e-mc/types
2
2
 
3
- ### LICENSE
3
+ PEP 402 - Forever 2056
4
4
 
5
- BSD 3-Clause
5
+ ## LICENSE
6
+
7
+ MIT
package/constant.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export const enum INTERNAL {
2
- VERSION = '0.7.1',
3
- TEMP_DIR = 'tmp', // eslint-disable-line @typescript-eslint/no-shadow
2
+ VERSION = '0.7.3',
3
+ TEMP_DIR = 'tmp',
4
4
  CJS = '__cjs__'
5
5
  }
6
6
 
package/index.d.ts CHANGED
@@ -281,7 +281,7 @@ declare namespace types {
281
281
  function cloneObject<T>(data: T, deepIgnore: WeakSet<object>): T;
282
282
  function cloneObject<T, U>(data: T, options?: CloneObjectOptions<U>): T;
283
283
  function coerceObject<T = unknown>(data: T, cache: boolean): T;
284
- function coerceObject<T = unknown>(data: T, parseString?: FunctionArgs<[string], unknown>, cache?: boolean): T;
284
+ function coerceObject<T = unknown>(data: T, parseString?: FunctionArgs<[string]>, cache?: boolean): T;
285
285
  function getEncoding(value: unknown, fallback?: BufferEncoding): BufferEncoding;
286
286
  function encryptUTF8(algorithm: CipherGCMTypes, key: BinaryLike, iv: BinaryLike, data: string, encoding?: Encoding): Undef<string>;
287
287
  function decryptUTF8(algorithm: CipherGCMTypes, key: BinaryLike, iv: BinaryLike, data: string, encoding?: Encoding): Undef<string>;
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.errorValue = exports.validateUUID = exports.randomString = exports.decryptUTF8 = exports.encryptUTF8 = exports.getEncoding = exports.asFunction = exports.coerceObject = exports.cloneObject = exports.cascadeObject = exports.formatSize = exports.renameExt = exports.escapePattern = exports.hasGlob = exports.convertTime = exports.formatTime = exports.parseExpires = exports.parseTime = exports.isEmpty = exports.isString = exports.isObject = exports.isPlainObject = exports.isArray = exports.setTempDir = exports.getTempDir = exports.setLogCurrent = exports.getLogCurrent = exports.existsFlag = exports.mainFlag = exports.processFlag = exports.modifiedFlag = exports.watchFlag = exports.usingFlag = exports.cloneFlag = exports.ignoreFlag = exports.hasBit = exports.createAbortError = exports.IMPORT_MAP = exports.THRESHOLD = exports.READDIR_SORT = exports.WATCH_EVENT = exports.DB_TRANSACTION = exports.DB_TYPE = exports.FETCH_TYPE = exports.DOWNLOAD_TYPE = exports.ERR_CODE = exports.ASSET_FLAG = exports.FILE_TYPE = exports.STATUS_TYPE = exports.LOG_TYPE = void 0;
4
- exports.generateUUID = exports.purgeMemory = exports.errorMessage = void 0;
3
+ exports.errorMessage = exports.errorValue = exports.validateUUID = exports.randomString = exports.decryptUTF8 = exports.encryptUTF8 = exports.getEncoding = exports.asFunction = exports.coerceObject = exports.cloneObject = exports.cascadeObject = exports.formatSize = exports.renameExt = exports.escapePattern = exports.hasGlob = exports.convertTime = exports.formatTime = exports.parseExpires = exports.parseTime = exports.isEmpty = exports.isString = exports.isObject = exports.isPlainObject = exports.isArray = exports.setTempDir = exports.getTempDir = exports.setLogCurrent = exports.getLogCurrent = exports.existsFlag = exports.mainFlag = exports.processFlag = exports.modifiedFlag = exports.watchFlag = exports.usingFlag = exports.cloneFlag = exports.ignoreFlag = exports.hasBit = exports.createAbortError = exports.THRESHOLD = exports.IMPORT_MAP = exports.WATCH_EVENT = exports.DB_TRANSACTION = exports.DB_TYPE = exports.FETCH_TYPE = exports.DOWNLOAD_TYPE = exports.ERR_CODE = exports.ASSET_FLAG = exports.FILE_TYPE = exports.STATUS_TYPE = exports.LOG_TYPE = void 0;
4
+ exports.generateUUID = exports.purgeMemory = void 0;
5
5
  const path = require("path");
6
6
  const fs = require("fs");
7
7
  const crypto = require("crypto");
@@ -9,7 +9,7 @@ const uuid = require("uuid");
9
9
  const bytes = require("bytes");
10
10
  class AbortError extends Error {
11
11
  constructor() {
12
- super("The operation was aborted" /* ERR_MESSAGE.ABORTED_OPERATION */);
12
+ super("The operation was aborted");
13
13
  this.code = 'ABORT_ERR';
14
14
  this.name = 'AbortError';
15
15
  }
@@ -19,7 +19,7 @@ const REGEXP_FUNCTION = /^(async\s+)?(function(?:\b|\s+)([\w_$]*)\s*\(([^)]*)\)\
19
19
  const ASYNC_FUNCTION = Object.getPrototypeOf(async () => { }).constructor;
20
20
  let CACHE_COERCED = new WeakSet();
21
21
  let LOG_CURRENT = null;
22
- let TEMP_DIR = path.join(process.cwd(), "tmp" /* INTERNAL.TEMP_DIR */);
22
+ let TEMP_DIR = path.join(process.cwd(), "tmp");
23
23
  function fromObject(value, typedArray) {
24
24
  if (isObject(value)) {
25
25
  if (value instanceof Map) {
@@ -241,18 +241,6 @@ var WATCH_EVENT;
241
241
  WATCH_EVENT["CLOSE"] = "close";
242
242
  WATCH_EVENT["ERROR"] = "error";
243
243
  })(WATCH_EVENT || (exports.WATCH_EVENT = WATCH_EVENT = {}));
244
- var READDIR_SORT;
245
- (function (READDIR_SORT) {
246
- READDIR_SORT[READDIR_SORT["FILE"] = 0] = "FILE";
247
- READDIR_SORT[READDIR_SORT["DIRECTORY"] = 1] = "DIRECTORY";
248
- READDIR_SORT[READDIR_SORT["DESCENDING"] = 2] = "DESCENDING";
249
- })(READDIR_SORT || (exports.READDIR_SORT = READDIR_SORT = {}));
250
- var THRESHOLD;
251
- (function (THRESHOLD) {
252
- THRESHOLD[THRESHOLD["FILEMANAGER_INTERVAL"] = 100] = "FILEMANAGER_INTERVAL";
253
- THRESHOLD[THRESHOLD["WATCH_INTERVAL"] = 500] = "WATCH_INTERVAL";
254
- THRESHOLD[THRESHOLD["WATCH_CHANGE"] = 100] = "WATCH_CHANGE";
255
- })(THRESHOLD || (exports.THRESHOLD = THRESHOLD = {}));
256
244
  var IMPORT_MAP;
257
245
  (function (IMPORT_MAP) {
258
246
  IMPORT_MAP["@squared-functions/cloud"] = "@e-mc/cloud";
@@ -333,6 +321,12 @@ var IMPORT_MAP;
333
321
  IMPORT_MAP["@squared-functions/document/packages/terser"] = "@pi-r/terser";
334
322
  IMPORT_MAP["@squared-functions/document/packages/uglify-js"] = "@pi-r/uglify-js";
335
323
  })(IMPORT_MAP || (exports.IMPORT_MAP = IMPORT_MAP = {}));
324
+ var THRESHOLD;
325
+ (function (THRESHOLD) {
326
+ THRESHOLD[THRESHOLD["FILEMANAGER_INTERVAL"] = 100] = "FILEMANAGER_INTERVAL";
327
+ THRESHOLD[THRESHOLD["WATCH_INTERVAL"] = 500] = "WATCH_INTERVAL";
328
+ THRESHOLD[THRESHOLD["WATCH_CHANGE"] = 100] = "WATCH_CHANGE";
329
+ })(THRESHOLD || (exports.THRESHOLD = THRESHOLD = {}));
336
330
  function createAbortError() {
337
331
  return new AbortError();
338
332
  }
@@ -342,35 +336,35 @@ function hasBit(value, flags) {
342
336
  }
343
337
  exports.hasBit = hasBit;
344
338
  function ignoreFlag(value) {
345
- return typeof value === 'number' && (value & 1 /* IASSET_FLAG.IGNORE */) === 1 /* IASSET_FLAG.IGNORE */;
339
+ return typeof value === 'number' && (value & 1) === 1;
346
340
  }
347
341
  exports.ignoreFlag = ignoreFlag;
348
342
  function cloneFlag(value) {
349
- return typeof value === 'number' && (value & 2 /* IASSET_FLAG.CLONE */) === 2 /* IASSET_FLAG.CLONE */;
343
+ return typeof value === 'number' && (value & 2) === 2;
350
344
  }
351
345
  exports.cloneFlag = cloneFlag;
352
346
  function usingFlag(value) {
353
- return typeof value === 'number' && (value & 4 /* IASSET_FLAG.USING */) === 4 /* IASSET_FLAG.USING */;
347
+ return typeof value === 'number' && (value & 4) === 4;
354
348
  }
355
349
  exports.usingFlag = usingFlag;
356
350
  function watchFlag(value) {
357
- return typeof value === 'number' && (value & 8 /* IASSET_FLAG.WATCH */) === 8 /* IASSET_FLAG.WATCH */;
351
+ return typeof value === 'number' && (value & 8) === 8;
358
352
  }
359
353
  exports.watchFlag = watchFlag;
360
354
  function modifiedFlag(value) {
361
- return typeof value === 'number' && (value & 16 /* IASSET_FLAG.MODIFIED */) === 16 /* IASSET_FLAG.MODIFIED */;
355
+ return typeof value === 'number' && (value & 16) === 16;
362
356
  }
363
357
  exports.modifiedFlag = modifiedFlag;
364
358
  function processFlag(value) {
365
- return typeof value === 'number' && (value & 32 /* IASSET_FLAG.PROCESS */) === 32 /* IASSET_FLAG.PROCESS */;
359
+ return typeof value === 'number' && (value & 32) === 32;
366
360
  }
367
361
  exports.processFlag = processFlag;
368
362
  function mainFlag(value) {
369
- return typeof value === 'number' && (value & 64 /* IASSET_FLAG.MAIN */) === 64 /* IASSET_FLAG.MAIN */;
363
+ return typeof value === 'number' && (value & 64) === 64;
370
364
  }
371
365
  exports.mainFlag = mainFlag;
372
366
  function existsFlag(value) {
373
- return typeof value === 'number' && (value & 128 /* IASSET_FLAG.EXISTS */) === 128 /* IASSET_FLAG.EXISTS */;
367
+ return typeof value === 'number' && (value & 128) === 128;
374
368
  }
375
369
  exports.existsFlag = existsFlag;
376
370
  function getLogCurrent() {
@@ -429,25 +423,25 @@ function parseTime(value, start = 0) {
429
423
  }
430
424
  switch (match[2]) {
431
425
  case 'y':
432
- result += n * 31449600000 /* TIME.Y */;
426
+ result += n * 31449600000;
433
427
  break;
434
428
  case 'M':
435
- result += n * 2592000000 /* TIME.M */;
429
+ result += n * 2592000000;
436
430
  break;
437
431
  case 'w':
438
- result += n * 604800000 /* TIME.W */;
432
+ result += n * 604800000;
439
433
  break;
440
434
  case 'd':
441
- result += n * 86400000 /* TIME.D */;
435
+ result += n * 86400000;
442
436
  break;
443
437
  case 'h':
444
- result += n * 3600000 /* TIME.H */;
438
+ result += n * 3600000;
445
439
  break;
446
440
  case 'm':
447
- result += n * 60000 /* TIME.m */;
441
+ result += n * 60000;
448
442
  break;
449
443
  case 's':
450
- result += n * 1000 /* TIME.S */;
444
+ result += n * 1000;
451
445
  break;
452
446
  case 'ms':
453
447
  result += Math.ceil(n);
@@ -459,7 +453,7 @@ function parseTime(value, start = 0) {
459
453
  }
460
454
  }
461
455
  else if (seconds > 0) {
462
- return Math.ceil(seconds * 1000 /* TIME.S */) + start;
456
+ return Math.ceil(seconds * 1000) + start;
463
457
  }
464
458
  return 0;
465
459
  }
@@ -482,18 +476,18 @@ function formatTime(value, elapsed, char = ' ') {
482
476
  if (value < 1000) {
483
477
  return value + 'ms';
484
478
  }
485
- const h = Math.floor(value / 3600000 /* TIME.H */);
479
+ const h = Math.floor(value / 3600000);
486
480
  if (h > 0) {
487
- value -= h * 3600000 /* TIME.H */;
481
+ value -= h * 3600000;
488
482
  result.push(h + 'h');
489
483
  }
490
- const m = Math.floor(value / 60000 /* TIME.m */);
484
+ const m = Math.floor(value / 60000);
491
485
  if (m > 0) {
492
- value -= m * 60000 /* TIME.m */;
486
+ value -= m * 60000;
493
487
  result.push(m + 'm');
494
488
  }
495
489
  if (value > 0) {
496
- result.push(value < 100 ? value + 'ms' : (value / 1000 /* TIME.S */).toPrecision(value <= 9950 ? 2 : 3).replace(/\.?0+$/, '') + 's');
490
+ result.push(value < 100 ? value + 'ms' : (value / 1000).toPrecision(value <= 9950 ? 2 : 3).replace(/\.?0+$/, '') + 's');
497
491
  }
498
492
  return result.join(char);
499
493
  }
@@ -549,10 +543,10 @@ function escapePattern(value, lookBehind) {
549
543
  }
550
544
  exports.escapePattern = escapePattern;
551
545
  function renameExt(value, ext, when) {
552
- if (ext[0] !== '.') {
546
+ if (!ext.startsWith('.')) {
553
547
  ext = '.' + ext;
554
548
  }
555
- if (when && when[0] !== '.') {
549
+ if (when && !when.startsWith('.')) {
556
550
  when = '.' + when;
557
551
  }
558
552
  const index = value.lastIndexOf('.');
@@ -574,7 +568,7 @@ function formatSize(value, options) {
574
568
  exports.formatSize = formatSize;
575
569
  function cascadeObject(data, query, fallback) {
576
570
  if (isObject(data) && isString(query)) {
577
- const names = query.trim().split(/(?<!\\)\./).map(item => item.indexOf('.') !== -1 ? item.replace(/\\(?=\.)/g, '') : item);
571
+ const names = query.trim().split(/(?<!\\)\./).map(item => item.includes('.') ? item.replace(/\\(?=\.)/g, '') : item);
578
572
  for (let i = 0, length = names.length, match, current = data; i < length; ++i) {
579
573
  if (!(match = /^(.+?)(?:\[(.+)\])?$/.exec(names[i]))) {
580
574
  break;
@@ -729,8 +723,8 @@ function coerceObject(data, parseString, cache) {
729
723
  }
730
724
  default: {
731
725
  const text = match[2].trim();
732
- let values = []; // eslint-disable-line @typescript-eslint/no-explicit-any
733
- if (text[0] === '[' && text[text.length - 1] === ']') {
726
+ let values = [];
727
+ if (text.startsWith('[') && text.endsWith(']')) {
734
728
  values = JSON.parse(text);
735
729
  }
736
730
  else if (text) {
@@ -855,7 +849,7 @@ function randomString(format, dictionary) {
855
849
  dictionary || (dictionary = '0123456789abcdef');
856
850
  const result = format.match(/(\d+|[^\d[]+|\[[^\]]+\]|\[)/g).reduce((a, b) => {
857
851
  let length, available;
858
- if (b[0] === '[' && b[b.length - 1] === ']') {
852
+ if (b.startsWith('[') && b.endsWith(']')) {
859
853
  length = 1;
860
854
  available = b.substring(1, b.length - 1);
861
855
  }
package/lib/core.d.ts CHANGED
@@ -12,7 +12,7 @@ export interface IdentifierAction {
12
12
  uuidKey?: string;
13
13
  }
14
14
 
15
- export interface IClient<T extends IHost, U extends ClientModule, V extends FunctionType = FunctionType> extends IModule<T>, IExternalConfig<U, U extends ClientModule<infer W> ? W : unknown>, IExternalFunction<V> {
15
+ export interface IClient<T extends IHost, U extends ClientModule, V extends FunctionType<any, any> = FunctionType> extends IModule<T>, IExternalConfig<U, U extends ClientModule<infer W> ? W : unknown>, IExternalFunction<V> {
16
16
  init(...args: unknown[]): this;
17
17
  set cacheDir(value: string);
18
18
  get cacheDir(): string;
package/lib/index.d.ts CHANGED
@@ -83,7 +83,7 @@ declare namespace functions {
83
83
  new(module?: U): ICompress<T, U>;
84
84
  }
85
85
 
86
- interface IImage<T extends IHost = IHost, U extends ImageModule = ImageModule> extends IClient<T, U, FunctionType> {
86
+ interface IImage<T extends IHost = IHost, U extends ImageModule = ImageModule> extends IClient<T, U> {
87
87
  resizeData?: ResizeData;
88
88
  cropData?: CropData;
89
89
  rotateData?: RotateData;
package/lib/logger.d.ts CHANGED
@@ -93,10 +93,9 @@ export interface LogTypeValue {
93
93
  sessionId?: string;
94
94
  }
95
95
 
96
- export interface LogArguments {
97
- type?: LogType;
98
- value?: LogValue;
96
+ export interface LogArguments extends Pick<LogBaseOptions, "type" | "sessionId"> {
99
97
  title?: string;
98
+ value?: LogValue;
100
99
  message?: unknown;
101
100
  }
102
101
 
package/lib/request.d.ts CHANGED
@@ -65,7 +65,6 @@ export interface OpenOptions extends KeepAliveAction, SilentAction {
65
65
  postData?: unknown;
66
66
  connected?: (headers: IncomingHttpHeaders) => Void<boolean>;
67
67
  statusMessage?: string;
68
- silent?: boolean;
69
68
  outFormat?: { out: BufferFormat; parser?: PlainObject };
70
69
  outFilename?: Null<string>;
71
70
  outHeaders?: Null<IncomingHttpHeaders>;
@@ -105,7 +104,9 @@ export interface ProxySettings extends KeepAliveAction {
105
104
 
106
105
  export interface RequestInit extends ProtocolAction {
107
106
  headers?: unknown;
107
+ /* @deprecated - readTimeout */
108
108
  requestTimeout?: number;
109
+ readTimeout?: number;
109
110
  }
110
111
 
111
112
  export interface ClientConfig {
package/lib/settings.d.ts CHANGED
@@ -81,8 +81,8 @@ export interface PermissionModule<T = PermissionSettings> extends PermittedDirec
81
81
  }
82
82
 
83
83
  export interface PermissionSettings extends PlainObject {
84
- picomatch?: PicomatchOptions;
85
- minimatch?: MinimatchOptions;
84
+ picomatch?: Null<PicomatchOptions>;
85
+ minimatch?: Null<MinimatchOptions>;
86
86
  }
87
87
 
88
88
  export interface DownloadModule<T = PlainObject> extends HandlerSettings<T> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/types",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "Type definitions for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/anpham6/e-mc.git",
12
+ "url": "git+https://github.com/anpham6/e-mc.git",
13
13
  "directory": "src/types"
14
14
  },
15
15
  "keywords": [
@@ -17,7 +17,7 @@
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
23
  "bytes": "^3.1.2",