@e-mc/types 0.12.9 → 0.13.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @e-mc/types
2
2
 
3
- * NodeJS 18
3
+ * NodeJS 18.20.5 LTS
4
4
  * ES2022
5
5
 
6
6
  ## General Usage
@@ -9,11 +9,11 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.12.9/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.13.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
+ import type { ErrorCode, HighResolutionTime } from "./lib/node";
17
17
 
18
18
  import type { BinaryLike, CipherGCMTypes, Encoding } from "node:crypto";
19
19
  import type { BytesOptions } from "bytes";
@@ -39,10 +39,14 @@ function isObject(value: unknown): value is object;
39
39
  function isPlainObject(value: unknown): value is Record<string | number | symbol, unknown>;
40
40
  function isString(value: unknown): value is string;
41
41
  function isEmpty(value: unknown): boolean;
42
- function isFunction<T extends Function>(value: unknown, cjs?: boolean): value is T;
42
+ function isFunction(value: unknown, cjs?: boolean): value is Function;
43
+ function isErrorCode(err: unknown, ...code: unknown[]): err is Required<ErrorCode>;
43
44
  function asFunction(value: unknown, sync?: boolean): ((...args: unknown[]) => unknown) | null;
45
+ function parseTime(value: number | string, epoch: true): number;
46
+ function parseTime(value: number | string, negative: false): number;
44
47
  function parseTime(value: number | string, start?: number): number;
45
- function parseExpires(value: number | string, start?: number): number;
48
+ function parseExpires(value: number | string, epoch: true): number;
49
+ function parseExpires(value: number | string, start?: number | boolean): number;
46
50
  function formatTime(value: number, char: string): string;
47
51
  function formatTime(value: number, elapsed?: boolean, char?: string): string;
48
52
  function convertTime(value: number | string): number;
@@ -203,10 +207,10 @@ const IMPORT_MAP: Record<string, string | undefined>;
203
207
 
204
208
  ## References
205
209
 
206
- - https://www.unpkg.com/@e-mc/types@0.12.9/index.d.ts
207
- - https://www.unpkg.com/@e-mc/types@0.12.9/lib/logger.d.ts
208
- - https://www.unpkg.com/@e-mc/types@0.12.9/lib/module.d.ts
209
- - https://www.unpkg.com/@e-mc/types@0.12.9/lib/node.d.ts
210
+ - https://www.unpkg.com/@e-mc/types@0.13.1/index.d.ts
211
+ - https://www.unpkg.com/@e-mc/types@0.13.1/lib/logger.d.ts
212
+ - https://www.unpkg.com/@e-mc/types@0.13.1/lib/module.d.ts
213
+ - https://www.unpkg.com/@e-mc/types@0.13.1/lib/node.d.ts
210
214
 
211
215
  * https://developer.mozilla.org/en-US/docs/Web/API/DOMException
212
216
  * https://www.npmjs.com/package/@types/bytes
package/constant.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export const enum INTERNAL {
2
- VERSION = '0.12.9',
2
+ VERSION = '0.13.1',
3
3
  TEMP_DIR = 'tmp',
4
4
  CJS = '__cjs__'
5
5
  }
@@ -20,6 +20,7 @@ export const enum VAL_DB {
20
20
  export const enum VAL_CLOUD {
21
21
  UPLOAD_FILE = 'Upload success',
22
22
  DOWNLOAD_FILE = 'Download success',
23
+ COPY_FILE = 'Copy success',
23
24
  DELETE_FILE = 'Delete success',
24
25
  RENAME_FILE = 'File renamed',
25
26
  CREATE_TAG = 'Tags created',
@@ -163,6 +164,7 @@ export const enum ERR_CLOUD {
163
164
  BUCKET_POLICY_SUPPORT = 'Bucket policy not supported',
164
165
  BUCKET_TAGGING_SUPPORT = 'Bucket tagging not supported',
165
166
  DELETE_OBJECTS_SUPPORT = 'Delete objects not supported',
167
+ COPY_OBJECT_SUPPORT = 'Copy object not supported',
166
168
  BUCKET_WEBSITE_SUPPORT = 'Set bucket website not supported',
167
169
  EXECUTE_QUERY_SUPPORT = 'Execute query not supported',
168
170
  UPLOAD_SUPPORT = 'Upload function not supported',
@@ -170,6 +172,7 @@ export const enum ERR_CLOUD {
170
172
  UPLOAD_FAIL = 'Upload failed',
171
173
  DOWNLOAD_FAIL = 'Download failed',
172
174
  DELETE_FAIL = 'Delete failed',
175
+ COPY_FAIL = 'Copy failed',
173
176
  METADATA_FAIL = 'Metadata failed'
174
177
  }
175
178
 
package/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  /// <reference path="./lib/type.d.ts" />
3
3
 
4
4
  import type { LogArguments } from './lib/logger';
5
- import type { HighResolutionTime } from './lib/node';
5
+ import type { ErrorCode, HighResolutionTime } from './lib/node';
6
6
 
7
7
  import type { BinaryLike, BinaryToTextEncoding, CipherGCMTypes, Encoding } from 'node:crypto';
8
8
 
@@ -308,9 +308,13 @@ declare namespace types {
308
308
  function isString<T extends string>(value: unknown): value is T;
309
309
  function isEmpty(value: unknown): boolean;
310
310
  function isFunction<T extends Function>(value: unknown, cjs?: boolean): value is T;
311
+ function isErrorCode<T extends unknown[]>(err: unknown, ...code: T): err is Required<ErrorCode<T[number]>>;
311
312
  function asFunction<U = unknown, V = unknown>(value: unknown, sync?: boolean): FunctionType<U, V> | null;
313
+ function parseTime(value: number | string, epoch: true): number;
314
+ function parseTime(value: number | string, negative: false): number;
312
315
  function parseTime(value: number | string, start?: number): number;
313
- function parseExpires(value: number | string, start?: number): number;
316
+ function parseExpires(value: number | string, epoch: true): number;
317
+ function parseExpires(value: number | string, start?: number | boolean): number;
314
318
  function formatTime(value: number, char: string): string;
315
319
  function formatTime(value: number, elapsed?: boolean, char?: string): string;
316
320
  function convertTime(value: number | string): number;
package/index.js CHANGED
@@ -20,6 +20,7 @@ exports.isObject = isObject;
20
20
  exports.isString = isString;
21
21
  exports.isEmpty = isEmpty;
22
22
  exports.isFunction = isFunction;
23
+ exports.isErrorCode = isErrorCode;
23
24
  exports.parseTime = parseTime;
24
25
  exports.parseExpires = parseExpires;
25
26
  exports.formatTime = formatTime;
@@ -537,9 +538,9 @@ exports.IMPORT_MAP = {
537
538
  "sass": "@pi-r/sass",
538
539
  "stylelint": "@pi-r/stylelint",
539
540
  "terser": "@pi-r/terser",
541
+ "imagemin": "@pi-r/imagemin",
540
542
  "ibm": "@pi-r2/ibm",
541
543
  "minio": "@pi-r2/minio",
542
- "imagemin": "@pi-r2/imagemin",
543
544
  "clean-css": "@pi-r2/clean-css",
544
545
  "csso": "@pi-r2/csso",
545
546
  "html-minifier": "@pi-r2/html-minifier",
@@ -622,16 +623,25 @@ function isEmpty(value) {
622
623
  function isFunction(value, cjs = false) {
623
624
  return typeof value === 'function' && (!cjs || Object.hasOwn(value, "__cjs__"));
624
625
  }
626
+ function isErrorCode(err, ...code) {
627
+ return err instanceof Error && code.some(value => value === err.code);
628
+ }
625
629
  function parseTime(value, start = 0) {
630
+ if (start === true) {
631
+ start = Date.now();
632
+ }
626
633
  const seconds = +value;
627
634
  if (isNaN(seconds) && isString(value)) {
628
635
  let result = 0;
629
- for (const match of value.matchAll(/\b([\d.]+)\s*(y|w|d|h|ms?|s)\b/gi)) {
630
- const n = +match[1];
636
+ for (const match of value.matchAll(/([+-]|\b)([\d.]+)\s*(y|w|d|h|ms?|s)\b/gi)) {
637
+ let n = +match[2];
631
638
  if (isNaN(n)) {
632
639
  continue;
633
640
  }
634
- switch (match[2].toLowerCase()) {
641
+ if (match[1] === '-' && start === false) {
642
+ n *= -1;
643
+ }
644
+ switch (match[3].toLowerCase()) {
635
645
  case 'y':
636
646
  result += n * 31449600000;
637
647
  break;
@@ -651,15 +661,18 @@ function parseTime(value, start = 0) {
651
661
  result += Math.ceil(n);
652
662
  break;
653
663
  default:
654
- result += n * (match[2] === 'M' ? 2592000000 : 60000);
664
+ result += n * (match[3] === 'M' ? 2592000000 : 60000);
655
665
  break;
656
666
  }
657
667
  }
668
+ if (start === false) {
669
+ return result;
670
+ }
658
671
  if (result > 0) {
659
672
  return Math.ceil(result) + start;
660
673
  }
661
674
  }
662
- else if (seconds > 0) {
675
+ else if (seconds > 0 && typeof start === 'number') {
663
676
  return Math.ceil(seconds * 1000) + start;
664
677
  }
665
678
  return 0;
@@ -668,14 +681,24 @@ function parseExpires(value, start = 0) {
668
681
  if (+value < 0 || value === 'never') {
669
682
  return Infinity;
670
683
  }
684
+ if (start === false) {
685
+ start = 0;
686
+ }
671
687
  return parseTime(value, start);
672
688
  }
673
689
  function formatTime(value, elapsed, char = ' ') {
690
+ let sign = '';
674
691
  if (elapsed === true) {
675
692
  value = Date.now() - value;
676
693
  }
677
- else if (isString(elapsed)) {
678
- char = elapsed;
694
+ else {
695
+ if (value < 0) {
696
+ sign = '-';
697
+ value = Math.abs(value);
698
+ }
699
+ if (isString(elapsed)) {
700
+ char = elapsed;
701
+ }
679
702
  }
680
703
  if (char === ':') {
681
704
  let result = '';
@@ -699,7 +722,7 @@ function formatTime(value, elapsed, char = ' ') {
699
722
  else {
700
723
  result += '00';
701
724
  }
702
- return result;
725
+ return sign + result;
703
726
  }
704
727
  const result = [];
705
728
  if (value < 1000) {
@@ -718,7 +741,7 @@ function formatTime(value, elapsed, char = ' ') {
718
741
  if (value > 0) {
719
742
  result.push(value < 100 ? value + 'ms' : (value / 1000).toPrecision(value <= 9950 ? 2 : 3).replace(/\.?0+$/, '') + 's');
720
743
  }
721
- return result.join(char);
744
+ return (sign ? result.map(item => sign + item) : result).join(char);
722
745
  }
723
746
  function convertTime(value, format) {
724
747
  let result = 0;
package/lib/cloud.d.ts CHANGED
@@ -54,7 +54,7 @@ export interface CloudStorageAction<T = unknown, U = string, V = unknown, W = un
54
54
  admin?: CloudStorageAdmin<T, U, V, W, X, Y>;
55
55
  }
56
56
 
57
- export interface CloudStorageUpload<T = unknown, U = string, V = unknown, W = string, X = unknown, Y = unknown, Z = unknown> extends CloudStorageACL<U>, CloudStorageAction<V, W, unknown, X, Y, Z> {
57
+ export interface CloudStorageUpload<T = unknown, U = string, V = unknown, W = string, X = unknown, Y = unknown, Z = unknown, A = unknown> extends CloudStorageACL<U>, CloudStorageAction<V, W, unknown, X, Y, Z>, CopyObjectAction<A> {
58
58
  buffer?: Buffer | null;
59
59
  contentType?: string;
60
60
  metadata?: Record<string, string>;
@@ -71,7 +71,7 @@ export interface CloudStorageACL<T = string> {
71
71
  acl?: T;
72
72
  }
73
73
 
74
- export interface CloudStorageDownload<T = unknown, U = unknown> extends CloudStorageAction {
74
+ export interface CloudStorageDownload<T = unknown, U = unknown, V = unknown> extends CloudStorageAction, CopyObjectAction<V> {
75
75
  keyname?: string;
76
76
  versionId?: string;
77
77
  options?: U;
@@ -88,20 +88,26 @@ export interface BucketWebsiteOptions {
88
88
 
89
89
  export interface DeleteObjectsOptions extends RecursiveAction, PlainObject {}
90
90
 
91
- export interface UploadData<T = unknown, U = string, V = unknown, W = string, X = unknown, Y = unknown, Z = unknown> extends BucketAction {
92
- upload: CloudStorageUpload<T, U, V, W, X, Y, Z>;
91
+ export interface CopyObjectOptions extends PlainObject {}
92
+
93
+ export interface UploadData<T = unknown, U = string, V = unknown, W = string, X = unknown, Y = unknown, Z = unknown, A = unknown> extends BucketAction {
94
+ upload: CloudStorageUpload<T, U, V, W, X, Y, Z, A>;
93
95
  localUri: string;
94
96
  buffer: Buffer;
95
97
  }
96
98
 
97
- export interface DownloadData<T = unknown, U = unknown> extends BucketAction {
98
- download: CloudStorageDownload<T, U>;
99
+ export interface DownloadData<T = unknown, U = unknown, V = unknown> extends BucketAction {
100
+ download: CloudStorageDownload<T, U, V>;
99
101
  }
100
102
 
101
103
  export interface BucketAction {
102
104
  bucket: string;
103
105
  }
104
106
 
107
+ export interface CopyObjectAction<T = PlainObject> {
108
+ copyObject?: ArrayOf<BucketAction & Partial<LocationUri> & { options?: T }>;
109
+ }
110
+
105
111
  export interface UploadAssetOptions {
106
112
  contentType?: string;
107
113
  ignoreProcess?: boolean;
@@ -111,4 +117,5 @@ export interface UploadAssetOptions {
111
117
  export type UploadContent = [Bufferable, string, string?];
112
118
  export type CloudSource = "atlas" | "aws" | "aws-v3" | "az" | "azure" | "gcp" | "gcloud" | "oci";
113
119
  export type CloudFeatures = "storage" | "database";
114
- export type CloudFunctions = "upload" | "download";
120
+ export type CloudFunctions = "upload" | "download";
121
+ export type CloudLogMessageType = "SUCCESS" | "FAIL" | "COMMAND" | "WARN" | "UPLOAD" | "DOWNLOAD" | "DELETE" | "DELAYED";
package/lib/compress.d.ts CHANGED
@@ -3,6 +3,8 @@ import type { CompressFormat as ICompressFormat, CompressLevel as ICompressLevel
3
3
  import type { LogBaseOptions, LogTime } from './logger';
4
4
  import type { ThrowsAction } from './module';
5
5
 
6
+ import type { BrotliOptions, ZlibOptions } from 'node:zlib';
7
+
6
8
  type ResultCallback<T = Buffer | Uint8Array | null> = (err: unknown, data?: T, ext?: string) => void;
7
9
  type ResultData = Buffer | Uint8Array | string | null;
8
10
 
@@ -14,14 +16,14 @@ export interface CompressFormat extends ICompressFormat, LogBaseOptions, Readabl
14
16
  outFile?: string;
15
17
  }
16
18
 
17
- export interface CompressLevel extends ICompressLevel, ReadableOptions {}
19
+ export interface CompressLevel extends ICompressLevel, ReadableOptions, ZlibOptions {}
18
20
 
19
- export interface BrotliCompressLevel extends CompressLevel, MimeTypeAction {}
21
+ export interface BrotliCompressLevel extends CompressLevel, BrotliOptions, MimeTypeAction {}
20
22
 
21
23
  export interface ReadableOptions extends ThrowsAction {}
22
24
 
23
25
  export type BufferLike = Buffer | Uint8Array | ArrayBuffer | SharedArrayBuffer | readonly number[];
24
- export type TryFileCompressor = (data: string | Buffer, output: string, config: CompressFormat, callback?: ResultCallback<ResultData>) => Promise<ResultData | void>;
25
- export type TryFileCompressorAsync = (data: string | Buffer, output: string, config: CompressFormat) => Promise<ResultData>;
26
+ export type TryFileCompressor = (data: Bufferable, output: string, config: CompressFormat, callback?: ResultCallback<ResultData>) => Promise<ResultData | void>;
27
+ export type TryFileCompressorAsync = (data: Bufferable, output: string, config: CompressFormat) => Promise<ResultData>;
26
28
  export type BufferResult = Buffer | Uint8Array | null;
27
29
  export type PluginCompressor = FunctionArgs<[CompressFormat["options"], CompressFormat["metadata"]?], FunctionArgs<[Buffer], Promise<Buffer | Uint8Array>>>;
package/lib/document.d.ts CHANGED
@@ -88,8 +88,11 @@ export interface ITransformSeries<T = AnyObject, U = T, V = object> extends IMod
88
88
  getMainFile(code?: string, imports?: StringMap): SourceInput<string> | undefined;
89
89
  getSourceFiles(imports?: StringMap): SourceInput | undefined;
90
90
  toBaseConfig(all?: boolean): T;
91
- upgrade<W = unknown>(context: W, dirname?: string, pkgname?: string): W;
92
- upgradeESM<W = unknown>(context: W, dirname?: string, pkgname?: string): Promise<W>;
91
+ upgrade<W = unknown>(context: W, options: FindModuleOptions): W;
92
+ upgrade<W = unknown>(context: W, startDir?: string, packageName?: string, version?: string): W;
93
+ upgradeESM<W = unknown>(context: W, options: FindModuleOptions): Promise<W>;
94
+ upgradeESM<W = unknown>(context: W, startDir?: string, packageName?: string, version?: string): Promise<W>;
95
+ findModule(startDir: string, packageName?: string, version?: string): string;
93
96
  set code(value);
94
97
  get code(): string;
95
98
  get out(): IOut;
@@ -151,6 +154,12 @@ export interface SourceMapConstructor {
151
154
  new(code: string, uri?: string, remove?: boolean): SourceMap;
152
155
  }
153
156
 
157
+ export interface FindModuleOptions {
158
+ startDir?: string;
159
+ packageName?: string;
160
+ version?: string;
161
+ }
162
+
154
163
  export interface ImportMap {
155
164
  imports?: StringMap;
156
165
  scopes?: ObjectMap<StringMap>;
@@ -196,4 +205,4 @@ export interface AsSourceFileOptions extends EncodingAction {
196
205
  export type Transformer = FunctionType<Promise<string> | string>;
197
206
  export type ConfigOrTransformer = AnyObject | Transformer;
198
207
  export type PluginConfig<T = ConfigOrTransformer> = [string, T | undefined, AnyObject | undefined, boolean?] | [];
199
- export type TransformCallback<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset> = (this: T, instance: IDocument<T, U>, requireOrDocumentDir?: NodeJS.Require | string) => Promise<void >;
208
+ export type TransformCallback<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset> = (this: T, instance: IDocument<T, U>, requireOrDocumentDir?: NodeJS.Require | string) => Promise<void>;
@@ -41,7 +41,7 @@ export interface IHttpDiskCache<T extends ExternalAsset = ExternalAsset> {
41
41
  expires: number;
42
42
  readonly host: IFileManager<T>;
43
43
  has(uri: string | URL): boolean;
44
- add<U extends HttpDiskCacheAddOptions>(uri: string | URL, etag: string, target: string | Buffer, options?: U): void;
44
+ add<U extends HttpDiskCacheAddOptions>(uri: string | URL, etag: string, target: Bufferable, options?: U): void;
45
45
  within(value: T | number): boolean;
46
46
  clear(value?: unknown): void;
47
47
  set enabled(value);
@@ -113,11 +113,18 @@ export interface ChecksumOptions extends ReadHashOptions, Pick<ChecksumOutput, "
113
113
  sortBy?: number;
114
114
  verbose?: boolean;
115
115
  ignore?: string[];
116
+ ignoreRoot?: string[];
116
117
  joinRoot?: boolean;
117
118
  outPath?: string;
118
119
  throwsEmpty?: boolean;
119
120
  }
120
121
 
122
+ export interface CheckHashOptions {
123
+ data?: Bufferable | null;
124
+ uri?: string | URL;
125
+ output?: boolean;
126
+ }
127
+
121
128
  export type ImageMimeMap = Map<string, InstallData<IImage, ImageConstructor>>;
122
129
  export type FetchType = FETCH_TYPE[keyof FETCH_TYPE];
123
130
  export type PostFinalizeCallback = (files: FileInfo[] | string[], errors: string[], status?: LogStatus[]) => void;
package/lib/index.d.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  /// <reference path="type.d.ts" />
2
2
 
3
- import type { DataSource, DbDataSource, IncrementalMatch, LogStatus, TaskAction, ViewEngine } from './squared';
3
+ import type { ChecksumValue, DataSource, DbDataSource, IncrementalMatch, LogStatus, TaskAction, ViewEngine } from './squared';
4
4
 
5
5
  import type { ExternalAsset, FileCommand, FileData, IFileThread, OutputFinalize } from './asset';
6
- import type { BucketWebsiteOptions, CloudDatabase, CloudFeatures, CloudFunctions, CloudService, CloudStorage, CloudStorageDownload, CloudStorageUpload, DeleteObjectsOptions, UploadAssetOptions } from './cloud';
6
+ import type { BucketWebsiteOptions, CloudDatabase, CloudFeatures, CloudFunctions, CloudLogMessageType, CloudService, CloudStorage, CloudStorageDownload, CloudStorageUpload, CopyObjectOptions, DeleteObjectsOptions, UploadAssetOptions } from './cloud';
7
7
  import type { BrotliCompressLevel, BufferResult, CompressFormat, CompressLevel, ReadableOptions, TryFileCompressor } from './compress';
8
8
  import type { ClientDbConstructor, HostInitConfig, IAbortComponent, IClient, IClientDb, IPermission, JoinQueueOptions, PermissionReadWrite, ResumeThreadOptions, ThreadCountStat } from './core';
9
9
  import type { BatchQueryResult, DB_TYPE, ErrorQueryCallback, ExecuteBatchQueryOptions, ExecuteQueryOptions, HandleFailOptions, ProcessRowsOptions, QueryResult, SQL_COMMAND } from './db';
10
10
  import type { AsSourceFileOptions, ConfigOrTransformer, CustomizeOptions as CustomizeDocument, GenerateLintTableOptions, LintMessage, PluginConfig, SourceCode, SourceInput, SourceMap, SourceMapOptions, TransformAction, TransformCallback, TransformOutput, TransformResult, UpdateGradleOptions } from './document';
11
- import type { AssetContentOptions, ChecksumOptions, DeleteFileAddendum, FileOutput, FinalizeResult, FindAssetOptions, IHttpDiskCache, IHttpMemoryCache, ImageMimeMap, InstallData, PostFinalizeCallback, ReplaceOptions } from './filemanager';
11
+ import type { AssetContentOptions, CheckHashOptions, ChecksumOptions, DeleteFileAddendum, FileOutput, FinalizeResult, FindAssetOptions, IHttpDiskCache, IHttpMemoryCache, ImageMimeMap, InstallData, PostFinalizeCallback, ReplaceOptions } from './filemanager';
12
12
  import type { HttpAgentSettings, HttpProtocolVersion, HttpRequestClient, InternetProtocolVersion } from './http';
13
13
  import type { CommandData, CropData, QualityData, ResizeData, RotateData, TransformOptions } from './image';
14
14
  import type { ExecCommand, LOG_TYPE, LogArguments, LogComponent, LogDate, LogFailOptions, LogMessageOptions, LogOptions, LogProcessOptions, LogState, LogTime, LogType, LogValue, STATUS_TYPE, StatusType } from './logger';
15
- import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, FileTypeFormat, GlobDirOptions, MoveFileOptions, PackageVersionOptions, ParseFunctionOptions, PermissionOptions, PermissionType, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, TempDirOptions, WriteFileOptions } from './module';
16
- import type { HighResolutionTime, RequestData, Settings } from './node';
15
+ import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, DirectoryActionType, FileActionType, FileTypeFormat, GlobDirOptions, MoveFileOptions, PackageVersionOptions, ParseFunctionOptions, PermissionOptions, PermissionType, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, TempDirOptions, WriteFileOptions } from './module';
16
+ import type { ErrorCode, HighResolutionTime, RequestData, Settings } from './node';
17
17
  import type { ApplyOptions, Aria2Options, BufferFormat, DataEncodedResult, DataObjectResult, FormDataPart, HeadersOnCallback, HostConfig, IHttpAdapter, OpenOptions, PostOptions, ProxySettings, PutOptions, RcloneOptions, ReadExpectType, RequestInit, StatusOnCallback } from './request';
18
18
  import type { ClientModule, CloudAuthSettings, CloudModule, CloudServiceOptions, CompressModule, CompressSettings, DbCoerceSettings, DbModule, DbSourceOptions, DnsLookupSettings, DocumentComponent, DocumentComponentOption, DocumentModule, HandlerSettings, HttpConnectSettings, HttpMemorySettings, ImageModule, LoggerFormat, LoggerFormatSettings, PoolConfig, RequestModule, RequestSettings, TaskModule, WatchModule } from './settings';
19
19
  import type { Command, SpawnResult } from './task';
@@ -69,18 +69,18 @@ declare namespace functions {
69
69
  register(format: string, callback: TryFileCompressor): void;
70
70
  getLevel(value: string, fallback?: number): number | undefined;
71
71
  getReadable(file: string | URL | Buffer, options?: ReadableOptions): Readable;
72
- createGzip(file: string | Buffer, options?: CompressLevel): Gzip;
73
- createBrotliCompress(file: string | Buffer, options?: BrotliCompressLevel): BrotliCompress;
74
- createWriteStreamAsGzip(file: string | Buffer, output: string, options?: CompressLevel): WriteStream;
75
- createWriteStreamAsBrotli(file: string | Buffer, output: string, options?: BrotliCompressLevel): WriteStream;
72
+ createGzip(file: Bufferable, options?: CompressLevel): Gzip;
73
+ createBrotliCompress(file: Bufferable, options?: BrotliCompressLevel): BrotliCompress;
74
+ createWriteStreamAsGzip(file: Bufferable, output: string, options?: CompressLevel): WriteStream;
75
+ createWriteStreamAsBrotli(file: Bufferable, output: string, options?: BrotliCompressLevel): WriteStream;
76
76
  intoGzipStream(output: string, options?: ZlibOptions): WriteStream;
77
77
  intoBrotliStream(output: string, options?: BrotliOptions): WriteStream;
78
- writeGzip(file: string | Buffer, output: string, options?: CompressLevel): Promise<void>;
79
- writeBrotli(file: string | Buffer, output: string, options?: CompressLevel): Promise<void>;
80
- tryFile(file: string | Buffer, options: CompressFormat): Promise<BufferResult>;
81
- tryFile(file: string | Buffer, output: string, options?: CompressFormat): Promise<BufferResult>;
78
+ writeGzip(file: Bufferable, output: string, options?: CompressLevel): Promise<void>;
79
+ writeBrotli(file: Bufferable, output: string, options?: CompressLevel): Promise<void>;
80
+ tryFile(file: Bufferable, options: CompressFormat): Promise<BufferResult>;
81
+ tryFile(file: Bufferable, output: string, options?: CompressFormat): Promise<BufferResult>;
82
82
  tryImage(file: string, options: CompressFormat): Promise<BufferResult>;
83
- tryImage(file: string | Buffer, output: string, options?: CompressFormat): Promise<BufferResult>;
83
+ tryImage(file: Bufferable, output: string, options?: CompressFormat): Promise<BufferResult>;
84
84
  hasPermission(type: string, options?: unknown): boolean;
85
85
  set chunkSize(value: number | string | undefined);
86
86
  get chunkSize(): number | undefined;
@@ -175,6 +175,49 @@ declare namespace functions {
175
175
  get commandType(): SQL_COMMAND;
176
176
  set host(value);
177
177
  get host(): T | null;
178
+
179
+ /* EventEmitter */
180
+ on(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
181
+ on(event: "error", listener: (err: Error) => void): this;
182
+ on(event: "file:read", listener: (src: string, data: Bufferable, options?: ReadFileOptions) => void): this;
183
+ on(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
184
+ on(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
185
+ on(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
186
+ on(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
187
+ on(event: "file:permission", listener: (src: string, type?: FileActionType) => void): this;
188
+ on(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
189
+ on(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
190
+ on(event: "dir:permission", listener: (src: string, type?: DirectoryActionType) => void): this;
191
+ once(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
192
+ once(event: "error", listener: (err: Error) => void): this;
193
+ once(event: "file:read", listener: (src: string, data: Bufferable, options?: ReadFileOptions) => void): this;
194
+ once(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
195
+ once(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
196
+ once(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
197
+ once(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
198
+ once(event: "file:permission", listener: (src: string, type?: FileActionType) => void): this;
199
+ once(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
200
+ once(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
201
+ once(event: "dir:permission", listener: (src: string, type?: DirectoryActionType) => void): this;
202
+ emit(event: "exec", command: ExecCommand, options?: SpawnOptions): boolean;
203
+ emit(event: "error", err: Error): boolean;
204
+ emit(event: "file:read", src: string, data: Bufferable, options?: ReadFileOptions): boolean;
205
+ emit(event: "file:write", src: string, options?: WriteFileOptions): boolean;
206
+ emit(event: "file:delete", src: string, options?: DeleteFileOptions): boolean;
207
+ emit(event: "file:copy", dest: string, options?: CopyFileOptions): boolean;
208
+ emit(event: "file:move", dest: string, options?: MoveFileOptions): boolean;
209
+ emit(event: "file:permission", src: string, type?: FileActionType): boolean;
210
+ emit(event: "dir:create", src: string, options?: CreateDirOptions): boolean;
211
+ emit(event: "dir:remove", src: string, options?: RemoveDirOptions): boolean;
212
+ emit(event: "dir:permission", src: string, type?: DirectoryActionType): boolean;
213
+
214
+ /* EventEmitter */
215
+ on(event: "db:result", listener: (batch: V[], result: BatchQueryResult) => void): this;
216
+ on(event: "db:fail", listener: (err: unknown, item: V) => void): this;
217
+ once(event: "db:result", listener: (batch: V[], result: BatchQueryResult) => void): this;
218
+ once(event: "db:fail", listener: (err: unknown, item: V) => void): this;
219
+ emit(event: "db:result", batch: V[], result: BatchQueryResult): boolean;
220
+ emit(event: "db:fail", err: unknown, item: V): boolean;
178
221
  }
179
222
 
180
223
  interface DbConstructor<T extends IHost = IHost, U extends DbModule = DbModule, V extends DbDataSource = DbDataSource> extends ClientDbConstructor<T> {
@@ -194,8 +237,9 @@ declare namespace functions {
194
237
  setBucketWebsite(service: string, credential: unknown, bucket: string, options: BucketWebsiteOptions): Promise<boolean>;
195
238
  deleteObjects(service: string, credential: unknown, bucket: string, options: DeleteObjectsOptions): Promise<void>;
196
239
  deleteObjects(service: string, credential: unknown, bucket: string, recursive?: boolean | DeleteObjectsOptions): Promise<void>;
197
- uploadObject(service: string, credential: unknown, bucket: string, upload: CloudStorageUpload, localUri: string, beforeResolve?: ((value: string) => Promise<void> | void)): Promise<string>;
198
- downloadObject(service: string, credential: unknown, bucket: string, download: CloudStorageDownload, beforeResolve?: ((value: Bufferable | null) => Promise<string | undefined> | void)): Promise<Bufferable>;
240
+ copyObject(service: string, credential: unknown, bucketSource: string, keySource: string, bucket: string, key: string, options?: CopyObjectOptions): Promise<void>;
241
+ uploadObject(service: string, credential: unknown, bucket: string, upload: CloudStorageUpload, localUri: string, beforeResolve?: (value: string) => Promise<void> | void): Promise<string>;
242
+ downloadObject(service: string, credential: unknown, bucket: string, download: CloudStorageDownload, beforeResolve?: (value: Bufferable | null) => Promise<string | undefined> | void): Promise<Bufferable>;
199
243
  getStorage(action: CloudFunctions, data: CloudStorage[] | undefined): CloudStorage | undefined;
200
244
  hasStorage(action: CloudFunctions, storage: CloudStorage): CloudStorageUpload | false;
201
245
  getDatabaseRows(item: V, ignoreErrors: boolean, sessionKey?: string): Promise<QueryResult>;
@@ -216,6 +260,7 @@ declare namespace functions {
216
260
  }
217
261
 
218
262
  interface CloudConstructor<T extends IHost = IHost, U extends CloudModule = CloudModule, V extends CloudDatabase = CloudDatabase> extends ClientDbConstructor<T> {
263
+ LOG_CLOUD_SUCCESS: LogMessageOptions;
219
264
  LOG_CLOUD_FAIL: LogMessageOptions;
220
265
  LOG_CLOUD_COMMAND: LogMessageOptions;
221
266
  LOG_CLOUD_WARN: LogMessageOptions;
@@ -227,7 +272,9 @@ declare namespace functions {
227
272
  uploadAsset<W extends IFileManager<X>, X extends ExternalAsset>(state: IScopeOrigin<W, ICloud<W>>, file: X, options: UploadAssetOptions): Promise<void>[];
228
273
  uploadAsset<W extends IFileManager<X>, X extends ExternalAsset>(state: IScopeOrigin<W, ICloud<W>>, file: X, ignoreProcess: boolean): Promise<void>[];
229
274
  uploadAsset<W extends IFileManager<X>, X extends ExternalAsset>(state: IScopeOrigin<W, ICloud<W>>, file: X, contentType?: string | boolean | UploadAssetOptions, ignoreProcess?: boolean): Promise<void>[];
275
+ uploadAssetSuccess<W extends IFileManager<X>, X extends ExternalAsset>(state: IScopeOrigin<W, ICloud<W>>, file: X, active?: boolean): (value: string) => Promise<void> | void;
230
276
  sanitizeAssets<W extends ExternalAsset>(assets: W[]): W[];
277
+ optionsLogMessage<W extends LogMessageOptions & LogFailOptions>(type: CloudLogMessageType, options?: W): W;
231
278
  readonly prototype: ICloud<T, U, V>;
232
279
  new(module?: U, database?: CloudDatabase[], ...args: unknown[]): ICloud<T, U, V>;
233
280
  }
@@ -239,7 +286,7 @@ declare namespace functions {
239
286
  init(assets: U[], config?: HostInitConfig): this;
240
287
  customize(options?: CustomizeDocument): void;
241
288
  findConfig(data: object, name: string, type?: string): PluginConfig;
242
- loadConfig(data: object, name: string): Optional<ConfigOrTransformer>;
289
+ loadConfig(data: object, name: string): ConfigOrTransformer | undefined;
243
290
  asSourceFile(value: string, cache: boolean): unknown;
244
291
  asSourceFile(value: string, options?: AsSourceFileOptions): unknown;
245
292
  findVersion(name: string | string[], fallback?: string): string;
@@ -267,7 +314,7 @@ declare namespace functions {
267
314
  writeImage?(output: OutputFinalize<U>): boolean;
268
315
  cloudInit?(state: IScopeOrigin<T, Y>): void;
269
316
  cloudObject?(state: IScopeOrigin<T, Y>, file: U): boolean;
270
- cloudUpload?(state: IScopeOrigin<T, Y>, file: U, url: string, active: boolean): Promise<boolean>;
317
+ cloudUpload?(state: IScopeOrigin<T, Y>, file: U, url: string, active?: boolean): Promise<boolean>;
271
318
  cloudFinalize?(state: IScopeOrigin<T, Y>): Promise<unknown[]>;
272
319
  watchInit?(watch: IFileGroup<U>, assets: U[], sanitize?: boolean): WatchInitResult | undefined;
273
320
  watchModified?(watch: IFileGroup<U>, assets?: U[], recursive?: [string, string[]][]): PostFinalizeCallback;
@@ -366,6 +413,8 @@ declare namespace functions {
366
413
  post<V extends { format: undefined; encoding: undefined }>(uri: string | URL, form: AnyObject, parts: FormDataPart[]): Promise<DataObjectResult<V>>;
367
414
  post<V extends PostOptions>(uri: string | URL, data: unknown, options: V): Promise<DataObjectResult<V>>;
368
415
  post<V extends PostOptions>(uri: string | URL, data: unknown, contentType?: string | FormDataPart[] | V, options?: V): Promise<DataObjectResult<V>>;
416
+ get<V extends OpenOptions & { encoding: BufferEncoding }>(uri: string | URL, options: V): Promise<string>;
417
+ get<V extends BufferFormat>(uri: string | URL, format: V): Promise<object | null>;
369
418
  get<V extends OpenOptions, W extends V | BufferFormat>(uri: string | URL, options?: W): Promise<W extends BufferFormat ? object | null : DataEncodedResult<V>>;
370
419
  detach(singleton?: boolean): void;
371
420
  reset(adapter?: IHttpAdapter): void;
@@ -384,10 +433,6 @@ declare namespace functions {
384
433
  readTLSKey(value: string, cache?: boolean): string;
385
434
  readTLSCert(value: string, cache?: boolean): string;
386
435
  isCert(value: string): boolean;
387
- /** @deprecated */
388
- fromURL(url: URL, value: string): string;
389
- /** @deprecated */
390
- fromStatusCode(value: number | string): string;
391
436
  defineHttpAgent(options: HttpAgentSettings): void;
392
437
  defineDnsLookup(options: DnsLookupSettings, clear?: boolean): void;
393
438
  isRclone(value: string | URL): boolean;
@@ -466,8 +511,12 @@ declare namespace functions {
466
511
  addDownload(value: number | Bufferable, encoding: BufferEncoding): number;
467
512
  addDownload(value: number | Bufferable, type?: number | BufferEncoding, encoding?: BufferEncoding): number;
468
513
  getDownload(type?: number): [number, number];
514
+ checkHash(checksum: ChecksumValue, options: CheckHashOptions): boolean;
515
+ checkHash(checksum: ChecksumValue, data: Bufferable | null, uri: string | URL | undefined): boolean;
516
+ checkHash(checksum: ChecksumValue, data: Bufferable, options?: CheckHashOptions): boolean;
469
517
  transformAsset(data: IFileThread<T>, parent?: T, override?: boolean): Promise<boolean>;
470
518
  addCopy(data: FileCommand<T>, saveAs?: string, replace?: boolean): string | undefined;
519
+ handleFilePermission(file: T): void;
471
520
  findMime(file: T, rename?: boolean): Promise<string>;
472
521
  getUTF8String(file: T, uri?: string): string;
473
522
  getBuffer<U>(file: T, minStreamSize?: U): U extends number ? Promise<Buffer | null> : Buffer | null;
@@ -498,6 +547,7 @@ declare namespace functions {
498
547
  finalizeChecksum(): Promise<void>;
499
548
  finalizeCleanup(): Promise<void>;
500
549
  finalize(): Promise<void>;
550
+ removeFiles(): void;
501
551
  close(): void;
502
552
  reset(): boolean;
503
553
  get baseDirectory(): string;
@@ -519,7 +569,6 @@ declare namespace functions {
519
569
  has(value: unknown): value is string;
520
570
 
521
571
  /* EventEmitter */
522
- on(event: "end", listener: PostFinalizeCallback): this;
523
572
  on(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
524
573
  on(event: "error", listener: (err: Error) => void): this;
525
574
  on(event: "file:read", listener: (src: string, data: Bufferable, options?: ReadFileOptions) => void): this;
@@ -527,9 +576,10 @@ declare namespace functions {
527
576
  on(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
528
577
  on(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
529
578
  on(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
579
+ on(event: "file:permission", listener: (src: string, type?: FileActionType) => void): this;
530
580
  on(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
531
581
  on(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
532
- once(event: "end", listener: PostFinalizeCallback): this;
582
+ on(event: "dir:permission", listener: (src: string, type?: DirectoryActionType) => void): this;
533
583
  once(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
534
584
  once(event: "error", listener: (err: Error) => void): this;
535
585
  once(event: "file:read", listener: (src: string, data: Bufferable, options?: ReadFileOptions) => void): this;
@@ -537,9 +587,10 @@ declare namespace functions {
537
587
  once(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
538
588
  once(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
539
589
  once(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
590
+ once(event: "file:permission", listener: (src: string, type?: FileActionType) => void): this;
540
591
  once(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
541
592
  once(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
542
- emit(event: "end", result: FinalizeResult): boolean;
593
+ once(event: "dir:permission", listener: (src: string, type?: DirectoryActionType) => void): this;
543
594
  emit(event: "exec", command: ExecCommand, options?: SpawnOptions): boolean;
544
595
  emit(event: "error", err: Error): boolean;
545
596
  emit(event: "file:read", src: string, data: Bufferable, options?: ReadFileOptions): boolean;
@@ -547,8 +598,17 @@ declare namespace functions {
547
598
  emit(event: "file:delete", src: string, options?: DeleteFileOptions): boolean;
548
599
  emit(event: "file:copy", dest: string, options?: CopyFileOptions): boolean;
549
600
  emit(event: "file:move", dest: string, options?: MoveFileOptions): boolean;
601
+ emit(event: "file:permission", src: string, type?: FileActionType): boolean;
550
602
  emit(event: "dir:create", src: string, options?: CreateDirOptions): boolean;
551
603
  emit(event: "dir:remove", src: string, options?: RemoveDirOptions): boolean;
604
+ emit(event: "dir:permission", src: string, type?: DirectoryActionType): boolean;
605
+
606
+ on(event: "end", listener: PostFinalizeCallback): this;
607
+ on(event: "asset:permission", listener: (file: T) => void): this;
608
+ once(event: "end", listener: PostFinalizeCallback): this;
609
+ once(event: "asset:permission", listener: (file: T) => void): this;
610
+ emit(event: "end", result: FinalizeResult): boolean;
611
+ emit(event: "asset:permission", file: T): boolean;
552
612
  }
553
613
 
554
614
  interface FileManagerConstructor<T extends ExternalAsset> extends HostConstructor {
@@ -687,9 +747,7 @@ declare namespace functions {
687
747
  checkFail(message: unknown, options: LogFailOptions): LogArguments | false | undefined;
688
748
  writeLog(component: LogComponent, queue?: boolean): void;
689
749
  writeLog(type: StatusType, value: unknown, options: LogOptions): void;
690
- writeLog(type: StatusType, value: unknown, from: string, source?: string): void;
691
- writeLog(type: StatusType, value: unknown, timeStamp?: LogDate, from?: string, source?: string): void;
692
- writeLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number, from?: string, source?: string): void;
750
+ writeLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number): void;
693
751
  addLog(component: LogComponent, queue?: boolean): void;
694
752
  addLog(type: StatusType, value: unknown, options: LogOptions): void;
695
753
  addLog(type: StatusType, value: unknown, from: string, source?: string): void;
@@ -734,8 +792,10 @@ declare namespace functions {
734
792
  on(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
735
793
  on(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
736
794
  on(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
795
+ on(event: "file:permission", listener: (src: string, type?: FileActionType) => void): this;
737
796
  on(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
738
797
  on(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
798
+ on(event: "dir:permission", listener: (src: string, type?: DirectoryActionType) => void): this;
739
799
  once(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
740
800
  once(event: "error", listener: (err: Error) => void): this;
741
801
  once(event: "file:read", listener: (src: string, data: Bufferable, options?: ReadFileOptions) => void): this;
@@ -743,8 +803,10 @@ declare namespace functions {
743
803
  once(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
744
804
  once(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
745
805
  once(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
806
+ once(event: "file:permission", listener: (src: string, type?: FileActionType) => void): this;
746
807
  once(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
747
808
  once(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
809
+ once(event: "dir:permission", listener: (src: string, type?: DirectoryActionType) => void): this;
748
810
  emit(event: "exec", command: ExecCommand, options?: SpawnOptions): boolean;
749
811
  emit(event: "error", err: Error): boolean;
750
812
  emit(event: "file:read", src: string, data: Bufferable, options?: ReadFileOptions): boolean;
@@ -752,8 +814,10 @@ declare namespace functions {
752
814
  emit(event: "file:delete", src: string, options?: DeleteFileOptions): boolean;
753
815
  emit(event: "file:copy", dest: string, options?: CopyFileOptions): boolean;
754
816
  emit(event: "file:move", dest: string, options?: MoveFileOptions): boolean;
817
+ emit(event: "file:permission", src: string, type?: FileActionType): boolean;
755
818
  emit(event: "dir:create", src: string, options?: CreateDirOptions): boolean;
756
819
  emit(event: "dir:remove", src: string, options?: RemoveDirOptions): boolean;
820
+ emit(event: "dir:permission", src: string, type?: DirectoryActionType): boolean;
757
821
  }
758
822
 
759
823
  interface ModuleConstructor<T extends IHost = IHost> {
@@ -789,10 +853,11 @@ declare namespace functions {
789
853
  hasLogType(value: LogType): boolean;
790
854
  isURL(value: string, ...exclude: string[]): boolean;
791
855
  isFile(value: string | URL, type?: ProtocolType): boolean;
792
- isDir(value: string | URL): boolean;
856
+ isDir(value: string | URL, absolute?: boolean): boolean;
793
857
  isPath(value: string | URL, type?: "unc" | "unc-exists"): boolean;
794
858
  isPath(value: string | URL, isFile?: boolean): boolean;
795
- isErrorCode(err: unknown, ...code: string[]): boolean;
859
+ /** @deprecated @e-mc/types */
860
+ isErrorCode<U extends unknown[]>(err: unknown, ...code: U): err is Required<ErrorCode<U[number]>>;
796
861
  fromLocalPath(value: string): string;
797
862
  resolveFile(value: string): string;
798
863
  resolvePath(value: string, base: string | URL): string;
package/lib/module.d.ts CHANGED
@@ -141,4 +141,6 @@ export type ReadTextOptions = ReadBufferOptions;
141
141
  export type ReadFileCallback<T extends Bufferable = Bufferable> = (err: NodeJS.ErrnoException | null, data?: T) => void;
142
142
  export type ProtocolType = "http" | "https" | "http/s" | "ftp" | "sftp" | "s/ftp" | "torrent" | "unc" | "file";
143
143
  export type PermissionType = "fs" | "memory" | "memory.user" | "worker";
144
+ export type FileActionType = "read" | "write" | "delete" | "copy" | "move";
145
+ export type DirectoryActionType = "create" | "remove";
144
146
  export type FileTypeFormat = Bufferable | Uint8Array | ArrayBuffer | Readable;
package/lib/node.d.ts CHANGED
@@ -21,8 +21,8 @@ export interface Settings {
21
21
  logger?: LoggerModule;
22
22
  }
23
23
 
24
- export interface ErrorCode extends Error {
25
- code?: unknown;
24
+ export interface ErrorCode<T = unknown> extends Error {
25
+ code?: T;
26
26
  }
27
27
 
28
28
  export type HighResolutionTime = bigint | [number, number];
package/lib/request.d.ts CHANGED
@@ -4,6 +4,7 @@ import type { IRequest } from './index';
4
4
  import type { BinaryAction } from './asset';
5
5
  import type { HeadersAction, HttpProtocolVersion, HttpRequestClient, InternetProtocolVersion } from './http';
6
6
  import type { IncludeAction } from './module';
7
+ import type { ErrorCode } from './node';
7
8
  import type { HttpHostSettings, RequestModule } from './settings';
8
9
 
9
10
  import type { IncomingHttpHeaders, OutgoingHttpHeaders } from 'node:http';
@@ -115,10 +116,11 @@ export interface IHttpAdapter<T extends OpenOptions = OpenOptions> {
115
116
  }
116
117
 
117
118
  export interface HttpAdapterConstructor<T extends OpenOptions = OpenOptions> {
119
+ constructorOf<U extends HttpAdapterConstructor>(value: unknown): value is U;
118
120
  isUnsupported(value: number): boolean;
119
121
  isDowngrade(err: unknown): err is Error;
120
122
  wasAborted(err: unknown): err is Error;
121
- isConnectionError(err: unknown): err is Error;
123
+ isConnectionError(err: unknown): err is Required<ErrorCode<string>>;
122
124
  defineHostConfig(settings: RequestModule): void;
123
125
  readonly prototype: IHttpAdapter<T>;
124
126
  new(instance: IRequest, state: ControllerState, uri: string | URL, options: T): IHttpAdapter<T>;
@@ -142,7 +144,7 @@ export interface OpenOptions extends KeepAliveAction, SilentAction, EncodingActi
142
144
  timeout?: number;
143
145
  pipeTo?: string | Writable;
144
146
  postData?: unknown;
145
- connected?: ((headers: IncomingHttpHeaders) => boolean | void);
147
+ connected?: (headers: IncomingHttpHeaders) => boolean | void;
146
148
  trailers?: (headers: IncomingHttpHeaders) => void;
147
149
  statusMessage?: string;
148
150
  progressId?: number | string;
package/lib/settings.d.ts CHANGED
@@ -141,7 +141,12 @@ export interface DownloadModule<T = PlainObject> extends HandlerSettings<T> {
141
141
  /* Copy */
142
142
  check_first?: boolean;
143
143
  checksum?: boolean;
144
+ combined?: string;
145
+ csv?: boolean;
146
+ differ?: string;
147
+ error?: string;
144
148
  cutoff_mode?: "HARD" | "SOFT" | "CAUTIOUS";
149
+ hash: "md5" | "SHA-1" | "DropboxHash";
145
150
  ignore_case_sync?: boolean;
146
151
  ignore_checksum?: boolean;
147
152
  ignore_existing?: boolean;
@@ -161,8 +166,10 @@ export interface DownloadModule<T = PlainObject> extends HandlerSettings<T> {
161
166
  no_check_dest?: boolean;
162
167
  no_traverse?: boolean;
163
168
  no_update_dir_modtime?: boolean;
169
+ no_update_modtime?: boolean;
164
170
  refresh_times?: boolean;
165
171
  size_only?: boolean;
172
+ streaming_upload_cutoff?: string;
166
173
  update?: boolean;
167
174
  /* Listing */
168
175
  fast_list?: boolean;
@@ -234,10 +241,13 @@ export interface MemoryModule<T = MemorySettings> extends HandlerSettings<T>, Re
234
241
 
235
242
  export interface MemorySettings extends PlainObject {
236
243
  users?: boolean | string[];
244
+ stats?: {
245
+ file_count?: boolean;
246
+ };
237
247
  cache_disk?: MemoryCacheDiskSettings;
238
248
  }
239
249
 
240
- export interface MemoryCacheDiskSettings<T = number | string> extends IncludeAction<string[] | null> {
250
+ export interface MemoryCacheDiskSettings<T = number | string, U = string[] | null> extends IncludeAction<U> {
241
251
  enabled?: boolean;
242
252
  min_size?: T;
243
253
  max_size?: T;
@@ -354,7 +364,8 @@ export interface CompressModule<U = CompressSettings> extends HandlerSettings<U>
354
364
  }
355
365
 
356
366
  export interface CompressSettings extends PlainObject {
357
- cache?: boolean;
367
+ cache?: boolean | CacheDirAction & ObjectMap<number | string | boolean>;
368
+ /** @deprecated cache.expires */
358
369
  cache_expires?: number | string;
359
370
  gzip_level?: number | string;
360
371
  brotli_quality?: number | string;
@@ -535,8 +546,15 @@ export interface PurgeAction {
535
546
  purge?: PurgeComponent;
536
547
  }
537
548
 
549
+ export interface CacheDirAction {
550
+ enabled?: boolean;
551
+ dir?: string;
552
+ expires?: number | string;
553
+ }
554
+
538
555
  export interface PoolConfig<T = number> extends MinMax {
539
556
  idle?: T;
557
+ idle_max?: number;
540
558
  queue_max?: number;
541
559
  queue_idle?: T;
542
560
  purge?: T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/types",
3
- "version": "0.12.9",
3
+ "version": "0.13.1",
4
4
  "description": "Type definitions for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -23,6 +23,6 @@
23
23
  "chalk": "4.1.2"
24
24
  },
25
25
  "devDependencies": {
26
- "typescript": "5.8.3"
26
+ "typescript": "5.9.3"
27
27
  }
28
28
  }