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.
Files changed (72) hide show
  1. package/README.md +41 -17
  2. package/dist/api/collection.d.ts +86 -25
  3. package/dist/api/collection.js +88 -29
  4. package/dist/api/index.d.ts +7 -7
  5. package/dist/api/index.js +9 -19
  6. package/dist/api/item.d.ts +141 -107
  7. package/dist/api/item.js +145 -125
  8. package/dist/api/meta.d.ts +16 -14
  9. package/dist/api/meta.js +20 -19
  10. package/dist/api/oauth.d.ts +38 -36
  11. package/dist/api/oauth.js +59 -59
  12. package/dist/api/site.d.ts +118 -43
  13. package/dist/api/site.js +131 -53
  14. package/dist/api/user.d.ts +143 -0
  15. package/dist/api/user.js +119 -0
  16. package/dist/api/webhook.d.ts +77 -55
  17. package/dist/api/webhook.js +74 -61
  18. package/dist/core/error.d.ts +2 -0
  19. package/dist/core/error.js +8 -1
  20. package/dist/core/index.d.ts +2 -2
  21. package/dist/core/index.js +2 -2
  22. package/dist/core/response.d.ts +32 -0
  23. package/dist/core/response.js +26 -0
  24. package/dist/{webflow.d.ts → core/webflow.d.ts} +66 -54
  25. package/dist/{webflow.js → core/webflow.js} +114 -65
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.js +2 -2
  28. package/package.json +12 -8
  29. package/src/api/collection.ts +103 -36
  30. package/src/api/index.ts +7 -7
  31. package/src/api/item.ts +217 -176
  32. package/src/api/meta.ts +19 -18
  33. package/src/api/oauth.ts +71 -74
  34. package/src/api/site.ts +161 -55
  35. package/src/api/user.ts +192 -0
  36. package/src/api/webhook.ts +103 -80
  37. package/src/core/error.ts +8 -0
  38. package/src/core/index.ts +2 -2
  39. package/src/core/response.ts +50 -0
  40. package/src/{webflow.ts → core/webflow.ts} +153 -125
  41. package/src/index.ts +1 -1
  42. package/yarn.lock +4 -9
  43. package/dist/api/membership.d.ts +0 -114
  44. package/dist/api/membership.js +0 -96
  45. package/dist/core/client.d.ts +0 -27
  46. package/dist/core/client.js +0 -60
  47. package/dist/core/options.d.ts +0 -8
  48. package/dist/core/options.js +0 -5
  49. package/dist/wrapper/collection.d.ts +0 -85
  50. package/dist/wrapper/collection.js +0 -94
  51. package/dist/wrapper/index.d.ts +0 -6
  52. package/dist/wrapper/index.js +0 -22
  53. package/dist/wrapper/item.d.ts +0 -140
  54. package/dist/wrapper/item.js +0 -153
  55. package/dist/wrapper/membership.d.ts +0 -105
  56. package/dist/wrapper/membership.js +0 -123
  57. package/dist/wrapper/response.d.ts +0 -16
  58. package/dist/wrapper/response.js +0 -17
  59. package/dist/wrapper/site.d.ts +0 -168
  60. package/dist/wrapper/site.js +0 -191
  61. package/dist/wrapper/webhook.d.ts +0 -78
  62. package/dist/wrapper/webhook.js +0 -82
  63. package/src/api/membership.ts +0 -155
  64. package/src/core/client.ts +0 -82
  65. package/src/core/options.ts +0 -9
  66. package/src/wrapper/collection.ts +0 -115
  67. package/src/wrapper/index.ts +0 -6
  68. package/src/wrapper/item.ts +0 -218
  69. package/src/wrapper/membership.ts +0 -163
  70. package/src/wrapper/response.ts +0 -25
  71. package/src/wrapper/site.ts +0 -228
  72. package/src/wrapper/webhook.ts +0 -116
@@ -1,228 +0,0 @@
1
- import {
2
- CreateWebhookParams,
3
- CollectionWrapper,
4
- ResponseWrapper,
5
- WebhookWrapper,
6
- MembershipWrapper,
7
- } from ".";
8
- import { Client, QueryString } from "../core";
9
- import { Site } from "../api";
10
-
11
- export class SiteWrapper implements Site.ISite {
12
- lastPublished: string;
13
- previewUrl: string;
14
- createdOn: string;
15
- shortName: string;
16
- timezone: string;
17
- database: string;
18
- name: string;
19
- _id: string;
20
-
21
- constructor(private client: Client, site: Site.ISite) {
22
- Object.assign(this, site);
23
- }
24
-
25
- /**************************************************************
26
- * Static Methods
27
- **************************************************************/
28
-
29
- /**
30
- * Get a single Site
31
- * @param client The Webflow client
32
- * @param params The Site information
33
- * @param params.siteId The Site ID
34
- * @returns The Site
35
- */
36
- static async getOne(client: Client, { siteId }: { siteId: string }) {
37
- const res = await Site.getOne(client, { siteId });
38
- const site = new SiteWrapper(client, res.data);
39
- return ResponseWrapper<typeof site>(res, site);
40
- }
41
-
42
- /**
43
- * Get a list of Sites available
44
- * @param client The Webflow client
45
- * @param params The query parameters (optional)
46
- * @returns A list of Sites
47
- */
48
- static async list(client: Client, params?: QueryString) {
49
- const res = await Site.list(client, params);
50
- const sites = res.data.map((s) => new SiteWrapper(client, s));
51
- return ResponseWrapper<typeof sites>(res, sites);
52
- }
53
-
54
- /**
55
- * Get a list of Domains for a Site
56
- * @param client The Webflow client
57
- * @param params The Site information
58
- * @param params.siteId The Site ID
59
- * @returns A list of Domains
60
- */
61
- static async domains(client: Client, { siteId }: { siteId: string }) {
62
- const res = await Site.domains(client, { siteId });
63
- return ResponseWrapper<typeof res.data>(res, res.data);
64
- }
65
-
66
- /**
67
- * Publish a Site
68
- * @param client The Webflow client
69
- * @param params The Site information
70
- * @param params.siteId The Site ID
71
- * @param params.domain The domains to publish
72
- * @returns The result of the publish
73
- */
74
- static async publish(
75
- client: Client,
76
- { siteId, domains }: { siteId: string; domains: string[] }
77
- ) {
78
- const res = await Site.publish(client, { siteId, domains });
79
- return ResponseWrapper<typeof res.data>(res);
80
- }
81
-
82
- /**************************************************************
83
- * Instance Methods
84
- **************************************************************/
85
-
86
- /**
87
- * Get a list of domains for a site
88
- * @returns A list of domains
89
- */
90
- async domains() {
91
- const res = await Site.domains(this.client, { siteId: this._id });
92
- return ResponseWrapper<typeof res.data>(res);
93
- }
94
-
95
- /**
96
- * Publish a site
97
- * @param domains The domains to publish to
98
- * @returns The publish result
99
- */
100
- async publishSite(domains: string[]) {
101
- const res = await Site.publish(this.client, { siteId: this._id, domains });
102
- return ResponseWrapper<typeof res.data>(res);
103
- }
104
-
105
- /**
106
- * Get a single Collection
107
- * @param params The params for the request
108
- * @param params.collectionId The collection ID
109
- * @returns A single Collection
110
- */
111
- async collection({ collectionId }: { collectionId: string }) {
112
- return CollectionWrapper.getOne(this.client, { collectionId });
113
- }
114
-
115
- /**
116
- * Get a list of Collections
117
- * @returns A list of Collections
118
- */
119
- async collections() {
120
- return CollectionWrapper.list(this.client, { siteId: this._id });
121
- }
122
-
123
- /**
124
- * Get a single Webhook
125
- * @param params The params for the request
126
- * @param params.webhookId The webhook ID
127
- * @returns A single Webhook
128
- */
129
- async webhook({ webhookId }: { webhookId: string }) {
130
- return WebhookWrapper.getOne(this.client, { siteId: this._id, webhookId });
131
- }
132
-
133
- /**
134
- * Get a list of Webhooks
135
- * @param params The query string parameters (optional)
136
- * @returns A list of Webhooks
137
- */
138
- async webhooks(params?: QueryString) {
139
- return WebhookWrapper.list(this.client, { siteId: this._id }, params);
140
- }
141
-
142
- /**
143
- * Remove a Webhook
144
- * @param params The query string parameters (optional)
145
- * @param params.webhookId The Webhook ID
146
- * @returns The result of the removal
147
- */
148
- async removeWebhook({ webhookId }: { webhookId: string }) {
149
- return WebhookWrapper.remove(this.client, { siteId: this._id, webhookId });
150
- }
151
-
152
- /**
153
- * Create a new Webhook
154
- * @param params1 The params for the request
155
- * @param params1.url The URL to send the webhook to
156
- * @param params1.triggerType The event to trigger the webhook
157
- * @param params1.filter The filter to apply to the webhook (optional: form_submission only)
158
- * @param params The query string parameters (optional)
159
- * @returns The created webhook
160
- */
161
- async createWebhook({ triggerType, filter, url }: CreateWebhookParams) {
162
- const _params = { url, siteId: this._id, triggerType, filter };
163
- return WebhookWrapper.create(this.client, _params);
164
- }
165
-
166
- /**
167
- * Get a list of Users
168
- * @param params The params for the request
169
- * @param params.limit The number of items to return (optional)
170
- * @param params.offset The number of items to skip (optional)
171
- * @returns A list of Users
172
- */
173
- async users({ limit, offset }: { limit?: number; offset?: number } = {}) {
174
- return MembershipWrapper.list(this.client, {
175
- siteId: this._id,
176
- limit,
177
- offset,
178
- });
179
- }
180
-
181
- /**
182
- * Get a single User
183
- * @param params The params for the request
184
- * @param params.userId The user ID
185
- * @returns A single User
186
- */
187
- async user({ userId }: { userId: string }) {
188
- return MembershipWrapper.getOne(this.client, { siteId: this._id, userId });
189
- }
190
-
191
- /**
192
- * Invite a User to a site
193
- * @param params The params for the request
194
- * @param params.email The email address of the user to invite
195
- * @returns The newly created User
196
- */
197
- async inviteUser({ email }: { email: string }) {
198
- return MembershipWrapper.invite(this.client, { siteId: this._id, email });
199
- }
200
-
201
- /**
202
- * Get a list of Access Groups
203
- * @param params The params for the request
204
- * @param params.limit The number of items to return (optional)
205
- * @param params.offset The number of items to skip (optional)
206
- * @returns A list of Access Groups
207
- */
208
- async accessGroups({
209
- limit,
210
- offset,
211
- }: { limit?: number; offset?: number } = {}) {
212
- return MembershipWrapper.accessGroups(this.client, {
213
- siteId: this._id,
214
- limit,
215
- offset,
216
- });
217
- }
218
-
219
- /**
220
- * Remove a User
221
- * @param params The params for the request
222
- * @param params.userId The user ID
223
- * @returns The result of the remove
224
- */
225
- async removeUser({ userId }: { userId: string }) {
226
- return MembershipWrapper.remove(this.client, { siteId: this._id, userId });
227
- }
228
- }
@@ -1,116 +0,0 @@
1
- import { Client, QueryString } from "../core";
2
- import { ResponseWrapper } from ".";
3
- import { Webhook } from "../api";
4
-
5
- export type CreateWebhookParams = {
6
- url: string;
7
- siteId: string;
8
- triggerType: string;
9
- filter?: Webhook.Filter;
10
- };
11
-
12
- export class WebhookWrapper implements Webhook.IWebhook {
13
- triggerType: Webhook.TriggerType;
14
- triggerId: string;
15
- createdOn: string;
16
- lastUsed?: string;
17
- site: string;
18
- _id: string;
19
- filter?: {
20
- name: string;
21
- };
22
-
23
- constructor(private client: Client, webhook: Webhook.IWebhook) {
24
- Object.assign(this, webhook);
25
- }
26
-
27
- /**************************************************************
28
- * Static Methods
29
- **************************************************************/
30
-
31
- /**
32
- * Get a Webhook
33
- * @param client The Webflow client
34
- * @param params The Webhook params
35
- * @param params.siteId The Site ID
36
- * @param params.webhookId The Webhook ID
37
- * @returns The Webhook
38
- */
39
- static async getOne(
40
- client: Client,
41
- { siteId, webhookId }: { siteId: string; webhookId: string }
42
- ) {
43
- const res = await Webhook.getOne(client, { siteId, webhookId });
44
- const webhook = new WebhookWrapper(client, res.data);
45
- return ResponseWrapper<typeof webhook>(res, webhook);
46
- }
47
-
48
- /**
49
- * List Webhooks
50
- * @param client The Webflow client
51
- * @param param1 The Webhook params
52
- * @param param1.siteId The Site ID
53
- * @param params Query string params (optional)
54
- * @returns A list of Webhooks
55
- */
56
- static async list(
57
- client: Client,
58
- { siteId }: { siteId: string },
59
- params?: QueryString
60
- ) {
61
- const res = await Webhook.list(client, { siteId }, params);
62
- const webhooks = res.data.map((w) => new WebhookWrapper(client, w));
63
- return ResponseWrapper<typeof webhooks>(res, webhooks);
64
- }
65
-
66
- /**
67
- * Remove a Webhook
68
- * @param client The Webflow client
69
- * @param params The Webhook params
70
- * @param params.siteId The Site ID
71
- * @param params.webhookId The Webhook ID
72
- * @returns The result of the removal
73
- */
74
- static async remove(
75
- client: Client,
76
- { siteId, webhookId }: { siteId: string; webhookId: string }
77
- ) {
78
- const res = await Webhook.remove(client, { siteId, webhookId });
79
- return ResponseWrapper<typeof res.data>(res);
80
- }
81
-
82
- /**
83
- * Create a Webhook
84
- * @param client The Webflow client
85
- * @param param1 The Webhook params
86
- * @param param1.siteId The Site ID
87
- * @param param1.url The URL to send the Webhook to
88
- * @param param1.triggerType The event to trigger the Webhook
89
- * @param param1.filter The filter to use (optional: form_submission only)
90
- * @returns The created Webhook
91
- */
92
- static async create(
93
- client: Client,
94
- { triggerType, siteId, filter, url }: CreateWebhookParams
95
- ) {
96
- const args = { triggerType, siteId, filter, url };
97
- const res = await Webhook.create(client, args);
98
- const _webhook = new WebhookWrapper(client, res.data);
99
- return ResponseWrapper<typeof _webhook>(res, _webhook);
100
- }
101
-
102
- /**************************************************************
103
- * Instance Methods
104
- **************************************************************/
105
-
106
- /**
107
- * Remove a Webhook
108
- * @returns The result of the removal
109
- */
110
- async remove() {
111
- return WebhookWrapper.remove(this.client, {
112
- webhookId: this._id,
113
- siteId: this.site,
114
- });
115
- }
116
- }