@fairmint/canton-node-sdk
Version:
Canton Node SDK
100 lines • 4.88 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CompletionStreamResponseSchema = exports.CompletionStreamRequestSchema = exports.CompletionResponseSchema = exports.OffsetCheckpointSchema = exports.CompletionSchema = exports.SynchronizerTimeSchema = exports.JsStatusSchema = void 0;
const zod_1 = require("zod");
const common_1 = require("../common");
const commands_1 = require("./commands");
const event_details_1 = require("./event-details");
/** Status information for completions. */
exports.JsStatusSchema = zod_1.z.object({
/** Status code. */
code: zod_1.z.number(),
/** Status message. */
message: zod_1.z.string(),
/** Additional details (optional). */
details: zod_1.z.array(event_details_1.StatusDetailsSchema).optional(),
});
/** Synchronizer time information. */
exports.SynchronizerTimeSchema = zod_1.z.object({
/** Synchronizer ID. */
synchronizerId: zod_1.z.string(),
/** Record time. */
recordTime: zod_1.z.string(),
});
/** Completion details. */
exports.CompletionSchema = zod_1.z.object({
/** The completion details. */
value: zod_1.z.object({
/** Command ID of the succeeded or failed command. */
commandId: zod_1.z.string(),
/** Status information (optional). */
status: exports.JsStatusSchema.optional(),
/** Update ID of the transaction (optional). */
updateId: zod_1.z.string().optional(),
/** User ID that was used for the submission (optional). */
userId: zod_1.z.string().optional(),
/** Parties on whose behalf the commands were executed (optional). */
actAs: zod_1.z.array(zod_1.z.string()).optional(),
/** Submission ID (optional). */
submissionId: zod_1.z.string().optional(),
/** Deduplication period (optional; WS may use multiple shapes). */
deduplicationPeriod: zod_1.z
.union([
// Standard REST/JS shapes
commands_1.DeduplicationPeriodSchema,
// WS variants with nested value wrappers or primitives
zod_1.z.object({ DeduplicationOffset: zod_1.z.object({ value: zod_1.z.object({ offset: zod_1.z.number() }) }) }),
zod_1.z.object({ DeduplicationOffset: zod_1.z.object({ value: zod_1.z.number() }) }),
zod_1.z.object({ DeduplicationOffset: zod_1.z.object({ offset: zod_1.z.number() }) }),
zod_1.z.object({ DeduplicationOffset: zod_1.z.number() }),
zod_1.z.object({ DeduplicationOffset: zod_1.z.string() }),
zod_1.z.object({ DeduplicationDuration: zod_1.z.object({ value: zod_1.z.object({ seconds: zod_1.z.number() }) }) }),
zod_1.z.object({ DeduplicationDuration: zod_1.z.object({ value: zod_1.z.number() }) }),
zod_1.z.object({ DeduplicationDuration: zod_1.z.object({ seconds: zod_1.z.number() }) }),
zod_1.z.object({ DeduplicationDuration: zod_1.z.number() }),
zod_1.z.object({ DeduplicationDuration: zod_1.z.string() }),
// Sometimes an explicit Empty or empty object
zod_1.z.object({ Empty: zod_1.z.object({}).strict() }),
zod_1.z.object({}).strict(),
])
.optional()
.nullable(),
/** Trace context (optional). */
traceContext: common_1.TraceContextSchema.optional(),
/** Offset for resuming the stream. */
offset: zod_1.z.number(),
/** Synchronizer time information. */
synchronizerTime: exports.SynchronizerTimeSchema,
}),
});
/** Offset checkpoint for stream resumption. */
exports.OffsetCheckpointSchema = zod_1.z.object({
/** The checkpoint details. */
value: zod_1.z.object({
/** Offset for resuming the stream. */
offset: zod_1.z.number(),
/** Synchronizer times. */
synchronizerTimes: zod_1.z.array(exports.SynchronizerTimeSchema),
}),
});
/** Completion response (oneOf completion, empty, or offset checkpoint). */
exports.CompletionResponseSchema = zod_1.z.union([
zod_1.z.object({ Completion: exports.CompletionSchema }),
zod_1.z.object({ Empty: zod_1.z.object({}) }),
zod_1.z.object({ OffsetCheckpoint: exports.OffsetCheckpointSchema }),
]);
/** Completion stream request. */
exports.CompletionStreamRequestSchema = 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(),
});
/** Completion stream response. */
exports.CompletionStreamResponseSchema = zod_1.z.object({
/** The completion response. */
completionResponse: exports.CompletionResponseSchema,
});
//# sourceMappingURL=completions.js.map