@wtfalch/calendar 0.1.0
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/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/calendar/calendar-client.d.ts +7 -0
- package/dist/calendar/calendar-client.js +242 -0
- package/dist/calendar/calendar.css +953 -0
- package/dist/calendar/client.d.ts +87 -0
- package/dist/calendar/client.js +233 -0
- package/dist/calendar/errors.d.ts +28 -0
- package/dist/calendar/errors.js +61 -0
- package/dist/calendar/fake/index.d.ts +36 -0
- package/dist/calendar/fake/index.js +79 -0
- package/dist/calendar/fake/sample.d.ts +66 -0
- package/dist/calendar/fake/sample.js +116 -0
- package/dist/calendar/fake/store.d.ts +79 -0
- package/dist/calendar/fake/store.js +906 -0
- package/dist/calendar/index.d.ts +12 -0
- package/dist/calendar/index.js +11 -0
- package/dist/calendar/push.d.ts +38 -0
- package/dist/calendar/push.js +129 -0
- package/dist/calendar/react/AvailabilityRibbon.d.ts +40 -0
- package/dist/calendar/react/AvailabilityRibbon.js +108 -0
- package/dist/calendar/react/Calendar.d.ts +28 -0
- package/dist/calendar/react/Calendar.js +431 -0
- package/dist/calendar/react/EventDetail.d.ts +22 -0
- package/dist/calendar/react/EventDetail.js +91 -0
- package/dist/calendar/react/EventEditor.d.ts +52 -0
- package/dist/calendar/react/EventEditor.js +188 -0
- package/dist/calendar/react/ShareDialog.d.ts +25 -0
- package/dist/calendar/react/ShareDialog.js +125 -0
- package/dist/calendar/react/Toolbar.d.ts +29 -0
- package/dist/calendar/react/Toolbar.js +58 -0
- package/dist/calendar/react/index.d.ts +9 -0
- package/dist/calendar/react/index.js +8 -0
- package/dist/calendar/react/participants.d.ts +34 -0
- package/dist/calendar/react/participants.js +40 -0
- package/dist/calendar/types.d.ts +384 -0
- package/dist/calendar/types.js +40 -0
- package/dist/calendar/uri.d.ts +13 -0
- package/dist/calendar/uri.js +22 -0
- package/dist/calendar/wire.d.ts +177 -0
- package/dist/calendar/wire.js +349 -0
- package/package.json +82 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small, fixed calendar universe.
|
|
3
|
+
*
|
|
4
|
+
* `ME` is the signed-in person `fakeCalendar()` speaks for. `BOB` and `CAROL`
|
|
5
|
+
* are never returned by `listCalendars()` — nothing in `CalendarClient` lists
|
|
6
|
+
* someone else's own calendars — they exist only so `getAvailability` has two
|
|
7
|
+
* principals to tell apart: one who shared a calendar with `ME` (busy periods
|
|
8
|
+
* come back) and one who shared nothing (an empty list comes back), per
|
|
9
|
+
* MSG-053's fourth load-bearing behaviour
|
|
10
|
+
* (https://github.com/wtfalch/messaging/issues/145).
|
|
11
|
+
*
|
|
12
|
+
* `ME`'s own "Work" calendar carries the one recurring event the rules ask
|
|
13
|
+
* for, so a month view has a whole series to draw, not just a single day.
|
|
14
|
+
*/
|
|
15
|
+
/** "Me": one plain calendar with a single event, one with a recurring weekly
|
|
16
|
+
* series. Both visible. Personal starts shared with Bob at the quieter of
|
|
17
|
+
* the two levels -- `mayReadFreeBusy` without `mayReadItems` -- so the
|
|
18
|
+
* sharing dialog opens onto a real grant rather than only an empty state,
|
|
19
|
+
* and so the level a row reads back is exercised rather than assumed. */
|
|
20
|
+
export const ME = {
|
|
21
|
+
accountId: 'me',
|
|
22
|
+
email: 'ada@example.com',
|
|
23
|
+
name: 'Ada Lovelace',
|
|
24
|
+
calendars: [
|
|
25
|
+
{
|
|
26
|
+
id: 'cal-personal',
|
|
27
|
+
name: 'Personal',
|
|
28
|
+
color: '#7c5cff',
|
|
29
|
+
isVisible: true,
|
|
30
|
+
shareWith: { bob: ['mayReadFreeBusy'] },
|
|
31
|
+
events: [
|
|
32
|
+
{
|
|
33
|
+
uid: 'uid-coffee',
|
|
34
|
+
title: 'Coffee with Mary',
|
|
35
|
+
startOffsetMinutes: 26 * 60,
|
|
36
|
+
durationMinutes: 60,
|
|
37
|
+
location: 'The usual place',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 'cal-work',
|
|
43
|
+
name: 'Work',
|
|
44
|
+
color: '#2f6fed',
|
|
45
|
+
isVisible: true,
|
|
46
|
+
events: [
|
|
47
|
+
{
|
|
48
|
+
uid: 'uid-sync',
|
|
49
|
+
title: 'Team sync',
|
|
50
|
+
startOffsetMinutes: 24 * 60,
|
|
51
|
+
durationMinutes: 30,
|
|
52
|
+
recurrenceRule: { frequency: 'weekly', interval: 1, count: 8 },
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
/** Bob has shared his calendar with "me" — `mayReadItems` only, no
|
|
59
|
+
* `mayReadFreeBusy` — because live testing found the first right alone is
|
|
60
|
+
* what unlocks `Principal/getAvailability`; the second right changed
|
|
61
|
+
* nothing (#145 amendment). He is also the invitee the scheduling tests
|
|
62
|
+
* send an invite to. */
|
|
63
|
+
export const BOB = {
|
|
64
|
+
accountId: 'bob',
|
|
65
|
+
email: 'bob@example.org',
|
|
66
|
+
name: 'Bob',
|
|
67
|
+
calendars: [
|
|
68
|
+
{
|
|
69
|
+
id: 'bob-cal',
|
|
70
|
+
name: 'Bob',
|
|
71
|
+
isVisible: true,
|
|
72
|
+
shareWith: { me: ['mayReadItems'] },
|
|
73
|
+
events: [
|
|
74
|
+
{
|
|
75
|
+
uid: 'uid-bob-standup',
|
|
76
|
+
title: 'Standup',
|
|
77
|
+
startOffsetMinutes: 25 * 60,
|
|
78
|
+
durationMinutes: 30,
|
|
79
|
+
status: 'confirmed',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
uid: 'uid-bob-dentist',
|
|
83
|
+
title: 'Dentist',
|
|
84
|
+
startOffsetMinutes: 27 * 60 + 30,
|
|
85
|
+
durationMinutes: 60,
|
|
86
|
+
status: 'confirmed',
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
};
|
|
92
|
+
/** Carol has shared nothing. `getAvailability('carol', ...)` must come back
|
|
93
|
+
* empty even though she has a real, confirmed event on the calendar — no
|
|
94
|
+
* share means no data, not even an aggregated blob (#137 "Free/busy"). */
|
|
95
|
+
export const CAROL = {
|
|
96
|
+
accountId: 'carol',
|
|
97
|
+
email: 'carol@example.org',
|
|
98
|
+
name: 'Carol',
|
|
99
|
+
calendars: [
|
|
100
|
+
{
|
|
101
|
+
id: 'carol-cal',
|
|
102
|
+
name: 'Carol',
|
|
103
|
+
isVisible: true,
|
|
104
|
+
events: [
|
|
105
|
+
{
|
|
106
|
+
uid: 'uid-carol-review',
|
|
107
|
+
title: 'Design review',
|
|
108
|
+
startOffsetMinutes: 26 * 60,
|
|
109
|
+
durationMinutes: 60,
|
|
110
|
+
status: 'confirmed',
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
export const OTHER_PRINCIPALS = [BOB, CAROL];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A calendar universe in memory, and the JMAP that answers questions about
|
|
3
|
+
* it.
|
|
4
|
+
*
|
|
5
|
+
* **A fake transport, not a fake API.** This answers JMAP calls the same way
|
|
6
|
+
* a running Stalwart does, so a component or a client method drawn against
|
|
7
|
+
* this fake is drawn through exactly the code that will face a real server —
|
|
8
|
+
* including the four load-bearing behaviours confirmed live against Stalwart
|
|
9
|
+
* v0.16.20 (https://github.com/wtfalch/messaging/issues/145):
|
|
10
|
+
*
|
|
11
|
+
* 1. `CalendarEvent/query` without `expandRecurrences` returns master
|
|
12
|
+
* events only; with it, and both `after`/`before`, dated occurrences —
|
|
13
|
+
* and with it but no bounds, `invalidArguments`.
|
|
14
|
+
* 2. An invite (`CalendarEvent/set create` with `sendSchedulingMessages`)
|
|
15
|
+
* lands a copy straight in the invitee's own calendar; the invitee's own
|
|
16
|
+
* reply (`update` with `sendSchedulingMessages`) updates every other
|
|
17
|
+
* copy sharing the same `uid`, including the organiser's.
|
|
18
|
+
* 3. A grant written to `Calendar/set update {shareWith}` reads back on the
|
|
19
|
+
* next `Calendar/get`.
|
|
20
|
+
* 4. `Principal/getAvailability` returns busy periods for a calendar shared
|
|
21
|
+
* with at least `mayReadItems` — no second opt-in needed — and an empty
|
|
22
|
+
* list for one shared with nothing at all.
|
|
23
|
+
*
|
|
24
|
+
* It implements only the methods `@wtfalch/calendar` sends. Anything else
|
|
25
|
+
* answers `unknownMethod`, which is what a real server does and what the
|
|
26
|
+
* error path expects.
|
|
27
|
+
*
|
|
28
|
+
* Wire shapes below (`myRights`/`shareWith` as boolean-flag objects, the
|
|
29
|
+
* `calendars`/`calendars:parse` capability strings, the session capability
|
|
30
|
+
* object's field names, `recurrenceRule` singular, `calendarAddress`, the
|
|
31
|
+
* synthetic-occurrence id carrying a `baseEventId`) are grounded in direct
|
|
32
|
+
* evidence from #137/#138/#145 rather than guessed; the wire's own method-arg
|
|
33
|
+
* shapes for bounds and `expandRecurrences` are accepted in more than one
|
|
34
|
+
* place (see `firstString`) since this package's own client, built alongside
|
|
35
|
+
* this fake rather than before it, has not settled which one it sends.
|
|
36
|
+
*/
|
|
37
|
+
import type { SeedPrincipal } from './sample.ts';
|
|
38
|
+
export type FakeOptions = {
|
|
39
|
+
/** The signed-in person. */
|
|
40
|
+
me?: SeedPrincipal;
|
|
41
|
+
/** Other principals `getAvailability` can be asked about. */
|
|
42
|
+
otherPrincipals?: readonly SeedPrincipal[];
|
|
43
|
+
/** Fixed "now", so a story's dates and a test's assertions do not move
|
|
44
|
+
* between runs — this fake never reads the real clock itself. */
|
|
45
|
+
now?: Date;
|
|
46
|
+
/** Milliseconds of delay on every request, for looking at a loading
|
|
47
|
+
* state. */
|
|
48
|
+
latency?: number;
|
|
49
|
+
};
|
|
50
|
+
export declare class FakeCalendarStore {
|
|
51
|
+
#private;
|
|
52
|
+
readonly me: SeedPrincipal;
|
|
53
|
+
/** Every invite `CalendarEvent/set create` landed in someone else's
|
|
54
|
+
* calendar, for a test that asserts the invite actually reached them
|
|
55
|
+
* rather than only that the call succeeded. */
|
|
56
|
+
readonly invitesSent: {
|
|
57
|
+
accountId: string;
|
|
58
|
+
eventId: string;
|
|
59
|
+
uid: string;
|
|
60
|
+
}[];
|
|
61
|
+
/** Every reply that propagated a participant-status change to another
|
|
62
|
+
* copy of the same event. */
|
|
63
|
+
readonly repliesSent: {
|
|
64
|
+
accountId: string;
|
|
65
|
+
eventId: string;
|
|
66
|
+
uid: string;
|
|
67
|
+
}[];
|
|
68
|
+
constructor(options?: FakeOptions);
|
|
69
|
+
/** The session document, as Stalwart writes it. */
|
|
70
|
+
session(origin: string): Record<string, unknown>;
|
|
71
|
+
/** Answer one method call. Exported for the transport, and for a test that
|
|
72
|
+
* wants to drive one side of a scheduling exchange directly — the
|
|
73
|
+
* invitee's reply, in particular, since `fakeCalendar()` only ever hands
|
|
74
|
+
* back one `CalendarClient`, for the organiser. */
|
|
75
|
+
call(method: string, args: Record<string, unknown>): Record<string, unknown>;
|
|
76
|
+
/** A `fetch` that answers this calendar universe. Hand it to whatever the
|
|
77
|
+
* package's client is built on. */
|
|
78
|
+
fetch: (input: unknown, init?: RequestInit) => Promise<Response>;
|
|
79
|
+
}
|