node-hp-scan-to 1.0.0 → 1.2.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/README.md +92 -11
- package/dist/Destination.d.ts +8 -0
- package/dist/Destination.js +116 -0
- package/dist/Destination.js.map +1 -0
- package/dist/Event.d.ts +21 -0
- package/dist/Event.js +47 -0
- package/dist/Event.js.map +1 -0
- package/dist/EventTable.d.ts +11 -0
- package/dist/EventTable.js +27 -0
- package/dist/EventTable.js.map +1 -0
- package/dist/HPApi.d.ts +42 -0
- package/dist/HPApi.js +529 -0
- package/dist/HPApi.js.map +1 -0
- package/dist/Job.d.ts +36 -0
- package/dist/Job.js +95 -0
- package/dist/Job.js.map +1 -0
- package/dist/JpegUtil.d.ts +26 -0
- package/dist/JpegUtil.js +238 -0
- package/dist/JpegUtil.js.map +1 -0
- package/dist/PathHelper.d.ts +5 -0
- package/dist/PathHelper.js +79 -0
- package/dist/PathHelper.js.map +1 -0
- package/dist/ScanContent.d.ts +12 -0
- package/dist/ScanContent.js +82 -0
- package/dist/ScanContent.js.map +1 -0
- package/dist/ScanJobSettings.d.ts +6 -0
- package/dist/ScanJobSettings.js +96 -0
- package/dist/ScanJobSettings.js.map +1 -0
- package/dist/ScanStatus.d.ts +18 -0
- package/dist/ScanStatus.js +36 -0
- package/dist/ScanStatus.js.map +1 -0
- package/dist/WalkupScanDestination.d.ts +24 -0
- package/dist/WalkupScanDestination.js +41 -0
- package/dist/WalkupScanDestination.js.map +1 -0
- package/dist/WalkupScanDestinations.d.ts +11 -0
- package/dist/WalkupScanDestinations.js +27 -0
- package/dist/WalkupScanDestinations.js.map +1 -0
- package/dist/WalkupScanToCompDestination.d.ts +26 -0
- package/dist/WalkupScanToCompDestination.js +44 -0
- package/dist/WalkupScanToCompDestination.js.map +1 -0
- package/dist/WalkupScanToCompDestinations.d.ts +11 -0
- package/dist/WalkupScanToCompDestinations.js +27 -0
- package/dist/WalkupScanToCompDestinations.js.map +1 -0
- package/dist/WalkupScanToCompEvent.d.ts +10 -0
- package/dist/WalkupScanToCompEvent.js +17 -0
- package/dist/WalkupScanToCompEvent.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +630 -292
- package/dist/index.js.map +1 -0
- package/nodemon.json +5 -5
- package/package.json +72 -51
- package/src/Destination.ts +63 -45
- package/src/Event.ts +45 -31
- package/src/EventTable.ts +25 -25
- package/src/HPApi.ts +365 -222
- package/src/Job.ts +100 -62
- package/src/JpegUtil.ts +319 -0
- package/src/PathHelper.ts +44 -0
- package/src/ScanContent.ts +34 -0
- package/src/ScanJobSettings.ts +55 -55
- package/src/ScanStatus.ts +36 -31
- package/src/WalkupScanDestination.ts +46 -44
- package/src/WalkupScanDestinations.ts +29 -27
- package/src/WalkupScanToCompDestination.ts +55 -0
- package/src/WalkupScanToCompDestinations.ts +34 -0
- package/src/WalkupScanToCompEvent.ts +18 -0
- package/src/index.ts +555 -205
- package/tsconfig.json +33 -33
- package/.travis.yml +0 -13
- package/protocol_doc/index.md +0 -1484
- package/test/dummy.js +0 -0
package/README.md
CHANGED
|
@@ -1,11 +1,92 @@
|
|
|
1
|
-
# node-hp-scan-to
|
|
2
|
-
|
|
3
|
-
[](https://app.travis-ci.com/manuc66/node-hp-scan-to)
|
|
4
|
+
[](https://www.npmjs.com/package/node-hp-scan-to)
|
|
5
|
+
[](https://hub.docker.com/repository/docker/manuc66/node-hp-scan-to)
|
|
6
|
+
[](https://gitter.im/node-hp-scan-to/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
|
7
|
+
|
|
8
|
+
Little command line program that allow to send scan from device to computer.
|
|
9
|
+
|
|
10
|
+
Developed and tested for the following HP All-in-One Printers:
|
|
11
|
+
- HP Officejet 6500A Plus
|
|
12
|
+
- HP Deskjet 3520
|
|
13
|
+
- HP Smart Tank Plus 570 series
|
|
14
|
+
|
|
15
|
+
The following printer are also working:
|
|
16
|
+
- Officejet 6700 premium
|
|
17
|
+
- HP Officejet 5740
|
|
18
|
+
- HP OfficeJet Pro 8025e
|
|
19
|
+
|
|
20
|
+
There are good chances it also works on your HP All-in-One Printer.
|
|
21
|
+
For this purpose, the original HP Windows application's interaction with the device has been [reverse engineered](protocol_doc/HP%20Officejet%206500%20E710n-z.md).
|
|
22
|
+
|
|
23
|
+
This project is not endorsed by nor affiliated with HP.
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
```sh
|
|
27
|
+
git clone ...
|
|
28
|
+
cd node-hp-scan-to
|
|
29
|
+
yarn install -d
|
|
30
|
+
yarn build
|
|
31
|
+
# now start the program with the ip or name of the desired printer
|
|
32
|
+
node dist/index.js -ip 192.168.1.4 # or -n "Officejet 6500 E710n-z"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Command line options
|
|
36
|
+
- `-ip` or `--address` followed by the ip address of the printer, i.e. `-ip 192.168.0.5`. This overrides `-p`.
|
|
37
|
+
- `-n` or `--name` followed by the printer name, it probably contains spaces, so it needs to be quoted, i.e. `-name "Officejet 6500 E710n-z"`
|
|
38
|
+
- `-d` or `--directory` followed by the directory path where the scanned documents should be saved, i.e. `-d ~/Documents/Scans`. Defaults to `/tmp/scan-to-pc<random value>` when not set.
|
|
39
|
+
- `-p` or `--pattern` followed by the pattern for the filename without file extension, i.e. `"scan"_dd.mm.yyyy_hh:MM:ss` to name the scanned file `scan_19.04.2021_17:26:47`. Date and time patterns are replaced by the current date and time, text that should not be replaced need to be inside quotes. Documentation for the pattern can be found [here](https://www.npmjs.com/package/dateformat) in the section `Mask options`. Defaults to `scan<increasing number>_page<page number>` when not set.
|
|
40
|
+
- `-D, --debug"` enables debug logs.
|
|
41
|
+
|
|
42
|
+
### Run with docker
|
|
43
|
+
Be aware that with docker you have to specify the ip address of the printer via the `IP` environment variable, because
|
|
44
|
+
bonjour service discovery uses multicast network traffic which by default doesn't work in docker.
|
|
45
|
+
You could however use docker's macvlan networking, this way you can use service discovery and the `NAME` environment variable.
|
|
46
|
+
|
|
47
|
+
All scanned files are written to the volume `/scan`, the filename can be changed with the `PATTERN` environment variable.
|
|
48
|
+
For the correct permissions to the volume set the environment variables `PUID` and `PGID`.
|
|
49
|
+
|
|
50
|
+
To enable debug logs set the environment variable `CMDLINE` to `-D`. Can also be used for any other command line parameters.
|
|
51
|
+
|
|
52
|
+
The name shown on the printer's display is the hostname of the docker container, which defaults to a random value, so you may want to specify it via the `-hostname` argument.
|
|
53
|
+
|
|
54
|
+
Example for docker:
|
|
55
|
+
```sh
|
|
56
|
+
git clone ...
|
|
57
|
+
cd node-hp-scan-to
|
|
58
|
+
docker build . -t node-hp-scan-to
|
|
59
|
+
docker run -e IP=192.168.0.5 -e PGID=1000 -e PUID=1000 --hostname scan node-hp-scan-to
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Example for docker-compose:
|
|
63
|
+
Write the following `docker-compose.yml` file into this directory:
|
|
64
|
+
```yml
|
|
65
|
+
version: "3"
|
|
66
|
+
|
|
67
|
+
services:
|
|
68
|
+
node-hp-scan-to:
|
|
69
|
+
build:
|
|
70
|
+
context: .
|
|
71
|
+
dockerfile: Dockerfile
|
|
72
|
+
container_name: node-hp-scan-to
|
|
73
|
+
hostname: scan
|
|
74
|
+
environment:
|
|
75
|
+
- IP=192.168.0.5
|
|
76
|
+
- PATTERN="scan"_dd.mm.yyyy_hh:MM:ss
|
|
77
|
+
- PGID=1000
|
|
78
|
+
- PUID=1000
|
|
79
|
+
- TZ=Europe/London
|
|
80
|
+
volumes:
|
|
81
|
+
- /some/host/directory/or/volume:/scan
|
|
82
|
+
restart: always
|
|
83
|
+
```
|
|
84
|
+
Then run `docker-compose up -d --build`.
|
|
85
|
+
To
|
|
86
|
+
|
|
87
|
+
Public Pre-built Docker image:
|
|
88
|
+
- https://hub.docker.com/repository/docker/manuc66/node-hp-scan-to
|
|
89
|
+
|
|
90
|
+
## Debugging
|
|
91
|
+
I'm using Visual Studio Code to debug this application, so instead of running ts-node just enter `code .` and press F5 to start debugging.
|
|
92
|
+
You may want to set your printers ip or name in `.vscode/launch.json`.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (_) try {
|
|
41
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
var xml2js_1 = require("xml2js");
|
|
63
|
+
var util = __importStar(require("util"));
|
|
64
|
+
var parser = new xml2js_1.Parser();
|
|
65
|
+
var Destination = /** @class */ (function () {
|
|
66
|
+
function Destination(name, hostname, toComp) {
|
|
67
|
+
this.name = name;
|
|
68
|
+
this.hostname = hostname;
|
|
69
|
+
this.linkType = "Network";
|
|
70
|
+
this.toComp = toComp;
|
|
71
|
+
}
|
|
72
|
+
Destination.prototype.toXML = function () {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
+
var rawDestination, parsed, builder, xml;
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
switch (_a.label) {
|
|
77
|
+
case 0:
|
|
78
|
+
rawDestination = '<?xml version="1.0" encoding="UTF-8"?>\n';
|
|
79
|
+
if (this.toComp) {
|
|
80
|
+
rawDestination +=
|
|
81
|
+
'<WalkupScanDestination xmlns="http://www.hp.com/schemas/imaging/con/ledm/walkupscan/2010/09/28" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
|
82
|
+
'xsi:schemaLocation="http://www.hp.com/schemas/imaging/con/ledm/walkupscan/2010/09/28 WalkupScan.xsd">\n';
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
rawDestination +=
|
|
86
|
+
'<WalkupScanDestination xmlns="http://www.hp.com/schemas/imaging/con/rest/walkupscan/2009/09/21" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \n' +
|
|
87
|
+
'xsi:schemaLocation="http://www.hp.com/schemas/imaging/con/rest/walkupscan/2009/09/21 WalkupScanDestinations.xsd">\n';
|
|
88
|
+
}
|
|
89
|
+
rawDestination +=
|
|
90
|
+
'\t<Hostname xmlns="http://www.hp.com/schemas/imaging/con/dictionaries/2009/04/06"></Hostname>\n' +
|
|
91
|
+
'\t<Name xmlns="http://www.hp.com/schemas/imaging/con/dictionaries/1.0/"></Name>\n' +
|
|
92
|
+
"\t<LinkType>Network</LinkType>\n" +
|
|
93
|
+
"</WalkupScanDestination>";
|
|
94
|
+
return [4 /*yield*/, util.promisify(parser.parseString)(rawDestination)];
|
|
95
|
+
case 1:
|
|
96
|
+
parsed = _a.sent();
|
|
97
|
+
parsed.WalkupScanDestination.Hostname[0]._ = this.hostname;
|
|
98
|
+
parsed.WalkupScanDestination.Name[0]._ = this.name;
|
|
99
|
+
parsed.WalkupScanDestination.LinkType[0] = this.linkType;
|
|
100
|
+
builder = new xml2js_1.Builder();
|
|
101
|
+
xml = builder.buildObject(parsed);
|
|
102
|
+
if (this.toComp) {
|
|
103
|
+
return [2 /*return*/, xml.replace(/WalkupScan/g, "WalkupScanToComp")];
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
return [2 /*return*/, xml];
|
|
107
|
+
}
|
|
108
|
+
return [2 /*return*/];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
return Destination;
|
|
114
|
+
}());
|
|
115
|
+
exports.default = Destination;
|
|
116
|
+
//# sourceMappingURL=Destination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Destination.js","sourceRoot":"","sources":["../src/Destination.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,iCAAuC;AACvC,yCAA6B;AAE7B,IAAM,MAAM,GAAG,IAAI,eAAM,EAAE,CAAC;AAU5B;IAME,qBAAY,IAAY,EAAE,QAAgB,EAAE,MAAe;QACzD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEK,2BAAK,GAAX;;;;;;wBACM,cAAc,GAAW,0CAA0C,CAAC;wBACxE,IAAI,IAAI,CAAC,MAAM,EAAE;4BACf,cAAc;gCACZ,wJAAwJ;oCACxJ,yGAAyG,CAAC;yBAC7G;6BAAM;4BACL,cAAc;gCACZ,0JAA0J;oCAC1J,qHAAqH,CAAC;yBACzH;wBAED,cAAc;4BACZ,iGAAiG;gCACjG,mFAAmF;gCACnF,kCAAkC;gCAClC,0BAA0B,CAAC;wBAEd,qBAAM,IAAI,CAAC,SAAS,CACjC,MAAM,CAAC,WAAW,CACnB,CAAC,cAAc,CAAC,EAAA;;wBAFX,MAAM,GAAG,SAEE;wBAEjB,MAAM,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;wBAC3D,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;wBACnD,MAAM,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;wBAErD,OAAO,GAAG,IAAI,gBAAO,EAAE,CAAC;wBACxB,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;wBACtC,IAAI,IAAI,CAAC,MAAM,EAAE;4BACf,sBAAO,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,kBAAkB,CAAC,EAAC;yBACvD;6BAAM;4BACL,sBAAO,GAAG,EAAC;yBACZ;;;;;KACF;IACH,kBAAC;AAAD,CAAC,AA/CD,IA+CC","sourcesContent":["\"use strict\";\n\nimport {Parser, Builder} from \"xml2js\";\nimport * as util from \"util\";\n\nconst parser = new Parser();\n\ntype WalkupScanDestinationData = {\n WalkupScanDestination: {\n Hostname: { _: string }[];\n Name: { _: string }[];\n LinkType: string[];\n };\n};\n\nexport default class Destination {\n private readonly name: string;\n private readonly hostname: string;\n private readonly linkType: string;\n private readonly toComp: boolean;\n\n constructor(name: string, hostname: string, toComp: boolean) {\n this.name = name;\n this.hostname = hostname;\n this.linkType = \"Network\";\n this.toComp = toComp;\n }\n\n async toXML() {\n let rawDestination: string = '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n';\n if (this.toComp) {\n rawDestination +=\n '<WalkupScanDestination xmlns=\"http://www.hp.com/schemas/imaging/con/ledm/walkupscan/2010/09/28\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ' +\n 'xsi:schemaLocation=\"http://www.hp.com/schemas/imaging/con/ledm/walkupscan/2010/09/28 WalkupScan.xsd\">\\n';\n } else {\n rawDestination +=\n '<WalkupScanDestination xmlns=\"http://www.hp.com/schemas/imaging/con/rest/walkupscan/2009/09/21\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \\n' +\n 'xsi:schemaLocation=\"http://www.hp.com/schemas/imaging/con/rest/walkupscan/2009/09/21 WalkupScanDestinations.xsd\">\\n';\n }\n\n rawDestination +=\n '\\t<Hostname xmlns=\"http://www.hp.com/schemas/imaging/con/dictionaries/2009/04/06\"></Hostname>\\n' +\n '\\t<Name xmlns=\"http://www.hp.com/schemas/imaging/con/dictionaries/1.0/\"></Name>\\n' +\n \"\\t<LinkType>Network</LinkType>\\n\" +\n \"</WalkupScanDestination>\";\n\n const parsed = await util.promisify<string, WalkupScanDestinationData>(\n parser.parseString\n )(rawDestination);\n\n parsed.WalkupScanDestination.Hostname[0]._ = this.hostname;\n parsed.WalkupScanDestination.Name[0]._ = this.name;\n parsed.WalkupScanDestination.LinkType[0] = this.linkType;\n\n let builder = new Builder();\n let xml = builder.buildObject(parsed);\n if (this.toComp) {\n return xml.replace(/WalkupScan/g, \"WalkupScanToComp\");\n } else {\n return xml;\n }\n }\n}\n"]}
|
package/dist/Event.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare type EventData = {
|
|
2
|
+
"dd:UnqualifiedEventCategory": string[];
|
|
3
|
+
"dd:AgingStamp": string[];
|
|
4
|
+
"ev:Payload": {
|
|
5
|
+
"dd:ResourceURI": {
|
|
6
|
+
"0": string;
|
|
7
|
+
};
|
|
8
|
+
"dd:ResourceType": {
|
|
9
|
+
"0": string;
|
|
10
|
+
};
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
13
|
+
export default class Event {
|
|
14
|
+
private readonly data;
|
|
15
|
+
constructor(data: EventData);
|
|
16
|
+
get unqualifiedEventCategory(): string;
|
|
17
|
+
get agingStamp(): string;
|
|
18
|
+
get destinationURI(): string | undefined;
|
|
19
|
+
get compEventURI(): string | undefined;
|
|
20
|
+
get isScanEvent(): boolean;
|
|
21
|
+
}
|
package/dist/Event.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var Event = /** @class */ (function () {
|
|
4
|
+
function Event(data) {
|
|
5
|
+
this.data = data;
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(Event.prototype, "unqualifiedEventCategory", {
|
|
8
|
+
get: function () {
|
|
9
|
+
return this.data["dd:UnqualifiedEventCategory"][0];
|
|
10
|
+
},
|
|
11
|
+
enumerable: false,
|
|
12
|
+
configurable: true
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(Event.prototype, "agingStamp", {
|
|
15
|
+
get: function () {
|
|
16
|
+
return this.data["dd:AgingStamp"][0];
|
|
17
|
+
},
|
|
18
|
+
enumerable: false,
|
|
19
|
+
configurable: true
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(Event.prototype, "destinationURI", {
|
|
22
|
+
get: function () {
|
|
23
|
+
var destination = this.data["ev:Payload"].find(function (v) { return v["dd:ResourceType"]["0"].includes("Destination"); });
|
|
24
|
+
return destination ? destination["dd:ResourceURI"]["0"] : undefined;
|
|
25
|
+
},
|
|
26
|
+
enumerable: false,
|
|
27
|
+
configurable: true
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(Event.prototype, "compEventURI", {
|
|
30
|
+
get: function () {
|
|
31
|
+
var compEvent = this.data["ev:Payload"].find(function (v) { return v["dd:ResourceType"]["0"].includes("CompEvent"); });
|
|
32
|
+
return compEvent ? compEvent["dd:ResourceURI"]["0"] : undefined;
|
|
33
|
+
},
|
|
34
|
+
enumerable: false,
|
|
35
|
+
configurable: true
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(Event.prototype, "isScanEvent", {
|
|
38
|
+
get: function () {
|
|
39
|
+
return this.unqualifiedEventCategory === "ScanEvent";
|
|
40
|
+
},
|
|
41
|
+
enumerable: false,
|
|
42
|
+
configurable: true
|
|
43
|
+
});
|
|
44
|
+
return Event;
|
|
45
|
+
}());
|
|
46
|
+
exports.default = Event;
|
|
47
|
+
//# sourceMappingURL=Event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Event.js","sourceRoot":"","sources":["../src/Event.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAeb;IAEE,eAAY,IAAe;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,sBAAI,2CAAwB;aAA5B;YACE,OAAO,IAAI,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC;QACrD,CAAC;;;OAAA;IAED,sBAAI,6BAAU;aAAd;YACE,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC;;;OAAA;IAED,sBAAI,iCAAc;aAAlB;YACE,IAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAjD,CAAiD,CAAC,CAAC;YAEzG,OAAO,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACtE,CAAC;;;OAAA;IAED,sBAAI,+BAAY;aAAhB;YACE,IAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAA/C,CAA+C,CAAC,CAAC;YAErG,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAClE,CAAC;;;OAAA;IAED,sBAAI,8BAAW;aAAf;YACE,OAAO,IAAI,CAAC,wBAAwB,KAAK,WAAW,CAAC;QACvD,CAAC;;;OAAA;IACH,YAAC;AAAD,CAAC,AA7BD,IA6BC","sourcesContent":["\"use strict\";\n\nexport type EventData = {\n \"dd:UnqualifiedEventCategory\": string[];\n \"dd:AgingStamp\": string[];\n \"ev:Payload\": {\n \"dd:ResourceURI\": {\n \"0\": string;\n },\n \"dd:ResourceType\": {\n \"0\": string;\n };\n }[];\n};\n\nexport default class Event {\n private readonly data: EventData;\n constructor(data: EventData) {\n this.data = data;\n }\n\n get unqualifiedEventCategory(): string {\n return this.data[\"dd:UnqualifiedEventCategory\"][0];\n }\n\n get agingStamp(): string {\n return this.data[\"dd:AgingStamp\"][0];\n }\n\n get destinationURI(): string | undefined {\n const destination = this.data[\"ev:Payload\"].find(v => v[\"dd:ResourceType\"][\"0\"].includes(\"Destination\"));\n\n return destination ? destination[\"dd:ResourceURI\"][\"0\"] : undefined;\n }\n\n get compEventURI(): string | undefined {\n const compEvent = this.data[\"ev:Payload\"].find(v => v[\"dd:ResourceType\"][\"0\"].includes(\"CompEvent\"));\n\n return compEvent ? compEvent[\"dd:ResourceURI\"][\"0\"] : undefined;\n }\n\n get isScanEvent(): boolean {\n return this.unqualifiedEventCategory === \"ScanEvent\";\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Event, { EventData } from "./Event";
|
|
2
|
+
export interface EventTableData {
|
|
3
|
+
"ev:EventTable"?: {
|
|
4
|
+
"ev:Event"?: EventData[];
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export default class EventTable {
|
|
8
|
+
private readonly data;
|
|
9
|
+
constructor(data: EventTableData);
|
|
10
|
+
get events(): Event[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var Event_1 = __importDefault(require("./Event"));
|
|
7
|
+
var EventTable = /** @class */ (function () {
|
|
8
|
+
function EventTable(data) {
|
|
9
|
+
this.data = data;
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(EventTable.prototype, "events", {
|
|
12
|
+
get: function () {
|
|
13
|
+
var eventTable = this.data["ev:EventTable"];
|
|
14
|
+
if (eventTable != null && eventTable["ev:Event"] != null) {
|
|
15
|
+
return eventTable["ev:Event"].map(function (x) { return new Event_1.default(x); });
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
enumerable: false,
|
|
22
|
+
configurable: true
|
|
23
|
+
});
|
|
24
|
+
return EventTable;
|
|
25
|
+
}());
|
|
26
|
+
exports.default = EventTable;
|
|
27
|
+
//# sourceMappingURL=EventTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventTable.js","sourceRoot":"","sources":["../src/EventTable.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AAEb,kDAA2C;AAQ3C;IAEE,oBAAY,IAAoB;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,sBAAI,8BAAM;aAAV;YACE,IAAI,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAC5C,IAAI,UAAU,IAAI,IAAI,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE;gBACxD,OAAO,UAAU,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,IAAI,eAAK,CAAC,CAAC,CAAC,EAAZ,CAAY,CAAC,CAAC;aACxD;iBAAM;gBACL,OAAO,EAAE,CAAC;aACX;QACH,CAAC;;;OAAA;IACH,iBAAC;AAAD,CAAC,AAdD,IAcC","sourcesContent":["\"use strict\";\n\nimport Event, { EventData } from \"./Event\";\n\nexport interface EventTableData {\n \"ev:EventTable\"?: {\n \"ev:Event\"?: EventData[];\n };\n}\n\nexport default class EventTable {\n private readonly data: EventTableData;\n constructor(data: EventTableData) {\n this.data = data;\n }\n\n get events() {\n let eventTable = this.data[\"ev:EventTable\"];\n if (eventTable != null && eventTable[\"ev:Event\"] != null) {\n return eventTable[\"ev:Event\"].map((x) => new Event(x));\n } else {\n return [];\n }\n }\n}\n"]}
|
package/dist/HPApi.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import WalkupScanDestination from "./WalkupScanDestination";
|
|
2
|
+
import WalkupScanToCompDestination from "./WalkupScanToCompDestination";
|
|
3
|
+
import { AxiosRequestHeaders } from "axios";
|
|
4
|
+
import EventTable from "./EventTable";
|
|
5
|
+
import Job from "./Job";
|
|
6
|
+
import ScanStatus from "./ScanStatus";
|
|
7
|
+
import WalkupScanDestinations from "./WalkupScanDestinations";
|
|
8
|
+
import WalkupScanToCompDestinations from "./WalkupScanToCompDestinations";
|
|
9
|
+
import ScanJobSettings from "./ScanJobSettings";
|
|
10
|
+
import Destination from "./Destination";
|
|
11
|
+
import WalkupScanToCompEvent from "./WalkupScanToCompEvent";
|
|
12
|
+
export default class HPApi {
|
|
13
|
+
static setPrinterIP(ip: string): void;
|
|
14
|
+
static setDebug(dbg: boolean): void;
|
|
15
|
+
private static logDebug;
|
|
16
|
+
private static callAxios;
|
|
17
|
+
static getWalkupScanDestinations(): Promise<WalkupScanDestinations>;
|
|
18
|
+
static getWalkupScanToCompDestinations(): Promise<WalkupScanToCompDestinations>;
|
|
19
|
+
static getWalkupScanToCompCaps(): Promise<boolean>;
|
|
20
|
+
static getWalkupScanToCompEvent(compEventURI: string): Promise<WalkupScanToCompEvent>;
|
|
21
|
+
static removeDestination(walkupScanDestination: WalkupScanDestination): Promise<boolean>;
|
|
22
|
+
static registerDestination(destination: Destination, toComp: boolean): Promise<string>;
|
|
23
|
+
static getEvents(etag?: string, timeout?: number): Promise<{
|
|
24
|
+
etag: string;
|
|
25
|
+
eventTable: EventTable;
|
|
26
|
+
}>;
|
|
27
|
+
static placeETagHeader(etag: string, headers: AxiosRequestHeaders): AxiosRequestHeaders;
|
|
28
|
+
static appendTimeout(url: string, timeout?: number | null): string;
|
|
29
|
+
static getDestination(destinationURL: string): Promise<WalkupScanDestination | WalkupScanToCompDestination>;
|
|
30
|
+
static createWalkupScanDestination(content: string): Promise<WalkupScanDestination>;
|
|
31
|
+
static createWalkupScanToCompDestination(content: string): Promise<WalkupScanToCompDestination>;
|
|
32
|
+
static createWalkupScanToCompEvent(content: string): Promise<WalkupScanToCompEvent>;
|
|
33
|
+
static getScanStatus(): Promise<ScanStatus>;
|
|
34
|
+
static delay(t: number): Promise<unknown>;
|
|
35
|
+
static postJob(job: ScanJobSettings): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* @param jobURL
|
|
38
|
+
* @return {Promise<Job|*>}
|
|
39
|
+
*/
|
|
40
|
+
static getJob(jobURL: string): Promise<Job>;
|
|
41
|
+
static downloadPage(binaryURL: string, destination: string): Promise<string>;
|
|
42
|
+
}
|