|
| 1 | +export * from './sdk'; |
| 2 | +export * as EVM_PB from '@cre/generated/capabilities/blockchain/evm/v1alpha/client_pb'; |
| 3 | +export * as CONFIDENTIAL_HTTP_CLIENT_PB from '@cre/generated/capabilities/networking/confidentialhttp/v1alpha/client_pb'; |
| 4 | +export * as HTTP_CLIENT_PB from '@cre/generated/capabilities/networking/http/v1alpha/client_pb'; |
| 5 | +export * as HTTP_TRIGGER_PB from '@cre/generated/capabilities/networking/http/v1alpha/trigger_pb'; |
| 6 | +export * as CRON_TRIGGER_PB from '@cre/generated/capabilities/scheduler/cron/v1/trigger_pb'; |
| 7 | +export * as SDK_PB from '@cre/generated/sdk/v1alpha/sdk_pb'; |
| 8 | +export * as VALUES_PB from '@cre/generated/values/v1/values_pb'; |
| 9 | +export * as BUFBUILD_TYPES from '@cre/sdk/types/bufbuild-types'; |
| 10 | +export * from './cre'; |
| 11 | +export * from './don-info'; |
| 12 | +export * from './errors'; |
| 13 | +export * from './report'; |
| 14 | +export type * from './runtime'; |
| 15 | +export * from './runtime'; |
| 16 | +export * from './types/bufbuild-types'; |
| 17 | +export * from './utils'; |
| 18 | +export * from './utils/capabilities/http/http-helpers'; |
| 19 | +export * from './wasm'; |
| 20 | +export * from './workflow'; |
| 21 | +import type { Message } from '@bufbuild/protobuf'; |
| 22 | +import type { GenMessage } from '@bufbuild/protobuf/codegenv2'; |
| 23 | +import type { ReportRequest, ReportRequestJson } from '@cre/generated/sdk/v1alpha/sdk_pb'; |
| 24 | +import type { Report } from '@cre/sdk/report'; |
| 25 | +import type { ConsensusAggregation, PrimitiveTypes, UnwrapOptions } from '@cre/sdk/utils'; |
| 26 | +import type { SecretsProvider } from '.'; |
| 27 | +export type { ReportRequest, ReportRequestJson }; |
| 28 | +export type CallCapabilityParams<I extends Message, O extends Message> = { |
| 29 | + capabilityId: string; |
| 30 | + method: string; |
| 31 | + payload: I; |
| 32 | + inputSchema: GenMessage<I>; |
| 33 | + outputSchema: GenMessage<O>; |
| 34 | +}; |
| 35 | +/** |
| 36 | + * Base runtime available in both DON and Node execution modes. |
| 37 | + * Provides core functionality for calling capabilities and logging. |
| 38 | + */ |
| 39 | +export interface BaseRuntime<C> { |
| 40 | + config: C; |
| 41 | + callCapability<I extends Message, O extends Message>(params: CallCapabilityParams<I, O>): { |
| 42 | + result: () => O; |
| 43 | + }; |
| 44 | + now(): Date; |
| 45 | + log(message: string): void; |
| 46 | +} |
| 47 | +/** |
| 48 | + * Runtime for Node mode execution. |
| 49 | + */ |
| 50 | +export interface NodeRuntime<C> extends BaseRuntime<C> { |
| 51 | + readonly _isNodeRuntime: true; |
| 52 | +} |
| 53 | +/** |
| 54 | + * Runtime for DON mode execution. |
| 55 | + */ |
| 56 | +export interface Runtime<C> extends BaseRuntime<C>, SecretsProvider { |
| 57 | + /** |
| 58 | + * Executes a function in Node mode and aggregates results via consensus. |
| 59 | + * |
| 60 | + * @param fn - Function to execute in each node (receives NodeRuntime) |
| 61 | + * @param consensusAggregation - How to aggregate results across nodes |
| 62 | + * @param unwrapOptions - Optional unwrapping config for complex return types |
| 63 | + * @returns Wrapped function that returns aggregated result |
| 64 | + */ |
| 65 | + runInNodeMode<TArgs extends unknown[], TOutput>(fn: (nodeRuntime: NodeRuntime<C>, ...args: TArgs) => TOutput, consensusAggregation: ConsensusAggregation<TOutput, true>, unwrapOptions?: TOutput extends PrimitiveTypes ? never : UnwrapOptions<TOutput>): (...args: TArgs) => { |
| 66 | + result: () => TOutput; |
| 67 | + }; |
| 68 | + report(input: ReportRequest | ReportRequestJson): { |
| 69 | + result: () => Report; |
| 70 | + }; |
| 71 | +} |
| 72 | +import type { Message } from '@bufbuild/protobuf'; |
| 73 | +import type { Secret, SecretRequest, SecretRequestJson } from '@cre/generated/sdk/v1alpha/sdk_pb'; |
| 74 | +import { type Runtime } from '@cre/sdk/runtime'; |
| 75 | +import type { Trigger } from '@cre/sdk/utils/triggers/trigger-interface'; |
| 76 | +import type { CreSerializable } from './utils'; |
| 77 | +export type HandlerFn<TConfig, TTriggerOutput, TResult> = (runtime: Runtime<TConfig>, triggerOutput: TTriggerOutput) => Promise<CreSerializable<TResult>> | CreSerializable<TResult>; |
| 78 | +export interface HandlerEntry<TConfig, TRawTriggerOutput extends Message<string>, TTriggerOutput, TResult> { |
| 79 | + trigger: Trigger<TRawTriggerOutput, TTriggerOutput>; |
| 80 | + fn: HandlerFn<TConfig, TTriggerOutput, TResult>; |
| 81 | +} |
| 82 | +export type Workflow<TConfig> = ReadonlyArray<HandlerEntry<TConfig, any, any, any>>; |
| 83 | +export declare const handler: <TRawTriggerOutput extends Message<string>, TTriggerOutput, TConfig, TResult>(trigger: Trigger<TRawTriggerOutput, TTriggerOutput>, fn: HandlerFn<TConfig, TTriggerOutput, TResult>) => HandlerEntry<TConfig, TRawTriggerOutput, TTriggerOutput, TResult>; |
| 84 | +export type SecretsProvider = { |
| 85 | + getSecret(request: SecretRequest | SecretRequestJson): { |
| 86 | + result: () => Secret; |
| 87 | + }; |
| 88 | +}; |
| 89 | +import type { SecretRequest } from '@cre/generated/sdk/v1alpha/sdk_pb'; |
| 90 | +export declare class DonModeError extends Error { |
| 91 | + constructor(); |
| 92 | +} |
| 93 | +export declare class NodeModeError extends Error { |
| 94 | + constructor(); |
| 95 | +} |
| 96 | +export declare class SecretsError extends Error { |
| 97 | + secretRequest: SecretRequest; |
| 98 | + error: string; |
| 99 | + constructor(secretRequest: SecretRequest, error: string); |
| 100 | +} |
| 101 | +export declare class NullReportError extends Error { |
| 102 | + constructor(); |
| 103 | +} |
| 104 | +export declare class WrongSignatureCountError extends Error { |
| 105 | + constructor(); |
| 106 | +} |
| 107 | +export declare class ParseSignatureError extends Error { |
| 108 | + constructor(); |
| 109 | +} |
| 110 | +export declare class RecoverSignerError extends Error { |
| 111 | + constructor(); |
| 112 | +} |
| 113 | +export declare class UnknownSignerError extends Error { |
| 114 | + constructor(); |
| 115 | +} |
| 116 | +export declare class DuplicateSignerError extends Error { |
| 117 | + constructor(); |
| 118 | +} |
| 119 | +export declare class RawReportTooShortError extends Error { |
| 120 | + readonly need: number; |
| 121 | + readonly got: number; |
| 122 | + constructor(need: number, got: number); |
| 123 | +} |
| 124 | +import { type ReportResponse, type ReportResponseJson } from '@cre/generated/sdk/v1alpha/sdk_pb'; |
| 125 | +import { type Environment, type Zone } from './don-info'; |
| 126 | +import type { BaseRuntime } from './runtime'; |
| 127 | +export type ReportParseConfig = { |
| 128 | + acceptedZones?: Zone[]; |
| 129 | + acceptedEnvironments?: Environment[]; |
| 130 | + skipSignatureVerification?: boolean; |
| 131 | +}; |
| 132 | +export declare const REPORT_METADATA_HEADER_LENGTH = 109; |
| 133 | +export type ReportMetadataHeader = { |
| 134 | + version: number; |
| 135 | + executionId: string; |
| 136 | + timestamp: number; |
| 137 | + donId: number; |
| 138 | + donConfigVersion: number; |
| 139 | + workflowId: string; |
| 140 | + workflowName: string; |
| 141 | + workflowOwner: string; |
| 142 | + reportId: string; |
| 143 | + body: Uint8Array; |
| 144 | +}; |
| 145 | +export declare class Report { |
| 146 | + private readonly report; |
| 147 | + private cachedHeader; |
| 148 | + constructor(report: ReportResponse | ReportResponseJson); |
| 149 | + static parse(runtime: BaseRuntime<unknown>, rawReport: Uint8Array, signatures: Uint8Array[], reportContext: Uint8Array, config?: ReportParseConfig): Promise<Report>; |
| 150 | + private parseHeader; |
| 151 | + private verifySignaturesWithConfig; |
| 152 | + seqNr(): bigint; |
| 153 | + configDigest(): Uint8Array; |
| 154 | + reportContext(): Uint8Array; |
| 155 | + rawReport(): Uint8Array; |
| 156 | + version(): number; |
| 157 | + executionId(): string; |
| 158 | + timestamp(): number; |
| 159 | + donId(): number; |
| 160 | + donConfigVersion(): number; |
| 161 | + workflowId(): string; |
| 162 | + workflowName(): string; |
| 163 | + workflowOwner(): string; |
| 164 | + reportId(): string; |
| 165 | + body(): Uint8Array; |
| 166 | + x_generatedCodeOnly_unwrap(): ReportResponse; |
| 167 | +} |
0 commit comments