@objectstack/client 4.0.5 → 4.1.1
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.d.mts +115 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.js +122 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +122 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
package/dist/index.mjs
CHANGED
|
@@ -736,6 +736,87 @@ var ObjectStackClient = class {
|
|
|
736
736
|
});
|
|
737
737
|
return this.unwrapResponse(res);
|
|
738
738
|
},
|
|
739
|
+
/**
|
|
740
|
+
* Update the visibility of this project ('private' | 'public').
|
|
741
|
+
* `private` (default) hides the project from /pub/v1 enumeration but
|
|
742
|
+
* still allows anonymous artifact downloads when the URL includes an
|
|
743
|
+
* exact `?commit=<id>` (share-by-link). `public` lists the project and
|
|
744
|
+
* freely exposes all revisions.
|
|
745
|
+
*/
|
|
746
|
+
updateVisibility: async (id, visibility) => {
|
|
747
|
+
const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}`, {
|
|
748
|
+
method: "PATCH",
|
|
749
|
+
body: JSON.stringify({ visibility })
|
|
750
|
+
});
|
|
751
|
+
return this.unwrapResponse(res);
|
|
752
|
+
},
|
|
753
|
+
/**
|
|
754
|
+
* List published artifact revisions for a project. Each revision has
|
|
755
|
+
* an immutable commitId (content-addressable) and storage_key.
|
|
756
|
+
* Optional `branch` filter narrows to a single logical branch
|
|
757
|
+
* (default branch `main` also matches rows with NULL `branch`).
|
|
758
|
+
*/
|
|
759
|
+
listRevisions: async (id, opts) => {
|
|
760
|
+
const params = new URLSearchParams();
|
|
761
|
+
if (opts?.limit) params.set("limit", String(opts.limit));
|
|
762
|
+
if (opts?.cursor) params.set("cursor", opts.cursor);
|
|
763
|
+
if (opts?.branch) params.set("branch", opts.branch);
|
|
764
|
+
const qs = params.toString();
|
|
765
|
+
const res = await this.fetch(
|
|
766
|
+
`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/revisions${qs ? `?${qs}` : ""}`
|
|
767
|
+
);
|
|
768
|
+
return this.unwrapResponse(res);
|
|
769
|
+
},
|
|
770
|
+
/**
|
|
771
|
+
* List logical branches for a project. Each branch has a head commit
|
|
772
|
+
* (latest published revision on that branch) and a count of revisions.
|
|
773
|
+
* Branches without a head row (e.g. all rows demoted) are omitted.
|
|
774
|
+
*/
|
|
775
|
+
listBranches: async (id) => {
|
|
776
|
+
const res = await this.fetch(
|
|
777
|
+
`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/branches`
|
|
778
|
+
);
|
|
779
|
+
return this.unwrapResponse(res);
|
|
780
|
+
},
|
|
781
|
+
/**
|
|
782
|
+
* Rename a branch. Updates every revision row in `from` to `to`.
|
|
783
|
+
* 409 if `to` already has rows.
|
|
784
|
+
*/
|
|
785
|
+
renameBranch: async (id, from, to) => {
|
|
786
|
+
const res = await this.fetch(
|
|
787
|
+
`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/branches/${encodeURIComponent(from)}/rename`,
|
|
788
|
+
{
|
|
789
|
+
method: "POST",
|
|
790
|
+
headers: { "content-type": "application/json" },
|
|
791
|
+
body: JSON.stringify({ newName: to })
|
|
792
|
+
}
|
|
793
|
+
);
|
|
794
|
+
return this.unwrapResponse(res);
|
|
795
|
+
},
|
|
796
|
+
/**
|
|
797
|
+
* Delete (demote) a branch. Soft-removal — clears `is_branch_head` on
|
|
798
|
+
* every row in this branch; the revisions themselves remain. The
|
|
799
|
+
* `main` branch and any branch carrying the active revision cannot be
|
|
800
|
+
* deleted.
|
|
801
|
+
*/
|
|
802
|
+
deleteBranch: async (id, name) => {
|
|
803
|
+
const res = await this.fetch(
|
|
804
|
+
`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/branches/${encodeURIComponent(name)}`,
|
|
805
|
+
{ method: "DELETE" }
|
|
806
|
+
);
|
|
807
|
+
return this.unwrapResponse(res);
|
|
808
|
+
},
|
|
809
|
+
/**
|
|
810
|
+
* Activate (rollback to) a previously-published revision by commit id.
|
|
811
|
+
* Marks the target revision is_current=true and demotes the prior one.
|
|
812
|
+
*/
|
|
813
|
+
activateRevision: async (id, commitId) => {
|
|
814
|
+
const res = await this.fetch(
|
|
815
|
+
`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/revisions/${encodeURIComponent(commitId)}/activate`,
|
|
816
|
+
{ method: "POST" }
|
|
817
|
+
);
|
|
818
|
+
return this.unwrapResponse(res);
|
|
819
|
+
},
|
|
739
820
|
/**
|
|
740
821
|
* Retry provisioning for a project stuck in `failed` (or
|
|
741
822
|
* `provisioning`) state. The server re-runs the driver handshake; on
|
|
@@ -755,6 +836,46 @@ var ObjectStackClient = class {
|
|
|
755
836
|
const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/members`);
|
|
756
837
|
return this.unwrapResponse(res);
|
|
757
838
|
},
|
|
839
|
+
/**
|
|
840
|
+
* Invite a member to a project. Caller must be `owner` or `admin`.
|
|
841
|
+
* Pass either `email` (resolved against the user table) or `user_id`.
|
|
842
|
+
* Returns `{ member, alreadyMember }` — `alreadyMember=true` means the
|
|
843
|
+
* row already existed; the call is idempotent.
|
|
844
|
+
*/
|
|
845
|
+
addMember: async (id, payload) => {
|
|
846
|
+
const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/members`, {
|
|
847
|
+
method: "POST",
|
|
848
|
+
headers: { "content-type": "application/json" },
|
|
849
|
+
body: JSON.stringify(payload)
|
|
850
|
+
});
|
|
851
|
+
return this.unwrapResponse(res);
|
|
852
|
+
},
|
|
853
|
+
/**
|
|
854
|
+
* Update a member's role. Caller must be `owner` or `admin`. Demoting
|
|
855
|
+
* the last `owner` returns 409.
|
|
856
|
+
*/
|
|
857
|
+
updateMemberRole: async (id, memberId, role) => {
|
|
858
|
+
const res = await this.fetch(
|
|
859
|
+
`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/members/${encodeURIComponent(memberId)}`,
|
|
860
|
+
{
|
|
861
|
+
method: "PATCH",
|
|
862
|
+
headers: { "content-type": "application/json" },
|
|
863
|
+
body: JSON.stringify({ role })
|
|
864
|
+
}
|
|
865
|
+
);
|
|
866
|
+
return this.unwrapResponse(res);
|
|
867
|
+
},
|
|
868
|
+
/**
|
|
869
|
+
* Remove a member. Owners/admins may remove anyone; non-privileged
|
|
870
|
+
* users may only remove themselves. Removing the last `owner` returns 409.
|
|
871
|
+
*/
|
|
872
|
+
removeMember: async (id, memberId) => {
|
|
873
|
+
const res = await this.fetch(
|
|
874
|
+
`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/members/${encodeURIComponent(memberId)}`,
|
|
875
|
+
{ method: "DELETE" }
|
|
876
|
+
);
|
|
877
|
+
return this.unwrapResponse(res);
|
|
878
|
+
},
|
|
758
879
|
/**
|
|
759
880
|
* List ObjectQL drivers registered on the server. Useful for populating a
|
|
760
881
|
* driver selector when provisioning a new project (memory / turso /
|
|
@@ -2761,7 +2882,7 @@ var ObjectStackClient = class {
|
|
|
2761
2882
|
status: res.status,
|
|
2762
2883
|
error: errorBody
|
|
2763
2884
|
});
|
|
2764
|
-
const errorMessage = errorBody?.message
|
|
2885
|
+
const errorMessage = errorBody?.message ?? errorBody?.error?.message ?? (typeof errorBody?.error === "string" ? errorBody.error : void 0) ?? res.statusText;
|
|
2765
2886
|
const errorCode = errorBody?.code || errorBody?.error?.code;
|
|
2766
2887
|
const error = new Error(`[ObjectStack] ${errorCode ? `${errorCode}: ` : ""}${errorMessage}`);
|
|
2767
2888
|
error.code = errorCode;
|