webflow-api 1.1.2 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +41 -17
  2. package/dist/api/collection.d.ts +86 -25
  3. package/dist/api/collection.js +88 -29
  4. package/dist/api/index.d.ts +7 -7
  5. package/dist/api/index.js +9 -19
  6. package/dist/api/item.d.ts +141 -107
  7. package/dist/api/item.js +145 -125
  8. package/dist/api/meta.d.ts +16 -14
  9. package/dist/api/meta.js +20 -19
  10. package/dist/api/oauth.d.ts +38 -36
  11. package/dist/api/oauth.js +59 -59
  12. package/dist/api/site.d.ts +118 -43
  13. package/dist/api/site.js +131 -53
  14. package/dist/api/user.d.ts +143 -0
  15. package/dist/api/user.js +119 -0
  16. package/dist/api/webhook.d.ts +77 -55
  17. package/dist/api/webhook.js +74 -61
  18. package/dist/core/error.d.ts +2 -0
  19. package/dist/core/error.js +8 -1
  20. package/dist/core/index.d.ts +2 -2
  21. package/dist/core/index.js +2 -2
  22. package/dist/core/response.d.ts +32 -0
  23. package/dist/core/response.js +26 -0
  24. package/dist/{webflow.d.ts → core/webflow.d.ts} +66 -54
  25. package/dist/{webflow.js → core/webflow.js} +114 -65
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.js +2 -2
  28. package/package.json +12 -8
  29. package/src/api/collection.ts +103 -36
  30. package/src/api/index.ts +7 -7
  31. package/src/api/item.ts +217 -176
  32. package/src/api/meta.ts +19 -18
  33. package/src/api/oauth.ts +71 -74
  34. package/src/api/site.ts +161 -55
  35. package/src/api/user.ts +192 -0
  36. package/src/api/webhook.ts +103 -80
  37. package/src/core/error.ts +8 -0
  38. package/src/core/index.ts +2 -2
  39. package/src/core/response.ts +50 -0
  40. package/src/{webflow.ts → core/webflow.ts} +153 -125
  41. package/src/index.ts +1 -1
  42. package/yarn.lock +4 -9
  43. package/dist/api/membership.d.ts +0 -114
  44. package/dist/api/membership.js +0 -96
  45. package/dist/core/client.d.ts +0 -27
  46. package/dist/core/client.js +0 -60
  47. package/dist/core/options.d.ts +0 -8
  48. package/dist/core/options.js +0 -5
  49. package/dist/wrapper/collection.d.ts +0 -85
  50. package/dist/wrapper/collection.js +0 -94
  51. package/dist/wrapper/index.d.ts +0 -6
  52. package/dist/wrapper/index.js +0 -22
  53. package/dist/wrapper/item.d.ts +0 -140
  54. package/dist/wrapper/item.js +0 -153
  55. package/dist/wrapper/membership.d.ts +0 -105
  56. package/dist/wrapper/membership.js +0 -123
  57. package/dist/wrapper/response.d.ts +0 -16
  58. package/dist/wrapper/response.js +0 -17
  59. package/dist/wrapper/site.d.ts +0 -168
  60. package/dist/wrapper/site.js +0 -191
  61. package/dist/wrapper/webhook.d.ts +0 -78
  62. package/dist/wrapper/webhook.js +0 -82
  63. package/src/api/membership.ts +0 -155
  64. package/src/core/client.ts +0 -82
  65. package/src/core/options.ts +0 -9
  66. package/src/wrapper/collection.ts +0 -115
  67. package/src/wrapper/index.ts +0 -6
  68. package/src/wrapper/item.ts +0 -218
  69. package/src/wrapper/membership.ts +0 -163
  70. package/src/wrapper/response.ts +0 -25
  71. package/src/wrapper/site.ts +0 -228
  72. package/src/wrapper/webhook.ts +0 -116
@@ -0,0 +1,143 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { PaginatedData, WebflowRecord } from "../core";
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
+ export interface IAcessGroup {
14
+ _id: string;
15
+ name: string;
16
+ shortId: string;
17
+ slug: string;
18
+ createdOn: string;
19
+ }
20
+ export interface IUserDelete {
21
+ deleted: number;
22
+ }
23
+ /**************************************************************
24
+ * Types
25
+ **************************************************************/
26
+ export declare type PaginatedUsers = PaginatedData & {
27
+ users: IUser[];
28
+ };
29
+ export declare type PaginatedAccessGroups = PaginatedData & {
30
+ accessGroups: IAcessGroup[];
31
+ };
32
+ export declare type UserIdParam = {
33
+ siteId: string;
34
+ userId: string;
35
+ };
36
+ /**************************************************************
37
+ * Class
38
+ **************************************************************/
39
+ export declare class User extends WebflowRecord<IUser> implements IUser {
40
+ emailVerified: boolean;
41
+ lastUpdated?: string;
42
+ createdOn: string;
43
+ siteId: string;
44
+ _id: string;
45
+ data: any;
46
+ /**************************************************************
47
+ * Static Methods
48
+ **************************************************************/
49
+ /**
50
+ * Get a list of Users
51
+ * @param params The params for the request
52
+ * @param params.siteId The site ID
53
+ * @param params.limit The number of items to return (optional)
54
+ * @param params.offset The number of items to skip (optional)
55
+ * @param client The Axios client instance
56
+ * @returns A list of Users
57
+ */
58
+ static list({ siteId, limit, offset }: {
59
+ siteId: string;
60
+ limit?: number;
61
+ offset?: number;
62
+ }, client: AxiosInstance): Promise<import("axios").AxiosResponse<PaginatedUsers, any>>;
63
+ /**
64
+ * Get a single User
65
+ * @param params The params for the request
66
+ * @param params.siteId The site ID
67
+ * @param params.userId The user ID
68
+ * @param client The Axios client instance
69
+ * @returns A single User
70
+ */
71
+ static getOne({ siteId, userId }: {
72
+ siteId: string;
73
+ userId: string;
74
+ }, client: AxiosInstance): Promise<import("axios").AxiosResponse<IUser, any>>;
75
+ /**
76
+ * Update a User
77
+ * @param params The params for the request
78
+ * @param params.siteId The site ID
79
+ * @param params.userId The user ID
80
+ * @param params.data The data to update
81
+ * @param client The Axios client instance
82
+ * @returns The updated User
83
+ */
84
+ static update({ siteId, userId, data, }: {
85
+ data: object;
86
+ siteId: string;
87
+ userId: string;
88
+ }, client: AxiosInstance): Promise<import("axios").AxiosResponse<IUser, any>>;
89
+ /**
90
+ * Invite a User to a site
91
+ * @param params The params for the request
92
+ * @param params.siteId The site ID
93
+ * @param params.email The email address of the user to invite
94
+ * @param client The Axios client instance
95
+ * @returns The newly created User
96
+ */
97
+ static invite({ siteId, email }: {
98
+ siteId: string;
99
+ email: string;
100
+ }, client: AxiosInstance): Promise<import("axios").AxiosResponse<IUser, any>>;
101
+ /**
102
+ * Remove a User
103
+ * @param params The params for the request
104
+ * @param params.siteId The site ID
105
+ * @param params.userId The user ID
106
+ * @param client The Axios client instance
107
+ * @returns The result of the remove
108
+ */
109
+ static remove({ siteId, userId }: {
110
+ siteId: string;
111
+ userId: string;
112
+ }, client: AxiosInstance): Promise<import("axios").AxiosResponse<IUserDelete, any>>;
113
+ /**
114
+ * Get a list of User Access Groups
115
+ * @param params The params for the request
116
+ * @param params.siteId The site ID
117
+ * @param params.limit The number of items to return (optional)
118
+ * @param params.offset The number of items to skip (optional)
119
+ * @param params.sort The sort order of the groups (optional)
120
+ * @param client The Axios client instance
121
+ * @returns A list of Access Groups
122
+ */
123
+ static accessGroups({ siteId, limit, offset, sort, }: {
124
+ siteId: string;
125
+ limit?: number;
126
+ offset?: number;
127
+ sort?: string;
128
+ }, client: AxiosInstance): Promise<import("axios").AxiosResponse<PaginatedAccessGroups, any>>;
129
+ /**************************************************************
130
+ * Instance Methods
131
+ **************************************************************/
132
+ /**
133
+ * Update a User
134
+ * @param data The data to update
135
+ * @returns The updated User
136
+ */
137
+ update(data: any): Promise<User>;
138
+ /**
139
+ * Remove a User
140
+ * @returns The result of the remove
141
+ */
142
+ remove(): Promise<IUserDelete>;
143
+ }
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.User = void 0;
4
+ const core_1 = require("../core");
5
+ /**************************************************************
6
+ * Class
7
+ **************************************************************/
8
+ class User extends core_1.WebflowRecord {
9
+ /**************************************************************
10
+ * Static Methods
11
+ **************************************************************/
12
+ /**
13
+ * Get a list of Users
14
+ * @param params The params for the request
15
+ * @param params.siteId The site ID
16
+ * @param params.limit The number of items to return (optional)
17
+ * @param params.offset The number of items to skip (optional)
18
+ * @param client The Axios client instance
19
+ * @returns A list of Users
20
+ */
21
+ static list({ siteId, limit, offset }, client) {
22
+ (0, core_1.requireArgs)({ siteId });
23
+ const params = { limit, offset };
24
+ const path = `/sites/${siteId}/users`;
25
+ return client.get(path, { params });
26
+ }
27
+ /**
28
+ * Get a single User
29
+ * @param params The params for the request
30
+ * @param params.siteId The site ID
31
+ * @param params.userId The user ID
32
+ * @param client The Axios client instance
33
+ * @returns A single User
34
+ */
35
+ static getOne({ siteId, userId }, client) {
36
+ (0, core_1.requireArgs)({ siteId, userId });
37
+ const path = `/sites/${siteId}/users/${userId}`;
38
+ return client.get(path);
39
+ }
40
+ /**
41
+ * Update a User
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
+ * @param client The Axios client instance
47
+ * @returns The updated User
48
+ */
49
+ static update({ siteId, userId, data, }, client) {
50
+ (0, core_1.requireArgs)({ siteId, userId });
51
+ const path = `/sites/${siteId}/users/${userId}`;
52
+ return client.patch(path, data);
53
+ }
54
+ /**
55
+ * Invite a User to a site
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
+ * @param client The Axios client instance
60
+ * @returns The newly created User
61
+ */
62
+ static async invite({ siteId, email }, client) {
63
+ (0, core_1.requireArgs)({ siteId, email });
64
+ const path = `/sites/${siteId}/users/invite`;
65
+ return client.post(path, { email });
66
+ }
67
+ /**
68
+ * Remove a User
69
+ * @param params The params for the request
70
+ * @param params.siteId The site ID
71
+ * @param params.userId The user ID
72
+ * @param client The Axios client instance
73
+ * @returns The result of the remove
74
+ */
75
+ static remove({ siteId, userId }, client) {
76
+ (0, core_1.requireArgs)({ siteId, userId });
77
+ const path = `/sites/${siteId}/users/${userId}`;
78
+ return client.delete(path);
79
+ }
80
+ /**
81
+ * Get a list of User Access Groups
82
+ * @param params The params for the request
83
+ * @param params.siteId The site ID
84
+ * @param params.limit The number of items to return (optional)
85
+ * @param params.offset The number of items to skip (optional)
86
+ * @param params.sort The sort order of the groups (optional)
87
+ * @param client The Axios client instance
88
+ * @returns A list of Access Groups
89
+ */
90
+ static accessGroups({ siteId, limit, offset, sort, }, client) {
91
+ (0, core_1.requireArgs)({ siteId });
92
+ const params = { limit, offset, sort };
93
+ const path = `/sites/${siteId}/accessgroups`;
94
+ return client.get(path, { params });
95
+ }
96
+ /**************************************************************
97
+ * Instance Methods
98
+ **************************************************************/
99
+ /**
100
+ * Update a User
101
+ * @param data The data to update
102
+ * @returns The updated User
103
+ */
104
+ async update(data) {
105
+ const params = { siteId: this.siteId, userId: this._id, data };
106
+ const res = await User.update(params, this.client);
107
+ return new User(this.client, res);
108
+ }
109
+ /**
110
+ * Remove a User
111
+ * @returns The result of the remove
112
+ */
113
+ async remove() {
114
+ const params = { siteId: this.siteId, userId: this._id };
115
+ const res = await User.remove(params, this.client);
116
+ return res.data;
117
+ }
118
+ }
119
+ exports.User = User;
@@ -1,9 +1,10 @@
1
- import { Client, QueryString } from "../core";
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 Filter = {
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
- * Functions
28
+ * Class
28
29
  **************************************************************/
29
- /**
30
- * Get a list of Webhooks
31
- * @param client The Webflow client
32
- * @param params1 The params for the request
33
- * @param params1.siteId The site ID
34
- * @param params The query string parameters (optional)
35
- * @returns A list of Webhooks
36
- */
37
- export declare function list(client: Client, { siteId }: {
38
- siteId: string;
39
- }, params?: QueryString): Promise<import("axios").AxiosResponse<IWebhook[], any>>;
40
- /**
41
- * Get a single Webhook
42
- * @param client The Webflow client
43
- * @param params The params for the request
44
- * @param params.siteId The site ID
45
- * @param params.webhookId The webhook ID
46
- * @returns A single Webhook
47
- */
48
- export declare function getOne(client: Client, { siteId, webhookId }: {
49
- siteId: string;
50
- webhookId: string;
51
- }): Promise<import("axios").AxiosResponse<IWebhook, any>>;
52
- /**
53
- * Create a new Webhook
54
- * @param client The Webflow client
55
- * @param params The params for the request
56
- * @param params.siteId The site ID
57
- * @param params.url The URL to send the webhook to
58
- * @param params.triggerType The event to trigger the webhook
59
- * @param params.filter The filter to apply to the webhook (optional: form_submission only)
60
- * @param params.params The query string parameters (optional)
61
- * @returns The created webhook
62
- */
63
- export declare function create(client: Client, { triggerType, siteId, filter, url, }: {
64
- url: string;
65
- siteId: string;
66
- filter?: Filter;
67
- triggerType: TriggerType;
68
- }): Promise<import("axios").AxiosResponse<IWebhook, any>>;
69
- /**
70
- * Remove a Webhook
71
- * @param client The Webflow client
72
- * @param params The query string parameters (optional)
73
- * @param params.webhookId The Webhook ID
74
- * @param params.siteId The Site ID
75
- * @returns The result of the removal
76
- */
77
- export declare function remove(client: Client, { siteId, webhookId }: {
78
- siteId: string;
79
- webhookId: string;
80
- }): Promise<import("axios").AxiosResponse<IRemoveResult, any>>;
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
+ }
@@ -1,67 +1,80 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.remove = exports.create = exports.getOne = exports.list = void 0;
3
+ exports.Webhook = void 0;
4
4
  const core_1 = require("../core");
5
5
  /**************************************************************
6
- * Functions
6
+ * Class
7
7
  **************************************************************/
8
- /**
9
- * Get a list of Webhooks
10
- * @param client The Webflow client
11
- * @param params1 The params for the request
12
- * @param params1.siteId The site ID
13
- * @param params The query string parameters (optional)
14
- * @returns A list of Webhooks
15
- */
16
- function list(client, { siteId }, params) {
17
- (0, core_1.requireArgs)({ siteId });
18
- const path = `/sites/${siteId}/webhooks`;
19
- return client.get(path, { params });
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.list = list;
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;
@@ -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<IRequestError>): AxiosResponse<IRequestError, any>;
@@ -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;
@@ -1,3 +1,3 @@
1
- export * from "./client";
2
1
  export * from "./error";
3
- export * from "./options";
2
+ export * from "./response";
3
+ export * from "./webflow";
@@ -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("./options"), exports);
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;