@indy-center/indy-larry-worker 1.2.0 → 1.3.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/dist/api.d.ts +118 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -79,6 +79,11 @@ export type RoleSync = {
|
|
|
79
79
|
* Larry never renames a role.
|
|
80
80
|
*/
|
|
81
81
|
rename?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* The colour of a role Larry **creates**, as hex (`'#e67e22'` or `'e67e22'`). Not applied to a role
|
|
84
|
+
* that already exists, so a colour chosen in Discord is never overwritten. Leave it out for no colour.
|
|
85
|
+
*/
|
|
86
|
+
color?: string;
|
|
82
87
|
/** Discord user IDs who should hold the role. Someone not in the server is reported and can be tried again later. */
|
|
83
88
|
members: string[];
|
|
84
89
|
/**
|
|
@@ -194,7 +199,7 @@ export type Sent = {
|
|
|
194
199
|
messageId: string;
|
|
195
200
|
};
|
|
196
201
|
/**
|
|
197
|
-
* Larry's RPC surface, version 1.
|
|
202
|
+
* Larry's RPC surface, version 1.3.0. Every method checks the message first and throws for an unknown
|
|
198
203
|
* channel, a bad user ID, an empty message or one over Discord's limits.
|
|
199
204
|
*/
|
|
200
205
|
export interface LarryRpc extends Rpc.WorkerEntrypointBranded {
|
|
@@ -256,6 +261,118 @@ export interface LarryRpc extends Rpc.WorkerEntrypointBranded {
|
|
|
256
261
|
sendToChannel(request: ChannelIdSend): Promise<Sent>;
|
|
257
262
|
/** Queue a post to a channel by ID, like enqueue(). The channel is checked before it is queued. */
|
|
258
263
|
enqueueToChannel(request: ChannelIdSend): Promise<void>;
|
|
264
|
+
/**
|
|
265
|
+
* Link a member's own Discord account, which the caller has already proven they hold, and queue
|
|
266
|
+
* their role sync. Throws "That Discord account is linked to another member." when someone else has
|
|
267
|
+
* it, and "Sign in to flyindycenter.com once before linking." when identity has no user for the CID.
|
|
268
|
+
*/
|
|
269
|
+
linkDiscord(cid: number, discordId: string): Promise<void>;
|
|
270
|
+
/**
|
|
271
|
+
* Clear a member's link and queue their role sync, which falls back to the Discord ID VATUSA holds.
|
|
272
|
+
* `'teamspeak'` throws "TeamSpeak links aren't available yet." for now.
|
|
273
|
+
*/
|
|
274
|
+
unlink(cid: number, service: 'discord' | 'teamspeak'): Promise<void>;
|
|
275
|
+
/** Which Discord account the role sync uses for a member, and whether it is their link or VATUSA's. */
|
|
276
|
+
getLinks(cid: number): Promise<Links>;
|
|
277
|
+
/**
|
|
278
|
+
* Sync these members now, instead of waiting for the next run: for an app that has just changed
|
|
279
|
+
* something about them (a credential granted, a student assigned). larry reads every group source
|
|
280
|
+
* again, then queues each CID's role sync. Each CID is declined, with a reason to show, when nothing is
|
|
281
|
+
* known to sync or it was synced in the last 2 minutes. At most 100 CIDs a call.
|
|
282
|
+
*/
|
|
283
|
+
syncMembers(cids: number[]): Promise<SyncMembersResult>;
|
|
284
|
+
/**
|
|
285
|
+
* Post a notice in a group's room, mentioning `mention` (CIDs). Each mentioned member's roles are
|
|
286
|
+
* synced first, so someone just added to the group can see the room. `'no-room'` when the group has
|
|
287
|
+
* no room (yet), `'not-live'` when the source's group sync isn't `live`.
|
|
288
|
+
*/
|
|
289
|
+
postToGroup(request: GroupPost): Promise<GroupPostResult>;
|
|
290
|
+
/** What the last cron run did with a source's groups. */
|
|
291
|
+
getGroupStatus(source: string): Promise<GroupStatus>;
|
|
259
292
|
}
|
|
293
|
+
/** One group an app serves: who is in it, and whether it has a private room. */
|
|
294
|
+
export type Group = {
|
|
295
|
+
/** Stable within the source; renaming a key makes a new group. */
|
|
296
|
+
key: string;
|
|
297
|
+
/** The group's name, as people should see it: the Discord role's name. */
|
|
298
|
+
name: string;
|
|
299
|
+
/** VATSIM CIDs, digit strings, no duplicates. The whole truth: anyone else loses the role. */
|
|
300
|
+
members: string[];
|
|
301
|
+
room?: {
|
|
302
|
+
/** The room's name, as people should see it. */
|
|
303
|
+
name: string;
|
|
304
|
+
/** Used instead when two rooms' names collide in Discord. */
|
|
305
|
+
fallbackName: string;
|
|
306
|
+
};
|
|
307
|
+
/** Keep this group exactly as it is: don't manage its members, rename or delete it. */
|
|
308
|
+
hold?: true;
|
|
309
|
+
};
|
|
310
|
+
/** What a group source's `getGroups()` answers. */
|
|
311
|
+
export type GroupsAnswer = {
|
|
312
|
+
groups: Group[];
|
|
313
|
+
};
|
|
314
|
+
/** What an app implements, on the entrypoint larry's binding names, to serve groups. */
|
|
315
|
+
export type GroupSource = {
|
|
316
|
+
getGroups(): Promise<GroupsAnswer>;
|
|
317
|
+
};
|
|
318
|
+
/** A notice for a group's room. Plain text: larry escapes Discord's formatting. */
|
|
319
|
+
export type GroupNotice = {
|
|
320
|
+
title: string;
|
|
321
|
+
body: string;
|
|
322
|
+
fields?: {
|
|
323
|
+
name: string;
|
|
324
|
+
value: string;
|
|
325
|
+
}[];
|
|
326
|
+
};
|
|
327
|
+
export type GroupPost = {
|
|
328
|
+
/** The source's name in larry's config, e.g. `'training'`. */
|
|
329
|
+
source: string;
|
|
330
|
+
/** The group's key in that source. */
|
|
331
|
+
key: string;
|
|
332
|
+
notice: GroupNotice;
|
|
333
|
+
/** CIDs to mention. One with no Discord account is left unmentioned. */
|
|
334
|
+
mention?: string[];
|
|
335
|
+
};
|
|
336
|
+
/** `'posted'` means queued. */
|
|
337
|
+
export type GroupPostResult = 'posted' | 'no-room' | 'not-live';
|
|
338
|
+
/** What happened to a role or room in the last run (or would, in `dry-run`). */
|
|
339
|
+
export type GroupState = 'found' | 'created' | 'renamed' | 'held' | 'missing' | 'deleted' | 'failed';
|
|
340
|
+
export type GroupStatus = {
|
|
341
|
+
mode: 'off' | 'dry-run' | 'live';
|
|
342
|
+
/** When the last run read the source; null before the first. */
|
|
343
|
+
at: string | null;
|
|
344
|
+
/** Why the source's answer was refused that run. */
|
|
345
|
+
refused?: string;
|
|
346
|
+
groups: {
|
|
347
|
+
key: string;
|
|
348
|
+
name: string;
|
|
349
|
+
role: GroupState;
|
|
350
|
+
room?: GroupState;
|
|
351
|
+
error?: string;
|
|
352
|
+
}[];
|
|
353
|
+
};
|
|
354
|
+
/** What `syncMembers` answers, one entry per CID asked for. */
|
|
355
|
+
export type SyncMembersResult = ({
|
|
356
|
+
cid: number;
|
|
357
|
+
} & SyncMemberResult)[];
|
|
358
|
+
/** What `getLinks` reports for a member. */
|
|
359
|
+
export type Links = {
|
|
360
|
+
/** The account the sync uses: `linked` when they linked it, `vatusa` when it is the one VATUSA holds. */
|
|
361
|
+
discord: {
|
|
362
|
+
id: string;
|
|
363
|
+
source: 'linked' | 'vatusa';
|
|
364
|
+
} | null;
|
|
365
|
+
/** Always null until TeamSpeak links arrive. */
|
|
366
|
+
teamspeak: {
|
|
367
|
+
uid: string;
|
|
368
|
+
} | null;
|
|
369
|
+
};
|
|
370
|
+
/** What `syncMembers` answers for one CID. */
|
|
371
|
+
export type SyncMemberResult = {
|
|
372
|
+
queued: true;
|
|
373
|
+
} | {
|
|
374
|
+
queued: false;
|
|
375
|
+
reason: string;
|
|
376
|
+
};
|
|
260
377
|
/** The binding's type in a caller's `Env`: `LARRY: LarryBinding`. */
|
|
261
378
|
export type LarryBinding = Service<LarryRpc>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { AllowedMentions, ChannelEdit, ChannelIdSend, ChannelSend, ChannelSyncResult, ChannelsResult, ChannelsSync, DeleteRequest, DeleteResult, Deletion, DirectSend, LarryBinding, LarryRpc, LinkButton, ManagedChannel, MemberRole, Message, MessageRef, RoleSync, RoleSyncResult, RolesResult, RolesSync, Sent, } from './api';
|
|
1
|
+
export type { AllowedMentions, ChannelEdit, ChannelIdSend, ChannelSend, ChannelSyncResult, ChannelsResult, ChannelsSync, DeleteRequest, DeleteResult, Deletion, DirectSend, Group, GroupNotice, GroupPost, GroupPostResult, GroupsAnswer, GroupSource, GroupState, GroupStatus, LarryBinding, LarryRpc, LinkButton, Links, ManagedChannel, MemberRole, Message, MessageRef, RoleSync, RoleSyncResult, RolesResult, RolesSync, Sent, SyncMemberResult, SyncMembersResult, } from './api';
|