-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(common): replace enum with const (#14)
- Loading branch information
Showing
17 changed files
with
108 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Same as WebSocket readyState | ||
*/ | ||
export const ClientReadyState = { | ||
CONNECTING: 0, | ||
OPEN: 1, | ||
CLOSING: 2, | ||
CLOSED: 3, | ||
} as const; | ||
export type ClientReadyState = | ||
(typeof ClientReadyState)[keyof typeof ClientReadyState]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
export const EventType = { | ||
/** | ||
* Regular event | ||
*/ | ||
REGULAR: 'REGULAR', | ||
/** | ||
* Replaceable event | ||
*/ | ||
REPLACEABLE: 'REPLACEABLE', | ||
/** | ||
* Ephemeral event | ||
*/ | ||
EPHEMERAL: 'EPHEMERAL', | ||
/** | ||
* Parameterized replaceable event | ||
*/ | ||
PARAMETERIZED_REPLACEABLE: 'PARAMETERIZED_REPLACEABLE', | ||
} as const; | ||
export type EventType = (typeof EventType)[keyof typeof EventType]; | ||
|
||
/** | ||
* Some special event kinds | ||
*/ | ||
export const EventKind = { | ||
SET_METADATA: 0, | ||
TEXT_NOTE: 1, | ||
RECOMMEND_SERVER: 2, | ||
CONTACT_LIST: 3, | ||
ENCRYPTED_DIRECT_MESSAGE: 4, | ||
DELETION: 5, | ||
// Channel | ||
CHANNEL_CREATION: 40, | ||
CHANNEL_METADATA: 41, | ||
CHANNEL_MESSAGE: 42, | ||
CHANNEL_HIDE_MESSAGE: 43, | ||
CHANNEL_MUTE_USER: 44, | ||
CHANNEL_RESERVE_FIRST: 45, | ||
CHANNEL_RESERVE_LAST: 49, | ||
// Regular Events | ||
REGULAR_FIRST: 1000, | ||
REGULAR_LAST: 9999, | ||
// Replaceable Events | ||
REPLACEABLE_FIRST: 10000, | ||
REPLACEABLE_LAST: 19999, | ||
// Ephemeral Events | ||
EPHEMERAL_FIRST: 20000, | ||
AUTHENTICATION: 22242, | ||
EPHEMERAL_LAST: 29999, | ||
// Parameterized Replaceable Events | ||
PARAMETERIZED_REPLACEABLE_FIRST: 30000, | ||
LONG_FORM_CONTENT: 30023, | ||
PARAMETERIZED_REPLACEABLE_LAST: 39999, | ||
}; | ||
export type EventKind = number; | ||
|
||
export const TagName = { | ||
EVENT_COORDINATES: 'a', | ||
EVENT: 'e', | ||
PUBKEY: 'p', | ||
D: 'd', | ||
NONCE: 'nonce', | ||
EXPIRATION: 'expiration', | ||
DELEGATION: 'delegation', | ||
RELAY: 'relay', | ||
CHALLENGE: 'challenge', | ||
} as const; | ||
export type TagName = (typeof TagName)[keyof typeof TagName]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './client.const'; | ||
export * from './event.const'; | ||
export * from './logger.const'; | ||
export * from './message.const'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const LogLevel = { | ||
DEBUG: 0, | ||
INFO: 1, | ||
WARN: 2, | ||
ERROR: 3, | ||
} as const; | ||
export type LogLevel = (typeof LogLevel)[keyof typeof LogLevel]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const MessageType = { | ||
REQ: 'REQ', | ||
EVENT: 'EVENT', | ||
CLOSE: 'CLOSE', | ||
AUTH: 'AUTH', | ||
EOSE: 'EOSE', | ||
OK: 'OK', | ||
NOTICE: 'NOTICE', | ||
CLOSED: 'CLOSED', | ||
} as const; | ||
export type MessageType = (typeof MessageType)[keyof typeof MessageType]; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters