@agility/management-sdk 0.1.3 → 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.
- package/.cursor/api-documentation-manifest.md +275 -0
- package/.cursor/api-functions-analysis.md +111 -0
- package/.cursor/docs-final-check.md +269 -0
- package/.cursor/manifest.md +153 -0
- package/.env +92 -0
- package/README.md +219 -352
- package/dist/apiClient.d.ts +86 -0
- package/dist/apiClient.js +229 -0
- package/dist/apiClient.js.map +1 -0
- package/dist/apiMethods/assetMethods.d.ts +28 -6
- package/dist/apiMethods/assetMethods.js +224 -29
- package/dist/apiMethods/assetMethods.js.map +1 -0
- package/dist/apiMethods/authMethods.d.ts +239 -0
- package/dist/apiMethods/authMethods.js +604 -0
- package/dist/apiMethods/batchMethods.d.ts +32 -1
- package/dist/apiMethods/batchMethods.js +241 -11
- package/dist/apiMethods/batchMethods.js.map +1 -0
- package/dist/apiMethods/clientInstance.d.ts +58 -4
- package/dist/apiMethods/clientInstance.js +311 -44
- package/dist/apiMethods/clientInstance.js.map +1 -0
- package/dist/apiMethods/containerMethods.d.ts +15 -7
- package/dist/apiMethods/containerMethods.js +70 -38
- package/dist/apiMethods/containerMethods.js.map +1 -0
- package/dist/apiMethods/contentMethods.d.ts +17 -10
- package/dist/apiMethods/contentMethods.js +169 -70
- package/dist/apiMethods/contentMethods.js.map +1 -0
- package/dist/apiMethods/instanceMethods.d.ts +9 -0
- package/dist/apiMethods/instanceMethods.js +69 -0
- package/dist/apiMethods/instanceMethods.js.map +1 -0
- package/dist/apiMethods/instanceUserMethods.d.ts +3 -3
- package/dist/apiMethods/instanceUserMethods.js +18 -18
- package/dist/apiMethods/instanceUserMethods.js.map +1 -0
- package/dist/apiMethods/modelMethods.d.ts +6 -5
- package/dist/apiMethods/modelMethods.js +46 -26
- package/dist/apiMethods/modelMethods.js.map +1 -0
- package/dist/apiMethods/pageMethods.d.ts +21 -9
- package/dist/apiMethods/pageMethods.js +278 -76
- package/dist/apiMethods/pageMethods.js.map +1 -0
- package/dist/apiMethods/serverUserMethods.d.ts +10 -0
- package/dist/apiMethods/serverUserMethods.js +89 -0
- package/dist/apiMethods/serverUserMethods.js.map +1 -0
- package/dist/apiMethods/webhookMethods.d.ts +12 -0
- package/dist/apiMethods/webhookMethods.js +131 -0
- package/dist/apiMethods/webhookMethods.js.map +1 -0
- package/dist/enums/assetGroupingType.d.ts +3 -0
- package/dist/enums/assetGroupingType.js +7 -0
- package/dist/enums/assetGroupingType.js.map +1 -0
- package/dist/enums/batchItemType.d.ts +7 -0
- package/dist/enums/batchItemType.js +11 -0
- package/dist/enums/batchOperationType.js +1 -1
- package/dist/enums/batchOperationType.js.map +1 -0
- package/dist/enums/batchState..js +1 -1
- package/dist/enums/batchState.d.ts +7 -0
- package/dist/enums/batchState.js +12 -0
- package/dist/enums/batchState.js.map +1 -0
- package/dist/enums/pageItemTemplateType.d.ts +4 -0
- package/dist/enums/pageItemTemplateType.js +8 -0
- package/dist/enums/pageItemTemplateType.js.map +1 -0
- package/dist/enums/workflowOperationType.d.ts +26 -0
- package/dist/enums/workflowOperationType.js +30 -0
- package/dist/errors/exception.d.ts +4 -0
- package/dist/errors/exception.js +11 -0
- package/dist/errors/exception.js.map +1 -0
- package/dist/index.d.ts +41 -9
- package/dist/index.js +48 -10
- package/dist/index.js.map +1 -0
- package/dist/models/assetContainer.d.ts +7 -0
- package/dist/models/assetContainer.js +9 -0
- package/dist/models/assetGalleries.d.ts +5 -0
- package/dist/models/assetGalleries.js +9 -0
- package/dist/models/assetMediaGrouping.d.ts +17 -0
- package/dist/models/assetMediaGrouping.js +9 -0
- package/dist/models/assetMediaGroupingMetaData.d.ts +4 -0
- package/dist/models/assetMediaGroupingMetaData.js +9 -0
- package/dist/models/authTokens.d.ts +73 -0
- package/dist/models/authTokens.js +2 -0
- package/dist/models/batchItem.d.ts +1 -0
- package/dist/models/batchRequests.d.ts +67 -0
- package/dist/models/batchRequests.js +2 -0
- package/dist/models/batchTypes.d.ts +34 -0
- package/dist/models/batchTypes.js +2 -0
- package/dist/models/container.d.ts +2 -1
- package/dist/models/contentDefinitionTypeID.d.ts +17 -0
- package/dist/models/contentDefinitionTypeID.js +21 -0
- package/dist/models/contentItemHistory.d.ts +20 -0
- package/dist/models/contentItemHistory.js +15 -0
- package/dist/models/contentListFilterModel.d.ts +26 -0
- package/dist/models/contentListFilterModel.js +33 -0
- package/dist/models/contentSectionDefaultModule.d.ts +7 -0
- package/dist/models/contentSectionDefaultModule.js +9 -0
- package/dist/models/contentSectionDefinition.d.ts +35 -0
- package/dist/models/contentSectionDefinition.js +9 -0
- package/dist/models/exception.js +2 -0
- package/dist/models/itemComments.d.ts +14 -0
- package/dist/models/itemComments.js +15 -0
- package/dist/models/listParams.d.ts +9 -0
- package/dist/models/listParams.js +16 -0
- package/dist/models/locales.d.ts +3 -0
- package/dist/models/locales.js +30 -0
- package/dist/models/options.d.ts +2 -5
- package/dist/models/options.js +0 -19
- package/dist/models/pageHistory.d.ts +21 -0
- package/dist/models/pageHistory.js +15 -0
- package/dist/models/pageModel.d.ts +14 -0
- package/dist/models/pageModel.js +9 -0
- package/dist/models/serverUser.d.ts +21 -0
- package/dist/models/serverUser.js +9 -0
- package/dist/models/sharedModule.d.ts +7 -0
- package/dist/models/sharedModule.js +9 -0
- package/dist/models/webhook.d.ts +9 -0
- package/dist/models/webhook.js +9 -0
- package/dist/models/websiteListing.d.ts +16 -0
- package/dist/models/websiteListing.js +9 -0
- package/dist/tests/authHelper.d.ts +2 -0
- package/dist/tests/authHelper.js +14 -0
- package/dist/tests/authHelper.js.map +1 -0
- package/dist/tests/config/apiClient.config.d.ts +16 -0
- package/dist/tests/config/apiClient.config.js +84 -0
- package/dist/tests/config/apiClient.config.js.map +1 -0
- package/dist/tests/config/test.config.d.ts +24 -0
- package/dist/tests/config/test.config.js +47 -0
- package/dist/tests/config/test.config.js.map +1 -0
- package/dist/tokenStorage.d.ts +72 -0
- package/dist/tokenStorage.js +366 -0
- package/dist/types/apiResponse.d.ts +13 -0
- package/dist/types/apiResponse.js +3 -0
- package/dist/types/apiResponse.js.map +1 -0
- package/dist/types/assetContainer.d.ts +7 -0
- package/dist/types/assetContainer.js +3 -0
- package/dist/types/assetContainer.js.map +1 -0
- package/dist/types/assetGalleries.d.ts +5 -0
- package/dist/types/assetGalleries.js +3 -0
- package/dist/types/assetGalleries.js.map +1 -0
- package/dist/types/assetMediaGrouping.d.ts +17 -0
- package/dist/types/assetMediaGrouping.js +3 -0
- package/dist/types/assetMediaGrouping.js.map +1 -0
- package/dist/types/assetMediaGroupingMetaData.d.ts +4 -0
- package/dist/types/assetMediaGroupingMetaData.js +3 -0
- package/dist/types/assetMediaGroupingMetaData.js.map +1 -0
- package/dist/types/batch.d.ts +29 -0
- package/dist/types/batch.js +3 -0
- package/dist/types/batch.js.map +1 -0
- package/dist/types/batchItem.d.ts +13 -0
- package/dist/types/batchItem.js +3 -0
- package/dist/types/batchItem.js.map +1 -0
- package/dist/types/container.d.ts +47 -0
- package/dist/types/container.js +3 -0
- package/dist/types/container.js.map +1 -0
- package/dist/types/contentItem.d.ts +37 -0
- package/dist/types/contentItem.js +3 -0
- package/dist/types/contentItem.js.map +1 -0
- package/dist/types/contentItemHistory.d.ts +20 -0
- package/dist/types/contentItemHistory.js +3 -0
- package/dist/types/contentItemHistory.js.map +1 -0
- package/dist/types/contentListFilterModel.d.ts +26 -0
- package/dist/types/contentListFilterModel.js +3 -0
- package/dist/types/contentListFilterModel.js.map +1 -0
- package/dist/types/contentSectionDefaultModule.d.ts +7 -0
- package/dist/types/contentSectionDefaultModule.js +3 -0
- package/dist/types/contentSectionDefaultModule.js.map +1 -0
- package/dist/types/contentSectionDefinition.d.ts +35 -0
- package/dist/types/contentSectionDefinition.js +3 -0
- package/dist/types/contentSectionDefinition.js.map +1 -0
- package/dist/types/contentViewColumn.d.ts +8 -0
- package/dist/types/contentViewColumn.js +3 -0
- package/dist/types/contentViewColumn.js.map +1 -0
- package/dist/types/instanceRole.d.ts +7 -0
- package/dist/types/instanceRole.js +3 -0
- package/dist/types/instanceRole.js.map +1 -0
- package/dist/types/instanceUser.d.ts +14 -0
- package/dist/types/instanceUser.js +3 -0
- package/dist/types/instanceUser.js.map +1 -0
- package/dist/types/itemComments.d.ts +14 -0
- package/dist/types/itemComments.js +3 -0
- package/dist/types/itemComments.js.map +1 -0
- package/dist/types/listParams.d.ts +9 -0
- package/dist/types/listParams.js +3 -0
- package/dist/types/listParams.js.map +1 -0
- package/dist/types/locales.d.ts +1 -0
- package/dist/types/locales.js +3 -0
- package/dist/types/locales.js.map +1 -0
- package/dist/types/media.d.ts +30 -0
- package/dist/types/media.js +3 -0
- package/dist/types/media.js.map +1 -0
- package/dist/types/model.d.ts +30 -0
- package/dist/types/model.js +3 -0
- package/dist/types/model.js.map +1 -0
- package/dist/types/notification.d.ts +13 -0
- package/dist/types/notification.js +3 -0
- package/dist/types/notification.js.map +1 -0
- package/dist/types/options.d.ts +7 -0
- package/dist/types/options.js +3 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/pageHistory.d.ts +21 -0
- package/dist/types/pageHistory.js +3 -0
- package/dist/types/pageHistory.js.map +1 -0
- package/dist/types/pageItem.d.ts +56 -0
- package/dist/types/pageItem.js +3 -0
- package/dist/types/pageItem.js.map +1 -0
- package/dist/types/pageModel.d.ts +14 -0
- package/dist/types/pageModel.js +3 -0
- package/dist/types/pageModel.js.map +1 -0
- package/dist/types/serverUser.d.ts +21 -0
- package/dist/types/serverUser.js +3 -0
- package/dist/types/serverUser.js.map +1 -0
- package/dist/types/sharedModule.d.ts +7 -0
- package/dist/types/sharedModule.js +3 -0
- package/dist/types/sharedModule.js.map +1 -0
- package/dist/types/sitemap.d.ts +20 -0
- package/dist/types/sitemap.js +3 -0
- package/dist/types/sitemap.js.map +1 -0
- package/dist/types/tokenResponseData.d.ts +10 -0
- package/dist/types/tokenResponseData.js +3 -0
- package/dist/types/tokenResponseData.js.map +1 -0
- package/dist/types/webhook.d.ts +9 -0
- package/dist/types/webhook.js +3 -0
- package/dist/types/webhook.js.map +1 -0
- package/dist/types/websiteListing.d.ts +16 -0
- package/dist/types/websiteListing.js +3 -0
- package/dist/types/websiteListing.js.map +1 -0
- package/dist/types/websiteUser.d.ts +22 -0
- package/dist/types/websiteUser.js +3 -0
- package/dist/types/websiteUser.js.map +1 -0
- package/docs/asset-methods.md +382 -0
- package/docs/auth.md +594 -0
- package/docs/batch-methods.md +244 -0
- package/docs/cicd.md +607 -0
- package/docs/container-methods.md +268 -0
- package/docs/content-methods.md +423 -0
- package/docs/instance-methods.md +105 -0
- package/docs/instance-user-methods.md +231 -0
- package/docs/model-methods.md +434 -0
- package/docs/multi-instance-operations.md +192 -0
- package/docs/page-methods.md +671 -0
- package/docs/server-user-methods.md +280 -0
- package/docs/webhook-methods.md +452 -0
- package/package.json +14 -10
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
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);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.TokenManager = exports.AuthMethods = void 0;
|
|
51
|
+
var clientInstance_1 = require("./clientInstance");
|
|
52
|
+
var exception_1 = require("../models/exception");
|
|
53
|
+
var tokenStorage_1 = require("../tokenStorage");
|
|
54
|
+
/**
|
|
55
|
+
* Internal authentication methods - not exposed publicly
|
|
56
|
+
* Handles OAuth flow and token management with secure storage
|
|
57
|
+
*/
|
|
58
|
+
var AuthMethods = /** @class */ (function () {
|
|
59
|
+
function AuthMethods(options) {
|
|
60
|
+
this._options = options;
|
|
61
|
+
this._clientInstance = new clientInstance_1.ClientInstance(this._options);
|
|
62
|
+
this._tokenStorage = new tokenStorage_1.TokenStorage();
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Generate OAuth authorization URL for user authentication
|
|
66
|
+
* @param options - Authorization URL configuration options
|
|
67
|
+
* @returns Complete authorization URL for user redirection
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const client = new ApiClient();
|
|
72
|
+
* const authUrl = client.authMethods.generateAuthUrl({
|
|
73
|
+
* redirectUri: 'https://yourapp.com/auth/callback',
|
|
74
|
+
* scope: 'openid profile email offline_access',
|
|
75
|
+
* state: 'random-state-string'
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* // Redirect user to authorization URL
|
|
79
|
+
* window.location.href = authUrl;
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
AuthMethods.prototype.generateAuthUrl = function (options) {
|
|
83
|
+
var baseUrl = this._clientInstance.determineOAuthBaseUrl(options.region);
|
|
84
|
+
var authUrl = "".concat(baseUrl, "/oauth/authorize");
|
|
85
|
+
var params = new URLSearchParams({
|
|
86
|
+
response_type: options.responseType || 'code',
|
|
87
|
+
redirect_uri: options.redirectUri,
|
|
88
|
+
scope: options.scope || 'openid profile email offline_access'
|
|
89
|
+
});
|
|
90
|
+
if (options.state) {
|
|
91
|
+
params.append('state', options.state);
|
|
92
|
+
}
|
|
93
|
+
return "".concat(authUrl, "?").concat(params.toString());
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Exchange authorization code for access tokens
|
|
97
|
+
* Automatically stores tokens securely and sets them in Options
|
|
98
|
+
* @param request - Token exchange request parameters
|
|
99
|
+
* @returns Promise containing access and refresh tokens
|
|
100
|
+
*/
|
|
101
|
+
AuthMethods.prototype.exchangeCodeForToken = function (request, region) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
+
var data, resp, tokenResponse, tokenData, err_1, errorData;
|
|
104
|
+
var _a;
|
|
105
|
+
return __generator(this, function (_b) {
|
|
106
|
+
switch (_b.label) {
|
|
107
|
+
case 0:
|
|
108
|
+
_b.trys.push([0, 3, , 4]);
|
|
109
|
+
data = new URLSearchParams({
|
|
110
|
+
grant_type: request.grantType || 'authorization_code',
|
|
111
|
+
code: request.code,
|
|
112
|
+
redirect_uri: request.redirectUri
|
|
113
|
+
});
|
|
114
|
+
return [4 /*yield*/, this._clientInstance.executeOAuthPost('token', data, region)];
|
|
115
|
+
case 1:
|
|
116
|
+
resp = _b.sent();
|
|
117
|
+
tokenResponse = resp.data;
|
|
118
|
+
tokenData = {
|
|
119
|
+
accessToken: tokenResponse.access_token,
|
|
120
|
+
refreshToken: tokenResponse.refresh_token,
|
|
121
|
+
expiresAt: tokenResponse.expires_in ? Date.now() + (tokenResponse.expires_in * 1000) : undefined,
|
|
122
|
+
tokenType: tokenResponse.token_type,
|
|
123
|
+
scope: tokenResponse.scope
|
|
124
|
+
};
|
|
125
|
+
return [4 /*yield*/, this._tokenStorage.setTokens(tokenData)];
|
|
126
|
+
case 2:
|
|
127
|
+
_b.sent();
|
|
128
|
+
// Set token in shared options for immediate use
|
|
129
|
+
this._options.token = tokenResponse.access_token;
|
|
130
|
+
return [2 /*return*/, tokenResponse];
|
|
131
|
+
case 3:
|
|
132
|
+
err_1 = _b.sent();
|
|
133
|
+
if ((_a = err_1.response) === null || _a === void 0 ? void 0 : _a.data) {
|
|
134
|
+
errorData = err_1.response.data;
|
|
135
|
+
throw new exception_1.Exception("OAuth token exchange failed: ".concat(errorData.error, " - ").concat(errorData.error_description || 'Unknown error'), err_1);
|
|
136
|
+
}
|
|
137
|
+
throw new exception_1.Exception('Unable to exchange authorization code for token', err_1);
|
|
138
|
+
case 4: return [2 /*return*/];
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Refresh an expired access token using refresh token
|
|
145
|
+
* Automatically updates stored tokens and Options
|
|
146
|
+
* @param request - Token refresh request parameters
|
|
147
|
+
* @returns Promise containing new access token
|
|
148
|
+
*/
|
|
149
|
+
AuthMethods.prototype.refreshAccessToken = function (request, region) {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
+
var data, resp, tokenResponse, existingTokenData, tokenData, err_2, errorData;
|
|
152
|
+
var _a;
|
|
153
|
+
return __generator(this, function (_b) {
|
|
154
|
+
switch (_b.label) {
|
|
155
|
+
case 0:
|
|
156
|
+
_b.trys.push([0, 4, , 5]);
|
|
157
|
+
data = new URLSearchParams({
|
|
158
|
+
grant_type: request.grantType || 'refresh_token',
|
|
159
|
+
refresh_token: request.refreshToken
|
|
160
|
+
});
|
|
161
|
+
return [4 /*yield*/, this._clientInstance.executeOAuthPost('refresh', data, region)];
|
|
162
|
+
case 1:
|
|
163
|
+
resp = _b.sent();
|
|
164
|
+
tokenResponse = resp.data;
|
|
165
|
+
return [4 /*yield*/, this._tokenStorage.getTokens()];
|
|
166
|
+
case 2:
|
|
167
|
+
existingTokenData = _b.sent();
|
|
168
|
+
tokenData = {
|
|
169
|
+
accessToken: tokenResponse.access_token,
|
|
170
|
+
refreshToken: tokenResponse.refresh_token || (existingTokenData === null || existingTokenData === void 0 ? void 0 : existingTokenData.refreshToken),
|
|
171
|
+
expiresAt: tokenResponse.expires_in ? Date.now() + (tokenResponse.expires_in * 1000) : undefined,
|
|
172
|
+
tokenType: tokenResponse.token_type,
|
|
173
|
+
scope: tokenResponse.scope
|
|
174
|
+
};
|
|
175
|
+
return [4 /*yield*/, this._tokenStorage.setTokens(tokenData)];
|
|
176
|
+
case 3:
|
|
177
|
+
_b.sent();
|
|
178
|
+
// Update shared options with new token
|
|
179
|
+
this._options.token = tokenResponse.access_token;
|
|
180
|
+
return [2 /*return*/, tokenResponse];
|
|
181
|
+
case 4:
|
|
182
|
+
err_2 = _b.sent();
|
|
183
|
+
if ((_a = err_2.response) === null || _a === void 0 ? void 0 : _a.data) {
|
|
184
|
+
errorData = err_2.response.data;
|
|
185
|
+
throw new exception_1.Exception("OAuth token refresh failed: ".concat(errorData.error, " - ").concat(errorData.error_description || 'Unknown error'), err_2);
|
|
186
|
+
}
|
|
187
|
+
throw new exception_1.Exception('Unable to refresh access token', err_2);
|
|
188
|
+
case 5: return [2 /*return*/];
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Validate an access token and get token information
|
|
195
|
+
* @param token - Access token to validate
|
|
196
|
+
* @returns Promise containing token validation information
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```typescript
|
|
200
|
+
* const client = new ApiClient();
|
|
201
|
+
*
|
|
202
|
+
* const tokenInfo = await client.authMethods.validateToken('your_access_token');
|
|
203
|
+
*
|
|
204
|
+
* if (tokenInfo.active) {
|
|
205
|
+
* console.log('Token is valid');
|
|
206
|
+
* console.log('Expires at:', new Date(tokenInfo.exp * 1000));
|
|
207
|
+
* console.log('Scope:', tokenInfo.scope);
|
|
208
|
+
* } else {
|
|
209
|
+
* console.log('Token is invalid or expired');
|
|
210
|
+
* }
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
AuthMethods.prototype.validateToken = function (token, region) {
|
|
214
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
215
|
+
var resp, err_3;
|
|
216
|
+
var _a;
|
|
217
|
+
return __generator(this, function (_b) {
|
|
218
|
+
switch (_b.label) {
|
|
219
|
+
case 0:
|
|
220
|
+
_b.trys.push([0, 2, , 3]);
|
|
221
|
+
return [4 /*yield*/, this._clientInstance.executeOAuthGet('introspect', region, token)];
|
|
222
|
+
case 1:
|
|
223
|
+
resp = _b.sent();
|
|
224
|
+
return [2 /*return*/, resp.data];
|
|
225
|
+
case 2:
|
|
226
|
+
err_3 = _b.sent();
|
|
227
|
+
if (((_a = err_3.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
|
|
228
|
+
return [2 /*return*/, { active: false }];
|
|
229
|
+
}
|
|
230
|
+
throw new exception_1.Exception('Unable to validate token', err_3);
|
|
231
|
+
case 3: return [2 /*return*/];
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Revoke an access token or refresh token
|
|
238
|
+
* @param token - Token to revoke
|
|
239
|
+
* @returns Promise indicating success
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* const client = new ApiClient();
|
|
244
|
+
*
|
|
245
|
+
* // Revoke access token on logout
|
|
246
|
+
* await client.authMethods.revokeToken('access_token');
|
|
247
|
+
*
|
|
248
|
+
* // Clear the client's token
|
|
249
|
+
* client.clearToken();
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
AuthMethods.prototype.revokeToken = function (token, region) {
|
|
253
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
254
|
+
var data, err_4;
|
|
255
|
+
return __generator(this, function (_a) {
|
|
256
|
+
switch (_a.label) {
|
|
257
|
+
case 0:
|
|
258
|
+
_a.trys.push([0, 2, , 3]);
|
|
259
|
+
data = new URLSearchParams({
|
|
260
|
+
token: token
|
|
261
|
+
});
|
|
262
|
+
return [4 /*yield*/, this._clientInstance.executeOAuthPost('revoke', data, region)];
|
|
263
|
+
case 1:
|
|
264
|
+
_a.sent();
|
|
265
|
+
return [3 /*break*/, 3];
|
|
266
|
+
case 2:
|
|
267
|
+
err_4 = _a.sent();
|
|
268
|
+
throw new exception_1.Exception('Unable to revoke token', err_4);
|
|
269
|
+
case 3: return [2 /*return*/];
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* Set the access token in the shared Options instance
|
|
276
|
+
* Also stores token in keytar for consistency
|
|
277
|
+
* @param token - Valid access token
|
|
278
|
+
*/
|
|
279
|
+
AuthMethods.prototype.setAccessToken = function (token) {
|
|
280
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
281
|
+
var tokenData;
|
|
282
|
+
return __generator(this, function (_a) {
|
|
283
|
+
switch (_a.label) {
|
|
284
|
+
case 0:
|
|
285
|
+
this._options.token = token;
|
|
286
|
+
tokenData = {
|
|
287
|
+
accessToken: token,
|
|
288
|
+
refreshToken: undefined, // No refresh token for manual tokens
|
|
289
|
+
expiresAt: undefined, // No expiration for manual tokens
|
|
290
|
+
tokenType: 'Bearer',
|
|
291
|
+
scope: undefined
|
|
292
|
+
};
|
|
293
|
+
return [4 /*yield*/, this._tokenStorage.setTokens(tokenData)];
|
|
294
|
+
case 1:
|
|
295
|
+
_a.sent();
|
|
296
|
+
return [2 /*return*/];
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Get a valid access token - automatically refreshes if expired
|
|
303
|
+
* @returns Promise containing valid access token or null if authentication required
|
|
304
|
+
*/
|
|
305
|
+
AuthMethods.prototype.getValidAccessToken = function () {
|
|
306
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
307
|
+
var storedTokens, isExpired, newTokens, error_1;
|
|
308
|
+
return __generator(this, function (_a) {
|
|
309
|
+
switch (_a.label) {
|
|
310
|
+
case 0:
|
|
311
|
+
// Check if manual token is set (highest priority)
|
|
312
|
+
if (this._options.token) {
|
|
313
|
+
return [2 /*return*/, this._options.token];
|
|
314
|
+
}
|
|
315
|
+
return [4 /*yield*/, this._tokenStorage.getTokens()];
|
|
316
|
+
case 1:
|
|
317
|
+
storedTokens = _a.sent();
|
|
318
|
+
if (!storedTokens) {
|
|
319
|
+
return [2 /*return*/, null];
|
|
320
|
+
}
|
|
321
|
+
return [4 /*yield*/, this._tokenStorage.areTokensExpired()];
|
|
322
|
+
case 2:
|
|
323
|
+
isExpired = _a.sent();
|
|
324
|
+
if (!isExpired) {
|
|
325
|
+
this._options.token = storedTokens.accessToken;
|
|
326
|
+
return [2 /*return*/, storedTokens.accessToken];
|
|
327
|
+
}
|
|
328
|
+
if (!storedTokens.refreshToken) return [3 /*break*/, 7];
|
|
329
|
+
_a.label = 3;
|
|
330
|
+
case 3:
|
|
331
|
+
_a.trys.push([3, 5, , 7]);
|
|
332
|
+
return [4 /*yield*/, this.refreshAccessToken({
|
|
333
|
+
refreshToken: storedTokens.refreshToken
|
|
334
|
+
})];
|
|
335
|
+
case 4:
|
|
336
|
+
newTokens = _a.sent();
|
|
337
|
+
return [2 /*return*/, newTokens.access_token];
|
|
338
|
+
case 5:
|
|
339
|
+
error_1 = _a.sent();
|
|
340
|
+
// Refresh failed, clear invalid tokens
|
|
341
|
+
return [4 /*yield*/, this._tokenStorage.clearTokens()];
|
|
342
|
+
case 6:
|
|
343
|
+
// Refresh failed, clear invalid tokens
|
|
344
|
+
_a.sent();
|
|
345
|
+
return [2 /*return*/, null];
|
|
346
|
+
case 7:
|
|
347
|
+
// No refresh token available
|
|
348
|
+
return [2 /*return*/, null];
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
};
|
|
353
|
+
/**
|
|
354
|
+
* Perform OAuth authentication flow
|
|
355
|
+
* @param options - OAuth configuration options
|
|
356
|
+
* @returns Promise resolving when authentication is complete
|
|
357
|
+
*/
|
|
358
|
+
AuthMethods.prototype.performOAuthFlow = function (options) {
|
|
359
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
360
|
+
var authUrl;
|
|
361
|
+
return __generator(this, function (_a) {
|
|
362
|
+
authUrl = this.generateAuthUrl(options);
|
|
363
|
+
throw new exception_1.Exception("OAuth flow not fully implemented. Please visit: ".concat(authUrl));
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
/**
|
|
368
|
+
* Clear all authentication data
|
|
369
|
+
*/
|
|
370
|
+
AuthMethods.prototype.clearAuthentication = function () {
|
|
371
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
372
|
+
return __generator(this, function (_a) {
|
|
373
|
+
switch (_a.label) {
|
|
374
|
+
case 0: return [4 /*yield*/, this._tokenStorage.clearTokens()];
|
|
375
|
+
case 1:
|
|
376
|
+
_a.sent();
|
|
377
|
+
this._options.token = undefined;
|
|
378
|
+
return [2 /*return*/];
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
};
|
|
383
|
+
/**
|
|
384
|
+
* Check if user is authenticated (has valid token)
|
|
385
|
+
* @returns Promise resolving to true if authenticated
|
|
386
|
+
*/
|
|
387
|
+
AuthMethods.prototype.isAuthenticated = function () {
|
|
388
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
389
|
+
var validToken;
|
|
390
|
+
return __generator(this, function (_a) {
|
|
391
|
+
switch (_a.label) {
|
|
392
|
+
case 0: return [4 /*yield*/, this.getValidAccessToken()];
|
|
393
|
+
case 1:
|
|
394
|
+
validToken = _a.sent();
|
|
395
|
+
return [2 /*return*/, validToken !== null];
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
};
|
|
400
|
+
/**
|
|
401
|
+
* Check if a token is expired based on expiration timestamp
|
|
402
|
+
* @param expiresAt - Token expiration timestamp (seconds since epoch)
|
|
403
|
+
* @param bufferSeconds - Buffer time in seconds to consider token expired early (default: 300 = 5 minutes)
|
|
404
|
+
* @returns True if token is expired or will expire within buffer time
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```typescript
|
|
408
|
+
* const client = new ApiClient();
|
|
409
|
+
*
|
|
410
|
+
* const expiresAt = Math.floor(Date.now() / 1000) + 3600; // 1 hour from now
|
|
411
|
+
*
|
|
412
|
+
* if (client.authMethods.isTokenExpired(expiresAt)) {
|
|
413
|
+
* console.log('Token is expired or will expire soon');
|
|
414
|
+
* // Refresh token or re-authenticate
|
|
415
|
+
* }
|
|
416
|
+
* ```
|
|
417
|
+
*/
|
|
418
|
+
AuthMethods.prototype.isTokenExpired = function (expiresAt, bufferSeconds) {
|
|
419
|
+
if (bufferSeconds === void 0) { bufferSeconds = 300; }
|
|
420
|
+
var currentTime = Math.floor(Date.now() / 1000);
|
|
421
|
+
return currentTime >= (expiresAt - bufferSeconds);
|
|
422
|
+
};
|
|
423
|
+
/**
|
|
424
|
+
* Calculate token expiration timestamp from expires_in value
|
|
425
|
+
* @param expiresIn - Token lifetime in seconds
|
|
426
|
+
* @returns Expiration timestamp (seconds since epoch)
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* ```typescript
|
|
430
|
+
* const client = new ApiClient();
|
|
431
|
+
*
|
|
432
|
+
* const tokens = await client.authMethods.exchangeCodeForToken(request);
|
|
433
|
+
* const expiresAt = client.authMethods.calculateExpirationTime(tokens.expires_in);
|
|
434
|
+
*
|
|
435
|
+
* // Store expiration time for later use
|
|
436
|
+
* localStorage.setItem('token_expires_at', expiresAt.toString());
|
|
437
|
+
* ```
|
|
438
|
+
*/
|
|
439
|
+
AuthMethods.prototype.calculateExpirationTime = function (expiresIn) {
|
|
440
|
+
return Math.floor(Date.now() / 1000) + expiresIn;
|
|
441
|
+
};
|
|
442
|
+
/**
|
|
443
|
+
* Generate a cryptographically secure random state parameter for OAuth
|
|
444
|
+
* @param length - Length of the state string (default: 32)
|
|
445
|
+
* @returns Random state string
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* ```typescript
|
|
449
|
+
* const client = new ApiClient();
|
|
450
|
+
*
|
|
451
|
+
* const state = client.authMethods.generateState();
|
|
452
|
+
*
|
|
453
|
+
* // Store state for validation
|
|
454
|
+
* sessionStorage.setItem('oauth_state', state);
|
|
455
|
+
*
|
|
456
|
+
* // Use in authorization URL
|
|
457
|
+
* const authUrl = client.authMethods.generateAuthUrl({
|
|
458
|
+
* redirectUri: 'https://yourapp.com/callback',
|
|
459
|
+
* state: state
|
|
460
|
+
* });
|
|
461
|
+
* ```
|
|
462
|
+
*/
|
|
463
|
+
AuthMethods.prototype.generateState = function (length) {
|
|
464
|
+
if (length === void 0) { length = 32; }
|
|
465
|
+
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
466
|
+
var result = '';
|
|
467
|
+
for (var i = 0; i < length; i++) {
|
|
468
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
469
|
+
}
|
|
470
|
+
return result;
|
|
471
|
+
};
|
|
472
|
+
/**
|
|
473
|
+
* Create a token manager for automatic token refresh
|
|
474
|
+
* @param config - Token manager configuration
|
|
475
|
+
* @returns Token manager instance
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* ```typescript
|
|
479
|
+
* const client = new ApiClient();
|
|
480
|
+
*
|
|
481
|
+
* const tokenManager = client.authMethods.createTokenManager({
|
|
482
|
+
* accessToken: 'current_access_token',
|
|
483
|
+
* refreshToken: 'current_refresh_token',
|
|
484
|
+
* expiresAt: 1234567890
|
|
485
|
+
* });
|
|
486
|
+
*
|
|
487
|
+
* // Get valid token (auto-refreshes if needed and updates client)
|
|
488
|
+
* const validToken = await tokenManager.getValidToken();
|
|
489
|
+
*
|
|
490
|
+
* // Client is now updated with fresh token - make API calls
|
|
491
|
+
* const content = await client.contentMethods.getContentItem(123, guid, locale);
|
|
492
|
+
* ```
|
|
493
|
+
*/
|
|
494
|
+
AuthMethods.prototype.createTokenManager = function (config) {
|
|
495
|
+
return new TokenManager(this, config);
|
|
496
|
+
};
|
|
497
|
+
/**
|
|
498
|
+
* Get current authentication state
|
|
499
|
+
* @param token - Current access token
|
|
500
|
+
* @param expiresAt - Token expiration timestamp
|
|
501
|
+
* @param refreshToken - Optional refresh token
|
|
502
|
+
* @returns Authentication state information
|
|
503
|
+
*
|
|
504
|
+
* @example
|
|
505
|
+
* ```typescript
|
|
506
|
+
* const client = new ApiClient();
|
|
507
|
+
*
|
|
508
|
+
* const authState = client.authMethods.getAuthState(
|
|
509
|
+
* localStorage.getItem('access_token'),
|
|
510
|
+
* parseInt(localStorage.getItem('token_expires_at')),
|
|
511
|
+
* localStorage.getItem('refresh_token')
|
|
512
|
+
* );
|
|
513
|
+
*
|
|
514
|
+
* if (authState.isAuthenticated) {
|
|
515
|
+
* console.log('User is authenticated');
|
|
516
|
+
* } else {
|
|
517
|
+
* console.log('User needs to authenticate');
|
|
518
|
+
* }
|
|
519
|
+
* ```
|
|
520
|
+
*/
|
|
521
|
+
AuthMethods.prototype.getAuthState = function (token, expiresAt, refreshToken) {
|
|
522
|
+
if (!token) {
|
|
523
|
+
return { isAuthenticated: false };
|
|
524
|
+
}
|
|
525
|
+
var isExpired = expiresAt ? this.isTokenExpired(expiresAt) : false;
|
|
526
|
+
return {
|
|
527
|
+
isAuthenticated: !isExpired,
|
|
528
|
+
token: token,
|
|
529
|
+
expiresAt: expiresAt,
|
|
530
|
+
refreshToken: refreshToken
|
|
531
|
+
};
|
|
532
|
+
};
|
|
533
|
+
return AuthMethods;
|
|
534
|
+
}());
|
|
535
|
+
exports.AuthMethods = AuthMethods;
|
|
536
|
+
/**
|
|
537
|
+
* Token manager class for automatic token refresh
|
|
538
|
+
*/
|
|
539
|
+
var TokenManager = /** @class */ (function () {
|
|
540
|
+
function TokenManager(authMethods, config) {
|
|
541
|
+
this.authMethods = authMethods;
|
|
542
|
+
this.config = config;
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Get a valid access token, refreshing if necessary
|
|
546
|
+
* This automatically updates the shared token in the AuthMethods instance
|
|
547
|
+
* @returns Promise containing valid access token
|
|
548
|
+
*/
|
|
549
|
+
TokenManager.prototype.getValidToken = function () {
|
|
550
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
551
|
+
var validToken, newTokens, error_2;
|
|
552
|
+
return __generator(this, function (_a) {
|
|
553
|
+
switch (_a.label) {
|
|
554
|
+
case 0: return [4 /*yield*/, this.authMethods.getValidAccessToken()];
|
|
555
|
+
case 1:
|
|
556
|
+
validToken = _a.sent();
|
|
557
|
+
if (validToken) {
|
|
558
|
+
return [2 /*return*/, validToken];
|
|
559
|
+
}
|
|
560
|
+
// Fallback to old config-based approach for backwards compatibility
|
|
561
|
+
if (this.config.expiresAt && !this.authMethods.isTokenExpired(this.config.expiresAt)) {
|
|
562
|
+
return [2 /*return*/, this.config.accessToken];
|
|
563
|
+
}
|
|
564
|
+
if (!this.config.refreshToken) return [3 /*break*/, 5];
|
|
565
|
+
_a.label = 2;
|
|
566
|
+
case 2:
|
|
567
|
+
_a.trys.push([2, 4, , 5]);
|
|
568
|
+
return [4 /*yield*/, this.authMethods.refreshAccessToken({
|
|
569
|
+
refreshToken: this.config.refreshToken
|
|
570
|
+
}, this.config.region)];
|
|
571
|
+
case 3:
|
|
572
|
+
newTokens = _a.sent();
|
|
573
|
+
// Update configuration with new tokens
|
|
574
|
+
this.config.accessToken = newTokens.access_token;
|
|
575
|
+
this.config.expiresAt = this.authMethods.calculateExpirationTime(newTokens.expires_in);
|
|
576
|
+
if (newTokens.refresh_token) {
|
|
577
|
+
this.config.refreshToken = newTokens.refresh_token;
|
|
578
|
+
}
|
|
579
|
+
return [2 /*return*/, this.config.accessToken];
|
|
580
|
+
case 4:
|
|
581
|
+
error_2 = _a.sent();
|
|
582
|
+
throw new exception_1.Exception('Token refresh failed - user needs to re-authenticate', error_2);
|
|
583
|
+
case 5: throw new exception_1.Exception('No refresh token available - user needs to re-authenticate');
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
});
|
|
587
|
+
};
|
|
588
|
+
/**
|
|
589
|
+
* Update the token configuration
|
|
590
|
+
* @param config - New token configuration
|
|
591
|
+
*/
|
|
592
|
+
TokenManager.prototype.updateConfig = function (config) {
|
|
593
|
+
this.config = __assign(__assign({}, this.config), config);
|
|
594
|
+
};
|
|
595
|
+
/**
|
|
596
|
+
* Get current token configuration
|
|
597
|
+
* @returns Current token configuration
|
|
598
|
+
*/
|
|
599
|
+
TokenManager.prototype.getConfig = function () {
|
|
600
|
+
return __assign({}, this.config);
|
|
601
|
+
};
|
|
602
|
+
return TokenManager;
|
|
603
|
+
}());
|
|
604
|
+
exports.TokenManager = TokenManager;
|
|
@@ -1,11 +1,42 @@
|
|
|
1
1
|
import { Options } from "../models/options";
|
|
2
2
|
import { ClientInstance } from "./clientInstance";
|
|
3
3
|
import { Batch } from "../models/batch";
|
|
4
|
+
import { BatchTypesResponse } from "../models/batchTypes";
|
|
4
5
|
export declare class BatchMethods {
|
|
5
6
|
_options: Options;
|
|
6
7
|
_clientInstance: ClientInstance;
|
|
7
8
|
constructor(options: Options);
|
|
8
|
-
getBatch(batchID: number): Promise<Batch>;
|
|
9
|
+
getBatch(batchID: number, guid: string, expandItems?: boolean): Promise<Batch>;
|
|
10
|
+
publishBatch(batchID: number, guid: string, returnBatchId?: boolean): Promise<number>;
|
|
11
|
+
unpublishBatch(batchID: number, guid: string, returnBatchId?: boolean): Promise<number>;
|
|
12
|
+
approveBatch(batchID: number, guid: string, returnBatchId?: boolean): Promise<number>;
|
|
13
|
+
declineBatch(batchID: number, guid: string, returnBatchId?: boolean): Promise<number>;
|
|
14
|
+
requestApprovalBatch(batchID: number, guid: string, returnBatchId?: boolean): Promise<number>;
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves all batch-related enum types for developer discovery.
|
|
17
|
+
* This method provides all available enum values with their names,
|
|
18
|
+
* enabling dynamic UI population and client-side validation.
|
|
19
|
+
*
|
|
20
|
+
* @param guid - Current website guid
|
|
21
|
+
* @returns Promise containing all batch enum types
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* // Get all batch types for UI population
|
|
26
|
+
* const types = await client.batchMethods.getBatchTypes(guid);
|
|
27
|
+
*
|
|
28
|
+
* // Create dropdown options for item types
|
|
29
|
+
* const itemTypeOptions = types.itemTypes.map(type => ({
|
|
30
|
+
* label: type.name,
|
|
31
|
+
* value: type.value
|
|
32
|
+
* }));
|
|
33
|
+
*
|
|
34
|
+
* // Validate operation type
|
|
35
|
+
* const isValidOperation = (value: number) =>
|
|
36
|
+
* types.workflowOperations.some(op => op.value === value);
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
getBatchTypes(guid: string): Promise<BatchTypesResponse>;
|
|
9
40
|
Retry(method: Function): Promise<Batch>;
|
|
10
41
|
delay(ms: number): Promise<unknown>;
|
|
11
42
|
}
|