@dimes-dot-fi/sdk 1.0.6 → 1.2.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 (36) hide show
  1. package/README.md +15 -0
  2. package/dist/{aliases-CXfmUrAb.d.cts → aliases-DzVxkXtK.d.cts} +143 -30
  3. package/dist/{aliases-CXfmUrAb.d.ts → aliases-DzVxkXtK.d.ts} +143 -30
  4. package/dist/{chunk-XWRROLKW.mjs → chunk-YUCGNELT.mjs} +6 -2
  5. package/dist/chunk-YUCGNELT.mjs.map +1 -0
  6. package/dist/{chunk-MSD7A3XX.cjs → chunk-ZK56XS4X.cjs} +6 -2
  7. package/dist/chunk-ZK56XS4X.cjs.map +1 -0
  8. package/dist/contract/index.d.cts +3 -3
  9. package/dist/contract/index.d.ts +3 -3
  10. package/dist/{dimes-client-Tfh-DX2h.d.cts → dimes-client-Bs6eTIvn.d.cts} +1 -1
  11. package/dist/{dimes-client-DfRPwGRk.d.ts → dimes-client-D88pW-Lm.d.ts} +1 -1
  12. package/dist/{dimes-error-CfbcQlUB.d.ts → dimes-error-BHVY6vDv.d.ts} +1 -1
  13. package/dist/{dimes-error-CrKY79nQ.d.cts → dimes-error-DxIoHQzj.d.cts} +1 -1
  14. package/dist/index.cjs +158 -2
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +50 -8
  17. package/dist/index.d.ts +50 -8
  18. package/dist/index.mjs +157 -1
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/{quote-DqF3MEbh.d.cts → quote-CZqCqt8R.d.cts} +2 -2
  21. package/dist/{quote-BB2YieGk.d.ts → quote-Cy7ie8yT.d.ts} +2 -2
  22. package/dist/react/index.d.cts +3 -3
  23. package/dist/react/index.d.ts +3 -3
  24. package/dist/types--ysRe5Os.d.cts +42 -0
  25. package/dist/types-BcUKsoEs.d.ts +42 -0
  26. package/dist/ws/index.cjs +22 -4
  27. package/dist/ws/index.cjs.map +1 -1
  28. package/dist/ws/index.d.cts +7 -4
  29. package/dist/ws/index.d.ts +7 -4
  30. package/dist/ws/index.mjs +19 -1
  31. package/dist/ws/index.mjs.map +1 -1
  32. package/package.json +1 -1
  33. package/dist/chunk-MSD7A3XX.cjs.map +0 -1
  34. package/dist/chunk-XWRROLKW.mjs.map +0 -1
  35. package/dist/types-C2WfUBLu.d.cts +0 -18
  36. package/dist/types-oz2d_Nyk.d.ts +0 -18
@@ -0,0 +1,42 @@
1
+ import { P as Position } from './aliases-DzVxkXtK.cjs';
2
+
3
+ declare const positionEventTypes: readonly ["position.cancelled", "position.close_requested", "position.closed", "position.created", "position.force_unwound", "position.liquidated", "position.opened", "position.opening", "position.reverted", "position.settled"];
4
+ type PositionEventType = (typeof positionEventTypes)[number];
5
+ interface PositionEventEnvelope {
6
+ id: string;
7
+ type: PositionEventType;
8
+ created_at: string;
9
+ data: Record<string, unknown>;
10
+ }
11
+ interface PositionEvent {
12
+ id: string;
13
+ type: PositionEventType;
14
+ createdAt: string;
15
+ data: Position;
16
+ }
17
+ interface NotificationEventEnvelope {
18
+ id: string;
19
+ type: "notification";
20
+ created_at: string;
21
+ data: {
22
+ code: string;
23
+ message: string;
24
+ params?: Record<string, unknown>;
25
+ };
26
+ }
27
+ interface NotificationEvent {
28
+ id: string;
29
+ type: "notification";
30
+ createdAt: string;
31
+ data: {
32
+ code: string;
33
+ message: string;
34
+ params?: Record<string, unknown>;
35
+ };
36
+ }
37
+ declare const notificationCodes: {
38
+ readonly orderFulfillmentRetrying: "ORDER_FULFILLMENT_RETRYING";
39
+ };
40
+ type NotificationCode = (typeof notificationCodes)[keyof typeof notificationCodes];
41
+
42
+ export { type NotificationEvent as N, type PositionEvent as P, type PositionEventType as a, type NotificationCode as b, type NotificationEventEnvelope as c, type PositionEventEnvelope as d, notificationCodes as n, positionEventTypes as p };
@@ -0,0 +1,42 @@
1
+ import { P as Position } from './aliases-DzVxkXtK.js';
2
+
3
+ declare const positionEventTypes: readonly ["position.cancelled", "position.close_requested", "position.closed", "position.created", "position.force_unwound", "position.liquidated", "position.opened", "position.opening", "position.reverted", "position.settled"];
4
+ type PositionEventType = (typeof positionEventTypes)[number];
5
+ interface PositionEventEnvelope {
6
+ id: string;
7
+ type: PositionEventType;
8
+ created_at: string;
9
+ data: Record<string, unknown>;
10
+ }
11
+ interface PositionEvent {
12
+ id: string;
13
+ type: PositionEventType;
14
+ createdAt: string;
15
+ data: Position;
16
+ }
17
+ interface NotificationEventEnvelope {
18
+ id: string;
19
+ type: "notification";
20
+ created_at: string;
21
+ data: {
22
+ code: string;
23
+ message: string;
24
+ params?: Record<string, unknown>;
25
+ };
26
+ }
27
+ interface NotificationEvent {
28
+ id: string;
29
+ type: "notification";
30
+ createdAt: string;
31
+ data: {
32
+ code: string;
33
+ message: string;
34
+ params?: Record<string, unknown>;
35
+ };
36
+ }
37
+ declare const notificationCodes: {
38
+ readonly orderFulfillmentRetrying: "ORDER_FULFILLMENT_RETRYING";
39
+ };
40
+ type NotificationCode = (typeof notificationCodes)[keyof typeof notificationCodes];
41
+
42
+ export { type NotificationEvent as N, type PositionEvent as P, type PositionEventType as a, type NotificationCode as b, type NotificationEventEnvelope as c, type PositionEventEnvelope as d, notificationCodes as n, positionEventTypes as p };
package/dist/ws/index.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
2
2
 
3
- var _chunkMSD7A3XXcjs = require('../chunk-MSD7A3XX.cjs');
3
+
4
+ var _chunkZK56XS4Xcjs = require('../chunk-ZK56XS4X.cjs');
4
5
 
5
6
  // src/ws/position-socket.ts
6
7
  var _humps = require('humps');
@@ -22,7 +23,8 @@ var PositionSocket = (_class = class {
22
23
  __init3() {this.connectListeners = /* @__PURE__ */ new Set()}
23
24
  __init4() {this.disconnectListeners = /* @__PURE__ */ new Set()}
24
25
  __init5() {this.errorListeners = /* @__PURE__ */ new Set()}
25
- constructor(options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);
26
+ __init6() {this.notificationListeners = /* @__PURE__ */ new Set()}
27
+ constructor(options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);
26
28
  this.baseUrl = _nullishCoalesce(options.baseUrl, () => ( "https://api.dimes.fi"));
27
29
  this.getToken = options.getToken;
28
30
  }
@@ -61,13 +63,24 @@ var PositionSocket = (_class = class {
61
63
  cb(err);
62
64
  }
63
65
  });
64
- for (const eventType of _chunkMSD7A3XXcjs.positionEventTypes) {
66
+ for (const eventType of _chunkZK56XS4Xcjs.positionEventTypes) {
65
67
  this.socket.on(eventType, (envelope) => {
66
68
  const event = camelizeEnvelope(envelope);
67
69
  this.emit(eventType, event);
68
70
  this.emit("*", event);
69
71
  });
70
72
  }
73
+ this.socket.on("notification", (envelope) => {
74
+ const event = {
75
+ id: envelope.id,
76
+ type: "notification",
77
+ createdAt: envelope.created_at,
78
+ data: envelope.data
79
+ };
80
+ for (const cb of this.notificationListeners) {
81
+ cb(event);
82
+ }
83
+ });
71
84
  }
72
85
  disconnect() {
73
86
  _optionalChain([this, 'access', _8 => _8.socket, 'optionalAccess', _9 => _9.disconnect, 'call', _10 => _10()]);
@@ -98,6 +111,10 @@ var PositionSocket = (_class = class {
98
111
  this.errorListeners.add(cb);
99
112
  return () => this.errorListeners.delete(cb);
100
113
  }
114
+ onNotification(cb) {
115
+ this.notificationListeners.add(cb);
116
+ return () => this.notificationListeners.delete(cb);
117
+ }
101
118
  emit(event, data) {
102
119
  const set = this.eventListeners.get(event);
103
120
  if (!set) {
@@ -111,5 +128,6 @@ var PositionSocket = (_class = class {
111
128
 
112
129
 
113
130
 
114
- exports.PositionSocket = PositionSocket; exports.positionEventTypes = _chunkMSD7A3XXcjs.positionEventTypes;
131
+
132
+ exports.PositionSocket = PositionSocket; exports.notificationCodes = _chunkZK56XS4Xcjs.notificationCodes; exports.positionEventTypes = _chunkZK56XS4Xcjs.positionEventTypes;
115
133
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/alexemery/bl/dimes-sdk/dist/ws/index.cjs","../../src/ws/position-socket.ts"],"names":[],"mappings":"AAAA;AACE;AACF,yDAA8B;AAC9B;AACA;ACJA,8BAA6B;AAC7B,kDAAgC;AAahC,IAAM,YAAA,EAAc,8CAAA;AAEpB,SAAS,gBAAA,CAAiB,QAAA,EAAgD;AACxE,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,QAAA,CAAS,EAAA;AAAA,IACb,IAAA,EAAM,QAAA,CAAS,IAAA;AAAA,IACf,SAAA,EAAW,QAAA,CAAS,UAAA;AAAA,IACpB,IAAA,EAAM,iCAAA,QAAa,CAAS,IAAI;AAAA,EAClC,CAAA;AACF;AAEO,IAAM,eAAA,YAAN,MAAqB;AAAA,iBAClB,OAAA,EAAwB,KAAA;AAAA,EAEf;AAAA,EAEA;AAAA,kBAEA,eAAA,kBAAiB,IAAI,GAAA,CAAgC,EAAA;AAAA,kBAErD,iBAAA,kBAAmB,IAAI,GAAA,CAAwB,EAAA;AAAA,kBAE/C,oBAAA,kBAAsB,IAAI,GAAA,CAAwB,EAAA;AAAA,kBAElD,eAAA,kBAAiB,IAAI,GAAA,CAAmB,EAAA;AAAA,EAEzD,WAAA,CAAY,OAAA,EAAgC;AAC1C,IAAA,I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D,EAAA;AACjD,IAAA;AACa,IAAA;AACpB,EAAA;AAE8C,EAAA;AACvC,IAAA;AACa,IAAA;AACpB,EAAA;AAEuD,EAAA;AACpC,IAAA;AACP,IAAA;AACR,MAAA;AACF,IAAA;AACiB,IAAA;AACR,MAAA;AACT,IAAA;AACF,EAAA;AACF;AD/BsB;AACA;AACA;AACA","file":"/Users/alexemery/bl/dimes-sdk/dist/ws/index.cjs","sourcesContent":[null,"import { camelizeKeys } from \"humps\";\nimport { io, type Socket } from \"socket.io-client\";\nimport type { Position } from \"../types\";\nimport { positionEventTypes, type PositionEvent, type PositionEventEnvelope, type PositionEventType } from \"./types\";\n\nexport interface PositionSocketOptions {\n baseUrl?: string;\n getToken: () => string | null;\n}\n\ntype EventCallback = (event: PositionEvent) => void;\ntype ConnectionCallback = () => void;\ntype ErrorCallback = (error: unknown) => void;\n\nconst wsNamespace = \"/v1/ws/prediction-markets/customer-positions\";\n\nfunction camelizeEnvelope(envelope: PositionEventEnvelope): PositionEvent {\n return {\n id: envelope.id,\n type: envelope.type,\n createdAt: envelope.created_at,\n data: camelizeKeys(envelope.data) as unknown as Position,\n };\n}\n\nexport class PositionSocket {\n private socket: Socket | null = null;\n\n private readonly baseUrl: string;\n\n private readonly getToken: () => string | null;\n\n private readonly eventListeners = new Map<string, Set<EventCallback>>();\n\n private readonly connectListeners = new Set<ConnectionCallback>();\n\n private readonly disconnectListeners = new Set<ConnectionCallback>();\n\n private readonly errorListeners = new Set<ErrorCallback>();\n\n constructor(options: PositionSocketOptions) {\n this.baseUrl = options.baseUrl ?? \"https://api.dimes.fi\";\n this.getToken = options.getToken;\n }\n\n public get connected(): boolean {\n return this.socket?.connected ?? false;\n }\n\n public connect(): void {\n if (this.socket?.connected) {\n return;\n }\n\n this.socket?.disconnect();\n\n const token = this.getToken();\n if (!token) {\n return;\n }\n\n const getToken = this.getToken;\n this.socket = io(`${this.baseUrl}${wsNamespace}`, {\n auth: (cb) => cb({ token: getToken() }),\n transports: [\"websocket\"],\n reconnection: true,\n reconnectionDelay: 1000,\n reconnectionDelayMax: 30000,\n });\n\n this.socket.on(\"connect\", () => {\n for (const cb of this.connectListeners) {\n cb();\n }\n });\n\n this.socket.on(\"disconnect\", () => {\n for (const cb of this.disconnectListeners) {\n cb();\n }\n });\n\n this.socket.on(\"error\", (err: unknown) => {\n for (const cb of this.errorListeners) {\n cb(err);\n }\n });\n\n for (const eventType of positionEventTypes) {\n this.socket.on(eventType, (envelope: PositionEventEnvelope) => {\n const event = camelizeEnvelope(envelope);\n this.emit(eventType, event);\n this.emit(\"*\", event);\n });\n }\n }\n\n public disconnect(): void {\n this.socket?.disconnect();\n this.socket = null;\n }\n\n public reconnectWithToken(): void {\n this.disconnect();\n this.connect();\n }\n\n public on(event: PositionEventType | \"*\", cb: EventCallback): () => void {\n let set = this.eventListeners.get(event);\n if (!set) {\n set = new Set();\n this.eventListeners.set(event, set);\n }\n set.add(cb);\n return () => set.delete(cb);\n }\n\n public onConnect(cb: ConnectionCallback): () => void {\n this.connectListeners.add(cb);\n return () => this.connectListeners.delete(cb);\n }\n\n public onDisconnect(cb: ConnectionCallback): () => void {\n this.disconnectListeners.add(cb);\n return () => this.disconnectListeners.delete(cb);\n }\n\n public onError(cb: ErrorCallback): () => void {\n this.errorListeners.add(cb);\n return () => this.errorListeners.delete(cb);\n }\n\n private emit(event: string, data: PositionEvent): void {\n const set = this.eventListeners.get(event);\n if (!set) {\n return;\n }\n for (const cb of set) {\n cb(data);\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["/Users/alexemery/bl/dimes-sdk/dist/ws/index.cjs","../../src/ws/position-socket.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,yDAA8B;AAC9B;AACA;ACLA,8BAA6B;AAC7B,kDAAgC;AAqBhC,IAAM,YAAA,EAAc,8CAAA;AAEpB,SAAS,gBAAA,CAAiB,QAAA,EAAgD;AACxE,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,QAAA,CAAS,EAAA;AAAA,IAC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D,MAAA;AACC,MAAA;AACd,MAAA;AACA,MAAA;AACD,IAAA;AAEc,IAAA;AACF,MAAA;AACN,QAAA;AACL,MAAA;AACD,IAAA;AAEc,IAAA;AACF,MAAA;AACN,QAAA;AACL,MAAA;AACD,IAAA;AAEc,IAAA;AACF,MAAA;AACH,QAAA;AACR,MAAA;AACD,IAAA;AAEU,IAAA;AACM,MAAA;AACC,QAAA;AACJ,QAAA;AACA,QAAA;AACX,MAAA;AACH,IAAA;AAEe,IAAA;AACoB,MAAA;AAClB,QAAA;AACP,QAAA;AACK,QAAA;AACL,QAAA;AACR,MAAA;AACW,MAAA;AACD,QAAA;AACV,MAAA;AACD,IAAA;AACH,EAAA;AAE0B,EAAA;AACX,oBAAA;AACC,IAAA;AAChB,EAAA;AAEO,EAAA;AACW,IAAA;AACH,IAAA;AACf,EAAA;AAEyE,EAAA;AACxD,IAAA;AACL,IAAA;AACF,MAAA;AACD,MAAA;AACP,IAAA;AACU,IAAA;AACO,IAAA;AACnB,EAAA;AAEqD,EAAA;AAC9C,IAAA;AACa,IAAA;AACpB,EAAA;AAEwD,EAAA;AACjD,IAAA;AACa,IAAA;AACpB,EAAA;AAE8C,EAAA;AACvC,IAAA;AACa,IAAA;AACpB,EAAA;AAE4D,EAAA;AACrD,IAAA;AACa,IAAA;AACpB,EAAA;AAEuD,EAAA;AACpC,IAAA;AACP,IAAA;AACR,MAAA;AACF,IAAA;AACiB,IAAA;AACR,MAAA;AACT,IAAA;AACF,EAAA;AACF;ADzCsB;AACA;AACA;AACA;AACA","file":"/Users/alexemery/bl/dimes-sdk/dist/ws/index.cjs","sourcesContent":[null,"import { camelizeKeys } from \"humps\";\nimport { io, type Socket } from \"socket.io-client\";\nimport type { Position } from \"../types\";\nimport {\n positionEventTypes,\n type NotificationEvent,\n type NotificationEventEnvelope,\n type PositionEvent,\n type PositionEventEnvelope,\n type PositionEventType,\n} from \"./types\";\n\nexport interface PositionSocketOptions {\n baseUrl?: string;\n getToken: () => string | null;\n}\n\ntype EventCallback = (event: PositionEvent) => void;\ntype NotificationCallback = (event: NotificationEvent) => void;\ntype ConnectionCallback = () => void;\ntype ErrorCallback = (error: unknown) => void;\n\nconst wsNamespace = \"/v1/ws/prediction-markets/customer-positions\";\n\nfunction camelizeEnvelope(envelope: PositionEventEnvelope): PositionEvent {\n return {\n id: envelope.id,\n type: envelope.type,\n createdAt: envelope.created_at,\n data: camelizeKeys(envelope.data) as unknown as Position,\n };\n}\n\nexport class PositionSocket {\n private socket: Socket | null = null;\n\n private readonly baseUrl: string;\n\n private readonly getToken: () => string | null;\n\n private readonly eventListeners = new Map<string, Set<EventCallback>>();\n\n private readonly connectListeners = new Set<ConnectionCallback>();\n\n private readonly disconnectListeners = new Set<ConnectionCallback>();\n\n private readonly errorListeners = new Set<ErrorCallback>();\n\n private readonly notificationListeners = new Set<NotificationCallback>();\n\n constructor(options: PositionSocketOptions) {\n this.baseUrl = options.baseUrl ?? \"https://api.dimes.fi\";\n this.getToken = options.getToken;\n }\n\n public get connected(): boolean {\n return this.socket?.connected ?? false;\n }\n\n public connect(): void {\n if (this.socket?.connected) {\n return;\n }\n\n this.socket?.disconnect();\n\n const token = this.getToken();\n if (!token) {\n return;\n }\n\n const getToken = this.getToken;\n this.socket = io(`${this.baseUrl}${wsNamespace}`, {\n auth: (cb) => cb({ token: getToken() }),\n transports: [\"websocket\"],\n reconnection: true,\n reconnectionDelay: 1000,\n reconnectionDelayMax: 30000,\n });\n\n this.socket.on(\"connect\", () => {\n for (const cb of this.connectListeners) {\n cb();\n }\n });\n\n this.socket.on(\"disconnect\", () => {\n for (const cb of this.disconnectListeners) {\n cb();\n }\n });\n\n this.socket.on(\"error\", (err: unknown) => {\n for (const cb of this.errorListeners) {\n cb(err);\n }\n });\n\n for (const eventType of positionEventTypes) {\n this.socket.on(eventType, (envelope: PositionEventEnvelope) => {\n const event = camelizeEnvelope(envelope);\n this.emit(eventType, event);\n this.emit(\"*\", event);\n });\n }\n\n this.socket.on(\"notification\", (envelope: NotificationEventEnvelope) => {\n const event: NotificationEvent = {\n id: envelope.id,\n type: \"notification\",\n createdAt: envelope.created_at,\n data: envelope.data,\n };\n for (const cb of this.notificationListeners) {\n cb(event);\n }\n });\n }\n\n public disconnect(): void {\n this.socket?.disconnect();\n this.socket = null;\n }\n\n public reconnectWithToken(): void {\n this.disconnect();\n this.connect();\n }\n\n public on(event: PositionEventType | \"*\", cb: EventCallback): () => void {\n let set = this.eventListeners.get(event);\n if (!set) {\n set = new Set();\n this.eventListeners.set(event, set);\n }\n set.add(cb);\n return () => set.delete(cb);\n }\n\n public onConnect(cb: ConnectionCallback): () => void {\n this.connectListeners.add(cb);\n return () => this.connectListeners.delete(cb);\n }\n\n public onDisconnect(cb: ConnectionCallback): () => void {\n this.disconnectListeners.add(cb);\n return () => this.disconnectListeners.delete(cb);\n }\n\n public onError(cb: ErrorCallback): () => void {\n this.errorListeners.add(cb);\n return () => this.errorListeners.delete(cb);\n }\n\n public onNotification(cb: NotificationCallback): () => void {\n this.notificationListeners.add(cb);\n return () => this.notificationListeners.delete(cb);\n }\n\n private emit(event: string, data: PositionEvent): void {\n const set = this.eventListeners.get(event);\n if (!set) {\n return;\n }\n for (const cb of set) {\n cb(data);\n }\n }\n}\n"]}
@@ -1,12 +1,13 @@
1
- import { a as PositionEventType, P as PositionEvent } from '../types-C2WfUBLu.cjs';
2
- export { b as PositionEventEnvelope, p as positionEventTypes } from '../types-C2WfUBLu.cjs';
3
- import '../aliases-CXfmUrAb.cjs';
1
+ import { a as PositionEventType, P as PositionEvent, N as NotificationEvent } from '../types--ysRe5Os.cjs';
2
+ export { b as NotificationCode, c as NotificationEventEnvelope, d as PositionEventEnvelope, n as notificationCodes, p as positionEventTypes } from '../types--ysRe5Os.cjs';
3
+ import '../aliases-DzVxkXtK.cjs';
4
4
 
5
5
  interface PositionSocketOptions {
6
6
  baseUrl?: string;
7
7
  getToken: () => string | null;
8
8
  }
9
9
  type EventCallback = (event: PositionEvent) => void;
10
+ type NotificationCallback = (event: NotificationEvent) => void;
10
11
  type ConnectionCallback = () => void;
11
12
  type ErrorCallback = (error: unknown) => void;
12
13
  declare class PositionSocket {
@@ -17,6 +18,7 @@ declare class PositionSocket {
17
18
  private readonly connectListeners;
18
19
  private readonly disconnectListeners;
19
20
  private readonly errorListeners;
21
+ private readonly notificationListeners;
20
22
  constructor(options: PositionSocketOptions);
21
23
  get connected(): boolean;
22
24
  connect(): void;
@@ -26,7 +28,8 @@ declare class PositionSocket {
26
28
  onConnect(cb: ConnectionCallback): () => void;
27
29
  onDisconnect(cb: ConnectionCallback): () => void;
28
30
  onError(cb: ErrorCallback): () => void;
31
+ onNotification(cb: NotificationCallback): () => void;
29
32
  private emit;
30
33
  }
31
34
 
32
- export { PositionEvent, PositionEventType, PositionSocket, type PositionSocketOptions };
35
+ export { NotificationEvent, PositionEvent, PositionEventType, PositionSocket, type PositionSocketOptions };
@@ -1,12 +1,13 @@
1
- import { a as PositionEventType, P as PositionEvent } from '../types-oz2d_Nyk.js';
2
- export { b as PositionEventEnvelope, p as positionEventTypes } from '../types-oz2d_Nyk.js';
3
- import '../aliases-CXfmUrAb.js';
1
+ import { a as PositionEventType, P as PositionEvent, N as NotificationEvent } from '../types-BcUKsoEs.js';
2
+ export { b as NotificationCode, c as NotificationEventEnvelope, d as PositionEventEnvelope, n as notificationCodes, p as positionEventTypes } from '../types-BcUKsoEs.js';
3
+ import '../aliases-DzVxkXtK.js';
4
4
 
5
5
  interface PositionSocketOptions {
6
6
  baseUrl?: string;
7
7
  getToken: () => string | null;
8
8
  }
9
9
  type EventCallback = (event: PositionEvent) => void;
10
+ type NotificationCallback = (event: NotificationEvent) => void;
10
11
  type ConnectionCallback = () => void;
11
12
  type ErrorCallback = (error: unknown) => void;
12
13
  declare class PositionSocket {
@@ -17,6 +18,7 @@ declare class PositionSocket {
17
18
  private readonly connectListeners;
18
19
  private readonly disconnectListeners;
19
20
  private readonly errorListeners;
21
+ private readonly notificationListeners;
20
22
  constructor(options: PositionSocketOptions);
21
23
  get connected(): boolean;
22
24
  connect(): void;
@@ -26,7 +28,8 @@ declare class PositionSocket {
26
28
  onConnect(cb: ConnectionCallback): () => void;
27
29
  onDisconnect(cb: ConnectionCallback): () => void;
28
30
  onError(cb: ErrorCallback): () => void;
31
+ onNotification(cb: NotificationCallback): () => void;
29
32
  private emit;
30
33
  }
31
34
 
32
- export { PositionEvent, PositionEventType, PositionSocket, type PositionSocketOptions };
35
+ export { NotificationEvent, PositionEvent, PositionEventType, PositionSocket, type PositionSocketOptions };
package/dist/ws/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
+ notificationCodes,
2
3
  positionEventTypes
3
- } from "../chunk-XWRROLKW.mjs";
4
+ } from "../chunk-YUCGNELT.mjs";
4
5
 
5
6
  // src/ws/position-socket.ts
6
7
  import { camelizeKeys } from "humps";
@@ -22,6 +23,7 @@ var PositionSocket = class {
22
23
  connectListeners = /* @__PURE__ */ new Set();
23
24
  disconnectListeners = /* @__PURE__ */ new Set();
24
25
  errorListeners = /* @__PURE__ */ new Set();
26
+ notificationListeners = /* @__PURE__ */ new Set();
25
27
  constructor(options) {
26
28
  this.baseUrl = options.baseUrl ?? "https://api.dimes.fi";
27
29
  this.getToken = options.getToken;
@@ -68,6 +70,17 @@ var PositionSocket = class {
68
70
  this.emit("*", event);
69
71
  });
70
72
  }
73
+ this.socket.on("notification", (envelope) => {
74
+ const event = {
75
+ id: envelope.id,
76
+ type: "notification",
77
+ createdAt: envelope.created_at,
78
+ data: envelope.data
79
+ };
80
+ for (const cb of this.notificationListeners) {
81
+ cb(event);
82
+ }
83
+ });
71
84
  }
72
85
  disconnect() {
73
86
  this.socket?.disconnect();
@@ -98,6 +111,10 @@ var PositionSocket = class {
98
111
  this.errorListeners.add(cb);
99
112
  return () => this.errorListeners.delete(cb);
100
113
  }
114
+ onNotification(cb) {
115
+ this.notificationListeners.add(cb);
116
+ return () => this.notificationListeners.delete(cb);
117
+ }
101
118
  emit(event, data) {
102
119
  const set = this.eventListeners.get(event);
103
120
  if (!set) {
@@ -110,6 +127,7 @@ var PositionSocket = class {
110
127
  };
111
128
  export {
112
129
  PositionSocket,
130
+ notificationCodes,
113
131
  positionEventTypes
114
132
  };
115
133
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ws/position-socket.ts"],"sourcesContent":["import { camelizeKeys } from \"humps\";\nimport { io, type Socket } from \"socket.io-client\";\nimport type { Position } from \"../types\";\nimport { positionEventTypes, type PositionEvent, type PositionEventEnvelope, type PositionEventType } from \"./types\";\n\nexport interface PositionSocketOptions {\n baseUrl?: string;\n getToken: () => string | null;\n}\n\ntype EventCallback = (event: PositionEvent) => void;\ntype ConnectionCallback = () => void;\ntype ErrorCallback = (error: unknown) => void;\n\nconst wsNamespace = \"/v1/ws/prediction-markets/customer-positions\";\n\nfunction camelizeEnvelope(envelope: PositionEventEnvelope): PositionEvent {\n return {\n id: envelope.id,\n type: envelope.type,\n createdAt: envelope.created_at,\n data: camelizeKeys(envelope.data) as unknown as Position,\n };\n}\n\nexport class PositionSocket {\n private socket: Socket | null = null;\n\n private readonly baseUrl: string;\n\n private readonly getToken: () => string | null;\n\n private readonly eventListeners = new Map<string, Set<EventCallback>>();\n\n private readonly connectListeners = new Set<ConnectionCallback>();\n\n private readonly disconnectListeners = new Set<ConnectionCallback>();\n\n private readonly errorListeners = new Set<ErrorCallback>();\n\n constructor(options: PositionSocketOptions) {\n this.baseUrl = options.baseUrl ?? \"https://api.dimes.fi\";\n this.getToken = options.getToken;\n }\n\n public get connected(): boolean {\n return this.socket?.connected ?? false;\n }\n\n public connect(): void {\n if (this.socket?.connected) {\n return;\n }\n\n this.socket?.disconnect();\n\n const token = this.getToken();\n if (!token) {\n return;\n }\n\n const getToken = this.getToken;\n this.socket = io(`${this.baseUrl}${wsNamespace}`, {\n auth: (cb) => cb({ token: getToken() }),\n transports: [\"websocket\"],\n reconnection: true,\n reconnectionDelay: 1000,\n reconnectionDelayMax: 30000,\n });\n\n this.socket.on(\"connect\", () => {\n for (const cb of this.connectListeners) {\n cb();\n }\n });\n\n this.socket.on(\"disconnect\", () => {\n for (const cb of this.disconnectListeners) {\n cb();\n }\n });\n\n this.socket.on(\"error\", (err: unknown) => {\n for (const cb of this.errorListeners) {\n cb(err);\n }\n });\n\n for (const eventType of positionEventTypes) {\n this.socket.on(eventType, (envelope: PositionEventEnvelope) => {\n const event = camelizeEnvelope(envelope);\n this.emit(eventType, event);\n this.emit(\"*\", event);\n });\n }\n }\n\n public disconnect(): void {\n this.socket?.disconnect();\n this.socket = null;\n }\n\n public reconnectWithToken(): void {\n this.disconnect();\n this.connect();\n }\n\n public on(event: PositionEventType | \"*\", cb: EventCallback): () => void {\n let set = this.eventListeners.get(event);\n if (!set) {\n set = new Set();\n this.eventListeners.set(event, set);\n }\n set.add(cb);\n return () => set.delete(cb);\n }\n\n public onConnect(cb: ConnectionCallback): () => void {\n this.connectListeners.add(cb);\n return () => this.connectListeners.delete(cb);\n }\n\n public onDisconnect(cb: ConnectionCallback): () => void {\n this.disconnectListeners.add(cb);\n return () => this.disconnectListeners.delete(cb);\n }\n\n public onError(cb: ErrorCallback): () => void {\n this.errorListeners.add(cb);\n return () => this.errorListeners.delete(cb);\n }\n\n private emit(event: string, data: PositionEvent): void {\n const set = this.eventListeners.get(event);\n if (!set) {\n return;\n }\n for (const cb of set) {\n cb(data);\n }\n }\n}\n"],"mappings":";;;;;AAAA,SAAS,oBAAoB;AAC7B,SAAS,UAAuB;AAahC,IAAM,cAAc;AAEpB,SAAS,iBAAiB,UAAgD;AACxE,SAAO;AAAA,IACL,IAAI,SAAS;AAAA,IACb,MAAM,SAAS;AAAA,IACf,WAAW,SAAS;AAAA,IACpB,MAAM,aAAa,SAAS,IAAI;AAAA,EAClC;AACF;AAEO,IAAM,iBAAN,MAAqB;AAAA,EAClB,SAAwB;AAAA,EAEf;AAAA,EAEA;AAAA,EAEA,iBAAiB,oBAAI,IAAgC;AAAA,EAErD,mBA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EAEO,aAAmB;AACxB,SAAK,QAAQ,WAAW;AACxB,SAAK,SAAS;AAAA,EAChB;AAAA,EAEO,qBAA2B;AAChC,SAAK,WAAW;AAChB,SAAK,QAAQ;AAAA,EACf;AAAA,EAEO,GAAG,OAAgC,IAA+B;AACvE,QAAI,MAAM,KAAK,eAAe,IAAI,KAAK;AACvC,QAAI,CAAC,KAAK;AACR,YAAM,oBAAI,IAAI;AACd,WAAK,eAAe,IAAI,OAAO,GAAG;AAAA,IACpC;AACA,QAAI,IAAI,EAAE;AACV,WAAO,MAAM,IAAI,OAAO,EAAE;AAAA,EAC5B;AAAA,EAEO,UAAU,IAAoC;AACnD,SAAK,iBAAiB,IAAI,EAAE;AAC5B,WAAO,MAAM,KAAK,iBAAiB,OAAO,EAAE;AAAA,EAC9C;AAAA,EAEO,aAAa,IAAoC;AACtD,SAAK,oBAAoB,IAAI,EAAE;AAC/B,WAAO,MAAM,KAAK,oBAAoB,OAAO,EAAE;AAAA,EACjD;AAAA,EAEO,QAAQ,IAA+B;AAC5C,SAAK,eAAe,IAAI,EAAE;AAC1B,WAAO,MAAM,KAAK,eAAe,OAAO,EAAE;AAAA,EAC5C;AAAA,EAEQ,KAAK,OAAe,MAA2B;AACrD,UAAM,MAAM,KAAK,eAAe,IAAI,KAAK;AACzC,QAAI,CAAC,KAAK;AACR;AAAA,IACF;AACA,eAAW,MAAM,KAAK;AACpB,SAAG,IAAI;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/ws/position-socket.ts"],"sourcesContent":["import { camelizeKeys } from \"humps\";\nimport { io, type Socket } from \"socket.io-client\";\nimport type { Position } from \"../types\";\nimport {\n positionEventTypes,\n type NotificationEvent,\n type NotificationEventEnvelope,\n type PositionEvent,\n type PositionEventEnvelope,\n type PositionEventType,\n} from \"./types\";\n\nexport interface PositionSocketOptions {\n baseUrl?: string;\n getToken: () => string | null;\n}\n\ntype EventCallback = (event: PositionEvent) => void;\ntype NotificationCallback = (event: NotificationEvent) => void;\ntype ConnectionCallback = () => void;\ntype ErrorCallback = (error: unknown) => void;\n\nconst wsNamespace = \"/v1/ws/prediction-markets/customer-positions\";\n\nfunction camelizeEnvelope(envelope: PositionEventEnvelope): PositionEvent {\n return {\n id: envelope.id,\n type: envelope.type,\n createdAt: envelope.created_at,\n data: camelizeKeys(envelope.data) as unknown as Position,\n };\n}\n\nexport class PositionSocket {\n private socket: Socket | null = null;\n\n private readonly baseUrl: string;\n\n private readonly getToken: () => string | null;\n\n private readonly eventListeners = new Map<string, Set<EventCallback>>();\n\n private readonly connectListeners = new Set<ConnectionCallback>();\n\n private readonly disconnectListeners = new Set<ConnectionCallback>();\n\n private readonly errorListeners = new Set<ErrorCallback>();\n\n private readonly notificationListeners = new Set<NotificationCallback>();\n\n constructor(options: PositionSocketOptions) {\n this.baseUrl = options.baseUrl ?? \"https://api.dimes.fi\";\n this.getToken = options.getToken;\n }\n\n public get connected(): boolean {\n return this.socket?.connected ?? false;\n }\n\n public connect(): void {\n if (this.socket?.connected) {\n return;\n }\n\n this.socket?.disconnect();\n\n const token = this.getToken();\n if (!token) {\n return;\n }\n\n const getToken = this.getToken;\n this.socket = io(`${this.baseUrl}${wsNamespace}`, {\n auth: (cb) => cb({ token: getToken() }),\n transports: [\"websocket\"],\n reconnection: true,\n reconnectionDelay: 1000,\n reconnectionDelayMax: 30000,\n });\n\n this.socket.on(\"connect\", () => {\n for (const cb of this.connectListeners) {\n cb();\n }\n });\n\n this.socket.on(\"disconnect\", () => {\n for (const cb of this.disconnectListeners) {\n cb();\n }\n });\n\n this.socket.on(\"error\", (err: unknown) => {\n for (const cb of this.errorListeners) {\n cb(err);\n }\n });\n\n for (const eventType of positionEventTypes) {\n this.socket.on(eventType, (envelope: PositionEventEnvelope) => {\n const event = camelizeEnvelope(envelope);\n this.emit(eventType, event);\n this.emit(\"*\", event);\n });\n }\n\n this.socket.on(\"notification\", (envelope: NotificationEventEnvelope) => {\n const event: NotificationEvent = {\n id: envelope.id,\n type: \"notification\",\n createdAt: envelope.created_at,\n data: envelope.data,\n };\n for (const cb of this.notificationListeners) {\n cb(event);\n }\n });\n }\n\n public disconnect(): void {\n this.socket?.disconnect();\n this.socket = null;\n }\n\n public reconnectWithToken(): void {\n this.disconnect();\n this.connect();\n }\n\n public on(event: PositionEventType | \"*\", cb: EventCallback): () => void {\n let set = this.eventListeners.get(event);\n if (!set) {\n set = new Set();\n this.eventListeners.set(event, set);\n }\n set.add(cb);\n return () => set.delete(cb);\n }\n\n public onConnect(cb: ConnectionCallback): () => void {\n this.connectListeners.add(cb);\n return () => this.connectListeners.delete(cb);\n }\n\n public onDisconnect(cb: ConnectionCallback): () => void {\n this.disconnectListeners.add(cb);\n return () => this.disconnectListeners.delete(cb);\n }\n\n public onError(cb: ErrorCallback): () => void {\n this.errorListeners.add(cb);\n return () => this.errorListeners.delete(cb);\n }\n\n public onNotification(cb: NotificationCallback): () => void {\n this.notificationListeners.add(cb);\n return () => this.notificationListeners.delete(cb);\n }\n\n private emit(event: string, data: PositionEvent): void {\n const set = this.eventListeners.get(event);\n if (!set) {\n return;\n }\n for (const cb of set) {\n cb(data);\n }\n }\n}\n"],"mappings":";;;;;;AAAA,SAAS,oBAAoB;AAC7B,SAAS,UAAuB;AAqBhC,IAAM,cAAc;AAEpB,SAAS,iBAAiB,UAAgD;AACxE,SAAO;AAAA,IACL,IAAI,SAAS;AAAA,IACb,MAAM,SAAS;AAAA,IACf,WAAW,SAAS;AAAA,IACpB,MAAM,aAAa,SAAS,IAAI;AAAA,EAClC;AACF;AAEO,IAAM,iBAAN,MAAqB;AAAA,EAClB,SAAwB;AAAA,EAEf;AAAA,EAEA;AAAA,EAEA,iBAAiB,oBAAI,IAAgC;AAAA,EAErD,mBAAmB,oBAAI,IAAwB;AAAA,EAE/C,sBAAsB,oBAAI,IAAwB;AAAA,EAElD,iBAAiB,oBAAI,IAAmB;AAAA,EAExC,wBAAwB,oBAAI,IAA0B;AAAA,EAEvE,YAAY,SAAgC;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- "version": "1.0.6",
3
+ "version": "1.2.0",
4
4
  "description": "TypeScript SDK for the Dimes prediction market API",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/alexemery/bl/dimes-sdk/dist/chunk-MSD7A3XX.cjs","../src/ws/types.ts"],"names":[],"mappings":"AAAA;ACEO,IAAM,mBAAA,EAAqB;AAAA,EAChC,oBAAA;AAAA,EACA,0BAAA;AAAA,EACA,iBAAA;AAAA,EACA,kBAAA;AAAA,EACA,wBAAA;AAAA,EACA,qBAAA;AAAA,EACA,iBAAA;AAAA,EACA,kBAAA;AAAA,EACA,mBAAA;AAAA,EACA;AACF,CAAA;ADAA;AACA;AACE;AACF,gDAAC","file":"/Users/alexemery/bl/dimes-sdk/dist/chunk-MSD7A3XX.cjs","sourcesContent":[null,"import type { Position } from \"../types\";\n\nexport const positionEventTypes = [\n \"position.cancelled\",\n \"position.close_requested\",\n \"position.closed\",\n \"position.created\",\n \"position.force_unwound\",\n \"position.liquidated\",\n \"position.opened\",\n \"position.opening\",\n \"position.reverted\",\n \"position.settled\",\n] as const;\n\nexport type PositionEventType = (typeof positionEventTypes)[number];\n\nexport interface PositionEventEnvelope {\n id: string;\n type: PositionEventType;\n created_at: string;\n data: Record<string, unknown>;\n}\n\nexport interface PositionEvent {\n id: string;\n type: PositionEventType;\n createdAt: string;\n data: Position;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/ws/types.ts"],"sourcesContent":["import type { Position } from \"../types\";\n\nexport const positionEventTypes = [\n \"position.cancelled\",\n \"position.close_requested\",\n \"position.closed\",\n \"position.created\",\n \"position.force_unwound\",\n \"position.liquidated\",\n \"position.opened\",\n \"position.opening\",\n \"position.reverted\",\n \"position.settled\",\n] as const;\n\nexport type PositionEventType = (typeof positionEventTypes)[number];\n\nexport interface PositionEventEnvelope {\n id: string;\n type: PositionEventType;\n created_at: string;\n data: Record<string, unknown>;\n}\n\nexport interface PositionEvent {\n id: string;\n type: PositionEventType;\n createdAt: string;\n data: Position;\n}\n"],"mappings":";AAEO,IAAM,qBAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
@@ -1,18 +0,0 @@
1
- import { P as Position } from './aliases-CXfmUrAb.cjs';
2
-
3
- declare const positionEventTypes: readonly ["position.cancelled", "position.close_requested", "position.closed", "position.created", "position.force_unwound", "position.liquidated", "position.opened", "position.opening", "position.reverted", "position.settled"];
4
- type PositionEventType = (typeof positionEventTypes)[number];
5
- interface PositionEventEnvelope {
6
- id: string;
7
- type: PositionEventType;
8
- created_at: string;
9
- data: Record<string, unknown>;
10
- }
11
- interface PositionEvent {
12
- id: string;
13
- type: PositionEventType;
14
- createdAt: string;
15
- data: Position;
16
- }
17
-
18
- export { type PositionEvent as P, type PositionEventType as a, type PositionEventEnvelope as b, positionEventTypes as p };
@@ -1,18 +0,0 @@
1
- import { P as Position } from './aliases-CXfmUrAb.js';
2
-
3
- declare const positionEventTypes: readonly ["position.cancelled", "position.close_requested", "position.closed", "position.created", "position.force_unwound", "position.liquidated", "position.opened", "position.opening", "position.reverted", "position.settled"];
4
- type PositionEventType = (typeof positionEventTypes)[number];
5
- interface PositionEventEnvelope {
6
- id: string;
7
- type: PositionEventType;
8
- created_at: string;
9
- data: Record<string, unknown>;
10
- }
11
- interface PositionEvent {
12
- id: string;
13
- type: PositionEventType;
14
- createdAt: string;
15
- data: Position;
16
- }
17
-
18
- export { type PositionEvent as P, type PositionEventType as a, type PositionEventEnvelope as b, positionEventTypes as p };