biz-a-cli 2.3.4 → 2.3.6
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/bin/hub.js +2 -2
- package/bin/watcher.js +3 -2
- package/callbackController.js +7 -4
- package/package.json +2 -2
- package/scheduler/converter.js +1 -1
- package/scheduler/datalib.js +15 -20
- package/scheduler/watcherController.js +3 -3
- package/tests/converter.test.js +4 -4
- package/tests/data.test.js +2 -2
- package/tests/watcherCtl.test.js +3 -3
package/bin/hub.js
CHANGED
|
@@ -4,6 +4,7 @@ import yargs from 'yargs';
|
|
|
4
4
|
import { io as ioc } from "socket.io-client";
|
|
5
5
|
import hubEvent from './hubEvent.js'
|
|
6
6
|
|
|
7
|
+
const port = 3002;
|
|
7
8
|
const argv = yargs(process.argv.slice(2))
|
|
8
9
|
.usage('Usage: $0 [options]')
|
|
9
10
|
.options('s', {
|
|
@@ -42,7 +43,7 @@ const argv = yargs(process.argv.slice(2))
|
|
|
42
43
|
})
|
|
43
44
|
.options('sp', {
|
|
44
45
|
alias: 'serverport',
|
|
45
|
-
default:
|
|
46
|
+
default: port,
|
|
46
47
|
describe: 'Express Port (Callback Feature)',
|
|
47
48
|
type: 'number',
|
|
48
49
|
demandOption: false
|
|
@@ -77,7 +78,6 @@ app.use(express.json());
|
|
|
77
78
|
app.set('args', argv);
|
|
78
79
|
|
|
79
80
|
app.use('/cb', runCliScript);
|
|
80
|
-
const port = 3002;
|
|
81
81
|
|
|
82
82
|
app.listen((argv.serverport || port), () => {
|
|
83
83
|
console.log(`Biz-A is listening at ${process.env.HOST || 'http://localhost'}:${argv.serverport || port} `);
|
package/bin/watcher.js
CHANGED
|
@@ -15,6 +15,8 @@ process.on('unhandledRejection', (err) => { //debug
|
|
|
15
15
|
console.log('Unhandled Rejection:', err);
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
+
const port = 3001;
|
|
19
|
+
|
|
18
20
|
const options = yargs(process.argv.slice(2))
|
|
19
21
|
.option('c', {
|
|
20
22
|
alias: 'company',
|
|
@@ -24,6 +26,7 @@ const options = yargs(process.argv.slice(2))
|
|
|
24
26
|
})
|
|
25
27
|
.option('p', {
|
|
26
28
|
alias: 'port',
|
|
29
|
+
default: port,
|
|
27
30
|
describe: 'Port to use',
|
|
28
31
|
type: 'string',
|
|
29
32
|
demandOption: false
|
|
@@ -40,8 +43,6 @@ const options = yargs(process.argv.slice(2))
|
|
|
40
43
|
app.use(cors());
|
|
41
44
|
timer.runScheduler(options.company);
|
|
42
45
|
|
|
43
|
-
const port = 3001;
|
|
44
|
-
|
|
45
46
|
app.listen((options.port || port), () => {
|
|
46
47
|
console.log(`Biz-A CLI is listening at ${process.env.HOST || 'http://localhost'}:${options.port || port} `);
|
|
47
48
|
});
|
package/callbackController.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { loadCliScript, extractFunctionScript } from "./scheduler/datalib.js";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
export function getInputScript(req) {
|
|
4
|
+
export function getInputScript(req) {
|
|
5
5
|
const args = req.app.settings.args;
|
|
6
6
|
return {
|
|
7
7
|
data: {
|
|
@@ -22,9 +22,12 @@ export async function runCliScript(req, res) {
|
|
|
22
22
|
loadCliScript(selectedConfig, req.body.query).subscribe({
|
|
23
23
|
next: script => {
|
|
24
24
|
let functions = extractFunctionScript(script);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
if (functions) {
|
|
26
|
+
res.send(functions.onInit(data));
|
|
27
|
+
console.log(`Run Callback Successfully!`);
|
|
28
|
+
} else {
|
|
29
|
+
res.send('CLI Script does not exist.');
|
|
30
|
+
}
|
|
28
31
|
},
|
|
29
32
|
error: error => {
|
|
30
33
|
console.error(error);
|
package/package.json
CHANGED
package/scheduler/converter.js
CHANGED
|
@@ -26,7 +26,7 @@ function addTimer(timer, timerData) {
|
|
|
26
26
|
timezone: timer.timezone,
|
|
27
27
|
templateName: timer.templateName,
|
|
28
28
|
seq: parseInt(timer.seq),
|
|
29
|
-
|
|
29
|
+
scriptid: parseInt(timer.scriptid),
|
|
30
30
|
script: (timer.cli_script) ? JSON.stringify(timer.cli_script) : ''
|
|
31
31
|
};
|
|
32
32
|
if ((timer.daily_days)) {
|
package/scheduler/datalib.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { map,
|
|
1
|
+
import { map, tap } from "rxjs";
|
|
2
2
|
import { Axios } from 'axios-observable';
|
|
3
3
|
import { insertHistory } from "./watcherController.js";
|
|
4
4
|
|
|
@@ -134,11 +134,7 @@ export function extractFunctionScript(data) {
|
|
|
134
134
|
return
|
|
135
135
|
}
|
|
136
136
|
if (data.length == 0) return
|
|
137
|
-
|
|
138
|
-
let hex = JSON.parse(hex2a(data[0].template))
|
|
139
|
-
//sementara ke template dahulu
|
|
140
|
-
// let hex = JSON.parse(hex2a(data[0].script))
|
|
141
|
-
|
|
137
|
+
let hex = JSON.parse(hex2a(data[0].script))
|
|
142
138
|
if (!hex.functions) return
|
|
143
139
|
return JSON.parse(JSON.stringify(hex.functions), deserialise)
|
|
144
140
|
}
|
|
@@ -146,13 +142,8 @@ export function extractFunctionScript(data) {
|
|
|
146
142
|
export function getQueryDataObsParameters(trigger) {
|
|
147
143
|
return {
|
|
148
144
|
length: 1,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
columns: [{ data: "TEMPLATE.TEMPLATE", key: 'template' }]
|
|
152
|
-
|
|
153
|
-
//sementara ke template dahulu
|
|
154
|
-
// filter: [{ junction: '', column: 'ID', operator: '=', value1: `${trigger.scriptId}` }],
|
|
155
|
-
// columns: [{ data: "SYS$CLI_SCRIPT.SCRIPT", key: 'script' }]
|
|
145
|
+
filter: [{ junction: '', column: 'ID', operator: '=', value1: `${trigger.scriptid}` }],
|
|
146
|
+
columns: [{ data: "SYS$CLI_SCRIPT.SCRIPT", key: 'script' }]
|
|
156
147
|
}
|
|
157
148
|
}
|
|
158
149
|
|
|
@@ -190,15 +181,19 @@ export function getInputData(config, trigger) {
|
|
|
190
181
|
export function scheduleSubscription(config, data, trigger, needSetHistory, isTest = false) {
|
|
191
182
|
try {
|
|
192
183
|
let functions = extractFunctionScript(data);
|
|
193
|
-
if (
|
|
194
|
-
|
|
195
|
-
|
|
184
|
+
if (functions) {
|
|
185
|
+
if (!isTest) { // next, change isTest to test better
|
|
186
|
+
functions.onInit(getInputData(config, trigger));
|
|
187
|
+
}
|
|
196
188
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
189
|
+
if (needSetHistory) {
|
|
190
|
+
insertHistory(config, trigger._id, new Date());
|
|
191
|
+
console.log(`Run Recent Schedule : ${trigger.name}`);
|
|
192
|
+
} else {
|
|
193
|
+
console.log(`Run Schedule : ${trigger.name}`);
|
|
194
|
+
}
|
|
200
195
|
} else {
|
|
201
|
-
console.log(`
|
|
196
|
+
console.log(`CLI Script does not exist : ${trigger.name}`);
|
|
202
197
|
}
|
|
203
198
|
} catch (error) {
|
|
204
199
|
console.error(error);
|
|
@@ -15,9 +15,9 @@ export function getWatcherParameters(watcherFilter) {
|
|
|
15
15
|
{ data: "SYS$WATCHER.ID.WATCHER_ID.SYS$TIMER.NAME", key: 'name' },
|
|
16
16
|
{ data: "SYS$WATCHER.ID.WATCHER_ID.SYS$TIMER.ACTIVE", key: 'active' },
|
|
17
17
|
{ data: "SYS$WATCHER.ID.WATCHER_ID.SYS$TIMER.TIME_ZONE", key: 'timezone' },
|
|
18
|
-
{ data: "SYS$WATCHER.ID.WATCHER_ID.SYS$TIMER.SCRIPT_NAME", key: 'templateName' },
|
|
18
|
+
// { data: "SYS$WATCHER.ID.WATCHER_ID.SYS$TIMER.SCRIPT_NAME", key: 'templateName' },
|
|
19
19
|
{ data: "SYS$WATCHER.ID.WATCHER_ID.SYS$TIMER.SEQ", key: 'seq' },
|
|
20
|
-
{ data: "SYS$WATCHER.ID.WATCHER_ID.SYS$TIMER.SCRIPT_ID", key: '
|
|
20
|
+
{ data: "SYS$WATCHER.ID.WATCHER_ID.SYS$TIMER.SCRIPT_ID", key: 'scriptid' },
|
|
21
21
|
{ data: "SYS$TIMER.ID.TIMER_ID.SYS$DAILY.DAYS", key: 'daily_days' },
|
|
22
22
|
{ data: "SYS$TIMER.ID.TIMER_ID.SYS$WEEKLY.ORDINAL", key: 'weekly_ordinal' },
|
|
23
23
|
{ data: "SYS$TIMER.ID.TIMER_ID.SYS$WEEKLY.DAYS", key: 'weekly_days' },
|
|
@@ -47,7 +47,7 @@ export function getInsertHistoryParameters(timerObjectId) {
|
|
|
47
47
|
value1: `'${timerObjectId}'`
|
|
48
48
|
}],
|
|
49
49
|
columns: [
|
|
50
|
-
{ data: "HISTORY.ID", key: 'history_id' },
|
|
50
|
+
{ data: "SYS$HISTORY.ID", key: 'history_id' },
|
|
51
51
|
]
|
|
52
52
|
}
|
|
53
53
|
}
|
package/tests/converter.test.js
CHANGED
|
@@ -36,7 +36,7 @@ describe('converter test', () => {
|
|
|
36
36
|
minutely_time_from: '08:00',
|
|
37
37
|
minutely_time_to: '22:00',
|
|
38
38
|
hourly_hours: '',
|
|
39
|
-
|
|
39
|
+
scriptid: 1,
|
|
40
40
|
cli_script: 'abc'
|
|
41
41
|
}, {
|
|
42
42
|
watcher_id: 1,
|
|
@@ -56,7 +56,7 @@ describe('converter test', () => {
|
|
|
56
56
|
minutely_time_from: '',
|
|
57
57
|
minutely_time_to: '',
|
|
58
58
|
hourly_hours: '12:00,13:00',
|
|
59
|
-
|
|
59
|
+
scriptid: 2,
|
|
60
60
|
cli_script: 'def'
|
|
61
61
|
}]
|
|
62
62
|
|
|
@@ -77,7 +77,7 @@ describe('converter test', () => {
|
|
|
77
77
|
from: '08:00',
|
|
78
78
|
to: '22:00'
|
|
79
79
|
},
|
|
80
|
-
|
|
80
|
+
scriptid: 1,
|
|
81
81
|
script: '"abc"'
|
|
82
82
|
}, {
|
|
83
83
|
_id: 2,
|
|
@@ -89,7 +89,7 @@ describe('converter test', () => {
|
|
|
89
89
|
seq: 1,
|
|
90
90
|
monthly: [2, 3],
|
|
91
91
|
hourly: ['12:00', '13:00'],
|
|
92
|
-
|
|
92
|
+
scriptid: 2,
|
|
93
93
|
script: '"def"'
|
|
94
94
|
|
|
95
95
|
}]
|
package/tests/data.test.js
CHANGED
|
@@ -27,7 +27,7 @@ describe('data test', () => {
|
|
|
27
27
|
dbindex: 2,
|
|
28
28
|
subdomain: 'abc'
|
|
29
29
|
}
|
|
30
|
-
const data = [{
|
|
30
|
+
const data = [{ script: '7b2266756e6374696f6e73223a7b226f6e496e6974223a5b2277696e646f772e46756e6374696f6e222c5b22636f6e666967222c222064617461225d2c5b2220202020202020202020202020202020636f6e737420646f6974203d206173796e63202829203d3e207b222c222020202020202020202020202020202020202020636f6e7374207b20746170207d203d20617761697420696d706f7274282772786a732729222c222020202020202020202020202020202020202020636f6e7374207b20717565727944617461207d203d20617761697420696d706f727428272e2f646174616c69622e6a732729222c222020202020202020202020202020202020202020636f6e737420706172616d203d207b222c222020202020202020202020202020202020202020202020206c656e6774683a2031302c222c22202020202020202020202020202020202020202020202020636f6c756d6e733a205b222c22202020202020202020202020202020202020202020202020202020207b20646174613a202755534552532e555345524944272c206b65793a202775736572696427207d222c222020202020202020202020202020202020202020202020205d2c222c222020202020202020202020202020202020202020202020206462496e6465783a2031222c2220202020202020202020202020202020202020207d222c22202020202020202020202020202020202020202071756572794461746128706172616d2c20636f6e6669672c2074727565292e7069706528222c2220202020202020202020202020202020202020202020202074617028726573203d3e20636f6e736f6c652e6c6f672872657329292c222c222020202020202020202020202020202020202020292e73756273637269626528726573203d3e207b222c22202020202020202020202020202020202020202020202020636f6e736f6c652e6c6f67287265732c20277375627363726962652729222c2220202020202020202020202020202020202020207d29222c22202020202020202020202020202020207d222c2220202020202020202020202020202020646f69742829222c222020202020202020202020202020202072657475726e20276f6b20646172692063656b55736572273b225d5d7d7d' }]
|
|
31
31
|
const trigger = {
|
|
32
32
|
_id: 1,
|
|
33
33
|
name: 'New Watcher 1',
|
|
@@ -45,7 +45,7 @@ describe('data test', () => {
|
|
|
45
45
|
subdomain: 'abc'
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
const data = [{
|
|
48
|
+
const data = [{ script: '7b2266756e6374696f6e73223a7b226f6e496e6974223a5b2277696e646f772e46756e6374696f6e222c5b22636f6e666967222c222064617461225d2c5b2220202020202020202020202020202020636f6e737420646f6974203d206173796e63202829203d3e207b222c222020202020202020202020202020202020202020636f6e7374207b20746170207d203d20617761697420696d706f7274282772786a732729222c222020202020202020202020202020202020202020636f6e7374207b20717565727944617461207d203d20617761697420696d706f727428272e2f646174616c69622e6a732729222c222020202020202020202020202020202020202020636f6e737420706172616d203d207b222c222020202020202020202020202020202020202020202020206c656e6774683a2031302c222c22202020202020202020202020202020202020202020202020636f6c756d6e733a205b222c22202020202020202020202020202020202020202020202020202020207b20646174613a202755534552532e555345524944272c206b65793a202775736572696427207d222c222020202020202020202020202020202020202020202020205d2c222c222020202020202020202020202020202020202020202020206462496e6465783a2031222c2220202020202020202020202020202020202020207d222c22202020202020202020202020202020202020202071756572794461746128706172616d2c20636f6e6669672c2074727565292e7069706528222c2220202020202020202020202020202020202020202020202074617028726573203d3e20636f6e736f6c652e6c6f672872657329292c222c222020202020202020202020202020202020202020292e73756273637269626528726573203d3e207b222c22202020202020202020202020202020202020202020202020636f6e736f6c652e6c6f67287265732c20277375627363726962652729222c2220202020202020202020202020202020202020207d29222c22202020202020202020202020202020207d222c2220202020202020202020202020202020646f69742829222c222020202020202020202020202020202072657475726e20276f6b20646172692063656b55736572273b225d5d7d7d' }]
|
|
49
49
|
const trigger = {
|
|
50
50
|
_id: 1,
|
|
51
51
|
name: 'New Watcher 1'
|
package/tests/watcherCtl.test.js
CHANGED
|
@@ -32,9 +32,9 @@ describe('Get Watcher Parameters', () => {
|
|
|
32
32
|
{ data: "SYS$WATCHER.ID.WATCHER_ID.SYS$TIMER.NAME", key: 'name' },
|
|
33
33
|
{ data: "SYS$WATCHER.ID.WATCHER_ID.SYS$TIMER.ACTIVE", key: 'active' },
|
|
34
34
|
{ data: "SYS$WATCHER.ID.WATCHER_ID.SYS$TIMER.TIME_ZONE", key: 'timezone' },
|
|
35
|
-
{ data: "SYS$WATCHER.ID.WATCHER_ID.SYS$TIMER.SCRIPT_NAME", key: 'templateName' },
|
|
35
|
+
// { data: "SYS$WATCHER.ID.WATCHER_ID.SYS$TIMER.SCRIPT_NAME", key: 'templateName' },
|
|
36
36
|
{ data: "SYS$WATCHER.ID.WATCHER_ID.SYS$TIMER.SEQ", key: 'seq' },
|
|
37
|
-
{ data: "SYS$WATCHER.ID.WATCHER_ID.SYS$TIMER.SCRIPT_ID", key: '
|
|
37
|
+
{ data: "SYS$WATCHER.ID.WATCHER_ID.SYS$TIMER.SCRIPT_ID", key: 'scriptid' },
|
|
38
38
|
{ data: "SYS$TIMER.ID.TIMER_ID.SYS$DAILY.DAYS", key: 'daily_days' },
|
|
39
39
|
{ data: "SYS$TIMER.ID.TIMER_ID.SYS$WEEKLY.ORDINAL", key: 'weekly_ordinal' },
|
|
40
40
|
{ data: "SYS$TIMER.ID.TIMER_ID.SYS$WEEKLY.DAYS", key: 'weekly_days' },
|
|
@@ -59,7 +59,7 @@ describe('Get Insert History Parameters', () => {
|
|
|
59
59
|
value1: "'abc'"
|
|
60
60
|
}],
|
|
61
61
|
columns: [
|
|
62
|
-
{ data: "HISTORY.ID", key: 'history_id' },
|
|
62
|
+
{ data: "SYS$HISTORY.ID", key: 'history_id' },
|
|
63
63
|
]
|
|
64
64
|
})
|
|
65
65
|
})
|