@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,253 @@
1
+ import { and, asc, desc, eq, sql } from "drizzle-orm";
2
+ import { offerExpirationEvents, offerRefreshRuns, sellabilityExplanations, sellabilityPolicies, sellabilityPolicyResults, } from "./schema.js";
3
+ import { normalizeDateTime, paginate } from "./service-shared.js";
4
+ export async function listPolicies(db, query) {
5
+ const conditions = [];
6
+ if (query.scope)
7
+ conditions.push(eq(sellabilityPolicies.scope, query.scope));
8
+ if (query.policyType)
9
+ conditions.push(eq(sellabilityPolicies.policyType, query.policyType));
10
+ if (query.productId)
11
+ conditions.push(eq(sellabilityPolicies.productId, query.productId));
12
+ if (query.optionId)
13
+ conditions.push(eq(sellabilityPolicies.optionId, query.optionId));
14
+ if (query.marketId)
15
+ conditions.push(eq(sellabilityPolicies.marketId, query.marketId));
16
+ if (query.channelId)
17
+ conditions.push(eq(sellabilityPolicies.channelId, query.channelId));
18
+ if (query.active !== undefined)
19
+ conditions.push(eq(sellabilityPolicies.active, query.active));
20
+ const where = conditions.length > 0 ? and(...conditions) : undefined;
21
+ return paginate(db
22
+ .select()
23
+ .from(sellabilityPolicies)
24
+ .where(where)
25
+ .limit(query.limit)
26
+ .offset(query.offset)
27
+ .orderBy(desc(sellabilityPolicies.priority), asc(sellabilityPolicies.name)), db.select({ count: sql `count(*)::int` }).from(sellabilityPolicies).where(where), query.limit, query.offset);
28
+ }
29
+ export async function getPolicyById(db, id) {
30
+ const [row] = await db
31
+ .select()
32
+ .from(sellabilityPolicies)
33
+ .where(eq(sellabilityPolicies.id, id))
34
+ .limit(1);
35
+ return row ?? null;
36
+ }
37
+ export async function createPolicy(db, data) {
38
+ const [row] = await db.insert(sellabilityPolicies).values(data).returning();
39
+ return row ?? null;
40
+ }
41
+ export async function updatePolicy(db, id, data) {
42
+ const [row] = await db
43
+ .update(sellabilityPolicies)
44
+ .set({ ...data, updatedAt: new Date() })
45
+ .where(eq(sellabilityPolicies.id, id))
46
+ .returning();
47
+ return row ?? null;
48
+ }
49
+ export async function deletePolicy(db, id) {
50
+ const [row] = await db
51
+ .delete(sellabilityPolicies)
52
+ .where(eq(sellabilityPolicies.id, id))
53
+ .returning({ id: sellabilityPolicies.id });
54
+ return row ?? null;
55
+ }
56
+ export async function listPolicyResults(db, query) {
57
+ const conditions = [];
58
+ if (query.snapshotId)
59
+ conditions.push(eq(sellabilityPolicyResults.snapshotId, query.snapshotId));
60
+ if (query.snapshotItemId)
61
+ conditions.push(eq(sellabilityPolicyResults.snapshotItemId, query.snapshotItemId));
62
+ if (query.policyId)
63
+ conditions.push(eq(sellabilityPolicyResults.policyId, query.policyId));
64
+ if (query.status)
65
+ conditions.push(eq(sellabilityPolicyResults.status, query.status));
66
+ const where = conditions.length ? and(...conditions) : undefined;
67
+ return paginate(db
68
+ .select()
69
+ .from(sellabilityPolicyResults)
70
+ .where(where)
71
+ .limit(query.limit)
72
+ .offset(query.offset)
73
+ .orderBy(desc(sellabilityPolicyResults.createdAt)), db.select({ count: sql `count(*)::int` }).from(sellabilityPolicyResults).where(where), query.limit, query.offset);
74
+ }
75
+ export async function getPolicyResultById(db, id) {
76
+ const [row] = await db
77
+ .select()
78
+ .from(sellabilityPolicyResults)
79
+ .where(eq(sellabilityPolicyResults.id, id))
80
+ .limit(1);
81
+ return row ?? null;
82
+ }
83
+ export async function createPolicyResult(db, data) {
84
+ const [row] = await db.insert(sellabilityPolicyResults).values(data).returning();
85
+ return row ?? null;
86
+ }
87
+ export async function updatePolicyResult(db, id, data) {
88
+ const [row] = await db
89
+ .update(sellabilityPolicyResults)
90
+ .set(data)
91
+ .where(eq(sellabilityPolicyResults.id, id))
92
+ .returning();
93
+ return row ?? null;
94
+ }
95
+ export async function deletePolicyResult(db, id) {
96
+ const [row] = await db
97
+ .delete(sellabilityPolicyResults)
98
+ .where(eq(sellabilityPolicyResults.id, id))
99
+ .returning({ id: sellabilityPolicyResults.id });
100
+ return row ?? null;
101
+ }
102
+ export async function listOfferRefreshRuns(db, query) {
103
+ const conditions = [];
104
+ if (query.offerId)
105
+ conditions.push(eq(offerRefreshRuns.offerId, query.offerId));
106
+ if (query.snapshotId)
107
+ conditions.push(eq(offerRefreshRuns.snapshotId, query.snapshotId));
108
+ if (query.status)
109
+ conditions.push(eq(offerRefreshRuns.status, query.status));
110
+ const where = conditions.length ? and(...conditions) : undefined;
111
+ return paginate(db
112
+ .select()
113
+ .from(offerRefreshRuns)
114
+ .where(where)
115
+ .limit(query.limit)
116
+ .offset(query.offset)
117
+ .orderBy(desc(offerRefreshRuns.startedAt)), db.select({ count: sql `count(*)::int` }).from(offerRefreshRuns).where(where), query.limit, query.offset);
118
+ }
119
+ export async function getOfferRefreshRunById(db, id) {
120
+ const [row] = await db.select().from(offerRefreshRuns).where(eq(offerRefreshRuns.id, id)).limit(1);
121
+ return row ?? null;
122
+ }
123
+ export async function createOfferRefreshRun(db, data) {
124
+ const [row] = await db
125
+ .insert(offerRefreshRuns)
126
+ .values({
127
+ ...data,
128
+ startedAt: normalizeDateTime(data.startedAt) ?? new Date(),
129
+ completedAt: normalizeDateTime(data.completedAt),
130
+ })
131
+ .returning();
132
+ return row ?? null;
133
+ }
134
+ export async function updateOfferRefreshRun(db, id, data) {
135
+ const [row] = await db
136
+ .update(offerRefreshRuns)
137
+ .set({
138
+ ...data,
139
+ startedAt: data.startedAt ? new Date(data.startedAt) : undefined,
140
+ completedAt: data.completedAt ? new Date(data.completedAt) : undefined,
141
+ updatedAt: new Date(),
142
+ })
143
+ .where(eq(offerRefreshRuns.id, id))
144
+ .returning();
145
+ return row ?? null;
146
+ }
147
+ export async function deleteOfferRefreshRun(db, id) {
148
+ const [row] = await db
149
+ .delete(offerRefreshRuns)
150
+ .where(eq(offerRefreshRuns.id, id))
151
+ .returning({ id: offerRefreshRuns.id });
152
+ return row ?? null;
153
+ }
154
+ export async function listOfferExpirationEvents(db, query) {
155
+ const conditions = [];
156
+ if (query.offerId)
157
+ conditions.push(eq(offerExpirationEvents.offerId, query.offerId));
158
+ if (query.snapshotId)
159
+ conditions.push(eq(offerExpirationEvents.snapshotId, query.snapshotId));
160
+ if (query.status)
161
+ conditions.push(eq(offerExpirationEvents.status, query.status));
162
+ const where = conditions.length ? and(...conditions) : undefined;
163
+ return paginate(db
164
+ .select()
165
+ .from(offerExpirationEvents)
166
+ .where(where)
167
+ .limit(query.limit)
168
+ .offset(query.offset)
169
+ .orderBy(desc(offerExpirationEvents.expiresAt)), db.select({ count: sql `count(*)::int` }).from(offerExpirationEvents).where(where), query.limit, query.offset);
170
+ }
171
+ export async function getOfferExpirationEventById(db, id) {
172
+ const [row] = await db
173
+ .select()
174
+ .from(offerExpirationEvents)
175
+ .where(eq(offerExpirationEvents.id, id))
176
+ .limit(1);
177
+ return row ?? null;
178
+ }
179
+ export async function createOfferExpirationEvent(db, data) {
180
+ const [row] = await db
181
+ .insert(offerExpirationEvents)
182
+ .values({
183
+ ...data,
184
+ expiresAt: new Date(data.expiresAt),
185
+ expiredAt: normalizeDateTime(data.expiredAt),
186
+ })
187
+ .returning();
188
+ return row ?? null;
189
+ }
190
+ export async function updateOfferExpirationEvent(db, id, data) {
191
+ const [row] = await db
192
+ .update(offerExpirationEvents)
193
+ .set({
194
+ ...data,
195
+ expiresAt: data.expiresAt ? new Date(data.expiresAt) : undefined,
196
+ expiredAt: normalizeDateTime(data.expiredAt),
197
+ updatedAt: new Date(),
198
+ })
199
+ .where(eq(offerExpirationEvents.id, id))
200
+ .returning();
201
+ return row ?? null;
202
+ }
203
+ export async function deleteOfferExpirationEvent(db, id) {
204
+ const [row] = await db
205
+ .delete(offerExpirationEvents)
206
+ .where(eq(offerExpirationEvents.id, id))
207
+ .returning({ id: offerExpirationEvents.id });
208
+ return row ?? null;
209
+ }
210
+ export async function listExplanations(db, query) {
211
+ const conditions = [];
212
+ if (query.snapshotId)
213
+ conditions.push(eq(sellabilityExplanations.snapshotId, query.snapshotId));
214
+ if (query.snapshotItemId)
215
+ conditions.push(eq(sellabilityExplanations.snapshotItemId, query.snapshotItemId));
216
+ if (query.explanationType)
217
+ conditions.push(eq(sellabilityExplanations.explanationType, query.explanationType));
218
+ const where = conditions.length ? and(...conditions) : undefined;
219
+ return paginate(db
220
+ .select()
221
+ .from(sellabilityExplanations)
222
+ .where(where)
223
+ .limit(query.limit)
224
+ .offset(query.offset)
225
+ .orderBy(desc(sellabilityExplanations.createdAt)), db.select({ count: sql `count(*)::int` }).from(sellabilityExplanations).where(where), query.limit, query.offset);
226
+ }
227
+ export async function getExplanationById(db, id) {
228
+ const [row] = await db
229
+ .select()
230
+ .from(sellabilityExplanations)
231
+ .where(eq(sellabilityExplanations.id, id))
232
+ .limit(1);
233
+ return row ?? null;
234
+ }
235
+ export async function createExplanation(db, data) {
236
+ const [row] = await db.insert(sellabilityExplanations).values(data).returning();
237
+ return row ?? null;
238
+ }
239
+ export async function updateExplanation(db, id, data) {
240
+ const [row] = await db
241
+ .update(sellabilityExplanations)
242
+ .set(data)
243
+ .where(eq(sellabilityExplanations.id, id))
244
+ .returning();
245
+ return row ?? null;
246
+ }
247
+ export async function deleteExplanation(db, id) {
248
+ const [row] = await db
249
+ .delete(sellabilityExplanations)
250
+ .where(eq(sellabilityExplanations.id, id))
251
+ .returning({ id: sellabilityExplanations.id });
252
+ return row ?? null;
253
+ }
@@ -0,0 +1,72 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import { type ResolvedPriceBreakdown, type ResolvedPriceComponent, type SellabilityResolveQuery } from "./service-shared.js";
3
+ type ResolveSlotRow = {
4
+ id: string;
5
+ productId: string;
6
+ optionId: string | null;
7
+ startTimeId: string | null;
8
+ dateLocal: string;
9
+ startsAt: Date | string;
10
+ timezone: string;
11
+ unlimited: boolean;
12
+ remainingPax: number | null;
13
+ remainingPickups: number | null;
14
+ pastCutoff: boolean;
15
+ tooEarly: boolean;
16
+ };
17
+ export declare function resolve(db: PostgresJsDatabase, query: SellabilityResolveQuery): Promise<{
18
+ data: {
19
+ product: {
20
+ id: string;
21
+ name: string;
22
+ };
23
+ option: {
24
+ id: string;
25
+ name: string;
26
+ code: string | null;
27
+ };
28
+ slot: ResolveSlotRow;
29
+ market: {
30
+ id: string;
31
+ code: string;
32
+ name: string;
33
+ } | null;
34
+ channel: {
35
+ id: string;
36
+ kind: "direct" | "reseller" | "affiliate" | "ota" | "marketplace" | "api_partner" | "connect";
37
+ } | null;
38
+ sellability: {
39
+ mode: "unavailable" | "sellable" | "on_request";
40
+ onRequest: boolean;
41
+ allotmentStatus: "sellable" | "not_applicable";
42
+ };
43
+ pricing: {
44
+ currencyCode: string;
45
+ sellAmountCents: number;
46
+ costAmountCents: number;
47
+ marginAmountCents: number;
48
+ breakdown: ResolvedPriceBreakdown[];
49
+ components: ResolvedPriceComponent[];
50
+ fx: {
51
+ fxRateSetId: string;
52
+ baseCurrency: string;
53
+ quoteCurrency: string;
54
+ rateDecimal: number;
55
+ } | null;
56
+ };
57
+ sources: {
58
+ marketProductRuleId: string | null;
59
+ marketChannelRuleId: string | null;
60
+ marketPriceCatalogId: string | null;
61
+ optionPriceRuleId: string;
62
+ optionStartTimeRuleId: string | null;
63
+ channelInventoryAllotmentIds: string[];
64
+ channelInventoryReleaseRuleId: string | null;
65
+ };
66
+ }[];
67
+ meta: {
68
+ total: number;
69
+ };
70
+ }>;
71
+ export {};
72
+ //# sourceMappingURL=service-resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-resolve.d.ts","sourceRoot":"","sources":["../../src/sellability/service-resolve.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAqBjE,OAAO,EAKL,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAG7B,MAAM,qBAAqB,CAAA;AAc5B,KAAK,cAAc,GAAG;IACpB,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,IAAI,GAAG,MAAM,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,UAAU,EAAE,OAAO,CAAA;IACnB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAyKD,wBAAsB,OAAO,CAAC,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAqhBjE,MAAM;8BACL,MAAM;+BACL,MAAM;6BACR,MAAM;;;;;;;;;;;;;;;;GAwExB"}