@fairmint/canton-node-sdk
Version:
Canton Node SDK
169 lines • 7.97 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetTransactionTreeResponseSchema = exports.GetUpdateResponseSchema = exports.GetTransactionResponseActualSchema = exports.GetTransactionResponseSchema = exports.GetUpdateTreesResponseSchema = exports.GetUpdatesResponseSchema = exports.SubmitAndWaitResponseSchema = exports.JsSubmitAndWaitForTransactionResponseSchema = exports.JsSubmitAndWaitForTransactionRequestSchema = exports.UpdateStreamResponseSchema = exports.UpdateStreamRequestSchema = exports.WsUpdateTreesSchema = exports.WsUpdateSchema = exports.JsUpdateSchema = exports.JsTransactionTreeSchema = exports.JsTransactionSchema = exports.JsUpdateEventSchema = exports.JsUpdateEventKindSchema = void 0;
const zod_1 = require("zod");
const common_1 = require("../common");
const commands_1 = require("./commands");
const completions_1 = require("./completions");
const event_details_1 = require("./event-details");
const events_1 = require("./events");
/** Update event kind (oneOf all update event types). */
exports.JsUpdateEventKindSchema = zod_1.z.union([
zod_1.z.object({ JsCreated: event_details_1.CreatedEventDetailsSchema }),
zod_1.z.object({ JsArchived: event_details_1.ArchivedEventDetailsSchema }),
zod_1.z.object({ JsAssigned: event_details_1.AssignedEventDetailsSchema }),
zod_1.z.object({ JsUnassigned: event_details_1.UnassignedEventDetailsSchema }),
]);
/** Update event details. */
exports.JsUpdateEventSchema = zod_1.z.object({
/** The kind of update event. */
kind: exports.JsUpdateEventKindSchema,
/** Synchronizer ID. */
synchronizerId: zod_1.z.string(),
/** Reassignment counter. */
reassignmentCounter: zod_1.z.number(),
});
/** Transaction details. */
exports.JsTransactionSchema = zod_1.z.object({
/** Unique update ID for the transaction. */
updateId: zod_1.z.string(),
/** Command ID associated with the transaction (optional). */
commandId: zod_1.z.string().optional(),
/** Workflow ID associated with the transaction (optional). */
workflowId: zod_1.z.string().optional(),
/** Effective time of the transaction (ISO 8601). */
effectiveAt: zod_1.z.string(),
/** Offset of the transaction in the ledger stream. */
offset: zod_1.z.number(),
/** Collection of update events. */
events: zod_1.z.array(exports.JsUpdateEventSchema),
/** Trace context (optional). */
traceContext: common_1.TraceContextSchema.optional(),
/** Record time of the transaction. */
recordTime: zod_1.z.string(),
});
/** Transaction tree details. */
exports.JsTransactionTreeSchema = zod_1.z.object({
/** Unique update ID for the transaction. */
updateId: zod_1.z.string(),
/** Command ID associated with the transaction (optional). */
commandId: zod_1.z.string().optional(),
/** Workflow ID associated with the transaction (optional). */
workflowId: zod_1.z.string().optional(),
/** Effective time of the transaction (ISO 8601). */
effectiveAt: zod_1.z.string(),
/** Offset of the transaction in the ledger stream. */
offset: zod_1.z.number(),
/** Map of event node IDs to tree events. */
eventsById: zod_1.z.record(zod_1.z.string(), events_1.TreeEventSchema),
/** Record time of the transaction. */
recordTime: zod_1.z.string(),
});
/** Update (oneOf transaction or transaction tree). */
exports.JsUpdateSchema = zod_1.z.union([
zod_1.z.object({ JsTransaction: exports.JsTransactionSchema }),
zod_1.z.object({ JsTransactionTree: exports.JsTransactionTreeSchema }),
zod_1.z.object({ OffsetCheckpoint: completions_1.OffsetCheckpointSchema }),
]);
/** WebSocket update wrappers (per AsyncAPI) - relaxed typing to accept server payloads. */
exports.WsUpdateSchema = zod_1.z.union([
zod_1.z.object({ OffsetCheckpoint: zod_1.z.any() }),
zod_1.z.object({ Reassignment: zod_1.z.any() }),
zod_1.z.object({ TopologyTransaction: zod_1.z.any() }),
zod_1.z.object({ Transaction: zod_1.z.any() }),
]);
exports.WsUpdateTreesSchema = zod_1.z.union([
zod_1.z.object({ OffsetCheckpoint: zod_1.z.any() }),
zod_1.z.object({ Reassignment: zod_1.z.any() }),
zod_1.z.object({ TransactionTree: zod_1.z.any() }),
]);
/** Update stream request. */
exports.UpdateStreamRequestSchema = zod_1.z.object({
/** User ID for the stream (optional if using authentication). */
userId: zod_1.z.string().optional(),
/** Parties whose data should be included. */
parties: zod_1.z.array(zod_1.z.string()),
/** Beginning offset (exclusive) for resuming the stream. */
beginExclusive: zod_1.z.number().optional(),
/** Event format (optional). */
eventFormat: events_1.EventFormatSchema.optional(),
});
/** Update stream response. */
exports.UpdateStreamResponseSchema = zod_1.z.object({
/** The update. */
update: exports.JsUpdateSchema,
});
/** Submit and wait for transaction request. */
exports.JsSubmitAndWaitForTransactionRequestSchema = zod_1.z.object({
/** The commands to submit. */
commands: commands_1.JsCommandsSchema,
/** Event format (optional). */
eventFormat: events_1.EventFormatSchema.optional(),
});
/** Submit and wait for transaction response. */
exports.JsSubmitAndWaitForTransactionResponseSchema = zod_1.z.object({
/** The transaction that resulted from the submitted command. */
transaction: exports.JsTransactionSchema,
});
/** Submit and wait response. */
exports.SubmitAndWaitResponseSchema = zod_1.z.object({
/** The update that resulted from the submitted command. */
update: exports.JsUpdateSchema,
});
/** Get updates response (array of updates). */
exports.GetUpdatesResponseSchema = zod_1.z.array(zod_1.z.object({
/** The update. */
update: exports.JsUpdateSchema,
}));
/** Get update trees response (array of transaction trees). */
exports.GetUpdateTreesResponseSchema = zod_1.z.array(zod_1.z.object({
/** The update. */
update: zod_1.z.object({ JsTransactionTree: exports.JsTransactionTreeSchema }),
}));
/** Get transaction response. */
exports.GetTransactionResponseSchema = zod_1.z.object({
/** The transaction. */
transaction: exports.JsTransactionSchema,
});
/**
* Get transaction response (actual API response format). The API returns events as an array of tree events, not update
* events.
*/
exports.GetTransactionResponseActualSchema = zod_1.z.object({
/** The transaction. */
transaction: zod_1.z.object({
/** Unique update ID for the transaction. */
updateId: zod_1.z.string(),
/** Command ID associated with the transaction (optional). */
commandId: zod_1.z.string().optional(),
/** Workflow ID associated with the transaction (optional). */
workflowId: zod_1.z.string().optional(),
/** Effective time of the transaction (ISO 8601). */
effectiveAt: zod_1.z.string(),
/** Offset of the transaction in the ledger stream. */
offset: zod_1.z.number(),
/** Collection of tree events (not update events). */
events: zod_1.z.array(zod_1.z.union([
zod_1.z.object({ ArchivedEvent: zod_1.z.any() }),
zod_1.z.object({ CreatedEvent: zod_1.z.any() }),
zod_1.z.object({ ExercisedEvent: zod_1.z.any() }),
])),
/** Record time of the transaction. */
recordTime: zod_1.z.string(),
/** Synchronizer ID for the transaction. */
synchronizerId: zod_1.z.string(),
/** Trace context for distributed tracing (optional). */
traceContext: common_1.TraceContextSchema.optional(),
}),
});
/** Get update response. */
exports.GetUpdateResponseSchema = zod_1.z.object({
/** The update. */
update: exports.JsUpdateSchema,
});
/** Get transaction tree response. */
exports.GetTransactionTreeResponseSchema = zod_1.z.object({
/** The transaction tree. */
transaction: exports.JsTransactionTreeSchema,
});
//# sourceMappingURL=updates.js.map