@kubun/connector-google-calendar 0.17.3 → 0.18.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/lib/actions.d.ts +1 -1
- package/lib/actions.js +15 -6
- package/lib/api.d.ts +49 -5
- package/lib/api.js +166 -16
- package/lib/connector.js +22 -2
- package/lib/index.d.ts +1 -1
- package/lib/intent.d.ts +4 -0
- package/lib/intent.js +23 -0
- package/lib/model.d.ts +8 -53
- package/lib/model.js +37 -74
- package/lib/provider.d.ts +14 -0
- package/lib/provider.js +401 -137
- package/package.json +12 -11
package/lib/model.js
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
import { connectorClusters, connectorModelIDs, externalEntityDefinition } from '@kubun/connector';
|
|
2
|
-
import {
|
|
2
|
+
import { calendarClusters, calendarModelDefinitions, calendarModelIDs } from '@kubun/models-calendar';
|
|
3
|
+
import { coreClusters, coreModelDefinitions, coreModelIDs } from '@kubun/models-core';
|
|
3
4
|
import { GraphBuilder } from '@kubun/protocol';
|
|
4
|
-
import { docIDSchema,
|
|
5
|
+
import { docIDSchema, urlSchema } from '@kubun/scalars';
|
|
6
|
+
const calendarKindProviderFields = calendarModelDefinitions.find((definition)=>definition.name === 'CalendarKind')?.providerMergePolicy?.group;
|
|
7
|
+
const eventKindProviderFields = calendarModelDefinitions.find((definition)=>definition.name === 'EventKind')?.providerMergePolicy?.group;
|
|
8
|
+
const schedulableProviderFields = coreModelDefinitions.find((definition)=>definition.name === 'Schedulable')?.providerMergePolicy?.group;
|
|
9
|
+
if (calendarKindProviderFields == null || eventKindProviderFields == null || schedulableProviderFields == null) {
|
|
10
|
+
throw new Error('Calendar provider fields are missing');
|
|
11
|
+
}
|
|
12
|
+
// The shared calendar fields (name, description, color, timeZone, accessRole)
|
|
13
|
+
// come from CalendarKind; only what is Google's own is declared here.
|
|
5
14
|
export const googleCalendarDefinition = {
|
|
6
15
|
name: 'GoogleCalendar',
|
|
7
16
|
behavior: 'default',
|
|
8
17
|
interfaces: [
|
|
9
|
-
connectorModelIDs.ExternalEntity
|
|
18
|
+
connectorModelIDs.ExternalEntity,
|
|
19
|
+
calendarModelIDs.CalendarKind
|
|
10
20
|
],
|
|
11
21
|
schema: {
|
|
12
22
|
type: 'object',
|
|
13
23
|
properties: {
|
|
14
|
-
summary: {
|
|
15
|
-
type: 'string'
|
|
16
|
-
},
|
|
17
|
-
description: {
|
|
18
|
-
type: 'string'
|
|
19
|
-
},
|
|
20
|
-
timeZone: {
|
|
21
|
-
$ref: '#/definitions/TimeZone'
|
|
22
|
-
},
|
|
23
24
|
primary: {
|
|
24
25
|
type: 'boolean'
|
|
25
26
|
},
|
|
26
|
-
backgroundColor: {
|
|
27
|
-
type: 'string'
|
|
28
|
-
},
|
|
29
27
|
accountKey: {
|
|
30
28
|
type: 'string',
|
|
31
29
|
minLength: 43,
|
|
@@ -45,61 +43,43 @@ export const googleCalendarDefinition = {
|
|
|
45
43
|
}
|
|
46
44
|
},
|
|
47
45
|
required: [
|
|
48
|
-
'summary',
|
|
49
46
|
'sourceService',
|
|
50
47
|
'sourceID',
|
|
51
48
|
'lastSyncedAt'
|
|
52
49
|
],
|
|
53
50
|
additionalProperties: false,
|
|
54
51
|
definitions: {
|
|
55
|
-
...externalEntityDefinition.schema.definitions
|
|
56
|
-
TimeZone: timeZoneSchema
|
|
52
|
+
...externalEntityDefinition.schema.definitions
|
|
57
53
|
}
|
|
58
54
|
},
|
|
59
|
-
fieldsMeta: {}
|
|
55
|
+
fieldsMeta: {},
|
|
56
|
+
providerMergePolicy: {
|
|
57
|
+
group: [
|
|
58
|
+
...calendarKindProviderFields,
|
|
59
|
+
'primary',
|
|
60
|
+
'sourceService',
|
|
61
|
+
'sourceID',
|
|
62
|
+
'sourceURL'
|
|
63
|
+
]
|
|
64
|
+
}
|
|
60
65
|
};
|
|
61
66
|
export const googleCalendarEventDefinition = {
|
|
62
67
|
name: 'GoogleCalendarEvent',
|
|
63
68
|
behavior: 'default',
|
|
69
|
+
// The event fields (title, times, participants, recurrence, reminders...)
|
|
70
|
+
// come from EventKind and Schedulable, and the local tags from Taggable;
|
|
71
|
+
// only what is Google's own is declared here.
|
|
64
72
|
interfaces: [
|
|
65
73
|
connectorModelIDs.ExternalEntity,
|
|
66
|
-
|
|
74
|
+
calendarModelIDs.EventKind,
|
|
75
|
+
coreModelIDs.Taggable
|
|
67
76
|
],
|
|
68
77
|
schema: {
|
|
69
78
|
type: 'object',
|
|
70
79
|
properties: {
|
|
71
|
-
title: {
|
|
72
|
-
type: 'string',
|
|
73
|
-
minLength: 1,
|
|
74
|
-
maxLength: 200
|
|
75
|
-
},
|
|
76
|
-
startAt: {
|
|
77
|
-
$ref: '#/definitions/DateTime'
|
|
78
|
-
},
|
|
79
|
-
endAt: {
|
|
80
|
-
$ref: '#/definitions/DateTime'
|
|
81
|
-
},
|
|
82
|
-
allDay: {
|
|
83
|
-
type: 'boolean'
|
|
84
|
-
},
|
|
85
|
-
timeZone: {
|
|
86
|
-
$ref: '#/definitions/TimeZone'
|
|
87
|
-
},
|
|
88
|
-
description: {
|
|
89
|
-
type: 'string'
|
|
90
|
-
},
|
|
91
|
-
location: {
|
|
92
|
-
type: 'string'
|
|
93
|
-
},
|
|
94
|
-
status: {
|
|
95
|
-
$ref: '#/definitions/EventStatus'
|
|
96
|
-
},
|
|
97
80
|
htmlLink: {
|
|
98
81
|
$ref: '#/definitions/HtmlLink'
|
|
99
82
|
},
|
|
100
|
-
recurringEventID: {
|
|
101
|
-
type: 'string'
|
|
102
|
-
},
|
|
103
83
|
eventID: {
|
|
104
84
|
type: 'string'
|
|
105
85
|
},
|
|
@@ -126,9 +106,6 @@ export const googleCalendarEventDefinition = {
|
|
|
126
106
|
}
|
|
127
107
|
},
|
|
128
108
|
required: [
|
|
129
|
-
'title',
|
|
130
|
-
'startAt',
|
|
131
|
-
'allDay',
|
|
132
109
|
'calendarID',
|
|
133
110
|
'calendar',
|
|
134
111
|
'sourceService',
|
|
@@ -146,18 +123,8 @@ export const googleCalendarEventDefinition = {
|
|
|
146
123
|
minLength: 1,
|
|
147
124
|
maxLength: 1400
|
|
148
125
|
},
|
|
149
|
-
TimeZone: timeZoneSchema,
|
|
150
126
|
HtmlLink: urlSchema,
|
|
151
|
-
CalendarDocID: docIDSchema
|
|
152
|
-
EventStatus: {
|
|
153
|
-
type: 'string',
|
|
154
|
-
title: 'EventStatus',
|
|
155
|
-
enum: [
|
|
156
|
-
'CONFIRMED',
|
|
157
|
-
'TENTATIVE',
|
|
158
|
-
'CANCELLED'
|
|
159
|
-
]
|
|
160
|
-
}
|
|
127
|
+
CalendarDocID: docIDSchema
|
|
161
128
|
}
|
|
162
129
|
},
|
|
163
130
|
fieldsMeta: {
|
|
@@ -166,20 +133,15 @@ export const googleCalendarEventDefinition = {
|
|
|
166
133
|
model: '#0'
|
|
167
134
|
}
|
|
168
135
|
},
|
|
169
|
-
// lastSyncedAt is a device-local sync-bookkeeping annotation
|
|
170
|
-
// provider content, so
|
|
136
|
+
// lastSyncedAt is a device-local sync-bookkeeping annotation and tags a
|
|
137
|
+
// local user annotation, neither fetched provider content, so both stay
|
|
138
|
+
// outside the group.
|
|
171
139
|
providerMergePolicy: {
|
|
172
140
|
group: [
|
|
173
141
|
'title',
|
|
174
|
-
|
|
175
|
-
'
|
|
176
|
-
'allDay',
|
|
177
|
-
'timeZone',
|
|
178
|
-
'description',
|
|
179
|
-
'location',
|
|
180
|
-
'status',
|
|
142
|
+
...schedulableProviderFields,
|
|
143
|
+
...eventKindProviderFields.filter((field)=>field !== 'title' && field !== 'calendar'),
|
|
181
144
|
'htmlLink',
|
|
182
|
-
'recurringEventID',
|
|
183
145
|
'eventID',
|
|
184
146
|
'calendarID',
|
|
185
147
|
'calendar',
|
|
@@ -196,7 +158,8 @@ export const googleCalendarEventDefinition = {
|
|
|
196
158
|
const builder = new GraphBuilder({
|
|
197
159
|
externalClusters: {
|
|
198
160
|
...connectorClusters,
|
|
199
|
-
...
|
|
161
|
+
...coreClusters,
|
|
162
|
+
...calendarClusters
|
|
200
163
|
}
|
|
201
164
|
});
|
|
202
165
|
builder.add(googleCalendarDefinition); // #0
|
package/lib/provider.d.ts
CHANGED
|
@@ -9,9 +9,23 @@ export type GoogleCalendarProviderConfig = {
|
|
|
9
9
|
};
|
|
10
10
|
export type CalendarCheckpoint = {
|
|
11
11
|
calendarListSyncToken?: string;
|
|
12
|
+
completed?: Array<string>;
|
|
13
|
+
roll?: {
|
|
14
|
+
windowEnd: string;
|
|
15
|
+
startedAt: string;
|
|
16
|
+
completed: Array<string>;
|
|
17
|
+
};
|
|
12
18
|
calendars: Record<string, {
|
|
13
19
|
eventsSyncToken?: string;
|
|
20
|
+
relist?: {
|
|
21
|
+
relistID: string;
|
|
22
|
+
pageToken?: string;
|
|
23
|
+
startedFetchHLC: string;
|
|
24
|
+
seen: Array<string>;
|
|
25
|
+
};
|
|
14
26
|
}>;
|
|
15
27
|
windowStart?: string;
|
|
28
|
+
windowEnd?: string;
|
|
29
|
+
windowRolledAt?: string;
|
|
16
30
|
};
|
|
17
31
|
export declare function createGoogleCalendarProvider(config: GoogleCalendarProviderConfig): ServerDataProvider;
|