@base44-preview/sdk 0.7.0-pr.27.15b5e4d → 0.7.0-pr.27.9034994
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/dist/client.d.ts +2 -0
- package/dist/client.js +24 -14
- package/dist/modules/agents.d.ts +1 -1
- package/dist/modules/agents.types.d.ts +44 -0
- package/dist/modules/agents.types.js +1 -0
- package/dist/modules/app.types.d.ts +115 -0
- package/dist/modules/app.types.js +1 -0
- package/dist/modules/auth.d.ts +4 -1
- package/dist/modules/auth.js +5 -1
- package/dist/modules/types.d.ts +2 -44
- package/dist/modules/types.js +2 -1
- package/dist/utils/axios-client.d.ts +2 -1
- package/dist/utils/axios-client.js +4 -2
- package/dist/utils/socket-utils.js +18 -11
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -18,7 +18,9 @@ export declare function createClient(config: {
|
|
|
18
18
|
token?: string;
|
|
19
19
|
serviceToken?: string;
|
|
20
20
|
requiresAuth?: boolean;
|
|
21
|
+
functionsVersion?: string;
|
|
21
22
|
options?: CreateClientOptions;
|
|
23
|
+
onRedirectToLogin?: () => void;
|
|
22
24
|
}): {
|
|
23
25
|
/**
|
|
24
26
|
* Set authentication token for all requests
|
package/dist/client.js
CHANGED
|
@@ -18,7 +18,7 @@ import { RoomsSocket } from "./utils/socket-utils.js";
|
|
|
18
18
|
* @returns {Object} Base44 client instance
|
|
19
19
|
*/
|
|
20
20
|
export function createClient(config) {
|
|
21
|
-
const { serverUrl = "https://base44.app", appId, token, serviceToken, requiresAuth = false, options, } = config;
|
|
21
|
+
const { serverUrl = "https://base44.app", appId, token, serviceToken, requiresAuth = false, options, functionsVersion, onRedirectToLogin, } = config;
|
|
22
22
|
const socketConfig = {
|
|
23
23
|
serverUrl,
|
|
24
24
|
mountPath: "/ws-user-apps/socket.io/",
|
|
@@ -29,53 +29,61 @@ export function createClient(config) {
|
|
|
29
29
|
const socket = RoomsSocket({
|
|
30
30
|
config: socketConfig,
|
|
31
31
|
});
|
|
32
|
+
const headers = {
|
|
33
|
+
"X-App-Id": String(appId),
|
|
34
|
+
};
|
|
35
|
+
const functionHeaders = functionsVersion
|
|
36
|
+
? {
|
|
37
|
+
...headers,
|
|
38
|
+
"Base44-Functions-Version": functionsVersion,
|
|
39
|
+
}
|
|
40
|
+
: headers;
|
|
32
41
|
const axiosClient = createAxiosClient({
|
|
33
42
|
baseURL: `${serverUrl}/api`,
|
|
34
|
-
headers
|
|
35
|
-
"X-App-Id": String(appId),
|
|
36
|
-
},
|
|
43
|
+
headers,
|
|
37
44
|
token,
|
|
38
45
|
requiresAuth,
|
|
39
46
|
appId,
|
|
40
47
|
serverUrl,
|
|
41
48
|
onError: options === null || options === void 0 ? void 0 : options.onError,
|
|
49
|
+
onRedirectToLogin,
|
|
42
50
|
});
|
|
43
51
|
const functionsAxiosClient = createAxiosClient({
|
|
44
52
|
baseURL: `${serverUrl}/api`,
|
|
45
|
-
headers:
|
|
46
|
-
"X-App-Id": String(appId),
|
|
47
|
-
},
|
|
53
|
+
headers: functionHeaders,
|
|
48
54
|
token,
|
|
49
55
|
requiresAuth,
|
|
50
56
|
appId,
|
|
51
57
|
serverUrl,
|
|
52
58
|
interceptResponses: false,
|
|
53
59
|
onError: options === null || options === void 0 ? void 0 : options.onError,
|
|
60
|
+
onRedirectToLogin,
|
|
54
61
|
});
|
|
55
62
|
const serviceRoleAxiosClient = createAxiosClient({
|
|
56
63
|
baseURL: `${serverUrl}/api`,
|
|
57
|
-
headers
|
|
58
|
-
"X-App-Id": String(appId),
|
|
59
|
-
},
|
|
64
|
+
headers,
|
|
60
65
|
token: serviceToken,
|
|
61
66
|
serverUrl,
|
|
62
67
|
appId,
|
|
63
68
|
onError: options === null || options === void 0 ? void 0 : options.onError,
|
|
69
|
+
onRedirectToLogin,
|
|
64
70
|
});
|
|
65
71
|
const serviceRoleFunctionsAxiosClient = createAxiosClient({
|
|
66
72
|
baseURL: `${serverUrl}/api`,
|
|
67
|
-
headers:
|
|
68
|
-
"X-App-Id": String(appId),
|
|
69
|
-
},
|
|
73
|
+
headers: functionHeaders,
|
|
70
74
|
token: serviceToken,
|
|
71
75
|
serverUrl,
|
|
72
76
|
appId,
|
|
73
77
|
interceptResponses: false,
|
|
78
|
+
onRedirectToLogin,
|
|
74
79
|
});
|
|
75
80
|
const userModules = {
|
|
76
81
|
entities: createEntitiesModule(axiosClient, appId),
|
|
77
82
|
integrations: createIntegrationsModule(axiosClient, appId),
|
|
78
|
-
auth: createAuthModule(axiosClient, functionsAxiosClient, appId
|
|
83
|
+
auth: createAuthModule(axiosClient, functionsAxiosClient, appId, {
|
|
84
|
+
onRedirectToLogin,
|
|
85
|
+
serverUrl,
|
|
86
|
+
}),
|
|
79
87
|
functions: createFunctionsModule(functionsAxiosClient, appId),
|
|
80
88
|
agents: createAgentsModule({
|
|
81
89
|
axios: axiosClient,
|
|
@@ -166,6 +174,7 @@ export function createClientFromRequest(request) {
|
|
|
166
174
|
const serviceRoleAuthHeader = request.headers.get("Base44-Service-Authorization");
|
|
167
175
|
const appId = request.headers.get("Base44-App-Id");
|
|
168
176
|
const serverUrlHeader = request.headers.get("Base44-Api-Url");
|
|
177
|
+
const functionsVersion = request.headers.get("Base44-Functions-Version");
|
|
169
178
|
if (!appId) {
|
|
170
179
|
throw new Error("Base44-App-Id header is required, but is was not found on the request");
|
|
171
180
|
}
|
|
@@ -193,5 +202,6 @@ export function createClientFromRequest(request) {
|
|
|
193
202
|
appId,
|
|
194
203
|
token: userToken,
|
|
195
204
|
serviceToken: serviceRoleToken,
|
|
205
|
+
functionsVersion: functionsVersion !== null && functionsVersion !== void 0 ? functionsVersion : undefined,
|
|
196
206
|
});
|
|
197
207
|
}
|
package/dist/modules/agents.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RoomsSocket } from "../utils/socket-utils.js";
|
|
2
|
-
import { AgentConversation, AgentMessage } from "./types.js";
|
|
2
|
+
import { AgentConversation, AgentMessage } from "./agents.types.js";
|
|
3
3
|
import { AxiosInstance } from "axios";
|
|
4
4
|
import { ModelFilterParams } from "../types.js";
|
|
5
5
|
export type AgentsModuleConfig = {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type AgentConversation = {
|
|
2
|
+
id: string;
|
|
3
|
+
app_id: string;
|
|
4
|
+
agent_name: string;
|
|
5
|
+
created_by_id: string;
|
|
6
|
+
messages: AgentMessage[];
|
|
7
|
+
metadata?: Record<string, any>;
|
|
8
|
+
};
|
|
9
|
+
export type AgentMessage = {
|
|
10
|
+
id: string;
|
|
11
|
+
role: "user" | "assistant" | "system";
|
|
12
|
+
reasoning?: {
|
|
13
|
+
start_date: string;
|
|
14
|
+
end_date?: string;
|
|
15
|
+
content: string;
|
|
16
|
+
};
|
|
17
|
+
content?: string | Record<string, any> | null;
|
|
18
|
+
file_urls?: string[] | null;
|
|
19
|
+
tool_calls?: {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
arguments_string: string;
|
|
23
|
+
status: "running" | "success" | "error" | "stopped";
|
|
24
|
+
results?: string | null;
|
|
25
|
+
}[] | null;
|
|
26
|
+
usage?: {
|
|
27
|
+
prompt_tokens?: number;
|
|
28
|
+
completion_tokens?: number;
|
|
29
|
+
} | null;
|
|
30
|
+
hidden?: boolean;
|
|
31
|
+
custom_context?: {
|
|
32
|
+
message: string;
|
|
33
|
+
data: Record<string, any>;
|
|
34
|
+
type: string;
|
|
35
|
+
}[] | null;
|
|
36
|
+
model?: string | null;
|
|
37
|
+
checkpoint_id?: string | null;
|
|
38
|
+
metadata?: {
|
|
39
|
+
created_date: string;
|
|
40
|
+
created_by_email: string;
|
|
41
|
+
created_by_full_name: string | null;
|
|
42
|
+
};
|
|
43
|
+
additional_message_params?: Record<string, any>;
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export interface AppMessageContent {
|
|
2
|
+
content?: string;
|
|
3
|
+
file_urls?: string[];
|
|
4
|
+
custom_context?: unknown;
|
|
5
|
+
additional_message_params?: Record<string, unknown>;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
export interface AppConversationMessage extends AppMessageContent {
|
|
9
|
+
id?: string | null;
|
|
10
|
+
role?: "user" | "assistant" | string;
|
|
11
|
+
}
|
|
12
|
+
export interface AppConversationLike {
|
|
13
|
+
id?: string | null;
|
|
14
|
+
messages?: AppMessageContent[] | null;
|
|
15
|
+
model?: string;
|
|
16
|
+
functions_fail_silently?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface DenoProjectLike {
|
|
19
|
+
project_id: string;
|
|
20
|
+
project_name: string;
|
|
21
|
+
app_id: string;
|
|
22
|
+
deployment_name_to_info: Record<string, {
|
|
23
|
+
id: string;
|
|
24
|
+
code: string;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
export interface AppLike {
|
|
28
|
+
id?: string;
|
|
29
|
+
conversation?: AppConversationLike | null;
|
|
30
|
+
app_stage?: "pending" | "product_flows" | "ready" | string;
|
|
31
|
+
created_date?: string;
|
|
32
|
+
updated_date?: string;
|
|
33
|
+
created_by?: string;
|
|
34
|
+
organization_id?: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
user_description?: string;
|
|
37
|
+
entities?: Record<string, any>;
|
|
38
|
+
additional_user_data_schema?: any;
|
|
39
|
+
pages?: {
|
|
40
|
+
[key: string]: string;
|
|
41
|
+
};
|
|
42
|
+
components: {
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
};
|
|
45
|
+
layout?: string;
|
|
46
|
+
globals_css?: string;
|
|
47
|
+
agents?: Record<string, any>;
|
|
48
|
+
logo_url?: string;
|
|
49
|
+
slug?: string;
|
|
50
|
+
public_settings?: "private_with_login" | "public_with_login" | "public_without_login" | "workspace_with_login" | string;
|
|
51
|
+
is_blocked?: boolean;
|
|
52
|
+
github_repo_url?: string;
|
|
53
|
+
main_page?: string;
|
|
54
|
+
installable_integrations?: any;
|
|
55
|
+
backend_project?: DenoProjectLike;
|
|
56
|
+
last_deployed_at?: string;
|
|
57
|
+
is_remixable?: boolean;
|
|
58
|
+
remixed_from_app_id?: string;
|
|
59
|
+
hide_entity_created_by?: boolean;
|
|
60
|
+
platform_version?: number;
|
|
61
|
+
enable_username_password?: boolean;
|
|
62
|
+
auth_config?: AuthConfigLike;
|
|
63
|
+
status?: {
|
|
64
|
+
state?: string;
|
|
65
|
+
details?: any;
|
|
66
|
+
last_updated_date?: string;
|
|
67
|
+
};
|
|
68
|
+
custom_instructions?: any;
|
|
69
|
+
frozen_files?: string[];
|
|
70
|
+
deep_coding_mode?: boolean;
|
|
71
|
+
needs_to_add_diff?: boolean;
|
|
72
|
+
installed_integration_context_items?: any[];
|
|
73
|
+
model?: string;
|
|
74
|
+
is_starred?: boolean;
|
|
75
|
+
agents_enabled?: boolean;
|
|
76
|
+
categories?: string[];
|
|
77
|
+
functions?: any;
|
|
78
|
+
function_names?: string[];
|
|
79
|
+
user_entity?: UserEntityLike;
|
|
80
|
+
app_code_hash?: string;
|
|
81
|
+
has_backend_functions_enabled?: boolean;
|
|
82
|
+
}
|
|
83
|
+
export interface UserLike {
|
|
84
|
+
id?: string | null;
|
|
85
|
+
}
|
|
86
|
+
export interface UserEntityLike {
|
|
87
|
+
type: string;
|
|
88
|
+
name: string;
|
|
89
|
+
title?: string;
|
|
90
|
+
properties?: {
|
|
91
|
+
role?: {
|
|
92
|
+
type?: string;
|
|
93
|
+
description?: string;
|
|
94
|
+
enum?: ("admin" | "user" | string)[];
|
|
95
|
+
};
|
|
96
|
+
email?: {
|
|
97
|
+
type?: string;
|
|
98
|
+
description?: string;
|
|
99
|
+
};
|
|
100
|
+
full_name?: {
|
|
101
|
+
type?: string;
|
|
102
|
+
description?: string;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
required: string[];
|
|
106
|
+
}
|
|
107
|
+
export interface AuthConfigLike {
|
|
108
|
+
enable_username_password?: boolean;
|
|
109
|
+
enable_google_login?: boolean;
|
|
110
|
+
enable_microsoft_login?: boolean;
|
|
111
|
+
enable_facebook_login?: boolean;
|
|
112
|
+
sso_provider_name?: string;
|
|
113
|
+
enable_sso_login?: boolean;
|
|
114
|
+
}
|
|
115
|
+
export type LoginInfoResponse = Pick<AppLike, "id" | "name" | "slug" | "logo_url" | "user_description" | "updated_date" | "created_date" | "auth_config" | "platform_version">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/modules/auth.d.ts
CHANGED
|
@@ -6,7 +6,10 @@ import { AxiosInstance } from "axios";
|
|
|
6
6
|
* @param {string} serverUrl - Server URL
|
|
7
7
|
* @returns {Object} Auth module with authentication methods
|
|
8
8
|
*/
|
|
9
|
-
export declare function createAuthModule(axios: AxiosInstance, functionsAxiosClient: AxiosInstance, appId: string
|
|
9
|
+
export declare function createAuthModule(axios: AxiosInstance, functionsAxiosClient: AxiosInstance, appId: string, options: {
|
|
10
|
+
serverUrl: string;
|
|
11
|
+
onRedirectToLogin?: () => void;
|
|
12
|
+
}): {
|
|
10
13
|
/**
|
|
11
14
|
* Get current user information
|
|
12
15
|
* @returns {Promise<Object>} Current user data
|
package/dist/modules/auth.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param {string} serverUrl - Server URL
|
|
6
6
|
* @returns {Object} Auth module with authentication methods
|
|
7
7
|
*/
|
|
8
|
-
export function createAuthModule(axios, functionsAxiosClient, appId) {
|
|
8
|
+
export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
9
9
|
return {
|
|
10
10
|
/**
|
|
11
11
|
* Get current user information
|
|
@@ -32,6 +32,10 @@ export function createAuthModule(axios, functionsAxiosClient, appId) {
|
|
|
32
32
|
if (typeof window === "undefined") {
|
|
33
33
|
throw new Error("Login method can only be used in a browser environment");
|
|
34
34
|
}
|
|
35
|
+
if (options.onRedirectToLogin) {
|
|
36
|
+
options.onRedirectToLogin();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
35
39
|
// If nextUrl is not provided, use the current URL
|
|
36
40
|
const redirectUrl = nextUrl || window.location.href;
|
|
37
41
|
// Build the login URL
|
package/dist/modules/types.d.ts
CHANGED
|
@@ -1,44 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
app_id: string;
|
|
4
|
-
agent_name: string;
|
|
5
|
-
created_by_id: string;
|
|
6
|
-
messages: AgentMessage[];
|
|
7
|
-
metadata?: Record<string, any>;
|
|
8
|
-
};
|
|
9
|
-
export type AgentMessage = {
|
|
10
|
-
id: string;
|
|
11
|
-
role: "user" | "assistant" | "system";
|
|
12
|
-
reasoning?: {
|
|
13
|
-
start_date: string;
|
|
14
|
-
end_date?: string;
|
|
15
|
-
content: string;
|
|
16
|
-
};
|
|
17
|
-
content?: string | Record<string, any> | null;
|
|
18
|
-
file_urls?: string[] | null;
|
|
19
|
-
tool_calls?: {
|
|
20
|
-
id: string;
|
|
21
|
-
name: string;
|
|
22
|
-
arguments_string: string;
|
|
23
|
-
status: "running" | "success" | "error" | "stopped";
|
|
24
|
-
results?: string | null;
|
|
25
|
-
}[] | null;
|
|
26
|
-
usage?: {
|
|
27
|
-
prompt_tokens?: number;
|
|
28
|
-
completion_tokens?: number;
|
|
29
|
-
} | null;
|
|
30
|
-
hidden?: boolean;
|
|
31
|
-
custom_context?: {
|
|
32
|
-
message: string;
|
|
33
|
-
data: Record<string, any>;
|
|
34
|
-
type: string;
|
|
35
|
-
}[] | null;
|
|
36
|
-
model?: string | null;
|
|
37
|
-
checkpoint_id?: string | null;
|
|
38
|
-
metadata?: {
|
|
39
|
-
created_date: string;
|
|
40
|
-
created_by_email: string;
|
|
41
|
-
created_by_full_name: string | null;
|
|
42
|
-
};
|
|
43
|
-
additional_message_params?: Record<string, any>;
|
|
44
|
-
};
|
|
1
|
+
export * from "./app.types.js";
|
|
2
|
+
export * from "./agents.types.js";
|
package/dist/modules/types.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./app.types.js";
|
|
2
|
+
export * from "./agents.types.js";
|
|
@@ -23,7 +23,7 @@ export declare class Base44Error extends Error {
|
|
|
23
23
|
* @param {string} options.serverUrl - Server URL (needed for login redirect)
|
|
24
24
|
* @returns {import('axios').AxiosInstance} Configured axios instance
|
|
25
25
|
*/
|
|
26
|
-
export declare function createAxiosClient({ baseURL, headers, token, requiresAuth, appId, serverUrl, interceptResponses, onError, }: {
|
|
26
|
+
export declare function createAxiosClient({ baseURL, headers, token, requiresAuth, appId, serverUrl, interceptResponses, onError, onRedirectToLogin, }: {
|
|
27
27
|
baseURL: string;
|
|
28
28
|
headers?: Record<string, string>;
|
|
29
29
|
token?: string;
|
|
@@ -32,4 +32,5 @@ export declare function createAxiosClient({ baseURL, headers, token, requiresAut
|
|
|
32
32
|
serverUrl: string;
|
|
33
33
|
interceptResponses?: boolean;
|
|
34
34
|
onError?: (error: Error) => void;
|
|
35
|
+
onRedirectToLogin?: () => void;
|
|
35
36
|
}): import("axios").AxiosInstance;
|
|
@@ -64,7 +64,7 @@ function redirectToLogin(serverUrl, appId) {
|
|
|
64
64
|
* @param {string} options.serverUrl - Server URL (needed for login redirect)
|
|
65
65
|
* @returns {import('axios').AxiosInstance} Configured axios instance
|
|
66
66
|
*/
|
|
67
|
-
export function createAxiosClient({ baseURL, headers = {}, token, requiresAuth = false, appId, serverUrl, interceptResponses = true, onError, }) {
|
|
67
|
+
export function createAxiosClient({ baseURL, headers = {}, token, requiresAuth = false, appId, serverUrl, interceptResponses = true, onError, onRedirectToLogin, }) {
|
|
68
68
|
const client = axios.create({
|
|
69
69
|
baseURL,
|
|
70
70
|
headers: {
|
|
@@ -104,7 +104,9 @@ export function createAxiosClient({ baseURL, headers = {}, token, requiresAuth =
|
|
|
104
104
|
console.log("Authentication required. Redirecting to login...");
|
|
105
105
|
// Use a slight delay to allow the error to propagate first
|
|
106
106
|
setTimeout(() => {
|
|
107
|
-
|
|
107
|
+
onRedirectToLogin
|
|
108
|
+
? onRedirectToLogin()
|
|
109
|
+
: redirectToLogin(serverUrl, appId);
|
|
108
110
|
}, 100);
|
|
109
111
|
}
|
|
110
112
|
onError === null || onError === void 0 ? void 0 : onError(base44Error);
|
|
@@ -10,23 +10,23 @@ function initializeSocket(config, handlers) {
|
|
|
10
10
|
token: (_a = config.token) !== null && _a !== void 0 ? _a : getAccessToken(),
|
|
11
11
|
},
|
|
12
12
|
});
|
|
13
|
-
socket.on("connect", () => {
|
|
13
|
+
socket.on("connect", async () => {
|
|
14
14
|
var _a;
|
|
15
15
|
console.log("connect", socket.id);
|
|
16
|
-
(_a = handlers.connect) === null || _a === void 0 ? void 0 : _a.call(handlers);
|
|
16
|
+
return (_a = handlers.connect) === null || _a === void 0 ? void 0 : _a.call(handlers);
|
|
17
17
|
});
|
|
18
|
-
socket.on("update_model", (msg) => {
|
|
18
|
+
socket.on("update_model", async (msg) => {
|
|
19
19
|
var _a;
|
|
20
|
-
(_a = handlers.update_model) === null || _a === void 0 ? void 0 : _a.call(handlers, msg);
|
|
20
|
+
return (_a = handlers.update_model) === null || _a === void 0 ? void 0 : _a.call(handlers, msg);
|
|
21
21
|
});
|
|
22
|
-
socket.on("error", (error) => {
|
|
22
|
+
socket.on("error", async (error) => {
|
|
23
23
|
var _a;
|
|
24
|
-
(_a = handlers.error) === null || _a === void 0 ? void 0 : _a.call(handlers, error);
|
|
24
|
+
return (_a = handlers.error) === null || _a === void 0 ? void 0 : _a.call(handlers, error);
|
|
25
25
|
});
|
|
26
|
-
socket.on("connect_error", (error) => {
|
|
26
|
+
socket.on("connect_error", async (error) => {
|
|
27
27
|
var _a;
|
|
28
28
|
console.error("connect_error", error);
|
|
29
|
-
(_a = handlers.error) === null || _a === void 0 ? void 0 : _a.call(handlers, error);
|
|
29
|
+
return (_a = handlers.error) === null || _a === void 0 ? void 0 : _a.call(handlers, error);
|
|
30
30
|
});
|
|
31
31
|
return socket;
|
|
32
32
|
}
|
|
@@ -52,9 +52,11 @@ export function RoomsSocket({ config }) {
|
|
|
52
52
|
await Promise.all(promises);
|
|
53
53
|
},
|
|
54
54
|
error: async (error) => {
|
|
55
|
-
var _a;
|
|
56
55
|
console.error("error", error);
|
|
57
|
-
|
|
56
|
+
const promises = Object.values(roomsToListeners)
|
|
57
|
+
.flat()
|
|
58
|
+
.map((listener) => { var _a; return (_a = listener.error) === null || _a === void 0 ? void 0 : _a.call(listener, error); });
|
|
59
|
+
await Promise.all(promises);
|
|
58
60
|
},
|
|
59
61
|
};
|
|
60
62
|
let socket = initializeSocket(config, handlers);
|
|
@@ -95,7 +97,12 @@ export function RoomsSocket({ config }) {
|
|
|
95
97
|
}
|
|
96
98
|
roomsToListeners[room].push(handlers);
|
|
97
99
|
return () => {
|
|
98
|
-
|
|
100
|
+
var _a, _b;
|
|
101
|
+
roomsToListeners[room] =
|
|
102
|
+
(_b = (_a = roomsToListeners[room]) === null || _a === void 0 ? void 0 : _a.filter((listener) => listener !== handlers)) !== null && _b !== void 0 ? _b : [];
|
|
103
|
+
if (roomsToListeners[room].length === 0) {
|
|
104
|
+
leaveRoom(room);
|
|
105
|
+
}
|
|
99
106
|
};
|
|
100
107
|
};
|
|
101
108
|
return {
|