@agentbadge/database 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import { type PrismaDb } from "./repositories/event-repository.js";
2
+ import { AgentWalletRepository } from "./repositories/agent-wallet-repository.js";
2
3
  import { type ChatSubscriptionStore, type ScanResultStore, type Store } from "./store.js";
3
4
  export interface DatabaseConfig {
4
5
  url?: string;
@@ -9,6 +10,7 @@ export interface Database {
9
10
  events: Store;
10
11
  scanResults: ScanResultStore;
11
12
  chatSubscriptions: ChatSubscriptionStore;
13
+ agentWallets: AgentWalletRepository | null;
12
14
  health(): Promise<boolean>;
13
15
  close(): Promise<void>;
14
16
  }
package/dist/database.js CHANGED
@@ -3,6 +3,7 @@ import contractJson from "./prisma/contract.json" with { type: "json" };
3
3
  import { EventRepository } from "./repositories/event-repository.js";
4
4
  import { ScanResultRepository } from "./repositories/scan-result-repository.js";
5
5
  import { ChatSubscriptionRepository } from "./repositories/chat-subscription-repository.js";
6
+ import { AgentWalletRepository } from "./repositories/agent-wallet-repository.js";
6
7
  import { InMemoryChatSubscriptionStore, InMemoryScanResultStore, InMemoryStore, } from "./store.js";
7
8
  export function createDatabase(config) {
8
9
  const enabled = config.enabled !== false && Boolean(config.url);
@@ -13,6 +14,7 @@ export function createDatabase(config) {
13
14
  events,
14
15
  scanResults: new InMemoryScanResultStore(),
15
16
  chatSubscriptions: new InMemoryChatSubscriptionStore(),
17
+ agentWallets: null,
16
18
  health: () => Promise.resolve(false),
17
19
  close: () => Promise.resolve(),
18
20
  };
@@ -23,6 +25,7 @@ export function createDatabase(config) {
23
25
  events: new EventRepository(db),
24
26
  scanResults: new ScanResultRepository(db),
25
27
  chatSubscriptions: new ChatSubscriptionRepository(db),
28
+ agentWallets: new AgentWalletRepository(db),
26
29
  health: async () => {
27
30
  try {
28
31
  const plan = db.raw.sql `SELECT 1 AS health`.returnsRow({ health: "pg/int4@1" }).build();
package/dist/index.d.ts CHANGED
@@ -9,4 +9,8 @@ export type { ChatSubscription, ChatSubscriptionCreate, ChatSubscriptionStore, C
9
9
  export { EventRepository } from "./repositories/event-repository.js";
10
10
  export { ScanResultRepository } from "./repositories/scan-result-repository.js";
11
11
  export { ChatSubscriptionRepository } from "./repositories/chat-subscription-repository.js";
12
+ export { VenueRepository } from "./repositories/venue-repository.js";
13
+ export type { VenueJobUpsert, VenueOfferUpsert, } from "./repositories/venue-repository.js";
14
+ export { AgentWalletRepository } from "./repositories/agent-wallet-repository.js";
15
+ export type { AgentWalletUpsert } from "./repositories/agent-wallet-repository.js";
12
16
  export type { PrismaDb } from "./repositories/event-repository.js";
package/dist/index.js CHANGED
@@ -6,3 +6,5 @@ export { InMemoryChatSubscriptionStore, InMemoryScanResultStore, InMemoryStore,
6
6
  export { EventRepository } from "./repositories/event-repository.js";
7
7
  export { ScanResultRepository } from "./repositories/scan-result-repository.js";
8
8
  export { ChatSubscriptionRepository } from "./repositories/chat-subscription-repository.js";
9
+ export { VenueRepository } from "./repositories/venue-repository.js";
10
+ export { AgentWalletRepository } from "./repositories/agent-wallet-repository.js";
@@ -4,6 +4,10 @@
4
4
  "target": "postgres",
5
5
  "profileHash": "3916f444a8a17ad749191acf9e08dad97d1a327b88c2f1d45d12f240296aa8b2",
6
6
  "roots": {
7
+ "agentWallet": {
8
+ "model": "AgentWallet",
9
+ "namespace": "public"
10
+ },
7
11
  "chatSubscription": {
8
12
  "model": "ChatSubscription",
9
13
  "namespace": "public"
@@ -15,12 +19,145 @@
15
19
  "scanResult": {
16
20
  "model": "ScanResult",
17
21
  "namespace": "public"
22
+ },
23
+ "venueJob": {
24
+ "model": "VenueJob",
25
+ "namespace": "public"
26
+ },
27
+ "venueMeta": {
28
+ "model": "VenueMeta",
29
+ "namespace": "public"
30
+ },
31
+ "venueOffer": {
32
+ "model": "VenueOffer",
33
+ "namespace": "public"
18
34
  }
19
35
  },
20
36
  "domain": {
21
37
  "namespaces": {
22
38
  "public": {
23
39
  "models": {
40
+ "AgentWallet": {
41
+ "fields": {
42
+ "active": {
43
+ "nullable": false,
44
+ "type": {
45
+ "codecId": "pg/bool@1",
46
+ "kind": "scalar"
47
+ }
48
+ },
49
+ "address": {
50
+ "nullable": false,
51
+ "type": {
52
+ "codecId": "pg/text@1",
53
+ "kind": "scalar"
54
+ }
55
+ },
56
+ "agentId": {
57
+ "nullable": true,
58
+ "type": {
59
+ "codecId": "pg/text@1",
60
+ "kind": "scalar"
61
+ }
62
+ },
63
+ "createdAt": {
64
+ "nullable": false,
65
+ "type": {
66
+ "codecId": "pg/timestamptz-string@1",
67
+ "kind": "scalar"
68
+ }
69
+ },
70
+ "id": {
71
+ "nullable": false,
72
+ "type": {
73
+ "codecId": "pg/text@1",
74
+ "kind": "scalar"
75
+ }
76
+ },
77
+ "kind": {
78
+ "nullable": false,
79
+ "type": {
80
+ "codecId": "pg/text@1",
81
+ "kind": "scalar"
82
+ }
83
+ },
84
+ "label": {
85
+ "nullable": false,
86
+ "type": {
87
+ "codecId": "pg/text@1",
88
+ "kind": "scalar"
89
+ }
90
+ },
91
+ "payload": {
92
+ "nullable": false,
93
+ "type": {
94
+ "codecId": "pg/json@1",
95
+ "kind": "scalar"
96
+ }
97
+ },
98
+ "registeredBy": {
99
+ "nullable": false,
100
+ "type": {
101
+ "codecId": "pg/text@1",
102
+ "kind": "scalar"
103
+ }
104
+ },
105
+ "updatedAt": {
106
+ "nullable": false,
107
+ "type": {
108
+ "codecId": "pg/timestamptz-string@1",
109
+ "kind": "scalar"
110
+ }
111
+ },
112
+ "venueId": {
113
+ "nullable": true,
114
+ "type": {
115
+ "codecId": "pg/text@1",
116
+ "kind": "scalar"
117
+ }
118
+ }
119
+ },
120
+ "relations": {},
121
+ "storage": {
122
+ "fields": {
123
+ "active": {
124
+ "column": "active"
125
+ },
126
+ "address": {
127
+ "column": "address"
128
+ },
129
+ "agentId": {
130
+ "column": "agentId"
131
+ },
132
+ "createdAt": {
133
+ "column": "createdAt"
134
+ },
135
+ "id": {
136
+ "column": "id"
137
+ },
138
+ "kind": {
139
+ "column": "kind"
140
+ },
141
+ "label": {
142
+ "column": "label"
143
+ },
144
+ "payload": {
145
+ "column": "payload"
146
+ },
147
+ "registeredBy": {
148
+ "column": "registeredBy"
149
+ },
150
+ "updatedAt": {
151
+ "column": "updatedAt"
152
+ },
153
+ "venueId": {
154
+ "column": "venueId"
155
+ }
156
+ },
157
+ "namespaceId": "public",
158
+ "table": "agentWallet"
159
+ }
160
+ },
24
161
  "ChatSubscription": {
25
162
  "fields": {
26
163
  "chatId": {
@@ -233,26 +370,337 @@
233
370
  "score": {
234
371
  "column": "score"
235
372
  },
236
- "updatedAt": {
237
- "column": "updatedAt"
373
+ "updatedAt": {
374
+ "column": "updatedAt"
375
+ },
376
+ "url": {
377
+ "column": "url"
378
+ }
379
+ },
380
+ "namespaceId": "public",
381
+ "table": "scanResult"
382
+ }
383
+ },
384
+ "VenueJob": {
385
+ "fields": {
386
+ "client": {
387
+ "nullable": false,
388
+ "type": {
389
+ "codecId": "pg/text@1",
390
+ "kind": "scalar"
391
+ }
392
+ },
393
+ "createdAt": {
394
+ "nullable": false,
395
+ "type": {
396
+ "codecId": "pg/timestamptz-string@1",
397
+ "kind": "scalar"
398
+ }
399
+ },
400
+ "id": {
401
+ "nullable": false,
402
+ "type": {
403
+ "codecId": "pg/text@1",
404
+ "kind": "scalar"
405
+ }
406
+ },
407
+ "jobId": {
408
+ "nullable": false,
409
+ "type": {
410
+ "codecId": "pg/text@1",
411
+ "kind": "scalar"
412
+ }
413
+ },
414
+ "payload": {
415
+ "nullable": false,
416
+ "type": {
417
+ "codecId": "pg/json@1",
418
+ "kind": "scalar"
419
+ }
420
+ },
421
+ "provider": {
422
+ "nullable": true,
423
+ "type": {
424
+ "codecId": "pg/text@1",
425
+ "kind": "scalar"
426
+ }
427
+ },
428
+ "status": {
429
+ "nullable": false,
430
+ "type": {
431
+ "codecId": "pg/text@1",
432
+ "kind": "scalar"
433
+ }
434
+ },
435
+ "updatedAt": {
436
+ "nullable": false,
437
+ "type": {
438
+ "codecId": "pg/timestamptz-string@1",
439
+ "kind": "scalar"
440
+ }
441
+ }
442
+ },
443
+ "relations": {},
444
+ "storage": {
445
+ "fields": {
446
+ "client": {
447
+ "column": "client"
448
+ },
449
+ "createdAt": {
450
+ "column": "createdAt"
451
+ },
452
+ "id": {
453
+ "column": "id"
454
+ },
455
+ "jobId": {
456
+ "column": "jobId"
457
+ },
458
+ "payload": {
459
+ "column": "payload"
460
+ },
461
+ "provider": {
462
+ "column": "provider"
463
+ },
464
+ "status": {
465
+ "column": "status"
466
+ },
467
+ "updatedAt": {
468
+ "column": "updatedAt"
469
+ }
470
+ },
471
+ "namespaceId": "public",
472
+ "table": "venueJob"
473
+ }
474
+ },
475
+ "VenueMeta": {
476
+ "fields": {
477
+ "key": {
478
+ "nullable": false,
479
+ "type": {
480
+ "codecId": "pg/text@1",
481
+ "kind": "scalar"
482
+ }
483
+ },
484
+ "updatedAt": {
485
+ "nullable": false,
486
+ "type": {
487
+ "codecId": "pg/timestamptz-string@1",
488
+ "kind": "scalar"
489
+ }
490
+ },
491
+ "value": {
492
+ "nullable": false,
493
+ "type": {
494
+ "codecId": "pg/json@1",
495
+ "kind": "scalar"
496
+ }
497
+ }
498
+ },
499
+ "relations": {},
500
+ "storage": {
501
+ "fields": {
502
+ "key": {
503
+ "column": "key"
504
+ },
505
+ "updatedAt": {
506
+ "column": "updatedAt"
507
+ },
508
+ "value": {
509
+ "column": "value"
510
+ }
511
+ },
512
+ "namespaceId": "public",
513
+ "table": "venueMeta"
514
+ }
515
+ },
516
+ "VenueOffer": {
517
+ "fields": {
518
+ "active": {
519
+ "nullable": false,
520
+ "type": {
521
+ "codecId": "pg/bool@1",
522
+ "kind": "scalar"
523
+ }
524
+ },
525
+ "createdAt": {
526
+ "nullable": false,
527
+ "type": {
528
+ "codecId": "pg/timestamptz-string@1",
529
+ "kind": "scalar"
530
+ }
531
+ },
532
+ "id": {
533
+ "nullable": false,
534
+ "type": {
535
+ "codecId": "pg/text@1",
536
+ "kind": "scalar"
537
+ }
538
+ },
539
+ "payload": {
540
+ "nullable": false,
541
+ "type": {
542
+ "codecId": "pg/json@1",
543
+ "kind": "scalar"
544
+ }
545
+ },
546
+ "providerAddress": {
547
+ "nullable": false,
548
+ "type": {
549
+ "codecId": "pg/text@1",
550
+ "kind": "scalar"
551
+ }
552
+ },
553
+ "updatedAt": {
554
+ "nullable": false,
555
+ "type": {
556
+ "codecId": "pg/timestamptz-string@1",
557
+ "kind": "scalar"
558
+ }
559
+ }
560
+ },
561
+ "relations": {},
562
+ "storage": {
563
+ "fields": {
564
+ "active": {
565
+ "column": "active"
566
+ },
567
+ "createdAt": {
568
+ "column": "createdAt"
569
+ },
570
+ "id": {
571
+ "column": "id"
572
+ },
573
+ "payload": {
574
+ "column": "payload"
575
+ },
576
+ "providerAddress": {
577
+ "column": "providerAddress"
578
+ },
579
+ "updatedAt": {
580
+ "column": "updatedAt"
581
+ }
582
+ },
583
+ "namespaceId": "public",
584
+ "table": "venueOffer"
585
+ }
586
+ }
587
+ }
588
+ }
589
+ }
590
+ },
591
+ "storage": {
592
+ "namespaces": {
593
+ "public": {
594
+ "entries": {
595
+ "table": {
596
+ "agentWallet": {
597
+ "columns": {
598
+ "active": {
599
+ "codecId": "pg/bool@1",
600
+ "default": {
601
+ "kind": "literal",
602
+ "value": true
603
+ },
604
+ "nativeType": "bool",
605
+ "nullable": false
606
+ },
607
+ "address": {
608
+ "codecId": "pg/text@1",
609
+ "nativeType": "text",
610
+ "nullable": false
611
+ },
612
+ "agentId": {
613
+ "codecId": "pg/text@1",
614
+ "nativeType": "text",
615
+ "nullable": true
616
+ },
617
+ "createdAt": {
618
+ "codecId": "pg/timestamptz-string@1",
619
+ "default": {
620
+ "expression": "now()",
621
+ "kind": "function"
622
+ },
623
+ "nativeType": "timestamptz",
624
+ "nullable": false
625
+ },
626
+ "id": {
627
+ "codecId": "pg/text@1",
628
+ "nativeType": "text",
629
+ "nullable": false
630
+ },
631
+ "kind": {
632
+ "codecId": "pg/text@1",
633
+ "nativeType": "text",
634
+ "nullable": false
635
+ },
636
+ "label": {
637
+ "codecId": "pg/text@1",
638
+ "nativeType": "text",
639
+ "nullable": false
640
+ },
641
+ "payload": {
642
+ "codecId": "pg/json@1",
643
+ "nativeType": "json",
644
+ "nullable": false
645
+ },
646
+ "registeredBy": {
647
+ "codecId": "pg/text@1",
648
+ "nativeType": "text",
649
+ "nullable": false
650
+ },
651
+ "updatedAt": {
652
+ "codecId": "pg/timestamptz-string@1",
653
+ "nativeType": "timestamptz",
654
+ "nullable": false
655
+ },
656
+ "venueId": {
657
+ "codecId": "pg/text@1",
658
+ "nativeType": "text",
659
+ "nullable": true
660
+ }
661
+ },
662
+ "foreignKeys": [],
663
+ "indexes": [
664
+ {
665
+ "columns": [
666
+ "active",
667
+ "createdAt"
668
+ ],
669
+ "name": "agentWallet_active_createdAt_idx_7cd57621",
670
+ "prefix": "agentWallet_active_createdAt_idx",
671
+ "unique": false
672
+ },
673
+ {
674
+ "columns": [
675
+ "agentId"
676
+ ],
677
+ "name": "agentWallet_agentId_idx_8d0ba4f0",
678
+ "prefix": "agentWallet_agentId_idx",
679
+ "unique": false
238
680
  },
239
- "url": {
240
- "column": "url"
681
+ {
682
+ "columns": [
683
+ "venueId",
684
+ "active"
685
+ ],
686
+ "name": "agentWallet_venueId_active_idx_51915f5b",
687
+ "prefix": "agentWallet_venueId_active_idx",
688
+ "unique": false
241
689
  }
690
+ ],
691
+ "primaryKey": {
692
+ "columns": [
693
+ "id"
694
+ ]
242
695
  },
243
- "namespaceId": "public",
244
- "table": "scanResult"
245
- }
246
- }
247
- }
248
- }
249
- }
250
- },
251
- "storage": {
252
- "namespaces": {
253
- "public": {
254
- "entries": {
255
- "table": {
696
+ "uniques": [
697
+ {
698
+ "columns": [
699
+ "address"
700
+ ]
701
+ }
702
+ ]
703
+ },
256
704
  "chatSubscription": {
257
705
  "columns": {
258
706
  "chatId": {
@@ -426,6 +874,173 @@
426
874
  ]
427
875
  },
428
876
  "uniques": []
877
+ },
878
+ "venueJob": {
879
+ "columns": {
880
+ "client": {
881
+ "codecId": "pg/text@1",
882
+ "nativeType": "text",
883
+ "nullable": false
884
+ },
885
+ "createdAt": {
886
+ "codecId": "pg/timestamptz-string@1",
887
+ "default": {
888
+ "expression": "now()",
889
+ "kind": "function"
890
+ },
891
+ "nativeType": "timestamptz",
892
+ "nullable": false
893
+ },
894
+ "id": {
895
+ "codecId": "pg/text@1",
896
+ "nativeType": "text",
897
+ "nullable": false
898
+ },
899
+ "jobId": {
900
+ "codecId": "pg/text@1",
901
+ "nativeType": "text",
902
+ "nullable": false
903
+ },
904
+ "payload": {
905
+ "codecId": "pg/json@1",
906
+ "nativeType": "json",
907
+ "nullable": false
908
+ },
909
+ "provider": {
910
+ "codecId": "pg/text@1",
911
+ "nativeType": "text",
912
+ "nullable": true
913
+ },
914
+ "status": {
915
+ "codecId": "pg/text@1",
916
+ "nativeType": "text",
917
+ "nullable": false
918
+ },
919
+ "updatedAt": {
920
+ "codecId": "pg/timestamptz-string@1",
921
+ "nativeType": "timestamptz",
922
+ "nullable": false
923
+ }
924
+ },
925
+ "foreignKeys": [],
926
+ "indexes": [
927
+ {
928
+ "columns": [
929
+ "client"
930
+ ],
931
+ "name": "venueJob_client_idx_135b7ce5",
932
+ "prefix": "venueJob_client_idx",
933
+ "unique": false
934
+ },
935
+ {
936
+ "columns": [
937
+ "status",
938
+ "createdAt"
939
+ ],
940
+ "name": "venueJob_status_createdAt_idx_58610442",
941
+ "prefix": "venueJob_status_createdAt_idx",
942
+ "unique": false
943
+ }
944
+ ],
945
+ "primaryKey": {
946
+ "columns": [
947
+ "id"
948
+ ]
949
+ },
950
+ "uniques": [
951
+ {
952
+ "columns": [
953
+ "jobId"
954
+ ]
955
+ }
956
+ ]
957
+ },
958
+ "venueMeta": {
959
+ "columns": {
960
+ "key": {
961
+ "codecId": "pg/text@1",
962
+ "nativeType": "text",
963
+ "nullable": false
964
+ },
965
+ "updatedAt": {
966
+ "codecId": "pg/timestamptz-string@1",
967
+ "nativeType": "timestamptz",
968
+ "nullable": false
969
+ },
970
+ "value": {
971
+ "codecId": "pg/json@1",
972
+ "nativeType": "json",
973
+ "nullable": false
974
+ }
975
+ },
976
+ "foreignKeys": [],
977
+ "indexes": [],
978
+ "primaryKey": {
979
+ "columns": [
980
+ "key"
981
+ ]
982
+ },
983
+ "uniques": []
984
+ },
985
+ "venueOffer": {
986
+ "columns": {
987
+ "active": {
988
+ "codecId": "pg/bool@1",
989
+ "default": {
990
+ "kind": "literal",
991
+ "value": true
992
+ },
993
+ "nativeType": "bool",
994
+ "nullable": false
995
+ },
996
+ "createdAt": {
997
+ "codecId": "pg/timestamptz-string@1",
998
+ "default": {
999
+ "expression": "now()",
1000
+ "kind": "function"
1001
+ },
1002
+ "nativeType": "timestamptz",
1003
+ "nullable": false
1004
+ },
1005
+ "id": {
1006
+ "codecId": "pg/text@1",
1007
+ "nativeType": "text",
1008
+ "nullable": false
1009
+ },
1010
+ "payload": {
1011
+ "codecId": "pg/json@1",
1012
+ "nativeType": "json",
1013
+ "nullable": false
1014
+ },
1015
+ "providerAddress": {
1016
+ "codecId": "pg/text@1",
1017
+ "nativeType": "text",
1018
+ "nullable": false
1019
+ },
1020
+ "updatedAt": {
1021
+ "codecId": "pg/timestamptz-string@1",
1022
+ "nativeType": "timestamptz",
1023
+ "nullable": false
1024
+ }
1025
+ },
1026
+ "foreignKeys": [],
1027
+ "indexes": [
1028
+ {
1029
+ "columns": [
1030
+ "providerAddress",
1031
+ "active"
1032
+ ],
1033
+ "name": "venueOffer_providerAddress_active_idx_bf5e414c",
1034
+ "prefix": "venueOffer_providerAddress_active_idx",
1035
+ "unique": false
1036
+ }
1037
+ ],
1038
+ "primaryKey": {
1039
+ "columns": [
1040
+ "id"
1041
+ ]
1042
+ },
1043
+ "uniques": []
429
1044
  }
430
1045
  }
431
1046
  },
@@ -433,12 +1048,38 @@
433
1048
  "kind": "postgres-schema"
434
1049
  }
435
1050
  },
436
- "storageHash": "34b23f5aeb2d36a58036b2eadcc94edf8dbcdf7644aa9eae5517ba51d66451df"
1051
+ "storageHash": "b8e32f5ce86590030c6c80c1f24c199aae7daf9a6869951a0b1af2903d31f177"
437
1052
  },
438
1053
  "execution": {
439
- "executionHash": "9a73be325ad1106310581a4337ffd4cb14486296a033307f46ad89116d36d6ce",
1054
+ "executionHash": "44a1f33983dd3b516b7a09d20036645e5dd41f325ead0441f78cf5b6647741a6",
440
1055
  "mutations": {
441
1056
  "defaults": [
1057
+ {
1058
+ "onCreate": {
1059
+ "id": "uuidv4",
1060
+ "kind": "generator"
1061
+ },
1062
+ "ref": {
1063
+ "column": "id",
1064
+ "namespace": "public",
1065
+ "table": "agentWallet"
1066
+ }
1067
+ },
1068
+ {
1069
+ "onCreate": {
1070
+ "id": "timestampNow",
1071
+ "kind": "generator"
1072
+ },
1073
+ "onUpdate": {
1074
+ "id": "timestampNow",
1075
+ "kind": "generator"
1076
+ },
1077
+ "ref": {
1078
+ "column": "updatedAt",
1079
+ "namespace": "public",
1080
+ "table": "agentWallet"
1081
+ }
1082
+ },
442
1083
  {
443
1084
  "onCreate": {
444
1085
  "id": "uuidv4",
@@ -516,6 +1157,62 @@
516
1157
  "namespace": "public",
517
1158
  "table": "scanResult"
518
1159
  }
1160
+ },
1161
+ {
1162
+ "onCreate": {
1163
+ "id": "uuidv4",
1164
+ "kind": "generator"
1165
+ },
1166
+ "ref": {
1167
+ "column": "id",
1168
+ "namespace": "public",
1169
+ "table": "venueJob"
1170
+ }
1171
+ },
1172
+ {
1173
+ "onCreate": {
1174
+ "id": "timestampNow",
1175
+ "kind": "generator"
1176
+ },
1177
+ "onUpdate": {
1178
+ "id": "timestampNow",
1179
+ "kind": "generator"
1180
+ },
1181
+ "ref": {
1182
+ "column": "updatedAt",
1183
+ "namespace": "public",
1184
+ "table": "venueJob"
1185
+ }
1186
+ },
1187
+ {
1188
+ "onCreate": {
1189
+ "id": "timestampNow",
1190
+ "kind": "generator"
1191
+ },
1192
+ "onUpdate": {
1193
+ "id": "timestampNow",
1194
+ "kind": "generator"
1195
+ },
1196
+ "ref": {
1197
+ "column": "updatedAt",
1198
+ "namespace": "public",
1199
+ "table": "venueMeta"
1200
+ }
1201
+ },
1202
+ {
1203
+ "onCreate": {
1204
+ "id": "timestampNow",
1205
+ "kind": "generator"
1206
+ },
1207
+ "onUpdate": {
1208
+ "id": "timestampNow",
1209
+ "kind": "generator"
1210
+ },
1211
+ "ref": {
1212
+ "column": "updatedAt",
1213
+ "namespace": "public",
1214
+ "table": "venueOffer"
1215
+ }
519
1216
  }
520
1217
  ]
521
1218
  }
@@ -0,0 +1,29 @@
1
+ import type { JsonValue } from "@prisma/orm-postgres/target/codec-types";
2
+ import type { Models } from "../prisma/contract.d.js";
3
+ import type { PrismaDb } from "./event-repository.js";
4
+ type Row = Models.public_AgentWallet;
5
+ export interface AgentWalletUpsert {
6
+ address: string;
7
+ agentId?: string | null;
8
+ venueId?: string | null;
9
+ label: string;
10
+ kind: string;
11
+ registeredBy: string;
12
+ active?: boolean;
13
+ payload: JsonValue;
14
+ }
15
+ export declare class AgentWalletRepository {
16
+ private readonly db;
17
+ constructor(db: PrismaDb);
18
+ upsert(w: AgentWalletUpsert): Promise<Row>;
19
+ getByAddress(address: string): Promise<Row | null>;
20
+ list(opts?: {
21
+ venueId?: string;
22
+ agentId?: string;
23
+ active?: boolean;
24
+ limit?: number;
25
+ }): Promise<Row[]>;
26
+ deactivate(address: string): Promise<boolean>;
27
+ setEnvelope(address: string, payload: JsonValue): Promise<boolean>;
28
+ }
29
+ export {};
@@ -0,0 +1,59 @@
1
+ export class AgentWalletRepository {
2
+ db;
3
+ constructor(db) {
4
+ this.db = db;
5
+ }
6
+ async upsert(w) {
7
+ return this.db.orm.public.AgentWallet.upsert({
8
+ create: {
9
+ address: w.address.toLowerCase(),
10
+ agentId: w.agentId ?? null,
11
+ venueId: w.venueId ?? null,
12
+ label: w.label,
13
+ kind: w.kind,
14
+ registeredBy: w.registeredBy,
15
+ active: w.active ?? true,
16
+ payload: w.payload,
17
+ },
18
+ update: {
19
+ agentId: w.agentId ?? null,
20
+ venueId: w.venueId ?? null,
21
+ label: w.label,
22
+ kind: w.kind,
23
+ registeredBy: w.registeredBy,
24
+ ...(w.active !== undefined ? { active: w.active } : {}),
25
+ payload: w.payload,
26
+ },
27
+ conflictOn: { address: w.address.toLowerCase() },
28
+ });
29
+ }
30
+ async getByAddress(address) {
31
+ return this.db.orm.public.AgentWallet.where({
32
+ address: address.toLowerCase(),
33
+ }).first();
34
+ }
35
+ async list(opts) {
36
+ let q = this.db.orm.public.AgentWallet.orderBy((w) => w.createdAt.desc());
37
+ if (opts?.venueId !== undefined)
38
+ q = q.where({ venueId: opts.venueId });
39
+ if (opts?.agentId !== undefined)
40
+ q = q.where({ agentId: opts.agentId });
41
+ if (opts?.active !== undefined)
42
+ q = q.where({ active: opts.active });
43
+ if (opts?.limit !== undefined)
44
+ q = q.limit(opts.limit);
45
+ return q.all();
46
+ }
47
+ async deactivate(address) {
48
+ const row = await this.db.orm.public.AgentWallet.where({
49
+ address: address.toLowerCase(),
50
+ }).update({ active: false });
51
+ return row !== null;
52
+ }
53
+ async setEnvelope(address, payload) {
54
+ const row = await this.db.orm.public.AgentWallet.where({
55
+ address: address.toLowerCase(),
56
+ }).update({ payload });
57
+ return row !== null;
58
+ }
59
+ }
@@ -0,0 +1,36 @@
1
+ import type { JsonValue } from "@prisma/orm-postgres/target/codec-types";
2
+ import type { Models } from "../prisma/contract.d.js";
3
+ import type { PrismaDb } from "./event-repository.js";
4
+ type VenueJobRow = Models.public_VenueJob;
5
+ type VenueOfferRow = Models.public_VenueOffer;
6
+ type VenueMetaRow = Models.public_VenueMeta;
7
+ export interface VenueJobUpsert {
8
+ jobId: string;
9
+ status: string;
10
+ client: string;
11
+ provider?: string | null;
12
+ payload: JsonValue;
13
+ }
14
+ export interface VenueOfferUpsert {
15
+ id: string;
16
+ providerAddress: string;
17
+ active: boolean;
18
+ payload: JsonValue;
19
+ }
20
+ export declare class VenueRepository {
21
+ private readonly db;
22
+ constructor(db: PrismaDb);
23
+ upsertJob(j: VenueJobUpsert): Promise<VenueJobRow>;
24
+ getJob(jobId: string): Promise<VenueJobRow | null>;
25
+ listJobs(opts?: {
26
+ status?: string;
27
+ limit?: number;
28
+ }): Promise<VenueJobRow[]>;
29
+ upsertOffer(o: VenueOfferUpsert): Promise<VenueOfferRow>;
30
+ listOffers(opts?: {
31
+ active?: boolean;
32
+ }): Promise<VenueOfferRow[]>;
33
+ getMeta(key: string): Promise<JsonValue | undefined>;
34
+ setMeta(key: string, value: JsonValue): Promise<VenueMetaRow>;
35
+ }
36
+ export {};
@@ -0,0 +1,68 @@
1
+ export class VenueRepository {
2
+ db;
3
+ constructor(db) {
4
+ this.db = db;
5
+ }
6
+ async upsertJob(j) {
7
+ return this.db.orm.public.VenueJob.upsert({
8
+ create: {
9
+ jobId: j.jobId,
10
+ status: j.status,
11
+ client: j.client,
12
+ provider: j.provider ?? null,
13
+ payload: j.payload,
14
+ },
15
+ update: {
16
+ status: j.status,
17
+ client: j.client,
18
+ provider: j.provider ?? null,
19
+ payload: j.payload,
20
+ },
21
+ conflictOn: { jobId: j.jobId },
22
+ });
23
+ }
24
+ async getJob(jobId) {
25
+ return this.db.orm.public.VenueJob.where({ jobId }).first();
26
+ }
27
+ async listJobs(opts) {
28
+ let q = this.db.orm.public.VenueJob.orderBy((j) => j.createdAt.desc());
29
+ if (opts?.status !== undefined)
30
+ q = q.where({ status: opts.status });
31
+ if (opts?.limit !== undefined)
32
+ q = q.limit(opts.limit);
33
+ return q.all();
34
+ }
35
+ async upsertOffer(o) {
36
+ return this.db.orm.public.VenueOffer.upsert({
37
+ create: {
38
+ id: o.id,
39
+ providerAddress: o.providerAddress,
40
+ active: o.active,
41
+ payload: o.payload,
42
+ },
43
+ update: {
44
+ providerAddress: o.providerAddress,
45
+ active: o.active,
46
+ payload: o.payload,
47
+ },
48
+ conflictOn: { id: o.id },
49
+ });
50
+ }
51
+ async listOffers(opts) {
52
+ let q = this.db.orm.public.VenueOffer.orderBy((o) => o.createdAt.desc());
53
+ if (opts?.active !== undefined)
54
+ q = q.where({ active: opts.active });
55
+ return q.all();
56
+ }
57
+ async getMeta(key) {
58
+ const row = await this.db.orm.public.VenueMeta.where({ key }).first();
59
+ return row?.value;
60
+ }
61
+ async setMeta(key, value) {
62
+ return this.db.orm.public.VenueMeta.upsert({
63
+ create: { key, value },
64
+ update: { value },
65
+ conflictOn: { key },
66
+ });
67
+ }
68
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentbadge/database",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Shared database layer for AgentBadge — Prisma ORM 8 client, repositories, store abstraction",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",