@open-conduit/sdk 0.0.0-stage → 7.1.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.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -2
  3. package/dist/actions.d.ts +145 -0
  4. package/dist/actions.js +281 -0
  5. package/dist/actiontest.d.ts +80 -0
  6. package/dist/actiontest.js +190 -0
  7. package/dist/artifactstore.d.ts +133 -0
  8. package/dist/artifactstore.js +364 -0
  9. package/dist/backup.d.ts +99 -0
  10. package/dist/backup.js +178 -0
  11. package/dist/containertest.d.ts +71 -0
  12. package/dist/containertest.js +294 -0
  13. package/dist/errors.d.ts +127 -0
  14. package/dist/errors.js +180 -0
  15. package/dist/executor.d.ts +374 -0
  16. package/dist/executor.js +556 -0
  17. package/dist/executortest.d.ts +183 -0
  18. package/dist/executortest.js +534 -0
  19. package/dist/extension.d.ts +855 -0
  20. package/dist/extension.js +1822 -0
  21. package/dist/feed.d.ts +20 -0
  22. package/dist/feed.js +88 -0
  23. package/dist/forward.d.ts +38 -0
  24. package/dist/forward.js +163 -0
  25. package/dist/forwardca.d.ts +21 -0
  26. package/dist/forwardca.js +144 -0
  27. package/dist/hooks.d.ts +108 -0
  28. package/dist/hooks.js +13 -0
  29. package/dist/host.d.ts +295 -0
  30. package/dist/host.js +486 -0
  31. package/dist/index.d.ts +34 -0
  32. package/dist/index.js +31 -0
  33. package/dist/jsonrpc.d.ts +39 -0
  34. package/dist/jsonrpc.js +350 -0
  35. package/dist/probe.d.ts +61 -0
  36. package/dist/probe.js +92 -0
  37. package/dist/providertest.d.ts +59 -0
  38. package/dist/providertest.js +168 -0
  39. package/dist/resources.d.ts +208 -0
  40. package/dist/resources.js +303 -0
  41. package/dist/sandbox.d.ts +84 -0
  42. package/dist/sandbox.js +85 -0
  43. package/dist/schema.d.ts +71 -0
  44. package/dist/schema.js +252 -0
  45. package/dist/setup.d.ts +145 -0
  46. package/dist/setup.js +179 -0
  47. package/dist/setuptest.d.ts +90 -0
  48. package/dist/setuptest.js +319 -0
  49. package/dist/storetest.d.ts +64 -0
  50. package/dist/storetest.js +740 -0
  51. package/dist/telemetry.d.ts +86 -0
  52. package/dist/telemetry.js +46 -0
  53. package/dist/testing.d.ts +756 -0
  54. package/dist/testing.js +2165 -0
  55. package/dist/toolbelt.d.ts +91 -0
  56. package/dist/toolbelt.js +216 -0
  57. package/dist/tunnel.d.ts +62 -0
  58. package/dist/tunnel.js +93 -0
  59. package/dist/wire.d.ts +5359 -0
  60. package/dist/wire.js +2211 -0
  61. package/package.json +29 -4
@@ -0,0 +1,183 @@
1
+ import { type ExecutorResult } from "./executor.js";
2
+ import { type Infer } from "./schema.js";
3
+ import { type Capabilities, type Controls, type Event, type ExecutionContext, type Payload, LiveResult, AttachSpec, InteractiveLaunchSpec, type RunRequest, type SandboxLaunch, type SandboxNeeds, StateSweepReport, type Work } from "./wire.js";
4
+ /** What a test attempt is: the IDs, config and context the host would send, the rest defaulted (testRunRequest). */
5
+ export interface TestRunRequestOptions {
6
+ executionId?: string;
7
+ workId?: string;
8
+ scopeId?: string;
9
+ /** The binding config's data. */
10
+ config?: unknown;
11
+ configSchema?: string;
12
+ /** The lease epoch (default 1). */
13
+ epoch?: number;
14
+ trigger?: Event;
15
+ inputs?: Event[];
16
+ /** More of the execution context: secrets, toolbelt, env. */
17
+ context?: Partial<ExecutionContext>;
18
+ }
19
+ /** A RunRequest as the host sends it, with every required field filled in. */
20
+ export declare function testRunRequest(o?: TestRunRequestOptions): RunRequest;
21
+ /** Saves a run's continuity state (the host's execution.persist_recovery); throwing refuses it. */
22
+ export type Persist = (state: Payload) => void | Promise<void>;
23
+ /** A started attempt, as the host observes it. */
24
+ export interface TestRunHandle {
25
+ wait(signal?: AbortSignal): Promise<ExecutorResult>;
26
+ }
27
+ /** One declared executor as the host reaches it: each call one executor.* request. */
28
+ export interface TestExecutor {
29
+ readonly name: string;
30
+ readonly capabilities: Capabilities;
31
+ readonly controls: Controls;
32
+ run(r: RunRequest, persist?: Persist): Promise<TestRunHandle>;
33
+ recover(r: RunRequest, state: Payload, persist?: Persist): Promise<TestRunHandle>;
34
+ resume(r: RunRequest, state: Payload, persist?: Persist): Promise<TestRunHandle>;
35
+ interrupt(execution: string): Promise<void>;
36
+ inject(execution: string, event: Event): Promise<void>;
37
+ stop(execution: string, epoch: number): Promise<void>;
38
+ forget(execution: string): Promise<void>;
39
+ /** One executor.sweep, its executor.known calls answered by known. */
40
+ sweep(known: (ids: string[]) => Iterable<string> | Promise<Iterable<string>>): Promise<Infer<typeof StateSweepReport>>;
41
+ live(execution: string, tail?: number): Promise<Infer<typeof LiveResult>>;
42
+ attach(work: string): Promise<Infer<typeof AttachSpec>>;
43
+ /** One executor.container_attach for a Work, with the binding's config data. */
44
+ containerAttach(work: Work, config: unknown, o?: {
45
+ secrets?: Record<string, string>;
46
+ home?: string;
47
+ }): Promise<{
48
+ needs: SandboxNeeds;
49
+ launch: SandboxLaunch;
50
+ }>;
51
+ /** One executor.interactive_launch; filesDir defaults to "/sdktest/files". */
52
+ interactiveLaunch(r: {
53
+ playbook: string;
54
+ name: string;
55
+ summary?: string;
56
+ allow?: string[];
57
+ dir?: string;
58
+ filesDir?: string;
59
+ program?: string;
60
+ }): Promise<Infer<typeof InteractiveLaunchSpec>>;
61
+ /** The resource mode a binding config requests (validate executor_mode), "" when undeclared or the call fails, as the host reads it. */
62
+ resourceMode(config: unknown): Promise<string>;
63
+ /** The playbook a binding config starts its turns on (validate executor_playbook), "" when undeclared or the call fails. */
64
+ playbook(config: unknown): Promise<string>;
65
+ /** The version probe for a binding config (validate executor_probe), undefined when undeclared, none or the call fails. */
66
+ versionProbe(config: unknown): Promise<{
67
+ argv: string[];
68
+ env: string[];
69
+ } | undefined>;
70
+ /** A binding config adapted to its included folder (validate executor_folder), unchanged when undeclared; a refusal throws, as the host refuses the binding. */
71
+ folderConfig(config: unknown, folder: string, resource: boolean): Promise<unknown>;
72
+ }
73
+ /** @internal What the test host keeps for the runs and sweeps it started. */
74
+ export interface ExecutorWiring {
75
+ call(method: string, p: unknown, signal?: AbortSignal): Promise<unknown>;
76
+ open(run: string, persist: Persist | undefined, confine: {
77
+ sandbox: boolean;
78
+ container: boolean;
79
+ }): {
80
+ persistErr: () => unknown;
81
+ };
82
+ close(run: string): void;
83
+ sweeps: Map<string, (ids: string[]) => Iterable<string> | Promise<Iterable<string>>>;
84
+ decl: {
85
+ capabilities: Capabilities;
86
+ controls?: Controls;
87
+ resource_mode?: boolean;
88
+ playbook?: boolean;
89
+ version_probe?: boolean;
90
+ folder_config?: boolean;
91
+ } | undefined;
92
+ }
93
+ /** @internal */
94
+ export declare function testExecutor(name: string, w: ExecutorWiring): TestExecutor;
95
+ /**
96
+ * Checks the attempt lifecycle (conformance.CheckExecutor): run saves its
97
+ * continuity state before it is acknowledged, and its result is valid;
98
+ * recover adopts the attempt from that state without launching a
99
+ * replacement, saving the identical state again under its lease, and
100
+ * keeps the result; recover refuses state it doesn't hold as not
101
+ * adoptable; and a run whose state the host refuses to save fails with
102
+ * that refusal. r must finish on its own.
103
+ */
104
+ export declare function checkExecutor(x: TestExecutor, r: RunRequest): Promise<void>;
105
+ /** An inject-capable executor's running attempt (conformance.InjectFixture). */
106
+ export interface InjectFixture {
107
+ executor: TestExecutor;
108
+ /** Starts an attempt that keeps running until finish. */
109
+ request: RunRequest;
110
+ /** Resolves once the running attempt can take input. */
111
+ ready?: () => Promise<void>;
112
+ /** Lets the attempt take in what was injected and finish. */
113
+ finish?: () => Promise<void>;
114
+ }
115
+ /**
116
+ * Checks the inject acknowledgement (conformance.CheckInjectExecutor):
117
+ * inject to an execution the executor doesn't hold is not accepting; to
118
+ * the running attempt, and again with the same Event, it is accepted; the
119
+ * result proves the attempt took the Event in, exactly once; after the
120
+ * result inject is not accepting; and recover gives the same proof.
121
+ */
122
+ export declare function checkInjectExecutor(f: InjectFixture): Promise<void>;
123
+ /** Two attempts of different executions that finish on their own; the sweeps say the host holds known and not unknown (conformance.StateSweepFixture). */
124
+ export interface StateSweepFixture {
125
+ executor: TestExecutor;
126
+ known: RunRequest;
127
+ unknown: RunRequest;
128
+ }
129
+ /**
130
+ * Checks a state sweep (conformance.CheckStateSweeper): a sweep whose
131
+ * known call fails fails, releasing nothing; a sweep asks about the
132
+ * unknown execution, at most MaxKnownBatch at a time, and reports it
133
+ * removed, never the known one; after it the known attempt still recovers
134
+ * with its result and the unknown one is not adoptable; a second sweep
135
+ * removes nothing more.
136
+ */
137
+ export declare function checkStateSweeper(f: StateSweepFixture): Promise<void>;
138
+ /** One toolbelt call the test toolbelt took. */
139
+ export interface TestToolCall {
140
+ operation: string;
141
+ input: unknown;
142
+ requestId: string;
143
+ token: string;
144
+ }
145
+ /**
146
+ * A toolbelt for executor tests, served on a Unix socket in a directory
147
+ * of its own as the host serves an execution's: POST /v1/toolbelt/call
148
+ * and GET /v1/toolbelt/guidance under its one token. A call to an
149
+ * operation in parks (and the builtin wait) answers with a Wait, as the
150
+ * host answers a call that parks the run; answer overrides any call's
151
+ * result. It records every call it takes.
152
+ */
153
+ export declare class TestToolbelt {
154
+ #private;
155
+ readonly token = "sdktest-toolbelt-token";
156
+ readonly calls: TestToolCall[];
157
+ readonly parks: Set<string>;
158
+ answer: ((c: TestToolCall) => Record<string, unknown> | undefined) | undefined;
159
+ private constructor();
160
+ /** Starts one, parking the run on calls to parks. Close it when the test ends. */
161
+ static start(parks?: string[]): Promise<TestToolbelt>;
162
+ /** The endpoint an execution context names it by. */
163
+ get endpoint(): string;
164
+ /** The execution context's toolbelt fields. */
165
+ get context(): Partial<ExecutionContext>;
166
+ close(): Promise<void>;
167
+ }
168
+ /** An attempt that calls the toolbelt, and the toolbelt it calls (checkTurnEnds). */
169
+ export interface TurnFixture {
170
+ executor: TestExecutor;
171
+ /** An attempt whose context names belt, that calls operation park and then goes on calling. */
172
+ request: RunRequest;
173
+ belt: TestToolbelt;
174
+ /** The operation whose result parks the run; belt must park on it. */
175
+ park: string;
176
+ }
177
+ /**
178
+ * Checks that a call whose result parks the run ends the turn, whichever
179
+ * operation made it: the attempt makes no toolbelt call after it, and
180
+ * ends with a waiting or handoff outcome rather than going on to complete
181
+ * or fail.
182
+ */
183
+ export declare function checkTurnEnds(f: TurnFixture): Promise<void>;