@deliverd/sdk 0.7.0 → 0.8.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 +48 -1
- package/dist/dev.d.ts +12 -1
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.js +100 -0
- package/dist/gates.d.ts +94 -0
- package/dist/gates.d.ts.map +1 -0
- package/dist/gates.js +188 -0
- package/dist/http.js +15 -2
- package/dist/index.d.ts +37 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -0
- package/dist/released.d.ts +37 -0
- package/dist/released.d.ts.map +1 -1
- package/dist/released.js +838 -0
- package/dist/types.d.ts +78 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/dev.ts +125 -1
- package/src/gates.ts +230 -0
- package/src/http.ts +15 -2
- package/src/index.ts +59 -0
- package/src/released.ts +841 -1
- package/src/types.ts +90 -1
package/README.md
CHANGED
|
@@ -153,6 +153,7 @@ neither can be waited on for ever, which is what `await` means.
|
|
|
153
153
|
## The primitives
|
|
154
154
|
|
|
155
155
|
```ts
|
|
156
|
+
await deliverd.gate({ action, input, externalId }); // may I? — your organisation answers
|
|
156
157
|
await deliverd.approve({ title }); // ask permission, and wait for the answer
|
|
157
158
|
await deliverd.review({ title, reportId, reviewers }); // ask whether it is right
|
|
158
159
|
await deliverd.collect({ title, questions, respondents }); // ask for what you lack
|
|
@@ -160,7 +161,53 @@ await deliverd.confirm({ title }); // a yes or no on something small → boole
|
|
|
160
161
|
await deliverd.publish({ title, content }); // get the work to the people who need it
|
|
161
162
|
```
|
|
162
163
|
|
|
163
|
-
All
|
|
164
|
+
All six. Each one is a person your agent needs and cannot be — and the first is
|
|
165
|
+
the one that asks *before* the work rather than about it.
|
|
166
|
+
|
|
167
|
+
## Gating
|
|
168
|
+
|
|
169
|
+
`gate()` is the only primitive whose answer is not yours to decide. The other
|
|
170
|
+
five ask a named person something; this one asks your **organisation's policy**
|
|
171
|
+
whether the action may happen at all, and the answer comes from rules an
|
|
172
|
+
administrator wrote and your code does not see.
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
const decision = await deliverd.gate({
|
|
176
|
+
action: "finance.refund",
|
|
177
|
+
externalId: `refund:${order.id}`,
|
|
178
|
+
input: { customer_id: order.customerId, amount: 1240, currency: "GBP" },
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
if (!decision.allowed) return; // denied by a rule, or refused by a person
|
|
182
|
+
await stripe.refunds.create(decision.input);
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Three answers, one field to branch on:
|
|
186
|
+
|
|
187
|
+
| `status` | `allowed` | What happened |
|
|
188
|
+
|---|---|---|
|
|
189
|
+
| `allowed` | `true` | A rule permitted it. Go. |
|
|
190
|
+
| `denied` | `false` | A rule refused it. `reason` and `rule` say which and why — do not retry it under another name. |
|
|
191
|
+
| `approved` / `rejected` / `expired` / `cancelled` | varies | No rule settled it, so a person was asked. `gate()` waited for them. |
|
|
192
|
+
|
|
193
|
+
**Use `decision.input`, not the object you passed.** It is what the action's
|
|
194
|
+
schema validated and what an approver actually saw. Passing your original works
|
|
195
|
+
right up until somebody edits a value before approving, and then it spends an
|
|
196
|
+
approval for £1200 on a refund of £1240.
|
|
197
|
+
|
|
198
|
+
**`externalId` is required**, which no other call here is. A random
|
|
199
|
+
per-attempt key guards a retried *request*; this guards a retried *decision*. A
|
|
200
|
+
crashed agent re-running its refund step must re-read the answer it already got
|
|
201
|
+
rather than ask a second person about the same money — and no id this library
|
|
202
|
+
could invent would know which two calls are the same attempt. Retrying with the
|
|
203
|
+
same id returns the same decision, with `reused: true`.
|
|
204
|
+
|
|
205
|
+
`wait: false` returns as soon as the decision is raised, pending or not.
|
|
206
|
+
`deliverd.gates.create()` and `deliverd.gates.get(id)` are the same thing with
|
|
207
|
+
the handle exposed, for work that resumes on a webhook rather than in this call.
|
|
208
|
+
|
|
209
|
+
Try it before you have an account: `DELIVERD_DEV_OUTCOME=denied` rehearses a
|
|
210
|
+
policy refusal, which is the branch agents most often forget to write.
|
|
164
211
|
|
|
165
212
|
## Flows
|
|
166
213
|
|
package/dist/dev.d.ts
CHANGED
|
@@ -18,7 +18,18 @@ import type { ApprovalData } from "./types.js";
|
|
|
18
18
|
* the same error mapping, the same polling in `wait()`. A simulator that
|
|
19
19
|
* bypassed all that would prove your integration works against the simulator.
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* What development mode makes happen.
|
|
23
|
+
*
|
|
24
|
+
* Four for the primitives that ask a person, and a fifth for the gate:
|
|
25
|
+
* `denied` is a **policy** refusal, which nothing else can have — an approval
|
|
26
|
+
* cannot be refused without somebody refusing it. It is the outcome an agent
|
|
27
|
+
* must handle by not retrying, and rehearsing that offline is worth a word of
|
|
28
|
+
* its own. The four that involve a person mean the same thing everywhere;
|
|
29
|
+
* `denied` on an approval is treated as `rejected`, because a request nobody
|
|
30
|
+
* was asked about is not a thing that surface can represent.
|
|
31
|
+
*/
|
|
32
|
+
export type DevelopmentOutcome = "approved" | "rejected" | "denied" | "timeout" | "question";
|
|
22
33
|
export interface DevelopmentOptions {
|
|
23
34
|
/**
|
|
24
35
|
* What the imaginary approver does. Default `approved`, or the value of
|
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,EACV,YAAY,
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAMb,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;AAE7F,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,CAqd1F"}
|
package/dist/dev.js
CHANGED
|
@@ -10,6 +10,7 @@ let counter = 0;
|
|
|
10
10
|
export function developmentFetch(options = {}) {
|
|
11
11
|
const store = new Map();
|
|
12
12
|
const reviewStore = new Map();
|
|
13
|
+
const gateStore = new Map();
|
|
13
14
|
const collectionStore = new Map();
|
|
14
15
|
const flowStore = new Map();
|
|
15
16
|
return (async (input, init) => {
|
|
@@ -152,6 +153,78 @@ export function developmentFetch(options = {}) {
|
|
|
152
153
|
announceReview(data, verdict, outcome === "timeout");
|
|
153
154
|
return json(data, 201);
|
|
154
155
|
}
|
|
156
|
+
/*
|
|
157
|
+
* The gate, offline.
|
|
158
|
+
*
|
|
159
|
+
* `DELIVERD_DEV_OUTCOME` means the same thing here as everywhere else, with
|
|
160
|
+
* one addition: `denied` is a *policy* refusal, which has no equivalent on
|
|
161
|
+
* the other primitives because nothing else can be refused without a person
|
|
162
|
+
* being asked. The default stays `approved`, so `gate()` runs green out of
|
|
163
|
+
* the box and the interesting cases are the ones you opt into.
|
|
164
|
+
*
|
|
165
|
+
* `allowed` and `denied` settle instantly, as a real rule does. `approved`
|
|
166
|
+
* and `rejected` go through `pending` first, because that is the path with
|
|
167
|
+
* a `wait()` in it and the one worth being able to rehearse.
|
|
168
|
+
*/
|
|
169
|
+
if (method === "POST" && path === "/gates") {
|
|
170
|
+
const id = `gat_dev_${++counter}`;
|
|
171
|
+
const externalId = String(body.externalId ?? "");
|
|
172
|
+
/*
|
|
173
|
+
* Server-side reuse, which the real endpoint enforces in the database.
|
|
174
|
+
* Offline it is a map lookup, and it is here rather than left out
|
|
175
|
+
* because the one thing `gate()` promises over `approve()` is that a
|
|
176
|
+
* retry re-reads its decision — testing that without an account is the
|
|
177
|
+
* whole point of this file.
|
|
178
|
+
*/
|
|
179
|
+
for (const stored of gateStore.values()) {
|
|
180
|
+
if (stored.data.externalId === externalId) {
|
|
181
|
+
settleGate(stored);
|
|
182
|
+
return json({ ...stored.data.gate, reused: true });
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const outcome = resolveOutcome(options.outcome, body);
|
|
186
|
+
/*
|
|
187
|
+
* `denied` is settled by a rule and reaches nobody; everything else goes
|
|
188
|
+
* through a person, which is where `wait()` earns its place. The default
|
|
189
|
+
* `approved` therefore rehearses the escalation path rather than the
|
|
190
|
+
* auto-allow — the opposite of production's common case, and the right
|
|
191
|
+
* default here, because the path with a wait in it is the one worth
|
|
192
|
+
* being able to run before you have an account.
|
|
193
|
+
*/
|
|
194
|
+
const byRule = outcome === "denied";
|
|
195
|
+
const gate = {
|
|
196
|
+
id,
|
|
197
|
+
status: byRule ? "denied" : "pending",
|
|
198
|
+
allowed: false,
|
|
199
|
+
input: body.input ?? {},
|
|
200
|
+
basis: byRule ? "policy" : "human",
|
|
201
|
+
reason: byRule
|
|
202
|
+
? "Development mode refused it. A real rule would say which one and why."
|
|
203
|
+
: "No rule covers this action yet, so it needs a person.",
|
|
204
|
+
rule: byRule ? "Development mode" : null,
|
|
205
|
+
policyVersionId: null,
|
|
206
|
+
approvalId: byRule ? null : `apr_dev_${id}`,
|
|
207
|
+
approvalUrl: byRule ? null : `https://deliverd.dev/approve/apr_dev_${id}`,
|
|
208
|
+
outcome: null,
|
|
209
|
+
settledAt: null,
|
|
210
|
+
reused: false,
|
|
211
|
+
};
|
|
212
|
+
gateStore.set(id, {
|
|
213
|
+
data: { gate, externalId },
|
|
214
|
+
outcome,
|
|
215
|
+
decideAt: Date.now() + (options.delay ?? 0),
|
|
216
|
+
});
|
|
217
|
+
return json(gate, 201);
|
|
218
|
+
}
|
|
219
|
+
const gateMatch = /^\/gates\/([^/]+)$/.exec(path);
|
|
220
|
+
if (gateMatch && method === "GET") {
|
|
221
|
+
const stored = gateStore.get(gateMatch[1]);
|
|
222
|
+
if (!stored) {
|
|
223
|
+
return json({ error: { code: "not_found", message: "No such gate in this development session." } }, 404);
|
|
224
|
+
}
|
|
225
|
+
settleGate(stored);
|
|
226
|
+
return json(stored.data.gate);
|
|
227
|
+
}
|
|
155
228
|
const reviewMatch = /^\/reviews\/([^/]+)(\/cancel)?$/.exec(path);
|
|
156
229
|
if (reviewMatch) {
|
|
157
230
|
const stored = reviewStore.get(reviewMatch[1]);
|
|
@@ -421,6 +494,33 @@ function announce(data, outcome) {
|
|
|
421
494
|
lines.push(" │", ` │ Simulating: ${outcome}${outcome === "question" ? " (needs an onQuestion handler)" : ""}`, " └───────────────────────────────────────────────────────", "");
|
|
422
495
|
console.log(lines.join("\n"));
|
|
423
496
|
}
|
|
497
|
+
/**
|
|
498
|
+
* A gate that went to a person, once that person has answered.
|
|
499
|
+
*
|
|
500
|
+
* Only the two outcomes that involve one. `allowed` and `denied` were settled
|
|
501
|
+
* by a rule at creation and have nothing to wait for — which is the honest
|
|
502
|
+
* shape, because in production most gated calls never reach a human either.
|
|
503
|
+
*/
|
|
504
|
+
function settleGate(stored) {
|
|
505
|
+
const gate = stored.data.gate;
|
|
506
|
+
if (gate.status !== "pending")
|
|
507
|
+
return;
|
|
508
|
+
if (Date.now() < stored.decideAt)
|
|
509
|
+
return;
|
|
510
|
+
if (stored.outcome === "timeout" || stored.outcome === "question")
|
|
511
|
+
return;
|
|
512
|
+
if (stored.outcome === "denied")
|
|
513
|
+
return;
|
|
514
|
+
const approved = stored.outcome === "approved";
|
|
515
|
+
gate.status = approved ? "approved" : "rejected";
|
|
516
|
+
gate.allowed = approved;
|
|
517
|
+
gate.outcome = approved ? "approved" : "rejected";
|
|
518
|
+
gate.settledAt = new Date().toISOString();
|
|
519
|
+
gate.basis = "human";
|
|
520
|
+
gate.reason = approved
|
|
521
|
+
? "A development approver agreed to it."
|
|
522
|
+
: "A development approver refused it.";
|
|
523
|
+
}
|
|
424
524
|
/** Settle it once its moment has passed, unless it is meant to hang. */
|
|
425
525
|
function settleReview(stored) {
|
|
426
526
|
if (stored.timeout || stored.data.status !== "pending")
|
package/dist/gates.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { HttpClient } from "./http.js";
|
|
2
|
+
import type { CreateGateInput, GateData, GateDecision } from "./types.js";
|
|
3
|
+
export interface GateWaitOptions {
|
|
4
|
+
/** Give up after this many milliseconds. Without one, waits indefinitely. */
|
|
5
|
+
timeout?: number;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
/** Called on every poll, for a progress line. */
|
|
8
|
+
onPoll?: (gate: GateData) => void;
|
|
9
|
+
pollIntervals?: readonly number[];
|
|
10
|
+
}
|
|
11
|
+
export interface GateOptions extends GateWaitOptions {
|
|
12
|
+
/** The registered action: `finance.refund`. */
|
|
13
|
+
action: string;
|
|
14
|
+
input: Record<string, unknown>;
|
|
15
|
+
externalId: string;
|
|
16
|
+
environment?: string;
|
|
17
|
+
reason?: string;
|
|
18
|
+
flowId?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether to block when policy sends it to a person. Default true.
|
|
21
|
+
*
|
|
22
|
+
* False returns the pending decision immediately, which is what you want
|
|
23
|
+
* inside a request handler that must not hold a connection open for an hour.
|
|
24
|
+
* `deliverd.gates.create()` is the same thing said more plainly.
|
|
25
|
+
*/
|
|
26
|
+
wait?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A decision, and what you can do with it.
|
|
30
|
+
*
|
|
31
|
+
* The data is a snapshot; `wait()` and `refresh()` replace it in place, so a
|
|
32
|
+
* handle held across a wait reads the settled decision rather than the pending
|
|
33
|
+
* one you created.
|
|
34
|
+
*/
|
|
35
|
+
export declare class Gate {
|
|
36
|
+
private readonly http;
|
|
37
|
+
private data;
|
|
38
|
+
constructor(http: HttpClient, data: GateData);
|
|
39
|
+
get id(): string;
|
|
40
|
+
get status(): GateData["status"];
|
|
41
|
+
/**
|
|
42
|
+
* The one to branch on. True when a rule permitted it **or** a person agreed
|
|
43
|
+
* to it; false for denied, rejected, expired, cancelled and while pending.
|
|
44
|
+
* An expiry is not permission — nobody said yes.
|
|
45
|
+
*/
|
|
46
|
+
get allowed(): boolean;
|
|
47
|
+
/** Still waiting on a person. */
|
|
48
|
+
get pending(): boolean;
|
|
49
|
+
/** Refused by a rule, as against rejected by a person. */
|
|
50
|
+
get denied(): boolean;
|
|
51
|
+
/** What to execute with: the input as the action's schema validated it. */
|
|
52
|
+
get input(): Record<string, unknown>;
|
|
53
|
+
/** Why, in the words of whoever wrote the rule. */
|
|
54
|
+
get reason(): string | null;
|
|
55
|
+
/** The rule that decided, by name. Null when nothing matched it. */
|
|
56
|
+
get rule(): string | null;
|
|
57
|
+
/** Where a person decides, when one was asked. */
|
|
58
|
+
get approvalUrl(): string | null;
|
|
59
|
+
get approvalId(): string | null;
|
|
60
|
+
/** True when this call read back a decision already made under your id. */
|
|
61
|
+
get reused(): boolean;
|
|
62
|
+
/** Everything the API returned, if you want a field the getters do not name. */
|
|
63
|
+
toJSON(): GateData;
|
|
64
|
+
/** The answer, flattened — what `gate()` hands back. */
|
|
65
|
+
toDecision(): GateDecision;
|
|
66
|
+
refresh(signal?: AbortSignal): Promise<this>;
|
|
67
|
+
/**
|
|
68
|
+
* Block until a person decides, then return.
|
|
69
|
+
*
|
|
70
|
+
* Resolves on every settled state — it does not throw on a refusal, because
|
|
71
|
+
* a no is an answer and `if (gate.allowed)` is the line that should follow.
|
|
72
|
+
* It throws only when the wait itself failed: a timeout, an abort, or the
|
|
73
|
+
* API being unreachable.
|
|
74
|
+
*
|
|
75
|
+
* Returns immediately when policy already settled it, which is the common
|
|
76
|
+
* case: most gated calls are allowed or denied by a rule and never reach a
|
|
77
|
+
* person at all.
|
|
78
|
+
*/
|
|
79
|
+
wait(options?: GateWaitOptions): Promise<this>;
|
|
80
|
+
}
|
|
81
|
+
export declare class Gates {
|
|
82
|
+
private readonly http;
|
|
83
|
+
constructor(http: HttpClient);
|
|
84
|
+
/**
|
|
85
|
+
* Raise a decision and return straight away, even if it went to a person.
|
|
86
|
+
*
|
|
87
|
+
* The non-blocking half of `gate()`. Use it when the work resumes on a
|
|
88
|
+
* webhook or a later poll rather than inside this call.
|
|
89
|
+
*/
|
|
90
|
+
create(input: CreateGateInput, signal?: AbortSignal): Promise<Gate>;
|
|
91
|
+
/** One decision by its id. */
|
|
92
|
+
get(id: string, signal?: AbortSignal): Promise<Gate>;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=gates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gates.d.ts","sourceRoot":"","sources":["../src/gates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA8B1E,MAAM,WAAW,eAAe;IAC9B,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,iDAAiD;IACjD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IAClC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,UAAU,EAA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,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;OAKG;IACG,MAAM,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBzE,8BAA8B;IACxB,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ3D"}
|
package/dist/gates.js
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { DeliverdError, DeliverdTimeoutError } from "./errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* Ask before you act.
|
|
4
|
+
*
|
|
5
|
+
* The other primitives in this package are an agent asking a person to look at
|
|
6
|
+
* work it has already done. This one asks first, and the answer comes from
|
|
7
|
+
* policy the developer does not own — which is the point: what needs a human is
|
|
8
|
+
* an organisation's decision, not a line in the agent's code.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const decision = await deliverd.gate({
|
|
12
|
+
* action: "finance.refund",
|
|
13
|
+
* externalId: `refund:${order.id}`,
|
|
14
|
+
* input: { customer_id: order.customerId, amount: 1240, currency: "GBP" },
|
|
15
|
+
* });
|
|
16
|
+
* if (!decision.allowed) return;
|
|
17
|
+
* await stripe.refunds.create(decision.input);
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* **Use `decision.input`, not your own object.** It is what the action's schema
|
|
21
|
+
* validated and what an approver actually saw — and once decision tokens land
|
|
22
|
+
* it is what execution will be checked against. Passing the original is right
|
|
23
|
+
* until the day somebody edits a value before approving, and then it is a
|
|
24
|
+
* silent bug that spends an approval for £1200 on a refund of £1240.
|
|
25
|
+
*/
|
|
26
|
+
/** How long between polls while waiting on a person. */
|
|
27
|
+
const POLL_SCHEDULE = [250, 750, 2_000, 4_000, 8_000, 15_000, 30_000];
|
|
28
|
+
/**
|
|
29
|
+
* A decision, and what you can do with it.
|
|
30
|
+
*
|
|
31
|
+
* The data is a snapshot; `wait()` and `refresh()` replace it in place, so a
|
|
32
|
+
* handle held across a wait reads the settled decision rather than the pending
|
|
33
|
+
* one you created.
|
|
34
|
+
*/
|
|
35
|
+
export class Gate {
|
|
36
|
+
http;
|
|
37
|
+
data;
|
|
38
|
+
constructor(http, data) {
|
|
39
|
+
this.http = http;
|
|
40
|
+
this.data = data;
|
|
41
|
+
}
|
|
42
|
+
get id() { return this.data.id; }
|
|
43
|
+
get status() { return this.data.status; }
|
|
44
|
+
/**
|
|
45
|
+
* The one to branch on. True when a rule permitted it **or** a person agreed
|
|
46
|
+
* to it; false for denied, rejected, expired, cancelled and while pending.
|
|
47
|
+
* An expiry is not permission — nobody said yes.
|
|
48
|
+
*/
|
|
49
|
+
get allowed() { return this.data.allowed; }
|
|
50
|
+
/** Still waiting on a person. */
|
|
51
|
+
get pending() { return this.data.status === "pending"; }
|
|
52
|
+
/** Refused by a rule, as against rejected by a person. */
|
|
53
|
+
get denied() { return this.data.status === "denied"; }
|
|
54
|
+
/** What to execute with: the input as the action's schema validated it. */
|
|
55
|
+
get input() { return this.data.input; }
|
|
56
|
+
/** Why, in the words of whoever wrote the rule. */
|
|
57
|
+
get reason() { return this.data.reason; }
|
|
58
|
+
/** The rule that decided, by name. Null when nothing matched it. */
|
|
59
|
+
get rule() { return this.data.rule; }
|
|
60
|
+
/** Where a person decides, when one was asked. */
|
|
61
|
+
get approvalUrl() { return this.data.approvalUrl; }
|
|
62
|
+
get approvalId() { return this.data.approvalId; }
|
|
63
|
+
/** True when this call read back a decision already made under your id. */
|
|
64
|
+
get reused() { return this.data.reused; }
|
|
65
|
+
/** Everything the API returned, if you want a field the getters do not name. */
|
|
66
|
+
toJSON() { return this.data; }
|
|
67
|
+
/** The answer, flattened — what `gate()` hands back. */
|
|
68
|
+
toDecision() {
|
|
69
|
+
return {
|
|
70
|
+
allowed: this.data.allowed,
|
|
71
|
+
status: this.data.status,
|
|
72
|
+
reason: this.data.reason,
|
|
73
|
+
rule: this.data.rule,
|
|
74
|
+
input: this.data.input,
|
|
75
|
+
id: this.data.id,
|
|
76
|
+
approvalUrl: this.data.approvalUrl,
|
|
77
|
+
gate: this,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
async refresh(signal) {
|
|
81
|
+
this.data = await this.http.request({
|
|
82
|
+
method: "GET",
|
|
83
|
+
path: `/gates/${this.data.id}`,
|
|
84
|
+
signal,
|
|
85
|
+
});
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Block until a person decides, then return.
|
|
90
|
+
*
|
|
91
|
+
* Resolves on every settled state — it does not throw on a refusal, because
|
|
92
|
+
* a no is an answer and `if (gate.allowed)` is the line that should follow.
|
|
93
|
+
* It throws only when the wait itself failed: a timeout, an abort, or the
|
|
94
|
+
* API being unreachable.
|
|
95
|
+
*
|
|
96
|
+
* Returns immediately when policy already settled it, which is the common
|
|
97
|
+
* case: most gated calls are allowed or denied by a rule and never reach a
|
|
98
|
+
* person at all.
|
|
99
|
+
*/
|
|
100
|
+
async wait(options = {}) {
|
|
101
|
+
const deadline = options.timeout !== undefined ? Date.now() + options.timeout : undefined;
|
|
102
|
+
let poll = 0;
|
|
103
|
+
if (!this.pending)
|
|
104
|
+
return this;
|
|
105
|
+
for (;;) {
|
|
106
|
+
if (options.signal?.aborted) {
|
|
107
|
+
throw new DeliverdError(0, "aborted", "The wait was aborted.", undefined, {
|
|
108
|
+
cause: options.signal.reason,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (deadline !== undefined && Date.now() >= deadline) {
|
|
112
|
+
throw new DeliverdTimeoutError(`Nobody decided the ${this.data.rule ? `"${this.data.rule}" ` : ""}gate on ` +
|
|
113
|
+
`"${this.data.input.action ?? this.id}" within the timeout. ` +
|
|
114
|
+
(this.data.approvalUrl
|
|
115
|
+
? `It is still open at ${this.data.approvalUrl}.`
|
|
116
|
+
: "It is still open."));
|
|
117
|
+
}
|
|
118
|
+
const delay = pollDelay(poll++, options.pollIntervals ?? POLL_SCHEDULE);
|
|
119
|
+
const remaining = deadline === undefined ? delay : Math.min(delay, deadline - Date.now());
|
|
120
|
+
await sleep(Math.max(0, remaining), options.signal);
|
|
121
|
+
await this.refresh(options.signal);
|
|
122
|
+
options.onPoll?.(this.data);
|
|
123
|
+
if (!this.pending)
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/** ±25% jitter, so a fleet of agents does not poll in lockstep. */
|
|
129
|
+
function pollDelay(attempt, schedule) {
|
|
130
|
+
const base = schedule[Math.min(attempt, schedule.length - 1)] ?? 30_000;
|
|
131
|
+
return Math.round(base * (0.75 + Math.random() * 0.5));
|
|
132
|
+
}
|
|
133
|
+
function sleep(ms, signal) {
|
|
134
|
+
return new Promise((resolve, reject) => {
|
|
135
|
+
if (signal?.aborted) {
|
|
136
|
+
return reject(new DeliverdError(0, "aborted", "The wait was aborted."));
|
|
137
|
+
}
|
|
138
|
+
const timer = setTimeout(() => {
|
|
139
|
+
signal?.removeEventListener("abort", onAbort);
|
|
140
|
+
resolve();
|
|
141
|
+
}, ms);
|
|
142
|
+
const onAbort = () => {
|
|
143
|
+
clearTimeout(timer);
|
|
144
|
+
reject(new DeliverdError(0, "aborted", "The wait was aborted."));
|
|
145
|
+
};
|
|
146
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
export class Gates {
|
|
150
|
+
http;
|
|
151
|
+
constructor(http) {
|
|
152
|
+
this.http = http;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Raise a decision and return straight away, even if it went to a person.
|
|
156
|
+
*
|
|
157
|
+
* The non-blocking half of `gate()`. Use it when the work resumes on a
|
|
158
|
+
* webhook or a later poll rather than inside this call.
|
|
159
|
+
*/
|
|
160
|
+
async create(input, signal) {
|
|
161
|
+
const data = await this.http.request({
|
|
162
|
+
method: "POST",
|
|
163
|
+
path: "/gates",
|
|
164
|
+
body: input,
|
|
165
|
+
/*
|
|
166
|
+
* The caller's own id, as the HTTP idempotency key too.
|
|
167
|
+
*
|
|
168
|
+
* The server enforces reuse against `gate_requests.external_id`, so this
|
|
169
|
+
* is belt and braces rather than the mechanism — but it means a retry
|
|
170
|
+
* inside the transport layer and a retry by the caller's own code are the
|
|
171
|
+
* same key, instead of one guarding the request and the other the
|
|
172
|
+
* decision.
|
|
173
|
+
*/
|
|
174
|
+
idempotencyKey: input.externalId,
|
|
175
|
+
signal,
|
|
176
|
+
});
|
|
177
|
+
return new Gate(this.http, data);
|
|
178
|
+
}
|
|
179
|
+
/** One decision by its id. */
|
|
180
|
+
async get(id, signal) {
|
|
181
|
+
const data = await this.http.request({
|
|
182
|
+
method: "GET",
|
|
183
|
+
path: `/gates/${id}`,
|
|
184
|
+
signal,
|
|
185
|
+
});
|
|
186
|
+
return new Gate(this.http, data);
|
|
187
|
+
}
|
|
188
|
+
}
|
package/dist/http.js
CHANGED
|
@@ -117,9 +117,22 @@ export class HttpClient {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
export const USER_AGENT = "deliverd-sdk";
|
|
120
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* A 5xx the server might get right next time. 501 is not one of them: it means
|
|
122
|
+
* the call is not built, which is a fact about the server rather than about
|
|
123
|
+
* this moment — the same argument as a 4xx.
|
|
124
|
+
*
|
|
125
|
+
* Ported from the Python SDK, which found it first and where the symptom was a
|
|
126
|
+
* development-mode call taking two and a half seconds to say three times that
|
|
127
|
+
* it is not implemented. The fix was never brought back here, and nothing
|
|
128
|
+
* compared the two until `packages/conformance/cases.json` existed.
|
|
129
|
+
*/
|
|
130
|
+
const RETRYABLE_5XX_EXCEPTIONS = new Set([501]);
|
|
131
|
+
/** 429 and most 5xx: a 4xx will be just as wrong on the next attempt. */
|
|
121
132
|
function isRetryable(status) {
|
|
122
|
-
|
|
133
|
+
if (status === 429)
|
|
134
|
+
return true;
|
|
135
|
+
return status >= 500 && !RETRYABLE_5XX_EXCEPTIONS.has(status);
|
|
123
136
|
}
|
|
124
137
|
function parseRetryAfter(header) {
|
|
125
138
|
if (!header)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HttpClient, type ClientOptions } from "./http.js";
|
|
2
2
|
import { Approvals, type WaitOptions } from "./approvals.js";
|
|
3
|
+
import { Gates, type GateOptions } from "./gates.js";
|
|
3
4
|
import { Comments, Reports, Schedules } from "./reports.js";
|
|
4
5
|
import { Reviews, type ReviewWaitOptions } from "./reviews.js";
|
|
5
6
|
import { Collections, type CollectWaitOptions } from "./collections.js";
|
|
@@ -7,8 +8,9 @@ import { Flows } from "./flows.js";
|
|
|
7
8
|
import { Webhooks } from "./webhooks.js";
|
|
8
9
|
import { type DevelopmentOptions } from "./dev.js";
|
|
9
10
|
import { type Duration } from "./duration.js";
|
|
10
|
-
import type { CollectedAnswers, CreateApprovalInput, CreateCollectionInput, CreateReviewInput, Decision, PublishReportInput, PublishResult, ReviewOutcome } from "./types.js";
|
|
11
|
+
import type { CollectedAnswers, CreateApprovalInput, CreateCollectionInput, CreateReviewInput, Decision, GateDecision, PublishReportInput, PublishResult, ReviewOutcome } from "./types.js";
|
|
11
12
|
export { Approval, Approvals, POLL_SCHEDULE, type WaitOptions } from "./approvals.js";
|
|
13
|
+
export { Gate, Gates, type GateOptions, type GateWaitOptions } from "./gates.js";
|
|
12
14
|
export { Comments, Reports, Schedules } from "./reports.js";
|
|
13
15
|
export { Review, Reviews, type ReviewWaitOptions } from "./reviews.js";
|
|
14
16
|
export { Collection, Collections, type CollectWaitOptions } from "./collections.js";
|
|
@@ -108,6 +110,7 @@ export interface CollectOptions extends Omit<CreateCollectionInput, "expiresAt">
|
|
|
108
110
|
*/
|
|
109
111
|
export declare class Deliverd {
|
|
110
112
|
readonly approvals: Approvals;
|
|
113
|
+
readonly gates: Gates;
|
|
111
114
|
readonly reviews: Reviews;
|
|
112
115
|
readonly collections: Collections;
|
|
113
116
|
readonly flows: Flows;
|
|
@@ -131,6 +134,39 @@ export declare class Deliverd {
|
|
|
131
134
|
* ends.
|
|
132
135
|
*/
|
|
133
136
|
approve(options: ApproveOptions): Promise<Decision>;
|
|
137
|
+
/**
|
|
138
|
+
* Ask whether to act, and wait if a person has to decide.
|
|
139
|
+
*
|
|
140
|
+
* The other primitives ask a person to look at work already done. This one
|
|
141
|
+
* asks first, and the answer comes from **policy the developer does not
|
|
142
|
+
* own** — which is the whole point: what needs a human is an organisation's
|
|
143
|
+
* decision, not a line in your code. Most calls never reach a person at all,
|
|
144
|
+
* because a rule already settles them.
|
|
145
|
+
*
|
|
146
|
+
* ```ts
|
|
147
|
+
* const decision = await deliverd.gate({
|
|
148
|
+
* action: "finance.refund",
|
|
149
|
+
* externalId: `refund:${order.id}`,
|
|
150
|
+
* input: { customer_id: order.customerId, amount: 1240, currency: "GBP" },
|
|
151
|
+
* });
|
|
152
|
+
* if (!decision.allowed) return;
|
|
153
|
+
* await stripe.refunds.create(decision.input);
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* **Execute with `decision.input`, not your own object.** It is what the
|
|
157
|
+
* action's schema validated and what an approver actually saw. Passing the
|
|
158
|
+
* original works right up until somebody edits a value before approving, and
|
|
159
|
+
* then it spends an approval for £1200 on a refund of £1240.
|
|
160
|
+
*
|
|
161
|
+
* It does not throw on a refusal — a no is an answer, and `if
|
|
162
|
+
* (decision.allowed)` is the line that follows. It throws when the action is
|
|
163
|
+
* not registered, when the input does not match its schema, or when the wait
|
|
164
|
+
* itself failed.
|
|
165
|
+
*
|
|
166
|
+
* `wait: false` returns a pending decision immediately; `deliverd.gates`
|
|
167
|
+
* is the same thing with the handle exposed.
|
|
168
|
+
*/
|
|
169
|
+
gate(options: GateOptions): Promise<GateDecision>;
|
|
134
170
|
/**
|
|
135
171
|
* A yes or no on something small: same mechanism, lower ceremony.
|
|
136
172
|
*
|
package/dist/index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