@scpxl/nodejs-framework 1.0.22 → 1.0.24
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 +199 -9
- package/dist/api-requester/api-requester.d.ts +32 -0
- package/dist/api-requester/api-requester.d.ts.map +1 -0
- package/dist/api-requester/index.d.ts +3 -0
- package/dist/api-requester/index.d.ts.map +1 -0
- package/dist/application/base-application.d.ts +106 -0
- package/dist/application/base-application.d.ts.map +1 -0
- package/dist/application/base-application.interface.d.ts +162 -0
- package/dist/application/base-application.interface.d.ts.map +1 -0
- package/dist/application/base-application.js +3 -0
- package/dist/application/base-application.js.map +2 -2
- package/dist/application/command-application.d.ts +18 -0
- package/dist/application/command-application.d.ts.map +1 -0
- package/dist/application/command-application.interface.d.ts +26 -0
- package/dist/application/command-application.interface.d.ts.map +1 -0
- package/dist/application/index.d.ts +5 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/web-application.d.ts +43 -0
- package/dist/application/web-application.d.ts.map +1 -0
- package/dist/application/web-application.interface.d.ts +21 -0
- package/dist/application/web-application.interface.d.ts.map +1 -0
- package/dist/application/web-application.js +1 -0
- package/dist/application/web-application.js.map +2 -2
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/jwt.d.ts +25 -0
- package/dist/auth/jwt.d.ts.map +1 -0
- package/dist/cache/index.d.ts +2 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/manager.d.ts +107 -0
- package/dist/cache/manager.d.ts.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +5655 -0
- package/dist/cli/index.js.map +7 -0
- package/dist/cluster/cluster-manager.d.ts +15 -0
- package/dist/cluster/cluster-manager.d.ts.map +1 -0
- package/dist/cluster/cluster-manager.interface.d.ts +23 -0
- package/dist/cluster/cluster-manager.interface.d.ts.map +1 -0
- package/dist/cluster/index.d.ts +2 -0
- package/dist/cluster/index.d.ts.map +1 -0
- package/dist/command/command-manager.d.ts +19 -0
- package/dist/command/command-manager.d.ts.map +1 -0
- package/dist/command/command.d.ts +27 -0
- package/dist/command/command.d.ts.map +1 -0
- package/dist/command/command.interface.d.ts +11 -0
- package/dist/command/command.interface.d.ts.map +1 -0
- package/dist/command/index.d.ts +3 -0
- package/dist/command/index.d.ts.map +1 -0
- package/dist/config/env.d.ts +11 -0
- package/dist/config/env.d.ts.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/schema.d.ts +432 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/database/dynamic-entity-form-decorators.d.ts +31 -0
- package/dist/database/dynamic-entity-form-decorators.d.ts.map +1 -0
- package/dist/database/dynamic-entity.d.ts +15 -0
- package/dist/database/dynamic-entity.d.ts.map +1 -0
- package/dist/database/index.d.ts +5 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/instance.d.ts +36 -0
- package/dist/database/instance.d.ts.map +1 -0
- package/dist/database/instance.interface.d.ts +5 -0
- package/dist/database/instance.interface.d.ts.map +1 -0
- package/dist/database/manager.d.ts +27 -0
- package/dist/database/manager.d.ts.map +1 -0
- package/dist/database/manager.interface.d.ts +18 -0
- package/dist/database/manager.interface.d.ts.map +1 -0
- package/dist/error/error-reporter.d.ts +96 -0
- package/dist/error/error-reporter.d.ts.map +1 -0
- package/dist/error/error.interface.d.ts +126 -0
- package/dist/error/error.interface.d.ts.map +1 -0
- package/dist/error/framework-errors.d.ts +113 -0
- package/dist/error/framework-errors.d.ts.map +1 -0
- package/dist/error/index.d.ts +6 -0
- package/dist/error/index.d.ts.map +1 -0
- package/dist/event/controller/base.d.ts +23 -0
- package/dist/event/controller/base.d.ts.map +1 -0
- package/dist/event/controller/base.interface.d.ts +11 -0
- package/dist/event/controller/base.interface.d.ts.map +1 -0
- package/dist/event/index.d.ts +5 -0
- package/dist/event/index.d.ts.map +1 -0
- package/dist/event/manager.d.ts +21 -0
- package/dist/event/manager.d.ts.map +1 -0
- package/dist/event/manager.interface.d.ts +137 -0
- package/dist/event/manager.interface.d.ts.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lifecycle/exit.d.ts +11 -0
- package/dist/lifecycle/exit.d.ts.map +1 -0
- package/dist/lifecycle/index.d.ts +7 -0
- package/dist/lifecycle/index.d.ts.map +1 -0
- package/dist/lifecycle/lifecycle-manager.d.ts +66 -0
- package/dist/lifecycle/lifecycle-manager.d.ts.map +1 -0
- package/dist/lifecycle/lifecycle-manager.js +6 -11
- package/dist/lifecycle/lifecycle-manager.js.map +2 -2
- package/dist/lifecycle/shutdown-controller.d.ts +15 -0
- package/dist/lifecycle/shutdown-controller.d.ts.map +1 -0
- package/dist/lifecycle/types.d.ts +28 -0
- package/dist/lifecycle/types.d.ts.map +1 -0
- package/dist/logger/index.d.ts +2 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/logger.d.ts +59 -0
- package/dist/logger/logger.d.ts.map +1 -0
- package/dist/logger/logger.interface.d.ts +2 -0
- package/dist/logger/logger.interface.d.ts.map +1 -0
- package/dist/logger/logger.js +8 -1
- package/dist/logger/logger.js.map +2 -2
- package/dist/performance/cache-performance.d.ts +64 -0
- package/dist/performance/cache-performance.d.ts.map +1 -0
- package/dist/performance/database-performance.d.ts +40 -0
- package/dist/performance/database-performance.d.ts.map +1 -0
- package/dist/performance/index.d.ts +8 -0
- package/dist/performance/index.d.ts.map +1 -0
- package/dist/performance/performance-monitor.d.ts +68 -0
- package/dist/performance/performance-monitor.d.ts.map +1 -0
- package/dist/performance/performance-monitor.plugin.d.ts +24 -0
- package/dist/performance/performance-monitor.plugin.d.ts.map +1 -0
- package/dist/performance/queue-performance.d.ts +46 -0
- package/dist/performance/queue-performance.d.ts.map +1 -0
- package/dist/performance/webserver-performance.d.ts +69 -0
- package/dist/performance/webserver-performance.d.ts.map +1 -0
- package/dist/performance/websocket-performance.d.ts +44 -0
- package/dist/performance/websocket-performance.d.ts.map +1 -0
- package/dist/queue/index.d.ts +6 -0
- package/dist/queue/index.d.ts.map +1 -0
- package/dist/queue/index.interface.d.ts +10 -0
- package/dist/queue/index.interface.d.ts.map +1 -0
- package/dist/queue/job.interface.d.ts +43 -0
- package/dist/queue/job.interface.d.ts.map +1 -0
- package/dist/queue/manager.d.ts +44 -0
- package/dist/queue/manager.d.ts.map +1 -0
- package/dist/queue/manager.interface.d.ts +18 -0
- package/dist/queue/manager.interface.d.ts.map +1 -0
- package/dist/queue/processor/base.d.ts +29 -0
- package/dist/queue/processor/base.d.ts.map +1 -0
- package/dist/queue/processor/processor.interface.d.ts +16 -0
- package/dist/queue/processor/processor.interface.d.ts.map +1 -0
- package/dist/queue/worker.d.ts +14 -0
- package/dist/queue/worker.d.ts.map +1 -0
- package/dist/queue/worker.interface.d.ts +13 -0
- package/dist/queue/worker.interface.d.ts.map +1 -0
- package/dist/redis/index.d.ts +3 -0
- package/dist/redis/index.d.ts.map +1 -0
- package/dist/redis/instance.d.ts +32 -0
- package/dist/redis/instance.d.ts.map +1 -0
- package/dist/redis/instance.interface.d.ts +9 -0
- package/dist/redis/instance.interface.d.ts.map +1 -0
- package/dist/redis/manager.d.ts +15 -0
- package/dist/redis/manager.d.ts.map +1 -0
- package/dist/redis/manager.interface.d.ts +8 -0
- package/dist/redis/manager.interface.d.ts.map +1 -0
- package/dist/redis/manager.js +13 -14
- package/dist/redis/manager.js.map +2 -2
- package/dist/request-context/index.d.ts +3 -0
- package/dist/request-context/index.d.ts.map +1 -0
- package/dist/request-context/request-context.d.ts +108 -0
- package/dist/request-context/request-context.d.ts.map +1 -0
- package/dist/request-context/request-context.interface.d.ts +46 -0
- package/dist/request-context/request-context.interface.d.ts.map +1 -0
- package/dist/services/aws/index.d.ts +2 -0
- package/dist/services/aws/index.d.ts.map +1 -0
- package/dist/services/aws/s3.d.ts +54 -0
- package/dist/services/aws/s3.d.ts.map +1 -0
- package/dist/services/aws/s3.interface.d.ts +14 -0
- package/dist/services/aws/s3.interface.d.ts.map +1 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/util/file.d.ts +58 -0
- package/dist/util/file.d.ts.map +1 -0
- package/dist/util/helper.d.ts +51 -0
- package/dist/util/helper.d.ts.map +1 -0
- package/dist/util/helper.js +72 -10
- package/dist/util/helper.js.map +2 -2
- package/dist/util/image.d.ts +12 -0
- package/dist/util/image.d.ts.map +1 -0
- package/dist/util/index.d.ts +11 -0
- package/dist/util/index.d.ts.map +1 -0
- package/dist/util/loader.d.ts +21 -0
- package/dist/util/loader.d.ts.map +1 -0
- package/dist/util/loader.js +5 -2
- package/dist/util/loader.js.map +2 -2
- package/dist/util/num.d.ts +13 -0
- package/dist/util/num.d.ts.map +1 -0
- package/dist/util/os.d.ts +6 -0
- package/dist/util/os.d.ts.map +1 -0
- package/dist/util/str.d.ts +39 -0
- package/dist/util/str.d.ts.map +1 -0
- package/dist/util/time.d.ts +19 -0
- package/dist/util/time.d.ts.map +1 -0
- package/dist/util/time.interface.d.ts +12 -0
- package/dist/util/time.interface.d.ts.map +1 -0
- package/dist/util/timing.d.ts +36 -0
- package/dist/util/timing.d.ts.map +1 -0
- package/dist/util/timing.interface.d.ts +47 -0
- package/dist/util/timing.interface.d.ts.map +1 -0
- package/dist/util/url.d.ts +7 -0
- package/dist/util/url.d.ts.map +1 -0
- package/dist/webserver/controller/auth-middleware.d.ts +21 -0
- package/dist/webserver/controller/auth-middleware.d.ts.map +1 -0
- package/dist/webserver/controller/base.d.ts +41 -0
- package/dist/webserver/controller/base.d.ts.map +1 -0
- package/dist/webserver/controller/base.interface.d.ts +50 -0
- package/dist/webserver/controller/base.interface.d.ts.map +1 -0
- package/dist/webserver/controller/entity.d.ts +94 -0
- package/dist/webserver/controller/entity.d.ts.map +1 -0
- package/dist/webserver/controller/example-auth.d.ts +12 -0
- package/dist/webserver/controller/example-auth.d.ts.map +1 -0
- package/dist/webserver/controller/health.d.ts +15 -0
- package/dist/webserver/controller/health.d.ts.map +1 -0
- package/dist/webserver/define-action.d.ts +26 -0
- package/dist/webserver/define-action.d.ts.map +1 -0
- package/dist/webserver/define-action.js +16 -0
- package/dist/webserver/define-action.js.map +7 -0
- package/dist/webserver/define-route.d.ts +53 -0
- package/dist/webserver/define-route.d.ts.map +1 -0
- package/dist/webserver/define-route.js +11 -6
- package/dist/webserver/define-route.js.map +2 -2
- package/dist/webserver/index.d.ts +14 -0
- package/dist/webserver/index.d.ts.map +1 -0
- package/dist/webserver/index.js +2 -0
- package/dist/webserver/index.js.map +2 -2
- package/dist/webserver/util.d.ts +10 -0
- package/dist/webserver/util.d.ts.map +1 -0
- package/dist/webserver/util.js +5 -2
- package/dist/webserver/util.js.map +2 -2
- package/dist/webserver/webserver.d.ts +93 -0
- package/dist/webserver/webserver.d.ts.map +1 -0
- package/dist/webserver/webserver.interface.d.ts +181 -0
- package/dist/webserver/webserver.interface.d.ts.map +1 -0
- package/dist/webserver/webserver.interface.js.map +1 -1
- package/dist/webserver/webserver.js +28 -31
- package/dist/webserver/webserver.js.map +2 -2
- package/dist/websocket/controller/client/base.d.ts +12 -0
- package/dist/websocket/controller/client/base.d.ts.map +1 -0
- package/dist/websocket/controller/client/base.interface.d.ts +12 -0
- package/dist/websocket/controller/client/base.interface.d.ts.map +1 -0
- package/dist/websocket/controller/server/base.d.ts +13 -0
- package/dist/websocket/controller/server/base.d.ts.map +1 -0
- package/dist/websocket/controller/server/base.interface.d.ts +13 -0
- package/dist/websocket/controller/server/base.interface.d.ts.map +1 -0
- package/dist/websocket/controllers/client/system.d.ts +6 -0
- package/dist/websocket/controllers/client/system.d.ts.map +1 -0
- package/dist/websocket/controllers/server/system.d.ts +7 -0
- package/dist/websocket/controllers/server/system.d.ts.map +1 -0
- package/dist/websocket/index.d.ts +7 -0
- package/dist/websocket/index.d.ts.map +1 -0
- package/dist/websocket/routes/client/system.d.ts +3 -0
- package/dist/websocket/routes/client/system.d.ts.map +1 -0
- package/dist/websocket/routes/server/system.d.ts +3 -0
- package/dist/websocket/routes/server/system.d.ts.map +1 -0
- package/dist/websocket/utils.d.ts +9 -0
- package/dist/websocket/utils.d.ts.map +1 -0
- package/dist/websocket/websocket-base.d.ts +19 -0
- package/dist/websocket/websocket-base.d.ts.map +1 -0
- package/dist/websocket/websocket-client-manager.d.ts +53 -0
- package/dist/websocket/websocket-client-manager.d.ts.map +1 -0
- package/dist/websocket/websocket-client-manager.interface.d.ts +8 -0
- package/dist/websocket/websocket-client-manager.interface.d.ts.map +1 -0
- package/dist/websocket/websocket-client.d.ts +35 -0
- package/dist/websocket/websocket-client.d.ts.map +1 -0
- package/dist/websocket/websocket-client.interface.d.ts +14 -0
- package/dist/websocket/websocket-client.interface.d.ts.map +1 -0
- package/dist/websocket/websocket-room-manager.d.ts +32 -0
- package/dist/websocket/websocket-room-manager.d.ts.map +1 -0
- package/dist/websocket/websocket-server.d.ts +92 -0
- package/dist/websocket/websocket-server.d.ts.map +1 -0
- package/dist/websocket/websocket-server.interface.d.ts +16 -0
- package/dist/websocket/websocket-server.interface.d.ts.map +1 -0
- package/dist/websocket/websocket-server.js +33 -9
- package/dist/websocket/websocket-server.js.map +2 -2
- package/dist/websocket/websocket-service.d.ts +44 -0
- package/dist/websocket/websocket-service.d.ts.map +1 -0
- package/dist/websocket/websocket.interface.d.ts +124 -0
- package/dist/websocket/websocket.interface.d.ts.map +1 -0
- package/package.json +13 -13
- package/pxl.js +0 -4
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a file or directory exists asynchronously
|
|
3
|
+
* @param pathToCheck - Path to check
|
|
4
|
+
* @returns Promise<boolean> - true if exists, false otherwise
|
|
5
|
+
*/
|
|
6
|
+
declare function pathExists(pathToCheck: string): Promise<boolean>;
|
|
7
|
+
/**
|
|
8
|
+
* Ensure directory exists, create if it doesn't
|
|
9
|
+
* @param dirPath - Directory path to ensure
|
|
10
|
+
*/
|
|
11
|
+
declare function ensureDir(dirPath: string): Promise<void>;
|
|
12
|
+
declare function convertFile({ inputFilePath, outputFilePath, format, }: {
|
|
13
|
+
inputFilePath: string;
|
|
14
|
+
outputFilePath: string;
|
|
15
|
+
format: string;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Copy a file or directory synchronously
|
|
19
|
+
*
|
|
20
|
+
* @param src The source path
|
|
21
|
+
* @param dest The destination path
|
|
22
|
+
*/
|
|
23
|
+
declare function copySync(src: string, dest: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Download file from URL
|
|
26
|
+
*
|
|
27
|
+
* @param url The URL to download the file from
|
|
28
|
+
* @param destinationPath The path to save the downloaded file
|
|
29
|
+
*/
|
|
30
|
+
declare function downloadFile({ url, destinationPath }: {
|
|
31
|
+
url: string;
|
|
32
|
+
destinationPath: string;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Format file size.
|
|
36
|
+
*
|
|
37
|
+
* @param bytes The file size in bytes
|
|
38
|
+
*/
|
|
39
|
+
declare function formatFileSize({ bytes }: {
|
|
40
|
+
bytes: number;
|
|
41
|
+
}): string;
|
|
42
|
+
/**
|
|
43
|
+
* Remove a file or directory synchronously
|
|
44
|
+
*
|
|
45
|
+
* @param target The path to the file or directory to remove
|
|
46
|
+
*/
|
|
47
|
+
declare function removeSync(target: string): void;
|
|
48
|
+
declare const _default: {
|
|
49
|
+
convertFile: typeof convertFile;
|
|
50
|
+
copySync: typeof copySync;
|
|
51
|
+
downloadFile: typeof downloadFile;
|
|
52
|
+
formatFileSize: typeof formatFileSize;
|
|
53
|
+
removeSync: typeof removeSync;
|
|
54
|
+
pathExists: typeof pathExists;
|
|
55
|
+
ensureDir: typeof ensureDir;
|
|
56
|
+
};
|
|
57
|
+
export default _default;
|
|
58
|
+
//# sourceMappingURL=file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/util/file.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,iBAAe,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO/D;AAED;;;GAGG;AACH,iBAAe,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMvD;AAED,iBAAe,WAAW,CAAC,EACzB,aAAa,EACb,cAAc,EACd,MAAM,GACP,EAAE;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBhB;AAED;;;;;GAKG;AACH,iBAAS,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAmBjD;AAED;;;;;GAKG;AACH,iBAAe,YAAY,CAAC,EAAE,GAAG,EAAE,eAAe,EAAE,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA4B7G;AAED;;;;GAIG;AACH,iBAAS,cAAc,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAyB5D;AAED;;;;GAIG;AACH,iBAAS,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAoBxC;;;;;;;;;;AAED,wBAQE"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep merge objects with defaults, preventing prototype pollution.
|
|
3
|
+
*
|
|
4
|
+
* This function:
|
|
5
|
+
* - Recursively merges source objects into the target
|
|
6
|
+
* - Preserves existing values in target (acts like defaults)
|
|
7
|
+
* - Sanitizes sources to remove dangerous keys (__proto__, constructor, prototype)
|
|
8
|
+
* - Prevents prototype pollution attacks
|
|
9
|
+
*
|
|
10
|
+
* @param target - The target object to merge into
|
|
11
|
+
* @param sources - Source objects providing default values
|
|
12
|
+
* @returns The merged target object (mutated)
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const userConfig = { host: 'localhost' };
|
|
16
|
+
* const defaults = { host: '0.0.0.0', port: 3001 };
|
|
17
|
+
* const merged = defaultsDeep(userConfig, defaults);
|
|
18
|
+
* // merged = { host: 'localhost', port: 3001 }
|
|
19
|
+
*/
|
|
20
|
+
declare function defaultsDeep<T extends object>(target: T, ...sources: Array<Partial<T>>): T;
|
|
21
|
+
/**
|
|
22
|
+
* Check if a value is an object.
|
|
23
|
+
*/
|
|
24
|
+
declare function isObject(item: unknown): item is Record<string, unknown>;
|
|
25
|
+
type AnyObject = Record<string, unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves the value from an object using a dotted key path safely.
|
|
28
|
+
*
|
|
29
|
+
* @param obj - The object to retrieve the value from.
|
|
30
|
+
* @param path - The dotted key path (e.g., 'user.email').
|
|
31
|
+
* @returns The value at the specified key path or undefined if not found.
|
|
32
|
+
*/
|
|
33
|
+
declare function getValueFromObject(obj: AnyObject, path: string): unknown;
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves the value from an array of objects using a dotted key path.
|
|
36
|
+
*
|
|
37
|
+
* @param arr - The array of objects.
|
|
38
|
+
* @param path - The dotted key path (e.g., 'user.email').
|
|
39
|
+
* @returns An array of values at the specified key path from each object.
|
|
40
|
+
*/
|
|
41
|
+
declare function getValueFromArray(arr: AnyObject[], path: string): unknown[];
|
|
42
|
+
declare function getScriptFileExtension(): string;
|
|
43
|
+
declare const _default: {
|
|
44
|
+
defaultsDeep: typeof defaultsDeep;
|
|
45
|
+
isObject: typeof isObject;
|
|
46
|
+
getValueFromArray: typeof getValueFromArray;
|
|
47
|
+
getValueFromObject: typeof getValueFromObject;
|
|
48
|
+
getScriptFileExtension: typeof getScriptFileExtension;
|
|
49
|
+
};
|
|
50
|
+
export default _default;
|
|
51
|
+
//# sourceMappingURL=helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/util/helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,iBAAS,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAgBnF;AA0HD;;GAEG;AACH,iBAAS,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEhE;AAED,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEzC;;;;;;GAMG;AACH,iBAAS,kBAAkB,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAWjE;AAED;;;;;;GAMG;AACH,iBAAS,iBAAiB,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,CAEpE;AAED,iBAAS,sBAAsB,IAAI,MAAM,CAExC;;;;;;;;AAED,wBAME"}
|
package/dist/util/helper.js
CHANGED
|
@@ -1,18 +1,80 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import lodashDefaultsDeep from "lodash.defaultsdeep";
|
|
4
3
|
function defaultsDeep(target, ...sources) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
return
|
|
4
|
+
let result = target;
|
|
5
|
+
if (target === null || target === void 0) {
|
|
6
|
+
result = {};
|
|
7
|
+
}
|
|
8
|
+
for (const source of sources) {
|
|
9
|
+
if (!isObject(source) && !Array.isArray(source)) continue;
|
|
10
|
+
mergeObjects(result, source);
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
14
13
|
}
|
|
15
14
|
__name(defaultsDeep, "defaultsDeep");
|
|
15
|
+
function mergeObjects(target, source) {
|
|
16
|
+
if (Array.isArray(source)) {
|
|
17
|
+
if (!Array.isArray(target)) {
|
|
18
|
+
for (let i = 0; i < source.length; i++) {
|
|
19
|
+
const key = String(i);
|
|
20
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") continue;
|
|
21
|
+
const sourceValue = source[i];
|
|
22
|
+
const targetValue = target[key];
|
|
23
|
+
const keyExists = key in target;
|
|
24
|
+
if (keyExists && isObject(targetValue) && isObject(sourceValue)) {
|
|
25
|
+
mergeObjects(targetValue, sourceValue);
|
|
26
|
+
} else if (!keyExists || targetValue === void 0) {
|
|
27
|
+
target[key] = isObject(sourceValue) ? deepClone(sourceValue) : sourceValue;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
for (let i = 0; i < source.length; i++) {
|
|
33
|
+
const sourceValue = source[i];
|
|
34
|
+
const targetValue = target[i];
|
|
35
|
+
const indexExists = i in target;
|
|
36
|
+
if (indexExists && isObject(targetValue) && isObject(sourceValue)) {
|
|
37
|
+
mergeObjects(targetValue, sourceValue);
|
|
38
|
+
} else if (!indexExists || targetValue === void 0) {
|
|
39
|
+
target[i] = isObject(sourceValue) ? deepClone(sourceValue) : sourceValue;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
for (const key of Object.keys(source)) {
|
|
45
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (!Object.prototype.hasOwnProperty.call(source, key)) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const sourceValue = source[key];
|
|
52
|
+
const targetValue = target[key];
|
|
53
|
+
if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
|
|
54
|
+
mergeObjects(targetValue, sourceValue);
|
|
55
|
+
} else if (isObject(targetValue) && Array.isArray(sourceValue)) {
|
|
56
|
+
mergeObjects(targetValue, sourceValue);
|
|
57
|
+
} else if (targetValue !== void 0 && isObject(targetValue) && isObject(sourceValue)) {
|
|
58
|
+
mergeObjects(targetValue, sourceValue);
|
|
59
|
+
} else if (targetValue === void 0) {
|
|
60
|
+
target[key] = isObject(sourceValue) || Array.isArray(sourceValue) ? deepClone(sourceValue) : sourceValue;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
__name(mergeObjects, "mergeObjects");
|
|
65
|
+
function deepClone(obj) {
|
|
66
|
+
if (!isObject(obj)) return obj;
|
|
67
|
+
const cloned = Array.isArray(obj) ? [] : {};
|
|
68
|
+
for (const key of Object.keys(obj)) {
|
|
69
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const value = obj[key];
|
|
73
|
+
cloned[key] = isObject(value) ? deepClone(value) : value;
|
|
74
|
+
}
|
|
75
|
+
return cloned;
|
|
76
|
+
}
|
|
77
|
+
__name(deepClone, "deepClone");
|
|
16
78
|
function isObject(item) {
|
|
17
79
|
return item !== null && typeof item === "object" && !Array.isArray(item);
|
|
18
80
|
}
|
package/dist/util/helper.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/util/helper.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;
|
|
4
|
+
"sourcesContent": ["/**\n * Deep merge objects with defaults, preventing prototype pollution.\n *\n * This function:\n * - Recursively merges source objects into the target\n * - Preserves existing values in target (acts like defaults)\n * - Sanitizes sources to remove dangerous keys (__proto__, constructor, prototype)\n * - Prevents prototype pollution attacks\n *\n * @param target - The target object to merge into\n * @param sources - Source objects providing default values\n * @returns The merged target object (mutated)\n *\n * @example\n * const userConfig = { host: 'localhost' };\n * const defaults = { host: '0.0.0.0', port: 3001 };\n * const merged = defaultsDeep(userConfig, defaults);\n * // merged = { host: 'localhost', port: 3001 }\n */\nfunction defaultsDeep<T extends object>(target: T, ...sources: Array<Partial<T>>): T {\n // Handle null/undefined target by converting to empty object\n let result = target;\n if (target === null || target === undefined) {\n result = {} as T;\n }\n\n // Process each source\n for (const source of sources) {\n if (!isObject(source) && !Array.isArray(source)) continue;\n\n // Recursively merge source into target\n mergeObjects(result, source);\n }\n\n return result;\n}\n\n/**\n * Recursively merge source into target, preserving target values.\n * This acts like defaultsDeep - only fills in missing values from source.\n */\nfunction mergeObjects(target: any, source: any): void {\n // Handle arrays specially - merge by index\n if (Array.isArray(source)) {\n // If target is not an array but source is, treat target as object with numeric keys\n if (!Array.isArray(target)) {\n // Merge array into object-like target\n for (let i = 0; i < source.length; i++) {\n const key = String(i);\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue;\n\n // eslint-disable-next-line security/detect-object-injection\n const sourceValue = source[i];\n // eslint-disable-next-line security/detect-object-injection\n const targetValue = target[key];\n\n // Check if key exists in target\n const keyExists = key in target;\n\n if (keyExists && isObject(targetValue) && isObject(sourceValue)) {\n mergeObjects(targetValue, sourceValue);\n } else if (!keyExists || targetValue === undefined) {\n // eslint-disable-next-line security/detect-object-injection\n target[key] = isObject(sourceValue) ? deepClone(sourceValue) : sourceValue;\n }\n }\n return;\n }\n\n // Both are arrays - merge by index\n for (let i = 0; i < source.length; i++) {\n // eslint-disable-next-line security/detect-object-injection\n const sourceValue = source[i];\n // eslint-disable-next-line security/detect-object-injection\n const targetValue = target[i];\n\n // Check if index exists in target (not just if value is undefined)\n const indexExists = i in target;\n\n // If index exists and both values are objects, merge them\n if (indexExists && isObject(targetValue) && isObject(sourceValue)) {\n mergeObjects(targetValue, sourceValue);\n }\n // If index doesn't exist or value is undefined, fill from source\n else if (!indexExists || targetValue === undefined) {\n // eslint-disable-next-line security/detect-object-injection\n target[i] = isObject(sourceValue) ? deepClone(sourceValue) : sourceValue;\n }\n // Otherwise, keep target's existing value\n }\n return;\n }\n\n // Regular object merging\n for (const key of Object.keys(source)) {\n // Block dangerous keys to prevent prototype pollution\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') {\n continue;\n }\n\n // Only use hasOwnProperty for safer property access\n if (!Object.prototype.hasOwnProperty.call(source, key)) {\n continue;\n }\n\n // Access guarded by ownProperty check and blocked prototype keys\n // eslint-disable-next-line security/detect-object-injection\n const sourceValue = source[key];\n\n // eslint-disable-next-line security/detect-object-injection\n const targetValue = target[key];\n\n // If both are arrays, merge them by index\n if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {\n mergeObjects(targetValue, sourceValue);\n }\n // If target is object and source is array, merge array into object by numeric keys\n else if (isObject(targetValue) && Array.isArray(sourceValue)) {\n mergeObjects(targetValue, sourceValue);\n }\n // If target value exists and both are objects (not arrays), recurse\n else if (targetValue !== undefined && isObject(targetValue) && isObject(sourceValue)) {\n mergeObjects(targetValue, sourceValue);\n }\n // If target doesn't have this key, set it from source\n else if (targetValue === undefined) {\n // eslint-disable-next-line security/detect-object-injection\n target[key] = isObject(sourceValue) || Array.isArray(sourceValue) ? deepClone(sourceValue) : sourceValue;\n }\n // Otherwise, keep target's existing value (defaultsDeep behavior)\n }\n}\n\n/**\n * Deep clone an object to avoid reference sharing.\n */\nfunction deepClone<T>(obj: T): T {\n if (!isObject(obj)) return obj;\n\n const cloned: any = Array.isArray(obj) ? [] : {};\n\n for (const key of Object.keys(obj)) {\n // Block dangerous keys\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') {\n continue;\n }\n\n // eslint-disable-next-line security/detect-object-injection\n const value = (obj as any)[key];\n\n // eslint-disable-next-line security/detect-object-injection\n cloned[key] = isObject(value) ? deepClone(value) : value;\n }\n\n return cloned;\n}\n\n/**\n * Check if a value is an object.\n */\nfunction isObject(item: unknown): item is Record<string, unknown> {\n return item !== null && typeof item === 'object' && !Array.isArray(item);\n}\n\ntype AnyObject = Record<string, unknown>;\n\n/**\n * Retrieves the value from an object using a dotted key path safely.\n *\n * @param obj - The object to retrieve the value from.\n * @param path - The dotted key path (e.g., 'user.email').\n * @returns The value at the specified key path or undefined if not found.\n */\nfunction getValueFromObject(obj: AnyObject, path: string): unknown {\n const parts = path.split('.');\n let current: any = obj;\n for (const part of parts) {\n if (part === '__proto__' || part === 'constructor' || part === 'prototype') return undefined;\n if (!current || !Object.prototype.hasOwnProperty.call(current, part)) return undefined;\n // Access guarded by ownProperty check and blocked prototype keys\n // eslint-disable-next-line security/detect-object-injection\n current = (current as Record<string, any>)[part];\n }\n return current;\n}\n\n/**\n * Retrieves the value from an array of objects using a dotted key path.\n *\n * @param arr - The array of objects.\n * @param path - The dotted key path (e.g., 'user.email').\n * @returns An array of values at the specified key path from each object.\n */\nfunction getValueFromArray(arr: AnyObject[], path: string): unknown[] {\n return arr.map(obj => getValueFromObject(obj, path));\n}\n\nfunction getScriptFileExtension(): string {\n return process.env.NODE_ENV === 'development' ? 'ts' : 'js';\n}\n\nexport default {\n defaultsDeep,\n isObject,\n getValueFromArray,\n getValueFromObject,\n getScriptFileExtension,\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare function extractMimeType({ base64 }: {
|
|
2
|
+
base64: string;
|
|
3
|
+
}): string | undefined;
|
|
4
|
+
declare function mimeTypeToExtension({ mimeType }: {
|
|
5
|
+
mimeType: string;
|
|
6
|
+
}): string | undefined;
|
|
7
|
+
declare const _default: {
|
|
8
|
+
extractMimeType: typeof extractMimeType;
|
|
9
|
+
mimeTypeToExtension: typeof mimeTypeToExtension;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
12
|
+
//# sourceMappingURL=image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/util/image.ts"],"names":[],"mappings":"AAAA,iBAAS,eAAe,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,SAAS,CAO3E;AAED,iBAAS,mBAAmB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,SAAS,CAenF;;;;;AAED,wBAGE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default as Time } from './time.js';
|
|
2
|
+
export { default as Timing } from './timing.js';
|
|
3
|
+
export { default as File } from './file.js';
|
|
4
|
+
export { default as Helper } from './helper.js';
|
|
5
|
+
export { default as Image } from './image.js';
|
|
6
|
+
export { default as Loader } from './loader.js';
|
|
7
|
+
export { default as Num } from './num.js';
|
|
8
|
+
export { default as OS } from './os.js';
|
|
9
|
+
export { default as Str } from './str.js';
|
|
10
|
+
export { default as URL } from './url.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface ModuleMap<T = unknown> {
|
|
2
|
+
[key: string]: T;
|
|
3
|
+
}
|
|
4
|
+
export type EntityClass<T = unknown> = new (...args: unknown[]) => T;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
loadModulesInDirectory: <T = unknown>({ directory, extensions, }: {
|
|
7
|
+
directory: string;
|
|
8
|
+
extensions?: string[];
|
|
9
|
+
}) => Promise<ModuleMap<T>>;
|
|
10
|
+
loadEntityModule: <T = unknown>({ entitiesDirectory, entityName, }: {
|
|
11
|
+
entitiesDirectory: string;
|
|
12
|
+
entityName: string;
|
|
13
|
+
}) => Promise<EntityClass<T>>;
|
|
14
|
+
clearModuleCache: () => void;
|
|
15
|
+
getCacheStats: () => {
|
|
16
|
+
modulesCached: number;
|
|
17
|
+
entitiesCached: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export default _default;
|
|
21
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/util/loader.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,OAAO;IACpC,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC;CAClB;AAgFD,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,OAAO,IAAI,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;;6BAlE/B,CAAC,wCAGpC;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;KACvB,KAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;uBA8DO,CAAC,gDAG9B;QACD,iBAAiB,EAAE,MAAM,CAAC;QAC1B,UAAU,EAAE,MAAM,CAAC;KACpB,KAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;4BAkCE,IAAI;yBAKP;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE;;AAO3E,wBAKE"}
|
package/dist/util/loader.js
CHANGED
|
@@ -41,10 +41,13 @@ const loadModulesInDirectory = /* @__PURE__ */ __name(async ({
|
|
|
41
41
|
}
|
|
42
42
|
const moduleName = path.basename(file, ext);
|
|
43
43
|
const filePath = path.join(directory, file);
|
|
44
|
+
const absolutePath = path.isAbsolute(filePath) ? filePath : path.resolve(filePath);
|
|
45
|
+
const fileUrl = `file://${absolutePath.replace(/\\/g, "/")}`;
|
|
44
46
|
try {
|
|
45
|
-
const importedModule = await import(
|
|
47
|
+
const importedModule = await import(fileUrl);
|
|
46
48
|
if (moduleName !== "__proto__" && moduleName !== "constructor" && moduleName !== "prototype") {
|
|
47
|
-
|
|
49
|
+
const moduleExport = importedModule.default ?? importedModule;
|
|
50
|
+
Reflect.set(loadedModules, moduleName, moduleExport);
|
|
48
51
|
}
|
|
49
52
|
} catch (error) {
|
|
50
53
|
console.error(`Failed to import module ${filePath}:`, error);
|
package/dist/util/loader.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/util/loader.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'fs';\nimport path from 'path';\nimport { LRUCache } from 'lru-cache';\nimport { Helper } from './index.js';\n\n// Type for a map of loaded modules\nexport interface ModuleMap<T = unknown> {\n [key: string]: T;\n}\n\n// Cache for loaded modules to avoid repeated imports\n// Using LRU cache to prevent unbounded memory growth in long-running processes\nconst moduleCache = new LRUCache<string, ModuleMap>({\n max: 100, // Max 100 directories cached\n ttl: 1000 * 60 * 10, // 10 minutes\n});\n\nconst entityCache = new LRUCache<string, EntityClass>({\n max: 500, // Max 500 entities cached (accessed more frequently than modules)\n ttl: 1000 * 60 * 10, // 10 minutes\n});\n\nconst loadModulesInDirectory = async <T = unknown>({\n directory,\n extensions,\n}: {\n directory: string;\n extensions?: string[];\n}): Promise<ModuleMap<T>> => {\n // Create cache key based on directory and extensions\n const cacheKey = `${directory}:${extensions?.join(',') ?? 'all'}`;\n\n // Check cache first\n if (moduleCache.has(cacheKey)) {\n const cachedModule = moduleCache.get(cacheKey);\n if (cachedModule) {\n return cachedModule as ModuleMap<T>;\n }\n }\n\n const loadedModules: ModuleMap<T> = {};\n\n // Use readdir with withFileTypes option to avoid separate stat calls\n const dirents = await fs.promises.readdir(directory, { withFileTypes: true });\n\n for (const dirent of dirents) {\n // Skip directories without needing stat call\n if (dirent.isDirectory()) {\n continue;\n }\n\n const file = dirent.name;\n const ext = path.extname(file);\n const isDeclarationFile = file.endsWith('.d.ts');\n\n // Skip files that are not in the specified extensions or are .d.ts files\n if ((extensions && extensions.length > 0 && !extensions.includes(ext)) || isDeclarationFile) {\n continue;\n }\n\n const moduleName = path.basename(file, ext);\n const filePath = path.join(directory, file);\n\n try {\n const importedModule = await import(
|
|
5
|
-
"mappings": ";;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,gBAAgB;AACzB,SAAS,cAAc;AASvB,MAAM,cAAc,IAAI,SAA4B;AAAA,EAClD,KAAK;AAAA;AAAA,EACL,KAAK,MAAO,KAAK;AAAA;AACnB,CAAC;AAED,MAAM,cAAc,IAAI,SAA8B;AAAA,EACpD,KAAK;AAAA;AAAA,EACL,KAAK,MAAO,KAAK;AAAA;AACnB,CAAC;AAED,MAAM,yBAAyB,8BAAoB;AAAA,EACjD;AAAA,EACA;AACF,MAG6B;AAE3B,QAAM,WAAW,GAAG,SAAS,IAAI,YAAY,KAAK,GAAG,KAAK,KAAK;AAG/D,MAAI,YAAY,IAAI,QAAQ,GAAG;AAC7B,UAAM,eAAe,YAAY,IAAI,QAAQ;AAC7C,QAAI,cAAc;AAChB,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,gBAA8B,CAAC;AAGrC,QAAM,UAAU,MAAM,GAAG,SAAS,QAAQ,WAAW,EAAE,eAAe,KAAK,CAAC;AAE5E,aAAW,UAAU,SAAS;AAE5B,QAAI,OAAO,YAAY,GAAG;AACxB;AAAA,IACF;AAEA,UAAM,OAAO,OAAO;AACpB,UAAM,MAAM,KAAK,QAAQ,IAAI;AAC7B,UAAM,oBAAoB,KAAK,SAAS,OAAO;AAG/C,QAAK,cAAc,WAAW,SAAS,KAAK,CAAC,WAAW,SAAS,GAAG,KAAM,mBAAmB;AAC3F;AAAA,IACF;AAEA,UAAM,aAAa,KAAK,SAAS,MAAM,GAAG;AAC1C,UAAM,WAAW,KAAK,KAAK,WAAW,IAAI;AAE1C,QAAI;AACF,YAAM,iBAAiB,MAAM,OAAO;AAGpC,UAAI,eAAe,eAAe,eAAe,iBAAiB,eAAe,aAAa;
|
|
4
|
+
"sourcesContent": ["import fs from 'fs';\nimport path from 'path';\nimport { LRUCache } from 'lru-cache';\nimport { Helper } from './index.js';\n\n// Type for a map of loaded modules\nexport interface ModuleMap<T = unknown> {\n [key: string]: T;\n}\n\n// Cache for loaded modules to avoid repeated imports\n// Using LRU cache to prevent unbounded memory growth in long-running processes\nconst moduleCache = new LRUCache<string, ModuleMap>({\n max: 100, // Max 100 directories cached\n ttl: 1000 * 60 * 10, // 10 minutes\n});\n\nconst entityCache = new LRUCache<string, EntityClass>({\n max: 500, // Max 500 entities cached (accessed more frequently than modules)\n ttl: 1000 * 60 * 10, // 10 minutes\n});\n\nconst loadModulesInDirectory = async <T = unknown>({\n directory,\n extensions,\n}: {\n directory: string;\n extensions?: string[];\n}): Promise<ModuleMap<T>> => {\n // Create cache key based on directory and extensions\n const cacheKey = `${directory}:${extensions?.join(',') ?? 'all'}`;\n\n // Check cache first\n if (moduleCache.has(cacheKey)) {\n const cachedModule = moduleCache.get(cacheKey);\n if (cachedModule) {\n return cachedModule as ModuleMap<T>;\n }\n }\n\n const loadedModules: ModuleMap<T> = {};\n\n // Use readdir with withFileTypes option to avoid separate stat calls\n const dirents = await fs.promises.readdir(directory, { withFileTypes: true });\n\n for (const dirent of dirents) {\n // Skip directories without needing stat call\n if (dirent.isDirectory()) {\n continue;\n }\n\n const file = dirent.name;\n const ext = path.extname(file);\n const isDeclarationFile = file.endsWith('.d.ts');\n\n // Skip files that are not in the specified extensions or are .d.ts files\n if ((extensions && extensions.length > 0 && !extensions.includes(ext)) || isDeclarationFile) {\n continue;\n }\n\n const moduleName = path.basename(file, ext);\n const filePath = path.join(directory, file);\n // Convert to absolute path for ESM import\n const absolutePath = path.isAbsolute(filePath) ? filePath : path.resolve(filePath);\n // Use file:// URL for Windows compatibility\n const fileUrl = `file://${absolutePath.replace(/\\\\/g, '/')}`;\n\n try {\n const importedModule = await import(fileUrl);\n\n // Use safe property assignment to prevent prototype pollution\n if (moduleName !== '__proto__' && moduleName !== 'constructor' && moduleName !== 'prototype') {\n // Prefer default export, but fall back to the entire module if no default\n const moduleExport = importedModule.default ?? importedModule;\n Reflect.set(loadedModules, moduleName, moduleExport);\n }\n } catch (error) {\n console.error(`Failed to import module ${filePath}:`, error);\n }\n }\n\n // Cache the results for future use\n moduleCache.set(cacheKey, loadedModules);\n\n return loadedModules;\n};\n\n// Type constraint for entity classes (must be constructable)\nexport type EntityClass<T = unknown> = new (...args: unknown[]) => T;\n\nconst loadEntityModule = async <T = unknown>({\n entitiesDirectory,\n entityName,\n}: {\n entitiesDirectory: string;\n entityName: string;\n}): Promise<EntityClass<T>> => {\n // Create cache key based on directory and entity name\n const cacheKey = `${entitiesDirectory}:${entityName}`;\n\n // Check cache first\n if (entityCache.has(cacheKey)) {\n return entityCache.get(cacheKey) as EntityClass<T>;\n }\n\n // Define entity module path\n const entityModulePath = path.join(entitiesDirectory, `${entityName}.${Helper.getScriptFileExtension()}`);\n\n // Import entity module\n const entityModule = await import(entityModulePath);\n\n // Safe property access to prevent prototype pollution\n if (entityName === '__proto__' || entityName === 'constructor' || entityName === 'prototype') {\n throw new Error(`Invalid entity name (Entity: ${entityName})`);\n }\n\n if (!entityModule || !Object.prototype.hasOwnProperty.call(entityModule, entityName)) {\n throw new Error(`Entity not found (Entity: ${entityName})`);\n }\n\n // Get entity class\n const EntityClass = Reflect.get(entityModule, entityName);\n\n // Cache the entity for future use\n entityCache.set(cacheKey, EntityClass);\n\n return EntityClass;\n};\n\n// Cache management functions for development/testing\nconst clearModuleCache = (): void => {\n moduleCache.clear();\n entityCache.clear();\n};\n\nconst getCacheStats = (): { modulesCached: number; entitiesCached: number } => {\n return {\n modulesCached: moduleCache.size,\n entitiesCached: entityCache.size,\n };\n};\n\nexport default {\n loadModulesInDirectory,\n loadEntityModule,\n clearModuleCache,\n getCacheStats,\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
getRandomNumber: ({ min, max }: {
|
|
3
|
+
min: number;
|
|
4
|
+
max: number;
|
|
5
|
+
}) => number;
|
|
6
|
+
clamp: ({ value, min, max }: {
|
|
7
|
+
value: number;
|
|
8
|
+
min: number;
|
|
9
|
+
max: number;
|
|
10
|
+
}) => number;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
13
|
+
//# sourceMappingURL=num.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"num.d.ts","sourceRoot":"","sources":["../../src/util/num.ts"],"names":[],"mappings":";oCAAuC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,KAAG,MAAM;iCAIxC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,KAAG,MAAM;;AAIxF,wBAGE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"os.d.ts","sourceRoot":"","sources":["../../src/util/os.ts"],"names":[],"mappings":"AAGA,iBAAS,mBAAmB,IAAI,MAAM,CAarC;;;;AAED,wBAEE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate a unique id.
|
|
3
|
+
*/
|
|
4
|
+
declare function generateUniqueId(): string;
|
|
5
|
+
/**
|
|
6
|
+
* Slugify string.
|
|
7
|
+
*/
|
|
8
|
+
declare function slugify({ text }: {
|
|
9
|
+
text: string;
|
|
10
|
+
}): string;
|
|
11
|
+
/**
|
|
12
|
+
* Make text title case.
|
|
13
|
+
*/
|
|
14
|
+
declare function titleCase({ text }: {
|
|
15
|
+
text: string;
|
|
16
|
+
}): string;
|
|
17
|
+
/**
|
|
18
|
+
* Remove file extension from filename.
|
|
19
|
+
*/
|
|
20
|
+
declare function removeFileExtension({ filename }: {
|
|
21
|
+
filename: string;
|
|
22
|
+
}): string;
|
|
23
|
+
/**
|
|
24
|
+
* Get file extension from filename.
|
|
25
|
+
* @param filename
|
|
26
|
+
* @returns File extension
|
|
27
|
+
*/
|
|
28
|
+
declare function getFileExtension({ filename }: {
|
|
29
|
+
filename: string;
|
|
30
|
+
}): string;
|
|
31
|
+
declare const _default: {
|
|
32
|
+
generateUniqueId: typeof generateUniqueId;
|
|
33
|
+
slugify: typeof slugify;
|
|
34
|
+
titleCase: typeof titleCase;
|
|
35
|
+
removeFileExtension: typeof removeFileExtension;
|
|
36
|
+
getFileExtension: typeof getFileExtension;
|
|
37
|
+
};
|
|
38
|
+
export default _default;
|
|
39
|
+
//# sourceMappingURL=str.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"str.d.ts","sourceRoot":"","sources":["../../src/util/str.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,iBAAS,gBAAgB,IAAI,MAAM,CAElC;AAED;;GAEG;AACH,iBAAS,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAQnD;AAED;;GAEG;AACH,iBAAS,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAMrD;AAED;;GAEG;AACH,iBAAS,mBAAmB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEvE;AAED;;;;GAIG;AACH,iBAAS,gBAAgB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEpE;;;;;;;;AAED,wBAME"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FormatRelativeTimeOptions, FormatTimeOptions } from './time.interface.js';
|
|
2
|
+
import Timing from './timing.js';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
calculateElapsedTimeMs: ({ startTime }: {
|
|
5
|
+
startTime: number;
|
|
6
|
+
}) => number;
|
|
7
|
+
formatTime: ({ time, format, numDecimals, showUnit }: FormatTimeOptions) => string;
|
|
8
|
+
formatRelativeTime: ({ date, baseDate, includeSeconds, }: FormatRelativeTimeOptions) => string;
|
|
9
|
+
sleep: ({ seconds }: {
|
|
10
|
+
seconds: number;
|
|
11
|
+
}) => Promise<void>;
|
|
12
|
+
now: typeof Timing.now;
|
|
13
|
+
start: typeof Timing.start;
|
|
14
|
+
measure: typeof Timing.measure;
|
|
15
|
+
measureSync: typeof Timing.measureSync;
|
|
16
|
+
duration: typeof Timing.duration;
|
|
17
|
+
};
|
|
18
|
+
export default _default;
|
|
19
|
+
//# sourceMappingURL=time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/util/time.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,MAAM,MAAM,aAAa,CAAC;;4CAMc;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,KAAG,MAAM;0DAOI,iBAAiB,KAAG,MAAM;8DA4CxG,yBAAyB,KAAG,MAAM;yBAbT;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,KAAG,OAAO,CAAC,IAAI,CAAC;;;;;;;AA6D/D,wBAWE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface FormatTimeOptions {
|
|
2
|
+
time: number;
|
|
3
|
+
format?: 'ms' | 's' | 'auto' | 'hh:mm:ss';
|
|
4
|
+
numDecimals?: number;
|
|
5
|
+
showUnit?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface FormatRelativeTimeOptions {
|
|
8
|
+
date: Date;
|
|
9
|
+
baseDate?: Date;
|
|
10
|
+
includeSeconds?: boolean;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=time.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.interface.d.ts","sourceRoot":"","sources":["../../src/util/time.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,IAAI,GAAG,GAAG,GAAG,MAAM,GAAG,UAAU,CAAC;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { MeasureOptions, Timer, TimingResult } from './timing.interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* Modern high-resolution timing utility using performance.now()
|
|
4
|
+
*
|
|
5
|
+
* Provides simple APIs for measuring function execution time and manual timing.
|
|
6
|
+
* All durations are returned in milliseconds with decimal precision.
|
|
7
|
+
*/
|
|
8
|
+
declare class Timing {
|
|
9
|
+
/**
|
|
10
|
+
* Get current high-resolution timestamp in milliseconds.
|
|
11
|
+
* Uses performance.now() which provides sub-millisecond precision.
|
|
12
|
+
*/
|
|
13
|
+
static now(): number;
|
|
14
|
+
/**
|
|
15
|
+
* Start a timer and return a Timer instance.
|
|
16
|
+
* Call timer.stop() to get elapsed time in milliseconds.
|
|
17
|
+
*/
|
|
18
|
+
static start(): Timer;
|
|
19
|
+
/**
|
|
20
|
+
* Measure the execution time of a function (async or sync).
|
|
21
|
+
* Returns both the function result and timing information.
|
|
22
|
+
*/
|
|
23
|
+
static measure<T>(fn: () => T | Promise<T>, options?: MeasureOptions): Promise<TimingResult<T>>;
|
|
24
|
+
/**
|
|
25
|
+
* Measure the execution time of a synchronous function.
|
|
26
|
+
* Returns both the function result and timing information.
|
|
27
|
+
*/
|
|
28
|
+
static measureSync<T>(fn: () => T, options?: MeasureOptions): TimingResult<T>;
|
|
29
|
+
/**
|
|
30
|
+
* Calculate duration between two timestamps in milliseconds.
|
|
31
|
+
* Both timestamps should be from performance.now().
|
|
32
|
+
*/
|
|
33
|
+
static duration(startTime: number, endTime: number): number;
|
|
34
|
+
}
|
|
35
|
+
export default Timing;
|
|
36
|
+
//# sourceMappingURL=timing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timing.d.ts","sourceRoot":"","sources":["../../src/util/timing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAqBjF;;;;;GAKG;AACH,cAAM,MAAM;IACV;;;OAGG;IACH,MAAM,CAAC,GAAG,IAAI,MAAM;IAIpB;;;OAGG;IACH,MAAM,CAAC,KAAK,IAAI,KAAK;IAIrB;;;OAGG;WACU,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAwBzG;;;OAGG;IACH,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,OAAO,GAAE,cAAmB,GAAG,YAAY,CAAC,CAAC,CAAC;IAwBjF;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;CAG5D;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface Timer {
|
|
2
|
+
/**
|
|
3
|
+
* Stop the timer and return elapsed time in milliseconds with decimal precision.
|
|
4
|
+
*/
|
|
5
|
+
stop(): number;
|
|
6
|
+
/**
|
|
7
|
+
* Get elapsed time since timer start without stopping the timer.
|
|
8
|
+
*/
|
|
9
|
+
elapsed(): number;
|
|
10
|
+
/**
|
|
11
|
+
* The start timestamp in milliseconds (performance.now() format).
|
|
12
|
+
*/
|
|
13
|
+
readonly startTime: number;
|
|
14
|
+
}
|
|
15
|
+
export interface TimingResult<T = unknown> {
|
|
16
|
+
/**
|
|
17
|
+
* Duration in milliseconds with decimal precision.
|
|
18
|
+
*/
|
|
19
|
+
duration: number;
|
|
20
|
+
/**
|
|
21
|
+
* The result returned by the measured function.
|
|
22
|
+
*/
|
|
23
|
+
result: T;
|
|
24
|
+
/**
|
|
25
|
+
* Start timestamp in milliseconds (performance.now() format).
|
|
26
|
+
*/
|
|
27
|
+
startTime: number;
|
|
28
|
+
/**
|
|
29
|
+
* End timestamp in milliseconds (performance.now() format).
|
|
30
|
+
*/
|
|
31
|
+
endTime: number;
|
|
32
|
+
}
|
|
33
|
+
export interface MeasureOptions {
|
|
34
|
+
/**
|
|
35
|
+
* Optional name for the measurement (useful for logging/debugging).
|
|
36
|
+
*/
|
|
37
|
+
name?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to log the timing result automatically.
|
|
40
|
+
*/
|
|
41
|
+
log?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Custom logger function to use if log is true.
|
|
44
|
+
*/
|
|
45
|
+
logger?: (message: string, duration: number) => void;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=timing.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timing.interface.d.ts","sourceRoot":"","sources":["../../src/util/timing.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,IAAI,IAAI,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,IAAI,MAAM,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO;IACvC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,MAAM,EAAE,CAAC,CAAC;IAEV;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/util/url.ts"],"names":[],"mappings":";+BAAkC;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;KAAE,KAAG,MAAM;;AAOvF,wBAEE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { FastifyReply, FastifyRequest } from 'fastify';
|
|
2
|
+
import type { AuthenticatedUser } from './base.js';
|
|
3
|
+
export type { AuthenticatedUser } from './base.js';
|
|
4
|
+
export interface AuthenticatedRequest extends FastifyRequest {
|
|
5
|
+
user: AuthenticatedUser;
|
|
6
|
+
}
|
|
7
|
+
export type AuthenticatedRouteHandler = (request: AuthenticatedRequest, reply: FastifyReply) => Promise<void>;
|
|
8
|
+
export type RouteHandler = (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Higher-order function that wraps a route handler with authentication
|
|
11
|
+
* @param handler The route handler that requires authentication
|
|
12
|
+
* @param authenticateRequest The authentication method from the controller
|
|
13
|
+
* @returns A new route handler with authentication built-in
|
|
14
|
+
*/
|
|
15
|
+
export declare function withAuth(handler: AuthenticatedRouteHandler, authenticateRequest: (request: FastifyRequest, reply: FastifyReply) => Promise<AuthenticatedUser | null>): RouteHandler;
|
|
16
|
+
/**
|
|
17
|
+
* Method decorator for class-based controllers
|
|
18
|
+
* Usage: @requiresAuth()
|
|
19
|
+
*/
|
|
20
|
+
export declare function requiresAuth(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
21
|
+
//# sourceMappingURL=auth-middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-middleware.d.ts","sourceRoot":"","sources":["../../../src/webserver/controller/auth-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnD,YAAY,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnD,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,IAAI,EAAE,iBAAiB,CAAC;CACzB;AAED,MAAM,MAAM,yBAAyB,GAAG,CAAC,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9G,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE3F;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,yBAAyB,EAClC,mBAAmB,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,GACvG,YAAY,CAed;AAED;;;GAGG;AACH,wBAAgB,YAAY,KACT,QAAQ,GAAG,EAAE,aAAa,MAAM,EAAE,YAAY,kBAAkB,wBAoBlF"}
|