@wrenautomation/vireo 0.11.0 → 0.13.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/dist/store.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type Collector } from "./collect.js";
2
2
  import { type Db, type Hooks, type Tx } from "./db.js";
3
- import { type Anchor, batches, type GuideState, guides, type Kind, notes, samples, ships, steers, subjects, type Tone, type Verdict, type Width } from "./schema.js";
3
+ import { type Anchor, batches, calls, type GuideState, guides, type Kind, notes, samples, ships, steers, subjects, type Tone, type Verdict, type Width } from "./schema.js";
4
4
  import { type Strength } from "./stats.js";
5
5
  import { type Source } from "./sync.js";
6
6
  export interface Ports {
@@ -33,10 +33,29 @@ export type Parent = number | {
33
33
  export type SubjectRow = typeof subjects.$inferSelect;
34
34
  export type BatchRow = typeof batches.$inferSelect;
35
35
  export type SampleRow = typeof samples.$inferSelect;
36
+ export type CallRow = typeof calls.$inferSelect;
37
+ /** `by` of calls made before calls had a judge (migration 0008); a host may name them after. */
38
+ export declare const EARLIER_JUDGE = "person";
36
39
  export type NoteRow = typeof notes.$inferSelect;
37
40
  export type GuideRow = typeof guides.$inferSelect;
38
41
  export type ShipRow = typeof ships.$inferSelect;
39
42
  export type SteerRow = typeof steers.$inferSelect;
43
+ export declare const BATCH_SORTS: readonly ["waiting", "newest", "oldest", "subject", "good"];
44
+ export type BatchSort = (typeof BATCH_SORTS)[number];
45
+ /** A page of batches (D11). `subjects`: only these (a host's folder); `who`: batches they called in. */
46
+ export interface BatchQuery {
47
+ subjects?: readonly number[];
48
+ subject?: string | number;
49
+ kind?: Kind;
50
+ /** waits = open and its subject's newest */
51
+ state?: "open" | "closed" | "waits";
52
+ who?: string;
53
+ /** default waiting: what waits first, then newest */
54
+ sort?: BatchSort;
55
+ limit?: number;
56
+ /** offset: the `next` of the page before */
57
+ after?: number;
58
+ }
40
59
  /** A steer to set (D10). pin, prune: `sample`. cross: `sample` and `other`. width: `subject`. */
41
60
  export type NewSteer = {
42
61
  kind: "pin" | "prune";
@@ -53,13 +72,28 @@ export type NewSteer = {
53
72
  width: Width;
54
73
  why?: string | null;
55
74
  };
75
+ type Called = Pick<CallRow, "sampleId" | "by" | "score" | "verdict">;
76
+ /**
77
+ * One sheet per (batch, person) who called in it: each sample of the batch with that person's
78
+ * call, or none (unmarked). The unit of every rank and rate (D11).
79
+ */
80
+ export declare function sheets(rows: readonly Pick<SampleRow, "id" | "batchId">[], cs: readonly Called[]): {
81
+ batchId: number;
82
+ by: string;
83
+ marks: {
84
+ id: number;
85
+ call: Called | null;
86
+ }[];
87
+ }[];
56
88
  /**
57
- * Strength per judged sample: each judged batch is a partial ranking by score, 10 down to 1, ties
58
- * unordered. Wins from 9 and up count double.
89
+ * Strength per judged sample: each sheet is a partial ranking by score, 10 down to 1, ties
90
+ * unordered; unmarked reads as 5. Wins from 9 and up count double.
59
91
  */
60
- export declare function strengths(rows: readonly Pick<SampleRow, "id" | "batchId" | "score">[]): Strength[];
61
- /** With-vs-without good rate per guide, over judged samples. */
62
- export declare function guideStats(guideRows: readonly GuideRow[], judged: readonly SampleRow[]): {
92
+ export declare function strengths(rows: readonly Pick<SampleRow, "id" | "batchId">[], cs: readonly Called[]): Strength[];
93
+ /** Good or better over every (sample, person) mark of these sheets; null with none. */
94
+ export declare function goodRateOf(ss: ReturnType<typeof sheets>): number | null;
95
+ /** With-vs-without good rate per guide, over every mark in judged batches. */
96
+ export declare function guideStats(guideRows: readonly GuideRow[], judged: readonly SampleRow[], cs: readonly Called[]): {
63
97
  effect: {
64
98
  with: {
65
99
  good: number;
@@ -99,6 +133,7 @@ export declare class Vireo {
99
133
  /** More samples in an open batch: `addBatch` with `into`, the subject read from the batch. */
100
134
  appendBatch(ref: string | number, b: {
101
135
  why: string;
136
+ title?: string | null;
102
137
  agent?: string | null;
103
138
  samples: NewSample[];
104
139
  }): Promise<{
@@ -162,6 +197,7 @@ export declare class Vireo {
162
197
  /** A new batch, or with `into` (id or `<subject>:<n>`) more samples in an open one. */
163
198
  addBatch(ref: string | number, b: {
164
199
  why: string;
200
+ title?: string | null;
165
201
  agent?: string | null;
166
202
  samples: NewSample[];
167
203
  into?: string | number | null;
@@ -222,12 +258,16 @@ export declare class Vireo {
222
258
  }[];
223
259
  pruned: number[];
224
260
  }>;
225
- /** Batches that wait on the person, oldest first, with samples and notes: what they have to pick. */
226
- queue(ref?: string | number): Promise<{
261
+ /**
262
+ * Batches that wait on the person, oldest first, with samples and notes: what they have to pick.
263
+ * `viewer`: a person sees only their own calls and notes (D11).
264
+ */
265
+ queue(ref?: string | number, viewer?: string | null): Promise<{
227
266
  batch: {
228
267
  id: number;
229
268
  subjectId: number;
230
269
  n: number;
270
+ title: string | null;
231
271
  why: string;
232
272
  agent: string | null;
233
273
  state: "open" | "closed";
@@ -247,7 +287,15 @@ export declare class Vireo {
247
287
  by: string | null;
248
288
  createdAt: Date;
249
289
  };
250
- samples: {
290
+ samples: ({
291
+ calls: {
292
+ id: number;
293
+ sampleId: number;
294
+ by: string;
295
+ score: number;
296
+ verdict: "amazing" | "good" | "okay" | "bad";
297
+ at: Date;
298
+ }[];
251
299
  notes: {
252
300
  id: number;
253
301
  sampleId: number;
@@ -257,6 +305,8 @@ export declare class Vireo {
257
305
  by: string | null;
258
306
  createdAt: Date;
259
307
  }[];
308
+ score: null;
309
+ verdict: null;
260
310
  id: number;
261
311
  batchId: number;
262
312
  subjectId: number;
@@ -269,20 +319,62 @@ export declare class Vireo {
269
319
  guides: number[];
270
320
  change: string | null;
271
321
  agent: string | null;
272
- score: number | null;
273
- verdict: "amazing" | "good" | "okay" | "bad" | null;
274
322
  keptAt: Date | null;
275
323
  createdAt: Date;
276
- }[];
324
+ } | {
325
+ calls: {
326
+ id: number;
327
+ sampleId: number;
328
+ by: string;
329
+ score: number;
330
+ verdict: "amazing" | "good" | "okay" | "bad";
331
+ at: Date;
332
+ }[];
333
+ notes: {
334
+ id: number;
335
+ sampleId: number;
336
+ anchor: Anchor | null;
337
+ tone: "good" | "bad" | null;
338
+ text: string | null;
339
+ by: string | null;
340
+ createdAt: Date;
341
+ }[];
342
+ score: number;
343
+ verdict: "amazing" | "good" | "okay" | "bad";
344
+ id: number;
345
+ batchId: number;
346
+ subjectId: number;
347
+ position: number;
348
+ body: string | null;
349
+ media: string | null;
350
+ poster: string | null;
351
+ source: Source | null;
352
+ name: string | null;
353
+ guides: number[];
354
+ change: string | null;
355
+ agent: string | null;
356
+ keptAt: Date | null;
357
+ createdAt: Date;
358
+ })[];
277
359
  }[]>;
360
+ private callsOf;
278
361
  private notesOf;
279
362
  /** Parent edges of these children, main parent first. */
280
363
  private lineageOf;
281
- /** A call: a 1-10 score, a verdict (its tap score) or null to clear. The verdict follows. */
364
+ /**
365
+ * `by`'s call: a 1-10 score, a verdict (its tap score) or null to clear. The verdict follows.
366
+ * One call per person per sample (D11).
367
+ */
282
368
  judge(sampleId: number, call: number | Verdict | null, by: string | null): Promise<{
283
369
  id: number;
284
- score: number | null;
285
- verdict: "amazing" | "good" | "okay" | "bad" | null;
370
+ by: string;
371
+ score: null;
372
+ verdict: null;
373
+ } | {
374
+ id: number;
375
+ by: string;
376
+ score: number;
377
+ verdict: "amazing" | "good" | "okay" | "bad";
286
378
  }>;
287
379
  addNote(sampleId: number, n: {
288
380
  anchor?: Anchor | null;
@@ -317,6 +409,12 @@ export declare class Vireo {
317
409
  slug: string;
318
410
  name: string;
319
411
  } | undefined>;
412
+ /** A batch's title (id or `<subject>:<n>`); blank refused. */
413
+ renameBatch(ref: string | number, title: string, by: string | null): Promise<{
414
+ id: number;
415
+ n: number;
416
+ title: string | null;
417
+ }>;
320
418
  /** A sample's short name; blank clears it. */
321
419
  renameSample(sampleId: number, name: string | null, by: string | null): Promise<{
322
420
  id: number;
@@ -408,7 +506,16 @@ export declare class Vireo {
408
506
  }[];
409
507
  batches: {
410
508
  goodRate: number | null;
411
- samples: {
509
+ judges: string[];
510
+ samples: ({
511
+ calls: {
512
+ id: number;
513
+ sampleId: number;
514
+ by: string;
515
+ score: number;
516
+ verdict: "amazing" | "good" | "okay" | "bad";
517
+ at: Date;
518
+ }[];
412
519
  strength: Strength | null;
413
520
  notes: {
414
521
  id: number;
@@ -423,6 +530,8 @@ export declare class Vireo {
423
530
  id: number;
424
531
  took: string | null;
425
532
  }[];
533
+ score: null;
534
+ verdict: null;
426
535
  id: number;
427
536
  batchId: number;
428
537
  subjectId: number;
@@ -435,14 +544,52 @@ export declare class Vireo {
435
544
  guides: number[];
436
545
  change: string | null;
437
546
  agent: string | null;
438
- score: number | null;
439
- verdict: "amazing" | "good" | "okay" | "bad" | null;
440
547
  keptAt: Date | null;
441
548
  createdAt: Date;
442
- }[];
549
+ } | {
550
+ calls: {
551
+ id: number;
552
+ sampleId: number;
553
+ by: string;
554
+ score: number;
555
+ verdict: "amazing" | "good" | "okay" | "bad";
556
+ at: Date;
557
+ }[];
558
+ strength: Strength | null;
559
+ notes: {
560
+ id: number;
561
+ sampleId: number;
562
+ anchor: Anchor | null;
563
+ tone: "good" | "bad" | null;
564
+ text: string | null;
565
+ by: string | null;
566
+ createdAt: Date;
567
+ }[];
568
+ parents: {
569
+ id: number;
570
+ took: string | null;
571
+ }[];
572
+ score: number;
573
+ verdict: "amazing" | "good" | "okay" | "bad";
574
+ id: number;
575
+ batchId: number;
576
+ subjectId: number;
577
+ position: number;
578
+ body: string | null;
579
+ media: string | null;
580
+ poster: string | null;
581
+ source: Source | null;
582
+ name: string | null;
583
+ guides: number[];
584
+ change: string | null;
585
+ agent: string | null;
586
+ keptAt: Date | null;
587
+ createdAt: Date;
588
+ })[];
443
589
  id: number;
444
590
  subjectId: number;
445
591
  n: number;
592
+ title: string | null;
446
593
  why: string;
447
594
  agent: string | null;
448
595
  state: "open" | "closed";
@@ -507,6 +654,161 @@ export declare class Vireo {
507
654
  }[];
508
655
  }>;
509
656
  /** Kept samples, newest first, with their subject. */
657
+ /**
658
+ * Batches as a page: filters, a sort and an offset (D11). `viewer` = the person reading: an open
659
+ * batch shows only their own marks, and none of the agent's words.
660
+ */
661
+ batches(q?: BatchQuery, viewer?: string | null): Promise<{
662
+ rows: {
663
+ ref: string;
664
+ id: number;
665
+ n: number;
666
+ title: string | null;
667
+ state: "open" | "closed";
668
+ note: string | null;
669
+ why: string | null;
670
+ createdAt: Date;
671
+ subject: {
672
+ id: number;
673
+ slug: string;
674
+ name: string;
675
+ kind: "text" | "image" | "video" | "page";
676
+ brief: string | null;
677
+ seeds: string[];
678
+ state: "open" | "paused" | "done";
679
+ by: string | null;
680
+ createdAt: Date;
681
+ };
682
+ waits: boolean;
683
+ samples: number;
684
+ kept: number;
685
+ marked: number;
686
+ judges: number | null;
687
+ goodRate: number | null;
688
+ tally: {
689
+ amazing: number;
690
+ good: number;
691
+ okay: number;
692
+ bad: number;
693
+ unmarked: number;
694
+ } | null;
695
+ thumbs: {
696
+ id: number;
697
+ poster: string;
698
+ verdict: "amazing" | "good" | "okay" | "bad" | null;
699
+ }[];
700
+ }[];
701
+ next: number | null;
702
+ waiting: number;
703
+ }>;
704
+ /** One batch whole, for `viewer` (see `batches`); `newer` = the subject's newer open batch. */
705
+ batch(ref: string | number, viewer?: string | null): Promise<{
706
+ why: string | null;
707
+ subject: {
708
+ id: number;
709
+ slug: string;
710
+ name: string;
711
+ kind: "text" | "image" | "video" | "page";
712
+ brief: string | null;
713
+ seeds: string[];
714
+ state: "open" | "paused" | "done";
715
+ by: string | null;
716
+ createdAt: Date;
717
+ };
718
+ goodRate: number | null;
719
+ judges: string[] | null;
720
+ newer: {
721
+ n: number;
722
+ ref: string;
723
+ } | null;
724
+ samples: ({
725
+ calls: {
726
+ id: number;
727
+ sampleId: number;
728
+ by: string;
729
+ score: number;
730
+ verdict: "amazing" | "good" | "okay" | "bad";
731
+ at: Date;
732
+ }[];
733
+ notes: {
734
+ id: number;
735
+ sampleId: number;
736
+ anchor: Anchor | null;
737
+ tone: "good" | "bad" | null;
738
+ text: string | null;
739
+ by: string | null;
740
+ createdAt: Date;
741
+ }[];
742
+ parents: {
743
+ id: number;
744
+ took: string | null;
745
+ }[];
746
+ score: null;
747
+ verdict: null;
748
+ name: string | null;
749
+ change: string | null;
750
+ id: number;
751
+ batchId: number;
752
+ subjectId: number;
753
+ position: number;
754
+ body: string | null;
755
+ media: string | null;
756
+ poster: string | null;
757
+ source: Source | null;
758
+ guides: number[];
759
+ agent: string | null;
760
+ keptAt: Date | null;
761
+ createdAt: Date;
762
+ } | {
763
+ calls: {
764
+ id: number;
765
+ sampleId: number;
766
+ by: string;
767
+ score: number;
768
+ verdict: "amazing" | "good" | "okay" | "bad";
769
+ at: Date;
770
+ }[];
771
+ notes: {
772
+ id: number;
773
+ sampleId: number;
774
+ anchor: Anchor | null;
775
+ tone: "good" | "bad" | null;
776
+ text: string | null;
777
+ by: string | null;
778
+ createdAt: Date;
779
+ }[];
780
+ parents: {
781
+ id: number;
782
+ took: string | null;
783
+ }[];
784
+ score: number;
785
+ verdict: "amazing" | "good" | "okay" | "bad";
786
+ name: string | null;
787
+ change: string | null;
788
+ id: number;
789
+ batchId: number;
790
+ subjectId: number;
791
+ position: number;
792
+ body: string | null;
793
+ media: string | null;
794
+ poster: string | null;
795
+ source: Source | null;
796
+ guides: number[];
797
+ agent: string | null;
798
+ keptAt: Date | null;
799
+ createdAt: Date;
800
+ })[];
801
+ id: number;
802
+ subjectId: number;
803
+ n: number;
804
+ title: string | null;
805
+ agent: string | null;
806
+ state: "open" | "closed";
807
+ note: string | null;
808
+ closedAt: Date | null;
809
+ createdAt: Date;
810
+ ref: string;
811
+ }>;
510
812
  catalog(opts?: {
511
813
  kind?: Kind;
512
814
  subject?: string | number;
@@ -524,8 +826,6 @@ export declare class Vireo {
524
826
  guides: number[];
525
827
  change: string | null;
526
828
  agent: string | null;
527
- score: number | null;
528
- verdict: "amazing" | "good" | "okay" | "bad" | null;
529
829
  keptAt: Date | null;
530
830
  createdAt: Date;
531
831
  };
@@ -538,7 +838,10 @@ export declare class Vireo {
538
838
  }
539
839
  /** Read models a host's page renders: no hand-copied types. */
540
840
  export type Queue = Awaited<ReturnType<Vireo["queue"]>>;
841
+ export type BatchPage = Awaited<ReturnType<Vireo["batches"]>>;
842
+ export type BatchWhole = Awaited<ReturnType<Vireo["batch"]>>;
541
843
  export type Feedback = Awaited<ReturnType<Vireo["feedback"]>>;
542
844
  export type SubjectList = Awaited<ReturnType<Vireo["listSubjects"]>>;
543
845
  export type Catalog = Awaited<ReturnType<Vireo["catalog"]>>;
544
846
  export type Steers = Awaited<ReturnType<Vireo["steersOf"]>>;
847
+ export {};