@donkeylabs/cli 0.4.0 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donkeylabs/cli",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "description": "CLI for @donkeylabs/server - project scaffolding and code generation",
6
6
  "main": "./src/index.ts",
@@ -4,9 +4,9 @@
4
4
  "": {
5
5
  "name": "my-sveltekit-app",
6
6
  "dependencies": {
7
- "@donkeylabs/adapter-sveltekit": "0.1.2",
8
- "@donkeylabs/cli": "0.1.1",
9
- "@donkeylabs/server": "0.3.1",
7
+ "@donkeylabs/adapter-sveltekit": "^0.4.0",
8
+ "@donkeylabs/cli": "^0.4.0",
9
+ "@donkeylabs/server": "^0.4.0",
10
10
  "bits-ui": "^2.15.4",
11
11
  "clsx": "^2.1.1",
12
12
  "kysely": "^0.27.6",
@@ -28,11 +28,11 @@
28
28
  },
29
29
  },
30
30
  "packages": {
31
- "@donkeylabs/adapter-sveltekit": ["@donkeylabs/adapter-sveltekit@0.1.2", "", { "peerDependencies": { "@donkeylabs/server": "*", "@sveltejs/kit": "^2.0.0" } }, "sha512-VvjRQ8XZQw6T+DYLjq5Sjz+u1k8LqkcZOTVZuB4SfC6TdGxGD7CkU/7NQ7gwlk/2pDNP7tqwMD3yGfP86A6j4Q=="],
31
+ "@donkeylabs/adapter-sveltekit": ["@donkeylabs/adapter-sveltekit@0.4.0", "", { "peerDependencies": { "@donkeylabs/server": "^0.4.0", "@sveltejs/kit": "^2.0.0" } }, "sha512-J1kcwhp8X0egAhjC/HyxEizR3aEP7ea08rfAh0++C31UldM3ahAjO3Ux0QYp+fAV76lh8mKrDNAWIsKTyPmqNg=="],
32
32
 
33
- "@donkeylabs/cli": ["@donkeylabs/cli@0.1.1", "", { "dependencies": { "picocolors": "^1.1.1", "prompts": "^2.4.2" }, "peerDependencies": { "@donkeylabs/server": "*" }, "bin": { "donkeylabs": "src/index.ts" } }, "sha512-lMGXz/KGCoN15siUf05Sl3NxoR5Qn0h44gXqRocHr51SLV8R/o2On2ELF4iHdTNV9hPJp3sjhNmcO3mMzQex2A=="],
33
+ "@donkeylabs/cli": ["@donkeylabs/cli@0.4.0", "", { "dependencies": { "picocolors": "^1.1.1", "prompts": "^2.4.2" }, "peerDependencies": { "@donkeylabs/server": "^0.4.0" }, "bin": { "donkeylabs": "src/index.ts" } }, "sha512-5Y5oXOzFrhdPMAprij5d/D1r9tcjDRuZo1Ud3zSkGTvVxfejMQjbzrB8KmxFM4+7TBJdjuduvhNewL5V6XnUlA=="],
34
34
 
35
- "@donkeylabs/server": ["@donkeylabs/server@0.3.1", "", { "dependencies": { "@modelcontextprotocol/sdk": "^1.25.2", "picocolors": "^1.1.1", "prompts": "^2.4.2" }, "peerDependencies": { "kysely": "^0.27.0 || ^0.28.0", "typescript": "^5", "zod": "^3.20.0" }, "bin": { "donkeylabs-mcp": "mcp/server.ts" } }, "sha512-rpYKD7dKNwpcw51aO/pL1Zh1r6FlAqp0UIUJ+9nV1Cm/4hKq6WQHM/AtmPhM25ZRvnSbriB4X8o28UVJR8dN2w=="],
35
+ "@donkeylabs/server": ["@donkeylabs/server@0.4.0", "", { "dependencies": { "@modelcontextprotocol/sdk": "^1.25.2", "picocolors": "^1.1.1", "prompts": "^2.4.2" }, "peerDependencies": { "kysely": "^0.27.0 || ^0.28.0", "typescript": "^5", "zod": "^3.20.0" } }, "sha512-Nr7kgKtyqM5EDFTmUL2kyEqCW/NeJiQgYQL4Y3DnphM9rgHz07Qi2mgPs8McYFvrWGUVFRMvzXa6CZILY896bw=="],
36
36
 
37
37
  "@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.27.2", "", { "os": "aix", "cpu": "ppc64" }, "sha512-GZMB+a0mOMZs4MpDbj8RJp4cw+w1WV5NYD6xzgvzUJ5Ek2jerwfO2eADyI6ExDSUED+1X8aMbegahsJi+8mgpw=="],
38
38
 
@@ -24,9 +24,9 @@
24
24
  "vite": "^7.2.6"
25
25
  },
26
26
  "dependencies": {
27
- "@donkeylabs/cli": "0.1.1",
28
- "@donkeylabs/adapter-sveltekit": "0.1.2",
29
- "@donkeylabs/server": "0.3.2",
27
+ "@donkeylabs/cli": "^0.4.0",
28
+ "@donkeylabs/adapter-sveltekit": "^0.4.0",
29
+ "@donkeylabs/server": "^0.4.0",
30
30
  "bits-ui": "^2.15.4",
31
31
  "clsx": "^2.1.1",
32
32
  "kysely": "^0.27.6",
@@ -27,101 +27,112 @@ export { type ServerContext as AppContext } from "@donkeylabs/server";
27
27
  // ============================================
28
28
 
29
29
  export namespace Routes {
30
- export namespace Counter {
31
- export namespace get {
32
- export type Input = Expand<Record<string, never>>;
33
- export type Output = Expand<{
30
+ export namespace Api {
31
+ export namespace Counter {
32
+ export namespace Get {
33
+ export type Input = Expand<Record<string, never>>;
34
+ export type Output = Expand<{
34
35
  count: number;
35
36
  }>;
36
- }
37
+ }
38
+ export type Get = { Input: Get.Input; Output: Get.Output };
37
39
 
38
- export namespace increment {
39
- export type Input = Expand<Record<string, never>>;
40
- export type Output = Expand<{
40
+ export namespace Increment {
41
+ export type Input = Expand<Record<string, never>>;
42
+ export type Output = Expand<{
41
43
  count: number;
42
44
  }>;
43
- }
45
+ }
46
+ export type Increment = { Input: Increment.Input; Output: Increment.Output };
44
47
 
45
- export namespace decrement {
46
- export type Input = Expand<Record<string, never>>;
47
- export type Output = Expand<{
48
+ export namespace Decrement {
49
+ export type Input = Expand<Record<string, never>>;
50
+ export type Output = Expand<{
48
51
  count: number;
49
52
  }>;
50
- }
53
+ }
54
+ export type Decrement = { Input: Decrement.Input; Output: Decrement.Output };
51
55
 
52
- export namespace reset {
53
- export type Input = Expand<Record<string, never>>;
54
- export type Output = Expand<{
56
+ export namespace Reset {
57
+ export type Input = Expand<Record<string, never>>;
58
+ export type Output = Expand<{
55
59
  count: number;
56
60
  }>;
61
+ }
62
+ export type Reset = { Input: Reset.Input; Output: Reset.Output };
57
63
  }
58
- }
59
64
 
60
- export namespace Cache {
61
- export namespace set {
62
- export type Input = Expand<{
65
+ export namespace Cache {
66
+ export namespace Set {
67
+ export type Input = Expand<{
63
68
  key: string;
64
69
  value: any;
65
70
  ttl?: number;
66
71
  }>;
67
- export type Output = Expand<{
72
+ export type Output = Expand<{
68
73
  success: boolean;
69
74
  }>;
70
- }
75
+ }
76
+ export type Set = { Input: Set.Input; Output: Set.Output };
71
77
 
72
- export namespace get {
73
- export type Input = Expand<{
78
+ export namespace Get {
79
+ export type Input = Expand<{
74
80
  key: string;
75
81
  }>;
76
- export type Output = Expand<{
82
+ export type Output = Expand<{
77
83
  value?: any;
78
84
  exists: boolean;
79
85
  }>;
80
- }
86
+ }
87
+ export type Get = { Input: Get.Input; Output: Get.Output };
81
88
 
82
- export namespace delete {
83
- export type Input = Expand<{
89
+ export namespace Delete {
90
+ export type Input = Expand<{
84
91
  key: string;
85
92
  }>;
86
- export type Output = Expand<{
93
+ export type Output = Expand<{
87
94
  success: boolean;
88
95
  }>;
89
- }
96
+ }
97
+ export type Delete = { Input: Delete.Input; Output: Delete.Output };
90
98
 
91
- export namespace keys {
92
- export type Input = Expand<Record<string, never>>;
93
- export type Output = Expand<{
99
+ export namespace Keys {
100
+ export type Input = Expand<Record<string, never>>;
101
+ export type Output = Expand<{
94
102
  keys: string[];
95
103
  }>;
104
+ }
105
+ export type Keys = { Input: Keys.Input; Output: Keys.Output };
96
106
  }
97
- }
98
107
 
99
- export namespace Jobs {
100
- export namespace enqueue {
101
- export type Input = Expand<{
108
+ export namespace Jobs {
109
+ export namespace Enqueue {
110
+ export type Input = Expand<{
102
111
  name: string;
103
112
  data: any;
104
113
  delay?: number;
105
114
  }>;
106
- export type Output = Expand<{
115
+ export type Output = Expand<{
107
116
  jobId: string;
108
117
  }>;
109
- }
118
+ }
119
+ export type Enqueue = { Input: Enqueue.Input; Output: Enqueue.Output };
110
120
 
111
- export namespace stats {
112
- export type Input = Expand<Record<string, never>>;
113
- export type Output = Expand<{
121
+ export namespace Stats {
122
+ export type Input = Expand<Record<string, never>>;
123
+ export type Output = Expand<{
114
124
  pending: number;
115
125
  running: number;
116
126
  completed: number;
117
127
  }>;
128
+ }
129
+ export type Stats = { Input: Stats.Input; Output: Stats.Output };
118
130
  }
119
- }
120
131
 
121
- export namespace Cron {
122
- export namespace list {
123
- export type Input = Expand<Record<string, never>>;
124
- export type Output = Expand<{
132
+ export namespace Cron {
133
+ export namespace List {
134
+ export type Input = Expand<Record<string, never>>;
135
+ export type Output = Expand<{
125
136
  tasks: {
126
137
  id: string;
127
138
  name: string;
@@ -131,64 +142,71 @@ export namespace Routes {
131
142
  nextRun?: string;
132
143
  }[];
133
144
  }>;
145
+ }
146
+ export type List = { Input: List.Input; Output: List.Output };
134
147
  }
135
- }
136
148
 
137
- export namespace Ratelimit {
138
- export namespace check {
139
- export type Input = Expand<{
149
+ export namespace Ratelimit {
150
+ export namespace Check {
151
+ export type Input = Expand<{
140
152
  key: string;
141
153
  limit: number;
142
154
  window: number;
143
155
  }>;
144
- export type Output = Expand<{
156
+ export type Output = Expand<{
145
157
  allowed: boolean;
146
158
  remaining: number;
147
159
  resetAt: Date;
148
160
  }>;
149
- }
161
+ }
162
+ export type Check = { Input: Check.Input; Output: Check.Output };
150
163
 
151
- export namespace reset {
152
- export type Input = Expand<{
164
+ export namespace Reset {
165
+ export type Input = Expand<{
153
166
  key: string;
154
167
  }>;
155
- export type Output = Expand<{
168
+ export type Output = Expand<{
156
169
  success: boolean;
157
170
  }>;
171
+ }
172
+ export type Reset = { Input: Reset.Input; Output: Reset.Output };
158
173
  }
159
- }
160
174
 
161
- export namespace Events {
162
- export namespace emit {
163
- export type Input = Expand<{
175
+ export namespace Events {
176
+ export namespace Emit {
177
+ export type Input = Expand<{
164
178
  event: string;
165
179
  data: any;
166
180
  }>;
167
- export type Output = Expand<{
181
+ export type Output = Expand<{
168
182
  success: boolean;
169
183
  }>;
184
+ }
185
+ export type Emit = { Input: Emit.Input; Output: Emit.Output };
170
186
  }
171
- }
172
187
 
173
- export namespace Sse {
174
- export namespace broadcast {
175
- export type Input = Expand<{
188
+ export namespace Sse {
189
+ export namespace Broadcast {
190
+ export type Input = Expand<{
176
191
  channel: string;
177
192
  event: string;
178
193
  data: any;
179
194
  }>;
180
- export type Output = Expand<{
195
+ export type Output = Expand<{
181
196
  success: boolean;
182
197
  recipients: number;
183
198
  }>;
184
- }
199
+ }
200
+ export type Broadcast = { Input: Broadcast.Input; Output: Broadcast.Output };
185
201
 
186
- export namespace clients {
187
- export type Input = Expand<Record<string, never>>;
188
- export type Output = Expand<{
202
+ export namespace Clients {
203
+ export type Input = Expand<Record<string, never>>;
204
+ export type Output = Expand<{
189
205
  total: number;
190
206
  byChannel: number;
191
207
  }>;
208
+ }
209
+ export type Clients = { Input: Clients.Input; Output: Clients.Output };
192
210
  }
193
211
  }
194
212
  }
@@ -202,41 +220,37 @@ export class ApiClient extends UnifiedApiClientBase {
202
220
  super(options);
203
221
  }
204
222
 
205
- counter = {
206
- get: (input: Routes.Counter.get.Input): Promise<Routes.Counter.get.Output> => this.request("api.counter.get", input),
207
- increment: (input: Routes.Counter.increment.Input): Promise<Routes.Counter.increment.Output> => this.request("api.counter.increment", input),
208
- decrement: (input: Routes.Counter.decrement.Input): Promise<Routes.Counter.decrement.Output> => this.request("api.counter.decrement", input),
209
- reset: (input: Routes.Counter.reset.Input): Promise<Routes.Counter.reset.Output> => this.request("api.counter.reset", input)
210
- };
211
-
212
- cache = {
213
- set: (input: Routes.Cache.set.Input): Promise<Routes.Cache.set.Output> => this.request("api.cache.set", input),
214
- get: (input: Routes.Cache.get.Input): Promise<Routes.Cache.get.Output> => this.request("api.cache.get", input),
215
- delete: (input: Routes.Cache.delete.Input): Promise<Routes.Cache.delete.Output> => this.request("api.cache.delete", input),
216
- keys: (input: Routes.Cache.keys.Input): Promise<Routes.Cache.keys.Output> => this.request("api.cache.keys", input)
217
- };
218
-
219
- jobs = {
220
- enqueue: (input: Routes.Jobs.enqueue.Input): Promise<Routes.Jobs.enqueue.Output> => this.request("api.jobs.enqueue", input),
221
- stats: (input: Routes.Jobs.stats.Input): Promise<Routes.Jobs.stats.Output> => this.request("api.jobs.stats", input)
222
- };
223
-
224
- cron = {
225
- list: (input: Routes.Cron.list.Input): Promise<Routes.Cron.list.Output> => this.request("api.cron.list", input)
226
- };
227
-
228
- ratelimit = {
229
- check: (input: Routes.Ratelimit.check.Input): Promise<Routes.Ratelimit.check.Output> => this.request("api.ratelimit.check", input),
230
- reset: (input: Routes.Ratelimit.reset.Input): Promise<Routes.Ratelimit.reset.Output> => this.request("api.ratelimit.reset", input)
231
- };
232
-
233
- events = {
234
- emit: (input: Routes.Events.emit.Input): Promise<Routes.Events.emit.Output> => this.request("api.events.emit", input)
235
- };
236
-
237
- sse = {
238
- broadcast: (input: Routes.Sse.broadcast.Input): Promise<Routes.Sse.broadcast.Output> => this.request("api.sse.broadcast", input),
239
- clients: (input: Routes.Sse.clients.Input): Promise<Routes.Sse.clients.Output> => this.request("api.sse.clients", input)
223
+ api = {
224
+ counter: {
225
+ get: (input: Routes.Api.Counter.Get.Input): Promise<Routes.Api.Counter.Get.Output> => this.request("api.counter.get", input),
226
+ increment: (input: Routes.Api.Counter.Increment.Input): Promise<Routes.Api.Counter.Increment.Output> => this.request("api.counter.increment", input),
227
+ decrement: (input: Routes.Api.Counter.Decrement.Input): Promise<Routes.Api.Counter.Decrement.Output> => this.request("api.counter.decrement", input),
228
+ reset: (input: Routes.Api.Counter.Reset.Input): Promise<Routes.Api.Counter.Reset.Output> => this.request("api.counter.reset", input)
229
+ },
230
+ cache: {
231
+ set: (input: Routes.Api.Cache.Set.Input): Promise<Routes.Api.Cache.Set.Output> => this.request("api.cache.set", input),
232
+ get: (input: Routes.Api.Cache.Get.Input): Promise<Routes.Api.Cache.Get.Output> => this.request("api.cache.get", input),
233
+ delete: (input: Routes.Api.Cache.Delete.Input): Promise<Routes.Api.Cache.Delete.Output> => this.request("api.cache.delete", input),
234
+ keys: (input: Routes.Api.Cache.Keys.Input): Promise<Routes.Api.Cache.Keys.Output> => this.request("api.cache.keys", input)
235
+ },
236
+ jobs: {
237
+ enqueue: (input: Routes.Api.Jobs.Enqueue.Input): Promise<Routes.Api.Jobs.Enqueue.Output> => this.request("api.jobs.enqueue", input),
238
+ stats: (input: Routes.Api.Jobs.Stats.Input): Promise<Routes.Api.Jobs.Stats.Output> => this.request("api.jobs.stats", input)
239
+ },
240
+ cron: {
241
+ list: (input: Routes.Api.Cron.List.Input): Promise<Routes.Api.Cron.List.Output> => this.request("api.cron.list", input)
242
+ },
243
+ ratelimit: {
244
+ check: (input: Routes.Api.Ratelimit.Check.Input): Promise<Routes.Api.Ratelimit.Check.Output> => this.request("api.ratelimit.check", input),
245
+ reset: (input: Routes.Api.Ratelimit.Reset.Input): Promise<Routes.Api.Ratelimit.Reset.Output> => this.request("api.ratelimit.reset", input)
246
+ },
247
+ events: {
248
+ emit: (input: Routes.Api.Events.Emit.Input): Promise<Routes.Api.Events.Emit.Output> => this.request("api.events.emit", input)
249
+ },
250
+ sse: {
251
+ broadcast: (input: Routes.Api.Sse.Broadcast.Input): Promise<Routes.Api.Sse.Broadcast.Output> => this.request("api.sse.broadcast", input),
252
+ clients: (input: Routes.Api.Sse.Clients.Input): Promise<Routes.Api.Sse.Clients.Output> => this.request("api.sse.clients", input)
253
+ }
240
254
  };
241
255
  }
242
256
 
@@ -8,7 +8,7 @@ export const load: PageServerLoad = async ({ locals }) => {
8
8
 
9
9
  try {
10
10
  // Direct service call through typed client
11
- const result = await client.counter.get({});
11
+ const result = await client.api.counter.get({});
12
12
  return {
13
13
  count: result.count,
14
14
  loadedAt: new Date().toISOString(),
@@ -72,37 +72,37 @@
72
72
  ) {
73
73
  counterLoading = true;
74
74
 
75
- const result = await client.counter[action]({});
75
+ const result = await client.api.counter[action]({});
76
76
  count = result.count;
77
77
  counterLoading = false;
78
78
  }
79
79
 
80
80
  // Cache actions - using typed client
81
81
  async function cacheSet() {
82
- await client.cache.set({ key: cacheKey, value: cacheValue, ttl: cacheTTL });
82
+ await client.api.cache.set({ key: cacheKey, value: cacheValue, ttl: cacheTTL });
83
83
  cacheResult = { action: "set", success: true };
84
84
  refreshCacheKeys();
85
85
  }
86
86
 
87
87
  async function cacheGet() {
88
- cacheResult = await client.cache.get({ key: cacheKey });
88
+ cacheResult = await client.api.cache.get({ key: cacheKey });
89
89
  refreshCacheKeys();
90
90
  }
91
91
 
92
92
  async function cacheDelete() {
93
- await client.cache.delete({ key: cacheKey });
93
+ await client.api.cache.delete({ key: cacheKey });
94
94
  cacheResult = { action: "deleted", success: true };
95
95
  refreshCacheKeys();
96
96
  }
97
97
 
98
98
  async function refreshCacheKeys() {
99
- const result = await client.cache.keys({});
99
+ const result = await client.api.cache.keys({});
100
100
  cacheKeys = result.keys || [];
101
101
  }
102
102
 
103
103
  // Jobs actions - using typed client
104
104
  async function enqueueJob() {
105
- const result = (await client.jobs.enqueue({
105
+ const result = (await client.api.jobs.enqueue({
106
106
  name: "demo-job",
107
107
  data: { message: jobMessage },
108
108
  delay: jobDelay > 0 ? jobDelay : undefined,
@@ -112,7 +112,7 @@
112
112
  }
113
113
 
114
114
  async function refreshJobStats() {
115
- jobStats = (await client.jobs.stats({})) as {
115
+ jobStats = (await client.api.jobs.stats({})) as {
116
116
  pending: number;
117
117
  running: number;
118
118
  completed: number;
@@ -121,7 +121,7 @@
121
121
 
122
122
  // Rate limiter actions - using typed client
123
123
  async function checkRateLimit() {
124
- rateLimitResult = await client.ratelimit.check({
124
+ rateLimitResult = await client.api.ratelimit.check({
125
125
  key: rateLimitKey,
126
126
  limit: rateLimitMax,
127
127
  window: rateLimitWindow,
@@ -129,13 +129,13 @@
129
129
  }
130
130
 
131
131
  async function resetRateLimit() {
132
- await client.ratelimit.reset({ key: rateLimitKey });
132
+ await client.api.ratelimit.reset({ key: rateLimitKey });
133
133
  rateLimitResult = { reset: true, message: "Rate limit reset" };
134
134
  }
135
135
 
136
136
  // Cron actions - using typed client
137
137
  async function refreshCronTasks() {
138
- const result = (await client.cron.list({})) as { tasks: CronTask[] };
138
+ const result = (await client.api.cron.list({})) as { tasks: CronTask[] };
139
139
  cronTasks = result.tasks;
140
140
  }
141
141
 
@@ -143,7 +143,7 @@
143
143
  async function emitEvent() {
144
144
  try {
145
145
  const parsedData = JSON.parse(eventData);
146
- await client.events.emit({ event: eventName, data: parsedData });
146
+ await client.api.events.emit({ event: eventName, data: parsedData });
147
147
  } catch (e) {
148
148
  console.error("Invalid JSON:", e);
149
149
  }
@@ -151,7 +151,7 @@
151
151
 
152
152
  // SSE actions - using typed client
153
153
  async function manualBroadcast() {
154
- await client.sseRoutes.broadcast({
154
+ await client.api.sse.broadcast({
155
155
  channel: "events",
156
156
  event: "manual",
157
157
  data: {
@@ -164,7 +164,7 @@
164
164
  }
165
165
 
166
166
  async function refreshSSEClients() {
167
- sseClients = (await client.sseRoutes.clients({})) as {
167
+ sseClients = (await client.api.sse.clients({})) as {
168
168
  total: number;
169
169
  byChannel: number;
170
170
  };