@voyantjs/pricing 0.2.0 → 0.3.1

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 (73) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +5 -0
  4. package/dist/routes-core.d.ts +981 -0
  5. package/dist/routes-core.d.ts.map +1 -0
  6. package/dist/routes-core.js +101 -0
  7. package/dist/routes-public.d.ts +136 -0
  8. package/dist/routes-public.d.ts.map +1 -0
  9. package/dist/routes-public.js +13 -0
  10. package/dist/routes-rules.d.ts +1176 -0
  11. package/dist/routes-rules.d.ts.map +1 -0
  12. package/dist/routes-rules.js +117 -0
  13. package/dist/routes-shared.d.ts +12 -0
  14. package/dist/routes-shared.d.ts.map +1 -0
  15. package/dist/routes-shared.js +3 -0
  16. package/dist/routes.d.ts +5 -2160
  17. package/dist/routes.d.ts.map +1 -1
  18. package/dist/routes.js +5 -354
  19. package/dist/schema-catalogs.d.ts +467 -0
  20. package/dist/schema-catalogs.d.ts.map +1 -0
  21. package/dist/schema-catalogs.js +44 -0
  22. package/dist/schema-categories.d.ts +497 -0
  23. package/dist/schema-categories.d.ts.map +1 -0
  24. package/dist/schema-categories.js +50 -0
  25. package/dist/schema-option-rules.d.ts +1770 -0
  26. package/dist/schema-option-rules.d.ts.map +1 -0
  27. package/dist/schema-option-rules.js +174 -0
  28. package/dist/schema-policies.d.ts +395 -0
  29. package/dist/schema-policies.d.ts.map +1 -0
  30. package/dist/schema-policies.js +38 -0
  31. package/dist/schema-relations.d.ts +55 -0
  32. package/dist/schema-relations.d.ts.map +1 -0
  33. package/dist/schema-relations.js +103 -0
  34. package/dist/schema-shared.d.ts +11 -0
  35. package/dist/schema-shared.d.ts.map +1 -0
  36. package/dist/schema-shared.js +67 -0
  37. package/dist/schema.d.ts +6 -3189
  38. package/dist/schema.d.ts.map +1 -1
  39. package/dist/schema.js +6 -458
  40. package/dist/service-catalogs.d.ts +139 -0
  41. package/dist/service-catalogs.d.ts.map +1 -0
  42. package/dist/service-catalogs.js +89 -0
  43. package/dist/service-categories.d.ts +147 -0
  44. package/dist/service-categories.d.ts.map +1 -0
  45. package/dist/service-categories.js +105 -0
  46. package/dist/service-option-rules.d.ts +307 -0
  47. package/dist/service-option-rules.d.ts.map +1 -0
  48. package/dist/service-option-rules.js +188 -0
  49. package/dist/service-policies.d.ts +123 -0
  50. package/dist/service-policies.d.ts.map +1 -0
  51. package/dist/service-policies.js +95 -0
  52. package/dist/service-public.d.ts +89 -0
  53. package/dist/service-public.d.ts.map +1 -0
  54. package/dist/service-public.js +355 -0
  55. package/dist/service-shared.d.ts +50 -0
  56. package/dist/service-shared.d.ts.map +1 -0
  57. package/dist/service-shared.js +4 -0
  58. package/dist/service-transfer-rules.d.ts +211 -0
  59. package/dist/service-transfer-rules.d.ts.map +1 -0
  60. package/dist/service-transfer-rules.js +139 -0
  61. package/dist/service.d.ts +70 -955
  62. package/dist/service.d.ts.map +1 -1
  63. package/dist/service.js +70 -595
  64. package/dist/validation-public.d.ts +410 -0
  65. package/dist/validation-public.d.ts.map +1 -0
  66. package/dist/validation-public.js +109 -0
  67. package/dist/validation-shared.d.ts +71 -0
  68. package/dist/validation-shared.d.ts.map +1 -0
  69. package/dist/validation-shared.js +63 -0
  70. package/dist/validation.d.ts +4 -69
  71. package/dist/validation.d.ts.map +1 -1
  72. package/dist/validation.js +5 -62
  73. package/package.json +16 -8
@@ -0,0 +1,188 @@
1
+ import { and, asc, desc, eq, sql } from "drizzle-orm";
2
+ import { optionPriceRules, optionStartTimeRules, optionUnitPriceRules, optionUnitTiers, } from "./schema.js";
3
+ import { paginate } from "./service-shared.js";
4
+ export async function listOptionPriceRules(db, query) {
5
+ const conditions = [];
6
+ if (query.productId)
7
+ conditions.push(eq(optionPriceRules.productId, query.productId));
8
+ if (query.optionId)
9
+ conditions.push(eq(optionPriceRules.optionId, query.optionId));
10
+ if (query.priceCatalogId)
11
+ conditions.push(eq(optionPriceRules.priceCatalogId, query.priceCatalogId));
12
+ if (query.priceScheduleId)
13
+ conditions.push(eq(optionPriceRules.priceScheduleId, query.priceScheduleId));
14
+ if (query.cancellationPolicyId) {
15
+ conditions.push(eq(optionPriceRules.cancellationPolicyId, query.cancellationPolicyId));
16
+ }
17
+ if (query.pricingMode)
18
+ conditions.push(eq(optionPriceRules.pricingMode, query.pricingMode));
19
+ if (query.active !== undefined)
20
+ conditions.push(eq(optionPriceRules.active, query.active));
21
+ const where = conditions.length ? and(...conditions) : undefined;
22
+ return paginate(db
23
+ .select()
24
+ .from(optionPriceRules)
25
+ .where(where)
26
+ .limit(query.limit)
27
+ .offset(query.offset)
28
+ .orderBy(desc(optionPriceRules.updatedAt)), db.select({ count: sql `count(*)::int` }).from(optionPriceRules).where(where), query.limit, query.offset);
29
+ }
30
+ export async function getOptionPriceRuleById(db, id) {
31
+ const [row] = await db.select().from(optionPriceRules).where(eq(optionPriceRules.id, id)).limit(1);
32
+ return row ?? null;
33
+ }
34
+ export async function createOptionPriceRule(db, data) {
35
+ const [row] = await db.insert(optionPriceRules).values(data).returning();
36
+ return row ?? null;
37
+ }
38
+ export async function updateOptionPriceRule(db, id, data) {
39
+ const [row] = await db
40
+ .update(optionPriceRules)
41
+ .set({ ...data, updatedAt: new Date() })
42
+ .where(eq(optionPriceRules.id, id))
43
+ .returning();
44
+ return row ?? null;
45
+ }
46
+ export async function deleteOptionPriceRule(db, id) {
47
+ const [row] = await db
48
+ .delete(optionPriceRules)
49
+ .where(eq(optionPriceRules.id, id))
50
+ .returning({ id: optionPriceRules.id });
51
+ return row ?? null;
52
+ }
53
+ export async function listOptionUnitPriceRules(db, query) {
54
+ const conditions = [];
55
+ if (query.optionPriceRuleId) {
56
+ conditions.push(eq(optionUnitPriceRules.optionPriceRuleId, query.optionPriceRuleId));
57
+ }
58
+ if (query.optionId)
59
+ conditions.push(eq(optionUnitPriceRules.optionId, query.optionId));
60
+ if (query.unitId)
61
+ conditions.push(eq(optionUnitPriceRules.unitId, query.unitId));
62
+ if (query.pricingCategoryId) {
63
+ conditions.push(eq(optionUnitPriceRules.pricingCategoryId, query.pricingCategoryId));
64
+ }
65
+ if (query.active !== undefined)
66
+ conditions.push(eq(optionUnitPriceRules.active, query.active));
67
+ const where = conditions.length ? and(...conditions) : undefined;
68
+ return paginate(db
69
+ .select()
70
+ .from(optionUnitPriceRules)
71
+ .where(where)
72
+ .limit(query.limit)
73
+ .offset(query.offset)
74
+ .orderBy(asc(optionUnitPriceRules.sortOrder), asc(optionUnitPriceRules.createdAt)), db.select({ count: sql `count(*)::int` }).from(optionUnitPriceRules).where(where), query.limit, query.offset);
75
+ }
76
+ export async function getOptionUnitPriceRuleById(db, id) {
77
+ const [row] = await db
78
+ .select()
79
+ .from(optionUnitPriceRules)
80
+ .where(eq(optionUnitPriceRules.id, id))
81
+ .limit(1);
82
+ return row ?? null;
83
+ }
84
+ export async function createOptionUnitPriceRule(db, data) {
85
+ const [row] = await db.insert(optionUnitPriceRules).values(data).returning();
86
+ return row ?? null;
87
+ }
88
+ export async function updateOptionUnitPriceRule(db, id, data) {
89
+ const [row] = await db
90
+ .update(optionUnitPriceRules)
91
+ .set({ ...data, updatedAt: new Date() })
92
+ .where(eq(optionUnitPriceRules.id, id))
93
+ .returning();
94
+ return row ?? null;
95
+ }
96
+ export async function deleteOptionUnitPriceRule(db, id) {
97
+ const [row] = await db
98
+ .delete(optionUnitPriceRules)
99
+ .where(eq(optionUnitPriceRules.id, id))
100
+ .returning({ id: optionUnitPriceRules.id });
101
+ return row ?? null;
102
+ }
103
+ export async function listOptionStartTimeRules(db, query) {
104
+ const conditions = [];
105
+ if (query.optionPriceRuleId) {
106
+ conditions.push(eq(optionStartTimeRules.optionPriceRuleId, query.optionPriceRuleId));
107
+ }
108
+ if (query.optionId)
109
+ conditions.push(eq(optionStartTimeRules.optionId, query.optionId));
110
+ if (query.startTimeId)
111
+ conditions.push(eq(optionStartTimeRules.startTimeId, query.startTimeId));
112
+ if (query.active !== undefined)
113
+ conditions.push(eq(optionStartTimeRules.active, query.active));
114
+ const where = conditions.length ? and(...conditions) : undefined;
115
+ return paginate(db
116
+ .select()
117
+ .from(optionStartTimeRules)
118
+ .where(where)
119
+ .limit(query.limit)
120
+ .offset(query.offset)
121
+ .orderBy(asc(optionStartTimeRules.createdAt)), db.select({ count: sql `count(*)::int` }).from(optionStartTimeRules).where(where), query.limit, query.offset);
122
+ }
123
+ export async function getOptionStartTimeRuleById(db, id) {
124
+ const [row] = await db
125
+ .select()
126
+ .from(optionStartTimeRules)
127
+ .where(eq(optionStartTimeRules.id, id))
128
+ .limit(1);
129
+ return row ?? null;
130
+ }
131
+ export async function createOptionStartTimeRule(db, data) {
132
+ const [row] = await db.insert(optionStartTimeRules).values(data).returning();
133
+ return row ?? null;
134
+ }
135
+ export async function updateOptionStartTimeRule(db, id, data) {
136
+ const [row] = await db
137
+ .update(optionStartTimeRules)
138
+ .set({ ...data, updatedAt: new Date() })
139
+ .where(eq(optionStartTimeRules.id, id))
140
+ .returning();
141
+ return row ?? null;
142
+ }
143
+ export async function deleteOptionStartTimeRule(db, id) {
144
+ const [row] = await db
145
+ .delete(optionStartTimeRules)
146
+ .where(eq(optionStartTimeRules.id, id))
147
+ .returning({ id: optionStartTimeRules.id });
148
+ return row ?? null;
149
+ }
150
+ export async function listOptionUnitTiers(db, query) {
151
+ const conditions = [];
152
+ if (query.optionUnitPriceRuleId) {
153
+ conditions.push(eq(optionUnitTiers.optionUnitPriceRuleId, query.optionUnitPriceRuleId));
154
+ }
155
+ if (query.active !== undefined)
156
+ conditions.push(eq(optionUnitTiers.active, query.active));
157
+ const where = conditions.length ? and(...conditions) : undefined;
158
+ return paginate(db
159
+ .select()
160
+ .from(optionUnitTiers)
161
+ .where(where)
162
+ .limit(query.limit)
163
+ .offset(query.offset)
164
+ .orderBy(asc(optionUnitTiers.sortOrder), asc(optionUnitTiers.minQuantity)), db.select({ count: sql `count(*)::int` }).from(optionUnitTiers).where(where), query.limit, query.offset);
165
+ }
166
+ export async function getOptionUnitTierById(db, id) {
167
+ const [row] = await db.select().from(optionUnitTiers).where(eq(optionUnitTiers.id, id)).limit(1);
168
+ return row ?? null;
169
+ }
170
+ export async function createOptionUnitTier(db, data) {
171
+ const [row] = await db.insert(optionUnitTiers).values(data).returning();
172
+ return row ?? null;
173
+ }
174
+ export async function updateOptionUnitTier(db, id, data) {
175
+ const [row] = await db
176
+ .update(optionUnitTiers)
177
+ .set({ ...data, updatedAt: new Date() })
178
+ .where(eq(optionUnitTiers.id, id))
179
+ .returning();
180
+ return row ?? null;
181
+ }
182
+ export async function deleteOptionUnitTier(db, id) {
183
+ const [row] = await db
184
+ .delete(optionUnitTiers)
185
+ .where(eq(optionUnitTiers.id, id))
186
+ .returning({ id: optionUnitTiers.id });
187
+ return row ?? null;
188
+ }
@@ -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: "simple" | "advanced" | "non_refundable" | "custom";
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: "simple" | "advanced" | "non_refundable" | "custom";
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
+ id: string;
36
+ name: string;
37
+ code: string | null;
38
+ isDefault: boolean;
39
+ active: boolean;
40
+ notes: string | null;
41
+ metadata: Record<string, unknown> | null;
42
+ createdAt: Date;
43
+ updatedAt: Date;
44
+ policyType: "simple" | "advanced" | "non_refundable" | "custom";
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: "simple" | "advanced" | "non_refundable" | "custom";
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
+ active: boolean;
97
+ notes: string | null;
98
+ createdAt: Date;
99
+ updatedAt: Date;
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/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 | null;
8
+ id: string;
9
+ code: string;
10
+ name: string;
11
+ };
12
+ options: {
13
+ id: string;
14
+ name: string;
15
+ description: string | null;
16
+ status: "active" | "draft" | "archived";
17
+ isDefault: boolean;
18
+ bookingMode: "other" | "date" | "open" | "date_time" | "stay" | "transfer" | "itinerary";
19
+ capacityMode: "on_request" | "free_sale" | "limited";
20
+ pricingRules: {
21
+ id: string;
22
+ name: string;
23
+ description: string | null;
24
+ pricingMode: "per_person" | "per_booking" | "starting_from" | "free" | "on_request";
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: "group" | "room" | "vehicle" | "service" | "other" | "person";
35
+ pricingMode: "per_person" | "per_booking" | "free" | "on_request" | "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: "included" | "excluded" | "override" | "adjustment";
55
+ adjustmentType: "fixed" | "percentage" | 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: "open" | "closed" | "sold_out" | "cancelled";
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/service-public.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AASjE,OAAO,KAAK,EACV,+BAA+B,EAC/B,yBAAyB,EAC1B,MAAM,wBAAwB,CAAA;AAuE/B,eAAO,MAAM,oBAAoB;kCAEzB,kBAAkB,aACX,MAAM,SACV,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA0R5B,kBAAkB,aACX,MAAM,SACV,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;CAgGzC,CAAA"}