@vercel/board 0.43.0 → 0.44.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/access.d.mts +2 -2
- package/dist/{auth-Bn8J_1F2.d.mts → auth-C8jxty0C.d.mts} +1 -1
- package/dist/{backend-DMrK55mU.d.mts → backend-_3W_5g6y.d.mts} +3 -3
- package/dist/backend-local.d.mts +1 -1
- package/dist/backend-local.mjs +1 -1
- package/dist/{bots-CGkO76qH.mjs → bots-CLKKMgYf.mjs} +6 -1
- package/dist/{chat-provider-CPZg2MQb.mjs → chat-provider-DZ4DsAZ7.mjs} +6 -4
- package/dist/{chat-provider-Cgkh9xJw.d.mts → chat-provider-HQo68RWL.d.mts} +4 -4
- 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 +2 -2
- package/dist/cli.mjs +6 -6
- package/dist/{commands-C4fR0md0.mjs → commands-B75pBXIV.mjs} +1 -1
- package/dist/{commands-BlM-ckFS.d.mts → commands-DHGZWeSZ.d.mts} +1 -1
- package/dist/{conformance-BORt5nky.mjs → conformance-CHqXZoGe.mjs} +66 -0
- package/dist/conformance.d.mts +1 -1
- package/dist/conformance.mjs +1 -1
- package/dist/{data-values-C-Cq80hz.mjs → data-values-CoTP0SQG.mjs} +43 -54
- package/dist/{engine-BVHSH2Kn.mjs → engine-D07DTYSi.mjs} +16 -9
- package/dist/{events-BT8y_81j.mjs → events-voButVQW.mjs} +3 -1
- package/dist/{exports-S2AJNE_O.mjs → exports-BNk4w-b2.mjs} +10 -12
- package/dist/exports-DFwXKst5.d.mts +4 -0
- package/dist/{index-CydxnBND.d.mts → index-CwOOIT0e.d.mts} +2 -2
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +2 -2
- package/dist/index.node.d.mts +6 -6
- package/dist/index.node.mjs +1 -1
- package/dist/inspect/app.js +94 -94
- package/dist/inspect/engine.js +5 -5
- package/dist/inspect-DBLdh9NM.mjs +2 -0
- package/dist/{inspect-ByIt7CxV.mjs → inspect-dtQlHBcq.mjs} +1 -1
- package/dist/{local-0TVbQkzW.mjs → local-CnGNTReZ.mjs} +3 -1
- package/dist/{main-CM0_uZ7w.mjs → main-CpsAmpEy.mjs} +22 -37
- package/dist/origin-D4ER_Tze.mjs +428 -0
- package/dist/{provider-dY54GFNz.d.mts → provider-CVI-DlWl.d.mts} +27 -2
- package/dist/{routes-By9lmvUD.d.mts → routes-CErTwlSZ.d.mts} +3 -1
- package/dist/{origin-DoRR9yql.mjs → routes-DrByOCc1.mjs} +4 -426
- package/dist/schemas.mjs +1 -1
- package/dist/{serve-p_KKFTWm.mjs → serve-BQT5quKD.mjs} +2 -2
- package/dist/{server-CD7qe_Pl.mjs → server-FlDE6BDt.mjs} +4 -3
- package/dist/sync-chat-sdk.d.mts +2 -2
- package/dist/sync-chat-sdk.mjs +2 -2
- package/dist/sync-github.d.mts +2 -2
- package/dist/sync-github.mjs +2 -2
- package/dist/sync-linear.d.mts +3 -3
- package/dist/sync-linear.mjs +3 -3
- package/dist/sync-slack.d.mts +27 -4
- package/dist/sync-slack.mjs +206 -10
- package/dist/sync.d.mts +3 -3
- package/dist/sync.mjs +1 -1
- package/docs/02-sync/02-functions.md +4 -1
- package/docs/02-sync/03-slack.md +24 -1
- package/docs/02-sync/04-github.md +5 -2
- package/docs/02-sync/06-providers.md +1 -1
- package/docs/04-reference/01-cli.md +2 -2
- package/docs/04-reference/02-board.md +1 -1
- package/docs/04-reference/03-http.md +9 -3
- package/docs/04-reference/05-conformance.md +2 -3
- package/package.json +3 -1
- package/dist/exports-Bw_OYNRl.d.mts +0 -4
- package/dist/inspect-BjDlPHjE.mjs +0 -2
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { g as DIRECT_UPLOAD_BYTES_MAX
|
|
1
|
+
import { g as DIRECT_UPLOAD_BYTES_MAX } from "./errors-DUzpDSrJ.mjs";
|
|
2
2
|
import { b as storable, d as Labels, f as MESSAGE_TEXT_MAX, l as LabelKey, m as MessageText, o as ChannelPath, r as AttachmentId, s as Emoji, u as LabelValue, y as platformAvatar } from "./schemas-DAzSsgWk.mjs";
|
|
3
|
-
import { a as Link, i as ExternalTarget,
|
|
3
|
+
import { a as Link, i as ExternalTarget, n as ExternalEvent, o as Origin, t as ExternalAuthor } from "./external-DymyhUzl.mjs";
|
|
4
4
|
import { a as SCHEMA_DESCRIPTION_MAX, o as SCHEMA_NAME, s as SCHEMA_VERSION_MAX } from "./blocks-CVoBC7ur.mjs";
|
|
5
|
-
import { i as afterRetry } from "./middleware-0DUFrav-.mjs";
|
|
6
|
-
import { o as options } from "./commands-C4fR0md0.mjs";
|
|
7
5
|
import { z } from "zod";
|
|
8
6
|
//#region src/api/routes.ts
|
|
9
7
|
/**
|
|
@@ -428,7 +426,6 @@ const SyncFindQuery = z.object({
|
|
|
428
426
|
message: z.string().min(1).max(300).optional()
|
|
429
427
|
});
|
|
430
428
|
const SyncCopiesQuery = z.object({ message: repeated.pipe(z.array(Ref).min(1).max(100)) });
|
|
431
|
-
/** Platform events for a sync key's inbox, each with the platform's own ID for it, which dedupes it. */
|
|
432
429
|
const InboxPushBody = z.object({ events: z.array(z.object({
|
|
433
430
|
id: z.string().min(1).max(300),
|
|
434
431
|
event: ExternalEvent,
|
|
@@ -455,7 +452,7 @@ const EditBody = z.object({
|
|
|
455
452
|
});
|
|
456
453
|
const DeleteBody = z.object({ revision: Revision.optional() }).optional();
|
|
457
454
|
/** `status`: what Slack shows in place of "Typing…" (other platforms ignore it). */
|
|
458
|
-
const TypingBody = z.object({ status: z.string().trim().min(1).max(
|
|
455
|
+
const TypingBody = z.object({ status: z.string().trim().min(1).max(50).optional() }).optional();
|
|
459
456
|
const ReactBody = z.object({
|
|
460
457
|
emoji: Emoji,
|
|
461
458
|
remove: z.boolean().optional()
|
|
@@ -756,423 +753,4 @@ const routes = {
|
|
|
756
753
|
}
|
|
757
754
|
};
|
|
758
755
|
//#endregion
|
|
759
|
-
|
|
760
|
-
const VERSION = "0.43.0";
|
|
761
|
-
//#endregion
|
|
762
|
-
//#region src/server/backend.ts
|
|
763
|
-
/** The subscription sync's outbound runs on, in `BoardBinding.subscriptions`. No watcher's ID starts with `@`. */
|
|
764
|
-
const SYNC = "@sync";
|
|
765
|
-
//#endregion
|
|
766
|
-
//#region src/server/routing.ts
|
|
767
|
-
/** board()'s own routes: the files it serves, and sync's, which run where board() does. */
|
|
768
|
-
const BOARD_ROUTES = [
|
|
769
|
-
"avatar",
|
|
770
|
-
"openapi",
|
|
771
|
-
"webhook",
|
|
772
|
-
"sync"
|
|
773
|
-
];
|
|
774
|
-
/** Every protocol method, by the route it's served at. */
|
|
775
|
-
const METHODS = [
|
|
776
|
-
"discovery",
|
|
777
|
-
"me",
|
|
778
|
-
"channels",
|
|
779
|
-
"createChannel",
|
|
780
|
-
"actors",
|
|
781
|
-
"messages",
|
|
782
|
-
"threads",
|
|
783
|
-
"message",
|
|
784
|
-
"post",
|
|
785
|
-
"posted",
|
|
786
|
-
"edit",
|
|
787
|
-
"delete",
|
|
788
|
-
"react",
|
|
789
|
-
"label",
|
|
790
|
-
"schedule",
|
|
791
|
-
"schedules",
|
|
792
|
-
"cancelSchedule",
|
|
793
|
-
"grants",
|
|
794
|
-
"createGrant",
|
|
795
|
-
"updateGrant",
|
|
796
|
-
"explain",
|
|
797
|
-
"revokeGrant",
|
|
798
|
-
"schemas",
|
|
799
|
-
"schema",
|
|
800
|
-
"createSchema",
|
|
801
|
-
"upload",
|
|
802
|
-
"attachment",
|
|
803
|
-
"uploadStart",
|
|
804
|
-
"uploadFinish",
|
|
805
|
-
"watchers",
|
|
806
|
-
"register",
|
|
807
|
-
"matches",
|
|
808
|
-
"ack",
|
|
809
|
-
"events",
|
|
810
|
-
"syncImport",
|
|
811
|
-
"syncReceipt",
|
|
812
|
-
"syncThread",
|
|
813
|
-
"syncFind",
|
|
814
|
-
"syncCopies",
|
|
815
|
-
"inboxPush",
|
|
816
|
-
"inboxNext",
|
|
817
|
-
"inboxAck",
|
|
818
|
-
"inbox",
|
|
819
|
-
"typing",
|
|
820
|
-
"readSource",
|
|
821
|
-
"joinSource",
|
|
822
|
-
"synced",
|
|
823
|
-
"linked"
|
|
824
|
-
];
|
|
825
|
-
const escape = (literal) => literal.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
826
|
-
function compile(method, path, target, own) {
|
|
827
|
-
const parts = path.split("/").filter(Boolean);
|
|
828
|
-
const source = parts.map((part) => part.startsWith(":") ? "/([^/]+)" : `/${escape(part)}`).join("");
|
|
829
|
-
return {
|
|
830
|
-
method,
|
|
831
|
-
pattern: new RegExp(`${source}$`),
|
|
832
|
-
names: parts.filter((part) => part.startsWith(":")).map((part) => part.slice(1)),
|
|
833
|
-
target,
|
|
834
|
-
segments: parts.length,
|
|
835
|
-
literals: parts.filter((part) => !part.startsWith(":")).length,
|
|
836
|
-
own
|
|
837
|
-
};
|
|
838
|
-
}
|
|
839
|
-
/**
|
|
840
|
-
* The routes a board answers, most specific first: each is matched as a suffix of the request's
|
|
841
|
-
* path, so `/api/board/messages/12` is `GET /messages/:id` under `/api/board`. A backend's own
|
|
842
|
-
* route at a protocol path takes its place. Discovery is the mount itself.
|
|
843
|
-
*/
|
|
844
|
-
function createRouter(backendRoutes, basePath) {
|
|
845
|
-
const patterns = [
|
|
846
|
-
...BOARD_ROUTES.map((name) => compile(routes[name].method, routes[name].path, {
|
|
847
|
-
kind: "board",
|
|
848
|
-
name
|
|
849
|
-
}, false)),
|
|
850
|
-
...METHODS.filter((name) => name !== "discovery").map((name) => compile(routes[name].method, routes[name].path, {
|
|
851
|
-
kind: "protocol",
|
|
852
|
-
name
|
|
853
|
-
}, false)),
|
|
854
|
-
...backendRoutes.map((route) => compile(route.method, route.path, {
|
|
855
|
-
kind: "backend",
|
|
856
|
-
route
|
|
857
|
-
}, true))
|
|
858
|
-
].sort((a, b) => b.segments - a.segments || b.literals - a.literals || Number(b.own) - Number(a.own));
|
|
859
|
-
/** A segment that isn't URI-encoded names nothing: no route. */
|
|
860
|
-
const found = (candidate, base, values) => {
|
|
861
|
-
const params = {};
|
|
862
|
-
try {
|
|
863
|
-
candidate.names.forEach((name, i) => params[name] = decodeURIComponent(values[i]));
|
|
864
|
-
} catch {
|
|
865
|
-
return null;
|
|
866
|
-
}
|
|
867
|
-
const first = candidate.names[0];
|
|
868
|
-
return {
|
|
869
|
-
target: candidate.target,
|
|
870
|
-
base,
|
|
871
|
-
param: first === void 0 ? null : params[first],
|
|
872
|
-
params
|
|
873
|
-
};
|
|
874
|
-
};
|
|
875
|
-
const discovery = (base) => ({
|
|
876
|
-
target: {
|
|
877
|
-
kind: "protocol",
|
|
878
|
-
name: "discovery"
|
|
879
|
-
},
|
|
880
|
-
base,
|
|
881
|
-
param: null,
|
|
882
|
-
params: {},
|
|
883
|
-
root: true
|
|
884
|
-
});
|
|
885
|
-
return function route(method, pathname) {
|
|
886
|
-
const path = pathname.length > 1 ? pathname.replace(/\/+$/, "") : pathname;
|
|
887
|
-
if (basePath !== void 0) {
|
|
888
|
-
const base = basePath.replace(/\/+$/, "");
|
|
889
|
-
if (path !== base && !path.startsWith(`${base}/`)) return null;
|
|
890
|
-
const rest = path.slice(base.length) || "/";
|
|
891
|
-
if (rest === "/") return method === "GET" ? discovery(base) : null;
|
|
892
|
-
for (const candidate of patterns) {
|
|
893
|
-
const hit = candidate.method === method ? rest.match(new RegExp(`^${candidate.pattern.source}`)) : null;
|
|
894
|
-
if (hit) return found(candidate, base, hit.slice(1));
|
|
895
|
-
}
|
|
896
|
-
return null;
|
|
897
|
-
}
|
|
898
|
-
for (const candidate of patterns) {
|
|
899
|
-
if (candidate.method !== method) continue;
|
|
900
|
-
const hit = path.match(candidate.pattern);
|
|
901
|
-
if (hit) return found(candidate, path.slice(0, hit.index), hit.slice(1));
|
|
902
|
-
}
|
|
903
|
-
return method === "GET" ? discovery(path === "/" ? "" : path) : null;
|
|
904
|
-
};
|
|
905
|
-
}
|
|
906
|
-
function queryObject(url) {
|
|
907
|
-
const out = {};
|
|
908
|
-
for (const key of new Set(url.searchParams.keys())) {
|
|
909
|
-
const values = url.searchParams.getAll(key);
|
|
910
|
-
out[key] = values.length > 1 ? values : values[0];
|
|
911
|
-
}
|
|
912
|
-
return out;
|
|
913
|
-
}
|
|
914
|
-
async function readJson(request) {
|
|
915
|
-
const text = await request.text();
|
|
916
|
-
if (text.trim() === "") return void 0;
|
|
917
|
-
try {
|
|
918
|
-
return JSON.parse(text);
|
|
919
|
-
} catch {
|
|
920
|
-
throw badRequest("request body is not valid JSON");
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
const tooLarge = () => new HttpError(413, "too_large", `attachments are at most ${ATTACHMENT_BYTES_MAX / 1024 / 1024} MB`);
|
|
924
|
-
/** The body, refused as soon as it's past `max`: with or without a `content-length`, it never reads more. */
|
|
925
|
-
async function readCapped(request, max) {
|
|
926
|
-
if (Number(request.headers.get("content-length") ?? 0) > max) throw tooLarge();
|
|
927
|
-
const chunks = [];
|
|
928
|
-
let size = 0;
|
|
929
|
-
for await (const chunk of request.body ?? []) {
|
|
930
|
-
size += chunk.byteLength;
|
|
931
|
-
if (size > max) throw tooLarge();
|
|
932
|
-
chunks.push(chunk);
|
|
933
|
-
}
|
|
934
|
-
const body = new Uint8Array(size);
|
|
935
|
-
let at = 0;
|
|
936
|
-
for (const chunk of chunks) {
|
|
937
|
-
body.set(chunk, at);
|
|
938
|
-
at += chunk.byteLength;
|
|
939
|
-
}
|
|
940
|
-
return body;
|
|
941
|
-
}
|
|
942
|
-
function openapi() {
|
|
943
|
-
const paths = {};
|
|
944
|
-
for (const [name, definition] of Object.entries(routes)) {
|
|
945
|
-
const path = definition.path.replace(/:(\w+)/g, "{$1}");
|
|
946
|
-
const operation = { operationId: name };
|
|
947
|
-
if ("query" in definition) operation["x-query-schema"] = z.toJSONSchema(definition.query, { io: "input" });
|
|
948
|
-
if ("body" in definition) operation.requestBody = { content: { "application/json": { schema: z.toJSONSchema(definition.body, { io: "input" }) } } };
|
|
949
|
-
(paths[path] ??= {})[definition.method.toLowerCase()] = operation;
|
|
950
|
-
}
|
|
951
|
-
return {
|
|
952
|
-
openapi: "3.1.0",
|
|
953
|
-
info: {
|
|
954
|
-
title: "board",
|
|
955
|
-
version: VERSION
|
|
956
|
-
},
|
|
957
|
-
paths
|
|
958
|
-
};
|
|
959
|
-
}
|
|
960
|
-
//#endregion
|
|
961
|
-
//#region src/api/tail.ts
|
|
962
|
-
/** The filter flags `read`, `tail`, and `wait` share, and that a watcher's `tail` accepts. */
|
|
963
|
-
const FILTER_FLAGS = {
|
|
964
|
-
re: options.re,
|
|
965
|
-
by: options.by,
|
|
966
|
-
mentions: options.mentions,
|
|
967
|
-
label: options.label,
|
|
968
|
-
source: options.source,
|
|
969
|
-
text: options.text
|
|
970
|
-
};
|
|
971
|
-
/**
|
|
972
|
-
* What `--mentions` takes as its value when it's the next word: `@ada`, `ada@vercel.com`, or `me`.
|
|
973
|
-
* A channel never has an `@`, and a flag (`--text=a@b`) is never the value.
|
|
974
|
-
*/
|
|
975
|
-
const mentionValue = (word) => word !== void 0 && !word.startsWith("-") && (word === "me" || word.includes("@"));
|
|
976
|
-
/**
|
|
977
|
-
* `--mentions` alone means mentions of me; `--mentions @ada`, mentions of ada; `--mentions
|
|
978
|
-
* ada@vercel.com`, of the user with that email. Nothing after `--` is a flag.
|
|
979
|
-
*/
|
|
980
|
-
function withMentions(args) {
|
|
981
|
-
const out = [];
|
|
982
|
-
for (let i = 0; i < args.length; i++) {
|
|
983
|
-
const arg = args[i];
|
|
984
|
-
if (arg === "--") {
|
|
985
|
-
out.push(...args.slice(i));
|
|
986
|
-
break;
|
|
987
|
-
}
|
|
988
|
-
if (arg !== "--mentions") out.push(arg);
|
|
989
|
-
else if (mentionValue(args[i + 1])) out.push(`--mentions=${args[++i]}`);
|
|
990
|
-
else out.push("--mentions=me");
|
|
991
|
-
}
|
|
992
|
-
return out;
|
|
993
|
-
}
|
|
994
|
-
/** Splits an expression the way a shell would: whitespace separates, quotes group, `\` escapes. */
|
|
995
|
-
function words(expression) {
|
|
996
|
-
const out = [];
|
|
997
|
-
let word = null;
|
|
998
|
-
let quote = null;
|
|
999
|
-
for (let i = 0; i < expression.length; i++) {
|
|
1000
|
-
const char = expression[i];
|
|
1001
|
-
if (quote) {
|
|
1002
|
-
if (char === quote) quote = null;
|
|
1003
|
-
else if (char === "\\" && quote === "\"" && i + 1 < expression.length) word += expression[++i];
|
|
1004
|
-
else word += char;
|
|
1005
|
-
} else if (/\s/.test(char)) {
|
|
1006
|
-
if (word !== null) out.push(word);
|
|
1007
|
-
word = null;
|
|
1008
|
-
} else if (char === "\"" || char === "'") {
|
|
1009
|
-
quote = char;
|
|
1010
|
-
word ??= "";
|
|
1011
|
-
} else if (char === "\\" && i + 1 < expression.length) word = (word ?? "") + expression[++i];
|
|
1012
|
-
else word = (word ?? "") + char;
|
|
1013
|
-
}
|
|
1014
|
-
if (quote) throw new Error(`unterminated ${quote}`);
|
|
1015
|
-
if (word !== null) out.push(word);
|
|
1016
|
-
return out;
|
|
1017
|
-
}
|
|
1018
|
-
/** A watcher's tail takes the filters and `--all`, which shows receipts as it does in `vb tail`. */
|
|
1019
|
-
const TAIL_FLAGS = {
|
|
1020
|
-
...FILTER_FLAGS,
|
|
1021
|
-
all: { type: "boolean" }
|
|
1022
|
-
};
|
|
1023
|
-
/**
|
|
1024
|
-
* Parses filter flags as the CLI's parser does (Node's `parseArgs`, strict), written out so a tail
|
|
1025
|
-
* parses wherever board() runs, a browser included.
|
|
1026
|
-
*/
|
|
1027
|
-
function parseFilterFlags(args) {
|
|
1028
|
-
const values = {};
|
|
1029
|
-
const positionals = [];
|
|
1030
|
-
for (let i = 0; i < args.length; i++) {
|
|
1031
|
-
const arg = args[i];
|
|
1032
|
-
if (arg === "--") {
|
|
1033
|
-
positionals.push(...args.slice(i + 1));
|
|
1034
|
-
break;
|
|
1035
|
-
}
|
|
1036
|
-
if (!arg.startsWith("-") || arg === "-") {
|
|
1037
|
-
positionals.push(arg);
|
|
1038
|
-
continue;
|
|
1039
|
-
}
|
|
1040
|
-
const eq = arg.indexOf("=");
|
|
1041
|
-
const name = arg.startsWith("--") ? arg.slice(2, eq === -1 ? void 0 : eq) : null;
|
|
1042
|
-
const spec = name !== null && Object.hasOwn(TAIL_FLAGS, name) ? TAIL_FLAGS[name] : null;
|
|
1043
|
-
if (!spec) throw new Error(`${name !== null ? `--${name}` : arg.slice(0, 2)} isn't a filter`);
|
|
1044
|
-
if (spec.type === "boolean") {
|
|
1045
|
-
if (eq !== -1) throw new Error(`--${name} takes no value`);
|
|
1046
|
-
values[name] = true;
|
|
1047
|
-
continue;
|
|
1048
|
-
}
|
|
1049
|
-
let value;
|
|
1050
|
-
if (eq !== -1) value = arg.slice(eq + 1);
|
|
1051
|
-
else {
|
|
1052
|
-
const next = args[i + 1];
|
|
1053
|
-
if (next === void 0 || next.length > 1 && next.startsWith("-")) throw new Error(`--${name} needs a value`);
|
|
1054
|
-
value = next;
|
|
1055
|
-
i++;
|
|
1056
|
-
}
|
|
1057
|
-
if ("multiple" in spec) values[name] = [...values[name] ?? [], value];
|
|
1058
|
-
else values[name] = value;
|
|
1059
|
-
}
|
|
1060
|
-
return {
|
|
1061
|
-
values,
|
|
1062
|
-
positionals
|
|
1063
|
-
};
|
|
1064
|
-
}
|
|
1065
|
-
/** A watcher's `tail`: its filters, and whether `--all` shows it receipts too. */
|
|
1066
|
-
function parseWatchTail(expression) {
|
|
1067
|
-
const { values, positionals } = parseFilterFlags(withMentions(words(expression)));
|
|
1068
|
-
if (positionals.length > 1) throw new Error(`expected one channel, got: ${positionals.join(" ")}`);
|
|
1069
|
-
const channel = positionals[0];
|
|
1070
|
-
const parsed = Filters.safeParse({
|
|
1071
|
-
...channel ? { channel } : {},
|
|
1072
|
-
...values.re ? { re: values.re.replace(/^#/, "") } : {},
|
|
1073
|
-
...values.by ? { by: values.by.replace(/^@/, "") } : {},
|
|
1074
|
-
...values.mentions ? { mentions: values.mentions.replace(/^@/, "") } : {},
|
|
1075
|
-
...values.label?.length ? { label: values.label } : {},
|
|
1076
|
-
...values.source ? { from: values.source } : {},
|
|
1077
|
-
...values.text ? { text: values.text } : {}
|
|
1078
|
-
});
|
|
1079
|
-
if (!parsed.success) {
|
|
1080
|
-
const issue = parsed.error.issues[0];
|
|
1081
|
-
throw new Error(`${issue?.path.length ? `--${String(issue.path[0])}: ` : ""}${issue?.message ?? "invalid filters"}`);
|
|
1082
|
-
}
|
|
1083
|
-
return {
|
|
1084
|
-
filters: parsed.data,
|
|
1085
|
-
all: values.all === true
|
|
1086
|
-
};
|
|
1087
|
-
}
|
|
1088
|
-
//#endregion
|
|
1089
|
-
//#region src/server/watch-spec.ts
|
|
1090
|
-
/** Whether filters narrow anything: a view a message can enter. */
|
|
1091
|
-
const hasCriteria = (filters) => filters.channel !== void 0 || filters.re !== void 0 || filters.by !== void 0 || filters.mentions !== void 0 || filters.from !== void 0 || filters.text !== void 0 || (filters.label?.length ?? 0) > 0;
|
|
1092
|
-
/** A watcher's tail, checked the way a boot checks it: errors name the watcher. */
|
|
1093
|
-
function compileWatcher(id, spec) {
|
|
1094
|
-
let filters;
|
|
1095
|
-
let all;
|
|
1096
|
-
try {
|
|
1097
|
-
({filters, all} = parseWatchTail(spec.tail));
|
|
1098
|
-
} catch (error) {
|
|
1099
|
-
throw new Error(`watch ${id}: ${error.message}`);
|
|
1100
|
-
}
|
|
1101
|
-
if (filters.mentions === "me") throw new Error(`watch ${id}: a watcher has no "me": use --mentions @handle`);
|
|
1102
|
-
return {
|
|
1103
|
-
filters,
|
|
1104
|
-
criteria: hasCriteria(filters),
|
|
1105
|
-
all
|
|
1106
|
-
};
|
|
1107
|
-
}
|
|
1108
|
-
//#endregion
|
|
1109
|
-
//#region src/server/watch-run.ts
|
|
1110
|
-
/**
|
|
1111
|
-
* A2 dead-letters an event after 10 failures, and a dead letter stops its
|
|
1112
|
-
* lane, which is the thread's: the watcher would never run on that thread
|
|
1113
|
-
* again. So `run` gets a few tries, then the failure is recorded and the
|
|
1114
|
-
* thread moves on.
|
|
1115
|
-
*/
|
|
1116
|
-
const RUN_ATTEMPTS = 5;
|
|
1117
|
-
/**
|
|
1118
|
-
* A run that's killed (a timeout, out of memory) never throws. A2 counts it
|
|
1119
|
-
* toward the 10 failures when the next attempt takes over, and dead-letters
|
|
1120
|
-
* the event at that takeover instead of running it: the 10th attempt is the
|
|
1121
|
-
* last one a watcher sees. Throws give up at RUN_ATTEMPTS, so getting this far
|
|
1122
|
-
* means runs keep dying, and the 10th records the failure without running.
|
|
1123
|
-
*/
|
|
1124
|
-
const KILLED_ATTEMPTS = 10;
|
|
1125
|
-
const describe = (error) => ((error instanceof Error ? error.message : String(error)) || "unknown error").slice(0, 500);
|
|
1126
|
-
/**
|
|
1127
|
-
* One match, on its thread's lane: `run`, retried while it fails (by A2 on a local board, by the
|
|
1128
|
-
* tail on a person's Vercel board), then given up on and recorded so the thread's next event runs.
|
|
1129
|
-
*/
|
|
1130
|
-
async function runMatch(input) {
|
|
1131
|
-
const { watcher, match, attempt } = input;
|
|
1132
|
-
const event = match.payload.event;
|
|
1133
|
-
const giveUp = async (error) => {
|
|
1134
|
-
console.error(`[board] watcher ${watcher.id} gave up on event #${event.cursor} after ${attempt} tries:`, error);
|
|
1135
|
-
await input.record({
|
|
1136
|
-
matched: match.id,
|
|
1137
|
-
thread: match.payload.thread,
|
|
1138
|
-
error
|
|
1139
|
-
});
|
|
1140
|
-
};
|
|
1141
|
-
const early = !afterRetry(attempt);
|
|
1142
|
-
if (early && attempt >= KILLED_ATTEMPTS) return giveUp(`its run was cut short ${attempt - 1} times (a timeout, or out of memory)`);
|
|
1143
|
-
try {
|
|
1144
|
-
await watcher.run(event);
|
|
1145
|
-
} catch (error) {
|
|
1146
|
-
if (!early || attempt < RUN_ATTEMPTS) throw error;
|
|
1147
|
-
await giveUp(describe(error));
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
//#endregion
|
|
1151
|
-
//#region src/server/watchers-hash.ts
|
|
1152
|
-
/** By UTF-16 code unit, as `sort()` orders strings: the same in every locale and runtime. */
|
|
1153
|
-
const byCodeUnit = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
1154
|
-
/**
|
|
1155
|
-
* What `watchersHash` hashes, the same on both ends: a board on `http()` hashes its watchers, and
|
|
1156
|
-
* whether its sync subscribes, and the board it uses hashes what it holds.
|
|
1157
|
-
*/
|
|
1158
|
-
function canonicalWatchers(watch, sync = []) {
|
|
1159
|
-
const canonical = Object.keys(watch).sort(byCodeUnit).map((id) => [id, watch[id].tail]);
|
|
1160
|
-
if (sync.length > 0) canonical.push(["sync", [...sync].sort((a, b) => byCodeUnit(a.key, b.key)).map((entry) => [entry.key, entry.platform])]);
|
|
1161
|
-
return JSON.stringify(canonical);
|
|
1162
|
-
}
|
|
1163
|
-
//#endregion
|
|
1164
|
-
//#region src/server/targets.ts
|
|
1165
|
-
/** A target as a post or a receipt names it, resolved: a plain one's kind goes by its shape. */
|
|
1166
|
-
const syncTarget = (target) => typeof target === "string" ? {
|
|
1167
|
-
target,
|
|
1168
|
-
kind: isThreadTarget(target) ? "thread" : "channel"
|
|
1169
|
-
} : target;
|
|
1170
|
-
//#endregion
|
|
1171
|
-
//#region src/server/origin.ts
|
|
1172
|
-
/**
|
|
1173
|
-
* Sync in board() itself, on a board whose log is in this deployment (`local()`): it checked each
|
|
1174
|
-
* platform event itself, so what it imports is by the platform user, not a profile of anyone.
|
|
1175
|
-
*/
|
|
1176
|
-
const SYNC_ACTOR = "board:sync";
|
|
1177
|
-
//#endregion
|
|
1178
|
-
export { MessagesQuery as A, SyncBody as B, InboxAckBody as C, LabelBody as D, InboxQuery as E, ScheduleBody as F, ThreadsQuery as G, SyncFindQuery as H, SchedulesQuery as I, UploadStartBody as J, TypingBody as K, SchemaBody as L, ReactBody as M, Ref as N, LinkedQuery as O, RegisterBody as P, SourceJoinBody as R, GrantBody as S, InboxPushBody as T, SyncImportBody as U, SyncCopiesQuery as V, SyncReceiptBody as W, routes as Y, CreateChannelBody as _, compileWatcher as a, EventsQuery as b, METHODS as c, queryObject as d, readCapped as f, AckBody as g, VERSION as h, runMatch as i, PostBody as j, MatchesQuery as k, createRouter as l, SYNC as m, syncTarget as n, hasCriteria as o, readJson as p, UpdateGrantBody as q, canonicalWatchers as r, withMentions as s, SYNC_ACTOR as t, openapi as u, DeleteBody as v, InboxNextQuery as w, ExplainQuery as x, EditBody as y, SourceReadQuery as z };
|
|
756
|
+
export { SyncReceiptBody as A, SchemaBody as C, SyncCopiesQuery as D, SyncBody as E, routes as F, TypingBody as M, UpdateGrantBody as N, SyncFindQuery as O, UploadStartBody as P, SchedulesQuery as S, SourceReadQuery as T, PostBody as _, EventsQuery as a, RegisterBody as b, GrantBody as c, InboxPushBody as d, InboxQuery as f, MessagesQuery as g, MatchesQuery as h, EditBody as i, ThreadsQuery as j, SyncImportBody as k, InboxAckBody as l, LinkedQuery as m, CreateChannelBody as n, ExplainQuery as o, LabelBody as p, DeleteBody as r, Filters as s, AckBody as t, InboxNextQuery as u, ReactBody as v, SourceJoinBody as w, ScheduleBody as x, Ref as y };
|
package/dist/schemas.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { c as canonical, d as parseSchemaId, i as BUILT_IN_SCHEMAS, l as checkDefinition, r as findBlocks, t as block } from "./blocks-CVoBC7ur.mjs";
|
|
2
|
-
import { t as checkValue } from "./data-values-
|
|
2
|
+
import { t as checkValue } from "./data-values-CoTP0SQG.mjs";
|
|
3
3
|
export { BUILT_IN_SCHEMAS, block, canonical, checkDefinition, checkValue, findBlocks, parseSchemaId };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { u as BoardError } from "./errors-DUzpDSrJ.mjs";
|
|
2
|
-
import { d as localTokenFile, t as board } from "./server-
|
|
2
|
+
import { d as localTokenFile, t as board } from "./server-FlDE6BDt.mjs";
|
|
3
3
|
import { t as oidcTokens } from "./tokens-BSMpTPEe.mjs";
|
|
4
|
-
import { t as local } from "./local-
|
|
4
|
+
import { t as local } from "./local-CnGNTReZ.mjs";
|
|
5
5
|
import { mkdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
6
6
|
import { userInfo } from "node:os";
|
|
7
7
|
import { dirname, join, resolve } from "node:path";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { d as createBoardClient, p as formatProfileHeader, t as HttpError, u as BoardError } from "./errors-DUzpDSrJ.mjs";
|
|
2
2
|
import "./schemas-DAzSsgWk.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { F as routes } from "./routes-DrByOCc1.mjs";
|
|
4
4
|
import { g as keyId, p as DERIVED_ID } from "./middleware-0DUFrav-.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { a as compileWatcher, c as METHODS } from "./origin-D4ER_Tze.mjs";
|
|
6
|
+
import { c as tailWatchers, i as createVercel, l as deployedOnVercel, o as PROTOCOL_ROUTES, s as withoutToken, t as createBoard } from "./exports-BNk4w-b2.mjs";
|
|
6
7
|
import { execFile } from "node:child_process";
|
|
7
8
|
import { createHash } from "node:crypto";
|
|
8
9
|
import { mkdir, readFile, readdir, stat, unlink, writeFile } from "node:fs/promises";
|
|
@@ -988,7 +989,7 @@ function vercel(options = {}) {
|
|
|
988
989
|
function board(options = {}) {
|
|
989
990
|
return createBoard(options, {
|
|
990
991
|
backend: (fetch) => process.env.BOARD_URL?.trim() ? http() : vercel(fetch ? { fetch } : {}),
|
|
991
|
-
sync: () => import("./engine-
|
|
992
|
+
sync: () => import("./engine-D07DTYSi.mjs"),
|
|
992
993
|
serving: () => import("./serving-hcxzaCCO.mjs"),
|
|
993
994
|
sandbox: (url, token) => sandboxHeaders(url, url, token)
|
|
994
995
|
});
|
package/dist/sync-chat-sdk.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as SyncFn, m as SyncProvider, x as channels } from "./provider-
|
|
2
|
-
import { r as ChatTransport, t as ChatInput } from "./chat-provider-
|
|
1
|
+
import { _ as SyncFn, m as SyncProvider, x as channels } from "./provider-CVI-DlWl.mjs";
|
|
2
|
+
import { r as ChatTransport, t as ChatInput } from "./chat-provider-HQo68RWL.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-chat-sdk.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as ChatSyncProvider } from "./chat-provider-
|
|
1
|
+
import { i as eventSchema, p as channels, r as envelope } from "./events-voButVQW.mjs";
|
|
2
|
+
import { t as ChatSyncProvider } from "./chat-provider-DZ4DsAZ7.mjs";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
//#region src/sync/chat-sdk.ts
|
|
5
5
|
const schemaOf = (platform) => eventSchema(platform, "message");
|
package/dist/sync-github.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as SyncFn, b as SyncUnit, p as SyncContext } from "./provider-
|
|
2
|
-
import { n as ChatSyncProvider } from "./chat-provider-
|
|
1
|
+
import { _ as SyncFn, b as SyncUnit, p as SyncContext } from "./provider-CVI-DlWl.mjs";
|
|
2
|
+
import { n as ChatSyncProvider } from "./chat-provider-HQo68RWL.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { Adapter } from "chat";
|
|
5
5
|
//#region src/sync/github.d.ts
|
package/dist/sync-github.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-
|
|
1
|
+
import { _ as withRoutes, i as eventSchema, m as into, r as envelope } from "./events-voButVQW.mjs";
|
|
2
|
+
import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-DZ4DsAZ7.mjs";
|
|
3
3
|
import { n as tagOf } from "./tags-BpFo6q0_.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { connectGitHubAdapter } from "@vercel/connect/chat";
|
package/dist/sync-linear.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _ as SyncFn, b as SyncUnit, f as ResolvedTarget, l as ReceivedEvent, o as ProviderPost, p as SyncContext, r as ProviderDelivery } from "./provider-
|
|
3
|
-
import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-
|
|
1
|
+
import { ft as SourceRead } from "./routes-CErTwlSZ.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-CVI-DlWl.mjs";
|
|
3
|
+
import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-HQo68RWL.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { Adapter } from "chat";
|
|
6
6
|
//#region src/sync/linear.d.ts
|
package/dist/sync-linear.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-
|
|
1
|
+
import { i as eventSchema, l as UnreadableError, p as channels, r as envelope } from "./events-voButVQW.mjs";
|
|
2
|
+
import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-DZ4DsAZ7.mjs";
|
|
3
3
|
import { n as tagOf, t as slug } from "./tags-BpFo6q0_.mjs";
|
|
4
4
|
import "zod";
|
|
5
5
|
import { connectLinearAdapter } from "@vercel/connect/chat";
|
|
@@ -84,7 +84,7 @@ function parseThread(thread) {
|
|
|
84
84
|
}
|
|
85
85
|
/** A board message's first line, as an issue title: Linear titles are plain text. */
|
|
86
86
|
function titleOf(markdown) {
|
|
87
|
-
return (markdown.split("\n").map((text) => text.trim()).find(Boolean) ?? "").replace(
|
|
87
|
+
return (markdown.replace(/^\*\*[^*\n]+\*\*:\s*/, "").split("\n").map((text) => text.trim()).find(Boolean) ?? "").replace(/\*\*|__|`/g, "").replace(/^[#>\s]+/, "").replace(/\s+/g, " ").trim().slice(0, 255) || "Untitled";
|
|
88
88
|
}
|
|
89
89
|
function stateOf(state) {
|
|
90
90
|
return state?.type ?? state?.name?.toLowerCase() ?? null;
|
package/dist/sync-slack.d.mts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _ as SyncFn, f as ResolvedTarget, o as ProviderPost, p as SyncContext, r as ProviderDelivery, s as ProviderSender, x as channels } from "./provider-
|
|
3
|
-
import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-
|
|
1
|
+
import { un as ExternalLink } from "./routes-CErTwlSZ.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-CVI-DlWl.mjs";
|
|
3
|
+
import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-HQo68RWL.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { Adapter } from "chat";
|
|
6
|
+
//#region src/sync/slack-deployments.d.ts
|
|
7
|
+
/** One of Slack's layout blocks, as its API takes it. */
|
|
8
|
+
type SlackBlock = {
|
|
9
|
+
type: string;
|
|
10
|
+
} & Record<string, unknown>;
|
|
11
|
+
//#endregion
|
|
6
12
|
//#region src/sync/slack.d.ts
|
|
7
13
|
type SlackChannel = {
|
|
8
14
|
id?: string;
|
|
@@ -98,6 +104,13 @@ export type SlackClient = {
|
|
|
98
104
|
postMessage(args: SlackPost): Promise<{
|
|
99
105
|
ts?: string;
|
|
100
106
|
}>;
|
|
107
|
+
/** Replaces a message's text and layout, for one board laid out itself. */
|
|
108
|
+
update?(args: {
|
|
109
|
+
channel: string;
|
|
110
|
+
ts: string;
|
|
111
|
+
text: string;
|
|
112
|
+
blocks: SlackBlock[];
|
|
113
|
+
}): Promise<unknown>;
|
|
101
114
|
/** A message's link, with the workspace's own host and a reply's `thread_ts`. */
|
|
102
115
|
getPermalink?(args: {
|
|
103
116
|
channel: string;
|
|
@@ -123,6 +136,7 @@ type SlackPost = {
|
|
|
123
136
|
thread_ts?: string;
|
|
124
137
|
text?: string;
|
|
125
138
|
markdown_text?: string;
|
|
139
|
+
blocks?: SlackBlock[];
|
|
126
140
|
username?: string;
|
|
127
141
|
icon_url?: string;
|
|
128
142
|
unfurl_links?: boolean;
|
|
@@ -133,7 +147,7 @@ type SlackPost = {
|
|
|
133
147
|
* is. Null when that alone doesn't fit, for the message to go as the app with its label.
|
|
134
148
|
*/
|
|
135
149
|
export declare function slackUsername({ name, attribution }: Pick<ProviderSender, 'name' | 'attribution'>): string | null;
|
|
136
|
-
/** The `**name**: ` a message's text opens with, taken out when Slack shows the name as the sender. */
|
|
150
|
+
/** The `**name**: ` a message's text opens with (on a line of its own before a block), taken out when Slack shows the name as the sender. */
|
|
137
151
|
export declare function withoutLabel(markdown: string, name: string): string;
|
|
138
152
|
/** GitHub's markdown allows inline HTML, which Slack shows as raw tags: as markdown instead, outside code. */
|
|
139
153
|
export declare function withoutHtml(markdown: string): string;
|
|
@@ -389,6 +403,15 @@ export declare class SlackProvider extends ChatSyncProvider<SlackEvent> {
|
|
|
389
403
|
private postWithFiles;
|
|
390
404
|
/** An edit keeps the label out only where the message went out under its author's name. */
|
|
391
405
|
edit(thread: string, message: string, body: ProviderPost): Promise<void>;
|
|
406
|
+
/**
|
|
407
|
+
* Vercel's deployment comment goes out with its deployments as the table Vercel posts on a
|
|
408
|
+
* pull request, the text around them as markdown, under its author's name where the app may
|
|
409
|
+
* set one. Null, with nothing sent, when board has no client to post with, the markdown isn't
|
|
410
|
+
* one board can lay out, or Slack won't take the layout: it goes out as markdown, a line each.
|
|
411
|
+
*/
|
|
412
|
+
private postDeployments;
|
|
413
|
+
/** An edit to that comment: its text and table, replaced. False, with nothing changed, where a post would be null, or board's client can't edit. */
|
|
414
|
+
private editDeployments;
|
|
392
415
|
private postNamed;
|
|
393
416
|
/** Whether the app may set a message's username and icon (`chat:write.customize`). */
|
|
394
417
|
private canCustomize;
|