@voyantjs/crm 0.1.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.
- package/LICENSE +109 -0
- package/README.md +47 -0
- package/dist/booking-extension.d.ts +123 -0
- package/dist/booking-extension.d.ts.map +1 -0
- package/dist/booking-extension.js +86 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/routes/accounts.d.ts +1203 -0
- package/dist/routes/accounts.d.ts.map +1 -0
- package/dist/routes/accounts.js +226 -0
- package/dist/routes/activities.d.ts +299 -0
- package/dist/routes/activities.d.ts.map +1 -0
- package/dist/routes/activities.js +61 -0
- package/dist/routes/custom-fields.d.ts +256 -0
- package/dist/routes/custom-fields.d.ts.map +1 -0
- package/dist/routes/custom-fields.js +46 -0
- package/dist/routes/index.d.ts +2671 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +14 -0
- package/dist/routes/opportunities.d.ts +387 -0
- package/dist/routes/opportunities.d.ts.map +1 -0
- package/dist/routes/opportunities.js +69 -0
- package/dist/routes/pipelines.d.ts +292 -0
- package/dist/routes/pipelines.d.ts.map +1 -0
- package/dist/routes/pipelines.js +58 -0
- package/dist/routes/quotes.d.ts +283 -0
- package/dist/routes/quotes.d.ts.map +1 -0
- package/dist/routes/quotes.js +51 -0
- package/dist/schema.d.ts +3478 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +515 -0
- package/dist/service/accounts.d.ts +982 -0
- package/dist/service/accounts.d.ts.map +1 -0
- package/dist/service/accounts.js +509 -0
- package/dist/service/activities.d.ts +486 -0
- package/dist/service/activities.d.ts.map +1 -0
- package/dist/service/activities.js +114 -0
- package/dist/service/custom-fields.d.ts +118 -0
- package/dist/service/custom-fields.d.ts.map +1 -0
- package/dist/service/custom-fields.js +88 -0
- package/dist/service/helpers.d.ts +22 -0
- package/dist/service/helpers.d.ts.map +1 -0
- package/dist/service/helpers.js +39 -0
- package/dist/service/index.d.ts +3329 -0
- package/dist/service/index.d.ts.map +1 -0
- package/dist/service/index.js +14 -0
- package/dist/service/opportunities.d.ts +822 -0
- package/dist/service/opportunities.d.ts.map +1 -0
- package/dist/service/opportunities.js +117 -0
- package/dist/service/pipelines.d.ts +113 -0
- package/dist/service/pipelines.d.ts.map +1 -0
- package/dist/service/pipelines.js +68 -0
- package/dist/service/quotes.d.ts +494 -0
- package/dist/service/quotes.d.ts.map +1 -0
- package/dist/service/quotes.js +69 -0
- package/dist/validation.d.ts +860 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +315 -0
- package/package.json +56 -0
|
@@ -0,0 +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;KAChB,CAAA;CACF,CAAA;AAKD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAmStB,CAAA"}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { insertAddressSchema, insertContactPointSchema, updateAddressSchema, updateContactPointSchema, } from "@voyantjs/identity/validation";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { crmService } from "../service/index.js";
|
|
4
|
+
import { communicationListQuerySchema, insertCommunicationLogSchema, insertOrganizationNoteSchema, insertOrganizationSchema, insertPersonNoteSchema, insertPersonSchema, insertSegmentSchema, organizationListQuerySchema, personListQuerySchema, updateOrganizationNoteSchema, updateOrganizationSchema, updatePersonNoteSchema, updatePersonSchema, } from "../validation.js";
|
|
5
|
+
const organizationEntity = "organization";
|
|
6
|
+
const personEntity = "person";
|
|
7
|
+
export const accountRoutes = new Hono()
|
|
8
|
+
// Organizations
|
|
9
|
+
.get("/organizations", async (c) => {
|
|
10
|
+
const query = organizationListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
11
|
+
return c.json(await crmService.listOrganizations(c.get("db"), query));
|
|
12
|
+
})
|
|
13
|
+
.post("/organizations", async (c) => {
|
|
14
|
+
return c.json({
|
|
15
|
+
data: await crmService.createOrganization(c.get("db"), insertOrganizationSchema.parse(await c.req.json())),
|
|
16
|
+
}, 201);
|
|
17
|
+
})
|
|
18
|
+
.get("/organizations/:id", async (c) => {
|
|
19
|
+
const row = await crmService.getOrganizationById(c.get("db"), c.req.param("id"));
|
|
20
|
+
if (!row)
|
|
21
|
+
return c.json({ error: "Organization not found" }, 404);
|
|
22
|
+
return c.json({ data: row });
|
|
23
|
+
})
|
|
24
|
+
.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
|
+
if (!row)
|
|
27
|
+
return c.json({ error: "Organization not found" }, 404);
|
|
28
|
+
return c.json({ data: row });
|
|
29
|
+
})
|
|
30
|
+
.delete("/organizations/:id", async (c) => {
|
|
31
|
+
const row = await crmService.deleteOrganization(c.get("db"), c.req.param("id"));
|
|
32
|
+
if (!row)
|
|
33
|
+
return c.json({ error: "Organization not found" }, 404);
|
|
34
|
+
return c.json({ success: true });
|
|
35
|
+
})
|
|
36
|
+
.get("/organizations/:id/contact-methods", async (c) => {
|
|
37
|
+
return c.json({
|
|
38
|
+
data: await crmService.listContactMethods(c.get("db"), organizationEntity, c.req.param("id")),
|
|
39
|
+
});
|
|
40
|
+
})
|
|
41
|
+
.post("/organizations/:id/contact-methods", async (c) => {
|
|
42
|
+
return c.json({
|
|
43
|
+
data: await crmService.createContactMethod(c.get("db"), organizationEntity, c.req.param("id"), insertContactPointSchema.parse(await c.req.json())),
|
|
44
|
+
}, 201);
|
|
45
|
+
})
|
|
46
|
+
.get("/organizations/:id/addresses", async (c) => {
|
|
47
|
+
return c.json({
|
|
48
|
+
data: await crmService.listAddresses(c.get("db"), organizationEntity, c.req.param("id")),
|
|
49
|
+
});
|
|
50
|
+
})
|
|
51
|
+
.post("/organizations/:id/addresses", async (c) => {
|
|
52
|
+
return c.json({
|
|
53
|
+
data: await crmService.createAddress(c.get("db"), organizationEntity, c.req.param("id"), insertAddressSchema.parse(await c.req.json())),
|
|
54
|
+
}, 201);
|
|
55
|
+
})
|
|
56
|
+
.get("/organizations/:id/notes", async (c) => {
|
|
57
|
+
return c.json({
|
|
58
|
+
data: await crmService.listOrganizationNotes(c.get("db"), c.req.param("id")),
|
|
59
|
+
});
|
|
60
|
+
})
|
|
61
|
+
.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()));
|
|
66
|
+
if (!row)
|
|
67
|
+
return c.json({ error: "Organization not found" }, 404);
|
|
68
|
+
return c.json({ data: row }, 201);
|
|
69
|
+
})
|
|
70
|
+
.patch("/organization-notes/:id", async (c) => {
|
|
71
|
+
const body = updateOrganizationNoteSchema.parse(await c.req.json());
|
|
72
|
+
const row = await crmService.updateOrganizationNote(c.get("db"), c.req.param("id"), body.content);
|
|
73
|
+
if (!row)
|
|
74
|
+
return c.json({ error: "Note not found" }, 404);
|
|
75
|
+
return c.json({ data: row });
|
|
76
|
+
})
|
|
77
|
+
.delete("/organization-notes/:id", async (c) => {
|
|
78
|
+
const row = await crmService.deleteOrganizationNote(c.get("db"), c.req.param("id"));
|
|
79
|
+
if (!row)
|
|
80
|
+
return c.json({ error: "Note not found" }, 404);
|
|
81
|
+
return c.json({ success: true });
|
|
82
|
+
})
|
|
83
|
+
// People
|
|
84
|
+
.get("/people", async (c) => {
|
|
85
|
+
const query = personListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
86
|
+
return c.json(await crmService.listPeople(c.get("db"), query));
|
|
87
|
+
})
|
|
88
|
+
.post("/people", async (c) => {
|
|
89
|
+
return c.json({
|
|
90
|
+
data: await crmService.createPerson(c.get("db"), insertPersonSchema.parse(await c.req.json())),
|
|
91
|
+
}, 201);
|
|
92
|
+
})
|
|
93
|
+
.get("/people/:id", async (c) => {
|
|
94
|
+
const row = await crmService.getPersonById(c.get("db"), c.req.param("id"));
|
|
95
|
+
if (!row)
|
|
96
|
+
return c.json({ error: "Person not found" }, 404);
|
|
97
|
+
return c.json({ data: row });
|
|
98
|
+
})
|
|
99
|
+
.patch("/people/:id", async (c) => {
|
|
100
|
+
const row = await crmService.updatePerson(c.get("db"), c.req.param("id"), updatePersonSchema.parse(await c.req.json()));
|
|
101
|
+
if (!row)
|
|
102
|
+
return c.json({ error: "Person not found" }, 404);
|
|
103
|
+
return c.json({ data: row });
|
|
104
|
+
})
|
|
105
|
+
.delete("/people/:id", async (c) => {
|
|
106
|
+
const row = await crmService.deletePerson(c.get("db"), c.req.param("id"));
|
|
107
|
+
if (!row)
|
|
108
|
+
return c.json({ error: "Person not found" }, 404);
|
|
109
|
+
return c.json({ success: true });
|
|
110
|
+
})
|
|
111
|
+
.get("/people/:id/contact-methods", async (c) => {
|
|
112
|
+
return c.json({
|
|
113
|
+
data: await crmService.listContactMethods(c.get("db"), personEntity, c.req.param("id")),
|
|
114
|
+
});
|
|
115
|
+
})
|
|
116
|
+
.post("/people/:id/contact-methods", async (c) => {
|
|
117
|
+
return c.json({
|
|
118
|
+
data: await crmService.createContactMethod(c.get("db"), personEntity, c.req.param("id"), insertContactPointSchema.parse(await c.req.json())),
|
|
119
|
+
}, 201);
|
|
120
|
+
})
|
|
121
|
+
.get("/people/:id/addresses", async (c) => {
|
|
122
|
+
return c.json({
|
|
123
|
+
data: await crmService.listAddresses(c.get("db"), personEntity, c.req.param("id")),
|
|
124
|
+
});
|
|
125
|
+
})
|
|
126
|
+
.post("/people/:id/addresses", async (c) => {
|
|
127
|
+
return c.json({
|
|
128
|
+
data: await crmService.createAddress(c.get("db"), personEntity, c.req.param("id"), insertAddressSchema.parse(await c.req.json())),
|
|
129
|
+
}, 201);
|
|
130
|
+
})
|
|
131
|
+
.get("/people/:id/notes", async (c) => {
|
|
132
|
+
return c.json({
|
|
133
|
+
data: await crmService.listPersonNotes(c.get("db"), c.req.param("id")),
|
|
134
|
+
});
|
|
135
|
+
})
|
|
136
|
+
.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()));
|
|
141
|
+
if (!row)
|
|
142
|
+
return c.json({ error: "Person not found" }, 404);
|
|
143
|
+
return c.json({ data: row }, 201);
|
|
144
|
+
})
|
|
145
|
+
.patch("/person-notes/:id", async (c) => {
|
|
146
|
+
const body = updatePersonNoteSchema.parse(await c.req.json());
|
|
147
|
+
const row = await crmService.updatePersonNote(c.get("db"), c.req.param("id"), body.content);
|
|
148
|
+
if (!row)
|
|
149
|
+
return c.json({ error: "Note not found" }, 404);
|
|
150
|
+
return c.json({ data: row });
|
|
151
|
+
})
|
|
152
|
+
.delete("/person-notes/:id", async (c) => {
|
|
153
|
+
const row = await crmService.deletePersonNote(c.get("db"), c.req.param("id"));
|
|
154
|
+
if (!row)
|
|
155
|
+
return c.json({ error: "Note not found" }, 404);
|
|
156
|
+
return c.json({ success: true });
|
|
157
|
+
})
|
|
158
|
+
.get("/people/:id/communications", async (c) => {
|
|
159
|
+
const query = communicationListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
160
|
+
return c.json({
|
|
161
|
+
data: await crmService.listCommunications(c.get("db"), c.req.param("id"), query),
|
|
162
|
+
});
|
|
163
|
+
})
|
|
164
|
+
.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()));
|
|
166
|
+
if (!row)
|
|
167
|
+
return c.json({ error: "Person not found" }, 404);
|
|
168
|
+
return c.json({ data: row }, 201);
|
|
169
|
+
})
|
|
170
|
+
// Segments
|
|
171
|
+
.get("/segments", async (c) => {
|
|
172
|
+
return c.json({ data: await crmService.listSegments(c.get("db")) });
|
|
173
|
+
})
|
|
174
|
+
.post("/segments", async (c) => {
|
|
175
|
+
return c.json({
|
|
176
|
+
data: await crmService.createSegment(c.get("db"), insertSegmentSchema.parse(await c.req.json())),
|
|
177
|
+
}, 201);
|
|
178
|
+
})
|
|
179
|
+
.delete("/segments/:segmentId", async (c) => {
|
|
180
|
+
const row = await crmService.deleteSegment(c.get("db"), c.req.param("segmentId"));
|
|
181
|
+
if (!row)
|
|
182
|
+
return c.json({ error: "Segment not found" }, 404);
|
|
183
|
+
return c.json({ success: true });
|
|
184
|
+
})
|
|
185
|
+
// CSV export/import
|
|
186
|
+
.post("/people/export", async (c) => {
|
|
187
|
+
const csv = await crmService.exportPeopleCsv(c.get("db"));
|
|
188
|
+
return new Response(csv, {
|
|
189
|
+
headers: {
|
|
190
|
+
"Content-Type": "text/csv",
|
|
191
|
+
"Content-Disposition": 'attachment; filename="people.csv"',
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
})
|
|
195
|
+
.post("/people/import", async (c) => {
|
|
196
|
+
const result = await crmService.importPeopleCsv(c.get("db"), await c.req.text());
|
|
197
|
+
if ("error" in result) {
|
|
198
|
+
return c.json({ error: result.error }, 400);
|
|
199
|
+
}
|
|
200
|
+
return c.json(result, 200);
|
|
201
|
+
})
|
|
202
|
+
// Shared contact method and address resources
|
|
203
|
+
.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()));
|
|
205
|
+
if (!row)
|
|
206
|
+
return c.json({ error: "Contact method not found" }, 404);
|
|
207
|
+
return c.json({ data: row });
|
|
208
|
+
})
|
|
209
|
+
.delete("/contact-methods/:id", async (c) => {
|
|
210
|
+
const row = await crmService.deleteContactMethod(c.get("db"), c.req.param("id"));
|
|
211
|
+
if (!row)
|
|
212
|
+
return c.json({ error: "Contact method not found" }, 404);
|
|
213
|
+
return c.json({ success: true });
|
|
214
|
+
})
|
|
215
|
+
.patch("/addresses/:id", async (c) => {
|
|
216
|
+
const row = await crmService.updateAddress(c.get("db"), c.req.param("id"), updateAddressSchema.parse(await c.req.json()));
|
|
217
|
+
if (!row)
|
|
218
|
+
return c.json({ error: "Address not found" }, 404);
|
|
219
|
+
return c.json({ data: row });
|
|
220
|
+
})
|
|
221
|
+
.delete("/addresses/:id", async (c) => {
|
|
222
|
+
const row = await crmService.deleteAddress(c.get("db"), c.req.param("id"));
|
|
223
|
+
if (!row)
|
|
224
|
+
return c.json({ error: "Address not found" }, 404);
|
|
225
|
+
return c.json({ success: true });
|
|
226
|
+
});
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
type Env = {
|
|
3
|
+
Variables: {
|
|
4
|
+
db: PostgresJsDatabase;
|
|
5
|
+
userId?: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare const activityRoutes: import("hono/hono-base").HonoBase<Env, {
|
|
9
|
+
"/activities": {
|
|
10
|
+
$get: {
|
|
11
|
+
input: {};
|
|
12
|
+
output: {
|
|
13
|
+
data: {
|
|
14
|
+
id: string;
|
|
15
|
+
subject: string;
|
|
16
|
+
type: "email" | "meeting" | "call" | "task" | "follow_up" | "note";
|
|
17
|
+
ownerId: string | null;
|
|
18
|
+
status: "done" | "planned" | "cancelled";
|
|
19
|
+
dueAt: string | null;
|
|
20
|
+
completedAt: string | null;
|
|
21
|
+
location: string | null;
|
|
22
|
+
description: string | null;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
}[];
|
|
26
|
+
total: number;
|
|
27
|
+
limit: number;
|
|
28
|
+
offset: number;
|
|
29
|
+
};
|
|
30
|
+
outputFormat: "json";
|
|
31
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
} & {
|
|
35
|
+
"/activities": {
|
|
36
|
+
$post: {
|
|
37
|
+
input: {};
|
|
38
|
+
output: {
|
|
39
|
+
data: {
|
|
40
|
+
createdAt: string;
|
|
41
|
+
updatedAt: string;
|
|
42
|
+
description: string | null;
|
|
43
|
+
type: "email" | "meeting" | "call" | "task" | "follow_up" | "note";
|
|
44
|
+
id: string;
|
|
45
|
+
ownerId: string | null;
|
|
46
|
+
status: "done" | "planned" | "cancelled";
|
|
47
|
+
subject: string;
|
|
48
|
+
dueAt: string | null;
|
|
49
|
+
completedAt: string | null;
|
|
50
|
+
location: string | null;
|
|
51
|
+
} | undefined;
|
|
52
|
+
};
|
|
53
|
+
outputFormat: "json";
|
|
54
|
+
status: 201;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
} & {
|
|
58
|
+
"/activities/:id": {
|
|
59
|
+
$get: {
|
|
60
|
+
input: {
|
|
61
|
+
param: {
|
|
62
|
+
id: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
output: {
|
|
66
|
+
error: string;
|
|
67
|
+
};
|
|
68
|
+
outputFormat: "json";
|
|
69
|
+
status: 404;
|
|
70
|
+
} | {
|
|
71
|
+
input: {
|
|
72
|
+
param: {
|
|
73
|
+
id: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
output: {
|
|
77
|
+
data: {
|
|
78
|
+
id: string;
|
|
79
|
+
subject: string;
|
|
80
|
+
type: "email" | "meeting" | "call" | "task" | "follow_up" | "note";
|
|
81
|
+
ownerId: string | null;
|
|
82
|
+
status: "done" | "planned" | "cancelled";
|
|
83
|
+
dueAt: string | null;
|
|
84
|
+
completedAt: string | null;
|
|
85
|
+
location: string | null;
|
|
86
|
+
description: string | null;
|
|
87
|
+
createdAt: string;
|
|
88
|
+
updatedAt: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
outputFormat: "json";
|
|
92
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
} & {
|
|
96
|
+
"/activities/:id": {
|
|
97
|
+
$patch: {
|
|
98
|
+
input: {
|
|
99
|
+
param: {
|
|
100
|
+
id: string;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
output: {
|
|
104
|
+
error: string;
|
|
105
|
+
};
|
|
106
|
+
outputFormat: "json";
|
|
107
|
+
status: 404;
|
|
108
|
+
} | {
|
|
109
|
+
input: {
|
|
110
|
+
param: {
|
|
111
|
+
id: string;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
output: {
|
|
115
|
+
data: {
|
|
116
|
+
id: string;
|
|
117
|
+
subject: string;
|
|
118
|
+
type: "email" | "meeting" | "call" | "task" | "follow_up" | "note";
|
|
119
|
+
ownerId: string | null;
|
|
120
|
+
status: "done" | "planned" | "cancelled";
|
|
121
|
+
dueAt: string | null;
|
|
122
|
+
completedAt: string | null;
|
|
123
|
+
location: string | null;
|
|
124
|
+
description: string | null;
|
|
125
|
+
createdAt: string;
|
|
126
|
+
updatedAt: string;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
outputFormat: "json";
|
|
130
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
} & {
|
|
134
|
+
"/activities/:id": {
|
|
135
|
+
$delete: {
|
|
136
|
+
input: {
|
|
137
|
+
param: {
|
|
138
|
+
id: string;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
output: {
|
|
142
|
+
error: string;
|
|
143
|
+
};
|
|
144
|
+
outputFormat: "json";
|
|
145
|
+
status: 404;
|
|
146
|
+
} | {
|
|
147
|
+
input: {
|
|
148
|
+
param: {
|
|
149
|
+
id: string;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
output: {
|
|
153
|
+
success: true;
|
|
154
|
+
};
|
|
155
|
+
outputFormat: "json";
|
|
156
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
} & {
|
|
160
|
+
"/activities/:id/links": {
|
|
161
|
+
$get: {
|
|
162
|
+
input: {
|
|
163
|
+
param: {
|
|
164
|
+
id: string;
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
output: {
|
|
168
|
+
data: {
|
|
169
|
+
id: string;
|
|
170
|
+
activityId: string;
|
|
171
|
+
entityType: "organization" | "person" | "opportunity" | "quote" | "activity";
|
|
172
|
+
entityId: string;
|
|
173
|
+
role: "primary" | "related";
|
|
174
|
+
createdAt: string;
|
|
175
|
+
}[];
|
|
176
|
+
};
|
|
177
|
+
outputFormat: "json";
|
|
178
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
} & {
|
|
182
|
+
"/activities/:id/links": {
|
|
183
|
+
$post: {
|
|
184
|
+
input: {
|
|
185
|
+
param: {
|
|
186
|
+
id: string;
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
output: {
|
|
190
|
+
data: {
|
|
191
|
+
createdAt: string;
|
|
192
|
+
entityType: "organization" | "person" | "opportunity" | "quote" | "activity";
|
|
193
|
+
entityId: string;
|
|
194
|
+
role: "primary" | "related";
|
|
195
|
+
id: string;
|
|
196
|
+
activityId: string;
|
|
197
|
+
} | undefined;
|
|
198
|
+
};
|
|
199
|
+
outputFormat: "json";
|
|
200
|
+
status: 201;
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
} & {
|
|
204
|
+
"/activity-links/:id": {
|
|
205
|
+
$delete: {
|
|
206
|
+
input: {
|
|
207
|
+
param: {
|
|
208
|
+
id: string;
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
output: {
|
|
212
|
+
error: string;
|
|
213
|
+
};
|
|
214
|
+
outputFormat: "json";
|
|
215
|
+
status: 404;
|
|
216
|
+
} | {
|
|
217
|
+
input: {
|
|
218
|
+
param: {
|
|
219
|
+
id: string;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
output: {
|
|
223
|
+
success: true;
|
|
224
|
+
};
|
|
225
|
+
outputFormat: "json";
|
|
226
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
} & {
|
|
230
|
+
"/activities/:id/participants": {
|
|
231
|
+
$get: {
|
|
232
|
+
input: {
|
|
233
|
+
param: {
|
|
234
|
+
id: string;
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
output: {
|
|
238
|
+
data: {
|
|
239
|
+
id: string;
|
|
240
|
+
activityId: string;
|
|
241
|
+
personId: string;
|
|
242
|
+
isPrimary: boolean;
|
|
243
|
+
createdAt: string;
|
|
244
|
+
}[];
|
|
245
|
+
};
|
|
246
|
+
outputFormat: "json";
|
|
247
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
} & {
|
|
251
|
+
"/activities/:id/participants": {
|
|
252
|
+
$post: {
|
|
253
|
+
input: {
|
|
254
|
+
param: {
|
|
255
|
+
id: string;
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
output: {
|
|
259
|
+
data: {
|
|
260
|
+
createdAt: string;
|
|
261
|
+
isPrimary: boolean;
|
|
262
|
+
id: string;
|
|
263
|
+
personId: string;
|
|
264
|
+
activityId: string;
|
|
265
|
+
} | undefined;
|
|
266
|
+
};
|
|
267
|
+
outputFormat: "json";
|
|
268
|
+
status: 201;
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
} & {
|
|
272
|
+
"/activity-participants/:id": {
|
|
273
|
+
$delete: {
|
|
274
|
+
input: {
|
|
275
|
+
param: {
|
|
276
|
+
id: string;
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
output: {
|
|
280
|
+
error: string;
|
|
281
|
+
};
|
|
282
|
+
outputFormat: "json";
|
|
283
|
+
status: 404;
|
|
284
|
+
} | {
|
|
285
|
+
input: {
|
|
286
|
+
param: {
|
|
287
|
+
id: string;
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
output: {
|
|
291
|
+
success: true;
|
|
292
|
+
};
|
|
293
|
+
outputFormat: "json";
|
|
294
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
}, "/", "/activity-participants/:id">;
|
|
298
|
+
export {};
|
|
299
|
+
//# sourceMappingURL=activities.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { crmService } from "../service/index.js";
|
|
3
|
+
import { activityListQuerySchema, insertActivityLinkSchema, insertActivityParticipantSchema, insertActivitySchema, updateActivitySchema, } from "../validation.js";
|
|
4
|
+
export const activityRoutes = new Hono()
|
|
5
|
+
.get("/activities", async (c) => {
|
|
6
|
+
const query = activityListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
7
|
+
return c.json(await crmService.listActivities(c.get("db"), query));
|
|
8
|
+
})
|
|
9
|
+
.post("/activities", async (c) => {
|
|
10
|
+
return c.json({
|
|
11
|
+
data: await crmService.createActivity(c.get("db"), insertActivitySchema.parse(await c.req.json())),
|
|
12
|
+
}, 201);
|
|
13
|
+
})
|
|
14
|
+
.get("/activities/:id", async (c) => {
|
|
15
|
+
const row = await crmService.getActivityById(c.get("db"), c.req.param("id"));
|
|
16
|
+
if (!row)
|
|
17
|
+
return c.json({ error: "Activity not found" }, 404);
|
|
18
|
+
return c.json({ data: row });
|
|
19
|
+
})
|
|
20
|
+
.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
|
+
if (!row)
|
|
23
|
+
return c.json({ error: "Activity not found" }, 404);
|
|
24
|
+
return c.json({ data: row });
|
|
25
|
+
})
|
|
26
|
+
.delete("/activities/:id", async (c) => {
|
|
27
|
+
const row = await crmService.deleteActivity(c.get("db"), c.req.param("id"));
|
|
28
|
+
if (!row)
|
|
29
|
+
return c.json({ error: "Activity not found" }, 404);
|
|
30
|
+
return c.json({ success: true });
|
|
31
|
+
})
|
|
32
|
+
.get("/activities/:id/links", async (c) => {
|
|
33
|
+
return c.json({ data: await crmService.listActivityLinks(c.get("db"), c.req.param("id")) });
|
|
34
|
+
})
|
|
35
|
+
.post("/activities/:id/links", async (c) => {
|
|
36
|
+
return c.json({
|
|
37
|
+
data: await crmService.createActivityLink(c.get("db"), c.req.param("id"), insertActivityLinkSchema.parse(await c.req.json())),
|
|
38
|
+
}, 201);
|
|
39
|
+
})
|
|
40
|
+
.delete("/activity-links/:id", async (c) => {
|
|
41
|
+
const row = await crmService.deleteActivityLink(c.get("db"), c.req.param("id"));
|
|
42
|
+
if (!row)
|
|
43
|
+
return c.json({ error: "Activity link not found" }, 404);
|
|
44
|
+
return c.json({ success: true });
|
|
45
|
+
})
|
|
46
|
+
.get("/activities/:id/participants", async (c) => {
|
|
47
|
+
return c.json({
|
|
48
|
+
data: await crmService.listActivityParticipants(c.get("db"), c.req.param("id")),
|
|
49
|
+
});
|
|
50
|
+
})
|
|
51
|
+
.post("/activities/:id/participants", async (c) => {
|
|
52
|
+
return c.json({
|
|
53
|
+
data: await crmService.createActivityParticipant(c.get("db"), c.req.param("id"), insertActivityParticipantSchema.parse(await c.req.json())),
|
|
54
|
+
}, 201);
|
|
55
|
+
})
|
|
56
|
+
.delete("/activity-participants/:id", async (c) => {
|
|
57
|
+
const row = await crmService.deleteActivityParticipant(c.get("db"), c.req.param("id"));
|
|
58
|
+
if (!row)
|
|
59
|
+
return c.json({ error: "Activity participant not found" }, 404);
|
|
60
|
+
return c.json({ success: true });
|
|
61
|
+
});
|