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,110 +0,0 @@
|
|
|
1
|
-
const libUltravisorTaskBase = require('../Ultravisor-Task-Base.cjs');
|
|
2
|
-
|
|
3
|
-
const libFS = require('fs');
|
|
4
|
-
const libPath = require('path');
|
|
5
|
-
|
|
6
|
-
class UltravisorTaskCopyFile extends libUltravisorTaskBase
|
|
7
|
-
{
|
|
8
|
-
constructor(pFable)
|
|
9
|
-
{
|
|
10
|
-
super(pFable);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Copy a local file into the staging folder.
|
|
15
|
-
*
|
|
16
|
-
* Task definition fields:
|
|
17
|
-
* - Source: absolute path to the local file to copy
|
|
18
|
-
* - File: relative destination path inside the staging folder
|
|
19
|
-
* - Address (optional): dot-notation path into GlobalState
|
|
20
|
-
* containing the source path (used instead of Source)
|
|
21
|
-
*/
|
|
22
|
-
execute(pTaskDefinition, pContext, pManifestEntry, fCallback)
|
|
23
|
-
{
|
|
24
|
-
let tmpStagingPath = this.resolveStagingPath(pContext);
|
|
25
|
-
|
|
26
|
-
// --- Resolve the source path ---
|
|
27
|
-
let tmpSourcePath = undefined;
|
|
28
|
-
|
|
29
|
-
if (pTaskDefinition.Address && typeof(pTaskDefinition.Address) === 'string')
|
|
30
|
-
{
|
|
31
|
-
tmpSourcePath = this.resolveAddress(pTaskDefinition.Address, pContext);
|
|
32
|
-
pManifestEntry.Log.push(`CopyFile: resolved source from Address "${pTaskDefinition.Address}".`);
|
|
33
|
-
}
|
|
34
|
-
else if (pTaskDefinition.Source && typeof(pTaskDefinition.Source) === 'string')
|
|
35
|
-
{
|
|
36
|
-
tmpSourcePath = pTaskDefinition.Source;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (!tmpSourcePath || typeof(tmpSourcePath) !== 'string' || tmpSourcePath.length === 0)
|
|
40
|
-
{
|
|
41
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
42
|
-
pManifestEntry.Status = 'Error';
|
|
43
|
-
pManifestEntry.Log.push(`CopyFile: missing or invalid Source (or Address) field.`);
|
|
44
|
-
return fCallback(null, pManifestEntry);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// --- Resolve the destination path ---
|
|
48
|
-
let tmpDestFilePath = this.resolveStagingFilePath(tmpStagingPath, pTaskDefinition.File);
|
|
49
|
-
|
|
50
|
-
if (!tmpDestFilePath)
|
|
51
|
-
{
|
|
52
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
53
|
-
pManifestEntry.Status = 'Error';
|
|
54
|
-
pManifestEntry.Log.push(`CopyFile: missing or invalid File field.`);
|
|
55
|
-
return fCallback(null, pManifestEntry);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
pManifestEntry.Log.push(`CopyFile: copying "${tmpSourcePath}" to "${tmpDestFilePath}".`);
|
|
59
|
-
|
|
60
|
-
try
|
|
61
|
-
{
|
|
62
|
-
// Verify the source file exists
|
|
63
|
-
if (!libFS.existsSync(tmpSourcePath))
|
|
64
|
-
{
|
|
65
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
66
|
-
pManifestEntry.Status = 'Error';
|
|
67
|
-
pManifestEntry.Log.push(`CopyFile: source file not found: "${tmpSourcePath}".`);
|
|
68
|
-
return fCallback(null, pManifestEntry);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Verify the source is a file (not a directory)
|
|
72
|
-
let tmpSourceStat = libFS.statSync(tmpSourcePath);
|
|
73
|
-
if (!tmpSourceStat.isFile())
|
|
74
|
-
{
|
|
75
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
76
|
-
pManifestEntry.Status = 'Error';
|
|
77
|
-
pManifestEntry.Log.push(`CopyFile: source is not a file: "${tmpSourcePath}".`);
|
|
78
|
-
return fCallback(null, pManifestEntry);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Ensure the destination directory exists
|
|
82
|
-
let tmpDir = libPath.dirname(tmpDestFilePath);
|
|
83
|
-
if (!libFS.existsSync(tmpDir))
|
|
84
|
-
{
|
|
85
|
-
libFS.mkdirSync(tmpDir, { recursive: true });
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Copy the file
|
|
89
|
-
libFS.copyFileSync(tmpSourcePath, tmpDestFilePath);
|
|
90
|
-
|
|
91
|
-
let tmpDestStat = libFS.statSync(tmpDestFilePath);
|
|
92
|
-
|
|
93
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
94
|
-
pManifestEntry.Status = 'Complete';
|
|
95
|
-
pManifestEntry.Success = true;
|
|
96
|
-
pManifestEntry.Output = `${tmpDestStat.size} bytes copied`;
|
|
97
|
-
pManifestEntry.Log.push(`CopyFile: copied ${tmpDestStat.size} bytes.`);
|
|
98
|
-
}
|
|
99
|
-
catch (pError)
|
|
100
|
-
{
|
|
101
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
102
|
-
pManifestEntry.Status = 'Error';
|
|
103
|
-
pManifestEntry.Log.push(`CopyFile: ${pError.message}`);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return fCallback(null, pManifestEntry);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
module.exports = UltravisorTaskCopyFile;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
const libUltravisorTaskBase = require('../Ultravisor-Task-Base.cjs');
|
|
2
|
-
|
|
3
|
-
const libFS = require('fs');
|
|
4
|
-
const libPath = require('path');
|
|
5
|
-
|
|
6
|
-
class UltravisorTaskListFiles extends libUltravisorTaskBase
|
|
7
|
-
{
|
|
8
|
-
constructor(pFable)
|
|
9
|
-
{
|
|
10
|
-
super(pFable);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* List files in the staging folder (or a sub-path within it).
|
|
15
|
-
*
|
|
16
|
-
* Task definition fields:
|
|
17
|
-
* - Path (optional): sub-directory within the staging folder
|
|
18
|
-
*/
|
|
19
|
-
execute(pTaskDefinition, pContext, pManifestEntry, fCallback)
|
|
20
|
-
{
|
|
21
|
-
let tmpStagingPath = this.resolveStagingPath(pContext);
|
|
22
|
-
let tmpTargetPath = tmpStagingPath;
|
|
23
|
-
|
|
24
|
-
if (pTaskDefinition.Path && typeof(pTaskDefinition.Path) === 'string' && pTaskDefinition.Path.length > 0)
|
|
25
|
-
{
|
|
26
|
-
let tmpResolved = this.resolveStagingFilePath(tmpStagingPath, pTaskDefinition.Path);
|
|
27
|
-
if (!tmpResolved)
|
|
28
|
-
{
|
|
29
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
30
|
-
pManifestEntry.Status = 'Error';
|
|
31
|
-
pManifestEntry.Log.push(`ListFiles: invalid path "${pTaskDefinition.Path}".`);
|
|
32
|
-
return fCallback(null, pManifestEntry);
|
|
33
|
-
}
|
|
34
|
-
tmpTargetPath = tmpResolved;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
pManifestEntry.Log.push(`ListFiles: listing files in ${tmpTargetPath}`);
|
|
38
|
-
|
|
39
|
-
try
|
|
40
|
-
{
|
|
41
|
-
if (!libFS.existsSync(tmpTargetPath))
|
|
42
|
-
{
|
|
43
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
44
|
-
pManifestEntry.Status = 'Error';
|
|
45
|
-
pManifestEntry.Log.push(`ListFiles: path does not exist: ${tmpTargetPath}`);
|
|
46
|
-
return fCallback(null, pManifestEntry);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
let tmpFiles = libFS.readdirSync(tmpTargetPath);
|
|
50
|
-
let tmpResults = [];
|
|
51
|
-
|
|
52
|
-
for (let i = 0; i < tmpFiles.length; i++)
|
|
53
|
-
{
|
|
54
|
-
let tmpFullPath = libPath.join(tmpTargetPath, tmpFiles[i]);
|
|
55
|
-
try
|
|
56
|
-
{
|
|
57
|
-
let tmpStat = libFS.statSync(tmpFullPath);
|
|
58
|
-
tmpResults.push(
|
|
59
|
-
{
|
|
60
|
-
Name: tmpFiles[i],
|
|
61
|
-
Size: tmpStat.size,
|
|
62
|
-
IsDirectory: tmpStat.isDirectory(),
|
|
63
|
-
Modified: tmpStat.mtime.toISOString()
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
catch (pStatError)
|
|
67
|
-
{
|
|
68
|
-
tmpResults.push({ Name: tmpFiles[i], Error: pStatError.message });
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
73
|
-
pManifestEntry.Status = 'Complete';
|
|
74
|
-
pManifestEntry.Success = true;
|
|
75
|
-
pManifestEntry.Output = JSON.stringify(tmpResults);
|
|
76
|
-
pManifestEntry.Log.push(`ListFiles: found ${tmpResults.length} entries.`);
|
|
77
|
-
}
|
|
78
|
-
catch (pError)
|
|
79
|
-
{
|
|
80
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
81
|
-
pManifestEntry.Status = 'Error';
|
|
82
|
-
pManifestEntry.Log.push(`ListFiles: ${pError.message}`);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return fCallback(null, pManifestEntry);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
module.exports = UltravisorTaskListFiles;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
const libUltravisorTaskBase = require('../Ultravisor-Task-Base.cjs');
|
|
2
|
-
|
|
3
|
-
const libFS = require('fs');
|
|
4
|
-
|
|
5
|
-
class UltravisorTaskReadBinary extends libUltravisorTaskBase
|
|
6
|
-
{
|
|
7
|
-
constructor(pFable)
|
|
8
|
-
{
|
|
9
|
-
super(pFable);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Read a binary file from the staging folder.
|
|
14
|
-
*
|
|
15
|
-
* Task definition fields:
|
|
16
|
-
* - File: relative file path inside the staging folder
|
|
17
|
-
* - Destination (optional): manyfest address in GlobalState
|
|
18
|
-
* where the binary data is stored as base64 (defaults to "Output")
|
|
19
|
-
* - Persist (optional): where to store the result
|
|
20
|
-
* string -- manyfest address into GlobalState (stores base64)
|
|
21
|
-
* { Address: "..." } -- same as string form
|
|
22
|
-
* { File: "..." } -- copies the binary to another staging path
|
|
23
|
-
*/
|
|
24
|
-
execute(pTaskDefinition, pContext, pManifestEntry, fCallback)
|
|
25
|
-
{
|
|
26
|
-
let tmpStagingPath = this.resolveStagingPath(pContext);
|
|
27
|
-
let tmpFilePath = this.resolveStagingFilePath(tmpStagingPath, pTaskDefinition.File);
|
|
28
|
-
|
|
29
|
-
if (!tmpFilePath)
|
|
30
|
-
{
|
|
31
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
32
|
-
pManifestEntry.Status = 'Error';
|
|
33
|
-
pManifestEntry.Log.push(`ReadBinary: missing or invalid File field.`);
|
|
34
|
-
return fCallback(null, pManifestEntry);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
pManifestEntry.Log.push(`ReadBinary: reading from ${tmpFilePath}`);
|
|
38
|
-
|
|
39
|
-
try
|
|
40
|
-
{
|
|
41
|
-
if (!libFS.existsSync(tmpFilePath))
|
|
42
|
-
{
|
|
43
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
44
|
-
pManifestEntry.Status = 'Error';
|
|
45
|
-
pManifestEntry.Log.push(`ReadBinary: file does not exist: ${tmpFilePath}`);
|
|
46
|
-
return fCallback(null, pManifestEntry);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
let tmpBuffer = libFS.readFileSync(tmpFilePath);
|
|
50
|
-
|
|
51
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
52
|
-
pManifestEntry.Status = 'Complete';
|
|
53
|
-
pManifestEntry.Success = true;
|
|
54
|
-
pManifestEntry.Output = `${tmpBuffer.length} bytes read`;
|
|
55
|
-
pManifestEntry.Log.push(`ReadBinary: read ${tmpBuffer.length} bytes.`);
|
|
56
|
-
|
|
57
|
-
this.storeDestination(pTaskDefinition, pContext, pManifestEntry, tmpBuffer.toString('base64'));
|
|
58
|
-
|
|
59
|
-
// When persisting to a state address, store as base64 string
|
|
60
|
-
if (pTaskDefinition.Persist)
|
|
61
|
-
{
|
|
62
|
-
let tmpPersist = pTaskDefinition.Persist;
|
|
63
|
-
let tmpIsAddressPersist = (typeof(tmpPersist) === 'string') ||
|
|
64
|
-
(typeof(tmpPersist) === 'object' && tmpPersist !== null && tmpPersist.Address);
|
|
65
|
-
|
|
66
|
-
if (tmpIsAddressPersist)
|
|
67
|
-
{
|
|
68
|
-
this.storeResult(pTaskDefinition, pContext, pManifestEntry, tmpBuffer.toString('base64'));
|
|
69
|
-
}
|
|
70
|
-
else
|
|
71
|
-
{
|
|
72
|
-
this.storeResult(pTaskDefinition, pContext, pManifestEntry, tmpBuffer);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
catch (pError)
|
|
77
|
-
{
|
|
78
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
79
|
-
pManifestEntry.Status = 'Error';
|
|
80
|
-
pManifestEntry.Log.push(`ReadBinary: ${pError.message}`);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return fCallback(null, pManifestEntry);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
module.exports = UltravisorTaskReadBinary;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const libUltravisorTaskBase = require('../Ultravisor-Task-Base.cjs');
|
|
2
|
-
|
|
3
|
-
const libFS = require('fs');
|
|
4
|
-
|
|
5
|
-
class UltravisorTaskReadJSON extends libUltravisorTaskBase
|
|
6
|
-
{
|
|
7
|
-
constructor(pFable)
|
|
8
|
-
{
|
|
9
|
-
super(pFable);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Read a JSON file from the staging folder and parse it.
|
|
14
|
-
*
|
|
15
|
-
* Task definition fields:
|
|
16
|
-
* - File: relative file path inside the staging folder
|
|
17
|
-
* - Destination (optional): manyfest address in GlobalState
|
|
18
|
-
* where the parsed object is stored (defaults to "Output")
|
|
19
|
-
*/
|
|
20
|
-
execute(pTaskDefinition, pContext, pManifestEntry, fCallback)
|
|
21
|
-
{
|
|
22
|
-
let tmpStagingPath = this.resolveStagingPath(pContext);
|
|
23
|
-
let tmpFilePath = this.resolveStagingFilePath(tmpStagingPath, pTaskDefinition.File);
|
|
24
|
-
|
|
25
|
-
if (!tmpFilePath)
|
|
26
|
-
{
|
|
27
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
28
|
-
pManifestEntry.Status = 'Error';
|
|
29
|
-
pManifestEntry.Log.push(`ReadJSON: missing or invalid File field.`);
|
|
30
|
-
return fCallback(null, pManifestEntry);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
pManifestEntry.Log.push(`ReadJSON: reading from ${tmpFilePath}`);
|
|
34
|
-
|
|
35
|
-
try
|
|
36
|
-
{
|
|
37
|
-
if (!libFS.existsSync(tmpFilePath))
|
|
38
|
-
{
|
|
39
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
40
|
-
pManifestEntry.Status = 'Error';
|
|
41
|
-
pManifestEntry.Log.push(`ReadJSON: file does not exist: ${tmpFilePath}`);
|
|
42
|
-
return fCallback(null, pManifestEntry);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
let tmpRaw = libFS.readFileSync(tmpFilePath, 'utf8');
|
|
46
|
-
let tmpParsed = JSON.parse(tmpRaw);
|
|
47
|
-
|
|
48
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
49
|
-
pManifestEntry.Status = 'Complete';
|
|
50
|
-
pManifestEntry.Success = true;
|
|
51
|
-
pManifestEntry.Output = JSON.stringify(tmpParsed);
|
|
52
|
-
pManifestEntry.Log.push(`ReadJSON: read ${tmpRaw.length} bytes, parsed successfully.`);
|
|
53
|
-
|
|
54
|
-
this.storeDestination(pTaskDefinition, pContext, pManifestEntry, tmpParsed);
|
|
55
|
-
}
|
|
56
|
-
catch (pError)
|
|
57
|
-
{
|
|
58
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
59
|
-
pManifestEntry.Status = 'Error';
|
|
60
|
-
pManifestEntry.Log.push(`ReadJSON: ${pError.message}`);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return fCallback(null, pManifestEntry);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
module.exports = UltravisorTaskReadJSON;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
const libUltravisorTaskBase = require('../Ultravisor-Task-Base.cjs');
|
|
2
|
-
|
|
3
|
-
const libFS = require('fs');
|
|
4
|
-
|
|
5
|
-
class UltravisorTaskReadText extends libUltravisorTaskBase
|
|
6
|
-
{
|
|
7
|
-
constructor(pFable)
|
|
8
|
-
{
|
|
9
|
-
super(pFable);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Read a text file from the staging folder.
|
|
14
|
-
*
|
|
15
|
-
* Task definition fields:
|
|
16
|
-
* - File: relative file path inside the staging folder
|
|
17
|
-
* - Destination (optional): manyfest address in GlobalState
|
|
18
|
-
* where the text content is stored (defaults to "Output")
|
|
19
|
-
*/
|
|
20
|
-
execute(pTaskDefinition, pContext, pManifestEntry, fCallback)
|
|
21
|
-
{
|
|
22
|
-
let tmpStagingPath = this.resolveStagingPath(pContext);
|
|
23
|
-
let tmpFilePath = this.resolveStagingFilePath(tmpStagingPath, pTaskDefinition.File);
|
|
24
|
-
|
|
25
|
-
if (!tmpFilePath)
|
|
26
|
-
{
|
|
27
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
28
|
-
pManifestEntry.Status = 'Error';
|
|
29
|
-
pManifestEntry.Log.push(`ReadText: missing or invalid File field.`);
|
|
30
|
-
return fCallback(null, pManifestEntry);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
pManifestEntry.Log.push(`ReadText: reading from ${tmpFilePath}`);
|
|
34
|
-
|
|
35
|
-
try
|
|
36
|
-
{
|
|
37
|
-
if (!libFS.existsSync(tmpFilePath))
|
|
38
|
-
{
|
|
39
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
40
|
-
pManifestEntry.Status = 'Error';
|
|
41
|
-
pManifestEntry.Log.push(`ReadText: file does not exist: ${tmpFilePath}`);
|
|
42
|
-
return fCallback(null, pManifestEntry);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
let tmpContent = libFS.readFileSync(tmpFilePath, 'utf8');
|
|
46
|
-
|
|
47
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
48
|
-
pManifestEntry.Status = 'Complete';
|
|
49
|
-
pManifestEntry.Success = true;
|
|
50
|
-
pManifestEntry.Output = tmpContent;
|
|
51
|
-
pManifestEntry.Log.push(`ReadText: read ${tmpContent.length} bytes.`);
|
|
52
|
-
|
|
53
|
-
this.storeDestination(pTaskDefinition, pContext, pManifestEntry, tmpContent);
|
|
54
|
-
}
|
|
55
|
-
catch (pError)
|
|
56
|
-
{
|
|
57
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
58
|
-
pManifestEntry.Status = 'Error';
|
|
59
|
-
pManifestEntry.Log.push(`ReadText: ${pError.message}`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return fCallback(null, pManifestEntry);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
module.exports = UltravisorTaskReadText;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
const libUltravisorTaskBase = require('../Ultravisor-Task-Base.cjs');
|
|
2
|
-
|
|
3
|
-
const libFS = require('fs');
|
|
4
|
-
|
|
5
|
-
class UltravisorTaskReadXML extends libUltravisorTaskBase
|
|
6
|
-
{
|
|
7
|
-
constructor(pFable)
|
|
8
|
-
{
|
|
9
|
-
super(pFable);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Read an XML file from the staging folder and return it as a string.
|
|
14
|
-
*
|
|
15
|
-
* The raw XML content is returned in Output. No parsing is performed
|
|
16
|
-
* -- the caller is responsible for interpreting the XML structure.
|
|
17
|
-
*
|
|
18
|
-
* Task definition fields:
|
|
19
|
-
* - File: relative file path inside the staging folder
|
|
20
|
-
* - Destination (optional): manyfest address in GlobalState
|
|
21
|
-
* where the XML content is stored (defaults to "Output")
|
|
22
|
-
*/
|
|
23
|
-
execute(pTaskDefinition, pContext, pManifestEntry, fCallback)
|
|
24
|
-
{
|
|
25
|
-
let tmpStagingPath = this.resolveStagingPath(pContext);
|
|
26
|
-
let tmpFilePath = this.resolveStagingFilePath(tmpStagingPath, pTaskDefinition.File);
|
|
27
|
-
|
|
28
|
-
if (!tmpFilePath)
|
|
29
|
-
{
|
|
30
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
31
|
-
pManifestEntry.Status = 'Error';
|
|
32
|
-
pManifestEntry.Log.push(`ReadXML: missing or invalid File field.`);
|
|
33
|
-
return fCallback(null, pManifestEntry);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
pManifestEntry.Log.push(`ReadXML: reading from ${tmpFilePath}`);
|
|
37
|
-
|
|
38
|
-
try
|
|
39
|
-
{
|
|
40
|
-
if (!libFS.existsSync(tmpFilePath))
|
|
41
|
-
{
|
|
42
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
43
|
-
pManifestEntry.Status = 'Error';
|
|
44
|
-
pManifestEntry.Log.push(`ReadXML: file does not exist: ${tmpFilePath}`);
|
|
45
|
-
return fCallback(null, pManifestEntry);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
let tmpContent = libFS.readFileSync(tmpFilePath, 'utf8');
|
|
49
|
-
|
|
50
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
51
|
-
pManifestEntry.Status = 'Complete';
|
|
52
|
-
pManifestEntry.Success = true;
|
|
53
|
-
pManifestEntry.Output = tmpContent;
|
|
54
|
-
pManifestEntry.Log.push(`ReadXML: read ${tmpContent.length} bytes.`);
|
|
55
|
-
|
|
56
|
-
this.storeDestination(pTaskDefinition, pContext, pManifestEntry, tmpContent);
|
|
57
|
-
}
|
|
58
|
-
catch (pError)
|
|
59
|
-
{
|
|
60
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
61
|
-
pManifestEntry.Status = 'Error';
|
|
62
|
-
pManifestEntry.Log.push(`ReadXML: ${pError.message}`);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return fCallback(null, pManifestEntry);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
module.exports = UltravisorTaskReadXML;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
const libUltravisorTaskBase = require('../Ultravisor-Task-Base.cjs');
|
|
2
|
-
|
|
3
|
-
const libFS = require('fs');
|
|
4
|
-
const libPath = require('path');
|
|
5
|
-
|
|
6
|
-
class UltravisorTaskWriteBinary extends libUltravisorTaskBase
|
|
7
|
-
{
|
|
8
|
-
constructor(pFable)
|
|
9
|
-
{
|
|
10
|
-
super(pFable);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Write binary data to a file in the staging folder.
|
|
15
|
-
*
|
|
16
|
-
* Task definition fields:
|
|
17
|
-
* - File: relative file path inside the staging folder
|
|
18
|
-
* - Data: the data to write — may be a Buffer, a base64 string,
|
|
19
|
-
* or an array of byte values
|
|
20
|
-
*/
|
|
21
|
-
execute(pTaskDefinition, pContext, pManifestEntry, fCallback)
|
|
22
|
-
{
|
|
23
|
-
let tmpStagingPath = this.resolveStagingPath(pContext);
|
|
24
|
-
let tmpFilePath = this.resolveStagingFilePath(tmpStagingPath, pTaskDefinition.File);
|
|
25
|
-
|
|
26
|
-
if (!tmpFilePath)
|
|
27
|
-
{
|
|
28
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
29
|
-
pManifestEntry.Status = 'Error';
|
|
30
|
-
pManifestEntry.Log.push(`WriteBinary: missing or invalid File field.`);
|
|
31
|
-
return fCallback(null, pManifestEntry);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (!pTaskDefinition.hasOwnProperty('Data'))
|
|
35
|
-
{
|
|
36
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
37
|
-
pManifestEntry.Status = 'Error';
|
|
38
|
-
pManifestEntry.Log.push(`WriteBinary: missing Data field.`);
|
|
39
|
-
return fCallback(null, pManifestEntry);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
pManifestEntry.Log.push(`WriteBinary: writing to ${tmpFilePath}`);
|
|
43
|
-
|
|
44
|
-
try
|
|
45
|
-
{
|
|
46
|
-
let tmpDir = libPath.dirname(tmpFilePath);
|
|
47
|
-
if (!libFS.existsSync(tmpDir))
|
|
48
|
-
{
|
|
49
|
-
libFS.mkdirSync(tmpDir, { recursive: true });
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
let tmpBuffer;
|
|
53
|
-
|
|
54
|
-
if (Buffer.isBuffer(pTaskDefinition.Data))
|
|
55
|
-
{
|
|
56
|
-
tmpBuffer = pTaskDefinition.Data;
|
|
57
|
-
}
|
|
58
|
-
else if (typeof(pTaskDefinition.Data) === 'string')
|
|
59
|
-
{
|
|
60
|
-
// Treat string data as base64 encoded
|
|
61
|
-
tmpBuffer = Buffer.from(pTaskDefinition.Data, 'base64');
|
|
62
|
-
}
|
|
63
|
-
else if (Array.isArray(pTaskDefinition.Data))
|
|
64
|
-
{
|
|
65
|
-
// Treat array as byte values
|
|
66
|
-
tmpBuffer = Buffer.from(pTaskDefinition.Data);
|
|
67
|
-
}
|
|
68
|
-
else
|
|
69
|
-
{
|
|
70
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
71
|
-
pManifestEntry.Status = 'Error';
|
|
72
|
-
pManifestEntry.Log.push(`WriteBinary: Data must be a Buffer, base64 string, or array of byte values.`);
|
|
73
|
-
return fCallback(null, pManifestEntry);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
libFS.writeFileSync(tmpFilePath, tmpBuffer);
|
|
77
|
-
|
|
78
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
79
|
-
pManifestEntry.Status = 'Complete';
|
|
80
|
-
pManifestEntry.Success = true;
|
|
81
|
-
pManifestEntry.Output = `${tmpBuffer.length} bytes written`;
|
|
82
|
-
pManifestEntry.Log.push(`WriteBinary: wrote ${tmpBuffer.length} bytes.`);
|
|
83
|
-
}
|
|
84
|
-
catch (pError)
|
|
85
|
-
{
|
|
86
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
87
|
-
pManifestEntry.Status = 'Error';
|
|
88
|
-
pManifestEntry.Log.push(`WriteBinary: ${pError.message}`);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return fCallback(null, pManifestEntry);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
module.exports = UltravisorTaskWriteBinary;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
const libUltravisorTaskBase = require('../Ultravisor-Task-Base.cjs');
|
|
2
|
-
|
|
3
|
-
const libFS = require('fs');
|
|
4
|
-
const libPath = require('path');
|
|
5
|
-
|
|
6
|
-
class UltravisorTaskWriteJSON extends libUltravisorTaskBase
|
|
7
|
-
{
|
|
8
|
-
constructor(pFable)
|
|
9
|
-
{
|
|
10
|
-
super(pFable);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Write JSON data to a file in the staging folder.
|
|
15
|
-
*
|
|
16
|
-
* Task definition fields:
|
|
17
|
-
* - File: relative file path inside the staging folder
|
|
18
|
-
* - Address (optional): dot-notation path into GlobalState to
|
|
19
|
-
* resolve the data to write (used instead of Data)
|
|
20
|
-
* - Data: the object/value to serialise as JSON
|
|
21
|
-
*
|
|
22
|
-
* Either Address or Data must be provided. When Address is set,
|
|
23
|
-
* the data is resolved from pContext.GlobalState (or NodeState).
|
|
24
|
-
*/
|
|
25
|
-
execute(pTaskDefinition, pContext, pManifestEntry, fCallback)
|
|
26
|
-
{
|
|
27
|
-
let tmpStagingPath = this.resolveStagingPath(pContext);
|
|
28
|
-
let tmpFilePath = this.resolveStagingFilePath(tmpStagingPath, pTaskDefinition.File);
|
|
29
|
-
|
|
30
|
-
if (!tmpFilePath)
|
|
31
|
-
{
|
|
32
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
33
|
-
pManifestEntry.Status = 'Error';
|
|
34
|
-
pManifestEntry.Log.push(`WriteJSON: missing or invalid File field.`);
|
|
35
|
-
return fCallback(null, pManifestEntry);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Resolve data from Address or Data
|
|
39
|
-
let tmpData;
|
|
40
|
-
|
|
41
|
-
if (pTaskDefinition.Address && typeof(pTaskDefinition.Address) === 'string')
|
|
42
|
-
{
|
|
43
|
-
tmpData = this.resolveAddress(pTaskDefinition.Address, pContext);
|
|
44
|
-
pManifestEntry.Log.push(`WriteJSON: resolved data from Address "${pTaskDefinition.Address}".`);
|
|
45
|
-
}
|
|
46
|
-
else if (pTaskDefinition.hasOwnProperty('Data'))
|
|
47
|
-
{
|
|
48
|
-
tmpData = pTaskDefinition.Data;
|
|
49
|
-
}
|
|
50
|
-
else
|
|
51
|
-
{
|
|
52
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
53
|
-
pManifestEntry.Status = 'Error';
|
|
54
|
-
pManifestEntry.Log.push(`WriteJSON: missing Data or Address field.`);
|
|
55
|
-
return fCallback(null, pManifestEntry);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (tmpData === undefined)
|
|
59
|
-
{
|
|
60
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
61
|
-
pManifestEntry.Status = 'Error';
|
|
62
|
-
pManifestEntry.Log.push(`WriteJSON: resolved data is undefined.`);
|
|
63
|
-
return fCallback(null, pManifestEntry);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
pManifestEntry.Log.push(`WriteJSON: writing to ${tmpFilePath}`);
|
|
67
|
-
|
|
68
|
-
try
|
|
69
|
-
{
|
|
70
|
-
let tmpDir = libPath.dirname(tmpFilePath);
|
|
71
|
-
if (!libFS.existsSync(tmpDir))
|
|
72
|
-
{
|
|
73
|
-
libFS.mkdirSync(tmpDir, { recursive: true });
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
let tmpContent = JSON.stringify(tmpData, null, 4);
|
|
77
|
-
libFS.writeFileSync(tmpFilePath, tmpContent, 'utf8');
|
|
78
|
-
|
|
79
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
80
|
-
pManifestEntry.Status = 'Complete';
|
|
81
|
-
pManifestEntry.Success = true;
|
|
82
|
-
pManifestEntry.Output = `${tmpContent.length} bytes written`;
|
|
83
|
-
pManifestEntry.Log.push(`WriteJSON: wrote ${tmpContent.length} bytes.`);
|
|
84
|
-
}
|
|
85
|
-
catch (pError)
|
|
86
|
-
{
|
|
87
|
-
pManifestEntry.StopTime = new Date().toISOString();
|
|
88
|
-
pManifestEntry.Status = 'Error';
|
|
89
|
-
pManifestEntry.Log.push(`WriteJSON: ${pError.message}`);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return fCallback(null, pManifestEntry);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
module.exports = UltravisorTaskWriteJSON;
|