@agility/management-sdk 0.1.1 → 0.1.3

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/README.md +395 -395
  2. package/dist/apiMethods/assetMethods.d.ts +14 -14
  3. package/dist/apiMethods/assetMethods.js +172 -95
  4. package/dist/apiMethods/batchMethods.d.ts +11 -11
  5. package/dist/apiMethods/batchMethods.js +117 -65
  6. package/dist/apiMethods/clientInstance.d.ts +8 -8
  7. package/dist/apiMethods/clientInstance.js +137 -77
  8. package/dist/apiMethods/containerMethods.d.ts +16 -16
  9. package/dist/apiMethods/containerMethods.js +189 -105
  10. package/dist/apiMethods/contentMethods.d.ts +20 -20
  11. package/dist/apiMethods/contentMethods.js +359 -175
  12. package/dist/apiMethods/instanceUserMethods.d.ts +13 -13
  13. package/dist/apiMethods/instanceUserMethods.js +111 -57
  14. package/dist/apiMethods/modelMethods.d.ts +13 -13
  15. package/dist/apiMethods/modelMethods.js +150 -81
  16. package/dist/apiMethods/pageMethods.d.ts +20 -20
  17. package/dist/apiMethods/pageMethods.js +323 -159
  18. package/dist/enums/batchOperationType.d.ts +19 -19
  19. package/dist/enums/batchOperationType.js +23 -23
  20. package/dist/enums/batchState..d.ts +7 -7
  21. package/dist/enums/batchState..js +11 -11
  22. package/dist/index.d.ts +21 -21
  23. package/dist/index.js +33 -37
  24. package/dist/models/batch.d.ts +29 -29
  25. package/dist/models/batch.js +9 -6
  26. package/dist/models/batchItem.d.ts +13 -13
  27. package/dist/models/batchItem.js +9 -6
  28. package/dist/models/container.d.ts +47 -47
  29. package/dist/models/container.js +9 -6
  30. package/dist/models/contentItem.d.ts +37 -37
  31. package/dist/models/contentItem.js +33 -18
  32. package/dist/models/contentViewColumn.d.ts +8 -8
  33. package/dist/models/contentViewColumn.js +9 -6
  34. package/dist/models/exception.d.ts +4 -4
  35. package/dist/models/exception.js +26 -10
  36. package/dist/models/instanceRole.d.ts +7 -7
  37. package/dist/models/instanceRole.js +9 -6
  38. package/dist/models/instanceUser.d.ts +14 -14
  39. package/dist/models/instanceUser.js +9 -6
  40. package/dist/models/media.d.ts +30 -30
  41. package/dist/models/media.js +15 -9
  42. package/dist/models/model.d.ts +30 -30
  43. package/dist/models/model.js +15 -9
  44. package/dist/models/notification.d.ts +13 -13
  45. package/dist/models/notification.js +9 -6
  46. package/dist/models/options.d.ts +10 -10
  47. package/dist/models/options.js +28 -25
  48. package/dist/models/pageItem.d.ts +56 -56
  49. package/dist/models/pageItem.js +39 -21
  50. package/dist/models/sitemap.d.ts +20 -20
  51. package/dist/models/sitemap.js +15 -9
  52. package/dist/models/websiteUser.d.ts +22 -22
  53. package/dist/models/websiteUser.js +15 -9
  54. package/license.txt +20 -20
  55. package/package.json +39 -39
  56. package/tsconfig.json +14 -14
@@ -1,14 +1,14 @@
1
- import { Options } from "../models/options";
2
- import { ClientInstance } from "./clientInstance";
3
- import { AssetMediaList, Media } from "../models/media";
4
- export declare class AssetMethods {
5
- _options: Options;
6
- _clientInstance: ClientInstance;
7
- constructor(options: Options);
8
- deleteFile(mediaID: number): Promise<string>;
9
- moveFile(mediaID: number, newFolder: string): Promise<Media>;
10
- getMediaList(pageSize: number, recordOffset: number): Promise<AssetMediaList>;
11
- getAssetByID(mediaID: number): Promise<Media>;
12
- getAssetByUrl(url: string): Promise<Media>;
13
- upload(formData: FormData, agilityFolderPath: string, groupingID?: number): Promise<Media[]>;
14
- }
1
+ import { Options } from "../models/options";
2
+ import { ClientInstance } from "./clientInstance";
3
+ import { AssetMediaList, Media } from "../models/media";
4
+ export declare class AssetMethods {
5
+ _options: Options;
6
+ _clientInstance: ClientInstance;
7
+ constructor(options: Options);
8
+ deleteFile(mediaID: number): Promise<string>;
9
+ moveFile(mediaID: number, newFolder: string): Promise<Media>;
10
+ getMediaList(pageSize: number, recordOffset: number): Promise<AssetMediaList>;
11
+ getAssetByID(mediaID: number): Promise<Media>;
12
+ getAssetByUrl(url: string): Promise<Media>;
13
+ upload(formData: FormData, agilityFolderPath: string, groupingID?: number): Promise<Media[]>;
14
+ }
@@ -1,95 +1,172 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AssetMethods = void 0;
13
- const clientInstance_1 = require("./clientInstance");
14
- const exception_1 = require("../models/exception");
15
- class AssetMethods {
16
- constructor(options) {
17
- this._options = options;
18
- this._clientInstance = new clientInstance_1.ClientInstance();
19
- }
20
- deleteFile(mediaID) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- try {
23
- let apiPath = `asset/delete/${mediaID}`;
24
- const resp = yield this._clientInstance.executeDelete(apiPath, this._options);
25
- ;
26
- return resp.data;
27
- }
28
- catch (err) {
29
- throw new exception_1.Exception(`Unable to delete the media for mediaID: ${mediaID}`, err);
30
- }
31
- });
32
- }
33
- moveFile(mediaID, newFolder) {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- try {
36
- let folder = encodeURIComponent(newFolder);
37
- let apiPath = `asset/move/${mediaID}?newFolder=${folder}`;
38
- const resp = yield this._clientInstance.executePost(apiPath, this._options, null);
39
- return resp.data;
40
- }
41
- catch (err) {
42
- throw new exception_1.Exception(`Unable to move the media for mediaID: ${mediaID}`, err);
43
- }
44
- });
45
- }
46
- getMediaList(pageSize, recordOffset) {
47
- return __awaiter(this, void 0, void 0, function* () {
48
- try {
49
- let apiPath = `asset/list?pageSize=${pageSize}&recordOffset=${recordOffset}`;
50
- const resp = yield this._clientInstance.executeGet(apiPath, this._options);
51
- return resp.data;
52
- }
53
- catch (err) {
54
- throw new exception_1.Exception(`Unable to retrieve assets for the website.`, err);
55
- }
56
- });
57
- }
58
- getAssetByID(mediaID) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- try {
61
- let apiPath = `asset/${mediaID}`;
62
- const resp = yield this._clientInstance.executeGet(apiPath, this._options);
63
- return resp.data;
64
- }
65
- catch (err) {
66
- throw new exception_1.Exception(`Unable to retrieve asset for mediaID ${mediaID}`, err);
67
- }
68
- });
69
- }
70
- getAssetByUrl(url) {
71
- return __awaiter(this, void 0, void 0, function* () {
72
- try {
73
- let apiPath = `asset?url=${url}`;
74
- const resp = yield this._clientInstance.executeGet(apiPath, this._options);
75
- return resp.data;
76
- }
77
- catch (err) {
78
- throw new exception_1.Exception(`Unable to retrieve asset for url ${url}`, err);
79
- }
80
- });
81
- }
82
- upload(formData, agilityFolderPath, groupingID = -1) {
83
- return __awaiter(this, void 0, void 0, function* () {
84
- try {
85
- let apiPath = `asset/upload?folderPath=${agilityFolderPath}&groupingID=${groupingID}`;
86
- const resp = yield this._clientInstance.executePost(apiPath, this._options, formData);
87
- return resp.data;
88
- }
89
- catch (err) {
90
- throw new exception_1.Exception(`Unable to upload media.`, err);
91
- }
92
- });
93
- }
94
- }
95
- exports.AssetMethods = AssetMethods;
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.AssetMethods = void 0;
40
+ var clientInstance_1 = require("./clientInstance");
41
+ var exception_1 = require("../models/exception");
42
+ var AssetMethods = /** @class */ (function () {
43
+ function AssetMethods(options) {
44
+ this._options = options;
45
+ this._clientInstance = new clientInstance_1.ClientInstance();
46
+ }
47
+ AssetMethods.prototype.deleteFile = function (mediaID) {
48
+ return __awaiter(this, void 0, void 0, function () {
49
+ var apiPath, resp, err_1;
50
+ return __generator(this, function (_a) {
51
+ switch (_a.label) {
52
+ case 0:
53
+ _a.trys.push([0, 2, , 3]);
54
+ apiPath = "asset/delete/" + mediaID;
55
+ return [4 /*yield*/, this._clientInstance.executeDelete(apiPath, this._options)];
56
+ case 1:
57
+ resp = _a.sent();
58
+ ;
59
+ return [2 /*return*/, resp.data];
60
+ case 2:
61
+ err_1 = _a.sent();
62
+ throw new exception_1.Exception("Unable to delete the media for mediaID: " + mediaID, err_1);
63
+ case 3: return [2 /*return*/];
64
+ }
65
+ });
66
+ });
67
+ };
68
+ AssetMethods.prototype.moveFile = function (mediaID, newFolder) {
69
+ return __awaiter(this, void 0, void 0, function () {
70
+ var folder, apiPath, resp, err_2;
71
+ return __generator(this, function (_a) {
72
+ switch (_a.label) {
73
+ case 0:
74
+ _a.trys.push([0, 2, , 3]);
75
+ folder = encodeURIComponent(newFolder);
76
+ apiPath = "asset/move/" + mediaID + "?newFolder=" + folder;
77
+ return [4 /*yield*/, this._clientInstance.executePost(apiPath, this._options, null)];
78
+ case 1:
79
+ resp = _a.sent();
80
+ return [2 /*return*/, resp.data];
81
+ case 2:
82
+ err_2 = _a.sent();
83
+ throw new exception_1.Exception("Unable to move the media for mediaID: " + mediaID, err_2);
84
+ case 3: return [2 /*return*/];
85
+ }
86
+ });
87
+ });
88
+ };
89
+ AssetMethods.prototype.getMediaList = function (pageSize, recordOffset) {
90
+ return __awaiter(this, void 0, void 0, function () {
91
+ var apiPath, resp, err_3;
92
+ return __generator(this, function (_a) {
93
+ switch (_a.label) {
94
+ case 0:
95
+ _a.trys.push([0, 2, , 3]);
96
+ apiPath = "asset/list?pageSize=" + pageSize + "&recordOffset=" + recordOffset;
97
+ return [4 /*yield*/, this._clientInstance.executeGet(apiPath, this._options)];
98
+ case 1:
99
+ resp = _a.sent();
100
+ return [2 /*return*/, resp.data];
101
+ case 2:
102
+ err_3 = _a.sent();
103
+ throw new exception_1.Exception("Unable to retrieve assets for the website.", err_3);
104
+ case 3: return [2 /*return*/];
105
+ }
106
+ });
107
+ });
108
+ };
109
+ AssetMethods.prototype.getAssetByID = function (mediaID) {
110
+ return __awaiter(this, void 0, void 0, function () {
111
+ var apiPath, resp, err_4;
112
+ return __generator(this, function (_a) {
113
+ switch (_a.label) {
114
+ case 0:
115
+ _a.trys.push([0, 2, , 3]);
116
+ apiPath = "asset/" + mediaID;
117
+ return [4 /*yield*/, this._clientInstance.executeGet(apiPath, this._options)];
118
+ case 1:
119
+ resp = _a.sent();
120
+ return [2 /*return*/, resp.data];
121
+ case 2:
122
+ err_4 = _a.sent();
123
+ throw new exception_1.Exception("Unable to retrieve asset for mediaID " + mediaID, err_4);
124
+ case 3: return [2 /*return*/];
125
+ }
126
+ });
127
+ });
128
+ };
129
+ AssetMethods.prototype.getAssetByUrl = function (url) {
130
+ return __awaiter(this, void 0, void 0, function () {
131
+ var apiPath, resp, err_5;
132
+ return __generator(this, function (_a) {
133
+ switch (_a.label) {
134
+ case 0:
135
+ _a.trys.push([0, 2, , 3]);
136
+ apiPath = "asset?url=" + url;
137
+ return [4 /*yield*/, this._clientInstance.executeGet(apiPath, this._options)];
138
+ case 1:
139
+ resp = _a.sent();
140
+ return [2 /*return*/, resp.data];
141
+ case 2:
142
+ err_5 = _a.sent();
143
+ throw new exception_1.Exception("Unable to retrieve asset for url " + url, err_5);
144
+ case 3: return [2 /*return*/];
145
+ }
146
+ });
147
+ });
148
+ };
149
+ AssetMethods.prototype.upload = function (formData, agilityFolderPath, groupingID) {
150
+ if (groupingID === void 0) { groupingID = -1; }
151
+ return __awaiter(this, void 0, void 0, function () {
152
+ var apiPath, resp, err_6;
153
+ return __generator(this, function (_a) {
154
+ switch (_a.label) {
155
+ case 0:
156
+ _a.trys.push([0, 2, , 3]);
157
+ apiPath = "asset/upload?folderPath=" + agilityFolderPath + "&groupingID=" + groupingID;
158
+ return [4 /*yield*/, this._clientInstance.executePost(apiPath, this._options, formData)];
159
+ case 1:
160
+ resp = _a.sent();
161
+ return [2 /*return*/, resp.data];
162
+ case 2:
163
+ err_6 = _a.sent();
164
+ throw new exception_1.Exception("Unable to upload media.", err_6);
165
+ case 3: return [2 /*return*/];
166
+ }
167
+ });
168
+ });
169
+ };
170
+ return AssetMethods;
171
+ }());
172
+ exports.AssetMethods = AssetMethods;
@@ -1,11 +1,11 @@
1
- import { Options } from "../models/options";
2
- import { ClientInstance } from "./clientInstance";
3
- import { Batch } from "../models/batch";
4
- export declare class BatchMethods {
5
- _options: Options;
6
- _clientInstance: ClientInstance;
7
- constructor(options: Options);
8
- getBatch(batchID: number): Promise<Batch>;
9
- Retry(method: Function): Promise<Batch>;
10
- delay(ms: number): Promise<unknown>;
11
- }
1
+ import { Options } from "../models/options";
2
+ import { ClientInstance } from "./clientInstance";
3
+ import { Batch } from "../models/batch";
4
+ export declare class BatchMethods {
5
+ _options: Options;
6
+ _clientInstance: ClientInstance;
7
+ constructor(options: Options);
8
+ getBatch(batchID: number): Promise<Batch>;
9
+ Retry(method: Function): Promise<Batch>;
10
+ delay(ms: number): Promise<unknown>;
11
+ }
@@ -1,65 +1,117 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- 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) {
18
- this._options = options;
19
- this._clientInstance = new clientInstance_1.ClientInstance();
20
- }
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
- }
31
- });
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 {
46
- --retryCount;
47
- if (--retryCount <= 0) {
48
- throw new Error('Timeout exceeded but operation still in progress. Please check the Batches page in the Agility Content Manager app.');
49
- }
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.');
55
- }
56
- }
57
- });
58
- }
59
- delay(ms) {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- return new Promise(resolve => setTimeout(resolve, ms));
62
- });
63
- }
64
- }
65
- exports.BatchMethods = BatchMethods;
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.BatchMethods = void 0;
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) {
45
+ this._options = options;
46
+ this._clientInstance = new clientInstance_1.ClientInstance();
47
+ }
48
+ BatchMethods.prototype.getBatch = function (batchID) {
49
+ return __awaiter(this, void 0, void 0, function () {
50
+ var apiPath, resp, err_1;
51
+ return __generator(this, function (_a) {
52
+ switch (_a.label) {
53
+ case 0:
54
+ _a.trys.push([0, 2, , 3]);
55
+ apiPath = "batch/" + batchID;
56
+ return [4 /*yield*/, this._clientInstance.executeGet(apiPath, this._options)];
57
+ case 1:
58
+ resp = _a.sent();
59
+ return [2 /*return*/, resp.data];
60
+ case 2:
61
+ err_1 = _a.sent();
62
+ throw new exception_1.Exception("Unable to retreive the batch for id: " + batchID, err_1);
63
+ case 3: return [2 /*return*/];
64
+ }
65
+ });
66
+ });
67
+ };
68
+ BatchMethods.prototype.Retry = function (method) {
69
+ return __awaiter(this, void 0, void 0, function () {
70
+ var retryCount, duration, batch, err_2;
71
+ return __generator(this, function (_a) {
72
+ switch (_a.label) {
73
+ case 0:
74
+ retryCount = this._options.retryCount;
75
+ duration = this._options.duration;
76
+ if (retryCount <= 0)
77
+ throw new Error('Number of retries has been exhausted.');
78
+ _a.label = 1;
79
+ case 1:
80
+ if (!true) return [3 /*break*/, 9];
81
+ _a.label = 2;
82
+ case 2:
83
+ _a.trys.push([2, 7, , 8]);
84
+ return [4 /*yield*/, method()];
85
+ case 3:
86
+ batch = _a.sent();
87
+ if (!(batch.batchState === batchState_1.BatchState.Processed)) return [3 /*break*/, 4];
88
+ return [2 /*return*/, batch];
89
+ case 4:
90
+ --retryCount;
91
+ if (--retryCount <= 0) {
92
+ throw new Error('Timeout exceeded but operation still in progress. Please check the Batches page in the Agility Content Manager app.');
93
+ }
94
+ return [4 /*yield*/, this.delay(duration)];
95
+ case 5:
96
+ _a.sent();
97
+ _a.label = 6;
98
+ case 6: return [3 /*break*/, 8];
99
+ case 7:
100
+ err_2 = _a.sent();
101
+ throw new Error('Timeout exceeded but operation still in progress. Please check the Batches page in the Agility Content Manager app.');
102
+ case 8: return [3 /*break*/, 1];
103
+ case 9: return [2 /*return*/];
104
+ }
105
+ });
106
+ });
107
+ };
108
+ BatchMethods.prototype.delay = function (ms) {
109
+ return __awaiter(this, void 0, void 0, function () {
110
+ return __generator(this, function (_a) {
111
+ return [2 /*return*/, new Promise(function (resolve) { return setTimeout(resolve, ms); })];
112
+ });
113
+ });
114
+ };
115
+ return BatchMethods;
116
+ }());
117
+ exports.BatchMethods = BatchMethods;
@@ -1,8 +1,8 @@
1
- import { AxiosInstance } from 'axios';
2
- import { Options } from "../models/options";
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>>;
8
- }
1
+ import { AxiosInstance } from 'axios';
2
+ import { Options } from "../models/options";
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>>;
8
+ }