Skip to content

Commit 93760e1

Browse files
SDK regeneration (#125)
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
1 parent c51b6a7 commit 93760e1

File tree

173 files changed

+5643
-547
lines changed

Some content is hidden

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

173 files changed

+5643
-547
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,21 @@ jobs:
1616
- name: Compile
1717
run: yarn && yarn build
1818

19+
test:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout repo
24+
uses: actions/checkout@v3
25+
26+
- name: Set up node
27+
uses: actions/setup-node@v3
28+
29+
- name: Compile
30+
run: yarn && yarn test
31+
1932
publish:
20-
needs: [ compile ]
33+
needs: [ compile, test ]
2134
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
2235
runs-on: ubuntu-latest
2336

jest.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} */
2+
module.exports = {
3+
preset: "ts-jest",
4+
testEnvironment: "node",
5+
};

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"name": "webflow-api",
3-
"version": "2.0.0",
3+
"version": "v2.1.0",
44
"private": false,
55
"repository": "https://github.com/webflow/js-webflow-api",
66
"main": "./index.js",
77
"types": "./index.d.ts",
88
"scripts": {
99
"format": "prettier --write 'src/**/*.ts'",
1010
"build": "tsc",
11-
"prepack": "cp -rv dist/. ."
11+
"prepack": "cp -rv dist/. .",
12+
"test": "jest"
1213
},
1314
"dependencies": {
1415
"url-join": "4.0.1",
@@ -21,8 +22,11 @@
2122
"@types/url-join": "4.0.1",
2223
"@types/qs": "6.9.8",
2324
"@types/node-fetch": "2.6.9",
25+
"jest": "^29.7.0",
26+
"@types/jest": "^29.5.5",
27+
"ts-jest": "^29.1.1",
2428
"@types/node": "17.0.33",
2529
"prettier": "2.7.1",
2630
"typescript": "4.6.4"
2731
}
28-
}
32+
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,15 @@ export class AccessGroups {
3434
* @throws {@link Webflow.InternalServerError}
3535
*
3636
* @example
37-
* await webflow.accessGroups.list("string", {
38-
* sort: Webflow.AccessGroupsListRequestSort.CreatedOnAscending
39-
* })
37+
* await webflow.accessGroups.list("site_id", {})
4038
*/
4139
public async list(
4240
siteId: string,
4341
request: Webflow.AccessGroupsListRequest = {},
4442
requestOptions?: AccessGroups.RequestOptions
4543
): Promise<Webflow.AccessGroupList> {
4644
const { offset, limit, sort } = request;
47-
const _queryParams: Record<string, string | string[]> = {};
45+
const _queryParams: Record<string, string | string[] | object | object[]> = {};
4846
if (offset != null) {
4947
_queryParams["offset"] = offset.toString();
5048
}
@@ -60,14 +58,16 @@ export class AccessGroups {
6058
const _response = await core.fetcher({
6159
url: urlJoin(
6260
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
63-
`v2/sites/${siteId}/accessgroups`
61+
`sites/${siteId}/accessgroups`
6462
),
6563
method: "GET",
6664
headers: {
6765
Authorization: await this._getAuthorizationHeader(),
6866
"X-Fern-Language": "JavaScript",
6967
"X-Fern-SDK-Name": "webflow-api",
70-
"X-Fern-SDK-Version": "2.0.0-beta",
68+
"X-Fern-SDK-Version": "v2.1.0",
69+
"X-Fern-Runtime": core.RUNTIME.type,
70+
"X-Fern-Runtime-Version": core.RUNTIME.version,
7171
},
7272
contentType: "application/json",
7373
queryParameters: _queryParams,

src/api/resources/accessGroups/client/requests/AccessGroupsListRequest.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import * as Webflow from "../../../..";
66

77
/**
88
* @example
9-
* {
10-
* sort: Webflow.AccessGroupsListRequestSort.CreatedOnAscending
11-
* }
9+
* {}
1210
*/
1311
export interface AccessGroupsListRequest {
1412
/**

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

Lines changed: 117 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,22 @@ export class Assets {
3333
* @throws {@link Webflow.InternalServerError}
3434
*
3535
* @example
36-
* await webflow.assets.list("string")
36+
* await webflow.assets.list("site_id")
3737
*/
3838
public async list(siteId: string, requestOptions?: Assets.RequestOptions): Promise<Webflow.Asset[]> {
3939
const _response = await core.fetcher({
4040
url: urlJoin(
4141
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
42-
`v2/sites/${siteId}/assets`
42+
`sites/${siteId}/assets`
4343
),
4444
method: "GET",
4545
headers: {
4646
Authorization: await this._getAuthorizationHeader(),
4747
"X-Fern-Language": "JavaScript",
4848
"X-Fern-SDK-Name": "webflow-api",
49-
"X-Fern-SDK-Version": "2.0.0-beta",
49+
"X-Fern-SDK-Version": "v2.1.0",
50+
"X-Fern-Runtime": core.RUNTIME.type,
51+
"X-Fern-Runtime-Version": core.RUNTIME.version,
5052
},
5153
contentType: "application/json",
5254
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -106,7 +108,7 @@ export class Assets {
106108
* @throws {@link Webflow.InternalServerError}
107109
*
108110
* @example
109-
* await webflow.assets.create("string", {
111+
* await webflow.assets.create("site_id", {
110112
* fileName: "file.png",
111113
* fileHash: "3c7d87c9575702bc3b1e991f4d3c638e",
112114
* parentFolder: "6436b1ce5281cace05b65aea"
@@ -120,14 +122,16 @@ export class Assets {
120122
const _response = await core.fetcher({
121123
url: urlJoin(
122124
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
123-
`v2/sites/${siteId}/assets`
125+
`sites/${siteId}/assets`
124126
),
125127
method: "POST",
126128
headers: {
127129
Authorization: await this._getAuthorizationHeader(),
128130
"X-Fern-Language": "JavaScript",
129131
"X-Fern-SDK-Name": "webflow-api",
130-
"X-Fern-SDK-Version": "2.0.0-beta",
132+
"X-Fern-SDK-Version": "v2.1.0",
133+
"X-Fern-Runtime": core.RUNTIME.type,
134+
"X-Fern-Runtime-Version": core.RUNTIME.version,
131135
},
132136
contentType: "application/json",
133137
body: await serializers.AssetsCreateRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -188,20 +192,22 @@ export class Assets {
188192
* @throws {@link Webflow.InternalServerError}
189193
*
190194
* @example
191-
* await webflow.assets.get("string")
195+
* await webflow.assets.get("asset_id")
192196
*/
193197
public async get(assetId: string, requestOptions?: Assets.RequestOptions): Promise<Webflow.Asset> {
194198
const _response = await core.fetcher({
195199
url: urlJoin(
196200
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
197-
`v2/assets/${assetId}`
201+
`assets/${assetId}`
198202
),
199203
method: "GET",
200204
headers: {
201205
Authorization: await this._getAuthorizationHeader(),
202206
"X-Fern-Language": "JavaScript",
203207
"X-Fern-SDK-Name": "webflow-api",
204-
"X-Fern-SDK-Version": "2.0.0-beta",
208+
"X-Fern-SDK-Version": "v2.1.0",
209+
"X-Fern-Runtime": core.RUNTIME.type,
210+
"X-Fern-Runtime-Version": core.RUNTIME.version,
205211
},
206212
contentType: "application/json",
207213
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -261,20 +267,22 @@ export class Assets {
261267
* @throws {@link Webflow.InternalServerError}
262268
*
263269
* @example
264-
* await webflow.assets.delete("string")
270+
* await webflow.assets.delete("asset_id")
265271
*/
266272
public async delete(assetId: string, requestOptions?: Assets.RequestOptions): Promise<void> {
267273
const _response = await core.fetcher({
268274
url: urlJoin(
269275
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
270-
`v2/assets/${assetId}`
276+
`assets/${assetId}`
271277
),
272278
method: "DELETE",
273279
headers: {
274280
Authorization: await this._getAuthorizationHeader(),
275281
"X-Fern-Language": "JavaScript",
276282
"X-Fern-SDK-Name": "webflow-api",
277-
"X-Fern-SDK-Version": "2.0.0-beta",
283+
"X-Fern-SDK-Version": "v2.1.0",
284+
"X-Fern-Runtime": core.RUNTIME.type,
285+
"X-Fern-Runtime-Version": core.RUNTIME.version,
278286
},
279287
contentType: "application/json",
280288
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -319,6 +327,88 @@ export class Assets {
319327
}
320328
}
321329

330+
/**
331+
* Update an Asset </br></br> Required scope | `assets:write`
332+
* @throws {@link Webflow.BadRequestError}
333+
* @throws {@link Webflow.UnauthorizedError}
334+
* @throws {@link Webflow.NotFoundError}
335+
* @throws {@link Webflow.TooManyRequestsError}
336+
* @throws {@link Webflow.InternalServerError}
337+
*
338+
* @example
339+
* await webflow.assets.update("asset_id", {
340+
* displayName: "file.png"
341+
* })
342+
*/
343+
public async update(
344+
assetId: string,
345+
request: Webflow.AssetsUpdateRequest,
346+
requestOptions?: Assets.RequestOptions
347+
): Promise<Webflow.Asset> {
348+
const _response = await core.fetcher({
349+
url: urlJoin(
350+
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
351+
`assets/${assetId}`
352+
),
353+
method: "PATCH",
354+
headers: {
355+
Authorization: await this._getAuthorizationHeader(),
356+
"X-Fern-Language": "JavaScript",
357+
"X-Fern-SDK-Name": "webflow-api",
358+
"X-Fern-SDK-Version": "v2.1.0",
359+
"X-Fern-Runtime": core.RUNTIME.type,
360+
"X-Fern-Runtime-Version": core.RUNTIME.version,
361+
},
362+
contentType: "application/json",
363+
body: await serializers.AssetsUpdateRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
364+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
365+
maxRetries: requestOptions?.maxRetries,
366+
});
367+
if (_response.ok) {
368+
return await serializers.Asset.parseOrThrow(_response.body, {
369+
unrecognizedObjectKeys: "passthrough",
370+
allowUnrecognizedUnionMembers: true,
371+
allowUnrecognizedEnumValues: true,
372+
skipValidation: true,
373+
breadcrumbsPrefix: ["response"],
374+
});
375+
}
376+
377+
if (_response.error.reason === "status-code") {
378+
switch (_response.error.statusCode) {
379+
case 400:
380+
throw new Webflow.BadRequestError(_response.error.body);
381+
case 401:
382+
throw new Webflow.UnauthorizedError(_response.error.body);
383+
case 404:
384+
throw new Webflow.NotFoundError(_response.error.body);
385+
case 429:
386+
throw new Webflow.TooManyRequestsError(_response.error.body);
387+
case 500:
388+
throw new Webflow.InternalServerError(_response.error.body);
389+
default:
390+
throw new errors.WebflowError({
391+
statusCode: _response.error.statusCode,
392+
body: _response.error.body,
393+
});
394+
}
395+
}
396+
397+
switch (_response.error.reason) {
398+
case "non-json":
399+
throw new errors.WebflowError({
400+
statusCode: _response.error.statusCode,
401+
body: _response.error.rawBody,
402+
});
403+
case "timeout":
404+
throw new errors.WebflowTimeoutError();
405+
case "unknown":
406+
throw new errors.WebflowError({
407+
message: _response.error.errorMessage,
408+
});
409+
}
410+
}
411+
322412
/**
323413
* List Asset Folders within a given site <br><br> Required scope | `assets:read`
324414
* @throws {@link Webflow.BadRequestError}
@@ -328,20 +418,22 @@ export class Assets {
328418
* @throws {@link Webflow.InternalServerError}
329419
*
330420
* @example
331-
* await webflow.assets.listFolders("string")
421+
* await webflow.assets.listFolders("site_id")
332422
*/
333423
public async listFolders(siteId: string, requestOptions?: Assets.RequestOptions): Promise<Webflow.AssetFolderList> {
334424
const _response = await core.fetcher({
335425
url: urlJoin(
336426
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
337-
`v2/sites/${siteId}/asset_folders`
427+
`sites/${siteId}/asset_folders`
338428
),
339429
method: "GET",
340430
headers: {
341431
Authorization: await this._getAuthorizationHeader(),
342432
"X-Fern-Language": "JavaScript",
343433
"X-Fern-SDK-Name": "webflow-api",
344-
"X-Fern-SDK-Version": "2.0.0-beta",
434+
"X-Fern-SDK-Version": "v2.1.0",
435+
"X-Fern-Runtime": core.RUNTIME.type,
436+
"X-Fern-Runtime-Version": core.RUNTIME.version,
345437
},
346438
contentType: "application/json",
347439
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -401,7 +493,7 @@ export class Assets {
401493
* @throws {@link Webflow.InternalServerError}
402494
*
403495
* @example
404-
* await webflow.assets.createFolder("string", {
496+
* await webflow.assets.createFolder("site_id", {
405497
* displayName: "my asset folder",
406498
* parentFolder: "6390c49774a71f99f21a08eb"
407499
* })
@@ -414,14 +506,16 @@ export class Assets {
414506
const _response = await core.fetcher({
415507
url: urlJoin(
416508
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
417-
`v2/sites/${siteId}/asset_folders`
509+
`sites/${siteId}/asset_folders`
418510
),
419511
method: "POST",
420512
headers: {
421513
Authorization: await this._getAuthorizationHeader(),
422514
"X-Fern-Language": "JavaScript",
423515
"X-Fern-SDK-Name": "webflow-api",
424-
"X-Fern-SDK-Version": "2.0.0-beta",
516+
"X-Fern-SDK-Version": "v2.1.0",
517+
"X-Fern-Runtime": core.RUNTIME.type,
518+
"X-Fern-Runtime-Version": core.RUNTIME.version,
425519
},
426520
contentType: "application/json",
427521
body: await serializers.AssetsCreateFolderRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -482,7 +576,7 @@ export class Assets {
482576
* @throws {@link Webflow.InternalServerError}
483577
*
484578
* @example
485-
* await webflow.assets.getFolder("string")
579+
* await webflow.assets.getFolder("asset_folder_id")
486580
*/
487581
public async getFolder(
488582
assetFolderId: string,
@@ -491,14 +585,16 @@ export class Assets {
491585
const _response = await core.fetcher({
492586
url: urlJoin(
493587
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
494-
`v2/asset_folders/${assetFolderId}`
588+
`asset_folders/${assetFolderId}`
495589
),
496590
method: "GET",
497591
headers: {
498592
Authorization: await this._getAuthorizationHeader(),
499593
"X-Fern-Language": "JavaScript",
500594
"X-Fern-SDK-Name": "webflow-api",
501-
"X-Fern-SDK-Version": "2.0.0-beta",
595+
"X-Fern-SDK-Version": "v2.1.0",
596+
"X-Fern-Runtime": core.RUNTIME.type,
597+
"X-Fern-Runtime-Version": core.RUNTIME.version,
502598
},
503599
contentType: "application/json",
504600
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,

0 commit comments

Comments
 (0)