@marinade.finance/ts-subscription-client 1.0.0-beta.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.
package/types.ts ADDED
@@ -0,0 +1,119 @@
1
+ /** Minimal logger interface — compatible with pino, console, etc. */
2
+ export interface Logger {
3
+ debug(msg: string): void
4
+ }
5
+
6
+ /** Configuration for the subscription client */
7
+ export interface SubscriptionClientConfig {
8
+ base_url: string
9
+ timeout_ms?: number
10
+ logger?: Logger
11
+ }
12
+
13
+ /** POST /subscriptions request */
14
+ export interface SubscribeRequest {
15
+ pubkey: string
16
+ notification_type: string
17
+ channel: string
18
+ channel_address: string
19
+ signature: string
20
+ message: string
21
+ additional_data?: Record<string, unknown>
22
+ }
23
+
24
+ /** DELETE /subscriptions request */
25
+ export interface UnsubscribeRequest {
26
+ pubkey: string
27
+ notification_type: string
28
+ channel: string
29
+ channel_address?: string
30
+ signature: string
31
+ message: string
32
+ additional_data?: Record<string, unknown>
33
+ }
34
+
35
+ /** GET /subscriptions auth */
36
+ export interface ListSubscriptionsAuth {
37
+ signature: string
38
+ message: string
39
+ }
40
+
41
+ /** GET /subscriptions query */
42
+ export interface ListSubscriptionsQuery {
43
+ pubkey: string
44
+ notification_type?: string
45
+ additional_data?: Record<string, unknown>
46
+ }
47
+
48
+ /** POST /subscriptions response */
49
+ export interface SubscribeResponse {
50
+ user_id: string
51
+ notification_type: string
52
+ channel: string
53
+ channel_address: string
54
+ created_at: string
55
+ deep_link?: string
56
+ telegram_status?:
57
+ | 'pending'
58
+ | 'active'
59
+ | 'inactive'
60
+ | 'unsubscribed'
61
+ | 'blocked'
62
+ | 'already_activated'
63
+ | 'bot_not_configured'
64
+ }
65
+
66
+ /** DELETE /subscriptions response */
67
+ export interface UnsubscribeResponse {
68
+ deleted: boolean
69
+ }
70
+
71
+ /** GET /subscriptions response item */
72
+ export interface Subscription {
73
+ user_id: string
74
+ notification_type: string
75
+ channel: string
76
+ channel_address: string
77
+ created_at: string
78
+ telegram_status?:
79
+ | 'pending'
80
+ | 'active'
81
+ | 'inactive'
82
+ | 'unsubscribed'
83
+ | 'blocked'
84
+ }
85
+
86
+ /** GET /notifications query (public, no auth required) */
87
+ export interface ListNotificationsQuery {
88
+ user_id: string
89
+ notification_type?: string
90
+ priority?: string
91
+ inner_type?: string
92
+ limit?: number
93
+ offset?: number
94
+ }
95
+
96
+ /** GET /notifications response item */
97
+ export interface Notification {
98
+ id: number
99
+ notification_type: string
100
+ inner_type: string
101
+ user_id: string
102
+ priority: string
103
+ message: string
104
+ data: Record<string, unknown>
105
+ notification_id: string | null
106
+ relevance_until: string
107
+ created_at: string
108
+ }
109
+
110
+ export class NetworkError extends Error {
111
+ constructor(
112
+ message: string,
113
+ public readonly status?: number,
114
+ public readonly response?: unknown,
115
+ ) {
116
+ super(message)
117
+ this.name = 'NetworkError'
118
+ }
119
+ }