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.
Files changed (71) hide show
  1. package/README.md +12 -1
  2. package/dist/api/collection.d.ts +85 -24
  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/{wrapper/membership.d.ts → api/user.d.ts} +59 -33
  15. package/dist/api/user.js +103 -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} +57 -52
  25. package/dist/{webflow.js → core/webflow.js} +102 -61
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.js +2 -2
  28. package/package.json +2 -4
  29. package/src/api/collection.ts +102 -35
  30. package/src/api/index.ts +7 -7
  31. package/src/api/item.ts +207 -176
  32. package/src/api/meta.ts +19 -18
  33. package/src/api/oauth.ts +62 -74
  34. package/src/api/site.ts +158 -55
  35. package/src/api/user.ts +152 -0
  36. package/src/api/webhook.ts +97 -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} +132 -137
  41. package/src/index.ts +1 -1
  42. package/yarn.lock +0 -5
  43. package/dist/api/membership.d.ts +0 -91
  44. package/dist/api/membership.js +0 -80
  45. package/dist/core/client.d.ts +0 -40
  46. package/dist/core/client.js +0 -49
  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.js +0 -106
  56. package/dist/wrapper/response.d.ts +0 -16
  57. package/dist/wrapper/response.js +0 -17
  58. package/dist/wrapper/site.d.ts +0 -119
  59. package/dist/wrapper/site.js +0 -136
  60. package/dist/wrapper/webhook.d.ts +0 -78
  61. package/dist/wrapper/webhook.js +0 -82
  62. package/src/api/membership.ts +0 -125
  63. package/src/core/client.ts +0 -76
  64. package/src/core/options.ts +0 -9
  65. package/src/wrapper/collection.ts +0 -115
  66. package/src/wrapper/index.ts +0 -6
  67. package/src/wrapper/item.ts +0 -218
  68. package/src/wrapper/membership.ts +0 -138
  69. package/src/wrapper/response.ts +0 -25
  70. package/src/wrapper/site.ts +0 -164
  71. package/src/wrapper/webhook.ts +0 -116
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.remove = exports.invite = exports.update = exports.getOne = exports.list = void 0;
4
- const core_1 = require("../core");
5
- /**************************************************************
6
- * Functions
7
- **************************************************************/
8
- /**
9
- * Get a list of Users
10
- * @param client The Webflow client
11
- * @param params The params for the request
12
- * @param params.siteId The site ID
13
- * @param params.limit The number of items to return (optional)
14
- * @param params.offset The number of items to skip (optional)
15
- * @returns A list of Users
16
- */
17
- function list(client, { siteId, limit, offset }) {
18
- (0, core_1.requireArgs)({ siteId });
19
- const params = { limit, offset };
20
- const path = `/sites/${siteId}/users`;
21
- return client.get(path, { params });
22
- }
23
- exports.list = list;
24
- /**
25
- * Get a single User
26
- * @param client The Webflow client
27
- * @param params The params for the request
28
- * @param params.siteId The site ID
29
- * @param params.userId The user ID
30
- * @returns A single User
31
- */
32
- function getOne(client, { siteId, userId }) {
33
- (0, core_1.requireArgs)({ siteId, userId });
34
- const path = `/sites/${siteId}/users/${userId}`;
35
- return client.get(path);
36
- }
37
- exports.getOne = getOne;
38
- /**
39
- * Update a User
40
- * @param client The Webflow client
41
- * @param params The params for the request
42
- * @param params.siteId The site ID
43
- * @param params.userId The user ID
44
- * @param params.data The data to update
45
- * @returns The updated User
46
- */
47
- function update(client, { siteId, userId, data, }) {
48
- (0, core_1.requireArgs)({ siteId, userId });
49
- const path = `/sites/${siteId}/users/${userId}`;
50
- return client.patch(path, data);
51
- }
52
- exports.update = update;
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
- async function invite(client, { siteId, email }) {
62
- (0, core_1.requireArgs)({ siteId, email });
63
- const path = `/sites/${siteId}/users/invite`;
64
- return client.post(path, { email });
65
- }
66
- exports.invite = invite;
67
- /**
68
- * Remove 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
- * @returns The result of the remove
74
- */
75
- function remove(client, { siteId, userId }) {
76
- (0, core_1.requireArgs)({ siteId, userId });
77
- const path = `/sites/${siteId}/users/${userId}`;
78
- return client.delete(path);
79
- }
80
- exports.remove = remove;
@@ -1,40 +0,0 @@
1
- import { Axios } from "axios";
2
- import { Options } from "../core";
3
- /**************************************************************
4
- * Types
5
- **************************************************************/
6
- export declare type QueryString = Record<string, any>;
7
- export declare type PaginationFilter = {
8
- limit?: number;
9
- offset?: number;
10
- };
11
- /**************************************************************
12
- * Interfaces
13
- ************************************************************* */
14
- export interface PaginatedData {
15
- count: number;
16
- limit: number;
17
- offset: number;
18
- total: number;
19
- }
20
- export interface WebflowOptions {
21
- host?: string;
22
- token?: string;
23
- version?: string;
24
- headers?: Record<string, string>;
25
- }
26
- /**************************************************************
27
- * Classes
28
- **************************************************************/
29
- export declare class Client extends Axios {
30
- constructor({ host, headers, version, token, }?: Options);
31
- /**
32
- * Transforms JSON response to an object
33
- * if the response is a Webflow error, it will throw an error
34
- * @param data JSON response
35
- * @returns response object
36
- */
37
- private transformResponse;
38
- set token(value: string);
39
- clearToken(): void;
40
- }
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Client = void 0;
4
- const axios_1 = require("axios");
5
- const core_1 = require("../core");
6
- /**************************************************************
7
- * Classes
8
- **************************************************************/
9
- class Client extends axios_1.Axios {
10
- constructor({ host = core_1.DEFAULT_HOST, headers = {}, version, token, } = {}) {
11
- super({
12
- transformRequest: [(data) => JSON.stringify(data)],
13
- baseURL: `https://api.${host}/`,
14
- headers: {
15
- "Content-Type": "application/json",
16
- "User-Agent": core_1.USER_AGENT,
17
- "Accept-Version": version,
18
- ...headers,
19
- },
20
- });
21
- if (token)
22
- this.token = token;
23
- // check for webflow errors
24
- this.defaults.transformResponse = [this.transformResponse];
25
- }
26
- /**
27
- * Transforms JSON response to an object
28
- * if the response is a Webflow error, it will throw an error
29
- * @param data JSON response
30
- * @returns response object
31
- */
32
- transformResponse(data = {}) {
33
- // parse json if string
34
- if (String(data) === data)
35
- data = JSON.parse(data);
36
- if (data.err)
37
- throw new core_1.RequestError(data);
38
- return data;
39
- }
40
- // set the Authorization header
41
- set token(value) {
42
- this.defaults.headers["Authorization"] = `Bearer ${value}`;
43
- }
44
- // clear the Authorization header
45
- clearToken() {
46
- delete this.defaults.headers["Authorization"];
47
- }
48
- }
49
- exports.Client = Client;
@@ -1,8 +0,0 @@
1
- export declare const DEFAULT_HOST = "webflow.com";
2
- export declare const USER_AGENT = "Webflow Javascript SDK / 1.0";
3
- export interface Options {
4
- host?: string;
5
- token?: string;
6
- version?: string;
7
- headers?: Record<string, string>;
8
- }
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.USER_AGENT = exports.DEFAULT_HOST = void 0;
4
- exports.DEFAULT_HOST = "webflow.com";
5
- exports.USER_AGENT = "Webflow Javascript SDK / 1.0";
@@ -1,85 +0,0 @@
1
- import { ItemWrapper } from ".";
2
- import { Client, QueryString } from "../core";
3
- import { Collection, Item } from "../api";
4
- export declare class CollectionWrapper implements Collection.ICollection {
5
- private client;
6
- fields: Collection.CollectionField[];
7
- singularName: string;
8
- lastUpdated: string;
9
- createdOn: string;
10
- _id: string;
11
- name: string;
12
- slug: string;
13
- constructor(client: Client, collection: Collection.ICollection);
14
- /**************************************************************
15
- * Static Methods
16
- **************************************************************/
17
- /**
18
- * Get a single Collection
19
- * @param client The Webflow client
20
- * @param params The Collection information
21
- * @param params.collectionId The Collection ID
22
- * @returns A single Collection
23
- */
24
- static getOne(client: Client, { collectionId }: {
25
- collectionId: string;
26
- }): Promise<import("./response").MetaResponse<CollectionWrapper>>;
27
- /**
28
- * Get a list of Collections
29
- * @param client The Webflow client
30
- * @param params1 The Site information
31
- * @param params1.siteId The Site ID
32
- * @param params The query parameters (optional)
33
- * @returns A list of Collections
34
- */
35
- static list(client: Client, { siteId }: {
36
- siteId: string;
37
- }, params?: QueryString): Promise<import("./response").MetaResponse<CollectionWrapper[]>>;
38
- /**************************************************************
39
- * Instance Methods
40
- **************************************************************/
41
- /**
42
- * Get a single Item
43
- * @param params The params for the request
44
- * @param params.itemId The Item ID
45
- * @returns A single Item
46
- */
47
- item({ itemId }: {
48
- itemId: string;
49
- }): Promise<import("./response").MetaResponse<ItemWrapper>>;
50
- /**
51
- * Get a list of Items
52
- * @param params The params for the request
53
- * @param params.limit The number of items to return (optional)
54
- * @param params.offset The number of items to skip (optional)
55
- * @returns A list of Items
56
- */
57
- items(params?: QueryString): Promise<import("./response").MetaResponse<ItemWrapper[]>>;
58
- /**
59
- * Remove a single Item
60
- * @param params The params for the request
61
- * @param params.itemId The Item ID
62
- * @returns The result from the removal
63
- */
64
- removeItem({ itemId }: {
65
- itemId: string;
66
- }): Promise<import("./response").MetaResponse<Item.IItemDelete>>;
67
- /**
68
- * Create a new Item
69
- * @param params The params for the request
70
- * @param params.fields The Item fields to create
71
- * @returns The created Item
72
- */
73
- createItem(fields: any): Promise<import("./response").MetaResponse<ItemWrapper>>;
74
- /**
75
- * Update a single Item
76
- * @param params The params for the request
77
- * @param params.itemId The Item ID
78
- * @param params.fields The fields to update
79
- * @returns The updated Item
80
- */
81
- updateItem({ itemId, fields }: {
82
- itemId: string;
83
- fields: any;
84
- }): Promise<import("./response").MetaResponse<ItemWrapper>>;
85
- }
@@ -1,94 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CollectionWrapper = void 0;
4
- const _1 = require(".");
5
- const api_1 = require("../api");
6
- class CollectionWrapper {
7
- constructor(client, collection) {
8
- this.client = client;
9
- Object.assign(this, collection);
10
- }
11
- /**************************************************************
12
- * Static Methods
13
- **************************************************************/
14
- /**
15
- * Get a single Collection
16
- * @param client The Webflow client
17
- * @param params The Collection information
18
- * @param params.collectionId The Collection ID
19
- * @returns A single Collection
20
- */
21
- static async getOne(client, { collectionId }) {
22
- const res = await api_1.Collection.getOne(client, { collectionId });
23
- const collection = new CollectionWrapper(client, res.data);
24
- return (0, _1.ResponseWrapper)(res, collection);
25
- }
26
- /**
27
- * Get a list of Collections
28
- * @param client The Webflow client
29
- * @param params1 The Site information
30
- * @param params1.siteId The Site ID
31
- * @param params The query parameters (optional)
32
- * @returns A list of Collections
33
- */
34
- static async list(client, { siteId }, params) {
35
- const res = await api_1.Collection.list(client, { siteId }, params);
36
- const collections = res.data.map((c) => new CollectionWrapper(client, c));
37
- return (0, _1.ResponseWrapper)(res, collections);
38
- }
39
- /**************************************************************
40
- * Instance Methods
41
- **************************************************************/
42
- /**
43
- * Get a single Item
44
- * @param params The params for the request
45
- * @param params.itemId The Item ID
46
- * @returns A single Item
47
- */
48
- async item({ itemId }) {
49
- return _1.ItemWrapper.getOne(this.client, { itemId, collectionId: this._id });
50
- }
51
- /**
52
- * Get a list of Items
53
- * @param params The params for the request
54
- * @param params.limit The number of items to return (optional)
55
- * @param params.offset The number of items to skip (optional)
56
- * @returns A list of Items
57
- */
58
- async items(params) {
59
- return _1.ItemWrapper.list(this.client, { collectionId: this._id, ...params });
60
- }
61
- /**
62
- * Remove a single Item
63
- * @param params The params for the request
64
- * @param params.itemId The Item ID
65
- * @returns The result from the removal
66
- */
67
- async removeItem({ itemId }) {
68
- return _1.ItemWrapper.remove(this.client, { itemId, collectionId: this._id });
69
- }
70
- /**
71
- * Create a new Item
72
- * @param params The params for the request
73
- * @param params.fields The Item fields to create
74
- * @returns The created Item
75
- */
76
- async createItem(fields) {
77
- return _1.ItemWrapper.create(this.client, { collectionId: this._id, fields });
78
- }
79
- /**
80
- * Update a single Item
81
- * @param params The params for the request
82
- * @param params.itemId The Item ID
83
- * @param params.fields The fields to update
84
- * @returns The updated Item
85
- */
86
- async updateItem({ itemId, fields }) {
87
- return _1.ItemWrapper.update(this.client, {
88
- collectionId: this._id,
89
- itemId,
90
- fields,
91
- });
92
- }
93
- }
94
- exports.CollectionWrapper = CollectionWrapper;
@@ -1,6 +0,0 @@
1
- export * from "./membership";
2
- export * from "./collection";
3
- export * from "./response";
4
- export * from "./webhook";
5
- export * from "./site";
6
- export * from "./item";
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./membership"), exports);
18
- __exportStar(require("./collection"), exports);
19
- __exportStar(require("./response"), exports);
20
- __exportStar(require("./webhook"), exports);
21
- __exportStar(require("./site"), exports);
22
- __exportStar(require("./item"), exports);
@@ -1,140 +0,0 @@
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
- }
@@ -1,153 +0,0 @@
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;