@skravets/eapi 0.0.5 → 0.0.7

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.
@@ -61,7 +61,7 @@ interface components {
61
61
  channel_id: number;
62
62
  /**
63
63
  * Format: date-time
64
- * @example 2025-08-11T23:03:13.539Z
64
+ * @example 2025-08-12T11:29:34.672Z
65
65
  */
66
66
  message_created_at: string;
67
67
  /** @example 123 */
@@ -100,7 +100,7 @@ interface components {
100
100
  * @description Message id to reply to
101
101
  * @example 123
102
102
  */
103
- replyToId: number;
103
+ replyToId?: number;
104
104
  };
105
105
  ISendMessage: {
106
106
  /**
@@ -111,6 +111,11 @@ interface components {
111
111
  * }
112
112
  */
113
113
  message: components["schemas"]["ISendMessageMessage"];
114
+ /**
115
+ * @description Seconds to typing
116
+ * @example 5
117
+ */
118
+ secondsToTyping?: number;
114
119
  /**
115
120
  * @description Account id
116
121
  * @example 1
@@ -61,7 +61,7 @@ interface components {
61
61
  channel_id: number;
62
62
  /**
63
63
  * Format: date-time
64
- * @example 2025-08-11T23:03:13.539Z
64
+ * @example 2025-08-12T11:29:34.672Z
65
65
  */
66
66
  message_created_at: string;
67
67
  /** @example 123 */
@@ -100,7 +100,7 @@ interface components {
100
100
  * @description Message id to reply to
101
101
  * @example 123
102
102
  */
103
- replyToId: number;
103
+ replyToId?: number;
104
104
  };
105
105
  ISendMessage: {
106
106
  /**
@@ -111,6 +111,11 @@ interface components {
111
111
  * }
112
112
  */
113
113
  message: components["schemas"]["ISendMessageMessage"];
114
+ /**
115
+ * @description Seconds to typing
116
+ * @example 5
117
+ */
118
+ secondsToTyping?: number;
114
119
  /**
115
120
  * @description Account id
116
121
  * @example 1
package/dist/index.cjs CHANGED
@@ -62,6 +62,7 @@ class EApi {
62
62
  headers: {
63
63
  "user-agent": "EAPI SDK",
64
64
  Authorization: `Basic ${btoa(`${this.options.client.id}:${this.options.client.secret}`)}`,
65
+ ...data ? { "content-type": "application/json" } : {},
65
66
  ...this.options.requestOptions?.headers,
66
67
  ...options?.headers
67
68
  }
@@ -71,7 +72,15 @@ class EApi {
71
72
  if (!response.ok) {
72
73
  throw new Error(`${response.status} ${await response.text()}`);
73
74
  }
74
- return response.json();
75
+ const contentType = response.headers.get("content-type");
76
+ const length = response.headers.get("content-length");
77
+ if (contentType?.includes("application/json")) {
78
+ return response.json();
79
+ }
80
+ if (length) {
81
+ return response.text();
82
+ }
83
+ return void 0;
75
84
  }
76
85
  on(type, handler) {
77
86
  this.listeners.push({ event: type, handler });
@@ -88,15 +97,15 @@ class EApi {
88
97
  */
89
98
  app = {
90
99
  /**
91
- *
92
- *
93
- * @tags App
94
- * @summary Get Hello World!
95
- *
96
- * [Documentation](.../App/operation/app.getHello)
97
- */
100
+ *
101
+ *
102
+ * @tags App
103
+ * @summary Get Hello World!
104
+ *
105
+ * [Documentation](.../App/operation/app.getHello)
106
+ */
98
107
  getHello: (options) => {
99
- return this.request(`/`, void 0, { method: "GET", ...options });
108
+ return this.request("/", void 0, { method: "GET", ...options });
100
109
  }
101
110
  };
102
111
  /**
@@ -104,70 +113,85 @@ class EApi {
104
113
  */
105
114
  chats = {
106
115
  /**
107
- *
108
- *
109
- * @tags chats
110
- * @summary Get Hello World!
111
- *
112
- * [Documentation](.../chats/operation/channels.getHello)
113
- */
116
+ *
117
+ *
118
+ * @tags chats
119
+ * @summary Get Hello World!
120
+ *
121
+ * [Documentation](.../chats/operation/channels.getHello)
122
+ */
114
123
  getHello: (options) => {
115
- return this.request(`/chats`, void 0, { method: "GET", ...options });
124
+ return this.request("/chats", void 0, { method: "GET", ...options });
116
125
  },
117
126
  /**
118
- *
119
- *
120
- * @tags chats
121
- * @summary Get last channel message
122
- *
123
- * [Documentation](.../chats/operation/channels.getLastMessage)
124
- */
127
+ *
128
+ *
129
+ * @tags chats
130
+ * @summary Get last channel message
131
+ *
132
+ * [Documentation](.../chats/operation/channels.getLastMessage)
133
+ */
125
134
  getLastMessage: (chat, options) => {
126
- return this.request(`/chats/${chat}/last-message`, void 0, { method: "GET", ...options });
135
+ return this.request(`/chats/${chat}/last-message`, void 0, {
136
+ method: "GET",
137
+ ...options
138
+ });
127
139
  },
128
140
  /**
129
- *
130
- *
131
- * @tags chats
132
- * @summary Get chat messages
133
- *
134
- * [Documentation](.../chats/operation/chats.getMessages)
135
- */
141
+ *
142
+ *
143
+ * @tags chats
144
+ * @summary Get chat messages
145
+ *
146
+ * [Documentation](.../chats/operation/chats.getMessages)
147
+ */
136
148
  getMessages: (chat, body, options) => {
137
- return this.request(`/chats/${chat}/new-messages`, body, { method: "POST", ...options });
149
+ return this.request(`/chats/${chat}/new-messages`, body, {
150
+ method: "POST",
151
+ ...options
152
+ });
138
153
  },
139
154
  /**
140
- *
141
- *
142
- * @tags chats
143
- * @summary Queue chat
144
- *
145
- * [Documentation](.../chats/operation/chats.queue)
146
- */
155
+ *
156
+ *
157
+ * @tags chats
158
+ * @summary Queue chat
159
+ *
160
+ * [Documentation](.../chats/operation/chats.queue)
161
+ */
147
162
  queue: (externalId, chat, options) => {
148
- return this.request(`/chats/${chat}/queue/${externalId}`, void 0, { method: "POST", ...options });
163
+ return this.request(`/chats/${chat}/queue/${externalId}`, void 0, {
164
+ method: "POST",
165
+ ...options
166
+ });
149
167
  },
150
168
  /**
151
- *
152
- *
153
- * @tags chats
154
- * @summary Add task to join chat
155
- *
156
- * [Documentation](.../chats/operation/chats.join)
157
- */
169
+ *
170
+ *
171
+ * @tags chats
172
+ * @summary Add task to join chat
173
+ *
174
+ * [Documentation](.../chats/operation/chats.join)
175
+ */
158
176
  join: (externalId, chat, body, options) => {
159
- return this.request(`/chats/${chat}/join/${externalId}`, body, { method: "POST", ...options });
177
+ return this.request(`/chats/${chat}/join/${externalId}`, body, {
178
+ method: "POST",
179
+ ...options
180
+ });
160
181
  },
161
182
  /**
162
- *
163
- *
164
- * @tags chats
165
- * @summary Add task to send message
166
- *
167
- * [Documentation](.../chats/operation/chats.send)
168
- */
183
+ *
184
+ *
185
+ * @tags chats
186
+ * @summary Add task to send message
187
+ *
188
+ * [Documentation](.../chats/operation/chats.send)
189
+ */
169
190
  send: (externalId, chat, body, options) => {
170
- return this.request(`/chats/${chat}/send/${externalId}`, body, { method: "POST", ...options });
191
+ return this.request(`/chats/${chat}/send/${externalId}`, body, {
192
+ method: "POST",
193
+ ...options
194
+ });
171
195
  }
172
196
  };
173
197
  /**
@@ -175,59 +199,74 @@ class EApi {
175
199
  */
176
200
  subscriptions = {
177
201
  /**
178
- *
179
- *
180
- * @tags Subscriptions
181
- * @summary Create subscription
182
- *
183
- * [Documentation](.../Subscriptions/operation/subscriptions.create)
184
- */
202
+ *
203
+ *
204
+ * @tags Subscriptions
205
+ * @summary Create subscription
206
+ *
207
+ * [Documentation](.../Subscriptions/operation/subscriptions.create)
208
+ */
185
209
  create: (body, options) => {
186
- return this.request(`/subscriptions`, body, { method: "POST", ...options });
210
+ return this.request("/subscriptions", body, {
211
+ method: "POST",
212
+ ...options
213
+ });
187
214
  },
188
215
  /**
189
- *
190
- *
191
- * @tags Subscriptions
192
- * @summary Upsert subscription
193
- *
194
- * [Documentation](.../Subscriptions/operation/subscriptions.upsert)
195
- */
216
+ *
217
+ *
218
+ * @tags Subscriptions
219
+ * @summary Upsert subscription
220
+ *
221
+ * [Documentation](.../Subscriptions/operation/subscriptions.upsert)
222
+ */
196
223
  upsert: (body, options) => {
197
- return this.request(`/subscriptions`, body, { method: "PUT", ...options });
224
+ return this.request("/subscriptions", body, {
225
+ method: "PUT",
226
+ ...options
227
+ });
198
228
  },
199
229
  /**
200
- *
201
- *
202
- * @tags Subscriptions
203
- * @summary Get subscription by subscription id
204
- *
205
- * [Documentation](.../Subscriptions/operation/subscriptions.getById)
206
- */
230
+ *
231
+ *
232
+ * @tags Subscriptions
233
+ * @summary Get subscription by subscription id
234
+ *
235
+ * [Documentation](.../Subscriptions/operation/subscriptions.getById)
236
+ */
207
237
  getById: (subId, options) => {
208
- return this.request(`/subscriptions/${subId}`, void 0, { method: "GET", ...options });
238
+ return this.request(`/subscriptions/${subId}`, void 0, {
239
+ method: "GET",
240
+ ...options
241
+ });
209
242
  },
210
243
  /**
211
- *
212
- *
213
- * @tags Subscriptions
214
- * @summary Update subscription by subscription id
215
- *
216
- * [Documentation](.../Subscriptions/operation/subscriptions.update)
217
- */
244
+ *
245
+ *
246
+ * @tags Subscriptions
247
+ * @summary Update subscription by subscription id
248
+ *
249
+ * [Documentation](.../Subscriptions/operation/subscriptions.update)
250
+ */
218
251
  update: (subId, body, options) => {
219
- return this.request(`/subscriptions/${subId}`, body, { method: "PUT", ...options });
252
+ return this.request(`/subscriptions/${subId}`, body, {
253
+ method: "PUT",
254
+ ...options
255
+ });
220
256
  },
221
257
  /**
222
- *
223
- *
224
- * @tags Subscriptions
225
- * @summary Delete subscription by subscription id
226
- *
227
- * [Documentation](.../Subscriptions/operation/subscriptions.delete)
228
- */
258
+ *
259
+ *
260
+ * @tags Subscriptions
261
+ * @summary Delete subscription by subscription id
262
+ *
263
+ * [Documentation](.../Subscriptions/operation/subscriptions.delete)
264
+ */
229
265
  delete: (subId, options) => {
230
- return this.request(`/subscriptions/${subId}`, void 0, { method: "DELETE", ...options });
266
+ return this.request(`/subscriptions/${subId}`, void 0, {
267
+ method: "DELETE",
268
+ ...options
269
+ });
231
270
  }
232
271
  };
233
272
  /** @generated stop-generate-methods */
package/dist/index.d.cts CHANGED
@@ -27,7 +27,7 @@ interface ChatStored {
27
27
  username: string;
28
28
  title: string;
29
29
  about: string;
30
- type: 'group' | 'channel';
30
+ type: "group" | "channel";
31
31
  participants_count: number;
32
32
  avatar_id: string | null;
33
33
  last_offset_id: number;
@@ -55,7 +55,7 @@ interface PublishersStatusQueueInputChatParsed {
55
55
  };
56
56
  }
57
57
  interface ChatParsedTyped extends PublishersStatusQueueInputChatParsed {
58
- type: 'chat_parsed';
58
+ type: "chat_parsed";
59
59
  }
60
60
  interface PublishersStatusQueueInputMessagesParsed {
61
61
  chat: {
@@ -73,7 +73,7 @@ interface PublishersStatusQueueInputMessagesParsed {
73
73
  };
74
74
  }
75
75
  interface MessagesParsedTyped extends PublishersStatusQueueInputMessagesParsed {
76
- type: 'messages_parsed';
76
+ type: "messages_parsed";
77
77
  }
78
78
  interface PublishersStatusQueueInputJoin {
79
79
  metadata: {
@@ -85,10 +85,10 @@ interface PublishersStatusQueueInputJoin {
85
85
  account: {
86
86
  id: number;
87
87
  };
88
- status: 'UNAVAILABLE' | 'ALREADY_JOINED' | 'JOINED';
88
+ status: "UNAVAILABLE" | "ALREADY_JOINED" | "JOINED";
89
89
  }
90
90
  interface PublishersStatusQueueInputJoinResult extends PublishersStatusQueueInputJoin {
91
- type: 'chat_join_result';
91
+ type: "chat_join_result";
92
92
  }
93
93
  interface PublishersStatusQueueInputSend {
94
94
  metadata: {
@@ -101,14 +101,14 @@ interface PublishersStatusQueueInputSend {
101
101
  account: {
102
102
  id: number;
103
103
  };
104
- status: 'SENT' | 'ERROR';
104
+ status: "SENT" | "ERROR";
105
105
  message?: {
106
106
  id: number;
107
107
  text: string;
108
108
  };
109
109
  }
110
110
  interface PublishersStatusQueueInputSendResult extends PublishersStatusQueueInputSend {
111
- type: 'chat_send_result';
111
+ type: "chat_send_result";
112
112
  }
113
113
  interface EventByType {
114
114
  chat_parsed: ChatParsedTyped;
@@ -185,13 +185,13 @@ declare class EApi {
185
185
  */
186
186
  app: {
187
187
  /**
188
- *
189
- *
190
- * @tags App
191
- * @summary Get Hello World!
192
- *
193
- * [Documentation](.../App/operation/app.getHello)
194
- */
188
+ *
189
+ *
190
+ * @tags App
191
+ * @summary Get Hello World!
192
+ *
193
+ * [Documentation](.../App/operation/app.getHello)
194
+ */
195
195
  getHello: (options?: RequestOptions) => Promise<GetResponse<"/", "get">>;
196
196
  };
197
197
  /**
@@ -199,58 +199,58 @@ declare class EApi {
199
199
  */
200
200
  chats: {
201
201
  /**
202
- *
203
- *
204
- * @tags chats
205
- * @summary Get Hello World!
206
- *
207
- * [Documentation](.../chats/operation/channels.getHello)
208
- */
202
+ *
203
+ *
204
+ * @tags chats
205
+ * @summary Get Hello World!
206
+ *
207
+ * [Documentation](.../chats/operation/channels.getHello)
208
+ */
209
209
  getHello: (options?: RequestOptions) => Promise<GetResponse<"/chats", "get">>;
210
210
  /**
211
- *
212
- *
213
- * @tags chats
214
- * @summary Get last channel message
215
- *
216
- * [Documentation](.../chats/operation/channels.getLastMessage)
217
- */
211
+ *
212
+ *
213
+ * @tags chats
214
+ * @summary Get last channel message
215
+ *
216
+ * [Documentation](.../chats/operation/channels.getLastMessage)
217
+ */
218
218
  getLastMessage: (chat: paths["/chats/{chat}/last-message"]["get"]["parameters"]["path"]["chat"], options?: RequestOptions) => Promise<GetResponse<"/chats/{chat}/last-message", "get">>;
219
219
  /**
220
- *
221
- *
222
- * @tags chats
223
- * @summary Get chat messages
224
- *
225
- * [Documentation](.../chats/operation/chats.getMessages)
226
- */
220
+ *
221
+ *
222
+ * @tags chats
223
+ * @summary Get chat messages
224
+ *
225
+ * [Documentation](.../chats/operation/chats.getMessages)
226
+ */
227
227
  getMessages: (chat: paths["/chats/{chat}/new-messages"]["post"]["parameters"]["path"]["chat"], body: GetRequestBody<"/chats/{chat}/new-messages", "post">, options?: RequestOptions) => Promise<GetResponse<"/chats/{chat}/new-messages", "post">>;
228
228
  /**
229
- *
230
- *
231
- * @tags chats
232
- * @summary Queue chat
233
- *
234
- * [Documentation](.../chats/operation/chats.queue)
235
- */
229
+ *
230
+ *
231
+ * @tags chats
232
+ * @summary Queue chat
233
+ *
234
+ * [Documentation](.../chats/operation/chats.queue)
235
+ */
236
236
  queue: (externalId: paths["/chats/{chat}/queue/{externalId}"]["post"]["parameters"]["path"]["externalId"], chat: paths["/chats/{chat}/queue/{externalId}"]["post"]["parameters"]["path"]["chat"], options?: RequestOptions) => Promise<GetResponse<"/chats/{chat}/queue/{externalId}", "post">>;
237
237
  /**
238
- *
239
- *
240
- * @tags chats
241
- * @summary Add task to join chat
242
- *
243
- * [Documentation](.../chats/operation/chats.join)
244
- */
238
+ *
239
+ *
240
+ * @tags chats
241
+ * @summary Add task to join chat
242
+ *
243
+ * [Documentation](.../chats/operation/chats.join)
244
+ */
245
245
  join: (externalId: paths["/chats/{chat}/join/{externalId}"]["post"]["parameters"]["path"]["externalId"], chat: paths["/chats/{chat}/join/{externalId}"]["post"]["parameters"]["path"]["chat"], body: GetRequestBody<"/chats/{chat}/join/{externalId}", "post">, options?: RequestOptions) => Promise<GetResponse<"/chats/{chat}/join/{externalId}", "post">>;
246
246
  /**
247
- *
248
- *
249
- * @tags chats
250
- * @summary Add task to send message
251
- *
252
- * [Documentation](.../chats/operation/chats.send)
253
- */
247
+ *
248
+ *
249
+ * @tags chats
250
+ * @summary Add task to send message
251
+ *
252
+ * [Documentation](.../chats/operation/chats.send)
253
+ */
254
254
  send: (externalId: paths["/chats/{chat}/send/{externalId}"]["post"]["parameters"]["path"]["externalId"], chat: paths["/chats/{chat}/send/{externalId}"]["post"]["parameters"]["path"]["chat"], body: GetRequestBody<"/chats/{chat}/send/{externalId}", "post">, options?: RequestOptions) => Promise<GetResponse<"/chats/{chat}/send/{externalId}", "post">>;
255
255
  };
256
256
  /**
@@ -258,49 +258,49 @@ declare class EApi {
258
258
  */
259
259
  subscriptions: {
260
260
  /**
261
- *
262
- *
263
- * @tags Subscriptions
264
- * @summary Create subscription
265
- *
266
- * [Documentation](.../Subscriptions/operation/subscriptions.create)
267
- */
261
+ *
262
+ *
263
+ * @tags Subscriptions
264
+ * @summary Create subscription
265
+ *
266
+ * [Documentation](.../Subscriptions/operation/subscriptions.create)
267
+ */
268
268
  create: (body: GetRequestBody<"/subscriptions", "post">, options?: RequestOptions) => Promise<GetResponse<"/subscriptions", "post">>;
269
269
  /**
270
- *
271
- *
272
- * @tags Subscriptions
273
- * @summary Upsert subscription
274
- *
275
- * [Documentation](.../Subscriptions/operation/subscriptions.upsert)
276
- */
270
+ *
271
+ *
272
+ * @tags Subscriptions
273
+ * @summary Upsert subscription
274
+ *
275
+ * [Documentation](.../Subscriptions/operation/subscriptions.upsert)
276
+ */
277
277
  upsert: (body: GetRequestBody<"/subscriptions", "put">, options?: RequestOptions) => Promise<GetResponse<"/subscriptions", "put">>;
278
278
  /**
279
- *
280
- *
281
- * @tags Subscriptions
282
- * @summary Get subscription by subscription id
283
- *
284
- * [Documentation](.../Subscriptions/operation/subscriptions.getById)
285
- */
279
+ *
280
+ *
281
+ * @tags Subscriptions
282
+ * @summary Get subscription by subscription id
283
+ *
284
+ * [Documentation](.../Subscriptions/operation/subscriptions.getById)
285
+ */
286
286
  getById: (subId: paths["/subscriptions/{subId}"]["get"]["parameters"]["path"]["subId"], options?: RequestOptions) => Promise<GetResponse<"/subscriptions/{subId}", "get">>;
287
287
  /**
288
- *
289
- *
290
- * @tags Subscriptions
291
- * @summary Update subscription by subscription id
292
- *
293
- * [Documentation](.../Subscriptions/operation/subscriptions.update)
294
- */
288
+ *
289
+ *
290
+ * @tags Subscriptions
291
+ * @summary Update subscription by subscription id
292
+ *
293
+ * [Documentation](.../Subscriptions/operation/subscriptions.update)
294
+ */
295
295
  update: (subId: paths["/subscriptions/{subId}"]["put"]["parameters"]["path"]["subId"], body: GetRequestBody<"/subscriptions/{subId}", "put">, options?: RequestOptions) => Promise<GetResponse<"/subscriptions/{subId}", "put">>;
296
296
  /**
297
- *
298
- *
299
- * @tags Subscriptions
300
- * @summary Delete subscription by subscription id
301
- *
302
- * [Documentation](.../Subscriptions/operation/subscriptions.delete)
303
- */
297
+ *
298
+ *
299
+ * @tags Subscriptions
300
+ * @summary Delete subscription by subscription id
301
+ *
302
+ * [Documentation](.../Subscriptions/operation/subscriptions.delete)
303
+ */
304
304
  delete: (subId: paths["/subscriptions/{subId}"]["delete"]["parameters"]["path"]["subId"], options?: RequestOptions) => Promise<GetResponse<"/subscriptions/{subId}", "delete">>;
305
305
  };
306
306
  }
package/dist/index.d.ts CHANGED
@@ -27,7 +27,7 @@ interface ChatStored {
27
27
  username: string;
28
28
  title: string;
29
29
  about: string;
30
- type: 'group' | 'channel';
30
+ type: "group" | "channel";
31
31
  participants_count: number;
32
32
  avatar_id: string | null;
33
33
  last_offset_id: number;
@@ -55,7 +55,7 @@ interface PublishersStatusQueueInputChatParsed {
55
55
  };
56
56
  }
57
57
  interface ChatParsedTyped extends PublishersStatusQueueInputChatParsed {
58
- type: 'chat_parsed';
58
+ type: "chat_parsed";
59
59
  }
60
60
  interface PublishersStatusQueueInputMessagesParsed {
61
61
  chat: {
@@ -73,7 +73,7 @@ interface PublishersStatusQueueInputMessagesParsed {
73
73
  };
74
74
  }
75
75
  interface MessagesParsedTyped extends PublishersStatusQueueInputMessagesParsed {
76
- type: 'messages_parsed';
76
+ type: "messages_parsed";
77
77
  }
78
78
  interface PublishersStatusQueueInputJoin {
79
79
  metadata: {
@@ -85,10 +85,10 @@ interface PublishersStatusQueueInputJoin {
85
85
  account: {
86
86
  id: number;
87
87
  };
88
- status: 'UNAVAILABLE' | 'ALREADY_JOINED' | 'JOINED';
88
+ status: "UNAVAILABLE" | "ALREADY_JOINED" | "JOINED";
89
89
  }
90
90
  interface PublishersStatusQueueInputJoinResult extends PublishersStatusQueueInputJoin {
91
- type: 'chat_join_result';
91
+ type: "chat_join_result";
92
92
  }
93
93
  interface PublishersStatusQueueInputSend {
94
94
  metadata: {
@@ -101,14 +101,14 @@ interface PublishersStatusQueueInputSend {
101
101
  account: {
102
102
  id: number;
103
103
  };
104
- status: 'SENT' | 'ERROR';
104
+ status: "SENT" | "ERROR";
105
105
  message?: {
106
106
  id: number;
107
107
  text: string;
108
108
  };
109
109
  }
110
110
  interface PublishersStatusQueueInputSendResult extends PublishersStatusQueueInputSend {
111
- type: 'chat_send_result';
111
+ type: "chat_send_result";
112
112
  }
113
113
  interface EventByType {
114
114
  chat_parsed: ChatParsedTyped;
@@ -185,13 +185,13 @@ declare class EApi {
185
185
  */
186
186
  app: {
187
187
  /**
188
- *
189
- *
190
- * @tags App
191
- * @summary Get Hello World!
192
- *
193
- * [Documentation](.../App/operation/app.getHello)
194
- */
188
+ *
189
+ *
190
+ * @tags App
191
+ * @summary Get Hello World!
192
+ *
193
+ * [Documentation](.../App/operation/app.getHello)
194
+ */
195
195
  getHello: (options?: RequestOptions) => Promise<GetResponse<"/", "get">>;
196
196
  };
197
197
  /**
@@ -199,58 +199,58 @@ declare class EApi {
199
199
  */
200
200
  chats: {
201
201
  /**
202
- *
203
- *
204
- * @tags chats
205
- * @summary Get Hello World!
206
- *
207
- * [Documentation](.../chats/operation/channels.getHello)
208
- */
202
+ *
203
+ *
204
+ * @tags chats
205
+ * @summary Get Hello World!
206
+ *
207
+ * [Documentation](.../chats/operation/channels.getHello)
208
+ */
209
209
  getHello: (options?: RequestOptions) => Promise<GetResponse<"/chats", "get">>;
210
210
  /**
211
- *
212
- *
213
- * @tags chats
214
- * @summary Get last channel message
215
- *
216
- * [Documentation](.../chats/operation/channels.getLastMessage)
217
- */
211
+ *
212
+ *
213
+ * @tags chats
214
+ * @summary Get last channel message
215
+ *
216
+ * [Documentation](.../chats/operation/channels.getLastMessage)
217
+ */
218
218
  getLastMessage: (chat: paths["/chats/{chat}/last-message"]["get"]["parameters"]["path"]["chat"], options?: RequestOptions) => Promise<GetResponse<"/chats/{chat}/last-message", "get">>;
219
219
  /**
220
- *
221
- *
222
- * @tags chats
223
- * @summary Get chat messages
224
- *
225
- * [Documentation](.../chats/operation/chats.getMessages)
226
- */
220
+ *
221
+ *
222
+ * @tags chats
223
+ * @summary Get chat messages
224
+ *
225
+ * [Documentation](.../chats/operation/chats.getMessages)
226
+ */
227
227
  getMessages: (chat: paths["/chats/{chat}/new-messages"]["post"]["parameters"]["path"]["chat"], body: GetRequestBody<"/chats/{chat}/new-messages", "post">, options?: RequestOptions) => Promise<GetResponse<"/chats/{chat}/new-messages", "post">>;
228
228
  /**
229
- *
230
- *
231
- * @tags chats
232
- * @summary Queue chat
233
- *
234
- * [Documentation](.../chats/operation/chats.queue)
235
- */
229
+ *
230
+ *
231
+ * @tags chats
232
+ * @summary Queue chat
233
+ *
234
+ * [Documentation](.../chats/operation/chats.queue)
235
+ */
236
236
  queue: (externalId: paths["/chats/{chat}/queue/{externalId}"]["post"]["parameters"]["path"]["externalId"], chat: paths["/chats/{chat}/queue/{externalId}"]["post"]["parameters"]["path"]["chat"], options?: RequestOptions) => Promise<GetResponse<"/chats/{chat}/queue/{externalId}", "post">>;
237
237
  /**
238
- *
239
- *
240
- * @tags chats
241
- * @summary Add task to join chat
242
- *
243
- * [Documentation](.../chats/operation/chats.join)
244
- */
238
+ *
239
+ *
240
+ * @tags chats
241
+ * @summary Add task to join chat
242
+ *
243
+ * [Documentation](.../chats/operation/chats.join)
244
+ */
245
245
  join: (externalId: paths["/chats/{chat}/join/{externalId}"]["post"]["parameters"]["path"]["externalId"], chat: paths["/chats/{chat}/join/{externalId}"]["post"]["parameters"]["path"]["chat"], body: GetRequestBody<"/chats/{chat}/join/{externalId}", "post">, options?: RequestOptions) => Promise<GetResponse<"/chats/{chat}/join/{externalId}", "post">>;
246
246
  /**
247
- *
248
- *
249
- * @tags chats
250
- * @summary Add task to send message
251
- *
252
- * [Documentation](.../chats/operation/chats.send)
253
- */
247
+ *
248
+ *
249
+ * @tags chats
250
+ * @summary Add task to send message
251
+ *
252
+ * [Documentation](.../chats/operation/chats.send)
253
+ */
254
254
  send: (externalId: paths["/chats/{chat}/send/{externalId}"]["post"]["parameters"]["path"]["externalId"], chat: paths["/chats/{chat}/send/{externalId}"]["post"]["parameters"]["path"]["chat"], body: GetRequestBody<"/chats/{chat}/send/{externalId}", "post">, options?: RequestOptions) => Promise<GetResponse<"/chats/{chat}/send/{externalId}", "post">>;
255
255
  };
256
256
  /**
@@ -258,49 +258,49 @@ declare class EApi {
258
258
  */
259
259
  subscriptions: {
260
260
  /**
261
- *
262
- *
263
- * @tags Subscriptions
264
- * @summary Create subscription
265
- *
266
- * [Documentation](.../Subscriptions/operation/subscriptions.create)
267
- */
261
+ *
262
+ *
263
+ * @tags Subscriptions
264
+ * @summary Create subscription
265
+ *
266
+ * [Documentation](.../Subscriptions/operation/subscriptions.create)
267
+ */
268
268
  create: (body: GetRequestBody<"/subscriptions", "post">, options?: RequestOptions) => Promise<GetResponse<"/subscriptions", "post">>;
269
269
  /**
270
- *
271
- *
272
- * @tags Subscriptions
273
- * @summary Upsert subscription
274
- *
275
- * [Documentation](.../Subscriptions/operation/subscriptions.upsert)
276
- */
270
+ *
271
+ *
272
+ * @tags Subscriptions
273
+ * @summary Upsert subscription
274
+ *
275
+ * [Documentation](.../Subscriptions/operation/subscriptions.upsert)
276
+ */
277
277
  upsert: (body: GetRequestBody<"/subscriptions", "put">, options?: RequestOptions) => Promise<GetResponse<"/subscriptions", "put">>;
278
278
  /**
279
- *
280
- *
281
- * @tags Subscriptions
282
- * @summary Get subscription by subscription id
283
- *
284
- * [Documentation](.../Subscriptions/operation/subscriptions.getById)
285
- */
279
+ *
280
+ *
281
+ * @tags Subscriptions
282
+ * @summary Get subscription by subscription id
283
+ *
284
+ * [Documentation](.../Subscriptions/operation/subscriptions.getById)
285
+ */
286
286
  getById: (subId: paths["/subscriptions/{subId}"]["get"]["parameters"]["path"]["subId"], options?: RequestOptions) => Promise<GetResponse<"/subscriptions/{subId}", "get">>;
287
287
  /**
288
- *
289
- *
290
- * @tags Subscriptions
291
- * @summary Update subscription by subscription id
292
- *
293
- * [Documentation](.../Subscriptions/operation/subscriptions.update)
294
- */
288
+ *
289
+ *
290
+ * @tags Subscriptions
291
+ * @summary Update subscription by subscription id
292
+ *
293
+ * [Documentation](.../Subscriptions/operation/subscriptions.update)
294
+ */
295
295
  update: (subId: paths["/subscriptions/{subId}"]["put"]["parameters"]["path"]["subId"], body: GetRequestBody<"/subscriptions/{subId}", "put">, options?: RequestOptions) => Promise<GetResponse<"/subscriptions/{subId}", "put">>;
296
296
  /**
297
- *
298
- *
299
- * @tags Subscriptions
300
- * @summary Delete subscription by subscription id
301
- *
302
- * [Documentation](.../Subscriptions/operation/subscriptions.delete)
303
- */
297
+ *
298
+ *
299
+ * @tags Subscriptions
300
+ * @summary Delete subscription by subscription id
301
+ *
302
+ * [Documentation](.../Subscriptions/operation/subscriptions.delete)
303
+ */
304
304
  delete: (subId: paths["/subscriptions/{subId}"]["delete"]["parameters"]["path"]["subId"], options?: RequestOptions) => Promise<GetResponse<"/subscriptions/{subId}", "delete">>;
305
305
  };
306
306
  }
package/dist/index.js CHANGED
@@ -60,6 +60,7 @@ class EApi {
60
60
  headers: {
61
61
  "user-agent": "EAPI SDK",
62
62
  Authorization: `Basic ${btoa(`${this.options.client.id}:${this.options.client.secret}`)}`,
63
+ ...data ? { "content-type": "application/json" } : {},
63
64
  ...this.options.requestOptions?.headers,
64
65
  ...options?.headers
65
66
  }
@@ -69,7 +70,15 @@ class EApi {
69
70
  if (!response.ok) {
70
71
  throw new Error(`${response.status} ${await response.text()}`);
71
72
  }
72
- return response.json();
73
+ const contentType = response.headers.get("content-type");
74
+ const length = response.headers.get("content-length");
75
+ if (contentType?.includes("application/json")) {
76
+ return response.json();
77
+ }
78
+ if (length) {
79
+ return response.text();
80
+ }
81
+ return void 0;
73
82
  }
74
83
  on(type, handler) {
75
84
  this.listeners.push({ event: type, handler });
@@ -86,15 +95,15 @@ class EApi {
86
95
  */
87
96
  app = {
88
97
  /**
89
- *
90
- *
91
- * @tags App
92
- * @summary Get Hello World!
93
- *
94
- * [Documentation](.../App/operation/app.getHello)
95
- */
98
+ *
99
+ *
100
+ * @tags App
101
+ * @summary Get Hello World!
102
+ *
103
+ * [Documentation](.../App/operation/app.getHello)
104
+ */
96
105
  getHello: (options) => {
97
- return this.request(`/`, void 0, { method: "GET", ...options });
106
+ return this.request("/", void 0, { method: "GET", ...options });
98
107
  }
99
108
  };
100
109
  /**
@@ -102,70 +111,85 @@ class EApi {
102
111
  */
103
112
  chats = {
104
113
  /**
105
- *
106
- *
107
- * @tags chats
108
- * @summary Get Hello World!
109
- *
110
- * [Documentation](.../chats/operation/channels.getHello)
111
- */
114
+ *
115
+ *
116
+ * @tags chats
117
+ * @summary Get Hello World!
118
+ *
119
+ * [Documentation](.../chats/operation/channels.getHello)
120
+ */
112
121
  getHello: (options) => {
113
- return this.request(`/chats`, void 0, { method: "GET", ...options });
122
+ return this.request("/chats", void 0, { method: "GET", ...options });
114
123
  },
115
124
  /**
116
- *
117
- *
118
- * @tags chats
119
- * @summary Get last channel message
120
- *
121
- * [Documentation](.../chats/operation/channels.getLastMessage)
122
- */
125
+ *
126
+ *
127
+ * @tags chats
128
+ * @summary Get last channel message
129
+ *
130
+ * [Documentation](.../chats/operation/channels.getLastMessage)
131
+ */
123
132
  getLastMessage: (chat, options) => {
124
- return this.request(`/chats/${chat}/last-message`, void 0, { method: "GET", ...options });
133
+ return this.request(`/chats/${chat}/last-message`, void 0, {
134
+ method: "GET",
135
+ ...options
136
+ });
125
137
  },
126
138
  /**
127
- *
128
- *
129
- * @tags chats
130
- * @summary Get chat messages
131
- *
132
- * [Documentation](.../chats/operation/chats.getMessages)
133
- */
139
+ *
140
+ *
141
+ * @tags chats
142
+ * @summary Get chat messages
143
+ *
144
+ * [Documentation](.../chats/operation/chats.getMessages)
145
+ */
134
146
  getMessages: (chat, body, options) => {
135
- return this.request(`/chats/${chat}/new-messages`, body, { method: "POST", ...options });
147
+ return this.request(`/chats/${chat}/new-messages`, body, {
148
+ method: "POST",
149
+ ...options
150
+ });
136
151
  },
137
152
  /**
138
- *
139
- *
140
- * @tags chats
141
- * @summary Queue chat
142
- *
143
- * [Documentation](.../chats/operation/chats.queue)
144
- */
153
+ *
154
+ *
155
+ * @tags chats
156
+ * @summary Queue chat
157
+ *
158
+ * [Documentation](.../chats/operation/chats.queue)
159
+ */
145
160
  queue: (externalId, chat, options) => {
146
- return this.request(`/chats/${chat}/queue/${externalId}`, void 0, { method: "POST", ...options });
161
+ return this.request(`/chats/${chat}/queue/${externalId}`, void 0, {
162
+ method: "POST",
163
+ ...options
164
+ });
147
165
  },
148
166
  /**
149
- *
150
- *
151
- * @tags chats
152
- * @summary Add task to join chat
153
- *
154
- * [Documentation](.../chats/operation/chats.join)
155
- */
167
+ *
168
+ *
169
+ * @tags chats
170
+ * @summary Add task to join chat
171
+ *
172
+ * [Documentation](.../chats/operation/chats.join)
173
+ */
156
174
  join: (externalId, chat, body, options) => {
157
- return this.request(`/chats/${chat}/join/${externalId}`, body, { method: "POST", ...options });
175
+ return this.request(`/chats/${chat}/join/${externalId}`, body, {
176
+ method: "POST",
177
+ ...options
178
+ });
158
179
  },
159
180
  /**
160
- *
161
- *
162
- * @tags chats
163
- * @summary Add task to send message
164
- *
165
- * [Documentation](.../chats/operation/chats.send)
166
- */
181
+ *
182
+ *
183
+ * @tags chats
184
+ * @summary Add task to send message
185
+ *
186
+ * [Documentation](.../chats/operation/chats.send)
187
+ */
167
188
  send: (externalId, chat, body, options) => {
168
- return this.request(`/chats/${chat}/send/${externalId}`, body, { method: "POST", ...options });
189
+ return this.request(`/chats/${chat}/send/${externalId}`, body, {
190
+ method: "POST",
191
+ ...options
192
+ });
169
193
  }
170
194
  };
171
195
  /**
@@ -173,59 +197,74 @@ class EApi {
173
197
  */
174
198
  subscriptions = {
175
199
  /**
176
- *
177
- *
178
- * @tags Subscriptions
179
- * @summary Create subscription
180
- *
181
- * [Documentation](.../Subscriptions/operation/subscriptions.create)
182
- */
200
+ *
201
+ *
202
+ * @tags Subscriptions
203
+ * @summary Create subscription
204
+ *
205
+ * [Documentation](.../Subscriptions/operation/subscriptions.create)
206
+ */
183
207
  create: (body, options) => {
184
- return this.request(`/subscriptions`, body, { method: "POST", ...options });
208
+ return this.request("/subscriptions", body, {
209
+ method: "POST",
210
+ ...options
211
+ });
185
212
  },
186
213
  /**
187
- *
188
- *
189
- * @tags Subscriptions
190
- * @summary Upsert subscription
191
- *
192
- * [Documentation](.../Subscriptions/operation/subscriptions.upsert)
193
- */
214
+ *
215
+ *
216
+ * @tags Subscriptions
217
+ * @summary Upsert subscription
218
+ *
219
+ * [Documentation](.../Subscriptions/operation/subscriptions.upsert)
220
+ */
194
221
  upsert: (body, options) => {
195
- return this.request(`/subscriptions`, body, { method: "PUT", ...options });
222
+ return this.request("/subscriptions", body, {
223
+ method: "PUT",
224
+ ...options
225
+ });
196
226
  },
197
227
  /**
198
- *
199
- *
200
- * @tags Subscriptions
201
- * @summary Get subscription by subscription id
202
- *
203
- * [Documentation](.../Subscriptions/operation/subscriptions.getById)
204
- */
228
+ *
229
+ *
230
+ * @tags Subscriptions
231
+ * @summary Get subscription by subscription id
232
+ *
233
+ * [Documentation](.../Subscriptions/operation/subscriptions.getById)
234
+ */
205
235
  getById: (subId, options) => {
206
- return this.request(`/subscriptions/${subId}`, void 0, { method: "GET", ...options });
236
+ return this.request(`/subscriptions/${subId}`, void 0, {
237
+ method: "GET",
238
+ ...options
239
+ });
207
240
  },
208
241
  /**
209
- *
210
- *
211
- * @tags Subscriptions
212
- * @summary Update subscription by subscription id
213
- *
214
- * [Documentation](.../Subscriptions/operation/subscriptions.update)
215
- */
242
+ *
243
+ *
244
+ * @tags Subscriptions
245
+ * @summary Update subscription by subscription id
246
+ *
247
+ * [Documentation](.../Subscriptions/operation/subscriptions.update)
248
+ */
216
249
  update: (subId, body, options) => {
217
- return this.request(`/subscriptions/${subId}`, body, { method: "PUT", ...options });
250
+ return this.request(`/subscriptions/${subId}`, body, {
251
+ method: "PUT",
252
+ ...options
253
+ });
218
254
  },
219
255
  /**
220
- *
221
- *
222
- * @tags Subscriptions
223
- * @summary Delete subscription by subscription id
224
- *
225
- * [Documentation](.../Subscriptions/operation/subscriptions.delete)
226
- */
256
+ *
257
+ *
258
+ * @tags Subscriptions
259
+ * @summary Delete subscription by subscription id
260
+ *
261
+ * [Documentation](.../Subscriptions/operation/subscriptions.delete)
262
+ */
227
263
  delete: (subId, options) => {
228
- return this.request(`/subscriptions/${subId}`, void 0, { method: "DELETE", ...options });
264
+ return this.request(`/subscriptions/${subId}`, void 0, {
265
+ method: "DELETE",
266
+ ...options
267
+ });
229
268
  }
230
269
  };
231
270
  /** @generated stop-generate-methods */
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@skravets/eapi",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "module": "./dist/index.js",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.ts",
7
7
  "scripts": {
8
- "build": "bunx pkgroll"
8
+ "build": "bunx pkgroll",
9
+ "prepublishOnly": "bunx pkgroll"
9
10
  },
10
11
  "exports": {
11
12
  ".": {