@things-factory/notification 10.1.218 → 10.1.223
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-client/bootstrap.js +8 -3
- package/dist-client/bootstrap.js.map +1 -1
- package/dist-client/index.d.ts +1 -0
- package/dist-client/index.js +1 -0
- package/dist-client/index.js.map +1 -1
- package/dist-client/store-once.d.ts +14 -0
- package/dist-client/store-once.js +32 -0
- package/dist-client/store-once.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/viewparts/notice-channel-setting-let.d.ts +32 -0
- package/dist-client/viewparts/notice-channel-setting-let.js +175 -0
- package/dist-client/viewparts/notice-channel-setting-let.js.map +1 -0
- package/dist-server/controllers/index.d.ts +1 -0
- package/dist-server/controllers/index.js +1 -0
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/controllers/notice/deliver-notice.d.ts +78 -0
- package/dist-server/controllers/notice/deliver-notice.js +101 -0
- package/dist-server/controllers/notice/deliver-notice.js.map +1 -0
- package/dist-server/controllers/notice/index.d.ts +4 -0
- package/dist-server/controllers/notice/index.js +8 -0
- package/dist-server/controllers/notice/index.js.map +1 -0
- package/dist-server/controllers/notice/notice-channels.d.ts +67 -0
- package/dist-server/controllers/notice/notice-channels.js +62 -0
- package/dist-server/controllers/notice/notice-channels.js.map +1 -0
- package/dist-server/controllers/notice/notice-email.d.ts +28 -0
- package/dist-server/controllers/notice/notice-email.js +125 -0
- package/dist-server/controllers/notice/notice-email.js.map +1 -0
- package/dist-server/controllers/notice/send-notice.d.ts +16 -0
- package/dist-server/controllers/notice/send-notice.js +72 -0
- package/dist-server/controllers/notice/send-notice.js.map +1 -0
- package/dist-server/middlewares/index.d.ts +1 -0
- package/dist-server/middlewares/index.js +3 -0
- package/dist-server/middlewares/index.js.map +1 -1
- package/dist-server/middlewares/notification-middleware.d.ts +19 -0
- package/dist-server/middlewares/notification-middleware.js +9 -3
- package/dist-server/middlewares/notification-middleware.js.map +1 -1
- package/dist-server/service/index.d.ts +1 -1
- package/dist-server/service/index.js +3 -1
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/notice-channel/index.d.ts +2 -0
- package/dist-server/service/notice-channel/index.js +6 -0
- package/dist-server/service/notice-channel/index.js.map +1 -0
- package/dist-server/service/notice-channel/notice-channel-resolver.d.ts +23 -0
- package/dist-server/service/notice-channel/notice-channel-resolver.js +118 -0
- package/dist-server/service/notice-channel/notice-channel-resolver.js.map +1 -0
- package/dist-server/service/notice-channel/notice-channel-rules.d.ts +25 -0
- package/dist-server/service/notice-channel/notice-channel-rules.js +60 -0
- package/dist-server/service/notice-channel/notice-channel-rules.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -7
- package/tests/notice-channel-setting.test.ts +107 -0
- package/tests/notice-delivery.test.ts +328 -0
- package/tests/open-doors.test.ts +5 -2
- package/tests/store-once.test.ts +88 -0
- package/translations/en.json +10 -1
- package/translations/es.json +10 -1
- package/translations/ja.json +10 -1
- package/translations/ko.json +10 -1
- package/translations/ms.json +10 -1
- package/translations/zh.json +10 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WEBHOOK_NOT_HTTPS = void 0;
|
|
4
|
+
exports.secretState = secretState;
|
|
5
|
+
exports.noticeChannelState = noticeChannelState;
|
|
6
|
+
exports.noticeChannelWrites = noticeChannelWrites;
|
|
7
|
+
/*
|
|
8
|
+
* The notice channels as the Settings screen sees them (ADR-0164): whether mail is on, and whether each Teams webhook
|
|
9
|
+
* is set. A webhook address is a secret - whoever holds it can post - so it goes in and never comes back; the screen
|
|
10
|
+
* learns only that it is set and its host.
|
|
11
|
+
*/
|
|
12
|
+
const shell_1 = require("@things-factory/shell");
|
|
13
|
+
const notice_channels_js_1 = require("../../controllers/notice/notice-channels.js");
|
|
14
|
+
/** Set or not, and the host - enough to tell which flow it is without handing out the address. */
|
|
15
|
+
function secretState(value) {
|
|
16
|
+
const raw = String(value ?? '').trim();
|
|
17
|
+
if (!raw)
|
|
18
|
+
return { set: false };
|
|
19
|
+
try {
|
|
20
|
+
return { set: true, host: new URL(raw).host };
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return { set: true };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function noticeChannelState(attributes) {
|
|
27
|
+
return {
|
|
28
|
+
email: String(attributes?.[notice_channels_js_1.NOTICE_EMAIL] ?? '').trim().toLowerCase() === 'on',
|
|
29
|
+
teamsChannel: secretState(attributes?.[notice_channels_js_1.NOTICE_TEAMS_CHANNEL])
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.WEBHOOK_NOT_HTTPS = 'notice-webhook-not-https';
|
|
33
|
+
/**
|
|
34
|
+
* The domain attributes a patch writes: a value to keep, or null to remove the domain's own. A webhook that is not an
|
|
35
|
+
* https address is refused by name - the channels would ignore it, and the person would think it was set.
|
|
36
|
+
*/
|
|
37
|
+
function noticeChannelWrites(patch) {
|
|
38
|
+
const writes = [];
|
|
39
|
+
if (typeof patch.email === 'boolean')
|
|
40
|
+
writes.push({ name: notice_channels_js_1.NOTICE_EMAIL, value: patch.email ? 'on' : 'off' });
|
|
41
|
+
for (const [field, name] of [['teamsChannelWebhook', notice_channels_js_1.NOTICE_TEAMS_CHANNEL]]) {
|
|
42
|
+
if (patch[field] === undefined)
|
|
43
|
+
continue;
|
|
44
|
+
const value = String(patch[field] ?? '').trim();
|
|
45
|
+
if (!value) {
|
|
46
|
+
writes.push({ name, value: null });
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
let https = false;
|
|
50
|
+
try {
|
|
51
|
+
https = new URL(value).protocol === 'https:';
|
|
52
|
+
}
|
|
53
|
+
catch { }
|
|
54
|
+
if (!https)
|
|
55
|
+
throw new shell_1.Refusal(exports.WEBHOOK_NOT_HTTPS, { field }, 'A Teams webhook address starts with https://');
|
|
56
|
+
writes.push({ name, value });
|
|
57
|
+
}
|
|
58
|
+
return writes;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=notice-channel-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notice-channel-rules.js","sourceRoot":"","sources":["../../../server/service/notice-channel/notice-channel-rules.ts"],"names":[],"mappings":";;;AAgBA,kCAQC;AAED,gDAKC;AAQD,kDAuBC;AA9DD;;;;GAIG;AACH,iDAA+C;AAE/C,oFAAgG;AAQhG,kGAAkG;AAClG,SAAgB,WAAW,CAAC,KAAgC;IAC1D,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IACtC,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;IAC/B,IAAI,CAAC;QACH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAA;IACtB,CAAC;AACH,CAAC;AAED,SAAgB,kBAAkB,CAAC,UAAiE;IAClG,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,iCAAY,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,IAAI;QAC7E,YAAY,EAAE,WAAW,CAAC,UAAU,EAAE,CAAC,yCAAoB,CAAC,CAAC;KAC9D,CAAA;AACH,CAAC;AAEY,QAAA,iBAAiB,GAAG,0BAA0B,CAAA;AAE3D;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,KAAyB;IAC3D,MAAM,MAAM,GAA6C,EAAE,CAAA;IAE3D,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,SAAS;QAAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,iCAAY,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAA;IAE5G,KAAK,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAE,yCAAoB,CAAC,CAAU,EAAE,CAAC;QACrF,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,SAAS;YAAE,SAAQ;QACxC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;QAC/C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;YAClC,SAAQ;QACV,CAAC;QAED,IAAI,KAAK,GAAG,KAAK,CAAA;QACjB,IAAI,CAAC;YACH,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAA;QAC9C,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QACV,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,eAAO,CAAC,yBAAiB,EAAE,EAAE,KAAK,EAAE,EAAE,8CAA8C,CAAC,CAAA;QAE3G,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IAC9B,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["/*\n * The notice channels as the Settings screen sees them (ADR-0164): whether mail is on, and whether each Teams webhook\n * is set. A webhook address is a secret - whoever holds it can post - so it goes in and never comes back; the screen\n * learns only that it is set and its host.\n */\nimport { Refusal } from '@things-factory/shell'\n\nimport { NOTICE_EMAIL, NOTICE_TEAMS_CHANNEL } from '../../controllers/notice/notice-channels.js'\n\nexport type SecretState = { set: boolean; host?: string }\nexport type NoticeChannelState = { email: boolean; teamsChannel: SecretState }\n\n/** What may change - a field left out stays as it is; an empty webhook clears it. */\nexport type NoticeChannelPatch = { email?: boolean | null; teamsChannelWebhook?: string | null }\n\n/** Set or not, and the host - enough to tell which flow it is without handing out the address. */\nexport function secretState(value: string | null | undefined): SecretState {\n const raw = String(value ?? '').trim()\n if (!raw) return { set: false }\n try {\n return { set: true, host: new URL(raw).host }\n } catch {\n return { set: true }\n }\n}\n\nexport function noticeChannelState(attributes: Record<string, string | undefined> | null | undefined): NoticeChannelState {\n return {\n email: String(attributes?.[NOTICE_EMAIL] ?? '').trim().toLowerCase() === 'on',\n teamsChannel: secretState(attributes?.[NOTICE_TEAMS_CHANNEL])\n }\n}\n\nexport const WEBHOOK_NOT_HTTPS = 'notice-webhook-not-https'\n\n/**\n * The domain attributes a patch writes: a value to keep, or null to remove the domain's own. A webhook that is not an\n * https address is refused by name - the channels would ignore it, and the person would think it was set.\n */\nexport function noticeChannelWrites(patch: NoticeChannelPatch): { name: string; value: string | null }[] {\n const writes: { name: string; value: string | null }[] = []\n\n if (typeof patch.email === 'boolean') writes.push({ name: NOTICE_EMAIL, value: patch.email ? 'on' : 'off' })\n\n for (const [field, name] of [['teamsChannelWebhook', NOTICE_TEAMS_CHANNEL]] as const) {\n if (patch[field] === undefined) continue\n const value = String(patch[field] ?? '').trim()\n if (!value) {\n writes.push({ name, value: null })\n continue\n }\n\n let https = false\n try {\n https = new URL(value).protocol === 'https:'\n } catch {}\n if (!https) throw new Refusal(WEBHOOK_NOT_HTTPS, { field }, 'A Teams webhook address starts with https://')\n\n writes.push({ name, value })\n }\n\n return writes\n}\n"]}
|