biz-a-cli 2.3.3 → 2.3.5
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 +14 -5
- package/bin/watcher.js +1 -0
- package/callbackController.js +30 -12
- package/envs/env.dev.js +1 -1
- package/envs/env.js +0 -1
- package/package.json +2 -2
- package/scheduler/configController.js +9 -9
- package/scheduler/converter.js +1 -1
- package/scheduler/datalib.js +32 -20
- package/scheduler/timer.js +1 -2
- package/scheduler/watcherController.js +3 -3
- package/tests/callback.test.js +40 -0
- package/tests/converter.test.js +4 -4
- package/tests/data.test.js +38 -6
- package/tests/hub.test.js +1 -1
- package/tests/watcherCtl.test.js +3 -3
package/bin/hub.js
CHANGED
|
@@ -22,21 +22,28 @@ const argv = yargs(process.argv.slice(2))
|
|
|
22
22
|
.options('h', {
|
|
23
23
|
alias: 'hostname',
|
|
24
24
|
default: '127.0.0.1',
|
|
25
|
-
describe: 'Address of local server for forwarding over socket-tunnel',
|
|
25
|
+
describe: '(Required) Address of local server for forwarding over socket-tunnel',
|
|
26
26
|
type: 'string',
|
|
27
27
|
demandOption: true
|
|
28
28
|
})
|
|
29
|
+
.options('d', {
|
|
30
|
+
alias: 'dbindex',
|
|
31
|
+
default: 2,
|
|
32
|
+
describe: '(Required) Biz-A Database Index (Callback Feature)',
|
|
33
|
+
type: 'number',
|
|
34
|
+
demandOption: false
|
|
35
|
+
})
|
|
29
36
|
.options('p', {
|
|
30
37
|
alias: 'port',
|
|
31
38
|
default: 212,
|
|
32
|
-
describe: '
|
|
39
|
+
describe: 'Port of local server for forwarding over socket-tunnel',
|
|
33
40
|
type: 'number',
|
|
34
|
-
demandOption:
|
|
41
|
+
demandOption: false
|
|
35
42
|
})
|
|
36
43
|
.options('sp', {
|
|
37
44
|
alias: 'serverport',
|
|
38
|
-
default:
|
|
39
|
-
describe: '
|
|
45
|
+
default: port,
|
|
46
|
+
describe: 'Express Port (Callback Feature)',
|
|
40
47
|
type: 'number',
|
|
41
48
|
demandOption: false
|
|
42
49
|
})
|
|
@@ -67,6 +74,8 @@ import { runCliScript } from '../callbackController.js'
|
|
|
67
74
|
app.use(cors());
|
|
68
75
|
app.use(express.json());
|
|
69
76
|
|
|
77
|
+
app.set('args', argv);
|
|
78
|
+
|
|
70
79
|
app.use('/cb', runCliScript);
|
|
71
80
|
const port = 3002;
|
|
72
81
|
|
package/bin/watcher.js
CHANGED
package/callbackController.js
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
import { loadCliScript, extractFunctionScript } from "./scheduler/datalib.js";
|
|
2
|
-
import { getCompanyObjectId, getSelectedConfig } from "./scheduler/configController.js";
|
|
3
2
|
|
|
4
|
-
export async function runCliScript(req, res) {
|
|
5
|
-
const data = req.body;
|
|
6
|
-
const company = await getCompanyObjectId(data.query.companyId);
|
|
7
|
-
const config = await getSelectedConfig(company._id);
|
|
8
|
-
const selectedConfig = config[0];
|
|
9
3
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
export function getInputScript(req) {
|
|
5
|
+
const args = req.app.settings.args;
|
|
6
|
+
return {
|
|
7
|
+
data: {
|
|
8
|
+
arguments: args,
|
|
9
|
+
body: req.body.body
|
|
10
|
+
},
|
|
11
|
+
selectedConfig: {
|
|
12
|
+
API_URL: `http://${args.hostname}:${args.port}`,
|
|
13
|
+
dbindex: args.dbindex,
|
|
14
|
+
subdomain: args.subdomain
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function runCliScript(req, res) {
|
|
20
|
+
const { data, selectedConfig } = getInputScript(req);
|
|
14
21
|
|
|
15
|
-
|
|
22
|
+
loadCliScript(selectedConfig, req.body.query).subscribe({
|
|
23
|
+
next: script => {
|
|
24
|
+
let functions = extractFunctionScript(script);
|
|
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
|
+
}
|
|
16
31
|
},
|
|
17
|
-
error: error =>
|
|
32
|
+
error: error => {
|
|
33
|
+
console.error(error);
|
|
34
|
+
throw new Error(error);
|
|
35
|
+
}
|
|
18
36
|
})
|
|
19
37
|
}
|
package/envs/env.dev.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export const envDev = {
|
|
2
2
|
production: false,
|
|
3
|
-
cdmUrl: 'https://imm-cdm-dev.herokuapp.com',
|
|
4
3
|
BIZA_MONGO_LINK: 'mongodb+srv://imm_biza:' +
|
|
5
4
|
encodeURIComponent('imm@2023') + '@cluster0.z2yr8kp.mongodb.net/?retryWrites=true&w=majority',
|
|
6
5
|
CDM_MONGO_LINK: 'mongodb+srv://imm_cdm:' +
|
|
7
6
|
encodeURIComponent('imm@2019') + '@imm-cdm-dev.rf6wr.mongodb.net/?retryWrites=true&w=majority',
|
|
8
7
|
COMPANY_REGISTER: 'companyregister-dev',
|
|
9
8
|
BIZA_SERVER_LINK: 'https://biz-a-dev-41e7c93a25e5.herokuapp.com'
|
|
9
|
+
// BIZA_SERVER_LINK: 'http://localhost:3000'
|
|
10
10
|
};
|
package/envs/env.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export const env = {
|
|
2
2
|
production: true,
|
|
3
|
-
cdmUrl: 'https://imm-cdm.herokuapp.com',
|
|
4
3
|
BIZA_MONGO_LINK: 'mongodb+srv://imm_biza:' +
|
|
5
4
|
encodeURIComponent('imm@2023') + '@cluster0.lezywmk.mongodb.net/?retryWrites=true&w=majority',
|
|
6
5
|
CDM_MONGO_LINK: 'mongodb+srv://imm_cdm:' +
|
package/package.json
CHANGED
|
@@ -7,17 +7,17 @@ let CDM_MONGO_LINK;
|
|
|
7
7
|
let COMPANY_REGISTER;
|
|
8
8
|
|
|
9
9
|
// if ((process.env.NODE_ENV == undefined) || (process.env.NODE_ENV == 'development')) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
// BIZA_MONGO_LINK = envDev.BIZA_MONGO_LINK;
|
|
11
|
+
// CDM_MONGO_LINK = envDev.CDM_MONGO_LINK;
|
|
12
|
+
// COMPANY_REGISTER = envDev.COMPANY_REGISTER;
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
// console.log('BIZA_MONGO_LINK =>', BIZA_MONGO_LINK);
|
|
15
|
+
// console.log('CDM_MONGO_LINK =>', CDM_MONGO_LINK);
|
|
16
|
+
// console.log('COMPANY_REGISTER =>', COMPANY_REGISTER);
|
|
17
17
|
// } else {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
BIZA_MONGO_LINK = env.BIZA_MONGO_LINK;
|
|
19
|
+
CDM_MONGO_LINK = env.CDM_MONGO_LINK;
|
|
20
|
+
COMPANY_REGISTER = env.COMPANY_REGISTER;
|
|
21
21
|
// }
|
|
22
22
|
|
|
23
23
|
async function fetchSelectedConfig(aggregateField) {
|
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,10 +134,7 @@ export function extractFunctionScript(data) {
|
|
|
134
134
|
return
|
|
135
135
|
}
|
|
136
136
|
if (data.length == 0) return
|
|
137
|
-
let hex = JSON.parse(hex2a(data[0].
|
|
138
|
-
//sementara ke template dahulu
|
|
139
|
-
// let hex = JSON.parse(hex2a(data[0].script))
|
|
140
|
-
|
|
137
|
+
let hex = JSON.parse(hex2a(data[0].script))
|
|
141
138
|
if (!hex.functions) return
|
|
142
139
|
return JSON.parse(JSON.stringify(hex.functions), deserialise)
|
|
143
140
|
}
|
|
@@ -145,13 +142,8 @@ export function extractFunctionScript(data) {
|
|
|
145
142
|
export function getQueryDataObsParameters(trigger) {
|
|
146
143
|
return {
|
|
147
144
|
length: 1,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
columns: [{ data: "TEMPLATE.TEMPLATE", key: 'template' }]
|
|
151
|
-
|
|
152
|
-
//sementara ke template dahulu
|
|
153
|
-
// filter: [{ junction: '', column: 'ID', operator: '=', value1: `${trigger.scriptId}` }],
|
|
154
|
-
// 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' }]
|
|
155
147
|
}
|
|
156
148
|
}
|
|
157
149
|
|
|
@@ -173,18 +165,35 @@ export function loadCliScript(selectedConfig, trigger) {
|
|
|
173
165
|
)
|
|
174
166
|
}
|
|
175
167
|
|
|
168
|
+
export function getInputData(config, trigger) {
|
|
169
|
+
const urlAndPort = config.API_URL.split(':');
|
|
170
|
+
return {
|
|
171
|
+
arguments: {
|
|
172
|
+
hostname: urlAndPort[1].split('//')[1],
|
|
173
|
+
port: +urlAndPort[2],
|
|
174
|
+
dbindex: config.dbindex,
|
|
175
|
+
subdomain: config.subdomain
|
|
176
|
+
},
|
|
177
|
+
body: trigger.data
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
176
181
|
export function scheduleSubscription(config, data, trigger, needSetHistory, isTest = false) {
|
|
177
182
|
try {
|
|
178
183
|
let functions = extractFunctionScript(data);
|
|
179
|
-
if (
|
|
180
|
-
|
|
181
|
-
|
|
184
|
+
if (functions) {
|
|
185
|
+
if (!isTest) { // next, change isTest to test better
|
|
186
|
+
functions.onInit(getInputData(config, trigger));
|
|
187
|
+
}
|
|
182
188
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
+
}
|
|
186
195
|
} else {
|
|
187
|
-
console.log(`
|
|
196
|
+
console.log(`CLI Script does not exist : ${trigger.name}`);
|
|
188
197
|
}
|
|
189
198
|
} catch (error) {
|
|
190
199
|
console.error(error);
|
|
@@ -195,6 +204,9 @@ export function scheduleSubscription(config, data, trigger, needSetHistory, isTe
|
|
|
195
204
|
export function checkSchedule(selectedConfig, trigger, needSetHistory) {
|
|
196
205
|
loadCliScript(selectedConfig, trigger).subscribe({
|
|
197
206
|
next: data => scheduleSubscription(selectedConfig, data, trigger, needSetHistory),
|
|
198
|
-
error: error =>
|
|
207
|
+
error: error => {
|
|
208
|
+
console.error(error);
|
|
209
|
+
throw new Error(error);
|
|
210
|
+
}
|
|
199
211
|
})
|
|
200
212
|
}
|
package/scheduler/timer.js
CHANGED
|
@@ -50,14 +50,13 @@ export async function runHistory(histories, config, watchers, now) {
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
export const runScheduler = async (companyName) => {
|
|
53
|
-
await delay(30000);
|
|
53
|
+
// await delay(30000);
|
|
54
54
|
|
|
55
55
|
const company = await getCompanyObjectId(companyName);
|
|
56
56
|
const config = await getSelectedConfig(company._id);
|
|
57
57
|
|
|
58
58
|
forkJoin([getHistories(config[0]), getWatchers(config[0])]).subscribe({
|
|
59
59
|
next: ([historyResult, watcherResult]) => {
|
|
60
|
-
|
|
61
60
|
const histories = historyRecordToJson(historyResult);
|
|
62
61
|
const watchers = watcherRecordToJson(watcherResult);
|
|
63
62
|
runHistory(histories, config[0], watchers, new Date());
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// import { jest } from '@jest/globals'
|
|
2
|
+
|
|
3
|
+
// const mockInsertHistory = jest.fn();
|
|
4
|
+
// jest.unstable_mockModule("../scheduler/watcherController.js", () => ({
|
|
5
|
+
// insertHistory: mockInsertHistory.mockResolvedValue('OK')
|
|
6
|
+
// }))
|
|
7
|
+
|
|
8
|
+
const {
|
|
9
|
+
getInputScript
|
|
10
|
+
} = await import('../callbackController.js');
|
|
11
|
+
|
|
12
|
+
describe('callback test', () => {
|
|
13
|
+
test('get input script', () => {
|
|
14
|
+
const args = {
|
|
15
|
+
hostname: 'localhost',
|
|
16
|
+
port: 212,
|
|
17
|
+
dbindex: 2,
|
|
18
|
+
subdomain: 'abc'
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const request = {
|
|
22
|
+
app: { settings: { args: args } },
|
|
23
|
+
body: { body: { body1: 'value1' } }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
expect(getInputScript(request)).toStrictEqual({
|
|
27
|
+
data: {
|
|
28
|
+
arguments: args,
|
|
29
|
+
body: { body1: 'value1' }
|
|
30
|
+
},
|
|
31
|
+
selectedConfig: {
|
|
32
|
+
API_URL: 'http://localhost:212',
|
|
33
|
+
dbindex: 2,
|
|
34
|
+
subdomain: 'abc'
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
})
|
|
40
|
+
|
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
|
@@ -15,6 +15,7 @@ jest.unstable_mockModule("../scheduler/watcherController.js", () => ({
|
|
|
15
15
|
const {
|
|
16
16
|
scheduleSubscription,
|
|
17
17
|
getConfig,
|
|
18
|
+
getInputData,
|
|
18
19
|
getQueryDataObsParameters,
|
|
19
20
|
} = await import('../scheduler/datalib.js');
|
|
20
21
|
|
|
@@ -22,10 +23,11 @@ describe('data test', () => {
|
|
|
22
23
|
test('check schedule subscription no history', () => {
|
|
23
24
|
const config = {
|
|
24
25
|
_id: 'ffffffff2ae49fab9ea654e1',
|
|
25
|
-
API_URL: 'localhost'
|
|
26
|
+
API_URL: 'http://localhost:212',
|
|
27
|
+
dbindex: 2,
|
|
28
|
+
subdomain: 'abc'
|
|
26
29
|
}
|
|
27
|
-
|
|
28
|
-
const data = [{ template: '7b2266756e6374696f6e73223a7b226f6e496e6974223a5b2277696e646f772e46756e6374696f6e222c5b22636f6e666967222c222064617461225d2c5b2220202020202020202020202020202020636f6e737420646f6974203d206173796e63202829203d3e207b222c222020202020202020202020202020202020202020636f6e7374207b20746170207d203d20617761697420696d706f7274282772786a732729222c222020202020202020202020202020202020202020636f6e7374207b20717565727944617461207d203d20617761697420696d706f727428272e2f646174616c69622e6a732729222c222020202020202020202020202020202020202020636f6e737420706172616d203d207b222c222020202020202020202020202020202020202020202020206c656e6774683a2031302c222c22202020202020202020202020202020202020202020202020636f6c756d6e733a205b222c22202020202020202020202020202020202020202020202020202020207b20646174613a202755534552532e555345524944272c206b65793a202775736572696427207d222c222020202020202020202020202020202020202020202020205d2c222c222020202020202020202020202020202020202020202020206462496e6465783a2031222c2220202020202020202020202020202020202020207d222c22202020202020202020202020202020202020202071756572794461746128706172616d2c20636f6e6669672c2074727565292e7069706528222c2220202020202020202020202020202020202020202020202074617028726573203d3e20636f6e736f6c652e6c6f672872657329292c222c222020202020202020202020202020202020202020292e73756273637269626528726573203d3e207b222c22202020202020202020202020202020202020202020202020636f6e736f6c652e6c6f67287265732c20277375627363726962652729222c2220202020202020202020202020202020202020207d29222c22202020202020202020202020202020207d222c2220202020202020202020202020202020646f69742829222c222020202020202020202020202020202072657475726e20276f6b20646172692063656b55736572273b225d5d7d7d' }]
|
|
30
|
+
const data = [{ script: '7b2266756e6374696f6e73223a7b226f6e496e6974223a5b2277696e646f772e46756e6374696f6e222c5b22636f6e666967222c222064617461225d2c5b2220202020202020202020202020202020636f6e737420646f6974203d206173796e63202829203d3e207b222c222020202020202020202020202020202020202020636f6e7374207b20746170207d203d20617761697420696d706f7274282772786a732729222c222020202020202020202020202020202020202020636f6e7374207b20717565727944617461207d203d20617761697420696d706f727428272e2f646174616c69622e6a732729222c222020202020202020202020202020202020202020636f6e737420706172616d203d207b222c222020202020202020202020202020202020202020202020206c656e6774683a2031302c222c22202020202020202020202020202020202020202020202020636f6c756d6e733a205b222c22202020202020202020202020202020202020202020202020202020207b20646174613a202755534552532e555345524944272c206b65793a202775736572696427207d222c222020202020202020202020202020202020202020202020205d2c222c222020202020202020202020202020202020202020202020206462496e6465783a2031222c2220202020202020202020202020202020202020207d222c22202020202020202020202020202020202020202071756572794461746128706172616d2c20636f6e6669672c2074727565292e7069706528222c2220202020202020202020202020202020202020202020202074617028726573203d3e20636f6e736f6c652e6c6f672872657329292c222c222020202020202020202020202020202020202020292e73756273637269626528726573203d3e207b222c22202020202020202020202020202020202020202020202020636f6e736f6c652e6c6f67287265732c20277375627363726962652729222c2220202020202020202020202020202020202020207d29222c22202020202020202020202020202020207d222c2220202020202020202020202020202020646f69742829222c222020202020202020202020202020202072657475726e20276f6b20646172692063656b55736572273b225d5d7d7d' }]
|
|
29
31
|
const trigger = {
|
|
30
32
|
_id: 1,
|
|
31
33
|
name: 'New Watcher 1',
|
|
@@ -38,19 +40,49 @@ describe('data test', () => {
|
|
|
38
40
|
test('check schedule subscription with history', () => {
|
|
39
41
|
const config = {
|
|
40
42
|
_id: 'ffffffff2ae49fab9ea654e1',
|
|
41
|
-
API_URL: 'localhost'
|
|
43
|
+
API_URL: 'http://localhost:212',
|
|
44
|
+
dbindex: 2,
|
|
45
|
+
subdomain: 'abc'
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
const data = [{
|
|
48
|
+
const data = [{ script: '7b2266756e6374696f6e73223a7b226f6e496e6974223a5b2277696e646f772e46756e6374696f6e222c5b22636f6e666967222c222064617461225d2c5b2220202020202020202020202020202020636f6e737420646f6974203d206173796e63202829203d3e207b222c222020202020202020202020202020202020202020636f6e7374207b20746170207d203d20617761697420696d706f7274282772786a732729222c222020202020202020202020202020202020202020636f6e7374207b20717565727944617461207d203d20617761697420696d706f727428272e2f646174616c69622e6a732729222c222020202020202020202020202020202020202020636f6e737420706172616d203d207b222c222020202020202020202020202020202020202020202020206c656e6774683a2031302c222c22202020202020202020202020202020202020202020202020636f6c756d6e733a205b222c22202020202020202020202020202020202020202020202020202020207b20646174613a202755534552532e555345524944272c206b65793a202775736572696427207d222c222020202020202020202020202020202020202020202020205d2c222c222020202020202020202020202020202020202020202020206462496e6465783a2031222c2220202020202020202020202020202020202020207d222c22202020202020202020202020202020202020202071756572794461746128706172616d2c20636f6e6669672c2074727565292e7069706528222c2220202020202020202020202020202020202020202020202074617028726573203d3e20636f6e736f6c652e6c6f672872657329292c222c222020202020202020202020202020202020202020292e73756273637269626528726573203d3e207b222c22202020202020202020202020202020202020202020202020636f6e736f6c652e6c6f67287265732c20277375627363726962652729222c2220202020202020202020202020202020202020207d29222c22202020202020202020202020202020207d222c2220202020202020202020202020202020646f69742829222c222020202020202020202020202020202072657475726e20276f6b20646172692063656b55736572273b225d5d7d7d' }]
|
|
45
49
|
const trigger = {
|
|
46
50
|
_id: 1,
|
|
47
|
-
name: 'New Watcher 1'
|
|
51
|
+
name: 'New Watcher 1'
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
scheduleSubscription(config, data, trigger, true, true);
|
|
51
55
|
expect(mockInsertHistory).toBeCalledTimes(1);
|
|
52
56
|
});
|
|
53
57
|
|
|
58
|
+
test('get input data', () => {
|
|
59
|
+
const config = {
|
|
60
|
+
_id: 'ffffffff2ae49fab9ea654e1',
|
|
61
|
+
API_URL: 'http://localhost:212',
|
|
62
|
+
dbindex: 2,
|
|
63
|
+
subdomain: 'abc'
|
|
64
|
+
}
|
|
65
|
+
const trigger = {
|
|
66
|
+
data: {
|
|
67
|
+
_id: 1,
|
|
68
|
+
name: 'New Watcher 1'
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
expect(getInputData(config, trigger)).toStrictEqual({
|
|
73
|
+
arguments: {
|
|
74
|
+
hostname: 'localhost',
|
|
75
|
+
port: 212,
|
|
76
|
+
dbindex: 2,
|
|
77
|
+
subdomain: 'abc'
|
|
78
|
+
},
|
|
79
|
+
body: {
|
|
80
|
+
_id: 1,
|
|
81
|
+
name: 'New Watcher 1'
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
54
86
|
test('get config', () => {
|
|
55
87
|
const config = {
|
|
56
88
|
_id: 'ffffffff2ae49fab9ea654e1',
|
package/tests/hub.test.js
CHANGED
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
|
})
|