55import * as environments from "./environments.js" ;
66import * as core from "./core/index.js" ;
77import * as Pipedream from "./api/index.js" ;
8- import { OauthTokens } from "./api/resources/oauthTokens/client/Client.js" ;
98import { mergeHeaders } from "./core/headers.js" ;
109import { AppCategories } from "./api/resources/appCategories/client/Client.js" ;
1110import { Apps } from "./api/resources/apps/client/Client.js" ;
@@ -18,15 +17,15 @@ import { DeployedTriggers } from "./api/resources/deployedTriggers/client/Client
1817import { Projects } from "./api/resources/projects/client/Client.js" ;
1918import { Proxy } from "./api/resources/proxy/client/Client.js" ;
2019import { Tokens } from "./api/resources/tokens/client/Client.js" ;
20+ import { OauthTokens } from "./api/resources/oauthTokens/client/Client.js" ;
2121
2222export declare namespace PipedreamClient {
2323 export interface Options {
2424 environment ?: core . Supplier < environments . PipedreamEnvironment | string > ;
2525 /** Specify a custom URL to connect the client to. */
2626 baseUrl ?: core . Supplier < string > ;
27- clientId ?: core . Supplier < string > ;
28- clientSecret ?: core . Supplier < string > ;
2927 projectId : string ;
28+ accessToken ?: core . Supplier < core . BearerToken | undefined > ;
3029 /** Override the x-pd-environment header */
3130 projectEnvironment ?: core . Supplier < Pipedream . ProjectEnvironment | undefined > ;
3231 /** Additional headers to include in requests. */
@@ -49,7 +48,6 @@ export declare namespace PipedreamClient {
4948
5049export class PipedreamClient {
5150 protected readonly _options : PipedreamClient . Options ;
52- private readonly _oauthTokenProvider : core . OAuthTokenProvider ;
5351 protected _appCategories : AppCategories | undefined ;
5452 protected _apps : Apps | undefined ;
5553 protected _accounts : Accounts | undefined ;
@@ -79,112 +77,53 @@ export class PipedreamClient {
7977 _options ?. headers ,
8078 ) ,
8179 } ;
82-
83- const clientId = this . _options . clientId ?? process . env [ "PIPEDREAM_CLIENT_ID" ] ;
84- if ( clientId == null ) {
85- throw new Error (
86- "clientId is required; either pass it as an argument or set the PIPEDREAM_CLIENT_ID environment variable" ,
87- ) ;
88- }
89-
90- const clientSecret = this . _options . clientSecret ?? process . env [ "PIPEDREAM_CLIENT_SECRET" ] ;
91- if ( clientSecret == null ) {
92- throw new Error (
93- "clientSecret is required; either pass it as an argument or set the PIPEDREAM_CLIENT_SECRET environment variable" ,
94- ) ;
95- }
96-
97- this . _oauthTokenProvider = new core . OAuthTokenProvider ( {
98- clientId,
99- clientSecret,
100- authClient : new OauthTokens ( {
101- ...this . _options ,
102- environment : this . _options . environment ,
103- } ) ,
104- } ) ;
10580 }
10681
10782 public get appCategories ( ) : AppCategories {
108- return ( this . _appCategories ??= new AppCategories ( {
109- ...this . _options ,
110- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
111- } ) ) ;
83+ return ( this . _appCategories ??= new AppCategories ( this . _options ) ) ;
11284 }
11385
11486 public get apps ( ) : Apps {
115- return ( this . _apps ??= new Apps ( {
116- ...this . _options ,
117- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
118- } ) ) ;
87+ return ( this . _apps ??= new Apps ( this . _options ) ) ;
11988 }
12089
12190 public get accounts ( ) : Accounts {
122- return ( this . _accounts ??= new Accounts ( {
123- ...this . _options ,
124- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
125- } ) ) ;
91+ return ( this . _accounts ??= new Accounts ( this . _options ) ) ;
12692 }
12793
12894 public get users ( ) : Users {
129- return ( this . _users ??= new Users ( {
130- ...this . _options ,
131- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
132- } ) ) ;
95+ return ( this . _users ??= new Users ( this . _options ) ) ;
13396 }
13497
13598 public get components ( ) : Components {
136- return ( this . _components ??= new Components ( {
137- ...this . _options ,
138- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
139- } ) ) ;
99+ return ( this . _components ??= new Components ( this . _options ) ) ;
140100 }
141101
142102 public get actions ( ) : Actions {
143- return ( this . _actions ??= new Actions ( {
144- ...this . _options ,
145- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
146- } ) ) ;
103+ return ( this . _actions ??= new Actions ( this . _options ) ) ;
147104 }
148105
149106 public get triggers ( ) : Triggers {
150- return ( this . _triggers ??= new Triggers ( {
151- ...this . _options ,
152- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
153- } ) ) ;
107+ return ( this . _triggers ??= new Triggers ( this . _options ) ) ;
154108 }
155109
156110 public get deployedTriggers ( ) : DeployedTriggers {
157- return ( this . _deployedTriggers ??= new DeployedTriggers ( {
158- ...this . _options ,
159- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
160- } ) ) ;
111+ return ( this . _deployedTriggers ??= new DeployedTriggers ( this . _options ) ) ;
161112 }
162113
163114 public get projects ( ) : Projects {
164- return ( this . _projects ??= new Projects ( {
165- ...this . _options ,
166- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
167- } ) ) ;
115+ return ( this . _projects ??= new Projects ( this . _options ) ) ;
168116 }
169117
170118 public get proxy ( ) : Proxy {
171- return ( this . _proxy ??= new Proxy ( {
172- ...this . _options ,
173- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
174- } ) ) ;
119+ return ( this . _proxy ??= new Proxy ( this . _options ) ) ;
175120 }
176121
177122 public get tokens ( ) : Tokens {
178- return ( this . _tokens ??= new Tokens ( {
179- ...this . _options ,
180- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
181- } ) ) ;
123+ return ( this . _tokens ??= new Tokens ( this . _options ) ) ;
182124 }
183125
184126 public get oauthTokens ( ) : OauthTokens {
185- return ( this . _oauthTokens ??= new OauthTokens ( {
186- ...this . _options ,
187- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
188- } ) ) ;
127+ return ( this . _oauthTokens ??= new OauthTokens ( this . _options ) ) ;
189128 }
190129}
0 commit comments