@voyantjs/transactions 0.5.0 → 0.6.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/booking-extension.d.ts +2 -2
- package/dist/booking-extension.d.ts.map +1 -1
- package/dist/booking-extension.js +2 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -4
- package/dist/route-runtime.d.ts +8 -0
- package/dist/route-runtime.d.ts.map +1 -0
- package/dist/route-runtime.js +17 -0
- package/dist/routes-offers.d.ts +21 -140
- package/dist/routes-offers.d.ts.map +1 -1
- package/dist/routes-offers.js +14 -13
- package/dist/routes-orders.d.ts +26 -145
- package/dist/routes-orders.d.ts.map +1 -1
- package/dist/routes-orders.js +17 -16
- package/dist/routes-shared.d.ts +23 -46
- package/dist/routes-shared.d.ts.map +1 -1
- package/dist/routes-shared.js +20 -12
- package/dist/schema-audit.d.ts +1 -1
- package/dist/schema-offers.d.ts +1 -1
- package/dist/schema-orders.d.ts +1 -1
- package/dist/service-offers.d.ts +21 -21
- package/dist/service-orders.d.ts +17 -17
- package/dist/validation.d.ts +5 -5
- package/package.json +5 -5
package/dist/routes-orders.d.ts
CHANGED
|
@@ -47,16 +47,16 @@ export declare const transactionOrderRoutes: import("hono/hono-base").HonoBase<E
|
|
|
47
47
|
input: {};
|
|
48
48
|
output: {
|
|
49
49
|
data: {
|
|
50
|
-
|
|
50
|
+
metadata: import("hono/utils/types").JSONValue;
|
|
51
|
+
id: string;
|
|
51
52
|
createdAt: string;
|
|
52
53
|
updatedAt: string;
|
|
53
|
-
id: string;
|
|
54
54
|
expiresAt: string | null;
|
|
55
|
-
metadata: import("hono/utils/types").JSONValue;
|
|
56
55
|
organizationId: string | null;
|
|
57
56
|
status: "pending" | "draft" | "expired" | "confirmed" | "fulfilled" | "cancelled";
|
|
58
57
|
currency: string;
|
|
59
58
|
notes: string | null;
|
|
59
|
+
offerId: string | null;
|
|
60
60
|
title: string;
|
|
61
61
|
personId: string | null;
|
|
62
62
|
opportunityId: string | null;
|
|
@@ -363,51 +363,9 @@ export declare const transactionOrderRoutes: import("hono/hono-base").HonoBase<E
|
|
|
363
363
|
id: string;
|
|
364
364
|
};
|
|
365
365
|
};
|
|
366
|
-
output: {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
outputFormat: "json";
|
|
370
|
-
status: 404;
|
|
371
|
-
} | {
|
|
372
|
-
input: {
|
|
373
|
-
param: {
|
|
374
|
-
id: string;
|
|
375
|
-
};
|
|
376
|
-
};
|
|
377
|
-
output: {
|
|
378
|
-
error: string;
|
|
379
|
-
};
|
|
380
|
-
outputFormat: "json";
|
|
381
|
-
status: 401;
|
|
382
|
-
} | {
|
|
383
|
-
input: {
|
|
384
|
-
param: {
|
|
385
|
-
id: string;
|
|
386
|
-
};
|
|
387
|
-
};
|
|
388
|
-
output: {
|
|
389
|
-
error: string;
|
|
390
|
-
};
|
|
391
|
-
outputFormat: "json";
|
|
392
|
-
status: 403;
|
|
393
|
-
} | {
|
|
394
|
-
input: {
|
|
395
|
-
param: {
|
|
396
|
-
id: string;
|
|
397
|
-
};
|
|
398
|
-
};
|
|
399
|
-
output: {
|
|
400
|
-
data: {
|
|
401
|
-
participantId: string;
|
|
402
|
-
participantKind: "offer" | "order";
|
|
403
|
-
dateOfBirth: string | null;
|
|
404
|
-
nationality: string | null;
|
|
405
|
-
createdAt: string;
|
|
406
|
-
updatedAt: string;
|
|
407
|
-
};
|
|
408
|
-
};
|
|
409
|
-
outputFormat: "json";
|
|
410
|
-
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
366
|
+
output: {};
|
|
367
|
+
outputFormat: string;
|
|
368
|
+
status: import("hono/utils/http-status").StatusCode;
|
|
411
369
|
};
|
|
412
370
|
};
|
|
413
371
|
} & {
|
|
@@ -418,51 +376,9 @@ export declare const transactionOrderRoutes: import("hono/hono-base").HonoBase<E
|
|
|
418
376
|
id: string;
|
|
419
377
|
};
|
|
420
378
|
};
|
|
421
|
-
output: {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
outputFormat: "json";
|
|
425
|
-
status: 404;
|
|
426
|
-
} | {
|
|
427
|
-
input: {
|
|
428
|
-
param: {
|
|
429
|
-
id: string;
|
|
430
|
-
};
|
|
431
|
-
};
|
|
432
|
-
output: {
|
|
433
|
-
error: string;
|
|
434
|
-
};
|
|
435
|
-
outputFormat: "json";
|
|
436
|
-
status: 401;
|
|
437
|
-
} | {
|
|
438
|
-
input: {
|
|
439
|
-
param: {
|
|
440
|
-
id: string;
|
|
441
|
-
};
|
|
442
|
-
};
|
|
443
|
-
output: {
|
|
444
|
-
error: string;
|
|
445
|
-
};
|
|
446
|
-
outputFormat: "json";
|
|
447
|
-
status: 403;
|
|
448
|
-
} | {
|
|
449
|
-
input: {
|
|
450
|
-
param: {
|
|
451
|
-
id: string;
|
|
452
|
-
};
|
|
453
|
-
};
|
|
454
|
-
output: {
|
|
455
|
-
data: {
|
|
456
|
-
participantId: string;
|
|
457
|
-
participantKind: "offer" | "order";
|
|
458
|
-
dateOfBirth: string | null;
|
|
459
|
-
nationality: string | null;
|
|
460
|
-
createdAt: string;
|
|
461
|
-
updatedAt: string;
|
|
462
|
-
};
|
|
463
|
-
};
|
|
464
|
-
outputFormat: "json";
|
|
465
|
-
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
379
|
+
output: {};
|
|
380
|
+
outputFormat: string;
|
|
381
|
+
status: import("hono/utils/http-status").StatusCode;
|
|
466
382
|
};
|
|
467
383
|
};
|
|
468
384
|
} & {
|
|
@@ -473,44 +389,9 @@ export declare const transactionOrderRoutes: import("hono/hono-base").HonoBase<E
|
|
|
473
389
|
id: string;
|
|
474
390
|
};
|
|
475
391
|
};
|
|
476
|
-
output: {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
outputFormat: "json";
|
|
480
|
-
status: 404;
|
|
481
|
-
} | {
|
|
482
|
-
input: {
|
|
483
|
-
param: {
|
|
484
|
-
id: string;
|
|
485
|
-
};
|
|
486
|
-
};
|
|
487
|
-
output: {
|
|
488
|
-
error: string;
|
|
489
|
-
};
|
|
490
|
-
outputFormat: "json";
|
|
491
|
-
status: 401;
|
|
492
|
-
} | {
|
|
493
|
-
input: {
|
|
494
|
-
param: {
|
|
495
|
-
id: string;
|
|
496
|
-
};
|
|
497
|
-
};
|
|
498
|
-
output: {
|
|
499
|
-
error: string;
|
|
500
|
-
};
|
|
501
|
-
outputFormat: "json";
|
|
502
|
-
status: 403;
|
|
503
|
-
} | {
|
|
504
|
-
input: {
|
|
505
|
-
param: {
|
|
506
|
-
id: string;
|
|
507
|
-
};
|
|
508
|
-
};
|
|
509
|
-
output: {
|
|
510
|
-
success: true;
|
|
511
|
-
};
|
|
512
|
-
outputFormat: "json";
|
|
513
|
-
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
392
|
+
output: {};
|
|
393
|
+
outputFormat: string;
|
|
394
|
+
status: import("hono/utils/http-status").StatusCode;
|
|
514
395
|
};
|
|
515
396
|
};
|
|
516
397
|
} & {
|
|
@@ -554,7 +435,7 @@ export declare const transactionOrderRoutes: import("hono/hono-base").HonoBase<E
|
|
|
554
435
|
slotId: string | null;
|
|
555
436
|
title: string;
|
|
556
437
|
description: string | null;
|
|
557
|
-
itemType: "
|
|
438
|
+
itemType: "service" | "other" | "unit" | "extra" | "fee" | "tax" | "discount" | "adjustment" | "accommodation" | "transport";
|
|
558
439
|
status: "draft" | "confirmed" | "fulfilled" | "cancelled" | "priced";
|
|
559
440
|
serviceDate: string | null;
|
|
560
441
|
startsAt: string | null;
|
|
@@ -587,14 +468,14 @@ export declare const transactionOrderRoutes: import("hono/hono-base").HonoBase<E
|
|
|
587
468
|
input: {};
|
|
588
469
|
output: {
|
|
589
470
|
data: {
|
|
590
|
-
|
|
471
|
+
metadata: import("hono/utils/types").JSONValue;
|
|
472
|
+
id: string;
|
|
591
473
|
createdAt: string;
|
|
592
474
|
updatedAt: string;
|
|
593
|
-
description: string | null;
|
|
594
|
-
id: string;
|
|
595
|
-
metadata: import("hono/utils/types").JSONValue;
|
|
596
475
|
status: "draft" | "confirmed" | "fulfilled" | "cancelled" | "priced";
|
|
597
476
|
notes: string | null;
|
|
477
|
+
description: string | null;
|
|
478
|
+
orderId: string;
|
|
598
479
|
title: string;
|
|
599
480
|
taxAmountCents: number | null;
|
|
600
481
|
feeAmountCents: number | null;
|
|
@@ -602,7 +483,7 @@ export declare const transactionOrderRoutes: import("hono/hono-base").HonoBase<E
|
|
|
602
483
|
optionId: string | null;
|
|
603
484
|
unitId: string | null;
|
|
604
485
|
slotId: string | null;
|
|
605
|
-
itemType: "
|
|
486
|
+
itemType: "service" | "other" | "unit" | "extra" | "fee" | "tax" | "discount" | "adjustment" | "accommodation" | "transport";
|
|
606
487
|
serviceDate: string | null;
|
|
607
488
|
startsAt: string | null;
|
|
608
489
|
endsAt: string | null;
|
|
@@ -650,7 +531,7 @@ export declare const transactionOrderRoutes: import("hono/hono-base").HonoBase<E
|
|
|
650
531
|
slotId: string | null;
|
|
651
532
|
title: string;
|
|
652
533
|
description: string | null;
|
|
653
|
-
itemType: "
|
|
534
|
+
itemType: "service" | "other" | "unit" | "extra" | "fee" | "tax" | "discount" | "adjustment" | "accommodation" | "transport";
|
|
654
535
|
status: "draft" | "confirmed" | "fulfilled" | "cancelled" | "priced";
|
|
655
536
|
serviceDate: string | null;
|
|
656
537
|
startsAt: string | null;
|
|
@@ -704,7 +585,7 @@ export declare const transactionOrderRoutes: import("hono/hono-base").HonoBase<E
|
|
|
704
585
|
slotId: string | null;
|
|
705
586
|
title: string;
|
|
706
587
|
description: string | null;
|
|
707
|
-
itemType: "
|
|
588
|
+
itemType: "service" | "other" | "unit" | "extra" | "fee" | "tax" | "discount" | "adjustment" | "accommodation" | "transport";
|
|
708
589
|
status: "draft" | "confirmed" | "fulfilled" | "cancelled" | "priced";
|
|
709
590
|
serviceDate: string | null;
|
|
710
591
|
startsAt: string | null;
|
|
@@ -781,8 +662,8 @@ export declare const transactionOrderRoutes: import("hono/hono-base").HonoBase<E
|
|
|
781
662
|
input: {};
|
|
782
663
|
output: {
|
|
783
664
|
data: {
|
|
784
|
-
createdAt: string;
|
|
785
665
|
id: string;
|
|
666
|
+
createdAt: string;
|
|
786
667
|
role: "other" | "traveler" | "occupant" | "primary_contact" | "beneficiary" | "service_assignee";
|
|
787
668
|
participantId: string;
|
|
788
669
|
isPrimary: boolean;
|
|
@@ -921,14 +802,14 @@ export declare const transactionOrderRoutes: import("hono/hono-base").HonoBase<E
|
|
|
921
802
|
input: {};
|
|
922
803
|
output: {
|
|
923
804
|
data: {
|
|
924
|
-
|
|
925
|
-
|
|
805
|
+
metadata: import("hono/utils/types").JSONValue;
|
|
806
|
+
id: string;
|
|
926
807
|
createdAt: string;
|
|
927
808
|
updatedAt: string;
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
metadata: import("hono/utils/types").JSONValue;
|
|
809
|
+
offerId: string | null;
|
|
810
|
+
orderId: string | null;
|
|
931
811
|
title: string;
|
|
812
|
+
body: string;
|
|
932
813
|
acceptedAt: string | null;
|
|
933
814
|
termType: "other" | "terms_and_conditions" | "cancellation" | "guarantee" | "payment" | "pricing" | "commission";
|
|
934
815
|
language: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes-orders.d.ts","sourceRoot":"","sources":["../src/routes-orders.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routes-orders.d.ts","sourceRoot":"","sources":["../src/routes-orders.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,GAAG,EAIT,MAAM,oBAAoB,CAAA;AAoB3B,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BA0P/B,CAAA"}
|
package/dist/routes-orders.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
+
import { parseJsonBody, parseQuery } from "@voyantjs/hono";
|
|
1
2
|
import { Hono } from "hono";
|
|
2
3
|
import { authorizeTransactionPiiAccess, createPiiService, hasParticipantIdentityInput, logTransactionPiiAccess, notFound, } from "./routes-shared.js";
|
|
3
4
|
import { transactionsService } from "./service.js";
|
|
4
5
|
import { insertOrderItemParticipantSchema, insertOrderItemSchema, insertOrderParticipantSchema, insertOrderSchema, insertOrderTermSchema, orderItemListQuerySchema, orderItemParticipantListQuerySchema, orderListQuerySchema, orderParticipantListQuerySchema, orderTermListQuerySchema, updateOrderItemParticipantSchema, updateOrderItemSchema, updateOrderParticipantSchema, updateOrderSchema, updateOrderTermSchema, } from "./validation.js";
|
|
5
6
|
export const transactionOrderRoutes = new Hono()
|
|
6
7
|
.get("/orders", async (c) => {
|
|
7
|
-
const query =
|
|
8
|
+
const query = await parseQuery(c, orderListQuerySchema);
|
|
8
9
|
return c.json(await transactionsService.listOrders(c.get("db"), query));
|
|
9
10
|
})
|
|
10
11
|
.post("/orders", async (c) => c.json({
|
|
11
|
-
data: await transactionsService.createOrder(c.get("db"),
|
|
12
|
+
data: await transactionsService.createOrder(c.get("db"), await parseJsonBody(c, insertOrderSchema)),
|
|
12
13
|
}, 201))
|
|
13
14
|
.get("/orders/:id", async (c) => {
|
|
14
15
|
const row = await transactionsService.getOrderById(c.get("db"), c.req.param("id"));
|
|
15
16
|
return row ? c.json({ data: row }) : notFound(c, "Order not found");
|
|
16
17
|
})
|
|
17
18
|
.patch("/orders/:id", async (c) => {
|
|
18
|
-
const row = await transactionsService.updateOrder(c.get("db"), c.req.param("id"),
|
|
19
|
+
const row = await transactionsService.updateOrder(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateOrderSchema));
|
|
19
20
|
return row ? c.json({ data: row }) : notFound(c, "Order not found");
|
|
20
21
|
})
|
|
21
22
|
.delete("/orders/:id", async (c) => {
|
|
@@ -23,11 +24,11 @@ export const transactionOrderRoutes = new Hono()
|
|
|
23
24
|
return row ? c.json({ success: true }) : notFound(c, "Order not found");
|
|
24
25
|
})
|
|
25
26
|
.get("/order-participants", async (c) => {
|
|
26
|
-
const query =
|
|
27
|
+
const query = await parseQuery(c, orderParticipantListQuerySchema);
|
|
27
28
|
return c.json(await transactionsService.listOrderParticipants(c.get("db"), query));
|
|
28
29
|
})
|
|
29
30
|
.post("/order-participants", async (c) => {
|
|
30
|
-
const payload =
|
|
31
|
+
const payload = await parseJsonBody(c, insertOrderParticipantSchema);
|
|
31
32
|
const row = await transactionsService.createOrderParticipant(c.get("db"), payload);
|
|
32
33
|
if (!row)
|
|
33
34
|
return c.json({ data: row }, 201);
|
|
@@ -43,7 +44,7 @@ export const transactionOrderRoutes = new Hono()
|
|
|
43
44
|
return row ? c.json({ data: row }) : notFound(c, "Order participant not found");
|
|
44
45
|
})
|
|
45
46
|
.patch("/order-participants/:id", async (c) => {
|
|
46
|
-
const payload =
|
|
47
|
+
const payload = await parseJsonBody(c, updateOrderParticipantSchema);
|
|
47
48
|
const row = await transactionsService.updateOrderParticipant(c.get("db"), c.req.param("id"), payload);
|
|
48
49
|
if (!row)
|
|
49
50
|
return notFound(c, "Order participant not found");
|
|
@@ -96,7 +97,7 @@ export const transactionOrderRoutes = new Hono()
|
|
|
96
97
|
if (!auth.allowed)
|
|
97
98
|
return auth.response;
|
|
98
99
|
const pii = createPiiService(c, "order", participant.orderId);
|
|
99
|
-
const row = await pii.upsertParticipantIdentity(c.get("db"), "order", participant.id,
|
|
100
|
+
const row = await pii.upsertParticipantIdentity(c.get("db"), "order", participant.id, await parseJsonBody(c, updateOrderParticipantSchema), c.get("userId"));
|
|
100
101
|
return row ? c.json({ data: row }) : notFound(c, "Order participant not found");
|
|
101
102
|
})
|
|
102
103
|
.delete("/order-participants/:id/travel-details", async (c) => {
|
|
@@ -122,18 +123,18 @@ export const transactionOrderRoutes = new Hono()
|
|
|
122
123
|
return row ? c.json({ success: true }) : notFound(c, "Order participant not found");
|
|
123
124
|
})
|
|
124
125
|
.get("/order-items", async (c) => {
|
|
125
|
-
const query =
|
|
126
|
+
const query = await parseQuery(c, orderItemListQuerySchema);
|
|
126
127
|
return c.json(await transactionsService.listOrderItems(c.get("db"), query));
|
|
127
128
|
})
|
|
128
129
|
.post("/order-items", async (c) => c.json({
|
|
129
|
-
data: await transactionsService.createOrderItem(c.get("db"),
|
|
130
|
+
data: await transactionsService.createOrderItem(c.get("db"), await parseJsonBody(c, insertOrderItemSchema)),
|
|
130
131
|
}, 201))
|
|
131
132
|
.get("/order-items/:id", async (c) => {
|
|
132
133
|
const row = await transactionsService.getOrderItemById(c.get("db"), c.req.param("id"));
|
|
133
134
|
return row ? c.json({ data: row }) : notFound(c, "Order item not found");
|
|
134
135
|
})
|
|
135
136
|
.patch("/order-items/:id", async (c) => {
|
|
136
|
-
const row = await transactionsService.updateOrderItem(c.get("db"), c.req.param("id"),
|
|
137
|
+
const row = await transactionsService.updateOrderItem(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateOrderItemSchema));
|
|
137
138
|
return row ? c.json({ data: row }) : notFound(c, "Order item not found");
|
|
138
139
|
})
|
|
139
140
|
.delete("/order-items/:id", async (c) => {
|
|
@@ -141,18 +142,18 @@ export const transactionOrderRoutes = new Hono()
|
|
|
141
142
|
return row ? c.json({ success: true }) : notFound(c, "Order item not found");
|
|
142
143
|
})
|
|
143
144
|
.get("/order-item-participants", async (c) => {
|
|
144
|
-
const query =
|
|
145
|
+
const query = await parseQuery(c, orderItemParticipantListQuerySchema);
|
|
145
146
|
return c.json(await transactionsService.listOrderItemParticipants(c.get("db"), query));
|
|
146
147
|
})
|
|
147
148
|
.post("/order-item-participants", async (c) => c.json({
|
|
148
|
-
data: await transactionsService.createOrderItemParticipant(c.get("db"),
|
|
149
|
+
data: await transactionsService.createOrderItemParticipant(c.get("db"), await parseJsonBody(c, insertOrderItemParticipantSchema)),
|
|
149
150
|
}, 201))
|
|
150
151
|
.get("/order-item-participants/:id", async (c) => {
|
|
151
152
|
const row = await transactionsService.getOrderItemParticipantById(c.get("db"), c.req.param("id"));
|
|
152
153
|
return row ? c.json({ data: row }) : notFound(c, "Order item participant not found");
|
|
153
154
|
})
|
|
154
155
|
.patch("/order-item-participants/:id", async (c) => {
|
|
155
|
-
const row = await transactionsService.updateOrderItemParticipant(c.get("db"), c.req.param("id"),
|
|
156
|
+
const row = await transactionsService.updateOrderItemParticipant(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateOrderItemParticipantSchema));
|
|
156
157
|
return row ? c.json({ data: row }) : notFound(c, "Order item participant not found");
|
|
157
158
|
})
|
|
158
159
|
.delete("/order-item-participants/:id", async (c) => {
|
|
@@ -160,18 +161,18 @@ export const transactionOrderRoutes = new Hono()
|
|
|
160
161
|
return row ? c.json({ success: true }) : notFound(c, "Order item participant not found");
|
|
161
162
|
})
|
|
162
163
|
.get("/order-terms", async (c) => {
|
|
163
|
-
const query =
|
|
164
|
+
const query = await parseQuery(c, orderTermListQuerySchema);
|
|
164
165
|
return c.json(await transactionsService.listOrderTerms(c.get("db"), query));
|
|
165
166
|
})
|
|
166
167
|
.post("/order-terms", async (c) => c.json({
|
|
167
|
-
data: await transactionsService.createOrderTerm(c.get("db"),
|
|
168
|
+
data: await transactionsService.createOrderTerm(c.get("db"), await parseJsonBody(c, insertOrderTermSchema)),
|
|
168
169
|
}, 201))
|
|
169
170
|
.get("/order-terms/:id", async (c) => {
|
|
170
171
|
const row = await transactionsService.getOrderTermById(c.get("db"), c.req.param("id"));
|
|
171
172
|
return row ? c.json({ data: row }) : notFound(c, "Order term not found");
|
|
172
173
|
})
|
|
173
174
|
.patch("/order-terms/:id", async (c) => {
|
|
174
|
-
const row = await transactionsService.updateOrderTerm(c.get("db"), c.req.param("id"),
|
|
175
|
+
const row = await transactionsService.updateOrderTerm(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateOrderTermSchema));
|
|
175
176
|
return row ? c.json({ data: row }) : notFound(c, "Order term not found");
|
|
176
177
|
})
|
|
177
178
|
.delete("/order-terms/:id", async (c) => {
|
package/dist/routes-shared.d.ts
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
|
+
import type { ModuleContainer } from "@voyantjs/core";
|
|
1
2
|
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
3
|
import type { Context } from "hono";
|
|
4
|
+
export type KmsBindings = Partial<{
|
|
5
|
+
KMS_PROVIDER: string;
|
|
6
|
+
KMS_ENV_KEY: string;
|
|
7
|
+
KMS_LOCAL_KEY: string;
|
|
8
|
+
GCP_PROJECT_ID: string;
|
|
9
|
+
GCP_SERVICE_ACCOUNT_EMAIL: string;
|
|
10
|
+
GCP_PRIVATE_KEY: string;
|
|
11
|
+
GCP_KMS_KEYRING: string;
|
|
12
|
+
GCP_KMS_LOCATION: string;
|
|
13
|
+
GCP_KMS_PEOPLE_KEY_NAME: string;
|
|
14
|
+
GCP_KMS_INTEGRATIONS_KEY_NAME: string;
|
|
15
|
+
AWS_REGION: string;
|
|
16
|
+
AWS_ACCESS_KEY_ID: string;
|
|
17
|
+
AWS_SECRET_ACCESS_KEY: string;
|
|
18
|
+
AWS_SESSION_TOKEN: string;
|
|
19
|
+
AWS_KMS_ENDPOINT: string;
|
|
20
|
+
AWS_KMS_PEOPLE_KEY_ID: string;
|
|
21
|
+
AWS_KMS_INTEGRATIONS_KEY_ID: string;
|
|
22
|
+
}>;
|
|
3
23
|
export type Env = {
|
|
4
|
-
Bindings:
|
|
5
|
-
KMS_PROVIDER: string;
|
|
6
|
-
KMS_ENV_KEY: string;
|
|
7
|
-
KMS_LOCAL_KEY: string;
|
|
8
|
-
GCP_PROJECT_ID: string;
|
|
9
|
-
GCP_SERVICE_ACCOUNT_EMAIL: string;
|
|
10
|
-
GCP_PRIVATE_KEY: string;
|
|
11
|
-
GCP_KMS_KEYRING: string;
|
|
12
|
-
GCP_KMS_LOCATION: string;
|
|
13
|
-
GCP_KMS_PEOPLE_KEY_NAME: string;
|
|
14
|
-
GCP_KMS_INTEGRATIONS_KEY_NAME: string;
|
|
15
|
-
AWS_REGION: string;
|
|
16
|
-
AWS_ACCESS_KEY_ID: string;
|
|
17
|
-
AWS_SECRET_ACCESS_KEY: string;
|
|
18
|
-
AWS_SESSION_TOKEN: string;
|
|
19
|
-
AWS_KMS_ENDPOINT: string;
|
|
20
|
-
AWS_KMS_PEOPLE_KEY_ID: string;
|
|
21
|
-
AWS_KMS_INTEGRATIONS_KEY_ID: string;
|
|
22
|
-
}>;
|
|
24
|
+
Bindings: KmsBindings;
|
|
23
25
|
Variables: {
|
|
24
26
|
db: PostgresJsDatabase;
|
|
27
|
+
container?: ModuleContainer;
|
|
25
28
|
userId?: string;
|
|
26
29
|
actor?: "staff" | "customer" | "partner" | "supplier";
|
|
27
30
|
callerType?: "session" | "api_key" | "internal";
|
|
@@ -41,25 +44,6 @@ export type Env = {
|
|
|
41
44
|
}) => boolean | Promise<boolean>;
|
|
42
45
|
};
|
|
43
46
|
};
|
|
44
|
-
export declare function getRuntimeEnv(c: Context<Env>): {
|
|
45
|
-
KMS_PROVIDER?: string | undefined;
|
|
46
|
-
KMS_ENV_KEY?: string | undefined;
|
|
47
|
-
KMS_LOCAL_KEY?: string | undefined;
|
|
48
|
-
GCP_PROJECT_ID?: string | undefined;
|
|
49
|
-
GCP_SERVICE_ACCOUNT_EMAIL?: string | undefined;
|
|
50
|
-
GCP_PRIVATE_KEY?: string | undefined;
|
|
51
|
-
GCP_KMS_KEYRING?: string | undefined;
|
|
52
|
-
GCP_KMS_LOCATION?: string | undefined;
|
|
53
|
-
GCP_KMS_PEOPLE_KEY_NAME?: string | undefined;
|
|
54
|
-
GCP_KMS_INTEGRATIONS_KEY_NAME?: string | undefined;
|
|
55
|
-
AWS_REGION?: string | undefined;
|
|
56
|
-
AWS_ACCESS_KEY_ID?: string | undefined;
|
|
57
|
-
AWS_SECRET_ACCESS_KEY?: string | undefined;
|
|
58
|
-
AWS_SESSION_TOKEN?: string | undefined;
|
|
59
|
-
AWS_KMS_ENDPOINT?: string | undefined;
|
|
60
|
-
AWS_KMS_PEOPLE_KEY_ID?: string | undefined;
|
|
61
|
-
AWS_KMS_INTEGRATIONS_KEY_ID?: string | undefined;
|
|
62
|
-
};
|
|
63
47
|
export declare function hasParticipantIdentityInput(body: Record<string, unknown>): boolean;
|
|
64
48
|
export declare function logTransactionPiiAccess(c: Context<Env>, input: {
|
|
65
49
|
participantKind: "offer" | "order";
|
|
@@ -80,14 +64,7 @@ export declare function authorizeTransactionPiiAccess(c: Context<Env>, input: {
|
|
|
80
64
|
response?: undefined;
|
|
81
65
|
} | {
|
|
82
66
|
allowed: false;
|
|
83
|
-
response: Response
|
|
84
|
-
error: string;
|
|
85
|
-
}, 401, "json">;
|
|
86
|
-
} | {
|
|
87
|
-
allowed: false;
|
|
88
|
-
response: Response & import("hono").TypedResponse<{
|
|
89
|
-
error: string;
|
|
90
|
-
}, 403, "json">;
|
|
67
|
+
response: Response;
|
|
91
68
|
}>;
|
|
92
69
|
export declare function createPiiService(c: Context<Env>, _participantKind: "offer" | "order", parentId: string): {
|
|
93
70
|
getParticipantIdentity(db: PostgresJsDatabase, participantKind: "offer" | "order", participantId: string, actorId?: string | null): Promise<import("./index.js").DecryptedTransactionParticipantIdentity | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes-shared.d.ts","sourceRoot":"","sources":["../src/routes-shared.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routes-shared.d.ts","sourceRoot":"","sources":["../src/routes-shared.ts"],"names":[],"mappings":"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"}
|
package/dist/routes-shared.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ForbiddenApiError, handleApiError, UnauthorizedApiError } from "@voyantjs/hono";
|
|
2
2
|
import { createTransactionPiiService } from "./pii.js";
|
|
3
|
+
import { buildTransactionsRouteRuntime, TRANSACTIONS_ROUTE_RUNTIME_CONTAINER_KEY, } from "./route-runtime.js";
|
|
3
4
|
import { transactionPiiAccessLog } from "./schema.js";
|
|
4
|
-
export function getRuntimeEnv(c) {
|
|
5
|
-
const processEnv = globalThis.process?.env ?? {};
|
|
6
|
-
return {
|
|
7
|
-
...processEnv,
|
|
8
|
-
...(c.env ?? {}),
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
5
|
function hasPiiScope(scopes, action) {
|
|
12
6
|
if (!scopes || scopes.length === 0) {
|
|
13
7
|
return false;
|
|
@@ -43,7 +37,10 @@ export async function authorizeTransactionPiiAccess(c, input) {
|
|
|
43
37
|
const userId = c.get("userId");
|
|
44
38
|
if (!userId) {
|
|
45
39
|
await logTransactionPiiAccess(c, { ...input, outcome: "denied", reason: "missing_user" });
|
|
46
|
-
return {
|
|
40
|
+
return {
|
|
41
|
+
allowed: false,
|
|
42
|
+
response: handleApiError(new UnauthorizedApiError(), c),
|
|
43
|
+
};
|
|
47
44
|
}
|
|
48
45
|
const customAuthorizer = c.get("authorizeTransactionPii");
|
|
49
46
|
if (customAuthorizer) {
|
|
@@ -62,7 +59,10 @@ export async function authorizeTransactionPiiAccess(c, input) {
|
|
|
62
59
|
outcome: "denied",
|
|
63
60
|
reason: "custom_policy_denied",
|
|
64
61
|
});
|
|
65
|
-
return {
|
|
62
|
+
return {
|
|
63
|
+
allowed: false,
|
|
64
|
+
response: handleApiError(new ForbiddenApiError(), c),
|
|
65
|
+
};
|
|
66
66
|
}
|
|
67
67
|
return { allowed: true };
|
|
68
68
|
}
|
|
@@ -74,13 +74,21 @@ export async function authorizeTransactionPiiAccess(c, input) {
|
|
|
74
74
|
reason: "insufficient_scope",
|
|
75
75
|
metadata: { actor: c.get("actor") ?? null },
|
|
76
76
|
});
|
|
77
|
-
return {
|
|
77
|
+
return {
|
|
78
|
+
allowed: false,
|
|
79
|
+
response: handleApiError(new ForbiddenApiError(), c),
|
|
80
|
+
};
|
|
78
81
|
}
|
|
79
82
|
return { allowed: true };
|
|
80
83
|
}
|
|
84
|
+
function getRouteRuntime(c) {
|
|
85
|
+
const runtime = c.var.container?.resolve(TRANSACTIONS_ROUTE_RUNTIME_CONTAINER_KEY);
|
|
86
|
+
return runtime ?? buildTransactionsRouteRuntime(c.env);
|
|
87
|
+
}
|
|
81
88
|
export function createPiiService(c, _participantKind, parentId) {
|
|
89
|
+
const runtime = getRouteRuntime(c);
|
|
82
90
|
return createTransactionPiiService({
|
|
83
|
-
kms:
|
|
91
|
+
kms: runtime.getKmsProvider(),
|
|
84
92
|
onAudit: async (event) => {
|
|
85
93
|
await logTransactionPiiAccess(c, {
|
|
86
94
|
participantKind: event.participantKind,
|
package/dist/schema-audit.d.ts
CHANGED
|
@@ -126,7 +126,7 @@ export declare const transactionPiiAccessLog: import("drizzle-orm/pg-core").PgTa
|
|
|
126
126
|
tableName: "transaction_pii_access_log";
|
|
127
127
|
dataType: "string";
|
|
128
128
|
columnType: "PgEnumColumn";
|
|
129
|
-
data: "
|
|
129
|
+
data: "read" | "delete" | "update";
|
|
130
130
|
driverParam: string;
|
|
131
131
|
notNull: true;
|
|
132
132
|
hasDefault: false;
|
package/dist/schema-offers.d.ts
CHANGED
|
@@ -877,7 +877,7 @@ export declare const offerItems: import("drizzle-orm/pg-core").PgTableWithColumn
|
|
|
877
877
|
tableName: "offer_items";
|
|
878
878
|
dataType: "string";
|
|
879
879
|
columnType: "PgEnumColumn";
|
|
880
|
-
data: "
|
|
880
|
+
data: "service" | "other" | "unit" | "extra" | "fee" | "tax" | "discount" | "adjustment" | "accommodation" | "transport";
|
|
881
881
|
driverParam: string;
|
|
882
882
|
notNull: true;
|
|
883
883
|
hasDefault: true;
|
package/dist/schema-orders.d.ts
CHANGED
|
@@ -894,7 +894,7 @@ export declare const orderItems: import("drizzle-orm/pg-core").PgTableWithColumn
|
|
|
894
894
|
tableName: "order_items";
|
|
895
895
|
dataType: "string";
|
|
896
896
|
columnType: "PgEnumColumn";
|
|
897
|
-
data: "
|
|
897
|
+
data: "service" | "other" | "unit" | "extra" | "fee" | "tax" | "discount" | "adjustment" | "accommodation" | "transport";
|
|
898
898
|
driverParam: string;
|
|
899
899
|
notNull: true;
|
|
900
900
|
hasDefault: true;
|