@deliverd/sdk 0.3.0 → 0.5.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/README.md +70 -0
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.js +94 -0
- package/dist/flows.d.ts +106 -0
- package/dist/flows.d.ts.map +1 -0
- package/dist/flows.js +150 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/reports.d.ts +10 -1
- package/dist/reports.d.ts.map +1 -1
- package/dist/reports.js +15 -0
- package/dist/types.d.ts +149 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/dev.ts +111 -1
- package/src/flows.ts +200 -0
- package/src/index.ts +9 -0
- package/src/reports.ts +17 -0
- package/src/types.ts +162 -1
package/README.md
CHANGED
|
@@ -161,6 +161,76 @@ await deliverd.publish({ title, content }); // get the work to the people who n
|
|
|
161
161
|
|
|
162
162
|
All five. Each one is a person your agent needs and cannot be.
|
|
163
163
|
|
|
164
|
+
## Flows
|
|
165
|
+
|
|
166
|
+
A job that takes more than one of them is one job, and a firm asking about it
|
|
167
|
+
afterwards asks about the job — not about approvals in October. A flow is the
|
|
168
|
+
thread that ties them together.
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
const flow = await deliverd.flows.resume({
|
|
172
|
+
title: "Q3 close",
|
|
173
|
+
externalId: "close_2026_q3", // so a restart extends this one
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
const { answers } = await flow.collect({ title: "Before I start", questions, respondents });
|
|
177
|
+
const outcome = await flow.review({ title: "Draft pack", reportId, reviewers });
|
|
178
|
+
if (outcome.approved) await deliverd.publish({ title, content, flowId: flow.id });
|
|
179
|
+
|
|
180
|
+
await flow.close();
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`flow.approve()`, `flow.review()` and `flow.collect()` are the same calls as
|
|
184
|
+
the ones above with the flow already named. That is the whole point of the
|
|
185
|
+
handle: a `flowId` passed by hand at four call sites is one that gets left off
|
|
186
|
+
the fifth, and the step is then missing from the history with nothing to say
|
|
187
|
+
so. Publishing takes `flowId` directly, because a report joins a flow when it
|
|
188
|
+
is first created rather than through a handle.
|
|
189
|
+
|
|
190
|
+
It groups and does nothing else. Nothing waits on a flow, nothing is blocked
|
|
191
|
+
by one, and there are no steps to declare in advance — do the work in the
|
|
192
|
+
order you want it done and name the flow as you go.
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
flow.allSettled // nothing in it is waiting on anybody right now
|
|
196
|
+
flow.openCount // how many still are
|
|
197
|
+
flow.timeline // every audited step across all of them, in order
|
|
198
|
+
await flow.refresh()
|
|
199
|
+
await flow.close() // say the work is done; it stops taking new members
|
|
200
|
+
await flow.cancel() // call it off; nothing inside it is cancelled
|
|
201
|
+
await deliverd.flows.list({ status: "open" });
|
|
202
|
+
await deliverd.flows.get(id);
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
`allSettled` is a fact about this moment, not a verdict. You may be about to
|
|
206
|
+
add the next step, so nothing closes a flow but you.
|
|
207
|
+
|
|
208
|
+
## Evidence
|
|
209
|
+
|
|
210
|
+
Show your working. One call assembles the whole record of a piece of work —
|
|
211
|
+
every approval, review and request with who was asked, what they were told and
|
|
212
|
+
what they said, plus the timeline across all of it.
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
const pack = await flow.evidence();
|
|
216
|
+
// or, for the deliverable itself:
|
|
217
|
+
const pack = await deliverd.reports.evidence(report.id);
|
|
218
|
+
|
|
219
|
+
pack.steps; // each one with asked[], outcomes[] and its own detail
|
|
220
|
+
pack.timeline; // what happened, in order
|
|
221
|
+
pack.integrity; // what the digest stands for, in the pack's own words
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
A person downloads it as a PDF from the flow or report page; this is the same
|
|
225
|
+
pack as JSON. It needs every read scope, because it contains everything.
|
|
226
|
+
|
|
227
|
+
**Read `integrity` before you quote it.** The digest is over the pack as
|
|
228
|
+
exported, so it detects a file altered after it left. It makes no claim about
|
|
229
|
+
the database — what stands behind the records is that the audit table rejects
|
|
230
|
+
updates and deletes at the database level. That is tamper-evident history, not
|
|
231
|
+
cryptographic immutability, and the pack says so in both directions rather than
|
|
232
|
+
leaving a hash to imply the stronger one.
|
|
233
|
+
|
|
164
234
|
## Collecting
|
|
165
235
|
|
|
166
236
|
`approve()` asks permission, `review()` asks judgement, and this asks for a
|
package/dist/dev.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAKb,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;AAElF,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,kBAAkB,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,KAAK,kBAAkB,CAAC,CAAC;IAC/E,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAcD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,UAAU,CAAC,KAAK,CAiW1F"}
|
package/dist/dev.js
CHANGED
|
@@ -11,6 +11,7 @@ export function developmentFetch(options = {}) {
|
|
|
11
11
|
const store = new Map();
|
|
12
12
|
const reviewStore = new Map();
|
|
13
13
|
const collectionStore = new Map();
|
|
14
|
+
const flowStore = new Map();
|
|
14
15
|
return (async (input, init) => {
|
|
15
16
|
const url = new URL(String(input));
|
|
16
17
|
const path = url.pathname.replace(/^\/api\/v1/, "");
|
|
@@ -228,6 +229,99 @@ export function developmentFetch(options = {}) {
|
|
|
228
229
|
collections: externalId ? all.filter((c) => c.externalId === externalId) : all,
|
|
229
230
|
});
|
|
230
231
|
}
|
|
232
|
+
/*
|
|
233
|
+
* Flows in development are real objects with no simulation attached:
|
|
234
|
+
* there is nobody to imagine, and the thing worth exercising offline is
|
|
235
|
+
* that `flow.approve()` reaches the same code as `deliverd.approve()`.
|
|
236
|
+
* Members are not tracked here — the server derives them from rows this
|
|
237
|
+
* store does not keep — so a development flow reports what it knows and
|
|
238
|
+
* does not invent a membership.
|
|
239
|
+
*/
|
|
240
|
+
if (method === "POST" && path === "/flows") {
|
|
241
|
+
const id = `flw_dev_${++counter}`;
|
|
242
|
+
const data = {
|
|
243
|
+
id,
|
|
244
|
+
status: "open",
|
|
245
|
+
url: `https://deliverd.dev/flows/${id}`,
|
|
246
|
+
title: String(body.title ?? "Untitled"),
|
|
247
|
+
description: body.description ?? null,
|
|
248
|
+
externalId: body.externalId ?? null,
|
|
249
|
+
metadata: body.metadata ?? {},
|
|
250
|
+
startedBy: "You (development mode)",
|
|
251
|
+
members: [],
|
|
252
|
+
memberCount: 0,
|
|
253
|
+
openCount: 0,
|
|
254
|
+
allSettled: false,
|
|
255
|
+
timeline: [],
|
|
256
|
+
settledAt: null,
|
|
257
|
+
createdAt: new Date().toISOString(),
|
|
258
|
+
};
|
|
259
|
+
flowStore.set(id, data);
|
|
260
|
+
if (options.log !== false) {
|
|
261
|
+
console.log(`\n \u25B8 Flow started: ${data.title}\n ${data.url}\n`);
|
|
262
|
+
}
|
|
263
|
+
return json(data, 201);
|
|
264
|
+
}
|
|
265
|
+
/*
|
|
266
|
+
* Evidence in development is the shape and not the substance: this store
|
|
267
|
+
* holds no audit rows, so the pack comes back with the subject and an
|
|
268
|
+
* empty record rather than an invented one. What it proves is that
|
|
269
|
+
* `flow.evidence()` reaches the right path and returns something a caller
|
|
270
|
+
* can destructure — an imaginary approval trail would be worse than none.
|
|
271
|
+
*/
|
|
272
|
+
const evidenceMatch = /^\/(flows|reports)\/([^/]+)\/evidence$/.exec(path);
|
|
273
|
+
if (evidenceMatch && method === "GET") {
|
|
274
|
+
const kind = evidenceMatch[1] === "flows" ? "flow" : "report";
|
|
275
|
+
const id = evidenceMatch[2];
|
|
276
|
+
const title = kind === "flow" ? (flowStore.get(id)?.title ?? "A flow") : "A report";
|
|
277
|
+
const now = new Date().toISOString();
|
|
278
|
+
const pack = {
|
|
279
|
+
packVersion: 1,
|
|
280
|
+
generatedAt: now,
|
|
281
|
+
generatedBy: "You (development mode)",
|
|
282
|
+
organisation: { id: "org_dev", name: "Development" },
|
|
283
|
+
subject: {
|
|
284
|
+
kind,
|
|
285
|
+
id,
|
|
286
|
+
title,
|
|
287
|
+
url: `https://deliverd.dev/${evidenceMatch[1]}/${id}`,
|
|
288
|
+
status: "open",
|
|
289
|
+
startedBy: "You (development mode)",
|
|
290
|
+
startedAt: now,
|
|
291
|
+
},
|
|
292
|
+
summary: { steps: 0, events: 0, firstEventAt: null, lastEventAt: null },
|
|
293
|
+
steps: [],
|
|
294
|
+
timeline: [],
|
|
295
|
+
integrity: {
|
|
296
|
+
algorithm: "sha256",
|
|
297
|
+
digest: "development",
|
|
298
|
+
covers: "Nothing: this pack was produced in development mode and holds no records.",
|
|
299
|
+
doesNotCover: "Everything. Do not hand this to anybody.",
|
|
300
|
+
recordsAreInsertOnly: true,
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
return json(pack);
|
|
304
|
+
}
|
|
305
|
+
const flowMatch = /^\/flows\/([^/]+)(\/complete|\/cancel)?$/.exec(path);
|
|
306
|
+
if (flowMatch) {
|
|
307
|
+
const flow = flowStore.get(flowMatch[1]);
|
|
308
|
+
if (!flow) {
|
|
309
|
+
return json({ error: { code: "not_found", message: "No such flow in this development session." } }, 404);
|
|
310
|
+
}
|
|
311
|
+
if (flowMatch[2] === "/complete" || flowMatch[2] === "/cancel") {
|
|
312
|
+
if (flow.status !== "open") {
|
|
313
|
+
return json({ error: { code: "not_open", message: `This flow is already ${flow.status}.` } }, 409);
|
|
314
|
+
}
|
|
315
|
+
flow.status = flowMatch[2] === "/complete" ? "complete" : "cancelled";
|
|
316
|
+
flow.settledAt = new Date().toISOString();
|
|
317
|
+
}
|
|
318
|
+
return json(flow);
|
|
319
|
+
}
|
|
320
|
+
if (method === "GET" && path === "/flows") {
|
|
321
|
+
const externalId = url.searchParams.get("externalId");
|
|
322
|
+
const all = [...flowStore.values()];
|
|
323
|
+
return json({ flows: externalId ? all.filter((f) => f.externalId === externalId) : all });
|
|
324
|
+
}
|
|
231
325
|
return json({
|
|
232
326
|
error: {
|
|
233
327
|
code: "not_in_development_mode",
|
package/dist/flows.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { HttpClient } from "./http.js";
|
|
2
|
+
import type { CreateFlowInput, EvidencePack, FlowData, ListFlowsInput } from "./types.js";
|
|
3
|
+
import type { ApproveOptions, CollectOptions, Decision, ReviewOptions, ReviewOutcome } from "./index.js";
|
|
4
|
+
import type { CollectedAnswers } from "./types.js";
|
|
5
|
+
/**
|
|
6
|
+
* A flow: the thread that ties one job's approvals, reviews, collections and
|
|
7
|
+
* publishes together.
|
|
8
|
+
*
|
|
9
|
+
* The reason it exists in this SDK rather than only in the API is the handle
|
|
10
|
+
* below. An agent doing a multi-step job would otherwise carry a `flowId`
|
|
11
|
+
* through every call and pass it by hand each time — which works right up
|
|
12
|
+
* until one call is written without it, and that step is then missing from
|
|
13
|
+
* the history with nothing to say so. `flow.approve()` cannot forget.
|
|
14
|
+
*
|
|
15
|
+
* It groups and nothing else. Nothing waits on a flow; nothing is blocked by
|
|
16
|
+
* one; there are no steps to declare up front. Do the work in the order you
|
|
17
|
+
* want it done and name the flow as you go.
|
|
18
|
+
*/
|
|
19
|
+
/** The three primitives a flow can start on your behalf, with their real signatures. */
|
|
20
|
+
export interface FlowPrimitives {
|
|
21
|
+
approve(options: ApproveOptions): Promise<Decision>;
|
|
22
|
+
review(options: ReviewOptions): Promise<ReviewOutcome>;
|
|
23
|
+
collect(options: CollectOptions): Promise<CollectedAnswers>;
|
|
24
|
+
}
|
|
25
|
+
export declare class Flow {
|
|
26
|
+
private readonly http;
|
|
27
|
+
private data;
|
|
28
|
+
private readonly client;
|
|
29
|
+
constructor(http: HttpClient, data: FlowData, client: FlowPrimitives);
|
|
30
|
+
get id(): string;
|
|
31
|
+
get status(): FlowData["status"];
|
|
32
|
+
/** The timeline page a person can open. */
|
|
33
|
+
get url(): string;
|
|
34
|
+
get title(): string;
|
|
35
|
+
get members(): FlowData["members"];
|
|
36
|
+
get timeline(): NonNullable<FlowData["timeline"]>;
|
|
37
|
+
get memberCount(): number;
|
|
38
|
+
get openCount(): number;
|
|
39
|
+
get open(): boolean;
|
|
40
|
+
get complete(): boolean;
|
|
41
|
+
get cancelled(): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Nothing in it is waiting on anybody *at this moment*.
|
|
44
|
+
*
|
|
45
|
+
* Not a claim that the job is finished — you may be about to add the next
|
|
46
|
+
* step, and an empty flow is never settled. Branch on it to decide whether
|
|
47
|
+
* to move on; call `complete()` to say the work is over.
|
|
48
|
+
*/
|
|
49
|
+
get allSettled(): boolean;
|
|
50
|
+
toJSON(): FlowData;
|
|
51
|
+
refresh(signal?: AbortSignal): Promise<this>;
|
|
52
|
+
/**
|
|
53
|
+
* Ask permission, inside this flow. Exactly `deliverd.approve()` with the
|
|
54
|
+
* flow already named — which is the point: a `flowId` passed by hand at
|
|
55
|
+
* four call sites is one that gets left off the fifth.
|
|
56
|
+
*/
|
|
57
|
+
approve(options: Omit<ApproveOptions, "flowId">): Promise<Decision>;
|
|
58
|
+
/** Ask for judgement, inside this flow. */
|
|
59
|
+
review(options: Omit<ReviewOptions, "flowId">): Promise<ReviewOutcome>;
|
|
60
|
+
/** Ask for facts, inside this flow. */
|
|
61
|
+
collect(options: Omit<CollectOptions, "flowId">): Promise<CollectedAnswers>;
|
|
62
|
+
/**
|
|
63
|
+
* The whole record of this flow: every step with who was asked and what they
|
|
64
|
+
* said, and the timeline across all of it.
|
|
65
|
+
*
|
|
66
|
+
* What to hand over when somebody asks you to show your working. Needs every
|
|
67
|
+
* read scope, because it contains everything.
|
|
68
|
+
*/
|
|
69
|
+
evidence(signal?: AbortSignal): Promise<EvidencePack>;
|
|
70
|
+
/**
|
|
71
|
+
* Say the work is done. It stops taking new members from here.
|
|
72
|
+
*
|
|
73
|
+
* Named `close()` rather than `complete()` so it does not collide with the
|
|
74
|
+
* `complete` getter above, which every other primitive in this SDK also
|
|
75
|
+
* has; `flow.complete` asks, `flow.close()` decides.
|
|
76
|
+
*
|
|
77
|
+
* Allowed with steps still outstanding, and how many is recorded — a flow
|
|
78
|
+
* that could not be closed until every reviewer replied would be one that
|
|
79
|
+
* stayed open for ever.
|
|
80
|
+
*/
|
|
81
|
+
close(signal?: AbortSignal): Promise<this>;
|
|
82
|
+
/** Call it off. The flow and its members stay as evidence; nothing inside is cancelled. */
|
|
83
|
+
cancel(signal?: AbortSignal): Promise<this>;
|
|
84
|
+
}
|
|
85
|
+
export declare class Flows {
|
|
86
|
+
private readonly http;
|
|
87
|
+
private readonly client;
|
|
88
|
+
constructor(http: HttpClient, client: FlowPrimitives);
|
|
89
|
+
create(input: CreateFlowInput, signal?: AbortSignal): Promise<Flow>;
|
|
90
|
+
get(id: string, signal?: AbortSignal): Promise<Flow>;
|
|
91
|
+
list(input?: ListFlowsInput, signal?: AbortSignal): Promise<Flow[]>;
|
|
92
|
+
/** The same job as before, when there was one — so a restart extends it rather than starting a second. */
|
|
93
|
+
findByExternalId(externalId: string, signal?: AbortSignal): Promise<Flow | null>;
|
|
94
|
+
/**
|
|
95
|
+
* The flow for this reference, started if it does not exist yet.
|
|
96
|
+
*
|
|
97
|
+
* What a restartable agent actually wants: one line that is correct on the
|
|
98
|
+
* first run and on the fourth. Without it the caller writes the lookup, the
|
|
99
|
+
* branch and the create by hand, and a crash between the lookup and the
|
|
100
|
+
* create leaves two flows for one job.
|
|
101
|
+
*/
|
|
102
|
+
resume(input: CreateFlowInput & {
|
|
103
|
+
externalId: string;
|
|
104
|
+
}, signal?: AbortSignal): Promise<Flow>;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=flows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flows.d.ts","sourceRoot":"","sources":["../src/flows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAO1F,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,QAAQ,EACR,aAAa,EACb,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;;;;;;;;;GAaG;AAEH,wFAAwF;AACxF,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpD,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACvD,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC7D;AAED,qBAAa,IAAI;IAEb,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAFN,IAAI,EAAE,UAAU,EACzB,IAAI,EAAE,QAAQ,EACL,MAAM,EAAE,cAAc;IAGzC,IAAI,EAAE,IAAI,MA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AO,CAAC,IAAI,CAAC;CAQlD;AAED,qBAAa,KAAK;IAEd,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,cAAc;IAGnC,MAAM,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAUnE,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IASpD,IAAI,CAAC,KAAK,GAAE,cAAmB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAU7E,0GAA0G;IACpG,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAKtF;;;;;;;OAOG;IACG,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAKnG"}
|
package/dist/flows.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
export class Flow {
|
|
2
|
+
http;
|
|
3
|
+
data;
|
|
4
|
+
client;
|
|
5
|
+
constructor(http, data, client) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
this.data = data;
|
|
8
|
+
this.client = client;
|
|
9
|
+
}
|
|
10
|
+
get id() { return this.data.id; }
|
|
11
|
+
get status() { return this.data.status; }
|
|
12
|
+
/** The timeline page a person can open. */
|
|
13
|
+
get url() { return this.data.url; }
|
|
14
|
+
get title() { return this.data.title; }
|
|
15
|
+
get members() { return this.data.members; }
|
|
16
|
+
get timeline() { return this.data.timeline ?? []; }
|
|
17
|
+
get memberCount() { return this.data.memberCount; }
|
|
18
|
+
get openCount() { return this.data.openCount; }
|
|
19
|
+
get open() { return this.data.status === "open"; }
|
|
20
|
+
get complete() { return this.data.status === "complete"; }
|
|
21
|
+
get cancelled() { return this.data.status === "cancelled"; }
|
|
22
|
+
/**
|
|
23
|
+
* Nothing in it is waiting on anybody *at this moment*.
|
|
24
|
+
*
|
|
25
|
+
* Not a claim that the job is finished — you may be about to add the next
|
|
26
|
+
* step, and an empty flow is never settled. Branch on it to decide whether
|
|
27
|
+
* to move on; call `complete()` to say the work is over.
|
|
28
|
+
*/
|
|
29
|
+
get allSettled() { return this.data.allSettled; }
|
|
30
|
+
toJSON() { return this.data; }
|
|
31
|
+
async refresh(signal) {
|
|
32
|
+
this.data = await this.http.request({
|
|
33
|
+
method: "GET",
|
|
34
|
+
path: `/flows/${this.data.id}`,
|
|
35
|
+
signal,
|
|
36
|
+
});
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Ask permission, inside this flow. Exactly `deliverd.approve()` with the
|
|
41
|
+
* flow already named — which is the point: a `flowId` passed by hand at
|
|
42
|
+
* four call sites is one that gets left off the fifth.
|
|
43
|
+
*/
|
|
44
|
+
approve(options) {
|
|
45
|
+
return this.client.approve({ ...options, flowId: this.data.id });
|
|
46
|
+
}
|
|
47
|
+
/** Ask for judgement, inside this flow. */
|
|
48
|
+
review(options) {
|
|
49
|
+
return this.client.review({ ...options, flowId: this.data.id });
|
|
50
|
+
}
|
|
51
|
+
/** Ask for facts, inside this flow. */
|
|
52
|
+
collect(options) {
|
|
53
|
+
return this.client.collect({ ...options, flowId: this.data.id });
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The whole record of this flow: every step with who was asked and what they
|
|
57
|
+
* said, and the timeline across all of it.
|
|
58
|
+
*
|
|
59
|
+
* What to hand over when somebody asks you to show your working. Needs every
|
|
60
|
+
* read scope, because it contains everything.
|
|
61
|
+
*/
|
|
62
|
+
evidence(signal) {
|
|
63
|
+
return this.http.request({
|
|
64
|
+
method: "GET",
|
|
65
|
+
path: `/flows/${this.data.id}/evidence`,
|
|
66
|
+
signal,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Say the work is done. It stops taking new members from here.
|
|
71
|
+
*
|
|
72
|
+
* Named `close()` rather than `complete()` so it does not collide with the
|
|
73
|
+
* `complete` getter above, which every other primitive in this SDK also
|
|
74
|
+
* has; `flow.complete` asks, `flow.close()` decides.
|
|
75
|
+
*
|
|
76
|
+
* Allowed with steps still outstanding, and how many is recorded — a flow
|
|
77
|
+
* that could not be closed until every reviewer replied would be one that
|
|
78
|
+
* stayed open for ever.
|
|
79
|
+
*/
|
|
80
|
+
async close(signal) {
|
|
81
|
+
this.data = await this.http.request({
|
|
82
|
+
method: "POST",
|
|
83
|
+
path: `/flows/${this.data.id}/complete`,
|
|
84
|
+
signal,
|
|
85
|
+
});
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
/** Call it off. The flow and its members stay as evidence; nothing inside is cancelled. */
|
|
89
|
+
async cancel(signal) {
|
|
90
|
+
this.data = await this.http.request({
|
|
91
|
+
method: "POST",
|
|
92
|
+
path: `/flows/${this.data.id}/cancel`,
|
|
93
|
+
signal,
|
|
94
|
+
});
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export class Flows {
|
|
99
|
+
http;
|
|
100
|
+
client;
|
|
101
|
+
constructor(http, client) {
|
|
102
|
+
this.http = http;
|
|
103
|
+
this.client = client;
|
|
104
|
+
}
|
|
105
|
+
async create(input, signal) {
|
|
106
|
+
const data = await this.http.request({
|
|
107
|
+
method: "POST",
|
|
108
|
+
path: "/flows",
|
|
109
|
+
body: input,
|
|
110
|
+
signal,
|
|
111
|
+
});
|
|
112
|
+
return new Flow(this.http, data, this.client);
|
|
113
|
+
}
|
|
114
|
+
async get(id, signal) {
|
|
115
|
+
const data = await this.http.request({
|
|
116
|
+
method: "GET",
|
|
117
|
+
path: `/flows/${id}`,
|
|
118
|
+
signal,
|
|
119
|
+
});
|
|
120
|
+
return new Flow(this.http, data, this.client);
|
|
121
|
+
}
|
|
122
|
+
async list(input = {}, signal) {
|
|
123
|
+
const { flows } = await this.http.request({
|
|
124
|
+
method: "GET",
|
|
125
|
+
path: "/flows",
|
|
126
|
+
query: { status: input.status, externalId: input.externalId, limit: input.limit },
|
|
127
|
+
signal,
|
|
128
|
+
});
|
|
129
|
+
return flows.map((f) => new Flow(this.http, f, this.client));
|
|
130
|
+
}
|
|
131
|
+
/** The same job as before, when there was one — so a restart extends it rather than starting a second. */
|
|
132
|
+
async findByExternalId(externalId, signal) {
|
|
133
|
+
const found = await this.list({ externalId, limit: 1 }, signal);
|
|
134
|
+
return found[0] ?? null;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The flow for this reference, started if it does not exist yet.
|
|
138
|
+
*
|
|
139
|
+
* What a restartable agent actually wants: one line that is correct on the
|
|
140
|
+
* first run and on the fourth. Without it the caller writes the lookup, the
|
|
141
|
+
* branch and the create by hand, and a crash between the lookup and the
|
|
142
|
+
* create leaves two flows for one job.
|
|
143
|
+
*/
|
|
144
|
+
async resume(input, signal) {
|
|
145
|
+
const existing = await this.findByExternalId(input.externalId, signal);
|
|
146
|
+
if (existing && existing.open)
|
|
147
|
+
return existing;
|
|
148
|
+
return this.create(input, signal);
|
|
149
|
+
}
|
|
150
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Approvals, type WaitOptions } from "./approvals.js";
|
|
|
3
3
|
import { Comments, Reports } from "./reports.js";
|
|
4
4
|
import { Reviews, type ReviewWaitOptions } from "./reviews.js";
|
|
5
5
|
import { Collections, type CollectWaitOptions } from "./collections.js";
|
|
6
|
+
import { Flows } from "./flows.js";
|
|
6
7
|
import { Webhooks } from "./webhooks.js";
|
|
7
8
|
import { type DevelopmentOptions } from "./dev.js";
|
|
8
9
|
import { type Duration } from "./duration.js";
|
|
@@ -11,6 +12,7 @@ export { Approval, Approvals, POLL_SCHEDULE, type WaitOptions } from "./approval
|
|
|
11
12
|
export { Comments, Reports } from "./reports.js";
|
|
12
13
|
export { Review, Reviews, type ReviewWaitOptions } from "./reviews.js";
|
|
13
14
|
export { Collection, Collections, type CollectWaitOptions } from "./collections.js";
|
|
15
|
+
export { Flow, Flows, type FlowPrimitives } from "./flows.js";
|
|
14
16
|
export { constructEvent, DELIVERY_HEADER, EVENT_HEADER, SIGNATURE_HEADER, TOLERANCE_SECONDS, verifySignature, Webhooks, } from "./webhooks.js";
|
|
15
17
|
export { DeliverdError, DeliverdTimeoutError } from "./errors.js";
|
|
16
18
|
export { DEFAULT_BASE_URL, type ClientOptions } from "./http.js";
|
|
@@ -108,6 +110,7 @@ export declare class Deliverd {
|
|
|
108
110
|
readonly approvals: Approvals;
|
|
109
111
|
readonly reviews: Reviews;
|
|
110
112
|
readonly collections: Collections;
|
|
113
|
+
readonly flows: Flows;
|
|
111
114
|
readonly reports: Reports;
|
|
112
115
|
readonly comments: Comments;
|
|
113
116
|
readonly webhooks: Webhooks;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAsB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAoB,KAAK,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO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AQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,uDAAuD;IACvD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;gBAElB,OAAO,GAAE,eAAoB;IA0BzC;;;;;;;;;;OAUG;IACG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IA0CzD;;;;;;OAMG;IACG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAKxD;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAoC5D;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkCjE,gFAAgF;IAChF,OAAO,CAAC,KAAK,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;CAGjF;AAoBD,eAAO,MAAM,QAAQ,EAAE,QAMrB,CAAC;AAEH,eAAe,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Approvals, FAST_POLL_SCHEDULE } from "./approvals.js";
|
|
|
3
3
|
import { Comments, Reports } from "./reports.js";
|
|
4
4
|
import { Reviews } from "./reviews.js";
|
|
5
5
|
import { Collections } from "./collections.js";
|
|
6
|
+
import { Flows } from "./flows.js";
|
|
6
7
|
import { Webhooks } from "./webhooks.js";
|
|
7
8
|
import { developmentFetch } from "./dev.js";
|
|
8
9
|
import { durationMs } from "./duration.js";
|
|
@@ -10,6 +11,7 @@ export { Approval, Approvals, POLL_SCHEDULE } from "./approvals.js";
|
|
|
10
11
|
export { Comments, Reports } from "./reports.js";
|
|
11
12
|
export { Review, Reviews } from "./reviews.js";
|
|
12
13
|
export { Collection, Collections } from "./collections.js";
|
|
14
|
+
export { Flow, Flows } from "./flows.js";
|
|
13
15
|
export { constructEvent, DELIVERY_HEADER, EVENT_HEADER, SIGNATURE_HEADER, TOLERANCE_SECONDS, verifySignature, Webhooks, } from "./webhooks.js";
|
|
14
16
|
export { DeliverdError, DeliverdTimeoutError } from "./errors.js";
|
|
15
17
|
export { DEFAULT_BASE_URL } from "./http.js";
|
|
@@ -39,6 +41,7 @@ export class Deliverd {
|
|
|
39
41
|
approvals;
|
|
40
42
|
reviews;
|
|
41
43
|
collections;
|
|
44
|
+
flows;
|
|
42
45
|
reports;
|
|
43
46
|
comments;
|
|
44
47
|
webhooks;
|
|
@@ -58,6 +61,12 @@ export class Deliverd {
|
|
|
58
61
|
this.approvals = new Approvals(this.http);
|
|
59
62
|
this.reviews = new Reviews(this.http);
|
|
60
63
|
this.collections = new Collections(this.http);
|
|
64
|
+
/*
|
|
65
|
+
* The handle takes the client so `flow.approve()` is the same call as
|
|
66
|
+
* `deliverd.approve()` with the flow filled in, rather than a second
|
|
67
|
+
* implementation that can drift from it.
|
|
68
|
+
*/
|
|
69
|
+
this.flows = new Flows(this.http, this);
|
|
61
70
|
this.reports = new Reports(this.http);
|
|
62
71
|
this.comments = new Comments(this.http);
|
|
63
72
|
this.webhooks = new Webhooks();
|
package/dist/reports.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from "./http.js";
|
|
2
|
-
import type { CommentThread, PublishReportInput, PublishResult, ReportData, UpdateReportInput } from "./types.js";
|
|
2
|
+
import type { CommentThread, PublishReportInput, PublishResult, ReportData, UpdateReportInput, EvidencePack } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* The publishing half: get what the agent wrote to the people who need it, at
|
|
5
5
|
* an address that does not change.
|
|
@@ -22,6 +22,15 @@ export declare class Reports {
|
|
|
22
22
|
publish(input: PublishReportInput, signal?: AbortSignal): Promise<PublishResult>;
|
|
23
23
|
/** A new version of an existing report, keeping its URL and its audience. */
|
|
24
24
|
update(idOrSlug: string, input: UpdateReportInput, signal?: AbortSignal): Promise<PublishResult>;
|
|
25
|
+
/**
|
|
26
|
+
* The whole record behind a report: the approvals, reviews and requests for
|
|
27
|
+
* information that point at it, its version history, and the timeline across
|
|
28
|
+
* all of it.
|
|
29
|
+
*
|
|
30
|
+
* The subject an auditor usually names — and unlike a flow, it works for
|
|
31
|
+
* work that was done before flows existed. Needs every read scope.
|
|
32
|
+
*/
|
|
33
|
+
evidence(idOrSlug: string, signal?: AbortSignal): Promise<EvidencePack>;
|
|
25
34
|
get(idOrSlug: string, signal?: AbortSignal): Promise<ReportData>;
|
|
26
35
|
list(query?: string, signal?: AbortSignal): Promise<ReportData[]>;
|
|
27
36
|
/** Change the title, the address, or both. The old address keeps working. */
|
package/dist/reports.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../src/reports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,iBAAiB,
|
|
1
|
+
{"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../src/reports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB;;;;;;;;GAQG;AACH,qBAAa,OAAO;IACN,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;OAMG;IACH,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AE,EAC1D,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,OAAO,CAAC;IASnB,2DAA2D;IAC3D,OAAO,CACL,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAO,EAC/C,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,OAAO,CAAC;CAQpB"}
|
package/dist/reports.js
CHANGED
|
@@ -31,6 +31,21 @@ export class Reports {
|
|
|
31
31
|
signal,
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* The whole record behind a report: the approvals, reviews and requests for
|
|
36
|
+
* information that point at it, its version history, and the timeline across
|
|
37
|
+
* all of it.
|
|
38
|
+
*
|
|
39
|
+
* The subject an auditor usually names — and unlike a flow, it works for
|
|
40
|
+
* work that was done before flows existed. Needs every read scope.
|
|
41
|
+
*/
|
|
42
|
+
evidence(idOrSlug, signal) {
|
|
43
|
+
return this.http.request({
|
|
44
|
+
method: "GET",
|
|
45
|
+
path: `/reports/${encodeURIComponent(idOrSlug)}/evidence`,
|
|
46
|
+
signal,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
34
49
|
get(idOrSlug, signal) {
|
|
35
50
|
return this.http.request({
|
|
36
51
|
method: "GET",
|