visualvault-api 1.2.0 → 2.0.0-beta.2

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 (45) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +23 -140
  3. package/dist/VVRestApi.cjs +2552 -0
  4. package/dist/VVRestApi.cjs.map +1 -0
  5. package/dist/VVRestApi.d.cts +386 -0
  6. package/dist/VVRestApi.d.ts +386 -0
  7. package/dist/VVRestApi.js +2522 -0
  8. package/dist/VVRestApi.js.map +1 -0
  9. package/{lib/VVRestApi/VVRestApiNodeJs → dist}/config.yml +3 -3
  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 +2572 -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 +2541 -0
  21. package/dist/index.js.map +1 -0
  22. package/package.json +46 -70
  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/ObjectsApi.js +0 -138
  27. package/lib/VVRestApi/VVRestApiNodeJs/StudioApi.js +0 -156
  28. package/lib/VVRestApi/VVRestApiNodeJs/VVRestApi.js +0 -1974
  29. package/lib/VVRestApi/VVRestApiNodeJs/app.js +0 -128
  30. package/lib/VVRestApi/VVRestApiNodeJs/common.js +0 -1598
  31. package/lib/VVRestApi/VVRestApiNodeJs/dts/express.d.ts +0 -125
  32. package/lib/VVRestApi/VVRestApiNodeJs/dts/node.d.ts +0 -1090
  33. package/lib/VVRestApi/VVRestApiNodeJs/files/237de37cf014ee1199a400d49e26e066.js +0 -51
  34. package/lib/VVRestApi/VVRestApiNodeJs/files/437833dc404aed118b0e644bf02b9c8a.js +0 -1
  35. package/lib/VVRestApi/VVRestApiNodeJs/log.js +0 -20
  36. package/lib/VVRestApi/VVRestApiNodeJs/public/favicon.ico +0 -0
  37. package/lib/VVRestApi/VVRestApiNodeJs/routes/scheduledscripts.js +0 -203
  38. package/lib/VVRestApi/VVRestApiNodeJs/routes/scripts.js +0 -215
  39. package/lib/VVRestApi/VVRestApiNodeJs/routes/testScheduledScripts.js +0 -131
  40. package/lib/VVRestApi/VVRestApiNodeJs/samples/SampleScheduledScript.js +0 -90
  41. package/lib/VVRestApi/VVRestApiNodeJs/samples/SendEmailScript.js +0 -51
  42. package/lib/VVRestApi/VVRestApiNodeJs/samples/fileTest.js +0 -60
  43. package/lib/VVRestApi/VVRestApiNodeJs/samples/sampleFormValidationScript.js +0 -126
  44. package/lib/VVRestApi/VVRestApiNodeJs/views/error.ejs +0 -8
  45. package/lib/VVRestApi/VVRestApiNodeJs/views/index.ejs +0 -8
package/dist/index.cjs ADDED
@@ -0,0 +1,2572 @@
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/documentManager.js
612
+ init_cjs_shims();
613
+ var DocumentManager = 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.documents = new DocumentManager(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/modelManager.js
734
+ init_cjs_shims();
735
+ var ModelManager = 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 modelManager_default = ModelManager;
765
+
766
+ // lib/objectsApi/objectManager.js
767
+ init_cjs_shims();
768
+ var ObjectManager = 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 objectManager_default = ObjectManager;
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 modelManager_default(this._httpHelper);
866
+ this.objects = new objectManager_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/rolesAndPermissionsManager.js
976
+ init_cjs_shims();
977
+ var RolesAndPermissionsManager = class {
978
+ constructor(httpHelper) {
979
+ this._httpHelper = httpHelper;
980
+ }
981
+ /**
982
+ * Retrieves available features for the requesting user
983
+ * @param {object} params - Optional URL parameters to include in the request
984
+ */
985
+ async getUserFeatures(params) {
986
+ var resourceUri = this._httpHelper._config.ResourceUri.StudioApi.ResourceUserFeatures;
987
+ var url = this._httpHelper.getUrl(resourceUri);
988
+ var opts = { method: "GET" };
989
+ var data = {};
990
+ params = params || {};
991
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
992
+ }
993
+ };
994
+ var rolesAndPermissionsManager_default = RolesAndPermissionsManager;
995
+
996
+ // lib/StudioApi.js
997
+ var import_js_yaml5 = __toESM(require("js-yaml"), 1);
998
+ var import_fs5 = __toESM(require("fs"), 1);
999
+ var import_url4 = require("url");
1000
+ var import_path4 = __toESM(require("path"), 1);
1001
+ var __filename5 = (0, import_url4.fileURLToPath)(importMetaUrl);
1002
+ var __dirname4 = import_path4.default.dirname(__filename5);
1003
+ var StudioApi = class {
1004
+ constructor(sessionToken, studioApiConfig) {
1005
+ if (!sessionToken["tokenType"] && sessionToken["tokenType"] != "jwt") {
1006
+ return;
1007
+ }
1008
+ const yamlConfig = import_js_yaml5.default.load(import_fs5.default.readFileSync(__dirname4 + "/config.yml", "utf8"));
1009
+ this._httpHelper = new common_default.httpHelper(sessionToken, yamlConfig);
1010
+ this.isEnabled = studioApiConfig["isEnabled"] || false;
1011
+ this.baseUrl = studioApiConfig["studioApiUrl"] || null;
1012
+ if (this.isEnabled) {
1013
+ this.workflow = new workflowManager_default(this._httpHelper);
1014
+ this.permissions = new rolesAndPermissionsManager_default(this._httpHelper);
1015
+ }
1016
+ }
1017
+ };
1018
+ var StudioApi_default = StudioApi;
1019
+
1020
+ // lib/NotificationsApi.js
1021
+ init_cjs_shims();
1022
+
1023
+ // lib/notificationsApi/userNotificationsManager.js
1024
+ init_cjs_shims();
1025
+ var UserNotificationsManager = class {
1026
+ constructor(httpHelper) {
1027
+ this._httpHelper = httpHelper;
1028
+ }
1029
+ async forceUIRefresh(userGuid) {
1030
+ const resourceUri = this._httpHelper._config.ResourceUri.NotificationsApi.ForceUIRefresh.replace("{id}", userGuid);
1031
+ const url = this._httpHelper.getUrl(resourceUri);
1032
+ const opts = { method: "POST" };
1033
+ const params = {};
1034
+ const data = {};
1035
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1036
+ }
1037
+ };
1038
+ var userNotificationsManager_default = UserNotificationsManager;
1039
+
1040
+ // lib/NotificationsApi.js
1041
+ var import_js_yaml6 = __toESM(require("js-yaml"), 1);
1042
+ var import_fs6 = __toESM(require("fs"), 1);
1043
+ var import_url5 = require("url");
1044
+ var import_path5 = __toESM(require("path"), 1);
1045
+ var __filename6 = (0, import_url5.fileURLToPath)(importMetaUrl);
1046
+ var __dirname5 = import_path5.default.dirname(__filename6);
1047
+ var NotificationsApi = class {
1048
+ constructor(sessionToken, notificationsApiConfig) {
1049
+ if (!sessionToken["tokenType"] && sessionToken["tokenType"] != "jwt") {
1050
+ return;
1051
+ }
1052
+ const yamlConfig = import_js_yaml6.default.load(import_fs6.default.readFileSync(__dirname5 + "/config.yml", "utf8"));
1053
+ this._httpHelper = new common_default.httpHelper(sessionToken, yamlConfig);
1054
+ this.isEnabled = notificationsApiConfig["isEnabled"] || false;
1055
+ this.baseUrl = notificationsApiConfig["apiUrl"] || null;
1056
+ if (this.isEnabled) {
1057
+ this.users = new userNotificationsManager_default(this._httpHelper);
1058
+ }
1059
+ }
1060
+ };
1061
+ var NotificationsApi_default = NotificationsApi;
1062
+
1063
+ // lib/VVRestApi.js
1064
+ var import_js_yaml7 = __toESM(require("js-yaml"), 1);
1065
+ var import_fs7 = __toESM(require("fs"), 1);
1066
+ var import_url6 = require("url");
1067
+ var import_path6 = __toESM(require("path"), 1);
1068
+ var import_debug5 = __toESM(require("debug"), 1);
1069
+
1070
+ // lib/vvRestApi/constants.js
1071
+ init_cjs_shims();
1072
+ var Constants = class {
1073
+ constructor() {
1074
+ }
1075
+ alertEventIds = {
1076
+ // Folder Events
1077
+ folderSecurityModified: "F06FD123-2C52-4F43-9122-34335A5BD8C6",
1078
+ // "CategorySecurity"
1079
+ childFolderSecurityModified: "30167D46-86CF-4E89-B1AE-FC00BB378F67",
1080
+ // "CategorySecurityCascade"
1081
+ folderDocumentAdded: "3702CFBF-555C-4032-BFB2-E25829788BAC",
1082
+ // "NewCategoryDoc"
1083
+ childFolderDocumentAdded: "28946E3C-AEAF-402B-BCE3-8DEAC3D19877",
1084
+ // "NewCategoryDocCascade"
1085
+ // Document Events
1086
+ documentCheckedIn: "D47804AB-AEE9-4002-BAB5-9F1AC0366076",
1087
+ // "CheckIn"
1088
+ documentCheckedOut: "4BBA55C1-7AF6-48FF-BFBE-EC7A58EB7F01",
1089
+ // "CheckOut"
1090
+ documentDetailsModified: "3B9D493F-2B45-4877-ABC1-5CA74F92723D",
1091
+ // "DocumentDetails"
1092
+ documentSecurityModified: "BAC187DC-78A8-4A8B-B50F-DB5D5AEE11B9",
1093
+ // "DocumentSecurity"
1094
+ documentViewed: "140B9E97-8D93-48D0-837B-AB4FD419B6D6",
1095
+ // "DocumentViewed"
1096
+ // Project Events
1097
+ projectDocumentAddedOrRemoved: "300DB724-5C51-4C38-B2E2-FFE19634A373",
1098
+ // "NewProjectDoc"
1099
+ projectViewed: "92F0C5F4-68DC-4309-9ABF-13B8E2198F79"
1100
+ // "ProjectView"
1101
+ };
1102
+ securityRoles = {
1103
+ // RoleType
1104
+ Owner: "Owner",
1105
+ Editor: "Editor",
1106
+ Viewer: "Viewer"
1107
+ };
1108
+ securityMemberType = {
1109
+ // MemberType
1110
+ User: "User",
1111
+ Group: "Group"
1112
+ };
1113
+ relationType = {
1114
+ Parent: "Parent",
1115
+ Child: "Child",
1116
+ Peer: "Peer"
1117
+ };
1118
+ };
1119
+
1120
+ // lib/vvRestApi/configurationManager.js
1121
+ init_cjs_shims();
1122
+ var ConfigurationManager = class {
1123
+ constructor(httpHelper) {
1124
+ this._httpHelper = httpHelper;
1125
+ }
1126
+ getDocApiConfig() {
1127
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.ConfigurationDocApi);
1128
+ const opts = { method: "GET" };
1129
+ const params = {};
1130
+ const data = {};
1131
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1132
+ }
1133
+ getFormsApiConfig() {
1134
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.ConfigurationFormsApi);
1135
+ const opts = { method: "GET" };
1136
+ const params = {};
1137
+ const data = {};
1138
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1139
+ }
1140
+ getObjectsApiConfig() {
1141
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.ConfigurationObjectsApi);
1142
+ const opts = { method: "GET" };
1143
+ const params = {};
1144
+ const data = {};
1145
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1146
+ }
1147
+ getStudioApiConfig() {
1148
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.ConfigurationStudioApi);
1149
+ const opts = { method: "GET" };
1150
+ const params = {};
1151
+ const data = {};
1152
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1153
+ }
1154
+ getNotificationsApiConfig() {
1155
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.ConfigurationNotificationApi);
1156
+ const opts = { method: "GET" };
1157
+ const params = {};
1158
+ const data = {};
1159
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1160
+ }
1161
+ };
1162
+
1163
+ // lib/vvRestApi/emailManager.js
1164
+ init_cjs_shims();
1165
+ var EmailManager = class {
1166
+ constructor(httpHelper) {
1167
+ this._httpHelper = httpHelper;
1168
+ }
1169
+ postEmails(params, data) {
1170
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.Emails);
1171
+ const opts = { method: "POST" };
1172
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1173
+ }
1174
+ postEmailsWithAttachments(params, data, fileObjs) {
1175
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.Emails);
1176
+ const opts = { method: "POSTSTREAM" };
1177
+ return this._httpHelper.doVvClientRequest(url, opts, params, data, fileObjs);
1178
+ }
1179
+ };
1180
+
1181
+ // lib/vvRestApi/formsManager.js
1182
+ init_cjs_shims();
1183
+ var import_debug3 = __toESM(require("debug"), 1);
1184
+ var debug3 = (0, import_debug3.default)("visualvault:forms");
1185
+ var ReturnField = class {
1186
+ /** @type {string} */
1187
+ id;
1188
+ /** @type {string} */
1189
+ name;
1190
+ /** @type {*} */
1191
+ value;
1192
+ /** @type {boolean} */
1193
+ isError;
1194
+ /** @type {string} */
1195
+ errorMessage;
1196
+ /**
1197
+ * @param {string} id - Field ID
1198
+ * @param {string} name - Field name
1199
+ * @param {*} value - Field value
1200
+ * @param {boolean} isError - Whether field has an error
1201
+ * @param {string} errorMessage - Error message if any
1202
+ */
1203
+ constructor(id, name, value, isError, errorMessage) {
1204
+ this.id = id;
1205
+ this.name = name;
1206
+ this.value = value;
1207
+ this.isError = isError;
1208
+ this.errorMessage = errorMessage;
1209
+ }
1210
+ };
1211
+ var FormFieldCollection = class {
1212
+ /**
1213
+ * @param {Array<*>} ffColl - Array of form fields
1214
+ */
1215
+ constructor(ffColl) {
1216
+ this._ffColl = ffColl;
1217
+ }
1218
+ /**
1219
+ * Get a form field by name
1220
+ * @param {string} name - Field name to search for
1221
+ * @returns {*} The field or null if not found
1222
+ */
1223
+ getFormFieldByName(name) {
1224
+ const fieldName = name.toLowerCase();
1225
+ return this._ffColl.find(
1226
+ (field) => field.name.toLowerCase() === fieldName
1227
+ ) || null;
1228
+ }
1229
+ /**
1230
+ * Get a form field by ID
1231
+ * @param {string} id - Field ID to search for
1232
+ * @returns {*} The field or null if not found
1233
+ */
1234
+ getFormFieldById(id) {
1235
+ const fieldId = id.toLowerCase();
1236
+ return this._ffColl.find(
1237
+ (field) => field.id.toLowerCase() === fieldId
1238
+ ) || null;
1239
+ }
1240
+ /**
1241
+ * Get the array of all form fields
1242
+ * @returns {Array<*>} Array of form fields
1243
+ */
1244
+ getFieldArray() {
1245
+ return this._ffColl;
1246
+ }
1247
+ };
1248
+ var FormsManager = class {
1249
+ /**
1250
+ * @param {*} httpHelper - HTTP helper instance
1251
+ */
1252
+ constructor(httpHelper) {
1253
+ this._httpHelper = httpHelper;
1254
+ }
1255
+ returnField(id, name, value, isError, errorMessage) {
1256
+ return new ReturnField(id, name, value, isError, errorMessage);
1257
+ }
1258
+ getFormTemplates(params) {
1259
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.FormTemplates);
1260
+ const opts = { method: "GET" };
1261
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1262
+ }
1263
+ /**
1264
+ * @param {string} templateName
1265
+ * @returns {Promise<{formsManager: FormsManager, templateIdGuid: string, templateRevisionIdGuid: string, error?: string}>}
1266
+ */
1267
+ async getFormTemplateIdByName(templateName) {
1268
+ const params = {
1269
+ fields: "id, name, description, revision, revisionId",
1270
+ q: `name eq '${templateName}'`
1271
+ };
1272
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.FormTemplates);
1273
+ const opts = { method: "GET" };
1274
+ try {
1275
+ const resp = await this._httpHelper.doVvClientRequest(url, opts, params, null);
1276
+ const templateResp = JSON.parse(resp);
1277
+ let templateId;
1278
+ let templateRevisionId;
1279
+ if (templateResp.data && templateResp.data.length > 0) {
1280
+ templateId = templateResp.data[0].id;
1281
+ templateRevisionId = templateResp.data[0].revisionId;
1282
+ }
1283
+ return {
1284
+ formsManager: this,
1285
+ templateIdGuid: templateId,
1286
+ templateRevisionIdGuid: templateRevisionId
1287
+ };
1288
+ } catch (error) {
1289
+ debug3('Failed to get form template by name "%s": %s', templateName, error.message);
1290
+ return {
1291
+ formsManager: this,
1292
+ templateIdGuid: "",
1293
+ templateRevisionIdGuid: "",
1294
+ error: error.message
1295
+ };
1296
+ }
1297
+ }
1298
+ async getForms(params, formTemplateId) {
1299
+ if (!this.isGuid(formTemplateId)) {
1300
+ const resp = await this.getFormTemplateIdByName(formTemplateId);
1301
+ const templateIdGuid = resp.templateIdGuid;
1302
+ const resourceUri = this._httpHelper._config.ResourceUri.Forms.replace("{id}", templateIdGuid);
1303
+ const url = this._httpHelper.getUrl(resourceUri);
1304
+ const opts = { method: "GET" };
1305
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1306
+ } else {
1307
+ const resourceUri = this._httpHelper._config.ResourceUri.Forms.replace("{id}", formTemplateId);
1308
+ const url = this._httpHelper.getUrl(resourceUri);
1309
+ const opts = { method: "GET" };
1310
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1311
+ }
1312
+ }
1313
+ setFieldImage(formId, fieldId, imageId) {
1314
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstanceImage.replace("{id}", formId);
1315
+ const url = this._httpHelper.getUrl(resourceUri);
1316
+ const data = { fieldId, imageId };
1317
+ const params = { fieldId, imageId };
1318
+ const opts = { method: "PUT" };
1319
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1320
+ }
1321
+ importFormTemplate(data, formTemplateId, buffer) {
1322
+ const resourceUri = this._httpHelper._config.ResourceUri.FormTemplatesImport.replace("{id}", formTemplateId);
1323
+ const url = this._httpHelper.getUrl(resourceUri);
1324
+ const opts = { method: "PUTSTREAM" };
1325
+ return this._httpHelper.doVvClientRequest(url, opts, null, data, buffer);
1326
+ }
1327
+ async postForms(params, data, formTemplateId) {
1328
+ if (!this.isGuid(formTemplateId)) {
1329
+ const resp = await this.getFormTemplateIdByName(formTemplateId);
1330
+ const templateIdGuid = resp.templateIdGuid;
1331
+ const resourceUri = this._httpHelper._config.ResourceUri.Forms.replace("{id}", templateIdGuid);
1332
+ const url = this._httpHelper.getUrl(resourceUri);
1333
+ const opts = { method: "POST" };
1334
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1335
+ } else {
1336
+ const resourceUri = this._httpHelper._config.ResourceUri.Forms.replace("{id}", formTemplateId);
1337
+ const url = this._httpHelper.getUrl(resourceUri);
1338
+ const opts = { method: "POST" };
1339
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1340
+ }
1341
+ }
1342
+ async postFormRevision(params, data, formTemplateId, formId) {
1343
+ if (!this.isGuid(formTemplateId)) {
1344
+ const resp = await this.getFormTemplateIdByName(formTemplateId);
1345
+ const templateIdGuid = resp.templateIdGuid;
1346
+ const resourceUri = this._httpHelper._config.ResourceUri.Forms.replace("{id}", templateIdGuid);
1347
+ const url = this._httpHelper.getUrl(resourceUri + "/" + formId);
1348
+ const opts = { method: "POST" };
1349
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1350
+ } else {
1351
+ const resourceUri = this._httpHelper._config.ResourceUri.Forms.replace("{id}", formTemplateId);
1352
+ const url = this._httpHelper.getUrl(resourceUri + "/" + formId);
1353
+ const opts = { method: "POST" };
1354
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1355
+ }
1356
+ }
1357
+ postFormRevisionByFormId(params, data, formId) {
1358
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.FormsId).replace("{id}", formId);
1359
+ const opts = { method: "POST" };
1360
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1361
+ }
1362
+ updateFormInstanceOriginator(formInstanceId, newOriginatorUsID) {
1363
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstanceUpdateOriginator.replace("{id}", formInstanceId);
1364
+ const url = this._httpHelper.getUrl(resourceUri);
1365
+ const params = { userId: newOriginatorUsID };
1366
+ const data = null;
1367
+ const opts = { method: "PUT" };
1368
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1369
+ }
1370
+ relateForm(formId, relateToId) {
1371
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1372
+ const url = this._httpHelper.getUrl(resourceUri + "/relateForm");
1373
+ const params = { relateToId };
1374
+ const data = null;
1375
+ const opts = { method: "PUT" };
1376
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1377
+ }
1378
+ relateFormByDocId(formId, relateToDocId) {
1379
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1380
+ const url = this._httpHelper.getUrl(resourceUri + "/relateForm");
1381
+ const params = { relateToDocId };
1382
+ const data = null;
1383
+ const opts = { method: "PUT" };
1384
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1385
+ }
1386
+ relateDocument(formId, relateToId) {
1387
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1388
+ const url = this._httpHelper.getUrl(resourceUri + "/relateDocument");
1389
+ const params = { relateToId };
1390
+ const data = null;
1391
+ const opts = { method: "PUT" };
1392
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1393
+ }
1394
+ relateDocumentByDocId(formId, relateToDocId) {
1395
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1396
+ const url = this._httpHelper.getUrl(resourceUri + "/relateDocument");
1397
+ const params = { relateToDocId };
1398
+ const data = null;
1399
+ const opts = { method: "PUT" };
1400
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1401
+ }
1402
+ relateProject(formId, relateToId) {
1403
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1404
+ const url = this._httpHelper.getUrl(resourceUri + "/relateProject");
1405
+ const params = { relateToId };
1406
+ const data = null;
1407
+ const opts = { method: "PUT" };
1408
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1409
+ }
1410
+ relateProjectByName(formId, relateToProjectName) {
1411
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1412
+ const url = this._httpHelper.getUrl(resourceUri + "/relateProject");
1413
+ const params = { relateToProjectName };
1414
+ const data = null;
1415
+ const opts = { method: "PUT" };
1416
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1417
+ }
1418
+ unrelateForm(formId, relateToId) {
1419
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1420
+ const url = this._httpHelper.getUrl(resourceUri + "/unrelateForm");
1421
+ const params = { relateToId };
1422
+ const data = null;
1423
+ const opts = { method: "PUT" };
1424
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1425
+ }
1426
+ unrelateFormByDocId(formId, relateToDocId) {
1427
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1428
+ const url = this._httpHelper.getUrl(resourceUri + "/unrelateForm");
1429
+ const params = { relateToDocId };
1430
+ const data = null;
1431
+ const opts = { method: "PUT" };
1432
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1433
+ }
1434
+ unrelateDocument(formId, relateToId) {
1435
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1436
+ const url = this._httpHelper.getUrl(resourceUri + "/unrelateDocument");
1437
+ const params = { relateToId };
1438
+ const data = null;
1439
+ const opts = { method: "PUT" };
1440
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1441
+ }
1442
+ unrelateDocumentByDocId(formId, relateToDocId) {
1443
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1444
+ const url = this._httpHelper.getUrl(resourceUri + "/unrelateDocument");
1445
+ const params = { relateToDocId };
1446
+ const data = null;
1447
+ const opts = { method: "PUT" };
1448
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1449
+ }
1450
+ unrelateProject(formId, relateToId) {
1451
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1452
+ const url = this._httpHelper.getUrl(resourceUri + "/unrelateProject");
1453
+ const params = { relateToId };
1454
+ const data = null;
1455
+ const opts = { method: "PUT" };
1456
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1457
+ }
1458
+ unrelateProjectByName(formId, relateToProjectName) {
1459
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", formId);
1460
+ const url = this._httpHelper.getUrl(resourceUri + "/unrelateProject");
1461
+ const params = { relateToProjectName };
1462
+ const data = null;
1463
+ const opts = { method: "PUT" };
1464
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1465
+ }
1466
+ getFormRelatedDocs(formId, params) {
1467
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstanceRelatedDocs.replace("{id}", formId);
1468
+ const url = this._httpHelper.getUrl(resourceUri);
1469
+ const opts = { method: "GET" };
1470
+ if (params === void 0) {
1471
+ params = null;
1472
+ }
1473
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1474
+ }
1475
+ getFormRelatedForms(formId, params) {
1476
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstanceRelatedForms.replace("{id}", formId);
1477
+ const url = this._httpHelper.getUrl(resourceUri);
1478
+ const opts = { method: "GET" };
1479
+ if (params === void 0) {
1480
+ params = null;
1481
+ }
1482
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1483
+ }
1484
+ isGuid(stringToTest) {
1485
+ let testString = stringToTest;
1486
+ if (testString[0] === "{") {
1487
+ testString = testString.substring(1, testString.length - 1);
1488
+ }
1489
+ 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;
1490
+ return regexGuid.test(testString);
1491
+ }
1492
+ getFormInstanceById(templateId, instanceId) {
1493
+ const resourceUri = this._httpHelper._config.ResourceUri.FormId.replace("{id}", templateId).replace("{formId}", instanceId);
1494
+ const url = this._httpHelper.getUrl(resourceUri);
1495
+ const opts = { method: "GET" };
1496
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1497
+ }
1498
+ getFormInstancePDF(templateId, instanceId) {
1499
+ const resourceUri = this._httpHelper._config.ResourceUri.FormIdPdf.replace("{id}", templateId).replace("{formId}", instanceId);
1500
+ const url = this._httpHelper.getUrl(resourceUri);
1501
+ const opts = { method: "GETSTREAM" };
1502
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1503
+ }
1504
+ getFormTemplateFields(templateId) {
1505
+ const resourceUri = this._httpHelper._config.ResourceUri.FormDesignerFormsTemplatesIdFields.replace("{id}", templateId);
1506
+ const url = this._httpHelper.getUrl(resourceUri);
1507
+ const opts = { method: "GET" };
1508
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1509
+ }
1510
+ deleteFormInstance(instanceId) {
1511
+ const resourceUri = this._httpHelper._config.ResourceUri.FormInstance.replace("{id}", instanceId);
1512
+ const url = this._httpHelper.getUrl(resourceUri);
1513
+ const opts = { method: "DELETE" };
1514
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1515
+ }
1516
+ releaseFormTemplate(formTemplateId) {
1517
+ const resourceUri = this._httpHelper._config.ResourceUri.FormTemplatesRelease.replace("{id}", formTemplateId);
1518
+ const url = this._httpHelper.getUrl(resourceUri);
1519
+ const opts = { method: "PUT" };
1520
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1521
+ }
1522
+ };
1523
+
1524
+ // lib/vvRestApi/groupsManager.js
1525
+ init_cjs_shims();
1526
+ var GroupsManager = class {
1527
+ constructor(httpHelper) {
1528
+ this._httpHelper = httpHelper;
1529
+ }
1530
+ getGroups(params) {
1531
+ const resourceUri = this._httpHelper._config.ResourceUri.GetGroups;
1532
+ const url = this._httpHelper.getUrl(resourceUri);
1533
+ const opts = { method: "GET" };
1534
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1535
+ }
1536
+ getGroupsUsers(params, groupId) {
1537
+ const resourceUri = this._httpHelper._config.ResourceUri.GroupsUsers.replace("{id}", groupId);
1538
+ const url = this._httpHelper.getUrl(resourceUri);
1539
+ const opts = { method: "GET" };
1540
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1541
+ }
1542
+ getGroupUser(params, groupId, userId) {
1543
+ const resourceUri = this._httpHelper._config.ResourceUri.GroupsAddUser.replace("{groupId}", groupId).replace("{userId}", userId);
1544
+ const url = this._httpHelper.getUrl(resourceUri);
1545
+ const opts = { method: "GET" };
1546
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1547
+ }
1548
+ addUserToGroup(params, groupId, userId) {
1549
+ const resourceUri = this._httpHelper._config.ResourceUri.GroupsAddUser.replace("{groupId}", groupId).replace("{userId}", userId);
1550
+ const url = this._httpHelper.getUrl(resourceUri);
1551
+ const opts = { method: "PUT" };
1552
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1553
+ }
1554
+ removeUserFromGroup(params, groupId, userId) {
1555
+ const resourceUri = this._httpHelper._config.ResourceUri.GroupsAddUser.replace("{groupId}", groupId).replace("{userId}", userId);
1556
+ const url = this._httpHelper.getUrl(resourceUri);
1557
+ const opts = { method: "DELETE" };
1558
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1559
+ }
1560
+ };
1561
+
1562
+ // lib/vvRestApi/libraryManager.js
1563
+ init_cjs_shims();
1564
+ var LibraryManager = class {
1565
+ constructor(httpHelper) {
1566
+ this._httpHelper = httpHelper;
1567
+ }
1568
+ getFolders(params) {
1569
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.Folders);
1570
+ const opts = { method: "GET" };
1571
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1572
+ }
1573
+ postFolderByPath(params, data, folderPath) {
1574
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.Folders);
1575
+ data.folderpath = folderPath;
1576
+ const opts = { method: "POST" };
1577
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1578
+ }
1579
+ // Valid fields to be defined on the "data" parameter to be updated on the folder: name, description
1580
+ putFolder(params, data, folderId) {
1581
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.FoldersId.replace("{id}", folderId));
1582
+ const opts = { method: "PUT" };
1583
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1584
+ }
1585
+ deleteFolder(folderId) {
1586
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.FoldersId.replace("{id}", folderId));
1587
+ const opts = { method: "DELETE" };
1588
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1589
+ }
1590
+ copyFolder(params, data) {
1591
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.FoldersCopy);
1592
+ const opts = { method: "POST" };
1593
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
1594
+ }
1595
+ moveFolder(params, data) {
1596
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.FoldersMove);
1597
+ const opts = { method: "PUT" };
1598
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
1599
+ }
1600
+ getDocuments(params, folderId) {
1601
+ const resourceUri = this._httpHelper._config.ResourceUri.Documents.replace("{id}", folderId);
1602
+ const url = this._httpHelper.getUrl(resourceUri);
1603
+ const opts = { method: "GET" };
1604
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1605
+ }
1606
+ updateFolderIndexFieldOverrideSettings(folderId, fieldId, queryId, displayField, valueField, dropDownListId, required, defaultValue) {
1607
+ const data = {
1608
+ queryId,
1609
+ queryValueField: valueField,
1610
+ queryDisplayField: displayField,
1611
+ dropDownListId,
1612
+ required,
1613
+ defaultValue
1614
+ };
1615
+ const resourceUri = this._httpHelper._config.ResourceUri.FoldersIdIndexFieldsId.replace("{id}", folderId).replace("{indexFieldId}", fieldId);
1616
+ const url = this._httpHelper.getUrl(resourceUri);
1617
+ const opts = { method: "PUT" };
1618
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
1619
+ }
1620
+ getFolderIndexFields(params, folderId) {
1621
+ const resourceUri = this._httpHelper._config.ResourceUri.FolderIndexFields.replace("{id}", folderId);
1622
+ const url = this._httpHelper.getUrl(resourceUri);
1623
+ const opts = { method: "GET" };
1624
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1625
+ }
1626
+ postFolderAlertSubscription(folderId, eventId, userId) {
1627
+ const resourceUri = this._httpHelper._config.ResourceUri.FolderAlertsId.replace("{folderId}", folderId).replace("{eventId}", eventId);
1628
+ const url = this._httpHelper.getUrl(resourceUri);
1629
+ const opts = { method: "POST" };
1630
+ const params = {
1631
+ usId: userId
1632
+ };
1633
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1634
+ }
1635
+ deleteFolderAlertSubscription(folderId, eventId, userId) {
1636
+ const resourceUri = this._httpHelper._config.ResourceUri.FolderAlertsId.replace("{folderId}", folderId).replace("{eventId}", eventId);
1637
+ const url = this._httpHelper.getUrl(resourceUri);
1638
+ const opts = { method: "DELETE" };
1639
+ const params = {
1640
+ usId: userId
1641
+ };
1642
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1643
+ }
1644
+ getFolderSecurityMembers(params, folderId) {
1645
+ const resourceUri = this._httpHelper._config.ResourceUri.FolderSecurity.replace("{folderId}", folderId);
1646
+ const url = this._httpHelper.getUrl(resourceUri);
1647
+ const opts = { method: "GET" };
1648
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1649
+ }
1650
+ putFolderSecurityMember(folderId, memberId, memberType, securityRole, cascadeSecurityChanges) {
1651
+ const resourceUri = this._httpHelper._config.ResourceUri.FolderSecurityId.replace("{folderId}", folderId).replace("{memberId}", memberId);
1652
+ const url = this._httpHelper.getUrl(resourceUri);
1653
+ const opts = { method: "PUT" };
1654
+ const data = {
1655
+ memberType,
1656
+ securityRole,
1657
+ cascadeSecurityChanges
1658
+ };
1659
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
1660
+ }
1661
+ deleteFolderSecurityMember(folderId, memberId, cascadeSecurityChanges) {
1662
+ const resourceUri = this._httpHelper._config.ResourceUri.FolderSecurityId.replace("{folderId}", folderId).replace("{memberId}", memberId);
1663
+ const url = this._httpHelper.getUrl(resourceUri);
1664
+ const opts = { method: "DELETE" };
1665
+ const params = {
1666
+ cascadeSecurityChanges
1667
+ };
1668
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1669
+ }
1670
+ };
1671
+
1672
+ // lib/vvRestApi/sitesManager.js
1673
+ init_cjs_shims();
1674
+ var SitesManager = class {
1675
+ constructor(httpHelper) {
1676
+ this._httpHelper = httpHelper;
1677
+ }
1678
+ getSites(params) {
1679
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.Sites);
1680
+ const opts = { method: "GET" };
1681
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1682
+ }
1683
+ postSites(params, data) {
1684
+ const resourceUri = this._httpHelper._config.ResourceUri.Sites;
1685
+ const url = this._httpHelper.getUrl(resourceUri);
1686
+ const opts = { method: "POST" };
1687
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1688
+ }
1689
+ putSites(params, data, siteId) {
1690
+ const resourceUri = this._httpHelper._config.ResourceUri.Sites;
1691
+ const url = this._httpHelper.getUrl(resourceUri + "/" + siteId);
1692
+ const opts = { method: "PUT" };
1693
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1694
+ }
1695
+ getGroups(params, siteId) {
1696
+ const resourceUri = this._httpHelper._config.ResourceUri.Groups.replace("{id}", siteId);
1697
+ const url = this._httpHelper.getUrl(resourceUri);
1698
+ const opts = { method: "GET" };
1699
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1700
+ }
1701
+ postGroups(params, data, siteId) {
1702
+ const resourceUri = this._httpHelper._config.ResourceUri.Groups.replace("{id}", siteId);
1703
+ const url = this._httpHelper.getUrl(resourceUri);
1704
+ const opts = { method: "POST" };
1705
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1706
+ }
1707
+ putGroups(params, data, siteId, grId) {
1708
+ const resourceUri = this._httpHelper._config.ResourceUri.Groups.replace("{id}", siteId);
1709
+ const url = this._httpHelper.getUrl(resourceUri + "/" + grId);
1710
+ const opts = { method: "PUT" };
1711
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1712
+ }
1713
+ changeUserSite(userId, newSiteId) {
1714
+ const resourceUri = this._httpHelper._config.ResourceUri.ChangeUserSite;
1715
+ const url = this._httpHelper.getUrl(resourceUri);
1716
+ const opts = { method: "PUT" };
1717
+ const data = {
1718
+ UserId: userId,
1719
+ NewSiteId: newSiteId
1720
+ };
1721
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
1722
+ }
1723
+ };
1724
+
1725
+ // lib/vvRestApi/usersManager.js
1726
+ init_cjs_shims();
1727
+ var UsersManager = class {
1728
+ constructor(httpHelper) {
1729
+ this._httpHelper = httpHelper;
1730
+ }
1731
+ getUsers(params, siteId) {
1732
+ const resourceUri = this._httpHelper._config.ResourceUri.Users.replace("{id}", siteId);
1733
+ const url = this._httpHelper.getUrl(resourceUri);
1734
+ const opts = { method: "GET" };
1735
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1736
+ }
1737
+ postUsers(params, data, siteId) {
1738
+ const resourceUri = this._httpHelper._config.ResourceUri.Users.replace("{id}", siteId);
1739
+ const url = this._httpHelper.getUrl(resourceUri);
1740
+ const opts = { method: "POST" };
1741
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1742
+ }
1743
+ putUsers(params, data, siteId, usId) {
1744
+ const resourceUri = this._httpHelper._config.ResourceUri.Users.replace("{id}", siteId);
1745
+ const url = this._httpHelper.getUrl(resourceUri + "/" + usId);
1746
+ const opts = { method: "PUT" };
1747
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1748
+ }
1749
+ putUsersEndpoint(params, data, usId) {
1750
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.User + "/" + usId);
1751
+ const opts = { method: "PUT" };
1752
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1753
+ }
1754
+ getUser(params) {
1755
+ const resourceUri = this._httpHelper._config.ResourceUri.User;
1756
+ const url = this._httpHelper.getUrl(resourceUri);
1757
+ const opts = { method: "GET" };
1758
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1759
+ }
1760
+ getUserById(params, usId) {
1761
+ const resourceUri = this._httpHelper._config.ResourceUri.UserById.replace("{id}", usId);
1762
+ const url = this._httpHelper.getUrl(resourceUri);
1763
+ const opts = { method: "GET" };
1764
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1765
+ }
1766
+ getUserGroups(params, usId) {
1767
+ const resourceUri = this._httpHelper._config.ResourceUri.UserGroups.replace("{id}", usId);
1768
+ const url = this._httpHelper.getUrl(resourceUri);
1769
+ const opts = { method: "GET" };
1770
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1771
+ }
1772
+ getUserSupervisors(params, usId) {
1773
+ const resourceUri = this._httpHelper._config.ResourceUri.UserSupervisors.replace("{id}", usId);
1774
+ const url = this._httpHelper.getUrl(resourceUri);
1775
+ const opts = { method: "GET" };
1776
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1777
+ }
1778
+ getUserSupervisees(params, usId) {
1779
+ const resourceUri = this._httpHelper._config.ResourceUri.UserSupervisees.replace("{id}", usId);
1780
+ const url = this._httpHelper.getUrl(resourceUri);
1781
+ const opts = { method: "GET" };
1782
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1783
+ }
1784
+ getUserLoginToken(usId) {
1785
+ const resourceUri = this._httpHelper._config.ResourceUri.UserWebToken.replace("{id}", usId);
1786
+ const url = this._httpHelper.getUrl(resourceUri);
1787
+ const opts = { method: "GET" };
1788
+ const params = [];
1789
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1790
+ }
1791
+ getUserJwt(audience) {
1792
+ const resourceUri = this._httpHelper._config.ResourceUri.UsersGetJwt;
1793
+ const url = this._httpHelper.getUrl(resourceUri);
1794
+ const opts = { method: "GET" };
1795
+ const params = {};
1796
+ if (audience) {
1797
+ params["audience"] = audience;
1798
+ }
1799
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1800
+ }
1801
+ getCurrentUser() {
1802
+ const resourceUri = this._httpHelper._config.ResourceUri.UsersMe;
1803
+ const url = this._httpHelper.getUrl(resourceUri);
1804
+ const opts = { method: "GET" };
1805
+ const params = [];
1806
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1807
+ }
1808
+ resetPassword(usId, sendEmail = true) {
1809
+ const resourceUri = this._httpHelper._config.ResourceUri.UsersPassword.replace("{id}", usId);
1810
+ const url = this._httpHelper.getUrl(resourceUri);
1811
+ const opts = { method: "PUT" };
1812
+ const params = [];
1813
+ const data = {
1814
+ resetPassword: true,
1815
+ sendEmail
1816
+ };
1817
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1818
+ }
1819
+ updateUserId(usId, newUserId) {
1820
+ const resourceUri = this._httpHelper._config.ResourceUri.UsersIdUserId.replace("{id}", usId);
1821
+ const url = this._httpHelper.getUrl(resourceUri);
1822
+ const opts = { method: "PUT" };
1823
+ const params = [];
1824
+ const data = {
1825
+ userId: newUserId
1826
+ };
1827
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
1828
+ }
1829
+ };
1830
+
1831
+ // lib/vvRestApi/currentUserManager.js
1832
+ init_cjs_shims();
1833
+ var CurrentUserManager = class {
1834
+ constructor(httpHelper) {
1835
+ this._httpHelper = httpHelper;
1836
+ }
1837
+ /**
1838
+ * Gets the currently authenticated user's information.
1839
+ * @param {Object} [params] - Optional query parameters.
1840
+ * @returns {Promise<string>} A promise that resolves with the current user's information as a JSON string.
1841
+ */
1842
+ async getCurrentUser(params) {
1843
+ var resourceUri = this._httpHelper._config.ResourceUri.UsersMe;
1844
+ var url = this._httpHelper.getUrl(resourceUri);
1845
+ var opts = { method: "GET" };
1846
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1847
+ }
1848
+ };
1849
+
1850
+ // lib/vvRestApi/scheduledProcessManager.js
1851
+ init_cjs_shims();
1852
+ var ScheduledProcessManager = class {
1853
+ constructor(httpHelper) {
1854
+ this._httpHelper = httpHelper;
1855
+ }
1856
+ postCompletion(id, action, result, message) {
1857
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.ScheduledProcess) + "/" + id;
1858
+ const opts = { method: "POST" };
1859
+ const params = {
1860
+ action
1861
+ };
1862
+ if (result !== null && (typeof result === "boolean" || result.length > 0)) {
1863
+ params.result = result.toString();
1864
+ }
1865
+ if (message && message.length > 0) {
1866
+ params.message = message;
1867
+ }
1868
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1869
+ }
1870
+ runAllScheduledProcesses() {
1871
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.ScheduledProcess) + "/Run";
1872
+ const opts = { method: "PUT" };
1873
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1874
+ }
1875
+ };
1876
+
1877
+ // lib/vvRestApi/customQueryManager.js
1878
+ init_cjs_shims();
1879
+ var CustomQueryManager = class {
1880
+ constructor(httpHelper) {
1881
+ this._httpHelper = httpHelper;
1882
+ }
1883
+ getCustomQueryResultsByName(queryName, params) {
1884
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.CustomQuery);
1885
+ const opts = { method: "GET" };
1886
+ if (!params) {
1887
+ params = {};
1888
+ }
1889
+ params.queryName = queryName;
1890
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1891
+ }
1892
+ getCustomQueryResultsById(id, params) {
1893
+ const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.CustomQuery + "/" + id);
1894
+ const opts = { method: "GET" };
1895
+ if (!params) {
1896
+ params = {};
1897
+ }
1898
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1899
+ }
1900
+ };
1901
+
1902
+ // lib/vvRestApi/customerManager.js
1903
+ init_cjs_shims();
1904
+ var CustomerManager = class {
1905
+ constructor(httpHelper) {
1906
+ this._httpHelper = httpHelper;
1907
+ }
1908
+ createCustomerInvite(data) {
1909
+ const baseUrl = this._httpHelper._sessionToken.baseUrl;
1910
+ let url = baseUrl + "/api/v1/" + this._httpHelper._config.ResourceUri.CustomerInvite;
1911
+ url = url.replace(/\/api\/\//g, "/api/");
1912
+ url = url.replace(/\/v1\/\//g, "/v1/");
1913
+ const opts = { method: "POST" };
1914
+ return this._httpHelper.doVvClientRequest(url, opts, "", data);
1915
+ }
1916
+ assignUser(customerId, data) {
1917
+ const baseUrl = this._httpHelper._sessionToken.baseUrl;
1918
+ const url = baseUrl + "/api/v1/" + this._httpHelper._config.ResourceUri.CustomerAssignUser.replace("{customerId}", customerId);
1919
+ const opts = { method: "PUT" };
1920
+ return this._httpHelper.doVvClientRequest(url, opts, "", data);
1921
+ }
1922
+ };
1923
+
1924
+ // lib/vvRestApi/customerDatabaseManager.js
1925
+ init_cjs_shims();
1926
+ var import_debug4 = __toESM(require("debug"), 1);
1927
+ var debug4 = (0, import_debug4.default)("visualvault:customer-db");
1928
+ var CustomerDatabaseManager = class {
1929
+ constructor(httpHelper) {
1930
+ this._httpHelper = httpHelper;
1931
+ }
1932
+ assignUser(customerId, data) {
1933
+ const baseUrl = this._httpHelper._sessionToken.baseUrl;
1934
+ const url = baseUrl + "/api/v1/" + this._httpHelper._config.ResourceUri.CustomerDatabaseAssignUser.replace("{databaseId}", customerId);
1935
+ const opts = { method: "PUT" };
1936
+ return this._httpHelper.doVvClientRequest(url, opts, "", data);
1937
+ }
1938
+ removeUser(authenticationUserId, databaseId) {
1939
+ const baseUrl = this._httpHelper._sessionToken.baseUrl;
1940
+ let url = baseUrl + "/api/v1" + this._httpHelper._config.ResourceUri.UserDelete.replace("{databaseId}", databaseId);
1941
+ url = url.replace("{authenticationUserId}", authenticationUserId);
1942
+ debug4("Removing user %s from database %s: %s", authenticationUserId, databaseId, url);
1943
+ const opts = { method: "DELETE" };
1944
+ const params = [];
1945
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
1946
+ }
1947
+ };
1948
+
1949
+ // lib/vvRestApi/filesManager.js
1950
+ init_cjs_shims();
1951
+ var FilesManager = class {
1952
+ constructor(httpHelper) {
1953
+ this._httpHelper = httpHelper;
1954
+ }
1955
+ getFileBytesQuery(query) {
1956
+ const resourceUri = this._httpHelper._config.ResourceUri.FilesQuery + query;
1957
+ const url = this._httpHelper.getUrl(resourceUri);
1958
+ const opts = { method: "GETSTREAM" };
1959
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1960
+ }
1961
+ getFileBytesId(id) {
1962
+ const resourceUri = this._httpHelper._config.ResourceUri.FilesId.replace("{id}", id);
1963
+ const url = this._httpHelper.getUrl(resourceUri);
1964
+ const opts = { method: "GETSTREAM" };
1965
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
1966
+ }
1967
+ postFile(data, buffer) {
1968
+ const resourceUri = this._httpHelper._config.ResourceUri.Files;
1969
+ const url = this._httpHelper.getUrl(resourceUri);
1970
+ const opts = { method: "POSTSTREAM" };
1971
+ return this._httpHelper.doVvClientRequest(url, opts, null, data, buffer);
1972
+ }
1973
+ };
1974
+
1975
+ // lib/vvRestApi/scriptsManager.js
1976
+ init_cjs_shims();
1977
+ var ScriptsManager = class {
1978
+ constructor(httpHelper) {
1979
+ this._httpHelper = httpHelper;
1980
+ }
1981
+ runWebService(serviceName, serviceData, usId) {
1982
+ let resourceUri = this._httpHelper._config.ResourceUri.Scripts + "?name=" + serviceName;
1983
+ if (typeof usId !== "undefined" && usId !== null) {
1984
+ resourceUri += `&usId=${usId}`;
1985
+ }
1986
+ const url = this._httpHelper.getUrl(resourceUri);
1987
+ const opts = { method: "POST" };
1988
+ return this._httpHelper.doVvClientRequest(url, opts, null, serviceData);
1989
+ }
1990
+ completeWorkflowWebService(executionId, workflowVariables) {
1991
+ const resourceUri = this._httpHelper._config.ResourceUri.ScriptsCompleteWf;
1992
+ const url = this._httpHelper.getUrl(resourceUri);
1993
+ const opts = { method: "POST" };
1994
+ const postData = {
1995
+ executionId,
1996
+ workflowVariables
1997
+ };
1998
+ return this._httpHelper.doVvClientRequest(url, opts, null, postData);
1999
+ }
2000
+ };
2001
+
2002
+ // lib/vvRestApi/documentsManager.js
2003
+ init_cjs_shims();
2004
+ var DocumentsManager = class {
2005
+ constructor(httpHelper) {
2006
+ this._httpHelper = httpHelper;
2007
+ }
2008
+ postDoc(data) {
2009
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsPost;
2010
+ const url = this._httpHelper.getUrl(resourceUri);
2011
+ const opts = { method: "POST" };
2012
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
2013
+ }
2014
+ postDocWithFile(data, fileData) {
2015
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsPost;
2016
+ const url = this._httpHelper.getUrl(resourceUri);
2017
+ const opts = { method: "POSTSTREAM" };
2018
+ return this._httpHelper.doVvClientRequest(url, opts, null, data, fileData);
2019
+ }
2020
+ copyDocument(params, data, documentId) {
2021
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsIdCopy.replace("{id}", documentId);
2022
+ const url = this._httpHelper.getUrl(resourceUri);
2023
+ const opts = { method: "POST" };
2024
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
2025
+ }
2026
+ moveDocument(params, data, documentId) {
2027
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsIdMove.replace("{id}", documentId);
2028
+ const url = this._httpHelper.getUrl(resourceUri);
2029
+ const opts = { method: "PUT" };
2030
+ return this._httpHelper.doVvClientRequest(url, opts, params, data);
2031
+ }
2032
+ deleteDocument(params, revisionId) {
2033
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsId.replace("{id}", revisionId);
2034
+ const url = this._httpHelper.getUrl(resourceUri);
2035
+ const opts = { method: "DELETE" };
2036
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2037
+ }
2038
+ getDocumentRevision(params, revisionId) {
2039
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsId.replace("{id}", revisionId);
2040
+ const url = this._httpHelper.getUrl(resourceUri);
2041
+ const opts = { method: "GET" };
2042
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2043
+ }
2044
+ getDocuments(params) {
2045
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsPost;
2046
+ const url = this._httpHelper.getUrl(resourceUri);
2047
+ const opts = { method: "GET" };
2048
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2049
+ }
2050
+ putDocumentIndexFields(data, documentId) {
2051
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentIndexFields.replace("{id}", documentId);
2052
+ const url = this._httpHelper.getUrl(resourceUri);
2053
+ const opts = { method: "PUT" };
2054
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
2055
+ }
2056
+ postDocumentAlertSubscription(documentId, eventId, userId) {
2057
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentAlertsId.replace("{documentId}", documentId).replace("{eventId}", eventId);
2058
+ const url = this._httpHelper.getUrl(resourceUri);
2059
+ const opts = { method: "POST" };
2060
+ const params = {
2061
+ usId: userId
2062
+ };
2063
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2064
+ }
2065
+ deleteDocumentAlertSubscription(documentId, eventId, userId) {
2066
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentAlertsId.replace("{documentId}", documentId).replace("{eventId}", eventId);
2067
+ const url = this._httpHelper.getUrl(resourceUri);
2068
+ const opts = { method: "DELETE" };
2069
+ const params = {
2070
+ usId: userId
2071
+ };
2072
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2073
+ }
2074
+ getDocumentRevisionOcrProperties(params, revisionId) {
2075
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsIdOcr.replace("{id}", revisionId);
2076
+ const url = this._httpHelper.getUrl(resourceUri);
2077
+ const opts = { method: "GET" };
2078
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2079
+ }
2080
+ relateDocuments(revisionId, relateToRevisionId, relateType) {
2081
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsIdRelateDocument.replace("{id}", revisionId);
2082
+ const url = this._httpHelper.getUrl(resourceUri);
2083
+ const opts = { method: "PUT" };
2084
+ const data = {
2085
+ relateToId: relateToRevisionId,
2086
+ relateType
2087
+ };
2088
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
2089
+ }
2090
+ updateDocumentExpiration(documentId, expirationDate) {
2091
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsIdExpiration.replace("{id}", documentId);
2092
+ const url = this._httpHelper.getUrl(resourceUri);
2093
+ const opts = { method: "PUT" };
2094
+ const data = {
2095
+ expirationDate
2096
+ };
2097
+ return this._httpHelper.doVvClientRequest(url, opts, null, data);
2098
+ }
2099
+ getDocumentWebDavUrl(documentId) {
2100
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsWebDavUrl.replace("{id}", documentId);
2101
+ const url = this._httpHelper.getUrl(resourceUri);
2102
+ const opts = { method: "GET" };
2103
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
2104
+ }
2105
+ getDocumentWopiUrl(documentId) {
2106
+ const resourceUri = this._httpHelper._config.ResourceUri.DocumentsWopiUrl.replace("{id}", documentId);
2107
+ const url = this._httpHelper.getUrl(resourceUri);
2108
+ const opts = { method: "GET" };
2109
+ return this._httpHelper.doVvClientRequest(url, opts, null, null);
2110
+ }
2111
+ };
2112
+
2113
+ // lib/vvRestApi/projectsManager.js
2114
+ init_cjs_shims();
2115
+ var ProjectsManager = class {
2116
+ constructor(httpHelper) {
2117
+ this._httpHelper = httpHelper;
2118
+ }
2119
+ postProjectAlertSubscription(projectId, eventId, userId) {
2120
+ const resourceUri = this._httpHelper._config.ResourceUri.ProjectAlertsId.replace("{projectId}", projectId).replace("{eventId}", eventId);
2121
+ const url = this._httpHelper.getUrl(resourceUri);
2122
+ const opts = { method: "POST" };
2123
+ const params = {
2124
+ usId: userId
2125
+ };
2126
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2127
+ }
2128
+ deleteProjectAlertSubscription(projectId, eventId, userId) {
2129
+ const resourceUri = this._httpHelper._config.ResourceUri.ProjectAlertsId.replace("{projectId}", projectId).replace("{eventId}", eventId);
2130
+ const url = this._httpHelper.getUrl(resourceUri);
2131
+ const opts = { method: "DELETE" };
2132
+ const params = {
2133
+ usId: userId
2134
+ };
2135
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2136
+ }
2137
+ };
2138
+
2139
+ // lib/vvRestApi/indexFieldsManager.js
2140
+ init_cjs_shims();
2141
+ var IndexFieldsManager = class {
2142
+ constructor(httpHelper) {
2143
+ this._httpHelper = httpHelper;
2144
+ }
2145
+ getIndexFields(params) {
2146
+ const resourceUri = this._httpHelper._config.ResourceUri.IndexFields;
2147
+ const url = this._httpHelper.getUrl(resourceUri);
2148
+ const opts = { method: "GET" };
2149
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2150
+ }
2151
+ };
2152
+
2153
+ // lib/vvRestApi/outsideProcessesManager.js
2154
+ init_cjs_shims();
2155
+ var OutsideProcessesManager = class {
2156
+ constructor(httpHelper) {
2157
+ this._httpHelper = httpHelper;
2158
+ }
2159
+ getOutsideProcesses(params) {
2160
+ const resourceUri = this._httpHelper._config.ResourceUri.OutsideProcesses;
2161
+ const url = this._httpHelper.getUrl(resourceUri);
2162
+ const opts = { method: "GET" };
2163
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2164
+ }
2165
+ };
2166
+
2167
+ // lib/vvRestApi/securityMembersManager.js
2168
+ init_cjs_shims();
2169
+ var SecurityMembersManager = class {
2170
+ constructor(httpHelper) {
2171
+ this._httpHelper = httpHelper;
2172
+ }
2173
+ addSecurityMember(parentId, memberId, roleType, isGroup) {
2174
+ const resourceUri = this._httpHelper._config.ResourceUri.SecurityMembers;
2175
+ const url = this._httpHelper.getUrl(resourceUri);
2176
+ const opts = { method: "POST" };
2177
+ const postData = {
2178
+ parentId,
2179
+ memberId,
2180
+ role: roleType,
2181
+ isGroup
2182
+ };
2183
+ return this._httpHelper.doVvClientRequest(url, opts, null, postData);
2184
+ }
2185
+ getSecurityMembersForParentId(parentId) {
2186
+ const resourceUri = this._httpHelper._config.ResourceUri.SecurityMembers;
2187
+ const url = this._httpHelper.getUrl(resourceUri);
2188
+ const opts = { method: "GET" };
2189
+ const params = {
2190
+ parentId
2191
+ };
2192
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2193
+ }
2194
+ removeSecurityMember(parentId, memberId) {
2195
+ const resourceUri = this._httpHelper._config.ResourceUri.SecurityMembers;
2196
+ const url = this._httpHelper.getUrl(resourceUri);
2197
+ const opts = { method: "DELETE" };
2198
+ const params = {
2199
+ parentId,
2200
+ memberId
2201
+ };
2202
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2203
+ }
2204
+ updateSecurityMember(parentId, memberId, roleType) {
2205
+ const resourceUri = this._httpHelper._config.ResourceUri.SecurityMembers;
2206
+ const url = this._httpHelper.getUrl(resourceUri);
2207
+ const opts = { method: "PUT" };
2208
+ const postData = {
2209
+ parentId,
2210
+ memberId,
2211
+ role: roleType
2212
+ };
2213
+ return this._httpHelper.doVvClientRequest(url, opts, null, postData);
2214
+ }
2215
+ };
2216
+
2217
+ // lib/vvRestApi/layoutsManager.js
2218
+ init_cjs_shims();
2219
+ var LayoutsManager = class {
2220
+ constructor(httpHelper) {
2221
+ this._httpHelper = httpHelper;
2222
+ }
2223
+ getLayout() {
2224
+ const resourceUri = this._httpHelper._config.ResourceUri.Layout;
2225
+ const url = this._httpHelper.getUrl(resourceUri);
2226
+ const opts = { method: "GET" };
2227
+ return this._httpHelper.doVvClientRequest(url, opts, {}, null);
2228
+ }
2229
+ };
2230
+
2231
+ // lib/vvRestApi/reportsManager.js
2232
+ init_cjs_shims();
2233
+ var ReportsManager = class {
2234
+ constructor(httpHelper) {
2235
+ this._httpHelper = httpHelper;
2236
+ }
2237
+ getReportPDF(reportId, params) {
2238
+ const resourceUri = this._httpHelper._config.ResourceUri.ReportServerPDF.replace("{id}", reportId);
2239
+ const url = this._httpHelper.getUrl(resourceUri);
2240
+ const opts = { method: "GETSTREAM" };
2241
+ return this._httpHelper.doVvClientRequest(url, opts, params, null);
2242
+ }
2243
+ };
2244
+
2245
+ // lib/VVRestApi.js
2246
+ var debug5 = (0, import_debug5.default)("visualvault:api");
2247
+ var __filename7 = (0, import_url6.fileURLToPath)(importMetaUrl);
2248
+ var __dirname6 = import_path6.default.dirname(__filename7);
2249
+ var VVClient = class {
2250
+ /** @type {*} */
2251
+ constants;
2252
+ /** @type {*} */
2253
+ configuration;
2254
+ /** @type {*} */
2255
+ customQuery;
2256
+ /** @type {*} */
2257
+ documents;
2258
+ /** @type {*} */
2259
+ email;
2260
+ /** @type {*} */
2261
+ files;
2262
+ /** @type {*} */
2263
+ forms;
2264
+ /** @type {*} */
2265
+ groups;
2266
+ /** @type {*} */
2267
+ library;
2268
+ /** @type {*} */
2269
+ sites;
2270
+ /** @type {*} */
2271
+ users;
2272
+ /** @type {*} */
2273
+ scheduledProcess;
2274
+ /** @type {*} */
2275
+ scripts;
2276
+ /** @type {*} */
2277
+ projects;
2278
+ /** @type {*} */
2279
+ customer;
2280
+ /** @type {*} */
2281
+ customerDatabase;
2282
+ /** @type {*} */
2283
+ indexFields;
2284
+ /** @type {*} */
2285
+ outsideProcesses;
2286
+ /** @type {*} */
2287
+ securityMembers;
2288
+ /** @type {*} */
2289
+ layouts;
2290
+ /** @type {*} */
2291
+ reports;
2292
+ /**
2293
+ * @param {*} sessionToken - Session token from authentication
2294
+ */
2295
+ constructor(sessionToken) {
2296
+ this.yamlConfig = import_js_yaml7.default.load(import_fs7.default.readFileSync(import_path6.default.join(__dirname6, "config.yml"), "utf8"));
2297
+ this._httpHelper = new common_default.httpHelper(sessionToken, this.yamlConfig);
2298
+ this.constants = new Constants();
2299
+ this.configuration = new ConfigurationManager(this._httpHelper);
2300
+ this.customQuery = new CustomQueryManager(this._httpHelper);
2301
+ this.documents = new DocumentsManager(this._httpHelper);
2302
+ this.email = new EmailManager(this._httpHelper);
2303
+ this.files = new FilesManager(this._httpHelper);
2304
+ this.forms = new FormsManager(this._httpHelper);
2305
+ this.groups = new GroupsManager(this._httpHelper);
2306
+ this.library = new LibraryManager(this._httpHelper);
2307
+ this.sites = new SitesManager(this._httpHelper);
2308
+ this.users = new UsersManager(this._httpHelper);
2309
+ this.currentUser = new CurrentUserManager(this._httpHelper);
2310
+ this.scheduledProcess = new ScheduledProcessManager(this._httpHelper);
2311
+ this.scripts = new ScriptsManager(this._httpHelper);
2312
+ this.projects = new ProjectsManager(this._httpHelper);
2313
+ this.customer = new CustomerManager(this._httpHelper);
2314
+ this.customerDatabase = new CustomerDatabaseManager(this._httpHelper);
2315
+ this.indexFields = new IndexFieldsManager(this._httpHelper);
2316
+ this.outsideProcesses = new OutsideProcessesManager(this._httpHelper);
2317
+ this.securityMembers = new SecurityMembersManager(this._httpHelper);
2318
+ this.layouts = new LayoutsManager(this._httpHelper);
2319
+ this.reports = new ReportsManager(this._httpHelper);
2320
+ this.docApi = null;
2321
+ this.formsApi = null;
2322
+ this.objectsApi = null;
2323
+ this.studioApi = null;
2324
+ this.notificationsApi = null;
2325
+ }
2326
+ async createDocApi(sessionToken) {
2327
+ const docApiConfigResponse = JSON.parse(await this.configuration.getDocApiConfig());
2328
+ if (docApiConfigResponse && docApiConfigResponse["data"]) {
2329
+ const docApiSession = sessionToken.createCopy();
2330
+ docApiSession.baseUrl = docApiConfigResponse.data["apiUrl"];
2331
+ docApiSession.apiUrl = this.yamlConfig.DocApiUri;
2332
+ if (docApiSession["tokenType"] == "jwt") {
2333
+ this.docApi = new DocApi_default(docApiSession, docApiConfigResponse.data);
2334
+ } else if (this.users) {
2335
+ const jwtResponse = JSON.parse(await this.users.getUserJwt(docApiSession.audience));
2336
+ if (jwtResponse["data"] && jwtResponse["data"]["token"]) {
2337
+ docApiSession.convertToJwt(jwtResponse["data"]);
2338
+ this.docApi = new DocApi_default(docApiSession, docApiConfigResponse.data);
2339
+ }
2340
+ }
2341
+ }
2342
+ }
2343
+ async createFormsApi(sessionToken) {
2344
+ const formsApiConfigResponse = JSON.parse(await this.configuration.getFormsApiConfig());
2345
+ if (formsApiConfigResponse && formsApiConfigResponse["data"]) {
2346
+ const formsApiSession = sessionToken.createCopy();
2347
+ formsApiSession.baseUrl = formsApiConfigResponse.data["formsApiUrl"];
2348
+ formsApiSession.apiUrl = this.yamlConfig.FormsApiUri;
2349
+ if (formsApiSession["tokenType"] == "jwt") {
2350
+ this.formsApi = new FormsApi_default(formsApiSession, formsApiConfigResponse.data);
2351
+ } else if (this.users) {
2352
+ const jwtResponse = JSON.parse(await this.users.getUserJwt(formsApiSession.audience));
2353
+ if (jwtResponse["data"] && jwtResponse["data"]["token"]) {
2354
+ formsApiSession.convertToJwt(jwtResponse["data"]);
2355
+ this.formsApi = new FormsApi_default(formsApiSession, formsApiConfigResponse.data);
2356
+ }
2357
+ }
2358
+ }
2359
+ }
2360
+ async createObjectsApi(sessionToken) {
2361
+ const objectsApiConfigResponse = JSON.parse(await this.configuration.getObjectsApiConfig());
2362
+ if (objectsApiConfigResponse && objectsApiConfigResponse["data"]) {
2363
+ const objectsApiSession = sessionToken.createCopy();
2364
+ objectsApiSession.baseUrl = objectsApiConfigResponse.data["apiUrl"];
2365
+ objectsApiSession.apiUrl = "";
2366
+ if (objectsApiSession["tokenType"] == "jwt") {
2367
+ this.objectsApi = new ObjectsApi_default(objectsApiSession, objectsApiConfigResponse.data);
2368
+ } else if (this.users) {
2369
+ const jwtResponse = JSON.parse(await this.users.getUserJwt(objectsApiSession.audience));
2370
+ if (jwtResponse["data"] && jwtResponse["data"]["token"]) {
2371
+ objectsApiSession.convertToJwt(jwtResponse["data"]);
2372
+ this.objectsApi = new ObjectsApi_default(objectsApiSession, objectsApiConfigResponse.data);
2373
+ }
2374
+ }
2375
+ }
2376
+ }
2377
+ async createStudioApi(sessionToken) {
2378
+ const studioApiConfigResponse = JSON.parse(await this.configuration.getStudioApiConfig());
2379
+ if (studioApiConfigResponse && studioApiConfigResponse["data"]) {
2380
+ const studioApiSession = sessionToken.createCopy();
2381
+ studioApiSession.baseUrl = studioApiConfigResponse.data["studioApiUrl"];
2382
+ studioApiSession.apiUrl = "";
2383
+ if (studioApiSession["tokenType"] == "jwt") {
2384
+ this.studioApi = new StudioApi_default(studioApiSession, studioApiConfigResponse.data);
2385
+ } else if (this.users) {
2386
+ const jwtResponse = JSON.parse(await this.users.getUserJwt(studioApiSession.audience));
2387
+ if (jwtResponse["data"] && jwtResponse["data"]["token"]) {
2388
+ studioApiSession.convertToJwt(jwtResponse["data"]);
2389
+ this.studioApi = new StudioApi_default(studioApiSession, studioApiConfigResponse.data);
2390
+ }
2391
+ }
2392
+ }
2393
+ }
2394
+ async createNotificationsApi(sessionToken) {
2395
+ const notificationsApiConfigResponse = JSON.parse(await this.configuration.getNotificationsApiConfig());
2396
+ if (notificationsApiConfigResponse && notificationsApiConfigResponse["data"]) {
2397
+ const notificationsApiSession = sessionToken.createCopy();
2398
+ notificationsApiSession.baseUrl = notificationsApiConfigResponse.data["apiUrl"];
2399
+ notificationsApiSession.apiUrl = this.yamlConfig.NotificationsApiUri;
2400
+ if (notificationsApiSession["tokenType"] == "jwt") {
2401
+ this.notificationsApi = new NotificationsApi_default(notificationsApiSession, notificationsApiConfigResponse.data);
2402
+ } else if (this.users) {
2403
+ const jwtResponse = JSON.parse(await this.users.getUserJwt(notificationsApiSession.audience));
2404
+ if (jwtResponse["data"] && jwtResponse["data"]["token"]) {
2405
+ notificationsApiSession.convertToJwt(jwtResponse["data"]);
2406
+ this.notificationsApi = new NotificationsApi_default(notificationsApiSession, notificationsApiConfigResponse.data);
2407
+ }
2408
+ }
2409
+ }
2410
+ }
2411
+ async _convertToJwt(sessionToken) {
2412
+ const jwtResponse = JSON.parse(await this.users.getUserJwt(sessionToken.audience));
2413
+ if (jwtResponse["data"] && jwtResponse["data"]["token"]) {
2414
+ sessionToken.convertToJwt(jwtResponse["data"]);
2415
+ } else {
2416
+ throw new Error("Failed to get JWT: API response missing data.token property");
2417
+ }
2418
+ }
2419
+ endsWith(source, suffix) {
2420
+ return source.indexOf(suffix, source.length - suffix.length) !== -1;
2421
+ }
2422
+ /**
2423
+ * Get the current security token
2424
+ * @returns {string} The access token
2425
+ */
2426
+ getSecurityToken() {
2427
+ return this._httpHelper._sessionToken.accessToken;
2428
+ }
2429
+ /**
2430
+ * Check if the client is authenticated
2431
+ * @returns {boolean} True if authenticated
2432
+ */
2433
+ isAuthenticated() {
2434
+ return this._httpHelper._sessionToken.isAuthenticated;
2435
+ }
2436
+ /**
2437
+ * Get the base URL
2438
+ * @returns {string} The base URL
2439
+ */
2440
+ getBaseUrl() {
2441
+ return this._httpHelper._sessionToken.baseUrl;
2442
+ }
2443
+ };
2444
+ var Authorize2 = class extends common_default.authorize {
2445
+ /**
2446
+ * Authenticate and get a VaultApi client instance
2447
+ * @param {string} clientId - OAuth client ID
2448
+ * @param {string} clientSecret - OAuth client secret
2449
+ * @param {string} userId - User username
2450
+ * @param {string} password - User password
2451
+ * @param {string} audience - OAuth audience
2452
+ * @param {string} baseVaultUrl - VisualVault base URL
2453
+ * @param {string} customerAlias - Customer alias
2454
+ * @param {string} databaseAlias - Database alias
2455
+ * @returns {Promise<VVClient>} Authenticated client instance
2456
+ */
2457
+ async getVaultApi(clientId, clientSecret, userId, password, audience, baseVaultUrl, customerAlias, databaseAlias) {
2458
+ debug5("getVaultApi called for user: %s, customer: %s/%s", userId, customerAlias, databaseAlias);
2459
+ const config = this.jsyaml.load(this.fs.readFileSync(__dirname6 + "/config.yml", "utf8"));
2460
+ if (this.endsWith(baseVaultUrl, "/")) {
2461
+ baseVaultUrl = baseVaultUrl.substring(0, baseVaultUrl.length - 1);
2462
+ }
2463
+ const apiUrl = config.ApiUri.replace("{custalias}", customerAlias).replace("{custdbalias}", databaseAlias);
2464
+ const authenticationUrl = config.AutheticateUri;
2465
+ const sessionToken = await this.acquireSecurityToken(clientId, clientSecret, userId, password, audience, baseVaultUrl, apiUrl, customerAlias, databaseAlias, authenticationUrl);
2466
+ const client = new VVClient(sessionToken);
2467
+ try {
2468
+ await client._convertToJwt(sessionToken);
2469
+ await Promise.all([
2470
+ client.createDocApi(sessionToken),
2471
+ client.createFormsApi(sessionToken),
2472
+ client.createObjectsApi(sessionToken),
2473
+ client.createStudioApi(sessionToken),
2474
+ client.createNotificationsApi(sessionToken)
2475
+ ]);
2476
+ return client;
2477
+ } catch (error) {
2478
+ debug5("Failed to convert to JWT or create specialized APIs: %s", error.message);
2479
+ return client;
2480
+ }
2481
+ }
2482
+ /**
2483
+ * Get a VaultApi client from an existing JWT token
2484
+ * @param {string} jwt - JWT authentication token
2485
+ * @param {string} baseVaultUrl - VisualVault base URL
2486
+ * @param {string} customerAlias - Customer alias
2487
+ * @param {string} databaseAlias - Database alias
2488
+ * @param {Date} expirationDate - Token expiration date
2489
+ * @returns {Promise<VVClient>} Authenticated client instance
2490
+ */
2491
+ async getVaultApiFromJwt(jwt, baseVaultUrl, customerAlias, databaseAlias, expirationDate) {
2492
+ debug5("getVaultApiFromJwt called for customer: %s/%s", customerAlias, databaseAlias);
2493
+ const config = this.jsyaml.load(this.fs.readFileSync(__dirname6 + "/config.yml", "utf8"));
2494
+ if (this.endsWith(baseVaultUrl, "/")) {
2495
+ baseVaultUrl = baseVaultUrl.substring(0, baseVaultUrl.length - 1);
2496
+ }
2497
+ const apiUrl = config.ApiUri.replace("{custalias}", customerAlias).replace("{custdbalias}", databaseAlias);
2498
+ const authenticationUrl = apiUrl + config.ResourceUri.UsersGetJwt;
2499
+ if (expirationDate && expirationDate >= new Date((/* @__PURE__ */ new Date()).getTime() + 30 * 1e3)) {
2500
+ const sessionToken = new common_default.sessionToken();
2501
+ sessionToken.accessToken = jwt;
2502
+ sessionToken.baseUrl = baseVaultUrl;
2503
+ sessionToken.apiUrl = apiUrl;
2504
+ sessionToken.authenticationUrl = authenticationUrl;
2505
+ sessionToken.customerAlias = customerAlias;
2506
+ sessionToken.databaseAlias = databaseAlias;
2507
+ sessionToken.expirationDate = expirationDate;
2508
+ sessionToken.isAuthenticated = true;
2509
+ sessionToken.isJwt = true;
2510
+ const client = new VVClient(sessionToken);
2511
+ return Promise.all([
2512
+ client.createDocApi(sessionToken),
2513
+ client.createFormsApi(sessionToken),
2514
+ client.createObjectsApi(sessionToken),
2515
+ client.createStudioApi(sessionToken)
2516
+ ]).then(() => client).catch((error) => {
2517
+ debug5("Failed to create specialized APIs: %s", error.message);
2518
+ return client;
2519
+ });
2520
+ } else {
2521
+ const token = await this.acquireJwt(jwt, baseVaultUrl, apiUrl, authenticationUrl, customerAlias, databaseAlias);
2522
+ const client = new VVClient(token);
2523
+ try {
2524
+ await Promise.all([
2525
+ client.createDocApi(token),
2526
+ client.createFormsApi(token),
2527
+ client.createObjectsApi(token),
2528
+ client.createStudioApi(token)
2529
+ ]);
2530
+ return client;
2531
+ } catch (error) {
2532
+ debug5("Failed to create specialized APIs: %s", error.message);
2533
+ return client;
2534
+ }
2535
+ }
2536
+ }
2537
+ endsWith(source, suffix) {
2538
+ return source.indexOf(suffix, source.length - suffix.length) !== -1;
2539
+ }
2540
+ };
2541
+ var forms = {
2542
+ returnField: ReturnField,
2543
+ formFieldCollection: FormFieldCollection
2544
+ };
2545
+ var VVRestApi_default = {
2546
+ vvClient: VVClient,
2547
+ authorize: Authorize2,
2548
+ forms
2549
+ };
2550
+
2551
+ // lib/constants.js
2552
+ init_cjs_shims();
2553
+ var RoleType = Object.freeze({
2554
+ None: 0,
2555
+ Owner: 1,
2556
+ Editor: 2,
2557
+ Publisher: 3,
2558
+ Viewer: 4,
2559
+ Member: 5
2560
+ });
2561
+ var MemberType = Object.freeze({
2562
+ User: 0,
2563
+ Group: 1
2564
+ });
2565
+ // Annotate the CommonJS export names for ESM import in node:
2566
+ 0 && (module.exports = {
2567
+ Authorize,
2568
+ MemberType,
2569
+ RoleType,
2570
+ VVClient
2571
+ });
2572
+ //# sourceMappingURL=index.cjs.map