@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/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?: string };
38
- detail = j.message ?? j.error ?? "";
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
- displayName?: string;
56
+ name: string;
52
57
  description?: string;
53
- version?: string;
54
- downloads?: number;
55
- tab?: string;
56
- verification?: "official" | "verified" | "none";
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
- readme?: string;
62
- latestVersion?: {
63
- version: string;
64
- tarballUrl?: string;
65
- tarballSha256?: string;
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
- items: BinderSummary[];
86
+ binders: BinderSummary[];
72
87
  total: number;
73
- page: number;
74
- pageSize: number;
75
88
  }
76
89
 
77
90
  export interface WhoamiResult {
78
- id: string;
79
- slug: string;
80
- displayName?: string;
81
- email?: string;
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)}&page=${page}&pageSize=${pageSize}`, {
104
+ request<SearchResult>("GET", `/binders?q=${encodeURIComponent(q)}&limit=${pageSize}&offset=${(page - 1) * pageSize}`, {
89
105
  auth: false,
90
106
  }),
91
107
 
92
- getBinder: (owner: string, slug: string) =>
93
- request<BinderDetail>("GET", `/binders/${encodeURIComponent(owner)}/${encodeURIComponent(slug)}`, {
108
+ getBinder: (slug: string) =>
109
+ request<{ binder: BinderDetail }>("GET", `/binders/${encodeURIComponent(slug)}`, {
94
110
  auth: false,
95
111
  }),
96
112
 
97
- listBinders: (owner?: string, page = 1, pageSize = 20) => {
98
- const ownerQ = owner ? `&owner=${encodeURIComponent(owner)}` : "";
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
- whoami: () => request<WhoamiResult>("GET", "/auth/me"),
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
- displayName?: string;
130
+ name: string;
109
131
  description?: string;
110
- version: string;
111
- readme?: string;
132
+ longDescription?: string;
133
+ category?: string;
112
134
  tags?: string[];
113
- tab?: string;
114
- license?: string;
115
- platforms?: string[];
116
- dependencies?: Record<string, string>;
117
- }) => request<{ id: string; slug: string; version: string }>("POST", "/binders", { body: data }),
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
  };