• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
nbbaier

nbbaier

pipedream-connect

Remix of valdottown/pipedream-connect
Public
Like
pipedream-connect
Home
Code
10
backend
4
frontend
2
sdk
1
.gitignore
.vtignore
AGENTS.md
MIGRATION_PLAN.md
README.md
biome.json
deno.json
Branches
1
Pull requests
Remixes
History
Environment variables
4
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
MIGRATION_PLAN.md
Code
/
MIGRATION_PLAN.md
Search
…
MIGRATION_PLAN.md

Pipedream SDK v1.x to v2.x Migration Plan

Current State Analysis

The codebase is currently using:

  • SDK Version: v1.6.8 (server) and v1.6.8 (browser)
  • Client Creation: createBackendClient() and createFrontendClient()
  • Method Calls: Old v1.x method names like actionRun(), deployTrigger(), etc.
  • Deno.json: Already has v2.0.12 mapped but code still uses v1.6.8

Required Changes

1. Update SDK Imports and Client Initialization

Backend (backend/pipedream.tsx)

Current (v1.x):

import { createBackendClient } from "npm:@pipedream/sdk@1.6.8/server"; export const pd = createBackendClient({ environment: Deno.env.get("PIPEDREAM_PROJECT_ENVIRONMENT") as | "development" | "production", credentials: { clientId: Deno.env.get("PIPEDREAM_CLIENT_ID") as string, clientSecret: Deno.env.get("PIPEDREAM_CLIENT_SECRET") as string, }, projectId: Deno.env.get("PIPEDREAM_PROJECT_ID"), });

Needs to become (v2.x):

import { PipedreamClient } from "@pipedream/sdk"; export const pd = new PipedreamClient({ clientId: Deno.env.get("PIPEDREAM_CLIENT_ID"), clientSecret: Deno.env.get("PIPEDREAM_CLIENT_SECRET"), projectId: Deno.env.get("PIPEDREAM_PROJECT_ID"), projectEnvironment: Deno.env.get("PIPEDREAM_PROJECT_ENVIRONMENT"), });

Frontend (multiple files)

Current (v1.x):

import { createFrontendClient } from "https://esm.sh/@pipedream/sdk@1.6.8/browser"; const frontendClient = createFrontendClient({ environment: "production", externalUserId: effectiveUserId, tokenCallback: async () => { const resp = await fetch("/api/pipedream/token", { method: "POST", }); const data = await resp.json(); return data; }, });

Needs to become (v2.x):

import { PipedreamClient } from "https://esm.sh/@pipedream/sdk@2.0.12/browser"; const frontendClient = new PipedreamClient({ tokenCallback: async ({ externalUserId }) => { const resp = await fetch("/api/pipedream/token", { method: "POST", }); const data = await resp.json(); return data; }, projectId: "your-project-id", // Add your project ID projectEnvironment: "production", });

2. Update Method Calls to Namespaced Format

Backend (backend/pipedream.tsx)

Current (v1.x)New (v2.x)
pd.createConnectToken()pd.tokens.create()
pd.actionRun()pd.actions.run()
pd.makeProxyRequest()pd.proxy.post() (or appropriate HTTP method)
pd.getAccountById()pd.accounts.retrieve()
pd.deleteAccount()pd.accounts.delete()
pd.deleteTrigger()pd.deployedTriggers.delete()

Backend (backend/main.tsx)

Current (v1.x)New (v2.x)
pd.getTriggers()pd.deployedTriggers.list()
pd.getTrigger()pd.deployedTriggers.retrieve()
pd.getTriggerEvents()pd.deployedTriggers.listEvents()
pd.getAccounts()pd.accounts.list()

Frontend

Current (v1.x)New (v2.x)
frontendClient.actionRun()frontendClient.actions.run()
frontendClient.deployTrigger()frontendClient.triggers.deploy()

3. Update Parameter Names

Change from snake_case to camelCase in TypeScript code:

CurrentNew
external_user_idexternalUserId
include_credentialsincludeCredentials
action_idid (for actions)
trigger_idid (for triggers)

4. Update Proxy Request Structure

Current (backend/pipedream.tsx lines 75-83):

const result = await pd.makeProxyRequest( { searchParams: { account_id: args.account_id, external_user_id: getLatestUserID(user), }, }, args.fetch, );

Needs to become:

const result = await pd.proxy.post({ accountId: args.account_id, externalUserId: getLatestUserID(user), url: args.fetch.url, body: args.fetch.body, headers: args.fetch.headers, });

5. Update SDK Version References

Remove the explicit version pinning from imports:

  • npm:@pipedream/sdk@1.6.8/server → @pipedream/sdk (uses deno.json mapping)
  • https://esm.sh/@pipedream/sdk@1.6.8/browser → https://esm.sh/@pipedream/sdk@2.0.12/browser

6. Files That Need Changes

High Priority

  1. backend/pipedream.tsx - Complete rewrite of client initialization and all method calls
  2. backend/main.tsx - Update all Pipedream method calls

Medium Priority

  1. frontend/pages/NewActionPage.tsx - Update client creation and actionRun() call
  2. frontend/pages/NewTriggerPage.tsx - Update client creation and deployTrigger() call
  3. frontend/pages/NewConnectionPage.tsx - Update client creation

Low Priority

  1. sdk/sdk.ts - This appears to be a wrapper function that calls your backend, so it might not need changes

7. Environment Variables

The v2.x SDK supports automatic environment variable loading, so you could potentially simplify the client initialization to just:

export const pd = new PipedreamClient();

8. Error Handling

Consider updating error handling to use the new PipedreamError type from v2.x for better error management:

import { PipedreamError } from "@pipedream/sdk"; try { // ... SDK calls } catch (error) { if (error instanceof PipedreamError) { console.error("API Error:", error.status, error.message); } }

Migration Checklist

  • Update import statements from createBackendClient/createFrontendClient to PipedreamClient
  • Update client initialization to use new PipedreamClient() for both server-side and browser-side
  • Convert all method calls to use namespaced format (e.g., client.actions.run())
  • Keep parameter names in camelCase in your TypeScript/JavaScript code (the SDK handles conversion to snake_case automatically)
  • Pass externalUserId to methods instead of setting it on the client
  • Update error handling to use PipedreamError type
  • Review and implement new features like pagination and request options where beneficial
  • Replace any usage of removed methods with their alternatives
  • Update any code using rawAccessToken() - for server-side code, you can access client.rawAccessToken as a getter property that returns a Promise
  • For raw response access, use .withRawResponse() method chaining instead of passing includeRawResponse option
  • Test all migrated code thoroughly
  • Remove the old SDK dependency once migration is complete

Migration Priority

  1. High Priority: Backend client initialization and core method calls
  2. Medium Priority: Frontend client updates
  3. Low Priority: Error handling improvements and environment variable simplification

Notes

  • The migration is straightforward but requires updating method calls across multiple files
  • The good news is that your deno.json already has the v2.0.12 mapping, so you just need to update the code to use the new API
  • The v2.x SDK includes several new features not available in v1.x:
    • Full TypeScript support
    • Pagination support
    • Enhanced error handling
    • Request options
    • Abort signals
    • Raw response access
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.