aurival 0.3.0 → 0.4.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/embeds.js ADDED
@@ -0,0 +1,308 @@
1
+ /**
2
+ * Discord-shaped `Embed` and `Button` builders (AMENDMENT-05). Mirrors
3
+ * python's builders field for field; the wire shape and every cap sentence
4
+ * are contractual (`caps.ts`) and must not drift between the two SDKs.
5
+ *
6
+ * Two ways in: a builder chain (`new Embed().addField(...)`), validated as
7
+ * each piece is added, or a plain object literal, accepted anywhere a
8
+ * builder is (the way `mentions` already accepts a raw `{ user }`) and
9
+ * validated to the exact same sentences by `serialiseEmbeds`/
10
+ * `serialiseButtons` before it ever reaches the wire — a plain object is
11
+ * never a bypass.
12
+ *
13
+ * Decoding off the wire (`fromJSON`, used by `embedsFromWire`/
14
+ * `buttonsFromWire` in events.ts) is deliberately tolerant and never
15
+ * throws — the caps are an outbound (client -> server) contract, not an
16
+ * inbound one, and a message already stored by the server is assumed valid.
17
+ */
18
+ import { BUTTON_STYLES, CAP_BAD_BUTTON_STYLE, CAP_BUTTON_ID_TOO_LONG, CAP_DESCRIPTION_TOO_LONG, CAP_DUPLICATE_BUTTON_ID, CAP_IMAGE_URL_NOT_HTTPS, CAP_LABEL_TOO_LONG, CAP_LINK_STYLE_DEFERRED, CAP_TITLE_TOO_LONG, CAP_TOO_MANY_BUTTONS, CAP_TOO_MANY_EMBEDS, CAP_TOO_MANY_FIELDS, MAX_BUTTON_ID_LENGTH, MAX_BUTTONS, MAX_DESCRIPTION_LENGTH, MAX_EMBED_FIELDS, MAX_EMBEDS, MAX_LABEL_RUNES, MAX_TITLE_LENGTH, } from './caps.js';
19
+ function asRecord(value) {
20
+ return typeof value === 'object' && value !== null && !Array.isArray(value)
21
+ ? value
22
+ : null;
23
+ }
24
+ function asOptionalString(value) {
25
+ return typeof value === 'string' ? value : undefined;
26
+ }
27
+ function graphemeLength(text) {
28
+ return [...text].length;
29
+ }
30
+ function requireHttps(url) {
31
+ if (!url.startsWith('https://'))
32
+ throw new Error(CAP_IMAGE_URL_NOT_HTTPS);
33
+ }
34
+ /**
35
+ * `Embed().addField(...)` builder. Every mutation is validated immediately
36
+ * (the cap sentence, thrown as a plain `Error`); `toJSON()` emits the wire
37
+ * shape, omitting absent keys and omitting `fields` when empty.
38
+ */
39
+ export class Embed {
40
+ title;
41
+ description;
42
+ color;
43
+ author;
44
+ thumbnail;
45
+ image;
46
+ fields = [];
47
+ footer;
48
+ timestamp;
49
+ #extra = {};
50
+ constructor(init = {}) {
51
+ if (init.title !== undefined) {
52
+ if (init.title.length > MAX_TITLE_LENGTH)
53
+ throw new Error(CAP_TITLE_TOO_LONG);
54
+ this.title = init.title;
55
+ }
56
+ if (init.description !== undefined) {
57
+ if (init.description.length > MAX_DESCRIPTION_LENGTH) {
58
+ throw new Error(CAP_DESCRIPTION_TOO_LONG);
59
+ }
60
+ this.description = init.description;
61
+ }
62
+ if (init.color !== undefined)
63
+ this.color = init.color;
64
+ }
65
+ /** Refuses the 7th field on ONE embed — the whole-message cap (summed across embeds) is enforced by `serialiseEmbeds`. */
66
+ addField(name, value, inline = false) {
67
+ if (this.fields.length >= MAX_EMBED_FIELDS)
68
+ throw new Error(CAP_TOO_MANY_FIELDS);
69
+ this.fields.push({ name, value, inline });
70
+ return this;
71
+ }
72
+ setAuthor(name, icon) {
73
+ if (icon !== undefined) {
74
+ requireHttps(icon);
75
+ this.author = { name, icon };
76
+ }
77
+ else {
78
+ this.author = { name };
79
+ }
80
+ return this;
81
+ }
82
+ setThumbnail(url) {
83
+ requireHttps(url);
84
+ this.thumbnail = { url };
85
+ return this;
86
+ }
87
+ setImage(url) {
88
+ requireHttps(url);
89
+ this.image = { url };
90
+ return this;
91
+ }
92
+ setFooter(text) {
93
+ this.footer = { text };
94
+ return this;
95
+ }
96
+ /** A `Date` becomes UTC RFC3339 (`Z`); a string is assumed already in that form. */
97
+ setTimestamp(value) {
98
+ this.timestamp = value instanceof Date ? value.toISOString() : value;
99
+ return this;
100
+ }
101
+ toJSON() {
102
+ const out = { ...this.#extra };
103
+ if (this.title !== undefined)
104
+ out['title'] = this.title;
105
+ if (this.description !== undefined)
106
+ out['description'] = this.description;
107
+ if (this.color !== undefined)
108
+ out['color'] = this.color;
109
+ if (this.author !== undefined)
110
+ out['author'] = this.author;
111
+ if (this.thumbnail !== undefined)
112
+ out['thumbnail'] = this.thumbnail;
113
+ if (this.image !== undefined)
114
+ out['image'] = this.image;
115
+ if (this.fields.length > 0)
116
+ out['fields'] = this.fields;
117
+ if (this.footer !== undefined)
118
+ out['footer'] = this.footer;
119
+ if (this.timestamp !== undefined)
120
+ out['timestamp'] = this.timestamp;
121
+ return out;
122
+ }
123
+ /**
124
+ * Tolerant decode — never throws, never validates. Used both for wire
125
+ * messages (already server-validated) and to normalise a plain object
126
+ * literal before `serialiseEmbeds` validates it for real. Unknown
127
+ * top-level keys are preserved so a round trip is lossless.
128
+ */
129
+ static fromJSON(data) {
130
+ const record = asRecord(data) ?? {};
131
+ const { title, description, color, author, thumbnail, image, fields, footer, timestamp, ...rest } = record;
132
+ const embed = new Embed();
133
+ const titleStr = asOptionalString(title);
134
+ if (titleStr !== undefined)
135
+ embed.title = titleStr;
136
+ const descriptionStr = asOptionalString(description);
137
+ if (descriptionStr !== undefined)
138
+ embed.description = descriptionStr;
139
+ const colorStr = asOptionalString(color);
140
+ if (colorStr !== undefined)
141
+ embed.color = colorStr;
142
+ const authorRecord = asRecord(author);
143
+ if (authorRecord) {
144
+ const name = asOptionalString(authorRecord['name']) ?? '';
145
+ const icon = asOptionalString(authorRecord['icon']);
146
+ embed.author = icon !== undefined ? { name, icon } : { name };
147
+ }
148
+ const thumbnailRecord = asRecord(thumbnail);
149
+ const thumbnailUrl = thumbnailRecord ? asOptionalString(thumbnailRecord['url']) : undefined;
150
+ if (thumbnailUrl !== undefined)
151
+ embed.thumbnail = { url: thumbnailUrl };
152
+ const imageRecord = asRecord(image);
153
+ const imageUrl = imageRecord ? asOptionalString(imageRecord['url']) : undefined;
154
+ if (imageUrl !== undefined)
155
+ embed.image = { url: imageUrl };
156
+ const footerRecord = asRecord(footer);
157
+ const footerText = footerRecord ? asOptionalString(footerRecord['text']) : undefined;
158
+ if (footerText !== undefined)
159
+ embed.footer = { text: footerText };
160
+ const timestampStr = asOptionalString(timestamp);
161
+ if (timestampStr !== undefined)
162
+ embed.timestamp = timestampStr;
163
+ if (Array.isArray(fields)) {
164
+ for (const raw of fields) {
165
+ const fieldRecord = asRecord(raw);
166
+ if (!fieldRecord)
167
+ continue;
168
+ embed.fields.push({
169
+ name: asOptionalString(fieldRecord['name']) ?? '',
170
+ value: asOptionalString(fieldRecord['value']) ?? '',
171
+ inline: fieldRecord['inline'] === true,
172
+ });
173
+ }
174
+ }
175
+ embed.#extra = rest;
176
+ return embed;
177
+ }
178
+ }
179
+ /** Every cap `serialiseEmbeds` enforces on one already-decoded `Embed`, whichever path built it. */
180
+ function validateEmbedShape(embed) {
181
+ if (embed.title !== undefined && embed.title.length > MAX_TITLE_LENGTH) {
182
+ throw new Error(CAP_TITLE_TOO_LONG);
183
+ }
184
+ if (embed.description !== undefined && embed.description.length > MAX_DESCRIPTION_LENGTH) {
185
+ throw new Error(CAP_DESCRIPTION_TOO_LONG);
186
+ }
187
+ if (embed.author?.icon !== undefined && !embed.author.icon.startsWith('https://')) {
188
+ throw new Error(CAP_IMAGE_URL_NOT_HTTPS);
189
+ }
190
+ if (embed.thumbnail !== undefined && !embed.thumbnail.url.startsWith('https://')) {
191
+ throw new Error(CAP_IMAGE_URL_NOT_HTTPS);
192
+ }
193
+ if (embed.image !== undefined && !embed.image.url.startsWith('https://')) {
194
+ throw new Error(CAP_IMAGE_URL_NOT_HTTPS);
195
+ }
196
+ if (embed.fields.length > MAX_EMBED_FIELDS)
197
+ throw new Error(CAP_TOO_MANY_FIELDS);
198
+ }
199
+ function slugify(label) {
200
+ const slug = label
201
+ .toLowerCase()
202
+ .replace(/[^a-z0-9]+/g, '-')
203
+ .replace(/^-+|-+$/g, '');
204
+ return slug.length > MAX_BUTTON_ID_LENGTH
205
+ ? slug.slice(0, MAX_BUTTON_ID_LENGTH).replace(/-+$/g, '')
206
+ : slug;
207
+ }
208
+ function validateButtonShape(button) {
209
+ if (graphemeLength(button.label) > MAX_LABEL_RUNES)
210
+ throw new Error(CAP_LABEL_TOO_LONG);
211
+ if (button.id.length > MAX_BUTTON_ID_LENGTH)
212
+ throw new Error(CAP_BUTTON_ID_TOO_LONG);
213
+ if (button.style === 'link')
214
+ throw new Error(CAP_LINK_STYLE_DEFERRED);
215
+ if (!BUTTON_STYLES.includes(button.style)) {
216
+ throw new Error(CAP_BAD_BUTTON_STYLE);
217
+ }
218
+ }
219
+ /** `new Button({ label: 'Pacific' })` — `id` defaults to a slug of `label`, `style` defaults to `'primary'`. */
220
+ export class Button {
221
+ label;
222
+ id;
223
+ style;
224
+ constructor(init) {
225
+ this.label = init.label;
226
+ this.style = init.style ?? 'primary';
227
+ this.id = init.id ?? slugify(init.label);
228
+ validateButtonShape(this);
229
+ }
230
+ toJSON() {
231
+ return { id: this.id, label: this.label, style: this.style };
232
+ }
233
+ /** Tolerant decode — never throws. See `Embed.fromJSON` for why. */
234
+ static fromJSON(data) {
235
+ const record = asRecord(data) ?? {};
236
+ const label = asOptionalString(record['label']) ?? '';
237
+ const id = asOptionalString(record['id']);
238
+ const style = asOptionalString(record['style']);
239
+ const button = Object.create(Button.prototype);
240
+ button.label = label;
241
+ button.style = style ?? 'primary';
242
+ button.id = id ?? slugify(label);
243
+ return button;
244
+ }
245
+ }
246
+ /** `null` for both an absent key and a JSON `null` — a message's `button_used` is never `undefined`. */
247
+ export function buttonUsedFromWire(value) {
248
+ const record = asRecord(value);
249
+ if (!record)
250
+ return null;
251
+ return {
252
+ button: asOptionalString(record['button']) ?? '',
253
+ user: asOptionalString(record['user']) ?? '',
254
+ at: asOptionalString(record['at']) ?? '',
255
+ };
256
+ }
257
+ /** `[]` for both an absent key and a JSON `null` — `Message.embeds` is never `null`/`undefined`. */
258
+ export function embedsFromWire(value) {
259
+ if (!Array.isArray(value))
260
+ return [];
261
+ return value.map((entry) => Embed.fromJSON(entry));
262
+ }
263
+ /** `[]` for both an absent key and a JSON `null` — `Message.buttons` is never `null`/`undefined`. */
264
+ export function buttonsFromWire(value) {
265
+ if (!Array.isArray(value))
266
+ return [];
267
+ return value.map((entry) => Button.fromJSON(entry));
268
+ }
269
+ /**
270
+ * Validates and serialises the `embeds` a caller passed to `send`/`reply`,
271
+ * to shape (a). A plain object literal is decoded (tolerant) then validated
272
+ * exactly as a builder is — never a bypass. `[]` when `embeds` is absent or
273
+ * empty, so the caller omits the key.
274
+ */
275
+ export function serialiseEmbeds(embeds) {
276
+ if (embeds === undefined || embeds.length === 0)
277
+ return [];
278
+ if (embeds.length > MAX_EMBEDS)
279
+ throw new Error(CAP_TOO_MANY_EMBEDS);
280
+ const normalised = embeds.map((entry) => entry instanceof Embed ? entry : Embed.fromJSON(entry));
281
+ for (const embed of normalised)
282
+ validateEmbedShape(embed);
283
+ const totalFields = normalised.reduce((sum, embed) => sum + embed.fields.length, 0);
284
+ if (totalFields > MAX_EMBED_FIELDS)
285
+ throw new Error(CAP_TOO_MANY_FIELDS);
286
+ return normalised.map((embed) => embed.toJSON());
287
+ }
288
+ /**
289
+ * Validates and serialises the `buttons` a caller passed to `send`/`reply`.
290
+ * `[]` when `buttons` is absent or empty, so the caller omits the key.
291
+ */
292
+ export function serialiseButtons(buttons) {
293
+ if (buttons === undefined || buttons.length === 0)
294
+ return [];
295
+ if (buttons.length > MAX_BUTTONS)
296
+ throw new Error(CAP_TOO_MANY_BUTTONS);
297
+ const normalised = buttons.map((entry) => entry instanceof Button ? entry : Button.fromJSON(entry));
298
+ for (const button of normalised)
299
+ validateButtonShape(button);
300
+ const seen = new Set();
301
+ for (const button of normalised) {
302
+ if (seen.has(button.id))
303
+ throw new Error(CAP_DUPLICATE_BUTTON_ID);
304
+ seen.add(button.id);
305
+ }
306
+ return normalised.map((button) => button.toJSON());
307
+ }
308
+ //# sourceMappingURL=embeds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embeds.js","sourceRoot":"","sources":["../src/embeds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,WAAW,EACX,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAEnB,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzE,CAAC,CAAE,KAAiC;QACpC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC;AAED,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC;AAC1B,CAAC;AAED,SAAS,YAAY,CAAC,GAAW;IAC/B,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;AAC5E,CAAC;AA+BD;;;;GAIG;AACH,MAAM,OAAO,KAAK;IAChB,KAAK,CAAU;IACf,WAAW,CAAU;IACrB,KAAK,CAAU;IACf,MAAM,CAAoB;IAC1B,SAAS,CAAuB;IAChC,KAAK,CAAmB;IACxB,MAAM,GAAsB,EAA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AAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;QAChC,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAClE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AACrD,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -132,6 +132,57 @@ export declare class BotPlaygroundOnly extends PermissionDeniedError {
132
132
  /** `message_not_yours` — 403, `edit()`/`delete()` only work on the bot's own messages. */
133
133
  export declare class MessageNotYours extends PermissionDeniedError {
134
134
  }
135
+ /** `too_many_embeds` — a message carries more than `MAX_EMBEDS` embeds. */
136
+ export declare class TooManyEmbeds extends InvalidRequestError {
137
+ }
138
+ /** `too_many_embed_fields` — one embed carries more than `MAX_EMBED_FIELDS` fields. */
139
+ export declare class TooManyEmbedFields extends InvalidRequestError {
140
+ }
141
+ /** `too_many_buttons` — a message carries more than `MAX_BUTTONS` buttons. */
142
+ export declare class TooManyButtons extends InvalidRequestError {
143
+ }
144
+ /** `button_missing_field` — a button is missing a field it needs to be rendered or pressed. */
145
+ export declare class ButtonMissingField extends InvalidRequestError {
146
+ }
147
+ /** `button_id_too_long` — a button id is longer than `MAX_BUTTON_ID_LENGTH`. */
148
+ export declare class ButtonIDTooLong extends InvalidRequestError {
149
+ }
150
+ /** `duplicate_button_id` — two buttons in the same message share an id. Button ids must be unique within a message. */
151
+ export declare class DuplicateButtonID extends InvalidRequestError {
152
+ }
153
+ /** `button_label_too_long` — a button label is longer than `MAX_LABEL_RUNES`. */
154
+ export declare class ButtonLabelTooLong extends InvalidRequestError {
155
+ }
156
+ /** `link_button_not_supported` — link-style buttons are not supported in v1. */
157
+ export declare class LinkButtonNotSupported extends InvalidRequestError {
158
+ }
159
+ /** `invalid_button_style` — a button's style is not one of `BUTTON_STYLES`. */
160
+ export declare class InvalidButtonStyle extends InvalidRequestError {
161
+ }
162
+ /** `embed_title_too_long` — an embed title is longer than `MAX_TITLE_LENGTH`. */
163
+ export declare class EmbedTitleTooLong extends InvalidRequestError {
164
+ }
165
+ /** `embed_description_too_long` — an embed description is longer than `MAX_DESCRIPTION_LENGTH`. */
166
+ export declare class EmbedDescriptionTooLong extends InvalidRequestError {
167
+ }
168
+ /** `embed_url_not_https` — an embed image url does not start with `https://`. */
169
+ export declare class EmbedURLNotHTTPS extends InvalidRequestError {
170
+ }
171
+ /**
172
+ * `embed_empty` — an embed carries none of a title, a description, a field or
173
+ * a footer. A colour on its own is a coloured rectangle, not a message.
174
+ */
175
+ export declare class EmbedEmpty extends InvalidRequestError {
176
+ }
177
+ /** `buttons_without_message` — buttons were sent with nothing under them. Send text, embeds, or both alongside them. */
178
+ export declare class ButtonsWithoutMessage extends InvalidRequestError {
179
+ }
180
+ /**
181
+ * `button_already_used` — a row of actions is spent once a button on it has
182
+ * been pressed; send a new message for another press.
183
+ */
184
+ export declare class ButtonAlreadyUsed extends InvalidRequestError {
185
+ }
135
186
  export declare class RateLimited extends RateLimitError {
136
187
  }
137
188
  export declare class PairRateLimited extends RateLimitError {
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,2CAA2C;AAC3C,qBAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED,4EAA4E;AAC5E,qBAAa,cAAe,SAAQ,YAAY;CAAG;AAEnD,4EAA4E;AAC5E,qBAAa,aAAc,SAAQ,YAAY;CAAG;AAElD,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAA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;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,GAAE,mBAAwB,GAChC,eAAe,CAoBjB"}
package/dist/errors.js CHANGED
@@ -136,6 +136,60 @@ export class BotPlaygroundOnly extends PermissionDeniedError {
136
136
  /** `message_not_yours` — 403, `edit()`/`delete()` only work on the bot's own messages. */
137
137
  export class MessageNotYours extends PermissionDeniedError {
138
138
  }
139
+ // AMENDMENT-05 §2. The card's caps and per-field refusals — every one a 400,
140
+ // and every sentence quotes card.go's CapTemplate* constants (mirrored in
141
+ // caps.ts) so a cap cannot move in the validator without moving here too.
142
+ /** `too_many_embeds` — a message carries more than `MAX_EMBEDS` embeds. */
143
+ export class TooManyEmbeds extends InvalidRequestError {
144
+ }
145
+ /** `too_many_embed_fields` — one embed carries more than `MAX_EMBED_FIELDS` fields. */
146
+ export class TooManyEmbedFields extends InvalidRequestError {
147
+ }
148
+ /** `too_many_buttons` — a message carries more than `MAX_BUTTONS` buttons. */
149
+ export class TooManyButtons extends InvalidRequestError {
150
+ }
151
+ /** `button_missing_field` — a button is missing a field it needs to be rendered or pressed. */
152
+ export class ButtonMissingField extends InvalidRequestError {
153
+ }
154
+ /** `button_id_too_long` — a button id is longer than `MAX_BUTTON_ID_LENGTH`. */
155
+ export class ButtonIDTooLong extends InvalidRequestError {
156
+ }
157
+ /** `duplicate_button_id` — two buttons in the same message share an id. Button ids must be unique within a message. */
158
+ export class DuplicateButtonID extends InvalidRequestError {
159
+ }
160
+ /** `button_label_too_long` — a button label is longer than `MAX_LABEL_RUNES`. */
161
+ export class ButtonLabelTooLong extends InvalidRequestError {
162
+ }
163
+ /** `link_button_not_supported` — link-style buttons are not supported in v1. */
164
+ export class LinkButtonNotSupported extends InvalidRequestError {
165
+ }
166
+ /** `invalid_button_style` — a button's style is not one of `BUTTON_STYLES`. */
167
+ export class InvalidButtonStyle extends InvalidRequestError {
168
+ }
169
+ /** `embed_title_too_long` — an embed title is longer than `MAX_TITLE_LENGTH`. */
170
+ export class EmbedTitleTooLong extends InvalidRequestError {
171
+ }
172
+ /** `embed_description_too_long` — an embed description is longer than `MAX_DESCRIPTION_LENGTH`. */
173
+ export class EmbedDescriptionTooLong extends InvalidRequestError {
174
+ }
175
+ /** `embed_url_not_https` — an embed image url does not start with `https://`. */
176
+ export class EmbedURLNotHTTPS extends InvalidRequestError {
177
+ }
178
+ /**
179
+ * `embed_empty` — an embed carries none of a title, a description, a field or
180
+ * a footer. A colour on its own is a coloured rectangle, not a message.
181
+ */
182
+ export class EmbedEmpty extends InvalidRequestError {
183
+ }
184
+ /** `buttons_without_message` — buttons were sent with nothing under them. Send text, embeds, or both alongside them. */
185
+ export class ButtonsWithoutMessage extends InvalidRequestError {
186
+ }
187
+ /**
188
+ * `button_already_used` — a row of actions is spent once a button on it has
189
+ * been pressed; send a new message for another press.
190
+ */
191
+ export class ButtonAlreadyUsed extends InvalidRequestError {
192
+ }
139
193
  export class RateLimited extends RateLimitError {
140
194
  }
141
195
  export class PairRateLimited extends RateLimitError {
@@ -195,6 +249,21 @@ export const CODE_CLASSES = {
195
249
  mention_not_member: MentionNotMember,
196
250
  mention_token_missing: MentionTokenMissing,
197
251
  message_not_yours: MessageNotYours,
252
+ too_many_embeds: TooManyEmbeds,
253
+ too_many_embed_fields: TooManyEmbedFields,
254
+ too_many_buttons: TooManyButtons,
255
+ button_missing_field: ButtonMissingField,
256
+ button_id_too_long: ButtonIDTooLong,
257
+ duplicate_button_id: DuplicateButtonID,
258
+ button_label_too_long: ButtonLabelTooLong,
259
+ link_button_not_supported: LinkButtonNotSupported,
260
+ invalid_button_style: InvalidButtonStyle,
261
+ embed_title_too_long: EmbedTitleTooLong,
262
+ embed_description_too_long: EmbedDescriptionTooLong,
263
+ embed_url_not_https: EmbedURLNotHTTPS,
264
+ embed_empty: EmbedEmpty,
265
+ buttons_without_message: ButtonsWithoutMessage,
266
+ button_already_used: ButtonAlreadyUsed,
198
267
  };
199
268
  function asString(value) {
200
269
  return typeof value === 'string' ? value : null;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,2CAA2C;AAC3C,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AAED,4EAA4E;AAC5E,MAAM,OAAO,cAAe,SAAQ,YAAY;CAAG;AAEnD,4EAA4E;AAC5E,MAAM,OAAO,aAAc,SAAQ,YAAY;CAAG;AAYlD,2EAA2E;AAC3E,MAAM,OAAO,eAAgB,SAAQ,YAAY;IACtC,IAAI,CAAS;IACb,IAAI,CAAS;IACb,OAAO,CAAS;IAChB,UAAU,CAAgB;IAC1B,WAAW,CAAgB;IAC3B,MAAM,CAAgB;IAE/B,YAAY,IAAyB;QACnC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC;QAC1C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC;QAC5C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC;IACpC,CAAC;CACF;AAED,+EAA+E;AAE/E,4DAA4D;AAC5D,MAAM,OAAO,mBAAoB,SAAQ,eAAe;CAAG;AAE3D,0DAA0D;AAC1D,MAAM,OAAO,mBAAoB,SAAQ,eAAe;CAAG;AAE3D,6CAA6C;AAC7C,MAAM,OAAO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D,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1C,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1C,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC;IAChD,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,cAAc,GAAG,IAAI,CAAC;IACnE,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEhD,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,eAAe,CAAC;IAExE,OAAO,IAAI,GAAG,CAAC;QACb,IAAI;QACJ,IAAI;QACJ,OAAO;QACP,OAAO;QACP,UAAU;QACV,WAAW,EAAE,OAAO,CAAC,UAAU,IAAI,IAAI;QACvC,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,IAAI;KAC/B,CAAC,CAAC;AACL,CAAC"}
package/dist/events.d.ts CHANGED
@@ -10,6 +10,7 @@
10
10
  * holds an `HttpClient` for its actions and nothing else network-shaped —
11
11
  * never the seed, a token, or the `Auth` object (SDK-33).
12
12
  */
13
+ import type { Button, ButtonLike, ButtonUsed, Embed, EmbedLike } from './embeds.js';
13
14
  import type { HttpClient } from './http.js';
14
15
  export interface User {
15
16
  id: string;
@@ -48,6 +49,12 @@ export interface Message {
48
49
  sent_at: string;
49
50
  sender: User | null;
50
51
  reply_to: string | null;
52
+ /** `[]` when the wire omits the key or sends `null` (AMENDMENT-05 §3) — never `null`/`undefined`. */
53
+ embeds: Embed[];
54
+ /** `[]` when the wire omits the key or sends `null` — never `null`/`undefined`. */
55
+ buttons: Button[];
56
+ /** `null` when the wire omits the key, sends `null`, or the message never carried a button. */
57
+ button_used: ButtonUsed | null;
51
58
  }
52
59
  export interface EventInit {
53
60
  id: string;
@@ -87,6 +94,15 @@ export declare function mention(user: User): Mention;
87
94
  export type MentionLike = Mention | User | {
88
95
  user: string;
89
96
  };
97
+ /** What `reply()` takes besides the text: the card to hang on the message. */
98
+ export interface ReplyOptions {
99
+ embeds?: ReadonlyArray<EmbedLike>;
100
+ buttons?: ReadonlyArray<ButtonLike>;
101
+ }
102
+ /** `send()` takes the same, plus who the `@handle` tokens in `text` point at. */
103
+ export interface SendOptions extends ReplyOptions {
104
+ mentions?: MentionLike[];
105
+ }
90
106
  /**
91
107
  * One page of `GET /v1/chats/{chat}/members` (CONTRACT-V1 §4, §5.0.1). No
92
108
  * auto-loading iterator. `MemberPage` is SDK-constructed — decoded from the
@@ -113,8 +129,10 @@ export type MemberEventType = 'member.joined' | 'member.left';
113
129
  export type BotEventType = 'bot.added' | 'bot.removed';
114
130
  /** `reaction.added` — on one of this bot's own messages. There is no `reaction.removed`. */
115
131
  export type ReactionEventType = 'reaction.added';
132
+ /** `button.pressed` — someone pressed a button on one of this bot's own messages (AMENDMENT-05). */
133
+ export type ButtonEventType = 'button.pressed';
116
134
  /** Every event type `bot.on()` names. `command.invoked` goes through `bot.command()`. */
117
- export type EventType = MemberEventType | BotEventType | ReactionEventType;
135
+ export type EventType = MemberEventType | BotEventType | ReactionEventType | ButtonEventType;
118
136
  interface BaseInit {
119
137
  chat: Chat;
120
138
  event: Event;
@@ -142,16 +160,17 @@ export declare class BaseContext {
142
160
  * `HttpClient.request` itself. When the event carried no message id the
143
161
  * `reply_to` field is omitted and the reply floats free.
144
162
  */
145
- reply(text: string): Promise<Message>;
163
+ reply(text: string, options?: ReplyOptions): Promise<Message>;
164
+ reply(options: ReplyOptions): Promise<Message>;
146
165
  /**
147
166
  * Send a message to any chat this bot is in — this one or another.
148
167
  * `mentions` names who `@handle` tokens in `text` point at: pass
149
- * `mention(user)`, a `User`, or `{ user: 'usr_…' }`. Returns the stored
150
- * message.
168
+ * `mention(user)`, a `User`, or `{ user: 'usr_…' }`. `embeds`/`buttons`
169
+ * accept a builder or a plain object literal, validated the same either
170
+ * way. Returns the stored message.
151
171
  */
152
- send(chat: Chat | string, text: string, options?: {
153
- mentions?: MentionLike[];
154
- }): Promise<Message>;
172
+ send(chat: Chat | string, text: string, options?: SendOptions): Promise<Message>;
173
+ send(chat: Chat | string, options: SendOptions): Promise<Message>;
155
174
  /**
156
175
  * Show or clear "is thinking…" in this chat. `POST /v1/chats/{chat}/typing`
157
176
  * with `{"is_typing": bool}`. Command handlers get this automatically
@@ -248,6 +267,33 @@ export declare class ReactionContext extends BaseContext {
248
267
  protected quotes(): string | null;
249
268
  static fromEvent(event: Event, http: HttpClient): ReactionContext;
250
269
  }
270
+ export interface ButtonContextInit extends BaseInit {
271
+ user: User;
272
+ message: Message;
273
+ button: string;
274
+ interaction: string;
275
+ }
276
+ /** `button.pressed`: someone pressed a button on one of this bot's own messages (AMENDMENT-05). */
277
+ export declare class ButtonContext extends BaseContext {
278
+ #private;
279
+ /** Who pressed the button. */
280
+ readonly user: User;
281
+ /** The bot's message the button lives on — id only; the text is not re-sent. `reply()` quotes it. */
282
+ readonly message: Message;
283
+ /** The pressed button's id. */
284
+ readonly button: string;
285
+ /** The interaction id — `ack()` posts to `/v1/interactions/{interaction}/ack`. */
286
+ readonly interaction: string;
287
+ constructor(init: ButtonContextInit);
288
+ protected quotes(): string | null;
289
+ /**
290
+ * Acknowledge the button press — `POST /v1/interactions/{interaction}/ack`,
291
+ * 204 no body. Acking twice is `InteractionAlreadyUsed` (surfaced through
292
+ * the existing code -> class mapping; there is no dedicated class here).
293
+ */
294
+ ack(): Promise<void>;
295
+ static fromEvent(event: Event, http: HttpClient): ButtonContext;
296
+ }
251
297
  export interface EventContextInit extends BaseInit {
252
298
  sender: User | null;
253
299
  user: User | null;
@@ -272,10 +318,10 @@ export declare class EventContext extends BaseContext {
272
318
  static fromEvent(event: Event, http: HttpClient): EventContext;
273
319
  }
274
320
  /** Any context a handler can receive. What `bot.onError()` sees beside the error. */
275
- export type AnyContext = Context | MemberContext | BotContext | ReactionContext | EventContext;
321
+ export type AnyContext = Context | MemberContext | BotContext | ReactionContext | ButtonContext | EventContext;
276
322
  /**
277
323
  * The context class for an event, by its type. `command.invoked` gets
278
- * `Context`; the three named families get theirs; anything else gets
324
+ * `Context`; the four named families get theirs; anything else gets
279
325
  * `EventContext`. The dispatch side of BA-R68 — `bot.ts` calls this and
280
326
  * hands the result to every handler registered for the type.
281
327
  */