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