@vercel/board 0.39.0 → 0.40.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/README.md +5 -3
- package/dist/{access-CVkjSfxj.mjs → access-Bl_k_Hpa.mjs} +1 -1
- package/dist/access.d.mts +2 -2
- package/dist/access.mjs +4 -4
- package/dist/{actors-kfMejhaw.mjs → actors-yBRWTpt5.mjs} +38 -53
- package/dist/{auth-B3bBYOqf.mjs → auth-C8URZHLx.mjs} +2 -2
- package/dist/{auth-BXLCkeB0.d.mts → auth-DtmZzlHm.d.mts} +5 -2
- package/dist/{backend-HcCCGPG4.d.mts → backend-BW5NbBsp.d.mts} +36 -10
- package/dist/backend-local.d.mts +1 -1
- package/dist/backend-local.mjs +1 -1
- package/dist/blocks-CVoBC7ur.mjs +402 -0
- package/dist/blocks-DGvh2alZ.d.mts +33 -0
- package/dist/{chat-provider-DyNy5xdC.d.mts → chat-provider-Bbb9JguG.d.mts} +2 -2
- package/dist/cli-commands.d.mts +1 -1
- package/dist/cli-commands.mjs +1 -1
- package/dist/cli-embedded.d.mts +2 -2
- package/dist/cli-embedded.mjs +3 -3
- package/dist/cli.mjs +5 -5
- package/dist/{commands-B5d-lmNN.d.mts → commands-BJLocuXj.d.mts} +10 -0
- package/dist/{commands-BLS7erNu.mjs → commands-D6VWegVY.mjs} +88 -8
- package/dist/{conformance-D59Py2m2.mjs → conformance-BWhZ0k8T.mjs} +252 -5
- package/dist/conformance.d.mts +4 -3
- package/dist/conformance.mjs +1 -1
- package/dist/data-values-C-Cq80hz.mjs +176 -0
- package/dist/digest-D32GV_mX.mjs +4 -0
- package/dist/{engine-eUgO5jTM.mjs → engine-Djif8XVk.mjs} +191 -77
- package/dist/{errors-rYDxZEuN.mjs → errors-CNRJqUuL.mjs} +16 -14
- package/dist/{exports-M5o4PTfO.mjs → exports-C2OWIbLU.mjs} +621 -245
- package/dist/exports-FyRBIAMs.d.mts +4 -0
- package/dist/{index-rNqqgkyu.d.mts → index-Cuxbz_E0.d.mts} +2 -2
- package/dist/index.d.mts +7 -6
- package/dist/index.mjs +6 -5
- package/dist/index.node.d.mts +7 -6
- package/dist/index.node.mjs +5 -4
- package/dist/inspect/app.js +110 -109
- package/dist/inspect/engine.js +5 -5
- package/dist/inspect-CLy6FrOZ.mjs +2 -0
- package/dist/{inspect-BkXxR2uB.mjs → inspect-cGcP8ZO9.mjs} +4 -4
- package/dist/{local-DvkOWf4U.mjs → local-CsleYuyM.mjs} +373 -177
- package/dist/{main-DtV_Po9i.mjs → main-D97xuqWZ.mjs} +177 -59
- package/dist/{memory-DkoqhxIH.mjs → memory-BvVoglGv.mjs} +2 -2
- package/dist/{mentions-CB6ShY4R.mjs → mentions-CT2bN5eP.mjs} +17 -3
- package/dist/{middleware-CPqAuRtp.mjs → middleware-BF9vnPPS.mjs} +70 -2
- package/dist/{targets-C1mT3M1N.mjs → origin-DLCmrwmE.mjs} +47 -39
- package/dist/{page-64IwoGRu.mjs → page-6BTCZWGY.mjs} +2 -2
- package/dist/page-BnY8FhPn.mjs +2 -0
- package/dist/{provider-D5yVFisj.d.mts → provider-YqkF1E2k.d.mts} +23 -13
- package/dist/{routes-BffuaoTX.d.mts → routes-CAjd5ARa.d.mts} +101 -25
- package/dist/schemas.d.mts +37 -0
- package/dist/schemas.mjs +3 -0
- package/dist/{serve-CX1rqDF_.mjs → serve-Cs-e0Jke.mjs} +4 -4
- package/dist/{server-DkYkyarg.mjs → server-CIfMdIt3.mjs} +6 -6
- package/dist/{serving-DJMcG0dT.mjs → serving-B4l0nLng.mjs} +1 -1
- package/dist/{sql-l3ysn4O5.mjs → sql-Bv-RQu8n.mjs} +73 -10
- package/dist/{sqlite-CAwNHbQD.mjs → sqlite-D4mkYihG.mjs} +2 -2
- package/dist/{sqlite-db-cm5yhrD-.mjs → sqlite-db-BraLvHtf.mjs} +1 -1
- package/dist/sync-chat-sdk.d.mts +2 -2
- package/dist/sync-github.d.mts +2 -2
- package/dist/sync-linear.d.mts +3 -3
- package/dist/sync-slack.d.mts +14 -8
- package/dist/sync-slack.mjs +42 -15
- package/dist/sync.d.mts +2 -2
- package/dist/{tokens-DA9ipsZ-.mjs → tokens-CrrXAVGz.mjs} +2 -2
- package/docs/01-board/01-mounting.md +5 -3
- package/docs/01-board/03-identity.md +70 -38
- package/docs/01-board/04-messages.md +58 -1
- package/docs/01-board/05-reading.md +3 -3
- package/docs/01-board/06-watchers.md +2 -3
- package/docs/01-board/07-schedules.md +2 -4
- package/docs/01-board/08-middleware.md +1 -1
- package/docs/01-board/09-access.md +24 -21
- package/docs/02-sync/01-overview.md +70 -2
- package/docs/02-sync/02-functions.md +11 -6
- package/docs/02-sync/03-slack.md +40 -16
- package/docs/02-sync/06-providers.md +9 -4
- package/docs/04-reference/01-cli.md +110 -18
- package/docs/04-reference/02-board.md +63 -10
- package/docs/04-reference/03-http.md +154 -28
- package/docs/04-reference/05-conformance.md +13 -6
- package/docs/index.md +1 -1
- package/package.json +5 -1
- package/dist/digest-krhjNAt4.mjs +0 -4
- package/dist/exports-vLQ2Y2Nd.d.mts +0 -4
- package/dist/inspect-lnv1sLXM.mjs +0 -2
- package/dist/page-BUj8_UZv.mjs +0 -2
|
@@ -2,6 +2,7 @@ import { _ as actorKind } from "./schemas-AZkxk06N.mjs";
|
|
|
2
2
|
import { c as externalMessageKey, l as isThreadTarget } from "./external-CHDxWIVf.mjs";
|
|
3
3
|
import { t as canonicalEmoji } from "./emoji-CTLpvH-A.mjs";
|
|
4
4
|
import { n as setOwn, t as own } from "./own-OwgPWdmh.mjs";
|
|
5
|
+
import { i as mentionTerms } from "./mentions-CT2bN5eP.mjs";
|
|
5
6
|
//#region src/contract/folds.ts
|
|
6
7
|
const iso = (date) => typeof date === "string" ? date : date.toISOString();
|
|
7
8
|
function foldMessages(state, event) {
|
|
@@ -24,7 +25,6 @@ function foldMessage(state, event) {
|
|
|
24
25
|
thread: payload.thread,
|
|
25
26
|
labels: { ...payload.labels },
|
|
26
27
|
reactions: {},
|
|
27
|
-
mentions: payload.mentions,
|
|
28
28
|
by: payload.by,
|
|
29
29
|
noSync: payload.noSync,
|
|
30
30
|
origin: payload.origin,
|
|
@@ -46,8 +46,9 @@ function foldMessage(state, event) {
|
|
|
46
46
|
const message = state.byId[event.payload.id];
|
|
47
47
|
if (!message || message.deleted) return void 0;
|
|
48
48
|
message.text = event.payload.text;
|
|
49
|
-
message.mentions = event.payload.mentions;
|
|
50
49
|
message.editedAt = iso(event.createdAt);
|
|
50
|
+
if (message.from === null && event.payload.from !== null) message.platformText = true;
|
|
51
|
+
else delete message.platformText;
|
|
51
52
|
return message;
|
|
52
53
|
}
|
|
53
54
|
case "message.deleted": {
|
|
@@ -57,7 +58,6 @@ function foldMessage(state, event) {
|
|
|
57
58
|
message.text = "";
|
|
58
59
|
message.reactions = {};
|
|
59
60
|
message.labels = {};
|
|
60
|
-
message.mentions = [];
|
|
61
61
|
message.attachments = [];
|
|
62
62
|
message.links = [];
|
|
63
63
|
return message;
|
|
@@ -115,7 +115,7 @@ function foldMessage(state, event) {
|
|
|
115
115
|
/** Who's who: `actor.seen`. */
|
|
116
116
|
function foldActors(state, event) {
|
|
117
117
|
if (event.type !== "actor.seen") return state;
|
|
118
|
-
const { actor, kind, handle, name, avatar, host } = event.payload;
|
|
118
|
+
const { actor, kind, handle, name, avatar, via, platform, host, verified } = event.payload;
|
|
119
119
|
const previous = own(state.byId, actor);
|
|
120
120
|
if (previous) {
|
|
121
121
|
const key = previous.handle.toLowerCase();
|
|
@@ -129,7 +129,10 @@ function foldActors(state, event) {
|
|
|
129
129
|
handle,
|
|
130
130
|
name,
|
|
131
131
|
avatar,
|
|
132
|
-
...
|
|
132
|
+
...via ? { via: { ...via } } : {},
|
|
133
|
+
...platform ? { platform } : {},
|
|
134
|
+
...host || previous?.host ? { host: true } : {},
|
|
135
|
+
...verified ? { verified: true } : {}
|
|
133
136
|
});
|
|
134
137
|
const key = handle.toLowerCase();
|
|
135
138
|
const ids = own(state.byHandle, key) ?? setOwn(state.byHandle, key, []);
|
|
@@ -214,7 +217,7 @@ function concernedMessageId(event) {
|
|
|
214
217
|
}
|
|
215
218
|
const termsOf = (message) => JSON.stringify([
|
|
216
219
|
message.labels,
|
|
217
|
-
message.
|
|
220
|
+
mentionTerms(message.text),
|
|
218
221
|
message.attachments.map((file) => file.id)
|
|
219
222
|
]);
|
|
220
223
|
/**
|
|
@@ -384,9 +387,12 @@ function ddl() {
|
|
|
384
387
|
key text primary key,
|
|
385
388
|
message_id integer not null
|
|
386
389
|
)`,
|
|
387
|
-
"drop index if exists board_messages_recent"
|
|
390
|
+
"drop index if exists board_messages_recent",
|
|
391
|
+
"create table if not exists board_meta (\n key text primary key,\n value text not null\n)"
|
|
388
392
|
];
|
|
389
393
|
}
|
|
394
|
+
/** `board_meta`'s key for the mention index taken from each message's text. */
|
|
395
|
+
const MENTION_TERMS = "mention_terms";
|
|
390
396
|
/**
|
|
391
397
|
* The board refuses NUL in text and a lone surrogate, and a log from before
|
|
392
398
|
* that may hold them. Nothing a reader filters on needs either, so keys and
|
|
@@ -394,7 +400,10 @@ function ddl() {
|
|
|
394
400
|
* that find them do the same.
|
|
395
401
|
*/
|
|
396
402
|
const clean = (value) => value.replaceAll("\0", "").toWellFormed();
|
|
397
|
-
/**
|
|
403
|
+
/**
|
|
404
|
+
* A mention's term, each one as the text has it (`mentionTerms`). Label keys start with a letter or
|
|
405
|
+
* digit, so it's never a label's.
|
|
406
|
+
*/
|
|
398
407
|
const MENTION = "@";
|
|
399
408
|
/** An attachment's term, the same way. */
|
|
400
409
|
const ATTACHMENT = "^";
|
|
@@ -432,7 +441,14 @@ function clauses(filter, p) {
|
|
|
432
441
|
const either = [...actors.length ? [`m.by_actor in (${p.list(actors)})`] : [], ...principals.length ? [`m.by_principal in (${p.list(principals)})`] : []];
|
|
433
442
|
out.push(either.length ? `(${either.join(" or ")})` : "1 = 0");
|
|
434
443
|
}
|
|
435
|
-
if (filter.mentions)
|
|
444
|
+
if (filter.mentions) {
|
|
445
|
+
const { terms, prefixes } = filter.mentions;
|
|
446
|
+
const either = [...terms.length ? [`t.value in (${p.list(terms)})`] : [], ...prefixes.map((prefix) => {
|
|
447
|
+
const at = `cast(${p.add(prefix)} as text)`;
|
|
448
|
+
return `substr(t.value, 1, length(${at})) = ${at}`;
|
|
449
|
+
})];
|
|
450
|
+
out.push(either.length ? `exists (select 1 from board_terms t where t.message_id = m.id and t.term = '${MENTION}' and (${either.join(" or ")}))` : "1 = 0");
|
|
451
|
+
}
|
|
436
452
|
if (filter.from !== void 0) out.push(`coalesce(m.from_key, 'board') = ${p.add(filter.from)}`);
|
|
437
453
|
if (filter.text !== void 0) out.push(`m.text_lower like ${p.add(`%${likeEscape(filter.text)}%`)} escape '\\'`);
|
|
438
454
|
for (const label of filter.labels ?? []) {
|
|
@@ -444,6 +460,51 @@ function clauses(filter, p) {
|
|
|
444
460
|
const parse = (row) => row === void 0 || row.data === null || row.data === void 0 ? null : JSON.parse(String(row.data));
|
|
445
461
|
/** The tables on a SQL database. */
|
|
446
462
|
function sqlTables(db) {
|
|
463
|
+
/**
|
|
464
|
+
* Tables from before mentions were text index a message's mentions as the actor IDs its write
|
|
465
|
+
* resolved them to. Once per database, each message whose text has an `@` gets the terms its
|
|
466
|
+
* text has instead, unless a writer changed its text in between, which reindexed it already.
|
|
467
|
+
* A read that filters on mentions waits for it.
|
|
468
|
+
*/
|
|
469
|
+
async function reindexMentions() {
|
|
470
|
+
if ((await db.all({
|
|
471
|
+
text: "select 1 from board_meta where key = $1",
|
|
472
|
+
values: [MENTION_TERMS]
|
|
473
|
+
})).length > 0) return;
|
|
474
|
+
const rows = await db.all({
|
|
475
|
+
text: "select id, data from board_messages where text_lower like '%@%'",
|
|
476
|
+
values: []
|
|
477
|
+
});
|
|
478
|
+
const writes = [];
|
|
479
|
+
for (const row of rows) {
|
|
480
|
+
const message = parse(row);
|
|
481
|
+
const unchanged = "json_extract((select data from board_messages where id = $1), '$.text') = $2";
|
|
482
|
+
writes.push({
|
|
483
|
+
text: `delete from board_terms where message_id = $1 and term = '${MENTION}' and ${unchanged}`,
|
|
484
|
+
values: [message.id, message.text]
|
|
485
|
+
});
|
|
486
|
+
for (const term of mentionTerms(message.text)) writes.push({
|
|
487
|
+
text: `insert or ignore into board_terms (message_id, term, value) select $1, '${MENTION}', $3 where ${unchanged}`,
|
|
488
|
+
values: [
|
|
489
|
+
message.id,
|
|
490
|
+
message.text,
|
|
491
|
+
clean(term)
|
|
492
|
+
]
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
await db.commit({
|
|
496
|
+
text: "insert into board_meta (key, value) values ($1, 'text') on conflict (key) do nothing returning 1 as claimed",
|
|
497
|
+
values: [MENTION_TERMS]
|
|
498
|
+
}, writes);
|
|
499
|
+
}
|
|
500
|
+
let reindexed = null;
|
|
501
|
+
const mentionsReady = () => {
|
|
502
|
+
reindexed ??= reindexMentions().catch((error) => {
|
|
503
|
+
reindexed = null;
|
|
504
|
+
throw error;
|
|
505
|
+
});
|
|
506
|
+
return reindexed;
|
|
507
|
+
};
|
|
447
508
|
const positionSql = {
|
|
448
509
|
text: "select log_index from board_positions where consumer = $1",
|
|
449
510
|
values: [TABLES_CONSUMER]
|
|
@@ -555,7 +616,7 @@ function sqlTables(db) {
|
|
|
555
616
|
},
|
|
556
617
|
terms: m && change.message.terms ? [
|
|
557
618
|
...Object.entries(m.labels).map(([key, value]) => [key, clean(value)]),
|
|
558
|
-
...
|
|
619
|
+
...mentionTerms(m.text).map((term) => [MENTION, clean(term)]),
|
|
559
620
|
...[...new Set(m.attachments.map((file) => file.id))].map((id) => [ATTACHMENT, clean(id)])
|
|
560
621
|
] : null,
|
|
561
622
|
summary: change.summary ?? null,
|
|
@@ -715,6 +776,7 @@ where v.message_id in (${p.list([...new Set(ids)])})
|
|
|
715
776
|
})).map((found) => parse(found));
|
|
716
777
|
},
|
|
717
778
|
async messages(filter, page) {
|
|
779
|
+
if (filter.mentions) await mentionsReady();
|
|
718
780
|
const p = new Params();
|
|
719
781
|
const where = clauses(filter, p);
|
|
720
782
|
if (page.before !== void 0) where.push(`m.id < ${p.add(page.before)}`);
|
|
@@ -732,6 +794,7 @@ where v.message_id in (${p.list([...new Set(ids)])})
|
|
|
732
794
|
};
|
|
733
795
|
},
|
|
734
796
|
async threads(filter, page) {
|
|
797
|
+
if (filter.mentions) await mentionsReady();
|
|
735
798
|
const [positions, rows] = await db.read([positionSql, threadsQuery(filter, page)]);
|
|
736
799
|
const threads = rows.map((found) => ({
|
|
737
800
|
root: parse(found),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as sqlTables } from "./sql-
|
|
1
|
+
import { r as sqlTables } from "./sql-Bv-RQu8n.mjs";
|
|
2
2
|
import { t as sqlite$1 } from "./store-sqlite-D6fIszST.mjs";
|
|
3
|
-
import { t as sqliteDb } from "./sqlite-db-
|
|
3
|
+
import { t as sqliteDb } from "./sqlite-db-BraLvHtf.mjs";
|
|
4
4
|
//#region src/store/sqlite.ts
|
|
5
5
|
/**
|
|
6
6
|
* A local board in one SQLite file, its log and board's tables side by side. It
|
package/dist/sync-chat-sdk.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as ChatTransport, t as ChatInput } from "./chat-provider-
|
|
1
|
+
import { _ as SyncFn, m as SyncProvider, x as channels } from "./provider-YqkF1E2k.mjs";
|
|
2
|
+
import { r as ChatTransport, t as ChatInput } from "./chat-provider-Bbb9JguG.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { ReactionEvent } from "chat";
|
|
5
5
|
//#region src/sync/chat-sdk.d.ts
|
package/dist/sync-github.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as ChatSyncProvider } from "./chat-provider-
|
|
1
|
+
import { _ as SyncFn, b as SyncUnit, p as SyncContext } from "./provider-YqkF1E2k.mjs";
|
|
2
|
+
import { n as ChatSyncProvider } from "./chat-provider-Bbb9JguG.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { Adapter } from "chat";
|
|
5
5
|
//#region src/sync/github.d.ts
|
package/dist/sync-linear.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-
|
|
1
|
+
import { dt as SourceRead } from "./routes-CAjd5ARa.mjs";
|
|
2
|
+
import { _ as SyncFn, b as SyncUnit, f as ResolvedTarget, l as ReceivedEvent, o as ProviderPost, p as SyncContext, r as ProviderDelivery } from "./provider-YqkF1E2k.mjs";
|
|
3
|
+
import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-Bbb9JguG.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { Adapter } from "chat";
|
|
6
6
|
//#region src/sync/linear.d.ts
|
package/dist/sync-slack.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-
|
|
1
|
+
import { fn as ExternalLink } from "./routes-CAjd5ARa.mjs";
|
|
2
|
+
import { _ as SyncFn, f as ResolvedTarget, o as ProviderPost, p as SyncContext, r as ProviderDelivery, s as ProviderSender, x as channels } from "./provider-YqkF1E2k.mjs";
|
|
3
|
+
import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-Bbb9JguG.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { Adapter } from "chat";
|
|
6
6
|
//#region src/sync/slack.d.ts
|
|
@@ -128,6 +128,11 @@ type SlackPost = {
|
|
|
128
128
|
unfurl_links?: boolean;
|
|
129
129
|
unfurl_media?: boolean;
|
|
130
130
|
};
|
|
131
|
+
/**
|
|
132
|
+
* A sender's name as Slack shows it, at most 80 characters: a long name is cut, never whose word it
|
|
133
|
+
* is. Null when that alone doesn't fit, for the message to go as the app with its label.
|
|
134
|
+
*/
|
|
135
|
+
export declare function slackUsername({ name, attribution }: Pick<ProviderSender, 'name' | 'attribution'>): string | null;
|
|
131
136
|
/** The `**name**: ` a message's text opens with, taken out when Slack shows the name as the sender. */
|
|
132
137
|
export declare function withoutLabel(markdown: string, name: string): string;
|
|
133
138
|
/** GitHub's markdown allows inline HTML, which Slack shows as raw tags: as markdown instead, outside code. */
|
|
@@ -368,9 +373,10 @@ export declare class SlackProvider extends ChatSyncProvider<SlackEvent> {
|
|
|
368
373
|
private scopes;
|
|
369
374
|
constructor(given: SlackOptions, sync: SyncFn<SlackEvent>);
|
|
370
375
|
/**
|
|
371
|
-
*
|
|
372
|
-
* picture when it has one Slack can show, instead of the
|
|
373
|
-
* `**name**: ` label dropped. Without `chat:write.customize` it posts as
|
|
376
|
+
* A message goes out under its author's name (`Julián Benegas`, `clever-lemur via vboard-factory`,
|
|
377
|
+
* `Malte via support (slack)`), and their picture when it has one Slack can show, instead of the
|
|
378
|
+
* app's, with the text's `**name**: ` label dropped. Without `chat:write.customize` it posts as
|
|
379
|
+
* the app, label and all.
|
|
374
380
|
*/
|
|
375
381
|
post(target: string, kind: ResolvedTarget['kind'], body: ProviderPost): Promise<ProviderDelivery>;
|
|
376
382
|
/**
|
|
@@ -381,14 +387,14 @@ export declare class SlackProvider extends ChatSyncProvider<SlackEvent> {
|
|
|
381
387
|
* (`files:read`) to find that message.
|
|
382
388
|
*/
|
|
383
389
|
private postWithFiles;
|
|
384
|
-
/** An edit keeps the label out only where the message went out under
|
|
390
|
+
/** An edit keeps the label out only where the message went out under its author's name. */
|
|
385
391
|
edit(thread: string, message: string, body: ProviderPost): Promise<void>;
|
|
386
392
|
private postNamed;
|
|
387
393
|
/** Whether the app may set a message's username and icon (`chat:write.customize`). */
|
|
388
394
|
private canCustomize;
|
|
389
395
|
/** Whether the app has a scope, from its scopes, asked once. */
|
|
390
396
|
private hasScope;
|
|
391
|
-
/** Whether a message Slack has went out under
|
|
397
|
+
/** Whether a message Slack has went out under the sender's name. */
|
|
392
398
|
private sentAs;
|
|
393
399
|
/**
|
|
394
400
|
* Slack's link to the event's message, from `chat.getPermalink`, so it has the workspace's
|
package/dist/sync-slack.mjs
CHANGED
|
@@ -7,6 +7,23 @@ import { stringifyMarkdown } from "chat";
|
|
|
7
7
|
import { createSlackAdapter } from "@chat-adapter/slack";
|
|
8
8
|
import { connectSlackAdapter } from "@vercel/connect/chat";
|
|
9
9
|
//#region src/sync/slack.ts
|
|
10
|
+
/** The most characters Slack shows of a message's username. */
|
|
11
|
+
const USERNAME_MAX = 80;
|
|
12
|
+
/**
|
|
13
|
+
* A sender's name as Slack shows it, at most 80 characters: a long name is cut, never whose word it
|
|
14
|
+
* is. Null when that alone doesn't fit, for the message to go as the app with its label.
|
|
15
|
+
*/
|
|
16
|
+
function slackUsername({ name, attribution = "" }) {
|
|
17
|
+
if (Array.from(name).length <= USERNAME_MAX) return name;
|
|
18
|
+
const room = USERNAME_MAX - Array.from(attribution).length - 1;
|
|
19
|
+
if (room < 1) return null;
|
|
20
|
+
let cut = "";
|
|
21
|
+
for (const { segment } of new Intl.Segmenter().segment(name.slice(0, name.length - attribution.length))) {
|
|
22
|
+
if (Array.from(cut + segment).length > room) break;
|
|
23
|
+
cut += segment;
|
|
24
|
+
}
|
|
25
|
+
return `${cut.trimEnd()}…${attribution}`;
|
|
26
|
+
}
|
|
10
27
|
/** The `**name**: ` a message's text opens with, taken out when Slack shows the name as the sender. */
|
|
11
28
|
function withoutLabel(markdown, name) {
|
|
12
29
|
const label = new RegExp(`^\\*\\*${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\*\\*: `);
|
|
@@ -653,9 +670,10 @@ var SlackProvider = class extends ChatSyncProvider {
|
|
|
653
670
|
this.web = client;
|
|
654
671
|
}
|
|
655
672
|
/**
|
|
656
|
-
*
|
|
657
|
-
* picture when it has one Slack can show, instead of the
|
|
658
|
-
* `**name**: ` label dropped. Without `chat:write.customize` it posts as
|
|
673
|
+
* A message goes out under its author's name (`Julián Benegas`, `clever-lemur via vboard-factory`,
|
|
674
|
+
* `Malte via support (slack)`), and their picture when it has one Slack can show, instead of the
|
|
675
|
+
* app's, with the text's `**name**: ` label dropped. Without `chat:write.customize` it posts as
|
|
676
|
+
* the app, label and all.
|
|
659
677
|
*/
|
|
660
678
|
async post(target, kind, body) {
|
|
661
679
|
const { as, ...given } = body;
|
|
@@ -696,13 +714,19 @@ var SlackProvider = class extends ChatSyncProvider {
|
|
|
696
714
|
}))
|
|
697
715
|
})).files?.[0]?.files ?? []).map((file) => file.id).filter((id) => !!id);
|
|
698
716
|
const found = async () => {
|
|
717
|
+
let failure = /* @__PURE__ */ new Error("never shared");
|
|
699
718
|
for (let attempt = 0; attempt < SHARE_POLLS; attempt++) {
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
719
|
+
try {
|
|
720
|
+
const shares = (await web.files.info({ file: ids[0] })).file?.shares;
|
|
721
|
+
const ts = shares?.public?.[channel]?.[0]?.ts ?? shares?.private?.[channel]?.[0]?.ts;
|
|
722
|
+
if (ts) return ts;
|
|
723
|
+
} catch (error) {
|
|
724
|
+
if (REFUSED.has(error?.data?.error ?? "")) throw error;
|
|
725
|
+
failure = error;
|
|
726
|
+
}
|
|
703
727
|
await new Promise((resolve) => setTimeout(resolve, Math.min(250 * 2 ** attempt, 2e3)));
|
|
704
728
|
}
|
|
705
|
-
throw
|
|
729
|
+
throw failure;
|
|
706
730
|
};
|
|
707
731
|
if (!ids[0]) throw new Error("slack: files.uploadV2 returned no file IDs");
|
|
708
732
|
let ts;
|
|
@@ -717,14 +741,14 @@ var SlackProvider = class extends ChatSyncProvider {
|
|
|
717
741
|
files: ids
|
|
718
742
|
};
|
|
719
743
|
}
|
|
720
|
-
/** An edit keeps the label out only where the message went out under
|
|
744
|
+
/** An edit keeps the label out only where the message went out under its author's name. */
|
|
721
745
|
async edit(thread, message, body) {
|
|
722
746
|
const { as, ...given } = body;
|
|
723
747
|
const post = {
|
|
724
748
|
...given,
|
|
725
749
|
markdown: withoutHtml(given.markdown)
|
|
726
750
|
};
|
|
727
|
-
const named = as ? await this.sentAs(thread, message, as
|
|
751
|
+
const named = as && await this.web().then((web) => !!web && this.canCustomize(web), () => false) ? await this.sentAs(thread, message, as) : false;
|
|
728
752
|
await super.edit(thread, message, named && as ? {
|
|
729
753
|
...post,
|
|
730
754
|
markdown: withoutLabel(post.markdown, as.name)
|
|
@@ -733,7 +757,8 @@ var SlackProvider = class extends ChatSyncProvider {
|
|
|
733
757
|
async postNamed(target, as, markdown) {
|
|
734
758
|
const adapter = await this.ready();
|
|
735
759
|
const web = await this.web();
|
|
736
|
-
|
|
760
|
+
const username = slackUsername(as);
|
|
761
|
+
if (!web?.chat || !adapter.formatConverter?.toSlackPayload || username === null || !await this.canCustomize(web)) return null;
|
|
737
762
|
const threadId = this.toChat(target);
|
|
738
763
|
const { channel, threadTs } = adapter.decodeThreadId(threadId);
|
|
739
764
|
const message = { markdown: withoutLabel(markdown, as.name) };
|
|
@@ -745,7 +770,7 @@ var SlackProvider = class extends ChatSyncProvider {
|
|
|
745
770
|
...adapter.formatConverter.toSlackPayload(resolved),
|
|
746
771
|
unfurl_links: false,
|
|
747
772
|
unfurl_media: false,
|
|
748
|
-
username
|
|
773
|
+
username,
|
|
749
774
|
...icon ? { icon_url: icon } : {}
|
|
750
775
|
});
|
|
751
776
|
if (!sent.ts) throw new Error("slack: chat.postMessage returned no ts");
|
|
@@ -767,8 +792,10 @@ var SlackProvider = class extends ChatSyncProvider {
|
|
|
767
792
|
});
|
|
768
793
|
return (await this.scopes).includes(scope);
|
|
769
794
|
}
|
|
770
|
-
/** Whether a message Slack has went out under
|
|
771
|
-
async sentAs(thread, message,
|
|
795
|
+
/** Whether a message Slack has went out under the sender's name. */
|
|
796
|
+
async sentAs(thread, message, as) {
|
|
797
|
+
const username = slackUsername(as);
|
|
798
|
+
if (username === null) return false;
|
|
772
799
|
const web = await this.web().catch(() => void 0);
|
|
773
800
|
const channel = thread.slice(0, thread.indexOf(":"));
|
|
774
801
|
if (!web?.conversations.replies || !channel) return false;
|
|
@@ -779,7 +806,7 @@ var SlackProvider = class extends ChatSyncProvider {
|
|
|
779
806
|
latest: message,
|
|
780
807
|
inclusive: true,
|
|
781
808
|
limit: 1
|
|
782
|
-
}).then((page) => page.messages?.find((m) => m.ts === message), () => void 0))?.username ===
|
|
809
|
+
}).then((page) => page.messages?.find((m) => m.ts === message), () => void 0))?.username === username;
|
|
783
810
|
}
|
|
784
811
|
/**
|
|
785
812
|
* Slack's link to the event's message, from `chat.getPermalink`, so it has the workspace's
|
|
@@ -815,4 +842,4 @@ var SlackProvider = class extends ChatSyncProvider {
|
|
|
815
842
|
}
|
|
816
843
|
};
|
|
817
844
|
//#endregion
|
|
818
|
-
export { SlackEvent, SlackProvider, channels, forwardText, slack, slackFileName, slackIcon, slackLinks, withoutHtml, withoutLabel };
|
|
845
|
+
export { SlackEvent, SlackProvider, channels, forwardText, slack, slackFileName, slackIcon, slackLinks, slackUsername, withoutHtml, withoutLabel };
|
package/dist/sync.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as
|
|
1
|
+
import { dn as ExternalFile, ln as ExternalAuthor, un as ExternalEvent } from "./routes-CAjd5ARa.mjs";
|
|
2
|
+
import { A as SyncRoot, C as mirror, D as RootOverride, E as ProviderEvent, M as eventSchema, O as SyncOverrides, S as into, T as EventBase, _ as SyncFn, a as ProviderOptions, b as SyncUnit, c as Receive, d as Renderer, f as ResolvedTarget, g as Sync, h as UnreadableError, i as ProviderFile, j as envelope, k as SyncResult, l as ReceivedEvent, m as SyncProvider, n as FileDelivery, o as ProviderPost, p as SyncContext, r as ProviderDelivery, u as RenderInput, v as SyncIn, w as render, x as channels, y as SyncOut } from "./provider-YqkF1E2k.mjs";
|
|
3
3
|
export { EventBase, type ExternalAuthor, ExternalEvent, type ExternalFile, type FileDelivery, type ProviderDelivery, type ProviderEvent, type ProviderFile, type ProviderOptions, type ProviderPost, type Receive, ReceivedEvent, type RenderInput, type Renderer, ResolvedTarget, type RootOverride, type Sync, type SyncContext, type SyncFn, type SyncIn, type SyncOut, SyncOverrides, SyncProvider, type SyncResult, type SyncRoot, type SyncUnit, UnreadableError, channels, envelope, eventSchema, into, mirror, render };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as unauthorized } from "./errors-
|
|
2
|
-
import { _ as privateHost, a as VERCEL_ISSUER, b as trustedIssuers, g as markVerified, i as TOKENS, m as issuerName } from "./auth-
|
|
1
|
+
import { l as unauthorized } from "./errors-CNRJqUuL.mjs";
|
|
2
|
+
import { _ as privateHost, a as VERCEL_ISSUER, b as trustedIssuers, g as markVerified, i as TOKENS, m as issuerName } from "./auth-C8URZHLx.mjs";
|
|
3
3
|
import { createRemoteJWKSet, decodeJwt, jwtVerify } from "jose";
|
|
4
4
|
//#region src/server/identity.ts
|
|
5
5
|
let fromDisk;
|
|
@@ -74,8 +74,7 @@ on any backend, and the backend stores. SSE, [the handle](#the-handle),
|
|
|
74
74
|
[How it runs](./06-watchers.md#how-it-runs).
|
|
75
75
|
- **What Vercel's API doesn't keep yet answers 501 `not_supported`:** files on
|
|
76
76
|
a scheduled message, labels on a scheduled reply, and a post's `sync`
|
|
77
|
-
targets. A
|
|
78
|
-
channel's message and thread counts are left out.
|
|
77
|
+
targets. A channel's message and thread counts are left out.
|
|
79
78
|
|
|
80
79
|
A request's caller is who `board()` verified it is: `authenticate` checks its
|
|
81
80
|
credential for the board's URL, which a token's audience must equal, works out
|
|
@@ -405,7 +404,10 @@ write.
|
|
|
405
404
|
optionally `expiresAt`. Its handle stands: the one the CLI sends doesn't
|
|
406
405
|
replace it, so a verifier that wants it returns `request.claims.handle`
|
|
407
406
|
itself. The name, profile, and `x-board-can` the caller sends still apply
|
|
408
|
-
on top of it.
|
|
407
|
+
on top of it. The board takes the handle as checked: a person posts to Slack
|
|
408
|
+
under it as a plain sender ([who posts under a name](../02-sync/03-slack.md#messages-post-under-their-authors-name)),
|
|
409
|
+
so a verifier that echoes the caller's handle lets them pick the name they
|
|
410
|
+
post under.
|
|
409
411
|
- **`kind: 'person'` is a person on the team:** it gets what grants give
|
|
410
412
|
people, as the board's own people do (g1 gives everything), and a channel
|
|
411
413
|
closed to `everyone` keeps it out unless a grant names it. So your verifier
|
|
@@ -121,13 +121,14 @@ A **principal** is who holds the credential. It's a readable string:
|
|
|
121
121
|
| `vercel:project:prj_x:production` | a deployment of a Vercel project |
|
|
122
122
|
| `github:repo:123456` | a GitHub Actions workflow in that repo |
|
|
123
123
|
| `oidc:gitlab.com:project_path:acme/api:ref_type:branch:ref:main` | another issuer's token, by its `sub` |
|
|
124
|
-
| `slack:user:U0456`, `github:user:583231` | a platform user
|
|
124
|
+
| `slack:user:U0456`, `github:user:583231` | a platform user the board's own [sync](../02-sync/01-overview.md) checked, under the sync key they came through |
|
|
125
125
|
| `board:watch:triage`, `board:client`, `board:client:deploys` | a [local board](./10-local.md)'s own [watchers](./06-watchers.md) and [handle](./01-mounting.md#the-handle), with `as()`'s profile |
|
|
126
126
|
|
|
127
127
|
A **profile** is a named identity within a principal: an agent acting for a
|
|
128
|
-
person
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
person, or a [platform user](#platform-users) a sync speaks for. An **actor**
|
|
129
|
+
is what a message is attributed to: the principal alone, or
|
|
130
|
+
`principal+profile`, like `vercel:user:u_abc123+claude`. One with a profile
|
|
131
|
+
shows through its principal: **claude via julian**.
|
|
131
132
|
|
|
132
133
|
### Profiles
|
|
133
134
|
|
|
@@ -162,9 +163,32 @@ When you write as yourself, the CLI also sends your Vercel display name and
|
|
|
162
163
|
avatar. Like your handle, they're details you assert; your identity is the
|
|
163
164
|
verified principal.
|
|
164
165
|
|
|
166
|
+
### Platform users
|
|
167
|
+
|
|
168
|
+
A Slack, GitHub, or Linear user arrives through [sync](../02-sync/01-overview.md),
|
|
169
|
+
named under the sync key they came through: `slack:user:U0456` through the key
|
|
170
|
+
`slack`, `slack-eu:user:U0456` through a key `slack-eu` registered for Slack. The
|
|
171
|
+
key is the connection, so renaming one changes its users' IDs; the platform shows
|
|
172
|
+
as their logo. The board's own sync checks each platform webhook itself, so what
|
|
173
|
+
it imports is by the user, shown by name. Any other sync, a project that
|
|
174
|
+
registers one on the board or any sync on Vercel's board, only says who wrote a
|
|
175
|
+
message, so what it imports is by a profile of that project, named
|
|
176
|
+
`<sync key>:<user>`: `vercel:project:prj_support:preview+slack:user:U0456`.
|
|
177
|
+
It shows through the project, with its environment outside production:
|
|
178
|
+
|
|
179
|
+
```text
|
|
180
|
+
#2 Malte via support (preview) · 2m
|
|
181
|
+
ship it, I checked
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Each sync's profile of a user is an actor of its own: two syncs' Malte don't
|
|
185
|
+
group, react, or match `--by` together, and only a sync's own imports change
|
|
186
|
+
its profile's name and avatar.
|
|
187
|
+
|
|
165
188
|
## Machines outside the project
|
|
166
189
|
|
|
167
|
-
g2 lets every project on the board's team read, post, react, and
|
|
190
|
+
g2 lets every project on the board's team read, post, react, label, and
|
|
191
|
+
[sync](../04-reference/03-http.md#what-sync-grants).
|
|
168
192
|
Anything else outside the board's project needs a
|
|
169
193
|
[grant](./09-access.md#grants), which says what it may do in each channel.
|
|
170
194
|
Someone with `manage` where it reaches creates it on the board, and it holds
|
|
@@ -218,8 +242,19 @@ Handles are display hints, not reservations:
|
|
|
218
242
|
that verifier returns, and the CLI's doesn't replace it.
|
|
219
243
|
- **A profile's** is `<person>/<profile>`: `julian/claude`.
|
|
220
244
|
- **A deployment's** is its project name, plus `@<env>` outside production.
|
|
245
|
+
On Vercel's board it's the project name in every environment, and one
|
|
246
|
+
outside production shows as `support (preview)`; where nothing names its
|
|
247
|
+
project, it goes by the project's ID (`prj_support@preview`).
|
|
221
248
|
- **A workflow's** is `owner/repo`.
|
|
222
|
-
- **A platform user's** is their login or display name there
|
|
249
|
+
- **A platform user's** is their login or display name there, for the
|
|
250
|
+
board's own sync. One a sync elsewhere imports is under that project's name,
|
|
251
|
+
in every environment: support's Malte is `support/malte`, and www's
|
|
252
|
+
`www/malte`. The part after `/` is made typable: accents taken off,
|
|
253
|
+
lowercased, every run of anything but letters, digits, `.`, `_`, and `-` as
|
|
254
|
+
one `-`, and the ends trimmed, so "Jürgen Ubl" is `support/jurgen-ubl`. When
|
|
255
|
+
nothing is left, it's their ID on the platform, without the sync key, the same
|
|
256
|
+
way (`T_EU:U0MALTE` is `t_eu-u0malte`). A handle holds 128 characters, so a
|
|
257
|
+
longer one is cut to fit, its ends trimmed again.
|
|
223
258
|
|
|
224
259
|
`vb actors` lists them.
|
|
225
260
|
|
|
@@ -229,37 +264,34 @@ Handles are display hints, not reservations:
|
|
|
229
264
|
vb reply 812 "@ada can you look? cc @julian/claude"
|
|
230
265
|
```
|
|
231
266
|
|
|
232
|
-
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
267
|
+
- **A mention is text.** The board posts it as written and stores nothing
|
|
268
|
+
else: no handle or actor ID fails a write, whether no one has it, several
|
|
269
|
+
share it, or the board has never seen them. An edit is just new text.
|
|
270
|
+
- **`@handle` and `@person/profile`** name whoever has that handle.
|
|
271
|
+
- **`@[actor-id]`** names an exact actor: `@[slack:user:U0456]`. It's how to
|
|
272
|
+
name one of several who share a handle.
|
|
236
273
|
- **`@[ada@vercel.com]`** names whoever has that email on a synced platform,
|
|
237
|
-
even someone the board hasn't seen.
|
|
238
|
-
renders natively. An email no platform knows stays plain text. A writer that
|
|
239
|
-
can't read the channel gets back what it wrote, and never sees who an email
|
|
240
|
-
turned out to be.
|
|
274
|
+
even someone the board hasn't seen.
|
|
241
275
|
- **Mentions in inline code or code blocks don't count.**
|
|
242
|
-
- **
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
name there: mention a Slack user in Slack by their actor
|
|
265
|
-
(`@[slack:user:U0456]`) or their email (`@[ada@vercel.com]`).
|
|
276
|
+
- **Each sync resolves them when it posts,** and only against its own users:
|
|
277
|
+
the platform users it brought in under the key it posts through. On Slack:
|
|
278
|
+
- `@ada` becomes `<@U0456>` when exactly one of its users goes by `ada`, or
|
|
279
|
+
by `<its project>/ada`: `@support/ada` reaches only support's Ada, and
|
|
280
|
+
`@ada` is the shorthand each sync reads as its own. Of several, it's the
|
|
281
|
+
one who wrote in the thread, if exactly one did. Otherwise it stays `@ada`.
|
|
282
|
+
- `@[actor-id]` becomes `<@U0456>` when it's one of its users, and their
|
|
283
|
+
name for anyone else, a board person included.
|
|
284
|
+
- `@[ada@vercel.com]` is looked up as it posts (it needs `users:read.email`):
|
|
285
|
+
`<@U0456>` when Slack finds her, and the plain email when it doesn't.
|
|
286
|
+
|
|
287
|
+
So `@malte` reaches each sync's own Malte, and neither two syncs that each
|
|
288
|
+
bring in a Malte nor a sync allowed only one channel makes it fail anywhere.
|
|
289
|
+
GitHub mentions its users as `@login`.
|
|
290
|
+
- **Filters read the text.** `--mentions @ada` finds `@ada`, and
|
|
291
|
+
`@[<actor id>]` for anyone who goes by `ada`. A name covers what's under it:
|
|
292
|
+
a person's agents (`@julian/claude`), and a project's imports
|
|
293
|
+
(`--mentions support` finds `@support/malte`). `--mentions` alone is your
|
|
294
|
+
handle and ID. A caller
|
|
295
|
+
that can't read every channel gets what it names as written, and its agents,
|
|
296
|
+
since who goes by what is for readers of every channel. See
|
|
297
|
+
[Reading](./05-reading.md#filters).
|