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
package/dist/api/webhook.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { WebflowRecord } from "../core";
|
|
2
3
|
/**************************************************************
|
|
3
4
|
* Types
|
|
4
5
|
**************************************************************/
|
|
5
6
|
export declare type TriggerType = "form_submission" | "site_publish" | "ecomm_new_order" | "ecomm_order_changed" | "ecomm_inventory_changed" | "collection_item_created" | "collection_item_changed" | "collection_item_deleted" | string;
|
|
6
|
-
export declare type
|
|
7
|
+
export declare type WebhookFilter = {
|
|
7
8
|
name: string;
|
|
8
9
|
};
|
|
9
10
|
/**************************************************************
|
|
@@ -24,57 +25,78 @@ export interface IRemoveResult {
|
|
|
24
25
|
deleted: number;
|
|
25
26
|
}
|
|
26
27
|
/**************************************************************
|
|
27
|
-
*
|
|
28
|
+
* Class
|
|
28
29
|
**************************************************************/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
siteId:
|
|
50
|
-
|
|
51
|
-
}): Promise<import("axios").AxiosResponse<IWebhook, any>>;
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}): Promise<import("axios").AxiosResponse<
|
|
30
|
+
export declare class Webhook extends WebflowRecord<IWebhook> implements IWebhook {
|
|
31
|
+
filter?: {
|
|
32
|
+
name: string;
|
|
33
|
+
};
|
|
34
|
+
triggerType: string;
|
|
35
|
+
triggerId: string;
|
|
36
|
+
createdOn: string;
|
|
37
|
+
lastUsed?: string;
|
|
38
|
+
site: string;
|
|
39
|
+
_id: string;
|
|
40
|
+
/**************************************************************
|
|
41
|
+
* Static Methods
|
|
42
|
+
**************************************************************/
|
|
43
|
+
/**
|
|
44
|
+
* Get a list of Webhooks
|
|
45
|
+
* @param params The params for the request
|
|
46
|
+
* @param params.siteId The site ID
|
|
47
|
+
* @param client The Axios client instance
|
|
48
|
+
* @returns A list of Webhooks
|
|
49
|
+
*/
|
|
50
|
+
static list({ siteId }: {
|
|
51
|
+
siteId: string;
|
|
52
|
+
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IWebhook[], any>>;
|
|
53
|
+
/**
|
|
54
|
+
* Get a single Webhook
|
|
55
|
+
* @param params The params for the request
|
|
56
|
+
* @param params.siteId The site ID
|
|
57
|
+
* @param params.webhookId The webhook ID
|
|
58
|
+
* @param client The Axios client instance
|
|
59
|
+
* @returns A single Webhook
|
|
60
|
+
*/
|
|
61
|
+
static getOne({ siteId, webhookId }: {
|
|
62
|
+
siteId: string;
|
|
63
|
+
webhookId: string;
|
|
64
|
+
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IWebhook, any>>;
|
|
65
|
+
/**
|
|
66
|
+
* Create a new Webhook
|
|
67
|
+
* @param params The params for the request
|
|
68
|
+
* @param params.siteId The site ID
|
|
69
|
+
* @param params.url The URL to send the webhook to
|
|
70
|
+
* @param params.triggerType The event to trigger the webhook
|
|
71
|
+
* @param params.filter The filter to apply to the webhook (optional: form_submission only)
|
|
72
|
+
* @param params.params The query string parameters (optional)
|
|
73
|
+
* @param client The Axios client instance
|
|
74
|
+
* @returns The created webhook
|
|
75
|
+
*/
|
|
76
|
+
static create({ triggerType, siteId, filter, url, }: {
|
|
77
|
+
url: string;
|
|
78
|
+
siteId: string;
|
|
79
|
+
filter?: WebhookFilter;
|
|
80
|
+
triggerType: TriggerType;
|
|
81
|
+
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IWebhook, any>>;
|
|
82
|
+
/**
|
|
83
|
+
* Remove a Webhook
|
|
84
|
+
* @param params The query string parameters (optional)
|
|
85
|
+
* @param params.webhookId The Webhook ID
|
|
86
|
+
* @param params.siteId The Site ID
|
|
87
|
+
* @param client The Axios client instance
|
|
88
|
+
* @returns The result of the removal
|
|
89
|
+
*/
|
|
90
|
+
static remove({ siteId, webhookId }: {
|
|
91
|
+
siteId: string;
|
|
92
|
+
webhookId: string;
|
|
93
|
+
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IRemoveResult, any>>;
|
|
94
|
+
/**************************************************************
|
|
95
|
+
* Instance Methods
|
|
96
|
+
**************************************************************/
|
|
97
|
+
/**
|
|
98
|
+
* Remove a Webhook
|
|
99
|
+
* @returns The result of the removal
|
|
100
|
+
*/
|
|
101
|
+
remove(): Promise<IRemoveResult>;
|
|
102
|
+
}
|
package/dist/api/webhook.js
CHANGED
|
@@ -1,67 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Webhook = void 0;
|
|
4
4
|
const core_1 = require("../core");
|
|
5
5
|
/**************************************************************
|
|
6
|
-
*
|
|
6
|
+
* Class
|
|
7
7
|
**************************************************************/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
class Webhook extends core_1.WebflowRecord {
|
|
9
|
+
/**************************************************************
|
|
10
|
+
* Static Methods
|
|
11
|
+
**************************************************************/
|
|
12
|
+
/**
|
|
13
|
+
* Get a list of Webhooks
|
|
14
|
+
* @param params The params for the request
|
|
15
|
+
* @param params.siteId The site ID
|
|
16
|
+
* @param client The Axios client instance
|
|
17
|
+
* @returns A list of Webhooks
|
|
18
|
+
*/
|
|
19
|
+
static list({ siteId }, client) {
|
|
20
|
+
(0, core_1.requireArgs)({ siteId });
|
|
21
|
+
const path = `/sites/${siteId}/webhooks`;
|
|
22
|
+
return client.get(path);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get a single Webhook
|
|
26
|
+
* @param params The params for the request
|
|
27
|
+
* @param params.siteId The site ID
|
|
28
|
+
* @param params.webhookId The webhook ID
|
|
29
|
+
* @param client The Axios client instance
|
|
30
|
+
* @returns A single Webhook
|
|
31
|
+
*/
|
|
32
|
+
static getOne({ siteId, webhookId }, client) {
|
|
33
|
+
(0, core_1.requireArgs)({ siteId, webhookId });
|
|
34
|
+
const path = `/sites/${siteId}/webhooks/${webhookId}`;
|
|
35
|
+
return client.get(path);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a new Webhook
|
|
39
|
+
* @param params The params for the request
|
|
40
|
+
* @param params.siteId The site ID
|
|
41
|
+
* @param params.url The URL to send the webhook to
|
|
42
|
+
* @param params.triggerType The event to trigger the webhook
|
|
43
|
+
* @param params.filter The filter to apply to the webhook (optional: form_submission only)
|
|
44
|
+
* @param params.params The query string parameters (optional)
|
|
45
|
+
* @param client The Axios client instance
|
|
46
|
+
* @returns The created webhook
|
|
47
|
+
*/
|
|
48
|
+
static create({ triggerType, siteId, filter, url, }, client) {
|
|
49
|
+
(0, core_1.requireArgs)({ siteId, triggerType, url });
|
|
50
|
+
const path = `/sites/${siteId}/webhooks`;
|
|
51
|
+
const data = { triggerType, url, filter };
|
|
52
|
+
return client.post(path, data);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Remove a Webhook
|
|
56
|
+
* @param params The query string parameters (optional)
|
|
57
|
+
* @param params.webhookId The Webhook ID
|
|
58
|
+
* @param params.siteId The Site ID
|
|
59
|
+
* @param client The Axios client instance
|
|
60
|
+
* @returns The result of the removal
|
|
61
|
+
*/
|
|
62
|
+
static remove({ siteId, webhookId }, client) {
|
|
63
|
+
(0, core_1.requireArgs)({ siteId, webhookId });
|
|
64
|
+
const path = `/sites/${siteId}/webhooks/${webhookId}`;
|
|
65
|
+
return client.delete(path);
|
|
66
|
+
}
|
|
67
|
+
/**************************************************************
|
|
68
|
+
* Instance Methods
|
|
69
|
+
**************************************************************/
|
|
70
|
+
/**
|
|
71
|
+
* Remove a Webhook
|
|
72
|
+
* @returns The result of the removal
|
|
73
|
+
*/
|
|
74
|
+
async remove() {
|
|
75
|
+
const params = { siteId: this.site, webhookId: this._id };
|
|
76
|
+
const res = await Webhook.remove(params, this.client);
|
|
77
|
+
return res.data;
|
|
78
|
+
}
|
|
20
79
|
}
|
|
21
|
-
exports.
|
|
22
|
-
/**
|
|
23
|
-
* Get a single Webhook
|
|
24
|
-
* @param client The Webflow client
|
|
25
|
-
* @param params The params for the request
|
|
26
|
-
* @param params.siteId The site ID
|
|
27
|
-
* @param params.webhookId The webhook ID
|
|
28
|
-
* @returns A single Webhook
|
|
29
|
-
*/
|
|
30
|
-
function getOne(client, { siteId, webhookId }) {
|
|
31
|
-
(0, core_1.requireArgs)({ siteId, webhookId });
|
|
32
|
-
const path = `/sites/${siteId}/webhooks/${webhookId}`;
|
|
33
|
-
return client.get(path);
|
|
34
|
-
}
|
|
35
|
-
exports.getOne = getOne;
|
|
36
|
-
/**
|
|
37
|
-
* Create a new Webhook
|
|
38
|
-
* @param client The Webflow client
|
|
39
|
-
* @param params The params for the request
|
|
40
|
-
* @param params.siteId The site ID
|
|
41
|
-
* @param params.url The URL to send the webhook to
|
|
42
|
-
* @param params.triggerType The event to trigger the webhook
|
|
43
|
-
* @param params.filter The filter to apply to the webhook (optional: form_submission only)
|
|
44
|
-
* @param params.params The query string parameters (optional)
|
|
45
|
-
* @returns The created webhook
|
|
46
|
-
*/
|
|
47
|
-
function create(client, { triggerType, siteId, filter, url, }) {
|
|
48
|
-
(0, core_1.requireArgs)({ siteId, triggerType, url });
|
|
49
|
-
const path = `/sites/${siteId}/webhooks`;
|
|
50
|
-
const data = { triggerType, url, filter };
|
|
51
|
-
return client.post(path, data);
|
|
52
|
-
}
|
|
53
|
-
exports.create = create;
|
|
54
|
-
/**
|
|
55
|
-
* Remove a Webhook
|
|
56
|
-
* @param client The Webflow client
|
|
57
|
-
* @param params The query string parameters (optional)
|
|
58
|
-
* @param params.webhookId The Webhook ID
|
|
59
|
-
* @param params.siteId The Site ID
|
|
60
|
-
* @returns The result of the removal
|
|
61
|
-
*/
|
|
62
|
-
function remove(client, { siteId, webhookId }) {
|
|
63
|
-
(0, core_1.requireArgs)({ siteId, webhookId });
|
|
64
|
-
const path = `/sites/${siteId}/webhooks/${webhookId}`;
|
|
65
|
-
return client.delete(path);
|
|
66
|
-
}
|
|
67
|
-
exports.remove = remove;
|
|
80
|
+
exports.Webhook = Webhook;
|
package/dist/core/error.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AxiosResponse } from "axios";
|
|
1
2
|
export interface IRequestError {
|
|
2
3
|
msg: string;
|
|
3
4
|
code: number;
|
|
@@ -17,3 +18,4 @@ export declare class ArgumentError extends Error {
|
|
|
17
18
|
constructor(name: string);
|
|
18
19
|
}
|
|
19
20
|
export declare function requireArgs(args: object): void;
|
|
21
|
+
export declare function ErrorInterceptor(res: AxiosResponse): AxiosResponse<any, any>;
|
package/dist/core/error.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requireArgs = exports.ArgumentError = exports.RequestError = void 0;
|
|
3
|
+
exports.ErrorInterceptor = exports.requireArgs = exports.ArgumentError = exports.RequestError = void 0;
|
|
4
4
|
class RequestError extends Error {
|
|
5
5
|
constructor(error) {
|
|
6
6
|
super(error.err ? error.err : "Unknown error occured");
|
|
@@ -21,3 +21,10 @@ function requireArgs(args) {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
exports.requireArgs = requireArgs;
|
|
24
|
+
// throw an error if Webflow error
|
|
25
|
+
function ErrorInterceptor(res) {
|
|
26
|
+
if (res.data.err)
|
|
27
|
+
throw new RequestError(res.data);
|
|
28
|
+
return res;
|
|
29
|
+
}
|
|
30
|
+
exports.ErrorInterceptor = ErrorInterceptor;
|
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.js
CHANGED
|
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./client"), exports);
|
|
18
17
|
__exportStar(require("./error"), exports);
|
|
19
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./response"), exports);
|
|
19
|
+
__exportStar(require("./webflow"), exports);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosResponse } from "axios";
|
|
2
|
+
/**************************************************************
|
|
3
|
+
* Types
|
|
4
|
+
**************************************************************/
|
|
5
|
+
export declare type PaginationFilter = {
|
|
6
|
+
limit?: number;
|
|
7
|
+
offset?: number;
|
|
8
|
+
};
|
|
9
|
+
export declare type WebflowHeaders = Record<string, any>;
|
|
10
|
+
/**************************************************************
|
|
11
|
+
* Interfaces
|
|
12
|
+
************************************************************* */
|
|
13
|
+
export interface PaginatedData {
|
|
14
|
+
count: number;
|
|
15
|
+
limit: number;
|
|
16
|
+
offset: number;
|
|
17
|
+
total: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class MetaResponse<T> {
|
|
20
|
+
response: AxiosResponse<T>;
|
|
21
|
+
rateLimit: {
|
|
22
|
+
limit: number;
|
|
23
|
+
remaining: number;
|
|
24
|
+
};
|
|
25
|
+
constructor(response: AxiosResponse<T>);
|
|
26
|
+
}
|
|
27
|
+
export declare class WebflowRecord<T> {
|
|
28
|
+
response: AxiosResponse<T>;
|
|
29
|
+
_meta: MetaResponse<T>;
|
|
30
|
+
client: AxiosInstance;
|
|
31
|
+
constructor(client: AxiosInstance, response: AxiosResponse<any>, record?: T, ...args: any[]);
|
|
32
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebflowRecord = exports.MetaResponse = void 0;
|
|
4
|
+
class MetaResponse {
|
|
5
|
+
constructor(response) {
|
|
6
|
+
this.response = response;
|
|
7
|
+
this.rateLimit = {
|
|
8
|
+
limit: parseInt(response.headers["x-ratelimit-limit"], 10),
|
|
9
|
+
remaining: parseInt(response.headers["x-ratelimit-remaining"], 10),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.MetaResponse = MetaResponse;
|
|
14
|
+
class WebflowRecord {
|
|
15
|
+
constructor(client, response, record, ...args) {
|
|
16
|
+
Object.assign(this, record || response.data, ...args); // Copy the record data
|
|
17
|
+
// dynamically add client and response to object
|
|
18
|
+
// without serializing during toString()
|
|
19
|
+
Object.defineProperties(this, {
|
|
20
|
+
client: { get: () => client },
|
|
21
|
+
response: { get: () => response },
|
|
22
|
+
_meta: { get: () => new MetaResponse(response) }, // legacy support
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.WebflowRecord = WebflowRecord;
|