nevus-nodejs-sdk 0.1.0-alpha.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.
@@ -0,0 +1,121 @@
1
+ import mqtt from 'mqtt';
2
+
3
+ declare const EVENT_NAMES: {
4
+ readonly CUSTOMER_CREATED: "customer.created";
5
+ readonly CUSTOMER_UPDATED: "customer.updated";
6
+ readonly CUSTOMER_DELETED: "customer.deleted";
7
+ readonly TICKET_CREATED: "ticket.created";
8
+ readonly TICKET_UPDATED: "ticket.updated";
9
+ readonly TICKET_DELETED: "ticket.deleted";
10
+ readonly TICKET_OPENED: "ticket.opened";
11
+ readonly TICKET_CLOSED: "ticket.closed";
12
+ readonly TICKET_REOPENED: "ticket.reopened";
13
+ readonly TICKET_ASSIGNED: "ticket.assigned";
14
+ readonly TICKET_UNASSIGNED: "ticket.unassigned";
15
+ readonly CHAT_CREATED: "chat.created";
16
+ readonly CHAT_UPDATED: "chat.updated";
17
+ readonly MESSAGE_SENT: "message.sent";
18
+ readonly MESSAGE_RECEIVED: "message.received";
19
+ readonly MESSAGE_DELIVERED: "message.delivered";
20
+ readonly MESSAGE_READ: "message.read";
21
+ readonly MESSAGE_EDITED: "message.edited";
22
+ readonly MESSAGE_DELETED: "message.deleted";
23
+ };
24
+ type EventName = (typeof EVENT_NAMES)[keyof typeof EVENT_NAMES];
25
+
26
+ declare class Mqtt {
27
+ private client;
28
+ constructor(brokerUrl: string, options?: mqtt.IClientOptions);
29
+ subscribe(topic: string, callback: (message: string) => void): void;
30
+ publish(topic: string, message: string): void;
31
+ }
32
+
33
+ declare class EventsResource {
34
+ private readonly mqtt;
35
+ constructor(mqtt: Mqtt);
36
+ subscribe<T>(event: EventName, callback: (data: T) => void): Promise<void>;
37
+ }
38
+
39
+ interface HttpOptions {
40
+ apiKey?: string;
41
+ }
42
+ declare class Http {
43
+ private options;
44
+ constructor(options: HttpOptions);
45
+ request<T>(path: string, options?: RequestInit): Promise<T>;
46
+ get<T>(path: string): Promise<T>;
47
+ post<T>(path: string, body?: unknown): Promise<T>;
48
+ put<T>(path: string, body?: unknown): Promise<T>;
49
+ patch<T>(path: string, body?: unknown): Promise<T>;
50
+ delete<T>(path: string): Promise<T>;
51
+ }
52
+
53
+ type Message = {
54
+ id: string;
55
+ };
56
+
57
+ declare class MessagesResource {
58
+ private readonly http;
59
+ constructor(http: Http);
60
+ findMany(): Promise<Message[]>;
61
+ findById(id: string): Promise<Message>;
62
+ create(data: Partial<Message>): Promise<Message>;
63
+ update(id: string, data: Partial<Message>): Promise<Message>;
64
+ delete(id: string): Promise<void>;
65
+ }
66
+
67
+ type Chat = {
68
+ id: string;
69
+ };
70
+
71
+ declare class ChatsResource {
72
+ private readonly http;
73
+ constructor(http: Http);
74
+ findMany(): Promise<Chat[]>;
75
+ findById(id: string): Promise<Chat>;
76
+ create(data: Partial<Chat>): Promise<Chat>;
77
+ update(id: string, data: Partial<Chat>): Promise<Chat>;
78
+ delete(id: string): Promise<void>;
79
+ }
80
+
81
+ type Customer = {
82
+ id: string;
83
+ };
84
+
85
+ declare class CustomersResource {
86
+ private readonly http;
87
+ constructor(http: Http);
88
+ findMany(): Promise<Customer[]>;
89
+ findById(id: string): Promise<Customer>;
90
+ create(data: Partial<Customer>): Promise<Customer>;
91
+ update(id: string, data: Partial<Customer>): Promise<Customer>;
92
+ delete(id: string): Promise<void>;
93
+ }
94
+
95
+ type Ticket = {
96
+ id: string;
97
+ };
98
+
99
+ declare class TicketsResource {
100
+ private readonly http;
101
+ constructor(http: Http);
102
+ findMany(): Promise<Ticket[]>;
103
+ findById(id: string): Promise<Ticket>;
104
+ create(data: Partial<Ticket>): Promise<Ticket>;
105
+ update(id: string, data: Partial<Ticket>): Promise<Ticket>;
106
+ delete(id: string): Promise<void>;
107
+ }
108
+
109
+ interface NevusOptions {
110
+ apiKey?: string;
111
+ }
112
+ declare class Nevus {
113
+ readonly tickets: TicketsResource;
114
+ readonly customers: CustomersResource;
115
+ readonly chats: ChatsResource;
116
+ readonly messages: MessagesResource;
117
+ readonly events: EventsResource;
118
+ constructor(options?: NevusOptions);
119
+ }
120
+
121
+ export { Nevus, type NevusOptions };
@@ -0,0 +1,121 @@
1
+ import mqtt from 'mqtt';
2
+
3
+ declare const EVENT_NAMES: {
4
+ readonly CUSTOMER_CREATED: "customer.created";
5
+ readonly CUSTOMER_UPDATED: "customer.updated";
6
+ readonly CUSTOMER_DELETED: "customer.deleted";
7
+ readonly TICKET_CREATED: "ticket.created";
8
+ readonly TICKET_UPDATED: "ticket.updated";
9
+ readonly TICKET_DELETED: "ticket.deleted";
10
+ readonly TICKET_OPENED: "ticket.opened";
11
+ readonly TICKET_CLOSED: "ticket.closed";
12
+ readonly TICKET_REOPENED: "ticket.reopened";
13
+ readonly TICKET_ASSIGNED: "ticket.assigned";
14
+ readonly TICKET_UNASSIGNED: "ticket.unassigned";
15
+ readonly CHAT_CREATED: "chat.created";
16
+ readonly CHAT_UPDATED: "chat.updated";
17
+ readonly MESSAGE_SENT: "message.sent";
18
+ readonly MESSAGE_RECEIVED: "message.received";
19
+ readonly MESSAGE_DELIVERED: "message.delivered";
20
+ readonly MESSAGE_READ: "message.read";
21
+ readonly MESSAGE_EDITED: "message.edited";
22
+ readonly MESSAGE_DELETED: "message.deleted";
23
+ };
24
+ type EventName = (typeof EVENT_NAMES)[keyof typeof EVENT_NAMES];
25
+
26
+ declare class Mqtt {
27
+ private client;
28
+ constructor(brokerUrl: string, options?: mqtt.IClientOptions);
29
+ subscribe(topic: string, callback: (message: string) => void): void;
30
+ publish(topic: string, message: string): void;
31
+ }
32
+
33
+ declare class EventsResource {
34
+ private readonly mqtt;
35
+ constructor(mqtt: Mqtt);
36
+ subscribe<T>(event: EventName, callback: (data: T) => void): Promise<void>;
37
+ }
38
+
39
+ interface HttpOptions {
40
+ apiKey?: string;
41
+ }
42
+ declare class Http {
43
+ private options;
44
+ constructor(options: HttpOptions);
45
+ request<T>(path: string, options?: RequestInit): Promise<T>;
46
+ get<T>(path: string): Promise<T>;
47
+ post<T>(path: string, body?: unknown): Promise<T>;
48
+ put<T>(path: string, body?: unknown): Promise<T>;
49
+ patch<T>(path: string, body?: unknown): Promise<T>;
50
+ delete<T>(path: string): Promise<T>;
51
+ }
52
+
53
+ type Message = {
54
+ id: string;
55
+ };
56
+
57
+ declare class MessagesResource {
58
+ private readonly http;
59
+ constructor(http: Http);
60
+ findMany(): Promise<Message[]>;
61
+ findById(id: string): Promise<Message>;
62
+ create(data: Partial<Message>): Promise<Message>;
63
+ update(id: string, data: Partial<Message>): Promise<Message>;
64
+ delete(id: string): Promise<void>;
65
+ }
66
+
67
+ type Chat = {
68
+ id: string;
69
+ };
70
+
71
+ declare class ChatsResource {
72
+ private readonly http;
73
+ constructor(http: Http);
74
+ findMany(): Promise<Chat[]>;
75
+ findById(id: string): Promise<Chat>;
76
+ create(data: Partial<Chat>): Promise<Chat>;
77
+ update(id: string, data: Partial<Chat>): Promise<Chat>;
78
+ delete(id: string): Promise<void>;
79
+ }
80
+
81
+ type Customer = {
82
+ id: string;
83
+ };
84
+
85
+ declare class CustomersResource {
86
+ private readonly http;
87
+ constructor(http: Http);
88
+ findMany(): Promise<Customer[]>;
89
+ findById(id: string): Promise<Customer>;
90
+ create(data: Partial<Customer>): Promise<Customer>;
91
+ update(id: string, data: Partial<Customer>): Promise<Customer>;
92
+ delete(id: string): Promise<void>;
93
+ }
94
+
95
+ type Ticket = {
96
+ id: string;
97
+ };
98
+
99
+ declare class TicketsResource {
100
+ private readonly http;
101
+ constructor(http: Http);
102
+ findMany(): Promise<Ticket[]>;
103
+ findById(id: string): Promise<Ticket>;
104
+ create(data: Partial<Ticket>): Promise<Ticket>;
105
+ update(id: string, data: Partial<Ticket>): Promise<Ticket>;
106
+ delete(id: string): Promise<void>;
107
+ }
108
+
109
+ interface NevusOptions {
110
+ apiKey?: string;
111
+ }
112
+ declare class Nevus {
113
+ readonly tickets: TicketsResource;
114
+ readonly customers: CustomersResource;
115
+ readonly chats: ChatsResource;
116
+ readonly messages: MessagesResource;
117
+ readonly events: EventsResource;
118
+ constructor(options?: NevusOptions);
119
+ }
120
+
121
+ export { Nevus, type NevusOptions };