@voyantjs/crm 0.6.7 → 0.6.9

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/README.md CHANGED
@@ -22,7 +22,7 @@ const app = createApp({
22
22
 
23
23
  ## Entities
24
24
 
25
- - **People** (`pers`) — canonical person record; syncs inline contact fields (email, phone, address) to `identity` module
25
+ - **People** (`pers`) — canonical person record; syncs inline contact fields (email, phone, website) to `identity` module, while addresses are managed as dedicated identity address resources
26
26
  - **Organizations** (`org`) — canonical company record
27
27
  - **Pipelines** + **Stages** (`pipe`, `stg`) — sales funnels
28
28
  - **Opportunities** (`opp`, `oppp`) — deals attached to people/orgs
@@ -456,9 +456,6 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
456
456
  email: string | null;
457
457
  phone: string | null;
458
458
  website: string | null;
459
- address: string | null;
460
- city: string | null;
461
- country: string | null;
462
459
  }[];
463
460
  total: number;
464
461
  limit: number;
@@ -495,9 +492,6 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
495
492
  email: string | null;
496
493
  phone: string | null;
497
494
  website: string | null;
498
- address: string | null;
499
- city: string | null;
500
- country: string | null;
501
495
  } | null;
502
496
  };
503
497
  outputFormat: "json";
@@ -546,9 +540,6 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
546
540
  email: string | null;
547
541
  phone: string | null;
548
542
  website: string | null;
549
- address: string | null;
550
- city: string | null;
551
- country: string | null;
552
543
  };
553
544
  };
554
545
  outputFormat: "json";
@@ -597,9 +588,6 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
597
588
  email: string | null;
598
589
  phone: string | null;
599
590
  website: string | null;
600
- address: string | null;
601
- city: string | null;
602
- country: string | null;
603
591
  };
604
592
  };
605
593
  outputFormat: "json";
@@ -1 +1 @@
1
- {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/routes/accounts.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBA6RtB,CAAA"}
@@ -456,9 +456,6 @@ export declare const crmRoutes: import("hono/hono-base").HonoBase<Env, import("h
456
456
  email: string | null;
457
457
  phone: string | null;
458
458
  website: string | null;
459
- address: string | null;
460
- city: string | null;
461
- country: string | null;
462
459
  }[];
463
460
  total: number;
464
461
  limit: number;
@@ -495,9 +492,6 @@ export declare const crmRoutes: import("hono/hono-base").HonoBase<Env, import("h
495
492
  email: string | null;
496
493
  phone: string | null;
497
494
  website: string | null;
498
- address: string | null;
499
- city: string | null;
500
- country: string | null;
501
495
  } | null;
502
496
  };
503
497
  outputFormat: "json";
@@ -546,9 +540,6 @@ export declare const crmRoutes: import("hono/hono-base").HonoBase<Env, import("h
546
540
  email: string | null;
547
541
  phone: string | null;
548
542
  website: string | null;
549
- address: string | null;
550
- city: string | null;
551
- country: string | null;
552
543
  };
553
544
  };
554
545
  outputFormat: "json";
@@ -597,9 +588,6 @@ export declare const crmRoutes: import("hono/hono-base").HonoBase<Env, import("h
597
588
  email: string | null;
598
589
  phone: string | null;
599
590
  website: string | null;
600
- address: string | null;
601
- city: string | null;
602
- country: string | null;
603
591
  };
604
592
  };
605
593
  outputFormat: "json";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAUjE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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628,98 @@ export declare const people: import("drizzle-orm/pg-core").PgTableWithColumns<{
628
628
  };
629
629
  dialect: "pg";
630
630
  }>;
631
+ export declare const personDirectoryProjections: import("drizzle-orm/pg-core").PgTableWithColumns<{
632
+ name: "person_directory_projections";
633
+ schema: undefined;
634
+ columns: {
635
+ personId: import("drizzle-orm/pg-core").PgColumn<{
636
+ name: string;
637
+ tableName: "person_directory_projections";
638
+ dataType: "string";
639
+ columnType: "PgText";
640
+ data: string;
641
+ driverParam: string;
642
+ notNull: true;
643
+ hasDefault: false;
644
+ isPrimaryKey: false;
645
+ isAutoincrement: false;
646
+ hasRuntimeDefault: false;
647
+ enumValues: [string, ...string[]];
648
+ baseColumn: never;
649
+ identity: undefined;
650
+ generated: undefined;
651
+ }, {}, {}>;
652
+ email: import("drizzle-orm/pg-core").PgColumn<{
653
+ name: "email";
654
+ tableName: "person_directory_projections";
655
+ dataType: "string";
656
+ columnType: "PgText";
657
+ data: string;
658
+ driverParam: string;
659
+ notNull: false;
660
+ hasDefault: false;
661
+ isPrimaryKey: false;
662
+ isAutoincrement: false;
663
+ hasRuntimeDefault: false;
664
+ enumValues: [string, ...string[]];
665
+ baseColumn: never;
666
+ identity: undefined;
667
+ generated: undefined;
668
+ }, {}, {}>;
669
+ phone: import("drizzle-orm/pg-core").PgColumn<{
670
+ name: "phone";
671
+ tableName: "person_directory_projections";
672
+ dataType: "string";
673
+ columnType: "PgText";
674
+ data: string;
675
+ driverParam: string;
676
+ notNull: false;
677
+ hasDefault: false;
678
+ isPrimaryKey: false;
679
+ isAutoincrement: false;
680
+ hasRuntimeDefault: false;
681
+ enumValues: [string, ...string[]];
682
+ baseColumn: never;
683
+ identity: undefined;
684
+ generated: undefined;
685
+ }, {}, {}>;
686
+ website: import("drizzle-orm/pg-core").PgColumn<{
687
+ name: "website";
688
+ tableName: "person_directory_projections";
689
+ dataType: "string";
690
+ columnType: "PgText";
691
+ data: string;
692
+ driverParam: string;
693
+ notNull: false;
694
+ hasDefault: false;
695
+ isPrimaryKey: false;
696
+ isAutoincrement: false;
697
+ hasRuntimeDefault: false;
698
+ enumValues: [string, ...string[]];
699
+ baseColumn: never;
700
+ identity: undefined;
701
+ generated: undefined;
702
+ }, {}, {}>;
703
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
704
+ name: "updated_at";
705
+ tableName: "person_directory_projections";
706
+ dataType: "date";
707
+ columnType: "PgTimestamp";
708
+ data: Date;
709
+ driverParam: string;
710
+ notNull: true;
711
+ hasDefault: true;
712
+ isPrimaryKey: false;
713
+ isAutoincrement: false;
714
+ hasRuntimeDefault: false;
715
+ enumValues: undefined;
716
+ baseColumn: never;
717
+ identity: undefined;
718
+ generated: undefined;
719
+ }, {}, {}>;
720
+ };
721
+ dialect: "pg";
722
+ }>;
631
723
  export declare const personNotes: import("drizzle-orm/pg-core").PgTableWithColumns<{
632
724
  name: "person_notes";
633
725
  schema: undefined;
@@ -1172,4 +1264,6 @@ export type Organization = typeof organizations.$inferSelect;
1172
1264
  export type NewOrganization = typeof organizations.$inferInsert;
1173
1265
  export type Person = typeof people.$inferSelect;
1174
1266
  export type NewPerson = typeof people.$inferInsert;
1267
+ export type PersonDirectoryProjection = typeof personDirectoryProjections.$inferSelect;
1268
+ export type NewPersonDirectoryProjection = typeof personDirectoryProjections.$inferInsert;
1175
1269
  //# sourceMappingURL=schema-accounts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-accounts.d.ts","sourceRoot":"","sources":["../src/schema-accounts.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AS,GAAG,OAAO,MAAM,CAAC,YAAY,CAAA;AAClD,MAAM,MAAM,yBAAyB,GAAG,OAAO,0BAA0B,CAAC,YAAY,CAAA;AACtF,MAAM,MAAM,4BAA4B,GAAG,OAAO,0BAA0B,CAAC,YAAY,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { typeId, typeIdRef } from "@voyantjs/db/lib/typeid-column";
2
- import { date, index, integer, jsonb, pgTable, text, timestamp } from "drizzle-orm/pg-core";
2
+ import { date, index, integer, jsonb, pgTable, text, timestamp, uniqueIndex, } from "drizzle-orm/pg-core";
3
3
  import { communicationChannelEnum, communicationDirectionEnum, recordStatusEnum, relationTypeEnum, } from "./schema-shared";
4
4
  export const organizations = pgTable("organizations", {
5
5
  id: typeId("organizations"),
@@ -24,6 +24,9 @@ export const organizations = pgTable("organizations", {
24
24
  index("idx_organizations_name").on(table.name),
25
25
  index("idx_organizations_owner").on(table.ownerId),
26
26
  index("idx_organizations_status").on(table.status),
27
+ index("idx_organizations_owner_updated").on(table.ownerId, table.updatedAt),
28
+ index("idx_organizations_relation_updated").on(table.relation, table.updatedAt),
29
+ index("idx_organizations_status_updated").on(table.status, table.updatedAt),
27
30
  ]);
28
31
  export const people = pgTable("people", {
29
32
  id: typeId("people"),
@@ -51,7 +54,20 @@ export const people = pgTable("people", {
51
54
  index("idx_people_owner").on(table.ownerId),
52
55
  index("idx_people_status").on(table.status),
53
56
  index("idx_people_name").on(table.firstName, table.lastName),
57
+ index("idx_people_org_updated").on(table.organizationId, table.updatedAt),
58
+ index("idx_people_owner_updated").on(table.ownerId, table.updatedAt),
59
+ index("idx_people_relation_updated").on(table.relation, table.updatedAt),
60
+ index("idx_people_status_updated").on(table.status, table.updatedAt),
54
61
  ]);
62
+ export const personDirectoryProjections = pgTable("person_directory_projections", {
63
+ personId: typeIdRef("person_id")
64
+ .notNull()
65
+ .references(() => people.id, { onDelete: "cascade" }),
66
+ email: text("email"),
67
+ phone: text("phone"),
68
+ website: text("website"),
69
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
70
+ }, (table) => [uniqueIndex("uq_person_directory_projections_person").on(table.personId)]);
55
71
  export const personNotes = pgTable("person_notes", {
56
72
  id: typeId("person_notes"),
57
73
  personId: typeIdRef("person_id")
@@ -60,7 +76,10 @@ export const personNotes = pgTable("person_notes", {
60
76
  authorId: text("author_id").notNull(),
61
77
  content: text("content").notNull(),
62
78
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
63
- }, (table) => [index("idx_person_notes_person").on(table.personId)]);
79
+ }, (table) => [
80
+ index("idx_person_notes_person").on(table.personId),
81
+ index("idx_person_notes_person_created").on(table.personId, table.createdAt),
82
+ ]);
64
83
  export const organizationNotes = pgTable("organization_notes", {
65
84
  id: typeId("organization_notes"),
66
85
  organizationId: typeIdRef("organization_id")
@@ -69,7 +88,10 @@ export const organizationNotes = pgTable("organization_notes", {
69
88
  authorId: text("author_id").notNull(),
70
89
  content: text("content").notNull(),
71
90
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
72
- }, (table) => [index("idx_organization_notes_org").on(table.organizationId)]);
91
+ }, (table) => [
92
+ index("idx_organization_notes_org").on(table.organizationId),
93
+ index("idx_organization_notes_org_created").on(table.organizationId, table.createdAt),
94
+ ]);
73
95
  export const communicationLog = pgTable("communication_log", {
74
96
  id: typeId("communication_log"),
75
97
  personId: typeIdRef("person_id")
@@ -86,6 +108,9 @@ export const communicationLog = pgTable("communication_log", {
86
108
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
87
109
  }, (table) => [
88
110
  index("idx_communication_log_person").on(table.personId),
111
+ index("idx_communication_log_person_created").on(table.personId, table.createdAt),
112
+ index("idx_communication_log_person_channel_created").on(table.personId, table.channel, table.createdAt),
113
+ index("idx_communication_log_person_direction_created").on(table.personId, table.direction, table.createdAt),
89
114
  index("idx_communication_log_org").on(table.organizationId),
90
115
  index("idx_communication_log_channel").on(table.channel),
91
116
  ]);
@@ -96,7 +121,7 @@ export const segments = pgTable("segments", {
96
121
  conditions: jsonb("conditions").$type(),
97
122
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
98
123
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
99
- });
124
+ }, (table) => [index("idx_segments_created").on(table.createdAt)]);
100
125
  export const segmentMembers = pgTable("segment_members", {
101
126
  id: typeId("segment_members"),
102
127
  segmentId: typeIdRef("segment_id")
@@ -1 +1 @@
1
- {"version":3,"file":"schema-activities.d.ts","sourceRoot":"","sources":["../src/schema-activities.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoBtB,CAAA;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBzB,CAAA;AAED,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBhC,CAAA;AAED,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAUgB,MAAM;uBAAS,MAAM;;;;;;;;;;;;;;uBAArB,MAAM;uBAAS,MAAM;;;;;;;;;;;;;;;;;;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,MAAM,eAAe,GAAG,OAAO,aAAa,CAAC,YAAY,CAAA;AAC/D,MAAM,MAAM,mBAAmB,GAAG,OAAO,oBAAoB,CAAC,YAAY,CAAA;AAC1E,MAAM,MAAM,sBAAsB,GAAG,OAAO,oBAAoB,CAAC,YAAY,CAAA;AAC7E,MAAM,MAAM,qBAAqB,GAAG,OAAO,sBAAsB,CAAC,YAAY,CAAA;AAC9E,MAAM,MAAM,wBAAwB,GAAG,OAAO,sBAAsB,CAAC,YAAY,CAAA;AACjF,MAAM,MAAM,gBAAgB,GAAG,OAAO,iBAAiB,CAAC,YAAY,CAAA;AACpE,MAAM,MAAM,mBAAmB,GAAG,OAAO,iBAAiB,CAAC,YAAY,CAAA"}
@@ -18,6 +18,9 @@ export const activities = pgTable("activities", {
18
18
  index("idx_activities_owner").on(table.ownerId),
19
19
  index("idx_activities_status").on(table.status),
20
20
  index("idx_activities_type").on(table.type),
21
+ index("idx_activities_owner_updated").on(table.ownerId, table.updatedAt),
22
+ index("idx_activities_status_updated").on(table.status, table.updatedAt),
23
+ index("idx_activities_type_updated").on(table.type, table.updatedAt),
21
24
  ]);
22
25
  export const activityLinks = pgTable("activity_links", {
23
26
  id: typeId("activity_links"),
@@ -30,6 +33,7 @@ export const activityLinks = pgTable("activity_links", {
30
33
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
31
34
  }, (table) => [
32
35
  index("idx_activity_links_activity").on(table.activityId),
36
+ index("idx_activity_links_activity_role").on(table.activityId, table.role, table.createdAt),
33
37
  index("idx_activity_links_entity").on(table.entityType, table.entityId),
34
38
  ]);
35
39
  export const activityParticipants = pgTable("activity_participants", {
@@ -44,6 +48,7 @@ export const activityParticipants = pgTable("activity_participants", {
44
48
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
45
49
  }, (table) => [
46
50
  index("idx_activity_participants_activity").on(table.activityId),
51
+ index("idx_activity_participants_activity_primary").on(table.activityId, table.isPrimary, table.createdAt),
47
52
  uniqueIndex("uidx_activity_participants_unique").on(table.activityId, table.personId),
48
53
  ]);
49
54
  export const customFieldDefinitions = pgTable("custom_field_definitions", {
@@ -59,6 +64,7 @@ export const customFieldDefinitions = pgTable("custom_field_definitions", {
59
64
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
60
65
  }, (table) => [
61
66
  index("idx_custom_field_definitions_entity").on(table.entityType),
67
+ index("idx_custom_field_definitions_entity_label").on(table.entityType, table.label),
62
68
  uniqueIndex("uidx_custom_field_definitions_key").on(table.entityType, table.key),
63
69
  ]);
64
70
  export const customFieldValues = pgTable("custom_field_values", {
@@ -79,5 +85,8 @@ export const customFieldValues = pgTable("custom_field_values", {
79
85
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
80
86
  }, (table) => [
81
87
  index("idx_custom_field_values_entity").on(table.entityType, table.entityId),
88
+ index("idx_custom_field_values_entity_type_updated").on(table.entityType, table.updatedAt),
89
+ index("idx_custom_field_values_entity_updated").on(table.entityType, table.entityId, table.updatedAt),
90
+ index("idx_custom_field_values_definition_updated").on(table.definitionId, table.updatedAt),
82
91
  uniqueIndex("uidx_custom_field_values_unique").on(table.definitionId, table.entityType, table.entityId),
83
92
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"schema-sales.d.ts","sourceRoot":"","sources":["../src/schema-sales.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAerB,CAAA;AAED,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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Y,CAAA;AACxE,MAAM,MAAM,qBAAqB,GAAG,OAAO,mBAAmB,CAAC,YAAY,CAAA;AAC3E,MAAM,MAAM,KAAK,GAAG,OAAO,MAAM,CAAC,YAAY,CAAA;AAC9C,MAAM,MAAM,QAAQ,GAAG,OAAO,MAAM,CAAC,YAAY,CAAA;AACjD,MAAM,MAAM,SAAS,GAAG,OAAO,UAAU,CAAC,YAAY,CAAA;AACtD,MAAM,MAAM,YAAY,GAAG,OAAO,UAAU,CAAC,YAAY,CAAA"}
@@ -12,6 +12,8 @@ export const pipelines = pgTable("pipelines", {
12
12
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
13
13
  }, (table) => [
14
14
  index("idx_pipelines_entity").on(table.entityType),
15
+ index("idx_pipelines_sort").on(table.sortOrder, table.createdAt),
16
+ index("idx_pipelines_entity_sort").on(table.entityType, table.sortOrder, table.createdAt),
15
17
  uniqueIndex("uidx_pipelines_entity_name").on(table.entityType, table.name),
16
18
  ]);
17
19
  export const stages = pgTable("stages", {
@@ -29,6 +31,8 @@ export const stages = pgTable("stages", {
29
31
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
30
32
  }, (table) => [
31
33
  index("idx_stages_pipeline").on(table.pipelineId),
34
+ index("idx_stages_sort").on(table.sortOrder, table.createdAt),
35
+ index("idx_stages_pipeline_sort").on(table.pipelineId, table.sortOrder, table.createdAt),
32
36
  uniqueIndex("uidx_stages_pipeline_name").on(table.pipelineId, table.name),
33
37
  ]);
34
38
  export const opportunities = pgTable("opportunities", {
@@ -64,6 +68,12 @@ export const opportunities = pgTable("opportunities", {
64
68
  index("idx_opportunities_stage").on(table.stageId),
65
69
  index("idx_opportunities_owner").on(table.ownerId),
66
70
  index("idx_opportunities_status").on(table.status),
71
+ index("idx_opportunities_person_updated").on(table.personId, table.updatedAt),
72
+ index("idx_opportunities_org_updated").on(table.organizationId, table.updatedAt),
73
+ index("idx_opportunities_pipeline_updated").on(table.pipelineId, table.updatedAt),
74
+ index("idx_opportunities_stage_updated").on(table.stageId, table.updatedAt),
75
+ index("idx_opportunities_owner_updated").on(table.ownerId, table.updatedAt),
76
+ index("idx_opportunities_status_updated").on(table.status, table.updatedAt),
67
77
  ]);
68
78
  export const opportunityParticipants = pgTable("opportunity_participants", {
69
79
  id: typeId("opportunity_participants"),
@@ -78,6 +88,7 @@ export const opportunityParticipants = pgTable("opportunity_participants", {
78
88
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
79
89
  }, (table) => [
80
90
  index("idx_opportunity_participants_opportunity").on(table.opportunityId),
91
+ index("idx_opportunity_participants_opportunity_primary").on(table.opportunityId, table.isPrimary, table.createdAt),
81
92
  index("idx_opportunity_participants_person").on(table.personId),
82
93
  uniqueIndex("uidx_opportunity_participants_unique").on(table.opportunityId, table.personId),
83
94
  ]);
@@ -99,6 +110,7 @@ export const opportunityProducts = pgTable("opportunity_products", {
99
110
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
100
111
  }, (table) => [
101
112
  index("idx_opportunity_products_opportunity").on(table.opportunityId),
113
+ index("idx_opportunity_products_opportunity_created").on(table.opportunityId, table.createdAt),
102
114
  index("idx_opportunity_products_product").on(table.productId),
103
115
  index("idx_opportunity_products_supplier_service").on(table.supplierServiceId),
104
116
  ]);
@@ -120,6 +132,8 @@ export const quotes = pgTable("quotes", {
120
132
  }, (table) => [
121
133
  index("idx_quotes_opportunity").on(table.opportunityId),
122
134
  index("idx_quotes_status").on(table.status),
135
+ index("idx_quotes_opportunity_updated").on(table.opportunityId, table.updatedAt),
136
+ index("idx_quotes_status_updated").on(table.status, table.updatedAt),
123
137
  ]);
124
138
  export const quoteLines = pgTable("quote_lines", {
125
139
  id: typeId("quote_lines"),
@@ -137,6 +151,7 @@ export const quoteLines = pgTable("quote_lines", {
137
151
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
138
152
  }, (table) => [
139
153
  index("idx_quote_lines_quote").on(table.quoteId),
154
+ index("idx_quote_lines_quote_created").on(table.quoteId, table.createdAt),
140
155
  index("idx_quote_lines_product").on(table.productId),
141
156
  index("idx_quote_lines_supplier_service").on(table.supplierServiceId),
142
157
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"accounts-people.d.ts","sourceRoot":"","sources":["../../src/service/accounts-people.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAUjE,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAChC,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAChC,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EAIvB,KAAK,eAAe,EAIpB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAA;AAG7B,eAAO,MAAM,qBAAqB;mBACX,kBAAkB,SAAS,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;sBAsCvC,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;qBAO/B,kBAAkB,QAAQ,iBAAiB;;;;;;;;;;;;;;;;;;;;qBAgB3C,kBAAkB,MAAM,MAAM,QAAQ,iBAAiB;;;;;;;;;;;;;;;;;;;;qBAqBvD,kBAAkB,MAAM,MAAM;;;2BAO/C,kBAAkB,cACV,cAAc,GAAG,QAAQ,YAC3B,MAAM;;;;;;;;;;;;;;4BAUZ,kBAAkB,cACV,cAAc,GAAG,QAAQ,YAC3B,MAAM,QACV,uBAAuB;;;;;;;;;;;;;;4BASD,kBAAkB,MAAM,MAAM,QAAQ,uBAAuB;;;;;;;;;;;;;;4BAI7D,kBAAkB,MAAM,MAAM;;;sBAI1C,kBAAkB,cAAc,cAAc,GAAG,QAAQ,YAAY,MAAM;;;;;;;;;;;;;;;;;;;;;sBASvF,kBAAkB,cACV,cAAc,GAAG,QAAQ,YAC3B,M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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAIX,kBAAkB,QAAQ,kBAAkB;;;;;;;;sBAK5C,kBAAkB,aAAa,MAAM;;;wBAQnC,kBAAkB;wBAiClB,kBAAkB,WAAW,MAAM;;;;;;;iBAuBtC,MAAM;mBAAS,MAAM;;;;CA4B7C,CAAA"}
@@ -65,9 +65,6 @@ export const peopleAccountsService = {
65
65
  email: data.email === undefined ? existing.email : data.email,
66
66
  phone: data.phone === undefined ? existing.phone : data.phone,
67
67
  website: data.website === undefined ? existing.website : data.website,
68
- address: data.address === undefined ? existing.address : data.address,
69
- city: data.city === undefined ? existing.city : data.city,
70
- country: data.country === undefined ? existing.country : data.country,
71
68
  });
72
69
  return this.getPersonById(db, id);
73
70
  },
@@ -241,9 +238,6 @@ export const peopleAccountsService = {
241
238
  "email",
242
239
  "phone",
243
240
  "website",
244
- "address",
245
- "city",
246
- "country",
247
241
  "organizationId",
248
242
  ];
249
243
  const csvLines = [headers.join(",")];
@@ -294,9 +288,6 @@ export const peopleAccountsService = {
294
288
  email: row.email || null,
295
289
  phone: row.phone || null,
296
290
  website: row.website || null,
297
- address: row.address || null,
298
- city: row.city || null,
299
- country: row.country || null,
300
291
  organizationId: row.organizationId || null,
301
292
  tags: [],
302
293
  });
@@ -20,14 +20,11 @@ export type CreateSegmentInput = z.infer<typeof insertSegmentSchema>;
20
20
  export declare const organizationEntityType = "organization";
21
21
  export declare const personEntityType = "person";
22
22
  export declare const personBaseIdentitySource = "crm.person.base";
23
- type PersonIdentityInput = Pick<CreatePersonInput, "email" | "phone" | "website" | "address" | "city" | "country">;
23
+ type PersonIdentityInput = Pick<CreatePersonInput, "email" | "phone" | "website">;
24
24
  export type PersonHydratedFields = {
25
25
  email: string | null;
26
26
  phone: string | null;
27
27
  website: string | null;
28
- address: string | null;
29
- city: string | null;
30
- country: string | null;
31
28
  };
32
29
  export declare function personBaseFields(data: CreatePersonInput | UpdatePersonInput): {
33
30
  organizationId: string | null | undefined;
@@ -45,6 +42,8 @@ export declare function personBaseFields(data: CreatePersonInput | UpdatePersonI
45
42
  birthday: string | null | undefined;
46
43
  notes: string | null | undefined;
47
44
  };
45
+ export declare function rebuildPersonDirectoryProjection(db: PostgresJsDatabase, personId: string): Promise<void>;
46
+ export declare function rebuildPersonDirectoryProjections(db: PostgresJsDatabase, personIds: string[]): Promise<void>;
48
47
  export declare function syncPersonIdentity(db: PostgresJsDatabase, personId: string, data: PersonIdentityInput): Promise<void>;
49
48
  export declare function deletePersonIdentity(db: PostgresJsDatabase, personId: string): Promise<void>;
50
49
  export declare function hydratePeople<T extends {
@@ -1 +1 @@
1
- {"version":3,"file":"accounts-shared.d.ts","sourceRoot":"","sources":["../../src/service/accounts-shared.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,KAAK,EACV,4BAA4B,EAC5B,4BAA4B,EAC5B,4BAA4B,EAC5B,wBAAwB,EACxB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,2BAA2B,EAC3B,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,kBAAkB,CAAA;AAQzB,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAC/E,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAC9E,MAAM,MAAM,uBAAuB,GAAG,CA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"@voyantjs/identity/schema";
1
+ import { identityContactPoints } from "@voyantjs/identity/schema";
2
2
  import { identityService } from "@voyantjs/identity/service";
3
3
  import { and, eq, inArray } from "drizzle-orm";
4
- import { formatAddress, isManagedBySource, normalizeContactValue, toNullableTrimmed, } from "./helpers.js";
4
+ import { personDirectoryProjections } from "../schema.js";
5
+ import { isManagedBySource, normalizeContactValue, toNullableTrimmed } from "./helpers.js";
5
6
  export const organizationEntityType = "organization";
6
7
  export const personEntityType = "person";
7
8
  export const personBaseIdentitySource = "crm.person.base";
9
+ function emptyPersonHydratedFields() {
10
+ return {
11
+ email: null,
12
+ phone: null,
13
+ website: null,
14
+ };
15
+ }
8
16
  export function personBaseFields(data) {
9
17
  return {
10
18
  organizationId: data.organizationId,
@@ -23,6 +31,87 @@ export function personBaseFields(data) {
23
31
  notes: data.notes,
24
32
  };
25
33
  }
34
+ async function buildPersonDirectoryProjectionRows(db, personIds) {
35
+ if (personIds.length === 0) {
36
+ return [];
37
+ }
38
+ const ids = [...new Set(personIds)];
39
+ const contactPoints = await db
40
+ .select()
41
+ .from(identityContactPoints)
42
+ .where(and(eq(identityContactPoints.entityType, personEntityType), inArray(identityContactPoints.entityId, ids)));
43
+ const contactPointMap = new Map();
44
+ for (const point of contactPoints) {
45
+ const bucket = contactPointMap.get(point.entityId) ?? [];
46
+ bucket.push(point);
47
+ contactPointMap.set(point.entityId, bucket);
48
+ }
49
+ return ids.map((personId) => {
50
+ const entityContactPoints = contactPointMap.get(personId) ?? [];
51
+ const findPrimaryContactPoint = (kind) => entityContactPoints.find((point) => point.kind === kind && point.isPrimary)?.value ??
52
+ entityContactPoints.find((point) => point.kind === kind)?.value ??
53
+ null;
54
+ return {
55
+ personId,
56
+ email: findPrimaryContactPoint("email"),
57
+ phone: findPrimaryContactPoint("phone"),
58
+ website: findPrimaryContactPoint("website"),
59
+ };
60
+ });
61
+ }
62
+ export async function rebuildPersonDirectoryProjection(db, personId) {
63
+ return rebuildPersonDirectoryProjections(db, [personId]);
64
+ }
65
+ export async function rebuildPersonDirectoryProjections(db, personIds) {
66
+ const ids = [...new Set(personIds)];
67
+ if (ids.length === 0) {
68
+ return;
69
+ }
70
+ const rows = await buildPersonDirectoryProjectionRows(db, ids);
71
+ await db
72
+ .delete(personDirectoryProjections)
73
+ .where(inArray(personDirectoryProjections.personId, ids));
74
+ await db.insert(personDirectoryProjections).values(rows);
75
+ }
76
+ async function ensurePersonDirectoryProjectionMap(db, personIds) {
77
+ const ids = [...new Set(personIds)];
78
+ if (ids.length === 0) {
79
+ return new Map();
80
+ }
81
+ const existing = await db
82
+ .select()
83
+ .from(personDirectoryProjections)
84
+ .where(inArray(personDirectoryProjections.personId, ids));
85
+ const map = new Map();
86
+ for (const projection of existing) {
87
+ map.set(projection.personId, {
88
+ email: projection.email,
89
+ phone: projection.phone,
90
+ website: projection.website,
91
+ });
92
+ }
93
+ const missingIds = ids.filter((id) => !map.has(id));
94
+ if (missingIds.length > 0) {
95
+ await rebuildPersonDirectoryProjections(db, missingIds);
96
+ const rebuilt = await db
97
+ .select()
98
+ .from(personDirectoryProjections)
99
+ .where(inArray(personDirectoryProjections.personId, missingIds));
100
+ for (const projection of rebuilt) {
101
+ map.set(projection.personId, {
102
+ email: projection.email,
103
+ phone: projection.phone,
104
+ website: projection.website,
105
+ });
106
+ }
107
+ }
108
+ for (const id of ids) {
109
+ if (!map.has(id)) {
110
+ map.set(id, emptyPersonHydratedFields());
111
+ }
112
+ }
113
+ return map;
114
+ }
26
115
  export async function syncPersonIdentity(db, personId, data) {
27
116
  const existingContactPoints = await identityService.listContactPointsForEntity(db, personEntityType, personId);
28
117
  const existingAddresses = await identityService.listAddressesForEntity(db, personEntityType, personId);
@@ -59,33 +148,10 @@ export async function syncPersonIdentity(db, personId, data) {
59
148
  await identityService.createContactPoint(db, payload);
60
149
  }
61
150
  }
62
- const addressLine = toNullableTrimmed(data.address);
63
- const city = toNullableTrimmed(data.city);
64
- const country = toNullableTrimmed(data.country);
65
- const hasAddress = Boolean(addressLine || city || country);
66
- if (!hasAddress) {
67
- if (managedAddress) {
68
- await identityService.deleteAddress(db, managedAddress.id);
69
- }
70
- return;
71
- }
72
- const addressPayload = {
73
- entityType: personEntityType,
74
- entityId: personId,
75
- label: "primary",
76
- fullText: addressLine,
77
- line1: addressLine,
78
- city,
79
- country,
80
- isPrimary: true,
81
- metadata: { managedBy: personBaseIdentitySource },
82
- };
83
151
  if (managedAddress) {
84
- await identityService.updateAddress(db, managedAddress.id, addressPayload);
85
- }
86
- else {
87
- await identityService.createAddress(db, addressPayload);
152
+ await identityService.deleteAddress(db, managedAddress.id);
88
153
  }
154
+ await rebuildPersonDirectoryProjection(db, personId);
89
155
  }
90
156
  export async function deletePersonIdentity(db, personId) {
91
157
  const [contactPoints, addresses] = await Promise.all([
@@ -101,52 +167,15 @@ export async function hydratePeople(db, rows) {
101
167
  if (rows.length === 0) {
102
168
  return rows.map((row) => ({
103
169
  ...row,
104
- email: null,
105
- phone: null,
106
- website: null,
107
- address: null,
108
- city: null,
109
- country: null,
170
+ ...emptyPersonHydratedFields(),
110
171
  }));
111
172
  }
112
173
  const ids = rows.map((row) => row.id);
113
- const [contactPoints, addresses] = await Promise.all([
114
- db
115
- .select()
116
- .from(identityContactPoints)
117
- .where(and(eq(identityContactPoints.entityType, personEntityType), inArray(identityContactPoints.entityId, ids))),
118
- db
119
- .select()
120
- .from(identityAddresses)
121
- .where(and(eq(identityAddresses.entityType, personEntityType), inArray(identityAddresses.entityId, ids))),
122
- ]);
123
- const contactPointMap = new Map();
124
- const addressMap = new Map();
125
- for (const point of contactPoints) {
126
- const bucket = contactPointMap.get(point.entityId) ?? [];
127
- bucket.push(point);
128
- contactPointMap.set(point.entityId, bucket);
129
- }
130
- for (const address of addresses) {
131
- const bucket = addressMap.get(address.entityId) ?? [];
132
- bucket.push(address);
133
- addressMap.set(address.entityId, bucket);
134
- }
174
+ const projectionMap = await ensurePersonDirectoryProjectionMap(db, ids);
135
175
  return rows.map((row) => {
136
- const entityContactPoints = contactPointMap.get(row.id) ?? [];
137
- const entityAddresses = addressMap.get(row.id) ?? [];
138
- const findPrimaryContactPoint = (kind) => entityContactPoints.find((point) => point.kind === kind && point.isPrimary) ??
139
- entityContactPoints.find((point) => point.kind === kind) ??
140
- null;
141
- const primaryAddress = entityAddresses.find((address) => address.isPrimary) ?? entityAddresses[0] ?? null;
142
176
  return {
143
177
  ...row,
144
- email: findPrimaryContactPoint("email")?.value ?? null,
145
- phone: findPrimaryContactPoint("phone")?.value ?? null,
146
- website: findPrimaryContactPoint("website")?.value ?? null,
147
- address: primaryAddress ? formatAddress(primaryAddress) : null,
148
- city: primaryAddress?.city ?? null,
149
- country: primaryAddress?.country ?? null,
178
+ ...(projectionMap.get(row.id) ?? emptyPersonHydratedFields()),
150
179
  };
151
180
  });
152
181
  }
@@ -199,9 +199,6 @@ export declare const personCoreSchema: z.ZodObject<{
199
199
  email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
200
200
  phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
201
201
  website: z.ZodPipe<z.ZodUnion<[z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodLiteral<"">]>, z.ZodTransform<string | null, string | null | undefined>>;
202
- address: z.ZodOptional<z.ZodNullable<z.ZodString>>;
203
- city: z.ZodOptional<z.ZodNullable<z.ZodString>>;
204
- country: z.ZodOptional<z.ZodNullable<z.ZodString>>;
205
202
  }, z.core.$strip>;
206
203
  export declare const insertPersonSchema: z.ZodObject<{
207
204
  organizationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -230,9 +227,6 @@ export declare const insertPersonSchema: z.ZodObject<{
230
227
  email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
231
228
  phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
232
229
  website: z.ZodPipe<z.ZodUnion<[z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodLiteral<"">]>, z.ZodTransform<string | null, string | null | undefined>>;
233
- address: z.ZodOptional<z.ZodNullable<z.ZodString>>;
234
- city: z.ZodOptional<z.ZodNullable<z.ZodString>>;
235
- country: z.ZodOptional<z.ZodNullable<z.ZodString>>;
236
230
  }, z.core.$strip>;
237
231
  export declare const updatePersonSchema: z.ZodObject<{
238
232
  organizationId: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
@@ -261,9 +255,6 @@ export declare const updatePersonSchema: z.ZodObject<{
261
255
  email: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
262
256
  phone: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
263
257
  website: z.ZodOptional<z.ZodPipe<z.ZodUnion<[z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodLiteral<"">]>, z.ZodTransform<string | null, string | null | undefined>>>;
264
- address: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
265
- city: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
266
- country: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
267
258
  }, z.core.$strip>;
268
259
  export declare const personListQuerySchema: z.ZodObject<{
269
260
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAOvB,eAAO,MAAM,gBAAgB;;;;;;EAM3B,CAAA;AAEF,eAAO,MAAM,kBAAkB;;;;EAA6C,CAAA;AAC5E,eAAO,MAAM,kBAAkB;;;;;EAAqD,CAAA;AACpF,eAAO,MAAM,0BAA0B;;;;;;;EAOrC,CAAA;AACF,eAAO,MAAM,4BAA4B;;;EAAkC,CAAA;AAC3E,eAAO,MAAM,uBAAuB;;;;;EAA8C,CAAA;AAClF,eAAO,MAAM,iBAAiB;;;;;;;EAO5B,CAAA;AACF,eAAO,MAAM,kBAAkB;;;;;;;EAAoE,CAAA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IF,eAAO,MAAM,sBAAsB;;iBAEjC,CAAA;AAEF,eAAO,MAAM,sBAAsB;;iBAEjC,CAAA;AAEF,eAAO,MAAM,4BAA4B;;iBAEvC,CAAA;AAEF,eAAO,MAAM,4BAA4B;;iBAEvC,CAAA;AAIF,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;iBAOvC,CAAA;AAEF,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;iBAKvC,CAAA;AAIF,eAAO,MAAM,mBAAmB;;;;iBAI9B,CAAA"}
@@ -108,9 +108,6 @@ export const personCoreSchema = z.object({
108
108
  .optional()
109
109
  .or(z.literal(""))
110
110
  .transform((v) => v || null),
111
- address: z.string().nullable().optional(),
112
- city: z.string().nullable().optional(),
113
- country: z.string().nullable().optional(),
114
111
  });
115
112
  export const insertPersonSchema = personCoreSchema;
116
113
  export const updatePersonSchema = personCoreSchema.partial();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/crm",
3
- "version": "0.6.7",
3
+ "version": "0.6.9",
4
4
  "license": "FSL-1.1-Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -29,10 +29,10 @@
29
29
  "drizzle-orm": "^0.45.2",
30
30
  "hono": "^4.12.10",
31
31
  "zod": "^4.3.6",
32
- "@voyantjs/core": "0.6.7",
33
- "@voyantjs/db": "0.6.7",
34
- "@voyantjs/hono": "0.6.7",
35
- "@voyantjs/identity": "0.6.7"
32
+ "@voyantjs/core": "0.6.9",
33
+ "@voyantjs/db": "0.6.9",
34
+ "@voyantjs/hono": "0.6.9",
35
+ "@voyantjs/identity": "0.6.9"
36
36
  },
37
37
  "devDependencies": {
38
38
  "typescript": "^6.0.2",