@voyant-travel/commerce 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 (210) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +145 -0
  3. package/dist/accepted-quote-version-reservation-golden-flow.test.d.ts +2 -0
  4. package/dist/accepted-quote-version-reservation-golden-flow.test.d.ts.map +1 -0
  5. package/dist/accepted-quote-version-reservation-golden-flow.test.js +398 -0
  6. package/dist/index.d.ts +15 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +14 -0
  9. package/dist/interface.d.ts +18 -0
  10. package/dist/interface.d.ts.map +1 -0
  11. package/dist/interface.js +246 -0
  12. package/dist/interface.test.d.ts +2 -0
  13. package/dist/interface.test.d.ts.map +1 -0
  14. package/dist/interface.test.js +357 -0
  15. package/dist/markets/index.d.ts +11 -0
  16. package/dist/markets/index.d.ts.map +1 -0
  17. package/dist/markets/index.js +12 -0
  18. package/dist/markets/routes.d.ts +1182 -0
  19. package/dist/markets/routes.d.ts.map +1 -0
  20. package/dist/markets/routes.js +209 -0
  21. package/dist/markets/schema.d.ts +1527 -0
  22. package/dist/markets/schema.d.ts.map +1 -0
  23. package/dist/markets/schema.js +240 -0
  24. package/dist/markets/service-core.d.ts +253 -0
  25. package/dist/markets/service-core.d.ts.map +1 -0
  26. package/dist/markets/service-core.js +242 -0
  27. package/dist/markets/service-rules.d.ts +191 -0
  28. package/dist/markets/service-rules.d.ts.map +1 -0
  29. package/dist/markets/service-rules.js +155 -0
  30. package/dist/markets/service-shared.d.ts +36 -0
  31. package/dist/markets/service-shared.d.ts.map +1 -0
  32. package/dist/markets/service-shared.js +7 -0
  33. package/dist/markets/service.d.ts +43 -0
  34. package/dist/markets/service.d.ts.map +1 -0
  35. package/dist/markets/service.js +42 -0
  36. package/dist/markets/validation.d.ts +451 -0
  37. package/dist/markets/validation.d.ts.map +1 -0
  38. package/dist/markets/validation.js +160 -0
  39. package/dist/pricing/events.d.ts +53 -0
  40. package/dist/pricing/events.d.ts.map +1 -0
  41. package/dist/pricing/events.js +28 -0
  42. package/dist/pricing/index.d.ts +15 -0
  43. package/dist/pricing/index.d.ts.map +1 -0
  44. package/dist/pricing/index.js +18 -0
  45. package/dist/pricing/routes-core.d.ts +981 -0
  46. package/dist/pricing/routes-core.d.ts.map +1 -0
  47. package/dist/pricing/routes-core.js +102 -0
  48. package/dist/pricing/routes-public.d.ts +136 -0
  49. package/dist/pricing/routes-public.d.ts.map +1 -0
  50. package/dist/pricing/routes-public.js +14 -0
  51. package/dist/pricing/routes-rules.d.ts +1339 -0
  52. package/dist/pricing/routes-rules.d.ts.map +1 -0
  53. package/dist/pricing/routes-rules.js +138 -0
  54. package/dist/pricing/routes-shared.d.ts +14 -0
  55. package/dist/pricing/routes-shared.d.ts.map +1 -0
  56. package/dist/pricing/routes-shared.js +3 -0
  57. package/dist/pricing/routes.d.ts +7 -0
  58. package/dist/pricing/routes.d.ts.map +1 -0
  59. package/dist/pricing/routes.js +6 -0
  60. package/dist/pricing/schema-catalogs.d.ts +467 -0
  61. package/dist/pricing/schema-catalogs.d.ts.map +1 -0
  62. package/dist/pricing/schema-catalogs.js +47 -0
  63. package/dist/pricing/schema-categories.d.ts +497 -0
  64. package/dist/pricing/schema-categories.d.ts.map +1 -0
  65. package/dist/pricing/schema-categories.js +54 -0
  66. package/dist/pricing/schema-departure-overrides.d.ts +228 -0
  67. package/dist/pricing/schema-departure-overrides.d.ts.map +1 -0
  68. package/dist/pricing/schema-departure-overrides.js +36 -0
  69. package/dist/pricing/schema-option-rules.d.ts +1770 -0
  70. package/dist/pricing/schema-option-rules.d.ts.map +1 -0
  71. package/dist/pricing/schema-option-rules.js +181 -0
  72. package/dist/pricing/schema-policies.d.ts +395 -0
  73. package/dist/pricing/schema-policies.d.ts.map +1 -0
  74. package/dist/pricing/schema-policies.js +41 -0
  75. package/dist/pricing/schema-relations.d.ts +59 -0
  76. package/dist/pricing/schema-relations.d.ts.map +1 -0
  77. package/dist/pricing/schema-relations.js +111 -0
  78. package/dist/pricing/schema-shared.d.ts +11 -0
  79. package/dist/pricing/schema-shared.d.ts.map +1 -0
  80. package/dist/pricing/schema-shared.js +67 -0
  81. package/dist/pricing/schema.d.ts +8 -0
  82. package/dist/pricing/schema.d.ts.map +1 -0
  83. package/dist/pricing/schema.js +7 -0
  84. package/dist/pricing/service-catalog-plane-pricing.d.ts +95 -0
  85. package/dist/pricing/service-catalog-plane-pricing.d.ts.map +1 -0
  86. package/dist/pricing/service-catalog-plane-pricing.js +382 -0
  87. package/dist/pricing/service-catalogs.d.ts +139 -0
  88. package/dist/pricing/service-catalogs.d.ts.map +1 -0
  89. package/dist/pricing/service-catalogs.js +89 -0
  90. package/dist/pricing/service-categories.d.ts +147 -0
  91. package/dist/pricing/service-categories.d.ts.map +1 -0
  92. package/dist/pricing/service-categories.js +105 -0
  93. package/dist/pricing/service-departure-overrides.d.ts +67 -0
  94. package/dist/pricing/service-departure-overrides.d.ts.map +1 -0
  95. package/dist/pricing/service-departure-overrides.js +54 -0
  96. package/dist/pricing/service-option-rules.d.ts +321 -0
  97. package/dist/pricing/service-option-rules.d.ts.map +1 -0
  98. package/dist/pricing/service-option-rules.js +340 -0
  99. package/dist/pricing/service-policies.d.ts +123 -0
  100. package/dist/pricing/service-policies.d.ts.map +1 -0
  101. package/dist/pricing/service-policies.js +95 -0
  102. package/dist/pricing/service-public.d.ts +89 -0
  103. package/dist/pricing/service-public.d.ts.map +1 -0
  104. package/dist/pricing/service-public.js +473 -0
  105. package/dist/pricing/service-rule-resolver.d.ts +67 -0
  106. package/dist/pricing/service-rule-resolver.d.ts.map +1 -0
  107. package/dist/pricing/service-rule-resolver.js +204 -0
  108. package/dist/pricing/service-shared.d.ts +53 -0
  109. package/dist/pricing/service-shared.d.ts.map +1 -0
  110. package/dist/pricing/service-shared.js +4 -0
  111. package/dist/pricing/service-transfer-rules.d.ts +211 -0
  112. package/dist/pricing/service-transfer-rules.d.ts.map +1 -0
  113. package/dist/pricing/service-transfer-rules.js +139 -0
  114. package/dist/pricing/service.d.ts +79 -0
  115. package/dist/pricing/service.d.ts.map +1 -0
  116. package/dist/pricing/service.js +78 -0
  117. package/dist/pricing/validation-public.d.ts +412 -0
  118. package/dist/pricing/validation-public.d.ts.map +1 -0
  119. package/dist/pricing/validation-public.js +111 -0
  120. package/dist/pricing/validation-shared.d.ts +71 -0
  121. package/dist/pricing/validation-shared.d.ts.map +1 -0
  122. package/dist/pricing/validation-shared.js +63 -0
  123. package/dist/pricing/validation.d.ts +987 -0
  124. package/dist/pricing/validation.d.ts.map +1 -0
  125. package/dist/pricing/validation.js +307 -0
  126. package/dist/promotions/events.d.ts +38 -0
  127. package/dist/promotions/events.d.ts.map +1 -0
  128. package/dist/promotions/events.js +25 -0
  129. package/dist/promotions/index.d.ts +12 -0
  130. package/dist/promotions/index.d.ts.map +1 -0
  131. package/dist/promotions/index.js +17 -0
  132. package/dist/promotions/routes-shared.d.ts +14 -0
  133. package/dist/promotions/routes-shared.d.ts.map +1 -0
  134. package/dist/promotions/routes-shared.js +3 -0
  135. package/dist/promotions/routes.d.ts +395 -0
  136. package/dist/promotions/routes.d.ts.map +1 -0
  137. package/dist/promotions/routes.js +55 -0
  138. package/dist/promotions/schema.d.ts +675 -0
  139. package/dist/promotions/schema.d.ts.map +1 -0
  140. package/dist/promotions/schema.js +126 -0
  141. package/dist/promotions/service-booking-confirmed.d.ts +77 -0
  142. package/dist/promotions/service-booking-confirmed.d.ts.map +1 -0
  143. package/dist/promotions/service-booking-confirmed.js +134 -0
  144. package/dist/promotions/service-boundary-scheduler.d.ts +85 -0
  145. package/dist/promotions/service-boundary-scheduler.d.ts.map +1 -0
  146. package/dist/promotions/service-boundary-scheduler.js +141 -0
  147. package/dist/promotions/service-catalog-evaluator.d.ts +22 -0
  148. package/dist/promotions/service-catalog-evaluator.d.ts.map +1 -0
  149. package/dist/promotions/service-catalog-evaluator.js +33 -0
  150. package/dist/promotions/service-catalog-plane-promotions.d.ts +73 -0
  151. package/dist/promotions/service-catalog-plane-promotions.d.ts.map +1 -0
  152. package/dist/promotions/service-catalog-plane-promotions.js +118 -0
  153. package/dist/promotions/service-evaluator.d.ts +134 -0
  154. package/dist/promotions/service-evaluator.d.ts.map +1 -0
  155. package/dist/promotions/service-evaluator.js +302 -0
  156. package/dist/promotions/service-storefront.d.ts +147 -0
  157. package/dist/promotions/service-storefront.d.ts.map +1 -0
  158. package/dist/promotions/service-storefront.js +326 -0
  159. package/dist/promotions/service.d.ts +143 -0
  160. package/dist/promotions/service.d.ts.map +1 -0
  161. package/dist/promotions/service.js +359 -0
  162. package/dist/promotions/validation.d.ts +195 -0
  163. package/dist/promotions/validation.d.ts.map +1 -0
  164. package/dist/promotions/validation.js +167 -0
  165. package/dist/promotions/workflow-bulk-reindex.d.ts +36 -0
  166. package/dist/promotions/workflow-bulk-reindex.d.ts.map +1 -0
  167. package/dist/promotions/workflow-bulk-reindex.js +53 -0
  168. package/dist/promotions/workflow-runtime.d.ts +17 -0
  169. package/dist/promotions/workflow-runtime.d.ts.map +1 -0
  170. package/dist/promotions/workflow-runtime.js +9 -0
  171. package/dist/runtime.d.ts +18 -0
  172. package/dist/runtime.d.ts.map +1 -0
  173. package/dist/runtime.js +27 -0
  174. package/dist/runtime.test.d.ts +2 -0
  175. package/dist/runtime.test.d.ts.map +1 -0
  176. package/dist/runtime.test.js +25 -0
  177. package/dist/schema.d.ts +5 -0
  178. package/dist/schema.d.ts.map +1 -0
  179. package/dist/schema.js +4 -0
  180. package/dist/sellability/index.d.ts +13 -0
  181. package/dist/sellability/index.d.ts.map +1 -0
  182. package/dist/sellability/index.js +17 -0
  183. package/dist/sellability/routes.d.ts +2332 -0
  184. package/dist/sellability/routes.d.ts.map +1 -0
  185. package/dist/sellability/routes.js +166 -0
  186. package/dist/sellability/schema.d.ts +1716 -0
  187. package/dist/sellability/schema.d.ts.map +1 -0
  188. package/dist/sellability/schema.js +278 -0
  189. package/dist/sellability/service-records.d.ts +316 -0
  190. package/dist/sellability/service-records.d.ts.map +1 -0
  191. package/dist/sellability/service-records.js +253 -0
  192. package/dist/sellability/service-resolve.d.ts +72 -0
  193. package/dist/sellability/service-resolve.d.ts.map +1 -0
  194. package/dist/sellability/service-resolve.js +580 -0
  195. package/dist/sellability/service-shared.d.ts +124 -0
  196. package/dist/sellability/service-shared.d.ts.map +1 -0
  197. package/dist/sellability/service-shared.js +96 -0
  198. package/dist/sellability/service-snapshots.d.ts +191 -0
  199. package/dist/sellability/service-snapshots.d.ts.map +1 -0
  200. package/dist/sellability/service-snapshots.js +153 -0
  201. package/dist/sellability/service.d.ts +1038 -0
  202. package/dist/sellability/service.d.ts.map +1 -0
  203. package/dist/sellability/service.js +17 -0
  204. package/dist/sellability/validation.d.ts +477 -0
  205. package/dist/sellability/validation.d.ts.map +1 -0
  206. package/dist/sellability/validation.js +192 -0
  207. package/dist/types.d.ts +239 -0
  208. package/dist/types.d.ts.map +1 -0
  209. package/dist/types.js +1 -0
  210. package/package.json +62 -0
@@ -0,0 +1,147 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import type { CreatePricingCategoryDependencyInput, CreatePricingCategoryInput, PricingCategoryDependencyListQuery, PricingCategoryListQuery, UpdatePricingCategoryDependencyInput, UpdatePricingCategoryInput } from "./service-shared.js";
3
+ export declare function listPricingCategories(db: PostgresJsDatabase, query: PricingCategoryListQuery): Promise<{
4
+ data: {
5
+ id: string;
6
+ productId: string | null;
7
+ optionId: string | null;
8
+ unitId: string | null;
9
+ code: string | null;
10
+ name: string;
11
+ categoryType: "service" | "other" | "adult" | "child" | "infant" | "senior" | "group" | "room" | "vehicle";
12
+ seatOccupancy: number;
13
+ groupSize: number | null;
14
+ isAgeQualified: boolean;
15
+ minAge: number | null;
16
+ maxAge: number | null;
17
+ internalUseOnly: boolean;
18
+ active: boolean;
19
+ sortOrder: number;
20
+ metadata: Record<string, unknown> | null;
21
+ createdAt: Date;
22
+ updatedAt: Date;
23
+ }[];
24
+ total: number;
25
+ limit: number;
26
+ offset: number;
27
+ }>;
28
+ export declare function getPricingCategoryById(db: PostgresJsDatabase, id: string): Promise<{
29
+ id: string;
30
+ productId: string | null;
31
+ optionId: string | null;
32
+ unitId: string | null;
33
+ code: string | null;
34
+ name: string;
35
+ categoryType: "service" | "other" | "adult" | "child" | "infant" | "senior" | "group" | "room" | "vehicle";
36
+ seatOccupancy: number;
37
+ groupSize: number | null;
38
+ isAgeQualified: boolean;
39
+ minAge: number | null;
40
+ maxAge: number | null;
41
+ internalUseOnly: boolean;
42
+ active: boolean;
43
+ sortOrder: number;
44
+ metadata: Record<string, unknown> | null;
45
+ createdAt: Date;
46
+ updatedAt: Date;
47
+ } | null>;
48
+ export declare function createPricingCategory(db: PostgresJsDatabase, data: CreatePricingCategoryInput): Promise<{
49
+ metadata: Record<string, unknown> | null;
50
+ id: string;
51
+ name: string;
52
+ createdAt: Date;
53
+ code: string | null;
54
+ updatedAt: Date;
55
+ active: boolean;
56
+ sortOrder: number;
57
+ productId: string | null;
58
+ optionId: string | null;
59
+ unitId: string | null;
60
+ categoryType: "service" | "other" | "adult" | "child" | "infant" | "senior" | "group" | "room" | "vehicle";
61
+ seatOccupancy: number;
62
+ groupSize: number | null;
63
+ isAgeQualified: boolean;
64
+ minAge: number | null;
65
+ maxAge: number | null;
66
+ internalUseOnly: boolean;
67
+ } | null>;
68
+ export declare function updatePricingCategory(db: PostgresJsDatabase, id: string, data: UpdatePricingCategoryInput): Promise<{
69
+ id: string;
70
+ productId: string | null;
71
+ optionId: string | null;
72
+ unitId: string | null;
73
+ code: string | null;
74
+ name: string;
75
+ categoryType: "service" | "other" | "adult" | "child" | "infant" | "senior" | "group" | "room" | "vehicle";
76
+ seatOccupancy: number;
77
+ groupSize: number | null;
78
+ isAgeQualified: boolean;
79
+ minAge: number | null;
80
+ maxAge: number | null;
81
+ internalUseOnly: boolean;
82
+ active: boolean;
83
+ sortOrder: number;
84
+ metadata: Record<string, unknown> | null;
85
+ createdAt: Date;
86
+ updatedAt: Date;
87
+ } | null>;
88
+ export declare function deletePricingCategory(db: PostgresJsDatabase, id: string): Promise<{
89
+ id: string;
90
+ } | null>;
91
+ export declare function listPricingCategoryDependencies(db: PostgresJsDatabase, query: PricingCategoryDependencyListQuery): Promise<{
92
+ data: {
93
+ id: string;
94
+ pricingCategoryId: string;
95
+ masterPricingCategoryId: string;
96
+ dependencyType: "requires" | "limits_per_master" | "limits_sum" | "excludes";
97
+ maxPerMaster: number | null;
98
+ maxDependentSum: number | null;
99
+ active: boolean;
100
+ notes: string | null;
101
+ createdAt: Date;
102
+ updatedAt: Date;
103
+ }[];
104
+ total: number;
105
+ limit: number;
106
+ offset: number;
107
+ }>;
108
+ export declare function getPricingCategoryDependencyById(db: PostgresJsDatabase, id: string): Promise<{
109
+ id: string;
110
+ pricingCategoryId: string;
111
+ masterPricingCategoryId: string;
112
+ dependencyType: "requires" | "limits_per_master" | "limits_sum" | "excludes";
113
+ maxPerMaster: number | null;
114
+ maxDependentSum: number | null;
115
+ active: boolean;
116
+ notes: string | null;
117
+ createdAt: Date;
118
+ updatedAt: Date;
119
+ } | null>;
120
+ export declare function createPricingCategoryDependency(db: PostgresJsDatabase, data: CreatePricingCategoryDependencyInput): Promise<{
121
+ id: string;
122
+ createdAt: Date;
123
+ notes: string | null;
124
+ updatedAt: Date;
125
+ active: boolean;
126
+ pricingCategoryId: string;
127
+ masterPricingCategoryId: string;
128
+ dependencyType: "requires" | "limits_per_master" | "limits_sum" | "excludes";
129
+ maxPerMaster: number | null;
130
+ maxDependentSum: number | null;
131
+ } | null>;
132
+ export declare function updatePricingCategoryDependency(db: PostgresJsDatabase, id: string, data: UpdatePricingCategoryDependencyInput): Promise<{
133
+ id: string;
134
+ pricingCategoryId: string;
135
+ masterPricingCategoryId: string;
136
+ dependencyType: "requires" | "limits_per_master" | "limits_sum" | "excludes";
137
+ maxPerMaster: number | null;
138
+ maxDependentSum: number | null;
139
+ active: boolean;
140
+ notes: string | null;
141
+ createdAt: Date;
142
+ updatedAt: Date;
143
+ } | null>;
144
+ export declare function deletePricingCategoryDependency(db: PostgresJsDatabase, id: string): Promise<{
145
+ id: string;
146
+ } | null>;
147
+ //# sourceMappingURL=service-categories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-categories.d.ts","sourceRoot":"","sources":["../../src/pricing/service-categories.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,KAAK,EACV,oCAAoC,EACpC,0BAA0B,EAC1B,kCAAkC,EAClC,wBAAwB,EACxB,oCAAoC,EACpC,0BAA0B,EAC3B,MAAM,qBAAqB,CAAA;AAG5B,wBAAsB,qBAAqB,CACzC,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;GA0BhC;AAED,wBAAsB,sBAAsB,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;UAO9E;AAED,wBAAsB,qBAAqB,CACzC,EAAE,EAAE,kBAAkB,EACtB,IAAI,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;UAIjC;AAED,wBAAsB,qBAAqB,CACzC,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;UAQjC;AAED,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAM7E;AAED,wBAAsB,+BAA+B,CACnD,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,kCAAkC;;;;;;;;;;;;;;;;GA+B1C;AAED,wBAAsB,gCAAgC,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;UAOxF;AAED,wBAAsB,+BAA+B,CACnD,EAAE,EAAE,kBAAkB,EACtB,IAAI,EAAE,oCAAoC;;;;;;;;;;;UAI3C;AAED,wBAAsB,+BAA+B,CACnD,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,oCAAoC;;;;;;;;;;;UAQ3C;AAED,wBAAsB,+BAA+B,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAMvF"}
@@ -0,0 +1,105 @@
1
+ import { and, asc, eq, ilike, or, sql } from "drizzle-orm";
2
+ import { pricingCategories, pricingCategoryDependencies } from "./schema.js";
3
+ import { paginate } from "./service-shared.js";
4
+ export async function listPricingCategories(db, query) {
5
+ const conditions = [];
6
+ if (query.productId)
7
+ conditions.push(eq(pricingCategories.productId, query.productId));
8
+ if (query.optionId)
9
+ conditions.push(eq(pricingCategories.optionId, query.optionId));
10
+ if (query.unitId)
11
+ conditions.push(eq(pricingCategories.unitId, query.unitId));
12
+ if (query.categoryType)
13
+ conditions.push(eq(pricingCategories.categoryType, query.categoryType));
14
+ if (query.active !== undefined)
15
+ conditions.push(eq(pricingCategories.active, query.active));
16
+ if (query.search) {
17
+ const term = `%${query.search}%`;
18
+ conditions.push(or(ilike(pricingCategories.name, term), ilike(pricingCategories.code, term)));
19
+ }
20
+ const where = conditions.length ? and(...conditions) : undefined;
21
+ return paginate(db
22
+ .select()
23
+ .from(pricingCategories)
24
+ .where(where)
25
+ .limit(query.limit)
26
+ .offset(query.offset)
27
+ .orderBy(asc(pricingCategories.sortOrder), asc(pricingCategories.name)), db.select({ count: sql `count(*)::int` }).from(pricingCategories).where(where), query.limit, query.offset);
28
+ }
29
+ export async function getPricingCategoryById(db, id) {
30
+ const [row] = await db
31
+ .select()
32
+ .from(pricingCategories)
33
+ .where(eq(pricingCategories.id, id))
34
+ .limit(1);
35
+ return row ?? null;
36
+ }
37
+ export async function createPricingCategory(db, data) {
38
+ const [row] = await db.insert(pricingCategories).values(data).returning();
39
+ return row ?? null;
40
+ }
41
+ export async function updatePricingCategory(db, id, data) {
42
+ const [row] = await db
43
+ .update(pricingCategories)
44
+ .set({ ...data, updatedAt: new Date() })
45
+ .where(eq(pricingCategories.id, id))
46
+ .returning();
47
+ return row ?? null;
48
+ }
49
+ export async function deletePricingCategory(db, id) {
50
+ const [row] = await db
51
+ .delete(pricingCategories)
52
+ .where(eq(pricingCategories.id, id))
53
+ .returning({ id: pricingCategories.id });
54
+ return row ?? null;
55
+ }
56
+ export async function listPricingCategoryDependencies(db, query) {
57
+ const conditions = [];
58
+ if (query.pricingCategoryId) {
59
+ conditions.push(eq(pricingCategoryDependencies.pricingCategoryId, query.pricingCategoryId));
60
+ }
61
+ if (query.masterPricingCategoryId) {
62
+ conditions.push(eq(pricingCategoryDependencies.masterPricingCategoryId, query.masterPricingCategoryId));
63
+ }
64
+ if (query.dependencyType) {
65
+ conditions.push(eq(pricingCategoryDependencies.dependencyType, query.dependencyType));
66
+ }
67
+ if (query.active !== undefined) {
68
+ conditions.push(eq(pricingCategoryDependencies.active, query.active));
69
+ }
70
+ const where = conditions.length ? and(...conditions) : undefined;
71
+ return paginate(db
72
+ .select()
73
+ .from(pricingCategoryDependencies)
74
+ .where(where)
75
+ .limit(query.limit)
76
+ .offset(query.offset)
77
+ .orderBy(asc(pricingCategoryDependencies.createdAt)), db.select({ count: sql `count(*)::int` }).from(pricingCategoryDependencies).where(where), query.limit, query.offset);
78
+ }
79
+ export async function getPricingCategoryDependencyById(db, id) {
80
+ const [row] = await db
81
+ .select()
82
+ .from(pricingCategoryDependencies)
83
+ .where(eq(pricingCategoryDependencies.id, id))
84
+ .limit(1);
85
+ return row ?? null;
86
+ }
87
+ export async function createPricingCategoryDependency(db, data) {
88
+ const [row] = await db.insert(pricingCategoryDependencies).values(data).returning();
89
+ return row ?? null;
90
+ }
91
+ export async function updatePricingCategoryDependency(db, id, data) {
92
+ const [row] = await db
93
+ .update(pricingCategoryDependencies)
94
+ .set({ ...data, updatedAt: new Date() })
95
+ .where(eq(pricingCategoryDependencies.id, id))
96
+ .returning();
97
+ return row ?? null;
98
+ }
99
+ export async function deletePricingCategoryDependency(db, id) {
100
+ const [row] = await db
101
+ .delete(pricingCategoryDependencies)
102
+ .where(eq(pricingCategoryDependencies.id, id))
103
+ .returning({ id: pricingCategoryDependencies.id });
104
+ return row ?? null;
105
+ }
@@ -0,0 +1,67 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import { type CreateDeparturePriceOverrideInput, type DeparturePriceOverrideListQuery, type UpdateDeparturePriceOverrideInput } from "./service-shared.js";
3
+ export declare function listDeparturePriceOverrides(db: PostgresJsDatabase, query: DeparturePriceOverrideListQuery): Promise<{
4
+ data: {
5
+ id: string;
6
+ departureId: string;
7
+ optionId: string;
8
+ optionUnitId: string;
9
+ priceCatalogId: string;
10
+ sellAmountCents: number;
11
+ costAmountCents: number | null;
12
+ notes: string | null;
13
+ active: boolean;
14
+ metadata: Record<string, unknown> | null;
15
+ createdAt: Date;
16
+ updatedAt: Date;
17
+ }[];
18
+ total: number;
19
+ limit: number;
20
+ offset: number;
21
+ }>;
22
+ export declare function getDeparturePriceOverrideById(db: PostgresJsDatabase, id: string): Promise<{
23
+ id: string;
24
+ departureId: string;
25
+ optionId: string;
26
+ optionUnitId: string;
27
+ priceCatalogId: string;
28
+ sellAmountCents: number;
29
+ costAmountCents: number | null;
30
+ notes: string | null;
31
+ active: boolean;
32
+ metadata: Record<string, unknown> | null;
33
+ createdAt: Date;
34
+ updatedAt: Date;
35
+ } | null>;
36
+ export declare function createDeparturePriceOverride(db: PostgresJsDatabase, data: CreateDeparturePriceOverrideInput): Promise<{
37
+ metadata: Record<string, unknown> | null;
38
+ id: string;
39
+ createdAt: Date;
40
+ notes: string | null;
41
+ updatedAt: Date;
42
+ active: boolean;
43
+ priceCatalogId: string;
44
+ optionId: string;
45
+ departureId: string;
46
+ optionUnitId: string;
47
+ sellAmountCents: number;
48
+ costAmountCents: number | null;
49
+ } | null>;
50
+ export declare function updateDeparturePriceOverride(db: PostgresJsDatabase, id: string, data: UpdateDeparturePriceOverrideInput): Promise<{
51
+ id: string;
52
+ departureId: string;
53
+ optionId: string;
54
+ optionUnitId: string;
55
+ priceCatalogId: string;
56
+ sellAmountCents: number;
57
+ costAmountCents: number | null;
58
+ notes: string | null;
59
+ active: boolean;
60
+ metadata: Record<string, unknown> | null;
61
+ createdAt: Date;
62
+ updatedAt: Date;
63
+ } | null>;
64
+ export declare function deleteDeparturePriceOverride(db: PostgresJsDatabase, id: string): Promise<{
65
+ id: string;
66
+ } | null>;
67
+ //# sourceMappingURL=service-departure-overrides.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-departure-overrides.d.ts","sourceRoot":"","sources":["../../src/pricing/service-departure-overrides.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,EACL,KAAK,iCAAiC,EACtC,KAAK,+BAA+B,EAEpC,KAAK,iCAAiC,EACvC,MAAM,qBAAqB,CAAA;AAE5B,wBAAsB,2BAA2B,CAC/C,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,+BAA+B;;;;;;;;;;;;;;;;;;GA4BvC;AAED,wBAAsB,6BAA6B,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;UAOrF;AAED,wBAAsB,4BAA4B,CAChD,EAAE,EAAE,kBAAkB,EACtB,IAAI,EAAE,iCAAiC;;;;;;;;;;;;;UAIxC;AAED,wBAAsB,4BAA4B,CAChD,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,iCAAiC;;;;;;;;;;;;;UAQxC;AAED,wBAAsB,4BAA4B,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAMpF"}
@@ -0,0 +1,54 @@
1
+ import { and, desc, eq, sql } from "drizzle-orm";
2
+ import { departurePriceOverrides } from "./schema.js";
3
+ import { paginate, } from "./service-shared.js";
4
+ export async function listDeparturePriceOverrides(db, query) {
5
+ const conditions = [];
6
+ if (query.departureId)
7
+ conditions.push(eq(departurePriceOverrides.departureId, query.departureId));
8
+ if (query.optionId)
9
+ conditions.push(eq(departurePriceOverrides.optionId, query.optionId));
10
+ if (query.optionUnitId) {
11
+ conditions.push(eq(departurePriceOverrides.optionUnitId, query.optionUnitId));
12
+ }
13
+ if (query.priceCatalogId) {
14
+ conditions.push(eq(departurePriceOverrides.priceCatalogId, query.priceCatalogId));
15
+ }
16
+ if (query.active !== undefined) {
17
+ conditions.push(eq(departurePriceOverrides.active, query.active));
18
+ }
19
+ const where = conditions.length ? and(...conditions) : undefined;
20
+ return paginate(db
21
+ .select()
22
+ .from(departurePriceOverrides)
23
+ .where(where)
24
+ .limit(query.limit)
25
+ .offset(query.offset)
26
+ .orderBy(desc(departurePriceOverrides.updatedAt)), db.select({ count: sql `count(*)::int` }).from(departurePriceOverrides).where(where), query.limit, query.offset);
27
+ }
28
+ export async function getDeparturePriceOverrideById(db, id) {
29
+ const [row] = await db
30
+ .select()
31
+ .from(departurePriceOverrides)
32
+ .where(eq(departurePriceOverrides.id, id))
33
+ .limit(1);
34
+ return row ?? null;
35
+ }
36
+ export async function createDeparturePriceOverride(db, data) {
37
+ const [row] = await db.insert(departurePriceOverrides).values(data).returning();
38
+ return row ?? null;
39
+ }
40
+ export async function updateDeparturePriceOverride(db, id, data) {
41
+ const [row] = await db
42
+ .update(departurePriceOverrides)
43
+ .set({ ...data, updatedAt: new Date() })
44
+ .where(eq(departurePriceOverrides.id, id))
45
+ .returning();
46
+ return row ?? null;
47
+ }
48
+ export async function deleteDeparturePriceOverride(db, id) {
49
+ const [row] = await db
50
+ .delete(departurePriceOverrides)
51
+ .where(eq(departurePriceOverrides.id, id))
52
+ .returning({ id: departurePriceOverrides.id });
53
+ return row ?? null;
54
+ }