@wtfalch/calendar 0.2.0 → 0.3.1
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 -0
- package/dist/calendar/calendar-client.js +158 -9
- package/dist/calendar/client.js +25 -1
- package/dist/calendar/fake/store.d.ts +20 -1
- package/dist/calendar/fake/store.js +240 -19
- package/dist/calendar/ics.d.ts +31 -5
- package/dist/calendar/ics.js +343 -4
- package/dist/calendar/index.d.ts +1 -1
- package/dist/calendar/types.d.ts +190 -7
- package/dist/calendar/wire.d.ts +43 -5
- package/dist/calendar/wire.js +57 -3
- package/package.json +3 -3
package/dist/calendar/wire.d.ts
CHANGED
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
* the key when a caller's own patch mentions it (`patchToWire`), so that
|
|
79
79
|
* holds for this client's own `updateEvent` too.
|
|
80
80
|
*/
|
|
81
|
-
import type { AvailabilityPeriod, Calendar, CalendarEvent, CalendarEventDraft, CalendarRecurrenceRule, CalendarRight, Principal } from './types.ts';
|
|
81
|
+
import type { AvailabilityPeriod, Calendar, CalendarChanges, CalendarEvent, CalendarEventDraft, CalendarEventPatch, CalendarEventProjection, CalendarRecurrenceRule, CalendarRight, Principal } from './types.ts';
|
|
82
82
|
type WireRights = Partial<Record<CalendarRight, boolean>>;
|
|
83
83
|
export declare function rightsFromWire(wire: WireRights | null | undefined): readonly CalendarRight[];
|
|
84
84
|
export declare function rightsToWire(rights: readonly CalendarRight[]): WireRights;
|
|
@@ -206,8 +206,11 @@ export declare function recurrenceRuleFromWire(wire: WireRecurrenceRule | null |
|
|
|
206
206
|
* `freeBusyStatus` (wtfalch/calendar#29) is named here on the strength of
|
|
207
207
|
* that same pattern, not a fresh live capture -- every property this list
|
|
208
208
|
* has ever gained needed an explicit name, and nothing suggests this is the
|
|
209
|
-
* one exception.
|
|
210
|
-
|
|
209
|
+
* one exception.
|
|
210
|
+
*
|
|
211
|
+
* `mayInviteSelf`/`mayInviteOthers` (wtfalch/calendar#51) are named here on
|
|
212
|
+
* that same strength, not a fresh live capture either. */
|
|
213
|
+
export declare const EVENT_GET_PROPERTIES: readonly ["id", "calendarIds", "uid", "title", "description", "start", "timeZone", "duration", "showWithoutTime", "locations", "virtualLocations", "links", "recurrenceRule", "participants", "mayInviteSelf", "mayInviteOthers", "alerts", "status", "freeBusyStatus", "sequence", "baseEventId", "recurrenceId"];
|
|
211
214
|
export type WireEvent = {
|
|
212
215
|
id: string;
|
|
213
216
|
calendarIds?: Record<string, boolean> | null;
|
|
@@ -223,6 +226,8 @@ export type WireEvent = {
|
|
|
223
226
|
links?: Record<string, WireLink> | null;
|
|
224
227
|
recurrenceRule?: WireRecurrenceRule | null;
|
|
225
228
|
participants?: Record<string, WireParticipant> | null;
|
|
229
|
+
mayInviteSelf?: boolean | null;
|
|
230
|
+
mayInviteOthers?: boolean | null;
|
|
226
231
|
alerts?: Record<string, WireAlert> | null;
|
|
227
232
|
status?: string | null;
|
|
228
233
|
freeBusyStatus?: string | null;
|
|
@@ -251,8 +256,41 @@ export declare function eventFromWire(wire: WireEvent, calendarIdFallback?: stri
|
|
|
251
256
|
export declare function draftToWire(calendarId: string, draft: CalendarEventDraft): Record<string, unknown>;
|
|
252
257
|
/** Only the properties `patch` actually carries -- `CalendarEvent/set`'s
|
|
253
258
|
* `update` is a genuine patch, and a field the caller did not mention must
|
|
254
|
-
* not be overwritten with `undefined`.
|
|
255
|
-
|
|
259
|
+
* not be overwritten with `undefined`.
|
|
260
|
+
*
|
|
261
|
+
* `recurrenceRule: null` is the one field this writes a real wire `null`
|
|
262
|
+
* for, rather than dropping the key: `CalendarEventPatch` widens just this
|
|
263
|
+
* field to allow it, as the explicit "clear this" signal distinct from
|
|
264
|
+
* leaving the key out entirely (wtfalch/calendar#45). Writing
|
|
265
|
+
* `recurrenceRuleToWire(null)` here instead would have produced `undefined`
|
|
266
|
+
* (its own "nothing to send" answer for an absent rule), which
|
|
267
|
+
* `JSON.stringify` drops from the request -- exactly why no code path could
|
|
268
|
+
* clear a rule before this. */
|
|
269
|
+
export declare function patchToWire(patch: CalendarEventPatch): Record<string, unknown>;
|
|
270
|
+
/** RFC 8620 §5.2's own `/changes` response shape, shared verbatim by
|
|
271
|
+
* `CalendarEvent/changes` and `Calendar/changes` -- both map through this
|
|
272
|
+
* one function (wtfalch/calendar#65). */
|
|
273
|
+
export type WireChanges = {
|
|
274
|
+
newState: string;
|
|
275
|
+
created?: readonly string[] | null;
|
|
276
|
+
updated?: readonly string[] | null;
|
|
277
|
+
destroyed?: readonly string[] | null;
|
|
278
|
+
hasMoreChanges?: boolean | null;
|
|
279
|
+
};
|
|
280
|
+
export declare function changesFromWire(wire: WireChanges): CalendarChanges;
|
|
281
|
+
/** The properties `getEventProjections` asks the server for -- named
|
|
282
|
+
* explicitly, the same discipline `EVENT_GET_PROPERTIES` already follows,
|
|
283
|
+
* so a title, description or location is never part of the response in the
|
|
284
|
+
* first place (wtfalch/calendar#65; Activity holds identifiers only, per
|
|
285
|
+
* `activity/packages/service/src/calendar/jmap.ts:17-22`). */
|
|
286
|
+
export declare const EVENT_PROJECTION_PROPERTIES: readonly ["id", "status", "sequence", "participants"];
|
|
287
|
+
export type WireEventProjection = {
|
|
288
|
+
id: string;
|
|
289
|
+
status?: string | null;
|
|
290
|
+
sequence?: number | null;
|
|
291
|
+
participants?: Record<string, WireParticipant> | null;
|
|
292
|
+
};
|
|
293
|
+
export declare function eventProjectionFromWire(wire: WireEventProjection): CalendarEventProjection;
|
|
256
294
|
/**
|
|
257
295
|
* A minimal ISO 8601 / RFC 5545 duration parser: `P`, an optional week or
|
|
258
296
|
* day count, an optional `T` time part with hours/minutes/seconds. Years and
|
package/dist/calendar/wire.js
CHANGED
|
@@ -410,7 +410,10 @@ function recurrenceRuleToWire(rule) {
|
|
|
410
410
|
* `freeBusyStatus` (wtfalch/calendar#29) is named here on the strength of
|
|
411
411
|
* that same pattern, not a fresh live capture -- every property this list
|
|
412
412
|
* has ever gained needed an explicit name, and nothing suggests this is the
|
|
413
|
-
* one exception.
|
|
413
|
+
* one exception.
|
|
414
|
+
*
|
|
415
|
+
* `mayInviteSelf`/`mayInviteOthers` (wtfalch/calendar#51) are named here on
|
|
416
|
+
* that same strength, not a fresh live capture either. */
|
|
414
417
|
export const EVENT_GET_PROPERTIES = [
|
|
415
418
|
'id',
|
|
416
419
|
'calendarIds',
|
|
@@ -426,6 +429,8 @@ export const EVENT_GET_PROPERTIES = [
|
|
|
426
429
|
'links',
|
|
427
430
|
'recurrenceRule',
|
|
428
431
|
'participants',
|
|
432
|
+
'mayInviteSelf',
|
|
433
|
+
'mayInviteOthers',
|
|
429
434
|
'alerts',
|
|
430
435
|
'status',
|
|
431
436
|
'freeBusyStatus',
|
|
@@ -457,6 +462,8 @@ export function eventFromWire(wire, calendarIdFallback) {
|
|
|
457
462
|
links: linksFromWire(wire.links),
|
|
458
463
|
recurrenceRule: recurrenceRuleFromWire(wire.recurrenceRule),
|
|
459
464
|
participants: participantsFromWire(wire.participants),
|
|
465
|
+
mayInviteSelf: wire.mayInviteSelf ?? undefined,
|
|
466
|
+
mayInviteOthers: wire.mayInviteOthers ?? undefined,
|
|
460
467
|
alerts: alertsFromWire(wire.alerts),
|
|
461
468
|
status: (wire.status ?? 'confirmed'),
|
|
462
469
|
freeBusyStatus: (wire.freeBusyStatus ?? undefined),
|
|
@@ -492,11 +499,22 @@ export function draftToWire(calendarId, draft) {
|
|
|
492
499
|
...(alertsToWire(draft.alerts) ? { alerts: alertsToWire(draft.alerts) } : {}),
|
|
493
500
|
status: draft.status,
|
|
494
501
|
...(draft.freeBusyStatus === undefined ? {} : { freeBusyStatus: draft.freeBusyStatus }),
|
|
502
|
+
...(draft.mayInviteSelf === undefined ? {} : { mayInviteSelf: draft.mayInviteSelf }),
|
|
503
|
+
...(draft.mayInviteOthers === undefined ? {} : { mayInviteOthers: draft.mayInviteOthers }),
|
|
495
504
|
};
|
|
496
505
|
}
|
|
497
506
|
/** Only the properties `patch` actually carries -- `CalendarEvent/set`'s
|
|
498
507
|
* `update` is a genuine patch, and a field the caller did not mention must
|
|
499
|
-
* not be overwritten with `undefined`.
|
|
508
|
+
* not be overwritten with `undefined`.
|
|
509
|
+
*
|
|
510
|
+
* `recurrenceRule: null` is the one field this writes a real wire `null`
|
|
511
|
+
* for, rather than dropping the key: `CalendarEventPatch` widens just this
|
|
512
|
+
* field to allow it, as the explicit "clear this" signal distinct from
|
|
513
|
+
* leaving the key out entirely (wtfalch/calendar#45). Writing
|
|
514
|
+
* `recurrenceRuleToWire(null)` here instead would have produced `undefined`
|
|
515
|
+
* (its own "nothing to send" answer for an absent rule), which
|
|
516
|
+
* `JSON.stringify` drops from the request -- exactly why no code path could
|
|
517
|
+
* clear a rule before this. */
|
|
500
518
|
export function patchToWire(patch) {
|
|
501
519
|
const wire = {};
|
|
502
520
|
if (patch.calendarId !== undefined)
|
|
@@ -523,10 +541,15 @@ export function patchToWire(patch) {
|
|
|
523
541
|
if (patch.links !== undefined)
|
|
524
542
|
wire.links = linksToWire(patch.links);
|
|
525
543
|
if (patch.recurrenceRule !== undefined) {
|
|
526
|
-
wire.recurrenceRule =
|
|
544
|
+
wire.recurrenceRule =
|
|
545
|
+
patch.recurrenceRule === null ? null : recurrenceRuleToWire(patch.recurrenceRule);
|
|
527
546
|
}
|
|
528
547
|
if (patch.participants !== undefined)
|
|
529
548
|
wire.participants = participantsToWire(patch.participants);
|
|
549
|
+
if (patch.mayInviteSelf !== undefined)
|
|
550
|
+
wire.mayInviteSelf = patch.mayInviteSelf;
|
|
551
|
+
if (patch.mayInviteOthers !== undefined)
|
|
552
|
+
wire.mayInviteOthers = patch.mayInviteOthers;
|
|
530
553
|
if (patch.alerts !== undefined)
|
|
531
554
|
wire.alerts = alertsToWire(patch.alerts);
|
|
532
555
|
if (patch.status !== undefined)
|
|
@@ -535,6 +558,37 @@ export function patchToWire(patch) {
|
|
|
535
558
|
wire.freeBusyStatus = patch.freeBusyStatus;
|
|
536
559
|
return wire;
|
|
537
560
|
}
|
|
561
|
+
export function changesFromWire(wire) {
|
|
562
|
+
return {
|
|
563
|
+
newState: wire.newState,
|
|
564
|
+
created: wire.created ?? [],
|
|
565
|
+
updated: wire.updated ?? [],
|
|
566
|
+
destroyed: wire.destroyed ?? [],
|
|
567
|
+
hasMoreChanges: wire.hasMoreChanges ?? false,
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
// ---------------------------------------------------------------------------
|
|
571
|
+
// CalendarEventProjection: id, status, sequence, participants' addresses
|
|
572
|
+
// ---------------------------------------------------------------------------
|
|
573
|
+
/** The properties `getEventProjections` asks the server for -- named
|
|
574
|
+
* explicitly, the same discipline `EVENT_GET_PROPERTIES` already follows,
|
|
575
|
+
* so a title, description or location is never part of the response in the
|
|
576
|
+
* first place (wtfalch/calendar#65; Activity holds identifiers only, per
|
|
577
|
+
* `activity/packages/service/src/calendar/jmap.ts:17-22`). */
|
|
578
|
+
export const EVENT_PROJECTION_PROPERTIES = ['id', 'status', 'sequence', 'participants'];
|
|
579
|
+
export function eventProjectionFromWire(wire) {
|
|
580
|
+
return {
|
|
581
|
+
id: wire.id,
|
|
582
|
+
// Mirrors `eventFromWire`'s own defaults: absent reads as 'confirmed'
|
|
583
|
+
// and 0, the same fallbacks a caller of the full `CalendarEvent` already
|
|
584
|
+
// relies on.
|
|
585
|
+
status: (wire.status ?? 'confirmed'),
|
|
586
|
+
sequence: wire.sequence ?? 0,
|
|
587
|
+
participants: wire.participants
|
|
588
|
+
? Object.values(wire.participants).map((p) => ({ calendarAddress: p.calendarAddress }))
|
|
589
|
+
: [],
|
|
590
|
+
};
|
|
591
|
+
}
|
|
538
592
|
// ---------------------------------------------------------------------------
|
|
539
593
|
// Availability
|
|
540
594
|
// ---------------------------------------------------------------------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wtfalch/calendar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "A JMAP calendar client for Agora, the wtfalch communications app: events, invites, sharing and free/busy over Stalwart, and the React UI on react-big-calendar.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dev": "vite --config dev/vite.config.ts"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@wtfalch/design": "0.
|
|
40
|
+
"@wtfalch/design": "^0.30.0",
|
|
41
41
|
"react": "^19.0.0",
|
|
42
42
|
"react-big-calendar": "^1.20.0",
|
|
43
43
|
"react-dom": "^19.0.0"
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@types/react-big-calendar": "^1.16.3",
|
|
63
63
|
"@types/react-dom": "^19",
|
|
64
64
|
"@vitejs/plugin-react": "^6.1.1",
|
|
65
|
-
"@wtfalch/design": "0.
|
|
65
|
+
"@wtfalch/design": "0.30.0",
|
|
66
66
|
"jsdom": "^30.0.1",
|
|
67
67
|
"react": "^19",
|
|
68
68
|
"react-big-calendar": "^1.20.0",
|