@persistmemory/sdk 0.2.0 → 0.4.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/README.md +17 -8
- package/dist/index.cjs +152 -17
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +152 -17
- package/dist/index.js.map +2 -2
- package/dist/resources/spaces.d.ts +109 -17
- package/dist/types.d.ts +119 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -613,6 +613,14 @@ var Spaces = class {
|
|
|
613
613
|
* `delete` never destroys a memory that is filed in another Space as well —
|
|
614
614
|
* that one is detached and left alone. `deleted` and `kept` come back so you
|
|
615
615
|
* can say what actually happened.
|
|
616
|
+
*
|
|
617
|
+
* `moveTo` NAMES WHERE THE STRANDED ONES GO, and is refused-into rather than
|
|
618
|
+
* required: most deletions strand nothing, because everything in the Space
|
|
619
|
+
* is also filed elsewhere, and demanding a destination for those would be a
|
|
620
|
+
* question about nothing. When something WOULD be left in no Space at all,
|
|
621
|
+
* the server answers 400 naming this field. It used to file them into the
|
|
622
|
+
* account's default, which no longer exists — nothing picks a Space on
|
|
623
|
+
* anybody's behalf, so "keep these" has no answer unless you say where.
|
|
616
624
|
*/
|
|
617
625
|
async delete(id, params, options) {
|
|
618
626
|
return this.#http.delete(
|
|
@@ -636,21 +644,55 @@ var Spaces = class {
|
|
|
636
644
|
options
|
|
637
645
|
);
|
|
638
646
|
}
|
|
647
|
+
/* ------------------------- where this is working ------------------------- */
|
|
648
|
+
/*
|
|
649
|
+
`getDefault` AND `setDefault` ARE GONE, with the endpoints they called.
|
|
650
|
+
|
|
651
|
+
They read and wrote the account-wide Space a capture fell into when nobody
|
|
652
|
+
named one. Nothing falls anywhere now: a Space is chosen for the context
|
|
653
|
+
doing the capturing, or `remember` answers 400. Keeping the methods would
|
|
654
|
+
mean keeping two calls that 404, which is a worse break than removing them
|
|
655
|
+
because it looks like a server fault rather than a change.
|
|
656
|
+
*/
|
|
639
657
|
/**
|
|
640
|
-
*
|
|
658
|
+
* Which Space a context is working in.
|
|
659
|
+
*
|
|
660
|
+
* `chosen` absent means NOTHING sent from that context is kept — there is no
|
|
661
|
+
* default behind it and nothing picks one. The reply used to carry a
|
|
662
|
+
* `fallback` for that case and no longer can.
|
|
641
663
|
*
|
|
642
|
-
* `
|
|
643
|
-
*
|
|
644
|
-
*
|
|
664
|
+
* `profile` is the command line's own profile name, and `surface` says which
|
|
665
|
+
* context is being asked about: `cli` for this profile, `email` for the
|
|
666
|
+
* account's ingest address. Between them they are the whole of what a caller
|
|
667
|
+
* may say about where it is working — the server builds the scope key
|
|
668
|
+
* itself, so this can never read or move where a chat is filing.
|
|
645
669
|
*/
|
|
646
|
-
async
|
|
647
|
-
return this.#http.get(
|
|
670
|
+
async working(params = {}, options) {
|
|
671
|
+
return this.#http.get(
|
|
672
|
+
"/api/v1/spaces/working",
|
|
673
|
+
{
|
|
674
|
+
...params.profile !== void 0 ? { profile: params.profile } : {},
|
|
675
|
+
...params.surface !== void 0 ? { surface: params.surface } : {}
|
|
676
|
+
},
|
|
677
|
+
options
|
|
678
|
+
);
|
|
648
679
|
}
|
|
649
|
-
/**
|
|
650
|
-
|
|
680
|
+
/**
|
|
681
|
+
* Works in one from here on. `null` stops working in any.
|
|
682
|
+
*
|
|
683
|
+
* Takes an id or a NAME, because that is how a person says it. `null` rather
|
|
684
|
+
* than an omitted field: "clear this" and "I did not mention it" are
|
|
685
|
+
* different instructions, and clearing means this context keeps nothing
|
|
686
|
+
* until a Space is chosen again.
|
|
687
|
+
*/
|
|
688
|
+
async chooseWorking(space, params = {}, options) {
|
|
651
689
|
return this.#http.patch(
|
|
652
|
-
"/api/v1/spaces/
|
|
653
|
-
{
|
|
690
|
+
"/api/v1/spaces/working",
|
|
691
|
+
{
|
|
692
|
+
space,
|
|
693
|
+
...params.profile !== void 0 ? { profile: params.profile } : {},
|
|
694
|
+
...params.surface !== void 0 ? { surface: params.surface } : {}
|
|
695
|
+
},
|
|
654
696
|
options
|
|
655
697
|
);
|
|
656
698
|
}
|
|
@@ -661,17 +703,22 @@ var Spaces = class {
|
|
|
661
703
|
/**
|
|
662
704
|
* The memories filed in a Space.
|
|
663
705
|
*
|
|
664
|
-
*
|
|
665
|
-
*
|
|
666
|
-
*
|
|
667
|
-
*
|
|
668
|
-
*
|
|
706
|
+
* The cursor is PASSED. This fetch used to ignore the paginator's cursor
|
|
707
|
+
* on the stale belief that the endpoint had none — the server has minted
|
|
708
|
+
* `pagination.nextCursor` since it started paging, and its own comment
|
|
709
|
+
* says "both SDKs iterate by reading pagination". Ignoring it meant every
|
|
710
|
+
* page request was identical: the loop guard saw a non-advancing fetch and
|
|
711
|
+
* stopped silently, so `all()` returned the first page twice and dropped
|
|
712
|
+
* everything after it — duplicated AND truncated data, with no error.
|
|
669
713
|
*/
|
|
670
714
|
memories(id, params = {}, options) {
|
|
671
715
|
return new Paginated(
|
|
672
|
-
() => this.#http.get(
|
|
716
|
+
(cursor) => this.#http.get(
|
|
673
717
|
`/api/v1/spaces/${encodeURIComponent(id)}/memories`,
|
|
674
|
-
{
|
|
718
|
+
{
|
|
719
|
+
...params.limit !== void 0 ? { limit: params.limit } : {},
|
|
720
|
+
...cursor !== void 0 ? { cursor } : {}
|
|
721
|
+
},
|
|
675
722
|
options
|
|
676
723
|
)
|
|
677
724
|
);
|
|
@@ -697,6 +744,94 @@ var Spaces = class {
|
|
|
697
744
|
options
|
|
698
745
|
);
|
|
699
746
|
}
|
|
747
|
+
/* ----------------------- who else can see it ----------------------- */
|
|
748
|
+
/**
|
|
749
|
+
* Who can see this Space, including invitations nobody has accepted.
|
|
750
|
+
*
|
|
751
|
+
* A DIFFERENT EDGE from `memories()` next door, and the difference is worth
|
|
752
|
+
* holding on to: that one maps a MEMORY to a Space, this one maps a PERSON
|
|
753
|
+
* to a Space. The server keeps them in two tables with two names for exactly
|
|
754
|
+
* that reason.
|
|
755
|
+
*
|
|
756
|
+
* Read `acceptedAt` before you render a row. An invitation grants nothing
|
|
757
|
+
* until it is accepted, so a list that draws invited and accepted people the
|
|
758
|
+
* same way tells its user somebody is reading their memories when nobody is.
|
|
759
|
+
*
|
|
760
|
+
* Paginated like every other list here. A Space has a handful of
|
|
761
|
+
* collaborators rather than thousands, so this will usually be one page -
|
|
762
|
+
* which costs a caller nothing and means the shape does not change if a
|
|
763
|
+
* Space ever has an organisation on it.
|
|
764
|
+
*/
|
|
765
|
+
collaborators(id, params = {}, options) {
|
|
766
|
+
return new Paginated(
|
|
767
|
+
(cursor) => this.#http.get(
|
|
768
|
+
`/api/v1/sharing/spaces/${encodeURIComponent(id)}/collaborators`,
|
|
769
|
+
{
|
|
770
|
+
...params.limit !== void 0 ? { limit: params.limit } : {},
|
|
771
|
+
...cursor !== void 0 ? { cursor } : {}
|
|
772
|
+
},
|
|
773
|
+
options
|
|
774
|
+
)
|
|
775
|
+
);
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Offers somebody sight of a Space. Answers with the invitation.
|
|
779
|
+
*
|
|
780
|
+
* AN OFFER, NOT A GRANT, and the returned `acceptedAt` will be absent to
|
|
781
|
+
* prove it. The recipient has to accept before they can see anything, which
|
|
782
|
+
* is the property that keeps "nothing enters your memory without you" true
|
|
783
|
+
* even when somebody else starts the sharing. Do not tell your user their
|
|
784
|
+
* Space "has been shared" on the strength of a 2xx here.
|
|
785
|
+
*
|
|
786
|
+
* WHAT THEY GET IS THE WHOLE SPACE: every memory already filed in it and
|
|
787
|
+
* every memory that lands in it afterwards. There is no narrower grant, and
|
|
788
|
+
* `role` does not make one - it decides what they may do BESIDES read.
|
|
789
|
+
*
|
|
790
|
+
* Worth an idempotency key when a person is behind it. A double-clicked
|
|
791
|
+
* "share" is two invitations to the same address, and the second one is a
|
|
792
|
+
* second email arriving at somebody who has already been asked.
|
|
793
|
+
*/
|
|
794
|
+
async share(id, params, options) {
|
|
795
|
+
return this.#http.post(
|
|
796
|
+
`/api/v1/sharing/spaces/${encodeURIComponent(id)}/collaborators`,
|
|
797
|
+
params,
|
|
798
|
+
options
|
|
799
|
+
);
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Ends somebody's access, or withdraws an invitation they never accepted.
|
|
803
|
+
*
|
|
804
|
+
* Nothing was ever copied into their account - a collaborator SEES the
|
|
805
|
+
* owner's memories rather than holding a duplicate - so this is one write
|
|
806
|
+
* and not a cascade, and there is no orphaned copy left behind.
|
|
807
|
+
*
|
|
808
|
+
* A body on a DELETE, matching `removeMemories` above. The alternative is an
|
|
809
|
+
* address in a path segment, where every `.`, `+` and `@` is a chance for a
|
|
810
|
+
* proxy or a router to normalise somebody else's email into the one that
|
|
811
|
+
* gets revoked.
|
|
812
|
+
*/
|
|
813
|
+
async unshare(id, email, options) {
|
|
814
|
+
return this.#http.delete(
|
|
815
|
+
`/api/v1/sharing/spaces/${encodeURIComponent(id)}/collaborators`,
|
|
816
|
+
{ email },
|
|
817
|
+
options
|
|
818
|
+
);
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Changes what an existing collaborator may do. Never invites anybody.
|
|
822
|
+
*
|
|
823
|
+
* The quiet one. Moving somebody from `viewer` to `owner` sends no
|
|
824
|
+
* invitation and needs no acceptance, and afterwards they can share the
|
|
825
|
+
* Space onward and revoke the person who promoted them. Show your user what
|
|
826
|
+
* `owner` means before you send this, not after.
|
|
827
|
+
*/
|
|
828
|
+
async setRole(id, params, options) {
|
|
829
|
+
return this.#http.patch(
|
|
830
|
+
`/api/v1/sharing/spaces/${encodeURIComponent(id)}/collaborators`,
|
|
831
|
+
params,
|
|
832
|
+
options
|
|
833
|
+
);
|
|
834
|
+
}
|
|
700
835
|
};
|
|
701
836
|
|
|
702
837
|
// src/resources/ingestion.ts
|