webflow-api 1.0.3 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -5
- package/dist/api/collection.d.ts +51 -0
- package/dist/api/collection.js +35 -0
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.js +33 -0
- package/dist/api/item.d.ts +143 -0
- package/dist/api/item.js +131 -0
- package/dist/api/membership.d.ts +91 -0
- package/dist/api/membership.js +80 -0
- package/dist/api/meta.d.ts +51 -0
- package/dist/api/meta.js +24 -0
- package/dist/api/oauth.d.ts +67 -0
- package/dist/api/oauth.js +65 -0
- package/dist/api/site.d.ts +65 -0
- package/dist/api/site.js +59 -0
- package/dist/api/webhook.d.ts +80 -0
- package/dist/api/webhook.js +67 -0
- package/dist/core/client.d.ts +40 -0
- package/dist/core/client.js +49 -0
- package/dist/core/error.d.ts +19 -0
- package/dist/core/error.js +23 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js +19 -0
- package/dist/core/options.d.ts +8 -0
- package/dist/core/options.js +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -9
- package/dist/webflow.d.ts +366 -0
- package/dist/webflow.js +388 -0
- package/dist/wrapper/collection.d.ts +85 -0
- package/dist/wrapper/collection.js +94 -0
- package/dist/wrapper/index.d.ts +6 -0
- package/dist/wrapper/index.js +22 -0
- package/dist/wrapper/item.d.ts +140 -0
- package/dist/wrapper/item.js +153 -0
- package/dist/wrapper/membership.d.ts +91 -0
- package/dist/wrapper/membership.js +106 -0
- package/dist/wrapper/response.d.ts +16 -0
- package/dist/wrapper/response.js +17 -0
- package/dist/wrapper/site.d.ts +119 -0
- package/dist/wrapper/site.js +136 -0
- package/dist/wrapper/webhook.d.ts +78 -0
- package/dist/wrapper/webhook.js +82 -0
- package/package.json +16 -18
- package/src/api/collection.ts +87 -0
- package/src/api/index.ts +7 -0
- package/src/api/item.ts +231 -0
- package/src/api/membership.ts +125 -0
- package/src/api/meta.ts +61 -0
- package/src/api/oauth.ts +119 -0
- package/src/api/site.ts +86 -0
- package/src/api/webhook.ts +125 -0
- package/src/core/client.ts +76 -0
- package/src/core/error.ts +32 -0
- package/src/core/index.ts +3 -0
- package/src/core/options.ts +9 -0
- package/src/index.ts +3 -0
- package/src/webflow.ts +487 -0
- package/src/wrapper/collection.ts +115 -0
- package/src/wrapper/index.ts +6 -0
- package/src/wrapper/item.ts +218 -0
- package/src/wrapper/membership.ts +138 -0
- package/src/wrapper/response.ts +25 -0
- package/src/wrapper/site.ts +164 -0
- package/src/wrapper/webhook.ts +116 -0
- package/yarn.lock +392 -1515
- package/dist/ResponseWrapper.js +0 -135
- package/dist/Webflow.js +0 -344
- package/dist/WebflowClient.js +0 -115
- package/index.d.ts +0 -430
- package/src/ResponseWrapper.js +0 -103
- package/src/Webflow.js +0 -301
- package/src/WebflowClient.js +0 -98
- package/src/index.js +0 -3
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Client } from "../core";
|
|
2
|
+
/**************************************************************
|
|
3
|
+
* Interfaces
|
|
4
|
+
**************************************************************/
|
|
5
|
+
export interface IAuthorizeUrlParams {
|
|
6
|
+
state?: string;
|
|
7
|
+
scope?: string;
|
|
8
|
+
client_id: string;
|
|
9
|
+
redirect_uri?: string;
|
|
10
|
+
response_type?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface IRevokeTokenParams {
|
|
13
|
+
client_secret: string;
|
|
14
|
+
access_token: string;
|
|
15
|
+
client_id: string;
|
|
16
|
+
}
|
|
17
|
+
export interface IAccessTokenParams {
|
|
18
|
+
code: string;
|
|
19
|
+
client_id: string;
|
|
20
|
+
grant_type?: string;
|
|
21
|
+
client_secret: string;
|
|
22
|
+
redirect_uri?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface IAccessToken {
|
|
25
|
+
token_type: string;
|
|
26
|
+
access_token: string;
|
|
27
|
+
}
|
|
28
|
+
export interface IRevokeToken {
|
|
29
|
+
didRevoke: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**************************************************************
|
|
32
|
+
* Functions
|
|
33
|
+
**************************************************************/
|
|
34
|
+
/**
|
|
35
|
+
* Get the URL to authorize a user
|
|
36
|
+
* @param client The Webflow client
|
|
37
|
+
* @param params The params for the request
|
|
38
|
+
* @param params.client_id The OAuth client ID
|
|
39
|
+
* @param params.scope The scope (optional)
|
|
40
|
+
* @param params.state The state (optional)
|
|
41
|
+
* @param params.redirect_uri The redirect URI (optional)
|
|
42
|
+
* @param params.response_type The response type (default: code)
|
|
43
|
+
* @returns The URL to authorize a user
|
|
44
|
+
*/
|
|
45
|
+
export declare function authorizeUrl(client: Client, { response_type, redirect_uri, client_id, state, scope, }: IAuthorizeUrlParams): string;
|
|
46
|
+
/**
|
|
47
|
+
* Get an access token
|
|
48
|
+
* @param client The Webflow client
|
|
49
|
+
* @param params The params for the request
|
|
50
|
+
* @param params.code The OAuth code
|
|
51
|
+
* @param params.client_id The OAuth client ID
|
|
52
|
+
* @param params.client_secret The OAuth client secret
|
|
53
|
+
* @param params.redirect_uri The redirect URI (optional)
|
|
54
|
+
* @param params.grant_type The grant type (default: "authorization_code")
|
|
55
|
+
* @returns An access token
|
|
56
|
+
*/
|
|
57
|
+
export declare function accessToken(client: Client, { grant_type, client_secret, redirect_uri, client_id, code, }: IAccessTokenParams): Promise<import("axios").AxiosResponse<IAccessToken, any>>;
|
|
58
|
+
/**
|
|
59
|
+
* Revoke an access token
|
|
60
|
+
* @param client The Webflow client
|
|
61
|
+
* @param params The params for the request
|
|
62
|
+
* @param params.client_id The OAuth client ID
|
|
63
|
+
* @param params.client_secret The OAuth client secret
|
|
64
|
+
* @param params.access_token The OAuth access token
|
|
65
|
+
* @returns The result of the revoke
|
|
66
|
+
*/
|
|
67
|
+
export declare function revokeToken(client: Client, { client_secret, access_token, client_id }: IRevokeTokenParams): Promise<import("axios").AxiosResponse<IRevokeToken, any>>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.revokeToken = exports.accessToken = exports.authorizeUrl = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
/**************************************************************
|
|
6
|
+
* Functions
|
|
7
|
+
**************************************************************/
|
|
8
|
+
/**
|
|
9
|
+
* Get the URL to authorize a user
|
|
10
|
+
* @param client The Webflow client
|
|
11
|
+
* @param params The params for the request
|
|
12
|
+
* @param params.client_id The OAuth client ID
|
|
13
|
+
* @param params.scope The scope (optional)
|
|
14
|
+
* @param params.state The state (optional)
|
|
15
|
+
* @param params.redirect_uri The redirect URI (optional)
|
|
16
|
+
* @param params.response_type The response type (default: code)
|
|
17
|
+
* @returns The URL to authorize a user
|
|
18
|
+
*/
|
|
19
|
+
function authorizeUrl(client, { response_type = "code", redirect_uri, client_id, state, scope, }) {
|
|
20
|
+
(0, core_1.requireArgs)({ client_id });
|
|
21
|
+
const params = { response_type, client_id };
|
|
22
|
+
if (redirect_uri)
|
|
23
|
+
params["redirect_uri"] = redirect_uri;
|
|
24
|
+
if (state)
|
|
25
|
+
params["state"] = state;
|
|
26
|
+
if (scope)
|
|
27
|
+
params["scope"] = scope;
|
|
28
|
+
const url = "/oauth/authorize";
|
|
29
|
+
return client.getUri({ url, method: "GET", params });
|
|
30
|
+
}
|
|
31
|
+
exports.authorizeUrl = authorizeUrl;
|
|
32
|
+
/**
|
|
33
|
+
* Get an access token
|
|
34
|
+
* @param client The Webflow client
|
|
35
|
+
* @param params The params for the request
|
|
36
|
+
* @param params.code The OAuth code
|
|
37
|
+
* @param params.client_id The OAuth client ID
|
|
38
|
+
* @param params.client_secret The OAuth client secret
|
|
39
|
+
* @param params.redirect_uri The redirect URI (optional)
|
|
40
|
+
* @param params.grant_type The grant type (default: "authorization_code")
|
|
41
|
+
* @returns An access token
|
|
42
|
+
*/
|
|
43
|
+
function accessToken(client, { grant_type = "authorization_code", client_secret, redirect_uri, client_id, code, }) {
|
|
44
|
+
(0, core_1.requireArgs)({ client_id, client_secret, code });
|
|
45
|
+
const path = "/oauth/access_token";
|
|
46
|
+
const data = { client_secret, redirect_uri, grant_type, client_id, code };
|
|
47
|
+
return client.post(path, data);
|
|
48
|
+
}
|
|
49
|
+
exports.accessToken = accessToken;
|
|
50
|
+
/**
|
|
51
|
+
* Revoke an access token
|
|
52
|
+
* @param client The Webflow client
|
|
53
|
+
* @param params The params for the request
|
|
54
|
+
* @param params.client_id The OAuth client ID
|
|
55
|
+
* @param params.client_secret The OAuth client secret
|
|
56
|
+
* @param params.access_token The OAuth access token
|
|
57
|
+
* @returns The result of the revoke
|
|
58
|
+
*/
|
|
59
|
+
function revokeToken(client, { client_secret, access_token, client_id }) {
|
|
60
|
+
(0, core_1.requireArgs)({ client_id, client_secret, access_token });
|
|
61
|
+
const path = "/oauth/revoke_authorization";
|
|
62
|
+
const data = { client_secret, access_token, client_id };
|
|
63
|
+
return client.post(path, data);
|
|
64
|
+
}
|
|
65
|
+
exports.revokeToken = revokeToken;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Client, QueryString } from "../core";
|
|
2
|
+
/**************************************************************
|
|
3
|
+
* Interfaces
|
|
4
|
+
*************************************************************/
|
|
5
|
+
export interface IDomain {
|
|
6
|
+
_id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ISite {
|
|
10
|
+
lastPublished: string;
|
|
11
|
+
previewUrl: string;
|
|
12
|
+
createdOn: string;
|
|
13
|
+
shortName: string;
|
|
14
|
+
timezone: string;
|
|
15
|
+
database: string;
|
|
16
|
+
name: string;
|
|
17
|
+
_id: string;
|
|
18
|
+
}
|
|
19
|
+
export interface IPublishSite {
|
|
20
|
+
queued: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**************************************************************
|
|
23
|
+
* Functions
|
|
24
|
+
**************************************************************/
|
|
25
|
+
/**
|
|
26
|
+
* Get a list of Sites
|
|
27
|
+
* @param client The Webflow client
|
|
28
|
+
* @param params The query string parameters (optional)
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
export declare function list(client: Client, params?: QueryString): Promise<import("axios").AxiosResponse<ISite[], any>>;
|
|
32
|
+
/**
|
|
33
|
+
* Get a single Site
|
|
34
|
+
* @param client The Webflow client
|
|
35
|
+
* @param params The params for the request
|
|
36
|
+
* @param params.siteId The site ID
|
|
37
|
+
* @param params.params The query string parameters (optional)
|
|
38
|
+
* @returns A single Site
|
|
39
|
+
*/
|
|
40
|
+
export declare function getOne(client: Client, { siteId, params }: {
|
|
41
|
+
siteId: string;
|
|
42
|
+
params?: QueryString;
|
|
43
|
+
}): Promise<import("axios").AxiosResponse<ISite, any>>;
|
|
44
|
+
/**
|
|
45
|
+
* Publish a site
|
|
46
|
+
* @param client The Webflow client
|
|
47
|
+
* @param params The params for the request
|
|
48
|
+
* @param params.siteId The site ID
|
|
49
|
+
* @param params.domains The domains to publish to
|
|
50
|
+
* @returns The publish result
|
|
51
|
+
*/
|
|
52
|
+
export declare function publish(client: Client, { siteId, domains }: {
|
|
53
|
+
siteId: string;
|
|
54
|
+
domains: string[];
|
|
55
|
+
}): Promise<import("axios").AxiosResponse<IPublishSite, any>>;
|
|
56
|
+
/**
|
|
57
|
+
* Get a list of domains for a site
|
|
58
|
+
* @param client The Webflow client
|
|
59
|
+
* @param params The params for the request
|
|
60
|
+
* @param params.siteId The site ID
|
|
61
|
+
* @returns A list of domains
|
|
62
|
+
*/
|
|
63
|
+
export declare function domains(client: Client, { siteId }: {
|
|
64
|
+
siteId: string;
|
|
65
|
+
}): Promise<import("axios").AxiosResponse<IDomain[], any>>;
|
package/dist/api/site.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.domains = exports.publish = exports.getOne = exports.list = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
/**************************************************************
|
|
6
|
+
* Functions
|
|
7
|
+
**************************************************************/
|
|
8
|
+
/**
|
|
9
|
+
* Get a list of Sites
|
|
10
|
+
* @param client The Webflow client
|
|
11
|
+
* @param params The query string parameters (optional)
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
function list(client, params) {
|
|
15
|
+
const path = "/sites";
|
|
16
|
+
return client.get(path, { params });
|
|
17
|
+
}
|
|
18
|
+
exports.list = list;
|
|
19
|
+
/**
|
|
20
|
+
* Get a single Site
|
|
21
|
+
* @param client The Webflow client
|
|
22
|
+
* @param params The params for the request
|
|
23
|
+
* @param params.siteId The site ID
|
|
24
|
+
* @param params.params The query string parameters (optional)
|
|
25
|
+
* @returns A single Site
|
|
26
|
+
*/
|
|
27
|
+
function getOne(client, { siteId, params }) {
|
|
28
|
+
(0, core_1.requireArgs)({ siteId });
|
|
29
|
+
const path = `/sites/${siteId}`;
|
|
30
|
+
return client.get(path, { params });
|
|
31
|
+
}
|
|
32
|
+
exports.getOne = getOne;
|
|
33
|
+
/**
|
|
34
|
+
* Publish a site
|
|
35
|
+
* @param client The Webflow client
|
|
36
|
+
* @param params The params for the request
|
|
37
|
+
* @param params.siteId The site ID
|
|
38
|
+
* @param params.domains The domains to publish to
|
|
39
|
+
* @returns The publish result
|
|
40
|
+
*/
|
|
41
|
+
function publish(client, { siteId, domains }) {
|
|
42
|
+
(0, core_1.requireArgs)({ siteId, domains });
|
|
43
|
+
const path = `/sites/${siteId}/publish`;
|
|
44
|
+
return client.post(path, { domains });
|
|
45
|
+
}
|
|
46
|
+
exports.publish = publish;
|
|
47
|
+
/**
|
|
48
|
+
* Get a list of domains for a site
|
|
49
|
+
* @param client The Webflow client
|
|
50
|
+
* @param params The params for the request
|
|
51
|
+
* @param params.siteId The site ID
|
|
52
|
+
* @returns A list of domains
|
|
53
|
+
*/
|
|
54
|
+
function domains(client, { siteId }) {
|
|
55
|
+
(0, core_1.requireArgs)({ siteId });
|
|
56
|
+
const path = `/sites/${siteId}/domains`;
|
|
57
|
+
return client.get(path);
|
|
58
|
+
}
|
|
59
|
+
exports.domains = domains;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Client, QueryString } from "../core";
|
|
2
|
+
/**************************************************************
|
|
3
|
+
* Types
|
|
4
|
+
**************************************************************/
|
|
5
|
+
export declare type TriggerType = "form_submission" | "site_publish" | "ecomm_new_order" | "ecomm_order_changed" | "ecomm_inventory_changed" | "collection_item_created" | "collection_item_changed" | "collection_item_deleted" | string;
|
|
6
|
+
export declare type Filter = {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
/**************************************************************
|
|
10
|
+
* Interfaces
|
|
11
|
+
**************************************************************/
|
|
12
|
+
export interface IWebhook {
|
|
13
|
+
triggerType: TriggerType;
|
|
14
|
+
triggerId: string;
|
|
15
|
+
createdOn: string;
|
|
16
|
+
lastUsed?: string;
|
|
17
|
+
site: string;
|
|
18
|
+
_id: string;
|
|
19
|
+
filter?: {
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface IRemoveResult {
|
|
24
|
+
deleted: number;
|
|
25
|
+
}
|
|
26
|
+
/**************************************************************
|
|
27
|
+
* Functions
|
|
28
|
+
**************************************************************/
|
|
29
|
+
/**
|
|
30
|
+
* Get a list of Webhooks
|
|
31
|
+
* @param client The Webflow client
|
|
32
|
+
* @param params1 The params for the request
|
|
33
|
+
* @param params1.siteId The site ID
|
|
34
|
+
* @param params The query string parameters (optional)
|
|
35
|
+
* @returns A list of Webhooks
|
|
36
|
+
*/
|
|
37
|
+
export declare function list(client: Client, { siteId }: {
|
|
38
|
+
siteId: string;
|
|
39
|
+
}, params?: QueryString): Promise<import("axios").AxiosResponse<IWebhook[], any>>;
|
|
40
|
+
/**
|
|
41
|
+
* Get a single Webhook
|
|
42
|
+
* @param client The Webflow client
|
|
43
|
+
* @param params The params for the request
|
|
44
|
+
* @param params.siteId The site ID
|
|
45
|
+
* @param params.webhookId The webhook ID
|
|
46
|
+
* @returns A single Webhook
|
|
47
|
+
*/
|
|
48
|
+
export declare function getOne(client: Client, { siteId, webhookId }: {
|
|
49
|
+
siteId: string;
|
|
50
|
+
webhookId: string;
|
|
51
|
+
}): Promise<import("axios").AxiosResponse<IWebhook, any>>;
|
|
52
|
+
/**
|
|
53
|
+
* Create a new Webhook
|
|
54
|
+
* @param client The Webflow client
|
|
55
|
+
* @param params The params for the request
|
|
56
|
+
* @param params.siteId The site ID
|
|
57
|
+
* @param params.url The URL to send the webhook to
|
|
58
|
+
* @param params.triggerType The event to trigger the webhook
|
|
59
|
+
* @param params.filter The filter to apply to the webhook (optional: form_submission only)
|
|
60
|
+
* @param params.params The query string parameters (optional)
|
|
61
|
+
* @returns The created webhook
|
|
62
|
+
*/
|
|
63
|
+
export declare function create(client: Client, { triggerType, siteId, filter, url, }: {
|
|
64
|
+
url: string;
|
|
65
|
+
siteId: string;
|
|
66
|
+
filter?: Filter;
|
|
67
|
+
triggerType: TriggerType;
|
|
68
|
+
}): Promise<import("axios").AxiosResponse<IWebhook, any>>;
|
|
69
|
+
/**
|
|
70
|
+
* Remove a Webhook
|
|
71
|
+
* @param client The Webflow client
|
|
72
|
+
* @param params The query string parameters (optional)
|
|
73
|
+
* @param params.webhookId The Webhook ID
|
|
74
|
+
* @param params.siteId The Site ID
|
|
75
|
+
* @returns The result of the removal
|
|
76
|
+
*/
|
|
77
|
+
export declare function remove(client: Client, { siteId, webhookId }: {
|
|
78
|
+
siteId: string;
|
|
79
|
+
webhookId: string;
|
|
80
|
+
}): Promise<import("axios").AxiosResponse<IRemoveResult, any>>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.remove = exports.create = exports.getOne = exports.list = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
/**************************************************************
|
|
6
|
+
* Functions
|
|
7
|
+
**************************************************************/
|
|
8
|
+
/**
|
|
9
|
+
* Get a list of Webhooks
|
|
10
|
+
* @param client The Webflow client
|
|
11
|
+
* @param params1 The params for the request
|
|
12
|
+
* @param params1.siteId The site ID
|
|
13
|
+
* @param params The query string parameters (optional)
|
|
14
|
+
* @returns A list of Webhooks
|
|
15
|
+
*/
|
|
16
|
+
function list(client, { siteId }, params) {
|
|
17
|
+
(0, core_1.requireArgs)({ siteId });
|
|
18
|
+
const path = `/sites/${siteId}/webhooks`;
|
|
19
|
+
return client.get(path, { params });
|
|
20
|
+
}
|
|
21
|
+
exports.list = list;
|
|
22
|
+
/**
|
|
23
|
+
* Get a single Webhook
|
|
24
|
+
* @param client The Webflow client
|
|
25
|
+
* @param params The params for the request
|
|
26
|
+
* @param params.siteId The site ID
|
|
27
|
+
* @param params.webhookId The webhook ID
|
|
28
|
+
* @returns A single Webhook
|
|
29
|
+
*/
|
|
30
|
+
function getOne(client, { siteId, webhookId }) {
|
|
31
|
+
(0, core_1.requireArgs)({ siteId, webhookId });
|
|
32
|
+
const path = `/sites/${siteId}/webhooks/${webhookId}`;
|
|
33
|
+
return client.get(path);
|
|
34
|
+
}
|
|
35
|
+
exports.getOne = getOne;
|
|
36
|
+
/**
|
|
37
|
+
* Create a new Webhook
|
|
38
|
+
* @param client The Webflow client
|
|
39
|
+
* @param params The params for the request
|
|
40
|
+
* @param params.siteId The site ID
|
|
41
|
+
* @param params.url The URL to send the webhook to
|
|
42
|
+
* @param params.triggerType The event to trigger the webhook
|
|
43
|
+
* @param params.filter The filter to apply to the webhook (optional: form_submission only)
|
|
44
|
+
* @param params.params The query string parameters (optional)
|
|
45
|
+
* @returns The created webhook
|
|
46
|
+
*/
|
|
47
|
+
function create(client, { triggerType, siteId, filter, url, }) {
|
|
48
|
+
(0, core_1.requireArgs)({ siteId, triggerType, url });
|
|
49
|
+
const path = `/sites/${siteId}/webhooks`;
|
|
50
|
+
const data = { triggerType, url, filter };
|
|
51
|
+
return client.post(path, data);
|
|
52
|
+
}
|
|
53
|
+
exports.create = create;
|
|
54
|
+
/**
|
|
55
|
+
* Remove a Webhook
|
|
56
|
+
* @param client The Webflow client
|
|
57
|
+
* @param params The query string parameters (optional)
|
|
58
|
+
* @param params.webhookId The Webhook ID
|
|
59
|
+
* @param params.siteId The Site ID
|
|
60
|
+
* @returns The result of the removal
|
|
61
|
+
*/
|
|
62
|
+
function remove(client, { siteId, webhookId }) {
|
|
63
|
+
(0, core_1.requireArgs)({ siteId, webhookId });
|
|
64
|
+
const path = `/sites/${siteId}/webhooks/${webhookId}`;
|
|
65
|
+
return client.delete(path);
|
|
66
|
+
}
|
|
67
|
+
exports.remove = remove;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Axios } from "axios";
|
|
2
|
+
import { Options } from "../core";
|
|
3
|
+
/**************************************************************
|
|
4
|
+
* Types
|
|
5
|
+
**************************************************************/
|
|
6
|
+
export declare type QueryString = Record<string, any>;
|
|
7
|
+
export declare type PaginationFilter = {
|
|
8
|
+
limit?: number;
|
|
9
|
+
offset?: number;
|
|
10
|
+
};
|
|
11
|
+
/**************************************************************
|
|
12
|
+
* Interfaces
|
|
13
|
+
************************************************************* */
|
|
14
|
+
export interface PaginatedData {
|
|
15
|
+
count: number;
|
|
16
|
+
limit: number;
|
|
17
|
+
offset: number;
|
|
18
|
+
total: number;
|
|
19
|
+
}
|
|
20
|
+
export interface WebflowOptions {
|
|
21
|
+
host?: string;
|
|
22
|
+
token?: string;
|
|
23
|
+
version?: string;
|
|
24
|
+
headers?: Record<string, string>;
|
|
25
|
+
}
|
|
26
|
+
/**************************************************************
|
|
27
|
+
* Classes
|
|
28
|
+
**************************************************************/
|
|
29
|
+
export declare class Client extends Axios {
|
|
30
|
+
constructor({ host, headers, version, token, }?: Options);
|
|
31
|
+
/**
|
|
32
|
+
* Transforms JSON response to an object
|
|
33
|
+
* if the response is a Webflow error, it will throw an error
|
|
34
|
+
* @param data JSON response
|
|
35
|
+
* @returns response object
|
|
36
|
+
*/
|
|
37
|
+
private transformResponse;
|
|
38
|
+
set token(value: string);
|
|
39
|
+
clearToken(): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Client = void 0;
|
|
4
|
+
const axios_1 = require("axios");
|
|
5
|
+
const core_1 = require("../core");
|
|
6
|
+
/**************************************************************
|
|
7
|
+
* Classes
|
|
8
|
+
**************************************************************/
|
|
9
|
+
class Client extends axios_1.Axios {
|
|
10
|
+
constructor({ host = core_1.DEFAULT_HOST, headers = {}, version, token, } = {}) {
|
|
11
|
+
super({
|
|
12
|
+
transformRequest: [(data) => JSON.stringify(data)],
|
|
13
|
+
baseURL: `https://api.${host}/`,
|
|
14
|
+
headers: {
|
|
15
|
+
"Content-Type": "application/json",
|
|
16
|
+
"User-Agent": core_1.USER_AGENT,
|
|
17
|
+
"Accept-Version": version,
|
|
18
|
+
...headers,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
if (token)
|
|
22
|
+
this.token = token;
|
|
23
|
+
// check for webflow errors
|
|
24
|
+
this.defaults.transformResponse = [this.transformResponse];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Transforms JSON response to an object
|
|
28
|
+
* if the response is a Webflow error, it will throw an error
|
|
29
|
+
* @param data JSON response
|
|
30
|
+
* @returns response object
|
|
31
|
+
*/
|
|
32
|
+
transformResponse(data = {}) {
|
|
33
|
+
// parse json if string
|
|
34
|
+
if (String(data) === data)
|
|
35
|
+
data = JSON.parse(data);
|
|
36
|
+
if (data.err)
|
|
37
|
+
throw new core_1.RequestError(data);
|
|
38
|
+
return data;
|
|
39
|
+
}
|
|
40
|
+
// set the Authorization header
|
|
41
|
+
set token(value) {
|
|
42
|
+
this.defaults.headers["Authorization"] = `Bearer ${value}`;
|
|
43
|
+
}
|
|
44
|
+
// clear the Authorization header
|
|
45
|
+
clearToken() {
|
|
46
|
+
delete this.defaults.headers["Authorization"];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.Client = Client;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface IRequestError {
|
|
2
|
+
msg: string;
|
|
3
|
+
code: number;
|
|
4
|
+
name: string;
|
|
5
|
+
path: string;
|
|
6
|
+
err: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class RequestError extends Error implements IRequestError {
|
|
9
|
+
msg: string;
|
|
10
|
+
code: number;
|
|
11
|
+
name: string;
|
|
12
|
+
path: string;
|
|
13
|
+
err: string;
|
|
14
|
+
constructor(error: IRequestError);
|
|
15
|
+
}
|
|
16
|
+
export declare class ArgumentError extends Error {
|
|
17
|
+
constructor(name: string);
|
|
18
|
+
}
|
|
19
|
+
export declare function requireArgs(args: object): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requireArgs = exports.ArgumentError = exports.RequestError = void 0;
|
|
4
|
+
class RequestError extends Error {
|
|
5
|
+
constructor(error) {
|
|
6
|
+
super(error.err ? error.err : "Unknown error occured");
|
|
7
|
+
Object.assign(this, error);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.RequestError = RequestError;
|
|
11
|
+
class ArgumentError extends Error {
|
|
12
|
+
constructor(name) {
|
|
13
|
+
super(`Argument '${name}' is required but was not present`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.ArgumentError = ArgumentError;
|
|
17
|
+
function requireArgs(args) {
|
|
18
|
+
for (const key in args) {
|
|
19
|
+
if (!args[key])
|
|
20
|
+
throw new ArgumentError(key);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.requireArgs = requireArgs;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./client"), exports);
|
|
18
|
+
__exportStar(require("./error"), exports);
|
|
19
|
+
__exportStar(require("./options"), exports);
|
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _Webflow = require("./Webflow");
|
|
8
|
-
var _default = _Webflow.Webflow;
|
|
9
|
-
exports.default = _default;
|
|
10
|
-
module.exports = exports.default;
|
|
2
|
+
const webflow_1 = require("./webflow");
|
|
3
|
+
module.exports = webflow_1.Webflow;
|