webflow-api 1.1.2 → 1.2.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.
Files changed (72) hide show
  1. package/README.md +41 -17
  2. package/dist/api/collection.d.ts +86 -25
  3. package/dist/api/collection.js +88 -29
  4. package/dist/api/index.d.ts +7 -7
  5. package/dist/api/index.js +9 -19
  6. package/dist/api/item.d.ts +141 -107
  7. package/dist/api/item.js +145 -125
  8. package/dist/api/meta.d.ts +16 -14
  9. package/dist/api/meta.js +20 -19
  10. package/dist/api/oauth.d.ts +38 -36
  11. package/dist/api/oauth.js +59 -59
  12. package/dist/api/site.d.ts +118 -43
  13. package/dist/api/site.js +131 -53
  14. package/dist/api/user.d.ts +143 -0
  15. package/dist/api/user.js +119 -0
  16. package/dist/api/webhook.d.ts +77 -55
  17. package/dist/api/webhook.js +74 -61
  18. package/dist/core/error.d.ts +2 -0
  19. package/dist/core/error.js +8 -1
  20. package/dist/core/index.d.ts +2 -2
  21. package/dist/core/index.js +2 -2
  22. package/dist/core/response.d.ts +32 -0
  23. package/dist/core/response.js +26 -0
  24. package/dist/{webflow.d.ts → core/webflow.d.ts} +66 -54
  25. package/dist/{webflow.js → core/webflow.js} +114 -65
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.js +2 -2
  28. package/package.json +12 -8
  29. package/src/api/collection.ts +103 -36
  30. package/src/api/index.ts +7 -7
  31. package/src/api/item.ts +217 -176
  32. package/src/api/meta.ts +19 -18
  33. package/src/api/oauth.ts +71 -74
  34. package/src/api/site.ts +161 -55
  35. package/src/api/user.ts +192 -0
  36. package/src/api/webhook.ts +103 -80
  37. package/src/core/error.ts +8 -0
  38. package/src/core/index.ts +2 -2
  39. package/src/core/response.ts +50 -0
  40. package/src/{webflow.ts → core/webflow.ts} +153 -125
  41. package/src/index.ts +1 -1
  42. package/yarn.lock +4 -9
  43. package/dist/api/membership.d.ts +0 -114
  44. package/dist/api/membership.js +0 -96
  45. package/dist/core/client.d.ts +0 -27
  46. package/dist/core/client.js +0 -60
  47. package/dist/core/options.d.ts +0 -8
  48. package/dist/core/options.js +0 -5
  49. package/dist/wrapper/collection.d.ts +0 -85
  50. package/dist/wrapper/collection.js +0 -94
  51. package/dist/wrapper/index.d.ts +0 -6
  52. package/dist/wrapper/index.js +0 -22
  53. package/dist/wrapper/item.d.ts +0 -140
  54. package/dist/wrapper/item.js +0 -153
  55. package/dist/wrapper/membership.d.ts +0 -105
  56. package/dist/wrapper/membership.js +0 -123
  57. package/dist/wrapper/response.d.ts +0 -16
  58. package/dist/wrapper/response.js +0 -17
  59. package/dist/wrapper/site.d.ts +0 -168
  60. package/dist/wrapper/site.js +0 -191
  61. package/dist/wrapper/webhook.d.ts +0 -78
  62. package/dist/wrapper/webhook.js +0 -82
  63. package/src/api/membership.ts +0 -155
  64. package/src/core/client.ts +0 -82
  65. package/src/core/options.ts +0 -9
  66. package/src/wrapper/collection.ts +0 -115
  67. package/src/wrapper/index.ts +0 -6
  68. package/src/wrapper/item.ts +0 -218
  69. package/src/wrapper/membership.ts +0 -163
  70. package/src/wrapper/response.ts +0 -25
  71. package/src/wrapper/site.ts +0 -228
  72. package/src/wrapper/webhook.ts +0 -116
package/src/api/site.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { Client, QueryString, requireArgs } from "../core";
1
+ import { AxiosInstance } from "axios";
2
+ import { Webhook, Collection, WebhookFilter } from ".";
3
+ import { requireArgs, WebflowRecord } from "../core";
2
4
 
3
5
  /**************************************************************
4
6
  * Interfaces
@@ -24,63 +26,167 @@ export interface IPublishSite {
24
26
  }
25
27
 
26
28
  /**************************************************************
27
- * Functions
29
+ * Class
28
30
  **************************************************************/
29
31
 
30
- /**
31
- * Get a list of Sites
32
- * @param client The Webflow client
33
- * @param params The query string parameters (optional)
34
- * @returns
35
- */
36
- export function list(client: Client, params?: QueryString) {
37
- const path = "/sites";
38
- return client.get<ISite[]>(path, { params });
39
- }
32
+ export class Site extends WebflowRecord<ISite> implements ISite {
33
+ lastPublished: string;
34
+ previewUrl: string;
35
+ createdOn: string;
36
+ shortName: string;
37
+ timezone: string;
38
+ database: string;
39
+ name: string;
40
+ _id: string;
40
41
 
41
- /**
42
- * Get a single Site
43
- * @param client The Webflow client
44
- * @param params The params for the request
45
- * @param params.siteId The site ID
46
- * @param params.params The query string parameters (optional)
47
- * @returns A single Site
48
- */
49
- export function getOne(
50
- client: Client,
51
- { siteId, params }: { siteId: string; params?: QueryString }
52
- ) {
53
- requireArgs({ siteId });
54
- const path = `/sites/${siteId}`;
55
- return client.get<ISite>(path, { params });
56
- }
42
+ /**
43
+ * Get a list of Sites
44
+ * @param client The Axios client instance
45
+ * @returns a list of Sites
46
+ */
47
+ static list(client: AxiosInstance) {
48
+ const path = "/sites";
49
+ return client.get<ISite[]>(path);
50
+ }
57
51
 
58
- /**
59
- * Publish a site
60
- * @param client The Webflow client
61
- * @param params The params for the request
62
- * @param params.siteId The site ID
63
- * @param params.domains The domains to publish to
64
- * @returns The publish result
65
- */
66
- export function publish(
67
- client: Client,
68
- { siteId, domains }: { siteId: string; domains: string[] }
69
- ) {
70
- requireArgs({ siteId, domains });
71
- const path = `/sites/${siteId}/publish`;
72
- return client.post<IPublishSite>(path, { domains });
73
- }
52
+ /**
53
+ * Get a single Site
54
+ * @param params The params for the request
55
+ * @param params.siteId The site ID
56
+ * @param params.params The query string parameters (optional)
57
+ * @param client The Axios client instance
58
+ * @returns A single Site
59
+ */
60
+ static getOne({ siteId }: { siteId: string }, client: AxiosInstance) {
61
+ requireArgs({ siteId });
62
+ const path = `/sites/${siteId}`;
63
+ return client.get<ISite>(path);
64
+ }
65
+
66
+ /**
67
+ * Publish a site
68
+ * @param params The params for the request
69
+ * @param params.siteId The site ID
70
+ * @param params.domains The domains to publish to
71
+ * @param client The Axios client instance
72
+ * @returns The publish result
73
+ */
74
+ static publish(
75
+ { siteId, domains }: { siteId: string; domains: string[] },
76
+ client: AxiosInstance,
77
+ ) {
78
+ requireArgs({ siteId, domains });
79
+ const path = `/sites/${siteId}/publish`;
80
+ return client.post<IPublishSite>(path, { domains });
81
+ }
82
+
83
+ /**
84
+ * Get a list of domains for a site
85
+ * @param params The params for the request
86
+ * @param params.siteId The site ID
87
+ * @param client The Axios client instance
88
+ * @returns A list of domains
89
+ */
90
+ static domains({ siteId }: { siteId: string }, client: AxiosInstance) {
91
+ requireArgs({ siteId });
92
+ const path = `/sites/${siteId}/domains`;
93
+ return client.get<IDomain[]>(path);
94
+ }
95
+
96
+ /**************************************************************
97
+ * Instance Methods
98
+ **************************************************************/
99
+
100
+ /**
101
+ * Get a list of domains for a site
102
+ * @returns A list of domains
103
+ */
104
+ async domains() {
105
+ const res = await Site.domains({ siteId: this._id }, this.client);
106
+ return res.data;
107
+ }
108
+
109
+ /**
110
+ * Publish a site
111
+ * @param domains The domains to publish to
112
+ * @returns The publish result
113
+ */
114
+ async publishSite(domains: string[]) {
115
+ const res = await Site.publish({ siteId: this._id, domains }, this.client);
116
+ return res.data;
117
+ }
118
+
119
+ /**
120
+ * Get a single Collection
121
+ * @param params The params for the request
122
+ * @param params.collectionId The collection ID
123
+ * @returns A single Collection
124
+ */
125
+ async collection({ collectionId }: { collectionId: string }) {
126
+ const res = await Collection.getOne({ collectionId }, this.client);
127
+ return new Collection(this.client, res);
128
+ }
129
+
130
+ /**
131
+ * Get a list of Collections
132
+ * @returns A list of Collections
133
+ */
134
+ async collections() {
135
+ const res = await Collection.list({ siteId: this._id }, this.client);
136
+ return res.data.map((data) => new Collection(this.client, { ...res, data }));
137
+ }
138
+
139
+ /**
140
+ * Get a single Webhook
141
+ * @param params The params for the request
142
+ * @param params.webhookId The webhook ID
143
+ * @returns A single Webhook
144
+ */
145
+ async webhook({ webhookId }: { webhookId: string }) {
146
+ const res = await Webhook.getOne({ siteId: this._id, webhookId }, this.client);
147
+ return new Webhook(this.client, res);
148
+ }
149
+
150
+ /**
151
+ * Get a list of Webhooks
152
+ * @returns A list of Webhooks
153
+ */
154
+ async webhooks() {
155
+ const res = await Webhook.list({ siteId: this._id }, this.client);
156
+ return res.data.map((data) => new Webhook(this.client, { ...res, data }));
157
+ }
158
+
159
+ /**
160
+ * Remove a Webhook
161
+ * @param params The query string parameters (optional)
162
+ * @param params.webhookId The Webhook ID
163
+ * @returns The result of the removal
164
+ */
165
+ async removeWebhook({ webhookId }: { webhookId: string }) {
166
+ const res = await Webhook.remove({ siteId: this._id, webhookId }, this.client);
167
+ return res.data;
168
+ }
74
169
 
75
- /**
76
- * Get a list of domains for a site
77
- * @param client The Webflow client
78
- * @param params The params for the request
79
- * @param params.siteId The site ID
80
- * @returns A list of domains
81
- */
82
- export function domains(client: Client, { siteId }: { siteId: string }) {
83
- requireArgs({ siteId });
84
- const path = `/sites/${siteId}/domains`;
85
- return client.get<IDomain[]>(path);
170
+ /**
171
+ * Create a new Webhook
172
+ * @param params The params for the request
173
+ * @param params.url The URL to send the webhook to
174
+ * @param params.triggerType The event to trigger the webhook
175
+ * @param params.filter The filter to apply to the webhook (optional: form_submission only)
176
+ * @returns The created webhook
177
+ */
178
+ async createWebhook({
179
+ triggerType,
180
+ filter,
181
+ url,
182
+ }: {
183
+ url: string;
184
+ siteId: string;
185
+ triggerType: string;
186
+ filter?: WebhookFilter;
187
+ }) {
188
+ const _params = { url, siteId: this._id, triggerType, filter };
189
+ const res = await Webhook.create(_params, this.client);
190
+ return new Webhook(this.client, res);
191
+ }
86
192
  }
@@ -0,0 +1,192 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { PaginatedData, requireArgs, WebflowRecord } from "../core";
3
+
4
+ /**************************************************************
5
+ * Interfaces
6
+ **************************************************************/
7
+ export interface IUser {
8
+ emailVerified: boolean;
9
+ lastUpdated?: string;
10
+ createdOn: string;
11
+ _id: string;
12
+ data: any;
13
+ }
14
+
15
+ export interface IAcessGroup {
16
+ _id: string;
17
+ name: string;
18
+ shortId: string;
19
+ slug: string;
20
+ createdOn: string;
21
+ }
22
+
23
+ export interface IUserDelete {
24
+ deleted: number;
25
+ }
26
+
27
+ /**************************************************************
28
+ * Types
29
+ **************************************************************/
30
+ export type PaginatedUsers = PaginatedData & {
31
+ users: IUser[];
32
+ };
33
+
34
+ export type PaginatedAccessGroups = PaginatedData & {
35
+ accessGroups: IAcessGroup[];
36
+ };
37
+
38
+ export type UserIdParam = { siteId: string; userId: string };
39
+
40
+ /**************************************************************
41
+ * Class
42
+ **************************************************************/
43
+
44
+ export class User extends WebflowRecord<IUser> implements IUser {
45
+ emailVerified: boolean;
46
+ lastUpdated?: string;
47
+ createdOn: string;
48
+ siteId: string;
49
+ _id: string;
50
+ data: any;
51
+
52
+ /**************************************************************
53
+ * Static Methods
54
+ **************************************************************/
55
+
56
+ /**
57
+ * Get a list of Users
58
+ * @param params The params for the request
59
+ * @param params.siteId The site ID
60
+ * @param params.limit The number of items to return (optional)
61
+ * @param params.offset The number of items to skip (optional)
62
+ * @param client The Axios client instance
63
+ * @returns A list of Users
64
+ */
65
+ static list(
66
+ { siteId, limit, offset }: { siteId: string; limit?: number; offset?: number },
67
+ client: AxiosInstance,
68
+ ) {
69
+ requireArgs({ siteId });
70
+ const params = { limit, offset };
71
+ const path = `/sites/${siteId}/users`;
72
+ return client.get<PaginatedUsers>(path, { params });
73
+ }
74
+
75
+ /**
76
+ * Get a single 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 client The Axios client instance
81
+ * @returns A single User
82
+ */
83
+ static getOne({ siteId, userId }: { siteId: string; userId: string }, client: AxiosInstance) {
84
+ requireArgs({ siteId, userId });
85
+ const path = `/sites/${siteId}/users/${userId}`;
86
+ return client.get<IUser>(path);
87
+ }
88
+
89
+ /**
90
+ * Update a User
91
+ * @param params The params for the request
92
+ * @param params.siteId The site ID
93
+ * @param params.userId The user ID
94
+ * @param params.data The data to update
95
+ * @param client The Axios client instance
96
+ * @returns The updated User
97
+ */
98
+ static update(
99
+ {
100
+ siteId,
101
+ userId,
102
+ data,
103
+ }: {
104
+ data: object;
105
+ siteId: string;
106
+ userId: string;
107
+ },
108
+ client: AxiosInstance,
109
+ ) {
110
+ requireArgs({ siteId, userId });
111
+ const path = `/sites/${siteId}/users/${userId}`;
112
+ return client.patch<IUser>(path, data);
113
+ }
114
+
115
+ /**
116
+ * Invite a User to a site
117
+ * @param params The params for the request
118
+ * @param params.siteId The site ID
119
+ * @param params.email The email address of the user to invite
120
+ * @param client The Axios client instance
121
+ * @returns The newly created User
122
+ */
123
+ static async invite({ siteId, email }: { siteId: string; email: string }, client: AxiosInstance) {
124
+ requireArgs({ siteId, email });
125
+ const path = `/sites/${siteId}/users/invite`;
126
+ return client.post<IUser>(path, { email });
127
+ }
128
+
129
+ /**
130
+ * Remove a User
131
+ * @param params The params for the request
132
+ * @param params.siteId The site ID
133
+ * @param params.userId The user ID
134
+ * @param client The Axios client instance
135
+ * @returns The result of the remove
136
+ */
137
+ static remove({ siteId, userId }: { siteId: string; userId: string }, client: AxiosInstance) {
138
+ requireArgs({ siteId, userId });
139
+ const path = `/sites/${siteId}/users/${userId}`;
140
+ return client.delete<IUserDelete>(path);
141
+ }
142
+
143
+ /**
144
+ * Get a list of User Access Groups
145
+ * @param params The params for the request
146
+ * @param params.siteId The site ID
147
+ * @param params.limit The number of items to return (optional)
148
+ * @param params.offset The number of items to skip (optional)
149
+ * @param params.sort The sort order of the groups (optional)
150
+ * @param client The Axios client instance
151
+ * @returns A list of Access Groups
152
+ */
153
+ static accessGroups(
154
+ {
155
+ siteId,
156
+ limit,
157
+ offset,
158
+ sort,
159
+ }: { siteId: string; limit?: number; offset?: number; sort?: string },
160
+ client: AxiosInstance,
161
+ ) {
162
+ requireArgs({ siteId });
163
+ const params = { limit, offset, sort };
164
+ const path = `/sites/${siteId}/accessgroups`;
165
+ return client.get<PaginatedAccessGroups>(path, { params });
166
+ }
167
+
168
+ /**************************************************************
169
+ * Instance Methods
170
+ **************************************************************/
171
+
172
+ /**
173
+ * Update a User
174
+ * @param data The data to update
175
+ * @returns The updated User
176
+ */
177
+ async update(data: any) {
178
+ const params = { siteId: this.siteId, userId: this._id, data };
179
+ const res = await User.update(params, this.client);
180
+ return new User(this.client, res);
181
+ }
182
+
183
+ /**
184
+ * Remove a User
185
+ * @returns The result of the remove
186
+ */
187
+ async remove() {
188
+ const params = { siteId: this.siteId, userId: this._id };
189
+ const res = await User.remove(params, this.client);
190
+ return res.data;
191
+ }
192
+ }
@@ -1,4 +1,5 @@
1
- import { Client, QueryString, requireArgs } from "../core";
1
+ import { AxiosInstance } from "axios";
2
+ import { requireArgs, WebflowRecord } from "../core";
2
3
 
3
4
  /**************************************************************
4
5
  * Types
@@ -14,7 +15,7 @@ export type TriggerType =
14
15
  | "collection_item_deleted"
15
16
  | string;
16
17
 
17
- export type Filter = {
18
+ export type WebhookFilter = {
18
19
  name: string;
19
20
  };
20
21
 
@@ -38,88 +39,110 @@ export interface IRemoveResult {
38
39
  }
39
40
 
40
41
  /**************************************************************
41
- * Functions
42
+ * Class
42
43
  **************************************************************/
44
+ export class Webhook extends WebflowRecord<IWebhook> implements IWebhook {
45
+ filter?: { name: string };
46
+ triggerType: string;
47
+ triggerId: string;
48
+ createdOn: string;
49
+ lastUsed?: string;
50
+ site: string;
51
+ _id: string;
43
52
 
44
- /**
45
- * Get a list of Webhooks
46
- * @param client The Webflow client
47
- * @param params1 The params for the request
48
- * @param params1.siteId The site ID
49
- * @param params The query string parameters (optional)
50
- * @returns A list of Webhooks
51
- */
52
- export function list(
53
- client: Client,
54
- { siteId }: { siteId: string },
55
- params?: QueryString
56
- ) {
57
- requireArgs({ siteId });
58
- const path = `/sites/${siteId}/webhooks`;
59
- return client.get<IWebhook[]>(path, { params });
60
- }
53
+ /**************************************************************
54
+ * Static Methods
55
+ **************************************************************/
61
56
 
62
- /**
63
- * Get a single Webhook
64
- * @param client The Webflow client
65
- * @param params The params for the request
66
- * @param params.siteId The site ID
67
- * @param params.webhookId The webhook ID
68
- * @returns A single Webhook
69
- */
70
- export function getOne(
71
- client: Client,
72
- { siteId, webhookId }: { siteId: string; webhookId: string }
73
- ) {
74
- requireArgs({ siteId, webhookId });
75
- const path = `/sites/${siteId}/webhooks/${webhookId}`;
76
- return client.get<IWebhook>(path);
77
- }
57
+ /**
58
+ * Get a list of Webhooks
59
+ * @param params The params for the request
60
+ * @param params.siteId The site ID
61
+ * @param client The Axios client instance
62
+ * @returns A list of Webhooks
63
+ */
64
+ static list({ siteId }: { siteId: string }, client: AxiosInstance) {
65
+ requireArgs({ siteId });
66
+ const path = `/sites/${siteId}/webhooks`;
67
+ return client.get<IWebhook[]>(path);
68
+ }
78
69
 
79
- /**
80
- * Create a new Webhook
81
- * @param client The Webflow client
82
- * @param params The params for the request
83
- * @param params.siteId The site ID
84
- * @param params.url The URL to send the webhook to
85
- * @param params.triggerType The event to trigger the webhook
86
- * @param params.filter The filter to apply to the webhook (optional: form_submission only)
87
- * @param params.params The query string parameters (optional)
88
- * @returns The created webhook
89
- */
90
- export function create(
91
- client: Client,
92
- {
93
- triggerType,
94
- siteId,
95
- filter,
96
- url,
97
- }: {
98
- url: string;
99
- siteId: string;
100
- filter?: Filter;
101
- triggerType: TriggerType;
70
+ /**
71
+ * Get a single Webhook
72
+ * @param params The params for the request
73
+ * @param params.siteId The site ID
74
+ * @param params.webhookId The webhook ID
75
+ * @param client The Axios client instance
76
+ * @returns A single Webhook
77
+ */
78
+ static getOne(
79
+ { siteId, webhookId }: { siteId: string; webhookId: string },
80
+ client: AxiosInstance,
81
+ ) {
82
+ requireArgs({ siteId, webhookId });
83
+ const path = `/sites/${siteId}/webhooks/${webhookId}`;
84
+ return client.get<IWebhook>(path);
85
+ }
86
+
87
+ /**
88
+ * Create a new Webhook
89
+ * @param params The params for the request
90
+ * @param params.siteId The site ID
91
+ * @param params.url The URL to send the webhook to
92
+ * @param params.triggerType The event to trigger the webhook
93
+ * @param params.filter The filter to apply to the webhook (optional: form_submission only)
94
+ * @param params.params The query string parameters (optional)
95
+ * @param client The Axios client instance
96
+ * @returns The created webhook
97
+ */
98
+ static create(
99
+ {
100
+ triggerType,
101
+ siteId,
102
+ filter,
103
+ url,
104
+ }: {
105
+ url: string;
106
+ siteId: string;
107
+ filter?: WebhookFilter;
108
+ triggerType: TriggerType;
109
+ },
110
+ client: AxiosInstance,
111
+ ) {
112
+ requireArgs({ siteId, triggerType, url });
113
+ const path = `/sites/${siteId}/webhooks`;
114
+ const data = { triggerType, url, filter };
115
+ return client.post<IWebhook>(path, data);
102
116
  }
103
- ) {
104
- requireArgs({ siteId, triggerType, url });
105
- const path = `/sites/${siteId}/webhooks`;
106
- const data = { triggerType, url, filter };
107
- return client.post<IWebhook>(path, data);
108
- }
109
117
 
110
- /**
111
- * Remove a Webhook
112
- * @param client The Webflow client
113
- * @param params The query string parameters (optional)
114
- * @param params.webhookId The Webhook ID
115
- * @param params.siteId The Site ID
116
- * @returns The result of the removal
117
- */
118
- export function remove(
119
- client: Client,
120
- { siteId, webhookId }: { siteId: string; webhookId: string }
121
- ) {
122
- requireArgs({ siteId, webhookId });
123
- const path = `/sites/${siteId}/webhooks/${webhookId}`;
124
- return client.delete<IRemoveResult>(path);
118
+ /**
119
+ * Remove a Webhook
120
+ * @param params The query string parameters (optional)
121
+ * @param params.webhookId The Webhook ID
122
+ * @param params.siteId The Site ID
123
+ * @param client The Axios client instance
124
+ * @returns The result of the removal
125
+ */
126
+ static remove(
127
+ { siteId, webhookId }: { siteId: string; webhookId: string },
128
+ client: AxiosInstance,
129
+ ) {
130
+ requireArgs({ siteId, webhookId });
131
+ const path = `/sites/${siteId}/webhooks/${webhookId}`;
132
+ return client.delete<IRemoveResult>(path);
133
+ }
134
+
135
+ /**************************************************************
136
+ * Instance Methods
137
+ **************************************************************/
138
+
139
+ /**
140
+ * Remove a Webhook
141
+ * @returns The result of the removal
142
+ */
143
+ async remove() {
144
+ const params = { siteId: this.site, webhookId: this._id };
145
+ const res = await Webhook.remove(params, this.client);
146
+ return res.data;
147
+ }
125
148
  }
package/src/core/error.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { AxiosResponse } from "axios";
2
+
1
3
  export interface IRequestError {
2
4
  msg: string;
3
5
  code: number;
@@ -30,3 +32,9 @@ export function requireArgs(args: object) {
30
32
  if (!args[key]) throw new ArgumentError(key);
31
33
  }
32
34
  }
35
+
36
+ // throw an error if Webflow error
37
+ export function ErrorInterceptor(res: AxiosResponse<IRequestError>) {
38
+ if (res.data.err) throw new RequestError(res.data);
39
+ return res;
40
+ }
package/src/core/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./client";
2
1
  export * from "./error";
3
- export * from "./options";
2
+ export * from "./response";
3
+ export * from "./webflow";