@agility/management-sdk 0.1.9 → 0.1.11

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 (122) hide show
  1. package/README.md +522 -465
  2. package/dist/apiClient.d.ts +19 -19
  3. package/dist/apiClient.js +24 -24
  4. package/dist/apiMethods/assetMethods.d.ts +24 -15
  5. package/dist/apiMethods/assetMethods.js +315 -192
  6. package/dist/apiMethods/batchMethods.d.ts +11 -11
  7. package/dist/apiMethods/batchMethods.js +117 -117
  8. package/dist/apiMethods/clientInstance.d.ts +18 -8
  9. package/dist/apiMethods/clientInstance.js +168 -156
  10. package/dist/apiMethods/containerMethods.d.ts +16 -16
  11. package/dist/apiMethods/containerMethods.js +189 -189
  12. package/dist/apiMethods/contentMethods.d.ts +20 -20
  13. package/dist/apiMethods/contentMethods.js +359 -359
  14. package/dist/apiMethods/instanceUserMethods.d.ts +13 -13
  15. package/dist/apiMethods/instanceUserMethods.js +111 -111
  16. package/dist/apiMethods/modelMethods.d.ts +14 -14
  17. package/dist/apiMethods/modelMethods.js +170 -170
  18. package/dist/apiMethods/pageMethods.d.ts +20 -20
  19. package/dist/apiMethods/pageMethods.js +323 -323
  20. package/dist/enums/assetGroupingType.d.ts +3 -0
  21. package/dist/enums/assetGroupingType.js +7 -0
  22. package/dist/enums/batchOperationType.d.ts +19 -19
  23. package/dist/enums/batchOperationType.js +23 -23
  24. package/dist/enums/batchState..d.ts +7 -7
  25. package/dist/enums/batchState..js +11 -11
  26. package/dist/index.d.ts +19 -14
  27. package/dist/index.js +31 -30
  28. package/dist/models/assetContainer.d.ts +7 -0
  29. package/dist/models/assetContainer.js +9 -0
  30. package/dist/models/assetGalleries.d.ts +5 -0
  31. package/dist/models/assetGalleries.js +9 -0
  32. package/dist/models/assetMediaGrouping.d.ts +17 -0
  33. package/dist/models/assetMediaGrouping.js +9 -0
  34. package/dist/models/assetMediaGroupingMetaData.d.ts +4 -0
  35. package/dist/models/assetMediaGroupingMetaData.js +9 -0
  36. package/dist/models/batch.d.ts +29 -29
  37. package/dist/models/batch.js +9 -9
  38. package/dist/models/batchItem.d.ts +13 -13
  39. package/dist/models/batchItem.js +9 -9
  40. package/dist/models/container.d.ts +47 -47
  41. package/dist/models/container.js +9 -9
  42. package/dist/models/contentItem.d.ts +37 -37
  43. package/dist/models/contentItem.js +33 -33
  44. package/dist/models/contentViewColumn.d.ts +8 -8
  45. package/dist/models/contentViewColumn.js +9 -9
  46. package/dist/models/exception.d.ts +4 -4
  47. package/dist/models/exception.js +26 -28
  48. package/dist/models/instanceRole.d.ts +7 -7
  49. package/dist/models/instanceRole.js +9 -9
  50. package/dist/models/instanceUser.d.ts +14 -14
  51. package/dist/models/instanceUser.js +9 -9
  52. package/dist/models/media.d.ts +30 -30
  53. package/dist/models/media.js +15 -15
  54. package/dist/models/model.d.ts +30 -30
  55. package/dist/models/model.js +15 -15
  56. package/dist/models/notification.d.ts +13 -13
  57. package/dist/models/notification.js +9 -9
  58. package/dist/models/options.d.ts +7 -7
  59. package/dist/models/options.js +9 -9
  60. package/dist/models/pageItem.d.ts +56 -56
  61. package/dist/models/pageItem.js +39 -39
  62. package/dist/models/sitemap.d.ts +20 -20
  63. package/dist/models/sitemap.js +15 -15
  64. package/dist/models/websiteUser.d.ts +22 -22
  65. package/dist/models/websiteUser.js +15 -15
  66. package/license.txt +20 -20
  67. package/package.json +39 -39
  68. package/tsconfig.json +14 -14
  69. package/dist/apiMethods/apiClient.d.ts +0 -19
  70. package/dist/apiMethods/apiClient.js +0 -24
  71. package/dist/src/apiMethods/assetMethods.d.ts +0 -14
  72. package/dist/src/apiMethods/assetMethods.js +0 -172
  73. package/dist/src/apiMethods/batchMethods.d.ts +0 -11
  74. package/dist/src/apiMethods/batchMethods.js +0 -117
  75. package/dist/src/apiMethods/clientInstance.d.ts +0 -8
  76. package/dist/src/apiMethods/clientInstance.js +0 -156
  77. package/dist/src/apiMethods/containerMethods.d.ts +0 -16
  78. package/dist/src/apiMethods/containerMethods.js +0 -189
  79. package/dist/src/apiMethods/contentMethods.d.ts +0 -20
  80. package/dist/src/apiMethods/contentMethods.js +0 -359
  81. package/dist/src/apiMethods/instanceUserMethods.d.ts +0 -13
  82. package/dist/src/apiMethods/instanceUserMethods.js +0 -111
  83. package/dist/src/apiMethods/modelMethods.d.ts +0 -13
  84. package/dist/src/apiMethods/modelMethods.js +0 -150
  85. package/dist/src/apiMethods/pageMethods.d.ts +0 -20
  86. package/dist/src/apiMethods/pageMethods.js +0 -323
  87. package/dist/src/enums/batchOperationType.d.ts +0 -19
  88. package/dist/src/enums/batchOperationType.js +0 -23
  89. package/dist/src/enums/batchState..d.ts +0 -7
  90. package/dist/src/enums/batchState..js +0 -11
  91. package/dist/src/index.d.ts +0 -14
  92. package/dist/src/index.js +0 -30
  93. package/dist/src/models/batch.d.ts +0 -29
  94. package/dist/src/models/batch.js +0 -9
  95. package/dist/src/models/batchItem.d.ts +0 -13
  96. package/dist/src/models/batchItem.js +0 -9
  97. package/dist/src/models/container.d.ts +0 -47
  98. package/dist/src/models/container.js +0 -9
  99. package/dist/src/models/contentItem.d.ts +0 -37
  100. package/dist/src/models/contentItem.js +0 -33
  101. package/dist/src/models/contentViewColumn.d.ts +0 -8
  102. package/dist/src/models/contentViewColumn.js +0 -9
  103. package/dist/src/models/exception.d.ts +0 -4
  104. package/dist/src/models/exception.js +0 -28
  105. package/dist/src/models/instanceRole.d.ts +0 -7
  106. package/dist/src/models/instanceRole.js +0 -9
  107. package/dist/src/models/instanceUser.d.ts +0 -14
  108. package/dist/src/models/instanceUser.js +0 -9
  109. package/dist/src/models/media.d.ts +0 -30
  110. package/dist/src/models/media.js +0 -15
  111. package/dist/src/models/model.d.ts +0 -30
  112. package/dist/src/models/model.js +0 -15
  113. package/dist/src/models/notification.d.ts +0 -13
  114. package/dist/src/models/notification.js +0 -9
  115. package/dist/src/models/options.d.ts +0 -7
  116. package/dist/src/models/options.js +0 -9
  117. package/dist/src/models/pageItem.d.ts +0 -56
  118. package/dist/src/models/pageItem.js +0 -39
  119. package/dist/src/models/sitemap.d.ts +0 -20
  120. package/dist/src/models/sitemap.js +0 -15
  121. package/dist/src/models/websiteUser.d.ts +0 -22
  122. package/dist/src/models/websiteUser.js +0 -15
@@ -1,359 +1,359 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.ContentMethods = void 0;
40
- var clientInstance_1 = require("./clientInstance");
41
- var batchMethods_1 = require("./batchMethods");
42
- var exception_1 = require("../models/exception");
43
- var ContentMethods = /** @class */ (function () {
44
- function ContentMethods(options) {
45
- this._options = options;
46
- this._clientInstance = new clientInstance_1.ClientInstance();
47
- this._batchMethods = new batchMethods_1.BatchMethods(this._options);
48
- }
49
- ContentMethods.prototype.getContentItem = function (contentID, guid, locale) {
50
- return __awaiter(this, void 0, void 0, function () {
51
- var apiPath, resp, err_1;
52
- return __generator(this, function (_a) {
53
- switch (_a.label) {
54
- case 0:
55
- _a.trys.push([0, 2, , 3]);
56
- apiPath = "".concat(locale, "/item/").concat(contentID);
57
- return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
58
- case 1:
59
- resp = _a.sent();
60
- return [2 /*return*/, resp.data];
61
- case 2:
62
- err_1 = _a.sent();
63
- throw new exception_1.Exception("Unable to retreive the content for id: ".concat(contentID), err_1);
64
- case 3: return [2 /*return*/];
65
- }
66
- });
67
- });
68
- };
69
- ContentMethods.prototype.publishContent = function (contentID, guid, locale, comments) {
70
- if (comments === void 0) { comments = null; }
71
- return __awaiter(this, void 0, void 0, function () {
72
- var apiPath, resp, batchID_1, batch, contentIDs_1, err_2;
73
- var _this = this;
74
- return __generator(this, function (_a) {
75
- switch (_a.label) {
76
- case 0:
77
- _a.trys.push([0, 3, , 4]);
78
- apiPath = "".concat(locale, "/item/").concat(contentID, "/publish?comments=").concat(comments);
79
- return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
80
- case 1:
81
- resp = _a.sent();
82
- batchID_1 = resp.data;
83
- return [4 /*yield*/, this._batchMethods.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
84
- switch (_a.label) {
85
- case 0: return [4 /*yield*/, this._batchMethods.getBatch(batchID_1, guid)];
86
- case 1: return [2 /*return*/, _a.sent()];
87
- }
88
- }); }); })];
89
- case 2:
90
- batch = _a.sent();
91
- contentIDs_1 = [];
92
- batch.items.forEach(function (element) { return contentIDs_1.push(element.itemID); });
93
- return [2 /*return*/, contentIDs_1];
94
- case 3:
95
- err_2 = _a.sent();
96
- throw new exception_1.Exception("Unable to publish the content for id: ".concat(contentID), err_2);
97
- case 4: return [2 /*return*/];
98
- }
99
- });
100
- });
101
- };
102
- ContentMethods.prototype.unPublishContent = function (contentID, guid, locale, comments) {
103
- if (comments === void 0) { comments = null; }
104
- return __awaiter(this, void 0, void 0, function () {
105
- var apiPath, resp, batchID_2, batch, contentIDs_2, err_3;
106
- var _this = this;
107
- return __generator(this, function (_a) {
108
- switch (_a.label) {
109
- case 0:
110
- _a.trys.push([0, 3, , 4]);
111
- apiPath = "".concat(locale, "/item/").concat(contentID, "/unpublish?comments=").concat(comments);
112
- return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
113
- case 1:
114
- resp = _a.sent();
115
- batchID_2 = resp.data;
116
- return [4 /*yield*/, this._batchMethods.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
117
- switch (_a.label) {
118
- case 0: return [4 /*yield*/, this._batchMethods.getBatch(batchID_2, guid)];
119
- case 1: return [2 /*return*/, _a.sent()];
120
- }
121
- }); }); })];
122
- case 2:
123
- batch = _a.sent();
124
- contentIDs_2 = [];
125
- batch.items.forEach(function (element) { return contentIDs_2.push(element.itemID); });
126
- return [2 /*return*/, contentIDs_2];
127
- case 3:
128
- err_3 = _a.sent();
129
- throw new exception_1.Exception("Unable to un-publish the content for id: ".concat(contentID), err_3);
130
- case 4: return [2 /*return*/];
131
- }
132
- });
133
- });
134
- };
135
- ContentMethods.prototype.contentRequestApproval = function (contentID, guid, locale, comments) {
136
- if (comments === void 0) { comments = null; }
137
- return __awaiter(this, void 0, void 0, function () {
138
- var apiPath, resp, batchID_3, batch, contentIDs_3, err_4;
139
- var _this = this;
140
- return __generator(this, function (_a) {
141
- switch (_a.label) {
142
- case 0:
143
- _a.trys.push([0, 3, , 4]);
144
- apiPath = "".concat(locale, "/item/").concat(contentID, "/request-approval?comments=").concat(comments);
145
- return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
146
- case 1:
147
- resp = _a.sent();
148
- batchID_3 = resp.data;
149
- return [4 /*yield*/, this._batchMethods.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
150
- switch (_a.label) {
151
- case 0: return [4 /*yield*/, this._batchMethods.getBatch(batchID_3, guid)];
152
- case 1: return [2 /*return*/, _a.sent()];
153
- }
154
- }); }); })];
155
- case 2:
156
- batch = _a.sent();
157
- contentIDs_3 = [];
158
- batch.items.forEach(function (element) { return contentIDs_3.push(element.itemID); });
159
- return [2 /*return*/, contentIDs_3];
160
- case 3:
161
- err_4 = _a.sent();
162
- throw new exception_1.Exception("Unable to request approval the content for id: ".concat(contentID), err_4);
163
- case 4: return [2 /*return*/];
164
- }
165
- });
166
- });
167
- };
168
- ContentMethods.prototype.approveContent = function (contentID, guid, locale, comments) {
169
- if (comments === void 0) { comments = null; }
170
- return __awaiter(this, void 0, void 0, function () {
171
- var apiPath, resp, batchID_4, batch, contentIDs_4, err_5;
172
- var _this = this;
173
- return __generator(this, function (_a) {
174
- switch (_a.label) {
175
- case 0:
176
- _a.trys.push([0, 3, , 4]);
177
- apiPath = "".concat(locale, "/item/").concat(contentID, "/approve?comments=").concat(comments);
178
- return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
179
- case 1:
180
- resp = _a.sent();
181
- batchID_4 = resp.data;
182
- return [4 /*yield*/, this._batchMethods.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
183
- switch (_a.label) {
184
- case 0: return [4 /*yield*/, this._batchMethods.getBatch(batchID_4, guid)];
185
- case 1: return [2 /*return*/, _a.sent()];
186
- }
187
- }); }); })];
188
- case 2:
189
- batch = _a.sent();
190
- contentIDs_4 = [];
191
- batch.items.forEach(function (element) { return contentIDs_4.push(element.itemID); });
192
- return [2 /*return*/, contentIDs_4];
193
- case 3:
194
- err_5 = _a.sent();
195
- throw new exception_1.Exception("Unable to approve the content for id: ".concat(contentID), err_5);
196
- case 4: return [2 /*return*/];
197
- }
198
- });
199
- });
200
- };
201
- ContentMethods.prototype.declineContent = function (contentID, guid, locale, comments) {
202
- if (comments === void 0) { comments = null; }
203
- return __awaiter(this, void 0, void 0, function () {
204
- var apiPath, resp, batchID_5, batch, contentIDs_5, err_6;
205
- var _this = this;
206
- return __generator(this, function (_a) {
207
- switch (_a.label) {
208
- case 0:
209
- _a.trys.push([0, 3, , 4]);
210
- apiPath = "".concat(locale, "/item/").concat(contentID, "/decline?comments=").concat(comments);
211
- return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
212
- case 1:
213
- resp = _a.sent();
214
- batchID_5 = resp.data;
215
- return [4 /*yield*/, this._batchMethods.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
216
- switch (_a.label) {
217
- case 0: return [4 /*yield*/, this._batchMethods.getBatch(batchID_5, guid)];
218
- case 1: return [2 /*return*/, _a.sent()];
219
- }
220
- }); }); })];
221
- case 2:
222
- batch = _a.sent();
223
- contentIDs_5 = [];
224
- batch.items.forEach(function (element) { return contentIDs_5.push(element.itemID); });
225
- return [2 /*return*/, contentIDs_5];
226
- case 3:
227
- err_6 = _a.sent();
228
- throw new exception_1.Exception("Unable to decline the content for id: ".concat(contentID), err_6);
229
- case 4: return [2 /*return*/];
230
- }
231
- });
232
- });
233
- };
234
- ContentMethods.prototype.deleteContent = function (contentID, guid, locale, comments) {
235
- if (comments === void 0) { comments = null; }
236
- return __awaiter(this, void 0, void 0, function () {
237
- var apiPath, resp, batchID_6, batch, contentIDs_6, err_7;
238
- var _this = this;
239
- return __generator(this, function (_a) {
240
- switch (_a.label) {
241
- case 0:
242
- _a.trys.push([0, 3, , 4]);
243
- apiPath = "".concat(locale, "/item/").concat(contentID, "?comments=").concat(comments);
244
- return [4 /*yield*/, this._clientInstance.executeDelete(apiPath, guid, this._options.token)];
245
- case 1:
246
- resp = _a.sent();
247
- batchID_6 = resp.data;
248
- return [4 /*yield*/, this._batchMethods.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
249
- switch (_a.label) {
250
- case 0: return [4 /*yield*/, this._batchMethods.getBatch(batchID_6, guid)];
251
- case 1: return [2 /*return*/, _a.sent()];
252
- }
253
- }); }); })];
254
- case 2:
255
- batch = _a.sent();
256
- contentIDs_6 = [];
257
- batch.items.forEach(function (element) { return contentIDs_6.push(element.itemID); });
258
- return [2 /*return*/, contentIDs_6];
259
- case 3:
260
- err_7 = _a.sent();
261
- throw new exception_1.Exception("Unable to delete the content for id: ".concat(contentID), err_7);
262
- case 4: return [2 /*return*/];
263
- }
264
- });
265
- });
266
- };
267
- ContentMethods.prototype.saveContentItem = function (contentItem, guid, locale) {
268
- return __awaiter(this, void 0, void 0, function () {
269
- var apiPath, resp, batchID_7, batch, contentIDs_7, err_8;
270
- var _this = this;
271
- return __generator(this, function (_a) {
272
- switch (_a.label) {
273
- case 0:
274
- _a.trys.push([0, 3, , 4]);
275
- apiPath = "".concat(locale, "/item");
276
- return [4 /*yield*/, this._clientInstance.executePost(apiPath, guid, this._options.token, contentItem)];
277
- case 1:
278
- resp = _a.sent();
279
- batchID_7 = resp.data;
280
- return [4 /*yield*/, this._batchMethods.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
281
- switch (_a.label) {
282
- case 0: return [4 /*yield*/, this._batchMethods.getBatch(batchID_7, guid)];
283
- case 1: return [2 /*return*/, _a.sent()];
284
- }
285
- }); }); })];
286
- case 2:
287
- batch = _a.sent();
288
- contentIDs_7 = [];
289
- batch.items.forEach(function (element) { return contentIDs_7.push(element.itemID); });
290
- return [2 /*return*/, contentIDs_7];
291
- case 3:
292
- err_8 = _a.sent();
293
- throw new exception_1.Exception('Unable to create content.', err_8);
294
- case 4: return [2 /*return*/];
295
- }
296
- });
297
- });
298
- };
299
- ContentMethods.prototype.saveContentItems = function (contentItems, guid, locale) {
300
- return __awaiter(this, void 0, void 0, function () {
301
- var apiPath, resp, batchID_8, batch, contentIDs_8, err_9;
302
- var _this = this;
303
- return __generator(this, function (_a) {
304
- switch (_a.label) {
305
- case 0:
306
- _a.trys.push([0, 3, , 4]);
307
- apiPath = "".concat(locale, "/item/multi");
308
- return [4 /*yield*/, this._clientInstance.executePost(apiPath, guid, this._options.token, contentItems)];
309
- case 1:
310
- resp = _a.sent();
311
- batchID_8 = resp.data;
312
- return [4 /*yield*/, this._batchMethods.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
313
- switch (_a.label) {
314
- case 0: return [4 /*yield*/, this._batchMethods.getBatch(batchID_8, guid)];
315
- case 1: return [2 /*return*/, _a.sent()];
316
- }
317
- }); }); })];
318
- case 2:
319
- batch = _a.sent();
320
- contentIDs_8 = [];
321
- batch.items.forEach(function (element) { return contentIDs_8.push(element.itemID); });
322
- return [2 /*return*/, contentIDs_8];
323
- case 3:
324
- err_9 = _a.sent();
325
- throw new exception_1.Exception('Unable to create contents.', err_9);
326
- case 4: return [2 /*return*/];
327
- }
328
- });
329
- });
330
- };
331
- ContentMethods.prototype.getContentItems = function (referenceName, guid, locale, filter, fields, sortDirection, sortField, take, skip) {
332
- if (filter === void 0) { filter = ''; }
333
- if (fields === void 0) { fields = null; }
334
- if (sortDirection === void 0) { sortDirection = null; }
335
- if (sortField === void 0) { sortField = null; }
336
- if (take === void 0) { take = 50; }
337
- if (skip === void 0) { skip = 0; }
338
- return __awaiter(this, void 0, void 0, function () {
339
- var apiPath, resp, err_10;
340
- return __generator(this, function (_a) {
341
- switch (_a.label) {
342
- case 0:
343
- _a.trys.push([0, 2, , 3]);
344
- apiPath = "".concat(locale, "/list/").concat(referenceName, "?filter=").concat(filter, "&fields=").concat(fields, "&sortDirection=").concat(sortDirection, "&sortField=").concat(sortField, "&take=").concat(take, "&skip=").concat(skip);
345
- return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
346
- case 1:
347
- resp = _a.sent();
348
- return [2 /*return*/, resp.data];
349
- case 2:
350
- err_10 = _a.sent();
351
- throw new exception_1.Exception("Unable retreive the content details for reference name: ".concat(referenceName), err_10);
352
- case 3: return [2 /*return*/];
353
- }
354
- });
355
- });
356
- };
357
- return ContentMethods;
358
- }());
359
- exports.ContentMethods = ContentMethods;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.ContentMethods = void 0;
40
+ var clientInstance_1 = require("./clientInstance");
41
+ var batchMethods_1 = require("./batchMethods");
42
+ var exception_1 = require("../models/exception");
43
+ var ContentMethods = /** @class */ (function () {
44
+ function ContentMethods(options) {
45
+ this._options = options;
46
+ this._clientInstance = new clientInstance_1.ClientInstance(options);
47
+ this._batchMethods = new batchMethods_1.BatchMethods(this._options);
48
+ }
49
+ ContentMethods.prototype.getContentItem = function (contentID, guid, locale) {
50
+ return __awaiter(this, void 0, void 0, function () {
51
+ var apiPath, resp, err_1;
52
+ return __generator(this, function (_a) {
53
+ switch (_a.label) {
54
+ case 0:
55
+ _a.trys.push([0, 2, , 3]);
56
+ apiPath = locale + "/item/" + contentID;
57
+ return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
58
+ case 1:
59
+ resp = _a.sent();
60
+ return [2 /*return*/, resp.data];
61
+ case 2:
62
+ err_1 = _a.sent();
63
+ throw new exception_1.Exception("Unable to retreive the content for id: " + contentID, err_1);
64
+ case 3: return [2 /*return*/];
65
+ }
66
+ });
67
+ });
68
+ };
69
+ ContentMethods.prototype.publishContent = function (contentID, guid, locale, comments) {
70
+ if (comments === void 0) { comments = null; }
71
+ return __awaiter(this, void 0, void 0, function () {
72
+ var apiPath, resp, batchID_1, batch, contentIDs_1, err_2;
73
+ var _this = this;
74
+ return __generator(this, function (_a) {
75
+ switch (_a.label) {
76
+ case 0:
77
+ _a.trys.push([0, 3, , 4]);
78
+ apiPath = locale + "/item/" + contentID + "/publish?comments=" + comments;
79
+ return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
80
+ case 1:
81
+ resp = _a.sent();
82
+ batchID_1 = resp.data;
83
+ return [4 /*yield*/, this._batchMethods.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
84
+ switch (_a.label) {
85
+ case 0: return [4 /*yield*/, this._batchMethods.getBatch(batchID_1, guid)];
86
+ case 1: return [2 /*return*/, _a.sent()];
87
+ }
88
+ }); }); })];
89
+ case 2:
90
+ batch = _a.sent();
91
+ contentIDs_1 = [];
92
+ batch.items.forEach(function (element) { return contentIDs_1.push(element.itemID); });
93
+ return [2 /*return*/, contentIDs_1];
94
+ case 3:
95
+ err_2 = _a.sent();
96
+ throw new exception_1.Exception("Unable to publish the content for id: " + contentID, err_2);
97
+ case 4: return [2 /*return*/];
98
+ }
99
+ });
100
+ });
101
+ };
102
+ ContentMethods.prototype.unPublishContent = function (contentID, guid, locale, comments) {
103
+ if (comments === void 0) { comments = null; }
104
+ return __awaiter(this, void 0, void 0, function () {
105
+ var apiPath, resp, batchID_2, batch, contentIDs_2, err_3;
106
+ var _this = this;
107
+ return __generator(this, function (_a) {
108
+ switch (_a.label) {
109
+ case 0:
110
+ _a.trys.push([0, 3, , 4]);
111
+ apiPath = locale + "/item/" + contentID + "/unpublish?comments=" + comments;
112
+ return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
113
+ case 1:
114
+ resp = _a.sent();
115
+ batchID_2 = resp.data;
116
+ return [4 /*yield*/, this._batchMethods.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
117
+ switch (_a.label) {
118
+ case 0: return [4 /*yield*/, this._batchMethods.getBatch(batchID_2, guid)];
119
+ case 1: return [2 /*return*/, _a.sent()];
120
+ }
121
+ }); }); })];
122
+ case 2:
123
+ batch = _a.sent();
124
+ contentIDs_2 = [];
125
+ batch.items.forEach(function (element) { return contentIDs_2.push(element.itemID); });
126
+ return [2 /*return*/, contentIDs_2];
127
+ case 3:
128
+ err_3 = _a.sent();
129
+ throw new exception_1.Exception("Unable to un-publish the content for id: " + contentID, err_3);
130
+ case 4: return [2 /*return*/];
131
+ }
132
+ });
133
+ });
134
+ };
135
+ ContentMethods.prototype.contentRequestApproval = function (contentID, guid, locale, comments) {
136
+ if (comments === void 0) { comments = null; }
137
+ return __awaiter(this, void 0, void 0, function () {
138
+ var apiPath, resp, batchID_3, batch, contentIDs_3, err_4;
139
+ var _this = this;
140
+ return __generator(this, function (_a) {
141
+ switch (_a.label) {
142
+ case 0:
143
+ _a.trys.push([0, 3, , 4]);
144
+ apiPath = locale + "/item/" + contentID + "/request-approval?comments=" + comments;
145
+ return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
146
+ case 1:
147
+ resp = _a.sent();
148
+ batchID_3 = resp.data;
149
+ return [4 /*yield*/, this._batchMethods.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
150
+ switch (_a.label) {
151
+ case 0: return [4 /*yield*/, this._batchMethods.getBatch(batchID_3, guid)];
152
+ case 1: return [2 /*return*/, _a.sent()];
153
+ }
154
+ }); }); })];
155
+ case 2:
156
+ batch = _a.sent();
157
+ contentIDs_3 = [];
158
+ batch.items.forEach(function (element) { return contentIDs_3.push(element.itemID); });
159
+ return [2 /*return*/, contentIDs_3];
160
+ case 3:
161
+ err_4 = _a.sent();
162
+ throw new exception_1.Exception("Unable to request approval the content for id: " + contentID, err_4);
163
+ case 4: return [2 /*return*/];
164
+ }
165
+ });
166
+ });
167
+ };
168
+ ContentMethods.prototype.approveContent = function (contentID, guid, locale, comments) {
169
+ if (comments === void 0) { comments = null; }
170
+ return __awaiter(this, void 0, void 0, function () {
171
+ var apiPath, resp, batchID_4, batch, contentIDs_4, err_5;
172
+ var _this = this;
173
+ return __generator(this, function (_a) {
174
+ switch (_a.label) {
175
+ case 0:
176
+ _a.trys.push([0, 3, , 4]);
177
+ apiPath = locale + "/item/" + contentID + "/approve?comments=" + comments;
178
+ return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
179
+ case 1:
180
+ resp = _a.sent();
181
+ batchID_4 = resp.data;
182
+ return [4 /*yield*/, this._batchMethods.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
183
+ switch (_a.label) {
184
+ case 0: return [4 /*yield*/, this._batchMethods.getBatch(batchID_4, guid)];
185
+ case 1: return [2 /*return*/, _a.sent()];
186
+ }
187
+ }); }); })];
188
+ case 2:
189
+ batch = _a.sent();
190
+ contentIDs_4 = [];
191
+ batch.items.forEach(function (element) { return contentIDs_4.push(element.itemID); });
192
+ return [2 /*return*/, contentIDs_4];
193
+ case 3:
194
+ err_5 = _a.sent();
195
+ throw new exception_1.Exception("Unable to approve the content for id: " + contentID, err_5);
196
+ case 4: return [2 /*return*/];
197
+ }
198
+ });
199
+ });
200
+ };
201
+ ContentMethods.prototype.declineContent = function (contentID, guid, locale, comments) {
202
+ if (comments === void 0) { comments = null; }
203
+ return __awaiter(this, void 0, void 0, function () {
204
+ var apiPath, resp, batchID_5, batch, contentIDs_5, err_6;
205
+ var _this = this;
206
+ return __generator(this, function (_a) {
207
+ switch (_a.label) {
208
+ case 0:
209
+ _a.trys.push([0, 3, , 4]);
210
+ apiPath = locale + "/item/" + contentID + "/decline?comments=" + comments;
211
+ return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
212
+ case 1:
213
+ resp = _a.sent();
214
+ batchID_5 = resp.data;
215
+ return [4 /*yield*/, this._batchMethods.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
216
+ switch (_a.label) {
217
+ case 0: return [4 /*yield*/, this._batchMethods.getBatch(batchID_5, guid)];
218
+ case 1: return [2 /*return*/, _a.sent()];
219
+ }
220
+ }); }); })];
221
+ case 2:
222
+ batch = _a.sent();
223
+ contentIDs_5 = [];
224
+ batch.items.forEach(function (element) { return contentIDs_5.push(element.itemID); });
225
+ return [2 /*return*/, contentIDs_5];
226
+ case 3:
227
+ err_6 = _a.sent();
228
+ throw new exception_1.Exception("Unable to decline the content for id: " + contentID, err_6);
229
+ case 4: return [2 /*return*/];
230
+ }
231
+ });
232
+ });
233
+ };
234
+ ContentMethods.prototype.deleteContent = function (contentID, guid, locale, comments) {
235
+ if (comments === void 0) { comments = null; }
236
+ return __awaiter(this, void 0, void 0, function () {
237
+ var apiPath, resp, batchID_6, batch, contentIDs_6, err_7;
238
+ var _this = this;
239
+ return __generator(this, function (_a) {
240
+ switch (_a.label) {
241
+ case 0:
242
+ _a.trys.push([0, 3, , 4]);
243
+ apiPath = locale + "/item/" + contentID + "?comments=" + comments;
244
+ return [4 /*yield*/, this._clientInstance.executeDelete(apiPath, guid, this._options.token)];
245
+ case 1:
246
+ resp = _a.sent();
247
+ batchID_6 = resp.data;
248
+ return [4 /*yield*/, this._batchMethods.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
249
+ switch (_a.label) {
250
+ case 0: return [4 /*yield*/, this._batchMethods.getBatch(batchID_6, guid)];
251
+ case 1: return [2 /*return*/, _a.sent()];
252
+ }
253
+ }); }); })];
254
+ case 2:
255
+ batch = _a.sent();
256
+ contentIDs_6 = [];
257
+ batch.items.forEach(function (element) { return contentIDs_6.push(element.itemID); });
258
+ return [2 /*return*/, contentIDs_6];
259
+ case 3:
260
+ err_7 = _a.sent();
261
+ throw new exception_1.Exception("Unable to delete the content for id: " + contentID, err_7);
262
+ case 4: return [2 /*return*/];
263
+ }
264
+ });
265
+ });
266
+ };
267
+ ContentMethods.prototype.saveContentItem = function (contentItem, guid, locale) {
268
+ return __awaiter(this, void 0, void 0, function () {
269
+ var apiPath, resp, batchID_7, batch, contentIDs_7, err_8;
270
+ var _this = this;
271
+ return __generator(this, function (_a) {
272
+ switch (_a.label) {
273
+ case 0:
274
+ _a.trys.push([0, 3, , 4]);
275
+ apiPath = locale + "/item";
276
+ return [4 /*yield*/, this._clientInstance.executePost(apiPath, guid, this._options.token, contentItem)];
277
+ case 1:
278
+ resp = _a.sent();
279
+ batchID_7 = resp.data;
280
+ return [4 /*yield*/, this._batchMethods.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
281
+ switch (_a.label) {
282
+ case 0: return [4 /*yield*/, this._batchMethods.getBatch(batchID_7, guid)];
283
+ case 1: return [2 /*return*/, _a.sent()];
284
+ }
285
+ }); }); })];
286
+ case 2:
287
+ batch = _a.sent();
288
+ contentIDs_7 = [];
289
+ batch.items.forEach(function (element) { return contentIDs_7.push(element.itemID); });
290
+ return [2 /*return*/, contentIDs_7];
291
+ case 3:
292
+ err_8 = _a.sent();
293
+ throw new exception_1.Exception('Unable to create content.', err_8);
294
+ case 4: return [2 /*return*/];
295
+ }
296
+ });
297
+ });
298
+ };
299
+ ContentMethods.prototype.saveContentItems = function (contentItems, guid, locale) {
300
+ return __awaiter(this, void 0, void 0, function () {
301
+ var apiPath, resp, batchID_8, batch, contentIDs_8, err_9;
302
+ var _this = this;
303
+ return __generator(this, function (_a) {
304
+ switch (_a.label) {
305
+ case 0:
306
+ _a.trys.push([0, 3, , 4]);
307
+ apiPath = locale + "/item/multi";
308
+ return [4 /*yield*/, this._clientInstance.executePost(apiPath, guid, this._options.token, contentItems)];
309
+ case 1:
310
+ resp = _a.sent();
311
+ batchID_8 = resp.data;
312
+ return [4 /*yield*/, this._batchMethods.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
313
+ switch (_a.label) {
314
+ case 0: return [4 /*yield*/, this._batchMethods.getBatch(batchID_8, guid)];
315
+ case 1: return [2 /*return*/, _a.sent()];
316
+ }
317
+ }); }); })];
318
+ case 2:
319
+ batch = _a.sent();
320
+ contentIDs_8 = [];
321
+ batch.items.forEach(function (element) { return contentIDs_8.push(element.itemID); });
322
+ return [2 /*return*/, contentIDs_8];
323
+ case 3:
324
+ err_9 = _a.sent();
325
+ throw new exception_1.Exception('Unable to create contents.', err_9);
326
+ case 4: return [2 /*return*/];
327
+ }
328
+ });
329
+ });
330
+ };
331
+ ContentMethods.prototype.getContentItems = function (referenceName, guid, locale, filter, fields, sortDirection, sortField, take, skip) {
332
+ if (filter === void 0) { filter = ''; }
333
+ if (fields === void 0) { fields = null; }
334
+ if (sortDirection === void 0) { sortDirection = null; }
335
+ if (sortField === void 0) { sortField = null; }
336
+ if (take === void 0) { take = 50; }
337
+ if (skip === void 0) { skip = 0; }
338
+ return __awaiter(this, void 0, void 0, function () {
339
+ var apiPath, resp, err_10;
340
+ return __generator(this, function (_a) {
341
+ switch (_a.label) {
342
+ case 0:
343
+ _a.trys.push([0, 2, , 3]);
344
+ apiPath = locale + "/list/" + referenceName + "?filter=" + filter + "&fields=" + fields + "&sortDirection=" + sortDirection + "&sortField=" + sortField + "&take=" + take + "&skip=" + skip;
345
+ return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
346
+ case 1:
347
+ resp = _a.sent();
348
+ return [2 /*return*/, resp.data];
349
+ case 2:
350
+ err_10 = _a.sent();
351
+ throw new exception_1.Exception("Unable retreive the content details for reference name: " + referenceName, err_10);
352
+ case 3: return [2 /*return*/];
353
+ }
354
+ });
355
+ });
356
+ };
357
+ return ContentMethods;
358
+ }());
359
+ exports.ContentMethods = ContentMethods;