@deliverd/sdk 0.6.2 → 0.7.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 +67 -2
- package/dist/approvals.d.ts +12 -0
- package/dist/approvals.d.ts.map +1 -1
- package/dist/approvals.js +21 -3
- package/dist/collections.d.ts +10 -0
- package/dist/collections.d.ts.map +1 -1
- package/dist/collections.js +18 -3
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.js +9 -2
- package/dist/flows.d.ts +10 -0
- package/dist/flows.d.ts.map +1 -1
- package/dist/flows.js +18 -3
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +7 -3
- package/dist/paging.d.ts +43 -0
- package/dist/paging.d.ts.map +1 -0
- package/dist/paging.js +27 -0
- package/dist/released.d.ts +29 -0
- package/dist/released.d.ts.map +1 -0
- package/dist/released.js +402 -0
- package/dist/reports.d.ts +152 -4
- package/dist/reports.d.ts.map +1 -1
- package/dist/reports.js +209 -10
- package/dist/reviews.d.ts +10 -0
- package/dist/reviews.d.ts.map +1 -1
- package/dist/reviews.js +18 -8
- package/dist/types.d.ts +137 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/approvals.ts +28 -3
- package/src/collections.ts +25 -3
- package/src/dev.ts +9 -2
- package/src/flows.ts +25 -3
- package/src/index.ts +4 -2
- package/src/messages.ts +7 -3
- package/src/paging.ts +64 -0
- package/src/released.ts +403 -0
- package/src/reports.ts +268 -12
- package/src/reviews.ts +25 -8
- package/src/types.ts +145 -1
package/README.md
CHANGED
|
@@ -80,6 +80,7 @@ default that works:
|
|
|
80
80
|
| Audit | On. Every request, question and decision, with the actor |
|
|
81
81
|
| Correlation id | Generated per request and sent with it |
|
|
82
82
|
| Webhook signing | Already signed; verify with `constructEvent` |
|
|
83
|
+
| Lists | `list()` returns every row; it follows the cursor so you do not have to |
|
|
83
84
|
|
|
84
85
|
## Progressive depth
|
|
85
86
|
|
|
@@ -363,6 +364,13 @@ console.log(report.url);
|
|
|
363
364
|
|
|
364
365
|
await deliverd.reports.update(report.id, { content: revised, changeSummary: "…" });
|
|
365
366
|
await deliverd.reports.share(report.id, "sarah@client.example");
|
|
367
|
+
|
|
368
|
+
// Sharing grants access to people the organisation knows. Sending reaches
|
|
369
|
+
// addresses it has never seen, and says something alongside the link.
|
|
370
|
+
await deliverd.reports.send(report.id, {
|
|
371
|
+
to: ["sarah@client.com", "ops@client.com"],
|
|
372
|
+
message: "Final numbers — let me know by Friday if anything looks wrong.",
|
|
373
|
+
});
|
|
366
374
|
```
|
|
367
375
|
|
|
368
376
|
A publishing policy can hold a version for a person's approval, so check
|
|
@@ -370,16 +378,45 @@ A publishing policy can hold a version for a person's approval, so check
|
|
|
370
378
|
held, `result.approval` names the request and nothing is live until somebody
|
|
371
379
|
says so.
|
|
372
380
|
|
|
373
|
-
Also on `reports`: `get`, `list`, `rename`, `archive`, `
|
|
374
|
-
`analytics`, `putData`, `listData`,
|
|
381
|
+
Also on `reports`: `get`, `list`, `rename`, `archive`, `unarchive`,
|
|
382
|
+
`rollback`, `versions`, `copy`, `analytics`, `putData`, `listData`,
|
|
383
|
+
`deleteData`, `evidence`, `revisionBrief`.
|
|
375
384
|
|
|
376
385
|
And reader feedback:
|
|
377
386
|
|
|
378
387
|
```ts
|
|
388
|
+
// Everything open, across every report — "is anything waiting on me?"
|
|
389
|
+
const waiting = await deliverd.comments.open();
|
|
390
|
+
|
|
379
391
|
const threads = await deliverd.comments.list(reportId);
|
|
380
392
|
await deliverd.comments.resolve(threadId, { note: "Fixed in v4." });
|
|
381
393
|
```
|
|
382
394
|
|
|
395
|
+
## Schedules
|
|
396
|
+
|
|
397
|
+
A schedule says when an agent is asked for a new version. It says nothing
|
|
398
|
+
about who hears about one — publishing emails the report's audience either
|
|
399
|
+
way, and nothing publishes by itself: the agent polls and does the work.
|
|
400
|
+
|
|
401
|
+
```ts
|
|
402
|
+
await deliverd.schedules.create({
|
|
403
|
+
reportId: report.id,
|
|
404
|
+
agentId,
|
|
405
|
+
recurrence: "0 9 * * 5", // Fridays at nine, UTC
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
const due = await deliverd.schedules.list({ dueOnly: true });
|
|
409
|
+
await deliverd.schedules.update(id, { recurrence: "0 9 * * 1" });
|
|
410
|
+
await deliverd.schedules.delete(id);
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
`recurrence` has to have a next occurrence: `0 0 30 2 *` is five well-formed
|
|
414
|
+
fields and a date that never arrives, and is refused rather than stored.
|
|
415
|
+
|
|
416
|
+
An **agent key cannot write here**. A schedule is an instruction *to* an
|
|
417
|
+
agent, so setting one is a person's decision — use a user key. Reading is
|
|
418
|
+
open to both, and an agent sees only the schedules addressed to it.
|
|
419
|
+
|
|
383
420
|
## Webhooks
|
|
384
421
|
|
|
385
422
|
Rather than polling, take the decision as it happens. Verify first — a
|
|
@@ -407,6 +444,34 @@ returns a boolean if you would rather branch. The scheme is Stripe's — a
|
|
|
407
444
|
timestamp and an HMAC in one header, the timestamp inside the signed material,
|
|
408
445
|
five minutes of tolerance — so anything you have written before will work too.
|
|
409
446
|
|
|
447
|
+
|
|
448
|
+
## Lists
|
|
449
|
+
|
|
450
|
+
`list()` gives you all of them. It follows the API's cursor until there is no
|
|
451
|
+
next page, so `.length` is the real count rather than a page size that happens
|
|
452
|
+
to look like one:
|
|
453
|
+
|
|
454
|
+
```ts
|
|
455
|
+
const waiting = await deliverd.approvals.list({ status: "pending" });
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
Ask for a `limit` and you get exactly that page instead — one request, one
|
|
459
|
+
page. When you want to drive the paging yourself, `listPage()` hands back the
|
|
460
|
+
cursor:
|
|
461
|
+
|
|
462
|
+
```ts
|
|
463
|
+
let cursor: string | undefined;
|
|
464
|
+
do {
|
|
465
|
+
const page = await deliverd.approvals.listPage({ limit: 100, cursor });
|
|
466
|
+
for (const approval of page.items) { /* … */ }
|
|
467
|
+
cursor = page.nextCursor ?? undefined;
|
|
468
|
+
} while (cursor);
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
The reason `list()` defaults to everything rather than to one page: a full page
|
|
472
|
+
and a complete list look identical, so a method called `list` that quietly
|
|
473
|
+
returns the first fifty is a wrong answer shaped like a right one.
|
|
474
|
+
|
|
410
475
|
## Errors
|
|
411
476
|
|
|
412
477
|
An error is part of the interface, so it says what happened and the one thing
|
package/dist/approvals.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PageOf } from "./paging.js";
|
|
1
2
|
import type { HttpClient } from "./http.js";
|
|
2
3
|
import type { ApprovalData, ApprovalQuestion, CreateApprovalInput, Decision, ListApprovalsInput } from "./types.js";
|
|
3
4
|
/**
|
|
@@ -65,7 +66,9 @@ export declare class Approval {
|
|
|
65
66
|
get title(): string;
|
|
66
67
|
/** Their reason, when they gave one. */
|
|
67
68
|
get note(): string | null;
|
|
69
|
+
/** Who decided, as a name rather than an id. */
|
|
68
70
|
get decidedBy(): string | null;
|
|
71
|
+
get decidedById(): string | null;
|
|
69
72
|
get decidedAt(): string | null;
|
|
70
73
|
get questions(): ApprovalQuestion[];
|
|
71
74
|
/** Questions the approver is still waiting on you to answer. */
|
|
@@ -111,7 +114,16 @@ export declare class Approvals {
|
|
|
111
114
|
*/
|
|
112
115
|
create(input: CreateApprovalInput, signal?: AbortSignal): Promise<Approval>;
|
|
113
116
|
get(id: string, signal?: AbortSignal): Promise<Approval>;
|
|
117
|
+
/**
|
|
118
|
+
* The organisation's approvals, newest first.
|
|
119
|
+
*
|
|
120
|
+
* With no `limit` this is every one of them: the API says where each page
|
|
121
|
+
* stopped and this follows the cursor to the end. With a `limit` it is one
|
|
122
|
+
* page of that size, and `listPage` hands back the cursor to continue from.
|
|
123
|
+
*/
|
|
114
124
|
list(input?: ListApprovalsInput, signal?: AbortSignal): Promise<Approval[]>;
|
|
125
|
+
/** One page, and the cursor to continue from — null when it is the end. */
|
|
126
|
+
listPage(input?: ListApprovalsInput, signal?: AbortSignal): Promise<PageOf<Approval>>;
|
|
115
127
|
/**
|
|
116
128
|
* Ask and wait, for the common case where there is nothing to do in
|
|
117
129
|
* between. `const { approved } = await deliverd.approvals.request({…})`.
|
package/dist/approvals.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approvals.d.ts","sourceRoot":"","sources":["../src/approvals.ts"],"names":[],"mappings":"
|
|
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,kBAAkB,EACnB,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;;;;;;GAMG;AACH,qBAAa,QAAQ;IAE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IACG,IAAI,CAAC,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAiDrD;AAmBD,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IAU3E,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IAS9D;;;;;;OAMG;IACG,IAAI,CAAC,KAAK,GAAE,kBAAuB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAOrF,2EAA2E;IACrE,QAAQ,CACZ,KAAK,GAAE,kBAAuB,EAC9B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAa5B;;;OAGG;IACG,OAAO,CACX,KAAK,EAAE,mBAAmB,EAC1B,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,QAAQ,CAAC;IAKpB;;;;;;;;;;OAUG;IACG,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;CAI3F"}
|
package/dist/approvals.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { listOrCollect } from "./paging.js";
|
|
1
2
|
import { DeliverdError, DeliverdTimeoutError } from "./errors.js";
|
|
2
3
|
/**
|
|
3
4
|
* Ask a person before you act.
|
|
@@ -49,7 +50,9 @@ export class Approval {
|
|
|
49
50
|
get title() { return this.data.title; }
|
|
50
51
|
/** Their reason, when they gave one. */
|
|
51
52
|
get note() { return this.data.note; }
|
|
53
|
+
/** Who decided, as a name rather than an id. */
|
|
52
54
|
get decidedBy() { return this.data.decidedBy; }
|
|
55
|
+
get decidedById() { return this.data.decidedById; }
|
|
53
56
|
get decidedAt() { return this.data.decidedAt; }
|
|
54
57
|
get questions() { return this.data.questions; }
|
|
55
58
|
/** Questions the approver is still waiting on you to answer. */
|
|
@@ -76,6 +79,7 @@ export class Approval {
|
|
|
76
79
|
status,
|
|
77
80
|
note: this.data.note,
|
|
78
81
|
decidedBy: this.data.decidedBy,
|
|
82
|
+
decidedById: this.data.decidedById,
|
|
79
83
|
decidedAt: this.data.decidedAt,
|
|
80
84
|
id: this.data.id,
|
|
81
85
|
url: this.data.url,
|
|
@@ -204,14 +208,28 @@ export class Approvals {
|
|
|
204
208
|
});
|
|
205
209
|
return new Approval(this.http, data);
|
|
206
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* The organisation's approvals, newest first.
|
|
213
|
+
*
|
|
214
|
+
* With no `limit` this is every one of them: the API says where each page
|
|
215
|
+
* stopped and this follows the cursor to the end. With a `limit` it is one
|
|
216
|
+
* page of that size, and `listPage` hands back the cursor to continue from.
|
|
217
|
+
*/
|
|
207
218
|
async list(input = {}, signal) {
|
|
208
|
-
|
|
219
|
+
return listOrCollect(input, async (q) => {
|
|
220
|
+
const page = await this.listPage({ ...input, ...q }, signal);
|
|
221
|
+
return { items: page.items, nextCursor: page.nextCursor };
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/** One page, and the cursor to continue from — null when it is the end. */
|
|
225
|
+
async listPage(input = {}, signal) {
|
|
226
|
+
const { approvals, nextCursor } = await this.http.request({
|
|
209
227
|
method: "GET",
|
|
210
228
|
path: "/approvals",
|
|
211
|
-
query: { status: input.status, externalId: input.externalId, limit: input.limit },
|
|
229
|
+
query: { status: input.status, externalId: input.externalId, limit: input.limit, cursor: input.cursor },
|
|
212
230
|
signal,
|
|
213
231
|
});
|
|
214
|
-
return approvals.map((
|
|
232
|
+
return { items: approvals.map((r) => new Approval(this.http, r)), nextCursor };
|
|
215
233
|
}
|
|
216
234
|
/**
|
|
217
235
|
* Ask and wait, for the common case where there is nothing to do in
|
package/dist/collections.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PageOf } from "./paging.js";
|
|
1
2
|
import type { HttpClient } from "./http.js";
|
|
2
3
|
import type { AnswerValue, CollectedAnswers, CollectionData, CreateCollectionInput, ListCollectionsInput } from "./types.js";
|
|
3
4
|
/**
|
|
@@ -69,7 +70,16 @@ export declare class Collections {
|
|
|
69
70
|
/** Ask. Returns as soon as the request is filed; call `wait()` next. */
|
|
70
71
|
create(input: CreateCollectionInput, signal?: AbortSignal): Promise<Collection>;
|
|
71
72
|
get(id: string, signal?: AbortSignal): Promise<Collection>;
|
|
73
|
+
/**
|
|
74
|
+
* The organisation's collections, newest first.
|
|
75
|
+
*
|
|
76
|
+
* With no `limit` this is every one of them: the API says where each page
|
|
77
|
+
* stopped and this follows the cursor to the end. With a `limit` it is one
|
|
78
|
+
* page of that size, and `listPage` hands back the cursor to continue from.
|
|
79
|
+
*/
|
|
72
80
|
list(input?: ListCollectionsInput, signal?: AbortSignal): Promise<Collection[]>;
|
|
81
|
+
/** One page, and the cursor to continue from — null when it is the end. */
|
|
82
|
+
listPage(input?: ListCollectionsInput, signal?: AbortSignal): Promise<PageOf<Collection>>;
|
|
73
83
|
/** Ask and wait, for the common case where there is nothing to do between. */
|
|
74
84
|
request(input: CreateCollectionInput, options?: CollectWaitOptions): Promise<Collection>;
|
|
75
85
|
/** The same request as before, when there was one — so a restart does not ask twice. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,KAAK,EAC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CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IASjD;;;;;;;OAOG;IACG,IAAI,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;CAyB5D;AAmBD,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,wEAAwE;IAClE,MAAM,CAAC,KAAK,EAAE,qBAAqB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAU/E,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAShE;;;;;;OAMG;IACG,IAAI,CAAC,KAAK,GAAE,oBAAyB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAOzF,2EAA2E;IACrE,QAAQ,CACZ,KAAK,GAAE,oBAAyB,EAChC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAa9B,8EAA8E;IACxE,OAAO,CACX,KAAK,EAAE,qBAAqB,EAC5B,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,UAAU,CAAC;IAKtB,wFAAwF;IAClF,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;CAI7F"}
|
package/dist/collections.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { listOrCollect } from "./paging.js";
|
|
1
2
|
import { DeliverdError, DeliverdTimeoutError } from "./errors.js";
|
|
2
3
|
import { POLL_SCHEDULE } from "./approvals.js";
|
|
3
4
|
function pollDelay(poll, schedule) {
|
|
@@ -148,14 +149,28 @@ export class Collections {
|
|
|
148
149
|
});
|
|
149
150
|
return new Collection(this.http, data);
|
|
150
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* The organisation's collections, newest first.
|
|
154
|
+
*
|
|
155
|
+
* With no `limit` this is every one of them: the API says where each page
|
|
156
|
+
* stopped and this follows the cursor to the end. With a `limit` it is one
|
|
157
|
+
* page of that size, and `listPage` hands back the cursor to continue from.
|
|
158
|
+
*/
|
|
151
159
|
async list(input = {}, signal) {
|
|
152
|
-
|
|
160
|
+
return listOrCollect(input, async (q) => {
|
|
161
|
+
const page = await this.listPage({ ...input, ...q }, signal);
|
|
162
|
+
return { items: page.items, nextCursor: page.nextCursor };
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/** One page, and the cursor to continue from — null when it is the end. */
|
|
166
|
+
async listPage(input = {}, signal) {
|
|
167
|
+
const { collections, nextCursor } = await this.http.request({
|
|
153
168
|
method: "GET",
|
|
154
169
|
path: "/collections",
|
|
155
|
-
query: { status: input.status, externalId: input.externalId, limit: input.limit },
|
|
170
|
+
query: { status: input.status, externalId: input.externalId, limit: input.limit, cursor: input.cursor },
|
|
156
171
|
signal,
|
|
157
172
|
});
|
|
158
|
-
return collections.map((
|
|
173
|
+
return { items: collections.map((r) => new Collection(this.http, r)), nextCursor };
|
|
159
174
|
}
|
|
160
175
|
/** Ask and wait, for the common case where there is nothing to do between. */
|
|
161
176
|
async request(input, options = {}) {
|
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,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,
|
|
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,CAqY1F"}
|
package/dist/dev.js
CHANGED
|
@@ -47,6 +47,7 @@ export function developmentFetch(options = {}) {
|
|
|
47
47
|
requiredApprovals: 1,
|
|
48
48
|
approvalsSoFar: 0,
|
|
49
49
|
decidedBy: null,
|
|
50
|
+
decidedById: null,
|
|
50
51
|
decidedAt: null,
|
|
51
52
|
note: null,
|
|
52
53
|
expiresAt: body.expiresAt ?? null,
|
|
@@ -313,7 +314,7 @@ export function developmentFetch(options = {}) {
|
|
|
313
314
|
const title = kind === "flow" ? (flowStore.get(id)?.title ?? "A flow") : "A report";
|
|
314
315
|
const now = new Date().toISOString();
|
|
315
316
|
const pack = {
|
|
316
|
-
packVersion:
|
|
317
|
+
packVersion: 2,
|
|
317
318
|
generatedAt: now,
|
|
318
319
|
generatedBy: "You (development mode)",
|
|
319
320
|
organisation: { id: "org_dev", name: "Development" },
|
|
@@ -383,7 +384,13 @@ function settle(stored) {
|
|
|
383
384
|
if (stored.outcome === "question" && stored.data.questions.some((q) => !q.answer))
|
|
384
385
|
return;
|
|
385
386
|
stored.data.status = stored.outcome === "rejected" ? "rejected" : "approved";
|
|
386
|
-
|
|
387
|
+
/*
|
|
388
|
+
* The same shape production sends: a person's name in `decidedBy` and the
|
|
389
|
+
* key in `decidedById`. It used to be an email-shaped string alone, so the
|
|
390
|
+
* offline loop taught a shape a real organisation never delivers.
|
|
391
|
+
*/
|
|
392
|
+
stored.data.decidedBy = "Development approver";
|
|
393
|
+
stored.data.decidedById = "00000000-0000-0000-0000-00000000dev0";
|
|
387
394
|
stored.data.decidedAt = new Date().toISOString();
|
|
388
395
|
stored.data.note =
|
|
389
396
|
stored.options.note ??
|
package/dist/flows.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PageOf } from "./paging.js";
|
|
1
2
|
import type { HttpClient } from "./http.js";
|
|
2
3
|
import type { CreateFlowInput, EvidencePack, FlowData, ListFlowsInput } from "./types.js";
|
|
3
4
|
import type { ApproveOptions, CollectOptions, Decision, ReviewOptions, ReviewOutcome } from "./index.js";
|
|
@@ -88,7 +89,16 @@ export declare class Flows {
|
|
|
88
89
|
constructor(http: HttpClient, client: FlowPrimitives);
|
|
89
90
|
create(input: CreateFlowInput, signal?: AbortSignal): Promise<Flow>;
|
|
90
91
|
get(id: string, signal?: AbortSignal): Promise<Flow>;
|
|
92
|
+
/**
|
|
93
|
+
* The organisation's flows, newest first.
|
|
94
|
+
*
|
|
95
|
+
* With no `limit` this is every one of them: the API says where each page
|
|
96
|
+
* stopped and this follows the cursor to the end. With a `limit` it is one
|
|
97
|
+
* page of that size, and `listPage` hands back the cursor to continue from.
|
|
98
|
+
*/
|
|
91
99
|
list(input?: ListFlowsInput, signal?: AbortSignal): Promise<Flow[]>;
|
|
100
|
+
/** One page, and the cursor to continue from — null when it is the end. */
|
|
101
|
+
listPage(input?: ListFlowsInput, signal?: AbortSignal): Promise<PageOf<Flow>>;
|
|
92
102
|
/** The same job as before, when there was one — so a restart extends it rather than starting a second. */
|
|
93
103
|
findByExternalId(externalId: string, signal?: AbortSignal): Promise<Flow | null>;
|
|
94
104
|
/**
|
package/dist/flows.d.ts.map
CHANGED
|
@@ -1 +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;IACr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
1
2
|
export class Flow {
|
|
2
3
|
http;
|
|
3
4
|
data;
|
|
@@ -119,14 +120,28 @@ export class Flows {
|
|
|
119
120
|
});
|
|
120
121
|
return new Flow(this.http, data, this.client);
|
|
121
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* The organisation's flows, newest first.
|
|
125
|
+
*
|
|
126
|
+
* With no `limit` this is every one of them: the API says where each page
|
|
127
|
+
* stopped and this follows the cursor to the end. With a `limit` it is one
|
|
128
|
+
* page of that size, and `listPage` hands back the cursor to continue from.
|
|
129
|
+
*/
|
|
122
130
|
async list(input = {}, signal) {
|
|
123
|
-
|
|
131
|
+
return listOrCollect(input, async (q) => {
|
|
132
|
+
const page = await this.listPage({ ...input, ...q }, signal);
|
|
133
|
+
return { items: page.items, nextCursor: page.nextCursor };
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/** One page, and the cursor to continue from — null when it is the end. */
|
|
137
|
+
async listPage(input = {}, signal) {
|
|
138
|
+
const { flows, nextCursor } = await this.http.request({
|
|
124
139
|
method: "GET",
|
|
125
140
|
path: "/flows",
|
|
126
|
-
query: { status: input.status, externalId: input.externalId, limit: input.limit },
|
|
141
|
+
query: { status: input.status, externalId: input.externalId, limit: input.limit, cursor: input.cursor },
|
|
127
142
|
signal,
|
|
128
143
|
});
|
|
129
|
-
return flows.map((f) => new Flow(this.http, f, this.client));
|
|
144
|
+
return { items: flows.map((f) => new Flow(this.http, f, this.client)), nextCursor };
|
|
130
145
|
}
|
|
131
146
|
/** The same job as before, when there was one — so a restart extends it rather than starting a second. */
|
|
132
147
|
async findByExternalId(externalId, signal) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpClient, type ClientOptions } from "./http.js";
|
|
2
2
|
import { Approvals, type WaitOptions } from "./approvals.js";
|
|
3
|
-
import { Comments, Reports } from "./reports.js";
|
|
3
|
+
import { Comments, Reports, Schedules } from "./reports.js";
|
|
4
4
|
import { Reviews, type ReviewWaitOptions } from "./reviews.js";
|
|
5
5
|
import { Collections, type CollectWaitOptions } from "./collections.js";
|
|
6
6
|
import { Flows } from "./flows.js";
|
|
@@ -9,7 +9,7 @@ import { type DevelopmentOptions } from "./dev.js";
|
|
|
9
9
|
import { type Duration } from "./duration.js";
|
|
10
10
|
import type { CollectedAnswers, CreateApprovalInput, CreateCollectionInput, CreateReviewInput, Decision, PublishReportInput, PublishResult, ReviewOutcome } from "./types.js";
|
|
11
11
|
export { Approval, Approvals, POLL_SCHEDULE, type WaitOptions } from "./approvals.js";
|
|
12
|
-
export { Comments, Reports } from "./reports.js";
|
|
12
|
+
export { Comments, Reports, Schedules } from "./reports.js";
|
|
13
13
|
export { Review, Reviews, type ReviewWaitOptions } from "./reviews.js";
|
|
14
14
|
export { Collection, Collections, type CollectWaitOptions } from "./collections.js";
|
|
15
15
|
export { Flow, Flows, type FlowPrimitives } from "./flows.js";
|
|
@@ -113,6 +113,7 @@ export declare class Deliverd {
|
|
|
113
113
|
readonly flows: Flows;
|
|
114
114
|
readonly reports: Reports;
|
|
115
115
|
readonly comments: Comments;
|
|
116
|
+
readonly schedules: Schedules;
|
|
116
117
|
readonly webhooks: Webhooks;
|
|
117
118
|
readonly http: HttpClient;
|
|
118
119
|
/** Whether an imaginary approver is deciding these. */
|
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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,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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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpClient } from "./http.js";
|
|
2
2
|
import { Approvals, FAST_POLL_SCHEDULE } from "./approvals.js";
|
|
3
|
-
import { Comments, Reports } from "./reports.js";
|
|
3
|
+
import { Comments, Reports, Schedules } from "./reports.js";
|
|
4
4
|
import { Reviews } from "./reviews.js";
|
|
5
5
|
import { Collections } from "./collections.js";
|
|
6
6
|
import { Flows } from "./flows.js";
|
|
@@ -8,7 +8,7 @@ import { Webhooks } from "./webhooks.js";
|
|
|
8
8
|
import { developmentFetch } from "./dev.js";
|
|
9
9
|
import { durationMs } from "./duration.js";
|
|
10
10
|
export { Approval, Approvals, POLL_SCHEDULE } from "./approvals.js";
|
|
11
|
-
export { Comments, Reports } from "./reports.js";
|
|
11
|
+
export { Comments, Reports, Schedules } from "./reports.js";
|
|
12
12
|
export { Review, Reviews } from "./reviews.js";
|
|
13
13
|
export { Collection, Collections } from "./collections.js";
|
|
14
14
|
export { Flow, Flows } from "./flows.js";
|
|
@@ -44,6 +44,7 @@ export class Deliverd {
|
|
|
44
44
|
flows;
|
|
45
45
|
reports;
|
|
46
46
|
comments;
|
|
47
|
+
schedules;
|
|
47
48
|
webhooks;
|
|
48
49
|
http;
|
|
49
50
|
/** Whether an imaginary approver is deciding these. */
|
|
@@ -69,6 +70,7 @@ export class Deliverd {
|
|
|
69
70
|
this.flows = new Flows(this.http, this);
|
|
70
71
|
this.reports = new Reports(this.http);
|
|
71
72
|
this.comments = new Comments(this.http);
|
|
73
|
+
this.schedules = new Schedules(this.http);
|
|
72
74
|
this.webhooks = new Webhooks();
|
|
73
75
|
}
|
|
74
76
|
/**
|
package/dist/messages.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,WAAW;IAC1B,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,WAAW;IAC1B,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAuDpD,CAAC;AAEF,iFAAiF;AACjF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAI5F"}
|
package/dist/messages.js
CHANGED
|
@@ -15,11 +15,15 @@ export const EXPLANATIONS = {
|
|
|
15
15
|
hint: "Set DELIVERD_API_KEY in your environment, or pass { apiKey } — or use { mode: \"development\" } to run without one.",
|
|
16
16
|
},
|
|
17
17
|
auth_error: {
|
|
18
|
-
message: "That
|
|
19
|
-
|
|
18
|
+
message: "That credential was not accepted.",
|
|
19
|
+
// Both families, because both work: a `dlv_` key somebody created, or a
|
|
20
|
+
// `dlvo_` access token from an OAuth connector. Naming only the first is
|
|
21
|
+
// how a connector's token gets thrown away and replaced with a key
|
|
22
|
+
// nobody needed to create.
|
|
23
|
+
hint: "Check DELIVERD_API_KEY. An API key starts with dlv_ and is created in Settings → API tokens; an OAuth access token starts with dlvo_ and needs no setup.",
|
|
20
24
|
},
|
|
21
25
|
insufficient_scope: {
|
|
22
|
-
hint: "Reissue the key with the scope named above. A
|
|
26
|
+
hint: "Reissue the key with the scope named above, or re-consent the connector for it. A credential issued before a scope existed does not have it.",
|
|
23
27
|
},
|
|
24
28
|
unknown_approver: {
|
|
25
29
|
message: "No approver could be found for this request.",
|
package/dist/paging.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { HttpClient } from "./http.js";
|
|
2
|
+
/**
|
|
3
|
+
* What the SDK does about a list that does not fit in one answer.
|
|
4
|
+
*
|
|
5
|
+
* The API says where it stopped: a response carries `nextCursor`, null when
|
|
6
|
+
* the page is the end of the list and a string to pass back when it is not.
|
|
7
|
+
* That leaves the client one decision, and it is worth stating rather than
|
|
8
|
+
* leaving to whoever reads the call:
|
|
9
|
+
*
|
|
10
|
+
* **`limit` set means one page of that size. `limit` unset means all of
|
|
11
|
+
* them.** `list()` with no limit follows the cursor until the API stops
|
|
12
|
+
* offering one, so `.length` is the real count rather than a page size that
|
|
13
|
+
* happens to look like one. A caller who wants to page by hand asks for a
|
|
14
|
+
* `limit`, or uses `listPage` and drives the cursor themselves.
|
|
15
|
+
*
|
|
16
|
+
* The alternative — return a page and let the caller notice — reads fine and
|
|
17
|
+
* fails quietly, because a full page and a complete list are indistinguishable
|
|
18
|
+
* until somebody counts.
|
|
19
|
+
*/
|
|
20
|
+
export interface PageInput {
|
|
21
|
+
limit?: number;
|
|
22
|
+
cursor?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface PageOf<T> {
|
|
25
|
+
items: T[];
|
|
26
|
+
nextCursor: string | null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Follow the cursor to the end, collecting as we go.
|
|
30
|
+
*
|
|
31
|
+
* `fetchPage` is whatever single request the caller's endpoint makes; this
|
|
32
|
+
* only decides when to ask again. A page that comes back empty while still
|
|
33
|
+
* offering a cursor ends the loop as well — a server that did that would
|
|
34
|
+
* otherwise spin here for ever.
|
|
35
|
+
*/
|
|
36
|
+
export declare function collect<T>(fetchPage: (cursor: string | null) => Promise<PageOf<T>>): Promise<T[]>;
|
|
37
|
+
/** One page, or every page, depending on whether a limit was asked for. */
|
|
38
|
+
export declare function listOrCollect<T>(input: PageInput, fetchPage: (query: {
|
|
39
|
+
limit?: number;
|
|
40
|
+
cursor?: string;
|
|
41
|
+
}) => Promise<PageOf<T>>): Promise<T[]>;
|
|
42
|
+
export type { HttpClient };
|
|
43
|
+
//# sourceMappingURL=paging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paging.d.ts","sourceRoot":"","sources":["../src/paging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAC7B,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GACvD,OAAO,CAAC,CAAC,EAAE,CAAC,CASd;AAED,2EAA2E;AAC3E,wBAAsB,aAAa,CAAC,CAAC,EACnC,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,CAAC,KAAK,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAC5E,OAAO,CAAC,CAAC,EAAE,CAAC,CAMd;AAED,YAAY,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/paging.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Follow the cursor to the end, collecting as we go.
|
|
3
|
+
*
|
|
4
|
+
* `fetchPage` is whatever single request the caller's endpoint makes; this
|
|
5
|
+
* only decides when to ask again. A page that comes back empty while still
|
|
6
|
+
* offering a cursor ends the loop as well — a server that did that would
|
|
7
|
+
* otherwise spin here for ever.
|
|
8
|
+
*/
|
|
9
|
+
export async function collect(fetchPage) {
|
|
10
|
+
const all = [];
|
|
11
|
+
let cursor = null;
|
|
12
|
+
for (;;) {
|
|
13
|
+
const page = await fetchPage(cursor);
|
|
14
|
+
all.push(...page.items);
|
|
15
|
+
if (!page.nextCursor || page.items.length === 0)
|
|
16
|
+
return all;
|
|
17
|
+
cursor = page.nextCursor;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** One page, or every page, depending on whether a limit was asked for. */
|
|
21
|
+
export async function listOrCollect(input, fetchPage) {
|
|
22
|
+
if (input.limit !== undefined) {
|
|
23
|
+
const page = await fetchPage({ limit: input.limit, cursor: input.cursor });
|
|
24
|
+
return page.items;
|
|
25
|
+
}
|
|
26
|
+
return collect((cursor) => fetchPage({ cursor: cursor ?? undefined }));
|
|
27
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What each published version of `@deliverd/sdk` actually offers.
|
|
3
|
+
*
|
|
4
|
+
* Written after the package drifted **thirteen commits and fifty-four public
|
|
5
|
+
* surface items** ahead of what npm was serving, under a version number that
|
|
6
|
+
* had already been published. Among them `decidedById` — the field the
|
|
7
|
+
* decision-names-the-person correction added — and the whole `Schedules`
|
|
8
|
+
* namespace, so `docs/api.md` and this repository's own readiness notes
|
|
9
|
+
* described an SDK nobody could install.
|
|
10
|
+
*
|
|
11
|
+
* `release.test.ts` already proves what a tarball *contains*; its own header
|
|
12
|
+
* says the one thing it cannot know is the version number, because the
|
|
13
|
+
* registry is not reachable from a test. This is that missing half, and it is
|
|
14
|
+
* the same device the CLI got after 0.3.0 shipped three commands short:
|
|
15
|
+
* a ledger the source is held against, so adding to the surface fails until
|
|
16
|
+
* somebody records which version carries it.
|
|
17
|
+
*
|
|
18
|
+
* **The rule:** every entry in `SURFACE` below is an item a caller can reach —
|
|
19
|
+
* an export, a field of an exported type, or a webhook event name. The guard
|
|
20
|
+
* computes the same set from source and refuses a mismatch. Adding a field
|
|
21
|
+
* therefore forces a version bump, which is correct: a package that describes
|
|
22
|
+
* something new is a package somebody has to install to get.
|
|
23
|
+
*
|
|
24
|
+
* 0.6.2 and earlier predate this ledger and are not recorded. Reconstructing
|
|
25
|
+
* them would mean asserting a surface nobody checked at the time, which is the
|
|
26
|
+
* kind of entry that reads like a fact and is a guess.
|
|
27
|
+
*/
|
|
28
|
+
export declare const RELEASED: Record<string, readonly string[]>;
|
|
29
|
+
//# sourceMappingURL=released.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"released.d.ts","sourceRoot":"","sources":["../src/released.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAsXtD,CAAC"}
|