Skip to content

Commit

Permalink
SDK regeneration (#125)
Browse files Browse the repository at this point in the history
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
  • Loading branch information
fern-api[bot] authored Mar 4, 2024
1 parent c51b6a7 commit 93760e1
Show file tree
Hide file tree
Showing 173 changed files with 5,643 additions and 547 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,21 @@ jobs:
- name: Compile
run: yarn && yarn build

test:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up node
uses: actions/setup-node@v3

- name: Compile
run: yarn && yarn test

publish:
needs: [ compile ]
needs: [ compile, test ]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest

Expand Down
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
};
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "webflow-api",
"version": "2.0.0",
"version": "v2.1.0",
"private": false,
"repository": "https://github.com/webflow/js-webflow-api",
"main": "./index.js",
"types": "./index.d.ts",
"scripts": {
"format": "prettier --write 'src/**/*.ts'",
"build": "tsc",
"prepack": "cp -rv dist/. ."
"prepack": "cp -rv dist/. .",
"test": "jest"
},
"dependencies": {
"url-join": "4.0.1",
Expand All @@ -21,8 +22,11 @@
"@types/url-join": "4.0.1",
"@types/qs": "6.9.8",
"@types/node-fetch": "2.6.9",
"jest": "^29.7.0",
"@types/jest": "^29.5.5",
"ts-jest": "^29.1.1",
"@types/node": "17.0.33",
"prettier": "2.7.1",
"typescript": "4.6.4"
}
}
}
12 changes: 6 additions & 6 deletions src/api/resources/accessGroups/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,15 @@ export class AccessGroups {
* @throws {@link Webflow.InternalServerError}
*
* @example
* await webflow.accessGroups.list("string", {
* sort: Webflow.AccessGroupsListRequestSort.CreatedOnAscending
* })
* await webflow.accessGroups.list("site_id", {})
*/
public async list(
siteId: string,
request: Webflow.AccessGroupsListRequest = {},
requestOptions?: AccessGroups.RequestOptions
): Promise<Webflow.AccessGroupList> {
const { offset, limit, sort } = request;
const _queryParams: Record<string, string | string[]> = {};
const _queryParams: Record<string, string | string[] | object | object[]> = {};
if (offset != null) {
_queryParams["offset"] = offset.toString();
}
Expand All @@ -60,14 +58,16 @@ export class AccessGroups {
const _response = await core.fetcher({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
`v2/sites/${siteId}/accessgroups`
`sites/${siteId}/accessgroups`
),
method: "GET",
headers: {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "webflow-api",
"X-Fern-SDK-Version": "2.0.0-beta",
"X-Fern-SDK-Version": "v2.1.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
queryParameters: _queryParams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import * as Webflow from "../../../..";

/**
* @example
* {
* sort: Webflow.AccessGroupsListRequestSort.CreatedOnAscending
* }
* {}
*/
export interface AccessGroupsListRequest {
/**
Expand Down
138 changes: 117 additions & 21 deletions src/api/resources/assets/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,22 @@ export class Assets {
* @throws {@link Webflow.InternalServerError}
*
* @example
* await webflow.assets.list("string")
* await webflow.assets.list("site_id")
*/
public async list(siteId: string, requestOptions?: Assets.RequestOptions): Promise<Webflow.Asset[]> {
const _response = await core.fetcher({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
`v2/sites/${siteId}/assets`
`sites/${siteId}/assets`
),
method: "GET",
headers: {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "webflow-api",
"X-Fern-SDK-Version": "2.0.0-beta",
"X-Fern-SDK-Version": "v2.1.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -106,7 +108,7 @@ export class Assets {
* @throws {@link Webflow.InternalServerError}
*
* @example
* await webflow.assets.create("string", {
* await webflow.assets.create("site_id", {
* fileName: "file.png",
* fileHash: "3c7d87c9575702bc3b1e991f4d3c638e",
* parentFolder: "6436b1ce5281cace05b65aea"
Expand All @@ -120,14 +122,16 @@ export class Assets {
const _response = await core.fetcher({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
`v2/sites/${siteId}/assets`
`sites/${siteId}/assets`
),
method: "POST",
headers: {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "webflow-api",
"X-Fern-SDK-Version": "2.0.0-beta",
"X-Fern-SDK-Version": "v2.1.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
body: await serializers.AssetsCreateRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
Expand Down Expand Up @@ -188,20 +192,22 @@ export class Assets {
* @throws {@link Webflow.InternalServerError}
*
* @example
* await webflow.assets.get("string")
* await webflow.assets.get("asset_id")
*/
public async get(assetId: string, requestOptions?: Assets.RequestOptions): Promise<Webflow.Asset> {
const _response = await core.fetcher({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
`v2/assets/${assetId}`
`assets/${assetId}`
),
method: "GET",
headers: {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "webflow-api",
"X-Fern-SDK-Version": "2.0.0-beta",
"X-Fern-SDK-Version": "v2.1.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -261,20 +267,22 @@ export class Assets {
* @throws {@link Webflow.InternalServerError}
*
* @example
* await webflow.assets.delete("string")
* await webflow.assets.delete("asset_id")
*/
public async delete(assetId: string, requestOptions?: Assets.RequestOptions): Promise<void> {
const _response = await core.fetcher({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
`v2/assets/${assetId}`
`assets/${assetId}`
),
method: "DELETE",
headers: {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "webflow-api",
"X-Fern-SDK-Version": "2.0.0-beta",
"X-Fern-SDK-Version": "v2.1.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -319,6 +327,88 @@ export class Assets {
}
}

/**
* Update an Asset </br></br> Required scope | `assets:write`
* @throws {@link Webflow.BadRequestError}
* @throws {@link Webflow.UnauthorizedError}
* @throws {@link Webflow.NotFoundError}
* @throws {@link Webflow.TooManyRequestsError}
* @throws {@link Webflow.InternalServerError}
*
* @example
* await webflow.assets.update("asset_id", {
* displayName: "file.png"
* })
*/
public async update(
assetId: string,
request: Webflow.AssetsUpdateRequest,
requestOptions?: Assets.RequestOptions
): Promise<Webflow.Asset> {
const _response = await core.fetcher({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
`assets/${assetId}`
),
method: "PATCH",
headers: {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "webflow-api",
"X-Fern-SDK-Version": "v2.1.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
body: await serializers.AssetsUpdateRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
});
if (_response.ok) {
return await serializers.Asset.parseOrThrow(_response.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
skipValidation: true,
breadcrumbsPrefix: ["response"],
});
}

if (_response.error.reason === "status-code") {
switch (_response.error.statusCode) {
case 400:
throw new Webflow.BadRequestError(_response.error.body);
case 401:
throw new Webflow.UnauthorizedError(_response.error.body);
case 404:
throw new Webflow.NotFoundError(_response.error.body);
case 429:
throw new Webflow.TooManyRequestsError(_response.error.body);
case 500:
throw new Webflow.InternalServerError(_response.error.body);
default:
throw new errors.WebflowError({
statusCode: _response.error.statusCode,
body: _response.error.body,
});
}
}

switch (_response.error.reason) {
case "non-json":
throw new errors.WebflowError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
});
case "timeout":
throw new errors.WebflowTimeoutError();
case "unknown":
throw new errors.WebflowError({
message: _response.error.errorMessage,
});
}
}

/**
* List Asset Folders within a given site <br><br> Required scope | `assets:read`
* @throws {@link Webflow.BadRequestError}
Expand All @@ -328,20 +418,22 @@ export class Assets {
* @throws {@link Webflow.InternalServerError}
*
* @example
* await webflow.assets.listFolders("string")
* await webflow.assets.listFolders("site_id")
*/
public async listFolders(siteId: string, requestOptions?: Assets.RequestOptions): Promise<Webflow.AssetFolderList> {
const _response = await core.fetcher({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
`v2/sites/${siteId}/asset_folders`
`sites/${siteId}/asset_folders`
),
method: "GET",
headers: {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "webflow-api",
"X-Fern-SDK-Version": "2.0.0-beta",
"X-Fern-SDK-Version": "v2.1.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -401,7 +493,7 @@ export class Assets {
* @throws {@link Webflow.InternalServerError}
*
* @example
* await webflow.assets.createFolder("string", {
* await webflow.assets.createFolder("site_id", {
* displayName: "my asset folder",
* parentFolder: "6390c49774a71f99f21a08eb"
* })
Expand All @@ -414,14 +506,16 @@ export class Assets {
const _response = await core.fetcher({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
`v2/sites/${siteId}/asset_folders`
`sites/${siteId}/asset_folders`
),
method: "POST",
headers: {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "webflow-api",
"X-Fern-SDK-Version": "2.0.0-beta",
"X-Fern-SDK-Version": "v2.1.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
body: await serializers.AssetsCreateFolderRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
Expand Down Expand Up @@ -482,7 +576,7 @@ export class Assets {
* @throws {@link Webflow.InternalServerError}
*
* @example
* await webflow.assets.getFolder("string")
* await webflow.assets.getFolder("asset_folder_id")
*/
public async getFolder(
assetFolderId: string,
Expand All @@ -491,14 +585,16 @@ export class Assets {
const _response = await core.fetcher({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.Default,
`v2/asset_folders/${assetFolderId}`
`asset_folders/${assetFolderId}`
),
method: "GET",
headers: {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "webflow-api",
"X-Fern-SDK-Version": "2.0.0-beta",
"X-Fern-SDK-Version": "v2.1.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down
Loading

0 comments on commit 93760e1

Please sign in to comment.