@voyantjs/distribution 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 +34 -0
- package/dist/booking-extension.d.ts +168 -0
- package/dist/booking-extension.d.ts.map +1 -0
- package/dist/booking-extension.js +101 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/routes.d.ts +3756 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +760 -0
- package/dist/schema.d.ts +4138 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +760 -0
- package/dist/service.d.ts +1369 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +1251 -0
- package/dist/validation.d.ts +1366 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +444 -0
- package/package.json +59 -0
package/dist/routes.js
ADDED
|
@@ -0,0 +1,760 @@
|
|
|
1
|
+
import { insertContactPointForEntitySchema, insertNamedContactForEntitySchema, updateContactPointSchema as updateIdentityContactPointSchema, updateNamedContactSchema as updateIdentityNamedContactSchema, } from "@voyantjs/identity/validation";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { distributionService } from "./service.js";
|
|
5
|
+
import { channelBookingLinkListQuerySchema, channelCommissionRuleListQuerySchema, channelContractListQuerySchema, channelInventoryAllotmentListQuerySchema, channelInventoryAllotmentTargetListQuerySchema, channelInventoryReleaseExecutionListQuerySchema, channelInventoryReleaseRuleListQuerySchema, channelListQuerySchema, channelProductMappingListQuerySchema, channelReconciliationItemListQuerySchema, channelReconciliationPolicyListQuerySchema, channelReconciliationRunListQuerySchema, channelReleaseScheduleListQuerySchema, channelRemittanceExceptionListQuerySchema, channelSettlementApprovalListQuerySchema, channelSettlementItemListQuerySchema, channelSettlementPolicyListQuerySchema, channelSettlementRunListQuerySchema, channelWebhookEventListQuerySchema, insertChannelBookingLinkSchema, insertChannelCommissionRuleSchema, insertChannelContractSchema, insertChannelInventoryAllotmentSchema, insertChannelInventoryAllotmentTargetSchema, insertChannelInventoryReleaseExecutionSchema, insertChannelInventoryReleaseRuleSchema, insertChannelProductMappingSchema, insertChannelReconciliationItemSchema, insertChannelReconciliationPolicySchema, insertChannelReconciliationRunSchema, insertChannelReleaseScheduleSchema, insertChannelRemittanceExceptionSchema, insertChannelSchema, insertChannelSettlementApprovalSchema, insertChannelSettlementItemSchema, insertChannelSettlementPolicySchema, insertChannelSettlementRunSchema, insertChannelWebhookEventSchema, updateChannelBookingLinkSchema, updateChannelCommissionRuleSchema, updateChannelContractSchema, updateChannelInventoryAllotmentSchema, updateChannelInventoryAllotmentTargetSchema, updateChannelInventoryReleaseExecutionSchema, updateChannelInventoryReleaseRuleSchema, updateChannelProductMappingSchema, updateChannelReconciliationItemSchema, updateChannelReconciliationPolicySchema, updateChannelReconciliationRunSchema, updateChannelReleaseScheduleSchema, updateChannelRemittanceExceptionSchema, updateChannelSchema, updateChannelSettlementApprovalSchema, updateChannelSettlementItemSchema, updateChannelSettlementPolicySchema, updateChannelSettlementRunSchema, updateChannelWebhookEventSchema, } from "./validation.js";
|
|
6
|
+
const batchIdsSchema = z.object({
|
|
7
|
+
ids: z.array(z.string()).min(1).max(200),
|
|
8
|
+
});
|
|
9
|
+
const createBatchUpdateSchema = (patchSchema) => z.object({
|
|
10
|
+
ids: batchIdsSchema.shape.ids,
|
|
11
|
+
patch: patchSchema.refine((value) => Object.keys(value).length > 0, {
|
|
12
|
+
message: "Patch payload is required",
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
const batchUpdateChannelSchema = createBatchUpdateSchema(updateChannelSchema);
|
|
16
|
+
const batchUpdateChannelContractSchema = createBatchUpdateSchema(updateChannelContractSchema);
|
|
17
|
+
const batchUpdateChannelCommissionRuleSchema = createBatchUpdateSchema(updateChannelCommissionRuleSchema);
|
|
18
|
+
const batchUpdateChannelProductMappingSchema = createBatchUpdateSchema(updateChannelProductMappingSchema);
|
|
19
|
+
const batchUpdateChannelBookingLinkSchema = createBatchUpdateSchema(updateChannelBookingLinkSchema);
|
|
20
|
+
const batchUpdateChannelWebhookEventSchema = createBatchUpdateSchema(updateChannelWebhookEventSchema);
|
|
21
|
+
const batchUpdateChannelInventoryAllotmentSchema = createBatchUpdateSchema(updateChannelInventoryAllotmentSchema);
|
|
22
|
+
const batchUpdateChannelInventoryAllotmentTargetSchema = createBatchUpdateSchema(updateChannelInventoryAllotmentTargetSchema);
|
|
23
|
+
const batchUpdateChannelInventoryReleaseRuleSchema = createBatchUpdateSchema(updateChannelInventoryReleaseRuleSchema);
|
|
24
|
+
async function handleBatchUpdate({ db, ids, patch, update, }) {
|
|
25
|
+
const results = await Promise.all(ids.map(async (id) => {
|
|
26
|
+
const row = await update(db, id, patch);
|
|
27
|
+
return row ? { id, row } : { id, row: null };
|
|
28
|
+
}));
|
|
29
|
+
const data = results.flatMap((result) => (result.row ? [result.row] : []));
|
|
30
|
+
const failed = results
|
|
31
|
+
.filter((result) => result.row === null)
|
|
32
|
+
.map((result) => ({ id: result.id, error: "Not found" }));
|
|
33
|
+
return {
|
|
34
|
+
data,
|
|
35
|
+
total: ids.length,
|
|
36
|
+
succeeded: data.length,
|
|
37
|
+
failed,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
async function handleBatchDelete({ db, ids, remove, }) {
|
|
41
|
+
const results = await Promise.all(ids.map(async (id) => {
|
|
42
|
+
const row = await remove(db, id);
|
|
43
|
+
return row ? { id } : { id, error: "Not found" };
|
|
44
|
+
}));
|
|
45
|
+
const deletedIds = results.flatMap((result) => ("error" in result ? [] : [result.id]));
|
|
46
|
+
const failed = results
|
|
47
|
+
.filter((result) => "error" in result)
|
|
48
|
+
.map((result) => ({ id: result.id, error: result.error }));
|
|
49
|
+
return {
|
|
50
|
+
deletedIds,
|
|
51
|
+
total: ids.length,
|
|
52
|
+
succeeded: deletedIds.length,
|
|
53
|
+
failed,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export const distributionRoutes = new Hono()
|
|
57
|
+
.get("/channels", async (c) => {
|
|
58
|
+
const query = channelListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
59
|
+
return c.json(await distributionService.listChannels(c.get("db"), query));
|
|
60
|
+
})
|
|
61
|
+
.post("/channels", async (c) => {
|
|
62
|
+
return c.json({
|
|
63
|
+
data: await distributionService.createChannel(c.get("db"), insertChannelSchema.parse(await c.req.json())),
|
|
64
|
+
}, 201);
|
|
65
|
+
})
|
|
66
|
+
.post("/channels/batch-update", async (c) => {
|
|
67
|
+
const body = batchUpdateChannelSchema.parse(await c.req.json());
|
|
68
|
+
return c.json(await handleBatchUpdate({
|
|
69
|
+
db: c.get("db"),
|
|
70
|
+
ids: body.ids,
|
|
71
|
+
patch: body.patch,
|
|
72
|
+
update: distributionService.updateChannel.bind(distributionService),
|
|
73
|
+
}));
|
|
74
|
+
})
|
|
75
|
+
.post("/channels/batch-delete", async (c) => {
|
|
76
|
+
const body = batchIdsSchema.parse(await c.req.json());
|
|
77
|
+
return c.json(await handleBatchDelete({
|
|
78
|
+
db: c.get("db"),
|
|
79
|
+
ids: body.ids,
|
|
80
|
+
remove: distributionService.deleteChannel,
|
|
81
|
+
}));
|
|
82
|
+
})
|
|
83
|
+
.get("/channels/:id", async (c) => {
|
|
84
|
+
const row = await distributionService.getChannelById(c.get("db"), c.req.param("id"));
|
|
85
|
+
if (!row)
|
|
86
|
+
return c.json({ error: "Channel not found" }, 404);
|
|
87
|
+
return c.json({ data: row });
|
|
88
|
+
})
|
|
89
|
+
.patch("/channels/:id", async (c) => {
|
|
90
|
+
const row = await distributionService.updateChannel(c.get("db"), c.req.param("id"), updateChannelSchema.parse(await c.req.json()));
|
|
91
|
+
if (!row)
|
|
92
|
+
return c.json({ error: "Channel not found" }, 404);
|
|
93
|
+
return c.json({ data: row });
|
|
94
|
+
})
|
|
95
|
+
.delete("/channels/:id", async (c) => {
|
|
96
|
+
const row = await distributionService.deleteChannel(c.get("db"), c.req.param("id"));
|
|
97
|
+
if (!row)
|
|
98
|
+
return c.json({ error: "Channel not found" }, 404);
|
|
99
|
+
return c.json({ success: true });
|
|
100
|
+
})
|
|
101
|
+
.get("/channels/:id/contact-points", async (c) => {
|
|
102
|
+
const rows = await distributionService.listChannelContactPoints(c.get("db"), c.req.param("id"));
|
|
103
|
+
if (!rows)
|
|
104
|
+
return c.json({ error: "Channel not found" }, 404);
|
|
105
|
+
return c.json({ data: rows });
|
|
106
|
+
})
|
|
107
|
+
.post("/channels/:id/contact-points", async (c) => {
|
|
108
|
+
const row = await distributionService.createChannelContactPoint(c.get("db"), c.req.param("id"), insertContactPointForEntitySchema.parse(await c.req.json()));
|
|
109
|
+
if (!row)
|
|
110
|
+
return c.json({ error: "Channel not found" }, 404);
|
|
111
|
+
return c.json({ data: row }, 201);
|
|
112
|
+
})
|
|
113
|
+
.patch("/channel-contact-points/:contactPointId", async (c) => {
|
|
114
|
+
const row = await distributionService.updateChannelContactPoint(c.get("db"), c.req.param("contactPointId"), updateIdentityContactPointSchema.parse(await c.req.json()));
|
|
115
|
+
if (!row)
|
|
116
|
+
return c.json({ error: "Channel contact point not found" }, 404);
|
|
117
|
+
return c.json({ data: row });
|
|
118
|
+
})
|
|
119
|
+
.delete("/channel-contact-points/:contactPointId", async (c) => {
|
|
120
|
+
const row = await distributionService.deleteChannelContactPoint(c.get("db"), c.req.param("contactPointId"));
|
|
121
|
+
if (!row)
|
|
122
|
+
return c.json({ error: "Channel contact point not found" }, 404);
|
|
123
|
+
return c.json({ success: true });
|
|
124
|
+
})
|
|
125
|
+
.get("/channels/:id/contacts", async (c) => {
|
|
126
|
+
const rows = await distributionService.listChannelContacts(c.get("db"), c.req.param("id"));
|
|
127
|
+
if (!rows)
|
|
128
|
+
return c.json({ error: "Channel not found" }, 404);
|
|
129
|
+
return c.json({ data: rows });
|
|
130
|
+
})
|
|
131
|
+
.post("/channels/:id/contacts", async (c) => {
|
|
132
|
+
const row = await distributionService.createChannelContact(c.get("db"), c.req.param("id"), insertNamedContactForEntitySchema.parse(await c.req.json()));
|
|
133
|
+
if (!row)
|
|
134
|
+
return c.json({ error: "Channel not found" }, 404);
|
|
135
|
+
return c.json({ data: row }, 201);
|
|
136
|
+
})
|
|
137
|
+
.patch("/channel-contacts/:contactId", async (c) => {
|
|
138
|
+
const row = await distributionService.updateChannelContact(c.get("db"), c.req.param("contactId"), updateIdentityNamedContactSchema.parse(await c.req.json()));
|
|
139
|
+
if (!row)
|
|
140
|
+
return c.json({ error: "Channel contact not found" }, 404);
|
|
141
|
+
return c.json({ data: row });
|
|
142
|
+
})
|
|
143
|
+
.delete("/channel-contacts/:contactId", async (c) => {
|
|
144
|
+
const row = await distributionService.deleteChannelContact(c.get("db"), c.req.param("contactId"));
|
|
145
|
+
if (!row)
|
|
146
|
+
return c.json({ error: "Channel contact not found" }, 404);
|
|
147
|
+
return c.json({ success: true });
|
|
148
|
+
})
|
|
149
|
+
.get("/contracts", async (c) => {
|
|
150
|
+
const query = channelContractListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
151
|
+
return c.json(await distributionService.listContracts(c.get("db"), query));
|
|
152
|
+
})
|
|
153
|
+
.post("/contracts", async (c) => {
|
|
154
|
+
return c.json({
|
|
155
|
+
data: await distributionService.createContract(c.get("db"), insertChannelContractSchema.parse(await c.req.json())),
|
|
156
|
+
}, 201);
|
|
157
|
+
})
|
|
158
|
+
.post("/contracts/batch-update", async (c) => {
|
|
159
|
+
const body = batchUpdateChannelContractSchema.parse(await c.req.json());
|
|
160
|
+
return c.json(await handleBatchUpdate({
|
|
161
|
+
db: c.get("db"),
|
|
162
|
+
ids: body.ids,
|
|
163
|
+
patch: body.patch,
|
|
164
|
+
update: distributionService.updateContract,
|
|
165
|
+
}));
|
|
166
|
+
})
|
|
167
|
+
.post("/contracts/batch-delete", async (c) => {
|
|
168
|
+
const body = batchIdsSchema.parse(await c.req.json());
|
|
169
|
+
return c.json(await handleBatchDelete({
|
|
170
|
+
db: c.get("db"),
|
|
171
|
+
ids: body.ids,
|
|
172
|
+
remove: distributionService.deleteContract,
|
|
173
|
+
}));
|
|
174
|
+
})
|
|
175
|
+
.get("/contracts/:id", async (c) => {
|
|
176
|
+
const row = await distributionService.getContractById(c.get("db"), c.req.param("id"));
|
|
177
|
+
if (!row)
|
|
178
|
+
return c.json({ error: "Channel contract not found" }, 404);
|
|
179
|
+
return c.json({ data: row });
|
|
180
|
+
})
|
|
181
|
+
.patch("/contracts/:id", async (c) => {
|
|
182
|
+
const row = await distributionService.updateContract(c.get("db"), c.req.param("id"), updateChannelContractSchema.parse(await c.req.json()));
|
|
183
|
+
if (!row)
|
|
184
|
+
return c.json({ error: "Channel contract not found" }, 404);
|
|
185
|
+
return c.json({ data: row });
|
|
186
|
+
})
|
|
187
|
+
.delete("/contracts/:id", async (c) => {
|
|
188
|
+
const row = await distributionService.deleteContract(c.get("db"), c.req.param("id"));
|
|
189
|
+
if (!row)
|
|
190
|
+
return c.json({ error: "Channel contract not found" }, 404);
|
|
191
|
+
return c.json({ success: true });
|
|
192
|
+
})
|
|
193
|
+
.get("/commission-rules", async (c) => {
|
|
194
|
+
const query = channelCommissionRuleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
195
|
+
return c.json(await distributionService.listCommissionRules(c.get("db"), query));
|
|
196
|
+
})
|
|
197
|
+
.post("/commission-rules", async (c) => {
|
|
198
|
+
return c.json({
|
|
199
|
+
data: await distributionService.createCommissionRule(c.get("db"), insertChannelCommissionRuleSchema.parse(await c.req.json())),
|
|
200
|
+
}, 201);
|
|
201
|
+
})
|
|
202
|
+
.post("/commission-rules/batch-update", async (c) => {
|
|
203
|
+
const body = batchUpdateChannelCommissionRuleSchema.parse(await c.req.json());
|
|
204
|
+
return c.json(await handleBatchUpdate({
|
|
205
|
+
db: c.get("db"),
|
|
206
|
+
ids: body.ids,
|
|
207
|
+
patch: body.patch,
|
|
208
|
+
update: distributionService.updateCommissionRule,
|
|
209
|
+
}));
|
|
210
|
+
})
|
|
211
|
+
.post("/commission-rules/batch-delete", async (c) => {
|
|
212
|
+
const body = batchIdsSchema.parse(await c.req.json());
|
|
213
|
+
return c.json(await handleBatchDelete({
|
|
214
|
+
db: c.get("db"),
|
|
215
|
+
ids: body.ids,
|
|
216
|
+
remove: distributionService.deleteCommissionRule,
|
|
217
|
+
}));
|
|
218
|
+
})
|
|
219
|
+
.get("/commission-rules/:id", async (c) => {
|
|
220
|
+
const row = await distributionService.getCommissionRuleById(c.get("db"), c.req.param("id"));
|
|
221
|
+
if (!row)
|
|
222
|
+
return c.json({ error: "Channel commission rule not found" }, 404);
|
|
223
|
+
return c.json({ data: row });
|
|
224
|
+
})
|
|
225
|
+
.patch("/commission-rules/:id", async (c) => {
|
|
226
|
+
const row = await distributionService.updateCommissionRule(c.get("db"), c.req.param("id"), updateChannelCommissionRuleSchema.parse(await c.req.json()));
|
|
227
|
+
if (!row)
|
|
228
|
+
return c.json({ error: "Channel commission rule not found" }, 404);
|
|
229
|
+
return c.json({ data: row });
|
|
230
|
+
})
|
|
231
|
+
.delete("/commission-rules/:id", async (c) => {
|
|
232
|
+
const row = await distributionService.deleteCommissionRule(c.get("db"), c.req.param("id"));
|
|
233
|
+
if (!row)
|
|
234
|
+
return c.json({ error: "Channel commission rule not found" }, 404);
|
|
235
|
+
return c.json({ success: true });
|
|
236
|
+
})
|
|
237
|
+
.get("/product-mappings", async (c) => {
|
|
238
|
+
const query = channelProductMappingListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
239
|
+
return c.json(await distributionService.listProductMappings(c.get("db"), query));
|
|
240
|
+
})
|
|
241
|
+
.post("/product-mappings", async (c) => {
|
|
242
|
+
return c.json({
|
|
243
|
+
data: await distributionService.createProductMapping(c.get("db"), insertChannelProductMappingSchema.parse(await c.req.json())),
|
|
244
|
+
}, 201);
|
|
245
|
+
})
|
|
246
|
+
.post("/product-mappings/batch-update", async (c) => {
|
|
247
|
+
const body = batchUpdateChannelProductMappingSchema.parse(await c.req.json());
|
|
248
|
+
return c.json(await handleBatchUpdate({
|
|
249
|
+
db: c.get("db"),
|
|
250
|
+
ids: body.ids,
|
|
251
|
+
patch: body.patch,
|
|
252
|
+
update: distributionService.updateProductMapping,
|
|
253
|
+
}));
|
|
254
|
+
})
|
|
255
|
+
.post("/product-mappings/batch-delete", async (c) => {
|
|
256
|
+
const body = batchIdsSchema.parse(await c.req.json());
|
|
257
|
+
return c.json(await handleBatchDelete({
|
|
258
|
+
db: c.get("db"),
|
|
259
|
+
ids: body.ids,
|
|
260
|
+
remove: distributionService.deleteProductMapping,
|
|
261
|
+
}));
|
|
262
|
+
})
|
|
263
|
+
.get("/product-mappings/:id", async (c) => {
|
|
264
|
+
const row = await distributionService.getProductMappingById(c.get("db"), c.req.param("id"));
|
|
265
|
+
if (!row)
|
|
266
|
+
return c.json({ error: "Channel product mapping not found" }, 404);
|
|
267
|
+
return c.json({ data: row });
|
|
268
|
+
})
|
|
269
|
+
.patch("/product-mappings/:id", async (c) => {
|
|
270
|
+
const row = await distributionService.updateProductMapping(c.get("db"), c.req.param("id"), updateChannelProductMappingSchema.parse(await c.req.json()));
|
|
271
|
+
if (!row)
|
|
272
|
+
return c.json({ error: "Channel product mapping not found" }, 404);
|
|
273
|
+
return c.json({ data: row });
|
|
274
|
+
})
|
|
275
|
+
.delete("/product-mappings/:id", async (c) => {
|
|
276
|
+
const row = await distributionService.deleteProductMapping(c.get("db"), c.req.param("id"));
|
|
277
|
+
if (!row)
|
|
278
|
+
return c.json({ error: "Channel product mapping not found" }, 404);
|
|
279
|
+
return c.json({ success: true });
|
|
280
|
+
})
|
|
281
|
+
.get("/booking-links", async (c) => {
|
|
282
|
+
const query = channelBookingLinkListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
283
|
+
return c.json(await distributionService.listBookingLinks(c.get("db"), query));
|
|
284
|
+
})
|
|
285
|
+
.post("/booking-links", async (c) => {
|
|
286
|
+
return c.json({
|
|
287
|
+
data: await distributionService.createBookingLink(c.get("db"), insertChannelBookingLinkSchema.parse(await c.req.json())),
|
|
288
|
+
}, 201);
|
|
289
|
+
})
|
|
290
|
+
.post("/booking-links/batch-update", async (c) => {
|
|
291
|
+
const body = batchUpdateChannelBookingLinkSchema.parse(await c.req.json());
|
|
292
|
+
return c.json(await handleBatchUpdate({
|
|
293
|
+
db: c.get("db"),
|
|
294
|
+
ids: body.ids,
|
|
295
|
+
patch: body.patch,
|
|
296
|
+
update: distributionService.updateBookingLink,
|
|
297
|
+
}));
|
|
298
|
+
})
|
|
299
|
+
.post("/booking-links/batch-delete", async (c) => {
|
|
300
|
+
const body = batchIdsSchema.parse(await c.req.json());
|
|
301
|
+
return c.json(await handleBatchDelete({
|
|
302
|
+
db: c.get("db"),
|
|
303
|
+
ids: body.ids,
|
|
304
|
+
remove: distributionService.deleteBookingLink,
|
|
305
|
+
}));
|
|
306
|
+
})
|
|
307
|
+
.get("/booking-links/:id", async (c) => {
|
|
308
|
+
const row = await distributionService.getBookingLinkById(c.get("db"), c.req.param("id"));
|
|
309
|
+
if (!row)
|
|
310
|
+
return c.json({ error: "Channel booking link not found" }, 404);
|
|
311
|
+
return c.json({ data: row });
|
|
312
|
+
})
|
|
313
|
+
.patch("/booking-links/:id", async (c) => {
|
|
314
|
+
const row = await distributionService.updateBookingLink(c.get("db"), c.req.param("id"), updateChannelBookingLinkSchema.parse(await c.req.json()));
|
|
315
|
+
if (!row)
|
|
316
|
+
return c.json({ error: "Channel booking link not found" }, 404);
|
|
317
|
+
return c.json({ data: row });
|
|
318
|
+
})
|
|
319
|
+
.delete("/booking-links/:id", async (c) => {
|
|
320
|
+
const row = await distributionService.deleteBookingLink(c.get("db"), c.req.param("id"));
|
|
321
|
+
if (!row)
|
|
322
|
+
return c.json({ error: "Channel booking link not found" }, 404);
|
|
323
|
+
return c.json({ success: true });
|
|
324
|
+
})
|
|
325
|
+
.get("/webhook-events", async (c) => {
|
|
326
|
+
const query = channelWebhookEventListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
327
|
+
return c.json(await distributionService.listWebhookEvents(c.get("db"), query));
|
|
328
|
+
})
|
|
329
|
+
.post("/webhook-events", async (c) => {
|
|
330
|
+
return c.json({
|
|
331
|
+
data: await distributionService.createWebhookEvent(c.get("db"), insertChannelWebhookEventSchema.parse(await c.req.json())),
|
|
332
|
+
}, 201);
|
|
333
|
+
})
|
|
334
|
+
.post("/webhook-events/batch-update", async (c) => {
|
|
335
|
+
const body = batchUpdateChannelWebhookEventSchema.parse(await c.req.json());
|
|
336
|
+
return c.json(await handleBatchUpdate({
|
|
337
|
+
db: c.get("db"),
|
|
338
|
+
ids: body.ids,
|
|
339
|
+
patch: body.patch,
|
|
340
|
+
update: distributionService.updateWebhookEvent,
|
|
341
|
+
}));
|
|
342
|
+
})
|
|
343
|
+
.post("/webhook-events/batch-delete", async (c) => {
|
|
344
|
+
const body = batchIdsSchema.parse(await c.req.json());
|
|
345
|
+
return c.json(await handleBatchDelete({
|
|
346
|
+
db: c.get("db"),
|
|
347
|
+
ids: body.ids,
|
|
348
|
+
remove: distributionService.deleteWebhookEvent,
|
|
349
|
+
}));
|
|
350
|
+
})
|
|
351
|
+
.get("/webhook-events/:id", async (c) => {
|
|
352
|
+
const row = await distributionService.getWebhookEventById(c.get("db"), c.req.param("id"));
|
|
353
|
+
if (!row)
|
|
354
|
+
return c.json({ error: "Channel webhook event not found" }, 404);
|
|
355
|
+
return c.json({ data: row });
|
|
356
|
+
})
|
|
357
|
+
.patch("/webhook-events/:id", async (c) => {
|
|
358
|
+
const row = await distributionService.updateWebhookEvent(c.get("db"), c.req.param("id"), updateChannelWebhookEventSchema.parse(await c.req.json()));
|
|
359
|
+
if (!row)
|
|
360
|
+
return c.json({ error: "Channel webhook event not found" }, 404);
|
|
361
|
+
return c.json({ data: row });
|
|
362
|
+
})
|
|
363
|
+
.delete("/webhook-events/:id", async (c) => {
|
|
364
|
+
const row = await distributionService.deleteWebhookEvent(c.get("db"), c.req.param("id"));
|
|
365
|
+
if (!row)
|
|
366
|
+
return c.json({ error: "Channel webhook event not found" }, 404);
|
|
367
|
+
return c.json({ success: true });
|
|
368
|
+
})
|
|
369
|
+
.get("/inventory-allotments", async (c) => {
|
|
370
|
+
const query = channelInventoryAllotmentListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
371
|
+
return c.json(await distributionService.listInventoryAllotments(c.get("db"), query));
|
|
372
|
+
})
|
|
373
|
+
.post("/inventory-allotments", async (c) => {
|
|
374
|
+
return c.json({
|
|
375
|
+
data: await distributionService.createInventoryAllotment(c.get("db"), insertChannelInventoryAllotmentSchema.parse(await c.req.json())),
|
|
376
|
+
}, 201);
|
|
377
|
+
})
|
|
378
|
+
.post("/inventory-allotments/batch-update", async (c) => {
|
|
379
|
+
const body = batchUpdateChannelInventoryAllotmentSchema.parse(await c.req.json());
|
|
380
|
+
return c.json(await handleBatchUpdate({
|
|
381
|
+
db: c.get("db"),
|
|
382
|
+
ids: body.ids,
|
|
383
|
+
patch: body.patch,
|
|
384
|
+
update: distributionService.updateInventoryAllotment,
|
|
385
|
+
}));
|
|
386
|
+
})
|
|
387
|
+
.post("/inventory-allotments/batch-delete", async (c) => {
|
|
388
|
+
const body = batchIdsSchema.parse(await c.req.json());
|
|
389
|
+
return c.json(await handleBatchDelete({
|
|
390
|
+
db: c.get("db"),
|
|
391
|
+
ids: body.ids,
|
|
392
|
+
remove: distributionService.deleteInventoryAllotment,
|
|
393
|
+
}));
|
|
394
|
+
})
|
|
395
|
+
.get("/inventory-allotments/:id", async (c) => {
|
|
396
|
+
const row = await distributionService.getInventoryAllotmentById(c.get("db"), c.req.param("id"));
|
|
397
|
+
if (!row)
|
|
398
|
+
return c.json({ error: "Channel inventory allotment not found" }, 404);
|
|
399
|
+
return c.json({ data: row });
|
|
400
|
+
})
|
|
401
|
+
.patch("/inventory-allotments/:id", async (c) => {
|
|
402
|
+
const row = await distributionService.updateInventoryAllotment(c.get("db"), c.req.param("id"), updateChannelInventoryAllotmentSchema.parse(await c.req.json()));
|
|
403
|
+
if (!row)
|
|
404
|
+
return c.json({ error: "Channel inventory allotment not found" }, 404);
|
|
405
|
+
return c.json({ data: row });
|
|
406
|
+
})
|
|
407
|
+
.delete("/inventory-allotments/:id", async (c) => {
|
|
408
|
+
const row = await distributionService.deleteInventoryAllotment(c.get("db"), c.req.param("id"));
|
|
409
|
+
if (!row)
|
|
410
|
+
return c.json({ error: "Channel inventory allotment not found" }, 404);
|
|
411
|
+
return c.json({ success: true });
|
|
412
|
+
})
|
|
413
|
+
.get("/inventory-allotment-targets", async (c) => {
|
|
414
|
+
const query = channelInventoryAllotmentTargetListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
415
|
+
return c.json(await distributionService.listInventoryAllotmentTargets(c.get("db"), query));
|
|
416
|
+
})
|
|
417
|
+
.post("/inventory-allotment-targets", async (c) => {
|
|
418
|
+
return c.json({
|
|
419
|
+
data: await distributionService.createInventoryAllotmentTarget(c.get("db"), insertChannelInventoryAllotmentTargetSchema.parse(await c.req.json())),
|
|
420
|
+
}, 201);
|
|
421
|
+
})
|
|
422
|
+
.post("/inventory-allotment-targets/batch-update", async (c) => {
|
|
423
|
+
const body = batchUpdateChannelInventoryAllotmentTargetSchema.parse(await c.req.json());
|
|
424
|
+
return c.json(await handleBatchUpdate({
|
|
425
|
+
db: c.get("db"),
|
|
426
|
+
ids: body.ids,
|
|
427
|
+
patch: body.patch,
|
|
428
|
+
update: distributionService.updateInventoryAllotmentTarget,
|
|
429
|
+
}));
|
|
430
|
+
})
|
|
431
|
+
.post("/inventory-allotment-targets/batch-delete", async (c) => {
|
|
432
|
+
const body = batchIdsSchema.parse(await c.req.json());
|
|
433
|
+
return c.json(await handleBatchDelete({
|
|
434
|
+
db: c.get("db"),
|
|
435
|
+
ids: body.ids,
|
|
436
|
+
remove: distributionService.deleteInventoryAllotmentTarget,
|
|
437
|
+
}));
|
|
438
|
+
})
|
|
439
|
+
.get("/inventory-allotment-targets/:id", async (c) => {
|
|
440
|
+
const row = await distributionService.getInventoryAllotmentTargetById(c.get("db"), c.req.param("id"));
|
|
441
|
+
if (!row)
|
|
442
|
+
return c.json({ error: "Channel inventory allotment target not found" }, 404);
|
|
443
|
+
return c.json({ data: row });
|
|
444
|
+
})
|
|
445
|
+
.patch("/inventory-allotment-targets/:id", async (c) => {
|
|
446
|
+
const row = await distributionService.updateInventoryAllotmentTarget(c.get("db"), c.req.param("id"), updateChannelInventoryAllotmentTargetSchema.parse(await c.req.json()));
|
|
447
|
+
if (!row)
|
|
448
|
+
return c.json({ error: "Channel inventory allotment target not found" }, 404);
|
|
449
|
+
return c.json({ data: row });
|
|
450
|
+
})
|
|
451
|
+
.delete("/inventory-allotment-targets/:id", async (c) => {
|
|
452
|
+
const row = await distributionService.deleteInventoryAllotmentTarget(c.get("db"), c.req.param("id"));
|
|
453
|
+
if (!row)
|
|
454
|
+
return c.json({ error: "Channel inventory allotment target not found" }, 404);
|
|
455
|
+
return c.json({ success: true });
|
|
456
|
+
})
|
|
457
|
+
.get("/inventory-release-rules", async (c) => {
|
|
458
|
+
const query = channelInventoryReleaseRuleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
459
|
+
return c.json(await distributionService.listInventoryReleaseRules(c.get("db"), query));
|
|
460
|
+
})
|
|
461
|
+
.post("/inventory-release-rules", async (c) => {
|
|
462
|
+
return c.json({
|
|
463
|
+
data: await distributionService.createInventoryReleaseRule(c.get("db"), insertChannelInventoryReleaseRuleSchema.parse(await c.req.json())),
|
|
464
|
+
}, 201);
|
|
465
|
+
})
|
|
466
|
+
.post("/inventory-release-rules/batch-update", async (c) => {
|
|
467
|
+
const body = batchUpdateChannelInventoryReleaseRuleSchema.parse(await c.req.json());
|
|
468
|
+
return c.json(await handleBatchUpdate({
|
|
469
|
+
db: c.get("db"),
|
|
470
|
+
ids: body.ids,
|
|
471
|
+
patch: body.patch,
|
|
472
|
+
update: distributionService.updateInventoryReleaseRule,
|
|
473
|
+
}));
|
|
474
|
+
})
|
|
475
|
+
.post("/inventory-release-rules/batch-delete", async (c) => {
|
|
476
|
+
const body = batchIdsSchema.parse(await c.req.json());
|
|
477
|
+
return c.json(await handleBatchDelete({
|
|
478
|
+
db: c.get("db"),
|
|
479
|
+
ids: body.ids,
|
|
480
|
+
remove: distributionService.deleteInventoryReleaseRule,
|
|
481
|
+
}));
|
|
482
|
+
})
|
|
483
|
+
.get("/inventory-release-rules/:id", async (c) => {
|
|
484
|
+
const row = await distributionService.getInventoryReleaseRuleById(c.get("db"), c.req.param("id"));
|
|
485
|
+
if (!row)
|
|
486
|
+
return c.json({ error: "Channel inventory release rule not found" }, 404);
|
|
487
|
+
return c.json({ data: row });
|
|
488
|
+
})
|
|
489
|
+
.patch("/inventory-release-rules/:id", async (c) => {
|
|
490
|
+
const row = await distributionService.updateInventoryReleaseRule(c.get("db"), c.req.param("id"), updateChannelInventoryReleaseRuleSchema.parse(await c.req.json()));
|
|
491
|
+
if (!row)
|
|
492
|
+
return c.json({ error: "Channel inventory release rule not found" }, 404);
|
|
493
|
+
return c.json({ data: row });
|
|
494
|
+
})
|
|
495
|
+
.delete("/inventory-release-rules/:id", async (c) => {
|
|
496
|
+
const row = await distributionService.deleteInventoryReleaseRule(c.get("db"), c.req.param("id"));
|
|
497
|
+
if (!row)
|
|
498
|
+
return c.json({ error: "Channel inventory release rule not found" }, 404);
|
|
499
|
+
return c.json({ success: true });
|
|
500
|
+
})
|
|
501
|
+
.get("/settlement-runs", async (c) => {
|
|
502
|
+
const query = channelSettlementRunListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
503
|
+
return c.json(await distributionService.listSettlementRuns(c.get("db"), query));
|
|
504
|
+
})
|
|
505
|
+
.post("/settlement-runs", async (c) => {
|
|
506
|
+
return c.json({
|
|
507
|
+
data: await distributionService.createSettlementRun(c.get("db"), insertChannelSettlementRunSchema.parse(await c.req.json())),
|
|
508
|
+
}, 201);
|
|
509
|
+
})
|
|
510
|
+
.get("/settlement-runs/:id", async (c) => {
|
|
511
|
+
const row = await distributionService.getSettlementRunById(c.get("db"), c.req.param("id"));
|
|
512
|
+
if (!row)
|
|
513
|
+
return c.json({ error: "Channel settlement run not found" }, 404);
|
|
514
|
+
return c.json({ data: row });
|
|
515
|
+
})
|
|
516
|
+
.patch("/settlement-runs/:id", async (c) => {
|
|
517
|
+
const row = await distributionService.updateSettlementRun(c.get("db"), c.req.param("id"), updateChannelSettlementRunSchema.parse(await c.req.json()));
|
|
518
|
+
if (!row)
|
|
519
|
+
return c.json({ error: "Channel settlement run not found" }, 404);
|
|
520
|
+
return c.json({ data: row });
|
|
521
|
+
})
|
|
522
|
+
.delete("/settlement-runs/:id", async (c) => {
|
|
523
|
+
const row = await distributionService.deleteSettlementRun(c.get("db"), c.req.param("id"));
|
|
524
|
+
if (!row)
|
|
525
|
+
return c.json({ error: "Channel settlement run not found" }, 404);
|
|
526
|
+
return c.json({ success: true });
|
|
527
|
+
})
|
|
528
|
+
.get("/settlement-items", async (c) => {
|
|
529
|
+
const query = channelSettlementItemListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
530
|
+
return c.json(await distributionService.listSettlementItems(c.get("db"), query));
|
|
531
|
+
})
|
|
532
|
+
.post("/settlement-items", async (c) => {
|
|
533
|
+
return c.json({
|
|
534
|
+
data: await distributionService.createSettlementItem(c.get("db"), insertChannelSettlementItemSchema.parse(await c.req.json())),
|
|
535
|
+
}, 201);
|
|
536
|
+
})
|
|
537
|
+
.get("/settlement-items/:id", async (c) => {
|
|
538
|
+
const row = await distributionService.getSettlementItemById(c.get("db"), c.req.param("id"));
|
|
539
|
+
if (!row)
|
|
540
|
+
return c.json({ error: "Channel settlement item not found" }, 404);
|
|
541
|
+
return c.json({ data: row });
|
|
542
|
+
})
|
|
543
|
+
.patch("/settlement-items/:id", async (c) => {
|
|
544
|
+
const row = await distributionService.updateSettlementItem(c.get("db"), c.req.param("id"), updateChannelSettlementItemSchema.parse(await c.req.json()));
|
|
545
|
+
if (!row)
|
|
546
|
+
return c.json({ error: "Channel settlement item not found" }, 404);
|
|
547
|
+
return c.json({ data: row });
|
|
548
|
+
})
|
|
549
|
+
.delete("/settlement-items/:id", async (c) => {
|
|
550
|
+
const row = await distributionService.deleteSettlementItem(c.get("db"), c.req.param("id"));
|
|
551
|
+
if (!row)
|
|
552
|
+
return c.json({ error: "Channel settlement item not found" }, 404);
|
|
553
|
+
return c.json({ success: true });
|
|
554
|
+
})
|
|
555
|
+
.get("/reconciliation-runs", async (c) => {
|
|
556
|
+
const query = channelReconciliationRunListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
557
|
+
return c.json(await distributionService.listReconciliationRuns(c.get("db"), query));
|
|
558
|
+
})
|
|
559
|
+
.post("/reconciliation-runs", async (c) => {
|
|
560
|
+
return c.json({
|
|
561
|
+
data: await distributionService.createReconciliationRun(c.get("db"), insertChannelReconciliationRunSchema.parse(await c.req.json())),
|
|
562
|
+
}, 201);
|
|
563
|
+
})
|
|
564
|
+
.get("/reconciliation-runs/:id", async (c) => {
|
|
565
|
+
const row = await distributionService.getReconciliationRunById(c.get("db"), c.req.param("id"));
|
|
566
|
+
if (!row)
|
|
567
|
+
return c.json({ error: "Channel reconciliation run not found" }, 404);
|
|
568
|
+
return c.json({ data: row });
|
|
569
|
+
})
|
|
570
|
+
.patch("/reconciliation-runs/:id", async (c) => {
|
|
571
|
+
const row = await distributionService.updateReconciliationRun(c.get("db"), c.req.param("id"), updateChannelReconciliationRunSchema.parse(await c.req.json()));
|
|
572
|
+
if (!row)
|
|
573
|
+
return c.json({ error: "Channel reconciliation run not found" }, 404);
|
|
574
|
+
return c.json({ data: row });
|
|
575
|
+
})
|
|
576
|
+
.delete("/reconciliation-runs/:id", async (c) => {
|
|
577
|
+
const row = await distributionService.deleteReconciliationRun(c.get("db"), c.req.param("id"));
|
|
578
|
+
if (!row)
|
|
579
|
+
return c.json({ error: "Channel reconciliation run not found" }, 404);
|
|
580
|
+
return c.json({ success: true });
|
|
581
|
+
})
|
|
582
|
+
.get("/reconciliation-items", async (c) => {
|
|
583
|
+
const query = channelReconciliationItemListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
584
|
+
return c.json(await distributionService.listReconciliationItems(c.get("db"), query));
|
|
585
|
+
})
|
|
586
|
+
.post("/reconciliation-items", async (c) => {
|
|
587
|
+
return c.json({
|
|
588
|
+
data: await distributionService.createReconciliationItem(c.get("db"), insertChannelReconciliationItemSchema.parse(await c.req.json())),
|
|
589
|
+
}, 201);
|
|
590
|
+
})
|
|
591
|
+
.get("/reconciliation-items/:id", async (c) => {
|
|
592
|
+
const row = await distributionService.getReconciliationItemById(c.get("db"), c.req.param("id"));
|
|
593
|
+
if (!row)
|
|
594
|
+
return c.json({ error: "Channel reconciliation item not found" }, 404);
|
|
595
|
+
return c.json({ data: row });
|
|
596
|
+
})
|
|
597
|
+
.patch("/reconciliation-items/:id", async (c) => {
|
|
598
|
+
const row = await distributionService.updateReconciliationItem(c.get("db"), c.req.param("id"), updateChannelReconciliationItemSchema.parse(await c.req.json()));
|
|
599
|
+
if (!row)
|
|
600
|
+
return c.json({ error: "Channel reconciliation item not found" }, 404);
|
|
601
|
+
return c.json({ data: row });
|
|
602
|
+
})
|
|
603
|
+
.delete("/reconciliation-items/:id", async (c) => {
|
|
604
|
+
const row = await distributionService.deleteReconciliationItem(c.get("db"), c.req.param("id"));
|
|
605
|
+
if (!row)
|
|
606
|
+
return c.json({ error: "Channel reconciliation item not found" }, 404);
|
|
607
|
+
return c.json({ success: true });
|
|
608
|
+
})
|
|
609
|
+
.get("/inventory-release-executions", async (c) => {
|
|
610
|
+
const query = channelInventoryReleaseExecutionListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
611
|
+
return c.json(await distributionService.listReleaseExecutions(c.get("db"), query));
|
|
612
|
+
})
|
|
613
|
+
.post("/inventory-release-executions", async (c) => {
|
|
614
|
+
return c.json({
|
|
615
|
+
data: await distributionService.createReleaseExecution(c.get("db"), insertChannelInventoryReleaseExecutionSchema.parse(await c.req.json())),
|
|
616
|
+
}, 201);
|
|
617
|
+
})
|
|
618
|
+
.get("/inventory-release-executions/:id", async (c) => {
|
|
619
|
+
const row = await distributionService.getReleaseExecutionById(c.get("db"), c.req.param("id"));
|
|
620
|
+
if (!row)
|
|
621
|
+
return c.json({ error: "Channel inventory release execution not found" }, 404);
|
|
622
|
+
return c.json({ data: row });
|
|
623
|
+
})
|
|
624
|
+
.patch("/inventory-release-executions/:id", async (c) => {
|
|
625
|
+
const row = await distributionService.updateReleaseExecution(c.get("db"), c.req.param("id"), updateChannelInventoryReleaseExecutionSchema.parse(await c.req.json()));
|
|
626
|
+
if (!row)
|
|
627
|
+
return c.json({ error: "Channel inventory release execution not found" }, 404);
|
|
628
|
+
return c.json({ data: row });
|
|
629
|
+
})
|
|
630
|
+
.delete("/inventory-release-executions/:id", async (c) => {
|
|
631
|
+
const row = await distributionService.deleteReleaseExecution(c.get("db"), c.req.param("id"));
|
|
632
|
+
if (!row)
|
|
633
|
+
return c.json({ error: "Channel inventory release execution not found" }, 404);
|
|
634
|
+
return c.json({ success: true });
|
|
635
|
+
})
|
|
636
|
+
.get("/settlement-policies", async (c) => {
|
|
637
|
+
const query = channelSettlementPolicyListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
638
|
+
return c.json(await distributionService.listSettlementPolicies(c.get("db"), query));
|
|
639
|
+
})
|
|
640
|
+
.post("/settlement-policies", async (c) => c.json({
|
|
641
|
+
data: await distributionService.createSettlementPolicy(c.get("db"), insertChannelSettlementPolicySchema.parse(await c.req.json())),
|
|
642
|
+
}, 201))
|
|
643
|
+
.get("/settlement-policies/:id", async (c) => {
|
|
644
|
+
const row = await distributionService.getSettlementPolicyById(c.get("db"), c.req.param("id"));
|
|
645
|
+
if (!row)
|
|
646
|
+
return c.json({ error: "Channel settlement policy not found" }, 404);
|
|
647
|
+
return c.json({ data: row });
|
|
648
|
+
})
|
|
649
|
+
.patch("/settlement-policies/:id", async (c) => {
|
|
650
|
+
const row = await distributionService.updateSettlementPolicy(c.get("db"), c.req.param("id"), updateChannelSettlementPolicySchema.parse(await c.req.json()));
|
|
651
|
+
if (!row)
|
|
652
|
+
return c.json({ error: "Channel settlement policy not found" }, 404);
|
|
653
|
+
return c.json({ data: row });
|
|
654
|
+
})
|
|
655
|
+
.delete("/settlement-policies/:id", async (c) => {
|
|
656
|
+
const row = await distributionService.deleteSettlementPolicy(c.get("db"), c.req.param("id"));
|
|
657
|
+
if (!row)
|
|
658
|
+
return c.json({ error: "Channel settlement policy not found" }, 404);
|
|
659
|
+
return c.json({ success: true });
|
|
660
|
+
})
|
|
661
|
+
.get("/reconciliation-policies", async (c) => {
|
|
662
|
+
const query = channelReconciliationPolicyListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
663
|
+
return c.json(await distributionService.listReconciliationPolicies(c.get("db"), query));
|
|
664
|
+
})
|
|
665
|
+
.post("/reconciliation-policies", async (c) => c.json({
|
|
666
|
+
data: await distributionService.createReconciliationPolicy(c.get("db"), insertChannelReconciliationPolicySchema.parse(await c.req.json())),
|
|
667
|
+
}, 201))
|
|
668
|
+
.get("/reconciliation-policies/:id", async (c) => {
|
|
669
|
+
const row = await distributionService.getReconciliationPolicyById(c.get("db"), c.req.param("id"));
|
|
670
|
+
if (!row)
|
|
671
|
+
return c.json({ error: "Channel reconciliation policy not found" }, 404);
|
|
672
|
+
return c.json({ data: row });
|
|
673
|
+
})
|
|
674
|
+
.patch("/reconciliation-policies/:id", async (c) => {
|
|
675
|
+
const row = await distributionService.updateReconciliationPolicy(c.get("db"), c.req.param("id"), updateChannelReconciliationPolicySchema.parse(await c.req.json()));
|
|
676
|
+
if (!row)
|
|
677
|
+
return c.json({ error: "Channel reconciliation policy not found" }, 404);
|
|
678
|
+
return c.json({ data: row });
|
|
679
|
+
})
|
|
680
|
+
.delete("/reconciliation-policies/:id", async (c) => {
|
|
681
|
+
const row = await distributionService.deleteReconciliationPolicy(c.get("db"), c.req.param("id"));
|
|
682
|
+
if (!row)
|
|
683
|
+
return c.json({ error: "Channel reconciliation policy not found" }, 404);
|
|
684
|
+
return c.json({ success: true });
|
|
685
|
+
})
|
|
686
|
+
.get("/release-schedules", async (c) => {
|
|
687
|
+
const query = channelReleaseScheduleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
688
|
+
return c.json(await distributionService.listReleaseSchedules(c.get("db"), query));
|
|
689
|
+
})
|
|
690
|
+
.post("/release-schedules", async (c) => c.json({
|
|
691
|
+
data: await distributionService.createReleaseSchedule(c.get("db"), insertChannelReleaseScheduleSchema.parse(await c.req.json())),
|
|
692
|
+
}, 201))
|
|
693
|
+
.get("/release-schedules/:id", async (c) => {
|
|
694
|
+
const row = await distributionService.getReleaseScheduleById(c.get("db"), c.req.param("id"));
|
|
695
|
+
if (!row)
|
|
696
|
+
return c.json({ error: "Channel release schedule not found" }, 404);
|
|
697
|
+
return c.json({ data: row });
|
|
698
|
+
})
|
|
699
|
+
.patch("/release-schedules/:id", async (c) => {
|
|
700
|
+
const row = await distributionService.updateReleaseSchedule(c.get("db"), c.req.param("id"), updateChannelReleaseScheduleSchema.parse(await c.req.json()));
|
|
701
|
+
if (!row)
|
|
702
|
+
return c.json({ error: "Channel release schedule not found" }, 404);
|
|
703
|
+
return c.json({ data: row });
|
|
704
|
+
})
|
|
705
|
+
.delete("/release-schedules/:id", async (c) => {
|
|
706
|
+
const row = await distributionService.deleteReleaseSchedule(c.get("db"), c.req.param("id"));
|
|
707
|
+
if (!row)
|
|
708
|
+
return c.json({ error: "Channel release schedule not found" }, 404);
|
|
709
|
+
return c.json({ success: true });
|
|
710
|
+
})
|
|
711
|
+
.get("/remittance-exceptions", async (c) => {
|
|
712
|
+
const query = channelRemittanceExceptionListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
713
|
+
return c.json(await distributionService.listRemittanceExceptions(c.get("db"), query));
|
|
714
|
+
})
|
|
715
|
+
.post("/remittance-exceptions", async (c) => c.json({
|
|
716
|
+
data: await distributionService.createRemittanceException(c.get("db"), insertChannelRemittanceExceptionSchema.parse(await c.req.json())),
|
|
717
|
+
}, 201))
|
|
718
|
+
.get("/remittance-exceptions/:id", async (c) => {
|
|
719
|
+
const row = await distributionService.getRemittanceExceptionById(c.get("db"), c.req.param("id"));
|
|
720
|
+
if (!row)
|
|
721
|
+
return c.json({ error: "Channel remittance exception not found" }, 404);
|
|
722
|
+
return c.json({ data: row });
|
|
723
|
+
})
|
|
724
|
+
.patch("/remittance-exceptions/:id", async (c) => {
|
|
725
|
+
const row = await distributionService.updateRemittanceException(c.get("db"), c.req.param("id"), updateChannelRemittanceExceptionSchema.parse(await c.req.json()));
|
|
726
|
+
if (!row)
|
|
727
|
+
return c.json({ error: "Channel remittance exception not found" }, 404);
|
|
728
|
+
return c.json({ data: row });
|
|
729
|
+
})
|
|
730
|
+
.delete("/remittance-exceptions/:id", async (c) => {
|
|
731
|
+
const row = await distributionService.deleteRemittanceException(c.get("db"), c.req.param("id"));
|
|
732
|
+
if (!row)
|
|
733
|
+
return c.json({ error: "Channel remittance exception not found" }, 404);
|
|
734
|
+
return c.json({ success: true });
|
|
735
|
+
})
|
|
736
|
+
.get("/settlement-approvals", async (c) => {
|
|
737
|
+
const query = channelSettlementApprovalListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
|
|
738
|
+
return c.json(await distributionService.listSettlementApprovals(c.get("db"), query));
|
|
739
|
+
})
|
|
740
|
+
.post("/settlement-approvals", async (c) => c.json({
|
|
741
|
+
data: await distributionService.createSettlementApproval(c.get("db"), insertChannelSettlementApprovalSchema.parse(await c.req.json())),
|
|
742
|
+
}, 201))
|
|
743
|
+
.get("/settlement-approvals/:id", async (c) => {
|
|
744
|
+
const row = await distributionService.getSettlementApprovalById(c.get("db"), c.req.param("id"));
|
|
745
|
+
if (!row)
|
|
746
|
+
return c.json({ error: "Channel settlement approval not found" }, 404);
|
|
747
|
+
return c.json({ data: row });
|
|
748
|
+
})
|
|
749
|
+
.patch("/settlement-approvals/:id", async (c) => {
|
|
750
|
+
const row = await distributionService.updateSettlementApproval(c.get("db"), c.req.param("id"), updateChannelSettlementApprovalSchema.parse(await c.req.json()));
|
|
751
|
+
if (!row)
|
|
752
|
+
return c.json({ error: "Channel settlement approval not found" }, 404);
|
|
753
|
+
return c.json({ data: row });
|
|
754
|
+
})
|
|
755
|
+
.delete("/settlement-approvals/:id", async (c) => {
|
|
756
|
+
const row = await distributionService.deleteSettlementApproval(c.get("db"), c.req.param("id"));
|
|
757
|
+
if (!row)
|
|
758
|
+
return c.json({ error: "Channel settlement approval not found" }, 404);
|
|
759
|
+
return c.json({ success: true });
|
|
760
|
+
});
|