@base44/sdk 0.8.3 → 0.8.5

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 CHANGED
@@ -44,6 +44,9 @@ export declare function createClient(config: {
44
44
  sso: {
45
45
  getAccessToken(userid: string): Promise<import("axios").AxiosResponse<any, any>>;
46
46
  };
47
+ connectors: {
48
+ getAccessToken(integrationType: import("./types.js").ConnectorIntegrationType): Promise<import("./types.js").ConnectorAccessTokenResponse>;
49
+ };
47
50
  functions: {
48
51
  invoke(functionName: string, data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
49
52
  };
@@ -122,6 +125,9 @@ export declare function createClient(config: {
122
125
  fetchLogs(params?: Record<string, any>): Promise<any>;
123
126
  getStats(params?: Record<string, any>): Promise<any>;
124
127
  };
128
+ users: {
129
+ inviteUser(user_email: string, role: "user" | "admin"): Promise<any>;
130
+ };
125
131
  cleanup: () => void;
126
132
  };
127
133
  export declare function createClientFromRequest(request: Request): {
@@ -145,6 +151,9 @@ export declare function createClientFromRequest(request: Request): {
145
151
  sso: {
146
152
  getAccessToken(userid: string): Promise<import("axios").AxiosResponse<any, any>>;
147
153
  };
154
+ connectors: {
155
+ getAccessToken(integrationType: import("./types.js").ConnectorIntegrationType): Promise<import("./types.js").ConnectorAccessTokenResponse>;
156
+ };
148
157
  functions: {
149
158
  invoke(functionName: string, data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
150
159
  };
@@ -223,5 +232,8 @@ export declare function createClientFromRequest(request: Request): {
223
232
  fetchLogs(params?: Record<string, any>): Promise<any>;
224
233
  getStats(params?: Record<string, any>): Promise<any>;
225
234
  };
235
+ users: {
236
+ inviteUser(user_email: string, role: "user" | "admin"): Promise<any>;
237
+ };
226
238
  cleanup: () => void;
227
239
  };
package/dist/client.js CHANGED
@@ -3,10 +3,12 @@ import { createEntitiesModule } from "./modules/entities.js";
3
3
  import { createIntegrationsModule } from "./modules/integrations.js";
4
4
  import { createAuthModule } from "./modules/auth.js";
5
5
  import { createSsoModule } from "./modules/sso.js";
6
+ import { createConnectorsModule } from "./modules/connectors.js";
6
7
  import { getAccessToken } from "./utils/auth-utils.js";
7
8
  import { createFunctionsModule } from "./modules/functions.js";
8
9
  import { createAgentsModule } from "./modules/agents.js";
9
10
  import { createAppLogsModule } from "./modules/app-logs.js";
11
+ import { createUsersModule } from "./modules/users.js";
10
12
  import { RoomsSocket } from "./utils/socket-utils.js";
11
13
  /**
12
14
  * Create a Base44 client instance
@@ -82,6 +84,7 @@ export function createClient(config) {
82
84
  token,
83
85
  }),
84
86
  appLogs: createAppLogsModule(axiosClient, appId),
87
+ users: createUsersModule(axiosClient, appId),
85
88
  cleanup: () => {
86
89
  socket.disconnect();
87
90
  },
@@ -90,6 +93,7 @@ export function createClient(config) {
90
93
  entities: createEntitiesModule(serviceRoleAxiosClient, appId),
91
94
  integrations: createIntegrationsModule(serviceRoleAxiosClient, appId),
92
95
  sso: createSsoModule(serviceRoleAxiosClient, appId, token),
96
+ connectors: createConnectorsModule(serviceRoleAxiosClient, appId),
93
97
  functions: createFunctionsModule(serviceRoleFunctionsAxiosClient, appId),
94
98
  agents: createAgentsModule({
95
99
  axios: serviceRoleAxiosClient,
@@ -0,0 +1,16 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { ConnectorIntegrationType, ConnectorAccessTokenResponse } from "./connectors.types.js";
3
+ /**
4
+ * Creates the Connectors module for the Base44 SDK
5
+ * @param axios - Axios instance (should be service role client)
6
+ * @param appId - Application ID
7
+ * @returns Connectors module
8
+ */
9
+ export declare function createConnectorsModule(axios: AxiosInstance, appId: string): {
10
+ /**
11
+ * Retrieve an access token for a given integration type
12
+ * @param integrationType - The integration type to get access token for
13
+ * @returns Access token response
14
+ */
15
+ getAccessToken(integrationType: ConnectorIntegrationType): Promise<ConnectorAccessTokenResponse>;
16
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Creates the Connectors module for the Base44 SDK
3
+ * @param axios - Axios instance (should be service role client)
4
+ * @param appId - Application ID
5
+ * @returns Connectors module
6
+ */
7
+ export function createConnectorsModule(axios, appId) {
8
+ return {
9
+ /**
10
+ * Retrieve an access token for a given integration type
11
+ * @param integrationType - The integration type to get access token for
12
+ * @returns Access token response
13
+ */
14
+ async getAccessToken(integrationType) {
15
+ if (!integrationType || typeof integrationType !== "string") {
16
+ throw new Error("Integration type is required and must be a string");
17
+ }
18
+ const response = await axios.get(`/apps/${appId}/external-auth/tokens/${integrationType}`);
19
+ // @ts-expect-error
20
+ return response.access_token;
21
+ },
22
+ };
23
+ }
@@ -0,0 +1,4 @@
1
+ export type ConnectorIntegrationType = string;
2
+ export type ConnectorAccessTokenResponse = {
3
+ access_token: string;
4
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,3 @@
1
1
  export * from "./app.types.js";
2
2
  export * from "./agents.types.js";
3
+ export * from "./connectors.types.js";
@@ -1,2 +1,3 @@
1
1
  export * from "./app.types.js";
2
2
  export * from "./agents.types.js";
3
+ export * from "./connectors.types.js";
@@ -0,0 +1,16 @@
1
+ import { AxiosInstance } from "axios";
2
+ /**
3
+ * Creates the users module for the Base44 SDK
4
+ * @param {AxiosInstance} axios - Axios instance
5
+ * @param {string} appId - Application ID
6
+ * @returns {Object} Users module
7
+ */
8
+ export declare function createUsersModule(axios: AxiosInstance, appId: string): {
9
+ /**
10
+ * Invite a user to the application
11
+ * @param {string} user_email - User's email address
12
+ * @param {'user'|'admin'} role - User's role (user or admin)
13
+ * @returns {Promise<any>}
14
+ */
15
+ inviteUser(user_email: string, role: "user" | "admin"): Promise<any>;
16
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Creates the users module for the Base44 SDK
3
+ * @param {AxiosInstance} axios - Axios instance
4
+ * @param {string} appId - Application ID
5
+ * @returns {Object} Users module
6
+ */
7
+ export function createUsersModule(axios, appId) {
8
+ return {
9
+ /**
10
+ * Invite a user to the application
11
+ * @param {string} user_email - User's email address
12
+ * @param {'user'|'admin'} role - User's role (user or admin)
13
+ * @returns {Promise<any>}
14
+ */
15
+ async inviteUser(user_email, role) {
16
+ if (role !== "user" && role !== "admin") {
17
+ throw new Error(`Invalid role: "${role}". Role must be either "user" or "admin".`);
18
+ }
19
+ const response = await axios.post(`/apps/${appId}/runtime/users/invite-user`, { user_email, role });
20
+ return response;
21
+ },
22
+ };
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44/sdk",
3
- "version": "0.8.3",
3
+ "version": "0.8.5",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,6 +24,7 @@
24
24
  "uuid": "^13.0.0"
25
25
  },
26
26
  "devDependencies": {
27
+ "@types/node": "^25.0.1",
27
28
  "@vitest/coverage-istanbul": "^1.0.0",
28
29
  "@vitest/coverage-v8": "^1.0.0",
29
30
  "@vitest/ui": "^1.0.0",