@timesheet/plugin-google-calendar 1.2.0 → 1.2.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.
@@ -194,6 +194,21 @@ async function syncCalendar(context, projectMapping) {
194
194
  if (!syncToken && metadataSyncToken) {
195
195
  syncToken = metadataSyncToken;
196
196
  }
197
+ try {
198
+ return await fetchAndSyncEvents(context, client, projectMapping, calendarId, syncStateKey, syncToken);
199
+ }
200
+ catch (err) {
201
+ // Google returns 400 or 410 when a sync token is invalid/expired — clear it and do a full resync
202
+ const errMsg = String(err);
203
+ if (syncToken && (errMsg.includes('(410)') || errMsg.includes('Invalid sync token'))) {
204
+ context.logger.warn('Sync token expired, performing full resync', { calendarId });
205
+ await context.state.delete(syncStateKey);
206
+ return await fetchAndSyncEvents(context, client, projectMapping, calendarId, syncStateKey, undefined);
207
+ }
208
+ throw err;
209
+ }
210
+ }
211
+ async function fetchAndSyncEvents(context, client, projectMapping, calendarId, syncStateKey, syncToken) {
197
212
  let pageToken;
198
213
  let nextSyncToken;
199
214
  let syncedCount = 0;
package/manifest.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "google-calendar-sync",
3
3
  "name": "Google Calendar Sync",
4
- "version": "1.2.0",
4
+ "version": "1.2.1",
5
5
  "description": "Synchronize Timesheet tasks with Google Calendar",
6
6
  "longDescription": "Bidirectional synchronization between Timesheet tasks and Google Calendar events.",
7
7
  "icon": "google-calendar",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timesheet/plugin-google-calendar",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [