webflow-api 1.0.3 → 1.1.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.
- package/README.md +4 -5
- package/dist/api/collection.d.ts +51 -0
- package/dist/api/collection.js +35 -0
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.js +33 -0
- package/dist/api/item.d.ts +143 -0
- package/dist/api/item.js +131 -0
- package/dist/api/membership.d.ts +91 -0
- package/dist/api/membership.js +80 -0
- package/dist/api/meta.d.ts +51 -0
- package/dist/api/meta.js +24 -0
- package/dist/api/oauth.d.ts +67 -0
- package/dist/api/oauth.js +65 -0
- package/dist/api/site.d.ts +65 -0
- package/dist/api/site.js +59 -0
- package/dist/api/webhook.d.ts +80 -0
- package/dist/api/webhook.js +67 -0
- package/dist/core/client.d.ts +40 -0
- package/dist/core/client.js +49 -0
- package/dist/core/error.d.ts +19 -0
- package/dist/core/error.js +23 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js +19 -0
- package/dist/core/options.d.ts +8 -0
- package/dist/core/options.js +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -9
- package/dist/webflow.d.ts +366 -0
- package/dist/webflow.js +388 -0
- package/dist/wrapper/collection.d.ts +85 -0
- package/dist/wrapper/collection.js +94 -0
- package/dist/wrapper/index.d.ts +6 -0
- package/dist/wrapper/index.js +22 -0
- package/dist/wrapper/item.d.ts +140 -0
- package/dist/wrapper/item.js +153 -0
- package/dist/wrapper/membership.d.ts +91 -0
- package/dist/wrapper/membership.js +106 -0
- package/dist/wrapper/response.d.ts +16 -0
- package/dist/wrapper/response.js +17 -0
- package/dist/wrapper/site.d.ts +119 -0
- package/dist/wrapper/site.js +136 -0
- package/dist/wrapper/webhook.d.ts +78 -0
- package/dist/wrapper/webhook.js +82 -0
- package/package.json +16 -18
- package/src/api/collection.ts +87 -0
- package/src/api/index.ts +7 -0
- package/src/api/item.ts +231 -0
- package/src/api/membership.ts +125 -0
- package/src/api/meta.ts +61 -0
- package/src/api/oauth.ts +119 -0
- package/src/api/site.ts +86 -0
- package/src/api/webhook.ts +125 -0
- package/src/core/client.ts +76 -0
- package/src/core/error.ts +32 -0
- package/src/core/index.ts +3 -0
- package/src/core/options.ts +9 -0
- package/src/index.ts +3 -0
- package/src/webflow.ts +487 -0
- package/src/wrapper/collection.ts +115 -0
- package/src/wrapper/index.ts +6 -0
- package/src/wrapper/item.ts +218 -0
- package/src/wrapper/membership.ts +138 -0
- package/src/wrapper/response.ts +25 -0
- package/src/wrapper/site.ts +164 -0
- package/src/wrapper/webhook.ts +116 -0
- package/yarn.lock +392 -1515
- package/dist/ResponseWrapper.js +0 -135
- package/dist/Webflow.js +0 -344
- package/dist/WebflowClient.js +0 -115
- package/index.d.ts +0 -430
- package/src/ResponseWrapper.js +0 -103
- package/src/Webflow.js +0 -301
- package/src/WebflowClient.js +0 -98
- package/src/index.js +0 -3
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Client, QueryString, PaginationFilter } from "../core";
|
|
2
|
+
import { Item } from "../api";
|
|
3
|
+
export declare class ItemWrapper implements Item.IItem {
|
|
4
|
+
private client;
|
|
5
|
+
"published-on"?: string | null;
|
|
6
|
+
"published-by"?: string | null;
|
|
7
|
+
"updated-on": string;
|
|
8
|
+
"created-on": string;
|
|
9
|
+
"updated-by": string;
|
|
10
|
+
"created-by": string;
|
|
11
|
+
_archived: boolean;
|
|
12
|
+
_draft: boolean;
|
|
13
|
+
_cid: string;
|
|
14
|
+
name: string;
|
|
15
|
+
slug: string;
|
|
16
|
+
_id: string;
|
|
17
|
+
constructor(client: Client, item: Item.IItem);
|
|
18
|
+
/**************************************************************
|
|
19
|
+
* Static Methods
|
|
20
|
+
**************************************************************/
|
|
21
|
+
/**
|
|
22
|
+
* Create a new Item
|
|
23
|
+
* @param client The Webflow client
|
|
24
|
+
* @param params The params for the request
|
|
25
|
+
* @param params.collectionId The Collection ID
|
|
26
|
+
* @param params.fields The Item fields to create
|
|
27
|
+
* @returns The created Item
|
|
28
|
+
*/
|
|
29
|
+
static create(client: Client, { collectionId, fields }: {
|
|
30
|
+
collectionId: string;
|
|
31
|
+
fields: any;
|
|
32
|
+
}): Promise<import("./response").MetaResponse<ItemWrapper>>;
|
|
33
|
+
/**
|
|
34
|
+
* Get a single Item
|
|
35
|
+
* @param client The Webflow client
|
|
36
|
+
* @param params The params for the request
|
|
37
|
+
* @param params.collectionId The Collection ID
|
|
38
|
+
* @param params.itemId The Item ID
|
|
39
|
+
* @returns A single Item
|
|
40
|
+
*/
|
|
41
|
+
static getOne(client: Client, itemParams: {
|
|
42
|
+
collectionId: string;
|
|
43
|
+
itemId: string;
|
|
44
|
+
}): Promise<import("./response").MetaResponse<ItemWrapper>>;
|
|
45
|
+
/**
|
|
46
|
+
* Get a list of Items
|
|
47
|
+
* @param client The Webflow client
|
|
48
|
+
* @param params The params for the request
|
|
49
|
+
* @param params.collectionId The Collection ID
|
|
50
|
+
* @param params.limit The number of items to return (optional)
|
|
51
|
+
* @param params.offset The number of items to skip (optional)
|
|
52
|
+
* @returns A list of Items
|
|
53
|
+
*/
|
|
54
|
+
static list(client: Client, { collectionId, limit, offset }: {
|
|
55
|
+
collectionId: string;
|
|
56
|
+
} & PaginationFilter): Promise<import("./response").MetaResponse<ItemWrapper[]>>;
|
|
57
|
+
/**
|
|
58
|
+
* Remove a single Item
|
|
59
|
+
* @param client The Webflow client
|
|
60
|
+
* @param params The params for the request
|
|
61
|
+
* @param params.collectionId The Collection ID
|
|
62
|
+
* @param params.itemId The Item ID
|
|
63
|
+
* @returns The result from the removal
|
|
64
|
+
*/
|
|
65
|
+
static remove(client: Client, { collectionId, itemId }: {
|
|
66
|
+
collectionId: string;
|
|
67
|
+
itemId: string;
|
|
68
|
+
}): Promise<import("./response").MetaResponse<Item.IItemDelete>>;
|
|
69
|
+
/**
|
|
70
|
+
* Publishes a list of Items
|
|
71
|
+
* @param client The Webflow client
|
|
72
|
+
* @param params The request parameters
|
|
73
|
+
* @param params.collectionId The Collection ID
|
|
74
|
+
* @param params.itemIds The list of Item IDs to publish
|
|
75
|
+
* @param params.live Publish to live site
|
|
76
|
+
* @returns The result of the publish
|
|
77
|
+
*/
|
|
78
|
+
static publish(client: Client, { collectionId, itemIds, live, }: {
|
|
79
|
+
collectionId: string;
|
|
80
|
+
itemIds: string[];
|
|
81
|
+
live: boolean;
|
|
82
|
+
}): Promise<import("./response").MetaResponse<Item.IPublishItems>>;
|
|
83
|
+
/**
|
|
84
|
+
* Unpublishes a list of Items
|
|
85
|
+
* @param client The Webflow client
|
|
86
|
+
* @param params The params for the request
|
|
87
|
+
* @param params.collectionId The Collection ID
|
|
88
|
+
* @param params.live Unpublish from the live site
|
|
89
|
+
* @returns The result of the unpublish
|
|
90
|
+
*/
|
|
91
|
+
static unpublish(client: Client, { collectionId, itemIds, live, }: {
|
|
92
|
+
collectionId: string;
|
|
93
|
+
itemIds: string[];
|
|
94
|
+
live: boolean;
|
|
95
|
+
}): Promise<import("./response").MetaResponse<Item.IDeletedItems>>;
|
|
96
|
+
/**
|
|
97
|
+
* Update a single Item
|
|
98
|
+
* @param client The Webflow client
|
|
99
|
+
* @param params The params for the request
|
|
100
|
+
* @param params.collectionId The Collection ID
|
|
101
|
+
* @param params.itemId The Item ID
|
|
102
|
+
* @param params.fields The fields to update
|
|
103
|
+
* @returns The updated Item
|
|
104
|
+
*/
|
|
105
|
+
static update(client: Client, { collectionId, itemId, fields, }: {
|
|
106
|
+
collectionId: string;
|
|
107
|
+
itemId: string;
|
|
108
|
+
fields: any;
|
|
109
|
+
}): Promise<import("./response").MetaResponse<ItemWrapper>>;
|
|
110
|
+
/**
|
|
111
|
+
* Patch a single Item
|
|
112
|
+
* @param client The Webflow client
|
|
113
|
+
* @param params The params for the request
|
|
114
|
+
* @param params.collectionId The Collection ID
|
|
115
|
+
* @param params.itemId The Item ID
|
|
116
|
+
* @param params.fields The fields to patch
|
|
117
|
+
* @returns The patched Item
|
|
118
|
+
*/
|
|
119
|
+
static patch(client: Client, { collectionId, itemId, fields, }: {
|
|
120
|
+
collectionId: string;
|
|
121
|
+
itemId: string;
|
|
122
|
+
fields: any;
|
|
123
|
+
}, params?: QueryString): Promise<import("./response").MetaResponse<ItemWrapper>>;
|
|
124
|
+
/**************************************************************
|
|
125
|
+
* Instance Methods
|
|
126
|
+
**************************************************************/
|
|
127
|
+
/**
|
|
128
|
+
* Update a single Item
|
|
129
|
+
* @param fields The fields to update
|
|
130
|
+
* @returns The updated Item
|
|
131
|
+
*/
|
|
132
|
+
update({ ...fields }: {
|
|
133
|
+
[x: string]: any;
|
|
134
|
+
}): Promise<import("./response").MetaResponse<ItemWrapper>>;
|
|
135
|
+
/**
|
|
136
|
+
* Remove a single Item
|
|
137
|
+
* @returns The result from the removal
|
|
138
|
+
*/
|
|
139
|
+
remove(): Promise<import("./response").MetaResponse<Item.IItemDelete>>;
|
|
140
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ItemWrapper = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const api_1 = require("../api");
|
|
6
|
+
class ItemWrapper {
|
|
7
|
+
constructor(client, item) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
Object.assign(this, item);
|
|
10
|
+
}
|
|
11
|
+
/**************************************************************
|
|
12
|
+
* Static Methods
|
|
13
|
+
**************************************************************/
|
|
14
|
+
/**
|
|
15
|
+
* Create a new Item
|
|
16
|
+
* @param client The Webflow client
|
|
17
|
+
* @param params The params for the request
|
|
18
|
+
* @param params.collectionId The Collection ID
|
|
19
|
+
* @param params.fields The Item fields to create
|
|
20
|
+
* @returns The created Item
|
|
21
|
+
*/
|
|
22
|
+
static async create(client, { collectionId, fields }) {
|
|
23
|
+
const res = await api_1.Item.create(client, { collectionId, fields });
|
|
24
|
+
const item = new ItemWrapper(client, res.data);
|
|
25
|
+
return (0, _1.ResponseWrapper)(res, item);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get a single 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.itemId The Item ID
|
|
33
|
+
* @returns A single Item
|
|
34
|
+
*/
|
|
35
|
+
static async getOne(client, itemParams) {
|
|
36
|
+
const res = await api_1.Item.getOne(client, itemParams);
|
|
37
|
+
const item = new ItemWrapper(client, res.data.items[0]);
|
|
38
|
+
return (0, _1.ResponseWrapper)(res, item);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get a list of Items
|
|
42
|
+
* @param client The Webflow client
|
|
43
|
+
* @param params The params for the request
|
|
44
|
+
* @param params.collectionId The Collection ID
|
|
45
|
+
* @param params.limit The number of items to return (optional)
|
|
46
|
+
* @param params.offset The number of items to skip (optional)
|
|
47
|
+
* @returns A list of Items
|
|
48
|
+
*/
|
|
49
|
+
static async list(client, { collectionId, limit, offset }) {
|
|
50
|
+
const res = await api_1.Item.list(client, { collectionId, limit, offset });
|
|
51
|
+
const items = res.data.items.map((i) => new ItemWrapper(client, i));
|
|
52
|
+
return (0, _1.ResponseWrapper)(res, items);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Remove a single Item
|
|
56
|
+
* @param client The Webflow client
|
|
57
|
+
* @param params The params for the request
|
|
58
|
+
* @param params.collectionId The Collection ID
|
|
59
|
+
* @param params.itemId The Item ID
|
|
60
|
+
* @returns The result from the removal
|
|
61
|
+
*/
|
|
62
|
+
static async remove(client, { collectionId, itemId }) {
|
|
63
|
+
const res = await api_1.Item.remove(client, { collectionId, itemId });
|
|
64
|
+
return (0, _1.ResponseWrapper)(res);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Publishes a list of Items
|
|
68
|
+
* @param client The Webflow client
|
|
69
|
+
* @param params The request parameters
|
|
70
|
+
* @param params.collectionId The Collection ID
|
|
71
|
+
* @param params.itemIds The list of Item IDs to publish
|
|
72
|
+
* @param params.live Publish to live site
|
|
73
|
+
* @returns The result of the publish
|
|
74
|
+
*/
|
|
75
|
+
static async publish(client, { collectionId, itemIds, live, }) {
|
|
76
|
+
const res = await api_1.Item.publish(client, { collectionId, itemIds, live });
|
|
77
|
+
return (0, _1.ResponseWrapper)(res);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Unpublishes a list of Items
|
|
81
|
+
* @param client The Webflow client
|
|
82
|
+
* @param params The params for the request
|
|
83
|
+
* @param params.collectionId The Collection ID
|
|
84
|
+
* @param params.live Unpublish from the live site
|
|
85
|
+
* @returns The result of the unpublish
|
|
86
|
+
*/
|
|
87
|
+
static async unpublish(client, { collectionId, itemIds, live, }) {
|
|
88
|
+
const res = await api_1.Item.unpublish(client, { collectionId, itemIds, live });
|
|
89
|
+
return (0, _1.ResponseWrapper)(res);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Update a single Item
|
|
93
|
+
* @param client The Webflow client
|
|
94
|
+
* @param params The params for the request
|
|
95
|
+
* @param params.collectionId The Collection ID
|
|
96
|
+
* @param params.itemId The Item ID
|
|
97
|
+
* @param params.fields The fields to update
|
|
98
|
+
* @returns The updated Item
|
|
99
|
+
*/
|
|
100
|
+
static async update(client, { collectionId, itemId, fields, }) {
|
|
101
|
+
const res = await api_1.Item.update(client, {
|
|
102
|
+
collectionId,
|
|
103
|
+
fields,
|
|
104
|
+
itemId,
|
|
105
|
+
});
|
|
106
|
+
const item = new ItemWrapper(client, res.data);
|
|
107
|
+
return (0, _1.ResponseWrapper)(res, item);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Patch a single Item
|
|
111
|
+
* @param client The Webflow client
|
|
112
|
+
* @param params The params for the request
|
|
113
|
+
* @param params.collectionId The Collection ID
|
|
114
|
+
* @param params.itemId The Item ID
|
|
115
|
+
* @param params.fields The fields to patch
|
|
116
|
+
* @returns The patched Item
|
|
117
|
+
*/
|
|
118
|
+
static async patch(client, { collectionId, itemId, fields, }, params) {
|
|
119
|
+
const res = await api_1.Item.patch(client, {
|
|
120
|
+
collectionId,
|
|
121
|
+
fields,
|
|
122
|
+
itemId,
|
|
123
|
+
});
|
|
124
|
+
const item = new ItemWrapper(client, res.data);
|
|
125
|
+
return (0, _1.ResponseWrapper)(res, item);
|
|
126
|
+
}
|
|
127
|
+
/**************************************************************
|
|
128
|
+
* Instance Methods
|
|
129
|
+
**************************************************************/
|
|
130
|
+
/**
|
|
131
|
+
* Update a single Item
|
|
132
|
+
* @param fields The fields to update
|
|
133
|
+
* @returns The updated Item
|
|
134
|
+
*/
|
|
135
|
+
update({ ...fields }) {
|
|
136
|
+
return ItemWrapper.update(this.client, {
|
|
137
|
+
collectionId: this._cid,
|
|
138
|
+
itemId: this._id,
|
|
139
|
+
fields,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Remove a single Item
|
|
144
|
+
* @returns The result from the removal
|
|
145
|
+
*/
|
|
146
|
+
remove() {
|
|
147
|
+
return ItemWrapper.remove(this.client, {
|
|
148
|
+
collectionId: this._cid,
|
|
149
|
+
itemId: this._id,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.ItemWrapper = ItemWrapper;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Client, PaginationFilter } from "../core";
|
|
2
|
+
import { Membership } from "../api";
|
|
3
|
+
export declare class MembershipWrapper implements Membership.IUser {
|
|
4
|
+
private client;
|
|
5
|
+
private siteId;
|
|
6
|
+
emailVerified: boolean;
|
|
7
|
+
lastUpdated?: string;
|
|
8
|
+
createdOn: string;
|
|
9
|
+
_id: string;
|
|
10
|
+
data: any;
|
|
11
|
+
constructor(client: Client, siteId: string, membership: Membership.IUser);
|
|
12
|
+
/**************************************************************
|
|
13
|
+
* Static Methods
|
|
14
|
+
**************************************************************/
|
|
15
|
+
/**
|
|
16
|
+
* Get a single User
|
|
17
|
+
* @param client The Webflow client
|
|
18
|
+
* @param params The params for the request
|
|
19
|
+
* @param params.siteId The site ID
|
|
20
|
+
* @param params.userId The user ID
|
|
21
|
+
* @returns A single User
|
|
22
|
+
*/
|
|
23
|
+
static getOne(client: Client, { userId, siteId }: {
|
|
24
|
+
siteId: string;
|
|
25
|
+
userId: string;
|
|
26
|
+
}): Promise<MembershipWrapper>;
|
|
27
|
+
/**
|
|
28
|
+
* Get a list of Users
|
|
29
|
+
* @param client The Webflow client
|
|
30
|
+
* @param params The params for the request
|
|
31
|
+
* @param params.siteId The site ID
|
|
32
|
+
* @param params.limit The number of items to return (optional)
|
|
33
|
+
* @param params.offset The number of items to skip (optional)
|
|
34
|
+
* @returns A list of Users
|
|
35
|
+
*/
|
|
36
|
+
static list(client: Client, { siteId, limit, offset }: {
|
|
37
|
+
siteId: string;
|
|
38
|
+
} & PaginationFilter): Promise<import("./response").MetaResponse<MembershipWrapper[]>>;
|
|
39
|
+
/**
|
|
40
|
+
* Update a User
|
|
41
|
+
* @param client The Webflow client
|
|
42
|
+
* @param params The params for the request
|
|
43
|
+
* @param params.siteId The site ID
|
|
44
|
+
* @param params.userId The user ID
|
|
45
|
+
* @param params.data The data to update
|
|
46
|
+
* @returns The updated User
|
|
47
|
+
*/
|
|
48
|
+
static update(client: Client, { userId, siteId, data }: {
|
|
49
|
+
userId: string;
|
|
50
|
+
siteId: string;
|
|
51
|
+
data: any;
|
|
52
|
+
}): Promise<MembershipWrapper>;
|
|
53
|
+
/**
|
|
54
|
+
* Invite a User to a site
|
|
55
|
+
* @param client The Webflow client
|
|
56
|
+
* @param params The params for the request
|
|
57
|
+
* @param params.siteId The site ID
|
|
58
|
+
* @param params.email The email address of the user to invite
|
|
59
|
+
* @returns The newly created User
|
|
60
|
+
*/
|
|
61
|
+
static invite(client: Client, { siteId, email }: {
|
|
62
|
+
siteId: string;
|
|
63
|
+
email: string;
|
|
64
|
+
}): Promise<import("./response").MetaResponse<Membership.IUser>>;
|
|
65
|
+
/**
|
|
66
|
+
* Remove a User
|
|
67
|
+
* @param client The Webflow client
|
|
68
|
+
* @param params The params for the request
|
|
69
|
+
* @param params.siteId The site ID
|
|
70
|
+
* @param params.userId The user ID
|
|
71
|
+
* @returns The result of the remove
|
|
72
|
+
*/
|
|
73
|
+
static remove(client: Client, { siteId, userId }: {
|
|
74
|
+
siteId: string;
|
|
75
|
+
userId: string;
|
|
76
|
+
}): Promise<import("./response").MetaResponse<Membership.IUserDelete>>;
|
|
77
|
+
/**************************************************************
|
|
78
|
+
* Instance Methods
|
|
79
|
+
**************************************************************/
|
|
80
|
+
/**
|
|
81
|
+
* Update a User
|
|
82
|
+
* @param data The data to update
|
|
83
|
+
* @returns The updated User
|
|
84
|
+
*/
|
|
85
|
+
update(data: any): Promise<MembershipWrapper>;
|
|
86
|
+
/**
|
|
87
|
+
* Remove a User
|
|
88
|
+
* @returns The result of the remove
|
|
89
|
+
*/
|
|
90
|
+
remove(): Promise<import("./response").MetaResponse<Membership.IUserDelete>>;
|
|
91
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MembershipWrapper = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const api_1 = require("../api");
|
|
6
|
+
class MembershipWrapper {
|
|
7
|
+
constructor(client, siteId, membership) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
this.siteId = siteId;
|
|
10
|
+
Object.assign(this, membership);
|
|
11
|
+
}
|
|
12
|
+
/**************************************************************
|
|
13
|
+
* Static Methods
|
|
14
|
+
**************************************************************/
|
|
15
|
+
/**
|
|
16
|
+
* Get a single User
|
|
17
|
+
* @param client The Webflow client
|
|
18
|
+
* @param params The params for the request
|
|
19
|
+
* @param params.siteId The site ID
|
|
20
|
+
* @param params.userId The user ID
|
|
21
|
+
* @returns A single User
|
|
22
|
+
*/
|
|
23
|
+
static async getOne(client, { userId, siteId }) {
|
|
24
|
+
const res = await api_1.Membership.getOne(client, { userId, siteId });
|
|
25
|
+
const user = (0, _1.ResponseWrapper)(res);
|
|
26
|
+
return new MembershipWrapper(client, siteId, user);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get a list of Users
|
|
30
|
+
* @param client The Webflow client
|
|
31
|
+
* @param params The params for the request
|
|
32
|
+
* @param params.siteId The site ID
|
|
33
|
+
* @param params.limit The number of items to return (optional)
|
|
34
|
+
* @param params.offset The number of items to skip (optional)
|
|
35
|
+
* @returns A list of Users
|
|
36
|
+
*/
|
|
37
|
+
static async list(client, { siteId, limit, offset }) {
|
|
38
|
+
const res = await api_1.Membership.list(client, { siteId, limit, offset });
|
|
39
|
+
const users = res.data.users.map((u) => new MembershipWrapper(client, siteId, u));
|
|
40
|
+
return (0, _1.ResponseWrapper)(res, users);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Update a User
|
|
44
|
+
* @param client The Webflow client
|
|
45
|
+
* @param params The params for the request
|
|
46
|
+
* @param params.siteId The site ID
|
|
47
|
+
* @param params.userId The user ID
|
|
48
|
+
* @param params.data The data to update
|
|
49
|
+
* @returns The updated User
|
|
50
|
+
*/
|
|
51
|
+
static async update(client, { userId, siteId, data }) {
|
|
52
|
+
const res = await api_1.Membership.update(client, { userId, siteId, data });
|
|
53
|
+
const user = (0, _1.ResponseWrapper)(res);
|
|
54
|
+
return new MembershipWrapper(client, siteId, user);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Invite a User to a site
|
|
58
|
+
* @param client The Webflow client
|
|
59
|
+
* @param params The params for the request
|
|
60
|
+
* @param params.siteId The site ID
|
|
61
|
+
* @param params.email The email address of the user to invite
|
|
62
|
+
* @returns The newly created User
|
|
63
|
+
*/
|
|
64
|
+
static async invite(client, { siteId, email }) {
|
|
65
|
+
const res = await api_1.Membership.invite(client, { siteId, email });
|
|
66
|
+
return (0, _1.ResponseWrapper)(res);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Remove a User
|
|
70
|
+
* @param client The Webflow client
|
|
71
|
+
* @param params The params for the request
|
|
72
|
+
* @param params.siteId The site ID
|
|
73
|
+
* @param params.userId The user ID
|
|
74
|
+
* @returns The result of the remove
|
|
75
|
+
*/
|
|
76
|
+
static async remove(client, { siteId, userId }) {
|
|
77
|
+
const res = await api_1.Membership.remove(client, { userId, siteId });
|
|
78
|
+
return (0, _1.ResponseWrapper)(res);
|
|
79
|
+
}
|
|
80
|
+
/**************************************************************
|
|
81
|
+
* Instance Methods
|
|
82
|
+
**************************************************************/
|
|
83
|
+
/**
|
|
84
|
+
* Update a User
|
|
85
|
+
* @param data The data to update
|
|
86
|
+
* @returns The updated User
|
|
87
|
+
*/
|
|
88
|
+
async update(data) {
|
|
89
|
+
return MembershipWrapper.update(this.client, {
|
|
90
|
+
siteId: this.siteId,
|
|
91
|
+
userId: this._id,
|
|
92
|
+
data,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Remove a User
|
|
97
|
+
* @returns The result of the remove
|
|
98
|
+
*/
|
|
99
|
+
async remove() {
|
|
100
|
+
return MembershipWrapper.remove(this.client, {
|
|
101
|
+
siteId: this.siteId,
|
|
102
|
+
userId: this._id,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.MembershipWrapper = MembershipWrapper;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AxiosResponse } from "axios";
|
|
2
|
+
export declare type MetaResponse<T> = T & {
|
|
3
|
+
_meta: {
|
|
4
|
+
rateLimit: {
|
|
5
|
+
limit: number;
|
|
6
|
+
remaining: number;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Wraps an HTTP response with Webflow Rate Limiting information
|
|
12
|
+
* @param response The HTTP response
|
|
13
|
+
* @param data The data to use (defaults to response.data)
|
|
14
|
+
* @returns The response with Webflow Rate Limiting information
|
|
15
|
+
*/
|
|
16
|
+
export declare function ResponseWrapper<T>(response: AxiosResponse, data?: T): MetaResponse<T>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResponseWrapper = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Wraps an HTTP response with Webflow Rate Limiting information
|
|
6
|
+
* @param response The HTTP response
|
|
7
|
+
* @param data The data to use (defaults to response.data)
|
|
8
|
+
* @returns The response with Webflow Rate Limiting information
|
|
9
|
+
*/
|
|
10
|
+
function ResponseWrapper(response, data) {
|
|
11
|
+
const limit = parseInt(response.headers["x-ratelimit-limit"], 10);
|
|
12
|
+
const remaining = parseInt(response.headers["x-ratelimit-remaining"], 10);
|
|
13
|
+
const result = data || response.data;
|
|
14
|
+
result._meta = { rateLimit: { limit, remaining } };
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
exports.ResponseWrapper = ResponseWrapper;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { CreateWebhookParams, CollectionWrapper, WebhookWrapper } from ".";
|
|
2
|
+
import { Client, QueryString } from "../core";
|
|
3
|
+
import { Site } from "../api";
|
|
4
|
+
export declare class SiteWrapper implements Site.ISite {
|
|
5
|
+
private client;
|
|
6
|
+
lastPublished: string;
|
|
7
|
+
previewUrl: string;
|
|
8
|
+
createdOn: string;
|
|
9
|
+
shortName: string;
|
|
10
|
+
timezone: string;
|
|
11
|
+
database: string;
|
|
12
|
+
name: string;
|
|
13
|
+
_id: string;
|
|
14
|
+
constructor(client: Client, site: Site.ISite);
|
|
15
|
+
/**************************************************************
|
|
16
|
+
* Static Methods
|
|
17
|
+
**************************************************************/
|
|
18
|
+
/**
|
|
19
|
+
* Get a single Site
|
|
20
|
+
* @param client The Webflow client
|
|
21
|
+
* @param params The Site information
|
|
22
|
+
* @param params.siteId The Site ID
|
|
23
|
+
* @returns The Site
|
|
24
|
+
*/
|
|
25
|
+
static getOne(client: Client, { siteId }: {
|
|
26
|
+
siteId: string;
|
|
27
|
+
}): Promise<import("./response").MetaResponse<SiteWrapper>>;
|
|
28
|
+
/**
|
|
29
|
+
* Get a list of Sites available
|
|
30
|
+
* @param client The Webflow client
|
|
31
|
+
* @param params The query parameters (optional)
|
|
32
|
+
* @returns A list of Sites
|
|
33
|
+
*/
|
|
34
|
+
static list(client: Client, params?: QueryString): Promise<import("./response").MetaResponse<SiteWrapper[]>>;
|
|
35
|
+
/**
|
|
36
|
+
* Get a list of Domains for a Site
|
|
37
|
+
* @param client The Webflow client
|
|
38
|
+
* @param params The Site information
|
|
39
|
+
* @param params.siteId The Site ID
|
|
40
|
+
* @returns A list of Domains
|
|
41
|
+
*/
|
|
42
|
+
static domains(client: Client, { siteId }: {
|
|
43
|
+
siteId: string;
|
|
44
|
+
}): Promise<import("./response").MetaResponse<Site.IDomain[]>>;
|
|
45
|
+
/**
|
|
46
|
+
* Publish a Site
|
|
47
|
+
* @param client The Webflow client
|
|
48
|
+
* @param params The Site information
|
|
49
|
+
* @param params.siteId The Site ID
|
|
50
|
+
* @param params.domain The domains to publish
|
|
51
|
+
* @returns The result of the publish
|
|
52
|
+
*/
|
|
53
|
+
static publish(client: Client, { siteId, domains }: {
|
|
54
|
+
siteId: string;
|
|
55
|
+
domains: string[];
|
|
56
|
+
}): Promise<import("./response").MetaResponse<Site.IPublishSite>>;
|
|
57
|
+
/**************************************************************
|
|
58
|
+
* Instance Methods
|
|
59
|
+
**************************************************************/
|
|
60
|
+
/**
|
|
61
|
+
* Get a list of domains for a site
|
|
62
|
+
* @returns A list of domains
|
|
63
|
+
*/
|
|
64
|
+
domains(): Promise<import("./response").MetaResponse<Site.IDomain[]>>;
|
|
65
|
+
/**
|
|
66
|
+
* Publish a site
|
|
67
|
+
* @param domains The domains to publish to
|
|
68
|
+
* @returns The publish result
|
|
69
|
+
*/
|
|
70
|
+
publishSite(domains: string[]): Promise<import("./response").MetaResponse<Site.IPublishSite>>;
|
|
71
|
+
/**
|
|
72
|
+
* Get a single Collection
|
|
73
|
+
* @param params The params for the request
|
|
74
|
+
* @param params.collectionId The collection ID
|
|
75
|
+
* @returns A single Collection
|
|
76
|
+
*/
|
|
77
|
+
collection({ collectionId }: {
|
|
78
|
+
collectionId: string;
|
|
79
|
+
}): Promise<import("./response").MetaResponse<CollectionWrapper>>;
|
|
80
|
+
/**
|
|
81
|
+
* Get a list of Collections
|
|
82
|
+
* @returns A list of Collections
|
|
83
|
+
*/
|
|
84
|
+
collections(): Promise<import("./response").MetaResponse<CollectionWrapper[]>>;
|
|
85
|
+
/**
|
|
86
|
+
* Get a single Webhook
|
|
87
|
+
* @param params The params for the request
|
|
88
|
+
* @param params.webhookId The webhook ID
|
|
89
|
+
* @returns A single Webhook
|
|
90
|
+
*/
|
|
91
|
+
webhook({ webhookId }: {
|
|
92
|
+
webhookId: string;
|
|
93
|
+
}): Promise<import("./response").MetaResponse<WebhookWrapper>>;
|
|
94
|
+
/**
|
|
95
|
+
* Get a list of Webhooks
|
|
96
|
+
* @param params The query string parameters (optional)
|
|
97
|
+
* @returns A list of Webhooks
|
|
98
|
+
*/
|
|
99
|
+
webhooks(params?: QueryString): Promise<import("./response").MetaResponse<WebhookWrapper[]>>;
|
|
100
|
+
/**
|
|
101
|
+
* Remove a Webhook
|
|
102
|
+
* @param params The query string parameters (optional)
|
|
103
|
+
* @param params.webhookId The Webhook ID
|
|
104
|
+
* @returns The result of the removal
|
|
105
|
+
*/
|
|
106
|
+
removeWebhook({ webhookId }: {
|
|
107
|
+
webhookId: string;
|
|
108
|
+
}): Promise<import("./response").MetaResponse<import("../api/webhook").IRemoveResult>>;
|
|
109
|
+
/**
|
|
110
|
+
* Create a new Webhook
|
|
111
|
+
* @param params1 The params for the request
|
|
112
|
+
* @param params1.url The URL to send the webhook to
|
|
113
|
+
* @param params1.triggerType The event to trigger the webhook
|
|
114
|
+
* @param params1.filter The filter to apply to the webhook (optional: form_submission only)
|
|
115
|
+
* @param params The query string parameters (optional)
|
|
116
|
+
* @returns The created webhook
|
|
117
|
+
*/
|
|
118
|
+
createWebhook({ triggerType, filter, url }: CreateWebhookParams): Promise<import("./response").MetaResponse<WebhookWrapper>>;
|
|
119
|
+
}
|