@e-mc/types 0.7.1 → 0.8.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/constant.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  export const enum INTERNAL {
2
- VERSION = '0.7.1',
2
+ VERSION = '0.8.1',
3
3
  TEMP_DIR = 'tmp', // eslint-disable-line @typescript-eslint/no-shadow
4
4
  CJS = '__cjs__'
5
5
  }
6
6
 
7
7
  export const enum VAL_MESSAGE {
8
8
  SUCCESS = 'Success',
9
+ COMPLETED = 'Completed',
9
10
  MODIFIED_DIRECTORY = 'Directory was modified',
10
11
  COMMIT_TRANSACTION = 'Transactions were committed'
11
12
  }
@@ -35,6 +36,9 @@ export const enum ERR_MESSAGE {
35
36
  FAIL = 'FAIL!',
36
37
  WARN = 'WARN!',
37
38
  ABORTED = 'Aborted',
39
+ ABORTED_HOST = 'Aborted by host',
40
+ ABORTED_CLIENT = 'Aborted by client',
41
+ ABORTED_PROCESS = 'Aborted by process',
38
42
  ABORTED_OPERATION = 'The operation was aborted',
39
43
  FAILED = 'Failed',
40
44
  FAILED_CHECKSUM = 'Checksum did not match',
@@ -251,6 +255,7 @@ export const enum SETTINGS_KEY_NAME {
251
255
  PERMISSION_HOMEREAD = "permission.home_read",
252
256
  PERMISSION_HOMEWRITE = "permission.home_write",
253
257
  MEMORY_SETTINGS_USERS = "memory.settings.users",
258
+ MEMORY_SETTINGS_CACHE_DISK = "memory.settings.cache_disk",
254
259
  ERROR_OUT = "error.out",
255
260
  ERROR_FATAL = "error.fatal",
256
261
  BROADCAST_OUT = "broadcast.out",
package/index.d.ts CHANGED
@@ -281,11 +281,12 @@ declare namespace types {
281
281
  function cloneObject<T>(data: T, deepIgnore: WeakSet<object>): T;
282
282
  function cloneObject<T, U>(data: T, options?: CloneObjectOptions<U>): T;
283
283
  function coerceObject<T = unknown>(data: T, cache: boolean): T;
284
- function coerceObject<T = unknown>(data: T, parseString?: FunctionArgs<[string], unknown>, cache?: boolean): T;
284
+ function coerceObject<T = unknown>(data: T, parseString?: FunctionArgs<[string]>, cache?: boolean): T;
285
285
  function getEncoding(value: unknown, fallback?: BufferEncoding): BufferEncoding;
286
286
  function encryptUTF8(algorithm: CipherGCMTypes, key: BinaryLike, iv: BinaryLike, data: string, encoding?: Encoding): Undef<string>;
287
287
  function decryptUTF8(algorithm: CipherGCMTypes, key: BinaryLike, iv: BinaryLike, data: string, encoding?: Encoding): Undef<string>;
288
288
  function generateUUID(): string;
289
+ function incrementUUID(restart?: boolean): string;
289
290
  function validateUUID(value: unknown): boolean;
290
291
  function randomString(format: string, dictionary?: string): string;
291
292
  function errorValue(value: string, hint?: string): Error;
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.errorValue = exports.validateUUID = exports.randomString = exports.decryptUTF8 = exports.encryptUTF8 = exports.getEncoding = exports.asFunction = exports.coerceObject = exports.cloneObject = exports.cascadeObject = exports.formatSize = exports.renameExt = exports.escapePattern = exports.hasGlob = exports.convertTime = exports.formatTime = exports.parseExpires = exports.parseTime = exports.isEmpty = exports.isString = exports.isObject = exports.isPlainObject = exports.isArray = exports.setTempDir = exports.getTempDir = exports.setLogCurrent = exports.getLogCurrent = exports.existsFlag = exports.mainFlag = exports.processFlag = exports.modifiedFlag = exports.watchFlag = exports.usingFlag = exports.cloneFlag = exports.ignoreFlag = exports.hasBit = exports.createAbortError = exports.IMPORT_MAP = exports.THRESHOLD = exports.READDIR_SORT = exports.WATCH_EVENT = exports.DB_TRANSACTION = exports.DB_TYPE = exports.FETCH_TYPE = exports.DOWNLOAD_TYPE = exports.ERR_CODE = exports.ASSET_FLAG = exports.FILE_TYPE = exports.STATUS_TYPE = exports.LOG_TYPE = void 0;
4
- exports.generateUUID = exports.purgeMemory = exports.errorMessage = void 0;
4
+ exports.generateUUID = exports.incrementUUID = exports.purgeMemory = exports.errorMessage = void 0;
5
5
  const path = require("path");
6
6
  const fs = require("fs");
7
7
  const crypto = require("crypto");
@@ -20,6 +20,8 @@ const ASYNC_FUNCTION = Object.getPrototypeOf(async () => { }).constructor;
20
20
  let CACHE_COERCED = new WeakSet();
21
21
  let LOG_CURRENT = null;
22
22
  let TEMP_DIR = path.join(process.cwd(), "tmp" /* INTERNAL.TEMP_DIR */);
23
+ let INCREMENT_COUNT = 65536;
24
+ let INCREMENT_PREFIX = '';
23
25
  function fromObject(value, typedArray) {
24
26
  if (isObject(value)) {
25
27
  if (value instanceof Map) {
@@ -402,7 +404,7 @@ function isArray(value) {
402
404
  }
403
405
  exports.isArray = isArray;
404
406
  function isPlainObject(value) {
405
- return value && typeof value === 'object' ? value.constructor === Object || Object.getPrototypeOf(value) === null : false;
407
+ return typeof value === 'object' && value !== null && (value.constructor === Object || Object.getPrototypeOf(value) === null);
406
408
  }
407
409
  exports.isPlainObject = isPlainObject;
408
410
  function isObject(value) {
@@ -549,10 +551,10 @@ function escapePattern(value, lookBehind) {
549
551
  }
550
552
  exports.escapePattern = escapePattern;
551
553
  function renameExt(value, ext, when) {
552
- if (ext[0] !== '.') {
554
+ if (!ext.startsWith('.')) {
553
555
  ext = '.' + ext;
554
556
  }
555
- if (when && when[0] !== '.') {
557
+ if (when && !when.startsWith('.')) {
556
558
  when = '.' + when;
557
559
  }
558
560
  const index = value.lastIndexOf('.');
@@ -574,7 +576,7 @@ function formatSize(value, options) {
574
576
  exports.formatSize = formatSize;
575
577
  function cascadeObject(data, query, fallback) {
576
578
  if (isObject(data) && isString(query)) {
577
- const names = query.trim().split(/(?<!\\)\./).map(item => item.indexOf('.') !== -1 ? item.replace(/\\(?=\.)/g, '') : item);
579
+ const names = query.trim().split(/(?<!\\)\./).map(item => item.includes('.') ? item.replace(/\\(?=\.)/g, '') : item);
578
580
  for (let i = 0, length = names.length, match, current = data; i < length; ++i) {
579
581
  if (!(match = /^(.+?)(?:\[(.+)\])?$/.exec(names[i]))) {
580
582
  break;
@@ -730,7 +732,7 @@ function coerceObject(data, parseString, cache) {
730
732
  default: {
731
733
  const text = match[2].trim();
732
734
  let values = []; // eslint-disable-line @typescript-eslint/no-explicit-any
733
- if (text[0] === '[' && text[text.length - 1] === ']') {
735
+ if (text.startsWith('[') && text.endsWith(']')) {
734
736
  values = JSON.parse(text);
735
737
  }
736
738
  else if (text) {
@@ -855,7 +857,7 @@ function randomString(format, dictionary) {
855
857
  dictionary || (dictionary = '0123456789abcdef');
856
858
  const result = format.match(/(\d+|[^\d[]+|\[[^\]]+\]|\[)/g).reduce((a, b) => {
857
859
  let length, available;
858
- if (b[0] === '[' && b[b.length - 1] === ']') {
860
+ if (b.startsWith('[') && b.endsWith(']')) {
859
861
  length = 1;
860
862
  available = b.substring(1, b.length - 1);
861
863
  }
@@ -907,4 +909,12 @@ function purgeMemory(percent) {
907
909
  CACHE_COERCED = new WeakSet();
908
910
  }
909
911
  exports.purgeMemory = purgeMemory;
912
+ function incrementUUID(restart) {
913
+ if (restart || INCREMENT_COUNT === 65536) {
914
+ INCREMENT_COUNT = 0;
915
+ INCREMENT_PREFIX = (0, exports.generateUUID)().substring(0, 33);
916
+ }
917
+ return INCREMENT_PREFIX + (INCREMENT_COUNT++).toString(16).padStart(4, '0');
918
+ }
919
+ exports.incrementUUID = incrementUUID;
910
920
  exports.generateUUID = typeof crypto.randomUUID === 'function' ? crypto.randomUUID.bind(crypto) : uuid.v4;
package/lib/asset.d.ts CHANGED
@@ -14,6 +14,10 @@ export interface BinaryAction {
14
14
  binOpts?: string[];
15
15
  }
16
16
 
17
+ export interface StreamAction {
18
+ minStreamSize?: NumString;
19
+ }
20
+
17
21
  export interface FileData<T extends ExternalAsset> extends MimeTypeAction {
18
22
  file: T;
19
23
  }
@@ -50,7 +54,7 @@ export interface InitialValue extends Partial<LocationUri>, MimeTypeAction {
50
54
  cacheable?: boolean;
51
55
  }
52
56
 
53
- export interface ExternalAsset extends FileAsset, BundleAction, BinaryAction {
57
+ export interface ExternalAsset extends FileAsset, BundleAction, BinaryAction, StreamAction {
54
58
  id?: number;
55
59
  url?: URL;
56
60
  socketPath?: string;
package/lib/cloud.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { DbDataSource, LocationUri, StorageAction } from './squared';
2
2
 
3
- import type { ExternalAsset } from './asset';
3
+ import type { ExternalAsset, StreamAction } from './asset';
4
4
 
5
5
  export interface UploadAction {
6
6
  cloudUrl?: string;
@@ -37,7 +37,7 @@ export interface CloudStorageAdmin<T = unknown, U = string, V = unknown, W = unk
37
37
  preservePath?: boolean;
38
38
  }
39
39
 
40
- export interface CloudStorageAction<T = unknown, U = string, V = unknown, W = unknown> extends Partial<LocationUri> {
40
+ export interface CloudStorageAction<T = unknown, U = string, V = unknown, W = unknown> extends Partial<LocationUri>, StreamAction {
41
41
  active?: boolean;
42
42
  overwrite?: boolean;
43
43
  admin?: CloudStorageAdmin<T, U, V, W>;
@@ -49,7 +49,7 @@ export interface CloudStorageUpload<T = unknown, U = string, V = unknown, W = st
49
49
  metadata?: Record<string, string>;
50
50
  tags?: Record<string, string> | false;
51
51
  options?: T;
52
- fileGroup?: [BufferContent, string, string?][];
52
+ fileGroup?: UploadContent[];
53
53
  localStorage?: boolean;
54
54
  endpoint?: string;
55
55
  all?: boolean;
@@ -87,5 +87,6 @@ export interface BucketAction {
87
87
  bucket: string;
88
88
  }
89
89
 
90
+ export type UploadContent = [BufferContent, string, string?];
90
91
  export type CloudFeatures = "storage" | "database";
91
92
  export type CloudFunctions = "upload" | "download";
package/lib/core.d.ts CHANGED
@@ -6,7 +6,7 @@ import type { IExternalConfig, IExternalFunction, IHost, IModule, ModuleConstruc
6
6
  import type { QueryResult, TimeoutAction } from './db';
7
7
  import type { AddEventListenerOptions } from './dom';
8
8
  import type { Settings } from './node';
9
- import type { ClientDBSettings, ClientModule, DbCacheValue, DbCoerceSettings, DbCoerceValue, DbSourceOptions } from './settings';
9
+ import type { ClientDbSettings, ClientModule, DbCacheValue, DbCoerceSettings, DbCoerceValue, DbSourceOptions } from './settings';
10
10
 
11
11
  export interface IdentifierAction {
12
12
  uuidKey?: string;
@@ -14,6 +14,7 @@ export interface IdentifierAction {
14
14
 
15
15
  export interface IClient<T extends IHost, U extends ClientModule, V extends FunctionType = FunctionType> extends IModule<T>, IExternalConfig<U, U extends ClientModule<infer W> ? W : unknown>, IExternalFunction<V> {
16
16
  init(...args: unknown[]): this;
17
+ getUserSettings<X>(): Null<X>;
17
18
  set cacheDir(value: string);
18
19
  get cacheDir(): string;
19
20
  }
@@ -23,7 +24,7 @@ export interface ClientConstructor<T extends IHost = IHost, U extends ClientModu
23
24
  new(module?: U): IClient<T, U>;
24
25
  }
25
26
 
26
- export interface IClientDb<T extends IHost, U extends ClientModule<ClientDBSettings>, V extends DataSource = DataSource, W extends DbSourceOptions = DbSourceOptions, X extends DbCoerceSettings = DbCoerceSettings> extends IClient<T, U> {
27
+ export interface IClientDb<T extends IHost, U extends ClientModule<ClientDbSettings>, V extends DataSource = DataSource, W extends DbSourceOptions = DbSourceOptions, X extends DbCoerceSettings = DbCoerceSettings> extends IClient<T, U> {
27
28
  database: V[];
28
29
  cacheExpires: number;
29
30
  add(item: V, state?: number): void;
@@ -151,6 +152,7 @@ export interface StoreResultOptions {
151
152
  export interface CacheOptions {
152
153
  value?: DbCacheValue;
153
154
  renewCache?: boolean;
155
+ exclusiveOf?: [number, number?, number?];
154
156
  sessionKey?: string;
155
157
  }
156
158
 
package/lib/document.d.ts CHANGED
@@ -148,6 +148,11 @@ export interface SourceMapConstructor {
148
148
  new(code: string, uri?: string, remove?: boolean): SourceMap;
149
149
  }
150
150
 
151
+ export interface ImportMap {
152
+ imports?: StringMap;
153
+ scopes?: ObjectMap<StringMap>;
154
+ }
155
+
151
156
  export interface UpdateGradleOptions {
152
157
  multiple?: boolean;
153
158
  addendum?: string;
package/lib/index.d.ts CHANGED
@@ -15,9 +15,9 @@ import type { AssetContentOptions, ChecksumOptions, DeleteFileAddendum, FileOutp
15
15
  import type { HttpAgentSettings, HttpProtocolVersion, HttpRequestClient, InternetProtocolVersion } from './http';
16
16
  import type { CommandData, CropData, QualityData, ResizeData, RotateData, TransformOptions } from './image';
17
17
  import type { ExecCommand, LOG_TYPE, LogArguments, LogComponent, LogDate, LogFailOptions, LogMessageOptions, LogOptions, LogProcessOptions, LogTime, LogType, LogValue, STATUS_TYPE, StatusType } from './logger';
18
- import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, GetTempDirOptions, MoveFileOptions, NormalizeFlags, ParseFunctionOptions, PermissionOptions, ProtocolType, ReadFileCallback, ReadFileOptions, ReadHashOptions, RemoveDirOptions, WriteFileOptions } from './module';
18
+ import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, GetTempDirOptions, MoveFileOptions, NormalizeFlags, ParseFunctionOptions, PermissionOptions, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, WriteFileOptions } from './module';
19
19
  import type { RequestData, Settings } from './node';
20
- import type { ApplyOptions, Aria2Options, BufferFormat, DataEncodedResult, DataObjectResult, FormDataPart, HostConfig, OpenOptions, PostOptions, ProxySettings, ReadExpectType, RequestInit } from './request';
20
+ import type { ApplyOptions, Aria2Options, BufferFormat, DataEncodedResult, DataObjectResult, FormDataPart, HeadersOnCallback, HostConfig, OpenOptions, PostOptions, ProxySettings, ReadExpectType, RequestInit } from './request';
21
21
  import type { ClientModule, CloudModule, CloudServiceOptions, CompressModule, CompressSettings, DbCoerceSettings, DbModule, DbSourceOptions, DnsLookupSettings, DocumentComponent, DocumentComponentOption, DocumentModule, HttpConnectSettings, HttpMemorySettings, ImageModule, RequestModule, RequestSettings, TaskModule, WatchModule } from './settings';
22
22
  import type { Command, SpawnResult } from './task';
23
23
  import type { IFileGroup, ModifiedPostFinalizeListener, SecureOptions, WatchInitResult } from './watch';
@@ -83,7 +83,7 @@ declare namespace functions {
83
83
  new(module?: U): ICompress<T, U>;
84
84
  }
85
85
 
86
- interface IImage<T extends IHost = IHost, U extends ImageModule = ImageModule> extends IClient<T, U, FunctionType> {
86
+ interface IImage<T extends IHost = IHost, U extends ImageModule = ImageModule> extends IClient<T, U> {
87
87
  resizeData?: ResizeData;
88
88
  cropData?: CropData;
89
89
  rotateData?: RotateData;
@@ -135,6 +135,7 @@ declare namespace functions {
135
135
  setCredential(item: V): Promise<void>;
136
136
  getCredential<Y = PlainObject>(item: V): Undef<Y>;
137
137
  hasSource(source: string, ...type: number[]): boolean;
138
+ applyCommand(...items: V[]): void;
138
139
  executeQuery(item: V, sessionKey: string): Promise<QueryResult>;
139
140
  executeQuery(item: V, options?: ExecuteQueryOptions | string): Promise<QueryResult>;
140
141
  executeBatchQuery(batch: V[], sessionKey: string, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
@@ -212,6 +213,7 @@ declare namespace functions {
212
213
  loadConfig(data: object, name: string): Optional<ConfigOrTransformer>;
213
214
  asSourceFile(value: string, options?: AsSourceFileOptions | boolean): unknown;
214
215
  findVersion(name: StringOfArray, fallback?: string): string;
216
+ findSourceScope(uri: string, imports: AnyObject): StringMap[];
215
217
  findSourceRoot(uri: string, imports?: StringMap): Undef<string>;
216
218
  resolveDir(name: string, ...paths: string[]): Undef<string>;
217
219
  locateSourceFiles(file: U, code?: string, bundleContent?: string[]): (imports?: StringMap) => Undef<SourceInput>;
@@ -222,7 +224,7 @@ declare namespace functions {
222
224
  settingsOf(name: keyof W, option: keyof X): unknown;
223
225
  parseTemplate(viewEngine: ViewEngine | string, template: string, data: unknown[]): Promise<Null<string>>;
224
226
  transform(type: string, code: string, format: StringOfArray, options?: TransformOutput & TransformAction): Promise<Void<TransformResult>>;
225
- abort(name?: keyof W): void;
227
+ abort(name?: keyof W | Error, reason?: unknown): void;
226
228
  restart(): void;
227
229
  using?(data: IFileThread<U>): Promise<unknown>;
228
230
  setLocalUri?(file: U, replace?: boolean): void;
@@ -303,6 +305,8 @@ declare namespace functions {
303
305
  addDns(hostname: string, address: string, family?: NumString): void;
304
306
  lookupDns(hostname: string): LookupFunction;
305
307
  proxyOf(uri: string, localhost?: boolean): Undef<ProxySettings>;
308
+ headersOn(name: ArrayOf<string>, callback: HeadersOnCallback): void;
309
+ headersOn(name: ArrayOf<string>, patternUrl: string, callback: HeadersOnCallback): void;
306
310
  headersOf(uri: string): Undef<OutgoingHttpHeaders>;
307
311
  aria2c(uri: string | URL, pathname: string): Promise<string[]>;
308
312
  aria2c(uri: string | URL, options?: Aria2Options): Promise<string[]>;
@@ -408,7 +412,7 @@ declare namespace functions {
408
412
  addCopy(data: FileCommand<T>, saveAs?: string, replace?: boolean): Undef<string>;
409
413
  findMime(file: T, rename?: boolean): Promise<string>;
410
414
  getUTF8String(file: T, uri?: string): string;
411
- getBuffer(file: T): Null<Buffer>;
415
+ getBuffer<U>(file: T, minStreamSize?: U): U extends number ? Promise<Buffer> : Null<Buffer>;
412
416
  getCacheDir(url: string | URL, createDir?: boolean): string;
413
417
  setAssetContent(file: T, content: string, options?: AssetContentOptions): string;
414
418
  getAssetContent(file: T, content?: string): Undef<string>;
@@ -558,7 +562,7 @@ declare namespace functions {
558
562
  canRead(uri: string, options?: PermissionOptions): boolean;
559
563
  canWrite(uri: string, options?: PermissionOptions): boolean;
560
564
  readFile(src: string): Undef<Buffer>;
561
- readFile<U extends ReadFileOptions>(src: string, options?: U): Undef<U extends { encoding: string } ? string : BufferContent>;
565
+ readFile<U extends ReadFileOptions>(src: string, options?: U): Undef<U extends { encoding: string } ? U extends { minStreamSize: NumString } ? Promise<string> : string : U extends { minStreamSize: NumString } ? Promise<Buffer> : Buffer>;
562
566
  readFile<U extends Buffer>(src: string, promises: true): Promise<Undef<U>>;
563
567
  readFile<U extends BufferContent>(src: string, options: ReadFileOptions, promises: true): Promise<Undef<U>>;
564
568
  readFile<U extends ReadFileCallback<V>, V extends Buffer>(src: string, callback: U): Undef<U extends ReadFileCallback<infer W> ? W : V>;
@@ -712,8 +716,13 @@ declare namespace functions {
712
716
  copyDir(src: string | URL, dest: string | URL, options: CopyDirOptions): Promise<CopyDirResult>;
713
717
  copyDir(src: string | URL, dest: string | URL, move?: boolean, recursive?: boolean): Promise<CopyDirResult>;
714
718
  renameFile(src: string | URL, dest: string | URL, throws?: boolean): boolean;
719
+ streamFile<U extends BufferContent>(src: string, cache: boolean): Promise<U>;
720
+ streamFile<U extends BufferContent>(src: string, options: U): Promise<U extends { encoding: string } ? string : Buffer>;
721
+ streamFile<U extends BufferContent>(src: string, cache?: boolean | U, options?: U): Promise<U extends { encoding: string } ? string : Buffer>;
715
722
  readText(value: string | URL, cache: boolean): string;
716
- readText(value: string | URL, encoding?: BufferEncoding | boolean, cache?: boolean): string;
723
+ readText<U extends ReadTextOptions>(value: string | URL, options: U): U extends { minStreamSize: NumString } ? Promise<string> : string;
724
+ readText(value: string | URL, encoding?: BufferEncoding | boolean | ReadTextOptions, cache?: boolean): string;
725
+ readBuffer<U extends ReadBufferOptions>(value: string | URL, options: U): U extends { minStreamSize: NumString } ? Promise<Null<Buffer>> : Null<Buffer>;
717
726
  readBuffer(value: string | URL, cache?: boolean): Null<Buffer>;
718
727
  resolveMime(data: string | Buffer | Uint8Array | ArrayBuffer): Promise<Undef<FileTypeResult>>;
719
728
  lookupMime(value: string, extension?: boolean): string;
package/lib/module.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type { ChecksumBase } from './squared';
2
2
 
3
+ import type { StreamAction } from './asset';
4
+
3
5
  import type { HashOptions } from 'crypto';
4
6
 
5
7
  declare enum NORMALIZE_FLAGS {
@@ -25,7 +27,7 @@ export interface FileSystemOptions extends PermissionOptions {
25
27
  throwsDoesNotExist?: boolean;
26
28
  }
27
29
 
28
- export interface ReadFileOptions extends FileSystemOptions, RequireAction {
30
+ export interface ReadFileOptions extends FileSystemOptions, StreamBase, RequireAction {
29
31
  cache?: boolean;
30
32
  encoding?: BufferEncoding;
31
33
  }
@@ -97,9 +99,17 @@ export interface CopyDirResult {
97
99
  ignored: string[];
98
100
  }
99
101
 
100
- export interface ReadHashOptions extends ChecksumBase {
102
+ export interface StreamBase extends StreamAction {
103
+ signal?: AbortSignal;
104
+ }
105
+
106
+ export interface ReadHashOptions extends ChecksumBase, StreamBase {
101
107
  chunkSize?: number;
102
- minStreamSize?: number;
108
+ }
109
+
110
+ export interface ReadBufferOptions extends StreamBase {
111
+ encoding?: BufferEncoding;
112
+ cache?: boolean;
103
113
  }
104
114
 
105
115
  export interface AsHashOptions extends HashOptions, ChecksumBase {
@@ -116,5 +126,6 @@ export interface GetTempDirOptions {
116
126
  }
117
127
 
118
128
  export type NormalizeFlags = typeof NORMALIZE_FLAGS[keyof typeof NORMALIZE_FLAGS];
129
+ export type ReadTextOptions = ReadBufferOptions;
119
130
  export type ReadFileCallback<T> = (err: Null<NodeJS.ErrnoException>, data?: T) => void;
120
131
  export type ProtocolType = "http" | "https" | "http/s" | "ftp" | "sftp" | "s/ftp" | "torrent" | "unc";
package/lib/request.d.ts CHANGED
@@ -127,4 +127,5 @@ export interface ApplyOptions extends ProtocolAction, PlainObject {
127
127
  export type BufferFormat = "json" | "yaml" | "json5" | "xml" | "toml";
128
128
  export type ReadExpectType = "always" | "string" | "none";
129
129
  export type DataEncodedResult<T extends { encoding?: BufferEncoding }> = T extends { encoding: BufferEncoding } ? string : Null<BufferContent>;
130
- export type DataObjectResult<T extends { format?: unknown; encoding?: BufferEncoding }> = T extends { format: string | PlainObject } ? Null<object> : DataEncodedResult<T>;
130
+ export type DataObjectResult<T extends { format?: unknown; encoding?: BufferEncoding }> = T extends { format: string | PlainObject } ? Null<object> : DataEncodedResult<T>;
131
+ export type HeadersOnCallback = (value: IncomingHttpHeaders, url?: URL) => Void<boolean>;
package/lib/settings.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { WatchInterval } from './squared';
2
+
1
3
  import type { PermissionAction, PermissionReadWrite, PermittedDirectories } from './core';
2
4
  import type { DbSource, PoolConfig, TimeoutAction } from './db';
3
5
  import type { HttpOutgoingHeaders } from './http';
@@ -29,7 +31,8 @@ export interface HandlerSettings<T = PlainObject> {
29
31
 
30
32
  export interface ClientModule<T = ClientSettings> extends HandlerModule<T>, PermissionAction {}
31
33
 
32
- export interface ClientSettings extends PlainObject {
34
+ export interface ClientSettings<T = PlainObject> extends PlainObject {
35
+ users?: ObjectMap<T>;
33
36
  cache_dir?: string;
34
37
  }
35
38
 
@@ -105,12 +108,12 @@ export interface DownloadModule<T = PlainObject> extends HandlerSettings<T> {
105
108
  };
106
109
  }
107
110
 
108
- export interface DocumentModule<T = DbSettings> extends ClientModule<DocumentSettings> {
111
+ export interface DocumentModule<T = DocumentSettings, U = DbSettings> extends ClientModule<T> {
109
112
  eval?: DocumentEval;
110
113
  imports?: StringMap;
111
114
  versions?: StringMap;
112
115
  format?: AnyObject;
113
- db?: DbModule<T>;
116
+ db?: DbModule<U>;
114
117
  }
115
118
 
116
119
  export interface DocumentEval {
@@ -125,8 +128,9 @@ export interface DocumentGroup<T = { imports?: StringMap } & AnyObject, U = T> {
125
128
  imports?: StringMap;
126
129
  }
127
130
 
128
- export interface DocumentUsersGroup<T = AnyObject, U = T> extends DocumentGroup<T, U> {
131
+ export interface DocumentUserSettings<T = AnyObject, U = T> extends DocumentGroup<T, U>, PlainObject {
129
132
  extensions?: Null<string[]>;
133
+ imports_strict?: boolean;
130
134
  }
131
135
 
132
136
  export interface DocumentComponent<T = boolean, U = T, V = U> extends Omit<DocumentGroup<T, U>, "pages"> {
@@ -140,8 +144,8 @@ export interface DocumentComponentOption<T = unknown> {
140
144
  local_file?: NumString;
141
145
  }
142
146
 
143
- export interface DocumentSettings extends DocumentGroup, PurgeAction, PlainObject {
144
- users?: ObjectMap<DocumentUsersGroup>;
147
+ export interface DocumentSettings extends DocumentGroup, PurgeAction, ClientSettings<DocumentUserSettings>, PlainObject {
148
+ imports_strict?: boolean;
145
149
  directory?: DocumentDirectory;
146
150
  options?: DocumentComponentOptions;
147
151
  }
@@ -152,7 +156,7 @@ export interface DocumentDirectory extends StringMap {
152
156
 
153
157
  export type DocumentComponentOptions = DocumentComponent<DocumentComponentOption<DocumentTransform>, DocumentComponentOption<boolean>>;
154
158
 
155
- export interface ClientDBSettings extends ClientSettings, PurgeAction {
159
+ export interface ClientDbSettings<T = PlainObject> extends ClientSettings<T>, PurgeAction {
156
160
  session_expires?: number;
157
161
  user_key?: ObjectMap<DbSourceOptions>;
158
162
  imports?: StringMap;
@@ -162,11 +166,21 @@ export interface MemoryModule<T = MemorySettings> extends HandlerSettings<T>, Re
162
166
 
163
167
  export interface MemorySettings extends PlainObject {
164
168
  users?: boolean | string[];
169
+ cache_disk?: MemoryCacheDiskSettings;
170
+ }
171
+
172
+ export interface MemoryCacheDiskSettings<T = NumString> extends IncludeAction<Null<string[]>> {
173
+ enabled?: boolean;
174
+ min_size?: T;
175
+ max_size?: T;
176
+ expires?: T;
165
177
  }
166
178
 
167
179
  export interface DbModule<T = DbSettings> extends ClientModule<T>, DbSourceDataType<ObjectMap<StringMap>>, PlainObject {}
168
180
 
169
- export interface DbSettings extends ClientDBSettings, DbSourceDataType<DbSourceOptions> {}
181
+ export interface DbSettings<T = DbUserSettings> extends ClientDbSettings<T>, DbSourceDataType<DbSourceOptions> {}
182
+
183
+ export interface DbUserSettings extends DbSourceDataType<{ commands?: ObjectMap<ObjectMap<PlainObject>> }>, PlainObject {}
170
184
 
171
185
  export interface DbCacheSettings extends TimeoutAction {
172
186
  dir?: string;
@@ -227,11 +241,9 @@ export interface RequestModule<T = RequestSettings> extends HandlerSettings<T> {
227
241
  http_version?: NumString;
228
242
  accept_encoding?: boolean;
229
243
  };
230
- proxy?: AuthValue & {
244
+ proxy?: AuthValue & IncludeAction & {
231
245
  address?: string;
232
246
  port?: NumString;
233
- include?: string[];
234
- exclude?: string[];
235
247
  keep_alive?: boolean;
236
248
  };
237
249
  headers?: HttpOutgoingHeaders;
@@ -254,9 +266,7 @@ export interface WatchModule<T = WatchSettings> extends HandlerModule<T>, Server
254
266
  interval?: NumString;
255
267
  }
256
268
 
257
- export interface WatchSettings<T = PlainObject> extends PlainObject {
258
- users?: ObjectMap<ObjectMap<T>>;
259
- }
269
+ export interface WatchSettings<T = WatchUserSettings> extends ClientSettings<ObjectMap<T>>, PlainObject {}
260
270
 
261
271
  export interface CompressModule<U = CompressSettings> extends HandlerSettings<U> {
262
272
  gzip?: ZlibOptions;
@@ -283,7 +293,7 @@ export interface CloudModule<T = CloudSettings> extends ClientModule<T>, CloudSe
283
293
  apiVersion?: string;
284
294
  }
285
295
 
286
- export interface CloudSettings extends ClientDBSettings, CloudServiceDataType<CloudServiceOptions> {}
296
+ export interface CloudSettings extends ClientDbSettings, CloudServiceDataType<CloudServiceOptions> {}
287
297
 
288
298
  export interface CloudServiceDataType<T = unknown> {
289
299
  atlas?: T;
@@ -319,6 +329,7 @@ export interface LoggerModule<T = NumString, U = boolean | T, V = LoggerFormat<T
319
329
  session_id?: U;
320
330
  message?: boolean;
321
331
  stack_trace?: boolean | T;
332
+ abort?: boolean;
322
333
  stdout?: boolean;
323
334
  unknown?: boolean | LoggerColor;
324
335
  system?: boolean | LoggerColor;
@@ -359,12 +370,10 @@ export interface HttpSettings {
359
370
  certs?: ObjectMap<SecureConfig<StringOfArray>>;
360
371
  }
361
372
 
362
- export interface HttpDiskSettings {
373
+ export interface HttpDiskSettings extends IncludeAction {
363
374
  enabled?: boolean;
364
375
  limit?: NumString;
365
376
  expires?: NumString;
366
- include?: string[];
367
- exclude?: string[];
368
377
  }
369
378
 
370
379
  export interface HttpMemorySettings extends HttpDiskSettings {
@@ -387,15 +396,13 @@ export interface DnsLookupSettings {
387
396
  resolve?: ObjectMap<Partial<LookupAddress>>;
388
397
  }
389
398
 
390
- export interface HashConfig {
399
+ export interface HashConfig extends IncludeAction<ObjectMap<string[] | "*">> {
391
400
  enabled?: boolean;
392
401
  algorithm?: HashAlgorithm;
393
402
  etag?: boolean;
394
403
  expires?: NumString;
395
404
  renew?: boolean;
396
405
  limit?: NumString;
397
- exclude?: ObjectMap<string[] | "*">;
398
- include?: ObjectMap<string[] | "*">;
399
406
  }
400
407
 
401
408
  export interface SecureConfig<T = string, U = T> {
@@ -435,6 +442,11 @@ export interface PurgeAction {
435
442
  purge?: PurgeComponent;
436
443
  }
437
444
 
445
+ export interface IncludeAction<T = string[]> {
446
+ include?: T;
447
+ exclude?: T;
448
+ }
449
+
438
450
  export interface CipherConfig {
439
451
  algorithm?: CipherGCMTypes;
440
452
  key?: BinaryLike;
@@ -445,6 +457,7 @@ export type DbSourceDataType<T = unknown> = {
445
457
  [K in DbSource]?: T;
446
458
  };
447
459
 
460
+ export type WatchUserSettings = ObjectMap<WatchInterval>;
448
461
  export type DocumentTransform = Null<boolean | "etag" | HashAlgorithm | HashConfig>;
449
462
  export type HashAlgorithm = "md5" | "sha1" | "sha256" | "sha224" | "sha384" | "sha512";
450
463
 
package/lib/squared.d.ts CHANGED
@@ -53,7 +53,7 @@ export interface DataSource<T = unknown> extends DocumentAction {
53
53
  preRender?: string | FunctionType;
54
54
  whenEmpty?: string | FunctionType;
55
55
  removeEmpty?: boolean;
56
- ignoreCache?: boolean | 0 | 1;
56
+ ignoreCache?: boolean | 0 | 1 | [number, number?, number?];
57
57
  transactionState?: number;
58
58
  transactionFail?: boolean;
59
59
  }
@@ -64,6 +64,7 @@ export interface DbDataSource<T = unknown, U = unknown, V = unknown, W = unknown
64
64
  credential?: W;
65
65
  options?: U;
66
66
  update?: V;
67
+ withCommand?: string | [string, string];
67
68
  parallel?: boolean;
68
69
  willAbort?: boolean;
69
70
  streamRow?: Null<boolean | string | ((row: unknown) => Undef<Error | false>)>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/types",
3
- "version": "0.7.1",
3
+ "version": "0.8.1",
4
4
  "description": "Type definitions for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",