visualvault-api 1.1.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.
- package/README.md +263 -0
- package/lib/VVRestApi/VVRestApiNodeJs/DocApi.js +66 -0
- package/lib/VVRestApi/VVRestApiNodeJs/FormsApi.js +51 -0
- package/lib/VVRestApi/VVRestApiNodeJs/NotificationsApi.js +39 -0
- package/lib/VVRestApi/VVRestApiNodeJs/StudioApi.js +136 -0
- package/lib/VVRestApi/VVRestApiNodeJs/VVRestApi.js +1889 -0
- package/lib/VVRestApi/VVRestApiNodeJs/app.js +128 -0
- package/lib/VVRestApi/VVRestApiNodeJs/common.js +1598 -0
- package/lib/VVRestApi/VVRestApiNodeJs/config.yml +100 -0
- package/lib/VVRestApi/VVRestApiNodeJs/dts/express.d.ts +125 -0
- package/lib/VVRestApi/VVRestApiNodeJs/dts/node.d.ts +1090 -0
- package/lib/VVRestApi/VVRestApiNodeJs/log.js +20 -0
- package/lib/VVRestApi/VVRestApiNodeJs/public/favicon.ico +0 -0
- package/lib/VVRestApi/VVRestApiNodeJs/routes/scheduledscripts.js +203 -0
- package/lib/VVRestApi/VVRestApiNodeJs/routes/scripts.js +215 -0
- package/lib/VVRestApi/VVRestApiNodeJs/routes/testScheduledScripts.js +131 -0
- package/lib/VVRestApi/VVRestApiNodeJs/samples/SampleScheduledScript.js +90 -0
- package/lib/VVRestApi/VVRestApiNodeJs/samples/SendEmailScript.js +51 -0
- package/lib/VVRestApi/VVRestApiNodeJs/samples/fileTest.js +60 -0
- package/lib/VVRestApi/VVRestApiNodeJs/samples/sampleFormValidationScript.js +126 -0
- package/lib/VVRestApi/VVRestApiNodeJs/views/error.ejs +8 -0
- package/lib/VVRestApi/VVRestApiNodeJs/views/index.ejs +8 -0
- package/package.json +98 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
|
|
2
|
+
// Send Email using VisualVault API
|
|
3
|
+
|
|
4
|
+
var logger = require('../log');
|
|
5
|
+
|
|
6
|
+
module.exports.getCredentials = function () {
|
|
7
|
+
var options = {};
|
|
8
|
+
|
|
9
|
+
//Your customer name found in the VisualVault URL
|
|
10
|
+
options.customerAlias = "ACME";
|
|
11
|
+
|
|
12
|
+
//Your customer database name found in the VisualVault URL
|
|
13
|
+
options.databaseAlias = "main5";
|
|
14
|
+
|
|
15
|
+
//User account credentials
|
|
16
|
+
options.userId = "vault.config";
|
|
17
|
+
options.password = "p";
|
|
18
|
+
|
|
19
|
+
//Developer account or registered OAuth application credentials
|
|
20
|
+
options.clientId = "fbb02e0c-2e97-4527-a6d7-9438d8b7b23c";
|
|
21
|
+
options.clientSecret = "bBb+IlcCV5duoyyHvrYYamSrDVMGf+rgJ4Gbhn6R7N4=";
|
|
22
|
+
|
|
23
|
+
return options;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
module.exports.main = function (vvClient, response) {
|
|
27
|
+
var currentDate = new Date();
|
|
28
|
+
var Q = require('q');
|
|
29
|
+
|
|
30
|
+
var emailParams = '';
|
|
31
|
+
var emailData = {};
|
|
32
|
+
emailData.recipients = 'someone@visualvault.com';
|
|
33
|
+
emailData.body = 'test';
|
|
34
|
+
emailData.subject = 'scheduled script test';
|
|
35
|
+
|
|
36
|
+
//Q is a node package used to create promise objects
|
|
37
|
+
//Node.js scripts are asynchronous!
|
|
38
|
+
|
|
39
|
+
Q
|
|
40
|
+
.allSettled(
|
|
41
|
+
[
|
|
42
|
+
vvClient.email.postEmails(emailParams, emailData)
|
|
43
|
+
]
|
|
44
|
+
)
|
|
45
|
+
.then(function (result) {
|
|
46
|
+
logger.info("PostEmails success");
|
|
47
|
+
})
|
|
48
|
+
.fail(function (error) {
|
|
49
|
+
logger.info("Error response from postEmails: " + error.message);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// credentials
|
|
2
|
+
module.exports.getCredentials = function () {
|
|
3
|
+
var options = {};
|
|
4
|
+
options.customerAlias = "customer";
|
|
5
|
+
options.databaseAlias = "alias";
|
|
6
|
+
options.userId = "userId";
|
|
7
|
+
options.password = "password";
|
|
8
|
+
options.clientId = "clientId";
|
|
9
|
+
options.clientSecret = "clientSecret";
|
|
10
|
+
|
|
11
|
+
return options;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
module.exports.main = function (vvClient, response, token) {
|
|
15
|
+
var Q = require('q');
|
|
16
|
+
// message for writing file called
|
|
17
|
+
function err(){console.log("wrote file!");}
|
|
18
|
+
// first promise to get related documents of a form by id
|
|
19
|
+
Q
|
|
20
|
+
.when(
|
|
21
|
+
// get form related documents
|
|
22
|
+
vvClient.forms.getFormRelatedDocs('34260ABE-22C1-E511-A698-E094676F83F7')
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
.then(
|
|
26
|
+
function (result) {
|
|
27
|
+
var response = JSON.parse(result);
|
|
28
|
+
// grabs the first id from response object
|
|
29
|
+
var id = response.data[0].id;
|
|
30
|
+
// 2nd promise taking in the id from the first promise and passing it into the second.
|
|
31
|
+
Q
|
|
32
|
+
.when(
|
|
33
|
+
// request file bytes by id
|
|
34
|
+
vvClient.files.getFileBytesId(id)
|
|
35
|
+
)
|
|
36
|
+
.then(
|
|
37
|
+
function (result) {
|
|
38
|
+
// the result will be the buffer (byte array) of requested file.
|
|
39
|
+
var bytes = result;
|
|
40
|
+
// log bytes to console or proceed with buisness logic.
|
|
41
|
+
// Here I write the bytes to the file system.
|
|
42
|
+
console.log(bytes);
|
|
43
|
+
var fs = require('fs');
|
|
44
|
+
fs.writeFile("c:/nodeTest/textNEW.xlsx",bytes,err);
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
.fail(
|
|
49
|
+
function (error) {
|
|
50
|
+
console.log(error);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
.fail(
|
|
57
|
+
function (error) {
|
|
58
|
+
console.log(error);
|
|
59
|
+
});
|
|
60
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
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 (ffColl, vvClient, response) {
|
|
18
|
+
console.log('In user Main method');
|
|
19
|
+
var meta = { code: 200, error: '' };
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
//example of accessing formfields to be validated
|
|
23
|
+
var outArray = [];
|
|
24
|
+
var ff1 = ffColl.getFormFieldByName("Name");
|
|
25
|
+
if (ff1 != null) {
|
|
26
|
+
console.log('Field 1 name: ' + ff1.name);
|
|
27
|
+
console.log('Field 1 name: ' + ff1.value);
|
|
28
|
+
outArray.push(ff1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
ff1 = ffColl.getFormFieldByName("Dept");
|
|
32
|
+
if (ff1 != null) {
|
|
33
|
+
console.log('Field 2 name: ' + ff1.name);
|
|
34
|
+
console.log('Field 2 name: ' + ff1.value);
|
|
35
|
+
outArray.push(ff1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//setup parameters for making requests to VisualVault
|
|
39
|
+
var formParams = {};
|
|
40
|
+
formParams.fields = "id, name, description, revision";
|
|
41
|
+
|
|
42
|
+
var siteParams = {};
|
|
43
|
+
siteParams.fields = "id, name, sitetype";
|
|
44
|
+
|
|
45
|
+
var foldersData = {};
|
|
46
|
+
foldersData.q = '';
|
|
47
|
+
foldersData.fields = 'id,name';
|
|
48
|
+
foldersData.folderpath = '/General';
|
|
49
|
+
foldersData.metaonly = 'true';
|
|
50
|
+
|
|
51
|
+
var Q = require('q');
|
|
52
|
+
|
|
53
|
+
//.sites.getSites(siteParams),
|
|
54
|
+
|
|
55
|
+
//make request to VisualVault
|
|
56
|
+
Q
|
|
57
|
+
.allSettled(
|
|
58
|
+
[
|
|
59
|
+
vvClient.forms.getFormTemplates(formParams),
|
|
60
|
+
vvClient.sites.getSites(siteParams),
|
|
61
|
+
vvClient.library.getFolders(foldersData)
|
|
62
|
+
|
|
63
|
+
]
|
|
64
|
+
)
|
|
65
|
+
.then(
|
|
66
|
+
function (promises) {
|
|
67
|
+
console.log("Results count: " + promises.length);
|
|
68
|
+
|
|
69
|
+
//example of accessing returned data from request to VisualVault
|
|
70
|
+
var promiseFormTemplates = promises[0];
|
|
71
|
+
if (promiseFormTemplates.state == 'fulfilled'){
|
|
72
|
+
var responseData = JSON.parse(promiseFormTemplates.value);
|
|
73
|
+
|
|
74
|
+
var formTemplates = responseData.data;
|
|
75
|
+
|
|
76
|
+
console.log("Listing Form Templates");
|
|
77
|
+
for (var x=0; x < formTemplates.length; x++){
|
|
78
|
+
var formTemplate = formTemplates[x];
|
|
79
|
+
console.log('FormTemplate Id: ' + formTemplate.id);
|
|
80
|
+
console.log('FormTemplate Name: ' + formTemplate.name);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
var outputCollection = [];
|
|
85
|
+
|
|
86
|
+
var fld = new vvClient.forms.returnField(
|
|
87
|
+
outArray[0].id,
|
|
88
|
+
outArray[0].name,
|
|
89
|
+
'New replacement value',
|
|
90
|
+
false,
|
|
91
|
+
'');
|
|
92
|
+
outputCollection.push(fld);
|
|
93
|
+
|
|
94
|
+
var fld1 = new vvClient.forms.returnField(
|
|
95
|
+
outArray[1].id,
|
|
96
|
+
outArray[1].name,
|
|
97
|
+
'',
|
|
98
|
+
true,
|
|
99
|
+
'This field is required');
|
|
100
|
+
outputCollection.push(fld1);
|
|
101
|
+
|
|
102
|
+
console.log("Returning: " + outputCollection);
|
|
103
|
+
|
|
104
|
+
response.json(200, outputCollection);
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
.fail(
|
|
108
|
+
function (error) {
|
|
109
|
+
console.log(error);
|
|
110
|
+
|
|
111
|
+
meta.code = 400;
|
|
112
|
+
meta.error = "An error occurred while validating form";
|
|
113
|
+
response.json(200, meta);
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
} catch (ex) {
|
|
121
|
+
meta.code = 400;
|
|
122
|
+
meta.error = "An exception occurred while validating form";
|
|
123
|
+
response.json(200, meta);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "visualvault-api",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Simplifies the use of VisualVault REST APIs from a Node.Js app",
|
|
5
|
+
"main": "lib/VVRestApi/VVRestApiNodeJs/VVRestApi.js",
|
|
6
|
+
"_comments": [
|
|
7
|
+
{
|
|
8
|
+
"checkout-node-sdk-v5": "file:checkout-node-sdk-v5-5.4.0.tgz",
|
|
9
|
+
"comment": "This dependency has been removed from the dependencies. It may be required to support a specific customer feature."
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@aws-sdk/client-comprehend": "^3.418.0",
|
|
14
|
+
"@esri/arcgis-rest-request": "^4.5.0",
|
|
15
|
+
"amazon-textract-response-parser": "^0.3.1",
|
|
16
|
+
"aws-sdk": "^2.1472.0",
|
|
17
|
+
"axios": "^1.9.0",
|
|
18
|
+
"body-parser": "^1.18.3",
|
|
19
|
+
"cors": "^2.8.5",
|
|
20
|
+
"cross-fetch": "^3.1.4",
|
|
21
|
+
"csv": "^4.0.0",
|
|
22
|
+
"currency.js": "^2.0.4",
|
|
23
|
+
"dayjs": "^1.11.7",
|
|
24
|
+
"digest-fetch": "^1.1.6",
|
|
25
|
+
"ejs": "^2.6.1",
|
|
26
|
+
"eml-parser": "^2.0.3",
|
|
27
|
+
"exceljs": "^4.4.0",
|
|
28
|
+
"express": "^4.16.3",
|
|
29
|
+
"express-error-handler": "^1.1.0",
|
|
30
|
+
"fetch": "^1.1.0",
|
|
31
|
+
"file-type-es5": "^6.2.1",
|
|
32
|
+
"form-data": "^4.0.2",
|
|
33
|
+
"FormData": "^0.10.1",
|
|
34
|
+
"https": "^1.0.0",
|
|
35
|
+
"isomorphic-form-data": "^2.0.0",
|
|
36
|
+
"js-yaml": "^2.1.3",
|
|
37
|
+
"jsforce": "^1.9.1",
|
|
38
|
+
"jsonwebtoken": "^9.0.2",
|
|
39
|
+
"libreoffice-convert": "^1.5.1",
|
|
40
|
+
"moment": "^2.22.2",
|
|
41
|
+
"moment-business-days": "^1.2.0",
|
|
42
|
+
"moment-timezone": "^0.5.23",
|
|
43
|
+
"mssql": "^6.0.1",
|
|
44
|
+
"multer": "^1.3.1",
|
|
45
|
+
"node-fetch": "^2.6.1",
|
|
46
|
+
"node-uuid": "^1.4.1",
|
|
47
|
+
"p-limit": "^3.1.0",
|
|
48
|
+
"parse-full-name": "^1.2.6",
|
|
49
|
+
"pdf-lib": "^1.17.1",
|
|
50
|
+
"pdf-merger-js": "^4.3.1",
|
|
51
|
+
"properties-reader": "^2.3.0",
|
|
52
|
+
"puppeteer": "^13.0.0",
|
|
53
|
+
"q": "^0.9.7",
|
|
54
|
+
"read-chunk": "^3.2.0",
|
|
55
|
+
"request": "^2.27.0",
|
|
56
|
+
"serve-favicon": "^2.5.0",
|
|
57
|
+
"ssh2-sftp-client": "^8.1.0",
|
|
58
|
+
"ssl-root-cas": "^1.3.1",
|
|
59
|
+
"sweetalert2": "^11.17.2",
|
|
60
|
+
"talisman": "^1.1.3",
|
|
61
|
+
"text-encoder": "^0.0.4",
|
|
62
|
+
"winston": "^2.4.2",
|
|
63
|
+
"winston-cloudwatch": "^1.13.1",
|
|
64
|
+
"winston-cloudwatch-transport": "^1.0.8"
|
|
65
|
+
},
|
|
66
|
+
"scripts": {
|
|
67
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
68
|
+
"prepublishOnly": "echo \"Ready to publish VVRestApi library\""
|
|
69
|
+
},
|
|
70
|
+
"keywords": [
|
|
71
|
+
"visualvault",
|
|
72
|
+
"api",
|
|
73
|
+
"rest",
|
|
74
|
+
"client",
|
|
75
|
+
"document",
|
|
76
|
+
"management",
|
|
77
|
+
"forms",
|
|
78
|
+
"nodejs"
|
|
79
|
+
],
|
|
80
|
+
"engines": {
|
|
81
|
+
"node": ">=20.0.0"
|
|
82
|
+
},
|
|
83
|
+
"files": [
|
|
84
|
+
"lib/VVRestApi/**/*",
|
|
85
|
+
"README.md",
|
|
86
|
+
"package.json"
|
|
87
|
+
],
|
|
88
|
+
"repository": {
|
|
89
|
+
"type": "git",
|
|
90
|
+
"url": "git+https://github.com/VisualVault/nodeJs-rest-client-library.git"
|
|
91
|
+
},
|
|
92
|
+
"author": "VisualVault",
|
|
93
|
+
"license": "ISC",
|
|
94
|
+
"bugs": {
|
|
95
|
+
"url": "https://github.com/VisualVault/nodeJs-rest-client-library/issues"
|
|
96
|
+
},
|
|
97
|
+
"homepage": "https://github.com/VisualVault/nodeJs-rest-client-library#readme"
|
|
98
|
+
}
|