node-hp-scan-to 1.0.1 → 1.2.1

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.
Files changed (68) hide show
  1. package/README.md +92 -11
  2. package/dist/Destination.d.ts +8 -7
  3. package/dist/Destination.js +115 -84
  4. package/dist/Destination.js.map +1 -1
  5. package/dist/Event.d.ts +21 -17
  6. package/dist/Event.js +46 -30
  7. package/dist/Event.js.map +1 -1
  8. package/dist/EventTable.d.ts +11 -11
  9. package/dist/EventTable.js +26 -26
  10. package/dist/EventTable.js.map +1 -1
  11. package/dist/HPApi.d.ts +42 -29
  12. package/dist/HPApi.js +528 -333
  13. package/dist/HPApi.js.map +1 -1
  14. package/dist/Job.d.ts +36 -24
  15. package/dist/Job.js +94 -62
  16. package/dist/Job.js.map +1 -1
  17. package/dist/JpegUtil.d.ts +26 -0
  18. package/dist/JpegUtil.js +238 -0
  19. package/dist/JpegUtil.js.map +1 -0
  20. package/dist/PathHelper.d.ts +5 -0
  21. package/dist/PathHelper.js +79 -0
  22. package/dist/PathHelper.js.map +1 -0
  23. package/dist/ScanContent.d.ts +12 -0
  24. package/dist/ScanContent.js +82 -0
  25. package/dist/ScanContent.js.map +1 -0
  26. package/dist/ScanJobSettings.d.ts +6 -6
  27. package/dist/ScanJobSettings.js +95 -94
  28. package/dist/ScanJobSettings.js.map +1 -1
  29. package/dist/ScanStatus.d.ts +18 -18
  30. package/dist/ScanStatus.js +35 -29
  31. package/dist/ScanStatus.js.map +1 -1
  32. package/dist/WalkupScanDestination.d.ts +24 -24
  33. package/dist/WalkupScanDestination.js +40 -40
  34. package/dist/WalkupScanDestination.js.map +1 -1
  35. package/dist/WalkupScanDestinations.d.ts +11 -11
  36. package/dist/WalkupScanDestinations.js +26 -26
  37. package/dist/WalkupScanDestinations.js.map +1 -1
  38. package/dist/WalkupScanToCompDestination.d.ts +26 -0
  39. package/dist/WalkupScanToCompDestination.js +44 -0
  40. package/dist/WalkupScanToCompDestination.js.map +1 -0
  41. package/dist/WalkupScanToCompDestinations.d.ts +11 -0
  42. package/dist/WalkupScanToCompDestinations.js +27 -0
  43. package/dist/WalkupScanToCompDestinations.js.map +1 -0
  44. package/dist/WalkupScanToCompEvent.d.ts +10 -0
  45. package/dist/WalkupScanToCompEvent.js +17 -0
  46. package/dist/WalkupScanToCompEvent.js.map +1 -0
  47. package/dist/index.d.ts +2 -2
  48. package/dist/index.js +630 -292
  49. package/dist/index.js.map +1 -1
  50. package/nodemon.json +5 -5
  51. package/package.json +72 -57
  52. package/src/Destination.ts +63 -45
  53. package/src/Event.ts +45 -31
  54. package/src/EventTable.ts +25 -25
  55. package/src/HPApi.ts +365 -222
  56. package/src/Job.ts +100 -62
  57. package/src/JpegUtil.ts +319 -0
  58. package/src/PathHelper.ts +44 -0
  59. package/src/ScanContent.ts +34 -0
  60. package/src/ScanJobSettings.ts +55 -55
  61. package/src/ScanStatus.ts +36 -31
  62. package/src/WalkupScanDestination.ts +46 -44
  63. package/src/WalkupScanDestinations.ts +29 -27
  64. package/src/WalkupScanToCompDestination.ts +55 -0
  65. package/src/WalkupScanToCompDestinations.ts +34 -0
  66. package/src/WalkupScanToCompEvent.ts +18 -0
  67. package/src/index.ts +555 -205
  68. package/tsconfig.json +34 -0
package/README.md CHANGED
@@ -1,11 +1,92 @@
1
- # node-hp-scan-to
2
-
3
- [![Build Status](https://travis-ci.org/manuc66/node-hp-scan-to.svg?branch=master)](https://travis-ci.org/manuc66/node-hp-scan-to)
4
-
5
- Little command line program that allow to send scan from device to computer.
6
-
7
- Developed and tested for `Officejet 6500 E710n-z [B21113]` (HP Officejet 6500A Plus)
8
-
9
- For this purpose, the original HP Windows application's interaction with the device has been [reverse engineered](protocol_doc/index.md)
10
-
11
- This project is not endorsed by nor affiliated with HP.
1
+ # node-hp-scan-to
2
+
3
+ [![Build Status](https://app.travis-ci.com/manuc66/node-hp-scan-to.svg?branch=master)](https://app.travis-ci.com/manuc66/node-hp-scan-to)
4
+ [![npm](https://img.shields.io/npm/dt/node-hp-scan-to)](https://www.npmjs.com/package/node-hp-scan-to)
5
+ [![Docker Pulls](https://img.shields.io/docker/pulls/manuc66/node-hp-scan-to)](https://hub.docker.com/repository/docker/manuc66/node-hp-scan-to)
6
+ [![Gitter](https://badges.gitter.im/node-hp-scan-to/community.svg)](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`.
@@ -1,7 +1,8 @@
1
- export default class Destination {
2
- private readonly name;
3
- private readonly hostname;
4
- private readonly linkType;
5
- constructor(name: string, hostname: string);
6
- toXML(): Promise<string>;
7
- }
1
+ export default class Destination {
2
+ private readonly name;
3
+ private readonly hostname;
4
+ private readonly linkType;
5
+ private readonly toComp;
6
+ constructor(name: string, hostname: string, toComp: boolean);
7
+ toXML(): Promise<string>;
8
+ }
@@ -1,85 +1,116 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- 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;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- var __importDefault = (this && this.__importDefault) || function (mod) {
38
- return (mod && mod.__esModule) ? mod : { "default": mod };
39
- };
40
- var __importStar = (this && this.__importStar) || function (mod) {
41
- if (mod && mod.__esModule) return mod;
42
- var result = {};
43
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
44
- result["default"] = mod;
45
- return result;
46
- };
47
- Object.defineProperty(exports, "__esModule", { value: true });
48
- var xml2js_1 = __importDefault(require("xml2js"));
49
- var util = __importStar(require("util"));
50
- var parser = new xml2js_1.default.Parser();
51
- var Destination = /** @class */ (function () {
52
- function Destination(name, hostname) {
53
- this.name = name;
54
- this.hostname = hostname;
55
- this.linkType = "Network";
56
- }
57
- Destination.prototype.toXML = function () {
58
- return __awaiter(this, void 0, void 0, function () {
59
- var rawDestination, parsed, builder;
60
- return __generator(this, function (_a) {
61
- switch (_a.label) {
62
- case 0:
63
- rawDestination = '<?xml version="1.0" encoding="UTF-8"?>\n' +
64
- '<WalkupScanDestination xmlns="http://www.hp.com/schemas/imaging/con/rest/walkupscan/2009/09/21" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \n' +
65
- 'xsi:schemaLocation="http://www.hp.com/schemas/imaging/con/rest/walkupscan/2009/09/21 WalkupScanDestinations.xsd">\n' +
66
- '<Hostname xmlns="http://www.hp.com/schemas/imaging/con/dictionaries/2009/04/06"></Hostname>\n' +
67
- '<Name xmlns="http://www.hp.com/schemas/imaging/con/dictionaries/1.0/"></Name>\n' +
68
- "<LinkType>Network</LinkType>\n" +
69
- "</WalkupScanDestination>";
70
- return [4 /*yield*/, util.promisify(parser.parseString)(rawDestination)];
71
- case 1:
72
- parsed = _a.sent();
73
- parsed.WalkupScanDestination.Hostname[0]._ = this.hostname;
74
- parsed.WalkupScanDestination.Name[0]._ = this.name;
75
- parsed.WalkupScanDestination.LinkType[0] = this.linkType;
76
- builder = new xml2js_1.default.Builder();
77
- return [2 /*return*/, builder.buildObject(parsed)];
78
- }
79
- });
80
- });
81
- };
82
- return Destination;
83
- }());
84
- exports.default = Destination;
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;
85
116
  //# sourceMappingURL=Destination.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Destination.js","sourceRoot":"","sources":["../src/Destination.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,kDAA4B;AAC5B,yCAA6B;AAC7B,IAAM,MAAM,GAAG,IAAI,gBAAM,CAAC,MAAM,EAAE,CAAC;AAUnC;IAKE,qBAAY,IAAY,EAAE,QAAgB;QACxC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;IAC5B,CAAC;IAEK,2BAAK,GAAX;;;;;;wBACM,cAAc,GAChB,0CAA0C;4BAC1C,0JAA0J;4BAC1J,qHAAqH;4BACrH,+FAA+F;4BAC/F,iFAAiF;4BACjF,gCAAgC;4BAChC,0BAA0B,CAAC;wBAEd,qBAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,EAAA;;wBAAjE,MAAM,GAAG,SAAqF;wBAEpG,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,gBAAM,CAAC,OAAO,EAAE,CAAC;wBACnC,sBAAO,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,EAAC;;;;KACpC;IACH,kBAAC;AAAD,CAAC,AA9BD,IA8BC","sourcesContent":["\"use strict\";\r\n\r\nimport xml2js from \"xml2js\";\r\nimport * as util from \"util\";\r\nconst parser = new xml2js.Parser();\r\n\r\ntype WalkupScanDestinationData = {\r\n WalkupScanDestination: {\r\n Hostname: { _: string }[];\r\n Name: { _: string }[];\r\n LinkType: string[];\r\n };\r\n}\r\n\r\nexport default class Destination {\r\n private readonly name: string;\r\n private readonly hostname: string;\r\n private readonly linkType: string;\r\n\r\n constructor(name: string, hostname: string) {\r\n this.name = name;\r\n this.hostname = hostname;\r\n this.linkType = \"Network\";\r\n }\r\n\r\n async toXML() {\r\n let rawDestination =\r\n '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n' +\r\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' +\r\n 'xsi:schemaLocation=\"http://www.hp.com/schemas/imaging/con/rest/walkupscan/2009/09/21 WalkupScanDestinations.xsd\">\\n' +\r\n '<Hostname xmlns=\"http://www.hp.com/schemas/imaging/con/dictionaries/2009/04/06\"></Hostname>\\n' +\r\n '<Name xmlns=\"http://www.hp.com/schemas/imaging/con/dictionaries/1.0/\"></Name>\\n' +\r\n \"<LinkType>Network</LinkType>\\n\" +\r\n \"</WalkupScanDestination>\";\r\n\r\n const parsed = await util.promisify(parser.parseString)(rawDestination) as WalkupScanDestinationData;\r\n\r\n parsed.WalkupScanDestination.Hostname[0]._ = this.hostname;\r\n parsed.WalkupScanDestination.Name[0]._ = this.name;\r\n parsed.WalkupScanDestination.LinkType[0] = this.linkType;\r\n\r\n let builder = new xml2js.Builder();\r\n return builder.buildObject(parsed);\r\n }\r\n}\r\n"]}
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 CHANGED
@@ -1,17 +1,21 @@
1
- export declare type EventData = {
2
- "dd:UnqualifiedEventCategory": string[];
3
- "ev:Payload": {
4
- "0": {
5
- "dd:ResourceURI": {
6
- "0": string;
7
- };
8
- };
9
- };
10
- };
11
- export default class Event {
12
- private readonly data;
13
- constructor(data: EventData);
14
- readonly unqualifiedEventCategory: string;
15
- readonly resourceURI: string;
16
- readonly isScanEvent: boolean;
17
- }
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 CHANGED
@@ -1,31 +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: true,
12
- configurable: true
13
- });
14
- Object.defineProperty(Event.prototype, "resourceURI", {
15
- get: function () {
16
- return this.data["ev:Payload"]["0"]["dd:ResourceURI"]["0"];
17
- },
18
- enumerable: true,
19
- configurable: true
20
- });
21
- Object.defineProperty(Event.prototype, "isScanEvent", {
22
- get: function () {
23
- return this.unqualifiedEventCategory === "ScanEvent";
24
- },
25
- enumerable: true,
26
- configurable: true
27
- });
28
- return Event;
29
- }());
30
- exports.default = Event;
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;
31
47
  //# sourceMappingURL=Event.js.map
package/dist/Event.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Event.js","sourceRoot":"","sources":["../src/Event.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAab;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,8BAAW;aAAf;YACE,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC;QAC7D,CAAC;;;OAAA;IAED,sBAAI,8BAAW;aAAf;YACE,OAAO,IAAI,CAAC,wBAAwB,KAAK,WAAW,CAAC;QACvD,CAAC;;;OAAA;IACH,YAAC;AAAD,CAAC,AAjBD,IAiBC","sourcesContent":["\"use strict\";\r\n\r\nexport type EventData = {\r\n \"dd:UnqualifiedEventCategory\": string[];\r\n \"ev:Payload\": {\r\n \"0\": {\r\n \"dd:ResourceURI\": {\r\n \"0\": string\r\n };\r\n }\r\n };\r\n};\r\n\r\nexport default class Event {\r\n private readonly data: EventData;\r\n constructor(data: EventData) {\r\n this.data = data;\r\n }\r\n\r\n get unqualifiedEventCategory(): string {\r\n return this.data[\"dd:UnqualifiedEventCategory\"][0];\r\n }\r\n\r\n get resourceURI(): string {\r\n return this.data[\"ev:Payload\"][\"0\"][\"dd:ResourceURI\"][\"0\"];\r\n }\r\n\r\n get isScanEvent(): boolean {\r\n return this.unqualifiedEventCategory === \"ScanEvent\";\r\n }\r\n}\r\n"]}
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"]}
@@ -1,11 +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
- readonly events: Event[];
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
+ }
@@ -1,27 +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: true,
22
- configurable: true
23
- });
24
- return EventTable;
25
- }());
26
- exports.default = EventTable;
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
27
  //# sourceMappingURL=EventTable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EventTable.js","sourceRoot":"","sources":["../src/EventTable.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AAEb,kDAAyC;AAQzC;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,UAAA,CAAC,IAAI,OAAA,IAAI,eAAK,CAAC,CAAC,CAAC,EAAZ,CAAY,CAAC,CAAC;aACtD;iBAAM;gBACL,OAAO,EAAE,CAAC;aACX;QACH,CAAC;;;OAAA;IACH,iBAAC;AAAD,CAAC,AAdD,IAcC","sourcesContent":["\"use strict\";\r\n\r\nimport Event, {EventData} from \"./Event\";\r\n\r\nexport interface EventTableData {\r\n \"ev:EventTable\"? : {\r\n \"ev:Event\"?: EventData[]\r\n }\r\n}\r\n\r\nexport default class EventTable {\r\n private readonly data: EventTableData;\r\n constructor(data: EventTableData) {\r\n this.data = data;\r\n }\r\n\r\n get events() {\r\n let eventTable = this.data[\"ev:EventTable\"];\r\n if (eventTable != null && eventTable[\"ev:Event\"] != null) {\r\n return eventTable[\"ev:Event\"].map(x => new Event(x));\r\n } else {\r\n return [];\r\n }\r\n }\r\n}\r\n"]}
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"]}