The codebase is currently using:
createBackendClient() and createFrontendClient()actionRun(), deployTrigger(),
etc.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"),
});
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",
});
| 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() |
| 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() |
| Current (v1.x) | New (v2.x) |
|---|---|
frontendClient.actionRun() | frontendClient.actions.run() |
frontendClient.deployTrigger() | frontendClient.triggers.deploy() |
Change from snake_case to camelCase in TypeScript code:
| Current | New |
|---|---|
external_user_id | externalUserId |
include_credentials | includeCredentials |
action_id | id (for actions) |
trigger_id | id (for triggers) |
const result = await pd.makeProxyRequest(
{
searchParams: {
account_id: args.account_id,
external_user_id: getLatestUserID(user),
},
},
args.fetch,
);
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,
});
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/browserbackend/pipedream.tsx - Complete rewrite of client initialization and
all method callsbackend/main.tsx - Update all Pipedream method callsfrontend/pages/NewActionPage.tsx - Update client creation and
actionRun() callfrontend/pages/NewTriggerPage.tsx - Update client creation and
deployTrigger() callfrontend/pages/NewConnectionPage.tsx - Update client creationsdk/sdk.ts - This appears to be a wrapper function that calls your
backend, so it might not need changesThe v2.x SDK supports automatic environment variable loading, so you could potentially simplify the client initialization to just:
export const pd = new PipedreamClient();
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);
}
}
createBackendClient/createFrontendClient
to PipedreamClientnew PipedreamClient() for both
server-side and browser-sideclient.actions.run())externalUserId to methods instead of setting it on the clientPipedreamError typerawAccessToken() - for server-side code, you can
access client.rawAccessToken as a getter property that returns a Promise.withRawResponse() method chaining instead
of passing includeRawResponse optiondeno.json already has the v2.0.12 mapping, so you
just need to update the code to use the new API