Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/feat-google-contacts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@syncdown/connector-google-contacts": minor
"@syncdown/connectors": minor
"@syncdown/core": minor
"@syncdown/renderer-md": minor
"@syncdown/cli": minor
---

Add Google Contacts connector backed by the People API. Syncs name, emails, phones, organizations, addresses, URLs, contact groups, birthdays, biographies, and custom fields into one markdown file per contact under `<outputDir>/google-contacts/<account>/`. Uses People API `syncToken` for incremental syncs and `contactGroups.list` to resolve human-readable group labels. Requires the `contacts.readonly` OAuth scope — existing users will need to re-authorize the shared Google connection to pick up the new scope.
10 changes: 10 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/connector-apple-notes/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {
import {
DEFAULT_APPLE_NOTES_CONNECTION_ID,
defineConnectorPlugin,
stableStringify,
} from "@syncdown/core";

export interface AppleNotesNote {
Expand Down Expand Up @@ -236,7 +237,7 @@ function toSourceId(rawId: string): string {
function toSourceHash(note: AppleNotesNote): string {
return new Bun.CryptoHasher("sha256")
.update(
JSON.stringify({
stableStringify({
title: note.title,
body: note.body,
account: note.account,
Expand Down
13 changes: 11 additions & 2 deletions packages/connector-gmail/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
GOOGLE_SECRET_NAMES,
getGoogleConnectionSecretNames,
getGoogleOAuthAppSecretNames,
stableStringify,
} from "@syncdown/core";

const HISTORY_ID_INVALID_REASON = "invalid_history_id";
Expand Down Expand Up @@ -138,7 +139,15 @@ async function parseJsonResponse<T>(response: Response): Promise<T | null> {
return null;
}

return JSON.parse(text) as T;
try {
return JSON.parse(text) as T;
} catch (error) {
const reason = error instanceof Error ? error.message : String(error);
throw new GmailApiError(
response.status,
`Gmail API response was not valid JSON: ${reason}`,
);
}
}

class OfficialGmailAdapter implements GmailAdapter {
Expand Down Expand Up @@ -433,7 +442,7 @@ function computeSourceHash(
): string {
return new Bun.CryptoHasher("sha256")
.update(
JSON.stringify({
stableStringify({
connectorId: snapshot.connectorId,
sourceId: snapshot.sourceId,
title: snapshot.title,
Expand Down
13 changes: 11 additions & 2 deletions packages/connector-google-calendar/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
DEFAULT_GOOGLE_CONNECTION_ID,
DEFAULT_GOOGLE_OAUTH_APP_ID,
defineConnectorPlugin,
stableStringify,
} from "@syncdown/core";

const GOOGLE_CALENDAR_API_BASE_URL = "https://www.googleapis.com/calendar/v3/";
Expand Down Expand Up @@ -125,7 +126,15 @@ async function parseJsonResponse<T>(response: Response): Promise<T | null> {
return null;
}

return JSON.parse(text) as T;
try {
return JSON.parse(text) as T;
} catch (error) {
const reason = error instanceof Error ? error.message : String(error);
throw new GoogleCalendarApiError(
response.status,
`Google Calendar API response was not valid JSON: ${reason}`,
);
}
}

class OfficialGoogleCalendarAdapter implements GoogleCalendarAdapter {
Expand Down Expand Up @@ -309,7 +318,7 @@ function computeSourceHash(
): string {
return new Bun.CryptoHasher("sha256")
.update(
JSON.stringify({
stableStringify({
connectorId: snapshot.connectorId,
sourceId: snapshot.sourceId,
title: snapshot.title,
Expand Down
18 changes: 18 additions & 0 deletions packages/connector-google-contacts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@syncdown/connector-google-contacts",
"private": true,
"version": "0.1.0",
"type": "module",
"main": "./src/index.ts",
"types": "./src/index.ts",
"exports": {
".": "./src/index.ts"
},
"scripts": {
"typecheck": "tsgo -p ./tsconfig.json --noEmit --pretty false",
"test": "bun test ./src/index.test.ts"
},
"dependencies": {
"@syncdown/core": "workspace:*"
}
}
Loading
Loading