@voyantjs/sellability 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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AA2BjE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAqN1B,CAAA;AAEJ,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAA"}
package/dist/routes.js ADDED
@@ -0,0 +1,169 @@
1
+ import { Hono } from "hono";
2
+ import { sellabilityService } from "./service.js";
3
+ import { insertOfferExpirationEventSchema, insertOfferRefreshRunSchema, insertSellabilityExplanationSchema, insertSellabilityPolicyResultSchema, insertSellabilityPolicySchema, offerExpirationEventListQuerySchema, offerRefreshRunListQuerySchema, sellabilityConstructOfferSchema, sellabilityExplanationListQuerySchema, sellabilityPersistSnapshotSchema, sellabilityPolicyListQuerySchema, sellabilityPolicyResultListQuerySchema, sellabilityResolveQuerySchema, sellabilitySnapshotItemListQuerySchema, sellabilitySnapshotListQuerySchema, updateOfferExpirationEventSchema, updateOfferRefreshRunSchema, updateSellabilityExplanationSchema, updateSellabilityPolicyResultSchema, updateSellabilityPolicySchema, } from "./validation.js";
4
+ export const sellabilityRoutes = new Hono()
5
+ .post("/resolve", async (c) => {
6
+ const input = sellabilityResolveQuerySchema.parse(await c.req.json());
7
+ return c.json(await sellabilityService.resolve(c.get("db"), input));
8
+ })
9
+ .post("/resolve-and-persist", async (c) => {
10
+ const input = sellabilityPersistSnapshotSchema.parse(await c.req.json());
11
+ return c.json(await sellabilityService.persistSnapshot(c.get("db"), input), 201);
12
+ })
13
+ .post("/construct-offer", async (c) => {
14
+ const input = sellabilityConstructOfferSchema.parse(await c.req.json());
15
+ const result = await sellabilityService.constructOffer(c.get("db"), input);
16
+ if (!result) {
17
+ return c.json({ error: "Sellable candidate not found" }, 404);
18
+ }
19
+ return c.json({ data: result }, 201);
20
+ })
21
+ .get("/snapshots", async (c) => {
22
+ const query = sellabilitySnapshotListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
23
+ return c.json(await sellabilityService.listSnapshots(c.get("db"), query));
24
+ })
25
+ .get("/snapshots/:id", async (c) => {
26
+ const row = await sellabilityService.getSnapshotById(c.get("db"), c.req.param("id"));
27
+ if (!row)
28
+ return c.json({ error: "Sellability snapshot not found" }, 404);
29
+ return c.json({ data: row });
30
+ })
31
+ .get("/snapshot-items", async (c) => {
32
+ const query = sellabilitySnapshotItemListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
33
+ return c.json(await sellabilityService.listSnapshotItems(c.get("db"), query));
34
+ })
35
+ .get("/policies", async (c) => {
36
+ const query = sellabilityPolicyListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
37
+ return c.json(await sellabilityService.listPolicies(c.get("db"), query));
38
+ })
39
+ .post("/policies", async (c) => {
40
+ return c.json({
41
+ data: await sellabilityService.createPolicy(c.get("db"), insertSellabilityPolicySchema.parse(await c.req.json())),
42
+ }, 201);
43
+ })
44
+ .get("/policies/:id", async (c) => {
45
+ const row = await sellabilityService.getPolicyById(c.get("db"), c.req.param("id"));
46
+ if (!row)
47
+ return c.json({ error: "Sellability policy not found" }, 404);
48
+ return c.json({ data: row });
49
+ })
50
+ .patch("/policies/:id", async (c) => {
51
+ const row = await sellabilityService.updatePolicy(c.get("db"), c.req.param("id"), updateSellabilityPolicySchema.parse(await c.req.json()));
52
+ if (!row)
53
+ return c.json({ error: "Sellability policy not found" }, 404);
54
+ return c.json({ data: row });
55
+ })
56
+ .delete("/policies/:id", async (c) => {
57
+ const row = await sellabilityService.deletePolicy(c.get("db"), c.req.param("id"));
58
+ if (!row)
59
+ return c.json({ error: "Sellability policy not found" }, 404);
60
+ return c.json({ success: true });
61
+ })
62
+ .get("/policy-results", async (c) => {
63
+ const query = sellabilityPolicyResultListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
64
+ return c.json(await sellabilityService.listPolicyResults(c.get("db"), query));
65
+ })
66
+ .post("/policy-results", async (c) => {
67
+ return c.json({
68
+ data: await sellabilityService.createPolicyResult(c.get("db"), insertSellabilityPolicyResultSchema.parse(await c.req.json())),
69
+ }, 201);
70
+ })
71
+ .get("/policy-results/:id", async (c) => {
72
+ const row = await sellabilityService.getPolicyResultById(c.get("db"), c.req.param("id"));
73
+ if (!row)
74
+ return c.json({ error: "Sellability policy result not found" }, 404);
75
+ return c.json({ data: row });
76
+ })
77
+ .patch("/policy-results/:id", async (c) => {
78
+ const row = await sellabilityService.updatePolicyResult(c.get("db"), c.req.param("id"), updateSellabilityPolicyResultSchema.parse(await c.req.json()));
79
+ if (!row)
80
+ return c.json({ error: "Sellability policy result not found" }, 404);
81
+ return c.json({ data: row });
82
+ })
83
+ .delete("/policy-results/:id", async (c) => {
84
+ const row = await sellabilityService.deletePolicyResult(c.get("db"), c.req.param("id"));
85
+ if (!row)
86
+ return c.json({ error: "Sellability policy result not found" }, 404);
87
+ return c.json({ success: true });
88
+ })
89
+ .get("/offer-refresh-runs", async (c) => {
90
+ const query = offerRefreshRunListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
91
+ return c.json(await sellabilityService.listOfferRefreshRuns(c.get("db"), query));
92
+ })
93
+ .post("/offer-refresh-runs", async (c) => {
94
+ return c.json({
95
+ data: await sellabilityService.createOfferRefreshRun(c.get("db"), insertOfferRefreshRunSchema.parse(await c.req.json())),
96
+ }, 201);
97
+ })
98
+ .get("/offer-refresh-runs/:id", async (c) => {
99
+ const row = await sellabilityService.getOfferRefreshRunById(c.get("db"), c.req.param("id"));
100
+ if (!row)
101
+ return c.json({ error: "Offer refresh run not found" }, 404);
102
+ return c.json({ data: row });
103
+ })
104
+ .patch("/offer-refresh-runs/:id", async (c) => {
105
+ const row = await sellabilityService.updateOfferRefreshRun(c.get("db"), c.req.param("id"), updateOfferRefreshRunSchema.parse(await c.req.json()));
106
+ if (!row)
107
+ return c.json({ error: "Offer refresh run not found" }, 404);
108
+ return c.json({ data: row });
109
+ })
110
+ .delete("/offer-refresh-runs/:id", async (c) => {
111
+ const row = await sellabilityService.deleteOfferRefreshRun(c.get("db"), c.req.param("id"));
112
+ if (!row)
113
+ return c.json({ error: "Offer refresh run not found" }, 404);
114
+ return c.json({ success: true });
115
+ })
116
+ .get("/offer-expiration-events", async (c) => {
117
+ const query = offerExpirationEventListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
118
+ return c.json(await sellabilityService.listOfferExpirationEvents(c.get("db"), query));
119
+ })
120
+ .post("/offer-expiration-events", async (c) => {
121
+ return c.json({
122
+ data: await sellabilityService.createOfferExpirationEvent(c.get("db"), insertOfferExpirationEventSchema.parse(await c.req.json())),
123
+ }, 201);
124
+ })
125
+ .get("/offer-expiration-events/:id", async (c) => {
126
+ const row = await sellabilityService.getOfferExpirationEventById(c.get("db"), c.req.param("id"));
127
+ if (!row)
128
+ return c.json({ error: "Offer expiration event not found" }, 404);
129
+ return c.json({ data: row });
130
+ })
131
+ .patch("/offer-expiration-events/:id", async (c) => {
132
+ const row = await sellabilityService.updateOfferExpirationEvent(c.get("db"), c.req.param("id"), updateOfferExpirationEventSchema.parse(await c.req.json()));
133
+ if (!row)
134
+ return c.json({ error: "Offer expiration event not found" }, 404);
135
+ return c.json({ data: row });
136
+ })
137
+ .delete("/offer-expiration-events/:id", async (c) => {
138
+ const row = await sellabilityService.deleteOfferExpirationEvent(c.get("db"), c.req.param("id"));
139
+ if (!row)
140
+ return c.json({ error: "Offer expiration event not found" }, 404);
141
+ return c.json({ success: true });
142
+ })
143
+ .get("/explanations", async (c) => {
144
+ const query = sellabilityExplanationListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
145
+ return c.json(await sellabilityService.listExplanations(c.get("db"), query));
146
+ })
147
+ .post("/explanations", async (c) => {
148
+ return c.json({
149
+ data: await sellabilityService.createExplanation(c.get("db"), insertSellabilityExplanationSchema.parse(await c.req.json())),
150
+ }, 201);
151
+ })
152
+ .get("/explanations/:id", async (c) => {
153
+ const row = await sellabilityService.getExplanationById(c.get("db"), c.req.param("id"));
154
+ if (!row)
155
+ return c.json({ error: "Sellability explanation not found" }, 404);
156
+ return c.json({ data: row });
157
+ })
158
+ .patch("/explanations/:id", async (c) => {
159
+ const row = await sellabilityService.updateExplanation(c.get("db"), c.req.param("id"), updateSellabilityExplanationSchema.parse(await c.req.json()));
160
+ if (!row)
161
+ return c.json({ error: "Sellability explanation not found" }, 404);
162
+ return c.json({ data: row });
163
+ })
164
+ .delete("/explanations/:id", async (c) => {
165
+ const row = await sellabilityService.deleteExplanation(c.get("db"), c.req.param("id"));
166
+ if (!row)
167
+ return c.json({ error: "Sellability explanation not found" }, 404);
168
+ return c.json({ success: true });
169
+ });