@developer.krd/discord-dashboard 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +166 -554
- package/dist/index.cjs +569 -711
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +141 -69
- package/dist/index.d.ts +141 -69
- package/dist/index.js +568 -707
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Express } from 'express';
|
|
2
2
|
|
|
3
|
+
type DashboardScope = "setup" | "user" | "guild";
|
|
4
|
+
type DashboardBoxWidth = 100 | 50 | 33 | 20;
|
|
3
5
|
type CardIntent = "neutral" | "success" | "warning" | "danger" | "info";
|
|
6
|
+
|
|
4
7
|
interface DashboardCard {
|
|
5
8
|
id: string;
|
|
6
9
|
title: string;
|
|
@@ -12,7 +15,6 @@ interface DashboardCard {
|
|
|
12
15
|
direction: "up" | "down" | "flat";
|
|
13
16
|
};
|
|
14
17
|
}
|
|
15
|
-
type DashboardBoxWidth = 100 | 50 | 33 | 20;
|
|
16
18
|
interface DashboardDesignConfig {
|
|
17
19
|
bg?: string;
|
|
18
20
|
rail?: string;
|
|
@@ -27,6 +29,7 @@ interface DashboardDesignConfig {
|
|
|
27
29
|
danger?: string;
|
|
28
30
|
info?: string;
|
|
29
31
|
border?: string;
|
|
32
|
+
customCss?: string;
|
|
30
33
|
}
|
|
31
34
|
interface DashboardTemplateRenderContext {
|
|
32
35
|
dashboardName: string;
|
|
@@ -34,36 +37,23 @@ interface DashboardTemplateRenderContext {
|
|
|
34
37
|
setupDesign?: DashboardDesignConfig;
|
|
35
38
|
}
|
|
36
39
|
type DashboardTemplateRenderer = (context: DashboardTemplateRenderContext) => string;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
label: string;
|
|
40
|
-
value: string | number | boolean | string[] | Record<string, unknown>;
|
|
41
|
-
type?: HomeFieldType | "url";
|
|
42
|
-
editable?: boolean;
|
|
43
|
-
placeholder?: string;
|
|
44
|
-
required?: boolean;
|
|
45
|
-
options?: HomeFieldOption[];
|
|
46
|
-
lookup?: HomeLookupConfig;
|
|
47
|
-
}
|
|
48
|
-
interface PluginPanelAction {
|
|
40
|
+
|
|
41
|
+
interface DashboardUser {
|
|
49
42
|
id: string;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
username: string;
|
|
44
|
+
discriminator: string;
|
|
45
|
+
avatar: string | null;
|
|
46
|
+
global_name?: string | null;
|
|
53
47
|
}
|
|
54
|
-
interface
|
|
48
|
+
interface DashboardGuild {
|
|
55
49
|
id: string;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
ok: boolean;
|
|
64
|
-
message?: string;
|
|
65
|
-
refresh?: boolean;
|
|
66
|
-
data?: unknown;
|
|
50
|
+
name: string;
|
|
51
|
+
icon: string | null;
|
|
52
|
+
owner: boolean;
|
|
53
|
+
permissions: string;
|
|
54
|
+
iconUrl?: string | null;
|
|
55
|
+
botInGuild?: boolean;
|
|
56
|
+
inviteUrl?: string;
|
|
67
57
|
}
|
|
68
58
|
interface DiscordChannel {
|
|
69
59
|
id: string;
|
|
@@ -113,13 +103,54 @@ interface DashboardDiscordHelpers {
|
|
|
113
103
|
}) => Promise<DiscordMember[]>;
|
|
114
104
|
getGuildMember: (guildId: string, userId: string) => Promise<DiscordMember | null>;
|
|
115
105
|
}
|
|
116
|
-
|
|
117
|
-
|
|
106
|
+
interface DashboardContext {
|
|
107
|
+
user: DashboardUser;
|
|
108
|
+
guilds: DashboardGuild[];
|
|
109
|
+
accessToken: string;
|
|
110
|
+
selectedGuildId?: string;
|
|
111
|
+
helpers: DashboardDiscordHelpers;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
interface PluginActionResult {
|
|
115
|
+
ok: boolean;
|
|
116
|
+
message?: string;
|
|
117
|
+
refresh?: boolean;
|
|
118
|
+
data?: unknown;
|
|
119
|
+
}
|
|
120
|
+
interface PluginPanelField {
|
|
121
|
+
id?: string;
|
|
122
|
+
label: string;
|
|
123
|
+
value: string | number | boolean | string[] | Record<string, unknown>;
|
|
124
|
+
type?: HomeFieldType | "url";
|
|
125
|
+
editable?: boolean;
|
|
126
|
+
placeholder?: string;
|
|
127
|
+
required?: boolean;
|
|
128
|
+
options?: HomeFieldOption[];
|
|
129
|
+
lookup?: HomeLookupConfig;
|
|
130
|
+
}
|
|
131
|
+
interface PluginPanelAction {
|
|
118
132
|
id: string;
|
|
119
133
|
label: string;
|
|
120
|
-
|
|
134
|
+
variant?: "primary" | "secondary" | "danger";
|
|
135
|
+
collectFields?: boolean;
|
|
136
|
+
}
|
|
137
|
+
interface PluginPanel {
|
|
138
|
+
id: string;
|
|
139
|
+
title: string;
|
|
140
|
+
description?: string;
|
|
141
|
+
width?: DashboardBoxWidth;
|
|
142
|
+
fields?: PluginPanelField[];
|
|
143
|
+
actions?: PluginPanelAction[];
|
|
144
|
+
}
|
|
145
|
+
interface DashboardPlugin {
|
|
146
|
+
id: string;
|
|
147
|
+
name: string;
|
|
121
148
|
description?: string;
|
|
149
|
+
scope?: DashboardScope | "both";
|
|
150
|
+
getPanels: (context: DashboardContext) => Promise<PluginPanel[]> | PluginPanel[];
|
|
151
|
+
actions?: Record<string, (context: DashboardContext, body: unknown) => Promise<PluginActionResult> | PluginActionResult>;
|
|
122
152
|
}
|
|
153
|
+
|
|
123
154
|
type HomeFieldType = "text" | "textarea" | "number" | "select" | "boolean" | "role-search" | "channel-search" | "member-search" | "string-list";
|
|
124
155
|
interface HomeLookupConfig {
|
|
125
156
|
limit?: number;
|
|
@@ -132,6 +163,12 @@ interface HomeFieldOption {
|
|
|
132
163
|
label: string;
|
|
133
164
|
value: string;
|
|
134
165
|
}
|
|
166
|
+
interface HomeCategory {
|
|
167
|
+
id: string;
|
|
168
|
+
label: string;
|
|
169
|
+
scope: DashboardScope;
|
|
170
|
+
description?: string;
|
|
171
|
+
}
|
|
135
172
|
interface HomeSectionField {
|
|
136
173
|
id: string;
|
|
137
174
|
label: string;
|
|
@@ -168,38 +205,7 @@ interface DashboardHomeBuilder {
|
|
|
168
205
|
getSections?: (context: DashboardContext) => Promise<HomeSection[]> | HomeSection[];
|
|
169
206
|
actions?: Record<string, (context: DashboardContext, payload: HomeActionPayload) => Promise<PluginActionResult> | PluginActionResult>;
|
|
170
207
|
}
|
|
171
|
-
|
|
172
|
-
id: string;
|
|
173
|
-
username: string;
|
|
174
|
-
discriminator: string;
|
|
175
|
-
avatar: string | null;
|
|
176
|
-
global_name?: string | null;
|
|
177
|
-
}
|
|
178
|
-
interface DashboardGuild {
|
|
179
|
-
id: string;
|
|
180
|
-
name: string;
|
|
181
|
-
icon: string | null;
|
|
182
|
-
owner: boolean;
|
|
183
|
-
permissions: string;
|
|
184
|
-
iconUrl?: string | null;
|
|
185
|
-
botInGuild?: boolean;
|
|
186
|
-
inviteUrl?: string;
|
|
187
|
-
}
|
|
188
|
-
interface DashboardContext {
|
|
189
|
-
user: DashboardUser;
|
|
190
|
-
guilds: DashboardGuild[];
|
|
191
|
-
accessToken: string;
|
|
192
|
-
selectedGuildId?: string;
|
|
193
|
-
helpers: DashboardDiscordHelpers;
|
|
194
|
-
}
|
|
195
|
-
interface DashboardPlugin {
|
|
196
|
-
id: string;
|
|
197
|
-
name: string;
|
|
198
|
-
description?: string;
|
|
199
|
-
scope?: DashboardScope | "both";
|
|
200
|
-
getPanels: (context: DashboardContext) => Promise<PluginPanel[]> | PluginPanel[];
|
|
201
|
-
actions?: Record<string, (context: DashboardContext, body: unknown) => Promise<PluginActionResult> | PluginActionResult>;
|
|
202
|
-
}
|
|
208
|
+
|
|
203
209
|
interface DashboardOptions {
|
|
204
210
|
app?: Express;
|
|
205
211
|
port?: number;
|
|
@@ -232,7 +238,29 @@ interface DashboardInstance {
|
|
|
232
238
|
stop: () => Promise<void>;
|
|
233
239
|
}
|
|
234
240
|
|
|
235
|
-
declare
|
|
241
|
+
declare class DiscordHelpers implements DashboardDiscordHelpers {
|
|
242
|
+
private readonly botToken;
|
|
243
|
+
private readonly DISCORD_API;
|
|
244
|
+
constructor(botToken: string);
|
|
245
|
+
private fetchDiscordWithBot;
|
|
246
|
+
getChannel(channelId: string): Promise<DiscordChannel | null>;
|
|
247
|
+
getGuildChannels(guildId: string): Promise<DiscordChannel[]>;
|
|
248
|
+
searchGuildChannels(guildId: string, query: string, options?: {
|
|
249
|
+
limit?: number;
|
|
250
|
+
nsfw?: boolean;
|
|
251
|
+
channelTypes?: number[];
|
|
252
|
+
}): Promise<DiscordChannel[]>;
|
|
253
|
+
getRole(guildId: string, roleId: string): Promise<DiscordRole | null>;
|
|
254
|
+
getGuildRoles(guildId: string): Promise<DiscordRole[]>;
|
|
255
|
+
searchGuildRoles(guildId: string, query: string, options?: {
|
|
256
|
+
limit?: number;
|
|
257
|
+
includeManaged?: boolean;
|
|
258
|
+
}): Promise<DiscordRole[]>;
|
|
259
|
+
searchGuildMembers(guildId: string, query: string, options?: {
|
|
260
|
+
limit?: number;
|
|
261
|
+
}): Promise<DiscordMember[]>;
|
|
262
|
+
getGuildMember(guildId: string, userId: string): Promise<DiscordMember | null>;
|
|
263
|
+
}
|
|
236
264
|
|
|
237
265
|
type HomeActionHandler = (context: DashboardContext, payload: HomeActionPayload) => Promise<PluginActionResult> | PluginActionResult;
|
|
238
266
|
type HomeLoadHandler = (context: DashboardContext, section: HomeSection) => Promise<Partial<HomeSection> | HomeSection | void> | Partial<HomeSection> | HomeSection | void;
|
|
@@ -300,18 +328,62 @@ declare class DashboardDesigner {
|
|
|
300
328
|
fields?: HomeSectionField[];
|
|
301
329
|
actions?: HomeSectionAction[];
|
|
302
330
|
}): this;
|
|
303
|
-
onHomeAction(actionId: string, handler: HomeActionHandler): this;
|
|
304
331
|
onLoad(pageId: string, handler: HomeLoadHandler): this;
|
|
305
332
|
onload(pageId: string, handler: HomeLoadHandler): this;
|
|
306
333
|
onSave(pageId: string, handler: HomeActionHandler): this;
|
|
307
334
|
onsave(pageId: string, handler: HomeActionHandler): this;
|
|
335
|
+
onHomeAction(actionId: string, handler: HomeActionHandler): this;
|
|
336
|
+
customCss(cssString: string): this;
|
|
308
337
|
build(): DashboardOptions;
|
|
338
|
+
/**
|
|
339
|
+
* Builds the configuration and immediately instantiates the Dashboard.
|
|
340
|
+
*/
|
|
341
|
+
createDashboard(): DiscordDashboard;
|
|
309
342
|
}
|
|
310
|
-
declare function createDashboardDesigner(baseOptions: Omit<DashboardOptions, "home">): DashboardDesigner;
|
|
311
|
-
|
|
312
|
-
declare function createDiscordHelpers(botToken: string): DashboardDiscordHelpers;
|
|
313
343
|
|
|
314
344
|
declare const builtinTemplateRenderers: Record<string, DashboardTemplateRenderer>;
|
|
315
345
|
declare function getBuiltinTemplateRenderer(templateId: string): DashboardTemplateRenderer | undefined;
|
|
316
346
|
|
|
317
|
-
|
|
347
|
+
declare class DiscordDashboard implements DashboardInstance {
|
|
348
|
+
app: Express;
|
|
349
|
+
options: DashboardOptions;
|
|
350
|
+
helpers: DiscordHelpers;
|
|
351
|
+
private router;
|
|
352
|
+
private server?;
|
|
353
|
+
private basePath;
|
|
354
|
+
private templateRenderer;
|
|
355
|
+
private plugins;
|
|
356
|
+
constructor(options: DashboardOptions);
|
|
357
|
+
private validateOptions;
|
|
358
|
+
private setupMiddleware;
|
|
359
|
+
private setupRoutes;
|
|
360
|
+
start(): Promise<void>;
|
|
361
|
+
stop(): Promise<void>;
|
|
362
|
+
private handleRoot;
|
|
363
|
+
private handleLogin;
|
|
364
|
+
private handleCallback;
|
|
365
|
+
private handleLogout;
|
|
366
|
+
private handleSession;
|
|
367
|
+
private handleGuilds;
|
|
368
|
+
private handleOverview;
|
|
369
|
+
private handleHomeCategories;
|
|
370
|
+
private handleHome;
|
|
371
|
+
private handleLookupRoles;
|
|
372
|
+
private handleLookupChannels;
|
|
373
|
+
private handleLookupMembers;
|
|
374
|
+
private handleHomeAction;
|
|
375
|
+
private handlePlugins;
|
|
376
|
+
private handlePluginAction;
|
|
377
|
+
private ensureAuthenticated;
|
|
378
|
+
private createContext;
|
|
379
|
+
private exchangeCodeForToken;
|
|
380
|
+
private resolveOverviewCards;
|
|
381
|
+
private resolveHomeSections;
|
|
382
|
+
private resolveScope;
|
|
383
|
+
private resolveHomeCategories;
|
|
384
|
+
private createGuildInviteUrl;
|
|
385
|
+
private fetchBotGuildIds;
|
|
386
|
+
private resolveTemplateRenderer;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
export { type CardIntent, type DashboardBoxWidth, type DashboardCard, type DashboardContext, type DashboardDesignConfig, DashboardDesigner, type DashboardDiscordHelpers, type DashboardGuild, type DashboardHomeBuilder, type DashboardInstance, type DashboardOptions, type DashboardPlugin, type DashboardScope, type DashboardTemplateRenderContext, type DashboardTemplateRenderer, type DashboardUser, type DiscordChannel, DiscordDashboard, DiscordHelpers, type DiscordMember, type DiscordRole, type HomeActionPayload, type HomeCategory, type HomeFieldOption, type HomeFieldType, type HomeLookupConfig, type HomeSection, type HomeSectionAction, type HomeSectionField, type PluginActionResult, type PluginPanel, type PluginPanelAction, type PluginPanelField, builtinTemplateRenderers, getBuiltinTemplateRenderer };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Express } from 'express';
|
|
2
2
|
|
|
3
|
+
type DashboardScope = "setup" | "user" | "guild";
|
|
4
|
+
type DashboardBoxWidth = 100 | 50 | 33 | 20;
|
|
3
5
|
type CardIntent = "neutral" | "success" | "warning" | "danger" | "info";
|
|
6
|
+
|
|
4
7
|
interface DashboardCard {
|
|
5
8
|
id: string;
|
|
6
9
|
title: string;
|
|
@@ -12,7 +15,6 @@ interface DashboardCard {
|
|
|
12
15
|
direction: "up" | "down" | "flat";
|
|
13
16
|
};
|
|
14
17
|
}
|
|
15
|
-
type DashboardBoxWidth = 100 | 50 | 33 | 20;
|
|
16
18
|
interface DashboardDesignConfig {
|
|
17
19
|
bg?: string;
|
|
18
20
|
rail?: string;
|
|
@@ -27,6 +29,7 @@ interface DashboardDesignConfig {
|
|
|
27
29
|
danger?: string;
|
|
28
30
|
info?: string;
|
|
29
31
|
border?: string;
|
|
32
|
+
customCss?: string;
|
|
30
33
|
}
|
|
31
34
|
interface DashboardTemplateRenderContext {
|
|
32
35
|
dashboardName: string;
|
|
@@ -34,36 +37,23 @@ interface DashboardTemplateRenderContext {
|
|
|
34
37
|
setupDesign?: DashboardDesignConfig;
|
|
35
38
|
}
|
|
36
39
|
type DashboardTemplateRenderer = (context: DashboardTemplateRenderContext) => string;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
label: string;
|
|
40
|
-
value: string | number | boolean | string[] | Record<string, unknown>;
|
|
41
|
-
type?: HomeFieldType | "url";
|
|
42
|
-
editable?: boolean;
|
|
43
|
-
placeholder?: string;
|
|
44
|
-
required?: boolean;
|
|
45
|
-
options?: HomeFieldOption[];
|
|
46
|
-
lookup?: HomeLookupConfig;
|
|
47
|
-
}
|
|
48
|
-
interface PluginPanelAction {
|
|
40
|
+
|
|
41
|
+
interface DashboardUser {
|
|
49
42
|
id: string;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
username: string;
|
|
44
|
+
discriminator: string;
|
|
45
|
+
avatar: string | null;
|
|
46
|
+
global_name?: string | null;
|
|
53
47
|
}
|
|
54
|
-
interface
|
|
48
|
+
interface DashboardGuild {
|
|
55
49
|
id: string;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
ok: boolean;
|
|
64
|
-
message?: string;
|
|
65
|
-
refresh?: boolean;
|
|
66
|
-
data?: unknown;
|
|
50
|
+
name: string;
|
|
51
|
+
icon: string | null;
|
|
52
|
+
owner: boolean;
|
|
53
|
+
permissions: string;
|
|
54
|
+
iconUrl?: string | null;
|
|
55
|
+
botInGuild?: boolean;
|
|
56
|
+
inviteUrl?: string;
|
|
67
57
|
}
|
|
68
58
|
interface DiscordChannel {
|
|
69
59
|
id: string;
|
|
@@ -113,13 +103,54 @@ interface DashboardDiscordHelpers {
|
|
|
113
103
|
}) => Promise<DiscordMember[]>;
|
|
114
104
|
getGuildMember: (guildId: string, userId: string) => Promise<DiscordMember | null>;
|
|
115
105
|
}
|
|
116
|
-
|
|
117
|
-
|
|
106
|
+
interface DashboardContext {
|
|
107
|
+
user: DashboardUser;
|
|
108
|
+
guilds: DashboardGuild[];
|
|
109
|
+
accessToken: string;
|
|
110
|
+
selectedGuildId?: string;
|
|
111
|
+
helpers: DashboardDiscordHelpers;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
interface PluginActionResult {
|
|
115
|
+
ok: boolean;
|
|
116
|
+
message?: string;
|
|
117
|
+
refresh?: boolean;
|
|
118
|
+
data?: unknown;
|
|
119
|
+
}
|
|
120
|
+
interface PluginPanelField {
|
|
121
|
+
id?: string;
|
|
122
|
+
label: string;
|
|
123
|
+
value: string | number | boolean | string[] | Record<string, unknown>;
|
|
124
|
+
type?: HomeFieldType | "url";
|
|
125
|
+
editable?: boolean;
|
|
126
|
+
placeholder?: string;
|
|
127
|
+
required?: boolean;
|
|
128
|
+
options?: HomeFieldOption[];
|
|
129
|
+
lookup?: HomeLookupConfig;
|
|
130
|
+
}
|
|
131
|
+
interface PluginPanelAction {
|
|
118
132
|
id: string;
|
|
119
133
|
label: string;
|
|
120
|
-
|
|
134
|
+
variant?: "primary" | "secondary" | "danger";
|
|
135
|
+
collectFields?: boolean;
|
|
136
|
+
}
|
|
137
|
+
interface PluginPanel {
|
|
138
|
+
id: string;
|
|
139
|
+
title: string;
|
|
140
|
+
description?: string;
|
|
141
|
+
width?: DashboardBoxWidth;
|
|
142
|
+
fields?: PluginPanelField[];
|
|
143
|
+
actions?: PluginPanelAction[];
|
|
144
|
+
}
|
|
145
|
+
interface DashboardPlugin {
|
|
146
|
+
id: string;
|
|
147
|
+
name: string;
|
|
121
148
|
description?: string;
|
|
149
|
+
scope?: DashboardScope | "both";
|
|
150
|
+
getPanels: (context: DashboardContext) => Promise<PluginPanel[]> | PluginPanel[];
|
|
151
|
+
actions?: Record<string, (context: DashboardContext, body: unknown) => Promise<PluginActionResult> | PluginActionResult>;
|
|
122
152
|
}
|
|
153
|
+
|
|
123
154
|
type HomeFieldType = "text" | "textarea" | "number" | "select" | "boolean" | "role-search" | "channel-search" | "member-search" | "string-list";
|
|
124
155
|
interface HomeLookupConfig {
|
|
125
156
|
limit?: number;
|
|
@@ -132,6 +163,12 @@ interface HomeFieldOption {
|
|
|
132
163
|
label: string;
|
|
133
164
|
value: string;
|
|
134
165
|
}
|
|
166
|
+
interface HomeCategory {
|
|
167
|
+
id: string;
|
|
168
|
+
label: string;
|
|
169
|
+
scope: DashboardScope;
|
|
170
|
+
description?: string;
|
|
171
|
+
}
|
|
135
172
|
interface HomeSectionField {
|
|
136
173
|
id: string;
|
|
137
174
|
label: string;
|
|
@@ -168,38 +205,7 @@ interface DashboardHomeBuilder {
|
|
|
168
205
|
getSections?: (context: DashboardContext) => Promise<HomeSection[]> | HomeSection[];
|
|
169
206
|
actions?: Record<string, (context: DashboardContext, payload: HomeActionPayload) => Promise<PluginActionResult> | PluginActionResult>;
|
|
170
207
|
}
|
|
171
|
-
|
|
172
|
-
id: string;
|
|
173
|
-
username: string;
|
|
174
|
-
discriminator: string;
|
|
175
|
-
avatar: string | null;
|
|
176
|
-
global_name?: string | null;
|
|
177
|
-
}
|
|
178
|
-
interface DashboardGuild {
|
|
179
|
-
id: string;
|
|
180
|
-
name: string;
|
|
181
|
-
icon: string | null;
|
|
182
|
-
owner: boolean;
|
|
183
|
-
permissions: string;
|
|
184
|
-
iconUrl?: string | null;
|
|
185
|
-
botInGuild?: boolean;
|
|
186
|
-
inviteUrl?: string;
|
|
187
|
-
}
|
|
188
|
-
interface DashboardContext {
|
|
189
|
-
user: DashboardUser;
|
|
190
|
-
guilds: DashboardGuild[];
|
|
191
|
-
accessToken: string;
|
|
192
|
-
selectedGuildId?: string;
|
|
193
|
-
helpers: DashboardDiscordHelpers;
|
|
194
|
-
}
|
|
195
|
-
interface DashboardPlugin {
|
|
196
|
-
id: string;
|
|
197
|
-
name: string;
|
|
198
|
-
description?: string;
|
|
199
|
-
scope?: DashboardScope | "both";
|
|
200
|
-
getPanels: (context: DashboardContext) => Promise<PluginPanel[]> | PluginPanel[];
|
|
201
|
-
actions?: Record<string, (context: DashboardContext, body: unknown) => Promise<PluginActionResult> | PluginActionResult>;
|
|
202
|
-
}
|
|
208
|
+
|
|
203
209
|
interface DashboardOptions {
|
|
204
210
|
app?: Express;
|
|
205
211
|
port?: number;
|
|
@@ -232,7 +238,29 @@ interface DashboardInstance {
|
|
|
232
238
|
stop: () => Promise<void>;
|
|
233
239
|
}
|
|
234
240
|
|
|
235
|
-
declare
|
|
241
|
+
declare class DiscordHelpers implements DashboardDiscordHelpers {
|
|
242
|
+
private readonly botToken;
|
|
243
|
+
private readonly DISCORD_API;
|
|
244
|
+
constructor(botToken: string);
|
|
245
|
+
private fetchDiscordWithBot;
|
|
246
|
+
getChannel(channelId: string): Promise<DiscordChannel | null>;
|
|
247
|
+
getGuildChannels(guildId: string): Promise<DiscordChannel[]>;
|
|
248
|
+
searchGuildChannels(guildId: string, query: string, options?: {
|
|
249
|
+
limit?: number;
|
|
250
|
+
nsfw?: boolean;
|
|
251
|
+
channelTypes?: number[];
|
|
252
|
+
}): Promise<DiscordChannel[]>;
|
|
253
|
+
getRole(guildId: string, roleId: string): Promise<DiscordRole | null>;
|
|
254
|
+
getGuildRoles(guildId: string): Promise<DiscordRole[]>;
|
|
255
|
+
searchGuildRoles(guildId: string, query: string, options?: {
|
|
256
|
+
limit?: number;
|
|
257
|
+
includeManaged?: boolean;
|
|
258
|
+
}): Promise<DiscordRole[]>;
|
|
259
|
+
searchGuildMembers(guildId: string, query: string, options?: {
|
|
260
|
+
limit?: number;
|
|
261
|
+
}): Promise<DiscordMember[]>;
|
|
262
|
+
getGuildMember(guildId: string, userId: string): Promise<DiscordMember | null>;
|
|
263
|
+
}
|
|
236
264
|
|
|
237
265
|
type HomeActionHandler = (context: DashboardContext, payload: HomeActionPayload) => Promise<PluginActionResult> | PluginActionResult;
|
|
238
266
|
type HomeLoadHandler = (context: DashboardContext, section: HomeSection) => Promise<Partial<HomeSection> | HomeSection | void> | Partial<HomeSection> | HomeSection | void;
|
|
@@ -300,18 +328,62 @@ declare class DashboardDesigner {
|
|
|
300
328
|
fields?: HomeSectionField[];
|
|
301
329
|
actions?: HomeSectionAction[];
|
|
302
330
|
}): this;
|
|
303
|
-
onHomeAction(actionId: string, handler: HomeActionHandler): this;
|
|
304
331
|
onLoad(pageId: string, handler: HomeLoadHandler): this;
|
|
305
332
|
onload(pageId: string, handler: HomeLoadHandler): this;
|
|
306
333
|
onSave(pageId: string, handler: HomeActionHandler): this;
|
|
307
334
|
onsave(pageId: string, handler: HomeActionHandler): this;
|
|
335
|
+
onHomeAction(actionId: string, handler: HomeActionHandler): this;
|
|
336
|
+
customCss(cssString: string): this;
|
|
308
337
|
build(): DashboardOptions;
|
|
338
|
+
/**
|
|
339
|
+
* Builds the configuration and immediately instantiates the Dashboard.
|
|
340
|
+
*/
|
|
341
|
+
createDashboard(): DiscordDashboard;
|
|
309
342
|
}
|
|
310
|
-
declare function createDashboardDesigner(baseOptions: Omit<DashboardOptions, "home">): DashboardDesigner;
|
|
311
|
-
|
|
312
|
-
declare function createDiscordHelpers(botToken: string): DashboardDiscordHelpers;
|
|
313
343
|
|
|
314
344
|
declare const builtinTemplateRenderers: Record<string, DashboardTemplateRenderer>;
|
|
315
345
|
declare function getBuiltinTemplateRenderer(templateId: string): DashboardTemplateRenderer | undefined;
|
|
316
346
|
|
|
317
|
-
|
|
347
|
+
declare class DiscordDashboard implements DashboardInstance {
|
|
348
|
+
app: Express;
|
|
349
|
+
options: DashboardOptions;
|
|
350
|
+
helpers: DiscordHelpers;
|
|
351
|
+
private router;
|
|
352
|
+
private server?;
|
|
353
|
+
private basePath;
|
|
354
|
+
private templateRenderer;
|
|
355
|
+
private plugins;
|
|
356
|
+
constructor(options: DashboardOptions);
|
|
357
|
+
private validateOptions;
|
|
358
|
+
private setupMiddleware;
|
|
359
|
+
private setupRoutes;
|
|
360
|
+
start(): Promise<void>;
|
|
361
|
+
stop(): Promise<void>;
|
|
362
|
+
private handleRoot;
|
|
363
|
+
private handleLogin;
|
|
364
|
+
private handleCallback;
|
|
365
|
+
private handleLogout;
|
|
366
|
+
private handleSession;
|
|
367
|
+
private handleGuilds;
|
|
368
|
+
private handleOverview;
|
|
369
|
+
private handleHomeCategories;
|
|
370
|
+
private handleHome;
|
|
371
|
+
private handleLookupRoles;
|
|
372
|
+
private handleLookupChannels;
|
|
373
|
+
private handleLookupMembers;
|
|
374
|
+
private handleHomeAction;
|
|
375
|
+
private handlePlugins;
|
|
376
|
+
private handlePluginAction;
|
|
377
|
+
private ensureAuthenticated;
|
|
378
|
+
private createContext;
|
|
379
|
+
private exchangeCodeForToken;
|
|
380
|
+
private resolveOverviewCards;
|
|
381
|
+
private resolveHomeSections;
|
|
382
|
+
private resolveScope;
|
|
383
|
+
private resolveHomeCategories;
|
|
384
|
+
private createGuildInviteUrl;
|
|
385
|
+
private fetchBotGuildIds;
|
|
386
|
+
private resolveTemplateRenderer;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
export { type CardIntent, type DashboardBoxWidth, type DashboardCard, type DashboardContext, type DashboardDesignConfig, DashboardDesigner, type DashboardDiscordHelpers, type DashboardGuild, type DashboardHomeBuilder, type DashboardInstance, type DashboardOptions, type DashboardPlugin, type DashboardScope, type DashboardTemplateRenderContext, type DashboardTemplateRenderer, type DashboardUser, type DiscordChannel, DiscordDashboard, DiscordHelpers, type DiscordMember, type DiscordRole, type HomeActionPayload, type HomeCategory, type HomeFieldOption, type HomeFieldType, type HomeLookupConfig, type HomeSection, type HomeSectionAction, type HomeSectionField, type PluginActionResult, type PluginPanel, type PluginPanelAction, type PluginPanelField, builtinTemplateRenderers, getBuiltinTemplateRenderer };
|