@larc-iu/plaid-client 0.2.0-alpha.11 → 0.2.0-alpha.13

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/index.d.ts CHANGED
@@ -25,6 +25,8 @@ interface ServiceParam {
25
25
  min?: number;
26
26
  max?: number;
27
27
  step?: number;
28
+ /** `number` only: render as a slider to drag rather than a box to type in. */
29
+ slider?: boolean;
28
30
  /** `string` only. */
29
31
  placeholder?: string;
30
32
  multiline?: boolean;
@@ -70,14 +72,41 @@ interface ServiceRegistration {
70
72
  }
71
73
 
72
74
  /** Connection-state transitions reported by a service registration. */
73
- type ServiceStatusEvent = 'registered' | 'reconnected' | 'disconnected';
75
+ type ServiceStatusEvent = "registered" | "reconnected" | "disconnected";
74
76
 
75
77
  interface ResponseHelper {
76
- progress(percent: number, message: string): void;
78
+ requestId: string;
79
+ requesterId: string | null;
80
+ /** True once the requester has asked this request to stop. */
81
+ readonly cancelled: boolean;
82
+ /**
83
+ * Report progress — and a cancellation CHECKPOINT: throws
84
+ * `ServiceCancelled` once a stop has been asked for, which is what makes a
85
+ * service that already reports progress cancellable for free.
86
+ */
87
+ progress(percent: number, message: string, extra?: Record<string, any>): void;
88
+ /** Stop here if the requester has asked the request to stop. */
89
+ raiseIfCancelled(): void;
90
+ /** Run `fn` as a stretch that must finish once begun, usually the writes. */
91
+ critical<T>(fn: () => T | Promise<T>): Promise<T>;
77
92
  complete(data: any): void;
93
+ /** End the request because it was asked to stop; result carries `stopped: true`. */
94
+ stopped(data?: any): void;
78
95
  error(error: string | Error): void;
79
96
  }
80
97
 
98
+ /** Thrown inside a handler when the requester has asked it to stop. */
99
+ export class ServiceCancelled extends Error {
100
+ constructor(message?: string);
101
+ }
102
+
103
+ /** The cancellation half of a responseHelper, on its own. */
104
+ export function createCancelScope(isCancelled: () => boolean): {
105
+ readonly cancelled: boolean;
106
+ raiseIfCancelled(): void;
107
+ critical<T>(fn: () => T | Promise<T>): Promise<T>;
108
+ };
109
+
81
110
  interface SSEConnection {
82
111
  close(): void;
83
112
  getStats(): any;
@@ -267,6 +296,7 @@ interface UsersBundle {
267
296
  endTime?: string,
268
297
  asOf?: string,
269
298
  ): Promise<any[]>;
299
+ auditPage(userId: string, opts?: AuditPageOptions): Promise<Page>;
270
300
  get(id: string, asOf?: string): Promise<any>;
271
301
  delete(id: string, auditMessage?: string): Promise<any>;
272
302
  activate(id: string, auditMessage?: string): Promise<any>;
@@ -313,12 +343,7 @@ interface CommentFilters {
313
343
 
314
344
  /** Entities that can carry a comment. */
315
345
  type CommentableType =
316
- | "document"
317
- | "text"
318
- | "token"
319
- | "span"
320
- | "relation"
321
- | "vocab-item";
346
+ "document" | "text" | "token" | "span" | "relation" | "vocab-item";
322
347
 
323
348
  interface Comment {
324
349
  id: string;
@@ -446,15 +471,182 @@ interface CreateInviteOptions {
446
471
  note?: string;
447
472
  }
448
473
 
474
+ /** Server limits, as reported by /api/v1/info. An unset limit is absent. */
475
+ interface ServerLimits {
476
+ mediaFileBytes?: number;
477
+ jsonBodyBytes?: number;
478
+ batchOperations?: number;
479
+ metadataDepth?: number;
480
+ metadataKeyCount?: number;
481
+ metadataStringLength?: number;
482
+ metadataTotalBytes?: number;
483
+ userDataValueBytes?: number;
484
+ }
485
+
486
+ interface ServerHealth {
487
+ ok: boolean;
488
+ version: string;
489
+ uptimeMs: number;
490
+ audit: { dbSizeMb?: number; auditRows?: number; error?: string };
491
+ }
492
+
493
+ interface DocumentLock {
494
+ documentId: string;
495
+ userId: string;
496
+ expiresAt: number;
497
+ }
498
+
499
+ interface RateLimitBucket {
500
+ ip: string;
501
+ userId?: string;
502
+ failures: number;
503
+ limit: number;
504
+ blocked: boolean;
505
+ }
506
+
507
+ interface RateLimitSnapshot {
508
+ windowMs: number;
509
+ logins: RateLimitBucket[];
510
+ ips: RateLimitBucket[];
511
+ invites: RateLimitBucket[];
512
+ }
513
+
514
+ interface BackupStatus {
515
+ enabled: boolean;
516
+ directory: string;
517
+ retention: number;
518
+ time: string;
519
+ backups: Array<{ name: string; bytes: number; modified: string }>;
520
+ ok?: boolean;
521
+ }
522
+
523
+ interface ServerReport {
524
+ version: string;
525
+ jvm: {
526
+ uptimeMs: number;
527
+ startedAt: string;
528
+ java: string;
529
+ heapUsed: number;
530
+ heapMax: number;
531
+ };
532
+ database: {
533
+ path: string | null;
534
+ bytes: number | null;
535
+ walBytes: number | null;
536
+ slowQueryThresholdMs?: number;
537
+ journalMode?: string;
538
+ maxPoolSize?: number;
539
+ tables: Record<string, number | null>;
540
+ };
541
+ media: {
542
+ directory: string;
543
+ files: number;
544
+ bytes: number;
545
+ orphans: number;
546
+ orphanBytes: number;
547
+ };
548
+ backup: BackupStatus;
549
+ settings: Record<string, any>;
550
+ }
551
+
552
+ /** Server-level facts. `info` is fetched at most once per client. */
553
+ interface ServerBundle {
554
+ info(): Promise<{ limits: ServerLimits }>;
555
+ limits(): Promise<ServerLimits>;
556
+ health(): Promise<ServerHealth>;
557
+ }
558
+
559
+ /** Instance-wide operations. Every method requires a global admin. */
560
+ interface AdminBundle {
561
+ server(): Promise<ServerReport>;
562
+ backup(): Promise<BackupStatus>;
563
+ locks(): Promise<{ entries: DocumentLock[] }>;
564
+ releaseLock(documentId: string): Promise<{ result: string }>;
565
+ rateLimits(): Promise<RateLimitSnapshot>;
566
+ clearRateLimits(opts?: {
567
+ ip?: string;
568
+ userId?: string;
569
+ }): Promise<{ result: string }>;
570
+ logs(opts?: {
571
+ lines?: number;
572
+ }): Promise<{ file: string | null; lines: string[]; error?: string }>;
573
+ userData(opts?: AdminUserDataOptions): Promise<AdminUserDataEntry[]>;
574
+ userDataPage(
575
+ opts?: AdminUserDataOptions & { limit?: number; cursor?: string },
576
+ ): Promise<Page<AdminUserDataEntry>>;
577
+ }
578
+
579
+ /** Narrowings for the cross-account private-data listing. */
580
+ interface AdminUserDataOptions {
581
+ /** Only keys starting with this literal head. */
582
+ prefix?: string;
583
+ /** Only keys matching this GLOB (`*` any run, `?` one character). */
584
+ pattern?: string;
585
+ includeValues?: boolean;
586
+ }
587
+
588
+ type AdminUserDataEntry = UserDataEntry & { userId: string };
589
+
590
+ /** Options for a single page of any audit log. */
591
+ interface AuditPageOptions {
592
+ startTime?: string;
593
+ endTime?: string;
594
+ asOf?: string;
595
+ opTypes?: string[] | string;
596
+ /** "desc" pages newest-first; a cursor belongs to the direction that made it. */
597
+ order?: "asc" | "desc";
598
+ limit?: number;
599
+ cursor?: string;
600
+ }
601
+
602
+ /** One user's activity over a scope and window. */
603
+ interface ActivityTallyRow {
604
+ user: { id: string; displayName?: string };
605
+ operations: number;
606
+ changes: number;
607
+ documents: number;
608
+ firstTs: string;
609
+ lastTs: string;
610
+ byDay?: Array<{ date: string; changes: number }>;
611
+ }
612
+
613
+ /** Instance-wide audit reads and the per-user aggregate. */
614
+ interface AuditBundle {
615
+ /** Admin only. */
616
+ list(opts?: {
617
+ startTime?: string;
618
+ endTime?: string;
619
+ opTypes?: string[] | string;
620
+ }): Promise<any[]>;
621
+ /** Admin only. */
622
+ listPage(opts?: AuditPageOptions): Promise<Page>;
623
+ /** Admin only. */
624
+ iterPages(opts?: {
625
+ startTime?: string;
626
+ endTime?: string;
627
+ opTypes?: string[] | string;
628
+ pageSize?: number;
629
+ }): AsyncGenerator<any[]>;
630
+ /** With projectId, open to that project's maintainers; without one, admin only. */
631
+ tally(opts?: {
632
+ projectId?: string;
633
+ startTime?: string;
634
+ endTime?: string;
635
+ daily?: boolean;
636
+ }): Promise<ActivityTallyRow[]>;
637
+ }
638
+
449
639
  interface InvitesBundle {
450
- list(opts?: { projectId?: string }): Promise<Invite[]>;
640
+ list(opts?: { projectId?: string; all?: boolean }): Promise<Invite[]>;
451
641
  listPage(opts?: {
452
642
  projectId?: string;
643
+ all?: boolean;
453
644
  limit?: number;
454
645
  cursor?: string;
455
646
  }): Promise<Page>;
456
647
  iterPages(opts?: {
457
648
  projectId?: string;
649
+ all?: boolean;
458
650
  pageSize?: number;
459
651
  }): AsyncGenerator<Invite[]>;
460
652
  /** The `code` is returned ONCE and is not recoverable afterward. */
@@ -532,6 +724,7 @@ interface DocumentsBundle {
532
724
  endTime?: string,
533
725
  asOf?: string,
534
726
  ): Promise<any[]>;
727
+ auditPage(documentId: string, opts?: AuditPageOptions): Promise<Page>;
535
728
  get(documentId: string, includeBody?: boolean, asOf?: string): Promise<any>;
536
729
  delete(documentId: string, auditMessage?: string): Promise<any>;
537
730
  update(documentId: string, name: string, auditMessage?: string): Promise<any>;
@@ -541,6 +734,19 @@ interface DocumentsBundle {
541
734
  metadata?: any,
542
735
  auditMessage?: string,
543
736
  ): Promise<any>;
737
+ /** Copy a document and everything in it into a new document of the same project. */
738
+ copy(
739
+ documentId: string,
740
+ name: string,
741
+ options?: { includeMedia?: boolean },
742
+ auditMessage?: string,
743
+ ): Promise<{ id: string; mediaError?: string }>;
744
+ restore(
745
+ documentId: string,
746
+ asOf: string,
747
+ options?: { dryRun?: boolean },
748
+ auditMessage?: string,
749
+ ): Promise<any>;
544
750
  }
545
751
 
546
752
  interface MessagesBundle {
@@ -567,7 +773,11 @@ interface MessagesBundle {
567
773
  serviceInfo: ServiceInfo,
568
774
  onServiceRequest: (data: any, responseHelper: ResponseHelper) => void,
569
775
  extras?: any,
570
- onStatus?: (event: ServiceStatusEvent, projectId: string, detail?: string) => void,
776
+ onStatus?: (
777
+ event: ServiceStatusEvent,
778
+ projectId: string,
779
+ detail?: string,
780
+ ) => void,
571
781
  ): ServiceRegistration;
572
782
  /**
573
783
  * Submit work to a service; streams progress to `onProgress`, resolves with
@@ -618,6 +828,7 @@ interface ProjectsBundle {
618
828
  endTime?: string,
619
829
  asOf?: string,
620
830
  ): Promise<any[]>;
831
+ auditPage(projectId: string, opts?: AuditPageOptions): Promise<Page>;
621
832
  linkVocab(id: string, vocabId: string, auditMessage?: string): Promise<any>;
622
833
  unlinkVocab(id: string, vocabId: string, auditMessage?: string): Promise<any>;
623
834
  get(id: string, asOf?: string): Promise<any>;
@@ -852,6 +1063,9 @@ export declare class PlaidClient {
852
1063
  apiTokens: ApiTokensBundle;
853
1064
  userData: UserDataBundle;
854
1065
  invites: InvitesBundle;
1066
+ server: ServerBundle;
1067
+ admin: AdminBundle;
1068
+ audit: AuditBundle;
855
1069
  comments: CommentsBundle;
856
1070
  tokenLayers: TokenLayersBundle;
857
1071
  documents: DocumentsBundle;
@@ -919,6 +1133,9 @@ export const TASKS: {
919
1133
  readonly TRANSCRIBE: "transcribe";
920
1134
  readonly LINK_VOCAB: "link-vocab";
921
1135
  readonly ANALYZE: "analyze";
1136
+ readonly TRANSLATE: "translate";
1137
+ readonly ASSIST: "assist";
1138
+ readonly DETECT_SPEECH: "detect-speech";
922
1139
  };
923
1140
  /** Whether a service serves a task (declared `extras.tasks`, legacy id-prefix fallback). */
924
1141
  export function servesTask(service: DiscoveredService, task: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@larc-iu/plaid-client",
3
- "version": "0.2.0-alpha.11",
3
+ "version": "0.2.0-alpha.13",
4
4
  "description": "JavaScript client for the Plaid annotation API",
5
5
  "type": "module",
6
6
  "repository": {