@vercel/board 0.43.1 → 0.45.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.
Files changed (79) hide show
  1. package/dist/{access-BgBiaCyx.mjs → access-3udXjJAg.mjs} +2 -2
  2. package/dist/access.d.mts +3 -3
  3. package/dist/access.mjs +6 -6
  4. package/dist/{actors-DkZsnMgA.mjs → actors-DasGZnfb.mjs} +3 -3
  5. package/dist/{auth-Bn8J_1F2.d.mts → auth-BG_whr9_.d.mts} +1 -1
  6. package/dist/{auth-Ft4AJptx.mjs → auth-aiOVE82-.mjs} +2 -2
  7. package/dist/{backend-DMrK55mU.d.mts → backend-D6yTo8Un.d.mts} +3 -3
  8. package/dist/backend-local.d.mts +1 -1
  9. package/dist/backend-local.mjs +1 -1
  10. package/dist/{bots-CGkO76qH.mjs → bots-CLKKMgYf.mjs} +6 -1
  11. package/dist/{chat-provider-CPZg2MQb.mjs → chat-provider-BvNqOQFL.mjs} +7 -5
  12. package/dist/{chat-provider-Cgkh9xJw.d.mts → chat-provider-V2jnjVLq.d.mts} +4 -4
  13. package/dist/cli-commands.d.mts +1 -1
  14. package/dist/cli-commands.mjs +1 -1
  15. package/dist/cli-embedded.d.mts +2 -2
  16. package/dist/cli-embedded.mjs +2 -2
  17. package/dist/cli.mjs +14 -7
  18. package/dist/{commands-C4fR0md0.mjs → commands-CqdnjUkm.mjs} +7 -1
  19. package/dist/{commands-BlM-ckFS.d.mts → commands-DewS14_P.d.mts} +7 -1
  20. package/dist/{conformance-BORt5nky.mjs → conformance-BInS4_6b.mjs} +68 -2
  21. package/dist/conformance.d.mts +1 -1
  22. package/dist/conformance.mjs +1 -1
  23. package/dist/{data-values-C-Cq80hz.mjs → data-values-CoTP0SQG.mjs} +43 -54
  24. package/dist/{engine-BVHSH2Kn.mjs → engine-XVBt02Bl.mjs} +20 -13
  25. package/dist/{errors-DUzpDSrJ.mjs → errors-ZazTZh-s.mjs} +20 -3
  26. package/dist/{events-BT8y_81j.mjs → events-D17RndlV.mjs} +5 -3
  27. package/dist/{exports-BVgUNVsP.mjs → exports-DCf75prP.mjs} +184 -45
  28. package/dist/exports-Gspe1eEq.d.mts +4 -0
  29. package/dist/{external-DymyhUzl.mjs → external-DfhN7lKK.mjs} +1 -1
  30. package/dist/{index-CydxnBND.d.mts → index-Djmr4GzQ.d.mts} +2 -2
  31. package/dist/index.d.mts +6 -6
  32. package/dist/index.mjs +4 -4
  33. package/dist/index.node.d.mts +6 -6
  34. package/dist/index.node.mjs +3 -3
  35. package/dist/inspect/app.js +88 -88
  36. package/dist/inspect/engine.js +5 -5
  37. package/dist/{inspect-ZGkTJl3f.mjs → inspect-B0_aKQM8.mjs} +23 -7
  38. package/dist/inspect-CULoD54F.mjs +2 -0
  39. package/dist/{local-yB2DFcRi.mjs → local-Bel_oeFa.mjs} +26 -13
  40. package/dist/{main-DjEJPCgo.mjs → main-DmsdcUZ_.mjs} +36 -13
  41. package/dist/{memory-DhduVbUu.mjs → memory-DyEL0fvN.mjs} +2 -2
  42. package/dist/{middleware-0DUFrav-.mjs → middleware-BHHKHA9q.mjs} +2 -2
  43. package/dist/origin-BHmEdok7.mjs +428 -0
  44. package/dist/{provider-dY54GFNz.d.mts → provider-BC9mPYVh.d.mts} +39 -6
  45. package/dist/{origin-9Ch-Zonv.mjs → routes-CkUetTO2.mjs} +14 -437
  46. package/dist/{routes-By9lmvUD.d.mts → routes-zm4TXKCC.d.mts} +8 -1
  47. package/dist/{schemas-DAzSsgWk.mjs → schemas-BhZaystC.mjs} +8 -2
  48. package/dist/schemas.mjs +1 -1
  49. package/dist/{serve-Cnb4TpaJ.mjs → serve-bPSEx_8X.mjs} +4 -4
  50. package/dist/{server-BHpUqip5.mjs → server-CcvxkXzG.mjs} +8 -7
  51. package/dist/{serving-hcxzaCCO.mjs → serving-BLVRrJ7P.mjs} +1 -1
  52. package/dist/{sql-P9g-rLIF.mjs → sql-CyVcjw8x.mjs} +2 -2
  53. package/dist/{sqlite-B3rCcIof.mjs → sqlite-Con-8duk.mjs} +2 -2
  54. package/dist/{sqlite-db-D0Fyju-4.mjs → sqlite-db-BdzxtUOV.mjs} +1 -1
  55. package/dist/sync-chat-sdk.d.mts +2 -2
  56. package/dist/sync-chat-sdk.mjs +2 -2
  57. package/dist/sync-github.d.mts +2 -2
  58. package/dist/sync-github.mjs +2 -2
  59. package/dist/sync-linear.d.mts +3 -3
  60. package/dist/sync-linear.mjs +3 -3
  61. package/dist/sync-slack.d.mts +27 -4
  62. package/dist/sync-slack.mjs +208 -12
  63. package/dist/sync.d.mts +3 -3
  64. package/dist/sync.mjs +2 -2
  65. package/dist/{tokens-BSMpTPEe.mjs → tokens-BErYXuHZ.mjs} +2 -2
  66. package/docs/01-board/04-messages.md +1 -1
  67. package/docs/01-board/09-access.md +8 -0
  68. package/docs/02-sync/02-functions.md +4 -1
  69. package/docs/02-sync/03-slack.md +24 -1
  70. package/docs/02-sync/04-github.md +5 -2
  71. package/docs/02-sync/06-providers.md +1 -1
  72. package/docs/03-guides/02-inspector.md +16 -0
  73. package/docs/04-reference/01-cli.md +1 -1
  74. package/docs/04-reference/02-board.md +24 -3
  75. package/docs/04-reference/03-http.md +8 -2
  76. package/docs/04-reference/05-conformance.md +1 -1
  77. package/package.json +3 -1
  78. package/dist/exports-Bw_OYNRl.d.mts +0 -4
  79. package/dist/inspect-DRPRCOaV.mjs +0 -2
@@ -1,9 +1,6 @@
1
- import { g as DIRECT_UPLOAD_BYTES_MAX, h as ATTACHMENT_BYTES_MAX, r as badRequest, t as HttpError } from "./errors-DUzpDSrJ.mjs";
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, l as isThreadTarget, n as ExternalEvent, o as Origin, t as ExternalAuthor } from "./external-DymyhUzl.mjs";
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";
1
+ import { v as DIRECT_UPLOAD_BYTES_MAX } from "./errors-ZazTZh-s.mjs";
2
+ import { S as storable, c as Emoji, d as LabelValue, f as Labels, h as MessageText, o as CHANNEL_PATTERN_MAX, p as MESSAGE_TEXT_MAX, r as AttachmentId, s as ChannelPath, u as LabelKey, v as SentText, x as platformAvatar } from "./schemas-BhZaystC.mjs";
3
+ import { a as Link, i as ExternalTarget, n as ExternalEvent, o as Origin, t as ExternalAuthor } from "./external-DfhN7lKK.mjs";
7
4
  import { z } from "zod";
8
5
  //#region src/api/routes.ts
9
6
  /**
@@ -70,7 +67,7 @@ const PostBody = z.object({
70
67
  channel: ChannelPath.optional(),
71
68
  re: Ref.optional(),
72
69
  /** May be empty when the message has attachments. */
73
- text: z.string().max(MESSAGE_TEXT_MAX).default(""),
70
+ text: z.string().default(""),
74
71
  labels: Labels.optional(),
75
72
  noSync: z.boolean().optional(),
76
73
  /**
@@ -80,7 +77,7 @@ const PostBody = z.object({
80
77
  sync: z.array(z.union([z.string().min(3).max(300), ResolvedSyncTarget])).max(10).optional(),
81
78
  id: z.string().min(1).max(200).refine(storable, "id has a NUL character or a lone surrogate").optional(),
82
79
  /** IDs from `POST /attachments`. */
83
- attachments: z.array(AttachmentId).max(10).optional(),
80
+ attachments: z.array(AttachmentId).optional(),
84
81
  /**
85
82
  * A reply's precondition: a message in its thread, the newest as the caller read it. If another
86
83
  * has come after it, nothing is posted, and the board answers 409 `newer_message`.
@@ -105,10 +102,10 @@ const Instant = z.string().datetime({ offset: true });
105
102
  const ScheduleBody = z.object({
106
103
  channel: ChannelPath.optional(),
107
104
  re: Ref.optional(),
108
- text: z.string().max(MESSAGE_TEXT_MAX).default(""),
105
+ text: z.string().default(""),
109
106
  labels: Labels.optional(),
110
107
  noSync: z.boolean().optional(),
111
- attachments: z.array(AttachmentId).max(10).optional(),
108
+ attachments: z.array(AttachmentId).optional(),
112
109
  in: Duration.optional(),
113
110
  at: Instant.optional(),
114
111
  every: Duration.optional(),
@@ -178,7 +175,7 @@ const PrincipalInput = z.discriminatedUnion("kind", [
178
175
  z.strictObject({ kind: z.literal("everyone") })
179
176
  ]);
180
177
  /** What a grant lets its principals do: a map from channel pattern to `'all'` or a list, `[]` for none. Kept as written. */
181
- const GrantCan = z.record(z.string().min(1).max(300), CanGrant);
178
+ const GrantCan = z.record(z.string().min(1).max(CHANNEL_PATTERN_MAX), CanGrant);
182
179
  /** A grant: who it names, and one `can` for all of them. The same principals again are another grant. */
183
180
  const GrantBody = z.strictObject({
184
181
  principals: z.array(PrincipalInput).min(1).max(32),
@@ -221,9 +218,9 @@ const UpdateGrantBody = z.strictObject({
221
218
  * Strict, so a board that doesn't know a field refuses it: what it kept could never be changed.
222
219
  */
223
220
  const SchemaBody = z.strictObject({
224
- name: z.string().regex(SCHEMA_NAME, "a schema name is up to 80 lowercase letters, numbers, and ._-, starting with a letter"),
225
- version: z.number().int().min(1).max(SCHEMA_VERSION_MAX),
226
- description: z.string().min(1).max(SCHEMA_DESCRIPTION_MAX).refine(storable, "a description has a NUL character or a lone surrogate").optional(),
221
+ name: z.string().regex(/^[a-z][a-z0-9._-]*$/, "a schema name is lowercase letters, numbers, and ._-, starting with a letter"),
222
+ version: z.number().int().min(1),
223
+ description: z.string().min(1).refine(storable, "a description has a NUL character or a lone surrogate").optional(),
227
224
  schema: z.record(z.string(), z.unknown())
228
225
  });
229
226
  const SyncBody = z.object({ target: z.string().min(3).max(300) });
@@ -428,7 +425,6 @@ const SyncFindQuery = z.object({
428
425
  message: z.string().min(1).max(300).optional()
429
426
  });
430
427
  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
428
  const InboxPushBody = z.object({ events: z.array(z.object({
433
429
  id: z.string().min(1).max(300),
434
430
  event: ExternalEvent,
@@ -450,12 +446,12 @@ const UploadStartBody = z.object({
450
446
  sha256: z.string().regex(/^[A-Za-z0-9+/]{43}=$/, "sha256 is the base64 SHA-256 of the bytes").optional()
451
447
  });
452
448
  const EditBody = z.object({
453
- text: MessageText,
449
+ text: SentText,
454
450
  revision: Revision.optional()
455
451
  });
456
452
  const DeleteBody = z.object({ revision: Revision.optional() }).optional();
457
453
  /** `status`: what Slack shows in place of "Typing…" (other platforms ignore it). */
458
- const TypingBody = z.object({ status: z.string().trim().min(1).max(100).optional() }).optional();
454
+ const TypingBody = z.object({ status: z.string().trim().min(1).max(50).optional() }).optional();
459
455
  const ReactBody = z.object({
460
456
  emoji: Emoji,
461
457
  remove: z.boolean().optional()
@@ -756,423 +752,4 @@ const routes = {
756
752
  }
757
753
  };
758
754
  //#endregion
759
- //#region src/version.ts
760
- const VERSION = "0.43.1";
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 };
755
+ 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 };
@@ -1206,6 +1206,8 @@ declare const SyncCopiesQuery: z.ZodObject<{
1206
1206
  message: z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>;
1207
1207
  }, z.core.$strip>;
1208
1208
  /** Platform events for a sync key's inbox, each with the platform's own ID for it, which dedupes it. */
1209
+ /** The longest inbox event ID a board takes: Vercel's API refuses a longer one. */
1210
+ declare const INBOX_EVENT_ID_MAX = 300;
1209
1211
  declare const InboxPushBody: z.ZodObject<{
1210
1212
  events: z.ZodArray<z.ZodObject<{
1211
1213
  id: z.ZodString;
@@ -1618,6 +1620,11 @@ type Discovery = {
1618
1620
  audience: string;
1619
1621
  team_id: string | null;
1620
1622
  project_id: string | null;
1623
+ /**
1624
+ * The board's name, where boards have one: a team's board in Vercel's API (`General`, the default's).
1625
+ * A handle on one says it, for a UI to show which board it's on; `GET /` on a board never does.
1626
+ */
1627
+ name?: string;
1621
1628
  /** The board's sync entries: `key` names its webhook and inbox, `platform` is e.g. `slack`. */
1622
1629
  sync: {
1623
1630
  key: string;
@@ -2670,4 +2677,4 @@ declare const routes: {
2670
2677
  };
2671
2678
  type RouteName = keyof typeof routes;
2672
2679
  //#endregion
2673
- export { ScheduleBodyOutput as $, union as $t, LinkView as A, TypingBody as At, PostBody as B, ChannelPattern as Bt, InboxEntry as C, SyncThreadView as Ct, InboxQuery as D, ThreadsPage as Dt, InboxPushBody as E, ThreadView as Et, MessageView as F, UploadTicket as Ft, ReactBody as G, GrantShape as Gt, PrincipalInput as H, Grant as Ht, MessagesPage as I, routes as It, RegisterInput as J, Permission as Jt, Ref as K, InvalidCan as Kt, MessagesQuery as L, Access as Lt, MatchView as M, UpdateGrantBody as Mt, MatchesQuery as N, UpdateGrantInput as Nt, LABEL_CONDITIONS_MAX as O, ThreadsQuery as Ot, Me as P, UploadStartBody as Pt, ScheduleBody as Q, parseCan as Qt, MessagesQueryInput as R, AccessSummary as Rt, InboxAckBody as S, SyncReceiptInput as St, InboxNextQuery as T, ThreadSummaryView as Tt, PrincipalView as U, GrantChange as Ut, PostInput as V, FULL_ACCESS as Vt, REGISTERED_WATCHERS_MAX as W, GrantChangeRefusal as Wt, ResolvedSyncTarget as X, checkGrantChange as Xt, RegistrationView as Y, WrittenCan as Yt, RouteName as Z, compileAccess as Zt, FiltersInput as _, SyncFindQuery as _t, BoardEventView as a, Labels as an, SchemaBody as at, GrantInput as b, SyncImportInput as bt, CreateChannelBody as c, ExternalFile as cn, SourceJoin as ct, EditBody as d, SourceRead as dt, Actor as en, ScheduleInput as et, EventsPage as f, SourceReadQuery as ft, Explanation as g, SyncFindInput as gt, ExplainQuery as h, SyncCopiesView as ht, BlockView as i, CAN_MAX as in, SchedulesQueryOutput as it, LinkedQuery as j, TypingResult as jt, LabelBody as k, ThreadsQueryInput as kt, DeleteBody as l, ExternalLink as ln, SourceJoinBody as lt, EventsQueryInput as m, SyncCopiesQuery as mt, ActorView as n, Attachment as nn, SchedulesQuery as nt, CanAt as o, ExternalAuthor as on, SchemaInput as ot, EventsQuery as p, SyncBody as pt, RegisterBody as q, Level as qt, ApiError as r, Author as rn, SchedulesQueryInput as rt, ChannelView as s, ExternalEvent as sn, SchemaView as st, AckBody as t, ExternalCopy as tn, ScheduleView as tt, Discovery as u, Link as un, SourceMessage as ut, GrantBody as v, SyncFindView as vt, InboxItem as w, SyncedView as wt, GrantView as x, SyncReceiptBody as xt, GrantCan as y, SyncImportBody as yt, ParsedFilters as z, Can as zt };
2680
+ export { ScheduleBody as $, compileAccess as $t, LabelBody as A, ThreadsQueryInput as At, ParsedFilters as B, Can as Bt, InboxAckBody as C, SyncReceiptInput as Ct, InboxPushBody as D, ThreadView as Dt, InboxNextQuery as E, ThreadSummaryView as Et, Me as F, UploadStartBody as Ft, REGISTERED_WATCHERS_MAX as G, GrantChangeRefusal as Gt, PostInput as H, FULL_ACCESS as Ht, MessageView as I, UploadTicket as It, RegisterBody as J, Level as Jt, ReactBody as K, GrantShape as Kt, MessagesPage as L, routes as Lt, LinkedQuery as M, TypingResult as Mt, MatchView as N, UpdateGrantBody as Nt, InboxQuery as O, ThreadsPage as Ot, MatchesQuery as P, UpdateGrantInput as Pt, RouteName as Q, checkGrantChange as Qt, MessagesQuery as R, Access as Rt, INBOX_EVENT_ID_MAX as S, SyncReceiptBody as St, InboxItem as T, SyncedView as Tt, PrincipalInput as U, Grant as Ut, PostBody as V, ChannelPattern as Vt, PrincipalView as W, GrantChange as Wt, RegistrationView as X, Permission as Xt, RegisterInput as Y, PERMISSIONS as Yt, ResolvedSyncTarget as Z, WrittenCan as Zt, FiltersInput as _, SyncFindInput as _t, BoardEventView as a, Author as an, SchedulesQueryOutput as at, GrantInput as b, SyncImportBody as bt, CreateChannelBody as c, ExternalAuthor as cn, SchemaView as ct, EditBody as d, ExternalLink as dn, SourceMessage as dt, parseCan as en, ScheduleBodyOutput as et, EventsPage as f, Link as fn, SourceRead as ft, Explanation as g, SyncCopiesView as gt, ExplainQuery as h, SyncCopiesQuery as ht, BlockView as i, Attachment as in, SchedulesQueryInput as it, LinkView as j, TypingBody as jt, LABEL_CONDITIONS_MAX as k, ThreadsQuery as kt, DeleteBody as l, ExternalEvent as ln, SourceJoin as lt, EventsQueryInput as m, SyncBody as mt, ActorView as n, Actor as nn, ScheduleView as nt, CanAt as o, CAN_MAX as on, SchemaBody as ot, EventsQuery as p, SourceReadQuery as pt, Ref as q, InvalidCan as qt, ApiError as r, ExternalCopy as rn, SchedulesQuery as rt, ChannelView as s, Labels as sn, SchemaInput as st, AckBody as t, union as tn, ScheduleInput as tt, Discovery as u, ExternalFile as un, SourceJoinBody as ut, GrantBody as v, SyncFindQuery as vt, InboxEntry as w, SyncThreadView as wt, GrantView as x, SyncImportInput as xt, GrantCan as y, SyncFindView as yt, MessagesQueryInput as z, AccessSummary as zt };
@@ -1,10 +1,14 @@
1
1
  import { z } from "zod";
2
+ //#region src/contract/schemas.ts
3
+ const CHANNEL_PATH_MAX = 2048;
4
+ /** A grant's channel pattern: a path, or a path and its subtree (`ops/`). */
5
+ const CHANNEL_PATTERN_MAX = 2049;
2
6
  const MESSAGE_TEXT_MAX = 1e4;
3
7
  /** The longest `x-board-can` header the board reads; a schedule keeps its creator's. */
4
8
  const CAN_MAX = 4e3;
5
9
  const segment = "[a-z0-9][a-z0-9_-]*";
6
10
  /** `errors-www`, `www/production`: lowercase segments joined by `/`. */
7
- const ChannelPath = z.string().max(80).regex(new RegExp(`^${segment}(?:/${segment})*$`), "invalid channel path");
11
+ const ChannelPath = z.string().max(CHANNEL_PATH_MAX).regex(new RegExp(`^${segment}(?:/${segment})*$`), "invalid channel path");
8
12
  /**
9
13
  * No board string holds a NUL, which Postgres can't store, or a lone surrogate,
10
14
  * which no store keeps as it was: requests with one are refused, and sync
@@ -13,6 +17,8 @@ const ChannelPath = z.string().max(80).regex(new RegExp(`^${segment}(?:/${segmen
13
17
  const storable = (value) => !value.includes("\0") && value.isWellFormed();
14
18
  /** `value` as the board keeps it, for what comes in from a platform: without NUL, and a lone surrogate as U+FFFD. */
15
19
  const toStorable = (value) => value.replaceAll("\0", "").toWellFormed();
20
+ /** A message's text as a request sends it: its length is the backend's to judge. */
21
+ const SentText = z.string().refine((text) => text.trim().length > 0, "message text is empty").refine(storable, "message text has a NUL character or a lone surrogate");
16
22
  const MessageText = z.string().max(MESSAGE_TEXT_MAX).refine((text) => text.trim().length > 0, "message text is empty").refine(storable, "message text has a NUL character or a lone surrogate");
17
23
  /** A message is named by the log index of its `message.posted` event. */
18
24
  const MessageId = z.number().int().positive();
@@ -74,4 +80,4 @@ const Attachment = z.object({
74
80
  /** A registered watcher's ID: a profile name, since its writes are by that profile. */
75
81
  const RemoteWatcherId = z.string().regex(/^[A-Za-z][A-Za-z0-9-]{0,31}$/, "ids start with a letter and use up to 32 letters, numbers, and hyphens");
76
82
  //#endregion
77
- export { actorKind as _, CAN_MAX as a, storable as b, Handle as c, Labels as d, MESSAGE_TEXT_MAX as f, SeenActorKind as g, RemoteWatcherId as h, Author as i, LabelKey as l, MessageText as m, Attachment as n, ChannelPath as o, MessageId as p, AttachmentId as r, Emoji as s, ActorId as t, LabelValue as u, authorView as v, toStorable as x, platformAvatar as y };
83
+ export { toStorable as C, storable as S, SeenActorKind as _, CAN_MAX as a, authorView as b, Emoji as c, LabelValue as d, Labels as f, RemoteWatcherId as g, MessageText as h, Author as i, Handle as l, MessageId as m, Attachment as n, CHANNEL_PATTERN_MAX as o, MESSAGE_TEXT_MAX as p, AttachmentId as r, ChannelPath as s, ActorId as t, LabelKey as u, SentText as v, platformAvatar as x, actorKind 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-C-Cq80hz.mjs";
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
- import { u as BoardError } from "./errors-DUzpDSrJ.mjs";
2
- import { d as localTokenFile, t as board } from "./server-BHpUqip5.mjs";
3
- import { t as oidcTokens } from "./tokens-BSMpTPEe.mjs";
4
- import { t as local } from "./local-yB2DFcRi.mjs";
1
+ import { d as BoardError } from "./errors-ZazTZh-s.mjs";
2
+ import { d as localTokenFile, t as board } from "./server-CcvxkXzG.mjs";
3
+ import { t as oidcTokens } from "./tokens-BErYXuHZ.mjs";
4
+ import { t as local } from "./local-Bel_oeFa.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
- import { d as createBoardClient, p as formatProfileHeader, t as HttpError, u as BoardError } from "./errors-DUzpDSrJ.mjs";
2
- import "./schemas-DAzSsgWk.mjs";
3
- import { Y as routes, a as compileWatcher, c as METHODS } from "./origin-9Ch-Zonv.mjs";
4
- import { g as keyId, p as DERIVED_ID } from "./middleware-0DUFrav-.mjs";
5
- import { c as tailWatchers, i as createVercel, l as deployedOnVercel, o as PROTOCOL_ROUTES, s as withoutToken, t as createBoard } from "./exports-BVgUNVsP.mjs";
1
+ import { d as BoardError, f as createBoardClient, h as formatProfileHeader, t as HttpError } from "./errors-ZazTZh-s.mjs";
2
+ import "./schemas-BhZaystC.mjs";
3
+ import { F as routes } from "./routes-CkUetTO2.mjs";
4
+ import { g as keyId, p as DERIVED_ID } from "./middleware-BHHKHA9q.mjs";
5
+ import { a as compileWatcher, c as METHODS } from "./origin-BHmEdok7.mjs";
6
+ import { c as tailWatchers, i as createVercel, l as deployedOnVercel, o as PROTOCOL_ROUTES, s as withoutToken, t as createBoard } from "./exports-DCf75prP.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,8 +989,8 @@ 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-BVHSH2Kn.mjs"),
992
- serving: () => import("./serving-hcxzaCCO.mjs"),
992
+ sync: () => import("./engine-XVBt02Bl.mjs"),
993
+ serving: () => import("./serving-BLVRrJ7P.mjs"),
993
994
  sandbox: (url, token) => sandboxHeaders(url, url, token)
994
995
  });
995
996
  }
@@ -1,2 +1,2 @@
1
- import { i as ownTeamId, n as discoveryIdentity, r as ownProjectId, t as oidcTokens } from "./tokens-BSMpTPEe.mjs";
1
+ import { i as ownTeamId, n as discoveryIdentity, r as ownProjectId, t as oidcTokens } from "./tokens-BErYXuHZ.mjs";
2
2
  export { discoveryIdentity, oidcTokens, ownProjectId, ownTeamId };
@@ -1,5 +1,5 @@
1
- import { _ as actorKind } from "./schemas-DAzSsgWk.mjs";
2
- import { c as externalMessageKey, l as isThreadTarget } from "./external-DymyhUzl.mjs";
1
+ import { y as actorKind } from "./schemas-BhZaystC.mjs";
2
+ import { c as externalMessageKey, l as isThreadTarget } from "./external-DfhN7lKK.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
5
  import { i as mentionTerms } from "./mentions-DfZGp3B-.mjs";
@@ -1,6 +1,6 @@
1
- import { r as sqlTables } from "./sql-P9g-rLIF.mjs";
1
+ import { r as sqlTables } from "./sql-CyVcjw8x.mjs";
2
2
  import { t as sqlite$1 } from "./store-sqlite-D6fIszST.mjs";
3
- import { t as sqliteDb } from "./sqlite-db-D0Fyju-4.mjs";
3
+ import { t as sqliteDb } from "./sqlite-db-BdzxtUOV.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
@@ -1,4 +1,4 @@
1
- import { n as ddl } from "./sql-P9g-rLIF.mjs";
1
+ import { n as ddl } from "./sql-CyVcjw8x.mjs";
2
2
  import { mkdirSync } from "node:fs";
3
3
  import { dirname, resolve } from "node:path";
4
4
  //#region src/store/sqlite-db.ts