@voyant-travel/distribution 0.109.8

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 (168) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +42 -0
  3. package/dist/booking-extension.d.ts +168 -0
  4. package/dist/booking-extension.d.ts.map +1 -0
  5. package/dist/booking-extension.js +102 -0
  6. package/dist/channel-push/admin-routes.d.ts +31 -0
  7. package/dist/channel-push/admin-routes.d.ts.map +1 -0
  8. package/dist/channel-push/admin-routes.js +165 -0
  9. package/dist/channel-push/availability-push.d.ts +76 -0
  10. package/dist/channel-push/availability-push.d.ts.map +1 -0
  11. package/dist/channel-push/availability-push.js +236 -0
  12. package/dist/channel-push/booking-push-helpers.d.ts +36 -0
  13. package/dist/channel-push/booking-push-helpers.d.ts.map +1 -0
  14. package/dist/channel-push/booking-push-helpers.js +169 -0
  15. package/dist/channel-push/booking-push.d.ts +108 -0
  16. package/dist/channel-push/booking-push.d.ts.map +1 -0
  17. package/dist/channel-push/booking-push.js +335 -0
  18. package/dist/channel-push/boundary-sql.d.ts +23 -0
  19. package/dist/channel-push/boundary-sql.d.ts.map +1 -0
  20. package/dist/channel-push/boundary-sql.js +75 -0
  21. package/dist/channel-push/content-push.d.ts +60 -0
  22. package/dist/channel-push/content-push.d.ts.map +1 -0
  23. package/dist/channel-push/content-push.js +252 -0
  24. package/dist/channel-push/index.d.ts +15 -0
  25. package/dist/channel-push/index.d.ts.map +1 -0
  26. package/dist/channel-push/index.js +18 -0
  27. package/dist/channel-push/plugin.d.ts +18 -0
  28. package/dist/channel-push/plugin.d.ts.map +1 -0
  29. package/dist/channel-push/plugin.js +21 -0
  30. package/dist/channel-push/reconciler.d.ts +85 -0
  31. package/dist/channel-push/reconciler.d.ts.map +1 -0
  32. package/dist/channel-push/reconciler.js +179 -0
  33. package/dist/channel-push/subscriber.d.ts +40 -0
  34. package/dist/channel-push/subscriber.d.ts.map +1 -0
  35. package/dist/channel-push/subscriber.js +199 -0
  36. package/dist/channel-push/types.d.ts +43 -0
  37. package/dist/channel-push/types.d.ts.map +1 -0
  38. package/dist/channel-push/types.js +32 -0
  39. package/dist/channel-push/workflows.d.ts +56 -0
  40. package/dist/channel-push/workflows.d.ts.map +1 -0
  41. package/dist/channel-push/workflows.js +100 -0
  42. package/dist/external-refs/index.d.ts +11 -0
  43. package/dist/external-refs/index.d.ts.map +1 -0
  44. package/dist/external-refs/index.js +12 -0
  45. package/dist/external-refs/routes.d.ts +253 -0
  46. package/dist/external-refs/routes.d.ts.map +1 -0
  47. package/dist/external-refs/routes.js +52 -0
  48. package/dist/external-refs/schema.d.ts +251 -0
  49. package/dist/external-refs/schema.d.ts.map +1 -0
  50. package/dist/external-refs/schema.js +32 -0
  51. package/dist/external-refs/service.d.ts +82 -0
  52. package/dist/external-refs/service.d.ts.map +1 -0
  53. package/dist/external-refs/service.js +112 -0
  54. package/dist/external-refs/validation.d.ts +91 -0
  55. package/dist/external-refs/validation.d.ts.map +1 -0
  56. package/dist/external-refs/validation.js +40 -0
  57. package/dist/index.d.ts +21 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +20 -0
  60. package/dist/interface-types.d.ts +128 -0
  61. package/dist/interface-types.d.ts.map +1 -0
  62. package/dist/interface-types.js +1 -0
  63. package/dist/interface.d.ts +10 -0
  64. package/dist/interface.d.ts.map +1 -0
  65. package/dist/interface.js +286 -0
  66. package/dist/rate-limit.d.ts +69 -0
  67. package/dist/rate-limit.d.ts.map +1 -0
  68. package/dist/rate-limit.js +135 -0
  69. package/dist/routes/batch.d.ts +200 -0
  70. package/dist/routes/batch.d.ts.map +1 -0
  71. package/dist/routes/batch.js +52 -0
  72. package/dist/routes/env.d.ts +8 -0
  73. package/dist/routes/env.d.ts.map +1 -0
  74. package/dist/routes/env.js +1 -0
  75. package/dist/routes/inventory.d.ts +604 -0
  76. package/dist/routes/inventory.d.ts.map +1 -0
  77. package/dist/routes/inventory.js +138 -0
  78. package/dist/routes/settlements.d.ts +1649 -0
  79. package/dist/routes/settlements.d.ts.map +1 -0
  80. package/dist/routes/settlements.js +265 -0
  81. package/dist/routes.d.ts +3909 -0
  82. package/dist/routes.d.ts.map +1 -0
  83. package/dist/routes.js +323 -0
  84. package/dist/schema-automation.d.ts +680 -0
  85. package/dist/schema-automation.d.ts.map +1 -0
  86. package/dist/schema-automation.js +76 -0
  87. package/dist/schema-core.d.ts +1674 -0
  88. package/dist/schema-core.d.ts.map +1 -0
  89. package/dist/schema-core.js +227 -0
  90. package/dist/schema-finance.d.ts +1372 -0
  91. package/dist/schema-finance.d.ts.map +1 -0
  92. package/dist/schema-finance.js +153 -0
  93. package/dist/schema-inventory.d.ts +855 -0
  94. package/dist/schema-inventory.d.ts.map +1 -0
  95. package/dist/schema-inventory.js +102 -0
  96. package/dist/schema-push-intents.d.ts +387 -0
  97. package/dist/schema-push-intents.d.ts.map +1 -0
  98. package/dist/schema-push-intents.js +77 -0
  99. package/dist/schema-relations.d.ts +95 -0
  100. package/dist/schema-relations.d.ts.map +1 -0
  101. package/dist/schema-relations.js +196 -0
  102. package/dist/schema-shared.d.ts +24 -0
  103. package/dist/schema-shared.d.ts.map +1 -0
  104. package/dist/schema-shared.js +123 -0
  105. package/dist/schema.d.ts +9 -0
  106. package/dist/schema.d.ts.map +1 -0
  107. package/dist/schema.js +8 -0
  108. package/dist/service/channels.d.ts +167 -0
  109. package/dist/service/channels.d.ts.map +1 -0
  110. package/dist/service/channels.js +305 -0
  111. package/dist/service/commercial.d.ts +385 -0
  112. package/dist/service/commercial.d.ts.map +1 -0
  113. package/dist/service/commercial.js +248 -0
  114. package/dist/service/helpers.d.ts +10 -0
  115. package/dist/service/helpers.d.ts.map +1 -0
  116. package/dist/service/helpers.js +7 -0
  117. package/dist/service/inventory.d.ts +193 -0
  118. package/dist/service/inventory.d.ts.map +1 -0
  119. package/dist/service/inventory.js +154 -0
  120. package/dist/service/settlement-policies.d.ts +325 -0
  121. package/dist/service/settlement-policies.d.ts.map +1 -0
  122. package/dist/service/settlement-policies.js +272 -0
  123. package/dist/service/settlements.d.ts +357 -0
  124. package/dist/service/settlements.d.ts.map +1 -0
  125. package/dist/service/settlements.js +319 -0
  126. package/dist/service/types.d.ts +60 -0
  127. package/dist/service/types.d.ts.map +1 -0
  128. package/dist/service/types.js +1 -0
  129. package/dist/service.d.ts +1418 -0
  130. package/dist/service.d.ts.map +1 -0
  131. package/dist/service.js +17 -0
  132. package/dist/suppliers/index.d.ts +15 -0
  133. package/dist/suppliers/index.d.ts.map +1 -0
  134. package/dist/suppliers/index.js +23 -0
  135. package/dist/suppliers/routes.d.ts +1202 -0
  136. package/dist/suppliers/routes.d.ts.map +1 -0
  137. package/dist/suppliers/routes.js +290 -0
  138. package/dist/suppliers/schema.d.ts +1272 -0
  139. package/dist/suppliers/schema.d.ts.map +1 -0
  140. package/dist/suppliers/schema.js +219 -0
  141. package/dist/suppliers/service-aggregates.d.ts +23 -0
  142. package/dist/suppliers/service-aggregates.d.ts.map +1 -0
  143. package/dist/suppliers/service-aggregates.js +51 -0
  144. package/dist/suppliers/service-core.d.ts +89 -0
  145. package/dist/suppliers/service-core.d.ts.map +1 -0
  146. package/dist/suppliers/service-core.js +164 -0
  147. package/dist/suppliers/service-identity.d.ts +162 -0
  148. package/dist/suppliers/service-identity.d.ts.map +1 -0
  149. package/dist/suppliers/service-identity.js +101 -0
  150. package/dist/suppliers/service-operations.d.ts +1500 -0
  151. package/dist/suppliers/service-operations.d.ts.map +1 -0
  152. package/dist/suppliers/service-operations.js +157 -0
  153. package/dist/suppliers/service-shared.d.ts +45 -0
  154. package/dist/suppliers/service-shared.d.ts.map +1 -0
  155. package/dist/suppliers/service-shared.js +294 -0
  156. package/dist/suppliers/service.d.ts +41 -0
  157. package/dist/suppliers/service.d.ts.map +1 -0
  158. package/dist/suppliers/service.js +40 -0
  159. package/dist/suppliers/validation.d.ts +2 -0
  160. package/dist/suppliers/validation.d.ts.map +1 -0
  161. package/dist/suppliers/validation.js +1 -0
  162. package/dist/validation.d.ts +1371 -0
  163. package/dist/validation.d.ts.map +1 -0
  164. package/dist/validation.js +445 -0
  165. package/dist/webhook-deliveries.d.ts +86 -0
  166. package/dist/webhook-deliveries.d.ts.map +1 -0
  167. package/dist/webhook-deliveries.js +296 -0
  168. package/package.json +71 -0
@@ -0,0 +1,357 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import type { ChannelInventoryReleaseExecutionListQuery, ChannelReconciliationItemListQuery, ChannelReconciliationRunListQuery, ChannelSettlementItemListQuery, ChannelSettlementRunListQuery, CreateChannelInventoryReleaseExecutionInput, CreateChannelReconciliationItemInput, CreateChannelReconciliationRunInput, CreateChannelSettlementItemInput, CreateChannelSettlementRunInput, UpdateChannelInventoryReleaseExecutionInput, UpdateChannelReconciliationItemInput, UpdateChannelReconciliationRunInput, UpdateChannelSettlementItemInput, UpdateChannelSettlementRunInput } from "./types.js";
3
+ export declare const settlementServiceOperations: {
4
+ listSettlementRuns(db: PostgresJsDatabase, query: ChannelSettlementRunListQuery): Promise<{
5
+ data: {
6
+ id: string;
7
+ channelId: string;
8
+ contractId: string | null;
9
+ status: "void" | "draft" | "open" | "posted" | "paid";
10
+ currencyCode: string | null;
11
+ periodStart: string | null;
12
+ periodEnd: string | null;
13
+ statementReference: string | null;
14
+ generatedAt: Date | null;
15
+ postedAt: Date | null;
16
+ paidAt: Date | null;
17
+ notes: string | null;
18
+ metadata: Record<string, unknown> | null;
19
+ createdAt: Date;
20
+ updatedAt: Date;
21
+ }[];
22
+ total: number;
23
+ limit: number;
24
+ offset: number;
25
+ }>;
26
+ getSettlementRunById(db: PostgresJsDatabase, id: string): Promise<{
27
+ id: string;
28
+ channelId: string;
29
+ contractId: string | null;
30
+ status: "void" | "draft" | "open" | "posted" | "paid";
31
+ currencyCode: string | null;
32
+ periodStart: string | null;
33
+ periodEnd: string | null;
34
+ statementReference: string | null;
35
+ generatedAt: Date | null;
36
+ postedAt: Date | null;
37
+ paidAt: Date | null;
38
+ notes: string | null;
39
+ metadata: Record<string, unknown> | null;
40
+ createdAt: Date;
41
+ updatedAt: Date;
42
+ } | null>;
43
+ createSettlementRun(db: PostgresJsDatabase, data: CreateChannelSettlementRunInput): Promise<{
44
+ createdAt: Date;
45
+ updatedAt: Date;
46
+ metadata: Record<string, unknown> | null;
47
+ id: string;
48
+ status: "void" | "draft" | "open" | "posted" | "paid";
49
+ channelId: string;
50
+ notes: string | null;
51
+ contractId: string | null;
52
+ paidAt: Date | null;
53
+ currencyCode: string | null;
54
+ periodStart: string | null;
55
+ periodEnd: string | null;
56
+ statementReference: string | null;
57
+ generatedAt: Date | null;
58
+ postedAt: Date | null;
59
+ } | undefined>;
60
+ updateSettlementRun(db: PostgresJsDatabase, id: string, data: UpdateChannelSettlementRunInput): Promise<{
61
+ id: string;
62
+ channelId: string;
63
+ contractId: string | null;
64
+ status: "void" | "draft" | "open" | "posted" | "paid";
65
+ currencyCode: string | null;
66
+ periodStart: string | null;
67
+ periodEnd: string | null;
68
+ statementReference: string | null;
69
+ generatedAt: Date | null;
70
+ postedAt: Date | null;
71
+ paidAt: Date | null;
72
+ notes: string | null;
73
+ metadata: Record<string, unknown> | null;
74
+ createdAt: Date;
75
+ updatedAt: Date;
76
+ } | null>;
77
+ deleteSettlementRun(db: PostgresJsDatabase, id: string): Promise<{
78
+ id: string;
79
+ } | null>;
80
+ listSettlementItems(db: PostgresJsDatabase, query: ChannelSettlementItemListQuery): Promise<{
81
+ data: {
82
+ id: string;
83
+ settlementRunId: string;
84
+ bookingLinkId: string | null;
85
+ bookingId: string | null;
86
+ commissionRuleId: string | null;
87
+ status: "void" | "pending" | "paid" | "approved" | "disputed";
88
+ grossAmountCents: number;
89
+ commissionAmountCents: number;
90
+ netRemittanceAmountCents: number;
91
+ currencyCode: string | null;
92
+ remittanceDueAt: Date | null;
93
+ paidAt: Date | null;
94
+ notes: string | null;
95
+ createdAt: Date;
96
+ updatedAt: Date;
97
+ }[];
98
+ total: number;
99
+ limit: number;
100
+ offset: number;
101
+ }>;
102
+ getSettlementItemById(db: PostgresJsDatabase, id: string): Promise<{
103
+ id: string;
104
+ settlementRunId: string;
105
+ bookingLinkId: string | null;
106
+ bookingId: string | null;
107
+ commissionRuleId: string | null;
108
+ status: "void" | "pending" | "paid" | "approved" | "disputed";
109
+ grossAmountCents: number;
110
+ commissionAmountCents: number;
111
+ netRemittanceAmountCents: number;
112
+ currencyCode: string | null;
113
+ remittanceDueAt: Date | null;
114
+ paidAt: Date | null;
115
+ notes: string | null;
116
+ createdAt: Date;
117
+ updatedAt: Date;
118
+ } | null>;
119
+ createSettlementItem(db: PostgresJsDatabase, data: CreateChannelSettlementItemInput): Promise<{
120
+ bookingId: string | null;
121
+ createdAt: Date;
122
+ updatedAt: Date;
123
+ id: string;
124
+ status: "void" | "pending" | "paid" | "approved" | "disputed";
125
+ notes: string | null;
126
+ paidAt: Date | null;
127
+ currencyCode: string | null;
128
+ settlementRunId: string;
129
+ bookingLinkId: string | null;
130
+ commissionRuleId: string | null;
131
+ grossAmountCents: number;
132
+ commissionAmountCents: number;
133
+ netRemittanceAmountCents: number;
134
+ remittanceDueAt: Date | null;
135
+ } | undefined>;
136
+ updateSettlementItem(db: PostgresJsDatabase, id: string, data: UpdateChannelSettlementItemInput): Promise<{
137
+ id: string;
138
+ settlementRunId: string;
139
+ bookingLinkId: string | null;
140
+ bookingId: string | null;
141
+ commissionRuleId: string | null;
142
+ status: "void" | "pending" | "paid" | "approved" | "disputed";
143
+ grossAmountCents: number;
144
+ commissionAmountCents: number;
145
+ netRemittanceAmountCents: number;
146
+ currencyCode: string | null;
147
+ remittanceDueAt: Date | null;
148
+ paidAt: Date | null;
149
+ notes: string | null;
150
+ createdAt: Date;
151
+ updatedAt: Date;
152
+ } | null>;
153
+ deleteSettlementItem(db: PostgresJsDatabase, id: string): Promise<{
154
+ id: string;
155
+ } | null>;
156
+ listReconciliationRuns(db: PostgresJsDatabase, query: ChannelReconciliationRunListQuery): Promise<{
157
+ data: {
158
+ id: string;
159
+ channelId: string;
160
+ contractId: string | null;
161
+ status: "archived" | "draft" | "completed" | "running";
162
+ periodStart: string | null;
163
+ periodEnd: string | null;
164
+ externalReportReference: string | null;
165
+ startedAt: Date | null;
166
+ completedAt: Date | null;
167
+ notes: string | null;
168
+ metadata: Record<string, unknown> | null;
169
+ createdAt: Date;
170
+ updatedAt: Date;
171
+ }[];
172
+ total: number;
173
+ limit: number;
174
+ offset: number;
175
+ }>;
176
+ getReconciliationRunById(db: PostgresJsDatabase, id: string): Promise<{
177
+ id: string;
178
+ channelId: string;
179
+ contractId: string | null;
180
+ status: "archived" | "draft" | "completed" | "running";
181
+ periodStart: string | null;
182
+ periodEnd: string | null;
183
+ externalReportReference: string | null;
184
+ startedAt: Date | null;
185
+ completedAt: Date | null;
186
+ notes: string | null;
187
+ metadata: Record<string, unknown> | null;
188
+ createdAt: Date;
189
+ updatedAt: Date;
190
+ } | null>;
191
+ createReconciliationRun(db: PostgresJsDatabase, data: CreateChannelReconciliationRunInput): Promise<{
192
+ createdAt: Date;
193
+ updatedAt: Date;
194
+ metadata: Record<string, unknown> | null;
195
+ id: string;
196
+ status: "archived" | "draft" | "completed" | "running";
197
+ channelId: string;
198
+ startedAt: Date | null;
199
+ notes: string | null;
200
+ contractId: string | null;
201
+ completedAt: Date | null;
202
+ periodStart: string | null;
203
+ periodEnd: string | null;
204
+ externalReportReference: string | null;
205
+ } | undefined>;
206
+ updateReconciliationRun(db: PostgresJsDatabase, id: string, data: UpdateChannelReconciliationRunInput): Promise<{
207
+ id: string;
208
+ channelId: string;
209
+ contractId: string | null;
210
+ status: "archived" | "draft" | "completed" | "running";
211
+ periodStart: string | null;
212
+ periodEnd: string | null;
213
+ externalReportReference: string | null;
214
+ startedAt: Date | null;
215
+ completedAt: Date | null;
216
+ notes: string | null;
217
+ metadata: Record<string, unknown> | null;
218
+ createdAt: Date;
219
+ updatedAt: Date;
220
+ } | null>;
221
+ deleteReconciliationRun(db: PostgresJsDatabase, id: string): Promise<{
222
+ id: string;
223
+ } | null>;
224
+ listReconciliationItems(db: PostgresJsDatabase, query: ChannelReconciliationItemListQuery): Promise<{
225
+ data: {
226
+ id: string;
227
+ reconciliationRunId: string;
228
+ bookingLinkId: string | null;
229
+ bookingId: string | null;
230
+ externalBookingId: string | null;
231
+ issueType: "other" | "missing_booking" | "status_mismatch" | "amount_mismatch" | "cancel_mismatch" | "missing_payout";
232
+ severity: "error" | "info" | "warning";
233
+ resolutionStatus: "ignored" | "open" | "resolved";
234
+ notes: string | null;
235
+ resolvedAt: Date | null;
236
+ createdAt: Date;
237
+ updatedAt: Date;
238
+ }[];
239
+ total: number;
240
+ limit: number;
241
+ offset: number;
242
+ }>;
243
+ getReconciliationItemById(db: PostgresJsDatabase, id: string): Promise<{
244
+ id: string;
245
+ reconciliationRunId: string;
246
+ bookingLinkId: string | null;
247
+ bookingId: string | null;
248
+ externalBookingId: string | null;
249
+ issueType: "other" | "missing_booking" | "status_mismatch" | "amount_mismatch" | "cancel_mismatch" | "missing_payout";
250
+ severity: "error" | "info" | "warning";
251
+ resolutionStatus: "ignored" | "open" | "resolved";
252
+ notes: string | null;
253
+ resolvedAt: Date | null;
254
+ createdAt: Date;
255
+ updatedAt: Date;
256
+ } | null>;
257
+ createReconciliationItem(db: PostgresJsDatabase, data: CreateChannelReconciliationItemInput): Promise<{
258
+ bookingId: string | null;
259
+ createdAt: Date;
260
+ updatedAt: Date;
261
+ id: string;
262
+ externalBookingId: string | null;
263
+ notes: string | null;
264
+ bookingLinkId: string | null;
265
+ reconciliationRunId: string;
266
+ issueType: "other" | "missing_booking" | "status_mismatch" | "amount_mismatch" | "cancel_mismatch" | "missing_payout";
267
+ resolutionStatus: "ignored" | "open" | "resolved";
268
+ severity: "error" | "info" | "warning";
269
+ resolvedAt: Date | null;
270
+ } | undefined>;
271
+ updateReconciliationItem(db: PostgresJsDatabase, id: string, data: UpdateChannelReconciliationItemInput): Promise<{
272
+ id: string;
273
+ reconciliationRunId: string;
274
+ bookingLinkId: string | null;
275
+ bookingId: string | null;
276
+ externalBookingId: string | null;
277
+ issueType: "other" | "missing_booking" | "status_mismatch" | "amount_mismatch" | "cancel_mismatch" | "missing_payout";
278
+ severity: "error" | "info" | "warning";
279
+ resolutionStatus: "ignored" | "open" | "resolved";
280
+ notes: string | null;
281
+ resolvedAt: Date | null;
282
+ createdAt: Date;
283
+ updatedAt: Date;
284
+ } | null>;
285
+ deleteReconciliationItem(db: PostgresJsDatabase, id: string): Promise<{
286
+ id: string;
287
+ } | null>;
288
+ listReleaseExecutions(db: PostgresJsDatabase, query: ChannelInventoryReleaseExecutionListQuery): Promise<{
289
+ data: {
290
+ id: string;
291
+ allotmentId: string;
292
+ releaseRuleId: string | null;
293
+ targetId: string | null;
294
+ slotId: string | null;
295
+ actionTaken: "expired" | "released" | "retained" | "manual_override";
296
+ status: "pending" | "failed" | "skipped" | "completed";
297
+ releasedCapacity: number | null;
298
+ executedAt: Date | null;
299
+ notes: string | null;
300
+ metadata: Record<string, unknown> | null;
301
+ createdAt: Date;
302
+ updatedAt: Date;
303
+ }[];
304
+ total: number;
305
+ limit: number;
306
+ offset: number;
307
+ }>;
308
+ getReleaseExecutionById(db: PostgresJsDatabase, id: string): Promise<{
309
+ id: string;
310
+ allotmentId: string;
311
+ releaseRuleId: string | null;
312
+ targetId: string | null;
313
+ slotId: string | null;
314
+ actionTaken: "expired" | "released" | "retained" | "manual_override";
315
+ status: "pending" | "failed" | "skipped" | "completed";
316
+ releasedCapacity: number | null;
317
+ executedAt: Date | null;
318
+ notes: string | null;
319
+ metadata: Record<string, unknown> | null;
320
+ createdAt: Date;
321
+ updatedAt: Date;
322
+ } | null>;
323
+ createReleaseExecution(db: PostgresJsDatabase, data: CreateChannelInventoryReleaseExecutionInput): Promise<{
324
+ createdAt: Date;
325
+ updatedAt: Date;
326
+ metadata: Record<string, unknown> | null;
327
+ id: string;
328
+ status: "pending" | "failed" | "skipped" | "completed";
329
+ notes: string | null;
330
+ slotId: string | null;
331
+ allotmentId: string;
332
+ releaseRuleId: string | null;
333
+ targetId: string | null;
334
+ actionTaken: "expired" | "released" | "retained" | "manual_override";
335
+ releasedCapacity: number | null;
336
+ executedAt: Date | null;
337
+ } | undefined>;
338
+ updateReleaseExecution(db: PostgresJsDatabase, id: string, data: UpdateChannelInventoryReleaseExecutionInput): Promise<{
339
+ id: string;
340
+ allotmentId: string;
341
+ releaseRuleId: string | null;
342
+ targetId: string | null;
343
+ slotId: string | null;
344
+ actionTaken: "expired" | "released" | "retained" | "manual_override";
345
+ status: "pending" | "failed" | "skipped" | "completed";
346
+ releasedCapacity: number | null;
347
+ executedAt: Date | null;
348
+ notes: string | null;
349
+ metadata: Record<string, unknown> | null;
350
+ createdAt: Date;
351
+ updatedAt: Date;
352
+ } | null>;
353
+ deleteReleaseExecution(db: PostgresJsDatabase, id: string): Promise<{
354
+ id: string;
355
+ } | null>;
356
+ };
357
+ //# sourceMappingURL=settlements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settlements.d.ts","sourceRoot":"","sources":["../../src/service/settlements.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAUjE,OAAO,KAAK,EACV,yCAAyC,EACzC,kCAAkC,EAClC,iCAAiC,EACjC,8BAA8B,EAC9B,6BAA6B,EAC7B,2CAA2C,EAC3C,oCAAoC,EACpC,mCAAmC,EACnC,gCAAgC,EAChC,+BAA+B,EAC/B,2CAA2C,EAC3C,oCAAoC,EACpC,mCAAmC,EACnC,gCAAgC,EAChC,+BAA+B,EAChC,MAAM,YAAY,CAAA;AAEnB,eAAO,MAAM,2BAA2B;2BACT,kBAAkB,SAAS,6BAA6B;;;;;;;;;;;;;;;;;;;;;;6BAoBtD,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;;;;4BAS/B,kBAAkB,QAAQ,+BAA+B;;;;;;;;;;;;;;;;;4BAejF,kBAAkB,MAClB,MAAM,QACJ,+BAA+B;;;;;;;;;;;;;;;;;4BAiBT,kBAAkB,MAAM,MAAM;;;4BAQ9B,kBAAkB,SAAS,8BAA8B;;;;;;;;;;;;;;;;;;;;;;8BAyBvD,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;;;;6BAS/B,kBAAkB,QAAQ,gCAAgC;;;;;;;;;;;;;;;;;6BAcnF,kBAAkB,MAClB,MAAM,QACJ,gCAAgC;;;;;;;;;;;;;;;;;6BAgBT,kBAAkB,MAAM,MAAM;;;+BAQ5B,kBAAkB,SAAS,iCAAiC;;;;;;;;;;;;;;;;;;;;iCAsB1D,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;;gCAS/B,kBAAkB,QAAQ,mCAAmC;;;;;;;;;;;;;;;gCAczF,kBAAkB,MAClB,MAAM,QACJ,mCAAmC;;;;;;;;;;;;;;;gCAgBT,kBAAkB,MAAM,MAAM;;;gCAQ9B,kBAAkB,SAAS,kCAAkC;;;;;;;;;;;;;;;;;;;kCAiC3D,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;iCAU5D,kBAAkB,QAChB,oCAAoC;;;;;;;;;;;;;;iCActC,kBAAkB,MAClB,MAAM,QACJ,oCAAoC;;;;;;;;;;;;;;iCAeT,kBAAkB,MAAM,MAAM;;;8BAS3D,kBAAkB,SACf,yCAAyC;;;;;;;;;;;;;;;;;;;;gCAgChB,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;;+BAU1D,kBAAkB,QAChB,2CAA2C;;;;;;;;;;;;;;;+BAc7C,kBAAkB,MAClB,MAAM,QACJ,2CAA2C;;;;;;;;;;;;;;;+BAelB,kBAAkB,MAAM,MAAM;;;CAOhE,CAAA"}
@@ -0,0 +1,319 @@
1
+ import { and, desc, eq, sql } from "drizzle-orm";
2
+ import { channelInventoryReleaseExecutions, channelReconciliationItems, channelReconciliationRuns, channelSettlementItems, channelSettlementRuns, } from "../schema.js";
3
+ import { paginate, toDateOrNull } from "./helpers.js";
4
+ export const settlementServiceOperations = {
5
+ async listSettlementRuns(db, query) {
6
+ const conditions = [];
7
+ if (query.channelId)
8
+ conditions.push(eq(channelSettlementRuns.channelId, query.channelId));
9
+ if (query.contractId)
10
+ conditions.push(eq(channelSettlementRuns.contractId, query.contractId));
11
+ if (query.status)
12
+ conditions.push(eq(channelSettlementRuns.status, query.status));
13
+ const where = conditions.length ? and(...conditions) : undefined;
14
+ return paginate(db
15
+ .select()
16
+ .from(channelSettlementRuns)
17
+ .where(where)
18
+ .limit(query.limit)
19
+ .offset(query.offset)
20
+ .orderBy(desc(channelSettlementRuns.updatedAt)), db.select({ count: sql `count(*)::int` }).from(channelSettlementRuns).where(where), query.limit, query.offset);
21
+ },
22
+ async getSettlementRunById(db, id) {
23
+ const [row] = await db
24
+ .select()
25
+ .from(channelSettlementRuns)
26
+ .where(eq(channelSettlementRuns.id, id))
27
+ .limit(1);
28
+ return row ?? null;
29
+ },
30
+ async createSettlementRun(db, data) {
31
+ const { generatedAt, postedAt, paidAt, ...rest } = data;
32
+ const [row] = await db
33
+ .insert(channelSettlementRuns)
34
+ .values({
35
+ ...rest,
36
+ generatedAt: toDateOrNull(generatedAt),
37
+ postedAt: toDateOrNull(postedAt),
38
+ paidAt: toDateOrNull(paidAt),
39
+ })
40
+ .returning();
41
+ return row;
42
+ },
43
+ async updateSettlementRun(db, id, data) {
44
+ const { generatedAt, postedAt, paidAt, ...rest } = data;
45
+ const [row] = await db
46
+ .update(channelSettlementRuns)
47
+ .set({
48
+ ...rest,
49
+ generatedAt: toDateOrNull(generatedAt),
50
+ postedAt: toDateOrNull(postedAt),
51
+ paidAt: toDateOrNull(paidAt),
52
+ updatedAt: new Date(),
53
+ })
54
+ .where(eq(channelSettlementRuns.id, id))
55
+ .returning();
56
+ return row ?? null;
57
+ },
58
+ async deleteSettlementRun(db, id) {
59
+ const [row] = await db
60
+ .delete(channelSettlementRuns)
61
+ .where(eq(channelSettlementRuns.id, id))
62
+ .returning({ id: channelSettlementRuns.id });
63
+ return row ?? null;
64
+ },
65
+ async listSettlementItems(db, query) {
66
+ const conditions = [];
67
+ if (query.settlementRunId) {
68
+ conditions.push(eq(channelSettlementItems.settlementRunId, query.settlementRunId));
69
+ }
70
+ if (query.bookingLinkId) {
71
+ conditions.push(eq(channelSettlementItems.bookingLinkId, query.bookingLinkId));
72
+ }
73
+ if (query.bookingId)
74
+ conditions.push(eq(channelSettlementItems.bookingId, query.bookingId));
75
+ if (query.status)
76
+ conditions.push(eq(channelSettlementItems.status, query.status));
77
+ const where = conditions.length ? and(...conditions) : undefined;
78
+ return paginate(db
79
+ .select()
80
+ .from(channelSettlementItems)
81
+ .where(where)
82
+ .limit(query.limit)
83
+ .offset(query.offset)
84
+ .orderBy(desc(channelSettlementItems.updatedAt)), db.select({ count: sql `count(*)::int` }).from(channelSettlementItems).where(where), query.limit, query.offset);
85
+ },
86
+ async getSettlementItemById(db, id) {
87
+ const [row] = await db
88
+ .select()
89
+ .from(channelSettlementItems)
90
+ .where(eq(channelSettlementItems.id, id))
91
+ .limit(1);
92
+ return row ?? null;
93
+ },
94
+ async createSettlementItem(db, data) {
95
+ const { remittanceDueAt, paidAt, ...rest } = data;
96
+ const [row] = await db
97
+ .insert(channelSettlementItems)
98
+ .values({
99
+ ...rest,
100
+ remittanceDueAt: toDateOrNull(remittanceDueAt),
101
+ paidAt: toDateOrNull(paidAt),
102
+ })
103
+ .returning();
104
+ return row;
105
+ },
106
+ async updateSettlementItem(db, id, data) {
107
+ const { remittanceDueAt, paidAt, ...rest } = data;
108
+ const [row] = await db
109
+ .update(channelSettlementItems)
110
+ .set({
111
+ ...rest,
112
+ remittanceDueAt: toDateOrNull(remittanceDueAt),
113
+ paidAt: toDateOrNull(paidAt),
114
+ updatedAt: new Date(),
115
+ })
116
+ .where(eq(channelSettlementItems.id, id))
117
+ .returning();
118
+ return row ?? null;
119
+ },
120
+ async deleteSettlementItem(db, id) {
121
+ const [row] = await db
122
+ .delete(channelSettlementItems)
123
+ .where(eq(channelSettlementItems.id, id))
124
+ .returning({ id: channelSettlementItems.id });
125
+ return row ?? null;
126
+ },
127
+ async listReconciliationRuns(db, query) {
128
+ const conditions = [];
129
+ if (query.channelId)
130
+ conditions.push(eq(channelReconciliationRuns.channelId, query.channelId));
131
+ if (query.contractId) {
132
+ conditions.push(eq(channelReconciliationRuns.contractId, query.contractId));
133
+ }
134
+ if (query.status)
135
+ conditions.push(eq(channelReconciliationRuns.status, query.status));
136
+ const where = conditions.length ? and(...conditions) : undefined;
137
+ return paginate(db
138
+ .select()
139
+ .from(channelReconciliationRuns)
140
+ .where(where)
141
+ .limit(query.limit)
142
+ .offset(query.offset)
143
+ .orderBy(desc(channelReconciliationRuns.updatedAt)), db.select({ count: sql `count(*)::int` }).from(channelReconciliationRuns).where(where), query.limit, query.offset);
144
+ },
145
+ async getReconciliationRunById(db, id) {
146
+ const [row] = await db
147
+ .select()
148
+ .from(channelReconciliationRuns)
149
+ .where(eq(channelReconciliationRuns.id, id))
150
+ .limit(1);
151
+ return row ?? null;
152
+ },
153
+ async createReconciliationRun(db, data) {
154
+ const { startedAt, completedAt, ...rest } = data;
155
+ const [row] = await db
156
+ .insert(channelReconciliationRuns)
157
+ .values({
158
+ ...rest,
159
+ startedAt: toDateOrNull(startedAt),
160
+ completedAt: toDateOrNull(completedAt),
161
+ })
162
+ .returning();
163
+ return row;
164
+ },
165
+ async updateReconciliationRun(db, id, data) {
166
+ const { startedAt, completedAt, ...rest } = data;
167
+ const [row] = await db
168
+ .update(channelReconciliationRuns)
169
+ .set({
170
+ ...rest,
171
+ startedAt: toDateOrNull(startedAt),
172
+ completedAt: toDateOrNull(completedAt),
173
+ updatedAt: new Date(),
174
+ })
175
+ .where(eq(channelReconciliationRuns.id, id))
176
+ .returning();
177
+ return row ?? null;
178
+ },
179
+ async deleteReconciliationRun(db, id) {
180
+ const [row] = await db
181
+ .delete(channelReconciliationRuns)
182
+ .where(eq(channelReconciliationRuns.id, id))
183
+ .returning({ id: channelReconciliationRuns.id });
184
+ return row ?? null;
185
+ },
186
+ async listReconciliationItems(db, query) {
187
+ const conditions = [];
188
+ if (query.reconciliationRunId) {
189
+ conditions.push(eq(channelReconciliationItems.reconciliationRunId, query.reconciliationRunId));
190
+ }
191
+ if (query.bookingLinkId) {
192
+ conditions.push(eq(channelReconciliationItems.bookingLinkId, query.bookingLinkId));
193
+ }
194
+ if (query.bookingId) {
195
+ conditions.push(eq(channelReconciliationItems.bookingId, query.bookingId));
196
+ }
197
+ if (query.issueType)
198
+ conditions.push(eq(channelReconciliationItems.issueType, query.issueType));
199
+ if (query.resolutionStatus) {
200
+ conditions.push(eq(channelReconciliationItems.resolutionStatus, query.resolutionStatus));
201
+ }
202
+ const where = conditions.length ? and(...conditions) : undefined;
203
+ return paginate(db
204
+ .select()
205
+ .from(channelReconciliationItems)
206
+ .where(where)
207
+ .limit(query.limit)
208
+ .offset(query.offset)
209
+ .orderBy(desc(channelReconciliationItems.updatedAt)), db
210
+ .select({ count: sql `count(*)::int` })
211
+ .from(channelReconciliationItems)
212
+ .where(where), query.limit, query.offset);
213
+ },
214
+ async getReconciliationItemById(db, id) {
215
+ const [row] = await db
216
+ .select()
217
+ .from(channelReconciliationItems)
218
+ .where(eq(channelReconciliationItems.id, id))
219
+ .limit(1);
220
+ return row ?? null;
221
+ },
222
+ async createReconciliationItem(db, data) {
223
+ const { resolvedAt, ...rest } = data;
224
+ const [row] = await db
225
+ .insert(channelReconciliationItems)
226
+ .values({
227
+ ...rest,
228
+ resolvedAt: toDateOrNull(resolvedAt),
229
+ })
230
+ .returning();
231
+ return row;
232
+ },
233
+ async updateReconciliationItem(db, id, data) {
234
+ const { resolvedAt, ...rest } = data;
235
+ const [row] = await db
236
+ .update(channelReconciliationItems)
237
+ .set({
238
+ ...rest,
239
+ resolvedAt: toDateOrNull(resolvedAt),
240
+ updatedAt: new Date(),
241
+ })
242
+ .where(eq(channelReconciliationItems.id, id))
243
+ .returning();
244
+ return row ?? null;
245
+ },
246
+ async deleteReconciliationItem(db, id) {
247
+ const [row] = await db
248
+ .delete(channelReconciliationItems)
249
+ .where(eq(channelReconciliationItems.id, id))
250
+ .returning({ id: channelReconciliationItems.id });
251
+ return row ?? null;
252
+ },
253
+ async listReleaseExecutions(db, query) {
254
+ const conditions = [];
255
+ if (query.allotmentId) {
256
+ conditions.push(eq(channelInventoryReleaseExecutions.allotmentId, query.allotmentId));
257
+ }
258
+ if (query.releaseRuleId) {
259
+ conditions.push(eq(channelInventoryReleaseExecutions.releaseRuleId, query.releaseRuleId));
260
+ }
261
+ if (query.targetId) {
262
+ conditions.push(eq(channelInventoryReleaseExecutions.targetId, query.targetId));
263
+ }
264
+ if (query.slotId)
265
+ conditions.push(eq(channelInventoryReleaseExecutions.slotId, query.slotId));
266
+ if (query.status)
267
+ conditions.push(eq(channelInventoryReleaseExecutions.status, query.status));
268
+ const where = conditions.length ? and(...conditions) : undefined;
269
+ return paginate(db
270
+ .select()
271
+ .from(channelInventoryReleaseExecutions)
272
+ .where(where)
273
+ .limit(query.limit)
274
+ .offset(query.offset)
275
+ .orderBy(desc(channelInventoryReleaseExecutions.updatedAt)), db
276
+ .select({ count: sql `count(*)::int` })
277
+ .from(channelInventoryReleaseExecutions)
278
+ .where(where), query.limit, query.offset);
279
+ },
280
+ async getReleaseExecutionById(db, id) {
281
+ const [row] = await db
282
+ .select()
283
+ .from(channelInventoryReleaseExecutions)
284
+ .where(eq(channelInventoryReleaseExecutions.id, id))
285
+ .limit(1);
286
+ return row ?? null;
287
+ },
288
+ async createReleaseExecution(db, data) {
289
+ const { executedAt, ...rest } = data;
290
+ const [row] = await db
291
+ .insert(channelInventoryReleaseExecutions)
292
+ .values({
293
+ ...rest,
294
+ executedAt: toDateOrNull(executedAt),
295
+ })
296
+ .returning();
297
+ return row;
298
+ },
299
+ async updateReleaseExecution(db, id, data) {
300
+ const { executedAt, ...rest } = data;
301
+ const [row] = await db
302
+ .update(channelInventoryReleaseExecutions)
303
+ .set({
304
+ ...rest,
305
+ executedAt: toDateOrNull(executedAt),
306
+ updatedAt: new Date(),
307
+ })
308
+ .where(eq(channelInventoryReleaseExecutions.id, id))
309
+ .returning();
310
+ return row ?? null;
311
+ },
312
+ async deleteReleaseExecution(db, id) {
313
+ const [row] = await db
314
+ .delete(channelInventoryReleaseExecutions)
315
+ .where(eq(channelInventoryReleaseExecutions.id, id))
316
+ .returning({ id: channelInventoryReleaseExecutions.id });
317
+ return row ?? null;
318
+ },
319
+ };