@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.
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/routes-core.d.ts +981 -0
- package/dist/routes-core.d.ts.map +1 -0
- package/dist/routes-core.js +101 -0
- package/dist/routes-public.d.ts +136 -0
- package/dist/routes-public.d.ts.map +1 -0
- package/dist/routes-public.js +13 -0
- package/dist/routes-rules.d.ts +1176 -0
- package/dist/routes-rules.d.ts.map +1 -0
- package/dist/routes-rules.js +117 -0
- package/dist/routes-shared.d.ts +12 -0
- package/dist/routes-shared.d.ts.map +1 -0
- package/dist/routes-shared.js +3 -0
- package/dist/routes.d.ts +5 -2160
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +5 -354
- package/dist/schema-catalogs.d.ts +467 -0
- package/dist/schema-catalogs.d.ts.map +1 -0
- package/dist/schema-catalogs.js +44 -0
- package/dist/schema-categories.d.ts +497 -0
- package/dist/schema-categories.d.ts.map +1 -0
- package/dist/schema-categories.js +50 -0
- package/dist/schema-option-rules.d.ts +1770 -0
- package/dist/schema-option-rules.d.ts.map +1 -0
- package/dist/schema-option-rules.js +174 -0
- package/dist/schema-policies.d.ts +395 -0
- package/dist/schema-policies.d.ts.map +1 -0
- package/dist/schema-policies.js +38 -0
- package/dist/schema-relations.d.ts +55 -0
- package/dist/schema-relations.d.ts.map +1 -0
- package/dist/schema-relations.js +103 -0
- package/dist/schema-shared.d.ts +11 -0
- package/dist/schema-shared.d.ts.map +1 -0
- package/dist/schema-shared.js +67 -0
- package/dist/schema.d.ts +6 -3189
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +6 -458
- package/dist/service-catalogs.d.ts +139 -0
- package/dist/service-catalogs.d.ts.map +1 -0
- package/dist/service-catalogs.js +89 -0
- package/dist/service-categories.d.ts +147 -0
- package/dist/service-categories.d.ts.map +1 -0
- package/dist/service-categories.js +105 -0
- package/dist/service-option-rules.d.ts +307 -0
- package/dist/service-option-rules.d.ts.map +1 -0
- package/dist/service-option-rules.js +188 -0
- package/dist/service-policies.d.ts +123 -0
- package/dist/service-policies.d.ts.map +1 -0
- package/dist/service-policies.js +95 -0
- package/dist/service-public.d.ts +89 -0
- package/dist/service-public.d.ts.map +1 -0
- package/dist/service-public.js +355 -0
- package/dist/service-shared.d.ts +50 -0
- package/dist/service-shared.d.ts.map +1 -0
- package/dist/service-shared.js +4 -0
- package/dist/service-transfer-rules.d.ts +211 -0
- package/dist/service-transfer-rules.d.ts.map +1 -0
- package/dist/service-transfer-rules.js +139 -0
- package/dist/service.d.ts +70 -955
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +70 -595
- package/dist/validation-public.d.ts +410 -0
- package/dist/validation-public.d.ts.map +1 -0
- package/dist/validation-public.js +109 -0
- package/dist/validation-shared.d.ts +71 -0
- package/dist/validation-shared.d.ts.map +1 -0
- package/dist/validation-shared.js +63 -0
- package/dist/validation.d.ts +4 -69
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +5 -62
- package/package.json +16 -8
package/dist/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAG3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE7D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;AAE7C,eAAO,MAAM,aAAa,kDAAkB,CAAA;AAI5C,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAA;AAChD,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAA"}
|
package/dist/routes.js
CHANGED
|
@@ -1,355 +1,6 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export const pricingRoutes = new Hono()
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return c.json(await pricingService.listPricingCategories(c.get("db"), query));
|
|
8
|
-
})
|
|
9
|
-
.post("/pricing-categories", async (c) => {
|
|
10
|
-
return c.json({
|
|
11
|
-
data: await pricingService.createPricingCategory(c.get("db"), insertPricingCategorySchema.parse(await c.req.json())),
|
|
12
|
-
}, 201);
|
|
13
|
-
})
|
|
14
|
-
.get("/pricing-categories/:id", async (c) => {
|
|
15
|
-
const row = await pricingService.getPricingCategoryById(c.get("db"), c.req.param("id"));
|
|
16
|
-
if (!row)
|
|
17
|
-
return c.json({ error: "Pricing category not found" }, 404);
|
|
18
|
-
return c.json({ data: row });
|
|
19
|
-
})
|
|
20
|
-
.patch("/pricing-categories/:id", async (c) => {
|
|
21
|
-
const row = await pricingService.updatePricingCategory(c.get("db"), c.req.param("id"), updatePricingCategorySchema.parse(await c.req.json()));
|
|
22
|
-
if (!row)
|
|
23
|
-
return c.json({ error: "Pricing category not found" }, 404);
|
|
24
|
-
return c.json({ data: row });
|
|
25
|
-
})
|
|
26
|
-
.delete("/pricing-categories/:id", async (c) => {
|
|
27
|
-
const row = await pricingService.deletePricingCategory(c.get("db"), c.req.param("id"));
|
|
28
|
-
if (!row)
|
|
29
|
-
return c.json({ error: "Pricing category not found" }, 404);
|
|
30
|
-
return c.json({ success: true });
|
|
31
|
-
})
|
|
32
|
-
.get("/pricing-category-dependencies", async (c) => {
|
|
33
|
-
const query = pricingCategoryDependencyListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
34
|
-
return c.json(await pricingService.listPricingCategoryDependencies(c.get("db"), query));
|
|
35
|
-
})
|
|
36
|
-
.post("/pricing-category-dependencies", async (c) => {
|
|
37
|
-
return c.json({
|
|
38
|
-
data: await pricingService.createPricingCategoryDependency(c.get("db"), insertPricingCategoryDependencySchema.parse(await c.req.json())),
|
|
39
|
-
}, 201);
|
|
40
|
-
})
|
|
41
|
-
.get("/pricing-category-dependencies/:id", async (c) => {
|
|
42
|
-
const row = await pricingService.getPricingCategoryDependencyById(c.get("db"), c.req.param("id"));
|
|
43
|
-
if (!row)
|
|
44
|
-
return c.json({ error: "Pricing category dependency not found" }, 404);
|
|
45
|
-
return c.json({ data: row });
|
|
46
|
-
})
|
|
47
|
-
.patch("/pricing-category-dependencies/:id", async (c) => {
|
|
48
|
-
const row = await pricingService.updatePricingCategoryDependency(c.get("db"), c.req.param("id"), updatePricingCategoryDependencySchema.parse(await c.req.json()));
|
|
49
|
-
if (!row)
|
|
50
|
-
return c.json({ error: "Pricing category dependency not found" }, 404);
|
|
51
|
-
return c.json({ data: row });
|
|
52
|
-
})
|
|
53
|
-
.delete("/pricing-category-dependencies/:id", async (c) => {
|
|
54
|
-
const row = await pricingService.deletePricingCategoryDependency(c.get("db"), c.req.param("id"));
|
|
55
|
-
if (!row)
|
|
56
|
-
return c.json({ error: "Pricing category dependency not found" }, 404);
|
|
57
|
-
return c.json({ success: true });
|
|
58
|
-
})
|
|
59
|
-
.get("/cancellation-policies", async (c) => {
|
|
60
|
-
const query = cancellationPolicyListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
61
|
-
return c.json(await pricingService.listCancellationPolicies(c.get("db"), query));
|
|
62
|
-
})
|
|
63
|
-
.post("/cancellation-policies", async (c) => {
|
|
64
|
-
return c.json({
|
|
65
|
-
data: await pricingService.createCancellationPolicy(c.get("db"), insertCancellationPolicySchema.parse(await c.req.json())),
|
|
66
|
-
}, 201);
|
|
67
|
-
})
|
|
68
|
-
.get("/cancellation-policies/:id", async (c) => {
|
|
69
|
-
const row = await pricingService.getCancellationPolicyById(c.get("db"), c.req.param("id"));
|
|
70
|
-
if (!row)
|
|
71
|
-
return c.json({ error: "Cancellation policy not found" }, 404);
|
|
72
|
-
return c.json({ data: row });
|
|
73
|
-
})
|
|
74
|
-
.patch("/cancellation-policies/:id", async (c) => {
|
|
75
|
-
const row = await pricingService.updateCancellationPolicy(c.get("db"), c.req.param("id"), updateCancellationPolicySchema.parse(await c.req.json()));
|
|
76
|
-
if (!row)
|
|
77
|
-
return c.json({ error: "Cancellation policy not found" }, 404);
|
|
78
|
-
return c.json({ data: row });
|
|
79
|
-
})
|
|
80
|
-
.delete("/cancellation-policies/:id", async (c) => {
|
|
81
|
-
const row = await pricingService.deleteCancellationPolicy(c.get("db"), c.req.param("id"));
|
|
82
|
-
if (!row)
|
|
83
|
-
return c.json({ error: "Cancellation policy not found" }, 404);
|
|
84
|
-
return c.json({ success: true });
|
|
85
|
-
})
|
|
86
|
-
.get("/cancellation-policy-rules", async (c) => {
|
|
87
|
-
const query = cancellationPolicyRuleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
88
|
-
return c.json(await pricingService.listCancellationPolicyRules(c.get("db"), query));
|
|
89
|
-
})
|
|
90
|
-
.post("/cancellation-policy-rules", async (c) => {
|
|
91
|
-
return c.json({
|
|
92
|
-
data: await pricingService.createCancellationPolicyRule(c.get("db"), insertCancellationPolicyRuleSchema.parse(await c.req.json())),
|
|
93
|
-
}, 201);
|
|
94
|
-
})
|
|
95
|
-
.get("/cancellation-policy-rules/:id", async (c) => {
|
|
96
|
-
const row = await pricingService.getCancellationPolicyRuleById(c.get("db"), c.req.param("id"));
|
|
97
|
-
if (!row)
|
|
98
|
-
return c.json({ error: "Cancellation policy rule not found" }, 404);
|
|
99
|
-
return c.json({ data: row });
|
|
100
|
-
})
|
|
101
|
-
.patch("/cancellation-policy-rules/:id", async (c) => {
|
|
102
|
-
const row = await pricingService.updateCancellationPolicyRule(c.get("db"), c.req.param("id"), updateCancellationPolicyRuleSchema.parse(await c.req.json()));
|
|
103
|
-
if (!row)
|
|
104
|
-
return c.json({ error: "Cancellation policy rule not found" }, 404);
|
|
105
|
-
return c.json({ data: row });
|
|
106
|
-
})
|
|
107
|
-
.delete("/cancellation-policy-rules/:id", async (c) => {
|
|
108
|
-
const row = await pricingService.deleteCancellationPolicyRule(c.get("db"), c.req.param("id"));
|
|
109
|
-
if (!row)
|
|
110
|
-
return c.json({ error: "Cancellation policy rule not found" }, 404);
|
|
111
|
-
return c.json({ success: true });
|
|
112
|
-
})
|
|
113
|
-
.get("/price-catalogs", async (c) => {
|
|
114
|
-
const query = priceCatalogListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
115
|
-
return c.json(await pricingService.listPriceCatalogs(c.get("db"), query));
|
|
116
|
-
})
|
|
117
|
-
.post("/price-catalogs", async (c) => {
|
|
118
|
-
return c.json({
|
|
119
|
-
data: await pricingService.createPriceCatalog(c.get("db"), insertPriceCatalogSchema.parse(await c.req.json())),
|
|
120
|
-
}, 201);
|
|
121
|
-
})
|
|
122
|
-
.get("/price-catalogs/:id", async (c) => {
|
|
123
|
-
const row = await pricingService.getPriceCatalogById(c.get("db"), c.req.param("id"));
|
|
124
|
-
if (!row)
|
|
125
|
-
return c.json({ error: "Price catalog not found" }, 404);
|
|
126
|
-
return c.json({ data: row });
|
|
127
|
-
})
|
|
128
|
-
.patch("/price-catalogs/:id", async (c) => {
|
|
129
|
-
const row = await pricingService.updatePriceCatalog(c.get("db"), c.req.param("id"), updatePriceCatalogSchema.parse(await c.req.json()));
|
|
130
|
-
if (!row)
|
|
131
|
-
return c.json({ error: "Price catalog not found" }, 404);
|
|
132
|
-
return c.json({ data: row });
|
|
133
|
-
})
|
|
134
|
-
.delete("/price-catalogs/:id", async (c) => {
|
|
135
|
-
const row = await pricingService.deletePriceCatalog(c.get("db"), c.req.param("id"));
|
|
136
|
-
if (!row)
|
|
137
|
-
return c.json({ error: "Price catalog not found" }, 404);
|
|
138
|
-
return c.json({ success: true });
|
|
139
|
-
})
|
|
140
|
-
.get("/price-schedules", async (c) => {
|
|
141
|
-
const query = priceScheduleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
142
|
-
return c.json(await pricingService.listPriceSchedules(c.get("db"), query));
|
|
143
|
-
})
|
|
144
|
-
.post("/price-schedules", async (c) => {
|
|
145
|
-
return c.json({
|
|
146
|
-
data: await pricingService.createPriceSchedule(c.get("db"), insertPriceScheduleSchema.parse(await c.req.json())),
|
|
147
|
-
}, 201);
|
|
148
|
-
})
|
|
149
|
-
.get("/price-schedules/:id", async (c) => {
|
|
150
|
-
const row = await pricingService.getPriceScheduleById(c.get("db"), c.req.param("id"));
|
|
151
|
-
if (!row)
|
|
152
|
-
return c.json({ error: "Price schedule not found" }, 404);
|
|
153
|
-
return c.json({ data: row });
|
|
154
|
-
})
|
|
155
|
-
.patch("/price-schedules/:id", async (c) => {
|
|
156
|
-
const row = await pricingService.updatePriceSchedule(c.get("db"), c.req.param("id"), updatePriceScheduleSchema.parse(await c.req.json()));
|
|
157
|
-
if (!row)
|
|
158
|
-
return c.json({ error: "Price schedule not found" }, 404);
|
|
159
|
-
return c.json({ data: row });
|
|
160
|
-
})
|
|
161
|
-
.delete("/price-schedules/:id", async (c) => {
|
|
162
|
-
const row = await pricingService.deletePriceSchedule(c.get("db"), c.req.param("id"));
|
|
163
|
-
if (!row)
|
|
164
|
-
return c.json({ error: "Price schedule not found" }, 404);
|
|
165
|
-
return c.json({ success: true });
|
|
166
|
-
})
|
|
167
|
-
.get("/option-price-rules", async (c) => {
|
|
168
|
-
const query = optionPriceRuleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
169
|
-
return c.json(await pricingService.listOptionPriceRules(c.get("db"), query));
|
|
170
|
-
})
|
|
171
|
-
.post("/option-price-rules", async (c) => {
|
|
172
|
-
return c.json({
|
|
173
|
-
data: await pricingService.createOptionPriceRule(c.get("db"), insertOptionPriceRuleSchema.parse(await c.req.json())),
|
|
174
|
-
}, 201);
|
|
175
|
-
})
|
|
176
|
-
.get("/option-price-rules/:id", async (c) => {
|
|
177
|
-
const row = await pricingService.getOptionPriceRuleById(c.get("db"), c.req.param("id"));
|
|
178
|
-
if (!row)
|
|
179
|
-
return c.json({ error: "Option price rule not found" }, 404);
|
|
180
|
-
return c.json({ data: row });
|
|
181
|
-
})
|
|
182
|
-
.patch("/option-price-rules/:id", async (c) => {
|
|
183
|
-
const row = await pricingService.updateOptionPriceRule(c.get("db"), c.req.param("id"), updateOptionPriceRuleSchema.parse(await c.req.json()));
|
|
184
|
-
if (!row)
|
|
185
|
-
return c.json({ error: "Option price rule not found" }, 404);
|
|
186
|
-
return c.json({ data: row });
|
|
187
|
-
})
|
|
188
|
-
.delete("/option-price-rules/:id", async (c) => {
|
|
189
|
-
const row = await pricingService.deleteOptionPriceRule(c.get("db"), c.req.param("id"));
|
|
190
|
-
if (!row)
|
|
191
|
-
return c.json({ error: "Option price rule not found" }, 404);
|
|
192
|
-
return c.json({ success: true });
|
|
193
|
-
})
|
|
194
|
-
.get("/option-unit-price-rules", async (c) => {
|
|
195
|
-
const query = optionUnitPriceRuleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
196
|
-
return c.json(await pricingService.listOptionUnitPriceRules(c.get("db"), query));
|
|
197
|
-
})
|
|
198
|
-
.post("/option-unit-price-rules", async (c) => {
|
|
199
|
-
return c.json({
|
|
200
|
-
data: await pricingService.createOptionUnitPriceRule(c.get("db"), insertOptionUnitPriceRuleSchema.parse(await c.req.json())),
|
|
201
|
-
}, 201);
|
|
202
|
-
})
|
|
203
|
-
.get("/option-unit-price-rules/:id", async (c) => {
|
|
204
|
-
const row = await pricingService.getOptionUnitPriceRuleById(c.get("db"), c.req.param("id"));
|
|
205
|
-
if (!row)
|
|
206
|
-
return c.json({ error: "Option unit price rule not found" }, 404);
|
|
207
|
-
return c.json({ data: row });
|
|
208
|
-
})
|
|
209
|
-
.patch("/option-unit-price-rules/:id", async (c) => {
|
|
210
|
-
const row = await pricingService.updateOptionUnitPriceRule(c.get("db"), c.req.param("id"), updateOptionUnitPriceRuleSchema.parse(await c.req.json()));
|
|
211
|
-
if (!row)
|
|
212
|
-
return c.json({ error: "Option unit price rule not found" }, 404);
|
|
213
|
-
return c.json({ data: row });
|
|
214
|
-
})
|
|
215
|
-
.delete("/option-unit-price-rules/:id", async (c) => {
|
|
216
|
-
const row = await pricingService.deleteOptionUnitPriceRule(c.get("db"), c.req.param("id"));
|
|
217
|
-
if (!row)
|
|
218
|
-
return c.json({ error: "Option unit price rule not found" }, 404);
|
|
219
|
-
return c.json({ success: true });
|
|
220
|
-
})
|
|
221
|
-
.get("/option-start-time-rules", async (c) => {
|
|
222
|
-
const query = optionStartTimeRuleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
223
|
-
return c.json(await pricingService.listOptionStartTimeRules(c.get("db"), query));
|
|
224
|
-
})
|
|
225
|
-
.post("/option-start-time-rules", async (c) => {
|
|
226
|
-
return c.json({
|
|
227
|
-
data: await pricingService.createOptionStartTimeRule(c.get("db"), insertOptionStartTimeRuleSchema.parse(await c.req.json())),
|
|
228
|
-
}, 201);
|
|
229
|
-
})
|
|
230
|
-
.get("/option-start-time-rules/:id", async (c) => {
|
|
231
|
-
const row = await pricingService.getOptionStartTimeRuleById(c.get("db"), c.req.param("id"));
|
|
232
|
-
if (!row)
|
|
233
|
-
return c.json({ error: "Option start time rule not found" }, 404);
|
|
234
|
-
return c.json({ data: row });
|
|
235
|
-
})
|
|
236
|
-
.patch("/option-start-time-rules/:id", async (c) => {
|
|
237
|
-
const row = await pricingService.updateOptionStartTimeRule(c.get("db"), c.req.param("id"), updateOptionStartTimeRuleSchema.parse(await c.req.json()));
|
|
238
|
-
if (!row)
|
|
239
|
-
return c.json({ error: "Option start time rule not found" }, 404);
|
|
240
|
-
return c.json({ data: row });
|
|
241
|
-
})
|
|
242
|
-
.delete("/option-start-time-rules/:id", async (c) => {
|
|
243
|
-
const row = await pricingService.deleteOptionStartTimeRule(c.get("db"), c.req.param("id"));
|
|
244
|
-
if (!row)
|
|
245
|
-
return c.json({ error: "Option start time rule not found" }, 404);
|
|
246
|
-
return c.json({ success: true });
|
|
247
|
-
})
|
|
248
|
-
.get("/option-unit-tiers", async (c) => {
|
|
249
|
-
const query = optionUnitTierListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
250
|
-
return c.json(await pricingService.listOptionUnitTiers(c.get("db"), query));
|
|
251
|
-
})
|
|
252
|
-
.post("/option-unit-tiers", async (c) => {
|
|
253
|
-
return c.json({
|
|
254
|
-
data: await pricingService.createOptionUnitTier(c.get("db"), insertOptionUnitTierSchema.parse(await c.req.json())),
|
|
255
|
-
}, 201);
|
|
256
|
-
})
|
|
257
|
-
.get("/option-unit-tiers/:id", async (c) => {
|
|
258
|
-
const row = await pricingService.getOptionUnitTierById(c.get("db"), c.req.param("id"));
|
|
259
|
-
if (!row)
|
|
260
|
-
return c.json({ error: "Option unit tier not found" }, 404);
|
|
261
|
-
return c.json({ data: row });
|
|
262
|
-
})
|
|
263
|
-
.patch("/option-unit-tiers/:id", async (c) => {
|
|
264
|
-
const row = await pricingService.updateOptionUnitTier(c.get("db"), c.req.param("id"), updateOptionUnitTierSchema.parse(await c.req.json()));
|
|
265
|
-
if (!row)
|
|
266
|
-
return c.json({ error: "Option unit tier not found" }, 404);
|
|
267
|
-
return c.json({ data: row });
|
|
268
|
-
})
|
|
269
|
-
.delete("/option-unit-tiers/:id", async (c) => {
|
|
270
|
-
const row = await pricingService.deleteOptionUnitTier(c.get("db"), c.req.param("id"));
|
|
271
|
-
if (!row)
|
|
272
|
-
return c.json({ error: "Option unit tier not found" }, 404);
|
|
273
|
-
return c.json({ success: true });
|
|
274
|
-
})
|
|
275
|
-
.get("/pickup-price-rules", async (c) => {
|
|
276
|
-
const query = pickupPriceRuleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
277
|
-
return c.json(await pricingService.listPickupPriceRules(c.get("db"), query));
|
|
278
|
-
})
|
|
279
|
-
.post("/pickup-price-rules", async (c) => {
|
|
280
|
-
return c.json({
|
|
281
|
-
data: await pricingService.createPickupPriceRule(c.get("db"), insertPickupPriceRuleSchema.parse(await c.req.json())),
|
|
282
|
-
}, 201);
|
|
283
|
-
})
|
|
284
|
-
.get("/pickup-price-rules/:id", async (c) => {
|
|
285
|
-
const row = await pricingService.getPickupPriceRuleById(c.get("db"), c.req.param("id"));
|
|
286
|
-
if (!row)
|
|
287
|
-
return c.json({ error: "Pickup price rule not found" }, 404);
|
|
288
|
-
return c.json({ data: row });
|
|
289
|
-
})
|
|
290
|
-
.patch("/pickup-price-rules/:id", async (c) => {
|
|
291
|
-
const row = await pricingService.updatePickupPriceRule(c.get("db"), c.req.param("id"), updatePickupPriceRuleSchema.parse(await c.req.json()));
|
|
292
|
-
if (!row)
|
|
293
|
-
return c.json({ error: "Pickup price rule not found" }, 404);
|
|
294
|
-
return c.json({ data: row });
|
|
295
|
-
})
|
|
296
|
-
.delete("/pickup-price-rules/:id", async (c) => {
|
|
297
|
-
const row = await pricingService.deletePickupPriceRule(c.get("db"), c.req.param("id"));
|
|
298
|
-
if (!row)
|
|
299
|
-
return c.json({ error: "Pickup price rule not found" }, 404);
|
|
300
|
-
return c.json({ success: true });
|
|
301
|
-
})
|
|
302
|
-
.get("/dropoff-price-rules", async (c) => {
|
|
303
|
-
const query = dropoffPriceRuleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
304
|
-
return c.json(await pricingService.listDropoffPriceRules(c.get("db"), query));
|
|
305
|
-
})
|
|
306
|
-
.post("/dropoff-price-rules", async (c) => {
|
|
307
|
-
return c.json({
|
|
308
|
-
data: await pricingService.createDropoffPriceRule(c.get("db"), insertDropoffPriceRuleSchema.parse(await c.req.json())),
|
|
309
|
-
}, 201);
|
|
310
|
-
})
|
|
311
|
-
.get("/dropoff-price-rules/:id", async (c) => {
|
|
312
|
-
const row = await pricingService.getDropoffPriceRuleById(c.get("db"), c.req.param("id"));
|
|
313
|
-
if (!row)
|
|
314
|
-
return c.json({ error: "Dropoff price rule not found" }, 404);
|
|
315
|
-
return c.json({ data: row });
|
|
316
|
-
})
|
|
317
|
-
.patch("/dropoff-price-rules/:id", async (c) => {
|
|
318
|
-
const row = await pricingService.updateDropoffPriceRule(c.get("db"), c.req.param("id"), updateDropoffPriceRuleSchema.parse(await c.req.json()));
|
|
319
|
-
if (!row)
|
|
320
|
-
return c.json({ error: "Dropoff price rule not found" }, 404);
|
|
321
|
-
return c.json({ data: row });
|
|
322
|
-
})
|
|
323
|
-
.delete("/dropoff-price-rules/:id", async (c) => {
|
|
324
|
-
const row = await pricingService.deleteDropoffPriceRule(c.get("db"), c.req.param("id"));
|
|
325
|
-
if (!row)
|
|
326
|
-
return c.json({ error: "Dropoff price rule not found" }, 404);
|
|
327
|
-
return c.json({ success: true });
|
|
328
|
-
})
|
|
329
|
-
.get("/extra-price-rules", async (c) => {
|
|
330
|
-
const query = extraPriceRuleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
331
|
-
return c.json(await pricingService.listExtraPriceRules(c.get("db"), query));
|
|
332
|
-
})
|
|
333
|
-
.post("/extra-price-rules", async (c) => {
|
|
334
|
-
return c.json({
|
|
335
|
-
data: await pricingService.createExtraPriceRule(c.get("db"), insertExtraPriceRuleSchema.parse(await c.req.json())),
|
|
336
|
-
}, 201);
|
|
337
|
-
})
|
|
338
|
-
.get("/extra-price-rules/:id", async (c) => {
|
|
339
|
-
const row = await pricingService.getExtraPriceRuleById(c.get("db"), c.req.param("id"));
|
|
340
|
-
if (!row)
|
|
341
|
-
return c.json({ error: "Extra price rule not found" }, 404);
|
|
342
|
-
return c.json({ data: row });
|
|
343
|
-
})
|
|
344
|
-
.patch("/extra-price-rules/:id", async (c) => {
|
|
345
|
-
const row = await pricingService.updateExtraPriceRule(c.get("db"), c.req.param("id"), updateExtraPriceRuleSchema.parse(await c.req.json()));
|
|
346
|
-
if (!row)
|
|
347
|
-
return c.json({ error: "Extra price rule not found" }, 404);
|
|
348
|
-
return c.json({ data: row });
|
|
349
|
-
})
|
|
350
|
-
.delete("/extra-price-rules/:id", async (c) => {
|
|
351
|
-
const row = await pricingService.deleteExtraPriceRule(c.get("db"), c.req.param("id"));
|
|
352
|
-
if (!row)
|
|
353
|
-
return c.json({ error: "Extra price rule not found" }, 404);
|
|
354
|
-
return c.json({ success: true });
|
|
355
|
-
});
|
|
2
|
+
import { pricingCoreRoutes } from "./routes-core.js";
|
|
3
|
+
import { pricingRuleRoutes } from "./routes-rules.js";
|
|
4
|
+
export const pricingRoutes = new Hono();
|
|
5
|
+
pricingRoutes.route("/", pricingCoreRoutes);
|
|
6
|
+
pricingRoutes.route("/", pricingRuleRoutes);
|