@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.
Files changed (60) hide show
  1. package/LICENSE +109 -0
  2. package/README.md +47 -0
  3. package/dist/booking-extension.d.ts +123 -0
  4. package/dist/booking-extension.d.ts.map +1 -0
  5. package/dist/booking-extension.js +86 -0
  6. package/dist/index.d.ts +14 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +29 -0
  9. package/dist/routes/accounts.d.ts +1203 -0
  10. package/dist/routes/accounts.d.ts.map +1 -0
  11. package/dist/routes/accounts.js +226 -0
  12. package/dist/routes/activities.d.ts +299 -0
  13. package/dist/routes/activities.d.ts.map +1 -0
  14. package/dist/routes/activities.js +61 -0
  15. package/dist/routes/custom-fields.d.ts +256 -0
  16. package/dist/routes/custom-fields.d.ts.map +1 -0
  17. package/dist/routes/custom-fields.js +46 -0
  18. package/dist/routes/index.d.ts +2671 -0
  19. package/dist/routes/index.d.ts.map +1 -0
  20. package/dist/routes/index.js +14 -0
  21. package/dist/routes/opportunities.d.ts +387 -0
  22. package/dist/routes/opportunities.d.ts.map +1 -0
  23. package/dist/routes/opportunities.js +69 -0
  24. package/dist/routes/pipelines.d.ts +292 -0
  25. package/dist/routes/pipelines.d.ts.map +1 -0
  26. package/dist/routes/pipelines.js +58 -0
  27. package/dist/routes/quotes.d.ts +283 -0
  28. package/dist/routes/quotes.d.ts.map +1 -0
  29. package/dist/routes/quotes.js +51 -0
  30. package/dist/schema.d.ts +3478 -0
  31. package/dist/schema.d.ts.map +1 -0
  32. package/dist/schema.js +515 -0
  33. package/dist/service/accounts.d.ts +982 -0
  34. package/dist/service/accounts.d.ts.map +1 -0
  35. package/dist/service/accounts.js +509 -0
  36. package/dist/service/activities.d.ts +486 -0
  37. package/dist/service/activities.d.ts.map +1 -0
  38. package/dist/service/activities.js +114 -0
  39. package/dist/service/custom-fields.d.ts +118 -0
  40. package/dist/service/custom-fields.d.ts.map +1 -0
  41. package/dist/service/custom-fields.js +88 -0
  42. package/dist/service/helpers.d.ts +22 -0
  43. package/dist/service/helpers.d.ts.map +1 -0
  44. package/dist/service/helpers.js +39 -0
  45. package/dist/service/index.d.ts +3329 -0
  46. package/dist/service/index.d.ts.map +1 -0
  47. package/dist/service/index.js +14 -0
  48. package/dist/service/opportunities.d.ts +822 -0
  49. package/dist/service/opportunities.d.ts.map +1 -0
  50. package/dist/service/opportunities.js +117 -0
  51. package/dist/service/pipelines.d.ts +113 -0
  52. package/dist/service/pipelines.d.ts.map +1 -0
  53. package/dist/service/pipelines.js +68 -0
  54. package/dist/service/quotes.d.ts +494 -0
  55. package/dist/service/quotes.d.ts.map +1 -0
  56. package/dist/service/quotes.js +69 -0
  57. package/dist/validation.d.ts +860 -0
  58. package/dist/validation.d.ts.map +1 -0
  59. package/dist/validation.js +315 -0
  60. package/package.json +56 -0
@@ -0,0 +1,256 @@
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 customFieldRoutes: import("hono/hono-base").HonoBase<Env, {
9
+ "/custom-fields": {
10
+ $get: {
11
+ input: {};
12
+ output: {
13
+ data: {
14
+ id: string;
15
+ entityType: "organization" | "person" | "opportunity" | "quote" | "activity";
16
+ key: string;
17
+ label: string;
18
+ fieldType: "boolean" | "json" | "date" | "text" | "phone" | "set" | "enum" | "varchar" | "double" | "monetary" | "address";
19
+ isRequired: boolean;
20
+ isSearchable: boolean;
21
+ options: {
22
+ label: string;
23
+ value: string;
24
+ }[] | null;
25
+ createdAt: string;
26
+ updatedAt: string;
27
+ }[];
28
+ total: number;
29
+ limit: number;
30
+ offset: number;
31
+ };
32
+ outputFormat: "json";
33
+ status: import("hono/utils/http-status").ContentfulStatusCode;
34
+ };
35
+ };
36
+ } & {
37
+ "/custom-fields": {
38
+ $post: {
39
+ input: {};
40
+ output: {
41
+ data: {
42
+ key: string;
43
+ createdAt: string;
44
+ updatedAt: string;
45
+ options: {
46
+ label: string;
47
+ value: string;
48
+ }[] | null;
49
+ entityType: "organization" | "person" | "opportunity" | "quote" | "activity";
50
+ label: string;
51
+ id: string;
52
+ fieldType: "boolean" | "json" | "date" | "text" | "phone" | "set" | "enum" | "varchar" | "double" | "monetary" | "address";
53
+ isRequired: boolean;
54
+ isSearchable: boolean;
55
+ } | undefined;
56
+ };
57
+ outputFormat: "json";
58
+ status: 201;
59
+ };
60
+ };
61
+ } & {
62
+ "/custom-fields/:id": {
63
+ $get: {
64
+ input: {
65
+ param: {
66
+ id: string;
67
+ };
68
+ };
69
+ output: {
70
+ error: string;
71
+ };
72
+ outputFormat: "json";
73
+ status: 404;
74
+ } | {
75
+ input: {
76
+ param: {
77
+ id: string;
78
+ };
79
+ };
80
+ output: {
81
+ data: {
82
+ id: string;
83
+ entityType: "organization" | "person" | "opportunity" | "quote" | "activity";
84
+ key: string;
85
+ label: string;
86
+ fieldType: "boolean" | "json" | "date" | "text" | "phone" | "set" | "enum" | "varchar" | "double" | "monetary" | "address";
87
+ isRequired: boolean;
88
+ isSearchable: boolean;
89
+ options: {
90
+ label: string;
91
+ value: string;
92
+ }[] | null;
93
+ createdAt: string;
94
+ updatedAt: string;
95
+ };
96
+ };
97
+ outputFormat: "json";
98
+ status: import("hono/utils/http-status").ContentfulStatusCode;
99
+ };
100
+ };
101
+ } & {
102
+ "/custom-fields/:id": {
103
+ $patch: {
104
+ input: {
105
+ param: {
106
+ id: string;
107
+ };
108
+ };
109
+ output: {
110
+ error: string;
111
+ };
112
+ outputFormat: "json";
113
+ status: 404;
114
+ } | {
115
+ input: {
116
+ param: {
117
+ id: string;
118
+ };
119
+ };
120
+ output: {
121
+ data: {
122
+ id: string;
123
+ entityType: "organization" | "person" | "opportunity" | "quote" | "activity";
124
+ key: string;
125
+ label: string;
126
+ fieldType: "boolean" | "json" | "date" | "text" | "phone" | "set" | "enum" | "varchar" | "double" | "monetary" | "address";
127
+ isRequired: boolean;
128
+ isSearchable: boolean;
129
+ options: {
130
+ label: string;
131
+ value: string;
132
+ }[] | null;
133
+ createdAt: string;
134
+ updatedAt: string;
135
+ };
136
+ };
137
+ outputFormat: "json";
138
+ status: import("hono/utils/http-status").ContentfulStatusCode;
139
+ };
140
+ };
141
+ } & {
142
+ "/custom-fields/:id": {
143
+ $delete: {
144
+ input: {
145
+ param: {
146
+ id: string;
147
+ };
148
+ };
149
+ output: {
150
+ error: string;
151
+ };
152
+ outputFormat: "json";
153
+ status: 404;
154
+ } | {
155
+ input: {
156
+ param: {
157
+ id: string;
158
+ };
159
+ };
160
+ output: {
161
+ success: true;
162
+ };
163
+ outputFormat: "json";
164
+ status: import("hono/utils/http-status").ContentfulStatusCode;
165
+ };
166
+ };
167
+ } & {
168
+ "/custom-field-values": {
169
+ $get: {
170
+ input: {};
171
+ output: {
172
+ data: {
173
+ id: string;
174
+ definitionId: string;
175
+ entityType: "organization" | "person" | "opportunity" | "quote" | "activity";
176
+ entityId: string;
177
+ textValue: string | null;
178
+ numberValue: number | null;
179
+ dateValue: string | null;
180
+ booleanValue: boolean | null;
181
+ monetaryValueCents: number | null;
182
+ currencyCode: string | null;
183
+ jsonValue: string[] | {
184
+ [x: string]: import("hono/utils/types").JSONValue;
185
+ } | null;
186
+ createdAt: string;
187
+ updatedAt: string;
188
+ }[];
189
+ total: number;
190
+ limit: number;
191
+ offset: number;
192
+ };
193
+ outputFormat: "json";
194
+ status: import("hono/utils/http-status").ContentfulStatusCode;
195
+ };
196
+ };
197
+ } & {
198
+ "/custom-fields/:id/value": {
199
+ $put: {
200
+ input: {
201
+ param: {
202
+ id: string;
203
+ };
204
+ };
205
+ output: {
206
+ data: {
207
+ createdAt: string;
208
+ updatedAt: string;
209
+ entityType: "organization" | "person" | "opportunity" | "quote" | "activity";
210
+ entityId: string;
211
+ id: string;
212
+ definitionId: string;
213
+ textValue: string | null;
214
+ numberValue: number | null;
215
+ dateValue: string | null;
216
+ booleanValue: boolean | null;
217
+ monetaryValueCents: number | null;
218
+ currencyCode: string | null;
219
+ jsonValue: string[] | {
220
+ [x: string]: import("hono/utils/types").JSONValue;
221
+ } | null;
222
+ } | undefined;
223
+ };
224
+ outputFormat: "json";
225
+ status: 200;
226
+ };
227
+ };
228
+ } & {
229
+ "/custom-field-values/:id": {
230
+ $delete: {
231
+ input: {
232
+ param: {
233
+ id: string;
234
+ };
235
+ };
236
+ output: {
237
+ error: string;
238
+ };
239
+ outputFormat: "json";
240
+ status: 404;
241
+ } | {
242
+ input: {
243
+ param: {
244
+ id: string;
245
+ };
246
+ };
247
+ output: {
248
+ success: true;
249
+ };
250
+ outputFormat: "json";
251
+ status: import("hono/utils/http-status").ContentfulStatusCode;
252
+ };
253
+ };
254
+ }, "/", "/custom-field-values/:id">;
255
+ export {};
256
+ //# sourceMappingURL=custom-fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-fields.d.ts","sourceRoot":"","sources":["../../src/routes/custom-fields.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,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCA2D1B,CAAA"}
@@ -0,0 +1,46 @@
1
+ import { Hono } from "hono";
2
+ import { crmService } from "../service/index.js";
3
+ import { customFieldDefinitionListQuerySchema, customFieldValueListQuerySchema, insertCustomFieldDefinitionSchema, updateCustomFieldDefinitionSchema, upsertCustomFieldValueSchema, } from "../validation.js";
4
+ export const customFieldRoutes = new Hono()
5
+ .get("/custom-fields", async (c) => {
6
+ const query = customFieldDefinitionListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
7
+ return c.json(await crmService.listCustomFieldDefinitions(c.get("db"), query));
8
+ })
9
+ .post("/custom-fields", async (c) => {
10
+ return c.json({
11
+ data: await crmService.createCustomFieldDefinition(c.get("db"), insertCustomFieldDefinitionSchema.parse(await c.req.json())),
12
+ }, 201);
13
+ })
14
+ .get("/custom-fields/:id", async (c) => {
15
+ const row = await crmService.getCustomFieldDefinitionById(c.get("db"), c.req.param("id"));
16
+ if (!row)
17
+ return c.json({ error: "Custom field not found" }, 404);
18
+ return c.json({ data: row });
19
+ })
20
+ .patch("/custom-fields/:id", async (c) => {
21
+ const row = await crmService.updateCustomFieldDefinition(c.get("db"), c.req.param("id"), updateCustomFieldDefinitionSchema.parse(await c.req.json()));
22
+ if (!row)
23
+ return c.json({ error: "Custom field not found" }, 404);
24
+ return c.json({ data: row });
25
+ })
26
+ .delete("/custom-fields/:id", async (c) => {
27
+ const row = await crmService.deleteCustomFieldDefinition(c.get("db"), c.req.param("id"));
28
+ if (!row)
29
+ return c.json({ error: "Custom field not found" }, 404);
30
+ return c.json({ success: true });
31
+ })
32
+ .get("/custom-field-values", async (c) => {
33
+ const query = customFieldValueListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
34
+ return c.json(await crmService.listCustomFieldValues(c.get("db"), query));
35
+ })
36
+ .put("/custom-fields/:id/value", async (c) => {
37
+ return c.json({
38
+ data: await crmService.upsertCustomFieldValue(c.get("db"), c.req.param("id"), upsertCustomFieldValueSchema.parse(await c.req.json())),
39
+ }, 200);
40
+ })
41
+ .delete("/custom-field-values/:id", async (c) => {
42
+ const row = await crmService.deleteCustomFieldValue(c.get("db"), c.req.param("id"));
43
+ if (!row)
44
+ return c.json({ error: "Custom field value not found" }, 404);
45
+ return c.json({ success: true });
46
+ });