@e-mc/types 0.0.3 → 0.0.4

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
@@ -132,7 +132,7 @@ export const enum ERR_CLOUD {
132
132
  METADATA_FAIL = 'Metadata failed'
133
133
  }
134
134
 
135
- export const enum TRANSACTION_DB {
135
+ export const enum DB_TRANSACTION {
136
136
  ACTIVE = 1,
137
137
  PARTIAL = 2,
138
138
  COMMIT = 4,
package/index.d.ts CHANGED
@@ -180,6 +180,28 @@ declare namespace types {
180
180
  KEYVALUE: 8;
181
181
  };
182
182
 
183
+ interface DB_TRANSACTION {
184
+ ACTIVE: 1;
185
+ PARTIAL: 2;
186
+ COMMIT: 4;
187
+ TERMINATE: 8;
188
+ ABORT: 16;
189
+ FAIL: 32;
190
+ AUTH: 64;
191
+ CACHE: 128;
192
+ }
193
+
194
+ const DB_TRANSACTION: {
195
+ ACTIVE: 1;
196
+ PARTIAL: 2;
197
+ COMMIT: 4;
198
+ TERMINATE: 8;
199
+ ABORT: 16;
200
+ FAIL: 32;
201
+ AUTH: 64;
202
+ CACHE: 128;
203
+ };
204
+
183
205
  interface WATCH_EVENT {
184
206
  MODIFIED: "modified";
185
207
  BROADCAST: "broadcast";
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateUUID = exports.purgeMemory = exports.errorMessage = 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.WATCH_EVENT = 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;
3
+ exports.purgeMemory = exports.errorMessage = 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.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 = void 0;
4
5
  const path = require("path");
5
6
  const fs = require("fs");
6
7
  const crypto = require("crypto");
@@ -224,6 +225,17 @@ var DB_TYPE;
224
225
  DB_TYPE[DB_TYPE["DOCUMENT"] = 4] = "DOCUMENT";
225
226
  DB_TYPE[DB_TYPE["KEYVALUE"] = 8] = "KEYVALUE";
226
227
  })(DB_TYPE = exports.DB_TYPE || (exports.DB_TYPE = {}));
228
+ var DB_TRANSACTION;
229
+ (function (DB_TRANSACTION) {
230
+ DB_TRANSACTION[DB_TRANSACTION["ACTIVE"] = 1] = "ACTIVE";
231
+ DB_TRANSACTION[DB_TRANSACTION["PARTIAL"] = 2] = "PARTIAL";
232
+ DB_TRANSACTION[DB_TRANSACTION["COMMIT"] = 4] = "COMMIT";
233
+ DB_TRANSACTION[DB_TRANSACTION["TERMINATE"] = 8] = "TERMINATE";
234
+ DB_TRANSACTION[DB_TRANSACTION["ABORT"] = 16] = "ABORT";
235
+ DB_TRANSACTION[DB_TRANSACTION["FAIL"] = 32] = "FAIL";
236
+ DB_TRANSACTION[DB_TRANSACTION["AUTH"] = 64] = "AUTH";
237
+ DB_TRANSACTION[DB_TRANSACTION["CACHE"] = 128] = "CACHE";
238
+ })(DB_TRANSACTION = exports.DB_TRANSACTION || (exports.DB_TRANSACTION = {}));
227
239
  var WATCH_EVENT;
228
240
  (function (WATCH_EVENT) {
229
241
  WATCH_EVENT["MODIFIED"] = "modified";
package/lib/db.d.ts CHANGED
@@ -4,34 +4,7 @@ import type { CacheOptions, IdentifierAction } from './core';
4
4
 
5
5
  import type { DB_TYPE } from '../index.d';
6
6
 
7
- import type { SecureContextOptions } from 'tls';
8
-
9
- // @ts-ignore
10
- import type { AggregateOptions, BulkWriteOptions, CollectionOptions, CommandOperationOptions, DbOptions, Document, Filter, MongoClientOptions, OptionalUnlessRequiredId, Sort, SortDirection, UpdateFilter } from 'mongodb';
11
- // @ts-ignore
12
- import type { CommandOptions } from '@redis/client/dist/lib/command-options';
13
- // @ts-ignore
14
- import type { ClientCommandOptions } from '@redis/client/dist/lib/client';
15
- // @ts-ignore
16
- import type { RedisClientOptions } from '@redis/client';
17
- // @ts-ignore
18
- import type { RedisCommandArgument } from '@redis/client/dist/lib/commands';
19
- // @ts-ignore
20
- import type { RedisJSON } from '@redis/json/dist/commands';
21
- // @ts-ignore
22
- import type { RediSearchSchema } from 'redis';
23
- // @ts-ignore
24
- import type { PoolOptions, QueryOptions } from 'mysql2/promise';
25
- // @ts-ignore
26
- import type { PoolConfig as PostgresPoolConfig, QueryArrayConfig } from 'pg';
27
- // @ts-ignore
28
- import type { BindParameters, ConnectionAttributes, ExecuteOptions, PoolAttributes } from 'oracledb';
29
- // @ts-ignore
30
- import type { ConnectionConfig as IConnectionConfig, ParameterOptions, TediousType, TediousTypes } from 'tedious';
31
- // @ts-ignore
32
- import type { PoolConfig as MSSQLPoolConfig } from 'tedious-connection-pool';
33
-
34
- interface ExecuteAction<T = unknown> {
7
+ export interface ExecuteAction<T = unknown> {
35
8
  params?: T;
36
9
  }
37
10
 
@@ -41,129 +14,6 @@ export interface CascadeAction {
41
14
  fallback?: unknown;
42
15
  }
43
16
 
44
- export interface MongoDBDataSource extends DbDataSource<Filter<Document> | MongoDBQueryWithOptions, MongoClientOptions, UpdateFilter<Document> | OptionalUnlessRequiredId<unknown>[], string | MongoDBCredential, string>, MongoDBClientDBOptions, CascadeAction {
45
- source: "mongodb";
46
- id?: string;
47
- updateType?: 0 | 1 | 2 | 3;
48
- }
49
-
50
- export interface RedisDataSource extends DbDataSource<string, PlainObject, ArrayOf<RedisSetValue> | ArrayOf<RedisJSONValue>, string | RedisCredential, string>, CascadeAction, AuthValue {
51
- source: "redis";
52
- key?: ArrayOf<RedisCommandArgument>;
53
- field?: RedisCommandArgument;
54
- path?: string;
55
- format?: RedisFormat | "HKEYS" | "HVALS";
56
- search?: {
57
- index?: string;
58
- schema?: RediSearchSchema | string;
59
- query?: string;
60
- options?: PlainObject;
61
- };
62
- options?: {
63
- client?: RedisClientOptions;
64
- get?: PlainObject;
65
- command?: RedisCommandOptions;
66
- };
67
- database?: number;
68
- }
69
-
70
- export interface MySQLDataSource<T = unknown> extends DbDataSource<string | QueryOptions, unknown, unknown, string | MySQLCredential, string>, ExecuteAction<T> {
71
- source: "mysql";
72
- }
73
-
74
- export interface PostgresDataSource<T = unknown[]> extends DbDataSource<string | QueryArrayConfig, unknown, unknown, string | PostgresCredential, string>, ExecuteAction<T> {
75
- source: "postgres";
76
- }
77
-
78
- export interface OracleDataSource extends DbDataSource<string, ExecuteOptions, unknown, string | OracleCredential, string>, ExecuteAction<BindParameters> {
79
- source: "oracle";
80
- }
81
-
82
- export interface MSSQLDataSource extends DbDataSource<string, unknown, unknown, string | MSSQLCredential, string | MSSQLPoolConfig>, ExecuteAction<MSSQLRequestParameters | MSSQLRequestWithOutputParameters> {
83
- source: "mssql";
84
- storedProc?: boolean;
85
- }
86
-
87
- export interface MongoDBCredential extends ServerAuth, Pick<MongoClientOptions, "auth" | "authMechanism" | "authSource" | "tlsCAFile" | "tlsCertificateFile" | "tlsCertificateKeyFile" | "tlsCertificateKeyFilePassword" | "sslCA" | "sslKey" | "sslCert"> {}
88
-
89
- export type RedisCredential = ServerAuth;
90
-
91
- export interface MySQLCredential extends ServerAuth, Omit<PoolOptions, "ssl"> {
92
- ssl?: boolean | string | SecureContextOptions & { rejectUnauthorized?: boolean };
93
- }
94
-
95
- export interface PostgresCredential extends Omit<ServerAuth, "password">, PostgresPoolConfig {}
96
-
97
- export interface OracleCredential extends ServerAuth, ConnectionAttributes, PoolAttributes {}
98
-
99
- export interface MSSQLCredential extends ServerAuth, IConnectionConfig {}
100
-
101
- export interface MongoDBSortValue {
102
- value?: Sort;
103
- direction?: SortDirection;
104
- }
105
-
106
- export interface MongoDBAggregate {
107
- pipeline?: Document[];
108
- options?: AggregateOptions;
109
- }
110
-
111
- export interface MongoDBClientDBOptions {
112
- client?: {
113
- db?: DbOptions;
114
- collection?: CollectionOptions;
115
- };
116
- execute?: {
117
- insert?: BulkWriteOptions;
118
- };
119
- aggregate?: MongoDBAggregate;
120
- sort?: Sort | string | MongoDBSortValue;
121
- }
122
-
123
- export interface MongoDBQueryWithOptions {
124
- value: Filter<Document>;
125
- options: CommandOperationOptions;
126
- }
127
-
128
- export interface MongoDBFilterValue {
129
- value?: Filter<Document>;
130
- options?: CommandOperationOptions;
131
- }
132
-
133
- export interface RedisSetValue<T = "HASH" | undefined, U = RedisCommandArgument, V = RedisCommandValue | RedisHSETObject> {
134
- format: T;
135
- key?: U;
136
- field?: V;
137
- value?: V;
138
- NX?: boolean;
139
- XX?: boolean;
140
- EX?: number;
141
- PX?: number;
142
- EXAT?: number;
143
- PXAT?: number;
144
- options?: {
145
- set?: PlainObject;
146
- expire?: { [K in RedisExpireCondition]?: boolean; };
147
- command?: RedisCommandOptions;
148
- };
149
- }
150
-
151
- export interface RedisJSONValue extends Omit<RedisSetValue<"JSON", string, RedisJSON>, "field" | "EX" | "PX" | "EXAT" | "PXAT"> {
152
- path?: string;
153
- }
154
-
155
- export interface MSSQLRequestWithOutputParameters {
156
- input?: MSSQLRequestParameters;
157
- output?: MSSQLRequestParameters;
158
- }
159
-
160
- export interface MSSQLRequestParameterValue {
161
- name?: string;
162
- value?: unknown;
163
- type?: keyof TediousTypes | TediousType;
164
- options?: ParameterOptions;
165
- }
166
-
167
17
  export interface ExecuteQueryOptions {
168
18
  checkObject?: CheckObjectCallback | string;
169
19
  checkObjectKey?: string;
@@ -228,12 +78,12 @@ export interface IDbPool<T extends DbDataSource = DbDataSource, U = unknown, V =
228
78
  set parent(value: ObjectMap<IDbPool<T>>);
229
79
  }
230
80
 
231
- export interface DbPoolConstructor<T extends DbDataSource = DbDataSource, U = unknown> {
232
- findKey<V extends IDbPool, W extends DbDataSource>(pools: ObjectMap<V>, uuidKey: unknown, poolKey: Undef<string>, ...items: W[]): Null<V>;
233
- validateKey<V extends IDbPool>(pools: ObjectMap<V>, username: string, uuidKey: unknown): [string, Null<V>];
234
- checkTimeout<V extends IDbPool>(pools: ObjectMap<V>, value: number, limit?: number): Promise<number>;
235
- readonly prototype: IDbPool<T, U>;
236
- new(pool: U, poolKey: string, uuidKey?: string): IDbPool<T, U>;
81
+ export interface DbPoolConstructor<T extends DbDataSource = DbDataSource, U = unknown, V = unknown> {
82
+ findKey<W extends IDbPool, X extends DbDataSource>(pools: ObjectMap<W>, uuidKey: unknown, poolKey: Undef<string>, ...items: X[]): Null<W>;
83
+ validateKey<W extends IDbPool>(pools: ObjectMap<W>, username: string, uuidKey: unknown): [string, Null<W>];
84
+ checkTimeout<W extends IDbPool>(pools: ObjectMap<W>, value: number, limit?: number): Promise<number>;
85
+ readonly prototype: IDbPool<T, U, V>;
86
+ new(pool: U, poolKey: string, uuidKey?: Null<AuthValue>): IDbPool<T, U, V>;
237
87
  }
238
88
 
239
89
  export interface PoolConfig<T = number> extends MinMax {
@@ -251,12 +101,6 @@ export type DbSource = "mongodb" | "redis" | "mysql" | "postgres" | "oracle" | "
251
101
  export type QueryResult = unknown[];
252
102
  export type BatchQueryResult = Null<QueryResult>[];
253
103
  export type CheckObjectCallback = (item: DataSource, data: unknown) => Null<QueryResult>;
254
- export type RedisFormat = "HASH" | "JSON";
255
- export type RedisExpireCondition = "NX" | "XX" | "GT" | "LT";
256
- export type RedisCommandValue = RedisCommandArgument | number;
257
- export type RedisCommandOptions = CommandOptions<ClientCommandOptions>;
258
- export type RedisHSETObject = Record<NumString, RedisCommandValue>;
259
- export type MSSQLRequestParameters = Null<MSSQLRequestParameterValue[] | ObjectMap<Omit<MSSQLRequestParameterValue, "name">>>;
260
104
  export type ErrorQueryCallback = (err: unknown, item: DbDataSource, commandType?: number) => boolean;
261
105
 
262
106
  export interface SQL_COMMAND {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/types",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Type definitions for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",