webflow-api 1.1.1 → 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/README.md +12 -1
- 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 -33
- 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} +57 -52
- package/dist/{webflow.js → core/webflow.js} +102 -61
- 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} +132 -137
- package/src/index.ts +1 -1
- package/yarn.lock +0 -5
- package/dist/api/membership.d.ts +0 -91
- package/dist/api/membership.js +0 -80
- package/dist/core/client.d.ts +0 -40
- package/dist/core/client.js +0 -49
- 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 -106
- package/dist/wrapper/response.d.ts +0 -16
- package/dist/wrapper/response.js +0 -17
- package/dist/wrapper/site.d.ts +0 -119
- package/dist/wrapper/site.js +0 -136
- package/dist/wrapper/webhook.d.ts +0 -78
- package/dist/wrapper/webhook.js +0 -82
- package/src/api/membership.ts +0 -125
- package/src/core/client.ts +0 -76
- 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 -138
- package/src/wrapper/response.ts +0 -25
- package/src/wrapper/site.ts +0 -164
- package/src/wrapper/webhook.ts +0 -116
|
@@ -1,106 +0,0 @@
|
|
|
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;
|
|
@@ -1,16 +0,0 @@
|
|
|
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>;
|
package/dist/wrapper/response.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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;
|
package/dist/wrapper/site.d.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/wrapper/site.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SiteWrapper = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
const api_1 = require("../api");
|
|
6
|
-
class SiteWrapper {
|
|
7
|
-
constructor(client, site) {
|
|
8
|
-
this.client = client;
|
|
9
|
-
Object.assign(this, site);
|
|
10
|
-
}
|
|
11
|
-
/**************************************************************
|
|
12
|
-
* Static Methods
|
|
13
|
-
**************************************************************/
|
|
14
|
-
/**
|
|
15
|
-
* Get a single Site
|
|
16
|
-
* @param client The Webflow client
|
|
17
|
-
* @param params The Site information
|
|
18
|
-
* @param params.siteId The Site ID
|
|
19
|
-
* @returns The Site
|
|
20
|
-
*/
|
|
21
|
-
static async getOne(client, { siteId }) {
|
|
22
|
-
const res = await api_1.Site.getOne(client, { siteId });
|
|
23
|
-
const site = new SiteWrapper(client, res.data);
|
|
24
|
-
return (0, _1.ResponseWrapper)(res, site);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Get a list of Sites available
|
|
28
|
-
* @param client The Webflow client
|
|
29
|
-
* @param params The query parameters (optional)
|
|
30
|
-
* @returns A list of Sites
|
|
31
|
-
*/
|
|
32
|
-
static async list(client, params) {
|
|
33
|
-
const res = await api_1.Site.list(client, params);
|
|
34
|
-
const sites = res.data.map((s) => new SiteWrapper(client, s));
|
|
35
|
-
return (0, _1.ResponseWrapper)(res, sites);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Get a list of Domains for a Site
|
|
39
|
-
* @param client The Webflow client
|
|
40
|
-
* @param params The Site information
|
|
41
|
-
* @param params.siteId The Site ID
|
|
42
|
-
* @returns A list of Domains
|
|
43
|
-
*/
|
|
44
|
-
static async domains(client, { siteId }) {
|
|
45
|
-
const res = await api_1.Site.domains(client, { siteId });
|
|
46
|
-
return (0, _1.ResponseWrapper)(res, res.data);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Publish a Site
|
|
50
|
-
* @param client The Webflow client
|
|
51
|
-
* @param params The Site information
|
|
52
|
-
* @param params.siteId The Site ID
|
|
53
|
-
* @param params.domain The domains to publish
|
|
54
|
-
* @returns The result of the publish
|
|
55
|
-
*/
|
|
56
|
-
static async publish(client, { siteId, domains }) {
|
|
57
|
-
const res = await api_1.Site.publish(client, { siteId, domains });
|
|
58
|
-
return (0, _1.ResponseWrapper)(res);
|
|
59
|
-
}
|
|
60
|
-
/**************************************************************
|
|
61
|
-
* Instance Methods
|
|
62
|
-
**************************************************************/
|
|
63
|
-
/**
|
|
64
|
-
* Get a list of domains for a site
|
|
65
|
-
* @returns A list of domains
|
|
66
|
-
*/
|
|
67
|
-
async domains() {
|
|
68
|
-
const res = await api_1.Site.domains(this.client, { siteId: this._id });
|
|
69
|
-
return (0, _1.ResponseWrapper)(res);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Publish a site
|
|
73
|
-
* @param domains The domains to publish to
|
|
74
|
-
* @returns The publish result
|
|
75
|
-
*/
|
|
76
|
-
async publishSite(domains) {
|
|
77
|
-
const res = await api_1.Site.publish(this.client, { siteId: this._id, domains });
|
|
78
|
-
return (0, _1.ResponseWrapper)(res);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Get a single Collection
|
|
82
|
-
* @param params The params for the request
|
|
83
|
-
* @param params.collectionId The collection ID
|
|
84
|
-
* @returns A single Collection
|
|
85
|
-
*/
|
|
86
|
-
async collection({ collectionId }) {
|
|
87
|
-
return _1.CollectionWrapper.getOne(this.client, { collectionId });
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Get a list of Collections
|
|
91
|
-
* @returns A list of Collections
|
|
92
|
-
*/
|
|
93
|
-
async collections() {
|
|
94
|
-
return _1.CollectionWrapper.list(this.client, { siteId: this._id });
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Get a single Webhook
|
|
98
|
-
* @param params The params for the request
|
|
99
|
-
* @param params.webhookId The webhook ID
|
|
100
|
-
* @returns A single Webhook
|
|
101
|
-
*/
|
|
102
|
-
async webhook({ webhookId }) {
|
|
103
|
-
return _1.WebhookWrapper.getOne(this.client, { siteId: this._id, webhookId });
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Get a list of Webhooks
|
|
107
|
-
* @param params The query string parameters (optional)
|
|
108
|
-
* @returns A list of Webhooks
|
|
109
|
-
*/
|
|
110
|
-
async webhooks(params) {
|
|
111
|
-
return _1.WebhookWrapper.list(this.client, { siteId: this._id }, params);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Remove a Webhook
|
|
115
|
-
* @param params The query string parameters (optional)
|
|
116
|
-
* @param params.webhookId The Webhook ID
|
|
117
|
-
* @returns The result of the removal
|
|
118
|
-
*/
|
|
119
|
-
async removeWebhook({ webhookId }) {
|
|
120
|
-
return _1.WebhookWrapper.remove(this.client, { siteId: this._id, webhookId });
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Create a new Webhook
|
|
124
|
-
* @param params1 The params for the request
|
|
125
|
-
* @param params1.url The URL to send the webhook to
|
|
126
|
-
* @param params1.triggerType The event to trigger the webhook
|
|
127
|
-
* @param params1.filter The filter to apply to the webhook (optional: form_submission only)
|
|
128
|
-
* @param params The query string parameters (optional)
|
|
129
|
-
* @returns The created webhook
|
|
130
|
-
*/
|
|
131
|
-
async createWebhook({ triggerType, filter, url }) {
|
|
132
|
-
const _params = { url, siteId: this._id, triggerType, filter };
|
|
133
|
-
return _1.WebhookWrapper.create(this.client, _params);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
exports.SiteWrapper = SiteWrapper;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Client, QueryString } from "../core";
|
|
2
|
-
import { Webhook } from "../api";
|
|
3
|
-
export declare type CreateWebhookParams = {
|
|
4
|
-
url: string;
|
|
5
|
-
siteId: string;
|
|
6
|
-
triggerType: string;
|
|
7
|
-
filter?: Webhook.Filter;
|
|
8
|
-
};
|
|
9
|
-
export declare class WebhookWrapper implements Webhook.IWebhook {
|
|
10
|
-
private client;
|
|
11
|
-
triggerType: Webhook.TriggerType;
|
|
12
|
-
triggerId: string;
|
|
13
|
-
createdOn: string;
|
|
14
|
-
lastUsed?: string;
|
|
15
|
-
site: string;
|
|
16
|
-
_id: string;
|
|
17
|
-
filter?: {
|
|
18
|
-
name: string;
|
|
19
|
-
};
|
|
20
|
-
constructor(client: Client, webhook: Webhook.IWebhook);
|
|
21
|
-
/**************************************************************
|
|
22
|
-
* Static Methods
|
|
23
|
-
**************************************************************/
|
|
24
|
-
/**
|
|
25
|
-
* Get a Webhook
|
|
26
|
-
* @param client The Webflow client
|
|
27
|
-
* @param params The Webhook params
|
|
28
|
-
* @param params.siteId The Site ID
|
|
29
|
-
* @param params.webhookId The Webhook ID
|
|
30
|
-
* @returns The Webhook
|
|
31
|
-
*/
|
|
32
|
-
static getOne(client: Client, { siteId, webhookId }: {
|
|
33
|
-
siteId: string;
|
|
34
|
-
webhookId: string;
|
|
35
|
-
}): Promise<import("./response").MetaResponse<WebhookWrapper>>;
|
|
36
|
-
/**
|
|
37
|
-
* List Webhooks
|
|
38
|
-
* @param client The Webflow client
|
|
39
|
-
* @param param1 The Webhook params
|
|
40
|
-
* @param param1.siteId The Site ID
|
|
41
|
-
* @param params Query string params (optional)
|
|
42
|
-
* @returns A list of Webhooks
|
|
43
|
-
*/
|
|
44
|
-
static list(client: Client, { siteId }: {
|
|
45
|
-
siteId: string;
|
|
46
|
-
}, params?: QueryString): Promise<import("./response").MetaResponse<WebhookWrapper[]>>;
|
|
47
|
-
/**
|
|
48
|
-
* Remove a Webhook
|
|
49
|
-
* @param client The Webflow client
|
|
50
|
-
* @param params The Webhook params
|
|
51
|
-
* @param params.siteId The Site ID
|
|
52
|
-
* @param params.webhookId The Webhook ID
|
|
53
|
-
* @returns The result of the removal
|
|
54
|
-
*/
|
|
55
|
-
static remove(client: Client, { siteId, webhookId }: {
|
|
56
|
-
siteId: string;
|
|
57
|
-
webhookId: string;
|
|
58
|
-
}): Promise<import("./response").MetaResponse<Webhook.IRemoveResult>>;
|
|
59
|
-
/**
|
|
60
|
-
* Create a Webhook
|
|
61
|
-
* @param client The Webflow client
|
|
62
|
-
* @param param1 The Webhook params
|
|
63
|
-
* @param param1.siteId The Site ID
|
|
64
|
-
* @param param1.url The URL to send the Webhook to
|
|
65
|
-
* @param param1.triggerType The event to trigger the Webhook
|
|
66
|
-
* @param param1.filter The filter to use (optional: form_submission only)
|
|
67
|
-
* @returns The created Webhook
|
|
68
|
-
*/
|
|
69
|
-
static create(client: Client, { triggerType, siteId, filter, url }: CreateWebhookParams): Promise<import("./response").MetaResponse<WebhookWrapper>>;
|
|
70
|
-
/**************************************************************
|
|
71
|
-
* Instance Methods
|
|
72
|
-
**************************************************************/
|
|
73
|
-
/**
|
|
74
|
-
* Remove a Webhook
|
|
75
|
-
* @returns The result of the removal
|
|
76
|
-
*/
|
|
77
|
-
remove(): Promise<import("./response").MetaResponse<Webhook.IRemoveResult>>;
|
|
78
|
-
}
|
package/dist/wrapper/webhook.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebhookWrapper = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
const api_1 = require("../api");
|
|
6
|
-
class WebhookWrapper {
|
|
7
|
-
constructor(client, webhook) {
|
|
8
|
-
this.client = client;
|
|
9
|
-
Object.assign(this, webhook);
|
|
10
|
-
}
|
|
11
|
-
/**************************************************************
|
|
12
|
-
* Static Methods
|
|
13
|
-
**************************************************************/
|
|
14
|
-
/**
|
|
15
|
-
* Get a Webhook
|
|
16
|
-
* @param client The Webflow client
|
|
17
|
-
* @param params The Webhook params
|
|
18
|
-
* @param params.siteId The Site ID
|
|
19
|
-
* @param params.webhookId The Webhook ID
|
|
20
|
-
* @returns The Webhook
|
|
21
|
-
*/
|
|
22
|
-
static async getOne(client, { siteId, webhookId }) {
|
|
23
|
-
const res = await api_1.Webhook.getOne(client, { siteId, webhookId });
|
|
24
|
-
const webhook = new WebhookWrapper(client, res.data);
|
|
25
|
-
return (0, _1.ResponseWrapper)(res, webhook);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* List Webhooks
|
|
29
|
-
* @param client The Webflow client
|
|
30
|
-
* @param param1 The Webhook params
|
|
31
|
-
* @param param1.siteId The Site ID
|
|
32
|
-
* @param params Query string params (optional)
|
|
33
|
-
* @returns A list of Webhooks
|
|
34
|
-
*/
|
|
35
|
-
static async list(client, { siteId }, params) {
|
|
36
|
-
const res = await api_1.Webhook.list(client, { siteId }, params);
|
|
37
|
-
const webhooks = res.data.map((w) => new WebhookWrapper(client, w));
|
|
38
|
-
return (0, _1.ResponseWrapper)(res, webhooks);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Remove a Webhook
|
|
42
|
-
* @param client The Webflow client
|
|
43
|
-
* @param params The Webhook params
|
|
44
|
-
* @param params.siteId The Site ID
|
|
45
|
-
* @param params.webhookId The Webhook ID
|
|
46
|
-
* @returns The result of the removal
|
|
47
|
-
*/
|
|
48
|
-
static async remove(client, { siteId, webhookId }) {
|
|
49
|
-
const res = await api_1.Webhook.remove(client, { siteId, webhookId });
|
|
50
|
-
return (0, _1.ResponseWrapper)(res);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Create a Webhook
|
|
54
|
-
* @param client The Webflow client
|
|
55
|
-
* @param param1 The Webhook params
|
|
56
|
-
* @param param1.siteId The Site ID
|
|
57
|
-
* @param param1.url The URL to send the Webhook to
|
|
58
|
-
* @param param1.triggerType The event to trigger the Webhook
|
|
59
|
-
* @param param1.filter The filter to use (optional: form_submission only)
|
|
60
|
-
* @returns The created Webhook
|
|
61
|
-
*/
|
|
62
|
-
static async create(client, { triggerType, siteId, filter, url }) {
|
|
63
|
-
const args = { triggerType, siteId, filter, url };
|
|
64
|
-
const res = await api_1.Webhook.create(client, args);
|
|
65
|
-
const _webhook = new WebhookWrapper(client, res.data);
|
|
66
|
-
return (0, _1.ResponseWrapper)(res, _webhook);
|
|
67
|
-
}
|
|
68
|
-
/**************************************************************
|
|
69
|
-
* Instance Methods
|
|
70
|
-
**************************************************************/
|
|
71
|
-
/**
|
|
72
|
-
* Remove a Webhook
|
|
73
|
-
* @returns The result of the removal
|
|
74
|
-
*/
|
|
75
|
-
async remove() {
|
|
76
|
-
return WebhookWrapper.remove(this.client, {
|
|
77
|
-
webhookId: this._id,
|
|
78
|
-
siteId: this.site,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
exports.WebhookWrapper = WebhookWrapper;
|
package/src/api/membership.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { Client, PaginatedData, QueryString, requireArgs } from "../core";
|
|
2
|
-
|
|
3
|
-
/**************************************************************
|
|
4
|
-
* Interfaces
|
|
5
|
-
**************************************************************/
|
|
6
|
-
export interface IUser {
|
|
7
|
-
emailVerified: boolean;
|
|
8
|
-
lastUpdated?: string;
|
|
9
|
-
createdOn: string;
|
|
10
|
-
_id: string;
|
|
11
|
-
data: any;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface IUserDelete {
|
|
15
|
-
deleted: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**************************************************************
|
|
19
|
-
* Types
|
|
20
|
-
**************************************************************/
|
|
21
|
-
export type PaginatedUsers = PaginatedData & {
|
|
22
|
-
users: IUser[];
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type UserIdParam = { siteId: string; userId: string };
|
|
26
|
-
|
|
27
|
-
/**************************************************************
|
|
28
|
-
* Functions
|
|
29
|
-
**************************************************************/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Get a list of Users
|
|
33
|
-
* @param client The Webflow client
|
|
34
|
-
* @param params The params for the request
|
|
35
|
-
* @param params.siteId The site ID
|
|
36
|
-
* @param params.limit The number of items to return (optional)
|
|
37
|
-
* @param params.offset The number of items to skip (optional)
|
|
38
|
-
* @returns A list of Users
|
|
39
|
-
*/
|
|
40
|
-
export function list(
|
|
41
|
-
client: Client,
|
|
42
|
-
{ siteId, limit, offset }: { siteId: string; limit?: number; offset?: number }
|
|
43
|
-
) {
|
|
44
|
-
requireArgs({ siteId });
|
|
45
|
-
const params = { limit, offset };
|
|
46
|
-
const path = `/sites/${siteId}/users`;
|
|
47
|
-
return client.get<PaginatedUsers>(path, { params });
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Get a single User
|
|
52
|
-
* @param client The Webflow client
|
|
53
|
-
* @param params The params for the request
|
|
54
|
-
* @param params.siteId The site ID
|
|
55
|
-
* @param params.userId The user ID
|
|
56
|
-
* @returns A single User
|
|
57
|
-
*/
|
|
58
|
-
export function getOne(
|
|
59
|
-
client: Client,
|
|
60
|
-
{ siteId, userId }: { siteId: string; userId: string }
|
|
61
|
-
) {
|
|
62
|
-
requireArgs({ siteId, userId });
|
|
63
|
-
const path = `/sites/${siteId}/users/${userId}`;
|
|
64
|
-
return client.get<IUser>(path);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Update a User
|
|
69
|
-
* @param client The Webflow client
|
|
70
|
-
* @param params The params for the request
|
|
71
|
-
* @param params.siteId The site ID
|
|
72
|
-
* @param params.userId The user ID
|
|
73
|
-
* @param params.data The data to update
|
|
74
|
-
* @returns The updated User
|
|
75
|
-
*/
|
|
76
|
-
export function update(
|
|
77
|
-
client: Client,
|
|
78
|
-
{
|
|
79
|
-
siteId,
|
|
80
|
-
userId,
|
|
81
|
-
data,
|
|
82
|
-
}: {
|
|
83
|
-
data: object;
|
|
84
|
-
siteId: string;
|
|
85
|
-
userId: string;
|
|
86
|
-
}
|
|
87
|
-
) {
|
|
88
|
-
requireArgs({ siteId, userId });
|
|
89
|
-
const path = `/sites/${siteId}/users/${userId}`;
|
|
90
|
-
return client.patch<IUser>(path, data);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Invite a User to a site
|
|
95
|
-
* @param client The Webflow client
|
|
96
|
-
* @param params The params for the request
|
|
97
|
-
* @param params.siteId The site ID
|
|
98
|
-
* @param params.email The email address of the user to invite
|
|
99
|
-
* @returns The newly created User
|
|
100
|
-
*/
|
|
101
|
-
export async function invite(
|
|
102
|
-
client: Client,
|
|
103
|
-
{ siteId, email }: { siteId: string; email: string }
|
|
104
|
-
) {
|
|
105
|
-
requireArgs({ siteId, email });
|
|
106
|
-
const path = `/sites/${siteId}/users/invite`;
|
|
107
|
-
return client.post<IUser>(path, { email });
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Remove a User
|
|
112
|
-
* @param client The Webflow client
|
|
113
|
-
* @param params The params for the request
|
|
114
|
-
* @param params.siteId The site ID
|
|
115
|
-
* @param params.userId The user ID
|
|
116
|
-
* @returns The result of the remove
|
|
117
|
-
*/
|
|
118
|
-
export function remove(
|
|
119
|
-
client: Client,
|
|
120
|
-
{ siteId, userId }: { siteId: string; userId: string }
|
|
121
|
-
) {
|
|
122
|
-
requireArgs({ siteId, userId });
|
|
123
|
-
const path = `/sites/${siteId}/users/${userId}`;
|
|
124
|
-
return client.delete<IUserDelete>(path);
|
|
125
|
-
}
|