@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":"quotes.d.ts","sourceRoot":"","sources":["../../src/service/quotes.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,4BAA4B,EAC5B,wBAAwB,EACxB,iBAAiB,EACjB,oBAAoB,EACpB,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,kBAAkB,CAAA;AAGzB,KAAK,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAC1D,KAAK,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AACzD,KAAK,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AACzD,KAAK,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AAC/E,KAAK,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AACvE,KAAK,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAEvE,eAAO,MAAM,aAAa;mBACH,kBAAkB,SAAS,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA+BvC,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;o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,kBAAkB,MAAM,MAAM;;;CAO5D,CAAA"}
@@ -0,0 +1,110 @@
1
+ import { and, desc, eq, ilike, or, sql } from "drizzle-orm";
2
+ import { quoteParticipants, quoteProducts, quotes } from "../schema.js";
3
+ import { paginate } from "./helpers.js";
4
+ export const quotesService = {
5
+ async listQuotes(db, query) {
6
+ const conditions = [];
7
+ if (query.personId)
8
+ conditions.push(eq(quotes.personId, query.personId));
9
+ if (query.organizationId)
10
+ conditions.push(eq(quotes.organizationId, query.organizationId));
11
+ if (query.pipelineId)
12
+ conditions.push(eq(quotes.pipelineId, query.pipelineId));
13
+ if (query.stageId)
14
+ conditions.push(eq(quotes.stageId, query.stageId));
15
+ if (query.ownerId)
16
+ conditions.push(eq(quotes.ownerId, query.ownerId));
17
+ if (query.status)
18
+ conditions.push(eq(quotes.status, query.status));
19
+ if (query.search) {
20
+ const term = `%${query.search}%`;
21
+ conditions.push(or(ilike(quotes.title, term), ilike(quotes.source, term), ilike(quotes.sourceRef, term)));
22
+ }
23
+ const where = conditions.length ? and(...conditions) : undefined;
24
+ return paginate(db
25
+ .select()
26
+ .from(quotes)
27
+ .where(where)
28
+ .limit(query.limit)
29
+ .offset(query.offset)
30
+ .orderBy(desc(quotes.updatedAt)), db.select({ count: sql `count(*)::int` }).from(quotes).where(where), query.limit, query.offset);
31
+ },
32
+ async getQuoteById(db, id) {
33
+ const [row] = await db.select().from(quotes).where(eq(quotes.id, id)).limit(1);
34
+ return row ?? null;
35
+ },
36
+ async createQuote(db, data) {
37
+ const [row] = await db.insert(quotes).values(data).returning();
38
+ return row;
39
+ },
40
+ async updateQuote(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.update(quotes).set(patch).where(eq(quotes.id, id)).returning();
54
+ return row ?? null;
55
+ },
56
+ async deleteQuote(db, id) {
57
+ const [row] = await db.delete(quotes).where(eq(quotes.id, id)).returning({ id: quotes.id });
58
+ return row ?? null;
59
+ },
60
+ listQuoteParticipants(db, quoteId) {
61
+ return db
62
+ .select()
63
+ .from(quoteParticipants)
64
+ .where(eq(quoteParticipants.quoteId, quoteId))
65
+ .orderBy(desc(quoteParticipants.isPrimary), quoteParticipants.createdAt);
66
+ },
67
+ async createQuoteParticipant(db, quoteId, data) {
68
+ const [row] = await db
69
+ .insert(quoteParticipants)
70
+ .values({ ...data, quoteId })
71
+ .returning();
72
+ return row;
73
+ },
74
+ async deleteQuoteParticipant(db, id) {
75
+ const [row] = await db
76
+ .delete(quoteParticipants)
77
+ .where(eq(quoteParticipants.id, id))
78
+ .returning({ id: quoteParticipants.id });
79
+ return row ?? null;
80
+ },
81
+ listQuoteProducts(db, quoteId) {
82
+ return db
83
+ .select()
84
+ .from(quoteProducts)
85
+ .where(eq(quoteProducts.quoteId, quoteId))
86
+ .orderBy(quoteProducts.createdAt);
87
+ },
88
+ async createQuoteProduct(db, quoteId, data) {
89
+ const [row] = await db
90
+ .insert(quoteProducts)
91
+ .values({ ...data, quoteId })
92
+ .returning();
93
+ return row;
94
+ },
95
+ async updateQuoteProduct(db, id, data) {
96
+ const [row] = await db
97
+ .update(quoteProducts)
98
+ .set({ ...data, updatedAt: new Date() })
99
+ .where(eq(quoteProducts.id, id))
100
+ .returning();
101
+ return row ?? null;
102
+ },
103
+ async deleteQuoteProduct(db, id) {
104
+ const [row] = await db
105
+ .delete(quoteProducts)
106
+ .where(eq(quoteProducts.id, id))
107
+ .returning({ id: quoteProducts.id });
108
+ return row ?? null;
109
+ },
110
+ };
@@ -0,0 +1,2 @@
1
+ export { acceptQuoteVersionSchema, applyTripSnapshotQuoteVersionLineSchema, applyTripSnapshotToQuoteVersionSchema, declineQuoteVersionSchema, entityTypeSchema, expireQuoteVersionsSchema, insertPipelineSchema, insertQuoteParticipantSchema, insertQuoteProductSchema, insertQuoteSchema, insertQuoteVersionLineSchema, insertQuoteVersionSchema, insertStageSchema, participantRoleSchema, pipelineCoreSchema, pipelineListQuerySchema, quoteCoreSchema, quoteListQuerySchema, quoteStatusSchema, quoteVersionCoreSchema, quoteVersionLineCoreSchema, quoteVersionListQuerySchema, quoteVersionStatusSchema, sendQuoteVersionSchema, stageCoreSchema, stageListQuerySchema, updatePipelineSchema, updateQuoteProductSchema, updateQuoteSchema, updateQuoteVersionLineSchema, updateQuoteVersionSchema, updateStageSchema, } from "@voyant-travel/crm-contracts";
2
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,uCAAuC,EACvC,qCAAqC,EACrC,yBAAyB,EACzB,gBAAgB,EAChB,yBAAyB,EACzB,oBAAoB,EACpB,4BAA4B,EAC5B,wBAAwB,EACxB,iBAAiB,EACjB,4BAA4B,EAC5B,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,iBAAiB,EACjB,4BAA4B,EAC5B,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,8BAA8B,CAAA"}
@@ -0,0 +1 @@
1
+ export { acceptQuoteVersionSchema, applyTripSnapshotQuoteVersionLineSchema, applyTripSnapshotToQuoteVersionSchema, declineQuoteVersionSchema, entityTypeSchema, expireQuoteVersionsSchema, insertPipelineSchema, insertQuoteParticipantSchema, insertQuoteProductSchema, insertQuoteSchema, insertQuoteVersionLineSchema, insertQuoteVersionSchema, insertStageSchema, participantRoleSchema, pipelineCoreSchema, pipelineListQuerySchema, quoteCoreSchema, quoteListQuerySchema, quoteStatusSchema, quoteVersionCoreSchema, quoteVersionLineCoreSchema, quoteVersionListQuerySchema, quoteVersionStatusSchema, sendQuoteVersionSchema, stageCoreSchema, stageListQuerySchema, updatePipelineSchema, updateQuoteProductSchema, updateQuoteSchema, updateQuoteVersionLineSchema, updateQuoteVersionSchema, updateStageSchema, } from "@voyant-travel/crm-contracts";
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@voyant-travel/quotes",
3
+ "version": "0.119.2",
4
+ "license": "Apache-2.0",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./schema": {
13
+ "types": "./dist/schema.d.ts",
14
+ "import": "./dist/schema.js",
15
+ "default": "./dist/schema.js"
16
+ },
17
+ "./validation": {
18
+ "types": "./dist/validation.d.ts",
19
+ "import": "./dist/validation.js",
20
+ "default": "./dist/validation.js"
21
+ },
22
+ "./routes": {
23
+ "types": "./dist/routes/index.d.ts",
24
+ "import": "./dist/routes/index.js",
25
+ "default": "./dist/routes/index.js"
26
+ },
27
+ "./booking-extension": {
28
+ "types": "./dist/booking-extension.d.ts",
29
+ "import": "./dist/booking-extension.js",
30
+ "default": "./dist/booking-extension.js"
31
+ }
32
+ },
33
+ "dependencies": {
34
+ "drizzle-orm": "^0.45.2",
35
+ "hono": "^4.12.10",
36
+ "zod": "^4.3.6",
37
+ "@voyant-travel/core": "^0.109.0",
38
+ "@voyant-travel/db": "^0.108.0",
39
+ "@voyant-travel/crm-contracts": "^0.106.1",
40
+ "@voyant-travel/hono": "^0.109.1"
41
+ },
42
+ "devDependencies": {
43
+ "typescript": "^6.0.2",
44
+ "@voyant-travel/voyant-typescript-config": "^0.1.0"
45
+ },
46
+ "files": [
47
+ "dist"
48
+ ],
49
+ "publishConfig": {
50
+ "access": "public"
51
+ },
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "https://github.com/voyant-travel/voyant.git",
55
+ "directory": "packages/quotes"
56
+ },
57
+ "voyant": {
58
+ "schema": "./schema",
59
+ "requiresSchemas": [
60
+ "@voyant-travel/db"
61
+ ]
62
+ },
63
+ "scripts": {
64
+ "typecheck": "tsc --noEmit",
65
+ "lint": "biome check src/",
66
+ "test": "vitest run",
67
+ "build": "tsc -p tsconfig.json",
68
+ "clean": "rm -rf dist tsconfig.tsbuildinfo"
69
+ },
70
+ "main": "./dist/index.js",
71
+ "types": "./dist/index.d.ts"
72
+ }