@deliverd/sdk 0.13.0 → 0.15.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 +83 -3
- package/dist/approvals.d.ts +17 -1
- package/dist/approvals.d.ts.map +1 -1
- package/dist/approvals.js +36 -1
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.js +5 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/released.d.ts +1 -1
- package/dist/released.d.ts.map +1 -1
- package/dist/released.js +1566 -0
- package/dist/types.d.ts +160 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/webhook-endpoints.d.ts +57 -0
- package/dist/webhook-endpoints.d.ts.map +1 -0
- package/dist/webhook-endpoints.js +94 -0
- package/package.json +1 -1
- package/src/approvals.ts +43 -1
- package/src/dev.ts +4 -0
- package/src/index.ts +9 -2
- package/src/released.ts +1566 -0
- package/src/types.ts +171 -0
- package/src/webhook-endpoints.ts +115 -0
package/README.md
CHANGED
|
@@ -284,9 +284,29 @@ context.reanchor // one paragraph to say back to yourse
|
|
|
284
284
|
```
|
|
285
285
|
|
|
286
286
|
`task.context()` is what to read instead of the history: the objective, where
|
|
287
|
-
this task stands, what is settled, what is still open
|
|
288
|
-
|
|
289
|
-
tasks
|
|
287
|
+
this task stands, what is settled, what is still open, and the reports already
|
|
288
|
+
published for it. `task.graph()` is the whole tree.
|
|
289
|
+
`deliverd.tasks.list({ status: "active" })` lists objectives; side tasks are
|
|
290
|
+
reached through the one they belong to.
|
|
291
|
+
|
|
292
|
+
A status report is written from that context and kept with the task:
|
|
293
|
+
|
|
294
|
+
```ts
|
|
295
|
+
const context = await task.context();
|
|
296
|
+
const html = renderStatus(context); // your own: objective, state, decisions, what is open
|
|
297
|
+
|
|
298
|
+
const [existing] = context.reports; // newest first
|
|
299
|
+
if (existing) {
|
|
300
|
+
await deliverd.reports.update(existing.id, { content: html, changeSummary: "This week" });
|
|
301
|
+
} else {
|
|
302
|
+
await deliverd.reports.publish({ title: "SSO rollout: status", content: html, taskId: task.id });
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
The report is then listed on the task's page and in its context, so the next
|
|
307
|
+
status report is a new version of it rather than a second one. A later
|
|
308
|
+
publish naming another `taskId` moves it there; leaving `taskId` out keeps it
|
|
309
|
+
where it is. It needs `tasks:read` on the key.
|
|
290
310
|
|
|
291
311
|
A finding of kind `decision` is a suggestion until a person confirms it.
|
|
292
312
|
`task.requestDecisionApproval(findingId)` puts it to somebody. Only a person
|
|
@@ -530,6 +550,29 @@ returns a boolean if you would rather branch. The scheme is Stripe's — a
|
|
|
530
550
|
timestamp and an HMAC in one header, the timestamp inside the signed material,
|
|
531
551
|
five minutes of tolerance — so anything you have written before will work too.
|
|
532
552
|
|
|
553
|
+
## Webhook endpoints
|
|
554
|
+
|
|
555
|
+
Add, change and remove the endpoints themselves from code, rather than under
|
|
556
|
+
Admin → Webhooks. The secret comes back from `create()` **once** — no other
|
|
557
|
+
call returns it — so store it where your receiver reads it.
|
|
558
|
+
|
|
559
|
+
```ts
|
|
560
|
+
const endpoint = await deliverd.webhookEndpoints.create({
|
|
561
|
+
url: "https://hooks.example.com/deliverd",
|
|
562
|
+
events: ["approval.approved", "approval.rejected"], // leave out for everything
|
|
563
|
+
});
|
|
564
|
+
await saveSecret(endpoint.secret);
|
|
565
|
+
|
|
566
|
+
const { delivered, responseStatus } = await deliverd.webhookEndpoints.test(endpoint.id);
|
|
567
|
+
await deliverd.webhookEndpoints.update(endpoint.id, { enabled: false });
|
|
568
|
+
const all = await deliverd.webhookEndpoints.list();
|
|
569
|
+
await deliverd.webhookEndpoints.delete(endpoint.id);
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
These need a key with `webhooks:manage` held by an owner or an administrator
|
|
573
|
+
— the people who can do it in the console. An **agent key is refused**, reads
|
|
574
|
+
included: an endpoint receives every event in the organisation.
|
|
575
|
+
|
|
533
576
|
## Approving with changes
|
|
534
577
|
|
|
535
578
|
Send what you will act on as `input`, and say which fields a person may
|
|
@@ -573,6 +616,43 @@ const envelope = constructCallback(secret, rawBody, req.header("deliverd-signatu
|
|
|
573
616
|
For code that should not hold a process open while a person decides: a
|
|
574
617
|
serverless function, a durable workflow, a paused graph.
|
|
575
618
|
|
|
619
|
+
## Inside your own product
|
|
620
|
+
|
|
621
|
+
The approver can decide without leaving your app. A decision session is a page
|
|
622
|
+
for one approver on one request: hosted, like a checkout page, or mounted in
|
|
623
|
+
your own UI. It shows the request; it never decides it — the approver signs
|
|
624
|
+
in, or confirms a code sent to their own address, before they can.
|
|
625
|
+
|
|
626
|
+
```ts
|
|
627
|
+
// Server: a page to send them to, and back again afterwards.
|
|
628
|
+
const session = await deliverd.approvals.createSession(approval.id, {
|
|
629
|
+
approver: "sarah@acme.com",
|
|
630
|
+
mode: "hosted",
|
|
631
|
+
returnUrl: "https://app.acme.com/refunds/1240",
|
|
632
|
+
});
|
|
633
|
+
redirect(session.url!); // returned once
|
|
634
|
+
|
|
635
|
+
// Or a frame in your own page. The origin must be on the organisation's
|
|
636
|
+
// embedding allow-list (Admin → Security → Embedding), or http://localhost.
|
|
637
|
+
const embedded = await deliverd.approvals.createSession(approval.id, {
|
|
638
|
+
approver: "sarah@acme.com",
|
|
639
|
+
mode: "embedded",
|
|
640
|
+
origin: "https://app.acme.com",
|
|
641
|
+
});
|
|
642
|
+
// Hand embedded.clientSecret to the browser, then:
|
|
643
|
+
// <script src="https://deliverd.dev/elements/v1.js"></script>
|
|
644
|
+
// Deliverd.mountDecision("#decision", { clientSecret, onDecided(e) { … } });
|
|
645
|
+
|
|
646
|
+
// Afterwards, from your server — never trust the browser's word for it:
|
|
647
|
+
const done = await deliverd.decisionSessions.get(embedded.id);
|
|
648
|
+
done.status; // "complete"
|
|
649
|
+
done.decision; // "approved"
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
`deliverd.approvals.list({ approver: "sarah@acme.com", status: "pending" })` is
|
|
653
|
+
her inbox, to show in your own UI. `deliverd.decisionSessions.expire(id)` ends a
|
|
654
|
+
session early.
|
|
655
|
+
|
|
576
656
|
## Inside your agent framework
|
|
577
657
|
|
|
578
658
|
`@deliverd/sdk/adapters` plugs Deliverd into the approval hook each framework
|
package/dist/approvals.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type PageOf } from "./paging.js";
|
|
2
2
|
import type { HttpClient } from "./http.js";
|
|
3
|
-
import type { ApprovalData, ApprovalQuestion, CreateApprovalInput, Decision, FieldChange, ListApprovalsInput } from "./types.js";
|
|
3
|
+
import type { ApprovalData, ApprovalQuestion, CreateApprovalInput, Decision, FieldChange, ListApprovalsInput, CreateDecisionSessionInput, DecisionSession } from "./types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Ask a person before you act.
|
|
6
6
|
*
|
|
@@ -155,5 +155,21 @@ export declare class Approvals {
|
|
|
155
155
|
* server work, not something a client can promise.
|
|
156
156
|
*/
|
|
157
157
|
findByExternalId(externalId: string, signal?: AbortSignal): Promise<Approval | null>;
|
|
158
|
+
/**
|
|
159
|
+
* A page on which one approver decides this request, inside your product.
|
|
160
|
+
*
|
|
161
|
+
* Keep `url` or `clientSecret` for the person in front of you: they are
|
|
162
|
+
* returned once. Neither decides anything — the approver signs in, or
|
|
163
|
+
* confirms a code sent to their own address, before they can.
|
|
164
|
+
*/
|
|
165
|
+
createSession(approvalId: string, input: CreateDecisionSessionInput, signal?: AbortSignal): Promise<DecisionSession>;
|
|
166
|
+
}
|
|
167
|
+
/** Decision sessions, after they are made: where they stand, and ending one early. */
|
|
168
|
+
export declare class DecisionSessions {
|
|
169
|
+
private readonly http;
|
|
170
|
+
constructor(http: HttpClient);
|
|
171
|
+
get(id: string, signal?: AbortSignal): Promise<DecisionSession>;
|
|
172
|
+
/** End it now. A decision already made through it stays made. */
|
|
173
|
+
expire(id: string, signal?: AbortSignal): Promise<DecisionSession>;
|
|
158
174
|
}
|
|
159
175
|
//# sourceMappingURL=approvals.d.ts.map
|
package/dist/approvals.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approvals.d.ts","sourceRoot":"","sources":["../src/approvals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,kBAAkB,
|
|
1
|
+
{"version":3,"file":"approvals.d.ts","sourceRoot":"","sources":["../src/approvals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;GAQG;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,qDAA2D,CAAC;AAGtF,2EAA2E;AAC3E,eAAO,MAAM,kBAAkB,4BAA6B,CAAC;AAQ7D,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,YAAY,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IAC5G,6DAA6D;IAC7D,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;OAGG;IACH,a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GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAK1F;;;;;;OAMG;IACG,aAAa,CACjB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,0BAA0B,EACjC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,eAAe,CAAC;CAQ5B;AAED,sFAAsF;AACtF,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAEvC,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC;IAIrE,iEAAiE;IAC3D,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC;CAGzE"}
|
package/dist/approvals.js
CHANGED
|
@@ -244,7 +244,13 @@ export class Approvals {
|
|
|
244
244
|
const { approvals, nextCursor } = await this.http.request({
|
|
245
245
|
method: "GET",
|
|
246
246
|
path: "/approvals",
|
|
247
|
-
query: {
|
|
247
|
+
query: {
|
|
248
|
+
status: input.status,
|
|
249
|
+
externalId: input.externalId,
|
|
250
|
+
approver: input.approver,
|
|
251
|
+
limit: input.limit,
|
|
252
|
+
cursor: input.cursor,
|
|
253
|
+
},
|
|
248
254
|
signal,
|
|
249
255
|
});
|
|
250
256
|
return { items: approvals.map((r) => new Approval(this.http, r)), nextCursor };
|
|
@@ -272,4 +278,33 @@ export class Approvals {
|
|
|
272
278
|
const found = await this.list({ externalId, limit: 1 }, signal);
|
|
273
279
|
return found[0] ?? null;
|
|
274
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* A page on which one approver decides this request, inside your product.
|
|
283
|
+
*
|
|
284
|
+
* Keep `url` or `clientSecret` for the person in front of you: they are
|
|
285
|
+
* returned once. Neither decides anything — the approver signs in, or
|
|
286
|
+
* confirms a code sent to their own address, before they can.
|
|
287
|
+
*/
|
|
288
|
+
async createSession(approvalId, input, signal) {
|
|
289
|
+
return this.http.request({
|
|
290
|
+
method: "POST",
|
|
291
|
+
path: `/approvals/${approvalId}/sessions`,
|
|
292
|
+
body: input,
|
|
293
|
+
signal,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
/** Decision sessions, after they are made: where they stand, and ending one early. */
|
|
298
|
+
export class DecisionSessions {
|
|
299
|
+
http;
|
|
300
|
+
constructor(http) {
|
|
301
|
+
this.http = http;
|
|
302
|
+
}
|
|
303
|
+
async get(id, signal) {
|
|
304
|
+
return this.http.request({ method: "GET", path: `/decision-sessions/${id}`, signal });
|
|
305
|
+
}
|
|
306
|
+
/** End it now. A decision already made through it stays made. */
|
|
307
|
+
async expire(id, signal) {
|
|
308
|
+
return this.http.request({ method: "POST", path: `/decision-sessions/${id}/expire`, signal });
|
|
309
|
+
}
|
|
275
310
|
}
|
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,EAWb,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;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,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,
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAWb,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;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,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,CA2kB1F"}
|
package/dist/dev.js
CHANGED
|
@@ -338,6 +338,7 @@ export function developmentFetch(options = {}) {
|
|
|
338
338
|
if (method === "GET" && path === "/approvals") {
|
|
339
339
|
const externalId = url.searchParams.get("externalId");
|
|
340
340
|
const status = url.searchParams.get("status");
|
|
341
|
+
const approver = url.searchParams.get("approver")?.toLowerCase();
|
|
341
342
|
// Settle first: a caller listing before polling should see the same
|
|
342
343
|
// state a poll would have shown it, not a stale `pending`.
|
|
343
344
|
for (const stored of store.values())
|
|
@@ -347,6 +348,8 @@ export function developmentFetch(options = {}) {
|
|
|
347
348
|
all = all.filter((a) => a.externalId === externalId);
|
|
348
349
|
if (status)
|
|
349
350
|
all = all.filter((a) => a.status === status);
|
|
351
|
+
if (approver)
|
|
352
|
+
all = all.filter((a) => a.approvers.some((who) => who.toLowerCase() === approver));
|
|
350
353
|
return json({ approvals: all });
|
|
351
354
|
}
|
|
352
355
|
if (method === "GET" && path === "/reviews") {
|
|
@@ -889,6 +892,8 @@ function developmentTasks(options) {
|
|
|
889
892
|
.filter((c) => c.outcome !== null)
|
|
890
893
|
.map((c) => ({ id: c.id, title: c.title, summary: c.result?.summary ?? null, outcome: c.outcome })),
|
|
891
894
|
},
|
|
895
|
+
// Development mode publishes nothing, so no task has a report to name.
|
|
896
|
+
reports: [],
|
|
892
897
|
reanchor: [
|
|
893
898
|
`Objective: ${root.objective}`,
|
|
894
899
|
isSideTask ? `You are in a side task: ${t.title}. Its goal: ${t.objective}` : null,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpClient, type ClientOptions } from "./http.js";
|
|
2
|
-
import { Approvals, type WaitOptions } from "./approvals.js";
|
|
2
|
+
import { Approvals, DecisionSessions, type WaitOptions } from "./approvals.js";
|
|
3
3
|
import { Gates, type GateOptions } from "./gates.js";
|
|
4
4
|
import { Comments, Reports, Schedules } from "./reports.js";
|
|
5
5
|
import { Reviews, type ReviewWaitOptions } from "./reviews.js";
|
|
@@ -7,16 +7,18 @@ import { Collections, type CollectWaitOptions } from "./collections.js";
|
|
|
7
7
|
import { Flows } from "./flows.js";
|
|
8
8
|
import { Tasks } from "./tasks.js";
|
|
9
9
|
import { Webhooks } from "./webhooks.js";
|
|
10
|
+
import { WebhookEndpoints } from "./webhook-endpoints.js";
|
|
10
11
|
import { type DevelopmentOptions } from "./dev.js";
|
|
11
12
|
import { type Duration } from "./duration.js";
|
|
12
13
|
import type { CollectedAnswers, CreateApprovalInput, CreateCollectionInput, CreateReviewInput, Decision, GateDecision, PublishReportInput, PublishResult, ReviewOutcome } from "./types.js";
|
|
13
|
-
export { Approval, Approvals, POLL_SCHEDULE, type WaitOptions } from "./approvals.js";
|
|
14
|
+
export { Approval, Approvals, DecisionSessions, POLL_SCHEDULE, type WaitOptions } from "./approvals.js";
|
|
14
15
|
export { Gate, Gates, type GateOptions, type GateWaitOptions } from "./gates.js";
|
|
15
16
|
export { Comments, Reports, Schedules } from "./reports.js";
|
|
16
17
|
export { Review, Reviews, type ReviewWaitOptions } from "./reviews.js";
|
|
17
18
|
export { Collection, Collections, type CollectWaitOptions } from "./collections.js";
|
|
18
19
|
export { Flow, Flows, type FlowPrimitives } from "./flows.js";
|
|
19
20
|
export { Task, Tasks } from "./tasks.js";
|
|
21
|
+
export { WebhookEndpoints } from "./webhook-endpoints.js";
|
|
20
22
|
export { constructCallback, constructEvent, DELIVERY_HEADER, EVENT_HEADER, SIGNATURE_HEADER, TOLERANCE_SECONDS, verifySignature, Webhooks, } from "./webhooks.js";
|
|
21
23
|
export { DeliverdError, DeliverdTimeoutError } from "./errors.js";
|
|
22
24
|
export { DEFAULT_BASE_URL, type ClientOptions } from "./http.js";
|
|
@@ -112,6 +114,8 @@ export interface CollectOptions extends Omit<CreateCollectionInput, "expiresAt">
|
|
|
112
114
|
*/
|
|
113
115
|
export declare class Deliverd {
|
|
114
116
|
readonly approvals: Approvals;
|
|
117
|
+
/** Pages on which an approver decides inside your product: `approvals.createSession` makes one. */
|
|
118
|
+
readonly decisionSessions: DecisionSessions;
|
|
115
119
|
readonly gates: Gates;
|
|
116
120
|
readonly reviews: Reviews;
|
|
117
121
|
readonly collections: Collections;
|
|
@@ -121,6 +125,7 @@ export declare class Deliverd {
|
|
|
121
125
|
readonly comments: Comments;
|
|
122
126
|
readonly schedules: Schedules;
|
|
123
127
|
readonly webhooks: Webhooks;
|
|
128
|
+
readonly webhookEndpoints: WebhookEndpoints;
|
|
124
129
|
readonly http: HttpClient;
|
|
125
130
|
/** Whether an imaginary approver is deciding these. */
|
|
126
131
|
readonly development: boolean;
|
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;
|
|
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,EAAE,gBAAgB,EAAsB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACnG,OAAO,EAAE,KAAK,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC5D,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,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAoB,KAAK,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,qBAAq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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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpClient } from "./http.js";
|
|
2
|
-
import { Approvals, FAST_POLL_SCHEDULE } from "./approvals.js";
|
|
2
|
+
import { Approvals, DecisionSessions, FAST_POLL_SCHEDULE } from "./approvals.js";
|
|
3
3
|
import { Gates } from "./gates.js";
|
|
4
4
|
import { Comments, Reports, Schedules } from "./reports.js";
|
|
5
5
|
import { Reviews } from "./reviews.js";
|
|
@@ -7,15 +7,17 @@ import { Collections } from "./collections.js";
|
|
|
7
7
|
import { Flows } from "./flows.js";
|
|
8
8
|
import { Tasks } from "./tasks.js";
|
|
9
9
|
import { Webhooks } from "./webhooks.js";
|
|
10
|
+
import { WebhookEndpoints } from "./webhook-endpoints.js";
|
|
10
11
|
import { developmentFetch } from "./dev.js";
|
|
11
12
|
import { durationMs } from "./duration.js";
|
|
12
|
-
export { Approval, Approvals, POLL_SCHEDULE } from "./approvals.js";
|
|
13
|
+
export { Approval, Approvals, DecisionSessions, POLL_SCHEDULE } from "./approvals.js";
|
|
13
14
|
export { Gate, Gates } from "./gates.js";
|
|
14
15
|
export { Comments, Reports, Schedules } from "./reports.js";
|
|
15
16
|
export { Review, Reviews } from "./reviews.js";
|
|
16
17
|
export { Collection, Collections } from "./collections.js";
|
|
17
18
|
export { Flow, Flows } from "./flows.js";
|
|
18
19
|
export { Task, Tasks } from "./tasks.js";
|
|
20
|
+
export { WebhookEndpoints } from "./webhook-endpoints.js";
|
|
19
21
|
export { constructCallback, constructEvent, DELIVERY_HEADER, EVENT_HEADER, SIGNATURE_HEADER, TOLERANCE_SECONDS, verifySignature, Webhooks, } from "./webhooks.js";
|
|
20
22
|
export { DeliverdError, DeliverdTimeoutError } from "./errors.js";
|
|
21
23
|
export { DEFAULT_BASE_URL } from "./http.js";
|
|
@@ -43,6 +45,8 @@ export const DEFAULT_EXPIRY = "24h";
|
|
|
43
45
|
*/
|
|
44
46
|
export class Deliverd {
|
|
45
47
|
approvals;
|
|
48
|
+
/** Pages on which an approver decides inside your product: `approvals.createSession` makes one. */
|
|
49
|
+
decisionSessions;
|
|
46
50
|
gates;
|
|
47
51
|
reviews;
|
|
48
52
|
collections;
|
|
@@ -52,6 +56,7 @@ export class Deliverd {
|
|
|
52
56
|
comments;
|
|
53
57
|
schedules;
|
|
54
58
|
webhooks;
|
|
59
|
+
webhookEndpoints;
|
|
55
60
|
http;
|
|
56
61
|
/** Whether an imaginary approver is deciding these. */
|
|
57
62
|
development;
|
|
@@ -66,6 +71,7 @@ export class Deliverd {
|
|
|
66
71
|
fetch: this.development ? developmentFetch(options.development) : options.fetch,
|
|
67
72
|
});
|
|
68
73
|
this.approvals = new Approvals(this.http);
|
|
74
|
+
this.decisionSessions = new DecisionSessions(this.http);
|
|
69
75
|
this.gates = new Gates(this.http);
|
|
70
76
|
this.reviews = new Reviews(this.http);
|
|
71
77
|
this.collections = new Collections(this.http);
|
|
@@ -80,6 +86,7 @@ export class Deliverd {
|
|
|
80
86
|
this.comments = new Comments(this.http);
|
|
81
87
|
this.schedules = new Schedules(this.http);
|
|
82
88
|
this.webhooks = new Webhooks();
|
|
89
|
+
this.webhookEndpoints = new WebhookEndpoints(this.http);
|
|
83
90
|
}
|
|
84
91
|
/**
|
|
85
92
|
* Ask a person, and wait for the answer.
|
package/dist/released.d.ts
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
* **Add the version here when you publish it, not before.** An entry is a
|
|
44
44
|
* claim that `npm install @deliverd/sdk@x` works today.
|
|
45
45
|
*/
|
|
46
|
-
export declare const PUBLISHED_TO_NPM: readonly ["0.1.0", "0.2.0", "0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.6.2", "0.7.0", "0.7.1", "0.8.0", "0.8.1", "0.8.2", "0.9.0", "0.10.0", "0.11.0", "0.11.1", "0.12.0"];
|
|
46
|
+
export declare const PUBLISHED_TO_NPM: readonly ["0.1.0", "0.2.0", "0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.6.2", "0.7.0", "0.7.1", "0.8.0", "0.8.1", "0.8.2", "0.9.0", "0.10.0", "0.11.0", "0.11.1", "0.12.0", "0.13.0", "0.14.0"];
|
|
47
47
|
/**
|
|
48
48
|
* A fingerprint of what each *published* version recorded.
|
|
49
49
|
*
|
package/dist/released.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"released.d.ts","sourceRoot":"","sources":["../src/released.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"released.d.ts","sourceRoot":"","sources":["../src/released.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,qMAqBnB,CAAC;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA8DzC,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAoxNtD,CAAC"}
|