@aloma.io/integration-sdk 3.0.2 → 3.0.4

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.
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const fetch = require('node-fetch');
4
- const C = require('../connection/constants.cjs');
5
- const cuid = require('@paralleldrive/cuid2').init({ length: 32 });
6
- const { DurableWebsocket } = require('./durable.cjs');
7
- const WebSocket = require('ws');
8
- const { Packet, Callback } = require('./packet.cjs');
3
+ const fetch = require("node-fetch");
4
+ const C = require("../connection/constants.cjs");
5
+ const cuid = require("@paralleldrive/cuid2").init({ length: 32 });
6
+ const { DurableWebsocket } = require("./durable.cjs");
7
+ const WebSocket = require("ws");
8
+ const { Packet, Callback } = require("./packet.cjs");
9
9
  const cleanInterval = 45 * 1000;
10
10
  const pingInterval = 30 * 1000;
11
11
  class Transport {
@@ -38,7 +38,7 @@ class Transport {
38
38
  local.ws.send(JSON.stringify({ p: packets }));
39
39
  }
40
40
  catch (e) {
41
- console.log('could not send packets ', e);
41
+ console.log("could not send packets ", e);
42
42
  packets.forEach((packet) => local.packets.unshift(packet));
43
43
  }
44
44
  }
@@ -48,20 +48,20 @@ class Transport {
48
48
  return;
49
49
  local.close();
50
50
  this.running = true;
51
- const ws = (local.ws = new WebSocket(config.wsUrl(), ['connector'], C.augmentRequest({ headers: {} }, config)));
52
- ws.on('open', () => {
53
- console.log('websocket connected');
51
+ const ws = (local.ws = new WebSocket(config.wsUrl(), ["connector"], C.augmentRequest({ headers: {} }, config)));
52
+ ws.on("open", () => {
53
+ console.log("websocket connected");
54
54
  local.connected = true;
55
55
  local.pinger = setInterval(() => ws.ping(() => null), pingInterval);
56
56
  local.onConnect(local);
57
57
  });
58
- ws.on('message', (message) => {
58
+ ws.on("message", (message) => {
59
59
  setTimeout(() => local.onMessages(JSON.parse(message)), 0);
60
60
  });
61
- ws.on('error', (message) => {
62
- console.log('error:', message);
61
+ ws.on("error", (message) => {
62
+ console.log("error:", message);
63
63
  });
64
- ws.on('close', (message) => {
64
+ ws.on("close", (message) => {
65
65
  local.connected = false;
66
66
  clearInterval(local.pinger);
67
67
  if (local.running)
@@ -92,7 +92,7 @@ class Transport {
92
92
  this.callbacks[packet.cb()].cb(packet.args());
93
93
  }
94
94
  catch (e) {
95
- console.log('error processing packet', e, packet);
95
+ console.log("error processing packet", e, packet);
96
96
  }
97
97
  finally {
98
98
  delete this.callbacks[packet.cb()];
@@ -117,12 +117,12 @@ class Transport {
117
117
  if (!cb)
118
118
  return;
119
119
  if (cb.created < then) {
120
- console.log('callback timeout', key);
120
+ console.log("callback timeout", key);
121
121
  try {
122
- cb.cb({ error: 'timeout' });
122
+ cb.cb({ error: "timeout" });
123
123
  }
124
124
  catch (e) {
125
- console.log('error while callback', key, cb, e);
125
+ console.log("error while callback", key, cb, e);
126
126
  }
127
127
  delete local.callbacks[key];
128
128
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const fetch = require('node-fetch');
4
- const cuid = require('@paralleldrive/cuid2').init({ length: 32 });
3
+ const fetch = require("node-fetch");
4
+ const cuid = require("@paralleldrive/cuid2").init({ length: 32 });
5
5
  class Packet {
6
6
  constructor(data = {}) {
7
7
  this.data = data;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const { Packet, Callback } = require('./packet.cjs');
3
+ const { Packet, Callback } = require("./packet.cjs");
4
4
  class Processor {
5
5
  constructor({ transport, processPacket }) {
6
6
  var local = this;
@@ -33,24 +33,24 @@ class Processor {
33
33
  callbacks[packet.cb()](packet.args());
34
34
  }
35
35
  catch (e) {
36
- console.log('error in callback', callbacks[packet.cb()], packet);
36
+ console.log("error in callback", callbacks[packet.cb()], packet);
37
37
  }
38
38
  delete local.transport.callbacks[packet.cb()];
39
39
  }
40
40
  else if (packet.event()) {
41
- console.log('handle event packet', packet);
41
+ console.log("handle event packet", packet);
42
42
  }
43
43
  else {
44
44
  try {
45
45
  const result = await local._processPacket(packet);
46
46
  const reply = local.transport.newPacket({});
47
- reply.method('connector.reply');
47
+ reply.method("connector.reply");
48
48
  reply.cb(original.cb());
49
49
  reply.args({ ...result });
50
50
  local.transport.send(reply);
51
51
  }
52
52
  catch (e) {
53
- console.log('error processing packet', e, packet);
53
+ console.log("error processing packet", e, packet);
54
54
  }
55
55
  }
56
56
  }
@@ -7,6 +7,6 @@ export default class Controller extends AbstractController {
7
7
  */
8
8
  async hello(args: any)
9
9
  {
10
- return "hello world";
10
+ return {hi: 'world'};
11
11
  }
12
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
@@ -7,6 +7,6 @@ export default class Controller extends AbstractController {
7
7
  */
8
8
  async hello(args: any)
9
9
  {
10
- return "hello world";
10
+ return {hi: 'world'};
11
11
  }
12
12
  }