Skip to content

Commit 0736dbc

Browse files
Switch to camelCase (#82)
Add a serialization layer between the client interfaces and the API, so that the former can have camelCase arguments and return types while being compatible with the API snake_case convention. --------- Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Co-authored-by: Jay Vercellone <[email protected]>
1 parent 893790d commit 0736dbc

File tree

262 files changed

+6058
-430
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

262 files changed

+6058
-430
lines changed

.fernignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
.gitignore
88
.prettierignore
99
.prettierrc.yml
10+
package.json
1011

1112
# Our own license
1213
LICENSE

MIGRATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ incrementally without breaking your existing codebase. To do this, you can
835835
install the new SDK with an alias:
836836

837837
```bash
838-
npm install @pipedream/sdk-v2@npm:@pipedream/sdk@^2.0.0-rc.6 --save
838+
npm install @pipedream/sdk-v2@npm:@pipedream/sdk@^2.0.0-rc.7 --save
839839
```
840840

841841
Then, in your code, you can import the new SDK with the alias:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const client = new PipedreamClient({
3535
});
3636
await client.actions.run({
3737
id: "id",
38-
external_user_id: "external_user_id",
38+
externalUserId: "external_user_id",
3939
});
4040
```
4141

package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/sdk",
3-
"version": "2.0.0-rc.6",
3+
"version": "2.0.0-rc.7",
44
"private": false,
55
"repository": "github:PipedreamHQ/pipedream-sdk-typescript",
66
"type": "commonjs",
@@ -30,6 +30,18 @@
3030
"import": "./dist/esm/browser/index.mjs",
3131
"default": "./dist/esm/browser/index.mjs"
3232
},
33+
"./serialization": {
34+
"types": "./dist/cjs/serialization/index.d.ts",
35+
"import": {
36+
"types": "./dist/esm/serialization/index.d.mts",
37+
"default": "./dist/esm/serialization/index.mjs"
38+
},
39+
"require": {
40+
"types": "./dist/cjs/serialization/index.d.ts",
41+
"default": "./dist/cjs/serialization/index.js"
42+
},
43+
"default": "./dist/cjs/serialization/index.js"
44+
},
3345
"./server": {
3446
"types": "./dist/cjs/index.d.ts",
3547
"import": {

src/Client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ export class PipedreamClient {
7373
"x-pd-environment": _options?.projectEnvironment,
7474
"X-Fern-Language": "JavaScript",
7575
"X-Fern-SDK-Name": "@pipedream/sdk",
76-
"X-Fern-SDK-Version": "2.0.0-rc.6",
77-
"User-Agent": "@pipedream/sdk/2.0.0-rc.6",
76+
"X-Fern-SDK-Version": "2.0.0-rc.7",
77+
"User-Agent": "@pipedream/sdk/2.0.0-rc.7",
7878
"X-Fern-Runtime": core.RUNTIME.type,
7979
"X-Fern-Runtime-Version": core.RUNTIME.version,
8080
},

src/api/resources/accounts/client/Client.ts

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as environments from "../../../../environments.js";
66
import * as core from "../../../../core/index.js";
77
import * as Pipedream from "../../../index.js";
88
import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
9+
import * as serializers from "../../../../serialization/index.js";
910
import * as errors from "../../../../errors/index.js";
1011

1112
export declare namespace Accounts {
@@ -59,15 +60,7 @@ export class Accounts {
5960
async (
6061
request: Pipedream.AccountsListRequest,
6162
): Promise<core.WithRawResponse<Pipedream.ListAccountsResponse>> => {
62-
const {
63-
app_id: appId,
64-
external_user_id: externalUserId,
65-
oauth_app_id: oauthAppId,
66-
after,
67-
before,
68-
limit,
69-
include_credentials: includeCredentials,
70-
} = request;
63+
const { appId, externalUserId, oauthAppId, after, before, limit, includeCredentials } = request;
7164
const _queryParams: Record<string, string | string[] | object | object[] | null> = {};
7265
if (appId != null) {
7366
_queryParams["app_id"] = appId;
@@ -114,7 +107,13 @@ export class Accounts {
114107
});
115108
if (_response.ok) {
116109
return {
117-
data: _response.body as Pipedream.ListAccountsResponse,
110+
data: serializers.ListAccountsResponse.parseOrThrow(_response.body, {
111+
unrecognizedObjectKeys: "passthrough",
112+
allowUnrecognizedUnionMembers: true,
113+
allowUnrecognizedEnumValues: true,
114+
skipValidation: true,
115+
breadcrumbsPrefix: ["response"],
116+
}),
118117
rawResponse: _response.rawResponse,
119118
};
120119
}
@@ -149,11 +148,11 @@ export class Accounts {
149148
response: dataWithRawResponse.data,
150149
rawResponse: dataWithRawResponse.rawResponse,
151150
hasNextPage: (response) =>
152-
response?.page_info?.end_cursor != null &&
153-
!(typeof response?.page_info?.end_cursor === "string" && response?.page_info?.end_cursor === ""),
151+
response?.pageInfo?.endCursor != null &&
152+
!(typeof response?.pageInfo?.endCursor === "string" && response?.pageInfo?.endCursor === ""),
154153
getItems: (response) => response?.data ?? [],
155154
loadPage: (response) => {
156-
return list(core.setObjectProperty(request, "after", response?.page_info?.end_cursor));
155+
return list(core.setObjectProperty(request, "after", response?.pageInfo?.endCursor));
157156
},
158157
});
159158
}
@@ -164,9 +163,9 @@ export class Accounts {
164163
*
165164
* @example
166165
* await client.accounts.create({
167-
* app_slug: "app_slug",
168-
* cfmap_json: "cfmap_json",
169-
* connect_token: "connect_token"
166+
* appSlug: "app_slug",
167+
* cfmapJson: "cfmap_json",
168+
* connectToken: "connect_token"
170169
* })
171170
*/
172171
public create(
@@ -180,7 +179,7 @@ export class Accounts {
180179
request: Pipedream.CreateAccountOpts,
181180
requestOptions?: Accounts.RequestOptions,
182181
): Promise<core.WithRawResponse<Pipedream.Account>> {
183-
const { app_id: appId, external_user_id: externalUserId, oauth_app_id: oauthAppId, ..._body } = request;
182+
const { appId, externalUserId, oauthAppId, ..._body } = request;
184183
const _queryParams: Record<string, string | string[] | object | object[] | null> = {};
185184
if (appId != null) {
186185
_queryParams["app_id"] = appId;
@@ -213,13 +212,25 @@ export class Accounts {
213212
contentType: "application/json",
214213
queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
215214
requestType: "json",
216-
body: _body,
215+
body: serializers.CreateAccountOpts.jsonOrThrow(_body, {
216+
unrecognizedObjectKeys: "strip",
217+
omitUndefined: true,
218+
}),
217219
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
218220
maxRetries: requestOptions?.maxRetries,
219221
abortSignal: requestOptions?.abortSignal,
220222
});
221223
if (_response.ok) {
222-
return { data: _response.body as Pipedream.Account, rawResponse: _response.rawResponse };
224+
return {
225+
data: serializers.Account.parseOrThrow(_response.body, {
226+
unrecognizedObjectKeys: "passthrough",
227+
allowUnrecognizedUnionMembers: true,
228+
allowUnrecognizedEnumValues: true,
229+
skipValidation: true,
230+
breadcrumbsPrefix: ["response"],
231+
}),
232+
rawResponse: _response.rawResponse,
233+
};
223234
}
224235

225236
if (_response.error.reason === "status-code") {
@@ -270,7 +281,7 @@ export class Accounts {
270281
request: Pipedream.AccountsRetrieveRequest = {},
271282
requestOptions?: Accounts.RequestOptions,
272283
): Promise<core.WithRawResponse<Pipedream.Account>> {
273-
const { include_credentials: includeCredentials } = request;
284+
const { includeCredentials } = request;
274285
const _queryParams: Record<string, string | string[] | object | object[] | null> = {};
275286
if (includeCredentials != null) {
276287
_queryParams["include_credentials"] = includeCredentials.toString();
@@ -298,7 +309,16 @@ export class Accounts {
298309
abortSignal: requestOptions?.abortSignal,
299310
});
300311
if (_response.ok) {
301-
return { data: _response.body as Pipedream.Account, rawResponse: _response.rawResponse };
312+
return {
313+
data: serializers.Account.parseOrThrow(_response.body, {
314+
unrecognizedObjectKeys: "passthrough",
315+
allowUnrecognizedUnionMembers: true,
316+
allowUnrecognizedEnumValues: true,
317+
skipValidation: true,
318+
breadcrumbsPrefix: ["response"],
319+
}),
320+
rawResponse: _response.rawResponse,
321+
};
302322
}
303323

304324
if (_response.error.reason === "status-code") {

src/api/resources/accounts/client/requests/AccountsListRequest.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ export interface AccountsListRequest {
1010
/**
1111
* The app slug or ID to filter accounts by.
1212
*/
13-
app_id?: string;
14-
external_user_id?: string;
13+
appId?: string;
14+
externalUserId?: string;
1515
/**
1616
* The OAuth app ID to filter by, if applicable
1717
*/
18-
oauth_app_id?: string;
18+
oauthAppId?: string;
1919
/**
2020
* The cursor to start from for pagination
2121
*/
@@ -31,5 +31,5 @@ export interface AccountsListRequest {
3131
/**
3232
* Whether to retrieve the account's credentials or not
3333
*/
34-
include_credentials?: boolean;
34+
includeCredentials?: boolean;
3535
}

src/api/resources/accounts/client/requests/AccountsRetrieveRequest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ export interface AccountsRetrieveRequest {
1010
/**
1111
* Whether to retrieve the account's credentials or not
1212
*/
13-
include_credentials?: boolean;
13+
includeCredentials?: boolean;
1414
}

src/api/resources/accounts/client/requests/CreateAccountOpts.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@
55
/**
66
* @example
77
* {
8-
* app_slug: "app_slug",
9-
* cfmap_json: "cfmap_json",
10-
* connect_token: "connect_token"
8+
* appSlug: "app_slug",
9+
* cfmapJson: "cfmap_json",
10+
* connectToken: "connect_token"
1111
* }
1212
*/
1313
export interface CreateAccountOpts {
1414
/**
1515
* The app slug or ID to filter accounts by.
1616
*/
17-
app_id?: string;
18-
external_user_id?: string;
17+
appId?: string;
18+
externalUserId?: string;
1919
/**
2020
* The OAuth app ID to filter by, if applicable
2121
*/
22-
oauth_app_id?: string;
22+
oauthAppId?: string;
2323
/** The app slug for the account */
24-
app_slug: string;
24+
appSlug: string;
2525
/** JSON string containing the custom fields mapping */
26-
cfmap_json: string;
26+
cfmapJson: string;
2727
/** The connect token for authentication */
28-
connect_token: string;
28+
connectToken: string;
2929
/** Optional name for the account */
3030
name?: string;
3131
}

0 commit comments

Comments
 (0)