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.
- package/dist/api/collection.d.ts +85 -24
- 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/{wrapper/membership.d.ts → api/user.d.ts} +59 -47
- package/dist/api/user.js +103 -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} +56 -59
- package/dist/{webflow.js → core/webflow.js} +101 -68
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +2 -4
- package/src/api/collection.ts +102 -35
- package/src/api/index.ts +7 -7
- package/src/api/item.ts +207 -176
- package/src/api/meta.ts +19 -18
- package/src/api/oauth.ts +62 -74
- package/src/api/site.ts +158 -55
- package/src/api/user.ts +152 -0
- package/src/api/webhook.ts +97 -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} +131 -145
- package/src/index.ts +1 -1
- package/yarn.lock +0 -5
- 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.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
package/src/wrapper/item.ts
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import { Client, QueryString, PaginationFilter } from "../core";
|
|
2
|
-
import { ResponseWrapper } from ".";
|
|
3
|
-
import { Item } from "../api";
|
|
4
|
-
|
|
5
|
-
export class ItemWrapper implements Item.IItem {
|
|
6
|
-
"published-on"?: string | null;
|
|
7
|
-
"published-by"?: string | null;
|
|
8
|
-
"updated-on": string;
|
|
9
|
-
"created-on": string;
|
|
10
|
-
"updated-by": string;
|
|
11
|
-
"created-by": string;
|
|
12
|
-
_archived: boolean;
|
|
13
|
-
_draft: boolean;
|
|
14
|
-
_cid: string;
|
|
15
|
-
name: string;
|
|
16
|
-
slug: string;
|
|
17
|
-
_id: string;
|
|
18
|
-
|
|
19
|
-
constructor(private client: Client, item: Item.IItem) {
|
|
20
|
-
Object.assign(this, item);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**************************************************************
|
|
24
|
-
* Static Methods
|
|
25
|
-
**************************************************************/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Create a new Item
|
|
29
|
-
* @param client The Webflow client
|
|
30
|
-
* @param params The params for the request
|
|
31
|
-
* @param params.collectionId The Collection ID
|
|
32
|
-
* @param params.fields The Item fields to create
|
|
33
|
-
* @returns The created Item
|
|
34
|
-
*/
|
|
35
|
-
static async create(
|
|
36
|
-
client: Client,
|
|
37
|
-
{ collectionId, fields }: { collectionId: string; fields: any }
|
|
38
|
-
) {
|
|
39
|
-
const res = await Item.create(client, { collectionId, fields });
|
|
40
|
-
const item = new ItemWrapper(client, res.data);
|
|
41
|
-
return ResponseWrapper<typeof item>(res, item);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Get a single Item
|
|
46
|
-
* @param client The Webflow client
|
|
47
|
-
* @param params The params for the request
|
|
48
|
-
* @param params.collectionId The Collection ID
|
|
49
|
-
* @param params.itemId The Item ID
|
|
50
|
-
* @returns A single Item
|
|
51
|
-
*/
|
|
52
|
-
static async getOne(
|
|
53
|
-
client: Client,
|
|
54
|
-
itemParams: { collectionId: string; itemId: string }
|
|
55
|
-
) {
|
|
56
|
-
const res = await Item.getOne(client, itemParams);
|
|
57
|
-
const item = new ItemWrapper(client, res.data.items[0]);
|
|
58
|
-
return ResponseWrapper<typeof item>(res, item);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Get a list of Items
|
|
63
|
-
* @param client The Webflow client
|
|
64
|
-
* @param params The params for the request
|
|
65
|
-
* @param params.collectionId The Collection ID
|
|
66
|
-
* @param params.limit The number of items to return (optional)
|
|
67
|
-
* @param params.offset The number of items to skip (optional)
|
|
68
|
-
* @returns A list of Items
|
|
69
|
-
*/
|
|
70
|
-
static async list(
|
|
71
|
-
client: Client,
|
|
72
|
-
{ collectionId, limit, offset }: { collectionId: string } & PaginationFilter
|
|
73
|
-
) {
|
|
74
|
-
const res = await Item.list(client, { collectionId, limit, offset });
|
|
75
|
-
const items = res.data.items.map((i) => new ItemWrapper(client, i));
|
|
76
|
-
return ResponseWrapper<typeof items>(res, items);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Remove a single Item
|
|
81
|
-
* @param client The Webflow client
|
|
82
|
-
* @param params The params for the request
|
|
83
|
-
* @param params.collectionId The Collection ID
|
|
84
|
-
* @param params.itemId The Item ID
|
|
85
|
-
* @returns The result from the removal
|
|
86
|
-
*/
|
|
87
|
-
static async remove(
|
|
88
|
-
client: Client,
|
|
89
|
-
{ collectionId, itemId }: { collectionId: string; itemId: string }
|
|
90
|
-
) {
|
|
91
|
-
const res = await Item.remove(client, { collectionId, itemId });
|
|
92
|
-
return ResponseWrapper<typeof res.data>(res);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Publishes a list of Items
|
|
97
|
-
* @param client The Webflow client
|
|
98
|
-
* @param params The request parameters
|
|
99
|
-
* @param params.collectionId The Collection ID
|
|
100
|
-
* @param params.itemIds The list of Item IDs to publish
|
|
101
|
-
* @param params.live Publish to live site
|
|
102
|
-
* @returns The result of the publish
|
|
103
|
-
*/
|
|
104
|
-
static async publish(
|
|
105
|
-
client: Client,
|
|
106
|
-
{
|
|
107
|
-
collectionId,
|
|
108
|
-
itemIds,
|
|
109
|
-
live,
|
|
110
|
-
}: { collectionId: string; itemIds: string[]; live: boolean }
|
|
111
|
-
) {
|
|
112
|
-
const res = await Item.publish(client, { collectionId, itemIds, live });
|
|
113
|
-
return ResponseWrapper<typeof res.data>(res);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Unpublishes a list of Items
|
|
118
|
-
* @param client The Webflow client
|
|
119
|
-
* @param params The params for the request
|
|
120
|
-
* @param params.collectionId The Collection ID
|
|
121
|
-
* @param params.live Unpublish from the live site
|
|
122
|
-
* @returns The result of the unpublish
|
|
123
|
-
*/
|
|
124
|
-
static async unpublish(
|
|
125
|
-
client: Client,
|
|
126
|
-
{
|
|
127
|
-
collectionId,
|
|
128
|
-
itemIds,
|
|
129
|
-
live,
|
|
130
|
-
}: { collectionId: string; itemIds: string[]; live: boolean }
|
|
131
|
-
) {
|
|
132
|
-
const res = await Item.unpublish(client, { collectionId, itemIds, live });
|
|
133
|
-
return ResponseWrapper<typeof res.data>(res);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Update a single Item
|
|
138
|
-
* @param client The Webflow client
|
|
139
|
-
* @param params The params for the request
|
|
140
|
-
* @param params.collectionId The Collection ID
|
|
141
|
-
* @param params.itemId The Item ID
|
|
142
|
-
* @param params.fields The fields to update
|
|
143
|
-
* @returns The updated Item
|
|
144
|
-
*/
|
|
145
|
-
static async update(
|
|
146
|
-
client: Client,
|
|
147
|
-
{
|
|
148
|
-
collectionId,
|
|
149
|
-
itemId,
|
|
150
|
-
fields,
|
|
151
|
-
}: { collectionId: string; itemId: string; fields: any }
|
|
152
|
-
) {
|
|
153
|
-
const res = await Item.update(client, {
|
|
154
|
-
collectionId,
|
|
155
|
-
fields,
|
|
156
|
-
itemId,
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
const item = new ItemWrapper(client, res.data);
|
|
160
|
-
return ResponseWrapper<typeof item>(res, item);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Patch a single Item
|
|
165
|
-
* @param client The Webflow client
|
|
166
|
-
* @param params The params for the request
|
|
167
|
-
* @param params.collectionId The Collection ID
|
|
168
|
-
* @param params.itemId The Item ID
|
|
169
|
-
* @param params.fields The fields to patch
|
|
170
|
-
* @returns The patched Item
|
|
171
|
-
*/
|
|
172
|
-
static async patch(
|
|
173
|
-
client: Client,
|
|
174
|
-
{
|
|
175
|
-
collectionId,
|
|
176
|
-
itemId,
|
|
177
|
-
fields,
|
|
178
|
-
}: { collectionId: string; itemId: string; fields: any },
|
|
179
|
-
params?: QueryString
|
|
180
|
-
) {
|
|
181
|
-
const res = await Item.patch(client, {
|
|
182
|
-
collectionId,
|
|
183
|
-
fields,
|
|
184
|
-
itemId,
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
const item = new ItemWrapper(client, res.data);
|
|
188
|
-
return ResponseWrapper<typeof item>(res, item);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**************************************************************
|
|
192
|
-
* Instance Methods
|
|
193
|
-
**************************************************************/
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Update a single Item
|
|
197
|
-
* @param fields The fields to update
|
|
198
|
-
* @returns The updated Item
|
|
199
|
-
*/
|
|
200
|
-
update({ ...fields }) {
|
|
201
|
-
return ItemWrapper.update(this.client, {
|
|
202
|
-
collectionId: this._cid,
|
|
203
|
-
itemId: this._id,
|
|
204
|
-
fields,
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Remove a single Item
|
|
210
|
-
* @returns The result from the removal
|
|
211
|
-
*/
|
|
212
|
-
remove() {
|
|
213
|
-
return ItemWrapper.remove(this.client, {
|
|
214
|
-
collectionId: this._cid,
|
|
215
|
-
itemId: this._id,
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { Client, PaginationFilter } from "../core";
|
|
2
|
-
import { ResponseWrapper } from ".";
|
|
3
|
-
import { Membership } from "../api";
|
|
4
|
-
|
|
5
|
-
export class MembershipWrapper implements Membership.IUser {
|
|
6
|
-
emailVerified: boolean;
|
|
7
|
-
lastUpdated?: string;
|
|
8
|
-
createdOn: string;
|
|
9
|
-
_id: string;
|
|
10
|
-
data: any;
|
|
11
|
-
|
|
12
|
-
constructor(
|
|
13
|
-
private client: Client,
|
|
14
|
-
private siteId: string,
|
|
15
|
-
membership: Membership.IUser
|
|
16
|
-
) {
|
|
17
|
-
Object.assign(this, membership);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**************************************************************
|
|
21
|
-
* Static Methods
|
|
22
|
-
**************************************************************/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Get a single User
|
|
26
|
-
* @param client The Webflow client
|
|
27
|
-
* @param params The params for the request
|
|
28
|
-
* @param params.siteId The site ID
|
|
29
|
-
* @param params.userId The user ID
|
|
30
|
-
* @returns A single User
|
|
31
|
-
*/
|
|
32
|
-
static async getOne(
|
|
33
|
-
client: Client,
|
|
34
|
-
{ userId, siteId }: { siteId: string; userId: string }
|
|
35
|
-
) {
|
|
36
|
-
const res = await Membership.getOne(client, { userId, siteId });
|
|
37
|
-
const user = ResponseWrapper<typeof res.data>(res);
|
|
38
|
-
return new MembershipWrapper(client, siteId, user);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Get a list of Users
|
|
43
|
-
* @param client The Webflow client
|
|
44
|
-
* @param params The params for the request
|
|
45
|
-
* @param params.siteId The site ID
|
|
46
|
-
* @param params.limit The number of items to return (optional)
|
|
47
|
-
* @param params.offset The number of items to skip (optional)
|
|
48
|
-
* @returns A list of Users
|
|
49
|
-
*/
|
|
50
|
-
static async list(
|
|
51
|
-
client: Client,
|
|
52
|
-
{ siteId, limit, offset }: { siteId: string } & PaginationFilter
|
|
53
|
-
) {
|
|
54
|
-
const res = await Membership.list(client, { siteId, limit, offset });
|
|
55
|
-
const users = res.data.users.map(
|
|
56
|
-
(u) => new MembershipWrapper(client, siteId, u)
|
|
57
|
-
);
|
|
58
|
-
return ResponseWrapper<typeof users>(res, users);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Update a User
|
|
63
|
-
* @param client The Webflow client
|
|
64
|
-
* @param params The params for the request
|
|
65
|
-
* @param params.siteId The site ID
|
|
66
|
-
* @param params.userId The user ID
|
|
67
|
-
* @param params.data The data to update
|
|
68
|
-
* @returns The updated User
|
|
69
|
-
*/
|
|
70
|
-
static async update(
|
|
71
|
-
client: Client,
|
|
72
|
-
{ userId, siteId, data }: { userId: string; siteId: string; data: any }
|
|
73
|
-
) {
|
|
74
|
-
const res = await Membership.update(client, { userId, siteId, ...data });
|
|
75
|
-
const user = ResponseWrapper<typeof res.data>(res);
|
|
76
|
-
return new MembershipWrapper(client, siteId, user);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Invite a User to a site
|
|
81
|
-
* @param client The Webflow client
|
|
82
|
-
* @param params The params for the request
|
|
83
|
-
* @param params.siteId The site ID
|
|
84
|
-
* @param params.email The email address of the user to invite
|
|
85
|
-
* @returns The newly created User
|
|
86
|
-
*/
|
|
87
|
-
static async invite(
|
|
88
|
-
client: Client,
|
|
89
|
-
{ siteId, email }: { siteId: string; email: string }
|
|
90
|
-
) {
|
|
91
|
-
const res = await Membership.invite(client, { siteId, email });
|
|
92
|
-
return ResponseWrapper<typeof res.data>(res);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Get a list of Access Groups
|
|
97
|
-
* @param client The Webflow client
|
|
98
|
-
* @param params The params for the request
|
|
99
|
-
* @param params.siteId The Site ID
|
|
100
|
-
* @param params.limit The number of items to return (optional)
|
|
101
|
-
* @param params.offset The number of items to skip (optional)
|
|
102
|
-
* @returns A list of Access Groups
|
|
103
|
-
*/
|
|
104
|
-
static async accessGroups(
|
|
105
|
-
client: Client,
|
|
106
|
-
{
|
|
107
|
-
siteId,
|
|
108
|
-
limit,
|
|
109
|
-
offset,
|
|
110
|
-
}: { siteId: string; limit?: number; offset?: number }
|
|
111
|
-
) {
|
|
112
|
-
const res = await Membership.accessGroups(client, {
|
|
113
|
-
siteId,
|
|
114
|
-
limit,
|
|
115
|
-
offset,
|
|
116
|
-
});
|
|
117
|
-
return ResponseWrapper<typeof res.data>(res);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Remove a User
|
|
122
|
-
* @param client The Webflow client
|
|
123
|
-
* @param params The params for the request
|
|
124
|
-
* @param params.siteId The site ID
|
|
125
|
-
* @param params.userId The user ID
|
|
126
|
-
* @returns The result of the remove
|
|
127
|
-
*/
|
|
128
|
-
static async remove(
|
|
129
|
-
client: Client,
|
|
130
|
-
{ siteId, userId }: { siteId: string; userId: string }
|
|
131
|
-
) {
|
|
132
|
-
const res = await Membership.remove(client, { userId, siteId });
|
|
133
|
-
return ResponseWrapper<typeof res.data>(res);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**************************************************************
|
|
137
|
-
* Instance Methods
|
|
138
|
-
**************************************************************/
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Update a User
|
|
142
|
-
* @param data The data to update
|
|
143
|
-
* @returns The updated User
|
|
144
|
-
*/
|
|
145
|
-
async update(data: any) {
|
|
146
|
-
return MembershipWrapper.update(this.client, {
|
|
147
|
-
siteId: this.siteId,
|
|
148
|
-
userId: this._id,
|
|
149
|
-
data,
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Remove a User
|
|
155
|
-
* @returns The result of the remove
|
|
156
|
-
*/
|
|
157
|
-
async remove() {
|
|
158
|
-
return MembershipWrapper.remove(this.client, {
|
|
159
|
-
siteId: this.siteId,
|
|
160
|
-
userId: this._id,
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}
|
package/src/wrapper/response.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { AxiosResponse } from "axios";
|
|
2
|
-
|
|
3
|
-
export type MetaResponse<T> = T & {
|
|
4
|
-
_meta: {
|
|
5
|
-
rateLimit: {
|
|
6
|
-
limit: number;
|
|
7
|
-
remaining: number;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Wraps an HTTP response with Webflow Rate Limiting information
|
|
14
|
-
* @param response The HTTP response
|
|
15
|
-
* @param data The data to use (defaults to response.data)
|
|
16
|
-
* @returns The response with Webflow Rate Limiting information
|
|
17
|
-
*/
|
|
18
|
-
export function ResponseWrapper<T>(response: AxiosResponse, data?: T) {
|
|
19
|
-
const limit = parseInt(response.headers["x-ratelimit-limit"], 10);
|
|
20
|
-
const remaining = parseInt(response.headers["x-ratelimit-remaining"], 10);
|
|
21
|
-
|
|
22
|
-
const result: MetaResponse<T> = data || response.data;
|
|
23
|
-
result._meta = { rateLimit: { limit, remaining } };
|
|
24
|
-
return result;
|
|
25
|
-
}
|
package/src/wrapper/site.ts
DELETED
|
@@ -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
|
-
}
|