@lagapp/sdk 0.1.0
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/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.md +207 -0
- package/dist/client.d.ts +36 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +45 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +67 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +103 -0
- package/dist/errors.js.map +1 -0
- package/dist/http.d.ts +61 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +187 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/pagination.d.ts +39 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +26 -0
- package/dist/pagination.js.map +1 -0
- package/dist/resources/dms.d.ts +39 -0
- package/dist/resources/dms.d.ts.map +1 -0
- package/dist/resources/dms.js +76 -0
- package/dist/resources/dms.js.map +1 -0
- package/dist/resources/event-guests.d.ts +30 -0
- package/dist/resources/event-guests.d.ts.map +1 -0
- package/dist/resources/event-guests.js +39 -0
- package/dist/resources/event-guests.js.map +1 -0
- package/dist/resources/event-templates.d.ts +24 -0
- package/dist/resources/event-templates.d.ts.map +1 -0
- package/dist/resources/event-templates.js +42 -0
- package/dist/resources/event-templates.js.map +1 -0
- package/dist/resources/events.d.ts +38 -0
- package/dist/resources/events.d.ts.map +1 -0
- package/dist/resources/events.js +73 -0
- package/dist/resources/events.js.map +1 -0
- package/dist/resources/friends.d.ts +32 -0
- package/dist/resources/friends.d.ts.map +1 -0
- package/dist/resources/friends.js +65 -0
- package/dist/resources/friends.js.map +1 -0
- package/dist/resources/images.d.ts +41 -0
- package/dist/resources/images.d.ts.map +1 -0
- package/dist/resources/images.js +106 -0
- package/dist/resources/images.js.map +1 -0
- package/dist/resources/room-messages.d.ts +24 -0
- package/dist/resources/room-messages.d.ts.map +1 -0
- package/dist/resources/room-messages.js +49 -0
- package/dist/resources/room-messages.js.map +1 -0
- package/dist/resources/rooms.d.ts +24 -0
- package/dist/resources/rooms.d.ts.map +1 -0
- package/dist/resources/rooms.js +42 -0
- package/dist/resources/rooms.js.map +1 -0
- package/dist/resources/server-invites.d.ts +29 -0
- package/dist/resources/server-invites.d.ts.map +1 -0
- package/dist/resources/server-invites.js +59 -0
- package/dist/resources/server-invites.js.map +1 -0
- package/dist/resources/server-members.d.ts +27 -0
- package/dist/resources/server-members.d.ts.map +1 -0
- package/dist/resources/server-members.js +64 -0
- package/dist/resources/server-members.js.map +1 -0
- package/dist/resources/server-roles.d.ts +23 -0
- package/dist/resources/server-roles.d.ts.map +1 -0
- package/dist/resources/server-roles.js +51 -0
- package/dist/resources/server-roles.js.map +1 -0
- package/dist/resources/servers.d.ts +37 -0
- package/dist/resources/servers.d.ts.map +1 -0
- package/dist/resources/servers.js +72 -0
- package/dist/resources/servers.js.map +1 -0
- package/dist/resources/system.d.ts +20 -0
- package/dist/resources/system.d.ts.map +1 -0
- package/dist/resources/system.js +27 -0
- package/dist/resources/system.js.map +1 -0
- package/dist/resources/users.d.ts +48 -0
- package/dist/resources/users.d.ts.map +1 -0
- package/dist/resources/users.js +103 -0
- package/dist/resources/users.js.map +1 -0
- package/dist/types/common.d.ts +27 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +23 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/dm.d.ts +33 -0
- package/dist/types/dm.d.ts.map +1 -0
- package/dist/types/dm.js +2 -0
- package/dist/types/dm.js.map +1 -0
- package/dist/types/event.d.ts +101 -0
- package/dist/types/event.d.ts.map +1 -0
- package/dist/types/event.js +2 -0
- package/dist/types/event.js.map +1 -0
- package/dist/types/friend.d.ts +51 -0
- package/dist/types/friend.d.ts.map +1 -0
- package/dist/types/friend.js +2 -0
- package/dist/types/friend.js.map +1 -0
- package/dist/types/image.d.ts +33 -0
- package/dist/types/image.d.ts.map +1 -0
- package/dist/types/image.js +3 -0
- package/dist/types/image.js.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +10 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/room.d.ts +98 -0
- package/dist/types/room.d.ts.map +1 -0
- package/dist/types/room.js +2 -0
- package/dist/types/room.js.map +1 -0
- package/dist/types/server.d.ts +134 -0
- package/dist/types/server.d.ts.map +1 -0
- package/dist/types/server.js +2 -0
- package/dist/types/server.js.map +1 -0
- package/dist/types/system.d.ts +14 -0
- package/dist/types/system.d.ts.map +1 -0
- package/dist/types/system.js +2 -0
- package/dist/types/system.js.map +1 -0
- package/dist/types/user.d.ts +61 -0
- package/dist/types/user.d.ts.map +1 -0
- package/dist/types/user.js +2 -0
- package/dist/types/user.js.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { HttpClient } from '../http.js';
|
|
2
|
+
import type { CreateEventBody, EventSummary, RsvpBody, RsvpResponse, UpdateEventBody } from '../types/event.js';
|
|
3
|
+
import { EventGuestsResource } from './event-guests.js';
|
|
4
|
+
import { EventTemplatesResource } from './event-templates.js';
|
|
5
|
+
/**
|
|
6
|
+
* Events resource: scheduled voice events that belong to a server.
|
|
7
|
+
*
|
|
8
|
+
* The Lag API mounts events under `/servers/:id/events/...` (and templates
|
|
9
|
+
* under `/servers/:id/event-templates/...`), so every method here takes a
|
|
10
|
+
* `serverId`. The two sub-resources `guests` and `templates` follow the
|
|
11
|
+
* same pattern.
|
|
12
|
+
*/
|
|
13
|
+
export declare class EventsResource {
|
|
14
|
+
private readonly http;
|
|
15
|
+
readonly guests: EventGuestsResource;
|
|
16
|
+
readonly templates: EventTemplatesResource;
|
|
17
|
+
constructor(http: HttpClient);
|
|
18
|
+
/** GET /servers/:id/events - upcoming and active events in a server. */
|
|
19
|
+
list(serverId: string): Promise<{
|
|
20
|
+
events: EventSummary[];
|
|
21
|
+
}>;
|
|
22
|
+
/** POST /servers/:id/events - create a new event. */
|
|
23
|
+
create(serverId: string, body: CreateEventBody): Promise<EventSummary>;
|
|
24
|
+
/** GET /servers/:id/events/:eventId - event detail. */
|
|
25
|
+
get(serverId: string, eventId: string): Promise<EventSummary>;
|
|
26
|
+
/** PATCH /servers/:id/events/:eventId - update event metadata. */
|
|
27
|
+
update(serverId: string, eventId: string, body: UpdateEventBody): Promise<EventSummary>;
|
|
28
|
+
/** DELETE /servers/:id/events/:eventId - cancel an event (soft delete). */
|
|
29
|
+
cancel(serverId: string, eventId: string): Promise<{
|
|
30
|
+
status: string;
|
|
31
|
+
deletesAt?: string;
|
|
32
|
+
}>;
|
|
33
|
+
/** POST /servers/:id/events/:eventId/rsvp - set the caller's RSVP status. */
|
|
34
|
+
rsvp(serverId: string, eventId: string, body: RsvpBody): Promise<RsvpResponse>;
|
|
35
|
+
/** POST /servers/:id/events/:eventId/external/toggle - toggle external (share-link) access. */
|
|
36
|
+
toggleExternalAccess(serverId: string, eventId: string): Promise<EventSummary>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/resources/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;;;;;;GAOG;AACH,qBAAa,cAAc;IAIb,OAAO,CAAC,QAAQ,CAAC,IAAI;IAHjC,SAAgB,MAAM,EAAE,mBAAmB,CAAC;IAC5C,SAAgB,SAAS,EAAE,sBAAsB,CAAC;gBAErB,IAAI,EAAE,UAAU;IAK7C,wEAAwE;IACxE,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAO3D,qDAAqD;IACrD,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC;IAQtE,uDAAuD;IACvD,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAO7D,kEAAkE;IAClE,MAAM,CACJ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,YAAY,CAAC;IAQxB,2EAA2E;IAC3E,MAAM,CACJ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAOlD,6EAA6E;IAC7E,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IAQ9E,+FAA+F;IAC/F,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAM/E"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { EventGuestsResource } from './event-guests.js';
|
|
2
|
+
import { EventTemplatesResource } from './event-templates.js';
|
|
3
|
+
/**
|
|
4
|
+
* Events resource: scheduled voice events that belong to a server.
|
|
5
|
+
*
|
|
6
|
+
* The Lag API mounts events under `/servers/:id/events/...` (and templates
|
|
7
|
+
* under `/servers/:id/event-templates/...`), so every method here takes a
|
|
8
|
+
* `serverId`. The two sub-resources `guests` and `templates` follow the
|
|
9
|
+
* same pattern.
|
|
10
|
+
*/
|
|
11
|
+
export class EventsResource {
|
|
12
|
+
http;
|
|
13
|
+
guests;
|
|
14
|
+
templates;
|
|
15
|
+
constructor(http) {
|
|
16
|
+
this.http = http;
|
|
17
|
+
this.guests = new EventGuestsResource(http);
|
|
18
|
+
this.templates = new EventTemplatesResource(http);
|
|
19
|
+
}
|
|
20
|
+
/** GET /servers/:id/events - upcoming and active events in a server. */
|
|
21
|
+
list(serverId) {
|
|
22
|
+
return this.http.request({
|
|
23
|
+
method: 'GET',
|
|
24
|
+
path: `/servers/${encodeURIComponent(serverId)}/events`,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** POST /servers/:id/events - create a new event. */
|
|
28
|
+
create(serverId, body) {
|
|
29
|
+
return this.http.request({
|
|
30
|
+
method: 'POST',
|
|
31
|
+
path: `/servers/${encodeURIComponent(serverId)}/events`,
|
|
32
|
+
body,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/** GET /servers/:id/events/:eventId - event detail. */
|
|
36
|
+
get(serverId, eventId) {
|
|
37
|
+
return this.http.request({
|
|
38
|
+
method: 'GET',
|
|
39
|
+
path: `/servers/${encodeURIComponent(serverId)}/events/${encodeURIComponent(eventId)}`,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/** PATCH /servers/:id/events/:eventId - update event metadata. */
|
|
43
|
+
update(serverId, eventId, body) {
|
|
44
|
+
return this.http.request({
|
|
45
|
+
method: 'PATCH',
|
|
46
|
+
path: `/servers/${encodeURIComponent(serverId)}/events/${encodeURIComponent(eventId)}`,
|
|
47
|
+
body,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** DELETE /servers/:id/events/:eventId - cancel an event (soft delete). */
|
|
51
|
+
cancel(serverId, eventId) {
|
|
52
|
+
return this.http.request({
|
|
53
|
+
method: 'DELETE',
|
|
54
|
+
path: `/servers/${encodeURIComponent(serverId)}/events/${encodeURIComponent(eventId)}`,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** POST /servers/:id/events/:eventId/rsvp - set the caller's RSVP status. */
|
|
58
|
+
rsvp(serverId, eventId, body) {
|
|
59
|
+
return this.http.request({
|
|
60
|
+
method: 'POST',
|
|
61
|
+
path: `/servers/${encodeURIComponent(serverId)}/events/${encodeURIComponent(eventId)}/rsvp`,
|
|
62
|
+
body,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/** POST /servers/:id/events/:eventId/external/toggle - toggle external (share-link) access. */
|
|
66
|
+
toggleExternalAccess(serverId, eventId) {
|
|
67
|
+
return this.http.request({
|
|
68
|
+
method: 'POST',
|
|
69
|
+
path: `/servers/${encodeURIComponent(serverId)}/events/${encodeURIComponent(eventId)}/external/toggle`,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/resources/events.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;;;;;;GAOG;AACH,MAAM,OAAO,cAAc;IAII;IAHb,MAAM,CAAsB;IAC5B,SAAS,CAAyB;IAElD,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;QAC3C,IAAI,CAAC,MAAM,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,SAAS,GAAG,IAAI,sBAAsB,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED,wEAAwE;IACxE,IAAI,CAAC,QAAgB;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAA6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AAE,YAAY,kBAAkB,CAAC,QAAQ,CAAC,WAAW,kBAAkB,CAAC,OAAO,CAAC,OAAO;YAC3F,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED,+FAA+F;IAC/F,oBAAoB,CAAC,QAAgB,EAAE,OAAe;QACpD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAe;YACrC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,YAAY,kBAAkB,CAAC,QAAQ,CAAC,WAAW,kBAAkB,CAAC,OAAO,CAAC,kBAAkB;SACvG,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { HttpClient } from '../http.js';
|
|
2
|
+
import type { Friend, FriendRequestList, Friendship } from '../types/friend.js';
|
|
3
|
+
/**
|
|
4
|
+
* Friends resource. Friend requests are a one-way handshake initiated by
|
|
5
|
+
* username; once accepted, both sides see the friendship in `list()`.
|
|
6
|
+
*
|
|
7
|
+
* Note: removing a friendship and cancelling a pending outbound request both
|
|
8
|
+
* use `DELETE /friends/:id` - the API distinguishes them internally based on
|
|
9
|
+
* the friendship state.
|
|
10
|
+
*/
|
|
11
|
+
export declare class FriendsResource {
|
|
12
|
+
private readonly http;
|
|
13
|
+
constructor(http: HttpClient);
|
|
14
|
+
/** GET /friends - all accepted friendships. */
|
|
15
|
+
list(): Promise<Friend[]>;
|
|
16
|
+
/** GET /friends/requests - pending requests in both directions. */
|
|
17
|
+
requests(): Promise<FriendRequestList>;
|
|
18
|
+
/** POST /friends/request - send a friend request to a user by username. */
|
|
19
|
+
sendRequest(username: string): Promise<Friendship>;
|
|
20
|
+
/** POST /friends/accept - accept an incoming friend request. */
|
|
21
|
+
accept(requestId: string): Promise<Friendship>;
|
|
22
|
+
/** POST /friends/decline - decline an incoming friend request. */
|
|
23
|
+
decline(requestId: string): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* DELETE /friends/:id - remove a friend OR cancel a pending outbound request.
|
|
26
|
+
* The friendship ID is what `list()` and `requests().outgoing[*].id` return.
|
|
27
|
+
*/
|
|
28
|
+
remove(friendshipId: string): Promise<void>;
|
|
29
|
+
/** POST /friends/block - block another user (creates or updates a friendship row). */
|
|
30
|
+
block(userId: string): Promise<Friendship>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=friends.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"friends.d.ts","sourceRoot":"","sources":["../../src/resources/friends.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EACjB,UAAU,EACX,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;GAOG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,+CAA+C;IAC/C,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIzB,mEAAmE;IACnE,QAAQ,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAItC,2EAA2E;IAC3E,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAQlD,gEAAgE;IAChE,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAQ9C,kEAAkE;IAClE,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQzC;;;OAGG;IACH,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO3C,sFAAsF;IACtF,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAO3C"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Friends resource. Friend requests are a one-way handshake initiated by
|
|
3
|
+
* username; once accepted, both sides see the friendship in `list()`.
|
|
4
|
+
*
|
|
5
|
+
* Note: removing a friendship and cancelling a pending outbound request both
|
|
6
|
+
* use `DELETE /friends/:id` - the API distinguishes them internally based on
|
|
7
|
+
* the friendship state.
|
|
8
|
+
*/
|
|
9
|
+
export class FriendsResource {
|
|
10
|
+
http;
|
|
11
|
+
constructor(http) {
|
|
12
|
+
this.http = http;
|
|
13
|
+
}
|
|
14
|
+
/** GET /friends - all accepted friendships. */
|
|
15
|
+
list() {
|
|
16
|
+
return this.http.request({ method: 'GET', path: '/friends' });
|
|
17
|
+
}
|
|
18
|
+
/** GET /friends/requests - pending requests in both directions. */
|
|
19
|
+
requests() {
|
|
20
|
+
return this.http.request({ method: 'GET', path: '/friends/requests' });
|
|
21
|
+
}
|
|
22
|
+
/** POST /friends/request - send a friend request to a user by username. */
|
|
23
|
+
sendRequest(username) {
|
|
24
|
+
return this.http.request({
|
|
25
|
+
method: 'POST',
|
|
26
|
+
path: '/friends/request',
|
|
27
|
+
body: { username },
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/** POST /friends/accept - accept an incoming friend request. */
|
|
31
|
+
accept(requestId) {
|
|
32
|
+
return this.http.request({
|
|
33
|
+
method: 'POST',
|
|
34
|
+
path: '/friends/accept',
|
|
35
|
+
body: { requestId },
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/** POST /friends/decline - decline an incoming friend request. */
|
|
39
|
+
decline(requestId) {
|
|
40
|
+
return this.http.request({
|
|
41
|
+
method: 'POST',
|
|
42
|
+
path: '/friends/decline',
|
|
43
|
+
body: { requestId },
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* DELETE /friends/:id - remove a friend OR cancel a pending outbound request.
|
|
48
|
+
* The friendship ID is what `list()` and `requests().outgoing[*].id` return.
|
|
49
|
+
*/
|
|
50
|
+
remove(friendshipId) {
|
|
51
|
+
return this.http.request({
|
|
52
|
+
method: 'DELETE',
|
|
53
|
+
path: `/friends/${encodeURIComponent(friendshipId)}`,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/** POST /friends/block - block another user (creates or updates a friendship row). */
|
|
57
|
+
block(userId) {
|
|
58
|
+
return this.http.request({
|
|
59
|
+
method: 'POST',
|
|
60
|
+
path: '/friends/block',
|
|
61
|
+
body: { userId },
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=friends.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"friends.js","sourceRoot":"","sources":["../../src/resources/friends.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,MAAM,OAAO,eAAe;IACG;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,+CAA+C;IAC/C,IAAI;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAW,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,mEAAmE;IACnE,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAoB,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED,2EAA2E;IAC3E,WAAW,CAAC,QAAgB;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAa;YACnC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,EAAE,QAAQ,EAAE;SACnB,CAAC,CAAC;IACL,CAAC;IAED,gEAAgE;IAChE,MAAM,CAAC,SAAiB;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAa;YACnC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,iBAAiB;YACvB,IAAI,EAAE,EAAE,SAAS,EAAE;SACpB,CAAC,CAAC;IACL,CAAC;IAED,kEAAkE;IAClE,OAAO,CAAC,SAAiB;QACvB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO;YAC7B,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,EAAE,SAAS,EAAE;SACpB,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,YAAoB;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO;YAC7B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,YAAY,kBAAkB,CAAC,YAAY,CAAC,EAAE;SACrD,CAAC,CAAC;IACL,CAAC;IAED,sFAAsF;IACtF,KAAK,CAAC,MAAc;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAa;YACnC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,EAAE,MAAM,EAAE;SACjB,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { HttpClient } from '../http.js';
|
|
2
|
+
import type { ImageMetadata, ImagePurpose, ImageStatus } from '../types/image.js';
|
|
3
|
+
/**
|
|
4
|
+
* Acceptable inputs for `images.upload(...)`. The SDK will:
|
|
5
|
+
* - read the file from disk if you pass a string path,
|
|
6
|
+
* - wrap a Buffer / Uint8Array / ArrayBuffer / Blob in FormData,
|
|
7
|
+
* - or use a Blob you constructed yourself.
|
|
8
|
+
*/
|
|
9
|
+
export type ImageInput = string | Buffer | Uint8Array | ArrayBuffer | Blob;
|
|
10
|
+
export interface UploadImageOptions {
|
|
11
|
+
/** What this image will be used for. The API rejects unknown purposes. */
|
|
12
|
+
purpose: ImagePurpose;
|
|
13
|
+
/** Optional alt text. */
|
|
14
|
+
alt?: string;
|
|
15
|
+
/** Optional ID of the entity this image belongs to (e.g. a server ID for an icon). */
|
|
16
|
+
entityId?: string;
|
|
17
|
+
/** File name reported in the multipart part. Auto-derived for paths. */
|
|
18
|
+
filename?: string;
|
|
19
|
+
/** Content-Type. Auto-detected for paths from the extension; defaults to `application/octet-stream`. */
|
|
20
|
+
contentType?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Images resource. Uploads use multipart/form-data; the SDK builds the
|
|
24
|
+
* FormData itself so callers don't have to know the field names.
|
|
25
|
+
*
|
|
26
|
+
* Large GIFs are processed asynchronously into MP4 by the API. Use
|
|
27
|
+
* `status(id)` to poll until `processingStatus === "ready"`.
|
|
28
|
+
*/
|
|
29
|
+
export declare class ImagesResource {
|
|
30
|
+
private readonly http;
|
|
31
|
+
constructor(http: HttpClient);
|
|
32
|
+
/** POST /images - upload an image as multipart form data. */
|
|
33
|
+
upload(input: ImageInput, opts: UploadImageOptions): Promise<ImageMetadata>;
|
|
34
|
+
/** GET /images/:id - fetch image metadata by ID. */
|
|
35
|
+
get(id: string): Promise<ImageMetadata>;
|
|
36
|
+
/** GET /images/:id/status - lightweight status check (for polling GIF -> MP4). */
|
|
37
|
+
status(id: string): Promise<ImageStatus>;
|
|
38
|
+
/** DELETE /images/:id - delete an image you uploaded. */
|
|
39
|
+
delete(id: string): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=images.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../../src/resources/images.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAE3B;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,MAAM,GACN,UAAU,GACV,WAAW,GACX,IAAI,CAAC;AAET,MAAM,WAAW,kBAAkB;IACjC,0EAA0E;IAC1E,OAAO,EAAE,YAAY,CAAC;IACtB,yBAAyB;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sFAAsF;IACtF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wGAAwG;IACxG,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;GAMG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,6DAA6D;IACvD,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC;IAkBjF,oDAAoD;IACpD,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAOvC,kFAAkF;IAClF,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAOxC,yDAAyD;IACzD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAMlC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { basename } from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Images resource. Uploads use multipart/form-data; the SDK builds the
|
|
5
|
+
* FormData itself so callers don't have to know the field names.
|
|
6
|
+
*
|
|
7
|
+
* Large GIFs are processed asynchronously into MP4 by the API. Use
|
|
8
|
+
* `status(id)` to poll until `processingStatus === "ready"`.
|
|
9
|
+
*/
|
|
10
|
+
export class ImagesResource {
|
|
11
|
+
http;
|
|
12
|
+
constructor(http) {
|
|
13
|
+
this.http = http;
|
|
14
|
+
}
|
|
15
|
+
/** POST /images - upload an image as multipart form data. */
|
|
16
|
+
async upload(input, opts) {
|
|
17
|
+
const { blob, filename, contentType } = await coerceToBlob(input, opts);
|
|
18
|
+
const form = new FormData();
|
|
19
|
+
form.set('file', blob, filename);
|
|
20
|
+
form.set('purpose', opts.purpose);
|
|
21
|
+
if (opts.alt !== undefined)
|
|
22
|
+
form.set('alt', opts.alt);
|
|
23
|
+
if (opts.entityId !== undefined)
|
|
24
|
+
form.set('entityId', opts.entityId);
|
|
25
|
+
return this.http.request({
|
|
26
|
+
method: 'POST',
|
|
27
|
+
path: '/images',
|
|
28
|
+
rawBody: form,
|
|
29
|
+
// Important: do NOT set Content-Type ourselves. The runtime will set
|
|
30
|
+
// multipart/form-data with the correct boundary when given a FormData.
|
|
31
|
+
headers: contentType ? {} : {},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/** GET /images/:id - fetch image metadata by ID. */
|
|
35
|
+
get(id) {
|
|
36
|
+
return this.http.request({
|
|
37
|
+
method: 'GET',
|
|
38
|
+
path: `/images/${encodeURIComponent(id)}`,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/** GET /images/:id/status - lightweight status check (for polling GIF -> MP4). */
|
|
42
|
+
status(id) {
|
|
43
|
+
return this.http.request({
|
|
44
|
+
method: 'GET',
|
|
45
|
+
path: `/images/${encodeURIComponent(id)}/status`,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/** DELETE /images/:id - delete an image you uploaded. */
|
|
49
|
+
delete(id) {
|
|
50
|
+
return this.http.request({
|
|
51
|
+
method: 'DELETE',
|
|
52
|
+
path: `/images/${encodeURIComponent(id)}`,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async function coerceToBlob(input, opts) {
|
|
57
|
+
// 1. String path - read from disk and infer name + type from the extension.
|
|
58
|
+
if (typeof input === 'string') {
|
|
59
|
+
const bytes = await readFile(input);
|
|
60
|
+
const filename = opts.filename ?? basename(input);
|
|
61
|
+
const contentType = opts.contentType ?? guessContentTypeFromName(filename);
|
|
62
|
+
// Buffer extends Uint8Array; cast through Uint8Array for Blob compatibility.
|
|
63
|
+
return {
|
|
64
|
+
blob: new Blob([new Uint8Array(bytes)], { type: contentType }),
|
|
65
|
+
filename,
|
|
66
|
+
contentType,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// 2. Already a Blob - reuse it (only override the filename if explicitly given).
|
|
70
|
+
if (input instanceof Blob) {
|
|
71
|
+
const filename = opts.filename ?? 'upload.bin';
|
|
72
|
+
const contentType = opts.contentType ?? input.type ?? 'application/octet-stream';
|
|
73
|
+
return { blob: input, filename, contentType };
|
|
74
|
+
}
|
|
75
|
+
// 3. Raw bytes - wrap in a Blob with whatever metadata the caller provided.
|
|
76
|
+
const filename = opts.filename ?? 'upload.bin';
|
|
77
|
+
const contentType = opts.contentType ?? 'application/octet-stream';
|
|
78
|
+
// Copy into a fresh ArrayBuffer-backed Uint8Array. This sidesteps the
|
|
79
|
+
// SharedArrayBuffer / ArrayBuffer variance issue with BlobPart and ensures
|
|
80
|
+
// a stable, owned buffer for the lifetime of the upload.
|
|
81
|
+
const source = input instanceof Uint8Array ? input : new Uint8Array(input);
|
|
82
|
+
const owned = new Uint8Array(source.byteLength);
|
|
83
|
+
owned.set(source);
|
|
84
|
+
return {
|
|
85
|
+
blob: new Blob([owned], { type: contentType }),
|
|
86
|
+
filename,
|
|
87
|
+
contentType,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function guessContentTypeFromName(name) {
|
|
91
|
+
const lower = name.toLowerCase();
|
|
92
|
+
if (lower.endsWith('.png'))
|
|
93
|
+
return 'image/png';
|
|
94
|
+
if (lower.endsWith('.jpg') || lower.endsWith('.jpeg'))
|
|
95
|
+
return 'image/jpeg';
|
|
96
|
+
if (lower.endsWith('.gif'))
|
|
97
|
+
return 'image/gif';
|
|
98
|
+
if (lower.endsWith('.webp'))
|
|
99
|
+
return 'image/webp';
|
|
100
|
+
if (lower.endsWith('.heic'))
|
|
101
|
+
return 'image/heic';
|
|
102
|
+
if (lower.endsWith('.heif'))
|
|
103
|
+
return 'image/heif';
|
|
104
|
+
return 'application/octet-stream';
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=images.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images.js","sourceRoot":"","sources":["../../src/res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C;AACpC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { HttpClient } from '../http.js';
|
|
2
|
+
import { type CursorParams, type Page, type PaginatedResponse } from '../pagination.js';
|
|
3
|
+
import type { EditRoomMessageBody, RoomMessage, SendRoomMessageBody } from '../types/room.js';
|
|
4
|
+
/**
|
|
5
|
+
* Room messages sub-resource. Walked off `client.servers.rooms.messages`.
|
|
6
|
+
*
|
|
7
|
+
* Pagination is identical to DM messages: ISO timestamp cursor, fetches
|
|
8
|
+
* older-than-cursor, max page size 100.
|
|
9
|
+
*/
|
|
10
|
+
export declare class RoomMessagesResource {
|
|
11
|
+
private readonly http;
|
|
12
|
+
constructor(http: HttpClient);
|
|
13
|
+
/** GET /servers/:serverId/rooms/:roomId/messages - one page. */
|
|
14
|
+
list(serverId: string, roomId: string, params?: CursorParams): Promise<PaginatedResponse<RoomMessage>>;
|
|
15
|
+
/** Iterate every page of room messages with the cursor walked automatically. */
|
|
16
|
+
iter(serverId: string, roomId: string, params?: CursorParams): AsyncGenerator<Page<RoomMessage>, void, void>;
|
|
17
|
+
/** POST /servers/:serverId/rooms/:roomId/messages - send a message. */
|
|
18
|
+
send(serverId: string, roomId: string, body: SendRoomMessageBody): Promise<RoomMessage>;
|
|
19
|
+
/** PATCH /servers/:serverId/rooms/:roomId/messages/:messageId - edit your message. */
|
|
20
|
+
edit(serverId: string, roomId: string, messageId: string, body: EditRoomMessageBody): Promise<RoomMessage>;
|
|
21
|
+
/** DELETE /servers/:serverId/rooms/:roomId/messages/:messageId - delete a message. */
|
|
22
|
+
delete(serverId: string, roomId: string, messageId: string): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=room-messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"room-messages.d.ts","sourceRoot":"","sources":["../../src/resources/room-messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,IAAI,EACT,KAAK,iBAAiB,EACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAE1B;;;;;GAKG;AACH,qBAAa,oBAAoB;IACnB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,gEAAgE;IAChE,IAAI,CACF,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,YAAiB,GACxB,OAAO,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAQ1C,gFAAgF;IAChF,IAAI,CACF,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,YAAiB,GACxB,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC;IAShD,uEAAuE;IACvE,IAAI,CACF,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,WAAW,CAAC;IAQvB,sFAAsF;IACtF,IAAI,CACF,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,WAAW,CAAC;IAQvB,sFAAsF;IACtF,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAM3E"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { paginate, } from '../pagination.js';
|
|
2
|
+
/**
|
|
3
|
+
* Room messages sub-resource. Walked off `client.servers.rooms.messages`.
|
|
4
|
+
*
|
|
5
|
+
* Pagination is identical to DM messages: ISO timestamp cursor, fetches
|
|
6
|
+
* older-than-cursor, max page size 100.
|
|
7
|
+
*/
|
|
8
|
+
export class RoomMessagesResource {
|
|
9
|
+
http;
|
|
10
|
+
constructor(http) {
|
|
11
|
+
this.http = http;
|
|
12
|
+
}
|
|
13
|
+
/** GET /servers/:serverId/rooms/:roomId/messages - one page. */
|
|
14
|
+
list(serverId, roomId, params = {}) {
|
|
15
|
+
return this.http.request({
|
|
16
|
+
method: 'GET',
|
|
17
|
+
path: `/servers/${encodeURIComponent(serverId)}/rooms/${encodeURIComponent(roomId)}/messages`,
|
|
18
|
+
query: { limit: params.limit, cursor: params.cursor },
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/** Iterate every page of room messages with the cursor walked automatically. */
|
|
22
|
+
iter(serverId, roomId, params = {}) {
|
|
23
|
+
return paginate(this.http, `/servers/${encodeURIComponent(serverId)}/rooms/${encodeURIComponent(roomId)}/messages`, params, 'messages');
|
|
24
|
+
}
|
|
25
|
+
/** POST /servers/:serverId/rooms/:roomId/messages - send a message. */
|
|
26
|
+
send(serverId, roomId, body) {
|
|
27
|
+
return this.http.request({
|
|
28
|
+
method: 'POST',
|
|
29
|
+
path: `/servers/${encodeURIComponent(serverId)}/rooms/${encodeURIComponent(roomId)}/messages`,
|
|
30
|
+
body,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** PATCH /servers/:serverId/rooms/:roomId/messages/:messageId - edit your message. */
|
|
34
|
+
edit(serverId, roomId, messageId, body) {
|
|
35
|
+
return this.http.request({
|
|
36
|
+
method: 'PATCH',
|
|
37
|
+
path: `/servers/${encodeURIComponent(serverId)}/rooms/${encodeURIComponent(roomId)}/messages/${encodeURIComponent(messageId)}`,
|
|
38
|
+
body,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/** DELETE /servers/:serverId/rooms/:roomId/messages/:messageId - delete a message. */
|
|
42
|
+
delete(serverId, roomId, messageId) {
|
|
43
|
+
return this.http.request({
|
|
44
|
+
method: 'DELETE',
|
|
45
|
+
path: `/servers/${encodeURIComponent(serverId)}/rooms/${encodeURIComponent(roomId)}/messages/${encodeURIComponent(messageId)}`,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=room-messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"room-messages.js","sourceRoot":"","sources":["../../src/resources/room-messages.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,GAIT,MAAM,kBAAkB,CAAC;AAO1B;;;;;GAKG;AACH,MAAM,OAAO,oBAAoB;IACF;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,gEAAgE;IAChE,IAAI,CACF,QAAgB,EAChB,MAAc,EACd,SAAuB,EAAE;QAEzB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAiC;YACvD,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,YAAY,kBAAkB,CAAC,QAAQ,CAAC,UAAU,kBAAkB,CAAC,MAAM,CAAC,WAAW;YAC7F,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;SACtD,CAAC,CAAC;IACL,CAAC;IAED,gFAAgF;IAChF,IAAI,CACF,QAAgB,EAChB,MAAc,EACd,SAAuB,EAAE;QAEzB,OAAO,QAAQ,CACb,IAAI,CAAC,IAAI,EACT,YAAY,kBAAkB,CAAC,QAAQ,CAAC,UAAU,kBAAkB,CAAC,MAAM,CAAC,WAAW,EACvF,MAAM,EACN,UAAU,CACX,CAAC;IACJ,CAAC;IAED,uEAAuE;IACvE,IAAI,CACF,QAAgB,EAChB,MAAc,EACd,IAAyB;QAEzB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc;YACpC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,YAAY,kBAAkB,CAAC,QAAQ,CAAC,UAAU,kBAAkB,CAAC,MAAM,CAAC,WAAW;YAC7F,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED,sFAAsF;IACtF,IAAI,CACF,QAAgB,EAChB,MAAc,EACd,SAAiB,EACjB,IAAyB;QAEzB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc;YACpC,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,YAAY,kBAAkB,CAAC,QAAQ,CAAC,UAAU,kBAAkB,CAAC,MAAM,CAAC,aAAa,kBAAkB,CAAC,SAAS,CAAC,EAAE;YAC9H,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED,sFAAsF;IACtF,MAAM,CAAC,QAAgB,EAAE,MAAc,EAAE,SAAiB;QACxD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO;YAC7B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,YAAY,kBAAkB,CAAC,QAAQ,CAAC,UAAU,kBAAkB,CAAC,MAAM,CAAC,aAAa,kBAAkB,CAAC,SAAS,CAAC,EAAE;SAC/H,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { HttpClient } from '../http.js';
|
|
2
|
+
import type { CreateRoomBody, Room, UpdateRoomBody } from '../types/room.js';
|
|
3
|
+
import { RoomMessagesResource } from './room-messages.js';
|
|
4
|
+
/**
|
|
5
|
+
* Voice rooms (channels) within a server.
|
|
6
|
+
*
|
|
7
|
+
* Hung off `client.servers.rooms`. The companion `messages` sub-resource
|
|
8
|
+
* gives full access to per-room chat (`client.servers.rooms.messages.send(...)`).
|
|
9
|
+
*
|
|
10
|
+
* Rooms are created/managed via the parent `/servers/:id/rooms*` paths; only
|
|
11
|
+
* server admins/owners can create, rename, or delete them.
|
|
12
|
+
*/
|
|
13
|
+
export declare class RoomsResource {
|
|
14
|
+
private readonly http;
|
|
15
|
+
readonly messages: RoomMessagesResource;
|
|
16
|
+
constructor(http: HttpClient);
|
|
17
|
+
/** POST /servers/:id/rooms - create a new voice room. */
|
|
18
|
+
create(serverId: string, body: CreateRoomBody): Promise<Room>;
|
|
19
|
+
/** PATCH /servers/:id/rooms/:roomId - rename or change capacity. */
|
|
20
|
+
update(serverId: string, roomId: string, body: UpdateRoomBody): Promise<Room>;
|
|
21
|
+
/** DELETE /servers/:id/rooms/:roomId - delete a voice room. */
|
|
22
|
+
delete(serverId: string, roomId: string): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=rooms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rooms.d.ts","sourceRoot":"","sources":["../../src/resources/rooms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;;GAQG;AACH,qBAAa,aAAa;IAGZ,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFjC,SAAgB,QAAQ,EAAE,oBAAoB,CAAC;gBAElB,IAAI,EAAE,UAAU;IAI7C,yDAAyD;IACzD,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ7D,oEAAoE;IACpE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ7E,+DAA+D;IAC/D,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAMxD"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { RoomMessagesResource } from './room-messages.js';
|
|
2
|
+
/**
|
|
3
|
+
* Voice rooms (channels) within a server.
|
|
4
|
+
*
|
|
5
|
+
* Hung off `client.servers.rooms`. The companion `messages` sub-resource
|
|
6
|
+
* gives full access to per-room chat (`client.servers.rooms.messages.send(...)`).
|
|
7
|
+
*
|
|
8
|
+
* Rooms are created/managed via the parent `/servers/:id/rooms*` paths; only
|
|
9
|
+
* server admins/owners can create, rename, or delete them.
|
|
10
|
+
*/
|
|
11
|
+
export class RoomsResource {
|
|
12
|
+
http;
|
|
13
|
+
messages;
|
|
14
|
+
constructor(http) {
|
|
15
|
+
this.http = http;
|
|
16
|
+
this.messages = new RoomMessagesResource(http);
|
|
17
|
+
}
|
|
18
|
+
/** POST /servers/:id/rooms - create a new voice room. */
|
|
19
|
+
create(serverId, body) {
|
|
20
|
+
return this.http.request({
|
|
21
|
+
method: 'POST',
|
|
22
|
+
path: `/servers/${encodeURIComponent(serverId)}/rooms`,
|
|
23
|
+
body,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/** PATCH /servers/:id/rooms/:roomId - rename or change capacity. */
|
|
27
|
+
update(serverId, roomId, body) {
|
|
28
|
+
return this.http.request({
|
|
29
|
+
method: 'PATCH',
|
|
30
|
+
path: `/servers/${encodeURIComponent(serverId)}/rooms/${encodeURIComponent(roomId)}`,
|
|
31
|
+
body,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/** DELETE /servers/:id/rooms/:roomId - delete a voice room. */
|
|
35
|
+
delete(serverId, roomId) {
|
|
36
|
+
return this.http.request({
|
|
37
|
+
method: 'DELETE',
|
|
38
|
+
path: `/servers/${encodeURIComponent(serverId)}/rooms/${encodeURIComponent(roomId)}`,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=rooms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rooms.js","sourceRoot":"","sources":["../../src/resources/rooms.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;;GAQG;AACH,MAAM,OAAO,aAAa;IAGK;IAFb,QAAQ,CAAuB;IAE/C,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;QAC3C,IAAI,CAAC,QAAQ,GAAG,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,yDAAyD;IACzD,MAAM,CAAC,QAAgB,EAAE,IAAoB;QAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO;YAC7B,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,YAAY,kBAAkB,CAAC,QAAQ,CAAC,QAAQ;YACtD,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED,oEAAoE;IACpE,MAAM,CAAC,QAAgB,EAAE,MAAc,EAAE,IAAoB;QAC3D,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO;YAC7B,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,YAAY,kBAAkB,CAAC,QAAQ,CAAC,UAAU,kBAAkB,CAAC,MAAM,CAAC,EAAE;YACpF,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED,+DAA+D;IAC/D,MAAM,CAAC,QAAgB,EAAE,MAAc;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO;YAC7B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,YAAY,kBAAkB,CAAC,QAAQ,CAAC,UAAU,kBAAkB,CAAC,MAAM,CAAC,EAAE;SACrF,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { HttpClient } from '../http.js';
|
|
2
|
+
import type { CreateInviteBody, Server, ServerInvite, ServerInvitePreview } from '../types/server.js';
|
|
3
|
+
/**
|
|
4
|
+
* Server invites sub-resource. Hung off `client.servers.invites` for
|
|
5
|
+
* discoverability. Most methods scope to a single server, except `preview`
|
|
6
|
+
* and `join` which operate purely on an invite code.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ServerInvitesResource {
|
|
9
|
+
private readonly http;
|
|
10
|
+
constructor(http: HttpClient);
|
|
11
|
+
/** GET /servers/:id/invites - list active invites for a server (admin/owner). */
|
|
12
|
+
list(serverId: string): Promise<ServerInvite[]>;
|
|
13
|
+
/** POST /servers/:id/invites - generate a new invite code. */
|
|
14
|
+
create(serverId: string, body?: CreateInviteBody): Promise<ServerInvite>;
|
|
15
|
+
/** DELETE /servers/:id/invites/:inviteId - revoke an invite. */
|
|
16
|
+
revoke(serverId: string, inviteId: string): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* GET /servers/invite/:code - public preview of an invite (no auth needed
|
|
19
|
+
* server-side, but the SDK still sends the bearer token, which is fine).
|
|
20
|
+
*/
|
|
21
|
+
preview(code: string): Promise<ServerInvitePreview>;
|
|
22
|
+
/** POST /servers/join/:code - join a server via an invite code. */
|
|
23
|
+
join(code: string): Promise<Server>;
|
|
24
|
+
/** POST /servers/:id/invite-friend - directly invite a single friend (no code). */
|
|
25
|
+
inviteFriend(serverId: string, userId: string): Promise<{
|
|
26
|
+
sent: boolean;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=server-invites.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-invites.d.ts","sourceRoot":"","sources":["../../src/resources/server-invites.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,gBAAgB,EAChB,MAAM,EACN,YAAY,EACZ,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,qBAAa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,iFAAiF;IACjF,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAO/C,8DAA8D;IAC9D,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,GAAE,gBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC;IAQ5E,gEAAgE;IAChE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOzD;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAOnD,mEAAmE;IACnE,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOnC,mFAAmF;IACnF,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;CAO3E"}
|