@meowpanel/api 0.1.0-alpha.11 → 1.0.0-beta.2
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/LICENSE +1 -1
- package/README.md +40 -0
- package/esm/mod.d.ts +87 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +85 -1
- package/esm/src/client.d.ts +248 -0
- package/esm/src/client.d.ts.map +1 -0
- package/esm/src/client.js +235 -0
- package/esm/src/emitter.d.ts +53 -0
- package/esm/src/emitter.d.ts.map +1 -0
- package/esm/src/emitter.js +55 -0
- package/esm/src/errors.d.ts +42 -0
- package/esm/src/errors.d.ts.map +1 -0
- package/esm/src/errors.js +45 -0
- package/esm/src/http.d.ts +157 -0
- package/esm/src/http.d.ts.map +1 -0
- package/esm/src/http.js +317 -0
- package/esm/src/namespace.d.ts +59 -0
- package/esm/src/namespace.d.ts.map +1 -0
- package/esm/src/namespace.js +79 -0
- package/esm/src/reactive.d.ts +29 -0
- package/esm/src/reactive.d.ts.map +1 -0
- package/esm/src/reactive.js +35 -0
- package/esm/src/resources/account.d.ts +125 -0
- package/esm/src/resources/account.d.ts.map +1 -0
- package/esm/src/resources/account.js +151 -0
- package/esm/src/resources/api-keys.d.ts +116 -0
- package/esm/src/resources/api-keys.d.ts.map +1 -0
- package/esm/src/resources/api-keys.js +105 -0
- package/esm/src/resources/auth.d.ts +57 -0
- package/esm/src/resources/auth.d.ts.map +1 -0
- package/esm/src/resources/auth.js +39 -0
- package/esm/src/resources/eggs.d.ts +238 -0
- package/esm/src/resources/eggs.d.ts.map +1 -0
- package/esm/src/resources/eggs.js +187 -0
- package/esm/src/resources/hosts.d.ts +62 -0
- package/esm/src/resources/hosts.d.ts.map +1 -0
- package/esm/src/resources/hosts.js +62 -0
- package/esm/src/resources/members.d.ts +138 -0
- package/esm/src/resources/members.d.ts.map +1 -0
- package/esm/src/resources/members.js +122 -0
- package/esm/src/resources/nodes.d.ts +397 -0
- package/esm/src/resources/nodes.d.ts.map +1 -0
- package/esm/src/resources/nodes.js +352 -0
- package/esm/src/resources/server-groups.d.ts +150 -0
- package/esm/src/resources/server-groups.d.ts.map +1 -0
- package/esm/src/resources/server-groups.js +111 -0
- package/esm/src/resources/servers/activity.d.ts +120 -0
- package/esm/src/resources/servers/activity.d.ts.map +1 -0
- package/esm/src/resources/servers/activity.js +163 -0
- package/esm/src/resources/servers/allocations.d.ts +125 -0
- package/esm/src/resources/servers/allocations.d.ts.map +1 -0
- package/esm/src/resources/servers/allocations.js +137 -0
- package/esm/src/resources/servers/connection.d.ts +108 -0
- package/esm/src/resources/servers/connection.d.ts.map +1 -0
- package/esm/src/resources/servers/connection.js +169 -0
- package/esm/src/resources/servers/files.d.ts +164 -0
- package/esm/src/resources/servers/files.d.ts.map +1 -0
- package/esm/src/resources/servers/files.js +281 -0
- package/esm/src/resources/servers/index.d.ts +126 -0
- package/esm/src/resources/servers/index.d.ts.map +1 -0
- package/esm/src/resources/servers/index.js +135 -0
- package/esm/src/resources/servers/profiles.d.ts +138 -0
- package/esm/src/resources/servers/profiles.d.ts.map +1 -0
- package/esm/src/resources/servers/profiles.js +177 -0
- package/esm/src/resources/servers/server.d.ts +136 -0
- package/esm/src/resources/servers/server.d.ts.map +1 -0
- package/esm/src/resources/servers/server.js +202 -0
- package/esm/src/resources/servers/sftp.d.ts +147 -0
- package/esm/src/resources/servers/sftp.d.ts.map +1 -0
- package/esm/src/resources/servers/sftp.js +153 -0
- package/esm/src/resources/servers/types.d.ts +199 -0
- package/esm/src/resources/servers/types.d.ts.map +1 -0
- package/esm/src/resources/servers/types.js +1 -0
- package/esm/src/sse.d.ts +53 -0
- package/esm/src/sse.d.ts.map +1 -0
- package/esm/src/sse.js +133 -0
- package/esm/src/types.d.ts +126 -0
- package/esm/src/types.d.ts.map +1 -0
- package/esm/src/types.js +21 -0
- package/package.json +4 -92
- package/script/mod.d.ts +87 -1
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +132 -3
- package/script/src/client.d.ts +248 -0
- package/script/src/client.d.ts.map +1 -0
- package/script/src/client.js +239 -0
- package/script/src/emitter.d.ts +53 -0
- package/script/src/emitter.d.ts.map +1 -0
- package/script/src/emitter.js +59 -0
- package/script/src/errors.d.ts +42 -0
- package/script/src/errors.d.ts.map +1 -0
- package/script/src/errors.js +49 -0
- package/script/src/http.d.ts +157 -0
- package/script/src/http.d.ts.map +1 -0
- package/script/src/http.js +321 -0
- package/script/src/namespace.d.ts +59 -0
- package/script/src/namespace.d.ts.map +1 -0
- package/script/src/namespace.js +83 -0
- package/script/src/reactive.d.ts +29 -0
- package/script/src/reactive.d.ts.map +1 -0
- package/script/src/reactive.js +39 -0
- package/script/src/resources/account.d.ts +125 -0
- package/script/src/resources/account.d.ts.map +1 -0
- package/script/src/resources/account.js +158 -0
- package/script/src/resources/api-keys.d.ts +116 -0
- package/script/src/resources/api-keys.d.ts.map +1 -0
- package/script/src/resources/api-keys.js +110 -0
- package/script/src/resources/auth.d.ts +57 -0
- package/script/src/resources/auth.d.ts.map +1 -0
- package/script/src/resources/auth.js +43 -0
- package/script/src/resources/eggs.d.ts +238 -0
- package/script/src/resources/eggs.d.ts.map +1 -0
- package/script/src/resources/eggs.js +193 -0
- package/script/src/resources/hosts.d.ts +62 -0
- package/script/src/resources/hosts.d.ts.map +1 -0
- package/script/src/resources/hosts.js +67 -0
- package/script/src/resources/members.d.ts +138 -0
- package/script/src/resources/members.d.ts.map +1 -0
- package/script/src/resources/members.js +127 -0
- package/script/src/resources/nodes.d.ts +397 -0
- package/script/src/resources/nodes.d.ts.map +1 -0
- package/script/src/resources/nodes.js +362 -0
- package/script/src/resources/server-groups.d.ts +150 -0
- package/script/src/resources/server-groups.d.ts.map +1 -0
- package/script/src/resources/server-groups.js +116 -0
- package/script/src/resources/servers/activity.d.ts +120 -0
- package/script/src/resources/servers/activity.d.ts.map +1 -0
- package/script/src/resources/servers/activity.js +170 -0
- package/script/src/resources/servers/allocations.d.ts +125 -0
- package/script/src/resources/servers/allocations.d.ts.map +1 -0
- package/script/src/resources/servers/allocations.js +142 -0
- package/script/src/resources/servers/connection.d.ts +108 -0
- package/script/src/resources/servers/connection.d.ts.map +1 -0
- package/script/src/resources/servers/connection.js +173 -0
- package/script/src/resources/servers/files.d.ts +164 -0
- package/script/src/resources/servers/files.d.ts.map +1 -0
- package/script/src/resources/servers/files.js +286 -0
- package/script/src/resources/servers/index.d.ts +126 -0
- package/script/src/resources/servers/index.d.ts.map +1 -0
- package/script/src/resources/servers/index.js +139 -0
- package/script/src/resources/servers/profiles.d.ts +138 -0
- package/script/src/resources/servers/profiles.d.ts.map +1 -0
- package/script/src/resources/servers/profiles.js +182 -0
- package/script/src/resources/servers/server.d.ts +136 -0
- package/script/src/resources/servers/server.d.ts.map +1 -0
- package/script/src/resources/servers/server.js +206 -0
- package/script/src/resources/servers/sftp.d.ts +147 -0
- package/script/src/resources/servers/sftp.d.ts.map +1 -0
- package/script/src/resources/servers/sftp.js +158 -0
- package/script/src/resources/servers/types.d.ts +199 -0
- package/script/src/resources/servers/types.d.ts.map +1 -0
- package/script/src/resources/servers/types.js +2 -0
- package/script/src/sse.d.ts +53 -0
- package/script/src/sse.d.ts.map +1 -0
- package/script/src/sse.js +137 -0
- package/script/src/types.d.ts +126 -0
- package/script/src/types.d.ts.map +1 -0
- package/script/src/types.js +25 -0
- package/esm/api.d.ts +0 -76
- package/esm/api.d.ts.map +0 -1
- package/esm/api.js +0 -187
- package/esm/components/auth.d.ts +0 -15
- package/esm/components/auth.d.ts.map +0 -1
- package/esm/components/auth.js +0 -13
- package/esm/components/connection/abstract.d.ts +0 -23
- package/esm/components/connection/abstract.d.ts.map +0 -1
- package/esm/components/connection/abstract.js +0 -43
- package/esm/components/connection/sse.d.ts +0 -20
- package/esm/components/connection/sse.d.ts.map +0 -1
- package/esm/components/connection/sse.js +0 -65
- package/esm/components/egg/egg.d.ts +0 -32
- package/esm/components/egg/egg.d.ts.map +0 -1
- package/esm/components/egg/egg.js +0 -70
- package/esm/components/group.d.ts +0 -14
- package/esm/components/group.d.ts.map +0 -1
- package/esm/components/group.js +0 -33
- package/esm/components/member_2.d.ts +0 -69
- package/esm/components/member_2.d.ts.map +0 -1
- package/esm/components/member_2.js +0 -140
- package/esm/components/node.d.ts +0 -78
- package/esm/components/node.d.ts.map +0 -1
- package/esm/components/node.js +0 -342
- package/esm/components/server/activity.d.ts +0 -45
- package/esm/components/server/activity.d.ts.map +0 -1
- package/esm/components/server/activity.js +0 -158
- package/esm/components/server/allocations.d.ts +0 -45
- package/esm/components/server/allocations.d.ts.map +0 -1
- package/esm/components/server/allocations.js +0 -146
- package/esm/components/server/files.d.ts +0 -50
- package/esm/components/server/files.d.ts.map +0 -1
- package/esm/components/server/files.js +0 -90
- package/esm/components/server/power.d.ts +0 -21
- package/esm/components/server/power.d.ts.map +0 -1
- package/esm/components/server/power.js +0 -43
- package/esm/components/server/profiles.d.ts +0 -63
- package/esm/components/server/profiles.d.ts.map +0 -1
- package/esm/components/server/profiles.js +0 -163
- package/esm/components/server/server.d.ts +0 -141
- package/esm/components/server/server.d.ts.map +0 -1
- package/esm/components/server/server.js +0 -358
- package/esm/components/server/sftp.d.ts +0 -31
- package/esm/components/server/sftp.d.ts.map +0 -1
- package/esm/components/server/sftp.js +0 -84
- package/esm/components/server/startup.d.ts +0 -17
- package/esm/components/server/startup.d.ts.map +0 -1
- package/esm/components/server/startup.js +0 -21
- package/esm/components/server/stats.d.ts +0 -19
- package/esm/components/server/stats.d.ts.map +0 -1
- package/esm/components/server/stats.js +0 -46
- package/esm/utils/cache.d.ts +0 -20
- package/esm/utils/cache.d.ts.map +0 -1
- package/esm/utils/cache.js +0 -66
- package/esm/utils/event.d.ts +0 -38
- package/esm/utils/event.d.ts.map +0 -1
- package/esm/utils/event.js +0 -71
- package/esm/utils/object.d.ts +0 -58
- package/esm/utils/object.d.ts.map +0 -1
- package/esm/utils/object.js +0 -86
- package/esm/utils/subscribe.d.ts +0 -37
- package/esm/utils/subscribe.d.ts.map +0 -1
- package/esm/utils/subscribe.js +0 -29
- package/esm/utils/timer.d.ts +0 -13
- package/esm/utils/timer.d.ts.map +0 -1
- package/esm/utils/timer.js +0 -32
- package/esm/utils/units.d.ts +0 -18
- package/esm/utils/units.d.ts.map +0 -1
- package/esm/utils/units.js +0 -82
- package/script/api.d.ts +0 -76
- package/script/api.d.ts.map +0 -1
- package/script/api.js +0 -192
- package/script/components/auth.d.ts +0 -15
- package/script/components/auth.d.ts.map +0 -1
- package/script/components/auth.js +0 -17
- package/script/components/connection/abstract.d.ts +0 -23
- package/script/components/connection/abstract.d.ts.map +0 -1
- package/script/components/connection/abstract.js +0 -47
- package/script/components/connection/sse.d.ts +0 -20
- package/script/components/connection/sse.d.ts.map +0 -1
- package/script/components/connection/sse.js +0 -69
- package/script/components/egg/egg.d.ts +0 -32
- package/script/components/egg/egg.d.ts.map +0 -1
- package/script/components/egg/egg.js +0 -74
- package/script/components/group.d.ts +0 -14
- package/script/components/group.d.ts.map +0 -1
- package/script/components/group.js +0 -37
- package/script/components/member_2.d.ts +0 -69
- package/script/components/member_2.d.ts.map +0 -1
- package/script/components/member_2.js +0 -146
- package/script/components/node.d.ts +0 -78
- package/script/components/node.d.ts.map +0 -1
- package/script/components/node.js +0 -349
- package/script/components/server/activity.d.ts +0 -45
- package/script/components/server/activity.d.ts.map +0 -1
- package/script/components/server/activity.js +0 -164
- package/script/components/server/allocations.d.ts +0 -45
- package/script/components/server/allocations.d.ts.map +0 -1
- package/script/components/server/allocations.js +0 -152
- package/script/components/server/files.d.ts +0 -50
- package/script/components/server/files.d.ts.map +0 -1
- package/script/components/server/files.js +0 -94
- package/script/components/server/power.d.ts +0 -21
- package/script/components/server/power.d.ts.map +0 -1
- package/script/components/server/power.js +0 -47
- package/script/components/server/profiles.d.ts +0 -63
- package/script/components/server/profiles.d.ts.map +0 -1
- package/script/components/server/profiles.js +0 -168
- package/script/components/server/server.d.ts +0 -141
- package/script/components/server/server.d.ts.map +0 -1
- package/script/components/server/server.js +0 -362
- package/script/components/server/sftp.d.ts +0 -31
- package/script/components/server/sftp.d.ts.map +0 -1
- package/script/components/server/sftp.js +0 -88
- package/script/components/server/startup.d.ts +0 -17
- package/script/components/server/startup.d.ts.map +0 -1
- package/script/components/server/startup.js +0 -25
- package/script/components/server/stats.d.ts +0 -19
- package/script/components/server/stats.d.ts.map +0 -1
- package/script/components/server/stats.js +0 -50
- package/script/utils/cache.d.ts +0 -20
- package/script/utils/cache.d.ts.map +0 -1
- package/script/utils/cache.js +0 -70
- package/script/utils/event.d.ts +0 -38
- package/script/utils/event.d.ts.map +0 -1
- package/script/utils/event.js +0 -75
- package/script/utils/object.d.ts +0 -58
- package/script/utils/object.d.ts.map +0 -1
- package/script/utils/object.js +0 -90
- package/script/utils/subscribe.d.ts +0 -37
- package/script/utils/subscribe.d.ts.map +0 -1
- package/script/utils/subscribe.js +0 -32
- package/script/utils/timer.d.ts +0 -13
- package/script/utils/timer.d.ts.map +0 -1
- package/script/utils/timer.js +0 -36
- package/script/utils/units.d.ts +0 -18
- package/script/utils/units.d.ts.map +0 -1
- package/script/utils/units.js +0 -86
package/esm/utils/timer.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A simple class for converting milliseconds to hours, minutes and seconds.
|
|
3
|
-
*/
|
|
4
|
-
export declare class Timer extends Number {
|
|
5
|
-
private readonly timerMs;
|
|
6
|
-
constructor(timerMs: number);
|
|
7
|
-
get hour(): number;
|
|
8
|
-
get minute(): number;
|
|
9
|
-
get second(): number;
|
|
10
|
-
get millisecond(): number;
|
|
11
|
-
toString(): string;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=timer.d.ts.map
|
package/esm/utils/timer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timer.d.ts","sourceRoot":"","sources":["../../src/utils/timer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,KAAM,SAAQ,MAAM;IACb,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,MAAM;IAInD,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,IAAW,WAAW,IAAI,MAAM,CAE/B;IAEe,QAAQ,IAAI,MAAM;CAMlC"}
|
package/esm/utils/timer.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A simple class for converting milliseconds to hours, minutes and seconds.
|
|
3
|
-
*/
|
|
4
|
-
export class Timer extends Number {
|
|
5
|
-
constructor(timerMs) {
|
|
6
|
-
super(timerMs);
|
|
7
|
-
Object.defineProperty(this, "timerMs", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
configurable: true,
|
|
10
|
-
writable: true,
|
|
11
|
-
value: timerMs
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
get hour() {
|
|
15
|
-
return Math.floor(this.timerMs / 1000 / 60 / 60);
|
|
16
|
-
}
|
|
17
|
-
get minute() {
|
|
18
|
-
return Math.floor(this.timerMs / 1000 / 60);
|
|
19
|
-
}
|
|
20
|
-
get second() {
|
|
21
|
-
return Math.floor(this.timerMs / 1000);
|
|
22
|
-
}
|
|
23
|
-
get millisecond() {
|
|
24
|
-
return this.timerMs;
|
|
25
|
-
}
|
|
26
|
-
toString() {
|
|
27
|
-
const hour = this.hour.toString().padStart(2, '0');
|
|
28
|
-
const minute = this.minute.toString().padStart(2, '0');
|
|
29
|
-
const second = this.second.toString().padStart(2, '0');
|
|
30
|
-
return `${hour}:${minute}:${second}`;
|
|
31
|
-
}
|
|
32
|
-
}
|
package/esm/utils/units.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A simple class for converting bytes to other units.
|
|
3
|
-
*/
|
|
4
|
-
export declare class ByteUnit {
|
|
5
|
-
protected static readonly KB = 1024;
|
|
6
|
-
protected static readonly MB: number;
|
|
7
|
-
protected static readonly GB: number;
|
|
8
|
-
static stringify(value: number, unit?: 'b' | 'kb' | 'mb' | 'gb'): string;
|
|
9
|
-
static readonly ZERO: ByteUnit;
|
|
10
|
-
protected readonly valueBytes: number;
|
|
11
|
-
constructor(value: number, unit?: 'b' | 'kb' | 'mb' | 'gb');
|
|
12
|
-
get bytes(): number;
|
|
13
|
-
get kb(): number;
|
|
14
|
-
get mb(): number;
|
|
15
|
-
get gb(): number;
|
|
16
|
-
toString(): string;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=units.d.ts.map
|
package/esm/utils/units.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../src/utils/units.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,QAAQ;IACpB,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ;IACpC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAe;IAC3C,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAsB;WAEpC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAU,GAAG,MAAM;IAIpF,gBAAuB,IAAI,EAAE,QAAQ,CAAmB;IAExD,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBACnB,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAU;IAmBtE,IAAW,KAAK,IAAI,MAAM,CAEzB;IAED,IAAW,EAAE,IAAI,MAAM,CAEtB;IAED,IAAW,EAAE,IAAI,MAAM,CAEtB;IAED,IAAW,EAAE,IAAI,MAAM,CAEtB;IAEM,QAAQ,IAAI,MAAM;CAWzB"}
|
package/esm/utils/units.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A simple class for converting bytes to other units.
|
|
3
|
-
*/
|
|
4
|
-
export class ByteUnit {
|
|
5
|
-
static stringify(value, unit = 'b') {
|
|
6
|
-
return new ByteUnit(value, unit).toString();
|
|
7
|
-
}
|
|
8
|
-
constructor(value, unit = 'b') {
|
|
9
|
-
Object.defineProperty(this, "valueBytes", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
configurable: true,
|
|
12
|
-
writable: true,
|
|
13
|
-
value: void 0
|
|
14
|
-
});
|
|
15
|
-
switch (unit) {
|
|
16
|
-
case 'b':
|
|
17
|
-
this.valueBytes = value;
|
|
18
|
-
break;
|
|
19
|
-
case 'kb':
|
|
20
|
-
this.valueBytes = value * 1024;
|
|
21
|
-
break;
|
|
22
|
-
case 'mb':
|
|
23
|
-
this.valueBytes = value * 1024 * 1024;
|
|
24
|
-
break;
|
|
25
|
-
case 'gb':
|
|
26
|
-
this.valueBytes = value * 1024 * 1024 * 1024;
|
|
27
|
-
break;
|
|
28
|
-
default:
|
|
29
|
-
throw new Error(`Unknown unit '${unit}'`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
get bytes() {
|
|
33
|
-
return this.valueBytes;
|
|
34
|
-
}
|
|
35
|
-
get kb() {
|
|
36
|
-
return this.valueBytes / ByteUnit.KB;
|
|
37
|
-
}
|
|
38
|
-
get mb() {
|
|
39
|
-
return this.valueBytes / ByteUnit.MB;
|
|
40
|
-
}
|
|
41
|
-
get gb() {
|
|
42
|
-
return this.valueBytes / ByteUnit.GB;
|
|
43
|
-
}
|
|
44
|
-
toString() {
|
|
45
|
-
if (this.valueBytes >= ByteUnit.GB) {
|
|
46
|
-
return `${this.gb.toFixed(2)} GB`;
|
|
47
|
-
}
|
|
48
|
-
else if (this.valueBytes >= ByteUnit.MB) {
|
|
49
|
-
return `${this.mb.toFixed(2)} MB`;
|
|
50
|
-
}
|
|
51
|
-
else if (this.valueBytes >= ByteUnit.KB) {
|
|
52
|
-
return `${this.kb.toFixed(2)} KB`;
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
return `${this.valueBytes} B`;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
Object.defineProperty(ByteUnit, "KB", {
|
|
60
|
-
enumerable: true,
|
|
61
|
-
configurable: true,
|
|
62
|
-
writable: true,
|
|
63
|
-
value: 1024
|
|
64
|
-
});
|
|
65
|
-
Object.defineProperty(ByteUnit, "MB", {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
configurable: true,
|
|
68
|
-
writable: true,
|
|
69
|
-
value: 1024 * 1024
|
|
70
|
-
});
|
|
71
|
-
Object.defineProperty(ByteUnit, "GB", {
|
|
72
|
-
enumerable: true,
|
|
73
|
-
configurable: true,
|
|
74
|
-
writable: true,
|
|
75
|
-
value: 1024 * 1024 * 1024
|
|
76
|
-
});
|
|
77
|
-
Object.defineProperty(ByteUnit, "ZERO", {
|
|
78
|
-
enumerable: true,
|
|
79
|
-
configurable: true,
|
|
80
|
-
writable: true,
|
|
81
|
-
value: new ByteUnit(0)
|
|
82
|
-
});
|
package/script/api.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { AuthApi } from './components/auth.js';
|
|
2
|
-
import { ServerGroup } from './components/group.js';
|
|
3
|
-
import { Member, type MemberInclude } from './components/member_2.js';
|
|
4
|
-
import { Node, type NodeInclude } from './components/node.js';
|
|
5
|
-
import { Server, type ServerInclude } from './components/server/server.js';
|
|
6
|
-
import { type EventFunction, EventManager, type EventManagerListener } from './utils/event.js';
|
|
7
|
-
export declare class ApiError extends Error {
|
|
8
|
-
readonly error: string;
|
|
9
|
-
readonly status: number;
|
|
10
|
-
constructor(response: Response, error: string);
|
|
11
|
-
}
|
|
12
|
-
export interface MainEvents {
|
|
13
|
-
error: ApiError;
|
|
14
|
-
}
|
|
15
|
-
export interface MeowPanelApiRequestData {
|
|
16
|
-
body?: Record<string, unknown> | FormData | ArrayBuffer | string;
|
|
17
|
-
params?: Record<string, string | undefined>;
|
|
18
|
-
}
|
|
19
|
-
export declare class MeowPanelApi implements EventManagerListener<MainEvents> {
|
|
20
|
-
private static isPlainJson;
|
|
21
|
-
protected readonly url: string | URL;
|
|
22
|
-
protected readonly token: string | undefined;
|
|
23
|
-
protected readonly fetch: typeof fetch;
|
|
24
|
-
protected readonly eventManager: EventManager<MainEvents>;
|
|
25
|
-
on<K extends keyof MainEvents>(event: K, func: EventFunction<MainEvents, K>): number;
|
|
26
|
-
off<K extends keyof MainEvents>(event: K, func: number | EventFunction<MainEvents, K>): boolean;
|
|
27
|
-
requestUrl(method: string, url: URL | string, data?: MeowPanelApiRequestData): Promise<Response>;
|
|
28
|
-
request<T>(method: string, endpoint: `/${string}`, init?: {
|
|
29
|
-
body?: Record<string, unknown>;
|
|
30
|
-
pagination?: Pagination;
|
|
31
|
-
params?: Record<string, string | undefined>;
|
|
32
|
-
}): Promise<ApiResponse<T>>;
|
|
33
|
-
constructor(options: Options);
|
|
34
|
-
/**
|
|
35
|
-
* Fetches the current logged in account
|
|
36
|
-
*/
|
|
37
|
-
me(include?: MemberInclude[]): Promise<Member>;
|
|
38
|
-
readonly members: {
|
|
39
|
-
list: (pagination: Pagination) => Promise<{
|
|
40
|
-
data: Member[];
|
|
41
|
-
page: Page | undefined;
|
|
42
|
-
}>;
|
|
43
|
-
get: (id: string) => Promise<Member>;
|
|
44
|
-
};
|
|
45
|
-
readonly getNode: (id: string, include?: NodeInclude[]) => Promise<Node>;
|
|
46
|
-
readonly getServers: (page: number, include?: ServerInclude[], query?: string) => Promise<{
|
|
47
|
-
servers: Server[];
|
|
48
|
-
page: Page;
|
|
49
|
-
}>;
|
|
50
|
-
readonly getServer: (id: string, include?: ServerInclude[]) => Promise<Server>;
|
|
51
|
-
readonly getServerGroups: (page: number) => Promise<{
|
|
52
|
-
groups: ServerGroup[];
|
|
53
|
-
page: Page;
|
|
54
|
-
}>;
|
|
55
|
-
readonly getServerGroup: (id: string) => Promise<ServerGroup>;
|
|
56
|
-
readonly auth: AuthApi;
|
|
57
|
-
}
|
|
58
|
-
export interface Options {
|
|
59
|
-
url: string | URL;
|
|
60
|
-
token?: string;
|
|
61
|
-
fetch?: typeof fetch;
|
|
62
|
-
}
|
|
63
|
-
export interface ApiResponse<T> {
|
|
64
|
-
data: T;
|
|
65
|
-
page?: Page;
|
|
66
|
-
}
|
|
67
|
-
export interface Pagination {
|
|
68
|
-
page: number;
|
|
69
|
-
perPage?: number;
|
|
70
|
-
}
|
|
71
|
-
export interface Page {
|
|
72
|
-
total: number;
|
|
73
|
-
from: number;
|
|
74
|
-
to: number;
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=api.d.ts.map
|
package/script/api.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"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"}
|
package/script/api.js
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MeowPanelApi = exports.ApiError = void 0;
|
|
4
|
-
const auth_js_1 = require("./components/auth.js");
|
|
5
|
-
const group_js_1 = require("./components/group.js");
|
|
6
|
-
const member_2_js_1 = require("./components/member_2.js");
|
|
7
|
-
const node_js_1 = require("./components/node.js");
|
|
8
|
-
const server_js_1 = require("./components/server/server.js");
|
|
9
|
-
const event_js_1 = require("./utils/event.js");
|
|
10
|
-
class ApiError extends Error {
|
|
11
|
-
constructor(response, error) {
|
|
12
|
-
super(`${response.status}: ${error}`);
|
|
13
|
-
Object.defineProperty(this, "error", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true,
|
|
17
|
-
value: error
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(this, "status", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: true,
|
|
23
|
-
value: void 0
|
|
24
|
-
});
|
|
25
|
-
this.status = response.status;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.ApiError = ApiError;
|
|
29
|
-
class MeowPanelApi {
|
|
30
|
-
static isPlainJson(value) {
|
|
31
|
-
return typeof value === 'object' && value !== null &&
|
|
32
|
-
value.constructor === Object;
|
|
33
|
-
}
|
|
34
|
-
on(event, func) {
|
|
35
|
-
return this.eventManager.on(event, func);
|
|
36
|
-
}
|
|
37
|
-
off(event, func) {
|
|
38
|
-
return this.eventManager.off(event, func);
|
|
39
|
-
}
|
|
40
|
-
async requestUrl(method, url, data = {}) {
|
|
41
|
-
const headers = {};
|
|
42
|
-
if (this.token) {
|
|
43
|
-
headers.Authorization = `Bearer ${this.token}`;
|
|
44
|
-
}
|
|
45
|
-
const requestUrl = new URL(url.toString());
|
|
46
|
-
if (data.params) {
|
|
47
|
-
for (const [key, value] of Object.entries(data.params)) {
|
|
48
|
-
if (value !== undefined) {
|
|
49
|
-
requestUrl.searchParams.set(key, value);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const response = await this.fetch(requestUrl, {
|
|
54
|
-
body: MeowPanelApi.isPlainJson(data.body) ? JSON.stringify(data.body) : data.body,
|
|
55
|
-
credentials: 'include',
|
|
56
|
-
headers,
|
|
57
|
-
method,
|
|
58
|
-
});
|
|
59
|
-
if (!response.ok) {
|
|
60
|
-
let message;
|
|
61
|
-
try {
|
|
62
|
-
const json = await response.json();
|
|
63
|
-
message = json.error;
|
|
64
|
-
}
|
|
65
|
-
catch (_) {
|
|
66
|
-
console.warn('Failed to parse error response');
|
|
67
|
-
message = 'Unknown error';
|
|
68
|
-
}
|
|
69
|
-
const error = new ApiError(response, message);
|
|
70
|
-
this.eventManager.dispatch('error', error);
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
return response;
|
|
74
|
-
}
|
|
75
|
-
async request(method, endpoint, init = {}) {
|
|
76
|
-
const url = new URL(this.url.toString());
|
|
77
|
-
url.pathname = `${url.pathname}/${endpoint}`.replace(/\/+/g, '/');
|
|
78
|
-
if (init.params) {
|
|
79
|
-
Object.entries(init.params).forEach(([key, value]) => value !== undefined && url.searchParams.set(key, value));
|
|
80
|
-
}
|
|
81
|
-
init.pagination &&
|
|
82
|
-
url.searchParams.set('page', `${init.pagination.page}`);
|
|
83
|
-
init.pagination?.perPage &&
|
|
84
|
-
url.searchParams.set('perPage', `${init.pagination.perPage}`);
|
|
85
|
-
const response = await this.requestUrl(method, url.toString(), init);
|
|
86
|
-
if (response.status === 204)
|
|
87
|
-
return {};
|
|
88
|
-
const json = await response.json();
|
|
89
|
-
let page = undefined;
|
|
90
|
-
if (init.pagination) {
|
|
91
|
-
const contentRange = response.headers.get('content-range');
|
|
92
|
-
if (!contentRange) {
|
|
93
|
-
throw new Error('Expected content-range header not found');
|
|
94
|
-
}
|
|
95
|
-
const [range, total] = contentRange.split('/') ??
|
|
96
|
-
['items 0-0', '0'];
|
|
97
|
-
const [from, to] = range.split(' ')[1].split('-').map(Number);
|
|
98
|
-
page = { total: Number(total), from, to };
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
page,
|
|
102
|
-
data: json,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
constructor(options) {
|
|
106
|
-
Object.defineProperty(this, "url", {
|
|
107
|
-
enumerable: true,
|
|
108
|
-
configurable: true,
|
|
109
|
-
writable: true,
|
|
110
|
-
value: void 0
|
|
111
|
-
});
|
|
112
|
-
Object.defineProperty(this, "token", {
|
|
113
|
-
enumerable: true,
|
|
114
|
-
configurable: true,
|
|
115
|
-
writable: true,
|
|
116
|
-
value: void 0
|
|
117
|
-
});
|
|
118
|
-
Object.defineProperty(this, "fetch", {
|
|
119
|
-
enumerable: true,
|
|
120
|
-
configurable: true,
|
|
121
|
-
writable: true,
|
|
122
|
-
value: void 0
|
|
123
|
-
});
|
|
124
|
-
Object.defineProperty(this, "eventManager", {
|
|
125
|
-
enumerable: true,
|
|
126
|
-
configurable: true,
|
|
127
|
-
writable: true,
|
|
128
|
-
value: new event_js_1.EventManager()
|
|
129
|
-
});
|
|
130
|
-
Object.defineProperty(this, "members", {
|
|
131
|
-
enumerable: true,
|
|
132
|
-
configurable: true,
|
|
133
|
-
writable: true,
|
|
134
|
-
value: {
|
|
135
|
-
list: (pagination) => member_2_js_1.Member.list(this, pagination),
|
|
136
|
-
get: (id) => member_2_js_1.Member.get(this, id),
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
Object.defineProperty(this, "getNode", {
|
|
140
|
-
enumerable: true,
|
|
141
|
-
configurable: true,
|
|
142
|
-
writable: true,
|
|
143
|
-
value: (id, include) => node_js_1.Node.get(this, id, include)
|
|
144
|
-
});
|
|
145
|
-
Object.defineProperty(this, "getServers", {
|
|
146
|
-
enumerable: true,
|
|
147
|
-
configurable: true,
|
|
148
|
-
writable: true,
|
|
149
|
-
value: (page, include, query) => server_js_1.Server.getPaged(this, page, include, query)
|
|
150
|
-
});
|
|
151
|
-
Object.defineProperty(this, "getServer", {
|
|
152
|
-
enumerable: true,
|
|
153
|
-
configurable: true,
|
|
154
|
-
writable: true,
|
|
155
|
-
value: (id, include) => server_js_1.Server.get(this, id, include)
|
|
156
|
-
});
|
|
157
|
-
Object.defineProperty(this, "getServerGroups", {
|
|
158
|
-
enumerable: true,
|
|
159
|
-
configurable: true,
|
|
160
|
-
writable: true,
|
|
161
|
-
value: (page) => group_js_1.ServerGroup.getPaged(this, page)
|
|
162
|
-
});
|
|
163
|
-
Object.defineProperty(this, "getServerGroup", {
|
|
164
|
-
enumerable: true,
|
|
165
|
-
configurable: true,
|
|
166
|
-
writable: true,
|
|
167
|
-
value: (id) => group_js_1.ServerGroup.get(this, id)
|
|
168
|
-
});
|
|
169
|
-
Object.defineProperty(this, "auth", {
|
|
170
|
-
enumerable: true,
|
|
171
|
-
configurable: true,
|
|
172
|
-
writable: true,
|
|
173
|
-
value: new auth_js_1.AuthApi(this)
|
|
174
|
-
});
|
|
175
|
-
this.url = options.url;
|
|
176
|
-
this.token = options.token;
|
|
177
|
-
this.fetch = options.fetch ?? fetch;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Fetches the current logged in account
|
|
181
|
-
*/
|
|
182
|
-
// TODO: update to accept API key response
|
|
183
|
-
async me(include) {
|
|
184
|
-
const response = await this.request('GET', '/v1/account', {
|
|
185
|
-
params: {
|
|
186
|
-
include: include?.join(','),
|
|
187
|
-
},
|
|
188
|
-
});
|
|
189
|
-
return new member_2_js_1.Member(this, response.data);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
exports.MeowPanelApi = MeowPanelApi;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { MeowPanelApi } from '../mod.js';
|
|
2
|
-
import type { ApiResponse } from '../api.js';
|
|
3
|
-
export interface AuthProvider {
|
|
4
|
-
fields: Record<string, string>;
|
|
5
|
-
url: string;
|
|
6
|
-
}
|
|
7
|
-
export interface AuthGetMeta {
|
|
8
|
-
providers: Record<string, AuthProvider>;
|
|
9
|
-
}
|
|
10
|
-
export declare class AuthApi {
|
|
11
|
-
protected readonly api: MeowPanelApi;
|
|
12
|
-
getMeta(): Promise<ApiResponse<AuthGetMeta>>;
|
|
13
|
-
constructor(api: MeowPanelApi);
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/components/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,WAAW,YAAY;IAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,WAAW;IAC3B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACxC;AAED,qBAAa,OAAO;IAKA,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,YAAY;IAJ1C,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBAInB,GAAG,EAAE,YAAY;CACvD"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AuthApi = void 0;
|
|
4
|
-
class AuthApi {
|
|
5
|
-
async getMeta() {
|
|
6
|
-
return await this.api.request('GET', '/v1/auth');
|
|
7
|
-
}
|
|
8
|
-
constructor(api) {
|
|
9
|
-
Object.defineProperty(this, "api", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
configurable: true,
|
|
12
|
-
writable: true,
|
|
13
|
-
value: api
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.AuthApi = AuthApi;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type EventFunction, EventManager, type EventManagerListener } from '../../utils/event.js';
|
|
2
|
-
import type { Server } from '../server/server.js';
|
|
3
|
-
import type { NodeServerEvents } from './node';
|
|
4
|
-
export declare abstract class ServerConnection implements EventManagerListener<NodeServerEvents> {
|
|
5
|
-
protected readonly subSystemName: string;
|
|
6
|
-
protected readonly server: Server;
|
|
7
|
-
constructor(subSystemName: string, server: Server);
|
|
8
|
-
readonly eventManager: EventManager<NodeServerEvents>;
|
|
9
|
-
on<K extends keyof NodeServerEvents>(event: K, func: EventFunction<NodeServerEvents, K>): number;
|
|
10
|
-
off<K extends keyof NodeServerEvents>(event: K | number, func?: EventFunction<NodeServerEvents, K> | number): boolean;
|
|
11
|
-
abstract connect(): Promise<void> | void;
|
|
12
|
-
abstract disconnect(): Promise<void> | void;
|
|
13
|
-
abstract isConnected: boolean;
|
|
14
|
-
logger: Logger;
|
|
15
|
-
private log;
|
|
16
|
-
}
|
|
17
|
-
export interface Logger {
|
|
18
|
-
debug: (message: string) => void;
|
|
19
|
-
info: (message: string) => void;
|
|
20
|
-
warn: (message: string) => void;
|
|
21
|
-
error: (message: string) => void;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=abstract.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.d.ts","sourceRoot":"","sources":["../../../src/components/connection/abstract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,YAAY,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACnG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAE/C,8BAAsB,gBAAiB,YAAW,oBAAoB,CAAC,gBAAgB,CAAC;IAEtF,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,MAAM;IACxC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM;gBADd,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM;IAGlC,SAAgB,YAAY,iCAAwC;IAC7D,EAAE,CAAC,CAAC,SAAS,MAAM,gBAAgB,EACzC,KAAK,EAAE,CAAC,EACR,IAAI,EAAE,aAAa,CAAC,gBAAgB,EAAE,CAAC,CAAC,GACtC,MAAM;IAIF,GAAG,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAC1C,KAAK,EAAE,CAAC,GAAG,MAAM,EACjB,IAAI,CAAC,EAAE,aAAa,CAAC,gBAAgB,EAAE,CAAC,CAAC,GAAG,MAAM,GAChD,OAAO;aAIM,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;aAC/B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAClD,SAAgB,WAAW,EAAE,OAAO,CAAC;IAE9B,MAAM,EAAE,MAAM,CAKnB;IAEF,OAAO,CAAC,GAAG;CAGX;AAED,MAAM,WAAW,MAAM;IACtB,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ServerConnection = void 0;
|
|
4
|
-
const event_js_1 = require("../../utils/event.js");
|
|
5
|
-
class ServerConnection {
|
|
6
|
-
constructor(subSystemName, server) {
|
|
7
|
-
Object.defineProperty(this, "subSystemName", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
configurable: true,
|
|
10
|
-
writable: true,
|
|
11
|
-
value: subSystemName
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(this, "server", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true,
|
|
17
|
-
value: server
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(this, "eventManager", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: true,
|
|
23
|
-
value: new event_js_1.EventManager()
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(this, "logger", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true,
|
|
29
|
-
value: {
|
|
30
|
-
debug: (message) => this.log('debug', message),
|
|
31
|
-
info: (message) => this.log('info', message),
|
|
32
|
-
warn: (message) => this.log('warn', message),
|
|
33
|
-
error: (message) => this.log('error', message),
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
on(event, func) {
|
|
38
|
-
return this.eventManager.on(event, func);
|
|
39
|
-
}
|
|
40
|
-
off(event, func) {
|
|
41
|
-
return this.eventManager.off(event, func);
|
|
42
|
-
}
|
|
43
|
-
log(level, message) {
|
|
44
|
-
console[level](`[${this.server.id}/${this.subSystemName}] ${message}`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.ServerConnection = ServerConnection;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { EventFunction } from '../../utils/event.js';
|
|
2
|
-
import type { Server } from '../server/server.js';
|
|
3
|
-
import { ServerConnection } from './abstract.js';
|
|
4
|
-
import type { NodeServerEvents } from './node';
|
|
5
|
-
export declare class SseServerConnection extends ServerConnection {
|
|
6
|
-
private eventSource;
|
|
7
|
-
constructor(server: Server);
|
|
8
|
-
connect(): Promise<void>;
|
|
9
|
-
disconnect(): void;
|
|
10
|
-
get isConnected(): boolean;
|
|
11
|
-
protected readonly eventSourceListenerTracker: Array<{
|
|
12
|
-
id: number;
|
|
13
|
-
func: EventFunction<NodeServerEvents, keyof NodeServerEvents>;
|
|
14
|
-
wrapper: (message: MessageEvent) => unknown;
|
|
15
|
-
}>;
|
|
16
|
-
protected registerEventToSource<K extends keyof NodeServerEvents>(event: K, id: number, func: (value: NodeServerEvents[K]) => unknown): void;
|
|
17
|
-
on<K extends keyof NodeServerEvents>(event: K, func: EventFunction<NodeServerEvents, K>): number;
|
|
18
|
-
off<K extends keyof NodeServerEvents>(event: K, func: number | EventFunction<NodeServerEvents, K>): boolean;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=sse.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../../src/components/connection/sse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAE/C,qBAAa,mBAAoB,SAAQ,gBAAgB;IACxD,OAAO,CAAC,WAAW,CAA0B;gBAE1B,MAAM,EAAE,MAAM;IAIpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB9B,UAAU,IAAI,IAAI;IAOzB,IAAoB,WAAW,YAG9B;IAED,SAAS,CAAC,QAAQ,CAAC,0BAA0B,EAAE,KAAK,CAAC;QACpD,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,aAAa,CAAC,gBAAgB,EAAE,MAAM,gBAAgB,CAAC,CAAC;QAC9D,OAAO,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC;KAC5C,CAAC,CAAM;IAER,SAAS,CAAC,qBAAqB,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAC/D,KAAK,EAAE,CAAC,EACR,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,OAAO,GAC3C,IAAI;IASS,EAAE,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAClD,KAAK,EAAE,CAAC,EACR,IAAI,EAAE,aAAa,CAAC,gBAAgB,EAAE,CAAC,CAAC,GACtC,MAAM;IAMO,GAAG,CAAC,CAAC,SAAS,MAAM,gBAAgB,EACnD,KAAK,EAAE,CAAC,EACR,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC,CAAC,GAC/C,OAAO;CAUV"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SseServerConnection = void 0;
|
|
4
|
-
const abstract_js_1 = require("./abstract.js");
|
|
5
|
-
class SseServerConnection extends abstract_js_1.ServerConnection {
|
|
6
|
-
constructor(server) {
|
|
7
|
-
super('sse', server);
|
|
8
|
-
Object.defineProperty(this, "eventSource", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: void 0
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(this, "eventSourceListenerTracker", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: []
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
async connect() {
|
|
22
|
-
this.disconnect();
|
|
23
|
-
this.logger.debug('Connecting to SSE');
|
|
24
|
-
const group = await this.server.group.get();
|
|
25
|
-
const node = await group.node.get();
|
|
26
|
-
const { connection } = node; // TODO: use Cache Relation for connection
|
|
27
|
-
if (!connection)
|
|
28
|
-
throw new Error('No permission to connect to server');
|
|
29
|
-
const url = new URL(connection.url);
|
|
30
|
-
url.pathname = `/api/servers/${this.server.id}/sse`;
|
|
31
|
-
this.eventSource = new EventSource(url, { withCredentials: true });
|
|
32
|
-
this.logger.info('Connected to SSE');
|
|
33
|
-
this.eventManager.assignAllEvents((event, id, func) => this.registerEventToSource(event, id, func));
|
|
34
|
-
}
|
|
35
|
-
disconnect() {
|
|
36
|
-
if (!this.eventSource)
|
|
37
|
-
return;
|
|
38
|
-
this.logger.info('Closing SSE connection');
|
|
39
|
-
this.eventSource.close();
|
|
40
|
-
this.eventSource = undefined;
|
|
41
|
-
}
|
|
42
|
-
get isConnected() {
|
|
43
|
-
return !!this.eventSource &&
|
|
44
|
-
this.eventSource.readyState === EventSource.OPEN;
|
|
45
|
-
}
|
|
46
|
-
registerEventToSource(event, id, func) {
|
|
47
|
-
if (!this.eventSource)
|
|
48
|
-
return;
|
|
49
|
-
const wrapper = (message) => func(JSON.parse(message.data));
|
|
50
|
-
this.eventSource.addEventListener(event, wrapper);
|
|
51
|
-
this.eventSourceListenerTracker.push({ id, func, wrapper });
|
|
52
|
-
this.logger.debug(`Registered: ${event}`);
|
|
53
|
-
}
|
|
54
|
-
on(event, func) {
|
|
55
|
-
const id = super.on(event, func);
|
|
56
|
-
this.registerEventToSource(event, id, func);
|
|
57
|
-
return id;
|
|
58
|
-
}
|
|
59
|
-
off(event, func) {
|
|
60
|
-
const i = this.eventSourceListenerTracker.findIndex((v) => v.id === func || v.func === func);
|
|
61
|
-
if (i >= 0) {
|
|
62
|
-
const { wrapper } = this.eventSourceListenerTracker[i];
|
|
63
|
-
this.eventSource?.removeEventListener(event, wrapper);
|
|
64
|
-
this.eventSourceListenerTracker.splice(i, 1);
|
|
65
|
-
}
|
|
66
|
-
return super.off(event, func);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.SseServerConnection = SseServerConnection;
|