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