@dsh-plus/notify-email 0.1.22 → 0.1.23
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/lib/client.js +4 -1
- package/lib/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/client/card.tsx +2 -1
- package/src/client/client.ts +4 -24
- package/src/client/i18n.ts +10 -4
- package/src/mailer.ts +4 -2
- package/src/watchers/turn-end.ts +5 -2
package/lib/client.js
CHANGED
|
@@ -168,7 +168,10 @@ window.__ModuleLoader__.load({
|
|
|
168
168
|
confirm: "Confirm",
|
|
169
169
|
cancel: "Cancel"
|
|
170
170
|
};
|
|
171
|
-
/**
|
|
171
|
+
/**
|
|
172
|
+
* own 覆盖同键合并(返回新对象,入参不可变)。
|
|
173
|
+
* 返回类型保留两侧键集合,调用方据此派生 DictKey。
|
|
174
|
+
*/
|
|
172
175
|
function mergeDict(base, own) {
|
|
173
176
|
return {
|
|
174
177
|
...base,
|
package/lib/index.d.ts
CHANGED
|
@@ -148,7 +148,7 @@ declare class NotifyEmailService extends Service {
|
|
|
148
148
|
//#endregion
|
|
149
149
|
//#region src/index.d.ts
|
|
150
150
|
declare const name = "dsh-plus-notify-email";
|
|
151
|
-
declare const inject: readonly [
|
|
151
|
+
declare const inject: readonly ['agents', 'tools', 'credentials'];
|
|
152
152
|
declare function apply(ctx: Context, config: NotifyEmailConfig): void;
|
|
153
153
|
//#endregion
|
|
154
154
|
export { Config, type DecisionCall, type EmailNotice, NotifyEmailService, type NotifyTrigger, type TurnEndInfo, apply, inject, name };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-plus/notify-email",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
4
4
|
"description": "dsh-plus service+ui plugin: 任务结束/等待决策/出错时向指定邮箱发送邮件通知",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"nodemailer": "9.0.6",
|
|
35
|
-
"@dsh-plus/shared": "0.1.
|
|
35
|
+
"@dsh-plus/shared": "0.1.16"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@deepseek-ai/cordis": "^4.0.2",
|
package/src/client/card.tsx
CHANGED
|
@@ -22,9 +22,10 @@ import {
|
|
|
22
22
|
import { type ReactElement, useEffect, useMemo, useState, useSyncExternalStore } from 'react'
|
|
23
23
|
import { SETTINGS_NS } from '../ns.ts'
|
|
24
24
|
import { sendTest } from './api.ts'
|
|
25
|
+
import type { Translate } from './i18n.ts'
|
|
25
26
|
|
|
26
27
|
export interface CardProps {
|
|
27
|
-
t
|
|
28
|
+
t: Translate
|
|
28
29
|
scope: Scope
|
|
29
30
|
api: NamespaceSettingsApi
|
|
30
31
|
}
|
package/src/client/client.ts
CHANGED
|
@@ -19,39 +19,19 @@ import {
|
|
|
19
19
|
createNamespaceApi,
|
|
20
20
|
createSettingsScope,
|
|
21
21
|
injectCardStyle,
|
|
22
|
-
type
|
|
22
|
+
type PluginClientContext,
|
|
23
23
|
} from '@dsh-plus/shared/client'
|
|
24
24
|
import { SETTINGS_NS } from '../ns.ts'
|
|
25
25
|
import { NotifyEmailCard } from './card.tsx'
|
|
26
|
-
import { en, NS, zh } from './i18n.ts'
|
|
26
|
+
import { type DictKey, en, NS, zh } from './i18n.ts'
|
|
27
27
|
|
|
28
28
|
export const name = 'dsh-plus-notify-email'
|
|
29
29
|
|
|
30
30
|
/** 浏览器半需要的 cordis 服务 key(loader 据此注入;package.json 的 dsh.client.inject 管包加载顺序)。 */
|
|
31
31
|
export const inject = ['slots', 'locale', 'remote', 'remote.settings'] as const
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
register(options: Record<string, unknown>, component: unknown): () => void
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
interface LocaleLike {
|
|
39
|
-
register(ns: string, dict: { zh: Record<string, string>; en: Record<string, string> }): () => void
|
|
40
|
-
bind(ns: string): (key: string) => string
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface RemoteLike {
|
|
44
|
-
settings: SettingsRemoteFace
|
|
45
|
-
$on(event: string, listener: (payload?: unknown) => void): () => void
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
interface ClientContext {
|
|
49
|
-
slots: SlotsLike
|
|
50
|
-
locale: LocaleLike
|
|
51
|
-
get(key: 'remote'): RemoteLike
|
|
52
|
-
on(event: string, listener: () => void): () => void
|
|
53
|
-
effect(execute: () => () => void, label?: string): unknown
|
|
54
|
-
}
|
|
33
|
+
/** 宿主窄面收编在 @dsh-plus/shared/client;TKey 传入本包 DictKey 使键名受检。 */
|
|
34
|
+
type ClientContext = PluginClientContext<DictKey>
|
|
55
35
|
|
|
56
36
|
export function apply(ctx: Context): void {
|
|
57
37
|
const c = ctx as unknown as ClientContext
|
package/src/client/i18n.ts
CHANGED
|
@@ -43,7 +43,7 @@ const ownZh = {
|
|
|
43
43
|
testDryRun: '已按 dry-run 记录日志(未真实发送)。',
|
|
44
44
|
testFailed: '测试发送失败:',
|
|
45
45
|
incomplete: 'SMTP 配置不完整(服务器/发件地址/收件人必填)。',
|
|
46
|
-
}
|
|
46
|
+
} as const
|
|
47
47
|
|
|
48
48
|
const ownEn = {
|
|
49
49
|
title: 'Email notifications',
|
|
@@ -81,7 +81,13 @@ const ownEn = {
|
|
|
81
81
|
testDryRun: 'Logged in dry-run mode (not sent).',
|
|
82
82
|
testFailed: 'Test send failed: ',
|
|
83
83
|
incomplete: 'SMTP config incomplete (host/from/recipients required).',
|
|
84
|
-
}
|
|
84
|
+
} as const
|
|
85
85
|
|
|
86
|
-
export
|
|
87
|
-
|
|
86
|
+
export type DictKey = keyof typeof commonZh | keyof typeof ownZh
|
|
87
|
+
|
|
88
|
+
/** 卡片/面板共用的翻译函数类型(slot 注入的 bind 结果按此消费)。 */
|
|
89
|
+
export type Translate = (key: DictKey) => string
|
|
90
|
+
|
|
91
|
+
// 标注为 Record<DictKey, string>:en 缺任一键即编译期报错(中英强制对齐)。
|
|
92
|
+
export const zh: Record<DictKey, string> = mergeDict(commonZh, ownZh)
|
|
93
|
+
export const en: Record<DictKey, string> = mergeDict(commonEn, ownEn)
|
package/src/mailer.ts
CHANGED
|
@@ -83,8 +83,10 @@ export class Mailer {
|
|
|
83
83
|
private readonly resolveConfig: () => NotifyEmailConfig
|
|
84
84
|
private readonly logger: MailLogger
|
|
85
85
|
private readonly transport: Transport
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
// 构造期无条件赋值,故为「必需但可为 undefined」:exactOptionalPropertyTypes
|
|
87
|
+
// 下可选属性不允许显式赋 undefined。
|
|
88
|
+
private readonly audit: AuditSink | undefined
|
|
89
|
+
private readonly credentials: CredentialsSeamLike | undefined
|
|
88
90
|
|
|
89
91
|
constructor(
|
|
90
92
|
resolveConfig: () => NotifyEmailConfig,
|
package/src/watchers/turn-end.ts
CHANGED
|
@@ -18,8 +18,11 @@ import type { NotifyEmailService } from '../service.ts'
|
|
|
18
18
|
const NOTIFY_KINDS = new Set(['completed', 'error', 'aborted'])
|
|
19
19
|
|
|
20
20
|
interface SessionWatch {
|
|
21
|
-
|
|
22
|
-
timer
|
|
21
|
+
// 显式并上 undefined:这些字段会被反复赋 undefined 以清空状态
|
|
22
|
+
// (如 `watch.timer = undefined` 取消定时器),exactOptionalPropertyTypes
|
|
23
|
+
// 下可选属性不允许该写法。
|
|
24
|
+
lastDelivery?: string | undefined
|
|
25
|
+
timer?: ReturnType<typeof setTimeout> | undefined
|
|
23
26
|
readonly notified: Set<string>
|
|
24
27
|
}
|
|
25
28
|
|