vortez 5.0.0-dev.18 → 5.0.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/.gitignore +11 -4
- package/README.md +699 -177
- package/build/Template/Compiler.d.ts +70 -0
- package/build/Template/Compiler.js +135 -0
- package/build/Template/Compiler.js.map +1 -0
- package/build/Template/StreamCompiler.d.ts +16 -0
- package/build/Template/StreamCompiler.js +54 -0
- package/build/Template/StreamCompiler.js.map +1 -0
- package/build/Template/Template.d.ts +49 -0
- package/build/Template/Template.js +77 -0
- package/build/Template/Template.js.map +1 -0
- package/build/Vortez.d.ts +2 -1
- package/build/Vortez.js +2 -1
- package/build/Vortez.js.map +1 -1
- package/build/beta/JwtManager/JwtError.d.ts +8 -0
- package/build/beta/JwtManager/JwtError.js +10 -0
- package/build/beta/JwtManager/JwtError.js.map +1 -0
- package/build/beta/JwtManager/JwtManager.d.ts +3 -0
- package/build/beta/JwtManager/JwtManager.js +24 -7
- package/build/beta/JwtManager/JwtManager.js.map +1 -1
- package/build/server/BodyParser.d.ts +6 -0
- package/build/server/BodyParser.js +18 -3
- package/build/server/BodyParser.js.map +1 -1
- package/build/server/Request.d.ts +6 -4
- package/build/server/Request.js +15 -10
- package/build/server/Request.js.map +1 -1
- package/build/server/Response.d.ts +25 -10
- package/build/server/Response.js +161 -75
- package/build/server/Response.js.map +1 -1
- package/build/server/Server.d.ts +4 -4
- package/build/server/Server.js +34 -11
- package/build/server/Server.js.map +1 -1
- package/build/server/ServerDebug.d.ts +10 -1
- package/build/server/ServerDebug.js +85 -17
- package/build/server/ServerDebug.js.map +1 -1
- package/build/server/config/Config.d.ts +276 -47
- package/build/server/config/Config.js +70 -47
- package/build/server/config/Config.js.map +1 -1
- package/build/server/config/{ConfigLoader.d.ts → Loader.d.ts} +4 -5
- package/build/server/config/{ConfigLoader.js → Loader.js} +8 -11
- package/build/server/config/Loader.js.map +1 -0
- package/build/server/router/Router.d.ts +88 -31
- package/build/server/router/Router.js +113 -51
- package/build/server/router/Router.js.map +1 -1
- package/build/server/router/algorithm/Algorithm.d.ts +39 -0
- package/build/server/router/algorithm/Algorithm.js +20 -0
- package/build/server/router/algorithm/Algorithm.js.map +1 -0
- package/build/server/router/algorithm/FIFO.d.ts +15 -0
- package/build/server/router/algorithm/FIFO.js +24 -0
- package/build/server/router/algorithm/FIFO.js.map +1 -0
- package/build/server/router/algorithm/Tree.d.ts +38 -0
- package/build/server/router/algorithm/Tree.js +126 -0
- package/build/server/router/algorithm/Tree.js.map +1 -0
- package/build/server/router/middleware/HttpMiddleware.js +1 -1
- package/build/server/router/middleware/HttpMiddleware.js.map +1 -1
- package/build/server/router/middleware/WsMiddleware.js +1 -1
- package/build/server/router/middleware/WsMiddleware.js.map +1 -1
- package/build/server/security/PathSecurity.d.ts +45 -0
- package/build/server/security/PathSecurity.js +108 -0
- package/build/server/security/PathSecurity.js.map +1 -0
- package/build/server/websocket/Websocket.js +4 -1
- package/build/server/websocket/Websocket.js.map +1 -1
- package/build/utilities/ConsoleUI.d.ts +2 -1
- package/build/utilities/ConsoleUI.js +2 -1
- package/build/utilities/ConsoleUI.js.map +1 -1
- package/build/utilities/DebugUI.d.ts +1 -1
- package/build/utilities/DebugUI.js +1 -1
- package/build/utilities/Encoding.d.ts +22 -0
- package/build/utilities/Encoding.js +26 -0
- package/build/utilities/Encoding.js.map +1 -0
- package/build/utilities/Env.js +7 -2
- package/build/utilities/Env.js.map +1 -1
- package/build/utilities/File.d.ts +10 -0
- package/build/utilities/File.js +19 -0
- package/build/utilities/File.js.map +1 -0
- package/build/utilities/Flatten.d.ts +73 -0
- package/build/utilities/Flatten.js +76 -0
- package/build/utilities/Flatten.js.map +1 -0
- package/build/utilities/Object.d.ts +16 -0
- package/build/utilities/Object.js +48 -0
- package/build/utilities/Object.js.map +1 -0
- package/build/utilities/Path.d.ts +31 -11
- package/build/utilities/Path.js +48 -15
- package/build/utilities/Path.js.map +1 -1
- package/build/utilities/Time.d.ts +21 -0
- package/build/utilities/Time.js +25 -0
- package/build/utilities/Time.js.map +1 -0
- package/build/utilities/Utilities.d.ts +50 -92
- package/build/utilities/Utilities.js +56 -71
- package/build/utilities/Utilities.js.map +1 -1
- package/build/utilities/schema/Introspection.d.ts +24 -0
- package/build/utilities/schema/Introspection.js +87 -0
- package/build/utilities/schema/Introspection.js.map +1 -0
- package/build/utilities/schema/JSONSchema.d.ts +68 -0
- package/build/utilities/schema/JSONSchema.js +13 -0
- package/build/utilities/schema/JSONSchema.js.map +1 -0
- package/build/utilities/schema/Schema.d.ts +253 -0
- package/build/utilities/schema/Schema.js +241 -0
- package/build/utilities/schema/Schema.js.map +1 -0
- package/build/utilities/schema/SchemaError.d.ts +10 -0
- package/build/utilities/schema/SchemaError.js +13 -0
- package/build/utilities/schema/SchemaError.js.map +1 -0
- package/build/utilities/schema/Validator.d.ts +94 -0
- package/build/utilities/schema/Validator.js +246 -0
- package/build/utilities/schema/Validator.js.map +1 -0
- package/changes.md +4 -0
- package/docs/ARCHITECTURE.md +142 -0
- package/global/style/template/error.css +29 -0
- package/global/style/template/folder.css +79 -0
- package/global/{Style/Template/Template.css → style/template/template.css} +60 -68
- package/global/template/error.vhtml +29 -0
- package/global/template/folder.vhtml +54 -0
- package/package.json +2 -2
- package/build/Template.d.ts +0 -46
- package/build/Template.js +0 -81
- package/build/Template.js.map +0 -1
- package/build/server/config/ConfigLoader.js.map +0 -1
- package/build/server/config/ConfigValidator.d.ts +0 -71
- package/build/server/config/ConfigValidator.js +0 -131
- package/build/server/config/ConfigValidator.js.map +0 -1
- package/examples/in-docs.js +0 -96
- package/global/Style/Template/Error.css +0 -30
- package/global/Style/Template/Folder.css +0 -77
- package/global/Template/Error.vhtml +0 -29
- package/global/Template/Folder.vhtml +0 -41
- package/tests/Template/template.js +0 -18
- package/tests/Template/template.txt +0 -13
- package/tests/Template/template.vhtml +0 -23
- package/tests/debug.js +0 -34
- package/tests/jwtManager/jwtManager.js +0 -342
- package/tests/test.js +0 -131
- package/tests/test.vhtml +0 -14
- package/tests/utilities.js +0 -28
- package/tests/websocket.vhtml +0 -86
- /package/global/{Source/Logo_960.png → source/logo_960.png} +0 -0
- /package/global/{Source/Logo_SM_960.png → source/logo_SM_960.png} +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>
|
|
3
|
+
* @description Provides flatten/unflatten helpers with strong TypeScript typing.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export declare class Flatten {
|
|
7
|
+
/**
|
|
8
|
+
* Flattens a nested plain-object into dot-notation keys.
|
|
9
|
+
* Non-plain objects (Date, RegExp, Map, Set, etc.) are treated as leaf values.
|
|
10
|
+
* @param object - The object to flatten.
|
|
11
|
+
* @param depth - The maximum depth to flatten (default is 10).
|
|
12
|
+
* @returns A new object with flattened keys.
|
|
13
|
+
*/
|
|
14
|
+
static object<T extends Flatten.Document, D extends number = 10>(object: T, depth?: D): Flatten.Object<T, D>;
|
|
15
|
+
/**
|
|
16
|
+
* Unflattens a flattened object back into its original nested structure.
|
|
17
|
+
* @param obj - The flattened object to unflatten.
|
|
18
|
+
* @returns A new object with the original nested structure.
|
|
19
|
+
*/
|
|
20
|
+
static unObject<Result extends any = any>(obj: Flatten.Document): Result;
|
|
21
|
+
/**
|
|
22
|
+
* Core recursive function to flatten an object. It handles the actual flattening logic, while the public `object` method provides type safety and a cleaner interface.
|
|
23
|
+
* @param object - The object to flatten.
|
|
24
|
+
* @param depth - The remaining depth to flatten.
|
|
25
|
+
* @param prefix - The current key prefix for nested keys.
|
|
26
|
+
* @returns A flattened object with dot-notation keys.
|
|
27
|
+
*/
|
|
28
|
+
private static flattenCore;
|
|
29
|
+
/**
|
|
30
|
+
* Checks if a value is a plain object (i.e., an object created by the Object constructor or with a null prototype). This is used to determine whether to flatten a value or treat it as a leaf.
|
|
31
|
+
* @param value - The value to check.
|
|
32
|
+
* @returns True if the value is a plain object, false otherwise.
|
|
33
|
+
*/
|
|
34
|
+
private static isPlainObject;
|
|
35
|
+
}
|
|
36
|
+
export declare namespace Flatten {
|
|
37
|
+
export type Document = {
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
};
|
|
40
|
+
type Prettify<T> = {
|
|
41
|
+
[K in keyof T]: T[K];
|
|
42
|
+
} & {};
|
|
43
|
+
type Primitive = string | number | boolean | bigint | symbol | null | undefined;
|
|
44
|
+
type Builtin = Primitive | Date | RegExp | Function | Error | Promise<any> | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any>;
|
|
45
|
+
type IsLeaf<T> = T extends Builtin ? true : T extends readonly any[] ? true : false;
|
|
46
|
+
type UndefinedToPartial<T extends object> = {
|
|
47
|
+
[K in keyof T as undefined extends T[K] ? never : K]: T[K];
|
|
48
|
+
} & {
|
|
49
|
+
[K in keyof T as undefined extends T[K] ? K : never]?: Exclude<T[K], undefined>;
|
|
50
|
+
};
|
|
51
|
+
type UnionToIntersection<U extends object> = ((U extends any ? (arg: U) => void : never) extends (arg: infer I) => void ? I extends object ? {
|
|
52
|
+
[K in keyof I]: I[K] extends object ? UnionToIntersection<I[K]> : I[K];
|
|
53
|
+
} : I : never);
|
|
54
|
+
type DepthTuple<Depth extends number, Current extends 1[] = []> = (number extends Depth ? [1, 1, 1, 1, 1] : Current['length'] extends Depth ? Current : DepthTuple<Depth, [1, ...Current]>);
|
|
55
|
+
type NextDepth<D extends 1[]> = D extends [1, ...infer R extends 1[]] ? R : [];
|
|
56
|
+
type Join<Prefix extends string, Key extends string> = Prefix extends '' ? Key : `${Prefix}.${Key}`;
|
|
57
|
+
type ResourceKeys<T extends Document, D extends 1[] = DepthTuple<5>, Prefix extends string = ''> = {
|
|
58
|
+
[K in Extract<keyof T, string>]-?: (Exclude<T[K], undefined> extends infer U ? IsLeaf<U> extends true ? Join<Prefix, K> : U extends Document ? D extends [] ? Join<Prefix, K> : ResourceKeys<U, NextDepth<D>, Join<Prefix, K>> : Join<Prefix, K> : never);
|
|
59
|
+
}[Extract<keyof T, string>];
|
|
60
|
+
type RecurseObject<T extends Document, Keys extends string> = (Keys extends `${infer K}.${infer Rest}` ? K extends keyof T ? Extract<Exclude<T[K], undefined>, Document> extends infer Nested ? [Nested] extends [never] ? never : (RecurseObject<Nested & Document, Rest> | (undefined extends T[K] ? undefined : never) | (null extends T[K] ? undefined : never)) : never : never : undefined extends T ? Keys extends keyof Exclude<T, undefined> ? Exclude<T, undefined>[Keys] | undefined : never : Keys extends keyof T ? T[Keys] : never);
|
|
61
|
+
export type Object<T extends Document, depth extends number = 5> = Prettify<UndefinedToPartial<{
|
|
62
|
+
[P in ResourceKeys<T, DepthTuple<depth>>]: RecurseObject<T, P>;
|
|
63
|
+
}>>;
|
|
64
|
+
type Split<S extends string, Delimiter extends string> = (S extends `${infer T}${Delimiter}${infer U}` ? [T, ...Split<U, Delimiter>] : [S]);
|
|
65
|
+
type BuildNestedObject<Path extends string[], Value> = (Path extends [infer Head extends string, ...infer Tail extends string[]] ? UndefinedToPartial<{
|
|
66
|
+
[K in Head]: BuildNestedObject<Tail, Value>;
|
|
67
|
+
}> : Value);
|
|
68
|
+
export type UnObject<T extends Document> = Prettify<UnionToIntersection<UndefinedToPartial<({
|
|
69
|
+
[K in keyof T]-?: BuildNestedObject<Split<Extract<K, string>, '.'>, T[K]>;
|
|
70
|
+
}[keyof T])>>>;
|
|
71
|
+
export {};
|
|
72
|
+
}
|
|
73
|
+
export default Flatten;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>
|
|
3
|
+
* @description Provides flatten/unflatten helpers with strong TypeScript typing.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export class Flatten {
|
|
7
|
+
/**
|
|
8
|
+
* Flattens a nested plain-object into dot-notation keys.
|
|
9
|
+
* Non-plain objects (Date, RegExp, Map, Set, etc.) are treated as leaf values.
|
|
10
|
+
* @param object - The object to flatten.
|
|
11
|
+
* @param depth - The maximum depth to flatten (default is 10).
|
|
12
|
+
* @returns A new object with flattened keys.
|
|
13
|
+
*/
|
|
14
|
+
static object(object, depth = 10) {
|
|
15
|
+
return this.flattenCore(object, depth);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Unflattens a flattened object back into its original nested structure.
|
|
19
|
+
* @param obj - The flattened object to unflatten.
|
|
20
|
+
* @returns A new object with the original nested structure.
|
|
21
|
+
*/
|
|
22
|
+
static unObject(obj) {
|
|
23
|
+
const result = {};
|
|
24
|
+
for (const key in obj) {
|
|
25
|
+
const value = obj[key];
|
|
26
|
+
const [first, ...rest] = key.split('.');
|
|
27
|
+
if (rest.length === 0)
|
|
28
|
+
result[first] = value;
|
|
29
|
+
else {
|
|
30
|
+
const last = rest.pop();
|
|
31
|
+
const subObj = result[first] ?? {};
|
|
32
|
+
let current = subObj;
|
|
33
|
+
rest.forEach((k) => {
|
|
34
|
+
current = current[k] ?? (current[k] = {});
|
|
35
|
+
});
|
|
36
|
+
current[last] = value;
|
|
37
|
+
result[first] = subObj;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Core recursive function to flatten an object. It handles the actual flattening logic, while the public `object` method provides type safety and a cleaner interface.
|
|
44
|
+
* @param object - The object to flatten.
|
|
45
|
+
* @param depth - The remaining depth to flatten.
|
|
46
|
+
* @param prefix - The current key prefix for nested keys.
|
|
47
|
+
* @returns A flattened object with dot-notation keys.
|
|
48
|
+
*/
|
|
49
|
+
static flattenCore(object, depth = 10, prefix = '') {
|
|
50
|
+
const result = {};
|
|
51
|
+
for (const key in object) {
|
|
52
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
53
|
+
const value = object[key];
|
|
54
|
+
if (depth > 0 && this.isPlainObject(value)) {
|
|
55
|
+
Object.assign(result, this.flattenCore(value, depth - 1, newKey));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
result[newKey] = value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Checks if a value is a plain object (i.e., an object created by the Object constructor or with a null prototype). This is used to determine whether to flatten a value or treat it as a leaf.
|
|
65
|
+
* @param value - The value to check.
|
|
66
|
+
* @returns True if the value is a plain object, false otherwise.
|
|
67
|
+
*/
|
|
68
|
+
static isPlainObject(value) {
|
|
69
|
+
if (value == null || typeof value !== 'object' || Array.isArray(value))
|
|
70
|
+
return false;
|
|
71
|
+
const proto = Object.getPrototypeOf(value);
|
|
72
|
+
return proto === Object.prototype || proto === null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export default Flatten;
|
|
76
|
+
//# sourceMappingURL=Flatten.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Flatten.js","sourceRoot":"","sources":["../../src/utilities/Flatten.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,OAAO,OAAO;IAChB;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAChB,MAAS,EACT,QAAW,EAAO;QAElB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,CAAyB,CAAC;IACnE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,QAAQ,CAA2B,GAAqB;QAClE,MAAM,MAAM,GAAQ,EAAE,CAAC;QACvB,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACvB,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACxC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;gBAAE,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;iBACxC,CAAC;gBACF,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAY,CAAC;gBAClC,MAAM,MAAM,GAAQ,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;gBACxC,IAAI,OAAO,GAAQ,MAAM,CAAC;gBAC1B,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;oBACf,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;gBAC9C,CAAC,CAAC,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;gBACtB,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;YAC3B,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IACD;;;;;;OAMG;IACK,MAAM,CAAC,WAAW,CAAC,MAAwB,EAAE,QAAgB,EAAE,EAAE,SAAiB,EAAE;QACxF,MAAM,MAAM,GAAqB,EAAE,CAAC;QACpC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACvB,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;YACjD,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAC1B,IAAI,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;YACtE,CAAC;iBAAM,CAAC;gBACJ,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;YAC3B,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IACD;;;;OAIG;IACK,MAAM,CAAC,aAAa,CAAC,KAAc;QACvC,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QACrF,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAC3C,OAAO,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;IACxD,CAAC;CACJ;AAsGD,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>
|
|
3
|
+
* @description Provides utilities for deep object comparison and manipulation, such as checking for deep equality between objects. This is useful for comparing complex data structures in a way that goes beyond simple reference checks.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export declare class Object {
|
|
7
|
+
/**
|
|
8
|
+
* Compares two objects recursively for deep equality.
|
|
9
|
+
* @param obj1 - The first object to compare.
|
|
10
|
+
* @param obj2 - The second object to compare.
|
|
11
|
+
* @returns true if the objects are deeply equal, false otherwise.
|
|
12
|
+
*/
|
|
13
|
+
static deepEqual(obj1: any, obj2: any): boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare namespace Object { }
|
|
16
|
+
export default Object;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>
|
|
3
|
+
* @description Provides utilities for deep object comparison and manipulation, such as checking for deep equality between objects. This is useful for comparing complex data structures in a way that goes beyond simple reference checks.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export class Object {
|
|
7
|
+
/**
|
|
8
|
+
* Compares two objects recursively for deep equality.
|
|
9
|
+
* @param obj1 - The first object to compare.
|
|
10
|
+
* @param obj2 - The second object to compare.
|
|
11
|
+
* @returns true if the objects are deeply equal, false otherwise.
|
|
12
|
+
*/
|
|
13
|
+
static deepEqual(obj1, obj2) {
|
|
14
|
+
if (obj1 === obj2)
|
|
15
|
+
return true;
|
|
16
|
+
if (typeof obj1 !== typeof obj2 ||
|
|
17
|
+
obj1 === null || obj2 === null)
|
|
18
|
+
return false;
|
|
19
|
+
const isArray1 = Array.isArray(obj1);
|
|
20
|
+
const isArray2 = Array.isArray(obj2);
|
|
21
|
+
if (isArray1 || isArray2) {
|
|
22
|
+
if (!isArray1 || !isArray2)
|
|
23
|
+
return false;
|
|
24
|
+
if (obj1.length !== obj2.length)
|
|
25
|
+
return false;
|
|
26
|
+
for (let i = 0; i < obj1.length; i++) {
|
|
27
|
+
const hasIndex1 = i in obj1;
|
|
28
|
+
const hasIndex2 = i in obj2;
|
|
29
|
+
if (hasIndex1 !== hasIndex2)
|
|
30
|
+
return false;
|
|
31
|
+
if (hasIndex1 && !this.deepEqual(obj1[i], obj2[i]))
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
const keys1 = globalThis.Object.keys(obj1);
|
|
37
|
+
const keys2 = globalThis.Object.keys(obj2);
|
|
38
|
+
if (keys1.length !== keys2.length)
|
|
39
|
+
return false;
|
|
40
|
+
for (const key of keys1)
|
|
41
|
+
if (!keys2.includes(key) ||
|
|
42
|
+
!this.deepEqual(obj1[key], obj2[key]))
|
|
43
|
+
return false;
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export default Object;
|
|
48
|
+
//# sourceMappingURL=Object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Object.js","sourceRoot":"","sources":["../../src/utilities/Object.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,MAAM;IACf;;;;;OAKG;IACI,MAAM,CAAC,SAAS,CAAC,IAAS,EAAE,IAAS;QACxC,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAC/B,IACI,OAAO,IAAI,KAAK,OAAO,IAAI;YAC3B,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI;YAChC,OAAO,KAAK,CAAC;QAEf,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACrC,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAErC,IAAI,QAAQ,IAAI,QAAQ,EAAE,CAAC;YACvB,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ;gBAAE,OAAO,KAAK,CAAC;YACzC,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;gBAAE,OAAO,KAAK,CAAC;YAE9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACnC,MAAM,SAAS,GAAG,CAAC,IAAI,IAAI,CAAC;gBAC5B,MAAM,SAAS,GAAG,CAAC,IAAI,IAAI,CAAC;gBAE5B,IAAI,SAAS,KAAK,SAAS;oBAAE,OAAO,KAAK,CAAC;gBAC1C,IAAI,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;oBAAE,OAAO,KAAK,CAAC;YACrE,CAAC;YAED,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QAChD,KAAK,MAAM,GAAG,IAAI,KAAK;YAAE,IACrB,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;gBACpB,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;gBACvC,OAAO,KAAK,CAAC;QACf,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAGD,eAAe,MAAM,CAAC"}
|
|
@@ -1,24 +1,44 @@
|
|
|
1
1
|
export declare class Path {
|
|
2
|
+
/** The directory where the Vortez module is located. */
|
|
2
3
|
static readonly moduleDir: string;
|
|
3
|
-
|
|
4
|
+
/** The directory where the user is running the server from. */
|
|
5
|
+
static readonly rootDir: string;
|
|
4
6
|
/**
|
|
5
|
-
* Normalizes a path by replacing
|
|
6
|
-
* @param path - The path to
|
|
7
|
-
* @
|
|
7
|
+
* Normalizes a file path by replacing multiple slashes with a single separator and ensuring consistent use of separators.
|
|
8
|
+
* @param path - The file path to normalize.
|
|
9
|
+
* @return The normalized file path.
|
|
8
10
|
*/
|
|
9
11
|
static normalize(path: string): string;
|
|
10
12
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @param
|
|
13
|
-
* @
|
|
13
|
+
* Resolves an absolute path from the root of the user project.
|
|
14
|
+
* @param paths - The path to resolve.
|
|
15
|
+
* @return The resolved path.
|
|
14
16
|
*/
|
|
15
|
-
static
|
|
17
|
+
static root(...paths: string[]): string;
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @param
|
|
19
|
-
* @
|
|
19
|
+
* Resolves an absolute path from the root of Vortez (internal).
|
|
20
|
+
* @param paths - The path to resolve.
|
|
21
|
+
* @return The resolved path.
|
|
22
|
+
*/
|
|
23
|
+
static module(...paths: string[]): string;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the directory name of a path, similar to `PATH.dirname`, but ensures the path is normalized first.
|
|
26
|
+
* @param path - The path to get the directory name of.
|
|
27
|
+
* @return The directory name of the path.
|
|
20
28
|
*/
|
|
21
29
|
static dirname(path: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Joins multiple path segments into a single path, ensuring that the result is normalized.
|
|
32
|
+
* @param paths - The path segments to join.
|
|
33
|
+
* @return The joined path.
|
|
34
|
+
*/
|
|
35
|
+
static join(...paths: string[]): string;
|
|
36
|
+
/**
|
|
37
|
+
* Resolves an absolute path from the root of the user project.
|
|
38
|
+
* @param paths - The path to resolve.
|
|
39
|
+
* @return The resolved path.
|
|
40
|
+
*/
|
|
41
|
+
static resolve(...paths: string[]): string;
|
|
22
42
|
}
|
|
23
43
|
export declare namespace Path { }
|
|
24
44
|
export default Path;
|
package/build/utilities/Path.js
CHANGED
|
@@ -1,36 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>
|
|
3
|
+
* @description Provides utilities for handling file paths, including normalization and resolution of paths relative to the module and user project.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
1
6
|
import PATH from 'path';
|
|
2
7
|
import URL from 'url';
|
|
3
8
|
export class Path {
|
|
9
|
+
/** The directory where the Vortez module is located. */
|
|
4
10
|
static moduleDir = PATH.dirname(PATH.dirname(PATH.dirname(URL.fileURLToPath(import.meta.url))));
|
|
5
|
-
|
|
11
|
+
/** The directory where the user is running the server from. */
|
|
12
|
+
static rootDir = process.cwd();
|
|
6
13
|
/**
|
|
7
|
-
* Normalizes a path by replacing
|
|
8
|
-
* @param path - The path to
|
|
9
|
-
* @
|
|
14
|
+
* Normalizes a file path by replacing multiple slashes with a single separator and ensuring consistent use of separators.
|
|
15
|
+
* @param path - The file path to normalize.
|
|
16
|
+
* @return The normalized file path.
|
|
10
17
|
*/
|
|
11
18
|
static normalize(path) {
|
|
12
|
-
path = path.replace(/[\\/]
|
|
19
|
+
path = path.replace(/[\\/]+/g, PATH.sep);
|
|
13
20
|
return path;
|
|
14
21
|
}
|
|
15
22
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @param
|
|
18
|
-
* @
|
|
23
|
+
* Resolves an absolute path from the root of the user project.
|
|
24
|
+
* @param paths - The path to resolve.
|
|
25
|
+
* @return The resolved path.
|
|
19
26
|
*/
|
|
20
|
-
static
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return PATH.normalize(path);
|
|
27
|
+
static root(...paths) {
|
|
28
|
+
paths = paths.map(path => this.normalize(path));
|
|
29
|
+
return PATH.join(this.rootDir, ...paths);
|
|
24
30
|
}
|
|
25
31
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @param
|
|
28
|
-
* @
|
|
32
|
+
* Resolves an absolute path from the root of Vortez (internal).
|
|
33
|
+
* @param paths - The path to resolve.
|
|
34
|
+
* @return The resolved path.
|
|
35
|
+
*/
|
|
36
|
+
static module(...paths) {
|
|
37
|
+
paths = paths.map(path => this.normalize(path));
|
|
38
|
+
return PATH.join(this.moduleDir, ...paths);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns the directory name of a path, similar to `PATH.dirname`, but ensures the path is normalized first.
|
|
42
|
+
* @param path - The path to get the directory name of.
|
|
43
|
+
* @return The directory name of the path.
|
|
29
44
|
*/
|
|
30
45
|
static dirname(path) {
|
|
31
46
|
path = this.normalize(path);
|
|
32
47
|
return PATH.dirname(path);
|
|
33
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Joins multiple path segments into a single path, ensuring that the result is normalized.
|
|
51
|
+
* @param paths - The path segments to join.
|
|
52
|
+
* @return The joined path.
|
|
53
|
+
*/
|
|
54
|
+
static join(...paths) {
|
|
55
|
+
paths = paths.map(path => this.normalize(path));
|
|
56
|
+
return PATH.join(...paths);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Resolves an absolute path from the root of the user project.
|
|
60
|
+
* @param paths - The path to resolve.
|
|
61
|
+
* @return The resolved path.
|
|
62
|
+
*/
|
|
63
|
+
static resolve(...paths) {
|
|
64
|
+
paths = paths.map(path => this.normalize(path));
|
|
65
|
+
return PATH.resolve(...paths);
|
|
66
|
+
}
|
|
34
67
|
}
|
|
35
68
|
export default Path;
|
|
36
69
|
//# sourceMappingURL=Path.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Path.js","sourceRoot":"","sources":["../../src/utilities/Path.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,MAAM,OAAO,IAAI;
|
|
1
|
+
{"version":3,"file":"Path.js","sourceRoot":"","sources":["../../src/utilities/Path.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,MAAM,OAAO,IAAI;IACb,wDAAwD;IACjD,MAAM,CAAU,SAAS,GAAW,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACxH,+DAA+D;IACxD,MAAM,CAAU,OAAO,GAAW,OAAO,CAAC,GAAG,EAAE,CAAC;IAEvD;;;;OAIG;IACI,MAAM,CAAC,SAAS,CAAC,IAAY;QAChC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IAChB,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAe;QACjC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC;IAC7C,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,GAAG,KAAe;QACnC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,KAAK,CAAC,CAAC;IAC/C,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,OAAO,CAAC,IAAY;QAC9B,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAe;QACjC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,OAAO,CAAC,GAAG,KAAe;QACpC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;IAClC,CAAC;;AAGL,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>
|
|
3
|
+
* @description Provides time-related utilities, such as sleep functions for delaying execution.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export declare class Time {
|
|
7
|
+
/**
|
|
8
|
+
* Converts a timestamp in milliseconds to seconds.
|
|
9
|
+
* @param timestamp - The timestamp in milliseconds to convert.
|
|
10
|
+
* @returns The equivalent timestamp in seconds.
|
|
11
|
+
*/
|
|
12
|
+
static timestampToSecond(timestamp: number): number;
|
|
13
|
+
/**
|
|
14
|
+
* Pauses execution for a specified duration.
|
|
15
|
+
* @param ms - The number of milliseconds to sleep.
|
|
16
|
+
* @returns A promise that resolves after the given time.
|
|
17
|
+
*/
|
|
18
|
+
static sleep(ms: number): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export declare namespace Time { }
|
|
21
|
+
export default Time;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>
|
|
3
|
+
* @description Provides time-related utilities, such as sleep functions for delaying execution.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export class Time {
|
|
7
|
+
/**
|
|
8
|
+
* Converts a timestamp in milliseconds to seconds.
|
|
9
|
+
* @param timestamp - The timestamp in milliseconds to convert.
|
|
10
|
+
* @returns The equivalent timestamp in seconds.
|
|
11
|
+
*/
|
|
12
|
+
static timestampToSecond(timestamp) {
|
|
13
|
+
return Math.floor(timestamp / 1000);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Pauses execution for a specified duration.
|
|
17
|
+
* @param ms - The number of milliseconds to sleep.
|
|
18
|
+
* @returns A promise that resolves after the given time.
|
|
19
|
+
*/
|
|
20
|
+
static sleep(ms) {
|
|
21
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export default Time;
|
|
25
|
+
//# sourceMappingURL=Time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Time.js","sourceRoot":"","sources":["../../src/utilities/Time.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,IAAI;IACb;;;;OAIG;IACI,MAAM,CAAC,iBAAiB,CAAC,SAAiB;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IACxC,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,KAAK,CAAC,EAAU;QAC1B,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACJ;AAGD,eAAe,IAAI,CAAC"}
|
|
@@ -1,61 +1,84 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @author NetFeez <netfeez.dev@gmail.com>
|
|
3
|
-
* @description
|
|
3
|
+
* @description Exports all utility classes and functions, providing a centralized access point for various helper methods used throughout the project.
|
|
4
|
+
* This includes:
|
|
5
|
+
* - file operations: `Utilities.File`.
|
|
6
|
+
* - object manipulation: `Utilities.Object`.
|
|
7
|
+
* - encoding: `Utilities.Encoding`.
|
|
8
|
+
* - time utilities: `Utilities.Time`.
|
|
9
|
+
* and more utilities.
|
|
4
10
|
* @license Apache-2.0
|
|
5
11
|
*/
|
|
6
12
|
import _Path from './Path.js';
|
|
7
13
|
import _Env from './Env.js';
|
|
8
14
|
import _ConsoleUI from './ConsoleUI.js';
|
|
9
15
|
import _DebugUI from './DebugUI.js';
|
|
16
|
+
import _Schema from './schema/Schema.js';
|
|
17
|
+
import _Flatten from './Flatten.js';
|
|
18
|
+
import _File from './File.js';
|
|
19
|
+
import _Object from './Object.js';
|
|
20
|
+
import _Encoding from './Encoding.js';
|
|
21
|
+
import _Time from './Time.js';
|
|
10
22
|
export { Path } from './Path.js';
|
|
11
23
|
export { Env } from './Env.js';
|
|
12
24
|
export { ConsoleUI } from './ConsoleUI.js';
|
|
13
25
|
export { DebugUI } from './DebugUI.js';
|
|
26
|
+
export { Schema } from './schema/Schema.js';
|
|
27
|
+
export { Flatten } from './Flatten.js';
|
|
28
|
+
export { File } from './File.js';
|
|
29
|
+
export { Object } from './Object.js';
|
|
30
|
+
export { Encoding } from './Encoding.js';
|
|
31
|
+
export { Time } from './Time.js';
|
|
14
32
|
export declare class Utilities {
|
|
15
33
|
/**
|
|
16
|
-
* Checks if a file exists
|
|
17
|
-
* @param path - The path to
|
|
18
|
-
* @returns A promise that resolves to
|
|
34
|
+
* Checks if a file exists at the given path.
|
|
35
|
+
* @param path - The file path to check.
|
|
36
|
+
* @returns A promise that resolves to true if the file exists, false otherwise.
|
|
37
|
+
* @deprecated Use Utilities.File.exists instead.
|
|
19
38
|
*/
|
|
20
39
|
static fileExists(path: string): Promise<boolean>;
|
|
21
40
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @param obj1 - The first
|
|
24
|
-
* @param obj2 - The second
|
|
25
|
-
* @returns A boolean indicating
|
|
41
|
+
* Checks if two values are deeply equal.
|
|
42
|
+
* @param obj1 - The first value to compare.
|
|
43
|
+
* @param obj2 - The second value to compare.
|
|
44
|
+
* @returns A boolean indicating if the values are deeply equal.
|
|
45
|
+
* @deprecated Use Utilities.Object.deepEqual instead.
|
|
26
46
|
*/
|
|
27
47
|
static deepEqual(obj1: any, obj2: any): boolean;
|
|
28
48
|
/**
|
|
29
|
-
* Flattens a nested object into a single-level object with dot
|
|
49
|
+
* Flattens a nested object into a single-level object with dot-separated keys.
|
|
30
50
|
* @param object - The object to flatten.
|
|
31
|
-
* @param depth - The maximum depth to
|
|
32
|
-
* @returns
|
|
51
|
+
* @param depth - The maximum depth to flatten (default is 10).
|
|
52
|
+
* @returns A new object with flattened keys.
|
|
53
|
+
* @deprecated Use Utilities.Flatten.object instead.
|
|
33
54
|
*/
|
|
34
55
|
static flattenObject<T extends object, D extends number = 10>(object: T, depth?: D): Utilities.Flatten.Object<T, D>;
|
|
35
|
-
private static flattenCore;
|
|
36
56
|
/**
|
|
37
|
-
*
|
|
38
|
-
* @
|
|
39
|
-
* @
|
|
40
|
-
* @
|
|
57
|
+
* Unflattens a flattened object back into its original nested structure.
|
|
58
|
+
* @param obj - The flattened object to unflatten.
|
|
59
|
+
* @returns A new object with the original nested structure.
|
|
60
|
+
* @deprecated Use Utilities.Flatten.unObject instead.
|
|
41
61
|
*/
|
|
42
62
|
static unFlattenObject<Result extends any = any>(obj: any): Result;
|
|
43
63
|
/**
|
|
44
|
-
* Pauses
|
|
64
|
+
* Pauses execution for a specified duration.
|
|
45
65
|
* @param ms - The number of milliseconds to sleep.
|
|
46
66
|
* @returns A promise that resolves after the given time.
|
|
67
|
+
* @deprecated Use Utilities.Time.sleep instead.
|
|
47
68
|
*/
|
|
48
69
|
static sleep(ms: number): Promise<void>;
|
|
49
70
|
/**
|
|
50
71
|
* Encodes a string to base64url format.
|
|
51
|
-
* @param data - The string
|
|
72
|
+
* @param data - The string to encode.
|
|
52
73
|
* @returns The base64url-encoded string.
|
|
74
|
+
* @deprecated Use Utilities.Encoding.base64UrlEncode instead.
|
|
53
75
|
*/
|
|
54
76
|
static base64UrlEncode(data: string): string;
|
|
55
77
|
/**
|
|
56
78
|
* Decodes a base64url-encoded string.
|
|
57
|
-
* @param data - The base64url-encoded string
|
|
58
|
-
* @returns The decoded string.
|
|
79
|
+
* @param data - The base64url-encoded string to decode.
|
|
80
|
+
* @returns The decoded UTF-8 string.
|
|
81
|
+
* @deprecated Use Utilities.Encoding.base64UrlDecode instead.
|
|
59
82
|
*/
|
|
60
83
|
static base64UrlDecode(data: string): string;
|
|
61
84
|
}
|
|
@@ -64,28 +87,19 @@ export declare namespace Utilities {
|
|
|
64
87
|
export import Env = _Env;
|
|
65
88
|
export import ConsoleUI = _ConsoleUI;
|
|
66
89
|
export import DebugUI = _DebugUI;
|
|
90
|
+
export import Schema = _Schema;
|
|
91
|
+
export import Flatten = _Flatten;
|
|
92
|
+
export import File = _File;
|
|
93
|
+
export import Object = _Object;
|
|
94
|
+
export import Encoding = _Encoding;
|
|
95
|
+
export import Time = _Time;
|
|
67
96
|
namespace Types {
|
|
68
97
|
type NumListAdd = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
|
|
69
98
|
type strToNum<str extends string> = str extends `${infer num extends number}` ? num : never;
|
|
70
|
-
/**
|
|
71
|
-
* Adds one to a number type.
|
|
72
|
-
* @template Number the number to add one to.
|
|
73
|
-
* @returns The number incremented by one.
|
|
74
|
-
*/
|
|
75
99
|
export type Inc<Number extends number | string> = (`${Number}` extends `${infer surPlus}${NumListAdd[number]}` ? `${Number}` extends `${surPlus}${infer unit extends number}` ? unit extends Exclude<NumListAdd[number], 9> ? strToNum<`${surPlus}${NumListAdd[unit]}`> : strToNum<`${surPlus extends `${infer Num extends number}` ? '' : '1'}${surPlus extends '' ? '' : Inc<surPlus>}${NumListAdd[unit]}`> : number : number);
|
|
76
|
-
/**
|
|
77
|
-
* Converts a union of object types into an intersection type.
|
|
78
|
-
* @template U the union to convert.
|
|
79
|
-
* @returns The intersection type of the given union.
|
|
80
|
-
*/
|
|
81
100
|
export type UnionToIntersection<U extends object> = ((U extends any ? (arg: U) => void : never) extends (arg: infer I) => void ? I extends object ? {
|
|
82
101
|
[K in keyof I]: I[K] extends object ? UnionToIntersection<I[K]> : I[K];
|
|
83
102
|
} : I : never);
|
|
84
|
-
/**
|
|
85
|
-
* Converts properties with `undefined` in an object type to optional properties.
|
|
86
|
-
* @template T the object to convert.
|
|
87
|
-
* @returns The object type with properties containing `undefined` marked as optional.
|
|
88
|
-
*/
|
|
89
103
|
export type undefinedToPartial<T extends object> = {
|
|
90
104
|
[K in keyof T as undefined extends T[K] ? never : K]: T[K];
|
|
91
105
|
} & {
|
|
@@ -96,63 +110,7 @@ export declare namespace Utilities {
|
|
|
96
110
|
};
|
|
97
111
|
export {};
|
|
98
112
|
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Generates a union of all possible flattened keys for a given object type and depth.
|
|
102
|
-
* @template T the object to flatten.
|
|
103
|
-
* @template depth - The maximum depth to flatten.
|
|
104
|
-
* @template index - The current recursion index (internal use).
|
|
105
|
-
* @returns A union type of the flattened keys.
|
|
106
|
-
*/
|
|
107
|
-
type ResourceKeys<T extends Types.Document, depth extends number = 5, index extends number = 1> = {
|
|
108
|
-
[K in keyof T]-?: depth extends index ? K & string : Exclude<T[K], undefined> extends infer U ? U extends any[] ? K & string : U extends object ? `${K & string}.${ResourceKeys<U, depth, Types.Inc<index>>}` : K & string : "fail_in_flatten_inference";
|
|
109
|
-
}[keyof T];
|
|
110
|
-
/**
|
|
111
|
-
* Recursively retrieves the type of a value based on a flattened key path.
|
|
112
|
-
* @template T the object to flatten.
|
|
113
|
-
* @template Keys - The flattened key path string.
|
|
114
|
-
* @returns The type of the value at the specified key path, or `never` if the path is invalid.
|
|
115
|
-
*/
|
|
116
|
-
type RecurseObject<T extends Types.Document, Keys extends string> = (Keys extends `${infer K}.${infer Rest}` ? K extends keyof T ? undefined extends T[K] ? RecurseObject<Exclude<T[K], undefined>, Rest> | undefined : RecurseObject<T[K], Rest> : never : undefined extends T ? Keys extends keyof Exclude<T, undefined> ? Exclude<T, undefined>[Keys] | undefined : never : Keys extends keyof T ? T[Keys] : never);
|
|
117
|
-
/**
|
|
118
|
-
* Represents the type of a flattened object up to a specified depth.
|
|
119
|
-
* @template T the object to flatten.
|
|
120
|
-
* @template depth - The maximum depth of flattening.
|
|
121
|
-
* @template index the current index.
|
|
122
|
-
* @returns the flattened object.
|
|
123
|
-
*/
|
|
124
|
-
export type Object<T extends Types.Document, depth extends number = 5, index extends number = 1> = Types.undefinedToPartial<{
|
|
125
|
-
[P in ResourceKeys<T, depth, index>]: RecurseObject<T, P>;
|
|
126
|
-
}>;
|
|
127
|
-
export {};
|
|
128
|
-
}
|
|
129
|
-
namespace UnFlatten {
|
|
130
|
-
/**
|
|
131
|
-
* Splits a string into a tuple of strings based on a delimiter.
|
|
132
|
-
* @template S - The string to split.
|
|
133
|
-
* @template Delimiter - The delimiter to split by.
|
|
134
|
-
* @returns the split string.
|
|
135
|
-
*/
|
|
136
|
-
type Split<S extends string, Delimiter extends string> = (S extends `${infer T}${Delimiter}${infer U}` ? [T, ...Split<U, Delimiter>] : [S]);
|
|
137
|
-
/**
|
|
138
|
-
* Builds a nested object type from a string path and a value type.
|
|
139
|
-
* @template Path - The path of keys as a string array.
|
|
140
|
-
* @template Value - The type of the value at the end of the path.
|
|
141
|
-
* @returns the nested object.
|
|
142
|
-
*/
|
|
143
|
-
type BuildNestedObject<Path extends string[], Value> = (Path extends [infer Head extends string, ...infer Tail extends string[]] ? Types.undefinedToPartial<{
|
|
144
|
-
[K in Head]: BuildNestedObject<Tail, Value>;
|
|
145
|
-
}> : Value);
|
|
146
|
-
/**
|
|
147
|
-
* Represents the type of a nested object reconstructed from a flattened object.
|
|
148
|
-
* @template T - The type of the flattened object.
|
|
149
|
-
* @returns the unFlattened object.
|
|
150
|
-
*/
|
|
151
|
-
export type Object<T extends Types.Document> = Types.UnionToIntersection<Types.undefinedToPartial<({
|
|
152
|
-
[K in keyof T]-?: BuildNestedObject<Split<Extract<K, string>, ".">, T[K]>;
|
|
153
|
-
}[keyof T])>>;
|
|
154
|
-
export {};
|
|
155
|
-
}
|
|
113
|
+
type FlattenObject<T extends Types.Document, depth extends number = 5> = Flatten.Object<T, depth>;
|
|
156
114
|
interface env {
|
|
157
115
|
[key: string]: string;
|
|
158
116
|
}
|