@deliverd/sdk 0.1.0 → 0.2.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/src/types.ts CHANGED
@@ -202,7 +202,10 @@ export type WebhookEventName =
202
202
  | "approval.rejected"
203
203
  | "approval.expired"
204
204
  | "approval.question"
205
- | "approval.answered";
205
+ | "approval.answered"
206
+ | "review.requested"
207
+ | "review.approved"
208
+ | "review.changes_requested";
206
209
 
207
210
  export interface WebhookEvent {
208
211
  event: WebhookEventName;
@@ -211,3 +214,99 @@ export interface WebhookEvent {
211
214
  test?: boolean;
212
215
  data: Record<string, unknown>;
213
216
  }
217
+
218
+ /* ── Reviews ──────────────────────────────────────────────────────────────── */
219
+
220
+ export type ReviewStatus =
221
+ | "pending"
222
+ | "approved"
223
+ | "changes_requested"
224
+ | "expired"
225
+ | "cancelled";
226
+
227
+ export interface CreateReviewInput {
228
+ /** What is being reviewed, as a headline the reviewer sees first. */
229
+ title: string;
230
+ /**
231
+ * What to check. Without this a reviewer decides what "review" means, and
232
+ * usually decides it means "looks fine".
233
+ */
234
+ instructions?: string;
235
+ /** The published report under review; the reviewer reads it and comments on it. */
236
+ reportId?: string;
237
+ /** Pin a version, so publishing again mid-review does not move the ground. */
238
+ versionId?: string;
239
+ /**
240
+ * Emails or user ids. An active member, or a guest who can already open the
241
+ * report — anyone else is refused rather than emailed. You cannot name
242
+ * yourself.
243
+ */
244
+ reviewers: string[];
245
+ /**
246
+ * How many approvals settle it; one when omitted. A single "changes
247
+ * requested" settles it regardless.
248
+ */
249
+ requiredApprovals?: number;
250
+ /** After this the review expires unanswered. ISO 8601. */
251
+ expiresAt?: string;
252
+ /** Your own reference, returned unchanged and searchable. */
253
+ externalId?: string;
254
+ metadata?: Record<string, unknown>;
255
+ }
256
+
257
+ export interface ReviewerRef {
258
+ kind: "user" | "guest";
259
+ id: string;
260
+ label: string;
261
+ }
262
+
263
+ export interface ReviewVerdict {
264
+ verdict: "approved" | "changes_requested";
265
+ /** Who gave it, as a name rather than an id. */
266
+ by: string;
267
+ note: string | null;
268
+ at: string;
269
+ }
270
+
271
+ export interface ReviewData {
272
+ id: string;
273
+ status: ReviewStatus;
274
+ /** The page the reviewer reads and decides on. */
275
+ url: string;
276
+ title: string;
277
+ instructions: string | null;
278
+ reportId: string | null;
279
+ versionId: string | null;
280
+ externalId: string | null;
281
+ metadata: Record<string, unknown>;
282
+ requestedBy: string;
283
+ requiredApprovals: number;
284
+ reviewers: ReviewerRef[];
285
+ verdicts: ReviewVerdict[];
286
+ /** How many comment threads the reviewers opened while reading. */
287
+ threadCount: number;
288
+ settledAt: string | null;
289
+ expiresAt: string | null;
290
+ createdAt: string;
291
+ }
292
+
293
+ /** The answer, flattened — what `review()` hands back. */
294
+ export interface ReviewOutcome {
295
+ /** The one to branch on. False for changes requested, expired and cancelled. */
296
+ approved: boolean;
297
+ status: Exclude<ReviewStatus, "pending">;
298
+ /** Every verdict returned, in the order they arrived. */
299
+ verdicts: ReviewVerdict[];
300
+ /** How many comment threads to read before producing the next version. */
301
+ threadCount: number;
302
+ id: string;
303
+ url: string;
304
+ review: ReviewData;
305
+ }
306
+
307
+ export interface ListReviewsInput {
308
+ status?: ReviewStatus;
309
+ externalId?: string;
310
+ reportId?: string;
311
+ limit?: number;
312
+ }