webflow-api 1.1.2 → 1.2.0

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