@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,123 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import type { CancellationPolicyListQuery, CancellationPolicyRuleListQuery, CreateCancellationPolicyInput, CreateCancellationPolicyRuleInput, UpdateCancellationPolicyInput, UpdateCancellationPolicyRuleInput } from "./service-shared.js";
3
+ export declare function listCancellationPolicies(db: PostgresJsDatabase, query: CancellationPolicyListQuery): Promise<{
4
+ data: {
5
+ id: string;
6
+ code: string | null;
7
+ name: string;
8
+ policyType: "custom" | "simple" | "advanced" | "non_refundable";
9
+ simpleCutoffHours: number | null;
10
+ isDefault: boolean;
11
+ active: boolean;
12
+ notes: string | null;
13
+ metadata: Record<string, unknown> | null;
14
+ createdAt: Date;
15
+ updatedAt: Date;
16
+ }[];
17
+ total: number;
18
+ limit: number;
19
+ offset: number;
20
+ }>;
21
+ export declare function getCancellationPolicyById(db: PostgresJsDatabase, id: string): Promise<{
22
+ id: string;
23
+ code: string | null;
24
+ name: string;
25
+ policyType: "custom" | "simple" | "advanced" | "non_refundable";
26
+ simpleCutoffHours: number | null;
27
+ isDefault: boolean;
28
+ active: boolean;
29
+ notes: string | null;
30
+ metadata: Record<string, unknown> | null;
31
+ createdAt: Date;
32
+ updatedAt: Date;
33
+ } | null>;
34
+ export declare function createCancellationPolicy(db: PostgresJsDatabase, data: CreateCancellationPolicyInput): Promise<{
35
+ metadata: Record<string, unknown> | null;
36
+ id: string;
37
+ name: string;
38
+ createdAt: Date;
39
+ code: string | null;
40
+ notes: string | null;
41
+ updatedAt: Date;
42
+ active: boolean;
43
+ isDefault: boolean;
44
+ policyType: "custom" | "simple" | "advanced" | "non_refundable";
45
+ simpleCutoffHours: number | null;
46
+ } | null>;
47
+ export declare function updateCancellationPolicy(db: PostgresJsDatabase, id: string, data: UpdateCancellationPolicyInput): Promise<{
48
+ id: string;
49
+ code: string | null;
50
+ name: string;
51
+ policyType: "custom" | "simple" | "advanced" | "non_refundable";
52
+ simpleCutoffHours: number | null;
53
+ isDefault: boolean;
54
+ active: boolean;
55
+ notes: string | null;
56
+ metadata: Record<string, unknown> | null;
57
+ createdAt: Date;
58
+ updatedAt: Date;
59
+ } | null>;
60
+ export declare function deleteCancellationPolicy(db: PostgresJsDatabase, id: string): Promise<{
61
+ id: string;
62
+ } | null>;
63
+ export declare function listCancellationPolicyRules(db: PostgresJsDatabase, query: CancellationPolicyRuleListQuery): Promise<{
64
+ data: {
65
+ id: string;
66
+ cancellationPolicyId: string;
67
+ sortOrder: number;
68
+ cutoffMinutesBefore: number | null;
69
+ chargeType: "none" | "amount" | "percentage";
70
+ chargeAmountCents: number | null;
71
+ chargePercentBasisPoints: number | null;
72
+ active: boolean;
73
+ notes: string | null;
74
+ createdAt: Date;
75
+ updatedAt: Date;
76
+ }[];
77
+ total: number;
78
+ limit: number;
79
+ offset: number;
80
+ }>;
81
+ export declare function getCancellationPolicyRuleById(db: PostgresJsDatabase, id: string): Promise<{
82
+ id: string;
83
+ cancellationPolicyId: string;
84
+ sortOrder: number;
85
+ cutoffMinutesBefore: number | null;
86
+ chargeType: "none" | "amount" | "percentage";
87
+ chargeAmountCents: number | null;
88
+ chargePercentBasisPoints: number | null;
89
+ active: boolean;
90
+ notes: string | null;
91
+ createdAt: Date;
92
+ updatedAt: Date;
93
+ } | null>;
94
+ export declare function createCancellationPolicyRule(db: PostgresJsDatabase, data: CreateCancellationPolicyRuleInput): Promise<{
95
+ id: string;
96
+ createdAt: Date;
97
+ notes: string | null;
98
+ updatedAt: Date;
99
+ active: boolean;
100
+ sortOrder: number;
101
+ cancellationPolicyId: string;
102
+ cutoffMinutesBefore: number | null;
103
+ chargeType: "none" | "amount" | "percentage";
104
+ chargeAmountCents: number | null;
105
+ chargePercentBasisPoints: number | null;
106
+ } | null>;
107
+ export declare function updateCancellationPolicyRule(db: PostgresJsDatabase, id: string, data: UpdateCancellationPolicyRuleInput): Promise<{
108
+ id: string;
109
+ cancellationPolicyId: string;
110
+ sortOrder: number;
111
+ cutoffMinutesBefore: number | null;
112
+ chargeType: "none" | "amount" | "percentage";
113
+ chargeAmountCents: number | null;
114
+ chargePercentBasisPoints: number | null;
115
+ active: boolean;
116
+ notes: string | null;
117
+ createdAt: Date;
118
+ updatedAt: Date;
119
+ } | null>;
120
+ export declare function deleteCancellationPolicyRule(db: PostgresJsDatabase, id: string): Promise<{
121
+ id: string;
122
+ } | null>;
123
+ //# sourceMappingURL=service-policies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-policies.d.ts","sourceRoot":"","sources":["../../src/pricing/service-policies.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,KAAK,EACV,2BAA2B,EAC3B,+BAA+B,EAC/B,6BAA6B,EAC7B,iCAAiC,EACjC,6BAA6B,EAC7B,iCAAiC,EAClC,MAAM,qBAAqB,CAAA;AAG5B,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,2BAA2B;;;;;;;;;;;;;;;;;GA4BnC;AAED,wBAAsB,yBAAyB,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;UAOjF;AAED,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,kBAAkB,EACtB,IAAI,EAAE,6BAA6B;;;;;;;;;;;;UAIpC;AAED,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,6BAA6B;;;;;;;;;;;;UAQpC;AAED,wBAAsB,wBAAwB,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAMhF;AAED,wBAAsB,2BAA2B,CAC/C,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,+BAA+B;;;;;;;;;;;;;;;;;GAqBvC;AAED,wBAAsB,6BAA6B,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;UAOrF;AAED,wBAAsB,4BAA4B,CAChD,EAAE,EAAE,kBAAkB,EACtB,IAAI,EAAE,iCAAiC;;;;;;;;;;;;UAIxC;AAED,wBAAsB,4BAA4B,CAChD,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,iCAAiC;;;;;;;;;;;;UAQxC;AAED,wBAAsB,4BAA4B,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAMpF"}
@@ -0,0 +1,95 @@
1
+ import { and, asc, desc, eq, ilike, or, sql } from "drizzle-orm";
2
+ import { cancellationPolicies, cancellationPolicyRules } from "./schema.js";
3
+ import { paginate } from "./service-shared.js";
4
+ export async function listCancellationPolicies(db, query) {
5
+ const conditions = [];
6
+ if (query.policyType)
7
+ conditions.push(eq(cancellationPolicies.policyType, query.policyType));
8
+ if (query.active !== undefined)
9
+ conditions.push(eq(cancellationPolicies.active, query.active));
10
+ if (query.isDefault !== undefined) {
11
+ conditions.push(eq(cancellationPolicies.isDefault, query.isDefault));
12
+ }
13
+ if (query.search) {
14
+ const term = `%${query.search}%`;
15
+ conditions.push(or(ilike(cancellationPolicies.name, term), ilike(cancellationPolicies.code, term)));
16
+ }
17
+ const where = conditions.length ? and(...conditions) : undefined;
18
+ return paginate(db
19
+ .select()
20
+ .from(cancellationPolicies)
21
+ .where(where)
22
+ .limit(query.limit)
23
+ .offset(query.offset)
24
+ .orderBy(desc(cancellationPolicies.updatedAt)), db.select({ count: sql `count(*)::int` }).from(cancellationPolicies).where(where), query.limit, query.offset);
25
+ }
26
+ export async function getCancellationPolicyById(db, id) {
27
+ const [row] = await db
28
+ .select()
29
+ .from(cancellationPolicies)
30
+ .where(eq(cancellationPolicies.id, id))
31
+ .limit(1);
32
+ return row ?? null;
33
+ }
34
+ export async function createCancellationPolicy(db, data) {
35
+ const [row] = await db.insert(cancellationPolicies).values(data).returning();
36
+ return row ?? null;
37
+ }
38
+ export async function updateCancellationPolicy(db, id, data) {
39
+ const [row] = await db
40
+ .update(cancellationPolicies)
41
+ .set({ ...data, updatedAt: new Date() })
42
+ .where(eq(cancellationPolicies.id, id))
43
+ .returning();
44
+ return row ?? null;
45
+ }
46
+ export async function deleteCancellationPolicy(db, id) {
47
+ const [row] = await db
48
+ .delete(cancellationPolicies)
49
+ .where(eq(cancellationPolicies.id, id))
50
+ .returning({ id: cancellationPolicies.id });
51
+ return row ?? null;
52
+ }
53
+ export async function listCancellationPolicyRules(db, query) {
54
+ const conditions = [];
55
+ if (query.cancellationPolicyId) {
56
+ conditions.push(eq(cancellationPolicyRules.cancellationPolicyId, query.cancellationPolicyId));
57
+ }
58
+ if (query.active !== undefined)
59
+ conditions.push(eq(cancellationPolicyRules.active, query.active));
60
+ const where = conditions.length ? and(...conditions) : undefined;
61
+ return paginate(db
62
+ .select()
63
+ .from(cancellationPolicyRules)
64
+ .where(where)
65
+ .limit(query.limit)
66
+ .offset(query.offset)
67
+ .orderBy(asc(cancellationPolicyRules.sortOrder), asc(cancellationPolicyRules.createdAt)), db.select({ count: sql `count(*)::int` }).from(cancellationPolicyRules).where(where), query.limit, query.offset);
68
+ }
69
+ export async function getCancellationPolicyRuleById(db, id) {
70
+ const [row] = await db
71
+ .select()
72
+ .from(cancellationPolicyRules)
73
+ .where(eq(cancellationPolicyRules.id, id))
74
+ .limit(1);
75
+ return row ?? null;
76
+ }
77
+ export async function createCancellationPolicyRule(db, data) {
78
+ const [row] = await db.insert(cancellationPolicyRules).values(data).returning();
79
+ return row ?? null;
80
+ }
81
+ export async function updateCancellationPolicyRule(db, id, data) {
82
+ const [row] = await db
83
+ .update(cancellationPolicyRules)
84
+ .set({ ...data, updatedAt: new Date() })
85
+ .where(eq(cancellationPolicyRules.id, id))
86
+ .returning();
87
+ return row ?? null;
88
+ }
89
+ export async function deleteCancellationPolicyRule(db, id) {
90
+ const [row] = await db
91
+ .delete(cancellationPolicyRules)
92
+ .where(eq(cancellationPolicyRules.id, id))
93
+ .returning({ id: cancellationPolicyRules.id });
94
+ return row ?? null;
95
+ }
@@ -0,0 +1,89 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import type { PublicAvailabilitySnapshotQuery, PublicProductPricingQuery } from "./validation-public.js";
3
+ export declare const publicPricingService: {
4
+ getProductPricingSnapshot(db: PostgresJsDatabase, productId: string, query: PublicProductPricingQuery): Promise<{
5
+ productId: string;
6
+ catalog: {
7
+ currencyCode: string;
8
+ id: string;
9
+ code: string;
10
+ name: string;
11
+ };
12
+ options: {
13
+ id: string;
14
+ name: string;
15
+ description: string | null;
16
+ status: string;
17
+ isDefault: boolean;
18
+ bookingMode: string;
19
+ capacityMode: string;
20
+ pricingRules: {
21
+ id: string;
22
+ name: string;
23
+ description: string | null;
24
+ pricingMode: "on_request" | "per_person" | "per_booking" | "starting_from" | "free";
25
+ baseSellAmountCents: number | null;
26
+ minPerBooking: number | null;
27
+ maxPerBooking: number | null;
28
+ isDefault: boolean;
29
+ cancellationPolicyId: string | null;
30
+ unitPrices: {
31
+ id: string;
32
+ unitId: string;
33
+ unitName: string;
34
+ unitType: string;
35
+ pricingMode: "on_request" | "per_person" | "per_booking" | "free" | "per_unit" | "included";
36
+ sellAmountCents: number | null;
37
+ minQuantity: number | null;
38
+ maxQuantity: number | null;
39
+ pricingCategoryId: string | null;
40
+ sortOrder: number;
41
+ tiers: {
42
+ id: string;
43
+ minQuantity: number;
44
+ maxQuantity: number | null;
45
+ sellAmountCents: number | null;
46
+ sortOrder: number;
47
+ }[];
48
+ }[];
49
+ startTimeAdjustments: {
50
+ id: string;
51
+ startTimeId: string;
52
+ label: string | null;
53
+ startTimeLocal: string;
54
+ ruleMode: string;
55
+ adjustmentType: string | null;
56
+ sellAdjustmentCents: number | null;
57
+ adjustmentBasisPoints: number | null;
58
+ }[];
59
+ }[];
60
+ }[];
61
+ } | null>;
62
+ getAvailabilitySnapshot(db: PostgresJsDatabase, productId: string, query: PublicAvailabilitySnapshotQuery): Promise<{
63
+ productId: string;
64
+ slots: {
65
+ id: string;
66
+ optionId: string | null;
67
+ dateLocal: string | null;
68
+ startsAt: string | null;
69
+ endsAt: string | null;
70
+ timezone: string;
71
+ status: string;
72
+ unlimited: boolean;
73
+ remainingPax: number | null;
74
+ remainingResources: number | null;
75
+ pastCutoff: boolean;
76
+ tooEarly: boolean;
77
+ startTime: {
78
+ id: string;
79
+ label: string | null;
80
+ startTimeLocal: string;
81
+ durationMinutes: number | null;
82
+ } | null;
83
+ }[];
84
+ total: number;
85
+ limit: number;
86
+ offset: number;
87
+ } | null>;
88
+ };
89
+ //# sourceMappingURL=service-public.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-public.d.ts","sourceRoot":"","sources":["../../src/pricing/service-public.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAejE,OAAO,KAAK,EACV,+BAA+B,EAC/B,yBAAyB,EAC1B,MAAM,wBAAwB,CAAA;AAgV/B,eAAO,MAAM,oBAAoB;kCAEzB,kBAAkB,aACX,MAAM,SACV,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAyO5B,kBAAkB,aACX,MAAM,SACV,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;CAgGzC,CAAA"}