@e-mc/types 0.9.6 → 0.10.0

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/README.md CHANGED
@@ -9,18 +9,16 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.9.6/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.10.0/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { LogArguments } from "./lib/logger";
16
- import type { CloneObjectOptions } from "./lib/module";
17
16
 
18
17
  import type { BytesOptions } from "bytes";
19
- import type { BinaryLike, CipherGCMTypes, Encoding } from "crypto";
20
- import type { HighResolutionTime } from "perf_hooks";
18
+ import type { BinaryLike, CipherGCMTypes, Encoding, RandomUUIDOptions } from "crypto";
21
19
 
22
20
  function createAbortError(reject: true): Promise<never>;
23
- function createAbortError(): Error;
21
+ function createAbortError(): DOMException;
24
22
  function hasBit(value: unknown, flags: number): boolean;
25
23
  function ignoreFlag(value: unknown): boolean;
26
24
  function cloneFlag(value: unknown): boolean;
@@ -62,12 +60,16 @@ function coerceObject(data: unknown, parseString?: (...args: [string]) => unknow
62
60
  function getEncoding(value: unknown, fallback?: BufferEncoding): BufferEncoding;
63
61
  function encryptUTF8(algorithm: CipherGCMTypes, key: BinaryLike, iv: BinaryLike, data: string, encoding?: Encoding): string | undefined;
64
62
  function decryptUTF8(algorithm: CipherGCMTypes, key: BinaryLike, iv: BinaryLike, data: string, encoding?: Encoding): string | undefined;
65
- function generateUUID(): string;
63
+ function hashKey(data: BinaryLike, algorithm?: string, encoding?: BinaryToTextEncoding): string;
64
+ /** @deprecated - crypto.randomUUID */
65
+ function generateUUID(options?: RandomUUIDOptions): string;
66
66
  function incrementUUID(restart?: boolean): string;
67
67
  function validateUUID(value: unknown): boolean;
68
68
  function randomString(format: string, dictionary?: string): string;
69
69
  function errorValue(value: string, hint?: string): Error;
70
70
  function errorMessage(title: number | string, value: string, hint?: string): Error;
71
+ function supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
72
+ function importESM<T = unknown>(name: string, isDefault?: boolean, fromPath?: boolean): Promise<T>;
71
73
  function purgeMemory(percent?: number): number;
72
74
 
73
75
  interface LOG_TYPE {
@@ -194,10 +196,12 @@ const IMPORT_MAP: Record<string, string | undefined>;
194
196
 
195
197
  ## References
196
198
 
197
- - https://www.unpkg.com/@e-mc/types@0.9.6/lib/logger.d.ts
198
- - https://www.unpkg.com/@e-mc/types@0.9.6/lib/module.d.ts
199
+ - https://www.unpkg.com/@e-mc/types@0.10.0/index.d.ts
200
+ - https://www.unpkg.com/@e-mc/types@0.10.0/lib/logger.d.ts
201
+ - https://www.unpkg.com/@e-mc/types@0.10.0/lib/module.d.ts
202
+ - https://www.unpkg.com/@e-mc/types@0.10.0/lib/object.d.ts
199
203
 
200
- * https://nodejs.org/api/perf_hooks.html
204
+ * https://developer.mozilla.org/en-US/docs/Web/API/DOMException
201
205
  * https://www.npmjs.com/package/@types/bytes
202
206
 
203
207
  ## LICENSE
package/constant.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export const enum INTERNAL {
2
- VERSION = '0.9.6',
2
+ VERSION = '0.10.0',
3
3
  TEMP_DIR = 'tmp',
4
4
  CJS = '__cjs__'
5
5
  }
@@ -8,6 +8,7 @@ export const enum VAL_MESSAGE {
8
8
  SUCCESS = 'Success',
9
9
  COMPLETED = 'Completed',
10
10
  CHECKSUM = 'Checksum matched',
11
+ MODIFIED_FILE = 'File modified',
11
12
  MODIFIED_DIRECTORY = 'Directory was modified',
12
13
  COMMIT_TRANSACTION = 'Transactions were committed'
13
14
  }
@@ -38,18 +39,22 @@ export const enum ERR_MESSAGE {
38
39
  FAIL = 'FAIL!',
39
40
  WARN = 'WARN!',
40
41
  ABORTED = 'Aborted',
42
+ EXPIRED = 'Expired',
41
43
  ABORTED_HOST = 'Aborted by host',
42
44
  ABORTED_CLIENT = 'Aborted by client',
43
45
  ABORTED_PROCESS = 'Aborted by process',
44
- ABORTED_OPERATION = 'The operation was aborted',
46
+ ABORTED_OPERATION = 'This operation was aborted',
45
47
  FAILED = 'Failed',
46
48
  FAILED_CHECKSUM = 'Checksum did not match',
47
49
  PARAMETERS = 'Invalid parameters',
48
50
  FORMAT = 'Invalid format',
49
51
  CHECKSUM = 'Invalid checksum',
52
+ CONFIG = 'Invalid config',
50
53
  RESPONSE = 'Invalid response',
54
+ FUNCTION = 'Invalid function',
51
55
  SIZE = 'Size limit was exceeded',
52
56
  ERROR_CODE = 'Error code',
57
+ BUSY_RESOURCE = 'Resource already in use',
53
58
  PERMISSION = 'Operation not permitted',
54
59
  EXEC_PERMISSION = 'Exec command not permitted',
55
60
  NOT_CACHEABLE = 'Not able to cache',
@@ -64,6 +69,7 @@ export const enum ERR_MESSAGE {
64
69
  TIMEOUT = 'Timeout was exceeded',
65
70
  HANDLED_REJECTION = 'Handled rejection',
66
71
  UNSUPPORTED_ACCESS = 'Unsupported access',
72
+ UNSUPPORTED_PROTOCOL = 'Unsupported protocol',
67
73
  UNSUPPORTED_MIME = 'Unsupported MIME',
68
74
  UNSUPPORTED_READ = 'Not permitted to read file',
69
75
  UNSUPPORTED_WRITE = 'Not permitted to write file',
@@ -72,6 +78,7 @@ export const enum ERR_MESSAGE {
72
78
  NOTFOUND_BINARY = 'Binary not found',
73
79
  NOTFOUND_PACKAGE = 'Package not found',
74
80
  NOTFOUND_MIME = 'MIME not found',
81
+ NOTFOUND_TLS = 'TLS/SSL key and cert not found',
75
82
  INSTALL = 'Install required?',
76
83
  INLINE_METHOD = 'Unable to parse inline method',
77
84
  INLINE_OBJECT = 'Unable to parse inline object',
@@ -118,6 +125,7 @@ export const enum ERR_DB {
118
125
  TABLE = 'Missing database table',
119
126
  QUERY = 'Missing database query',
120
127
  CONNECTION = 'Missing connection string',
128
+ TLS = 'Missing TLS/SSL credentials',
121
129
  CLIENT = 'Unable to configure client',
122
130
  EXEC_QUERY = 'Unable to execute query',
123
131
  FILTER_QUERY = 'Unable to filter results',
@@ -159,6 +167,10 @@ export const enum ERR_CLOUD {
159
167
  METADATA_FAIL = 'Metadata failed'
160
168
  }
161
169
 
170
+ export const enum ERR_COMPRESS {
171
+ API_KEY = 'Missing API key'
172
+ }
173
+
162
174
  export const enum ERR_IMAGE {
163
175
  ROTATE = 'Unable to rotate image',
164
176
  FINALIZE = 'Unable to finalize image',
@@ -168,7 +180,16 @@ export const enum ERR_IMAGE {
168
180
 
169
181
  export const enum ERR_HTTP {
170
182
  HEADERS = 'Unable to process headers',
183
+ FORMAT = 'Unable to parse URI response',
184
+ SERVER_WEBSOCKET = 'Unable to create WebSocket server',
171
185
  ETAG = 'ETag not supported',
186
+ REQUEST = 'Invalid HTTP request',
187
+ TIMEOUT = 'HTTP request timeout',
188
+ TIMEOUT_CONNECTION = 'HTTP connection timeout',
189
+ DATA_RECEIVED = 'No data received',
190
+ REDIRECT_LIMIT = 'Exceeded redirect limit',
191
+ REDIRECT_FOLLOW = 'Follow redirect was disabled',
192
+ REDIRECT_MISSING = 'Missing redirect location',
172
193
  DOWNLOAD_SUCCESS = 'No files were successfully downloaded',
173
194
  MULTIPART_ATTACH = 'No files were attached'
174
195
  }
@@ -229,6 +250,14 @@ export const enum PACKAGE_NAME {
229
250
  WATCH_FILEGROUP = '@e-mc/watch/filegroup'
230
251
  }
231
252
 
253
+ export const enum MIME_TYPE {
254
+ MULTIPART = 'multipart/form-data',
255
+ URLENCODED = 'application/x-www-form-urlencoded',
256
+ JSON = 'application/json',
257
+ TEXT = 'text/plain',
258
+ OCTET_STREAM = 'application/octet-stream'
259
+ }
260
+
232
261
  export const enum ASSET_FLAG {
233
262
  NONE = 0,
234
263
  IGNORE = 1,
@@ -263,15 +292,15 @@ export const enum LOG_TYPE {
263
292
  }
264
293
 
265
294
  export const enum LOG_STATE {
266
- STDIN = 0,
267
- STDOUT = 1,
268
- STDERR = 2
295
+ STDIN,
296
+ STDOUT,
297
+ STDERR
269
298
  }
270
299
 
271
300
  export const enum READDIR_SORT {
272
- FILE = 0,
273
- DIRECTORY = 1,
274
- DESCENDING = 2
301
+ FILE,
302
+ DIRECTORY,
303
+ DESCENDING
275
304
  }
276
305
 
277
306
  export const enum SETTINGS_KEY_NAME {
package/index.d.ts CHANGED
@@ -1,18 +1,14 @@
1
+ /// <reference lib="dom" />
1
2
  /// <reference path="./lib/type.d.ts" />
2
3
  /// <reference path="./lib/object.d.ts" />
3
4
 
4
5
  import type { LogArguments } from './lib/logger';
5
- import type { CloneObjectOptions } from './lib/module';
6
6
 
7
- import type { BinaryLike, CipherGCMTypes, Encoding } from 'crypto';
7
+ import type { BinaryLike, BinaryToTextEncoding, CipherGCMTypes, Encoding, RandomUUIDOptions } from 'crypto';
8
8
 
9
9
  // @ts-ignore
10
10
  import type { BytesOptions } from 'bytes';
11
11
 
12
- declare class AbortError extends Error {
13
- code: string;
14
- }
15
-
16
12
  declare namespace types {
17
13
  interface LOG_TYPE {
18
14
  UNKNOWN: 0;
@@ -266,10 +262,24 @@ declare namespace types {
266
262
 
267
263
  const IMPORT_MAP: StringMap;
268
264
 
265
+ interface CloneObjectOptions<T = unknown> {
266
+ target?: T;
267
+ deep?: boolean;
268
+ deepIgnore?: WeakSet<object>;
269
+ mergeArray?: MergeArrayMethod;
270
+ mergeDepth?: number;
271
+ typedArray?: boolean;
272
+ symbol?: boolean;
273
+ inherited?: boolean;
274
+ nonenumerable?: boolean;
275
+ preserve?: boolean;
276
+ }
277
+
278
+ type MergeArrayMethod = "concat" | "concat-pre" | "includes" | "unshift" | "push" | "flat" | "join" | "slice" | "reverse" | ["flat", number] | ["join", string] | ["slice", number, number?];
269
279
  type WatchEventValue = WATCH_EVENT[keyof WATCH_EVENT];
270
280
 
271
281
  function createAbortError(reject: true): Promise<never>;
272
- function createAbortError(): AbortError;
282
+ function createAbortError(): DOMException;
273
283
  function hasBit(value: unknown, flags: number): boolean;
274
284
  function ignoreFlag(value: unknown): boolean;
275
285
  function cloneFlag(value: unknown): boolean;
@@ -280,7 +290,7 @@ declare namespace types {
280
290
  function mainFlag(value: unknown): boolean;
281
291
  function existsFlag(value: unknown): boolean;
282
292
  function getLogCurrent(): Null<LogArguments>;
283
- function setLogCurrent(value: LogArguments): void;
293
+ function setLogCurrent(value: Null<LogArguments>): void;
284
294
  function setTempDir(value: string): boolean;
285
295
  function getTempDir(): string;
286
296
  function isArray<T>(value: unknown): value is T[];
@@ -289,11 +299,11 @@ declare namespace types {
289
299
  function isString(value: unknown): value is string;
290
300
  function isEmpty(value: unknown): boolean;
291
301
  function asFunction<T = unknown, U = FunctionType<Promise<T> | T>>(value: unknown, sync?: boolean): Null<U>;
292
- function parseTime(value: NumString, start?: number): number;
293
- function parseExpires(value: NumString, start?: number): number;
302
+ function parseTime(value: number | string, start?: number): number;
303
+ function parseExpires(value: number | string, start?: number): number;
294
304
  function formatTime(value: number, char: string): string;
295
305
  function formatTime(value: number, elapsed?: boolean, char?: string): string;
296
- function convertTime(value: NumString): number;
306
+ function convertTime(value: number | string): number;
297
307
  function convertTime(value: HighResolutionTime, format: true): string;
298
308
  function convertTime(value: HighResolutionTime, format?: boolean): number;
299
309
  function hasGlob(value: string): boolean;
@@ -311,13 +321,16 @@ declare namespace types {
311
321
  function getEncoding(value: unknown, fallback?: BufferEncoding): BufferEncoding;
312
322
  function encryptUTF8(algorithm: CipherGCMTypes, key: BinaryLike, iv: BinaryLike, data: string, encoding?: Encoding): Undef<string>;
313
323
  function decryptUTF8(algorithm: CipherGCMTypes, key: BinaryLike, iv: BinaryLike, data: string, encoding?: Encoding): Undef<string>;
314
- /** @deprecated crypto.randomUUID */
315
- function generateUUID(): string;
324
+ function hashKey(data: BinaryLike, algorithm?: string, encoding?: BinaryToTextEncoding): string;
325
+ /** @deprecated - crypto.randomUUID */
326
+ function generateUUID(options?: RandomUUIDOptions): string;
316
327
  function incrementUUID(restart?: boolean): string;
317
328
  function validateUUID(value: unknown): boolean;
318
329
  function randomString(format: string, dictionary?: string): string;
319
330
  function errorValue(value: string, hint?: string): Error;
320
- function errorMessage(title: NumString, value: string, hint?: string): Error;
331
+ function errorMessage(title: number | string, value: string, hint?: string): Error;
332
+ function supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
333
+ function importESM<T = unknown>(name: string, isDefault?: boolean, fromPath?: boolean): Promise<T>;
321
334
  function purgeMemory(percent?: number): number;
322
335
  }
323
336