@n8n/chat 0.7.0 → 0.8.0
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/package.json +1 -1
- package/src/__tests__/utils/fetch.ts +1 -1
- package/src/api/generic.ts +6 -6
- package/src/api/message.ts +2 -2
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import type { LoadPreviousSessionResponse, SendMessageResponse } from '@n8n/chat
|
|
|
3
3
|
export function createFetchResponse<T>(data: T) {
|
|
4
4
|
return async () =>
|
|
5
5
|
({
|
|
6
|
-
json: async () => new Promise<T>((resolve) => resolve(data)),
|
|
6
|
+
json: async () => await new Promise<T>((resolve) => resolve(data)),
|
|
7
7
|
}) as Response;
|
|
8
8
|
}
|
|
9
9
|
|
package/src/api/generic.ts
CHANGED
|
@@ -16,7 +16,7 @@ export async function authenticatedFetch<T>(...args: Parameters<typeof fetch>):
|
|
|
16
16
|
},
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
return (await response.json()) as
|
|
19
|
+
return (await response.json()) as T;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export async function get<T>(url: string, query: object = {}, options: RequestInit = {}) {
|
|
@@ -27,11 +27,11 @@ export async function get<T>(url: string, query: object = {}, options: RequestIn
|
|
|
27
27
|
).toString()}`;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
return authenticatedFetch<T>(resolvedUrl, { ...options, method: 'GET' });
|
|
30
|
+
return await authenticatedFetch<T>(resolvedUrl, { ...options, method: 'GET' });
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export async function post<T>(url: string, body: object = {}, options: RequestInit = {}) {
|
|
34
|
-
return authenticatedFetch<T>(url, {
|
|
34
|
+
return await authenticatedFetch<T>(url, {
|
|
35
35
|
...options,
|
|
36
36
|
method: 'POST',
|
|
37
37
|
body: JSON.stringify(body),
|
|
@@ -39,7 +39,7 @@ export async function post<T>(url: string, body: object = {}, options: RequestIn
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export async function put<T>(url: string, body: object = {}, options: RequestInit = {}) {
|
|
42
|
-
return authenticatedFetch<T>(url, {
|
|
42
|
+
return await authenticatedFetch<T>(url, {
|
|
43
43
|
...options,
|
|
44
44
|
method: 'PUT',
|
|
45
45
|
body: JSON.stringify(body),
|
|
@@ -47,7 +47,7 @@ export async function put<T>(url: string, body: object = {}, options: RequestIni
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export async function patch<T>(url: string, body: object = {}, options: RequestInit = {}) {
|
|
50
|
-
return authenticatedFetch<T>(url, {
|
|
50
|
+
return await authenticatedFetch<T>(url, {
|
|
51
51
|
...options,
|
|
52
52
|
method: 'PATCH',
|
|
53
53
|
body: JSON.stringify(body),
|
|
@@ -55,7 +55,7 @@ export async function patch<T>(url: string, body: object = {}, options: RequestI
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
export async function del<T>(url: string, body: object = {}, options: RequestInit = {}) {
|
|
58
|
-
return authenticatedFetch<T>(url, {
|
|
58
|
+
return await authenticatedFetch<T>(url, {
|
|
59
59
|
...options,
|
|
60
60
|
method: 'DELETE',
|
|
61
61
|
body: JSON.stringify(body),
|
package/src/api/message.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
|
|
8
8
|
export async function loadPreviousSession(sessionId: string, options: ChatOptions) {
|
|
9
9
|
const method = options.webhookConfig?.method === 'POST' ? post : get;
|
|
10
|
-
return method<LoadPreviousSessionResponse>(
|
|
10
|
+
return await method<LoadPreviousSessionResponse>(
|
|
11
11
|
`${options.webhookUrl}`,
|
|
12
12
|
{
|
|
13
13
|
action: 'loadPreviousSession',
|
|
@@ -22,7 +22,7 @@ export async function loadPreviousSession(sessionId: string, options: ChatOption
|
|
|
22
22
|
|
|
23
23
|
export async function sendMessage(message: string, sessionId: string, options: ChatOptions) {
|
|
24
24
|
const method = options.webhookConfig?.method === 'POST' ? post : get;
|
|
25
|
-
return method<SendMessageResponse>(
|
|
25
|
+
return await method<SendMessageResponse>(
|
|
26
26
|
`${options.webhookUrl}`,
|
|
27
27
|
{
|
|
28
28
|
action: 'sendMessage',
|