@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,457 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import type { z } from "zod";
3
+ import type { insertProductNoteSchema, insertVersionSchema } from "./validation.js";
4
+ type CreateVersionInput = z.infer<typeof insertVersionSchema>;
5
+ type CreateProductNoteInput = z.infer<typeof insertProductNoteSchema>;
6
+ export declare const itineraryHistoryProductsService: {
7
+ listVersions(db: PostgresJsDatabase, productId: string): Omit<import("drizzle-orm/pg-core").PgSelectBase<"product_versions", {
8
+ id: import("drizzle-orm/pg-core").PgColumn<{
9
+ name: string;
10
+ tableName: "product_versions";
11
+ dataType: "string";
12
+ columnType: "PgText";
13
+ data: string;
14
+ driverParam: string;
15
+ notNull: true;
16
+ hasDefault: true;
17
+ isPrimaryKey: true;
18
+ isAutoincrement: false;
19
+ hasRuntimeDefault: true;
20
+ enumValues: [string, ...string[]];
21
+ baseColumn: never;
22
+ identity: undefined;
23
+ generated: undefined;
24
+ }, {}, {}>;
25
+ productId: import("drizzle-orm/pg-core").PgColumn<{
26
+ name: string;
27
+ tableName: "product_versions";
28
+ dataType: "string";
29
+ columnType: "PgText";
30
+ data: string;
31
+ driverParam: string;
32
+ notNull: true;
33
+ hasDefault: false;
34
+ isPrimaryKey: false;
35
+ isAutoincrement: false;
36
+ hasRuntimeDefault: false;
37
+ enumValues: [string, ...string[]];
38
+ baseColumn: never;
39
+ identity: undefined;
40
+ generated: undefined;
41
+ }, {}, {}>;
42
+ versionNumber: import("drizzle-orm/pg-core").PgColumn<{
43
+ name: "version_number";
44
+ tableName: "product_versions";
45
+ dataType: "number";
46
+ columnType: "PgInteger";
47
+ data: number;
48
+ driverParam: string | number;
49
+ notNull: true;
50
+ hasDefault: false;
51
+ isPrimaryKey: false;
52
+ isAutoincrement: false;
53
+ hasRuntimeDefault: false;
54
+ enumValues: undefined;
55
+ baseColumn: never;
56
+ identity: undefined;
57
+ generated: undefined;
58
+ }, {}, {}>;
59
+ snapshot: import("drizzle-orm/pg-core").PgColumn<{
60
+ name: "snapshot";
61
+ tableName: "product_versions";
62
+ dataType: "json";
63
+ columnType: "PgJsonb";
64
+ data: unknown;
65
+ driverParam: unknown;
66
+ notNull: true;
67
+ hasDefault: false;
68
+ isPrimaryKey: false;
69
+ isAutoincrement: false;
70
+ hasRuntimeDefault: false;
71
+ enumValues: undefined;
72
+ baseColumn: never;
73
+ identity: undefined;
74
+ generated: undefined;
75
+ }, {}, {}>;
76
+ authorId: import("drizzle-orm/pg-core").PgColumn<{
77
+ name: "author_id";
78
+ tableName: "product_versions";
79
+ dataType: "string";
80
+ columnType: "PgText";
81
+ data: string;
82
+ driverParam: string;
83
+ notNull: true;
84
+ hasDefault: false;
85
+ isPrimaryKey: false;
86
+ isAutoincrement: false;
87
+ hasRuntimeDefault: false;
88
+ enumValues: [string, ...string[]];
89
+ baseColumn: never;
90
+ identity: undefined;
91
+ generated: undefined;
92
+ }, {}, {}>;
93
+ notes: import("drizzle-orm/pg-core").PgColumn<{
94
+ name: "notes";
95
+ tableName: "product_versions";
96
+ dataType: "string";
97
+ columnType: "PgText";
98
+ data: string;
99
+ driverParam: string;
100
+ notNull: false;
101
+ hasDefault: false;
102
+ isPrimaryKey: false;
103
+ isAutoincrement: false;
104
+ hasRuntimeDefault: false;
105
+ enumValues: [string, ...string[]];
106
+ baseColumn: never;
107
+ identity: undefined;
108
+ generated: undefined;
109
+ }, {}, {}>;
110
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
111
+ name: "created_at";
112
+ tableName: "product_versions";
113
+ dataType: "date";
114
+ columnType: "PgTimestamp";
115
+ data: Date;
116
+ driverParam: string;
117
+ notNull: true;
118
+ hasDefault: true;
119
+ isPrimaryKey: false;
120
+ isAutoincrement: false;
121
+ hasRuntimeDefault: false;
122
+ enumValues: undefined;
123
+ baseColumn: never;
124
+ identity: undefined;
125
+ generated: undefined;
126
+ }, {}, {}>;
127
+ }, "single", Record<"product_versions", "not-null">, false, "where" | "orderBy", {
128
+ id: string;
129
+ productId: string;
130
+ versionNumber: number;
131
+ snapshot: unknown;
132
+ authorId: string;
133
+ notes: string | null;
134
+ createdAt: Date;
135
+ }[], {
136
+ id: import("drizzle-orm/pg-core").PgColumn<{
137
+ name: string;
138
+ tableName: "product_versions";
139
+ dataType: "string";
140
+ columnType: "PgText";
141
+ data: string;
142
+ driverParam: string;
143
+ notNull: true;
144
+ hasDefault: true;
145
+ isPrimaryKey: true;
146
+ isAutoincrement: false;
147
+ hasRuntimeDefault: true;
148
+ enumValues: [string, ...string[]];
149
+ baseColumn: never;
150
+ identity: undefined;
151
+ generated: undefined;
152
+ }, {}, {}>;
153
+ productId: import("drizzle-orm/pg-core").PgColumn<{
154
+ name: string;
155
+ tableName: "product_versions";
156
+ dataType: "string";
157
+ columnType: "PgText";
158
+ data: string;
159
+ driverParam: string;
160
+ notNull: true;
161
+ hasDefault: false;
162
+ isPrimaryKey: false;
163
+ isAutoincrement: false;
164
+ hasRuntimeDefault: false;
165
+ enumValues: [string, ...string[]];
166
+ baseColumn: never;
167
+ identity: undefined;
168
+ generated: undefined;
169
+ }, {}, {}>;
170
+ versionNumber: import("drizzle-orm/pg-core").PgColumn<{
171
+ name: "version_number";
172
+ tableName: "product_versions";
173
+ dataType: "number";
174
+ columnType: "PgInteger";
175
+ data: number;
176
+ driverParam: string | number;
177
+ notNull: true;
178
+ hasDefault: false;
179
+ isPrimaryKey: false;
180
+ isAutoincrement: false;
181
+ hasRuntimeDefault: false;
182
+ enumValues: undefined;
183
+ baseColumn: never;
184
+ identity: undefined;
185
+ generated: undefined;
186
+ }, {}, {}>;
187
+ snapshot: import("drizzle-orm/pg-core").PgColumn<{
188
+ name: "snapshot";
189
+ tableName: "product_versions";
190
+ dataType: "json";
191
+ columnType: "PgJsonb";
192
+ data: unknown;
193
+ driverParam: unknown;
194
+ notNull: true;
195
+ hasDefault: false;
196
+ isPrimaryKey: false;
197
+ isAutoincrement: false;
198
+ hasRuntimeDefault: false;
199
+ enumValues: undefined;
200
+ baseColumn: never;
201
+ identity: undefined;
202
+ generated: undefined;
203
+ }, {}, {}>;
204
+ authorId: import("drizzle-orm/pg-core").PgColumn<{
205
+ name: "author_id";
206
+ tableName: "product_versions";
207
+ dataType: "string";
208
+ columnType: "PgText";
209
+ data: string;
210
+ driverParam: string;
211
+ notNull: true;
212
+ hasDefault: false;
213
+ isPrimaryKey: false;
214
+ isAutoincrement: false;
215
+ hasRuntimeDefault: false;
216
+ enumValues: [string, ...string[]];
217
+ baseColumn: never;
218
+ identity: undefined;
219
+ generated: undefined;
220
+ }, {}, {}>;
221
+ notes: import("drizzle-orm/pg-core").PgColumn<{
222
+ name: "notes";
223
+ tableName: "product_versions";
224
+ dataType: "string";
225
+ columnType: "PgText";
226
+ data: string;
227
+ driverParam: string;
228
+ notNull: false;
229
+ hasDefault: false;
230
+ isPrimaryKey: false;
231
+ isAutoincrement: false;
232
+ hasRuntimeDefault: false;
233
+ enumValues: [string, ...string[]];
234
+ baseColumn: never;
235
+ identity: undefined;
236
+ generated: undefined;
237
+ }, {}, {}>;
238
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
239
+ name: "created_at";
240
+ tableName: "product_versions";
241
+ dataType: "date";
242
+ columnType: "PgTimestamp";
243
+ data: Date;
244
+ driverParam: string;
245
+ notNull: true;
246
+ hasDefault: true;
247
+ isPrimaryKey: false;
248
+ isAutoincrement: false;
249
+ hasRuntimeDefault: false;
250
+ enumValues: undefined;
251
+ baseColumn: never;
252
+ identity: undefined;
253
+ generated: undefined;
254
+ }, {}, {}>;
255
+ }>, "where" | "orderBy">;
256
+ createVersion(db: PostgresJsDatabase, productId: string, userId: string, data: CreateVersionInput): Promise<{
257
+ id: string;
258
+ createdAt: Date;
259
+ productId: string;
260
+ notes: string | null;
261
+ versionNumber: number;
262
+ snapshot: unknown;
263
+ authorId: string;
264
+ } | null | undefined>;
265
+ listNotes(db: PostgresJsDatabase, productId: string): Omit<import("drizzle-orm/pg-core").PgSelectBase<"product_notes", {
266
+ id: import("drizzle-orm/pg-core").PgColumn<{
267
+ name: string;
268
+ tableName: "product_notes";
269
+ dataType: "string";
270
+ columnType: "PgText";
271
+ data: string;
272
+ driverParam: string;
273
+ notNull: true;
274
+ hasDefault: true;
275
+ isPrimaryKey: true;
276
+ isAutoincrement: false;
277
+ hasRuntimeDefault: true;
278
+ enumValues: [string, ...string[]];
279
+ baseColumn: never;
280
+ identity: undefined;
281
+ generated: undefined;
282
+ }, {}, {}>;
283
+ productId: import("drizzle-orm/pg-core").PgColumn<{
284
+ name: string;
285
+ tableName: "product_notes";
286
+ dataType: "string";
287
+ columnType: "PgText";
288
+ data: string;
289
+ driverParam: string;
290
+ notNull: true;
291
+ hasDefault: false;
292
+ isPrimaryKey: false;
293
+ isAutoincrement: false;
294
+ hasRuntimeDefault: false;
295
+ enumValues: [string, ...string[]];
296
+ baseColumn: never;
297
+ identity: undefined;
298
+ generated: undefined;
299
+ }, {}, {}>;
300
+ authorId: import("drizzle-orm/pg-core").PgColumn<{
301
+ name: "author_id";
302
+ tableName: "product_notes";
303
+ dataType: "string";
304
+ columnType: "PgText";
305
+ data: string;
306
+ driverParam: string;
307
+ notNull: true;
308
+ hasDefault: false;
309
+ isPrimaryKey: false;
310
+ isAutoincrement: false;
311
+ hasRuntimeDefault: false;
312
+ enumValues: [string, ...string[]];
313
+ baseColumn: never;
314
+ identity: undefined;
315
+ generated: undefined;
316
+ }, {}, {}>;
317
+ content: import("drizzle-orm/pg-core").PgColumn<{
318
+ name: "content";
319
+ tableName: "product_notes";
320
+ dataType: "string";
321
+ columnType: "PgText";
322
+ data: string;
323
+ driverParam: string;
324
+ notNull: true;
325
+ hasDefault: false;
326
+ isPrimaryKey: false;
327
+ isAutoincrement: false;
328
+ hasRuntimeDefault: false;
329
+ enumValues: [string, ...string[]];
330
+ baseColumn: never;
331
+ identity: undefined;
332
+ generated: undefined;
333
+ }, {}, {}>;
334
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
335
+ name: "created_at";
336
+ tableName: "product_notes";
337
+ dataType: "date";
338
+ columnType: "PgTimestamp";
339
+ data: Date;
340
+ driverParam: string;
341
+ notNull: true;
342
+ hasDefault: true;
343
+ isPrimaryKey: false;
344
+ isAutoincrement: false;
345
+ hasRuntimeDefault: false;
346
+ enumValues: undefined;
347
+ baseColumn: never;
348
+ identity: undefined;
349
+ generated: undefined;
350
+ }, {}, {}>;
351
+ }, "single", Record<"product_notes", "not-null">, false, "where" | "orderBy", {
352
+ id: string;
353
+ productId: string;
354
+ authorId: string;
355
+ content: string;
356
+ createdAt: Date;
357
+ }[], {
358
+ id: import("drizzle-orm/pg-core").PgColumn<{
359
+ name: string;
360
+ tableName: "product_notes";
361
+ dataType: "string";
362
+ columnType: "PgText";
363
+ data: string;
364
+ driverParam: string;
365
+ notNull: true;
366
+ hasDefault: true;
367
+ isPrimaryKey: true;
368
+ isAutoincrement: false;
369
+ hasRuntimeDefault: true;
370
+ enumValues: [string, ...string[]];
371
+ baseColumn: never;
372
+ identity: undefined;
373
+ generated: undefined;
374
+ }, {}, {}>;
375
+ productId: import("drizzle-orm/pg-core").PgColumn<{
376
+ name: string;
377
+ tableName: "product_notes";
378
+ dataType: "string";
379
+ columnType: "PgText";
380
+ data: string;
381
+ driverParam: string;
382
+ notNull: true;
383
+ hasDefault: false;
384
+ isPrimaryKey: false;
385
+ isAutoincrement: false;
386
+ hasRuntimeDefault: false;
387
+ enumValues: [string, ...string[]];
388
+ baseColumn: never;
389
+ identity: undefined;
390
+ generated: undefined;
391
+ }, {}, {}>;
392
+ authorId: import("drizzle-orm/pg-core").PgColumn<{
393
+ name: "author_id";
394
+ tableName: "product_notes";
395
+ dataType: "string";
396
+ columnType: "PgText";
397
+ data: string;
398
+ driverParam: string;
399
+ notNull: true;
400
+ hasDefault: false;
401
+ isPrimaryKey: false;
402
+ isAutoincrement: false;
403
+ hasRuntimeDefault: false;
404
+ enumValues: [string, ...string[]];
405
+ baseColumn: never;
406
+ identity: undefined;
407
+ generated: undefined;
408
+ }, {}, {}>;
409
+ content: import("drizzle-orm/pg-core").PgColumn<{
410
+ name: "content";
411
+ tableName: "product_notes";
412
+ dataType: "string";
413
+ columnType: "PgText";
414
+ data: string;
415
+ driverParam: string;
416
+ notNull: true;
417
+ hasDefault: false;
418
+ isPrimaryKey: false;
419
+ isAutoincrement: false;
420
+ hasRuntimeDefault: false;
421
+ enumValues: [string, ...string[]];
422
+ baseColumn: never;
423
+ identity: undefined;
424
+ generated: undefined;
425
+ }, {}, {}>;
426
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
427
+ name: "created_at";
428
+ tableName: "product_notes";
429
+ dataType: "date";
430
+ columnType: "PgTimestamp";
431
+ data: Date;
432
+ driverParam: string;
433
+ notNull: true;
434
+ hasDefault: true;
435
+ isPrimaryKey: false;
436
+ isAutoincrement: false;
437
+ hasRuntimeDefault: false;
438
+ enumValues: undefined;
439
+ baseColumn: never;
440
+ identity: undefined;
441
+ generated: undefined;
442
+ }, {}, {}>;
443
+ }>, "where" | "orderBy">;
444
+ createNote(db: PostgresJsDatabase, productId: string, userId: string, data: CreateProductNoteInput): Promise<{
445
+ id: string;
446
+ createdAt: Date;
447
+ productId: string;
448
+ content: string;
449
+ authorId: string;
450
+ } | null | undefined>;
451
+ recalculate(db: PostgresJsDatabase, productId: string): Promise<{
452
+ costAmountCents: number;
453
+ marginPercent: number;
454
+ } | null>;
455
+ };
456
+ export {};
457
+ //# sourceMappingURL=service-itinerary-history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-itinerary-history.d.ts","sourceRoot":"","sources":["../src/service-itinerary-history.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAW5B,OAAO,KAAK,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAEnF,KAAK,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAC7D,KAAK,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAkCrE,eAAO,MAAM,+BAA+B;qBACzB,kBAAkB,aAAa,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAShD,kBAAkB,aACX,MAAM,UACT,MAAM,QACR,kBAAkB;;;;;;;;;kBAqFZ,kBAAkB,aAAa,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAS7C,kBAAkB,aACX,MAAM,UACT,MAAM,QACR,sBAAsB;;;;;;;oBAwBR,kBAAkB,aAAa,MAAM;;;;CAa5D,CAAA"}
@@ -0,0 +1,135 @@
1
+ import { asc, desc, eq, sql } from "drizzle-orm";
2
+ import { optionUnits, productDayServices, productDays, productItineraries, productNotes, productOptions, products, productVersions, } from "./schema.js";
3
+ async function recalculateProductCost(db, productId) {
4
+ const [result] = await db
5
+ .select({
6
+ totalCost: sql `coalesce(sum(${productDayServices.costAmountCents} * ${productDayServices.quantity}), 0)::int`,
7
+ })
8
+ .from(productDayServices)
9
+ .innerJoin(productDays, eq(productDayServices.dayId, productDays.id))
10
+ .innerJoin(productItineraries, eq(productDays.itineraryId, productItineraries.id))
11
+ .where(eq(productItineraries.productId, productId));
12
+ const costAmountCents = result?.totalCost ?? 0;
13
+ const [product] = await db
14
+ .select({ sellAmountCents: products.sellAmountCents })
15
+ .from(products)
16
+ .where(eq(products.id, productId))
17
+ .limit(1);
18
+ const sellAmountCents = product?.sellAmountCents ?? 0;
19
+ const marginPercent = sellAmountCents > 0
20
+ ? Math.round(((sellAmountCents - costAmountCents) / sellAmountCents) * 100)
21
+ : 0;
22
+ await db
23
+ .update(products)
24
+ .set({ costAmountCents, marginPercent, updatedAt: new Date() })
25
+ .where(eq(products.id, productId));
26
+ return { costAmountCents, marginPercent };
27
+ }
28
+ export const itineraryHistoryProductsService = {
29
+ listVersions(db, productId) {
30
+ return db
31
+ .select()
32
+ .from(productVersions)
33
+ .where(eq(productVersions.productId, productId))
34
+ .orderBy(desc(productVersions.versionNumber));
35
+ },
36
+ async createVersion(db, productId, userId, data) {
37
+ const [product] = await db.select().from(products).where(eq(products.id, productId)).limit(1);
38
+ if (!product) {
39
+ return null;
40
+ }
41
+ const itineraries = await db
42
+ .select()
43
+ .from(productItineraries)
44
+ .where(eq(productItineraries.productId, productId))
45
+ .orderBy(desc(productItineraries.isDefault), asc(productItineraries.sortOrder));
46
+ const defaultItinerary = itineraries.find((itinerary) => itinerary.isDefault) ?? null;
47
+ const options = await db
48
+ .select()
49
+ .from(productOptions)
50
+ .where(eq(productOptions.productId, productId))
51
+ .orderBy(asc(productOptions.sortOrder), asc(productOptions.createdAt));
52
+ const optionsWithUnits = await Promise.all(options.map(async (option) => {
53
+ const units = await db
54
+ .select()
55
+ .from(optionUnits)
56
+ .where(eq(optionUnits.optionId, option.id))
57
+ .orderBy(asc(optionUnits.sortOrder), asc(optionUnits.createdAt));
58
+ return { ...option, units };
59
+ }));
60
+ const itinerariesWithDays = await Promise.all(itineraries.map(async (itinerary) => {
61
+ const days = await db
62
+ .select()
63
+ .from(productDays)
64
+ .where(eq(productDays.itineraryId, itinerary.id))
65
+ .orderBy(asc(productDays.dayNumber));
66
+ const daysWithServices = await Promise.all(days.map(async (day) => {
67
+ const services = await db
68
+ .select()
69
+ .from(productDayServices)
70
+ .where(eq(productDayServices.dayId, day.id))
71
+ .orderBy(asc(productDayServices.sortOrder));
72
+ return { ...day, services };
73
+ }));
74
+ return { ...itinerary, days: daysWithServices };
75
+ }));
76
+ const defaultDays = itinerariesWithDays.find((itinerary) => itinerary.id === defaultItinerary?.id)?.days ?? [];
77
+ const [maxVersion] = await db
78
+ .select({ max: sql `coalesce(max(${productVersions.versionNumber}), 0)` })
79
+ .from(productVersions)
80
+ .where(eq(productVersions.productId, productId));
81
+ const [row] = await db
82
+ .insert(productVersions)
83
+ .values({
84
+ productId,
85
+ versionNumber: (maxVersion?.max ?? 0) + 1,
86
+ snapshot: {
87
+ ...product,
88
+ options: optionsWithUnits,
89
+ itineraries: itinerariesWithDays,
90
+ days: defaultDays,
91
+ },
92
+ authorId: userId,
93
+ notes: data.notes,
94
+ })
95
+ .returning();
96
+ return row;
97
+ },
98
+ listNotes(db, productId) {
99
+ return db
100
+ .select()
101
+ .from(productNotes)
102
+ .where(eq(productNotes.productId, productId))
103
+ .orderBy(productNotes.createdAt);
104
+ },
105
+ async createNote(db, productId, userId, data) {
106
+ const [product] = await db
107
+ .select({ id: products.id })
108
+ .from(products)
109
+ .where(eq(products.id, productId))
110
+ .limit(1);
111
+ if (!product) {
112
+ return null;
113
+ }
114
+ const [row] = await db
115
+ .insert(productNotes)
116
+ .values({
117
+ productId,
118
+ authorId: userId,
119
+ content: data.content,
120
+ })
121
+ .returning();
122
+ return row;
123
+ },
124
+ async recalculate(db, productId) {
125
+ const [product] = await db
126
+ .select({ id: products.id })
127
+ .from(products)
128
+ .where(eq(products.id, productId))
129
+ .limit(1);
130
+ if (!product) {
131
+ return null;
132
+ }
133
+ return recalculateProductCost(db, productId);
134
+ },
135
+ };