@open-conduit/sdk 0.0.0-bootstrap.0

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.
@@ -0,0 +1,167 @@
1
+ import type { Extension } from "./extension.js";
2
+ import { type Value } from "./host.js";
3
+ import { type AcceptedEvent, type ArtifactRef, type Authority, type CheckRunResult, type ConfigEntry, ConfigureResult, type Event, type PendingInput, type Route, RouteDecision, type RouteInput, RouteSample, type Scan, type Scope, Snapshot, type SourceDecl, WaitPlan, type Work } from "./wire.js";
4
+ /** The test clock's start (sdktest.Start, conformance.NewClock's start). */
5
+ export declare const testStart = "2026-10-24T12:00:00.000Z";
6
+ /** The host's clock. It moves only when the test moves it. */
7
+ export declare class TestClock {
8
+ #private;
9
+ constructor(start?: string | Date);
10
+ /** The clock's time, as an RFC 3339 string. */
11
+ now(): string;
12
+ /** Moves the clock on by ms milliseconds. */
13
+ advance(ms: number): void;
14
+ /** Sets the clock to a time. */
15
+ set(at: string | Date): void;
16
+ }
17
+ export interface TestHostOptions {
18
+ clock?: TestClock;
19
+ /** Scopes configured for the extension (configure's entries add theirs). */
20
+ scopes?: string[];
21
+ /** Seeded Work; its scope is configured. */
22
+ works?: Work[];
23
+ /** Seeded accepted Events, in order, each in a scope. */
24
+ events?: {
25
+ scopeId: string;
26
+ event: Event;
27
+ }[];
28
+ /** Input routed to a Work that no attempt has read yet, by Work ID. */
29
+ pending?: Record<string, PendingInput[]>;
30
+ /** Secret values an entry may resolve, by scope. */
31
+ secrets?: Record<string, Record<string, string>>;
32
+ /** Secret values of a connection in a scope. */
33
+ connectionSecrets?: {
34
+ scopeId: string;
35
+ connection: string;
36
+ values: Record<string, string>;
37
+ }[];
38
+ /** Seeded KV values. */
39
+ kv?: {
40
+ namespace: string;
41
+ key: string;
42
+ value: Value;
43
+ }[];
44
+ /** The KV layout the host has recorded (default 0). */
45
+ kvVersion?: number;
46
+ /** The private state directory given at initialize (default "/sdktest/state"). */
47
+ stateDir?: string;
48
+ /** The authority operation calls carry; unset fields are defaulted. */
49
+ authority?: Partial<Authority>;
50
+ }
51
+ /** What an operation returned: a handler's output, a wait's plan, an emission's Event and commit output. */
52
+ export interface OperationOut {
53
+ /** The output's data (a handler's, a wait plan's, or an emission's commit's). */
54
+ output: unknown;
55
+ wait?: WaitPlan;
56
+ event?: AcceptedEvent;
57
+ /** False when an emission's once matched one already accepted. */
58
+ added?: boolean;
59
+ }
60
+ export interface WebhookCall {
61
+ method?: string;
62
+ query?: string;
63
+ headers?: Record<string, string | string[]>;
64
+ body?: Value;
65
+ /** The host's receipt time (default now). */
66
+ receivedAt?: string;
67
+ forwardId?: string;
68
+ }
69
+ export interface WebhookOut {
70
+ status: number;
71
+ headers: Record<string, string[]>;
72
+ body: Uint8Array;
73
+ }
74
+ /** One committed artifact. */
75
+ export interface TestArtifact {
76
+ ref: ArtifactRef;
77
+ mediaType: string;
78
+ data: Uint8Array;
79
+ }
80
+ /** A KV value's version: a digest of its content, as sdktest.Version. */
81
+ export declare function kvVersion(value: Uint8Array): string;
82
+ /**
83
+ * Serves ext on an in-memory host and initializes it. Close it when the
84
+ * test ends (in an after hook), so the served connection ends.
85
+ */
86
+ export declare function testHost(ext: Extension, o?: TestHostOptions): Promise<TestHost>;
87
+ export declare class TestHost {
88
+ #private;
89
+ readonly clock: TestClock;
90
+ readonly stateDir: string;
91
+ constructor(ext: Extension, o: TestHostOptions);
92
+ /** @internal */
93
+ _initialize(): Promise<void>;
94
+ /** Ends the served connection. */
95
+ close(): void;
96
+ /** The host clock's time. */
97
+ now(): string;
98
+ /** Makes any host-to-extension call, for a surface without a helper. */
99
+ call(method: string, p: unknown): Promise<unknown>;
100
+ /**
101
+ * Applies a configuration generation. Each entry's scope becomes
102
+ * configured, and the sources the result registers can be delivered to,
103
+ * reconciled and sent webhooks.
104
+ */
105
+ configure(entries: ConfigEntry[], o?: {
106
+ disabled?: ConfigEntry[];
107
+ publicUrl?: string;
108
+ }): Promise<ConfigureResult>;
109
+ /** Checks a config object as config check does: throws the extension's refusal. */
110
+ validate(kind: string, type: string, config: unknown): Promise<void>;
111
+ /**
112
+ * Calls a declared operation with input as its data, by the kind the
113
+ * manifest declares. Unset authority fields default: the first
114
+ * configured scope, Work "sdktest-work", execution "sdktest-execution",
115
+ * an expiry an hour from now, every declared operation and family. An
116
+ * emission is accepted in the authority's scope, and its commit's
117
+ * records are written to KV, as the toolbelt would.
118
+ */
119
+ operation(name: string, input?: unknown, authority?: Partial<Authority>): Promise<OperationOut>;
120
+ /** Asks a route handler to match one input; route.config is given as its data. */
121
+ route(handler: string, input: Omit<RouteInput, "event"> & {
122
+ event: Event | AcceptedEvent;
123
+ }): Promise<RouteDecision>;
124
+ /** The sample Events a route handler offers for a route of a scope, as of the clock's now. */
125
+ samples(handler: string, scope: Scope, route: Route): Promise<RouteSample[]>;
126
+ /** Reads one page of a registered source. */
127
+ reconcile(source: string, scan?: Omit<Scan, "source">): Promise<Snapshot>;
128
+ /** Reads every page of a registered source, from its first. */
129
+ reconcileAll(source: string): Promise<Snapshot[]>;
130
+ /** Pushes a delivery to a registered source and accepts what it observed, as the host's ingress does. */
131
+ push(source: string, delivery: {
132
+ id: string;
133
+ body: Value;
134
+ contentType?: string;
135
+ receivedAt?: string;
136
+ }): Promise<{
137
+ accepted: AcceptedEvent[];
138
+ added: boolean[];
139
+ }>;
140
+ /**
141
+ * Sends one HTTP request on a webhook path, as the host's listener
142
+ * does. A path no registered source took answers 404 here, as the
143
+ * listener answers it, without reaching the extension.
144
+ */
145
+ webhook(path: string, req?: WebhookCall): Promise<WebhookOut>;
146
+ /** Asks a Work kind's trigger which of inputs triggers the next execution. */
147
+ trigger(kind: string, inputs: Event[]): Promise<number>;
148
+ /** Runs a background task once. */
149
+ task(name: string): Promise<void>;
150
+ /** Runs a doctor check, with an empty configuration view unless config is given. */
151
+ check(name: string, o?: {
152
+ deep?: boolean;
153
+ config?: unknown;
154
+ }): Promise<CheckRunResult>;
155
+ /** A KV value, or undefined. */
156
+ kv(namespace: string, key: string): Uint8Array | undefined;
157
+ /** A KV value as UTF-8 text, or undefined. */
158
+ kvText(namespace: string, key: string): string | undefined;
159
+ /** Every accepted Event, in order, seeded ones included. */
160
+ events(): AcceptedEvent[];
161
+ /** The sources the last configure registered. */
162
+ sources(): SourceDecl[];
163
+ /** Committed artifacts, in order. */
164
+ artifacts(): TestArtifact[];
165
+ /** The progress line wait.progress last set for a Work ("" for none). */
166
+ progress(workId: string): string;
167
+ }