@e-mc/types 0.8.7 → 0.9.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/lib/cloud.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { DbDataSource, LocationUri, StorageAction } from './squared';
2
2
 
3
3
  import type { ExternalAsset, StreamAction } from './asset';
4
+ import type { ExecuteAction } from './db';
4
5
 
5
6
  export interface UploadAction {
6
7
  cloudUrl?: string;
@@ -8,42 +9,47 @@ export interface UploadAction {
8
9
 
9
10
  export interface CloudAsset<T = CloudStorage> extends ExternalAsset, UploadAction, StorageAction<T> {}
10
11
 
11
- export interface CloudService {
12
- service: string;
13
- credential?: unknown;
12
+ export interface CloudService<T = unknown, U = string> {
13
+ service: U;
14
+ credential?: T;
14
15
  }
15
16
 
16
- export interface CloudDatabase<T = unknown, U = PlainObject, V = unknown, W = unknown> extends CloudService, DbDataSource<T, U, V> {
17
+ export interface CloudDatabase<T = unknown, U = PlainObject, V = unknown, W = unknown, X = unknown> extends CloudService<X>, Omit<DbDataSource<T, U, V>, "credential" | "parallel" | "withCommand" | "usePool">, ExecuteAction<W> {
17
18
  id?: string;
18
- params?: W;
19
19
  }
20
20
 
21
- export interface CloudStorage extends CloudService {
21
+ export interface CloudStorage<T = unknown, U = string> extends CloudService<T, U> {
22
22
  bucket?: string;
23
23
  admin?: CloudStorageAdmin;
24
24
  upload?: CloudStorageUpload;
25
25
  download?: CloudStorageDownload;
26
26
  }
27
27
 
28
- export interface CloudStorageAdmin<T = unknown, U = string, V = unknown, W = unknown> extends CloudStorageACL<U> {
28
+ export interface CloudStorageAdmin<T = unknown, U = string, V = unknown, W = unknown, X = unknown, Y = unknown> extends CloudStorageACL<U> {
29
29
  emptyBucket?: boolean;
30
30
  configBucket?: {
31
31
  create?: T;
32
32
  policy?: V;
33
+ tags?: unknown;
33
34
  website?: BucketWebsiteOptions;
34
35
  retentionPolicy?: W;
36
+ cors?: X;
37
+ lifecycle?: Y;
35
38
  };
36
39
  recursive?: boolean;
37
40
  preservePath?: boolean;
38
41
  }
39
42
 
40
- export interface CloudStorageAction<T = unknown, U = string, V = unknown, W = unknown> extends Partial<LocationUri>, StreamAction {
43
+ export interface CloudStorageAction<T = unknown, U = string, V = unknown, W = unknown, X = unknown, Y = unknown> extends Partial<LocationUri>, StreamAction {
41
44
  active?: boolean;
42
45
  overwrite?: boolean;
43
- admin?: CloudStorageAdmin<T, U, V, W>;
46
+ chunkSize?: NumString;
47
+ chunkLimit?: number;
48
+ flags?: number;
49
+ admin?: CloudStorageAdmin<T, U, V, W, X, Y>;
44
50
  }
45
51
 
46
- export interface CloudStorageUpload<T = unknown, U = string, V = unknown, W = string, X = unknown> extends CloudStorageACL<U>, CloudStorageAction<V, W, unknown, X> {
52
+ 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> {
47
53
  buffer?: Null<Buffer>;
48
54
  contentType?: string;
49
55
  metadata?: Record<string, string>;
@@ -60,8 +66,10 @@ export interface CloudStorageACL<T = string> {
60
66
  acl?: T;
61
67
  }
62
68
 
63
- export interface CloudStorageDownload<T = unknown> extends CloudStorageAction {
69
+ export interface CloudStorageDownload<T = unknown, U = unknown> extends CloudStorageAction {
70
+ keyname?: string;
64
71
  versionId?: string;
72
+ options?: U;
65
73
  deleteObject?: T;
66
74
  waitStatus?: boolean;
67
75
  }
@@ -73,20 +81,27 @@ export interface BucketWebsiteOptions {
73
81
  errorPath?: string;
74
82
  }
75
83
 
76
- export interface UploadData<T = unknown, U = string, V = unknown, W = string, X = unknown> extends BucketAction {
77
- upload: CloudStorageUpload<T, U, V, W, X>;
84
+ export interface UploadData<T = unknown, U = string, V = unknown, W = string, X = unknown, Y = unknown, Z = unknown> extends BucketAction {
85
+ upload: CloudStorageUpload<T, U, V, W, X, Y, Z>;
78
86
  localUri: string;
79
87
  buffer: Buffer;
80
88
  }
81
89
 
82
- export interface DownloadData<T = unknown> extends BucketAction {
83
- download: CloudStorageDownload<T>;
90
+ export interface DownloadData<T = unknown, U = unknown> extends BucketAction {
91
+ download: CloudStorageDownload<T, U>;
84
92
  }
85
93
 
86
94
  export interface BucketAction {
87
95
  bucket: string;
88
96
  }
89
97
 
90
- export type UploadContent = [BufferContent, string, string?];
98
+ export interface UploadAssetOptions {
99
+ contentType?: string;
100
+ ignoreProcess?: boolean;
101
+ preferBuffer?: boolean;
102
+ }
103
+
104
+ export type UploadContent = [Bufferable, string, string?];
105
+ export type CloudSource = "atlas" | "aws" | "aws-v3" | "az" | "azure" | "gcp" | "gcloud" | "ibm" | "oci" | "minio";
91
106
  export type CloudFeatures = "storage" | "database";
92
107
  export type CloudFunctions = "upload" | "download";
@@ -1,6 +1,6 @@
1
- import type { CloudConstructor, FileManagerConstructor, ICloud, IFileManager, IHost, IImage, IModule, ImageConstructor, ModuleConstructor, WatchConstructor } from './index';
1
+ import type { CloudConstructor, FileManagerConstructor, ICloud, IFileManager, IHost, IModule, ModuleConstructor, WatchConstructor } from './index';
2
2
 
3
- import type { ExternalAsset, IFileThread } from './asset';
3
+ import type { ExternalAsset } from './asset';
4
4
  import type { CacheOptions } from './core';
5
5
  import type { QueryResult } from './db';
6
6
  import type { ITransformSeries, OutV3, TransformSeriesConstructor } from './document';
@@ -9,14 +9,11 @@ import type { HttpAgentSettings, HttpProtocolVersion, HttpRequestClient, Interne
9
9
  import type { CloneObjectOptions, GetFunctionsOptions } from './module';
10
10
  import type { LogFailOptions, LogType, LogValue } from './logger';
11
11
  import type { HostConfig, OpenOptions, ProxySettings } from './request';
12
- import type { DbCoerceSettings, DnsLookupSettings, HttpMemorySettings, HttpSettings, ImageModule } from './settings';
12
+ import type { DbCoerceSettings, DnsLookupSettings, HttpMemorySettings, HttpSettings } from './settings';
13
13
 
14
- import type { Readable, Writable } from 'stream';
15
14
  import type { OutgoingHttpHeaders } from 'http';
16
15
  import type { LookupFunction } from 'net';
17
-
18
- // @ts-ignore
19
- import type { BytesOptions } from 'bytes';
16
+ import type { Readable, Writable } from 'stream';
20
17
 
21
18
  type CpuUsage = NodeJS.CpuUsage;
22
19
 
@@ -36,13 +33,13 @@ export interface IModuleLibV4 {
36
33
  toTimeMs(hrtime: HighResolutionTime, format?: boolean): NumString;
37
34
  renameExt(value: string, ext: string, when?: string): string;
38
35
  existsSafe(value: string, isFile?: boolean): boolean;
39
- readFileSafe(value: string, encoding: BufferEncoding | "buffer", cache?: boolean): Null<BufferContent>;
36
+ readFileSafe(value: string, encoding: BufferEncoding | "buffer", cache?: boolean): Null<Bufferable>;
40
37
  getFunctions<T extends FunctionType>(values: unknown[], absolute?: boolean | GetFunctionsOptions, sync?: boolean, outFailed?: string[]): T[];
41
- formatSize(value: NumString, options?: BytesOptions): NumString;
38
+ formatSize(value: NumString, options?: PlainObject): NumString;
42
39
  hasSameStat(src: string, dest: string, keepEmpty?: boolean): boolean;
43
40
  hasSize(value: string, keepEmpty?: boolean): boolean;
44
41
  getSize(value: string, diskUsed?: boolean): number;
45
- byteLength(value: BufferContent, encoding?: BufferEncoding): number;
42
+ byteLength(value: Bufferable, encoding?: BufferEncoding): number;
46
43
  cleanupStream(target: Readable | Writable, pathname?: string): void;
47
44
  allSettled<U>(values: readonly (U | PromiseLike<U>)[], rejected?: LogValue, options?: LogFailOptions | LogType): Promise<PromiseSettledResult<U>[]>;
48
45
  }
@@ -91,10 +88,6 @@ export interface FileManagerCompatV4Constructor<T extends ExternalAsset = Extern
91
88
  new(...args: unknown[]): IFileManagerCompatV4<T>;
92
89
  }
93
90
 
94
- export interface ImageCompatV4Constructor<T extends IHost = IHost, U extends ImageModule = ImageModule> extends ImageConstructor<T, U> {
95
- using<V extends ExternalAsset>(this: T, instance: IImage<T, U>, data: IFileThread<V>, command: string): Promise<unknown>;
96
- }
97
-
98
91
  export interface ICloudCompatV4<T extends IHost = IHost> extends ICloud<T> {
99
92
  getDatabaseResult(service: string, credential: unknown, queryString: string, options?: CacheOptions | boolean | string): Undef<QueryResult>;
100
93
  setDatabaseResult(service: string, credential: unknown, queryString: string, result: unknown, options?: CacheOptions | string): QueryResult;
package/lib/compress.d.ts CHANGED
@@ -7,6 +7,8 @@ interface CompressFormat extends ICompressFormat, LogBaseOptions {
7
7
  startTime?: LogTime;
8
8
  etag?: string;
9
9
  proxyUrl?: string | ((uri: string) => Undef<string>);
10
+ outExt?: string;
11
+ outFile?: string;
10
12
  }
11
13
 
12
14
  interface Woff {
@@ -18,8 +20,6 @@ type ResultCallback<T = Null<Buffer | Uint8Array>> = (err: unknown, data?: T, ex
18
20
  type ResultData = Null<Buffer | Uint8Array> | string;
19
21
 
20
22
  export type BufferLike = Buffer | Uint8Array | ArrayBuffer | SharedArrayBuffer | readonly number[];
21
- export type TryFileCompressor = (data: string | Buffer, output: string, config: CompressFormat, callback?: TryFileResult) => Void<Promise<ResultData>>;
23
+ export type TryFileCompressor = (data: string | Buffer, output: string, config: CompressFormat, callback?: ResultCallback<ResultData>) => Void<Promise<ResultData>>;
22
24
  export type TryFileCompressorAsync = (data: string | Buffer, output: string, config: CompressFormat) => Promise<ResultData>;
23
- export type TryFileResult = ResultCallback<ResultData>;
24
- export type TryImageResult = ResultCallback;
25
25
  export type BufferResult = Null<Buffer | Uint8Array>;
package/lib/core.d.ts CHANGED
@@ -4,14 +4,20 @@ import type { DataSource, RequestBase } from './squared';
4
4
 
5
5
  import type { IExternalConfig, IExternalFunction, IHost, IModule, ModuleConstructor } from './index';
6
6
  import type { QueryResult, TimeoutAction } from './db';
7
- import type { AddEventListenerOptions } from './dom';
8
7
  import type { Settings } from './node';
9
- import type { ClientDbSettings, ClientModule, DbCacheValue, DbCoerceSettings, DbCoerceValue, DbSourceOptions } from './settings';
8
+ import type { ClientDbSettings, ClientModule, DbCacheValue, DbCoerceSettings, DbSourceOptions } from './settings';
10
9
 
11
10
  export interface IdentifierAction {
12
11
  uuidKey?: string;
13
12
  }
14
13
 
14
+ export interface AddEventListenerOptions {
15
+ capture?: boolean;
16
+ once?: boolean;
17
+ passive?: boolean;
18
+ signal?: AbortSignal;
19
+ }
20
+
15
21
  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
22
  init(...args: unknown[]): this;
17
23
  getUserSettings<X>(): Null<X>;
@@ -28,14 +34,13 @@ export interface IClientDb<T extends IHost, U extends ClientModule<ClientDbSetti
28
34
  database: V[];
29
35
  cacheExpires: number;
30
36
  add(item: V, state?: number): void;
31
- hasCache(source: string, sessionKey?: string, override?: DbCacheValue): boolean;
37
+ hasCache(source: string, sessionKey?: string): boolean;
32
38
  hasCoerce(source: string, component: keyof DbCoerceSettings, uuidKey: Undef<string>): boolean;
33
- hasCoerce(source: string, component: keyof DbCoerceSettings, override: Optional<DbCoerceValue>, credential?: unknown): boolean;
34
39
  hasCoerce(source: string, component: keyof DbCoerceSettings, credential?: unknown): boolean;
35
40
  getQueryResult(source: string, credential: unknown, queryString: string, renewCache: boolean): Undef<QueryResult>;
36
- getQueryResult(source: string, credential: unknown, queryString: string, sessionKey: string, renewCache?: boolean): Undef<QueryResult>;
41
+ getQueryResult(source: string, credential: unknown, queryString: string, sessionKey?: string, renewCache?: boolean): Undef<QueryResult>;
37
42
  getQueryResult(source: string, credential: unknown, queryString: string, options?: CacheOptions | string, renewCache?: boolean): Undef<QueryResult>;
38
- setQueryResult(source: string, credential: unknown, queryString: string, result: unknown, sessionKey: Undef<string>): QueryResult;
43
+ setQueryResult(source: string, credential: unknown, queryString: string, result: unknown, sessionKey?: string): QueryResult;
39
44
  setQueryResult(source: string, credential: unknown, queryString: string, result: unknown, options?: CacheOptions | string): QueryResult;
40
45
  applyState(items: ArrayOf<V>, value: number, as?: boolean): void;
41
46
  commit(items?: V[]): Promise<boolean>;
@@ -86,14 +91,14 @@ export interface AbortComponentConstructor {
86
91
  }
87
92
 
88
93
  export interface IPermission {
89
- setDiskRead(pathname?: StringOfArray, enabled?: boolean): void;
90
- setDiskWrite(pathname?: StringOfArray, enabled?: boolean): void;
91
- setUNCRead(pathname?: StringOfArray, enabled?: boolean): void;
92
- setUNCWrite(pathname?: StringOfArray, enabled?: boolean): void;
93
- getDiskRead(): StringOfArray;
94
- getDiskWrite(): StringOfArray;
95
- getUNCRead(): StringOfArray;
96
- getUNCWrite(): StringOfArray;
94
+ setDiskRead(pathname?: ArrayOf<string>, enabled?: boolean): void;
95
+ setDiskWrite(pathname?: ArrayOf<string>, enabled?: boolean): void;
96
+ setUNCRead(pathname?: ArrayOf<string>, enabled?: boolean): void;
97
+ setUNCWrite(pathname?: ArrayOf<string>, enabled?: boolean): void;
98
+ getDiskRead(): ArrayOf<string>;
99
+ getDiskWrite(): ArrayOf<string>;
100
+ getUNCRead(): ArrayOf<string>;
101
+ getUNCWrite(): ArrayOf<string>;
97
102
  hasDiskRead(pathname: string): boolean;
98
103
  hasDiskWrite(pathname: string): boolean;
99
104
  hasUNCRead(pathname: string): boolean;
@@ -109,8 +114,8 @@ export interface PermissionConstructor {
109
114
  create(settings: PermittedDirectories, parent: Null<IPermission>, freeze?: boolean): Null<IPermission>;
110
115
  validate(settings: unknown): settings is PermittedDirectories;
111
116
  clone(permission: IPermission, freeze?: boolean): IPermission;
112
- match(pathname: string, pattern: StringOfArray): boolean;
113
- toPosix(value: unknown): StringOfArray;
117
+ match(pathname: string, pattern: ArrayOf<string>): boolean;
118
+ toPosix(value: unknown): ArrayOf<string>;
114
119
  readonly prototype: IPermission;
115
120
  new(freeze?: boolean): IPermission;
116
121
  }
@@ -134,11 +139,12 @@ export interface HostInitConfig extends PlainObject, RequestBase<HostInitLog> {
134
139
  export interface HostInitLog {
135
140
  enabled?: boolean;
136
141
  level?: NumString;
137
- exclude?: StringOfArray;
142
+ exclude?: ArrayOf<string>;
138
143
  useColor?: boolean;
144
+ showProgress?: boolean;
139
145
  }
140
146
 
141
- export interface PermittedDirectories extends PermissionReadWrite<StringOfArray> {
147
+ export interface PermittedDirectories extends PermissionReadWrite<ArrayOf<string>> {
142
148
  inherit?: boolean;
143
149
  }
144
150
 
@@ -161,7 +167,7 @@ export interface ThreadInfo {
161
167
  startTime: number;
162
168
  username?: string;
163
169
  sessionId?: string;
164
- broadcastId?: StringOfArray;
170
+ broadcastId?: ArrayOf<string>;
165
171
  }
166
172
 
167
173
  export interface ThreadCountStat {
package/lib/db.d.ts CHANGED
@@ -86,15 +86,6 @@ export interface DbPoolConstructor<T extends DbDataSource = DbDataSource, U = un
86
86
  new(pool: U, poolKey: string, uuidKey?: Null<AuthValue>): IDbPool<T, U, V>;
87
87
  }
88
88
 
89
- export interface PoolConfig<T = number> extends MinMax {
90
- idle?: T;
91
- queue_max?: number;
92
- queue_idle?: T;
93
- purge?: T;
94
- timeout?: number;
95
- socket_timeout?: number;
96
- }
97
-
98
89
  export interface TimeoutAction {
99
90
  timeout?: NumString;
100
91
  }
@@ -1,6 +1,6 @@
1
1
  import type { BundleAction, ChecksumOutput, FileInfo, LogStatus } from './squared';
2
2
 
3
- import type { IFileManager, IModule, ModuleConstructor } from './index';
3
+ import type { IFileManager, IImage, IModule, ImageConstructor, ModuleConstructor } from './index';
4
4
  import type { ExternalAsset } from './asset';
5
5
  import type { HostInitLog as IHostInitLog } from './core';
6
6
  import type { ReadHashOptions } from './module';
@@ -60,7 +60,7 @@ export interface IHttpMemoryCache<T extends ExternalAsset = ExternalAsset> exten
60
60
  }
61
61
 
62
62
  export interface HttpDiskCacheAddOptions {
63
- buffer?: Null<BufferContent>;
63
+ buffer?: Null<Bufferable>;
64
64
  contentLength?: number;
65
65
  }
66
66
 
@@ -117,5 +117,6 @@ export interface ChecksumOptions extends ReadHashOptions, Pick<ChecksumOutput, "
117
117
  throwsEmpty?: boolean;
118
118
  }
119
119
 
120
+ export type ImageMimeMap = Map<string, InstallData<IImage, ImageConstructor>>;
120
121
  export type FetchType = FETCH_TYPE[keyof FETCH_TYPE];
121
122
  export type PostFinalizeCallback = (files: FileInfo[] | string[], errors: string[], status?: LogStatus[]) => void;
package/lib/http.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { LookupAddress } from 'dns';
2
2
  import type { ClientRequest, Agent as HttpAgent, OutgoingHttpHeaders } from 'http';
3
3
  import type { Agent as HttpsAgent } from 'https';
4
4
  import type { ClientHttp2Stream } from 'http2';
5
+ import type { SecureVersion } from 'tls';
5
6
 
6
7
  export const enum HTTP_STATUS {
7
8
  CONTINUE = 100,
@@ -87,6 +88,25 @@ export interface HttpAgentSettings {
87
88
  timeout?: number;
88
89
  }
89
90
 
91
+ export interface SecureConfig<T = string, U = T> {
92
+ ca?: T;
93
+ key?: U;
94
+ cert?: T;
95
+ passphrase?: U;
96
+ version?: SecureVersion;
97
+ }
98
+
99
+ export interface ServerPort<T = NumString> {
100
+ port?: T;
101
+ }
102
+
103
+ export interface ServerSecure extends SecureConfig, ServerPort {}
104
+
105
+ export interface AuthValue {
106
+ username?: string;
107
+ password?: string;
108
+ }
109
+
90
110
  export type HttpRequestClient = ClientRequest | ClientHttp2Stream;
91
111
  export type HttpOutgoingHeaders = ObjectMap<OutgoingHttpHeaders>;
92
112
  export type HttpProtocolVersion = 1 | 2 | 3;