Files
gen/out/ts/tasks/tasks_zap.ts
zeekay fd4da20ec5 test(gen): commit end-to-end proof artifacts (TS + OpenAPI + Go)
Force-added past .gitignore's out/ as reproducible proof that one .zap
schema mechanically produces every surface:
- out/ts/tasks/tasks_zap.ts   Tier-2 zero-copy View/Client/Server; tsc --noEmit
  clean against @zap-proto/zap under strict (noUnusedLocals, verbatimModuleSyntax).
- out/{ts,go}/tasks/tasks.openapi.json  OpenAPI 3.1.0; openapi-spec-validator OK;
  4/4 methods as POST /tasks/<method>; 9 referenced structs in components.schemas.
- out/go/tasks  oapi-codegen Tier-1 client + go.mod + offline request-forming
  test: go vet/build/test all green (forms POST https://api.hanzo.ai/tasks/*).
- out/docs/{ts,go}/tasks.mdx  generated SDK doc stubs.

Regenerate: bin/zapsdk ts schemas/tasks.zap ; bin/zapsdk go schemas/tasks.zap
2026-07-05 13:29:14 -07:00

519 lines
18 KiB
TypeScript

// Code generated from a ZAP schema (zap-proto/gen) — DO NOT EDIT.
// Regenerate: bin/zapsdk ts schemas/tasks.zap
// Code generated by zapgen --target=ts; DO NOT EDIT.
// source: tasks.zap
import {
Builder,
Message,
StructView,
buildRequest,
parseRequest,
buildResponse,
Status,
Session,
type Call,
type Response,
type PromiseHandle,
} from "@zap-proto/zap";
const workflowExecutionOff = {
workflowId: 0,
runId: 8,
} as const;
const workflowExecutionSize = 16;
/** Zero-copy view into a ZAP-encoded WorkflowExecution message. */
export class WorkflowExecution extends StructView {
/** Parse `b` and return a typed view. Throws on a wire-level check failure (magic, version, size). */
static wrap(b: Uint8Array): WorkflowExecution {
const root = Message.parse(b).root();
return new WorkflowExecution(root.data, root.offset);
}
get workflowId(): string { return this.text(workflowExecutionOff.workflowId); }
get runId(): string { return this.text(workflowExecutionOff.runId); }
}
/** Field values for newWorkflowExecution. */
export interface WorkflowExecutionInput {
workflowId: string;
runId: string;
}
/** Build a ZAP-encoded WorkflowExecution message from `in` and return the bytes. */
export function newWorkflowExecution(in_: WorkflowExecutionInput): Uint8Array {
const b = new Builder(256);
const ob = b.startObject(workflowExecutionSize);
ob.setText(workflowExecutionOff.workflowId, in_.workflowId);
ob.setText(workflowExecutionOff.runId, in_.runId);
ob.finishAsRoot();
return b.finish();
}
const workflowTypeOff = {
name: 0,
} as const;
const workflowTypeSize = 8;
/** Zero-copy view into a ZAP-encoded WorkflowType message. */
export class WorkflowType extends StructView {
/** Parse `b` and return a typed view. Throws on a wire-level check failure (magic, version, size). */
static wrap(b: Uint8Array): WorkflowType {
const root = Message.parse(b).root();
return new WorkflowType(root.data, root.offset);
}
get name(): string { return this.text(workflowTypeOff.name); }
}
/** Field values for newWorkflowType. */
export interface WorkflowTypeInput {
name: string;
}
/** Build a ZAP-encoded WorkflowType message from `in` and return the bytes. */
export function newWorkflowType(in_: WorkflowTypeInput): Uint8Array {
const b = new Builder(256);
const ob = b.startObject(workflowTypeSize);
ob.setText(workflowTypeOff.name, in_.name);
ob.finishAsRoot();
return b.finish();
}
const startWorkflowRequestOff = {
namespace: 0,
workflowId: 8,
taskQueue: 16,
input: 24,
} as const;
const startWorkflowRequestSize = 32;
/** Zero-copy view into a ZAP-encoded StartWorkflowRequest message. */
export class StartWorkflowRequest extends StructView {
/** Parse `b` and return a typed view. Throws on a wire-level check failure (magic, version, size). */
static wrap(b: Uint8Array): StartWorkflowRequest {
const root = Message.parse(b).root();
return new StartWorkflowRequest(root.data, root.offset);
}
get namespace(): string { return this.text(startWorkflowRequestOff.namespace); }
get workflowId(): string { return this.text(startWorkflowRequestOff.workflowId); }
get taskQueue(): string { return this.text(startWorkflowRequestOff.taskQueue); }
get input(): Uint8Array { return this.bytes(startWorkflowRequestOff.input); }
}
/** Field values for newStartWorkflowRequest. */
export interface StartWorkflowRequestInput {
namespace: string;
workflowId: string;
taskQueue: string;
input: Uint8Array;
}
/** Build a ZAP-encoded StartWorkflowRequest message from `in` and return the bytes. */
export function newStartWorkflowRequest(in_: StartWorkflowRequestInput): Uint8Array {
const b = new Builder(256);
const ob = b.startObject(startWorkflowRequestSize);
ob.setText(startWorkflowRequestOff.namespace, in_.namespace);
ob.setText(startWorkflowRequestOff.workflowId, in_.workflowId);
ob.setText(startWorkflowRequestOff.taskQueue, in_.taskQueue);
ob.setBytes(startWorkflowRequestOff.input, in_.input);
ob.finishAsRoot();
return b.finish();
}
const startWorkflowResponseOff = {
runId: 0,
} as const;
const startWorkflowResponseSize = 8;
/** Zero-copy view into a ZAP-encoded StartWorkflowResponse message. */
export class StartWorkflowResponse extends StructView {
/** Parse `b` and return a typed view. Throws on a wire-level check failure (magic, version, size). */
static wrap(b: Uint8Array): StartWorkflowResponse {
const root = Message.parse(b).root();
return new StartWorkflowResponse(root.data, root.offset);
}
get runId(): string { return this.text(startWorkflowResponseOff.runId); }
}
/** Field values for newStartWorkflowResponse. */
export interface StartWorkflowResponseInput {
runId: string;
}
/** Build a ZAP-encoded StartWorkflowResponse message from `in` and return the bytes. */
export function newStartWorkflowResponse(in_: StartWorkflowResponseInput): Uint8Array {
const b = new Builder(256);
const ob = b.startObject(startWorkflowResponseSize);
ob.setText(startWorkflowResponseOff.runId, in_.runId);
ob.finishAsRoot();
return b.finish();
}
const signalWorkflowRequestOff = {
namespace: 0,
workflowId: 8,
runId: 16,
signalName: 24,
input: 32,
} as const;
const signalWorkflowRequestSize = 40;
/** Zero-copy view into a ZAP-encoded SignalWorkflowRequest message. */
export class SignalWorkflowRequest extends StructView {
/** Parse `b` and return a typed view. Throws on a wire-level check failure (magic, version, size). */
static wrap(b: Uint8Array): SignalWorkflowRequest {
const root = Message.parse(b).root();
return new SignalWorkflowRequest(root.data, root.offset);
}
get namespace(): string { return this.text(signalWorkflowRequestOff.namespace); }
get workflowId(): string { return this.text(signalWorkflowRequestOff.workflowId); }
get runId(): string { return this.text(signalWorkflowRequestOff.runId); }
get signalName(): string { return this.text(signalWorkflowRequestOff.signalName); }
get input(): Uint8Array { return this.bytes(signalWorkflowRequestOff.input); }
}
/** Field values for newSignalWorkflowRequest. */
export interface SignalWorkflowRequestInput {
namespace: string;
workflowId: string;
runId: string;
signalName: string;
input: Uint8Array;
}
/** Build a ZAP-encoded SignalWorkflowRequest message from `in` and return the bytes. */
export function newSignalWorkflowRequest(in_: SignalWorkflowRequestInput): Uint8Array {
const b = new Builder(256);
const ob = b.startObject(signalWorkflowRequestSize);
ob.setText(signalWorkflowRequestOff.namespace, in_.namespace);
ob.setText(signalWorkflowRequestOff.workflowId, in_.workflowId);
ob.setText(signalWorkflowRequestOff.runId, in_.runId);
ob.setText(signalWorkflowRequestOff.signalName, in_.signalName);
ob.setBytes(signalWorkflowRequestOff.input, in_.input);
ob.finishAsRoot();
return b.finish();
}
const describeWorkflowRequestOff = {
namespace: 0,
workflowId: 8,
runId: 16,
} as const;
const describeWorkflowRequestSize = 24;
/** Zero-copy view into a ZAP-encoded DescribeWorkflowRequest message. */
export class DescribeWorkflowRequest extends StructView {
/** Parse `b` and return a typed view. Throws on a wire-level check failure (magic, version, size). */
static wrap(b: Uint8Array): DescribeWorkflowRequest {
const root = Message.parse(b).root();
return new DescribeWorkflowRequest(root.data, root.offset);
}
get namespace(): string { return this.text(describeWorkflowRequestOff.namespace); }
get workflowId(): string { return this.text(describeWorkflowRequestOff.workflowId); }
get runId(): string { return this.text(describeWorkflowRequestOff.runId); }
}
/** Field values for newDescribeWorkflowRequest. */
export interface DescribeWorkflowRequestInput {
namespace: string;
workflowId: string;
runId: string;
}
/** Build a ZAP-encoded DescribeWorkflowRequest message from `in` and return the bytes. */
export function newDescribeWorkflowRequest(in_: DescribeWorkflowRequestInput): Uint8Array {
const b = new Builder(256);
const ob = b.startObject(describeWorkflowRequestSize);
ob.setText(describeWorkflowRequestOff.namespace, in_.namespace);
ob.setText(describeWorkflowRequestOff.workflowId, in_.workflowId);
ob.setText(describeWorkflowRequestOff.runId, in_.runId);
ob.finishAsRoot();
return b.finish();
}
const workflowExecutionInfoOff = {
execution: 0,
type: 4,
startTimeMs: 8,
closeTimeMs: 16,
status: 24,
historyLength: 32,
} as const;
const workflowExecutionInfoSize = 40;
/** Zero-copy view into a ZAP-encoded WorkflowExecutionInfo message. */
export class WorkflowExecutionInfo extends StructView {
/** Parse `b` and return a typed view. Throws on a wire-level check failure (magic, version, size). */
static wrap(b: Uint8Array): WorkflowExecutionInfo {
const root = Message.parse(b).root();
return new WorkflowExecutionInfo(root.data, root.offset);
}
get execution(): WorkflowExecution {
const o = this.object(workflowExecutionInfoOff.execution);
return new WorkflowExecution(o.data, o.offset);
}
get type(): WorkflowType {
const o = this.object(workflowExecutionInfoOff.type);
return new WorkflowType(o.data, o.offset);
}
get startTimeMs(): bigint { return this.i64(workflowExecutionInfoOff.startTimeMs); }
get closeTimeMs(): bigint { return this.i64(workflowExecutionInfoOff.closeTimeMs); }
get status(): number { return this.u8(workflowExecutionInfoOff.status); }
get historyLength(): bigint { return this.i64(workflowExecutionInfoOff.historyLength); }
}
/** Field values for newWorkflowExecutionInfo. */
export interface WorkflowExecutionInfoInput {
execution: Uint8Array;
type: Uint8Array;
startTimeMs: bigint;
closeTimeMs: bigint;
status: number;
historyLength: bigint;
}
/** Build a ZAP-encoded WorkflowExecutionInfo message from `in` and return the bytes. */
export function newWorkflowExecutionInfo(in_: WorkflowExecutionInfoInput): Uint8Array {
const b = new Builder(256);
const ob = b.startObject(workflowExecutionInfoSize);
if (in_.execution.length > 0) {
const nested = b.startObject(in_.execution.length);
nested.setBytesFixed(0, in_.execution);
ob.setObject(workflowExecutionInfoOff.execution, nested.finish());
}
if (in_.type.length > 0) {
const nested = b.startObject(in_.type.length);
nested.setBytesFixed(0, in_.type);
ob.setObject(workflowExecutionInfoOff.type, nested.finish());
}
ob.setI64(workflowExecutionInfoOff.startTimeMs, in_.startTimeMs);
ob.setI64(workflowExecutionInfoOff.closeTimeMs, in_.closeTimeMs);
ob.setU8(workflowExecutionInfoOff.status, in_.status);
ob.setI64(workflowExecutionInfoOff.historyLength, in_.historyLength);
ob.finishAsRoot();
return b.finish();
}
const describeWorkflowResponseOff = {
info: 0,
} as const;
const describeWorkflowResponseSize = 4;
/** Zero-copy view into a ZAP-encoded DescribeWorkflowResponse message. */
export class DescribeWorkflowResponse extends StructView {
/** Parse `b` and return a typed view. Throws on a wire-level check failure (magic, version, size). */
static wrap(b: Uint8Array): DescribeWorkflowResponse {
const root = Message.parse(b).root();
return new DescribeWorkflowResponse(root.data, root.offset);
}
get info(): WorkflowExecutionInfo {
const o = this.object(describeWorkflowResponseOff.info);
return new WorkflowExecutionInfo(o.data, o.offset);
}
}
/** Field values for newDescribeWorkflowResponse. */
export interface DescribeWorkflowResponseInput {
info: Uint8Array;
}
/** Build a ZAP-encoded DescribeWorkflowResponse message from `in` and return the bytes. */
export function newDescribeWorkflowResponse(in_: DescribeWorkflowResponseInput): Uint8Array {
const b = new Builder(256);
const ob = b.startObject(describeWorkflowResponseSize);
if (in_.info.length > 0) {
const nested = b.startObject(in_.info.length);
nested.setBytesFixed(0, in_.info);
ob.setObject(describeWorkflowResponseOff.info, nested.finish());
}
ob.finishAsRoot();
return b.finish();
}
const healthResponseOff = {
service: 0,
status: 8,
} as const;
const healthResponseSize = 16;
/** Zero-copy view into a ZAP-encoded HealthResponse message. */
export class HealthResponse extends StructView {
/** Parse `b` and return a typed view. Throws on a wire-level check failure (magic, version, size). */
static wrap(b: Uint8Array): HealthResponse {
const root = Message.parse(b).root();
return new HealthResponse(root.data, root.offset);
}
get service(): string { return this.text(healthResponseOff.service); }
get status(): string { return this.text(healthResponseOff.status); }
}
/** Field values for newHealthResponse. */
export interface HealthResponseInput {
service: string;
status: string;
}
/** Build a ZAP-encoded HealthResponse message from `in` and return the bytes. */
export function newHealthResponse(in_: HealthResponseInput): Uint8Array {
const b = new Builder(256);
const ob = b.startObject(healthResponseSize);
ob.setText(healthResponseOff.service, in_.service);
ob.setText(healthResponseOff.status, in_.status);
ob.finishAsRoot();
return b.finish();
}
/** Method ordinals for the Tasks service (stable wire ids). */
export const TasksMethod = {
startWorkflow: 1,
signalWorkflow: 2,
describeWorkflow: 3,
health: 4,
} as const;
/** Typed RPC client for the Tasks service over a ZAP call channel. */
export interface TasksChannel {
/** Ship one Call envelope and await its correlated Response. */
call(envelope: Uint8Array): Promise<Response>;
}
/**
* Each call takes a fresh PromiseID from `session`; the pipelined "On" form
* of a method sets Target to a prior call's Promise so the server chains them.
*/
export class TasksClient {
private readonly session = new Session();
constructor(private readonly channel: TasksChannel, private readonly cap: Uint8Array = new Uint8Array(0)) {}
async startWorkflow(req: Uint8Array): Promise<[PromiseHandle, Uint8Array]> {
const p = this.session.next();
return this.invokeStartWorkflow(this.session.origin(p, TasksMethod.startWorkflow, this.cap, req), p);
}
/** Issue startWorkflow pipelined on `on`'s answer (the server substitutes it for the payload). */
async startWorkflowOn(on: PromiseHandle): Promise<[PromiseHandle, Uint8Array]> {
const p = this.session.next();
return this.invokeStartWorkflow(this.session.pipe(p, on, TasksMethod.startWorkflow, this.cap), p);
}
private async invokeStartWorkflow(call: Call, p: PromiseHandle): Promise<[PromiseHandle, Uint8Array]> {
const resp = await this.channel.call(buildRequest(call));
if (resp.status !== Status.OK) {
throw new Error(`Tasks.startWorkflow: status ${resp.status}`);
}
return [p, resp.body];
}
async signalWorkflow(req: Uint8Array): Promise<PromiseHandle> {
const p = this.session.next();
return this.invokeSignalWorkflow(this.session.origin(p, TasksMethod.signalWorkflow, this.cap, req), p);
}
/** Issue signalWorkflow pipelined on `on`'s answer (the server substitutes it for the payload). */
async signalWorkflowOn(on: PromiseHandle): Promise<PromiseHandle> {
const p = this.session.next();
return this.invokeSignalWorkflow(this.session.pipe(p, on, TasksMethod.signalWorkflow, this.cap), p);
}
private async invokeSignalWorkflow(call: Call, p: PromiseHandle): Promise<PromiseHandle> {
const resp = await this.channel.call(buildRequest(call));
if (resp.status !== Status.OK) {
throw new Error(`Tasks.signalWorkflow: status ${resp.status}`);
}
return p;
}
async describeWorkflow(req: Uint8Array): Promise<[PromiseHandle, Uint8Array]> {
const p = this.session.next();
return this.invokeDescribeWorkflow(this.session.origin(p, TasksMethod.describeWorkflow, this.cap, req), p);
}
/** Issue describeWorkflow pipelined on `on`'s answer (the server substitutes it for the payload). */
async describeWorkflowOn(on: PromiseHandle): Promise<[PromiseHandle, Uint8Array]> {
const p = this.session.next();
return this.invokeDescribeWorkflow(this.session.pipe(p, on, TasksMethod.describeWorkflow, this.cap), p);
}
private async invokeDescribeWorkflow(call: Call, p: PromiseHandle): Promise<[PromiseHandle, Uint8Array]> {
const resp = await this.channel.call(buildRequest(call));
if (resp.status !== Status.OK) {
throw new Error(`Tasks.describeWorkflow: status ${resp.status}`);
}
return [p, resp.body];
}
async health(): Promise<[PromiseHandle, Uint8Array]> {
const p = this.session.next();
return this.invokeHealth(this.session.origin(p, TasksMethod.health, this.cap, new Uint8Array(0)), p);
}
/** Issue health pipelined on `on`'s answer (the server substitutes it for the payload). */
async healthOn(on: PromiseHandle): Promise<[PromiseHandle, Uint8Array]> {
const p = this.session.next();
return this.invokeHealth(this.session.pipe(p, on, TasksMethod.health, this.cap), p);
}
private async invokeHealth(call: Call, p: PromiseHandle): Promise<[PromiseHandle, Uint8Array]> {
const resp = await this.channel.call(buildRequest(call));
if (resp.status !== Status.OK) {
throw new Error(`Tasks.health: status ${resp.status}`);
}
return [p, resp.body];
}
}
/** Abstract RPC server for the Tasks service. Subclass and implement each method. */
export abstract class TasksServer {
abstract startWorkflow(req: Uint8Array): Promise<Uint8Array>;
abstract signalWorkflow(req: Uint8Array): Promise<void>;
abstract describeWorkflow(req: Uint8Array): Promise<Uint8Array>;
abstract health(): Promise<Uint8Array>;
/** Decode a Call envelope, route by method ordinal, and build the Response envelope. */
async dispatch(envelope: Uint8Array): Promise<Uint8Array> {
const call: Call = parseRequest(envelope);
switch (call.method) {
case TasksMethod.startWorkflow: {
const body = await this.startWorkflow(call.payload);
return buildResponse(Status.OK, call.promiseID, body);
}
case TasksMethod.signalWorkflow: {
await this.signalWorkflow(call.payload);
return buildResponse(Status.OK, call.promiseID, new Uint8Array(0));
}
case TasksMethod.describeWorkflow: {
const body = await this.describeWorkflow(call.payload);
return buildResponse(Status.OK, call.promiseID, body);
}
case TasksMethod.health: {
const body = await this.health();
return buildResponse(Status.OK, call.promiseID, body);
}
default:
return buildResponse(Status.NotFound, call.promiseID, new Uint8Array(0));
}
}
}