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
package/dist/webflow.js
ADDED
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Webflow = void 0;
|
|
4
|
+
const core_1 = require("./core");
|
|
5
|
+
const api_1 = require("./api");
|
|
6
|
+
const wrapper_1 = require("./wrapper");
|
|
7
|
+
/**************************************************************
|
|
8
|
+
* Class
|
|
9
|
+
**************************************************************/
|
|
10
|
+
class Webflow {
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
this.options = options;
|
|
13
|
+
this.client = new core_1.Client(options);
|
|
14
|
+
}
|
|
15
|
+
// Set the Authentication token
|
|
16
|
+
set token(value) {
|
|
17
|
+
this.client.token = value;
|
|
18
|
+
}
|
|
19
|
+
// clear the Authorization header
|
|
20
|
+
clearToken() {
|
|
21
|
+
this.client.clearToken();
|
|
22
|
+
}
|
|
23
|
+
/**************************************************************
|
|
24
|
+
* HTTP Methods
|
|
25
|
+
**************************************************************/
|
|
26
|
+
/**
|
|
27
|
+
* Send a GET request to the Webflow API
|
|
28
|
+
* @param path The path to the endpoint
|
|
29
|
+
* @param params The query parameters (optional)
|
|
30
|
+
* @returns The response from the Webflow API
|
|
31
|
+
*/
|
|
32
|
+
get(path, params) {
|
|
33
|
+
return this.client.get(path, { params });
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Send a DELETE request to the Webflow API
|
|
37
|
+
* @param path The path to the endpoint
|
|
38
|
+
* @param params The query parameters (optional)
|
|
39
|
+
* @returns The response from the Webflow API
|
|
40
|
+
*/
|
|
41
|
+
delete(path, params) {
|
|
42
|
+
return this.client.delete(path, { params });
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Send a POST request to create a new Collection
|
|
46
|
+
* @param path The path to the endpoint
|
|
47
|
+
* @param data The data to send
|
|
48
|
+
* @param params The query parameters (optional)
|
|
49
|
+
* @returns The response from the Webflow API
|
|
50
|
+
*/
|
|
51
|
+
post(path, data, params) {
|
|
52
|
+
return this.client.post(path, data, { params });
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Send a PUT request to create a new Collection
|
|
56
|
+
* @param path The path to the endpoint
|
|
57
|
+
* @param data The data to send
|
|
58
|
+
* @param params The query parameters (optional)
|
|
59
|
+
* @returns The response from the Webflow API
|
|
60
|
+
*/
|
|
61
|
+
put(path, data, params) {
|
|
62
|
+
return this.client.put(path, data, { params });
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Send a PATCH request to create a new Collection
|
|
66
|
+
* @param path The path to the endpoint
|
|
67
|
+
* @param data The data to send
|
|
68
|
+
* @param params The query parameters (optional)
|
|
69
|
+
* @returns The response from the Webflow API
|
|
70
|
+
*/
|
|
71
|
+
patch(path, data, params) {
|
|
72
|
+
return this.client.patch(path, data, { params });
|
|
73
|
+
}
|
|
74
|
+
/**************************************************************
|
|
75
|
+
* OAuth Endpoints
|
|
76
|
+
**************************************************************/
|
|
77
|
+
/**
|
|
78
|
+
* Create an OAuth Authorization url
|
|
79
|
+
* @param params The OAuth information
|
|
80
|
+
* @param params.state The state parameter (optional)
|
|
81
|
+
* @param params.scope The scope parameter (optional)
|
|
82
|
+
* @param params.client_id The client_id parameter (optional)
|
|
83
|
+
* @param params.redirect_uri The redirect_uri parameter (optional)
|
|
84
|
+
* @param params.response_type The response_type parameter (default: "code")
|
|
85
|
+
* @returns The url to redirect to
|
|
86
|
+
*/
|
|
87
|
+
authorizeUrl(params) {
|
|
88
|
+
return api_1.OAuth.authorizeUrl(this.client, params);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Create an OAuth Access Token
|
|
92
|
+
* @param params The OAuth information
|
|
93
|
+
* @param params.code The code parameter
|
|
94
|
+
* @param params.client_id The client_id parameter
|
|
95
|
+
* @param params.client_secret The client_secret parameter
|
|
96
|
+
* @param params.redirect_uri The redirect_uri parameter (optional)
|
|
97
|
+
* @param params.grant_type The grant_type parameter (default: "authorization_code")
|
|
98
|
+
* @returns The access token
|
|
99
|
+
*/
|
|
100
|
+
async accessToken(params) {
|
|
101
|
+
const res = await api_1.OAuth.accessToken(this.client, params);
|
|
102
|
+
return (0, wrapper_1.ResponseWrapper)(res);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Revoke an OAuth Access Token
|
|
106
|
+
* @param params The access token information
|
|
107
|
+
* @param params.access_token The access token
|
|
108
|
+
* @param params.client_id The client_id parameter
|
|
109
|
+
* @param params.client_secret The client_secret parameter
|
|
110
|
+
* @returns The result of the revoked token
|
|
111
|
+
*/
|
|
112
|
+
async revokeToken(params) {
|
|
113
|
+
const res = await api_1.OAuth.revokeToken(this.client, params);
|
|
114
|
+
return (0, wrapper_1.ResponseWrapper)(res);
|
|
115
|
+
}
|
|
116
|
+
/**************************************************************
|
|
117
|
+
* Meta Endpoints
|
|
118
|
+
**************************************************************/
|
|
119
|
+
/**
|
|
120
|
+
* Get the current authorization information
|
|
121
|
+
* @returns The authorization information
|
|
122
|
+
*/
|
|
123
|
+
async info() {
|
|
124
|
+
const res = await api_1.Meta.info(this.client);
|
|
125
|
+
return (0, wrapper_1.ResponseWrapper)(res);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Get the current authenticated user
|
|
129
|
+
* @returns The current authenticated user
|
|
130
|
+
*/
|
|
131
|
+
async authenticatedUser() {
|
|
132
|
+
const res = await api_1.Meta.user(this.client);
|
|
133
|
+
return (0, wrapper_1.ResponseWrapper)(res);
|
|
134
|
+
}
|
|
135
|
+
/**************************************************************
|
|
136
|
+
* Site Endpoints
|
|
137
|
+
**************************************************************/
|
|
138
|
+
/**
|
|
139
|
+
* Get a list of Sites available
|
|
140
|
+
* @param query The query parameters (optional)
|
|
141
|
+
* @returns A list of Sites
|
|
142
|
+
*/
|
|
143
|
+
async sites(query) {
|
|
144
|
+
return wrapper_1.SiteWrapper.list(this.client, query);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get a single Site
|
|
148
|
+
* @param params The Site information
|
|
149
|
+
* @param params.siteId The Site ID
|
|
150
|
+
* @returns The Site
|
|
151
|
+
*/
|
|
152
|
+
async site({ siteId }) {
|
|
153
|
+
return wrapper_1.SiteWrapper.getOne(this.client, { siteId });
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Publish a Site
|
|
157
|
+
* @param params The Site information
|
|
158
|
+
* @param params.siteId The Site ID
|
|
159
|
+
* @param params.domain The domains to publish
|
|
160
|
+
* @returns The result of the publish
|
|
161
|
+
*/
|
|
162
|
+
publishSite({ siteId, domains }) {
|
|
163
|
+
return wrapper_1.SiteWrapper.publish(this.client, { siteId, domains });
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Get a list of Domains for a Site
|
|
167
|
+
* @param params The Site information
|
|
168
|
+
* @param params.siteId The Site ID
|
|
169
|
+
* @returns A list of Domains
|
|
170
|
+
*/
|
|
171
|
+
async domains({ siteId }) {
|
|
172
|
+
return wrapper_1.SiteWrapper.domains(this.client, { siteId });
|
|
173
|
+
}
|
|
174
|
+
/**************************************************************
|
|
175
|
+
* Collection Endpoints
|
|
176
|
+
**************************************************************/
|
|
177
|
+
/**
|
|
178
|
+
* Get a list of Collections
|
|
179
|
+
* @param params The Site information
|
|
180
|
+
* @param params.siteId The Site ID
|
|
181
|
+
* @param query The query parameters (optional)
|
|
182
|
+
* @returns A list of Collections
|
|
183
|
+
*/
|
|
184
|
+
async collections({ siteId }, query) {
|
|
185
|
+
return wrapper_1.CollectionWrapper.list(this.client, { siteId }, query);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Get a single Collection
|
|
189
|
+
* @param params The Collection information
|
|
190
|
+
* @param params.collectionId The Collection ID
|
|
191
|
+
* @returns A single Collection
|
|
192
|
+
*/
|
|
193
|
+
async collection({ collectionId }) {
|
|
194
|
+
return wrapper_1.CollectionWrapper.getOne(this.client, { collectionId });
|
|
195
|
+
}
|
|
196
|
+
/**************************************************************
|
|
197
|
+
* Item Endpoints
|
|
198
|
+
**************************************************************/
|
|
199
|
+
/**
|
|
200
|
+
* Get a list of Collection Items
|
|
201
|
+
* @param params The Collection information
|
|
202
|
+
* @param params.collectionId The Collection ID
|
|
203
|
+
* @param pageParams The pagination parameters (optional)
|
|
204
|
+
* @returns A list of Items
|
|
205
|
+
*/
|
|
206
|
+
async items({ collectionId }, pageParams) {
|
|
207
|
+
return wrapper_1.ItemWrapper.list(this.client, { collectionId, ...pageParams });
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Get a single Collection Item
|
|
211
|
+
* @param params The Item information
|
|
212
|
+
* @param params.collectionId The Collection ID
|
|
213
|
+
* @param params.itemId The Item ID
|
|
214
|
+
* @returns A single Collection Item
|
|
215
|
+
*/
|
|
216
|
+
async item({ itemId, collectionId, }) {
|
|
217
|
+
return wrapper_1.ItemWrapper.getOne(this.client, { itemId, collectionId });
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Create a new Collection Item
|
|
221
|
+
* @param params The Item information
|
|
222
|
+
* @param params.collectionId The Collection ID
|
|
223
|
+
* @returns The created Collection Item
|
|
224
|
+
*/
|
|
225
|
+
async createItem({ collectionId, fields, }) {
|
|
226
|
+
return wrapper_1.ItemWrapper.create(this.client, { collectionId, fields });
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Update a Collection Item
|
|
230
|
+
* @param params The Item information
|
|
231
|
+
* @param params.collectionId The Collection ID
|
|
232
|
+
* @param params.itemId The Item ID
|
|
233
|
+
* @param query The query parameters (optional)
|
|
234
|
+
* @returns The updated Collection Item
|
|
235
|
+
*/
|
|
236
|
+
updateItem({ collectionId, itemId, ...fields }) {
|
|
237
|
+
const _params = { collectionId, itemId, fields };
|
|
238
|
+
return wrapper_1.ItemWrapper.update(this.client, _params);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Patch a Collection Item
|
|
242
|
+
* @param params The Item information
|
|
243
|
+
* @param params.collectionId The Collection ID
|
|
244
|
+
* @param params.itemId The Item ID
|
|
245
|
+
* @param query The query parameters (optional)
|
|
246
|
+
* @returns The patched Collection Item
|
|
247
|
+
*/
|
|
248
|
+
patchItem({ collectionId, itemId, ...fields }, query) {
|
|
249
|
+
const _params = { collectionId, itemId, fields };
|
|
250
|
+
return wrapper_1.ItemWrapper.patch(this.client, _params, query);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Delete a Collection Item
|
|
254
|
+
* @param params The Item information
|
|
255
|
+
* @param params.collectionId The Collection ID
|
|
256
|
+
* @param params.itemId The Item ID
|
|
257
|
+
* @returns The deleted Collection Item result
|
|
258
|
+
*/
|
|
259
|
+
removeItem({ collectionId, itemId, }) {
|
|
260
|
+
return wrapper_1.ItemWrapper.remove(this.client, { collectionId, itemId });
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Upublish a Collection Item
|
|
264
|
+
* @param params The Item information
|
|
265
|
+
* @param params.collectionId The Collection ID
|
|
266
|
+
* @param params.itemId The Item ID
|
|
267
|
+
* @param query The query parameters (optional)
|
|
268
|
+
* @param query.live Update the live version
|
|
269
|
+
* @returns The unpublished Collection Item result
|
|
270
|
+
*/
|
|
271
|
+
deleteItems({ collectionId, itemIds, live, }) {
|
|
272
|
+
const params = { collectionId, itemIds, live };
|
|
273
|
+
return wrapper_1.ItemWrapper.unpublish(this.client, params);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Publish a Collection Item
|
|
277
|
+
* @param params The Item information
|
|
278
|
+
* @param params.collectionId The Collection ID
|
|
279
|
+
* @param params.itemId The Item ID
|
|
280
|
+
* @param query The query parameters (optional)
|
|
281
|
+
* @param query.live Update the live version
|
|
282
|
+
* @returns The Published Collection Item result
|
|
283
|
+
*/
|
|
284
|
+
publishItems({ collectionId, itemIds, live, }) {
|
|
285
|
+
const params = { collectionId, itemIds, live };
|
|
286
|
+
return wrapper_1.ItemWrapper.publish(this.client, params);
|
|
287
|
+
}
|
|
288
|
+
/**************************************************************
|
|
289
|
+
* Membership Endpoints
|
|
290
|
+
**************************************************************/
|
|
291
|
+
/**
|
|
292
|
+
* Get a list of User accounts
|
|
293
|
+
* @param params The Site information
|
|
294
|
+
* @param params.siteId The Site ID
|
|
295
|
+
* @param pageParams The pagination information (optional)
|
|
296
|
+
* @returns A list of User accounts
|
|
297
|
+
*/
|
|
298
|
+
async users({ siteId }, pageParams) {
|
|
299
|
+
return wrapper_1.MembershipWrapper.list(this.client, { siteId, ...pageParams });
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Get a single User account
|
|
303
|
+
* @param param The Site and User information
|
|
304
|
+
* @param param.siteId The Site ID
|
|
305
|
+
* @param param.userId The User ID
|
|
306
|
+
* @returns The User information
|
|
307
|
+
*/
|
|
308
|
+
async user({ siteId, userId }) {
|
|
309
|
+
return wrapper_1.MembershipWrapper.getOne(this.client, { siteId, userId });
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Update a User account
|
|
313
|
+
* @param params The Site and User information
|
|
314
|
+
* @param params.siteId The Site ID
|
|
315
|
+
* @param params.userId The User ID
|
|
316
|
+
* @returns The updated User
|
|
317
|
+
*/
|
|
318
|
+
async updateUser({ siteId, userId, ...data }) {
|
|
319
|
+
const _params = { siteId, userId, data };
|
|
320
|
+
return wrapper_1.MembershipWrapper.update(this.client, _params);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Invite a User to a Site
|
|
324
|
+
* @param params The Site and User information
|
|
325
|
+
* @param params.siteId The Site ID
|
|
326
|
+
* @param params.email The User's email address
|
|
327
|
+
* @returns The created User account
|
|
328
|
+
*/
|
|
329
|
+
async inviteUser({ siteId, email }) {
|
|
330
|
+
return wrapper_1.MembershipWrapper.invite(this.client, { siteId, email });
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Remove a user from a Site
|
|
334
|
+
* @param params The Site and User information
|
|
335
|
+
* @param params.siteId The Site ID
|
|
336
|
+
* @param params.userId The User ID
|
|
337
|
+
* @returns The result from the remove request
|
|
338
|
+
*/
|
|
339
|
+
removeUser({ siteId, userId }) {
|
|
340
|
+
return wrapper_1.MembershipWrapper.remove(this.client, { siteId, userId });
|
|
341
|
+
}
|
|
342
|
+
/**************************************************************
|
|
343
|
+
* Webhook Endpoints
|
|
344
|
+
**************************************************************/
|
|
345
|
+
/**
|
|
346
|
+
* Get a list of webhooks for a Site
|
|
347
|
+
* @param params The site information to get the Webhooks from
|
|
348
|
+
* @param params.siteId The Site ID
|
|
349
|
+
* @returns A list of Webhooks
|
|
350
|
+
*/
|
|
351
|
+
async webhooks({ siteId }, query) {
|
|
352
|
+
return wrapper_1.WebhookWrapper.list(this.client, { siteId }, query);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Get a single Webhook
|
|
356
|
+
* @param params The Webhook and Site information
|
|
357
|
+
* @param params.siteId The Site Id
|
|
358
|
+
* @param params.webhookId The Webhook Id
|
|
359
|
+
* @returns The Webhook
|
|
360
|
+
*/
|
|
361
|
+
async webhook({ siteId, webhookId }) {
|
|
362
|
+
return wrapper_1.WebhookWrapper.getOne(this.client, { siteId, webhookId });
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Remove a Webhook
|
|
366
|
+
* @param params The Webhook and Site information
|
|
367
|
+
* @param params.siteId The Site Id
|
|
368
|
+
* @param params.webhookId The Webhook Id
|
|
369
|
+
* @returns the result from the remove request
|
|
370
|
+
*/
|
|
371
|
+
removeWebhook({ siteId, webhookId }) {
|
|
372
|
+
return wrapper_1.WebhookWrapper.remove(this.client, { siteId, webhookId });
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Create a Webhook
|
|
376
|
+
* @param params The params to create a webhooks
|
|
377
|
+
* @param params.siteId The Site Id
|
|
378
|
+
* @param params.url The Url the Webhook should call on events
|
|
379
|
+
* @param params.triggerType The type of event that should trigger the Webhook
|
|
380
|
+
* @param params.filter The filter to apply to the Webhook (form_submssion only)
|
|
381
|
+
* @returns The created webhook
|
|
382
|
+
*/
|
|
383
|
+
async createWebhook({ url, siteId, triggerType, filter, }) {
|
|
384
|
+
const _params = { url, siteId, triggerType, filter };
|
|
385
|
+
return wrapper_1.WebhookWrapper.create(this.client, _params);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
exports.Webflow = Webflow;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { ItemWrapper } from ".";
|
|
2
|
+
import { Client, QueryString } from "../core";
|
|
3
|
+
import { Collection, Item } from "../api";
|
|
4
|
+
export declare class CollectionWrapper implements Collection.ICollection {
|
|
5
|
+
private client;
|
|
6
|
+
fields: Collection.CollectionField[];
|
|
7
|
+
singularName: string;
|
|
8
|
+
lastUpdated: string;
|
|
9
|
+
createdOn: string;
|
|
10
|
+
_id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
slug: string;
|
|
13
|
+
constructor(client: Client, collection: Collection.ICollection);
|
|
14
|
+
/**************************************************************
|
|
15
|
+
* Static Methods
|
|
16
|
+
**************************************************************/
|
|
17
|
+
/**
|
|
18
|
+
* Get a single Collection
|
|
19
|
+
* @param client The Webflow client
|
|
20
|
+
* @param params The Collection information
|
|
21
|
+
* @param params.collectionId The Collection ID
|
|
22
|
+
* @returns A single Collection
|
|
23
|
+
*/
|
|
24
|
+
static getOne(client: Client, { collectionId }: {
|
|
25
|
+
collectionId: string;
|
|
26
|
+
}): Promise<import("./response").MetaResponse<CollectionWrapper>>;
|
|
27
|
+
/**
|
|
28
|
+
* Get a list of Collections
|
|
29
|
+
* @param client The Webflow client
|
|
30
|
+
* @param params1 The Site information
|
|
31
|
+
* @param params1.siteId The Site ID
|
|
32
|
+
* @param params The query parameters (optional)
|
|
33
|
+
* @returns A list of Collections
|
|
34
|
+
*/
|
|
35
|
+
static list(client: Client, { siteId }: {
|
|
36
|
+
siteId: string;
|
|
37
|
+
}, params?: QueryString): Promise<import("./response").MetaResponse<CollectionWrapper[]>>;
|
|
38
|
+
/**************************************************************
|
|
39
|
+
* Instance Methods
|
|
40
|
+
**************************************************************/
|
|
41
|
+
/**
|
|
42
|
+
* Get a single Item
|
|
43
|
+
* @param params The params for the request
|
|
44
|
+
* @param params.itemId The Item ID
|
|
45
|
+
* @returns A single Item
|
|
46
|
+
*/
|
|
47
|
+
item({ itemId }: {
|
|
48
|
+
itemId: string;
|
|
49
|
+
}): Promise<import("./response").MetaResponse<ItemWrapper>>;
|
|
50
|
+
/**
|
|
51
|
+
* Get a list of Items
|
|
52
|
+
* @param params The params for the request
|
|
53
|
+
* @param params.limit The number of items to return (optional)
|
|
54
|
+
* @param params.offset The number of items to skip (optional)
|
|
55
|
+
* @returns A list of Items
|
|
56
|
+
*/
|
|
57
|
+
items(params?: QueryString): Promise<import("./response").MetaResponse<ItemWrapper[]>>;
|
|
58
|
+
/**
|
|
59
|
+
* Remove a single Item
|
|
60
|
+
* @param params The params for the request
|
|
61
|
+
* @param params.itemId The Item ID
|
|
62
|
+
* @returns The result from the removal
|
|
63
|
+
*/
|
|
64
|
+
removeItem({ itemId }: {
|
|
65
|
+
itemId: string;
|
|
66
|
+
}): Promise<import("./response").MetaResponse<Item.IItemDelete>>;
|
|
67
|
+
/**
|
|
68
|
+
* Create a new Item
|
|
69
|
+
* @param params The params for the request
|
|
70
|
+
* @param params.fields The Item fields to create
|
|
71
|
+
* @returns The created Item
|
|
72
|
+
*/
|
|
73
|
+
createItem(fields: any): Promise<import("./response").MetaResponse<ItemWrapper>>;
|
|
74
|
+
/**
|
|
75
|
+
* Update a single Item
|
|
76
|
+
* @param params The params for the request
|
|
77
|
+
* @param params.itemId The Item ID
|
|
78
|
+
* @param params.fields The fields to update
|
|
79
|
+
* @returns The updated Item
|
|
80
|
+
*/
|
|
81
|
+
updateItem({ itemId, fields }: {
|
|
82
|
+
itemId: string;
|
|
83
|
+
fields: any;
|
|
84
|
+
}): Promise<import("./response").MetaResponse<ItemWrapper>>;
|
|
85
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CollectionWrapper = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const api_1 = require("../api");
|
|
6
|
+
class CollectionWrapper {
|
|
7
|
+
constructor(client, collection) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
Object.assign(this, collection);
|
|
10
|
+
}
|
|
11
|
+
/**************************************************************
|
|
12
|
+
* Static Methods
|
|
13
|
+
**************************************************************/
|
|
14
|
+
/**
|
|
15
|
+
* Get a single Collection
|
|
16
|
+
* @param client The Webflow client
|
|
17
|
+
* @param params The Collection information
|
|
18
|
+
* @param params.collectionId The Collection ID
|
|
19
|
+
* @returns A single Collection
|
|
20
|
+
*/
|
|
21
|
+
static async getOne(client, { collectionId }) {
|
|
22
|
+
const res = await api_1.Collection.getOne(client, { collectionId });
|
|
23
|
+
const collection = new CollectionWrapper(client, res.data);
|
|
24
|
+
return (0, _1.ResponseWrapper)(res, collection);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get a list of Collections
|
|
28
|
+
* @param client The Webflow client
|
|
29
|
+
* @param params1 The Site information
|
|
30
|
+
* @param params1.siteId The Site ID
|
|
31
|
+
* @param params The query parameters (optional)
|
|
32
|
+
* @returns A list of Collections
|
|
33
|
+
*/
|
|
34
|
+
static async list(client, { siteId }, params) {
|
|
35
|
+
const res = await api_1.Collection.list(client, { siteId }, params);
|
|
36
|
+
const collections = res.data.map((c) => new CollectionWrapper(client, c));
|
|
37
|
+
return (0, _1.ResponseWrapper)(res, collections);
|
|
38
|
+
}
|
|
39
|
+
/**************************************************************
|
|
40
|
+
* Instance Methods
|
|
41
|
+
**************************************************************/
|
|
42
|
+
/**
|
|
43
|
+
* Get a single Item
|
|
44
|
+
* @param params The params for the request
|
|
45
|
+
* @param params.itemId The Item ID
|
|
46
|
+
* @returns A single Item
|
|
47
|
+
*/
|
|
48
|
+
async item({ itemId }) {
|
|
49
|
+
return _1.ItemWrapper.getOne(this.client, { itemId, collectionId: this._id });
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get a list of Items
|
|
53
|
+
* @param params The params for the request
|
|
54
|
+
* @param params.limit The number of items to return (optional)
|
|
55
|
+
* @param params.offset The number of items to skip (optional)
|
|
56
|
+
* @returns A list of Items
|
|
57
|
+
*/
|
|
58
|
+
async items(params) {
|
|
59
|
+
return _1.ItemWrapper.list(this.client, { collectionId: this._id, ...params });
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Remove a single Item
|
|
63
|
+
* @param params The params for the request
|
|
64
|
+
* @param params.itemId The Item ID
|
|
65
|
+
* @returns The result from the removal
|
|
66
|
+
*/
|
|
67
|
+
async removeItem({ itemId }) {
|
|
68
|
+
return _1.ItemWrapper.remove(this.client, { itemId, collectionId: this._id });
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create a new Item
|
|
72
|
+
* @param params The params for the request
|
|
73
|
+
* @param params.fields The Item fields to create
|
|
74
|
+
* @returns The created Item
|
|
75
|
+
*/
|
|
76
|
+
async createItem(fields) {
|
|
77
|
+
return _1.ItemWrapper.create(this.client, { collectionId: this._id, fields });
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Update a single Item
|
|
81
|
+
* @param params The params for the request
|
|
82
|
+
* @param params.itemId The Item ID
|
|
83
|
+
* @param params.fields The fields to update
|
|
84
|
+
* @returns The updated Item
|
|
85
|
+
*/
|
|
86
|
+
async updateItem({ itemId, fields }) {
|
|
87
|
+
return _1.ItemWrapper.update(this.client, {
|
|
88
|
+
collectionId: this._id,
|
|
89
|
+
itemId,
|
|
90
|
+
fields,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.CollectionWrapper = CollectionWrapper;
|
|
@@ -0,0 +1,22 @@
|
|
|
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("./membership"), exports);
|
|
18
|
+
__exportStar(require("./collection"), exports);
|
|
19
|
+
__exportStar(require("./response"), exports);
|
|
20
|
+
__exportStar(require("./webhook"), exports);
|
|
21
|
+
__exportStar(require("./site"), exports);
|
|
22
|
+
__exportStar(require("./item"), exports);
|