@base44-preview/sdk 0.8.57-pr.362.2ee7c13 → 0.8.58-beta.0-pr.363.7ab0486

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.
@@ -193,8 +193,8 @@ export interface AgentsModuleConfig {
193
193
  *
194
194
  * This module is available to use with a client in all authentication modes:
195
195
  *
196
- * - **Anonymous or User authentication** (`base44.agents`): Access is scoped to the current user's permissions. Users must be authenticated to create and access conversations. Each user can read and add messages only to conversations they created, even if they have the admin role.
197
- * - **Service role authentication** (`base44.asServiceRole.agents`): Operations are invoked with the service role for backend code that needs elevated permissions. This module only reaches conversations created through the service role, so it doesn't give your backend access to conversations that individual users created.
196
+ * - **Anonymous or User authentication** (`base44.agents`): Access is scoped to the current user's permissions. Users must be authenticated to create and access conversations.
197
+ * - **Service role authentication** (`base44.asServiceRole.agents`): Operations are invoked with the service role for backend code that needs elevated permissions.
198
198
  *
199
199
  * ## Generated Types
200
200
  *
@@ -202,15 +202,15 @@ export interface AgentsModuleConfig {
202
202
  */
203
203
  export interface AgentsModule {
204
204
  /**
205
- * Gets the current user's conversations with all agents in the app.
205
+ * Gets all conversations from all agents in the app.
206
206
  *
207
- * Retrieves every conversation the current user started, across all agents. Conversations that other users started aren't included, even if the current user has the admin role. When you call this method through `base44.asServiceRole.agents`, it returns only the conversations created through the service role, not the conversations that your users created. Use {@linkcode listConversations | listConversations()} to filter which conversations are returned, apply sorting, or paginate results. Use {@linkcode getConversation | getConversation()} to retrieve a specific conversation by ID.
207
+ * Retrieves all conversations. Use {@linkcode listConversations | listConversations()} to filter which conversations are returned, apply sorting, or paginate results. Use {@linkcode getConversation | getConversation()} to retrieve a specific conversation by ID.
208
208
  *
209
209
  * @returns Promise resolving to an array of conversations.
210
210
  *
211
211
  * @example
212
212
  * ```typescript
213
- * // Get the current user's conversations
213
+ * // Get all conversations
214
214
  * const conversations = await base44.agents.getConversations();
215
215
  * console.log(`Total conversations: ${conversations.length}`);
216
216
  * ```
@@ -222,13 +222,13 @@ export interface AgentsModule {
222
222
  /**
223
223
  * Gets a specific conversation by ID.
224
224
  *
225
- * Retrieves a single conversation using its unique identifier. The conversation must belong to the current user. If another user created it, the request fails with a `403` error. If no conversation has that ID, the request fails with a `404` error. To retrieve
226
- * all of the current user's conversations, use {@linkcode getConversations | getConversations()}. To filter, sort, or paginate conversations, use {@linkcode listConversations | listConversations()}.
225
+ * Retrieves a single conversation using its unique identifier. To retrieve
226
+ * all conversations, use {@linkcode getConversations | getConversations()}. To filter, sort, or paginate conversations, use {@linkcode listConversations | listConversations()}.
227
227
  *
228
228
  * This function returns the complete stored conversation including full tool call results, even for large responses.
229
229
  *
230
230
  * @param conversationId - The unique identifier of the conversation.
231
- * @returns Promise resolving to the conversation.
231
+ * @returns Promise resolving to the conversation, or undefined if not found.
232
232
  *
233
233
  * @example
234
234
  * ```typescript
@@ -239,14 +239,14 @@ export interface AgentsModule {
239
239
  * }
240
240
  * ```
241
241
  *
242
- * @see {@linkcode getConversations | getConversations()} for retrieving all of the current user's conversations
242
+ * @see {@linkcode getConversations | getConversations()} for retrieving all conversations
243
243
  * @see {@linkcode listConversations | listConversations()} for filtering and sorting conversations
244
244
  */
245
245
  getConversation(conversationId: string): Promise<AgentConversation | undefined>;
246
246
  /**
247
- * Lists the current user's conversations with filtering, sorting, and pagination.
247
+ * Lists conversations with filtering, sorting, and pagination.
248
248
  *
249
- * Provides querying capabilities including filtering by fields, sorting, pagination, and field selection. Results only include conversations the current user created, even if `q` filters on a different `created_by_id`. When you call this method through `base44.asServiceRole.agents`, results only include conversations created through the service role. For cases where you need all of the current user's conversations without filtering, use {@linkcode getConversations | getConversations()}. To retrieve a specific conversation by ID, use {@linkcode getConversation | getConversation()}.
249
+ * Provides querying capabilities including filtering by fields, sorting, pagination, and field selection. For cases where you need all conversations without filtering, use {@linkcode getConversations | getConversations()}. To retrieve a specific conversation by ID, use {@linkcode getConversation | getConversation()}.
250
250
  *
251
251
  * @param filterParams - Filter parameters for querying conversations.
252
252
  * @returns Promise resolving to an array of filtered conversations.
@@ -273,15 +273,13 @@ export interface AgentsModule {
273
273
  * });
274
274
  * ```
275
275
  *
276
- * @see {@linkcode getConversations | getConversations()} for retrieving all of the current user's conversations without filtering
276
+ * @see {@linkcode getConversations | getConversations()} for retrieving all conversations without filtering
277
277
  * @see {@linkcode getConversation | getConversation()} for retrieving a specific conversation by ID
278
278
  */
279
279
  listConversations(filterParams: ModelFilterParams): Promise<AgentConversation[]>;
280
280
  /**
281
281
  * Creates a new conversation with an agent.
282
282
  *
283
- * The conversation belongs to the current user. Only that user can read it or add messages to it.
284
- *
285
283
  * @param conversation - Conversation details including agent name and optional metadata.
286
284
  * @returns Promise resolving to the created conversation.
287
285
  *
@@ -303,7 +301,7 @@ export interface AgentsModule {
303
301
  /**
304
302
  * Adds a message to a conversation.
305
303
  *
306
- * Sends a message to the agent and updates the conversation. You can only add messages to conversations the current user created. This method
304
+ * Sends a message to the agent and updates the conversation. This method
307
305
  * also updates the realtime socket to notify any subscribers.
308
306
  *
309
307
  * @param conversation - The conversation to add the message to.
@@ -325,7 +323,7 @@ export interface AgentsModule {
325
323
  * Subscribes to realtime updates for a conversation.
326
324
  *
327
325
  * Establishes a WebSocket connection to receive instant updates when new
328
- * messages are added to the conversation. You can only subscribe to conversations the current user created. Returns an unsubscribe function
326
+ * messages are added to the conversation. Returns an unsubscribe function
329
327
  * to clean up the connection.
330
328
  *
331
329
  * <Note>
@@ -6,6 +6,9 @@ export declare const ANALYTICS_INITIALIZATION_EVENT_NAME = "__initialization_eve
6
6
  export declare const ANALYTICS_SESSION_DURATION_EVENT_NAME = "__session_duration_event__";
7
7
  export declare const ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY = "analytics-enable";
8
8
  export declare const ANALYTICS_SESSION_ID_LOCAL_STORAGE_KEY = "base44_analytics_session_id";
9
+ export declare const ANALYTICS_DENIED_LOCAL_STORAGE_KEY = "base44_analytics_denied";
10
+ /** Whether a page in this mode may track before any consent signal. */
11
+ export declare function initialConsentGranted(mode: string | null): boolean;
9
12
  export declare const ANALYTICS_MODE_META_NAME = "base44-analytics";
10
13
  /** Whether analytics may run and store the session id on this page. */
11
14
  export declare function isAnalyticsAllowed(): boolean;
@@ -5,6 +5,37 @@ export const ANALYTICS_INITIALIZATION_EVENT_NAME = "__initialization_event__";
5
5
  export const ANALYTICS_SESSION_DURATION_EVENT_NAME = "__session_duration_event__";
6
6
  export const ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY = "analytics-enable";
7
7
  export const ANALYTICS_SESSION_ID_LOCAL_STORAGE_KEY = "base44_analytics_session_id";
8
+ // Remembers a visitor's Decline across pages. On "on" pages the SDK starts
9
+ // before the app's banner replays the saved choice, so without it each new
10
+ // page would store the id and send one batch before the denial arrives.
11
+ export const ANALYTICS_DENIED_LOCAL_STORAGE_KEY = "base44_analytics_denied";
12
+ function readAnalyticsDenied() {
13
+ try {
14
+ return localStorage.getItem(ANALYTICS_DENIED_LOCAL_STORAGE_KEY) === "1";
15
+ }
16
+ catch (_a) {
17
+ return false;
18
+ }
19
+ }
20
+ function writeAnalyticsDenied(denied) {
21
+ try {
22
+ if (denied)
23
+ localStorage.setItem(ANALYTICS_DENIED_LOCAL_STORAGE_KEY, "1");
24
+ else
25
+ localStorage.removeItem(ANALYTICS_DENIED_LOCAL_STORAGE_KEY);
26
+ }
27
+ catch (_a) {
28
+ // storage unavailable: the banner's replay still stops tracking
29
+ }
30
+ }
31
+ /** Whether a page in this mode may track before any consent signal. */
32
+ export function initialConsentGranted(mode) {
33
+ if (mode === "consent")
34
+ return false;
35
+ if (mode === "on")
36
+ return !readAnalyticsDenied();
37
+ return true;
38
+ }
8
39
  // Set by the Base44 server from the app owner's choice: "off" never tracks,
9
40
  // "consent" waits for the page's Google Consent Mode `analytics_storage` grant,
10
41
  // "on" tracks until that consent is denied. Absent: track as before.
@@ -61,7 +92,7 @@ const consentSharedState = getSharedInstance("analytics-consent", () => {
61
92
  return {
62
93
  analyticsMode,
63
94
  // Whether the visitor may be tracked and the session id stored.
64
- consentGranted: analyticsMode !== "consent",
95
+ consentGranted: initialConsentGranted(analyticsMode),
65
96
  isWatchingConsent: false,
66
97
  listeners: [],
67
98
  };
@@ -73,6 +104,7 @@ export function isAnalyticsAllowed() {
73
104
  }
74
105
  function setConsentGranted(granted) {
75
106
  var _a;
107
+ writeAnalyticsDenied(!granted);
76
108
  if (consentSharedState.consentGranted === granted)
77
109
  return;
78
110
  consentSharedState.consentGranted = granted;
@@ -45,7 +45,7 @@ export interface DeleteManyResult {
45
45
  export interface UpdateManyResult {
46
46
  /** Whether the operation was successful. */
47
47
  success: boolean;
48
- /** Number of entities that were updated. This includes records that already held the new values, because every update refreshes `updated_date`. */
48
+ /** Number of entities that were updated. */
49
49
  updated: number;
50
50
  /** Whether there are more entities matching the query that were not updated in this batch. When `true`, call `updateMany` again with the same query to update the next batch. */
51
51
  has_more: boolean;
@@ -777,8 +777,6 @@ export interface EntityHandler<T = any> {
777
777
  * records first and then updates them. Learn more about
778
778
  * [concurrent updates](/developers/backend/resources/entities/entity-schemas#concurrent-updates).
779
779
  *
780
- * This method isn't available for the built-in `User` entity, and calling it fails with a 405 error.
781
- *
782
780
  * To update a single record by ID, use {@linkcode update | update()} instead. To update
783
781
  * multiple specific records with different data each, use {@linkcode bulkUpdate | bulkUpdate()}.
784
782
  *
@@ -1019,13 +1017,8 @@ export interface EntityHandler<T = any> {
1019
1017
  *
1020
1018
  * You can update up to 500 records per request.
1021
1019
  *
1022
- * This method isn't available for the built-in `User` entity, and calling it fails with a 405 error.
1023
- *
1024
- * This isn't a transaction. Before writing, the call checks every record. If an `id`
1025
- * doesn't match a record you can update, or a change isn't allowed or doesn't match the
1026
- * entity's schema, the call fails and no records change. After the checks pass, each
1027
- * record is written on its own, so if a write fails partway, the records already written
1028
- * stay written. Learn more about
1020
+ * This isn't a transaction. Each record is written on its own, so if the call
1021
+ * fails partway, the records already written stay written. Learn more about
1029
1022
  * [concurrent updates](/developers/backend/resources/entities/entity-schemas#concurrent-updates).
1030
1023
  *
1031
1024
  * To apply the same update to all records matching a query, use
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.57-pr.362.2ee7c13",
3
+ "version": "0.8.58-beta.0-pr.363.7ab0486",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",