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