@e-mc/types 0.10.6 → 0.10.7

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/settings.d.ts CHANGED
@@ -5,7 +5,7 @@ import type { CloudSource } from './cloud';
5
5
  import type { PermissionAction, PermissionReadWrite, PermittedDirectories } from './core';
6
6
  import type { DbSource, TimeoutAction } from './db';
7
7
  import type { HttpOutgoingHeaders, SecureConfig, ServerPort } from './http';
8
- import type { BackgroundColor, BroadcastOutMethod, ErrorOutMethod, ForegroundColor, LoggerColor, LoggerStatus, TextAlign } from './logger';
8
+ import type { BackgroundColor, BroadcastOutMethod, ErrorOutMethod, ForegroundColor, LoggerColor, LoggerStatus, TextAlign, TextWrapStyle } from './logger';
9
9
  import type { ExecAction, IncludeAction } from './module';
10
10
 
11
11
  import type { SpawnOptions } from 'child_process';
@@ -13,6 +13,7 @@ import type { BinaryLike, CipherGCMTypes } from 'crypto';
13
13
  import type { LookupAddress } from 'dns';
14
14
  import type { BrotliOptions, ZlibOptions } from 'zlib';
15
15
 
16
+ import type { BackgroundColor as IBackgroundColor } from 'chalk';
16
17
  // @ts-ignore
17
18
  import type { Unit } from 'bytes';
18
19
  // @ts-ignore
@@ -59,13 +60,13 @@ export interface ProcessModule<T = PlainObject> extends HandlerSettings<T> {
59
60
  private?: boolean;
60
61
  };
61
62
  queue?: {
62
- limit?: NumString;
63
- expires?: NumString;
64
- priority: { bypass?: NumString } & MinMax<NumString>;
63
+ limit?: number | string;
64
+ expires?: number | string;
65
+ priority: { bypass?: number | string } & MinMax<number | string>;
65
66
  };
66
- limit?: NumString;
67
- sub_limit?: NumString;
68
- expires?: NumString;
67
+ limit?: number | string;
68
+ sub_limit?: number | string;
69
+ expires?: number | string;
69
70
  };
70
71
  cipher?: CipherConfig;
71
72
  password?: string;
@@ -77,6 +78,7 @@ export interface ProcessEnvConfig {
77
78
 
78
79
  export interface TempModule<T = PlainObject> extends HandlerSettings<T> {
79
80
  dir?: string;
81
+ env?: string;
80
82
  write?: boolean;
81
83
  }
82
84
 
@@ -92,19 +94,20 @@ export interface PermissionSettings extends PlainObject {
92
94
  }
93
95
 
94
96
  export interface DownloadModule<T = PlainObject> extends HandlerSettings<T> {
95
- expires?: NumString;
97
+ expires?: number | string;
96
98
  aria2?: {
97
99
  bin?: string | false;
98
100
  exec?: ExecAction;
99
- update_status?: NumString | { interval?: NumString; broadcast_only?: boolean };
100
- max_concurrent_downloads?: NumString;
101
- max_connection_per_server?: NumString;
102
- bt_stop_timeout?: NumString;
103
- bt_tracker_connect_timeout?: NumString;
104
- bt_tracker_timeout?: NumString;
101
+ check_integrity?: boolean;
102
+ update_status?: number | string | { interval?: number | string; broadcast_only?: boolean };
103
+ max_concurrent_downloads?: number | string;
104
+ max_connection_per_server?: number | string;
105
+ bt_stop_timeout?: number | string;
106
+ bt_tracker_connect_timeout?: number | string;
107
+ bt_tracker_timeout?: number | string;
105
108
  min_split_size?: string;
106
- disk_cache?: NumString;
107
- lowest_speed_limit?: NumString;
109
+ disk_cache?: number | string;
110
+ lowest_speed_limit?: number | string;
108
111
  always_resume?: boolean;
109
112
  file_allocation?: "none" | "prealloc" | "trunc" | "falloc";
110
113
  conf_path?: string;
@@ -144,13 +147,13 @@ export interface DocumentComponentOption<T = unknown> {
144
147
  cache?: T;
145
148
  coerce?: boolean;
146
149
  abort?: boolean;
147
- local_file?: NumString;
150
+ local_file?: number | string;
148
151
  }
149
152
 
150
- export interface DocumentSettings extends DocumentGroup, PurgeAction, ClientSettings<DocumentUserSettings>, PlainObject {
151
- imports_strict?: boolean;
153
+ export interface DocumentSettings<T extends DocumentUserSettings = DocumentUserSettings> extends DocumentGroup, PurgeAction, ClientSettings<T>, PlainObject {
152
154
  directory?: DocumentDirectory;
153
155
  options?: DocumentComponentOptions;
156
+ imports_strict?: boolean;
154
157
  }
155
158
 
156
159
  export interface DocumentDirectory extends StringMap {
@@ -172,7 +175,7 @@ export interface MemorySettings extends PlainObject {
172
175
  cache_disk?: MemoryCacheDiskSettings;
173
176
  }
174
177
 
175
- export interface MemoryCacheDiskSettings<T = NumString> extends IncludeAction<Null<string[]>> {
178
+ export interface MemoryCacheDiskSettings<T = number | string> extends IncludeAction<Null<string[]>> {
176
179
  enabled?: boolean;
177
180
  min_size?: T;
178
181
  max_size?: T;
@@ -189,12 +192,12 @@ export interface DbUserSettings extends DbSourceDataType<{ commands?: ObjectMap<
189
192
 
190
193
  export interface DbCacheSettings extends TimeoutAction {
191
194
  dir?: string;
192
- purge?: NumString;
195
+ purge?: number | string;
193
196
  when_empty?: boolean;
194
197
  }
195
198
 
196
199
  export interface DbSourceOptions {
197
- pool?: PoolConfig<NumString>;
200
+ pool?: PoolConfig<number | string>;
198
201
  cache?: DbCacheValue;
199
202
  coerce?: DbCoerceValue;
200
203
  }
@@ -204,20 +207,20 @@ export interface DbCoerceSettings<T = boolean> {
204
207
  options?: T;
205
208
  }
206
209
 
207
- export interface PurgeBase<T = NumString> extends MinMax {
210
+ export interface PurgeBase<T = number | string> extends MinMax {
208
211
  enabled?: boolean;
209
212
  percent?: T;
210
213
  limit?: number;
211
214
  }
212
215
 
213
216
  export interface PurgeComponent extends PurgeBase {
214
- interval?: NumString;
217
+ interval?: number | string;
215
218
  all?: boolean | number;
216
219
  log?: boolean;
217
220
  prefix?: string;
218
221
  }
219
222
 
220
- export type DbCacheValue = NumString | DbCacheSettings;
223
+ export type DbCacheValue = number | string | DbCacheSettings;
221
224
  export type DbCoerceValue = boolean | DbCoerceSettings;
222
225
  export type DbSourceDataType<T = unknown> = {
223
226
  [K in DbSource]?: T;
@@ -234,35 +237,42 @@ export interface ImageSettings extends PlainObject {
234
237
  };
235
238
  }
236
239
 
237
- export interface RequestModule<T = RequestSettings> extends HandlerSettings<T> {
238
- timeout?: NumString;
239
- read_timeout?: NumString;
240
+ export interface RequestModule<T = RequestSettings> extends HandlerSettings<T>, HttpHostSettings {
241
+ timeout?: number | string;
242
+ read_timeout?: number | string;
240
243
  agent?: {
241
244
  keep_alive?: boolean;
242
- timeout?: NumString;
245
+ timeout?: number | string;
243
246
  };
244
247
  disk?: HttpDiskSettings;
245
248
  buffer?: HttpMemorySettings;
246
249
  connect?: HttpConnectSettings;
247
250
  dns?: DnsLookupSettings;
248
251
  use?: {
249
- http_version?: NumString;
252
+ http_version?: number | string;
250
253
  accept_encoding?: boolean;
251
254
  };
252
- proxy?: AuthValue & IncludeAction & {
253
- address?: string;
254
- port?: NumString;
255
- keep_alive?: boolean;
256
- };
255
+ proxy?: HttpProxySettings;
257
256
  headers?: HttpOutgoingHeaders;
258
257
  certs?: ObjectMap<SecureConfig<ArrayOf<string>>>;
258
+ post_limit?: number | string;
259
+ }
260
+
261
+ export interface HttpProxySettings extends AuthValue, IncludeAction {
262
+ address?: string;
263
+ port?: number | string;
264
+ origin?: string;
265
+ keep_alive?: boolean;
266
+ }
267
+
268
+ export interface HttpHostSettings {
259
269
  localhost?: string[];
260
270
  protocol?: {
261
271
  "http/1.1"?: string[];
262
272
  h2c?: string[];
263
273
  h2?: string[];
264
274
  };
265
- post_limit?: NumString;
275
+ write_stream?: ObjectMap<number | string>;
266
276
  }
267
277
 
268
278
  export interface RequestSettings extends PurgeAction, PlainObject {
@@ -270,7 +280,7 @@ export interface RequestSettings extends PurgeAction, PlainObject {
270
280
  }
271
281
 
272
282
  export interface WatchModule<T = WatchSettings> extends HandlerModule<T>, ServerInfo {
273
- interval?: NumString;
283
+ interval?: number | string;
274
284
  }
275
285
 
276
286
  export interface WatchSettings<T = WatchUserSettings> extends ClientSettings<ObjectMap<T>>, PlainObject {}
@@ -279,19 +289,15 @@ export interface CompressModule<U = CompressSettings> extends HandlerSettings<U>
279
289
  gzip?: ZlibOptions;
280
290
  brotli?: BrotliOptions;
281
291
  zopfli?: ZopfliOptions;
282
- tinify?: {
283
- api_key?: string;
284
- proxy?: string;
285
- };
286
292
  }
287
293
 
288
294
  export interface CompressSettings extends PlainObject {
289
295
  cache?: boolean;
290
- cache_expires?: NumString;
291
- gzip_level?: NumString;
292
- brotli_quality?: NumString;
293
- zopfli_iterations?: NumString;
294
- chunk_size?: NumString;
296
+ cache_expires?: number | string;
297
+ gzip_level?: number | string;
298
+ brotli_quality?: number | string;
299
+ zopfli_iterations?: number | string;
300
+ chunk_size?: number | string;
295
301
  }
296
302
 
297
303
  export interface TaskModule<T = PlainObject> extends ClientModule<T>, PlainObject {}
@@ -319,14 +325,24 @@ export interface ErrorModule extends HandlerModule {
319
325
  out?: string | ErrorOutMethod;
320
326
  abort?: string[];
321
327
  fatal?: boolean;
322
- recursion_limit?: NumString;
328
+ recursion_limit?: number | string;
329
+ }
330
+
331
+ export interface LoggerProgress extends LoggerFormatColor {
332
+ scroll_buffer?: number | string;
333
+ max_width?: number | string;
334
+ use_color?: boolean;
335
+ text_wrap?: TextWrapStyle;
336
+ box_char?: string;
337
+ raw_mode?: boolean;
323
338
  }
324
339
 
325
- export interface LoggerModule<T = NumString, U = boolean | T, V = LoggerFormat<T>> {
340
+ export interface LoggerModule<T = number | string, U = boolean | T, V = LoggerFormat<T>> {
326
341
  enabled?: boolean;
327
- level?: NumString;
342
+ level?: number | string;
328
343
  production?: string[];
329
344
  format?: LoggerFormatSettings<V>;
345
+ progress?: LoggerProgress;
330
346
  meter?: LoggerMeterSettings<T>;
331
347
  broadcast?: BroadcastServer & { color?: boolean };
332
348
  status?: boolean | LoggerStatus;
@@ -359,9 +375,10 @@ export interface LoggerFormatSettings<T = PlainObject> {
359
375
  session_id?: T;
360
376
  message?: T;
361
377
  meter?: T;
378
+ error?: T;
362
379
  }
363
380
 
364
- export interface LoggerMeterSettings<T = NumString> {
381
+ export interface LoggerMeterSettings<T = number | string> {
365
382
  http?: T;
366
383
  image?: T;
367
384
  compress?: T;
@@ -371,52 +388,58 @@ export interface LoggerMeterSettings<T = NumString> {
371
388
  export interface LoggerProcessSettings extends LoggerColor {
372
389
  cpu?: boolean;
373
390
  cpu_bar?: boolean | ArrayOf<number>;
391
+ cpu_bar_color?: [typeof IBackgroundColor, typeof IBackgroundColor, typeof IBackgroundColor];
374
392
  cpu_single_core?: boolean;
375
393
  mem?: boolean;
376
394
  mem_format?: "%" | Unit;
377
395
  }
378
396
 
379
- export interface LoggerFormat<T = NumString> {
380
- width?: T;
397
+ export interface LoggerFormatColor {
381
398
  color?: ForegroundColor;
382
399
  bg_color?: BackgroundColor;
400
+ }
401
+
402
+ export interface LoggerFormat<T = number | string> extends LoggerFormatColor {
403
+ width?: T;
404
+ alt_color?: ForegroundColor;
383
405
  bg_alt_color?: BackgroundColor;
384
406
  bold?: boolean;
385
407
  justify?: TextAlign;
386
408
  unit?: string;
387
409
  as?: StringMap;
410
+ braces?: string | TupleOf<string>;
388
411
  }
389
412
 
390
413
  export interface HttpSettings {
391
- version?: NumString;
392
- timeout?: NumString;
414
+ version?: number | string;
415
+ timeout?: number | string;
393
416
  headers?: HttpOutgoingHeaders;
394
417
  certs?: ObjectMap<SecureConfig<ArrayOf<string>>>;
395
418
  }
396
419
 
397
420
  export interface HttpDiskSettings extends IncludeAction {
398
421
  enabled?: boolean;
399
- limit?: NumString;
400
- expires?: NumString;
422
+ limit?: number | string;
423
+ expires?: number | string;
401
424
  }
402
425
 
403
426
  export interface HttpMemorySettings extends HttpDiskSettings {
404
- limit_all?: NumString;
405
- to_disk?: NumString | [NumString, NumString?];
406
- purge_amount?: NumString;
427
+ limit_all?: number | string;
428
+ to_disk?: number | string | [number | string, (number | string)?];
429
+ purge_amount?: number | string;
407
430
  }
408
431
 
409
432
  export interface HttpConnectSettings {
410
- timeout?: NumString;
411
- retry_wait?: NumString;
412
- retry_after?: NumString;
413
- retry_limit?: NumString;
414
- redirect_limit?: NumString;
433
+ timeout?: number | string;
434
+ retry_wait?: number | string;
435
+ retry_after?: number | string;
436
+ retry_limit?: number | string;
437
+ redirect_limit?: number | string;
415
438
  }
416
439
 
417
440
  export interface DnsLookupSettings {
418
- family?: NumString;
419
- expires?: NumString;
441
+ family?: number | string;
442
+ expires?: number | string;
420
443
  resolve?: ObjectMap<Partial<LookupAddress>>;
421
444
  }
422
445
 
@@ -424,12 +447,12 @@ export interface HashConfig extends IncludeAction<ObjectMap<string[] | "*">> {
424
447
  enabled?: boolean;
425
448
  algorithm?: HashAlgorithm;
426
449
  etag?: boolean;
427
- expires?: NumString;
450
+ expires?: number | string;
428
451
  renew?: boolean;
429
- limit?: NumString;
452
+ limit?: number | string;
430
453
  }
431
454
 
432
- export interface BroadcastServer extends ServerInfo<ArrayOf<NumString>> {
455
+ export interface BroadcastServer extends ServerInfo<ArrayOf<number | string>> {
433
456
  out?: string | BroadcastOutMethod;
434
457
  }
435
458
 
@@ -457,7 +480,7 @@ export interface CipherConfig {
457
480
  iv?: BinaryLike;
458
481
  }
459
482
 
460
- export interface ServerInfo<T = NumString> extends ServerPort<T> {
483
+ export interface ServerInfo<T = number | string> extends ServerPort<T> {
461
484
  enabled?: boolean;
462
485
  secure?: SecureConfig & ServerPort<T>;
463
486
  }
package/lib/squared.d.ts CHANGED
@@ -23,18 +23,6 @@ interface BlobValue extends KeyValue<string, unknown> {
23
23
  filename?: string;
24
24
  }
25
25
 
26
- interface BoxRect<T = number> {
27
- top: T;
28
- right: T;
29
- bottom: T;
30
- left: T;
31
- }
32
-
33
- interface BoxRectDimension extends BoxRect, Dimension {
34
- numberOfLines?: number;
35
- overflow?: boolean;
36
- }
37
-
38
26
  export interface FileAsset extends TextAsset, OutputAction, DocumentAction, MultipartAction, ResourceAction, IncrementalAction, ChecksumAction {
39
27
  format?: ArrayOf<string>;
40
28
  dataView?: NodeJS.ArrayBufferView;
@@ -53,7 +41,7 @@ export interface DataSource<T = unknown> extends DocumentAction {
53
41
  preRender?: string | FunctionType;
54
42
  whenEmpty?: string | FunctionType;
55
43
  removeEmpty?: boolean;
56
- ignoreCache?: boolean | 0 | 1 | [number, number?, number?];
44
+ ignoreCache?: IntBool | FirstOf<number, number>;
57
45
  transactionState?: number;
58
46
  transactionFail?: boolean;
59
47
  }
@@ -66,6 +54,7 @@ export interface DbDataSource<T = unknown, U = unknown, V = unknown, W = unknown
66
54
  update?: V;
67
55
  withCommand?: string | TupleOf<string>;
68
56
  parallel?: boolean;
57
+ flat?: number;
69
58
  willAbort?: boolean;
70
59
  streamRow?: Null<boolean | string | ((row: unknown) => Void<Error | false>)>;
71
60
  usePool?: boolean | X;
@@ -91,7 +80,7 @@ export interface WatchAction {
91
80
  }
92
81
 
93
82
  export interface BundleAction<T = unknown> {
94
- bundleId?: NumString;
83
+ bundleId?: number | string;
95
84
  bundleIndex?: number;
96
85
  bundleReplace?: T;
97
86
  bundleQueue?: Promise<unknown>[];
@@ -225,7 +214,7 @@ export interface CompressFormat extends CompressLevel {
225
214
  condition?: string;
226
215
  plugin?: string;
227
216
  timeout?: number;
228
- options?: PlainObject & { apiKey?: string };
217
+ options?: PlainObject;
229
218
  }
230
219
 
231
220
  export interface WatchInterval<T = FileAsset> extends TaskBase {
@@ -268,7 +257,7 @@ export interface BroadcastResponse extends WebSocketResponse {
268
257
 
269
258
  export interface FileInfo {
270
259
  name: string;
271
- size: NumString;
260
+ size: number | string;
272
261
  }
273
262
 
274
263
  export interface RequestBase<T = PlainObject> {
@@ -322,32 +311,7 @@ export interface ResponseError {
322
311
 
323
312
  export interface RequestObserve extends WebSocketClient {
324
313
  action?: string;
325
- expires?: NumString;
326
- }
327
-
328
- export interface FinalizedElement {
329
- documentId: string;
330
- bounds: BoxRectDimension;
331
- css: PlainObject;
332
- outerWrapperIds?: string[];
333
- }
334
-
335
- export interface ConditionProperty {
336
- conditionText: string;
337
- }
338
-
339
- export interface CssConditionData extends ConditionProperty {
340
- name?: string;
341
- conditionText: string;
342
- }
343
-
344
- export interface ControllerSettingsDirectoryUI {
345
- layout: string;
346
- string: string;
347
- font: string;
348
- image: string;
349
- video: string;
350
- audio: string;
314
+ expires?: number | string;
351
315
  }
352
316
 
353
317
  export interface ChecksumBase<T = BinaryToTextEncoding> {
@@ -363,9 +327,9 @@ export interface ChecksumOutput<T = BinaryToTextEncoding> extends ChecksumBase<T
363
327
  }
364
328
 
365
329
  export interface TaskBase {
366
- interval?: NumString;
367
- start?: NumString;
368
- expires?: NumString;
330
+ interval?: number | string;
331
+ start?: number | string;
332
+ expires?: number | string;
369
333
  }
370
334
 
371
335
  export type WebSocketEvent = "close" | "error";
package/lib/task.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export interface Command<T = unknown> extends PlainObject {
2
- task: string;
3
- origDir: string;
4
- data: T;
5
- }
6
-
7
- export interface SpawnResult {
8
- added?: string[];
9
- deleted?: string[];
1
+ export interface Command<T = unknown> extends PlainObject {
2
+ task: string;
3
+ origDir: string;
4
+ data: T;
5
+ }
6
+
7
+ export interface SpawnResult {
8
+ added?: string[];
9
+ deleted?: string[];
10
10
  }
package/lib/type.d.ts CHANGED
@@ -1,31 +1,34 @@
1
- /* eslint @typescript-eslint/no-explicit-any: "off", @typescript-eslint/no-redeclare: "off" */
2
-
3
1
  type Undef<T> = T | undefined;
4
2
  type Null<T> = T | null;
5
3
  type Void<T> = T | void;
6
4
  type Optional<T> = T | null | undefined;
7
5
  type Nullable<T> = { [P in keyof T]: T[P] | null; };
8
- type Writeable<T> = { -readonly [P in keyof T]: T[P] };
6
+ type Writable<T> = { -readonly [P in keyof T]: T[P] };
9
7
  type KeyOfType<T, U = any, V = any> = { [K in keyof T]: K extends U ? T[K] extends V ? K : never : never }[keyof T];
10
8
  type MapOfType<T, U = any, V = any> = { [K in KeyOfType<T, U, V>]: K extends U ? T[K] extends V ? T[K] : never : never };
11
9
 
12
10
  type Constructor<out T> = new(...args: any[]) => T;
11
+ type ConstructorDerived<T> = Pick<T, { [K in keyof T]: T[K] extends new() => any ? never : K }[keyof T]>;
13
12
 
14
13
  type FunctionType<T = unknown, U = unknown> = (...args: U[]) => T;
15
14
  type FunctionArgs<T extends unknown[], U = unknown> = (...args: T) => U;
16
15
 
16
+ /** @deprecated */
17
17
  type NumString = number | string;
18
+ type IntBool = boolean | 0 | 1;
18
19
  type ArrayOf<T> = T | T[];
20
+ /** @deprecated */
19
21
  type TupleOf<T> = [T, T];
20
- type FirstOf<T, U = boolean> = T[] | [U, ...T[]];
22
+ type FirstOf<T, U = boolean> = T extends U ? [T, ...T[]] : T[] | [U, T, ...T[]];
21
23
  type Bufferable = string | Buffer;
22
24
 
23
25
  type AnyObject = Record<string, unknown>;
24
26
  type PlainObject = Record<string | number | symbol, unknown>;
25
27
 
26
28
  type StandardMap = Record<string, any>;
27
- type StringMap = Record<string, Undef<string>>;
28
- type ObjectMap<T> = Record<string, Undef<T>>;
29
+ type StringMap = Record<string, string | undefined>;
30
+ type ObjectMap<T> = Record<string, T | undefined>;
31
+ type IterableMap<T> = Record<string, T>;
29
32
 
30
33
  type PropertyAction<T, U extends string, V extends boolean = false> = {
31
34
  [K in keyof T as `${U}${V extends true ? string & K : Capitalize<string & K>}`]: T[K];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/types",
3
- "version": "0.10.6",
3
+ "version": "0.10.7",
4
4
  "description": "Type definitions for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,7 +20,8 @@
20
20
  "license": "BSD-3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "bytes": "^3.1.2"
23
+ "bytes": "^3.1.2",
24
+ "chalk": "4.1.2"
24
25
  },
25
26
  "devDependencies": {
26
27
  "typescript": "5.5.4"