@fairmint/canton-node-sdk 0.0.88 → 0.0.90

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 (79) hide show
  1. package/build/src/clients/ledger-json-api/LedgerJsonApiClient.generated.d.ts +9 -0
  2. package/build/src/clients/ledger-json-api/LedgerJsonApiClient.generated.d.ts.map +1 -1
  3. package/build/src/clients/ledger-json-api/LedgerJsonApiClient.generated.js +8 -0
  4. package/build/src/clients/ledger-json-api/LedgerJsonApiClient.generated.js.map +1 -1
  5. package/build/src/clients/ledger-json-api/operations/v2/commands/subscribe-to-completions.d.ts +17 -0
  6. package/build/src/clients/ledger-json-api/operations/v2/commands/subscribe-to-completions.d.ts.map +1 -0
  7. package/build/src/clients/ledger-json-api/operations/v2/commands/subscribe-to-completions.js +32 -0
  8. package/build/src/clients/ledger-json-api/operations/v2/commands/subscribe-to-completions.js.map +1 -0
  9. package/build/src/clients/ledger-json-api/operations/v2/state/subscribe-to-active-contracts.d.ts +51 -0
  10. package/build/src/clients/ledger-json-api/operations/v2/state/subscribe-to-active-contracts.d.ts.map +1 -0
  11. package/build/src/clients/ledger-json-api/operations/v2/state/subscribe-to-active-contracts.js +34 -0
  12. package/build/src/clients/ledger-json-api/operations/v2/state/subscribe-to-active-contracts.js.map +1 -0
  13. package/build/src/clients/ledger-json-api/operations/v2/updates/get-flats.d.ts +10 -0
  14. package/build/src/clients/ledger-json-api/operations/v2/updates/get-flats.d.ts.map +1 -1
  15. package/build/src/clients/ledger-json-api/operations/v2/updates/subscribe-to-flats.d.ts +237 -0
  16. package/build/src/clients/ledger-json-api/operations/v2/updates/subscribe-to-flats.d.ts.map +1 -0
  17. package/build/src/clients/ledger-json-api/operations/v2/updates/subscribe-to-flats.js +36 -0
  18. package/build/src/clients/ledger-json-api/operations/v2/updates/subscribe-to-flats.js.map +1 -0
  19. package/build/src/clients/ledger-json-api/operations/v2/updates/subscribe-to-trees.d.ts +239 -0
  20. package/build/src/clients/ledger-json-api/operations/v2/updates/subscribe-to-trees.d.ts.map +1 -0
  21. package/build/src/clients/ledger-json-api/operations/v2/updates/subscribe-to-trees.js +34 -0
  22. package/build/src/clients/ledger-json-api/operations/v2/updates/subscribe-to-trees.js.map +1 -0
  23. package/build/src/clients/ledger-json-api/operations/v2/updates/utils/format-normalizers.d.ts +8 -0
  24. package/build/src/clients/ledger-json-api/operations/v2/updates/utils/format-normalizers.d.ts.map +1 -0
  25. package/build/src/clients/ledger-json-api/operations/v2/updates/utils/format-normalizers.js +95 -0
  26. package/build/src/clients/ledger-json-api/operations/v2/updates/utils/format-normalizers.js.map +1 -0
  27. package/build/src/clients/ledger-json-api/schemas/api/completions.d.ts +120 -6
  28. package/build/src/clients/ledger-json-api/schemas/api/completions.d.ts.map +1 -1
  29. package/build/src/clients/ledger-json-api/schemas/api/completions.js +19 -2
  30. package/build/src/clients/ledger-json-api/schemas/api/completions.js.map +1 -1
  31. package/build/src/clients/ledger-json-api/schemas/api/errors.d.ts +17 -0
  32. package/build/src/clients/ledger-json-api/schemas/api/errors.d.ts.map +1 -1
  33. package/build/src/clients/ledger-json-api/schemas/api/errors.js +17 -1
  34. package/build/src/clients/ledger-json-api/schemas/api/errors.js.map +1 -1
  35. package/build/src/clients/ledger-json-api/schemas/api/updates.d.ts +71 -0
  36. package/build/src/clients/ledger-json-api/schemas/api/updates.d.ts.map +1 -1
  37. package/build/src/clients/ledger-json-api/schemas/api/updates.js +17 -1
  38. package/build/src/clients/ledger-json-api/schemas/api/updates.js.map +1 -1
  39. package/build/src/clients/lighthouse-api/LighthouseApiClient.generated.d.ts.map +1 -1
  40. package/build/src/clients/lighthouse-api/LighthouseApiClient.generated.js.map +1 -1
  41. package/build/src/clients/register.d.ts +0 -1
  42. package/build/src/clients/register.d.ts.map +1 -1
  43. package/build/src/clients/register.js +1 -3
  44. package/build/src/clients/register.js.map +1 -1
  45. package/build/src/clients/validator-api/ValidatorApiClient.generated.d.ts.map +1 -1
  46. package/build/src/clients/validator-api/ValidatorApiClient.generated.js.map +1 -1
  47. package/build/src/core/BaseClient.d.ts +1 -0
  48. package/build/src/core/BaseClient.d.ts.map +1 -1
  49. package/build/src/core/BaseClient.js +3 -0
  50. package/build/src/core/BaseClient.js.map +1 -1
  51. package/build/src/core/errors.d.ts +2 -1
  52. package/build/src/core/errors.d.ts.map +1 -1
  53. package/build/src/core/errors.js +2 -1
  54. package/build/src/core/errors.js.map +1 -1
  55. package/build/src/core/index.d.ts +1 -0
  56. package/build/src/core/index.d.ts.map +1 -1
  57. package/build/src/core/index.js +1 -0
  58. package/build/src/core/index.js.map +1 -1
  59. package/build/src/core/operations/WebSocketOperationFactory.d.ts +17 -0
  60. package/build/src/core/operations/WebSocketOperationFactory.d.ts.map +1 -0
  61. package/build/src/core/operations/WebSocketOperationFactory.js +38 -0
  62. package/build/src/core/operations/WebSocketOperationFactory.js.map +1 -0
  63. package/build/src/core/operations/index.d.ts +1 -0
  64. package/build/src/core/operations/index.d.ts.map +1 -1
  65. package/build/src/core/operations/index.js +1 -0
  66. package/build/src/core/operations/index.js.map +1 -1
  67. package/build/src/core/ws/WebSocketClient.d.ts +27 -0
  68. package/build/src/core/ws/WebSocketClient.d.ts.map +1 -0
  69. package/build/src/core/ws/WebSocketClient.js +96 -0
  70. package/build/src/core/ws/WebSocketClient.js.map +1 -0
  71. package/build/src/core/ws/WebSocketErrorUtils.d.ts +36 -0
  72. package/build/src/core/ws/WebSocketErrorUtils.d.ts.map +1 -0
  73. package/build/src/core/ws/WebSocketErrorUtils.js +71 -0
  74. package/build/src/core/ws/WebSocketErrorUtils.js.map +1 -0
  75. package/build/src/core/ws/index.d.ts +2 -0
  76. package/build/src/core/ws/index.d.ts.map +1 -0
  77. package/build/src/core/ws/index.js +18 -0
  78. package/build/src/core/ws/index.js.map +1 -0
  79. package/package.json +8 -6
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createWebSocketOperation = createWebSocketOperation;
4
+ const zod_1 = require("zod");
5
+ const ws_1 = require("../ws");
6
+ const errors_1 = require("../errors");
7
+ function createWebSocketOperation(config) {
8
+ return class WebSocketOperation {
9
+ constructor(client) {
10
+ this.client = client;
11
+ }
12
+ validateParams(params, schema) {
13
+ try {
14
+ return schema.parse(params);
15
+ }
16
+ catch (error) {
17
+ if (error instanceof zod_1.z.ZodError) {
18
+ throw new errors_1.ValidationError(`Parameter validation failed: ${error.issues.map(e => `${e.path.join('.')}: ${e.message}`).join(', ')}`);
19
+ }
20
+ throw error;
21
+ }
22
+ }
23
+ async subscribe(params, handlers) {
24
+ const validatedParams = this.validateParams(params, config.paramsSchema);
25
+ const wsClient = new ws_1.WebSocketClient(this.client);
26
+ const path = config.buildPath(validatedParams, this.client.getApiUrl(), this.client);
27
+ const request = await config.buildRequestMessage(validatedParams, this.client);
28
+ const wrappedHandlers = config.transformInbound
29
+ ? {
30
+ ...handlers,
31
+ onMessage: (msg) => handlers.onMessage(config.transformInbound(msg)),
32
+ }
33
+ : handlers;
34
+ return wsClient.connect(path, request, wrappedHandlers);
35
+ }
36
+ };
37
+ }
38
+ //# sourceMappingURL=WebSocketOperationFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebSocketOperationFactory.js","sourceRoot":"","sources":["../../../../src/core/operations/WebSocketOperationFactory.ts"],"names":[],"mappings":";;AAYA,4DAsCC;AAlDD,6BAAwB;AAExB,8BAAkF;AAClF,sCAA4C;AAS5C,SAAgB,wBAAwB,CACvC,MAAwE;IAExE,OAAO,MAAM,kBAAkB;QAC9B,YAAmB,MAAkB;YAAlB,WAAM,GAAN,MAAM,CAAY;QAAG,CAAC;QAElC,cAAc,CAAI,MAAS,EAAE,MAAsB;YACzD,IAAI,CAAC;gBACJ,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC7B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,KAAK,YAAY,OAAC,CAAC,QAAQ,EAAE,CAAC;oBACjC,MAAM,IAAI,wBAAe,CACxB,gCAAgC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACvG,CAAC;gBACH,CAAC;gBACD,MAAM,KAAK,CAAC;YACb,CAAC;QACF,CAAC;QAEM,KAAK,CAAC,SAAS,CACrB,MAAc,EACd,QAA2C;YAE3C,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;YACzE,MAAM,QAAQ,GAAG,IAAI,oBAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAClD,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YACrF,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAE/E,MAAM,eAAe,GAAsC,MAAM,CAAC,gBAAgB;gBACjF,CAAC,CAAC;oBACD,GAAG,QAAQ;oBACX,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,gBAAiB,CAAC,GAAG,CAAC,CAAC;iBACrE;gBACD,CAAC,CAAC,QAAQ,CAAC;YAEZ,OAAO,QAAQ,CAAC,OAAO,CAAiC,IAAI,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;QACzF,CAAC;KACD,CAAC;AACH,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from './ApiOperation';
2
2
  export * from './ApiOperationFactory';
3
+ export * from './WebSocketOperationFactory';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/operations/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/operations/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC"}
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./ApiOperation"), exports);
18
18
  __exportStar(require("./ApiOperationFactory"), exports);
19
+ __exportStar(require("./WebSocketOperationFactory"), exports);
19
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/operations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,wDAAsC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/operations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,wDAAsC;AACtC,8DAA4C"}
@@ -0,0 +1,27 @@
1
+ import { BaseClient } from '../BaseClient';
2
+ export interface WebSocketSubscription {
3
+ close: () => void;
4
+ isConnected: () => boolean;
5
+ getConnectionState: () => number;
6
+ }
7
+ export interface WebSocketHandlers<Message, ErrorMessage = unknown> {
8
+ onOpen?: () => void;
9
+ onMessage: (msg: Message) => void;
10
+ onError?: (err: Error | ErrorMessage) => void;
11
+ onClose?: (code: number, reason: string) => void;
12
+ }
13
+ /**
14
+ * Minimal WebSocket helper that:
15
+ * - Upgrades http(s) URL to ws(s)
16
+ * - Auth via Authorization header (standard approach)
17
+ * - Uses 'daml-ledger-api' subprotocol
18
+ * - Sends an initial request message
19
+ * - Dispatches parsed messages to user handlers
20
+ */
21
+ export declare class WebSocketClient {
22
+ private client;
23
+ constructor(client: BaseClient);
24
+ connect<RequestMessage, InboundMessage, ErrorMessage = unknown>(path: string, requestMessage: RequestMessage, handlers: WebSocketHandlers<InboundMessage, ErrorMessage>): Promise<WebSocketSubscription>;
25
+ private buildWsUrl;
26
+ }
27
+ //# sourceMappingURL=WebSocketClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebSocketClient.d.ts","sourceRoot":"","sources":["../../../../src/core/ws/WebSocketClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,WAAW,qBAAqB;IACrC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B,kBAAkB,EAAE,MAAM,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO;IACjE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAClC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,YAAY,KAAK,IAAI,CAAC;IAC9C,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD;AAED;;;;;;;GAOG;AACH,qBAAa,eAAe;IACf,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEzB,OAAO,CAAC,cAAc,EAAE,cAAc,EAAE,YAAY,GAAG,OAAO,EAC1E,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,iBAAiB,CAAC,cAAc,EAAE,YAAY,CAAC,GACvD,OAAO,CAAC,qBAAqB,CAAC;IAwEjC,OAAO,CAAC,UAAU;CAMlB"}
@@ -0,0 +1,96 @@
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
+ exports.WebSocketClient = void 0;
7
+ const ws_1 = __importDefault(require("ws"));
8
+ const WebSocketErrorUtils_1 = require("./WebSocketErrorUtils");
9
+ /**
10
+ * Minimal WebSocket helper that:
11
+ * - Upgrades http(s) URL to ws(s)
12
+ * - Auth via Authorization header (standard approach)
13
+ * - Uses 'daml-ledger-api' subprotocol
14
+ * - Sends an initial request message
15
+ * - Dispatches parsed messages to user handlers
16
+ */
17
+ class WebSocketClient {
18
+ constructor(client) {
19
+ this.client = client;
20
+ }
21
+ async connect(path, requestMessage, handlers) {
22
+ const baseUrl = this.client.getApiUrl();
23
+ const wsUrl = this.buildWsUrl(baseUrl, path);
24
+ const token = await this.client.authenticate();
25
+ // Use standard WebSocket auth pattern:
26
+ // - JWT in Authorization header
27
+ // - Application protocol in subprotocol (daml.ws.auth)
28
+ const protocols = ['daml.ws.auth'];
29
+ const socket = new ws_1.default(wsUrl, protocols, {
30
+ handshakeTimeout: 30000,
31
+ headers: token ? { 'Authorization': `Bearer ${token}` } : undefined,
32
+ });
33
+ const logger = this.client.getLogger();
34
+ const log = async (event, payload) => {
35
+ if (logger) {
36
+ await logger.logRequestResponse(wsUrl, { event, requestMessage }, payload);
37
+ }
38
+ };
39
+ await log('connect', { headers: token ? { Authorization: '[REDACTED]' } : undefined, protocols });
40
+ socket.on('open', async () => {
41
+ try {
42
+ socket.send(JSON.stringify(requestMessage));
43
+ await log('send', requestMessage);
44
+ if (handlers.onOpen)
45
+ handlers.onOpen();
46
+ }
47
+ catch (err) {
48
+ await log('send_error', err instanceof Error ? { message: err.message } : String(err));
49
+ if (handlers.onError)
50
+ handlers.onError(err);
51
+ socket.close();
52
+ }
53
+ });
54
+ socket.on('message', async (data) => {
55
+ try {
56
+ const parsed = WebSocketErrorUtils_1.WebSocketErrorUtils.safeJsonParse(data.toString(), 'WebSocket message');
57
+ await log('message', parsed);
58
+ handlers.onMessage(parsed);
59
+ }
60
+ catch (err) {
61
+ await log('parse_error', { raw: data.toString(), error: err instanceof Error ? err.message : String(err) });
62
+ // Close connection on JSON parse failure to prevent inconsistent state
63
+ socket.close(1003, 'Invalid JSON received');
64
+ if (handlers.onError)
65
+ handlers.onError(err);
66
+ }
67
+ });
68
+ socket.on('error', async (err) => {
69
+ await log('socket_error', { message: err.message });
70
+ if (handlers.onError)
71
+ handlers.onError(err);
72
+ });
73
+ socket.on('close', async (code, reason) => {
74
+ await log('close', { code, reason: reason.toString() });
75
+ if (handlers.onClose)
76
+ handlers.onClose(code, reason.toString());
77
+ });
78
+ return {
79
+ close: () => {
80
+ // Remove all event listeners to prevent memory leaks
81
+ socket.removeAllListeners();
82
+ socket.close();
83
+ },
84
+ isConnected: () => socket.readyState === ws_1.default.OPEN,
85
+ getConnectionState: () => socket.readyState,
86
+ };
87
+ }
88
+ buildWsUrl(base, path) {
89
+ const hasProtocol = base.startsWith('http://') || base.startsWith('https://');
90
+ const normalizedBase = hasProtocol ? base : `https://${base}`;
91
+ const wsBase = normalizedBase.replace(/^http:/, 'ws:').replace(/^https:/, 'wss:');
92
+ return `${wsBase}${path}`;
93
+ }
94
+ }
95
+ exports.WebSocketClient = WebSocketClient;
96
+ //# sourceMappingURL=WebSocketClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebSocketClient.js","sourceRoot":"","sources":["../../../../src/core/ws/WebSocketClient.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAwC;AAExC,+DAA4D;AAe5D;;;;;;;GAOG;AACH,MAAa,eAAe;IAC3B,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAEnC,KAAK,CAAC,OAAO,CACnB,IAAY,EACZ,cAA8B,EAC9B,QAAyD;QAEzD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACxC,MAAM,KAAK,GA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z } from 'zod';
2
+ /**
3
+ * Utility functions for consistent WebSocket error handling
4
+ */
5
+ export declare class WebSocketErrorUtils {
6
+ /**
7
+ * Safely parses a message using multiple schemas, throwing descriptive errors if all fail
8
+ * @param msg - The message to parse
9
+ * @param schemas - Array of schemas to try in order
10
+ * @param operationName - Name of the operation for error context
11
+ * @returns The parsed message
12
+ * @throws CantonError if all schemas fail to parse
13
+ */
14
+ static parseWithFallback<T>(msg: unknown, schemas: Array<{
15
+ schema: z.ZodSchema<T>;
16
+ name: string;
17
+ }>, operationName: string): T;
18
+ /**
19
+ * Parses a union schema and returns the result without type assertion
20
+ * @param msg - The message to parse
21
+ * @param unionSchema - The Zod union schema
22
+ * @param operationName - Name of the operation for error context
23
+ * @returns The parsed message with proper typing
24
+ * @throws CantonError if parsing fails
25
+ */
26
+ static parseUnion<T>(msg: unknown, unionSchema: z.ZodSchema<T>, operationName: string): T;
27
+ /**
28
+ * Creates a safe JSON parser that throws descriptive errors
29
+ * @param data - Raw data to parse
30
+ * @param context - Context for error messages
31
+ * @returns Parsed JSON object
32
+ * @throws CantonError if JSON parsing fails
33
+ */
34
+ static safeJsonParse(data: string, context: string): unknown;
35
+ }
36
+ //# sourceMappingURL=WebSocketErrorUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebSocketErrorUtils.d.ts","sourceRoot":"","sources":["../../../../src/core/ws/WebSocketErrorUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;GAEG;AACH,qBAAa,mBAAmB;IAC9B;;;;;;;OAOG;IACH,MAAM,CAAC,iBAAiB,CAAC,CAAC,EACxB,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,EACxD,aAAa,EAAE,MAAM,GACpB,CAAC;IAsBJ;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,CAAC,EACjB,GAAG,EAAE,OAAO,EACZ,WAAW,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAC3B,aAAa,EAAE,MAAM,GACpB,CAAC;IAmBJ;;;;;;OAMG;IACH,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO;CAW7D"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebSocketErrorUtils = void 0;
4
+ const zod_1 = require("zod");
5
+ const errors_1 = require("../errors");
6
+ /**
7
+ * Utility functions for consistent WebSocket error handling
8
+ */
9
+ class WebSocketErrorUtils {
10
+ /**
11
+ * Safely parses a message using multiple schemas, throwing descriptive errors if all fail
12
+ * @param msg - The message to parse
13
+ * @param schemas - Array of schemas to try in order
14
+ * @param operationName - Name of the operation for error context
15
+ * @returns The parsed message
16
+ * @throws CantonError if all schemas fail to parse
17
+ */
18
+ static parseWithFallback(msg, schemas, operationName) {
19
+ const errors = [];
20
+ for (const { schema, name } of schemas) {
21
+ try {
22
+ return schema.parse(msg);
23
+ }
24
+ catch (error) {
25
+ if (error instanceof zod_1.z.ZodError) {
26
+ errors.push(`${name}: ${error.issues.map(e => e.message).join(', ')}`);
27
+ }
28
+ else {
29
+ errors.push(`${name}: ${error instanceof Error ? error.message : String(error)}`);
30
+ }
31
+ }
32
+ }
33
+ throw new errors_1.CantonError(`Failed to parse ${operationName} message with any expected schema. Errors: ${errors.join('; ')}`, 'VALIDATION_ERROR', { originalMessage: msg, attemptedSchemas: schemas.map(s => s.name) });
34
+ }
35
+ /**
36
+ * Parses a union schema and returns the result without type assertion
37
+ * @param msg - The message to parse
38
+ * @param unionSchema - The Zod union schema
39
+ * @param operationName - Name of the operation for error context
40
+ * @returns The parsed message with proper typing
41
+ * @throws CantonError if parsing fails
42
+ */
43
+ static parseUnion(msg, unionSchema, operationName) {
44
+ try {
45
+ return unionSchema.parse(msg);
46
+ }
47
+ catch (error) {
48
+ if (error instanceof zod_1.z.ZodError) {
49
+ throw new errors_1.CantonError(`Failed to parse ${operationName} message: ${error.issues.map(e => e.message).join(', ')}`, 'VALIDATION_ERROR', { originalMessage: msg, validationErrors: error.issues });
50
+ }
51
+ throw new errors_1.CantonError(`Failed to parse ${operationName} message: ${error instanceof Error ? error.message : String(error)}`, 'VALIDATION_ERROR', { originalMessage: msg });
52
+ }
53
+ }
54
+ /**
55
+ * Creates a safe JSON parser that throws descriptive errors
56
+ * @param data - Raw data to parse
57
+ * @param context - Context for error messages
58
+ * @returns Parsed JSON object
59
+ * @throws CantonError if JSON parsing fails
60
+ */
61
+ static safeJsonParse(data, context) {
62
+ try {
63
+ return JSON.parse(data);
64
+ }
65
+ catch (error) {
66
+ throw new errors_1.CantonError(`Failed to parse JSON in ${context}: ${error instanceof Error ? error.message : String(error)}`, 'VALIDATION_ERROR', { rawData: data, context });
67
+ }
68
+ }
69
+ }
70
+ exports.WebSocketErrorUtils = WebSocketErrorUtils;
71
+ //# sourceMappingURL=WebSocketErrorUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebSocketErrorUtils.js","sourceRoot":"","sources":["../../../../src/core/ws/WebSocketErrorUtils.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,sCAAwC;AAExC;;GAEG;AACH,MAAa,mBAAmB;IAC9B;;;;;;;OAOG;IACH,MAAM,CAAC,iBAAiB,CACtB,GAAY,EACZ,OAAwD,EACxD,aAAqB;QAErB,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,KAAK,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,OAAO,EAAE,CAAC;YACvC,IAAI,CAAC;gBACH,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC3B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,KAAK,YAAY,OAAC,CAAC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,IAAI,oBAAW,CACnB,mBAAmB,aAAa,aAAa,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EACrG,kBAAkB,EAClB,EAAE,eAAe,EAAE,GAAG,EAAE,CACzB,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,aAAa,CAAC,IAAY,EAAE,OAAe;QAChD,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,oBAAW,CACnB,2BAA2B,OAAO,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAC/F,kBAAkB,EAClB,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAC3B,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AApFD,kDAoFC"}
@@ -0,0 +1,2 @@
1
+ export * from './WebSocketClient';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/ws/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./WebSocketClient"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/ws/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fairmint/canton-node-sdk",
3
- "version": "0.0.88",
3
+ "version": "0.0.90",
4
4
  "description": "Canton Node SDK",
5
5
  "main": "build/src/index.js",
6
6
  "types": "build/src/index.d.ts",
@@ -11,7 +11,7 @@
11
11
  "build": "npm run build:core && npm run build:lint",
12
12
  "build:core": "npm run generate:openapi-types && npm run build:core:generate-client-methods && tsc",
13
13
  "build:core:generate-client-methods": "tsx scripts/generate-all-client-methods.ts",
14
- "generate:openapi-types": "find artifacts/splice -name '*.yaml' -exec sh -c 'relative_path=\"$(echo \"$1\" | sed \"s|^artifacts/splice/||\" | sed \"s|\\.yaml$|.ts|\")\"; output_file=\"src/generated/$relative_path\"; mkdir -p \"$(dirname \"$output_file\")\"; npx openapi-typescript \"$1\" -o \"$output_file\"' _ {} \\;",
14
+ "generate:openapi-types": "tsx scripts/generate-openapi-types.ts",
15
15
  "build:lint": "tsc -p tsconfig.lint.json",
16
16
  "simulate": "tsx --tsconfig tsconfig.lint.json scripts/run-simulations.ts",
17
17
  "simulate:events": "tsx --tsconfig tsconfig.lint.json scripts/run-events-simulation.ts",
@@ -56,19 +56,20 @@
56
56
  "@types/jest": "30.0.0",
57
57
  "@types/node": "24.3.0",
58
58
  "@typescript-eslint/eslint-plugin": "8.40.0",
59
- "@typescript-eslint/parser": "8.40.0",
59
+ "@typescript-eslint/parser": "8.41.0",
60
60
  "eslint": "9.34.0",
61
61
  "eslint-config-prettier": "10.1.8",
62
62
  "eslint-plugin-import": "2.32.0",
63
63
  "eslint-plugin-markdown": "5.1.0",
64
64
  "eslint-plugin-prettier": "5.5.4",
65
- "jest": "30.0.5",
65
+ "jest": "30.1.2",
66
66
  "markdownlint-cli": "0.45.0",
67
67
  "npm-package-json-lint": "9.0.0",
68
68
  "prettier": "3.6.2",
69
69
  "ts-jest": "29.4.1",
70
70
  "tsx": "4.20.5",
71
- "typescript": "5.9.2"
71
+ "typescript": "5.9.2",
72
+ "@types/ws": "8.5.12"
72
73
  },
73
74
  "engines": {
74
75
  "node": ">=18.0.0"
@@ -79,6 +80,7 @@
79
80
  "glob": "^11.0.3",
80
81
  "openapi-fetch": "^0.14.0",
81
82
  "openapi-typescript": "7.9.1",
82
- "zod": "4.1.5"
83
+ "zod": "4.1.5",
84
+ "ws": "8.18.0"
83
85
  }
84
86
  }