@voyantjs/crm 0.4.5 → 0.6.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 (36) hide show
  1. package/dist/booking-extension.d.ts +2 -2
  2. package/dist/booking-extension.d.ts.map +1 -1
  3. package/dist/booking-extension.js +2 -1
  4. package/dist/routes/accounts.d.ts +42 -64
  5. package/dist/routes/accounts.d.ts.map +1 -1
  6. package/dist/routes/accounts.js +22 -25
  7. package/dist/routes/activities.d.ts +6 -6
  8. package/dist/routes/activities.d.ts.map +1 -1
  9. package/dist/routes/activities.js +6 -5
  10. package/dist/routes/custom-fields.d.ts +6 -6
  11. package/dist/routes/custom-fields.d.ts.map +1 -1
  12. package/dist/routes/custom-fields.js +6 -5
  13. package/dist/routes/index.d.ts +73 -95
  14. package/dist/routes/index.d.ts.map +1 -1
  15. package/dist/routes/opportunities.d.ts +10 -10
  16. package/dist/routes/opportunities.d.ts.map +1 -1
  17. package/dist/routes/opportunities.js +7 -6
  18. package/dist/routes/pipelines.d.ts +2 -2
  19. package/dist/routes/pipelines.d.ts.map +1 -1
  20. package/dist/routes/pipelines.js +7 -6
  21. package/dist/routes/quotes.d.ts +7 -7
  22. package/dist/routes/quotes.d.ts.map +1 -1
  23. package/dist/routes/quotes.js +6 -5
  24. package/dist/schema-accounts.d.ts +1 -1
  25. package/dist/schema-activities.d.ts +1 -1
  26. package/dist/service/accounts-organizations.d.ts +4 -4
  27. package/dist/service/accounts-people.d.ts +21 -21
  28. package/dist/service/accounts.d.ts +25 -25
  29. package/dist/service/activities.d.ts +6 -6
  30. package/dist/service/custom-fields.d.ts +6 -6
  31. package/dist/service/index.d.ts +58 -58
  32. package/dist/service/opportunities.d.ts +10 -10
  33. package/dist/service/pipelines.d.ts +2 -2
  34. package/dist/service/quotes.d.ts +7 -7
  35. package/dist/validation.d.ts +11 -11
  36. package/package.json +5 -5
@@ -108,11 +108,11 @@ export declare const bookingCrmExtensionService: {
108
108
  updatedAt: Date;
109
109
  } | null>;
110
110
  upsert(db: PostgresJsDatabase, bookingId: string, data: z.infer<typeof bookingCrmDetailSchema>): Promise<{
111
+ createdAt: Date;
112
+ updatedAt: Date;
111
113
  bookingId: string;
112
114
  opportunityId: string | null;
113
115
  quoteId: string | null;
114
- createdAt: Date;
115
- updatedAt: Date;
116
116
  } | null>;
117
117
  remove(db: PostgresJsDatabase, bookingId: string): Promise<{
118
118
  bookingId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"booking-extension.d.ts","sourceRoot":"","sources":["../src/booking-extension.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAG1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU7B,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,iBAAiB,CAAC,YAAY,CAAA;AACpE,MAAM,MAAM,mBAAmB,GAAG,OAAO,iBAAiB,CAAC,YAAY,CAAA;AAIvE,QAAA,MAAM,sBAAsB;;;iBAG1B,CAAA;AAIF,eAAO,MAAM,0BAA0B;YACvB,kBAAkB,aAAa,MAAM;;;;;;;eAU7C,kBAAkB,aACX,MAAM,QACX,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC;;;;;;;eAqB7B,kBAAkB,aAAa,MAAM;;;CAOvD,CAAA;AA0CD,eAAO,MAAM,mBAAmB,EAAE,aAGjC,CAAA"}
1
+ {"version":3,"file":"booking-extension.d.ts","sourceRoot":"","sources":["../src/booking-extension.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAG1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU7B,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,iBAAiB,CAAC,YAAY,CAAA;AACpE,MAAM,MAAM,mBAAmB,GAAG,OAAO,iBAAiB,CAAC,YAAY,CAAA;AAIvE,QAAA,MAAM,sBAAsB;;;iBAG1B,CAAA;AAIF,eAAO,MAAM,0BAA0B;YACvB,kBAAkB,aAAa,MAAM;;;;;;;eAU7C,kBAAkB,aACX,MAAM,QACX,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC;;;;;;;eAqB7B,kBAAkB,aAAa,MAAM;;;CAOvD,CAAA;AA0CD,eAAO,MAAM,mBAAmB,EAAE,aAGjC,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { parseJsonBody } from "@voyantjs/hono";
1
2
  import { eq } from "drizzle-orm";
2
3
  import { index, pgTable, text, timestamp } from "drizzle-orm/pg-core";
3
4
  import { Hono } from "hono";
@@ -61,7 +62,7 @@ const bookingCrmExtensionRoutes = new Hono()
61
62
  return c.json({ data: row });
62
63
  })
63
64
  .put("/:bookingId/crm-details", async (c) => {
64
- const data = bookingCrmDetailSchema.parse(await c.req.json());
65
+ const data = await parseJsonBody(c, bookingCrmDetailSchema);
65
66
  const row = await bookingCrmExtensionService.upsert(c.get("db"), c.req.param("bookingId"), data);
66
67
  return c.json({ data: row });
67
68
  })
@@ -44,21 +44,21 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
44
44
  input: {};
45
45
  output: {
46
46
  data: {
47
+ source: string | null;
47
48
  relation: "partner" | "supplier" | "other" | "client" | null;
49
+ id: string;
48
50
  name: string;
49
51
  createdAt: string;
50
52
  updatedAt: string;
51
- website: string | null;
53
+ status: "active" | "inactive" | "archived";
52
54
  notes: string | null;
53
- id: string;
55
+ website: string | null;
54
56
  legalName: string | null;
55
57
  industry: string | null;
56
58
  ownerId: string | null;
57
59
  defaultCurrency: string | null;
58
60
  preferredLanguage: string | null;
59
61
  paymentTerms: number | null;
60
- status: "active" | "inactive" | "archived";
61
- source: string | null;
62
62
  sourceRef: string | null;
63
63
  tags: string[];
64
64
  archivedAt: string | null;
@@ -197,7 +197,7 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
197
197
  id: string;
198
198
  entityType: string;
199
199
  entityId: string;
200
- kind: "email" | "phone" | "mobile" | "whatsapp" | "website" | "sms" | "fax" | "social" | "other";
200
+ kind: "email" | "other" | "phone" | "mobile" | "whatsapp" | "website" | "sms" | "fax" | "social";
201
201
  label: string | null;
202
202
  value: string;
203
203
  normalizedValue: string | null;
@@ -225,19 +225,19 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
225
225
  output: {
226
226
  data: {
227
227
  value: string;
228
+ metadata: {
229
+ [x: string]: import("hono/utils/types").JSONValue;
230
+ } | null;
231
+ id: string;
228
232
  createdAt: string;
229
233
  updatedAt: string;
230
- kind: "email" | "phone" | "mobile" | "whatsapp" | "website" | "sms" | "fax" | "social" | "other";
234
+ notes: string | null;
235
+ kind: "email" | "other" | "phone" | "mobile" | "whatsapp" | "website" | "sms" | "fax" | "social";
231
236
  entityType: string;
232
237
  entityId: string;
233
238
  label: string | null;
234
239
  normalizedValue: string | null;
235
240
  isPrimary: boolean;
236
- notes: string | null;
237
- metadata: {
238
- [x: string]: import("hono/utils/types").JSONValue;
239
- } | null;
240
- id: string;
241
241
  } | null;
242
242
  };
243
243
  outputFormat: "json";
@@ -257,7 +257,7 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
257
257
  id: string;
258
258
  entityType: string;
259
259
  entityId: string;
260
- label: "primary" | "other" | "billing" | "shipping" | "mailing" | "meeting" | "service" | "legal";
260
+ label: "service" | "primary" | "other" | "billing" | "shipping" | "mailing" | "meeting" | "legal";
261
261
  fullText: string | null;
262
262
  line1: string | null;
263
263
  line2: string | null;
@@ -291,16 +291,18 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
291
291
  };
292
292
  output: {
293
293
  data: {
294
+ metadata: {
295
+ [x: string]: import("hono/utils/types").JSONValue;
296
+ } | null;
297
+ id: string;
294
298
  createdAt: string;
295
299
  updatedAt: string;
300
+ notes: string | null;
301
+ timezone: string | null;
296
302
  entityType: string;
297
303
  entityId: string;
298
- label: "primary" | "other" | "billing" | "shipping" | "mailing" | "meeting" | "service" | "legal";
304
+ label: "service" | "primary" | "other" | "billing" | "shipping" | "mailing" | "meeting" | "legal";
299
305
  isPrimary: boolean;
300
- notes: string | null;
301
- metadata: {
302
- [x: string]: import("hono/utils/types").JSONValue;
303
- } | null;
304
306
  fullText: string | null;
305
307
  line1: string | null;
306
308
  line2: string | null;
@@ -310,8 +312,6 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
310
312
  country: string | null;
311
313
  latitude: number | null;
312
314
  longitude: number | null;
313
- timezone: string | null;
314
- id: string;
315
315
  } | null;
316
316
  };
317
317
  outputFormat: "json";
@@ -342,17 +342,6 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
342
342
  } & {
343
343
  "/organizations/:id/notes": {
344
344
  $post: {
345
- input: {
346
- param: {
347
- id: string;
348
- };
349
- };
350
- output: {
351
- error: string;
352
- };
353
- outputFormat: "json";
354
- status: 400;
355
- } | {
356
345
  input: {
357
346
  param: {
358
347
  id: string;
@@ -371,8 +360,8 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
371
360
  };
372
361
  output: {
373
362
  data: {
374
- createdAt: string;
375
363
  id: string;
364
+ createdAt: string;
376
365
  organizationId: string;
377
366
  authorId: string;
378
367
  content: string;
@@ -656,7 +645,7 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
656
645
  id: string;
657
646
  entityType: string;
658
647
  entityId: string;
659
- kind: "email" | "phone" | "mobile" | "whatsapp" | "website" | "sms" | "fax" | "social" | "other";
648
+ kind: "email" | "other" | "phone" | "mobile" | "whatsapp" | "website" | "sms" | "fax" | "social";
660
649
  label: string | null;
661
650
  value: string;
662
651
  normalizedValue: string | null;
@@ -684,19 +673,19 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
684
673
  output: {
685
674
  data: {
686
675
  value: string;
676
+ metadata: {
677
+ [x: string]: import("hono/utils/types").JSONValue;
678
+ } | null;
679
+ id: string;
687
680
  createdAt: string;
688
681
  updatedAt: string;
689
- kind: "email" | "phone" | "mobile" | "whatsapp" | "website" | "sms" | "fax" | "social" | "other";
682
+ notes: string | null;
683
+ kind: "email" | "other" | "phone" | "mobile" | "whatsapp" | "website" | "sms" | "fax" | "social";
690
684
  entityType: string;
691
685
  entityId: string;
692
686
  label: string | null;
693
687
  normalizedValue: string | null;
694
688
  isPrimary: boolean;
695
- notes: string | null;
696
- metadata: {
697
- [x: string]: import("hono/utils/types").JSONValue;
698
- } | null;
699
- id: string;
700
689
  } | null;
701
690
  };
702
691
  outputFormat: "json";
@@ -716,7 +705,7 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
716
705
  id: string;
717
706
  entityType: string;
718
707
  entityId: string;
719
- label: "primary" | "other" | "billing" | "shipping" | "mailing" | "meeting" | "service" | "legal";
708
+ label: "service" | "primary" | "other" | "billing" | "shipping" | "mailing" | "meeting" | "legal";
720
709
  fullText: string | null;
721
710
  line1: string | null;
722
711
  line2: string | null;
@@ -750,16 +739,18 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
750
739
  };
751
740
  output: {
752
741
  data: {
742
+ metadata: {
743
+ [x: string]: import("hono/utils/types").JSONValue;
744
+ } | null;
745
+ id: string;
753
746
  createdAt: string;
754
747
  updatedAt: string;
748
+ notes: string | null;
749
+ timezone: string | null;
755
750
  entityType: string;
756
751
  entityId: string;
757
- label: "primary" | "other" | "billing" | "shipping" | "mailing" | "meeting" | "service" | "legal";
752
+ label: "service" | "primary" | "other" | "billing" | "shipping" | "mailing" | "meeting" | "legal";
758
753
  isPrimary: boolean;
759
- notes: string | null;
760
- metadata: {
761
- [x: string]: import("hono/utils/types").JSONValue;
762
- } | null;
763
754
  fullText: string | null;
764
755
  line1: string | null;
765
756
  line2: string | null;
@@ -769,8 +760,6 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
769
760
  country: string | null;
770
761
  latitude: number | null;
771
762
  longitude: number | null;
772
- timezone: string | null;
773
- id: string;
774
763
  } | null;
775
764
  };
776
765
  outputFormat: "json";
@@ -801,17 +790,6 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
801
790
  } & {
802
791
  "/people/:id/notes": {
803
792
  $post: {
804
- input: {
805
- param: {
806
- id: string;
807
- };
808
- };
809
- output: {
810
- error: string;
811
- };
812
- outputFormat: "json";
813
- status: 400;
814
- } | {
815
793
  input: {
816
794
  param: {
817
795
  id: string;
@@ -830,8 +808,8 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
830
808
  };
831
809
  output: {
832
810
  data: {
833
- createdAt: string;
834
811
  id: string;
812
+ createdAt: string;
835
813
  personId: string;
836
814
  authorId: string;
837
815
  content: string;
@@ -912,7 +890,7 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
912
890
  id: string;
913
891
  personId: string;
914
892
  organizationId: string | null;
915
- channel: "email" | "phone" | "whatsapp" | "sms" | "other" | "meeting";
893
+ channel: "email" | "other" | "phone" | "whatsapp" | "sms" | "meeting";
916
894
  direction: "inbound" | "outbound";
917
895
  subject: string | null;
918
896
  content: string | null;
@@ -945,12 +923,12 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
945
923
  };
946
924
  output: {
947
925
  data: {
948
- createdAt: string;
949
926
  id: string;
927
+ createdAt: string;
950
928
  organizationId: string | null;
951
929
  personId: string;
952
930
  content: string | null;
953
- channel: "email" | "phone" | "whatsapp" | "sms" | "other" | "meeting";
931
+ channel: "email" | "other" | "phone" | "whatsapp" | "sms" | "meeting";
954
932
  direction: "inbound" | "outbound";
955
933
  subject: string | null;
956
934
  sentAt: string | null;
@@ -986,11 +964,11 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
986
964
  input: {};
987
965
  output: {
988
966
  data: {
967
+ id: string;
989
968
  name: string;
990
969
  createdAt: string;
991
970
  updatedAt: string;
992
971
  description: string | null;
993
- id: string;
994
972
  conditions: {
995
973
  [x: string]: import("hono/utils/types").JSONValue;
996
974
  } | null;
@@ -1081,7 +1059,7 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
1081
1059
  id: string;
1082
1060
  entityType: string;
1083
1061
  entityId: string;
1084
- kind: "email" | "phone" | "mobile" | "whatsapp" | "website" | "sms" | "fax" | "social" | "other";
1062
+ kind: "email" | "other" | "phone" | "mobile" | "whatsapp" | "website" | "sms" | "fax" | "social";
1085
1063
  label: string | null;
1086
1064
  value: string;
1087
1065
  normalizedValue: string | null;
@@ -1148,7 +1126,7 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
1148
1126
  id: string;
1149
1127
  entityType: string;
1150
1128
  entityId: string;
1151
- label: "primary" | "other" | "billing" | "shipping" | "mailing" | "meeting" | "service" | "legal";
1129
+ label: "service" | "primary" | "other" | "billing" | "shipping" | "mailing" | "meeting" | "legal";
1152
1130
  fullText: string | null;
1153
1131
  line1: string | null;
1154
1132
  line2: string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/routes/accounts.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAoBjE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBA6RtB,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { parseJsonBody, parseQuery, requireUserId } from "@voyantjs/hono";
1
2
  import { insertAddressSchema, insertContactPointSchema, updateAddressSchema, updateContactPointSchema, } from "@voyantjs/identity/validation";
2
3
  import { Hono } from "hono";
3
4
  import { crmService } from "../service/index.js";
@@ -7,12 +8,12 @@ const personEntity = "person";
7
8
  export const accountRoutes = new Hono()
8
9
  // Organizations
9
10
  .get("/organizations", async (c) => {
10
- const query = organizationListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
11
+ const query = parseQuery(c, organizationListQuerySchema);
11
12
  return c.json(await crmService.listOrganizations(c.get("db"), query));
12
13
  })
13
14
  .post("/organizations", async (c) => {
14
15
  return c.json({
15
- data: await crmService.createOrganization(c.get("db"), insertOrganizationSchema.parse(await c.req.json())),
16
+ data: await crmService.createOrganization(c.get("db"), await parseJsonBody(c, insertOrganizationSchema)),
16
17
  }, 201);
17
18
  })
18
19
  .get("/organizations/:id", async (c) => {
@@ -22,7 +23,7 @@ export const accountRoutes = new Hono()
22
23
  return c.json({ data: row });
23
24
  })
24
25
  .patch("/organizations/:id", async (c) => {
25
- const row = await crmService.updateOrganization(c.get("db"), c.req.param("id"), updateOrganizationSchema.parse(await c.req.json()));
26
+ const row = await crmService.updateOrganization(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateOrganizationSchema));
26
27
  if (!row)
27
28
  return c.json({ error: "Organization not found" }, 404);
28
29
  return c.json({ data: row });
@@ -40,7 +41,7 @@ export const accountRoutes = new Hono()
40
41
  })
41
42
  .post("/organizations/:id/contact-methods", async (c) => {
42
43
  return c.json({
43
- data: await crmService.createContactMethod(c.get("db"), organizationEntity, c.req.param("id"), insertContactPointSchema.parse(await c.req.json())),
44
+ data: await crmService.createContactMethod(c.get("db"), organizationEntity, c.req.param("id"), await parseJsonBody(c, insertContactPointSchema)),
44
45
  }, 201);
45
46
  })
46
47
  .get("/organizations/:id/addresses", async (c) => {
@@ -50,7 +51,7 @@ export const accountRoutes = new Hono()
50
51
  })
51
52
  .post("/organizations/:id/addresses", async (c) => {
52
53
  return c.json({
53
- data: await crmService.createAddress(c.get("db"), organizationEntity, c.req.param("id"), insertAddressSchema.parse(await c.req.json())),
54
+ data: await crmService.createAddress(c.get("db"), organizationEntity, c.req.param("id"), await parseJsonBody(c, insertAddressSchema)),
54
55
  }, 201);
55
56
  })
56
57
  .get("/organizations/:id/notes", async (c) => {
@@ -59,16 +60,14 @@ export const accountRoutes = new Hono()
59
60
  });
60
61
  })
61
62
  .post("/organizations/:id/notes", async (c) => {
62
- const userId = c.get("userId");
63
- if (!userId)
64
- return c.json({ error: "User ID required to create notes" }, 400);
65
- const row = await crmService.createOrganizationNote(c.get("db"), c.req.param("id"), userId, insertOrganizationNoteSchema.parse(await c.req.json()));
63
+ const userId = requireUserId(c);
64
+ const row = await crmService.createOrganizationNote(c.get("db"), c.req.param("id"), userId, await parseJsonBody(c, insertOrganizationNoteSchema));
66
65
  if (!row)
67
66
  return c.json({ error: "Organization not found" }, 404);
68
67
  return c.json({ data: row }, 201);
69
68
  })
70
69
  .patch("/organization-notes/:id", async (c) => {
71
- const body = updateOrganizationNoteSchema.parse(await c.req.json());
70
+ const body = await parseJsonBody(c, updateOrganizationNoteSchema);
72
71
  const row = await crmService.updateOrganizationNote(c.get("db"), c.req.param("id"), body.content);
73
72
  if (!row)
74
73
  return c.json({ error: "Note not found" }, 404);
@@ -82,12 +81,12 @@ export const accountRoutes = new Hono()
82
81
  })
83
82
  // People
84
83
  .get("/people", async (c) => {
85
- const query = personListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
84
+ const query = parseQuery(c, personListQuerySchema);
86
85
  return c.json(await crmService.listPeople(c.get("db"), query));
87
86
  })
88
87
  .post("/people", async (c) => {
89
88
  return c.json({
90
- data: await crmService.createPerson(c.get("db"), insertPersonSchema.parse(await c.req.json())),
89
+ data: await crmService.createPerson(c.get("db"), await parseJsonBody(c, insertPersonSchema)),
91
90
  }, 201);
92
91
  })
93
92
  .get("/people/:id", async (c) => {
@@ -97,7 +96,7 @@ export const accountRoutes = new Hono()
97
96
  return c.json({ data: row });
98
97
  })
99
98
  .patch("/people/:id", async (c) => {
100
- const row = await crmService.updatePerson(c.get("db"), c.req.param("id"), updatePersonSchema.parse(await c.req.json()));
99
+ const row = await crmService.updatePerson(c.get("db"), c.req.param("id"), await parseJsonBody(c, updatePersonSchema));
101
100
  if (!row)
102
101
  return c.json({ error: "Person not found" }, 404);
103
102
  return c.json({ data: row });
@@ -115,7 +114,7 @@ export const accountRoutes = new Hono()
115
114
  })
116
115
  .post("/people/:id/contact-methods", async (c) => {
117
116
  return c.json({
118
- data: await crmService.createContactMethod(c.get("db"), personEntity, c.req.param("id"), insertContactPointSchema.parse(await c.req.json())),
117
+ data: await crmService.createContactMethod(c.get("db"), personEntity, c.req.param("id"), await parseJsonBody(c, insertContactPointSchema)),
119
118
  }, 201);
120
119
  })
121
120
  .get("/people/:id/addresses", async (c) => {
@@ -125,7 +124,7 @@ export const accountRoutes = new Hono()
125
124
  })
126
125
  .post("/people/:id/addresses", async (c) => {
127
126
  return c.json({
128
- data: await crmService.createAddress(c.get("db"), personEntity, c.req.param("id"), insertAddressSchema.parse(await c.req.json())),
127
+ data: await crmService.createAddress(c.get("db"), personEntity, c.req.param("id"), await parseJsonBody(c, insertAddressSchema)),
129
128
  }, 201);
130
129
  })
131
130
  .get("/people/:id/notes", async (c) => {
@@ -134,16 +133,14 @@ export const accountRoutes = new Hono()
134
133
  });
135
134
  })
136
135
  .post("/people/:id/notes", async (c) => {
137
- const userId = c.get("userId");
138
- if (!userId)
139
- return c.json({ error: "User ID required to create notes" }, 400);
140
- const row = await crmService.createPersonNote(c.get("db"), c.req.param("id"), userId, insertPersonNoteSchema.parse(await c.req.json()));
136
+ const userId = requireUserId(c);
137
+ const row = await crmService.createPersonNote(c.get("db"), c.req.param("id"), userId, await parseJsonBody(c, insertPersonNoteSchema));
141
138
  if (!row)
142
139
  return c.json({ error: "Person not found" }, 404);
143
140
  return c.json({ data: row }, 201);
144
141
  })
145
142
  .patch("/person-notes/:id", async (c) => {
146
- const body = updatePersonNoteSchema.parse(await c.req.json());
143
+ const body = await parseJsonBody(c, updatePersonNoteSchema);
147
144
  const row = await crmService.updatePersonNote(c.get("db"), c.req.param("id"), body.content);
148
145
  if (!row)
149
146
  return c.json({ error: "Note not found" }, 404);
@@ -156,13 +153,13 @@ export const accountRoutes = new Hono()
156
153
  return c.json({ success: true });
157
154
  })
158
155
  .get("/people/:id/communications", async (c) => {
159
- const query = communicationListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
156
+ const query = parseQuery(c, communicationListQuerySchema);
160
157
  return c.json({
161
158
  data: await crmService.listCommunications(c.get("db"), c.req.param("id"), query),
162
159
  });
163
160
  })
164
161
  .post("/people/:id/communications", async (c) => {
165
- const row = await crmService.createCommunication(c.get("db"), c.req.param("id"), insertCommunicationLogSchema.parse(await c.req.json()));
162
+ const row = await crmService.createCommunication(c.get("db"), c.req.param("id"), await parseJsonBody(c, insertCommunicationLogSchema));
166
163
  if (!row)
167
164
  return c.json({ error: "Person not found" }, 404);
168
165
  return c.json({ data: row }, 201);
@@ -173,7 +170,7 @@ export const accountRoutes = new Hono()
173
170
  })
174
171
  .post("/segments", async (c) => {
175
172
  return c.json({
176
- data: await crmService.createSegment(c.get("db"), insertSegmentSchema.parse(await c.req.json())),
173
+ data: await crmService.createSegment(c.get("db"), await parseJsonBody(c, insertSegmentSchema)),
177
174
  }, 201);
178
175
  })
179
176
  .delete("/segments/:segmentId", async (c) => {
@@ -201,7 +198,7 @@ export const accountRoutes = new Hono()
201
198
  })
202
199
  // Shared contact method and address resources
203
200
  .patch("/contact-methods/:id", async (c) => {
204
- const row = await crmService.updateContactMethod(c.get("db"), c.req.param("id"), updateContactPointSchema.parse(await c.req.json()));
201
+ const row = await crmService.updateContactMethod(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateContactPointSchema));
205
202
  if (!row)
206
203
  return c.json({ error: "Contact method not found" }, 404);
207
204
  return c.json({ data: row });
@@ -213,7 +210,7 @@ export const accountRoutes = new Hono()
213
210
  return c.json({ success: true });
214
211
  })
215
212
  .patch("/addresses/:id", async (c) => {
216
- const row = await crmService.updateAddress(c.get("db"), c.req.param("id"), updateAddressSchema.parse(await c.req.json()));
213
+ const row = await crmService.updateAddress(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateAddressSchema));
217
214
  if (!row)
218
215
  return c.json({ error: "Address not found" }, 404);
219
216
  return c.json({ data: row });
@@ -37,13 +37,13 @@ export declare const activityRoutes: import("hono/hono-base").HonoBase<Env, {
37
37
  input: {};
38
38
  output: {
39
39
  data: {
40
+ id: string;
40
41
  createdAt: string;
41
42
  updatedAt: string;
42
- description: string | null;
43
+ status: "done" | "planned" | "cancelled";
43
44
  type: "email" | "meeting" | "call" | "task" | "follow_up" | "note";
44
- id: string;
45
+ description: string | null;
45
46
  ownerId: string | null;
46
- status: "done" | "planned" | "cancelled";
47
47
  subject: string;
48
48
  dueAt: string | null;
49
49
  completedAt: string | null;
@@ -188,11 +188,11 @@ export declare const activityRoutes: import("hono/hono-base").HonoBase<Env, {
188
188
  };
189
189
  output: {
190
190
  data: {
191
+ id: string;
191
192
  createdAt: string;
193
+ role: "primary" | "related";
192
194
  entityType: "organization" | "person" | "opportunity" | "quote" | "activity";
193
195
  entityId: string;
194
- role: "primary" | "related";
195
- id: string;
196
196
  activityId: string;
197
197
  } | undefined;
198
198
  };
@@ -257,9 +257,9 @@ export declare const activityRoutes: import("hono/hono-base").HonoBase<Env, {
257
257
  };
258
258
  output: {
259
259
  data: {
260
+ id: string;
260
261
  createdAt: string;
261
262
  isPrimary: boolean;
262
- id: string;
263
263
  personId: string;
264
264
  activityId: string;
265
265
  } | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"activities.d.ts","sourceRoot":"","sources":["../../src/routes/activities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAYjE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCA4EvB,CAAA"}
1
+ {"version":3,"file":"activities.d.ts","sourceRoot":"","sources":["../../src/routes/activities.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAYjE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCA4EvB,CAAA"}
@@ -1,14 +1,15 @@
1
+ import { parseJsonBody, parseQuery } from "@voyantjs/hono";
1
2
  import { Hono } from "hono";
2
3
  import { crmService } from "../service/index.js";
3
4
  import { activityListQuerySchema, insertActivityLinkSchema, insertActivityParticipantSchema, insertActivitySchema, updateActivitySchema, } from "../validation.js";
4
5
  export const activityRoutes = new Hono()
5
6
  .get("/activities", async (c) => {
6
- const query = activityListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
7
+ const query = await parseQuery(c, activityListQuerySchema);
7
8
  return c.json(await crmService.listActivities(c.get("db"), query));
8
9
  })
9
10
  .post("/activities", async (c) => {
10
11
  return c.json({
11
- data: await crmService.createActivity(c.get("db"), insertActivitySchema.parse(await c.req.json())),
12
+ data: await crmService.createActivity(c.get("db"), await parseJsonBody(c, insertActivitySchema)),
12
13
  }, 201);
13
14
  })
14
15
  .get("/activities/:id", async (c) => {
@@ -18,7 +19,7 @@ export const activityRoutes = new Hono()
18
19
  return c.json({ data: row });
19
20
  })
20
21
  .patch("/activities/:id", async (c) => {
21
- const row = await crmService.updateActivity(c.get("db"), c.req.param("id"), updateActivitySchema.parse(await c.req.json()));
22
+ const row = await crmService.updateActivity(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateActivitySchema));
22
23
  if (!row)
23
24
  return c.json({ error: "Activity not found" }, 404);
24
25
  return c.json({ data: row });
@@ -34,7 +35,7 @@ export const activityRoutes = new Hono()
34
35
  })
35
36
  .post("/activities/:id/links", async (c) => {
36
37
  return c.json({
37
- data: await crmService.createActivityLink(c.get("db"), c.req.param("id"), insertActivityLinkSchema.parse(await c.req.json())),
38
+ data: await crmService.createActivityLink(c.get("db"), c.req.param("id"), await parseJsonBody(c, insertActivityLinkSchema)),
38
39
  }, 201);
39
40
  })
40
41
  .delete("/activity-links/:id", async (c) => {
@@ -50,7 +51,7 @@ export const activityRoutes = new Hono()
50
51
  })
51
52
  .post("/activities/:id/participants", async (c) => {
52
53
  return c.json({
53
- data: await crmService.createActivityParticipant(c.get("db"), c.req.param("id"), insertActivityParticipantSchema.parse(await c.req.json())),
54
+ data: await crmService.createActivityParticipant(c.get("db"), c.req.param("id"), await parseJsonBody(c, insertActivityParticipantSchema)),
54
55
  }, 201);
55
56
  })
56
57
  .delete("/activity-participants/:id", async (c) => {