Add initial RBS support with Steep and TypeProf

This commit is contained in:
Wilson Silva
2023-01-22 17:42:59 +07:00
parent 59e058d511
commit 8f6a7547f5
19 changed files with 290 additions and 1 deletions

20
sig/nostr/client.rbs Normal file
View File

@@ -0,0 +1,20 @@
module Nostr
class Client
include EventEmitter
def initialize: -> void
def connect: (Relay relay) -> Thread
def subscribe: (?subscription_id: String, ?filter: Filter) -> Subscription
def unsubscribe: (String subscription_id) -> untyped
def publish: (Event event) -> untyped
private
attr_reader subscriptions: Hash[String, Subscription]
attr_reader parent_to_child_channel: untyped
attr_reader child_to_parent_channel: untyped
def execute_within_an_em_thread: { -> untyped } -> Thread
def initialize_channels: -> untyped
end
end

View File

@@ -0,0 +1,7 @@
module Nostr
module ClientMessageType
EVENT: String
REQ: String
CLOSE: String
end
end

24
sig/nostr/event.rbs Normal file
View File

@@ -0,0 +1,24 @@
module Nostr
class Event < EventFragment
attr_reader id: String
attr_reader sig: String
def initialize: (id: String, sig: String,
created_at: Integer,
kind: Integer,
tags: Array[String],
content: String,
) -> void
def to_h: -> {
id: String,
pubkey: String,
created_at: Integer,
kind: Integer,
tags: Array[String],
content: String,
sig: String
}
def ==: (Event other) -> bool
end
end

View File

@@ -0,0 +1,12 @@
module Nostr
class EventFragment
attr_reader pubkey: String
attr_reader created_at: Integer
attr_reader kind: Integer
attr_reader tags: Array[String]
attr_reader content: String
def initialize: (pubkey: String, kind: Integer, content: String, ?created_at: Integer, ?tags: Array[String]) -> void
def serialize: -> [Integer, String, Integer, Integer, Array[String], String]
end
end

8
sig/nostr/event_kind.rbs Normal file
View File

@@ -0,0 +1,8 @@
module Nostr
module EventKind
SET_METADATA: Integer
TEXT_NOTE: Integer
RECOMMEND_SERVER: Integer
CONTACTS: Integer
end
end

25
sig/nostr/filter.rbs Normal file
View File

@@ -0,0 +1,25 @@
module Nostr
class Filter
attr_reader ids: Array[String]
attr_reader authors: Array[String]
attr_reader kinds: Array[Integer]
attr_reader e: String
attr_reader p: String
attr_reader since: Integer
attr_reader until: Integer
attr_reader limit: Integer
def initialize: (**untyped) -> void
def to_h: -> {
ids: Array[String],
authors: Array[String],
kinds: Array[Integer],
e: String,
p: String,
since: Integer,
until: Integer,
limit: Integer
}
def ==: (Filter other) -> bool
end
end

9
sig/nostr/key_pair.rbs Normal file
View File

@@ -0,0 +1,9 @@
# Classes
module Nostr
class KeyPair
attr_reader private_key: String
attr_reader public_key: String
def initialize: (private_key: String, public_key: String) -> void
end
end

13
sig/nostr/keygen.rbs Normal file
View File

@@ -0,0 +1,13 @@
# Classes
module Nostr
class Keygen
def initialize: -> void
def generate_key_pair: -> KeyPair
def generate_private_key: -> String
def extract_public_key: (String private_key) -> String
private
attr_reader group: untyped
end
end

9
sig/nostr/relay.rbs Normal file
View File

@@ -0,0 +1,9 @@
# Classes
module Nostr
class Relay
attr_reader url: String
attr_reader name: String
def initialize: (url: String, name: String) -> void
end
end

View File

@@ -0,0 +1,9 @@
module Nostr
class Subscription
attr_reader id: String
attr_reader filter: Filter
def initialize: (filter: Filter, ?id: String) -> void
def ==: (Subscription other) -> bool
end
end

24
sig/nostr/user.rbs Normal file
View File

@@ -0,0 +1,24 @@
# Classes
module Nostr
class User
attr_reader keypair: KeyPair
def initialize: (?keypair: KeyPair | nil, ?keygen: Keygen) -> void
def create_event: (
{
id: String,
pubkey: String,
created_at: Integer,
kind: Integer,
tags: Array[String],
content: String,
created_at: Integer,
sig: String
}
) -> Event
private
def sign: (String event_sha256) -> String
end
end