@mikitasazan/notify 1.10.1 → 1.11.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/lint.js CHANGED
@@ -31,7 +31,7 @@ const NOT_A_NAME = new Set([
31
31
  'null'
32
32
  ]);
33
33
  /** The five words the third tag is allowed to be, and there is no sixth. */
34
- const OUTCOMES = new Set(['ok', 'fail', 'off', 'unknown', 'news']);
34
+ const OUTCOMES = new Set(['ok', 'fail', 'off', 'unknown', 'info']);
35
35
  /** Labels the template retired. Each one used to say what a neighbour said. */
36
36
  const RETIRED = ['Title', 'Number', 'State', 'Via', 'Check', 'Logs', 'Task', 'Id', 'Period'];
37
37
  /**
@@ -46,7 +46,7 @@ export const lintCard = (html) => {
46
46
  found.push(`line 1 is "${rows[0] ?? ''}" — it must be exactly three tags`);
47
47
  }
48
48
  else if (!OUTCOMES.has(tags[2].slice(1))) {
49
- found.push(`the outcome tag is "${tags[2]}" — the vocabulary is ok, fail, off, unknown, news`);
49
+ found.push(`the outcome tag is "${tags[2]}" — the vocabulary is ok, fail, off, unknown, info`);
50
50
  }
51
51
  if (tags[1] === '#' || tags[1] === '#_') {
52
52
  found.push('the instance tag is empty — it groups nothing and pairs with nothing');
@@ -98,5 +98,17 @@ export const lintCard = (html) => {
98
98
  break;
99
99
  }
100
100
  }
101
+ // A red card must say where to look. Here — and only here — that can be
102
+ // judged completely: a log row, a command to run, or any address at all,
103
+ // including the one riding on line 2 where the standard puts it. Read back
104
+ // from Telegram the addresses are gone, so the same rule there accused a
105
+ // deploy card whose own second line was the link to the failed run.
106
+ // `#fail` only. A task that has gone silent is `#unknown`, and it has no log
107
+ // by definition — it never ran. Demanding one there would be demanding a
108
+ // thing that cannot exist.
109
+ const broke = (rows[0] ?? '').includes('#fail');
110
+ if (broke && !html.includes('<b>Log:</b>') && !html.includes('<b>To do:</b>') && !html.includes('<a href=')) {
111
+ found.push('a red card with no log, no command and no link — nowhere to look');
112
+ }
101
113
  return found;
102
114
  };
package/dist/render.d.ts CHANGED
@@ -68,13 +68,13 @@ export declare const eventKey: (e: NotifyEvent) => string;
68
68
  /** Every icon the package can print — the key space of the outcome table. */
69
69
  type Icon = (typeof ICON)[keyof typeof ICON];
70
70
  /** The five words the third tag is allowed to be, and there is no sixth. */
71
- type OutcomeTag = 'ok' | 'fail' | 'off' | 'unknown' | 'news';
71
+ type OutcomeTag = 'ok' | 'fail' | 'off' | 'unknown' | 'info';
72
72
  /**
73
73
  * The type is `Record` over EVERY icon, not over `string`. A new icon added to
74
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
75
+ * fell through a `?? 'info'` default instead: a card whose outcome nobody had
76
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
77
+ * nothing anywhere went red. `info` is therefore written out for each icon
78
78
  * that means it, never left to a fallback.
79
79
  */
80
80
  export declare const OUTCOME_TAG: Readonly<Record<Icon, OutcomeTag>>;
package/dist/render.js CHANGED
@@ -694,9 +694,9 @@ export const eventKey = (e) => {
694
694
  /**
695
695
  * The type is `Record` over EVERY icon, not over `string`. A new icon added to
696
696
  * `ICON` without a word here now fails to compile. Under the old loose type it
697
- * fell through a `?? 'news'` default instead: a card whose outcome nobody had
697
+ * fell through a `?? 'info'` default instead: a card whose outcome nobody had
698
698
  * decided was indistinguishable from a card that is genuinely just news, and
699
- * nothing anywhere went red. `news` is therefore written out for each icon
699
+ * nothing anywhere went red. `info` is therefore written out for each icon
700
700
  * that means it, never left to a fallback.
701
701
  */
702
702
  export const OUTCOME_TAG = {
@@ -707,12 +707,14 @@ export const OUTCOME_TAG = {
707
707
  [ICON.ok]: 'ok',
708
708
  [ICON.landed]: 'ok',
709
709
  [ICON.approved]: 'ok',
710
- // Something happened; no verdict was passed on it.
711
- [ICON.fresh]: 'news',
712
- [ICON.taken]: 'news',
713
- [ICON.discarded]: 'news',
714
- [ICON.changes]: 'news',
715
- [ICON.info]: 'news'
710
+ // Something happened; no verdict was passed on it. The word is `info`, not
711
+ // `news`: the icon on every one of these cards is ℹ️, and the owner read
712
+ // `#news` under it and asked what news meant. One thing wore two words.
713
+ [ICON.fresh]: 'info',
714
+ [ICON.taken]: 'info',
715
+ [ICON.discarded]: 'info',
716
+ [ICON.changes]: 'info',
717
+ [ICON.info]: 'info'
716
718
  };
717
719
  export const outcomeTag = (e) => OUTCOME_TAG[iconFor(e)];
718
720
  const tagsLine = (e) => `#${TYPE_TAG[e.type]} #${esc(eventKey(e))} #${outcomeTag(e)}`;
package/dist/trend.d.ts CHANGED
@@ -10,11 +10,15 @@
10
10
  * So the shape is not a sender's business any more. It lives here, one
11
11
  * implementation, and every report calls it:
12
12
  *
13
- * trend(210, 207) → '210 ▲3'
14
- * trend(202, 207) → '202 ▼5'
15
- * trend(0, 0) → '0 ='
13
+ * trend(210, 207) → '210 / 207 ▲3'
14
+ * trend(202, 207) → '202 / 207 ▼5'
15
+ * trend(0, 0) → '0 / 0 ='
16
16
  * trend(37) → '37' nothing to compare to, so no mark
17
- * trend(4.4, 3.6, '%') → '4.4% ▲0.8' the mark is in the unit left of it
17
+ * trend(4.4, 3.6, '%') → '4.4% / 3.6% ▲0.8'
18
+ *
19
+ * Both numbers are printed, now first and before first. The owner read
20
+ * `51 ▲5` and asked what the 5 was — the new value or the old one. Neither: it
21
+ * was the distance between two numbers, one of which the card never showed.
18
22
  *
19
23
  * The rule the owner asked for, in one line: where there is data to compare
20
24
  * against, the arrow is printed; where there is none, nothing is printed —
package/dist/trend.js CHANGED
@@ -10,11 +10,15 @@
10
10
  * So the shape is not a sender's business any more. It lives here, one
11
11
  * implementation, and every report calls it:
12
12
  *
13
- * trend(210, 207) → '210 ▲3'
14
- * trend(202, 207) → '202 ▼5'
15
- * trend(0, 0) → '0 ='
13
+ * trend(210, 207) → '210 / 207 ▲3'
14
+ * trend(202, 207) → '202 / 207 ▼5'
15
+ * trend(0, 0) → '0 / 0 ='
16
16
  * trend(37) → '37' nothing to compare to, so no mark
17
- * trend(4.4, 3.6, '%') → '4.4% ▲0.8' the mark is in the unit left of it
17
+ * trend(4.4, 3.6, '%') → '4.4% / 3.6% ▲0.8'
18
+ *
19
+ * Both numbers are printed, now first and before first. The owner read
20
+ * `51 ▲5` and asked what the 5 was — the new value or the old one. Neither: it
21
+ * was the distance between two numbers, one of which the card never showed.
18
22
  *
19
23
  * The rule the owner asked for, in one line: where there is data to compare
20
24
  * against, the arrow is printed; where there is none, nothing is printed —
@@ -32,8 +36,9 @@ export const trend = (now, was, unit = '') => {
32
36
  if (was === undefined || !Number.isFinite(was)) {
33
37
  return head;
34
38
  }
39
+ const pair = `${head} / ${fmt(was)}${unit}`;
35
40
  if (same(now, was)) {
36
- return `${head} =`;
41
+ return `${pair} =`;
37
42
  }
38
- return now > was ? `${head} ▲${fmt(now - was)}` : `${head} ▼${fmt(was - now)}`;
43
+ return now > was ? `${pair} ▲${fmt(now - was)}` : `${pair} ▼${fmt(was - now)}`;
39
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikitasazan/notify",
3
- "version": "1.10.1",
3
+ "version": "1.11.0",
4
4
  "description": "Единая типизированная отправка Telegram-уведомлений (форум-темы, маршрутизация, ретраи) для всех проектов",
5
5
  "type": "module",
6
6
  "license": "MIT",