@deliverd/sdk 0.6.2 → 0.7.1

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/dist/reports.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ import { type PageInput, type PageOf } from "./paging.js";
1
2
  import type { HttpClient } from "./http.js";
2
- import type { CommentThread, PublishReportInput, PublishResult, ReportData, UpdateReportInput, EvidencePack } from "./types.js";
3
+ import type { CommentThread, OpenThread, OrgAnalytics, ReportAnalytics, PublishReportInput, PublishResult, ReportData, ScheduleSummary, SendResult, UpdateReportInput, EvidencePack } from "./types.js";
3
4
  /**
4
5
  * The publishing half: get what the agent wrote to the people who need it, at
5
6
  * an address that does not change.
@@ -32,7 +33,20 @@ export declare class Reports {
32
33
  */
33
34
  evidence(idOrSlug: string, signal?: AbortSignal): Promise<EvidencePack>;
34
35
  get(idOrSlug: string, signal?: AbortSignal): Promise<ReportData>;
36
+ /**
37
+ * Every report, newest change first. `query` searches title, slug and
38
+ * description.
39
+ *
40
+ * This one used to be the worst of them: the API had no limit at all, so an
41
+ * organisation past PostgREST's own cap was handed a prefix of its reports
42
+ * and nothing said so. It follows the cursor now, so the array really is all
43
+ * of them; `listPage` is there when one page is what you want.
44
+ */
35
45
  list(query?: string, signal?: AbortSignal): Promise<ReportData[]>;
46
+ /** One page, and the cursor to continue from — null when it is the end. */
47
+ listPage(input?: {
48
+ query?: string;
49
+ } & PageInput, signal?: AbortSignal): Promise<PageOf<ReportData>>;
36
50
  /** Change the title, the address, or both. The old address keeps working. */
37
51
  rename(idOrSlug: string, input: {
38
52
  title?: string;
@@ -42,20 +56,85 @@ export declare class Reports {
42
56
  }, signal?: AbortSignal): Promise<ReportData>;
43
57
  /** Grant people, teams or groups access. Filing is not access; this is. */
44
58
  share(idOrSlug: string, audience: unknown, signal?: AbortSignal): Promise<unknown[]>;
45
- /** Stop the URL serving. `archived: false` puts it back. */
59
+ /**
60
+ * Take it away again, from the same audience phrase that granted it.
61
+ *
62
+ * By audience rather than by grant id because that is all a caller has:
63
+ * `get()` returns each grant's principal id, never the grant row's. Refuses
64
+ * when the audience never had access, so a script that revokes and carries
65
+ * on is not told the door is shut when it is open.
66
+ */
67
+ revoke(idOrSlug: string, audience: unknown, signal?: AbortSignal): Promise<unknown[]>;
68
+ /**
69
+ * Email it to a list of addresses, inside or outside the organisation.
70
+ *
71
+ * `share` grants access to people the organisation already knows. This
72
+ * takes bare email addresses, creates the guest records behind them, and
73
+ * emails each recipient their own link with your covering note. Not a
74
+ * mailing list: one link per person, which is what makes the audit trail
75
+ * and the per-reader analytics mean anything.
76
+ *
77
+ * A publishing rule can refuse it — a report classified confidential or
78
+ * restricted does not leave the organisation.
79
+ */
80
+ send(idOrSlug: string, input: {
81
+ to: string[];
82
+ message?: string;
83
+ allowComments?: boolean;
84
+ expiresInDays?: number;
85
+ }, signal?: AbortSignal): Promise<SendResult>;
86
+ /**
87
+ * Stop the URL serving. A reader following a link they already hold is told
88
+ * the report is no longer available; nothing is deleted and the audience is
89
+ * kept, so `unarchive` puts it back exactly as it was.
90
+ */
46
91
  archive(idOrSlug: string, archived?: boolean, signal?: AbortSignal): Promise<ReportData>;
47
- rollback(idOrSlug: string, version: number, signal?: AbortSignal): Promise<unknown>;
92
+ /** Put an archived report back at the same URL, to the same audience. */
93
+ unarchive(idOrSlug: string, signal?: AbortSignal): Promise<ReportData>;
94
+ /**
95
+ * Serve an earlier version again, at the same URL. The newer version is
96
+ * kept — roll forward the same way.
97
+ *
98
+ * The version number is the one `versions()` and `get()` report, not a
99
+ * version uuid.
100
+ */
101
+ rollback(idOrSlug: string, version: number, signal?: AbortSignal): Promise<{
102
+ ok: true;
103
+ version: number;
104
+ versionId: string;
105
+ }>;
48
106
  /**
49
107
  * Every version, with `latestVersion` beside `currentVersion`. Pass
50
108
  * `latestVersion` as `expectedVersion` on an update: a held or declined
51
109
  * version takes a number without going live.
52
110
  */
53
111
  versions(idOrSlug: string, signal?: AbortSignal): Promise<Record<string, unknown>>;
112
+ /**
113
+ * What is being read across every report — and what is not.
114
+ *
115
+ * `analytics` needs to be told which report, so "what is getting read" meant
116
+ * walking the list and adding up. The half that cannot be reconstructed that
117
+ * way is `inactiveReports`: a report nobody has opened does not appear in
118
+ * anything you would think to ask about.
119
+ *
120
+ * Part of analytics, so Team and above; `analytics` returns a total view
121
+ * count on every plan.
122
+ */
123
+ orgAnalytics(options?: {
124
+ days?: number;
125
+ limit?: number;
126
+ }, signal?: AbortSignal): Promise<OrgAnalytics>;
54
127
  /** Who read it and when. The detail needs the analytics plan. */
55
- analytics(idOrSlug: string, signal?: AbortSignal): Promise<Record<string, unknown>>;
128
+ analytics(idOrSlug: string, signal?: AbortSignal): Promise<ReportAnalytics>;
56
129
  /** Replace a dataset a living report reads. No new version, same URL. */
57
130
  putData(idOrSlug: string, name: string, data: unknown, signal?: AbortSignal): Promise<unknown>;
58
131
  listData(idOrSlug: string, signal?: AbortSignal): Promise<unknown>;
132
+ /**
133
+ * Remove a dataset. The published version is untouched; a report that
134
+ * fetches this name will show its readers an error from the next open, so
135
+ * `listData` first if you are not sure what reads it.
136
+ */
137
+ deleteData(idOrSlug: string, name: string, signal?: AbortSignal): Promise<void>;
59
138
  /**
60
139
  * The open feedback composed into one prompt, with the readers' images as
61
140
  * signed links: everything needed to write the next version.
@@ -69,17 +148,86 @@ export declare class Reports {
69
148
  export declare class Comments {
70
149
  private readonly http;
71
150
  constructor(http: HttpClient);
151
+ /** Every thread on a report, newest activity first. */
72
152
  list(idOrSlug: string, status?: "open" | "resolved" | "all", signal?: AbortSignal): Promise<CommentThread[]>;
153
+ /**
154
+ * Every open thread in the organisation, newest activity first — the
155
+ * answer to "is anything waiting on me?" without naming a report first.
156
+ *
157
+ * `list` needs one, which means enumerating every report to find the two
158
+ * with feedback on them. Threads on archived reports are left out: the URL
159
+ * does not serve, so nothing can be done about them.
160
+ */
161
+ open(signal?: AbortSignal): Promise<OpenThread[]>;
73
162
  /** `quote` anchors it to a passage; `threadId` replies to one. */
74
163
  create(idOrSlug: string, input: {
75
164
  body: string;
76
165
  quote?: string;
77
166
  threadId?: string;
78
167
  }, signal?: AbortSignal): Promise<unknown>;
168
+ /**
169
+ * Take back a comment you posted.
170
+ *
171
+ * Your own last comment in a thread, while the thread is open. Once
172
+ * somebody has replied it stays — their reply would otherwise be left
173
+ * answering something no longer on the page. Retracting the only comment in
174
+ * a thread takes the thread with it.
175
+ *
176
+ * `commentId` comes back from `create`, and `list` carries one on every
177
+ * message with `retractable` beside it. This closes what a reader can see
178
+ * and unsends nothing: the report's owner may already have been emailed.
179
+ */
180
+ retract(idOrSlug: string, commentId: string, signal?: AbortSignal): Promise<{
181
+ status: "retracted";
182
+ threadId: string;
183
+ threadRetracted: boolean;
184
+ }>;
79
185
  /** Mark a thread resolved, with a note on what changed. */
80
186
  resolve(threadId: string, input?: {
81
187
  note?: string;
82
188
  reopen?: boolean;
83
189
  }, signal?: AbortSignal): Promise<unknown>;
84
190
  }
191
+ /**
192
+ * Recurring publishes.
193
+ *
194
+ * A schedule says when an agent is asked for a new version. It says nothing
195
+ * about who hears about one — publishing emails the report's audience either
196
+ * way.
197
+ *
198
+ * Read-only over the API until now, which made the timetable the one thing
199
+ * about an agent that could be set from the admin screen and nowhere else.
200
+ * An agent key cannot write here on purpose: a schedule is an instruction
201
+ * *to* an agent.
202
+ */
203
+ export declare class Schedules {
204
+ private readonly http;
205
+ constructor(http: HttpClient);
206
+ /** Every schedule, or only the ones waiting on a publish. */
207
+ list(options?: {
208
+ dueOnly?: boolean;
209
+ }, signal?: AbortSignal): Promise<ScheduleSummary[]>;
210
+ /**
211
+ * `recurrence` is a five-field cron expression in UTC, and it has to have a
212
+ * next occurrence — `0 0 30 2 *` is well-formed and never arrives, and is
213
+ * refused rather than stored.
214
+ */
215
+ create(input: {
216
+ reportId: string;
217
+ agentId: string;
218
+ recurrence: string;
219
+ }, signal?: AbortSignal): Promise<ScheduleSummary>;
220
+ /**
221
+ * Change the cadence, or turn it on or off.
222
+ *
223
+ * Changing the cadence re-times the next run, so moving a weekly publish
224
+ * from Friday to Monday does not fire once more on the Friday.
225
+ */
226
+ update(id: string, input: {
227
+ recurrence?: string;
228
+ enabled?: boolean;
229
+ }, signal?: AbortSignal): Promise<ScheduleSummary>;
230
+ /** Remove it. `update(id, { enabled: false })` pauses it instead. */
231
+ delete(id: string, signal?: AbortSignal): Promise<void>;
232
+ }
85
233
  //# sourceMappingURL=reports.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../src/reports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB;;;;;;;;GAQG;AACH,qBAAa,OAAO;IACN,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;OAMG;IACH,OAAO,CAAC,KAAK,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAIhF,6EAA6E;IAC7E,MAAM,CACJ,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,iBAAiB,EACxB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,aAAa,CAAC;IASzB;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAQvE,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAQ1D,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAUvE,6E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AAM,CACJ,EAAE,EAAE,MAAM,EACV,KAAK,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,EACjD,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,eAAe,CAAC;IAS3B,qEAAqE;IACrE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAOxD"}
package/dist/reports.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { collect } from "./paging.js";
1
2
  /**
2
3
  * The publishing half: get what the agent wrote to the people who need it, at
3
4
  * an address that does not change.
@@ -53,14 +54,30 @@ export class Reports {
53
54
  signal,
54
55
  });
55
56
  }
57
+ /**
58
+ * Every report, newest change first. `query` searches title, slug and
59
+ * description.
60
+ *
61
+ * This one used to be the worst of them: the API had no limit at all, so an
62
+ * organisation past PostgREST's own cap was handed a prefix of its reports
63
+ * and nothing said so. It follows the cursor now, so the array really is all
64
+ * of them; `listPage` is there when one page is what you want.
65
+ */
56
66
  async list(query, signal) {
57
- const { reports } = await this.http.request({
67
+ return collect(async (cursor) => {
68
+ const page = await this.listPage({ query, cursor: cursor ?? undefined }, signal);
69
+ return { items: page.items, nextCursor: page.nextCursor };
70
+ });
71
+ }
72
+ /** One page, and the cursor to continue from — null when it is the end. */
73
+ async listPage(input = {}, signal) {
74
+ const { reports, nextCursor } = await this.http.request({
58
75
  method: "GET",
59
76
  path: "/reports",
60
- query: { q: query },
77
+ query: { q: input.query, limit: input.limit, cursor: input.cursor },
61
78
  signal,
62
79
  });
63
- return reports;
80
+ return { items: reports, nextCursor };
64
81
  }
65
82
  /** Change the title, the address, or both. The old address keeps working. */
66
83
  rename(idOrSlug, input, signal) {
@@ -81,7 +98,48 @@ export class Reports {
81
98
  });
82
99
  return granted;
83
100
  }
84
- /** Stop the URL serving. `archived: false` puts it back. */
101
+ /**
102
+ * Take it away again, from the same audience phrase that granted it.
103
+ *
104
+ * By audience rather than by grant id because that is all a caller has:
105
+ * `get()` returns each grant's principal id, never the grant row's. Refuses
106
+ * when the audience never had access, so a script that revokes and carries
107
+ * on is not told the door is shut when it is open.
108
+ */
109
+ async revoke(idOrSlug, audience, signal) {
110
+ const { revoked } = await this.http.request({
111
+ method: "DELETE",
112
+ path: `/reports/${encodeURIComponent(idOrSlug)}/share`,
113
+ body: { audience },
114
+ signal,
115
+ });
116
+ return revoked;
117
+ }
118
+ /**
119
+ * Email it to a list of addresses, inside or outside the organisation.
120
+ *
121
+ * `share` grants access to people the organisation already knows. This
122
+ * takes bare email addresses, creates the guest records behind them, and
123
+ * emails each recipient their own link with your covering note. Not a
124
+ * mailing list: one link per person, which is what makes the audit trail
125
+ * and the per-reader analytics mean anything.
126
+ *
127
+ * A publishing rule can refuse it — a report classified confidential or
128
+ * restricted does not leave the organisation.
129
+ */
130
+ send(idOrSlug, input, signal) {
131
+ return this.http.request({
132
+ method: "POST",
133
+ path: `/reports/${encodeURIComponent(idOrSlug)}/send`,
134
+ body: input,
135
+ signal,
136
+ });
137
+ }
138
+ /**
139
+ * Stop the URL serving. A reader following a link they already hold is told
140
+ * the report is no longer available; nothing is deleted and the audience is
141
+ * kept, so `unarchive` puts it back exactly as it was.
142
+ */
85
143
  archive(idOrSlug, archived = true, signal) {
86
144
  return this.http.request({
87
145
  method: "POST",
@@ -90,6 +148,17 @@ export class Reports {
90
148
  signal,
91
149
  });
92
150
  }
151
+ /** Put an archived report back at the same URL, to the same audience. */
152
+ unarchive(idOrSlug, signal) {
153
+ return this.archive(idOrSlug, false, signal);
154
+ }
155
+ /**
156
+ * Serve an earlier version again, at the same URL. The newer version is
157
+ * kept — roll forward the same way.
158
+ *
159
+ * The version number is the one `versions()` and `get()` report, not a
160
+ * version uuid.
161
+ */
93
162
  rollback(idOrSlug, version, signal) {
94
163
  return this.http.request({
95
164
  method: "POST",
@@ -110,6 +179,25 @@ export class Reports {
110
179
  signal,
111
180
  });
112
181
  }
182
+ /**
183
+ * What is being read across every report — and what is not.
184
+ *
185
+ * `analytics` needs to be told which report, so "what is getting read" meant
186
+ * walking the list and adding up. The half that cannot be reconstructed that
187
+ * way is `inactiveReports`: a report nobody has opened does not appear in
188
+ * anything you would think to ask about.
189
+ *
190
+ * Part of analytics, so Team and above; `analytics` returns a total view
191
+ * count on every plan.
192
+ */
193
+ orgAnalytics(options = {}, signal) {
194
+ return this.http.request({
195
+ method: "GET",
196
+ path: "/analytics",
197
+ query: { days: options.days, limit: options.limit },
198
+ signal,
199
+ });
200
+ }
113
201
  /** Who read it and when. The detail needs the analytics plan. */
114
202
  analytics(idOrSlug, signal) {
115
203
  return this.http.request({
@@ -134,6 +222,18 @@ export class Reports {
134
222
  signal,
135
223
  });
136
224
  }
225
+ /**
226
+ * Remove a dataset. The published version is untouched; a report that
227
+ * fetches this name will show its readers an error from the next open, so
228
+ * `listData` first if you are not sure what reads it.
229
+ */
230
+ deleteData(idOrSlug, name, signal) {
231
+ return this.http.request({
232
+ method: "DELETE",
233
+ path: `/reports/${encodeURIComponent(idOrSlug)}/data/${encodeURIComponent(name)}`,
234
+ signal,
235
+ });
236
+ }
137
237
  /**
138
238
  * The open feedback composed into one prompt, with the readers' images as
139
239
  * signed links: everything needed to write the next version.
@@ -153,14 +253,36 @@ export class Comments {
153
253
  constructor(http) {
154
254
  this.http = http;
155
255
  }
256
+ /** Every thread on a report, newest activity first. */
156
257
  async list(idOrSlug, status = "open", signal) {
157
- const { threads } = await this.http.request({
158
- method: "GET",
159
- path: `/reports/${encodeURIComponent(idOrSlug)}/comments`,
160
- query: { status },
161
- signal,
258
+ return collect(async (cursor) => {
259
+ const { threads, nextCursor } = await this.http.request({
260
+ method: "GET",
261
+ path: `/reports/${encodeURIComponent(idOrSlug)}/comments`,
262
+ query: { status, cursor: cursor ?? undefined },
263
+ signal,
264
+ });
265
+ return { items: threads, nextCursor };
266
+ });
267
+ }
268
+ /**
269
+ * Every open thread in the organisation, newest activity first — the
270
+ * answer to "is anything waiting on me?" without naming a report first.
271
+ *
272
+ * `list` needs one, which means enumerating every report to find the two
273
+ * with feedback on them. Threads on archived reports are left out: the URL
274
+ * does not serve, so nothing can be done about them.
275
+ */
276
+ async open(signal) {
277
+ return collect(async (cursor) => {
278
+ const { threads, nextCursor } = await this.http.request({
279
+ method: "GET",
280
+ path: "/comments",
281
+ query: { cursor: cursor ?? undefined },
282
+ signal,
283
+ });
284
+ return { items: threads, nextCursor };
162
285
  });
163
- return threads;
164
286
  }
165
287
  /** `quote` anchors it to a passage; `threadId` replies to one. */
166
288
  create(idOrSlug, input, signal) {
@@ -171,6 +293,25 @@ export class Comments {
171
293
  signal,
172
294
  });
173
295
  }
296
+ /**
297
+ * Take back a comment you posted.
298
+ *
299
+ * Your own last comment in a thread, while the thread is open. Once
300
+ * somebody has replied it stays — their reply would otherwise be left
301
+ * answering something no longer on the page. Retracting the only comment in
302
+ * a thread takes the thread with it.
303
+ *
304
+ * `commentId` comes back from `create`, and `list` carries one on every
305
+ * message with `retractable` beside it. This closes what a reader can see
306
+ * and unsends nothing: the report's owner may already have been emailed.
307
+ */
308
+ retract(idOrSlug, commentId, signal) {
309
+ return this.http.request({
310
+ method: "DELETE",
311
+ path: `/reports/${encodeURIComponent(idOrSlug)}/comments/${encodeURIComponent(commentId)}`,
312
+ signal,
313
+ });
314
+ }
174
315
  /** Mark a thread resolved, with a note on what changed. */
175
316
  resolve(threadId, input = {}, signal) {
176
317
  return this.http.request({
@@ -181,3 +322,61 @@ export class Comments {
181
322
  });
182
323
  }
183
324
  }
325
+ /**
326
+ * Recurring publishes.
327
+ *
328
+ * A schedule says when an agent is asked for a new version. It says nothing
329
+ * about who hears about one — publishing emails the report's audience either
330
+ * way.
331
+ *
332
+ * Read-only over the API until now, which made the timetable the one thing
333
+ * about an agent that could be set from the admin screen and nowhere else.
334
+ * An agent key cannot write here on purpose: a schedule is an instruction
335
+ * *to* an agent.
336
+ */
337
+ export class Schedules {
338
+ http;
339
+ constructor(http) {
340
+ this.http = http;
341
+ }
342
+ /** Every schedule, or only the ones waiting on a publish. */
343
+ async list(options = {}, signal) {
344
+ const { schedules } = await this.http.request({
345
+ method: "GET",
346
+ path: "/schedules",
347
+ query: options.dueOnly ? { due: "1" } : {},
348
+ signal,
349
+ });
350
+ return schedules;
351
+ }
352
+ /**
353
+ * `recurrence` is a five-field cron expression in UTC, and it has to have a
354
+ * next occurrence — `0 0 30 2 *` is well-formed and never arrives, and is
355
+ * refused rather than stored.
356
+ */
357
+ create(input, signal) {
358
+ return this.http.request({ method: "POST", path: "/schedules", body: input, signal });
359
+ }
360
+ /**
361
+ * Change the cadence, or turn it on or off.
362
+ *
363
+ * Changing the cadence re-times the next run, so moving a weekly publish
364
+ * from Friday to Monday does not fire once more on the Friday.
365
+ */
366
+ update(id, input, signal) {
367
+ return this.http.request({
368
+ method: "PATCH",
369
+ path: `/schedules/${encodeURIComponent(id)}`,
370
+ body: input,
371
+ signal,
372
+ });
373
+ }
374
+ /** Remove it. `update(id, { enabled: false })` pauses it instead. */
375
+ delete(id, signal) {
376
+ return this.http.request({
377
+ method: "DELETE",
378
+ path: `/schedules/${encodeURIComponent(id)}`,
379
+ signal,
380
+ });
381
+ }
382
+ }
package/dist/reviews.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 { CreateReviewInput, ListReviewsInput, ReviewData, ReviewOutcome } from "./types.js";
3
4
  /**
@@ -66,7 +67,16 @@ export declare class Reviews {
66
67
  */
67
68
  create(input: CreateReviewInput, signal?: AbortSignal): Promise<Review>;
68
69
  get(id: string, signal?: AbortSignal): Promise<Review>;
70
+ /**
71
+ * The organisation's reviews, newest first.
72
+ *
73
+ * With no `limit` this is every one of them: the API says where each page
74
+ * stopped and this follows the cursor to the end. With a `limit` it is one
75
+ * page of that size, and `listPage` hands back the cursor to continue from.
76
+ */
69
77
  list(input?: ListReviewsInput, signal?: AbortSignal): Promise<Review[]>;
78
+ /** One page, and the cursor to continue from — null when it is the end. */
79
+ listPage(input?: ListReviewsInput, signal?: AbortSignal): Promise<PageOf<Review>>;
70
80
  /** Ask and wait, for the common case where there is nothing to do between. */
71
81
  request(input: CreateReviewInput, options?: ReviewWaitOptions): Promise<Review>;
72
82
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"reviews.d.ts","sourceRoot":"","sources":["../src/reviews.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB;;;;;;;GAOG;AAEH,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAQD,6CAA6C;AAC7C,qBAAa,MAAM;IAEf,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,IAAI;gBADK,IAAI,EAAE,UAAU,EACzB,IAAI,EAAE,UAAU;IAG1B,IAAI,EAAE,IAAI,MAAM,CAAyB;IACzC,IAAI,MAAM,IAAI,UAAU,CAAC,QAAQ,CAAC,CAA6B;IAC/D,kDAAkD;IAClD,IAAI,GAAG,IAAI,MAAM,CAA0B;IAC3C,IAAI,KAAK,IAAI,MAAM,CAA4B;IAC/C,IAAI,QAAQ,IAAI,UAAU,CAAC,UAAU,CAAC,CAA+B;IACrE,mEAAmE;IACnE,IAAI,WAAW,IAAI,MAAM,CAAkC;IAE3D,gFAAgF;IAChF,IAAI,QAAQ,IAAI,OAAO,CAA4C;IACnE,IAAI,gBAAgB,IAAI,OAA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M,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IASjD;;;;;;;OAOG;IACG,IAAI,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;CAyB3D;AAmBD,qBAAa,OAAO;IACN,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAUvE,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAS5D;;;;;;OAMG;IACG,IAAI,CAAC,KAAK,GAAE,gBAAqB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAOjF,2EAA2E;IACrE,QAAQ,CACZ,KAAK,GAAE,gBAAqB,EAC5B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAa1B,8EAA8E;IACxE,OAAO,CAAC,KAAK,EAAE,iBAAiB,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC;IAKzF;;;;;OAKG;IACG,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAIzF"}
package/dist/reviews.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) {
@@ -133,19 +134,28 @@ export class Reviews {
133
134
  });
134
135
  return new Review(this.http, data);
135
136
  }
137
+ /**
138
+ * The organisation's reviews, newest first.
139
+ *
140
+ * With no `limit` this is every one of them: the API says where each page
141
+ * stopped and this follows the cursor to the end. With a `limit` it is one
142
+ * page of that size, and `listPage` hands back the cursor to continue from.
143
+ */
136
144
  async list(input = {}, signal) {
137
- const { reviews } = await this.http.request({
145
+ return listOrCollect(input, async (q) => {
146
+ const page = await this.listPage({ ...input, ...q }, signal);
147
+ return { items: page.items, nextCursor: page.nextCursor };
148
+ });
149
+ }
150
+ /** One page, and the cursor to continue from — null when it is the end. */
151
+ async listPage(input = {}, signal) {
152
+ const { reviews, nextCursor } = await this.http.request({
138
153
  method: "GET",
139
154
  path: "/reviews",
140
- query: {
141
- status: input.status,
142
- externalId: input.externalId,
143
- reportId: input.reportId,
144
- limit: input.limit,
145
- },
155
+ query: { status: input.status, externalId: input.externalId, reportId: input.reportId, limit: input.limit, cursor: input.cursor },
146
156
  signal,
147
157
  });
148
- return reviews.map((r) => new Review(this.http, r));
158
+ return { items: reviews.map((r) => new Review(this.http, r)), nextCursor };
149
159
  }
150
160
  /** Ask and wait, for the common case where there is nothing to do between. */
151
161
  async request(input, options = {}) {