@zhin.js/plugin-ledger 1.0.1 → 1.0.3
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/README.md +24 -0
- package/commands/ledger-add/index.js +6 -4
- package/commands/ledger-add/index.ts +6 -4
- package/commands/ledger-delete/index.js +6 -4
- package/commands/ledger-delete/index.ts +6 -4
- package/commands/ledger-list/index.js +8 -6
- package/commands/ledger-list/index.ts +8 -6
- package/commands/ledger-month/index.js +5 -3
- package/commands/ledger-month/index.ts +5 -3
- package/commands/ledger-report/index.js +11 -11
- package/commands/ledger-report/index.ts +10 -12
- package/commands/ledger-stats/index.js +8 -6
- package/commands/ledger-stats/index.ts +8 -6
- package/commands/ledger-today/index.js +5 -3
- package/commands/ledger-today/index.ts +5 -3
- package/commands/ledger-week/index.js +5 -3
- package/commands/ledger-week/index.ts +5 -3
- package/lib/config.d.ts +11 -5
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +3 -3
- package/lib/config.js.map +1 -1
- package/lib/console.d.ts +4 -0
- package/lib/console.d.ts.map +1 -0
- package/lib/console.js +39 -0
- package/lib/console.js.map +1 -0
- package/lib/entry-input.d.ts +3 -2
- package/lib/entry-input.d.ts.map +1 -1
- package/lib/entry-input.js +11 -9
- package/lib/entry-input.js.map +1 -1
- package/lib/i18n.d.ts +2 -0
- package/lib/i18n.d.ts.map +1 -0
- package/lib/i18n.js +200 -0
- package/lib/i18n.js.map +1 -0
- package/lib/identity.d.ts +3 -1
- package/lib/identity.d.ts.map +1 -1
- package/lib/identity.js +5 -2
- package/lib/identity.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/money.d.ts +2 -1
- package/lib/money.d.ts.map +1 -1
- package/lib/money.js +6 -5
- package/lib/money.js.map +1 -1
- package/lib/period.d.ts +4 -3
- package/lib/period.d.ts.map +1 -1
- package/lib/period.js +8 -16
- package/lib/period.js.map +1 -1
- package/lib/report-format.d.ts +5 -4
- package/lib/report-format.d.ts.map +1 -1
- package/lib/report-format.js +25 -24
- package/lib/report-format.js.map +1 -1
- package/lib/service.d.ts +14 -1
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +41 -24
- package/lib/service.js.map +1 -1
- package/lib/store.d.ts +3 -1
- package/lib/store.d.ts.map +1 -1
- package/lib/store.js +8 -4
- package/lib/store.js.map +1 -1
- package/lib/tool-caller.d.ts +32 -0
- package/lib/tool-caller.d.ts.map +1 -0
- package/lib/tool-caller.js +74 -0
- package/lib/tool-caller.js.map +1 -0
- package/package.json +36 -7
- package/pages/index/index.js +63 -0
- package/pages/index/index.ts +65 -0
- package/plugin.js +3 -1
- package/schema.json +15 -0
- package/skills/ledger/SKILL.md +41 -0
- package/skills/ledger/tools/ledger_add/index.js +25 -0
- package/skills/ledger/tools/ledger_add/index.ts +26 -0
- package/skills/ledger/tools/ledger_delete/index.js +22 -0
- package/skills/ledger/tools/ledger_delete/index.ts +23 -0
- package/skills/ledger/tools/ledger_list/index.js +23 -0
- package/skills/ledger/tools/ledger_list/index.ts +24 -0
- package/skills/ledger/tools/ledger_summary/index.js +27 -0
- package/skills/ledger/tools/ledger_summary/index.ts +28 -0
- package/src/config.ts +3 -3
- package/src/console.ts +47 -0
- package/src/entry-input.ts +12 -9
- package/src/i18n.ts +200 -0
- package/src/identity.ts +6 -2
- package/src/index.ts +9 -1
- package/src/money.ts +7 -5
- package/src/period.ts +7 -13
- package/src/report-format.ts +26 -24
- package/src/service.ts +56 -24
- package/src/store.ts +9 -4
- package/src/tool-caller.ts +101 -0
package/README.md
CHANGED
|
@@ -73,6 +73,24 @@ ledger:
|
|
|
73
73
|
|
|
74
74
|
发送 `记账日报 开启` 订阅。插件每分钟检查一次,按 `timezone` 到达 `reportTime` 后给订阅者私信当天的合计和分类明细,每人每天最多一次;当天没有记账时默认不发送。在群里开启时会先私信一条确认,私信失败则不开启并提示先私聊 Bot。在 `reportTime` 之后开启的,从第二天开始发送。投递失败只记录日志,当天不重试。
|
|
75
75
|
|
|
76
|
+
## Agent 工具与技能
|
|
77
|
+
|
|
78
|
+
启用 `@zhin.js/tool` 与 `@zhin.js/skill` Feature 后,本插件提供 `ledger` 技能与以下工具(按当前发送者隔离,群聊遵守同样的金额隐私策略):
|
|
79
|
+
|
|
80
|
+
| 工具 | 权限/属性 | 说明 |
|
|
81
|
+
| --- | --- | --- |
|
|
82
|
+
| `ledger_add` | `requiresApproval: 'always'` | 记录一笔个人支出(`category`、`amount`、可选 `note`) |
|
|
83
|
+
| `ledger_summary` | `readOnly: true` | 查看 `today` / `week` / `month` 的消费汇总(`summary`)或分类统计(`categories`) |
|
|
84
|
+
| `ledger_list` | `readOnly: true` | 查看指定时间段内的账单明细与编号(`#seq`) |
|
|
85
|
+
| `ledger_delete` | `requiresApproval: 'always'` | 按编号 `seq` 删除当前发送者自己的账目 |
|
|
86
|
+
|
|
87
|
+
## Console 页面与 RPC
|
|
88
|
+
|
|
89
|
+
启用 `@zhin.js/page` Feature 后,插件暴露声明式页面 `pages/index/index.ts` 与 Console RPC:
|
|
90
|
+
|
|
91
|
+
- `status`(`ledger:read`):返回日报订阅人数、订阅状态摘要(`ownerKey`、`reportLocale`、`lastReportDate`)与运行配置,不暴露个人消费明细或金额。
|
|
92
|
+
- `run-daily-reports`(`ledger:write`):立即触发一次当日日报检查与投递。
|
|
93
|
+
|
|
76
94
|
## 开发
|
|
77
95
|
|
|
78
96
|
```bash
|
|
@@ -82,3 +100,9 @@ pnpm --filter @zhin.js/plugin-ledger test
|
|
|
82
100
|
```
|
|
83
101
|
|
|
84
102
|
测试使用 `@zhin.js/testing` 的 `FakePlugin` 与 `FakeClock`,覆盖金额与输入解析、用户隔离、群聊隐私、删除权限、时区下的日/周/月边界和日报调度。
|
|
103
|
+
|
|
104
|
+
## 语言
|
|
105
|
+
|
|
106
|
+
指令反馈跟随当前发送者语言;英文环境的时间范围为 `today / week / month / all`,日报操作为 `on / off / status`,中文环境仍使用对应中文输入。命令路径与已有别名保持不变,提示中的调用头由当前 Endpoint 的实际前缀及插件命名空间生成。
|
|
107
|
+
|
|
108
|
+
每日日报在开启时固定语言,之后修改个人偏好不改变已开启日报。旧数据库的日报仍按中文发送,启动时仅增补声明的可空语言列。语言不改变配置时区、人民币金额格式或群聊金额隐私。
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { resolveLocale } from 'zhin.js/i18n';
|
|
3
|
+
import { messages as t } from "../../lib/i18n.js";
|
|
2
4
|
import { defineCommand } from 'zhin.js/command';
|
|
3
5
|
import { ledgerCaller, replyLedger } from "../../lib/identity.js";
|
|
4
6
|
import { ledgerServiceToken } from "../../lib/runtime.js";
|
|
5
7
|
export default defineCommand({
|
|
6
|
-
description: '记一笔消费:记 <类别> <金额> [备注]',
|
|
8
|
+
description: '记一笔消费:记 <类别> <金额> [备注]', descriptionI18n: { en: "Record an expense with a category, amount and optional note" },
|
|
7
9
|
alias: ['记'],
|
|
8
10
|
params: {
|
|
9
|
-
entry: { type: 'text', min: 1, max: 200, description: '类别 金额 [备注],例如:午饭 18.5 和同事' },
|
|
11
|
+
entry: { type: 'text', min: 1, max: 200, description: '类别 金额 [备注],例如:午饭 18.5 和同事', descriptionI18n: { en: "Category, amount and optional note, such as Lunch 18.5 With colleagues" } },
|
|
10
12
|
},
|
|
11
|
-
async execute({ input, params, use }) {
|
|
13
|
+
async execute({ input, params, use, locale, formatCommand }) {
|
|
12
14
|
return replyLedger(async () => {
|
|
13
|
-
const caller = ledgerCaller(input);
|
|
15
|
+
const caller = ledgerCaller(input, locale);
|
|
14
16
|
return use(ledgerServiceToken).addEntry(caller, params.entry);
|
|
15
17
|
});
|
|
16
18
|
},
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
import { resolveLocale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../../src/i18n.js';
|
|
1
3
|
import { defineCommand } from 'zhin.js/command';
|
|
2
4
|
import { ledgerCaller, replyLedger } from '../../src/identity.js';
|
|
3
5
|
import { ledgerServiceToken } from '../../src/runtime.js';
|
|
4
6
|
|
|
5
7
|
export default defineCommand({
|
|
6
|
-
description: '记一笔消费:记 <类别> <金额> [备注]',
|
|
8
|
+
description: '记一笔消费:记 <类别> <金额> [备注]', descriptionI18n: { en: "Record an expense with a category, amount and optional note" },
|
|
7
9
|
alias: ['记'],
|
|
8
10
|
params: {
|
|
9
|
-
entry: { type: 'text', min: 1, max: 200, description: '类别 金额 [备注],例如:午饭 18.5 和同事' },
|
|
11
|
+
entry: { type: 'text', min: 1, max: 200, description: '类别 金额 [备注],例如:午饭 18.5 和同事', descriptionI18n: { en: "Category, amount and optional note, such as Lunch 18.5 With colleagues" } },
|
|
10
12
|
},
|
|
11
|
-
async execute({ input, params, use }) {
|
|
13
|
+
async execute({ input, params, use, locale, formatCommand }) {
|
|
12
14
|
return replyLedger(async () => {
|
|
13
|
-
const caller = ledgerCaller(input);
|
|
15
|
+
const caller = ledgerCaller(input, locale);
|
|
14
16
|
return use(ledgerServiceToken).addEntry(caller, params.entry);
|
|
15
17
|
});
|
|
16
18
|
},
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { resolveLocale } from 'zhin.js/i18n';
|
|
3
|
+
import { messages as t } from "../../lib/i18n.js";
|
|
2
4
|
import { defineCommand } from 'zhin.js/command';
|
|
3
5
|
import { ledgerCaller, replyLedger } from "../../lib/identity.js";
|
|
4
6
|
import { ledgerServiceToken } from "../../lib/runtime.js";
|
|
5
7
|
export default defineCommand({
|
|
6
|
-
description: '删除自己的一笔记账:删账 <编号>',
|
|
8
|
+
description: '删除自己的一笔记账:删账 <编号>', descriptionI18n: { en: "Delete one of your expense records" },
|
|
7
9
|
alias: ['删账'],
|
|
8
10
|
params: {
|
|
9
|
-
id: { type: 'integer', min: 1, description: '账目编号(记账回复或「账单」中的 #编号)' },
|
|
11
|
+
id: { type: 'integer', min: 1, description: '账目编号(记账回复或「账单」中的 #编号)', descriptionI18n: { en: "Record ID from the expense list" } },
|
|
10
12
|
},
|
|
11
|
-
async execute({ input, params, use }) {
|
|
13
|
+
async execute({ input, params, use, locale, formatCommand }) {
|
|
12
14
|
return replyLedger(async () => {
|
|
13
|
-
const caller = ledgerCaller(input);
|
|
15
|
+
const caller = ledgerCaller(input, locale);
|
|
14
16
|
return use(ledgerServiceToken).deleteEntry(caller, params.id);
|
|
15
17
|
});
|
|
16
18
|
},
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
import { resolveLocale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../../src/i18n.js';
|
|
1
3
|
import { defineCommand } from 'zhin.js/command';
|
|
2
4
|
import { ledgerCaller, replyLedger } from '../../src/identity.js';
|
|
3
5
|
import { ledgerServiceToken } from '../../src/runtime.js';
|
|
4
6
|
|
|
5
7
|
export default defineCommand({
|
|
6
|
-
description: '删除自己的一笔记账:删账 <编号>',
|
|
8
|
+
description: '删除自己的一笔记账:删账 <编号>', descriptionI18n: { en: "Delete one of your expense records" },
|
|
7
9
|
alias: ['删账'],
|
|
8
10
|
params: {
|
|
9
|
-
id: { type: 'integer', min: 1, description: '账目编号(记账回复或「账单」中的 #编号)' },
|
|
11
|
+
id: { type: 'integer', min: 1, description: '账目编号(记账回复或「账单」中的 #编号)', descriptionI18n: { en: "Record ID from the expense list" } },
|
|
10
12
|
},
|
|
11
|
-
async execute({ input, params, use }) {
|
|
13
|
+
async execute({ input, params, use, locale, formatCommand }) {
|
|
12
14
|
return replyLedger(async () => {
|
|
13
|
-
const caller = ledgerCaller(input);
|
|
15
|
+
const caller = ledgerCaller(input, locale);
|
|
14
16
|
return use(ledgerServiceToken).deleteEntry(caller, params.id);
|
|
15
17
|
});
|
|
16
18
|
},
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { resolveLocale } from 'zhin.js/i18n';
|
|
3
|
+
import { messages as t } from "../../lib/i18n.js";
|
|
2
4
|
import { defineCommand } from 'zhin.js/command';
|
|
3
5
|
import { ledgerCaller, replyLedger } from "../../lib/identity.js";
|
|
4
6
|
import { parsePeriodWord } from "../../lib/period.js";
|
|
5
7
|
import { ledgerServiceToken } from "../../lib/runtime.js";
|
|
6
8
|
export default defineCommand({
|
|
7
|
-
description: '列出账目及编号(最新 20 笔):账单 [今日|本周|本月|全部],默认本月',
|
|
9
|
+
description: '列出账目及编号(最新 20 笔):账单 [今日|本周|本月|全部],默认本月', descriptionI18n: { en: "List the latest 20 expense records with IDs; defaults to the current month" },
|
|
8
10
|
alias: ['账单'],
|
|
9
11
|
params: {
|
|
10
|
-
period: { type: 'word', optional: true, description: '今日、本周、本月或全部' },
|
|
12
|
+
period: { type: 'word', optional: true, description: '今日、本周、本月或全部', descriptionI18n: { en: "Today, this week, this month, or all time" } },
|
|
11
13
|
},
|
|
12
|
-
async execute({ input, params, use }) {
|
|
14
|
+
async execute({ input, params, use, locale, formatCommand }) {
|
|
13
15
|
return replyLedger(async () => {
|
|
14
|
-
const caller = ledgerCaller(input);
|
|
15
|
-
const period = parsePeriodWord(params.period, 'month');
|
|
16
|
+
const caller = ledgerCaller(input, locale);
|
|
17
|
+
const period = parsePeriodWord(params.period, 'month', locale);
|
|
16
18
|
if (!period)
|
|
17
|
-
return '
|
|
19
|
+
return t(locale, 'periodInput');
|
|
18
20
|
return use(ledgerServiceToken).listEntries(caller, period);
|
|
19
21
|
});
|
|
20
22
|
},
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
+
import { resolveLocale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../../src/i18n.js';
|
|
1
3
|
import { defineCommand } from 'zhin.js/command';
|
|
2
4
|
import { ledgerCaller, replyLedger } from '../../src/identity.js';
|
|
3
5
|
import { parsePeriodWord } from '../../src/period.js';
|
|
4
6
|
import { ledgerServiceToken } from '../../src/runtime.js';
|
|
5
7
|
|
|
6
8
|
export default defineCommand({
|
|
7
|
-
description: '列出账目及编号(最新 20 笔):账单 [今日|本周|本月|全部],默认本月',
|
|
9
|
+
description: '列出账目及编号(最新 20 笔):账单 [今日|本周|本月|全部],默认本月', descriptionI18n: { en: "List the latest 20 expense records with IDs; defaults to the current month" },
|
|
8
10
|
alias: ['账单'],
|
|
9
11
|
params: {
|
|
10
|
-
period: { type: 'word', optional: true, description: '今日、本周、本月或全部' },
|
|
12
|
+
period: { type: 'word', optional: true, description: '今日、本周、本月或全部', descriptionI18n: { en: "Today, this week, this month, or all time" } },
|
|
11
13
|
},
|
|
12
|
-
async execute({ input, params, use }) {
|
|
14
|
+
async execute({ input, params, use, locale, formatCommand }) {
|
|
13
15
|
return replyLedger(async () => {
|
|
14
|
-
const caller = ledgerCaller(input);
|
|
15
|
-
const period = parsePeriodWord(params.period, 'month');
|
|
16
|
-
if (!period) return '
|
|
16
|
+
const caller = ledgerCaller(input, locale);
|
|
17
|
+
const period = parsePeriodWord(params.period, 'month', locale);
|
|
18
|
+
if (!period) return t(locale, 'periodInput');
|
|
17
19
|
return use(ledgerServiceToken).listEntries(caller, period);
|
|
18
20
|
});
|
|
19
21
|
},
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { resolveLocale } from 'zhin.js/i18n';
|
|
3
|
+
import { messages as t } from "../../lib/i18n.js";
|
|
2
4
|
import { defineCommand } from 'zhin.js/command';
|
|
3
5
|
import { ledgerCaller, replyLedger } from "../../lib/identity.js";
|
|
4
6
|
import { ledgerServiceToken } from "../../lib/runtime.js";
|
|
5
7
|
export default defineCommand({
|
|
6
|
-
description: '查看本月消费合计与分类明细',
|
|
8
|
+
description: '查看本月消费合计与分类明细', descriptionI18n: { en: "View this month's spending totals and categories" },
|
|
7
9
|
alias: ['本月消费'],
|
|
8
|
-
async execute({ input, use }) {
|
|
10
|
+
async execute({ input, use, locale, formatCommand }) {
|
|
9
11
|
return replyLedger(async () => {
|
|
10
|
-
const caller = ledgerCaller(input);
|
|
12
|
+
const caller = ledgerCaller(input, locale);
|
|
11
13
|
return use(ledgerServiceToken).periodSummary(caller, 'month');
|
|
12
14
|
});
|
|
13
15
|
},
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { resolveLocale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../../src/i18n.js';
|
|
1
3
|
import { defineCommand } from 'zhin.js/command';
|
|
2
4
|
import { ledgerCaller, replyLedger } from '../../src/identity.js';
|
|
3
5
|
import { ledgerServiceToken } from '../../src/runtime.js';
|
|
4
6
|
|
|
5
7
|
export default defineCommand({
|
|
6
|
-
description: '查看本月消费合计与分类明细',
|
|
8
|
+
description: '查看本月消费合计与分类明细', descriptionI18n: { en: "View this month's spending totals and categories" },
|
|
7
9
|
alias: ['本月消费'],
|
|
8
|
-
async execute({ input, use }) {
|
|
10
|
+
async execute({ input, use, locale, formatCommand }) {
|
|
9
11
|
return replyLedger(async () => {
|
|
10
|
-
const caller = ledgerCaller(input);
|
|
12
|
+
const caller = ledgerCaller(input, locale);
|
|
11
13
|
return use(ledgerServiceToken).periodSummary(caller, 'month');
|
|
12
14
|
});
|
|
13
15
|
},
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { resolveLocale } from 'zhin.js/i18n';
|
|
3
|
+
import { messages as t } from "../../lib/i18n.js";
|
|
2
4
|
import { defineCommand } from 'zhin.js/command';
|
|
3
5
|
import { ledgerCaller, replyLedger } from "../../lib/identity.js";
|
|
4
6
|
import { ledgerServiceToken } from "../../lib/runtime.js";
|
|
5
|
-
const ACTIONS = {
|
|
6
|
-
开启: 'on',
|
|
7
|
-
关闭: 'off',
|
|
8
|
-
状态: 'status',
|
|
9
|
-
};
|
|
10
7
|
export default defineCommand({
|
|
11
|
-
description: '订阅或取消每日私信记账日报:记账日报 [开启|关闭|状态]',
|
|
8
|
+
description: '订阅或取消每日私信记账日报:记账日报 [开启|关闭|状态]', descriptionI18n: { en: "Manage the daily expense report sent by private message" },
|
|
12
9
|
alias: ['记账日报'],
|
|
13
10
|
params: {
|
|
14
|
-
action: { type: 'word', optional: true,
|
|
11
|
+
action: { type: 'word', optional: true, description: '开启、关闭或状态(默认状态)', descriptionI18n: { en: "on, off, or status (default: status)" } },
|
|
15
12
|
},
|
|
16
|
-
async execute({ input, params, use }) {
|
|
13
|
+
async execute({ input, params, use, locale, formatCommand }) {
|
|
17
14
|
return replyLedger(async () => {
|
|
18
|
-
const caller = ledgerCaller(input);
|
|
19
|
-
const
|
|
20
|
-
|
|
15
|
+
const caller = ledgerCaller(input, locale);
|
|
16
|
+
const actions = resolveLocale(locale) === 'en' ? { on: 'on', off: 'off', status: 'status' } : { 开启: 'on', 关闭: 'off', 状态: 'status' };
|
|
17
|
+
const action = params.action === undefined ? 'status' : actions[params.action];
|
|
18
|
+
if (!action)
|
|
19
|
+
return t(locale, 'actionInput');
|
|
20
|
+
return use(ledgerServiceToken).dailyReport(caller, action, formatCommand('ledger-report'));
|
|
21
21
|
});
|
|
22
22
|
},
|
|
23
23
|
});
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
+
import { resolveLocale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../../src/i18n.js';
|
|
1
3
|
import { defineCommand } from 'zhin.js/command';
|
|
2
4
|
import { ledgerCaller, replyLedger } from '../../src/identity.js';
|
|
3
5
|
import { ledgerServiceToken } from '../../src/runtime.js';
|
|
4
6
|
import type { DailyReportAction } from '../../src/service.js';
|
|
5
7
|
|
|
6
|
-
const ACTIONS: Readonly<Record<string, DailyReportAction>> = {
|
|
7
|
-
开启: 'on',
|
|
8
|
-
关闭: 'off',
|
|
9
|
-
状态: 'status',
|
|
10
|
-
};
|
|
11
|
-
|
|
12
8
|
export default defineCommand({
|
|
13
|
-
description: '订阅或取消每日私信记账日报:记账日报 [开启|关闭|状态]',
|
|
9
|
+
description: '订阅或取消每日私信记账日报:记账日报 [开启|关闭|状态]', descriptionI18n: { en: "Manage the daily expense report sent by private message" },
|
|
14
10
|
alias: ['记账日报'],
|
|
15
11
|
params: {
|
|
16
|
-
action: { type: 'word', optional: true,
|
|
12
|
+
action: { type: 'word', optional: true, description: '开启、关闭或状态(默认状态)', descriptionI18n: { en: "on, off, or status (default: status)" } },
|
|
17
13
|
},
|
|
18
|
-
async execute({ input, params, use }) {
|
|
14
|
+
async execute({ input, params, use, locale, formatCommand }) {
|
|
19
15
|
return replyLedger(async () => {
|
|
20
|
-
const caller = ledgerCaller(input);
|
|
21
|
-
const
|
|
22
|
-
|
|
16
|
+
const caller = ledgerCaller(input, locale);
|
|
17
|
+
const actions: Readonly<Record<string, DailyReportAction>> = resolveLocale(locale) === 'en' ? { on: 'on', off: 'off', status: 'status' } : { 开启: 'on', 关闭: 'off', 状态: 'status' };
|
|
18
|
+
const action = params.action === undefined ? 'status' : actions[params.action];
|
|
19
|
+
if (!action) return t(locale, 'actionInput');
|
|
20
|
+
return use(ledgerServiceToken).dailyReport(caller, action, formatCommand('ledger-report'));
|
|
23
21
|
});
|
|
24
22
|
},
|
|
25
23
|
});
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { resolveLocale } from 'zhin.js/i18n';
|
|
3
|
+
import { messages as t } from "../../lib/i18n.js";
|
|
2
4
|
import { defineCommand } from 'zhin.js/command';
|
|
3
5
|
import { ledgerCaller, replyLedger } from "../../lib/identity.js";
|
|
4
6
|
import { parsePeriodWord } from "../../lib/period.js";
|
|
5
7
|
import { ledgerServiceToken } from "../../lib/runtime.js";
|
|
6
8
|
export default defineCommand({
|
|
7
|
-
description: '按类别统计合计、笔数、平均、最大与占比:分类统计 [今日|本周|本月|全部],默认本月',
|
|
9
|
+
description: '按类别统计合计、笔数、平均、最大与占比:分类统计 [今日|本周|本月|全部],默认本月', descriptionI18n: { en: "Category totals, counts, averages, maxima and proportions; defaults to the current month" },
|
|
8
10
|
alias: ['分类统计'],
|
|
9
11
|
params: {
|
|
10
|
-
period: { type: 'word', optional: true, description: '今日、本周、本月或全部' },
|
|
12
|
+
period: { type: 'word', optional: true, description: '今日、本周、本月或全部', descriptionI18n: { en: "Today, this week, this month, or all time" } },
|
|
11
13
|
},
|
|
12
|
-
async execute({ input, params, use }) {
|
|
14
|
+
async execute({ input, params, use, locale, formatCommand }) {
|
|
13
15
|
return replyLedger(async () => {
|
|
14
|
-
const caller = ledgerCaller(input);
|
|
15
|
-
const period = parsePeriodWord(params.period, 'month');
|
|
16
|
+
const caller = ledgerCaller(input, locale);
|
|
17
|
+
const period = parsePeriodWord(params.period, 'month', locale);
|
|
16
18
|
if (!period)
|
|
17
|
-
return '
|
|
19
|
+
return t(locale, 'periodInput');
|
|
18
20
|
return use(ledgerServiceToken).categoryStatistics(caller, period);
|
|
19
21
|
});
|
|
20
22
|
},
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
+
import { resolveLocale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../../src/i18n.js';
|
|
1
3
|
import { defineCommand } from 'zhin.js/command';
|
|
2
4
|
import { ledgerCaller, replyLedger } from '../../src/identity.js';
|
|
3
5
|
import { parsePeriodWord } from '../../src/period.js';
|
|
4
6
|
import { ledgerServiceToken } from '../../src/runtime.js';
|
|
5
7
|
|
|
6
8
|
export default defineCommand({
|
|
7
|
-
description: '按类别统计合计、笔数、平均、最大与占比:分类统计 [今日|本周|本月|全部],默认本月',
|
|
9
|
+
description: '按类别统计合计、笔数、平均、最大与占比:分类统计 [今日|本周|本月|全部],默认本月', descriptionI18n: { en: "Category totals, counts, averages, maxima and proportions; defaults to the current month" },
|
|
8
10
|
alias: ['分类统计'],
|
|
9
11
|
params: {
|
|
10
|
-
period: { type: 'word', optional: true, description: '今日、本周、本月或全部' },
|
|
12
|
+
period: { type: 'word', optional: true, description: '今日、本周、本月或全部', descriptionI18n: { en: "Today, this week, this month, or all time" } },
|
|
11
13
|
},
|
|
12
|
-
async execute({ input, params, use }) {
|
|
14
|
+
async execute({ input, params, use, locale, formatCommand }) {
|
|
13
15
|
return replyLedger(async () => {
|
|
14
|
-
const caller = ledgerCaller(input);
|
|
15
|
-
const period = parsePeriodWord(params.period, 'month');
|
|
16
|
-
if (!period) return '
|
|
16
|
+
const caller = ledgerCaller(input, locale);
|
|
17
|
+
const period = parsePeriodWord(params.period, 'month', locale);
|
|
18
|
+
if (!period) return t(locale, 'periodInput');
|
|
17
19
|
return use(ledgerServiceToken).categoryStatistics(caller, period);
|
|
18
20
|
});
|
|
19
21
|
},
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { resolveLocale } from 'zhin.js/i18n';
|
|
3
|
+
import { messages as t } from "../../lib/i18n.js";
|
|
2
4
|
import { defineCommand } from 'zhin.js/command';
|
|
3
5
|
import { ledgerCaller, replyLedger } from "../../lib/identity.js";
|
|
4
6
|
import { ledgerServiceToken } from "../../lib/runtime.js";
|
|
5
7
|
export default defineCommand({
|
|
6
|
-
description: '查看今日消费合计与分类明细',
|
|
8
|
+
description: '查看今日消费合计与分类明细', descriptionI18n: { en: "View today's spending totals and categories" },
|
|
7
9
|
alias: ['今日消费'],
|
|
8
|
-
async execute({ input, use }) {
|
|
10
|
+
async execute({ input, use, locale, formatCommand }) {
|
|
9
11
|
return replyLedger(async () => {
|
|
10
|
-
const caller = ledgerCaller(input);
|
|
12
|
+
const caller = ledgerCaller(input, locale);
|
|
11
13
|
return use(ledgerServiceToken).periodSummary(caller, 'today');
|
|
12
14
|
});
|
|
13
15
|
},
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { resolveLocale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../../src/i18n.js';
|
|
1
3
|
import { defineCommand } from 'zhin.js/command';
|
|
2
4
|
import { ledgerCaller, replyLedger } from '../../src/identity.js';
|
|
3
5
|
import { ledgerServiceToken } from '../../src/runtime.js';
|
|
4
6
|
|
|
5
7
|
export default defineCommand({
|
|
6
|
-
description: '查看今日消费合计与分类明细',
|
|
8
|
+
description: '查看今日消费合计与分类明细', descriptionI18n: { en: "View today's spending totals and categories" },
|
|
7
9
|
alias: ['今日消费'],
|
|
8
|
-
async execute({ input, use }) {
|
|
10
|
+
async execute({ input, use, locale, formatCommand }) {
|
|
9
11
|
return replyLedger(async () => {
|
|
10
|
-
const caller = ledgerCaller(input);
|
|
12
|
+
const caller = ledgerCaller(input, locale);
|
|
11
13
|
return use(ledgerServiceToken).periodSummary(caller, 'today');
|
|
12
14
|
});
|
|
13
15
|
},
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { resolveLocale } from 'zhin.js/i18n';
|
|
3
|
+
import { messages as t } from "../../lib/i18n.js";
|
|
2
4
|
import { defineCommand } from 'zhin.js/command';
|
|
3
5
|
import { ledgerCaller, replyLedger } from "../../lib/identity.js";
|
|
4
6
|
import { ledgerServiceToken } from "../../lib/runtime.js";
|
|
5
7
|
export default defineCommand({
|
|
6
|
-
description: '查看本周(周一至周日)消费合计与分类明细',
|
|
8
|
+
description: '查看本周(周一至周日)消费合计与分类明细', descriptionI18n: { en: "View this week's spending totals and categories (Monday through Sunday)" },
|
|
7
9
|
alias: ['本周消费'],
|
|
8
|
-
async execute({ input, use }) {
|
|
10
|
+
async execute({ input, use, locale, formatCommand }) {
|
|
9
11
|
return replyLedger(async () => {
|
|
10
|
-
const caller = ledgerCaller(input);
|
|
12
|
+
const caller = ledgerCaller(input, locale);
|
|
11
13
|
return use(ledgerServiceToken).periodSummary(caller, 'week');
|
|
12
14
|
});
|
|
13
15
|
},
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { resolveLocale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../../src/i18n.js';
|
|
1
3
|
import { defineCommand } from 'zhin.js/command';
|
|
2
4
|
import { ledgerCaller, replyLedger } from '../../src/identity.js';
|
|
3
5
|
import { ledgerServiceToken } from '../../src/runtime.js';
|
|
4
6
|
|
|
5
7
|
export default defineCommand({
|
|
6
|
-
description: '查看本周(周一至周日)消费合计与分类明细',
|
|
8
|
+
description: '查看本周(周一至周日)消费合计与分类明细', descriptionI18n: { en: "View this week's spending totals and categories (Monday through Sunday)" },
|
|
7
9
|
alias: ['本周消费'],
|
|
8
|
-
async execute({ input, use }) {
|
|
10
|
+
async execute({ input, use, locale, formatCommand }) {
|
|
9
11
|
return replyLedger(async () => {
|
|
10
|
-
const caller = ledgerCaller(input);
|
|
12
|
+
const caller = ledgerCaller(input, locale);
|
|
11
13
|
return use(ledgerServiceToken).periodSummary(caller, 'week');
|
|
12
14
|
});
|
|
13
15
|
},
|
package/lib/config.d.ts
CHANGED
|
@@ -5,11 +5,17 @@ export declare const ledgerConfig: Schema<Schema.InputRecord<{
|
|
|
5
5
|
timezone: Schema<string, string> & Schema.Present;
|
|
6
6
|
reportTime: Schema<string, string> & Schema.Present;
|
|
7
7
|
reportWhenEmpty: Schema<boolean, boolean> & Schema.Present;
|
|
8
|
-
}>, {
|
|
9
|
-
timezone: string;
|
|
10
|
-
reportTime: string;
|
|
11
|
-
reportWhenEmpty: boolean;
|
|
12
|
-
} & {
|
|
8
|
+
}>, Schema.RecordTypes<{
|
|
9
|
+
timezone: Schema<string, string> & Schema.Present;
|
|
10
|
+
reportTime: Schema<string, string> & Schema.Present;
|
|
11
|
+
reportWhenEmpty: Schema<boolean, boolean> & Schema.Present;
|
|
12
|
+
}>> & {
|
|
13
|
+
readonly output?: Schema.RecordTypes<{
|
|
14
|
+
timezone: Schema<string, string> & Schema.Present;
|
|
15
|
+
reportTime: Schema<string, string> & Schema.Present;
|
|
16
|
+
reportWhenEmpty: Schema<boolean, boolean> & Schema.Present;
|
|
17
|
+
}> | undefined;
|
|
18
|
+
};
|
|
13
19
|
export type LedgerConfig = Schema.Output<typeof ledgerConfig>;
|
|
14
20
|
export interface ResolvedLedgerConfig {
|
|
15
21
|
readonly timezone: string;
|
package/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAChD,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAE3C,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAChD,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAE3C,eAAO,MAAM,YAAY;;;;;;;;;;;;;;CAIvB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC;AAE9D,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;CACnC;AAaD,kGAAkG;AAClG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,SAAS,GAAG,oBAAoB,CAOnG"}
|
package/lib/config.js
CHANGED
|
@@ -2,9 +2,9 @@ import { Schema } from 'zhin.js';
|
|
|
2
2
|
export const DEFAULT_TIMEZONE = 'Asia/Shanghai';
|
|
3
3
|
export const DEFAULT_REPORT_TIME = '22:00';
|
|
4
4
|
export const ledgerConfig = Schema.object({
|
|
5
|
-
timezone: Schema.string().default(DEFAULT_TIMEZONE).description('计算今日、本周(周一开始)、本月与日报日期所用的 IANA 时区').effect('reload'),
|
|
6
|
-
reportTime: Schema.string().default(DEFAULT_REPORT_TIME).description('记账日报的发送时间(HH:MM,按 timezone);只发给用「记账日报 开启」订阅的用户').effect('reload'),
|
|
7
|
-
reportWhenEmpty: Schema.boolean().default(false).description('当天没有记账时是否仍发送日报').effect('reload'),
|
|
5
|
+
timezone: Schema.string().default(DEFAULT_TIMEZONE).description('计算今日、本周(周一开始)、本月与日报日期所用的 IANA 时区').i18n({ "en": { "description": "IANA timezone used to calculate today, this week (starting Monday), this month and daily-report dates." } }).effect('reload'),
|
|
6
|
+
reportTime: Schema.string().default(DEFAULT_REPORT_TIME).description('记账日报的发送时间(HH:MM,按 timezone);只发给用「记账日报 开启」订阅的用户').i18n({ "en": { "description": "Daily ledger report time (HH:MM in timezone); sent only to users who explicitly subscribed to daily reports." } }).effect('reload'),
|
|
7
|
+
reportWhenEmpty: Schema.boolean().default(false).description('当天没有记账时是否仍发送日报').i18n({ "en": { "description": "Send a daily report even when no transactions were recorded that day." } }).effect('reload'),
|
|
8
8
|
});
|
|
9
9
|
const REPORT_TIME_PATTERN = /^(?:[01]\d|2[0-3]):[0-5]\d$/u;
|
|
10
10
|
function assertTimezone(timezone) {
|
package/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAChD,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAE3C,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,WAAW,CAAC,kCAAkC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAChD,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAE3C,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,WAAW,CAAC,kCAAkC,CAAC,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,EAAC,aAAa,EAAE,wGAAwG,EAAC,EAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC5P,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,WAAW,CAAC,gDAAgD,CAAC,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,EAAC,aAAa,EAAE,8GAA8G,EAAC,EAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;IACrR,eAAe,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,EAAC,aAAa,EAAE,uEAAuE,EAAC,EAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;CACvM,CAAC,CAAC;AAUH,MAAM,mBAAmB,GAAG,8BAA8B,CAAC;AAE3D,SAAS,cAAc,CAAC,QAAgB;IACtC,IAAI,CAAC;QACH,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,QAAQ,CAAC,IAAI,EAAE,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;YAAE,MAAM,IAAI,UAAU,CAAC,uBAAuB,CAAC,CAAC;QACxH,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,SAAS,CAAC,8BAA8B,QAAQ,EAAE,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,mBAAmB,CAAC,MAAyC;IAC3E,MAAM,QAAQ,GAAG,MAAM,EAAE,QAAQ,IAAI,gBAAgB,CAAC;IACtD,MAAM,UAAU,GAAG,MAAM,EAAE,UAAU,IAAI,mBAAmB,CAAC;IAC7D,MAAM,eAAe,GAAG,MAAM,EAAE,eAAe,IAAI,KAAK,CAAC;IACzD,cAAc,CAAC,QAAQ,CAAC,CAAC;IACzB,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,2BAA2B,UAAU,EAAE,CAAC,CAAC;IACxG,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;AACnD,CAAC"}
|
package/lib/console.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../src/console.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,EAEtB,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAalD,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,gBAAgB,CA0BhF"}
|
package/lib/console.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { definePluginConsoleRpc, PluginConsoleRpcError, } from 'zhin.js';
|
|
2
|
+
import { ledgerServiceToken } from './runtime.js';
|
|
3
|
+
function resolveService(provided, call) {
|
|
4
|
+
if (provided)
|
|
5
|
+
return provided;
|
|
6
|
+
const runtimeWithUse = call.runtime;
|
|
7
|
+
const fromRuntime = runtimeWithUse?.use?.(ledgerServiceToken);
|
|
8
|
+
if (fromRuntime)
|
|
9
|
+
return fromRuntime;
|
|
10
|
+
throw new PluginConsoleRpcError('unavailable', '记账服务尚未就绪');
|
|
11
|
+
}
|
|
12
|
+
export function createLedgerConsoleRpc(service) {
|
|
13
|
+
const rpc = definePluginConsoleRpc({
|
|
14
|
+
status: {
|
|
15
|
+
page: 'index',
|
|
16
|
+
requiredPermissions: ['ledger:read'],
|
|
17
|
+
async handler(_input, call) {
|
|
18
|
+
return resolveService(service, call).getConsoleSnapshot();
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
actions: {
|
|
22
|
+
'run-daily-reports': {
|
|
23
|
+
page: 'index',
|
|
24
|
+
requiredPermissions: ['ledger:write'],
|
|
25
|
+
async handler(_input, call) {
|
|
26
|
+
const sent = await resolveService(service, call).runDailyReports();
|
|
27
|
+
return { sent };
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const methods = rpc.methods;
|
|
33
|
+
const originalGet = methods.get.bind(methods);
|
|
34
|
+
const originalHas = methods.has.bind(methods);
|
|
35
|
+
methods.get = (key) => originalGet(key === 'runDailyReports' ? 'run-daily-reports' : key);
|
|
36
|
+
methods.has = (key) => originalHas(key === 'runDailyReports' ? 'run-daily-reports' : key);
|
|
37
|
+
return rpc;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=console.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console.js","sourceRoot":"","sources":["../src/console.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,qBAAqB,GAGtB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGlD,SAAS,cAAc,CACrB,QAAmC,EACnC,IAA0B;IAE1B,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,MAAM,cAAc,GAAG,IAAI,CAAC,OAAoF,CAAC;IACjH,MAAM,WAAW,GAAG,cAAc,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,CAAC;IAC9D,IAAI,WAAW;QAAE,OAAO,WAAW,CAAC;IACpC,MAAM,IAAI,qBAAqB,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAuB;IAC5D,MAAM,GAAG,GAAG,sBAAsB,CAAC;QACjC,MAAM,EAAE;YACN,IAAI,EAAE,OAAO;YACb,mBAAmB,EAAE,CAAC,aAAa,CAAC;YACpC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI;gBACxB,OAAO,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,kBAAkB,EAAE,CAAC;YAC5D,CAAC;SACF;QACD,OAAO,EAAE;YACP,mBAAmB,EAAE;gBACnB,IAAI,EAAE,OAAO;gBACb,mBAAmB,EAAE,CAAC,cAAc,CAAC;gBACrC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI;oBACxB,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;oBACnE,OAAO,EAAE,IAAI,EAAE,CAAC;gBAClB,CAAC;aACF;SACF;KACF,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,GAAG,CAAC,OAAsE,CAAC;IAC3F,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,KAAK,iBAAiB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAClG,OAAO,CAAC,GAAG,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,KAAK,iBAAiB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAClG,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/lib/entry-input.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { type Locale } from 'zhin.js/i18n';
|
|
1
2
|
export declare const MAX_CATEGORY_LENGTH = 20;
|
|
2
3
|
export declare const MAX_NOTE_LENGTH = 100;
|
|
3
|
-
export declare const ADD_USAGE
|
|
4
|
+
export declare const ADD_USAGE: string;
|
|
4
5
|
export interface ParsedEntryInput {
|
|
5
6
|
readonly category: string;
|
|
6
7
|
readonly amountCents: number;
|
|
@@ -14,5 +15,5 @@ export type EntryInputResult = {
|
|
|
14
15
|
readonly reason: string;
|
|
15
16
|
};
|
|
16
17
|
/** Parses the text after `记`: category, amount, then an optional free-form note. */
|
|
17
|
-
export declare function parseEntryInput(text: string): EntryInputResult;
|
|
18
|
+
export declare function parseEntryInput(text: string, locale?: Locale): EntryInputResult;
|
|
18
19
|
//# sourceMappingURL=entry-input.d.ts.map
|
package/lib/entry-input.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-input.d.ts","sourceRoot":"","sources":["../src/entry-input.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entry-input.d.ts","sourceRoot":"","sources":["../src/entry-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAI1D,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,eAAO,MAAM,SAAS,QAAsB,CAAC;AAE7C,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAA;CAAE,GACvD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAMpD,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAiB/E"}
|