types.proto raw
1 syntax = "proto3";
2 package orlydb.v1;
3 option go_package = "next.orly.dev/pkg/proto/orlydb/v1;orlydbv1";
4
5 // Empty is used for requests/responses with no data
6 message Empty {}
7
8 // Event represents a Nostr event
9 // Binary fields (id, pubkey, sig) are stored as raw bytes for efficiency
10 message Event {
11 bytes id = 1; // 32 bytes SHA256 hash
12 bytes pubkey = 2; // 32 bytes public key
13 int64 created_at = 3; // UNIX timestamp
14 uint32 kind = 4; // Event kind (uint16 in Go, promoted to uint32)
15 repeated Tag tags = 5; // Event tags
16 bytes content = 6; // Arbitrary content (may be binary)
17 bytes sig = 7; // 64 bytes Schnorr signature
18 }
19
20 // Tag represents a Nostr tag (array of byte slices)
21 // Values are bytes to preserve binary data in e/p tags (33-byte format)
22 message Tag {
23 repeated bytes values = 1;
24 }
25
26 // TagSet represents a set of tag values for filtering
27 message TagSet {
28 repeated bytes values = 1;
29 }
30
31 // Filter represents a Nostr query filter (NIP-01)
32 message Filter {
33 repeated bytes ids = 1; // Event IDs to match (32 bytes each)
34 repeated uint32 kinds = 2; // Kinds to match
35 repeated bytes authors = 3; // Author pubkeys (32 bytes each)
36 map<string, TagSet> tags = 4; // Tag filters (#e, #p, #t, etc.)
37 optional int64 since = 5; // Created after timestamp
38 optional int64 until = 6; // Created before timestamp
39 optional bytes search = 7; // Full-text search query (NIP-50)
40 optional uint32 limit = 8; // Max results
41 }
42
43 // Uint40 represents a 40-bit serial number
44 // Packed into uint64 with upper 24 bits unused
45 message Uint40 {
46 uint64 value = 1;
47 }
48
49 // IdPkTs holds event reference data (ID, Pubkey, Timestamp, Serial)
50 message IdPkTs {
51 bytes id = 1; // 32 bytes event ID
52 bytes pubkey = 2; // 32 bytes author pubkey
53 int64 timestamp = 3; // Created timestamp
54 uint64 serial = 4; // Database serial number
55 }
56
57 // Range represents an index range for serial queries
58 message Range {
59 bytes prefix = 1; // Index prefix
60 uint64 start = 2; // Start serial
61 uint64 end = 3; // End serial
62 }
63
64 // Subscription represents payment-based access control data
65 message Subscription {
66 bytes pubkey = 1;
67 int64 trial_end = 2;
68 int64 paid_until = 3;
69 string blossom_level = 4;
70 int64 blossom_storage_mb = 5;
71 }
72
73 // Payment represents a payment record
74 message Payment {
75 int64 amount = 1;
76 int64 timestamp = 2;
77 string invoice = 3;
78 string preimage = 4;
79 }
80
81 // NIP43Membership represents NIP-43 invite-based ACL membership
82 message NIP43Membership {
83 bytes pubkey = 1;
84 int64 added_at = 2;
85 string invite_code = 3;
86 }
87
88 // EventBatch is used for streaming query results
89 message EventBatch {
90 repeated Event events = 1;
91 }
92
93 // SerialList is used for returning lists of serials
94 message SerialList {
95 repeated uint64 serials = 1;
96 }
97
98 // IdPkTsList is used for returning lists of IdPkTs
99 message IdPkTsList {
100 repeated IdPkTs items = 1;
101 }
102
103 // EventMap maps serial numbers to events
104 message EventMap {
105 map<uint64, Event> events = 1;
106 }
107
108 // SerialMap maps string IDs to serial numbers
109 message SerialMap {
110 map<string, uint64> serials = 1;
111 }
112
113 // PaymentList is used for returning payment history
114 message PaymentList {
115 repeated Payment payments = 1;
116 }
117
118 // PubkeyList is used for returning lists of pubkeys
119 message PubkeyList {
120 repeated bytes pubkeys = 1;
121 }
122