@voyant-travel/quotes 0.119.2

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 (51) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +39 -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 +87 -0
  6. package/dist/index.d.ts +16 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +32 -0
  9. package/dist/routes/index.d.ts +1410 -0
  10. package/dist/routes/index.d.ts.map +1 -0
  11. package/dist/routes/index.js +8 -0
  12. package/dist/routes/pipelines.d.ts +292 -0
  13. package/dist/routes/pipelines.d.ts.map +1 -0
  14. package/dist/routes/pipelines.js +59 -0
  15. package/dist/routes/quote-versions.d.ts +746 -0
  16. package/dist/routes/quote-versions.d.ts.map +1 -0
  17. package/dist/routes/quote-versions.js +175 -0
  18. package/dist/routes/quotes.d.ts +391 -0
  19. package/dist/routes/quotes.d.ts.map +1 -0
  20. package/dist/routes/quotes.js +70 -0
  21. package/dist/schema-relations.d.ts +30 -0
  22. package/dist/schema-relations.d.ts.map +1 -0
  23. package/dist/schema-relations.js +49 -0
  24. package/dist/schema-sales.d.ts +1511 -0
  25. package/dist/schema-sales.d.ts.map +1 -0
  26. package/dist/schema-sales.js +164 -0
  27. package/dist/schema-shared.d.ts +5 -0
  28. package/dist/schema-shared.d.ts.map +1 -0
  29. package/dist/schema-shared.js +18 -0
  30. package/dist/schema.d.ts +5 -0
  31. package/dist/schema.d.ts.map +1 -0
  32. package/dist/schema.js +4 -0
  33. package/dist/service/helpers.d.ts +22 -0
  34. package/dist/service/helpers.d.ts.map +1 -0
  35. package/dist/service/helpers.js +39 -0
  36. package/dist/service/index.d.ts +1734 -0
  37. package/dist/service/index.d.ts.map +1 -0
  38. package/dist/service/index.js +11 -0
  39. package/dist/service/pipelines.d.ts +113 -0
  40. package/dist/service/pipelines.d.ts.map +1 -0
  41. package/dist/service/pipelines.js +68 -0
  42. package/dist/service/quote-versions.d.ts +674 -0
  43. package/dist/service/quote-versions.d.ts.map +1 -0
  44. package/dist/service/quote-versions.js +400 -0
  45. package/dist/service/quotes.d.ts +826 -0
  46. package/dist/service/quotes.d.ts.map +1 -0
  47. package/dist/service/quotes.js +110 -0
  48. package/dist/validation.d.ts +2 -0
  49. package/dist/validation.d.ts.map +1 -0
  50. package/dist/validation.js +1 -0
  51. package/package.json +72 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quote-versions.d.ts","sourceRoot":"","sources":["../../src/routes/quote-versions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAiBjE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCAsL3B,CAAA"}
@@ -0,0 +1,175 @@
1
+ import { parseJsonBody, parseOptionalJsonBody, parseQuery } from "@voyant-travel/hono";
2
+ import { Hono } from "hono";
3
+ import { quotesService } from "../service/index.js";
4
+ import { QuoteVersionConflictError } from "../service/quote-versions.js";
5
+ import { acceptQuoteVersionSchema, applyTripSnapshotToQuoteVersionSchema, declineQuoteVersionSchema, expireQuoteVersionsSchema, insertQuoteVersionLineSchema, insertQuoteVersionSchema, quoteVersionListQuerySchema, sendQuoteVersionSchema, updateQuoteVersionLineSchema, updateQuoteVersionSchema, } from "../validation.js";
6
+ export const quoteVersionRoutes = new Hono()
7
+ .get("/quote-versions", async (c) => {
8
+ const query = await parseQuery(c, quoteVersionListQuerySchema);
9
+ return c.json(await quotesService.listQuoteVersions(c.get("db"), query));
10
+ })
11
+ .post("/quotes/:id/versions", async (c) => {
12
+ try {
13
+ const body = await parseJsonBody(c, insertQuoteVersionSchema.omit({ quoteId: true }));
14
+ return c.json({
15
+ data: await quotesService.createQuoteVersion(c.get("db"), {
16
+ ...body,
17
+ quoteId: c.req.param("id"),
18
+ }),
19
+ }, 201);
20
+ }
21
+ catch (error) {
22
+ if (error instanceof QuoteVersionConflictError) {
23
+ return c.json({ error: error.message }, 409);
24
+ }
25
+ throw error;
26
+ }
27
+ })
28
+ .post("/quote-versions/expire", async (c) => {
29
+ return c.json({
30
+ data: await quotesService.expireQuoteVersions(c.get("db"), await parseOptionalJsonBody(c, expireQuoteVersionsSchema)),
31
+ });
32
+ })
33
+ .get("/quote-versions/:id", async (c) => {
34
+ const row = await quotesService.getQuoteVersionById(c.get("db"), c.req.param("id"));
35
+ if (!row)
36
+ return c.json({ error: "Quote version not found" }, 404);
37
+ return c.json({ data: row });
38
+ })
39
+ .patch("/quote-versions/:id", async (c) => {
40
+ try {
41
+ const row = await quotesService.updateQuoteVersion(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateQuoteVersionSchema));
42
+ if (!row)
43
+ return c.json({ error: "Quote version not found" }, 404);
44
+ return c.json({ data: row });
45
+ }
46
+ catch (error) {
47
+ if (error instanceof QuoteVersionConflictError) {
48
+ return c.json({ error: error.message }, 409);
49
+ }
50
+ throw error;
51
+ }
52
+ })
53
+ .delete("/quote-versions/:id", async (c) => {
54
+ try {
55
+ const row = await quotesService.deleteQuoteVersion(c.get("db"), c.req.param("id"));
56
+ if (!row)
57
+ return c.json({ error: "Quote version not found" }, 404);
58
+ return c.json({ success: true });
59
+ }
60
+ catch (error) {
61
+ if (error instanceof QuoteVersionConflictError) {
62
+ return c.json({ error: error.message }, 409);
63
+ }
64
+ throw error;
65
+ }
66
+ })
67
+ .post("/quote-versions/:id/trip-snapshot", async (c) => {
68
+ try {
69
+ const row = await quotesService.applyTripSnapshotToQuoteVersion(c.get("db"), c.req.param("id"), await parseJsonBody(c, applyTripSnapshotToQuoteVersionSchema));
70
+ if (!row)
71
+ return c.json({ error: "Quote version not found" }, 404);
72
+ return c.json({ data: row });
73
+ }
74
+ catch (error) {
75
+ if (error instanceof QuoteVersionConflictError) {
76
+ return c.json({ error: error.message }, 409);
77
+ }
78
+ throw error;
79
+ }
80
+ })
81
+ .post("/quote-versions/:id/send", async (c) => {
82
+ try {
83
+ const row = await quotesService.sendQuoteVersion(c.get("db"), c.req.param("id"), await parseOptionalJsonBody(c, sendQuoteVersionSchema));
84
+ if (!row)
85
+ return c.json({ error: "Quote version not found" }, 404);
86
+ return c.json({ data: row });
87
+ }
88
+ catch (error) {
89
+ if (error instanceof QuoteVersionConflictError) {
90
+ return c.json({ error: error.message }, 409);
91
+ }
92
+ throw error;
93
+ }
94
+ })
95
+ .post("/quote-versions/:id/view", async (c) => {
96
+ const row = await quotesService.markQuoteVersionViewed(c.get("db"), c.req.param("id"));
97
+ if (!row)
98
+ return c.json({ error: "Quote version not found" }, 404);
99
+ return c.json({ data: row });
100
+ })
101
+ .post("/quote-versions/:id/accept", async (c) => {
102
+ try {
103
+ const row = await quotesService.acceptQuoteVersion(c.get("db"), c.req.param("id"), await parseOptionalJsonBody(c, acceptQuoteVersionSchema));
104
+ if (!row)
105
+ return c.json({ error: "Quote version not found" }, 404);
106
+ return c.json({ data: row });
107
+ }
108
+ catch (error) {
109
+ if (error instanceof QuoteVersionConflictError) {
110
+ return c.json({ error: error.message }, 409);
111
+ }
112
+ throw error;
113
+ }
114
+ })
115
+ .post("/quote-versions/:id/decline", async (c) => {
116
+ try {
117
+ const row = await quotesService.declineQuoteVersion(c.get("db"), c.req.param("id"), await parseOptionalJsonBody(c, declineQuoteVersionSchema));
118
+ if (!row)
119
+ return c.json({ error: "Quote version not found" }, 404);
120
+ return c.json({ data: row });
121
+ }
122
+ catch (error) {
123
+ if (error instanceof QuoteVersionConflictError) {
124
+ return c.json({ error: error.message }, 409);
125
+ }
126
+ throw error;
127
+ }
128
+ })
129
+ .get("/quote-versions/:id/lines", async (c) => {
130
+ return c.json({
131
+ data: await quotesService.listQuoteVersionLines(c.get("db"), c.req.param("id")),
132
+ });
133
+ })
134
+ .post("/quote-versions/:id/lines", async (c) => {
135
+ try {
136
+ const row = await quotesService.createQuoteVersionLine(c.get("db"), c.req.param("id"), await parseJsonBody(c, insertQuoteVersionLineSchema));
137
+ if (!row)
138
+ return c.json({ error: "Quote version not found" }, 404);
139
+ return c.json({ data: row }, 201);
140
+ }
141
+ catch (error) {
142
+ if (error instanceof QuoteVersionConflictError) {
143
+ return c.json({ error: error.message }, 409);
144
+ }
145
+ throw error;
146
+ }
147
+ })
148
+ .patch("/quote-version-lines/:id", async (c) => {
149
+ try {
150
+ const row = await quotesService.updateQuoteVersionLine(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateQuoteVersionLineSchema));
151
+ if (!row)
152
+ return c.json({ error: "Quote version line not found" }, 404);
153
+ return c.json({ data: row });
154
+ }
155
+ catch (error) {
156
+ if (error instanceof QuoteVersionConflictError) {
157
+ return c.json({ error: error.message }, 409);
158
+ }
159
+ throw error;
160
+ }
161
+ })
162
+ .delete("/quote-version-lines/:id", async (c) => {
163
+ try {
164
+ const row = await quotesService.deleteQuoteVersionLine(c.get("db"), c.req.param("id"));
165
+ if (!row)
166
+ return c.json({ error: "Quote version line not found" }, 404);
167
+ return c.json({ success: true });
168
+ }
169
+ catch (error) {
170
+ if (error instanceof QuoteVersionConflictError) {
171
+ return c.json({ error: error.message }, 409);
172
+ }
173
+ throw error;
174
+ }
175
+ });
@@ -0,0 +1,391 @@
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 quoteRoutes: import("hono/hono-base").HonoBase<Env, {
9
+ "/quotes": {
10
+ $get: {
11
+ input: {};
12
+ output: {
13
+ data: {
14
+ id: string;
15
+ title: string;
16
+ personId: string | null;
17
+ organizationId: string | null;
18
+ pipelineId: string;
19
+ stageId: string;
20
+ ownerId: string | null;
21
+ status: "open" | "won" | "lost" | "archived";
22
+ acceptedVersionId: string | null;
23
+ valueAmountCents: number | null;
24
+ valueCurrency: string | null;
25
+ expectedCloseDate: string | null;
26
+ source: string | null;
27
+ sourceRef: string | null;
28
+ lostReason: string | null;
29
+ tags: string[];
30
+ createdAt: string;
31
+ updatedAt: string;
32
+ stageChangedAt: string;
33
+ closedAt: string | null;
34
+ }[];
35
+ total: number;
36
+ limit: number;
37
+ offset: number;
38
+ };
39
+ outputFormat: "json";
40
+ status: import("hono/utils/http-status").ContentfulStatusCode;
41
+ };
42
+ };
43
+ } & {
44
+ "/quotes": {
45
+ $post: {
46
+ input: {};
47
+ output: {
48
+ data: {
49
+ createdAt: string;
50
+ updatedAt: string;
51
+ id: string;
52
+ title: string;
53
+ pipelineId: string;
54
+ personId: string | null;
55
+ organizationId: string | null;
56
+ stageId: string;
57
+ ownerId: string | null;
58
+ status: "open" | "won" | "lost" | "archived";
59
+ acceptedVersionId: string | null;
60
+ valueAmountCents: number | null;
61
+ valueCurrency: string | null;
62
+ expectedCloseDate: string | null;
63
+ source: string | null;
64
+ sourceRef: string | null;
65
+ lostReason: string | null;
66
+ tags: string[];
67
+ stageChangedAt: string;
68
+ closedAt: string | null;
69
+ } | undefined;
70
+ };
71
+ outputFormat: "json";
72
+ status: 201;
73
+ };
74
+ };
75
+ } & {
76
+ "/quotes/:id": {
77
+ $get: {
78
+ input: {
79
+ param: {
80
+ id: string;
81
+ };
82
+ };
83
+ output: {
84
+ error: string;
85
+ };
86
+ outputFormat: "json";
87
+ status: 404;
88
+ } | {
89
+ input: {
90
+ param: {
91
+ id: string;
92
+ };
93
+ };
94
+ output: {
95
+ data: {
96
+ id: string;
97
+ title: string;
98
+ personId: string | null;
99
+ organizationId: string | null;
100
+ pipelineId: string;
101
+ stageId: string;
102
+ ownerId: string | null;
103
+ status: "open" | "won" | "lost" | "archived";
104
+ acceptedVersionId: string | null;
105
+ valueAmountCents: number | null;
106
+ valueCurrency: string | null;
107
+ expectedCloseDate: string | null;
108
+ source: string | null;
109
+ sourceRef: string | null;
110
+ lostReason: string | null;
111
+ tags: string[];
112
+ createdAt: string;
113
+ updatedAt: string;
114
+ stageChangedAt: string;
115
+ closedAt: string | null;
116
+ };
117
+ };
118
+ outputFormat: "json";
119
+ status: import("hono/utils/http-status").ContentfulStatusCode;
120
+ };
121
+ };
122
+ } & {
123
+ "/quotes/:id": {
124
+ $patch: {
125
+ input: {
126
+ param: {
127
+ id: string;
128
+ };
129
+ };
130
+ output: {
131
+ error: string;
132
+ };
133
+ outputFormat: "json";
134
+ status: 404;
135
+ } | {
136
+ input: {
137
+ param: {
138
+ id: string;
139
+ };
140
+ };
141
+ output: {
142
+ data: {
143
+ id: string;
144
+ title: string;
145
+ personId: string | null;
146
+ organizationId: string | null;
147
+ pipelineId: string;
148
+ stageId: string;
149
+ ownerId: string | null;
150
+ status: "open" | "won" | "lost" | "archived";
151
+ acceptedVersionId: string | null;
152
+ valueAmountCents: number | null;
153
+ valueCurrency: string | null;
154
+ expectedCloseDate: string | null;
155
+ source: string | null;
156
+ sourceRef: string | null;
157
+ lostReason: string | null;
158
+ tags: string[];
159
+ createdAt: string;
160
+ updatedAt: string;
161
+ stageChangedAt: string;
162
+ closedAt: string | null;
163
+ };
164
+ };
165
+ outputFormat: "json";
166
+ status: import("hono/utils/http-status").ContentfulStatusCode;
167
+ };
168
+ };
169
+ } & {
170
+ "/quotes/:id": {
171
+ $delete: {
172
+ input: {
173
+ param: {
174
+ id: string;
175
+ };
176
+ };
177
+ output: {
178
+ error: string;
179
+ };
180
+ outputFormat: "json";
181
+ status: 404;
182
+ } | {
183
+ input: {
184
+ param: {
185
+ id: string;
186
+ };
187
+ };
188
+ output: {
189
+ success: true;
190
+ };
191
+ outputFormat: "json";
192
+ status: import("hono/utils/http-status").ContentfulStatusCode;
193
+ };
194
+ };
195
+ } & {
196
+ "/quotes/:id/participants": {
197
+ $get: {
198
+ input: {
199
+ param: {
200
+ id: string;
201
+ };
202
+ };
203
+ output: {
204
+ data: {
205
+ id: string;
206
+ quoteId: string;
207
+ personId: string;
208
+ role: "traveler" | "booker" | "decision_maker" | "finance" | "other";
209
+ isPrimary: boolean;
210
+ createdAt: string;
211
+ }[];
212
+ };
213
+ outputFormat: "json";
214
+ status: import("hono/utils/http-status").ContentfulStatusCode;
215
+ };
216
+ };
217
+ } & {
218
+ "/quotes/:id/participants": {
219
+ $post: {
220
+ input: {
221
+ param: {
222
+ id: string;
223
+ };
224
+ };
225
+ output: {
226
+ data: {
227
+ quoteId: string;
228
+ createdAt: string;
229
+ id: string;
230
+ personId: string;
231
+ role: "traveler" | "booker" | "decision_maker" | "finance" | "other";
232
+ isPrimary: boolean;
233
+ } | undefined;
234
+ };
235
+ outputFormat: "json";
236
+ status: 201;
237
+ };
238
+ };
239
+ } & {
240
+ "/quote-participants/:id": {
241
+ $delete: {
242
+ input: {
243
+ param: {
244
+ id: string;
245
+ };
246
+ };
247
+ output: {
248
+ error: string;
249
+ };
250
+ outputFormat: "json";
251
+ status: 404;
252
+ } | {
253
+ input: {
254
+ param: {
255
+ id: string;
256
+ };
257
+ };
258
+ output: {
259
+ success: true;
260
+ };
261
+ outputFormat: "json";
262
+ status: import("hono/utils/http-status").ContentfulStatusCode;
263
+ };
264
+ };
265
+ } & {
266
+ "/quotes/:id/products": {
267
+ $get: {
268
+ input: {
269
+ param: {
270
+ id: string;
271
+ };
272
+ };
273
+ output: {
274
+ data: {
275
+ id: string;
276
+ quoteId: string;
277
+ productId: string | null;
278
+ supplierServiceId: string | null;
279
+ nameSnapshot: string;
280
+ description: string | null;
281
+ quantity: number;
282
+ unitPriceAmountCents: number | null;
283
+ costAmountCents: number | null;
284
+ currency: string | null;
285
+ discountAmountCents: number | null;
286
+ createdAt: string;
287
+ updatedAt: string;
288
+ }[];
289
+ };
290
+ outputFormat: "json";
291
+ status: import("hono/utils/http-status").ContentfulStatusCode;
292
+ };
293
+ };
294
+ } & {
295
+ "/quotes/:id/products": {
296
+ $post: {
297
+ input: {
298
+ param: {
299
+ id: string;
300
+ };
301
+ };
302
+ output: {
303
+ data: {
304
+ quoteId: string;
305
+ createdAt: string;
306
+ updatedAt: string;
307
+ description: string | null;
308
+ id: string;
309
+ productId: string | null;
310
+ supplierServiceId: string | null;
311
+ nameSnapshot: string;
312
+ quantity: number;
313
+ unitPriceAmountCents: number | null;
314
+ costAmountCents: number | null;
315
+ currency: string | null;
316
+ discountAmountCents: number | null;
317
+ } | undefined;
318
+ };
319
+ outputFormat: "json";
320
+ status: 201;
321
+ };
322
+ };
323
+ } & {
324
+ "/quote-products/:id": {
325
+ $patch: {
326
+ input: {
327
+ param: {
328
+ id: string;
329
+ };
330
+ };
331
+ output: {
332
+ error: string;
333
+ };
334
+ outputFormat: "json";
335
+ status: 404;
336
+ } | {
337
+ input: {
338
+ param: {
339
+ id: string;
340
+ };
341
+ };
342
+ output: {
343
+ data: {
344
+ id: string;
345
+ quoteId: string;
346
+ productId: string | null;
347
+ supplierServiceId: string | null;
348
+ nameSnapshot: string;
349
+ description: string | null;
350
+ quantity: number;
351
+ unitPriceAmountCents: number | null;
352
+ costAmountCents: number | null;
353
+ currency: string | null;
354
+ discountAmountCents: number | null;
355
+ createdAt: string;
356
+ updatedAt: string;
357
+ };
358
+ };
359
+ outputFormat: "json";
360
+ status: import("hono/utils/http-status").ContentfulStatusCode;
361
+ };
362
+ };
363
+ } & {
364
+ "/quote-products/:id": {
365
+ $delete: {
366
+ input: {
367
+ param: {
368
+ id: string;
369
+ };
370
+ };
371
+ output: {
372
+ error: string;
373
+ };
374
+ outputFormat: "json";
375
+ status: 404;
376
+ } | {
377
+ input: {
378
+ param: {
379
+ id: string;
380
+ };
381
+ };
382
+ output: {
383
+ success: true;
384
+ };
385
+ outputFormat: "json";
386
+ status: import("hono/utils/http-status").ContentfulStatusCode;
387
+ };
388
+ };
389
+ }, "/", "/quote-products/:id">;
390
+ export {};
391
+ //# sourceMappingURL=quotes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quotes.d.ts","sourceRoot":"","sources":["../../src/routes/quotes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAajE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAuFpB,CAAA"}
@@ -0,0 +1,70 @@
1
+ import { parseJsonBody, parseQuery } from "@voyant-travel/hono";
2
+ import { Hono } from "hono";
3
+ import { quotesService } from "../service/index.js";
4
+ import { insertQuoteParticipantSchema, insertQuoteProductSchema, insertQuoteSchema, quoteListQuerySchema, updateQuoteProductSchema, updateQuoteSchema, } from "../validation.js";
5
+ export const quoteRoutes = new Hono()
6
+ .get("/quotes", async (c) => {
7
+ const query = await parseQuery(c, quoteListQuerySchema);
8
+ return c.json(await quotesService.listQuotes(c.get("db"), query));
9
+ })
10
+ .post("/quotes", async (c) => {
11
+ return c.json({
12
+ data: await quotesService.createQuote(c.get("db"), await parseJsonBody(c, insertQuoteSchema)),
13
+ }, 201);
14
+ })
15
+ .get("/quotes/:id", async (c) => {
16
+ const row = await quotesService.getQuoteById(c.get("db"), c.req.param("id"));
17
+ if (!row)
18
+ return c.json({ error: "Quote not found" }, 404);
19
+ return c.json({ data: row });
20
+ })
21
+ .patch("/quotes/:id", async (c) => {
22
+ const row = await quotesService.updateQuote(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateQuoteSchema));
23
+ if (!row)
24
+ return c.json({ error: "Quote not found" }, 404);
25
+ return c.json({ data: row });
26
+ })
27
+ .delete("/quotes/:id", async (c) => {
28
+ const row = await quotesService.deleteQuote(c.get("db"), c.req.param("id"));
29
+ if (!row)
30
+ return c.json({ error: "Quote not found" }, 404);
31
+ return c.json({ success: true });
32
+ })
33
+ .get("/quotes/:id/participants", async (c) => {
34
+ return c.json({
35
+ data: await quotesService.listQuoteParticipants(c.get("db"), c.req.param("id")),
36
+ });
37
+ })
38
+ .post("/quotes/:id/participants", async (c) => {
39
+ return c.json({
40
+ data: await quotesService.createQuoteParticipant(c.get("db"), c.req.param("id"), await parseJsonBody(c, insertQuoteParticipantSchema)),
41
+ }, 201);
42
+ })
43
+ .delete("/quote-participants/:id", async (c) => {
44
+ const row = await quotesService.deleteQuoteParticipant(c.get("db"), c.req.param("id"));
45
+ if (!row)
46
+ return c.json({ error: "Quote participant not found" }, 404);
47
+ return c.json({ success: true });
48
+ })
49
+ .get("/quotes/:id/products", async (c) => {
50
+ return c.json({
51
+ data: await quotesService.listQuoteProducts(c.get("db"), c.req.param("id")),
52
+ });
53
+ })
54
+ .post("/quotes/:id/products", async (c) => {
55
+ return c.json({
56
+ data: await quotesService.createQuoteProduct(c.get("db"), c.req.param("id"), await parseJsonBody(c, insertQuoteProductSchema)),
57
+ }, 201);
58
+ })
59
+ .patch("/quote-products/:id", async (c) => {
60
+ const row = await quotesService.updateQuoteProduct(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateQuoteProductSchema));
61
+ if (!row)
62
+ return c.json({ error: "Quote product not found" }, 404);
63
+ return c.json({ data: row });
64
+ })
65
+ .delete("/quote-products/:id", async (c) => {
66
+ const row = await quotesService.deleteQuoteProduct(c.get("db"), c.req.param("id"));
67
+ if (!row)
68
+ return c.json({ error: "Quote product not found" }, 404);
69
+ return c.json({ success: true });
70
+ });
@@ -0,0 +1,30 @@
1
+ export declare const pipelinesRelations: import("drizzle-orm").Relations<"pipelines", {
2
+ stages: import("drizzle-orm").Many<"stages">;
3
+ quotes: import("drizzle-orm").Many<"quotes">;
4
+ }>;
5
+ export declare const stagesRelations: import("drizzle-orm").Relations<"stages", {
6
+ pipeline: import("drizzle-orm").One<"pipelines", true>;
7
+ quotes: import("drizzle-orm").Many<"quotes">;
8
+ }>;
9
+ export declare const quotesRelations: import("drizzle-orm").Relations<"quotes", {
10
+ pipeline: import("drizzle-orm").One<"pipelines", true>;
11
+ stage: import("drizzle-orm").One<"stages", true>;
12
+ participants: import("drizzle-orm").Many<"quote_participants">;
13
+ products: import("drizzle-orm").Many<"quote_products">;
14
+ versions: import("drizzle-orm").Many<"quote_versions">;
15
+ }>;
16
+ export declare const quoteParticipantsRelations: import("drizzle-orm").Relations<"quote_participants", {
17
+ quote: import("drizzle-orm").One<"quotes", true>;
18
+ }>;
19
+ export declare const quoteProductsRelations: import("drizzle-orm").Relations<"quote_products", {
20
+ quote: import("drizzle-orm").One<"quotes", true>;
21
+ }>;
22
+ export declare const quoteVersionsRelations: import("drizzle-orm").Relations<"quote_versions", {
23
+ quote: import("drizzle-orm").One<"quotes", true>;
24
+ supersedes: import("drizzle-orm").One<"quote_versions", false>;
25
+ lines: import("drizzle-orm").Many<"quote_version_lines">;
26
+ }>;
27
+ export declare const quoteVersionLinesRelations: import("drizzle-orm").Relations<"quote_version_lines", {
28
+ quoteVersion: import("drizzle-orm").One<"quote_versions", true>;
29
+ }>;
30
+ //# sourceMappingURL=schema-relations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-relations.d.ts","sourceRoot":"","sources":["../src/schema-relations.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,kBAAkB;;;EAG5B,CAAA;AAEH,eAAO,MAAM,eAAe;;;EAGzB,CAAA;AAEH,eAAO,MAAM,eAAe;;;;;;EASzB,CAAA;AAEH,eAAO,MAAM,0BAA0B;;EAKpC,CAAA;AAEH,eAAO,MAAM,sBAAsB;;EAKhC,CAAA;AAEH,eAAO,MAAM,sBAAsB;;;;EAUhC,CAAA;AAEH,eAAO,MAAM,0BAA0B;;EAKpC,CAAA"}