spur-board 0.60.0 → 0.61.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/daemon.mjs +68 -21
- package/package.json +1 -1
package/dist/daemon.mjs
CHANGED
|
@@ -8871,11 +8871,28 @@ const exchange = z.strictObject({
|
|
|
8871
8871
|
answeredBy: z.string().min(1),
|
|
8872
8872
|
outcome: z.literal("unblocked")
|
|
8873
8873
|
});
|
|
8874
|
+
/** One piece of a feed line: plain text, or a command shown as code on one line. */
|
|
8875
|
+
const segment = z.discriminatedUnion("kind", [z.strictObject({
|
|
8876
|
+
kind: z.literal("text"),
|
|
8877
|
+
text: z.string()
|
|
8878
|
+
}), z.strictObject({
|
|
8879
|
+
kind: z.literal("code"),
|
|
8880
|
+
text: z.string().regex(/^[^\n]+$/)
|
|
8881
|
+
})]);
|
|
8882
|
+
/** The plain summary of `segments`: what is scanned, stored on the item and struck. */
|
|
8883
|
+
function feedText(segments) {
|
|
8884
|
+
return segments.map((part) => part.text).join("");
|
|
8885
|
+
}
|
|
8886
|
+
/** `segments`, when set, is the line's rich form of `text`; a mismatch is never sent. */
|
|
8874
8887
|
const feedLineWithLinkPayload = feedLinePayload.extend({
|
|
8875
8888
|
itemId: id.optional(),
|
|
8876
8889
|
url: z.url().optional(),
|
|
8877
8890
|
actions: z.array(actionPayload).optional(),
|
|
8878
|
-
exchange: exchange.optional()
|
|
8891
|
+
exchange: exchange.optional(),
|
|
8892
|
+
segments: z.array(segment).optional()
|
|
8893
|
+
}).refine((line) => line.segments === void 0 || line.text === feedText(line.segments), {
|
|
8894
|
+
message: "text does not match segments",
|
|
8895
|
+
path: ["text"]
|
|
8879
8896
|
});
|
|
8880
8897
|
const doorbellPayload = z.strictObject({
|
|
8881
8898
|
session: z.string().min(1),
|
|
@@ -9072,7 +9089,8 @@ async function enqueueFeedLine(trx, input) {
|
|
|
9072
9089
|
itemId: input.itemId,
|
|
9073
9090
|
taskId: input.taskId ?? void 0,
|
|
9074
9091
|
...input.url === "" ? {} : { url: input.url },
|
|
9075
|
-
actions: input.actions
|
|
9092
|
+
actions: input.actions,
|
|
9093
|
+
...input.segments === void 0 ? {} : { segments: input.segments }
|
|
9076
9094
|
},
|
|
9077
9095
|
parent: null,
|
|
9078
9096
|
at: input.at
|
|
@@ -9114,7 +9132,8 @@ async function enqueueBoardFeedLine(trx, input) {
|
|
|
9114
9132
|
role: "board"
|
|
9115
9133
|
},
|
|
9116
9134
|
itemKey: input.itemKey,
|
|
9117
|
-
...input.actions === void 0 ? {} : { actions: input.actions }
|
|
9135
|
+
...input.actions === void 0 ? {} : { actions: input.actions },
|
|
9136
|
+
...input.segments === void 0 ? {} : { segments: input.segments }
|
|
9118
9137
|
},
|
|
9119
9138
|
parent: null,
|
|
9120
9139
|
at: input.at
|
|
@@ -9233,17 +9252,28 @@ async function blockPost(trx, row, payload, rule) {
|
|
|
9233
9252
|
const taskId = "taskId" in payload && typeof payload.taskId === "number" ? payload.taskId : null;
|
|
9234
9253
|
const blockId = "blockId" in payload && typeof payload.blockId === "number" ? payload.blockId : null;
|
|
9235
9254
|
const task = taskId === null ? null : await trx.selectFrom("task").selectAll().where("id", "=", taskId).executeTakeFirstOrThrow();
|
|
9255
|
+
const head = `text on ${safeKey} not sent: looks like a secret (${rule}), read `;
|
|
9256
|
+
const segments = typeof payload.key === "string" && safeKey === payload.key ? [{
|
|
9257
|
+
kind: "text",
|
|
9258
|
+
text: head
|
|
9259
|
+
}, {
|
|
9260
|
+
kind: "code",
|
|
9261
|
+
text: `board task ${safeKey}`
|
|
9262
|
+
}] : void 0;
|
|
9236
9263
|
await raiseItemWith(trx, {
|
|
9237
9264
|
itemKey: `secret-post:${createHash("sha256").update(row.dedupeKey).digest("hex")}`,
|
|
9238
9265
|
kind: "post_blocked",
|
|
9239
|
-
text:
|
|
9266
|
+
text: `${head}board task ${safeKey}`,
|
|
9240
9267
|
url: task === null ? "" : taskUrl(task, scanConfig()),
|
|
9241
9268
|
taskId,
|
|
9242
9269
|
blockId,
|
|
9243
9270
|
at: row.at,
|
|
9244
9271
|
rule,
|
|
9245
9272
|
source: row.kind
|
|
9246
|
-
}, enqueueFeedLine)
|
|
9273
|
+
}, segments === void 0 ? enqueueFeedLine : (t, line) => enqueueFeedLine(t, {
|
|
9274
|
+
...line,
|
|
9275
|
+
segments
|
|
9276
|
+
}));
|
|
9247
9277
|
}
|
|
9248
9278
|
/**
|
|
9249
9279
|
* Scans a stored gateway row's payload again before it is resent, with the rules used at
|
|
@@ -9614,6 +9644,29 @@ function resolvedLine(by, at, config) {
|
|
|
9614
9644
|
}
|
|
9615
9645
|
];
|
|
9616
9646
|
}
|
|
9647
|
+
/**
|
|
9648
|
+
* A feed line: its key, linked when it has a url, then its segments, or its text, as a quote.
|
|
9649
|
+
*/
|
|
9650
|
+
function feedLineBody(payload) {
|
|
9651
|
+
const { key, url, text, segments } = payload;
|
|
9652
|
+
return [{
|
|
9653
|
+
kind: "paragraph",
|
|
9654
|
+
children: [url === void 0 ? {
|
|
9655
|
+
kind: "text",
|
|
9656
|
+
text: key
|
|
9657
|
+
} : {
|
|
9658
|
+
kind: "link",
|
|
9659
|
+
url,
|
|
9660
|
+
text: key
|
|
9661
|
+
}]
|
|
9662
|
+
}, {
|
|
9663
|
+
kind: "quote",
|
|
9664
|
+
children: segments ?? [{
|
|
9665
|
+
kind: "text",
|
|
9666
|
+
text
|
|
9667
|
+
}]
|
|
9668
|
+
}];
|
|
9669
|
+
}
|
|
9617
9670
|
/** A cleared line: its key line, the struck summary and who resolved it when; no actions. */
|
|
9618
9671
|
function resolvedFeedBody(payload, config) {
|
|
9619
9672
|
const { key, url, text, resolved } = payload;
|
|
@@ -10712,11 +10765,18 @@ async function postTokenList(trx, input) {
|
|
|
10712
10765
|
}
|
|
10713
10766
|
const shown = rows.slice(0, lines.length);
|
|
10714
10767
|
const hidden = rows.length - shown.length;
|
|
10715
|
-
|
|
10768
|
+
const segments = hidden > 0 ? [{
|
|
10769
|
+
kind: "text",
|
|
10770
|
+
text: [...lines, `${String(hidden)} more: `].join("\n")
|
|
10771
|
+
}, {
|
|
10772
|
+
kind: "code",
|
|
10773
|
+
text: "board token list"
|
|
10774
|
+
}] : void 0;
|
|
10716
10775
|
await enqueueBoardFeedLine(trx, {
|
|
10717
10776
|
dedupeKey: `feed.line:token-list:${input.key}`,
|
|
10718
10777
|
itemKey: `token-list:${input.key}`,
|
|
10719
|
-
text: lines.join("\n"),
|
|
10778
|
+
text: segments === void 0 ? lines.join("\n") : feedText(segments),
|
|
10779
|
+
...segments === void 0 ? {} : { segments },
|
|
10720
10780
|
title: "Operator tokens",
|
|
10721
10781
|
actions: shown.map(({ row }) => revokeAction(row.item_id, row.name, `Revoke ${capPoints(row.name, LABEL_NAME)}`)),
|
|
10722
10782
|
at: input.at
|
|
@@ -12891,20 +12951,7 @@ function createSender(options) {
|
|
|
12891
12951
|
}, options.config) : c.body.kind === "feed.line" && c.body.payload.exchange !== void 0 ? exchangeBody({
|
|
12892
12952
|
...c.body.payload,
|
|
12893
12953
|
exchange: c.body.payload.exchange
|
|
12894
|
-
}) : c.body.kind === "feed.line"
|
|
12895
|
-
kind: "paragraph",
|
|
12896
|
-
children: [{
|
|
12897
|
-
kind: "link",
|
|
12898
|
-
url: c.body.payload.url,
|
|
12899
|
-
text: c.body.payload.key
|
|
12900
|
-
}]
|
|
12901
|
-
}, {
|
|
12902
|
-
kind: "quote",
|
|
12903
|
-
children: [{
|
|
12904
|
-
kind: "text",
|
|
12905
|
-
text: c.body.payload.text
|
|
12906
|
-
}]
|
|
12907
|
-
}] : renderBody(c.body.payload.key, c.body.payload.text),
|
|
12954
|
+
}) : c.body.kind === "feed.line" ? feedLineBody(c.body.payload) : renderBody(c.body.payload.key, c.body.payload.text),
|
|
12908
12955
|
...(body.kind === "feed.line" || body.kind === "feed.line.edit") && body.payload.actions !== void 0 ? { actions: body.payload.actions } : {}
|
|
12909
12956
|
};
|
|
12910
12957
|
return {
|