@persistmemory/sdk 0.2.0 → 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/index.cjs +100 -7
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +100 -7
- package/dist/index.js.map +2 -2
- package/dist/resources/spaces.d.ts +73 -6
- package/dist/types.d.ts +75 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -661,17 +661,22 @@ var Spaces = class {
|
|
|
661
661
|
/**
|
|
662
662
|
* The memories filed in a Space.
|
|
663
663
|
*
|
|
664
|
-
*
|
|
665
|
-
*
|
|
666
|
-
*
|
|
667
|
-
*
|
|
668
|
-
*
|
|
664
|
+
* The cursor is PASSED. This fetch used to ignore the paginator's cursor
|
|
665
|
+
* on the stale belief that the endpoint had none — the server has minted
|
|
666
|
+
* `pagination.nextCursor` since it started paging, and its own comment
|
|
667
|
+
* says "both SDKs iterate by reading pagination". Ignoring it meant every
|
|
668
|
+
* page request was identical: the loop guard saw a non-advancing fetch and
|
|
669
|
+
* stopped silently, so `all()` returned the first page twice and dropped
|
|
670
|
+
* everything after it — duplicated AND truncated data, with no error.
|
|
669
671
|
*/
|
|
670
672
|
memories(id, params = {}, options) {
|
|
671
673
|
return new Paginated(
|
|
672
|
-
() => this.#http.get(
|
|
674
|
+
(cursor) => this.#http.get(
|
|
673
675
|
`/api/v1/spaces/${encodeURIComponent(id)}/memories`,
|
|
674
|
-
{
|
|
676
|
+
{
|
|
677
|
+
...params.limit !== void 0 ? { limit: params.limit } : {},
|
|
678
|
+
...cursor !== void 0 ? { cursor } : {}
|
|
679
|
+
},
|
|
675
680
|
options
|
|
676
681
|
)
|
|
677
682
|
);
|
|
@@ -697,6 +702,94 @@ var Spaces = class {
|
|
|
697
702
|
options
|
|
698
703
|
);
|
|
699
704
|
}
|
|
705
|
+
/* ----------------------- who else can see it ----------------------- */
|
|
706
|
+
/**
|
|
707
|
+
* Who can see this Space, including invitations nobody has accepted.
|
|
708
|
+
*
|
|
709
|
+
* A DIFFERENT EDGE from `memories()` next door, and the difference is worth
|
|
710
|
+
* holding on to: that one maps a MEMORY to a Space, this one maps a PERSON
|
|
711
|
+
* to a Space. The server keeps them in two tables with two names for exactly
|
|
712
|
+
* that reason.
|
|
713
|
+
*
|
|
714
|
+
* Read `acceptedAt` before you render a row. An invitation grants nothing
|
|
715
|
+
* until it is accepted, so a list that draws invited and accepted people the
|
|
716
|
+
* same way tells its user somebody is reading their memories when nobody is.
|
|
717
|
+
*
|
|
718
|
+
* Paginated like every other list here. A Space has a handful of
|
|
719
|
+
* collaborators rather than thousands, so this will usually be one page -
|
|
720
|
+
* which costs a caller nothing and means the shape does not change if a
|
|
721
|
+
* Space ever has an organisation on it.
|
|
722
|
+
*/
|
|
723
|
+
collaborators(id, params = {}, options) {
|
|
724
|
+
return new Paginated(
|
|
725
|
+
(cursor) => this.#http.get(
|
|
726
|
+
`/api/v1/sharing/spaces/${encodeURIComponent(id)}/collaborators`,
|
|
727
|
+
{
|
|
728
|
+
...params.limit !== void 0 ? { limit: params.limit } : {},
|
|
729
|
+
...cursor !== void 0 ? { cursor } : {}
|
|
730
|
+
},
|
|
731
|
+
options
|
|
732
|
+
)
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Offers somebody sight of a Space. Answers with the invitation.
|
|
737
|
+
*
|
|
738
|
+
* AN OFFER, NOT A GRANT, and the returned `acceptedAt` will be absent to
|
|
739
|
+
* prove it. The recipient has to accept before they can see anything, which
|
|
740
|
+
* is the property that keeps "nothing enters your memory without you" true
|
|
741
|
+
* even when somebody else starts the sharing. Do not tell your user their
|
|
742
|
+
* Space "has been shared" on the strength of a 2xx here.
|
|
743
|
+
*
|
|
744
|
+
* WHAT THEY GET IS THE WHOLE SPACE: every memory already filed in it and
|
|
745
|
+
* every memory that lands in it afterwards. There is no narrower grant, and
|
|
746
|
+
* `role` does not make one - it decides what they may do BESIDES read.
|
|
747
|
+
*
|
|
748
|
+
* Worth an idempotency key when a person is behind it. A double-clicked
|
|
749
|
+
* "share" is two invitations to the same address, and the second one is a
|
|
750
|
+
* second email arriving at somebody who has already been asked.
|
|
751
|
+
*/
|
|
752
|
+
async share(id, params, options) {
|
|
753
|
+
return this.#http.post(
|
|
754
|
+
`/api/v1/sharing/spaces/${encodeURIComponent(id)}/collaborators`,
|
|
755
|
+
params,
|
|
756
|
+
options
|
|
757
|
+
);
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Ends somebody's access, or withdraws an invitation they never accepted.
|
|
761
|
+
*
|
|
762
|
+
* Nothing was ever copied into their account - a collaborator SEES the
|
|
763
|
+
* owner's memories rather than holding a duplicate - so this is one write
|
|
764
|
+
* and not a cascade, and there is no orphaned copy left behind.
|
|
765
|
+
*
|
|
766
|
+
* A body on a DELETE, matching `removeMemories` above. The alternative is an
|
|
767
|
+
* address in a path segment, where every `.`, `+` and `@` is a chance for a
|
|
768
|
+
* proxy or a router to normalise somebody else's email into the one that
|
|
769
|
+
* gets revoked.
|
|
770
|
+
*/
|
|
771
|
+
async unshare(id, email, options) {
|
|
772
|
+
return this.#http.delete(
|
|
773
|
+
`/api/v1/sharing/spaces/${encodeURIComponent(id)}/collaborators`,
|
|
774
|
+
{ email },
|
|
775
|
+
options
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Changes what an existing collaborator may do. Never invites anybody.
|
|
780
|
+
*
|
|
781
|
+
* The quiet one. Moving somebody from `viewer` to `owner` sends no
|
|
782
|
+
* invitation and needs no acceptance, and afterwards they can share the
|
|
783
|
+
* Space onward and revoke the person who promoted them. Show your user what
|
|
784
|
+
* `owner` means before you send this, not after.
|
|
785
|
+
*/
|
|
786
|
+
async setRole(id, params, options) {
|
|
787
|
+
return this.#http.patch(
|
|
788
|
+
`/api/v1/sharing/spaces/${encodeURIComponent(id)}/collaborators`,
|
|
789
|
+
params,
|
|
790
|
+
options
|
|
791
|
+
);
|
|
792
|
+
}
|
|
700
793
|
};
|
|
701
794
|
|
|
702
795
|
// src/resources/ingestion.ts
|