@base44-preview/sdk 0.8.31-pr.178.f27934d → 0.8.31-pr.179.d377a1e

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.js CHANGED
@@ -9,7 +9,6 @@ import { createFunctionsModule } from "./modules/functions.js";
9
9
  import { createAgentsModule } from "./modules/agents.js";
10
10
  import { createAppLogsModule } from "./modules/app-logs.js";
11
11
  import { createUsersModule } from "./modules/users.js";
12
- import { createAccountsModule } from "./modules/accounts.js";
13
12
  import { RoomsSocket } from "./utils/socket-utils.js";
14
13
  import { createAnalyticsModule } from "./modules/analytics.js";
15
14
  /**
@@ -153,7 +152,6 @@ export function createClient(config) {
153
152
  }),
154
153
  appLogs: createAppLogsModule(axiosClient, appId),
155
154
  users: createUsersModule(axiosClient, appId),
156
- accounts: createAccountsModule(axiosClient, appId),
157
155
  analytics: createAnalyticsModule({
158
156
  axiosClient,
159
157
  serverUrl,
@@ -7,7 +7,6 @@ import type { FunctionsModule } from "./modules/functions.types.js";
7
7
  import type { AgentsModule } from "./modules/agents.types.js";
8
8
  import type { AppLogsModule } from "./modules/app-logs.types.js";
9
9
  import type { AnalyticsModule } from "./modules/analytics.types.js";
10
- import type { AccountsModule } from "./modules/accounts.types.js";
11
10
  /**
12
11
  * Options for creating a Base44 client.
13
12
  */
@@ -80,8 +79,6 @@ export interface CreateClientConfig {
80
79
  * Provides access to all SDK modules for interacting with the app.
81
80
  */
82
81
  export interface Base44Client {
83
- /** {@link AccountsModule | Accounts module} for multi-tenancy (accounts, members, billing). */
84
- accounts: AccountsModule;
85
82
  /** {@link AgentsModule | Agents module} for managing AI agent conversations. */
86
83
  agents: AgentsModule;
87
84
  /** {@link AnalyticsModule | Analytics module} for tracking custom events in your app. */
package/dist/index.d.ts CHANGED
@@ -10,7 +10,6 @@ export type { IntegrationsModule, IntegrationEndpointFunction, CoreIntegrations,
10
10
  export type { FunctionsModule, FunctionName, FunctionNameRegistry, } from "./modules/functions.types.js";
11
11
  export type { AgentsModule, AgentName, AgentNameRegistry, AgentConversation, AgentMessage, AgentMessageReasoning, AgentMessageToolCall, AgentMessageUsage, AgentMessageCustomContext, AgentMessageMetadata, CreateConversationParams, } from "./modules/agents.types.js";
12
12
  export type { AppLogsModule } from "./modules/app-logs.types.js";
13
- export type { AccountsModule, Account, AccountMembership, AccountPlan, AccountRole, AssignableAccountRole, AccountStatus, AccountMembershipStatus, MyAccountsResponse, CheckoutSession, } from "./modules/accounts.types.js";
14
13
  export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
15
14
  export type { ConnectorsModule, UserConnectorsModule, } from "./modules/connectors.types.js";
16
15
  export type { CustomIntegrationsModule, CustomIntegrationCallParams, CustomIntegrationCallResponse, } from "./modules/custom-integrations.types.js";
@@ -1,5 +1,5 @@
1
1
  import axios from "axios";
2
- import { getActiveAccountIdFromPath, isInIFrame } from "./common.js";
2
+ import { isInIFrame } from "./common.js";
3
3
  import { v4 as uuidv4 } from "uuid";
4
4
  /**
5
5
  * Custom error class for Base44 SDK errors.
@@ -131,15 +131,6 @@ export function createAxiosClient({ baseURL, headers = {}, token, interceptRespo
131
131
  client.interceptors.request.use((config) => {
132
132
  if (typeof window !== "undefined") {
133
133
  config.headers.set("X-Origin-URL", window.location.href);
134
- // Multi-tenancy: forward the active account (from the URL path) per request
135
- // so account-scoped reads/writes stay isolated to the current tenant even
136
- // after a client-side account switch. The path is the canonical source, so
137
- // it overrides any stale default header (e.g. one frozen at module load);
138
- // no-op for single-tenant apps (no account segment in the path).
139
- const activeAccountId = getActiveAccountIdFromPath();
140
- if (activeAccountId) {
141
- config.headers.set("X-Active-Account-Id", activeAccountId);
142
- }
143
134
  }
144
135
  const requestId = uuidv4();
145
136
  config.requestId = requestId;
@@ -1,4 +1,3 @@
1
1
  export declare const isNode: boolean;
2
2
  export declare const isInIFrame: boolean;
3
- export declare function getActiveAccountIdFromPath(): string | undefined;
4
3
  export declare const generateUuid: () => string;
@@ -1,18 +1,5 @@
1
1
  export const isNode = typeof window === "undefined";
2
2
  export const isInIFrame = !isNode && window.self !== window.top;
3
- // Multi-tenancy: apps are served under `/<account_id>/<route>` where the first
4
- // path segment is a 24-hex Mongo ObjectId. Read it at request time so the active
5
- // account is always current — even after client-side (Link/useNavigate) account
6
- // switches that don't reload the module.
7
- const ACCOUNT_ID_RE = /^[a-f0-9]{24}$/;
8
- export function getActiveAccountIdFromPath() {
9
- if (isNode)
10
- return undefined;
11
- const firstSegment = window.location.pathname.split("/").filter(Boolean)[0];
12
- return firstSegment && ACCOUNT_ID_RE.test(firstSegment)
13
- ? firstSegment
14
- : undefined;
15
- }
16
3
  export const generateUuid = () => {
17
4
  return (Math.random().toString(36).substring(2, 15) +
18
5
  Math.random().toString(36).substring(2, 15));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.31-pr.178.f27934d",
3
+ "version": "0.8.31-pr.179.d377a1e",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -26,9 +26,9 @@
26
26
  "create-docs:process": "node scripts/mintlify-post-processing/file-processing/file-processing.js"
27
27
  },
28
28
  "dependencies": {
29
- "axios": "^1.6.2",
30
- "socket.io-client": "^4.7.5",
31
- "uuid": "^13.0.0"
29
+ "axios": "^1.15.2",
30
+ "socket.io-client": "^4.8.3",
31
+ "uuid": "^13.0.2"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/hast": "^3.0.4",
@@ -1,11 +0,0 @@
1
- import { AxiosInstance } from "axios";
2
- import type { AccountsModule } from "./accounts.types.js";
3
- /**
4
- * Creates the accounts module (multi-tenancy) for the Base44 SDK.
5
- *
6
- * @param axios - Axios instance (responses are unwrapped to data).
7
- * @param appId - Application ID.
8
- * @returns The accounts module.
9
- * @internal
10
- */
11
- export declare function createAccountsModule(axios: AxiosInstance, appId: string): AccountsModule;
@@ -1,61 +0,0 @@
1
- import { getActiveAccountIdFromPath } from "../utils/common.js";
2
- /**
3
- * Creates the accounts module (multi-tenancy) for the Base44 SDK.
4
- *
5
- * @param axios - Axios instance (responses are unwrapped to data).
6
- * @param appId - Application ID.
7
- * @returns The accounts module.
8
- * @internal
9
- */
10
- export function createAccountsModule(axios, appId) {
11
- const base = `/apps/${appId}/accounts`;
12
- const enc = encodeURIComponent;
13
- return {
14
- getActiveAccountId() {
15
- return getActiveAccountIdFromPath();
16
- },
17
- switchAccount(accountId, subPath = "") {
18
- if (typeof window === "undefined")
19
- return;
20
- const clean = subPath.replace(/^\/+/, "");
21
- window.location.assign(`/${accountId}${clean ? `/${clean}` : "/"}`);
22
- },
23
- async listMine() {
24
- return axios.get(`${base}/me`);
25
- },
26
- async create(params) {
27
- return axios.post(base, params);
28
- },
29
- async update(accountId, params) {
30
- return axios.patch(`${base}/${accountId}`, params);
31
- },
32
- async listMembers(accountId) {
33
- return axios.get(`${base}/${accountId}/members`);
34
- },
35
- async invite(accountId, email, role = "member") {
36
- return axios.post(`${base}/${accountId}/invites`, { email, role });
37
- },
38
- async acceptInvite(accountId) {
39
- return axios.post(`${base}/${accountId}/accept`, {});
40
- },
41
- async changeMemberRole(accountId, email, role) {
42
- return axios.patch(`${base}/${accountId}/members/${enc(email)}/role`, {
43
- role,
44
- });
45
- },
46
- async removeMember(accountId, email) {
47
- return axios.delete(`${base}/${accountId}/members/${enc(email)}`);
48
- },
49
- async transferOwnership(accountId, email) {
50
- return axios.post(`${base}/${accountId}/transfer-ownership`, { email });
51
- },
52
- billing: {
53
- async listPlans(accountId) {
54
- return axios.get(`${base}/${accountId}/billing/plans`);
55
- },
56
- async startCheckout(accountId, params) {
57
- return axios.post(`${base}/${accountId}/billing/checkout`, params);
58
- },
59
- },
60
- };
61
- }
@@ -1,112 +0,0 @@
1
- /**
2
- * Types for the {@link AccountsModule | accounts} module (multi-tenancy).
3
- *
4
- * An Account groups the app's end-users into an isolated tenant (a company,
5
- * team, or organization). Users join accounts via membership and act inside one
6
- * active account at a time. Account-scoped entities are transparently isolated
7
- * to the active account (carried by the `X-Active-Account-Id` header, derived
8
- * from the `/<account_id>/...` URL path).
9
- */
10
- /** Account-management role. Distinct from the app's business roles. */
11
- export type AccountRole = "owner" | "admin" | "member";
12
- /** Assignable (non-owner) role used for invites/role changes. */
13
- export type AssignableAccountRole = "admin" | "member";
14
- export type AccountStatus = "active" | "suspended";
15
- export type AccountMembershipStatus = "pending" | "active";
16
- /** An account (tenant) within the app. */
17
- export interface Account {
18
- id: string;
19
- app_id: string;
20
- name: string;
21
- status: AccountStatus;
22
- plan_id?: string | null;
23
- billing_status?: string;
24
- /** The current user's role in this account (present on `listMine()` results). */
25
- my_role?: AccountRole;
26
- /** Builder-defined custom fields. */
27
- data?: Record<string, unknown>;
28
- created_date?: string;
29
- }
30
- /** The accounts the current user belongs to, plus the active one. */
31
- export interface MyAccountsResponse {
32
- accounts: Account[];
33
- active_account_id: string | null;
34
- }
35
- /** A user's membership in an account. */
36
- export interface AccountMembership {
37
- id: string;
38
- account_id: string;
39
- email: string;
40
- role: AccountRole;
41
- status: AccountMembershipStatus;
42
- }
43
- /** A subscription plan/tier offered to accounts. */
44
- export interface AccountPlan {
45
- id: string;
46
- name: string;
47
- description?: string | null;
48
- price_amount: number;
49
- currency: string;
50
- interval: "month" | "year";
51
- is_active: boolean;
52
- }
53
- /** A provider checkout session. */
54
- export interface CheckoutSession {
55
- url: string;
56
- session_id: string;
57
- }
58
- /**
59
- * The accounts module — manage multi-tenancy ("Accounts") from inside the app.
60
- *
61
- * Access via `base44.accounts`. Available when the app has multi-tenancy enabled.
62
- */
63
- export interface AccountsModule {
64
- /** The active account id, read from the current URL path (or `undefined`). */
65
- getActiveAccountId(): string | undefined;
66
- /**
67
- * Switch the active account by navigating to its folder (`/<accountId>/...`).
68
- * A full navigation re-roots the app so all data follows the new account.
69
- * @param accountId - The account to switch to.
70
- * @param subPath - Optional in-account route to land on (defaults to the root).
71
- */
72
- switchAccount(accountId: string, subPath?: string): void;
73
- /** List the accounts the current user belongs to, plus the active one. */
74
- listMine(): Promise<MyAccountsResponse>;
75
- /** Create a new account; the current user becomes its owner. */
76
- create(params: {
77
- name: string;
78
- data?: Record<string, unknown>;
79
- }): Promise<Account>;
80
- /** Rename and/or update an account's custom fields (managers only). */
81
- update(accountId: string, params: {
82
- name?: string;
83
- data?: Record<string, unknown>;
84
- }): Promise<Account>;
85
- /** List an account's members (any active member). */
86
- listMembers(accountId: string): Promise<AccountMembership[]>;
87
- /** Invite a user by email to an account (managers only). */
88
- invite(accountId: string, email: string, role?: AssignableAccountRole): Promise<AccountMembership>;
89
- /** Accept a pending invite to an account for the current user. */
90
- acceptInvite(accountId: string): Promise<AccountMembership>;
91
- /** Change a member's role (managers only; not for the owner). */
92
- changeMemberRole(accountId: string, email: string, role: AssignableAccountRole): Promise<AccountMembership>;
93
- /** Remove a member from an account (managers only; not the owner). */
94
- removeMember(accountId: string, email: string): Promise<{
95
- removed: boolean;
96
- }>;
97
- /** Transfer ownership to another active member (owner only). */
98
- transferOwnership(accountId: string, email: string): Promise<{
99
- transferred: boolean;
100
- }>;
101
- /** Per-account billing. */
102
- billing: {
103
- /** List the active plans available to this account. */
104
- listPlans(accountId: string): Promise<AccountPlan[]>;
105
- /** Start a subscription checkout session for a plan. */
106
- startCheckout(accountId: string, params: {
107
- plan_id: string;
108
- success_url: string;
109
- cancel_url: string;
110
- }): Promise<CheckoutSession>;
111
- };
112
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Types for the {@link AccountsModule | accounts} module (multi-tenancy).
3
- *
4
- * An Account groups the app's end-users into an isolated tenant (a company,
5
- * team, or organization). Users join accounts via membership and act inside one
6
- * active account at a time. Account-scoped entities are transparently isolated
7
- * to the active account (carried by the `X-Active-Account-Id` header, derived
8
- * from the `/<account_id>/...` URL path).
9
- */
10
- export {};