webflow-api 1.1.1 → 1.2.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/README.md +12 -1
- package/dist/api/collection.d.ts +85 -24
- package/dist/api/collection.js +88 -29
- package/dist/api/index.d.ts +7 -7
- package/dist/api/index.js +9 -19
- package/dist/api/item.d.ts +141 -107
- package/dist/api/item.js +145 -125
- package/dist/api/meta.d.ts +16 -14
- package/dist/api/meta.js +20 -19
- package/dist/api/oauth.d.ts +38 -36
- package/dist/api/oauth.js +59 -59
- package/dist/api/site.d.ts +118 -43
- package/dist/api/site.js +131 -53
- package/dist/{wrapper/membership.d.ts → api/user.d.ts} +59 -33
- package/dist/api/user.js +103 -0
- package/dist/api/webhook.d.ts +77 -55
- package/dist/api/webhook.js +74 -61
- package/dist/core/error.d.ts +2 -0
- package/dist/core/error.js +8 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +2 -2
- package/dist/core/response.d.ts +32 -0
- package/dist/core/response.js +26 -0
- package/dist/{webflow.d.ts → core/webflow.d.ts} +57 -52
- package/dist/{webflow.js → core/webflow.js} +102 -61
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +2 -4
- package/src/api/collection.ts +102 -35
- package/src/api/index.ts +7 -7
- package/src/api/item.ts +207 -176
- package/src/api/meta.ts +19 -18
- package/src/api/oauth.ts +62 -74
- package/src/api/site.ts +158 -55
- package/src/api/user.ts +152 -0
- package/src/api/webhook.ts +97 -80
- package/src/core/error.ts +8 -0
- package/src/core/index.ts +2 -2
- package/src/core/response.ts +50 -0
- package/src/{webflow.ts → core/webflow.ts} +132 -137
- package/src/index.ts +1 -1
- package/yarn.lock +0 -5
- package/dist/api/membership.d.ts +0 -91
- package/dist/api/membership.js +0 -80
- package/dist/core/client.d.ts +0 -40
- package/dist/core/client.js +0 -49
- package/dist/core/options.d.ts +0 -8
- package/dist/core/options.js +0 -5
- package/dist/wrapper/collection.d.ts +0 -85
- package/dist/wrapper/collection.js +0 -94
- package/dist/wrapper/index.d.ts +0 -6
- package/dist/wrapper/index.js +0 -22
- package/dist/wrapper/item.d.ts +0 -140
- package/dist/wrapper/item.js +0 -153
- package/dist/wrapper/membership.js +0 -106
- package/dist/wrapper/response.d.ts +0 -16
- package/dist/wrapper/response.js +0 -17
- package/dist/wrapper/site.d.ts +0 -119
- package/dist/wrapper/site.js +0 -136
- package/dist/wrapper/webhook.d.ts +0 -78
- package/dist/wrapper/webhook.js +0 -82
- package/src/api/membership.ts +0 -125
- package/src/core/client.ts +0 -76
- package/src/core/options.ts +0 -9
- package/src/wrapper/collection.ts +0 -115
- package/src/wrapper/index.ts +0 -6
- package/src/wrapper/item.ts +0 -218
- package/src/wrapper/membership.ts +0 -138
- package/src/wrapper/response.ts +0 -25
- package/src/wrapper/site.ts +0 -164
- package/src/wrapper/webhook.ts +0 -116
|
@@ -1,32 +1,68 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import axios, { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
2
|
+
import { PaginationFilter } from "../core";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
Collection,
|
|
5
|
+
IAccessTokenParams,
|
|
6
|
+
IAuthorizeUrlParams,
|
|
7
|
+
IRevokeTokenParams,
|
|
8
|
+
User,
|
|
9
|
+
Meta,
|
|
10
|
+
OAuth,
|
|
11
|
+
Site,
|
|
12
|
+
Webhook,
|
|
13
|
+
WebhookFilter,
|
|
14
|
+
Item,
|
|
15
|
+
} from "../api";
|
|
16
|
+
|
|
17
|
+
export const DEFAULT_HOST = "webflow.com";
|
|
18
|
+
export const USER_AGENT = "Webflow Javascript SDK / 1.0";
|
|
19
|
+
|
|
20
|
+
export interface Options {
|
|
21
|
+
host?: string;
|
|
22
|
+
token?: string;
|
|
23
|
+
version?: string;
|
|
24
|
+
headers?: Record<string, string>;
|
|
25
|
+
}
|
|
11
26
|
|
|
12
27
|
/**************************************************************
|
|
13
28
|
* Class
|
|
14
29
|
**************************************************************/
|
|
15
30
|
export class Webflow {
|
|
16
|
-
client:
|
|
17
|
-
|
|
31
|
+
private client: AxiosInstance;
|
|
18
32
|
constructor(public options: Options = {}) {
|
|
19
|
-
this.client =
|
|
33
|
+
this.client = axios.create(this.config);
|
|
20
34
|
}
|
|
21
35
|
|
|
22
36
|
// Set the Authentication token
|
|
23
37
|
set token(value: string) {
|
|
24
|
-
this.
|
|
38
|
+
this.options.token = value;
|
|
25
39
|
}
|
|
26
40
|
|
|
27
41
|
// clear the Authorization header
|
|
28
42
|
clearToken() {
|
|
29
|
-
this.
|
|
43
|
+
delete this.options.token;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// The Axios configuration
|
|
47
|
+
get config() {
|
|
48
|
+
const { host = DEFAULT_HOST, token, version, headers } = this.options;
|
|
49
|
+
|
|
50
|
+
const config: AxiosRequestConfig = {
|
|
51
|
+
baseURL: `https://api.${host}/`,
|
|
52
|
+
headers: {
|
|
53
|
+
"Content-Type": "application/json",
|
|
54
|
+
"User-Agent": USER_AGENT,
|
|
55
|
+
...headers,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// Add the version to the headers if passed in
|
|
60
|
+
if (version) config.headers["Accept-Version"] = version;
|
|
61
|
+
|
|
62
|
+
// Add the Authorization header if a token is set
|
|
63
|
+
if (token) config.headers.Authorization = `Bearer ${token}`;
|
|
64
|
+
|
|
65
|
+
return config;
|
|
30
66
|
}
|
|
31
67
|
|
|
32
68
|
/**************************************************************
|
|
@@ -39,7 +75,7 @@ export class Webflow {
|
|
|
39
75
|
* @param params The query parameters (optional)
|
|
40
76
|
* @returns The response from the Webflow API
|
|
41
77
|
*/
|
|
42
|
-
get(path: string, params?:
|
|
78
|
+
get(path: string, params?: Record<string, any>) {
|
|
43
79
|
return this.client.get(path, { params });
|
|
44
80
|
}
|
|
45
81
|
/**
|
|
@@ -48,7 +84,7 @@ export class Webflow {
|
|
|
48
84
|
* @param params The query parameters (optional)
|
|
49
85
|
* @returns The response from the Webflow API
|
|
50
86
|
*/
|
|
51
|
-
delete(path: string, params?:
|
|
87
|
+
delete(path: string, params?: Record<string, any>) {
|
|
52
88
|
return this.client.delete(path, { params });
|
|
53
89
|
}
|
|
54
90
|
/**
|
|
@@ -58,7 +94,7 @@ export class Webflow {
|
|
|
58
94
|
* @param params The query parameters (optional)
|
|
59
95
|
* @returns The response from the Webflow API
|
|
60
96
|
*/
|
|
61
|
-
post(path: string, data: any, params?:
|
|
97
|
+
post(path: string, data: any, params?: Record<string, any>) {
|
|
62
98
|
return this.client.post(path, data, { params });
|
|
63
99
|
}
|
|
64
100
|
/**
|
|
@@ -68,7 +104,7 @@ export class Webflow {
|
|
|
68
104
|
* @param params The query parameters (optional)
|
|
69
105
|
* @returns The response from the Webflow API
|
|
70
106
|
*/
|
|
71
|
-
put(path: string, data: any, params?:
|
|
107
|
+
put(path: string, data: any, params?: Record<string, any>) {
|
|
72
108
|
return this.client.put(path, data, { params });
|
|
73
109
|
}
|
|
74
110
|
/**
|
|
@@ -78,7 +114,7 @@ export class Webflow {
|
|
|
78
114
|
* @param params The query parameters (optional)
|
|
79
115
|
* @returns The response from the Webflow API
|
|
80
116
|
*/
|
|
81
|
-
patch(path: string, data: any, params?:
|
|
117
|
+
patch(path: string, data: any, params?: Record<string, any>) {
|
|
82
118
|
return this.client.patch(path, data, { params });
|
|
83
119
|
}
|
|
84
120
|
|
|
@@ -96,8 +132,8 @@ export class Webflow {
|
|
|
96
132
|
* @param params.response_type The response_type parameter (default: "code")
|
|
97
133
|
* @returns The url to redirect to
|
|
98
134
|
*/
|
|
99
|
-
authorizeUrl(params:
|
|
100
|
-
return OAuth.authorizeUrl(this.client
|
|
135
|
+
authorizeUrl(params: IAuthorizeUrlParams) {
|
|
136
|
+
return OAuth.authorizeUrl(params, this.client);
|
|
101
137
|
}
|
|
102
138
|
/**
|
|
103
139
|
* Create an OAuth Access Token
|
|
@@ -109,9 +145,9 @@ export class Webflow {
|
|
|
109
145
|
* @param params.grant_type The grant_type parameter (default: "authorization_code")
|
|
110
146
|
* @returns The access token
|
|
111
147
|
*/
|
|
112
|
-
async accessToken(params:
|
|
113
|
-
const res = await OAuth.accessToken(this.client
|
|
114
|
-
return
|
|
148
|
+
async accessToken(params: IAccessTokenParams) {
|
|
149
|
+
const res = await OAuth.accessToken(params, this.client);
|
|
150
|
+
return res.data;
|
|
115
151
|
}
|
|
116
152
|
/**
|
|
117
153
|
* Revoke an OAuth Access Token
|
|
@@ -121,9 +157,9 @@ export class Webflow {
|
|
|
121
157
|
* @param params.client_secret The client_secret parameter
|
|
122
158
|
* @returns The result of the revoked token
|
|
123
159
|
*/
|
|
124
|
-
async revokeToken(params:
|
|
125
|
-
const res = await OAuth.revokeToken(this.client
|
|
126
|
-
return
|
|
160
|
+
async revokeToken(params: IRevokeTokenParams) {
|
|
161
|
+
const res = await OAuth.revokeToken(params, this.client);
|
|
162
|
+
return res.data;
|
|
127
163
|
}
|
|
128
164
|
|
|
129
165
|
/**************************************************************
|
|
@@ -136,7 +172,7 @@ export class Webflow {
|
|
|
136
172
|
*/
|
|
137
173
|
async info() {
|
|
138
174
|
const res = await Meta.info(this.client);
|
|
139
|
-
return
|
|
175
|
+
return res.data;
|
|
140
176
|
}
|
|
141
177
|
/**
|
|
142
178
|
* Get the current authenticated user
|
|
@@ -144,7 +180,7 @@ export class Webflow {
|
|
|
144
180
|
*/
|
|
145
181
|
async authenticatedUser() {
|
|
146
182
|
const res = await Meta.user(this.client);
|
|
147
|
-
return
|
|
183
|
+
return res.data;
|
|
148
184
|
}
|
|
149
185
|
|
|
150
186
|
/**************************************************************
|
|
@@ -153,11 +189,11 @@ export class Webflow {
|
|
|
153
189
|
|
|
154
190
|
/**
|
|
155
191
|
* Get a list of Sites available
|
|
156
|
-
* @param query The query parameters (optional)
|
|
157
192
|
* @returns A list of Sites
|
|
158
193
|
*/
|
|
159
|
-
async sites(
|
|
160
|
-
|
|
194
|
+
async sites() {
|
|
195
|
+
const res = await Site.list(this.client);
|
|
196
|
+
return res.data.map((data) => new Site(this.client, { ...res, data }));
|
|
161
197
|
}
|
|
162
198
|
/**
|
|
163
199
|
* Get a single Site
|
|
@@ -166,7 +202,8 @@ export class Webflow {
|
|
|
166
202
|
* @returns The Site
|
|
167
203
|
*/
|
|
168
204
|
async site({ siteId }: { siteId: string }) {
|
|
169
|
-
|
|
205
|
+
const res = await Site.getOne({ siteId }, this.client);
|
|
206
|
+
return new Site(this.client, res);
|
|
170
207
|
}
|
|
171
208
|
/**
|
|
172
209
|
* Publish a Site
|
|
@@ -175,8 +212,9 @@ export class Webflow {
|
|
|
175
212
|
* @param params.domain The domains to publish
|
|
176
213
|
* @returns The result of the publish
|
|
177
214
|
*/
|
|
178
|
-
publishSite({ siteId, domains }: { siteId: string } & { domains: string[] }) {
|
|
179
|
-
|
|
215
|
+
async publishSite({ siteId, domains }: { siteId: string } & { domains: string[] }) {
|
|
216
|
+
const res = await Site.publish({ siteId, domains }, this.client);
|
|
217
|
+
return res.data;
|
|
180
218
|
}
|
|
181
219
|
/**
|
|
182
220
|
* Get a list of Domains for a Site
|
|
@@ -185,7 +223,8 @@ export class Webflow {
|
|
|
185
223
|
* @returns A list of Domains
|
|
186
224
|
*/
|
|
187
225
|
async domains({ siteId }: { siteId: string }) {
|
|
188
|
-
|
|
226
|
+
const res = await Site.domains({ siteId }, this.client);
|
|
227
|
+
return res.data;
|
|
189
228
|
}
|
|
190
229
|
|
|
191
230
|
/**************************************************************
|
|
@@ -196,11 +235,11 @@ export class Webflow {
|
|
|
196
235
|
* Get a list of Collections
|
|
197
236
|
* @param params The Site information
|
|
198
237
|
* @param params.siteId The Site ID
|
|
199
|
-
* @param query The query parameters (optional)
|
|
200
238
|
* @returns A list of Collections
|
|
201
239
|
*/
|
|
202
|
-
async collections({ siteId }: { siteId: string }
|
|
203
|
-
|
|
240
|
+
async collections({ siteId }: { siteId: string }) {
|
|
241
|
+
const res = await Collection.list({ siteId }, this.client);
|
|
242
|
+
return res.data.map((data) => new Collection(this.client, { ...res, data }));
|
|
204
243
|
}
|
|
205
244
|
/**
|
|
206
245
|
* Get a single Collection
|
|
@@ -209,7 +248,8 @@ export class Webflow {
|
|
|
209
248
|
* @returns A single Collection
|
|
210
249
|
*/
|
|
211
250
|
async collection({ collectionId }: { collectionId: string }) {
|
|
212
|
-
|
|
251
|
+
const res = await Collection.getOne({ collectionId }, this.client);
|
|
252
|
+
return new Collection(this.client, res);
|
|
213
253
|
}
|
|
214
254
|
|
|
215
255
|
/**************************************************************
|
|
@@ -220,14 +260,13 @@ export class Webflow {
|
|
|
220
260
|
* Get a list of Collection Items
|
|
221
261
|
* @param params The Collection information
|
|
222
262
|
* @param params.collectionId The Collection ID
|
|
223
|
-
* @param
|
|
263
|
+
* @param params.limit The number of items to return
|
|
264
|
+
* @param params.offset The number of items to skip
|
|
224
265
|
* @returns A list of Items
|
|
225
266
|
*/
|
|
226
|
-
async items(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
) {
|
|
230
|
-
return ItemWrapper.list(this.client, { collectionId, ...pageParams });
|
|
267
|
+
async items({ collectionId, limit, offset }: { collectionId: string } & PaginationFilter) {
|
|
268
|
+
const res = await Item.list({ collectionId, limit, offset }, this.client);
|
|
269
|
+
return res.data.items.map((data) => new Item(this.client, { ...res, data }));
|
|
231
270
|
}
|
|
232
271
|
/**
|
|
233
272
|
* Get a single Collection Item
|
|
@@ -236,14 +275,10 @@ export class Webflow {
|
|
|
236
275
|
* @param params.itemId The Item ID
|
|
237
276
|
* @returns A single Collection Item
|
|
238
277
|
*/
|
|
239
|
-
async item({
|
|
240
|
-
itemId,
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
itemId: string;
|
|
244
|
-
collectionId: string;
|
|
245
|
-
}) {
|
|
246
|
-
return ItemWrapper.getOne(this.client, { itemId, collectionId });
|
|
278
|
+
async item({ itemId, collectionId }: { itemId: string; collectionId: string }) {
|
|
279
|
+
const res = await Item.getOne({ itemId, collectionId }, this.client);
|
|
280
|
+
const [item] = res.data.items.map((data) => new Item(this.client, { ...res, data }));
|
|
281
|
+
return item;
|
|
247
282
|
}
|
|
248
283
|
/**
|
|
249
284
|
* Create a new Collection Item
|
|
@@ -251,14 +286,9 @@ export class Webflow {
|
|
|
251
286
|
* @param params.collectionId The Collection ID
|
|
252
287
|
* @returns The created Collection Item
|
|
253
288
|
*/
|
|
254
|
-
async createItem({
|
|
255
|
-
collectionId,
|
|
256
|
-
|
|
257
|
-
}: {
|
|
258
|
-
collectionId: string;
|
|
259
|
-
fields: any;
|
|
260
|
-
}) {
|
|
261
|
-
return ItemWrapper.create(this.client, { collectionId, fields });
|
|
289
|
+
async createItem({ collectionId, fields }: { collectionId: string; fields: any }) {
|
|
290
|
+
const res = await Item.create({ collectionId, fields }, this.client);
|
|
291
|
+
return new Item(this.client, res);
|
|
262
292
|
}
|
|
263
293
|
/**
|
|
264
294
|
* Update a Collection Item
|
|
@@ -268,35 +298,22 @@ export class Webflow {
|
|
|
268
298
|
* @param query The query parameters (optional)
|
|
269
299
|
* @returns The updated Collection Item
|
|
270
300
|
*/
|
|
271
|
-
updateItem({
|
|
272
|
-
collectionId,
|
|
273
|
-
itemId,
|
|
274
|
-
...fields
|
|
275
|
-
}: {
|
|
276
|
-
itemId: string;
|
|
277
|
-
collectionId: string;
|
|
278
|
-
}) {
|
|
301
|
+
async updateItem({ collectionId, itemId, ...fields }: { itemId: string; collectionId: string }) {
|
|
279
302
|
const _params = { collectionId, itemId, fields };
|
|
280
|
-
|
|
303
|
+
const res = await Item.update(_params, this.client);
|
|
304
|
+
return new Item(this.client, res);
|
|
281
305
|
}
|
|
282
306
|
/**
|
|
283
307
|
* Patch a Collection Item
|
|
284
308
|
* @param params The Item information
|
|
285
309
|
* @param params.collectionId The Collection ID
|
|
286
310
|
* @param params.itemId The Item ID
|
|
287
|
-
* @param query The query parameters (optional)
|
|
288
311
|
* @returns The patched Collection Item
|
|
289
312
|
*/
|
|
290
|
-
patchItem(
|
|
291
|
-
{
|
|
292
|
-
collectionId,
|
|
293
|
-
itemId,
|
|
294
|
-
...fields
|
|
295
|
-
}: { collectionId: string; itemId: string },
|
|
296
|
-
query?: QueryString
|
|
297
|
-
) {
|
|
313
|
+
async patchItem({ collectionId, itemId, ...fields }: { collectionId: string; itemId: string }) {
|
|
298
314
|
const _params = { collectionId, itemId, fields };
|
|
299
|
-
|
|
315
|
+
const res = await Item.patch(_params, this.client);
|
|
316
|
+
return new Item(this.client, res);
|
|
300
317
|
}
|
|
301
318
|
/**
|
|
302
319
|
* Delete a Collection Item
|
|
@@ -305,56 +322,33 @@ export class Webflow {
|
|
|
305
322
|
* @param params.itemId The Item ID
|
|
306
323
|
* @returns The deleted Collection Item result
|
|
307
324
|
*/
|
|
308
|
-
removeItem({
|
|
309
|
-
collectionId,
|
|
310
|
-
|
|
311
|
-
}: {
|
|
312
|
-
itemId: string;
|
|
313
|
-
collectionId: string;
|
|
314
|
-
}) {
|
|
315
|
-
return ItemWrapper.remove(this.client, { collectionId, itemId });
|
|
325
|
+
async removeItem({ collectionId, itemId }: { itemId: string; collectionId: string }) {
|
|
326
|
+
const res = await Item.remove({ collectionId, itemId }, this.client);
|
|
327
|
+
return res.data;
|
|
316
328
|
}
|
|
317
329
|
/**
|
|
318
330
|
* Upublish a Collection Item
|
|
319
331
|
* @param params The Item information
|
|
320
332
|
* @param params.collectionId The Collection ID
|
|
321
333
|
* @param params.itemId The Item ID
|
|
322
|
-
* @param
|
|
323
|
-
* @param query.live Update the live version
|
|
334
|
+
* @param params.live Update the live version
|
|
324
335
|
* @returns The unpublished Collection Item result
|
|
325
336
|
*/
|
|
326
|
-
deleteItems({
|
|
327
|
-
collectionId,
|
|
328
|
-
|
|
329
|
-
live,
|
|
330
|
-
}: {
|
|
331
|
-
collectionId: string;
|
|
332
|
-
itemIds: string[];
|
|
333
|
-
live?: boolean;
|
|
334
|
-
}) {
|
|
335
|
-
const params = { collectionId, itemIds, live };
|
|
336
|
-
return ItemWrapper.unpublish(this.client, params);
|
|
337
|
+
async deleteItems({ collectionId, itemIds, live }: { collectionId: string; itemIds: string[]; live?: boolean }) {
|
|
338
|
+
const res = await Item.unpublish({ collectionId, itemIds, live }, this.client);
|
|
339
|
+
return res.data;
|
|
337
340
|
}
|
|
338
341
|
/**
|
|
339
342
|
* Publish a Collection Item
|
|
340
343
|
* @param params The Item information
|
|
341
344
|
* @param params.collectionId The Collection ID
|
|
342
345
|
* @param params.itemId The Item ID
|
|
343
|
-
* @param
|
|
344
|
-
* @param query.live Update the live version
|
|
346
|
+
* @param params.live Update the live version
|
|
345
347
|
* @returns The Published Collection Item result
|
|
346
348
|
*/
|
|
347
|
-
publishItems({
|
|
348
|
-
collectionId,
|
|
349
|
-
|
|
350
|
-
live,
|
|
351
|
-
}: {
|
|
352
|
-
collectionId: string;
|
|
353
|
-
itemIds: string[];
|
|
354
|
-
live?: boolean;
|
|
355
|
-
}) {
|
|
356
|
-
const params = { collectionId, itemIds, live };
|
|
357
|
-
return ItemWrapper.publish(this.client, params);
|
|
349
|
+
async publishItems({ collectionId, itemIds, live }: { collectionId: string; itemIds: string[]; live?: boolean }) {
|
|
350
|
+
const res = await Item.publish({ collectionId, itemIds, live }, this.client);
|
|
351
|
+
return res.data;
|
|
358
352
|
}
|
|
359
353
|
|
|
360
354
|
/**************************************************************
|
|
@@ -369,7 +363,8 @@ export class Webflow {
|
|
|
369
363
|
* @returns A list of User accounts
|
|
370
364
|
*/
|
|
371
365
|
async users({ siteId }: { siteId: string }, pageParams?: PaginationFilter) {
|
|
372
|
-
|
|
366
|
+
const res = await User.list({ siteId, ...pageParams }, this.client);
|
|
367
|
+
return res.data.users.map((data) => new User(this.client, { ...res, data }));
|
|
373
368
|
}
|
|
374
369
|
|
|
375
370
|
/**
|
|
@@ -380,7 +375,8 @@ export class Webflow {
|
|
|
380
375
|
* @returns The User information
|
|
381
376
|
*/
|
|
382
377
|
async user({ siteId, userId }: { siteId: string; userId: string }) {
|
|
383
|
-
|
|
378
|
+
const res = await User.getOne({ siteId, userId }, this.client);
|
|
379
|
+
return new User(this.client, res, res.data, { siteId });
|
|
384
380
|
}
|
|
385
381
|
|
|
386
382
|
/**
|
|
@@ -390,17 +386,10 @@ export class Webflow {
|
|
|
390
386
|
* @param params.userId The User ID
|
|
391
387
|
* @returns The updated User
|
|
392
388
|
*/
|
|
393
|
-
async updateUser({
|
|
394
|
-
siteId,
|
|
395
|
-
userId,
|
|
396
|
-
...data
|
|
397
|
-
}: {
|
|
398
|
-
siteId: string;
|
|
399
|
-
userId: string;
|
|
400
|
-
data: any;
|
|
401
|
-
}) {
|
|
389
|
+
async updateUser({ siteId, userId, ...data }: { siteId: string; userId: string; data: any }) {
|
|
402
390
|
const _params = { siteId, userId, data };
|
|
403
|
-
|
|
391
|
+
const res = await User.update(_params, this.client);
|
|
392
|
+
return new User(this.client, res, res.data, { siteId });
|
|
404
393
|
}
|
|
405
394
|
|
|
406
395
|
/**
|
|
@@ -411,7 +400,8 @@ export class Webflow {
|
|
|
411
400
|
* @returns The created User account
|
|
412
401
|
*/
|
|
413
402
|
async inviteUser({ siteId, email }: { siteId: string; email: string }) {
|
|
414
|
-
|
|
403
|
+
const res = await User.invite({ siteId, email }, this.client);
|
|
404
|
+
return new User(this.client, res, res.data, { siteId });
|
|
415
405
|
}
|
|
416
406
|
|
|
417
407
|
/**
|
|
@@ -421,8 +411,9 @@ export class Webflow {
|
|
|
421
411
|
* @param params.userId The User ID
|
|
422
412
|
* @returns The result from the remove request
|
|
423
413
|
*/
|
|
424
|
-
removeUser({ siteId, userId }: { siteId: string; userId: string }) {
|
|
425
|
-
|
|
414
|
+
async removeUser({ siteId, userId }: { siteId: string; userId: string }) {
|
|
415
|
+
const res = await User.remove({ siteId, userId }, this.client);
|
|
416
|
+
return res.data;
|
|
426
417
|
}
|
|
427
418
|
|
|
428
419
|
/**************************************************************
|
|
@@ -435,8 +426,9 @@ export class Webflow {
|
|
|
435
426
|
* @param params.siteId The Site ID
|
|
436
427
|
* @returns A list of Webhooks
|
|
437
428
|
*/
|
|
438
|
-
async webhooks({ siteId }: { siteId: string }
|
|
439
|
-
|
|
429
|
+
async webhooks({ siteId }: { siteId: string }) {
|
|
430
|
+
const res = await Webhook.list({ siteId }, this.client);
|
|
431
|
+
return res.data.map((data) => new Webhook(this.client, { ...res, data }));
|
|
440
432
|
}
|
|
441
433
|
|
|
442
434
|
/**
|
|
@@ -447,7 +439,8 @@ export class Webflow {
|
|
|
447
439
|
* @returns The Webhook
|
|
448
440
|
*/
|
|
449
441
|
async webhook({ siteId, webhookId }: { siteId: string; webhookId: string }) {
|
|
450
|
-
|
|
442
|
+
const res = await Webhook.getOne({ siteId, webhookId }, this.client);
|
|
443
|
+
return new Webhook(this.client, res);
|
|
451
444
|
}
|
|
452
445
|
|
|
453
446
|
/**
|
|
@@ -457,8 +450,9 @@ export class Webflow {
|
|
|
457
450
|
* @param params.webhookId The Webhook Id
|
|
458
451
|
* @returns the result from the remove request
|
|
459
452
|
*/
|
|
460
|
-
removeWebhook({ siteId, webhookId }: { siteId: string; webhookId: string }) {
|
|
461
|
-
|
|
453
|
+
async removeWebhook({ siteId, webhookId }: { siteId: string; webhookId: string }) {
|
|
454
|
+
const res = await Webhook.remove({ siteId, webhookId }, this.client);
|
|
455
|
+
return res.data;
|
|
462
456
|
}
|
|
463
457
|
|
|
464
458
|
/**
|
|
@@ -479,9 +473,10 @@ export class Webflow {
|
|
|
479
473
|
url: string;
|
|
480
474
|
siteId: string;
|
|
481
475
|
triggerType: string;
|
|
482
|
-
filter?:
|
|
476
|
+
filter?: WebhookFilter;
|
|
483
477
|
}) {
|
|
484
478
|
const _params = { url, siteId, triggerType, filter };
|
|
485
|
-
|
|
479
|
+
const res = await Webhook.create(_params, this.client);
|
|
480
|
+
return new Webhook(this.client, res);
|
|
486
481
|
}
|
|
487
482
|
}
|
package/src/index.ts
CHANGED
package/yarn.lock
CHANGED
|
@@ -654,11 +654,6 @@
|
|
|
654
654
|
dependencies:
|
|
655
655
|
"@types/node" "*"
|
|
656
656
|
|
|
657
|
-
"@types/isomorphic-fetch@^0.0.36":
|
|
658
|
-
"integrity" "sha512-ulw4d+vW1HKn4oErSmNN2HYEcHGq0N1C5exlrMM0CRqX1UUpFhGb5lwiom5j9KN3LBJJDLRmYIZz1ghm7FIzZw=="
|
|
659
|
-
"resolved" "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.36.tgz"
|
|
660
|
-
"version" "0.0.36"
|
|
661
|
-
|
|
662
657
|
"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1":
|
|
663
658
|
"integrity" "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g=="
|
|
664
659
|
"resolved" "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz"
|
package/dist/api/membership.d.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { Client, PaginatedData } from "../core";
|
|
2
|
-
/**************************************************************
|
|
3
|
-
* Interfaces
|
|
4
|
-
**************************************************************/
|
|
5
|
-
export interface IUser {
|
|
6
|
-
emailVerified: boolean;
|
|
7
|
-
lastUpdated?: string;
|
|
8
|
-
createdOn: string;
|
|
9
|
-
_id: string;
|
|
10
|
-
data: any;
|
|
11
|
-
}
|
|
12
|
-
export interface IUserDelete {
|
|
13
|
-
deleted: number;
|
|
14
|
-
}
|
|
15
|
-
/**************************************************************
|
|
16
|
-
* Types
|
|
17
|
-
**************************************************************/
|
|
18
|
-
export declare type PaginatedUsers = PaginatedData & {
|
|
19
|
-
users: IUser[];
|
|
20
|
-
};
|
|
21
|
-
export declare type UserIdParam = {
|
|
22
|
-
siteId: string;
|
|
23
|
-
userId: string;
|
|
24
|
-
};
|
|
25
|
-
/**************************************************************
|
|
26
|
-
* Functions
|
|
27
|
-
**************************************************************/
|
|
28
|
-
/**
|
|
29
|
-
* Get a list of Users
|
|
30
|
-
* @param client The Webflow client
|
|
31
|
-
* @param params The params for the request
|
|
32
|
-
* @param params.siteId The site ID
|
|
33
|
-
* @param params.limit The number of items to return (optional)
|
|
34
|
-
* @param params.offset The number of items to skip (optional)
|
|
35
|
-
* @returns A list of Users
|
|
36
|
-
*/
|
|
37
|
-
export declare function list(client: Client, { siteId, limit, offset }: {
|
|
38
|
-
siteId: string;
|
|
39
|
-
limit?: number;
|
|
40
|
-
offset?: number;
|
|
41
|
-
}): Promise<import("axios").AxiosResponse<PaginatedUsers, any>>;
|
|
42
|
-
/**
|
|
43
|
-
* Get a single User
|
|
44
|
-
* @param client The Webflow client
|
|
45
|
-
* @param params The params for the request
|
|
46
|
-
* @param params.siteId The site ID
|
|
47
|
-
* @param params.userId The user ID
|
|
48
|
-
* @returns A single User
|
|
49
|
-
*/
|
|
50
|
-
export declare function getOne(client: Client, { siteId, userId }: {
|
|
51
|
-
siteId: string;
|
|
52
|
-
userId: string;
|
|
53
|
-
}): Promise<import("axios").AxiosResponse<IUser, any>>;
|
|
54
|
-
/**
|
|
55
|
-
* Update a User
|
|
56
|
-
* @param client The Webflow client
|
|
57
|
-
* @param params The params for the request
|
|
58
|
-
* @param params.siteId The site ID
|
|
59
|
-
* @param params.userId The user ID
|
|
60
|
-
* @param params.data The data to update
|
|
61
|
-
* @returns The updated User
|
|
62
|
-
*/
|
|
63
|
-
export declare function update(client: Client, { siteId, userId, data, }: {
|
|
64
|
-
data: object;
|
|
65
|
-
siteId: string;
|
|
66
|
-
userId: string;
|
|
67
|
-
}): Promise<import("axios").AxiosResponse<IUser, any>>;
|
|
68
|
-
/**
|
|
69
|
-
* Invite a User to a site
|
|
70
|
-
* @param client The Webflow client
|
|
71
|
-
* @param params The params for the request
|
|
72
|
-
* @param params.siteId The site ID
|
|
73
|
-
* @param params.email The email address of the user to invite
|
|
74
|
-
* @returns The newly created User
|
|
75
|
-
*/
|
|
76
|
-
export declare function invite(client: Client, { siteId, email }: {
|
|
77
|
-
siteId: string;
|
|
78
|
-
email: string;
|
|
79
|
-
}): Promise<import("axios").AxiosResponse<IUser, any>>;
|
|
80
|
-
/**
|
|
81
|
-
* Remove a User
|
|
82
|
-
* @param client The Webflow client
|
|
83
|
-
* @param params The params for the request
|
|
84
|
-
* @param params.siteId The site ID
|
|
85
|
-
* @param params.userId The user ID
|
|
86
|
-
* @returns The result of the remove
|
|
87
|
-
*/
|
|
88
|
-
export declare function remove(client: Client, { siteId, userId }: {
|
|
89
|
-
siteId: string;
|
|
90
|
-
userId: string;
|
|
91
|
-
}): Promise<import("axios").AxiosResponse<IUserDelete, any>>;
|