@voyantjs/crm 0.106.0 → 0.107.0

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.
Files changed (55) hide show
  1. package/README.md +3 -3
  2. package/dist/booking-extension.d.ts +7 -7
  3. package/dist/booking-extension.d.ts.map +1 -1
  4. package/dist/booking-extension.js +8 -5
  5. package/dist/index.d.ts +5 -3
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +3 -2
  8. package/dist/routes/activities.d.ts +2 -2
  9. package/dist/routes/custom-fields.d.ts +6 -6
  10. package/dist/routes/index.d.ts +518 -51
  11. package/dist/routes/index.d.ts.map +1 -1
  12. package/dist/routes/index.js +2 -2
  13. package/dist/routes/pipelines.d.ts +4 -4
  14. package/dist/routes/quote-versions.d.ts +746 -0
  15. package/dist/routes/quote-versions.d.ts.map +1 -0
  16. package/dist/routes/quote-versions.js +175 -0
  17. package/dist/routes/quotes.d.ts +161 -53
  18. package/dist/routes/quotes.d.ts.map +1 -1
  19. package/dist/routes/quotes.js +29 -11
  20. package/dist/schema-activities.d.ts +6 -6
  21. package/dist/schema-relations.d.ts +19 -18
  22. package/dist/schema-relations.d.ts.map +1 -1
  23. package/dist/schema-relations.js +38 -31
  24. package/dist/schema-sales.d.ts +206 -87
  25. package/dist/schema-sales.d.ts.map +1 -1
  26. package/dist/schema-sales.js +62 -50
  27. package/dist/schema-shared.d.ts +3 -3
  28. package/dist/schema-shared.d.ts.map +1 -1
  29. package/dist/schema-shared.js +5 -16
  30. package/dist/schema-signals.d.ts +1 -1
  31. package/dist/schema-signals.js +1 -1
  32. package/dist/service/accounts-merge.js +10 -10
  33. package/dist/service/accounts-people.js +1 -1
  34. package/dist/service/accounts-shared.d.ts +4 -1
  35. package/dist/service/accounts-shared.d.ts.map +1 -1
  36. package/dist/service/accounts-shared.js +20 -6
  37. package/dist/service/activities.d.ts +6 -6
  38. package/dist/service/custom-fields.d.ts +6 -6
  39. package/dist/service/index.d.ts +338 -139
  40. package/dist/service/index.d.ts.map +1 -1
  41. package/dist/service/index.js +2 -2
  42. package/dist/service/pipelines.d.ts +4 -4
  43. package/dist/service/quote-versions.d.ts +674 -0
  44. package/dist/service/quote-versions.d.ts.map +1 -0
  45. package/dist/service/quote-versions.js +399 -0
  46. package/dist/service/quotes.d.ts +426 -94
  47. package/dist/service/quotes.d.ts.map +1 -1
  48. package/dist/service/quotes.js +63 -22
  49. package/package.json +7 -7
  50. package/dist/routes/opportunities.d.ts +0 -387
  51. package/dist/routes/opportunities.d.ts.map +0 -1
  52. package/dist/routes/opportunities.js +0 -70
  53. package/dist/service/opportunities.d.ts +0 -822
  54. package/dist/service/opportunities.d.ts.map +0 -1
  55. package/dist/service/opportunities.js +0 -117
@@ -1 +1 @@
1
- {"version":3,"file":"quotes.d.ts","sourceRoot":"","sources":["../../src/service/quotes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAG5B,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,kBAAkB,CAAA;AAGzB,KAAK,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAC1D,KAAK,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AACzD,KAAK,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AACzD,KAAK,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AACjE,KAAK,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAEjE,eAAO,MAAM,aAAa;mBACH,kBAAkB,SAAS,cAAc;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAQ5B,kBAAkB,WAAW,MAAM,QAAQ,uBAAuB;;;;;;;;;;;;;;;2BAQlE,kBAAkB,MAAM,MAAM,QAAQ,uBAAuB;;;;;;;;;;;;;;;2BAS7D,kBAAkB,MAAM,MAAM;;;CAO5D,CAAA"}
@@ -1,13 +1,25 @@
1
- import { and, desc, eq, sql } from "drizzle-orm";
2
- import { quoteLines, quotes } from "../schema.js";
1
+ import { and, desc, eq, ilike, or, sql } from "drizzle-orm";
2
+ import { quoteParticipants, quoteProducts, quotes } from "../schema.js";
3
3
  import { paginate } from "./helpers.js";
4
4
  export const quotesService = {
5
5
  async listQuotes(db, query) {
6
6
  const conditions = [];
7
- if (query.opportunityId)
8
- conditions.push(eq(quotes.opportunityId, query.opportunityId));
7
+ if (query.personId)
8
+ conditions.push(eq(quotes.personId, query.personId));
9
+ if (query.organizationId)
10
+ conditions.push(eq(quotes.organizationId, query.organizationId));
11
+ if (query.pipelineId)
12
+ conditions.push(eq(quotes.pipelineId, query.pipelineId));
13
+ if (query.stageId)
14
+ conditions.push(eq(quotes.stageId, query.stageId));
15
+ if (query.ownerId)
16
+ conditions.push(eq(quotes.ownerId, query.ownerId));
9
17
  if (query.status)
10
18
  conditions.push(eq(quotes.status, query.status));
19
+ if (query.search) {
20
+ const term = `%${query.search}%`;
21
+ conditions.push(or(ilike(quotes.title, term), ilike(quotes.source, term), ilike(quotes.sourceRef, term)));
22
+ }
11
23
  const where = conditions.length ? and(...conditions) : undefined;
12
24
  return paginate(db
13
25
  .select()
@@ -26,44 +38,73 @@ export const quotesService = {
26
38
  return row;
27
39
  },
28
40
  async updateQuote(db, id, data) {
29
- const [row] = await db
30
- .update(quotes)
31
- .set({ ...data, updatedAt: new Date() })
32
- .where(eq(quotes.id, id))
33
- .returning();
41
+ const patch = {
42
+ ...data,
43
+ updatedAt: new Date(),
44
+ };
45
+ if (data.stageId)
46
+ patch.stageChangedAt = new Date();
47
+ if (data.status && data.status !== "open") {
48
+ patch.closedAt = new Date();
49
+ }
50
+ if (data.status === "open") {
51
+ patch.closedAt = null;
52
+ }
53
+ const [row] = await db.update(quotes).set(patch).where(eq(quotes.id, id)).returning();
34
54
  return row ?? null;
35
55
  },
36
56
  async deleteQuote(db, id) {
37
57
  const [row] = await db.delete(quotes).where(eq(quotes.id, id)).returning({ id: quotes.id });
38
58
  return row ?? null;
39
59
  },
40
- listQuoteLines(db, quoteId) {
60
+ listQuoteParticipants(db, quoteId) {
61
+ return db
62
+ .select()
63
+ .from(quoteParticipants)
64
+ .where(eq(quoteParticipants.quoteId, quoteId))
65
+ .orderBy(desc(quoteParticipants.isPrimary), quoteParticipants.createdAt);
66
+ },
67
+ async createQuoteParticipant(db, quoteId, data) {
68
+ const [row] = await db
69
+ .insert(quoteParticipants)
70
+ .values({ ...data, quoteId })
71
+ .returning();
72
+ return row;
73
+ },
74
+ async deleteQuoteParticipant(db, id) {
75
+ const [row] = await db
76
+ .delete(quoteParticipants)
77
+ .where(eq(quoteParticipants.id, id))
78
+ .returning({ id: quoteParticipants.id });
79
+ return row ?? null;
80
+ },
81
+ listQuoteProducts(db, quoteId) {
41
82
  return db
42
83
  .select()
43
- .from(quoteLines)
44
- .where(eq(quoteLines.quoteId, quoteId))
45
- .orderBy(quoteLines.createdAt);
84
+ .from(quoteProducts)
85
+ .where(eq(quoteProducts.quoteId, quoteId))
86
+ .orderBy(quoteProducts.createdAt);
46
87
  },
47
- async createQuoteLine(db, quoteId, data) {
88
+ async createQuoteProduct(db, quoteId, data) {
48
89
  const [row] = await db
49
- .insert(quoteLines)
90
+ .insert(quoteProducts)
50
91
  .values({ ...data, quoteId })
51
92
  .returning();
52
93
  return row;
53
94
  },
54
- async updateQuoteLine(db, id, data) {
95
+ async updateQuoteProduct(db, id, data) {
55
96
  const [row] = await db
56
- .update(quoteLines)
97
+ .update(quoteProducts)
57
98
  .set({ ...data, updatedAt: new Date() })
58
- .where(eq(quoteLines.id, id))
99
+ .where(eq(quoteProducts.id, id))
59
100
  .returning();
60
101
  return row ?? null;
61
102
  },
62
- async deleteQuoteLine(db, id) {
103
+ async deleteQuoteProduct(db, id) {
63
104
  const [row] = await db
64
- .delete(quoteLines)
65
- .where(eq(quoteLines.id, id))
66
- .returning({ id: quoteLines.id });
105
+ .delete(quoteProducts)
106
+ .where(eq(quoteProducts.id, id))
107
+ .returning({ id: quoteProducts.id });
67
108
  return row ?? null;
68
109
  },
69
110
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/crm",
3
- "version": "0.106.0",
3
+ "version": "0.107.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -39,12 +39,12 @@
39
39
  "drizzle-orm": "^0.45.2",
40
40
  "hono": "^4.12.10",
41
41
  "zod": "^4.3.6",
42
- "@voyantjs/action-ledger": "^0.104.1",
43
- "@voyantjs/core": "^0.104.1",
44
- "@voyantjs/crm-contracts": "^0.105.0",
45
- "@voyantjs/db": "^0.104.2",
46
- "@voyantjs/hono": "^0.104.1",
47
- "@voyantjs/identity": "^0.106.0",
42
+ "@voyantjs/action-ledger": "^0.104.2",
43
+ "@voyantjs/core": "^0.105.0",
44
+ "@voyantjs/crm-contracts": "^0.106.0",
45
+ "@voyantjs/db": "^0.104.3",
46
+ "@voyantjs/hono": "^0.104.2",
47
+ "@voyantjs/identity": "^0.107.0",
48
48
  "@voyantjs/utils": "^0.104.1"
49
49
  },
50
50
  "devDependencies": {
@@ -1,387 +0,0 @@
1
- import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
- type Env = {
3
- Variables: {
4
- db: PostgresJsDatabase;
5
- userId?: string;
6
- };
7
- };
8
- export declare const opportunityRoutes: import("hono/hono-base").HonoBase<Env, {
9
- "/opportunities": {
10
- $get: {
11
- input: {};
12
- output: {
13
- data: {
14
- id: string;
15
- title: string;
16
- personId: string | null;
17
- organizationId: string | null;
18
- pipelineId: string;
19
- stageId: string;
20
- ownerId: string | null;
21
- status: "lost" | "archived" | "open" | "won";
22
- valueAmountCents: number | null;
23
- valueCurrency: string | null;
24
- expectedCloseDate: string | null;
25
- source: string | null;
26
- sourceRef: string | null;
27
- lostReason: string | null;
28
- tags: string[];
29
- createdAt: string;
30
- updatedAt: string;
31
- stageChangedAt: string;
32
- closedAt: string | null;
33
- }[];
34
- total: number;
35
- limit: number;
36
- offset: number;
37
- };
38
- outputFormat: "json";
39
- status: import("hono/utils/http-status").ContentfulStatusCode;
40
- };
41
- };
42
- } & {
43
- "/opportunities": {
44
- $post: {
45
- input: {};
46
- output: {
47
- data: {
48
- id: string;
49
- status: "lost" | "archived" | "open" | "won";
50
- organizationId: string | null;
51
- createdAt: string;
52
- source: string | null;
53
- updatedAt: string;
54
- title: string;
55
- ownerId: string | null;
56
- sourceRef: string | null;
57
- tags: string[];
58
- personId: string | null;
59
- pipelineId: string;
60
- stageId: string;
61
- valueAmountCents: number | null;
62
- valueCurrency: string | null;
63
- expectedCloseDate: string | null;
64
- lostReason: string | null;
65
- stageChangedAt: string;
66
- closedAt: string | null;
67
- } | undefined;
68
- };
69
- outputFormat: "json";
70
- status: 201;
71
- };
72
- };
73
- } & {
74
- "/opportunities/:id": {
75
- $get: {
76
- input: {
77
- param: {
78
- id: string;
79
- };
80
- };
81
- output: {
82
- error: string;
83
- };
84
- outputFormat: "json";
85
- status: 404;
86
- } | {
87
- input: {
88
- param: {
89
- id: string;
90
- };
91
- };
92
- output: {
93
- data: {
94
- id: string;
95
- title: string;
96
- personId: string | null;
97
- organizationId: string | null;
98
- pipelineId: string;
99
- stageId: string;
100
- ownerId: string | null;
101
- status: "lost" | "archived" | "open" | "won";
102
- valueAmountCents: number | null;
103
- valueCurrency: string | null;
104
- expectedCloseDate: string | null;
105
- source: string | null;
106
- sourceRef: string | null;
107
- lostReason: string | null;
108
- tags: string[];
109
- createdAt: string;
110
- updatedAt: string;
111
- stageChangedAt: string;
112
- closedAt: string | null;
113
- };
114
- };
115
- outputFormat: "json";
116
- status: import("hono/utils/http-status").ContentfulStatusCode;
117
- };
118
- };
119
- } & {
120
- "/opportunities/:id": {
121
- $patch: {
122
- input: {
123
- param: {
124
- id: string;
125
- };
126
- };
127
- output: {
128
- error: string;
129
- };
130
- outputFormat: "json";
131
- status: 404;
132
- } | {
133
- input: {
134
- param: {
135
- id: string;
136
- };
137
- };
138
- output: {
139
- data: {
140
- id: string;
141
- title: string;
142
- personId: string | null;
143
- organizationId: string | null;
144
- pipelineId: string;
145
- stageId: string;
146
- ownerId: string | null;
147
- status: "lost" | "archived" | "open" | "won";
148
- valueAmountCents: number | null;
149
- valueCurrency: string | null;
150
- expectedCloseDate: string | null;
151
- source: string | null;
152
- sourceRef: string | null;
153
- lostReason: string | null;
154
- tags: string[];
155
- createdAt: string;
156
- updatedAt: string;
157
- stageChangedAt: string;
158
- closedAt: string | null;
159
- };
160
- };
161
- outputFormat: "json";
162
- status: import("hono/utils/http-status").ContentfulStatusCode;
163
- };
164
- };
165
- } & {
166
- "/opportunities/:id": {
167
- $delete: {
168
- input: {
169
- param: {
170
- id: string;
171
- };
172
- };
173
- output: {
174
- error: string;
175
- };
176
- outputFormat: "json";
177
- status: 404;
178
- } | {
179
- input: {
180
- param: {
181
- id: string;
182
- };
183
- };
184
- output: {
185
- success: true;
186
- };
187
- outputFormat: "json";
188
- status: import("hono/utils/http-status").ContentfulStatusCode;
189
- };
190
- };
191
- } & {
192
- "/opportunities/:id/participants": {
193
- $get: {
194
- input: {
195
- param: {
196
- id: string;
197
- };
198
- };
199
- output: {
200
- data: {
201
- id: string;
202
- opportunityId: string;
203
- personId: string;
204
- role: "other" | "finance" | "traveler" | "booker" | "decision_maker";
205
- isPrimary: boolean;
206
- createdAt: string;
207
- }[];
208
- };
209
- outputFormat: "json";
210
- status: import("hono/utils/http-status").ContentfulStatusCode;
211
- };
212
- };
213
- } & {
214
- "/opportunities/:id/participants": {
215
- $post: {
216
- input: {
217
- param: {
218
- id: string;
219
- };
220
- };
221
- output: {
222
- data: {
223
- id: string;
224
- createdAt: string;
225
- role: "other" | "finance" | "traveler" | "booker" | "decision_maker";
226
- opportunityId: string;
227
- isPrimary: boolean;
228
- personId: string;
229
- } | undefined;
230
- };
231
- outputFormat: "json";
232
- status: 201;
233
- };
234
- };
235
- } & {
236
- "/opportunity-participants/:id": {
237
- $delete: {
238
- input: {
239
- param: {
240
- id: string;
241
- };
242
- };
243
- output: {
244
- error: string;
245
- };
246
- outputFormat: "json";
247
- status: 404;
248
- } | {
249
- input: {
250
- param: {
251
- id: string;
252
- };
253
- };
254
- output: {
255
- success: true;
256
- };
257
- outputFormat: "json";
258
- status: import("hono/utils/http-status").ContentfulStatusCode;
259
- };
260
- };
261
- } & {
262
- "/opportunities/:id/products": {
263
- $get: {
264
- input: {
265
- param: {
266
- id: string;
267
- };
268
- };
269
- output: {
270
- data: {
271
- id: string;
272
- opportunityId: string;
273
- productId: string | null;
274
- supplierServiceId: string | null;
275
- nameSnapshot: string;
276
- description: string | null;
277
- quantity: number;
278
- unitPriceAmountCents: number | null;
279
- costAmountCents: number | null;
280
- currency: string | null;
281
- discountAmountCents: number | null;
282
- createdAt: string;
283
- updatedAt: string;
284
- }[];
285
- };
286
- outputFormat: "json";
287
- status: import("hono/utils/http-status").ContentfulStatusCode;
288
- };
289
- };
290
- } & {
291
- "/opportunities/:id/products": {
292
- $post: {
293
- input: {
294
- param: {
295
- id: string;
296
- };
297
- };
298
- output: {
299
- data: {
300
- id: string;
301
- description: string | null;
302
- createdAt: string;
303
- updatedAt: string;
304
- currency: string | null;
305
- opportunityId: string;
306
- productId: string | null;
307
- supplierServiceId: string | null;
308
- nameSnapshot: string;
309
- quantity: number;
310
- unitPriceAmountCents: number | null;
311
- costAmountCents: number | null;
312
- discountAmountCents: number | null;
313
- } | undefined;
314
- };
315
- outputFormat: "json";
316
- status: 201;
317
- };
318
- };
319
- } & {
320
- "/opportunity-products/:id": {
321
- $patch: {
322
- input: {
323
- param: {
324
- id: string;
325
- };
326
- };
327
- output: {
328
- error: string;
329
- };
330
- outputFormat: "json";
331
- status: 404;
332
- } | {
333
- input: {
334
- param: {
335
- id: string;
336
- };
337
- };
338
- output: {
339
- data: {
340
- id: string;
341
- opportunityId: string;
342
- productId: string | null;
343
- supplierServiceId: string | null;
344
- nameSnapshot: string;
345
- description: string | null;
346
- quantity: number;
347
- unitPriceAmountCents: number | null;
348
- costAmountCents: number | null;
349
- currency: string | null;
350
- discountAmountCents: number | null;
351
- createdAt: string;
352
- updatedAt: string;
353
- };
354
- };
355
- outputFormat: "json";
356
- status: import("hono/utils/http-status").ContentfulStatusCode;
357
- };
358
- };
359
- } & {
360
- "/opportunity-products/:id": {
361
- $delete: {
362
- input: {
363
- param: {
364
- id: string;
365
- };
366
- };
367
- output: {
368
- error: string;
369
- };
370
- outputFormat: "json";
371
- status: 404;
372
- } | {
373
- input: {
374
- param: {
375
- id: string;
376
- };
377
- };
378
- output: {
379
- success: true;
380
- };
381
- outputFormat: "json";
382
- status: import("hono/utils/http-status").ContentfulStatusCode;
383
- };
384
- };
385
- }, "/", "/opportunity-products/:id">;
386
- export {};
387
- //# sourceMappingURL=opportunities.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"opportunities.d.ts","sourceRoot":"","sources":["../../src/routes/opportunities.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAajE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAuF1B,CAAA"}
@@ -1,70 +0,0 @@
1
- import { parseJsonBody, parseQuery } from "@voyantjs/hono";
2
- import { Hono } from "hono";
3
- import { crmService } from "../service/index.js";
4
- import { insertOpportunityParticipantSchema, insertOpportunityProductSchema, insertOpportunitySchema, opportunityListQuerySchema, updateOpportunityProductSchema, updateOpportunitySchema, } from "../validation.js";
5
- export const opportunityRoutes = new Hono()
6
- .get("/opportunities", async (c) => {
7
- const query = await parseQuery(c, opportunityListQuerySchema);
8
- return c.json(await crmService.listOpportunities(c.get("db"), query));
9
- })
10
- .post("/opportunities", async (c) => {
11
- return c.json({
12
- data: await crmService.createOpportunity(c.get("db"), await parseJsonBody(c, insertOpportunitySchema)),
13
- }, 201);
14
- })
15
- .get("/opportunities/:id", async (c) => {
16
- const row = await crmService.getOpportunityById(c.get("db"), c.req.param("id"));
17
- if (!row)
18
- return c.json({ error: "Opportunity not found" }, 404);
19
- return c.json({ data: row });
20
- })
21
- .patch("/opportunities/:id", async (c) => {
22
- const row = await crmService.updateOpportunity(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateOpportunitySchema));
23
- if (!row)
24
- return c.json({ error: "Opportunity not found" }, 404);
25
- return c.json({ data: row });
26
- })
27
- .delete("/opportunities/:id", async (c) => {
28
- const row = await crmService.deleteOpportunity(c.get("db"), c.req.param("id"));
29
- if (!row)
30
- return c.json({ error: "Opportunity not found" }, 404);
31
- return c.json({ success: true });
32
- })
33
- .get("/opportunities/:id/participants", async (c) => {
34
- return c.json({
35
- data: await crmService.listOpportunityParticipants(c.get("db"), c.req.param("id")),
36
- });
37
- })
38
- .post("/opportunities/:id/participants", async (c) => {
39
- return c.json({
40
- data: await crmService.createOpportunityParticipant(c.get("db"), c.req.param("id"), await parseJsonBody(c, insertOpportunityParticipantSchema)),
41
- }, 201);
42
- })
43
- .delete("/opportunity-participants/:id", async (c) => {
44
- const row = await crmService.deleteOpportunityParticipant(c.get("db"), c.req.param("id"));
45
- if (!row)
46
- return c.json({ error: "Opportunity participant not found" }, 404);
47
- return c.json({ success: true });
48
- })
49
- .get("/opportunities/:id/products", async (c) => {
50
- return c.json({
51
- data: await crmService.listOpportunityProducts(c.get("db"), c.req.param("id")),
52
- });
53
- })
54
- .post("/opportunities/:id/products", async (c) => {
55
- return c.json({
56
- data: await crmService.createOpportunityProduct(c.get("db"), c.req.param("id"), await parseJsonBody(c, insertOpportunityProductSchema)),
57
- }, 201);
58
- })
59
- .patch("/opportunity-products/:id", async (c) => {
60
- const row = await crmService.updateOpportunityProduct(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateOpportunityProductSchema));
61
- if (!row)
62
- return c.json({ error: "Opportunity product not found" }, 404);
63
- return c.json({ data: row });
64
- })
65
- .delete("/opportunity-products/:id", async (c) => {
66
- const row = await crmService.deleteOpportunityProduct(c.get("db"), c.req.param("id"));
67
- if (!row)
68
- return c.json({ error: "Opportunity product not found" }, 404);
69
- return c.json({ success: true });
70
- });