@yoyo-bot/cli 0.1.0 → 0.1.2
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 +10 -0
- package/dist/commands/bind.d.ts.map +1 -1
- package/dist/commands/bind.js +40 -68
- package/dist/commands/bind.js.map +1 -1
- package/dist/commands/list.d.ts +0 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +10 -10
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +43 -30
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/search.d.ts.map +1 -1
- package/dist/commands/search.js +9 -6
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +13 -7
- package/dist/commands/whoami.js.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/api.d.ts +68 -30
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/api.js +21 -10
- package/dist/lib/api.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/bind.ts +41 -71
- package/src/commands/list.ts +12 -12
- package/src/commands/publish.ts +48 -32
- package/src/commands/search.ts +10 -6
- package/src/commands/whoami.ts +12 -6
- package/src/index.ts +1 -2
- package/src/lib/api.ts +65 -39
package/src/lib/api.ts
CHANGED
|
@@ -34,8 +34,14 @@ async function request<T>(
|
|
|
34
34
|
if (!res.ok) {
|
|
35
35
|
let detail = "";
|
|
36
36
|
try {
|
|
37
|
-
const j = (await res.json()) as { message?: string; error?:
|
|
38
|
-
|
|
37
|
+
const j = (await res.json()) as { message?: string; error?: unknown };
|
|
38
|
+
if (typeof j.error === "string") {
|
|
39
|
+
detail = j.error;
|
|
40
|
+
} else if (j.error && typeof j.error === "object") {
|
|
41
|
+
detail = (j.error as { message?: string }).message || JSON.stringify(j.error);
|
|
42
|
+
} else {
|
|
43
|
+
detail = j.message ?? "";
|
|
44
|
+
}
|
|
39
45
|
} catch {}
|
|
40
46
|
throw new ApiError(res.status, detail || res.statusText);
|
|
41
47
|
}
|
|
@@ -46,73 +52,93 @@ async function request<T>(
|
|
|
46
52
|
// ── Types ──────────────────────────────────────────────────────────────────
|
|
47
53
|
|
|
48
54
|
export interface BinderSummary {
|
|
49
|
-
owner: string;
|
|
50
55
|
slug: string;
|
|
51
|
-
|
|
56
|
+
name: string;
|
|
52
57
|
description?: string;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
category?: string;
|
|
59
|
+
latestVersion?: string;
|
|
60
|
+
installCount?: number;
|
|
61
|
+
starCount?: number;
|
|
57
62
|
tags?: string[];
|
|
63
|
+
featured?: boolean;
|
|
64
|
+
authorName?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface BinderFile {
|
|
68
|
+
id: string;
|
|
69
|
+
filename: string;
|
|
70
|
+
description?: string;
|
|
71
|
+
content: string;
|
|
72
|
+
fileType: string;
|
|
73
|
+
fileSize: number;
|
|
74
|
+
sortOrder: number;
|
|
58
75
|
}
|
|
59
76
|
|
|
60
77
|
export interface BinderDetail extends BinderSummary {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
platforms?: string[];
|
|
67
|
-
};
|
|
78
|
+
id: string;
|
|
79
|
+
longDescription?: string;
|
|
80
|
+
files?: BinderFile[];
|
|
81
|
+
versions?: Array<{ version: string; publishedAt: string }>;
|
|
82
|
+
author?: { id: string; name: string; displayName?: string };
|
|
68
83
|
}
|
|
69
84
|
|
|
70
85
|
export interface SearchResult {
|
|
71
|
-
|
|
86
|
+
binders: BinderSummary[];
|
|
72
87
|
total: number;
|
|
73
|
-
page: number;
|
|
74
|
-
pageSize: number;
|
|
75
88
|
}
|
|
76
89
|
|
|
77
90
|
export interface WhoamiResult {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
agent: {
|
|
92
|
+
id: string;
|
|
93
|
+
name: string;
|
|
94
|
+
displayName?: string;
|
|
95
|
+
description?: string;
|
|
96
|
+
avatarUrl?: string;
|
|
97
|
+
};
|
|
82
98
|
}
|
|
83
99
|
|
|
84
100
|
// ── API calls ──────────────────────────────────────────────────────────────
|
|
85
101
|
|
|
86
102
|
export const api = {
|
|
87
103
|
search: (q: string, page = 1, pageSize = 20) =>
|
|
88
|
-
request<SearchResult>("GET", `/binders?q=${encodeURIComponent(q)}&
|
|
104
|
+
request<SearchResult>("GET", `/binders?q=${encodeURIComponent(q)}&limit=${pageSize}&offset=${(page - 1) * pageSize}`, {
|
|
89
105
|
auth: false,
|
|
90
106
|
}),
|
|
91
107
|
|
|
92
|
-
getBinder: (
|
|
93
|
-
request<BinderDetail>("GET", `/binders/${encodeURIComponent(
|
|
108
|
+
getBinder: (slug: string) =>
|
|
109
|
+
request<{ binder: BinderDetail }>("GET", `/binders/${encodeURIComponent(slug)}`, {
|
|
94
110
|
auth: false,
|
|
95
111
|
}),
|
|
96
112
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return request<SearchResult>("GET", `/binders?page=${page}&pageSize=${pageSize}${ownerQ}`, {
|
|
113
|
+
getInstallBundle: (slug: string) =>
|
|
114
|
+
request<{ instructions: string; binder: unknown }>("GET", `/binders/${encodeURIComponent(slug)}/install`, {
|
|
100
115
|
auth: false,
|
|
101
|
-
})
|
|
102
|
-
|
|
116
|
+
}),
|
|
117
|
+
|
|
118
|
+
listBinders: (page = 1, pageSize = 20) =>
|
|
119
|
+
request<SearchResult>("GET", `/binders?limit=${pageSize}&offset=${(page - 1) * pageSize}`, {
|
|
120
|
+
auth: false,
|
|
121
|
+
}),
|
|
103
122
|
|
|
104
|
-
|
|
123
|
+
listMyBinders: () =>
|
|
124
|
+
request<{ binders: BinderSummary[] }>("GET", "/binders/my"),
|
|
125
|
+
|
|
126
|
+
whoami: () => request<WhoamiResult>("GET", "/agents/me"),
|
|
105
127
|
|
|
106
128
|
publish: (data: {
|
|
107
129
|
slug: string;
|
|
108
|
-
|
|
130
|
+
name: string;
|
|
109
131
|
description?: string;
|
|
110
|
-
|
|
111
|
-
|
|
132
|
+
longDescription?: string;
|
|
133
|
+
category?: string;
|
|
112
134
|
tags?: string[];
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
135
|
+
latestVersion?: string;
|
|
136
|
+
files?: Array<{ filename: string; content: string; fileType?: string; description?: string }>;
|
|
137
|
+
}) => request<{ binder: BinderDetail }>("POST", "/binders", { body: data }),
|
|
138
|
+
|
|
139
|
+
addFiles: (slug: string, files: Array<{ filename: string; content: string; fileType?: string; description?: string }>) =>
|
|
140
|
+
request<{ success: boolean; filesAdded: number }>("POST", `/binders/${encodeURIComponent(slug)}/files`, { body: { files } }),
|
|
141
|
+
|
|
142
|
+
deleteBinder: (slug: string) =>
|
|
143
|
+
request<{ success: boolean }>("DELETE", `/binders/${encodeURIComponent(slug)}`),
|
|
118
144
|
};
|