@fatehan/tsrp 1.3.8 → 1.3.10
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/dist/api.d.ts.map +1 -1
- package/dist/api.js +29 -14
- package/dist/tests/api.test.js +6 -4
- package/package.json +1 -1
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAUnD,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6C;IACvE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAiB;gBAEvC,GAAG,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc;YAKzC,KAAK;IAgCN,OAAO,CAClB,OAAO,EAAE,OAAO,wBAAwB,EAAE,SAAS,GAClD,OAAO,CAAC,OAAO,wBAAwB,EAAE,UAAU,CAAC;IAK1C,WAAW,CACtB,OAAO,EAAE,OAAO,wBAAwB,EAAE,aAAa,GACtD,OAAO,CAAC,OAAO,wBAAwB,EAAE,cAAc,CAAC;IAO9C,UAAU,CACrB,OAAO,EAAE,OAAO,wBAAwB,EAAE,iBAAiB,GAC1D,OAAO,CAAC,OAAO,wBAAwB,EAAE,kBAAkB,CAAC;IAYlD,SAAS,CACpB,OAAO,EAAE,OAAO,wBAAwB,EAAE,gBAAgB,GACzD,OAAO,CAAC,OAAO,wBAAwB,EAAE,iBAAiB,CAAC;IAYjD,WAAW,CACtB,OAAO,EAAE,OAAO,wBAAwB,EAAE,aAAa,GACtD,OAAO,CAAC,OAAO,wBAAwB,EAAE,cAAc,CAAC;IAO9C,SAAS,CACpB,OAAO,EAAE,OAAO,wBAAwB,EAAE,WAAW,GACpD,OAAO,CAAC,OAAO,wBAAwB,EAAE,YAAY,CAAC;IAO5C,OAAO,CAClB,OAAO,EAAE,OAAO,wBAAwB,EAAE,SAAS,GAClD,OAAO,CAAC,OAAO,wBAAwB,EAAE,UAAU,CAAC;IAgD1C,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAuB1D"}
|
package/dist/api.js
CHANGED
|
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.ApiService = void 0;
|
|
40
40
|
const system_io_1 = require("./store/system.io");
|
|
41
41
|
const system_io_2 = __importDefault(require("./system.io"));
|
|
42
|
+
const api_1 = require("./fatehan/services/api");
|
|
42
43
|
class ApiService {
|
|
43
44
|
constructor(url, headerProvider) {
|
|
44
45
|
this.namespace = "com.fatehan.services.ApiService";
|
|
@@ -92,24 +93,38 @@ class ApiService {
|
|
|
92
93
|
}
|
|
93
94
|
async IoIndex(request) {
|
|
94
95
|
if (request.deviceId != null) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
try {
|
|
97
|
+
const cachedIo = (0, system_io_1.getDeviceIoCache)(request.deviceId.toString());
|
|
98
|
+
if (cachedIo != null && cachedIo != undefined) {
|
|
99
|
+
return { cost: 0, ios: cachedIo, records: cachedIo.length };
|
|
100
|
+
}
|
|
101
|
+
const { IoRequest, IoResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/services/api")));
|
|
102
|
+
const response = await this._call("IoIndex", request, IoRequest, IoResponse);
|
|
103
|
+
if (response.records > 0) {
|
|
104
|
+
(0, system_io_1.setDeviceIoCache)(request.deviceId.toString(), response.ios);
|
|
105
|
+
}
|
|
106
|
+
return response;
|
|
107
|
+
}
|
|
108
|
+
catch (ex) {
|
|
109
|
+
console.error("device io exception", ex);
|
|
110
|
+
return api_1.IoResponse.create({ ios: [] });
|
|
98
111
|
}
|
|
99
|
-
const { IoRequest, IoResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/services/api")));
|
|
100
|
-
const response = await this._call("IoIndex", request, IoRequest, IoResponse);
|
|
101
|
-
(0, system_io_1.setDeviceIoCache)(request.deviceId.toString(), response.ios);
|
|
102
|
-
return response;
|
|
103
112
|
}
|
|
104
113
|
else {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
114
|
+
try {
|
|
115
|
+
const cachedIo = (0, system_io_1.getSystemIoCache)();
|
|
116
|
+
if (cachedIo != null && cachedIo != undefined) {
|
|
117
|
+
return { cost: 0, ios: cachedIo, records: cachedIo.length };
|
|
118
|
+
}
|
|
119
|
+
const { IoRequest, IoResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/services/api")));
|
|
120
|
+
const response = await this._call("IoIndex", request, IoRequest, IoResponse);
|
|
121
|
+
(0, system_io_1.setSystemIoCache)(response.ios);
|
|
122
|
+
return response;
|
|
123
|
+
}
|
|
124
|
+
catch (ex) {
|
|
125
|
+
console.error("device io exception", ex);
|
|
126
|
+
return api_1.IoResponse.create({ ios: [] });
|
|
108
127
|
}
|
|
109
|
-
const { IoRequest, IoResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/services/api")));
|
|
110
|
-
const response = await this._call("IoIndex", request, IoRequest, IoResponse);
|
|
111
|
-
(0, system_io_1.setSystemIoCache)(response.ios);
|
|
112
|
-
return response;
|
|
113
128
|
}
|
|
114
129
|
}
|
|
115
130
|
async SystemIoCast(data) {
|
package/dist/tests/api.test.js
CHANGED
|
@@ -10,8 +10,8 @@ global.fetch = vitest_1.vi.fn();
|
|
|
10
10
|
(0, vitest_1.beforeEach)(() => {
|
|
11
11
|
vitest_1.vi.clearAllMocks();
|
|
12
12
|
mockHeaderProvider = vitest_1.vi.fn(() => ({
|
|
13
|
-
authorization: "Bearer
|
|
14
|
-
"organization-id": "
|
|
13
|
+
authorization: "Bearer 258|1Pf5nFVZLvYfQD6BAXVi0PYuYR75ZfP05R8C1PXl314ba8dd",
|
|
14
|
+
"organization-id": "1000001",
|
|
15
15
|
}));
|
|
16
16
|
service = new api_1.ApiService(url, mockHeaderProvider);
|
|
17
17
|
});
|
|
@@ -52,7 +52,9 @@ global.fetch = vitest_1.vi.fn();
|
|
|
52
52
|
(0, vitest_1.expect)(global.fetch).toHaveBeenCalledWith(`${url}/com.fatehan.services.ApiService/DeviceIndex`, vitest_1.expect.any(Object));
|
|
53
53
|
});
|
|
54
54
|
(0, vitest_1.it)("should call IoIndex with correct headers and URL", async () => {
|
|
55
|
-
var x =
|
|
56
|
-
|
|
55
|
+
var x = service.IoIndex({}).then((x) => {
|
|
56
|
+
;
|
|
57
|
+
console.log(x);
|
|
58
|
+
});
|
|
57
59
|
});
|
|
58
60
|
});
|