1- // This file was auto-generated by Fern from our API Definition.
1+ // This file was initially auto-generated by Fern from our API Definition.
2+ // It was later customized by the Pipedream team.
23
4+ import { SDK_VERSION } from "./version.js" ;
35import { Accounts } from "./api/resources/accounts/client/Client.js" ;
46import { Actions } from "./api/resources/actions/client/Client.js" ;
57import { AppCategories } from "./api/resources/appCategories/client/Client.js" ;
@@ -21,14 +23,15 @@ export declare namespace PipedreamClient {
2123 export interface Options extends BaseClientOptions {
2224 clientId ?: core . Supplier < string > ;
2325 clientSecret ?: core . Supplier < string > ;
26+ tokenProvider ?: core . TokenProvider ;
2427 }
2528
2629 export interface RequestOptions extends BaseRequestOptions { }
2730}
2831
2932export class PipedreamClient {
3033 protected readonly _options : PipedreamClient . Options ;
31- private readonly _oauthTokenProvider : core . OAuthTokenProvider ;
34+ protected readonly _tokenProvider : core . TokenProvider ;
3235 protected _appCategories : AppCategories | undefined ;
3336 protected _apps : Apps | undefined ;
3437 protected _accounts : Accounts | undefined ;
@@ -37,8 +40,8 @@ export class PipedreamClient {
3740 protected _actions : Actions | undefined ;
3841 protected _triggers : Triggers | undefined ;
3942 protected _deployedTriggers : DeployedTriggers | undefined ;
40- protected _projects : Projects | undefined ;
4143 protected _fileStash : FileStash | undefined ;
44+ protected _projects : Projects | undefined ;
4245 protected _proxy : Proxy | undefined ;
4346 protected _tokens : Tokens | undefined ;
4447 protected _oauthTokens : OauthTokens | undefined ;
@@ -51,15 +54,19 @@ export class PipedreamClient {
5154 "x-pd-environment" : _options ?. projectEnvironment ,
5255 "X-Fern-Language" : "JavaScript" ,
5356 "X-Fern-SDK-Name" : "@pipedream/sdk" ,
54- "X-Fern-SDK-Version" : "2.3.3" ,
55- "User-Agent" : " @pipedream/sdk/2.3.3" ,
57+ "X-Fern-SDK-Version" : SDK_VERSION ,
58+ "User-Agent" : ` @pipedream/sdk/${ SDK_VERSION } ` ,
5659 "X-Fern-Runtime" : core . RUNTIME . type ,
5760 "X-Fern-Runtime-Version" : core . RUNTIME . version ,
5861 } ,
5962 _options ?. headers ,
6063 ) ,
6164 } ;
6265
66+ this . _tokenProvider = this . _options . tokenProvider ?? this . newOAuthTokenProvider ( ) ;
67+ }
68+
69+ private newOAuthTokenProvider ( ) : core . OAuthTokenProvider {
6370 const clientId = this . _options . clientId ?? process . env . PIPEDREAM_CLIENT_ID ;
6471 if ( clientId == null ) {
6572 throw new Error (
@@ -74,9 +81,8 @@ export class PipedreamClient {
7481 ) ;
7582 }
7683
77- this . _oauthTokenProvider = new core . OAuthTokenProvider ( {
84+ return new core . OAuthTokenProvider ( {
7885 clientId,
79-
8086 clientSecret,
8187 authClient : new OauthTokens ( {
8288 ...this . _options ,
@@ -88,91 +94,91 @@ export class PipedreamClient {
8894 public get appCategories ( ) : AppCategories {
8995 return ( this . _appCategories ??= new AppCategories ( {
9096 ...this . _options ,
91- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
97+ token : async ( ) => await this . _tokenProvider . getToken ( ) ,
9298 } ) ) ;
9399 }
94100
95101 public get apps ( ) : Apps {
96102 return ( this . _apps ??= new Apps ( {
97103 ...this . _options ,
98- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
104+ token : async ( ) => await this . _tokenProvider . getToken ( ) ,
99105 } ) ) ;
100106 }
101107
102108 public get accounts ( ) : Accounts {
103109 return ( this . _accounts ??= new Accounts ( {
104110 ...this . _options ,
105- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
111+ token : async ( ) => await this . _tokenProvider . getToken ( ) ,
106112 } ) ) ;
107113 }
108114
109115 public get users ( ) : Users {
110116 return ( this . _users ??= new Users ( {
111117 ...this . _options ,
112- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
118+ token : async ( ) => await this . _tokenProvider . getToken ( ) ,
113119 } ) ) ;
114120 }
115121
116122 public get components ( ) : Components {
117123 return ( this . _components ??= new Components ( {
118124 ...this . _options ,
119- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
125+ token : async ( ) => await this . _tokenProvider . getToken ( ) ,
120126 } ) ) ;
121127 }
122128
123129 public get actions ( ) : Actions {
124130 return ( this . _actions ??= new Actions ( {
125131 ...this . _options ,
126- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
132+ token : async ( ) => await this . _tokenProvider . getToken ( ) ,
127133 } ) ) ;
128134 }
129135
130136 public get triggers ( ) : Triggers {
131137 return ( this . _triggers ??= new Triggers ( {
132138 ...this . _options ,
133- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
139+ token : async ( ) => await this . _tokenProvider . getToken ( ) ,
134140 } ) ) ;
135141 }
136142
137143 public get deployedTriggers ( ) : DeployedTriggers {
138144 return ( this . _deployedTriggers ??= new DeployedTriggers ( {
139145 ...this . _options ,
140- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
146+ token : async ( ) => await this . _tokenProvider . getToken ( ) ,
141147 } ) ) ;
142148 }
143149
144- public get projects ( ) : Projects {
145- return ( this . _projects ??= new Projects ( {
150+ public get fileStash ( ) : FileStash {
151+ return ( this . _fileStash ??= new FileStash ( {
146152 ...this . _options ,
147- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
153+ token : async ( ) => await this . _tokenProvider . getToken ( ) ,
148154 } ) ) ;
149155 }
150156
151- public get fileStash ( ) : FileStash {
152- return ( this . _fileStash ??= new FileStash ( {
157+ public get projects ( ) : Projects {
158+ return ( this . _projects ??= new Projects ( {
153159 ...this . _options ,
154- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
160+ token : async ( ) => await this . _tokenProvider . getToken ( ) ,
155161 } ) ) ;
156162 }
157163
158164 public get proxy ( ) : Proxy {
159165 return ( this . _proxy ??= new Proxy ( {
160166 ...this . _options ,
161- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
167+ token : async ( ) => await this . _tokenProvider . getToken ( ) ,
162168 } ) ) ;
163169 }
164170
165171 public get tokens ( ) : Tokens {
166172 return ( this . _tokens ??= new Tokens ( {
167173 ...this . _options ,
168- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
174+ token : async ( ) => await this . _tokenProvider . getToken ( ) ,
169175 } ) ) ;
170176 }
171177
172178 public get oauthTokens ( ) : OauthTokens {
173179 return ( this . _oauthTokens ??= new OauthTokens ( {
174180 ...this . _options ,
175- token : async ( ) => await this . _oauthTokenProvider . getToken ( ) ,
181+ token : async ( ) => await this . _tokenProvider . getToken ( ) ,
176182 } ) ) ;
177183 }
178184}
0 commit comments