@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,181 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import type { z } from "zod";
3
+ import type { insertOptionUnitSchema, insertProductOptionSchema, optionUnitListQuerySchema, productOptionListQuerySchema, updateOptionUnitSchema, updateProductOptionSchema } from "./validation.js";
4
+ type ProductOptionListQuery = z.infer<typeof productOptionListQuerySchema>;
5
+ type CreateProductOptionInput = z.infer<typeof insertProductOptionSchema>;
6
+ type UpdateProductOptionInput = z.infer<typeof updateProductOptionSchema>;
7
+ type OptionUnitListQuery = z.infer<typeof optionUnitListQuerySchema>;
8
+ type CreateOptionUnitInput = z.infer<typeof insertOptionUnitSchema>;
9
+ type UpdateOptionUnitInput = z.infer<typeof updateOptionUnitSchema>;
10
+ export declare const optionProductsService: {
11
+ listOptions(db: PostgresJsDatabase, query: ProductOptionListQuery): Promise<{
12
+ data: {
13
+ id: string;
14
+ productId: string;
15
+ name: string;
16
+ code: string | null;
17
+ description: string | null;
18
+ status: "draft" | "active" | "archived";
19
+ isDefault: boolean;
20
+ sortOrder: number;
21
+ availableFrom: string | null;
22
+ availableTo: string | null;
23
+ createdAt: Date;
24
+ updatedAt: Date;
25
+ }[];
26
+ total: number;
27
+ limit: number;
28
+ offset: number;
29
+ }>;
30
+ getOptionById(db: PostgresJsDatabase, id: string): Promise<{
31
+ id: string;
32
+ productId: string;
33
+ name: string;
34
+ code: string | null;
35
+ description: string | null;
36
+ status: "draft" | "active" | "archived";
37
+ isDefault: boolean;
38
+ sortOrder: number;
39
+ availableFrom: string | null;
40
+ availableTo: string | null;
41
+ createdAt: Date;
42
+ updatedAt: Date;
43
+ } | null>;
44
+ createOption(db: PostgresJsDatabase, productId: string, data: CreateProductOptionInput): Promise<{
45
+ id: string;
46
+ name: string;
47
+ status: "draft" | "active" | "archived";
48
+ description: string | null;
49
+ createdAt: Date;
50
+ updatedAt: Date;
51
+ code: string | null;
52
+ productId: string;
53
+ isDefault: boolean;
54
+ sortOrder: number;
55
+ availableFrom: string | null;
56
+ availableTo: string | null;
57
+ } | null | undefined>;
58
+ updateOption(db: PostgresJsDatabase, id: string, data: UpdateProductOptionInput): Promise<{
59
+ id: string;
60
+ productId: string;
61
+ name: string;
62
+ code: string | null;
63
+ description: string | null;
64
+ status: "draft" | "active" | "archived";
65
+ isDefault: boolean;
66
+ sortOrder: number;
67
+ availableFrom: string | null;
68
+ availableTo: string | null;
69
+ createdAt: Date;
70
+ updatedAt: Date;
71
+ } | null>;
72
+ deleteOption(db: PostgresJsDatabase, id: string): Promise<{
73
+ id: string;
74
+ } | null>;
75
+ listUnits(db: PostgresJsDatabase, query: OptionUnitListQuery): Promise<{
76
+ data: {
77
+ id: string;
78
+ optionId: string;
79
+ name: string;
80
+ code: string | null;
81
+ description: string | null;
82
+ unitType: "other" | "person" | "group" | "room" | "vehicle" | "service";
83
+ minQuantity: number | null;
84
+ maxQuantity: number | null;
85
+ minAge: number | null;
86
+ maxAge: number | null;
87
+ occupancyMin: number | null;
88
+ occupancyMax: number | null;
89
+ isRequired: boolean;
90
+ isHidden: boolean;
91
+ sortOrder: number;
92
+ createdAt: Date;
93
+ updatedAt: Date;
94
+ }[];
95
+ total: number;
96
+ limit: number;
97
+ offset: number;
98
+ }>;
99
+ getUnitById(db: PostgresJsDatabase, id: string): Promise<{
100
+ id: string;
101
+ optionId: string;
102
+ name: string;
103
+ code: string | null;
104
+ description: string | null;
105
+ unitType: "other" | "person" | "group" | "room" | "vehicle" | "service";
106
+ minQuantity: number | null;
107
+ maxQuantity: number | null;
108
+ minAge: number | null;
109
+ maxAge: number | null;
110
+ occupancyMin: number | null;
111
+ occupancyMax: number | null;
112
+ isRequired: boolean;
113
+ isHidden: boolean;
114
+ sortOrder: number;
115
+ createdAt: Date;
116
+ updatedAt: Date;
117
+ } | null>;
118
+ getUnitForProductMutation(db: PostgresJsDatabase, id: string): Promise<{
119
+ productId: string;
120
+ id: string;
121
+ optionId: string;
122
+ name: string;
123
+ code: string | null;
124
+ description: string | null;
125
+ unitType: "other" | "person" | "group" | "room" | "vehicle" | "service";
126
+ minQuantity: number | null;
127
+ maxQuantity: number | null;
128
+ minAge: number | null;
129
+ maxAge: number | null;
130
+ occupancyMin: number | null;
131
+ occupancyMax: number | null;
132
+ isRequired: boolean;
133
+ isHidden: boolean;
134
+ sortOrder: number;
135
+ createdAt: Date;
136
+ updatedAt: Date;
137
+ } | null>;
138
+ createUnit(db: PostgresJsDatabase, optionId: string, data: CreateOptionUnitInput): Promise<{
139
+ id: string;
140
+ name: string;
141
+ description: string | null;
142
+ createdAt: Date;
143
+ updatedAt: Date;
144
+ code: string | null;
145
+ sortOrder: number;
146
+ optionId: string;
147
+ unitType: "other" | "person" | "group" | "room" | "vehicle" | "service";
148
+ minQuantity: number | null;
149
+ maxQuantity: number | null;
150
+ minAge: number | null;
151
+ maxAge: number | null;
152
+ occupancyMin: number | null;
153
+ occupancyMax: number | null;
154
+ isRequired: boolean;
155
+ isHidden: boolean;
156
+ } | null | undefined>;
157
+ updateUnit(db: PostgresJsDatabase, id: string, data: UpdateOptionUnitInput): Promise<{
158
+ id: string;
159
+ optionId: string;
160
+ name: string;
161
+ code: string | null;
162
+ description: string | null;
163
+ unitType: "other" | "person" | "group" | "room" | "vehicle" | "service";
164
+ minQuantity: number | null;
165
+ maxQuantity: number | null;
166
+ minAge: number | null;
167
+ maxAge: number | null;
168
+ occupancyMin: number | null;
169
+ occupancyMax: number | null;
170
+ isRequired: boolean;
171
+ isHidden: boolean;
172
+ sortOrder: number;
173
+ createdAt: Date;
174
+ updatedAt: Date;
175
+ } | null>;
176
+ deleteUnit(db: PostgresJsDatabase, id: string): Promise<{
177
+ id: string;
178
+ } | null>;
179
+ };
180
+ export {};
181
+ //# sourceMappingURL=service-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-options.d.ts","sourceRoot":"","sources":["../src/service-options.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,KAAK,EACV,sBAAsB,EACtB,yBAAyB,EACzB,yBAAyB,EACzB,4BAA4B,EAC5B,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,iBAAiB,CAAA;AAGxB,KAAK,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AAC1E,KAAK,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AACzE,KAAK,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AACzE,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AACpE,KAAK,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AACnE,KAAK,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAEnE,eAAO,MAAM,qBAAqB;oBACV,kBAAkB,SAAS,sBAAsB;;;;;;;;;;;;;;;;;;;sBAgC/C,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;qBAK/B,kBAAkB,aAAa,MAAM,QAAQ,wBAAwB;;;;;;;;;;;;;;qBA0BrE,kBAAkB,MAAM,MAAM,QAAQ,wBAAwB;;;;;;;;;;;;;;qBA2B9D,kBAAkB,MAAM,MAAM;;;kBASjC,kBAAkB,SAAS,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;oBAgC5C,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;;;;;;kCAKhB,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;mBAW7C,kBAAkB,YAAY,MAAM,QAAQ,qBAAqB;;;;;;;;;;;;;;;;;;;mBAmBjE,kBAAkB,MAAM,MAAM,QAAQ,qBAAqB;;;;;;;;;;;;;;;;;;;mBAsC3D,kBAAkB,MAAM,MAAM;;;CAQpD,CAAA"}
@@ -0,0 +1,179 @@
1
+ import { RequestValidationError } from "@voyant-travel/hono";
2
+ import { and, asc, eq, sql } from "drizzle-orm";
3
+ import { optionUnits, productOptions, products } from "./schema.js";
4
+ import { validateMergedOptionUnit } from "./validation-core.js";
5
+ export const optionProductsService = {
6
+ async listOptions(db, query) {
7
+ const conditions = [];
8
+ if (query.productId) {
9
+ conditions.push(eq(productOptions.productId, query.productId));
10
+ }
11
+ if (query.status) {
12
+ conditions.push(eq(productOptions.status, query.status));
13
+ }
14
+ const where = conditions.length > 0 ? and(...conditions) : undefined;
15
+ const [rows, countResult] = await Promise.all([
16
+ db
17
+ .select()
18
+ .from(productOptions)
19
+ .where(where)
20
+ .limit(query.limit)
21
+ .offset(query.offset)
22
+ .orderBy(asc(productOptions.sortOrder), asc(productOptions.createdAt)),
23
+ db.select({ count: sql `count(*)::int` }).from(productOptions).where(where),
24
+ ]);
25
+ return {
26
+ data: rows,
27
+ total: countResult[0]?.count ?? 0,
28
+ limit: query.limit,
29
+ offset: query.offset,
30
+ };
31
+ },
32
+ async getOptionById(db, id) {
33
+ const [row] = await db.select().from(productOptions).where(eq(productOptions.id, id)).limit(1);
34
+ return row ?? null;
35
+ },
36
+ async createOption(db, productId, data) {
37
+ const [product] = await db
38
+ .select({ id: products.id })
39
+ .from(products)
40
+ .where(eq(products.id, productId))
41
+ .limit(1);
42
+ if (!product) {
43
+ return null;
44
+ }
45
+ if (data.isDefault) {
46
+ await db
47
+ .update(productOptions)
48
+ .set({ isDefault: false, updatedAt: new Date() })
49
+ .where(eq(productOptions.productId, productId));
50
+ }
51
+ const [row] = await db
52
+ .insert(productOptions)
53
+ .values({ ...data, productId })
54
+ .returning();
55
+ return row;
56
+ },
57
+ async updateOption(db, id, data) {
58
+ const [current] = await db
59
+ .select({ id: productOptions.id, productId: productOptions.productId })
60
+ .from(productOptions)
61
+ .where(eq(productOptions.id, id))
62
+ .limit(1);
63
+ if (!current) {
64
+ return null;
65
+ }
66
+ if (data.isDefault) {
67
+ await db
68
+ .update(productOptions)
69
+ .set({ isDefault: false, updatedAt: new Date() })
70
+ .where(eq(productOptions.productId, current.productId));
71
+ }
72
+ const [row] = await db
73
+ .update(productOptions)
74
+ .set({ ...data, updatedAt: new Date() })
75
+ .where(eq(productOptions.id, id))
76
+ .returning();
77
+ return row ?? null;
78
+ },
79
+ async deleteOption(db, id) {
80
+ const [row] = await db
81
+ .delete(productOptions)
82
+ .where(eq(productOptions.id, id))
83
+ .returning({ id: productOptions.id });
84
+ return row ?? null;
85
+ },
86
+ async listUnits(db, query) {
87
+ const conditions = [];
88
+ if (query.optionId) {
89
+ conditions.push(eq(optionUnits.optionId, query.optionId));
90
+ }
91
+ if (query.unitType) {
92
+ conditions.push(eq(optionUnits.unitType, query.unitType));
93
+ }
94
+ const where = conditions.length > 0 ? and(...conditions) : undefined;
95
+ const [rows, countResult] = await Promise.all([
96
+ db
97
+ .select()
98
+ .from(optionUnits)
99
+ .where(where)
100
+ .limit(query.limit)
101
+ .offset(query.offset)
102
+ .orderBy(asc(optionUnits.sortOrder), asc(optionUnits.createdAt)),
103
+ db.select({ count: sql `count(*)::int` }).from(optionUnits).where(where),
104
+ ]);
105
+ return {
106
+ data: rows,
107
+ total: countResult[0]?.count ?? 0,
108
+ limit: query.limit,
109
+ offset: query.offset,
110
+ };
111
+ },
112
+ async getUnitById(db, id) {
113
+ const [row] = await db.select().from(optionUnits).where(eq(optionUnits.id, id)).limit(1);
114
+ return row ?? null;
115
+ },
116
+ async getUnitForProductMutation(db, id) {
117
+ const [row] = await db
118
+ .select({ unit: optionUnits, productId: productOptions.productId })
119
+ .from(optionUnits)
120
+ .innerJoin(productOptions, eq(optionUnits.optionId, productOptions.id))
121
+ .where(eq(optionUnits.id, id))
122
+ .limit(1);
123
+ return row ? { ...row.unit, productId: row.productId } : null;
124
+ },
125
+ async createUnit(db, optionId, data) {
126
+ const [option] = await db
127
+ .select({ id: productOptions.id })
128
+ .from(productOptions)
129
+ .where(eq(productOptions.id, optionId))
130
+ .limit(1);
131
+ if (!option) {
132
+ return null;
133
+ }
134
+ const [row] = await db
135
+ .insert(optionUnits)
136
+ .values({ ...data, optionId })
137
+ .returning();
138
+ return row;
139
+ },
140
+ async updateUnit(db, id, data) {
141
+ const [existing] = await db
142
+ .select({
143
+ unitType: optionUnits.unitType,
144
+ occupancyMin: optionUnits.occupancyMin,
145
+ occupancyMax: optionUnits.occupancyMax,
146
+ })
147
+ .from(optionUnits)
148
+ .where(eq(optionUnits.id, id))
149
+ .limit(1);
150
+ if (!existing) {
151
+ return null;
152
+ }
153
+ const merged = {
154
+ unitType: "unitType" in data ? data.unitType : existing.unitType,
155
+ occupancyMin: "occupancyMin" in data ? data.occupancyMin : existing.occupancyMin,
156
+ occupancyMax: "occupancyMax" in data ? data.occupancyMax : existing.occupancyMax,
157
+ };
158
+ const validation = validateMergedOptionUnit(merged);
159
+ if (!validation.ok) {
160
+ const first = validation.issues[0];
161
+ throw new RequestValidationError(first?.message ?? "Invalid option unit", {
162
+ issues: validation.issues,
163
+ });
164
+ }
165
+ const [row] = await db
166
+ .update(optionUnits)
167
+ .set({ ...data, updatedAt: new Date() })
168
+ .where(eq(optionUnits.id, id))
169
+ .returning();
170
+ return row ?? null;
171
+ },
172
+ async deleteUnit(db, id) {
173
+ const [row] = await db
174
+ .delete(optionUnits)
175
+ .where(eq(optionUnits.id, id))
176
+ .returning({ id: optionUnits.id });
177
+ return row ?? null;
178
+ },
179
+ };
@@ -0,0 +1,37 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import type { z } from "zod";
3
+ import type { productDestinationListQuerySchema } from "./validation.js";
4
+ type ProductDestinationListQuery = z.infer<typeof productDestinationListQuerySchema>;
5
+ export declare const productDestinationProductsService: {
6
+ listProductDestinations(db: PostgresJsDatabase, query: ProductDestinationListQuery): Promise<{
7
+ data: {
8
+ productId: string;
9
+ destinationId: string;
10
+ sortOrder: number;
11
+ createdAt: Date;
12
+ updatedAt: Date;
13
+ destinationSlug: string;
14
+ destinationType: string;
15
+ destinationActive: boolean;
16
+ }[];
17
+ total: number;
18
+ limit: number;
19
+ offset: number;
20
+ }>;
21
+ assignProductDestination(db: PostgresJsDatabase, productId: string, input: {
22
+ destinationId: string;
23
+ sortOrder?: number;
24
+ }): Promise<{
25
+ createdAt: Date;
26
+ updatedAt: Date;
27
+ productId: string;
28
+ sortOrder: number;
29
+ destinationId: string;
30
+ } | null>;
31
+ removeProductDestination(db: PostgresJsDatabase, productId: string, destinationId: string): Promise<{
32
+ productId: string;
33
+ destinationId: string;
34
+ } | null>;
35
+ };
36
+ export {};
37
+ //# sourceMappingURL=service-product-destinations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-product-destinations.d.ts","sourceRoot":"","sources":["../src/service-product-destinations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAA;AAExE,KAAK,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AAYpF,eAAO,MAAM,iCAAiC;gCACV,kBAAkB,SAAS,2BAA2B;;;;;;;;;;;;;;;iCA2ClF,kBAAkB,aACX,MAAM,SACV;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;iCAqDnB,kBAAkB,aAAa,MAAM,iBAAiB,MAAM;;;;CAgBhG,CAAA"}
@@ -0,0 +1,94 @@
1
+ import { and, asc, eq, sql } from "drizzle-orm";
2
+ import { destinations, productDestinations, 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 productDestinationProductsService = {
12
+ async listProductDestinations(db, query) {
13
+ const conditions = [];
14
+ if (query.productId) {
15
+ conditions.push(eq(productDestinations.productId, query.productId));
16
+ }
17
+ if (query.destinationId) {
18
+ conditions.push(eq(productDestinations.destinationId, query.destinationId));
19
+ }
20
+ const where = conditions.length > 0 ? and(...conditions) : undefined;
21
+ const [rows, countResult] = await Promise.all([
22
+ db
23
+ .select({
24
+ productId: productDestinations.productId,
25
+ destinationId: productDestinations.destinationId,
26
+ sortOrder: productDestinations.sortOrder,
27
+ createdAt: productDestinations.createdAt,
28
+ updatedAt: productDestinations.updatedAt,
29
+ destinationSlug: destinations.slug,
30
+ destinationType: destinations.destinationType,
31
+ destinationActive: destinations.active,
32
+ })
33
+ .from(productDestinations)
34
+ .innerJoin(destinations, eq(destinations.id, productDestinations.destinationId))
35
+ .where(where)
36
+ .limit(query.limit)
37
+ .offset(query.offset)
38
+ .orderBy(asc(productDestinations.sortOrder), asc(destinations.slug)),
39
+ db.select({ count: sql `count(*)::int` }).from(productDestinations).where(where),
40
+ ]);
41
+ return {
42
+ data: rows,
43
+ total: countResult[0]?.count ?? 0,
44
+ limit: query.limit,
45
+ offset: query.offset,
46
+ };
47
+ },
48
+ async assignProductDestination(db, productId, input) {
49
+ const product = await ensureProductExists(db, productId);
50
+ if (!product) {
51
+ return null;
52
+ }
53
+ const [destination] = await db
54
+ .select({ id: destinations.id })
55
+ .from(destinations)
56
+ .where(eq(destinations.id, input.destinationId))
57
+ .limit(1);
58
+ if (!destination) {
59
+ return null;
60
+ }
61
+ const [existing] = await db
62
+ .select()
63
+ .from(productDestinations)
64
+ .where(and(eq(productDestinations.productId, productId), eq(productDestinations.destinationId, input.destinationId)))
65
+ .limit(1);
66
+ if (existing) {
67
+ const [row] = await db
68
+ .update(productDestinations)
69
+ .set({ sortOrder: input.sortOrder ?? existing.sortOrder, updatedAt: new Date() })
70
+ .where(and(eq(productDestinations.productId, productId), eq(productDestinations.destinationId, input.destinationId)))
71
+ .returning();
72
+ return row ?? null;
73
+ }
74
+ const [row] = await db
75
+ .insert(productDestinations)
76
+ .values({
77
+ productId,
78
+ destinationId: input.destinationId,
79
+ sortOrder: input.sortOrder ?? 0,
80
+ })
81
+ .returning();
82
+ return row ?? null;
83
+ },
84
+ async removeProductDestination(db, productId, destinationId) {
85
+ const [row] = await db
86
+ .delete(productDestinations)
87
+ .where(and(eq(productDestinations.productId, productId), eq(productDestinations.destinationId, destinationId)))
88
+ .returning({
89
+ productId: productDestinations.productId,
90
+ destinationId: productDestinations.destinationId,
91
+ });
92
+ return row ?? null;
93
+ },
94
+ };