ultravisor 1.0.3 → 1.0.8
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/card-audit.json +1545 -0
- package/docs/_sidebar.md +17 -0
- package/docs/css/docuserve.css +73 -0
- package/docs/features/beacon-authentication.md +209 -0
- package/docs/features/beacon-providers.md +1299 -0
- package/docs/features/beacons.md +530 -0
- package/docs/features/capabilities.md +193 -0
- package/docs/features/llm-model-setup.md +505 -0
- package/docs/features/llm.md +262 -0
- package/docs/features/tasks-content-system.md +110 -0
- package/docs/features/tasks-data-transform.md +233 -0
- package/docs/features/tasks-extension.md +36 -0
- package/docs/features/tasks-file-system.md +203 -0
- package/docs/features/tasks-flow-control.md +125 -0
- package/docs/features/tasks-http-client.md +119 -0
- package/docs/features/tasks-llm.md +118 -0
- package/docs/features/tasks-meadow-api.md +163 -0
- package/docs/features/tasks-user-interaction.md +49 -0
- package/docs/features/tasks.md +14 -0
- package/docs/index.html +1 -1
- package/docs/retold-catalog.json +1 -1
- package/docs/retold-keyword-index.json +17374 -5
- package/operation-library/api-data-pipeline.json +143 -0
- package/operation-library/beacon-remote-command.json +72 -0
- package/operation-library/conditional-file-backup.json +143 -0
- package/operation-library/config-processor.json +136 -0
- package/operation-library/csv-data-analysis.json +228 -0
- package/operation-library/csv-to-json.json +160 -0
- package/operation-library/directory-inventory.json +128 -0
- package/operation-library/expression-calculator.json +114 -0
- package/operation-library/file-search-replace.json +175 -0
- package/operation-library/git-status-report.json +368 -0
- package/operation-library/health-check-ping.json +329 -0
- package/operation-library/json-config-merge.json +313 -0
- package/operation-library/llm-embedding-tool-use.json +314 -0
- package/operation-library/llm-multi-turn-analysis.json +322 -0
- package/operation-library/llm-summarize.json +264 -0
- package/operation-library/log-line-counter.json +185 -0
- package/operation-library/meadow-crud-lifecycle.json +264 -0
- package/operation-library/npm-project-validator.json +193 -0
- package/operation-library/rest-api-orchestrator.json +218 -0
- package/operation-library/shell-system-info.json +137 -0
- package/operation-library/simple-echo.json +95 -0
- package/operation-library/template-processor.json +299 -0
- package/operation-library/text-sanitizer.json +176 -0
- package/package.json +12 -8
- package/source/Ultravisor.cjs +30 -3
- package/source/beacon/Ultravisor-Beacon-CLI.cjs +143 -0
- package/source/beacon/Ultravisor-Beacon-CapabilityProvider.cjs +129 -0
- package/source/beacon/Ultravisor-Beacon-Client.cjs +568 -0
- package/source/beacon/Ultravisor-Beacon-Executor.cjs +500 -0
- package/source/beacon/Ultravisor-Beacon-ProviderRegistry.cjs +330 -0
- package/source/beacon/providers/Ultravisor-Beacon-Provider-FileSystem.cjs +331 -0
- package/source/beacon/providers/Ultravisor-Beacon-Provider-LLM.cjs +966 -0
- package/source/beacon/providers/Ultravisor-Beacon-Provider-Shell.cjs +95 -0
- package/source/cli/Ultravisor-CLIProgram.cjs +44 -22
- 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 +12 -3
- package/source/services/Ultravisor-Beacon-Coordinator.cjs +966 -0
- package/source/services/Ultravisor-ExecutionEngine.cjs +1093 -0
- package/source/services/Ultravisor-ExecutionManifest.cjs +629 -0
- package/source/services/Ultravisor-Hypervisor-State.cjs +270 -97
- package/source/services/Ultravisor-Hypervisor.cjs +185 -75
- package/source/services/Ultravisor-Schedule-Persistence-Base.cjs +45 -0
- package/source/services/Ultravisor-StateManager.cjs +253 -0
- package/source/services/Ultravisor-TaskTypeRegistry.cjs +213 -0
- package/source/services/persistence/Ultravisor-Schedule-Persistence-JSONFile.cjs +140 -0
- package/source/services/tasks/Ultravisor-BuiltIn-TaskConfigs.cjs +19 -0
- package/source/services/tasks/Ultravisor-TaskHelper-BeaconDispatch.cjs +107 -0
- package/source/services/tasks/Ultravisor-TaskType-Base.cjs +125 -0
- package/source/services/tasks/content-system/Ultravisor-TaskConfigs-ContentSystem.cjs +90 -0
- package/source/services/tasks/content-system/definitions/content-create-folder.json +24 -0
- package/source/services/tasks/content-system/definitions/content-list-files.json +27 -0
- package/source/services/tasks/content-system/definitions/content-read-file.json +26 -0
- package/source/services/tasks/content-system/definitions/content-save-file.json +26 -0
- package/source/services/tasks/data-transform/Ultravisor-TaskConfigs-DataTransform.cjs +577 -0
- package/source/services/tasks/data-transform/Ultravisor-TaskType-ReplaceString.cjs +80 -0
- package/source/services/tasks/data-transform/Ultravisor-TaskType-SetValues.cjs +74 -0
- package/source/services/tasks/data-transform/Ultravisor-TaskType-StringAppender.cjs +90 -0
- package/source/services/tasks/data-transform/definitions/comprehension-intersect.json +24 -0
- package/source/services/tasks/data-transform/definitions/csv-transform.json +24 -0
- package/source/services/tasks/data-transform/definitions/expression-solver.json +20 -0
- package/source/services/tasks/data-transform/definitions/histogram.json +23 -0
- package/source/services/tasks/data-transform/definitions/parse-csv.json +27 -0
- package/source/services/tasks/data-transform/definitions/replace-string.json +27 -0
- package/source/services/tasks/data-transform/definitions/set-values.json +17 -0
- package/source/services/tasks/data-transform/definitions/string-appender.json +22 -0
- package/source/services/tasks/data-transform/definitions/template-string.json +20 -0
- package/source/services/tasks/extension/Ultravisor-TaskConfigs-Extension.cjs +87 -0
- package/source/services/tasks/extension/definitions/beacon-dispatch.json +32 -0
- package/source/services/tasks/file-system/Ultravisor-TaskConfigs-FileSystem.cjs +509 -0
- package/source/services/tasks/file-system/Ultravisor-TaskType-ReadFile.cjs +96 -0
- package/source/services/tasks/file-system/Ultravisor-TaskType-ReadFileBuffered.cjs +123 -0
- package/source/services/tasks/file-system/Ultravisor-TaskType-WriteFile.cjs +106 -0
- package/source/services/tasks/file-system/definitions/copy-file.json +27 -0
- package/source/services/tasks/file-system/definitions/list-files.json +27 -0
- package/source/services/tasks/file-system/definitions/read-file-buffered.json +31 -0
- package/source/services/tasks/file-system/definitions/read-file.json +26 -0
- package/source/services/tasks/file-system/definitions/read-json.json +23 -0
- package/source/services/tasks/file-system/definitions/write-file.json +29 -0
- package/source/services/tasks/file-system/definitions/write-json.json +30 -0
- package/source/services/tasks/flow-control/Ultravisor-TaskConfigs-FlowControl.cjs +353 -0
- package/source/services/tasks/flow-control/Ultravisor-TaskType-IfConditional.cjs +125 -0
- package/source/services/tasks/flow-control/Ultravisor-TaskType-LaunchOperation.cjs +186 -0
- package/source/services/tasks/flow-control/Ultravisor-TaskType-SplitExecute.cjs +164 -0
- package/source/services/tasks/flow-control/definitions/if-conditional.json +25 -0
- package/source/services/tasks/flow-control/definitions/launch-operation.json +27 -0
- package/source/services/tasks/flow-control/definitions/split-execute.json +32 -0
- package/source/services/tasks/http-client/Ultravisor-TaskConfigs-HttpClient.cjs +281 -0
- package/source/services/tasks/http-client/definitions/get-json.json +26 -0
- package/source/services/tasks/http-client/definitions/get-text.json +26 -0
- package/source/services/tasks/http-client/definitions/rest-request.json +32 -0
- package/source/services/tasks/http-client/definitions/send-json.json +28 -0
- package/source/services/tasks/llm/Ultravisor-TaskConfigs-LLM.cjs +605 -0
- package/source/services/tasks/llm/definitions/llm-chat-completion.json +46 -0
- package/source/services/tasks/llm/definitions/llm-embedding.json +31 -0
- package/source/services/tasks/llm/definitions/llm-tool-use.json +42 -0
- package/source/services/tasks/meadow-api/Ultravisor-TaskConfigs-MeadowApi.cjs +341 -0
- package/source/services/tasks/meadow-api/definitions/meadow-count.json +26 -0
- package/source/services/tasks/meadow-api/definitions/meadow-create.json +26 -0
- package/source/services/tasks/meadow-api/definitions/meadow-delete.json +23 -0
- package/source/services/tasks/meadow-api/definitions/meadow-read.json +26 -0
- package/source/services/tasks/meadow-api/definitions/meadow-reads.json +29 -0
- package/source/services/tasks/meadow-api/definitions/meadow-update.json +26 -0
- package/source/services/tasks/shell/Ultravisor-TaskConfigs-Shell.cjs +63 -0
- package/source/services/tasks/shell/definitions/command.json +29 -0
- package/source/services/tasks/user-interaction/Ultravisor-TaskConfigs-UserInteraction.cjs +64 -0
- package/source/services/tasks/user-interaction/Ultravisor-TaskType-ErrorMessage.cjs +55 -0
- package/source/services/tasks/user-interaction/Ultravisor-TaskType-ValueInput.cjs +47 -0
- package/source/services/tasks/user-interaction/definitions/error-message.json +18 -0
- package/source/services/tasks/user-interaction/definitions/value-input.json +23 -0
- package/source/web_server/Ultravisor-API-Server.cjs +849 -124
- package/test/Ultravisor_browser_tests.js +2226 -0
- package/test/Ultravisor_operation_library_tests.js +894 -0
- package/test/Ultravisor_tests.js +4946 -5044
- package/test/workflows/test-content-concatenate-all.json +339 -0
- package/test/workflows/test-content-full-pipeline.json +159 -0
- package/test/workflows/test-content-list-files.json +76 -0
- package/test/workflows/test-content-save-and-read.json +106 -0
- package/webinterface/css/ultravisor-themes.css +668 -0
- package/webinterface/css/ultravisor.css +37 -14
- package/webinterface/docs/card-help/beacon-dispatch.md +30 -0
- package/webinterface/docs/card-help/command.md +27 -0
- package/webinterface/docs/card-help/comprehension-intersect.md +24 -0
- package/webinterface/docs/card-help/content-create-folder.md +22 -0
- package/webinterface/docs/card-help/content-list-files.md +25 -0
- package/webinterface/docs/card-help/content-read-file.md +24 -0
- package/webinterface/docs/card-help/content-save-file.md +24 -0
- package/webinterface/docs/card-help/copy-file.md +25 -0
- package/webinterface/docs/card-help/csv-transform.md +24 -0
- package/webinterface/docs/card-help/end.md +11 -0
- package/webinterface/docs/card-help/error-message.md +16 -0
- package/webinterface/docs/card-help/expression-solver.md +21 -0
- package/webinterface/docs/card-help/get-json.md +24 -0
- package/webinterface/docs/card-help/get-text.md +24 -0
- package/webinterface/docs/card-help/histogram.md +23 -0
- package/webinterface/docs/card-help/if-conditional.md +23 -0
- package/webinterface/docs/card-help/launch-operation.md +25 -0
- package/webinterface/docs/card-help/list-files.md +25 -0
- package/webinterface/docs/card-help/llm-chat-completion.md +43 -0
- package/webinterface/docs/card-help/llm-embedding.md +24 -0
- package/webinterface/docs/card-help/llm-tool-use.md +39 -0
- package/webinterface/docs/card-help/meadow-count.md +24 -0
- package/webinterface/docs/card-help/meadow-create.md +24 -0
- package/webinterface/docs/card-help/meadow-delete.md +19 -0
- package/webinterface/docs/card-help/meadow-read.md +24 -0
- package/webinterface/docs/card-help/meadow-reads.md +27 -0
- package/webinterface/docs/card-help/meadow-update.md +24 -0
- package/webinterface/docs/card-help/parse-csv.md +27 -0
- package/webinterface/docs/card-help/read-file-buffered.md +29 -0
- package/webinterface/docs/card-help/read-file.md +24 -0
- package/webinterface/docs/card-help/read-json.md +21 -0
- package/webinterface/docs/card-help/replace-string.md +25 -0
- package/webinterface/docs/card-help/rest-request.md +30 -0
- package/webinterface/docs/card-help/send-json.md +26 -0
- package/webinterface/docs/card-help/set-values.md +16 -0
- package/webinterface/docs/card-help/split-execute.md +35 -0
- package/webinterface/docs/card-help/start.md +11 -0
- package/webinterface/docs/card-help/string-appender.md +22 -0
- package/webinterface/docs/card-help/template-string.md +21 -0
- package/webinterface/docs/card-help/value-input.md +24 -0
- package/webinterface/docs/card-help/write-file.md +27 -0
- package/webinterface/docs/card-help/write-json.md +28 -0
- package/webinterface/html/index.html +5 -0
- package/webinterface/package.json +13 -4
- package/webinterface/source/Pict-Application-Ultravisor.js +564 -70
- package/webinterface/source/Ultravisor-TimingUtils.js +99 -0
- package/webinterface/source/card-help-content.js +46 -0
- package/webinterface/source/cards/Ultravisor-BuiltIn-CardConfigs.js +174 -0
- package/webinterface/source/cards/Ultravisor-CardConfigGenerator.js +431 -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/panels/Ultravisor-CardSettingsPanel.js +902 -0
- package/webinterface/source/providers/PictRouter-Ultravisor-Configuration.json +20 -8
- package/webinterface/source/views/PictView-Ultravisor-BeaconList.js +817 -0
- package/webinterface/source/views/PictView-Ultravisor-BottomBar.js +5 -5
- package/webinterface/source/views/PictView-Ultravisor-Dashboard.js +25 -25
- package/webinterface/source/views/PictView-Ultravisor-Documentation.js +856 -0
- package/webinterface/source/views/PictView-Ultravisor-FlowEditor.js +777 -0
- package/webinterface/source/views/PictView-Ultravisor-ManifestList.js +321 -58
- package/webinterface/source/views/PictView-Ultravisor-OperationEdit.js +36 -91
- package/webinterface/source/views/PictView-Ultravisor-OperationList.js +388 -16
- package/webinterface/source/views/PictView-Ultravisor-PendingInput.js +314 -0
- package/webinterface/source/views/PictView-Ultravisor-Schedule.js +521 -65
- package/webinterface/source/views/PictView-Ultravisor-TimingView.js +333 -71
- package/webinterface/source/views/PictView-Ultravisor-TopBar.js +257 -21
- package/webinterface/theme-sampler.html +645 -0
- package/debug/Harness.js +0 -6
- 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/source/views/PictView-Ultravisor-TaskEdit.js +0 -220
- package/webinterface/source/views/PictView-Ultravisor-TaskList.js +0 -248
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
const libUltravisorTaskType = require('../Ultravisor-TaskType-Base.cjs');
|
|
2
|
+
const libFS = require('fs');
|
|
3
|
+
const libPath = require('path');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Read File Buffered task type.
|
|
7
|
+
*
|
|
8
|
+
* Reads a file in chunks up to a maximum buffer size, splitting on the
|
|
9
|
+
* last occurrence of a preferred split character within the buffer.
|
|
10
|
+
* Supports continuation via ByteOffset for processing large files
|
|
11
|
+
* incrementally.
|
|
12
|
+
*/
|
|
13
|
+
class UltravisorTaskTypeReadFileBuffered extends libUltravisorTaskType
|
|
14
|
+
{
|
|
15
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
16
|
+
{
|
|
17
|
+
super(pFable, pOptions, pServiceHash);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get definition()
|
|
21
|
+
{
|
|
22
|
+
return require('./definitions/read-file-buffered.json');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
execute(pResolvedSettings, pExecutionContext, fCallback, fFireIntermediateEvent)
|
|
26
|
+
{
|
|
27
|
+
let tmpFilePath = pResolvedSettings.FilePath || '';
|
|
28
|
+
let tmpEncoding = pResolvedSettings.Encoding || 'utf8';
|
|
29
|
+
let tmpMaxBufferSize = parseInt(pResolvedSettings.MaxBufferSize, 10) || 65536;
|
|
30
|
+
let tmpSplitChar = pResolvedSettings.SplitCharacter;
|
|
31
|
+
let tmpByteOffset = parseInt(pResolvedSettings.ByteOffset, 10) || 0;
|
|
32
|
+
|
|
33
|
+
if (tmpSplitChar === undefined || tmpSplitChar === null)
|
|
34
|
+
{
|
|
35
|
+
tmpSplitChar = '\n';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!tmpFilePath)
|
|
39
|
+
{
|
|
40
|
+
return fCallback(null, {
|
|
41
|
+
EventToFire: 'Error',
|
|
42
|
+
Outputs: {},
|
|
43
|
+
Log: ['ReadFileBuffered: no FilePath specified.']
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Resolve relative paths against the staging folder
|
|
48
|
+
tmpFilePath = this.resolveFilePath(tmpFilePath, pExecutionContext.StagingPath);
|
|
49
|
+
|
|
50
|
+
try
|
|
51
|
+
{
|
|
52
|
+
let tmpStat = libFS.statSync(tmpFilePath);
|
|
53
|
+
let tmpTotalSize = tmpStat.size;
|
|
54
|
+
let tmpRemainingBytes = tmpTotalSize - tmpByteOffset;
|
|
55
|
+
|
|
56
|
+
if (tmpRemainingBytes <= 0)
|
|
57
|
+
{
|
|
58
|
+
return fCallback(null, {
|
|
59
|
+
EventToFire: 'ReadComplete',
|
|
60
|
+
Outputs:
|
|
61
|
+
{
|
|
62
|
+
FileContent: '',
|
|
63
|
+
BytesRead: 0,
|
|
64
|
+
ByteOffset: tmpByteOffset,
|
|
65
|
+
IsComplete: true,
|
|
66
|
+
FileName: libPath.basename(tmpFilePath),
|
|
67
|
+
TotalFileSize: tmpTotalSize
|
|
68
|
+
},
|
|
69
|
+
Log: ['ReadFileBuffered: already at end of file.']
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let tmpReadSize = Math.min(tmpMaxBufferSize, tmpRemainingBytes);
|
|
74
|
+
let tmpBuffer = Buffer.alloc(tmpReadSize);
|
|
75
|
+
let tmpFd = libFS.openSync(tmpFilePath, 'r');
|
|
76
|
+
let tmpActualBytesRead = libFS.readSync(tmpFd, tmpBuffer, 0, tmpReadSize, tmpByteOffset);
|
|
77
|
+
libFS.closeSync(tmpFd);
|
|
78
|
+
|
|
79
|
+
let tmpContent = tmpBuffer.slice(0, tmpActualBytesRead).toString(tmpEncoding);
|
|
80
|
+
let tmpIsComplete = (tmpByteOffset + tmpActualBytesRead) >= tmpTotalSize;
|
|
81
|
+
let tmpNewOffset = tmpByteOffset + tmpActualBytesRead;
|
|
82
|
+
|
|
83
|
+
// If not at EOF and we have a split character, find the last occurrence
|
|
84
|
+
if (!tmpIsComplete && tmpSplitChar && tmpSplitChar.length > 0)
|
|
85
|
+
{
|
|
86
|
+
let tmpLastSplitIndex = tmpContent.lastIndexOf(tmpSplitChar);
|
|
87
|
+
|
|
88
|
+
if (tmpLastSplitIndex > 0)
|
|
89
|
+
{
|
|
90
|
+
// Keep content up to and including the split character
|
|
91
|
+
tmpContent = tmpContent.substring(0, tmpLastSplitIndex + tmpSplitChar.length);
|
|
92
|
+
tmpNewOffset = tmpByteOffset + Buffer.byteLength(tmpContent, tmpEncoding);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let tmpBytesRead = Buffer.byteLength(tmpContent, tmpEncoding);
|
|
97
|
+
|
|
98
|
+
return fCallback(null, {
|
|
99
|
+
EventToFire: 'ReadComplete',
|
|
100
|
+
Outputs:
|
|
101
|
+
{
|
|
102
|
+
FileContent: tmpContent,
|
|
103
|
+
BytesRead: tmpBytesRead,
|
|
104
|
+
ByteOffset: tmpNewOffset,
|
|
105
|
+
IsComplete: tmpIsComplete,
|
|
106
|
+
FileName: libPath.basename(tmpFilePath),
|
|
107
|
+
TotalFileSize: tmpTotalSize
|
|
108
|
+
},
|
|
109
|
+
Log: [`ReadFileBuffered: read ${tmpBytesRead} bytes from offset ${tmpByteOffset} (${tmpIsComplete ? 'complete' : 'more data available'})`]
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
catch (pError)
|
|
113
|
+
{
|
|
114
|
+
return fCallback(null, {
|
|
115
|
+
EventToFire: 'Error',
|
|
116
|
+
Outputs: {},
|
|
117
|
+
Log: [`ReadFileBuffered: failed: ${pError.message}`]
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
module.exports = UltravisorTaskTypeReadFileBuffered;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const libUltravisorTaskType = require('../Ultravisor-TaskType-Base.cjs');
|
|
2
|
+
const libFS = require('fs');
|
|
3
|
+
const libPath = require('path');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Write File task type.
|
|
7
|
+
*
|
|
8
|
+
* Writes content from state to a file on disk. The file path can be
|
|
9
|
+
* absolute or relative to the operation's staging folder.
|
|
10
|
+
*/
|
|
11
|
+
class UltravisorTaskTypeWriteFile extends libUltravisorTaskType
|
|
12
|
+
{
|
|
13
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
14
|
+
{
|
|
15
|
+
super(pFable, pOptions, pServiceHash);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get definition()
|
|
19
|
+
{
|
|
20
|
+
return require('./definitions/write-file.json');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
execute(pResolvedSettings, pExecutionContext, fCallback, fFireIntermediateEvent)
|
|
24
|
+
{
|
|
25
|
+
let tmpFileLocation = pResolvedSettings.FilePath || '';
|
|
26
|
+
let tmpContent = pResolvedSettings.Content;
|
|
27
|
+
let tmpEncoding = pResolvedSettings.Encoding || 'utf8';
|
|
28
|
+
|
|
29
|
+
if (!tmpFileLocation)
|
|
30
|
+
{
|
|
31
|
+
return fCallback(null, {
|
|
32
|
+
EventToFire: 'Error',
|
|
33
|
+
Outputs: {},
|
|
34
|
+
Log: ['WriteFile: no FilePath specified.']
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (tmpContent === undefined || tmpContent === null)
|
|
39
|
+
{
|
|
40
|
+
tmpContent = '';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Ensure content is a string
|
|
44
|
+
if (typeof(tmpContent) !== 'string')
|
|
45
|
+
{
|
|
46
|
+
tmpContent = JSON.stringify(tmpContent, null, '\t');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Apply line ending conversion
|
|
50
|
+
let tmpLineEnding = pResolvedSettings.LineEnding || '';
|
|
51
|
+
if (tmpLineEnding === 'crlf')
|
|
52
|
+
{
|
|
53
|
+
tmpContent = tmpContent.replace(/(?<!\r)\n/g, '\r\n');
|
|
54
|
+
}
|
|
55
|
+
else if (tmpLineEnding === 'lf')
|
|
56
|
+
{
|
|
57
|
+
tmpContent = tmpContent.replace(/\r\n/g, '\n');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Resolve relative paths against the staging folder
|
|
61
|
+
let tmpFilePath = this.resolveFilePath(tmpFileLocation, pExecutionContext.StagingPath);
|
|
62
|
+
|
|
63
|
+
try
|
|
64
|
+
{
|
|
65
|
+
// Ensure the directory exists
|
|
66
|
+
let tmpDir = libPath.dirname(tmpFilePath);
|
|
67
|
+
if (!libFS.existsSync(tmpDir))
|
|
68
|
+
{
|
|
69
|
+
libFS.mkdirSync(tmpDir, { recursive: true });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (pResolvedSettings.Append)
|
|
73
|
+
{
|
|
74
|
+
libFS.appendFileSync(tmpFilePath, tmpContent, tmpEncoding);
|
|
75
|
+
}
|
|
76
|
+
else
|
|
77
|
+
{
|
|
78
|
+
libFS.writeFileSync(tmpFilePath, tmpContent, tmpEncoding);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let tmpBytesWritten = Buffer.byteLength(tmpContent, tmpEncoding);
|
|
82
|
+
|
|
83
|
+
return fCallback(null, {
|
|
84
|
+
EventToFire: 'WriteComplete',
|
|
85
|
+
Outputs:
|
|
86
|
+
{
|
|
87
|
+
FileLocation: tmpFileLocation,
|
|
88
|
+
FileName: libPath.basename(tmpFilePath),
|
|
89
|
+
FilePath: tmpFilePath,
|
|
90
|
+
BytesWritten: tmpBytesWritten
|
|
91
|
+
},
|
|
92
|
+
Log: [`WriteFile: wrote ${tmpBytesWritten} bytes to ${tmpFilePath}`]
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
catch (pError)
|
|
96
|
+
{
|
|
97
|
+
return fCallback(null, {
|
|
98
|
+
EventToFire: 'Error',
|
|
99
|
+
Outputs: {},
|
|
100
|
+
Log: [`WriteFile: failed to write ${tmpFilePath}: ${pError.message}`]
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
module.exports = UltravisorTaskTypeWriteFile;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Hash": "copy-file",
|
|
3
|
+
"Type": "copy-file",
|
|
4
|
+
"Name": "Copy File",
|
|
5
|
+
"Description": "Copies a file from source to target path.",
|
|
6
|
+
"Category": "file-io",
|
|
7
|
+
"Capability": "File System",
|
|
8
|
+
"Action": "Copy",
|
|
9
|
+
"Tier": "Platform",
|
|
10
|
+
"EventInputs": [{ "Name": "Trigger" }],
|
|
11
|
+
"EventOutputs": [
|
|
12
|
+
{ "Name": "Done" },
|
|
13
|
+
{ "Name": "Error", "IsError": true }
|
|
14
|
+
],
|
|
15
|
+
"SettingsInputs": [
|
|
16
|
+
{ "Name": "Source", "DataType": "String", "Required": true, "Description": "Source file path" },
|
|
17
|
+
{ "Name": "TargetFile", "DataType": "String", "Required": true, "Description": "Target file path" },
|
|
18
|
+
{ "Name": "Overwrite", "DataType": "Boolean", "Required": false, "Description": "Allow overwriting existing target file (default true)" }
|
|
19
|
+
],
|
|
20
|
+
"StateOutputs": [
|
|
21
|
+
{ "Name": "FileLocation", "DataType": "String", "Description": "The target path the file was referenced at (may be relative)" },
|
|
22
|
+
{ "Name": "FileName", "DataType": "String", "Description": "The name of the target file only (no directory)" },
|
|
23
|
+
{ "Name": "FilePath", "DataType": "String", "Description": "The fully resolved absolute path of the target file" },
|
|
24
|
+
{ "Name": "BytesCopied", "DataType": "Number", "Description": "Size of the copied file in bytes" }
|
|
25
|
+
],
|
|
26
|
+
"DefaultSettings": { "Source": "", "TargetFile": "", "Overwrite": true }
|
|
27
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Hash": "list-files",
|
|
3
|
+
"Type": "list-files",
|
|
4
|
+
"Name": "List Files",
|
|
5
|
+
"Description": "Lists files in a directory with optional glob pattern filtering.",
|
|
6
|
+
"Category": "file-io",
|
|
7
|
+
"Capability": "File System",
|
|
8
|
+
"Action": "List",
|
|
9
|
+
"Tier": "Platform",
|
|
10
|
+
"EventInputs": [{ "Name": "Trigger" }],
|
|
11
|
+
"EventOutputs": [
|
|
12
|
+
{ "Name": "Complete" },
|
|
13
|
+
{ "Name": "Error", "IsError": true }
|
|
14
|
+
],
|
|
15
|
+
"SettingsInputs": [
|
|
16
|
+
{ "Name": "Folder", "DataType": "String", "Required": true, "Description": "Directory path to list" },
|
|
17
|
+
{ "Name": "Pattern", "DataType": "String", "Required": false, "Description": "Glob-style pattern filter (e.g. *.txt)" },
|
|
18
|
+
{ "Name": "Destination", "DataType": "String", "Required": false, "Description": "State address to store file list" },
|
|
19
|
+
{ "Name": "Recursive", "DataType": "Boolean", "Required": false, "Description": "Recursively list files in subdirectories" },
|
|
20
|
+
{ "Name": "IncludeDirectories", "DataType": "Boolean", "Required": false, "Description": "Include directory entries in results" }
|
|
21
|
+
],
|
|
22
|
+
"StateOutputs": [
|
|
23
|
+
{ "Name": "Files", "DataType": "Array", "Description": "Array of file names" },
|
|
24
|
+
{ "Name": "FileCount", "DataType": "Number", "Description": "Number of entries found" }
|
|
25
|
+
],
|
|
26
|
+
"DefaultSettings": { "Folder": "", "Pattern": "*", "Destination": "", "Recursive": false, "IncludeDirectories": false }
|
|
27
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Hash": "read-file-buffered",
|
|
3
|
+
"Type": "read-file-buffered",
|
|
4
|
+
"Name": "Read File Buffered",
|
|
5
|
+
"Description": "Reads a file in chunks up to a maximum buffer size, splitting on a preferred character boundary.",
|
|
6
|
+
"Category": "file-io",
|
|
7
|
+
"Capability": "File System",
|
|
8
|
+
"Action": "ReadBuffered",
|
|
9
|
+
"Tier": "Platform",
|
|
10
|
+
"EventInputs": [{ "Name": "BeginRead", "Description": "Triggers the buffered file read" }],
|
|
11
|
+
"EventOutputs": [
|
|
12
|
+
{ "Name": "ReadComplete", "Description": "Fires when chunk is read successfully" },
|
|
13
|
+
{ "Name": "Error", "Description": "Fires on read failure", "IsError": true }
|
|
14
|
+
],
|
|
15
|
+
"SettingsInputs": [
|
|
16
|
+
{ "Name": "FilePath", "DataType": "String", "Required": true, "Description": "Path to the file to read" },
|
|
17
|
+
{ "Name": "Encoding", "DataType": "String", "Required": false, "Description": "File encoding" },
|
|
18
|
+
{ "Name": "MaxBufferSize", "DataType": "Number", "Required": false, "Description": "Maximum bytes per chunk" },
|
|
19
|
+
{ "Name": "SplitCharacter", "DataType": "String", "Required": false, "Description": "Preferred character to split on (reads up to last occurrence within buffer)" },
|
|
20
|
+
{ "Name": "ByteOffset", "DataType": "Number", "Required": false, "Description": "Byte offset to start reading from (for continuation)" }
|
|
21
|
+
],
|
|
22
|
+
"StateOutputs": [
|
|
23
|
+
{ "Name": "FileContent", "DataType": "String", "Description": "Content of this chunk" },
|
|
24
|
+
{ "Name": "BytesRead", "DataType": "Number", "Description": "Bytes in this chunk" },
|
|
25
|
+
{ "Name": "ByteOffset", "DataType": "Number", "Description": "Updated byte offset for the next read" },
|
|
26
|
+
{ "Name": "IsComplete", "DataType": "Boolean", "Description": "True when entire file has been read" },
|
|
27
|
+
{ "Name": "FileName", "DataType": "String", "Description": "Base name of the file" },
|
|
28
|
+
{ "Name": "TotalFileSize", "DataType": "Number", "Description": "Total size of the file in bytes" }
|
|
29
|
+
],
|
|
30
|
+
"DefaultSettings": { "FilePath": "", "Encoding": "utf8", "MaxBufferSize": 65536, "SplitCharacter": "\n", "ByteOffset": 0 }
|
|
31
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Hash": "read-file",
|
|
3
|
+
"Type": "read-file",
|
|
4
|
+
"Name": "Read File",
|
|
5
|
+
"Description": "Reads a file from disk into state.",
|
|
6
|
+
"Category": "file-io",
|
|
7
|
+
"Capability": "File System",
|
|
8
|
+
"Action": "Read",
|
|
9
|
+
"Tier": "Platform",
|
|
10
|
+
"EventInputs": [{ "Name": "BeginRead", "Description": "Triggers the file read" }],
|
|
11
|
+
"EventOutputs": [
|
|
12
|
+
{ "Name": "ReadComplete", "Description": "Fires when file is read successfully" },
|
|
13
|
+
{ "Name": "Error", "Description": "Fires on read failure", "IsError": true }
|
|
14
|
+
],
|
|
15
|
+
"SettingsInputs": [
|
|
16
|
+
{ "Name": "FilePath", "DataType": "String", "Required": true, "Description": "Path to the file to read" },
|
|
17
|
+
{ "Name": "Encoding", "DataType": "String", "Required": false, "Default": "utf8", "Description": "File encoding" },
|
|
18
|
+
{ "Name": "MaxBytes", "DataType": "Number", "Required": false, "Description": "Maximum bytes to read (0 = unlimited)" }
|
|
19
|
+
],
|
|
20
|
+
"StateOutputs": [
|
|
21
|
+
{ "Name": "FileContent", "DataType": "String", "Description": "Contents of the file" },
|
|
22
|
+
{ "Name": "BytesRead", "DataType": "Number", "Description": "Number of bytes read" },
|
|
23
|
+
{ "Name": "FileName", "DataType": "String", "Description": "Base name of the file" }
|
|
24
|
+
],
|
|
25
|
+
"DefaultSettings": { "FilePath": "", "Encoding": "utf8", "MaxBytes": 0 }
|
|
26
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Hash": "read-json",
|
|
3
|
+
"Type": "read-json",
|
|
4
|
+
"Name": "Read JSON",
|
|
5
|
+
"Description": "Reads a JSON file from disk and parses it into state.",
|
|
6
|
+
"Category": "file-io",
|
|
7
|
+
"Capability": "File System",
|
|
8
|
+
"Action": "ReadJSON",
|
|
9
|
+
"Tier": "Platform",
|
|
10
|
+
"EventInputs": [{ "Name": "Trigger" }],
|
|
11
|
+
"EventOutputs": [
|
|
12
|
+
{ "Name": "Complete" },
|
|
13
|
+
{ "Name": "Error", "IsError": true }
|
|
14
|
+
],
|
|
15
|
+
"SettingsInputs": [
|
|
16
|
+
{ "Name": "FilePath", "DataType": "String", "Required": true, "Description": "Path to the JSON file" },
|
|
17
|
+
{ "Name": "Destination", "DataType": "String", "Required": false, "Description": "State address to store the parsed data" }
|
|
18
|
+
],
|
|
19
|
+
"StateOutputs": [
|
|
20
|
+
{ "Name": "Data", "DataType": "Object", "Description": "Parsed JSON data" }
|
|
21
|
+
],
|
|
22
|
+
"DefaultSettings": { "FilePath": "", "Destination": "" }
|
|
23
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Hash": "write-file",
|
|
3
|
+
"Type": "write-file",
|
|
4
|
+
"Name": "Write File",
|
|
5
|
+
"Description": "Writes content to a file on disk.",
|
|
6
|
+
"Category": "file-io",
|
|
7
|
+
"Capability": "File System",
|
|
8
|
+
"Action": "Write",
|
|
9
|
+
"Tier": "Platform",
|
|
10
|
+
"EventInputs": [{ "Name": "BeginWrite", "Description": "Triggers the file write" }],
|
|
11
|
+
"EventOutputs": [
|
|
12
|
+
{ "Name": "WriteComplete", "Description": "Fires when file is written successfully" },
|
|
13
|
+
{ "Name": "Error", "Description": "Fires on write failure", "IsError": true }
|
|
14
|
+
],
|
|
15
|
+
"SettingsInputs": [
|
|
16
|
+
{ "Name": "FilePath", "DataType": "String", "Required": true, "Description": "Path to the output file" },
|
|
17
|
+
{ "Name": "Content", "DataType": "String", "Required": true, "Description": "Content to write" },
|
|
18
|
+
{ "Name": "Encoding", "DataType": "String", "Required": false, "Default": "utf8", "Description": "File encoding" },
|
|
19
|
+
{ "Name": "Append", "DataType": "Boolean", "Required": false, "Description": "Append to existing file instead of overwriting" },
|
|
20
|
+
{ "Name": "LineEnding", "DataType": "String", "Required": false, "Description": "Force line ending style: \"lf\", \"crlf\", or empty for no conversion" }
|
|
21
|
+
],
|
|
22
|
+
"StateOutputs": [
|
|
23
|
+
{ "Name": "FileLocation", "DataType": "String", "Description": "The path the file was referenced at (may be relative)" },
|
|
24
|
+
{ "Name": "FileName", "DataType": "String", "Description": "The name of the file only (no directory)" },
|
|
25
|
+
{ "Name": "FilePath", "DataType": "String", "Description": "The fully resolved absolute path of the file" },
|
|
26
|
+
{ "Name": "BytesWritten", "DataType": "Number", "Description": "Number of bytes written" }
|
|
27
|
+
],
|
|
28
|
+
"DefaultSettings": { "FilePath": "", "Content": "", "Encoding": "utf8", "Append": false, "LineEnding": "" }
|
|
29
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Hash": "write-json",
|
|
3
|
+
"Type": "write-json",
|
|
4
|
+
"Name": "Write JSON",
|
|
5
|
+
"Description": "Writes a JSON object to a file on disk.",
|
|
6
|
+
"Category": "file-io",
|
|
7
|
+
"Capability": "File System",
|
|
8
|
+
"Action": "WriteJSON",
|
|
9
|
+
"Tier": "Platform",
|
|
10
|
+
"EventInputs": [{ "Name": "Trigger" }],
|
|
11
|
+
"EventOutputs": [
|
|
12
|
+
{ "Name": "Done" },
|
|
13
|
+
{ "Name": "Error", "IsError": true }
|
|
14
|
+
],
|
|
15
|
+
"SettingsInputs": [
|
|
16
|
+
{ "Name": "FilePath", "DataType": "String", "Required": true, "Description": "Path to the output JSON file" },
|
|
17
|
+
{ "Name": "DataAddress", "DataType": "String", "Required": false, "Description": "State address of the data to write" },
|
|
18
|
+
{ "Name": "PrettyFormat", "DataType": "Boolean", "Required": false, "Description": "Pretty-print with indentation (default true)" },
|
|
19
|
+
{ "Name": "IndentType", "DataType": "String", "Required": false, "Description": "Indent character: \"tab\" or \"space\" (default \"tab\")" },
|
|
20
|
+
{ "Name": "IndentCount", "DataType": "Number", "Required": false, "Description": "Number of indent characters per level (default 1)" },
|
|
21
|
+
{ "Name": "SortKeys", "DataType": "Boolean", "Required": false, "Description": "Alphabetically sort object keys" }
|
|
22
|
+
],
|
|
23
|
+
"StateOutputs": [
|
|
24
|
+
{ "Name": "FileLocation", "DataType": "String", "Description": "The path the file was referenced at (may be relative)" },
|
|
25
|
+
{ "Name": "FileName", "DataType": "String", "Description": "The name of the file only (no directory)" },
|
|
26
|
+
{ "Name": "FilePath", "DataType": "String", "Description": "The fully resolved absolute path of the file" },
|
|
27
|
+
{ "Name": "BytesWritten", "DataType": "Number", "Description": "Number of bytes written" }
|
|
28
|
+
],
|
|
29
|
+
"DefaultSettings": { "FilePath": "", "DataAddress": "", "PrettyFormat": true, "IndentType": "tab", "IndentCount": 1, "SortKeys": false }
|
|
30
|
+
}
|