@persistmemory/sdk 0.1.2 → 0.3.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/client.d.ts +3 -0
- package/dist/http.d.ts +20 -0
- package/dist/index.cjs +253 -10
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +253 -10
- package/dist/index.js.map +3 -3
- package/dist/resources/google.d.ts +84 -0
- package/dist/resources/spaces.d.ts +73 -6
- package/dist/types.d.ts +131 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HttpClient, RequestOptions } from "../http.js";
|
|
2
2
|
import { Paginated } from "../pagination.js";
|
|
3
|
-
import type { CreateSpaceParams, ListSpacesParams, Memory, Space, UpdateSpaceParams } from "../types.js";
|
|
3
|
+
import type { CreateSpaceParams, ListSpacesParams, Memory, ShareSpaceParams, Space, SpaceCollaborator, GrantableSpaceRole, UpdateSpaceParams } from "../types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Spaces: a boundary around a set of memories.
|
|
6
6
|
*
|
|
@@ -78,11 +78,13 @@ export declare class Spaces {
|
|
|
78
78
|
/**
|
|
79
79
|
* The memories filed in a Space.
|
|
80
80
|
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
81
|
+
* The cursor is PASSED. This fetch used to ignore the paginator's cursor
|
|
82
|
+
* on the stale belief that the endpoint had none — the server has minted
|
|
83
|
+
* `pagination.nextCursor` since it started paging, and its own comment
|
|
84
|
+
* says "both SDKs iterate by reading pagination". Ignoring it meant every
|
|
85
|
+
* page request was identical: the loop guard saw a non-advancing fetch and
|
|
86
|
+
* stopped silently, so `all()` returned the first page twice and dropped
|
|
87
|
+
* everything after it — duplicated AND truncated data, with no error.
|
|
86
88
|
*/
|
|
87
89
|
memories(id: string, params?: {
|
|
88
90
|
readonly limit?: number;
|
|
@@ -100,4 +102,69 @@ export declare class Spaces {
|
|
|
100
102
|
removeMemories(id: string, memoryIds: readonly string[], options?: RequestOptions): Promise<{
|
|
101
103
|
removed: number;
|
|
102
104
|
}>;
|
|
105
|
+
/**
|
|
106
|
+
* Who can see this Space, including invitations nobody has accepted.
|
|
107
|
+
*
|
|
108
|
+
* A DIFFERENT EDGE from `memories()` next door, and the difference is worth
|
|
109
|
+
* holding on to: that one maps a MEMORY to a Space, this one maps a PERSON
|
|
110
|
+
* to a Space. The server keeps them in two tables with two names for exactly
|
|
111
|
+
* that reason.
|
|
112
|
+
*
|
|
113
|
+
* Read `acceptedAt` before you render a row. An invitation grants nothing
|
|
114
|
+
* until it is accepted, so a list that draws invited and accepted people the
|
|
115
|
+
* same way tells its user somebody is reading their memories when nobody is.
|
|
116
|
+
*
|
|
117
|
+
* Paginated like every other list here. A Space has a handful of
|
|
118
|
+
* collaborators rather than thousands, so this will usually be one page -
|
|
119
|
+
* which costs a caller nothing and means the shape does not change if a
|
|
120
|
+
* Space ever has an organisation on it.
|
|
121
|
+
*/
|
|
122
|
+
collaborators(id: string, params?: {
|
|
123
|
+
readonly limit?: number;
|
|
124
|
+
}, options?: RequestOptions): Paginated<SpaceCollaborator>;
|
|
125
|
+
/**
|
|
126
|
+
* Offers somebody sight of a Space. Answers with the invitation.
|
|
127
|
+
*
|
|
128
|
+
* AN OFFER, NOT A GRANT, and the returned `acceptedAt` will be absent to
|
|
129
|
+
* prove it. The recipient has to accept before they can see anything, which
|
|
130
|
+
* is the property that keeps "nothing enters your memory without you" true
|
|
131
|
+
* even when somebody else starts the sharing. Do not tell your user their
|
|
132
|
+
* Space "has been shared" on the strength of a 2xx here.
|
|
133
|
+
*
|
|
134
|
+
* WHAT THEY GET IS THE WHOLE SPACE: every memory already filed in it and
|
|
135
|
+
* every memory that lands in it afterwards. There is no narrower grant, and
|
|
136
|
+
* `role` does not make one - it decides what they may do BESIDES read.
|
|
137
|
+
*
|
|
138
|
+
* Worth an idempotency key when a person is behind it. A double-clicked
|
|
139
|
+
* "share" is two invitations to the same address, and the second one is a
|
|
140
|
+
* second email arriving at somebody who has already been asked.
|
|
141
|
+
*/
|
|
142
|
+
share(id: string, params: ShareSpaceParams, options?: RequestOptions): Promise<SpaceCollaborator>;
|
|
143
|
+
/**
|
|
144
|
+
* Ends somebody's access, or withdraws an invitation they never accepted.
|
|
145
|
+
*
|
|
146
|
+
* Nothing was ever copied into their account - a collaborator SEES the
|
|
147
|
+
* owner's memories rather than holding a duplicate - so this is one write
|
|
148
|
+
* and not a cascade, and there is no orphaned copy left behind.
|
|
149
|
+
*
|
|
150
|
+
* A body on a DELETE, matching `removeMemories` above. The alternative is an
|
|
151
|
+
* address in a path segment, where every `.`, `+` and `@` is a chance for a
|
|
152
|
+
* proxy or a router to normalise somebody else's email into the one that
|
|
153
|
+
* gets revoked.
|
|
154
|
+
*/
|
|
155
|
+
unshare(id: string, email: string, options?: RequestOptions): Promise<{
|
|
156
|
+
email: string;
|
|
157
|
+
}>;
|
|
158
|
+
/**
|
|
159
|
+
* Changes what an existing collaborator may do. Never invites anybody.
|
|
160
|
+
*
|
|
161
|
+
* The quiet one. Moving somebody from `viewer` to `owner` sends no
|
|
162
|
+
* invitation and needs no acceptance, and afterwards they can share the
|
|
163
|
+
* Space onward and revoke the person who promoted them. Show your user what
|
|
164
|
+
* `owner` means before you send this, not after.
|
|
165
|
+
*/
|
|
166
|
+
setRole(id: string, params: {
|
|
167
|
+
readonly email: string;
|
|
168
|
+
readonly role: GrantableSpaceRole;
|
|
169
|
+
}, options?: RequestOptions): Promise<SpaceCollaborator>;
|
|
103
170
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -70,10 +70,35 @@ export interface Temporal {
|
|
|
70
70
|
/** True while the claim is believed to hold. */
|
|
71
71
|
readonly current: boolean;
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Whoever owns a memory that is not yours.
|
|
75
|
+
*
|
|
76
|
+
* A name, never a user id: the API does not send one, and nothing here takes
|
|
77
|
+
* one. `name` is absent when the account set neither a display name nor a
|
|
78
|
+
* username, which is why `mine` below and not this is what says the memory
|
|
79
|
+
* belongs to somebody else.
|
|
80
|
+
*/
|
|
81
|
+
export interface SharedBy {
|
|
82
|
+
readonly name: string;
|
|
83
|
+
}
|
|
73
84
|
export interface Memory {
|
|
74
85
|
readonly id: string;
|
|
75
86
|
readonly type: MemoryType;
|
|
76
87
|
readonly state: MemoryState;
|
|
88
|
+
/**
|
|
89
|
+
* Whether YOU own this memory.
|
|
90
|
+
*
|
|
91
|
+
* Not always true. A listing returns everything your key may see, and that
|
|
92
|
+
* includes memories owned by people who shared a Space with you — filed in
|
|
93
|
+
* the same Spaces you file into, so `spaceIds` will not tell them apart.
|
|
94
|
+
* Anything that reads a memory back to a person, or puts one in a model's
|
|
95
|
+
* context, has to carry this: an unmarked claim from a colleague is
|
|
96
|
+
* indistinguishable from one of your own, and a model will state it in your
|
|
97
|
+
* voice.
|
|
98
|
+
*/
|
|
99
|
+
readonly mine: boolean;
|
|
100
|
+
/** Who it belongs to, when `mine` is false and the API can name them. */
|
|
101
|
+
readonly sharedBy?: SharedBy;
|
|
77
102
|
readonly title: string;
|
|
78
103
|
readonly content: string;
|
|
79
104
|
readonly value?: Readonly<Record<string, unknown>>;
|
|
@@ -241,6 +266,56 @@ export interface ListSpacesParams {
|
|
|
241
266
|
readonly cursor?: string;
|
|
242
267
|
readonly includeArchived?: boolean;
|
|
243
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* What somebody you shared a Space with may do with it.
|
|
271
|
+
*
|
|
272
|
+
* A WIDENING SCALE: every role sees everything filed in the Space, and the
|
|
273
|
+
* role decides only what they may do BESIDES read. `viewer` reads it,
|
|
274
|
+
* `editor` also files new memories into it, `owner` can additionally share it
|
|
275
|
+
* onward and revoke people - including you.
|
|
276
|
+
*/
|
|
277
|
+
export type SpaceRole = "viewer" | "editor" | "owner";
|
|
278
|
+
/**
|
|
279
|
+
* A role that may actually be GRANTED, which is not every role.
|
|
280
|
+
*
|
|
281
|
+
* `owner` is real — the Space's owner holds it and a collaborator listing
|
|
282
|
+
* shows it — but no request can hand it out. `POST /collaborators` and
|
|
283
|
+
* `PATCH /collaborators/:id` both take `["viewer", "editor"]`, and the store
|
|
284
|
+
* throws `CannotGrantOwnership` behind them, so a call carrying `owner` is
|
|
285
|
+
* refused with a 400 every time.
|
|
286
|
+
*
|
|
287
|
+
* Separate from `SpaceRole` rather than narrowing it, because the two are
|
|
288
|
+
* genuinely different questions: what a collaborator MAY BE is three values,
|
|
289
|
+
* what you may SET them to is two. Typing the parameters as `SpaceRole` made
|
|
290
|
+
* the compiler accept a call the server always rejects — a typed client whose
|
|
291
|
+
* types are wrong about the server is worse than an untyped one, because the
|
|
292
|
+
* error arrives at runtime after the type system said it was fine.
|
|
293
|
+
*/
|
|
294
|
+
export type GrantableSpaceRole = Exclude<SpaceRole, "owner">;
|
|
295
|
+
/**
|
|
296
|
+
* One person who has been given, or merely offered, sight of a Space.
|
|
297
|
+
*
|
|
298
|
+
* `acceptedAt` is the field to read before you render anything. An invitation
|
|
299
|
+
* grants NOTHING until the recipient accepts, so a UI that shows an invited
|
|
300
|
+
* person the same way it shows an accepted one tells its user that somebody is
|
|
301
|
+
* reading their memories when nobody is - and read the other way, hides that
|
|
302
|
+
* an invitation never landed.
|
|
303
|
+
*/
|
|
304
|
+
export interface SpaceCollaborator {
|
|
305
|
+
readonly email: string;
|
|
306
|
+
readonly name?: string;
|
|
307
|
+
readonly role: SpaceRole;
|
|
308
|
+
readonly invitedBy?: string;
|
|
309
|
+
readonly invitedAt?: string;
|
|
310
|
+
/** Absent means they have accepted nothing and can see nothing. */
|
|
311
|
+
readonly acceptedAt?: string;
|
|
312
|
+
}
|
|
313
|
+
export interface ShareSpaceParams {
|
|
314
|
+
/** The person to offer the Space to, by address. */
|
|
315
|
+
readonly email: string;
|
|
316
|
+
/** See `GrantableSpaceRole` — `owner` cannot be given away. */
|
|
317
|
+
readonly role: GrantableSpaceRole;
|
|
318
|
+
}
|
|
244
319
|
export interface Source {
|
|
245
320
|
readonly id: string;
|
|
246
321
|
readonly provider: string;
|
|
@@ -533,3 +608,59 @@ export interface HealthResponse {
|
|
|
533
608
|
readonly status: string;
|
|
534
609
|
readonly [key: string]: unknown;
|
|
535
610
|
}
|
|
611
|
+
export interface DriveFile {
|
|
612
|
+
readonly id: string;
|
|
613
|
+
readonly name: string;
|
|
614
|
+
readonly mimeType: string;
|
|
615
|
+
readonly size?: number;
|
|
616
|
+
readonly modifiedTime?: string;
|
|
617
|
+
readonly link?: string;
|
|
618
|
+
readonly owner?: string;
|
|
619
|
+
/** True for Docs, Sheets and Slides, which have no bytes of their own. */
|
|
620
|
+
readonly native: boolean;
|
|
621
|
+
}
|
|
622
|
+
export interface SearchDriveParams {
|
|
623
|
+
readonly query?: string;
|
|
624
|
+
readonly limit?: number;
|
|
625
|
+
}
|
|
626
|
+
export interface SaveToDriveParams {
|
|
627
|
+
readonly name: string;
|
|
628
|
+
readonly bytes: Uint8Array;
|
|
629
|
+
readonly contentType?: string;
|
|
630
|
+
readonly folderId?: string;
|
|
631
|
+
}
|
|
632
|
+
export interface MailSummary {
|
|
633
|
+
readonly id: string;
|
|
634
|
+
readonly threadId?: string;
|
|
635
|
+
readonly from?: string;
|
|
636
|
+
readonly to?: string;
|
|
637
|
+
readonly subject?: string;
|
|
638
|
+
readonly date?: string;
|
|
639
|
+
/** Gmail's own one-line preview. Never the whole body. */
|
|
640
|
+
readonly snippet?: string;
|
|
641
|
+
readonly unread: boolean;
|
|
642
|
+
readonly hasAttachments: boolean;
|
|
643
|
+
}
|
|
644
|
+
export interface MailAttachment {
|
|
645
|
+
readonly id: string;
|
|
646
|
+
readonly filename: string;
|
|
647
|
+
readonly mimeType: string;
|
|
648
|
+
readonly size?: number;
|
|
649
|
+
}
|
|
650
|
+
export interface MailMessage extends MailSummary {
|
|
651
|
+
readonly body: string;
|
|
652
|
+
/** Named, not fetched. Use `downloadAttachment` for the bytes. */
|
|
653
|
+
readonly attachments: readonly MailAttachment[];
|
|
654
|
+
}
|
|
655
|
+
export interface SearchMailParams {
|
|
656
|
+
/** Gmail search syntax: `from:priya`, `has:attachment`, `newer_than:7d`. */
|
|
657
|
+
readonly query?: string;
|
|
658
|
+
readonly limit?: number;
|
|
659
|
+
}
|
|
660
|
+
export interface Person {
|
|
661
|
+
readonly id: string;
|
|
662
|
+
readonly name?: string;
|
|
663
|
+
readonly emails: readonly string[];
|
|
664
|
+
readonly phones: readonly string[];
|
|
665
|
+
readonly organisation?: string;
|
|
666
|
+
}
|