webflow-api 1.2.2 → 1.3.0
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/.eslintrc +31 -0
- package/.github/workflows/code-quality.yml +102 -0
- package/.github/workflows/npm-publish.yml +21 -0
- package/.github/workflows/semgrep.yml +24 -0
- package/.prettierignore +5 -0
- package/.prettierrc +6 -0
- package/README.md +50 -1
- package/jest.config.js +17 -0
- package/package.json +2 -7
- package/src/api/collection.ts +1 -1
- package/src/api/item.ts +4 -4
- package/src/api/meta.ts +2 -2
- package/src/api/oauth.ts +8 -2
- package/src/core/error.ts +1 -1
- package/src/core/webflow.ts +111 -4
- package/tests/api/collection.test.ts +147 -0
- package/tests/api/item.test.ts +180 -0
- package/tests/api/meta.test.ts +38 -0
- package/tests/api/oauth.test.ts +44 -0
- package/tests/api/site.test.ts +202 -0
- package/tests/api/user.test.ts +139 -0
- package/tests/api/webhook.test.ts +82 -0
- package/tests/core/error.test.ts +19 -0
- package/tests/core/response.test.ts +36 -0
- package/tests/core/webflow.test.ts +540 -0
- package/tests/fixtures/collection.fixture.ts +374 -0
- package/tests/fixtures/index.ts +7 -0
- package/tests/fixtures/item.fixture.ts +193 -0
- package/tests/fixtures/meta.fixture.ts +34 -0
- package/tests/fixtures/oauth.fixture.ts +38 -0
- package/tests/fixtures/site.fixture.ts +78 -0
- package/tests/fixtures/user.fixture.ts +175 -0
- package/tests/fixtures/webhook.fixture.ts +69 -0
- package/tsconfig.eslint.json +7 -0
- package/tsconfig.json +14 -0
- package/dist/api/collection.d.ts +0 -112
- package/dist/api/collection.js +0 -94
- package/dist/api/index.d.ts +0 -7
- package/dist/api/index.js +0 -23
- package/dist/api/item.d.ts +0 -177
- package/dist/api/item.js +0 -151
- package/dist/api/meta.d.ts +0 -53
- package/dist/api/meta.js +0 -25
- package/dist/api/oauth.d.ts +0 -69
- package/dist/api/oauth.js +0 -66
- package/dist/api/site.d.ts +0 -140
- package/dist/api/site.js +0 -137
- package/dist/api/user.d.ts +0 -143
- package/dist/api/user.js +0 -119
- package/dist/api/webhook.d.ts +0 -102
- package/dist/api/webhook.js +0 -80
- package/dist/core/error.d.ts +0 -21
- package/dist/core/error.js +0 -30
- package/dist/core/index.d.ts +0 -3
- package/dist/core/index.js +0 -19
- package/dist/core/response.d.ts +0 -32
- package/dist/core/response.js +0 -26
- package/dist/core/webflow.d.ts +0 -386
- package/dist/core/webflow.js +0 -445
- package/dist/index.d.ts +0 -2
- package/yarn.lock +0 -2830
package/dist/api/site.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Site = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
const core_1 = require("../core");
|
|
6
|
-
/**************************************************************
|
|
7
|
-
* Class
|
|
8
|
-
**************************************************************/
|
|
9
|
-
class Site extends core_1.WebflowRecord {
|
|
10
|
-
/**
|
|
11
|
-
* Get a list of Sites
|
|
12
|
-
* @param client The Axios client instance
|
|
13
|
-
* @returns a list of Sites
|
|
14
|
-
*/
|
|
15
|
-
static list(client) {
|
|
16
|
-
const path = "/sites";
|
|
17
|
-
return client.get(path);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Get a single Site
|
|
21
|
-
* @param params The params for the request
|
|
22
|
-
* @param params.siteId The site ID
|
|
23
|
-
* @param params.params The query string parameters (optional)
|
|
24
|
-
* @param client The Axios client instance
|
|
25
|
-
* @returns A single Site
|
|
26
|
-
*/
|
|
27
|
-
static getOne({ siteId }, client) {
|
|
28
|
-
(0, core_1.requireArgs)({ siteId });
|
|
29
|
-
const path = `/sites/${siteId}`;
|
|
30
|
-
return client.get(path);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Publish a site
|
|
34
|
-
* @param params The params for the request
|
|
35
|
-
* @param params.siteId The site ID
|
|
36
|
-
* @param params.domains The domains to publish to
|
|
37
|
-
* @param client The Axios client instance
|
|
38
|
-
* @returns The publish result
|
|
39
|
-
*/
|
|
40
|
-
static publish({ siteId, domains }, client) {
|
|
41
|
-
(0, core_1.requireArgs)({ siteId, domains });
|
|
42
|
-
const path = `/sites/${siteId}/publish`;
|
|
43
|
-
return client.post(path, { domains });
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Get a list of domains for a site
|
|
47
|
-
* @param params The params for the request
|
|
48
|
-
* @param params.siteId The site ID
|
|
49
|
-
* @param client The Axios client instance
|
|
50
|
-
* @returns A list of domains
|
|
51
|
-
*/
|
|
52
|
-
static domains({ siteId }, client) {
|
|
53
|
-
(0, core_1.requireArgs)({ siteId });
|
|
54
|
-
const path = `/sites/${siteId}/domains`;
|
|
55
|
-
return client.get(path);
|
|
56
|
-
}
|
|
57
|
-
/**************************************************************
|
|
58
|
-
* Instance Methods
|
|
59
|
-
**************************************************************/
|
|
60
|
-
/**
|
|
61
|
-
* Get a list of domains for a site
|
|
62
|
-
* @returns A list of domains
|
|
63
|
-
*/
|
|
64
|
-
async domains() {
|
|
65
|
-
const res = await Site.domains({ siteId: this._id }, this.client);
|
|
66
|
-
return res.data;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Publish a site
|
|
70
|
-
* @param domains The domains to publish to
|
|
71
|
-
* @returns The publish result
|
|
72
|
-
*/
|
|
73
|
-
async publishSite(domains) {
|
|
74
|
-
const res = await Site.publish({ siteId: this._id, domains }, this.client);
|
|
75
|
-
return res.data;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Get a single Collection
|
|
79
|
-
* @param params The params for the request
|
|
80
|
-
* @param params.collectionId The collection ID
|
|
81
|
-
* @returns A single Collection
|
|
82
|
-
*/
|
|
83
|
-
async collection({ collectionId }) {
|
|
84
|
-
const res = await _1.Collection.getOne({ collectionId }, this.client);
|
|
85
|
-
return new _1.Collection(this.client, res);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Get a list of Collections
|
|
89
|
-
* @returns A list of Collections
|
|
90
|
-
*/
|
|
91
|
-
async collections() {
|
|
92
|
-
const res = await _1.Collection.list({ siteId: this._id }, this.client);
|
|
93
|
-
return res.data.map((data) => new _1.Collection(this.client, { ...res, data }));
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Get a single Webhook
|
|
97
|
-
* @param params The params for the request
|
|
98
|
-
* @param params.webhookId The webhook ID
|
|
99
|
-
* @returns A single Webhook
|
|
100
|
-
*/
|
|
101
|
-
async webhook({ webhookId }) {
|
|
102
|
-
const res = await _1.Webhook.getOne({ siteId: this._id, webhookId }, this.client);
|
|
103
|
-
return new _1.Webhook(this.client, res);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Get a list of Webhooks
|
|
107
|
-
* @returns A list of Webhooks
|
|
108
|
-
*/
|
|
109
|
-
async webhooks() {
|
|
110
|
-
const res = await _1.Webhook.list({ siteId: this._id }, this.client);
|
|
111
|
-
return res.data.map((data) => new _1.Webhook(this.client, { ...res, data }));
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Remove a Webhook
|
|
115
|
-
* @param params The query string parameters (optional)
|
|
116
|
-
* @param params.webhookId The Webhook ID
|
|
117
|
-
* @returns The result of the removal
|
|
118
|
-
*/
|
|
119
|
-
async removeWebhook({ webhookId }) {
|
|
120
|
-
const res = await _1.Webhook.remove({ siteId: this._id, webhookId }, this.client);
|
|
121
|
-
return res.data;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Create a new Webhook
|
|
125
|
-
* @param params The params for the request
|
|
126
|
-
* @param params.url The URL to send the webhook to
|
|
127
|
-
* @param params.triggerType The event to trigger the webhook
|
|
128
|
-
* @param params.filter The filter to apply to the webhook (optional: form_submission only)
|
|
129
|
-
* @returns The created webhook
|
|
130
|
-
*/
|
|
131
|
-
async createWebhook({ triggerType, filter, url, }) {
|
|
132
|
-
const _params = { url, siteId: this._id, triggerType, filter };
|
|
133
|
-
const res = await _1.Webhook.create(_params, this.client);
|
|
134
|
-
return new _1.Webhook(this.client, res);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
exports.Site = Site;
|
package/dist/api/user.d.ts
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance } from "axios";
|
|
2
|
-
import { PaginatedData, WebflowRecord } from "../core";
|
|
3
|
-
/**************************************************************
|
|
4
|
-
* Interfaces
|
|
5
|
-
**************************************************************/
|
|
6
|
-
export interface IUser {
|
|
7
|
-
emailVerified: boolean;
|
|
8
|
-
lastUpdated?: string;
|
|
9
|
-
createdOn: string;
|
|
10
|
-
_id: string;
|
|
11
|
-
data: any;
|
|
12
|
-
}
|
|
13
|
-
export interface IAcessGroup {
|
|
14
|
-
_id: string;
|
|
15
|
-
name: string;
|
|
16
|
-
shortId: string;
|
|
17
|
-
slug: string;
|
|
18
|
-
createdOn: string;
|
|
19
|
-
}
|
|
20
|
-
export interface IUserDelete {
|
|
21
|
-
deleted: number;
|
|
22
|
-
}
|
|
23
|
-
/**************************************************************
|
|
24
|
-
* Types
|
|
25
|
-
**************************************************************/
|
|
26
|
-
export declare type PaginatedUsers = PaginatedData & {
|
|
27
|
-
users: IUser[];
|
|
28
|
-
};
|
|
29
|
-
export declare type PaginatedAccessGroups = PaginatedData & {
|
|
30
|
-
accessGroups: IAcessGroup[];
|
|
31
|
-
};
|
|
32
|
-
export declare type UserIdParam = {
|
|
33
|
-
siteId: string;
|
|
34
|
-
userId: string;
|
|
35
|
-
};
|
|
36
|
-
/**************************************************************
|
|
37
|
-
* Class
|
|
38
|
-
**************************************************************/
|
|
39
|
-
export declare class User extends WebflowRecord<IUser> implements IUser {
|
|
40
|
-
emailVerified: boolean;
|
|
41
|
-
lastUpdated?: string;
|
|
42
|
-
createdOn: string;
|
|
43
|
-
siteId: string;
|
|
44
|
-
_id: string;
|
|
45
|
-
data: any;
|
|
46
|
-
/**************************************************************
|
|
47
|
-
* Static Methods
|
|
48
|
-
**************************************************************/
|
|
49
|
-
/**
|
|
50
|
-
* Get a list of Users
|
|
51
|
-
* @param params The params for the request
|
|
52
|
-
* @param params.siteId The site ID
|
|
53
|
-
* @param params.limit The number of items to return (optional)
|
|
54
|
-
* @param params.offset The number of items to skip (optional)
|
|
55
|
-
* @param client The Axios client instance
|
|
56
|
-
* @returns A list of Users
|
|
57
|
-
*/
|
|
58
|
-
static list({ siteId, limit, offset }: {
|
|
59
|
-
siteId: string;
|
|
60
|
-
limit?: number;
|
|
61
|
-
offset?: number;
|
|
62
|
-
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<PaginatedUsers, any>>;
|
|
63
|
-
/**
|
|
64
|
-
* Get a single User
|
|
65
|
-
* @param params The params for the request
|
|
66
|
-
* @param params.siteId The site ID
|
|
67
|
-
* @param params.userId The user ID
|
|
68
|
-
* @param client The Axios client instance
|
|
69
|
-
* @returns A single User
|
|
70
|
-
*/
|
|
71
|
-
static getOne({ siteId, userId }: {
|
|
72
|
-
siteId: string;
|
|
73
|
-
userId: string;
|
|
74
|
-
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IUser, any>>;
|
|
75
|
-
/**
|
|
76
|
-
* Update a User
|
|
77
|
-
* @param params The params for the request
|
|
78
|
-
* @param params.siteId The site ID
|
|
79
|
-
* @param params.userId The user ID
|
|
80
|
-
* @param params.data The data to update
|
|
81
|
-
* @param client The Axios client instance
|
|
82
|
-
* @returns The updated User
|
|
83
|
-
*/
|
|
84
|
-
static update({ siteId, userId, data, }: {
|
|
85
|
-
data: object;
|
|
86
|
-
siteId: string;
|
|
87
|
-
userId: string;
|
|
88
|
-
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IUser, any>>;
|
|
89
|
-
/**
|
|
90
|
-
* Invite a User to a site
|
|
91
|
-
* @param params The params for the request
|
|
92
|
-
* @param params.siteId The site ID
|
|
93
|
-
* @param params.email The email address of the user to invite
|
|
94
|
-
* @param client The Axios client instance
|
|
95
|
-
* @returns The newly created User
|
|
96
|
-
*/
|
|
97
|
-
static invite({ siteId, email }: {
|
|
98
|
-
siteId: string;
|
|
99
|
-
email: string;
|
|
100
|
-
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IUser, any>>;
|
|
101
|
-
/**
|
|
102
|
-
* Remove a User
|
|
103
|
-
* @param params The params for the request
|
|
104
|
-
* @param params.siteId The site ID
|
|
105
|
-
* @param params.userId The user ID
|
|
106
|
-
* @param client The Axios client instance
|
|
107
|
-
* @returns The result of the remove
|
|
108
|
-
*/
|
|
109
|
-
static remove({ siteId, userId }: {
|
|
110
|
-
siteId: string;
|
|
111
|
-
userId: string;
|
|
112
|
-
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IUserDelete, any>>;
|
|
113
|
-
/**
|
|
114
|
-
* Get a list of User Access Groups
|
|
115
|
-
* @param params The params for the request
|
|
116
|
-
* @param params.siteId The site ID
|
|
117
|
-
* @param params.limit The number of items to return (optional)
|
|
118
|
-
* @param params.offset The number of items to skip (optional)
|
|
119
|
-
* @param params.sort The sort order of the groups (optional)
|
|
120
|
-
* @param client The Axios client instance
|
|
121
|
-
* @returns A list of Access Groups
|
|
122
|
-
*/
|
|
123
|
-
static accessGroups({ siteId, limit, offset, sort, }: {
|
|
124
|
-
siteId: string;
|
|
125
|
-
limit?: number;
|
|
126
|
-
offset?: number;
|
|
127
|
-
sort?: string;
|
|
128
|
-
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<PaginatedAccessGroups, any>>;
|
|
129
|
-
/**************************************************************
|
|
130
|
-
* Instance Methods
|
|
131
|
-
**************************************************************/
|
|
132
|
-
/**
|
|
133
|
-
* Update a User
|
|
134
|
-
* @param data The data to update
|
|
135
|
-
* @returns The updated User
|
|
136
|
-
*/
|
|
137
|
-
update(data: any): Promise<User>;
|
|
138
|
-
/**
|
|
139
|
-
* Remove a User
|
|
140
|
-
* @returns The result of the remove
|
|
141
|
-
*/
|
|
142
|
-
remove(): Promise<IUserDelete>;
|
|
143
|
-
}
|
package/dist/api/user.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.User = void 0;
|
|
4
|
-
const core_1 = require("../core");
|
|
5
|
-
/**************************************************************
|
|
6
|
-
* Class
|
|
7
|
-
**************************************************************/
|
|
8
|
-
class User extends core_1.WebflowRecord {
|
|
9
|
-
/**************************************************************
|
|
10
|
-
* Static Methods
|
|
11
|
-
**************************************************************/
|
|
12
|
-
/**
|
|
13
|
-
* Get a list of Users
|
|
14
|
-
* @param params The params for the request
|
|
15
|
-
* @param params.siteId The site ID
|
|
16
|
-
* @param params.limit The number of items to return (optional)
|
|
17
|
-
* @param params.offset The number of items to skip (optional)
|
|
18
|
-
* @param client The Axios client instance
|
|
19
|
-
* @returns A list of Users
|
|
20
|
-
*/
|
|
21
|
-
static list({ siteId, limit, offset }, client) {
|
|
22
|
-
(0, core_1.requireArgs)({ siteId });
|
|
23
|
-
const params = { limit, offset };
|
|
24
|
-
const path = `/sites/${siteId}/users`;
|
|
25
|
-
return client.get(path, { params });
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Get a single User
|
|
29
|
-
* @param params The params for the request
|
|
30
|
-
* @param params.siteId The site ID
|
|
31
|
-
* @param params.userId The user ID
|
|
32
|
-
* @param client The Axios client instance
|
|
33
|
-
* @returns A single User
|
|
34
|
-
*/
|
|
35
|
-
static getOne({ siteId, userId }, client) {
|
|
36
|
-
(0, core_1.requireArgs)({ siteId, userId });
|
|
37
|
-
const path = `/sites/${siteId}/users/${userId}`;
|
|
38
|
-
return client.get(path);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Update a User
|
|
42
|
-
* @param params The params for the request
|
|
43
|
-
* @param params.siteId The site ID
|
|
44
|
-
* @param params.userId The user ID
|
|
45
|
-
* @param params.data The data to update
|
|
46
|
-
* @param client The Axios client instance
|
|
47
|
-
* @returns The updated User
|
|
48
|
-
*/
|
|
49
|
-
static update({ siteId, userId, data, }, client) {
|
|
50
|
-
(0, core_1.requireArgs)({ siteId, userId });
|
|
51
|
-
const path = `/sites/${siteId}/users/${userId}`;
|
|
52
|
-
return client.patch(path, data);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Invite a User to a site
|
|
56
|
-
* @param params The params for the request
|
|
57
|
-
* @param params.siteId The site ID
|
|
58
|
-
* @param params.email The email address of the user to invite
|
|
59
|
-
* @param client The Axios client instance
|
|
60
|
-
* @returns The newly created User
|
|
61
|
-
*/
|
|
62
|
-
static async invite({ siteId, email }, client) {
|
|
63
|
-
(0, core_1.requireArgs)({ siteId, email });
|
|
64
|
-
const path = `/sites/${siteId}/users/invite`;
|
|
65
|
-
return client.post(path, { email });
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Remove a User
|
|
69
|
-
* @param params The params for the request
|
|
70
|
-
* @param params.siteId The site ID
|
|
71
|
-
* @param params.userId The user ID
|
|
72
|
-
* @param client The Axios client instance
|
|
73
|
-
* @returns The result of the remove
|
|
74
|
-
*/
|
|
75
|
-
static remove({ siteId, userId }, client) {
|
|
76
|
-
(0, core_1.requireArgs)({ siteId, userId });
|
|
77
|
-
const path = `/sites/${siteId}/users/${userId}`;
|
|
78
|
-
return client.delete(path);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Get a list of User Access Groups
|
|
82
|
-
* @param params The params for the request
|
|
83
|
-
* @param params.siteId The site ID
|
|
84
|
-
* @param params.limit The number of items to return (optional)
|
|
85
|
-
* @param params.offset The number of items to skip (optional)
|
|
86
|
-
* @param params.sort The sort order of the groups (optional)
|
|
87
|
-
* @param client The Axios client instance
|
|
88
|
-
* @returns A list of Access Groups
|
|
89
|
-
*/
|
|
90
|
-
static accessGroups({ siteId, limit, offset, sort, }, client) {
|
|
91
|
-
(0, core_1.requireArgs)({ siteId });
|
|
92
|
-
const params = { limit, offset, sort };
|
|
93
|
-
const path = `/sites/${siteId}/accessgroups`;
|
|
94
|
-
return client.get(path, { params });
|
|
95
|
-
}
|
|
96
|
-
/**************************************************************
|
|
97
|
-
* Instance Methods
|
|
98
|
-
**************************************************************/
|
|
99
|
-
/**
|
|
100
|
-
* Update a User
|
|
101
|
-
* @param data The data to update
|
|
102
|
-
* @returns The updated User
|
|
103
|
-
*/
|
|
104
|
-
async update(data) {
|
|
105
|
-
const params = { siteId: this.siteId, userId: this._id, data };
|
|
106
|
-
const res = await User.update(params, this.client);
|
|
107
|
-
return new User(this.client, res);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Remove a User
|
|
111
|
-
* @returns The result of the remove
|
|
112
|
-
*/
|
|
113
|
-
async remove() {
|
|
114
|
-
const params = { siteId: this.siteId, userId: this._id };
|
|
115
|
-
const res = await User.remove(params, this.client);
|
|
116
|
-
return res.data;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
exports.User = User;
|
package/dist/api/webhook.d.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance } from "axios";
|
|
2
|
-
import { WebflowRecord } from "../core";
|
|
3
|
-
/**************************************************************
|
|
4
|
-
* Types
|
|
5
|
-
**************************************************************/
|
|
6
|
-
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;
|
|
7
|
-
export declare type WebhookFilter = {
|
|
8
|
-
name: string;
|
|
9
|
-
};
|
|
10
|
-
/**************************************************************
|
|
11
|
-
* Interfaces
|
|
12
|
-
**************************************************************/
|
|
13
|
-
export interface IWebhook {
|
|
14
|
-
triggerType: TriggerType;
|
|
15
|
-
triggerId: string;
|
|
16
|
-
createdOn: string;
|
|
17
|
-
lastUsed?: string;
|
|
18
|
-
site: string;
|
|
19
|
-
_id: string;
|
|
20
|
-
filter?: {
|
|
21
|
-
name: string;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export interface IRemoveResult {
|
|
25
|
-
deleted: number;
|
|
26
|
-
}
|
|
27
|
-
/**************************************************************
|
|
28
|
-
* Class
|
|
29
|
-
**************************************************************/
|
|
30
|
-
export declare class Webhook extends WebflowRecord<IWebhook> implements IWebhook {
|
|
31
|
-
filter?: {
|
|
32
|
-
name: string;
|
|
33
|
-
};
|
|
34
|
-
triggerType: string;
|
|
35
|
-
triggerId: string;
|
|
36
|
-
createdOn: string;
|
|
37
|
-
lastUsed?: string;
|
|
38
|
-
site: string;
|
|
39
|
-
_id: string;
|
|
40
|
-
/**************************************************************
|
|
41
|
-
* Static Methods
|
|
42
|
-
**************************************************************/
|
|
43
|
-
/**
|
|
44
|
-
* Get a list of Webhooks
|
|
45
|
-
* @param params The params for the request
|
|
46
|
-
* @param params.siteId The site ID
|
|
47
|
-
* @param client The Axios client instance
|
|
48
|
-
* @returns A list of Webhooks
|
|
49
|
-
*/
|
|
50
|
-
static list({ siteId }: {
|
|
51
|
-
siteId: string;
|
|
52
|
-
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IWebhook[], any>>;
|
|
53
|
-
/**
|
|
54
|
-
* Get a single Webhook
|
|
55
|
-
* @param params The params for the request
|
|
56
|
-
* @param params.siteId The site ID
|
|
57
|
-
* @param params.webhookId The webhook ID
|
|
58
|
-
* @param client The Axios client instance
|
|
59
|
-
* @returns A single Webhook
|
|
60
|
-
*/
|
|
61
|
-
static getOne({ siteId, webhookId }: {
|
|
62
|
-
siteId: string;
|
|
63
|
-
webhookId: string;
|
|
64
|
-
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IWebhook, any>>;
|
|
65
|
-
/**
|
|
66
|
-
* Create a new Webhook
|
|
67
|
-
* @param params The params for the request
|
|
68
|
-
* @param params.siteId The site ID
|
|
69
|
-
* @param params.url The URL to send the webhook to
|
|
70
|
-
* @param params.triggerType The event to trigger the webhook
|
|
71
|
-
* @param params.filter The filter to apply to the webhook (optional: form_submission only)
|
|
72
|
-
* @param params.params The query string parameters (optional)
|
|
73
|
-
* @param client The Axios client instance
|
|
74
|
-
* @returns The created webhook
|
|
75
|
-
*/
|
|
76
|
-
static create({ triggerType, siteId, filter, url, }: {
|
|
77
|
-
url: string;
|
|
78
|
-
siteId: string;
|
|
79
|
-
filter?: WebhookFilter;
|
|
80
|
-
triggerType: TriggerType;
|
|
81
|
-
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IWebhook, any>>;
|
|
82
|
-
/**
|
|
83
|
-
* Remove a Webhook
|
|
84
|
-
* @param params The query string parameters (optional)
|
|
85
|
-
* @param params.webhookId The Webhook ID
|
|
86
|
-
* @param params.siteId The Site ID
|
|
87
|
-
* @param client The Axios client instance
|
|
88
|
-
* @returns The result of the removal
|
|
89
|
-
*/
|
|
90
|
-
static remove({ siteId, webhookId }: {
|
|
91
|
-
siteId: string;
|
|
92
|
-
webhookId: string;
|
|
93
|
-
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IRemoveResult, any>>;
|
|
94
|
-
/**************************************************************
|
|
95
|
-
* Instance Methods
|
|
96
|
-
**************************************************************/
|
|
97
|
-
/**
|
|
98
|
-
* Remove a Webhook
|
|
99
|
-
* @returns The result of the removal
|
|
100
|
-
*/
|
|
101
|
-
remove(): Promise<IRemoveResult>;
|
|
102
|
-
}
|
package/dist/api/webhook.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Webhook = void 0;
|
|
4
|
-
const core_1 = require("../core");
|
|
5
|
-
/**************************************************************
|
|
6
|
-
* Class
|
|
7
|
-
**************************************************************/
|
|
8
|
-
class Webhook extends core_1.WebflowRecord {
|
|
9
|
-
/**************************************************************
|
|
10
|
-
* Static Methods
|
|
11
|
-
**************************************************************/
|
|
12
|
-
/**
|
|
13
|
-
* Get a list of Webhooks
|
|
14
|
-
* @param params The params for the request
|
|
15
|
-
* @param params.siteId The site ID
|
|
16
|
-
* @param client The Axios client instance
|
|
17
|
-
* @returns A list of Webhooks
|
|
18
|
-
*/
|
|
19
|
-
static list({ siteId }, client) {
|
|
20
|
-
(0, core_1.requireArgs)({ siteId });
|
|
21
|
-
const path = `/sites/${siteId}/webhooks`;
|
|
22
|
-
return client.get(path);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Get a single Webhook
|
|
26
|
-
* @param params The params for the request
|
|
27
|
-
* @param params.siteId The site ID
|
|
28
|
-
* @param params.webhookId The webhook ID
|
|
29
|
-
* @param client The Axios client instance
|
|
30
|
-
* @returns A single Webhook
|
|
31
|
-
*/
|
|
32
|
-
static getOne({ siteId, webhookId }, client) {
|
|
33
|
-
(0, core_1.requireArgs)({ siteId, webhookId });
|
|
34
|
-
const path = `/sites/${siteId}/webhooks/${webhookId}`;
|
|
35
|
-
return client.get(path);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Create a new Webhook
|
|
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
|
-
* @param client The Axios client instance
|
|
46
|
-
* @returns The created webhook
|
|
47
|
-
*/
|
|
48
|
-
static create({ triggerType, siteId, filter, url, }, client) {
|
|
49
|
-
(0, core_1.requireArgs)({ siteId, triggerType, url });
|
|
50
|
-
const path = `/sites/${siteId}/webhooks`;
|
|
51
|
-
const data = { triggerType, url, filter };
|
|
52
|
-
return client.post(path, data);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Remove a Webhook
|
|
56
|
-
* @param params The query string parameters (optional)
|
|
57
|
-
* @param params.webhookId The Webhook ID
|
|
58
|
-
* @param params.siteId The Site ID
|
|
59
|
-
* @param client The Axios client instance
|
|
60
|
-
* @returns The result of the removal
|
|
61
|
-
*/
|
|
62
|
-
static remove({ siteId, webhookId }, client) {
|
|
63
|
-
(0, core_1.requireArgs)({ siteId, webhookId });
|
|
64
|
-
const path = `/sites/${siteId}/webhooks/${webhookId}`;
|
|
65
|
-
return client.delete(path);
|
|
66
|
-
}
|
|
67
|
-
/**************************************************************
|
|
68
|
-
* Instance Methods
|
|
69
|
-
**************************************************************/
|
|
70
|
-
/**
|
|
71
|
-
* Remove a Webhook
|
|
72
|
-
* @returns The result of the removal
|
|
73
|
-
*/
|
|
74
|
-
async remove() {
|
|
75
|
-
const params = { siteId: this.site, webhookId: this._id };
|
|
76
|
-
const res = await Webhook.remove(params, this.client);
|
|
77
|
-
return res.data;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.Webhook = Webhook;
|
package/dist/core/error.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { AxiosResponse } from "axios";
|
|
2
|
-
export interface IRequestError {
|
|
3
|
-
msg: string;
|
|
4
|
-
code: number;
|
|
5
|
-
name: string;
|
|
6
|
-
path: string;
|
|
7
|
-
err: string;
|
|
8
|
-
}
|
|
9
|
-
export declare class RequestError extends Error implements IRequestError {
|
|
10
|
-
msg: string;
|
|
11
|
-
code: number;
|
|
12
|
-
name: string;
|
|
13
|
-
path: string;
|
|
14
|
-
err: string;
|
|
15
|
-
constructor(error: IRequestError);
|
|
16
|
-
}
|
|
17
|
-
export declare class ArgumentError extends Error {
|
|
18
|
-
constructor(name: string);
|
|
19
|
-
}
|
|
20
|
-
export declare function requireArgs(args: object): void;
|
|
21
|
-
export declare function ErrorInterceptor(res: AxiosResponse<IRequestError>): AxiosResponse<IRequestError, any>;
|
package/dist/core/error.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ErrorInterceptor = 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;
|
|
24
|
-
// throw an error if Webflow error
|
|
25
|
-
function ErrorInterceptor(res) {
|
|
26
|
-
if (res.data.err)
|
|
27
|
-
throw new RequestError(res.data);
|
|
28
|
-
return res;
|
|
29
|
-
}
|
|
30
|
-
exports.ErrorInterceptor = ErrorInterceptor;
|
package/dist/core/index.d.ts
DELETED
package/dist/core/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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("./error"), exports);
|
|
18
|
-
__exportStar(require("./response"), exports);
|
|
19
|
-
__exportStar(require("./webflow"), exports);
|
package/dist/core/response.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosResponse } from "axios";
|
|
2
|
-
/**************************************************************
|
|
3
|
-
* Types
|
|
4
|
-
**************************************************************/
|
|
5
|
-
export declare type PaginationFilter = {
|
|
6
|
-
limit?: number;
|
|
7
|
-
offset?: number;
|
|
8
|
-
};
|
|
9
|
-
export declare type WebflowHeaders = Record<string, any>;
|
|
10
|
-
/**************************************************************
|
|
11
|
-
* Interfaces
|
|
12
|
-
************************************************************* */
|
|
13
|
-
export interface PaginatedData {
|
|
14
|
-
count: number;
|
|
15
|
-
limit: number;
|
|
16
|
-
offset: number;
|
|
17
|
-
total: number;
|
|
18
|
-
}
|
|
19
|
-
export declare class MetaResponse<T> {
|
|
20
|
-
response: AxiosResponse<T>;
|
|
21
|
-
rateLimit: {
|
|
22
|
-
limit: number;
|
|
23
|
-
remaining: number;
|
|
24
|
-
};
|
|
25
|
-
constructor(response: AxiosResponse<T>);
|
|
26
|
-
}
|
|
27
|
-
export declare class WebflowRecord<T> {
|
|
28
|
-
response: AxiosResponse<T>;
|
|
29
|
-
_meta: MetaResponse<T>;
|
|
30
|
-
client: AxiosInstance;
|
|
31
|
-
constructor(client: AxiosInstance, response: AxiosResponse<any>, record?: T, ...args: any[]);
|
|
32
|
-
}
|