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