@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,395 @@
1
+ /**
2
+ * Admin routes for promotions — mounted by the operator starter at
3
+ * `/v1/admin/promotions/*` (staff-actor-gated by the parent app's
4
+ * middleware chain).
5
+ *
6
+ * PR1 ships CRUD only. Public storefront routes are exposed via the
7
+ * existing `/v1/public/products/:productId/offers` endpoints in
8
+ * `@voyant-travel/storefront` once the storefront resolver is wired in PR4.
9
+ */
10
+ import { type Env } from "./routes-shared.js";
11
+ export declare const promotionsRoutes: import("hono/hono-base").HonoBase<Env, {
12
+ "/": {
13
+ $get: {
14
+ input: {};
15
+ output: {
16
+ data: {
17
+ id: string;
18
+ name: string;
19
+ slug: string;
20
+ description: string | null;
21
+ discountType: "percentage" | "fixed_amount";
22
+ discountPercent: string | null;
23
+ discountAmountCents: number | null;
24
+ currency: string | null;
25
+ scope: {
26
+ kind: "global";
27
+ } | {
28
+ kind: "products";
29
+ productIds: string[];
30
+ } | {
31
+ kind: "categories";
32
+ categoryIds: string[];
33
+ } | {
34
+ kind: "destinations";
35
+ destinationIds: string[];
36
+ } | {
37
+ kind: "markets";
38
+ marketIds: string[];
39
+ } | {
40
+ kind: "audiences";
41
+ audiences: ("staff" | "customer" | "partner" | "supplier")[];
42
+ } | {
43
+ kind: "fare_codes";
44
+ fareCodes: string[];
45
+ } | {
46
+ kind: "cabin_grades";
47
+ cabinGradeCodes: string[];
48
+ };
49
+ conditions: {
50
+ minPax?: number | undefined;
51
+ pastGuestOnly?: boolean | undefined;
52
+ soloTravelerOnly?: boolean | undefined;
53
+ childTravelerOnly?: boolean | undefined;
54
+ familyOnly?: boolean | undefined;
55
+ };
56
+ validFrom: string | null;
57
+ validUntil: string | null;
58
+ code: string | null;
59
+ stackable: boolean;
60
+ active: boolean;
61
+ metadata: import("hono/utils/types").JSONValue;
62
+ createdAt: string;
63
+ updatedAt: string;
64
+ }[];
65
+ total: number;
66
+ limit: number;
67
+ offset: number;
68
+ };
69
+ outputFormat: "json";
70
+ status: import("hono/utils/http-status").ContentfulStatusCode;
71
+ };
72
+ };
73
+ } & {
74
+ "/": {
75
+ $post: {
76
+ input: {};
77
+ output: {
78
+ data: {
79
+ id: string;
80
+ code: string | null;
81
+ currency: string | null;
82
+ validUntil: string | null;
83
+ validFrom: string | null;
84
+ active: boolean;
85
+ metadata: import("hono/utils/types").JSONValue;
86
+ description: string | null;
87
+ name: string;
88
+ createdAt: string;
89
+ updatedAt: string;
90
+ slug: string;
91
+ discountType: "percentage" | "fixed_amount";
92
+ discountPercent: string | null;
93
+ discountAmountCents: number | null;
94
+ scope: {
95
+ kind: "global";
96
+ } | {
97
+ kind: "products";
98
+ productIds: string[];
99
+ } | {
100
+ kind: "categories";
101
+ categoryIds: string[];
102
+ } | {
103
+ kind: "destinations";
104
+ destinationIds: string[];
105
+ } | {
106
+ kind: "markets";
107
+ marketIds: string[];
108
+ } | {
109
+ kind: "audiences";
110
+ audiences: ("staff" | "customer" | "partner" | "supplier")[];
111
+ } | {
112
+ kind: "fare_codes";
113
+ fareCodes: string[];
114
+ } | {
115
+ kind: "cabin_grades";
116
+ cabinGradeCodes: string[];
117
+ };
118
+ conditions: {
119
+ minPax?: number | undefined;
120
+ pastGuestOnly?: boolean | undefined;
121
+ soloTravelerOnly?: boolean | undefined;
122
+ childTravelerOnly?: boolean | undefined;
123
+ familyOnly?: boolean | undefined;
124
+ };
125
+ stackable: boolean;
126
+ };
127
+ };
128
+ outputFormat: "json";
129
+ status: 201;
130
+ };
131
+ };
132
+ } & {
133
+ "/:id": {
134
+ $get: {
135
+ input: {
136
+ param: {
137
+ id: string;
138
+ };
139
+ };
140
+ output: {
141
+ data: {
142
+ id: string;
143
+ code: string | null;
144
+ currency: string | null;
145
+ validUntil: string | null;
146
+ validFrom: string | null;
147
+ active: boolean;
148
+ metadata: import("hono/utils/types").JSONValue;
149
+ description: string | null;
150
+ name: string;
151
+ createdAt: string;
152
+ updatedAt: string;
153
+ slug: string;
154
+ discountType: "percentage" | "fixed_amount";
155
+ discountPercent: string | null;
156
+ discountAmountCents: number | null;
157
+ scope: {
158
+ kind: "global";
159
+ } | {
160
+ kind: "products";
161
+ productIds: string[];
162
+ } | {
163
+ kind: "categories";
164
+ categoryIds: string[];
165
+ } | {
166
+ kind: "destinations";
167
+ destinationIds: string[];
168
+ } | {
169
+ kind: "markets";
170
+ marketIds: string[];
171
+ } | {
172
+ kind: "audiences";
173
+ audiences: ("staff" | "customer" | "partner" | "supplier")[];
174
+ } | {
175
+ kind: "fare_codes";
176
+ fareCodes: string[];
177
+ } | {
178
+ kind: "cabin_grades";
179
+ cabinGradeCodes: string[];
180
+ };
181
+ conditions: {
182
+ minPax?: number | undefined;
183
+ pastGuestOnly?: boolean | undefined;
184
+ soloTravelerOnly?: boolean | undefined;
185
+ childTravelerOnly?: boolean | undefined;
186
+ familyOnly?: boolean | undefined;
187
+ };
188
+ stackable: boolean;
189
+ };
190
+ };
191
+ outputFormat: "json";
192
+ status: import("hono/utils/http-status").ContentfulStatusCode;
193
+ } | {
194
+ input: {
195
+ param: {
196
+ id: string;
197
+ };
198
+ };
199
+ output: {
200
+ error: string;
201
+ };
202
+ outputFormat: "json";
203
+ status: 404;
204
+ };
205
+ };
206
+ } & {
207
+ "/:id": {
208
+ $patch: {
209
+ input: {
210
+ param: {
211
+ id: string;
212
+ };
213
+ };
214
+ output: {
215
+ error: string;
216
+ };
217
+ outputFormat: "json";
218
+ status: 404;
219
+ } | {
220
+ input: {
221
+ param: {
222
+ id: string;
223
+ };
224
+ };
225
+ output: {
226
+ data: {
227
+ id: string;
228
+ code: string | null;
229
+ currency: string | null;
230
+ validUntil: string | null;
231
+ validFrom: string | null;
232
+ active: boolean;
233
+ metadata: import("hono/utils/types").JSONValue;
234
+ description: string | null;
235
+ name: string;
236
+ createdAt: string;
237
+ updatedAt: string;
238
+ slug: string;
239
+ discountType: "percentage" | "fixed_amount";
240
+ discountPercent: string | null;
241
+ discountAmountCents: number | null;
242
+ scope: {
243
+ kind: "global";
244
+ } | {
245
+ kind: "products";
246
+ productIds: string[];
247
+ } | {
248
+ kind: "categories";
249
+ categoryIds: string[];
250
+ } | {
251
+ kind: "destinations";
252
+ destinationIds: string[];
253
+ } | {
254
+ kind: "markets";
255
+ marketIds: string[];
256
+ } | {
257
+ kind: "audiences";
258
+ audiences: ("staff" | "customer" | "partner" | "supplier")[];
259
+ } | {
260
+ kind: "fare_codes";
261
+ fareCodes: string[];
262
+ } | {
263
+ kind: "cabin_grades";
264
+ cabinGradeCodes: string[];
265
+ };
266
+ conditions: {
267
+ minPax?: number | undefined;
268
+ pastGuestOnly?: boolean | undefined;
269
+ soloTravelerOnly?: boolean | undefined;
270
+ childTravelerOnly?: boolean | undefined;
271
+ familyOnly?: boolean | undefined;
272
+ };
273
+ stackable: boolean;
274
+ };
275
+ };
276
+ outputFormat: "json";
277
+ status: import("hono/utils/http-status").ContentfulStatusCode;
278
+ };
279
+ };
280
+ } & {
281
+ "/:id/archive": {
282
+ $post: {
283
+ input: {
284
+ param: {
285
+ id: string;
286
+ };
287
+ };
288
+ output: {
289
+ error: string;
290
+ };
291
+ outputFormat: "json";
292
+ status: 404;
293
+ } | {
294
+ input: {
295
+ param: {
296
+ id: string;
297
+ };
298
+ };
299
+ output: {
300
+ data: {
301
+ id: string;
302
+ code: string | null;
303
+ currency: string | null;
304
+ validUntil: string | null;
305
+ validFrom: string | null;
306
+ active: boolean;
307
+ metadata: import("hono/utils/types").JSONValue;
308
+ description: string | null;
309
+ name: string;
310
+ createdAt: string;
311
+ updatedAt: string;
312
+ slug: string;
313
+ discountType: "percentage" | "fixed_amount";
314
+ discountPercent: string | null;
315
+ discountAmountCents: number | null;
316
+ scope: {
317
+ kind: "global";
318
+ } | {
319
+ kind: "products";
320
+ productIds: string[];
321
+ } | {
322
+ kind: "categories";
323
+ categoryIds: string[];
324
+ } | {
325
+ kind: "destinations";
326
+ destinationIds: string[];
327
+ } | {
328
+ kind: "markets";
329
+ marketIds: string[];
330
+ } | {
331
+ kind: "audiences";
332
+ audiences: ("staff" | "customer" | "partner" | "supplier")[];
333
+ } | {
334
+ kind: "fare_codes";
335
+ fareCodes: string[];
336
+ } | {
337
+ kind: "cabin_grades";
338
+ cabinGradeCodes: string[];
339
+ };
340
+ conditions: {
341
+ minPax?: number | undefined;
342
+ pastGuestOnly?: boolean | undefined;
343
+ soloTravelerOnly?: boolean | undefined;
344
+ childTravelerOnly?: boolean | undefined;
345
+ familyOnly?: boolean | undefined;
346
+ };
347
+ stackable: boolean;
348
+ };
349
+ };
350
+ outputFormat: "json";
351
+ status: import("hono/utils/http-status").ContentfulStatusCode;
352
+ };
353
+ };
354
+ } & {
355
+ "/:id": {
356
+ $delete: {
357
+ input: {
358
+ param: {
359
+ id: string;
360
+ };
361
+ };
362
+ output: {
363
+ error: string;
364
+ };
365
+ outputFormat: "json";
366
+ status: 404;
367
+ } | {
368
+ input: {
369
+ param: {
370
+ id: string;
371
+ };
372
+ };
373
+ output: {
374
+ data: {
375
+ id: string;
376
+ };
377
+ };
378
+ outputFormat: "json";
379
+ status: import("hono/utils/http-status").ContentfulStatusCode;
380
+ } | {
381
+ input: {
382
+ param: {
383
+ id: string;
384
+ };
385
+ };
386
+ output: {
387
+ error: string;
388
+ };
389
+ outputFormat: "json";
390
+ status: 409;
391
+ };
392
+ };
393
+ }, "/", "/:id">;
394
+ export type PromotionsRoutes = typeof promotionsRoutes;
395
+ //# sourceMappingURL=routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/promotions/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,EAAE,KAAK,GAAG,EAAY,MAAM,oBAAoB,CAAA;AAQvD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAgDzB,CAAA;AAEJ,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAA"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Admin routes for promotions — mounted by the operator starter at
3
+ * `/v1/admin/promotions/*` (staff-actor-gated by the parent app's
4
+ * middleware chain).
5
+ *
6
+ * PR1 ships CRUD only. Public storefront routes are exposed via the
7
+ * existing `/v1/public/products/:productId/offers` endpoints in
8
+ * `@voyant-travel/storefront` once the storefront resolver is wired in PR4.
9
+ */
10
+ import { parseJsonBody, parseQuery } from "@voyant-travel/hono";
11
+ import { Hono } from "hono";
12
+ import { notFound } from "./routes-shared.js";
13
+ import { promotionsService } from "./service.js";
14
+ import { insertPromotionalOfferSchema, promotionalOfferListQuerySchema, updatePromotionalOfferSchema, } from "./validation.js";
15
+ export const promotionsRoutes = new Hono()
16
+ .get("/", async (c) => {
17
+ const query = await parseQuery(c, promotionalOfferListQuerySchema);
18
+ return c.json(await promotionsService.listOffers(c.get("db"), query));
19
+ })
20
+ .post("/", async (c) => c.json({
21
+ data: await promotionsService.createOffer(c.get("db"), await parseJsonBody(c, insertPromotionalOfferSchema), { eventBus: c.get("eventBus") }),
22
+ }, 201))
23
+ .get("/:id", async (c) => {
24
+ const offer = await promotionsService.getOfferById(c.get("db"), c.req.param("id"));
25
+ return offer ? c.json({ data: offer }) : notFound(c, "Promotional offer not found");
26
+ })
27
+ .patch("/:id", async (c) => {
28
+ const patch = await parseJsonBody(c, updatePromotionalOfferSchema);
29
+ const offer = await promotionsService.updateOffer(c.get("db"), c.req.param("id"), patch, {
30
+ eventBus: c.get("eventBus"),
31
+ });
32
+ return offer ? c.json({ data: offer }) : notFound(c, "Promotional offer not found");
33
+ })
34
+ .post("/:id/archive", async (c) => {
35
+ const offer = await promotionsService.archiveOffer(c.get("db"), c.req.param("id"), {
36
+ eventBus: c.get("eventBus"),
37
+ });
38
+ return offer ? c.json({ data: offer }) : notFound(c, "Promotional offer not found");
39
+ })
40
+ .delete("/:id", async (c) => {
41
+ try {
42
+ const result = await promotionsService.deleteOffer(c.get("db"), c.req.param("id"), {
43
+ eventBus: c.get("eventBus"),
44
+ });
45
+ return result ? c.json({ data: result }) : notFound(c, "Promotional offer not found");
46
+ }
47
+ catch (err) {
48
+ // `deleteOffer` throws when redemptions exist (the FK RESTRICT
49
+ // would otherwise surface a less helpful error). Translate to 409.
50
+ if (err instanceof Error && err.message.includes("redemption(s) exist")) {
51
+ return c.json({ error: err.message }, 409);
52
+ }
53
+ throw err;
54
+ }
55
+ });