webflow-api 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +31 -0
- package/.github/workflows/code-quality.yml +102 -0
- package/.github/workflows/npm-publish.yml +21 -0
- package/.github/workflows/semgrep.yml +24 -0
- package/.prettierignore +5 -0
- package/.prettierrc +6 -0
- package/README.md +50 -1
- package/jest.config.js +17 -0
- package/package.json +2 -7
- package/src/api/collection.ts +1 -1
- package/src/api/item.ts +4 -4
- package/src/api/meta.ts +2 -2
- package/src/api/oauth.ts +8 -2
- package/src/core/error.ts +1 -1
- package/src/core/webflow.ts +111 -4
- package/tests/api/collection.test.ts +147 -0
- package/tests/api/item.test.ts +180 -0
- package/tests/api/meta.test.ts +38 -0
- package/tests/api/oauth.test.ts +44 -0
- package/tests/api/site.test.ts +202 -0
- package/tests/api/user.test.ts +139 -0
- package/tests/api/webhook.test.ts +82 -0
- package/tests/core/error.test.ts +19 -0
- package/tests/core/response.test.ts +36 -0
- package/tests/core/webflow.test.ts +540 -0
- package/tests/fixtures/collection.fixture.ts +374 -0
- package/tests/fixtures/index.ts +7 -0
- package/tests/fixtures/item.fixture.ts +193 -0
- package/tests/fixtures/meta.fixture.ts +34 -0
- package/tests/fixtures/oauth.fixture.ts +38 -0
- package/tests/fixtures/site.fixture.ts +78 -0
- package/tests/fixtures/user.fixture.ts +175 -0
- package/tests/fixtures/webhook.fixture.ts +69 -0
- package/tsconfig.eslint.json +7 -0
- package/tsconfig.json +14 -0
- package/dist/api/collection.d.ts +0 -112
- package/dist/api/collection.js +0 -94
- package/dist/api/index.d.ts +0 -7
- package/dist/api/index.js +0 -23
- package/dist/api/item.d.ts +0 -177
- package/dist/api/item.js +0 -151
- package/dist/api/meta.d.ts +0 -53
- package/dist/api/meta.js +0 -25
- package/dist/api/oauth.d.ts +0 -69
- package/dist/api/oauth.js +0 -66
- package/dist/api/site.d.ts +0 -140
- package/dist/api/site.js +0 -137
- package/dist/api/user.d.ts +0 -143
- package/dist/api/user.js +0 -119
- package/dist/api/webhook.d.ts +0 -102
- package/dist/api/webhook.js +0 -80
- package/dist/core/error.d.ts +0 -21
- package/dist/core/error.js +0 -30
- package/dist/core/index.d.ts +0 -3
- package/dist/core/index.js +0 -19
- package/dist/core/response.d.ts +0 -32
- package/dist/core/response.js +0 -26
- package/dist/core/webflow.d.ts +0 -386
- package/dist/core/webflow.js +0 -445
- package/dist/index.d.ts +0 -2
- package/yarn.lock +0 -2830
package/dist/core/response.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebflowRecord = exports.MetaResponse = void 0;
|
|
4
|
-
class MetaResponse {
|
|
5
|
-
constructor(response) {
|
|
6
|
-
this.response = response;
|
|
7
|
-
this.rateLimit = {
|
|
8
|
-
limit: parseInt(response.headers["x-ratelimit-limit"], 10),
|
|
9
|
-
remaining: parseInt(response.headers["x-ratelimit-remaining"], 10),
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.MetaResponse = MetaResponse;
|
|
14
|
-
class WebflowRecord {
|
|
15
|
-
constructor(client, response, record, ...args) {
|
|
16
|
-
Object.assign(this, record || response.data, ...args); // Copy the record data
|
|
17
|
-
// dynamically add client and response to object
|
|
18
|
-
// without serializing during toString()
|
|
19
|
-
Object.defineProperties(this, {
|
|
20
|
-
client: { get: () => client },
|
|
21
|
-
response: { get: () => response },
|
|
22
|
-
_meta: { get: () => new MetaResponse(response) }, // legacy support
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.WebflowRecord = WebflowRecord;
|
package/dist/core/webflow.d.ts
DELETED
|
@@ -1,386 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from "axios";
|
|
2
|
-
import { PaginationFilter } from "../core";
|
|
3
|
-
import { Collection, IAccessTokenParams, IAuthorizeUrlParams, IRevokeTokenParams, User, Site, Webhook, WebhookFilter, Item } from "../api";
|
|
4
|
-
export declare const DEFAULT_HOST = "webflow.com";
|
|
5
|
-
export declare const USER_AGENT = "Webflow Javascript SDK / 1.0";
|
|
6
|
-
export interface Options {
|
|
7
|
-
host?: string;
|
|
8
|
-
token?: string;
|
|
9
|
-
version?: string;
|
|
10
|
-
headers?: Record<string, string>;
|
|
11
|
-
}
|
|
12
|
-
/**************************************************************
|
|
13
|
-
* Class
|
|
14
|
-
**************************************************************/
|
|
15
|
-
export declare class Webflow {
|
|
16
|
-
options: Options;
|
|
17
|
-
private client;
|
|
18
|
-
constructor(options?: Options);
|
|
19
|
-
set token(value: string);
|
|
20
|
-
clearToken(): void;
|
|
21
|
-
get config(): AxiosRequestConfig<any>;
|
|
22
|
-
/**************************************************************
|
|
23
|
-
* HTTP Methods
|
|
24
|
-
**************************************************************/
|
|
25
|
-
/**
|
|
26
|
-
* Send a GET request to the Webflow API
|
|
27
|
-
* @param path The path to the endpoint
|
|
28
|
-
* @param params The query parameters (optional)
|
|
29
|
-
* @returns The response from the Webflow API
|
|
30
|
-
*/
|
|
31
|
-
get(path: string, params?: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
32
|
-
/**
|
|
33
|
-
* Send a DELETE request to the Webflow API
|
|
34
|
-
* @param path The path to the endpoint
|
|
35
|
-
* @param params The query parameters (optional)
|
|
36
|
-
* @returns The response from the Webflow API
|
|
37
|
-
*/
|
|
38
|
-
delete(path: string, params?: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
39
|
-
/**
|
|
40
|
-
* Send a POST request to create a new Collection
|
|
41
|
-
* @param path The path to the endpoint
|
|
42
|
-
* @param data The data to send
|
|
43
|
-
* @param params The query parameters (optional)
|
|
44
|
-
* @returns The response from the Webflow API
|
|
45
|
-
*/
|
|
46
|
-
post(path: string, data: any, params?: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
47
|
-
/**
|
|
48
|
-
* Send a PUT request to create a new Collection
|
|
49
|
-
* @param path The path to the endpoint
|
|
50
|
-
* @param data The data to send
|
|
51
|
-
* @param params The query parameters (optional)
|
|
52
|
-
* @returns The response from the Webflow API
|
|
53
|
-
*/
|
|
54
|
-
put(path: string, data: any, params?: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
55
|
-
/**
|
|
56
|
-
* Send a PATCH request to create a new Collection
|
|
57
|
-
* @param path The path to the endpoint
|
|
58
|
-
* @param data The data to send
|
|
59
|
-
* @param params The query parameters (optional)
|
|
60
|
-
* @returns The response from the Webflow API
|
|
61
|
-
*/
|
|
62
|
-
patch(path: string, data: any, params?: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
63
|
-
/**************************************************************
|
|
64
|
-
* OAuth Endpoints
|
|
65
|
-
**************************************************************/
|
|
66
|
-
/**
|
|
67
|
-
* Create an OAuth Authorization url
|
|
68
|
-
* @param params The OAuth information
|
|
69
|
-
* @param params.state The state parameter (optional)
|
|
70
|
-
* @param params.scope The scope parameter (optional)
|
|
71
|
-
* @param params.client_id The client_id parameter (optional)
|
|
72
|
-
* @param params.redirect_uri The redirect_uri parameter (optional)
|
|
73
|
-
* @param params.response_type The response_type parameter (default: "code")
|
|
74
|
-
* @returns The url to redirect to
|
|
75
|
-
*/
|
|
76
|
-
authorizeUrl(params: IAuthorizeUrlParams): string;
|
|
77
|
-
/**
|
|
78
|
-
* Create an OAuth Access Token
|
|
79
|
-
* @param params The OAuth information
|
|
80
|
-
* @param params.code The code parameter
|
|
81
|
-
* @param params.client_id The client_id parameter
|
|
82
|
-
* @param params.client_secret The client_secret parameter
|
|
83
|
-
* @param params.redirect_uri The redirect_uri parameter (optional)
|
|
84
|
-
* @param params.grant_type The grant_type parameter (default: "authorization_code")
|
|
85
|
-
* @returns The access token
|
|
86
|
-
*/
|
|
87
|
-
accessToken(params: IAccessTokenParams): Promise<import("../api").IAccessToken>;
|
|
88
|
-
/**
|
|
89
|
-
* Revoke an OAuth Access Token
|
|
90
|
-
* @param params The access token information
|
|
91
|
-
* @param params.access_token The access token
|
|
92
|
-
* @param params.client_id The client_id parameter
|
|
93
|
-
* @param params.client_secret The client_secret parameter
|
|
94
|
-
* @returns The result of the revoked token
|
|
95
|
-
*/
|
|
96
|
-
revokeToken(params: IRevokeTokenParams): Promise<import("../api").IRevokeToken>;
|
|
97
|
-
/**************************************************************
|
|
98
|
-
* Meta Endpoints
|
|
99
|
-
**************************************************************/
|
|
100
|
-
/**
|
|
101
|
-
* Get the current authorization information
|
|
102
|
-
* @returns The authorization information
|
|
103
|
-
*/
|
|
104
|
-
info(): Promise<import("../api").IAuthentiationInfo>;
|
|
105
|
-
/**
|
|
106
|
-
* Get the current authenticated user
|
|
107
|
-
* @returns The current authenticated user
|
|
108
|
-
*/
|
|
109
|
-
authenticatedUser(): Promise<import("../api").IAuthenticatedUser>;
|
|
110
|
-
/**************************************************************
|
|
111
|
-
* Site Endpoints
|
|
112
|
-
**************************************************************/
|
|
113
|
-
/**
|
|
114
|
-
* Get a list of Sites available
|
|
115
|
-
* @returns A list of Sites
|
|
116
|
-
*/
|
|
117
|
-
sites(): Promise<Site[]>;
|
|
118
|
-
/**
|
|
119
|
-
* Get a single Site
|
|
120
|
-
* @param params The Site information
|
|
121
|
-
* @param params.siteId The Site ID
|
|
122
|
-
* @returns The Site
|
|
123
|
-
*/
|
|
124
|
-
site({ siteId }: {
|
|
125
|
-
siteId: string;
|
|
126
|
-
}): Promise<Site>;
|
|
127
|
-
/**
|
|
128
|
-
* Publish a Site
|
|
129
|
-
* @param params The Site information
|
|
130
|
-
* @param params.siteId The Site ID
|
|
131
|
-
* @param params.domain The domains to publish
|
|
132
|
-
* @returns The result of the publish
|
|
133
|
-
*/
|
|
134
|
-
publishSite({ siteId, domains }: {
|
|
135
|
-
siteId: string;
|
|
136
|
-
} & {
|
|
137
|
-
domains: string[];
|
|
138
|
-
}): Promise<import("../api").IPublishSite>;
|
|
139
|
-
/**
|
|
140
|
-
* Get a list of Domains for a Site
|
|
141
|
-
* @param params The Site information
|
|
142
|
-
* @param params.siteId The Site ID
|
|
143
|
-
* @returns A list of Domains
|
|
144
|
-
*/
|
|
145
|
-
domains({ siteId }: {
|
|
146
|
-
siteId: string;
|
|
147
|
-
}): Promise<import("../api").IDomain[]>;
|
|
148
|
-
/**************************************************************
|
|
149
|
-
* Collection Endpoints
|
|
150
|
-
**************************************************************/
|
|
151
|
-
/**
|
|
152
|
-
* Get a list of Collections
|
|
153
|
-
* @param params The Site information
|
|
154
|
-
* @param params.siteId The Site ID
|
|
155
|
-
* @returns A list of Collections
|
|
156
|
-
*/
|
|
157
|
-
collections({ siteId }: {
|
|
158
|
-
siteId: string;
|
|
159
|
-
}): Promise<Collection[]>;
|
|
160
|
-
/**
|
|
161
|
-
* Get a single Collection
|
|
162
|
-
* @param params The Collection information
|
|
163
|
-
* @param params.collectionId The Collection ID
|
|
164
|
-
* @returns A single Collection
|
|
165
|
-
*/
|
|
166
|
-
collection({ collectionId }: {
|
|
167
|
-
collectionId: string;
|
|
168
|
-
}): Promise<Collection>;
|
|
169
|
-
/**************************************************************
|
|
170
|
-
* Item Endpoints
|
|
171
|
-
**************************************************************/
|
|
172
|
-
/**
|
|
173
|
-
* Get a list of Collection Items
|
|
174
|
-
* @param params The Collection information
|
|
175
|
-
* @param params.collectionId The Collection ID
|
|
176
|
-
* @param params.limit The number of items to return
|
|
177
|
-
* @param params.offset The number of items to skip
|
|
178
|
-
* @returns A list of Items
|
|
179
|
-
*/
|
|
180
|
-
items({ collectionId, limit, offset }: {
|
|
181
|
-
collectionId: string;
|
|
182
|
-
} & PaginationFilter): Promise<Item[]>;
|
|
183
|
-
/**
|
|
184
|
-
* Get a single Collection Item
|
|
185
|
-
* @param params The Item information
|
|
186
|
-
* @param params.collectionId The Collection ID
|
|
187
|
-
* @param params.itemId The Item ID
|
|
188
|
-
* @returns A single Collection Item
|
|
189
|
-
*/
|
|
190
|
-
item({ itemId, collectionId }: {
|
|
191
|
-
itemId: string;
|
|
192
|
-
collectionId: string;
|
|
193
|
-
}): Promise<Item>;
|
|
194
|
-
/**
|
|
195
|
-
* Create a new Collection Item
|
|
196
|
-
* @param params The Item information
|
|
197
|
-
* @param params.collectionId The Collection ID
|
|
198
|
-
* @returns The created Collection Item
|
|
199
|
-
*/
|
|
200
|
-
createItem({ collectionId, fields }: {
|
|
201
|
-
collectionId: string;
|
|
202
|
-
fields: any;
|
|
203
|
-
}): Promise<Item>;
|
|
204
|
-
/**
|
|
205
|
-
* Update a Collection Item
|
|
206
|
-
* @param params The Item information
|
|
207
|
-
* @param params.collectionId The Collection ID
|
|
208
|
-
* @param params.itemId The Item ID
|
|
209
|
-
* @param query The query parameters (optional)
|
|
210
|
-
* @returns The updated Collection Item
|
|
211
|
-
*/
|
|
212
|
-
updateItem({ collectionId, itemId, ...fields }: {
|
|
213
|
-
itemId: string;
|
|
214
|
-
collectionId: string;
|
|
215
|
-
}): Promise<Item>;
|
|
216
|
-
/**
|
|
217
|
-
* Patch a Collection Item
|
|
218
|
-
* @param params The Item information
|
|
219
|
-
* @param params.collectionId The Collection ID
|
|
220
|
-
* @param params.itemId The Item ID
|
|
221
|
-
* @returns The patched Collection Item
|
|
222
|
-
*/
|
|
223
|
-
patchItem({ collectionId, itemId, ...fields }: {
|
|
224
|
-
collectionId: string;
|
|
225
|
-
itemId: string;
|
|
226
|
-
}): Promise<Item>;
|
|
227
|
-
/**
|
|
228
|
-
* Delete a Collection Item
|
|
229
|
-
* @param params The Item information
|
|
230
|
-
* @param params.collectionId The Collection ID
|
|
231
|
-
* @param params.itemId The Item ID
|
|
232
|
-
* @returns The deleted Collection Item result
|
|
233
|
-
*/
|
|
234
|
-
removeItem({ collectionId, itemId }: {
|
|
235
|
-
itemId: string;
|
|
236
|
-
collectionId: string;
|
|
237
|
-
}): Promise<import("../api").IItemDelete>;
|
|
238
|
-
/**
|
|
239
|
-
* Upublish a Collection Item
|
|
240
|
-
* @param params The Item information
|
|
241
|
-
* @param params.collectionId The Collection ID
|
|
242
|
-
* @param params.itemId The Item ID
|
|
243
|
-
* @param params.live Update the live version
|
|
244
|
-
* @returns The unpublished Collection Item result
|
|
245
|
-
*/
|
|
246
|
-
deleteItems({ collectionId, itemIds, live, }: {
|
|
247
|
-
collectionId: string;
|
|
248
|
-
itemIds: string[];
|
|
249
|
-
live?: boolean;
|
|
250
|
-
}): Promise<import("../api").IDeletedItems>;
|
|
251
|
-
/**
|
|
252
|
-
* Publish a Collection Item
|
|
253
|
-
* @param params The Item information
|
|
254
|
-
* @param params.collectionId The Collection ID
|
|
255
|
-
* @param params.itemId The Item ID
|
|
256
|
-
* @param params.live Update the live version
|
|
257
|
-
* @returns The Published Collection Item result
|
|
258
|
-
*/
|
|
259
|
-
publishItems({ collectionId, itemIds, live, }: {
|
|
260
|
-
collectionId: string;
|
|
261
|
-
itemIds: string[];
|
|
262
|
-
live?: boolean;
|
|
263
|
-
}): Promise<import("../api").IPublishItems>;
|
|
264
|
-
/**************************************************************
|
|
265
|
-
* Membership Endpoints
|
|
266
|
-
**************************************************************/
|
|
267
|
-
/**
|
|
268
|
-
* Get a list of User accounts
|
|
269
|
-
* @param params The Site information
|
|
270
|
-
* @param params.siteId The Site ID
|
|
271
|
-
* @param pageParams The pagination information (optional)
|
|
272
|
-
* @returns A list of User accounts
|
|
273
|
-
*/
|
|
274
|
-
users({ siteId }: {
|
|
275
|
-
siteId: string;
|
|
276
|
-
}, pageParams?: PaginationFilter): Promise<User[]>;
|
|
277
|
-
/**
|
|
278
|
-
* Get a single User account
|
|
279
|
-
* @param param The Site and User information
|
|
280
|
-
* @param param.siteId The Site ID
|
|
281
|
-
* @param param.userId The User ID
|
|
282
|
-
* @returns The User information
|
|
283
|
-
*/
|
|
284
|
-
user({ siteId, userId }: {
|
|
285
|
-
siteId: string;
|
|
286
|
-
userId: string;
|
|
287
|
-
}): Promise<User>;
|
|
288
|
-
/**
|
|
289
|
-
* Update a User account
|
|
290
|
-
* @param params The Site and User information
|
|
291
|
-
* @param params.siteId The Site ID
|
|
292
|
-
* @param params.userId The User ID
|
|
293
|
-
* @returns The updated User
|
|
294
|
-
*/
|
|
295
|
-
updateUser({ siteId, userId, ...data }: {
|
|
296
|
-
siteId: string;
|
|
297
|
-
userId: string;
|
|
298
|
-
data: any;
|
|
299
|
-
}): Promise<User>;
|
|
300
|
-
/**
|
|
301
|
-
* Invite a User to a Site
|
|
302
|
-
* @param params The Site and User information
|
|
303
|
-
* @param params.siteId The Site ID
|
|
304
|
-
* @param params.email The User's email address
|
|
305
|
-
* @returns The created User account
|
|
306
|
-
*/
|
|
307
|
-
inviteUser({ siteId, email }: {
|
|
308
|
-
siteId: string;
|
|
309
|
-
email: string;
|
|
310
|
-
}): Promise<User>;
|
|
311
|
-
/**
|
|
312
|
-
* Remove a user from a Site
|
|
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 result from the remove request
|
|
317
|
-
*/
|
|
318
|
-
removeUser({ siteId, userId }: {
|
|
319
|
-
siteId: string;
|
|
320
|
-
userId: string;
|
|
321
|
-
}): Promise<import("../api").IUserDelete>;
|
|
322
|
-
/**
|
|
323
|
-
* Get a list of User Access Groups
|
|
324
|
-
* @param params The params for the request
|
|
325
|
-
* @param params.siteId The site ID
|
|
326
|
-
* @param params.limit The number of items to return (optional)
|
|
327
|
-
* @param params.offset The number of items to skip (optional)
|
|
328
|
-
* @param params.sort The sort order of the groups (optional)
|
|
329
|
-
* @returns A list of Access Groups
|
|
330
|
-
*/
|
|
331
|
-
accessGroups({ siteId, limit, offset, sort, }: {
|
|
332
|
-
siteId: string;
|
|
333
|
-
limit?: number;
|
|
334
|
-
offset?: number;
|
|
335
|
-
sort?: string;
|
|
336
|
-
}): Promise<import("../api").PaginatedAccessGroups>;
|
|
337
|
-
/**************************************************************
|
|
338
|
-
* Webhook Endpoints
|
|
339
|
-
**************************************************************/
|
|
340
|
-
/**
|
|
341
|
-
* Get a list of webhooks for a Site
|
|
342
|
-
* @param params The site information to get the Webhooks from
|
|
343
|
-
* @param params.siteId The Site ID
|
|
344
|
-
* @returns A list of Webhooks
|
|
345
|
-
*/
|
|
346
|
-
webhooks({ siteId }: {
|
|
347
|
-
siteId: string;
|
|
348
|
-
}): Promise<Webhook[]>;
|
|
349
|
-
/**
|
|
350
|
-
* Get a single Webhook
|
|
351
|
-
* @param params The Webhook and Site information
|
|
352
|
-
* @param params.siteId The Site Id
|
|
353
|
-
* @param params.webhookId The Webhook Id
|
|
354
|
-
* @returns The Webhook
|
|
355
|
-
*/
|
|
356
|
-
webhook({ siteId, webhookId }: {
|
|
357
|
-
siteId: string;
|
|
358
|
-
webhookId: string;
|
|
359
|
-
}): Promise<Webhook>;
|
|
360
|
-
/**
|
|
361
|
-
* Remove a Webhook
|
|
362
|
-
* @param params The Webhook and Site information
|
|
363
|
-
* @param params.siteId The Site Id
|
|
364
|
-
* @param params.webhookId The Webhook Id
|
|
365
|
-
* @returns the result from the remove request
|
|
366
|
-
*/
|
|
367
|
-
removeWebhook({ siteId, webhookId }: {
|
|
368
|
-
siteId: string;
|
|
369
|
-
webhookId: string;
|
|
370
|
-
}): Promise<import("../api").IRemoveResult>;
|
|
371
|
-
/**
|
|
372
|
-
* Create a Webhook
|
|
373
|
-
* @param params The params to create a webhooks
|
|
374
|
-
* @param params.siteId The Site Id
|
|
375
|
-
* @param params.url The Url the Webhook should call on events
|
|
376
|
-
* @param params.triggerType The type of event that should trigger the Webhook
|
|
377
|
-
* @param params.filter The filter to apply to the Webhook (form_submssion only)
|
|
378
|
-
* @returns The created webhook
|
|
379
|
-
*/
|
|
380
|
-
createWebhook({ url, siteId, triggerType, filter, }: {
|
|
381
|
-
url: string;
|
|
382
|
-
siteId: string;
|
|
383
|
-
triggerType: string;
|
|
384
|
-
filter?: WebhookFilter;
|
|
385
|
-
}): Promise<Webhook>;
|
|
386
|
-
}
|