1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.info = info;
|
7 | exports.version = version;
|
8 | exports.devices = devices;
|
9 | exports.acquire = acquire;
|
10 | exports.call = call;
|
11 |
|
12 |
|
13 | function info(res) {
|
14 | if (typeof res !== "object" || res == null) {
|
15 | throw new Error("Wrong result type.");
|
16 | }
|
17 |
|
18 | var version = res.version;
|
19 |
|
20 | if (typeof version !== "string") {
|
21 | throw new Error("Wrong result type.");
|
22 | }
|
23 |
|
24 | var configured = !!res.configured;
|
25 | return {
|
26 | version: version,
|
27 | configured: configured
|
28 | };
|
29 | }
|
30 |
|
31 | function version(version) {
|
32 | if (typeof version !== "string") {
|
33 | throw new Error("Wrong result type.");
|
34 | }
|
35 |
|
36 | return version.trim();
|
37 | }
|
38 |
|
39 | function convertSession(r) {
|
40 | if (r == null) {
|
41 | return null;
|
42 | }
|
43 |
|
44 | if (typeof r !== "string") {
|
45 | throw new Error("Wrong result type.");
|
46 | }
|
47 |
|
48 | return r;
|
49 | }
|
50 |
|
51 | function devices(res) {
|
52 | if (typeof res !== "object") {
|
53 | throw new Error("Wrong result type.");
|
54 | }
|
55 |
|
56 | if (!(res instanceof Array)) {
|
57 | throw new Error("Wrong result type.");
|
58 | }
|
59 |
|
60 | return res.map(function (o) {
|
61 | if (typeof o !== "object" || o == null) {
|
62 | throw new Error("Wrong result type.");
|
63 | }
|
64 |
|
65 | var path = o.path;
|
66 |
|
67 | if (typeof path !== "string") {
|
68 | throw new Error("Wrong result type.");
|
69 | }
|
70 |
|
71 | var pathS = path.toString();
|
72 | return {
|
73 | path: pathS,
|
74 | session: convertSession(o.session),
|
75 | debugSession: convertSession(o.debugSession),
|
76 | product: o.product,
|
77 | vendor: o.vendor,
|
78 | debug: !!o.debug
|
79 | };
|
80 | });
|
81 | }
|
82 |
|
83 | function acquire(res) {
|
84 | if (typeof res !== "object" || res == null) {
|
85 | throw new Error("Wrong result type.");
|
86 | }
|
87 |
|
88 | var session = res.session;
|
89 |
|
90 | if (typeof session !== "string" && typeof session !== "number") {
|
91 | throw new Error("Wrong result type.");
|
92 | }
|
93 |
|
94 | return session.toString();
|
95 | }
|
96 |
|
97 | function call(res) {
|
98 | if (typeof res !== "object" || res == null) {
|
99 | throw new Error("Wrong result type.");
|
100 | }
|
101 |
|
102 | var type = res.type;
|
103 |
|
104 | if (typeof type !== "string") {
|
105 | throw new Error("Wrong result type.");
|
106 | }
|
107 |
|
108 | var message = res.message;
|
109 |
|
110 | if (typeof message !== "object" || message == null) {
|
111 | throw new Error("Wrong result type.");
|
112 | }
|
113 |
|
114 | return {
|
115 | type: type,
|
116 | message: message
|
117 | };
|
118 | } |
\ | No newline at end of file |