@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,581 @@
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 { deleteEntity, fetch, fetchAll, update } from '../../entity';
9
+ import { WebHooks } from './webhooks';
10
+
11
+ /**
12
+ *
13
+ * @namespace Installation
14
+ */
15
+ export function Installation(http, data) {
16
+ var _this = this;
17
+ var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
18
+ this.params = params;
19
+ if (data.data) {
20
+ Object.assign(this, cloneDeep(data.data));
21
+ if (this.uid && !this.installation_uid) this.installation_uid = this.uid;
22
+ if (this.organization_uid) {
23
+ this.params = {
24
+ organization_uid: this.organization_uid
25
+ };
26
+ }
27
+ if (this.installation_uid) {
28
+ this.urlPath = "/installations/".concat(this.installation_uid);
29
+
30
+ /**
31
+ * @description The GET installation call is used to retrieve a specific installation of an app.
32
+ * @memberof Installation
33
+ * @func fetch
34
+ * @returns {Promise<Installation>}
35
+ *
36
+ * @example
37
+ * import * as contentstack from '@contentstack/marketplace'
38
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
39
+ *
40
+ * client.marketplace('organization_uid').installation('installation_uid').fetch()
41
+ * .then((installation) => console.log(installation))
42
+ *
43
+ */
44
+ this.fetch = fetch(http, 'data', this.params);
45
+
46
+ /**
47
+ * @description The Update installation call is used to update information of an installation.
48
+ * @memberof Installation
49
+ * @func update
50
+ * @returns {Promise<Installation>}
51
+ *
52
+ * @example
53
+ * import * as contentstack from '@contentstack/marketplace'
54
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
55
+ *
56
+ * const updateInstallation = {
57
+ * name: 'APP_NAME',
58
+ * description: 'APP_DESCRIPTION',
59
+ * target_type: 'stack'/'organization',
60
+ * }
61
+ *
62
+ * const installation = client.marketplace('organization_uid').installation('installation_uid')
63
+ * installation = Object.assign(installation, updateInstallation)
64
+ * installation.update()
65
+ * .then((installation) => console.log(installation))
66
+ */
67
+ this.update = update(http, 'data', this.params);
68
+
69
+ /**
70
+ * @description The Uninstall installation call is used to uninstall the installation.
71
+ * @memberof Installation
72
+ * @func uninstall
73
+ * @returns {Promise<Response>}
74
+ *
75
+ * @example
76
+ * import * as contentstack from '@contentstack/marketplace'
77
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
78
+ *
79
+ * client.marketplace('organization_uid').installation('installation_uid').uninstall()
80
+ * .then((response) => console.log(response))
81
+ */
82
+ this.uninstall = deleteEntity(http, false, this.params);
83
+
84
+ /**
85
+ * @description To fetch organization level app installation configuration.
86
+ * @memberof Installation
87
+ * @func configuration
88
+ * @param {*} param
89
+ * @returns {Promise<Response>}
90
+ *
91
+ * @example
92
+ * import * as contentstack from '@contentstack/marketplace'
93
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
94
+ *
95
+ * client.marketplace('organization_uid').installation('installation_uid').configuration()
96
+ * .then((response) => console.log(response))
97
+ */
98
+ this.configuration = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
99
+ var param,
100
+ headers,
101
+ response,
102
+ _args = arguments;
103
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
104
+ while (1) switch (_context.prev = _context.next) {
105
+ case 0:
106
+ param = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
107
+ _context.prev = 1;
108
+ headers = {
109
+ headers: _objectSpread({}, cloneDeep(params)),
110
+ params: _objectSpread({}, cloneDeep(param))
111
+ } || {};
112
+ _context.next = 5;
113
+ return http.get("".concat(_this.urlPath, "/configuration"), headers);
114
+ case 5:
115
+ response = _context.sent;
116
+ if (!response.data) {
117
+ _context.next = 10;
118
+ break;
119
+ }
120
+ return _context.abrupt("return", response.data);
121
+ case 10:
122
+ throw error(response);
123
+ case 11:
124
+ _context.next = 16;
125
+ break;
126
+ case 13:
127
+ _context.prev = 13;
128
+ _context.t0 = _context["catch"](1);
129
+ throw error(_context.t0);
130
+ case 16:
131
+ case "end":
132
+ return _context.stop();
133
+ }
134
+ }, _callee, null, [[1, 13]]);
135
+ }));
136
+
137
+ /**
138
+ * @description To update organization level app installation configuration.
139
+ * @memberof Installation
140
+ * @func setConfiguration
141
+ * @param {*} config Config that needs to be updated
142
+ * @returns {Promise<Response>}
143
+ *
144
+ * @example
145
+ * import * as contentstack from '@contentstack/marketplace'
146
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
147
+ *
148
+ * client.marketplace('organization_uid').installation('installation_uid').setConfiguration({<configuration_details>})
149
+ * .then((response) => console.log(response))
150
+ */
151
+ this.setConfiguration = /*#__PURE__*/function () {
152
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(config) {
153
+ var headers, response;
154
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
155
+ while (1) switch (_context2.prev = _context2.next) {
156
+ case 0:
157
+ _context2.prev = 0;
158
+ headers = {
159
+ headers: _objectSpread({}, cloneDeep(params))
160
+ } || {};
161
+ _context2.next = 4;
162
+ return http.put("".concat(_this.urlPath, "/configuration"), config, headers);
163
+ case 4:
164
+ response = _context2.sent;
165
+ if (!response.data) {
166
+ _context2.next = 9;
167
+ break;
168
+ }
169
+ return _context2.abrupt("return", response.data);
170
+ case 9:
171
+ throw error(response);
172
+ case 10:
173
+ _context2.next = 15;
174
+ break;
175
+ case 12:
176
+ _context2.prev = 12;
177
+ _context2.t0 = _context2["catch"](0);
178
+ throw error(_context2.t0);
179
+ case 15:
180
+ case "end":
181
+ return _context2.stop();
182
+ }
183
+ }, _callee2, null, [[0, 12]]);
184
+ }));
185
+ return function (_x) {
186
+ return _ref2.apply(this, arguments);
187
+ };
188
+ }();
189
+
190
+ /**
191
+ * @description To update organization level app installation configuration.
192
+ * @memberof Installation
193
+ * @func getConfigLocation
194
+ * @param {*} config Config that needs to be updated
195
+ * @returns {Promise<Response>}
196
+ *
197
+ * @example
198
+ * import * as contentstack from '@contentstack/marketplace'
199
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
200
+ *
201
+ * client.marketplace('organization_uid').installation('installation_uid').getConfigLocation()
202
+ * .then((response) => console.log(response))
203
+ */
204
+ this.getConfigLocation = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
205
+ var headers, response;
206
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
207
+ while (1) switch (_context3.prev = _context3.next) {
208
+ case 0:
209
+ _context3.prev = 0;
210
+ headers = {
211
+ headers: _objectSpread({}, cloneDeep(params))
212
+ } || {};
213
+ _context3.next = 4;
214
+ return http.get("".concat(_this.urlPath, "/locations/configuration"), headers);
215
+ case 4:
216
+ response = _context3.sent;
217
+ if (!response.data) {
218
+ _context3.next = 9;
219
+ break;
220
+ }
221
+ return _context3.abrupt("return", response.data);
222
+ case 9:
223
+ throw error(response);
224
+ case 10:
225
+ _context3.next = 15;
226
+ break;
227
+ case 12:
228
+ _context3.prev = 12;
229
+ _context3.t0 = _context3["catch"](0);
230
+ throw error(_context3.t0);
231
+ case 15:
232
+ case "end":
233
+ return _context3.stop();
234
+ }
235
+ }, _callee3, null, [[0, 12]]);
236
+ }));
237
+
238
+ /**
239
+ * @description To fetch server side organization level config required for the app.
240
+ * @memberof Installation
241
+ * @func getServerConfig
242
+ * @param {*} param
243
+ * @returns {Promise<Response>}
244
+ *
245
+ * @example
246
+ * import * as contentstack from '@contentstack/marketplace'
247
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
248
+ *
249
+ * client.marketplace('organization_uid').installation('installation_uid').serverConfig()
250
+ * .then((response) => console.log(response))
251
+ */
252
+ this.serverConfig = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
253
+ var param,
254
+ headers,
255
+ response,
256
+ _args4 = arguments;
257
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
258
+ while (1) switch (_context4.prev = _context4.next) {
259
+ case 0:
260
+ param = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
261
+ _context4.prev = 1;
262
+ headers = {
263
+ headers: _objectSpread({}, cloneDeep(params)),
264
+ params: _objectSpread({}, cloneDeep(param))
265
+ } || {};
266
+ _context4.next = 5;
267
+ return http.get("".concat(_this.urlPath, "/server-configuration"), headers);
268
+ case 5:
269
+ response = _context4.sent;
270
+ if (!response.data) {
271
+ _context4.next = 10;
272
+ break;
273
+ }
274
+ return _context4.abrupt("return", response.data);
275
+ case 10:
276
+ throw error(response);
277
+ case 11:
278
+ _context4.next = 16;
279
+ break;
280
+ case 13:
281
+ _context4.prev = 13;
282
+ _context4.t0 = _context4["catch"](1);
283
+ throw error(_context4.t0);
284
+ case 16:
285
+ case "end":
286
+ return _context4.stop();
287
+ }
288
+ }, _callee4, null, [[1, 13]]);
289
+ }));
290
+
291
+ /**
292
+ * @description To update server side organization level config required for the app.
293
+ * @memberof Installation
294
+ * @func setServerConfig
295
+ * @param {*} config Config that needs to be updated
296
+ * @returns {Promise<Response>}
297
+ *
298
+ * @example
299
+ * import * as contentstack from '@contentstack/marketplace'
300
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
301
+ *
302
+ * client.marketplace('organization_uid').installation('installation_uid').setServerConfig({<configuration_details>})
303
+ * .then((response) => console.log(response))
304
+ */
305
+ this.setServerConfig = /*#__PURE__*/function () {
306
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(config) {
307
+ var headers, response;
308
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
309
+ while (1) switch (_context5.prev = _context5.next) {
310
+ case 0:
311
+ _context5.prev = 0;
312
+ headers = {
313
+ headers: _objectSpread({}, cloneDeep(params))
314
+ } || {};
315
+ _context5.next = 4;
316
+ return http.put("".concat(_this.urlPath, "/server-configuration"), config, headers);
317
+ case 4:
318
+ response = _context5.sent;
319
+ if (!response.data) {
320
+ _context5.next = 9;
321
+ break;
322
+ }
323
+ return _context5.abrupt("return", response.data);
324
+ case 9:
325
+ throw error(response);
326
+ case 10:
327
+ _context5.next = 15;
328
+ break;
329
+ case 12:
330
+ _context5.prev = 12;
331
+ _context5.t0 = _context5["catch"](0);
332
+ throw error(_context5.t0);
333
+ case 15:
334
+ case "end":
335
+ return _context5.stop();
336
+ }
337
+ }, _callee5, null, [[0, 12]]);
338
+ }));
339
+ return function (_x2) {
340
+ return _ref5.apply(this, arguments);
341
+ };
342
+ }();
343
+
344
+ /**
345
+ * @description To fetch installation data of an app configuration.
346
+ * @memberof Installation
347
+ * @func installationData
348
+ * @returns {Promise<Response>}
349
+ *
350
+ * @example
351
+ * import * as contentstack from '@contentstack/marketplace'
352
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
353
+ *
354
+ * client.marketplace('organization_uid').installation('installation_uid').installationData()
355
+ * .then((response) => console.log(response))
356
+ */
357
+ this.installationData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
358
+ var headers, response;
359
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
360
+ while (1) switch (_context6.prev = _context6.next) {
361
+ case 0:
362
+ _context6.prev = 0;
363
+ headers = {
364
+ headers: _objectSpread({}, cloneDeep(params))
365
+ } || {};
366
+ _context6.next = 4;
367
+ return http.get("".concat(_this.urlPath, "/installationData"), headers);
368
+ case 4:
369
+ response = _context6.sent;
370
+ if (!response.data) {
371
+ _context6.next = 9;
372
+ break;
373
+ }
374
+ return _context6.abrupt("return", response.data);
375
+ case 9:
376
+ throw error(response);
377
+ case 10:
378
+ _context6.next = 15;
379
+ break;
380
+ case 12:
381
+ _context6.prev = 12;
382
+ _context6.t0 = _context6["catch"](0);
383
+ throw error(_context6.t0);
384
+ case 15:
385
+ case "end":
386
+ return _context6.stop();
387
+ }
388
+ }, _callee6, null, [[0, 12]]);
389
+ }));
390
+
391
+ /**
392
+ * @description Gives Webhook instance
393
+ * @memberof Installation
394
+ * @func webhooks
395
+ * @returns {WebHooks}
396
+ *
397
+ * @example
398
+ * import * as contentstack from '@contentstack/marketplace'
399
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
400
+ * client.marketplace('organization_uid').app('manifest_uid')
401
+ */
402
+ this.webhooks = function (webhookUid) {
403
+ return new WebHooks(http, {
404
+ uid: webhookUid,
405
+ installationUid: _this.installation_uid
406
+ });
407
+ };
408
+ } else {
409
+ this.urlPath = "/installations";
410
+
411
+ /**
412
+ * @description The fetchAll call is used to fetch all the installations in your Contentstack organization.
413
+ * @memberof Installation
414
+ * @func fetchAll
415
+ * @returns {Promise<ContentstackCollection<Installation>>}
416
+ *
417
+ * @example
418
+ * import * as contentstack from '@contentstack/marketplace'
419
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
420
+ *
421
+ * client.marketplace('organization_uid').installation().fetchAll()
422
+ * .then((collection) => console.log(collection))
423
+ *
424
+ */
425
+ this.fetchAll = fetchAll(http, InstallationCollection);
426
+
427
+ /**
428
+ * @description The getInstalledApps call is used to fetch all the installed apps in your Contentstack organization.
429
+ * @memberof Installation
430
+ * @func getInstalledApps
431
+ * @returns {Promise<ContentstackCollection<Installation>>}
432
+ *
433
+ * @example
434
+ * import * as contentstack from '@contentstack/marketplace'
435
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
436
+ *
437
+ * client.marketplace('organization_uid').installation().getInstalledApps()
438
+ * .then((collection) => console.log(collection))
439
+ *
440
+ */
441
+ this.getInstalledApps = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
442
+ var headers, response;
443
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
444
+ while (1) switch (_context7.prev = _context7.next) {
445
+ case 0:
446
+ _context7.prev = 0;
447
+ headers = {
448
+ headers: _objectSpread({}, cloneDeep(params))
449
+ } || {};
450
+ _context7.next = 4;
451
+ return http.get("".concat(_this.urlPath, "/view/apps"), headers);
452
+ case 4:
453
+ response = _context7.sent;
454
+ if (!response.data) {
455
+ _context7.next = 9;
456
+ break;
457
+ }
458
+ return _context7.abrupt("return", response.data);
459
+ case 9:
460
+ throw error(response);
461
+ case 10:
462
+ _context7.next = 15;
463
+ break;
464
+ case 12:
465
+ _context7.prev = 12;
466
+ _context7.t0 = _context7["catch"](0);
467
+ throw error(_context7.t0);
468
+ case 15:
469
+ case "end":
470
+ return _context7.stop();
471
+ }
472
+ }, _callee7, null, [[0, 12]]);
473
+ }));
474
+
475
+ /**
476
+ * @description The getInstalledUsers call is used to fetch all the installed apps in your Contentstack organization.
477
+ * @memberof Installation
478
+ * @func getInstalledUsers
479
+ * @returns {Promise<ContentstackCollection<Installation>>}
480
+ *
481
+ * @example
482
+ * import * as contentstack from '@contentstack/marketplace'
483
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
484
+ *
485
+ * client.marketplace('organization_uid').installation().getInstalledUsers()
486
+ * .then((collection) => console.log(collection))
487
+ *
488
+ */
489
+ this.getInstalledUsers = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
490
+ var headers, response;
491
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
492
+ while (1) switch (_context8.prev = _context8.next) {
493
+ case 0:
494
+ _context8.prev = 0;
495
+ headers = {
496
+ headers: _objectSpread({}, cloneDeep(params))
497
+ } || {};
498
+ _context8.next = 4;
499
+ return http.get("".concat(_this.urlPath, "/view/users"), headers);
500
+ case 4:
501
+ response = _context8.sent;
502
+ if (!response.data) {
503
+ _context8.next = 9;
504
+ break;
505
+ }
506
+ return _context8.abrupt("return", response.data);
507
+ case 9:
508
+ throw error(response);
509
+ case 10:
510
+ _context8.next = 15;
511
+ break;
512
+ case 12:
513
+ _context8.prev = 12;
514
+ _context8.t0 = _context8["catch"](0);
515
+ throw error(_context8.t0);
516
+ case 15:
517
+ case "end":
518
+ return _context8.stop();
519
+ }
520
+ }, _callee8, null, [[0, 12]]);
521
+ }));
522
+
523
+ /**
524
+ * @description The getInstalledStacks call is used to fetch all the installed apps in your Contentstack organization.
525
+ * @memberof Installation
526
+ * @func getInstalledStacks
527
+ * @returns {Promise<ContentstackCollection<Installation>>}
528
+ *
529
+ * @example
530
+ * import * as contentstack from '@contentstack/marketplace'
531
+ * const client = contentstack.client({ authtoken: 'TOKEN'})
532
+ *
533
+ * client.marketplace('organization_uid').installation().getInstalledStacks()
534
+ * .then((collection) => console.log(collection))
535
+ *
536
+ */
537
+ this.getInstalledStacks = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
538
+ var headers, response;
539
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
540
+ while (1) switch (_context9.prev = _context9.next) {
541
+ case 0:
542
+ _context9.prev = 0;
543
+ headers = {
544
+ headers: _objectSpread({}, cloneDeep(params))
545
+ } || {};
546
+ _context9.next = 4;
547
+ return http.get("".concat(_this.urlPath, "/view/stacks"), headers);
548
+ case 4:
549
+ response = _context9.sent;
550
+ if (!response.data) {
551
+ _context9.next = 9;
552
+ break;
553
+ }
554
+ return _context9.abrupt("return", response.data);
555
+ case 9:
556
+ throw error(response);
557
+ case 10:
558
+ _context9.next = 15;
559
+ break;
560
+ case 12:
561
+ _context9.prev = 12;
562
+ _context9.t0 = _context9["catch"](0);
563
+ throw error(_context9.t0);
564
+ case 15:
565
+ case "end":
566
+ return _context9.stop();
567
+ }
568
+ }, _callee9, null, [[0, 12]]);
569
+ }));
570
+ }
571
+ }
572
+ return this;
573
+ }
574
+ export function InstallationCollection(http, data) {
575
+ var obj = cloneDeep(data.data) || [];
576
+ return obj.map(function (installationData) {
577
+ return new Installation(http, {
578
+ data: installationData
579
+ });
580
+ });
581
+ }