ultravisor 1.0.0 → 1.0.2

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.
Files changed (96) hide show
  1. package/.babelrc +6 -0
  2. package/.browserslistrc +1 -0
  3. package/.browserslistrc-BACKUP +1 -0
  4. package/.gulpfile-quackage-config.json +7 -0
  5. package/.gulpfile-quackage.js +2 -0
  6. package/CONTRIBUTING.md +50 -0
  7. package/README.md +34 -0
  8. package/debug/Harness.js +2 -1
  9. package/docs/.nojekyll +0 -0
  10. package/docs/_sidebar.md +18 -0
  11. package/docs/_topbar.md +7 -0
  12. package/docs/architecture.md +103 -0
  13. package/docs/cover.md +15 -0
  14. package/docs/features/api.md +230 -0
  15. package/docs/features/cli.md +182 -0
  16. package/docs/features/configuration.md +245 -0
  17. package/docs/features/manifests.md +177 -0
  18. package/docs/features/operations.md +292 -0
  19. package/docs/features/scheduling.md +179 -0
  20. package/docs/features/tasks.md +1857 -0
  21. package/docs/index.html +39 -0
  22. package/docs/overview.md +75 -0
  23. package/docs/quickstart.md +167 -0
  24. package/docs/retold-catalog.json +24 -0
  25. package/docs/retold-keyword-index.json +19 -0
  26. package/package.json +5 -2
  27. package/source/Ultravisor.cjs +2 -2
  28. package/source/cli/Ultravisor-CLIProgram.cjs +38 -0
  29. package/source/cli/commands/Ultravisor-Command-ScheduleOperation.cjs +26 -2
  30. package/source/cli/commands/Ultravisor-Command-ScheduleTask.cjs +26 -2
  31. package/source/cli/commands/Ultravisor-Command-ScheduleView.cjs +22 -0
  32. package/source/cli/commands/Ultravisor-Command-SingleOperation.cjs +49 -1
  33. package/source/cli/commands/Ultravisor-Command-SingleTask.cjs +51 -1
  34. package/source/cli/commands/Ultravisor-Command-Stop.cjs +4 -0
  35. package/source/cli/commands/Ultravisor-Command-UpdateTask.cjs +91 -0
  36. package/source/config/Ultravisor-Default-Command-Configuration.cjs +6 -1
  37. package/source/services/Ultravisor-Hypervisor-Event-Base.cjs +18 -1
  38. package/source/services/Ultravisor-Hypervisor-State.cjs +213 -0
  39. package/source/services/Ultravisor-Hypervisor.cjs +225 -1
  40. package/source/services/Ultravisor-Operation-Manifest.cjs +150 -1
  41. package/source/services/Ultravisor-Operation.cjs +190 -1
  42. package/source/services/Ultravisor-Task.cjs +339 -1
  43. package/source/services/events/Ultravisor-Hypervisor-Event-Cron.cjs +71 -1
  44. package/source/services/tasks/Ultravisor-Task-Base.cjs +264 -0
  45. package/source/services/tasks/Ultravisor-Task-CollectValues.cjs +188 -0
  46. package/source/services/tasks/Ultravisor-Task-Command.cjs +65 -0
  47. package/source/services/tasks/Ultravisor-Task-CommandEach.cjs +190 -0
  48. package/source/services/tasks/Ultravisor-Task-Conditional.cjs +104 -0
  49. package/source/services/tasks/Ultravisor-Task-DateWindow.cjs +72 -0
  50. package/source/services/tasks/Ultravisor-Task-GeneratePagedOperation.cjs +336 -0
  51. package/source/services/tasks/Ultravisor-Task-LaunchOperation.cjs +143 -0
  52. package/source/services/tasks/Ultravisor-Task-LaunchTask.cjs +146 -0
  53. package/source/services/tasks/Ultravisor-Task-LineMatch.cjs +158 -0
  54. package/source/services/tasks/Ultravisor-Task-Request.cjs +56 -0
  55. package/source/services/tasks/Ultravisor-Task-Solver.cjs +89 -0
  56. package/source/services/tasks/Ultravisor-Task-TemplateString.cjs +93 -0
  57. package/source/services/tasks/rest/Ultravisor-Task-GetBinary.cjs +127 -0
  58. package/source/services/tasks/rest/Ultravisor-Task-GetJSON.cjs +119 -0
  59. package/source/services/tasks/rest/Ultravisor-Task-GetText.cjs +109 -0
  60. package/source/services/tasks/rest/Ultravisor-Task-GetXML.cjs +112 -0
  61. package/source/services/tasks/rest/Ultravisor-Task-RestRequest.cjs +499 -0
  62. package/source/services/tasks/rest/Ultravisor-Task-SendJSON.cjs +150 -0
  63. package/source/services/tasks/stagingfiles/Ultravisor-Task-CopyFile.cjs +110 -0
  64. package/source/services/tasks/stagingfiles/Ultravisor-Task-ListFiles.cjs +89 -0
  65. package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadBinary.cjs +87 -0
  66. package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadJSON.cjs +67 -0
  67. package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadText.cjs +66 -0
  68. package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadXML.cjs +69 -0
  69. package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteBinary.cjs +95 -0
  70. package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteJSON.cjs +96 -0
  71. package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteText.cjs +99 -0
  72. package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteXML.cjs +102 -0
  73. package/source/web_server/Ultravisor-API-Server.cjs +463 -3
  74. package/test/Ultravisor_tests.js +6097 -1
  75. package/webinterface/.babelrc +6 -0
  76. package/webinterface/.browserslistrc +1 -0
  77. package/webinterface/.browserslistrc-BACKUP +1 -0
  78. package/webinterface/.gulpfile-quackage-config.json +7 -0
  79. package/webinterface/.gulpfile-quackage.js +2 -0
  80. package/webinterface/css/ultravisor.css +121 -0
  81. package/webinterface/html/index.html +32 -0
  82. package/webinterface/package.json +39 -0
  83. package/webinterface/source/Pict-Application-Ultravisor-Configuration.json +15 -0
  84. package/webinterface/source/Pict-Application-Ultravisor.js +414 -0
  85. package/webinterface/source/providers/PictRouter-Ultravisor-Configuration.json +42 -0
  86. package/webinterface/source/views/PictView-Ultravisor-BottomBar.js +65 -0
  87. package/webinterface/source/views/PictView-Ultravisor-Dashboard.js +236 -0
  88. package/webinterface/source/views/PictView-Ultravisor-Layout.js +83 -0
  89. package/webinterface/source/views/PictView-Ultravisor-ManifestList.js +273 -0
  90. package/webinterface/source/views/PictView-Ultravisor-OperationEdit.js +243 -0
  91. package/webinterface/source/views/PictView-Ultravisor-OperationList.js +141 -0
  92. package/webinterface/source/views/PictView-Ultravisor-Schedule.js +280 -0
  93. package/webinterface/source/views/PictView-Ultravisor-TaskEdit.js +220 -0
  94. package/webinterface/source/views/PictView-Ultravisor-TaskList.js +248 -0
  95. package/webinterface/source/views/PictView-Ultravisor-TimingView.js +420 -0
  96. package/webinterface/source/views/PictView-Ultravisor-TopBar.js +147 -0
@@ -0,0 +1,127 @@
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;
@@ -0,0 +1,119 @@
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;
@@ -0,0 +1,109 @@
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;
@@ -0,0 +1,112 @@
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;