orator-conversion 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/debug/Harness.js +86 -1
- package/package.json +8 -6
- package/source/Conversion-Core.js +939 -0
- package/source/Orator-Conversion-BeaconProvider.js +852 -0
- package/source/Orator-File-Translation.js +154 -0
- package/source/endpoints/Endpoint-Image-Convert.js +33 -0
- package/source/endpoints/Endpoint-Image-Resize.js +49 -0
- package/source/endpoints/Endpoint-Image-Rotate.js +34 -0
- package/test/Conversion-Core_tests.js +442 -0
- package/test/Orator-File-Translation_basic_tests.js +10 -4
- package/test/Orator-File-Translation_tests.js +148 -0
package/debug/Harness.js
CHANGED
|
@@ -1,10 +1,48 @@
|
|
|
1
1
|
const libFable = require('fable');
|
|
2
|
+
const libPath = require('path');
|
|
3
|
+
|
|
4
|
+
// Parse command-line flags before creating Fable so LogStreams can be set
|
|
5
|
+
let tmpUltravisorURL = null;
|
|
6
|
+
let tmpLogFilePath = null;
|
|
7
|
+
for (let i = 2; i < process.argv.length; i++)
|
|
8
|
+
{
|
|
9
|
+
if ((process.argv[i] === '--ultravisor' || process.argv[i] === '-u'))
|
|
10
|
+
{
|
|
11
|
+
if (process.argv[i + 1] && !process.argv[i + 1].startsWith('-'))
|
|
12
|
+
{
|
|
13
|
+
tmpUltravisorURL = process.argv[++i];
|
|
14
|
+
}
|
|
15
|
+
else
|
|
16
|
+
{
|
|
17
|
+
tmpUltravisorURL = 'http://localhost:54321';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (process.argv[i] === '--logfile' || process.argv[i] === '-l')
|
|
21
|
+
{
|
|
22
|
+
if (process.argv[i + 1] && !process.argv[i + 1].startsWith('-'))
|
|
23
|
+
{
|
|
24
|
+
tmpLogFilePath = libPath.resolve(process.argv[++i]);
|
|
25
|
+
}
|
|
26
|
+
else
|
|
27
|
+
{
|
|
28
|
+
tmpLogFilePath = libPath.resolve(`orator-conversion-${new Date().toISOString().replace(/[:.]/g, '-')}.log`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let tmpLogStreams = [{ level: 'trace', streamtype: 'process.stdout' }];
|
|
34
|
+
if (tmpLogFilePath)
|
|
35
|
+
{
|
|
36
|
+
tmpLogStreams.push({ loggertype: 'simpleflatfile', level: 'trace', path: tmpLogFilePath });
|
|
37
|
+
console.log(`[Orator-Conversion] Logging to file: ${tmpLogFilePath}`);
|
|
38
|
+
}
|
|
2
39
|
|
|
3
40
|
const defaultFableSettings = (
|
|
4
41
|
{
|
|
5
42
|
Product: 'Orator-FileTranslation',
|
|
6
43
|
ProductVersion: '1.0.0',
|
|
7
|
-
APIServerPort: 8765
|
|
44
|
+
APIServerPort: 8765,
|
|
45
|
+
LogStreams: tmpLogStreams
|
|
8
46
|
});
|
|
9
47
|
|
|
10
48
|
let _Fable = new libFable(defaultFableSettings);
|
|
@@ -32,6 +70,30 @@ tmpAnticipate.anticipate(
|
|
|
32
70
|
|
|
33
71
|
tmpAnticipate.anticipate(_Orator.startService.bind(_Orator));
|
|
34
72
|
|
|
73
|
+
// If an Ultravisor URL was provided, connect as a beacon
|
|
74
|
+
if (tmpUltravisorURL)
|
|
75
|
+
{
|
|
76
|
+
tmpAnticipate.anticipate(
|
|
77
|
+
(fNext) =>
|
|
78
|
+
{
|
|
79
|
+
_Fable.OratorFileTranslation.connectBeacon(
|
|
80
|
+
{
|
|
81
|
+
ServerURL: tmpUltravisorURL,
|
|
82
|
+
Name: 'orator-conversion',
|
|
83
|
+
BindAddresses: [{ IP: '127.0.0.1', Port: 8765, Protocol: 'http' }]
|
|
84
|
+
},
|
|
85
|
+
(pError) =>
|
|
86
|
+
{
|
|
87
|
+
if (pError)
|
|
88
|
+
{
|
|
89
|
+
_Fable.log.warn(`Beacon connection failed (server may not be running): ${pError.message}`);
|
|
90
|
+
_Fable.log.warn('HTTP endpoints are still available. Beacon will not be active.');
|
|
91
|
+
}
|
|
92
|
+
return fNext();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
35
97
|
tmpAnticipate.wait(
|
|
36
98
|
(pError) =>
|
|
37
99
|
{
|
|
@@ -45,4 +107,27 @@ tmpAnticipate.wait(
|
|
|
45
107
|
_Fable.log.info(' POST http://127.0.0.1:8765/conversion/1.0/image/png-to-jpg');
|
|
46
108
|
_Fable.log.info(' POST http://127.0.0.1:8765/conversion/1.0/pdf-to-page-png/:Page');
|
|
47
109
|
_Fable.log.info(' POST http://127.0.0.1:8765/conversion/1.0/pdf-to-page-jpg/:Page');
|
|
110
|
+
|
|
111
|
+
if (tmpUltravisorURL)
|
|
112
|
+
{
|
|
113
|
+
_Fable.log.info('');
|
|
114
|
+
_Fable.log.info(`Beacon: connected to Ultravisor at ${tmpUltravisorURL}`);
|
|
115
|
+
}
|
|
48
116
|
});
|
|
117
|
+
|
|
118
|
+
// Graceful shutdown
|
|
119
|
+
process.on('SIGINT', () =>
|
|
120
|
+
{
|
|
121
|
+
console.log('\n[Orator-Conversion] Shutting down...');
|
|
122
|
+
if (_Fable.OratorFileTranslation._BeaconService)
|
|
123
|
+
{
|
|
124
|
+
_Fable.OratorFileTranslation.disconnectBeacon(() =>
|
|
125
|
+
{
|
|
126
|
+
process.exit(0);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
else
|
|
130
|
+
{
|
|
131
|
+
process.exit(0);
|
|
132
|
+
}
|
|
133
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orator-conversion",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "File format conversion endpoints for Orator service servers.",
|
|
5
5
|
"main": "source/Orator-File-Translation.js",
|
|
6
6
|
"scripts": {
|
|
@@ -42,12 +42,14 @@
|
|
|
42
42
|
"homepage": "https://github.com/stevenvelozo/orator-conversion#readme",
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"fable-serviceproviderbase": "^3.0.19",
|
|
45
|
-
"sharp": "^0.34.5"
|
|
45
|
+
"sharp": "^0.34.5",
|
|
46
|
+
"ultravisor-beacon": "^0.0.3",
|
|
47
|
+
"ws": "^8.20.0"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
48
|
-
"fable": "^3.1.
|
|
49
|
-
"orator": "^6.0.
|
|
50
|
-
"orator-serviceserver-restify": "^2.0.
|
|
51
|
-
"quackage": "^1.0.
|
|
50
|
+
"fable": "^3.1.67",
|
|
51
|
+
"orator": "^6.0.4",
|
|
52
|
+
"orator-serviceserver-restify": "^2.0.9",
|
|
53
|
+
"quackage": "^1.0.65"
|
|
52
54
|
}
|
|
53
55
|
}
|