dsh-calendar 0.2.0 → 0.2.2
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 +4 -1
- package/lib/ical.d.ts +2 -0
- package/lib/ical.js +12 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/tools.js +7 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -101,7 +101,10 @@ iCloud:登录 appleid.apple.com → 登录与安全 → App 专用密码,生
|
|
|
101
101
|
|
|
102
102
|
输入输出统一 ISO 8601。定时事件输出为 UTC(如 `2025-01-15T01:00:00Z`),全天事件输出 `YYYY-MM-DD`。输入可带时区偏移(如 `2025-01-15T09:00:00+08:00`),插件内部转 UTC 存储。
|
|
103
103
|
|
|
104
|
-
## 已知限制
|
|
104
|
+
## 已知限制
|
|
105
|
+
|
|
106
|
+
- **国内网络**:Google(apidata.googleusercontent.com)与 iCloud(caldav.icloud.com)在中国大陆不可直连;请使用可达的 CalDAV 端点(自建 Nextcloud/Radicale 或代理)。
|
|
107
|
+
|
|
105
108
|
|
|
106
109
|
- 重复事件展开:calendar_list 默认用 ICAL.RecurExpansion 展开 RRULE(`expand=true`),受 `maxOccurrences` 封顶;calendar_search 仍返回原始系列(不展开)。
|
|
107
110
|
- 不支持单次实例的改/删:calendar_update / calendar_delete 针对整个重复系列(按 uid 操作),无法只修改或删除某一次发生(不支持 RECURRENCE-ID 实例级操作)。
|
package/lib/ical.d.ts
CHANGED
package/lib/ical.js
CHANGED
|
@@ -216,6 +216,18 @@ export function buildICalString(fields) {
|
|
|
216
216
|
if (fields.location !== undefined && fields.location !== '') {
|
|
217
217
|
vevent.addPropertyWithValue('location', fields.location);
|
|
218
218
|
}
|
|
219
|
+
if (fields.rrule !== undefined && fields.rrule !== '') {
|
|
220
|
+
const rule = fields.rrule.trim();
|
|
221
|
+
if (!/^FREQ=/i.test(rule)) {
|
|
222
|
+
throw new Error('rrule 格式无效:' + fields.rrule + '(应为 RFC 5545 RRULE,如 FREQ=WEEKLY;COUNT=4)');
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
vevent.addPropertyWithValue('rrule', ICAL.Recur.fromString(rule));
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
throw new Error('rrule 格式无效:' + fields.rrule);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
219
231
|
vcal.addSubcomponent(vevent);
|
|
220
232
|
return vcal.toString();
|
|
221
233
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { type CalendarConfig } from './config.js';
|
|
11
11
|
import { type CalendarToolDefinition } from './tools.js';
|
|
12
|
+
/** cordis 服务注入:apply 里要用 ctx.tools,必须显式声明注入,否则宿主会抛 cannot get property without inject。 */
|
|
13
|
+
export declare const inject: string[];
|
|
12
14
|
/** 插件所需的最小 ctx 面(社区插件不依赖宿主内部类型)。 */
|
|
13
15
|
export interface CalendarPluginContext {
|
|
14
16
|
tools: {
|
|
@@ -22,7 +24,6 @@ export interface CalendarPluginContext {
|
|
|
22
24
|
* @param config - 插件配置(可缺省)。
|
|
23
25
|
*/
|
|
24
26
|
export declare function apply(ctx: CalendarPluginContext, config?: CalendarConfig | null): void;
|
|
25
|
-
export default apply;
|
|
26
27
|
export * from './parameters.js';
|
|
27
28
|
export * from './config.js';
|
|
28
29
|
export * from './ical.js';
|
package/lib/index.js
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { resolveConfig } from './config.js';
|
|
11
11
|
import { buildCalendarTools } from './tools.js';
|
|
12
|
+
/** cordis 服务注入:apply 里要用 ctx.tools,必须显式声明注入,否则宿主会抛 cannot get property without inject。 */
|
|
13
|
+
export const inject = ['tools'];
|
|
12
14
|
/**
|
|
13
15
|
* 插件入口:惰性解析配置并注册五个日历工具。
|
|
14
16
|
* @param ctx - 宿主上下文(至少含 tools.register)。
|
|
@@ -33,7 +35,6 @@ export function apply(ctx, config) {
|
|
|
33
35
|
});
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
|
-
export default apply;
|
|
37
38
|
export * from './parameters.js';
|
|
38
39
|
export * from './config.js';
|
|
39
40
|
export * from './ical.js';
|
package/lib/tools.js
CHANGED
|
@@ -115,7 +115,7 @@ export function buildCalendarTools(config) {
|
|
|
115
115
|
};
|
|
116
116
|
const create = {
|
|
117
117
|
name: 'calendar_create',
|
|
118
|
-
description: '新建一个日历事件。summary 与 start、end(ISO 8601,含时区偏移)为必填;description、location、allDay 可选。全天事件 start/end 用 YYYY-MM-DD 或设置 allDay=true。成功返回新事件的稳定标识 uid。',
|
|
118
|
+
description: '新建一个日历事件。summary 与 start、end(ISO 8601,含时区偏移)为必填;description、location、allDay、rrule 可选。全天事件 start/end 用 YYYY-MM-DD 或设置 allDay=true。成功返回新事件的稳定标识 uid。',
|
|
119
119
|
parameters: compileParameters({
|
|
120
120
|
summary: { type: 'string', required: true, description: '事件标题(必填)。' },
|
|
121
121
|
start: { type: 'string', required: true, description: '开始时间(ISO 8601,含时区偏移,必填)。' },
|
|
@@ -123,6 +123,7 @@ export function buildCalendarTools(config) {
|
|
|
123
123
|
description: { type: 'string', description: '事件描述(可选)。' },
|
|
124
124
|
location: { type: 'string', description: '地点(可选)。' },
|
|
125
125
|
allDay: { type: 'boolean', description: '是否全天事件(可选,默认 false)。' },
|
|
126
|
+
rrule: { type: 'string', description: '重复规则(可选,RFC 5545 RRULE 语法),如 FREQ=WEEKLY;COUNT=4;calendar_list 会按该规则展开实例。' },
|
|
126
127
|
}),
|
|
127
128
|
output: {
|
|
128
129
|
schema: {
|
|
@@ -150,6 +151,7 @@ export function buildCalendarTools(config) {
|
|
|
150
151
|
...(optionalString(input, 'description') !== undefined ? { description: optionalString(input, 'description') } : {}),
|
|
151
152
|
...(optionalString(input, 'location') !== undefined ? { location: optionalString(input, 'location') } : {}),
|
|
152
153
|
...(optionalBoolean(input, 'allDay') !== undefined ? { allDay: optionalBoolean(input, 'allDay') } : {}),
|
|
154
|
+
...(optionalString(input, 'rrule') !== undefined ? { rrule: optionalString(input, 'rrule') } : {}),
|
|
153
155
|
};
|
|
154
156
|
const created = await service().create(fields);
|
|
155
157
|
return { created };
|
|
@@ -167,6 +169,7 @@ export function buildCalendarTools(config) {
|
|
|
167
169
|
description: { type: 'string', description: '新描述(可选)。' },
|
|
168
170
|
location: { type: 'string', description: '新地点(可选)。' },
|
|
169
171
|
allDay: { type: 'boolean', description: '是否全天事件(可选)。' },
|
|
172
|
+
rrule: { type: 'string', description: '新的重复规则(可选)。' },
|
|
170
173
|
}),
|
|
171
174
|
output: {
|
|
172
175
|
schema: {
|
|
@@ -206,6 +209,9 @@ export function buildCalendarTools(config) {
|
|
|
206
209
|
const allDay = optionalBoolean(input, 'allDay');
|
|
207
210
|
if (allDay !== undefined)
|
|
208
211
|
changes.allDay = allDay;
|
|
212
|
+
const rrule = optionalString(input, 'rrule');
|
|
213
|
+
if (rrule !== undefined)
|
|
214
|
+
changes.rrule = rrule;
|
|
209
215
|
const updated = await service().update(uid, changes);
|
|
210
216
|
return { updated };
|
|
211
217
|
},
|