webflow-api 1.3.0 → 1.3.1

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