@voyantjs/facilities 0.1.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/LICENSE +109 -0
- package/README.md +41 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/routes.d.ts +1386 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +224 -0
- package/dist/schema.d.ts +1303 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +249 -0
- package/dist/service.d.ts +585 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +601 -0
- package/dist/validation.d.ts +676 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +208 -0
- package/package.json +52 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AA4BjE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAEJ,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAA"}
|
package/dist/routes.js
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { insertAddressForEntitySchema, insertContactPointForEntitySchema, updateAddressSchema as updateIdentityAddressSchema, updateContactPointSchema as updateIdentityContactPointSchema, } from "@voyantjs/identity/validation";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { facilitiesService } from "./service.js";
|
|
4
|
+
import { facilityContactListQuerySchema, facilityFeatureListQuerySchema, facilityListQuerySchema, facilityOperationScheduleListQuerySchema, insertFacilityContactSchema, insertFacilityFeatureSchema, insertFacilityOperationScheduleSchema, insertFacilitySchema, insertPropertyGroupMemberSchema, insertPropertyGroupSchema, insertPropertySchema, propertyGroupListQuerySchema, propertyGroupMemberListQuerySchema, propertyListQuerySchema, updateFacilityContactSchema, updateFacilityFeatureSchema, updateFacilityOperationScheduleSchema, updateFacilitySchema, updatePropertyGroupMemberSchema, updatePropertyGroupSchema, updatePropertySchema, } from "./validation.js";
|
|
5
|
+
export const facilitiesRoutes = new Hono()
|
|
6
|
+
.get("/facilities", async (c) => {
|
|
7
|
+
const query = facilityListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
8
|
+
return c.json(await facilitiesService.listFacilities(c.get("db"), query));
|
|
9
|
+
})
|
|
10
|
+
.post("/facilities", async (c) => {
|
|
11
|
+
return c.json({
|
|
12
|
+
data: await facilitiesService.createFacility(c.get("db"), insertFacilitySchema.parse(await c.req.json())),
|
|
13
|
+
}, 201);
|
|
14
|
+
})
|
|
15
|
+
.get("/facilities/:id", async (c) => {
|
|
16
|
+
const row = await facilitiesService.getFacilityById(c.get("db"), c.req.param("id"));
|
|
17
|
+
if (!row)
|
|
18
|
+
return c.json({ error: "Facility not found" }, 404);
|
|
19
|
+
return c.json({ data: row });
|
|
20
|
+
})
|
|
21
|
+
.patch("/facilities/:id", async (c) => {
|
|
22
|
+
const row = await facilitiesService.updateFacility(c.get("db"), c.req.param("id"), updateFacilitySchema.parse(await c.req.json()));
|
|
23
|
+
if (!row)
|
|
24
|
+
return c.json({ error: "Facility not found" }, 404);
|
|
25
|
+
return c.json({ data: row });
|
|
26
|
+
})
|
|
27
|
+
.delete("/facilities/:id", async (c) => {
|
|
28
|
+
const row = await facilitiesService.deleteFacility(c.get("db"), c.req.param("id"));
|
|
29
|
+
if (!row)
|
|
30
|
+
return c.json({ error: "Facility not found" }, 404);
|
|
31
|
+
return c.json({ success: true });
|
|
32
|
+
})
|
|
33
|
+
.get("/facilities/:id/contact-points", async (c) => {
|
|
34
|
+
return c.json({
|
|
35
|
+
data: await facilitiesService.listContactPoints(c.get("db"), c.req.param("id")),
|
|
36
|
+
});
|
|
37
|
+
})
|
|
38
|
+
.post("/facilities/:id/contact-points", async (c) => {
|
|
39
|
+
const row = await facilitiesService.createContactPoint(c.get("db"), c.req.param("id"), insertContactPointForEntitySchema.parse(await c.req.json()));
|
|
40
|
+
if (!row)
|
|
41
|
+
return c.json({ error: "Facility not found" }, 404);
|
|
42
|
+
return c.json({ data: row }, 201);
|
|
43
|
+
})
|
|
44
|
+
.patch("/contact-points/:id", async (c) => {
|
|
45
|
+
const row = await facilitiesService.updateContactPoint(c.get("db"), c.req.param("id"), updateIdentityContactPointSchema.parse(await c.req.json()));
|
|
46
|
+
if (!row)
|
|
47
|
+
return c.json({ error: "Contact point not found" }, 404);
|
|
48
|
+
return c.json({ data: row });
|
|
49
|
+
})
|
|
50
|
+
.delete("/contact-points/:id", async (c) => {
|
|
51
|
+
const row = await facilitiesService.deleteContactPoint(c.get("db"), c.req.param("id"));
|
|
52
|
+
if (!row)
|
|
53
|
+
return c.json({ error: "Contact point not found" }, 404);
|
|
54
|
+
return c.json({ success: true });
|
|
55
|
+
})
|
|
56
|
+
.get("/facilities/:id/addresses", async (c) => {
|
|
57
|
+
return c.json({ data: await facilitiesService.listAddresses(c.get("db"), c.req.param("id")) });
|
|
58
|
+
})
|
|
59
|
+
.post("/facilities/:id/addresses", async (c) => {
|
|
60
|
+
const row = await facilitiesService.createAddress(c.get("db"), c.req.param("id"), insertAddressForEntitySchema.parse(await c.req.json()));
|
|
61
|
+
if (!row)
|
|
62
|
+
return c.json({ error: "Facility not found" }, 404);
|
|
63
|
+
return c.json({ data: row }, 201);
|
|
64
|
+
})
|
|
65
|
+
.patch("/addresses/:id", async (c) => {
|
|
66
|
+
const row = await facilitiesService.updateAddress(c.get("db"), c.req.param("id"), updateIdentityAddressSchema.parse(await c.req.json()));
|
|
67
|
+
if (!row)
|
|
68
|
+
return c.json({ error: "Address not found" }, 404);
|
|
69
|
+
return c.json({ data: row });
|
|
70
|
+
})
|
|
71
|
+
.delete("/addresses/:id", async (c) => {
|
|
72
|
+
const row = await facilitiesService.deleteAddress(c.get("db"), c.req.param("id"));
|
|
73
|
+
if (!row)
|
|
74
|
+
return c.json({ error: "Address not found" }, 404);
|
|
75
|
+
return c.json({ success: true });
|
|
76
|
+
})
|
|
77
|
+
.get("/facility-contacts", async (c) => {
|
|
78
|
+
const query = facilityContactListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
79
|
+
return c.json(await facilitiesService.listFacilityContacts(c.get("db"), query));
|
|
80
|
+
})
|
|
81
|
+
.post("/facilities/:id/contacts", async (c) => {
|
|
82
|
+
const row = await facilitiesService.createFacilityContact(c.get("db"), c.req.param("id"), insertFacilityContactSchema.parse(await c.req.json()));
|
|
83
|
+
if (!row)
|
|
84
|
+
return c.json({ error: "Facility not found" }, 404);
|
|
85
|
+
return c.json({ data: row }, 201);
|
|
86
|
+
})
|
|
87
|
+
.patch("/facility-contacts/:id", async (c) => {
|
|
88
|
+
const row = await facilitiesService.updateFacilityContact(c.get("db"), c.req.param("id"), updateFacilityContactSchema.parse(await c.req.json()));
|
|
89
|
+
if (!row)
|
|
90
|
+
return c.json({ error: "Facility contact not found" }, 404);
|
|
91
|
+
return c.json({ data: row });
|
|
92
|
+
})
|
|
93
|
+
.delete("/facility-contacts/:id", async (c) => {
|
|
94
|
+
const row = await facilitiesService.deleteFacilityContact(c.get("db"), c.req.param("id"));
|
|
95
|
+
if (!row)
|
|
96
|
+
return c.json({ error: "Facility contact not found" }, 404);
|
|
97
|
+
return c.json({ success: true });
|
|
98
|
+
})
|
|
99
|
+
.get("/facility-features", async (c) => {
|
|
100
|
+
const query = facilityFeatureListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
101
|
+
return c.json(await facilitiesService.listFacilityFeatures(c.get("db"), query));
|
|
102
|
+
})
|
|
103
|
+
.post("/facilities/:id/features", async (c) => {
|
|
104
|
+
const row = await facilitiesService.createFacilityFeature(c.get("db"), c.req.param("id"), insertFacilityFeatureSchema.parse(await c.req.json()));
|
|
105
|
+
if (!row)
|
|
106
|
+
return c.json({ error: "Facility not found" }, 404);
|
|
107
|
+
return c.json({ data: row }, 201);
|
|
108
|
+
})
|
|
109
|
+
.patch("/facility-features/:id", async (c) => {
|
|
110
|
+
const row = await facilitiesService.updateFacilityFeature(c.get("db"), c.req.param("id"), updateFacilityFeatureSchema.parse(await c.req.json()));
|
|
111
|
+
if (!row)
|
|
112
|
+
return c.json({ error: "Facility feature not found" }, 404);
|
|
113
|
+
return c.json({ data: row });
|
|
114
|
+
})
|
|
115
|
+
.delete("/facility-features/:id", async (c) => {
|
|
116
|
+
const row = await facilitiesService.deleteFacilityFeature(c.get("db"), c.req.param("id"));
|
|
117
|
+
if (!row)
|
|
118
|
+
return c.json({ error: "Facility feature not found" }, 404);
|
|
119
|
+
return c.json({ success: true });
|
|
120
|
+
})
|
|
121
|
+
.get("/facility-operation-schedules", async (c) => {
|
|
122
|
+
const query = facilityOperationScheduleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
123
|
+
return c.json(await facilitiesService.listFacilityOperationSchedules(c.get("db"), query));
|
|
124
|
+
})
|
|
125
|
+
.post("/facilities/:id/operation-schedules", async (c) => {
|
|
126
|
+
const row = await facilitiesService.createFacilityOperationSchedule(c.get("db"), c.req.param("id"), insertFacilityOperationScheduleSchema.parse(await c.req.json()));
|
|
127
|
+
if (!row)
|
|
128
|
+
return c.json({ error: "Facility not found" }, 404);
|
|
129
|
+
return c.json({ data: row }, 201);
|
|
130
|
+
})
|
|
131
|
+
.patch("/facility-operation-schedules/:id", async (c) => {
|
|
132
|
+
const row = await facilitiesService.updateFacilityOperationSchedule(c.get("db"), c.req.param("id"), updateFacilityOperationScheduleSchema.parse(await c.req.json()));
|
|
133
|
+
if (!row)
|
|
134
|
+
return c.json({ error: "Facility operation schedule not found" }, 404);
|
|
135
|
+
return c.json({ data: row });
|
|
136
|
+
})
|
|
137
|
+
.delete("/facility-operation-schedules/:id", async (c) => {
|
|
138
|
+
const row = await facilitiesService.deleteFacilityOperationSchedule(c.get("db"), c.req.param("id"));
|
|
139
|
+
if (!row)
|
|
140
|
+
return c.json({ error: "Facility operation schedule not found" }, 404);
|
|
141
|
+
return c.json({ success: true });
|
|
142
|
+
})
|
|
143
|
+
.get("/properties", async (c) => {
|
|
144
|
+
const query = propertyListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
145
|
+
return c.json(await facilitiesService.listProperties(c.get("db"), query));
|
|
146
|
+
})
|
|
147
|
+
.post("/properties", async (c) => {
|
|
148
|
+
const row = await facilitiesService.createProperty(c.get("db"), insertPropertySchema.parse(await c.req.json()));
|
|
149
|
+
if (!row)
|
|
150
|
+
return c.json({ error: "Facility not found" }, 404);
|
|
151
|
+
return c.json({ data: row }, 201);
|
|
152
|
+
})
|
|
153
|
+
.get("/properties/:id", async (c) => {
|
|
154
|
+
const row = await facilitiesService.getPropertyById(c.get("db"), c.req.param("id"));
|
|
155
|
+
if (!row)
|
|
156
|
+
return c.json({ error: "Property not found" }, 404);
|
|
157
|
+
return c.json({ data: row });
|
|
158
|
+
})
|
|
159
|
+
.patch("/properties/:id", async (c) => {
|
|
160
|
+
const row = await facilitiesService.updateProperty(c.get("db"), c.req.param("id"), updatePropertySchema.parse(await c.req.json()));
|
|
161
|
+
if (!row)
|
|
162
|
+
return c.json({ error: "Property not found" }, 404);
|
|
163
|
+
return c.json({ data: row });
|
|
164
|
+
})
|
|
165
|
+
.delete("/properties/:id", async (c) => {
|
|
166
|
+
const row = await facilitiesService.deleteProperty(c.get("db"), c.req.param("id"));
|
|
167
|
+
if (!row)
|
|
168
|
+
return c.json({ error: "Property not found" }, 404);
|
|
169
|
+
return c.json({ success: true });
|
|
170
|
+
})
|
|
171
|
+
.get("/property-groups", async (c) => {
|
|
172
|
+
const query = propertyGroupListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
173
|
+
return c.json(await facilitiesService.listPropertyGroups(c.get("db"), query));
|
|
174
|
+
})
|
|
175
|
+
.post("/property-groups", async (c) => {
|
|
176
|
+
const row = await facilitiesService.createPropertyGroup(c.get("db"), insertPropertyGroupSchema.parse(await c.req.json()));
|
|
177
|
+
return c.json({ data: row }, 201);
|
|
178
|
+
})
|
|
179
|
+
.get("/property-groups/:id", async (c) => {
|
|
180
|
+
const row = await facilitiesService.getPropertyGroupById(c.get("db"), c.req.param("id"));
|
|
181
|
+
if (!row)
|
|
182
|
+
return c.json({ error: "Property group not found" }, 404);
|
|
183
|
+
return c.json({ data: row });
|
|
184
|
+
})
|
|
185
|
+
.patch("/property-groups/:id", async (c) => {
|
|
186
|
+
const row = await facilitiesService.updatePropertyGroup(c.get("db"), c.req.param("id"), updatePropertyGroupSchema.parse(await c.req.json()));
|
|
187
|
+
if (!row)
|
|
188
|
+
return c.json({ error: "Property group not found" }, 404);
|
|
189
|
+
return c.json({ data: row });
|
|
190
|
+
})
|
|
191
|
+
.delete("/property-groups/:id", async (c) => {
|
|
192
|
+
const row = await facilitiesService.deletePropertyGroup(c.get("db"), c.req.param("id"));
|
|
193
|
+
if (!row)
|
|
194
|
+
return c.json({ error: "Property group not found" }, 404);
|
|
195
|
+
return c.json({ success: true });
|
|
196
|
+
})
|
|
197
|
+
.get("/property-group-members", async (c) => {
|
|
198
|
+
const query = propertyGroupMemberListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
199
|
+
return c.json(await facilitiesService.listPropertyGroupMembers(c.get("db"), query));
|
|
200
|
+
})
|
|
201
|
+
.post("/property-group-members", async (c) => {
|
|
202
|
+
const row = await facilitiesService.createPropertyGroupMember(c.get("db"), insertPropertyGroupMemberSchema.parse(await c.req.json()));
|
|
203
|
+
if (!row)
|
|
204
|
+
return c.json({ error: "Property group or property not found" }, 404);
|
|
205
|
+
return c.json({ data: row }, 201);
|
|
206
|
+
})
|
|
207
|
+
.get("/property-group-members/:id", async (c) => {
|
|
208
|
+
const row = await facilitiesService.getPropertyGroupMemberById(c.get("db"), c.req.param("id"));
|
|
209
|
+
if (!row)
|
|
210
|
+
return c.json({ error: "Property group member not found" }, 404);
|
|
211
|
+
return c.json({ data: row });
|
|
212
|
+
})
|
|
213
|
+
.patch("/property-group-members/:id", async (c) => {
|
|
214
|
+
const row = await facilitiesService.updatePropertyGroupMember(c.get("db"), c.req.param("id"), updatePropertyGroupMemberSchema.parse(await c.req.json()));
|
|
215
|
+
if (!row)
|
|
216
|
+
return c.json({ error: "Property group member not found" }, 404);
|
|
217
|
+
return c.json({ data: row });
|
|
218
|
+
})
|
|
219
|
+
.delete("/property-group-members/:id", async (c) => {
|
|
220
|
+
const row = await facilitiesService.deletePropertyGroupMember(c.get("db"), c.req.param("id"));
|
|
221
|
+
if (!row)
|
|
222
|
+
return c.json({ error: "Property group member not found" }, 404);
|
|
223
|
+
return c.json({ success: true });
|
|
224
|
+
});
|