Skip to content

🌿 Fern Regeneration -- July 8, 2025 #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ Instantiate and use the client with the following:
```typescript
import { PipedreamClient } from "@pipedream/sdk";

const client = new PipedreamClient({
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
xPdEnvironment: "YOUR_X_PD_ENVIRONMENT",
});
const client = new PipedreamClient({ apiKey: "YOUR_API_KEY", xPdEnvironment: "YOUR_X_PD_ENVIRONMENT" });
await client.accounts.create({
app_slug: "app_slug",
cfmap_json: "cfmap_json",
Expand Down Expand Up @@ -74,11 +70,7 @@ List endpoints are paginated. The SDK provides an iterator so that you can simpl
```typescript
import { PipedreamClient } from "@pipedream/sdk";

const client = new PipedreamClient({
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
xPdEnvironment: "YOUR_X_PD_ENVIRONMENT",
});
const client = new PipedreamClient({ apiKey: "YOUR_API_KEY", xPdEnvironment: "YOUR_X_PD_ENVIRONMENT" });
const response = await client.apps.list();
for await (const item of response) {
console.log(item);
Expand Down
75 changes: 14 additions & 61 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import * as environments from "./environments.js";
import * as core from "./core/index.js";
import { OauthTokens } from "./api/resources/oauthTokens/client/Client.js";
import { mergeHeaders } from "./core/headers.js";
import { AppCategories } from "./api/resources/appCategories/client/Client.js";
import { Apps } from "./api/resources/apps/client/Client.js";
Expand All @@ -17,15 +16,15 @@ import { DeployedTriggers } from "./api/resources/deployedTriggers/client/Client
import { Projects } from "./api/resources/projects/client/Client.js";
import { Proxy } from "./api/resources/proxy/client/Client.js";
import { Tokens } from "./api/resources/tokens/client/Client.js";
import { OauthTokens } from "./api/resources/oauthTokens/client/Client.js";

export declare namespace PipedreamClient {
export interface Options {
environment?: core.Supplier<environments.PipedreamEnvironment | string>;
/** Specify a custom URL to connect the client to. */
baseUrl?: core.Supplier<string>;
clientId: core.Supplier<string>;
clientSecret: core.Supplier<string>;
projectId: string;
apiKey?: core.Supplier<string | undefined>;
/** Override the x-pd-environment header */
xPdEnvironment?: core.Supplier<string | undefined>;
/** Additional headers to include in requests. */
Expand All @@ -48,7 +47,6 @@ export declare namespace PipedreamClient {

export class PipedreamClient {
protected readonly _options: PipedreamClient.Options;
private readonly _oauthTokenProvider: core.OAuthTokenProvider;
protected _appCategories: AppCategories | undefined;
protected _apps: Apps | undefined;
protected _accounts: Accounts | undefined;
Expand Down Expand Up @@ -78,98 +76,53 @@ export class PipedreamClient {
_options?.headers,
),
};

this._oauthTokenProvider = new core.OAuthTokenProvider({
clientId: this._options.clientId,
clientSecret: this._options.clientSecret,
authClient: new OauthTokens({
...this._options,
environment: this._options.environment,
}),
});
}

public get appCategories(): AppCategories {
return (this._appCategories ??= new AppCategories({
...this._options,
token: async () => await this._oauthTokenProvider.getToken(),
}));
return (this._appCategories ??= new AppCategories(this._options));
}

public get apps(): Apps {
return (this._apps ??= new Apps({
...this._options,
token: async () => await this._oauthTokenProvider.getToken(),
}));
return (this._apps ??= new Apps(this._options));
}

public get accounts(): Accounts {
return (this._accounts ??= new Accounts({
...this._options,
token: async () => await this._oauthTokenProvider.getToken(),
}));
return (this._accounts ??= new Accounts(this._options));
}

public get users(): Users {
return (this._users ??= new Users({
...this._options,
token: async () => await this._oauthTokenProvider.getToken(),
}));
return (this._users ??= new Users(this._options));
}

public get components(): Components {
return (this._components ??= new Components({
...this._options,
token: async () => await this._oauthTokenProvider.getToken(),
}));
return (this._components ??= new Components(this._options));
}

public get actions(): Actions {
return (this._actions ??= new Actions({
...this._options,
token: async () => await this._oauthTokenProvider.getToken(),
}));
return (this._actions ??= new Actions(this._options));
}

public get triggers(): Triggers {
return (this._triggers ??= new Triggers({
...this._options,
token: async () => await this._oauthTokenProvider.getToken(),
}));
return (this._triggers ??= new Triggers(this._options));
}

public get deployedTriggers(): DeployedTriggers {
return (this._deployedTriggers ??= new DeployedTriggers({
...this._options,
token: async () => await this._oauthTokenProvider.getToken(),
}));
return (this._deployedTriggers ??= new DeployedTriggers(this._options));
}

public get projects(): Projects {
return (this._projects ??= new Projects({
...this._options,
token: async () => await this._oauthTokenProvider.getToken(),
}));
return (this._projects ??= new Projects(this._options));
}

public get proxy(): Proxy {
return (this._proxy ??= new Proxy({
...this._options,
token: async () => await this._oauthTokenProvider.getToken(),
}));
return (this._proxy ??= new Proxy(this._options));
}

public get tokens(): Tokens {
return (this._tokens ??= new Tokens({
...this._options,
token: async () => await this._oauthTokenProvider.getToken(),
}));
return (this._tokens ??= new Tokens(this._options));
}

public get oauthTokens(): OauthTokens {
return (this._oauthTokens ??= new OauthTokens({
...this._options,
token: async () => await this._oauthTokenProvider.getToken(),
}));
return (this._oauthTokens ??= new OauthTokens(this._options));
}
}
22 changes: 9 additions & 13 deletions src/api/resources/accounts/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export declare namespace Accounts {
/** Specify a custom URL to connect the client to. */
baseUrl?: core.Supplier<string>;
projectId: string;
token?: core.Supplier<core.BearerToken | undefined>;
apiKey?: core.Supplier<string | undefined>;
/** Override the x-pd-environment header */
xPdEnvironment?: core.Supplier<string | undefined>;
/** Additional headers to include in requests. */
Expand Down Expand Up @@ -99,8 +99,8 @@ export class Accounts {
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({
Authorization: await this._getAuthorizationHeader(),
"x-pd-environment": requestOptions?.xPdEnvironment,
...(await this._getCustomAuthorizationHeaders()),
}),
requestOptions?.headers,
),
Expand Down Expand Up @@ -203,8 +203,8 @@ export class Accounts {
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({
Authorization: await this._getAuthorizationHeader(),
"x-pd-environment": requestOptions?.xPdEnvironment,
...(await this._getCustomAuthorizationHeaders()),
}),
requestOptions?.headers,
),
Expand Down Expand Up @@ -285,8 +285,8 @@ export class Accounts {
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({
Authorization: await this._getAuthorizationHeader(),
"x-pd-environment": requestOptions?.xPdEnvironment,
...(await this._getCustomAuthorizationHeaders()),
}),
requestOptions?.headers,
),
Expand Down Expand Up @@ -352,8 +352,8 @@ export class Accounts {
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({
Authorization: await this._getAuthorizationHeader(),
"x-pd-environment": requestOptions?.xPdEnvironment,
...(await this._getCustomAuthorizationHeaders()),
}),
requestOptions?.headers,
),
Expand Down Expand Up @@ -418,8 +418,8 @@ export class Accounts {
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({
Authorization: await this._getAuthorizationHeader(),
"x-pd-environment": requestOptions?.xPdEnvironment,
...(await this._getCustomAuthorizationHeaders()),
}),
requestOptions?.headers,
),
Expand Down Expand Up @@ -458,12 +458,8 @@ export class Accounts {
}
}

protected async _getAuthorizationHeader(): Promise<string | undefined> {
const bearer = await core.Supplier.get(this._options.token);
if (bearer != null) {
return `Bearer ${bearer}`;
}

return undefined;
protected async _getCustomAuthorizationHeaders() {
const apiKeyValue = await core.Supplier.get(this._options.apiKey);
return { Authorization: apiKeyValue };
}
}
22 changes: 9 additions & 13 deletions src/api/resources/actions/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export declare namespace Actions {
/** Specify a custom URL to connect the client to. */
baseUrl?: core.Supplier<string>;
projectId: string;
token?: core.Supplier<core.BearerToken | undefined>;
apiKey?: core.Supplier<string | undefined>;
/** Override the x-pd-environment header */
xPdEnvironment?: core.Supplier<string | undefined>;
/** Additional headers to include in requests. */
Expand Down Expand Up @@ -85,8 +85,8 @@ export class Actions {
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({
Authorization: await this._getAuthorizationHeader(),
"x-pd-environment": requestOptions?.xPdEnvironment,
...(await this._getCustomAuthorizationHeaders()),
}),
requestOptions?.headers,
),
Expand Down Expand Up @@ -171,8 +171,8 @@ export class Actions {
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({
Authorization: await this._getAuthorizationHeader(),
"x-pd-environment": requestOptions?.xPdEnvironment,
...(await this._getCustomAuthorizationHeaders()),
}),
requestOptions?.headers,
),
Expand Down Expand Up @@ -247,9 +247,9 @@ export class Actions {
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({
Authorization: await this._getAuthorizationHeader(),
"x-async-handle": asyncHandle != null ? asyncHandle : undefined,
"x-pd-environment": requestOptions?.xPdEnvironment,
...(await this._getCustomAuthorizationHeaders()),
}),
requestOptions?.headers,
),
Expand Down Expand Up @@ -326,9 +326,9 @@ export class Actions {
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({
Authorization: await this._getAuthorizationHeader(),
"x-async-handle": asyncHandle != null ? asyncHandle : undefined,
"x-pd-environment": requestOptions?.xPdEnvironment,
...(await this._getCustomAuthorizationHeaders()),
}),
requestOptions?.headers,
),
Expand Down Expand Up @@ -403,9 +403,9 @@ export class Actions {
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({
Authorization: await this._getAuthorizationHeader(),
"x-async-handle": asyncHandle != null ? asyncHandle : undefined,
"x-pd-environment": requestOptions?.xPdEnvironment,
...(await this._getCustomAuthorizationHeaders()),
}),
requestOptions?.headers,
),
Expand Down Expand Up @@ -447,12 +447,8 @@ export class Actions {
}
}

protected async _getAuthorizationHeader(): Promise<string | undefined> {
const bearer = await core.Supplier.get(this._options.token);
if (bearer != null) {
return `Bearer ${bearer}`;
}

return undefined;
protected async _getCustomAuthorizationHeaders() {
const apiKeyValue = await core.Supplier.get(this._options.apiKey);
return { Authorization: apiKeyValue };
}
}
16 changes: 6 additions & 10 deletions src/api/resources/appCategories/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export declare namespace AppCategories {
/** Specify a custom URL to connect the client to. */
baseUrl?: core.Supplier<string>;
projectId: string;
token?: core.Supplier<core.BearerToken | undefined>;
apiKey?: core.Supplier<string | undefined>;
/** Override the x-pd-environment header */
xPdEnvironment?: core.Supplier<string | undefined>;
/** Additional headers to include in requests. */
Expand Down Expand Up @@ -68,8 +68,8 @@ export class AppCategories {
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({
Authorization: await this._getAuthorizationHeader(),
"x-pd-environment": requestOptions?.xPdEnvironment,
...(await this._getCustomAuthorizationHeaders()),
}),
requestOptions?.headers,
),
Expand Down Expand Up @@ -135,8 +135,8 @@ export class AppCategories {
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({
Authorization: await this._getAuthorizationHeader(),
"x-pd-environment": requestOptions?.xPdEnvironment,
...(await this._getCustomAuthorizationHeaders()),
}),
requestOptions?.headers,
),
Expand Down Expand Up @@ -175,12 +175,8 @@ export class AppCategories {
}
}

protected async _getAuthorizationHeader(): Promise<string | undefined> {
const bearer = await core.Supplier.get(this._options.token);
if (bearer != null) {
return `Bearer ${bearer}`;
}

return undefined;
protected async _getCustomAuthorizationHeaders() {
const apiKeyValue = await core.Supplier.get(this._options.apiKey);
return { Authorization: apiKeyValue };
}
}
Loading
Loading