@voyantjs/crm 0.106.1 → 0.107.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.
- package/README.md +3 -3
- package/dist/booking-extension.d.ts +7 -7
- package/dist/booking-extension.d.ts.map +1 -1
- package/dist/booking-extension.js +8 -5
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/routes/activities.d.ts +2 -2
- package/dist/routes/custom-fields.d.ts +6 -6
- package/dist/routes/index.d.ts +518 -51
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +2 -2
- package/dist/routes/pipelines.d.ts +4 -4
- package/dist/routes/quote-versions.d.ts +746 -0
- package/dist/routes/quote-versions.d.ts.map +1 -0
- package/dist/routes/quote-versions.js +175 -0
- package/dist/routes/quotes.d.ts +161 -53
- package/dist/routes/quotes.d.ts.map +1 -1
- package/dist/routes/quotes.js +29 -11
- package/dist/schema-activities.d.ts +6 -6
- package/dist/schema-relations.d.ts +19 -18
- package/dist/schema-relations.d.ts.map +1 -1
- package/dist/schema-relations.js +38 -31
- package/dist/schema-sales.d.ts +206 -87
- package/dist/schema-sales.d.ts.map +1 -1
- package/dist/schema-sales.js +62 -50
- package/dist/schema-shared.d.ts +3 -3
- package/dist/schema-shared.d.ts.map +1 -1
- package/dist/schema-shared.js +5 -16
- package/dist/schema-signals.d.ts +1 -1
- package/dist/schema-signals.js +1 -1
- package/dist/service/accounts-merge.js +10 -10
- package/dist/service/activities.d.ts +6 -6
- package/dist/service/custom-fields.d.ts +6 -6
- package/dist/service/index.d.ts +338 -139
- package/dist/service/index.d.ts.map +1 -1
- package/dist/service/index.js +2 -2
- package/dist/service/pipelines.d.ts +4 -4
- package/dist/service/quote-versions.d.ts +674 -0
- package/dist/service/quote-versions.d.ts.map +1 -0
- package/dist/service/quote-versions.js +399 -0
- package/dist/service/quotes.d.ts +426 -94
- package/dist/service/quotes.d.ts.map +1 -1
- package/dist/service/quotes.js +63 -22
- package/package.json +7 -7
- package/dist/routes/opportunities.d.ts +0 -387
- package/dist/routes/opportunities.d.ts.map +0 -1
- package/dist/routes/opportunities.js +0 -70
- package/dist/service/opportunities.d.ts +0 -822
- package/dist/service/opportunities.d.ts.map +0 -1
- package/dist/service/opportunities.js +0 -117
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"opportunities.d.ts","sourceRoot":"","sources":["../../src/service/opportunities.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,kCAAkC,EAClC,8BAA8B,EAC9B,uBAAuB,EACvB,0BAA0B,EAC1B,8BAA8B,EAC9B,uBAAuB,EACxB,MAAM,kBAAkB,CAAA;AAGzB,KAAK,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AACtE,KAAK,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AACrE,KAAK,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AACrE,KAAK,iCAAiC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAA;AAC3F,KAAK,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA;AACnF,KAAK,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA;AAEnF,eAAO,MAAM,oBAAoB;0BACH,kBAAkB,SAAS,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;2BAoC9C,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;0BAK/B,kBAAkB,QAAQ,sBAAsB;;;;;;;;;;;;;;;;;;;;;0BAKhD,kBAAkB,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|
-
import { and, desc, eq, ilike, or, sql } from "drizzle-orm";
|
|
2
|
-
import { opportunities, opportunityParticipants, opportunityProducts } from "../schema.js";
|
|
3
|
-
import { paginate } from "./helpers.js";
|
|
4
|
-
export const opportunitiesService = {
|
|
5
|
-
async listOpportunities(db, query) {
|
|
6
|
-
const conditions = [];
|
|
7
|
-
if (query.personId)
|
|
8
|
-
conditions.push(eq(opportunities.personId, query.personId));
|
|
9
|
-
if (query.organizationId)
|
|
10
|
-
conditions.push(eq(opportunities.organizationId, query.organizationId));
|
|
11
|
-
if (query.pipelineId)
|
|
12
|
-
conditions.push(eq(opportunities.pipelineId, query.pipelineId));
|
|
13
|
-
if (query.stageId)
|
|
14
|
-
conditions.push(eq(opportunities.stageId, query.stageId));
|
|
15
|
-
if (query.ownerId)
|
|
16
|
-
conditions.push(eq(opportunities.ownerId, query.ownerId));
|
|
17
|
-
if (query.status)
|
|
18
|
-
conditions.push(eq(opportunities.status, query.status));
|
|
19
|
-
if (query.search) {
|
|
20
|
-
const term = `%${query.search}%`;
|
|
21
|
-
conditions.push(or(ilike(opportunities.title, term), ilike(opportunities.source, term), ilike(opportunities.sourceRef, term)));
|
|
22
|
-
}
|
|
23
|
-
const where = conditions.length ? and(...conditions) : undefined;
|
|
24
|
-
return paginate(db
|
|
25
|
-
.select()
|
|
26
|
-
.from(opportunities)
|
|
27
|
-
.where(where)
|
|
28
|
-
.limit(query.limit)
|
|
29
|
-
.offset(query.offset)
|
|
30
|
-
.orderBy(desc(opportunities.updatedAt)), db.select({ count: sql `count(*)::int` }).from(opportunities).where(where), query.limit, query.offset);
|
|
31
|
-
},
|
|
32
|
-
async getOpportunityById(db, id) {
|
|
33
|
-
const [row] = await db.select().from(opportunities).where(eq(opportunities.id, id)).limit(1);
|
|
34
|
-
return row ?? null;
|
|
35
|
-
},
|
|
36
|
-
async createOpportunity(db, data) {
|
|
37
|
-
const [row] = await db.insert(opportunities).values(data).returning();
|
|
38
|
-
return row;
|
|
39
|
-
},
|
|
40
|
-
async updateOpportunity(db, id, data) {
|
|
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
|
|
54
|
-
.update(opportunities)
|
|
55
|
-
.set(patch)
|
|
56
|
-
.where(eq(opportunities.id, id))
|
|
57
|
-
.returning();
|
|
58
|
-
return row ?? null;
|
|
59
|
-
},
|
|
60
|
-
async deleteOpportunity(db, id) {
|
|
61
|
-
const [row] = await db
|
|
62
|
-
.delete(opportunities)
|
|
63
|
-
.where(eq(opportunities.id, id))
|
|
64
|
-
.returning({ id: opportunities.id });
|
|
65
|
-
return row ?? null;
|
|
66
|
-
},
|
|
67
|
-
listOpportunityParticipants(db, opportunityId) {
|
|
68
|
-
return db
|
|
69
|
-
.select()
|
|
70
|
-
.from(opportunityParticipants)
|
|
71
|
-
.where(eq(opportunityParticipants.opportunityId, opportunityId))
|
|
72
|
-
.orderBy(desc(opportunityParticipants.isPrimary), opportunityParticipants.createdAt);
|
|
73
|
-
},
|
|
74
|
-
async createOpportunityParticipant(db, opportunityId, data) {
|
|
75
|
-
const [row] = await db
|
|
76
|
-
.insert(opportunityParticipants)
|
|
77
|
-
.values({ ...data, opportunityId })
|
|
78
|
-
.returning();
|
|
79
|
-
return row;
|
|
80
|
-
},
|
|
81
|
-
async deleteOpportunityParticipant(db, id) {
|
|
82
|
-
const [row] = await db
|
|
83
|
-
.delete(opportunityParticipants)
|
|
84
|
-
.where(eq(opportunityParticipants.id, id))
|
|
85
|
-
.returning({ id: opportunityParticipants.id });
|
|
86
|
-
return row ?? null;
|
|
87
|
-
},
|
|
88
|
-
listOpportunityProducts(db, opportunityId) {
|
|
89
|
-
return db
|
|
90
|
-
.select()
|
|
91
|
-
.from(opportunityProducts)
|
|
92
|
-
.where(eq(opportunityProducts.opportunityId, opportunityId))
|
|
93
|
-
.orderBy(opportunityProducts.createdAt);
|
|
94
|
-
},
|
|
95
|
-
async createOpportunityProduct(db, opportunityId, data) {
|
|
96
|
-
const [row] = await db
|
|
97
|
-
.insert(opportunityProducts)
|
|
98
|
-
.values({ ...data, opportunityId })
|
|
99
|
-
.returning();
|
|
100
|
-
return row;
|
|
101
|
-
},
|
|
102
|
-
async updateOpportunityProduct(db, id, data) {
|
|
103
|
-
const [row] = await db
|
|
104
|
-
.update(opportunityProducts)
|
|
105
|
-
.set({ ...data, updatedAt: new Date() })
|
|
106
|
-
.where(eq(opportunityProducts.id, id))
|
|
107
|
-
.returning();
|
|
108
|
-
return row ?? null;
|
|
109
|
-
},
|
|
110
|
-
async deleteOpportunityProduct(db, id) {
|
|
111
|
-
const [row] = await db
|
|
112
|
-
.delete(opportunityProducts)
|
|
113
|
-
.where(eq(opportunityProducts.id, id))
|
|
114
|
-
.returning({ id: opportunityProducts.id });
|
|
115
|
-
return row ?? null;
|
|
116
|
-
},
|
|
117
|
-
};
|