@tidegap/core 0.22.0 → 0.24.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/channels/commands.js +3 -2
- package/dist/channels/digest.d.ts +4 -1
- package/dist/channels/digest.js +6 -2
- package/dist/channels/format.d.ts +44 -19
- package/dist/channels/format.js +113 -77
- package/dist/channels/index.d.ts +1 -0
- package/dist/channels/index.js +1 -0
- package/dist/channels/kinds/discord.js +2 -2
- package/dist/channels/kinds/email.js +2 -1
- package/dist/channels/kinds/ntfy.js +9 -1
- package/dist/channels/kinds/pushover.js +4 -3
- package/dist/channels/kinds/shared.d.ts +4 -1
- package/dist/channels/kinds/shared.js +6 -1
- package/dist/channels/kinds/slack.js +2 -2
- package/dist/channels/notice.d.ts +42 -0
- package/dist/channels/notice.js +142 -0
- package/dist/channels/payload.d.ts +3 -0
- package/dist/channels/payload.js +16 -5
- package/dist/channels/telegram.d.ts +31 -1
- package/dist/channels/telegram.js +34 -12
- package/dist/history.d.ts +101 -0
- package/dist/history.js +95 -0
- package/dist/index.d.ts +8 -6
- package/dist/index.js +6 -4
- package/dist/jobs.d.ts +53 -5
- package/dist/jobs.js +279 -42
- package/dist/notice-language.d.ts +37 -0
- package/dist/notice-language.js +67 -0
- package/dist/providers/base.d.ts +7 -0
- package/dist/redact.d.ts +3 -2
- package/dist/redact.js +8 -2
- package/dist/schedule-job.d.ts +3 -2
- package/dist/schedule-job.js +6 -5
- package/dist/scheduler.d.ts +9 -1
- package/dist/scheduler.js +13 -5
- package/dist/storage/sqlite.js +7 -3
- package/dist/types.d.ts +14 -1
- package/dist/zone-time.d.ts +2 -0
- package/dist/zone-time.js +11 -0
- package/package.json +2 -2
|
@@ -225,10 +225,11 @@ async function runJobAction(action, ref, ctx, listing) {
|
|
|
225
225
|
}
|
|
226
226
|
if (action === "pause")
|
|
227
227
|
return `Paused: ${title}.`;
|
|
228
|
-
if (action === "run")
|
|
229
|
-
return `Runs at the next tick: ${title}.`;
|
|
230
228
|
const after = ctx.getJob(job.jobId);
|
|
231
229
|
const next = after?.pendingTaskId ? jobNextLabel(after, ctx.getTask(after.pendingTaskId), ctx.now()) : undefined;
|
|
230
|
+
// An extra run: the planned run keeps its time.
|
|
231
|
+
if (action === "run")
|
|
232
|
+
return next && next !== JOB_RUNNING_NOW ? `Runs at the next tick: ${title}. The planned run stays: next ${next}.` : `Runs at the next tick: ${title}.`;
|
|
232
233
|
if (next === JOB_RUNNING_NOW)
|
|
233
234
|
return `Resumed: ${title}. A run is in progress.`;
|
|
234
235
|
return next ? `Resumed: ${title}. Next ${next}.` : `Resumed: ${title}.`;
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { type ReadinessProblem } from "../readiness.js";
|
|
11
11
|
import type { TaskRecord } from "../types.js";
|
|
12
|
+
import { type NoticeStatus } from "./notice.js";
|
|
12
13
|
import type { ChannelEvent, CleanWindowEvent } from "./types.js";
|
|
13
14
|
/**
|
|
14
15
|
* Ledger meta key: ISO-8601 end of the last summary window. An empty day
|
|
@@ -69,6 +70,8 @@ export interface DigestInput {
|
|
|
69
70
|
/** One job in the daily summary; the host builds it from the job and its finished runs in the window. */
|
|
70
71
|
export interface JobDigestLine {
|
|
71
72
|
title: string;
|
|
73
|
+
/** The newest finished run's notice status; the line starts with its emoji. */
|
|
74
|
+
status: NoticeStatus;
|
|
72
75
|
/** Finished runs in the window. */
|
|
73
76
|
runs: number;
|
|
74
77
|
/** Failed runs among them. */
|
|
@@ -87,7 +90,7 @@ export interface JobDigestLine {
|
|
|
87
90
|
/** The runs this line reports; their alerts fold into the summary only when the line is printed. */
|
|
88
91
|
coveredTaskIds: readonly string[];
|
|
89
92
|
}
|
|
90
|
-
/**
|
|
93
|
+
/** `✅ Mail triage: ok 03:12, "3 messages need a reply..." - next Fri 02:00` (KTD11). */
|
|
91
94
|
export declare function jobDigestText(job: JobDigestLine): string;
|
|
92
95
|
/** The digest event, with what it covers so per-task alerts can fold into it. */
|
|
93
96
|
export type DigestEvent = Extract<ChannelEvent, {
|
package/dist/channels/digest.js
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { localTimeLabel, MORNING_START_H } from "../postpone.js";
|
|
11
11
|
import { problemLine } from "../readiness.js";
|
|
12
|
-
import {
|
|
12
|
+
import { messageTitle } from "./format.js";
|
|
13
|
+
import { cutPreview, NOTICE_EMOJI } from "./notice.js";
|
|
13
14
|
/**
|
|
14
15
|
* Ledger meta key: ISO-8601 end of the last summary window. An empty day
|
|
15
16
|
* moves it too, so it is not proof of a send; see {@link DIGEST_SENT_META_KEY}.
|
|
@@ -57,8 +58,11 @@ export function digestDue(now, lastIso, at = DEFAULT_DIGEST_AT) {
|
|
|
57
58
|
}
|
|
58
59
|
/** Most characters (code points, ellipsis included) of a run preview a job line quotes. */
|
|
59
60
|
const JOB_PREVIEW_CHARS = 100;
|
|
60
|
-
/**
|
|
61
|
+
/** `✅ Mail triage: ok 03:12, "3 messages need a reply..." - next Fri 02:00` (KTD11). */
|
|
61
62
|
export function jobDigestText(job) {
|
|
63
|
+
return `${NOTICE_EMOJI[job.status]} ${jobDigestBody(job)}`;
|
|
64
|
+
}
|
|
65
|
+
function jobDigestBody(job) {
|
|
62
66
|
const { last } = job;
|
|
63
67
|
const when = last.late ? `ran late at ${last.at}` : `${last.outcome} ${last.at}`;
|
|
64
68
|
const preview = last.preview?.replace(/\s+/g, " ").trim();
|
|
@@ -18,23 +18,33 @@
|
|
|
18
18
|
* | not ready | none |
|
|
19
19
|
* | replies and `/result` | none |
|
|
20
20
|
*/
|
|
21
|
+
import { type TaskAttachment } from "../history.js";
|
|
21
22
|
import { type PostponeOption, type PostponePreset } from "../postpone.js";
|
|
22
23
|
import { type ReadinessProblem } from "../readiness.js";
|
|
23
24
|
import type { JobRecord, TaskRecord } from "../types.js";
|
|
24
25
|
import { type InlineKeyboard } from "./telegram.js";
|
|
26
|
+
import { type NoticeStatus, type StructuredSummary } from "./notice.js";
|
|
25
27
|
import type { ChannelEvent, CleanWindowEvent, JobEndedNotice, JobPausedNotice } from "./types.js";
|
|
26
28
|
/** Characters of result text a done message previews (Q4). */
|
|
27
29
|
export declare const TELEGRAM_PREVIEW_CHARS = 600;
|
|
30
|
+
/** Longest `📎` line: with the title, the time and a full preview, a notice still fits the smallest body cap (Pushover, 1024). */
|
|
31
|
+
export declare const ATTACHMENT_LINE_CHARS = 300;
|
|
28
32
|
/** Most messages one `/result` sends before pointing to `tidegap queue show`. */
|
|
29
33
|
export declare const RESULT_MAX_PARTS = 4;
|
|
30
34
|
/** Tasks one `/queue` lists. */
|
|
31
35
|
export declare const QUEUE_LIST_MAX = 10;
|
|
32
36
|
/** Jobs one `/jobs` lists; the same cap as the digest's lists. */
|
|
33
37
|
export declare const JOBS_LIST_MAX = 10;
|
|
34
|
-
/**
|
|
38
|
+
/** The stored files a host sends after a message's text (Telegram only), from {@link sendableAttachments}. */
|
|
39
|
+
export interface OutgoingFiles {
|
|
40
|
+
taskId: string;
|
|
41
|
+
attachments: readonly TaskAttachment[];
|
|
42
|
+
}
|
|
43
|
+
/** A message a host sends: text, optional inline buttons, and optional files to send after it. */
|
|
35
44
|
export interface OutgoingMessage {
|
|
36
45
|
text: string;
|
|
37
46
|
buttons?: InlineKeyboard;
|
|
47
|
+
files?: OutgoingFiles;
|
|
38
48
|
}
|
|
39
49
|
/** Button actions in `callback_data` (KTD15). */
|
|
40
50
|
export type CallbackActionName = "later" | "cancel" | "run" | "result";
|
|
@@ -49,8 +59,6 @@ export declare function callbackFits(taskId: string): boolean;
|
|
|
49
59
|
/** The decoding tables, for `parseCallback`. */
|
|
50
60
|
export declare const CALLBACK_ACTIONS: Readonly<Record<string, CallbackActionName>>;
|
|
51
61
|
export declare const CALLBACK_PRESETS: Readonly<Record<string, PostponePreset>>;
|
|
52
|
-
/** True when the task asked for receipt redaction (`redactInReceipt` with patterns): no result text leaves the machine. */
|
|
53
|
-
export declare function isRedactedTask(record: TaskRecord<unknown>): boolean;
|
|
54
62
|
/**
|
|
55
63
|
* The one-line preview of a run, the same on the jobs page and in the
|
|
56
64
|
* digest (KTD6): a failed task's first error line with visible text, a
|
|
@@ -60,41 +68,59 @@ export declare function isRedactedTask(record: TaskRecord<unknown>): boolean;
|
|
|
60
68
|
* code points plus "…", so the result never exceeds `maxChars`.
|
|
61
69
|
*/
|
|
62
70
|
export declare function runPreview(record: TaskRecord<unknown>, maxChars: number): string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* A run's summary in the notice shape, or undefined when the run has no
|
|
73
|
+
* usable summary: it failed, it redacts its receipt, it has no summary, or
|
|
74
|
+
* the summary has no verdict. The summary is default-redacted first.
|
|
75
|
+
*/
|
|
76
|
+
export declare function runSummary(record: TaskRecord<unknown>): StructuredSummary | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* The status of a job run's notice: `failed` for a failed run; for a
|
|
79
|
+
* completed run, the status word of its usable summary, else `done`. A
|
|
80
|
+
* final notice is `ended`, which the caller sets.
|
|
81
|
+
*/
|
|
82
|
+
export declare function noticeStatus(record: TaskRecord<unknown>): NoticeStatus;
|
|
63
83
|
/**
|
|
64
84
|
* A run's verdict, the one line a person reads first: for a completed run
|
|
65
|
-
* that does not redact its receipt, the
|
|
66
|
-
* its result text; for a failed run,
|
|
67
|
-
* `maxChars`; undefined when there is no such line.
|
|
85
|
+
* that does not redact its receipt, the verdict of its summary without the
|
|
86
|
+
* status word, else the first line of its result text; for a failed run,
|
|
87
|
+
* its first error line. Cut to `maxChars`; undefined when there is no such line.
|
|
68
88
|
*/
|
|
69
89
|
export declare function runVerdict(record: TaskRecord<unknown>, maxChars?: number): string | undefined;
|
|
70
|
-
/** `text` cut to `maxChars - 1` code points plus "…" when longer, so it never exceeds `maxChars` (KTD6). */
|
|
71
|
-
export declare function cutPreview(text: string, maxChars: number): string;
|
|
72
90
|
/** The title a message shows: `displayTitle`, one line, at most 80 characters, else the task id. */
|
|
73
91
|
export declare function messageTitle(record: TaskRecord<unknown>): string;
|
|
74
92
|
/** The title a task event's message shows: the job's title for a job occurrence, else {@link messageTitle}. */
|
|
75
93
|
export declare function eventTitle(record: TaskRecord<unknown>, jobTitle?: string): string;
|
|
76
94
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
95
|
+
* The line that names a run's attachments: `📎 funnel.png (48 KB), weekly.csv
|
|
96
|
+
* (2 KB), not attached: huge.png (over 10 MB)`. A redacted task names no
|
|
97
|
+
* file: `📎 2 files, not sent: this task redacts its receipt`. Undefined
|
|
98
|
+
* when the run has none.
|
|
99
|
+
*/
|
|
100
|
+
export declare function attachmentLine(record: TaskRecord<unknown>): string | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* Task done (R26): title, time, the attachments line, where it ran, the
|
|
103
|
+
* preview or the redaction note, and a [Result] button with the raw result;
|
|
104
|
+
* the run's sendable files go with it. A job occurrence
|
|
105
|
+
* (`jobTitle`) leads with `<status emoji> <job title> — <verdict>`, adds the job's next run
|
|
80
106
|
* (`jobNext`) to the time line, a `No summary` line when its summarize step
|
|
81
107
|
* failed, and shows its summary in place of the raw preview.
|
|
82
108
|
*/
|
|
83
109
|
export declare function taskDoneMessage(record: TaskRecord<unknown>, now?: Date, jobTitle?: string, jobNext?: string): OutgoingMessage;
|
|
84
110
|
/**
|
|
85
111
|
* Task failed: title, time, the first error line, the show command. No
|
|
86
|
-
* buttons. A job occurrence (`jobTitle`) leads with
|
|
112
|
+
* buttons. A job occurrence (`jobTitle`) leads with `❌ <job title>: failed`.
|
|
87
113
|
*/
|
|
88
114
|
export declare function taskFailedMessage(record: TaskRecord<unknown>, now?: Date, jobTitle?: string): OutgoingMessage;
|
|
89
115
|
/** The first line of an auto-pause notice (jobs KTD10): `job '<title>' paused after 3 failures: <reason>`. */
|
|
90
116
|
export declare function jobPausedTitle(notice: JobPausedNotice): string;
|
|
91
|
-
/** The auto-pause notice: the sentence, then how to resume. No buttons. */
|
|
117
|
+
/** The auto-pause notice: the failed emoji and the sentence, then how to resume. No buttons. */
|
|
92
118
|
export declare function jobPausedMessage(notice: JobPausedNotice): OutgoingMessage;
|
|
93
119
|
/** The first line of a job's final notice: `Job ended: "<title>"`. */
|
|
94
120
|
export declare function jobEndedTitle(notice: JobEndedNotice): string;
|
|
95
121
|
/** The body of a job's final notice: why it ended, then its last run with its verdict, or its first error line. */
|
|
96
122
|
export declare function jobEndedBody(notice: JobEndedNotice, last: TaskRecord<unknown>): string;
|
|
97
|
-
/** A job's final notice: the title line and the body. No buttons. */
|
|
123
|
+
/** A job's final notice: the ended emoji, the title line and the body. No buttons. */
|
|
98
124
|
export declare function jobEndedMessage(notice: JobEndedNotice, last: TaskRecord<unknown>): OutgoingMessage;
|
|
99
125
|
/** A clean window starting. No buttons. */
|
|
100
126
|
export declare function cleanWindowMessage(window: CleanWindowEvent, now?: Date): OutgoingMessage;
|
|
@@ -111,8 +137,6 @@ export declare function queueMessage(records: readonly TaskRecord<unknown>[], no
|
|
|
111
137
|
};
|
|
112
138
|
/** A job's title: one line, at most 80 characters, else the job id. */
|
|
113
139
|
export declare function jobTitle(job: JobRecord): string;
|
|
114
|
-
/** `HH:MM` in `timeZone` when `at` falls on the same day there as `now`, else `Ddd HH:MM`. */
|
|
115
|
-
export declare function zoneTimeLabel(at: Date, now: Date, timeZone: string): string;
|
|
116
140
|
/** The {@link jobNextLabel} of a job whose occurrence is running. */
|
|
117
141
|
export declare const JOB_RUNNING_NOW = "running now";
|
|
118
142
|
/**
|
|
@@ -134,9 +158,10 @@ export declare function laterMenuMessage(record: TaskRecord<unknown>, options: r
|
|
|
134
158
|
/** Split text into parts of at most `max` characters, preferring line breaks. */
|
|
135
159
|
export declare function splitMessage(text: string, max?: number): string[];
|
|
136
160
|
/**
|
|
137
|
-
* `/result` and the Result button (R27): no result text for a
|
|
138
|
-
* task; otherwise the result in parts of 4096 characters, at most
|
|
139
|
-
* {@link RESULT_MAX_PARTS}, then a pointer to `tidegap queue show
|
|
161
|
+
* `/result` and the Result button (R27): no result text and no file for a
|
|
162
|
+
* redacted task; otherwise the result in parts of 4096 characters, at most
|
|
163
|
+
* {@link RESULT_MAX_PARTS}, then a pointer to `tidegap queue show`; the
|
|
164
|
+
* run's sendable files go after the last part.
|
|
140
165
|
*/
|
|
141
166
|
export declare function resultMessages(record: TaskRecord<unknown>): OutgoingMessage[];
|
|
142
167
|
/** `/later` grammar (KTD15), quoted by `/help` and the reset-time reply. */
|
package/dist/channels/format.js
CHANGED
|
@@ -18,19 +18,22 @@
|
|
|
18
18
|
* | not ready | none |
|
|
19
19
|
* | replies and `/result` | none |
|
|
20
20
|
*/
|
|
21
|
-
import { displayTitle, stripControlChars, taskActions, taskResultText, taskSummaryError, taskSummaryText } from "../history.js";
|
|
22
|
-
import { JOB_AUTO_PAUSE_FAILURES, jobAutoPauseReason, jobEndText } from "../jobs.js";
|
|
21
|
+
import { displayTitle, formatBytes, isRedactedTask, sendableAttachments, stripControlChars, taskActions, taskAttachments, taskAttachmentsSkipped, taskResultText, taskSummaryError, taskSummaryText, } from "../history.js";
|
|
22
|
+
import { JOB_AUTO_PAUSE_FAILURES, jobAutoPauseReason, jobEndText, jobLastRun, jobNextRun, runOutcome } from "../jobs.js";
|
|
23
23
|
import { clip, firstErrorLine, oneLine } from "../notify.js";
|
|
24
24
|
import { localTimeLabel } from "../postpone.js";
|
|
25
25
|
import { problemLine, TICKER_CODES } from "../readiness.js";
|
|
26
|
-
import {
|
|
26
|
+
import { zoneTimeLabel } from "../zone-time.js";
|
|
27
27
|
import { redactPrompt } from "../redact.js";
|
|
28
28
|
import { freshReasonText, shortSessionId } from "../run-session.js";
|
|
29
29
|
import { TELEGRAM_CALLBACK_MAX_BYTES, TELEGRAM_MESSAGE_MAX } from "./telegram.js";
|
|
30
|
+
import { cutPreview, NOTICE_EMOJI, NOTICE_VERDICT_CHARS, stripBidiControls, structureSummary } from "./notice.js";
|
|
30
31
|
/** Characters of result text a done message previews (Q4). */
|
|
31
32
|
export const TELEGRAM_PREVIEW_CHARS = 600;
|
|
33
|
+
/** Longest `📎` line: with the title, the time and a full preview, a notice still fits the smallest body cap (Pushover, 1024). */
|
|
34
|
+
export const ATTACHMENT_LINE_CHARS = 300;
|
|
32
35
|
/** Most characters of the verdict a job's notice leads with. */
|
|
33
|
-
const VERDICT_CHARS =
|
|
36
|
+
const VERDICT_CHARS = NOTICE_VERDICT_CHARS;
|
|
34
37
|
/** Most messages one `/result` sends before pointing to `tidegap queue show`. */
|
|
35
38
|
export const RESULT_MAX_PARTS = 4;
|
|
36
39
|
/** Tasks one `/queue` lists. */
|
|
@@ -54,16 +57,6 @@ export function callbackFits(taskId) {
|
|
|
54
57
|
/** The decoding tables, for `parseCallback`. */
|
|
55
58
|
export const CALLBACK_ACTIONS = Object.fromEntries(Object.entries(ACTION_CODE).map(([name, code]) => [code, name]));
|
|
56
59
|
export const CALLBACK_PRESETS = Object.fromEntries(Object.entries(PRESET_CODE).map(([preset, code]) => [code, preset]));
|
|
57
|
-
/** True when the task asked for receipt redaction (`redactInReceipt` with patterns): no result text leaves the machine. */
|
|
58
|
-
export function isRedactedTask(record) {
|
|
59
|
-
try {
|
|
60
|
-
const spec = JSON.parse(record.bodyJson ?? "");
|
|
61
|
-
return Array.isArray(spec.redactInReceipt) && spec.redactInReceipt.length > 0;
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
60
|
/**
|
|
68
61
|
* The one-line preview of a run, the same on the jobs page and in the
|
|
69
62
|
* digest (KTD6): a failed task's first error line with visible text, a
|
|
@@ -80,10 +73,34 @@ export function runPreview(record, maxChars) {
|
|
|
80
73
|
text = oneLine(taskSummaryText(record) ?? taskResultText(record) ?? "");
|
|
81
74
|
return text ? cutPreview(text, maxChars) : undefined;
|
|
82
75
|
}
|
|
83
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* A run's summary in the notice shape, or undefined when the run has no
|
|
78
|
+
* usable summary: it failed, it redacts its receipt, it has no summary, or
|
|
79
|
+
* the summary has no verdict. The summary is default-redacted first.
|
|
80
|
+
*/
|
|
81
|
+
export function runSummary(record) {
|
|
82
|
+
if (record.status !== "completed" || isRedactedTask(record))
|
|
83
|
+
return undefined;
|
|
84
|
+
const summary = taskSummaryText(record);
|
|
85
|
+
if (!summary)
|
|
86
|
+
return undefined;
|
|
87
|
+
const structured = structureSummary(redactPrompt(summary, undefined));
|
|
88
|
+
return structured.verdict ? structured : undefined;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The status of a job run's notice: `failed` for a failed run; for a
|
|
92
|
+
* completed run, the status word of its usable summary, else `done`. A
|
|
93
|
+
* final notice is `ended`, which the caller sets.
|
|
94
|
+
*/
|
|
95
|
+
export function noticeStatus(record) {
|
|
96
|
+
if (record.status === "failed")
|
|
97
|
+
return "failed";
|
|
98
|
+
return runSummary(record)?.status ?? "done";
|
|
99
|
+
}
|
|
100
|
+
/** The first line of `text` with visible text, made one line (default-redacted, no bidirectional controls), or undefined. */
|
|
84
101
|
function firstVisibleLine(text) {
|
|
85
102
|
for (const line of (text ?? "").split(/\r?\n/)) {
|
|
86
|
-
const one = oneLine(line);
|
|
103
|
+
const one = stripBidiControls(oneLine(line)).trim();
|
|
87
104
|
if (one)
|
|
88
105
|
return one;
|
|
89
106
|
}
|
|
@@ -91,23 +108,18 @@ function firstVisibleLine(text) {
|
|
|
91
108
|
}
|
|
92
109
|
/**
|
|
93
110
|
* A run's verdict, the one line a person reads first: for a completed run
|
|
94
|
-
* that does not redact its receipt, the
|
|
95
|
-
* its result text; for a failed run,
|
|
96
|
-
* `maxChars`; undefined when there is no such line.
|
|
111
|
+
* that does not redact its receipt, the verdict of its summary without the
|
|
112
|
+
* status word, else the first line of its result text; for a failed run,
|
|
113
|
+
* its first error line. Cut to `maxChars`; undefined when there is no such line.
|
|
97
114
|
*/
|
|
98
115
|
export function runVerdict(record, maxChars = VERDICT_CHARS) {
|
|
99
116
|
let line;
|
|
100
117
|
if (record.status === "failed")
|
|
101
118
|
line = firstErrorLine(record.error, Infinity);
|
|
102
119
|
else if (record.status === "completed" && !isRedactedTask(record))
|
|
103
|
-
line =
|
|
120
|
+
line = runSummary(record)?.verdict ?? firstVisibleLine(taskResultText(record));
|
|
104
121
|
return line ? cutPreview(line, maxChars) : undefined;
|
|
105
122
|
}
|
|
106
|
-
/** `text` cut to `maxChars - 1` code points plus "…" when longer, so it never exceeds `maxChars` (KTD6). */
|
|
107
|
-
export function cutPreview(text, maxChars) {
|
|
108
|
-
const chars = Array.from(text);
|
|
109
|
-
return chars.length > maxChars ? `${chars.slice(0, maxChars - 1).join("")}…` : text;
|
|
110
|
-
}
|
|
111
123
|
/** The title a message shows: `displayTitle`, one line, at most 80 characters, else the task id. */
|
|
112
124
|
export function messageTitle(record) {
|
|
113
125
|
const t = stripControlChars(displayTitle(record) ?? "").trim();
|
|
@@ -145,9 +157,9 @@ function runSessionLine(record) {
|
|
|
145
157
|
const where = dir ? ` (${stripControlChars(dir)})` : "";
|
|
146
158
|
return origin ? `Ran in a copy of session ${shortSessionId(origin)}${where}` : `Ran in a copy of its session${where}`;
|
|
147
159
|
}
|
|
148
|
-
/** A job's title as a message shows it (one line, at most 80 characters), or undefined when blank. */
|
|
160
|
+
/** A job's title as a message shows it (one line, no bidirectional controls, at most 80 characters), or undefined when blank. */
|
|
149
161
|
function cleanJobTitle(title) {
|
|
150
|
-
const t = stripControlChars(title ?? "").trim();
|
|
162
|
+
const t = stripBidiControls(stripControlChars(title ?? "")).trim();
|
|
151
163
|
return t ? clip(t, 80) : undefined;
|
|
152
164
|
}
|
|
153
165
|
/** The title a task event's message shows: the job's title for a job occurrence, else {@link messageTitle}. */
|
|
@@ -155,26 +167,52 @@ export function eventTitle(record, jobTitle) {
|
|
|
155
167
|
return cleanJobTitle(jobTitle) ?? messageTitle(record);
|
|
156
168
|
}
|
|
157
169
|
/**
|
|
158
|
-
* The body of a job run's notice:
|
|
159
|
-
*
|
|
160
|
-
*
|
|
170
|
+
* The body of a job run's notice: with a usable summary, one `• ` line per
|
|
171
|
+
* bullet, cut to {@link TELEGRAM_PREVIEW_CHARS}; else the raw output after
|
|
172
|
+
* its first visible line (the whole raw preview when that line was cut),
|
|
173
|
+
* clipped to {@link TELEGRAM_PREVIEW_CHARS}; "" when there is nothing more.
|
|
161
174
|
*/
|
|
162
175
|
function jobDoneBody(record) {
|
|
163
|
-
const summary =
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
176
|
+
const summary = runSummary(record);
|
|
177
|
+
if (summary)
|
|
178
|
+
return cutPreview(summary.bullets.map((b) => `• ${b}`).join("\n"), TELEGRAM_PREVIEW_CHARS);
|
|
179
|
+
const result = safeResult(record);
|
|
180
|
+
const lines = result.split(/\r?\n/);
|
|
181
|
+
const first = lines.findIndex((line) => oneLine(line) !== "");
|
|
182
|
+
if (first < 0)
|
|
183
|
+
return "";
|
|
184
|
+
if (Array.from(oneLine(lines[first])).length > VERDICT_CHARS)
|
|
185
|
+
return clip(result, TELEGRAM_PREVIEW_CHARS);
|
|
186
|
+
return clip(lines.slice(first + 1).join("\n").trim(), TELEGRAM_PREVIEW_CHARS);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The line that names a run's attachments: `📎 funnel.png (48 KB), weekly.csv
|
|
190
|
+
* (2 KB), not attached: huge.png (over 10 MB)`. A redacted task names no
|
|
191
|
+
* file: `📎 2 files, not sent: this task redacts its receipt`. Undefined
|
|
192
|
+
* when the run has none.
|
|
193
|
+
*/
|
|
194
|
+
export function attachmentLine(record) {
|
|
195
|
+
const stored = taskAttachments(record);
|
|
196
|
+
if (isRedactedTask(record)) {
|
|
197
|
+
const n = stored.length;
|
|
198
|
+
return n > 0 ? `📎 ${n} ${n === 1 ? "file" : "files"}, not sent: this task redacts its receipt` : undefined;
|
|
170
199
|
}
|
|
171
|
-
const
|
|
172
|
-
|
|
200
|
+
const skipped = taskAttachmentsSkipped(record);
|
|
201
|
+
const parts = stored.map((a) => `${a.name} (${formatBytes(a.bytes)})`);
|
|
202
|
+
if (skipped.length > 0)
|
|
203
|
+
parts.push(`not attached: ${skipped.map((s) => `${s.name} (${s.reason})`).join(", ")}`);
|
|
204
|
+
return parts.length > 0 ? cutPreview(`📎 ${parts.join(", ")}`, ATTACHMENT_LINE_CHARS) : undefined;
|
|
205
|
+
}
|
|
206
|
+
/** The files a message about `record` sends after its text, or undefined. */
|
|
207
|
+
function messageFiles(record) {
|
|
208
|
+
const attachments = sendableAttachments(record);
|
|
209
|
+
return attachments.length > 0 ? { files: { taskId: record.taskId, attachments } } : {};
|
|
173
210
|
}
|
|
174
211
|
/**
|
|
175
|
-
* Task done (R26): title, time, where it ran, the
|
|
176
|
-
* note, and a [Result] button with the raw result
|
|
177
|
-
*
|
|
212
|
+
* Task done (R26): title, time, the attachments line, where it ran, the
|
|
213
|
+
* preview or the redaction note, and a [Result] button with the raw result;
|
|
214
|
+
* the run's sendable files go with it. A job occurrence
|
|
215
|
+
* (`jobTitle`) leads with `<status emoji> <job title> — <verdict>`, adds the job's next run
|
|
178
216
|
* (`jobNext`) to the time line, a `No summary` line when its summarize step
|
|
179
217
|
* failed, and shows its summary in place of the raw preview.
|
|
180
218
|
*/
|
|
@@ -185,7 +223,7 @@ export function taskDoneMessage(record, now = new Date(), jobTitle, jobNext) {
|
|
|
185
223
|
const lines = [];
|
|
186
224
|
let body = "";
|
|
187
225
|
if (job) {
|
|
188
|
-
lines.push(`${job} — ${runVerdict(record) ?? "done"}`);
|
|
226
|
+
lines.push(`${NOTICE_EMOJI[noticeStatus(record)]} ${job} — ${runVerdict(record) ?? "done"}`);
|
|
189
227
|
const next = jobNext && jobNext !== JOB_RUNNING_NOW ? `next ${jobNext}` : undefined;
|
|
190
228
|
const time = [at && `Finished ${at}`, next].filter(Boolean).join(" · ");
|
|
191
229
|
if (time)
|
|
@@ -196,6 +234,9 @@ export function taskDoneMessage(record, now = new Date(), jobTitle, jobNext) {
|
|
|
196
234
|
if (at)
|
|
197
235
|
lines.push(`Finished ${at}`);
|
|
198
236
|
}
|
|
237
|
+
const files = attachmentLine(record);
|
|
238
|
+
if (files)
|
|
239
|
+
lines.push(files);
|
|
199
240
|
const ran = runSessionLine(record);
|
|
200
241
|
if (ran)
|
|
201
242
|
lines.push(ran);
|
|
@@ -215,17 +256,17 @@ export function taskDoneMessage(record, now = new Date(), jobTitle, jobNext) {
|
|
|
215
256
|
lines.push("", body);
|
|
216
257
|
}
|
|
217
258
|
const buttons = callbackFits(record.taskId) ? [[{ text: "Result", data: encodeCallback("result", record.taskId) }]] : undefined;
|
|
218
|
-
return { text: lines.join("\n"), ...(buttons ? { buttons } : {}) };
|
|
259
|
+
return { text: lines.join("\n"), ...(buttons ? { buttons } : {}), ...messageFiles(record) };
|
|
219
260
|
}
|
|
220
261
|
/** The first error line with visible text (notify's firstErrorLine), at most `max` characters, or "unknown error". */
|
|
221
262
|
const errorLine = (error, max = 300) => firstErrorLine(error, max) ?? "unknown error";
|
|
222
263
|
/**
|
|
223
264
|
* Task failed: title, time, the first error line, the show command. No
|
|
224
|
-
* buttons. A job occurrence (`jobTitle`) leads with
|
|
265
|
+
* buttons. A job occurrence (`jobTitle`) leads with `❌ <job title>: failed`.
|
|
225
266
|
*/
|
|
226
267
|
export function taskFailedMessage(record, now = new Date(), jobTitle) {
|
|
227
268
|
const job = cleanJobTitle(jobTitle);
|
|
228
|
-
const lines = [job ? `${job}: failed` : `Failed: ${messageTitle(record)}`];
|
|
269
|
+
const lines = [job ? `${NOTICE_EMOJI.failed} ${job}: failed` : `Failed: ${messageTitle(record)}`];
|
|
229
270
|
const at = when(record.completedAt, now);
|
|
230
271
|
if (at)
|
|
231
272
|
lines.push(`Failed ${at}`);
|
|
@@ -238,9 +279,9 @@ export function jobPausedTitle(notice) {
|
|
|
238
279
|
const title = cleanJobTitle(notice.title) ?? notice.jobId;
|
|
239
280
|
return `job '${title}' paused after ${JOB_AUTO_PAUSE_FAILURES} failures: ${errorLine(notice.reason, 200)}`;
|
|
240
281
|
}
|
|
241
|
-
/** The auto-pause notice: the sentence, then how to resume. No buttons. */
|
|
282
|
+
/** The auto-pause notice: the failed emoji and the sentence, then how to resume. No buttons. */
|
|
242
283
|
export function jobPausedMessage(notice) {
|
|
243
|
-
return { text: `${jobPausedTitle(notice)}\nResume it: tidegap jobs resume ${notice.jobId}` };
|
|
284
|
+
return { text: `${NOTICE_EMOJI.failed} ${jobPausedTitle(notice)}\nResume it: tidegap jobs resume ${notice.jobId}` };
|
|
244
285
|
}
|
|
245
286
|
/** The first line of a job's final notice: `Job ended: "<title>"`. */
|
|
246
287
|
export function jobEndedTitle(notice) {
|
|
@@ -252,9 +293,9 @@ export function jobEndedBody(notice, last) {
|
|
|
252
293
|
const verdict = runVerdict(last);
|
|
253
294
|
return `"${title}" ended: ${jobEndText(notice.reason, notice.until)}.\nLast run: ${last.taskId} ${notice.lastOutcome}${verdict ? `: ${verdict}` : "."}`;
|
|
254
295
|
}
|
|
255
|
-
/** A job's final notice: the title line and the body. No buttons. */
|
|
296
|
+
/** A job's final notice: the ended emoji, the title line and the body. No buttons. */
|
|
256
297
|
export function jobEndedMessage(notice, last) {
|
|
257
|
-
return { text: `${jobEndedTitle(notice)}\n${jobEndedBody(notice, last)}` };
|
|
298
|
+
return { text: `${NOTICE_EMOJI.ended} ${jobEndedTitle(notice)}\n${jobEndedBody(notice, last)}` };
|
|
258
299
|
}
|
|
259
300
|
/** A clean window starting. No buttons. */
|
|
260
301
|
export function cleanWindowMessage(window, now = new Date()) {
|
|
@@ -346,17 +387,6 @@ function cadenceText(cadence) {
|
|
|
346
387
|
return `at least every ${cadence.every} h`;
|
|
347
388
|
}
|
|
348
389
|
}
|
|
349
|
-
/** `HH:MM` in `timeZone` when `at` falls on the same day there as `now`, else `Ddd HH:MM`. */
|
|
350
|
-
export function zoneTimeLabel(at, now, timeZone) {
|
|
351
|
-
const parts = (d) => {
|
|
352
|
-
// An unknown zone falls back to the system zone.
|
|
353
|
-
const fmt = new Intl.DateTimeFormat("en-US", { timeZone: isValidTimeZone(timeZone) ? timeZone : undefined, weekday: "short", year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", hourCycle: "h23" });
|
|
354
|
-
const p = Object.fromEntries(fmt.formatToParts(d).map((x) => [x.type, x.value]));
|
|
355
|
-
return { day: `${p.year}-${p.month}-${p.day}`, weekday: p.weekday, time: `${p.hour}:${p.minute}` };
|
|
356
|
-
};
|
|
357
|
-
const a = parts(at);
|
|
358
|
-
return a.day === parts(now).day ? a.time : `${a.weekday} ${a.time}`;
|
|
359
|
-
}
|
|
360
390
|
/** The {@link jobNextLabel} of a job whose occurrence is running. */
|
|
361
391
|
export const JOB_RUNNING_NOW = "running now";
|
|
362
392
|
/**
|
|
@@ -392,14 +422,16 @@ function jobLine(job, taskOf, now) {
|
|
|
392
422
|
return `${jobTitle(job)} - ${pausedText(job)}`;
|
|
393
423
|
const parts = [jobTitle(job)];
|
|
394
424
|
parts.push(job.window ? `${cadenceText(job.cadence)} ${job.window.start}-${job.window.end}` : cadenceText(job.cadence));
|
|
395
|
-
const next = jobNextLabel(job,
|
|
425
|
+
const next = jobNextLabel(job, jobNextRun({ get: taskOf }, job), now);
|
|
396
426
|
if (next)
|
|
397
427
|
parts.push(next === JOB_RUNNING_NOW ? next : `next ${next}`);
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
428
|
+
// The last run is an occurrence that ran, never a cancelled one.
|
|
429
|
+
const last = jobLastRun({ get: taskOf }, job);
|
|
430
|
+
const outcome = last && runOutcome(last);
|
|
431
|
+
if (outcome) {
|
|
432
|
+
const at = when(last.completedAt, now, (t) => zoneTimeLabel(t, now, job.timeZone));
|
|
433
|
+
const count = outcome === "failed" && job.consecutiveFailures > 0 ? ` (${job.consecutiveFailures} of ${JOB_AUTO_PAUSE_FAILURES})` : "";
|
|
434
|
+
parts.push(`last ${outcome}${at ? ` ${at}` : ""}${count}`);
|
|
403
435
|
}
|
|
404
436
|
return parts.join(" - ");
|
|
405
437
|
}
|
|
@@ -452,9 +484,10 @@ export function splitMessage(text, max = TELEGRAM_MESSAGE_MAX) {
|
|
|
452
484
|
return parts;
|
|
453
485
|
}
|
|
454
486
|
/**
|
|
455
|
-
* `/result` and the Result button (R27): no result text for a
|
|
456
|
-
* task; otherwise the result in parts of 4096 characters, at most
|
|
457
|
-
* {@link RESULT_MAX_PARTS}, then a pointer to `tidegap queue show
|
|
487
|
+
* `/result` and the Result button (R27): no result text and no file for a
|
|
488
|
+
* redacted task; otherwise the result in parts of 4096 characters, at most
|
|
489
|
+
* {@link RESULT_MAX_PARTS}, then a pointer to `tidegap queue show`; the
|
|
490
|
+
* run's sendable files go after the last part.
|
|
458
491
|
*/
|
|
459
492
|
export function resultMessages(record) {
|
|
460
493
|
const title = messageTitle(record);
|
|
@@ -465,14 +498,17 @@ export function resultMessages(record) {
|
|
|
465
498
|
return [{ text: `${title} is ${record.status}; it has no result.` }];
|
|
466
499
|
}
|
|
467
500
|
const body = safeResult(record);
|
|
501
|
+
const out = [];
|
|
468
502
|
if (!body)
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
503
|
+
out.push({ text: `${title}\nThe result is empty.` });
|
|
504
|
+
else {
|
|
505
|
+
const parts = splitMessage(body, TELEGRAM_MESSAGE_MAX - 100);
|
|
506
|
+
out.push(...parts.slice(0, RESULT_MAX_PARTS).map((p) => ({ text: p })));
|
|
507
|
+
out[0] = { text: `${title}\n\n${out[0].text}` };
|
|
508
|
+
if (parts.length > RESULT_MAX_PARTS)
|
|
509
|
+
out.push({ text: `The result is longer. Run \`${showCommand(record)}\` for the rest.` });
|
|
510
|
+
}
|
|
511
|
+
out[out.length - 1] = { ...out[out.length - 1], ...messageFiles(record) };
|
|
476
512
|
return out;
|
|
477
513
|
}
|
|
478
514
|
/** `/later` grammar (KTD15), quoted by `/help` and the reset-time reply. */
|
package/dist/channels/index.d.ts
CHANGED
|
@@ -11,5 +11,6 @@ export { PUSHOVER_MESSAGES_PATH } from "./kinds/pushover.js";
|
|
|
11
11
|
export { isLoopbackSmtpHost } from "./kinds/email.js";
|
|
12
12
|
export * from "./telegram.js";
|
|
13
13
|
export * from "./format.js";
|
|
14
|
+
export * from "./notice.js";
|
|
14
15
|
export * from "./commands.js";
|
|
15
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/channels/index.js
CHANGED
|
@@ -11,5 +11,6 @@ export { PUSHOVER_MESSAGES_PATH } from "./kinds/pushover.js";
|
|
|
11
11
|
export { isLoopbackSmtpHost } from "./kinds/email.js";
|
|
12
12
|
export * from "./telegram.js";
|
|
13
13
|
export * from "./format.js";
|
|
14
|
+
export * from "./notice.js";
|
|
14
15
|
export * from "./commands.js";
|
|
15
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* neither link nor ping (KTD2). Sent with `?wait=true`, so Discord answers
|
|
5
5
|
* only after it accepted the message.
|
|
6
6
|
*/
|
|
7
|
-
import { clipEscaped, escapeChars, LEVEL_COLOR, LOOPBACK_URL } from "./shared.js";
|
|
7
|
+
import { clipEscaped, escapeChars, LEVEL_COLOR, LOOPBACK_URL, statusTitle } from "./shared.js";
|
|
8
8
|
/** Discord's caps on an embed's title and description. */
|
|
9
9
|
export const DISCORD_TITLE_MAX = 256;
|
|
10
10
|
export const DISCORD_DESCRIPTION_MAX = 4096;
|
|
@@ -15,7 +15,7 @@ export function discordBody(payload) {
|
|
|
15
15
|
username: "Tidegap",
|
|
16
16
|
embeds: [
|
|
17
17
|
{
|
|
18
|
-
title: clipEscaped(escapeChars(payload
|
|
18
|
+
title: clipEscaped(escapeChars(statusTitle(payload), SPECIALS), DISCORD_TITLE_MAX),
|
|
19
19
|
description: clipEscaped(escapeChars(payload.text, SPECIALS), DISCORD_DESCRIPTION_MAX),
|
|
20
20
|
color: LEVEL_COLOR[payload.level],
|
|
21
21
|
timestamp: payload.at,
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* turned off password SMTP for them on 2024-09-16 and they need OAuth,
|
|
10
10
|
* which would need a Tidegap-owned client id (R20).
|
|
11
11
|
*/
|
|
12
|
+
import { statusTitle } from "./shared.js";
|
|
12
13
|
/** A plain `local@domain` address: no spaces, CR, LF, `<`, `>`, quotes, commas or semicolons. */
|
|
13
14
|
export const EMAIL_ADDRESS = String.raw `[^\s<>@,;"]{1,64}@[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)+`;
|
|
14
15
|
const WHOLE_ADDRESS = new RegExp(`^(?:${EMAIL_ADDRESS})$`);
|
|
@@ -154,7 +155,7 @@ export const email = {
|
|
|
154
155
|
...(password ? { user, password } : {}),
|
|
155
156
|
from,
|
|
156
157
|
to: String(values.to || from),
|
|
157
|
-
subject: headerLine(`Tidegap: ${payload
|
|
158
|
+
subject: headerLine(`Tidegap: ${statusTitle(payload)}`),
|
|
158
159
|
text: payload.text,
|
|
159
160
|
};
|
|
160
161
|
},
|
|
@@ -14,6 +14,14 @@ export const NTFY_MAX_BODY_BYTES = 4000;
|
|
|
14
14
|
const PRIORITY = { task_failed: 4, not_ready: 4, task_done: 3, test: 3, clean_window: 2, digest: 2 };
|
|
15
15
|
/** ntfy emoji tags per level (`x` shows ❌). */
|
|
16
16
|
const TAGS = { success: "white_check_mark", error: "x", warning: "warning", info: "information_source" };
|
|
17
|
+
/** ntfy emoji tags per job notice status, in place of the level's. */
|
|
18
|
+
const STATUS_TAGS = {
|
|
19
|
+
ok: "white_check_mark",
|
|
20
|
+
attention: "warning",
|
|
21
|
+
done: "ballot_box_with_check",
|
|
22
|
+
failed: "x",
|
|
23
|
+
ended: "checkered_flag",
|
|
24
|
+
};
|
|
17
25
|
/** The header value of `text`: as is when printable ASCII, else an RFC 2047 base64 encoded word. */
|
|
18
26
|
export function headerText(text) {
|
|
19
27
|
if (/^[\x20-\x7e]*$/.test(text))
|
|
@@ -153,7 +161,7 @@ export const ntfy = {
|
|
|
153
161
|
"Content-Type": "text/plain; charset=utf-8",
|
|
154
162
|
Title: headerText(payload.title),
|
|
155
163
|
Priority: String(ntfyPriority(payload, values.priority)),
|
|
156
|
-
Tags: TAGS[payload.level],
|
|
164
|
+
Tags: payload.status ? STATUS_TAGS[payload.status] : TAGS[payload.level],
|
|
157
165
|
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
|
158
166
|
},
|
|
159
167
|
body: clipBytes(payload.text, NTFY_MAX_BODY_BYTES),
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* loopback test server (`TIDEGAP_PUSHOVER_API_BASE`, KTD8), never anywhere
|
|
6
6
|
* else. Pushover shows plain text, so nothing is escaped.
|
|
7
7
|
*/
|
|
8
|
+
import { cutPreview } from "../notice.js";
|
|
9
|
+
import { statusTitle } from "./shared.js";
|
|
8
10
|
const PUSHOVER_API_BASE = "https://api.pushover.net";
|
|
9
11
|
export const PUSHOVER_MESSAGES_PATH = "/1/messages.json";
|
|
10
12
|
/** Pushover's limits: message 1,024 characters, title 250. */
|
|
@@ -12,7 +14,6 @@ const PUSHOVER_MAX_MESSAGE = 1024;
|
|
|
12
14
|
const PUSHOVER_MAX_TITLE = 250;
|
|
13
15
|
/** Priority per event: summaries and clean windows quiet (-1), the rest normal (0). */
|
|
14
16
|
const PRIORITY = { task_failed: 0, not_ready: 0, task_done: 0, test: 0, clean_window: -1, digest: -1 };
|
|
15
|
-
const clip = (s, n) => (s.length > n ? `${s.slice(0, n - 1)}…` : s);
|
|
16
17
|
/** Pushover user keys and application tokens: 30 letters and digits. */
|
|
17
18
|
const KEY = "[A-Za-z0-9]{30}";
|
|
18
19
|
export const pushover = {
|
|
@@ -60,8 +61,8 @@ export const pushover = {
|
|
|
60
61
|
const body = new URLSearchParams({
|
|
61
62
|
token: String(values.app_token),
|
|
62
63
|
user: String(values.user_key),
|
|
63
|
-
title:
|
|
64
|
-
message:
|
|
64
|
+
title: cutPreview(statusTitle(payload), PUSHOVER_MAX_TITLE),
|
|
65
|
+
message: cutPreview(payload.text, PUSHOVER_MAX_MESSAGE),
|
|
65
66
|
priority: String(PRIORITY[payload.event]),
|
|
66
67
|
...(Number.isFinite(at) ? { timestamp: String(at) } : {}),
|
|
67
68
|
});
|