@voyant-travel/commerce 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +145 -0
  3. package/dist/accepted-quote-version-reservation-golden-flow.test.d.ts +2 -0
  4. package/dist/accepted-quote-version-reservation-golden-flow.test.d.ts.map +1 -0
  5. package/dist/accepted-quote-version-reservation-golden-flow.test.js +398 -0
  6. package/dist/index.d.ts +15 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +14 -0
  9. package/dist/interface.d.ts +18 -0
  10. package/dist/interface.d.ts.map +1 -0
  11. package/dist/interface.js +246 -0
  12. package/dist/interface.test.d.ts +2 -0
  13. package/dist/interface.test.d.ts.map +1 -0
  14. package/dist/interface.test.js +357 -0
  15. package/dist/markets/index.d.ts +11 -0
  16. package/dist/markets/index.d.ts.map +1 -0
  17. package/dist/markets/index.js +12 -0
  18. package/dist/markets/routes.d.ts +1182 -0
  19. package/dist/markets/routes.d.ts.map +1 -0
  20. package/dist/markets/routes.js +209 -0
  21. package/dist/markets/schema.d.ts +1527 -0
  22. package/dist/markets/schema.d.ts.map +1 -0
  23. package/dist/markets/schema.js +240 -0
  24. package/dist/markets/service-core.d.ts +253 -0
  25. package/dist/markets/service-core.d.ts.map +1 -0
  26. package/dist/markets/service-core.js +242 -0
  27. package/dist/markets/service-rules.d.ts +191 -0
  28. package/dist/markets/service-rules.d.ts.map +1 -0
  29. package/dist/markets/service-rules.js +155 -0
  30. package/dist/markets/service-shared.d.ts +36 -0
  31. package/dist/markets/service-shared.d.ts.map +1 -0
  32. package/dist/markets/service-shared.js +7 -0
  33. package/dist/markets/service.d.ts +43 -0
  34. package/dist/markets/service.d.ts.map +1 -0
  35. package/dist/markets/service.js +42 -0
  36. package/dist/markets/validation.d.ts +451 -0
  37. package/dist/markets/validation.d.ts.map +1 -0
  38. package/dist/markets/validation.js +160 -0
  39. package/dist/pricing/events.d.ts +53 -0
  40. package/dist/pricing/events.d.ts.map +1 -0
  41. package/dist/pricing/events.js +28 -0
  42. package/dist/pricing/index.d.ts +15 -0
  43. package/dist/pricing/index.d.ts.map +1 -0
  44. package/dist/pricing/index.js +18 -0
  45. package/dist/pricing/routes-core.d.ts +981 -0
  46. package/dist/pricing/routes-core.d.ts.map +1 -0
  47. package/dist/pricing/routes-core.js +102 -0
  48. package/dist/pricing/routes-public.d.ts +136 -0
  49. package/dist/pricing/routes-public.d.ts.map +1 -0
  50. package/dist/pricing/routes-public.js +14 -0
  51. package/dist/pricing/routes-rules.d.ts +1339 -0
  52. package/dist/pricing/routes-rules.d.ts.map +1 -0
  53. package/dist/pricing/routes-rules.js +138 -0
  54. package/dist/pricing/routes-shared.d.ts +14 -0
  55. package/dist/pricing/routes-shared.d.ts.map +1 -0
  56. package/dist/pricing/routes-shared.js +3 -0
  57. package/dist/pricing/routes.d.ts +7 -0
  58. package/dist/pricing/routes.d.ts.map +1 -0
  59. package/dist/pricing/routes.js +6 -0
  60. package/dist/pricing/schema-catalogs.d.ts +467 -0
  61. package/dist/pricing/schema-catalogs.d.ts.map +1 -0
  62. package/dist/pricing/schema-catalogs.js +47 -0
  63. package/dist/pricing/schema-categories.d.ts +497 -0
  64. package/dist/pricing/schema-categories.d.ts.map +1 -0
  65. package/dist/pricing/schema-categories.js +54 -0
  66. package/dist/pricing/schema-departure-overrides.d.ts +228 -0
  67. package/dist/pricing/schema-departure-overrides.d.ts.map +1 -0
  68. package/dist/pricing/schema-departure-overrides.js +36 -0
  69. package/dist/pricing/schema-option-rules.d.ts +1770 -0
  70. package/dist/pricing/schema-option-rules.d.ts.map +1 -0
  71. package/dist/pricing/schema-option-rules.js +181 -0
  72. package/dist/pricing/schema-policies.d.ts +395 -0
  73. package/dist/pricing/schema-policies.d.ts.map +1 -0
  74. package/dist/pricing/schema-policies.js +41 -0
  75. package/dist/pricing/schema-relations.d.ts +59 -0
  76. package/dist/pricing/schema-relations.d.ts.map +1 -0
  77. package/dist/pricing/schema-relations.js +111 -0
  78. package/dist/pricing/schema-shared.d.ts +11 -0
  79. package/dist/pricing/schema-shared.d.ts.map +1 -0
  80. package/dist/pricing/schema-shared.js +67 -0
  81. package/dist/pricing/schema.d.ts +8 -0
  82. package/dist/pricing/schema.d.ts.map +1 -0
  83. package/dist/pricing/schema.js +7 -0
  84. package/dist/pricing/service-catalog-plane-pricing.d.ts +95 -0
  85. package/dist/pricing/service-catalog-plane-pricing.d.ts.map +1 -0
  86. package/dist/pricing/service-catalog-plane-pricing.js +382 -0
  87. package/dist/pricing/service-catalogs.d.ts +139 -0
  88. package/dist/pricing/service-catalogs.d.ts.map +1 -0
  89. package/dist/pricing/service-catalogs.js +89 -0
  90. package/dist/pricing/service-categories.d.ts +147 -0
  91. package/dist/pricing/service-categories.d.ts.map +1 -0
  92. package/dist/pricing/service-categories.js +105 -0
  93. package/dist/pricing/service-departure-overrides.d.ts +67 -0
  94. package/dist/pricing/service-departure-overrides.d.ts.map +1 -0
  95. package/dist/pricing/service-departure-overrides.js +54 -0
  96. package/dist/pricing/service-option-rules.d.ts +321 -0
  97. package/dist/pricing/service-option-rules.d.ts.map +1 -0
  98. package/dist/pricing/service-option-rules.js +340 -0
  99. package/dist/pricing/service-policies.d.ts +123 -0
  100. package/dist/pricing/service-policies.d.ts.map +1 -0
  101. package/dist/pricing/service-policies.js +95 -0
  102. package/dist/pricing/service-public.d.ts +89 -0
  103. package/dist/pricing/service-public.d.ts.map +1 -0
  104. package/dist/pricing/service-public.js +473 -0
  105. package/dist/pricing/service-rule-resolver.d.ts +67 -0
  106. package/dist/pricing/service-rule-resolver.d.ts.map +1 -0
  107. package/dist/pricing/service-rule-resolver.js +204 -0
  108. package/dist/pricing/service-shared.d.ts +53 -0
  109. package/dist/pricing/service-shared.d.ts.map +1 -0
  110. package/dist/pricing/service-shared.js +4 -0
  111. package/dist/pricing/service-transfer-rules.d.ts +211 -0
  112. package/dist/pricing/service-transfer-rules.d.ts.map +1 -0
  113. package/dist/pricing/service-transfer-rules.js +139 -0
  114. package/dist/pricing/service.d.ts +79 -0
  115. package/dist/pricing/service.d.ts.map +1 -0
  116. package/dist/pricing/service.js +78 -0
  117. package/dist/pricing/validation-public.d.ts +412 -0
  118. package/dist/pricing/validation-public.d.ts.map +1 -0
  119. package/dist/pricing/validation-public.js +111 -0
  120. package/dist/pricing/validation-shared.d.ts +71 -0
  121. package/dist/pricing/validation-shared.d.ts.map +1 -0
  122. package/dist/pricing/validation-shared.js +63 -0
  123. package/dist/pricing/validation.d.ts +987 -0
  124. package/dist/pricing/validation.d.ts.map +1 -0
  125. package/dist/pricing/validation.js +307 -0
  126. package/dist/promotions/events.d.ts +38 -0
  127. package/dist/promotions/events.d.ts.map +1 -0
  128. package/dist/promotions/events.js +25 -0
  129. package/dist/promotions/index.d.ts +12 -0
  130. package/dist/promotions/index.d.ts.map +1 -0
  131. package/dist/promotions/index.js +17 -0
  132. package/dist/promotions/routes-shared.d.ts +14 -0
  133. package/dist/promotions/routes-shared.d.ts.map +1 -0
  134. package/dist/promotions/routes-shared.js +3 -0
  135. package/dist/promotions/routes.d.ts +395 -0
  136. package/dist/promotions/routes.d.ts.map +1 -0
  137. package/dist/promotions/routes.js +55 -0
  138. package/dist/promotions/schema.d.ts +675 -0
  139. package/dist/promotions/schema.d.ts.map +1 -0
  140. package/dist/promotions/schema.js +126 -0
  141. package/dist/promotions/service-booking-confirmed.d.ts +77 -0
  142. package/dist/promotions/service-booking-confirmed.d.ts.map +1 -0
  143. package/dist/promotions/service-booking-confirmed.js +134 -0
  144. package/dist/promotions/service-boundary-scheduler.d.ts +85 -0
  145. package/dist/promotions/service-boundary-scheduler.d.ts.map +1 -0
  146. package/dist/promotions/service-boundary-scheduler.js +141 -0
  147. package/dist/promotions/service-catalog-evaluator.d.ts +22 -0
  148. package/dist/promotions/service-catalog-evaluator.d.ts.map +1 -0
  149. package/dist/promotions/service-catalog-evaluator.js +33 -0
  150. package/dist/promotions/service-catalog-plane-promotions.d.ts +73 -0
  151. package/dist/promotions/service-catalog-plane-promotions.d.ts.map +1 -0
  152. package/dist/promotions/service-catalog-plane-promotions.js +118 -0
  153. package/dist/promotions/service-evaluator.d.ts +134 -0
  154. package/dist/promotions/service-evaluator.d.ts.map +1 -0
  155. package/dist/promotions/service-evaluator.js +302 -0
  156. package/dist/promotions/service-storefront.d.ts +147 -0
  157. package/dist/promotions/service-storefront.d.ts.map +1 -0
  158. package/dist/promotions/service-storefront.js +326 -0
  159. package/dist/promotions/service.d.ts +143 -0
  160. package/dist/promotions/service.d.ts.map +1 -0
  161. package/dist/promotions/service.js +359 -0
  162. package/dist/promotions/validation.d.ts +195 -0
  163. package/dist/promotions/validation.d.ts.map +1 -0
  164. package/dist/promotions/validation.js +167 -0
  165. package/dist/promotions/workflow-bulk-reindex.d.ts +36 -0
  166. package/dist/promotions/workflow-bulk-reindex.d.ts.map +1 -0
  167. package/dist/promotions/workflow-bulk-reindex.js +53 -0
  168. package/dist/promotions/workflow-runtime.d.ts +17 -0
  169. package/dist/promotions/workflow-runtime.d.ts.map +1 -0
  170. package/dist/promotions/workflow-runtime.js +9 -0
  171. package/dist/runtime.d.ts +18 -0
  172. package/dist/runtime.d.ts.map +1 -0
  173. package/dist/runtime.js +27 -0
  174. package/dist/runtime.test.d.ts +2 -0
  175. package/dist/runtime.test.d.ts.map +1 -0
  176. package/dist/runtime.test.js +25 -0
  177. package/dist/schema.d.ts +5 -0
  178. package/dist/schema.d.ts.map +1 -0
  179. package/dist/schema.js +4 -0
  180. package/dist/sellability/index.d.ts +13 -0
  181. package/dist/sellability/index.d.ts.map +1 -0
  182. package/dist/sellability/index.js +17 -0
  183. package/dist/sellability/routes.d.ts +2332 -0
  184. package/dist/sellability/routes.d.ts.map +1 -0
  185. package/dist/sellability/routes.js +166 -0
  186. package/dist/sellability/schema.d.ts +1716 -0
  187. package/dist/sellability/schema.d.ts.map +1 -0
  188. package/dist/sellability/schema.js +278 -0
  189. package/dist/sellability/service-records.d.ts +316 -0
  190. package/dist/sellability/service-records.d.ts.map +1 -0
  191. package/dist/sellability/service-records.js +253 -0
  192. package/dist/sellability/service-resolve.d.ts +72 -0
  193. package/dist/sellability/service-resolve.d.ts.map +1 -0
  194. package/dist/sellability/service-resolve.js +580 -0
  195. package/dist/sellability/service-shared.d.ts +124 -0
  196. package/dist/sellability/service-shared.d.ts.map +1 -0
  197. package/dist/sellability/service-shared.js +96 -0
  198. package/dist/sellability/service-snapshots.d.ts +191 -0
  199. package/dist/sellability/service-snapshots.d.ts.map +1 -0
  200. package/dist/sellability/service-snapshots.js +153 -0
  201. package/dist/sellability/service.d.ts +1038 -0
  202. package/dist/sellability/service.d.ts.map +1 -0
  203. package/dist/sellability/service.js +17 -0
  204. package/dist/sellability/validation.d.ts +477 -0
  205. package/dist/sellability/validation.d.ts.map +1 -0
  206. package/dist/sellability/validation.js +192 -0
  207. package/dist/types.d.ts +239 -0
  208. package/dist/types.d.ts.map +1 -0
  209. package/dist/types.js +1 -0
  210. package/package.json +62 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-option-rules.d.ts","sourceRoot":"","sources":["../../src/pricing/schema-option-rules.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,181 @@
1
+ import { typeId, typeIdRef } from "@voyant-travel/db/lib/typeid-column";
2
+ import { boolean, index, integer, jsonb, pgTable, text, timestamp, uniqueIndex, } from "drizzle-orm/pg-core";
3
+ import { priceCatalogs, priceSchedules } from "./schema-catalogs.js";
4
+ import { pricingCategories } from "./schema-categories.js";
5
+ import { cancellationPolicies } from "./schema-policies.js";
6
+ import { addonPricingModeEnum, optionPricingModeEnum, optionStartTimeRuleModeEnum, optionUnitPricingModeEnum, priceAdjustmentTypeEnum, } from "./schema-shared.js";
7
+ export const optionPriceRules = pgTable("option_price_rules", {
8
+ id: typeId("option_price_rules"),
9
+ productId: text("product_id").notNull(),
10
+ optionId: text("option_id").notNull(),
11
+ priceCatalogId: typeIdRef("price_catalog_id")
12
+ .notNull()
13
+ .references(() => priceCatalogs.id, { onDelete: "cascade" }),
14
+ priceScheduleId: typeIdRef("price_schedule_id").references(() => priceSchedules.id, {
15
+ onDelete: "set null",
16
+ }),
17
+ cancellationPolicyId: typeIdRef("cancellation_policy_id").references(() => cancellationPolicies.id, { onDelete: "set null" }),
18
+ code: text("code"),
19
+ name: text("name").notNull(),
20
+ description: text("description"),
21
+ pricingMode: optionPricingModeEnum("pricing_mode").notNull().default("per_person"),
22
+ baseSellAmountCents: integer("base_sell_amount_cents"),
23
+ baseCostAmountCents: integer("base_cost_amount_cents"),
24
+ minPerBooking: integer("min_per_booking"),
25
+ maxPerBooking: integer("max_per_booking"),
26
+ allPricingCategories: boolean("all_pricing_categories").notNull().default(true),
27
+ isDefault: boolean("is_default").notNull().default(false),
28
+ active: boolean("active").notNull().default(true),
29
+ notes: text("notes"),
30
+ metadata: jsonb("metadata").$type(),
31
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
32
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
33
+ }, (table) => [
34
+ index("idx_option_price_rules_updated").on(table.updatedAt),
35
+ index("idx_option_price_rules_product_updated").on(table.productId, table.updatedAt),
36
+ index("idx_option_price_rules_option_updated").on(table.optionId, table.updatedAt),
37
+ index("idx_option_price_rules_catalog_updated").on(table.priceCatalogId, table.updatedAt),
38
+ index("idx_option_price_rules_schedule_updated").on(table.priceScheduleId, table.updatedAt),
39
+ index("idx_option_price_rules_policy_updated").on(table.cancellationPolicyId, table.updatedAt),
40
+ index("idx_option_price_rules_pricing_mode_updated").on(table.pricingMode, table.updatedAt),
41
+ index("idx_option_price_rules_active_updated").on(table.active, table.updatedAt),
42
+ uniqueIndex("uidx_option_price_rules_option_code").on(table.optionId, table.code),
43
+ ]);
44
+ export const optionUnitPriceRules = pgTable("option_unit_price_rules", {
45
+ id: typeId("option_unit_price_rules"),
46
+ optionPriceRuleId: typeIdRef("option_price_rule_id")
47
+ .notNull()
48
+ .references(() => optionPriceRules.id, { onDelete: "cascade" }),
49
+ optionId: text("option_id").notNull(),
50
+ unitId: text("unit_id").notNull(),
51
+ pricingCategoryId: typeIdRef("pricing_category_id").references(() => pricingCategories.id, {
52
+ onDelete: "set null",
53
+ }),
54
+ pricingMode: optionUnitPricingModeEnum("pricing_mode").notNull().default("per_unit"),
55
+ sellAmountCents: integer("sell_amount_cents"),
56
+ costAmountCents: integer("cost_amount_cents"),
57
+ minQuantity: integer("min_quantity"),
58
+ maxQuantity: integer("max_quantity"),
59
+ active: boolean("active").notNull().default(true),
60
+ sortOrder: integer("sort_order").notNull().default(0),
61
+ notes: text("notes"),
62
+ metadata: jsonb("metadata").$type(),
63
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
64
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
65
+ }, (table) => [
66
+ index("idx_option_unit_price_rules_rule_sort_created").on(table.optionPriceRuleId, table.sortOrder, table.createdAt),
67
+ index("idx_option_unit_price_rules_option_sort_created").on(table.optionId, table.sortOrder, table.createdAt),
68
+ index("idx_option_unit_price_rules_unit_sort_created").on(table.unitId, table.sortOrder, table.createdAt),
69
+ index("idx_option_unit_price_rules_category_sort_created").on(table.pricingCategoryId, table.sortOrder, table.createdAt),
70
+ index("idx_option_unit_price_rules_active_sort_created").on(table.active, table.sortOrder, table.createdAt),
71
+ ]);
72
+ export const optionStartTimeRules = pgTable("option_start_time_rules", {
73
+ id: typeId("option_start_time_rules"),
74
+ optionPriceRuleId: typeIdRef("option_price_rule_id")
75
+ .notNull()
76
+ .references(() => optionPriceRules.id, { onDelete: "cascade" }),
77
+ optionId: text("option_id").notNull(),
78
+ startTimeId: text("start_time_id").notNull(),
79
+ ruleMode: optionStartTimeRuleModeEnum("rule_mode").notNull().default("included"),
80
+ adjustmentType: priceAdjustmentTypeEnum("adjustment_type"),
81
+ sellAdjustmentCents: integer("sell_adjustment_cents"),
82
+ costAdjustmentCents: integer("cost_adjustment_cents"),
83
+ adjustmentBasisPoints: integer("adjustment_basis_points"),
84
+ active: boolean("active").notNull().default(true),
85
+ notes: text("notes"),
86
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
87
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
88
+ }, (table) => [
89
+ index("idx_option_start_time_rules_created").on(table.createdAt),
90
+ index("idx_option_start_time_rules_rule_created").on(table.optionPriceRuleId, table.createdAt),
91
+ index("idx_option_start_time_rules_option_created").on(table.optionId, table.createdAt),
92
+ index("idx_option_start_time_rules_start_time_created").on(table.startTimeId, table.createdAt),
93
+ index("idx_option_start_time_rules_active_created").on(table.active, table.createdAt),
94
+ uniqueIndex("uidx_option_start_time_rules_rule_start_time").on(table.optionPriceRuleId, table.startTimeId),
95
+ ]);
96
+ export const optionUnitTiers = pgTable("option_unit_tiers", {
97
+ id: typeId("option_unit_tiers"),
98
+ optionUnitPriceRuleId: typeIdRef("option_unit_price_rule_id")
99
+ .notNull()
100
+ .references(() => optionUnitPriceRules.id, { onDelete: "cascade" }),
101
+ minQuantity: integer("min_quantity").notNull(),
102
+ maxQuantity: integer("max_quantity"),
103
+ sellAmountCents: integer("sell_amount_cents"),
104
+ costAmountCents: integer("cost_amount_cents"),
105
+ active: boolean("active").notNull().default(true),
106
+ sortOrder: integer("sort_order").notNull().default(0),
107
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
108
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
109
+ }, (table) => [
110
+ index("idx_option_unit_tiers_rule_sort_min_quantity").on(table.optionUnitPriceRuleId, table.sortOrder, table.minQuantity),
111
+ index("idx_option_unit_tiers_active_sort_min_quantity").on(table.active, table.sortOrder, table.minQuantity),
112
+ ]);
113
+ export const pickupPriceRules = pgTable("pickup_price_rules", {
114
+ id: typeId("pickup_price_rules"),
115
+ optionPriceRuleId: typeIdRef("option_price_rule_id")
116
+ .notNull()
117
+ .references(() => optionPriceRules.id, { onDelete: "cascade" }),
118
+ optionId: text("option_id").notNull(),
119
+ pickupPointId: text("pickup_point_id").notNull(),
120
+ pricingMode: addonPricingModeEnum("pricing_mode").notNull().default("included"),
121
+ sellAmountCents: integer("sell_amount_cents"),
122
+ costAmountCents: integer("cost_amount_cents"),
123
+ active: boolean("active").notNull().default(true),
124
+ sortOrder: integer("sort_order").notNull().default(0),
125
+ notes: text("notes"),
126
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
127
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
128
+ }, (table) => [
129
+ index("idx_pickup_price_rules_rule_sort_created").on(table.optionPriceRuleId, table.sortOrder, table.createdAt),
130
+ index("idx_pickup_price_rules_option_sort_created").on(table.optionId, table.sortOrder, table.createdAt),
131
+ index("idx_pickup_price_rules_pickup_sort_created").on(table.pickupPointId, table.sortOrder, table.createdAt),
132
+ index("idx_pickup_price_rules_active_sort_created").on(table.active, table.sortOrder, table.createdAt),
133
+ uniqueIndex("uidx_pickup_price_rules_rule_pickup").on(table.optionPriceRuleId, table.pickupPointId),
134
+ ]);
135
+ export const dropoffPriceRules = pgTable("dropoff_price_rules", {
136
+ id: typeId("dropoff_price_rules"),
137
+ optionPriceRuleId: typeIdRef("option_price_rule_id")
138
+ .notNull()
139
+ .references(() => optionPriceRules.id, { onDelete: "cascade" }),
140
+ optionId: text("option_id").notNull(),
141
+ facilityId: text("facility_id"),
142
+ dropoffCode: text("dropoff_code"),
143
+ dropoffName: text("dropoff_name").notNull(),
144
+ pricingMode: addonPricingModeEnum("pricing_mode").notNull().default("included"),
145
+ sellAmountCents: integer("sell_amount_cents"),
146
+ costAmountCents: integer("cost_amount_cents"),
147
+ active: boolean("active").notNull().default(true),
148
+ sortOrder: integer("sort_order").notNull().default(0),
149
+ notes: text("notes"),
150
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
151
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
152
+ }, (table) => [
153
+ index("idx_dropoff_price_rules_rule_sort_created").on(table.optionPriceRuleId, table.sortOrder, table.createdAt),
154
+ index("idx_dropoff_price_rules_option_sort_created").on(table.optionId, table.sortOrder, table.createdAt),
155
+ index("idx_dropoff_price_rules_facility_sort_created").on(table.facilityId, table.sortOrder, table.createdAt),
156
+ index("idx_dropoff_price_rules_active_sort_created").on(table.active, table.sortOrder, table.createdAt),
157
+ ]);
158
+ export const extraPriceRules = pgTable("extra_price_rules", {
159
+ id: typeId("extra_price_rules"),
160
+ optionPriceRuleId: typeIdRef("option_price_rule_id")
161
+ .notNull()
162
+ .references(() => optionPriceRules.id, { onDelete: "cascade" }),
163
+ optionId: text("option_id").notNull(),
164
+ productExtraId: text("product_extra_id"),
165
+ optionExtraConfigId: text("option_extra_config_id"),
166
+ pricingMode: addonPricingModeEnum("pricing_mode").notNull().default("included"),
167
+ sellAmountCents: integer("sell_amount_cents"),
168
+ costAmountCents: integer("cost_amount_cents"),
169
+ active: boolean("active").notNull().default(true),
170
+ sortOrder: integer("sort_order").notNull().default(0),
171
+ notes: text("notes"),
172
+ metadata: jsonb("metadata").$type(),
173
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
174
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
175
+ }, (table) => [
176
+ index("idx_extra_price_rules_rule_sort_created").on(table.optionPriceRuleId, table.sortOrder, table.createdAt),
177
+ index("idx_extra_price_rules_option_sort_created").on(table.optionId, table.sortOrder, table.createdAt),
178
+ index("idx_extra_price_rules_product_extra_sort_created").on(table.productExtraId, table.sortOrder, table.createdAt),
179
+ index("idx_extra_price_rules_option_extra_config_sort_created").on(table.optionExtraConfigId, table.sortOrder, table.createdAt),
180
+ index("idx_extra_price_rules_active_sort_created").on(table.active, table.sortOrder, table.createdAt),
181
+ ]);
@@ -0,0 +1,395 @@
1
+ export declare const cancellationPolicies: import("drizzle-orm/pg-core").PgTableWithColumns<{
2
+ name: "cancellation_policies";
3
+ schema: undefined;
4
+ columns: {
5
+ id: import("drizzle-orm/pg-core").PgColumn<{
6
+ name: string;
7
+ tableName: "cancellation_policies";
8
+ dataType: "string";
9
+ columnType: "PgText";
10
+ data: string;
11
+ driverParam: string;
12
+ notNull: true;
13
+ hasDefault: true;
14
+ isPrimaryKey: true;
15
+ isAutoincrement: false;
16
+ hasRuntimeDefault: true;
17
+ enumValues: [string, ...string[]];
18
+ baseColumn: never;
19
+ identity: undefined;
20
+ generated: undefined;
21
+ }, {}, {}>;
22
+ code: import("drizzle-orm/pg-core").PgColumn<{
23
+ name: "code";
24
+ tableName: "cancellation_policies";
25
+ dataType: "string";
26
+ columnType: "PgText";
27
+ data: string;
28
+ driverParam: string;
29
+ notNull: false;
30
+ hasDefault: false;
31
+ isPrimaryKey: false;
32
+ isAutoincrement: false;
33
+ hasRuntimeDefault: false;
34
+ enumValues: [string, ...string[]];
35
+ baseColumn: never;
36
+ identity: undefined;
37
+ generated: undefined;
38
+ }, {}, {}>;
39
+ name: import("drizzle-orm/pg-core").PgColumn<{
40
+ name: "name";
41
+ tableName: "cancellation_policies";
42
+ dataType: "string";
43
+ columnType: "PgText";
44
+ data: string;
45
+ driverParam: string;
46
+ notNull: true;
47
+ hasDefault: false;
48
+ isPrimaryKey: false;
49
+ isAutoincrement: false;
50
+ hasRuntimeDefault: false;
51
+ enumValues: [string, ...string[]];
52
+ baseColumn: never;
53
+ identity: undefined;
54
+ generated: undefined;
55
+ }, {}, {}>;
56
+ policyType: import("drizzle-orm/pg-core").PgColumn<{
57
+ name: "policy_type";
58
+ tableName: "cancellation_policies";
59
+ dataType: "string";
60
+ columnType: "PgEnumColumn";
61
+ data: "custom" | "simple" | "advanced" | "non_refundable";
62
+ driverParam: string;
63
+ notNull: true;
64
+ hasDefault: true;
65
+ isPrimaryKey: false;
66
+ isAutoincrement: false;
67
+ hasRuntimeDefault: false;
68
+ enumValues: ["simple", "advanced", "non_refundable", "custom"];
69
+ baseColumn: never;
70
+ identity: undefined;
71
+ generated: undefined;
72
+ }, {}, {}>;
73
+ simpleCutoffHours: import("drizzle-orm/pg-core").PgColumn<{
74
+ name: "simple_cutoff_hours";
75
+ tableName: "cancellation_policies";
76
+ dataType: "number";
77
+ columnType: "PgInteger";
78
+ data: number;
79
+ driverParam: string | number;
80
+ notNull: false;
81
+ hasDefault: false;
82
+ isPrimaryKey: false;
83
+ isAutoincrement: false;
84
+ hasRuntimeDefault: false;
85
+ enumValues: undefined;
86
+ baseColumn: never;
87
+ identity: undefined;
88
+ generated: undefined;
89
+ }, {}, {}>;
90
+ isDefault: import("drizzle-orm/pg-core").PgColumn<{
91
+ name: "is_default";
92
+ tableName: "cancellation_policies";
93
+ dataType: "boolean";
94
+ columnType: "PgBoolean";
95
+ data: boolean;
96
+ driverParam: boolean;
97
+ notNull: true;
98
+ hasDefault: true;
99
+ isPrimaryKey: false;
100
+ isAutoincrement: false;
101
+ hasRuntimeDefault: false;
102
+ enumValues: undefined;
103
+ baseColumn: never;
104
+ identity: undefined;
105
+ generated: undefined;
106
+ }, {}, {}>;
107
+ active: import("drizzle-orm/pg-core").PgColumn<{
108
+ name: "active";
109
+ tableName: "cancellation_policies";
110
+ dataType: "boolean";
111
+ columnType: "PgBoolean";
112
+ data: boolean;
113
+ driverParam: boolean;
114
+ notNull: true;
115
+ hasDefault: true;
116
+ isPrimaryKey: false;
117
+ isAutoincrement: false;
118
+ hasRuntimeDefault: false;
119
+ enumValues: undefined;
120
+ baseColumn: never;
121
+ identity: undefined;
122
+ generated: undefined;
123
+ }, {}, {}>;
124
+ notes: import("drizzle-orm/pg-core").PgColumn<{
125
+ name: "notes";
126
+ tableName: "cancellation_policies";
127
+ dataType: "string";
128
+ columnType: "PgText";
129
+ data: string;
130
+ driverParam: string;
131
+ notNull: false;
132
+ hasDefault: false;
133
+ isPrimaryKey: false;
134
+ isAutoincrement: false;
135
+ hasRuntimeDefault: false;
136
+ enumValues: [string, ...string[]];
137
+ baseColumn: never;
138
+ identity: undefined;
139
+ generated: undefined;
140
+ }, {}, {}>;
141
+ metadata: import("drizzle-orm/pg-core").PgColumn<{
142
+ name: "metadata";
143
+ tableName: "cancellation_policies";
144
+ dataType: "json";
145
+ columnType: "PgJsonb";
146
+ data: Record<string, unknown>;
147
+ driverParam: unknown;
148
+ notNull: false;
149
+ hasDefault: false;
150
+ isPrimaryKey: false;
151
+ isAutoincrement: false;
152
+ hasRuntimeDefault: false;
153
+ enumValues: undefined;
154
+ baseColumn: never;
155
+ identity: undefined;
156
+ generated: undefined;
157
+ }, {}, {
158
+ $type: Record<string, unknown>;
159
+ }>;
160
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
161
+ name: "created_at";
162
+ tableName: "cancellation_policies";
163
+ dataType: "date";
164
+ columnType: "PgTimestamp";
165
+ data: Date;
166
+ driverParam: string;
167
+ notNull: true;
168
+ hasDefault: true;
169
+ isPrimaryKey: false;
170
+ isAutoincrement: false;
171
+ hasRuntimeDefault: false;
172
+ enumValues: undefined;
173
+ baseColumn: never;
174
+ identity: undefined;
175
+ generated: undefined;
176
+ }, {}, {}>;
177
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
178
+ name: "updated_at";
179
+ tableName: "cancellation_policies";
180
+ dataType: "date";
181
+ columnType: "PgTimestamp";
182
+ data: Date;
183
+ driverParam: string;
184
+ notNull: true;
185
+ hasDefault: true;
186
+ isPrimaryKey: false;
187
+ isAutoincrement: false;
188
+ hasRuntimeDefault: false;
189
+ enumValues: undefined;
190
+ baseColumn: never;
191
+ identity: undefined;
192
+ generated: undefined;
193
+ }, {}, {}>;
194
+ };
195
+ dialect: "pg";
196
+ }>;
197
+ export declare const cancellationPolicyRules: import("drizzle-orm/pg-core").PgTableWithColumns<{
198
+ name: "cancellation_policy_rules";
199
+ schema: undefined;
200
+ columns: {
201
+ id: import("drizzle-orm/pg-core").PgColumn<{
202
+ name: string;
203
+ tableName: "cancellation_policy_rules";
204
+ dataType: "string";
205
+ columnType: "PgText";
206
+ data: string;
207
+ driverParam: string;
208
+ notNull: true;
209
+ hasDefault: true;
210
+ isPrimaryKey: true;
211
+ isAutoincrement: false;
212
+ hasRuntimeDefault: true;
213
+ enumValues: [string, ...string[]];
214
+ baseColumn: never;
215
+ identity: undefined;
216
+ generated: undefined;
217
+ }, {}, {}>;
218
+ cancellationPolicyId: import("drizzle-orm/pg-core").PgColumn<{
219
+ name: string;
220
+ tableName: "cancellation_policy_rules";
221
+ dataType: "string";
222
+ columnType: "PgText";
223
+ data: string;
224
+ driverParam: string;
225
+ notNull: true;
226
+ hasDefault: false;
227
+ isPrimaryKey: false;
228
+ isAutoincrement: false;
229
+ hasRuntimeDefault: false;
230
+ enumValues: [string, ...string[]];
231
+ baseColumn: never;
232
+ identity: undefined;
233
+ generated: undefined;
234
+ }, {}, {}>;
235
+ sortOrder: import("drizzle-orm/pg-core").PgColumn<{
236
+ name: "sort_order";
237
+ tableName: "cancellation_policy_rules";
238
+ dataType: "number";
239
+ columnType: "PgInteger";
240
+ data: number;
241
+ driverParam: string | number;
242
+ notNull: true;
243
+ hasDefault: true;
244
+ isPrimaryKey: false;
245
+ isAutoincrement: false;
246
+ hasRuntimeDefault: false;
247
+ enumValues: undefined;
248
+ baseColumn: never;
249
+ identity: undefined;
250
+ generated: undefined;
251
+ }, {}, {}>;
252
+ cutoffMinutesBefore: import("drizzle-orm/pg-core").PgColumn<{
253
+ name: "cutoff_minutes_before";
254
+ tableName: "cancellation_policy_rules";
255
+ dataType: "number";
256
+ columnType: "PgInteger";
257
+ data: number;
258
+ driverParam: string | number;
259
+ notNull: false;
260
+ hasDefault: false;
261
+ isPrimaryKey: false;
262
+ isAutoincrement: false;
263
+ hasRuntimeDefault: false;
264
+ enumValues: undefined;
265
+ baseColumn: never;
266
+ identity: undefined;
267
+ generated: undefined;
268
+ }, {}, {}>;
269
+ chargeType: import("drizzle-orm/pg-core").PgColumn<{
270
+ name: "charge_type";
271
+ tableName: "cancellation_policy_rules";
272
+ dataType: "string";
273
+ columnType: "PgEnumColumn";
274
+ data: "none" | "amount" | "percentage";
275
+ driverParam: string;
276
+ notNull: true;
277
+ hasDefault: true;
278
+ isPrimaryKey: false;
279
+ isAutoincrement: false;
280
+ hasRuntimeDefault: false;
281
+ enumValues: ["none", "amount", "percentage"];
282
+ baseColumn: never;
283
+ identity: undefined;
284
+ generated: undefined;
285
+ }, {}, {}>;
286
+ chargeAmountCents: import("drizzle-orm/pg-core").PgColumn<{
287
+ name: "charge_amount_cents";
288
+ tableName: "cancellation_policy_rules";
289
+ dataType: "number";
290
+ columnType: "PgInteger";
291
+ data: number;
292
+ driverParam: string | number;
293
+ notNull: false;
294
+ hasDefault: false;
295
+ isPrimaryKey: false;
296
+ isAutoincrement: false;
297
+ hasRuntimeDefault: false;
298
+ enumValues: undefined;
299
+ baseColumn: never;
300
+ identity: undefined;
301
+ generated: undefined;
302
+ }, {}, {}>;
303
+ chargePercentBasisPoints: import("drizzle-orm/pg-core").PgColumn<{
304
+ name: "charge_percent_basis_points";
305
+ tableName: "cancellation_policy_rules";
306
+ dataType: "number";
307
+ columnType: "PgInteger";
308
+ data: number;
309
+ driverParam: string | number;
310
+ notNull: false;
311
+ hasDefault: false;
312
+ isPrimaryKey: false;
313
+ isAutoincrement: false;
314
+ hasRuntimeDefault: false;
315
+ enumValues: undefined;
316
+ baseColumn: never;
317
+ identity: undefined;
318
+ generated: undefined;
319
+ }, {}, {}>;
320
+ active: import("drizzle-orm/pg-core").PgColumn<{
321
+ name: "active";
322
+ tableName: "cancellation_policy_rules";
323
+ dataType: "boolean";
324
+ columnType: "PgBoolean";
325
+ data: boolean;
326
+ driverParam: boolean;
327
+ notNull: true;
328
+ hasDefault: true;
329
+ isPrimaryKey: false;
330
+ isAutoincrement: false;
331
+ hasRuntimeDefault: false;
332
+ enumValues: undefined;
333
+ baseColumn: never;
334
+ identity: undefined;
335
+ generated: undefined;
336
+ }, {}, {}>;
337
+ notes: import("drizzle-orm/pg-core").PgColumn<{
338
+ name: "notes";
339
+ tableName: "cancellation_policy_rules";
340
+ dataType: "string";
341
+ columnType: "PgText";
342
+ data: string;
343
+ driverParam: string;
344
+ notNull: false;
345
+ hasDefault: false;
346
+ isPrimaryKey: false;
347
+ isAutoincrement: false;
348
+ hasRuntimeDefault: false;
349
+ enumValues: [string, ...string[]];
350
+ baseColumn: never;
351
+ identity: undefined;
352
+ generated: undefined;
353
+ }, {}, {}>;
354
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
355
+ name: "created_at";
356
+ tableName: "cancellation_policy_rules";
357
+ dataType: "date";
358
+ columnType: "PgTimestamp";
359
+ data: Date;
360
+ driverParam: string;
361
+ notNull: true;
362
+ hasDefault: true;
363
+ isPrimaryKey: false;
364
+ isAutoincrement: false;
365
+ hasRuntimeDefault: false;
366
+ enumValues: undefined;
367
+ baseColumn: never;
368
+ identity: undefined;
369
+ generated: undefined;
370
+ }, {}, {}>;
371
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
372
+ name: "updated_at";
373
+ tableName: "cancellation_policy_rules";
374
+ dataType: "date";
375
+ columnType: "PgTimestamp";
376
+ data: Date;
377
+ driverParam: string;
378
+ notNull: true;
379
+ hasDefault: true;
380
+ isPrimaryKey: false;
381
+ isAutoincrement: false;
382
+ hasRuntimeDefault: false;
383
+ enumValues: undefined;
384
+ baseColumn: never;
385
+ identity: undefined;
386
+ generated: undefined;
387
+ }, {}, {}>;
388
+ };
389
+ dialect: "pg";
390
+ }>;
391
+ export type CancellationPolicy = typeof cancellationPolicies.$inferSelect;
392
+ export type NewCancellationPolicy = typeof cancellationPolicies.$inferInsert;
393
+ export type CancellationPolicyRule = typeof cancellationPolicyRules.$inferSelect;
394
+ export type NewCancellationPolicyRule = typeof cancellationPolicyRules.$inferInsert;
395
+ //# sourceMappingURL=schema-policies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-policies.d.ts","sourceRoot":"","sources":["../../src/pricing/schema-policies.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsBhC,CAAA;AAED,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BnC,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,oBAAoB,CAAC,YAAY,CAAA;AACzE,MAAM,MAAM,qBAAqB,GAAG,OAAO,oBAAoB,CAAC,YAAY,CAAA;AAC5E,MAAM,MAAM,sBAAsB,GAAG,OAAO,uBAAuB,CAAC,YAAY,CAAA;AAChF,MAAM,MAAM,yBAAyB,GAAG,OAAO,uBAAuB,CAAC,YAAY,CAAA"}
@@ -0,0 +1,41 @@
1
+ import { typeId, typeIdRef } from "@voyant-travel/db/lib/typeid-column";
2
+ import { boolean, index, integer, jsonb, pgTable, text, timestamp, uniqueIndex, } from "drizzle-orm/pg-core";
3
+ import { cancellationChargeTypeEnum, cancellationPolicyTypeEnum } from "./schema-shared.js";
4
+ export const cancellationPolicies = pgTable("cancellation_policies", {
5
+ id: typeId("cancellation_policies"),
6
+ code: text("code"),
7
+ name: text("name").notNull(),
8
+ policyType: cancellationPolicyTypeEnum("policy_type").notNull().default("custom"),
9
+ simpleCutoffHours: integer("simple_cutoff_hours"),
10
+ isDefault: boolean("is_default").notNull().default(false),
11
+ active: boolean("active").notNull().default(true),
12
+ notes: text("notes"),
13
+ metadata: jsonb("metadata").$type(),
14
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
15
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
16
+ }, (table) => [
17
+ index("idx_cancellation_policies_updated").on(table.updatedAt),
18
+ index("idx_cancellation_policies_type_updated").on(table.policyType, table.updatedAt),
19
+ index("idx_cancellation_policies_active_updated").on(table.active, table.updatedAt),
20
+ index("idx_cancellation_policies_default_updated").on(table.isDefault, table.updatedAt),
21
+ uniqueIndex("uidx_cancellation_policies_code").on(table.code),
22
+ ]);
23
+ export const cancellationPolicyRules = pgTable("cancellation_policy_rules", {
24
+ id: typeId("cancellation_policy_rules"),
25
+ cancellationPolicyId: typeIdRef("cancellation_policy_id")
26
+ .notNull()
27
+ .references(() => cancellationPolicies.id, { onDelete: "cascade" }),
28
+ sortOrder: integer("sort_order").notNull().default(0),
29
+ cutoffMinutesBefore: integer("cutoff_minutes_before"),
30
+ chargeType: cancellationChargeTypeEnum("charge_type").notNull().default("none"),
31
+ chargeAmountCents: integer("charge_amount_cents"),
32
+ chargePercentBasisPoints: integer("charge_percent_basis_points"),
33
+ active: boolean("active").notNull().default(true),
34
+ notes: text("notes"),
35
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
36
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
37
+ }, (table) => [
38
+ index("idx_cancellation_policy_rules_created").on(table.createdAt),
39
+ index("idx_cancellation_policy_rules_policy_sort_created").on(table.cancellationPolicyId, table.sortOrder, table.createdAt),
40
+ index("idx_cancellation_policy_rules_active_sort_created").on(table.active, table.sortOrder, table.createdAt),
41
+ ]);