@rc-ex/ws 1.2.1 → 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 (56) hide show
  1. package/lib/esm/exceptions/ClosedException.d.ts +4 -0
  2. package/lib/esm/exceptions/ClosedException.js +7 -0
  3. package/lib/esm/exceptions/ClosedException.js.map +1 -0
  4. package/lib/esm/exceptions/ConnectionException.d.ts +7 -0
  5. package/lib/esm/exceptions/ConnectionException.js +13 -0
  6. package/lib/esm/exceptions/ConnectionException.js.map +1 -0
  7. package/lib/esm/exceptions/TimeoutException.d.ts +4 -0
  8. package/lib/esm/exceptions/TimeoutException.js +7 -0
  9. package/lib/esm/exceptions/TimeoutException.js.map +1 -0
  10. package/lib/esm/index.d.ts +44 -0
  11. package/lib/{index.js → esm/index.js} +62 -63
  12. package/lib/esm/index.js.map +1 -0
  13. package/lib/esm/rest.d.ts +3 -0
  14. package/lib/{rest.js → esm/rest.js} +10 -17
  15. package/lib/esm/rest.js.map +1 -0
  16. package/lib/esm/subscription.d.ts +20 -0
  17. package/lib/{subscription.js → esm/subscription.js} +9 -9
  18. package/lib/esm/subscription.js.map +1 -0
  19. package/lib/esm/types.d.ts +61 -0
  20. package/lib/esm/types.js +2 -0
  21. package/lib/esm/types.js.map +1 -0
  22. package/lib/esm/utils.d.ts +8 -0
  23. package/lib/{utils.js → esm/utils.js} +5 -10
  24. package/lib/esm/utils.js.map +1 -0
  25. package/lib/exceptions/ClosedException.cjs +26 -0
  26. package/lib/exceptions/ClosedException.js.map +1 -1
  27. package/lib/exceptions/ConnectionException.cjs +35 -0
  28. package/lib/exceptions/ConnectionException.d.ts +1 -1
  29. package/lib/exceptions/ConnectionException.js.map +1 -1
  30. package/lib/exceptions/TimeoutException.cjs +26 -0
  31. package/lib/exceptions/TimeoutException.js.map +1 -1
  32. package/lib/index.cjs +515 -0
  33. package/lib/index.d.ts +5 -5
  34. package/lib/index.js.map +1 -1
  35. package/lib/rest.cjs +104 -0
  36. package/lib/rest.d.ts +2 -2
  37. package/lib/rest.js.map +1 -1
  38. package/lib/subscription.cjs +178 -0
  39. package/lib/subscription.d.ts +3 -3
  40. package/lib/subscription.js.map +1 -1
  41. package/lib/types.d.ts +1 -1
  42. package/lib/utils.cjs +116 -0
  43. package/lib/utils.d.ts +1 -1
  44. package/lib/utils.js.map +1 -1
  45. package/package.json +10 -5
  46. package/src/exceptions/ConnectionException.ts +2 -2
  47. package/src/index.ts +15 -12
  48. package/src/rest.ts +4 -4
  49. package/src/subscription.ts +9 -5
  50. package/src/types.ts +1 -1
  51. package/src/utils.ts +3 -3
  52. package/tsconfig.json +0 -3
  53. package/lib/exceptions/ClosedException.js +0 -9
  54. package/lib/exceptions/ConnectionException.js +0 -16
  55. package/lib/exceptions/TimeoutException.js +0 -9
  56. /package/lib/{types.js → types.cjs} +0 -0
@@ -1,10 +1,5 @@
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
- const ClosedException_1 = __importDefault(require("./exceptions/ClosedException"));
7
- const TimeoutException_1 = __importDefault(require("./exceptions/TimeoutException"));
1
+ import ClosedException from "./exceptions/ClosedException.js";
2
+ import TimeoutException from "./exceptions/TimeoutException.js";
8
3
  class Utils {
9
4
  static splitWsgData(wsgData) {
10
5
  if (wsgData.includes(",--Boundary")) {
@@ -46,13 +41,13 @@ ${JSON.stringify(JSON.parse(event.data), null, 2)}
46
41
  const checkHandle = setInterval(() => {
47
42
  if (ws.readyState === ws.CLOSED) {
48
43
  clearInterval(checkHandle);
49
- reject(new ClosedException_1.default());
44
+ reject(new ClosedException());
50
45
  }
51
46
  }, 1000);
52
47
  const timeoutHandle = setTimeout(() => {
53
48
  ws.removeEventListener("message", handler);
54
49
  clearInterval(checkHandle);
55
- reject(new TimeoutException_1.default());
50
+ reject(new TimeoutException());
56
51
  }, timeout);
57
52
  const handler = (mEvent) => {
58
53
  const event = mEvent;
@@ -68,5 +63,5 @@ ${JSON.stringify(JSON.parse(event.data), null, 2)}
68
63
  });
69
64
  }
70
65
  }
71
- exports.default = Utils;
66
+ export default Utils;
72
67
  //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAIA,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAEhE,MAAM,KAAK;IACF,MAAM,CAAC,YAAY,CAAC,OAAe;QACxC,IAAI,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;YACpC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;YAC7C,OAAO;gBACL,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;gBACvC,OAAO,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;aACjD,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAEM,MAAM,CAAC,cAAc,CAAC,GAAO;QAClC,MAAM,EAAE,GAAG,GAAG,CAAC;QACf,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9B,EAAE,CAAC,IAAI,GAAG,KAAK,EAAE,GAAW,EAAE,EAAE;YAC9B,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC;YAChB,OAAO,CAAC,KAAK,CACX;EACN,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;OACnC,CACA,CAAC;QACJ,CAAC,CAAC;QACF,EAAE,CAAC,gBAAgB,CAAC,S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BAC3C,aAAa,CAAC,WAAW,CAAC,CAAC;gBAC3B,MAAM,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAC;YACjC,CAAC,EAAE,OAAO,CAAC,CAAC;YACZ,MAAM,OAAO,GAAG,CAAC,MAAoB,EAAE,EAAE;gBACvC,MAAM,KAAK,GAAG,MAAkB,CAAC;gBACjC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACpD,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;oBACzB,EAAE,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;oBAC3C,aAAa,CAAC,WAAW,CAAC,CAAC;oBAC3B,YAAY,CAAC,aAAa,CAAC,CAAC;oBAC5B,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;gBAC/B,CAAC;YACH,CAAC,CAAC;YACF,EAAE,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,eAAe,KAAK,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ var ClosedException = /** @class */ (function (_super) {
19
+ __extends(ClosedException, _super);
20
+ function ClosedException(message) {
21
+ return _super.call(this, message !== null && message !== void 0 ? message : "WebSocket has been closed") || this;
22
+ }
23
+ return ClosedException;
24
+ }(Error));
25
+ exports.default = ClosedException;
26
+ //# sourceMappingURL=ClosedException.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClosedException.js","sourceRoot":"","sources":["../../src/exceptions/ClosedException.ts"],"names":[],"mappings":";;AAAA,MAAM,eAAgB,SAAQ,KAAK;IACjC,YAAmB,OAAgB;QACjC,KAAK,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,2BAA2B,CAAC,CAAC;IAChD,CAAC;CACF;AAED,kBAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"ClosedException.js","sourceRoot":"","sources":["../../src/exceptions/ClosedException.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;IAA8B,mCAAK;IACjC,yBAAmB,OAAgB;QACjC,OAAA,MAAK,YAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,2BAA2B,CAAC,SAAC;IAChD,CAAC;IACH,sBAAC;AAAD,CAAC,AAJD,CAA8B,KAAK,GAIlC;AAED,kBAAe,eAAe,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ var utils_js_1 = __importDefault(require("../utils.js"));
22
+ var ConnectionException = /** @class */ (function (_super) {
23
+ __extends(ConnectionException, _super);
24
+ function ConnectionException(wsgEvent) {
25
+ var _this = this;
26
+ var _a = utils_js_1.default.splitWsgData(wsgEvent.data), wsgError = _a[1];
27
+ _this = _super.call(this, JSON.stringify(wsgError, null, 2)) || this;
28
+ _this.wsgEvent = wsgEvent;
29
+ _this.wsgError = wsgError;
30
+ return _this;
31
+ }
32
+ return ConnectionException;
33
+ }(Error));
34
+ exports.default = ConnectionException;
35
+ //# sourceMappingURL=ConnectionException.js.map
@@ -1,4 +1,4 @@
1
- import type { WsgError, WsgEvent } from "../types";
1
+ import type { WsgError, WsgEvent } from "../types.js";
2
2
  declare class ConnectionException extends Error {
3
3
  wsgEvent: WsgEvent;
4
4
  wsgError: WsgError;
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectionException.js","sourceRoot":"","sources":["../../src/exceptions/ConnectionException.ts"],"names":[],"mappings":";;;;;AACA,qDAA6B;AAE7B,MAAM,mBAAoB,SAAQ,KAAK;IAKrC,YAAmB,QAAkB;QACnC,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAwB,eAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC5E,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAED,kBAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"ConnectionException.js","sourceRoot":"","sources":["../../src/exceptions/ConnectionException.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,yDAAgC;AAEhC;IAAkC,uCAAK;IAKrC,6BAAmB,QAAkB;QAArC,iBAKC;QAJO,IAAA,KAAoC,kBAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAlE,QAAQ,QAA0D,CAAC;QAC5E,QAAA,MAAK,YAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAC;QACzC,KAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,KAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;;IAC3B,CAAC;IACH,0BAAC;AAAD,CAAC,AAXD,CAAkC,KAAK,GAWtC;AAED,kBAAe,mBAAmB,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ var TimeoutException = /** @class */ (function (_super) {
19
+ __extends(TimeoutException, _super);
20
+ function TimeoutException(message) {
21
+ return _super.call(this, message !== null && message !== void 0 ? message : "Failed to receive expected WebSocket message in time.") || this;
22
+ }
23
+ return TimeoutException;
24
+ }(Error));
25
+ exports.default = TimeoutException;
26
+ //# sourceMappingURL=TimeoutException.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeoutException.js","sourceRoot":"","sources":["../../src/exceptions/TimeoutException.ts"],"names":[],"mappings":";;AAAA,MAAM,gBAAiB,SAAQ,KAAK;IAClC,YAAmB,OAAgB;QACjC,KAAK,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,uDAAuD,CAAC,CAAC;IAC5E,CAAC;CACF;AAED,kBAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"TimeoutException.js","sourceRoot":"","sources":["../../src/exceptions/TimeoutException.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;IAA+B,oCAAK;IAClC,0BAAmB,OAAgB;QACjC,OAAA,MAAK,YAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,uDAAuD,CAAC,SAAC;IAC5E,CAAC;IACH,uBAAC;AAAD,CAAC,AAJD,CAA+B,KAAK,GAInC;AAED,kBAAe,gBAAgB,CAAC"}