@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
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { HttpClient } from './http.js';
|
|
2
|
+
import { SseConnection } from './sse.js';
|
|
3
|
+
import { AccountResource } from './resources/account.js';
|
|
4
|
+
import { AuthResource } from './resources/auth.js';
|
|
5
|
+
import { ApiKeysNamespace } from './resources/api-keys.js';
|
|
6
|
+
import { EggsNamespace } from './resources/eggs.js';
|
|
7
|
+
import { HostsNamespace } from './resources/hosts.js';
|
|
8
|
+
import { MembersNamespace } from './resources/members.js';
|
|
9
|
+
import { NodesNamespace } from './resources/nodes.js';
|
|
10
|
+
import { ServerGroupsNamespace } from './resources/server-groups.js';
|
|
11
|
+
import { ServersNamespace } from './resources/servers/index.js';
|
|
12
|
+
/**
|
|
13
|
+
* The root MeowPanel API client.
|
|
14
|
+
*
|
|
15
|
+
* Instantiate once and reuse across your application. All namespaces implement the
|
|
16
|
+
* readable store contract so they can be used directly in reactive templates.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts ignore
|
|
20
|
+
* import { MeowPanelApi } from '@meowpanel/api';
|
|
21
|
+
*
|
|
22
|
+
* const api = new MeowPanelApi({
|
|
23
|
+
* url: 'https://panel.example.com',
|
|
24
|
+
* token: 'your-bearer-token',
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Fetch resources
|
|
28
|
+
* const me = await api.account.get();
|
|
29
|
+
* const servers = await api.servers.list({ include: ['status'] });
|
|
30
|
+
* const members = await api.members.list();
|
|
31
|
+
*
|
|
32
|
+
* // Reactive store: {#each $api.servers as server} ... {/each}
|
|
33
|
+
*
|
|
34
|
+
* // Listen for mutations
|
|
35
|
+
* api.servers.on('created', (server) => console.log('New server:', server.name));
|
|
36
|
+
* api.members.on('updated', (member) => console.log('Member updated:', member.nickname));
|
|
37
|
+
*
|
|
38
|
+
* // Panel-level SSE
|
|
39
|
+
* const sse = api.connectSse();
|
|
40
|
+
* sse.connect((event, data) => console.log('Panel event:', event, data));
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export class MeowPanelApi {
|
|
44
|
+
http;
|
|
45
|
+
sseConnections = new Set();
|
|
46
|
+
/**
|
|
47
|
+
* Fetch authentication configuration (available login providers).
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts ignore
|
|
51
|
+
* const { providers } = await api.auth.getMeta();
|
|
52
|
+
* if (providers.whmcs) console.log(providers.whmcs.fields.display_name);
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
auth;
|
|
56
|
+
/**
|
|
57
|
+
* Access and update the currently authenticated account (me).
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts ignore
|
|
61
|
+
* const me = await api.account.get();
|
|
62
|
+
* await api.account.update({ display: { theme: 'dark' } });
|
|
63
|
+
* await api.account.uploadAvatar(imageBlob, 'image/png');
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
account;
|
|
67
|
+
/**
|
|
68
|
+
* Manage API keys for the current account.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts ignore
|
|
72
|
+
* const key = await api.apiKeys.create('CI/CD Pipeline');
|
|
73
|
+
* console.log(key.token); // Save this!
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
apiKeys;
|
|
77
|
+
/**
|
|
78
|
+
* Manage member (user) accounts.
|
|
79
|
+
*
|
|
80
|
+
* Supports reactive subscriptions via `$api.members`.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts ignore
|
|
84
|
+
* const members = await api.members.list();
|
|
85
|
+
* const member = await api.members.get(id);
|
|
86
|
+
* await api.members.update(id, { nickname: 'newname' });
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
members;
|
|
90
|
+
/**
|
|
91
|
+
* Manage nodes (daemon servers).
|
|
92
|
+
*
|
|
93
|
+
* Supports reactive subscriptions via `$api.nodes`.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts ignore
|
|
97
|
+
* const nodes = await api.nodes.list();
|
|
98
|
+
* const node = await api.nodes.get(id, { includeConnection: true });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
nodes;
|
|
102
|
+
/**
|
|
103
|
+
* Manage eggs (game/application configuration templates).
|
|
104
|
+
*
|
|
105
|
+
* Supports reactive subscriptions via `$api.eggs`.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts ignore
|
|
109
|
+
* const eggs = await api.eggs.list();
|
|
110
|
+
* await api.eggs.update(id, { name: 'Paper Minecraft' });
|
|
111
|
+
* await api.eggs.delete(id);
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
eggs;
|
|
115
|
+
/**
|
|
116
|
+
* View physical host machines.
|
|
117
|
+
*
|
|
118
|
+
* Supports reactive subscriptions via `$api.hosts`.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts ignore
|
|
122
|
+
* const hosts = await api.hosts.list();
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
hosts;
|
|
126
|
+
/**
|
|
127
|
+
* Manage server groups (node + resource limits containers).
|
|
128
|
+
*
|
|
129
|
+
* Supports reactive subscriptions via `$api.serverGroups`.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts ignore
|
|
133
|
+
* const groups = await api.serverGroups.list();
|
|
134
|
+
* const group = await api.serverGroups.create({ nodeId, limits: { ramMb: 1024 } });
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
serverGroups;
|
|
138
|
+
/**
|
|
139
|
+
* Manage game servers.
|
|
140
|
+
*
|
|
141
|
+
* Supports reactive subscriptions via `$api.servers`.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts ignore
|
|
145
|
+
* const servers = await api.servers.list({ include: ['status'] });
|
|
146
|
+
* const server = await api.servers.get(id);
|
|
147
|
+
* await server.sendPower('start');
|
|
148
|
+
* await server.sendCommand('say Hello!');
|
|
149
|
+
*
|
|
150
|
+
* // File management
|
|
151
|
+
* const entries = await server.files.list('/');
|
|
152
|
+
* await server.files.write('/motd.txt', 'Hello World');
|
|
153
|
+
*
|
|
154
|
+
* // Real-time events
|
|
155
|
+
* const conn = await server.createConnection();
|
|
156
|
+
* conn.on('console_output', (line) => console.log(line));
|
|
157
|
+
* conn.on('stats', (stats) => console.log(`CPU: ${stats.cpuAbsolute}%`));
|
|
158
|
+
* await conn.open();
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
servers;
|
|
162
|
+
constructor(options) {
|
|
163
|
+
const userCallback = options.onTokenRefresh;
|
|
164
|
+
this.http = new HttpClient({
|
|
165
|
+
url: options.url.toString(),
|
|
166
|
+
token: options.token,
|
|
167
|
+
fetch: options.fetch,
|
|
168
|
+
logger: options.logger,
|
|
169
|
+
credentials: options.credentials,
|
|
170
|
+
onTokenRefresh: (token) => {
|
|
171
|
+
for (const sse of this.sseConnections) {
|
|
172
|
+
sse.updateToken(token);
|
|
173
|
+
}
|
|
174
|
+
userCallback?.(token);
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
this.auth = new AuthResource(this.http);
|
|
178
|
+
this.account = new AccountResource(this.http);
|
|
179
|
+
this.apiKeys = new ApiKeysNamespace(this.http);
|
|
180
|
+
this.members = new MembersNamespace(this.http);
|
|
181
|
+
this.nodes = new NodesNamespace(this.http);
|
|
182
|
+
this.eggs = new EggsNamespace(this.http);
|
|
183
|
+
this.hosts = new HostsNamespace(this.http);
|
|
184
|
+
this.serverGroups = new ServerGroupsNamespace(this.http);
|
|
185
|
+
this.servers = new ServersNamespace(this.http);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Update the bearer token used for all subsequent API requests.
|
|
189
|
+
*
|
|
190
|
+
* Useful when a session token is refreshed.
|
|
191
|
+
*
|
|
192
|
+
* @param token The new bearer token.
|
|
193
|
+
*/
|
|
194
|
+
setToken(token) {
|
|
195
|
+
this.http.setToken(token);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Create a panel-level Server-Sent Events connection to Nexus.
|
|
199
|
+
*
|
|
200
|
+
* The panel SSE stream (`GET /v1/sse`) broadcasts events for mutations
|
|
201
|
+
* across the panel (e.g. server updates, member changes).
|
|
202
|
+
*
|
|
203
|
+
* The connection is not opened until you call `.connect()` on the returned object.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```ts ignore
|
|
207
|
+
* const sse = api.connectSse();
|
|
208
|
+
* sse.connect(
|
|
209
|
+
* (event, data) => {
|
|
210
|
+
* const payload = JSON.parse(data);
|
|
211
|
+
* console.log('Panel event:', event, payload);
|
|
212
|
+
* },
|
|
213
|
+
* (err) => console.error('SSE error:', err),
|
|
214
|
+
* );
|
|
215
|
+
*
|
|
216
|
+
* // Later...
|
|
217
|
+
* sse.disconnect();
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
connectSse() {
|
|
221
|
+
const url = this.http.buildUrl('/sse');
|
|
222
|
+
const sse = new SseConnection(url, this.http.getToken());
|
|
223
|
+
this.sseConnections.add(sse);
|
|
224
|
+
return sse;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Manually trigger a token refresh.
|
|
228
|
+
*
|
|
229
|
+
* Typically not needed as the client refreshes automatically when using
|
|
230
|
+
* JWT tokens that are about to expire.
|
|
231
|
+
*/
|
|
232
|
+
refresh(opts) {
|
|
233
|
+
return this.auth.refresh(opts);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A typed event handler function.
|
|
3
|
+
*
|
|
4
|
+
* @template T The event map (event names → payload types).
|
|
5
|
+
* @template K The specific event key being handled.
|
|
6
|
+
*/
|
|
7
|
+
export type EventHandler<T extends object, K extends keyof T> = (payload: T[K]) => void;
|
|
8
|
+
/**
|
|
9
|
+
* A lightweight typed event emitter.
|
|
10
|
+
*
|
|
11
|
+
* Provides strongly-typed {@link on}, {@link off}, and {@link emit} methods so that
|
|
12
|
+
* consumers can react to mutations without polling.
|
|
13
|
+
*
|
|
14
|
+
* @template T A record mapping event names to their payload types.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts ignore
|
|
18
|
+
* type ServerEvents = { updated: Server; deleted: NanoID };
|
|
19
|
+
* const emitter = new TypedEmitter<ServerEvents>();
|
|
20
|
+
*
|
|
21
|
+
* const handler = (server: Server) => console.log('Updated:', server.name);
|
|
22
|
+
* emitter.on('updated', handler);
|
|
23
|
+
* emitter.emit('updated', someServer);
|
|
24
|
+
* emitter.off('updated', handler);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare class TypedEmitter<T extends object> {
|
|
28
|
+
private readonly listeners;
|
|
29
|
+
/**
|
|
30
|
+
* Register a handler for the given event.
|
|
31
|
+
*
|
|
32
|
+
* @param event The event name to listen for.
|
|
33
|
+
* @param handler Callback invoked with the event payload.
|
|
34
|
+
*/
|
|
35
|
+
on<K extends keyof T>(event: K, handler: EventHandler<T, K>): void;
|
|
36
|
+
/**
|
|
37
|
+
* Unregister a previously registered handler.
|
|
38
|
+
*
|
|
39
|
+
* @param event The event name.
|
|
40
|
+
* @param handler The exact handler reference that was passed to {@link on}.
|
|
41
|
+
*/
|
|
42
|
+
off<K extends keyof T>(event: K, handler: EventHandler<T, K>): void;
|
|
43
|
+
/**
|
|
44
|
+
* Dispatch an event to all registered handlers for the given event name.
|
|
45
|
+
*
|
|
46
|
+
* @param event The event name.
|
|
47
|
+
* @param payload The event payload passed to each handler.
|
|
48
|
+
*/
|
|
49
|
+
emit<K extends keyof T>(event: K, payload: T[K]): void;
|
|
50
|
+
/** Remove all registered listeners for all events. */
|
|
51
|
+
removeAllListeners(): void;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=emitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/src/emitter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAExF;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,YAAY,CAAC,CAAC,SAAS,MAAM;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqD;IAE/E;;;;;OAKG;IACI,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI;IAKzE;;;;;OAKG;IACI,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI;IAI1E;;;;;OAKG;IACI,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAI7D,sDAAsD;IAC/C,kBAAkB,IAAI,IAAI;CAGjC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A lightweight typed event emitter.
|
|
3
|
+
*
|
|
4
|
+
* Provides strongly-typed {@link on}, {@link off}, and {@link emit} methods so that
|
|
5
|
+
* consumers can react to mutations without polling.
|
|
6
|
+
*
|
|
7
|
+
* @template T A record mapping event names to their payload types.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts ignore
|
|
11
|
+
* type ServerEvents = { updated: Server; deleted: NanoID };
|
|
12
|
+
* const emitter = new TypedEmitter<ServerEvents>();
|
|
13
|
+
*
|
|
14
|
+
* const handler = (server: Server) => console.log('Updated:', server.name);
|
|
15
|
+
* emitter.on('updated', handler);
|
|
16
|
+
* emitter.emit('updated', someServer);
|
|
17
|
+
* emitter.off('updated', handler);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export class TypedEmitter {
|
|
21
|
+
listeners = new Map();
|
|
22
|
+
/**
|
|
23
|
+
* Register a handler for the given event.
|
|
24
|
+
*
|
|
25
|
+
* @param event The event name to listen for.
|
|
26
|
+
* @param handler Callback invoked with the event payload.
|
|
27
|
+
*/
|
|
28
|
+
on(event, handler) {
|
|
29
|
+
if (!this.listeners.has(event))
|
|
30
|
+
this.listeners.set(event, new Set());
|
|
31
|
+
this.listeners.get(event).add(handler);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Unregister a previously registered handler.
|
|
35
|
+
*
|
|
36
|
+
* @param event The event name.
|
|
37
|
+
* @param handler The exact handler reference that was passed to {@link on}.
|
|
38
|
+
*/
|
|
39
|
+
off(event, handler) {
|
|
40
|
+
this.listeners.get(event)?.delete(handler);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Dispatch an event to all registered handlers for the given event name.
|
|
44
|
+
*
|
|
45
|
+
* @param event The event name.
|
|
46
|
+
* @param payload The event payload passed to each handler.
|
|
47
|
+
*/
|
|
48
|
+
emit(event, payload) {
|
|
49
|
+
this.listeners.get(event)?.forEach((h) => h(payload));
|
|
50
|
+
}
|
|
51
|
+
/** Remove all registered listeners for all events. */
|
|
52
|
+
removeAllListeners() {
|
|
53
|
+
this.listeners.clear();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** Options for constructing an {@link ApiError}. */
|
|
2
|
+
export interface ApiErrorOptions {
|
|
3
|
+
/** Human-readable description of the error. */
|
|
4
|
+
message: string;
|
|
5
|
+
/** HTTP status code of the failing response. */
|
|
6
|
+
status: number;
|
|
7
|
+
/** Optional URL to documentation about this error. */
|
|
8
|
+
helpUrl?: string | null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* An error returned by the MeowPanel API.
|
|
12
|
+
*
|
|
13
|
+
* All {@link HttpClient} methods throw this when the server responds with a non-2xx status code.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts ignore
|
|
17
|
+
* try {
|
|
18
|
+
* const server = await api.servers.get(id);
|
|
19
|
+
* } catch (e) {
|
|
20
|
+
* if (e instanceof ApiError) {
|
|
21
|
+
* if (e.isNotFound) console.error('Server not found');
|
|
22
|
+
* if (e.isAuthError) console.error('Access denied:', e.message);
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare class ApiError extends Error {
|
|
28
|
+
/** HTTP status code of the error response. */
|
|
29
|
+
readonly status: number;
|
|
30
|
+
/** Optional documentation URL, or `null` if not provided by the API. */
|
|
31
|
+
readonly helpUrl: string | null;
|
|
32
|
+
constructor(options: ApiErrorOptions);
|
|
33
|
+
/** `true` when the API returned `404 Not Found`. */
|
|
34
|
+
get isNotFound(): boolean;
|
|
35
|
+
/** `true` when the API returned `401 Unauthorized` or `403 Forbidden`. */
|
|
36
|
+
get isAuthError(): boolean;
|
|
37
|
+
/** `true` when the API returned `400 Bad Request` or `422 Unprocessable Entity`. */
|
|
38
|
+
get isValidationError(): boolean;
|
|
39
|
+
/** `true` when the API returned a `5xx` server error. */
|
|
40
|
+
get isServerError(): boolean;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/src/errors.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,WAAW,eAAe;IAC/B,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,QAAS,SAAQ,KAAK;IAClC,8CAA8C;IAC9C,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,wEAAwE;IACxE,SAAgB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;gBAEpB,OAAO,EAAE,eAAe;IAO3C,oDAAoD;IACpD,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED,0EAA0E;IAC1E,IAAW,WAAW,IAAI,OAAO,CAEhC;IAED,oFAAoF;IACpF,IAAW,iBAAiB,IAAI,OAAO,CAEtC;IAED,yDAAyD;IACzD,IAAW,aAAa,IAAI,OAAO,CAElC;CACD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An error returned by the MeowPanel API.
|
|
3
|
+
*
|
|
4
|
+
* All {@link HttpClient} methods throw this when the server responds with a non-2xx status code.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts ignore
|
|
8
|
+
* try {
|
|
9
|
+
* const server = await api.servers.get(id);
|
|
10
|
+
* } catch (e) {
|
|
11
|
+
* if (e instanceof ApiError) {
|
|
12
|
+
* if (e.isNotFound) console.error('Server not found');
|
|
13
|
+
* if (e.isAuthError) console.error('Access denied:', e.message);
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export class ApiError extends Error {
|
|
19
|
+
/** HTTP status code of the error response. */
|
|
20
|
+
status;
|
|
21
|
+
/** Optional documentation URL, or `null` if not provided by the API. */
|
|
22
|
+
helpUrl;
|
|
23
|
+
constructor(options) {
|
|
24
|
+
super(options.message);
|
|
25
|
+
this.name = 'ApiError';
|
|
26
|
+
this.status = options.status;
|
|
27
|
+
this.helpUrl = options.helpUrl ?? null;
|
|
28
|
+
}
|
|
29
|
+
/** `true` when the API returned `404 Not Found`. */
|
|
30
|
+
get isNotFound() {
|
|
31
|
+
return this.status === 404;
|
|
32
|
+
}
|
|
33
|
+
/** `true` when the API returned `401 Unauthorized` or `403 Forbidden`. */
|
|
34
|
+
get isAuthError() {
|
|
35
|
+
return this.status === 401 || this.status === 403;
|
|
36
|
+
}
|
|
37
|
+
/** `true` when the API returned `400 Bad Request` or `422 Unprocessable Entity`. */
|
|
38
|
+
get isValidationError() {
|
|
39
|
+
return this.status === 400 || this.status === 422;
|
|
40
|
+
}
|
|
41
|
+
/** `true` when the API returned a `5xx` server error. */
|
|
42
|
+
get isServerError() {
|
|
43
|
+
return this.status >= 500;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { ApiError } from './errors.js';
|
|
2
|
+
import type { ListOptions, Paginated } from './types.js';
|
|
3
|
+
/** Configuration for {@link HttpClient}. */
|
|
4
|
+
export interface HttpClientOptions {
|
|
5
|
+
/** Base URL of the MeowPanel Nexus API, e.g. `https://panel.example.com`. */
|
|
6
|
+
url: string;
|
|
7
|
+
/** Bearer token used to authenticate every request. */
|
|
8
|
+
token?: string;
|
|
9
|
+
/** Custom fetch implementation. Defaults to `globalThis.fetch`. */
|
|
10
|
+
fetch?: typeof globalThis.fetch;
|
|
11
|
+
/** Optional callback invoked for every outgoing request lifecycle event. */
|
|
12
|
+
logger?: HttpLogger;
|
|
13
|
+
/**
|
|
14
|
+
* The `credentials` mode for all fetch requests.
|
|
15
|
+
*
|
|
16
|
+
* Set to `'include'` for browser apps that rely on cookie-based authentication
|
|
17
|
+
* (e.g. session cookies set by the auth endpoint).
|
|
18
|
+
*
|
|
19
|
+
* Defaults to `undefined` (browser default is `'same-origin'`).
|
|
20
|
+
*/
|
|
21
|
+
credentials?: RequestCredentials;
|
|
22
|
+
/** Callback invoked when the access token is refreshed. */
|
|
23
|
+
onTokenRefresh?: (token: string) => void;
|
|
24
|
+
}
|
|
25
|
+
/** Typed lifecycle code emitted by {@link HttpClient}'s optional logger. */
|
|
26
|
+
export type HttpLogCode = 'request.start' | 'request.success' | 'request.error';
|
|
27
|
+
/** Common fields included with every HTTP log event. */
|
|
28
|
+
interface HttpLogEventBase {
|
|
29
|
+
code: HttpLogCode;
|
|
30
|
+
method: string;
|
|
31
|
+
path: string;
|
|
32
|
+
url: string;
|
|
33
|
+
params?: Record<string, string | number | boolean | undefined>;
|
|
34
|
+
}
|
|
35
|
+
/** Emitted immediately before a request is sent. */
|
|
36
|
+
export interface HttpRequestStartLogEvent extends HttpLogEventBase {
|
|
37
|
+
code: 'request.start';
|
|
38
|
+
}
|
|
39
|
+
/** Emitted after a successful response is received. */
|
|
40
|
+
export interface HttpRequestSuccessLogEvent extends HttpLogEventBase {
|
|
41
|
+
code: 'request.success';
|
|
42
|
+
status: number;
|
|
43
|
+
durationMs: number;
|
|
44
|
+
}
|
|
45
|
+
/** Emitted when a request fails due to an HTTP or transport error. */
|
|
46
|
+
export interface HttpRequestErrorLogEvent extends HttpLogEventBase {
|
|
47
|
+
code: 'request.error';
|
|
48
|
+
status?: number;
|
|
49
|
+
durationMs: number;
|
|
50
|
+
error: Error;
|
|
51
|
+
}
|
|
52
|
+
/** Union of all events emitted to the optional HTTP logger. */
|
|
53
|
+
export type HttpLogEvent = HttpRequestStartLogEvent | HttpRequestSuccessLogEvent | HttpRequestErrorLogEvent;
|
|
54
|
+
/** Callback invoked for outgoing request lifecycle events. */
|
|
55
|
+
export type HttpLogger = (event: HttpLogEvent) => void;
|
|
56
|
+
/** Per-request options shared across all {@link HttpClient} methods. */
|
|
57
|
+
export interface RequestOptions {
|
|
58
|
+
/** Query parameters to append to the URL. Undefined values are omitted. */
|
|
59
|
+
params?: Record<string, string | number | boolean | undefined>;
|
|
60
|
+
/** AbortSignal for cancelling the request. */
|
|
61
|
+
signal?: AbortSignal;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A thin `fetch` wrapper providing bearer auth, JSON serialization, error parsing,
|
|
65
|
+
* and paginated list support.
|
|
66
|
+
*
|
|
67
|
+
* All methods throw {@link ApiError} for non-2xx HTTP responses.
|
|
68
|
+
*/
|
|
69
|
+
export declare class HttpClient {
|
|
70
|
+
protected baseUrl: string;
|
|
71
|
+
protected token: string;
|
|
72
|
+
protected readonly fetchImpl: typeof globalThis.fetch;
|
|
73
|
+
protected readonly logger?: HttpLogger;
|
|
74
|
+
protected readonly credentials?: RequestCredentials;
|
|
75
|
+
protected readonly onTokenRefresh?: (token: string) => void;
|
|
76
|
+
private refreshPromise;
|
|
77
|
+
constructor(options: HttpClientOptions);
|
|
78
|
+
/** Replace the bearer token for all subsequent requests. */
|
|
79
|
+
setToken(token: string): void;
|
|
80
|
+
/** Return the current bearer token. */
|
|
81
|
+
getToken(): string;
|
|
82
|
+
/** Build a fully qualified URL with optional query parameters. */
|
|
83
|
+
buildUrl(path: string, params?: Record<string, string | number | boolean | undefined>): string;
|
|
84
|
+
/** Shared headers sent with every JSON request. */
|
|
85
|
+
protected get defaultHeaders(): Record<string, string>;
|
|
86
|
+
/** Parse a non-2xx response body into an {@link ApiError}. */
|
|
87
|
+
protected parseError(response: Response): Promise<ApiError>;
|
|
88
|
+
private log;
|
|
89
|
+
private executeFetch;
|
|
90
|
+
/** Extract the `exp` claim from a JWT without verification. Returns 0 for non-JWT tokens. */
|
|
91
|
+
private getTokenExp;
|
|
92
|
+
/** Refresh the access token if it's a JWT and about to expire. */
|
|
93
|
+
private refreshTokenIfNeeded;
|
|
94
|
+
/** Force a token refresh regardless of expiry. Only works if credentials are set (cookie auth). */
|
|
95
|
+
private forceRefresh;
|
|
96
|
+
/**
|
|
97
|
+
* Perform a raw `fetch` and throw {@link ApiError} on non-2xx responses.
|
|
98
|
+
*
|
|
99
|
+
* Proactively refreshes JWT tokens that are about to expire and retries
|
|
100
|
+
* once on `401 Unauthorized` after forcing a token refresh.
|
|
101
|
+
*
|
|
102
|
+
* @param path Path relative to the API base URL, e.g. `/servers`.
|
|
103
|
+
* @param init Standard `RequestInit` options.
|
|
104
|
+
* @param params Query parameters to append.
|
|
105
|
+
*/
|
|
106
|
+
fetch(path: string, init?: RequestInit, params?: Record<string, string | number | boolean | undefined>): Promise<Response>;
|
|
107
|
+
/**
|
|
108
|
+
* GET and deserialize a JSON response body.
|
|
109
|
+
*
|
|
110
|
+
* @param path Path relative to the API base URL.
|
|
111
|
+
* @param opts Additional request options.
|
|
112
|
+
*/
|
|
113
|
+
get<T>(path: string, opts?: RequestOptions): Promise<T>;
|
|
114
|
+
/**
|
|
115
|
+
* POST with an optional JSON body. Returns `undefined` for `204 No Content`.
|
|
116
|
+
*
|
|
117
|
+
* @param path Path relative to the API base URL.
|
|
118
|
+
* @param body Request body, serialized as JSON.
|
|
119
|
+
* @param opts Additional request options.
|
|
120
|
+
*/
|
|
121
|
+
post<T = void>(path: string, body?: unknown, opts?: RequestOptions): Promise<T>;
|
|
122
|
+
/**
|
|
123
|
+
* PATCH with an optional JSON body. Returns `undefined` for `204 No Content`.
|
|
124
|
+
*
|
|
125
|
+
* @param path Path relative to the API base URL.
|
|
126
|
+
* @param body Partial update body, serialized as JSON.
|
|
127
|
+
* @param opts Additional request options.
|
|
128
|
+
*/
|
|
129
|
+
patch<T = void>(path: string, body?: unknown, opts?: RequestOptions): Promise<T>;
|
|
130
|
+
/**
|
|
131
|
+
* DELETE a resource.
|
|
132
|
+
*
|
|
133
|
+
* @param path Path relative to the API base URL.
|
|
134
|
+
* @param opts Additional request options.
|
|
135
|
+
*/
|
|
136
|
+
delete(path: string, opts?: RequestOptions): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* PUT raw body content (e.g. for binary or multipart uploads).
|
|
139
|
+
*
|
|
140
|
+
* @param path Path relative to the API base URL.
|
|
141
|
+
* @param body Raw body content.
|
|
142
|
+
* @param contentType The `Content-Type` header value.
|
|
143
|
+
* @param opts Additional request options.
|
|
144
|
+
*/
|
|
145
|
+
put<T = void>(path: string, body: BodyInit, contentType: string, opts?: RequestOptions): Promise<T>;
|
|
146
|
+
/**
|
|
147
|
+
* GET a paginated list, parsing the `Content-Range` header for metadata when available.
|
|
148
|
+
*
|
|
149
|
+
* The `Content-Range` header format expected is: `items {from}-{to}/{total}`.
|
|
150
|
+
*
|
|
151
|
+
* @param path Path relative to the API base URL.
|
|
152
|
+
* @param opts Pagination and search options.
|
|
153
|
+
*/
|
|
154
|
+
list<T>(path: string, opts?: ListOptions, extraParams?: Record<string, string | number | boolean | undefined>): Promise<Paginated<T>>;
|
|
155
|
+
}
|
|
156
|
+
export {};
|
|
157
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEzD,4CAA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