node-hp-scan-to 1.2.2 → 1.3.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.
Files changed (235) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +47 -10
  3. package/dist/Destination.js +36 -84
  4. package/dist/Destination.js.map +1 -1
  5. package/dist/DeviceCapabilities.d.ts +4 -0
  6. package/dist/DeviceCapabilities.js +3 -0
  7. package/dist/DeviceCapabilities.js.map +1 -0
  8. package/dist/DiscoveryTree.d.ts +16 -0
  9. package/dist/DiscoveryTree.js +38 -0
  10. package/dist/DiscoveryTree.js.map +1 -0
  11. package/dist/Event.d.ts +1 -1
  12. package/dist/Event.js +24 -39
  13. package/dist/Event.js.map +1 -1
  14. package/dist/EventTable.d.ts +5 -0
  15. package/dist/EventTable.js +24 -18
  16. package/dist/EventTable.js.map +1 -1
  17. package/dist/HPApi.d.ts +26 -18
  18. package/dist/HPApi.js +386 -461
  19. package/dist/HPApi.js.map +1 -1
  20. package/dist/Job.d.ts +8 -7
  21. package/dist/Job.js +69 -86
  22. package/dist/Job.js.map +1 -1
  23. package/dist/JpegUtil.js +73 -82
  24. package/dist/JpegUtil.js.map +1 -1
  25. package/dist/KnownShortcut.d.ts +1 -0
  26. package/dist/KnownShortcut.js +3 -0
  27. package/dist/KnownShortcut.js.map +1 -0
  28. package/dist/PathHelper.d.ts +2 -1
  29. package/dist/PathHelper.js +41 -68
  30. package/dist/PathHelper.js.map +1 -1
  31. package/dist/ScanCaps.d.ts +7 -0
  32. package/dist/ScanCaps.js +17 -0
  33. package/dist/ScanCaps.js.map +1 -0
  34. package/dist/ScanContent.js +18 -73
  35. package/dist/ScanContent.js.map +1 -1
  36. package/dist/ScanJobManifest.d.ts +23 -0
  37. package/dist/ScanJobManifest.js +24 -0
  38. package/dist/ScanJobManifest.js.map +1 -0
  39. package/dist/ScanJobSettings.d.ts +3 -1
  40. package/dist/ScanJobSettings.js +48 -88
  41. package/dist/ScanJobSettings.js.map +1 -1
  42. package/dist/ScanStatus.d.ts +1 -0
  43. package/dist/ScanStatus.js +27 -28
  44. package/dist/ScanStatus.js.map +1 -1
  45. package/dist/WalkupScanDestination.d.ts +11 -13
  46. package/dist/WalkupScanDestination.js +32 -35
  47. package/dist/WalkupScanDestination.js.map +1 -1
  48. package/dist/WalkupScanDestinations.d.ts +1 -0
  49. package/dist/WalkupScanDestinations.js +21 -18
  50. package/dist/WalkupScanDestinations.js.map +1 -1
  51. package/dist/WalkupScanManifest.d.ts +23 -0
  52. package/dist/WalkupScanManifest.js +25 -0
  53. package/dist/WalkupScanManifest.js.map +1 -0
  54. package/dist/WalkupScanToCompCaps.d.ts +12 -0
  55. package/dist/WalkupScanToCompCaps.js +20 -0
  56. package/dist/WalkupScanToCompCaps.js.map +1 -0
  57. package/dist/WalkupScanToCompDestination.d.ts +10 -14
  58. package/dist/WalkupScanToCompDestination.js +32 -38
  59. package/dist/WalkupScanToCompDestination.js.map +1 -1
  60. package/dist/WalkupScanToCompDestinations.d.ts +1 -0
  61. package/dist/WalkupScanToCompDestinations.js +21 -18
  62. package/dist/WalkupScanToCompDestinations.js.map +1 -1
  63. package/dist/WalkupScanToCompEvent.d.ts +2 -1
  64. package/dist/WalkupScanToCompEvent.js +14 -11
  65. package/dist/WalkupScanToCompEvent.js.map +1 -1
  66. package/dist/WalkupScanToCompManifest.d.ts +23 -0
  67. package/dist/WalkupScanToCompManifest.js +25 -0
  68. package/dist/WalkupScanToCompManifest.js.map +1 -0
  69. package/dist/delay.d.ts +1 -0
  70. package/dist/delay.js +10 -0
  71. package/dist/delay.js.map +1 -0
  72. package/dist/fixJpegSize.d.ts +19 -0
  73. package/dist/fixJpegSize.js +292 -0
  74. package/dist/fixJpegSize.js.map +1 -0
  75. package/dist/index.js +209 -607
  76. package/dist/index.js.map +1 -1
  77. package/dist/listening.d.ts +9 -0
  78. package/dist/listening.js +108 -0
  79. package/dist/listening.js.map +1 -0
  80. package/dist/readDeviceCapabilities.d.ts +2 -0
  81. package/dist/readDeviceCapabilities.js +41 -0
  82. package/dist/readDeviceCapabilities.js.map +1 -0
  83. package/dist/scanProcess.d.ts +19 -0
  84. package/dist/scanProcess.js +292 -0
  85. package/dist/scanProcess.js.map +1 -0
  86. package/dist/scanProcessing.d.ts +20 -0
  87. package/dist/scanProcessing.js +320 -0
  88. package/dist/scanProcessing.js.map +1 -0
  89. package/dist/src/Destination.d.ts +8 -0
  90. package/dist/src/Destination.js +68 -0
  91. package/dist/src/Destination.js.map +1 -0
  92. package/dist/src/DiscoveryTree.d.ts +16 -0
  93. package/dist/src/DiscoveryTree.js +38 -0
  94. package/dist/src/DiscoveryTree.js.map +1 -0
  95. package/dist/src/Event.d.ts +21 -0
  96. package/dist/src/Event.js +32 -0
  97. package/dist/src/Event.js.map +1 -0
  98. package/dist/src/EventTable.d.ts +16 -0
  99. package/dist/src/EventTable.js +33 -0
  100. package/dist/src/EventTable.js.map +1 -0
  101. package/dist/src/HPApi.d.ts +50 -0
  102. package/dist/src/HPApi.js +454 -0
  103. package/dist/src/HPApi.js.map +1 -0
  104. package/dist/src/Job.d.ts +37 -0
  105. package/dist/src/Job.js +78 -0
  106. package/dist/src/Job.js.map +1 -0
  107. package/dist/src/JpegUtil.d.ts +26 -0
  108. package/dist/src/JpegUtil.js +229 -0
  109. package/dist/src/JpegUtil.js.map +1 -0
  110. package/dist/src/KnownShortcut.d.ts +1 -0
  111. package/dist/src/KnownShortcut.js +3 -0
  112. package/dist/src/KnownShortcut.js.map +1 -0
  113. package/dist/src/PathHelper.d.ts +6 -0
  114. package/dist/src/PathHelper.js +52 -0
  115. package/dist/src/PathHelper.js.map +1 -0
  116. package/dist/src/ScanCaps.d.ts +7 -0
  117. package/dist/src/ScanCaps.js +17 -0
  118. package/dist/src/ScanCaps.js.map +1 -0
  119. package/dist/src/ScanJobManifest.d.ts +23 -0
  120. package/dist/src/ScanJobManifest.js +24 -0
  121. package/dist/src/ScanJobManifest.js.map +1 -0
  122. package/dist/src/ScanJobSettings.d.ts +8 -0
  123. package/dist/src/ScanJobSettings.js +56 -0
  124. package/dist/src/ScanJobSettings.js.map +1 -0
  125. package/dist/src/ScanStatus.d.ts +19 -0
  126. package/dist/src/ScanStatus.js +35 -0
  127. package/dist/src/ScanStatus.js.map +1 -0
  128. package/dist/src/WalkupScanDestination.d.ts +22 -0
  129. package/dist/src/WalkupScanDestination.js +38 -0
  130. package/dist/src/WalkupScanDestination.js.map +1 -0
  131. package/dist/src/WalkupScanDestinations.d.ts +12 -0
  132. package/dist/src/WalkupScanDestinations.js +30 -0
  133. package/dist/src/WalkupScanDestinations.js.map +1 -0
  134. package/dist/src/WalkupScanManifest.d.ts +23 -0
  135. package/dist/src/WalkupScanManifest.js +25 -0
  136. package/dist/src/WalkupScanManifest.js.map +1 -0
  137. package/dist/src/WalkupScanToCompCaps.d.ts +12 -0
  138. package/dist/src/WalkupScanToCompCaps.js +20 -0
  139. package/dist/src/WalkupScanToCompCaps.js.map +1 -0
  140. package/dist/src/WalkupScanToCompDestination.d.ts +22 -0
  141. package/dist/src/WalkupScanToCompDestination.js +38 -0
  142. package/dist/src/WalkupScanToCompDestination.js.map +1 -0
  143. package/dist/src/WalkupScanToCompDestinations.d.ts +12 -0
  144. package/dist/src/WalkupScanToCompDestinations.js +30 -0
  145. package/dist/src/WalkupScanToCompDestinations.js.map +1 -0
  146. package/dist/src/WalkupScanToCompEvent.d.ts +11 -0
  147. package/dist/src/WalkupScanToCompEvent.js +20 -0
  148. package/dist/src/WalkupScanToCompEvent.js.map +1 -0
  149. package/dist/src/WalkupScanToCompManifest.d.ts +23 -0
  150. package/dist/src/WalkupScanToCompManifest.js +25 -0
  151. package/dist/src/WalkupScanToCompManifest.js.map +1 -0
  152. package/dist/src/delay.d.ts +1 -0
  153. package/dist/src/delay.js +10 -0
  154. package/dist/src/delay.js.map +1 -0
  155. package/dist/test/DiscoveryTree.test.d.ts +1 -0
  156. package/dist/test/DiscoveryTree.test.js +68 -0
  157. package/dist/test/DiscoveryTree.test.js.map +1 -0
  158. package/dist/test/EtagEventTable.test.d.ts +1 -0
  159. package/dist/test/EtagEventTable.test.js +93 -0
  160. package/dist/test/EtagEventTable.test.js.map +1 -0
  161. package/dist/test/Job.test.d.ts +1 -0
  162. package/dist/test/Job.test.js +104 -0
  163. package/dist/test/Job.test.js.map +1 -0
  164. package/dist/test/JpegUtil.test.d.ts +1 -0
  165. package/dist/test/JpegUtil.test.js +51 -0
  166. package/dist/test/JpegUtil.test.js.map +1 -0
  167. package/dist/test/PathHelper.test.d.ts +1 -0
  168. package/dist/test/PathHelper.test.js +99 -0
  169. package/dist/test/PathHelper.test.js.map +1 -0
  170. package/dist/test/ScanJobManifest.test.d.ts +1 -0
  171. package/dist/test/ScanJobManifest.test.js +56 -0
  172. package/dist/test/ScanJobManifest.test.js.map +1 -0
  173. package/dist/test/ScanJobSettings.test.d.ts +1 -0
  174. package/dist/test/ScanJobSettings.test.js +53 -0
  175. package/dist/test/ScanJobSettings.test.js.map +1 -0
  176. package/dist/test/ScanStatus.test.d.ts +1 -0
  177. package/dist/test/ScanStatus.test.js +75 -0
  178. package/dist/test/ScanStatus.test.js.map +1 -0
  179. package/dist/test/WalkupScanDestination.test.d.ts +1 -0
  180. package/dist/test/WalkupScanDestination.test.js +80 -0
  181. package/dist/test/WalkupScanDestination.test.js.map +1 -0
  182. package/dist/test/WalkupScanDestinations.test.d.ts +1 -0
  183. package/dist/test/WalkupScanDestinations.test.js +68 -0
  184. package/dist/test/WalkupScanDestinations.test.js.map +1 -0
  185. package/dist/test/WalkupScanManifest.test.d.ts +1 -0
  186. package/dist/test/WalkupScanManifest.test.js +46 -0
  187. package/dist/test/WalkupScanManifest.test.js.map +1 -0
  188. package/dist/test/WalkupScanToCompCaps.test.d.ts +1 -0
  189. package/dist/test/WalkupScanToCompCaps.test.js +56 -0
  190. package/dist/test/WalkupScanToCompCaps.test.js.map +1 -0
  191. package/dist/test/WalkupScanToCompDestination.test.d.ts +1 -0
  192. package/dist/test/WalkupScanToCompDestination.test.js +58 -0
  193. package/dist/test/WalkupScanToCompDestination.test.js.map +1 -0
  194. package/dist/test/WalkupScanToCompDestinations.test.d.ts +1 -0
  195. package/dist/test/WalkupScanToCompDestinations.test.js +58 -0
  196. package/dist/test/WalkupScanToCompDestinations.test.js.map +1 -0
  197. package/dist/test/WalkupScanToCompEvent.test.d.ts +1 -0
  198. package/dist/test/WalkupScanToCompEvent.test.js +46 -0
  199. package/dist/test/WalkupScanToCompEvent.test.js.map +1 -0
  200. package/dist/test/WalkupScanToCompManifest.test.d.ts +1 -0
  201. package/dist/test/WalkupScanToCompManifest.test.js +46 -0
  202. package/dist/test/WalkupScanToCompManifest.test.js.map +1 -0
  203. package/dist/test/clean.d.ts +1 -0
  204. package/dist/test/clean.js +21 -0
  205. package/dist/test/clean.js.map +1 -0
  206. package/package.json +27 -18
  207. package/src/Destination.ts +1 -1
  208. package/src/DeviceCapabilities.ts +4 -0
  209. package/src/DiscoveryTree.ts +56 -0
  210. package/src/Event.ts +17 -7
  211. package/src/EventTable.ts +20 -0
  212. package/src/HPApi.ts +245 -103
  213. package/src/Job.ts +51 -29
  214. package/src/JpegUtil.ts +8 -4
  215. package/src/KnownShortcut.ts +6 -0
  216. package/src/PathHelper.ts +47 -13
  217. package/src/ScanCaps.ts +19 -0
  218. package/src/ScanContent.ts +4 -1
  219. package/src/ScanJobManifest.ts +55 -0
  220. package/src/ScanJobSettings.ts +18 -3
  221. package/src/ScanStatus.ts +9 -0
  222. package/src/WalkupScanDestination.ts +42 -18
  223. package/src/WalkupScanDestinations.ts +12 -0
  224. package/src/WalkupScanManifest.ts +59 -0
  225. package/src/WalkupScanToCompCaps.ts +36 -0
  226. package/src/WalkupScanToCompDestination.ts +38 -24
  227. package/src/WalkupScanToCompDestinations.ts +12 -0
  228. package/src/WalkupScanToCompEvent.ts +15 -3
  229. package/src/WalkupScanToCompManifest.ts +59 -0
  230. package/src/delay.ts +5 -0
  231. package/src/index.ts +267 -465
  232. package/src/listening.ts +145 -0
  233. package/src/readDeviceCapabilities.ts +46 -0
  234. package/src/scanProcessing.ts +535 -0
  235. package/tsconfig.json +1 -1
package/dist/HPApi.js CHANGED
@@ -22,321 +22,337 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
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
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
62
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
63
27
  };
64
28
  Object.defineProperty(exports, "__esModule", { value: true });
65
- var WalkupScanDestination_1 = __importDefault(require("./WalkupScanDestination"));
66
- var WalkupScanToCompDestination_1 = __importDefault(require("./WalkupScanToCompDestination"));
67
- var util_1 = require("util");
68
- var fs_1 = __importDefault(require("fs"));
69
- var axios_1 = __importDefault(require("axios"));
70
- var url_1 = require("url");
71
- var xml2js_1 = require("xml2js");
72
- var stream = __importStar(require("stream/promises"));
73
- var EventTable_1 = __importDefault(require("./EventTable"));
74
- var Job_1 = __importDefault(require("./Job"));
75
- var ScanStatus_1 = __importDefault(require("./ScanStatus"));
76
- var WalkupScanDestinations_1 = __importDefault(require("./WalkupScanDestinations"));
77
- var WalkupScanToCompDestinations_1 = __importDefault(require("./WalkupScanToCompDestinations"));
78
- var WalkupScanToCompEvent_1 = __importDefault(require("./WalkupScanToCompEvent"));
79
- var parser = new xml2js_1.Parser();
80
- var parseString = (0, util_1.promisify)(parser.parseString);
81
- var printerIP = "192.168.1.11";
82
- var debug = false;
83
- var callCount = 0;
84
- var HPApi = /** @class */ (function () {
85
- function HPApi() {
86
- }
87
- HPApi.setPrinterIP = function (ip) {
29
+ const util_1 = require("util");
30
+ const fs_1 = __importDefault(require("fs"));
31
+ const axios_1 = __importDefault(require("axios"));
32
+ const url_1 = require("url");
33
+ const stream = __importStar(require("stream"));
34
+ const EventTable_1 = __importDefault(require("./EventTable"));
35
+ const Job_1 = __importDefault(require("./Job"));
36
+ const ScanStatus_1 = __importDefault(require("./ScanStatus"));
37
+ const WalkupScanDestination_1 = __importDefault(require("./WalkupScanDestination"));
38
+ const WalkupScanToCompDestination_1 = __importDefault(require("./WalkupScanToCompDestination"));
39
+ const WalkupScanDestinations_1 = __importDefault(require("./WalkupScanDestinations"));
40
+ const WalkupScanToCompDestinations_1 = __importDefault(require("./WalkupScanToCompDestinations"));
41
+ const WalkupScanToCompEvent_1 = __importDefault(require("./WalkupScanToCompEvent"));
42
+ const DiscoveryTree_1 = __importDefault(require("./DiscoveryTree"));
43
+ const WalkupScanToCompManifest_1 = __importDefault(require("./WalkupScanToCompManifest"));
44
+ const WalkupScanToCompCaps_1 = __importDefault(require("./WalkupScanToCompCaps"));
45
+ const WalkupScanManifest_1 = __importDefault(require("./WalkupScanManifest"));
46
+ const ScanJobManifest_1 = __importDefault(require("./ScanJobManifest"));
47
+ const ScanCaps_1 = __importDefault(require("./ScanCaps"));
48
+ const delay_1 = require("./delay");
49
+ const net = __importStar(require("net"));
50
+ let printerIP = "192.168.1.11";
51
+ let debug = false;
52
+ let callCount = 0;
53
+ class HPApi {
54
+ static setDeviceIP(ip) {
88
55
  printerIP = ip;
89
- };
90
- HPApi.setDebug = function (dbg) {
56
+ }
57
+ static setDebug(dbg) {
91
58
  debug = dbg;
92
- };
93
- HPApi.logDebug = function (callId, isRequest, msg) {
59
+ }
60
+ static logDebug(callId, isRequest, msg) {
94
61
  if (debug) {
95
- var id = String(callId).padStart(4, "0");
96
- var content = typeof msg === "string" ? msg : JSON.stringify(msg);
62
+ const id = String(callId).padStart(4, "0");
63
+ const content = typeof msg === "string" ? msg : JSON.stringify(msg);
97
64
  console.log(id + (isRequest ? " -> " : " <- ") + content);
98
65
  }
99
- };
100
- HPApi.callAxios = function (request) {
66
+ }
67
+ static async callAxios(request) {
101
68
  var _a, _b, _c, _d;
102
- return __awaiter(this, void 0, void 0, function () {
103
- var response, error_1, axiosError;
104
- return __generator(this, function (_e) {
105
- switch (_e.label) {
106
- case 0:
107
- callCount++;
108
- HPApi.logDebug(callCount, true, request);
109
- _e.label = 1;
110
- case 1:
111
- _e.trys.push([1, 3, , 4]);
112
- return [4 /*yield*/, (0, axios_1.default)(request)];
113
- case 2:
114
- response = (_e.sent());
115
- HPApi.logDebug(callCount, false, {
116
- status: response.status,
117
- data: response.data,
118
- headers: response.headers,
119
- statusText: response.statusText,
120
- });
121
- return [2 /*return*/, response];
122
- case 3:
123
- error_1 = _e.sent();
124
- axiosError = error_1;
125
- if (axiosError.isAxiosError) {
126
- HPApi.logDebug(callCount, false, {
127
- status: (_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.status,
128
- data: (_b = axiosError.response) === null || _b === void 0 ? void 0 : _b.data,
129
- headers: (_c = axiosError.response) === null || _c === void 0 ? void 0 : _c.headers,
130
- statusText: (_d = axiosError.response) === null || _d === void 0 ? void 0 : _d.statusText,
131
- });
132
- }
133
- throw error_1;
134
- case 4: return [2 /*return*/];
135
- }
69
+ callCount++;
70
+ if (request.timeout === 0) {
71
+ request.timeout = 100000;
72
+ }
73
+ HPApi.logDebug(callCount, true, request);
74
+ try {
75
+ const response = await (0, axios_1.default)(request);
76
+ HPApi.logDebug(callCount, false, {
77
+ status: response.status,
78
+ data: response.data,
79
+ headers: response.headers,
80
+ statusText: response.statusText,
136
81
  });
137
- });
138
- };
139
- HPApi.getWalkupScanDestinations = function () {
140
- return __awaiter(this, void 0, void 0, function () {
141
- var response, parsed;
142
- return __generator(this, function (_a) {
143
- switch (_a.label) {
144
- case 0: return [4 /*yield*/, HPApi.callAxios({
145
- baseURL: "http://".concat(printerIP),
146
- url: "/WalkupScan/WalkupScanDestinations",
147
- method: "GET",
148
- responseType: "text",
149
- })];
150
- case 1:
151
- response = _a.sent();
152
- if (!(response.status !== 200)) return [3 /*break*/, 2];
153
- throw new Error(response.statusText);
154
- case 2: return [4 /*yield*/, parseString(response.data)];
155
- case 3:
156
- parsed = (_a.sent());
157
- return [2 /*return*/, new WalkupScanDestinations_1.default(parsed)];
158
- }
82
+ return response;
83
+ }
84
+ catch (error) {
85
+ const axiosError = error;
86
+ if (axiosError.isAxiosError) {
87
+ HPApi.logDebug(callCount, false, {
88
+ status: (_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.status,
89
+ data: (_b = axiosError.response) === null || _b === void 0 ? void 0 : _b.data,
90
+ headers: (_c = axiosError.response) === null || _c === void 0 ? void 0 : _c.headers,
91
+ statusText: (_d = axiosError.response) === null || _d === void 0 ? void 0 : _d.statusText,
92
+ });
93
+ }
94
+ throw error;
95
+ }
96
+ }
97
+ static async isAlive(timeout = null) {
98
+ const definedTimeout = timeout || 10000; // default of 10 seconds
99
+ return new Promise((resolve) => {
100
+ const socket = net.createConnection(80, printerIP, () => {
101
+ clearTimeout(timer);
102
+ resolve(true);
103
+ socket.end();
159
104
  });
160
- });
161
- };
162
- HPApi.getWalkupScanToCompDestinations = function () {
163
- return __awaiter(this, void 0, void 0, function () {
164
- var response, parsed;
165
- return __generator(this, function (_a) {
166
- switch (_a.label) {
167
- case 0: return [4 /*yield*/, HPApi.callAxios({
168
- baseURL: "http://".concat(printerIP),
169
- url: "/WalkupScanToComp/WalkupScanToCompDestinations",
170
- method: "GET",
171
- responseType: "text",
172
- })];
173
- case 1:
174
- response = _a.sent();
175
- if (!(response.status !== 200)) return [3 /*break*/, 2];
176
- throw new Error(response.statusText);
177
- case 2: return [4 /*yield*/, parseString(response.data)];
178
- case 3:
179
- parsed = (_a.sent());
180
- return [2 /*return*/, new WalkupScanToCompDestinations_1.default(parsed)];
181
- }
105
+ const timer = setTimeout(() => {
106
+ resolve(false);
107
+ socket.end();
108
+ }, definedTimeout);
109
+ socket.on("error", () => {
110
+ clearTimeout(timer);
111
+ resolve(false);
182
112
  });
183
113
  });
184
- };
185
- HPApi.getWalkupScanToCompCaps = function () {
186
- return __awaiter(this, void 0, void 0, function () {
187
- return __generator(this, function (_a) {
188
- return [2 /*return*/, HPApi.callAxios({
189
- baseURL: "http://".concat(printerIP),
190
- url: "/WalkupScanToComp/WalkupScanToCompCaps",
191
- method: "GET",
192
- responseType: "text",
193
- }).then(function (response) { return response.status == 200; }, function () { return false; })];
194
- });
114
+ }
115
+ static async waitDeviceUp(deviceUpPollingInterval) {
116
+ let first = true;
117
+ while (!(await HPApi.isAlive())) {
118
+ if (first) {
119
+ console.log(`Device ip: ${printerIP} is down! [${new Date().toISOString()}]`);
120
+ }
121
+ first = false;
122
+ await (0, delay_1.delay)(deviceUpPollingInterval);
123
+ }
124
+ if (!first) {
125
+ console.log(`Device ip: ${printerIP} is up again! [${new Date().toISOString()}]`);
126
+ }
127
+ }
128
+ static async getDiscoveryTree() {
129
+ const response = await HPApi.callAxios({
130
+ baseURL: `http://${printerIP}`,
131
+ url: "/DevMgmt/DiscoveryTree.xml",
132
+ method: "GET",
133
+ responseType: "text",
195
134
  });
196
- };
197
- HPApi.getWalkupScanToCompEvent = function (compEventURI) {
198
- return __awaiter(this, void 0, void 0, function () {
199
- var response;
200
- return __generator(this, function (_a) {
201
- switch (_a.label) {
202
- case 0: return [4 /*yield*/, HPApi.callAxios({
203
- baseURL: "http://".concat(printerIP),
204
- url: compEventURI,
205
- method: "GET",
206
- responseType: "text",
207
- })];
208
- case 1:
209
- response = _a.sent();
210
- if (response.status !== 200) {
211
- throw response;
212
- }
213
- else {
214
- return [2 /*return*/, HPApi.createWalkupScanToCompEvent(response.data)];
215
- }
216
- return [2 /*return*/];
217
- }
218
- });
135
+ if (response.status !== 200) {
136
+ throw new Error(response.statusText);
137
+ }
138
+ else {
139
+ return DiscoveryTree_1.default.createDiscoveryTree(response.data);
140
+ }
141
+ }
142
+ static async getWalkupScanDestinations(uri = "/WalkupScan/WalkupScanDestinations") {
143
+ const response = await HPApi.callAxios({
144
+ baseURL: `http://${printerIP}`,
145
+ url: uri,
146
+ method: "GET",
147
+ responseType: "text",
219
148
  });
220
- };
221
- HPApi.removeDestination = function (walkupScanDestination) {
222
- return __awaiter(this, void 0, void 0, function () {
223
- var urlInfo, response;
224
- return __generator(this, function (_a) {
225
- switch (_a.label) {
226
- case 0:
227
- urlInfo = new url_1.URL(walkupScanDestination.resourceURI);
228
- if (urlInfo.pathname === null) {
229
- throw new Error("invalid walkupScanDestination.resourceURI: ".concat(walkupScanDestination.resourceURI));
230
- }
231
- return [4 /*yield*/, HPApi.callAxios({
232
- baseURL: "http://".concat(printerIP),
233
- url: urlInfo.pathname,
234
- method: "DELETE",
235
- responseType: "text",
236
- })];
237
- case 1:
238
- response = _a.sent();
239
- if (response.status === 204) {
240
- return [2 /*return*/, true];
241
- }
242
- else {
243
- throw response;
244
- }
245
- return [2 /*return*/];
246
- }
247
- });
149
+ if (response.status !== 200) {
150
+ throw new Error(response.statusText);
151
+ }
152
+ else {
153
+ return WalkupScanDestinations_1.default.createWalkupScanDestinations(response.data);
154
+ }
155
+ }
156
+ static async getWalkupScanToCompDestinations() {
157
+ const response = await HPApi.callAxios({
158
+ baseURL: `http://${printerIP}`,
159
+ url: "/WalkupScanToComp/WalkupScanToCompDestinations",
160
+ method: "GET",
161
+ responseType: "text",
248
162
  });
249
- };
250
- HPApi.registerDestination = function (destination, toComp) {
251
- return __awaiter(this, void 0, void 0, function () {
252
- var xml, url, response;
253
- return __generator(this, function (_a) {
254
- switch (_a.label) {
255
- case 0: return [4 /*yield*/, destination.toXML()];
256
- case 1:
257
- xml = _a.sent();
258
- url = "/WalkupScan/WalkupScanDestinations";
259
- if (toComp) {
260
- url = "/WalkupScanToComp/WalkupScanToCompDestinations";
261
- }
262
- return [4 /*yield*/, HPApi.callAxios({
263
- baseURL: "http://".concat(printerIP),
264
- url: url,
265
- method: "POST",
266
- headers: { "Content-Type": "text/xml" },
267
- data: xml,
268
- responseType: "text",
269
- })];
270
- case 2:
271
- response = _a.sent();
272
- if (response.status === 201) {
273
- return [2 /*return*/, new url_1.URL(response.headers.location).pathname];
274
- }
275
- else {
276
- throw response;
277
- }
278
- return [2 /*return*/];
279
- }
280
- });
163
+ if (response.status !== 200) {
164
+ throw new Error(response.statusText);
165
+ }
166
+ else {
167
+ return WalkupScanToCompDestinations_1.default.createWalkupScanToCompDestinations(response.data);
168
+ }
169
+ }
170
+ static async getWalkupScanManifest(uri) {
171
+ const response = await HPApi.callAxios({
172
+ baseURL: `http://${printerIP}`,
173
+ url: uri,
174
+ method: "GET",
175
+ responseType: "text",
176
+ });
177
+ if (response.status !== 200) {
178
+ throw new Error(response.statusText);
179
+ }
180
+ else {
181
+ return WalkupScanManifest_1.default.createWalkupScanManifest(response.data);
182
+ }
183
+ }
184
+ static async getWalkupScanToCompManifest(uri) {
185
+ const response = await HPApi.callAxios({
186
+ baseURL: `http://${printerIP}`,
187
+ url: uri,
188
+ method: "GET",
189
+ responseType: "text",
190
+ });
191
+ if (response.status !== 200) {
192
+ throw new Error(response.statusText);
193
+ }
194
+ else {
195
+ return WalkupScanToCompManifest_1.default.createWalkupScanToCompManifest(response.data);
196
+ }
197
+ }
198
+ static async getScanJobManifest(uri) {
199
+ const response = await HPApi.callAxios({
200
+ baseURL: `http://${printerIP}`,
201
+ url: uri,
202
+ method: "GET",
203
+ responseType: "text",
204
+ });
205
+ if (response.status !== 200) {
206
+ throw new Error(response.statusText);
207
+ }
208
+ else {
209
+ return ScanJobManifest_1.default.createScanJobManifest(response.data);
210
+ }
211
+ }
212
+ static async getScanCaps(uri) {
213
+ const response = await HPApi.callAxios({
214
+ baseURL: `http://${printerIP}`,
215
+ url: uri,
216
+ method: "GET",
217
+ responseType: "text",
218
+ });
219
+ if (response.status !== 200) {
220
+ throw new Error(response.statusText);
221
+ }
222
+ else {
223
+ return ScanCaps_1.default.createScanCaps(response.data);
224
+ }
225
+ }
226
+ static async getWalkupScanToCompCaps(uri) {
227
+ const response = await HPApi.callAxios({
228
+ baseURL: `http://${printerIP}`,
229
+ url: uri,
230
+ method: "GET",
231
+ responseType: "text",
232
+ });
233
+ if (response.status !== 200) {
234
+ throw new Error(response.statusText);
235
+ }
236
+ else {
237
+ return WalkupScanToCompCaps_1.default.createWalkupScanToCompCaps(response.data);
238
+ }
239
+ }
240
+ static async getWalkupScanToCompEvent(compEventURI) {
241
+ const response = await HPApi.callAxios({
242
+ baseURL: `http://${printerIP}`,
243
+ url: compEventURI,
244
+ method: "GET",
245
+ responseType: "text",
281
246
  });
282
- };
283
- HPApi.getEvents = function (etag, timeout) {
247
+ if (response.status !== 200) {
248
+ throw response;
249
+ }
250
+ else {
251
+ return WalkupScanToCompEvent_1.default.createWalkupScanToCompEvent(response.data);
252
+ }
253
+ }
254
+ static async removeDestination(walkupScanDestination) {
255
+ let path;
256
+ if (walkupScanDestination.resourceURI.startsWith("http")) {
257
+ let urlInfo = new url_1.URL(walkupScanDestination.resourceURI);
258
+ if (urlInfo.pathname === null) {
259
+ throw new Error(`invalid walkupScanDestination.resourceURI: ${walkupScanDestination.resourceURI}`);
260
+ }
261
+ path = urlInfo.pathname;
262
+ }
263
+ else {
264
+ path = walkupScanDestination.resourceURI;
265
+ }
266
+ const response = await HPApi.callAxios({
267
+ baseURL: `http://${printerIP}`,
268
+ url: path,
269
+ method: "DELETE",
270
+ responseType: "text",
271
+ });
272
+ if (response.status === 204 || response.status == 200) {
273
+ return true;
274
+ }
275
+ else {
276
+ throw response;
277
+ }
278
+ }
279
+ static async registerWalkupScanDestination(destination) {
280
+ const xml = await destination.toXML();
281
+ const url = "/WalkupScan/WalkupScanDestinations";
282
+ const response = await HPApi.callAxios({
283
+ baseURL: `http://${printerIP}`,
284
+ url: url,
285
+ method: "POST",
286
+ headers: { "Content-Type": "text/xml" },
287
+ data: xml,
288
+ responseType: "text",
289
+ });
290
+ if (response.status === 201 && response.headers.location != null) {
291
+ return new url_1.URL(response.headers.location).pathname;
292
+ }
293
+ else {
294
+ throw response;
295
+ }
296
+ }
297
+ static async registerWalkupScanToCompDestination(destination) {
298
+ const xml = await destination.toXML();
299
+ const url = "/WalkupScanToComp/WalkupScanToCompDestinations";
300
+ const response = await HPApi.callAxios({
301
+ baseURL: `http://${printerIP}`,
302
+ url: url,
303
+ method: "POST",
304
+ headers: { "Content-Type": "text/xml" },
305
+ data: xml,
306
+ responseType: "text",
307
+ });
308
+ if (response.status === 201 && response.headers.location != null) {
309
+ return new url_1.URL(response.headers.location).pathname;
310
+ }
311
+ else {
312
+ throw response;
313
+ }
314
+ }
315
+ static async getEvents(etag = "", decisecondTimeout = 0) {
284
316
  var _a;
285
- if (etag === void 0) { etag = ""; }
286
- if (timeout === void 0) { timeout = 0; }
287
- return __awaiter(this, void 0, void 0, function () {
288
- var url, headers, response, error_2, axiosError, parsed;
289
- return __generator(this, function (_b) {
290
- switch (_b.label) {
291
- case 0:
292
- url = this.appendTimeout("/EventMgmt/EventTable", timeout);
293
- headers = this.placeETagHeader(etag, {});
294
- _b.label = 1;
295
- case 1:
296
- _b.trys.push([1, 3, , 4]);
297
- return [4 /*yield*/, HPApi.callAxios({
298
- baseURL: "http://".concat(printerIP),
299
- url: url,
300
- method: "GET",
301
- responseType: "text",
302
- headers: headers,
303
- })];
304
- case 2:
305
- response = _b.sent();
306
- return [3 /*break*/, 4];
307
- case 3:
308
- error_2 = _b.sent();
309
- axiosError = error_2;
310
- if (!axiosError.isAxiosError)
311
- throw error_2;
312
- if (((_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.status) === 304) {
313
- return [2 /*return*/, {
314
- etag: etag,
315
- eventTable: new EventTable_1.default({}),
316
- }];
317
- }
318
- throw error_2;
319
- case 4: return [4 /*yield*/, parseString(response.data)];
320
- case 5:
321
- parsed = _b.sent();
322
- return [2 /*return*/, {
323
- etag: response.headers["etag"],
324
- eventTable: new EventTable_1.default(parsed),
325
- }];
326
- }
317
+ let url = this.appendTimeout("/EventMgmt/EventTable", decisecondTimeout);
318
+ let headers = this.placeETagHeader(etag, {});
319
+ let response;
320
+ try {
321
+ response = await HPApi.callAxios({
322
+ baseURL: `http://${printerIP}`,
323
+ url: url,
324
+ method: "GET",
325
+ responseType: "text",
326
+ headers: headers,
327
+ timeout: decisecondTimeout * 100 * 1.1,
327
328
  });
328
- });
329
- };
330
- HPApi.placeETagHeader = function (etag, headers) {
329
+ }
330
+ catch (error) {
331
+ const axiosError = error;
332
+ if (!axiosError.isAxiosError)
333
+ throw error;
334
+ if (((_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.status) === 304) {
335
+ return {
336
+ etag: etag,
337
+ eventTable: new EventTable_1.default({}),
338
+ };
339
+ }
340
+ throw error;
341
+ }
342
+ const etagReceived = response.headers["etag"];
343
+ if (etagReceived == null) {
344
+ throw response;
345
+ }
346
+ const content = response.data;
347
+ return EventTable_1.default.createEtagEventTable(content, etagReceived);
348
+ }
349
+ static placeETagHeader(etag, headers) {
331
350
  if (etag !== "") {
332
- headers = {
333
- "If-None-Match": etag,
334
- };
351
+ headers["If-None-Match"] = etag;
335
352
  }
336
353
  return headers;
337
- };
338
- HPApi.appendTimeout = function (url, timeout) {
339
- if (timeout === void 0) { timeout = null; }
354
+ }
355
+ static appendTimeout(url, timeout = null) {
340
356
  if (timeout == null) {
341
357
  timeout = 1200;
342
358
  }
@@ -344,186 +360,95 @@ var HPApi = /** @class */ (function () {
344
360
  url += "?timeout=" + timeout;
345
361
  }
346
362
  return url;
347
- };
348
- HPApi.getDestination = function (destinationURL) {
349
- return __awaiter(this, void 0, void 0, function () {
350
- var response, content;
351
- return __generator(this, function (_a) {
352
- switch (_a.label) {
353
- case 0: return [4 /*yield*/, HPApi.callAxios({
354
- baseURL: "http://".concat(printerIP),
355
- url: destinationURL,
356
- method: "GET",
357
- responseType: "text",
358
- })];
359
- case 1:
360
- response = _a.sent();
361
- if (response.status !== 200) {
362
- throw response;
363
- }
364
- else {
365
- content = response.data;
366
- if (destinationURL.includes("WalkupScanToComp")) {
367
- return [2 /*return*/, this.createWalkupScanToCompDestination(content)];
368
- }
369
- else {
370
- return [2 /*return*/, this.createWalkupScanDestination(content)];
371
- }
372
- }
373
- return [2 /*return*/];
374
- }
375
- });
376
- });
377
- };
378
- HPApi.createWalkupScanDestination = function (content) {
379
- return __awaiter(this, void 0, void 0, function () {
380
- var parsed;
381
- return __generator(this, function (_a) {
382
- switch (_a.label) {
383
- case 0: return [4 /*yield*/, parseString(content)];
384
- case 1:
385
- parsed = (_a.sent());
386
- return [2 /*return*/, new WalkupScanDestination_1.default(parsed)];
387
- }
388
- });
389
- });
390
- };
391
- HPApi.createWalkupScanToCompDestination = function (content) {
392
- return __awaiter(this, void 0, void 0, function () {
393
- var parsed;
394
- return __generator(this, function (_a) {
395
- switch (_a.label) {
396
- case 0: return [4 /*yield*/, parseString(content)];
397
- case 1:
398
- parsed = (_a.sent());
399
- return [2 /*return*/, new WalkupScanToCompDestination_1.default(parsed)];
400
- }
401
- });
402
- });
403
- };
404
- HPApi.createWalkupScanToCompEvent = function (content) {
405
- return __awaiter(this, void 0, void 0, function () {
406
- var parsed;
407
- return __generator(this, function (_a) {
408
- switch (_a.label) {
409
- case 0: return [4 /*yield*/, parseString(content)];
410
- case 1:
411
- parsed = (_a.sent());
412
- return [2 /*return*/, new WalkupScanToCompEvent_1.default(parsed)];
413
- }
414
- });
363
+ }
364
+ static async getDestination(destinationURL) {
365
+ const response = await HPApi.callAxios({
366
+ baseURL: `http://${printerIP}`,
367
+ url: destinationURL,
368
+ method: "GET",
369
+ responseType: "text",
415
370
  });
416
- };
417
- HPApi.getScanStatus = function () {
418
- return __awaiter(this, void 0, void 0, function () {
419
- var response, parsed;
420
- return __generator(this, function (_a) {
421
- switch (_a.label) {
422
- case 0: return [4 /*yield*/, HPApi.callAxios({
423
- baseURL: "http://".concat(printerIP),
424
- url: "/Scan/Status",
425
- method: "GET",
426
- responseType: "text",
427
- })];
428
- case 1:
429
- response = _a.sent();
430
- if (!(response.status !== 200)) return [3 /*break*/, 2];
431
- throw response;
432
- case 2: return [4 /*yield*/, parseString(response.data)];
433
- case 3:
434
- parsed = (_a.sent());
435
- return [2 /*return*/, new ScanStatus_1.default(parsed)];
436
- }
437
- });
371
+ if (response.status !== 200) {
372
+ throw response;
373
+ }
374
+ else {
375
+ const content = response.data;
376
+ if (destinationURL.includes("WalkupScanToComp")) {
377
+ return WalkupScanToCompDestination_1.default.createWalkupScanToCompDestination(content);
378
+ }
379
+ else {
380
+ return WalkupScanDestination_1.default.createWalkupScanDestination(content);
381
+ }
382
+ }
383
+ }
384
+ static async getScanStatus() {
385
+ const response = await HPApi.callAxios({
386
+ baseURL: `http://${printerIP}`,
387
+ url: "/Scan/Status",
388
+ method: "GET",
389
+ responseType: "text",
438
390
  });
439
- };
440
- HPApi.delay = function (t) {
391
+ if (response.status !== 200) {
392
+ throw response;
393
+ }
394
+ else {
395
+ let content = response.data;
396
+ return ScanStatus_1.default.createScanStatus(content);
397
+ }
398
+ }
399
+ static delay(t) {
441
400
  return new Promise(function (resolve) {
442
401
  setTimeout(resolve, t);
443
402
  });
444
- };
445
- HPApi.postJob = function (job) {
446
- return __awaiter(this, void 0, void 0, function () {
447
- var xml, response;
448
- return __generator(this, function (_a) {
449
- switch (_a.label) {
450
- case 0: return [4 /*yield*/, HPApi.delay(500)];
451
- case 1:
452
- _a.sent();
453
- return [4 /*yield*/, job.toXML()];
454
- case 2:
455
- xml = _a.sent();
456
- return [4 /*yield*/, HPApi.callAxios({
457
- baseURL: "http://".concat(printerIP, ":8080"),
458
- url: "/Scan/Jobs",
459
- method: "POST",
460
- headers: { "Content-Type": "text/xml" },
461
- data: xml,
462
- responseType: "text",
463
- })];
464
- case 3:
465
- response = _a.sent();
466
- if (response.status === 201) {
467
- return [2 /*return*/, response.headers.location];
468
- }
469
- else {
470
- throw response;
471
- }
472
- return [2 /*return*/];
473
- }
474
- });
403
+ }
404
+ static async postJob(job) {
405
+ await HPApi.delay(500);
406
+ const xml = await job.toXML();
407
+ const response = await HPApi.callAxios({
408
+ baseURL: `http://${printerIP}:8080`,
409
+ url: "/Scan/Jobs",
410
+ method: "POST",
411
+ headers: { "Content-Type": "text/xml" },
412
+ data: xml,
413
+ responseType: "text",
475
414
  });
476
- };
415
+ if (response.status === 201 && response.headers.location != null) {
416
+ return response.headers.location;
417
+ }
418
+ else {
419
+ throw response;
420
+ }
421
+ }
477
422
  /**
478
423
  * @param jobURL
479
424
  * @return {Promise<Job|*>}
480
425
  */
481
- HPApi.getJob = function (jobURL) {
482
- return __awaiter(this, void 0, void 0, function () {
483
- var response, parsed;
484
- return __generator(this, function (_a) {
485
- switch (_a.label) {
486
- case 0: return [4 /*yield*/, HPApi.callAxios({
487
- url: jobURL,
488
- method: "GET",
489
- responseType: "text",
490
- })];
491
- case 1:
492
- response = _a.sent();
493
- if (!(response.status !== 200)) return [3 /*break*/, 2];
494
- throw response;
495
- case 2: return [4 /*yield*/, parseString(response.data)];
496
- case 3:
497
- parsed = (_a.sent());
498
- return [2 /*return*/, new Job_1.default(parsed)];
499
- }
500
- });
426
+ static async getJob(jobURL) {
427
+ const response = await HPApi.callAxios({
428
+ url: jobURL,
429
+ method: "GET",
430
+ responseType: "text",
501
431
  });
502
- };
503
- HPApi.downloadPage = function (binaryURL, destination) {
504
- return __awaiter(this, void 0, void 0, function () {
505
- var data, destinationFileStream;
506
- return __generator(this, function (_a) {
507
- switch (_a.label) {
508
- case 0: return [4 /*yield*/, axios_1.default.request({
509
- baseURL: "http://".concat(printerIP, ":8080"),
510
- url: binaryURL,
511
- method: "GET",
512
- responseType: "stream",
513
- })];
514
- case 1:
515
- data = (_a.sent()).data;
516
- destinationFileStream = fs_1.default.createWriteStream(destination);
517
- data.pipe(destinationFileStream);
518
- return [4 /*yield*/, stream.finished(destinationFileStream)];
519
- case 2:
520
- _a.sent();
521
- return [2 /*return*/, destination];
522
- }
523
- });
432
+ if (response.status !== 200) {
433
+ throw response;
434
+ }
435
+ else {
436
+ const content = response.data;
437
+ return Job_1.default.createJob(content);
438
+ }
439
+ }
440
+ static async downloadPage(binaryURL, destination) {
441
+ const { data } = await axios_1.default.request({
442
+ baseURL: `http://${printerIP}:8080`,
443
+ url: binaryURL,
444
+ method: "GET",
445
+ responseType: "stream",
524
446
  });
525
- };
526
- return HPApi;
527
- }());
447
+ const destinationFileStream = fs_1.default.createWriteStream(destination);
448
+ data.pipe(destinationFileStream);
449
+ await (0, util_1.promisify)(stream.finished)(destinationFileStream);
450
+ return destination;
451
+ }
452
+ }
528
453
  exports.default = HPApi;
529
454
  //# sourceMappingURL=HPApi.js.map