@voyantjs/availability 0.1.1 → 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.
- package/dist/routes-core.d.ts +851 -0
- package/dist/routes-core.d.ts.map +1 -0
- package/dist/routes-core.js +153 -0
- package/dist/routes-pickups.d.ts +1362 -0
- package/dist/routes-pickups.d.ts.map +1 -0
- package/dist/routes-pickups.js +264 -0
- package/dist/routes-shared.d.ts +49 -0
- package/dist/routes-shared.d.ts.map +1 -0
- package/dist/routes-shared.js +45 -0
- package/dist/routes.d.ts +3 -2216
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +5 -540
- package/dist/service-core.d.ts +291 -0
- package/dist/service-core.d.ts.map +1 -0
- package/dist/service-core.js +205 -0
- package/dist/service-pickups.d.ts +407 -0
- package/dist/service-pickups.d.ts.map +1 -0
- package/dist/service-pickups.js +308 -0
- package/dist/service-shared.d.ts +45 -0
- package/dist/service-shared.d.ts.map +1 -0
- package/dist/service-shared.js +12 -0
- package/dist/service.d.ts +57 -729
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +57 -517
- package/package.json +5 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes-core.d.ts","sourceRoot":"","sources":["../src/routes-core.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,GAAG,EAIT,MAAM,oBAAoB,CAAA;AA0B3B,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAwN/B,CAAA"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { batchIdsSchema, createBatchUpdateSchema, handleBatchDelete, handleBatchUpdate, notFound, } from "./routes-shared.js";
|
|
3
|
+
import { availabilityService } from "./service.js";
|
|
4
|
+
import { availabilityCloseoutListQuerySchema, availabilityRuleListQuerySchema, availabilitySlotListQuerySchema, availabilityStartTimeListQuerySchema, insertAvailabilityCloseoutSchema, insertAvailabilityRuleSchema, insertAvailabilitySlotSchema, insertAvailabilityStartTimeSchema, updateAvailabilityCloseoutSchema, updateAvailabilityRuleSchema, updateAvailabilitySlotSchema, updateAvailabilityStartTimeSchema, } from "./validation.js";
|
|
5
|
+
const batchUpdateAvailabilityRuleSchema = createBatchUpdateSchema(updateAvailabilityRuleSchema);
|
|
6
|
+
const batchUpdateAvailabilityStartTimeSchema = createBatchUpdateSchema(updateAvailabilityStartTimeSchema);
|
|
7
|
+
const batchUpdateAvailabilitySlotSchema = createBatchUpdateSchema(updateAvailabilitySlotSchema);
|
|
8
|
+
const batchUpdateAvailabilityCloseoutSchema = createBatchUpdateSchema(updateAvailabilityCloseoutSchema);
|
|
9
|
+
export const availabilityCoreRoutes = new Hono()
|
|
10
|
+
.get("/rules", async (c) => {
|
|
11
|
+
const query = availabilityRuleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
12
|
+
return c.json(await availabilityService.listRules(c.get("db"), query));
|
|
13
|
+
})
|
|
14
|
+
.post("/rules", async (c) => c.json({
|
|
15
|
+
data: await availabilityService.createRule(c.get("db"), insertAvailabilityRuleSchema.parse(await c.req.json())),
|
|
16
|
+
}, 201))
|
|
17
|
+
.post("/rules/batch-update", async (c) => {
|
|
18
|
+
const body = batchUpdateAvailabilityRuleSchema.parse(await c.req.json());
|
|
19
|
+
return c.json(await handleBatchUpdate({
|
|
20
|
+
db: c.get("db"),
|
|
21
|
+
ids: body.ids,
|
|
22
|
+
patch: body.patch,
|
|
23
|
+
update: availabilityService.updateRule,
|
|
24
|
+
}));
|
|
25
|
+
})
|
|
26
|
+
.post("/rules/batch-delete", async (c) => {
|
|
27
|
+
const body = batchIdsSchema.parse(await c.req.json());
|
|
28
|
+
return c.json(await handleBatchDelete({
|
|
29
|
+
db: c.get("db"),
|
|
30
|
+
ids: body.ids,
|
|
31
|
+
remove: availabilityService.deleteRule,
|
|
32
|
+
}));
|
|
33
|
+
})
|
|
34
|
+
.get("/rules/:id", async (c) => {
|
|
35
|
+
const row = await availabilityService.getRuleById(c.get("db"), c.req.param("id"));
|
|
36
|
+
return row ? c.json({ data: row }) : notFound(c, "Availability rule not found");
|
|
37
|
+
})
|
|
38
|
+
.patch("/rules/:id", async (c) => {
|
|
39
|
+
const row = await availabilityService.updateRule(c.get("db"), c.req.param("id"), updateAvailabilityRuleSchema.parse(await c.req.json()));
|
|
40
|
+
return row ? c.json({ data: row }) : notFound(c, "Availability rule not found");
|
|
41
|
+
})
|
|
42
|
+
.delete("/rules/:id", async (c) => {
|
|
43
|
+
const row = await availabilityService.deleteRule(c.get("db"), c.req.param("id"));
|
|
44
|
+
return row ? c.json({ success: true }) : notFound(c, "Availability rule not found");
|
|
45
|
+
})
|
|
46
|
+
.get("/start-times", async (c) => {
|
|
47
|
+
const query = availabilityStartTimeListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
48
|
+
return c.json(await availabilityService.listStartTimes(c.get("db"), query));
|
|
49
|
+
})
|
|
50
|
+
.post("/start-times", async (c) => c.json({
|
|
51
|
+
data: await availabilityService.createStartTime(c.get("db"), insertAvailabilityStartTimeSchema.parse(await c.req.json())),
|
|
52
|
+
}, 201))
|
|
53
|
+
.post("/start-times/batch-update", async (c) => {
|
|
54
|
+
const body = batchUpdateAvailabilityStartTimeSchema.parse(await c.req.json());
|
|
55
|
+
return c.json(await handleBatchUpdate({
|
|
56
|
+
db: c.get("db"),
|
|
57
|
+
ids: body.ids,
|
|
58
|
+
patch: body.patch,
|
|
59
|
+
update: availabilityService.updateStartTime,
|
|
60
|
+
}));
|
|
61
|
+
})
|
|
62
|
+
.post("/start-times/batch-delete", async (c) => {
|
|
63
|
+
const body = batchIdsSchema.parse(await c.req.json());
|
|
64
|
+
return c.json(await handleBatchDelete({
|
|
65
|
+
db: c.get("db"),
|
|
66
|
+
ids: body.ids,
|
|
67
|
+
remove: availabilityService.deleteStartTime,
|
|
68
|
+
}));
|
|
69
|
+
})
|
|
70
|
+
.get("/start-times/:id", async (c) => {
|
|
71
|
+
const row = await availabilityService.getStartTimeById(c.get("db"), c.req.param("id"));
|
|
72
|
+
return row ? c.json({ data: row }) : notFound(c, "Availability start time not found");
|
|
73
|
+
})
|
|
74
|
+
.patch("/start-times/:id", async (c) => {
|
|
75
|
+
const row = await availabilityService.updateStartTime(c.get("db"), c.req.param("id"), updateAvailabilityStartTimeSchema.parse(await c.req.json()));
|
|
76
|
+
return row ? c.json({ data: row }) : notFound(c, "Availability start time not found");
|
|
77
|
+
})
|
|
78
|
+
.delete("/start-times/:id", async (c) => {
|
|
79
|
+
const row = await availabilityService.deleteStartTime(c.get("db"), c.req.param("id"));
|
|
80
|
+
return row ? c.json({ success: true }) : notFound(c, "Availability start time not found");
|
|
81
|
+
})
|
|
82
|
+
.get("/slots", async (c) => {
|
|
83
|
+
const query = availabilitySlotListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
84
|
+
return c.json(await availabilityService.listSlots(c.get("db"), query));
|
|
85
|
+
})
|
|
86
|
+
.post("/slots", async (c) => c.json({
|
|
87
|
+
data: await availabilityService.createSlot(c.get("db"), insertAvailabilitySlotSchema.parse(await c.req.json())),
|
|
88
|
+
}, 201))
|
|
89
|
+
.post("/slots/batch-update", async (c) => {
|
|
90
|
+
const body = batchUpdateAvailabilitySlotSchema.parse(await c.req.json());
|
|
91
|
+
return c.json(await handleBatchUpdate({
|
|
92
|
+
db: c.get("db"),
|
|
93
|
+
ids: body.ids,
|
|
94
|
+
patch: body.patch,
|
|
95
|
+
update: availabilityService.updateSlot,
|
|
96
|
+
}));
|
|
97
|
+
})
|
|
98
|
+
.post("/slots/batch-delete", async (c) => {
|
|
99
|
+
const body = batchIdsSchema.parse(await c.req.json());
|
|
100
|
+
return c.json(await handleBatchDelete({
|
|
101
|
+
db: c.get("db"),
|
|
102
|
+
ids: body.ids,
|
|
103
|
+
remove: availabilityService.deleteSlot,
|
|
104
|
+
}));
|
|
105
|
+
})
|
|
106
|
+
.get("/slots/:id", async (c) => {
|
|
107
|
+
const row = await availabilityService.getSlotById(c.get("db"), c.req.param("id"));
|
|
108
|
+
return row ? c.json({ data: row }) : notFound(c, "Availability slot not found");
|
|
109
|
+
})
|
|
110
|
+
.patch("/slots/:id", async (c) => {
|
|
111
|
+
const row = await availabilityService.updateSlot(c.get("db"), c.req.param("id"), updateAvailabilitySlotSchema.parse(await c.req.json()));
|
|
112
|
+
return row ? c.json({ data: row }) : notFound(c, "Availability slot not found");
|
|
113
|
+
})
|
|
114
|
+
.delete("/slots/:id", async (c) => {
|
|
115
|
+
const row = await availabilityService.deleteSlot(c.get("db"), c.req.param("id"));
|
|
116
|
+
return row ? c.json({ success: true }) : notFound(c, "Availability slot not found");
|
|
117
|
+
})
|
|
118
|
+
.get("/closeouts", async (c) => {
|
|
119
|
+
const query = availabilityCloseoutListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
120
|
+
return c.json(await availabilityService.listCloseouts(c.get("db"), query));
|
|
121
|
+
})
|
|
122
|
+
.post("/closeouts", async (c) => c.json({
|
|
123
|
+
data: await availabilityService.createCloseout(c.get("db"), insertAvailabilityCloseoutSchema.parse(await c.req.json())),
|
|
124
|
+
}, 201))
|
|
125
|
+
.post("/closeouts/batch-update", async (c) => {
|
|
126
|
+
const body = batchUpdateAvailabilityCloseoutSchema.parse(await c.req.json());
|
|
127
|
+
return c.json(await handleBatchUpdate({
|
|
128
|
+
db: c.get("db"),
|
|
129
|
+
ids: body.ids,
|
|
130
|
+
patch: body.patch,
|
|
131
|
+
update: availabilityService.updateCloseout,
|
|
132
|
+
}));
|
|
133
|
+
})
|
|
134
|
+
.post("/closeouts/batch-delete", async (c) => {
|
|
135
|
+
const body = batchIdsSchema.parse(await c.req.json());
|
|
136
|
+
return c.json(await handleBatchDelete({
|
|
137
|
+
db: c.get("db"),
|
|
138
|
+
ids: body.ids,
|
|
139
|
+
remove: availabilityService.deleteCloseout,
|
|
140
|
+
}));
|
|
141
|
+
})
|
|
142
|
+
.get("/closeouts/:id", async (c) => {
|
|
143
|
+
const row = await availabilityService.getCloseoutById(c.get("db"), c.req.param("id"));
|
|
144
|
+
return row ? c.json({ data: row }) : notFound(c, "Availability closeout not found");
|
|
145
|
+
})
|
|
146
|
+
.patch("/closeouts/:id", async (c) => {
|
|
147
|
+
const row = await availabilityService.updateCloseout(c.get("db"), c.req.param("id"), updateAvailabilityCloseoutSchema.parse(await c.req.json()));
|
|
148
|
+
return row ? c.json({ data: row }) : notFound(c, "Availability closeout not found");
|
|
149
|
+
})
|
|
150
|
+
.delete("/closeouts/:id", async (c) => {
|
|
151
|
+
const row = await availabilityService.deleteCloseout(c.get("db"), c.req.param("id"));
|
|
152
|
+
return row ? c.json({ success: true }) : notFound(c, "Availability closeout not found");
|
|
153
|
+
});
|