topsyde-utils 1.3.2 → 2.0.1
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/dist/index.d.ts +2 -43
- package/dist/index.js +1 -38
- package/dist/index.js.map +1 -1
- package/dist/utils/Lib.d.ts +0 -12
- package/dist/utils/Lib.js +0 -65
- package/dist/utils/Lib.js.map +1 -1
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.js +0 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/websocket.shared.types.d.ts +25 -0
- package/dist/websocket.shared.types.js +4 -0
- package/dist/websocket.shared.types.js.map +1 -0
- package/package.json +12 -66
- package/src/__tests__/singleton.test.ts +0 -143
- package/src/index.ts +2 -83
- package/src/utils/Lib.ts +0 -77
- package/src/utils/index.ts +0 -3
- package/src/websocket.shared.types.ts +27 -0
- package/dist/application.d.ts +0 -18
- package/dist/application.js +0 -60
- package/dist/application.js.map +0 -1
- package/dist/client/api/base.api.d.ts +0 -63
- package/dist/client/api/base.api.js +0 -61
- package/dist/client/api/base.api.js.map +0 -1
- package/dist/client/api/index.d.ts +0 -2
- package/dist/client/api/index.js +0 -5
- package/dist/client/api/index.js.map +0 -1
- package/dist/client/rxjs/index.d.ts +0 -1
- package/dist/client/rxjs/index.js +0 -4
- package/dist/client/rxjs/index.js.map +0 -1
- package/dist/client/rxjs/useRxjs.d.ts +0 -17
- package/dist/client/rxjs/useRxjs.js +0 -87
- package/dist/client/rxjs/useRxjs.js.map +0 -1
- package/dist/client/vite/plugins/index.d.ts +0 -2
- package/dist/client/vite/plugins/index.js +0 -5
- package/dist/client/vite/plugins/index.js.map +0 -1
- package/dist/client/vite/plugins/topsydeUtilsVitePlugin.d.ts +0 -9
- package/dist/client/vite/plugins/topsydeUtilsVitePlugin.js +0 -74
- package/dist/client/vite/plugins/topsydeUtilsVitePlugin.js.map +0 -1
- package/dist/external/index.d.ts +0 -1
- package/dist/external/index.js +0 -4
- package/dist/external/index.js.map +0 -1
- package/dist/external/re-exports.d.ts +0 -16
- package/dist/external/re-exports.js +0 -24
- package/dist/external/re-exports.js.map +0 -1
- package/dist/server/base/base.database.d.ts +0 -10
- package/dist/server/base/base.database.js +0 -23
- package/dist/server/base/base.database.js.map +0 -1
- package/dist/server/base/index.d.ts +0 -2
- package/dist/server/base/index.js +0 -5
- package/dist/server/base/index.js.map +0 -1
- package/dist/server/bun/index.d.ts +0 -3
- package/dist/server/bun/index.js +0 -6
- package/dist/server/bun/index.js.map +0 -1
- package/dist/server/bun/router/controller-discovery.d.ts +0 -13
- package/dist/server/bun/router/controller-discovery.js +0 -83
- package/dist/server/bun/router/controller-discovery.js.map +0 -1
- package/dist/server/bun/router/index.d.ts +0 -6
- package/dist/server/bun/router/index.js +0 -9
- package/dist/server/bun/router/index.js.map +0 -1
- package/dist/server/bun/router/router.d.ts +0 -12
- package/dist/server/bun/router/router.internal.d.ts +0 -15
- package/dist/server/bun/router/router.internal.js +0 -51
- package/dist/server/bun/router/router.internal.js.map +0 -1
- package/dist/server/bun/router/router.js +0 -38
- package/dist/server/bun/router/router.js.map +0 -1
- package/dist/server/bun/router/routes.d.ts +0 -5
- package/dist/server/bun/router/routes.js +0 -2
- package/dist/server/bun/router/routes.js.map +0 -1
- package/dist/server/bun/websocket/Channel.d.ts +0 -68
- package/dist/server/bun/websocket/Channel.js +0 -263
- package/dist/server/bun/websocket/Channel.js.map +0 -1
- package/dist/server/bun/websocket/Client.d.ts +0 -87
- package/dist/server/bun/websocket/Client.js +0 -193
- package/dist/server/bun/websocket/Client.js.map +0 -1
- package/dist/server/bun/websocket/Message.d.ts +0 -10
- package/dist/server/bun/websocket/Message.js +0 -103
- package/dist/server/bun/websocket/Message.js.map +0 -1
- package/dist/server/bun/websocket/Websocket.d.ts +0 -171
- package/dist/server/bun/websocket/Websocket.js +0 -336
- package/dist/server/bun/websocket/Websocket.js.map +0 -1
- package/dist/server/bun/websocket/index.d.ts +0 -11
- package/dist/server/bun/websocket/index.js +0 -14
- package/dist/server/bun/websocket/index.js.map +0 -1
- package/dist/server/bun/websocket/websocket.enums.d.ts +0 -27
- package/dist/server/bun/websocket/websocket.enums.js +0 -31
- package/dist/server/bun/websocket/websocket.enums.js.map +0 -1
- package/dist/server/bun/websocket/websocket.guards.d.ts +0 -3
- package/dist/server/bun/websocket/websocket.guards.js +0 -17
- package/dist/server/bun/websocket/websocket.guards.js.map +0 -1
- package/dist/server/bun/websocket/websocket.types.d.ts +0 -235
- package/dist/server/bun/websocket/websocket.types.js +0 -2
- package/dist/server/bun/websocket/websocket.types.js.map +0 -1
- package/dist/server/controller.d.ts +0 -62
- package/dist/server/controller.js +0 -55
- package/dist/server/controller.js.map +0 -1
- package/dist/server/index.d.ts +0 -4
- package/dist/server/index.js +0 -7
- package/dist/server/index.js.map +0 -1
- package/dist/server/service.d.ts +0 -5
- package/dist/server/service.js +0 -38
- package/dist/server/service.js.map +0 -1
- package/dist/utils/BaseDto.d.ts +0 -33
- package/dist/utils/BaseDto.js +0 -69
- package/dist/utils/BaseDto.js.map +0 -1
- package/dist/utils/BaseEntity.d.ts +0 -31
- package/dist/utils/BaseEntity.js +0 -37
- package/dist/utils/BaseEntity.js.map +0 -1
- package/dist/utils/dto_validators/IsNumberOrRangeConstraint.d.ts +0 -9
- package/dist/utils/dto_validators/IsNumberOrRangeConstraint.js +0 -85
- package/dist/utils/dto_validators/IsNumberOrRangeConstraint.js.map +0 -1
- package/dist/utils/dto_validators/index.d.ts +0 -1
- package/dist/utils/dto_validators/index.js +0 -4
- package/dist/utils/dto_validators/index.js.map +0 -1
- package/src/__tests__/app.test.ts +0 -206
- package/src/application.ts +0 -73
- package/src/client/api/base.api.ts +0 -111
- package/src/client/api/index.ts +0 -5
- package/src/client/rxjs/index.ts +0 -4
- package/src/client/rxjs/useRxjs.ts +0 -113
- package/src/client/vite/plugins/index.ts +0 -5
- package/src/client/vite/plugins/topsydeUtilsVitePlugin.ts +0 -80
- package/src/external/index.ts +0 -4
- package/src/external/re-exports.ts +0 -54
- package/src/server/base/base.database.ts +0 -31
- package/src/server/base/index.ts +0 -5
- package/src/server/bun/index.ts +0 -6
- package/src/server/bun/router/controller-discovery.ts +0 -94
- package/src/server/bun/router/index.ts +0 -9
- package/src/server/bun/router/router.internal.ts +0 -64
- package/src/server/bun/router/router.ts +0 -51
- package/src/server/bun/router/routes.ts +0 -7
- package/src/server/bun/websocket/Channel.ts +0 -310
- package/src/server/bun/websocket/Client.ts +0 -243
- package/src/server/bun/websocket/ISSUES.md +0 -1175
- package/src/server/bun/websocket/Message.ts +0 -120
- package/src/server/bun/websocket/Websocket.ts +0 -402
- package/src/server/bun/websocket/index.ts +0 -14
- package/src/server/bun/websocket/websocket.enums.ts +0 -29
- package/src/server/bun/websocket/websocket.guards.ts +0 -22
- package/src/server/bun/websocket/websocket.types.ts +0 -252
- package/src/server/controller.ts +0 -121
- package/src/server/index.ts +0 -7
- package/src/server/service.ts +0 -36
- package/src/utils/BaseDto.ts +0 -77
- package/src/utils/BaseEntity.ts +0 -49
- package/src/utils/dto_validators/IsNumberOrRangeConstraint.ts +0 -32
- package/src/utils/dto_validators/index.ts +0 -4
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import Axios, { isAxiosError } from "axios";
|
|
2
|
-
class BaseAPI {
|
|
3
|
-
constructor(controller, base_url) {
|
|
4
|
-
this.controller = controller;
|
|
5
|
-
this.base_url = base_url || import.meta.env.VITE_HOST || "";
|
|
6
|
-
this.api = this.initAxios();
|
|
7
|
-
}
|
|
8
|
-
initAxios() {
|
|
9
|
-
const config = {
|
|
10
|
-
headers: {
|
|
11
|
-
"Content-Type": "application/json",
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
const instance = Axios.create(config);
|
|
15
|
-
// Add interceptor to modify request config
|
|
16
|
-
instance.interceptors.request.use((config) => {
|
|
17
|
-
// Ensure the correct content type
|
|
18
|
-
config.headers["Content-Type"] = "application/json";
|
|
19
|
-
return config;
|
|
20
|
-
});
|
|
21
|
-
return instance;
|
|
22
|
-
}
|
|
23
|
-
static Status(response) {
|
|
24
|
-
if (!response.data.status)
|
|
25
|
-
throw new Error("Something went wrong");
|
|
26
|
-
}
|
|
27
|
-
async get(controllerOrEndpoint, endpoint, _debounceDelay) {
|
|
28
|
-
let controller = endpoint ? controllerOrEndpoint : this.controller;
|
|
29
|
-
let action = endpoint ? endpoint : controllerOrEndpoint;
|
|
30
|
-
return this.api.get(`${this.base_url}/${controller}/${action}`).catch((err) => {
|
|
31
|
-
if (isAxiosError(err))
|
|
32
|
-
throw err.response;
|
|
33
|
-
throw err;
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
async post(controllerOrEndpoint, endpointOrPayload, payload) {
|
|
37
|
-
let controller;
|
|
38
|
-
let action;
|
|
39
|
-
let data;
|
|
40
|
-
if (payload !== null && payload !== undefined) {
|
|
41
|
-
controller = controllerOrEndpoint;
|
|
42
|
-
action = endpointOrPayload;
|
|
43
|
-
data = payload;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
controller = this.controller;
|
|
47
|
-
action = controllerOrEndpoint;
|
|
48
|
-
data = endpointOrPayload;
|
|
49
|
-
}
|
|
50
|
-
const response = await this.api.post(`${this.base_url}/${controller}/${action}`, data).catch((err) => {
|
|
51
|
-
if (isAxiosError(err))
|
|
52
|
-
throw err.response;
|
|
53
|
-
throw err;
|
|
54
|
-
});
|
|
55
|
-
if (!response.data.status)
|
|
56
|
-
throw new Error("Something went wrong");
|
|
57
|
-
return response;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
export default BaseAPI;
|
|
61
|
-
//# sourceMappingURL=base.api.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.api.js","sourceRoot":"","sources":["../../../src/client/api/base.api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAoD,YAAY,EAAE,MAAM,OAAO,CAAC;AAC9F,MAAM,OAAO;IAKZ,YAAY,UAAkB,EAAE,QAA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C,GAAG,CAAC;gBAAE,MAAM,GAAG,CAAC,QAAQ,CAAC;YAC1C,MAAM,GAAG,CAAC;QACX,CAAC,CAAC,CAAC;IACJ,CAAC;IAmBD,KAAK,CAAC,IAAI,CAAgC,oBAA4B,EAAE,iBAA+B,EAAE,OAAa;QACrH,IAAI,UAAkB,CAAC;QACvB,IAAI,MAAc,CAAC;QACnB,IAAI,IAAS,CAAC;QAEd,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC/C,UAAU,GAAG,oBAAoB,CAAC;YAClC,MAAM,GAAG,iBAAiB,CAAC;YAC3B,IAAI,GAAG,OAAO,CAAC;QAChB,CAAC;aAAM,CAAC;YACP,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;YAC7B,MAAM,GAAG,oBAAoB,CAAC;YAC9B,IAAI,GAAG,iBAAiB,CAAC;QAC1B,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAI,GAAG,IAAI,CAAC,QAAQ,IAAI,UAAU,IAAI,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACvG,IAAI,YAAY,CAAC,GAAG,CAAC;gBAAE,MAAM,GAAG,CAAC,QAAQ,CAAC;YAC1C,MAAM,GAAG,CAAC;QACX,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACnE,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD;AAED,eAAe,OAAO,CAAC","sourcesContent":["import Axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, isAxiosError } from \"axios\";\nclass BaseAPI {\n\tprivate api: AxiosInstance;\n\tprotected controller: string;\n\tprotected base_url: string;\n\n\tconstructor(controller: string, base_url?: string) {\n\t\tthis.controller = controller;\n\t\tthis.base_url = base_url || import.meta.env.VITE_HOST || \"\";\n\t\tthis.api = this.initAxios();\n\t}\n\n\tprivate initAxios(): AxiosInstance {\n\t\tconst config: AxiosRequestConfig = {\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t},\n\t\t};\n\n\t\tconst instance = Axios.create(config);\n\n\t\t// Add interceptor to modify request config\n\t\tinstance.interceptors.request.use((config) => {\n\t\t\t// Ensure the correct content type\n\t\t\tconfig.headers[\"Content-Type\"] = \"application/json\";\n\n\t\t\treturn config;\n\t\t});\n\n\t\treturn instance;\n\t}\n\n\tpublic static Status(response: AxiosResponse<{ status: boolean }>) {\n\t\tif (!response.data.status) throw new Error(\"Something went wrong\");\n\t}\n\n\t/**\n\t * @description Axios GET request wrapper\n\t * @param endpoint string\n\t * @generic T\n\t * @returns Promise<AxiosResponse<T>>\n\t */\n\tasync get<T extends { status: boolean }>(endpoint: string): Promise<AxiosResponse<T>>;\n\t/**\n\t * @description Axios GET request wrapper\n\t * @param controller string - which controller to use\n\t * @param endpoint string - controller action to call\n\t * @generic T\n\t * @returns Promise<AxiosResponse<T>>\n\t */\n\tasync get<T extends { status: boolean }>(controller: string, endpoint: string): Promise<AxiosResponse<T>>;\n\t/**\n\t * @description Axios GET request wrapper\n\t * @param controller string - which controller to use\n\t * @param endpoint string - controller action to call\n\t * @param debounceDelay number - debounce delay\n\t * @generic T\n\t * @returns Promise<AxiosResponse<T>>\n\t */\n\tasync get<T extends { status: boolean }>(controller: string, endpoint: string, debounceDelay?: number): Promise<AxiosResponse<T>>;\n\tasync get<T extends { status: boolean }>(controllerOrEndpoint: string, endpoint?: string | undefined, _debounceDelay?: number): Promise<AxiosResponse<T>> {\n\t\tlet controller = endpoint ? controllerOrEndpoint : this.controller;\n\t\tlet action = endpoint ? endpoint : controllerOrEndpoint;\n\n\t\treturn this.api.get<T>(`${this.base_url}/${controller}/${action}`).catch((err) => {\n\t\t\tif (isAxiosError(err)) throw err.response;\n\t\t\tthrow err;\n\t\t});\n\t}\n\n\t/**\n\t * @description Axios POST request wrapper\n\t * @param endpoint string - controller action to call\n\t * @param payload any\n\t * @generic T\n\t * @returns Promise<AxiosResponse<T>>\n\t */\n\tasync post<T extends { status: boolean }>(endpoint: string, payload: any): Promise<AxiosResponse<T>>;\n\t/**\n\t * @description Axios POST request wrapper\n\t * @param controller string - which controller to use\n\t * @param endpoint string - controller action to call\n\t * @param payload any\n\t * @generic T\n\t * @returns Promise<AxiosResponse<T>>\n\t */\n\tasync post<T extends { status: boolean }>(controller: string, endpoint: string, payload: any): Promise<AxiosResponse<T>>;\n\tasync post<T extends { status: boolean }>(controllerOrEndpoint: string, endpointOrPayload: string | any, payload?: any): Promise<AxiosResponse<T>> {\n\t\tlet controller: string;\n\t\tlet action: string;\n\t\tlet data: any;\n\n\t\tif (payload !== null && payload !== undefined) {\n\t\t\tcontroller = controllerOrEndpoint;\n\t\t\taction = endpointOrPayload;\n\t\t\tdata = payload;\n\t\t} else {\n\t\t\tcontroller = this.controller;\n\t\t\taction = controllerOrEndpoint;\n\t\t\tdata = endpointOrPayload;\n\t\t}\n\t\tconst response = await this.api.post<T>(`${this.base_url}/${controller}/${action}`, data).catch((err) => {\n\t\t\tif (isAxiosError(err)) throw err.response;\n\t\t\tthrow err;\n\t\t});\n\t\tif (!response.data.status) throw new Error(\"Something went wrong\");\n\t\treturn response;\n\t}\n}\n\nexport default BaseAPI;\n"]}
|
package/dist/client/api/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/api/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,iCAAiC;AAEjC,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,YAAY,CAAC","sourcesContent":["// This file is auto-generated by scripts/generate-indexes.ts\n// Do not edit this file directly\n\nexport * from './base.api';\nexport { default as BaseAPI } from './base.api';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useRxjs';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/rxjs/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,iCAAiC;AAEjC,cAAc,WAAW,CAAC","sourcesContent":["// This file is auto-generated by scripts/generate-indexes.ts\n// Do not edit this file directly\n\nexport * from './useRxjs';\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { I_RxjsPayload, RxjsNamespaces } from "../../utils/Rxjs";
|
|
2
|
-
export type RxjsDataType = string | Record<string, any>;
|
|
3
|
-
export type NamespaceActions = Record<string, (data: any) => void>;
|
|
4
|
-
export type MultiNamespaceActions<T extends string> = Partial<Record<RxjsNamespaces<T>, NamespaceActions>>;
|
|
5
|
-
export declare const useRxjs: <T extends string>(_namespace: RxjsNamespaces<T> | RxjsNamespaces<T>[], actions?: NamespaceActions | MultiNamespaceActions<T>, options?: {
|
|
6
|
-
static_instance: boolean;
|
|
7
|
-
}) => {
|
|
8
|
-
$next: {
|
|
9
|
-
(namespace: RxjsNamespaces<T>, payload: I_RxjsPayload<any>): void;
|
|
10
|
-
(cta: string, data: RxjsDataType): void;
|
|
11
|
-
};
|
|
12
|
-
$clear: (namespace: RxjsNamespaces<T>) => void;
|
|
13
|
-
$subscribe: (actions: NamespaceActions | MultiNamespaceActions<T>) => void;
|
|
14
|
-
$unsubscribe: () => void;
|
|
15
|
-
$mount: () => void;
|
|
16
|
-
$unmount: () => void;
|
|
17
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { onBeforeUnmount, onMounted, ref } from "vue";
|
|
2
|
-
import { Guards, Lib } from "../../utils/index.js";
|
|
3
|
-
import { Rxjs } from "../../utils/Rxjs.js";
|
|
4
|
-
export const useRxjs = (_namespace, actions, options) => {
|
|
5
|
-
const subs = ref(new Map());
|
|
6
|
-
const _actions = ref(actions);
|
|
7
|
-
const instance = Rxjs.GetInstance();
|
|
8
|
-
const namespaces = ref(Guards.IsArray(_namespace) ? _namespace : [_namespace]);
|
|
9
|
-
namespaces.value.forEach((ns) => {
|
|
10
|
-
if (instance.has(ns))
|
|
11
|
-
return;
|
|
12
|
-
console.log("Creating namespace", ns);
|
|
13
|
-
instance.create(ns);
|
|
14
|
-
});
|
|
15
|
-
function _getAction(cta, ns) {
|
|
16
|
-
if (Guards.IsArray(_namespace))
|
|
17
|
-
return _actions.value?.[ns]?.[cta];
|
|
18
|
-
return _actions.value?.[cta];
|
|
19
|
-
}
|
|
20
|
-
function $next(firstParam, secondParam) {
|
|
21
|
-
// Check if second param is a payload object (has both 'cta' and 'data' properties)
|
|
22
|
-
if (secondParam && typeof secondParam === "object" && "cta" in secondParam && "data" in secondParam) {
|
|
23
|
-
const ns = firstParam;
|
|
24
|
-
const payload = secondParam;
|
|
25
|
-
instance.next(ns, payload);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
// Otherwise treat first param as cta and second as data
|
|
29
|
-
const cta = firstParam;
|
|
30
|
-
const data = secondParam;
|
|
31
|
-
const namespaces = Guards.IsArray(_namespace) ? _namespace : [_namespace];
|
|
32
|
-
namespaces.forEach((ns) => {
|
|
33
|
-
instance.next(ns, { cta, data });
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
function $clear(namespace) {
|
|
37
|
-
instance.clear(namespace);
|
|
38
|
-
}
|
|
39
|
-
function $subscribe(actions) {
|
|
40
|
-
_actions.value = actions;
|
|
41
|
-
$unsubscribe(); // Clear existing subscriptions
|
|
42
|
-
const namespaces = Guards.IsArray(_namespace) ? _namespace : [_namespace];
|
|
43
|
-
namespaces.forEach((ns) => {
|
|
44
|
-
if (!instance.namespaces.has(ns)) {
|
|
45
|
-
Lib.Warn(`Rxjs namespace ${ns} does not exist`);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (subs.value.has(ns))
|
|
49
|
-
return;
|
|
50
|
-
subs.value.set(ns, instance.subscribe(ns, ({ cta, data }) => {
|
|
51
|
-
const action = _getAction(cta, ns) || (() => { });
|
|
52
|
-
action(data);
|
|
53
|
-
}));
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
function $unsubscribe() {
|
|
57
|
-
subs.value.forEach((sub) => sub.unsubscribe());
|
|
58
|
-
subs.value.clear();
|
|
59
|
-
}
|
|
60
|
-
function $mount() {
|
|
61
|
-
if (subs.value.size > 0 || !actions)
|
|
62
|
-
return;
|
|
63
|
-
$subscribe(actions);
|
|
64
|
-
}
|
|
65
|
-
function $unmount() {
|
|
66
|
-
$unsubscribe();
|
|
67
|
-
}
|
|
68
|
-
if (!options?.static_instance) {
|
|
69
|
-
onMounted(() => {
|
|
70
|
-
$mount();
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
if (!options?.static_instance) {
|
|
74
|
-
onBeforeUnmount(() => {
|
|
75
|
-
$unmount();
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
$next,
|
|
80
|
-
$clear,
|
|
81
|
-
$subscribe,
|
|
82
|
-
$unsubscribe,
|
|
83
|
-
$mount,
|
|
84
|
-
$unmount,
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
//# sourceMappingURL=useRxjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useRxjs.js","sourceRoot":"","sources":["../../../src/client/rxjs/useRxjs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAiB,IAAI,EAAkB,MAAM,kBAAkB,CAAC;AAMvE,MAAM,CAAC,MAAM,OAAO,GAAG,CACtB,UAAmD,EACnD,OAAqD,EACrD,OAAsC,EACrC,EAAE;IACH,MAAM,IAAI,GAAG,GAAG,CAAuC,IAAI,GAAG,EAAE,CAAC,CAAC;I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J,CAAC;IAED,SAAS,YAAY;QACpB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;IAED,SAAS,MAAM;QACd,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO;QAC5C,UAAU,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAED,SAAS,QAAQ;QAChB,YAAY,EAAE,CAAC;IAChB,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,eAAe,EAAE,CAAC;QAC/B,SAAS,CAAC,GAAG,EAAE;YACd,MAAM,EAAE,CAAC;QACV,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,eAAe,EAAE,CAAC;QAC/B,eAAe,CAAC,GAAG,EAAE;YACpB,QAAQ,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,OAAO;QACN,KAAK;QACL,MAAM;QACN,UAAU;QACV,YAAY;QACZ,MAAM;QACN,QAAQ;KACR,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { Subscription } from \"rxjs\";\nimport { onBeforeUnmount, onMounted, ref } from \"vue\";\nimport { Guards, Lib } from \"../../utils\";\nimport { I_RxjsPayload, Rxjs, RxjsNamespaces } from \"../../utils/Rxjs\";\n\nexport type RxjsDataType = string | Record<string, any>;\nexport type NamespaceActions = Record<string, (data: any) => void>;\nexport type MultiNamespaceActions<T extends string> = Partial<Record<RxjsNamespaces<T>, NamespaceActions>>;\n\nexport const useRxjs = <T extends string>(\n\t_namespace: RxjsNamespaces<T> | RxjsNamespaces<T>[],\n\tactions?: NamespaceActions | MultiNamespaceActions<T>,\n\toptions?: { static_instance: boolean },\n) => {\n\tconst subs = ref<Map<RxjsNamespaces<T>, Subscription>>(new Map());\n\tconst _actions = ref(actions);\n\tconst instance = Rxjs.GetInstance<Rxjs<T>>();\n\tconst namespaces = ref<RxjsNamespaces<T>[]>(Guards.IsArray(_namespace) ? _namespace : [_namespace]);\n\n\tnamespaces.value.forEach((ns) => {\n\t\tif (instance.has(ns)) return;\n\t\tconsole.log(\"Creating namespace\", ns);\n\t\tinstance.create(ns);\n\t});\n\n\tfunction _getAction(cta: string, ns: RxjsNamespaces<T>) {\n\t\tif (Guards.IsArray(_namespace)) return _actions.value?.[ns]?.[cta];\n\t\treturn _actions.value?.[cta];\n\t}\n\n\tfunction $next(namespace: RxjsNamespaces<T>, payload: I_RxjsPayload<any>): void;\n\tfunction $next(cta: string, data: RxjsDataType): void;\n\tfunction $next(firstParam: RxjsNamespaces<T> | string, secondParam: I_RxjsPayload<RxjsDataType> | any): void {\n\t\t// Check if second param is a payload object (has both 'cta' and 'data' properties)\n\t\tif (secondParam && typeof secondParam === \"object\" && \"cta\" in secondParam && \"data\" in secondParam) {\n\t\t\tconst ns = firstParam as RxjsNamespaces<T>;\n\t\t\tconst payload: I_RxjsPayload<any> = secondParam;\n\t\t\tinstance.next(ns, payload);\n\t\t\treturn;\n\t\t}\n\n\t\t// Otherwise treat first param as cta and second as data\n\t\tconst cta = firstParam as string;\n\t\tconst data = secondParam as RxjsDataType;\n\t\tconst namespaces = Guards.IsArray(_namespace) ? _namespace : [_namespace];\n\t\tnamespaces.forEach((ns) => {\n\t\t\tinstance.next(ns, { cta, data });\n\t\t});\n\t}\n\n\tfunction $clear(namespace: RxjsNamespaces<T>) {\n\t\tinstance.clear(namespace);\n\t}\n\n\tfunction $subscribe(actions: NamespaceActions | MultiNamespaceActions<T>) {\n\t\t_actions.value = actions;\n\t\t$unsubscribe(); // Clear existing subscriptions\n\n\t\tconst namespaces = Guards.IsArray(_namespace) ? _namespace : [_namespace];\n\n\t\tnamespaces.forEach((ns) => {\n\t\t\tif (!instance.namespaces.has(ns)) {\n\t\t\t\tLib.Warn(`Rxjs namespace ${ns} does not exist`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (subs.value.has(ns)) return;\n\n\t\t\tsubs.value.set(\n\t\t\t\tns,\n\t\t\t\tinstance.subscribe(ns, ({ cta, data }) => {\n\t\t\t\t\tconst action = _getAction(cta, ns) || (() => {});\n\t\t\t\t\taction(data);\n\t\t\t\t}),\n\t\t\t);\n\t\t});\n\t}\n\n\tfunction $unsubscribe() {\n\t\tsubs.value.forEach((sub) => sub.unsubscribe());\n\t\tsubs.value.clear();\n\t}\n\n\tfunction $mount() {\n\t\tif (subs.value.size > 0 || !actions) return;\n\t\t$subscribe(actions);\n\t}\n\n\tfunction $unmount() {\n\t\t$unsubscribe();\n\t}\n\n\tif (!options?.static_instance) {\n\t\tonMounted(() => {\n\t\t\t$mount();\n\t\t});\n\t}\n\n\tif (!options?.static_instance) {\n\t\tonBeforeUnmount(() => {\n\t\t\t$unmount();\n\t\t});\n\t}\n\n\treturn {\n\t\t$next,\n\t\t$clear,\n\t\t$subscribe,\n\t\t$unsubscribe,\n\t\t$mount,\n\t\t$unmount,\n\t};\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/vite/plugins/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,iCAAiC;AAEjC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["// This file is auto-generated by scripts/generate-indexes.ts\n// Do not edit this file directly\n\nexport * from './topsydeUtilsVitePlugin';\nexport { default as TopsydeUtilsVitePlugin } from './topsydeUtilsVitePlugin';\n"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from "vite";
|
|
2
|
-
/**
|
|
3
|
-
* Creates a Vite plugin that provides compatibility for topsyde-utils in browser environments
|
|
4
|
-
* by disabling sourcemaps and providing mock implementations of Node.js modules.
|
|
5
|
-
*
|
|
6
|
-
* @returns A single Vite plugin with all necessary functionality
|
|
7
|
-
*/
|
|
8
|
-
export declare function TopsydeUtilsVitePlugin(): Plugin;
|
|
9
|
-
export default TopsydeUtilsVitePlugin;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a Vite plugin that provides compatibility for topsyde-utils in browser environments
|
|
3
|
-
* by disabling sourcemaps and providing mock implementations of Node.js modules.
|
|
4
|
-
*
|
|
5
|
-
* @returns A single Vite plugin with all necessary functionality
|
|
6
|
-
*/
|
|
7
|
-
export function TopsydeUtilsVitePlugin() {
|
|
8
|
-
return {
|
|
9
|
-
name: "topsyde-utils-compatibility",
|
|
10
|
-
// Disable sourcemaps for topsyde-utils
|
|
11
|
-
transform(code, id) {
|
|
12
|
-
if (id.includes("node_modules/topsyde-utils")) {
|
|
13
|
-
return {
|
|
14
|
-
code,
|
|
15
|
-
map: { mappings: "" }, // Return empty sourcemap
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
// Handle virtual modules for Node.js built-ins
|
|
20
|
-
resolveId(id) {
|
|
21
|
-
if (id === "virtual:path" || id === "virtual:fs") {
|
|
22
|
-
return id;
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
},
|
|
26
|
-
// Provide virtual module implementations
|
|
27
|
-
load(id) {
|
|
28
|
-
if (id === "virtual:path") {
|
|
29
|
-
return `
|
|
30
|
-
export function join() { return ''; }
|
|
31
|
-
export function resolve() { return ''; }
|
|
32
|
-
export function dirname() { return ''; }
|
|
33
|
-
export function basename() { return ''; }
|
|
34
|
-
export function extname() { return ''; }
|
|
35
|
-
export default { join, resolve, dirname, basename, extname };
|
|
36
|
-
`;
|
|
37
|
-
}
|
|
38
|
-
if (id === "virtual:fs") {
|
|
39
|
-
return `
|
|
40
|
-
export function readFileSync() { return ''; }
|
|
41
|
-
export function existsSync() { return false; }
|
|
42
|
-
export function writeFileSync() { return null; }
|
|
43
|
-
export function readdirSync() { return []; }
|
|
44
|
-
export function statSync() {
|
|
45
|
-
return {
|
|
46
|
-
isDirectory: () => false,
|
|
47
|
-
isFile: () => true
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
export default { readFileSync, existsSync, writeFileSync, readdirSync, statSync };
|
|
51
|
-
`;
|
|
52
|
-
}
|
|
53
|
-
return null;
|
|
54
|
-
},
|
|
55
|
-
// Configure aliases and optimization
|
|
56
|
-
config() {
|
|
57
|
-
return {
|
|
58
|
-
resolve: {
|
|
59
|
-
alias: {
|
|
60
|
-
// Alias Node.js built-ins to virtual modules
|
|
61
|
-
path: "virtual:path",
|
|
62
|
-
fs: "virtual:fs",
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
optimizeDeps: {
|
|
66
|
-
exclude: ["topsyde-utils"],
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
// Export as default for compatibility with different import styles
|
|
73
|
-
export default TopsydeUtilsVitePlugin;
|
|
74
|
-
//# sourceMappingURL=topsydeUtilsVitePlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"topsydeUtilsVitePlugin.js","sourceRoot":"","sources":["../../../../src/client/vite/plugins/topsydeUtilsVitePlugin.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB;IACrC,OAAO;QACN,IAAI,EAAE,6BAA6B;QAEnC,uCAAuC;QACvC,SAAS,CAAC,IAAI,EAAE,EAAE;YACjB,IAAI,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC,EAAE,CAAC;gBAC/C,OAAO;oBACN,IAAI;oBACJ,GAAG,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,yBAAyB;iBAChD,CAAC;YACH,CAAC;QACF,CAAC;QAED,+CAA+C;QAC/C,SAAS,CAAC,EAAE;YACX,IAAI,EAAE,KAAK,cAAc,IAAI,EAAE,KAAK,YAAY,EAAE,CAAC;gBAClD,OAAO,EAAE,CAAC;YACX,CAAC;YACD,OAAO,IAAI,CAAC;QACb,CAAC;QAED,yCAAyC;QACzC,IAAI,CAAC,EAAE;YACN,IAAI,EAAE,KAAK,cAAc,EAAE,CAAC;gBAC3B,OAAO;;;;;;;SAOF,CAAC;YACP,CAAC;YACD,IAAI,EAAE,KAAK,YAAY,EAAE,CAAC;gBACzB,OAAO;;;;;;;;;;;;SAYF,CAAC;YACP,CAAC;YACD,OAAO,IAAI,CAAC;QACb,CAAC;QAED,qCAAqC;QACrC,MAAM;YACL,OAAO;gBACN,OAAO,EAAE;oBACR,KAAK,EAAE;wBACN,6CAA6C;wBAC7C,IAAI,EAAE,cAAc;wBACpB,EAAE,EAAE,YAAY;qBAChB;iBACD;gBACD,YAAY,EAAE;oBACb,OAAO,EAAE,CAAC,eAAe,CAAC;iBAC1B;aACD,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC;AAED,mEAAmE;AACnE,eAAe,sBAAsB,CAAC","sourcesContent":["import type { Plugin } from \"vite\";\n\n/**\n * Creates a Vite plugin that provides compatibility for topsyde-utils in browser environments\n * by disabling sourcemaps and providing mock implementations of Node.js modules.\n * \n * @returns A single Vite plugin with all necessary functionality\n */\nexport function TopsydeUtilsVitePlugin(): Plugin {\n\treturn {\n\t\tname: \"topsyde-utils-compatibility\",\n\n\t\t// Disable sourcemaps for topsyde-utils\n\t\ttransform(code, id) {\n\t\t\tif (id.includes(\"node_modules/topsyde-utils\")) {\n\t\t\t\treturn {\n\t\t\t\t\tcode,\n\t\t\t\t\tmap: { mappings: \"\" }, // Return empty sourcemap\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\n\t\t// Handle virtual modules for Node.js built-ins\n\t\tresolveId(id) {\n\t\t\tif (id === \"virtual:path\" || id === \"virtual:fs\") {\n\t\t\t\treturn id;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\n\t\t// Provide virtual module implementations\n\t\tload(id) {\n\t\t\tif (id === \"virtual:path\") {\n\t\t\t\treturn `\n export function join() { return ''; }\n export function resolve() { return ''; }\n export function dirname() { return ''; }\n export function basename() { return ''; }\n export function extname() { return ''; }\n export default { join, resolve, dirname, basename, extname };\n `;\n\t\t\t}\n\t\t\tif (id === \"virtual:fs\") {\n\t\t\t\treturn `\n export function readFileSync() { return ''; }\n export function existsSync() { return false; }\n export function writeFileSync() { return null; }\n export function readdirSync() { return []; }\n export function statSync() { \n return { \n isDirectory: () => false,\n isFile: () => true\n }; \n }\n export default { readFileSync, existsSync, writeFileSync, readdirSync, statSync };\n `;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\n\t\t// Configure aliases and optimization\n\t\tconfig() {\n\t\t\treturn {\n\t\t\t\tresolve: {\n\t\t\t\t\talias: {\n\t\t\t\t\t\t// Alias Node.js built-ins to virtual modules\n\t\t\t\t\t\tpath: \"virtual:path\",\n\t\t\t\t\t\tfs: \"virtual:fs\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\toptimizeDeps: {\n\t\t\t\t\texclude: [\"topsyde-utils\"],\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n\n// Export as default for compatibility with different import styles\nexport default TopsydeUtilsVitePlugin;\n"]}
|
package/dist/external/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './re-exports';
|
package/dist/external/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/external/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,iCAAiC;AAEjC,cAAc,cAAc,CAAC","sourcesContent":["// This file is auto-generated by scripts/generate-indexes.ts\n// Do not edit this file directly\n\nexport * from './re-exports';\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Re-exports of external dependencies for convenience
|
|
3
|
-
*
|
|
4
|
-
* This module re-exports commonly used types, classes, and decorators from
|
|
5
|
-
* class-transformer and class-validator to provide a single import source
|
|
6
|
-
* for projects using topsyde-utils.
|
|
7
|
-
*
|
|
8
|
-
* This prevents the need to separately install these dependencies in
|
|
9
|
-
* consuming projects, as they're already bundled with topsyde-utils.
|
|
10
|
-
*/
|
|
11
|
-
export type { ClassConstructor, ClassTransformOptions } from "class-transformer";
|
|
12
|
-
export { instanceToPlain, plainToInstance } from "class-transformer";
|
|
13
|
-
export { Expose } from "class-transformer";
|
|
14
|
-
export { ValidationError } from "class-validator";
|
|
15
|
-
export { validateSync } from "class-validator";
|
|
16
|
-
export { IsArray, IsBoolean, IsDate, IsEnum, IsNumber, IsObject, IsOptional, IsString, Validate, IsAlphanumeric, IsBooleanString, IsDateString, IsDecimal, IsDefined, IsNumberString, IsNotEmpty, IsNotEmptyObject, } from "class-validator";
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Re-exports of external dependencies for convenience
|
|
3
|
-
*
|
|
4
|
-
* This module re-exports commonly used types, classes, and decorators from
|
|
5
|
-
* class-transformer and class-validator to provide a single import source
|
|
6
|
-
* for projects using topsyde-utils.
|
|
7
|
-
*
|
|
8
|
-
* This prevents the need to separately install these dependencies in
|
|
9
|
-
* consuming projects, as they're already bundled with topsyde-utils.
|
|
10
|
-
*/
|
|
11
|
-
// Core transformation functions
|
|
12
|
-
export { instanceToPlain, plainToInstance } from "class-transformer";
|
|
13
|
-
// Decorators
|
|
14
|
-
export { Expose } from "class-transformer";
|
|
15
|
-
// ============================================================================
|
|
16
|
-
// class-validator exports
|
|
17
|
-
// ============================================================================
|
|
18
|
-
// Types and Classes
|
|
19
|
-
export { ValidationError } from "class-validator";
|
|
20
|
-
// Validation function
|
|
21
|
-
export { validateSync } from "class-validator";
|
|
22
|
-
// Property decorators
|
|
23
|
-
export { IsArray, IsBoolean, IsDate, IsEnum, IsNumber, IsObject, IsOptional, IsString, Validate, IsAlphanumeric, IsBooleanString, IsDateString, IsDecimal, IsDefined, IsNumberString, IsNotEmpty, IsNotEmptyObject, } from "class-validator";
|
|
24
|
-
//# sourceMappingURL=re-exports.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"re-exports.js","sourceRoot":"","sources":["../../src/external/re-exports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,gCAAgC;AAChC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAErE,aAAa;AACb,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E,oBAAoB;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,sBAAsB;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,sBAAsB;AACtB,OAAO,EACN,OAAO,EACP,SAAS,EACT,MAAM,EACN,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,eAAe,EACf,YAAY,EACZ,SAAS,EACT,SAAS,EACT,cAAc,EACd,UAAU,EACV,gBAAgB,GAChB,MAAM,iBAAiB,CAAC","sourcesContent":["/**\n * Re-exports of external dependencies for convenience\n *\n * This module re-exports commonly used types, classes, and decorators from\n * class-transformer and class-validator to provide a single import source\n * for projects using topsyde-utils.\n *\n * This prevents the need to separately install these dependencies in\n * consuming projects, as they're already bundled with topsyde-utils.\n */\n\n// ============================================================================\n// class-transformer exports\n// ============================================================================\n\n// Types\nexport type { ClassConstructor, ClassTransformOptions } from \"class-transformer\";\n\n// Core transformation functions\nexport { instanceToPlain, plainToInstance } from \"class-transformer\";\n\n// Decorators\nexport { Expose } from \"class-transformer\";\n\n// ============================================================================\n// class-validator exports\n// ============================================================================\n\n// Types and Classes\nexport { ValidationError } from \"class-validator\";\n\n// Validation function\nexport { validateSync } from \"class-validator\";\n\n// Property decorators\nexport {\n\tIsArray,\n\tIsBoolean,\n\tIsDate,\n\tIsEnum,\n\tIsNumber,\n\tIsObject,\n\tIsOptional,\n\tIsString,\n\tValidate,\n\tIsAlphanumeric,\n\tIsBooleanString,\n\tIsDateString,\n\tIsDecimal,\n\tIsDefined,\n\tIsNumberString,\n\tIsNotEmpty,\n\tIsNotEmptyObject,\n} from \"class-validator\";\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import Singleton from "../../singleton";
|
|
2
|
-
declare abstract class Database extends Singleton {
|
|
3
|
-
constructor();
|
|
4
|
-
abstract connect(): Promise<void>;
|
|
5
|
-
abstract disconnect(): Promise<void>;
|
|
6
|
-
protected connected: boolean;
|
|
7
|
-
protected processing: boolean;
|
|
8
|
-
static Connection<T extends (new (...args: any[]) => Database) & typeof Singleton>(this: T, ...args: ConstructorParameters<T>): Promise<InstanceType<T>>;
|
|
9
|
-
}
|
|
10
|
-
export default Database;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import Singleton from "../../singleton.js";
|
|
2
|
-
class Database extends Singleton {
|
|
3
|
-
constructor() {
|
|
4
|
-
super();
|
|
5
|
-
this.connected = false;
|
|
6
|
-
this.processing = false;
|
|
7
|
-
}
|
|
8
|
-
static async Connection(...args) {
|
|
9
|
-
try {
|
|
10
|
-
const instance = this.GetInstance(...args);
|
|
11
|
-
if (!instance.connected && !instance.processing) {
|
|
12
|
-
await instance.connect();
|
|
13
|
-
}
|
|
14
|
-
return instance;
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
console.error(e);
|
|
18
|
-
throw e;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export default Database;
|
|
23
|
-
//# sourceMappingURL=base.database.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.database.js","sourceRoot":"","sources":["../../../src/server/base/base.database.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,iBAAiB,CAAC;AAExC,MAAe,QAAS,SAAQ,SAAS;IACxC;QACC,KAAK,EAAE,CAAC;QAMC,cAAS,GAAY,KAAK,CAAC;QAC3B,eAAU,GAAY,KAAK,CAAC;IANtC,CAAC;IAQM,MAAM,CAAC,KAAK,CAAC,UAAU,CAE7B,GAAG,IAA8B;QAEjC,IAAI,CAAC;YACJ,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAoB,CAAC;YAC9D,IAAI,CAAC,QAAQ,CAAC,SAAS,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;gBACjD,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;YAC1B,CAAC;YACD,OAAO,QAAQ,CAAC;QACjB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjB,MAAM,CAAC,CAAC;QACT,CAAC;IACF,CAAC;CACD;AAED,eAAe,QAAQ,CAAC","sourcesContent":["import Singleton from \"../../singleton\";\n\nabstract class Database extends Singleton {\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic abstract connect(): Promise<void>;\n\tpublic abstract disconnect(): Promise<void>;\n\n\tprotected connected: boolean = false;\n\tprotected processing: boolean = false;\n\n\tpublic static async Connection<T extends (new (...args: any[]) => Database) & typeof Singleton>(\n\t\tthis: T,\n\t\t...args: ConstructorParameters<T>\n\t): Promise<InstanceType<T>> {\n\t\ttry {\n\t\t\tconst instance = this.GetInstance(...args) as InstanceType<T>;\n\t\t\tif (!instance.connected && !instance.processing) {\n\t\t\t\tawait instance.connect();\n\t\t\t}\n\t\t\treturn instance;\n\t\t} catch (e) {\n\t\t\tconsole.error(e);\n\t\t\tthrow e;\n\t\t}\n\t}\n}\n\nexport default Database;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/base/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,iCAAiC;AAEjC,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["// This file is auto-generated by scripts/generate-indexes.ts\n// Do not edit this file directly\n\nexport * from './base.database';\nexport { default as Database } from './base.database';\n"]}
|
package/dist/server/bun/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// This file is auto-generated by scripts/generate-indexes.sh
|
|
2
|
-
// Do not edit this file directly
|
|
3
|
-
export * from './websocket/Websocket.js';
|
|
4
|
-
export { default as Websocket } from './websocket/Websocket.js';
|
|
5
|
-
export * from './websocket/index.js';
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/bun/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,iCAAiC;AAEjC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC7D,cAAc,aAAa,CAAC","sourcesContent":["// This file is auto-generated by scripts/generate-indexes.sh\n// Do not edit this file directly\n\nexport * from './websocket/Websocket';\nexport { default as Websocket } from './websocket/Websocket';\nexport * from './websocket';\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Routes } from './routes';
|
|
2
|
-
/**
|
|
3
|
-
* Dynamically discovers and loads controllers from the components directory
|
|
4
|
-
*/
|
|
5
|
-
export declare class ControllerDiscovery {
|
|
6
|
-
static DiscoverRoutes(componentPaths: string[]): Promise<Routes>;
|
|
7
|
-
/**
|
|
8
|
-
* Discovers controllers in the specified directory
|
|
9
|
-
* @param componentsPath Optional custom path to components directory (relative to project root)
|
|
10
|
-
* @returns Routes object with discovered controllers
|
|
11
|
-
*/
|
|
12
|
-
static Find(componentsPath?: string): Promise<Routes>;
|
|
13
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
2
|
-
import { readdirSync, statSync } from 'fs';
|
|
3
|
-
import { Lib } from '../../../utils/index.js';
|
|
4
|
-
const fallbackRoutes = {};
|
|
5
|
-
/**
|
|
6
|
-
* Dynamically discovers and loads controllers from the components directory
|
|
7
|
-
*/
|
|
8
|
-
export class ControllerDiscovery {
|
|
9
|
-
static async DiscoverRoutes(componentPaths) {
|
|
10
|
-
try {
|
|
11
|
-
const allDiscoveredRoutes = {};
|
|
12
|
-
// Discover controllers in all specified component paths
|
|
13
|
-
for (const path of componentPaths) {
|
|
14
|
-
const discoveredRoutes = await ControllerDiscovery.Find(path);
|
|
15
|
-
// Merge discovered routes
|
|
16
|
-
Object.assign(allDiscoveredRoutes, discoveredRoutes);
|
|
17
|
-
}
|
|
18
|
-
// Use discovered routes if any were found, otherwise use fallback
|
|
19
|
-
if (Object.keys(allDiscoveredRoutes).length > 0) {
|
|
20
|
-
Lib.Log(`Using auto-discovered routes from paths: ${componentPaths.join(', ')}`);
|
|
21
|
-
return allDiscoveredRoutes;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
Lib.Log('No routes discovered, using fallback routes');
|
|
25
|
-
return fallbackRoutes;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
// If auto-discovery fails, use fallback routes
|
|
30
|
-
Lib.Warn('Controller auto-discovery failed, using fallback routes:', error);
|
|
31
|
-
return fallbackRoutes;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Discovers controllers in the specified directory
|
|
36
|
-
* @param componentsPath Optional custom path to components directory (relative to project root)
|
|
37
|
-
* @returns Routes object with discovered controllers
|
|
38
|
-
*/
|
|
39
|
-
static async Find(componentsPath) {
|
|
40
|
-
const routes = {};
|
|
41
|
-
// Get project root - use process.cwd() to get the root of the project using this library
|
|
42
|
-
const projectRoot = process.cwd();
|
|
43
|
-
// Use provided path or default to components directory
|
|
44
|
-
const componentsDir = componentsPath
|
|
45
|
-
? join(projectRoot, componentsPath) // From project root
|
|
46
|
-
: join(projectRoot, 'src', 'components'); // Default location
|
|
47
|
-
Lib.Log(`Looking for controllers in: ${componentsDir}`);
|
|
48
|
-
try {
|
|
49
|
-
// Get all component directories
|
|
50
|
-
const componentFolders = readdirSync(componentsDir).filter(folder => statSync(join(componentsDir, folder)).isDirectory());
|
|
51
|
-
// Process each component folder
|
|
52
|
-
for (const componentName of componentFolders) {
|
|
53
|
-
const controllerPath = join(componentsDir, componentName, `${componentName}.controller.ts`);
|
|
54
|
-
try {
|
|
55
|
-
// Check if controller file exists
|
|
56
|
-
const controllerFile = Bun.file(controllerPath);
|
|
57
|
-
if (await controllerFile.exists()) {
|
|
58
|
-
// Import the controller
|
|
59
|
-
try {
|
|
60
|
-
const module = await import(controllerPath);
|
|
61
|
-
const Controller = module.default;
|
|
62
|
-
if (Controller && typeof Controller === 'function') {
|
|
63
|
-
routes[componentName] = Controller;
|
|
64
|
-
Lib.Log(`Registered controller: ${componentName}`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
catch (err) {
|
|
68
|
-
Lib.Warn(`Failed to import controller for ${componentName}:`, err);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
catch (err) {
|
|
73
|
-
Lib.Warn(`Error processing component ${componentName}:`, err);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
catch (err) {
|
|
78
|
-
Lib.Warn(`Error discovering controllers in ${componentsDir}:`, err);
|
|
79
|
-
}
|
|
80
|
-
return routes;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=controller-discovery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"controller-discovery.js","sourceRoot":"","sources":["../../../../src/server/bun/router/controller-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,QAAQ,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,GAAG,EAAE,CAAC;oBACd,GAAG,CAAC,IAAI,CAAC,8BAA8B,aAAa,GAAG,EAAE,GAAG,CAAC,CAAC;gBAC/D,CAAC;YACF,CAAC;QACF,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,GAAG,CAAC,IAAI,CAAC,oCAAoC,aAAa,GAAG,EAAE,GAAG,CAAC,CAAC;QACrE,CAAC;QAED,OAAO,MAAM,CAAC;IACf,CAAC;CACD","sourcesContent":["import { join } from 'path';\nimport { readdirSync, statSync } from 'fs';\nimport { Lib } from '../../../utils';\nimport { Routes } from './routes';\n\nconst fallbackRoutes: Routes = {};\n\n/**\n * Dynamically discovers and loads controllers from the components directory\n */\nexport class ControllerDiscovery {\n\tpublic static async DiscoverRoutes(componentPaths: string[]) {\n\t\ttry {\n\t\t\tconst allDiscoveredRoutes: Routes = {};\n\n\t\t\t// Discover controllers in all specified component paths\n\t\t\tfor (const path of componentPaths) {\n\t\t\t\tconst discoveredRoutes = await ControllerDiscovery.Find(path);\n\n\t\t\t\t// Merge discovered routes\n\t\t\t\tObject.assign(allDiscoveredRoutes, discoveredRoutes);\n\t\t\t}\n\n\t\t\t// Use discovered routes if any were found, otherwise use fallback\n\t\t\tif (Object.keys(allDiscoveredRoutes).length > 0) {\n\t\t\t\tLib.Log(`Using auto-discovered routes from paths: ${componentPaths.join(', ')}`);\n\t\t\t\treturn allDiscoveredRoutes;\n\t\t\t} else {\n\t\t\t\tLib.Log('No routes discovered, using fallback routes');\n\t\t\t\treturn fallbackRoutes;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// If auto-discovery fails, use fallback routes\n\t\t\tLib.Warn('Controller auto-discovery failed, using fallback routes:', error);\n\t\t\treturn fallbackRoutes;\n\t\t}\n\t}\n\n\t/**\n\t * Discovers controllers in the specified directory\n\t * @param componentsPath Optional custom path to components directory (relative to project root)\n\t * @returns Routes object with discovered controllers\n\t */\n\tpublic static async Find(componentsPath?: string): Promise<Routes> {\n\t\tconst routes: Routes = {};\n\t\t\n\t\t// Get project root - use process.cwd() to get the root of the project using this library\n\t\tconst projectRoot = process.cwd();\n\t\t\n\t\t// Use provided path or default to components directory\n\t\tconst componentsDir = componentsPath\n\t\t\t? join(projectRoot, componentsPath) // From project root\n\t\t\t: join(projectRoot, 'src', 'components'); // Default location\n\t\t\n\t\tLib.Log(`Looking for controllers in: ${componentsDir}`);\n\n\t\ttry {\n\t\t\t// Get all component directories\n\t\t\tconst componentFolders = readdirSync(componentsDir).filter(folder =>\n\t\t\t\tstatSync(join(componentsDir, folder)).isDirectory()\n\t\t\t);\n\n\t\t\t// Process each component folder\n\t\t\tfor (const componentName of componentFolders) {\n\t\t\t\tconst controllerPath = join(componentsDir, componentName, `${componentName}.controller.ts`);\n\n\t\t\t\ttry {\n\t\t\t\t\t// Check if controller file exists\n\t\t\t\t\tconst controllerFile = Bun.file(controllerPath);\n\t\t\t\t\tif (await controllerFile.exists()) {\n\t\t\t\t\t\t// Import the controller\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst module = await import(controllerPath);\n\t\t\t\t\t\t\tconst Controller = module.default;\n\n\t\t\t\t\t\t\tif (Controller && typeof Controller === 'function') {\n\t\t\t\t\t\t\t\troutes[componentName] = Controller;\n\t\t\t\t\t\t\t\tLib.Log(`Registered controller: ${componentName}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\tLib.Warn(`Failed to import controller for ${componentName}:`, err);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\tLib.Warn(`Error processing component ${componentName}:`, err);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tLib.Warn(`Error discovering controllers in ${componentsDir}:`, err);\n\t\t}\n\n\t\treturn routes;\n\t}\n}\n"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// This file is auto-generated by scripts/generate-indexes.ts
|
|
2
|
-
// Do not edit this file directly
|
|
3
|
-
export * from './controller-discovery.js';
|
|
4
|
-
export * from './routes.js';
|
|
5
|
-
export * from './router.js';
|
|
6
|
-
export * from './router.internal.js';
|
|
7
|
-
export { default as Router } from './router.js';
|
|
8
|
-
export { default as Router_Internal } from './router.internal.js';
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/server/bun/router/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,iCAAiC;AAEjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["// This file is auto-generated by scripts/generate-indexes.ts\n// Do not edit this file directly\n\nexport * from './controller-discovery';\nexport * from './routes';\nexport * from './router';\nexport * from './router.internal';\nexport { default as Router } from './router';\nexport { default as Router_Internal } from './router.internal';\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Singleton from "../../../singleton";
|
|
2
|
-
import { Routes } from "./routes";
|
|
3
|
-
declare class Router extends Singleton {
|
|
4
|
-
private internal;
|
|
5
|
-
constructor(routes?: Routes);
|
|
6
|
-
private setRoutes;
|
|
7
|
-
static Call<T>(request: Request): Promise<T>;
|
|
8
|
-
static SetRoutes(routes: Routes): void;
|
|
9
|
-
private static getMethodMap;
|
|
10
|
-
static GetQueryParams(request: Request): URLSearchParams;
|
|
11
|
-
}
|
|
12
|
-
export default Router;
|