ultravisor 1.0.2 → 1.0.4
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/.claude/launch.json +11 -0
- package/.claude/ultravisor-dev-config.json +3 -0
- package/.ultravisor.json +426 -0
- package/docs/README.md +63 -0
- package/package.json +12 -8
- package/source/Ultravisor.cjs +22 -3
- package/source/cli/Ultravisor-CLIProgram.cjs +35 -23
- package/source/cli/commands/Ultravisor-Command-SingleOperation.cjs +29 -18
- package/source/cli/commands/Ultravisor-Command-SingleTask.cjs +62 -19
- package/source/cli/commands/Ultravisor-Command-UpdateTask.cjs +27 -15
- package/source/config/Ultravisor-Default-Command-Configuration.cjs +5 -3
- package/source/services/Ultravisor-ExecutionEngine.cjs +1039 -0
- package/source/services/Ultravisor-ExecutionManifest.cjs +399 -0
- package/source/services/Ultravisor-Hypervisor-State.cjs +270 -97
- package/source/services/Ultravisor-Hypervisor.cjs +38 -83
- package/source/services/Ultravisor-StateManager.cjs +241 -0
- package/source/services/Ultravisor-TaskTypeRegistry.cjs +143 -0
- package/source/services/tasks/Ultravisor-TaskType-Base.cjs +105 -0
- package/source/services/tasks/control/Ultravisor-TaskType-IfConditional.cjs +148 -0
- package/source/services/tasks/control/Ultravisor-TaskType-LaunchOperation.cjs +187 -0
- package/source/services/tasks/control/Ultravisor-TaskType-SplitExecute.cjs +184 -0
- package/source/services/tasks/data/Ultravisor-TaskType-ReplaceString.cjs +82 -0
- package/source/services/tasks/data/Ultravisor-TaskType-SetValues.cjs +81 -0
- package/source/services/tasks/data/Ultravisor-TaskType-StringAppender.cjs +101 -0
- package/source/services/tasks/file-io/Ultravisor-TaskType-ReadFile.cjs +103 -0
- package/source/services/tasks/file-io/Ultravisor-TaskType-WriteFile.cjs +117 -0
- package/source/services/tasks/interaction/Ultravisor-TaskType-ErrorMessage.cjs +54 -0
- package/source/services/tasks/interaction/Ultravisor-TaskType-ValueInput.cjs +62 -0
- package/source/web_server/Ultravisor-API-Server.cjs +237 -124
- package/test/Ultravisor_browser_tests.js +2226 -0
- package/test/Ultravisor_tests.js +1143 -5830
- package/webinterface/css/ultravisor.css +23 -0
- package/webinterface/package.json +6 -3
- package/webinterface/source/Pict-Application-Ultravisor.js +93 -73
- package/webinterface/source/cards/FlowCard-CSVTransform.js +43 -0
- package/webinterface/source/cards/FlowCard-Command.js +86 -0
- package/webinterface/source/cards/FlowCard-ComprehensionIntersect.js +40 -0
- package/webinterface/source/cards/FlowCard-Conditional.js +87 -0
- package/webinterface/source/cards/FlowCard-CopyFile.js +55 -0
- package/webinterface/source/cards/FlowCard-End.js +29 -0
- package/webinterface/source/cards/FlowCard-GetJSON.js +55 -0
- package/webinterface/source/cards/FlowCard-GetText.js +54 -0
- package/webinterface/source/cards/FlowCard-Histogram.js +176 -0
- package/webinterface/source/cards/FlowCard-LaunchOperation.js +82 -0
- package/webinterface/source/cards/FlowCard-ListFiles.js +55 -0
- package/webinterface/source/cards/FlowCard-MeadowCount.js +44 -0
- package/webinterface/source/cards/FlowCard-MeadowCreate.js +44 -0
- package/webinterface/source/cards/FlowCard-MeadowDelete.js +45 -0
- package/webinterface/source/cards/FlowCard-MeadowRead.js +46 -0
- package/webinterface/source/cards/FlowCard-MeadowReads.js +46 -0
- package/webinterface/source/cards/FlowCard-MeadowUpdate.js +44 -0
- package/webinterface/source/cards/FlowCard-ParseCSV.js +85 -0
- package/webinterface/source/cards/FlowCard-ReadJSON.js +54 -0
- package/webinterface/source/cards/FlowCard-ReadText.js +54 -0
- package/webinterface/source/cards/FlowCard-RestRequest.js +59 -0
- package/webinterface/source/cards/FlowCard-SendJSON.js +57 -0
- package/webinterface/source/cards/FlowCard-Solver.js +77 -0
- package/webinterface/source/cards/FlowCard-Start.js +29 -0
- package/webinterface/source/cards/FlowCard-TemplateString.js +77 -0
- package/webinterface/source/cards/FlowCard-WriteJSON.js +54 -0
- package/webinterface/source/cards/FlowCard-WriteText.js +54 -0
- package/webinterface/source/data/ExampleFlow-CSVPipeline.js +231 -0
- package/webinterface/source/data/ExampleFlow-FileProcessor.js +315 -0
- package/webinterface/source/data/ExampleFlow-MeadowPipeline.js +328 -0
- package/webinterface/source/providers/PictRouter-Ultravisor-Configuration.json +8 -8
- package/webinterface/source/views/PictView-Ultravisor-Dashboard.js +6 -6
- package/webinterface/source/views/PictView-Ultravisor-FlowEditor.js +436 -0
- package/webinterface/source/views/PictView-Ultravisor-ManifestList.js +45 -43
- package/webinterface/source/views/PictView-Ultravisor-OperationEdit.js +34 -89
- package/webinterface/source/views/PictView-Ultravisor-OperationList.js +128 -13
- package/webinterface/source/views/PictView-Ultravisor-PendingInput.js +314 -0
- package/webinterface/source/views/PictView-Ultravisor-Schedule.js +18 -53
- package/webinterface/source/views/PictView-Ultravisor-TimingView.js +27 -14
- package/webinterface/source/views/PictView-Ultravisor-TopBar.js +2 -1
- package/.babelrc +0 -6
- package/.browserslistrc +0 -1
- package/.browserslistrc-BACKUP +0 -1
- package/.gulpfile-quackage-config.json +0 -7
- package/.gulpfile-quackage.js +0 -2
- package/debug/Harness.js +0 -5
- package/source/services/Ultravisor-Operation-Manifest.cjs +0 -160
- package/source/services/Ultravisor-Operation.cjs +0 -200
- package/source/services/Ultravisor-Task.cjs +0 -349
- package/source/services/events/Ultravisor-Hypervisor-Event-Solver.cjs +0 -11
- package/source/services/tasks/Ultravisor-Task-Base.cjs +0 -264
- package/source/services/tasks/Ultravisor-Task-CollectValues.cjs +0 -188
- package/source/services/tasks/Ultravisor-Task-Command.cjs +0 -65
- package/source/services/tasks/Ultravisor-Task-CommandEach.cjs +0 -190
- package/source/services/tasks/Ultravisor-Task-Conditional.cjs +0 -104
- package/source/services/tasks/Ultravisor-Task-DateWindow.cjs +0 -72
- package/source/services/tasks/Ultravisor-Task-GeneratePagedOperation.cjs +0 -336
- package/source/services/tasks/Ultravisor-Task-LaunchOperation.cjs +0 -143
- package/source/services/tasks/Ultravisor-Task-LaunchTask.cjs +0 -146
- package/source/services/tasks/Ultravisor-Task-LineMatch.cjs +0 -158
- package/source/services/tasks/Ultravisor-Task-Request.cjs +0 -56
- package/source/services/tasks/Ultravisor-Task-Solver.cjs +0 -89
- package/source/services/tasks/Ultravisor-Task-TemplateString.cjs +0 -93
- package/source/services/tasks/rest/Ultravisor-Task-GetBinary.cjs +0 -127
- package/source/services/tasks/rest/Ultravisor-Task-GetJSON.cjs +0 -119
- package/source/services/tasks/rest/Ultravisor-Task-GetText.cjs +0 -109
- package/source/services/tasks/rest/Ultravisor-Task-GetXML.cjs +0 -112
- package/source/services/tasks/rest/Ultravisor-Task-RestRequest.cjs +0 -499
- package/source/services/tasks/rest/Ultravisor-Task-SendJSON.cjs +0 -150
- package/source/services/tasks/stagingfiles/Ultravisor-Task-CopyFile.cjs +0 -110
- package/source/services/tasks/stagingfiles/Ultravisor-Task-ListFiles.cjs +0 -89
- package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadBinary.cjs +0 -87
- package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadJSON.cjs +0 -67
- package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadText.cjs +0 -66
- package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadXML.cjs +0 -69
- package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteBinary.cjs +0 -95
- package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteJSON.cjs +0 -96
- package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteText.cjs +0 -99
- package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteXML.cjs +0 -102
- package/webinterface/.babelrc +0 -6
- package/webinterface/.browserslistrc +0 -1
- package/webinterface/.browserslistrc-BACKUP +0 -1
- package/webinterface/.gulpfile-quackage-config.json +0 -7
- package/webinterface/.gulpfile-quackage.js +0 -2
- package/webinterface/source/views/PictView-Ultravisor-TaskEdit.js +0 -220
- package/webinterface/source/views/PictView-Ultravisor-TaskList.js +0 -248
- /package/docs/{cover.md → _cover.md} +0 -0
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
const libUltravisorTaskBase = require('../Ultravisor-Task-Base.cjs');
|
|
2
|
-
|
|
3
|
-
const libHTTP = require('http');
|
|
4
|
-
const libHTTPS = require('https');
|
|
5
|
-
|
|
6
|
-
class UltravisorTaskGetBinary extends libUltravisorTaskBase
|
|
7
|
-
{
|
|
8
|
-
constructor(pFable)
|
|
9
|
-
{
|
|
10
|
-
super(pFable);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Download a binary file from an HTTP/HTTPS URL.
|
|
15
|
-
*
|
|
16
|
-
* Task definition fields:
|
|
17
|
-
* - URL: the endpoint to download from
|
|
18
|
-
* - Headers (optional): object of request headers
|
|
19
|
-
* - Destination (optional): manyfest address in GlobalState
|
|
20
|
-
* where the binary data is stored as base64 (defaults to "Output")
|
|
21
|
-
* - Persist (optional): where to store the downloaded content
|
|
22
|
-
* string -- manyfest address into GlobalState (stores base64)
|
|
23
|
-
* { Address: "..." } -- same as string form
|
|
24
|
-
* { File: "..." } -- writes the raw binary to a staging file
|
|
25
|
-
*/
|
|
26
|
-
execute(pTaskDefinition, pContext, pManifestEntry, fCallback)
|
|
27
|
-
{
|
|
28
|
-
let tmpURL = pTaskDefinition.URL || pTaskDefinition.Parameters || '';
|
|
29
|
-
|
|
30
|
-
if (!tmpURL || tmpURL.length === 0)
|
|
31
|
-
{
|
|
32
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
33
|
-
pManifestEntry.Status = 'Error';
|
|
34
|
-
pManifestEntry.Log.push(`GetBinary: missing URL.`);
|
|
35
|
-
return fCallback(null, pManifestEntry);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
pManifestEntry.Log.push(`GetBinary: GET ${tmpURL}`);
|
|
39
|
-
|
|
40
|
-
let tmpHeaders = Object.assign({}, pTaskDefinition.Headers || {});
|
|
41
|
-
|
|
42
|
-
let tmpParsedURL;
|
|
43
|
-
try
|
|
44
|
-
{
|
|
45
|
-
tmpParsedURL = new URL(tmpURL);
|
|
46
|
-
}
|
|
47
|
-
catch (pParseError)
|
|
48
|
-
{
|
|
49
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
50
|
-
pManifestEntry.Status = 'Error';
|
|
51
|
-
pManifestEntry.Log.push(`GetBinary: invalid URL: ${pParseError.message}`);
|
|
52
|
-
return fCallback(null, pManifestEntry);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
let tmpTransport = (tmpParsedURL.protocol === 'https:') ? libHTTPS : libHTTP;
|
|
56
|
-
let tmpTimeout = (this.fable?.ProgramConfiguration?.UltravisorCommandTimeoutMilliseconds) || 300000;
|
|
57
|
-
|
|
58
|
-
let tmpRequestOptions = {
|
|
59
|
-
method: 'GET',
|
|
60
|
-
headers: tmpHeaders,
|
|
61
|
-
timeout: tmpTimeout
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
let tmpRequest = tmpTransport.request(tmpURL, tmpRequestOptions,
|
|
65
|
-
(pResponse) =>
|
|
66
|
-
{
|
|
67
|
-
let tmpChunks = [];
|
|
68
|
-
|
|
69
|
-
pResponse.on('data', (pChunk) => { tmpChunks.push(pChunk); });
|
|
70
|
-
|
|
71
|
-
pResponse.on('end', () =>
|
|
72
|
-
{
|
|
73
|
-
let tmpBuffer = Buffer.concat(tmpChunks);
|
|
74
|
-
|
|
75
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
76
|
-
pManifestEntry.Log.push(`GetBinary: received ${tmpBuffer.length} bytes, status ${pResponse.statusCode}.`);
|
|
77
|
-
|
|
78
|
-
pManifestEntry.Output = `${tmpBuffer.length} bytes downloaded`;
|
|
79
|
-
pManifestEntry.Status = 'Complete';
|
|
80
|
-
pManifestEntry.Success = true;
|
|
81
|
-
pManifestEntry.Log.push(`GetBinary: download completed successfully.`);
|
|
82
|
-
|
|
83
|
-
this.storeDestination(pTaskDefinition, pContext, pManifestEntry, tmpBuffer.toString('base64'));
|
|
84
|
-
|
|
85
|
-
// Persist the result
|
|
86
|
-
if (pTaskDefinition.Persist)
|
|
87
|
-
{
|
|
88
|
-
let tmpPersist = pTaskDefinition.Persist;
|
|
89
|
-
let tmpIsAddressPersist = (typeof(tmpPersist) === 'string') ||
|
|
90
|
-
(typeof(tmpPersist) === 'object' && tmpPersist !== null && tmpPersist.Address);
|
|
91
|
-
|
|
92
|
-
if (tmpIsAddressPersist)
|
|
93
|
-
{
|
|
94
|
-
this.storeResult(pTaskDefinition, pContext, pManifestEntry, tmpBuffer.toString('base64'));
|
|
95
|
-
}
|
|
96
|
-
else
|
|
97
|
-
{
|
|
98
|
-
this.storeResult(pTaskDefinition, pContext, pManifestEntry, tmpBuffer);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return fCallback(null, pManifestEntry);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
tmpRequest.on('error', (pError) =>
|
|
107
|
-
{
|
|
108
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
109
|
-
pManifestEntry.Status = 'Error';
|
|
110
|
-
pManifestEntry.Log.push(`GetBinary: request error: ${pError.message}`);
|
|
111
|
-
return fCallback(null, pManifestEntry);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
tmpRequest.on('timeout', () =>
|
|
115
|
-
{
|
|
116
|
-
tmpRequest.destroy();
|
|
117
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
118
|
-
pManifestEntry.Status = 'Error';
|
|
119
|
-
pManifestEntry.Log.push(`GetBinary: request timed out after ${tmpTimeout}ms.`);
|
|
120
|
-
return fCallback(null, pManifestEntry);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
tmpRequest.end();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
module.exports = UltravisorTaskGetBinary;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
const libUltravisorTaskBase = require('../Ultravisor-Task-Base.cjs');
|
|
2
|
-
|
|
3
|
-
const libHTTP = require('http');
|
|
4
|
-
const libHTTPS = require('https');
|
|
5
|
-
|
|
6
|
-
class UltravisorTaskGetJSON extends libUltravisorTaskBase
|
|
7
|
-
{
|
|
8
|
-
constructor(pFable)
|
|
9
|
-
{
|
|
10
|
-
super(pFable);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Perform an HTTP/HTTPS GET and parse the response as JSON.
|
|
15
|
-
*
|
|
16
|
-
* Task definition fields:
|
|
17
|
-
* - URL: the endpoint to request
|
|
18
|
-
* - Headers (optional): object of request headers
|
|
19
|
-
* - Destination (optional): manyfest address in GlobalState
|
|
20
|
-
* where the parsed object is stored (defaults to "Output")
|
|
21
|
-
* - Persist (optional): where to store the parsed response
|
|
22
|
-
* string -- manyfest address into GlobalState
|
|
23
|
-
* { Address: "..." } -- same as string form
|
|
24
|
-
* { File: "..." } -- writes JSON to a staging file
|
|
25
|
-
*/
|
|
26
|
-
execute(pTaskDefinition, pContext, pManifestEntry, fCallback)
|
|
27
|
-
{
|
|
28
|
-
let tmpURL = pTaskDefinition.URL || pTaskDefinition.Parameters || '';
|
|
29
|
-
|
|
30
|
-
if (!tmpURL || tmpURL.length === 0)
|
|
31
|
-
{
|
|
32
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
33
|
-
pManifestEntry.Status = 'Error';
|
|
34
|
-
pManifestEntry.Log.push(`GetJSON: missing URL.`);
|
|
35
|
-
return fCallback(null, pManifestEntry);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
pManifestEntry.Log.push(`GetJSON: GET ${tmpURL}`);
|
|
39
|
-
|
|
40
|
-
let tmpHeaders = Object.assign({ 'Accept': 'application/json' }, pTaskDefinition.Headers || {});
|
|
41
|
-
|
|
42
|
-
let tmpParsedURL;
|
|
43
|
-
try
|
|
44
|
-
{
|
|
45
|
-
tmpParsedURL = new URL(tmpURL);
|
|
46
|
-
}
|
|
47
|
-
catch (pParseError)
|
|
48
|
-
{
|
|
49
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
50
|
-
pManifestEntry.Status = 'Error';
|
|
51
|
-
pManifestEntry.Log.push(`GetJSON: invalid URL: ${pParseError.message}`);
|
|
52
|
-
return fCallback(null, pManifestEntry);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
let tmpTransport = (tmpParsedURL.protocol === 'https:') ? libHTTPS : libHTTP;
|
|
56
|
-
let tmpTimeout = (this.fable?.ProgramConfiguration?.UltravisorCommandTimeoutMilliseconds) || 300000;
|
|
57
|
-
|
|
58
|
-
let tmpRequestOptions = {
|
|
59
|
-
method: 'GET',
|
|
60
|
-
headers: tmpHeaders,
|
|
61
|
-
timeout: tmpTimeout
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
let tmpRequest = tmpTransport.request(tmpURL, tmpRequestOptions,
|
|
65
|
-
(pResponse) =>
|
|
66
|
-
{
|
|
67
|
-
let tmpData = '';
|
|
68
|
-
|
|
69
|
-
pResponse.on('data', (pChunk) => { tmpData += pChunk; });
|
|
70
|
-
|
|
71
|
-
pResponse.on('end', () =>
|
|
72
|
-
{
|
|
73
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
74
|
-
pManifestEntry.Log.push(`GetJSON: received ${tmpData.length} bytes, status ${pResponse.statusCode}.`);
|
|
75
|
-
|
|
76
|
-
try
|
|
77
|
-
{
|
|
78
|
-
let tmpParsed = JSON.parse(tmpData);
|
|
79
|
-
pManifestEntry.Output = JSON.stringify(tmpParsed);
|
|
80
|
-
pManifestEntry.Status = 'Complete';
|
|
81
|
-
pManifestEntry.Success = true;
|
|
82
|
-
pManifestEntry.Log.push(`GetJSON: parsed JSON successfully.`);
|
|
83
|
-
|
|
84
|
-
this.storeDestination(pTaskDefinition, pContext, pManifestEntry, tmpParsed);
|
|
85
|
-
this.storeResult(pTaskDefinition, pContext, pManifestEntry, tmpParsed);
|
|
86
|
-
}
|
|
87
|
-
catch (pJsonError)
|
|
88
|
-
{
|
|
89
|
-
pManifestEntry.Output = tmpData.substring(0, 2000);
|
|
90
|
-
pManifestEntry.Status = 'Error';
|
|
91
|
-
pManifestEntry.Log.push(`GetJSON: failed to parse response as JSON: ${pJsonError.message}`);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return fCallback(null, pManifestEntry);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
tmpRequest.on('error', (pError) =>
|
|
99
|
-
{
|
|
100
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
101
|
-
pManifestEntry.Status = 'Error';
|
|
102
|
-
pManifestEntry.Log.push(`GetJSON: request error: ${pError.message}`);
|
|
103
|
-
return fCallback(null, pManifestEntry);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
tmpRequest.on('timeout', () =>
|
|
107
|
-
{
|
|
108
|
-
tmpRequest.destroy();
|
|
109
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
110
|
-
pManifestEntry.Status = 'Error';
|
|
111
|
-
pManifestEntry.Log.push(`GetJSON: request timed out after ${tmpTimeout}ms.`);
|
|
112
|
-
return fCallback(null, pManifestEntry);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
tmpRequest.end();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
module.exports = UltravisorTaskGetJSON;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
const libUltravisorTaskBase = require('../Ultravisor-Task-Base.cjs');
|
|
2
|
-
|
|
3
|
-
const libHTTP = require('http');
|
|
4
|
-
const libHTTPS = require('https');
|
|
5
|
-
|
|
6
|
-
class UltravisorTaskGetText extends libUltravisorTaskBase
|
|
7
|
-
{
|
|
8
|
-
constructor(pFable)
|
|
9
|
-
{
|
|
10
|
-
super(pFable);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Perform an HTTP/HTTPS GET and return the response as plain text.
|
|
15
|
-
*
|
|
16
|
-
* Task definition fields:
|
|
17
|
-
* - URL: the endpoint to request
|
|
18
|
-
* - Headers (optional): object of request headers
|
|
19
|
-
* - Destination (optional): manyfest address in GlobalState
|
|
20
|
-
* where the response text is stored (defaults to "Output")
|
|
21
|
-
* - Persist (optional): where to store the response text
|
|
22
|
-
* string -- manyfest address into GlobalState
|
|
23
|
-
* { Address: "..." } -- same as string form
|
|
24
|
-
* { File: "..." } -- writes the text to a staging file
|
|
25
|
-
*/
|
|
26
|
-
execute(pTaskDefinition, pContext, pManifestEntry, fCallback)
|
|
27
|
-
{
|
|
28
|
-
let tmpURL = pTaskDefinition.URL || pTaskDefinition.Parameters || '';
|
|
29
|
-
|
|
30
|
-
if (!tmpURL || tmpURL.length === 0)
|
|
31
|
-
{
|
|
32
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
33
|
-
pManifestEntry.Status = 'Error';
|
|
34
|
-
pManifestEntry.Log.push(`GetText: missing URL.`);
|
|
35
|
-
return fCallback(null, pManifestEntry);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
pManifestEntry.Log.push(`GetText: GET ${tmpURL}`);
|
|
39
|
-
|
|
40
|
-
let tmpHeaders = Object.assign({ 'Accept': 'text/plain' }, pTaskDefinition.Headers || {});
|
|
41
|
-
|
|
42
|
-
let tmpParsedURL;
|
|
43
|
-
try
|
|
44
|
-
{
|
|
45
|
-
tmpParsedURL = new URL(tmpURL);
|
|
46
|
-
}
|
|
47
|
-
catch (pParseError)
|
|
48
|
-
{
|
|
49
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
50
|
-
pManifestEntry.Status = 'Error';
|
|
51
|
-
pManifestEntry.Log.push(`GetText: invalid URL: ${pParseError.message}`);
|
|
52
|
-
return fCallback(null, pManifestEntry);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
let tmpTransport = (tmpParsedURL.protocol === 'https:') ? libHTTPS : libHTTP;
|
|
56
|
-
let tmpTimeout = (this.fable?.ProgramConfiguration?.UltravisorCommandTimeoutMilliseconds) || 300000;
|
|
57
|
-
|
|
58
|
-
let tmpRequestOptions = {
|
|
59
|
-
method: 'GET',
|
|
60
|
-
headers: tmpHeaders,
|
|
61
|
-
timeout: tmpTimeout
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
let tmpRequest = tmpTransport.request(tmpURL, tmpRequestOptions,
|
|
65
|
-
(pResponse) =>
|
|
66
|
-
{
|
|
67
|
-
let tmpData = '';
|
|
68
|
-
|
|
69
|
-
pResponse.on('data', (pChunk) => { tmpData += pChunk; });
|
|
70
|
-
|
|
71
|
-
pResponse.on('end', () =>
|
|
72
|
-
{
|
|
73
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
74
|
-
pManifestEntry.Log.push(`GetText: received ${tmpData.length} bytes, status ${pResponse.statusCode}.`);
|
|
75
|
-
|
|
76
|
-
pManifestEntry.Output = tmpData;
|
|
77
|
-
pManifestEntry.Status = 'Complete';
|
|
78
|
-
pManifestEntry.Success = true;
|
|
79
|
-
pManifestEntry.Log.push(`GetText: response received successfully.`);
|
|
80
|
-
|
|
81
|
-
this.storeDestination(pTaskDefinition, pContext, pManifestEntry, tmpData);
|
|
82
|
-
this.storeResult(pTaskDefinition, pContext, pManifestEntry, tmpData);
|
|
83
|
-
|
|
84
|
-
return fCallback(null, pManifestEntry);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
tmpRequest.on('error', (pError) =>
|
|
89
|
-
{
|
|
90
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
91
|
-
pManifestEntry.Status = 'Error';
|
|
92
|
-
pManifestEntry.Log.push(`GetText: request error: ${pError.message}`);
|
|
93
|
-
return fCallback(null, pManifestEntry);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
tmpRequest.on('timeout', () =>
|
|
97
|
-
{
|
|
98
|
-
tmpRequest.destroy();
|
|
99
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
100
|
-
pManifestEntry.Status = 'Error';
|
|
101
|
-
pManifestEntry.Log.push(`GetText: request timed out after ${tmpTimeout}ms.`);
|
|
102
|
-
return fCallback(null, pManifestEntry);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
tmpRequest.end();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
module.exports = UltravisorTaskGetText;
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
const libUltravisorTaskBase = require('../Ultravisor-Task-Base.cjs');
|
|
2
|
-
|
|
3
|
-
const libHTTP = require('http');
|
|
4
|
-
const libHTTPS = require('https');
|
|
5
|
-
|
|
6
|
-
class UltravisorTaskGetXML extends libUltravisorTaskBase
|
|
7
|
-
{
|
|
8
|
-
constructor(pFable)
|
|
9
|
-
{
|
|
10
|
-
super(pFable);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Perform an HTTP/HTTPS GET and return the response as XML text.
|
|
15
|
-
*
|
|
16
|
-
* The raw XML string is returned in Output. No parsing is performed
|
|
17
|
-
* -- the caller is responsible for interpreting the XML structure.
|
|
18
|
-
*
|
|
19
|
-
* Task definition fields:
|
|
20
|
-
* - URL: the endpoint to request
|
|
21
|
-
* - Headers (optional): object of request headers
|
|
22
|
-
* - Destination (optional): manyfest address in GlobalState
|
|
23
|
-
* where the XML response is stored (defaults to "Output")
|
|
24
|
-
* - Persist (optional): where to store the XML response
|
|
25
|
-
* string -- manyfest address into GlobalState
|
|
26
|
-
* { Address: "..." } -- same as string form
|
|
27
|
-
* { File: "..." } -- writes the XML to a staging file
|
|
28
|
-
*/
|
|
29
|
-
execute(pTaskDefinition, pContext, pManifestEntry, fCallback)
|
|
30
|
-
{
|
|
31
|
-
let tmpURL = pTaskDefinition.URL || pTaskDefinition.Parameters || '';
|
|
32
|
-
|
|
33
|
-
if (!tmpURL || tmpURL.length === 0)
|
|
34
|
-
{
|
|
35
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
36
|
-
pManifestEntry.Status = 'Error';
|
|
37
|
-
pManifestEntry.Log.push(`GetXML: missing URL.`);
|
|
38
|
-
return fCallback(null, pManifestEntry);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
pManifestEntry.Log.push(`GetXML: GET ${tmpURL}`);
|
|
42
|
-
|
|
43
|
-
let tmpHeaders = Object.assign({ 'Accept': 'application/xml, text/xml' }, pTaskDefinition.Headers || {});
|
|
44
|
-
|
|
45
|
-
let tmpParsedURL;
|
|
46
|
-
try
|
|
47
|
-
{
|
|
48
|
-
tmpParsedURL = new URL(tmpURL);
|
|
49
|
-
}
|
|
50
|
-
catch (pParseError)
|
|
51
|
-
{
|
|
52
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
53
|
-
pManifestEntry.Status = 'Error';
|
|
54
|
-
pManifestEntry.Log.push(`GetXML: invalid URL: ${pParseError.message}`);
|
|
55
|
-
return fCallback(null, pManifestEntry);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
let tmpTransport = (tmpParsedURL.protocol === 'https:') ? libHTTPS : libHTTP;
|
|
59
|
-
let tmpTimeout = (this.fable?.ProgramConfiguration?.UltravisorCommandTimeoutMilliseconds) || 300000;
|
|
60
|
-
|
|
61
|
-
let tmpRequestOptions = {
|
|
62
|
-
method: 'GET',
|
|
63
|
-
headers: tmpHeaders,
|
|
64
|
-
timeout: tmpTimeout
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
let tmpRequest = tmpTransport.request(tmpURL, tmpRequestOptions,
|
|
68
|
-
(pResponse) =>
|
|
69
|
-
{
|
|
70
|
-
let tmpData = '';
|
|
71
|
-
|
|
72
|
-
pResponse.on('data', (pChunk) => { tmpData += pChunk; });
|
|
73
|
-
|
|
74
|
-
pResponse.on('end', () =>
|
|
75
|
-
{
|
|
76
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
77
|
-
pManifestEntry.Log.push(`GetXML: received ${tmpData.length} bytes, status ${pResponse.statusCode}.`);
|
|
78
|
-
|
|
79
|
-
pManifestEntry.Output = tmpData;
|
|
80
|
-
pManifestEntry.Status = 'Complete';
|
|
81
|
-
pManifestEntry.Success = true;
|
|
82
|
-
pManifestEntry.Log.push(`GetXML: response received successfully.`);
|
|
83
|
-
|
|
84
|
-
this.storeDestination(pTaskDefinition, pContext, pManifestEntry, tmpData);
|
|
85
|
-
this.storeResult(pTaskDefinition, pContext, pManifestEntry, tmpData);
|
|
86
|
-
|
|
87
|
-
return fCallback(null, pManifestEntry);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
tmpRequest.on('error', (pError) =>
|
|
92
|
-
{
|
|
93
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
94
|
-
pManifestEntry.Status = 'Error';
|
|
95
|
-
pManifestEntry.Log.push(`GetXML: request error: ${pError.message}`);
|
|
96
|
-
return fCallback(null, pManifestEntry);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
tmpRequest.on('timeout', () =>
|
|
100
|
-
{
|
|
101
|
-
tmpRequest.destroy();
|
|
102
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
103
|
-
pManifestEntry.Status = 'Error';
|
|
104
|
-
pManifestEntry.Log.push(`GetXML: request timed out after ${tmpTimeout}ms.`);
|
|
105
|
-
return fCallback(null, pManifestEntry);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
tmpRequest.end();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
module.exports = UltravisorTaskGetXML;
|