@agility/management-sdk 0.1.2 → 0.1.4-beta.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.
Files changed (251) hide show
  1. package/.cursor/api-documentation-manifest.md +275 -0
  2. package/.cursor/api-functions-analysis.md +111 -0
  3. package/.cursor/docs-final-check.md +269 -0
  4. package/.cursor/manifest.md +153 -0
  5. package/.env +92 -0
  6. package/README.md +219 -352
  7. package/dist/apiClient.d.ts +86 -0
  8. package/dist/apiClient.js +229 -0
  9. package/dist/apiClient.js.map +1 -0
  10. package/dist/apiMethods/assetMethods.d.ts +28 -6
  11. package/dist/apiMethods/assetMethods.js +346 -74
  12. package/dist/apiMethods/assetMethods.js.map +1 -0
  13. package/dist/apiMethods/authMethods.d.ts +239 -0
  14. package/dist/apiMethods/authMethods.js +604 -0
  15. package/dist/apiMethods/batchMethods.d.ts +32 -1
  16. package/dist/apiMethods/batchMethods.js +324 -42
  17. package/dist/apiMethods/batchMethods.js.map +1 -0
  18. package/dist/apiMethods/clientInstance.d.ts +58 -4
  19. package/dist/apiMethods/clientInstance.js +383 -56
  20. package/dist/apiMethods/clientInstance.js.map +1 -0
  21. package/dist/apiMethods/containerMethods.d.ts +15 -7
  22. package/dist/apiMethods/containerMethods.js +199 -83
  23. package/dist/apiMethods/containerMethods.js.map +1 -0
  24. package/dist/apiMethods/contentMethods.d.ts +17 -10
  25. package/dist/apiMethods/contentMethods.js +432 -149
  26. package/dist/apiMethods/contentMethods.js.map +1 -0
  27. package/dist/apiMethods/instanceMethods.d.ts +9 -0
  28. package/dist/apiMethods/instanceMethods.js +69 -0
  29. package/dist/apiMethods/instanceMethods.js.map +1 -0
  30. package/dist/apiMethods/instanceUserMethods.d.ts +3 -3
  31. package/dist/apiMethods/instanceUserMethods.js +93 -39
  32. package/dist/apiMethods/instanceUserMethods.js.map +1 -0
  33. package/dist/apiMethods/modelMethods.d.ts +6 -5
  34. package/dist/apiMethods/modelMethods.js +150 -61
  35. package/dist/apiMethods/modelMethods.js.map +1 -0
  36. package/dist/apiMethods/pageMethods.d.ts +21 -9
  37. package/dist/apiMethods/pageMethods.js +500 -134
  38. package/dist/apiMethods/pageMethods.js.map +1 -0
  39. package/dist/apiMethods/serverUserMethods.d.ts +10 -0
  40. package/dist/apiMethods/serverUserMethods.js +89 -0
  41. package/dist/apiMethods/serverUserMethods.js.map +1 -0
  42. package/dist/apiMethods/webhookMethods.d.ts +12 -0
  43. package/dist/apiMethods/webhookMethods.js +131 -0
  44. package/dist/apiMethods/webhookMethods.js.map +1 -0
  45. package/dist/enums/assetGroupingType.d.ts +3 -0
  46. package/dist/enums/assetGroupingType.js +7 -0
  47. package/dist/enums/assetGroupingType.js.map +1 -0
  48. package/dist/enums/batchItemType.d.ts +7 -0
  49. package/dist/enums/batchItemType.js +11 -0
  50. package/dist/enums/batchOperationType.js +1 -1
  51. package/dist/enums/batchOperationType.js.map +1 -0
  52. package/dist/enums/batchState..js +1 -1
  53. package/dist/enums/batchState.d.ts +7 -0
  54. package/dist/enums/batchState.js +12 -0
  55. package/dist/enums/batchState.js.map +1 -0
  56. package/dist/enums/pageItemTemplateType.d.ts +4 -0
  57. package/dist/enums/pageItemTemplateType.js +8 -0
  58. package/dist/enums/pageItemTemplateType.js.map +1 -0
  59. package/dist/enums/workflowOperationType.d.ts +26 -0
  60. package/dist/enums/workflowOperationType.js +30 -0
  61. package/dist/errors/exception.d.ts +4 -0
  62. package/dist/errors/exception.js +11 -0
  63. package/dist/errors/exception.js.map +1 -0
  64. package/dist/index.d.ts +41 -9
  65. package/dist/index.js +48 -10
  66. package/dist/index.js.map +1 -0
  67. package/dist/models/assetContainer.d.ts +7 -0
  68. package/dist/models/assetContainer.js +9 -0
  69. package/dist/models/assetGalleries.d.ts +5 -0
  70. package/dist/models/assetGalleries.js +9 -0
  71. package/dist/models/assetMediaGrouping.d.ts +17 -0
  72. package/dist/models/assetMediaGrouping.js +9 -0
  73. package/dist/models/assetMediaGroupingMetaData.d.ts +4 -0
  74. package/dist/models/assetMediaGroupingMetaData.js +9 -0
  75. package/dist/models/authTokens.d.ts +73 -0
  76. package/dist/models/authTokens.js +2 -0
  77. package/dist/models/batch.js +5 -2
  78. package/dist/models/batchItem.d.ts +1 -0
  79. package/dist/models/batchItem.js +5 -2
  80. package/dist/models/batchRequests.d.ts +67 -0
  81. package/dist/models/batchRequests.js +2 -0
  82. package/dist/models/batchTypes.d.ts +34 -0
  83. package/dist/models/batchTypes.js +2 -0
  84. package/dist/models/container.d.ts +2 -1
  85. package/dist/models/container.js +5 -2
  86. package/dist/models/contentDefinitionTypeID.d.ts +17 -0
  87. package/dist/models/contentDefinitionTypeID.js +21 -0
  88. package/dist/models/contentItem.js +25 -10
  89. package/dist/models/contentItemHistory.d.ts +20 -0
  90. package/dist/models/contentItemHistory.js +15 -0
  91. package/dist/models/contentListFilterModel.d.ts +26 -0
  92. package/dist/models/contentListFilterModel.js +33 -0
  93. package/dist/models/contentSectionDefaultModule.d.ts +7 -0
  94. package/dist/models/contentSectionDefaultModule.js +9 -0
  95. package/dist/models/contentSectionDefinition.d.ts +35 -0
  96. package/dist/models/contentSectionDefinition.js +9 -0
  97. package/dist/models/contentViewColumn.js +5 -2
  98. package/dist/models/exception.js +23 -5
  99. package/dist/models/instanceRole.js +5 -2
  100. package/dist/models/instanceUser.js +5 -2
  101. package/dist/models/itemComments.d.ts +14 -0
  102. package/dist/models/itemComments.js +15 -0
  103. package/dist/models/listParams.d.ts +9 -0
  104. package/dist/models/listParams.js +16 -0
  105. package/dist/models/locales.d.ts +3 -0
  106. package/dist/models/locales.js +30 -0
  107. package/dist/models/media.js +10 -4
  108. package/dist/models/model.js +10 -4
  109. package/dist/models/notification.js +5 -2
  110. package/dist/models/options.d.ts +2 -5
  111. package/dist/models/options.js +4 -20
  112. package/dist/models/pageHistory.d.ts +21 -0
  113. package/dist/models/pageHistory.js +15 -0
  114. package/dist/models/pageItem.js +30 -12
  115. package/dist/models/pageModel.d.ts +14 -0
  116. package/dist/models/pageModel.js +9 -0
  117. package/dist/models/serverUser.d.ts +21 -0
  118. package/dist/models/serverUser.js +9 -0
  119. package/dist/models/sharedModule.d.ts +7 -0
  120. package/dist/models/sharedModule.js +9 -0
  121. package/dist/models/sitemap.js +10 -4
  122. package/dist/models/webhook.d.ts +9 -0
  123. package/dist/models/webhook.js +9 -0
  124. package/dist/models/websiteListing.d.ts +16 -0
  125. package/dist/models/websiteListing.js +9 -0
  126. package/dist/models/websiteUser.js +10 -4
  127. package/dist/tests/authHelper.d.ts +2 -0
  128. package/dist/tests/authHelper.js +14 -0
  129. package/dist/tests/authHelper.js.map +1 -0
  130. package/dist/tests/config/apiClient.config.d.ts +16 -0
  131. package/dist/tests/config/apiClient.config.js +84 -0
  132. package/dist/tests/config/apiClient.config.js.map +1 -0
  133. package/dist/tests/config/test.config.d.ts +24 -0
  134. package/dist/tests/config/test.config.js +47 -0
  135. package/dist/tests/config/test.config.js.map +1 -0
  136. package/dist/tokenStorage.d.ts +72 -0
  137. package/dist/tokenStorage.js +366 -0
  138. package/dist/types/apiResponse.d.ts +13 -0
  139. package/dist/types/apiResponse.js +3 -0
  140. package/dist/types/apiResponse.js.map +1 -0
  141. package/dist/types/assetContainer.d.ts +7 -0
  142. package/dist/types/assetContainer.js +3 -0
  143. package/dist/types/assetContainer.js.map +1 -0
  144. package/dist/types/assetGalleries.d.ts +5 -0
  145. package/dist/types/assetGalleries.js +3 -0
  146. package/dist/types/assetGalleries.js.map +1 -0
  147. package/dist/types/assetMediaGrouping.d.ts +17 -0
  148. package/dist/types/assetMediaGrouping.js +3 -0
  149. package/dist/types/assetMediaGrouping.js.map +1 -0
  150. package/dist/types/assetMediaGroupingMetaData.d.ts +4 -0
  151. package/dist/types/assetMediaGroupingMetaData.js +3 -0
  152. package/dist/types/assetMediaGroupingMetaData.js.map +1 -0
  153. package/dist/types/batch.d.ts +29 -0
  154. package/dist/types/batch.js +3 -0
  155. package/dist/types/batch.js.map +1 -0
  156. package/dist/types/batchItem.d.ts +13 -0
  157. package/dist/types/batchItem.js +3 -0
  158. package/dist/types/batchItem.js.map +1 -0
  159. package/dist/types/container.d.ts +47 -0
  160. package/dist/types/container.js +3 -0
  161. package/dist/types/container.js.map +1 -0
  162. package/dist/types/contentItem.d.ts +37 -0
  163. package/dist/types/contentItem.js +3 -0
  164. package/dist/types/contentItem.js.map +1 -0
  165. package/dist/types/contentItemHistory.d.ts +20 -0
  166. package/dist/types/contentItemHistory.js +3 -0
  167. package/dist/types/contentItemHistory.js.map +1 -0
  168. package/dist/types/contentListFilterModel.d.ts +26 -0
  169. package/dist/types/contentListFilterModel.js +3 -0
  170. package/dist/types/contentListFilterModel.js.map +1 -0
  171. package/dist/types/contentSectionDefaultModule.d.ts +7 -0
  172. package/dist/types/contentSectionDefaultModule.js +3 -0
  173. package/dist/types/contentSectionDefaultModule.js.map +1 -0
  174. package/dist/types/contentSectionDefinition.d.ts +35 -0
  175. package/dist/types/contentSectionDefinition.js +3 -0
  176. package/dist/types/contentSectionDefinition.js.map +1 -0
  177. package/dist/types/contentViewColumn.d.ts +8 -0
  178. package/dist/types/contentViewColumn.js +3 -0
  179. package/dist/types/contentViewColumn.js.map +1 -0
  180. package/dist/types/instanceRole.d.ts +7 -0
  181. package/dist/types/instanceRole.js +3 -0
  182. package/dist/types/instanceRole.js.map +1 -0
  183. package/dist/types/instanceUser.d.ts +14 -0
  184. package/dist/types/instanceUser.js +3 -0
  185. package/dist/types/instanceUser.js.map +1 -0
  186. package/dist/types/itemComments.d.ts +14 -0
  187. package/dist/types/itemComments.js +3 -0
  188. package/dist/types/itemComments.js.map +1 -0
  189. package/dist/types/listParams.d.ts +9 -0
  190. package/dist/types/listParams.js +3 -0
  191. package/dist/types/listParams.js.map +1 -0
  192. package/dist/types/locales.d.ts +1 -0
  193. package/dist/types/locales.js +3 -0
  194. package/dist/types/locales.js.map +1 -0
  195. package/dist/types/media.d.ts +30 -0
  196. package/dist/types/media.js +3 -0
  197. package/dist/types/media.js.map +1 -0
  198. package/dist/types/model.d.ts +30 -0
  199. package/dist/types/model.js +3 -0
  200. package/dist/types/model.js.map +1 -0
  201. package/dist/types/notification.d.ts +13 -0
  202. package/dist/types/notification.js +3 -0
  203. package/dist/types/notification.js.map +1 -0
  204. package/dist/types/options.d.ts +7 -0
  205. package/dist/types/options.js +3 -0
  206. package/dist/types/options.js.map +1 -0
  207. package/dist/types/pageHistory.d.ts +21 -0
  208. package/dist/types/pageHistory.js +3 -0
  209. package/dist/types/pageHistory.js.map +1 -0
  210. package/dist/types/pageItem.d.ts +56 -0
  211. package/dist/types/pageItem.js +3 -0
  212. package/dist/types/pageItem.js.map +1 -0
  213. package/dist/types/pageModel.d.ts +14 -0
  214. package/dist/types/pageModel.js +3 -0
  215. package/dist/types/pageModel.js.map +1 -0
  216. package/dist/types/serverUser.d.ts +21 -0
  217. package/dist/types/serverUser.js +3 -0
  218. package/dist/types/serverUser.js.map +1 -0
  219. package/dist/types/sharedModule.d.ts +7 -0
  220. package/dist/types/sharedModule.js +3 -0
  221. package/dist/types/sharedModule.js.map +1 -0
  222. package/dist/types/sitemap.d.ts +20 -0
  223. package/dist/types/sitemap.js +3 -0
  224. package/dist/types/sitemap.js.map +1 -0
  225. package/dist/types/tokenResponseData.d.ts +10 -0
  226. package/dist/types/tokenResponseData.js +3 -0
  227. package/dist/types/tokenResponseData.js.map +1 -0
  228. package/dist/types/webhook.d.ts +9 -0
  229. package/dist/types/webhook.js +3 -0
  230. package/dist/types/webhook.js.map +1 -0
  231. package/dist/types/websiteListing.d.ts +16 -0
  232. package/dist/types/websiteListing.js +3 -0
  233. package/dist/types/websiteListing.js.map +1 -0
  234. package/dist/types/websiteUser.d.ts +22 -0
  235. package/dist/types/websiteUser.js +3 -0
  236. package/dist/types/websiteUser.js.map +1 -0
  237. package/docs/asset-methods.md +382 -0
  238. package/docs/auth.md +594 -0
  239. package/docs/batch-methods.md +244 -0
  240. package/docs/cicd.md +607 -0
  241. package/docs/container-methods.md +268 -0
  242. package/docs/content-methods.md +423 -0
  243. package/docs/instance-methods.md +105 -0
  244. package/docs/instance-user-methods.md +231 -0
  245. package/docs/model-methods.md +434 -0
  246. package/docs/multi-instance-operations.md +192 -0
  247. package/docs/page-methods.md +671 -0
  248. package/docs/server-user-methods.md +280 -0
  249. package/docs/webhook-methods.md +452 -0
  250. package/package.json +14 -10
  251. package/tsconfig.json +2 -2
@@ -8,58 +8,340 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["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 (g && (g = 0, op[0] && (_ = 0)), _) 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
+ };
11
38
  Object.defineProperty(exports, "__esModule", { value: true });
12
39
  exports.BatchMethods = void 0;
13
- const clientInstance_1 = require("./clientInstance");
14
- const batchState_1 = require("../enums/batchState.");
15
- const exception_1 = require("../models/exception");
16
- class BatchMethods {
17
- constructor(options) {
40
+ var clientInstance_1 = require("./clientInstance");
41
+ var batchState_1 = require("../enums/batchState.");
42
+ var exception_1 = require("../models/exception");
43
+ var BatchMethods = /** @class */ (function () {
44
+ function BatchMethods(options) {
18
45
  this._options = options;
19
- this._clientInstance = new clientInstance_1.ClientInstance();
46
+ this._clientInstance = new clientInstance_1.ClientInstance(this._options);
20
47
  }
21
- getBatch(batchID) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- try {
24
- let apiPath = `batch/${batchID}`;
25
- const resp = yield this._clientInstance.executeGet(apiPath, this._options);
26
- return resp.data;
27
- }
28
- catch (err) {
29
- throw new exception_1.Exception(`Unable to retreive the batch for id: ${batchID}`, err);
30
- }
48
+ BatchMethods.prototype.getBatch = function (batchID_1, guid_1) {
49
+ return __awaiter(this, arguments, void 0, function (batchID, guid, expandItems) {
50
+ var apiPath, resp, err_1;
51
+ if (expandItems === void 0) { expandItems = true; }
52
+ return __generator(this, function (_a) {
53
+ switch (_a.label) {
54
+ case 0:
55
+ _a.trys.push([0, 2, , 3]);
56
+ apiPath = "batch/".concat(batchID, "?expandItems=").concat(expandItems);
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 retrieve the batch for id: ".concat(batchID), err_1);
64
+ case 3: return [2 /*return*/];
65
+ }
66
+ });
31
67
  });
32
- }
33
- Retry(method) {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- let retryCount = this._options.retryCount;
36
- let duration = this._options.duration;
37
- if (retryCount <= 0)
38
- throw new Error('Number of retries has been exhausted.');
39
- while (true) {
40
- try {
41
- let batch = yield method();
42
- if (batch.batchState === batchState_1.BatchState.Processed) {
43
- return batch;
44
- }
45
- else {
68
+ };
69
+ BatchMethods.prototype.publishBatch = function (batchID_1, guid_1) {
70
+ return __awaiter(this, arguments, void 0, function (batchID, guid, returnBatchId) {
71
+ var apiPath, resp, resultBatchID_1, err_2;
72
+ var _this = this;
73
+ if (returnBatchId === void 0) { returnBatchId = false; }
74
+ return __generator(this, function (_a) {
75
+ switch (_a.label) {
76
+ case 0:
77
+ _a.trys.push([0, 3, , 4]);
78
+ apiPath = "batch/".concat(batchID, "/publish");
79
+ return [4 /*yield*/, this._clientInstance.executePost(apiPath, guid, this._options.token, null)];
80
+ case 1:
81
+ resp = _a.sent();
82
+ resultBatchID_1 = resp.data;
83
+ // If user wants batchID immediately, return it for custom polling
84
+ if (returnBatchId) {
85
+ return [2 /*return*/, resultBatchID_1];
86
+ }
87
+ // Default behavior: wait for completion and return batch ID
88
+ return [4 /*yield*/, this.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
89
+ switch (_a.label) {
90
+ case 0: return [4 /*yield*/, this.getBatch(resultBatchID_1, guid)];
91
+ case 1: return [2 /*return*/, _a.sent()];
92
+ }
93
+ }); }); })];
94
+ case 2:
95
+ // Default behavior: wait for completion and return batch ID
96
+ _a.sent();
97
+ return [2 /*return*/, resultBatchID_1];
98
+ case 3:
99
+ err_2 = _a.sent();
100
+ throw new exception_1.Exception("Unable to publish the batch with id: ".concat(batchID), err_2);
101
+ case 4: return [2 /*return*/];
102
+ }
103
+ });
104
+ });
105
+ };
106
+ BatchMethods.prototype.unpublishBatch = function (batchID_1, guid_1) {
107
+ return __awaiter(this, arguments, void 0, function (batchID, guid, returnBatchId) {
108
+ var apiPath, resp, resultBatchID_2, err_3;
109
+ var _this = this;
110
+ if (returnBatchId === void 0) { returnBatchId = false; }
111
+ return __generator(this, function (_a) {
112
+ switch (_a.label) {
113
+ case 0:
114
+ _a.trys.push([0, 3, , 4]);
115
+ apiPath = "batch/".concat(batchID, "/unpublish");
116
+ return [4 /*yield*/, this._clientInstance.executePost(apiPath, guid, this._options.token, null)];
117
+ case 1:
118
+ resp = _a.sent();
119
+ resultBatchID_2 = resp.data;
120
+ // If user wants batchID immediately, return it for custom polling
121
+ if (returnBatchId) {
122
+ return [2 /*return*/, resultBatchID_2];
123
+ }
124
+ // Default behavior: wait for completion and return batch ID
125
+ return [4 /*yield*/, this.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
126
+ switch (_a.label) {
127
+ case 0: return [4 /*yield*/, this.getBatch(resultBatchID_2, guid)];
128
+ case 1: return [2 /*return*/, _a.sent()];
129
+ }
130
+ }); }); })];
131
+ case 2:
132
+ // Default behavior: wait for completion and return batch ID
133
+ _a.sent();
134
+ return [2 /*return*/, resultBatchID_2];
135
+ case 3:
136
+ err_3 = _a.sent();
137
+ throw new exception_1.Exception("Unable to unpublish the batch with id: ".concat(batchID), err_3);
138
+ case 4: return [2 /*return*/];
139
+ }
140
+ });
141
+ });
142
+ };
143
+ BatchMethods.prototype.approveBatch = function (batchID_1, guid_1) {
144
+ return __awaiter(this, arguments, void 0, function (batchID, guid, returnBatchId) {
145
+ var apiPath, resp, resultBatchID_3, err_4;
146
+ var _this = this;
147
+ if (returnBatchId === void 0) { returnBatchId = false; }
148
+ return __generator(this, function (_a) {
149
+ switch (_a.label) {
150
+ case 0:
151
+ _a.trys.push([0, 3, , 4]);
152
+ apiPath = "batch/".concat(batchID, "/approve");
153
+ return [4 /*yield*/, this._clientInstance.executePost(apiPath, guid, this._options.token, null)];
154
+ case 1:
155
+ resp = _a.sent();
156
+ resultBatchID_3 = resp.data;
157
+ // If user wants batchID immediately, return it for custom polling
158
+ if (returnBatchId) {
159
+ return [2 /*return*/, resultBatchID_3];
160
+ }
161
+ // Default behavior: wait for completion and return batch ID
162
+ return [4 /*yield*/, this.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
163
+ switch (_a.label) {
164
+ case 0: return [4 /*yield*/, this.getBatch(resultBatchID_3, guid)];
165
+ case 1: return [2 /*return*/, _a.sent()];
166
+ }
167
+ }); }); })];
168
+ case 2:
169
+ // Default behavior: wait for completion and return batch ID
170
+ _a.sent();
171
+ return [2 /*return*/, resultBatchID_3];
172
+ case 3:
173
+ err_4 = _a.sent();
174
+ throw new exception_1.Exception("Unable to approve the batch with id: ".concat(batchID), err_4);
175
+ case 4: return [2 /*return*/];
176
+ }
177
+ });
178
+ });
179
+ };
180
+ BatchMethods.prototype.declineBatch = function (batchID_1, guid_1) {
181
+ return __awaiter(this, arguments, void 0, function (batchID, guid, returnBatchId) {
182
+ var apiPath, resp, resultBatchID_4, err_5;
183
+ var _this = this;
184
+ if (returnBatchId === void 0) { returnBatchId = false; }
185
+ return __generator(this, function (_a) {
186
+ switch (_a.label) {
187
+ case 0:
188
+ _a.trys.push([0, 3, , 4]);
189
+ apiPath = "batch/".concat(batchID, "/decline");
190
+ return [4 /*yield*/, this._clientInstance.executePost(apiPath, guid, this._options.token, null)];
191
+ case 1:
192
+ resp = _a.sent();
193
+ resultBatchID_4 = resp.data;
194
+ // If user wants batchID immediately, return it for custom polling
195
+ if (returnBatchId) {
196
+ return [2 /*return*/, resultBatchID_4];
197
+ }
198
+ // Default behavior: wait for completion and return batch ID
199
+ return [4 /*yield*/, this.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
200
+ switch (_a.label) {
201
+ case 0: return [4 /*yield*/, this.getBatch(resultBatchID_4, guid)];
202
+ case 1: return [2 /*return*/, _a.sent()];
203
+ }
204
+ }); }); })];
205
+ case 2:
206
+ // Default behavior: wait for completion and return batch ID
207
+ _a.sent();
208
+ return [2 /*return*/, resultBatchID_4];
209
+ case 3:
210
+ err_5 = _a.sent();
211
+ throw new exception_1.Exception("Unable to decline the batch with id: ".concat(batchID), err_5);
212
+ case 4: return [2 /*return*/];
213
+ }
214
+ });
215
+ });
216
+ };
217
+ BatchMethods.prototype.requestApprovalBatch = function (batchID_1, guid_1) {
218
+ return __awaiter(this, arguments, void 0, function (batchID, guid, returnBatchId) {
219
+ var apiPath, resp, resultBatchID_5, err_6;
220
+ var _this = this;
221
+ if (returnBatchId === void 0) { returnBatchId = false; }
222
+ return __generator(this, function (_a) {
223
+ switch (_a.label) {
224
+ case 0:
225
+ _a.trys.push([0, 3, , 4]);
226
+ apiPath = "batch/".concat(batchID, "/request-approval");
227
+ return [4 /*yield*/, this._clientInstance.executePost(apiPath, guid, this._options.token, null)];
228
+ case 1:
229
+ resp = _a.sent();
230
+ resultBatchID_5 = resp.data;
231
+ // If user wants batchID immediately, return it for custom polling
232
+ if (returnBatchId) {
233
+ return [2 /*return*/, resultBatchID_5];
234
+ }
235
+ // Default behavior: wait for completion and return batch ID
236
+ return [4 /*yield*/, this.Retry(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
237
+ switch (_a.label) {
238
+ case 0: return [4 /*yield*/, this.getBatch(resultBatchID_5, guid)];
239
+ case 1: return [2 /*return*/, _a.sent()];
240
+ }
241
+ }); }); })];
242
+ case 2:
243
+ // Default behavior: wait for completion and return batch ID
244
+ _a.sent();
245
+ return [2 /*return*/, resultBatchID_5];
246
+ case 3:
247
+ err_6 = _a.sent();
248
+ throw new exception_1.Exception("Unable to request approval for the batch with id: ".concat(batchID), err_6);
249
+ case 4: return [2 /*return*/];
250
+ }
251
+ });
252
+ });
253
+ };
254
+ /**
255
+ * Retrieves all batch-related enum types for developer discovery.
256
+ * This method provides all available enum values with their names,
257
+ * enabling dynamic UI population and client-side validation.
258
+ *
259
+ * @param guid - Current website guid
260
+ * @returns Promise containing all batch enum types
261
+ *
262
+ * @example
263
+ * ```typescript
264
+ * // Get all batch types for UI population
265
+ * const types = await client.batchMethods.getBatchTypes(guid);
266
+ *
267
+ * // Create dropdown options for item types
268
+ * const itemTypeOptions = types.itemTypes.map(type => ({
269
+ * label: type.name,
270
+ * value: type.value
271
+ * }));
272
+ *
273
+ * // Validate operation type
274
+ * const isValidOperation = (value: number) =>
275
+ * types.workflowOperations.some(op => op.value === value);
276
+ * ```
277
+ */
278
+ BatchMethods.prototype.getBatchTypes = function (guid) {
279
+ return __awaiter(this, void 0, void 0, function () {
280
+ var apiPath, resp, err_7;
281
+ return __generator(this, function (_a) {
282
+ switch (_a.label) {
283
+ case 0:
284
+ _a.trys.push([0, 2, , 3]);
285
+ apiPath = "batch/types";
286
+ return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
287
+ case 1:
288
+ resp = _a.sent();
289
+ return [2 /*return*/, resp.data];
290
+ case 2:
291
+ err_7 = _a.sent();
292
+ throw new exception_1.Exception("Unable to retrieve batch types", err_7);
293
+ case 3: return [2 /*return*/];
294
+ }
295
+ });
296
+ });
297
+ };
298
+ BatchMethods.prototype.Retry = function (method) {
299
+ return __awaiter(this, void 0, void 0, function () {
300
+ var retryCount, duration, batch, err_8;
301
+ return __generator(this, function (_a) {
302
+ switch (_a.label) {
303
+ case 0:
304
+ retryCount = this._options.retryCount;
305
+ duration = this._options.duration;
306
+ if (retryCount <= 0)
307
+ throw new Error('Number of retries has been exhausted.');
308
+ _a.label = 1;
309
+ case 1:
310
+ if (!true) return [3 /*break*/, 9];
311
+ _a.label = 2;
312
+ case 2:
313
+ _a.trys.push([2, 7, , 8]);
314
+ return [4 /*yield*/, method()];
315
+ case 3:
316
+ batch = _a.sent();
317
+ if (!(batch.batchState === batchState_1.BatchState.Processed)) return [3 /*break*/, 4];
318
+ return [2 /*return*/, batch];
319
+ case 4:
46
320
  --retryCount;
47
321
  if (--retryCount <= 0) {
48
322
  throw new Error('Timeout exceeded but operation still in progress. Please check the Batches page in the Agility Content Manager app.');
49
323
  }
50
- yield this.delay(duration);
51
- }
52
- }
53
- catch (err) {
54
- throw new Error('Timeout exceeded but operation still in progress. Please check the Batches page in the Agility Content Manager app.');
324
+ return [4 /*yield*/, this.delay(duration)];
325
+ case 5:
326
+ _a.sent();
327
+ _a.label = 6;
328
+ case 6: return [3 /*break*/, 8];
329
+ case 7:
330
+ err_8 = _a.sent();
331
+ throw new Error('Timeout exceeded but operation still in progress. Please check the Batches page in the Agility Content Manager app.');
332
+ case 8: return [3 /*break*/, 1];
333
+ case 9: return [2 /*return*/];
55
334
  }
56
- }
335
+ });
57
336
  });
58
- }
59
- delay(ms) {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- return new Promise(resolve => setTimeout(resolve, ms));
337
+ };
338
+ BatchMethods.prototype.delay = function (ms) {
339
+ return __awaiter(this, void 0, void 0, function () {
340
+ return __generator(this, function (_a) {
341
+ return [2 /*return*/, new Promise(function (resolve) { return setTimeout(resolve, ms); })];
342
+ });
62
343
  });
63
- }
64
- }
344
+ };
345
+ return BatchMethods;
346
+ }());
65
347
  exports.BatchMethods = BatchMethods;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batchMethods.js","sourceRoot":"","sources":["../../src/apiMethods/batchMethods.ts"],"names":[],"mappings":";;;AACA,qDAAkD;AAElD,oDAAiD;AACjD,mDAAgD;AAEhD,MAAa,YAAY;IAIrB,YAAY,OAAgB;QACxB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,eAAe,GAAG,IAAI,+BAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAe,EAAE,IAAY;QACxC,IAAG,CAAC;YACA,IAAI,OAAO,GAAG,SAAS,OAAO,EAAE,CAAC;YACjC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAEvF,OAAO,IAAI,CAAC,IAAa,CAAC;QAC9B,CAAC;QAAC,OAAM,GAAG,EAAC,CAAC;YACT,MAAM,UAAU,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;YAC1D,MAAM,IAAI,qBAAS,CAAC,6BAA6B,EAAE,UAAU,CAAC,CAAC;QACnE,CAAC;IACL,CAAC;IAEC,KAAK,CAAC,KAAK,CAAC,MAAgB;QAC1B,IAAI,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,IAAI,GAAG,CAAC;QACjD,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,IAAI,IAAI,CAAC;QAC9C,IAAG,UAAU,IAAI,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC7D,OAAM,IAAI,EAAC,CAAC;YACR,IAAG,CAAC;gBACA,IAAI,KAAK,GAAG,MAAM,MAAM,EAAW,CAAC;gBACpC,IAAG,KAAK,CAAC,UAAU,KAAK,uBAAU,CAAC,SAAS;oBACzC,KAAK,CAAC,UAAU,KAAK,uBAAU,CAAC,OAAO;oBACvC,UAAU,IAAI,CAAC,EAAC,CAAC;oBAChB,OAAO,KAAK,CAAC;gBACjB,CAAC;qBACG,CAAC;oBACD,EAAE,UAAU,CAAC;oBACb,IAAG,UAAU,IAAI,CAAC,EAAC,CAAC;wBAChB,MAAM,IAAI,KAAK,CAAC,qHAAqH,CAAC,CAAC;oBAC3I,CAAC;oBACD,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;gBAC/B,CAAC;YACL,CAAC;YAAC,OAAM,GAAG,EAAC,CAAC;gBACT,MAAM,IAAI,KAAK,CAAC,qHAAqH,CAAC,CAAC;YAC3I,CAAC;QACL,CAAC;IACH,CAAC;IAEF,KAAK,CAAC,KAAK,CAAC,EAAU;QACnB,OAAO,IAAI,OAAO,CAAE,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAE,CAAC;IAC7D,CAAC;CACJ;AAlDD,oCAkDC"}
@@ -1,8 +1,62 @@
1
1
  import { AxiosInstance } from 'axios';
2
2
  import { Options } from "../models/options";
3
3
  export declare class ClientInstance {
4
- getInstance(options: Options): AxiosInstance;
5
- executeGet(apiPath: string, options: Options): Promise<import("axios").AxiosResponse<any, any>>;
6
- executeDelete(apiPath: string, options: Options): Promise<import("axios").AxiosResponse<any, any>>;
7
- executePost(apiPath: string, options: Options, data: any): Promise<import("axios").AxiosResponse<any, any>>;
4
+ _options: Options;
5
+ private _tokenRefreshHandler?;
6
+ constructor(options: Options);
7
+ /**
8
+ * Set token refresh handler for automatic token refresh on 401 errors
9
+ * @param handler - Function that returns a valid access token or null
10
+ */
11
+ setTokenRefreshHandler(handler: () => Promise<string | null>): void;
12
+ /**
13
+ * Handle token refresh on 401 errors
14
+ * @param error - The error from the API call
15
+ * @param retryCallback - Function to retry the original request
16
+ * @returns Promise with retry result or throws error
17
+ */
18
+ private handleTokenRefresh;
19
+ /**
20
+ * Figure out the Base Url, which can be overriden using options.baseUrl
21
+ *
22
+ * @param {string} guid
23
+ * @returns {string}
24
+ * @memberof ClientInstance
25
+ */
26
+ determineBaseUrl(guid: string): string;
27
+ /**
28
+ * Determine OAuth base URL based on region or custom baseUrl
29
+ * @param region - Optional region code (d, u, c, e, a) or use default
30
+ * @returns OAuth base URL
31
+ */
32
+ determineOAuthBaseUrl(region?: string): string;
33
+ getInstance(guid: string): AxiosInstance;
34
+ getAxiosInstance(guid: string): AxiosInstance;
35
+ /**
36
+ * Get Axios instance for OAuth endpoints
37
+ * @param region - Optional region code for OAuth endpoints
38
+ * @returns Axios instance configured for OAuth endpoints
39
+ */
40
+ getOAuthInstance(region?: string): AxiosInstance;
41
+ executeServerGet(apiPath: string, guid: string, token: string): Promise<any>;
42
+ executeGet(apiPath: string, guid: string, token: string): Promise<any>;
43
+ executeDelete(apiPath: string, guid: string, token: string, data?: any): Promise<any>;
44
+ executePost(apiPath: string, guid: string, token: string, data: any): Promise<any>;
45
+ /**
46
+ * Execute OAuth GET request
47
+ * @param apiPath - API path relative to /oauth
48
+ * @param region - Optional region code
49
+ * @param token - Optional bearer token for authenticated requests
50
+ * @returns Promise with response
51
+ */
52
+ executeOAuthGet(apiPath: string, region?: string, token?: string): Promise<import("axios").AxiosResponse<any, any>>;
53
+ /**
54
+ * Execute OAuth POST request
55
+ * @param apiPath - API path relative to /oauth
56
+ * @param data - Request body data
57
+ * @param region - Optional region code
58
+ * @param token - Optional bearer token for authenticated requests
59
+ * @returns Promise with response
60
+ */
61
+ executeOAuthPost(apiPath: string, data: any, region?: string, token?: string): Promise<import("axios").AxiosResponse<any, any>>;
8
62
  }