@open-conduit/sdk 0.0.0-bootstrap.0 → 0.0.0-stage
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/README.md +2 -12
- package/package.json +4 -29
- package/LICENSE +0 -21
- package/dist/errors.d.ts +0 -98
- package/dist/errors.js +0 -142
- package/dist/extension.d.ts +0 -356
- package/dist/extension.js +0 -674
- package/dist/host.d.ts +0 -129
- package/dist/host.js +0 -249
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -19
- package/dist/jsonrpc.d.ts +0 -31
- package/dist/jsonrpc.js +0 -316
- package/dist/schema.d.ts +0 -71
- package/dist/schema.js +0 -252
- package/dist/testing.d.ts +0 -167
- package/dist/testing.js +0 -711
- package/dist/wire.d.ts +0 -1621
- package/dist/wire.js +0 -611
package/dist/host.d.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { type Infer, type Type } from "./schema.js";
|
|
2
|
-
import { AcceptedEvent, ArtifactRef, type Event, EventAcceptResult, type KVCheck, type KVDelete, PendingInput, Work } from "./wire.js";
|
|
3
|
-
/** The most Work one state.works page holds (protocol.MaxWorksPage). */
|
|
4
|
-
export declare const MaxWorksPage = 1000;
|
|
5
|
-
/**
|
|
6
|
-
* What a state.works read selects (storage.WorkQuery): Work in any of
|
|
7
|
-
* `states`, of `scopeId`, `kind`, `parentId`, any of `sources` and
|
|
8
|
-
* `executor`, updated at or after `updatedSince` (an RFC 3339 time).
|
|
9
|
-
* `order` is "created", "-created", "updated" or "-updated".
|
|
10
|
-
*/
|
|
11
|
-
export interface WorksQuery {
|
|
12
|
-
scopeId?: string;
|
|
13
|
-
states?: string[];
|
|
14
|
-
kind?: string;
|
|
15
|
-
parentId?: string;
|
|
16
|
-
sources?: string[];
|
|
17
|
-
executor?: string;
|
|
18
|
-
updatedSince?: string;
|
|
19
|
-
order?: "created" | "-created" | "updated" | "-updated";
|
|
20
|
-
limit?: number;
|
|
21
|
-
}
|
|
22
|
-
/** Makes one extension-to-host call; the result is decoded by the caller. */
|
|
23
|
-
export type Caller = (method: string, params: unknown, signal?: AbortSignal) => Promise<unknown>;
|
|
24
|
-
/** A KV value: bytes, or a string stored as its UTF-8 bytes. */
|
|
25
|
-
export type Value = Uint8Array | string;
|
|
26
|
-
/** A KV entry and its version, which a later commit can require unchanged. */
|
|
27
|
-
export interface Entry {
|
|
28
|
-
key: string;
|
|
29
|
-
value: Uint8Array;
|
|
30
|
-
version: string;
|
|
31
|
-
}
|
|
32
|
-
export interface Put {
|
|
33
|
-
namespace: string;
|
|
34
|
-
key: string;
|
|
35
|
-
value: Value;
|
|
36
|
-
}
|
|
37
|
-
/** A precondition batch, applied atomically: a failed check changes nothing. */
|
|
38
|
-
export interface Batch {
|
|
39
|
-
checks?: KVCheck[];
|
|
40
|
-
puts?: Put[];
|
|
41
|
-
deletes?: KVDelete[];
|
|
42
|
-
}
|
|
43
|
-
/** A delivery to push to a source: a webhook's body, say. */
|
|
44
|
-
export interface DeliveryInput {
|
|
45
|
-
/** The sender's delivery ID: a retry carries the same one. */
|
|
46
|
-
id: string;
|
|
47
|
-
/** When it was received (default now). */
|
|
48
|
-
receivedAt?: string;
|
|
49
|
-
contentType?: string;
|
|
50
|
-
body?: Value;
|
|
51
|
-
}
|
|
52
|
-
/** One Event derived from parent, committed atomically with the batch. */
|
|
53
|
-
export interface Accept extends Batch {
|
|
54
|
-
scopeId: string;
|
|
55
|
-
parent: string;
|
|
56
|
-
event: Event;
|
|
57
|
-
}
|
|
58
|
-
export declare class Host {
|
|
59
|
-
#private;
|
|
60
|
-
constructor(call: Caller);
|
|
61
|
-
/** Makes any extension-to-host call, decoding its result through result. */
|
|
62
|
-
call<S extends Type<unknown>>(method: string, params: unknown, result: S, signal?: AbortSignal): Promise<Infer<S>>;
|
|
63
|
-
/** A KV value and its version, or undefined when the key is absent. */
|
|
64
|
-
get(namespace: string, key: string, signal?: AbortSignal): Promise<Entry | undefined>;
|
|
65
|
-
/** The entries under prefix, in lexical key order. */
|
|
66
|
-
list(namespace: string, prefix?: string, signal?: AbortSignal): Promise<Entry[]>;
|
|
67
|
-
/** Applies a batch atomically; a failed check throws ProtocolError conflict. */
|
|
68
|
-
commit(b: Batch, signal?: AbortSignal): Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* Reads a key, applies fn and commits with a version check, retrying when
|
|
71
|
-
* another writer got there first. fn returns undefined to delete the key.
|
|
72
|
-
*/
|
|
73
|
-
update(namespace: string, key: string, fn: (old: Uint8Array | undefined) => Value | undefined | Promise<Value | undefined>, signal?: AbortSignal): Promise<void>;
|
|
74
|
-
/**
|
|
75
|
-
* Derives one Event from parent (an accepted Event in a configured scope),
|
|
76
|
-
* committing the batch's KV writes atomically with it.
|
|
77
|
-
*/
|
|
78
|
-
accept(a: Accept, signal?: AbortSignal): Promise<EventAcceptResult>;
|
|
79
|
-
/**
|
|
80
|
-
* Hands a delivery (a verified webhook's body) to the source registered
|
|
81
|
-
* as name. The host calls the source's push with it and answers once its
|
|
82
|
-
* Events are durably accepted: added[i] is false for an Event it already
|
|
83
|
-
* had, such as a sender's retry.
|
|
84
|
-
*/
|
|
85
|
-
deliver(name: string, delivery: DeliveryInput, signal?: AbortSignal): Promise<{
|
|
86
|
-
accepted: AcceptedEvent[];
|
|
87
|
-
added: boolean[];
|
|
88
|
-
}>;
|
|
89
|
-
/** Accepted Events of the configured scopes after a sequence. */
|
|
90
|
-
events(after?: number, limit?: number, signal?: AbortSignal): Promise<AcceptedEvent[]>;
|
|
91
|
-
/**
|
|
92
|
-
* One Work's accepted Events of the configured scopes after a sequence:
|
|
93
|
-
* those naming it and those routed to it. The host reads them from its
|
|
94
|
-
* index, so the cost follows the Work's own Events, not the whole log.
|
|
95
|
-
*/
|
|
96
|
-
workEvents(workId: string, after?: number, limit?: number, signal?: AbortSignal): Promise<AcceptedEvent[]>;
|
|
97
|
-
/** Work of the configured scopes (one scope when scopeId is set). */
|
|
98
|
-
works(scopeId?: string, signal?: AbortSignal): Promise<Work[]>;
|
|
99
|
-
/**
|
|
100
|
-
* The Work a query selects, of the configured scopes and the extension's
|
|
101
|
-
* own kinds, in its order (by creation unless `order` says otherwise),
|
|
102
|
-
* at most `limit` (all when unset). The host reads them through its
|
|
103
|
-
* indexes a page at a time, so the cost follows the Work selected, not
|
|
104
|
-
* every Work ever made: ask for live Work with `states`, or for Work
|
|
105
|
-
* changed since a time with `updatedSince`.
|
|
106
|
-
*/
|
|
107
|
-
queryWorks(query: WorksQuery, signal?: AbortSignal): Promise<Work[]>;
|
|
108
|
-
/**
|
|
109
|
-
* The input routed to a Work that no attempt of it has read yet, oldest
|
|
110
|
-
* first. Ready Work with none has read everything routed to it; ready
|
|
111
|
-
* Work with some is about to start on it.
|
|
112
|
-
*/
|
|
113
|
-
pending(workId: string, signal?: AbortSignal): Promise<PendingInput[]>;
|
|
114
|
-
/** Resolves secret names bound to the extension's entry in a scope. */
|
|
115
|
-
secrets(scopeId: string, names: string[], signal?: AbortSignal): Promise<Record<string, string>>;
|
|
116
|
-
/**
|
|
117
|
-
* Resolves secret names of a connection an entry or binding in the scope
|
|
118
|
-
* names, such as an operation's authority.connection.
|
|
119
|
-
*/
|
|
120
|
-
connectionSecrets(scopeId: string, connection: string, names: string[], signal?: AbortSignal): Promise<Record<string, string>>;
|
|
121
|
-
/** Writes an immutable artifact in chunks, each acknowledged before the next. */
|
|
122
|
-
artifact(mediaType: string, data: Value, signal?: AbortSignal): Promise<ArtifactRef>;
|
|
123
|
-
/** Sets the progress line of a Work's active Wait ("" clears it). */
|
|
124
|
-
waitProgress(workId: string, progress: string, signal?: AbortSignal): Promise<void>;
|
|
125
|
-
}
|
|
126
|
-
export declare function toBytes(v: Value): Uint8Array;
|
|
127
|
-
export declare function base64(b: Uint8Array): string;
|
|
128
|
-
/** Decodes a KV value as UTF-8 text. */
|
|
129
|
-
export declare function text(v: Uint8Array): string;
|
package/dist/host.js
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
// The extension's client for the scoped extension-to-host methods, as
|
|
2
|
-
// protocol/sdk/host.go offers them. The host binds every call to the
|
|
3
|
-
// identity it started the process with, so nothing here can name another
|
|
4
|
-
// extension's namespaces or scopes.
|
|
5
|
-
import { Code, ProtocolError } from "./errors.js";
|
|
6
|
-
import { MaxChunkBytes } from "./jsonrpc.js";
|
|
7
|
-
import { matches, t } from "./schema.js";
|
|
8
|
-
import { AcceptedEvent, ArtifactCreateResult, ArtifactRef, EventAcceptResult, IngressDeliverResult, KVGetResult, KVListResult, PendingInput, SecretResolveResult, Work, } from "./wire.js";
|
|
9
|
-
/** The most Work one state.works page holds (protocol.MaxWorksPage). */
|
|
10
|
-
export const MaxWorksPage = 1000;
|
|
11
|
-
const Empty = t.any();
|
|
12
|
-
export class Host {
|
|
13
|
-
#call;
|
|
14
|
-
constructor(call) {
|
|
15
|
-
this.#call = call;
|
|
16
|
-
}
|
|
17
|
-
/** Makes any extension-to-host call, decoding its result through result. */
|
|
18
|
-
async call(method, params, result, signal) {
|
|
19
|
-
const out = await this.#call(method, params, signal);
|
|
20
|
-
// A result that doesn't match is refused, as the Go SDK's decoding refuses it.
|
|
21
|
-
if (!matches(result, out))
|
|
22
|
-
throw new ProtocolError(Code.Invalid, `malformed ${method} result`);
|
|
23
|
-
return out;
|
|
24
|
-
}
|
|
25
|
-
/** A KV value and its version, or undefined when the key is absent. */
|
|
26
|
-
async get(namespace, key, signal) {
|
|
27
|
-
const out = await this.call("kv.get", { namespace, key }, KVGetResult, signal);
|
|
28
|
-
return out.found ? entry(out.entry) : undefined;
|
|
29
|
-
}
|
|
30
|
-
/** The entries under prefix, in lexical key order. */
|
|
31
|
-
async list(namespace, prefix = "", signal) {
|
|
32
|
-
const out = await this.call("kv.list", prefix === "" ? { namespace } : { namespace, prefix }, KVListResult, signal);
|
|
33
|
-
return (out.entries ?? []).map(entry);
|
|
34
|
-
}
|
|
35
|
-
/** Applies a batch atomically; a failed check throws ProtocolError conflict. */
|
|
36
|
-
async commit(b, signal) {
|
|
37
|
-
const { puts, ...rest } = batchFields(b);
|
|
38
|
-
await this.call("kv.commit", puts === undefined ? rest : { ...rest, puts }, Empty, signal);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Reads a key, applies fn and commits with a version check, retrying when
|
|
42
|
-
* another writer got there first. fn returns undefined to delete the key.
|
|
43
|
-
*/
|
|
44
|
-
async update(namespace, key, fn, signal) {
|
|
45
|
-
for (let attempt = 0; attempt < 16; attempt++) {
|
|
46
|
-
const old = await this.get(namespace, key, signal);
|
|
47
|
-
const value = await fn(old?.value);
|
|
48
|
-
const check = old === undefined
|
|
49
|
-
? { namespace, key, absent: true }
|
|
50
|
-
: { namespace, key, version: old.version };
|
|
51
|
-
const b = value === undefined
|
|
52
|
-
? { checks: [check], deletes: [{ namespace, key }] }
|
|
53
|
-
: { checks: [check], puts: [{ namespace, key, value }] };
|
|
54
|
-
try {
|
|
55
|
-
return await this.commit(b, signal);
|
|
56
|
-
}
|
|
57
|
-
catch (err) {
|
|
58
|
-
if (!(err instanceof ProtocolError && err.code === Code.Conflict))
|
|
59
|
-
throw err;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
throw new ProtocolError(Code.Conflict, "update kept conflicting");
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Derives one Event from parent (an accepted Event in a configured scope),
|
|
66
|
-
* committing the batch's KV writes atomically with it.
|
|
67
|
-
*/
|
|
68
|
-
async accept(a, signal) {
|
|
69
|
-
const { puts, ...rest } = batchFields(a);
|
|
70
|
-
// event.accept calls its puts "records".
|
|
71
|
-
const params = {
|
|
72
|
-
scope_id: a.scopeId,
|
|
73
|
-
parent: a.parent,
|
|
74
|
-
event: a.event,
|
|
75
|
-
...rest,
|
|
76
|
-
};
|
|
77
|
-
return this.call("event.accept", puts === undefined ? params : { ...params, records: puts }, EventAcceptResult, signal);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Hands a delivery (a verified webhook's body) to the source registered
|
|
81
|
-
* as name. The host calls the source's push with it and answers once its
|
|
82
|
-
* Events are durably accepted: added[i] is false for an Event it already
|
|
83
|
-
* had, such as a sender's retry.
|
|
84
|
-
*/
|
|
85
|
-
async deliver(name, delivery, signal) {
|
|
86
|
-
const out = await this.call("ingress.deliver", {
|
|
87
|
-
name,
|
|
88
|
-
delivery: {
|
|
89
|
-
id: delivery.id,
|
|
90
|
-
received_at: delivery.receivedAt ?? new Date().toISOString(),
|
|
91
|
-
...(delivery.contentType
|
|
92
|
-
? { content_type: delivery.contentType }
|
|
93
|
-
: {}),
|
|
94
|
-
...(delivery.body === undefined
|
|
95
|
-
? {}
|
|
96
|
-
: { body: base64(toBytes(delivery.body)) }),
|
|
97
|
-
},
|
|
98
|
-
}, IngressDeliverResult, signal);
|
|
99
|
-
return { accepted: out.accepted ?? [], added: out.added ?? [] };
|
|
100
|
-
}
|
|
101
|
-
/** Accepted Events of the configured scopes after a sequence. */
|
|
102
|
-
async events(after = 0, limit = 0, signal) {
|
|
103
|
-
const params = {
|
|
104
|
-
...(after > 0 ? { after } : {}),
|
|
105
|
-
...(limit > 0 ? { limit } : {}),
|
|
106
|
-
};
|
|
107
|
-
return ((await this.call("state.events", params, t.nullable(t.array(AcceptedEvent)), signal)) ?? []);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* One Work's accepted Events of the configured scopes after a sequence:
|
|
111
|
-
* those naming it and those routed to it. The host reads them from its
|
|
112
|
-
* index, so the cost follows the Work's own Events, not the whole log.
|
|
113
|
-
*/
|
|
114
|
-
async workEvents(workId, after = 0, limit = 0, signal) {
|
|
115
|
-
if (workId === "")
|
|
116
|
-
return [];
|
|
117
|
-
const params = {
|
|
118
|
-
id: workId,
|
|
119
|
-
...(after > 0 ? { after } : {}),
|
|
120
|
-
...(limit > 0 ? { limit } : {}),
|
|
121
|
-
};
|
|
122
|
-
return ((await this.call("state.work_events", params, t.nullable(t.array(AcceptedEvent)), signal)) ?? []);
|
|
123
|
-
}
|
|
124
|
-
/** Work of the configured scopes (one scope when scopeId is set). */
|
|
125
|
-
async works(scopeId = "", signal) {
|
|
126
|
-
return this.queryWorks(scopeId === "" ? {} : { scopeId }, signal);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* The Work a query selects, of the configured scopes and the extension's
|
|
130
|
-
* own kinds, in its order (by creation unless `order` says otherwise),
|
|
131
|
-
* at most `limit` (all when unset). The host reads them through its
|
|
132
|
-
* indexes a page at a time, so the cost follows the Work selected, not
|
|
133
|
-
* every Work ever made: ask for live Work with `states`, or for Work
|
|
134
|
-
* changed since a time with `updatedSince`.
|
|
135
|
-
*/
|
|
136
|
-
async queryWorks(query, signal) {
|
|
137
|
-
const order = query.order ?? "created";
|
|
138
|
-
const all = [];
|
|
139
|
-
let cursor;
|
|
140
|
-
for (;;) {
|
|
141
|
-
const page = query.limit !== undefined && query.limit > 0
|
|
142
|
-
? Math.min(MaxWorksPage, query.limit - all.length)
|
|
143
|
-
: MaxWorksPage;
|
|
144
|
-
const params = {
|
|
145
|
-
...(query.scopeId ? { scope_id: query.scopeId } : {}),
|
|
146
|
-
...(query.states?.length ? { states: query.states } : {}),
|
|
147
|
-
...(query.kind ? { kind: query.kind } : {}),
|
|
148
|
-
...(query.parentId ? { parent_id: query.parentId } : {}),
|
|
149
|
-
...(query.sources?.length ? { sources: query.sources } : {}),
|
|
150
|
-
...(query.executor ? { executor: query.executor } : {}),
|
|
151
|
-
...(query.updatedSince ? { updated_since: query.updatedSince } : {}),
|
|
152
|
-
...(query.order ? { order: query.order } : {}),
|
|
153
|
-
...(cursor ? { cursor } : {}),
|
|
154
|
-
limit: page,
|
|
155
|
-
};
|
|
156
|
-
const got = (await this.call("state.works", params, t.nullable(t.array(Work)), signal)) ?? [];
|
|
157
|
-
// A host that predates the query answers every Work in one page.
|
|
158
|
-
if (got.length > page)
|
|
159
|
-
return got;
|
|
160
|
-
all.push(...got);
|
|
161
|
-
const last = got[got.length - 1];
|
|
162
|
-
if (got.length < page ||
|
|
163
|
-
last === undefined ||
|
|
164
|
-
(query.limit !== undefined &&
|
|
165
|
-
query.limit > 0 &&
|
|
166
|
-
all.length >= query.limit))
|
|
167
|
-
return all;
|
|
168
|
-
cursor = {
|
|
169
|
-
at: order.endsWith("updated") ? last.updated_at : last.created_at,
|
|
170
|
-
id: last.id,
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* The input routed to a Work that no attempt of it has read yet, oldest
|
|
176
|
-
* first. Ready Work with none has read everything routed to it; ready
|
|
177
|
-
* Work with some is about to start on it.
|
|
178
|
-
*/
|
|
179
|
-
async pending(workId, signal) {
|
|
180
|
-
return ((await this.call("state.pending", { id: workId }, t.nullable(t.array(PendingInput)), signal)) ?? []);
|
|
181
|
-
}
|
|
182
|
-
/** Resolves secret names bound to the extension's entry in a scope. */
|
|
183
|
-
async secrets(scopeId, names, signal) {
|
|
184
|
-
const out = await this.call("secret.resolve", { scope_id: scopeId, names }, SecretResolveResult, signal);
|
|
185
|
-
return out.values ?? {};
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Resolves secret names of a connection an entry or binding in the scope
|
|
189
|
-
* names, such as an operation's authority.connection.
|
|
190
|
-
*/
|
|
191
|
-
async connectionSecrets(scopeId, connection, names, signal) {
|
|
192
|
-
const out = await this.call("secret.resolve", { scope_id: scopeId, connection, names }, SecretResolveResult, signal);
|
|
193
|
-
return out.values ?? {};
|
|
194
|
-
}
|
|
195
|
-
/** Writes an immutable artifact in chunks, each acknowledged before the next. */
|
|
196
|
-
async artifact(mediaType, data, signal) {
|
|
197
|
-
const bytes = toBytes(data);
|
|
198
|
-
const { writer } = await this.call("artifact.create", { media_type: mediaType }, ArtifactCreateResult, signal);
|
|
199
|
-
try {
|
|
200
|
-
for (let at = 0; at < bytes.length; at += MaxChunkBytes) {
|
|
201
|
-
await this.call("artifact.write", { writer, chunk: base64(bytes.subarray(at, at + MaxChunkBytes)) }, Empty, signal);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
catch (err) {
|
|
205
|
-
// Not under signal: a cancelled write must still release the writer.
|
|
206
|
-
await this.call("artifact.abort", { writer }, Empty).catch(() => { });
|
|
207
|
-
throw err;
|
|
208
|
-
}
|
|
209
|
-
return this.call("artifact.commit", { writer }, ArtifactRef, signal);
|
|
210
|
-
}
|
|
211
|
-
/** Sets the progress line of a Work's active Wait ("" clears it). */
|
|
212
|
-
async waitProgress(workId, progress, signal) {
|
|
213
|
-
await this.call("wait.progress", { work_id: workId, progress }, Empty, signal);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
function entry(e) {
|
|
217
|
-
return {
|
|
218
|
-
key: e.key,
|
|
219
|
-
value: e.value === null
|
|
220
|
-
? new Uint8Array()
|
|
221
|
-
: new Uint8Array(Buffer.from(e.value, "base64")),
|
|
222
|
-
version: e.version,
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
function batchFields(b) {
|
|
226
|
-
return {
|
|
227
|
-
...(b.checks?.length ? { checks: b.checks } : {}),
|
|
228
|
-
...(b.puts?.length
|
|
229
|
-
? {
|
|
230
|
-
puts: b.puts.map((p) => ({
|
|
231
|
-
namespace: p.namespace,
|
|
232
|
-
key: p.key,
|
|
233
|
-
value: base64(toBytes(p.value)),
|
|
234
|
-
})),
|
|
235
|
-
}
|
|
236
|
-
: {}),
|
|
237
|
-
...(b.deletes?.length ? { deletes: b.deletes } : {}),
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
export function toBytes(v) {
|
|
241
|
-
return typeof v === "string" ? new TextEncoder().encode(v) : v;
|
|
242
|
-
}
|
|
243
|
-
export function base64(b) {
|
|
244
|
-
return Buffer.from(b.buffer, b.byteOffset, b.byteLength).toString("base64");
|
|
245
|
-
}
|
|
246
|
-
/** Decodes a KV value as UTF-8 text. */
|
|
247
|
-
export function text(v) {
|
|
248
|
-
return new TextDecoder().decode(v);
|
|
249
|
-
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { extension, Extension, Server, ProtocolVersions } from "./extension.js";
|
|
2
|
-
export type { CallContext, CheckContext, CheckFn, CommitOut, Context, EmitOut, EmitSpec, EntryOf, EntryTypeSpec, IngressTypeSpec, MigrateFn, OperationSpec, Options, PushDelivery, RouteCall, RouteSpec, SampleCall, SourceSpec, TaskFn, WaitOut, WaitSpec, WebhookContext, WebhookRequest, WebhookResponse, WorkKindSpec, } from "./extension.js";
|
|
3
|
-
export { Host, MaxWorksPage, text } from "./host.js";
|
|
4
|
-
export type { Accept, Batch, Caller, DeliveryInput, Entry, Put, Value, WorksQuery, } from "./host.js";
|
|
5
|
-
export { t, check, diagnose, matches, isRecord } from "./schema.js";
|
|
6
|
-
export type { Infer, Type } from "./schema.js";
|
|
7
|
-
export { Code, OperationError, ProtocolError, ConfigError, pointer, CancelledError, TransportError, isProtocolCode, } from "./errors.js";
|
|
8
|
-
export type { ConfigDiagnostic } from "./errors.js";
|
|
9
|
-
export { Conn, MaxMessageBytes, MaxChunkBytes, MaxInflight, } from "./jsonrpc.js";
|
|
10
|
-
export * from "./wire.js";
|
package/dist/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// @open-conduit/sdk: build an Open Conduit extension in TypeScript.
|
|
2
|
-
//
|
|
3
|
-
// import { extension, t, OperationError } from "@open-conduit/sdk";
|
|
4
|
-
//
|
|
5
|
-
// const ext = extension("weather", { version: "0.1.0" })
|
|
6
|
-
// .operation("weather.forecast", {
|
|
7
|
-
// input: t.object({ city: t.string({ description: "The city, by name." }) }),
|
|
8
|
-
// guidance: "Call `weather.forecast` before planning anything outdoors.",
|
|
9
|
-
// handler: async ({ city }) => ({ city, summary: "sunny" }),
|
|
10
|
-
// });
|
|
11
|
-
// await ext.main();
|
|
12
|
-
//
|
|
13
|
-
// The guide is site/src/content/docs/architecture/extension-packaging.md.
|
|
14
|
-
export { extension, Extension, Server, ProtocolVersions } from "./extension.js";
|
|
15
|
-
export { Host, MaxWorksPage, text } from "./host.js";
|
|
16
|
-
export { t, check, diagnose, matches, isRecord } from "./schema.js";
|
|
17
|
-
export { Code, OperationError, ProtocolError, ConfigError, pointer, CancelledError, TransportError, isProtocolCode, } from "./errors.js";
|
|
18
|
-
export { Conn, MaxMessageBytes, MaxChunkBytes, MaxInflight, } from "./jsonrpc.js";
|
|
19
|
-
export * from "./wire.js";
|
package/dist/jsonrpc.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { Readable, Writable } from "node:stream";
|
|
2
|
-
/** Bounds of protocol version 1 (protocol/protocol.go). */
|
|
3
|
-
export declare const MaxMessageBytes: number;
|
|
4
|
-
export declare const MaxChunkBytes: number;
|
|
5
|
-
export declare const MaxInflight = 64;
|
|
6
|
-
export declare const CancelMethod = "$/cancel";
|
|
7
|
-
/** Serves one inbound request. Its signal aborts when the peer cancels. */
|
|
8
|
-
export type Handler = (method: string, params: unknown, signal: AbortSignal) => Promise<unknown>;
|
|
9
|
-
export interface ConnOptions {
|
|
10
|
-
maxMessage?: number;
|
|
11
|
-
maxInflight?: number;
|
|
12
|
-
/** Receives why a malformed stream closed the connection. */
|
|
13
|
-
onProtocolError?: (reason: string) => void;
|
|
14
|
-
}
|
|
15
|
-
/** One JSON-RPC peer. */
|
|
16
|
-
export declare class Conn {
|
|
17
|
-
#private;
|
|
18
|
-
readonly done: Promise<void>;
|
|
19
|
-
constructor(input: Readable, output: Writable, handler: Handler, o?: ConnOptions);
|
|
20
|
-
/** Reports whether the connection has ended. */
|
|
21
|
-
get closed(): boolean;
|
|
22
|
-
/** Ends the connection; pending calls reject with TransportError. */
|
|
23
|
-
close(): void;
|
|
24
|
-
/**
|
|
25
|
-
* Sends a request and resolves with its result, undecoded. Aborting
|
|
26
|
-
* signal sends $/cancel and rejects at once with CancelledError.
|
|
27
|
-
*/
|
|
28
|
-
call(method: string, params?: unknown, signal?: AbortSignal): Promise<unknown>;
|
|
29
|
-
/** Sends a notification (no response). */
|
|
30
|
-
notify(method: string, params?: unknown): void;
|
|
31
|
-
}
|