@e-mc/types 0.10.6 → 0.11.1

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
@@ -8,4 +8,4 @@ Redistribution and use in source and binary forms, with or without modification,
8
8
 
9
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
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.
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,7 +1,7 @@
1
1
  # @e-mc/types
2
2
 
3
- * NodeJS 16
4
- * ES2020
3
+ * NodeJS 16 LTS
4
+ * ES2021
5
5
 
6
6
  ## General Usage
7
7
 
@@ -9,13 +9,14 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.10.6/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.11.1/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { LogArguments } from "./lib/logger";
16
+ import type { HighResolutionTime } from "./lib/node";
16
17
 
18
+ import type { BinaryLike, CipherGCMTypes, Encoding, RandomUUIDOptions } from "node:crypto";
17
19
  import type { BytesOptions } from "bytes";
18
- import type { BinaryLike, CipherGCMTypes, Encoding, RandomUUIDOptions } from "crypto";
19
20
 
20
21
  function createAbortError(reject: true): Promise<never>;
21
22
  function createAbortError(): DOMException;
@@ -46,7 +47,7 @@ function convertTime(value: number | string): number;
46
47
  function convertTime(value: HighResolutionTime, format: true): string;
47
48
  function convertTime(value: HighResolutionTime, format?: boolean): number;
48
49
  function hasGlob(value: string): boolean;
49
- function escapePattern(value: unknown, lookBehind?: boolean): string;
50
+ function escapePattern(value: unknown, lookBehind?: boolean, reserved?: boolean): string;
50
51
  function renameExt(value: string, ext: string, when?: string): string;
51
52
  function formatSize(value: string): number;
52
53
  function formatSize(value: number, options?: BytesOptions): string;
@@ -68,6 +69,7 @@ function validateUUID(value: unknown): boolean;
68
69
  function randomString(format: string, dictionary?: string): string;
69
70
  function errorValue(value: string, hint?: string): Error;
70
71
  function errorMessage(title: number | string, value: string, hint?: string): Error;
72
+ function supported(major: number, minor: number, lts: boolean): boolean;
71
73
  function supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
72
74
  function importESM<T = unknown>(name: string, isDefault?: boolean, fromPath?: boolean): Promise<T>;
73
75
  function purgeMemory(percent?: number): number;
@@ -196,14 +198,14 @@ const IMPORT_MAP: Record<string, string | undefined>;
196
198
 
197
199
  ## References
198
200
 
199
- - https://www.unpkg.com/@e-mc/types@0.10.6/index.d.ts
200
- - https://www.unpkg.com/@e-mc/types@0.10.6/lib/logger.d.ts
201
- - https://www.unpkg.com/@e-mc/types@0.10.6/lib/module.d.ts
202
- - https://www.unpkg.com/@e-mc/types@0.10.6/lib/object.d.ts
201
+ - https://www.unpkg.com/@e-mc/types@0.11.1/index.d.ts
202
+ - https://www.unpkg.com/@e-mc/types@0.11.1/lib/logger.d.ts
203
+ - https://www.unpkg.com/@e-mc/types@0.11.1/lib/module.d.ts
204
+ - https://www.unpkg.com/@e-mc/types@0.11.1/lib/node.d.ts
203
205
 
204
206
  * https://developer.mozilla.org/en-US/docs/Web/API/DOMException
205
207
  * https://www.npmjs.com/package/@types/bytes
206
208
 
207
209
  ## LICENSE
208
210
 
209
- BSD 3-Clause
211
+ BSD 3-Clause
package/constant.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export const enum INTERNAL {
2
- VERSION = '0.9.15',
2
+ VERSION = '0.11.1',
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,17 @@ 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',
193
+ EXPECT_CONTINUE = 'Did not receive continue acknowledgment',
172
194
  DOWNLOAD_SUCCESS = 'No files were successfully downloaded',
173
195
  MULTIPART_ATTACH = 'No files were attached'
174
196
  }
@@ -203,7 +225,6 @@ export const enum TIME {
203
225
  export const enum PACKAGE_NAME {
204
226
  CLOUD = '@e-mc/cloud',
205
227
  CLOUD_UTIL = '@e-mc/cloud/util',
206
- COMPAT_V4 = '@e-mc/compat-v4',
207
228
  COMPRESS = '@e-mc/compress',
208
229
  CORE = '@e-mc/core',
209
230
  DB = '@e-mc/db',
@@ -218,7 +239,6 @@ export const enum PACKAGE_NAME {
218
239
  IMAGE = '@e-mc/image',
219
240
  IMAGE_JIMP = '@pi-r/jimp',
220
241
  MODULE = '@e-mc/module',
221
- MODULE_LIB_V4 = '@e-mc/module/lib-v4',
222
242
  REQUEST = '@e-mc/request',
223
243
  REQUEST_HTTP_HOST = '@e-mc/request/http/host',
224
244
  REQUEST_UTIL = '@e-mc/request/util',
@@ -229,6 +249,14 @@ export const enum PACKAGE_NAME {
229
249
  WATCH_FILEGROUP = '@e-mc/watch/filegroup'
230
250
  }
231
251
 
252
+ export const enum MIME_TYPE {
253
+ MULTIPART = 'multipart/form-data',
254
+ URLENCODED = 'application/x-www-form-urlencoded',
255
+ JSON = 'application/json',
256
+ TEXT = 'text/plain',
257
+ OCTET_STREAM = 'application/octet-stream'
258
+ }
259
+
232
260
  export const enum ASSET_FLAG {
233
261
  NONE = 0,
234
262
  IGNORE = 1,
@@ -263,15 +291,15 @@ export const enum LOG_TYPE {
263
291
  }
264
292
 
265
293
  export const enum LOG_STATE {
266
- STDIN = 0,
267
- STDOUT = 1,
268
- STDERR = 2
294
+ STDIN,
295
+ STDOUT,
296
+ STDERR
269
297
  }
270
298
 
271
299
  export const enum READDIR_SORT {
272
- FILE = 0,
273
- DIRECTORY = 1,
274
- DESCENDING = 2
300
+ FILE,
301
+ DIRECTORY,
302
+ DESCENDING
275
303
  }
276
304
 
277
305
  export const enum SETTINGS_KEY_NAME {
@@ -281,6 +309,7 @@ export const enum SETTINGS_KEY_NAME {
281
309
  NODE_REQUIRE_EXT = "node.require.ext",
282
310
  NODE_REQUIRE_NPM = "node.require.npm",
283
311
  NODE_REQUIRE_INLINE = "node.require.inline",
312
+ NODE_PACKAGE_MANAGER = "node.settings.package_manager",
284
313
  TEMP_DIR = "temp.dir",
285
314
  TEMP_WRITE = "temp.write",
286
315
  PROCESS_PASSWORD = "process.password",
package/index.d.ts CHANGED
@@ -1,18 +1,14 @@
1
+ /// <reference lib="dom" />
1
2
  /// <reference path="./lib/type.d.ts" />
2
- /// <reference path="./lib/object.d.ts" />
3
3
 
4
4
  import type { LogArguments } from './lib/logger';
5
- import type { CloneObjectOptions } from './lib/module';
5
+ import type { HighResolutionTime } from './lib/node';
6
6
 
7
- import type { BinaryLike, CipherGCMTypes, Encoding } from 'crypto';
7
+ import type { BinaryLike, BinaryToTextEncoding, CipherGCMTypes, Encoding, RandomUUIDOptions } from 'node: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,25 @@ 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
+ freezeDepth?: number | boolean;
270
+ mergeArray?: MergeArrayMethod;
271
+ mergeDepth?: number;
272
+ typedArray?: boolean;
273
+ symbol?: boolean;
274
+ inherited?: boolean;
275
+ nonenumerable?: boolean;
276
+ preserve?: boolean;
277
+ }
278
+
279
+ type MergeArrayMethod = "concat" | "concat-pre" | "includes" | "unshift" | "push" | "flat" | "join" | "slice" | "reverse" | ["flat", number] | ["join", string] | ["slice", number, number?];
269
280
  type WatchEventValue = WATCH_EVENT[keyof WATCH_EVENT];
270
281
 
271
282
  function createAbortError(reject: true): Promise<never>;
272
- function createAbortError(): AbortError;
283
+ function createAbortError(): DOMException;
273
284
  function hasBit(value: unknown, flags: number): boolean;
274
285
  function ignoreFlag(value: unknown): boolean;
275
286
  function cloneFlag(value: unknown): boolean;
@@ -279,8 +290,8 @@ declare namespace types {
279
290
  function processFlag(value: unknown): boolean;
280
291
  function mainFlag(value: unknown): boolean;
281
292
  function existsFlag(value: unknown): boolean;
282
- function getLogCurrent(): Null<LogArguments>;
283
- function setLogCurrent(value: LogArguments): void;
293
+ function getLogCurrent(): LogArguments | null;
294
+ function setLogCurrent(value: LogArguments | null): void;
284
295
  function setTempDir(value: string): boolean;
285
296
  function getTempDir(): string;
286
297
  function isArray<T>(value: unknown): value is T[];
@@ -288,16 +299,16 @@ declare namespace types {
288
299
  function isPlainObject<T = PlainObject>(value: unknown): value is T;
289
300
  function isString(value: unknown): value is string;
290
301
  function isEmpty(value: unknown): boolean;
291
- function asFunction<U = unknown, V = unknown>(value: unknown, sync?: boolean): Null<FunctionType<U, V>>;
292
- function parseTime(value: NumString, start?: number): number;
293
- function parseExpires(value: NumString, start?: number): number;
302
+ function asFunction<U = unknown, V = unknown>(value: unknown, sync?: boolean): FunctionType<U, V> | null;
303
+ function parseTime(value: number | string, start?: number): number;
304
+ function parseExpires(value: number | string, start?: number): number;
294
305
  function formatTime(value: number, char: string): string;
295
306
  function formatTime(value: number, elapsed?: boolean, char?: string): string;
296
- function convertTime(value: NumString): number;
307
+ function convertTime(value: number | string): number;
297
308
  function convertTime(value: HighResolutionTime, format: true): string;
298
309
  function convertTime(value: HighResolutionTime, format?: boolean): number;
299
310
  function hasGlob(value: string): boolean;
300
- function escapePattern(value: unknown, lookBehind?: boolean): string;
311
+ function escapePattern(value: unknown, symbols?: boolean): string;
301
312
  function renameExt(value: string, ext: string, when?: string): string;
302
313
  function formatSize(value: string): number;
303
314
  function formatSize(value: number, options?: BytesOptions): string;
@@ -309,15 +320,19 @@ declare namespace types {
309
320
  function coerceObject<T = unknown>(data: T, cache: boolean): T;
310
321
  function coerceObject<T = unknown>(data: T, parseString?: FunctionArgs<[string]>, cache?: boolean): T;
311
322
  function getEncoding(value: unknown, fallback?: BufferEncoding): BufferEncoding;
312
- function encryptUTF8(algorithm: CipherGCMTypes, key: BinaryLike, iv: BinaryLike, data: string, encoding?: Encoding): Undef<string>;
313
- function decryptUTF8(algorithm: CipherGCMTypes, key: BinaryLike, iv: BinaryLike, data: string, encoding?: Encoding): Undef<string>;
314
- /** @deprecated crypto.randomUUID */
315
- function generateUUID(): string;
323
+ function encryptUTF8(algorithm: CipherGCMTypes, key: BinaryLike, iv: BinaryLike, data: string, encoding?: Encoding): string | undefined;
324
+ function decryptUTF8(algorithm: CipherGCMTypes, key: BinaryLike, iv: BinaryLike, data: string, encoding?: Encoding): string | undefined;
325
+ function hashKey(data: BinaryLike, algorithm?: string, encoding?: BinaryToTextEncoding): string;
326
+ /** @deprecated - crypto.randomUUID */
327
+ function generateUUID(options?: RandomUUIDOptions): string;
316
328
  function incrementUUID(restart?: boolean): string;
317
329
  function validateUUID(value: unknown): boolean;
318
330
  function randomString(format: string, dictionary?: string): string;
319
331
  function errorValue(value: string, hint?: string): Error;
320
- function errorMessage(title: NumString, value: string, hint?: string): Error;
332
+ function errorMessage(title: number | string, value: string, hint?: string): Error;
333
+ function supported(major: number, minor: number, lts: boolean): boolean;
334
+ function supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
335
+ function importESM<T = unknown>(name: string, isDefault?: boolean, fromPath?: boolean): Promise<T>;
321
336
  function purgeMemory(percent?: number): number;
322
337
  }
323
338