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
package/README.md
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
# visualvault-api
|
|
2
|
+
|
|
3
|
+
A Node.js client library that provides convenient access to the VisualVault REST API for server-side applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install visualvault-api
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
- Node.js 20.0.0 or higher
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
### Basic Authentication and Setup
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
const vvRestApi = require('visualvault-api');
|
|
21
|
+
|
|
22
|
+
// Initialize authentication
|
|
23
|
+
const auth = new vvRestApi.authorize();
|
|
24
|
+
|
|
25
|
+
// Get authenticated client
|
|
26
|
+
auth.getVaultApi(
|
|
27
|
+
'your-client-id',
|
|
28
|
+
'your-client-secret',
|
|
29
|
+
'username',
|
|
30
|
+
'password',
|
|
31
|
+
'your-audience',
|
|
32
|
+
'https://your-vault-url.com',
|
|
33
|
+
'customer-alias',
|
|
34
|
+
'database-alias'
|
|
35
|
+
).then(client => {
|
|
36
|
+
console.log('Successfully authenticated!');
|
|
37
|
+
// Use the client for API calls
|
|
38
|
+
}).catch(error => {
|
|
39
|
+
console.error('Authentication failed:', error);
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### JWT Authentication
|
|
44
|
+
|
|
45
|
+
If you already have a JWT token:
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
const auth = new vvRestApi.authorize();
|
|
49
|
+
|
|
50
|
+
auth.getVaultApiFromJwt(
|
|
51
|
+
'your-jwt-token',
|
|
52
|
+
'https://your-vault-url.com',
|
|
53
|
+
'customer-alias',
|
|
54
|
+
'database-alias',
|
|
55
|
+
new Date('2024-12-31') // expiration date
|
|
56
|
+
).then(client => {
|
|
57
|
+
console.log('JWT authentication successful!');
|
|
58
|
+
}).catch(error => {
|
|
59
|
+
console.error('JWT authentication failed:', error);
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## API Usage Examples
|
|
64
|
+
|
|
65
|
+
### Working with Documents
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
// Get documents from a folder
|
|
69
|
+
client.library.getDocuments(params, folderId)
|
|
70
|
+
.then(response => {
|
|
71
|
+
const documents = JSON.parse(response);
|
|
72
|
+
console.log('Documents:', documents.data);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Upload a new document
|
|
76
|
+
const documentData = {
|
|
77
|
+
fileName: 'example.pdf',
|
|
78
|
+
description: 'Example document',
|
|
79
|
+
folderId: 'your-folder-id'
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
client.documents.postDocWithFile(documentData, fileBuffer)
|
|
83
|
+
.then(response => {
|
|
84
|
+
console.log('Document uploaded:', response);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Get document details
|
|
88
|
+
client.documents.getDocumentRevision(params, revisionId)
|
|
89
|
+
.then(response => {
|
|
90
|
+
const document = JSON.parse(response);
|
|
91
|
+
console.log('Document details:', document);
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Working with Forms
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
// Get forms by template name
|
|
99
|
+
client.forms.getForms(params, 'Your Form Template Name')
|
|
100
|
+
.then(response => {
|
|
101
|
+
const forms = JSON.parse(response);
|
|
102
|
+
console.log('Forms:', forms.data);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Create a new form instance
|
|
106
|
+
const formData = {
|
|
107
|
+
field1: 'value1',
|
|
108
|
+
field2: 'value2'
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
client.forms.postForms(params, formData, 'Your Form Template Name')
|
|
112
|
+
.then(response => {
|
|
113
|
+
console.log('Form created:', response);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Get form instance by ID
|
|
117
|
+
client.forms.getFormInstanceById(templateId, instanceId)
|
|
118
|
+
.then(response => {
|
|
119
|
+
const form = JSON.parse(response);
|
|
120
|
+
console.log('Form instance:', form);
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Working with Folders
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
// Get folders
|
|
128
|
+
client.library.getFolders(params)
|
|
129
|
+
.then(response => {
|
|
130
|
+
const folders = JSON.parse(response);
|
|
131
|
+
console.log('Folders:', folders.data);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// Create a new folder
|
|
135
|
+
const folderData = {
|
|
136
|
+
name: 'New Folder',
|
|
137
|
+
description: 'Folder description'
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
client.library.postFolderByPath(params, folderData, '/Parent Folder/New Folder')
|
|
141
|
+
.then(response => {
|
|
142
|
+
console.log('Folder created:', response);
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Working with Users
|
|
147
|
+
|
|
148
|
+
```javascript
|
|
149
|
+
// Get current user information
|
|
150
|
+
client.users.getUser(params)
|
|
151
|
+
.then(response => {
|
|
152
|
+
const user = JSON.parse(response);
|
|
153
|
+
console.log('Current user:', user);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Get users in a site
|
|
157
|
+
client.users.getUsers(params, siteId)
|
|
158
|
+
.then(response => {
|
|
159
|
+
const users = JSON.parse(response);
|
|
160
|
+
console.log('Users:', users.data);
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Running Custom Queries
|
|
165
|
+
|
|
166
|
+
```javascript
|
|
167
|
+
// Execute a custom query by name
|
|
168
|
+
client.customQuery.getCustomQueryResultsByName('Your Query Name', params)
|
|
169
|
+
.then(response => {
|
|
170
|
+
const results = JSON.parse(response);
|
|
171
|
+
console.log('Query results:', results.data);
|
|
172
|
+
});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Working with Files
|
|
176
|
+
|
|
177
|
+
```javascript
|
|
178
|
+
// Upload a file
|
|
179
|
+
const fileData = {
|
|
180
|
+
fileName: 'document.pdf',
|
|
181
|
+
description: 'My document'
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
client.files.postFile(fileData, fileBuffer)
|
|
185
|
+
.then(response => {
|
|
186
|
+
console.log('File uploaded:', response);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// Download a file
|
|
190
|
+
client.files.getFileBytesId(fileId)
|
|
191
|
+
.then(fileBuffer => {
|
|
192
|
+
// Process the file buffer
|
|
193
|
+
console.log('File downloaded, size:', fileBuffer.length);
|
|
194
|
+
});
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Running Web Services
|
|
198
|
+
|
|
199
|
+
```javascript
|
|
200
|
+
// Execute a web service
|
|
201
|
+
const serviceData = {
|
|
202
|
+
param1: 'value1',
|
|
203
|
+
param2: 'value2'
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
client.scripts.runWebService('YourWebServiceName', serviceData)
|
|
207
|
+
.then(response => {
|
|
208
|
+
console.log('Web service result:', response);
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## API Modules
|
|
213
|
+
|
|
214
|
+
The client provides access to the following VisualVault API modules:
|
|
215
|
+
|
|
216
|
+
- **documents** - Document management operations
|
|
217
|
+
- **forms** - Form template and instance operations
|
|
218
|
+
- **library** - Folder and library management
|
|
219
|
+
- **users** - User management operations
|
|
220
|
+
- **groups** - Group management operations
|
|
221
|
+
- **sites** - Site management operations
|
|
222
|
+
- **files** - File upload/download operations
|
|
223
|
+
- **scripts** - Web service execution
|
|
224
|
+
- **customQuery** - Custom query execution
|
|
225
|
+
- **email** - Email operations
|
|
226
|
+
- **constants** - API constants and enums
|
|
227
|
+
- **scheduledProcess** - Scheduled process management
|
|
228
|
+
- **customer** - Customer management operations
|
|
229
|
+
- **projects** - Project management operations
|
|
230
|
+
- **indexFields** - Document Index field operations
|
|
231
|
+
- **outsideProcesses** - Outside process management
|
|
232
|
+
- **securityMembers** - Security member management
|
|
233
|
+
- **reports** - Report generation
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
## Error Handling
|
|
237
|
+
|
|
238
|
+
```javascript
|
|
239
|
+
client.documents.getDocuments(params, folderId)
|
|
240
|
+
.then(response => {
|
|
241
|
+
const result = JSON.parse(response);
|
|
242
|
+
if (result.meta && result.meta.statusCode === 200) {
|
|
243
|
+
console.log('Success:', result.data);
|
|
244
|
+
} else {
|
|
245
|
+
console.error('API Error:', result);
|
|
246
|
+
}
|
|
247
|
+
})
|
|
248
|
+
.catch(error => {
|
|
249
|
+
console.error('Request failed:', error);
|
|
250
|
+
});
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Support
|
|
254
|
+
|
|
255
|
+
For more information about the VisualVault API, visit the [VisualVault documentation](https://docs.visualvault.com/).
|
|
256
|
+
|
|
257
|
+
## License
|
|
258
|
+
|
|
259
|
+
Use of the VisualVault API requires a customer hosting contract which defines all license terms.
|
|
260
|
+
|
|
261
|
+
## Repository
|
|
262
|
+
|
|
263
|
+
[GitHub Repository](https://github.com/VisualVault/nodeJs-rest-client-library)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//DocApi
|
|
2
|
+
var common = require('./common');
|
|
3
|
+
|
|
4
|
+
module.exports = class DocApi {
|
|
5
|
+
constructor(sessionToken, docApiConfig) {
|
|
6
|
+
if (!sessionToken['tokenType'] && sessionToken['tokenType'] != 'jwt') {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
var yaml = require('js-yaml');
|
|
11
|
+
var fs = require('fs');
|
|
12
|
+
var yamlConfig = yaml.safeLoad(fs.readFileSync(__dirname + '/config.yml', 'utf8'));
|
|
13
|
+
this._httpHelper = new common.httpHelper(sessionToken, yamlConfig);
|
|
14
|
+
|
|
15
|
+
this.isEnabled = docApiConfig['isEnabled'] || false;
|
|
16
|
+
this.baseUrl = docApiConfig['apiUrl'] || null;
|
|
17
|
+
this.roleSecurity = docApiConfig['roleSecurity'] || false;
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async GetRevision(documentRevisionId) {
|
|
22
|
+
let resourceUri = this._httpHelper._config.ResourceUri.DocApi.GetRevision;
|
|
23
|
+
resourceUri = resourceUri.replace('{id}', documentRevisionId);
|
|
24
|
+
const url = this._httpHelper.getUrl(resourceUri);
|
|
25
|
+
const opts = { method: 'GET' };
|
|
26
|
+
|
|
27
|
+
return this._httpHelper.doVvClientRequest(url, opts, null, null);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async getDocumentOcrStatus(documentRevisionId) {
|
|
31
|
+
let resourceUri = this._httpHelper._config.ResourceUri.DocApi.OcrStatus;
|
|
32
|
+
resourceUri = resourceUri.replace('{id}', documentRevisionId);
|
|
33
|
+
const url = this._httpHelper.getUrl(resourceUri);
|
|
34
|
+
|
|
35
|
+
const opts = { method: 'GET' };
|
|
36
|
+
return this._httpHelper.doVvClientRequest(url, opts, null, null);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async updateDocumentOcrStatus(documentRevisionId, data) {
|
|
40
|
+
let resourceUri = this._httpHelper._config.ResourceUri.DocApi.OcrStatus;
|
|
41
|
+
resourceUri = resourceUri.replace('{id}', documentRevisionId);
|
|
42
|
+
const url = this._httpHelper.getUrl(resourceUri);
|
|
43
|
+
|
|
44
|
+
const opts = { method: 'PUT' };
|
|
45
|
+
return this._httpHelper.doVvClientRequest(url, opts, null, data);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async search(criteriaList, searchFolders, excludeFolders, sortBy, sortDirection = 'desc', page = 0, take = 15, archiveType = 0, roleSecurity = false) {
|
|
49
|
+
const url = this._httpHelper.getUrl(this._httpHelper._config.ResourceUri.DocApi.AdvancedSearch);
|
|
50
|
+
|
|
51
|
+
var data = {
|
|
52
|
+
criteriaList,
|
|
53
|
+
searchFolders,
|
|
54
|
+
excludeFolders,
|
|
55
|
+
sortBy,
|
|
56
|
+
sortDirection,
|
|
57
|
+
page,
|
|
58
|
+
take,
|
|
59
|
+
archiveType,
|
|
60
|
+
roleSecurity
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const options = { method: 'POST'};
|
|
64
|
+
return this._httpHelper.doVvClientRequest(url, options, null, data);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//forms api
|
|
2
|
+
var common = require('./common');
|
|
3
|
+
|
|
4
|
+
module.exports = class FormsApi {
|
|
5
|
+
constructor(sessionToken, formsApiConfig){
|
|
6
|
+
if(!sessionToken['tokenType'] && sessionToken['tokenType'] != 'jwt'){
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
var yaml = require('js-yaml');
|
|
11
|
+
var fs = require('fs');
|
|
12
|
+
var yamlConfig = yaml.safeLoad(fs.readFileSync(__dirname + '/config.yml', 'utf8'));
|
|
13
|
+
this._httpHelper = new common.httpHelper(sessionToken, yamlConfig);
|
|
14
|
+
|
|
15
|
+
this.isEnabled = formsApiConfig['isEnabled'] || false;
|
|
16
|
+
this.baseUrl = formsApiConfig['formsApiUrl'] || null;
|
|
17
|
+
|
|
18
|
+
if(this.isEnabled){
|
|
19
|
+
this.formInstances = new FormInstanceManager(this._httpHelper);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
class FormInstanceManager{
|
|
25
|
+
constructor(httpHelper){
|
|
26
|
+
this._httpHelper = httpHelper;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async postForm(params, data, formTemplateRevisionId) {
|
|
30
|
+
var resourceUri = this._httpHelper._config.ResourceUri.FormsApi.FormInstance;
|
|
31
|
+
var url = this._httpHelper.getUrl(resourceUri);
|
|
32
|
+
var opts = { method: 'POST' };
|
|
33
|
+
|
|
34
|
+
data['formTemplateId'] = formTemplateRevisionId || data['formTemplateId'];
|
|
35
|
+
|
|
36
|
+
return this._httpHelper.doVvClientRequest(url, opts, params, data);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async postFormRevision(params, data, formTemplateRevisionId, formId){
|
|
40
|
+
var resourceUri = this._httpHelper._config.ResourceUri.FormsApi.FormInstance;
|
|
41
|
+
var url = this._httpHelper.getUrl(resourceUri);
|
|
42
|
+
var opts = { method: 'PUT' };
|
|
43
|
+
|
|
44
|
+
// only add these if provided. params could already have the value
|
|
45
|
+
data['formTemplateId'] = formTemplateRevisionId || data['formTemplateId'];
|
|
46
|
+
data['formId'] = formId || data['formId'];
|
|
47
|
+
|
|
48
|
+
return this._httpHelper.doVvClientRequest(url, opts, params, data);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Notifications API
|
|
2
|
+
var common = require('./common');
|
|
3
|
+
|
|
4
|
+
module.exports = class NotificationsApi {
|
|
5
|
+
constructor(sessionToken, notificationsApiConfig) {
|
|
6
|
+
if(!sessionToken['tokenType'] && sessionToken['tokenType'] != 'jwt'){
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
var yaml = require('js-yaml');
|
|
11
|
+
var fs = require('fs');
|
|
12
|
+
var yamlConfig = yaml.safeLoad(fs.readFileSync(__dirname + '/config.yml', 'utf8'));
|
|
13
|
+
console.log("Before")
|
|
14
|
+
this._httpHelper = new common.httpHelper(sessionToken, yamlConfig);
|
|
15
|
+
console.log('After');
|
|
16
|
+
|
|
17
|
+
this.isEnabled = notificationsApiConfig['isEnabled'] || false;
|
|
18
|
+
this.baseUrl = notificationsApiConfig['apiUrl'] || null;
|
|
19
|
+
|
|
20
|
+
if (this.isEnabled) {
|
|
21
|
+
this.users = new UserNotificationsManager(this._httpHelper);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class UserNotificationsManager {
|
|
27
|
+
constructor (httpHelper) {
|
|
28
|
+
this._httpHelper = httpHelper;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async forceUIRefresh(userGuid) {
|
|
32
|
+
var resourceUri = this._httpHelper._config.ResourceUri.NotificationsApi.ForceUIRefresh.replace('{id}', userGuid);
|
|
33
|
+
var url = this._httpHelper.getUrl(resourceUri);
|
|
34
|
+
var opts = { method: 'POST' };
|
|
35
|
+
var params = {};
|
|
36
|
+
var data = {};
|
|
37
|
+
return this._httpHelper.doVvClientRequest(url, opts, params, data);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
//studio api
|
|
2
|
+
var common = require('./common');
|
|
3
|
+
|
|
4
|
+
module.exports = class StudioApi {
|
|
5
|
+
constructor(sessionToken, studioApiConfig){
|
|
6
|
+
if(!sessionToken['tokenType'] && sessionToken['tokenType'] != 'jwt'){
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
var yaml = require('js-yaml');
|
|
11
|
+
var fs = require('fs');
|
|
12
|
+
var yamlConfig = yaml.safeLoad(fs.readFileSync(__dirname + '/config.yml', 'utf8'));
|
|
13
|
+
this._httpHelper = new common.httpHelper(sessionToken, yamlConfig);
|
|
14
|
+
|
|
15
|
+
this.isEnabled = studioApiConfig['isEnabled'] || false;
|
|
16
|
+
this.baseUrl = studioApiConfig['studioApiUrl'] || null;
|
|
17
|
+
this.apiUrl = '';
|
|
18
|
+
|
|
19
|
+
if(this.isEnabled){
|
|
20
|
+
this.workflow = new WorkflowManager(this._httpHelper);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Manage Workflows */
|
|
26
|
+
class WorkflowManager{
|
|
27
|
+
constructor(httpHelper){
|
|
28
|
+
this._httpHelper = httpHelper;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Gets the latest published workflow by Id*/
|
|
32
|
+
async getWorkflow(workflowId){
|
|
33
|
+
var resourceUri = this._httpHelper._config.ResourceUri.StudioApi.WorkflowLatestPublishedId.replace('{id}', workflowId);
|
|
34
|
+
var url = this._httpHelper.getUrl(resourceUri);
|
|
35
|
+
var opts = { method: 'GET' };
|
|
36
|
+
var data = {};
|
|
37
|
+
var params = {};
|
|
38
|
+
|
|
39
|
+
return this._httpHelper.doVvClientRequest(url, opts, params, data);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Gets the latest published workflow by Name */
|
|
43
|
+
async getWorkflowByName(workflowName){
|
|
44
|
+
var resourceUri = this._httpHelper._config.ResourceUri.StudioApi.WorkflowLatestPublished;
|
|
45
|
+
var url = this._httpHelper.getUrl(resourceUri);
|
|
46
|
+
var opts = { method: 'GET' };
|
|
47
|
+
var data = {};
|
|
48
|
+
var params = { name: workflowName };
|
|
49
|
+
|
|
50
|
+
return this._httpHelper.doVvClientRequest(url, opts, params, data);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Gets workflow variables assigned to the workflow */
|
|
54
|
+
async getWorkflowVariables(params, workflowId){
|
|
55
|
+
var resourceUri = this._httpHelper._config.ResourceUri.StudioApi.WorkflowVariables.replace('{id}', workflowId);
|
|
56
|
+
var url = this._httpHelper.getUrl(resourceUri);
|
|
57
|
+
var opts = { method: 'GET' };
|
|
58
|
+
var data = {};
|
|
59
|
+
params = params || {};
|
|
60
|
+
|
|
61
|
+
return this._httpHelper.doVvClientRequest(url, opts, params, data);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Triggers workflow
|
|
66
|
+
* @param {string} workflowId
|
|
67
|
+
* @param {number} workflowRevision
|
|
68
|
+
* @param {string} objectId
|
|
69
|
+
* @param {object[]} workflowVariables - workflow values to be submitted to the workflow
|
|
70
|
+
* * @param {string} workflowVariables[].name = name of variable
|
|
71
|
+
* * @param {*} workflowVariables[].value - value to be passed
|
|
72
|
+
* * @param {number} workflowVariables[].dataType - Text: 1, Number: 2, Date: 3, Boolean: 4
|
|
73
|
+
*/
|
|
74
|
+
async triggerWorkflow(workflowId, workflowRevision, objectId, workflowVariables){
|
|
75
|
+
var resourceUri = this._httpHelper._config.ResourceUri.StudioApi.WorkflowRun.replace('{id}', workflowId).replace('{revision}', workflowRevision);
|
|
76
|
+
var url = this._httpHelper.getUrl(resourceUri);
|
|
77
|
+
var opts = { method: 'POST' };
|
|
78
|
+
var data ={
|
|
79
|
+
objectId: objectId,
|
|
80
|
+
reference: 'API',
|
|
81
|
+
data: {
|
|
82
|
+
workflowVariables: workflowVariables,
|
|
83
|
+
dataSetVariables: []
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var params = {};
|
|
87
|
+
|
|
88
|
+
return this._httpHelper.doVvClientRequest(url, opts, params, data);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Terminates the workflow instance
|
|
93
|
+
* @param {string} workflowId
|
|
94
|
+
* @param {string} instanceId
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
async terminateWorkflow(workflowId, instanceId){
|
|
98
|
+
var resourceUri = this._httpHelper._config.ResourceUri.StudioApi.WorkflowTerminate.replace('{workflowId}', workflowId).replace('{instanceId}', instanceId);
|
|
99
|
+
var url = this._httpHelper.getUrl(resourceUri);
|
|
100
|
+
var opts = { method: 'POST' };
|
|
101
|
+
var data ={}
|
|
102
|
+
var params = {};
|
|
103
|
+
return this._httpHelper.doVvClientRequest(url, opts, params, data);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Returns workflow history for an object under the provided workflow
|
|
108
|
+
* @param {string} workflowId
|
|
109
|
+
* @param {string} objectId
|
|
110
|
+
* @returns
|
|
111
|
+
*/
|
|
112
|
+
async GetWorkflowHistoryForObject(objectId, workflowId){
|
|
113
|
+
var resourceUri = this._httpHelper._config.ResourceUri.StudioApi.WorkflowHistoryObject.replace('{workflowId}', workflowId).replace('{objectId}', objectId);
|
|
114
|
+
var url = this._httpHelper.getUrl(resourceUri);
|
|
115
|
+
var opts = { method: 'GET' };
|
|
116
|
+
var data ={}
|
|
117
|
+
var params = {};
|
|
118
|
+
return this._httpHelper.doVvClientRequest(url, opts, params, data);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Returns the running workflow, if any, for an object under the provided workflow
|
|
123
|
+
* @param {string} workflowId
|
|
124
|
+
* @param {string} objectId
|
|
125
|
+
* @returns
|
|
126
|
+
*/
|
|
127
|
+
async GetRunningWorkflowForObject(objectId, workflowId){
|
|
128
|
+
var resourceUri = this._httpHelper._config.ResourceUri.StudioApi.WorkflowHistoryRunningObject.replace('{workflowId}', workflowId).replace('{objectId}', objectId);
|
|
129
|
+
var url = this._httpHelper.getUrl(resourceUri);
|
|
130
|
+
var opts = { method: 'GET' };
|
|
131
|
+
var data ={}
|
|
132
|
+
var params = {};
|
|
133
|
+
return this._httpHelper.doVvClientRequest(url, opts, params, data);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|