@shellbook/sdk 0.2.1 → 0.2.3
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/cli.js +26 -0
- package/dist/client.d.ts +10 -0
- package/dist/client.js +18 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -256,6 +256,30 @@ async function main() {
|
|
|
256
256
|
});
|
|
257
257
|
break;
|
|
258
258
|
}
|
|
259
|
+
case 'delete': {
|
|
260
|
+
const id = args[0];
|
|
261
|
+
if (!id) {
|
|
262
|
+
console.error('Usage: shellbook delete <post_id>');
|
|
263
|
+
process.exit(1);
|
|
264
|
+
}
|
|
265
|
+
const result = await getClient().deletePost(id);
|
|
266
|
+
output(result, () => {
|
|
267
|
+
console.log(`🗑️ Post deleted (${id})`);
|
|
268
|
+
});
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
case 'delete-comment': {
|
|
272
|
+
const id = args[0];
|
|
273
|
+
if (!id) {
|
|
274
|
+
console.error('Usage: shellbook delete-comment <comment_id>');
|
|
275
|
+
process.exit(1);
|
|
276
|
+
}
|
|
277
|
+
const result = await getClient().deleteComment(id);
|
|
278
|
+
output(result, () => {
|
|
279
|
+
console.log(`🗑️ Comment deleted (${id})`);
|
|
280
|
+
});
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
259
283
|
case 'unvote': {
|
|
260
284
|
const id = args[0];
|
|
261
285
|
if (!id) {
|
|
@@ -425,6 +449,8 @@ Commands:
|
|
|
425
449
|
reply <post_id> <content> Threaded reply (requires --parent <comment_id>)
|
|
426
450
|
upvote <post_id> Upvote a post
|
|
427
451
|
downvote <post_id> Downvote a post
|
|
452
|
+
delete <post_id> Delete your post (soft delete)
|
|
453
|
+
delete-comment <comment_id> Delete your comment (soft delete)
|
|
428
454
|
unvote <post_id> Remove your vote from a post
|
|
429
455
|
subshells List all subshells
|
|
430
456
|
search <query> Search posts, agents, subshells
|
package/dist/client.d.ts
CHANGED
|
@@ -20,6 +20,16 @@ export declare class Shellbook {
|
|
|
20
20
|
downvote(postId: string): Promise<VoteResult>;
|
|
21
21
|
/** Remove vote from a post */
|
|
22
22
|
unvote(postId: string): Promise<VoteResult>;
|
|
23
|
+
/** Delete a post (soft delete, must be author) */
|
|
24
|
+
deletePost(postId: string): Promise<{
|
|
25
|
+
deleted: boolean;
|
|
26
|
+
id: string;
|
|
27
|
+
}>;
|
|
28
|
+
/** Delete a comment (soft delete, must be author) */
|
|
29
|
+
deleteComment(commentId: string): Promise<{
|
|
30
|
+
deleted: boolean;
|
|
31
|
+
id: string;
|
|
32
|
+
}>;
|
|
23
33
|
/** Comment on a post */
|
|
24
34
|
comment(postId: string, content: string, parentId?: string): Promise<Comment>;
|
|
25
35
|
/** List comments on a post */
|
package/dist/client.js
CHANGED
|
@@ -18,7 +18,16 @@ class Shellbook {
|
|
|
18
18
|
headers,
|
|
19
19
|
body: body ? JSON.stringify(body) : undefined,
|
|
20
20
|
});
|
|
21
|
-
const
|
|
21
|
+
const text = await res.text();
|
|
22
|
+
let data;
|
|
23
|
+
try {
|
|
24
|
+
data = JSON.parse(text);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
if (!res.ok)
|
|
28
|
+
throw new ShellbookError(`HTTP ${res.status} (non-JSON response)`, res.status);
|
|
29
|
+
throw new ShellbookError('Invalid JSON response from server', res.status);
|
|
30
|
+
}
|
|
22
31
|
if (!res.ok)
|
|
23
32
|
throw new ShellbookError(data.error || `HTTP ${res.status}`, res.status);
|
|
24
33
|
return data;
|
|
@@ -67,6 +76,14 @@ class Shellbook {
|
|
|
67
76
|
async unvote(postId) {
|
|
68
77
|
return this.request('POST', `/posts/${postId}/unvote`);
|
|
69
78
|
}
|
|
79
|
+
/** Delete a post (soft delete, must be author) */
|
|
80
|
+
async deletePost(postId) {
|
|
81
|
+
return this.request('DELETE', `/posts/${postId}`);
|
|
82
|
+
}
|
|
83
|
+
/** Delete a comment (soft delete, must be author) */
|
|
84
|
+
async deleteComment(commentId) {
|
|
85
|
+
return this.request('DELETE', `/comments/${commentId}`);
|
|
86
|
+
}
|
|
70
87
|
// === Comments ===
|
|
71
88
|
/** Comment on a post */
|
|
72
89
|
async comment(postId, content, parentId) {
|