biz-a-cli 2.3.36 → 2.3.38

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.
@@ -20,39 +20,8 @@ export function getInputScript(req) {
20
20
  }
21
21
  }
22
22
 
23
- function rawHeadersToHeaders(rawHeaders) {
24
- const headers = {};
25
-
26
- for (let headerIdx = 0; headerIdx < rawHeaders.length; headerIdx += 2) {
27
- const key = rawHeaders[headerIdx].toLowerCase();
28
- const value = rawHeaders[headerIdx + 1];
29
-
30
- if (headers[key]) {
31
- headers[key] += `, ${value}`;
32
- } else {
33
- headers[key] = value;
34
- }
35
- }
36
-
37
- return headers;
38
- }
39
-
40
- export function setDirectHubData(req) {
41
- return {
42
- body: {
43
- query: req.query,
44
- body: req.body,
45
- headers: rawHeadersToHeaders(req.rawHeaders)
46
- }
47
- }
48
- }
49
-
50
23
  export async function runCliScript(req, res) {
51
24
  try {
52
- if (!req.body.query) {
53
- Object.assign(req, setDirectHubData(req))
54
- };
55
-
56
25
  const { data, selectedConfig } = getInputScript(req);
57
26
  let script = await loadCliScript(selectedConfig, 'ID', req.body.query.scriptid);
58
27
  let functions = await extractFunctionScript(selectedConfig, script);
package/envs/env.dev.js CHANGED
@@ -7,11 +7,4 @@ export const envDev = {
7
7
  COMPANY_REGISTER: 'companyregister-dev',
8
8
  BIZA_SERVER_LINK: 'https://biz-a-dev-41e7c93a25e5.herokuapp.com',
9
9
  // BIZA_SERVER_LINK: 'http://localhost:3000',
10
- ESPAY_INQUIRY_LINK: 'http://localhost:3006/cb?subdomain=anejandev&companyid=anejandev&scriptid=5',
11
- ESPAY_PAYMENT_LINK: 'http://localhost:3004/cb?subdomain=SACHLI&companyid=immdev&scriptid=6',
12
- // ESPAY_INQUIRY_LINK: 'https://biz-a.herokuapp.com/cb?subdomain=anejandev&companyid=anejandev&scriptid=5',
13
- // ESPAY_PAYMENT_LINK: 'https://biz-a.herokuapp.com/cb?subdomain=SACHLI&companyid=immdev&scriptid=6',
14
-
15
-
16
-
17
10
  };
package/envs/env.js CHANGED
@@ -6,9 +6,4 @@ export const env = {
6
6
  encodeURIComponent('imm@2019') + '@imm-cdm.ohcqt.mongodb.net/?retryWrites=true&w=majority',
7
7
  COMPANY_REGISTER: 'companyregister',
8
8
  BIZA_SERVER_LINK: 'https://biz-a.herokuapp.com',
9
- // ESPAY_INQUIRY_LINK: 'http://localhost:3002/cb?subdomain=scya&companyid=scy&scriptid=5',
10
- ESPAY_INQUIRY_LINK: 'http://localhost:3008/cb?subdomain=anejan&companyid=anejan&scriptid=4',
11
- ESPAY_PAYMENT_LINK: 'http://localhost:3002/cb?subdomain=imm&companyid=imamatek&scriptid=7',
12
- // ESPAY_INQUIRY_LINK: 'https://biz-a.herokuapp.com/cb?subdomain=anejandev&companyid=anejandev&scriptid=5',
13
- // ESPAY_PAYMENT_LINK: 'https://biz-a.herokuapp.com/cb?subdomain=SACHLI&companyid=immdev&scriptid=6',
14
9
  };
package/package.json CHANGED
@@ -1,21 +1,20 @@
1
1
  {
2
2
  "name": "biz-a-cli",
3
3
  "nameDev": "biz-a-cli-dev",
4
- "version": "2.3.36",
4
+ "version": "2.3.38",
5
5
  "versionDev": "0.0.30",
6
6
  "description": "",
7
7
  "main": "bin/index.js",
8
8
  "type": "module",
9
9
  "engines": {
10
- "node": "20.16.0",
11
- "npm": "10.8.1"
10
+ "node": "^20.16.0",
11
+ "npm": "^10.8.1"
12
12
  },
13
13
  "scripts": {
14
14
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch a",
15
15
  "test1": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
16
16
  "dev": "node --watch server.js",
17
17
  "hub": "node --experimental-vm-modules bin/hub.js"
18
-
19
18
  },
20
19
  "author": "Imamatek",
21
20
  "license": "ISC",
@@ -26,8 +25,7 @@
26
25
  "watcher": "bin/watcher.js",
27
26
  "uploadapp": "bin/uploadApp.js",
28
27
  "deleteapp": "bin/deleteApp.js",
29
- "biza": "bin/app.js",
30
- "pmtGateway": "bin/pmtGateway.js"
28
+ "biza": "bin/app.js"
31
29
  },
32
30
  "dependencies": {
33
31
  "axios": "^1.6.8",
@@ -57,4 +55,4 @@
57
55
  "!<rootDir>/tests/mockData/**"
58
56
  ]
59
57
  }
60
- }
58
+ }
@@ -151,12 +151,12 @@ function runScriptInThisContext(script) {
151
151
  return runInThisContext(script, { importModuleDynamically: constants.USE_MAIN_CONTEXT_DEFAULT_LOADER });
152
152
  }
153
153
 
154
- export async function setLibrary(config, libraries) {
154
+ export async function setLibrary(config, libraries, defaultLib) {
155
155
  let libs = {};
156
156
  for (const lib of libraries) {
157
157
  const data = await loadCliScript(config, 'SCRIPT_NAME', lib);
158
158
  const libFn = runScriptInThisContext(data[0].script);
159
- Object.assign(libs, { lib: libFn().functions });
159
+ Object.assign(libs, { lib: libFn(defaultLib).functions });
160
160
  }
161
161
 
162
162
  return libs;
@@ -182,7 +182,7 @@ export async function extractFunctionScript(selectedConfig, data) {
182
182
  }
183
183
 
184
184
  if (scriptFn().functions.useLibrary) {
185
- Object.assign(lib, await setLibrary(config, scriptFn().functions.useLibrary()));
185
+ Object.assign(lib, await setLibrary(config, scriptFn().functions.useLibrary(), lib));
186
186
  }
187
187
  return scriptFn(lib).functions;
188
188
  }
@@ -58,10 +58,13 @@ export const runScheduler = async (companyName) => {
58
58
  runHistory(histories, config, watchers, new Date());
59
59
  });
60
60
 
61
+ let intervalStartTime = '';
61
62
  for await (const startTime of setInterval(SCHEDULE_INTERVAL, Date.now())) {
62
- // if ((now - startTime) > 1000)
63
- // break;
64
-
63
+ if (!intervalStartTime) {
64
+ console.log('Interval Time starts at :', new Date(startTime));
65
+ intervalStartTime = new Date(startTime);
66
+ }
67
+
65
68
  const result = await getWatchers(config);
66
69
  const watchers = watcherRecordToJson(result);
67
70
  for (const watcher of watchers) {
@@ -1,6 +1,5 @@
1
1
  const {
2
- getInputScript,
3
- setDirectHubData
2
+ getInputScript
4
3
  } = await import('../callbackController.js');
5
4
 
6
5
  describe('callback test', () => {
@@ -40,20 +39,4 @@ describe('callback test', () => {
40
39
  }
41
40
  });
42
41
  });
43
-
44
- test('get input script', () => {
45
- const req = {
46
- query: { 'a': 1 },
47
- body: { 'b': 2 },
48
- rawHeaders: ['Abc-Xyz', 'def']
49
- }
50
-
51
- expect(setDirectHubData(req)).toStrictEqual({
52
- body: {
53
- query: { 'a': 1 },
54
- body: { 'b': 2 },
55
- headers: { 'abc-xyz': 'def' }
56
- }
57
- })
58
- });
59
42
  })
@@ -313,19 +313,21 @@ describe('data test', () => {
313
313
  axios.post.mockResolvedValueOnce(axios.post.mockResolvedValueOnce({
314
314
  data: [
315
315
  {
316
- 'SYS$CLI_SCRIPT.SCRIPT': 'get = function () {\n' +
316
+ 'SYS$CLI_SCRIPT.SCRIPT': 'get = function (lib) {\n' +
317
317
  ' return {\n' +
318
318
  ' functions: {\n' +
319
319
  ' yyy: function (data) {\n' +
320
320
  ' function doit() {\n' +
321
321
  ' return {\n' +
322
- " abc: function () { return 'abc'; console.log('abc') },\n" +
322
+ ' abc: function () {\n' +
323
+ " return 'abc';\n" +
324
+ ' },\n' +
323
325
  ' }\n' +
324
326
  ' }\n' +
325
327
  ' return doit()\n' +
326
328
  ' },\n' +
327
329
  ' zzz: function () {\n' +
328
- " return 'aaabbbccc';\n" +
330
+ " return lib;\n" +
329
331
  ' }\n' +
330
332
  ' }\n' +
331
333
  ' }\n' +
@@ -336,11 +338,12 @@ describe('data test', () => {
336
338
 
337
339
  const config = {};
338
340
  const libraries = ['lib'];
341
+ const defaultLib = { defA: 'A', defB: 'B' }
339
342
 
340
- const result = await setLibrary(config, libraries);
343
+ const result = await setLibrary(config, libraries, defaultLib);
341
344
 
342
345
  expect(result.lib.yyy().abc()).toStrictEqual('abc');
343
- expect(result.lib.zzz()).toStrictEqual('aaabbbccc');
346
+ expect(result.lib.zzz()).toStrictEqual({ "defA": "A", "defB": "B" });
344
347
  });
345
348
 
346
349
 
@@ -0,0 +1 @@
1
+ get = function () {return {modelA: {}}}
@@ -0,0 +1,2 @@
1
+ const get = function () {
2
+ return {"modelB": {id: null}}};
@@ -0,0 +1,4 @@
1
+ let get = function () {return {modelC: {}, function: {func: () => {
2
+ return ["lib"];
3
+ }
4
+ }}};
@@ -0,0 +1,2 @@
1
+ var get = function () {return {model: {}, tableName: "", fields: [], function: {}}};
2
+ module.exports = get;
@@ -0,0 +1,49 @@
1
+ [
2
+ {"menuName": "", "caption": "Home", "link": ["./main"],"subMenu": []},
3
+ {"menuName": "", "caption": "Personalia","link": [], "subMenu": [
4
+ {"menuName": "","caption": "Data Master","link": [], "subMenu": []},
5
+ {
6
+ "menuName": "",
7
+ "caption": "Gaji",
8
+ "link": [],
9
+ "subMenu": [
10
+ {
11
+ "menuName": "",
12
+ "caption": "Parameter",
13
+ "link": [
14
+ "./form",
15
+ "gajiparam",
16
+ null
17
+ ],
18
+ "subMenu": []
19
+ },
20
+ {
21
+ "menuName": "",
22
+ "caption": "Perubahan",
23
+ "link": [],
24
+ "subMenu": [
25
+ {
26
+ "menuName": "",
27
+ "caption": "Form Perubahan Gaji",
28
+ "link": [
29
+ "./form",
30
+ "gajiubah",
31
+ null
32
+ ],
33
+ "subMenu": []
34
+ },
35
+ {
36
+ "menuName": "",
37
+ "caption": "Daftar Perubahan Gaji",
38
+ "link": [
39
+ "./list",
40
+ "gajiubahdaftar"
41
+ ],
42
+ "subMenu": []
43
+ }
44
+ ]
45
+ }
46
+ ]
47
+ }
48
+ ]}
49
+ ]
package/bin/pmtGateway.js DELETED
@@ -1,68 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import yargs from 'yargs';
4
- import { createLogger, transports, format } from "winston";
5
- import {
6
- sendInquiry,
7
- sendPaymentNotif,
8
- } from "../pmtGatewayController.js";
9
-
10
-
11
- const logger = createLogger({
12
- level: 'info',
13
- transports: [
14
- new transports.File({ filename: 'log/error.log', level: 'error' }),
15
- new transports.File({ filename: 'log/debug.log', level: 'debug' }),
16
- new transports.File({ filename: 'log/info.log', level: 'info' }),
17
- ],
18
- })
19
- if (process.env.NODE_ENV !== 'production') {
20
- logger.add(new transports.Console({ format: format.simple(), level: 'info' }))
21
- }
22
-
23
- process.on('uncaughtException', (err) => { //debug
24
- console.log('Unhandled Exception:', err);
25
- logger.error('Unhandled Exception:', err)
26
- });
27
-
28
- process.on('unhandledRejection', (err) => { //debug
29
- console.log('Unhandled Rejection:', err);
30
- logger.error('Unhandled Rejection:', err)
31
- });
32
-
33
- const port = 3003;
34
- const argv = yargs(process.argv.slice(2))
35
- .usage('Usage: $0 [options]')
36
- .options('sp', {
37
- alias: 'serverport',
38
- default: port,
39
- describe: 'Express Port (Callback Feature)',
40
- type: 'number',
41
- demandOption: false
42
- })
43
- .argv;
44
-
45
- if (argv.help) {
46
- yargs().showHelp();
47
- process.exit();
48
- }
49
-
50
- //
51
- import express from 'express';
52
- import cors from 'cors';
53
- const app = express();
54
-
55
- app.use(cors());
56
- app.use(express.json());
57
-
58
- app.set('args', argv);
59
-
60
- app.use('/v1.0/transfer-va/inquiry', sendInquiry);
61
- app.use('/v1.0/transfer-va/payment', sendPaymentNotif);
62
-
63
- app.listen((argv.serverport || port), () => {
64
- console.log(`Biz-A is listening at ${process.env.HOST || 'http://localhost'}:${argv.serverport || port} `);
65
- });
66
- //
67
-
68
- export { app }
@@ -1,55 +0,0 @@
1
- import { default as axios } from 'axios';
2
- import { envDev } from './envs/env.dev.js';
3
- import { env } from './envs/env.js';
4
-
5
- import dayjs from "dayjs";
6
- import utc from "dayjs/plugin/utc.js";
7
- import timezone from "dayjs/plugin/timezone.js"
8
-
9
- dayjs.extend(timezone)
10
- dayjs.extend(utc)
11
-
12
- const TIME_FORMAT = 'YYYY-MM-DDTHH:mm:ssZ'
13
- let ESPAY_INQUIRY_LINK;
14
- let ESPAY_PAYMENT_LINK;
15
-
16
- if ((process.env.NODE_ENV == undefined) || (process.env.NODE_ENV == 'development')) {
17
- ESPAY_INQUIRY_LINK = envDev.ESPAY_INQUIRY_LINK;
18
- ESPAY_PAYMENT_LINK = envDev.ESPAY_PAYMENT_LINK;
19
-
20
- console.log('ESPAY_INQUIRY_LINK =>', ESPAY_INQUIRY_LINK);
21
- console.log('ESPAY_PAYMENT_LINK =>', ESPAY_PAYMENT_LINK);
22
- } else {
23
- ESPAY_INQUIRY_LINK = env.ESPAY_INQUIRY_LINK;
24
- ESPAY_PAYMENT_LINK = env.ESPAY_PAYMENT_LINK;
25
- }
26
-
27
- async function sendData(req, res, url) {
28
- const headers = {
29
- 'content-type': req.headers['content-type'],
30
- 'x-timestamp': req.headers['x-timestamp'],
31
- 'x-signature': req.headers['x-signature'],
32
- 'channel-id': req.headers['channel-id'],
33
- 'x-external-id': req.headers['x-external-id'],
34
- 'x-partner-id': req.headers['x-partner-id'],
35
- 'imm-original-url': req.originalUrl
36
- }
37
-
38
- res.setHeader('x-timestamp', dayjs().tz('Asia/jakarta').format(TIME_FORMAT));
39
-
40
- const result = await axios.post(url, req.body, { headers });
41
- res.send(result.data);
42
- }
43
-
44
- async function sendInquiry(req, res) {
45
- await sendData(req, res, ESPAY_INQUIRY_LINK);
46
- }
47
-
48
- async function sendPaymentNotif(req, res) {
49
- await sendData(req, res, ESPAY_PAYMENT_LINK);
50
- }
51
-
52
- export {
53
- sendInquiry,
54
- sendPaymentNotif
55
- };