@contentstack/marketplace-sdk 1.0.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 (56) hide show
  1. package/CODEOWNERS +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +115 -0
  4. package/SECURITY.md +27 -0
  5. package/dist/es-modules/contentstack.js +184 -0
  6. package/dist/es-modules/contentstackClient.js +116 -0
  7. package/dist/es-modules/contentstackCollection.js +30 -0
  8. package/dist/es-modules/core/Util.js +89 -0
  9. package/dist/es-modules/core/concurrency-queue.js +297 -0
  10. package/dist/es-modules/core/contentstackError.js +36 -0
  11. package/dist/es-modules/core/contentstackHTTPClient.js +87 -0
  12. package/dist/es-modules/entity.js +433 -0
  13. package/dist/es-modules/marketplace/app/hosting/deployment.js +307 -0
  14. package/dist/es-modules/marketplace/app/hosting/index.js +284 -0
  15. package/dist/es-modules/marketplace/app/index.js +456 -0
  16. package/dist/es-modules/marketplace/app/oauth/index.js +190 -0
  17. package/dist/es-modules/marketplace/apprequest/index.js +188 -0
  18. package/dist/es-modules/marketplace/authorization/index.js +175 -0
  19. package/dist/es-modules/marketplace/index.js +177 -0
  20. package/dist/es-modules/marketplace/installation/index.js +581 -0
  21. package/dist/es-modules/marketplace/installation/webhooks/index.js +185 -0
  22. package/dist/es5/contentstack.js +196 -0
  23. package/dist/es5/contentstackClient.js +126 -0
  24. package/dist/es5/contentstackCollection.js +41 -0
  25. package/dist/es5/core/Util.js +98 -0
  26. package/dist/es5/core/concurrency-queue.js +307 -0
  27. package/dist/es5/core/contentstackError.js +43 -0
  28. package/dist/es5/core/contentstackHTTPClient.js +101 -0
  29. package/dist/es5/entity.js +449 -0
  30. package/dist/es5/marketplace/app/hosting/deployment.js +321 -0
  31. package/dist/es5/marketplace/app/hosting/index.js +296 -0
  32. package/dist/es5/marketplace/app/index.js +469 -0
  33. package/dist/es5/marketplace/app/oauth/index.js +202 -0
  34. package/dist/es5/marketplace/apprequest/index.js +200 -0
  35. package/dist/es5/marketplace/authorization/index.js +187 -0
  36. package/dist/es5/marketplace/index.js +190 -0
  37. package/dist/es5/marketplace/installation/index.js +594 -0
  38. package/dist/es5/marketplace/installation/webhooks/index.js +197 -0
  39. package/dist/nativescript/contentstack-marketplace.js +2 -0
  40. package/dist/node/contentstack-marketplace.js +2 -0
  41. package/dist/react-native/contentstack-marketplace.js +2 -0
  42. package/dist/web/contentstack-marketplace.js +2 -0
  43. package/jest.config.js +11 -0
  44. package/package.json +95 -0
  45. package/types/contentstackClient.d.ts +56 -0
  46. package/types/contentstackCollection.d.ts +18 -0
  47. package/types/marketplace/app/hosting.d.ts +39 -0
  48. package/types/marketplace/app/index.d.ts +89 -0
  49. package/types/marketplace/app/oath.d.ts +8 -0
  50. package/types/marketplace/apprequest.d.ts +7 -0
  51. package/types/marketplace/authorization.d.ts +7 -0
  52. package/types/marketplace/index.d.ts +17 -0
  53. package/types/marketplace/installation.d.ts +22 -0
  54. package/types/marketplace/webhooks.d.ts +7 -0
  55. package/types/utility/fields.d.ts +9 -0
  56. package/types/utility/operations.d.ts +11 -0
@@ -0,0 +1,307 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ import cloneDeep from 'lodash/cloneDeep';
7
+ import ContentstackCollection from '../../../contentstackCollection';
8
+ import error from '../../../core/contentstackError';
9
+
10
+ /**
11
+ *
12
+ * @namespace Deployment
13
+ */
14
+ export function Deployment(http, data, params) {
15
+ var _this = this;
16
+ http.defaults.versioningStrategy = undefined;
17
+ if (data && data.app_uid) {
18
+ this.params = params || {};
19
+ this.urlPath = "/manifests/".concat(data.app_uid, "/hosting/deployments");
20
+ if (data.organization_uid) {
21
+ this.params = {
22
+ organization_uid: data.organization_uid
23
+ };
24
+ }
25
+ if (data.data) {
26
+ Object.assign(this, cloneDeep(data.data));
27
+ if (this.organization_uid) {
28
+ this.params = {
29
+ organization_uid: this.organization_uid
30
+ };
31
+ }
32
+ }
33
+ if (this.uid) {
34
+ this.urlPath = "/manifests/".concat(data.app_uid, "/hosting/deployments/").concat(this.uid);
35
+ /**
36
+ * @descriptionThe The GET deployment call is used to get all the details of an deployment of an app
37
+ * @memberof Deployment
38
+ * @func fetch
39
+ * @returns {Promise<Deployment>}
40
+ *
41
+ * @example
42
+ * import * as contentstack from '@contentstack/marketplace'
43
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
44
+ * client.marketplace('organization_uid').app('manifest_uid').hosting().deployment('deployment_uid').fetch()
45
+ * .then((data) => {})
46
+ */
47
+ this.fetch = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
48
+ var headers, response, content;
49
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
50
+ while (1) switch (_context.prev = _context.next) {
51
+ case 0:
52
+ _context.prev = 0;
53
+ headers = {
54
+ headers: _objectSpread({}, cloneDeep(_this.params))
55
+ };
56
+ _context.next = 4;
57
+ return http.get("".concat(_this.urlPath), headers);
58
+ case 4:
59
+ response = _context.sent;
60
+ if (!response.data) {
61
+ _context.next = 10;
62
+ break;
63
+ }
64
+ content = response.data.data;
65
+ return _context.abrupt("return", new Deployment(http, {
66
+ data: content,
67
+ app_uid: data.app_uid
68
+ }, _this.params));
69
+ case 10:
70
+ throw error(response);
71
+ case 11:
72
+ _context.next = 16;
73
+ break;
74
+ case 13:
75
+ _context.prev = 13;
76
+ _context.t0 = _context["catch"](0);
77
+ throw error(_context.t0);
78
+ case 16:
79
+ case "end":
80
+ return _context.stop();
81
+ }
82
+ }, _callee, null, [[0, 13]]);
83
+ }));
84
+
85
+ /**
86
+ * @descriptionThe The list deployment logs call is used to list logs of a deployment.
87
+ * @memberof Deployment
88
+ * @func logs
89
+ * @returns {Promise<Response>}
90
+ *
91
+ * @example
92
+ * import * as contentstack from '@contentstack/marketplace'
93
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
94
+ * client.marketplace('organization_uid').app('manifest_uid').hosting().deployment('deployment_uid').logs()
95
+ * .then((data) => {})
96
+ */
97
+ this.logs = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
98
+ var headers, response;
99
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
100
+ while (1) switch (_context2.prev = _context2.next) {
101
+ case 0:
102
+ _context2.prev = 0;
103
+ headers = {
104
+ headers: _objectSpread({}, cloneDeep(_this.params))
105
+ };
106
+ _context2.next = 4;
107
+ return http.get("".concat(_this.urlPath, "/logs"), headers);
108
+ case 4:
109
+ response = _context2.sent;
110
+ if (!response.data) {
111
+ _context2.next = 9;
112
+ break;
113
+ }
114
+ return _context2.abrupt("return", response.data.data);
115
+ case 9:
116
+ throw error(response);
117
+ case 10:
118
+ _context2.next = 15;
119
+ break;
120
+ case 12:
121
+ _context2.prev = 12;
122
+ _context2.t0 = _context2["catch"](0);
123
+ throw error(_context2.t0);
124
+ case 15:
125
+ case "end":
126
+ return _context2.stop();
127
+ }
128
+ }, _callee2, null, [[0, 12]]);
129
+ }));
130
+
131
+ /**
132
+ * @descriptionThe The create signed download url call is used to get the download url of the deployment source code.
133
+ * @memberof signedDownloadUrl
134
+ * @func logs
135
+ * @returns {Promise<Response>}
136
+ *
137
+ * @example
138
+ * import * as contentstack from '@contentstack/marketplace'
139
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
140
+ * client.marketplace('organization_uid').app('manifest_uid').hosting().deployment('deployment_uid').signedDownloadUrl()
141
+ * .then((data) => {})
142
+ */
143
+ this.signedDownloadUrl = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
144
+ var headers, response;
145
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
146
+ while (1) switch (_context3.prev = _context3.next) {
147
+ case 0:
148
+ _context3.prev = 0;
149
+ headers = {
150
+ headers: _objectSpread({}, cloneDeep(_this.params))
151
+ };
152
+ _context3.next = 4;
153
+ return http.post("".concat(_this.urlPath, "/signedDownloadUrl"), {}, headers);
154
+ case 4:
155
+ response = _context3.sent;
156
+ if (!response.data) {
157
+ _context3.next = 9;
158
+ break;
159
+ }
160
+ return _context3.abrupt("return", response.data.data);
161
+ case 9:
162
+ throw error(response);
163
+ case 10:
164
+ _context3.next = 15;
165
+ break;
166
+ case 12:
167
+ _context3.prev = 12;
168
+ _context3.t0 = _context3["catch"](0);
169
+ throw error(_context3.t0);
170
+ case 15:
171
+ case "end":
172
+ return _context3.stop();
173
+ }
174
+ }, _callee3, null, [[0, 12]]);
175
+ }));
176
+ } else {
177
+ /**
178
+ * @descriptionThe The create hosting deployments call is used to deploy the uploaded file in hosting
179
+ * @memberof Deployment
180
+ * @func create
181
+ * @returns {Promise<Deployment>}
182
+ *
183
+ * @example
184
+ * import * as contentstack from '@contentstack/marketplace'
185
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
186
+ * client.marketplace('organization_uid').app('manifest_uid').hosting().deployment().create()
187
+ * .then((data) => {})
188
+ */
189
+ this.create = /*#__PURE__*/function () {
190
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref4) {
191
+ var uploadUid, fileType, withAdvancedOptions, headers, response, content;
192
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
193
+ while (1) switch (_context4.prev = _context4.next) {
194
+ case 0:
195
+ uploadUid = _ref4.uploadUid, fileType = _ref4.fileType, withAdvancedOptions = _ref4.withAdvancedOptions;
196
+ _context4.prev = 1;
197
+ headers = {
198
+ headers: _objectSpread({}, cloneDeep(_this.params))
199
+ };
200
+ if (withAdvancedOptions) {
201
+ headers.params = {
202
+ with_advanced_options: withAdvancedOptions
203
+ };
204
+ }
205
+ _context4.next = 6;
206
+ return http.post("".concat(_this.urlPath), {
207
+ upload_uid: uploadUid,
208
+ file_type: fileType
209
+ }, headers);
210
+ case 6:
211
+ response = _context4.sent;
212
+ if (!response.data) {
213
+ _context4.next = 12;
214
+ break;
215
+ }
216
+ content = response.data.data;
217
+ return _context4.abrupt("return", new Deployment(http, {
218
+ data: content,
219
+ app_uid: data.app_uid
220
+ }, _this.params));
221
+ case 12:
222
+ throw error(response);
223
+ case 13:
224
+ _context4.next = 18;
225
+ break;
226
+ case 15:
227
+ _context4.prev = 15;
228
+ _context4.t0 = _context4["catch"](1);
229
+ throw error(_context4.t0);
230
+ case 18:
231
+ case "end":
232
+ return _context4.stop();
233
+ }
234
+ }, _callee4, null, [[1, 15]]);
235
+ }));
236
+ return function (_x) {
237
+ return _ref5.apply(this, arguments);
238
+ };
239
+ }();
240
+
241
+ /**
242
+ * @descriptionThe The list deployments call is used to get all the available deployments made for an app.
243
+ * @memberof Deployment
244
+ * @func findAll
245
+ * @returns {Promise<ContentstackCollection>}
246
+ *
247
+ * @example
248
+ * import * as contentstack from '@contentstack/marketplace'
249
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
250
+ * client.marketplace('organization_uid').app('manifest_uid').hosting().deployment().create()
251
+ * .then((data) => {})
252
+ */
253
+ this.findAll = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
254
+ var param,
255
+ headers,
256
+ response,
257
+ content,
258
+ collection,
259
+ _args5 = arguments;
260
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
261
+ while (1) switch (_context5.prev = _context5.next) {
262
+ case 0:
263
+ param = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
264
+ _context5.prev = 1;
265
+ headers = {
266
+ headers: _objectSpread({}, cloneDeep(_this.params)),
267
+ params: _objectSpread({}, cloneDeep(param))
268
+ };
269
+ _context5.next = 5;
270
+ return http.get("".concat(_this.urlPath), headers);
271
+ case 5:
272
+ response = _context5.sent;
273
+ if (!response.data) {
274
+ _context5.next = 13;
275
+ break;
276
+ }
277
+ content = response.data;
278
+ collection = new ContentstackCollection(response, http);
279
+ collection.items = DeploymentCollection(http, content, data.app_uid, _this.params);
280
+ return _context5.abrupt("return", collection);
281
+ case 13:
282
+ throw error(response);
283
+ case 14:
284
+ _context5.next = 19;
285
+ break;
286
+ case 16:
287
+ _context5.prev = 16;
288
+ _context5.t0 = _context5["catch"](1);
289
+ throw error(_context5.t0);
290
+ case 19:
291
+ case "end":
292
+ return _context5.stop();
293
+ }
294
+ }, _callee5, null, [[1, 16]]);
295
+ }));
296
+ }
297
+ }
298
+ }
299
+ export function DeploymentCollection(http, data, appUid, param) {
300
+ var obj = cloneDeep(data.data) || [];
301
+ return obj.map(function (content) {
302
+ return new Deployment(http, {
303
+ data: content,
304
+ app_uid: appUid
305
+ }, param);
306
+ });
307
+ }
@@ -0,0 +1,284 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ import cloneDeep from 'lodash/cloneDeep';
7
+ import error from '../../../core/contentstackError';
8
+ import { Deployment } from './deployment';
9
+
10
+ /**
11
+ *
12
+ * @namespace Hosting
13
+ */
14
+ export function Hosting(http, data, params) {
15
+ var _this = this;
16
+ http.defaults.versioningStrategy = undefined;
17
+ this.params = params || {};
18
+ if (data && data.app_uid) {
19
+ this.urlPath = "/manifests/".concat(data.app_uid, "/hosting");
20
+ if (data.organization_uid) {
21
+ this.params = {
22
+ organization_uid: data.organization_uid
23
+ };
24
+ }
25
+ /**
26
+ * @description The get hosting call is used to fetch to know whether the hosting is enabled or not.
27
+ * @memberof Hosting
28
+ * @func isEnable
29
+ * @returns {Promise<Response>}
30
+ *
31
+ * @example
32
+ * import * as contentstack from '@contentstack/marketplace'
33
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
34
+ * client.marketplace('organization_uid').app('manifest_uid').hosting().isEnable()
35
+ * .then((data) => {})
36
+ */
37
+ this.isEnable = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
38
+ var headers, response;
39
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
40
+ while (1) switch (_context.prev = _context.next) {
41
+ case 0:
42
+ _context.prev = 0;
43
+ headers = {
44
+ headers: _objectSpread({}, cloneDeep(_this.params))
45
+ };
46
+ _context.next = 4;
47
+ return http.get(_this.urlPath, headers);
48
+ case 4:
49
+ response = _context.sent;
50
+ if (!response.data) {
51
+ _context.next = 9;
52
+ break;
53
+ }
54
+ return _context.abrupt("return", response.data);
55
+ case 9:
56
+ throw error(response);
57
+ case 10:
58
+ _context.next = 15;
59
+ break;
60
+ case 12:
61
+ _context.prev = 12;
62
+ _context.t0 = _context["catch"](0);
63
+ throw error(_context.t0);
64
+ case 15:
65
+ case "end":
66
+ return _context.stop();
67
+ }
68
+ }, _callee, null, [[0, 12]]);
69
+ }));
70
+
71
+ /**
72
+ * @description The toggle hosting call is used to enable the hosting of an app.
73
+ * @memberof Hosting
74
+ * @func enable
75
+ * @returns {Promise<Response>}
76
+ *
77
+ * @example
78
+ * import * as contentstack from '@contentstack/marketplace'
79
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
80
+ * client.marketplace('organization_uid').app('manifest_uid').hosting().enable()
81
+ * .then((data) => {})
82
+ */
83
+ this.enable = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
84
+ var headers, response;
85
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
86
+ while (1) switch (_context2.prev = _context2.next) {
87
+ case 0:
88
+ _context2.prev = 0;
89
+ headers = {
90
+ headers: _objectSpread({}, cloneDeep(_this.params))
91
+ };
92
+ _context2.next = 4;
93
+ return http.patch("".concat(_this.urlPath, "/enable"), {}, headers);
94
+ case 4:
95
+ response = _context2.sent;
96
+ if (!response.data) {
97
+ _context2.next = 9;
98
+ break;
99
+ }
100
+ return _context2.abrupt("return", response.data);
101
+ case 9:
102
+ throw error(response);
103
+ case 10:
104
+ _context2.next = 15;
105
+ break;
106
+ case 12:
107
+ _context2.prev = 12;
108
+ _context2.t0 = _context2["catch"](0);
109
+ throw error(_context2.t0);
110
+ case 15:
111
+ case "end":
112
+ return _context2.stop();
113
+ }
114
+ }, _callee2, null, [[0, 12]]);
115
+ }));
116
+
117
+ /**
118
+ * @description The toggle hosting call is used to disable the hosting of an app.
119
+ * @memberof Hosting
120
+ * @func disable
121
+ * @returns {Promise<Response>}
122
+ *
123
+ * @example
124
+ * import * as contentstack from '@contentstack/marketplace'
125
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
126
+ * client.marketplace('organization_uid').app('manifest_uid').hosting().disable()
127
+ * .then((data) => {})
128
+ */
129
+ this.disable = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
130
+ var headers, response;
131
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
132
+ while (1) switch (_context3.prev = _context3.next) {
133
+ case 0:
134
+ _context3.prev = 0;
135
+ headers = {
136
+ headers: _objectSpread({}, cloneDeep(_this.params))
137
+ };
138
+ _context3.next = 4;
139
+ return http.patch("".concat(_this.urlPath, "/disable"), {}, headers);
140
+ case 4:
141
+ response = _context3.sent;
142
+ if (!response.data) {
143
+ _context3.next = 9;
144
+ break;
145
+ }
146
+ return _context3.abrupt("return", response.data);
147
+ case 9:
148
+ throw error(response);
149
+ case 10:
150
+ _context3.next = 15;
151
+ break;
152
+ case 12:
153
+ _context3.prev = 12;
154
+ _context3.t0 = _context3["catch"](0);
155
+ throw error(_context3.t0);
156
+ case 15:
157
+ case "end":
158
+ return _context3.stop();
159
+ }
160
+ }, _callee3, null, [[0, 12]]);
161
+ }));
162
+
163
+ /**
164
+ * @descriptionThe create signed upload url call is used to create an signed upload url for the files in hosting.
165
+ * @memberof Hosting
166
+ * @func createUploadUrl
167
+ * @returns {Promise<Response>}
168
+ *
169
+ * @example
170
+ * import * as contentstack from '@contentstack/marketplace'
171
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
172
+ * client.marketplace('organization_uid').app('manifest_uid').hosting().createUploadUrl()
173
+ * .then((data) => {})
174
+ */
175
+ this.createUploadUrl = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
176
+ var headers, response;
177
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
178
+ while (1) switch (_context4.prev = _context4.next) {
179
+ case 0:
180
+ _context4.prev = 0;
181
+ headers = {
182
+ headers: _objectSpread({}, cloneDeep(_this.params))
183
+ };
184
+ _context4.next = 4;
185
+ return http.post("".concat(_this.urlPath, "/signedUploadUrl"), {}, headers);
186
+ case 4:
187
+ response = _context4.sent;
188
+ if (!response.data) {
189
+ _context4.next = 9;
190
+ break;
191
+ }
192
+ return _context4.abrupt("return", response.data);
193
+ case 9:
194
+ throw error(response);
195
+ case 10:
196
+ _context4.next = 15;
197
+ break;
198
+ case 12:
199
+ _context4.prev = 12;
200
+ _context4.t0 = _context4["catch"](0);
201
+ throw error(_context4.t0);
202
+ case 15:
203
+ case "end":
204
+ return _context4.stop();
205
+ }
206
+ }, _callee4, null, [[0, 12]]);
207
+ }));
208
+
209
+ /**
210
+ * @descriptionThe The GET latest live deployment call is used to get details of latest deployment of the source file.
211
+ * @memberof Hosting
212
+ * @func latestLiveDeployment
213
+ * @returns {Promise<Deployment>}
214
+ *
215
+ * @example
216
+ * import * as contentstack from '@contentstack/marketplace'
217
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
218
+ * client.marketplace('organization_uid').app('manifest_uid').hosting().latestLiveDeployment()
219
+ * .then((data) => {})
220
+ */
221
+ this.latestLiveDeployment = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
222
+ var headers, response, content;
223
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
224
+ while (1) switch (_context5.prev = _context5.next) {
225
+ case 0:
226
+ _context5.prev = 0;
227
+ headers = {
228
+ headers: _objectSpread({}, cloneDeep(_this.params))
229
+ };
230
+ _context5.next = 4;
231
+ return http.get("".concat(_this.urlPath, "/latestLiveDeployment"), headers);
232
+ case 4:
233
+ response = _context5.sent;
234
+ if (!response.data) {
235
+ _context5.next = 10;
236
+ break;
237
+ }
238
+ content = response.data.data;
239
+ return _context5.abrupt("return", new Deployment(http, {
240
+ data: content,
241
+ app_uid: data.app_uid
242
+ }, _this.params));
243
+ case 10:
244
+ throw error(response);
245
+ case 11:
246
+ _context5.next = 16;
247
+ break;
248
+ case 13:
249
+ _context5.prev = 13;
250
+ _context5.t0 = _context5["catch"](0);
251
+ throw error(_context5.t0);
252
+ case 16:
253
+ case "end":
254
+ return _context5.stop();
255
+ }
256
+ }, _callee5, null, [[0, 13]]);
257
+ }));
258
+
259
+ /**
260
+ * @description Create instance of Hosting deployment.
261
+ * @memberof Hosting
262
+ * @func deployment
263
+ * @returns {Deployment}
264
+ *
265
+ * @example
266
+ * import * as contentstack from '@contentstack/marketplace'
267
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
268
+ * client.marketplace('organization_uid').app('manifest_uid').hosting().deployment()
269
+ *
270
+ */
271
+ this.deployment = function () {
272
+ var uid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
273
+ var content = {
274
+ app_uid: data.app_uid
275
+ };
276
+ if (uid) {
277
+ content.data = {
278
+ uid: uid
279
+ };
280
+ }
281
+ return new Deployment(http, content, _this.params);
282
+ };
283
+ }
284
+ }