@fairmint/canton-node-sdk 0.0.266 → 0.0.267

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 (61) hide show
  1. package/README.md +12 -3
  2. package/build/src/clients/ledger-json-api/LedgerJsonApiClient.generated.d.ts +5 -2
  3. package/build/src/clients/ledger-json-api/LedgerJsonApiClient.generated.d.ts.map +1 -1
  4. package/build/src/clients/ledger-json-api/LedgerJsonApiClient.generated.js +2 -0
  5. package/build/src/clients/ledger-json-api/LedgerJsonApiClient.generated.js.map +1 -1
  6. package/build/src/clients/ledger-json-api/index.d.ts +5 -1
  7. package/build/src/clients/ledger-json-api/index.d.ts.map +1 -1
  8. package/build/src/clients/ledger-json-api/index.js +7 -1
  9. package/build/src/clients/ledger-json-api/index.js.map +1 -1
  10. package/build/src/clients/ledger-json-api/operations/v2/commands/submit-and-wait-for-reassignment.d.ts +2 -2
  11. package/build/src/clients/ledger-json-api/operations/v2/state/active-contracts-request.d.ts +49 -0
  12. package/build/src/clients/ledger-json-api/operations/v2/state/active-contracts-request.d.ts.map +1 -0
  13. package/build/src/clients/ledger-json-api/operations/v2/state/active-contracts-request.js +127 -0
  14. package/build/src/clients/ledger-json-api/operations/v2/state/active-contracts-request.js.map +1 -0
  15. package/build/src/clients/ledger-json-api/operations/v2/state/get-active-contracts.d.ts +10 -13
  16. package/build/src/clients/ledger-json-api/operations/v2/state/get-active-contracts.d.ts.map +1 -1
  17. package/build/src/clients/ledger-json-api/operations/v2/state/get-active-contracts.js +18 -106
  18. package/build/src/clients/ledger-json-api/operations/v2/state/get-active-contracts.js.map +1 -1
  19. package/build/src/clients/ledger-json-api/operations/v2/state/index.d.ts +1 -0
  20. package/build/src/clients/ledger-json-api/operations/v2/state/index.d.ts.map +1 -1
  21. package/build/src/clients/ledger-json-api/operations/v2/state/index.js +1 -0
  22. package/build/src/clients/ledger-json-api/operations/v2/state/index.js.map +1 -1
  23. package/build/src/clients/ledger-json-api/operations/v2/state/stream-active-contracts.d.ts +64 -0
  24. package/build/src/clients/ledger-json-api/operations/v2/state/stream-active-contracts.d.ts.map +1 -0
  25. package/build/src/clients/ledger-json-api/operations/v2/state/stream-active-contracts.js +211 -0
  26. package/build/src/clients/ledger-json-api/operations/v2/state/stream-active-contracts.js.map +1 -0
  27. package/build/src/clients/ledger-json-api/operations/v2/updates/get-update-by-id.d.ts +45 -7
  28. package/build/src/clients/ledger-json-api/operations/v2/updates/get-update-by-id.d.ts.map +1 -1
  29. package/build/src/clients/ledger-json-api/operations/v2/updates/get-update-by-id.js +64 -7
  30. package/build/src/clients/ledger-json-api/operations/v2/updates/get-update-by-id.js.map +1 -1
  31. package/build/src/clients/ledger-json-api/operations/v2/updates/get-update-by-offset.d.ts +17 -0
  32. package/build/src/clients/ledger-json-api/operations/v2/updates/get-update-by-offset.d.ts.map +1 -1
  33. package/build/src/clients/ledger-json-api/operations/v2/updates/get-update-by-offset.js +17 -0
  34. package/build/src/clients/ledger-json-api/operations/v2/updates/get-update-by-offset.js.map +1 -1
  35. package/build/src/clients/ledger-json-api/operations/v2/updates/subscribe-to-updates.d.ts +46 -8
  36. package/build/src/clients/ledger-json-api/operations/v2/updates/subscribe-to-updates.d.ts.map +1 -1
  37. package/build/src/clients/ledger-json-api/operations/v2/updates/subscribe-to-updates.js +12 -25
  38. package/build/src/clients/ledger-json-api/operations/v2/updates/subscribe-to-updates.js.map +1 -1
  39. package/build/src/clients/ledger-json-api/operations/v2/utils/event-format-builder.d.ts +29 -0
  40. package/build/src/clients/ledger-json-api/operations/v2/utils/event-format-builder.d.ts.map +1 -1
  41. package/build/src/clients/ledger-json-api/operations/v2/utils/event-format-builder.js +43 -0
  42. package/build/src/clients/ledger-json-api/operations/v2/utils/event-format-builder.js.map +1 -1
  43. package/build/src/clients/ledger-json-api/schemas/api/event-details.d.ts +22 -4
  44. package/build/src/clients/ledger-json-api/schemas/api/event-details.d.ts.map +1 -1
  45. package/build/src/clients/ledger-json-api/schemas/api/events.d.ts +44 -8
  46. package/build/src/clients/ledger-json-api/schemas/api/events.d.ts.map +1 -1
  47. package/build/src/clients/ledger-json-api/schemas/api/interface-view.d.ts +28 -5
  48. package/build/src/clients/ledger-json-api/schemas/api/interface-view.d.ts.map +1 -1
  49. package/build/src/clients/ledger-json-api/schemas/api/interface-view.js +16 -4
  50. package/build/src/clients/ledger-json-api/schemas/api/interface-view.js.map +1 -1
  51. package/build/src/clients/ledger-json-api/schemas/api/reassignment.d.ts +88 -16
  52. package/build/src/clients/ledger-json-api/schemas/api/reassignment.d.ts.map +1 -1
  53. package/build/src/clients/ledger-json-api/schemas/api/state.d.ts +176 -32
  54. package/build/src/clients/ledger-json-api/schemas/api/state.d.ts.map +1 -1
  55. package/build/src/clients/ledger-json-api/schemas/api/updates.d.ts +242 -44
  56. package/build/src/clients/ledger-json-api/schemas/api/updates.d.ts.map +1 -1
  57. package/build/src/core/ws/WebSocketClient.d.ts +8 -0
  58. package/build/src/core/ws/WebSocketClient.d.ts.map +1 -1
  59. package/build/src/core/ws/WebSocketClient.js +24 -1
  60. package/build/src/core/ws/WebSocketClient.js.map +1 -1
  61. package/package.json +1 -1
@@ -1,126 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GetActiveContracts = void 0;
4
- const zod_1 = require("zod");
5
- const errors_1 = require("../../../../../core/errors");
6
- const HttpClient_1 = require("../../../../../core/http/HttpClient");
7
4
  const WebSocketClient_1 = require("../../../../../core/ws/WebSocketClient");
8
- const errors_2 = require("../../../schemas/api/errors");
9
- const state_1 = require("../../../schemas/api/state");
10
- const event_format_builder_1 = require("../utils/event-format-builder");
11
- const path = '/v2/state/active-contracts';
12
- /**
13
- * Idle timeout for the active-contracts snapshot stream.
14
- *
15
- * The snapshot is a bounded stream that the server closes on its own, so silence this long means the connection is hung
16
- * rather than slow. Callers that expect longer gaps can raise it or pass `0` to wait indefinitely.
17
- *
18
- * Intentionally reuses {@link DEFAULT_HTTP_TIMEOUT_MS} rather than an independent literal: both exist to detect a hung
19
- * connection at the same "this is clearly stuck" horizon.
20
- */
21
- const DEFAULT_IDLE_TIMEOUT_MS = HttpClient_1.DEFAULT_HTTP_TIMEOUT_MS;
22
- /**
23
- * We intentionally do not expose the JSON/REST version of this endpoint. The REST variant is too limited, while the
24
- * WebSocket variant returns the same snapshot and automatically closes the connection once the current state is sent.
25
- * Wrapping the WebSocket call behind a simple awaitable method gives a better DX and keeps the door open for optional
26
- * streaming via a callback.
27
- */
28
- const ActiveContractsParamsSchema = zod_1.z.object({
29
- /** Optional list of parties to scope the filter. */
30
- parties: zod_1.z.array(zod_1.z.string()).optional(),
31
- /** Optional template filters applied server-side. */
32
- templateIds: zod_1.z.array(zod_1.z.string()).optional(),
33
- /** Optional interface filters applied server-side. */
34
- interfaceIds: zod_1.z.array(zod_1.z.string()).optional(),
35
- /** Include interface views in InterfaceFilter results (default true). */
36
- includeInterfaceView: zod_1.z.boolean().optional(),
37
- /** Include created event blobs in template and interface filter results (default false). */
38
- includeCreatedEventBlob: zod_1.z.boolean().optional(),
39
- /** Allow caller to omit activeAtOffset; we'll default to ledger end */
40
- activeAtOffset: zod_1.z.number().optional(),
41
- /** Fail the snapshot when no message arrives for this many milliseconds. `0` waits indefinitely. */
42
- idleTimeoutMs: zod_1.z.number().min(0).optional(),
43
- });
5
+ const active_contracts_request_1 = require("./active-contracts-request");
44
6
  class GetActiveContracts {
45
7
  constructor(client) {
46
8
  this.client = client;
47
9
  }
48
10
  async execute(params) {
49
- const validated = ActiveContractsParamsSchema.parse(params);
50
- // Determine activeAtOffset (default to ledger end if not specified)
51
- let activeAtOffset;
52
- if (validated.activeAtOffset !== undefined) {
53
- ({ activeAtOffset } = validated);
54
- }
55
- else {
56
- const ledgerEnd = await this.client.getLedgerEnd({});
57
- const { offset } = ledgerEnd;
58
- if (offset === undefined) {
59
- throw new errors_1.ApiError('Ledger end response did not include an offset');
60
- }
61
- activeAtOffset = offset;
62
- }
63
- // Build party list - default to client's party list if not provided
64
- const partyList = validated.parties && validated.parties.length > 0 ? validated.parties : this.client.buildPartyList();
65
- // Build event format
66
- const eventFormat = (0, event_format_builder_1.buildEventFormat)({
67
- parties: partyList,
68
- ...(validated.templateIds !== undefined && { templateIds: validated.templateIds }),
69
- ...(validated.interfaceIds !== undefined && { interfaceIds: validated.interfaceIds }),
70
- ...(validated.includeInterfaceView !== undefined && {
71
- includeInterfaceView: validated.includeInterfaceView,
72
- }),
73
- ...(validated.includeCreatedEventBlob !== undefined && {
74
- includeCreatedEventBlob: validated.includeCreatedEventBlob,
75
- }),
76
- });
77
- const ActiveContractsResponseMessageSchema = zod_1.z.union([
78
- state_1.JsGetActiveContractsResponseItemSchema,
79
- errors_2.JsCantonErrorSchema,
80
- errors_2.WsCantonErrorSchema,
81
- ]);
82
- const requestMessage = {
83
- verbose: false,
84
- activeAtOffset,
85
- eventFormat,
86
- };
11
+ const { requestMessage, idleTimeoutMs } = await (0, active_contracts_request_1.buildActiveContractsRequest)(this.client, params);
87
12
  const wsClient = new WebSocketClient_1.WebSocketClient(this.client);
88
13
  return new Promise((resolve, reject) => {
89
14
  const results = [];
90
15
  let settled = false;
91
- /** Convert a Canton error response to a proper Error object */
92
- const toError = (errorResponse) => {
93
- // JsCantonError has 'message' string, WsCantonError has 'cause' string
94
- // JsCantonError has code as object, WsCantonError has code as string
95
- if ('cause' in errorResponse) {
96
- // WsCantonError
97
- return new errors_1.ApiError(`WebSocket error [${errorResponse.code}]: ${errorResponse.cause}`);
98
- }
99
- // JsCantonError
100
- const codeStr = JSON.stringify(errorResponse.code);
101
- return new errors_1.ApiError(`WebSocket error [${codeStr}]: ${errorResponse.message}`);
102
- };
103
16
  void wsClient
104
- .connect(path, requestMessage, {
17
+ .connect(active_contracts_request_1.ACTIVE_CONTRACTS_PATH, requestMessage, {
105
18
  onMessage: async (parsed) => {
106
- const decoded = ActiveContractsResponseMessageSchema.safeParse(parsed);
107
- if (!decoded.success) {
108
- throw new errors_1.ApiError('Unexpected active-contracts WebSocket message');
109
- }
110
- const message = decoded.data;
111
- // Distinguish item vs error union members
112
- if ('contractEntry' in message) {
113
- results.push(message);
19
+ const frame = (0, active_contracts_request_1.decodeActiveContractsFrame)(parsed);
20
+ if ('item' in frame) {
21
+ results.push(frame.item);
114
22
  if (typeof params.onItem === 'function') {
115
- await params.onItem(message);
23
+ await params.onItem(frame.item);
116
24
  }
117
25
  }
118
26
  else if (!settled) {
119
- // Treat any non-item as an error message
120
- const error = toError(message);
121
27
  settled = true;
122
- reject(error);
123
- throw error;
28
+ reject(frame.error);
29
+ throw frame.error;
124
30
  }
125
31
  },
126
32
  onError: (err) => {
@@ -129,13 +35,19 @@ class GetActiveContracts {
129
35
  reject(err instanceof Error ? err : new Error(String(err)));
130
36
  }
131
37
  },
132
- onClose: () => {
38
+ onClose: (code, reason) => {
133
39
  if (!settled) {
134
40
  settled = true;
135
- resolve(results);
41
+ const error = (0, active_contracts_request_1.activeContractsCloseError)(code, reason);
42
+ if (error === undefined) {
43
+ resolve(results);
44
+ }
45
+ else {
46
+ reject(error);
47
+ }
136
48
  }
137
49
  },
138
- }, { idleTimeoutMs: validated.idleTimeoutMs ?? DEFAULT_IDLE_TIMEOUT_MS })
50
+ }, { idleTimeoutMs })
139
51
  .catch((err) => {
140
52
  if (!settled) {
141
53
  settled = true;
@@ -1 +1 @@
1
- {"version":3,"file":"get-active-contracts.js","sourceRoot":"","sources":["../../../../../../../src/clients/ledger-json-api/operations/v2/state/get-active-contracts.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,uDAAsD;AACtD,oEAA8E;AAC9E,4EAAyE;AAEzE,wDAKqC;AACrC,sDAIoC;AACpC,wEAAiE;AAEjE,MAAM,IAAI,GAAG,4BAAqC,CAAC;AAEnD;;;;;;;;GAQG;AACH,MAAM,uBAAuB,GAAG,oCAAuB,CAAC;AAExD;;;;;GAKG;AAEH,MAAM,2BAA2B,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,oDA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;oBACd,CAAC;gBACH,CAAC;gBACD,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;oBACf,IAAI,CAAC,OAAO,EAAE,CAAC;wBACb,OAAO,GAAG,IAAI,CAAC;wBACf,MAAM,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBAC9D,CAAC;gBACH,CAAC;gBACD,OAAO,EAAE,GAAG,EAAE;oBACZ,IAAI,CAAC,OAAO,EAAE,CAAC;wBACb,OAAO,GAAG,IAAI,CAAC;wBACf,OAAO,CAAC,OAAO,CAAC,CAAC;oBACnB,CAAC;gBACH,CAAC;aACF,EACD,EAAE,aAAa,EAAE,SAAS,CAAC,aAAa,IAAI,uBAAuB,EAAE,CACtE;iBACA,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;gBACtB,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,OAAO,GAAG,IAAI,CAAC;oBACf,MAAM,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;gBAC9D,CAAC;YACH,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
1
+ {"version":3,"file":"get-active-contracts.js","sourceRoot":"","sources":["../../../../../../../src/clients/ledger-json-api/operations/v2/state/get-active-contracts.ts"],"names":[],"mappings":";;;AAAA,4EAAyE;AAGzE,yEAOoC;AAqBpC;IACE,YAA6B,MAA2B;sBAA3B,MAAM;IAAwB,CAAC;IAErD,KAAK,CAAC,OAAO,CAAC,MAAgC;QACnD,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,MAAM,IAAA,sDAA2B,EAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAEjG,MAAM,QAAQ,GAAG,IA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yB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;wBACtD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;4BACxB,OAAO,CAAC,OAAO,CAAC,CAAC;wBACnB,CAAC;6BAAM,CAAC;4BACN,MAAM,CAAC,KAAK,CAAC,CAAC;wBAChB,CAAC;oBACH,CAAC;gBACH,CAAC;aACF,EACD,EAAE,aAAa,EAAE,CAClB;iBACA,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;gBACtB,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,OAAO,GAAG,IAAI,CAAC;oBACf,MAAM,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;gBAC9D,CAAC;YACH,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -2,4 +2,5 @@ export * from './get-active-contracts';
2
2
  export * from './get-connected-synchronizers';
3
3
  export * from './get-latest-pruned-offsets';
4
4
  export * from './get-ledger-end';
5
+ export * from './stream-active-contracts';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/clients/ledger-json-api/operations/v2/state/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/clients/ledger-json-api/operations/v2/state/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC"}
@@ -18,4 +18,5 @@ __exportStar(require("./get-active-contracts"), exports);
18
18
  __exportStar(require("./get-connected-synchronizers"), exports);
19
19
  __exportStar(require("./get-latest-pruned-offsets"), exports);
20
20
  __exportStar(require("./get-ledger-end"), exports);
21
+ __exportStar(require("./stream-active-contracts"), exports);
21
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/clients/ledger-json-api/operations/v2/state/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,gEAA8C;AAC9C,8DAA4C;AAC5C,mDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/clients/ledger-json-api/operations/v2/state/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,gEAA8C;AAC9C,8DAA4C;AAC5C,mDAAiC;AACjC,4DAA0C"}
@@ -0,0 +1,64 @@
1
+ import type { LedgerJsonApiClient } from '../../../LedgerJsonApiClient.generated';
2
+ import type { JsGetActiveContractsResponseItem } from '../../../schemas/api/state';
3
+ import { type ActiveContractsParams } from './active-contracts-request';
4
+ /**
5
+ * Most received items that wait for the consumer before the socket stops reading. Past it the participant's sends back
6
+ * up behind TCP flow control instead of the snapshot collecting in memory; reading resumes once half have been taken.
7
+ */
8
+ export declare const ACTIVE_CONTRACTS_STREAM_HIGH_WATER_MARK = 256;
9
+ /** Parameters of `streamActiveContracts`: those of `getActiveContracts` without its `onItem` callback. */
10
+ export type StreamActiveContractsParams = ActiveContractsParams;
11
+ /**
12
+ * One read of the active contracts at an offset, returned by `streamActiveContracts`. It can be iterated once: a second
13
+ * `for await` over the same stream throws instead of reporting an empty snapshot, so a retry has to call
14
+ * `streamActiveContracts` again.
15
+ */
16
+ export declare class ActiveContractsStream implements AsyncIterable<JsGetActiveContractsResponseItem> {
17
+ private readonly client;
18
+ private readonly params;
19
+ private offset;
20
+ private iterated;
21
+ constructor(client: LedgerJsonApiClient, params: StreamActiveContractsParams);
22
+ /**
23
+ * The offset the snapshot is read at: the `activeAtOffset` passed in or, when it is omitted, the ledger end read as
24
+ * iteration starts. It is `undefined` until the first `next()` has built the request, and set before the first item
25
+ * is yielded. A reader that continues with `subscribeToUpdates` passes it as `beginExclusive`; reading the ledger end
26
+ * again instead would skip the updates in between.
27
+ */
28
+ get activeAtOffset(): number | undefined;
29
+ [Symbol.asyncIterator](): AsyncIterator<JsGetActiveContractsResponseItem, void, undefined>;
30
+ private read;
31
+ }
32
+ /**
33
+ * Streams the active contracts at an offset one item at a time, without collecting the snapshot.
34
+ *
35
+ * Takes the filters, offset and idle timeout of `getActiveContracts`. Canton 3.4's state service serves the snapshot
36
+ * only as a stream, so this reads the same WebSocket but hands each item to the consumer as it arrives and keeps no
37
+ * reference to it afterwards. The returned {@link ActiveContractsStream} connects when iteration starts and yields items
38
+ * in the order the participant sends them. When the consumer falls {@link ACTIVE_CONTRACTS_STREAM_HIGH_WATER_MARK} items
39
+ * behind, the socket stops reading until it catches up. A Canton error frame, an unexpected frame, the idle timeout or
40
+ * a close other than the participant's normal close (1000), such as a dropped connection, ends the iteration with an
41
+ * error once the items received before it have been yielded. Leaving a `for await` loop early, by `break`, `return` or
42
+ * a throw, closes the socket; an iterator driven by hand must be run to the end or closed with `return()`. A stream is
43
+ * read once; to retry, call `streamActiveContracts` again.
44
+ *
45
+ * To continue from the snapshot with `subscribeToUpdates`, pass its {@link ActiveContractsStream.activeAtOffset} as
46
+ * `beginExclusive`.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const snapshot = client.streamActiveContracts({ parties: [party], interfaceIds: [interfaceId] });
51
+ * for await (const item of snapshot) {
52
+ * if ('JsActiveContract' in item.contractEntry) {
53
+ * handle(item.contractEntry.JsActiveContract.createdEvent);
54
+ * }
55
+ * }
56
+ * const beginExclusive = snapshot.activeAtOffset; // the offset the snapshot was read at
57
+ * ```;
58
+ */
59
+ export declare class StreamActiveContracts {
60
+ private readonly client;
61
+ constructor(client: LedgerJsonApiClient);
62
+ execute(params: StreamActiveContractsParams): ActiveContractsStream;
63
+ }
64
+ //# sourceMappingURL=stream-active-contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-active-contracts.d.ts","sourceRoot":"","sources":["../../../../../../../src/clients/ledger-json-api/operations/v2/state/stream-active-contracts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAKL,KAAK,qBAAqB,EAE3B,MAAM,4BAA4B,CAAC;AAEpC;;;GAGG;AACH,eAAO,MAAM,uCAAuC,MAAM,CAAC;AAE3D,0GAA0G;AAC1G,MAAM,MAAM,2BAA2B,GAAG,qBAAqB,CAAC;AA0GhE;;;;GAIG;AACH,qBAAa,qBAAsB,YAAW,aAAa,CAAC,gCAAgC,CAAC;IAKzF,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IALzB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,QAAQ,CAAS;IAEzB,YACmB,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,2BAA2B,EAClD;IAEJ;;;;;OAKG;IACH,IAAW,cAAc,IAAI,MAAM,GAAG,SAAS,CAE9C;IAEM,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,gCAAgC,EAAE,IAAI,EAAE,SAAS,CAAC,CAQhG;YAEc,IAAI;CA0CpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAAnC,YAA6B,MAAM,EAAE,mBAAmB,EAAI;IAErD,OAAO,CAAC,MAAM,EAAE,2BAA2B,GAAG,qBAAqB,CAEzE;CACF"}
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StreamActiveContracts = exports.ActiveContractsStream = exports.ACTIVE_CONTRACTS_STREAM_HIGH_WATER_MARK = void 0;
4
+ const WebSocketClient_1 = require("../../../../../core/ws/WebSocketClient");
5
+ const active_contracts_request_1 = require("./active-contracts-request");
6
+ /**
7
+ * Most received items that wait for the consumer before the socket stops reading. Past it the participant's sends back
8
+ * up behind TCP flow control instead of the snapshot collecting in memory; reading resumes once half have been taken.
9
+ */
10
+ exports.ACTIVE_CONTRACTS_STREAM_HIGH_WATER_MARK = 256;
11
+ /** Items received from the socket and not yet taken by the iterator, followed by how the stream ended. */
12
+ class SnapshotQueue {
13
+ constructor() {
14
+ this.items = [];
15
+ this.paused = false;
16
+ this.ended = false;
17
+ }
18
+ get hasEnded() {
19
+ return this.ended;
20
+ }
21
+ attach(subscription) {
22
+ this.subscription = subscription;
23
+ if (this.paused) {
24
+ subscription.pause?.();
25
+ }
26
+ }
27
+ push(item) {
28
+ this.items.push(item);
29
+ if (!this.paused && this.items.length >= exports.ACTIVE_CONTRACTS_STREAM_HIGH_WATER_MARK) {
30
+ this.paused = true;
31
+ this.subscription?.pause?.();
32
+ }
33
+ this.signal();
34
+ }
35
+ /** Ends the stream; items already queued are still taken before the failure, if any, is thrown. */
36
+ end(failure) {
37
+ if (this.ended)
38
+ return;
39
+ this.ended = true;
40
+ this.failure = failure;
41
+ this.signal();
42
+ }
43
+ /** Waits for the next item. Resolves to `undefined` once the stream has ended and every item has been taken. */
44
+ async take() {
45
+ for (;;) {
46
+ const item = this.items.shift();
47
+ if (item !== undefined) {
48
+ if (this.paused && this.items.length <= exports.ACTIVE_CONTRACTS_STREAM_HIGH_WATER_MARK / 2) {
49
+ this.paused = false;
50
+ this.subscription?.resume?.();
51
+ }
52
+ return item;
53
+ }
54
+ if (this.ended) {
55
+ if (this.failure !== undefined)
56
+ throw this.failure;
57
+ return undefined;
58
+ }
59
+ await new Promise((resolve) => {
60
+ this.wake = resolve;
61
+ });
62
+ }
63
+ }
64
+ /** Ends the stream, drops the items no one will take, and closes the socket. */
65
+ close() {
66
+ this.end();
67
+ this.items.length = 0;
68
+ this.subscription?.close();
69
+ }
70
+ signal() {
71
+ const { wake } = this;
72
+ this.wake = undefined;
73
+ wake?.();
74
+ }
75
+ }
76
+ /**
77
+ * The iterator of an {@link ActiveContractsStream}. It reports `done` only after the participant's normal close has
78
+ * completed the snapshot. Once the read fails, every later `next()` rejects with the same error, and once `return()`
79
+ * has closed the stream early, every later `next()` rejects too, so that no caller takes part of the snapshot for all
80
+ * of it.
81
+ */
82
+ class SnapshotIterator {
83
+ constructor(items) {
84
+ this.items = items;
85
+ this.completed = false;
86
+ }
87
+ async next() {
88
+ if (this.failure !== undefined)
89
+ throw this.failure.error;
90
+ try {
91
+ const result = await this.items.next();
92
+ if (result.done === true)
93
+ this.completed = true;
94
+ return result;
95
+ }
96
+ catch (error) {
97
+ this.failure ?? (this.failure = { error });
98
+ throw error;
99
+ }
100
+ }
101
+ async return() {
102
+ if (!this.completed) {
103
+ this.failure ?? (this.failure = { error: new Error('Active-contracts stream was closed before the snapshot completed') });
104
+ }
105
+ return this.items.return(undefined);
106
+ }
107
+ }
108
+ /**
109
+ * One read of the active contracts at an offset, returned by `streamActiveContracts`. It can be iterated once: a second
110
+ * `for await` over the same stream throws instead of reporting an empty snapshot, so a retry has to call
111
+ * `streamActiveContracts` again.
112
+ */
113
+ class ActiveContractsStream {
114
+ constructor(client, params) {
115
+ this.client = client;
116
+ this.params = params;
117
+ this.iterated = false;
118
+ }
119
+ /**
120
+ * The offset the snapshot is read at: the `activeAtOffset` passed in or, when it is omitted, the ledger end read as
121
+ * iteration starts. It is `undefined` until the first `next()` has built the request, and set before the first item
122
+ * is yielded. A reader that continues with `subscribeToUpdates` passes it as `beginExclusive`; reading the ledger end
123
+ * again instead would skip the updates in between.
124
+ */
125
+ get activeAtOffset() {
126
+ return this.offset;
127
+ }
128
+ [Symbol.asyncIterator]() {
129
+ if (this.iterated) {
130
+ throw new Error('An active-contracts stream can be iterated only once; call streamActiveContracts again to read another snapshot');
131
+ }
132
+ this.iterated = true;
133
+ return new SnapshotIterator(this.read());
134
+ }
135
+ async *read() {
136
+ const { requestMessage, idleTimeoutMs } = await (0, active_contracts_request_1.buildActiveContractsRequest)(this.client, this.params);
137
+ this.offset = requestMessage.activeAtOffset;
138
+ const queue = new SnapshotQueue();
139
+ const subscription = await new WebSocketClient_1.WebSocketClient(this.client).connect(active_contracts_request_1.ACTIVE_CONTRACTS_PATH, requestMessage, {
140
+ // Synchronous on purpose: WebSocketClient dispatches the next frame without waiting for this handler, so only a
141
+ // handler that returns before then keeps the items in order.
142
+ onMessage: (parsed) => {
143
+ if (queue.hasEnded)
144
+ return;
145
+ const frame = (0, active_contracts_request_1.decodeActiveContractsFrame)(parsed);
146
+ if ('error' in frame) {
147
+ queue.end(frame.error);
148
+ // Rethrown so that WebSocketClient closes the socket.
149
+ throw frame.error;
150
+ }
151
+ queue.push(frame.item);
152
+ },
153
+ onError: (err) => {
154
+ queue.end(err);
155
+ },
156
+ onClose: (code, reason) => {
157
+ queue.end((0, active_contracts_request_1.activeContractsCloseError)(code, reason));
158
+ },
159
+ }, { idleTimeoutMs });
160
+ queue.attach(subscription);
161
+ try {
162
+ for (;;) {
163
+ const item = await queue.take();
164
+ if (item === undefined)
165
+ return;
166
+ yield item;
167
+ }
168
+ }
169
+ finally {
170
+ queue.close();
171
+ }
172
+ }
173
+ }
174
+ exports.ActiveContractsStream = ActiveContractsStream;
175
+ /**
176
+ * Streams the active contracts at an offset one item at a time, without collecting the snapshot.
177
+ *
178
+ * Takes the filters, offset and idle timeout of `getActiveContracts`. Canton 3.4's state service serves the snapshot
179
+ * only as a stream, so this reads the same WebSocket but hands each item to the consumer as it arrives and keeps no
180
+ * reference to it afterwards. The returned {@link ActiveContractsStream} connects when iteration starts and yields items
181
+ * in the order the participant sends them. When the consumer falls {@link ACTIVE_CONTRACTS_STREAM_HIGH_WATER_MARK} items
182
+ * behind, the socket stops reading until it catches up. A Canton error frame, an unexpected frame, the idle timeout or
183
+ * a close other than the participant's normal close (1000), such as a dropped connection, ends the iteration with an
184
+ * error once the items received before it have been yielded. Leaving a `for await` loop early, by `break`, `return` or
185
+ * a throw, closes the socket; an iterator driven by hand must be run to the end or closed with `return()`. A stream is
186
+ * read once; to retry, call `streamActiveContracts` again.
187
+ *
188
+ * To continue from the snapshot with `subscribeToUpdates`, pass its {@link ActiveContractsStream.activeAtOffset} as
189
+ * `beginExclusive`.
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * const snapshot = client.streamActiveContracts({ parties: [party], interfaceIds: [interfaceId] });
194
+ * for await (const item of snapshot) {
195
+ * if ('JsActiveContract' in item.contractEntry) {
196
+ * handle(item.contractEntry.JsActiveContract.createdEvent);
197
+ * }
198
+ * }
199
+ * const beginExclusive = snapshot.activeAtOffset; // the offset the snapshot was read at
200
+ * ```;
201
+ */
202
+ class StreamActiveContracts {
203
+ constructor(client) {
204
+ this.client = client;
205
+ }
206
+ execute(params) {
207
+ return new ActiveContractsStream(this.client, params);
208
+ }
209
+ }
210
+ exports.StreamActiveContracts = StreamActiveContracts;
211
+ //# sourceMappingURL=stream-active-contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-active-contracts.js","sourceRoot":"","sources":["../../../../../../../src/clients/ledger-json-api/operations/v2/state/stream-active-contracts.ts"],"names":[],"mappings":";;;AAAA,4EAAqG;AAGrG,yEAOoC;AAEpC;;;GAGG;AACU,QAAA,uCAAuC,GAAG,GAAG,CAAC;AAK3D,0GAA0G;AAC1G,MAAM,aAAa;IAAnB;QACmB,UAAK,GAAuC,EAAE,CAAC;QAExD,WAAM,GAAG,KAAK,CAAC;QAGf,UAAK,GAAG,KAAK,CAAC;IA+DxB,CAAC;IA7DC,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAEM,MAAM,CAAC,YAAmC;QAC/C,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC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IAAI,KAAK,EAAE,CAAC;oBACrB,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;oBACvB,sDAAsD;oBACtD,MAAM,KAAK,CAAC,KAAK,CAAC;gBACpB,CAAC;gBACD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC;YACD,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;gBACf,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACjB,CAAC;YACD,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;gBACxB,KAAK,CAAC,GAAG,CAAC,IAAA,oDAAyB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;YACrD,CAAC;SACF,EACD,EAAE,aAAa,EAAE,CAClB,CAAC;QACF,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAE3B,IAAI,CAAC;YACH,SAAS,CAAC;gBACR,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;gBAChC,IAAI,IAAI,KAAK,SAAS;oBAAE,OAAO;gBAC/B,MAAM,IAAI,CAAC;YACb,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;CACF;;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH;IACE,YAA6B,MAA2B;sBAA3B,MAAM;IAAwB,CAAC;IAErD,OAAO,CAAC,MAAmC;QAChD,OAAO,IAAI,qBAAqB,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;CACF"}
@@ -1,14 +1,52 @@
1
+ import { z } from 'zod';
1
2
  import type { paths } from '../../../../../generated/canton/community/ledger/ledger-json-api/src/test/resources/json-api-docs/openapi';
2
3
  declare const endpoint: '/v2/updates/update-by-id';
3
- export interface GetUpdateByIdParams {
4
- /** The ID of the update to fetch. */
4
+ declare const GetUpdateByIdParamsSchema: z.ZodObject<{
5
+ updateId: z.ZodString;
6
+ readAs: z.ZodArray<z.ZodString>;
7
+ templateIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
8
+ interfaceIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
9
+ includeInterfaceView: z.ZodOptional<z.ZodBoolean>;
10
+ includeCreatedEventBlob: z.ZodOptional<z.ZodBoolean>;
11
+ transactionShape: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"TRANSACTION_SHAPE_ACS_DELTA">, z.ZodLiteral<"TRANSACTION_SHAPE_LEDGER_EFFECTS">]>>;
12
+ }, z.core.$strip>;
13
+ export type GetUpdateByIdParams = z.infer<typeof GetUpdateByIdParamsSchema>;
14
+ export type GetUpdateByIdResponse = paths[typeof endpoint]['post']['responses']['200']['content']['application/json'];
15
+ /**
16
+ * Fetches one update by its ID.
17
+ *
18
+ * Without `templateIds` or `interfaceIds` the request reads every event the `readAs` parties can see (a wildcard filter
19
+ * per party) with created event blobs included. With at least one template or interface filter, only matching events
20
+ * are returned, and created event blobs are included only when `includeCreatedEventBlob` is `true`. Interface views are
21
+ * included by default.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const update = await client.getUpdateById({
26
+ * updateId: '1220...',
27
+ * readAs: ['party1'],
28
+ * interfaceIds: ['#example-package:Example.Module:Asset'],
29
+ * });
30
+ * ```;
31
+ */
32
+ export declare const GetUpdateById: new (client: import("../../../../..").BaseClient) => import("../../../../..").ApiOperation<{
5
33
  updateId: string;
6
- /** Parties to read as (optional). */
7
34
  readAs: string[];
8
- }
9
- export type GetUpdateByIdResponse = paths[typeof endpoint]['post']['responses']['200']['content']['application/json'];
10
- export declare const GetUpdateById: new (client: import("../../../../..").BaseClient) => import("../../../../..").ApiOperation<GetUpdateByIdParams, {
35
+ templateIds?: string[] | undefined;
36
+ interfaceIds?: string[] | undefined;
37
+ includeInterfaceView?: boolean | undefined;
38
+ includeCreatedEventBlob?: boolean | undefined;
39
+ transactionShape?: "TRANSACTION_SHAPE_ACS_DELTA" | "TRANSACTION_SHAPE_LEDGER_EFFECTS" | undefined;
40
+ }, {
11
41
  update?: import("../../../../../generated/canton/community/ledger/ledger-json-api/src/test/resources/json-api-docs/openapi").components["schemas"]["Update"];
12
- }, import("../../../../..").OperationExecuteOptions<GetUpdateByIdParams>>;
42
+ }, import("../../../../..").OperationExecuteOptions<{
43
+ updateId: string;
44
+ readAs: string[];
45
+ templateIds?: string[] | undefined;
46
+ interfaceIds?: string[] | undefined;
47
+ includeInterfaceView?: boolean | undefined;
48
+ includeCreatedEventBlob?: boolean | undefined;
49
+ transactionShape?: "TRANSACTION_SHAPE_ACS_DELTA" | "TRANSACTION_SHAPE_LEDGER_EFFECTS" | undefined;
50
+ }>>;
13
51
  export {};
14
52
  //# sourceMappingURL=get-update-by-id.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-update-by-id.d.ts","sourceRoot":"","sources":["../../../../../../../src/clients/ledger-json-api/operations/v2/updates/get-update-by-id.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2GAA2G,CAAC;AAEvI,QAAA,MAAM,QAAQ,EAAG,0BAAmC,CAAC;AAGrD,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC;AAEtH,eAAO,MAAM,aAAa;;yEA6CxB,CAAC"}
1
+ {"version":3,"file":"get-update-by-id.d.ts","sourceRoot":"","sources":["../../../../../../../src/clients/ledger-json-api/operations/v2/updates/get-update-by-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2GAA2G,CAAC;AAIvI,QAAA,MAAM,QAAQ,EAAG,0BAAmC,CAAC;AAErD,QAAA,MAAM,yBAAyB;;;;;;;;iBAkB7B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC;AAEtH;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;GAkExB,CAAC"}