@fairmint/canton-node-sdk 0.0.266 → 0.0.268
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.
- package/README.md +12 -3
- package/build/src/clients/ledger-json-api/LedgerJsonApiClient.generated.d.ts +5 -2
- package/build/src/clients/ledger-json-api/LedgerJsonApiClient.generated.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/LedgerJsonApiClient.generated.js +2 -0
- package/build/src/clients/ledger-json-api/LedgerJsonApiClient.generated.js.map +1 -1
- package/build/src/clients/ledger-json-api/index.d.ts +5 -1
- package/build/src/clients/ledger-json-api/index.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/index.js +7 -1
- package/build/src/clients/ledger-json-api/index.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/commands/submit-and-wait-for-reassignment.d.ts +2 -2
- package/build/src/clients/ledger-json-api/operations/v2/state/active-contracts-request.d.ts +49 -0
- package/build/src/clients/ledger-json-api/operations/v2/state/active-contracts-request.d.ts.map +1 -0
- package/build/src/clients/ledger-json-api/operations/v2/state/active-contracts-request.js +127 -0
- package/build/src/clients/ledger-json-api/operations/v2/state/active-contracts-request.js.map +1 -0
- package/build/src/clients/ledger-json-api/operations/v2/state/get-active-contracts.d.ts +10 -13
- package/build/src/clients/ledger-json-api/operations/v2/state/get-active-contracts.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/state/get-active-contracts.js +18 -106
- package/build/src/clients/ledger-json-api/operations/v2/state/get-active-contracts.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/state/index.d.ts +1 -0
- package/build/src/clients/ledger-json-api/operations/v2/state/index.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/state/index.js +1 -0
- package/build/src/clients/ledger-json-api/operations/v2/state/index.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/state/stream-active-contracts.d.ts +64 -0
- package/build/src/clients/ledger-json-api/operations/v2/state/stream-active-contracts.d.ts.map +1 -0
- package/build/src/clients/ledger-json-api/operations/v2/state/stream-active-contracts.js +230 -0
- package/build/src/clients/ledger-json-api/operations/v2/state/stream-active-contracts.js.map +1 -0
- package/build/src/clients/ledger-json-api/operations/v2/updates/get-update-by-id.d.ts +45 -7
- package/build/src/clients/ledger-json-api/operations/v2/updates/get-update-by-id.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/updates/get-update-by-id.js +64 -7
- package/build/src/clients/ledger-json-api/operations/v2/updates/get-update-by-id.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/updates/get-update-by-offset.d.ts +17 -0
- package/build/src/clients/ledger-json-api/operations/v2/updates/get-update-by-offset.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/updates/get-update-by-offset.js +17 -0
- package/build/src/clients/ledger-json-api/operations/v2/updates/get-update-by-offset.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/updates/subscribe-to-updates.d.ts +46 -8
- package/build/src/clients/ledger-json-api/operations/v2/updates/subscribe-to-updates.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/updates/subscribe-to-updates.js +12 -25
- package/build/src/clients/ledger-json-api/operations/v2/updates/subscribe-to-updates.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/utils/event-format-builder.d.ts +29 -0
- package/build/src/clients/ledger-json-api/operations/v2/utils/event-format-builder.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/utils/event-format-builder.js +43 -0
- package/build/src/clients/ledger-json-api/operations/v2/utils/event-format-builder.js.map +1 -1
- package/build/src/clients/ledger-json-api/schemas/api/event-details.d.ts +22 -4
- package/build/src/clients/ledger-json-api/schemas/api/event-details.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/schemas/api/events.d.ts +44 -8
- package/build/src/clients/ledger-json-api/schemas/api/events.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/schemas/api/interface-view.d.ts +28 -5
- package/build/src/clients/ledger-json-api/schemas/api/interface-view.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/schemas/api/interface-view.js +16 -4
- package/build/src/clients/ledger-json-api/schemas/api/interface-view.js.map +1 -1
- package/build/src/clients/ledger-json-api/schemas/api/reassignment.d.ts +88 -16
- package/build/src/clients/ledger-json-api/schemas/api/reassignment.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/schemas/api/state.d.ts +176 -32
- package/build/src/clients/ledger-json-api/schemas/api/state.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/schemas/api/updates.d.ts +242 -44
- package/build/src/clients/ledger-json-api/schemas/api/updates.d.ts.map +1 -1
- package/build/src/core/ws/WebSocketClient.d.ts +8 -0
- package/build/src/core/ws/WebSocketClient.d.ts.map +1 -1
- package/build/src/core/ws/WebSocketClient.js +28 -1
- package/build/src/core/ws/WebSocketClient.js.map +1 -1
- 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
|
|
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
|
|
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(
|
|
17
|
+
.connect(active_contracts_request_1.ACTIVE_CONTRACTS_PATH, requestMessage, {
|
|
105
18
|
onMessage: async (parsed) => {
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
|
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,
|
|
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,IAAI,iCAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAElD,OAAO,IAAI,OAAO,CAA+B,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnE,MAAM,OAAO,GAAiC,EAAE,CAAC;YACjD,IAAI,OAAO,GAAG,KAAK,CAAC;YAEpB,KAAK,QAAQ;iBACV,OAAO,CACN,gDAAqB,EACrB,cA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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"}
|
|
@@ -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 open;
|
|
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
|
package/build/src/clients/ledger-json-api/operations/v2/state/stream-active-contracts.d.ts.map
ADDED
|
@@ -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;AAwIhE;;;;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;YAEa,IAAI;CAiCnB;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,230 @@
|
|
|
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
|
+
this.closed = false;
|
|
18
|
+
}
|
|
19
|
+
get hasEnded() {
|
|
20
|
+
return this.ended;
|
|
21
|
+
}
|
|
22
|
+
attach(subscription) {
|
|
23
|
+
this.subscription = subscription;
|
|
24
|
+
if (this.paused) {
|
|
25
|
+
subscription.pause?.();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
push(item) {
|
|
29
|
+
this.items.push(item);
|
|
30
|
+
if (!this.paused && this.items.length >= exports.ACTIVE_CONTRACTS_STREAM_HIGH_WATER_MARK) {
|
|
31
|
+
this.paused = true;
|
|
32
|
+
this.subscription?.pause?.();
|
|
33
|
+
}
|
|
34
|
+
this.signal();
|
|
35
|
+
}
|
|
36
|
+
/** Ends the stream; items already queued are still taken before the failure, if any, is thrown. */
|
|
37
|
+
end(failure) {
|
|
38
|
+
if (this.ended)
|
|
39
|
+
return;
|
|
40
|
+
this.ended = true;
|
|
41
|
+
this.failure = failure;
|
|
42
|
+
this.signal();
|
|
43
|
+
}
|
|
44
|
+
/** Waits for the next item. Resolves to `undefined` once the stream has ended and every item has been taken. */
|
|
45
|
+
async take() {
|
|
46
|
+
for (;;) {
|
|
47
|
+
const item = this.items.shift();
|
|
48
|
+
if (item !== undefined) {
|
|
49
|
+
if (this.paused && this.items.length <= exports.ACTIVE_CONTRACTS_STREAM_HIGH_WATER_MARK / 2) {
|
|
50
|
+
this.paused = false;
|
|
51
|
+
this.subscription?.resume?.();
|
|
52
|
+
}
|
|
53
|
+
return item;
|
|
54
|
+
}
|
|
55
|
+
if (this.ended) {
|
|
56
|
+
if (this.failure !== undefined)
|
|
57
|
+
throw this.failure;
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
await new Promise((resolve) => {
|
|
61
|
+
this.wake = resolve;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Ends the stream, drops the items no one will take, and closes the socket; closing again does nothing. */
|
|
66
|
+
close() {
|
|
67
|
+
this.end();
|
|
68
|
+
this.items.length = 0;
|
|
69
|
+
if (this.closed)
|
|
70
|
+
return;
|
|
71
|
+
this.closed = true;
|
|
72
|
+
this.subscription?.close();
|
|
73
|
+
}
|
|
74
|
+
signal() {
|
|
75
|
+
const { wake } = this;
|
|
76
|
+
this.wake = undefined;
|
|
77
|
+
wake?.();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The iterator of an {@link ActiveContractsStream}. It reports `done` only after the participant's normal close has
|
|
82
|
+
* completed the snapshot. Once the read fails, every later `next()` rejects with the same error, and once `return()`
|
|
83
|
+
* has closed the stream early, every later `next()` rejects too, so that no caller takes part of the snapshot for all
|
|
84
|
+
* of it. Calls to `next()` are served one at a time in the order they were made, each checking the stored failure again
|
|
85
|
+
* after it has waited, so a call that was already pending when the stream failed or was closed rejects too. `return()`
|
|
86
|
+
* closes the socket at once, whether or not a `next()` is waiting for a frame or the connection is still being set up.
|
|
87
|
+
*/
|
|
88
|
+
class SnapshotIterator {
|
|
89
|
+
constructor(open) {
|
|
90
|
+
this.open = open;
|
|
91
|
+
this.completed = false;
|
|
92
|
+
this.cancelled = false;
|
|
93
|
+
this.tail = Promise.resolve();
|
|
94
|
+
}
|
|
95
|
+
async next() {
|
|
96
|
+
const result = this.tail.then(async () => this.advance());
|
|
97
|
+
this.tail = result.catch(() => undefined);
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
async return() {
|
|
101
|
+
if (!this.completed) {
|
|
102
|
+
this.cancelled = true;
|
|
103
|
+
this.failure ?? (this.failure = { error: new Error('Active-contracts stream was closed before the snapshot completed') });
|
|
104
|
+
this.queue?.close();
|
|
105
|
+
}
|
|
106
|
+
return Promise.resolve({ done: true, value: undefined });
|
|
107
|
+
}
|
|
108
|
+
async advance() {
|
|
109
|
+
this.rethrow();
|
|
110
|
+
if (this.completed)
|
|
111
|
+
return { done: true, value: undefined };
|
|
112
|
+
try {
|
|
113
|
+
this.queue ?? (this.queue = await this.open());
|
|
114
|
+
// A return() that came while the connection was being set up could not close a socket that did not exist yet.
|
|
115
|
+
if (this.cancelled)
|
|
116
|
+
this.queue.close();
|
|
117
|
+
const item = await this.queue.take();
|
|
118
|
+
this.rethrow();
|
|
119
|
+
if (item === undefined) {
|
|
120
|
+
this.completed = true;
|
|
121
|
+
this.queue.close();
|
|
122
|
+
return { done: true, value: undefined };
|
|
123
|
+
}
|
|
124
|
+
return { done: false, value: item };
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
this.failure ?? (this.failure = { error });
|
|
128
|
+
this.queue?.close();
|
|
129
|
+
throw this.failure.error;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
rethrow() {
|
|
133
|
+
if (this.failure !== undefined)
|
|
134
|
+
throw this.failure.error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* One read of the active contracts at an offset, returned by `streamActiveContracts`. It can be iterated once: a second
|
|
139
|
+
* `for await` over the same stream throws instead of reporting an empty snapshot, so a retry has to call
|
|
140
|
+
* `streamActiveContracts` again.
|
|
141
|
+
*/
|
|
142
|
+
class ActiveContractsStream {
|
|
143
|
+
constructor(client, params) {
|
|
144
|
+
this.client = client;
|
|
145
|
+
this.params = params;
|
|
146
|
+
this.iterated = false;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The offset the snapshot is read at: the `activeAtOffset` passed in or, when it is omitted, the ledger end read as
|
|
150
|
+
* iteration starts. It is `undefined` until the first `next()` has built the request, and set before the first item
|
|
151
|
+
* is yielded. A reader that continues with `subscribeToUpdates` passes it as `beginExclusive`; reading the ledger end
|
|
152
|
+
* again instead would skip the updates in between.
|
|
153
|
+
*/
|
|
154
|
+
get activeAtOffset() {
|
|
155
|
+
return this.offset;
|
|
156
|
+
}
|
|
157
|
+
[Symbol.asyncIterator]() {
|
|
158
|
+
if (this.iterated) {
|
|
159
|
+
throw new Error('An active-contracts stream can be iterated only once; call streamActiveContracts again to read another snapshot');
|
|
160
|
+
}
|
|
161
|
+
this.iterated = true;
|
|
162
|
+
return new SnapshotIterator(async () => this.open());
|
|
163
|
+
}
|
|
164
|
+
async open() {
|
|
165
|
+
const { requestMessage, idleTimeoutMs } = await (0, active_contracts_request_1.buildActiveContractsRequest)(this.client, this.params);
|
|
166
|
+
this.offset = requestMessage.activeAtOffset;
|
|
167
|
+
const queue = new SnapshotQueue();
|
|
168
|
+
const subscription = await new WebSocketClient_1.WebSocketClient(this.client).connect(active_contracts_request_1.ACTIVE_CONTRACTS_PATH, requestMessage, {
|
|
169
|
+
// Synchronous on purpose: WebSocketClient dispatches the next frame without waiting for this handler, so only a
|
|
170
|
+
// handler that returns before then keeps the items in order.
|
|
171
|
+
onMessage: (parsed) => {
|
|
172
|
+
if (queue.hasEnded)
|
|
173
|
+
return;
|
|
174
|
+
const frame = (0, active_contracts_request_1.decodeActiveContractsFrame)(parsed);
|
|
175
|
+
if ('error' in frame) {
|
|
176
|
+
queue.end(frame.error);
|
|
177
|
+
// Rethrown so that WebSocketClient closes the socket.
|
|
178
|
+
throw frame.error;
|
|
179
|
+
}
|
|
180
|
+
queue.push(frame.item);
|
|
181
|
+
},
|
|
182
|
+
onError: (err) => {
|
|
183
|
+
queue.end(err);
|
|
184
|
+
},
|
|
185
|
+
onClose: (code, reason) => {
|
|
186
|
+
queue.end((0, active_contracts_request_1.activeContractsCloseError)(code, reason));
|
|
187
|
+
},
|
|
188
|
+
}, { idleTimeoutMs });
|
|
189
|
+
queue.attach(subscription);
|
|
190
|
+
return queue;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
exports.ActiveContractsStream = ActiveContractsStream;
|
|
194
|
+
/**
|
|
195
|
+
* Streams the active contracts at an offset one item at a time, without collecting the snapshot.
|
|
196
|
+
*
|
|
197
|
+
* Takes the filters, offset and idle timeout of `getActiveContracts`. Canton 3.4's state service serves the snapshot
|
|
198
|
+
* only as a stream, so this reads the same WebSocket but hands each item to the consumer as it arrives and keeps no
|
|
199
|
+
* reference to it afterwards. The returned {@link ActiveContractsStream} connects when iteration starts and yields items
|
|
200
|
+
* in the order the participant sends them. When the consumer falls {@link ACTIVE_CONTRACTS_STREAM_HIGH_WATER_MARK} items
|
|
201
|
+
* behind, the socket stops reading until it catches up. A Canton error frame, an unexpected frame, the idle timeout or
|
|
202
|
+
* a close other than the participant's normal close (1000), such as a dropped connection, ends the iteration with an
|
|
203
|
+
* error once the items received before it have been yielded. Leaving a `for await` loop early, by `break`, `return` or
|
|
204
|
+
* a throw, closes the socket; an iterator driven by hand must be run to the end or closed with `return()`. A stream is
|
|
205
|
+
* read once; to retry, call `streamActiveContracts` again.
|
|
206
|
+
*
|
|
207
|
+
* To continue from the snapshot with `subscribeToUpdates`, pass its {@link ActiveContractsStream.activeAtOffset} as
|
|
208
|
+
* `beginExclusive`.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript
|
|
212
|
+
* const snapshot = client.streamActiveContracts({ parties: [party], interfaceIds: [interfaceId] });
|
|
213
|
+
* for await (const item of snapshot) {
|
|
214
|
+
* if ('JsActiveContract' in item.contractEntry) {
|
|
215
|
+
* handle(item.contractEntry.JsActiveContract.createdEvent);
|
|
216
|
+
* }
|
|
217
|
+
* }
|
|
218
|
+
* const beginExclusive = snapshot.activeAtOffset; // the offset the snapshot was read at
|
|
219
|
+
* ```;
|
|
220
|
+
*/
|
|
221
|
+
class StreamActiveContracts {
|
|
222
|
+
constructor(client) {
|
|
223
|
+
this.client = client;
|
|
224
|
+
}
|
|
225
|
+
execute(params) {
|
|
226
|
+
return new ActiveContractsStream(this.client, params);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
exports.StreamActiveContracts = StreamActiveContracts;
|
|
230
|
+
//# 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;QACd,WAAM,GAAG,KAAK,CAAC;IAiEzB,CAAC;IA/DC,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAEM,MAAM,CAAC,YAAmC;QAC/C,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,IAA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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;QAC3B,OAAO,KAAK,CAAC;IACf,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
|
-
|
|
4
|
-
|
|
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
|
-
|
|
10
|
-
|
|
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<
|
|
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":"
|
|
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"}
|