@mikitasazan/notify 1.6.2 → 1.7.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/render.d.ts CHANGED
@@ -46,6 +46,24 @@ export declare const slug: (raw: string) => string;
46
46
  * заголовок и есть единственное стабильное поле).
47
47
  */
48
48
  export declare const eventKey: (e: NotifyEvent) => string;
49
+ /**
50
+ * Третий тег — ИСХОД, и он есть всегда. Владелец: «не хватает тега fail или
51
+ * похожего, чтобы фейлы можно было группировать и ок можно было группировать».
52
+ * Одно нажатие в Telegram собирает все падения проекта разом, каким бы типом
53
+ * они ни пришли — выкатка, проверка, задача по расписанию, авария.
54
+ *
55
+ * The value comes from the ICON, never from the status word. The icon is
56
+ * already the single source of truth for the sound, and a second list of "what
57
+ * counts as broken" would drift from the first — it already did once, when a
58
+ * red card arrived silent.
59
+ *
60
+ * One icon meaning, one tag. A watchdog that SWITCHED SOMETHING OFF is not a
61
+ * failure and must not be filed under the same word as one: the owner read
62
+ * `#fail` under a 🚫 and said so. Nor is a task that has simply gone quiet —
63
+ * nobody knows yet whether it broke, and `#unknown` is the honest word for it.
64
+ */
65
+ export declare const OUTCOME_TAG: Readonly<Record<string, string>>;
66
+ export declare const outcomeTag: (e: NotifyEvent) => string;
49
67
  /**
50
68
  * Строка тегов для свободного HTML (`sendReport`). Тег — это ФИЛЬТР владельца,
51
69
  * и к формату тела он отношения не имеет: дневной отчёт остаётся свободным
package/dist/render.js CHANGED
@@ -19,7 +19,7 @@
19
19
  * строка разделяет БЛОКИ ПО СМЫСЛУ (шапка / суть / действия), не механически
20
20
  * после каждой строки.
21
21
  */
22
- import { ICON, LOUD, iconFor } from "./events.js";
22
+ import { ICON, iconFor } from "./events.js";
23
23
  /** Первая буква — заглавная, остальное как есть (ga4/GitHub остаются собой). */
24
24
  /**
25
25
  * Ярлык с большой буквы — но НЕ у имени, которое пишется со строчной нарочно:
@@ -424,17 +424,12 @@ const renderJob = (e) => {
424
424
  // were two words for one thing, and the outcome that took the first line is
425
425
  // already the icon, and now the third tag too.
426
426
  //
427
- // `disabled` and `silent` keep a word of their own. A red mark reads as
428
- // "it broke", and neither of those is that: one was switched off on purpose
429
- // and the other has not been heard from at all.
430
- const state = e.status === 'disabled'
431
- ? 'switched off, not broken'
432
- : e.status === 'silent'
433
- ? 'no word from it at all'
434
- : undefined;
427
+ // There is no `State:` row. It said "switched off, not broken" under a 🚫
428
+ // and "no word from it at all" under a the third way of saying what the
429
+ // icon says and what the third tag now says too. The icon table on the
430
+ // catalogue page defines both marks.
435
431
  return join([
436
432
  typeLine(icon, 'Job', e.job, e.workflowUrl ?? e.url),
437
- field('State', state),
438
433
  field('Reason', e.note),
439
434
  field('Expected', e.expected),
440
435
  // `Last run` when the task is alive, `Last seen` when it is not: the same
@@ -640,21 +635,28 @@ export const eventKey = (e) => {
640
635
  * Одно нажатие в Telegram собирает все падения проекта разом, каким бы типом
641
636
  * они ни пришли — выкатка, проверка, задача по расписанию, авария.
642
637
  *
643
- * Значение берётся у ЗНАЧКА, а не у слова статуса, и это не мелочь: значок уже
644
- * единственный источник правды про звук, и второй список «что считать
645
- * падением» разошёлся бы с первымтак уже было, когда красная карточка
646
- * приходила беззвучной. Громкий значок — `#fail`, зелёный — `#ok`, всё
647
- * остальное (завели задачу, открыли PR, попросили правки, отчёт) — `#news`:
648
- * это новость, а не приговор робота.
638
+ * The value comes from the ICON, never from the status word. The icon is
639
+ * already the single source of truth for the sound, and a second list of "what
640
+ * counts as broken" would drift from the first it already did once, when a
641
+ * red card arrived silent.
642
+ *
643
+ * One icon meaning, one tag. A watchdog that SWITCHED SOMETHING OFF is not a
644
+ * failure and must not be filed under the same word as one: the owner read
645
+ * `#fail` under a 🚫 and said so. Nor is a task that has simply gone quiet —
646
+ * nobody knows yet whether it broke, and `#unknown` is the honest word for it.
649
647
  */
650
- const OK_ICONS = new Set([ICON.ok, ICON.landed, ICON.approved]);
651
- const outcomeTag = (e) => {
652
- const icon = iconFor(e);
653
- if (LOUD.has(icon)) {
654
- return 'fail';
655
- }
656
- return OK_ICONS.has(icon) ? 'ok' : 'news';
648
+ export const OUTCOME_TAG = {
649
+ [ICON.red]: 'fail',
650
+ [ICON.alarm]: 'fail',
651
+ [ICON.off]: 'off',
652
+ [ICON.unknown]: 'unknown',
653
+ [ICON.ok]: 'ok',
654
+ [ICON.landed]: 'ok',
655
+ [ICON.approved]: 'ok'
657
656
  };
657
+ // Everything left over — a task was opened, a PR opened, edits asked for, a
658
+ // digest — is news: something happened, no verdict was passed.
659
+ export const outcomeTag = (e) => OUTCOME_TAG[iconFor(e)] ?? 'news';
658
660
  const tagsLine = (e) => `#${TYPE_TAG[e.type]} #${esc(eventKey(e))} #${outcomeTag(e)}`;
659
661
  /**
660
662
  * Строка тегов для свободного HTML (`sendReport`). Тег — это ФИЛЬТР владельца,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikitasazan/notify",
3
- "version": "1.6.2",
3
+ "version": "1.7.0",
4
4
  "description": "Единая типизированная отправка Telegram-уведомлений (форум-темы, маршрутизация, ретраи) для всех проектов",
5
5
  "type": "module",
6
6
  "license": "MIT",