@voyant-travel/inventory 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 (311) hide show
  1. package/LICENSE +201 -0
  2. package/dist/action-ledger-drift.d.ts +29 -0
  3. package/dist/action-ledger-drift.d.ts.map +1 -0
  4. package/dist/action-ledger-drift.js +338 -0
  5. package/dist/action-ledger.d.ts +104 -0
  6. package/dist/action-ledger.d.ts.map +1 -0
  7. package/dist/action-ledger.js +100 -0
  8. package/dist/authoring/builder.d.ts +37 -0
  9. package/dist/authoring/builder.d.ts.map +1 -0
  10. package/dist/authoring/builder.js +248 -0
  11. package/dist/authoring/clone-content.d.ts +38 -0
  12. package/dist/authoring/clone-content.d.ts.map +1 -0
  13. package/dist/authoring/clone-content.js +367 -0
  14. package/dist/authoring/clone-pricing.d.ts +9 -0
  15. package/dist/authoring/clone-pricing.d.ts.map +1 -0
  16. package/dist/authoring/clone-pricing.js +242 -0
  17. package/dist/authoring/clone.d.ts +45 -0
  18. package/dist/authoring/clone.d.ts.map +1 -0
  19. package/dist/authoring/clone.js +142 -0
  20. package/dist/authoring/errors.d.ts +21 -0
  21. package/dist/authoring/errors.d.ts.map +1 -0
  22. package/dist/authoring/errors.js +13 -0
  23. package/dist/authoring/extension.d.ts +248 -0
  24. package/dist/authoring/extension.d.ts.map +1 -0
  25. package/dist/authoring/extension.js +116 -0
  26. package/dist/authoring/index.d.ts +12 -0
  27. package/dist/authoring/index.d.ts.map +1 -0
  28. package/dist/authoring/index.js +11 -0
  29. package/dist/authoring/schema.d.ts +85 -0
  30. package/dist/authoring/schema.d.ts.map +1 -0
  31. package/dist/authoring/schema.js +16 -0
  32. package/dist/authoring/service.d.ts +28 -0
  33. package/dist/authoring/service.d.ts.map +1 -0
  34. package/dist/authoring/service.js +66 -0
  35. package/dist/authoring/spec.d.ts +524 -0
  36. package/dist/authoring/spec.d.ts.map +1 -0
  37. package/dist/authoring/spec.js +167 -0
  38. package/dist/authoring/validate.d.ts +17 -0
  39. package/dist/authoring/validate.d.ts.map +1 -0
  40. package/dist/authoring/validate.js +83 -0
  41. package/dist/authoring.d.ts +2 -0
  42. package/dist/authoring.d.ts.map +1 -0
  43. package/dist/authoring.js +1 -0
  44. package/dist/booking-engine/handler-support.d.ts +91 -0
  45. package/dist/booking-engine/handler-support.d.ts.map +1 -0
  46. package/dist/booking-engine/handler-support.js +355 -0
  47. package/dist/booking-engine/handler.d.ts +404 -0
  48. package/dist/booking-engine/handler.d.ts.map +1 -0
  49. package/dist/booking-engine/handler.js +398 -0
  50. package/dist/booking-engine/index.d.ts +8 -0
  51. package/dist/booking-engine/index.d.ts.map +1 -0
  52. package/dist/booking-engine/index.js +7 -0
  53. package/dist/booking-engine.d.ts +2 -0
  54. package/dist/booking-engine.d.ts.map +1 -0
  55. package/dist/booking-engine.js +1 -0
  56. package/dist/booking-extension.d.ts +278 -0
  57. package/dist/booking-extension.d.ts.map +1 -0
  58. package/dist/booking-extension.js +161 -0
  59. package/dist/catalog-policy-departures.d.ts +52 -0
  60. package/dist/catalog-policy-departures.d.ts.map +1 -0
  61. package/dist/catalog-policy-departures.js +169 -0
  62. package/dist/catalog-policy-destinations.d.ts +43 -0
  63. package/dist/catalog-policy-destinations.d.ts.map +1 -0
  64. package/dist/catalog-policy-destinations.js +165 -0
  65. package/dist/catalog-policy-pricing.d.ts +55 -0
  66. package/dist/catalog-policy-pricing.d.ts.map +1 -0
  67. package/dist/catalog-policy-pricing.js +109 -0
  68. package/dist/catalog-policy-promotions.d.ts +52 -0
  69. package/dist/catalog-policy-promotions.d.ts.map +1 -0
  70. package/dist/catalog-policy-promotions.js +270 -0
  71. package/dist/catalog-policy-taxonomy.d.ts +51 -0
  72. package/dist/catalog-policy-taxonomy.d.ts.map +1 -0
  73. package/dist/catalog-policy-taxonomy.js +191 -0
  74. package/dist/catalog-policy.d.ts +33 -0
  75. package/dist/catalog-policy.d.ts.map +1 -0
  76. package/dist/catalog-policy.js +733 -0
  77. package/dist/content-shape.d.ts +15 -0
  78. package/dist/content-shape.d.ts.map +1 -0
  79. package/dist/content-shape.js +28 -0
  80. package/dist/draft-shape.d.ts +43 -0
  81. package/dist/draft-shape.d.ts.map +1 -0
  82. package/dist/draft-shape.js +48 -0
  83. package/dist/events.d.ts +37 -0
  84. package/dist/events.d.ts.map +1 -0
  85. package/dist/events.js +32 -0
  86. package/dist/extras/catalog-policy.d.ts +30 -0
  87. package/dist/extras/catalog-policy.d.ts.map +1 -0
  88. package/dist/extras/catalog-policy.js +319 -0
  89. package/dist/extras/content-shape.d.ts +5 -0
  90. package/dist/extras/content-shape.d.ts.map +1 -0
  91. package/dist/extras/content-shape.js +13 -0
  92. package/dist/extras/draft-shape.d.ts +34 -0
  93. package/dist/extras/draft-shape.d.ts.map +1 -0
  94. package/dist/extras/draft-shape.js +69 -0
  95. package/dist/extras/routes.d.ts +380 -0
  96. package/dist/extras/routes.d.ts.map +1 -0
  97. package/dist/extras/routes.js +59 -0
  98. package/dist/extras/schema-sourced-content.d.ts +254 -0
  99. package/dist/extras/schema-sourced-content.d.ts.map +1 -0
  100. package/dist/extras/schema-sourced-content.js +45 -0
  101. package/dist/extras/schema.d.ts +628 -0
  102. package/dist/extras/schema.d.ts.map +1 -0
  103. package/dist/extras/schema.js +87 -0
  104. package/dist/extras/service-catalog-plane.d.ts +77 -0
  105. package/dist/extras/service-catalog-plane.d.ts.map +1 -0
  106. package/dist/extras/service-catalog-plane.js +219 -0
  107. package/dist/extras/service-content-synthesizer.d.ts +41 -0
  108. package/dist/extras/service-content-synthesizer.d.ts.map +1 -0
  109. package/dist/extras/service-content-synthesizer.js +138 -0
  110. package/dist/extras/service-content.d.ts +48 -0
  111. package/dist/extras/service-content.d.ts.map +1 -0
  112. package/dist/extras/service-content.js +253 -0
  113. package/dist/extras/service.d.ts +185 -0
  114. package/dist/extras/service.d.ts.map +1 -0
  115. package/dist/extras/service.js +96 -0
  116. package/dist/extras/validation.d.ts +437 -0
  117. package/dist/extras/validation.d.ts.map +1 -0
  118. package/dist/extras/validation.js +149 -0
  119. package/dist/extras.d.ts +267 -0
  120. package/dist/extras.d.ts.map +1 -0
  121. package/dist/extras.js +19 -0
  122. package/dist/index.d.ts +22 -0
  123. package/dist/index.d.ts.map +1 -0
  124. package/dist/index.js +32 -0
  125. package/dist/interface.d.ts +5869 -0
  126. package/dist/interface.d.ts.map +1 -0
  127. package/dist/interface.js +54 -0
  128. package/dist/public-routes.d.ts +2 -0
  129. package/dist/public-routes.d.ts.map +1 -0
  130. package/dist/public-routes.js +1 -0
  131. package/dist/public-validation.d.ts +2 -0
  132. package/dist/public-validation.d.ts.map +1 -0
  133. package/dist/public-validation.js +1 -0
  134. package/dist/read-model.d.ts +25 -0
  135. package/dist/read-model.d.ts.map +1 -0
  136. package/dist/read-model.js +99 -0
  137. package/dist/route-env.d.ts +22 -0
  138. package/dist/route-env.d.ts.map +1 -0
  139. package/dist/route-env.js +1 -0
  140. package/dist/routes-associations.d.ts +164 -0
  141. package/dist/routes-associations.d.ts.map +1 -0
  142. package/dist/routes-associations.js +100 -0
  143. package/dist/routes-catalog.d.ts +436 -0
  144. package/dist/routes-catalog.d.ts.map +1 -0
  145. package/dist/routes-catalog.js +104 -0
  146. package/dist/routes-configuration.d.ts +773 -0
  147. package/dist/routes-configuration.d.ts.map +1 -0
  148. package/dist/routes-configuration.js +364 -0
  149. package/dist/routes-content.d.ts +74 -0
  150. package/dist/routes-content.d.ts.map +1 -0
  151. package/dist/routes-content.js +117 -0
  152. package/dist/routes-core.d.ts +331 -0
  153. package/dist/routes-core.d.ts.map +1 -0
  154. package/dist/routes-core.js +95 -0
  155. package/dist/routes-itinerary.d.ts +759 -0
  156. package/dist/routes-itinerary.d.ts.map +1 -0
  157. package/dist/routes-itinerary.js +387 -0
  158. package/dist/routes-maintenance.d.ts +32 -0
  159. package/dist/routes-maintenance.d.ts.map +1 -0
  160. package/dist/routes-maintenance.js +14 -0
  161. package/dist/routes-media.d.ts +634 -0
  162. package/dist/routes-media.d.ts.map +1 -0
  163. package/dist/routes-media.js +245 -0
  164. package/dist/routes-merchandising.d.ts +1120 -0
  165. package/dist/routes-merchandising.d.ts.map +1 -0
  166. package/dist/routes-merchandising.js +377 -0
  167. package/dist/routes-options.d.ts +363 -0
  168. package/dist/routes-options.d.ts.map +1 -0
  169. package/dist/routes-options.js +173 -0
  170. package/dist/routes-public.d.ts +776 -0
  171. package/dist/routes-public.d.ts.map +1 -0
  172. package/dist/routes-public.js +119 -0
  173. package/dist/routes-translations.d.ts +489 -0
  174. package/dist/routes-translations.d.ts.map +1 -0
  175. package/dist/routes-translations.js +258 -0
  176. package/dist/routes.d.ts +5097 -0
  177. package/dist/routes.d.ts.map +1 -0
  178. package/dist/routes.js +64 -0
  179. package/dist/schema-core.d.ts +1238 -0
  180. package/dist/schema-core.d.ts.map +1 -0
  181. package/dist/schema-core.js +157 -0
  182. package/dist/schema-itinerary.d.ts +1169 -0
  183. package/dist/schema-itinerary.d.ts.map +1 -0
  184. package/dist/schema-itinerary.js +130 -0
  185. package/dist/schema-relations.d.ts +117 -0
  186. package/dist/schema-relations.d.ts.map +1 -0
  187. package/dist/schema-relations.js +192 -0
  188. package/dist/schema-settings.d.ts +1800 -0
  189. package/dist/schema-settings.d.ts.map +1 -0
  190. package/dist/schema-settings.js +220 -0
  191. package/dist/schema-shared.d.ts +15 -0
  192. package/dist/schema-shared.d.ts.map +1 -0
  193. package/dist/schema-shared.js +91 -0
  194. package/dist/schema-sourced-content.d.ts +262 -0
  195. package/dist/schema-sourced-content.d.ts.map +1 -0
  196. package/dist/schema-sourced-content.js +69 -0
  197. package/dist/schema-taxonomy.d.ts +1363 -0
  198. package/dist/schema-taxonomy.d.ts.map +1 -0
  199. package/dist/schema-taxonomy.js +203 -0
  200. package/dist/schema.d.ts +10 -0
  201. package/dist/schema.d.ts.map +1 -0
  202. package/dist/schema.js +9 -0
  203. package/dist/service-aggregates.d.ts +29 -0
  204. package/dist/service-aggregates.d.ts.map +1 -0
  205. package/dist/service-aggregates.js +56 -0
  206. package/dist/service-catalog-plane-destinations.d.ts +30 -0
  207. package/dist/service-catalog-plane-destinations.d.ts.map +1 -0
  208. package/dist/service-catalog-plane-destinations.js +143 -0
  209. package/dist/service-catalog-plane-taxonomy.d.ts +73 -0
  210. package/dist/service-catalog-plane-taxonomy.d.ts.map +1 -0
  211. package/dist/service-catalog-plane-taxonomy.js +242 -0
  212. package/dist/service-catalog-plane.d.ts +179 -0
  213. package/dist/service-catalog-plane.d.ts.map +1 -0
  214. package/dist/service-catalog-plane.js +431 -0
  215. package/dist/service-catalog.d.ts +251 -0
  216. package/dist/service-catalog.d.ts.map +1 -0
  217. package/dist/service-catalog.js +517 -0
  218. package/dist/service-configuration.d.ts +261 -0
  219. package/dist/service-configuration.d.ts.map +1 -0
  220. package/dist/service-configuration.js +343 -0
  221. package/dist/service-content-owned.d.ts +68 -0
  222. package/dist/service-content-owned.d.ts.map +1 -0
  223. package/dist/service-content-owned.js +329 -0
  224. package/dist/service-content-synthesizer.d.ts +90 -0
  225. package/dist/service-content-synthesizer.d.ts.map +1 -0
  226. package/dist/service-content-synthesizer.js +178 -0
  227. package/dist/service-content.d.ts +106 -0
  228. package/dist/service-content.d.ts.map +1 -0
  229. package/dist/service-content.js +388 -0
  230. package/dist/service-core.d.ts +194 -0
  231. package/dist/service-core.d.ts.map +1 -0
  232. package/dist/service-core.js +213 -0
  233. package/dist/service-delivery-formats.d.ts +58 -0
  234. package/dist/service-delivery-formats.d.ts.map +1 -0
  235. package/dist/service-delivery-formats.js +107 -0
  236. package/dist/service-destinations.d.ts +223 -0
  237. package/dist/service-destinations.d.ts.map +1 -0
  238. package/dist/service-destinations.js +310 -0
  239. package/dist/service-itinerary-history.d.ts +457 -0
  240. package/dist/service-itinerary-history.d.ts.map +1 -0
  241. package/dist/service-itinerary-history.js +135 -0
  242. package/dist/service-itinerary.d.ts +1149 -0
  243. package/dist/service-itinerary.d.ts.map +1 -0
  244. package/dist/service-itinerary.js +419 -0
  245. package/dist/service-media.d.ts +272 -0
  246. package/dist/service-media.d.ts.map +1 -0
  247. package/dist/service-media.js +320 -0
  248. package/dist/service-merchandising.d.ts +184 -0
  249. package/dist/service-merchandising.d.ts.map +1 -0
  250. package/dist/service-merchandising.js +181 -0
  251. package/dist/service-option-translations.d.ts +268 -0
  252. package/dist/service-option-translations.d.ts.map +1 -0
  253. package/dist/service-option-translations.js +300 -0
  254. package/dist/service-options.d.ts +181 -0
  255. package/dist/service-options.d.ts.map +1 -0
  256. package/dist/service-options.js +179 -0
  257. package/dist/service-product-destinations.d.ts +37 -0
  258. package/dist/service-product-destinations.d.ts.map +1 -0
  259. package/dist/service-product-destinations.js +94 -0
  260. package/dist/service-public.d.ts +664 -0
  261. package/dist/service-public.d.ts.map +1 -0
  262. package/dist/service-public.js +374 -0
  263. package/dist/service-taxonomy.d.ts +197 -0
  264. package/dist/service-taxonomy.d.ts.map +1 -0
  265. package/dist/service-taxonomy.js +221 -0
  266. package/dist/service.d.ts +3929 -0
  267. package/dist/service.d.ts.map +1 -0
  268. package/dist/service.js +28 -0
  269. package/dist/tasks/brochure-printers.d.ts +31 -0
  270. package/dist/tasks/brochure-printers.d.ts.map +1 -0
  271. package/dist/tasks/brochure-printers.js +149 -0
  272. package/dist/tasks/brochure-templates.d.ts +36 -0
  273. package/dist/tasks/brochure-templates.d.ts.map +1 -0
  274. package/dist/tasks/brochure-templates.js +110 -0
  275. package/dist/tasks/brochures.d.ts +43 -0
  276. package/dist/tasks/brochures.d.ts.map +1 -0
  277. package/dist/tasks/brochures.js +72 -0
  278. package/dist/tasks/generate-pdf.d.ts +8 -0
  279. package/dist/tasks/generate-pdf.d.ts.map +1 -0
  280. package/dist/tasks/generate-pdf.js +106 -0
  281. package/dist/tasks/index.d.ts +5 -0
  282. package/dist/tasks/index.d.ts.map +1 -0
  283. package/dist/tasks/index.js +4 -0
  284. package/dist/tasks/pdf-text.d.ts +2 -0
  285. package/dist/tasks/pdf-text.d.ts.map +1 -0
  286. package/dist/tasks/pdf-text.js +40 -0
  287. package/dist/tasks.d.ts +2 -0
  288. package/dist/tasks.d.ts.map +1 -0
  289. package/dist/tasks.js +1 -0
  290. package/dist/validation-catalog.d.ts +2 -0
  291. package/dist/validation-catalog.d.ts.map +1 -0
  292. package/dist/validation-catalog.js +3 -0
  293. package/dist/validation-config.d.ts +2 -0
  294. package/dist/validation-config.d.ts.map +1 -0
  295. package/dist/validation-config.js +3 -0
  296. package/dist/validation-content.d.ts +2 -0
  297. package/dist/validation-content.d.ts.map +1 -0
  298. package/dist/validation-content.js +3 -0
  299. package/dist/validation-core.d.ts +2 -0
  300. package/dist/validation-core.d.ts.map +1 -0
  301. package/dist/validation-core.js +3 -0
  302. package/dist/validation-public.d.ts +2 -0
  303. package/dist/validation-public.d.ts.map +1 -0
  304. package/dist/validation-public.js +3 -0
  305. package/dist/validation-shared.d.ts +2 -0
  306. package/dist/validation-shared.d.ts.map +1 -0
  307. package/dist/validation-shared.js +3 -0
  308. package/dist/validation.d.ts +2 -0
  309. package/dist/validation.d.ts.map +1 -0
  310. package/dist/validation.js +3 -0
  311. package/package.json +204 -0
@@ -0,0 +1,194 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import type { z } from "zod";
3
+ import type { insertProductSchema, productListQuerySchema, updateProductSchema } from "./validation.js";
4
+ type ProductListQuery = z.infer<typeof productListQuerySchema>;
5
+ type CreateProductInput = z.infer<typeof insertProductSchema>;
6
+ type UpdateProductInput = z.infer<typeof updateProductSchema>;
7
+ export declare const coreProductsService: {
8
+ listProducts(db: PostgresJsDatabase, query: ProductListQuery): Promise<{
9
+ data: {
10
+ id: string;
11
+ name: string;
12
+ status: "draft" | "active" | "archived";
13
+ description: string | null;
14
+ inclusionsHtml: string | null;
15
+ exclusionsHtml: string | null;
16
+ termsHtml: string | null;
17
+ termsShowOnContract: boolean;
18
+ bookingMode: "date" | "date_time" | "open" | "stay" | "transfer" | "itinerary" | "other";
19
+ capacityMode: "free_sale" | "limited" | "on_request";
20
+ timezone: string | null;
21
+ defaultLanguageTag: string | null;
22
+ visibility: "public" | "private" | "hidden";
23
+ activated: boolean;
24
+ reservationTimeoutMinutes: number | null;
25
+ sellCurrency: string;
26
+ sellAmountCents: number | null;
27
+ costAmountCents: number | null;
28
+ marginPercent: number | null;
29
+ facilityId: string | null;
30
+ supplierId: string | null;
31
+ startDate: string | null;
32
+ endDate: string | null;
33
+ pax: number | null;
34
+ productTypeId: string | null;
35
+ contractTemplateId: string | null;
36
+ taxClassId: string | null;
37
+ customerPaymentPolicy: unknown;
38
+ tags: string[] | null;
39
+ createdAt: Date;
40
+ updatedAt: Date;
41
+ }[];
42
+ total: number;
43
+ limit: number;
44
+ offset: number;
45
+ }>;
46
+ getProductById(db: PostgresJsDatabase, id: string): Promise<{
47
+ id: string;
48
+ name: string;
49
+ status: "draft" | "active" | "archived";
50
+ description: string | null;
51
+ inclusionsHtml: string | null;
52
+ exclusionsHtml: string | null;
53
+ termsHtml: string | null;
54
+ termsShowOnContract: boolean;
55
+ bookingMode: "date" | "date_time" | "open" | "stay" | "transfer" | "itinerary" | "other";
56
+ capacityMode: "free_sale" | "limited" | "on_request";
57
+ timezone: string | null;
58
+ defaultLanguageTag: string | null;
59
+ visibility: "public" | "private" | "hidden";
60
+ activated: boolean;
61
+ reservationTimeoutMinutes: number | null;
62
+ sellCurrency: string;
63
+ sellAmountCents: number | null;
64
+ costAmountCents: number | null;
65
+ marginPercent: number | null;
66
+ facilityId: string | null;
67
+ supplierId: string | null;
68
+ startDate: string | null;
69
+ endDate: string | null;
70
+ pax: number | null;
71
+ productTypeId: string | null;
72
+ contractTemplateId: string | null;
73
+ taxClassId: string | null;
74
+ customerPaymentPolicy: unknown;
75
+ tags: string[] | null;
76
+ createdAt: Date;
77
+ updatedAt: Date;
78
+ } | null>;
79
+ /**
80
+ * Same as `getProductById` but eagerly hydrates the `productType`
81
+ * relation so consumers (slot detail page, etc.) can render a
82
+ * category-style badge without a second round-trip. `productType` is
83
+ * `null` when the product has no type assigned.
84
+ */
85
+ getProductByIdWithType(db: PostgresJsDatabase, id: string): Promise<{
86
+ productType: {
87
+ id: string;
88
+ name: string;
89
+ code: string;
90
+ } | null;
91
+ id: string;
92
+ name: string;
93
+ status: "draft" | "active" | "archived";
94
+ description: string | null;
95
+ inclusionsHtml: string | null;
96
+ exclusionsHtml: string | null;
97
+ termsHtml: string | null;
98
+ termsShowOnContract: boolean;
99
+ bookingMode: "date" | "date_time" | "open" | "stay" | "transfer" | "itinerary" | "other";
100
+ capacityMode: "free_sale" | "limited" | "on_request";
101
+ timezone: string | null;
102
+ defaultLanguageTag: string | null;
103
+ visibility: "public" | "private" | "hidden";
104
+ activated: boolean;
105
+ reservationTimeoutMinutes: number | null;
106
+ sellCurrency: string;
107
+ sellAmountCents: number | null;
108
+ costAmountCents: number | null;
109
+ marginPercent: number | null;
110
+ facilityId: string | null;
111
+ supplierId: string | null;
112
+ startDate: string | null;
113
+ endDate: string | null;
114
+ pax: number | null;
115
+ productTypeId: string | null;
116
+ contractTemplateId: string | null;
117
+ taxClassId: string | null;
118
+ customerPaymentPolicy: unknown;
119
+ tags: string[] | null;
120
+ createdAt: Date;
121
+ updatedAt: Date;
122
+ } | null>;
123
+ createProduct(db: PostgresJsDatabase, data: CreateProductInput): Promise<{
124
+ id: string;
125
+ name: string;
126
+ status: "draft" | "active" | "archived";
127
+ description: string | null;
128
+ inclusionsHtml: string | null;
129
+ exclusionsHtml: string | null;
130
+ termsHtml: string | null;
131
+ termsShowOnContract: boolean;
132
+ bookingMode: "date" | "date_time" | "open" | "stay" | "transfer" | "itinerary" | "other";
133
+ capacityMode: "free_sale" | "limited" | "on_request";
134
+ timezone: string | null;
135
+ defaultLanguageTag: string | null;
136
+ visibility: "public" | "private" | "hidden";
137
+ activated: boolean;
138
+ reservationTimeoutMinutes: number | null;
139
+ sellCurrency: string;
140
+ sellAmountCents: number | null;
141
+ costAmountCents: number | null;
142
+ marginPercent: number | null;
143
+ facilityId: string | null;
144
+ supplierId: string | null;
145
+ startDate: string | null;
146
+ endDate: string | null;
147
+ pax: number | null;
148
+ productTypeId: string | null;
149
+ contractTemplateId: string | null;
150
+ taxClassId: string | null;
151
+ customerPaymentPolicy: unknown;
152
+ tags: string[] | null;
153
+ createdAt: Date;
154
+ updatedAt: Date;
155
+ }>;
156
+ updateProduct(db: PostgresJsDatabase, id: string, data: UpdateProductInput): Promise<{
157
+ id: string;
158
+ name: string;
159
+ status: "draft" | "active" | "archived";
160
+ description: string | null;
161
+ inclusionsHtml: string | null;
162
+ exclusionsHtml: string | null;
163
+ termsHtml: string | null;
164
+ termsShowOnContract: boolean;
165
+ bookingMode: "date" | "date_time" | "open" | "stay" | "transfer" | "itinerary" | "other";
166
+ capacityMode: "free_sale" | "limited" | "on_request";
167
+ timezone: string | null;
168
+ defaultLanguageTag: string | null;
169
+ visibility: "public" | "private" | "hidden";
170
+ activated: boolean;
171
+ reservationTimeoutMinutes: number | null;
172
+ sellCurrency: string;
173
+ sellAmountCents: number | null;
174
+ costAmountCents: number | null;
175
+ marginPercent: number | null;
176
+ facilityId: string | null;
177
+ supplierId: string | null;
178
+ startDate: string | null;
179
+ endDate: string | null;
180
+ pax: number | null;
181
+ productTypeId: string | null;
182
+ contractTemplateId: string | null;
183
+ taxClassId: string | null;
184
+ customerPaymentPolicy: unknown;
185
+ tags: string[] | null;
186
+ createdAt: Date;
187
+ updatedAt: Date;
188
+ } | null>;
189
+ deleteProduct(db: PostgresJsDatabase, id: string): Promise<{
190
+ id: string;
191
+ } | null>;
192
+ };
193
+ export {};
194
+ //# sourceMappingURL=service-core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-core.d.ts","sourceRoot":"","sources":["../src/service-core.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAQ5B,OAAO,KAAK,EACV,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,iBAAiB,CAAA;AAExB,KAAK,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAC9D,KAAK,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAC7D,KAAK,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAwE7D,eAAO,MAAM,mBAAmB;qBACP,kBAAkB,SAAS,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAyHzC,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAKvD;;;;;OAKG;+BAC8B,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAqBvC,kBAAkB,QAAQ,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAU5C,kBAAkB,MAAM,MAAM,QAAQ,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAUxD,kBAAkB,MAAM,MAAM;;;CAQvD,CAAA"}
@@ -0,0 +1,213 @@
1
+ import { and, asc, desc, eq, gte, ilike, lte, or, sql } from "drizzle-orm";
2
+ import { productCategoryProducts, productItineraries, productOptions, products, productTypes, } from "./schema.js";
3
+ async function getDefaultItinerary(db, productId) {
4
+ const [itinerary] = await db
5
+ .select({ id: productItineraries.id })
6
+ .from(productItineraries)
7
+ .where(and(eq(productItineraries.productId, productId), eq(productItineraries.isDefault, true)))
8
+ .orderBy(asc(productItineraries.sortOrder), asc(productItineraries.createdAt))
9
+ .limit(1);
10
+ return itinerary ?? null;
11
+ }
12
+ async function ensureDefaultItinerary(db, productId) {
13
+ const existing = await getDefaultItinerary(db, productId);
14
+ if (existing) {
15
+ return existing;
16
+ }
17
+ const [row] = await db
18
+ .insert(productItineraries)
19
+ .values({
20
+ productId,
21
+ name: "Main itinerary",
22
+ isDefault: true,
23
+ sortOrder: 0,
24
+ })
25
+ .returning({ id: productItineraries.id });
26
+ if (!row) {
27
+ throw new Error(`Failed to create default itinerary for product ${productId}`);
28
+ }
29
+ return row;
30
+ }
31
+ // Every product needs at least one bookable option for the operator pricing
32
+ // grid to have something to attach inventory and prices to. Seed a single
33
+ // "Standard" default option on creation so a brand-new product opens straight
34
+ async function ensureDefaultOption(db, productId) {
35
+ const [existing] = await db
36
+ .select({ id: productOptions.id })
37
+ .from(productOptions)
38
+ .where(eq(productOptions.productId, productId))
39
+ .limit(1);
40
+ if (existing) {
41
+ return existing;
42
+ }
43
+ const [row] = await db
44
+ .insert(productOptions)
45
+ .values({
46
+ productId,
47
+ name: "Standard",
48
+ code: "standard",
49
+ status: "active",
50
+ isDefault: true,
51
+ sortOrder: 0,
52
+ })
53
+ .returning({ id: productOptions.id });
54
+ if (!row) {
55
+ throw new Error(`Failed to create default option for product ${productId}`);
56
+ }
57
+ return row;
58
+ }
59
+ export const coreProductsService = {
60
+ async listProducts(db, query) {
61
+ const conditions = [];
62
+ if (query.status) {
63
+ conditions.push(eq(products.status, query.status));
64
+ }
65
+ if (query.bookingMode) {
66
+ conditions.push(eq(products.bookingMode, query.bookingMode));
67
+ }
68
+ if (query.visibility) {
69
+ conditions.push(eq(products.visibility, query.visibility));
70
+ }
71
+ if (query.activated !== undefined) {
72
+ conditions.push(eq(products.activated, query.activated));
73
+ }
74
+ if (query.facilityId) {
75
+ conditions.push(eq(products.facilityId, query.facilityId));
76
+ }
77
+ if (query.supplierId) {
78
+ conditions.push(eq(products.supplierId, query.supplierId));
79
+ }
80
+ if (query.productTypeId) {
81
+ conditions.push(eq(products.productTypeId, query.productTypeId));
82
+ }
83
+ if (query.contractTemplateId) {
84
+ conditions.push(eq(products.contractTemplateId, query.contractTemplateId));
85
+ }
86
+ if (query.categoryId) {
87
+ conditions.push(
88
+ // agent-quality: raw-sql reviewed -- owner: inventory; dynamic SQL interpolation uses Drizzle parameter binding or vetted SQL identifiers.
89
+ sql `exists (select 1 from ${productCategoryProducts}
90
+ where ${productCategoryProducts.productId} = ${products.id}
91
+ and ${productCategoryProducts.categoryId} = ${query.categoryId})`);
92
+ }
93
+ if (query.tag) {
94
+ // Postgres jsonb `@>` containment: does the array include this string?
95
+ // Mirrors the pattern used in @voyant-travel/charters and @voyant-travel/cruises.
96
+ // agent-quality: raw-sql reviewed -- owner: inventory; dynamic SQL interpolation uses Drizzle parameter binding or vetted SQL identifiers.
97
+ conditions.push(sql `${products.tags} @> ${JSON.stringify([query.tag])}::jsonb`);
98
+ }
99
+ if (query.search) {
100
+ const term = `%${query.search}%`;
101
+ conditions.push(or(ilike(products.name, term), ilike(products.description, term)));
102
+ }
103
+ if (query.dateFrom) {
104
+ conditions.push(gte(products.startDate, query.dateFrom));
105
+ }
106
+ if (query.dateTo) {
107
+ conditions.push(lte(products.startDate, query.dateTo));
108
+ }
109
+ if (query.paxMin !== undefined) {
110
+ conditions.push(gte(products.pax, query.paxMin));
111
+ }
112
+ if (query.paxMax !== undefined) {
113
+ conditions.push(lte(products.pax, query.paxMax));
114
+ }
115
+ if (query.sellAmountMin !== undefined) {
116
+ conditions.push(gte(products.sellAmountCents, query.sellAmountMin));
117
+ }
118
+ if (query.sellAmountMax !== undefined) {
119
+ conditions.push(lte(products.sellAmountCents, query.sellAmountMax));
120
+ }
121
+ const where = conditions.length > 0 ? and(...conditions) : undefined;
122
+ const sortColumn = (() => {
123
+ switch (query.sortBy) {
124
+ case "name":
125
+ return products.name;
126
+ case "status":
127
+ return products.status;
128
+ case "sellAmount":
129
+ return products.sellAmountCents;
130
+ case "pax":
131
+ return products.pax;
132
+ case "startDate":
133
+ return products.startDate;
134
+ case "endDate":
135
+ return products.endDate;
136
+ default:
137
+ return products.createdAt;
138
+ }
139
+ })();
140
+ const sortFn = query.sortDir === "asc" ? asc : desc;
141
+ const [rows, countResult] = await Promise.all([
142
+ db
143
+ .select()
144
+ .from(products)
145
+ .where(where)
146
+ .limit(query.limit)
147
+ .offset(query.offset)
148
+ .orderBy(sortFn(sortColumn), desc(products.createdAt)),
149
+ db.select({ count: sql `count(*)::int` }).from(products).where(where),
150
+ ]);
151
+ return {
152
+ data: rows,
153
+ total: countResult[0]?.count ?? 0,
154
+ limit: query.limit,
155
+ offset: query.offset,
156
+ };
157
+ },
158
+ async getProductById(db, id) {
159
+ const [row] = await db.select().from(products).where(eq(products.id, id)).limit(1);
160
+ return row ?? null;
161
+ },
162
+ /**
163
+ * Same as `getProductById` but eagerly hydrates the `productType`
164
+ * relation so consumers (slot detail page, etc.) can render a
165
+ * category-style badge without a second round-trip. `productType` is
166
+ * `null` when the product has no type assigned.
167
+ */
168
+ async getProductByIdWithType(db, id) {
169
+ const [row] = await db
170
+ .select({
171
+ product: products,
172
+ productType: {
173
+ id: productTypes.id,
174
+ name: productTypes.name,
175
+ code: productTypes.code,
176
+ },
177
+ })
178
+ .from(products)
179
+ .leftJoin(productTypes, eq(productTypes.id, products.productTypeId))
180
+ .where(eq(products.id, id))
181
+ .limit(1);
182
+ if (!row)
183
+ return null;
184
+ return {
185
+ ...row.product,
186
+ productType: row.productType?.id ? row.productType : null,
187
+ };
188
+ },
189
+ async createProduct(db, data) {
190
+ const [row] = await db.insert(products).values(data).returning();
191
+ if (!row) {
192
+ throw new Error("Failed to create product");
193
+ }
194
+ await ensureDefaultItinerary(db, row.id);
195
+ await ensureDefaultOption(db, row.id);
196
+ return row;
197
+ },
198
+ async updateProduct(db, id, data) {
199
+ const [row] = await db
200
+ .update(products)
201
+ .set({ ...data, updatedAt: new Date() })
202
+ .where(eq(products.id, id))
203
+ .returning();
204
+ return row ?? null;
205
+ },
206
+ async deleteProduct(db, id) {
207
+ const [row] = await db
208
+ .delete(products)
209
+ .where(eq(products.id, id))
210
+ .returning({ id: products.id });
211
+ return row ?? null;
212
+ },
213
+ };
@@ -0,0 +1,58 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import type { z } from "zod";
3
+ import type { insertProductDeliveryFormatSchema, productDeliveryFormatListQuerySchema, updateProductDeliveryFormatSchema } from "./validation.js";
4
+ type ProductDeliveryFormatListQuery = z.infer<typeof productDeliveryFormatListQuerySchema>;
5
+ type CreateProductDeliveryFormatInput = z.infer<typeof insertProductDeliveryFormatSchema>;
6
+ type UpdateProductDeliveryFormatInput = z.infer<typeof updateProductDeliveryFormatSchema>;
7
+ export declare const deliveryFormatProductsService: {
8
+ listDeliveryFormats(db: PostgresJsDatabase, query: ProductDeliveryFormatListQuery): Promise<{
9
+ data: {
10
+ id: string;
11
+ productId: string;
12
+ format: "none" | "voucher" | "ticket" | "pdf" | "qr_code" | "barcode" | "email" | "mobile";
13
+ isDefault: boolean;
14
+ createdAt: Date;
15
+ updatedAt: Date;
16
+ }[];
17
+ total: number;
18
+ limit: number;
19
+ offset: number;
20
+ }>;
21
+ getDeliveryFormatById(db: PostgresJsDatabase, id: string): Promise<{
22
+ id: string;
23
+ productId: string;
24
+ format: "none" | "voucher" | "ticket" | "pdf" | "qr_code" | "barcode" | "email" | "mobile";
25
+ isDefault: boolean;
26
+ createdAt: Date;
27
+ updatedAt: Date;
28
+ } | null>;
29
+ getDeliveryFormatByProductAndFormat(db: PostgresJsDatabase, productId: string, format: CreateProductDeliveryFormatInput["format"]): Promise<{
30
+ id: string;
31
+ productId: string;
32
+ format: "none" | "voucher" | "ticket" | "pdf" | "qr_code" | "barcode" | "email" | "mobile";
33
+ isDefault: boolean;
34
+ createdAt: Date;
35
+ updatedAt: Date;
36
+ } | null>;
37
+ createDeliveryFormat(db: PostgresJsDatabase, productId: string, data: CreateProductDeliveryFormatInput): Promise<{
38
+ format: "none" | "voucher" | "ticket" | "pdf" | "qr_code" | "barcode" | "email" | "mobile";
39
+ id: string;
40
+ createdAt: Date;
41
+ updatedAt: Date;
42
+ productId: string;
43
+ isDefault: boolean;
44
+ } | null>;
45
+ updateDeliveryFormat(db: PostgresJsDatabase, id: string, data: UpdateProductDeliveryFormatInput): Promise<{
46
+ id: string;
47
+ productId: string;
48
+ format: "none" | "voucher" | "ticket" | "pdf" | "qr_code" | "barcode" | "email" | "mobile";
49
+ isDefault: boolean;
50
+ createdAt: Date;
51
+ updatedAt: Date;
52
+ } | null>;
53
+ deleteDeliveryFormat(db: PostgresJsDatabase, id: string): Promise<{
54
+ id: string;
55
+ } | null>;
56
+ };
57
+ export {};
58
+ //# sourceMappingURL=service-delivery-formats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-delivery-formats.d.ts","sourceRoot":"","sources":["../src/service-delivery-formats.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,KAAK,EACV,iCAAiC,EACjC,oCAAoC,EACpC,iCAAiC,EAClC,MAAM,iBAAiB,CAAA;AAExB,KAAK,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oCAAoC,CAAC,CAAA;AAC1F,KAAK,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AACzF,KAAK,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AAYzF,eAAO,MAAM,6BAA6B;4BACV,kBAAkB,SAAS,8BAA8B;;;;;;;;;;;;;8BAgCvD,kBAAkB,MAAM,MAAM;;;;;;;;4CAWxD,kBAAkB,aACX,MAAM,UACT,gCAAgC,CAAC,QAAQ,CAAC;;;;;;;;6BAiB9C,kBAAkB,aACX,MAAM,QACX,gCAAgC;;;;;;;;6BA8BlC,kBAAkB,MAClB,MAAM,QACJ,gCAAgC;;;;;;;;6BA4BT,kBAAkB,MAAM,MAAM;;;CAQ9D,CAAA"}
@@ -0,0 +1,107 @@
1
+ import { and, asc, desc, eq, sql } from "drizzle-orm";
2
+ import { productDeliveryFormats, products } from "./schema.js";
3
+ async function ensureProductExists(db, productId) {
4
+ const [product] = await db
5
+ .select({ id: products.id })
6
+ .from(products)
7
+ .where(eq(products.id, productId))
8
+ .limit(1);
9
+ return product ?? null;
10
+ }
11
+ export const deliveryFormatProductsService = {
12
+ async listDeliveryFormats(db, query) {
13
+ const conditions = [];
14
+ if (query.productId) {
15
+ conditions.push(eq(productDeliveryFormats.productId, query.productId));
16
+ }
17
+ if (query.format) {
18
+ conditions.push(eq(productDeliveryFormats.format, query.format));
19
+ }
20
+ const where = conditions.length > 0 ? and(...conditions) : undefined;
21
+ const [rows, countResult] = await Promise.all([
22
+ db
23
+ .select()
24
+ .from(productDeliveryFormats)
25
+ .where(where)
26
+ .limit(query.limit)
27
+ .offset(query.offset)
28
+ .orderBy(desc(productDeliveryFormats.isDefault), asc(productDeliveryFormats.createdAt)),
29
+ db.select({ count: sql `count(*)::int` }).from(productDeliveryFormats).where(where),
30
+ ]);
31
+ return {
32
+ data: rows,
33
+ total: countResult[0]?.count ?? 0,
34
+ limit: query.limit,
35
+ offset: query.offset,
36
+ };
37
+ },
38
+ async getDeliveryFormatById(db, id) {
39
+ const [row] = await db
40
+ .select()
41
+ .from(productDeliveryFormats)
42
+ .where(eq(productDeliveryFormats.id, id))
43
+ .limit(1);
44
+ return row ?? null;
45
+ },
46
+ async getDeliveryFormatByProductAndFormat(db, productId, format) {
47
+ const [row] = await db
48
+ .select()
49
+ .from(productDeliveryFormats)
50
+ .where(and(eq(productDeliveryFormats.productId, productId), eq(productDeliveryFormats.format, format)))
51
+ .limit(1);
52
+ return row ?? null;
53
+ },
54
+ async createDeliveryFormat(db, productId, data) {
55
+ const product = await ensureProductExists(db, productId);
56
+ if (!product) {
57
+ return null;
58
+ }
59
+ if (data.isDefault) {
60
+ await db
61
+ .update(productDeliveryFormats)
62
+ .set({ isDefault: false, updatedAt: new Date() })
63
+ .where(eq(productDeliveryFormats.productId, productId));
64
+ }
65
+ const [row] = await db
66
+ .insert(productDeliveryFormats)
67
+ .values({ productId, ...data })
68
+ .onConflictDoUpdate({
69
+ target: [productDeliveryFormats.productId, productDeliveryFormats.format],
70
+ set: {
71
+ isDefault: data.isDefault ?? false,
72
+ updatedAt: new Date(),
73
+ },
74
+ })
75
+ .returning();
76
+ return row ?? null;
77
+ },
78
+ async updateDeliveryFormat(db, id, data) {
79
+ const [current] = await db
80
+ .select({ id: productDeliveryFormats.id, productId: productDeliveryFormats.productId })
81
+ .from(productDeliveryFormats)
82
+ .where(eq(productDeliveryFormats.id, id))
83
+ .limit(1);
84
+ if (!current) {
85
+ return null;
86
+ }
87
+ if (data.isDefault) {
88
+ await db
89
+ .update(productDeliveryFormats)
90
+ .set({ isDefault: false, updatedAt: new Date() })
91
+ .where(eq(productDeliveryFormats.productId, current.productId));
92
+ }
93
+ const [row] = await db
94
+ .update(productDeliveryFormats)
95
+ .set({ ...data, updatedAt: new Date() })
96
+ .where(eq(productDeliveryFormats.id, id))
97
+ .returning();
98
+ return row ?? null;
99
+ },
100
+ async deleteDeliveryFormat(db, id) {
101
+ const [row] = await db
102
+ .delete(productDeliveryFormats)
103
+ .where(eq(productDeliveryFormats.id, id))
104
+ .returning({ id: productDeliveryFormats.id });
105
+ return row ?? null;
106
+ },
107
+ };