@easy-cms/plugin-notify 1.31.0 → 1.33.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.
Files changed (2) hide show
  1. package/dist/index.js +31 -22
  2. package/package.json +5 -4
package/dist/index.js CHANGED
@@ -79,7 +79,7 @@ function noticeOf(message, language) {
79
79
  return notice && { ...notice, open: T[language].open };
80
80
  }
81
81
  function describe(message, language) {
82
- const t = T[language];
82
+ const t2 = T[language];
83
83
  const d = message.data;
84
84
  const event = message.event;
85
85
  if (!NOTIFY_EVENTS.includes(event)) return null;
@@ -92,7 +92,7 @@ function describe(message, language) {
92
92
  const form = d.form ?? {};
93
93
  return {
94
94
  title,
95
- lines: [...line(t.form, form.title ?? form.id), ...line(t.from, d.email)],
95
+ lines: [...line(t2.form, form.title ?? form.id), ...line(t2.from, d.email)],
96
96
  path: docPath
97
97
  };
98
98
  }
@@ -100,20 +100,20 @@ function describe(message, language) {
100
100
  return {
101
101
  title,
102
102
  lines: [
103
- ...line(t.order, d.orderNumber ? `#${str(d.orderNumber)}` : d.id),
104
- ...line(t.total, money(d.total, d.currency, language)),
105
- ...line(t.email, d.email)
103
+ ...line(t2.order, d.orderNumber ? `#${str(d.orderNumber)}` : d.id),
104
+ ...line(t2.total, money(d.total, d.currency, language)),
105
+ ...line(t2.email, d.email)
106
106
  ],
107
107
  path: docPath
108
108
  };
109
109
  case "scheduled.failed": {
110
- const action = d.action === "unpublish" ? t.unpublish : d.action ? t.publish : "";
110
+ const action = d.action === "unpublish" ? t2.unpublish : d.action ? t2.publish : "";
111
111
  const target = d.global ?? (d.collection ? `${str(d.collection)} ${str(d.doc)}` : "");
112
112
  return {
113
113
  title,
114
114
  lines: [
115
- ...line(t.document, `${str(target)}${action ? ` (${action})` : ""}`.trim()),
116
- ...line(t.error, d.error)
115
+ ...line(t2.document, `${str(target)}${action ? ` (${action})` : ""}`.trim()),
116
+ ...line(t2.error, d.error)
117
117
  ],
118
118
  path: "/jobs?tab=scheduled"
119
119
  };
@@ -122,20 +122,20 @@ function describe(message, language) {
122
122
  return {
123
123
  title,
124
124
  lines: [
125
- ...line(t.to, d.url ?? d.to),
126
- ...line(t.attempts, d.attempts),
127
- ...line(t.error, d.error)
125
+ ...line(t2.to, d.url ?? d.to),
126
+ ...line(t2.attempts, d.attempts),
127
+ ...line(t2.error, d.error)
128
128
  ],
129
129
  path: "/deliveries"
130
130
  };
131
131
  case "backup.failed":
132
- return { title, lines: line(t.error, d.error), path: "/backups" };
132
+ return { title, lines: line(t2.error, d.error), path: "/backups" };
133
133
  case "integration.failed":
134
134
  return {
135
135
  title,
136
136
  lines: [
137
- ...line(t.connection, d.name ? `${str(d.integration)} \xB7 ${str(d.name)}` : d.integration),
138
- ...line(t.error, d.error)
137
+ ...line(t2.connection, d.name ? `${str(d.integration)} \xB7 ${str(d.name)}` : d.integration),
138
+ ...line(t2.error, d.error)
139
139
  ],
140
140
  path: "/integrations"
141
141
  };
@@ -152,9 +152,17 @@ var INFO = {
152
152
  name: "@easy-cms/plugin-notify",
153
153
  // The plugin API it is written for (`PLUGIN_API_VERSION` of @easy-cms/core).
154
154
  apiVersion: 1,
155
- ...true ? { version: "1.31.0" } : {}
155
+ ...true ? { version: "1.33.0" } : {}
156
156
  };
157
157
 
158
+ // ../../node_modules/.pnpm/simple-icons@16.36.0/node_modules/simple-icons/index.mjs
159
+ var c = '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>';
160
+ var t = '</title><path d="';
161
+ var a = '"/></svg>';
162
+ var siTelegram = { title: "Telegram", slug: "telegram", get svg() {
163
+ return c + "Telegram" + t + this.path + a;
164
+ }, path: "M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z", source: "https://telegram.org/tour/screenshots", hex: "26A5E4" };
165
+
158
166
  // src/telegram.ts
159
167
  var api = () => (process.env.TELEGRAM_API_URL ?? "https://api.telegram.org").replace(/\/$/, "");
160
168
  var html = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
@@ -227,7 +235,8 @@ var telegram = {
227
235
  en: "Tell admins about new orders, form answers and failures in a Telegram chat.",
228
236
  th: "\u0E41\u0E08\u0E49\u0E07\u0E1C\u0E39\u0E49\u0E14\u0E39\u0E41\u0E25\u0E40\u0E23\u0E37\u0E48\u0E2D\u0E07\u0E04\u0E33\u0E2A\u0E31\u0E48\u0E07\u0E0B\u0E37\u0E49\u0E2D\u0E43\u0E2B\u0E21\u0E48 \u0E1F\u0E2D\u0E23\u0E4C\u0E21 \u0E41\u0E25\u0E30\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14\u0E43\u0E19\u0E41\u0E0A\u0E15 Telegram"
229
237
  },
230
- icon: "send",
238
+ // A trademark of its owner, naming the service; from simple-icons (CC0), bundled at build time.
239
+ icon: { paths: [{ d: siTelegram.path }], color: `#${siTelegram.hex}` },
231
240
  docs: "https://easycms.dev/docs/notifications",
232
241
  plugin: "@easy-cms/plugin-notify",
233
242
  kind: "fields",
@@ -267,11 +276,11 @@ function notifyPlugin(options = {}) {
267
276
  const channels = options.channels ?? [telegram];
268
277
  const limit = options.limit ?? 60;
269
278
  const slug = options.slug ?? "notify-messages";
270
- const channelIds = new Set(channels.map((c) => c.integration.id));
279
+ const channelIds = new Set(channels.map((c2) => c2.integration.id));
271
280
  if (!Number.isInteger(limit) || limit < 1)
272
281
  throw new Error("notifyPlugin: `limit` must be a whole number above 0");
273
282
  return definePlugin((config) => {
274
- if (config.collections?.some((c) => c.slug === slug))
283
+ if (config.collections?.some((c2) => c2.slug === slug))
275
284
  throw new Error(`notifyPlugin: there is already a collection "${slug}"; set \`slug\``);
276
285
  const adminLanguage = config.admin?.locale === "th" ? "th" : "en";
277
286
  const messages = {
@@ -290,7 +299,7 @@ function notifyPlugin(options = {}) {
290
299
  { name: "error", type: "text" }
291
300
  ]
292
301
  };
293
- const channelOf = (id) => channels.find((c) => c.integration.id === id);
302
+ const channelOf = (id) => channels.find((c2) => c2.integration.id === id);
294
303
  const languageOf = (conn) => conn.values.language === "th" || conn.values.language === "en" ? conn.values.language : adminLanguage;
295
304
  const linkOf = (cms, path) => {
296
305
  const server = cms.config.serverURL?.replace(/\/+$/, "");
@@ -402,11 +411,11 @@ ${String(row.connection)}`;
402
411
  const channel = channelOf(channelId);
403
412
  const conn = channel && await cms.integrations.get(channelId, { name: connection });
404
413
  if (!channel || !conn) continue;
405
- const t = texts(languageOf(conn));
414
+ const t2 = texts(languageOf(conn));
406
415
  const notice = {
407
416
  title: "Easy CMS",
408
- lines: [t.dropped(rows.length, limit)],
409
- open: t.open
417
+ lines: [t2.dropped(rows.length, limit)],
418
+ open: t2.open
410
419
  };
411
420
  await enqueue(cms, channel, conn, "notify.dropped", channel.format(notice, void 0), now);
412
421
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easy-cms/plugin-notify",
3
- "version": "1.31.0",
3
+ "version": "1.33.0",
4
4
  "description": "Notifications for Easy CMS admins: Telegram messages when a form is submitted, an order comes in or something fails",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -16,11 +16,12 @@
16
16
  "dist"
17
17
  ],
18
18
  "peerDependencies": {
19
- "@easy-cms/core": "^1.31.0"
19
+ "@easy-cms/core": "^1.33.0"
20
20
  },
21
21
  "devDependencies": {
22
- "@easy-cms/db-sqlite": "^1.31.0",
23
- "@easy-cms/core": "^1.31.0"
22
+ "simple-icons": "16.36.0",
23
+ "@easy-cms/core": "^1.33.0",
24
+ "@easy-cms/db-sqlite": "^1.33.0"
24
25
  },
25
26
  "engines": {
26
27
  "node": ">=22.12"