@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.
- package/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/errors.d.ts +98 -0
- package/dist/errors.js +142 -0
- package/dist/extension.d.ts +356 -0
- package/dist/extension.js +674 -0
- package/dist/host.d.ts +129 -0
- package/dist/host.js +249 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +19 -0
- package/dist/jsonrpc.d.ts +31 -0
- package/dist/jsonrpc.js +316 -0
- package/dist/schema.d.ts +71 -0
- package/dist/schema.js +252 -0
- package/dist/testing.d.ts +167 -0
- package/dist/testing.js +711 -0
- package/dist/wire.d.ts +1621 -0
- package/dist/wire.js +611 -0
- package/package.json +31 -0
package/dist/wire.js
ADDED
|
@@ -0,0 +1,611 @@
|
|
|
1
|
+
// The wire messages this SDK uses, as protocol/messages.go, protocol/wire.go
|
|
2
|
+
// and protocol/manifest.go encode them. Each is a schema and a type of the
|
|
3
|
+
// same name: the SDK decodes what the host sends through the schema, so a
|
|
4
|
+
// malformed message is refused instead of reaching extension code as a lie.
|
|
5
|
+
//
|
|
6
|
+
// protocol/typescript_parity_test.go checks every field here against the Go
|
|
7
|
+
// type's JSON fields, so a renamed or removed Go field fails the Go tests.
|
|
8
|
+
//
|
|
9
|
+
// Times are RFC 3339 strings. Bytes ([]byte in Go: KV values, artifact
|
|
10
|
+
// chunks) are base64 strings; the Host client converts them. Go sends a nil
|
|
11
|
+
// slice or map as null, hence the t.nullable on the ones the SDK decodes.
|
|
12
|
+
import { t } from "./schema.js";
|
|
13
|
+
// A newer host may add fields; ignoring them is what keeps old extensions working.
|
|
14
|
+
const open = { open: true };
|
|
15
|
+
/** A versioned payload: data is any JSON value, schema names its shape. */
|
|
16
|
+
export const Payload = t.object({
|
|
17
|
+
schema: t.optional(t.string()),
|
|
18
|
+
data: t.optional(t.any()),
|
|
19
|
+
}, open);
|
|
20
|
+
export const Key = t.object({
|
|
21
|
+
source: t.string(),
|
|
22
|
+
external_id: t.string(),
|
|
23
|
+
}, open);
|
|
24
|
+
export const Event = t.object({
|
|
25
|
+
id: t.optional(t.string()),
|
|
26
|
+
type: t.string(),
|
|
27
|
+
source: t.optional(t.string()),
|
|
28
|
+
delivery_id: t.optional(t.string()),
|
|
29
|
+
occurred_at: t.optional(t.string()),
|
|
30
|
+
received_at: t.optional(t.string()),
|
|
31
|
+
correlation_key: t.optional(Key),
|
|
32
|
+
causation_id: t.optional(t.string()),
|
|
33
|
+
work_id: t.optional(t.string()),
|
|
34
|
+
execution_id: t.optional(t.string()),
|
|
35
|
+
data: t.optional(Payload),
|
|
36
|
+
// Who caused the Event, as kind:id, when the host knows. The host sets
|
|
37
|
+
// it; an Event an extension submits never carries one.
|
|
38
|
+
actor: t.optional(t.string()),
|
|
39
|
+
// The client the actor acted through, as kind:id, when a client
|
|
40
|
+
// credential acted for the actor (a person signed in to it).
|
|
41
|
+
via: t.optional(t.string()),
|
|
42
|
+
}, open);
|
|
43
|
+
export const AcceptedEvent = t.object({
|
|
44
|
+
event: Event,
|
|
45
|
+
sequence: t.integer(),
|
|
46
|
+
routed: t.boolean(),
|
|
47
|
+
routed_work_id: t.optional(t.string()),
|
|
48
|
+
disposition: t.optional(t.string()),
|
|
49
|
+
scope_id: t.optional(t.string()),
|
|
50
|
+
}, open);
|
|
51
|
+
export const DisplayLink = t.object({
|
|
52
|
+
label: t.string(),
|
|
53
|
+
url: t.string(),
|
|
54
|
+
}, open);
|
|
55
|
+
export const Display = t.object({
|
|
56
|
+
title: t.optional(t.string()),
|
|
57
|
+
ref: t.optional(t.string()),
|
|
58
|
+
requester: t.optional(t.string()),
|
|
59
|
+
links: t.optional(t.array(DisplayLink)),
|
|
60
|
+
}, open);
|
|
61
|
+
export const Work = t.object({
|
|
62
|
+
id: t.string(),
|
|
63
|
+
kind: t.string(),
|
|
64
|
+
scope_id: t.string(),
|
|
65
|
+
state: t.string(),
|
|
66
|
+
correlation_keys: t.nullable(t.array(Key)),
|
|
67
|
+
context: Payload,
|
|
68
|
+
parent_id: t.optional(t.string()),
|
|
69
|
+
display: t.optional(Display),
|
|
70
|
+
// The executor of the Work's latest attempt, when recorded.
|
|
71
|
+
latest_executor: t.optional(t.string()),
|
|
72
|
+
revision: t.integer(),
|
|
73
|
+
created_at: t.string(),
|
|
74
|
+
updated_at: t.string(),
|
|
75
|
+
}, open);
|
|
76
|
+
/** One Event for a Work that no attempt of it has read yet: queued, or accepted and not yet routed (unrouted). */
|
|
77
|
+
export const PendingInput = t.object({
|
|
78
|
+
event_id: t.string(),
|
|
79
|
+
sequence: t.integer(),
|
|
80
|
+
type: t.string(),
|
|
81
|
+
binding: t.optional(t.string()),
|
|
82
|
+
unrouted: t.optional(t.boolean()),
|
|
83
|
+
}, open);
|
|
84
|
+
export const LeaseRef = t.object({
|
|
85
|
+
execution_id: t.string(),
|
|
86
|
+
owner: t.string(),
|
|
87
|
+
epoch: t.integer(),
|
|
88
|
+
}, open);
|
|
89
|
+
/** The authority an operation call runs under: its scope, Work and grant. */
|
|
90
|
+
export const Authority = t.object({
|
|
91
|
+
scope_id: t.string(),
|
|
92
|
+
work_id: t.string(),
|
|
93
|
+
execution_id: t.string(),
|
|
94
|
+
lease: LeaseRef,
|
|
95
|
+
expires_at: t.string(),
|
|
96
|
+
operations: t.optional(t.array(t.string())),
|
|
97
|
+
event_types: t.optional(t.array(t.string())),
|
|
98
|
+
trigger_id: t.optional(t.string()),
|
|
99
|
+
// The connection the execution's binding names, whose secrets the operation may resolve.
|
|
100
|
+
connection: t.optional(t.string()),
|
|
101
|
+
// The kinds of child Work the execution may ask for, each with what to ask it for.
|
|
102
|
+
work_kinds: t.optional(t.array(t.object({ kind: t.string(), description: t.optional(t.string()) }, open))),
|
|
103
|
+
}, open);
|
|
104
|
+
// Lifecycle.
|
|
105
|
+
export const HostInfo = t.object({
|
|
106
|
+
name: t.string(),
|
|
107
|
+
version: t.string(),
|
|
108
|
+
}, open);
|
|
109
|
+
export const InitializeParams = t.object({
|
|
110
|
+
protocol_versions: t.nullable(t.array(t.integer())),
|
|
111
|
+
host: HostInfo,
|
|
112
|
+
state_dir: t.string(),
|
|
113
|
+
}, open);
|
|
114
|
+
export const InitializeResult = t.object({
|
|
115
|
+
protocol_version: t.integer(),
|
|
116
|
+
manifest: t.any(),
|
|
117
|
+
}, open);
|
|
118
|
+
export const ConnectionEntry = t.object({
|
|
119
|
+
id: t.string(),
|
|
120
|
+
type: t.string(),
|
|
121
|
+
config: t.optional(t.any()),
|
|
122
|
+
secrets: t.optional(t.array(t.string())),
|
|
123
|
+
}, open);
|
|
124
|
+
/** One configured scope entry of one of the extension's types. */
|
|
125
|
+
export const ConfigEntry = t.object({
|
|
126
|
+
scope_id: t.string(),
|
|
127
|
+
type: t.string(),
|
|
128
|
+
config: t.optional(t.any()),
|
|
129
|
+
secrets: t.optional(t.array(t.string())),
|
|
130
|
+
name: t.optional(t.string()),
|
|
131
|
+
connection: t.optional(ConnectionEntry),
|
|
132
|
+
binding_connections: t.optional(t.array(ConnectionEntry)),
|
|
133
|
+
}, open);
|
|
134
|
+
export const KVState = t.object({
|
|
135
|
+
stored: t.integer(),
|
|
136
|
+
declared: t.integer(),
|
|
137
|
+
}, open);
|
|
138
|
+
export const ConfigureParams = t.object({
|
|
139
|
+
generation: t.string(),
|
|
140
|
+
entries: t.optional(t.array(ConfigEntry)),
|
|
141
|
+
disabled: t.optional(t.array(ConfigEntry)),
|
|
142
|
+
public_url: t.optional(t.string()),
|
|
143
|
+
dry_run: t.optional(t.boolean()),
|
|
144
|
+
kv: KVState,
|
|
145
|
+
}, open);
|
|
146
|
+
export const ValidateParams = t.object({
|
|
147
|
+
kind: t.string(),
|
|
148
|
+
type: t.string(),
|
|
149
|
+
config: t.optional(t.any()),
|
|
150
|
+
secret_names: t.optional(t.array(t.string())),
|
|
151
|
+
}, open);
|
|
152
|
+
// Operations, tasks and checks.
|
|
153
|
+
export const OperationParams = t.object({
|
|
154
|
+
operation: t.string(),
|
|
155
|
+
authority: Authority,
|
|
156
|
+
input: Payload,
|
|
157
|
+
request_id: t.optional(t.string()),
|
|
158
|
+
}, open);
|
|
159
|
+
export const OperationResult = t.object({
|
|
160
|
+
output: Payload,
|
|
161
|
+
}, open);
|
|
162
|
+
export const TaskRunParams = t.object({
|
|
163
|
+
task: t.string(),
|
|
164
|
+
}, open);
|
|
165
|
+
export const CheckRunParams = t.object({
|
|
166
|
+
check: t.string(),
|
|
167
|
+
deep: t.optional(t.boolean()),
|
|
168
|
+
config: t.any(),
|
|
169
|
+
}, open);
|
|
170
|
+
export const CheckRunResult = t.object({
|
|
171
|
+
ok: t.boolean(),
|
|
172
|
+
detail: t.optional(t.string()),
|
|
173
|
+
status: t.optional(t.string()),
|
|
174
|
+
code: t.optional(t.string()),
|
|
175
|
+
items: t.optional(t.array(t.string())),
|
|
176
|
+
}, open);
|
|
177
|
+
// Extension-to-host calls.
|
|
178
|
+
export const KVGetParams = t.object({
|
|
179
|
+
namespace: t.string(),
|
|
180
|
+
key: t.string(),
|
|
181
|
+
}, open);
|
|
182
|
+
export const KVEntry = t.object({
|
|
183
|
+
key: t.string(),
|
|
184
|
+
value: t.nullable(t.string()),
|
|
185
|
+
version: t.string(),
|
|
186
|
+
}, open);
|
|
187
|
+
export const KVGetResult = t.object({
|
|
188
|
+
found: t.boolean(),
|
|
189
|
+
entry: KVEntry,
|
|
190
|
+
}, open);
|
|
191
|
+
export const KVListParams = t.object({
|
|
192
|
+
namespace: t.string(),
|
|
193
|
+
prefix: t.optional(t.string()),
|
|
194
|
+
}, open);
|
|
195
|
+
export const KVListResult = t.object({
|
|
196
|
+
entries: t.nullable(t.array(KVEntry)),
|
|
197
|
+
}, open);
|
|
198
|
+
/** A precondition: the key holds version, or is absent. */
|
|
199
|
+
export const KVCheck = t.object({
|
|
200
|
+
namespace: t.string(),
|
|
201
|
+
key: t.string(),
|
|
202
|
+
version: t.optional(t.string()),
|
|
203
|
+
absent: t.optional(t.boolean()),
|
|
204
|
+
}, open);
|
|
205
|
+
export const KVPut = t.object({
|
|
206
|
+
namespace: t.string(),
|
|
207
|
+
key: t.string(),
|
|
208
|
+
value: t.string(),
|
|
209
|
+
}, open);
|
|
210
|
+
export const KVDelete = t.object({
|
|
211
|
+
namespace: t.string(),
|
|
212
|
+
key: t.string(),
|
|
213
|
+
}, open);
|
|
214
|
+
export const KVCommitParams = t.object({
|
|
215
|
+
checks: t.optional(t.array(KVCheck)),
|
|
216
|
+
puts: t.optional(t.array(KVPut)),
|
|
217
|
+
deletes: t.optional(t.array(KVDelete)),
|
|
218
|
+
}, open);
|
|
219
|
+
/** A Work's position in a state.works order: the next page starts after it. */
|
|
220
|
+
export const WorkCursor = t.object({
|
|
221
|
+
at: t.string(),
|
|
222
|
+
id: t.string(),
|
|
223
|
+
}, open);
|
|
224
|
+
export const StateParams = t.object({
|
|
225
|
+
id: t.optional(t.string()),
|
|
226
|
+
scope_id: t.optional(t.string()),
|
|
227
|
+
after: t.optional(t.integer()),
|
|
228
|
+
limit: t.optional(t.integer()),
|
|
229
|
+
states: t.optional(t.array(t.string())),
|
|
230
|
+
kind: t.optional(t.string()),
|
|
231
|
+
parent_id: t.optional(t.string()),
|
|
232
|
+
sources: t.optional(t.array(t.string())),
|
|
233
|
+
executor: t.optional(t.string()),
|
|
234
|
+
correlation: t.optional(Key),
|
|
235
|
+
updated_since: t.optional(t.string()),
|
|
236
|
+
order: t.optional(t.string()),
|
|
237
|
+
cursor: t.optional(WorkCursor),
|
|
238
|
+
source: t.optional(t.string()),
|
|
239
|
+
delivery_id: t.optional(t.string()),
|
|
240
|
+
}, open);
|
|
241
|
+
export const EventAcceptParams = t.object({
|
|
242
|
+
scope_id: t.string(),
|
|
243
|
+
parent: t.string(),
|
|
244
|
+
event: Event,
|
|
245
|
+
checks: t.optional(t.array(KVCheck)),
|
|
246
|
+
records: t.optional(t.array(KVPut)),
|
|
247
|
+
deletes: t.optional(t.array(KVDelete)),
|
|
248
|
+
}, open);
|
|
249
|
+
export const EventAcceptResult = t.object({
|
|
250
|
+
event: AcceptedEvent,
|
|
251
|
+
// False when the host already had this Event: accepting is idempotent.
|
|
252
|
+
added: t.boolean(),
|
|
253
|
+
}, open);
|
|
254
|
+
export const SecretResolveParams = t.object({
|
|
255
|
+
scope_id: t.string(),
|
|
256
|
+
connection: t.optional(t.string()),
|
|
257
|
+
names: t.array(t.string()),
|
|
258
|
+
}, open);
|
|
259
|
+
export const SecretResolveResult = t.object({
|
|
260
|
+
values: t.nullable(t.record(t.string())),
|
|
261
|
+
}, open);
|
|
262
|
+
export const ArtifactCreateParams = t.object({
|
|
263
|
+
media_type: t.string(),
|
|
264
|
+
}, open);
|
|
265
|
+
export const ArtifactCreateResult = t.object({
|
|
266
|
+
writer: t.string(),
|
|
267
|
+
}, open);
|
|
268
|
+
export const ArtifactWriteParams = t.object({
|
|
269
|
+
writer: t.string(),
|
|
270
|
+
chunk: t.string(),
|
|
271
|
+
}, open);
|
|
272
|
+
export const ArtifactTarget = t.object({
|
|
273
|
+
writer: t.string(),
|
|
274
|
+
}, open);
|
|
275
|
+
export const ArtifactRef = t.object({
|
|
276
|
+
id: t.string(),
|
|
277
|
+
size: t.integer(),
|
|
278
|
+
media_type: t.optional(t.string()),
|
|
279
|
+
// The content's SHA-256; return the ref artifact.commit gave unchanged.
|
|
280
|
+
sha256: t.optional(t.string()),
|
|
281
|
+
}, open);
|
|
282
|
+
// Ingress: sources, deliveries, push and reconcile (protocol.Source and on).
|
|
283
|
+
/** A source's namespace (its correlation keys' source) in a scope. */
|
|
284
|
+
export const Source = t.object({
|
|
285
|
+
namespace: t.string(),
|
|
286
|
+
scope_id: t.string(),
|
|
287
|
+
}, open);
|
|
288
|
+
/** One delivery of a push (a webhook's body); body is base64. */
|
|
289
|
+
export const Delivery = t.object({
|
|
290
|
+
id: t.string(),
|
|
291
|
+
received_at: t.string(),
|
|
292
|
+
content_type: t.optional(t.string()),
|
|
293
|
+
body: t.optional(t.string()),
|
|
294
|
+
}, open);
|
|
295
|
+
export const EventFamily = t.object({
|
|
296
|
+
type: t.string(),
|
|
297
|
+
re_derivable: t.boolean(),
|
|
298
|
+
loss: t.optional(t.string()),
|
|
299
|
+
}, open);
|
|
300
|
+
/** What a source holds of one object now: its ID, version and the Event it maps to. */
|
|
301
|
+
export const Observation = t.object({
|
|
302
|
+
id: t.string(),
|
|
303
|
+
version: t.string(),
|
|
304
|
+
event: Event,
|
|
305
|
+
}, open);
|
|
306
|
+
export const PushResult = t.object({
|
|
307
|
+
observations: t.optional(t.array(Observation)),
|
|
308
|
+
// Only for families declared not re-derivable.
|
|
309
|
+
events: t.optional(t.array(Event)),
|
|
310
|
+
}, open);
|
|
311
|
+
export const Scan = t.object({
|
|
312
|
+
source: Source,
|
|
313
|
+
scan_id: t.optional(t.string()),
|
|
314
|
+
cursor: t.optional(t.string()),
|
|
315
|
+
checkpoint: t.optional(t.string()),
|
|
316
|
+
}, open);
|
|
317
|
+
/**
|
|
318
|
+
* One page of a reconcile. complete certifies the scan covered the whole
|
|
319
|
+
* source across its pages; false with no next_cursor is a partial scan,
|
|
320
|
+
* never proof that anything is gone.
|
|
321
|
+
*/
|
|
322
|
+
export const Snapshot = t.object({
|
|
323
|
+
scan_id: t.string(),
|
|
324
|
+
observations: t.optional(t.array(Observation)),
|
|
325
|
+
next_cursor: t.optional(t.string()),
|
|
326
|
+
complete: t.boolean(),
|
|
327
|
+
checkpoint: t.optional(t.string()),
|
|
328
|
+
}, open);
|
|
329
|
+
/** A source an entry registers at configure. */
|
|
330
|
+
export const SourceDecl = t.object({
|
|
331
|
+
name: t.string(),
|
|
332
|
+
source: Source,
|
|
333
|
+
interval_seconds: t.integer(),
|
|
334
|
+
families: t.array(EventFamily),
|
|
335
|
+
}, open);
|
|
336
|
+
export const ConfigureResult = t.object({
|
|
337
|
+
sources: t.optional(t.array(SourceDecl)),
|
|
338
|
+
// Each under /<name>/; a path covers the paths beneath it.
|
|
339
|
+
webhook_paths: t.optional(t.array(t.string())),
|
|
340
|
+
kv_version: t.integer(),
|
|
341
|
+
}, open);
|
|
342
|
+
export const IngressPushParams = t.object({
|
|
343
|
+
name: t.string(),
|
|
344
|
+
source: Source,
|
|
345
|
+
delivery: Delivery,
|
|
346
|
+
}, open);
|
|
347
|
+
export const IngressReconcileParams = t.object({
|
|
348
|
+
name: t.string(),
|
|
349
|
+
scan: Scan,
|
|
350
|
+
}, open);
|
|
351
|
+
export const IngressDeliverParams = t.object({
|
|
352
|
+
name: t.string(),
|
|
353
|
+
delivery: Delivery,
|
|
354
|
+
}, open);
|
|
355
|
+
/** A delivery's accepted Events; added[i] is false for one already accepted (a retry). */
|
|
356
|
+
export const IngressDeliverResult = t.object({
|
|
357
|
+
accepted: t.nullable(t.array(AcceptedEvent)),
|
|
358
|
+
added: t.nullable(t.array(t.boolean())),
|
|
359
|
+
}, open);
|
|
360
|
+
/** One HTTP request on a webhook path the extension registered; body is base64. */
|
|
361
|
+
export const WebhookHandleParams = t.object({
|
|
362
|
+
path: t.string(),
|
|
363
|
+
method: t.string(),
|
|
364
|
+
query: t.optional(t.string()),
|
|
365
|
+
header: t.optional(t.record(t.array(t.string()))),
|
|
366
|
+
body: t.optional(t.string()),
|
|
367
|
+
received_at: t.string(),
|
|
368
|
+
forward_id: t.optional(t.string()),
|
|
369
|
+
}, open);
|
|
370
|
+
export const WebhookHandleResult = t.object({
|
|
371
|
+
status: t.integer(),
|
|
372
|
+
header: t.optional(t.record(t.array(t.string()))),
|
|
373
|
+
body: t.optional(t.string()),
|
|
374
|
+
}, open);
|
|
375
|
+
// Routing.
|
|
376
|
+
export const Route = t.object({
|
|
377
|
+
name: t.string(),
|
|
378
|
+
handler: t.string(),
|
|
379
|
+
binding: t.string(),
|
|
380
|
+
active_policy: t.optional(t.string()),
|
|
381
|
+
config: Payload,
|
|
382
|
+
}, open);
|
|
383
|
+
/** A scope as an extension sees it: never its secret references. */
|
|
384
|
+
export const Scope = t.object({
|
|
385
|
+
id: t.string(),
|
|
386
|
+
name: t.string(),
|
|
387
|
+
parent_id: t.optional(t.string()),
|
|
388
|
+
bindings: t.optional(t.array(t.any())),
|
|
389
|
+
routes: t.optional(t.array(Route)),
|
|
390
|
+
config: Payload,
|
|
391
|
+
revision: t.integer(),
|
|
392
|
+
created_at: t.string(),
|
|
393
|
+
updated_at: t.string(),
|
|
394
|
+
}, open);
|
|
395
|
+
export const RouteInput = t.object({
|
|
396
|
+
event: AcceptedEvent,
|
|
397
|
+
scope: Scope,
|
|
398
|
+
work: t.optional(Work),
|
|
399
|
+
route: Route,
|
|
400
|
+
}, open);
|
|
401
|
+
/**
|
|
402
|
+
* A route's answer for one Event. On a match with no work, create_id and
|
|
403
|
+
* kind open new Work; attach_keys add correlation keys to it; display
|
|
404
|
+
* replaces what the Work shows. deliver is absent to queue the Event on
|
|
405
|
+
* the route's binding, "none" to only attach, "current" to queue it on the
|
|
406
|
+
* binding the Work runs on.
|
|
407
|
+
*/
|
|
408
|
+
export const RouteDecision = t.object({
|
|
409
|
+
match: t.boolean(),
|
|
410
|
+
create_id: t.optional(t.string()),
|
|
411
|
+
kind: t.optional(t.string()),
|
|
412
|
+
attach_keys: t.optional(t.array(Key)),
|
|
413
|
+
reason: t.optional(t.string()),
|
|
414
|
+
display: t.optional(Display),
|
|
415
|
+
context: t.optional(Payload),
|
|
416
|
+
grants: t.optional(t.array(t.string())),
|
|
417
|
+
successor: t.optional(t.boolean()),
|
|
418
|
+
deliver: t.optional(t.string()),
|
|
419
|
+
}, open);
|
|
420
|
+
/** A sample Event a route handler offers for a route trace (routes.decisions). */
|
|
421
|
+
export const RouteSample = t.object({
|
|
422
|
+
id: t.string(),
|
|
423
|
+
title: t.string(),
|
|
424
|
+
event: Event,
|
|
425
|
+
}, open);
|
|
426
|
+
export const RouteMatchParams = t.object({
|
|
427
|
+
handler: t.string(),
|
|
428
|
+
input: RouteInput,
|
|
429
|
+
}, open);
|
|
430
|
+
export const RouteSamplesParams = t.object({
|
|
431
|
+
handler: t.string(),
|
|
432
|
+
scope: Scope,
|
|
433
|
+
route: Route,
|
|
434
|
+
now: t.string(),
|
|
435
|
+
}, open);
|
|
436
|
+
export const RouteSamplesResult = t.object({
|
|
437
|
+
samples: t.array(RouteSample),
|
|
438
|
+
}, open);
|
|
439
|
+
export const WorkKindTriggerParams = t.object({
|
|
440
|
+
kind: t.string(),
|
|
441
|
+
inputs: t.nullable(t.array(Event)),
|
|
442
|
+
}, open);
|
|
443
|
+
export const WorkKindTriggerResult = t.object({
|
|
444
|
+
index: t.integer(),
|
|
445
|
+
}, open);
|
|
446
|
+
// Wait and emit operations.
|
|
447
|
+
/**
|
|
448
|
+
* What a wait suspends the Work until: an Event of one of types (any, when
|
|
449
|
+
* empty) on one of keys (every key the Work owns, when empty), or timeout.
|
|
450
|
+
*/
|
|
451
|
+
export const WaitRequest = t.object({
|
|
452
|
+
keys: t.optional(t.array(Key)),
|
|
453
|
+
types: t.optional(t.array(t.string())),
|
|
454
|
+
timeout: t.optional(t.string()),
|
|
455
|
+
after_sequence: t.optional(t.integer()),
|
|
456
|
+
description: t.optional(t.string()),
|
|
457
|
+
}, open);
|
|
458
|
+
/**
|
|
459
|
+
* A subscription to Events on another key (another Work's, or one no Work
|
|
460
|
+
* owns yet), aliased into the waiting Work as alias_type Events.
|
|
461
|
+
*/
|
|
462
|
+
export const Dependency = t.object({
|
|
463
|
+
id: t.string(),
|
|
464
|
+
source_scope_id: t.optional(t.string()),
|
|
465
|
+
source_key: Key,
|
|
466
|
+
types: t.optional(t.array(t.string())),
|
|
467
|
+
alias_type: t.string(),
|
|
468
|
+
filter: Payload,
|
|
469
|
+
label: t.optional(t.string()),
|
|
470
|
+
from_now: t.optional(t.boolean()),
|
|
471
|
+
}, open);
|
|
472
|
+
export const WaitPlan = t.object({
|
|
473
|
+
wait: WaitRequest,
|
|
474
|
+
dependencies: t.optional(t.array(Dependency)),
|
|
475
|
+
output: Payload,
|
|
476
|
+
}, open);
|
|
477
|
+
export const EmitPlan = t.object({
|
|
478
|
+
event: Event,
|
|
479
|
+
cause: t.optional(t.string()),
|
|
480
|
+
once: t.optional(t.string()),
|
|
481
|
+
commit_id: t.optional(t.string()),
|
|
482
|
+
}, open);
|
|
483
|
+
/** The Event an emission accepted, as its commit receives it. */
|
|
484
|
+
export const Emitted = t.object({
|
|
485
|
+
event: AcceptedEvent,
|
|
486
|
+
added: t.boolean(),
|
|
487
|
+
root: t.string(),
|
|
488
|
+
depth: t.integer(),
|
|
489
|
+
}, open);
|
|
490
|
+
/** A KV write an emission's commit makes; value is base64. */
|
|
491
|
+
export const EmitRecord = t.object({
|
|
492
|
+
namespace: t.string(),
|
|
493
|
+
key: t.string(),
|
|
494
|
+
value: t.string(),
|
|
495
|
+
}, open);
|
|
496
|
+
export const EmitCommit = t.object({
|
|
497
|
+
records: t.optional(t.array(EmitRecord)),
|
|
498
|
+
output: Payload,
|
|
499
|
+
}, open);
|
|
500
|
+
export const EmitCommitParams = t.object({
|
|
501
|
+
commit_id: t.string(),
|
|
502
|
+
emitted: Emitted,
|
|
503
|
+
}, open);
|
|
504
|
+
// The manifest (open-conduit-extension.json): the fields this SDK writes.
|
|
505
|
+
export const Family = t.object({
|
|
506
|
+
type: t.string(),
|
|
507
|
+
// Whether a lost Event can be derived again, which tells the host how to recover.
|
|
508
|
+
re_derivable: t.boolean(),
|
|
509
|
+
loss: t.optional(t.string()),
|
|
510
|
+
// Only the extension's own emit operations may emit it; the builtin emit refuses it.
|
|
511
|
+
sealed: t.optional(t.boolean()),
|
|
512
|
+
}, open);
|
|
513
|
+
/** A payload schema the extension writes and reads: the versions it reads, the highest being the one it writes. */
|
|
514
|
+
export const SchemaDecl = t.object({
|
|
515
|
+
name: t.string(),
|
|
516
|
+
versions: t.array(t.integer()),
|
|
517
|
+
}, open);
|
|
518
|
+
export const ExtensionDecl = t.object({
|
|
519
|
+
type: t.string(),
|
|
520
|
+
// The entry registers ingress sources at configure.
|
|
521
|
+
ingress: t.optional(t.boolean()),
|
|
522
|
+
}, open);
|
|
523
|
+
export const OperationDecl = t.object({
|
|
524
|
+
name: t.string(),
|
|
525
|
+
kind: t.enum(["handler", "wait", "emit"]),
|
|
526
|
+
commit: t.optional(t.boolean()),
|
|
527
|
+
summary: t.optional(t.string()),
|
|
528
|
+
guidance: t.optional(t.string()),
|
|
529
|
+
input: t.optional(t.record(t.any())),
|
|
530
|
+
wants: t.optional(t.string()),
|
|
531
|
+
serves: t.optional(t.string()),
|
|
532
|
+
}, open);
|
|
533
|
+
export const RouteDecl = t.object({
|
|
534
|
+
handler: t.string(),
|
|
535
|
+
// Its routes carry config, checked through validate with kind route.
|
|
536
|
+
config: t.optional(t.boolean()),
|
|
537
|
+
// It offers sample Events for a route trace through route.samples.
|
|
538
|
+
samples: t.optional(t.boolean()),
|
|
539
|
+
}, open);
|
|
540
|
+
export const WorkKindDecl = t.object({
|
|
541
|
+
kind: t.string(),
|
|
542
|
+
standing: t.optional(t.boolean()),
|
|
543
|
+
trigger: t.optional(t.boolean()),
|
|
544
|
+
timed: t.optional(t.boolean()),
|
|
545
|
+
run_once: t.optional(t.boolean()),
|
|
546
|
+
}, open);
|
|
547
|
+
export const ToolsetOperation = t.object({
|
|
548
|
+
name: t.string(),
|
|
549
|
+
// The toolset version the operation joined in (1 when left out).
|
|
550
|
+
since: t.optional(t.integer()),
|
|
551
|
+
}, open);
|
|
552
|
+
// A toolset config grants as "@<name>": the operations (the extension's own
|
|
553
|
+
// or builtins) an agent playing one of its roles is given.
|
|
554
|
+
export const ToolsetDecl = t.object({
|
|
555
|
+
name: t.string(),
|
|
556
|
+
summary: t.optional(t.string()),
|
|
557
|
+
operations: t.array(ToolsetOperation),
|
|
558
|
+
}, open);
|
|
559
|
+
export const TaskDecl = t.object({
|
|
560
|
+
name: t.string(),
|
|
561
|
+
interval_seconds: t.integer(),
|
|
562
|
+
}, open);
|
|
563
|
+
export const CheckDecl = t.object({
|
|
564
|
+
name: t.string(),
|
|
565
|
+
// Deep checks run only on doctor --deep, so they may be slow or call out.
|
|
566
|
+
deep: t.optional(t.boolean()),
|
|
567
|
+
}, open);
|
|
568
|
+
export const Provides = t.object({
|
|
569
|
+
extensions: t.optional(t.array(ExtensionDecl)),
|
|
570
|
+
families: t.optional(t.array(Family)),
|
|
571
|
+
schemas: t.optional(t.array(SchemaDecl)),
|
|
572
|
+
routes: t.optional(t.array(RouteDecl)),
|
|
573
|
+
work_kinds: t.optional(t.array(WorkKindDecl)),
|
|
574
|
+
operations: t.optional(t.array(OperationDecl)),
|
|
575
|
+
toolsets: t.optional(t.array(ToolsetDecl)),
|
|
576
|
+
tasks: t.optional(t.array(TaskDecl)),
|
|
577
|
+
webhooks: t.optional(t.boolean()),
|
|
578
|
+
webhook_max_bytes: t.optional(t.integer()),
|
|
579
|
+
checks: t.optional(t.array(CheckDecl)),
|
|
580
|
+
// A directory, relative to the manifest, of prompt material the host offers agent executors.
|
|
581
|
+
playbooks: t.optional(t.string()),
|
|
582
|
+
}, open);
|
|
583
|
+
export const Manifest = t.object({
|
|
584
|
+
protocol: t.array(t.integer()),
|
|
585
|
+
name: t.string(),
|
|
586
|
+
version: t.string(),
|
|
587
|
+
title: t.optional(t.string()),
|
|
588
|
+
summary: t.optional(t.string()),
|
|
589
|
+
command: t.array(t.string()),
|
|
590
|
+
kv_version: t.optional(t.integer()),
|
|
591
|
+
permissions: t.optional(t.array(t.string())),
|
|
592
|
+
provides: Provides,
|
|
593
|
+
}, open);
|
|
594
|
+
export const OperationCase = t.object({
|
|
595
|
+
operation: t.string(),
|
|
596
|
+
input: Payload,
|
|
597
|
+
output: t.optional(Payload),
|
|
598
|
+
// The refusal code expected instead of an output.
|
|
599
|
+
error: t.optional(t.string()),
|
|
600
|
+
}, open);
|
|
601
|
+
export const Fixture = t.object({
|
|
602
|
+
entries: t.optional(t.array(ConfigEntry)),
|
|
603
|
+
secrets: t.optional(t.record(t.string())),
|
|
604
|
+
scopes: t.optional(t.array(t.string())),
|
|
605
|
+
operations: t.optional(t.array(OperationCase)),
|
|
606
|
+
}, open);
|
|
607
|
+
/** A package's certification.json: the fixture `extension certify` runs. */
|
|
608
|
+
export const CertificationFile = t.object({
|
|
609
|
+
fixture: t.optional(Fixture),
|
|
610
|
+
command: t.optional(t.array(t.string())),
|
|
611
|
+
}, open);
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@open-conduit/sdk",
|
|
3
|
+
"version": "0.0.0-bootstrap.0",
|
|
4
|
+
"description": "Build Open Conduit extensions in TypeScript: serve protocol version 1, call the host, declare each operation once.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/open-conduit/open-conduit.git",
|
|
9
|
+
"directory": "sdk/typescript"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=22.18"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./testing": {
|
|
21
|
+
"types": "./dist/testing.d.ts",
|
|
22
|
+
"default": "./dist/testing.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
}
|
|
31
|
+
}
|