@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.d.ts","sourceRoot":"","sources":["../../src/sellability/schema.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,6BAA6B,oFAIxC,CAAA;AAEF,eAAO,MAAM,oCAAoC,2FAK/C,CAAA;AAEF,eAAO,MAAM,0BAA0B,4FAMrC,CAAA;AAEF,eAAO,MAAM,yBAAyB,mJASpC,CAAA;AAEF,eAAO,MAAM,iCAAiC,oFAK5C,CAAA;AAEF,eAAO,MAAM,yBAAyB,gGAMpC,CAAA;AAEF,eAAO,MAAM,8BAA8B,2FAKzC,CAAA;AAEF,eAAO,MAAM,8BAA8B,sHAQzC,CAAA;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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YAAY,CAAA;AAC1E,MAAM,MAAM,uBAAuB,GAAG,OAAO,wBAAwB,CAAC,YAAY,CAAA;AAClF,MAAM,MAAM,0BAA0B,GAAG,OAAO,wBAAwB,CAAC,YAAY,CAAA;AACrF,MAAM,MAAM,eAAe,GAAG,OAAO,gBAAgB,CAAC,YAAY,CAAA;AAClE,MAAM,MAAM,kBAAkB,GAAG,OAAO,gBAAgB,CAAC,YAAY,CAAA;AACrE,MAAM,MAAM,oBAAoB,GAAG,OAAO,qBAAqB,CAAC,YAAY,CAAA;AAC5E,MAAM,MAAM,uBAAuB,GAAG,OAAO,qBAAqB,CAAC,YAAY,CAAA;AAC/E,MAAM,MAAM,sBAAsB,GAAG,OAAO,uBAAuB,CAAC,YAAY,CAAA;AAChF,MAAM,MAAM,yBAAyB,GAAG,OAAO,uBAAuB,CAAC,YAAY,CAAA;AAEnF,eAAO,MAAM,6BAA6B;;;;;;EAMvC,CAAA;AAEH,eAAO,MAAM,iCAAiC;;EAK3C,CAAA;AAEH,eAAO,MAAM,4BAA4B;;EAEtC,CAAA;AAEH,eAAO,MAAM,iCAAiC;;;;EAa3C,CAAA;AAEH,eAAO,MAAM,yBAAyB;;EAKnC,CAAA;AAEH,eAAO,MAAM,8BAA8B;;EAKxC,CAAA;AAEH,eAAO,MAAM,gCAAgC;;;EAS1C,CAAA"}
@@ -0,0 +1,278 @@
1
+ import { typeId, typeIdRef } from "@voyant-travel/db/lib/typeid-column";
2
+ import { relations } from "drizzle-orm";
3
+ import { boolean, index, integer, jsonb, pgEnum, pgTable, text, timestamp, } from "drizzle-orm/pg-core";
4
+ export const sellabilitySnapshotStatusEnum = pgEnum("sellability_snapshot_status", [
5
+ "resolved",
6
+ "offer_constructed",
7
+ "expired",
8
+ ]);
9
+ export const sellabilitySnapshotComponentKindEnum = pgEnum("sellability_snapshot_component_kind", [
10
+ "base",
11
+ "unit",
12
+ "pickup",
13
+ "start_time_adjustment",
14
+ ]);
15
+ export const sellabilityPolicyScopeEnum = pgEnum("sellability_policy_scope", [
16
+ "global",
17
+ "product",
18
+ "option",
19
+ "market",
20
+ "channel",
21
+ ]);
22
+ export const sellabilityPolicyTypeEnum = pgEnum("sellability_policy_type", [
23
+ "capability",
24
+ "occupancy",
25
+ "pickup",
26
+ "question",
27
+ "allotment",
28
+ "availability_window",
29
+ "currency",
30
+ "custom",
31
+ ]);
32
+ export const sellabilityPolicyResultStatusEnum = pgEnum("sellability_policy_result_status", [
33
+ "passed",
34
+ "blocked",
35
+ "warning",
36
+ "adjusted",
37
+ ]);
38
+ export const offerRefreshRunStatusEnum = pgEnum("offer_refresh_run_status", [
39
+ "pending",
40
+ "running",
41
+ "completed",
42
+ "failed",
43
+ "expired",
44
+ ]);
45
+ export const offerExpirationEventStatusEnum = pgEnum("offer_expiration_event_status", [
46
+ "scheduled",
47
+ "expired",
48
+ "cancelled",
49
+ "superseded",
50
+ ]);
51
+ export const sellabilityExplanationTypeEnum = pgEnum("sellability_explanation_type", [
52
+ "sellable",
53
+ "blocked",
54
+ "warning",
55
+ "pricing",
56
+ "allotment",
57
+ "pickup",
58
+ "policy",
59
+ ]);
60
+ export const sellabilitySnapshots = pgTable("sellability_snapshots", {
61
+ id: typeId("sellability_snapshots"),
62
+ offerId: text("offer_id"),
63
+ marketId: text("market_id"),
64
+ channelId: text("channel_id"),
65
+ productId: text("product_id"),
66
+ optionId: text("option_id"),
67
+ slotId: text("slot_id"),
68
+ requestedCurrencyCode: text("requested_currency_code"),
69
+ sourceCurrencyCode: text("source_currency_code"),
70
+ fxRateSetId: text("fx_rate_set_id"),
71
+ status: sellabilitySnapshotStatusEnum("status").notNull().default("resolved"),
72
+ queryPayload: jsonb("query_payload").$type().notNull(),
73
+ pricingSummary: jsonb("pricing_summary").$type().notNull(),
74
+ expiresAt: timestamp("expires_at", { withTimezone: true }),
75
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
76
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
77
+ }, (table) => [
78
+ index("idx_sellability_snapshots_updated").on(table.updatedAt),
79
+ index("idx_sellability_snapshots_offer_updated").on(table.offerId, table.updatedAt),
80
+ index("idx_sellability_snapshots_market_updated").on(table.marketId, table.updatedAt),
81
+ index("idx_sellability_snapshots_channel_updated").on(table.channelId, table.updatedAt),
82
+ index("idx_sellability_snapshots_product_updated").on(table.productId, table.updatedAt),
83
+ index("idx_sellability_snapshots_option_updated").on(table.optionId, table.updatedAt),
84
+ index("idx_sellability_snapshots_slot_updated").on(table.slotId, table.updatedAt),
85
+ index("idx_sellability_snapshots_status_updated").on(table.status, table.updatedAt),
86
+ ]);
87
+ export const sellabilitySnapshotItems = pgTable("sellability_snapshot_items", {
88
+ id: typeId("sellability_snapshot_items"),
89
+ snapshotId: typeIdRef("snapshot_id")
90
+ .notNull()
91
+ .references(() => sellabilitySnapshots.id, { onDelete: "cascade" }),
92
+ candidateIndex: integer("candidate_index").notNull().default(0),
93
+ componentIndex: integer("component_index").notNull().default(0),
94
+ productId: text("product_id"),
95
+ optionId: text("option_id"),
96
+ slotId: text("slot_id"),
97
+ unitId: text("unit_id"),
98
+ requestRef: text("request_ref"),
99
+ componentKind: sellabilitySnapshotComponentKindEnum("component_kind").notNull(),
100
+ title: text("title").notNull(),
101
+ quantity: integer("quantity").notNull().default(1),
102
+ pricingMode: text("pricing_mode").notNull(),
103
+ pricingCategoryId: text("pricing_category_id"),
104
+ pricingCategoryName: text("pricing_category_name"),
105
+ unitName: text("unit_name"),
106
+ unitType: text("unit_type"),
107
+ currencyCode: text("currency_code").notNull(),
108
+ sellAmountCents: integer("sell_amount_cents").notNull().default(0),
109
+ costAmountCents: integer("cost_amount_cents").notNull().default(0),
110
+ sourceRuleId: text("source_rule_id"),
111
+ tierId: text("tier_id"),
112
+ isSelected: boolean("is_selected").notNull().default(true),
113
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
114
+ }, (table) => [
115
+ index("idx_sellability_snapshot_items_snapshot_order").on(table.snapshotId, table.candidateIndex, table.componentIndex),
116
+ index("idx_sellability_snapshot_items_product_order").on(table.productId, table.candidateIndex, table.componentIndex),
117
+ index("idx_sellability_snapshot_items_option_order").on(table.optionId, table.candidateIndex, table.componentIndex),
118
+ index("idx_sellability_snapshot_items_slot_order").on(table.slotId, table.candidateIndex, table.componentIndex),
119
+ index("idx_sellability_snapshot_items_unit_order").on(table.unitId, table.candidateIndex, table.componentIndex),
120
+ index("idx_sellability_snapshot_items_candidate").on(table.candidateIndex),
121
+ index("idx_sellability_snapshot_items_component").on(table.componentKind),
122
+ ]);
123
+ export const sellabilityPolicies = pgTable("sellability_policies", {
124
+ id: typeId("sellability_policies"),
125
+ name: text("name").notNull(),
126
+ scope: sellabilityPolicyScopeEnum("scope").notNull().default("global"),
127
+ policyType: sellabilityPolicyTypeEnum("policy_type").notNull().default("custom"),
128
+ productId: text("product_id"),
129
+ optionId: text("option_id"),
130
+ marketId: text("market_id"),
131
+ channelId: text("channel_id"),
132
+ priority: integer("priority").notNull().default(0),
133
+ active: boolean("active").notNull().default(true),
134
+ conditions: jsonb("conditions").$type().notNull().default({}),
135
+ effects: jsonb("effects").$type().notNull().default({}),
136
+ notes: text("notes"),
137
+ metadata: jsonb("metadata").$type(),
138
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
139
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
140
+ }, (table) => [
141
+ index("idx_sellability_policies_priority_name").on(table.priority, table.name),
142
+ index("idx_sellability_policies_scope_priority_name").on(table.scope, table.priority, table.name),
143
+ index("idx_sellability_policies_type_priority_name").on(table.policyType, table.priority, table.name),
144
+ index("idx_sellability_policies_product_priority_name").on(table.productId, table.priority, table.name),
145
+ index("idx_sellability_policies_option_priority_name").on(table.optionId, table.priority, table.name),
146
+ index("idx_sellability_policies_market_priority_name").on(table.marketId, table.priority, table.name),
147
+ index("idx_sellability_policies_channel_priority_name").on(table.channelId, table.priority, table.name),
148
+ index("idx_sellability_policies_active_priority_name").on(table.active, table.priority, table.name),
149
+ ]);
150
+ export const sellabilityPolicyResults = pgTable("sellability_policy_results", {
151
+ id: typeId("sellability_policy_results"),
152
+ snapshotId: typeIdRef("snapshot_id")
153
+ .notNull()
154
+ .references(() => sellabilitySnapshots.id, { onDelete: "cascade" }),
155
+ snapshotItemId: typeIdRef("snapshot_item_id").references(() => sellabilitySnapshotItems.id, {
156
+ onDelete: "set null",
157
+ }),
158
+ policyId: typeIdRef("policy_id").references(() => sellabilityPolicies.id, {
159
+ onDelete: "set null",
160
+ }),
161
+ candidateIndex: integer("candidate_index").notNull().default(0),
162
+ status: sellabilityPolicyResultStatusEnum("status").notNull().default("passed"),
163
+ message: text("message"),
164
+ details: jsonb("details").$type(),
165
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
166
+ }, (table) => [
167
+ index("idx_sellability_policy_results_snapshot_created").on(table.snapshotId, table.createdAt),
168
+ index("idx_sellability_policy_results_snapshot_item_created").on(table.snapshotItemId, table.createdAt),
169
+ index("idx_sellability_policy_results_policy_created").on(table.policyId, table.createdAt),
170
+ index("idx_sellability_policy_results_status_created").on(table.status, table.createdAt),
171
+ ]);
172
+ export const offerRefreshRuns = pgTable("offer_refresh_runs", {
173
+ id: typeId("offer_refresh_runs"),
174
+ offerId: text("offer_id").notNull(),
175
+ snapshotId: typeIdRef("snapshot_id").references(() => sellabilitySnapshots.id, {
176
+ onDelete: "set null",
177
+ }),
178
+ status: offerRefreshRunStatusEnum("status").notNull().default("pending"),
179
+ startedAt: timestamp("started_at", { withTimezone: true }).notNull().defaultNow(),
180
+ completedAt: timestamp("completed_at", { withTimezone: true }),
181
+ notes: text("notes"),
182
+ metadata: jsonb("metadata").$type(),
183
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
184
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
185
+ }, (table) => [
186
+ index("idx_offer_refresh_runs_offer_started").on(table.offerId, table.startedAt),
187
+ index("idx_offer_refresh_runs_snapshot_started").on(table.snapshotId, table.startedAt),
188
+ index("idx_offer_refresh_runs_status_started").on(table.status, table.startedAt),
189
+ ]);
190
+ export const offerExpirationEvents = pgTable("offer_expiration_events", {
191
+ id: typeId("offer_expiration_events"),
192
+ offerId: text("offer_id").notNull(),
193
+ snapshotId: typeIdRef("snapshot_id").references(() => sellabilitySnapshots.id, {
194
+ onDelete: "set null",
195
+ }),
196
+ expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
197
+ expiredAt: timestamp("expired_at", { withTimezone: true }),
198
+ status: offerExpirationEventStatusEnum("status").notNull().default("scheduled"),
199
+ reason: text("reason"),
200
+ metadata: jsonb("metadata").$type(),
201
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
202
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
203
+ }, (table) => [
204
+ index("idx_offer_expiration_events_offer_expires").on(table.offerId, table.expiresAt),
205
+ index("idx_offer_expiration_events_snapshot_expires").on(table.snapshotId, table.expiresAt),
206
+ index("idx_offer_expiration_events_status_expires").on(table.status, table.expiresAt),
207
+ ]);
208
+ export const sellabilityExplanations = pgTable("sellability_explanations", {
209
+ id: typeId("sellability_explanations"),
210
+ snapshotId: typeIdRef("snapshot_id")
211
+ .notNull()
212
+ .references(() => sellabilitySnapshots.id, { onDelete: "cascade" }),
213
+ snapshotItemId: typeIdRef("snapshot_item_id").references(() => sellabilitySnapshotItems.id, {
214
+ onDelete: "set null",
215
+ }),
216
+ candidateIndex: integer("candidate_index").notNull().default(0),
217
+ explanationType: sellabilityExplanationTypeEnum("explanation_type").notNull().default("policy"),
218
+ code: text("code"),
219
+ message: text("message").notNull(),
220
+ details: jsonb("details").$type(),
221
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
222
+ }, (table) => [
223
+ index("idx_sellability_explanations_snapshot_created").on(table.snapshotId, table.createdAt),
224
+ index("idx_sellability_explanations_snapshot_item_created").on(table.snapshotItemId, table.createdAt),
225
+ index("idx_sellability_explanations_type_created").on(table.explanationType, table.createdAt),
226
+ ]);
227
+ export const sellabilitySnapshotsRelations = relations(sellabilitySnapshots, ({ many }) => ({
228
+ items: many(sellabilitySnapshotItems),
229
+ policyResults: many(sellabilityPolicyResults),
230
+ explanations: many(sellabilityExplanations),
231
+ refreshRuns: many(offerRefreshRuns),
232
+ expirationEvents: many(offerExpirationEvents),
233
+ }));
234
+ export const sellabilitySnapshotItemsRelations = relations(sellabilitySnapshotItems, ({ one }) => ({
235
+ snapshot: one(sellabilitySnapshots, {
236
+ fields: [sellabilitySnapshotItems.snapshotId],
237
+ references: [sellabilitySnapshots.id],
238
+ }),
239
+ }));
240
+ export const sellabilityPoliciesRelations = relations(sellabilityPolicies, ({ many }) => ({
241
+ results: many(sellabilityPolicyResults),
242
+ }));
243
+ export const sellabilityPolicyResultsRelations = relations(sellabilityPolicyResults, ({ one }) => ({
244
+ snapshot: one(sellabilitySnapshots, {
245
+ fields: [sellabilityPolicyResults.snapshotId],
246
+ references: [sellabilitySnapshots.id],
247
+ }),
248
+ snapshotItem: one(sellabilitySnapshotItems, {
249
+ fields: [sellabilityPolicyResults.snapshotItemId],
250
+ references: [sellabilitySnapshotItems.id],
251
+ }),
252
+ policy: one(sellabilityPolicies, {
253
+ fields: [sellabilityPolicyResults.policyId],
254
+ references: [sellabilityPolicies.id],
255
+ }),
256
+ }));
257
+ export const offerRefreshRunsRelations = relations(offerRefreshRuns, ({ one }) => ({
258
+ snapshot: one(sellabilitySnapshots, {
259
+ fields: [offerRefreshRuns.snapshotId],
260
+ references: [sellabilitySnapshots.id],
261
+ }),
262
+ }));
263
+ export const offerExpirationEventsRelations = relations(offerExpirationEvents, ({ one }) => ({
264
+ snapshot: one(sellabilitySnapshots, {
265
+ fields: [offerExpirationEvents.snapshotId],
266
+ references: [sellabilitySnapshots.id],
267
+ }),
268
+ }));
269
+ export const sellabilityExplanationsRelations = relations(sellabilityExplanations, ({ one }) => ({
270
+ snapshot: one(sellabilitySnapshots, {
271
+ fields: [sellabilityExplanations.snapshotId],
272
+ references: [sellabilitySnapshots.id],
273
+ }),
274
+ snapshotItem: one(sellabilitySnapshotItems, {
275
+ fields: [sellabilityExplanations.snapshotItemId],
276
+ references: [sellabilitySnapshotItems.id],
277
+ }),
278
+ }));
@@ -0,0 +1,316 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import type { z } from "zod";
3
+ import type { insertOfferExpirationEventSchema, insertOfferRefreshRunSchema, insertSellabilityExplanationSchema, insertSellabilityPolicyResultSchema, insertSellabilityPolicySchema, offerExpirationEventListQuerySchema, offerRefreshRunListQuerySchema, sellabilityExplanationListQuerySchema, sellabilityPolicyListQuerySchema, sellabilityPolicyResultListQuerySchema, updateOfferExpirationEventSchema, updateOfferRefreshRunSchema, updateSellabilityExplanationSchema, updateSellabilityPolicyResultSchema, updateSellabilityPolicySchema } from "./validation.js";
4
+ type SellabilityPolicyListQuery = z.infer<typeof sellabilityPolicyListQuerySchema>;
5
+ type CreateSellabilityPolicyInput = z.infer<typeof insertSellabilityPolicySchema>;
6
+ type UpdateSellabilityPolicyInput = z.infer<typeof updateSellabilityPolicySchema>;
7
+ type SellabilityPolicyResultListQuery = z.infer<typeof sellabilityPolicyResultListQuerySchema>;
8
+ type CreateSellabilityPolicyResultInput = z.infer<typeof insertSellabilityPolicyResultSchema>;
9
+ type UpdateSellabilityPolicyResultInput = z.infer<typeof updateSellabilityPolicyResultSchema>;
10
+ type OfferRefreshRunListQuery = z.infer<typeof offerRefreshRunListQuerySchema>;
11
+ type CreateOfferRefreshRunInput = z.infer<typeof insertOfferRefreshRunSchema>;
12
+ type UpdateOfferRefreshRunInput = z.infer<typeof updateOfferRefreshRunSchema>;
13
+ type OfferExpirationEventListQuery = z.infer<typeof offerExpirationEventListQuerySchema>;
14
+ type CreateOfferExpirationEventInput = z.infer<typeof insertOfferExpirationEventSchema>;
15
+ type UpdateOfferExpirationEventInput = z.infer<typeof updateOfferExpirationEventSchema>;
16
+ type SellabilityExplanationListQuery = z.infer<typeof sellabilityExplanationListQuerySchema>;
17
+ type CreateSellabilityExplanationInput = z.infer<typeof insertSellabilityExplanationSchema>;
18
+ type UpdateSellabilityExplanationInput = z.infer<typeof updateSellabilityExplanationSchema>;
19
+ export declare function listPolicies(db: PostgresJsDatabase, query: SellabilityPolicyListQuery): Promise<{
20
+ data: {
21
+ id: string;
22
+ name: string;
23
+ scope: "channel" | "market" | "global" | "product" | "option";
24
+ policyType: "custom" | "currency" | "pickup" | "occupancy" | "capability" | "question" | "allotment" | "availability_window";
25
+ productId: string | null;
26
+ optionId: string | null;
27
+ marketId: string | null;
28
+ channelId: string | null;
29
+ priority: number;
30
+ active: boolean;
31
+ conditions: Record<string, unknown>;
32
+ effects: Record<string, unknown>;
33
+ notes: string | null;
34
+ metadata: Record<string, unknown> | null;
35
+ createdAt: Date;
36
+ updatedAt: Date;
37
+ }[];
38
+ total: number;
39
+ limit: number;
40
+ offset: number;
41
+ }>;
42
+ export declare function getPolicyById(db: PostgresJsDatabase, id: string): Promise<{
43
+ id: string;
44
+ name: string;
45
+ scope: "channel" | "market" | "global" | "product" | "option";
46
+ policyType: "custom" | "currency" | "pickup" | "occupancy" | "capability" | "question" | "allotment" | "availability_window";
47
+ productId: string | null;
48
+ optionId: string | null;
49
+ marketId: string | null;
50
+ channelId: string | null;
51
+ priority: number;
52
+ active: boolean;
53
+ conditions: Record<string, unknown>;
54
+ effects: Record<string, unknown>;
55
+ notes: string | null;
56
+ metadata: Record<string, unknown> | null;
57
+ createdAt: Date;
58
+ updatedAt: Date;
59
+ } | null>;
60
+ export declare function createPolicy(db: PostgresJsDatabase, data: CreateSellabilityPolicyInput): Promise<{
61
+ metadata: Record<string, unknown> | null;
62
+ id: string;
63
+ name: string;
64
+ createdAt: Date;
65
+ priority: number;
66
+ effects: Record<string, unknown>;
67
+ notes: string | null;
68
+ updatedAt: Date;
69
+ scope: "channel" | "market" | "global" | "product" | "option";
70
+ active: boolean;
71
+ marketId: string | null;
72
+ productId: string | null;
73
+ optionId: string | null;
74
+ channelId: string | null;
75
+ policyType: "custom" | "currency" | "pickup" | "occupancy" | "capability" | "question" | "allotment" | "availability_window";
76
+ conditions: Record<string, unknown>;
77
+ } | null>;
78
+ export declare function updatePolicy(db: PostgresJsDatabase, id: string, data: UpdateSellabilityPolicyInput): Promise<{
79
+ id: string;
80
+ name: string;
81
+ scope: "channel" | "market" | "global" | "product" | "option";
82
+ policyType: "custom" | "currency" | "pickup" | "occupancy" | "capability" | "question" | "allotment" | "availability_window";
83
+ productId: string | null;
84
+ optionId: string | null;
85
+ marketId: string | null;
86
+ channelId: string | null;
87
+ priority: number;
88
+ active: boolean;
89
+ conditions: Record<string, unknown>;
90
+ effects: Record<string, unknown>;
91
+ notes: string | null;
92
+ metadata: Record<string, unknown> | null;
93
+ createdAt: Date;
94
+ updatedAt: Date;
95
+ } | null>;
96
+ export declare function deletePolicy(db: PostgresJsDatabase, id: string): Promise<{
97
+ id: string;
98
+ } | null>;
99
+ export declare function listPolicyResults(db: PostgresJsDatabase, query: SellabilityPolicyResultListQuery): Promise<{
100
+ data: {
101
+ id: string;
102
+ snapshotId: string;
103
+ snapshotItemId: string | null;
104
+ policyId: string | null;
105
+ candidateIndex: number;
106
+ status: "warning" | "passed" | "blocked" | "adjusted";
107
+ message: string | null;
108
+ details: Record<string, unknown> | null;
109
+ createdAt: Date;
110
+ }[];
111
+ total: number;
112
+ limit: number;
113
+ offset: number;
114
+ }>;
115
+ export declare function getPolicyResultById(db: PostgresJsDatabase, id: string): Promise<{
116
+ id: string;
117
+ snapshotId: string;
118
+ snapshotItemId: string | null;
119
+ policyId: string | null;
120
+ candidateIndex: number;
121
+ status: "warning" | "passed" | "blocked" | "adjusted";
122
+ message: string | null;
123
+ details: Record<string, unknown> | null;
124
+ createdAt: Date;
125
+ } | null>;
126
+ export declare function createPolicyResult(db: PostgresJsDatabase, data: CreateSellabilityPolicyResultInput): Promise<{
127
+ id: string;
128
+ status: "warning" | "passed" | "blocked" | "adjusted";
129
+ createdAt: Date;
130
+ message: string | null;
131
+ details: Record<string, unknown> | null;
132
+ snapshotId: string;
133
+ candidateIndex: number;
134
+ snapshotItemId: string | null;
135
+ policyId: string | null;
136
+ } | null>;
137
+ export declare function updatePolicyResult(db: PostgresJsDatabase, id: string, data: UpdateSellabilityPolicyResultInput): Promise<{
138
+ id: string;
139
+ snapshotId: string;
140
+ snapshotItemId: string | null;
141
+ policyId: string | null;
142
+ candidateIndex: number;
143
+ status: "warning" | "passed" | "blocked" | "adjusted";
144
+ message: string | null;
145
+ details: Record<string, unknown> | null;
146
+ createdAt: Date;
147
+ } | null>;
148
+ export declare function deletePolicyResult(db: PostgresJsDatabase, id: string): Promise<{
149
+ id: string;
150
+ } | null>;
151
+ export declare function listOfferRefreshRuns(db: PostgresJsDatabase, query: OfferRefreshRunListQuery): Promise<{
152
+ data: {
153
+ id: string;
154
+ offerId: string;
155
+ snapshotId: string | null;
156
+ status: "failed" | "pending" | "running" | "completed" | "expired";
157
+ startedAt: Date;
158
+ completedAt: Date | null;
159
+ notes: string | null;
160
+ metadata: Record<string, unknown> | null;
161
+ createdAt: Date;
162
+ updatedAt: Date;
163
+ }[];
164
+ total: number;
165
+ limit: number;
166
+ offset: number;
167
+ }>;
168
+ export declare function getOfferRefreshRunById(db: PostgresJsDatabase, id: string): Promise<{
169
+ id: string;
170
+ offerId: string;
171
+ snapshotId: string | null;
172
+ status: "failed" | "pending" | "running" | "completed" | "expired";
173
+ startedAt: Date;
174
+ completedAt: Date | null;
175
+ notes: string | null;
176
+ metadata: Record<string, unknown> | null;
177
+ createdAt: Date;
178
+ updatedAt: Date;
179
+ } | null>;
180
+ export declare function createOfferRefreshRun(db: PostgresJsDatabase, data: CreateOfferRefreshRunInput): Promise<{
181
+ metadata: Record<string, unknown> | null;
182
+ id: string;
183
+ status: "failed" | "pending" | "running" | "completed" | "expired";
184
+ createdAt: Date;
185
+ startedAt: Date;
186
+ notes: string | null;
187
+ updatedAt: Date;
188
+ snapshotId: string | null;
189
+ offerId: string;
190
+ completedAt: Date | null;
191
+ } | null>;
192
+ export declare function updateOfferRefreshRun(db: PostgresJsDatabase, id: string, data: UpdateOfferRefreshRunInput): Promise<{
193
+ id: string;
194
+ offerId: string;
195
+ snapshotId: string | null;
196
+ status: "failed" | "pending" | "running" | "completed" | "expired";
197
+ startedAt: Date;
198
+ completedAt: Date | null;
199
+ notes: string | null;
200
+ metadata: Record<string, unknown> | null;
201
+ createdAt: Date;
202
+ updatedAt: Date;
203
+ } | null>;
204
+ export declare function deleteOfferRefreshRun(db: PostgresJsDatabase, id: string): Promise<{
205
+ id: string;
206
+ } | null>;
207
+ export declare function listOfferExpirationEvents(db: PostgresJsDatabase, query: OfferExpirationEventListQuery): Promise<{
208
+ data: {
209
+ id: string;
210
+ offerId: string;
211
+ snapshotId: string | null;
212
+ expiresAt: Date;
213
+ expiredAt: Date | null;
214
+ status: "cancelled" | "expired" | "scheduled" | "superseded";
215
+ reason: string | null;
216
+ metadata: Record<string, unknown> | null;
217
+ createdAt: Date;
218
+ updatedAt: Date;
219
+ }[];
220
+ total: number;
221
+ limit: number;
222
+ offset: number;
223
+ }>;
224
+ export declare function getOfferExpirationEventById(db: PostgresJsDatabase, id: string): Promise<{
225
+ id: string;
226
+ offerId: string;
227
+ snapshotId: string | null;
228
+ expiresAt: Date;
229
+ expiredAt: Date | null;
230
+ status: "cancelled" | "expired" | "scheduled" | "superseded";
231
+ reason: string | null;
232
+ metadata: Record<string, unknown> | null;
233
+ createdAt: Date;
234
+ updatedAt: Date;
235
+ } | null>;
236
+ export declare function createOfferExpirationEvent(db: PostgresJsDatabase, data: CreateOfferExpirationEventInput): Promise<{
237
+ metadata: Record<string, unknown> | null;
238
+ id: string;
239
+ status: "cancelled" | "expired" | "scheduled" | "superseded";
240
+ createdAt: Date;
241
+ updatedAt: Date;
242
+ expiresAt: Date;
243
+ snapshotId: string | null;
244
+ offerId: string;
245
+ reason: string | null;
246
+ expiredAt: Date | null;
247
+ } | null>;
248
+ export declare function updateOfferExpirationEvent(db: PostgresJsDatabase, id: string, data: UpdateOfferExpirationEventInput): Promise<{
249
+ id: string;
250
+ offerId: string;
251
+ snapshotId: string | null;
252
+ expiresAt: Date;
253
+ expiredAt: Date | null;
254
+ status: "cancelled" | "expired" | "scheduled" | "superseded";
255
+ reason: string | null;
256
+ metadata: Record<string, unknown> | null;
257
+ createdAt: Date;
258
+ updatedAt: Date;
259
+ } | null>;
260
+ export declare function deleteOfferExpirationEvent(db: PostgresJsDatabase, id: string): Promise<{
261
+ id: string;
262
+ } | null>;
263
+ export declare function listExplanations(db: PostgresJsDatabase, query: SellabilityExplanationListQuery): Promise<{
264
+ data: {
265
+ id: string;
266
+ snapshotId: string;
267
+ snapshotItemId: string | null;
268
+ candidateIndex: number;
269
+ explanationType: "warning" | "sellable" | "pickup" | "pricing" | "policy" | "allotment" | "blocked";
270
+ code: string | null;
271
+ message: string;
272
+ details: Record<string, unknown> | null;
273
+ createdAt: Date;
274
+ }[];
275
+ total: number;
276
+ limit: number;
277
+ offset: number;
278
+ }>;
279
+ export declare function getExplanationById(db: PostgresJsDatabase, id: string): Promise<{
280
+ id: string;
281
+ snapshotId: string;
282
+ snapshotItemId: string | null;
283
+ candidateIndex: number;
284
+ explanationType: "warning" | "sellable" | "pickup" | "pricing" | "policy" | "allotment" | "blocked";
285
+ code: string | null;
286
+ message: string;
287
+ details: Record<string, unknown> | null;
288
+ createdAt: Date;
289
+ } | null>;
290
+ export declare function createExplanation(db: PostgresJsDatabase, data: CreateSellabilityExplanationInput): Promise<{
291
+ id: string;
292
+ createdAt: Date;
293
+ code: string | null;
294
+ message: string;
295
+ details: Record<string, unknown> | null;
296
+ snapshotId: string;
297
+ candidateIndex: number;
298
+ snapshotItemId: string | null;
299
+ explanationType: "warning" | "sellable" | "pickup" | "pricing" | "policy" | "allotment" | "blocked";
300
+ } | null>;
301
+ export declare function updateExplanation(db: PostgresJsDatabase, id: string, data: UpdateSellabilityExplanationInput): Promise<{
302
+ id: string;
303
+ snapshotId: string;
304
+ snapshotItemId: string | null;
305
+ candidateIndex: number;
306
+ explanationType: "warning" | "sellable" | "pickup" | "pricing" | "policy" | "allotment" | "blocked";
307
+ code: string | null;
308
+ message: string;
309
+ details: Record<string, unknown> | null;
310
+ createdAt: Date;
311
+ } | null>;
312
+ export declare function deleteExplanation(db: PostgresJsDatabase, id: string): Promise<{
313
+ id: string;
314
+ } | null>;
315
+ export {};
316
+ //# sourceMappingURL=service-records.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-records.d.ts","sourceRoot":"","sources":["../../src/sellability/service-records.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAU5B,OAAO,KAAK,EACV,gCAAgC,EAChC,2BAA2B,EAC3B,kCAAkC,EAClC,mCAAmC,EACnC,6BAA6B,EAC7B,mCAAmC,EACnC,8BAA8B,EAC9B,qCAAqC,EACrC,gCAAgC,EAChC,sCAAsC,EACtC,gCAAgC,EAChC,2BAA2B,EAC3B,kCAAkC,EAClC,mCAAmC,EACnC,6BAA6B,EAC9B,MAAM,iBAAiB,CAAA;AAExB,KAAK,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AAClF,KAAK,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AACjF,KAAK,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AACjF,KAAK,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sCAAsC,CAAC,CAAA;AAC9F,KAAK,kCAAkC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAA;AAC7F,KAAK,kCAAkC,GAAG,C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