@voyantjs/pricing 0.2.0 → 0.3.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 (58) hide show
  1. package/dist/routes-core.d.ts +981 -0
  2. package/dist/routes-core.d.ts.map +1 -0
  3. package/dist/routes-core.js +101 -0
  4. package/dist/routes-rules.d.ts +1176 -0
  5. package/dist/routes-rules.d.ts.map +1 -0
  6. package/dist/routes-rules.js +117 -0
  7. package/dist/routes-shared.d.ts +12 -0
  8. package/dist/routes-shared.d.ts.map +1 -0
  9. package/dist/routes-shared.js +3 -0
  10. package/dist/routes.d.ts +3 -2160
  11. package/dist/routes.d.ts.map +1 -1
  12. package/dist/routes.js +5 -354
  13. package/dist/schema-catalogs.d.ts +467 -0
  14. package/dist/schema-catalogs.d.ts.map +1 -0
  15. package/dist/schema-catalogs.js +44 -0
  16. package/dist/schema-categories.d.ts +497 -0
  17. package/dist/schema-categories.d.ts.map +1 -0
  18. package/dist/schema-categories.js +50 -0
  19. package/dist/schema-option-rules.d.ts +1770 -0
  20. package/dist/schema-option-rules.d.ts.map +1 -0
  21. package/dist/schema-option-rules.js +174 -0
  22. package/dist/schema-policies.d.ts +395 -0
  23. package/dist/schema-policies.d.ts.map +1 -0
  24. package/dist/schema-policies.js +38 -0
  25. package/dist/schema-relations.d.ts +55 -0
  26. package/dist/schema-relations.d.ts.map +1 -0
  27. package/dist/schema-relations.js +103 -0
  28. package/dist/schema-shared.d.ts +11 -0
  29. package/dist/schema-shared.d.ts.map +1 -0
  30. package/dist/schema-shared.js +67 -0
  31. package/dist/schema.d.ts +6 -3189
  32. package/dist/schema.d.ts.map +1 -1
  33. package/dist/schema.js +6 -458
  34. package/dist/service-catalogs.d.ts +139 -0
  35. package/dist/service-catalogs.d.ts.map +1 -0
  36. package/dist/service-catalogs.js +89 -0
  37. package/dist/service-categories.d.ts +147 -0
  38. package/dist/service-categories.d.ts.map +1 -0
  39. package/dist/service-categories.js +105 -0
  40. package/dist/service-option-rules.d.ts +307 -0
  41. package/dist/service-option-rules.d.ts.map +1 -0
  42. package/dist/service-option-rules.js +188 -0
  43. package/dist/service-policies.d.ts +123 -0
  44. package/dist/service-policies.d.ts.map +1 -0
  45. package/dist/service-policies.js +95 -0
  46. package/dist/service-shared.d.ts +50 -0
  47. package/dist/service-shared.d.ts.map +1 -0
  48. package/dist/service-shared.js +4 -0
  49. package/dist/service-transfer-rules.d.ts +211 -0
  50. package/dist/service-transfer-rules.d.ts.map +1 -0
  51. package/dist/service-transfer-rules.js +139 -0
  52. package/dist/service.d.ts +70 -955
  53. package/dist/service.d.ts.map +1 -1
  54. package/dist/service.js +70 -595
  55. package/dist/validation.d.ts +2 -0
  56. package/dist/validation.d.ts.map +1 -1
  57. package/dist/validation.js +2 -0
  58. package/package.json +8 -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
+ });