@indy-center/indy-larry-worker 1.0.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 ADDED
@@ -0,0 +1,60 @@
1
+ import type { APIEmbed } from 'discord-api-types/v10';
2
+ /** Discord's `allowed_mentions`, with `parse` as plain strings. */
3
+ export type AllowedMentions = {
4
+ /** Kinds of mention in the content that ping. */
5
+ parse?: ('users' | 'roles' | 'everyone')[];
6
+ /** User IDs that may ping (not with `parse: ['users']`). */
7
+ users?: string[];
8
+ /** Role IDs that may ping (not with `parse: ['roles']`). */
9
+ roles?: string[];
10
+ };
11
+ /** A message to send as Larry. At least one of `content` or `embeds` is required. */
12
+ export type Message = {
13
+ /** Up to 2000 characters. Mention a user with `<@userId>`, a role with `<@&roleId>`. */
14
+ content?: string;
15
+ /** Up to 10 embeds, in Discord's embed format. */
16
+ embeds?: APIEmbed[];
17
+ /**
18
+ * Passed to Discord as `allowed_mentions`, unchanged. Leave it out to ping the users mentioned in
19
+ * the content and nobody else; pass e.g. `{ parse: ['users', 'roles'] }` or `{ roles: ['123'] }` to
20
+ * ping more, or `{ parse: [] }` to ping nobody.
21
+ */
22
+ allowedMentions?: AllowedMentions;
23
+ };
24
+ /** A message to a channel. */
25
+ export type ChannelSend = Message & {
26
+ /**
27
+ * A channel name from Larry's `SEND_CHANNELS` setting, e.g. `'events'`. Names, not IDs, so a channel
28
+ * can move without a change to the caller. Any other name is rejected.
29
+ */
30
+ channel: string;
31
+ };
32
+ /** A private message to a user. */
33
+ export type DirectSend = Message & {
34
+ /** The user's Discord ID. They must share a server with Larry and allow DMs from it. */
35
+ userId: string;
36
+ };
37
+ /** Where a message was posted. */
38
+ export type Sent = {
39
+ channelId: string;
40
+ messageId: string;
41
+ };
42
+ /**
43
+ * Larry's RPC surface, version 1.0.0. Every method checks the message first and throws for an unknown
44
+ * channel, a bad user ID, an empty message or one over Discord's limits.
45
+ */
46
+ export interface LarryRpc extends Rpc.WorkerEntrypointBranded {
47
+ /** Post now and return the message. Throws if Discord refuses it (e.g. missing permissions). */
48
+ send(request: ChannelSend): Promise<Sent>;
49
+ /** DM a user now and return the message. Throws if the user can't be messaged. */
50
+ sendDirect(request: DirectSend): Promise<Sent>;
51
+ /**
52
+ * Queue a post and return once it's queued. Delivery retries rate limits and Discord outages;
53
+ * a message Discord refuses is logged and dropped.
54
+ */
55
+ enqueue(request: ChannelSend): Promise<void>;
56
+ /** Queue a DM, like enqueue(). */
57
+ enqueueDirect(request: DirectSend): Promise<void>;
58
+ }
59
+ /** The binding's type in a caller's `Env`: `LARRY: LarryBinding`. */
60
+ export type LarryBinding = Service<LarryRpc>;
package/dist/api.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export type { AllowedMentions, ChannelSend, DirectSend, LarryBinding, LarryRpc, Message, Sent } from './api';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@indy-center/indy-larry-worker",
3
+ "version": "1.0.0",
4
+ "description": "Send Discord messages as Larry from other Indy Center Workers, over RPC or a queue",
5
+ "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Indy-Center/indy-larry.git",
9
+ "directory": "worker"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.js"
21
+ }
22
+ },
23
+ "scripts": {
24
+ "dev": "wrangler dev",
25
+ "deploy": "wrangler deploy",
26
+ "typecheck": "tsc --noEmit",
27
+ "test": "vitest run",
28
+ "build:lib": "tsc -p tsconfig.lib.json",
29
+ "prepublishOnly": "npm run build:lib"
30
+ },
31
+ "dependencies": {
32
+ "discord-api-types": "^0.38.56"
33
+ },
34
+ "devDependencies": {
35
+ "@cloudflare/workers-types": "^5.20260930.2",
36
+ "typescript": "^7.0.2",
37
+ "vitest": "^5.0.3",
38
+ "wrangler": "^4.145.0"
39
+ }
40
+ }