@dsh-plus/notify-email 0.1.22 → 0.1.24

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 CHANGED
@@ -168,7 +168,10 @@ window.__ModuleLoader__.load({
168
168
  confirm: "Confirm",
169
169
  cancel: "Cancel"
170
170
  };
171
- /** own 覆盖同键合并(返回新对象,入参不可变)。 */
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 ["agents", "tools", "credentials"];
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.22",
3
+ "version": "0.1.24",
4
4
  "description": "dsh-plus service+ui plugin: 任务结束/等待决策/出错时向指定邮箱发送邮件通知",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -32,29 +32,29 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "nodemailer": "9.0.6",
35
- "@dsh-plus/shared": "0.1.15"
35
+ "@dsh-plus/shared": "0.1.17"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@deepseek-ai/cordis": "^4.0.2",
39
- "@deepseek-ai/dsh-home-paths": "^0.1.5-rc.1",
40
- "@deepseek-ai/dsh-settings": "^0.1.5-rc.1",
39
+ "@deepseek-ai/dsh-home-paths": "^0.1.5-rc.2",
40
+ "@deepseek-ai/dsh-settings": "^0.1.5-rc.2",
41
41
  "@deepseek-ai/schemastery": "^3.18.2",
42
- "@deepseek-ai/dsh-credentials": "^0.1.5-rc.1"
42
+ "@deepseek-ai/dsh-credentials": "^0.1.5-rc.2"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@deepseek-ai/cordis": "4.0.2",
46
- "@deepseek-ai/dsh-agent": "0.1.5-rc.1",
47
- "@deepseek-ai/dsh-home-paths": "0.1.5-rc.1",
48
- "@deepseek-ai/dsh-host-webserver": "0.1.5-rc.1",
49
- "@deepseek-ai/dsh-llm": "0.1.5-rc.1",
50
- "@deepseek-ai/dsh-session": "0.1.5-rc.1",
51
- "@deepseek-ai/dsh-settings": "0.1.5-rc.1",
52
- "@deepseek-ai/dsh-tools": "0.1.5-rc.1",
46
+ "@deepseek-ai/dsh-agent": "0.1.5-rc.2",
47
+ "@deepseek-ai/dsh-home-paths": "0.1.5-rc.2",
48
+ "@deepseek-ai/dsh-host-webserver": "0.1.5-rc.2",
49
+ "@deepseek-ai/dsh-llm": "0.1.5-rc.2",
50
+ "@deepseek-ai/dsh-session": "0.1.5-rc.2",
51
+ "@deepseek-ai/dsh-settings": "0.1.5-rc.2",
52
+ "@deepseek-ai/dsh-tools": "0.1.5-rc.2",
53
53
  "@deepseek-ai/schemastery": "3.18.2",
54
54
  "@types/nodemailer": "8.0.1",
55
55
  "@types/react": "~18.3.31",
56
56
  "react": "^18.2.0",
57
- "@deepseek-ai/dsh-credentials": "0.1.5-rc.1"
57
+ "@deepseek-ai/dsh-credentials": "0.1.5-rc.2"
58
58
  },
59
59
  "publishConfig": {
60
60
  "access": "public"
@@ -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(key: string): string
28
+ t: Translate
28
29
  scope: Scope
29
30
  api: NamespaceSettingsApi
30
31
  }
@@ -19,39 +19,19 @@ import {
19
19
  createNamespaceApi,
20
20
  createSettingsScope,
21
21
  injectCardStyle,
22
- type SettingsRemoteFace,
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
- interface SlotsLike {
34
- inject(key: string, callback: () => unknown): unknown
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
@@ -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 const zh: Record<string, string> = mergeDict(commonZh, ownZh)
87
- export const en: Record<string, string> = mergeDict(commonEn, ownEn)
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
- private readonly audit?: AuditSink
87
- private readonly credentials?: CredentialsSeamLike
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,
@@ -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
- lastDelivery?: string
22
- timer?: ReturnType<typeof setTimeout>
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