@voyantjs/crm 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/routes/accounts.d.ts +1 -1
  2. package/dist/routes/index.d.ts +2 -2
  3. package/dist/routes/opportunities.d.ts +1 -1
  4. package/dist/schema-accounts.d.ts +1175 -0
  5. package/dist/schema-accounts.d.ts.map +1 -0
  6. package/dist/schema-accounts.js +112 -0
  7. package/dist/schema-activities.d.ts +821 -0
  8. package/dist/schema-activities.d.ts.map +1 -0
  9. package/dist/schema-activities.js +83 -0
  10. package/dist/schema-relations.d.ts +81 -0
  11. package/dist/schema-relations.d.ts.map +1 -0
  12. package/dist/schema-relations.js +123 -0
  13. package/dist/schema-sales.d.ts +1392 -0
  14. package/dist/schema-sales.d.ts.map +1 -0
  15. package/dist/schema-sales.js +142 -0
  16. package/dist/schema-shared.d.ts +13 -0
  17. package/dist/schema-shared.d.ts.map +1 -0
  18. package/dist/schema-shared.js +63 -0
  19. package/dist/schema.d.ts +5 -3477
  20. package/dist/schema.d.ts.map +1 -1
  21. package/dist/schema.js +5 -515
  22. package/dist/service/accounts-organizations.d.ts +93 -0
  23. package/dist/service/accounts-organizations.d.ts.map +1 -0
  24. package/dist/service/accounts-organizations.js +49 -0
  25. package/dist/service/accounts-people.d.ts +868 -0
  26. package/dist/service/accounts-people.d.ts.map +1 -0
  27. package/dist/service/accounts-people.js +311 -0
  28. package/dist/service/accounts-shared.d.ts +54 -0
  29. package/dist/service/accounts-shared.d.ts.map +1 -0
  30. package/dist/service/accounts-shared.js +152 -0
  31. package/dist/service/accounts.d.ts +121 -149
  32. package/dist/service/accounts.d.ts.map +1 -1
  33. package/dist/service/accounts.js +4 -507
  34. package/dist/service/index.d.ts +106 -297
  35. package/dist/service/index.d.ts.map +1 -1
  36. package/dist/service/opportunities.d.ts +1 -1
  37. package/package.json +5 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":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F,MAAM,MAAM,kBAAkB,GAAG,OAAO,mBAAmB,CAAC,YAAY,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"}
@@ -0,0 +1,142 @@
1
+ import { typeId, typeIdRef } from "@voyantjs/db/lib/typeid-column";
2
+ import { boolean, date, index, integer, jsonb, pgTable, text, timestamp, uniqueIndex, } from "drizzle-orm/pg-core";
3
+ import { organizations, people } from "./schema-accounts";
4
+ import { entityTypeEnum, opportunityStatusEnum, participantRoleEnum, quoteStatusEnum, } from "./schema-shared";
5
+ export const pipelines = pgTable("pipelines", {
6
+ id: typeId("pipelines"),
7
+ entityType: entityTypeEnum("entity_type").notNull().default("opportunity"),
8
+ name: text("name").notNull(),
9
+ isDefault: boolean("is_default").notNull().default(false),
10
+ sortOrder: integer("sort_order").notNull().default(0),
11
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
12
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
13
+ }, (table) => [
14
+ index("idx_pipelines_entity").on(table.entityType),
15
+ uniqueIndex("uidx_pipelines_entity_name").on(table.entityType, table.name),
16
+ ]);
17
+ export const stages = pgTable("stages", {
18
+ id: typeId("stages"),
19
+ pipelineId: typeIdRef("pipeline_id")
20
+ .notNull()
21
+ .references(() => pipelines.id, { onDelete: "cascade" }),
22
+ name: text("name").notNull(),
23
+ sortOrder: integer("sort_order").notNull().default(0),
24
+ probability: integer("probability"),
25
+ isClosed: boolean("is_closed").notNull().default(false),
26
+ isWon: boolean("is_won").notNull().default(false),
27
+ isLost: boolean("is_lost").notNull().default(false),
28
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
29
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
30
+ }, (table) => [
31
+ index("idx_stages_pipeline").on(table.pipelineId),
32
+ uniqueIndex("uidx_stages_pipeline_name").on(table.pipelineId, table.name),
33
+ ]);
34
+ export const opportunities = pgTable("opportunities", {
35
+ id: typeId("opportunities"),
36
+ title: text("title").notNull(),
37
+ personId: typeIdRef("person_id").references(() => people.id, { onDelete: "set null" }),
38
+ organizationId: typeIdRef("organization_id").references(() => organizations.id, {
39
+ onDelete: "set null",
40
+ }),
41
+ pipelineId: typeIdRef("pipeline_id")
42
+ .notNull()
43
+ .references(() => pipelines.id, { onDelete: "restrict" }),
44
+ stageId: typeIdRef("stage_id")
45
+ .notNull()
46
+ .references(() => stages.id, { onDelete: "restrict" }),
47
+ ownerId: text("owner_id"),
48
+ status: opportunityStatusEnum("status").notNull().default("open"),
49
+ valueAmountCents: integer("value_amount_cents"),
50
+ valueCurrency: text("value_currency"),
51
+ expectedCloseDate: date("expected_close_date"),
52
+ source: text("source"),
53
+ sourceRef: text("source_ref"),
54
+ lostReason: text("lost_reason"),
55
+ tags: jsonb("tags").$type().notNull().default([]),
56
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
57
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
58
+ stageChangedAt: timestamp("stage_changed_at", { withTimezone: true }).notNull().defaultNow(),
59
+ closedAt: timestamp("closed_at", { withTimezone: true }),
60
+ }, (table) => [
61
+ index("idx_opportunities_person").on(table.personId),
62
+ index("idx_opportunities_org").on(table.organizationId),
63
+ index("idx_opportunities_pipeline").on(table.pipelineId),
64
+ index("idx_opportunities_stage").on(table.stageId),
65
+ index("idx_opportunities_owner").on(table.ownerId),
66
+ index("idx_opportunities_status").on(table.status),
67
+ ]);
68
+ export const opportunityParticipants = pgTable("opportunity_participants", {
69
+ id: typeId("opportunity_participants"),
70
+ opportunityId: typeIdRef("opportunity_id")
71
+ .notNull()
72
+ .references(() => opportunities.id, { onDelete: "cascade" }),
73
+ personId: typeIdRef("person_id")
74
+ .notNull()
75
+ .references(() => people.id, { onDelete: "cascade" }),
76
+ role: participantRoleEnum("role").notNull().default("other"),
77
+ isPrimary: boolean("is_primary").notNull().default(false),
78
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
79
+ }, (table) => [
80
+ index("idx_opportunity_participants_opportunity").on(table.opportunityId),
81
+ index("idx_opportunity_participants_person").on(table.personId),
82
+ uniqueIndex("uidx_opportunity_participants_unique").on(table.opportunityId, table.personId),
83
+ ]);
84
+ export const opportunityProducts = pgTable("opportunity_products", {
85
+ id: typeId("opportunity_products"),
86
+ opportunityId: typeIdRef("opportunity_id")
87
+ .notNull()
88
+ .references(() => opportunities.id, { onDelete: "cascade" }),
89
+ productId: text("product_id"),
90
+ supplierServiceId: text("supplier_service_id"),
91
+ nameSnapshot: text("name_snapshot").notNull(),
92
+ description: text("description"),
93
+ quantity: integer("quantity").notNull().default(1),
94
+ unitPriceAmountCents: integer("unit_price_amount_cents"),
95
+ costAmountCents: integer("cost_amount_cents"),
96
+ currency: text("currency"),
97
+ discountAmountCents: integer("discount_amount_cents"),
98
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
99
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
100
+ }, (table) => [
101
+ index("idx_opportunity_products_opportunity").on(table.opportunityId),
102
+ index("idx_opportunity_products_product").on(table.productId),
103
+ index("idx_opportunity_products_supplier_service").on(table.supplierServiceId),
104
+ ]);
105
+ export const quotes = pgTable("quotes", {
106
+ id: typeId("quotes"),
107
+ opportunityId: typeIdRef("opportunity_id")
108
+ .notNull()
109
+ .references(() => opportunities.id, { onDelete: "cascade" }),
110
+ status: quoteStatusEnum("status").notNull().default("draft"),
111
+ validUntil: date("valid_until"),
112
+ currency: text("currency").notNull(),
113
+ subtotalAmountCents: integer("subtotal_amount_cents").notNull().default(0),
114
+ taxAmountCents: integer("tax_amount_cents").notNull().default(0),
115
+ totalAmountCents: integer("total_amount_cents").notNull().default(0),
116
+ notes: text("notes"),
117
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
118
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
119
+ archivedAt: timestamp("archived_at", { withTimezone: true }),
120
+ }, (table) => [
121
+ index("idx_quotes_opportunity").on(table.opportunityId),
122
+ index("idx_quotes_status").on(table.status),
123
+ ]);
124
+ export const quoteLines = pgTable("quote_lines", {
125
+ id: typeId("quote_lines"),
126
+ quoteId: typeIdRef("quote_id")
127
+ .notNull()
128
+ .references(() => quotes.id, { onDelete: "cascade" }),
129
+ productId: text("product_id"),
130
+ supplierServiceId: text("supplier_service_id"),
131
+ description: text("description").notNull(),
132
+ quantity: integer("quantity").notNull().default(1),
133
+ unitPriceAmountCents: integer("unit_price_amount_cents").notNull().default(0),
134
+ totalAmountCents: integer("total_amount_cents").notNull().default(0),
135
+ currency: text("currency").notNull(),
136
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
137
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
138
+ }, (table) => [
139
+ index("idx_quote_lines_quote").on(table.quoteId),
140
+ index("idx_quote_lines_product").on(table.productId),
141
+ index("idx_quote_lines_supplier_service").on(table.supplierServiceId),
142
+ ]);
@@ -0,0 +1,13 @@
1
+ export declare const entityTypeEnum: import("drizzle-orm/pg-core").PgEnum<["organization", "person", "opportunity", "quote", "activity"]>;
2
+ export declare const relationTypeEnum: import("drizzle-orm/pg-core").PgEnum<["client", "partner", "supplier", "other"]>;
3
+ export declare const communicationChannelEnum: import("drizzle-orm/pg-core").PgEnum<["email", "phone", "whatsapp", "sms", "meeting", "other"]>;
4
+ export declare const communicationDirectionEnum: import("drizzle-orm/pg-core").PgEnum<["inbound", "outbound"]>;
5
+ export declare const recordStatusEnum: import("drizzle-orm/pg-core").PgEnum<["active", "inactive", "archived"]>;
6
+ export declare const opportunityStatusEnum: import("drizzle-orm/pg-core").PgEnum<["open", "won", "lost", "archived"]>;
7
+ export declare const quoteStatusEnum: import("drizzle-orm/pg-core").PgEnum<["draft", "sent", "accepted", "expired", "rejected", "archived"]>;
8
+ export declare const activityTypeEnum: import("drizzle-orm/pg-core").PgEnum<["call", "email", "meeting", "task", "follow_up", "note"]>;
9
+ export declare const activityStatusEnum: import("drizzle-orm/pg-core").PgEnum<["planned", "done", "cancelled"]>;
10
+ export declare const activityLinkRoleEnum: import("drizzle-orm/pg-core").PgEnum<["primary", "related"]>;
11
+ export declare const participantRoleEnum: import("drizzle-orm/pg-core").PgEnum<["traveler", "booker", "decision_maker", "finance", "other"]>;
12
+ export declare const customFieldTypeEnum: import("drizzle-orm/pg-core").PgEnum<["varchar", "text", "double", "monetary", "date", "boolean", "enum", "set", "json", "address", "phone"]>;
13
+ //# sourceMappingURL=schema-shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-shared.d.ts","sourceRoot":"","sources":["../src/schema-shared.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,sGAMzB,CAAA;AAEF,eAAO,MAAM,gBAAgB,kFAAsE,CAAA;AAEnG,eAAO,MAAM,wBAAwB,iGAOnC,CAAA;AAEF,eAAO,MAAM,0BAA0B,+DAA6D,CAAA;AAEpG,eAAO,MAAM,gBAAgB,0EAA8D,CAAA;AAE3F,eAAO,MAAM,qBAAqB,2EAKhC,CAAA;AAEF,eAAO,MAAM,eAAe,wGAO1B,CAAA;AAEF,eAAO,MAAM,gBAAgB,iGAO3B,CAAA;AAEF,eAAO,MAAM,kBAAkB,wEAA8D,CAAA;AAE7F,eAAO,MAAM,oBAAoB,8DAAuD,CAAA;AAExF,eAAO,MAAM,mBAAmB,oGAM9B,CAAA;AAEF,eAAO,MAAM,mBAAmB,+IAY9B,CAAA"}
@@ -0,0 +1,63 @@
1
+ import { pgEnum } from "drizzle-orm/pg-core";
2
+ export const entityTypeEnum = pgEnum("entity_type", [
3
+ "organization",
4
+ "person",
5
+ "opportunity",
6
+ "quote",
7
+ "activity",
8
+ ]);
9
+ export const relationTypeEnum = pgEnum("relation_type", ["client", "partner", "supplier", "other"]);
10
+ export const communicationChannelEnum = pgEnum("communication_channel", [
11
+ "email",
12
+ "phone",
13
+ "whatsapp",
14
+ "sms",
15
+ "meeting",
16
+ "other",
17
+ ]);
18
+ export const communicationDirectionEnum = pgEnum("communication_direction", ["inbound", "outbound"]);
19
+ export const recordStatusEnum = pgEnum("record_status", ["active", "inactive", "archived"]);
20
+ export const opportunityStatusEnum = pgEnum("opportunity_status", [
21
+ "open",
22
+ "won",
23
+ "lost",
24
+ "archived",
25
+ ]);
26
+ export const quoteStatusEnum = pgEnum("quote_status", [
27
+ "draft",
28
+ "sent",
29
+ "accepted",
30
+ "expired",
31
+ "rejected",
32
+ "archived",
33
+ ]);
34
+ export const activityTypeEnum = pgEnum("activity_type", [
35
+ "call",
36
+ "email",
37
+ "meeting",
38
+ "task",
39
+ "follow_up",
40
+ "note",
41
+ ]);
42
+ export const activityStatusEnum = pgEnum("activity_status", ["planned", "done", "cancelled"]);
43
+ export const activityLinkRoleEnum = pgEnum("activity_link_role", ["primary", "related"]);
44
+ export const participantRoleEnum = pgEnum("participant_role", [
45
+ "traveler",
46
+ "booker",
47
+ "decision_maker",
48
+ "finance",
49
+ "other",
50
+ ]);
51
+ export const customFieldTypeEnum = pgEnum("custom_field_type", [
52
+ "varchar",
53
+ "text",
54
+ "double",
55
+ "monetary",
56
+ "date",
57
+ "boolean",
58
+ "enum",
59
+ "set",
60
+ "json",
61
+ "address",
62
+ "phone",
63
+ ]);