webflow-api 0.5.4 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ResponseWrapper.js +81 -45
- package/dist/Webflow.js +95 -141
- package/dist/WebflowError.js +34 -15
- package/dist/index.js +3 -3
- package/dist/utils.js +12 -7
- package/index.d.ts +354 -0
- package/package.json +15 -18
- package/src/Webflow.js +1 -1
- package/src/index.js +2 -2
- package/yarn.lock +3741 -3580
package/dist/Webflow.js
CHANGED
|
@@ -1,37 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
4
|
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _isomorphicFetch = _interopRequireDefault(require("isomorphic-fetch"));
|
|
6
11
|
|
|
7
|
-
var
|
|
12
|
+
var _qs = _interopRequireDefault(require("qs"));
|
|
8
13
|
|
|
9
|
-
var
|
|
14
|
+
var _utils = require("./utils");
|
|
10
15
|
|
|
11
|
-
var
|
|
16
|
+
var _ResponseWrapper = _interopRequireDefault(require("./ResponseWrapper"));
|
|
12
17
|
|
|
13
|
-
var
|
|
18
|
+
var _WebflowError = _interopRequireWildcard(require("./WebflowError"));
|
|
14
19
|
|
|
15
|
-
var
|
|
20
|
+
var _excluded = ["collectionId"],
|
|
21
|
+
_excluded2 = ["collectionId", "itemId"],
|
|
22
|
+
_excluded3 = ["collectionId", "itemId"],
|
|
23
|
+
_excluded4 = ["siteId"];
|
|
16
24
|
|
|
17
|
-
var
|
|
25
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
26
|
|
|
19
|
-
var
|
|
27
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
28
|
|
|
21
|
-
|
|
29
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
22
30
|
|
|
23
|
-
var
|
|
31
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
24
32
|
|
|
25
|
-
var
|
|
33
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
26
34
|
|
|
27
|
-
var
|
|
35
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
28
36
|
|
|
29
|
-
function
|
|
37
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
30
38
|
|
|
31
|
-
function
|
|
39
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
32
40
|
|
|
33
41
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
34
42
|
|
|
43
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
44
|
+
|
|
45
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
46
|
+
|
|
35
47
|
var DEFAULT_ENDPOINT = 'https://api.webflow.com';
|
|
36
48
|
|
|
37
49
|
var buildMeta = function buildMeta(res) {
|
|
@@ -48,11 +60,10 @@ var buildMeta = function buildMeta(res) {
|
|
|
48
60
|
};
|
|
49
61
|
|
|
50
62
|
var responseHandler = function responseHandler(res) {
|
|
51
|
-
return res.json()
|
|
52
|
-
return (
|
|
53
|
-
// Catch unexpected server errors where json isn't sent and rewrite
|
|
63
|
+
return res.json()["catch"](function (err) {
|
|
64
|
+
return (// Catch unexpected server errors where json isn't sent and rewrite
|
|
54
65
|
// with proper class (WebflowError)
|
|
55
|
-
Promise.reject(new
|
|
66
|
+
Promise.reject(new _WebflowError["default"](err))
|
|
56
67
|
);
|
|
57
68
|
}).then(function (body) {
|
|
58
69
|
if (res.status >= 400) {
|
|
@@ -67,8 +78,7 @@ var responseHandler = function responseHandler(res) {
|
|
|
67
78
|
}
|
|
68
79
|
|
|
69
80
|
var errMsg = body && body.err ? body.err : 'Unknown error occured';
|
|
70
|
-
var err = new
|
|
71
|
-
|
|
81
|
+
var err = new _WebflowError["default"](errMsg);
|
|
72
82
|
return Promise.reject(Object.assign(err, errOpts));
|
|
73
83
|
}
|
|
74
84
|
|
|
@@ -78,37 +88,33 @@ var responseHandler = function responseHandler(res) {
|
|
|
78
88
|
});
|
|
79
89
|
};
|
|
80
90
|
|
|
81
|
-
var Webflow = function () {
|
|
91
|
+
var Webflow = /*#__PURE__*/function () {
|
|
82
92
|
function Webflow() {
|
|
83
93
|
var _this = this;
|
|
84
94
|
|
|
85
95
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
86
96
|
_ref$endpoint = _ref.endpoint,
|
|
87
|
-
endpoint = _ref$endpoint ===
|
|
97
|
+
endpoint = _ref$endpoint === void 0 ? DEFAULT_ENDPOINT : _ref$endpoint,
|
|
88
98
|
token = _ref.token,
|
|
89
99
|
_ref$version = _ref.version,
|
|
90
|
-
version = _ref$version ===
|
|
100
|
+
version = _ref$version === void 0 ? '1.0.0' : _ref$version;
|
|
91
101
|
|
|
92
102
|
_classCallCheck(this, Webflow);
|
|
93
103
|
|
|
94
104
|
if (!token) throw (0, _WebflowError.buildRequiredArgError)('token');
|
|
95
|
-
|
|
96
|
-
this.responseWrapper = new _ResponseWrapper2.default(this);
|
|
97
|
-
|
|
105
|
+
this.responseWrapper = new _ResponseWrapper["default"](this);
|
|
98
106
|
this.endpoint = endpoint;
|
|
99
107
|
this.token = token;
|
|
100
|
-
|
|
101
108
|
this.headers = {
|
|
102
109
|
Accept: 'application/json',
|
|
103
|
-
Authorization:
|
|
110
|
+
Authorization: "Bearer ".concat(token),
|
|
104
111
|
'accept-version': version,
|
|
105
112
|
'Content-Type': 'application/json'
|
|
106
113
|
};
|
|
107
114
|
|
|
108
115
|
this.authenticatedFetch = function (method, path, data, query) {
|
|
109
|
-
var queryString = query && !(0, _utils.isObjectEmpty)(query) ?
|
|
110
|
-
|
|
111
|
-
var uri = '' + _this.endpoint + path + queryString;
|
|
116
|
+
var queryString = query && !(0, _utils.isObjectEmpty)(query) ? "?".concat(_qs["default"].stringify(query)) : '';
|
|
117
|
+
var uri = "".concat(_this.endpoint).concat(path).concat(queryString);
|
|
112
118
|
var opts = {
|
|
113
119
|
method: method,
|
|
114
120
|
headers: _this.headers,
|
|
@@ -119,67 +125,55 @@ var Webflow = function () {
|
|
|
119
125
|
opts.body = JSON.stringify(data);
|
|
120
126
|
}
|
|
121
127
|
|
|
122
|
-
return (0,
|
|
128
|
+
return (0, _isomorphicFetch["default"])(uri, opts).then(responseHandler);
|
|
123
129
|
};
|
|
124
|
-
}
|
|
130
|
+
} // Generic HTTP request handlers
|
|
125
131
|
|
|
126
|
-
// Generic HTTP request handlers
|
|
127
132
|
|
|
128
133
|
_createClass(Webflow, [{
|
|
129
|
-
key:
|
|
134
|
+
key: "get",
|
|
130
135
|
value: function get(path) {
|
|
131
136
|
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
132
|
-
|
|
133
137
|
return this.authenticatedFetch('GET', path, false, query);
|
|
134
138
|
}
|
|
135
139
|
}, {
|
|
136
|
-
key:
|
|
140
|
+
key: "post",
|
|
137
141
|
value: function post(path, data) {
|
|
138
142
|
var query = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
139
|
-
|
|
140
143
|
return this.authenticatedFetch('POST', path, data, query);
|
|
141
144
|
}
|
|
142
145
|
}, {
|
|
143
|
-
key:
|
|
146
|
+
key: "put",
|
|
144
147
|
value: function put(path, data) {
|
|
145
148
|
var query = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
146
|
-
|
|
147
149
|
return this.authenticatedFetch('PUT', path, data, query);
|
|
148
150
|
}
|
|
149
151
|
}, {
|
|
150
|
-
key:
|
|
152
|
+
key: "patch",
|
|
151
153
|
value: function patch(path, data) {
|
|
152
154
|
var query = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
153
|
-
|
|
154
155
|
return this.authenticatedFetch('PATCH', path, data, query);
|
|
155
156
|
}
|
|
156
157
|
}, {
|
|
157
|
-
key:
|
|
158
|
+
key: "delete",
|
|
158
159
|
value: function _delete(path) {
|
|
159
160
|
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
160
|
-
|
|
161
161
|
return this.authenticatedFetch('DELETE', path, query);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// Meta
|
|
162
|
+
} // Meta
|
|
165
163
|
|
|
166
164
|
}, {
|
|
167
|
-
key:
|
|
165
|
+
key: "info",
|
|
168
166
|
value: function info() {
|
|
169
167
|
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
170
|
-
|
|
171
168
|
return this.get('/info', query);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Sites
|
|
169
|
+
} // Sites
|
|
175
170
|
|
|
176
171
|
}, {
|
|
177
|
-
key:
|
|
172
|
+
key: "sites",
|
|
178
173
|
value: function sites() {
|
|
179
174
|
var _this2 = this;
|
|
180
175
|
|
|
181
176
|
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
182
|
-
|
|
183
177
|
return this.get('/sites', query).then(function (sites) {
|
|
184
178
|
return sites.map(function (site) {
|
|
185
179
|
return _this2.responseWrapper.site(site);
|
|
@@ -187,97 +181,80 @@ var Webflow = function () {
|
|
|
187
181
|
});
|
|
188
182
|
}
|
|
189
183
|
}, {
|
|
190
|
-
key:
|
|
184
|
+
key: "site",
|
|
191
185
|
value: function site(_ref2) {
|
|
192
186
|
var _this3 = this;
|
|
193
187
|
|
|
194
188
|
var siteId = _ref2.siteId;
|
|
195
189
|
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
196
|
-
|
|
197
190
|
if (!siteId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('siteId'));
|
|
198
|
-
|
|
199
|
-
return this.get('/sites/' + siteId, query).then(function (site) {
|
|
191
|
+
return this.get("/sites/".concat(siteId), query).then(function (site) {
|
|
200
192
|
return _this3.responseWrapper.site(site);
|
|
201
193
|
});
|
|
202
194
|
}
|
|
203
195
|
}, {
|
|
204
|
-
key:
|
|
196
|
+
key: "publishSite",
|
|
205
197
|
value: function publishSite(_ref3) {
|
|
206
198
|
var siteId = _ref3.siteId,
|
|
207
199
|
domains = _ref3.domains;
|
|
208
|
-
|
|
209
200
|
if (!siteId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('siteId'));
|
|
210
201
|
if (!domains) return Promise.reject((0, _WebflowError.buildRequiredArgError)('domains'));
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
// Domains
|
|
202
|
+
return this.post("/sites/".concat(siteId, "/publish"), {
|
|
203
|
+
domains: domains
|
|
204
|
+
});
|
|
205
|
+
} // Domains
|
|
216
206
|
|
|
217
207
|
}, {
|
|
218
|
-
key:
|
|
208
|
+
key: "domains",
|
|
219
209
|
value: function domains(_ref4) {
|
|
220
210
|
var _this4 = this;
|
|
221
211
|
|
|
222
212
|
var siteId = _ref4.siteId;
|
|
223
|
-
|
|
224
213
|
if (!siteId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('siteId'));
|
|
225
|
-
|
|
226
|
-
return this.get('/sites/' + siteId + '/domains').then(function (domains) {
|
|
214
|
+
return this.get("/sites/".concat(siteId, "/domains")).then(function (domains) {
|
|
227
215
|
return domains.map(function (domain) {
|
|
228
216
|
return _this4.responseWrapper.domain(domain, siteId);
|
|
229
217
|
});
|
|
230
218
|
});
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// Collections
|
|
219
|
+
} // Collections
|
|
234
220
|
|
|
235
221
|
}, {
|
|
236
|
-
key:
|
|
222
|
+
key: "collections",
|
|
237
223
|
value: function collections(_ref5) {
|
|
238
224
|
var _this5 = this;
|
|
239
225
|
|
|
240
226
|
var siteId = _ref5.siteId;
|
|
241
227
|
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
242
|
-
|
|
243
228
|
if (!siteId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('siteId'));
|
|
244
|
-
|
|
245
|
-
return this.get('/sites/' + siteId + '/collections', query).then(function (collections) {
|
|
229
|
+
return this.get("/sites/".concat(siteId, "/collections"), query).then(function (collections) {
|
|
246
230
|
return collections.map(function (collection) {
|
|
247
231
|
return _this5.responseWrapper.collection(collection);
|
|
248
232
|
});
|
|
249
233
|
});
|
|
250
234
|
}
|
|
251
235
|
}, {
|
|
252
|
-
key:
|
|
236
|
+
key: "collection",
|
|
253
237
|
value: function collection(_ref6) {
|
|
254
238
|
var _this6 = this;
|
|
255
239
|
|
|
256
240
|
var collectionId = _ref6.collectionId;
|
|
257
241
|
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
258
|
-
|
|
259
242
|
if (!collectionId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('collectionId'));
|
|
260
|
-
|
|
261
|
-
return this.get('/collections/' + collectionId, query).then(function (collection) {
|
|
243
|
+
return this.get("/collections/".concat(collectionId), query).then(function (collection) {
|
|
262
244
|
return _this6.responseWrapper.collection(collection);
|
|
263
245
|
});
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// Items
|
|
246
|
+
} // Items
|
|
267
247
|
|
|
268
248
|
}, {
|
|
269
|
-
key:
|
|
249
|
+
key: "items",
|
|
270
250
|
value: function items(_ref7) {
|
|
271
251
|
var _this7 = this;
|
|
272
252
|
|
|
273
253
|
var collectionId = _ref7.collectionId;
|
|
274
254
|
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
275
|
-
|
|
276
255
|
if (!collectionId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('collectionId'));
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
return _extends({}, res, {
|
|
280
|
-
|
|
256
|
+
return this.get("/collections/".concat(collectionId, "/items"), query).then(function (res) {
|
|
257
|
+
return _objectSpread(_objectSpread({}, res), {}, {
|
|
281
258
|
items: res.items.map(function (item) {
|
|
282
259
|
return _this7.responseWrapper.item(item, collectionId);
|
|
283
260
|
})
|
|
@@ -285,148 +262,125 @@ var Webflow = function () {
|
|
|
285
262
|
});
|
|
286
263
|
}
|
|
287
264
|
}, {
|
|
288
|
-
key:
|
|
265
|
+
key: "item",
|
|
289
266
|
value: function item(_ref8) {
|
|
290
267
|
var _this8 = this;
|
|
291
268
|
|
|
292
269
|
var collectionId = _ref8.collectionId,
|
|
293
270
|
itemId = _ref8.itemId;
|
|
294
271
|
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
295
|
-
|
|
296
272
|
if (!collectionId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('collectionId'));
|
|
297
|
-
if (!itemId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('
|
|
298
|
-
|
|
299
|
-
return this.get('/collections/' + collectionId + '/items/' + itemId, query).then(function (res) {
|
|
273
|
+
if (!itemId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('itemId'));
|
|
274
|
+
return this.get("/collections/".concat(collectionId, "/items/").concat(itemId), query).then(function (res) {
|
|
300
275
|
return _this8.responseWrapper.item(res.items[0], collectionId);
|
|
301
276
|
});
|
|
302
277
|
}
|
|
303
278
|
}, {
|
|
304
|
-
key:
|
|
279
|
+
key: "createItem",
|
|
305
280
|
value: function createItem(_ref9) {
|
|
306
281
|
var _this9 = this;
|
|
307
282
|
|
|
308
|
-
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
309
|
-
|
|
310
283
|
var collectionId = _ref9.collectionId,
|
|
311
|
-
data = _objectWithoutProperties(_ref9,
|
|
284
|
+
data = _objectWithoutProperties(_ref9, _excluded);
|
|
312
285
|
|
|
286
|
+
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
313
287
|
if (!collectionId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('collectionId'));
|
|
314
|
-
|
|
315
|
-
return this.post('/collections/' + collectionId + '/items', data, query).then(function (item) {
|
|
288
|
+
return this.post("/collections/".concat(collectionId, "/items"), data, query).then(function (item) {
|
|
316
289
|
return _this9.responseWrapper.item(item, collectionId);
|
|
317
290
|
});
|
|
318
291
|
}
|
|
319
292
|
}, {
|
|
320
|
-
key:
|
|
293
|
+
key: "updateItem",
|
|
321
294
|
value: function updateItem(_ref10) {
|
|
322
|
-
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
323
|
-
|
|
324
295
|
var collectionId = _ref10.collectionId,
|
|
325
296
|
itemId = _ref10.itemId,
|
|
326
|
-
data = _objectWithoutProperties(_ref10,
|
|
297
|
+
data = _objectWithoutProperties(_ref10, _excluded2);
|
|
327
298
|
|
|
299
|
+
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
328
300
|
if (!collectionId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('collectionId'));
|
|
329
301
|
if (!itemId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('itemId'));
|
|
330
|
-
|
|
331
|
-
return this.put('/collections/' + collectionId + '/items/' + itemId, data, query);
|
|
302
|
+
return this.put("/collections/".concat(collectionId, "/items/").concat(itemId), data, query);
|
|
332
303
|
}
|
|
333
304
|
}, {
|
|
334
|
-
key:
|
|
305
|
+
key: "removeItem",
|
|
335
306
|
value: function removeItem(_ref11) {
|
|
336
307
|
var collectionId = _ref11.collectionId,
|
|
337
308
|
itemId = _ref11.itemId;
|
|
338
309
|
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
339
|
-
|
|
340
310
|
if (!collectionId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('collectionId'));
|
|
341
311
|
if (!itemId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('itemId'));
|
|
342
|
-
|
|
343
|
-
return this.delete('/collections/' + collectionId + '/items/' + itemId, query);
|
|
312
|
+
return this["delete"]("/collections/".concat(collectionId, "/items/").concat(itemId), query);
|
|
344
313
|
}
|
|
345
314
|
}, {
|
|
346
|
-
key:
|
|
315
|
+
key: "patchItem",
|
|
347
316
|
value: function patchItem(_ref12) {
|
|
348
|
-
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
349
|
-
|
|
350
317
|
var collectionId = _ref12.collectionId,
|
|
351
318
|
itemId = _ref12.itemId,
|
|
352
|
-
data = _objectWithoutProperties(_ref12,
|
|
319
|
+
data = _objectWithoutProperties(_ref12, _excluded3);
|
|
353
320
|
|
|
321
|
+
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
354
322
|
if (!collectionId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('collectionId'));
|
|
355
323
|
if (!itemId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('itemId'));
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
// Images
|
|
361
|
-
|
|
324
|
+
return this.patch("/collections/".concat(collectionId, "/items/").concat(itemId), data, query);
|
|
325
|
+
} // Images
|
|
362
326
|
// TODO
|
|
363
|
-
|
|
364
327
|
// Webhooks
|
|
365
328
|
|
|
366
329
|
}, {
|
|
367
|
-
key:
|
|
330
|
+
key: "webhooks",
|
|
368
331
|
value: function webhooks(_ref13) {
|
|
369
332
|
var _this10 = this;
|
|
370
333
|
|
|
371
334
|
var siteId = _ref13.siteId;
|
|
372
335
|
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
373
|
-
|
|
374
336
|
if (!siteId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('siteId'));
|
|
375
|
-
|
|
376
|
-
return this.get('/sites/' + siteId + '/webhooks', query).then(function (webhooks) {
|
|
337
|
+
return this.get("/sites/".concat(siteId, "/webhooks"), query).then(function (webhooks) {
|
|
377
338
|
return webhooks.map(function (webhook) {
|
|
378
339
|
return _this10.responseWrapper.webhook(webhook, siteId);
|
|
379
340
|
});
|
|
380
341
|
});
|
|
381
342
|
}
|
|
382
343
|
}, {
|
|
383
|
-
key:
|
|
344
|
+
key: "webhook",
|
|
384
345
|
value: function webhook(_ref14) {
|
|
385
346
|
var _this11 = this;
|
|
386
347
|
|
|
387
348
|
var siteId = _ref14.siteId,
|
|
388
349
|
webhookId = _ref14.webhookId;
|
|
389
350
|
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
390
|
-
|
|
391
351
|
if (!siteId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('siteId'));
|
|
392
352
|
if (!webhookId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('webhookId'));
|
|
393
|
-
|
|
394
|
-
return this.get('/sites/' + siteId + '/webhooks/' + webhookId, query).then(function (webhook) {
|
|
353
|
+
return this.get("/sites/".concat(siteId, "/webhooks/").concat(webhookId), query).then(function (webhook) {
|
|
395
354
|
return _this11.responseWrapper.webhook(webhook, siteId);
|
|
396
355
|
});
|
|
397
356
|
}
|
|
398
357
|
}, {
|
|
399
|
-
key:
|
|
358
|
+
key: "createWebhook",
|
|
400
359
|
value: function createWebhook(_ref15) {
|
|
401
360
|
var _this12 = this;
|
|
402
361
|
|
|
403
|
-
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
404
|
-
|
|
405
362
|
var siteId = _ref15.siteId,
|
|
406
|
-
data = _objectWithoutProperties(_ref15,
|
|
363
|
+
data = _objectWithoutProperties(_ref15, _excluded4);
|
|
407
364
|
|
|
365
|
+
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
408
366
|
if (!siteId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('siteId'));
|
|
409
|
-
|
|
410
|
-
return this.post('/sites/' + siteId + '/webhooks', data, query).then(function (webhook) {
|
|
367
|
+
return this.post("/sites/".concat(siteId, "/webhooks"), data, query).then(function (webhook) {
|
|
411
368
|
return _this12.responseWrapper.webhook(webhook, siteId);
|
|
412
369
|
});
|
|
413
370
|
}
|
|
414
371
|
}, {
|
|
415
|
-
key:
|
|
372
|
+
key: "removeWebhook",
|
|
416
373
|
value: function removeWebhook(_ref16) {
|
|
417
374
|
var siteId = _ref16.siteId,
|
|
418
375
|
webhookId = _ref16.webhookId;
|
|
419
376
|
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
420
|
-
|
|
421
377
|
if (!siteId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('siteId'));
|
|
422
378
|
if (!webhookId) return Promise.reject((0, _WebflowError.buildRequiredArgError)('webhookId'));
|
|
423
|
-
|
|
424
|
-
return this.delete('/sites/' + siteId + '/webhooks/' + webhookId, query);
|
|
379
|
+
return this["delete"]("/sites/".concat(siteId, "/webhooks/").concat(webhookId), query);
|
|
425
380
|
}
|
|
426
381
|
}]);
|
|
427
382
|
|
|
428
383
|
return Webflow;
|
|
429
384
|
}();
|
|
430
385
|
|
|
431
|
-
exports
|
|
432
|
-
module.exports = exports['default'];
|
|
386
|
+
exports["default"] = Webflow;
|
package/dist/WebflowError.js
CHANGED
|
@@ -1,35 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
4
|
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
exports.buildRequiredArgError =
|
|
8
|
+
exports["default"] = exports.buildRequiredArgError = void 0;
|
|
9
|
+
|
|
10
|
+
var _es6Error = _interopRequireDefault(require("es6-error"));
|
|
7
11
|
|
|
8
|
-
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
9
13
|
|
|
10
|
-
var
|
|
14
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
11
15
|
|
|
12
|
-
function
|
|
16
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
17
|
|
|
14
18
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
19
|
|
|
16
|
-
function
|
|
20
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
21
|
+
|
|
22
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
23
|
+
|
|
24
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
25
|
+
|
|
26
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
17
27
|
|
|
18
|
-
function
|
|
28
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
19
29
|
|
|
20
|
-
|
|
30
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
31
|
+
|
|
32
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
33
|
+
|
|
34
|
+
var WebflowError = /*#__PURE__*/function (_ExtendableError) {
|
|
21
35
|
_inherits(WebflowError, _ExtendableError);
|
|
22
36
|
|
|
37
|
+
var _super = _createSuper(WebflowError);
|
|
38
|
+
|
|
23
39
|
function WebflowError() {
|
|
24
40
|
_classCallCheck(this, WebflowError);
|
|
25
41
|
|
|
26
|
-
return
|
|
42
|
+
return _super.apply(this, arguments);
|
|
27
43
|
}
|
|
28
44
|
|
|
29
|
-
return WebflowError;
|
|
30
|
-
}(
|
|
45
|
+
return _createClass(WebflowError);
|
|
46
|
+
}(_es6Error["default"]);
|
|
47
|
+
|
|
48
|
+
exports["default"] = WebflowError;
|
|
49
|
+
|
|
50
|
+
var buildRequiredArgError = function buildRequiredArgError(name) {
|
|
51
|
+
return new WebflowError("Argument '".concat(name, "' is required but was not present"));
|
|
52
|
+
};
|
|
31
53
|
|
|
32
|
-
exports.
|
|
33
|
-
var buildRequiredArgError = exports.buildRequiredArgError = function buildRequiredArgError(name) {
|
|
34
|
-
return new WebflowError('Argument \'' + name + '\' is required but was not present');
|
|
35
|
-
};
|
|
54
|
+
exports.buildRequiredArgError = buildRequiredArgError;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
module.exports = require(
|
|
4
|
-
module.exports.WebflowError = require(
|
|
3
|
+
module.exports = require("./Webflow")["default"];
|
|
4
|
+
module.exports.WebflowError = require("./WebflowError")["default"];
|
package/dist/utils.js
CHANGED
|
@@ -3,22 +3,27 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
6
|
+
exports.pick = exports.isObjectEmpty = void 0;
|
|
7
|
+
|
|
8
|
+
var isObjectEmpty = function isObjectEmpty(obj) {
|
|
7
9
|
return Object.keys(obj).length === 0;
|
|
8
10
|
};
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
for (var _len = arguments.length, props = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
12
|
-
props[_key - 1] = arguments[_key];
|
|
13
|
-
}
|
|
12
|
+
exports.isObjectEmpty = isObjectEmpty;
|
|
14
13
|
|
|
14
|
+
var pick = function pick(obj) {
|
|
15
15
|
var picked = {};
|
|
16
16
|
|
|
17
|
+
for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
18
|
+
props[_key - 1] = arguments[_key];
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
props.forEach(function (prop) {
|
|
18
22
|
if (obj[prop] !== undefined) {
|
|
19
23
|
picked[prop] = obj[prop];
|
|
20
24
|
}
|
|
21
25
|
});
|
|
22
|
-
|
|
23
26
|
return picked;
|
|
24
|
-
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.pick = pick;
|