Add Salesforce worker sync example - #15
Open
thisisgoldman wants to merge 1 commit into
Open
Conversation
Replaces the placeholder with a working Notion worker that one-way syncs
Salesforce Accounts and Opportunities into two related managed Notion
databases via OAuth 2.0.
- worker.oauth("salesforceAuth") with Web Server Flow; the runtime
refreshes tokens automatically.
- Two managed databases joined by a two-way relation
(Accounts ↔ Opportunities, related property "Opportunities").
- Four syncs (backfill+delta per object) share one pacer; the backfill
replace-mode handles deletes via mark-and-sweep.
- accessToken() only returns the bearer, so salesforce.ts discovers the
org's instance URL via /services/oauth2/userinfo and caches it for
the lifetime of the invocation.
README walks through Connected App creation, OAuth redirect URL setup,
scopes, and the ntn workers oauth start step.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the placeholder at
examples/workers/syncs/salesforce/with a working Notion worker that one-way syncs Accounts and Opportunities from Salesforce into Notion via OAuth.worker.oauth("salesforceAuth")(Web Server Flow) — the runtime stores and refreshes tokens.Schema.relation("accounts", { twoWay: true, relatedPropertyName: "Opportunities" })).runBackfillCycle/runDeltaCycleso each registration is ~6 lines.accessToken()only returns the bearer, sosalesforce.tscalls/services/oauth2/userinfoonce per invocation to discover the org's instance URL.Test plan
npm install && npm run checkinexamples/workers/syncs/salesforce/ntn workers oauth show-redirect-urlntn workers env set SF_CLIENT_ID=... SF_CLIENT_SECRET=...ntn workers deploy --name salesforce-syncntn workers oauth start salesforceAuthntn workers sync trigger accountsBackfill && ntn workers sync trigger opportunitiesBackfill🤖 Generated with Claude Code