dsh-calendar 0.2.1 → 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 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
@@ -41,6 +41,8 @@ export interface EventFields {
41
41
  description?: string;
42
42
  location?: string;
43
43
  allDay?: boolean;
44
+ /** 重复规则(RFC 5545 RRULE 语法),如 FREQ=WEEKLY;COUNT=4。 */
45
+ rrule?: string;
44
46
  /** iCal UID;创建时缺省则自动生成,更新时用于保留原 UID。 */
45
47
  icalUid?: string;
46
48
  }
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/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
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-calendar",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "DSH 日历工具插件:通过 CalDAV 读写日历事件(Google / iCloud / Nextcloud / 自定义)",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",