@ntlab/sipd-agr 3.7.0 → 3.9.0
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/package.json +3 -3
- package/sipd/index.js +38 -42
- package/sipd/modules/agr/index.js +9 -3
- package/sipd/modules/app.js +4 -4
- package/sipd/modules/subkeg.js +1 -1
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ntlab/sipd-agr",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "SIPD RI Kemendagri Automation is a web automation using Selenium to help manage data such as budgeting download",
|
|
5
5
|
"main": "main.js",
|
|
6
6
|
"author": "Toha <tohenk@yahoo.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@ntlab/ntlib": "^2.6.2",
|
|
10
|
-
"@ntlab/webrobot": "^1.
|
|
10
|
+
"@ntlab/webrobot": "^2.1.2",
|
|
11
11
|
"@ntlab/work": "^2.3.0",
|
|
12
|
-
"debug": "^4.4.
|
|
12
|
+
"debug": "^4.4.3",
|
|
13
13
|
"exceljs": "^4.4.0",
|
|
14
14
|
"glob": "^11.0.3"
|
|
15
15
|
},
|
package/sipd/index.js
CHANGED
|
@@ -49,6 +49,41 @@ class Sipd extends WebRobot {
|
|
|
49
49
|
super.constructor.expectErr(error.StaleElementReferenceError);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
getPageScript1() {
|
|
53
|
+
return (
|
|
54
|
+
'd2luZG93LmdldENvZGUgPSBmdW5jdGlvbigpIHsKICAgIGlmIChBcnJheS5pc0FycmF5KHdpbmRvdy5' +
|
|
55
|
+
'yZXRfbm9kZXMpKSB7CiAgICAgICAgZm9yIChjb25zdCBub2RlIG9mIHdpbmRvdy5yZXRfbm9kZXMpIH' +
|
|
56
|
+
'sKICAgICAgICAgICAgaWYgKG5vZGUubm9kZU5hbWUgPT09ICdOR1gtQ0FQVENIQScgJiYgQXJyYXkua' +
|
|
57
|
+
'XNBcnJheShub2RlLl9fbmdDb250ZXh0X18pKSB7CiAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG8g' +
|
|
58
|
+
'b2Ygbm9kZS5fX25nQ29udGV4dF9fKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKG8gJiYgby5jYXB' +
|
|
59
|
+
'0Y2hTZXJ2aWNlICYmIG8uY29kZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gby5jb2' +
|
|
60
|
+
'RlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgI' +
|
|
61
|
+
'GJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQp9'
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
getPageScript2() {
|
|
66
|
+
return (
|
|
67
|
+
'YWRkRXZlbnRMaXN0ZW5lcignbG9hZCcsIGUgPT4gew0KICAgIGlmIChYTUxIdHRwUmVxdWVzdC5wcm90' +
|
|
68
|
+
'b3R5cGUuX3NlbmQgPT09IHVuZGVmaW5lZCkgew0KICAgICAgICBYTUxIdHRwUmVxdWVzdC5wcm90b3R5' +
|
|
69
|
+
'cGUuX3NlbmQgPSBYTUxIdHRwUmVxdWVzdC5wcm90b3R5cGUuc2VuZDsNCiAgICAgICAgWE1MSHR0cFJl' +
|
|
70
|
+
'cXVlc3QucHJvdG90eXBlLnNlbmQgPSBmdW5jdGlvbiguLi5hcmdzKSB7DQogICAgICAgICAgICBpZiAo' +
|
|
71
|
+
'd2luZG93LmFwaXMgPT09IHVuZGVmaW5lZCkgew0KICAgICAgICAgICAgICAgIHdpbmRvdy5hcGlzID0g' +
|
|
72
|
+
'e307DQogICAgICAgICAgICB9DQogICAgICAgICAgICBjb25zdCB1cmkgPSB0aGlzLl9fem9uZV9zeW1i' +
|
|
73
|
+
'b2xfX3hoclVSTC5zdWJzdHIod2luZG93LmxvY2F0aW9uLm9yaWdpbi5sZW5ndGgpOw0KICAgICAgICAg' +
|
|
74
|
+
'ICAgaWYgKHVyaS5zdGFydHNXaXRoKCcvYXBpLycpKSB7DQogICAgICAgICAgICAgICAgdGhpcy5hZGRF' +
|
|
75
|
+
'dmVudExpc3RlbmVyKCdyZWFkeXN0YXRlY2hhbmdlJywgZSA9PiB7DQogICAgICAgICAgICAgICAgICAg' +
|
|
76
|
+
'IGNvbnN0IHhociA9IGUudGFyZ2V0Ow0KICAgICAgICAgICAgICAgICAgICBpZiAoeGhyLnJlYWR5U3Rh' +
|
|
77
|
+
'dGUgPT09IFhNTEh0dHBSZXF1ZXN0LkRPTkUpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgh' +
|
|
78
|
+
'd2luZG93LmFwaXNbdXJpXSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpbmRvdy5hcGlz' +
|
|
79
|
+
'W3VyaV0gPSBbeGhyLnN0YXR1cywgeGhyLnJlc3BvbnNlVGV4dF07DQogICAgICAgICAgICAgICAgICAg' +
|
|
80
|
+
'ICAgICB9DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAg' +
|
|
81
|
+
'ICAgIH0NCiAgICAgICAgICAgIHRoaXMuX3NlbmQuYXBwbHkodGhpcywgYXJncyk7DQogICAgICAgIH0N' +
|
|
82
|
+
'CiAgICB9DQp9KTsNCndpbmRvdy5nZXRBcGlSZXNwb25zZSA9IGZ1bmN0aW9uKHBhdGgpIHsNCiAgICBy' +
|
|
83
|
+
'ZXR1cm4gd2luZG93LmFwaXMgPyB3aW5kb3cuYXBpc1twYXRoXSA6IG51bGw7DQp9DQo='
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
52
87
|
getWorks() {
|
|
53
88
|
const works = this.getCommonWorks();
|
|
54
89
|
switch (this.options.mode) {
|
|
@@ -69,46 +104,7 @@ class Sipd extends WebRobot {
|
|
|
69
104
|
const mode = this.options.mode;
|
|
70
105
|
if (mode === Sipd.DOWNLOAD || mode === Sipd.REFS) {
|
|
71
106
|
if (!this.options.skipDownload) {
|
|
72
|
-
const code =
|
|
73
|
-
'd2luZG93LmdldENvZGUgPSBmdW5jdGlvbigpIHsKICAgIGlmIChBcnJheS5pc0FycmF5KHdpbmRvdy5' +
|
|
74
|
-
'yZXRfbm9kZXMpKSB7CiAgICAgICAgZm9yIChjb25zdCBub2RlIG9mIHdpbmRvdy5yZXRfbm9kZXMpIH' +
|
|
75
|
-
'sKICAgICAgICAgICAgaWYgKG5vZGUubm9kZU5hbWUgPT09ICdOR1gtQ0FQVENIQScgJiYgQXJyYXkua' +
|
|
76
|
-
'XNBcnJheShub2RlLl9fbmdDb250ZXh0X18pKSB7CiAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG8g' +
|
|
77
|
-
'b2Ygbm9kZS5fX25nQ29udGV4dF9fKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKG8gJiYgby5jYXB' +
|
|
78
|
-
'0Y2hTZXJ2aWNlICYmIG8uY29kZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gby5jb2' +
|
|
79
|
-
'RlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgI' +
|
|
80
|
-
'GJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQp9';
|
|
81
107
|
works.push(
|
|
82
|
-
[w => this.getDriver().sendDevToolsCommand('Page.addScriptToEvaluateOnNewDocument', {
|
|
83
|
-
source: `
|
|
84
|
-
addEventListener('load', e => {
|
|
85
|
-
if (XMLHttpRequest.prototype._send === undefined) {
|
|
86
|
-
XMLHttpRequest.prototype._send = XMLHttpRequest.prototype.send;
|
|
87
|
-
XMLHttpRequest.prototype.send = function(...args) {
|
|
88
|
-
if (window.apis === undefined) {
|
|
89
|
-
window.apis = {};
|
|
90
|
-
}
|
|
91
|
-
const uri = this.__zone_symbol__xhrURL.substr(window.location.origin.length);
|
|
92
|
-
if (uri.startsWith('/api/')) {
|
|
93
|
-
this.addEventListener('readystatechange', e => {
|
|
94
|
-
const xhr = e.target;
|
|
95
|
-
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
96
|
-
if (!window.apis[uri]) {
|
|
97
|
-
window.apis[uri] = [xhr.status, xhr.responseText];
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
this._send.apply(this, args);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
window.getApiResponse = function(path) {
|
|
107
|
-
return window.apis ? window.apis[path] : null;
|
|
108
|
-
}
|
|
109
|
-
${Buffer.from(code, '\x62\x61\x73\x65\x36\x34').toString()}
|
|
110
|
-
`
|
|
111
|
-
})],
|
|
112
108
|
[w => this.open()],
|
|
113
109
|
[w => this.app.login()],
|
|
114
110
|
[w => this.app.setYear()],
|
|
@@ -147,9 +143,9 @@ class Sipd extends WebRobot {
|
|
|
147
143
|
const f = () => {
|
|
148
144
|
const q = new Queue([...uris], uri => {
|
|
149
145
|
this.works([
|
|
150
|
-
[w => this.
|
|
146
|
+
[w => this.driver.getCurrentUrl(), w => options.referer],
|
|
151
147
|
[w => Promise.reject(`Unexpected referer ${w.getRes(0)}!`), w => options.referer && options.referer !== w.getRes(0)],
|
|
152
|
-
[w => this.
|
|
148
|
+
[w => this.driver.executeScript('return getApiResponse(arguments[0])', uri)],
|
|
153
149
|
])
|
|
154
150
|
.then(result => {
|
|
155
151
|
if (result && Array.isArray(result)) {
|
|
@@ -257,7 +253,7 @@ class Sipd extends WebRobot {
|
|
|
257
253
|
}
|
|
258
254
|
|
|
259
255
|
scrollTo(top) {
|
|
260
|
-
return this.
|
|
256
|
+
return this.driver.executeScript(`window.scrollTo(0, ${top});`);
|
|
261
257
|
}
|
|
262
258
|
|
|
263
259
|
static get UPLOAD() {
|
|
@@ -187,6 +187,14 @@ class SipdAgrRinci {
|
|
|
187
187
|
this.fromJson(data);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
isHibahUang(data) {
|
|
191
|
+
if (data && data.nama_akun !== undefined) {
|
|
192
|
+
const rek = data.nama_akun.toLowerCase();
|
|
193
|
+
return rek.includes('hibah uang') && !rek.includes('dana bos') ? true : false;
|
|
194
|
+
}
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
|
|
190
198
|
fromJson(data) {
|
|
191
199
|
this.ref = data.id_rinci_sub_bl;
|
|
192
200
|
this.ssh = data.kode_standar_harga;
|
|
@@ -196,9 +204,7 @@ class SipdAgrRinci {
|
|
|
196
204
|
this.volume = SipdUtil.makeFloat(data.koefisien);
|
|
197
205
|
this.total = SipdUtil.makeFloat(data.total_harga);
|
|
198
206
|
this.satuan = data.koefisien.substr(this.volume.toString().length);
|
|
199
|
-
if (
|
|
200
|
-
data.penerima_bantuan ||
|
|
201
|
-
(data.subs_bl_teks && data.subs_bl_teks.toLowerCase().indexOf('hibah') >= 0)) {
|
|
207
|
+
if (this.isHibahUang(data)) {
|
|
202
208
|
const penerima = SipdUtil.cleanText(data.penerima_bantuan);
|
|
203
209
|
let uraian = SipdUtil.cleanText(data.ket_bl_teks);
|
|
204
210
|
if (uraian) {
|
package/sipd/modules/app.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
const { By
|
|
25
|
+
const { By } = require('selenium-webdriver');
|
|
26
26
|
const Sipd = require('..');
|
|
27
27
|
const SipdScript = require('../script');
|
|
28
28
|
|
|
@@ -112,7 +112,7 @@ class SipdApp {
|
|
|
112
112
|
w => i === menus.length && mitem && !options.click],
|
|
113
113
|
[w => Promise.resolve(url = w.res),
|
|
114
114
|
w => i === menus.length && mitem && !options.click],
|
|
115
|
-
[w => this.owner.
|
|
115
|
+
[w => this.owner.driver.get(url + (options.params ? (url.indexOf('?') < 0 ? '?' : '&') + options.params : '')),
|
|
116
116
|
w => i === menus.length && mitem && !options.click],
|
|
117
117
|
[w => Promise.resolve(url),
|
|
118
118
|
w => i === menus.length && mitem && !options.click],
|
|
@@ -131,7 +131,7 @@ class SipdApp {
|
|
|
131
131
|
|
|
132
132
|
solveCaptcha() {
|
|
133
133
|
return this.owner.works([
|
|
134
|
-
[w => this.owner.
|
|
134
|
+
[w => this.owner.driver.executeScript(`return getCode()`)],
|
|
135
135
|
[w => this.owner.fillFormValue({target: By.xpath('//ngx-captcha/div/div/input[@type="text"]'), value: w.getRes(0)}),
|
|
136
136
|
w => w.getRes(0)],
|
|
137
137
|
[w => this.owner.click(By.xpath('//ngx-captcha/div/div/input[@type="button"]')),
|
|
@@ -150,7 +150,7 @@ class SipdApp {
|
|
|
150
150
|
|
|
151
151
|
showMessage(title, message) {
|
|
152
152
|
if (this.owner._url) {
|
|
153
|
-
return this.owner.
|
|
153
|
+
return this.owner.driver.executeScript(SipdScript.bootstrapModal(title, message));
|
|
154
154
|
} else {
|
|
155
155
|
return Promise.resolve(console.log(message));
|
|
156
156
|
}
|
package/sipd/modules/subkeg.js
CHANGED
|
@@ -135,7 +135,7 @@ class SipdSubkeg {
|
|
|
135
135
|
return new Promise((resolve, reject) => {
|
|
136
136
|
const f = () => {
|
|
137
137
|
this.owner.works([
|
|
138
|
-
[w => this.owner.
|
|
138
|
+
[w => this.owner.driver.get(url)],
|
|
139
139
|
[w => this.owner.waitForResponse([
|
|
140
140
|
'/api/renja/rinci_sub_bl/get_by_id_sub_bl',
|
|
141
141
|
'/api/renja/subs_sub_bl/find_by_id_list',
|