vortez 5.0.0-dev.18 → 5.0.0-dev.19
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 +9 -4
- package/README.md +681 -176
- package/build/Vortez.d.ts +1 -0
- package/build/Vortez.js +1 -0
- package/build/Vortez.js.map +1 -1
- package/build/server/Response.d.ts +1 -1
- package/build/server/Response.js +1 -1
- package/build/server/Response.js.map +1 -1
- package/build/server/Server.d.ts +4 -4
- package/build/server/Server.js +5 -5
- 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 +274 -47
- package/build/server/config/Config.js +68 -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} +7 -10
- package/build/server/config/Loader.js.map +1 -0
- package/build/server/router/Router.d.ts +87 -30
- package/build/server/router/Router.js +110 -48
- 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/WsMiddleware.js +1 -1
- package/build/server/router/middleware/WsMiddleware.js.map +1 -1
- package/build/utilities/Flatten.d.ts +56 -0
- package/build/utilities/Flatten.js +59 -0
- package/build/utilities/Flatten.js.map +1 -0
- package/build/utilities/Utilities.d.ts +7 -58
- package/build/utilities/Utilities.js +8 -33
- 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/package.json +1 -1
- package/tests/config/config.js +233 -0
- package/tests/router.js +596 -0
- package/tests/schema/schema.js +368 -0
- package/tests/test.env +0 -0
- package/tests/test.js +3 -3
- 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
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import Algorithm from './Algorithm.js';
|
|
2
|
+
import FIFO from './FIFO.js';
|
|
3
|
+
class RouteNode {
|
|
4
|
+
statics;
|
|
5
|
+
params;
|
|
6
|
+
wildcard;
|
|
7
|
+
rules;
|
|
8
|
+
constructor() {
|
|
9
|
+
this.statics = new Map();
|
|
10
|
+
this.rules = new FIFO();
|
|
11
|
+
}
|
|
12
|
+
get allRules() {
|
|
13
|
+
const rules = [...this.rules.allRules];
|
|
14
|
+
if (this.wildcard)
|
|
15
|
+
rules.push(...this.wildcard.allRules);
|
|
16
|
+
if (this.params)
|
|
17
|
+
rules.push(...this.params.node.allRules);
|
|
18
|
+
for (const node of this.statics.values())
|
|
19
|
+
rules.push(...node.allRules);
|
|
20
|
+
return rules;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export class Tree extends Algorithm {
|
|
24
|
+
root;
|
|
25
|
+
constructor() {
|
|
26
|
+
super();
|
|
27
|
+
this.root = new RouteNode();
|
|
28
|
+
}
|
|
29
|
+
get allRules() { return this.root.allRules; }
|
|
30
|
+
add(...rules) {
|
|
31
|
+
for (const rule of rules) {
|
|
32
|
+
const segments = this.splitPath(rule.urlRule);
|
|
33
|
+
let currentNode = this.root;
|
|
34
|
+
for (let index = 0; index < segments.length; index++) {
|
|
35
|
+
const segment = segments[index];
|
|
36
|
+
if (segment === '*') {
|
|
37
|
+
currentNode.wildcard ??= new RouteNode();
|
|
38
|
+
currentNode = currentNode.wildcard;
|
|
39
|
+
}
|
|
40
|
+
else if (segment.startsWith('$')) {
|
|
41
|
+
const isOptional = segment.startsWith('$?');
|
|
42
|
+
const paramName = segment.replace(/^\$\??/, '');
|
|
43
|
+
if (isOptional && index === segments.length - 1) {
|
|
44
|
+
currentNode.rules.add(rule);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
currentNode.params ??= { name: paramName, isOptional, node: new RouteNode() };
|
|
48
|
+
currentNode = currentNode.params.node;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
if (!currentNode.statics.has(segment)) {
|
|
52
|
+
currentNode.statics.set(segment, new RouteNode());
|
|
53
|
+
}
|
|
54
|
+
currentNode = currentNode.statics.get(segment);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
currentNode.rules.add(rule);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Route a request to a rule.
|
|
62
|
+
* @param request - The request to route.
|
|
63
|
+
* @param client - The client to route the request to.
|
|
64
|
+
* @returns True if the request was routed, false otherwise.
|
|
65
|
+
*/
|
|
66
|
+
routeHttp(request, client) {
|
|
67
|
+
request.ruleParams = {};
|
|
68
|
+
const node = this.navigate(request);
|
|
69
|
+
if (!node)
|
|
70
|
+
return false;
|
|
71
|
+
return node.rules.route(request, client);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Route a websocket to a rule.
|
|
75
|
+
* @param request - The request to route.
|
|
76
|
+
* @param client - The client to route the request to.
|
|
77
|
+
* @returns True if the request was routed, false otherwise.
|
|
78
|
+
*/
|
|
79
|
+
routeWebsocket(request, client) {
|
|
80
|
+
request.ruleParams = {};
|
|
81
|
+
const node = this.navigate(request);
|
|
82
|
+
if (!node)
|
|
83
|
+
return false;
|
|
84
|
+
return node.rules.route(request, client);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Navigate to a route node.
|
|
88
|
+
* @param request - The request to navigate to.
|
|
89
|
+
* @returns The route node or null if not found.
|
|
90
|
+
*/
|
|
91
|
+
navigate(request) {
|
|
92
|
+
const segments = this.splitPath(request.url);
|
|
93
|
+
let currentNode = this.root;
|
|
94
|
+
for (const segment of segments) {
|
|
95
|
+
if (currentNode.statics.has(segment)) {
|
|
96
|
+
currentNode = currentNode.statics.get(segment);
|
|
97
|
+
}
|
|
98
|
+
else if (currentNode.params) {
|
|
99
|
+
const { name, node } = currentNode.params;
|
|
100
|
+
request.ruleParams[name] = segment;
|
|
101
|
+
currentNode = node;
|
|
102
|
+
}
|
|
103
|
+
else if (currentNode.wildcard) {
|
|
104
|
+
currentNode = currentNode.wildcard;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
else if (currentNode.rules.allRules.some((rule) => rule.test(request))) {
|
|
108
|
+
return currentNode;
|
|
109
|
+
}
|
|
110
|
+
else
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
return currentNode;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Split a path into segments.
|
|
117
|
+
* @param path - The path to split.
|
|
118
|
+
* @returns An array of segments.
|
|
119
|
+
*/
|
|
120
|
+
splitPath(path) {
|
|
121
|
+
return path.split('/').filter(p => p.length > 0);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
;
|
|
125
|
+
export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MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC;gBAC1C,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;gBACnC,WAAW,GAAG,IAAI,CAAC;YACvB,CAAC;iBAAM,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;gBAC9B,WAAW,GAAG,WAAW,CAAC,QAAQ,CAAC;gBACnC,MAAM;YACV,CAAC;iBAAM,IAAI,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;gBACvE,OAAO,WAAW,CAAC;YACvB,CAAC;;gBAAM,OAAO,IAAI,CAAC;QACvB,CAAC;QACD,OAAO,WAAW,CAAC;IACvB,CAAC;IACD;;;;OAIG;IACK,SAAS,CAAC,IAAY;QAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACrD,CAAC;CACJ;AACuB,CAAC;AACzB,eAAe,IAAI,CAAC"}
|
|
@@ -8,7 +8,7 @@ import LoggerManager from '../../LoggerManager.js';
|
|
|
8
8
|
import Middleware from './Middleware.js';
|
|
9
9
|
const logger = LoggerManager.getInstance();
|
|
10
10
|
export class WsMiddleware extends Middleware {
|
|
11
|
-
clone() { return new WsMiddleware(this.pipeline); }
|
|
11
|
+
clone() { return new WsMiddleware(this.pipeline, this.errorPipeline); }
|
|
12
12
|
/**
|
|
13
13
|
* Runs the middleware pipeline.
|
|
14
14
|
* @param request The request received by the server.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WsMiddleware.js","sourceRoot":"","sources":["../../../../src/server/router/middleware/WsMiddleware.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,WAAW,M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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
|
+
*/
|
|
11
|
+
static object<T extends Flatten.Document, D extends number = 10>(object: T, depth?: D): Flatten.Object<T, D>;
|
|
12
|
+
/**
|
|
13
|
+
* Reconstructs a nested object from dot-notation keys.
|
|
14
|
+
*/
|
|
15
|
+
static unObject<Result extends any = any>(obj: Flatten.Document): Result;
|
|
16
|
+
private static flattenCore;
|
|
17
|
+
private static isPlainObject;
|
|
18
|
+
}
|
|
19
|
+
export declare namespace Flatten {
|
|
20
|
+
export type Document = {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
};
|
|
23
|
+
type Prettify<T> = {
|
|
24
|
+
[K in keyof T]: T[K];
|
|
25
|
+
} & {};
|
|
26
|
+
type Primitive = string | number | boolean | bigint | symbol | null | undefined;
|
|
27
|
+
type Builtin = Primitive | Date | RegExp | Function | Error | Promise<any> | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any>;
|
|
28
|
+
type IsLeaf<T> = T extends Builtin ? true : T extends readonly any[] ? true : false;
|
|
29
|
+
type UndefinedToPartial<T extends object> = {
|
|
30
|
+
[K in keyof T as undefined extends T[K] ? never : K]: T[K];
|
|
31
|
+
} & {
|
|
32
|
+
[K in keyof T as undefined extends T[K] ? K : never]?: Exclude<T[K], undefined>;
|
|
33
|
+
};
|
|
34
|
+
type UnionToIntersection<U extends object> = ((U extends any ? (arg: U) => void : never) extends (arg: infer I) => void ? I extends object ? {
|
|
35
|
+
[K in keyof I]: I[K] extends object ? UnionToIntersection<I[K]> : I[K];
|
|
36
|
+
} : I : never);
|
|
37
|
+
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]>);
|
|
38
|
+
type NextDepth<D extends 1[]> = D extends [1, ...infer R extends 1[]] ? R : [];
|
|
39
|
+
type Join<Prefix extends string, Key extends string> = Prefix extends '' ? Key : `${Prefix}.${Key}`;
|
|
40
|
+
type ResourceKeys<T extends Document, D extends 1[] = DepthTuple<5>, Prefix extends string = ''> = {
|
|
41
|
+
[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);
|
|
42
|
+
}[Extract<keyof T, string>];
|
|
43
|
+
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);
|
|
44
|
+
export type Object<T extends Document, depth extends number = 5> = Prettify<UndefinedToPartial<{
|
|
45
|
+
[P in ResourceKeys<T, DepthTuple<depth>>]: RecurseObject<T, P>;
|
|
46
|
+
}>>;
|
|
47
|
+
type Split<S extends string, Delimiter extends string> = (S extends `${infer T}${Delimiter}${infer U}` ? [T, ...Split<U, Delimiter>] : [S]);
|
|
48
|
+
type BuildNestedObject<Path extends string[], Value> = (Path extends [infer Head extends string, ...infer Tail extends string[]] ? UndefinedToPartial<{
|
|
49
|
+
[K in Head]: BuildNestedObject<Tail, Value>;
|
|
50
|
+
}> : Value);
|
|
51
|
+
export type UnObject<T extends Document> = Prettify<UnionToIntersection<UndefinedToPartial<({
|
|
52
|
+
[K in keyof T]-?: BuildNestedObject<Split<Extract<K, string>, '.'>, T[K]>;
|
|
53
|
+
}[keyof T])>>>;
|
|
54
|
+
export {};
|
|
55
|
+
}
|
|
56
|
+
export default Flatten;
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
*/
|
|
11
|
+
static object(object, depth = 10) {
|
|
12
|
+
return this.flattenCore(object, depth);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Reconstructs a nested object from dot-notation keys.
|
|
16
|
+
*/
|
|
17
|
+
static unObject(obj) {
|
|
18
|
+
const result = {};
|
|
19
|
+
for (const key in obj) {
|
|
20
|
+
const value = obj[key];
|
|
21
|
+
const [first, ...rest] = key.split('.');
|
|
22
|
+
if (rest.length === 0)
|
|
23
|
+
result[first] = value;
|
|
24
|
+
else {
|
|
25
|
+
const last = rest.pop();
|
|
26
|
+
const subObj = result[first] ?? {};
|
|
27
|
+
let current = subObj;
|
|
28
|
+
rest.forEach((k) => {
|
|
29
|
+
current = current[k] ?? (current[k] = {});
|
|
30
|
+
});
|
|
31
|
+
current[last] = value;
|
|
32
|
+
result[first] = subObj;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
static flattenCore(object, depth = 10, prefix = '') {
|
|
38
|
+
const result = {};
|
|
39
|
+
for (const key in object) {
|
|
40
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
41
|
+
const value = object[key];
|
|
42
|
+
if (depth > 0 && this.isPlainObject(value)) {
|
|
43
|
+
Object.assign(result, this.flattenCore(value, depth - 1, newKey));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
result[newKey] = value;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
static isPlainObject(value) {
|
|
52
|
+
if (value == null || typeof value !== 'object' || Array.isArray(value))
|
|
53
|
+
return false;
|
|
54
|
+
const proto = Object.getPrototypeOf(value);
|
|
55
|
+
return proto === Object.prototype || proto === null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export default Flatten;
|
|
59
|
+
//# 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;;;OAGG;IACI,MAAM,CAAC,MAAM,CAChB,MAAS,EACT,QAAW,EAAO;QAElB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,CAAyB,CAAC;IACnE,CAAC;IAED;;OAEG;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,CAA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AAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;IACxD,CAAC;CACJ;AAsGD,eAAe,OAAO,CAAC"}
|
|
@@ -7,10 +7,14 @@ import _Path from './Path.js';
|
|
|
7
7
|
import _Env from './Env.js';
|
|
8
8
|
import _ConsoleUI from './ConsoleUI.js';
|
|
9
9
|
import _DebugUI from './DebugUI.js';
|
|
10
|
+
import _Schema from './schema/Schema.js';
|
|
11
|
+
import _Flatten from './Flatten.js';
|
|
10
12
|
export { Path } from './Path.js';
|
|
11
13
|
export { Env } from './Env.js';
|
|
12
14
|
export { ConsoleUI } from './ConsoleUI.js';
|
|
13
15
|
export { DebugUI } from './DebugUI.js';
|
|
16
|
+
export { Schema } from './schema/Schema.js';
|
|
17
|
+
export { Flatten } from './Flatten.js';
|
|
14
18
|
export declare class Utilities {
|
|
15
19
|
/**
|
|
16
20
|
* Checks if a file exists asynchronously.
|
|
@@ -32,7 +36,6 @@ export declare class Utilities {
|
|
|
32
36
|
* @returns The flattened object.
|
|
33
37
|
*/
|
|
34
38
|
static flattenObject<T extends object, D extends number = 10>(object: T, depth?: D): Utilities.Flatten.Object<T, D>;
|
|
35
|
-
private static flattenCore;
|
|
36
39
|
/**
|
|
37
40
|
* Reconstructs a nested object from a flattened object with dot notation keys.
|
|
38
41
|
* @template Result - The type of the unflattened object.
|
|
@@ -64,6 +67,8 @@ export declare namespace Utilities {
|
|
|
64
67
|
export import Env = _Env;
|
|
65
68
|
export import ConsoleUI = _ConsoleUI;
|
|
66
69
|
export import DebugUI = _DebugUI;
|
|
70
|
+
export import Schema = _Schema;
|
|
71
|
+
export import Flatten = _Flatten;
|
|
67
72
|
namespace Types {
|
|
68
73
|
type NumListAdd = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
|
|
69
74
|
type strToNum<str extends string> = str extends `${infer num extends number}` ? num : never;
|
|
@@ -96,63 +101,7 @@ export declare namespace Utilities {
|
|
|
96
101
|
};
|
|
97
102
|
export {};
|
|
98
103
|
}
|
|
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
|
-
}
|
|
104
|
+
type FlattenObject<T extends Types.Document, depth extends number = 5> = Flatten.Object<T, depth>;
|
|
156
105
|
interface env {
|
|
157
106
|
[key: string]: string;
|
|
158
107
|
}
|
|
@@ -8,10 +8,14 @@ import _Path from './Path.js';
|
|
|
8
8
|
import _Env from './Env.js';
|
|
9
9
|
import _ConsoleUI from './ConsoleUI.js';
|
|
10
10
|
import _DebugUI from './DebugUI.js';
|
|
11
|
+
import _Schema from './schema/Schema.js';
|
|
12
|
+
import _Flatten from './Flatten.js';
|
|
11
13
|
export { Path } from './Path.js';
|
|
12
14
|
export { Env } from './Env.js';
|
|
13
15
|
export { ConsoleUI } from './ConsoleUI.js';
|
|
14
16
|
export { DebugUI } from './DebugUI.js';
|
|
17
|
+
export { Schema } from './schema/Schema.js';
|
|
18
|
+
export { Flatten } from './Flatten.js';
|
|
15
19
|
export class Utilities {
|
|
16
20
|
/**
|
|
17
21
|
* Checks if a file exists asynchronously.
|
|
@@ -50,21 +54,7 @@ export class Utilities {
|
|
|
50
54
|
* @returns The flattened object.
|
|
51
55
|
*/
|
|
52
56
|
static flattenObject(object, depth = 10) {
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
static flattenCore(object, depth = 10, prefix = '') {
|
|
56
|
-
const result = {};
|
|
57
|
-
for (const key in object) {
|
|
58
|
-
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
59
|
-
const value = object[key];
|
|
60
|
-
if (typeof value === 'object' && !Array.isArray(value) && value !== null && depth > 0) {
|
|
61
|
-
Object.assign(result, Utilities.flattenCore(value, depth - 1, newKey));
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
result[newKey] = value;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return result;
|
|
57
|
+
return Utilities.Flatten.object(object, depth);
|
|
68
58
|
}
|
|
69
59
|
/**
|
|
70
60
|
* Reconstructs a nested object from a flattened object with dot notation keys.
|
|
@@ -73,24 +63,7 @@ export class Utilities {
|
|
|
73
63
|
* @returns The unflattened object.
|
|
74
64
|
*/
|
|
75
65
|
static unFlattenObject(obj) {
|
|
76
|
-
|
|
77
|
-
for (const key in obj) {
|
|
78
|
-
const value = obj[key];
|
|
79
|
-
const [first, ...rest] = key.split('.');
|
|
80
|
-
if (rest.length === 0)
|
|
81
|
-
result[first] = value;
|
|
82
|
-
else {
|
|
83
|
-
const last = rest.pop();
|
|
84
|
-
const subObj = result[first] ?? {};
|
|
85
|
-
let current = subObj;
|
|
86
|
-
rest.forEach((k) => {
|
|
87
|
-
current = current[k] ?? (current[k] = {});
|
|
88
|
-
});
|
|
89
|
-
current[last] = value;
|
|
90
|
-
result[first] = subObj;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return result;
|
|
66
|
+
return Utilities.Flatten.unObject(obj);
|
|
94
67
|
}
|
|
95
68
|
/**
|
|
96
69
|
* Pauses the execution of the program for a specified duration.
|
|
@@ -122,6 +95,8 @@ export class Utilities {
|
|
|
122
95
|
Utilities.Env = _Env;
|
|
123
96
|
Utilities.ConsoleUI = _ConsoleUI;
|
|
124
97
|
Utilities.DebugUI = _DebugUI;
|
|
98
|
+
Utilities.Schema = _Schema;
|
|
99
|
+
Utilities.Flatten = _Flatten;
|
|
125
100
|
})(Utilities || (Utilities = {}));
|
|
126
101
|
export default Utilities;
|
|
127
102
|
//# sourceMappingURL=Utilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utilities.js","sourceRoot":"","sources":["../../src/utilities/Utilities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,IAAI,GAAG,EAAE,MAAM,IAAI,CAAC;AAErC,OAAO,KAAK,MAAM,WAAW,CAAC;AAC9B,OAAO,IAAI,MAAM,UAAU,CAAC;AAC5B,OAAO,UAAU,MAAM,gBAAgB,CAAC;AACxC,OAAO,QAAQ,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,OAAO,SAAS;IAClB;;;;OAIG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,IAAY;QACvC,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC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MAAS,EAAE,QAAW,EAAO;QAC9F,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,MAAkC,EAAE,KAAK,CAAmC,CAAC;IACjH,CAAC;IACD;;;;;OAKG;IACI,MAAM,CAAC,eAAe,CAA2B,GAAQ;QAC5D,OAAO,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAS,GAAiC,CAAC,CAAC;IACjF,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;IACD;;;;OAIG;IACI,MAAM,CAAC,eAAe,CAAC,IAAY;QACtC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,eAAe,CAAC,IAAY;QACtC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;CACJ;AAED,WAAiB,SAAS;IACR,cAAI,GAAG,KAAK,CAAC;IACb,aAAG,GAAG,IAAI,CAAC;IACX,mBAAS,GAAG,UAAU,CAAC;IACvB,iBAAO,GAAG,QAAQ,CAAC;IACnB,gBAAM,GAAG,OAAO,CAAC;IACjB,iBAAO,GAAG,QAAQ,CAAC;AAyDrC,CAAC,EA/DgB,SAAS,KAAT,SAAS,QA+DzB;AACD,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>
|
|
3
|
+
* @description Provides utilities for schema introspection, including listing unique properties and converting custom schemas to JSON Schema format.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { JSONSchema } from './JSONSchema.js';
|
|
7
|
+
import type { Schema } from './Schema.js';
|
|
8
|
+
export declare class Introspection {
|
|
9
|
+
/**
|
|
10
|
+
* Lists all unique properties in a schema, including nested unique properties, and returns their full paths.
|
|
11
|
+
* @param doc The schema to list unique properties from
|
|
12
|
+
* @param parentKey The parent key of the current schema, used for building full paths of nested properties
|
|
13
|
+
* @returns An array of full paths to unique properties in the schema
|
|
14
|
+
*/
|
|
15
|
+
static listUniques(doc: Schema.Schema, parentKey?: string): string[];
|
|
16
|
+
/**
|
|
17
|
+
* Converts a schema to a JSON Schema, used for validating data against the schema and generating documentation.
|
|
18
|
+
* @param schema The schema to convert to JSON Schema
|
|
19
|
+
* @returns The JSON Schema representation of the input schema
|
|
20
|
+
*/
|
|
21
|
+
static toJsonSchema(schema: Schema.Schema): JSONSchema.schema;
|
|
22
|
+
}
|
|
23
|
+
export declare namespace Introspection { }
|
|
24
|
+
export default Introspection;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>
|
|
3
|
+
* @description Provides utilities for schema introspection, including listing unique properties and converting custom schemas to JSON Schema format.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export class Introspection {
|
|
7
|
+
/**
|
|
8
|
+
* Lists all unique properties in a schema, including nested unique properties, and returns their full paths.
|
|
9
|
+
* @param doc The schema to list unique properties from
|
|
10
|
+
* @param parentKey The parent key of the current schema, used for building full paths of nested properties
|
|
11
|
+
* @returns An array of full paths to unique properties in the schema
|
|
12
|
+
*/
|
|
13
|
+
static listUniques(doc, parentKey) {
|
|
14
|
+
const uniques = [];
|
|
15
|
+
for (const key in doc) {
|
|
16
|
+
const prop = doc[key];
|
|
17
|
+
if (key !== '_id' && prop.unique)
|
|
18
|
+
uniques.push(parentKey ? `${parentKey}.${key}` : key);
|
|
19
|
+
if (prop.type === 'object') {
|
|
20
|
+
uniques.push(...this.listUniques(prop.schema, parentKey ? `${parentKey}.${key}` : key));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return uniques;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Converts a schema to a JSON Schema, used for validating data against the schema and generating documentation.
|
|
27
|
+
* @param schema The schema to convert to JSON Schema
|
|
28
|
+
* @returns The JSON Schema representation of the input schema
|
|
29
|
+
*/
|
|
30
|
+
static toJsonSchema(schema) {
|
|
31
|
+
const sch = {};
|
|
32
|
+
sch.type = 'object';
|
|
33
|
+
sch.properties = {};
|
|
34
|
+
for (const key in schema) {
|
|
35
|
+
const prop = schema[key];
|
|
36
|
+
let subSch = {};
|
|
37
|
+
subSch.type = prop.nullable ? [prop.type, 'null'] : prop.type;
|
|
38
|
+
if (prop.required) {
|
|
39
|
+
if (sch.required == null)
|
|
40
|
+
sch.required = [];
|
|
41
|
+
sch.required.push(key);
|
|
42
|
+
}
|
|
43
|
+
switch (prop.type) {
|
|
44
|
+
case 'string': {
|
|
45
|
+
if (prop.enum !== undefined)
|
|
46
|
+
subSch.enum = [...prop.enum];
|
|
47
|
+
if (prop.minLength !== undefined)
|
|
48
|
+
subSch.minLength = prop.minLength;
|
|
49
|
+
if (prop.maxLength !== undefined)
|
|
50
|
+
subSch.maxLength = prop.maxLength;
|
|
51
|
+
if (prop.pattern !== undefined)
|
|
52
|
+
subSch.pattern = prop.pattern.source;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
case 'boolean': break;
|
|
56
|
+
case 'number': {
|
|
57
|
+
if (prop.minimum !== undefined)
|
|
58
|
+
subSch.minimum = prop.minimum;
|
|
59
|
+
if (prop.maximum !== undefined)
|
|
60
|
+
subSch.maximum = prop.maximum;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
case 'array': {
|
|
64
|
+
if (prop.minimum !== undefined)
|
|
65
|
+
subSch.minItems = prop.minimum;
|
|
66
|
+
if (prop.maximum !== undefined)
|
|
67
|
+
subSch.maxItems = prop.maximum;
|
|
68
|
+
const itemContainer = this.toJsonSchema({ item: prop.property });
|
|
69
|
+
const itemSchema = itemContainer.properties?.item;
|
|
70
|
+
if (itemSchema)
|
|
71
|
+
subSch.items = itemSchema;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case 'object': {
|
|
75
|
+
subSch = this.toJsonSchema(prop.schema);
|
|
76
|
+
if (prop.nullable)
|
|
77
|
+
subSch.type = ['object', 'null'];
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
sch.properties[key] = subSch;
|
|
82
|
+
}
|
|
83
|
+
return sch;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export default Introspection;
|
|
87
|
+
//# sourceMappingURL=Introspection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Introspection.js","sourceRoot":"","sources":["../../../src/utilities/schema/Introspection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,OAAO,aAAa;IACtB;;;;;OAKG;IACI,MAAM,CAAC,WAAW,CAAC,GAAkB,EAAE,SAAkB;QAC5D,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;YACpB,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACtB,IAAI,GAAG,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM;gBAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACxF,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACzB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC5F,CAAC;QACL,CA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|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>
|
|
3
|
+
* @description Provides type definitions for JSON Schema, a powerful tool for validating and describing the structure of JSON data.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export declare namespace JSONSchema {
|
|
7
|
+
type schemeArray = schemeTypes[];
|
|
8
|
+
type schemaObject = {
|
|
9
|
+
[key: string]: schemeTypes;
|
|
10
|
+
};
|
|
11
|
+
interface SchemaTypeMap {
|
|
12
|
+
string: string;
|
|
13
|
+
number: number;
|
|
14
|
+
boolean: boolean;
|
|
15
|
+
object: schemaObject;
|
|
16
|
+
array: schemeArray;
|
|
17
|
+
null: null;
|
|
18
|
+
}
|
|
19
|
+
type schemaNames = keyof SchemaTypeMap;
|
|
20
|
+
type schemeTypes = SchemaTypeMap[schemaNames];
|
|
21
|
+
type schemaVersion = string;
|
|
22
|
+
type schema = {
|
|
23
|
+
title?: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
multipleOf?: number;
|
|
26
|
+
maximum?: number;
|
|
27
|
+
exclusiveMaximum?: boolean;
|
|
28
|
+
minimum?: number;
|
|
29
|
+
exclusiveMinimum?: boolean;
|
|
30
|
+
maxLength?: number;
|
|
31
|
+
minLength?: number;
|
|
32
|
+
pattern?: string;
|
|
33
|
+
additionalItems?: schema;
|
|
34
|
+
items?: schema | schema[];
|
|
35
|
+
maxItems?: number;
|
|
36
|
+
minItems?: number;
|
|
37
|
+
uniqueItems?: boolean;
|
|
38
|
+
maxProperties?: number;
|
|
39
|
+
minProperties?: number;
|
|
40
|
+
required?: string[];
|
|
41
|
+
properties?: {
|
|
42
|
+
[key: string]: schema;
|
|
43
|
+
};
|
|
44
|
+
additionalProperties?: boolean | schema;
|
|
45
|
+
patternProperties?: {
|
|
46
|
+
[key: string]: schema;
|
|
47
|
+
};
|
|
48
|
+
dependencies?: {
|
|
49
|
+
[key: string]: string[] | schema;
|
|
50
|
+
};
|
|
51
|
+
enum?: schemeTypes[];
|
|
52
|
+
type?: schemaNames | schemaNames[];
|
|
53
|
+
allOf?: schema[];
|
|
54
|
+
anyOf?: schema[];
|
|
55
|
+
oneOf?: schema[];
|
|
56
|
+
not?: schema;
|
|
57
|
+
extends?: string | string[];
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* provide the type definition of a json schema
|
|
62
|
+
* @param schema the json schema to validate
|
|
63
|
+
*/
|
|
64
|
+
export declare function schema(schema: JSONSchema.schema): JSONSchema.schema;
|
|
65
|
+
export declare const JSONSchema: {
|
|
66
|
+
schema: typeof schema;
|
|
67
|
+
};
|
|
68
|
+
export default JSONSchema;
|