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