@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 @@
1
+ {"version":3,"file":"routes-core.d.ts","sourceRoot":"","sources":["../src/routes-core.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,GAAG,EAAY,MAAM,oBAAoB,CAAA;AAuBvD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BA2N1B,CAAA"}
@@ -0,0 +1,101 @@
1
+ import { Hono } from "hono";
2
+ import { notFound } from "./routes-shared.js";
3
+ import { pricingService } from "./service.js";
4
+ import { cancellationPolicyListQuerySchema, cancellationPolicyRuleListQuerySchema, insertCancellationPolicyRuleSchema, insertCancellationPolicySchema, insertPriceCatalogSchema, insertPriceScheduleSchema, insertPricingCategoryDependencySchema, insertPricingCategorySchema, priceCatalogListQuerySchema, priceScheduleListQuerySchema, pricingCategoryDependencyListQuerySchema, pricingCategoryListQuerySchema, updateCancellationPolicyRuleSchema, updateCancellationPolicySchema, updatePriceCatalogSchema, updatePriceScheduleSchema, updatePricingCategoryDependencySchema, updatePricingCategorySchema, } from "./validation.js";
5
+ export const pricingCoreRoutes = new Hono()
6
+ .get("/pricing-categories", async (c) => c.json(await pricingService.listPricingCategories(c.get("db"), pricingCategoryListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams)))))
7
+ .post("/pricing-categories", async (c) => c.json({
8
+ data: await pricingService.createPricingCategory(c.get("db"), insertPricingCategorySchema.parse(await c.req.json())),
9
+ }, 201))
10
+ .get("/pricing-categories/:id", async (c) => {
11
+ const row = await pricingService.getPricingCategoryById(c.get("db"), c.req.param("id"));
12
+ return row ? c.json({ data: row }) : notFound(c, "Pricing category not found");
13
+ })
14
+ .patch("/pricing-categories/:id", async (c) => {
15
+ const row = await pricingService.updatePricingCategory(c.get("db"), c.req.param("id"), updatePricingCategorySchema.parse(await c.req.json()));
16
+ return row ? c.json({ data: row }) : notFound(c, "Pricing category not found");
17
+ })
18
+ .delete("/pricing-categories/:id", async (c) => {
19
+ const row = await pricingService.deletePricingCategory(c.get("db"), c.req.param("id"));
20
+ return row ? c.json({ success: true }) : notFound(c, "Pricing category not found");
21
+ })
22
+ .get("/pricing-category-dependencies", async (c) => c.json(await pricingService.listPricingCategoryDependencies(c.get("db"), pricingCategoryDependencyListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams)))))
23
+ .post("/pricing-category-dependencies", async (c) => c.json({
24
+ data: await pricingService.createPricingCategoryDependency(c.get("db"), insertPricingCategoryDependencySchema.parse(await c.req.json())),
25
+ }, 201))
26
+ .get("/pricing-category-dependencies/:id", async (c) => {
27
+ const row = await pricingService.getPricingCategoryDependencyById(c.get("db"), c.req.param("id"));
28
+ return row ? c.json({ data: row }) : notFound(c, "Pricing category dependency not found");
29
+ })
30
+ .patch("/pricing-category-dependencies/:id", async (c) => {
31
+ const row = await pricingService.updatePricingCategoryDependency(c.get("db"), c.req.param("id"), updatePricingCategoryDependencySchema.parse(await c.req.json()));
32
+ return row ? c.json({ data: row }) : notFound(c, "Pricing category dependency not found");
33
+ })
34
+ .delete("/pricing-category-dependencies/:id", async (c) => {
35
+ const row = await pricingService.deletePricingCategoryDependency(c.get("db"), c.req.param("id"));
36
+ return row ? c.json({ success: true }) : notFound(c, "Pricing category dependency not found");
37
+ })
38
+ .get("/cancellation-policies", async (c) => c.json(await pricingService.listCancellationPolicies(c.get("db"), cancellationPolicyListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams)))))
39
+ .post("/cancellation-policies", async (c) => c.json({
40
+ data: await pricingService.createCancellationPolicy(c.get("db"), insertCancellationPolicySchema.parse(await c.req.json())),
41
+ }, 201))
42
+ .get("/cancellation-policies/:id", async (c) => {
43
+ const row = await pricingService.getCancellationPolicyById(c.get("db"), c.req.param("id"));
44
+ return row ? c.json({ data: row }) : notFound(c, "Cancellation policy not found");
45
+ })
46
+ .patch("/cancellation-policies/:id", async (c) => {
47
+ const row = await pricingService.updateCancellationPolicy(c.get("db"), c.req.param("id"), updateCancellationPolicySchema.parse(await c.req.json()));
48
+ return row ? c.json({ data: row }) : notFound(c, "Cancellation policy not found");
49
+ })
50
+ .delete("/cancellation-policies/:id", async (c) => {
51
+ const row = await pricingService.deleteCancellationPolicy(c.get("db"), c.req.param("id"));
52
+ return row ? c.json({ success: true }) : notFound(c, "Cancellation policy not found");
53
+ })
54
+ .get("/cancellation-policy-rules", async (c) => c.json(await pricingService.listCancellationPolicyRules(c.get("db"), cancellationPolicyRuleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams)))))
55
+ .post("/cancellation-policy-rules", async (c) => c.json({
56
+ data: await pricingService.createCancellationPolicyRule(c.get("db"), insertCancellationPolicyRuleSchema.parse(await c.req.json())),
57
+ }, 201))
58
+ .get("/cancellation-policy-rules/:id", async (c) => {
59
+ const row = await pricingService.getCancellationPolicyRuleById(c.get("db"), c.req.param("id"));
60
+ return row ? c.json({ data: row }) : notFound(c, "Cancellation policy rule not found");
61
+ })
62
+ .patch("/cancellation-policy-rules/:id", async (c) => {
63
+ const row = await pricingService.updateCancellationPolicyRule(c.get("db"), c.req.param("id"), updateCancellationPolicyRuleSchema.parse(await c.req.json()));
64
+ return row ? c.json({ data: row }) : notFound(c, "Cancellation policy rule not found");
65
+ })
66
+ .delete("/cancellation-policy-rules/:id", async (c) => {
67
+ const row = await pricingService.deleteCancellationPolicyRule(c.get("db"), c.req.param("id"));
68
+ return row ? c.json({ success: true }) : notFound(c, "Cancellation policy rule not found");
69
+ })
70
+ .get("/price-catalogs", async (c) => c.json(await pricingService.listPriceCatalogs(c.get("db"), priceCatalogListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams)))))
71
+ .post("/price-catalogs", async (c) => c.json({
72
+ data: await pricingService.createPriceCatalog(c.get("db"), insertPriceCatalogSchema.parse(await c.req.json())),
73
+ }, 201))
74
+ .get("/price-catalogs/:id", async (c) => {
75
+ const row = await pricingService.getPriceCatalogById(c.get("db"), c.req.param("id"));
76
+ return row ? c.json({ data: row }) : notFound(c, "Price catalog not found");
77
+ })
78
+ .patch("/price-catalogs/:id", async (c) => {
79
+ const row = await pricingService.updatePriceCatalog(c.get("db"), c.req.param("id"), updatePriceCatalogSchema.parse(await c.req.json()));
80
+ return row ? c.json({ data: row }) : notFound(c, "Price catalog not found");
81
+ })
82
+ .delete("/price-catalogs/:id", async (c) => {
83
+ const row = await pricingService.deletePriceCatalog(c.get("db"), c.req.param("id"));
84
+ return row ? c.json({ success: true }) : notFound(c, "Price catalog not found");
85
+ })
86
+ .get("/price-schedules", async (c) => c.json(await pricingService.listPriceSchedules(c.get("db"), priceScheduleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams)))))
87
+ .post("/price-schedules", async (c) => c.json({
88
+ data: await pricingService.createPriceSchedule(c.get("db"), insertPriceScheduleSchema.parse(await c.req.json())),
89
+ }, 201))
90
+ .get("/price-schedules/:id", async (c) => {
91
+ const row = await pricingService.getPriceScheduleById(c.get("db"), c.req.param("id"));
92
+ return row ? c.json({ data: row }) : notFound(c, "Price schedule not found");
93
+ })
94
+ .patch("/price-schedules/:id", async (c) => {
95
+ const row = await pricingService.updatePriceSchedule(c.get("db"), c.req.param("id"), updatePriceScheduleSchema.parse(await c.req.json()));
96
+ return row ? c.json({ data: row }) : notFound(c, "Price schedule not found");
97
+ })
98
+ .delete("/price-schedules/:id", async (c) => {
99
+ const row = await pricingService.deletePriceSchedule(c.get("db"), c.req.param("id"));
100
+ return row ? c.json({ success: true }) : notFound(c, "Price schedule not found");
101
+ });
@@ -0,0 +1,136 @@
1
+ import { type Env } from "./routes-shared.js";
2
+ export declare const publicPricingRoutes: import("hono/hono-base").HonoBase<Env, {
3
+ "/products/:productId/pricing": {
4
+ $get: {
5
+ input: {
6
+ param: {
7
+ productId: string;
8
+ };
9
+ };
10
+ output: {
11
+ error: string;
12
+ };
13
+ outputFormat: "json";
14
+ status: 404;
15
+ } | {
16
+ input: {
17
+ param: {
18
+ productId: string;
19
+ };
20
+ };
21
+ output: {
22
+ data: {
23
+ productId: string;
24
+ catalog: {
25
+ currencyCode: string | null;
26
+ id: string;
27
+ code: string;
28
+ name: string;
29
+ };
30
+ options: {
31
+ id: string;
32
+ name: string;
33
+ description: string | null;
34
+ status: "active" | "draft" | "archived";
35
+ isDefault: boolean;
36
+ bookingMode: "other" | "date" | "open" | "date_time" | "stay" | "transfer" | "itinerary";
37
+ capacityMode: "on_request" | "free_sale" | "limited";
38
+ pricingRules: {
39
+ id: string;
40
+ name: string;
41
+ description: string | null;
42
+ pricingMode: "per_person" | "per_booking" | "starting_from" | "free" | "on_request";
43
+ baseSellAmountCents: number | null;
44
+ minPerBooking: number | null;
45
+ maxPerBooking: number | null;
46
+ isDefault: boolean;
47
+ cancellationPolicyId: string | null;
48
+ unitPrices: {
49
+ id: string;
50
+ unitId: string;
51
+ unitName: string;
52
+ unitType: "group" | "room" | "vehicle" | "service" | "other" | "person";
53
+ pricingMode: "per_person" | "per_booking" | "free" | "on_request" | "per_unit" | "included";
54
+ sellAmountCents: number | null;
55
+ minQuantity: number | null;
56
+ maxQuantity: number | null;
57
+ pricingCategoryId: string | null;
58
+ sortOrder: number;
59
+ tiers: {
60
+ id: string;
61
+ minQuantity: number;
62
+ maxQuantity: number | null;
63
+ sellAmountCents: number | null;
64
+ sortOrder: number;
65
+ }[];
66
+ }[];
67
+ startTimeAdjustments: {
68
+ id: string;
69
+ startTimeId: string;
70
+ label: string | null;
71
+ startTimeLocal: string;
72
+ ruleMode: "included" | "excluded" | "override" | "adjustment";
73
+ adjustmentType: "fixed" | "percentage" | null;
74
+ sellAdjustmentCents: number | null;
75
+ adjustmentBasisPoints: number | null;
76
+ }[];
77
+ }[];
78
+ }[];
79
+ };
80
+ };
81
+ outputFormat: "json";
82
+ status: import("hono/utils/http-status").ContentfulStatusCode;
83
+ };
84
+ };
85
+ } & {
86
+ "/products/:productId/availability": {
87
+ $get: {
88
+ input: {
89
+ param: {
90
+ productId: string;
91
+ };
92
+ };
93
+ output: {
94
+ error: string;
95
+ };
96
+ outputFormat: "json";
97
+ status: 404;
98
+ } | {
99
+ input: {
100
+ param: {
101
+ productId: string;
102
+ };
103
+ };
104
+ output: {
105
+ productId: string;
106
+ slots: {
107
+ id: string;
108
+ optionId: string | null;
109
+ dateLocal: string | null;
110
+ startsAt: string | null;
111
+ endsAt: string | null;
112
+ timezone: string;
113
+ status: "open" | "closed" | "sold_out" | "cancelled";
114
+ unlimited: boolean;
115
+ remainingPax: number | null;
116
+ remainingResources: number | null;
117
+ pastCutoff: boolean;
118
+ tooEarly: boolean;
119
+ startTime: {
120
+ id: string;
121
+ label: string | null;
122
+ startTimeLocal: string;
123
+ durationMinutes: number | null;
124
+ } | null;
125
+ }[];
126
+ total: number;
127
+ limit: number;
128
+ offset: number;
129
+ };
130
+ outputFormat: "json";
131
+ status: import("hono/utils/http-status").ContentfulStatusCode;
132
+ };
133
+ };
134
+ }, "/", "/products/:productId/availability">;
135
+ export type PublicPricingRoutes = typeof publicPricingRoutes;
136
+ //# sourceMappingURL=routes-public.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes-public.d.ts","sourceRoot":"","sources":["../src/routes-public.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,GAAG,EAAY,MAAM,oBAAoB,CAAA;AAOvD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4CAoB5B,CAAA;AAEJ,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { Hono } from "hono";
2
+ import { notFound } from "./routes-shared.js";
3
+ import { publicPricingService } from "./service-public.js";
4
+ import { publicAvailabilitySnapshotQuerySchema, publicProductPricingQuerySchema, } from "./validation-public.js";
5
+ export const publicPricingRoutes = new Hono()
6
+ .get("/products/:productId/pricing", async (c) => {
7
+ const snapshot = await publicPricingService.getProductPricingSnapshot(c.get("db"), c.req.param("productId"), publicProductPricingQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams)));
8
+ return snapshot ? c.json({ data: snapshot }) : notFound(c, "Public pricing snapshot not found");
9
+ })
10
+ .get("/products/:productId/availability", async (c) => {
11
+ const snapshot = await publicPricingService.getAvailabilitySnapshot(c.get("db"), c.req.param("productId"), publicAvailabilitySnapshotQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams)));
12
+ return snapshot ? c.json(snapshot) : notFound(c, "Public availability snapshot not found");
13
+ });