@lovelybunch/api 1.0.7
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/lib/gait-path.d.ts +13 -0
- package/dist/lib/gait-path.js +57 -0
- package/dist/lib/project-paths.d.ts +13 -0
- package/dist/lib/project-paths.js +57 -0
- package/dist/lib/storage/file-storage.d.ts +28 -0
- package/dist/lib/storage/file-storage.js +224 -0
- package/dist/lib/symlinks/symlink-manager.d.ts +66 -0
- package/dist/lib/symlinks/symlink-manager.js +444 -0
- package/dist/lib/symlinks/types.d.ts +23 -0
- package/dist/lib/symlinks/types.js +4 -0
- package/dist/lib/terminal/context-helper.d.ts +11 -0
- package/dist/lib/terminal/context-helper.js +164 -0
- package/dist/lib/terminal/global-manager.d.ts +2 -0
- package/dist/lib/terminal/global-manager.js +15 -0
- package/dist/lib/terminal/shell-utils.d.ts +33 -0
- package/dist/lib/terminal/shell-utils.js +176 -0
- package/dist/lib/terminal/terminal-manager.d.ts +26 -0
- package/dist/lib/terminal/terminal-manager.js +276 -0
- package/dist/lib/user-preferences.d.ts +48 -0
- package/dist/lib/user-preferences.js +87 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +5 -0
- package/dist/routes/api/symlink-status/route.d.ts +1 -0
- package/dist/routes/api/symlink-status/route.js +37 -0
- package/dist/routes/api/symlinks/[id]/route.d.ts +19 -0
- package/dist/routes/api/symlinks/[id]/route.js +95 -0
- package/dist/routes/api/symlinks/[id]/toggle/route.d.ts +11 -0
- package/dist/routes/api/symlinks/[id]/toggle/route.js +32 -0
- package/dist/routes/api/symlinks/debug/route.d.ts +1 -0
- package/dist/routes/api/symlinks/debug/route.js +35 -0
- package/dist/routes/api/symlinks/route.d.ts +9 -0
- package/dist/routes/api/symlinks/route.js +72 -0
- package/dist/routes/api/toggle-symlink/route.d.ts +2 -0
- package/dist/routes/api/toggle-symlink/route.js +94 -0
- package/dist/routes/api/v1/agents/[id]/index.d.ts +1 -0
- package/dist/routes/api/v1/agents/[id]/index.js +1 -0
- package/dist/routes/api/v1/agents/[id]/route.d.ts +3 -0
- package/dist/routes/api/v1/agents/[id]/route.js +163 -0
- package/dist/routes/api/v1/agents/index.d.ts +1 -0
- package/dist/routes/api/v1/agents/index.js +1 -0
- package/dist/routes/api/v1/agents/route.d.ts +3 -0
- package/dist/routes/api/v1/agents/route.js +133 -0
- package/dist/routes/api/v1/ai/index.d.ts +3 -0
- package/dist/routes/api/v1/ai/index.js +5 -0
- package/dist/routes/api/v1/ai/route.d.ts +8 -0
- package/dist/routes/api/v1/ai/route.js +86 -0
- package/dist/routes/api/v1/chats/[id]/index.d.ts +3 -0
- package/dist/routes/api/v1/chats/[id]/index.js +6 -0
- package/dist/routes/api/v1/chats/[id]/route.d.ts +12 -0
- package/dist/routes/api/v1/chats/[id]/route.js +31 -0
- package/dist/routes/api/v1/chats/index.d.ts +3 -0
- package/dist/routes/api/v1/chats/index.js +6 -0
- package/dist/routes/api/v1/chats/route.d.ts +32 -0
- package/dist/routes/api/v1/chats/route.js +67 -0
- package/dist/routes/api/v1/config/index.d.ts +3 -0
- package/dist/routes/api/v1/config/index.js +5 -0
- package/dist/routes/api/v1/config/route.d.ts +9 -0
- package/dist/routes/api/v1/config/route.js +29 -0
- package/dist/routes/api/v1/context/[...path]/route.d.ts +16 -0
- package/dist/routes/api/v1/context/[...path]/route.js +107 -0
- package/dist/routes/api/v1/context/architecture/route.d.ts +3 -0
- package/dist/routes/api/v1/context/architecture/route.js +198 -0
- package/dist/routes/api/v1/context/index.d.ts +3 -0
- package/dist/routes/api/v1/context/index.js +9 -0
- package/dist/routes/api/v1/context/knowledge/[filename]/index.d.ts +1 -0
- package/dist/routes/api/v1/context/knowledge/[filename]/index.js +1 -0
- package/dist/routes/api/v1/context/knowledge/[filename]/route.d.ts +3 -0
- package/dist/routes/api/v1/context/knowledge/[filename]/route.js +165 -0
- package/dist/routes/api/v1/context/knowledge/index.d.ts +1 -0
- package/dist/routes/api/v1/context/knowledge/index.js +1 -0
- package/dist/routes/api/v1/context/knowledge/route.d.ts +3 -0
- package/dist/routes/api/v1/context/knowledge/route.js +121 -0
- package/dist/routes/api/v1/context/project/route.d.ts +3 -0
- package/dist/routes/api/v1/context/project/route.js +153 -0
- package/dist/routes/api/v1/proposals/[id]/route.d.ts +337 -0
- package/dist/routes/api/v1/proposals/[id]/route.js +99 -0
- package/dist/routes/api/v1/proposals/index.d.ts +3 -0
- package/dist/routes/api/v1/proposals/index.js +10 -0
- package/dist/routes/api/v1/proposals/route.d.ts +315 -0
- package/dist/routes/api/v1/proposals/route.js +103 -0
- package/dist/routes/api/v1/resources/[id]/index.d.ts +3 -0
- package/dist/routes/api/v1/resources/[id]/index.js +7 -0
- package/dist/routes/api/v1/resources/[id]/route.d.ts +46 -0
- package/dist/routes/api/v1/resources/[id]/route.js +143 -0
- package/dist/routes/api/v1/resources/[id]/thumbnail/index.d.ts +3 -0
- package/dist/routes/api/v1/resources/[id]/thumbnail/index.js +5 -0
- package/dist/routes/api/v1/resources/[id]/thumbnail/route.d.ts +2 -0
- package/dist/routes/api/v1/resources/[id]/thumbnail/route.js +50 -0
- package/dist/routes/api/v1/resources/index.d.ts +3 -0
- package/dist/routes/api/v1/resources/index.js +6 -0
- package/dist/routes/api/v1/resources/route.d.ts +51 -0
- package/dist/routes/api/v1/resources/route.js +147 -0
- package/dist/routes/api/v1/search/route.d.ts +3 -0
- package/dist/routes/api/v1/search/route.js +39 -0
- package/dist/routes/api/v1/terminal/[proposalId]/create/index.d.ts +3 -0
- package/dist/routes/api/v1/terminal/[proposalId]/create/index.js +5 -0
- package/dist/routes/api/v1/terminal/[proposalId]/create/route.d.ts +10 -0
- package/dist/routes/api/v1/terminal/[proposalId]/create/route.js +27 -0
- package/dist/routes/api/v1/terminal/[proposalId]/destroy/index.d.ts +3 -0
- package/dist/routes/api/v1/terminal/[proposalId]/destroy/index.js +5 -0
- package/dist/routes/api/v1/terminal/[proposalId]/destroy/route.d.ts +10 -0
- package/dist/routes/api/v1/terminal/[proposalId]/destroy/route.js +21 -0
- package/dist/routes/api/v1/terminal/[proposalId]/resize/index.d.ts +3 -0
- package/dist/routes/api/v1/terminal/[proposalId]/resize/index.js +5 -0
- package/dist/routes/api/v1/terminal/[proposalId]/resize/route.d.ts +10 -0
- package/dist/routes/api/v1/terminal/[proposalId]/resize/route.js +21 -0
- package/dist/routes/api/v1/terminal/sessions/index.d.ts +3 -0
- package/dist/routes/api/v1/terminal/sessions/index.js +5 -0
- package/dist/routes/api/v1/terminal/sessions/route.d.ts +6 -0
- package/dist/routes/api/v1/terminal/sessions/route.js +29 -0
- package/dist/routes/api/v1/user/index.d.ts +3 -0
- package/dist/routes/api/v1/user/index.js +5 -0
- package/dist/routes/api/v1/user/preferences/route.d.ts +11 -0
- package/dist/routes/api/v1/user/preferences/route.js +31 -0
- package/dist/routes/api/v1/user/profile/route.d.ts +11 -0
- package/dist/routes/api/v1/user/profile/route.js +31 -0
- package/dist/routes/api/v1/user/settings/index.d.ts +1 -0
- package/dist/routes/api/v1/user/settings/index.js +1 -0
- package/dist/routes/api/v1/user/settings/route.d.ts +3 -0
- package/dist/routes/api/v1/user/settings/route.js +51 -0
- package/dist/server-with-static.d.ts +4 -0
- package/dist/server-with-static.js +144 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +91 -0
- package/package.json +42 -0
- package/static/assets/index-BvTnrm0O.js +576 -0
- package/static/assets/index-Cm5dZHTl.css +33 -0
- package/static/assets/index-ORkAkJNi.js +576 -0
- package/static/assets/index-_Keadpms.js +576 -0
- package/static/index.html +17 -0
- package/static/vite.svg +1 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { Context } from 'hono';
|
|
2
|
+
export declare function GET(c: Context): Promise<(Response & import("hono").TypedResponse<{
|
|
3
|
+
success: false;
|
|
4
|
+
error: {
|
|
5
|
+
code: string;
|
|
6
|
+
message: string;
|
|
7
|
+
};
|
|
8
|
+
}, 404, "json">) | (Response & import("hono").TypedResponse<{
|
|
9
|
+
success: true;
|
|
10
|
+
data: {
|
|
11
|
+
id: string;
|
|
12
|
+
intent: string;
|
|
13
|
+
content?: string;
|
|
14
|
+
author: {
|
|
15
|
+
type: import("@lovelybunch/types").AuthorType;
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
email?: string;
|
|
19
|
+
};
|
|
20
|
+
productSpecRef?: string;
|
|
21
|
+
planSteps: {
|
|
22
|
+
id: string;
|
|
23
|
+
description: string;
|
|
24
|
+
command?: string;
|
|
25
|
+
expectedOutcome?: string;
|
|
26
|
+
status: "pending" | "in-progress" | "completed" | "failed";
|
|
27
|
+
output?: string;
|
|
28
|
+
error?: string;
|
|
29
|
+
executedAt?: string;
|
|
30
|
+
}[];
|
|
31
|
+
evidence: {
|
|
32
|
+
type: "test" | "benchmark" | "screenshot" | "log" | "other";
|
|
33
|
+
description: string;
|
|
34
|
+
data: any;
|
|
35
|
+
timestamp: string;
|
|
36
|
+
}[];
|
|
37
|
+
policies: {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
description: string;
|
|
41
|
+
status: "pending" | "passed" | "failed" | "skipped";
|
|
42
|
+
message?: string;
|
|
43
|
+
checkedAt?: string;
|
|
44
|
+
}[];
|
|
45
|
+
featureFlags: {
|
|
46
|
+
id: string;
|
|
47
|
+
version: string;
|
|
48
|
+
name: string;
|
|
49
|
+
description: string;
|
|
50
|
+
type: import("@lovelybunch/types").FeatureFlagType;
|
|
51
|
+
defaultValue: any;
|
|
52
|
+
scopes: string[];
|
|
53
|
+
targets: {
|
|
54
|
+
audience: string;
|
|
55
|
+
value: any;
|
|
56
|
+
percentage?: number;
|
|
57
|
+
}[];
|
|
58
|
+
killSwitch: boolean;
|
|
59
|
+
dependencies: string[];
|
|
60
|
+
createdAt: string;
|
|
61
|
+
updatedAt: string;
|
|
62
|
+
}[];
|
|
63
|
+
experiments: {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
hypothesis: string;
|
|
67
|
+
variants: {
|
|
68
|
+
id: string;
|
|
69
|
+
name: string;
|
|
70
|
+
description: string;
|
|
71
|
+
allocation: number;
|
|
72
|
+
config: {
|
|
73
|
+
[x: string]: any;
|
|
74
|
+
};
|
|
75
|
+
}[];
|
|
76
|
+
allocation: {
|
|
77
|
+
method: "random" | "deterministic" | "weighted";
|
|
78
|
+
seed?: string;
|
|
79
|
+
totalAllocation: number;
|
|
80
|
+
};
|
|
81
|
+
successMetrics: string[];
|
|
82
|
+
guardrailMetrics: {
|
|
83
|
+
name: string;
|
|
84
|
+
threshold: number;
|
|
85
|
+
comparison: "greater" | "less" | "equal";
|
|
86
|
+
action: "alert" | "pause" | "stop";
|
|
87
|
+
}[];
|
|
88
|
+
stopRules: {
|
|
89
|
+
metric: string;
|
|
90
|
+
condition: string;
|
|
91
|
+
action: "stop" | "pause";
|
|
92
|
+
}[];
|
|
93
|
+
analysisConfig: {
|
|
94
|
+
confidenceLevel: number;
|
|
95
|
+
minimumSampleSize: number;
|
|
96
|
+
testType: "two-tailed" | "one-tailed";
|
|
97
|
+
};
|
|
98
|
+
status: import("@lovelybunch/types").ExperimentStatus;
|
|
99
|
+
startedAt?: string;
|
|
100
|
+
endedAt?: string;
|
|
101
|
+
}[];
|
|
102
|
+
telemetryContracts: {
|
|
103
|
+
eventName: string;
|
|
104
|
+
version: string;
|
|
105
|
+
schema: {
|
|
106
|
+
[x: string]: any;
|
|
107
|
+
};
|
|
108
|
+
piiFields: {
|
|
109
|
+
field: string;
|
|
110
|
+
classification: "none" | "quasi" | "sensitive" | "highly-sensitive";
|
|
111
|
+
handling: "clear" | "hash" | "encrypt" | "remove";
|
|
112
|
+
}[];
|
|
113
|
+
samplingRate: number;
|
|
114
|
+
retentionPolicy: {
|
|
115
|
+
duration: number;
|
|
116
|
+
archiveAfter?: number;
|
|
117
|
+
deleteAfter: number;
|
|
118
|
+
};
|
|
119
|
+
approvals: {
|
|
120
|
+
approver: string;
|
|
121
|
+
approvedAt: string;
|
|
122
|
+
comment?: string;
|
|
123
|
+
}[];
|
|
124
|
+
}[];
|
|
125
|
+
releasePlan: {
|
|
126
|
+
strategy: "immediate" | "gradual" | "scheduled" | "gated";
|
|
127
|
+
stages?: {
|
|
128
|
+
name: string;
|
|
129
|
+
percentage: number;
|
|
130
|
+
duration?: number;
|
|
131
|
+
criteria?: string[];
|
|
132
|
+
}[];
|
|
133
|
+
schedule?: string;
|
|
134
|
+
rollbackPlan?: string;
|
|
135
|
+
};
|
|
136
|
+
status: import("@lovelybunch/types").CPStatus;
|
|
137
|
+
metadata: {
|
|
138
|
+
createdAt: string;
|
|
139
|
+
updatedAt: string;
|
|
140
|
+
reviewers: string[];
|
|
141
|
+
aiInteractions: {
|
|
142
|
+
id: string;
|
|
143
|
+
timestamp: string;
|
|
144
|
+
model: string;
|
|
145
|
+
prompt: string;
|
|
146
|
+
response: string;
|
|
147
|
+
tokens: {
|
|
148
|
+
prompt: number;
|
|
149
|
+
completion: number;
|
|
150
|
+
total: number;
|
|
151
|
+
};
|
|
152
|
+
cost?: number;
|
|
153
|
+
}[];
|
|
154
|
+
tags?: string[];
|
|
155
|
+
priority?: "low" | "medium" | "high" | "critical";
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
159
|
+
success: false;
|
|
160
|
+
error: {
|
|
161
|
+
code: string;
|
|
162
|
+
message: any;
|
|
163
|
+
};
|
|
164
|
+
}, 500, "json">)>;
|
|
165
|
+
export declare function PATCH(c: Context): Promise<(Response & import("hono").TypedResponse<{
|
|
166
|
+
success: true;
|
|
167
|
+
data: {
|
|
168
|
+
id: string;
|
|
169
|
+
intent: string;
|
|
170
|
+
content?: string;
|
|
171
|
+
author: {
|
|
172
|
+
type: import("@lovelybunch/types").AuthorType;
|
|
173
|
+
id: string;
|
|
174
|
+
name: string;
|
|
175
|
+
email?: string;
|
|
176
|
+
};
|
|
177
|
+
productSpecRef?: string;
|
|
178
|
+
planSteps: {
|
|
179
|
+
id: string;
|
|
180
|
+
description: string;
|
|
181
|
+
command?: string;
|
|
182
|
+
expectedOutcome?: string;
|
|
183
|
+
status: "pending" | "in-progress" | "completed" | "failed";
|
|
184
|
+
output?: string;
|
|
185
|
+
error?: string;
|
|
186
|
+
executedAt?: string;
|
|
187
|
+
}[];
|
|
188
|
+
evidence: {
|
|
189
|
+
type: "test" | "benchmark" | "screenshot" | "log" | "other";
|
|
190
|
+
description: string;
|
|
191
|
+
data: any;
|
|
192
|
+
timestamp: string;
|
|
193
|
+
}[];
|
|
194
|
+
policies: {
|
|
195
|
+
id: string;
|
|
196
|
+
name: string;
|
|
197
|
+
description: string;
|
|
198
|
+
status: "pending" | "passed" | "failed" | "skipped";
|
|
199
|
+
message?: string;
|
|
200
|
+
checkedAt?: string;
|
|
201
|
+
}[];
|
|
202
|
+
featureFlags: {
|
|
203
|
+
id: string;
|
|
204
|
+
version: string;
|
|
205
|
+
name: string;
|
|
206
|
+
description: string;
|
|
207
|
+
type: import("@lovelybunch/types").FeatureFlagType;
|
|
208
|
+
defaultValue: any;
|
|
209
|
+
scopes: string[];
|
|
210
|
+
targets: {
|
|
211
|
+
audience: string;
|
|
212
|
+
value: any;
|
|
213
|
+
percentage?: number;
|
|
214
|
+
}[];
|
|
215
|
+
killSwitch: boolean;
|
|
216
|
+
dependencies: string[];
|
|
217
|
+
createdAt: string;
|
|
218
|
+
updatedAt: string;
|
|
219
|
+
}[];
|
|
220
|
+
experiments: {
|
|
221
|
+
id: string;
|
|
222
|
+
name: string;
|
|
223
|
+
hypothesis: string;
|
|
224
|
+
variants: {
|
|
225
|
+
id: string;
|
|
226
|
+
name: string;
|
|
227
|
+
description: string;
|
|
228
|
+
allocation: number;
|
|
229
|
+
config: {
|
|
230
|
+
[x: string]: any;
|
|
231
|
+
};
|
|
232
|
+
}[];
|
|
233
|
+
allocation: {
|
|
234
|
+
method: "random" | "deterministic" | "weighted";
|
|
235
|
+
seed?: string;
|
|
236
|
+
totalAllocation: number;
|
|
237
|
+
};
|
|
238
|
+
successMetrics: string[];
|
|
239
|
+
guardrailMetrics: {
|
|
240
|
+
name: string;
|
|
241
|
+
threshold: number;
|
|
242
|
+
comparison: "greater" | "less" | "equal";
|
|
243
|
+
action: "alert" | "pause" | "stop";
|
|
244
|
+
}[];
|
|
245
|
+
stopRules: {
|
|
246
|
+
metric: string;
|
|
247
|
+
condition: string;
|
|
248
|
+
action: "stop" | "pause";
|
|
249
|
+
}[];
|
|
250
|
+
analysisConfig: {
|
|
251
|
+
confidenceLevel: number;
|
|
252
|
+
minimumSampleSize: number;
|
|
253
|
+
testType: "two-tailed" | "one-tailed";
|
|
254
|
+
};
|
|
255
|
+
status: import("@lovelybunch/types").ExperimentStatus;
|
|
256
|
+
startedAt?: string;
|
|
257
|
+
endedAt?: string;
|
|
258
|
+
}[];
|
|
259
|
+
telemetryContracts: {
|
|
260
|
+
eventName: string;
|
|
261
|
+
version: string;
|
|
262
|
+
schema: {
|
|
263
|
+
[x: string]: any;
|
|
264
|
+
};
|
|
265
|
+
piiFields: {
|
|
266
|
+
field: string;
|
|
267
|
+
classification: "none" | "quasi" | "sensitive" | "highly-sensitive";
|
|
268
|
+
handling: "clear" | "hash" | "encrypt" | "remove";
|
|
269
|
+
}[];
|
|
270
|
+
samplingRate: number;
|
|
271
|
+
retentionPolicy: {
|
|
272
|
+
duration: number;
|
|
273
|
+
archiveAfter?: number;
|
|
274
|
+
deleteAfter: number;
|
|
275
|
+
};
|
|
276
|
+
approvals: {
|
|
277
|
+
approver: string;
|
|
278
|
+
approvedAt: string;
|
|
279
|
+
comment?: string;
|
|
280
|
+
}[];
|
|
281
|
+
}[];
|
|
282
|
+
releasePlan: {
|
|
283
|
+
strategy: "immediate" | "gradual" | "scheduled" | "gated";
|
|
284
|
+
stages?: {
|
|
285
|
+
name: string;
|
|
286
|
+
percentage: number;
|
|
287
|
+
duration?: number;
|
|
288
|
+
criteria?: string[];
|
|
289
|
+
}[];
|
|
290
|
+
schedule?: string;
|
|
291
|
+
rollbackPlan?: string;
|
|
292
|
+
};
|
|
293
|
+
status: import("@lovelybunch/types").CPStatus;
|
|
294
|
+
metadata: {
|
|
295
|
+
createdAt: string;
|
|
296
|
+
updatedAt: string;
|
|
297
|
+
reviewers: string[];
|
|
298
|
+
aiInteractions: {
|
|
299
|
+
id: string;
|
|
300
|
+
timestamp: string;
|
|
301
|
+
model: string;
|
|
302
|
+
prompt: string;
|
|
303
|
+
response: string;
|
|
304
|
+
tokens: {
|
|
305
|
+
prompt: number;
|
|
306
|
+
completion: number;
|
|
307
|
+
total: number;
|
|
308
|
+
};
|
|
309
|
+
cost?: number;
|
|
310
|
+
}[];
|
|
311
|
+
tags?: string[];
|
|
312
|
+
priority?: "low" | "medium" | "high" | "critical";
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
316
|
+
success: false;
|
|
317
|
+
error: {
|
|
318
|
+
code: string;
|
|
319
|
+
message: any;
|
|
320
|
+
};
|
|
321
|
+
}, 404, "json">) | (Response & import("hono").TypedResponse<{
|
|
322
|
+
success: false;
|
|
323
|
+
error: {
|
|
324
|
+
code: string;
|
|
325
|
+
message: any;
|
|
326
|
+
};
|
|
327
|
+
}, 500, "json">)>;
|
|
328
|
+
export declare function DELETE(c: Context): Promise<(Response & import("hono").TypedResponse<{
|
|
329
|
+
success: true;
|
|
330
|
+
message: string;
|
|
331
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
332
|
+
success: false;
|
|
333
|
+
error: {
|
|
334
|
+
code: string;
|
|
335
|
+
message: any;
|
|
336
|
+
};
|
|
337
|
+
}, 500, "json">)>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { FileStorageAdapter } from '../../../../../lib/storage/file-storage.js';
|
|
2
|
+
const storage = new FileStorageAdapter();
|
|
3
|
+
export async function GET(c) {
|
|
4
|
+
try {
|
|
5
|
+
const id = c.req.param('id');
|
|
6
|
+
const proposal = await storage.getCP(id);
|
|
7
|
+
if (!proposal) {
|
|
8
|
+
return c.json({
|
|
9
|
+
success: false,
|
|
10
|
+
error: {
|
|
11
|
+
code: 'PROPOSAL_NOT_FOUND',
|
|
12
|
+
message: `Proposal with id ${id} not found`
|
|
13
|
+
}
|
|
14
|
+
}, 404);
|
|
15
|
+
}
|
|
16
|
+
return c.json({
|
|
17
|
+
success: true,
|
|
18
|
+
data: proposal
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error('Error getting proposal:', error);
|
|
23
|
+
return c.json({
|
|
24
|
+
success: false,
|
|
25
|
+
error: {
|
|
26
|
+
code: 'GET_PROPOSAL_ERROR',
|
|
27
|
+
message: error.message
|
|
28
|
+
}
|
|
29
|
+
}, 500);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export async function PATCH(c) {
|
|
33
|
+
try {
|
|
34
|
+
const id = c.req.param('id');
|
|
35
|
+
const updates = await c.req.json();
|
|
36
|
+
// Get existing proposal to merge updates properly
|
|
37
|
+
const existing = await storage.getCP(id);
|
|
38
|
+
if (!existing) {
|
|
39
|
+
return c.json({
|
|
40
|
+
success: false,
|
|
41
|
+
error: {
|
|
42
|
+
code: 'PROPOSAL_NOT_FOUND',
|
|
43
|
+
message: `Proposal with id ${id} not found`
|
|
44
|
+
}
|
|
45
|
+
}, 404);
|
|
46
|
+
}
|
|
47
|
+
// Handle special fields like comments
|
|
48
|
+
let finalUpdates = { ...updates };
|
|
49
|
+
if (updates.comments) {
|
|
50
|
+
finalUpdates = { ...finalUpdates, comments: updates.comments };
|
|
51
|
+
}
|
|
52
|
+
await storage.updateCP(id, finalUpdates);
|
|
53
|
+
// Fetch the updated proposal
|
|
54
|
+
const updatedProposal = await storage.getCP(id);
|
|
55
|
+
return c.json({
|
|
56
|
+
success: true,
|
|
57
|
+
data: updatedProposal
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.error('Error updating proposal:', error);
|
|
62
|
+
if (error.message.includes('not found')) {
|
|
63
|
+
return c.json({
|
|
64
|
+
success: false,
|
|
65
|
+
error: {
|
|
66
|
+
code: 'PROPOSAL_NOT_FOUND',
|
|
67
|
+
message: error.message
|
|
68
|
+
}
|
|
69
|
+
}, 404);
|
|
70
|
+
}
|
|
71
|
+
return c.json({
|
|
72
|
+
success: false,
|
|
73
|
+
error: {
|
|
74
|
+
code: 'UPDATE_PROPOSAL_ERROR',
|
|
75
|
+
message: error.message
|
|
76
|
+
}
|
|
77
|
+
}, 500);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export async function DELETE(c) {
|
|
81
|
+
try {
|
|
82
|
+
const id = c.req.param('id');
|
|
83
|
+
await storage.deleteCP(id);
|
|
84
|
+
return c.json({
|
|
85
|
+
success: true,
|
|
86
|
+
message: `Proposal ${id} deleted successfully`
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
console.error('Error deleting proposal:', error);
|
|
91
|
+
return c.json({
|
|
92
|
+
success: false,
|
|
93
|
+
error: {
|
|
94
|
+
code: 'DELETE_PROPOSAL_ERROR',
|
|
95
|
+
message: error.message
|
|
96
|
+
}
|
|
97
|
+
}, 500);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { GET, POST } from './route.js';
|
|
3
|
+
import { GET as getProposal, PATCH as patchProposal, DELETE as deleteProposal } from './[id]/route.js';
|
|
4
|
+
const proposals = new Hono();
|
|
5
|
+
proposals.get('/', GET);
|
|
6
|
+
proposals.post('/', POST);
|
|
7
|
+
proposals.get('/:id', getProposal);
|
|
8
|
+
proposals.patch('/:id', patchProposal);
|
|
9
|
+
proposals.delete('/:id', deleteProposal);
|
|
10
|
+
export default proposals;
|