@mikitasazan/notify 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/dist/cli.js +69 -60
- package/dist/events.d.ts +127 -117
- package/dist/events.js +30 -24
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/render.d.ts +57 -49
- package/dist/render.js +255 -221
- package/dist/routes.d.ts +31 -27
- package/dist/routes.js +25 -20
- package/dist/send.d.ts +1 -19
- package/dist/send.js +2 -33
- package/package.json +1 -1
package/dist/render.d.ts
CHANGED
|
@@ -1,56 +1,59 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* One renderer per event type, all built on one skeleton — approved by
|
|
3
|
+
* the owner on 20.08.2026 after ~15 live rounds in the test forum:
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* #type #instance
|
|
6
|
+
* icon <b>Type:</b> action
|
|
7
7
|
*
|
|
8
|
-
* <b
|
|
9
|
-
* <blockquote
|
|
8
|
+
* <b>Label:</b> value
|
|
9
|
+
* <blockquote>quoted text from someone else — commit body, task body</blockquote>
|
|
10
10
|
*
|
|
11
|
-
* <i><u
|
|
12
|
-
* <b>#N (overdue):</b> <a
|
|
11
|
+
* <i><u>Group</u></i>
|
|
12
|
+
* <b>#N (overdue):</b> <a>title</a>
|
|
13
13
|
*
|
|
14
|
-
* <b
|
|
14
|
+
* <b>Label:</b> value ← actions/directions
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
16
|
+
* Three levels of styling, never mixed: a field is a bold, capitalized
|
|
17
|
+
* label plus a plain value; a group is italic+underline, no bold and no
|
|
18
|
+
* colon; line 2 (the type) follows the same field rule. A blank line
|
|
19
|
+
* separates BLOCKS BY MEANING (header / body / actions), not mechanically
|
|
20
|
+
* after every line.
|
|
21
21
|
*/
|
|
22
|
-
import { type NotifyEvent } from './events.ts';
|
|
23
|
-
/**
|
|
22
|
+
import { ICON, type NotifyEvent } from './events.ts';
|
|
23
|
+
/** Escapes EVERYTHING that comes from outside — only the template adds tags. */
|
|
24
24
|
export declare const esc: (v: unknown) => string;
|
|
25
25
|
/**
|
|
26
|
-
* Telegram
|
|
27
|
-
*
|
|
26
|
+
* Telegram cuts a message at 4096 characters — we cut it ourselves first,
|
|
27
|
+
* on a line boundary where possible.
|
|
28
28
|
*
|
|
29
|
-
*
|
|
30
|
-
* 1.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
29
|
+
* Two traps, both caused a SILENT loss of the message:
|
|
30
|
+
* 1. Cutting strictly at the last `\n` does not work: if a long chunk runs
|
|
31
|
+
* as one line (a stack trace, command output — the most common `detail`
|
|
32
|
+
* on an incident), the last line break sits BEFORE it, and the whole
|
|
33
|
+
* content got dropped — only the heading arrived, with not a single
|
|
34
|
+
* fact about what broke.
|
|
35
|
+
* 2. Cutting in the middle of an HTML tag or entity does not work either:
|
|
36
|
+
* Telegram replies `400 can't parse entities`, and we treat a 4xx as a
|
|
37
|
+
* permanent error and do not retry — the message disappeared for good.
|
|
37
38
|
*/
|
|
38
39
|
export declare const clampMessage: (text: string, limit?: number) => string;
|
|
39
40
|
export declare const slug: (raw: string) => string;
|
|
40
41
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
42
|
+
* The instance tag: exactly which concrete event this is (branch,
|
|
43
|
+
* environment, task, number) — the parser uses it to match a 🔴 against a
|
|
44
|
+
* later green card of the SAME instance. An explicit `key` always wins;
|
|
45
|
+
* without one, it is derived from the type's most stable fields (branch/
|
|
46
|
+
* environment outrank the title, because a recurring task's title does not
|
|
47
|
+
* change, while for a report the title is exactly the one stable field it
|
|
48
|
+
* has).
|
|
47
49
|
*/
|
|
48
50
|
export declare const eventKey: (e: NotifyEvent) => string;
|
|
49
51
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
52
|
+
* The third tag is the OUTCOME, and it is always there. The owner: "I'm
|
|
53
|
+
* missing a fail tag or something like it, so failures can be grouped and
|
|
54
|
+
* ok can be grouped." One tap in Telegram collects every failure of a
|
|
55
|
+
* project at once, no matter what type it arrived as — a deploy, a check,
|
|
56
|
+
* a scheduled task, an incident.
|
|
54
57
|
*
|
|
55
58
|
* The value comes from the ICON, never from the status word. The icon is
|
|
56
59
|
* already the single source of truth for the sound, and a second list of "what
|
|
@@ -62,21 +65,26 @@ export declare const eventKey: (e: NotifyEvent) => string;
|
|
|
62
65
|
* `#fail` under a 🚫 and said so. Nor is a task that has simply gone quiet —
|
|
63
66
|
* nobody knows yet whether it broke, and `#unknown` is the honest word for it.
|
|
64
67
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
/** Every icon the package can print — the key space of the outcome table. */
|
|
69
|
+
type Icon = (typeof ICON)[keyof typeof ICON];
|
|
70
|
+
/** The five words the third tag is allowed to be, and there is no sixth. */
|
|
71
|
+
type OutcomeTag = 'ok' | 'fail' | 'off' | 'unknown' | 'news';
|
|
67
72
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
+
* The type is `Record` over EVERY icon, not over `string`. A new icon added to
|
|
74
|
+
* `ICON` without a word here now fails to compile. Under the old loose type it
|
|
75
|
+
* fell through a `?? 'news'` default instead: a card whose outcome nobody had
|
|
76
|
+
* decided was indistinguishable from a card that is genuinely just news, and
|
|
77
|
+
* nothing anywhere went red. `news` is therefore written out for each icon
|
|
78
|
+
* that means it, never left to a fallback.
|
|
73
79
|
*/
|
|
74
|
-
export declare const
|
|
80
|
+
export declare const OUTCOME_TAG: Readonly<Record<Icon, OutcomeTag>>;
|
|
81
|
+
export declare const outcomeTag: (e: NotifyEvent) => OutcomeTag;
|
|
75
82
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
83
|
+
* Renders an event into finished HTML text, cut to Telegram's limit.
|
|
84
|
+
* Tags are the FIRST line, added before the cut (not after, as before):
|
|
85
|
+
* they carry both the human filter and the parser's machine key — a card
|
|
86
|
+
* cut without them would be not only unclickable but invisible to the
|
|
87
|
+
* parser on exactly the longest, meaning the most important, messages.
|
|
81
88
|
*/
|
|
82
89
|
export declare const render: (e: NotifyEvent) => string;
|
|
90
|
+
export {};
|