@persistmemory/sdk 0.1.1 → 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.
@@ -0,0 +1,84 @@
1
+ import type { HttpClient, RequestOptions } from "../http.js";
2
+ import type { DriveFile, MailMessage, MailSummary, Person, SaveToDriveParams, SearchDriveParams, SearchMailParams } from "../types.js";
3
+ /**
4
+ * A user's own Google, through this API rather than through Google.
5
+ *
6
+ * The distinction is the point. Google's tokens live encrypted on the server
7
+ * and never reach a client, so an API key that leaks is an API key - not a
8
+ * mailbox. Nothing here takes a Google credential, and nothing here ever will.
9
+ *
10
+ * Every method answers 409 when there is no connected account, or when Google
11
+ * has stopped renewing one. Neither is a server fault and neither is fixed by
12
+ * retrying: the user has to connect or reconnect at
13
+ * persistmemory.com/dashboard/connect, and the error message says so.
14
+ */
15
+ export declare class Google {
16
+ #private;
17
+ constructor(http: HttpClient);
18
+ /** Files by name, newest first. Omit the query for recently changed ones. */
19
+ searchDrive(params?: SearchDriveParams, options?: RequestOptions): Promise<{
20
+ data: DriveFile[];
21
+ }>;
22
+ getDriveFile(fileId: string, options?: RequestOptions): Promise<DriveFile>;
23
+ /**
24
+ * The bytes of a Drive file.
25
+ *
26
+ * A Google Doc, Sheet or Slide holds no bytes of its own and is exported on
27
+ * the way - a document as PDF, a spreadsheet as CSV - so `filename` comes
28
+ * back describing what it BECAME. Writing it under the id instead produces a
29
+ * file nothing will open.
30
+ */
31
+ downloadDriveFile(fileId: string, options?: RequestOptions): Promise<{
32
+ bytes: Uint8Array;
33
+ contentType: string;
34
+ filename?: string;
35
+ }>;
36
+ /**
37
+ * Writes a file into the user's Drive.
38
+ *
39
+ * Needs one of the Drive write permissions on their connection. A read-only
40
+ * grant is refused by Google, and the error names the missing permission
41
+ * rather than reporting a failed upload - one is fixed with a checkbox and
42
+ * the other sends somebody looking for a bug.
43
+ */
44
+ saveToDrive(params: SaveToDriveParams, options?: RequestOptions): Promise<DriveFile>;
45
+ /**
46
+ * Recent messages - senders, subjects and a one-line preview, never bodies.
47
+ *
48
+ * `query` is Gmail's own syntax passed through as written: `from:priya`,
49
+ * `has:attachment`, `newer_than:7d`. It selects within the connected mailbox
50
+ * and cannot reach another one.
51
+ */
52
+ searchMail(params?: SearchMailParams, options?: RequestOptions): Promise<{
53
+ data: MailSummary[];
54
+ }>;
55
+ /** One message, with its body and the names of what is attached. */
56
+ readMail(messageId: string, options?: RequestOptions): Promise<MailMessage>;
57
+ /**
58
+ * The bytes of one attachment.
59
+ *
60
+ * Separate from `readMail` so listing a mailbox never drags attachments
61
+ * across the network: a message with a 40 MB deck should not cost 40 MB to
62
+ * summarise.
63
+ */
64
+ downloadAttachment(messageId: string, attachmentId: string, options?: RequestOptions): Promise<{
65
+ bytes: Uint8Array;
66
+ contentType: string;
67
+ }>;
68
+ /** Sends as the connected account. Needs the send permission. */
69
+ sendMail(params: {
70
+ to: string;
71
+ subject: string;
72
+ body: string;
73
+ replyToMessageId?: string;
74
+ }, options?: RequestOptions): Promise<{
75
+ id: string;
76
+ }>;
77
+ /** People in the user's contacts. Omit the query to list them. */
78
+ contacts(params?: {
79
+ query?: string;
80
+ limit?: number;
81
+ }, options?: RequestOptions): Promise<{
82
+ data: Person[];
83
+ }>;
84
+ }
package/dist/types.d.ts CHANGED
@@ -494,7 +494,98 @@ export interface UpdateIntegrationParams {
494
494
  readonly enabled?: boolean;
495
495
  readonly spaceIds?: readonly string[];
496
496
  }
497
+ /** A file asked of one of the caller's own machines. */
498
+ export interface AgentRequest {
499
+ readonly id: string;
500
+ readonly surface: string;
501
+ readonly kind: string;
502
+ /** The path that was asked for, on the machine that was asked. */
503
+ readonly path: string;
504
+ readonly status: string;
505
+ /**
506
+ * An opaque storage key, and deliberately not a URL.
507
+ *
508
+ * Nothing outside the server can do anything with it. Call `downloadLink`
509
+ * for something that opens.
510
+ */
511
+ readonly resultKey?: string;
512
+ readonly resultBytes?: string;
513
+ readonly resultType?: string;
514
+ readonly error?: string;
515
+ readonly createdAt: string;
516
+ readonly completedAt?: string;
517
+ }
518
+ export interface AgentDownloadLink {
519
+ /**
520
+ * A bearer credential for one file, in URL form. Short-lived.
521
+ *
522
+ * Do not log it, store it, or hand it anywhere the file itself would not be
523
+ * safe: whoever holds this URL holds the bytes until it expires.
524
+ */
525
+ readonly downloadUrl: string;
526
+ readonly method: "GET";
527
+ readonly filename: string;
528
+ readonly contentType: string;
529
+ readonly sizeBytes?: number;
530
+ readonly expiresInSeconds: number;
531
+ }
497
532
  export interface HealthResponse {
498
533
  readonly status: string;
499
534
  readonly [key: string]: unknown;
500
535
  }
536
+ export interface DriveFile {
537
+ readonly id: string;
538
+ readonly name: string;
539
+ readonly mimeType: string;
540
+ readonly size?: number;
541
+ readonly modifiedTime?: string;
542
+ readonly link?: string;
543
+ readonly owner?: string;
544
+ /** True for Docs, Sheets and Slides, which have no bytes of their own. */
545
+ readonly native: boolean;
546
+ }
547
+ export interface SearchDriveParams {
548
+ readonly query?: string;
549
+ readonly limit?: number;
550
+ }
551
+ export interface SaveToDriveParams {
552
+ readonly name: string;
553
+ readonly bytes: Uint8Array;
554
+ readonly contentType?: string;
555
+ readonly folderId?: string;
556
+ }
557
+ export interface MailSummary {
558
+ readonly id: string;
559
+ readonly threadId?: string;
560
+ readonly from?: string;
561
+ readonly to?: string;
562
+ readonly subject?: string;
563
+ readonly date?: string;
564
+ /** Gmail's own one-line preview. Never the whole body. */
565
+ readonly snippet?: string;
566
+ readonly unread: boolean;
567
+ readonly hasAttachments: boolean;
568
+ }
569
+ export interface MailAttachment {
570
+ readonly id: string;
571
+ readonly filename: string;
572
+ readonly mimeType: string;
573
+ readonly size?: number;
574
+ }
575
+ export interface MailMessage extends MailSummary {
576
+ readonly body: string;
577
+ /** Named, not fetched. Use `downloadAttachment` for the bytes. */
578
+ readonly attachments: readonly MailAttachment[];
579
+ }
580
+ export interface SearchMailParams {
581
+ /** Gmail search syntax: `from:priya`, `has:attachment`, `newer_than:7d`. */
582
+ readonly query?: string;
583
+ readonly limit?: number;
584
+ }
585
+ export interface Person {
586
+ readonly id: string;
587
+ readonly name?: string;
588
+ readonly emails: readonly string[];
589
+ readonly phones: readonly string[];
590
+ readonly organisation?: string;
591
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@persistmemory/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "The official TypeScript client for the PersistMemory API",
5
5
  "license": "MIT",
6
6
  "author": "PersistMemory",