@agentbadge/database 0.6.0 → 0.6.1

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.
@@ -16,6 +16,10 @@
16
16
  "model": "A2ATask",
17
17
  "namespace": "public"
18
18
  },
19
+ "agentTrustEdge": {
20
+ "model": "AgentTrustEdge",
21
+ "namespace": "public"
22
+ },
19
23
  "agentWallet": {
20
24
  "model": "AgentWallet",
21
25
  "namespace": "public"
@@ -80,6 +84,10 @@
80
84
  "model": "EaasVerdict",
81
85
  "namespace": "public"
82
86
  },
87
+ "economicEvent": {
88
+ "model": "EconomicEvent",
89
+ "namespace": "public"
90
+ },
83
91
  "event": {
84
92
  "model": "Event",
85
93
  "namespace": "public"
@@ -404,6 +412,137 @@
404
412
  "table": "a2ATask"
405
413
  }
406
414
  },
415
+ "AgentTrustEdge": {
416
+ "fields": {
417
+ "createdAt": {
418
+ "nullable": false,
419
+ "type": {
420
+ "codecId": "pg/timestamptz-string@1",
421
+ "kind": "scalar"
422
+ }
423
+ },
424
+ "eventCount": {
425
+ "nullable": false,
426
+ "type": {
427
+ "codecId": "pg/int4@1",
428
+ "kind": "scalar"
429
+ }
430
+ },
431
+ "firstEventAt": {
432
+ "nullable": true,
433
+ "type": {
434
+ "codecId": "pg/text@1",
435
+ "kind": "scalar"
436
+ }
437
+ },
438
+ "firstEventSeq": {
439
+ "nullable": true,
440
+ "type": {
441
+ "codecId": "pg/int8@1",
442
+ "kind": "scalar"
443
+ }
444
+ },
445
+ "fromAgent": {
446
+ "nullable": false,
447
+ "type": {
448
+ "codecId": "pg/text@1",
449
+ "kind": "scalar"
450
+ }
451
+ },
452
+ "id": {
453
+ "nullable": false,
454
+ "type": {
455
+ "codecId": "pg/text@1",
456
+ "kind": "scalar"
457
+ }
458
+ },
459
+ "kind": {
460
+ "nullable": false,
461
+ "type": {
462
+ "codecId": "pg/text@1",
463
+ "kind": "scalar"
464
+ }
465
+ },
466
+ "lastEventAt": {
467
+ "nullable": false,
468
+ "type": {
469
+ "codecId": "pg/text@1",
470
+ "kind": "scalar"
471
+ }
472
+ },
473
+ "lastEventSeq": {
474
+ "nullable": false,
475
+ "type": {
476
+ "codecId": "pg/int8@1",
477
+ "kind": "scalar"
478
+ }
479
+ },
480
+ "toAgent": {
481
+ "nullable": false,
482
+ "type": {
483
+ "codecId": "pg/text@1",
484
+ "kind": "scalar"
485
+ }
486
+ },
487
+ "totalUsd": {
488
+ "nullable": false,
489
+ "type": {
490
+ "codecId": "pg/numeric@1",
491
+ "kind": "scalar"
492
+ }
493
+ },
494
+ "updatedAt": {
495
+ "nullable": false,
496
+ "type": {
497
+ "codecId": "pg/timestamptz-string@1",
498
+ "kind": "scalar"
499
+ }
500
+ }
501
+ },
502
+ "relations": {},
503
+ "storage": {
504
+ "fields": {
505
+ "createdAt": {
506
+ "column": "createdAt"
507
+ },
508
+ "eventCount": {
509
+ "column": "eventCount"
510
+ },
511
+ "firstEventAt": {
512
+ "column": "firstEventAt"
513
+ },
514
+ "firstEventSeq": {
515
+ "column": "firstEventSeq"
516
+ },
517
+ "fromAgent": {
518
+ "column": "fromAgent"
519
+ },
520
+ "id": {
521
+ "column": "id"
522
+ },
523
+ "kind": {
524
+ "column": "kind"
525
+ },
526
+ "lastEventAt": {
527
+ "column": "lastEventAt"
528
+ },
529
+ "lastEventSeq": {
530
+ "column": "lastEventSeq"
531
+ },
532
+ "toAgent": {
533
+ "column": "toAgent"
534
+ },
535
+ "totalUsd": {
536
+ "column": "totalUsd"
537
+ },
538
+ "updatedAt": {
539
+ "column": "updatedAt"
540
+ }
541
+ },
542
+ "namespaceId": "public",
543
+ "table": "agentTrustEdge"
544
+ }
545
+ },
407
546
  "AgentWallet": {
408
547
  "fields": {
409
548
  "active": {
@@ -2250,6 +2389,167 @@
2250
2389
  "table": "eaasVerdict"
2251
2390
  }
2252
2391
  },
2392
+ "EconomicEvent": {
2393
+ "fields": {
2394
+ "actor": {
2395
+ "nullable": false,
2396
+ "type": {
2397
+ "codecId": "pg/text@1",
2398
+ "kind": "scalar"
2399
+ }
2400
+ },
2401
+ "amountUsdc": {
2402
+ "nullable": true,
2403
+ "type": {
2404
+ "codecId": "pg/numeric@1",
2405
+ "kind": "scalar"
2406
+ }
2407
+ },
2408
+ "at": {
2409
+ "nullable": false,
2410
+ "type": {
2411
+ "codecId": "pg/text@1",
2412
+ "kind": "scalar"
2413
+ }
2414
+ },
2415
+ "counterparty": {
2416
+ "nullable": true,
2417
+ "type": {
2418
+ "codecId": "pg/text@1",
2419
+ "kind": "scalar"
2420
+ }
2421
+ },
2422
+ "createdAt": {
2423
+ "nullable": false,
2424
+ "type": {
2425
+ "codecId": "pg/timestamptz-string@1",
2426
+ "kind": "scalar"
2427
+ }
2428
+ },
2429
+ "id": {
2430
+ "nullable": false,
2431
+ "type": {
2432
+ "codecId": "pg/text@1",
2433
+ "kind": "scalar"
2434
+ }
2435
+ },
2436
+ "idempotencyKey": {
2437
+ "nullable": false,
2438
+ "type": {
2439
+ "codecId": "pg/text@1",
2440
+ "kind": "scalar"
2441
+ }
2442
+ },
2443
+ "kind": {
2444
+ "nullable": false,
2445
+ "type": {
2446
+ "codecId": "pg/text@1",
2447
+ "kind": "scalar"
2448
+ }
2449
+ },
2450
+ "ledgerSeq": {
2451
+ "nullable": false,
2452
+ "type": {
2453
+ "codecId": "pg/int8@1",
2454
+ "kind": "scalar"
2455
+ }
2456
+ },
2457
+ "payload": {
2458
+ "nullable": false,
2459
+ "type": {
2460
+ "codecId": "pg/json@1",
2461
+ "kind": "scalar"
2462
+ }
2463
+ },
2464
+ "seq": {
2465
+ "nullable": false,
2466
+ "type": {
2467
+ "codecId": "pg/int4@1",
2468
+ "kind": "scalar"
2469
+ }
2470
+ },
2471
+ "source": {
2472
+ "nullable": false,
2473
+ "type": {
2474
+ "codecId": "pg/text@1",
2475
+ "kind": "scalar"
2476
+ }
2477
+ },
2478
+ "sourceId": {
2479
+ "nullable": false,
2480
+ "type": {
2481
+ "codecId": "pg/text@1",
2482
+ "kind": "scalar"
2483
+ }
2484
+ },
2485
+ "spec": {
2486
+ "nullable": false,
2487
+ "type": {
2488
+ "codecId": "pg/text@1",
2489
+ "kind": "scalar"
2490
+ }
2491
+ },
2492
+ "updatedAt": {
2493
+ "nullable": false,
2494
+ "type": {
2495
+ "codecId": "pg/timestamptz-string@1",
2496
+ "kind": "scalar"
2497
+ }
2498
+ }
2499
+ },
2500
+ "relations": {},
2501
+ "storage": {
2502
+ "fields": {
2503
+ "actor": {
2504
+ "column": "actor"
2505
+ },
2506
+ "amountUsdc": {
2507
+ "column": "amountUsdc"
2508
+ },
2509
+ "at": {
2510
+ "column": "at"
2511
+ },
2512
+ "counterparty": {
2513
+ "column": "counterparty"
2514
+ },
2515
+ "createdAt": {
2516
+ "column": "createdAt"
2517
+ },
2518
+ "id": {
2519
+ "column": "id"
2520
+ },
2521
+ "idempotencyKey": {
2522
+ "column": "idempotencyKey"
2523
+ },
2524
+ "kind": {
2525
+ "column": "kind"
2526
+ },
2527
+ "ledgerSeq": {
2528
+ "column": "ledgerSeq"
2529
+ },
2530
+ "payload": {
2531
+ "column": "payload"
2532
+ },
2533
+ "seq": {
2534
+ "column": "seq"
2535
+ },
2536
+ "source": {
2537
+ "column": "source"
2538
+ },
2539
+ "sourceId": {
2540
+ "column": "sourceId"
2541
+ },
2542
+ "spec": {
2543
+ "column": "spec"
2544
+ },
2545
+ "updatedAt": {
2546
+ "column": "updatedAt"
2547
+ }
2548
+ },
2549
+ "namespaceId": "public",
2550
+ "table": "economicEvent"
2551
+ }
2552
+ },
2253
2553
  "Event": {
2254
2554
  "fields": {
2255
2555
  "at": {
@@ -3787,6 +4087,100 @@
3787
4087
  },
3788
4088
  "uniques": []
3789
4089
  },
4090
+ "agentTrustEdge": {
4091
+ "columns": {
4092
+ "createdAt": {
4093
+ "codecId": "pg/timestamptz-string@1",
4094
+ "default": {
4095
+ "expression": "now()",
4096
+ "kind": "function"
4097
+ },
4098
+ "nativeType": "timestamptz",
4099
+ "nullable": false
4100
+ },
4101
+ "eventCount": {
4102
+ "codecId": "pg/int4@1",
4103
+ "nativeType": "int4",
4104
+ "nullable": false
4105
+ },
4106
+ "firstEventAt": {
4107
+ "codecId": "pg/text@1",
4108
+ "nativeType": "text",
4109
+ "nullable": true
4110
+ },
4111
+ "firstEventSeq": {
4112
+ "codecId": "pg/int8@1",
4113
+ "nativeType": "int8",
4114
+ "nullable": true
4115
+ },
4116
+ "fromAgent": {
4117
+ "codecId": "pg/text@1",
4118
+ "nativeType": "text",
4119
+ "nullable": false
4120
+ },
4121
+ "id": {
4122
+ "codecId": "pg/text@1",
4123
+ "nativeType": "text",
4124
+ "nullable": false
4125
+ },
4126
+ "kind": {
4127
+ "codecId": "pg/text@1",
4128
+ "nativeType": "text",
4129
+ "nullable": false
4130
+ },
4131
+ "lastEventAt": {
4132
+ "codecId": "pg/text@1",
4133
+ "nativeType": "text",
4134
+ "nullable": false
4135
+ },
4136
+ "lastEventSeq": {
4137
+ "codecId": "pg/int8@1",
4138
+ "nativeType": "int8",
4139
+ "nullable": false
4140
+ },
4141
+ "toAgent": {
4142
+ "codecId": "pg/text@1",
4143
+ "nativeType": "text",
4144
+ "nullable": false
4145
+ },
4146
+ "totalUsd": {
4147
+ "codecId": "pg/numeric@1",
4148
+ "nativeType": "numeric",
4149
+ "nullable": false
4150
+ },
4151
+ "updatedAt": {
4152
+ "codecId": "pg/timestamptz-string@1",
4153
+ "nativeType": "timestamptz",
4154
+ "nullable": false
4155
+ }
4156
+ },
4157
+ "foreignKeys": [],
4158
+ "indexes": [
4159
+ {
4160
+ "columns": [
4161
+ "toAgent",
4162
+ "lastEventSeq"
4163
+ ],
4164
+ "name": "agentTrustEdge_toAgent_lastEventSeq_idx_94a10541",
4165
+ "prefix": "agentTrustEdge_toAgent_lastEventSeq_idx",
4166
+ "unique": false
4167
+ }
4168
+ ],
4169
+ "primaryKey": {
4170
+ "columns": [
4171
+ "id"
4172
+ ]
4173
+ },
4174
+ "uniques": [
4175
+ {
4176
+ "columns": [
4177
+ "fromAgent",
4178
+ "toAgent",
4179
+ "kind"
4180
+ ]
4181
+ }
4182
+ ]
4183
+ },
3790
4184
  "agentWallet": {
3791
4185
  "columns": {
3792
4186
  "active": {
@@ -5228,6 +5622,147 @@
5228
5622
  },
5229
5623
  "uniques": []
5230
5624
  },
5625
+ "economicEvent": {
5626
+ "columns": {
5627
+ "actor": {
5628
+ "codecId": "pg/text@1",
5629
+ "nativeType": "text",
5630
+ "nullable": false
5631
+ },
5632
+ "amountUsdc": {
5633
+ "codecId": "pg/numeric@1",
5634
+ "nativeType": "numeric",
5635
+ "nullable": true
5636
+ },
5637
+ "at": {
5638
+ "codecId": "pg/text@1",
5639
+ "nativeType": "text",
5640
+ "nullable": false
5641
+ },
5642
+ "counterparty": {
5643
+ "codecId": "pg/text@1",
5644
+ "nativeType": "text",
5645
+ "nullable": true
5646
+ },
5647
+ "createdAt": {
5648
+ "codecId": "pg/timestamptz-string@1",
5649
+ "default": {
5650
+ "expression": "now()",
5651
+ "kind": "function"
5652
+ },
5653
+ "nativeType": "timestamptz",
5654
+ "nullable": false
5655
+ },
5656
+ "id": {
5657
+ "codecId": "pg/text@1",
5658
+ "nativeType": "text",
5659
+ "nullable": false
5660
+ },
5661
+ "idempotencyKey": {
5662
+ "codecId": "pg/text@1",
5663
+ "nativeType": "text",
5664
+ "nullable": false
5665
+ },
5666
+ "kind": {
5667
+ "codecId": "pg/text@1",
5668
+ "nativeType": "text",
5669
+ "nullable": false
5670
+ },
5671
+ "ledgerSeq": {
5672
+ "codecId": "pg/int8@1",
5673
+ "default": {
5674
+ "expression": "autoincrement()",
5675
+ "kind": "function"
5676
+ },
5677
+ "nativeType": "int8",
5678
+ "nullable": false
5679
+ },
5680
+ "payload": {
5681
+ "codecId": "pg/json@1",
5682
+ "nativeType": "json",
5683
+ "nullable": false
5684
+ },
5685
+ "seq": {
5686
+ "codecId": "pg/int4@1",
5687
+ "nativeType": "int4",
5688
+ "nullable": false
5689
+ },
5690
+ "source": {
5691
+ "codecId": "pg/text@1",
5692
+ "nativeType": "text",
5693
+ "nullable": false
5694
+ },
5695
+ "sourceId": {
5696
+ "codecId": "pg/text@1",
5697
+ "nativeType": "text",
5698
+ "nullable": false
5699
+ },
5700
+ "spec": {
5701
+ "codecId": "pg/text@1",
5702
+ "nativeType": "text",
5703
+ "nullable": false
5704
+ },
5705
+ "updatedAt": {
5706
+ "codecId": "pg/timestamptz-string@1",
5707
+ "nativeType": "timestamptz",
5708
+ "nullable": false
5709
+ }
5710
+ },
5711
+ "foreignKeys": [],
5712
+ "indexes": [
5713
+ {
5714
+ "columns": [
5715
+ "actor",
5716
+ "ledgerSeq"
5717
+ ],
5718
+ "name": "economicEvent_actor_ledgerSeq_idx_c13dd6fa",
5719
+ "prefix": "economicEvent_actor_ledgerSeq_idx",
5720
+ "unique": false
5721
+ },
5722
+ {
5723
+ "columns": [
5724
+ "counterparty",
5725
+ "ledgerSeq"
5726
+ ],
5727
+ "name": "economicEvent_counterparty_ledgerSeq_idx_0c96cd61",
5728
+ "prefix": "economicEvent_counterparty_ledgerSeq_idx",
5729
+ "unique": false
5730
+ },
5731
+ {
5732
+ "columns": [
5733
+ "kind",
5734
+ "ledgerSeq"
5735
+ ],
5736
+ "name": "economicEvent_kind_ledgerSeq_idx_82590d81",
5737
+ "prefix": "economicEvent_kind_ledgerSeq_idx",
5738
+ "unique": false
5739
+ }
5740
+ ],
5741
+ "primaryKey": {
5742
+ "columns": [
5743
+ "id"
5744
+ ]
5745
+ },
5746
+ "uniques": [
5747
+ {
5748
+ "columns": [
5749
+ "idempotencyKey"
5750
+ ]
5751
+ },
5752
+ {
5753
+ "columns": [
5754
+ "source",
5755
+ "sourceId",
5756
+ "seq"
5757
+ ]
5758
+ },
5759
+ {
5760
+ "columns": [
5761
+ "ledgerSeq"
5762
+ ]
5763
+ }
5764
+ ]
5765
+ },
5231
5766
  "event": {
5232
5767
  "columns": {
5233
5768
  "at": {
@@ -6277,10 +6812,10 @@
6277
6812
  "kind": "postgres-schema"
6278
6813
  }
6279
6814
  },
6280
- "storageHash": "2bf60d54acf4ab9abee988ad1a46b4b9438fcbcdd771d4ee9fddd2a97a5f4ebb"
6815
+ "storageHash": "1a14b094b57f1bba69a6facb398084be0f103c4fbb3cb05a11f5d5138347d3e6"
6281
6816
  },
6282
6817
  "execution": {
6283
- "executionHash": "29e436f5dbe3c7d64d064c40d6c5ebb540e44167052e83ea58bc682aabe6a0cb",
6818
+ "executionHash": "5515f4d8afa61f4d3611fefb9cbdee48df2bf1192349a1640bb63d8a1c62173d",
6284
6819
  "mutations": {
6285
6820
  "defaults": [
6286
6821
  {
@@ -6331,6 +6866,32 @@
6331
6866
  "table": "a2ATask"
6332
6867
  }
6333
6868
  },
6869
+ {
6870
+ "onCreate": {
6871
+ "id": "uuidv4",
6872
+ "kind": "generator"
6873
+ },
6874
+ "ref": {
6875
+ "column": "id",
6876
+ "namespace": "public",
6877
+ "table": "agentTrustEdge"
6878
+ }
6879
+ },
6880
+ {
6881
+ "onCreate": {
6882
+ "id": "timestampNow",
6883
+ "kind": "generator"
6884
+ },
6885
+ "onUpdate": {
6886
+ "id": "timestampNow",
6887
+ "kind": "generator"
6888
+ },
6889
+ "ref": {
6890
+ "column": "updatedAt",
6891
+ "namespace": "public",
6892
+ "table": "agentTrustEdge"
6893
+ }
6894
+ },
6334
6895
  {
6335
6896
  "onCreate": {
6336
6897
  "id": "uuidv4",
@@ -6633,6 +7194,21 @@
6633
7194
  "table": "eaasVerdict"
6634
7195
  }
6635
7196
  },
7197
+ {
7198
+ "onCreate": {
7199
+ "id": "timestampNow",
7200
+ "kind": "generator"
7201
+ },
7202
+ "onUpdate": {
7203
+ "id": "timestampNow",
7204
+ "kind": "generator"
7205
+ },
7206
+ "ref": {
7207
+ "column": "updatedAt",
7208
+ "namespace": "public",
7209
+ "table": "economicEvent"
7210
+ }
7211
+ },
6636
7212
  {
6637
7213
  "onCreate": {
6638
7214
  "id": "uuidv4",
@@ -0,0 +1,22 @@
1
+ import type { EconomicEvent } from "@agentbadge/econ-events";
2
+ import type { PrismaDb } from "./event-repository.js";
3
+ import { type AppendResult, type EconEventStored, type EconLedgerStore, type ListOpts } from "./econ-ledger-store.js";
4
+ import { type TrustEdgeStore } from "./trust-edge-store.js";
5
+ type Orm = PrismaDb["orm"];
6
+ export declare class EconLedgerRepository implements EconLedgerStore<Orm> {
7
+ private readonly db;
8
+ private readonly edges?;
9
+ constructor(db: PrismaDb, edges?: TrustEdgeStore<Orm> | undefined);
10
+ append(events: EconomicEvent[]): Promise<AppendResult[]>;
11
+ appendInTx(events: EconomicEvent[], extra: (tx: Orm) => Promise<void>): Promise<AppendResult[]>;
12
+ getById(id: string): Promise<EconEventStored | null>;
13
+ getByKey(idempotencyKey: string): Promise<EconEventStored | null>;
14
+ listByAgent(agent: string, opts?: ListOpts): Promise<EconEventStored[]>;
15
+ listByPair(a: string, b: string, opts?: ListOpts): Promise<EconEventStored[]>;
16
+ listBySourceId(source: string, sourceId: string, opts?: ListOpts): Promise<EconEventStored[]>;
17
+ scan(fromLedgerSeq: bigint, opts?: {
18
+ limit?: number;
19
+ }): Promise<EconEventStored[]>;
20
+ private page;
21
+ }
22
+ export {};