@e-mc/types 0.8.1 → 0.8.3

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,5 +1,7 @@
1
1
  ### @e-mc/types
2
2
 
3
+ https://e-mc.readthedocs.io
4
+
3
5
  ### LICENSE
4
6
 
5
7
  BSD 3-Clause
package/constant.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export const enum INTERNAL {
2
- VERSION = '0.8.1',
2
+ VERSION = '0.8.3',
3
3
  TEMP_DIR = 'tmp', // eslint-disable-line @typescript-eslint/no-shadow
4
4
  CJS = '__cjs__'
5
5
  }
@@ -7,6 +7,7 @@ export const enum INTERNAL {
7
7
  export const enum VAL_MESSAGE {
8
8
  SUCCESS = 'Success',
9
9
  COMPLETED = 'Completed',
10
+ CHECKSUM = 'Checksum matched',
10
11
  MODIFIED_DIRECTORY = 'Directory was modified',
11
12
  COMMIT_TRANSACTION = 'Transactions were committed'
12
13
  }
@@ -28,6 +29,7 @@ export const enum VAL_CLOUD {
28
29
  EMPTY_BUCKET = 'Bucket emptied',
29
30
  CONFIGURE_BUCKET = 'Bucket configured',
30
31
  POLICY_BUCKET = 'Bucket policy configured',
32
+ WEBSITE_BUCKET = 'Bucket website configured',
31
33
  ACL_BUCKET = 'Bucket ACL configured'
32
34
  }
33
35
 
@@ -57,6 +59,7 @@ export const enum ERR_MESSAGE {
57
59
  TIMEOUT = 'Timeout was exceeded',
58
60
  HANDLED_REJECTION = 'Handled rejection',
59
61
  UNSUPPORTED_ACCESS = 'Unsupported access',
62
+ UNSUPPORTED_MIME = 'Unsupported MIME',
60
63
  UNSUPPORTED_READ = 'Not permitted to read file',
61
64
  UNSUPPORTED_WRITE = 'Not permitted to write file',
62
65
  NOTFOUND_FILE = 'File not found',
@@ -123,8 +126,11 @@ export const enum ERR_CLOUD {
123
126
  CONSTRUCTOR = 'Not a Cloud constructor',
124
127
  CREATE_BUCKET = 'Unable to create bucket',
125
128
  POLICY_BUCKET = 'Unable to update bucket policy',
129
+ TAGGING_BUCKET = 'Unable to update bucket tagging',
130
+ WEBSITE_BUCKET = 'Unable to set bucket website',
126
131
  DELETE_BUCKET = 'Unable to empty bucket',
127
132
  CONFIGURE_BUCKET = 'Unable to configure bucket',
133
+ CREATE_TAG = 'Unable to create tags',
128
134
  EXISTS_BUCKET = 'Bucket does not exist',
129
135
  POLICY_INVALID = 'Invalid bucket policy',
130
136
  LIST_BUCKET = 'Unable to list bucket',
@@ -135,6 +141,7 @@ export const enum ERR_CLOUD {
135
141
  MODULE_NOTFOUND = 'Cloud module not installed',
136
142
  CREATE_BUCKET_SUPPORT = 'Create bucket not supported',
137
143
  BUCKET_POLICY_SUPPORT = 'Bucket policy not supported',
144
+ BUCKET_TAGGING_SUPPORT = 'Bucket tagging not supported',
138
145
  DELETE_OBJECTS_SUPPORT = 'Delete objects not supported',
139
146
  BUCKET_WEBSITE_SUPPORT = 'Set bucket website not supported',
140
147
  EXECUTE_QUERY_SUPPORT = 'Execute query not supported',
@@ -153,6 +160,10 @@ export const enum ERR_IMAGE {
153
160
  METHOD_ARGS = 'Invalid method arguments'
154
161
  }
155
162
 
163
+ export const enum ERR_HTTP {
164
+ HEADERS = 'Unable to process headers'
165
+ }
166
+
156
167
  export const enum DB_TRANSACTION {
157
168
  ACTIVE = 1,
158
169
  PARTIAL = 2,
package/index.js CHANGED
@@ -5,7 +5,6 @@ exports.generateUUID = exports.incrementUUID = exports.purgeMemory = exports.err
5
5
  const path = require("path");
6
6
  const fs = require("fs");
7
7
  const crypto = require("crypto");
8
- const uuid = require("uuid");
9
8
  const bytes = require("bytes");
10
9
  class AbortError extends Error {
11
10
  constructor() {
@@ -15,7 +14,8 @@ class AbortError extends Error {
15
14
  }
16
15
  }
17
16
  const REGEXP_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
18
- const REGEXP_FUNCTION = /^(async\s+)?(function(?:\b|\s+)([\w_$]*)\s*\(([^)]*)\)\s*\{([\S\s]*)\})$/;
17
+ const REGEXP_FUNCTION = /^(async\s+)?(function(?:\b|\s+)[\w_$]*\s*\(([^)]*)\)\s*\{([\S\s]*)\})$/;
18
+ const REGEXP_FUNCTION_ARROW = /^(async\s+)?(\s*\(([^)]*)\)\s*=>\s*(?:\{([\S\s]*)\}|(?!\s|{)((?:(?<!return\s+)(?:"[^"\n]*"|'[^'\n]*'|`[^`]*`|[^\n;"'`]))*;)))$/;
19
19
  const ASYNC_FUNCTION = Object.getPrototypeOf(async () => { }).constructor;
20
20
  let CACHE_COERCED = new WeakSet();
21
21
  let LOG_CURRENT = null;
@@ -322,8 +322,8 @@ var IMPORT_MAP;
322
322
  IMPORT_MAP["@squared-functions/document/packages/@babel/core"] = "@pi-r/babel";
323
323
  IMPORT_MAP["@squared-functions/document/packages/clean-css"] = "@pi-r/clean-css";
324
324
  IMPORT_MAP["@squared-functions/document/packages/eslint"] = "@pi-r/eslint";
325
- IMPORT_MAP["@squared-functions/document/packages/html-minifier-terser"] = "@pi-r/html-minifier-terser";
326
325
  IMPORT_MAP["@squared-functions/document/packages/html-minifier"] = "@pi-r/html-minifier";
326
+ IMPORT_MAP["@squared-functions/document/packages/html-minifier-terser"] = "@pi-r/html-minifier-terser";
327
327
  IMPORT_MAP["@squared-functions/document/packages/html-validate"] = "@pi-r/html-validate";
328
328
  IMPORT_MAP["@squared-functions/document/packages/postcss"] = "@pi-r/postcss";
329
329
  IMPORT_MAP["@squared-functions/document/packages/posthtml"] = "@pi-r/posthtml";
@@ -805,10 +805,10 @@ function asFunction(value, sync = true) {
805
805
  return value;
806
806
  }
807
807
  let match;
808
- if (isString(value) && (match = REGEXP_FUNCTION.exec(value = value.trim()))) {
808
+ if (isString(value) && (match = REGEXP_FUNCTION.exec(value = value.trim()) || REGEXP_FUNCTION_ARROW.exec(value))) {
809
809
  if (!sync || match[1]) {
810
- const args = match[4].trim().split(/\s*,\s*/);
811
- args.push(match[5]);
810
+ const args = match[3].trim().split(/\s*,\s*/);
811
+ args.push(match[4] || (match[5] && (match[5] = 'return ' + match[5])));
812
812
  return new ASYNC_FUNCTION(...args);
813
813
  }
814
814
  try {
@@ -824,7 +824,22 @@ function asFunction(value, sync = true) {
824
824
  }
825
825
  exports.asFunction = asFunction;
826
826
  function getEncoding(value, fallback = 'utf-8') {
827
- return typeof value === 'string' && Buffer.isEncoding(value = value.trim().toLowerCase()) ? value : fallback;
827
+ if (typeof value === 'string') {
828
+ switch (value = value.trim().toLowerCase()) {
829
+ case 'utf8':
830
+ case 'utf-8':
831
+ case 'utf16le':
832
+ return value;
833
+ case 'utf-16le':
834
+ case 'utf16':
835
+ case 'utf-16':
836
+ return 'utf16le';
837
+ }
838
+ if (Buffer.isEncoding(value)) {
839
+ return value;
840
+ }
841
+ }
842
+ return fallback;
828
843
  }
829
844
  exports.getEncoding = getEncoding;
830
845
  function encryptUTF8(algorithm, key, iv, data, encoding = 'hex') {
@@ -917,4 +932,4 @@ function incrementUUID(restart) {
917
932
  return INCREMENT_PREFIX + (INCREMENT_COUNT++).toString(16).padStart(4, '0');
918
933
  }
919
934
  exports.incrementUUID = incrementUUID;
920
- exports.generateUUID = typeof crypto.randomUUID === 'function' ? crypto.randomUUID.bind(crypto) : uuid.v4;
935
+ exports.generateUUID = typeof crypto.randomUUID === 'function' ? crypto.randomUUID.bind(crypto) : require('uuid').v4;
@@ -19,6 +19,13 @@ export const enum FINALIZE_STATE {
19
19
  ABORTED = 6
20
20
  }
21
21
 
22
+ export const enum INCREMENTAL {
23
+ NONE = 'none',
24
+ STAGING = 'staging',
25
+ ETAG = 'etag',
26
+ EXISTS = 'exists'
27
+ }
28
+
22
29
  export interface RequestData<T extends ExternalAsset = ExternalAsset> extends IRequestData<T>, RequestInit {
23
30
  timeout?: ObjectMap<NumString>;
24
31
  }
package/lib/http.d.ts CHANGED
@@ -45,6 +45,7 @@ export const enum HTTP_STATUS {
45
45
  UNPROCESSABLE_ENTITY = 422,
46
46
  LOCKED = 423,
47
47
  FAILED_DEPENDENCY = 424,
48
+ TOO_EARLY = 425,
48
49
  UPGRADE_REQUIRED = 426,
49
50
  PRECONDITION_REQUIRED = 428,
50
51
  TOO_MANY_REQUESTS = 429,
@@ -62,6 +63,7 @@ export const enum HTTP_STATUS {
62
63
  VARIANT_ALSO_NEGOTIATES = 506,
63
64
  INSUFFICIENT_STORAGE = 507,
64
65
  LOOP_DETECTED = 508,
66
+ BANDWIDTH_LIMIT_EXCEEDED = 509,
65
67
  NOT_EXTENDED = 510,
66
68
  NETWORK_AUTHENTICATION_REQUIRED = 511,
67
69
  WEB_SERVER_IS_DOWN = 521,
package/lib/index.d.ts CHANGED
@@ -17,7 +17,7 @@ import type { CommandData, CropData, QualityData, ResizeData, RotateData, Transf
17
17
  import type { ExecCommand, LOG_TYPE, LogArguments, LogComponent, LogDate, LogFailOptions, LogMessageOptions, LogOptions, LogProcessOptions, LogTime, LogType, LogValue, STATUS_TYPE, StatusType } from './logger';
18
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, HeadersOnCallback, HostConfig, OpenOptions, PostOptions, ProxySettings, ReadExpectType, RequestInit } from './request';
20
+ import type { ApplyOptions, Aria2Options, BufferFormat, DataEncodedResult, DataObjectResult, FormDataPart, HeadersOnCallback, HostConfig, OpenOptions, PostOptions, ProxySettings, ReadExpectType, RequestInit, StatusOnCallback } 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';
@@ -109,6 +109,7 @@ declare namespace functions {
109
109
  clamp(value: unknown, min?: number, max?: number): number;
110
110
  isBinary(mime: unknown): mime is string;
111
111
  toABGR(buffer: Uint8Array | Buffer): Buffer;
112
+ /* @deprecated IImage.using (v0.9) */
112
113
  using?<V extends ExternalAsset>(this: T, instance: IImage<T, U>, data: IFileThread<V>, command: string): Promise<unknown>;
113
114
  readonly prototype: IImage<T, U>;
114
115
  new(module?: U): IImage<T, U>;
@@ -126,6 +127,7 @@ declare namespace functions {
126
127
 
127
128
  interface TaskConstructor<T extends IHost = IHost, U extends TaskModule = TaskModule> extends ModuleConstructor {
128
129
  finalize<V extends ExternalAsset>(this: T, instance: ITask<T, U>, assets: V[]): Promise<unknown>;
130
+ /* @deprecated ITask.using (v0.9) */
129
131
  using?<V extends ExternalAsset>(this: T, instance: ITask<T, U>, assets: V[], preceding?: boolean): Promise<unknown>;
130
132
  readonly prototype: ITask<T, U>;
131
133
  new(module?: U, ...args: unknown[]): ITask<T, U>;
@@ -254,6 +256,7 @@ declare namespace functions {
254
256
  writeSourceMap(uri: string, data: SourceCode, options?: SourceMapOptions): Undef<string>;
255
257
  updateGradle(source: string, namespaces: string[], value: string, options?: UpdateGradleOptions | boolean): string;
256
258
  generateLintTable(messages: LintMessage[], options: GenerateLintTableOptions): LogComponent[];
259
+ /* @deprecated IDocument.using (v0.9) */
257
260
  using?(this: T, instance: IDocument<T, U, V, W, X, Y>, file: U): Promise<unknown>;
258
261
  cleanup?(this: T, instance: IDocument<T, U, V, W, X, Y>): Promise<unknown>;
259
262
  sanitizeAssets?(assets: U[], exclusions?: U[]): U[];
@@ -302,9 +305,12 @@ declare namespace functions {
302
305
  proxy: Null<ProxySettings>;
303
306
  init(config?: RequestInit): this;
304
307
  apply(options: ApplyOptions): this;
305
- addDns(hostname: string, address: string, family?: NumString): void;
308
+ addDns(hostname: string, address: string, timeout: number): void;
309
+ addDns(hostname: string, address: string, family?: NumString, timeout?: number): void;
306
310
  lookupDns(hostname: string): LookupFunction;
307
311
  proxyOf(uri: string, localhost?: boolean): Undef<ProxySettings>;
312
+ statusOn(name: ArrayOf<number>, callback: StatusOnCallback): void;
313
+ statusOn(name: ArrayOf<number>, patternUrl: string, callback: StatusOnCallback): void;
308
314
  headersOn(name: ArrayOf<string>, callback: HeadersOnCallback): void;
309
315
  headersOn(name: ArrayOf<string>, patternUrl: string, callback: HeadersOnCallback): void;
310
316
  headersOf(uri: string): Undef<OutgoingHttpHeaders>;
package/lib/logger.d.ts CHANGED
@@ -40,6 +40,7 @@ export interface LoggerFormat<T = NumString> {
40
40
  bold?: boolean;
41
41
  justify?: TextAlign;
42
42
  unit?: string;
43
+ as?: StringMap;
43
44
  }
44
45
 
45
46
  export interface LoggerStatus<T = boolean> {
@@ -93,10 +94,9 @@ export interface LogTypeValue {
93
94
  sessionId?: string;
94
95
  }
95
96
 
96
- export interface LogArguments {
97
- type?: LogType;
98
- value?: LogValue;
97
+ export interface LogArguments extends Pick<LogBaseOptions, "type" | "sessionId"> {
99
98
  title?: string;
99
+ value?: LogValue;
100
100
  message?: unknown;
101
101
  }
102
102
 
package/lib/request.d.ts CHANGED
@@ -128,4 +128,5 @@ 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
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>;
131
+ export type StatusOnCallback = (code: number, headers: IncomingHttpHeaders, url?: URL) => Void<boolean>;
132
+ export type HeadersOnCallback = (headers: IncomingHttpHeaders, url?: URL) => Void<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/types",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "Type definitions for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/anpham6/e-mc.git",
12
+ "url": "git+https://github.com/anpham6/e-mc.git",
13
13
  "directory": "src/types"
14
14
  },
15
15
  "keywords": [