visualvault-api 1.1.0 → 2.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -138
  3. package/dist/VVRestApi.cjs +2574 -0
  4. package/dist/VVRestApi.cjs.map +1 -0
  5. package/dist/VVRestApi.d.cts +375 -0
  6. package/dist/VVRestApi.d.ts +375 -0
  7. package/dist/VVRestApi.js +2544 -0
  8. package/dist/VVRestApi.js.map +1 -0
  9. package/{lib/VVRestApi/VVRestApiNodeJs → dist}/config.yml +106 -100
  10. package/dist/constants.cjs +45 -0
  11. package/dist/constants.cjs.map +1 -0
  12. package/dist/constants.d.cts +48 -0
  13. package/dist/constants.d.ts +48 -0
  14. package/dist/constants.js +20 -0
  15. package/dist/constants.js.map +1 -0
  16. package/dist/index.cjs +2594 -0
  17. package/dist/index.cjs.map +1 -0
  18. package/dist/index.d.cts +2 -0
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.js +2563 -0
  21. package/dist/index.js.map +1 -0
  22. package/package.json +47 -71
  23. package/lib/VVRestApi/VVRestApiNodeJs/DocApi.js +0 -66
  24. package/lib/VVRestApi/VVRestApiNodeJs/FormsApi.js +0 -51
  25. package/lib/VVRestApi/VVRestApiNodeJs/NotificationsApi.js +0 -39
  26. package/lib/VVRestApi/VVRestApiNodeJs/StudioApi.js +0 -136
  27. package/lib/VVRestApi/VVRestApiNodeJs/VVRestApi.js +0 -1889
  28. package/lib/VVRestApi/VVRestApiNodeJs/app.js +0 -128
  29. package/lib/VVRestApi/VVRestApiNodeJs/common.js +0 -1598
  30. package/lib/VVRestApi/VVRestApiNodeJs/dts/express.d.ts +0 -125
  31. package/lib/VVRestApi/VVRestApiNodeJs/dts/node.d.ts +0 -1090
  32. package/lib/VVRestApi/VVRestApiNodeJs/log.js +0 -20
  33. package/lib/VVRestApi/VVRestApiNodeJs/public/favicon.ico +0 -0
  34. package/lib/VVRestApi/VVRestApiNodeJs/routes/scheduledscripts.js +0 -203
  35. package/lib/VVRestApi/VVRestApiNodeJs/routes/scripts.js +0 -215
  36. package/lib/VVRestApi/VVRestApiNodeJs/routes/testScheduledScripts.js +0 -131
  37. package/lib/VVRestApi/VVRestApiNodeJs/samples/SampleScheduledScript.js +0 -90
  38. package/lib/VVRestApi/VVRestApiNodeJs/samples/SendEmailScript.js +0 -51
  39. package/lib/VVRestApi/VVRestApiNodeJs/samples/fileTest.js +0 -60
  40. package/lib/VVRestApi/VVRestApiNodeJs/samples/sampleFormValidationScript.js +0 -126
  41. package/lib/VVRestApi/VVRestApiNodeJs/views/error.ejs +0 -8
  42. package/lib/VVRestApi/VVRestApiNodeJs/views/index.ejs +0 -8
@@ -0,0 +1,2574 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __esm = (fn, res) => function __init() {
8
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
+ };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+
32
+ // node_modules/tsup/assets/cjs_shims.js
33
+ var getImportMetaUrl, importMetaUrl;
34
+ var init_cjs_shims = __esm({
35
+ "node_modules/tsup/assets/cjs_shims.js"() {
36
+ getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
37
+ importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
38
+ }
39
+ });
40
+
41
+ // lib/http/sessionToken.js
42
+ var SessionToken;
43
+ var init_sessionToken = __esm({
44
+ "lib/http/sessionToken.js"() {
45
+ init_cjs_shims();
46
+ SessionToken = class _SessionToken {
47
+ constructor() {
48
+ this.isAuthenticated = false;
49
+ this.apiUrl = null;
50
+ this.baseUrl = null;
51
+ this.authenticationUrl = null;
52
+ this.customerAlias = null;
53
+ this.databaseAlias = null;
54
+ this.expirationDate = null;
55
+ this.accessToken = null;
56
+ this.tokenType = null;
57
+ this.refreshToken = null;
58
+ this.expiresIn = 0;
59
+ this.clientId = null;
60
+ this.clientSecret = null;
61
+ this.userId = null;
62
+ this.password = null;
63
+ this.audience = null;
64
+ }
65
+ createCopy() {
66
+ const newSession = new _SessionToken();
67
+ newSession.isAuthenticated = this.isAuthenticated;
68
+ newSession.apiUrl = this.apiUrl;
69
+ newSession.baseUrl = this.baseUrl;
70
+ newSession.authenticationUrl = this.authenticationUrl;
71
+ newSession.customerAlias = this.customerAlias;
72
+ newSession.databaseAlias = this.databaseAlias;
73
+ newSession.expirationDate = this.expirationDate;
74
+ newSession.accessToken = this.accessToken;
75
+ newSession.tokenType = this.tokenType;
76
+ newSession.refreshToken = this.refreshToken;
77
+ newSession.expiresIn = this.expiresIn;
78
+ newSession.clientId = this.clientId;
79
+ newSession.clientSecret = this.clientSecret;
80
+ newSession.userId = this.userId;
81
+ newSession.password = this.password;
82
+ newSession.audience = this.audience;
83
+ return newSession;
84
+ }
85
+ convertToJwt(jwt) {
86
+ this.tokenType = "jwt";
87
+ this.accessToken = jwt["token"];
88
+ this.expirationDate = new Date(jwt["expires"]);
89
+ this.expiresIn = 0;
90
+ }
91
+ };
92
+ }
93
+ });
94
+
95
+ // lib/http/authorize.js
96
+ var authorize_exports = {};
97
+ __export(authorize_exports, {
98
+ Authorize: () => Authorize,
99
+ default: () => authorize_default
100
+ });
101
+ var import_debug, import_js_yaml, import_fs, debug, Authorize, authorize_default;
102
+ var init_authorize = __esm({
103
+ "lib/http/authorize.js"() {
104
+ init_cjs_shims();
105
+ init_sessionToken();
106
+ import_debug = __toESM(require("debug"), 1);
107
+ import_js_yaml = __toESM(require("js-yaml"), 1);
108
+ import_fs = __toESM(require("fs"), 1);
109
+ debug = (0, import_debug.default)("visualvault:auth");
110
+ Authorize = class {
111
+ constructor() {
112
+ this.jsyaml = import_js_yaml.default;
113
+ this.fs = import_fs.default;
114
+ }
115
+ async acquireSecurityToken(clientId, clientSecret, userId, password, audience, baseUrl, apiUrl, customerAlias, databaseAlias, authenticationUrl) {
116
+ debug("acquireSecurityToken called for user: %s", userId);
117
+ try {
118
+ const sessionToken = await this.__getToken(
119
+ clientId,
120
+ clientSecret,
121
+ userId,
122
+ password,
123
+ audience,
124
+ baseUrl,
125
+ customerAlias,
126
+ databaseAlias,
127
+ authenticationUrl,
128
+ true
129
+ );
130
+ debug("acquireSecurityToken success");
131
+ if (typeof sessionToken != "undefined" && sessionToken != null) {
132
+ sessionToken.baseUrl = baseUrl;
133
+ sessionToken.apiUrl = apiUrl;
134
+ sessionToken.authenticationUrl = authenticationUrl;
135
+ sessionToken.customerAlias = customerAlias;
136
+ sessionToken.databaseAlias = databaseAlias;
137
+ sessionToken.clientId = clientId;
138
+ sessionToken.clientSecret = clientSecret;
139
+ sessionToken.userId = userId;
140
+ sessionToken.password = password;
141
+ sessionToken.audience = audience;
142
+ sessionToken.isAuthenticated = true;
143
+ }
144
+ return sessionToken;
145
+ } catch (error) {
146
+ debug("acquireSecurityToken failed: %s", error.message);
147
+ throw error;
148
+ }
149
+ }
150
+ async acquireJwt(jwt, baseUrl, apiUrl, authenticationUrl, customerAlias, databaseAlias) {
151
+ debug("acquireJwt called");
152
+ try {
153
+ const sessionToken = await this.__getJwt(
154
+ jwt,
155
+ baseUrl,
156
+ customerAlias,
157
+ databaseAlias,
158
+ authenticationUrl,
159
+ true
160
+ );
161
+ debug("acquireJwt success");
162
+ if (typeof sessionToken != "undefined" && sessionToken != null) {
163
+ sessionToken.baseUrl = baseUrl;
164
+ sessionToken.apiUrl = apiUrl;
165
+ sessionToken.authenticationUrl = authenticationUrl;
166
+ sessionToken.customerAlias = customerAlias;
167
+ sessionToken.databaseAlias = databaseAlias;
168
+ sessionToken.isAuthenticated = true;
169
+ sessionToken.isJwt = true;
170
+ }
171
+ return sessionToken;
172
+ } catch (error) {
173
+ debug("acquireJwt failed: %s", error.message);
174
+ throw error;
175
+ }
176
+ }
177
+ async reacquireSecurityToken(sessionToken) {
178
+ debug("reacquireSecurityToken called (isJwt: %s)", sessionToken.isJwt);
179
+ try {
180
+ if (sessionToken.isJwt) {
181
+ const newToken = await this.__getJwt(
182
+ sessionToken.accessToken,
183
+ sessionToken.baseUrl,
184
+ sessionToken.customerAlias,
185
+ sessionToken.databaseAlias,
186
+ sessionToken.authenticationUrl,
187
+ true
188
+ );
189
+ debug("reacquireSecurityToken success (JWT)");
190
+ return newToken;
191
+ } else {
192
+ const newToken = await this.__getToken(
193
+ sessionToken.clientId,
194
+ sessionToken.clientSecret,
195
+ sessionToken.userId,
196
+ sessionToken.password,
197
+ sessionToken.audience,
198
+ sessionToken.baseUrl,
199
+ sessionToken.customerAlias,
200
+ sessionToken.databaseAlias,
201
+ sessionToken.authenticationUrl,
202
+ true
203
+ );
204
+ debug("reacquireSecurityToken success (password grant)");
205
+ return newToken;
206
+ }
207
+ } catch (error) {
208
+ debug("reacquireSecurityToken failed: %s", error.message);
209
+ throw error;
210
+ }
211
+ }
212
+ async acquireRefreshToken(sessionToken) {
213
+ if (sessionToken.isJwt) {
214
+ return await this.reacquireSecurityToken(sessionToken);
215
+ }
216
+ const claim = {
217
+ grant_type: "refresh_token",
218
+ refresh_token: sessionToken.refreshToken,
219
+ client_id: sessionToken.clientId,
220
+ client_secret: sessionToken.clientSecret
221
+ };
222
+ if (sessionToken["audience"]) {
223
+ claim["audience"] = sessionToken["audience"];
224
+ }
225
+ const urlSecurity = sessionToken.baseUrl + sessionToken.authenticationUrl;
226
+ debug("acquireRefreshToken - URL: %s", urlSecurity);
227
+ try {
228
+ const response = await fetch(urlSecurity, {
229
+ method: "POST",
230
+ headers: {
231
+ "Content-Type": "application/x-www-form-urlencoded"
232
+ },
233
+ body: new URLSearchParams(claim)
234
+ });
235
+ const body = await response.text();
236
+ if (response.status === 200) {
237
+ debug("acquireRefreshToken success");
238
+ const responseObject = JSON.parse(body);
239
+ sessionToken.accessToken = responseObject.access_token;
240
+ sessionToken.expiresIn = responseObject.expires_in;
241
+ sessionToken.refreshToken = responseObject.refresh_token;
242
+ sessionToken.tokenType = responseObject.token_type;
243
+ const expireDate = /* @__PURE__ */ new Date();
244
+ expireDate.setSeconds(expireDate.getSeconds() + sessionToken.expiresIn);
245
+ sessionToken.expirationDate = expireDate;
246
+ sessionToken.isAuthenticated = true;
247
+ return sessionToken;
248
+ } else if (response.status === 401 || response.status === 403 || response.status === 400) {
249
+ sessionToken.isAuthenticated = false;
250
+ throw new Error(`Authorization has been refused for current credentials (HTTP ${response.status}): ${body.substring(0, 200)}`);
251
+ } else {
252
+ sessionToken.isAuthenticated = false;
253
+ throw new Error(`Unknown response for access token: HTTP ${response.status}`);
254
+ }
255
+ } catch (error) {
256
+ sessionToken.isAuthenticated = false;
257
+ debug("acquireRefreshToken error: %s", error.message);
258
+ throw error;
259
+ }
260
+ }
261
+ async __getToken(clientId, clientSecret, userId, password, audience, baseUrl, customerAlias, databaseAlias, authenticationUrl) {
262
+ const sessionToken = new SessionToken();
263
+ const claim = {
264
+ grant_type: "password",
265
+ client_id: clientId,
266
+ client_secret: clientSecret,
267
+ username: userId,
268
+ password,
269
+ scope: "vault"
270
+ };
271
+ const urlSecurity = baseUrl + authenticationUrl;
272
+ debug("__getToken - URL: %s, user: %s, customer: %s/%s, audience: %s", urlSecurity, userId, customerAlias, databaseAlias, audience);
273
+ try {
274
+ const response = await fetch(urlSecurity, {
275
+ method: "POST",
276
+ headers: {
277
+ "Content-Type": "application/x-www-form-urlencoded"
278
+ },
279
+ body: new URLSearchParams(claim)
280
+ });
281
+ const body = await response.text();
282
+ if (response.status === 200) {
283
+ const responseObject = JSON.parse(body);
284
+ sessionToken.accessToken = responseObject.access_token;
285
+ sessionToken.expiresIn = responseObject.expires_in;
286
+ sessionToken.refreshToken = responseObject.refresh_token;
287
+ sessionToken.tokenType = responseObject.token_type;
288
+ const expireDate = /* @__PURE__ */ new Date();
289
+ expireDate.setSeconds(expireDate.getSeconds() + sessionToken.expiresIn);
290
+ sessionToken.expirationDate = expireDate;
291
+ sessionToken.isAuthenticated = true;
292
+ debug("__getToken success");
293
+ return sessionToken;
294
+ } else if (response.status === 401 || response.status === 403 || response.status === 400) {
295
+ sessionToken.isAuthenticated = false;
296
+ throw new Error(`Authorization has been refused for current credentials (HTTP ${response.status}): ${body.substring(0, 200)}`);
297
+ } else {
298
+ sessionToken.isAuthenticated = false;
299
+ throw new Error(`Unknown response for access token: HTTP ${response.status}`);
300
+ }
301
+ } catch (error) {
302
+ sessionToken.isAuthenticated = false;
303
+ debug("__getToken error: %s", error.message);
304
+ throw error;
305
+ }
306
+ }
307
+ async __getJwt(jwt, baseUrl, customerAlias, databaseAlias, authenticationUrl) {
308
+ const sessionToken = new SessionToken();
309
+ const headers = {
310
+ Authorization: "Bearer " + jwt
311
+ };
312
+ const urlSecurity = baseUrl + authenticationUrl;
313
+ debug("__getJwt - URL: %s, customer: %s/%s", urlSecurity, customerAlias, databaseAlias);
314
+ try {
315
+ const response = await fetch(urlSecurity, {
316
+ method: "GET",
317
+ headers
318
+ });
319
+ const body = await response.text();
320
+ if (response.status === 200) {
321
+ const responseObject = JSON.parse(body);
322
+ sessionToken.accessToken = responseObject.data.token;
323
+ sessionToken.expirationDate = new Date(responseObject.data.expires);
324
+ sessionToken.isAuthenticated = true;
325
+ sessionToken.isJwt = true;
326
+ debug("__getJwt success");
327
+ return sessionToken;
328
+ } else if (response.status === 401 || response.status === 403 || response.status === 400) {
329
+ sessionToken.isAuthenticated = false;
330
+ throw new Error(`Authorization has been refused for current credentials (HTTP ${response.status}): ${body.substring(0, 200)}`);
331
+ } else {
332
+ sessionToken.isAuthenticated = false;
333
+ throw new Error(`Unknown response for JWT: HTTP ${response.status}`);
334
+ }
335
+ } catch (error) {
336
+ sessionToken.isAuthenticated = false;
337
+ debug("__getJwt error: %s", error.message);
338
+ throw error;
339
+ }
340
+ }
341
+ endsWith(source, suffix) {
342
+ return source.indexOf(suffix, source.length - suffix.length) !== -1;
343
+ }
344
+ };
345
+ authorize_default = Authorize;
346
+ }
347
+ });
348
+
349
+ // lib/VVRestApi.js
350
+ var VVRestApi_exports = {};
351
+ __export(VVRestApi_exports, {
352
+ Authorize: () => Authorize2,
353
+ VVClient: () => VVClient,
354
+ default: () => VVRestApi_default,
355
+ forms: () => forms
356
+ });
357
+ module.exports = __toCommonJS(VVRestApi_exports);
358
+ init_cjs_shims();
359
+
360
+ // lib/DocApi.js
361
+ init_cjs_shims();
362
+
363
+ // lib/common.js
364
+ init_cjs_shims();
365
+
366
+ // lib/http/httpHelper.js
367
+ init_cjs_shims();
368
+ var import_debug2 = __toESM(require("debug"), 1);
369
+ var debug2 = (0, import_debug2.default)("visualvault:http");
370
+ var HttpHelper = class {
371
+ constructor(sessionToken, yamlConfig) {
372
+ this._sessionToken = sessionToken;
373
+ this._config = yamlConfig;
374
+ this._maxRetries = 3;
375
+ }
376
+ async doVvClientRequest(url, options, params, data, buffer) {
377
+ if (this._sessionToken.expirationDate < new Date((/* @__PURE__ */ new Date()).getTime() + 30 * 1e3)) {
378
+ debug2("accessToken has expired, calling __acquireRefreshToken");
379
+ try {
380
+ await this.__acquireRefreshToken();
381
+ debug2("return success from __acquireRefreshToken");
382
+ return await this.__doVvClientCallRequest(url, options, params, data, buffer);
383
+ } catch (error) {
384
+ debug2("return fail from __acquireRefreshToken: %s", error.message);
385
+ throw new Error("Unable to obtain Authorization, error: " + error);
386
+ }
387
+ } else {
388
+ return await this.__doVvClientCallRequest(url, options, params, data, buffer);
389
+ }
390
+ }
391
+ async __doVvClientCallRequest(url, options, params, data, buffer, retries = 0) {
392
+ try {
393
+ let responseData;
394
+ if (options.method === "GET") {
395
+ responseData = await this.httpGet(url, params);
396
+ } else if (options.method === "GETSTREAM") {
397
+ responseData = await this.httpGetStream(url, params);
398
+ } else if (options.method === "POST") {
399
+ responseData = await this.httpPost(url, params, data);
400
+ } else if (options.method === "POSTSTREAM") {
401
+ responseData = await this.httpPostStream(url, params, data, buffer);
402
+ } else if (options.method === "PUT") {
403
+ responseData = await this.httpPut(url, params, data);
404
+ } else if (options.method === "PUTSTREAM") {
405
+ responseData = await this.httpPutStream(url, params, data, buffer);
406
+ } else if (options.method === "DELETE") {
407
+ responseData = await this.httpDelete(url, params);
408
+ } else {
409
+ throw new Error("http request method name error");
410
+ }
411
+ return responseData;
412
+ } catch (error) {
413
+ if (error.status === 429 && retries < this._maxRetries) {
414
+ const timeout = this.__getRetryDelay(error.retryTime);
415
+ debug2("Timed Out: Retrying in %d ms. (%d retries left)", timeout, this._maxRetries - retries - 1);
416
+ await new Promise((resolve) => setTimeout(resolve, timeout));
417
+ return await this.__doVvClientCallRequest(url, options, params, data, buffer, retries + 1);
418
+ }
419
+ throw error;
420
+ }
421
+ }
422
+ async __makeRequest(url, options) {
423
+ const headers = {
424
+ "Authorization": "Bearer " + this._sessionToken.accessToken,
425
+ "Content-Type": "application/json"
426
+ };
427
+ debug2("Performing request to url: %s", url);
428
+ const fetchOptions = {
429
+ method: options.method,
430
+ headers: { ...headers, ...options.headers }
431
+ };
432
+ if (options.qs && Object.keys(options.qs).length > 0) {
433
+ const queryString = new URLSearchParams(options.qs).toString();
434
+ url = `${url}?${queryString}`;
435
+ }
436
+ if (options.json && (options.method === "POST" || options.method === "PUT")) {
437
+ fetchOptions.body = JSON.stringify(options.json);
438
+ }
439
+ const response = await fetch(url, fetchOptions);
440
+ const responseText = await response.text();
441
+ if (!response.ok) {
442
+ let parsedData;
443
+ try {
444
+ parsedData = JSON.parse(responseText);
445
+ } catch (e) {
446
+ parsedData = { meta: responseText };
447
+ }
448
+ if (response.status === 401 || response.status === 403) {
449
+ this._sessionToken.isAuthenticated = false;
450
+ throw new Error(JSON.stringify(parsedData.meta));
451
+ } else if (response.status === 429) {
452
+ const error = new Error(JSON.stringify(parsedData.meta));
453
+ error.status = 429;
454
+ error.retryTime = parsedData.meta?.retryTime;
455
+ throw error;
456
+ } else {
457
+ throw new Error(responseText);
458
+ }
459
+ }
460
+ return responseText;
461
+ }
462
+ async __makePostStreamRequest(url, options, buffer) {
463
+ debug2("Performing stream request to url: %s", url);
464
+ const formData = new FormData();
465
+ if (options.json) {
466
+ for (const key in options.json) {
467
+ if (options.json.hasOwnProperty(key)) {
468
+ formData.append(key, options.json[key]);
469
+ }
470
+ }
471
+ }
472
+ if (Buffer.isBuffer(buffer)) {
473
+ const filename = options.json?.fileName || "file";
474
+ const blob = new Blob([buffer]);
475
+ formData.append("fileUpload", blob, filename);
476
+ } else if (Array.isArray(buffer)) {
477
+ for (let i = 0; i < buffer.length; i++) {
478
+ const fileInfoObj = buffer[i];
479
+ if (Buffer.isBuffer(fileInfoObj.buffer)) {
480
+ const fileName = fileInfoObj.fileName || `file${i}`;
481
+ const blob = new Blob([fileInfoObj.buffer]);
482
+ formData.append("fileUpload", blob, fileName);
483
+ } else {
484
+ throw new Error(`Invalid 'buffer' property found on fileObj at index ${i}`);
485
+ }
486
+ }
487
+ } else {
488
+ throw new Error("Expecting Buffer");
489
+ }
490
+ const headers = {
491
+ "Authorization": "Bearer " + this._sessionToken.accessToken
492
+ };
493
+ const response = await fetch(url, {
494
+ method: options.method,
495
+ headers,
496
+ body: formData
497
+ });
498
+ const responseText = await response.text();
499
+ if (!response.ok) {
500
+ throw new Error(responseText);
501
+ }
502
+ return responseText;
503
+ }
504
+ async httpGet(url, params) {
505
+ const options = { method: "GET", qs: params || {}, headers: {}, json: null };
506
+ if (this._sessionToken.accessToken == null) {
507
+ throw new Error("Access token is null");
508
+ }
509
+ return await this.__makeRequest(url, options);
510
+ }
511
+ async httpGetStream(url, params) {
512
+ if (this._sessionToken.accessToken == null) {
513
+ throw new Error("Access token is null");
514
+ }
515
+ const headers = {
516
+ "Authorization": "Bearer " + this._sessionToken.accessToken,
517
+ "Content-Type": "application/json; charset=utf-8"
518
+ };
519
+ if (params && Object.keys(params).length > 0) {
520
+ const queryString = new URLSearchParams(params).toString();
521
+ url = `${url}?${queryString}`;
522
+ }
523
+ const response = await fetch(url, { method: "GET", headers });
524
+ if (!response.ok) {
525
+ throw new Error(`HTTP error! status: ${response.status}`);
526
+ }
527
+ const buffer = await response.arrayBuffer();
528
+ return Buffer.from(buffer);
529
+ }
530
+ async httpPost(url, params, data) {
531
+ const options = { method: "POST", qs: params || {}, json: data, headers: {} };
532
+ if (this._sessionToken.accessToken == null) {
533
+ throw new Error("Access token is null");
534
+ }
535
+ return await this.__makeRequest(url, options);
536
+ }
537
+ async httpPostStream(url, params, data, buffer) {
538
+ const options = { method: "POST", qs: params || {}, json: data, headers: {} };
539
+ if (this._sessionToken.accessToken == null) {
540
+ throw new Error("Access token is null");
541
+ }
542
+ return await this.__makePostStreamRequest(url, options, buffer);
543
+ }
544
+ async httpPut(url, params, data) {
545
+ const options = { method: "PUT", qs: params || {}, json: data, headers: {} };
546
+ if (this._sessionToken.accessToken == null) {
547
+ throw new Error("Access token is null");
548
+ }
549
+ return await this.__makeRequest(url, options);
550
+ }
551
+ async httpPutStream(url, params, data, buffer) {
552
+ const options = { method: "PUT", qs: params || {}, json: data, headers: {} };
553
+ if (this._sessionToken.accessToken == null) {
554
+ throw new Error("Access token is null");
555
+ }
556
+ return await this.__makePostStreamRequest(url, options, buffer);
557
+ }
558
+ async httpDelete(url, params) {
559
+ const options = { method: "DELETE", qs: params || {}, json: null, headers: {} };
560
+ if (this._sessionToken.accessToken == null) {
561
+ throw new Error("Access token is null");
562
+ }
563
+ return await this.__makeRequest(url, options);
564
+ }
565
+ async __acquireRefreshToken() {
566
+ this._sessionToken.isAuthenticated = false;
567
+ const { Authorize: Authorize3 } = await Promise.resolve().then(() => (init_authorize(), authorize_exports));
568
+ const vvAuthorize = new Authorize3();
569
+ try {
570
+ await vvAuthorize.acquireRefreshToken(this._sessionToken);
571
+ } catch (error) {
572
+ await vvAuthorize.reacquireSecurityToken(this._sessionToken);
573
+ }
574
+ }
575
+ request(httpVerb, url, params, data) {
576
+ const options = { method: httpVerb.toUpperCase() };
577
+ debug2("Performing %s request to url: %s", httpVerb.toUpperCase(), url);
578
+ return this.doVvClientRequest(url, options, params, data);
579
+ }
580
+ getUrl(resourceUrl) {
581
+ return this._sessionToken.baseUrl + this._sessionToken.apiUrl + resourceUrl;
582
+ }
583
+ __getRetryDelay(retryTime) {
584
+ let delay = 10;
585
+ if (retryTime && !isNaN(Date.parse(retryTime))) {
586
+ const now = /* @__PURE__ */ new Date();
587
+ delay = Date.parse(retryTime) - now.getTime();
588
+ if (delay < 0) {
589
+ delay *= -1;
590
+ }
591
+ }
592
+ return delay;
593
+ }
594
+ };
595
+
596
+ // lib/common.js
597
+ init_sessionToken();
598
+ init_authorize();
599
+ init_sessionToken();
600
+ init_authorize();
601
+ var common_default = {
602
+ httpHelper: HttpHelper,
603
+ sessionToken: SessionToken,
604
+ authorize: Authorize
605
+ };
606
+
607
+ // lib/docApi/documentInstanceManager.js
608
+ init_cjs_shims();
609
+ var DocumentInstanceManager = class {
610
+ constructor(httpHelper) {
611
+ this._httpHelper = httpHelper;
612
+ }
613
+ async GetRevision(documentRevisionId) {
614
+ let resourceUri = this._httpHelper._config.ResourceUri.DocApi.GetRevision;
615
+ resourceUri = resourceUri.replace("{id}", documentRevisionId);
616
+ const url = this._httpHelper.getUrl(resourceUri);
617
+ const opts = { method: "GET" };
618
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
619
+ }
620
+ async getDocumentOcrStatus(documentRevisionId) {
621
+ let resourceUri = this._httpHelper._config.ResourceUri.DocApi.OcrStatus;
622
+ resourceUri = resourceUri.replace("{id}", documentRevisionId);
623
+ const url = this._httpHelper.getUrl(resourceUri);
624
+ const opts = { method: "GET" };
625
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
626
+ }
627
+ async updateDocumentOcrStatus(documentRevisionId, data) {
628
+ let resourceUri = this._httpHelper._config.ResourceUri.DocApi.OcrStatus;
629
+ resourceUri = resourceUri.replace("{id}", documentRevisionId);
630
+ const url = this._httpHelper.getUrl(resourceUri);
631
+ const opts = { method: "PUT" };
632
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
633
+ }
634
+ async search(criteriaList, searchFolders, excludeFolders, sortBy, sortDirection = "desc", page = 0, take = 15, archiveType = 0, roleSecurity = false) {
635
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.DocApi.AdvancedSearch);
636
+ const data = {
637
+ criteriaList,
638
+ searchFolders,
639
+ excludeFolders,
640
+ sortBy,
641
+ sortDirection,
642
+ page,
643
+ take,
644
+ archiveType,
645
+ roleSecurity
646
+ };
647
+ const options = { method: "POST" };
648
+ return this._httpHelper.doVvClientRequest(url, options, null, data);
649
+ }
650
+ };
651
+
652
+ // lib/DocApi.js
653
+ var import_js_yaml2 = __toESM(require("js-yaml"), 1);
654
+ var import_fs2 = __toESM(require("fs"), 1);
655
+ var import_url = require("url");
656
+ var import_path = __toESM(require("path"), 1);
657
+ var __filename2 = (0, import_url.fileURLToPath)(importMetaUrl);
658
+ var __dirname = import_path.default.dirname(__filename2);
659
+ var DocApi = class {
660
+ constructor(sessionToken, docApiConfig) {
661
+ if (!sessionToken["tokenType"] && sessionToken["tokenType"] != "jwt") {
662
+ return;
663
+ }
664
+ const yamlConfig = import_js_yaml2.default.load(import_fs2.default.readFileSync(__dirname + "/config.yml", "utf8"));
665
+ this._httpHelper = new common_default.httpHelper(sessionToken, yamlConfig);
666
+ this.isEnabled = docApiConfig["isEnabled"] || false;
667
+ this.baseUrl = docApiConfig["apiUrl"] || null;
668
+ this.roleSecurity = docApiConfig["roleSecurity"] || false;
669
+ if (this.isEnabled) {
670
+ this.documentInstances = new DocumentInstanceManager(this._httpHelper);
671
+ }
672
+ }
673
+ };
674
+ var DocApi_default = DocApi;
675
+
676
+ // lib/FormsApi.js
677
+ init_cjs_shims();
678
+
679
+ // lib/formsApi/formInstanceManager.js
680
+ init_cjs_shims();
681
+ var FormInstanceManager = class {
682
+ constructor(httpHelper) {
683
+ this._httpHelper = httpHelper;
684
+ }
685
+ async postForm(params, data, formTemplateRevisionId) {
686
+ const resourceUri = this._httpHelper._config.ResourceUri.FormsApi.FormInstance;
687
+ const url = this._httpHelper.getUrl(resourceUri);
688
+ const opts = { method: "POST" };
689
+ data["formTemplateId"] = formTemplateRevisionId || data["formTemplateId"];
690
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
691
+ }
692
+ async postFormRevision(params, data, formTemplateRevisionId, formId) {
693
+ const resourceUri = this._httpHelper._config.ResourceUri.FormsApi.FormInstance;
694
+ const url = this._httpHelper.getUrl(resourceUri);
695
+ const opts = { method: "PUT" };
696
+ data["formTemplateId"] = formTemplateRevisionId || data["formTemplateId"];
697
+ data["formId"] = formId || data["formId"];
698
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
699
+ }
700
+ };
701
+ var formInstanceManager_default = FormInstanceManager;
702
+
703
+ // lib/FormsApi.js
704
+ var import_js_yaml3 = __toESM(require("js-yaml"), 1);
705
+ var import_fs3 = __toESM(require("fs"), 1);
706
+ var import_url2 = require("url");
707
+ var import_path2 = __toESM(require("path"), 1);
708
+ var __filename3 = (0, import_url2.fileURLToPath)(importMetaUrl);
709
+ var __dirname2 = import_path2.default.dirname(__filename3);
710
+ var FormsApi = class {
711
+ constructor(sessionToken, formsApiConfig) {
712
+ if (!sessionToken["tokenType"] && sessionToken["tokenType"] != "jwt") {
713
+ return;
714
+ }
715
+ const yamlConfig = import_js_yaml3.default.load(import_fs3.default.readFileSync(__dirname2 + "/config.yml", "utf8"));
716
+ this._httpHelper = new common_default.httpHelper(sessionToken, yamlConfig);
717
+ this.isEnabled = formsApiConfig["isEnabled"] || false;
718
+ this.baseUrl = formsApiConfig["formsApiUrl"] || null;
719
+ if (this.isEnabled) {
720
+ this.formInstances = new formInstanceManager_default(this._httpHelper);
721
+ }
722
+ }
723
+ };
724
+ var FormsApi_default = FormsApi;
725
+
726
+ // lib/ObjectsApi.js
727
+ init_cjs_shims();
728
+
729
+ // lib/objectsApi/modelsManager.js
730
+ init_cjs_shims();
731
+ var ModelsManager = class {
732
+ constructor(httpHelper) {
733
+ this._httpHelper = httpHelper;
734
+ }
735
+ /**
736
+ * Retrieves a list of available models
737
+ * @param {object} params - Optional URL parameters to include in the request
738
+ */
739
+ async getModels(params) {
740
+ const resourceUri = this._httpHelper._config.ResourceUri.ObjectsApi.Models;
741
+ const url = this._httpHelper.getUrl(resourceUri);
742
+ const opts = { method: "GET" };
743
+ params = params || {};
744
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
745
+ }
746
+ /**
747
+ * Retrieves a specific model by its ID
748
+ * @param {string} modelId - The ID (Guid) for the requested model
749
+ * @param {object} params - Optional URL parameters to include in the request
750
+ */
751
+ async getModelById(modelId, params) {
752
+ let resourceUri = this._httpHelper._config.ResourceUri.ObjectsApi.ModelById;
753
+ resourceUri = resourceUri.replace("{id}", modelId);
754
+ const url = this._httpHelper.getUrl(resourceUri);
755
+ const opts = { method: "GET" };
756
+ params = params || {};
757
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
758
+ }
759
+ };
760
+ var modelsManager_default = ModelsManager;
761
+
762
+ // lib/objectsApi/objectsManager.js
763
+ init_cjs_shims();
764
+ var ObjectsManager = class {
765
+ constructor(httpHelper) {
766
+ this._httpHelper = httpHelper;
767
+ }
768
+ /**
769
+ * Retrieves a specific object by its ID
770
+ * @param {string} objectId - The ID (Guid) for the requested object
771
+ * @param {object} params - Optional URL parameters to include in the request
772
+ */
773
+ async getObject(objectId, params) {
774
+ let resourceUri = this._httpHelper._config.ResourceUri.ObjectsApi.ObjectById;
775
+ resourceUri = resourceUri.replace("{id}", objectId);
776
+ const url = this._httpHelper.getUrl(resourceUri);
777
+ const opts = { method: "GET" };
778
+ params = params || {};
779
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
780
+ }
781
+ /**
782
+ * Retrieves a paged list of objects associated with a given model
783
+ * @param {string} modelId - The ID (Guid) for the requested model to search
784
+ * @param {object} data - Data to send in the request body
785
+ * @param {object} params - Optional URL parameters to include in the request
786
+ */
787
+ async getObjectsByModelId(modelId, data, params) {
788
+ let resourceUri = this._httpHelper._config.ResourceUri.ObjectsApi.ObjectSearchByModelId;
789
+ resourceUri = resourceUri.replace("{modelId}", modelId);
790
+ const url = this._httpHelper.getUrl(resourceUri);
791
+ const opts = { method: "POST" };
792
+ data = data || {};
793
+ params = params || {};
794
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
795
+ }
796
+ /**
797
+ * Creates a new object adhering to a given model
798
+ * @param {string} modelId - The ID (Guid) used to create a new object for that model
799
+ * @param {object} data - Data to send in the request body
800
+ * @param {object} params - Optional URL parameters to include in the request
801
+ */
802
+ async createObject(modelId, data, params) {
803
+ const resourceUri = this._httpHelper._config.ResourceUri.ObjectsApi.Object;
804
+ const url = this._httpHelper.getUrl(resourceUri);
805
+ const opts = { method: "POST" };
806
+ data = data || {};
807
+ params = params || {};
808
+ data["modelId"] = modelId || data["modelId"];
809
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
810
+ }
811
+ /**
812
+ * Updates an existing object by its ID (Guid) and revision ID (Guid)
813
+ * @param {string} objectId - The ID (Guid) for the requested object to update
814
+ * @param {string} objectRevisionId - The revision ID (Guid) for the requested object to update
815
+ * @param {object} data - Data to send in the request body
816
+ * @param {object} params - Optional URL parameters to include in the request
817
+ */
818
+ async updateObject(objectId, objectRevisionId, data, params) {
819
+ let resourceUri = this._httpHelper._config.ResourceUri.ObjectsApi.ObjectById;
820
+ resourceUri = resourceUri.replace("{id}", objectId);
821
+ const url = this._httpHelper.getUrl(resourceUri);
822
+ const opts = { method: "PUT" };
823
+ data = data || {};
824
+ params = params || {};
825
+ data["revisionId"] = objectRevisionId || data["revisionId"];
826
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
827
+ }
828
+ /**
829
+ * Deletes an existing object by its ID (Guid)
830
+ * @param {string} objectId - The ID (Guid) for the requested object to delete
831
+ * @param {object} params - Optional URL parameters to include in the request
832
+ */
833
+ async deleteObject(objectId, params) {
834
+ let resourceUri = this._httpHelper._config.ResourceUri.ObjectsApi.ObjectById;
835
+ resourceUri = resourceUri.replace("{id}", objectId);
836
+ const url = this._httpHelper.getUrl(resourceUri);
837
+ const opts = { method: "DELETE" };
838
+ params = params || {};
839
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
840
+ }
841
+ };
842
+ var objectsManager_default = ObjectsManager;
843
+
844
+ // lib/ObjectsApi.js
845
+ var import_js_yaml4 = __toESM(require("js-yaml"), 1);
846
+ var import_fs4 = __toESM(require("fs"), 1);
847
+ var import_url3 = require("url");
848
+ var import_path3 = __toESM(require("path"), 1);
849
+ var __filename4 = (0, import_url3.fileURLToPath)(importMetaUrl);
850
+ var __dirname3 = import_path3.default.dirname(__filename4);
851
+ var ObjectsApi = class {
852
+ constructor(sessionToken, objectsApiConfig) {
853
+ if (!sessionToken["tokenType"] && sessionToken["tokenType"] != "jwt") {
854
+ return;
855
+ }
856
+ const yamlConfig = import_js_yaml4.default.load(import_fs4.default.readFileSync(__dirname3 + "/config.yml", "utf8"));
857
+ this._httpHelper = new common_default.httpHelper(sessionToken, yamlConfig);
858
+ this.isEnabled = objectsApiConfig["isEnabled"] || false;
859
+ this.baseUrl = objectsApiConfig["apiUrl"] || null;
860
+ if (this.isEnabled) {
861
+ this.models = new modelsManager_default(this._httpHelper);
862
+ this.objects = new objectsManager_default(this._httpHelper);
863
+ }
864
+ }
865
+ };
866
+ var ObjectsApi_default = ObjectsApi;
867
+
868
+ // lib/StudioApi.js
869
+ init_cjs_shims();
870
+
871
+ // lib/studioApi/workflowManager.js
872
+ init_cjs_shims();
873
+ var WorkflowManager = class {
874
+ constructor(httpHelper) {
875
+ this._httpHelper = httpHelper;
876
+ }
877
+ async getWorkflow(workflowId) {
878
+ const resourceUri = this._httpHelper._config.ResourceUri.StudioApi.WorkflowLatestPublishedId.replace("{id}", workflowId);
879
+ const url = this._httpHelper.getUrl(resourceUri);
880
+ const opts = { method: "GET" };
881
+ const data = {};
882
+ const params = {};
883
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
884
+ }
885
+ async getWorkflowByName(workflowName) {
886
+ const resourceUri = this._httpHelper._config.ResourceUri.StudioApi.WorkflowLatestPublished;
887
+ const url = this._httpHelper.getUrl(resourceUri);
888
+ const opts = { method: "GET" };
889
+ const data = {};
890
+ const params = { name: workflowName };
891
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
892
+ }
893
+ async getWorkflowVariables(params, workflowId) {
894
+ const resourceUri = this._httpHelper._config.ResourceUri.StudioApi.WorkflowVariables.replace("{id}", workflowId);
895
+ const url = this._httpHelper.getUrl(resourceUri);
896
+ const opts = { method: "GET" };
897
+ const data = {};
898
+ params = params || {};
899
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
900
+ }
901
+ /**
902
+ * Triggers workflow
903
+ * @param {string} workflowId
904
+ * @param {number} workflowRevision
905
+ * @param {string} objectId
906
+ * @param {object[]} workflowVariables - workflow values to be submitted to the workflow
907
+ * * @param {string} workflowVariables[].name = name of variable
908
+ * * @param {*} workflowVariables[].value - value to be passed
909
+ * * @param {number} workflowVariables[].dataType - Text: 1, Number: 2, Date: 3, Boolean: 4
910
+ */
911
+ async triggerWorkflow(workflowId, workflowRevision, objectId, workflowVariables) {
912
+ const resourceUri = this._httpHelper._config.ResourceUri.StudioApi.WorkflowRun.replace("{id}", workflowId).replace("{revision}", workflowRevision);
913
+ const url = this._httpHelper.getUrl(resourceUri);
914
+ const opts = { method: "POST" };
915
+ const data = {
916
+ objectId,
917
+ reference: "API",
918
+ data: {
919
+ workflowVariables,
920
+ dataSetVariables: []
921
+ }
922
+ };
923
+ const params = {};
924
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
925
+ }
926
+ /**
927
+ * Terminates the workflow instance
928
+ * @param {string} workflowId
929
+ * @param {string} instanceId
930
+ * @returns
931
+ */
932
+ async terminateWorkflow(workflowId, instanceId) {
933
+ const resourceUri = this._httpHelper._config.ResourceUri.StudioApi.WorkflowTerminate.replace("{workflowId}", workflowId).replace("{instanceId}", instanceId);
934
+ const url = this._httpHelper.getUrl(resourceUri);
935
+ const opts = { method: "POST" };
936
+ const data = {};
937
+ const params = {};
938
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
939
+ }
940
+ /**
941
+ * Returns workflow history for an object under the provided workflow
942
+ * @param {string} workflowId
943
+ * @param {string} objectId
944
+ * @returns
945
+ */
946
+ async GetWorkflowHistoryForObject(objectId, workflowId) {
947
+ const resourceUri = this._httpHelper._config.ResourceUri.StudioApi.WorkflowHistoryObject.replace("{workflowId}", workflowId).replace("{objectId}", objectId);
948
+ const url = this._httpHelper.getUrl(resourceUri);
949
+ const opts = { method: "GET" };
950
+ const data = {};
951
+ const params = {};
952
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
953
+ }
954
+ /**
955
+ * Returns the running workflow, if any, for an object under the provided workflow
956
+ * @param {string} workflowId
957
+ * @param {string} objectId
958
+ * @returns
959
+ */
960
+ async GetRunningWorkflowForObject(objectId, workflowId) {
961
+ const resourceUri = this._httpHelper._config.ResourceUri.StudioApi.WorkflowHistoryRunningObject.replace("{workflowId}", workflowId).replace("{objectId}", objectId);
962
+ const url = this._httpHelper.getUrl(resourceUri);
963
+ const opts = { method: "GET" };
964
+ const data = {};
965
+ const params = {};
966
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
967
+ }
968
+ };
969
+ var workflowManager_default = WorkflowManager;
970
+
971
+ // lib/StudioApi.js
972
+ var import_js_yaml5 = __toESM(require("js-yaml"), 1);
973
+ var import_fs5 = __toESM(require("fs"), 1);
974
+ var import_url4 = require("url");
975
+ var import_path4 = __toESM(require("path"), 1);
976
+ var __filename5 = (0, import_url4.fileURLToPath)(importMetaUrl);
977
+ var __dirname4 = import_path4.default.dirname(__filename5);
978
+ var StudioApi = class {
979
+ constructor(sessionToken, studioApiConfig) {
980
+ if (!sessionToken["tokenType"] && sessionToken["tokenType"] != "jwt") {
981
+ return;
982
+ }
983
+ const yamlConfig = import_js_yaml5.default.load(import_fs5.default.readFileSync(__dirname4 + "/config.yml", "utf8"));
984
+ this._httpHelper = new common_default.httpHelper(sessionToken, yamlConfig);
985
+ this.isEnabled = studioApiConfig["isEnabled"] || false;
986
+ this.baseUrl = studioApiConfig["studioApiUrl"] || null;
987
+ if (this.isEnabled) {
988
+ this.workflow = new workflowManager_default(this._httpHelper);
989
+ }
990
+ }
991
+ };
992
+ var StudioApi_default = StudioApi;
993
+
994
+ // lib/NotificationsApi.js
995
+ init_cjs_shims();
996
+
997
+ // lib/notificationsApi/userNotificationsManager.js
998
+ init_cjs_shims();
999
+ var UserNotificationsManager = class {
1000
+ constructor(httpHelper) {
1001
+ this._httpHelper = httpHelper;
1002
+ }
1003
+ async forceUIRefresh(userGuid) {
1004
+ const resourceUri = this._httpHelper._config.ResourceUri.NotificationsApi.ForceUIRefresh.replace("{id}", userGuid);
1005
+ const url = this._httpHelper.getUrl(resourceUri);
1006
+ const opts = { method: "POST" };
1007
+ const params = {};
1008
+ const data = {};
1009
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1010
+ }
1011
+ };
1012
+ var userNotificationsManager_default = UserNotificationsManager;
1013
+
1014
+ // lib/NotificationsApi.js
1015
+ var import_js_yaml6 = __toESM(require("js-yaml"), 1);
1016
+ var import_fs6 = __toESM(require("fs"), 1);
1017
+ var import_url5 = require("url");
1018
+ var import_path5 = __toESM(require("path"), 1);
1019
+ var __filename6 = (0, import_url5.fileURLToPath)(importMetaUrl);
1020
+ var __dirname5 = import_path5.default.dirname(__filename6);
1021
+ var NotificationsApi = class {
1022
+ constructor(sessionToken, notificationsApiConfig) {
1023
+ if (!sessionToken["tokenType"] && sessionToken["tokenType"] != "jwt") {
1024
+ return;
1025
+ }
1026
+ const yamlConfig = import_js_yaml6.default.load(import_fs6.default.readFileSync(__dirname5 + "/config.yml", "utf8"));
1027
+ this._httpHelper = new common_default.httpHelper(sessionToken, yamlConfig);
1028
+ this.isEnabled = notificationsApiConfig["isEnabled"] || false;
1029
+ this.baseUrl = notificationsApiConfig["apiUrl"] || null;
1030
+ if (this.isEnabled) {
1031
+ this.users = new userNotificationsManager_default(this._httpHelper);
1032
+ }
1033
+ }
1034
+ };
1035
+ var NotificationsApi_default = NotificationsApi;
1036
+
1037
+ // lib/VVRestApi.js
1038
+ var import_js_yaml7 = __toESM(require("js-yaml"), 1);
1039
+ var import_fs7 = __toESM(require("fs"), 1);
1040
+ var import_url6 = require("url");
1041
+ var import_path6 = __toESM(require("path"), 1);
1042
+ var import_debug5 = __toESM(require("debug"), 1);
1043
+
1044
+ // lib/vvRestApi/constants.js
1045
+ init_cjs_shims();
1046
+ var Constants = class {
1047
+ constructor() {
1048
+ }
1049
+ alertEventIds = {
1050
+ // Folder Events
1051
+ folderSecurityModified: "F06FD123-2C52-4F43-9122-34335A5BD8C6",
1052
+ // "CategorySecurity"
1053
+ childFolderSecurityModified: "30167D46-86CF-4E89-B1AE-FC00BB378F67",
1054
+ // "CategorySecurityCascade"
1055
+ folderDocumentAdded: "3702CFBF-555C-4032-BFB2-E25829788BAC",
1056
+ // "NewCategoryDoc"
1057
+ childFolderDocumentAdded: "28946E3C-AEAF-402B-BCE3-8DEAC3D19877",
1058
+ // "NewCategoryDocCascade"
1059
+ // Document Events
1060
+ documentCheckedIn: "D47804AB-AEE9-4002-BAB5-9F1AC0366076",
1061
+ // "CheckIn"
1062
+ documentCheckedOut: "4BBA55C1-7AF6-48FF-BFBE-EC7A58EB7F01",
1063
+ // "CheckOut"
1064
+ documentDetailsModified: "3B9D493F-2B45-4877-ABC1-5CA74F92723D",
1065
+ // "DocumentDetails"
1066
+ documentSecurityModified: "BAC187DC-78A8-4A8B-B50F-DB5D5AEE11B9",
1067
+ // "DocumentSecurity"
1068
+ documentViewed: "140B9E97-8D93-48D0-837B-AB4FD419B6D6",
1069
+ // "DocumentViewed"
1070
+ // Project Events
1071
+ projectDocumentAddedOrRemoved: "300DB724-5C51-4C38-B2E2-FFE19634A373",
1072
+ // "NewProjectDoc"
1073
+ projectViewed: "92F0C5F4-68DC-4309-9ABF-13B8E2198F79"
1074
+ // "ProjectView"
1075
+ };
1076
+ securityRoles = {
1077
+ // RoleType
1078
+ Owner: "Owner",
1079
+ Editor: "Editor",
1080
+ Viewer: "Viewer"
1081
+ };
1082
+ securityMemberType = {
1083
+ // MemberType
1084
+ User: "User",
1085
+ Group: "Group"
1086
+ };
1087
+ relationType = {
1088
+ Parent: "Parent",
1089
+ Child: "Child",
1090
+ Peer: "Peer"
1091
+ };
1092
+ };
1093
+
1094
+ // lib/vvRestApi/configurationManager.js
1095
+ init_cjs_shims();
1096
+ var ConfigurationManager = class {
1097
+ constructor(httpHelper) {
1098
+ this._httpHelper = httpHelper;
1099
+ }
1100
+ getDocApiConfig() {
1101
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.ConfigurationDocApi);
1102
+ const opts = { method: "GET" };
1103
+ const params = {};
1104
+ const data = {};
1105
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1106
+ }
1107
+ getFormsApiConfig() {
1108
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.ConfigurationFormsApi);
1109
+ const opts = { method: "GET" };
1110
+ const params = {};
1111
+ const data = {};
1112
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1113
+ }
1114
+ getObjectsApiConfig() {
1115
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.ConfigurationObjectsApi);
1116
+ const opts = { method: "GET" };
1117
+ const params = {};
1118
+ const data = {};
1119
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1120
+ }
1121
+ getStudioApiConfig() {
1122
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.ConfigurationStudioApi);
1123
+ const opts = { method: "GET" };
1124
+ const params = {};
1125
+ const data = {};
1126
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1127
+ }
1128
+ getNotificationsApiConfig() {
1129
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.ConfigurationNotificationApi);
1130
+ const opts = { method: "GET" };
1131
+ const params = {};
1132
+ const data = {};
1133
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1134
+ }
1135
+ };
1136
+
1137
+ // lib/vvRestApi/emailManager.js
1138
+ init_cjs_shims();
1139
+ var EmailManager = class {
1140
+ constructor(httpHelper) {
1141
+ this._httpHelper = httpHelper;
1142
+ }
1143
+ postEmails(params, data) {
1144
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.Emails);
1145
+ const opts = { method: "POST" };
1146
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1147
+ }
1148
+ postEmailsWithAttachments(params, data, fileObjs) {
1149
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.Emails);
1150
+ const opts = { method: "POSTSTREAM" };
1151
+ return this._httpHelper.doVvClientRequest(url, opts, params, data, fileObjs);
1152
+ }
1153
+ };
1154
+
1155
+ // lib/vvRestApi/formsManager.js
1156
+ init_cjs_shims();
1157
+ var import_debug3 = __toESM(require("debug"), 1);
1158
+ var debug3 = (0, import_debug3.default)("visualvault:forms");
1159
+ var ReturnField = class {
1160
+ /** @type {string} */
1161
+ id;
1162
+ /** @type {string} */
1163
+ name;
1164
+ /** @type {*} */
1165
+ value;
1166
+ /** @type {boolean} */
1167
+ isError;
1168
+ /** @type {string} */
1169
+ errorMessage;
1170
+ /**
1171
+ * @param {string} id - Field ID
1172
+ * @param {string} name - Field name
1173
+ * @param {*} value - Field value
1174
+ * @param {boolean} isError - Whether field has an error
1175
+ * @param {string} errorMessage - Error message if any
1176
+ */
1177
+ constructor(id, name, value, isError, errorMessage) {
1178
+ this.id = id;
1179
+ this.name = name;
1180
+ this.value = value;
1181
+ this.isError = isError;
1182
+ this.errorMessage = errorMessage;
1183
+ }
1184
+ };
1185
+ var FormFieldCollection = class {
1186
+ /**
1187
+ * @param {Array<*>} ffColl - Array of form fields
1188
+ */
1189
+ constructor(ffColl) {
1190
+ this._ffColl = ffColl;
1191
+ }
1192
+ /**
1193
+ * Get a form field by name
1194
+ * @param {string} name - Field name to search for
1195
+ * @returns {*} The field or null if not found
1196
+ */
1197
+ getFormFieldByName(name) {
1198
+ const fieldName = name.toLowerCase();
1199
+ return this._ffColl.find(
1200
+ (field) => field.name.toLowerCase() === fieldName
1201
+ ) || null;
1202
+ }
1203
+ /**
1204
+ * Get a form field by ID
1205
+ * @param {string} id - Field ID to search for
1206
+ * @returns {*} The field or null if not found
1207
+ */
1208
+ getFormFieldById(id) {
1209
+ const fieldId = id.toLowerCase();
1210
+ return this._ffColl.find(
1211
+ (field) => field.id.toLowerCase() === fieldId
1212
+ ) || null;
1213
+ }
1214
+ /**
1215
+ * Get the array of all form fields
1216
+ * @returns {Array<*>} Array of form fields
1217
+ */
1218
+ getFieldArray() {
1219
+ return this._ffColl;
1220
+ }
1221
+ };
1222
+ var FormsManager = class {
1223
+ /**
1224
+ * @param {*} httpHelper - HTTP helper instance
1225
+ */
1226
+ constructor(httpHelper) {
1227
+ this._httpHelper = httpHelper;
1228
+ }
1229
+ returnField(id, name, value, isError, errorMessage) {
1230
+ return new ReturnField(id, name, value, isError, errorMessage);
1231
+ }
1232
+ getFormTemplates(params) {
1233
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.FormTemplates);
1234
+ const opts = { method: "GET" };
1235
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1236
+ }
1237
+ /**
1238
+ * @param {string} templateName
1239
+ * @returns {Promise<{formsManager: FormsManager, templateIdGuid: string, templateRevisionIdGuid: string, error?: string}>}
1240
+ */
1241
+ async getFormTemplateIdByName(templateName) {
1242
+ const params = {
1243
+ fields: "id, name, description, revision, revisionId",
1244
+ q: `name eq '${templateName}'`
1245
+ };
1246
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.FormTemplates);
1247
+ const opts = { method: "GET" };
1248
+ try {
1249
+ const resp = await this._httpHelper.doVvClientRequest(url, opts, params, null);
1250
+ const templateResp = JSON.parse(resp);
1251
+ let templateId;
1252
+ let templateRevisionId;
1253
+ if (templateResp.data && templateResp.data.length > 0) {
1254
+ templateId = templateResp.data[0].id;
1255
+ templateRevisionId = templateResp.data[0].revisionId;
1256
+ }
1257
+ return {
1258
+ formsManager: this,
1259
+ templateIdGuid: templateId,
1260
+ templateRevisionIdGuid: templateRevisionId
1261
+ };
1262
+ } catch (error) {
1263
+ debug3('Failed to get form template by name "%s": %s', templateName, error.message);
1264
+ return {
1265
+ formsManager: this,
1266
+ templateIdGuid: "",
1267
+ templateRevisionIdGuid: "",
1268
+ error: error.message
1269
+ };
1270
+ }
1271
+ }
1272
+ async getForms(params, formTemplateId) {
1273
+ if (!this.isGuid(formTemplateId)) {
1274
+ const resp = await this.getFormTemplateIdByName(formTemplateId);
1275
+ const templateIdGuid = resp.templateIdGuid;
1276
+ const resourceUri = this._httpHelper._config.ResourceUri.Forms.replace("{id}", templateIdGuid);
1277
+ const url = this._httpHelper.getUrl(resourceUri);
1278
+ const opts = { method: "GET" };
1279
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1280
+ } else {
1281
+ const resourceUri = this._httpHelper._config.ResourceUri.Forms.replace("{id}", formTemplateId);
1282
+ const url = this._httpHelper.getUrl(resourceUri);
1283
+ const opts = { method: "GET" };
1284
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1285
+ }
1286
+ }
1287
+ setFieldImage(formId, fieldId, imageId) {
1288
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstanceImage.replace("{id}", formId);
1289
+ const url = this._httpHelper.getUrl(resourceUri);
1290
+ const data = { fieldId, imageId };
1291
+ const params = { fieldId, imageId };
1292
+ const opts = { method: "PUT" };
1293
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1294
+ }
1295
+ importFormTemplate(data, formTemplateId, buffer) {
1296
+ const resourceUri = this._httpHelper._config.ResourceUri.FormTemplatesImport.replace("{id}", formTemplateId);
1297
+ const url = this._httpHelper.getUrl(resourceUri);
1298
+ const opts = { method: "PUTSTREAM" };
1299
+ return this._httpHelper.doVvClientRequest(url, opts, null, data, buffer);
1300
+ }
1301
+ async postForms(params, data, formTemplateId) {
1302
+ if (!this.isGuid(formTemplateId)) {
1303
+ const resp = await this.getFormTemplateIdByName(formTemplateId);
1304
+ const templateIdGuid = resp.templateIdGuid;
1305
+ const resourceUri = this._httpHelper._config.ResourceUri.Forms.replace("{id}", templateIdGuid);
1306
+ const url = this._httpHelper.getUrl(resourceUri);
1307
+ const opts = { method: "POST" };
1308
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1309
+ } else {
1310
+ const resourceUri = this._httpHelper._config.ResourceUri.Forms.replace("{id}", formTemplateId);
1311
+ const url = this._httpHelper.getUrl(resourceUri);
1312
+ const opts = { method: "POST" };
1313
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1314
+ }
1315
+ }
1316
+ async postFormRevision(params, data, formTemplateId, formId) {
1317
+ if (!this.isGuid(formTemplateId)) {
1318
+ const resp = await this.getFormTemplateIdByName(formTemplateId);
1319
+ const templateIdGuid = resp.templateIdGuid;
1320
+ const resourceUri = this._httpHelper._config.ResourceUri.Forms.replace("{id}", templateIdGuid);
1321
+ const url = this._httpHelper.getUrl(resourceUri + "/" + formId);
1322
+ const opts = { method: "POST" };
1323
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1324
+ } else {
1325
+ const resourceUri = this._httpHelper._config.ResourceUri.Forms.replace("{id}", formTemplateId);
1326
+ const url = this._httpHelper.getUrl(resourceUri + "/" + formId);
1327
+ const opts = { method: "POST" };
1328
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1329
+ }
1330
+ }
1331
+ postFormRevisionByFormId(params, data, formId) {
1332
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.FormsId).replace("{id}", formId);
1333
+ const opts = { method: "POST" };
1334
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1335
+ }
1336
+ updateFormInstanceOriginator(formInstanceId, newOriginatorUsID) {
1337
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstanceUpdateOriginator.replace("{id}", formInstanceId);
1338
+ const url = this._httpHelper.getUrl(resourceUri);
1339
+ const params = { userId: newOriginatorUsID };
1340
+ const data = null;
1341
+ const opts = { method: "PUT" };
1342
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1343
+ }
1344
+ relateForm(formId, relateToId) {
1345
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1346
+ const url = this._httpHelper.getUrl(resourceUri + "/relateForm");
1347
+ const params = { relateToId };
1348
+ const data = null;
1349
+ const opts = { method: "PUT" };
1350
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1351
+ }
1352
+ relateFormByDocId(formId, relateToDocId) {
1353
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1354
+ const url = this._httpHelper.getUrl(resourceUri + "/relateForm");
1355
+ const params = { relateToDocId };
1356
+ const data = null;
1357
+ const opts = { method: "PUT" };
1358
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1359
+ }
1360
+ relateDocument(formId, relateToId) {
1361
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1362
+ const url = this._httpHelper.getUrl(resourceUri + "/relateDocument");
1363
+ const params = { relateToId };
1364
+ const data = null;
1365
+ const opts = { method: "PUT" };
1366
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1367
+ }
1368
+ relateDocumentByDocId(formId, relateToDocId) {
1369
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1370
+ const url = this._httpHelper.getUrl(resourceUri + "/relateDocument");
1371
+ const params = { relateToDocId };
1372
+ const data = null;
1373
+ const opts = { method: "PUT" };
1374
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1375
+ }
1376
+ relateProject(formId, relateToId) {
1377
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1378
+ const url = this._httpHelper.getUrl(resourceUri + "/relateProject");
1379
+ const params = { relateToId };
1380
+ const data = null;
1381
+ const opts = { method: "PUT" };
1382
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1383
+ }
1384
+ relateProjectByName(formId, relateToProjectName) {
1385
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1386
+ const url = this._httpHelper.getUrl(resourceUri + "/relateProject");
1387
+ const params = { relateToProjectName };
1388
+ const data = null;
1389
+ const opts = { method: "PUT" };
1390
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1391
+ }
1392
+ unrelateForm(formId, relateToId) {
1393
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1394
+ const url = this._httpHelper.getUrl(resourceUri + "/unrelateForm");
1395
+ const params = { relateToId };
1396
+ const data = null;
1397
+ const opts = { method: "PUT" };
1398
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1399
+ }
1400
+ unrelateFormByDocId(formId, relateToDocId) {
1401
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1402
+ const url = this._httpHelper.getUrl(resourceUri + "/unrelateForm");
1403
+ const params = { relateToDocId };
1404
+ const data = null;
1405
+ const opts = { method: "PUT" };
1406
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1407
+ }
1408
+ unrelateDocument(formId, relateToId) {
1409
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1410
+ const url = this._httpHelper.getUrl(resourceUri + "/unrelateDocument");
1411
+ const params = { relateToId };
1412
+ const data = null;
1413
+ const opts = { method: "PUT" };
1414
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1415
+ }
1416
+ unrelateDocumentByDocId(formId, relateToDocId) {
1417
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1418
+ const url = this._httpHelper.getUrl(resourceUri + "/unrelateDocument");
1419
+ const params = { relateToDocId };
1420
+ const data = null;
1421
+ const opts = { method: "PUT" };
1422
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1423
+ }
1424
+ unrelateProject(formId, relateToId) {
1425
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1426
+ const url = this._httpHelper.getUrl(resourceUri + "/unrelateProject");
1427
+ const params = { relateToId };
1428
+ const data = null;
1429
+ const opts = { method: "PUT" };
1430
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1431
+ }
1432
+ unrelateProjectByName(formId, relateToProjectName) {
1433
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1434
+ const url = this._httpHelper.getUrl(resourceUri + "/unrelateProject");
1435
+ const params = { relateToProjectName };
1436
+ const data = null;
1437
+ const opts = { method: "PUT" };
1438
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1439
+ }
1440
+ getFormRelatedDocs(formId, params) {
1441
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstanceRelatedDocs.replace("{id}", formId);
1442
+ const url = this._httpHelper.getUrl(resourceUri);
1443
+ const opts = { method: "GET" };
1444
+ if (params === void 0) {
1445
+ params = null;
1446
+ }
1447
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1448
+ }
1449
+ getFormRelatedForms(formId, params) {
1450
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstanceRelatedForms.replace("{id}", formId);
1451
+ const url = this._httpHelper.getUrl(resourceUri);
1452
+ const opts = { method: "GET" };
1453
+ if (params === void 0) {
1454
+ params = null;
1455
+ }
1456
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1457
+ }
1458
+ isGuid(stringToTest) {
1459
+ let testString = stringToTest;
1460
+ if (testString[0] === "{") {
1461
+ testString = testString.substring(1, testString.length - 1);
1462
+ }
1463
+ const regexGuid = /^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$/gi;
1464
+ return regexGuid.test(testString);
1465
+ }
1466
+ getFormInstanceById(templateId, instanceId) {
1467
+ const resourceUri = this._httpHelper._config.ResourceUri.FormId.replace("{id}", templateId).replace("{formId}", instanceId);
1468
+ const url = this._httpHelper.getUrl(resourceUri);
1469
+ const opts = { method: "GET" };
1470
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1471
+ }
1472
+ getFormInstancePDF(templateId, instanceId) {
1473
+ const resourceUri = this._httpHelper._config.ResourceUri.FormIdPdf.replace("{id}", templateId).replace("{formId}", instanceId);
1474
+ const url = this._httpHelper.getUrl(resourceUri);
1475
+ const opts = { method: "GETSTREAM" };
1476
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1477
+ }
1478
+ getFormTemplateFields(templateId) {
1479
+ const resourceUri = this._httpHelper._config.ResourceUri.FormDesignerFormsTemplatesIdFields.replace("{id}", templateId);
1480
+ const url = this._httpHelper.getUrl(resourceUri);
1481
+ const opts = { method: "GET" };
1482
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1483
+ }
1484
+ deleteFormInstance(instanceId) {
1485
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", instanceId);
1486
+ const url = this._httpHelper.getUrl(resourceUri);
1487
+ const opts = { method: "DELETE" };
1488
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1489
+ }
1490
+ releaseFormTemplate(formTemplateId) {
1491
+ const resourceUri = this._httpHelper._config.ResourceUri.FormTemplatesRelease.replace("{id}", formTemplateId);
1492
+ const url = this._httpHelper.getUrl(resourceUri);
1493
+ const opts = { method: "PUT" };
1494
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1495
+ }
1496
+ };
1497
+
1498
+ // lib/vvRestApi/groupsManager.js
1499
+ init_cjs_shims();
1500
+ var GroupsManager = class {
1501
+ constructor(httpHelper) {
1502
+ this._httpHelper = httpHelper;
1503
+ }
1504
+ getGroups(params) {
1505
+ const resourceUri = this._httpHelper._config.ResourceUri.GetGroups;
1506
+ const url = this._httpHelper.getUrl(resourceUri);
1507
+ const opts = { method: "GET" };
1508
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1509
+ }
1510
+ getGroupsUsers(params, groupId) {
1511
+ const resourceUri = this._httpHelper._config.ResourceUri.GroupsUsers.replace("{id}", groupId);
1512
+ const url = this._httpHelper.getUrl(resourceUri);
1513
+ const opts = { method: "GET" };
1514
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1515
+ }
1516
+ getGroupUser(params, groupId, userId) {
1517
+ const resourceUri = this._httpHelper._config.ResourceUri.GroupsAddUser.replace("{groupId}", groupId).replace("{userId}", userId);
1518
+ const url = this._httpHelper.getUrl(resourceUri);
1519
+ const opts = { method: "GET" };
1520
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1521
+ }
1522
+ addUserToGroup(params, groupId, userId) {
1523
+ const resourceUri = this._httpHelper._config.ResourceUri.GroupsAddUser.replace("{groupId}", groupId).replace("{userId}", userId);
1524
+ const url = this._httpHelper.getUrl(resourceUri);
1525
+ const opts = { method: "PUT" };
1526
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1527
+ }
1528
+ removeUserFromGroup(params, groupId, userId) {
1529
+ const resourceUri = this._httpHelper._config.ResourceUri.GroupsAddUser.replace("{groupId}", groupId).replace("{userId}", userId);
1530
+ const url = this._httpHelper.getUrl(resourceUri);
1531
+ const opts = { method: "DELETE" };
1532
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1533
+ }
1534
+ };
1535
+
1536
+ // lib/vvRestApi/libraryManager.js
1537
+ init_cjs_shims();
1538
+ var LibraryManager = class {
1539
+ constructor(httpHelper) {
1540
+ this._httpHelper = httpHelper;
1541
+ }
1542
+ getFolders(params) {
1543
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.Folders);
1544
+ const opts = { method: "GET" };
1545
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1546
+ }
1547
+ postFolderByPath(params, data, folderPath) {
1548
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.Folders);
1549
+ data.folderpath = folderPath;
1550
+ const opts = { method: "POST" };
1551
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1552
+ }
1553
+ // Valid fields to be defined on the "data" parameter to be updated on the folder: name, description
1554
+ putFolder(params, data, folderId) {
1555
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.FoldersId.replace("{id}", folderId));
1556
+ const opts = { method: "PUT" };
1557
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1558
+ }
1559
+ deleteFolder(folderId) {
1560
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.FoldersId.replace("{id}", folderId));
1561
+ const opts = { method: "DELETE" };
1562
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1563
+ }
1564
+ copyFolder(params, data) {
1565
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.FoldersCopy);
1566
+ const opts = { method: "POST" };
1567
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
1568
+ }
1569
+ moveFolder(params, data) {
1570
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.FoldersMove);
1571
+ const opts = { method: "PUT" };
1572
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
1573
+ }
1574
+ getDocuments(params, folderId) {
1575
+ const resourceUri = this._httpHelper._config.ResourceUri.Documents.replace("{id}", folderId);
1576
+ const url = this._httpHelper.getUrl(resourceUri);
1577
+ const opts = { method: "GET" };
1578
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1579
+ }
1580
+ updateFolderIndexFieldOverrideSettings(folderId, fieldId, queryId, displayField, valueField, dropDownListId, required, defaultValue) {
1581
+ const data = {
1582
+ queryId,
1583
+ queryValueField: valueField,
1584
+ queryDisplayField: displayField,
1585
+ dropDownListId,
1586
+ required,
1587
+ defaultValue
1588
+ };
1589
+ const resourceUri = this._httpHelper._config.ResourceUri.FoldersIdIndexFieldsId.replace("{id}", folderId).replace("{indexFieldId}", fieldId);
1590
+ const url = this._httpHelper.getUrl(resourceUri);
1591
+ const opts = { method: "PUT" };
1592
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
1593
+ }
1594
+ getFolderIndexFields(params, folderId) {
1595
+ const resourceUri = this._httpHelper._config.ResourceUri.FolderIndexFields.replace("{id}", folderId);
1596
+ const url = this._httpHelper.getUrl(resourceUri);
1597
+ const opts = { method: "GET" };
1598
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1599
+ }
1600
+ postFolderAlertSubscription(folderId, eventId, userId) {
1601
+ const resourceUri = this._httpHelper._config.ResourceUri.FolderAlertsId.replace("{folderId}", folderId).replace("{eventId}", eventId);
1602
+ const url = this._httpHelper.getUrl(resourceUri);
1603
+ const opts = { method: "POST" };
1604
+ const params = {
1605
+ usId: userId
1606
+ };
1607
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1608
+ }
1609
+ deleteFolderAlertSubscription(folderId, eventId, userId) {
1610
+ const resourceUri = this._httpHelper._config.ResourceUri.FolderAlertsId.replace("{folderId}", folderId).replace("{eventId}", eventId);
1611
+ const url = this._httpHelper.getUrl(resourceUri);
1612
+ const opts = { method: "DELETE" };
1613
+ const params = {
1614
+ usId: userId
1615
+ };
1616
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1617
+ }
1618
+ getFolderSecurityMembers(params, folderId) {
1619
+ const resourceUri = this._httpHelper._config.ResourceUri.FolderSecurity.replace("{folderId}", folderId);
1620
+ const url = this._httpHelper.getUrl(resourceUri);
1621
+ const opts = { method: "GET" };
1622
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1623
+ }
1624
+ putFolderSecurityMember(folderId, memberId, memberType, securityRole, cascadeSecurityChanges) {
1625
+ const resourceUri = this._httpHelper._config.ResourceUri.FolderSecurityId.replace("{folderId}", folderId).replace("{memberId}", memberId);
1626
+ const url = this._httpHelper.getUrl(resourceUri);
1627
+ const opts = { method: "PUT" };
1628
+ const data = {
1629
+ memberType,
1630
+ securityRole,
1631
+ cascadeSecurityChanges
1632
+ };
1633
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
1634
+ }
1635
+ deleteFolderSecurityMember(folderId, memberId, cascadeSecurityChanges) {
1636
+ const resourceUri = this._httpHelper._config.ResourceUri.FolderSecurityId.replace("{folderId}", folderId).replace("{memberId}", memberId);
1637
+ const url = this._httpHelper.getUrl(resourceUri);
1638
+ const opts = { method: "DELETE" };
1639
+ const params = {
1640
+ cascadeSecurityChanges
1641
+ };
1642
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1643
+ }
1644
+ };
1645
+
1646
+ // lib/vvRestApi/sitesManager.js
1647
+ init_cjs_shims();
1648
+ var SitesManager = class {
1649
+ constructor(httpHelper) {
1650
+ this._httpHelper = httpHelper;
1651
+ }
1652
+ getSites(params) {
1653
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.Sites);
1654
+ const opts = { method: "GET" };
1655
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1656
+ }
1657
+ postSites(params, data) {
1658
+ const resourceUri = this._httpHelper._config.ResourceUri.Sites;
1659
+ const url = this._httpHelper.getUrl(resourceUri);
1660
+ const opts = { method: "POST" };
1661
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1662
+ }
1663
+ putSites(params, data, siteId) {
1664
+ const resourceUri = this._httpHelper._config.ResourceUri.Sites;
1665
+ const url = this._httpHelper.getUrl(resourceUri + "/" + siteId);
1666
+ const opts = { method: "PUT" };
1667
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1668
+ }
1669
+ getGroups(params, siteId) {
1670
+ const resourceUri = this._httpHelper._config.ResourceUri.Groups.replace("{id}", siteId);
1671
+ const url = this._httpHelper.getUrl(resourceUri);
1672
+ const opts = { method: "GET" };
1673
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1674
+ }
1675
+ postGroups(params, data, siteId) {
1676
+ const resourceUri = this._httpHelper._config.ResourceUri.Groups.replace("{id}", siteId);
1677
+ const url = this._httpHelper.getUrl(resourceUri);
1678
+ const opts = { method: "POST" };
1679
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1680
+ }
1681
+ putGroups(params, data, siteId, grId) {
1682
+ const resourceUri = this._httpHelper._config.ResourceUri.Groups.replace("{id}", siteId);
1683
+ const url = this._httpHelper.getUrl(resourceUri + "/" + grId);
1684
+ const opts = { method: "PUT" };
1685
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1686
+ }
1687
+ changeUserSite(userId, newSiteId) {
1688
+ const resourceUri = this._httpHelper._config.ResourceUri.ChangeUserSite;
1689
+ const url = this._httpHelper.getUrl(resourceUri);
1690
+ const opts = { method: "PUT" };
1691
+ const data = {
1692
+ UserId: userId,
1693
+ NewSiteId: newSiteId
1694
+ };
1695
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
1696
+ }
1697
+ };
1698
+
1699
+ // lib/vvRestApi/usersManager.js
1700
+ init_cjs_shims();
1701
+ var UsersManager = class {
1702
+ constructor(httpHelper) {
1703
+ this._httpHelper = httpHelper;
1704
+ }
1705
+ getUsers(params, siteId) {
1706
+ const resourceUri = this._httpHelper._config.ResourceUri.Users.replace("{id}", siteId);
1707
+ const url = this._httpHelper.getUrl(resourceUri);
1708
+ const opts = { method: "GET" };
1709
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1710
+ }
1711
+ postUsers(params, data, siteId) {
1712
+ const resourceUri = this._httpHelper._config.ResourceUri.Users.replace("{id}", siteId);
1713
+ const url = this._httpHelper.getUrl(resourceUri);
1714
+ const opts = { method: "POST" };
1715
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1716
+ }
1717
+ putUsers(params, data, siteId, usId) {
1718
+ const resourceUri = this._httpHelper._config.ResourceUri.Users.replace("{id}", siteId);
1719
+ const url = this._httpHelper.getUrl(resourceUri + "/" + usId);
1720
+ const opts = { method: "PUT" };
1721
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1722
+ }
1723
+ putUsersEndpoint(params, data, usId) {
1724
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.User + "/" + usId);
1725
+ const opts = { method: "PUT" };
1726
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1727
+ }
1728
+ getUser(params) {
1729
+ const resourceUri = this._httpHelper._config.ResourceUri.User;
1730
+ const url = this._httpHelper.getUrl(resourceUri);
1731
+ const opts = { method: "GET" };
1732
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1733
+ }
1734
+ getUserById(params, usId) {
1735
+ const resourceUri = this._httpHelper._config.ResourceUri.UserById.replace("{id}", usId);
1736
+ const url = this._httpHelper.getUrl(resourceUri);
1737
+ const opts = { method: "GET" };
1738
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1739
+ }
1740
+ getUserGroups(params, usId) {
1741
+ const resourceUri = this._httpHelper._config.ResourceUri.UserGroups.replace("{id}", usId);
1742
+ const url = this._httpHelper.getUrl(resourceUri);
1743
+ const opts = { method: "GET" };
1744
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1745
+ }
1746
+ getUserSupervisors(params, usId) {
1747
+ const resourceUri = this._httpHelper._config.ResourceUri.UserSupervisors.replace("{id}", usId);
1748
+ const url = this._httpHelper.getUrl(resourceUri);
1749
+ const opts = { method: "GET" };
1750
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1751
+ }
1752
+ getUserSupervisees(params, usId) {
1753
+ const resourceUri = this._httpHelper._config.ResourceUri.UserSupervisees.replace("{id}", usId);
1754
+ const url = this._httpHelper.getUrl(resourceUri);
1755
+ const opts = { method: "GET" };
1756
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1757
+ }
1758
+ getUserLoginToken(usId) {
1759
+ const resourceUri = this._httpHelper._config.ResourceUri.UserWebToken.replace("{id}", usId);
1760
+ const url = this._httpHelper.getUrl(resourceUri);
1761
+ const opts = { method: "GET" };
1762
+ const params = [];
1763
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1764
+ }
1765
+ getUserJwt(audience) {
1766
+ const resourceUri = this._httpHelper._config.ResourceUri.UsersGetJwt;
1767
+ const url = this._httpHelper.getUrl(resourceUri);
1768
+ const opts = { method: "GET" };
1769
+ const params = {};
1770
+ if (audience) {
1771
+ params["audience"] = audience;
1772
+ }
1773
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1774
+ }
1775
+ getCurrentUser() {
1776
+ const resourceUri = this._httpHelper._config.ResourceUri.UsersWhoAmI;
1777
+ const baseUrl = this._httpHelper._sessionToken.baseUrl;
1778
+ const url = baseUrl + "/api/v1" + resourceUri;
1779
+ const opts = { method: "GET" };
1780
+ const params = [];
1781
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1782
+ }
1783
+ resetPassword(usId, sendEmail = true) {
1784
+ const resourceUri = this._httpHelper._config.ResourceUri.UsersPassword.replace("{id}", usId);
1785
+ const url = this._httpHelper.getUrl(resourceUri);
1786
+ const opts = { method: "PUT" };
1787
+ const params = [];
1788
+ const data = {
1789
+ resetPassword: true,
1790
+ sendEmail
1791
+ };
1792
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1793
+ }
1794
+ updateUserId(usId, newUserId) {
1795
+ const resourceUri = this._httpHelper._config.ResourceUri.UsersIdUserId.replace("{id}", usId);
1796
+ const url = this._httpHelper.getUrl(resourceUri);
1797
+ const opts = { method: "PUT" };
1798
+ const params = [];
1799
+ const data = {
1800
+ userId: newUserId
1801
+ };
1802
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1803
+ }
1804
+ };
1805
+
1806
+ // lib/vvRestApi/currentUserManager.js
1807
+ init_cjs_shims();
1808
+ var CurrentUserManager = class {
1809
+ constructor(httpHelper) {
1810
+ this._httpHelper = httpHelper;
1811
+ }
1812
+ /**
1813
+ * Gets the currently authenticated user's information.
1814
+ * @param {Object} [params] - Optional query parameters.
1815
+ * @returns {Promise<string>} A promise that resolves with the current user's information as a JSON string.
1816
+ */
1817
+ async getCurrentUser(params) {
1818
+ var resourceUri = this._httpHelper._config.ResourceUri.UsersMe;
1819
+ var url = this._httpHelper.getUrl(resourceUri);
1820
+ var opts = { method: "GET" };
1821
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1822
+ }
1823
+ };
1824
+
1825
+ // lib/vvRestApi/scheduledProcessManager.js
1826
+ init_cjs_shims();
1827
+ var ScheduledProcessManager = class {
1828
+ constructor(httpHelper) {
1829
+ this._httpHelper = httpHelper;
1830
+ }
1831
+ postCompletion(id, action, result, message) {
1832
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.ScheduledProcess) + "/" + id;
1833
+ const opts = { method: "POST" };
1834
+ const params = {
1835
+ action
1836
+ };
1837
+ if (result !== null && (typeof result === "boolean" || result.length > 0)) {
1838
+ params.result = result.toString();
1839
+ }
1840
+ if (message && message.length > 0) {
1841
+ params.message = message;
1842
+ }
1843
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1844
+ }
1845
+ runAllScheduledProcesses() {
1846
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.ScheduledProcess) + "/Run";
1847
+ const opts = { method: "PUT" };
1848
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1849
+ }
1850
+ };
1851
+
1852
+ // lib/vvRestApi/customQueryManager.js
1853
+ init_cjs_shims();
1854
+ var CustomQueryManager = class {
1855
+ constructor(httpHelper) {
1856
+ this._httpHelper = httpHelper;
1857
+ }
1858
+ getCustomQueryResultsByName(queryName, params) {
1859
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.CustomQuery);
1860
+ const opts = { method: "GET" };
1861
+ if (!params) {
1862
+ params = {};
1863
+ }
1864
+ params.queryName = queryName;
1865
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1866
+ }
1867
+ getCustomQueryResultsById(id, params) {
1868
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.CustomQuery + "/" + id);
1869
+ const opts = { method: "GET" };
1870
+ if (!params) {
1871
+ params = {};
1872
+ }
1873
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1874
+ }
1875
+ };
1876
+
1877
+ // lib/vvRestApi/customerManager.js
1878
+ init_cjs_shims();
1879
+ var CustomerManager = class {
1880
+ constructor(httpHelper) {
1881
+ this._httpHelper = httpHelper;
1882
+ }
1883
+ createCustomerInvite(data) {
1884
+ const baseUrl = this._httpHelper._sessionToken.baseUrl;
1885
+ let url = baseUrl + "/api/v1/" + this._httpHelper._config.ResourceUri.CustomerInvite;
1886
+ url = url.replace(/\/api\/\//g, "/api/");
1887
+ url = url.replace(/\/v1\/\//g, "/v1/");
1888
+ const opts = { method: "POST" };
1889
+ return this._httpHelper.doVvClientRequest(url, opts, "", data);
1890
+ }
1891
+ assignUser(customerId, data) {
1892
+ const baseUrl = this._httpHelper._sessionToken.baseUrl;
1893
+ const url = baseUrl + "/api/v1/" + this._httpHelper._config.ResourceUri.CustomerAssignUser.replace("{customerId}", customerId);
1894
+ const opts = { method: "PUT" };
1895
+ return this._httpHelper.doVvClientRequest(url, opts, "", data);
1896
+ }
1897
+ };
1898
+
1899
+ // lib/vvRestApi/customerDatabaseManager.js
1900
+ init_cjs_shims();
1901
+ var import_debug4 = __toESM(require("debug"), 1);
1902
+ var debug4 = (0, import_debug4.default)("visualvault:customer-db");
1903
+ var CustomerDatabaseManager = class {
1904
+ constructor(httpHelper) {
1905
+ this._httpHelper = httpHelper;
1906
+ }
1907
+ assignUser(customerId, data) {
1908
+ const baseUrl = this._httpHelper._sessionToken.baseUrl;
1909
+ const url = baseUrl + "/api/v1/" + this._httpHelper._config.ResourceUri.CustomerDatabaseAssignUser.replace("{databaseId}", customerId);
1910
+ const opts = { method: "PUT" };
1911
+ return this._httpHelper.doVvClientRequest(url, opts, "", data);
1912
+ }
1913
+ removeUser(authenticationUserId, databaseId) {
1914
+ const baseUrl = this._httpHelper._sessionToken.baseUrl;
1915
+ let url = baseUrl + "/api/v1" + this._httpHelper._config.ResourceUri.UserDelete.replace("{databaseId}", databaseId);
1916
+ url = url.replace("{authenticationUserId}", authenticationUserId);
1917
+ debug4("Removing user %s from database %s: %s", authenticationUserId, databaseId, url);
1918
+ const opts = { method: "DELETE" };
1919
+ const params = [];
1920
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1921
+ }
1922
+ };
1923
+
1924
+ // lib/vvRestApi/filesManager.js
1925
+ init_cjs_shims();
1926
+ var FilesManager = class {
1927
+ constructor(httpHelper) {
1928
+ this._httpHelper = httpHelper;
1929
+ }
1930
+ getFileBytesQuery(query) {
1931
+ const resourceUri = this._httpHelper._config.ResourceUri.FilesQuery + query;
1932
+ const url = this._httpHelper.getUrl(resourceUri);
1933
+ const opts = { method: "GETSTREAM" };
1934
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1935
+ }
1936
+ getFileBytesId(id) {
1937
+ const resourceUri = this._httpHelper._config.ResourceUri.FilesId.replace("{id}", id);
1938
+ const url = this._httpHelper.getUrl(resourceUri);
1939
+ const opts = { method: "GETSTREAM" };
1940
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1941
+ }
1942
+ postFile(data, buffer) {
1943
+ const resourceUri = this._httpHelper._config.ResourceUri.Files;
1944
+ const url = this._httpHelper.getUrl(resourceUri);
1945
+ const opts = { method: "POSTSTREAM" };
1946
+ return this._httpHelper.doVvClientRequest(url, opts, null, data, buffer);
1947
+ }
1948
+ };
1949
+
1950
+ // lib/vvRestApi/scriptsManager.js
1951
+ init_cjs_shims();
1952
+ var ScriptsManager = class {
1953
+ constructor(httpHelper) {
1954
+ this._httpHelper = httpHelper;
1955
+ }
1956
+ runWebService(serviceName, serviceData, usId) {
1957
+ let resourceUri = this._httpHelper._config.ResourceUri.Scripts + "?name=" + serviceName;
1958
+ if (typeof usId !== "undefined" && usId !== null) {
1959
+ resourceUri += `&usId=${usId}`;
1960
+ }
1961
+ const url = this._httpHelper.getUrl(resourceUri);
1962
+ const opts = { method: "POST" };
1963
+ return this._httpHelper.doVvClientRequest(url, opts, null, serviceData);
1964
+ }
1965
+ completeWorkflowWebService(executionId, workflowVariables) {
1966
+ const resourceUri = this._httpHelper._config.ResourceUri.ScriptsCompleteWf;
1967
+ const url = this._httpHelper.getUrl(resourceUri);
1968
+ const opts = { method: "POST" };
1969
+ const postData = {
1970
+ executionId,
1971
+ workflowVariables
1972
+ };
1973
+ return this._httpHelper.doVvClientRequest(url, opts, null, postData);
1974
+ }
1975
+ };
1976
+
1977
+ // lib/vvRestApi/documentsManager.js
1978
+ init_cjs_shims();
1979
+ var DocumentsManager = class {
1980
+ constructor(httpHelper) {
1981
+ this._httpHelper = httpHelper;
1982
+ }
1983
+ postDoc(data) {
1984
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsPost;
1985
+ const url = this._httpHelper.getUrl(resourceUri);
1986
+ const opts = { method: "POST" };
1987
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
1988
+ }
1989
+ postDocWithFile(data, fileData) {
1990
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsPost;
1991
+ const url = this._httpHelper.getUrl(resourceUri);
1992
+ const opts = { method: "POSTSTREAM" };
1993
+ return this._httpHelper.doVvClientRequest(url, opts, null, data, fileData);
1994
+ }
1995
+ copyDocument(params, data, documentId) {
1996
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsIdCopy.replace("{id}", documentId);
1997
+ const url = this._httpHelper.getUrl(resourceUri);
1998
+ const opts = { method: "POST" };
1999
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
2000
+ }
2001
+ moveDocument(params, data, documentId) {
2002
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsIdMove.replace("{id}", documentId);
2003
+ const url = this._httpHelper.getUrl(resourceUri);
2004
+ const opts = { method: "PUT" };
2005
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
2006
+ }
2007
+ deleteDocument(params, revisionId) {
2008
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsId.replace("{id}", revisionId);
2009
+ const url = this._httpHelper.getUrl(resourceUri);
2010
+ const opts = { method: "DELETE" };
2011
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2012
+ }
2013
+ getDocumentRevision(params, revisionId) {
2014
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsId.replace("{id}", revisionId);
2015
+ const url = this._httpHelper.getUrl(resourceUri);
2016
+ const opts = { method: "GET" };
2017
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2018
+ }
2019
+ getDocuments(params) {
2020
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsPost;
2021
+ const url = this._httpHelper.getUrl(resourceUri);
2022
+ const opts = { method: "GET" };
2023
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2024
+ }
2025
+ putDocumentIndexFields(data, documentId) {
2026
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentIndexFields.replace("{id}", documentId);
2027
+ const url = this._httpHelper.getUrl(resourceUri);
2028
+ const opts = { method: "PUT" };
2029
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
2030
+ }
2031
+ postDocumentAlertSubscription(documentId, eventId, userId) {
2032
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentAlertsId.replace("{documentId}", documentId).replace("{eventId}", eventId);
2033
+ const url = this._httpHelper.getUrl(resourceUri);
2034
+ const opts = { method: "POST" };
2035
+ const params = {
2036
+ usId: userId
2037
+ };
2038
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2039
+ }
2040
+ deleteDocumentAlertSubscription(documentId, eventId, userId) {
2041
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentAlertsId.replace("{documentId}", documentId).replace("{eventId}", eventId);
2042
+ const url = this._httpHelper.getUrl(resourceUri);
2043
+ const opts = { method: "DELETE" };
2044
+ const params = {
2045
+ usId: userId
2046
+ };
2047
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2048
+ }
2049
+ getDocumentRevisionOcrProperties(params, revisionId) {
2050
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsIdOcr.replace("{id}", revisionId);
2051
+ const url = this._httpHelper.getUrl(resourceUri);
2052
+ const opts = { method: "GET" };
2053
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2054
+ }
2055
+ relateDocuments(revisionId, relateToRevisionId, relateType) {
2056
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsIdRelateDocument.replace("{id}", revisionId);
2057
+ const url = this._httpHelper.getUrl(resourceUri);
2058
+ const opts = { method: "PUT" };
2059
+ const data = {
2060
+ relateToId: relateToRevisionId,
2061
+ relateType
2062
+ };
2063
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
2064
+ }
2065
+ updateDocumentExpiration(documentId, expirationDate) {
2066
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsIdExpiration.replace("{id}", documentId);
2067
+ const url = this._httpHelper.getUrl(resourceUri);
2068
+ const opts = { method: "PUT" };
2069
+ const data = {
2070
+ expirationDate
2071
+ };
2072
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
2073
+ }
2074
+ };
2075
+
2076
+ // lib/vvRestApi/projectsManager.js
2077
+ init_cjs_shims();
2078
+ var ProjectsManager = class {
2079
+ constructor(httpHelper) {
2080
+ this._httpHelper = httpHelper;
2081
+ }
2082
+ postProjectAlertSubscription(projectId, eventId, userId) {
2083
+ const resourceUri = this._httpHelper._config.ResourceUri.ProjectAlertsId.replace("{projectId}", projectId).replace("{eventId}", eventId);
2084
+ const url = this._httpHelper.getUrl(resourceUri);
2085
+ const opts = { method: "POST" };
2086
+ const params = {
2087
+ usId: userId
2088
+ };
2089
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2090
+ }
2091
+ deleteProjectAlertSubscription(projectId, eventId, userId) {
2092
+ const resourceUri = this._httpHelper._config.ResourceUri.ProjectAlertsId.replace("{projectId}", projectId).replace("{eventId}", eventId);
2093
+ const url = this._httpHelper.getUrl(resourceUri);
2094
+ const opts = { method: "DELETE" };
2095
+ const params = {
2096
+ usId: userId
2097
+ };
2098
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2099
+ }
2100
+ };
2101
+
2102
+ // lib/vvRestApi/indexFieldsManager.js
2103
+ init_cjs_shims();
2104
+ var IndexFieldsManager = class {
2105
+ constructor(httpHelper) {
2106
+ this._httpHelper = httpHelper;
2107
+ }
2108
+ getIndexFields(params) {
2109
+ const resourceUri = this._httpHelper._config.ResourceUri.IndexFields;
2110
+ const url = this._httpHelper.getUrl(resourceUri);
2111
+ const opts = { method: "GET" };
2112
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2113
+ }
2114
+ };
2115
+
2116
+ // lib/vvRestApi/outsideProcessesManager.js
2117
+ init_cjs_shims();
2118
+ var OutsideProcessesManager = class {
2119
+ constructor(httpHelper) {
2120
+ this._httpHelper = httpHelper;
2121
+ }
2122
+ getOutsideProcesses(params) {
2123
+ const resourceUri = this._httpHelper._config.ResourceUri.OutsideProcesses;
2124
+ const url = this._httpHelper.getUrl(resourceUri);
2125
+ const opts = { method: "GET" };
2126
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2127
+ }
2128
+ };
2129
+
2130
+ // lib/vvRestApi/securityMembersManager.js
2131
+ init_cjs_shims();
2132
+ var SecurityMembersManager = class {
2133
+ constructor(httpHelper) {
2134
+ this._httpHelper = httpHelper;
2135
+ }
2136
+ addSecurityMember(parentId, memberId, roleType, isGroup) {
2137
+ const resourceUri = this._httpHelper._config.ResourceUri.SecurityMembers;
2138
+ const url = this._httpHelper.getUrl(resourceUri);
2139
+ const opts = { method: "POST" };
2140
+ const postData = {
2141
+ parentId,
2142
+ memberId,
2143
+ role: roleType,
2144
+ isGroup
2145
+ };
2146
+ return this._httpHelper.doVvClientRequest(url, opts, null, postData);
2147
+ }
2148
+ getSecurityMembersForParentId(parentId) {
2149
+ const resourceUri = this._httpHelper._config.ResourceUri.SecurityMembers;
2150
+ const url = this._httpHelper.getUrl(resourceUri);
2151
+ const opts = { method: "GET" };
2152
+ const params = {
2153
+ parentId
2154
+ };
2155
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2156
+ }
2157
+ removeSecurityMember(parentId, memberId) {
2158
+ const resourceUri = this._httpHelper._config.ResourceUri.SecurityMembers;
2159
+ const url = this._httpHelper.getUrl(resourceUri);
2160
+ const opts = { method: "DELETE" };
2161
+ const params = {
2162
+ parentId,
2163
+ memberId
2164
+ };
2165
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2166
+ }
2167
+ updateSecurityMember(parentId, memberId, roleType) {
2168
+ const resourceUri = this._httpHelper._config.ResourceUri.SecurityMembers;
2169
+ const url = this._httpHelper.getUrl(resourceUri);
2170
+ const opts = { method: "PUT" };
2171
+ const postData = {
2172
+ parentId,
2173
+ memberId,
2174
+ role: roleType
2175
+ };
2176
+ return this._httpHelper.doVvClientRequest(url, opts, null, postData);
2177
+ }
2178
+ };
2179
+
2180
+ // lib/vvRestApi/layoutsManager.js
2181
+ init_cjs_shims();
2182
+ var LayoutsManager = class {
2183
+ constructor(httpHelper) {
2184
+ this._httpHelper = httpHelper;
2185
+ }
2186
+ getLayout() {
2187
+ const resourceUri = this._httpHelper._config.ResourceUri.Layout;
2188
+ const url = this._httpHelper.getUrl(resourceUri);
2189
+ const opts = { method: "GET" };
2190
+ return this._httpHelper.doVvClientRequest(url, opts, {}, null);
2191
+ }
2192
+ };
2193
+
2194
+ // lib/vvRestApi/reportsManager.js
2195
+ init_cjs_shims();
2196
+ var ReportsManager = class {
2197
+ constructor(httpHelper) {
2198
+ this._httpHelper = httpHelper;
2199
+ }
2200
+ getReportPDF(reportId, params) {
2201
+ const resourceUri = this._httpHelper._config.ResourceUri.ReportServerPDF.replace("{id}", reportId);
2202
+ const url = this._httpHelper.getUrl(resourceUri);
2203
+ const opts = { method: "GETSTREAM" };
2204
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2205
+ }
2206
+ };
2207
+
2208
+ // lib/VVRestApi.js
2209
+ var debug5 = (0, import_debug5.default)("visualvault:api");
2210
+ var __filename7 = (0, import_url6.fileURLToPath)(importMetaUrl);
2211
+ var __dirname6 = import_path6.default.dirname(__filename7);
2212
+ var VVClient = class {
2213
+ /** @type {*} */
2214
+ constants;
2215
+ /** @type {*} */
2216
+ configuration;
2217
+ /** @type {*} */
2218
+ customQuery;
2219
+ /** @type {*} */
2220
+ documents;
2221
+ /** @type {*} */
2222
+ email;
2223
+ /** @type {*} */
2224
+ files;
2225
+ /** @type {*} */
2226
+ forms;
2227
+ /** @type {*} */
2228
+ groups;
2229
+ /** @type {*} */
2230
+ library;
2231
+ /** @type {*} */
2232
+ sites;
2233
+ /** @type {*} */
2234
+ users;
2235
+ /** @type {*} */
2236
+ scheduledProcess;
2237
+ /** @type {*} */
2238
+ scripts;
2239
+ /** @type {*} */
2240
+ projects;
2241
+ /** @type {*} */
2242
+ customer;
2243
+ /** @type {*} */
2244
+ customerDatabase;
2245
+ /** @type {*} */
2246
+ indexFields;
2247
+ /** @type {*} */
2248
+ outsideProcesses;
2249
+ /** @type {*} */
2250
+ securityMembers;
2251
+ /** @type {*} */
2252
+ layouts;
2253
+ /** @type {*} */
2254
+ reports;
2255
+ /**
2256
+ * @param {*} sessionToken - Session token from authentication
2257
+ */
2258
+ constructor(sessionToken) {
2259
+ this.yamlConfig = import_js_yaml7.default.load(import_fs7.default.readFileSync(import_path6.default.join(__dirname6, "config.yml"), "utf8"));
2260
+ this._httpHelper = new common_default.httpHelper(sessionToken, this.yamlConfig);
2261
+ this.constants = new Constants();
2262
+ this.configuration = new ConfigurationManager(this._httpHelper);
2263
+ this.customQuery = new CustomQueryManager(this._httpHelper);
2264
+ this.documents = new DocumentsManager(this._httpHelper);
2265
+ this.email = new EmailManager(this._httpHelper);
2266
+ this.files = new FilesManager(this._httpHelper);
2267
+ this.forms = new FormsManager(this._httpHelper);
2268
+ this.groups = new GroupsManager(this._httpHelper);
2269
+ this.library = new LibraryManager(this._httpHelper);
2270
+ this.sites = new SitesManager(this._httpHelper);
2271
+ this.users = new UsersManager(this._httpHelper);
2272
+ this.currentUser = new CurrentUserManager(this._httpHelper);
2273
+ this.scheduledProcess = new ScheduledProcessManager(this._httpHelper);
2274
+ this.scripts = new ScriptsManager(this._httpHelper);
2275
+ this.projects = new ProjectsManager(this._httpHelper);
2276
+ this.customer = new CustomerManager(this._httpHelper);
2277
+ this.customerDatabase = new CustomerDatabaseManager(this._httpHelper);
2278
+ this.indexFields = new IndexFieldsManager(this._httpHelper);
2279
+ this.outsideProcesses = new OutsideProcessesManager(this._httpHelper);
2280
+ this.securityMembers = new SecurityMembersManager(this._httpHelper);
2281
+ this.layouts = new LayoutsManager(this._httpHelper);
2282
+ this.reports = new ReportsManager(this._httpHelper);
2283
+ this._docApi = null;
2284
+ Object.defineProperties(this, {
2285
+ docApi: {
2286
+ get: function() {
2287
+ if (this._docApi != null && this._docApi.isEnabled && this._docApi.baseUrl) {
2288
+ return this._docApi;
2289
+ } else {
2290
+ throw new ReferenceError("Document Api not enabled");
2291
+ }
2292
+ }
2293
+ }
2294
+ });
2295
+ this._formsApi = null;
2296
+ Object.defineProperties(this, {
2297
+ formsApi: {
2298
+ get: function() {
2299
+ if (this._formsApi != null && this._formsApi.isEnabled && this._formsApi.baseUrl) {
2300
+ return this._formsApi;
2301
+ } else {
2302
+ throw new ReferenceError("Forms Api not enabled");
2303
+ }
2304
+ }
2305
+ }
2306
+ });
2307
+ this._objectsApi = null;
2308
+ Object.defineProperties(this, {
2309
+ objectsApi: {
2310
+ get: function() {
2311
+ if (this._objectsApi != null && this._objectsApi.isEnabled && this._objectsApi.baseUrl) {
2312
+ return this._objectsApi;
2313
+ } else {
2314
+ throw new ReferenceError("Objects Api not enabled");
2315
+ }
2316
+ }
2317
+ }
2318
+ });
2319
+ this._studioApi = null;
2320
+ Object.defineProperties(this, {
2321
+ studioApi: {
2322
+ get: function() {
2323
+ if (this._studioApi != null && this._studioApi.isEnabled && this._studioApi.baseUrl) {
2324
+ return this._studioApi;
2325
+ } else {
2326
+ throw new ReferenceError("Studio Api not enabled");
2327
+ }
2328
+ }
2329
+ }
2330
+ });
2331
+ this._notificationsApi = null;
2332
+ Object.defineProperties(this, {
2333
+ notificationsApi: {
2334
+ get: function() {
2335
+ if (this._notificationsApi != null && this._notificationsApi.isEnabled && this._notificationsApi.baseUrl) {
2336
+ return this._notificationsApi;
2337
+ } else {
2338
+ throw new ReferenceError("Notifications Api not enabled");
2339
+ }
2340
+ }
2341
+ }
2342
+ });
2343
+ }
2344
+ async createDocApi(sessionToken) {
2345
+ const docApiConfigResponse = JSON.parse(await this.configuration.getDocApiConfig());
2346
+ if (docApiConfigResponse && docApiConfigResponse["data"]) {
2347
+ const docApiSession = sessionToken.createCopy();
2348
+ docApiSession.baseUrl = docApiConfigResponse.data["apiUrl"];
2349
+ docApiSession.apiUrl = this.yamlConfig.DocApiUri;
2350
+ if (docApiSession["tokenType"] == "jwt") {
2351
+ this._docApi = new DocApi_default(docApiSession, docApiConfigResponse.data);
2352
+ } else if (this.users) {
2353
+ const jwtResponse = JSON.parse(await this.users.getUserJwt(docApiSession.audience));
2354
+ if (jwtResponse["data"] && jwtResponse["data"]["token"]) {
2355
+ docApiSession.convertToJwt(jwtResponse["data"]);
2356
+ this._docApi = new DocApi_default(docApiSession, docApiConfigResponse.data);
2357
+ }
2358
+ }
2359
+ }
2360
+ }
2361
+ async createFormsApi(sessionToken) {
2362
+ const formsApiConfigResponse = JSON.parse(await this.configuration.getFormsApiConfig());
2363
+ if (formsApiConfigResponse && formsApiConfigResponse["data"]) {
2364
+ const formsApiSession = sessionToken.createCopy();
2365
+ formsApiSession.baseUrl = formsApiConfigResponse.data["formsApiUrl"];
2366
+ formsApiSession.apiUrl = this.yamlConfig.FormsApiUri;
2367
+ if (formsApiSession["tokenType"] == "jwt") {
2368
+ this._formsApi = new FormsApi_default(formsApiSession, formsApiConfigResponse.data);
2369
+ } else if (this.users) {
2370
+ const jwtResponse = JSON.parse(await this.users.getUserJwt(formsApiSession.audience));
2371
+ if (jwtResponse["data"] && jwtResponse["data"]["token"]) {
2372
+ formsApiSession.convertToJwt(jwtResponse["data"]);
2373
+ this._formsApi = new FormsApi_default(formsApiSession, formsApiConfigResponse.data);
2374
+ }
2375
+ }
2376
+ }
2377
+ }
2378
+ async createObjectsApi(sessionToken) {
2379
+ const objectsApiConfigResponse = JSON.parse(await this.configuration.getObjectsApiConfig());
2380
+ if (objectsApiConfigResponse && objectsApiConfigResponse["data"]) {
2381
+ const objectsApiSession = sessionToken.createCopy();
2382
+ objectsApiSession.baseUrl = objectsApiConfigResponse.data["apiUrl"];
2383
+ objectsApiSession.apiUrl = "";
2384
+ if (objectsApiSession["tokenType"] == "jwt") {
2385
+ this._objectsApi = new ObjectsApi_default(objectsApiSession, objectsApiConfigResponse.data);
2386
+ } else if (this.users) {
2387
+ const jwtResponse = JSON.parse(await this.users.getUserJwt(objectsApiSession.audience));
2388
+ if (jwtResponse["data"] && jwtResponse["data"]["token"]) {
2389
+ objectsApiSession.convertToJwt(jwtResponse["data"]);
2390
+ this._objectsApi = new ObjectsApi_default(objectsApiSession, objectsApiConfigResponse.data);
2391
+ }
2392
+ }
2393
+ }
2394
+ }
2395
+ async createStudioApi(sessionToken) {
2396
+ const studioApiConfigResponse = JSON.parse(await this.configuration.getStudioApiConfig());
2397
+ if (studioApiConfigResponse && studioApiConfigResponse["data"]) {
2398
+ const studioApiSession = sessionToken.createCopy();
2399
+ studioApiSession.baseUrl = studioApiConfigResponse.data["studioApiUrl"];
2400
+ studioApiSession.apiUrl = "";
2401
+ if (studioApiSession["tokenType"] == "jwt") {
2402
+ this._studioApi = new StudioApi_default(studioApiSession, studioApiConfigResponse.data);
2403
+ } else if (this.users) {
2404
+ const jwtResponse = JSON.parse(await this.users.getUserJwt(studioApiSession.audience));
2405
+ if (jwtResponse["data"] && jwtResponse["data"]["token"]) {
2406
+ studioApiSession.convertToJwt(jwtResponse["data"]);
2407
+ this._studioApi = new StudioApi_default(studioApiSession, studioApiConfigResponse.data);
2408
+ }
2409
+ }
2410
+ }
2411
+ }
2412
+ async createNotificationsApi(sessionToken) {
2413
+ const notificationsApiConfigResponse = JSON.parse(await this.configuration.getNotificationsApiConfig());
2414
+ if (notificationsApiConfigResponse && notificationsApiConfigResponse["data"]) {
2415
+ const notificationsApiSession = sessionToken.createCopy();
2416
+ notificationsApiSession.baseUrl = notificationsApiConfigResponse.data["apiUrl"];
2417
+ notificationsApiSession.apiUrl = this.yamlConfig.NotificationsApiUri;
2418
+ if (notificationsApiSession["tokenType"] == "jwt") {
2419
+ this._notificationsApi = new NotificationsApi_default(notificationsApiSession, notificationsApiConfigResponse.data);
2420
+ } else if (this.users) {
2421
+ const jwtResponse = JSON.parse(await this.users.getUserJwt(notificationsApiSession.audience));
2422
+ if (jwtResponse["data"] && jwtResponse["data"]["token"]) {
2423
+ notificationsApiSession.convertToJwt(jwtResponse["data"]);
2424
+ this._notificationsApi = new NotificationsApi_default(notificationsApiSession, notificationsApiConfigResponse.data);
2425
+ }
2426
+ }
2427
+ }
2428
+ }
2429
+ async _convertToJwt(sessionToken) {
2430
+ const jwtResponse = JSON.parse(await this.users.getUserJwt(sessionToken.audience));
2431
+ if (jwtResponse["data"] && jwtResponse["data"]["token"]) {
2432
+ sessionToken.convertToJwt(jwtResponse["data"]);
2433
+ } else {
2434
+ throw new Error("Failed to get JWT: API response missing data.token property");
2435
+ }
2436
+ }
2437
+ endsWith(source, suffix) {
2438
+ return source.indexOf(suffix, source.length - suffix.length) !== -1;
2439
+ }
2440
+ /**
2441
+ * Get the current security token
2442
+ * @returns {string} The access token
2443
+ */
2444
+ getSecurityToken() {
2445
+ return this._httpHelper._sessionToken.accessToken;
2446
+ }
2447
+ /**
2448
+ * Check if the client is authenticated
2449
+ * @returns {boolean} True if authenticated
2450
+ */
2451
+ isAuthenticated() {
2452
+ return this._httpHelper._sessionToken.isAuthenticated;
2453
+ }
2454
+ /**
2455
+ * Get the base URL
2456
+ * @returns {string} The base URL
2457
+ */
2458
+ getBaseUrl() {
2459
+ return this._httpHelper._sessionToken.baseUrl;
2460
+ }
2461
+ };
2462
+ var Authorize2 = class extends common_default.authorize {
2463
+ /**
2464
+ * Authenticate and get a VaultApi client instance
2465
+ * @param {string} clientId - OAuth client ID
2466
+ * @param {string} clientSecret - OAuth client secret
2467
+ * @param {string} userId - User username
2468
+ * @param {string} password - User password
2469
+ * @param {string} audience - OAuth audience
2470
+ * @param {string} baseVaultUrl - VisualVault base URL
2471
+ * @param {string} customerAlias - Customer alias
2472
+ * @param {string} databaseAlias - Database alias
2473
+ * @returns {Promise<VVClient>} Authenticated client instance
2474
+ */
2475
+ async getVaultApi(clientId, clientSecret, userId, password, audience, baseVaultUrl, customerAlias, databaseAlias) {
2476
+ debug5("getVaultApi called for user: %s, customer: %s/%s", userId, customerAlias, databaseAlias);
2477
+ const config = this.jsyaml.load(this.fs.readFileSync(__dirname6 + "/config.yml", "utf8"));
2478
+ if (this.endsWith(baseVaultUrl, "/")) {
2479
+ baseVaultUrl = baseVaultUrl.substring(0, baseVaultUrl.length - 1);
2480
+ }
2481
+ const apiUrl = config.ApiUri.replace("{custalias}", customerAlias).replace("{custdbalias}", databaseAlias);
2482
+ const authenticationUrl = config.AutheticateUri;
2483
+ const sessionToken = await this.acquireSecurityToken(clientId, clientSecret, userId, password, audience, baseVaultUrl, apiUrl, customerAlias, databaseAlias, authenticationUrl);
2484
+ const client = new VVClient(sessionToken);
2485
+ try {
2486
+ await client._convertToJwt(sessionToken);
2487
+ await Promise.all([
2488
+ client.createDocApi(sessionToken),
2489
+ client.createFormsApi(sessionToken),
2490
+ client.createObjectsApi(sessionToken),
2491
+ client.createStudioApi(sessionToken),
2492
+ client.createNotificationsApi(sessionToken)
2493
+ ]);
2494
+ return client;
2495
+ } catch (error) {
2496
+ debug5("Failed to convert to JWT or create specialized APIs: %s", error.message);
2497
+ return client;
2498
+ }
2499
+ }
2500
+ /**
2501
+ * Get a VaultApi client from an existing JWT token
2502
+ * @param {string} jwt - JWT authentication token
2503
+ * @param {string} baseVaultUrl - VisualVault base URL
2504
+ * @param {string} customerAlias - Customer alias
2505
+ * @param {string} databaseAlias - Database alias
2506
+ * @param {Date} expirationDate - Token expiration date
2507
+ * @returns {Promise<VVClient>} Authenticated client instance
2508
+ */
2509
+ async getVaultApiFromJwt(jwt, baseVaultUrl, customerAlias, databaseAlias, expirationDate) {
2510
+ debug5("getVaultApiFromJwt called for customer: %s/%s", customerAlias, databaseAlias);
2511
+ const config = this.jsyaml.load(this.fs.readFileSync(__dirname6 + "/config.yml", "utf8"));
2512
+ if (this.endsWith(baseVaultUrl, "/")) {
2513
+ baseVaultUrl = baseVaultUrl.substring(0, baseVaultUrl.length - 1);
2514
+ }
2515
+ const apiUrl = config.ApiUri.replace("{custalias}", customerAlias).replace("{custdbalias}", databaseAlias);
2516
+ const authenticationUrl = apiUrl + config.ResourceUri.UsersGetJwt;
2517
+ if (expirationDate && expirationDate >= new Date((/* @__PURE__ */ new Date()).getTime() + 30 * 1e3)) {
2518
+ const sessionToken = new common_default.sessionToken();
2519
+ sessionToken.accessToken = jwt;
2520
+ sessionToken.baseUrl = baseVaultUrl;
2521
+ sessionToken.apiUrl = apiUrl;
2522
+ sessionToken.authenticationUrl = authenticationUrl;
2523
+ sessionToken.customerAlias = customerAlias;
2524
+ sessionToken.databaseAlias = databaseAlias;
2525
+ sessionToken.expirationDate = expirationDate;
2526
+ sessionToken.isAuthenticated = true;
2527
+ sessionToken.isJwt = true;
2528
+ const client = new VVClient(sessionToken);
2529
+ return Promise.all([
2530
+ client.createDocApi(sessionToken),
2531
+ client.createFormsApi(sessionToken),
2532
+ client.createObjectsApi(sessionToken),
2533
+ client.createStudioApi(sessionToken)
2534
+ ]).then(() => client).catch((error) => {
2535
+ debug5("Failed to create specialized APIs: %s", error.message);
2536
+ return client;
2537
+ });
2538
+ } else {
2539
+ const token = await this.acquireJwt(jwt, baseVaultUrl, apiUrl, authenticationUrl, customerAlias, databaseAlias);
2540
+ const client = new VVClient(token);
2541
+ try {
2542
+ await Promise.all([
2543
+ client.createDocApi(token),
2544
+ client.createFormsApi(token),
2545
+ client.createObjectsApi(token),
2546
+ client.createStudioApi(token)
2547
+ ]);
2548
+ return client;
2549
+ } catch (error) {
2550
+ debug5("Failed to create specialized APIs: %s", error.message);
2551
+ return client;
2552
+ }
2553
+ }
2554
+ }
2555
+ endsWith(source, suffix) {
2556
+ return source.indexOf(suffix, source.length - suffix.length) !== -1;
2557
+ }
2558
+ };
2559
+ var forms = {
2560
+ returnField: ReturnField,
2561
+ formFieldCollection: FormFieldCollection
2562
+ };
2563
+ var VVRestApi_default = {
2564
+ vvClient: VVClient,
2565
+ authorize: Authorize2,
2566
+ forms
2567
+ };
2568
+ // Annotate the CommonJS export names for ESM import in node:
2569
+ 0 && (module.exports = {
2570
+ Authorize,
2571
+ VVClient,
2572
+ forms
2573
+ });
2574
+ //# sourceMappingURL=VVRestApi.cjs.map