visualvault-api 1.1.0 → 2.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -138
  3. package/dist/VVRestApi.cjs +2574 -0
  4. package/dist/VVRestApi.cjs.map +1 -0
  5. package/dist/VVRestApi.d.cts +375 -0
  6. package/dist/VVRestApi.d.ts +375 -0
  7. package/dist/VVRestApi.js +2544 -0
  8. package/dist/VVRestApi.js.map +1 -0
  9. package/{lib/VVRestApi/VVRestApiNodeJs → dist}/config.yml +106 -100
  10. package/dist/constants.cjs +45 -0
  11. package/dist/constants.cjs.map +1 -0
  12. package/dist/constants.d.cts +48 -0
  13. package/dist/constants.d.ts +48 -0
  14. package/dist/constants.js +20 -0
  15. package/dist/constants.js.map +1 -0
  16. package/dist/index.cjs +2594 -0
  17. package/dist/index.cjs.map +1 -0
  18. package/dist/index.d.cts +2 -0
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.js +2563 -0
  21. package/dist/index.js.map +1 -0
  22. package/package.json +47 -71
  23. package/lib/VVRestApi/VVRestApiNodeJs/DocApi.js +0 -66
  24. package/lib/VVRestApi/VVRestApiNodeJs/FormsApi.js +0 -51
  25. package/lib/VVRestApi/VVRestApiNodeJs/NotificationsApi.js +0 -39
  26. package/lib/VVRestApi/VVRestApiNodeJs/StudioApi.js +0 -136
  27. package/lib/VVRestApi/VVRestApiNodeJs/VVRestApi.js +0 -1889
  28. package/lib/VVRestApi/VVRestApiNodeJs/app.js +0 -128
  29. package/lib/VVRestApi/VVRestApiNodeJs/common.js +0 -1598
  30. package/lib/VVRestApi/VVRestApiNodeJs/dts/express.d.ts +0 -125
  31. package/lib/VVRestApi/VVRestApiNodeJs/dts/node.d.ts +0 -1090
  32. package/lib/VVRestApi/VVRestApiNodeJs/log.js +0 -20
  33. package/lib/VVRestApi/VVRestApiNodeJs/public/favicon.ico +0 -0
  34. package/lib/VVRestApi/VVRestApiNodeJs/routes/scheduledscripts.js +0 -203
  35. package/lib/VVRestApi/VVRestApiNodeJs/routes/scripts.js +0 -215
  36. package/lib/VVRestApi/VVRestApiNodeJs/routes/testScheduledScripts.js +0 -131
  37. package/lib/VVRestApi/VVRestApiNodeJs/samples/SampleScheduledScript.js +0 -90
  38. package/lib/VVRestApi/VVRestApiNodeJs/samples/SendEmailScript.js +0 -51
  39. package/lib/VVRestApi/VVRestApiNodeJs/samples/fileTest.js +0 -60
  40. package/lib/VVRestApi/VVRestApiNodeJs/samples/sampleFormValidationScript.js +0 -126
  41. package/lib/VVRestApi/VVRestApiNodeJs/views/error.ejs +0 -8
  42. package/lib/VVRestApi/VVRestApiNodeJs/views/index.ejs +0 -8
@@ -1,20 +0,0 @@
1
- var winston = require('winston');
2
-
3
- var os = require("os");
4
- var infoLogStreamName = 'nodejs-' + os.hostname().toLowerCase() + '-info';
5
- var errorLogStreamName = 'nodejs-' + os.hostname().toLowerCase() + '-error';
6
-
7
- const tsFormat = () => (new Date()).toUTCString();
8
-
9
- var logger = new (winston.Logger)({
10
- transports: [
11
- new (winston.transports.Console)({ timestamp: tsFormat }),
12
- new (winston.transports.File)({ timestamp: tsFormat, filename: infoLogStreamName + '.log' })
13
- ]
14
- });
15
-
16
-
17
- module.exports = logger;
18
-
19
-
20
-
@@ -1,203 +0,0 @@
1
- var clientLibrary = require('../VVRestApi');
2
- var logger = require('../log');
3
-
4
- var VVScriptFilePath = require('path').dirname(require.main.filename) + '/files/';
5
- var VVScriptFileRequirePath = require('path').dirname(require.main.filename) + '/files/';
6
-
7
- exports.processRequest = function (req, res) {
8
- logger.info('Call from VisualVault to scheduledscripts');
9
-
10
- var fs = require('fs');
11
- var Q = require('q');
12
- var meta = { code: 200, error: '' };
13
- var attemptCount = 0;
14
-
15
- var script = null;
16
- var scriptName = null;
17
- var baseUrl = null;
18
- var token = null;
19
-
20
- if (req.body instanceof Array) {
21
- for (var x = 0; x < req.body.length; x++) {
22
- var key = req.body[x].Key;
23
- var value = req.body[x].Value;
24
-
25
- if (key == "script") {
26
- //retrieve script from form encoded post
27
- script = value;
28
- } else if (key == "baseUrl") {
29
- //retrieve baseUrl from form encoded post
30
- baseUrl = value;
31
- } else if (key == "token") {
32
- //retrieve token from form encoded post
33
- token = value;
34
- }
35
- }
36
- } else if (typeof (req.body.script) != 'undefined' && typeof (req.body.baseUrl) != 'undefined') {
37
- //retrieve script from form encoded post
38
- script = req.body.script;
39
-
40
- //retrieve baseUrl from form encoded post
41
- baseUrl = req.body.baseUrl;
42
-
43
- //retrieve token from form encoded post
44
- token = req.body.token;
45
- } else if (typeof (req.query.name) != 'undefined') {
46
- //retrieve script name from query string
47
- scriptName = req.query.name;
48
-
49
- if (typeof (req.query.baseUrl) != 'undefined') {
50
- //retrieve baseUrl from query string
51
- baseUrl = req.query.baseUrl;
52
- }
53
-
54
- //retrieve token from form encoded post
55
- //token = req.query.token;
56
- } else {
57
- console.log('Error, body of request did not contain key/value pairs for script and baseurl');
58
- logger.error("Error, body of request did not contain key/value pairs for baseurl. http 400 response returned.");
59
- meta.code = 400;
60
- meta.error = "Error, body of request did not contain key/value pairs for script and baseurl";
61
- res.json(200, meta);
62
- }
63
-
64
- if (script === null && scriptName === null) {
65
- console.log('Error, body of request did not contain key/value pairs for script');
66
- logger.error("Error, body of request did not contain key/value pairs for script. http 400 response returned.");
67
-
68
- meta.code = 400;
69
- meta.error = "Error, body of request did not contain key/value pairs for script";
70
- res.json(200, meta);
71
- }
72
-
73
- if (baseUrl === null && scriptName === null) {
74
- console.log('Error, body of request did not contain key/value pairs for baseurl');
75
- logger.error("Error, body of request did not contain key/value pairs for baseurl. http 400 response returned.");
76
- meta.code = 400;
77
- meta.error = "Error, body of request did not contain key/value pairs for baseurl";
78
- res.json(200, meta);
79
- }
80
-
81
-
82
- if (typeof req.query.id === 'string') {
83
- var fileId = req.query.id;
84
-
85
- //todo: need config parameter for this path location
86
- console.log('attempting to write script to ' + VVScriptFilePath + fileId + ".js");
87
-
88
- //todo: need config parameter for this path location
89
- fs.writeFile(VVScriptFilePath + fileId + ".js", script, function (err) {
90
- if (err) {
91
-
92
- logger.info("Error, unable to write script file: " + err);
93
-
94
- console.log('Error, unable to write script file: ' + err);
95
-
96
- meta.code = 500;
97
- meta.error = "File System error, unable to write script file.";
98
- logger.error("File System error, unable to write script file. http 500 response returned.");
99
- res.json(200, meta);
100
- } else {
101
- console.log("loading scheduledScript script file");
102
-
103
- try {
104
- for (var p in require.cache) {
105
- if (p.indexOf(fileId) > -1) {
106
- logger.info("deleting cached scheduledScript script file: " + p);
107
- delete require.cache[p];
108
- }
109
- }
110
- } catch (ex) {
111
- logger.error("error loading scheduledScript script file " + ex);
112
- }
113
-
114
- logger.info("Loading scheduledScript script file");
115
-
116
- //load the script file we just saved to the filesystem
117
- var scheduledScript = require(VVScriptFileRequirePath + fileId);
118
-
119
- // YOU CAN SWAP OUT YOUR SCRIPT HERE IF YOU WANT TO TEST
120
- //var scheduledScript = require("../test.js");
121
-
122
- //get the customer name and other credentials
123
- var params = scheduledScript.getCredentials();
124
-
125
- //add baseUrl to parameters for vvClient
126
- if (!params.baseUrl) {
127
- params.baseUrl = baseUrl;
128
- }
129
-
130
- logger.info("calling vvAuthorize.getVaultApi");
131
-
132
- var vvAuthorize = new clientLibrary.authorize();
133
-
134
- //making call to vvClient to get access token
135
- Q
136
- .when(
137
- vvAuthorize.getVaultApi(params.clientId, params.clientSecret, params.userId, params.password, params.audience, params.baseUrl, params.customerAlias, params.databaseAlias)
138
- )
139
- .then(function (result) {
140
- logger.info("Calling the scheduledScript's Main method");
141
-
142
- scheduledScript.main(result, res, token);
143
- })
144
- .fail(function (error) {
145
- logger.error("Error response from vvAuthorize.getVaultApi. http 401 response returned. " + error.message);
146
-
147
- meta.code = 401;
148
- meta.error = "Unable to acquire access token";
149
- res.json(200, meta);
150
- });
151
- }
152
- });
153
- } else if (typeof scriptName === 'string') {
154
- try {
155
-
156
- logger.info("Loading scheduled script file requested by query string: " + scriptName + ".js");
157
-
158
- //load the requested script file
159
- var scheduledScript = require("../../../../scripts/server-scripts/scheduled/" + scriptName + ".js");
160
-
161
- //get the customer name and other credentials
162
- var params = scheduledScript.getCredentials();
163
-
164
- //add baseUrl to parameters for vvClient
165
- if (!params.baseUrl) {
166
- params.baseUrl = baseUrl;
167
- }
168
-
169
- var vvAuthorize = new clientLibrary.authorize();
170
-
171
- //making call to vvClient to get access token
172
- Q
173
- .when(
174
- vvAuthorize.getVaultApi(params.clientId, params.clientSecret, params.userId, params.password, params.audience, params.baseUrl, params.customerAlias, params.databaseAlias)
175
- )
176
- .then(function (result) {
177
- logger.info("Calling the scheduledScript's Main method");
178
-
179
- scheduledScript.main(result, res, token);
180
- })
181
- .fail(function (error) {
182
- logger.error("Error response from vvAuthorize.getVaultApi. http 401 response returned. " + error.message);
183
-
184
- meta.code = 401;
185
- meta.error = "Unable to acquire access token";
186
- res.json(200, meta);
187
- });
188
- } catch (ex) {
189
- logger.error("http 500: Error Loading scheduled script file requested by query string: " + scriptName + ".js. http 500 response returned. " + ex);
190
-
191
- meta.code = 500;
192
- meta.error = "Unable to Load scheduled script file requested by query string: " + scriptName + ".js";
193
- res.json(500, meta);
194
- }
195
-
196
- } else {
197
- meta.code = 400;
198
- meta.error = "Script file Id not specified";
199
- res.json(200, meta);
200
- }
201
- };
202
-
203
-
@@ -1,215 +0,0 @@
1
- var clientLibrary = require('../VVRestApi');
2
- var logger = require('../log');
3
-
4
- var VVScriptFilePath = require('path').dirname(require.main.filename) + '/files/';
5
- var VVScriptFileRequirePath = require('path').dirname(require.main.filename) + '/files/';
6
-
7
- exports.testsite = function (req, res) {
8
- res.end('Hello. VisualVault Node.Js execution environment. Node Version ' + process.version);
9
- };
10
-
11
-
12
-
13
- exports.scripts = function (req, res) {
14
- console.log('Call from VisualVault to scripts');
15
- var fs = require('fs');
16
- var Q = require('q');
17
- var meta = { code: 200, error: '' };
18
-
19
- var script = null;
20
- var baseUrl = null;
21
- var ffColl = null;
22
-
23
- if (req.body instanceof Array) {
24
- for (var x = 0; x < req.body.length; x++) {
25
- var key = req.body[x].Key;
26
- var value = req.body[x].Value;
27
-
28
- if (key == "script") {
29
- //retrieve script from form encoded post
30
- script = value;
31
- } else if (key == "baseUrl") {
32
- //retrieve baseUrl from form encoded post
33
- baseUrl = value;
34
- } else if (key == "fields") {
35
- //create formfield collection from form encoded post
36
- if (value && value instanceof Array) {
37
- ffColl = value;
38
- } else if (value) {
39
- ffColl = JSON.parse(value);
40
- }
41
- }
42
- }
43
- } else if (typeof (req.body.script) != 'undefined' && typeof (req.body.baseUrl) != 'undefined') {
44
- //retrieve script from form encoded post
45
- script = req.body.script;
46
-
47
- //retrieve baseUrl from form encoded post
48
- baseUrl = req.body.baseUrl;
49
-
50
- if (typeof (req.body.fields) != 'undefined') {
51
- //create formfield collection from form encoded post
52
- ffColl = JSON.parse(req.body.fields);
53
- }
54
- } else {
55
- logger.info('Error, body of request did not contain key/value pairs for script and baseurl');
56
- meta.code = 400;
57
- meta.error = "Error, body of request did not contain key/value pairs for script and baseurl";
58
- res.json(200, meta);
59
- }
60
-
61
-
62
- if (script === null) {
63
- logger.info('Error, body of request did not contain key/value pairs for script');
64
- meta.code = 400;
65
- meta.error = "Error, body of request did not contain key/value pairs for script";
66
- res.json(200, meta);
67
- }
68
-
69
- if (baseUrl === null) {
70
- logger.info('Error, body of request did not contain key/value pairs for baseurl');
71
- meta.code = 400;
72
- meta.error = "Error, body of request did not contain key/value pairs for baseurl";
73
- res.json(200, meta);
74
- }
75
-
76
- //instantiate the formfieldcollection
77
- var ffCollection = new clientLibrary.forms.formFieldCollection(ffColl);
78
-
79
- if (typeof req.query.id === 'string') {
80
- //set filename to id of script
81
- var fileId = req.query.id;
82
- var scriptToExecute = "";
83
-
84
- if (fileId == "localScript") {
85
-
86
- var scriptFilePath = '../../../../outsideScripts/' + script + ".js";
87
-
88
- try {
89
- require.resolve(scriptFilePath);
90
- }
91
- catch (e) {
92
- scriptFilePath = VVScriptFilePath + script + ".js";
93
- }
94
-
95
- scriptToExecute = require(scriptFilePath);
96
-
97
- //get the customer name and other credentials
98
- var params = scriptToExecute.getCredentials();
99
-
100
- //add baseUrl to parameters for vvClient
101
- params.baseUrl = baseUrl;
102
-
103
- //instantiate the authentication object
104
- var vvAuthorize = new clientLibrary.authorize();
105
-
106
- //call VisualVault to get access token
107
- Q
108
- .when(
109
- vvAuthorize.getVaultApi(params.clientId, params.clientSecret, params.userId, params.password, params.audience, params.baseUrl, params.customerAlias, params.databaseAlias)
110
- )
111
- .then(function (result) {
112
- logger.info("Calling the scriptToExecute's Main method");
113
-
114
- scriptToExecute.main(ffCollection, result, res);
115
- })
116
- .fail(function (error) {
117
- if (error.message && (error.message.indexOf('Authorization') >= 0 || error.message.indexOf('token') >= 0)) {
118
- //error while acquiring access token
119
- meta.code = 401;
120
- meta.error = "Unable to acquire access token";
121
- logger.info("Error response from acquire access token");
122
- } else {
123
- //error while executing script
124
- meta.code = 500;
125
- meta.error = error;
126
- logger.info(error);
127
- }
128
-
129
- res.json(200, meta);
130
- });
131
-
132
- } else {
133
-
134
- logger.info('attempting to write script to ' + VVScriptFilePath + fileId + ".js");
135
-
136
- //write script out to filesystem
137
- fs.writeFile(VVScriptFilePath + fileId + ".js", script, function (err) {
138
- if (err) {
139
- logger.info('Error, unable to write script file: ' + err);
140
-
141
- meta.code = 500;
142
- meta.error = "File System error, unable to write script file.";
143
- res.json(200, meta);
144
-
145
- logger.error(params.baseUrl + " Unable to write script file. http 500 response returned. " + error.message);
146
- } else {
147
- logger.info("loading scriptToExecute script file");
148
-
149
- try {
150
- for (var p in require.cache) {
151
- if (p.indexOf(fileId) > -1) {
152
- console.log("deleting cached scriptToExecute script file: " + p);
153
- delete require.cache[p];
154
- }
155
- }
156
- } catch (ex) {
157
- console.log(ex);
158
- }
159
-
160
- // YOU CAN SWAP OUT YOUR SCRIPT HERE IF YOU WANT TO TEST
161
- scriptToExecute = require(VVScriptFileRequirePath + fileId);
162
- //scriptToExecute = require(VVScriptFileRequirePath);
163
-
164
- //get the customer name and other credentials
165
- var params = scriptToExecute.getCredentials();
166
-
167
- //add baseUrl to parameters for vvClient unless script explicity requested an override
168
- if (!params.baseUrlOverride) {
169
- params.baseUrl = baseUrl;
170
- }
171
-
172
- //instantiate the authentication object
173
- var vvAuthorize = new clientLibrary.authorize();
174
-
175
- //call VisualVault to get access token
176
- Q
177
- .when(
178
- vvAuthorize.getVaultApi(params.clientId, params.clientSecret, params.userId, params.password, params.audience, params.baseUrl, params.customerAlias, params.databaseAlias)
179
- )
180
- .then(function (result) {
181
- logger.info(params.baseUrl + " calling script " + scriptToExecute + " Main method");
182
-
183
- //result is the clientLibrary object returned after authentication
184
- scriptToExecute.main(ffCollection, result, res);
185
- })
186
- .fail(function (error) {
187
- if (error.message && (error.message.indexOf('Authorization') >= 0 || error.message.indexOf('token') >= 0)) {
188
- //error while acquiring access token
189
- meta.code = 401;
190
- meta.error = "Unable to acquire access token";
191
- logger.error(params.baseUrl + " Error acquiring access token. http 401 response returned. " + error.message);
192
- } else {
193
- //error while executing script
194
- meta.code = 500;
195
- meta.error = error;
196
- logger.error(params.baseUrl + " Error acquiring access token. http 500 response returned. " + error.message);
197
- }
198
-
199
- res.json(200, meta);
200
- });
201
- }
202
- });
203
- }
204
- }
205
- else {
206
- meta.code = 400;
207
- meta.error = "Script file Id not specified";
208
- logger.error(params.baseUrl + " Script file Id not specified. http 400 response returned. " + error.message);
209
- res.json(200, meta);
210
- }
211
- };
212
-
213
-
214
-
215
-
@@ -1,131 +0,0 @@
1
- var clientLibrary = require('../VVRestApi');
2
- var logger = require('../log');
3
-
4
- var VVScriptFilePath = require('path').dirname(require.main.filename) + '/files/';
5
- var VVScriptFileRequirePath = require('path').dirname(require.main.filename) + '/files/';
6
-
7
-
8
- exports.processRequest = function (req, res) {
9
- logger.info('Request received for test script');
10
-
11
- var fs = require('fs');
12
- var Q = require('q');
13
- var meta = { code: 200, error: '' };
14
- var attemptCount = 0;
15
-
16
- var script = null;
17
- var scriptName = null;
18
- var baseUrl = null;
19
- var token = null;
20
-
21
- if (req.body instanceof Array) {
22
- for (var x = 0; x < req.body.length; x++) {
23
- var key = req.body[x].Key;
24
- var value = req.body[x].Value;
25
-
26
- if (key == "script") {
27
- //retrieve script from form encoded post
28
- script = value;
29
- } else if (key == "baseUrl") {
30
- //retrieve baseUrl from form encoded post
31
- baseUrl = value;
32
- } else if (key == "token") {
33
- //retrieve token from form encoded post
34
- token = value;
35
- }
36
- }
37
- } else if (typeof (req.body.script) != 'undefined' && typeof (req.body.baseUrl) != 'undefined') {
38
- //retrieve script from form encoded post
39
- script = req.body.script;
40
-
41
- //retrieve baseUrl from form encoded post
42
- baseUrl = req.body.baseUrl;
43
-
44
- //retrieve token from form encoded post
45
- token = req.body.token;
46
- } else if (typeof (req.params.name) != 'undefined') {
47
- //retrieve script name from query string
48
- scriptName = req.params.name;
49
-
50
- if (typeof (req.query.baseUrl) != 'undefined') {
51
- //retrieve baseUrl from query string
52
- baseUrl = req.query.baseUrl;
53
- }
54
-
55
- } else {
56
- console.log('Error, body of request did not contain key/value pairs for script and baseurl');
57
- logger.error("Error, body of request did not contain key/value pairs for baseurl. http 400 response returned.");
58
- meta.code = 400;
59
- meta.error = "Error, body of request did not contain key/value pairs for script and baseurl";
60
- res.json(200, meta);
61
- }
62
-
63
- if (script === null && scriptName === null) {
64
- console.log('Error, body of request did not contain key/value pairs for script');
65
- logger.error("Error, body of request did not contain key/value pairs for script. http 400 response returned.");
66
-
67
- meta.code = 400;
68
- meta.error = "Error, body of request did not contain key/value pairs for script";
69
- res.json(200, meta);
70
- }
71
-
72
- if (baseUrl === null && scriptName === null) {
73
- console.log('Error, body of request did not contain key/value pairs for baseurl');
74
- logger.error("Error, body of request did not contain key/value pairs for baseurl. http 400 response returned.");
75
- meta.code = 400;
76
- meta.error = "Error, body of request did not contain key/value pairs for baseurl";
77
- res.json(200, meta);
78
- }
79
-
80
-
81
- if (typeof scriptName === 'string') {
82
- try {
83
-
84
- logger.info("Loading test script file: " + scriptName + ".js");
85
-
86
- //load the requested script file
87
- var testScript = require(process.cwd() + "/scripts/test-scripts/scheduled/" + scriptName + ".js");
88
-
89
- //get the customer name and other credentials
90
- var params = testScript.getCredentials();
91
-
92
- //add baseUrl to parameters for vvClient
93
- if (!params.baseUrl) {
94
- params.baseUrl = baseUrl;
95
- }
96
-
97
- var vvAuthorize = new clientLibrary.authorize();
98
-
99
- //making call to vvClient to get access token
100
- Q
101
- .when(
102
- vvAuthorize.getVaultApi(params.clientId, params.clientSecret, params.userId, params.password, params.audience, params.baseUrl, params.customerAlias, params.databaseAlias)
103
- )
104
- .then(function (result) {
105
- logger.info("Calling the test script's Main method");
106
-
107
- testScript.main(result, res, token);
108
- })
109
- .fail(function (error) {
110
- logger.error("Error response from vvAuthorize.getVaultApi. http 401 response returned. " + error.message);
111
-
112
- meta.code = 401;
113
- meta.error = "Unable to acquire access token";
114
- res.json(200, meta);
115
- });
116
- } catch (ex) {
117
- logger.error("http 500: Error Loading scheduled script file: " + scriptName + ".js. http 500 response returned. " + ex);
118
-
119
- meta.code = 500;
120
- meta.error = "Unable to Load script file: " + scriptName + ".js";
121
- res.json(500, meta);
122
- }
123
-
124
- } else {
125
- meta.code = 400;
126
- meta.error = "Script name not specified";
127
- res.json(200, meta);
128
- }
129
- };
130
-
131
-
@@ -1,90 +0,0 @@
1
- 
2
-
3
-
4
- module.exports.getCredentials = function () {
5
- var options = {};
6
- options.customerAlias = "sampleCustomer";
7
- options.databaseAlias = "main";
8
- options.userId = "sample.user";
9
- options.password = "mypassword";
10
- options.clientId = "ce9e042d-87f5-42d5-97af-435aff70152b";
11
- options.clientSecret = "/PbgaChHbPoboS/1s07E6pfHCNFSdqPsD3B/yiKHfHw=";
12
-
13
-
14
- return options;
15
- };
16
-
17
- module.exports.main = function (vvClient, response) {
18
- console.log('In user Main method');
19
- var meta = { code: 200, error: '' };
20
-
21
- try {
22
- //setup parameters for making requests to VisualVault
23
- var formParams = {};
24
- formParams.fields = "id, name, description, revision";
25
-
26
- var siteParams = {};
27
- siteParams.fields = "id, name, sitetype";
28
-
29
- var foldersData = {};
30
- foldersData.q = '';
31
- foldersData.fields = 'id,name';
32
- foldersData.folderpath = '/General';
33
- foldersData.metaonly = 'true';
34
-
35
- var Q = require('q');
36
-
37
- //make request to VisualVault
38
- Q
39
- .allSettled(
40
- [
41
- vvClient.forms.getFormTemplates(formParams),
42
- vvClient.sites.getSites(siteParams),
43
- vvClient.library.getFolders(foldersData)
44
-
45
- ]
46
- )
47
- .then(
48
- function (promises) {
49
- console.log("Results count: " + promises.length);
50
-
51
- //example of accessing returned data from request to VisualVault
52
- var promiseFormTemplates = promises[0];
53
- if (promiseFormTemplates.state == 'fulfilled') {
54
- var responseData = JSON.parse(promiseFormTemplates.value);
55
-
56
- var formTemplates = responseData.data;
57
-
58
- console.log("Listing Form Templates");
59
- for (var x = 0; x < formTemplates.length; x++) {
60
- var formTemplate = formTemplates[x];
61
- console.log('FormTemplate Id: ' + formTemplate.id);
62
- console.log('FormTemplate Name: ' + formTemplate.name);
63
- }
64
- }
65
-
66
- meta.code = 200;
67
- meta.error = "";
68
- response.json(200, meta);
69
- }
70
- )
71
- .fail(
72
- function (error) {
73
- console.log(error);
74
-
75
- meta.code = 400;
76
- meta.error = "An error occurred while accessing VisualVault";
77
- response.json(200, meta);
78
- }
79
- );
80
-
81
-
82
-
83
-
84
- } catch (ex) {
85
- meta.code = 400;
86
- meta.error = "An exception occurred while performing this scheduled script";
87
- response.json(200, meta);
88
- }
89
-
90
- };