@deliverd/sdk 0.14.0 → 0.16.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 +65 -4
- 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 +3 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- package/dist/released.d.ts +1 -1
- package/dist/released.d.ts.map +1 -1
- package/dist/released.js +1634 -0
- package/dist/reports.d.ts +9 -3
- package/dist/reports.d.ts.map +1 -1
- package/dist/reports.js +14 -3
- package/dist/types.d.ts +140 -0
- 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 +2 -0
- package/src/index.ts +10 -3
- package/src/released.ts +1634 -0
- package/src/reports.ts +20 -3
- package/src/types.ts +152 -0
- package/src/webhook-endpoints.ts +115 -0
package/README.md
CHANGED
|
@@ -161,8 +161,8 @@ await deliverd.confirm({ title }); // a yes or no on something small → boole
|
|
|
161
161
|
await deliverd.publish({ title, content }); // get the work to the people who need it
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
the one that asks *before* the work rather than about it.
|
|
164
|
+
Six primitives, one API. Each one is a person your agent needs and cannot be —
|
|
165
|
+
and the first is the one that asks *before* the work rather than about it.
|
|
166
166
|
|
|
167
167
|
## Gating
|
|
168
168
|
|
|
@@ -457,8 +457,8 @@ nothing.
|
|
|
457
457
|
|
|
458
458
|
## Publishing
|
|
459
459
|
|
|
460
|
-
The
|
|
461
|
-
|
|
460
|
+
The sixth primitive: get what your agent wrote to the people who need it, at
|
|
461
|
+
an address that does not change.
|
|
462
462
|
|
|
463
463
|
```ts
|
|
464
464
|
const { report } = await deliverd.reports.publish({
|
|
@@ -470,6 +470,7 @@ console.log(report.url);
|
|
|
470
470
|
|
|
471
471
|
await deliverd.reports.update(report.id, { content: revised, changeSummary: "…" });
|
|
472
472
|
await deliverd.reports.share(report.id, "sarah@client.example");
|
|
473
|
+
await deliverd.reports.share(report.id, "Finance team", { capability: "comment" });
|
|
473
474
|
|
|
474
475
|
// Sharing grants access to people the organisation knows. Sending reaches
|
|
475
476
|
// addresses it has never seen, and says something alongside the link.
|
|
@@ -550,6 +551,29 @@ returns a boolean if you would rather branch. The scheme is Stripe's — a
|
|
|
550
551
|
timestamp and an HMAC in one header, the timestamp inside the signed material,
|
|
551
552
|
five minutes of tolerance — so anything you have written before will work too.
|
|
552
553
|
|
|
554
|
+
## Webhook endpoints
|
|
555
|
+
|
|
556
|
+
Add, change and remove the endpoints themselves from code, rather than under
|
|
557
|
+
Admin → Webhooks. The secret comes back from `create()` **once** — no other
|
|
558
|
+
call returns it — so store it where your receiver reads it.
|
|
559
|
+
|
|
560
|
+
```ts
|
|
561
|
+
const endpoint = await deliverd.webhookEndpoints.create({
|
|
562
|
+
url: "https://hooks.example.com/deliverd",
|
|
563
|
+
events: ["approval.approved", "approval.rejected"], // leave out for everything
|
|
564
|
+
});
|
|
565
|
+
await saveSecret(endpoint.secret);
|
|
566
|
+
|
|
567
|
+
const { delivered, responseStatus } = await deliverd.webhookEndpoints.test(endpoint.id);
|
|
568
|
+
await deliverd.webhookEndpoints.update(endpoint.id, { enabled: false });
|
|
569
|
+
const all = await deliverd.webhookEndpoints.list();
|
|
570
|
+
await deliverd.webhookEndpoints.delete(endpoint.id);
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
These need a key with `webhooks:manage` held by an owner or an administrator
|
|
574
|
+
— the people who can do it in the console. An **agent key is refused**, reads
|
|
575
|
+
included: an endpoint receives every event in the organisation.
|
|
576
|
+
|
|
553
577
|
## Approving with changes
|
|
554
578
|
|
|
555
579
|
Send what you will act on as `input`, and say which fields a person may
|
|
@@ -593,6 +617,43 @@ const envelope = constructCallback(secret, rawBody, req.header("deliverd-signatu
|
|
|
593
617
|
For code that should not hold a process open while a person decides: a
|
|
594
618
|
serverless function, a durable workflow, a paused graph.
|
|
595
619
|
|
|
620
|
+
## Inside your own product
|
|
621
|
+
|
|
622
|
+
The approver can decide without leaving your app. A decision session is a page
|
|
623
|
+
for one approver on one request: hosted, like a checkout page, or mounted in
|
|
624
|
+
your own UI. It shows the request; it never decides it — the approver signs
|
|
625
|
+
in, or confirms a code sent to their own address, before they can.
|
|
626
|
+
|
|
627
|
+
```ts
|
|
628
|
+
// Server: a page to send them to, and back again afterwards.
|
|
629
|
+
const session = await deliverd.approvals.createSession(approval.id, {
|
|
630
|
+
approver: "sarah@acme.com",
|
|
631
|
+
mode: "hosted",
|
|
632
|
+
returnUrl: "https://app.acme.com/refunds/1240",
|
|
633
|
+
});
|
|
634
|
+
redirect(session.url!); // returned once
|
|
635
|
+
|
|
636
|
+
// Or a frame in your own page. The origin must be on the organisation's
|
|
637
|
+
// embedding allow-list (Admin → Security → Embedding), or http://localhost.
|
|
638
|
+
const embedded = await deliverd.approvals.createSession(approval.id, {
|
|
639
|
+
approver: "sarah@acme.com",
|
|
640
|
+
mode: "embedded",
|
|
641
|
+
origin: "https://app.acme.com",
|
|
642
|
+
});
|
|
643
|
+
// Hand embedded.clientSecret to the browser, then:
|
|
644
|
+
// <script src="https://deliverd.dev/elements/v1.js"></script>
|
|
645
|
+
// Deliverd.mountDecision("#decision", { clientSecret, onDecided(e) { … } });
|
|
646
|
+
|
|
647
|
+
// Afterwards, from your server — never trust the browser's word for it:
|
|
648
|
+
const done = await deliverd.decisionSessions.get(embedded.id);
|
|
649
|
+
done.status; // "complete"
|
|
650
|
+
done.decision; // "approved"
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
`deliverd.approvals.list({ approver: "sarah@acme.com", status: "pending" })` is
|
|
654
|
+
her inbox, to show in your own UI. `deliverd.decisionSessions.expire(id)` ends a
|
|
655
|
+
session early.
|
|
656
|
+
|
|
596
657
|
## Inside your agent framework
|
|
597
658
|
|
|
598
659
|
`@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,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED;;;;;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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") {
|
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;
|
|
@@ -223,7 +228,7 @@ export declare class Deliverd {
|
|
|
223
228
|
* thing you do without the figure is usually not the thing you do with it.
|
|
224
229
|
*/
|
|
225
230
|
collect(options: CollectOptions): Promise<CollectedAnswers>;
|
|
226
|
-
/** Publish HTML to a secure URL. The
|
|
231
|
+
/** Publish HTML to a secure URL. The sixth primitive, one call in. */
|
|
227
232
|
publish(input: PublishReportInput, signal?: AbortSignal): Promise<PublishResult>;
|
|
228
233
|
}
|
|
229
234
|
export declare const deliverd: Deliverd;
|
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,qBAAqB,EACrB,iBAAiB,EACjB,QAAQ,EACR,YAAY,EACZ,kBAAkB,EAClB,a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AO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAoC5D;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkCjE,sEAAsE;IACtE,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.
|
|
@@ -290,7 +297,7 @@ export class Deliverd {
|
|
|
290
297
|
});
|
|
291
298
|
return settled.toCollected();
|
|
292
299
|
}
|
|
293
|
-
/** Publish HTML to a secure URL. The
|
|
300
|
+
/** Publish HTML to a secure URL. The sixth primitive, one call in. */
|
|
294
301
|
publish(input, signal) {
|
|
295
302
|
return this.reports.publish(input, signal);
|
|
296
303
|
}
|
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", "0.13.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", "0.15.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,+MAsBnB,CAAC;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAoEzC,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CA6jPtD,CAAC"}
|