@base44-preview/sdk 0.8.44-pr.268.b6fd238 → 0.8.46-pr.272.2f95f82
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/actor.d.ts +7 -7
- package/dist/actor.js +6 -6
- package/dist/client.d.ts +2 -2
- package/dist/client.js +5 -4
- package/dist/client.types.d.ts +23 -2
- package/dist/index.d.ts +2 -2
- package/dist/modules/actors.d.ts +1 -1
- package/dist/modules/actors.js +5 -5
- package/dist/modules/actors.types.d.ts +6 -6
- package/dist/modules/analytics.d.ts +2 -1
- package/dist/modules/analytics.js +4 -4
- package/dist/modules/app.types.d.ts +4 -4
- package/dist/modules/auth.js +1 -1
- package/dist/modules/auth.types.d.ts +2 -2
- package/dist/modules/connectors.js +2 -2
- package/dist/modules/connectors.types.d.ts +4 -4
- package/dist/modules/entities.js +1 -1
- package/dist/utils/common.js +1 -1
- package/package.json +1 -1
package/dist/actor.d.ts
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
* export class MyActor extends Actor { ... }
|
|
7
7
|
*
|
|
8
8
|
* At deploy time the bundler replaces this import with the compiled
|
|
9
|
-
* Cloudflare Durable Object implementation
|
|
9
|
+
* Cloudflare Durable Object implementation. This file provides types only.
|
|
10
10
|
*/
|
|
11
11
|
import type { Base44Client } from "./client";
|
|
12
12
|
/**
|
|
13
13
|
* A single client connection. `Send` is the message type this connection accepts
|
|
14
|
-
* via {@link send}
|
|
14
|
+
* via {@link send}, the actor's *outgoing* (server→client) messages.
|
|
15
15
|
*/
|
|
16
16
|
export interface Conn<Send = unknown> {
|
|
17
17
|
/** Unique per-connection id (one per socket/tab), the same value the client
|
|
@@ -33,9 +33,9 @@ export interface Storage {
|
|
|
33
33
|
* Base class for an Actor.
|
|
34
34
|
*
|
|
35
35
|
* @typeParam Incoming - messages this actor *receives* from clients
|
|
36
|
-
* (`handleMessage`'s `msg`)
|
|
36
|
+
* (`handleMessage`'s `msg`), the schema's `toServer` section.
|
|
37
37
|
* @typeParam Outgoing - messages this actor *sends* to clients
|
|
38
|
-
* (`conn.send`/`broadcast`)
|
|
38
|
+
* (`conn.send`/`broadcast`), the schema's `toClient` section.
|
|
39
39
|
*
|
|
40
40
|
* With a generated `schema.jsonc`, wire both from the registry so they can't drift
|
|
41
41
|
* from the client's types:
|
|
@@ -51,7 +51,7 @@ export declare abstract class Actor<Incoming = unknown, Outgoing = unknown> {
|
|
|
51
51
|
abstract handleTick(): void | Promise<void>;
|
|
52
52
|
/**
|
|
53
53
|
* Optional wake hook: runs once when the instance starts, before any
|
|
54
|
-
* connection is handled
|
|
54
|
+
* connection is handled. Safe to load persisted state here.
|
|
55
55
|
*/
|
|
56
56
|
handleStart(): void | Promise<void>;
|
|
57
57
|
/**
|
|
@@ -71,7 +71,7 @@ export declare abstract class Actor<Incoming = unknown, Outgoing = unknown> {
|
|
|
71
71
|
/**
|
|
72
72
|
* Managed ticker (opt-in). Override {@link shouldTick} and the platform runs
|
|
73
73
|
* {@link handleTick} on a timer of {@link tickIntervalMs} while it returns true,
|
|
74
|
-
* and stops (letting the Durable Object hibernate
|
|
74
|
+
* and stops (letting the Durable Object hibernate at no compute cost) when it
|
|
75
75
|
* returns false. The platform owns scheduling, rescheduling, self-heal, and
|
|
76
76
|
* error-safety.
|
|
77
77
|
*
|
|
@@ -85,7 +85,7 @@ export declare abstract class Actor<Incoming = unknown, Outgoing = unknown> {
|
|
|
85
85
|
protected get instanceId(): string;
|
|
86
86
|
protected get storage(): Storage;
|
|
87
87
|
/**
|
|
88
|
-
* Anonymous Base44 client scoped to this actor instance
|
|
88
|
+
* Anonymous Base44 client scoped to this actor instance, with no user or service
|
|
89
89
|
* auth, so entity access is RLS-gated (same as a logged-out visitor). Always
|
|
90
90
|
* operates on production data: an actor runs server-side with no per-connection
|
|
91
91
|
* identity, so a Test DB preview selected in the editor does not apply here.
|
package/dist/actor.js
CHANGED
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
* export class MyActor extends Actor { ... }
|
|
7
7
|
*
|
|
8
8
|
* At deploy time the bundler replaces this import with the compiled
|
|
9
|
-
* Cloudflare Durable Object implementation
|
|
9
|
+
* Cloudflare Durable Object implementation. This file provides types only.
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
12
12
|
* Base class for an Actor.
|
|
13
13
|
*
|
|
14
14
|
* @typeParam Incoming - messages this actor *receives* from clients
|
|
15
|
-
* (`handleMessage`'s `msg`)
|
|
15
|
+
* (`handleMessage`'s `msg`), the schema's `toServer` section.
|
|
16
16
|
* @typeParam Outgoing - messages this actor *sends* to clients
|
|
17
|
-
* (`conn.send`/`broadcast`)
|
|
17
|
+
* (`conn.send`/`broadcast`), the schema's `toClient` section.
|
|
18
18
|
*
|
|
19
19
|
* With a generated `schema.jsonc`, wire both from the registry so they can't drift
|
|
20
20
|
* from the client's types:
|
|
@@ -28,7 +28,7 @@ export class Actor {
|
|
|
28
28
|
/**
|
|
29
29
|
* Managed ticker (opt-in). Override {@link shouldTick} and the platform runs
|
|
30
30
|
* {@link handleTick} on a timer of {@link tickIntervalMs} while it returns true,
|
|
31
|
-
* and stops (letting the Durable Object hibernate
|
|
31
|
+
* and stops (letting the Durable Object hibernate at no compute cost) when it
|
|
32
32
|
* returns false. The platform owns scheduling, rescheduling, self-heal, and
|
|
33
33
|
* error-safety.
|
|
34
34
|
*
|
|
@@ -39,7 +39,7 @@ export class Actor {
|
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Optional wake hook: runs once when the instance starts, before any
|
|
42
|
-
* connection is handled
|
|
42
|
+
* connection is handled. Safe to load persisted state here.
|
|
43
43
|
*/
|
|
44
44
|
handleStart() { }
|
|
45
45
|
/**
|
|
@@ -73,7 +73,7 @@ export class Actor {
|
|
|
73
73
|
throw new Error("Actor.storage is only available inside a deployed actor");
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
|
-
* Anonymous Base44 client scoped to this actor instance
|
|
76
|
+
* Anonymous Base44 client scoped to this actor instance, with no user or service
|
|
77
77
|
* auth, so entity access is RLS-gated (same as a logged-out visitor). Always
|
|
78
78
|
* operates on production data: an actor runs server-side with no per-connection
|
|
79
79
|
* identity, so a Test DB preview selected in the editor does not apply here.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Base44Client, CreateClientConfig, CreateClientOptions } from "./client.types.js";
|
|
2
|
-
export type { Base44Client, CreateClientConfig, CreateClientOptions };
|
|
1
|
+
import type { Base44Client, CreateClientAnalyticsConfig, CreateClientConfig, CreateClientOptions } from "./client.types.js";
|
|
2
|
+
export type { Base44Client, CreateClientAnalyticsConfig, CreateClientConfig, CreateClientOptions, };
|
|
3
3
|
/**
|
|
4
4
|
* Creates a Base44 client.
|
|
5
5
|
*
|
package/dist/client.js
CHANGED
|
@@ -52,8 +52,8 @@ import { createActorsModule, resolveActorsHost, } from "./modules/actors.js";
|
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
54
|
export function createClient(config) {
|
|
55
|
-
var _a, _b, _c;
|
|
56
|
-
const { serverUrl = "https://base44.app", appId, token, serviceToken, requiresAuth = false, appBaseUrl, options, functionsVersion, headers: optionalHeaders, } = config;
|
|
55
|
+
var _a, _b, _c, _d;
|
|
56
|
+
const { serverUrl = "https://base44.app", appId, analytics, token, serviceToken, requiresAuth = false, appBaseUrl, options, functionsVersion, headers: optionalHeaders, } = config;
|
|
57
57
|
// Normalize appBaseUrl to always be a string (empty if not provided or invalid)
|
|
58
58
|
const normalizedAppBaseUrl = typeof appBaseUrl === "string" ? appBaseUrl : "";
|
|
59
59
|
const socketConfig = {
|
|
@@ -113,7 +113,7 @@ export function createClient(config) {
|
|
|
113
113
|
});
|
|
114
114
|
// Dedicated client for actor connection-token mints: no onError (a legacy
|
|
115
115
|
// actor answers every mint with an expected 409 before the proxy fallback,
|
|
116
|
-
// which must not reach the app's error handler
|
|
116
|
+
// which must not reach the app's error handler. The actors module forwards
|
|
117
117
|
// genuine failures itself via onMintError) and no constructor token
|
|
118
118
|
// (auth is per-request so a login/logout is picked up on every reconnect).
|
|
119
119
|
const actorsAxiosClient = createAxiosClient({
|
|
@@ -195,6 +195,7 @@ export function createClient(config) {
|
|
|
195
195
|
serverUrl,
|
|
196
196
|
appId,
|
|
197
197
|
userAuthModule,
|
|
198
|
+
enabled: (_c = analytics === null || analytics === void 0 ? void 0 : analytics.enabled) !== null && _c !== void 0 ? _c : true,
|
|
198
199
|
}),
|
|
199
200
|
actors: actorsModule.module,
|
|
200
201
|
cleanup: () => {
|
|
@@ -223,7 +224,7 @@ export function createClient(config) {
|
|
|
223
224
|
}
|
|
224
225
|
return headers;
|
|
225
226
|
},
|
|
226
|
-
baseURL: (
|
|
227
|
+
baseURL: (_d = serviceRoleFunctionsAxiosClient.defaults) === null || _d === void 0 ? void 0 : _d.baseURL,
|
|
227
228
|
}),
|
|
228
229
|
agents: createAgentsModule({
|
|
229
230
|
axios: serviceRoleAxiosClient,
|
package/dist/client.types.d.ts
CHANGED
|
@@ -18,19 +18,34 @@ export interface CreateClientOptions {
|
|
|
18
18
|
* Optional error handler that will be called whenever an API error occurs.
|
|
19
19
|
*
|
|
20
20
|
* Also receives {@link ActorsModule | actors} connection failures. Errors
|
|
21
|
-
* are usually {@linkcode Base44Error} instances
|
|
21
|
+
* are usually {@linkcode Base44Error} instances, so check `error.status`.
|
|
22
22
|
*/
|
|
23
23
|
onError?: (error: Error) => void;
|
|
24
24
|
/**
|
|
25
25
|
* Forces the actors transport. `"auto"` (default) connects directly to the
|
|
26
26
|
* actor and falls back to the platform proxy when the app's actors don't
|
|
27
27
|
* support direct connections; `"proxy"` always uses the platform proxy
|
|
28
|
-
* (ops rollback
|
|
28
|
+
* (ops rollback, with no connection-token calls); `"direct"` disables the
|
|
29
29
|
* fallback (validation environments).
|
|
30
30
|
* @internal
|
|
31
31
|
*/
|
|
32
32
|
actorsTransport?: "auto" | "proxy" | "direct";
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for the SDK's app analytics module.
|
|
36
|
+
*/
|
|
37
|
+
export interface CreateClientAnalyticsConfig {
|
|
38
|
+
/**
|
|
39
|
+
* Whether app analytics is enabled for this client.
|
|
40
|
+
*
|
|
41
|
+
* When disabled, automatic analytics and calls to `analytics.track()` are
|
|
42
|
+
* no-ops. The SDK does not create an analytics session identifier, start
|
|
43
|
+
* heartbeat timers, or send analytics requests.
|
|
44
|
+
*
|
|
45
|
+
* @defaultValue `true`
|
|
46
|
+
*/
|
|
47
|
+
enabled: boolean;
|
|
48
|
+
}
|
|
34
49
|
/**
|
|
35
50
|
* Configuration for creating a Base44 client.
|
|
36
51
|
*/
|
|
@@ -57,6 +72,12 @@ export interface CreateClientConfig {
|
|
|
57
72
|
* It's the string between `/apps/` and `/editor/`.
|
|
58
73
|
*/
|
|
59
74
|
appId: string;
|
|
75
|
+
/**
|
|
76
|
+
* Controls app analytics for this client.
|
|
77
|
+
*
|
|
78
|
+
* Omit this option to preserve the default analytics behavior.
|
|
79
|
+
*/
|
|
80
|
+
analytics?: CreateClientAnalyticsConfig;
|
|
60
81
|
/**
|
|
61
82
|
* User authentication token. Used to authenticate as a specific user.
|
|
62
83
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createClient, createClientFromRequest, type Base44Client, type CreateClientConfig, type CreateClientOptions } from "./client.js";
|
|
1
|
+
import { createClient, createClientFromRequest, type Base44Client, type CreateClientAnalyticsConfig, type CreateClientConfig, type CreateClientOptions } from "./client.js";
|
|
2
2
|
import { Base44Error, type Base44ErrorJSON } from "./utils/axios-client.js";
|
|
3
3
|
import { getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl } from "./utils/auth-utils.js";
|
|
4
4
|
export { createClient, createClientFromRequest, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, };
|
|
5
|
-
export type { Base44Client, CreateClientConfig, CreateClientOptions, Base44ErrorJSON, };
|
|
5
|
+
export type { Base44Client, CreateClientAnalyticsConfig, CreateClientConfig, CreateClientOptions, Base44ErrorJSON, };
|
|
6
6
|
export * from "./types.js";
|
|
7
7
|
export type { DeleteManyResult, DeleteResult, EntitiesModule, EntityFilterOperators, EntityFilterQuery, EntityFilterValue, EntityHandler, EntityRecord, EntityTypeRegistry, ImportResult, RealtimeEventType, RealtimeEvent, RealtimeCallback, SortField, UpdateManyResult, } from "./modules/entities.types.js";
|
|
8
8
|
export type { AuthModule, LoginResponse, RegisterParams, VerifyOtpParams, ChangePasswordParams, ResetPasswordParams, User, } from "./modules/auth.types.js";
|
package/dist/modules/actors.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ interface ActorsConfig {
|
|
|
35
35
|
* The legacy platform-proxy URL, byte-for-byte what PartySocket built before
|
|
36
36
|
* the direct path existed: same scheme swap (including its localhost-needs-a-
|
|
37
37
|
* port quirk), case-preserved party segment, `_pk` first in the query. The
|
|
38
|
-
* `handler` param is load-bearing
|
|
38
|
+
* `handler` param is load-bearing, because the proxy reads it for the actor name.
|
|
39
39
|
*/
|
|
40
40
|
export declare function buildProxyActorUrl(rawHost: string, actorName: string, instanceId: string, connectionId: string, appId: string, token: string | null | undefined, functionsVersion?: string): string;
|
|
41
41
|
/**
|
package/dist/modules/actors.js
CHANGED
|
@@ -8,12 +8,12 @@ const DEAD_MS = 3000;
|
|
|
8
8
|
// 422 = no principal (e.g. anonymous outside a browser) or an id/room only the
|
|
9
9
|
// proxy's looser validation accepts, 405 = a backend that predates the mint
|
|
10
10
|
// endpoint (its actor deploy routes catch the path via `{handler_name:path}`
|
|
11
|
-
// but not the POST method
|
|
11
|
+
// but not the POST method, and the real endpoint never 405s a POST). The
|
|
12
12
|
// proxy serves migrated actors too, so falling back is always safe.
|
|
13
13
|
const PROXY_FALLBACK_STATUSES = new Set([405, 409, 422, 503]);
|
|
14
14
|
// Mint responses no retry can fix (bad request / forbidden / not found): the
|
|
15
15
|
// connection closes instead of re-minting forever; a fresh connect() re-probes.
|
|
16
|
-
// 401 is deliberately absent
|
|
16
|
+
// 401 is deliberately absent. The auth token is re-read on every attempt, so a
|
|
17
17
|
// login recovers on the next retry. Disjoint from PROXY_FALLBACK_STATUSES.
|
|
18
18
|
const TERMINAL_MINT_STATUSES = new Set([400, 403, 404]);
|
|
19
19
|
/** The mint's rejection can be anything; a `Base44Error` carries a numeric
|
|
@@ -29,7 +29,7 @@ function toError(err) {
|
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* A live connection to an actor instance. Only obtainable from
|
|
32
|
-
* {@link ActorRef.connect}, so `subscribe`/`send` are always valid
|
|
32
|
+
* {@link ActorRef.connect}, so `subscribe`/`send` are always valid. The socket
|
|
33
33
|
* exists for this object's whole lifetime.
|
|
34
34
|
*/
|
|
35
35
|
class Connection {
|
|
@@ -44,7 +44,7 @@ class Connection {
|
|
|
44
44
|
// mint answers with a fallback status the choice is sticky for this
|
|
45
45
|
// socket's lifetime (a fresh connect() after close() probes direct again,
|
|
46
46
|
// picking up actors migrated in the meantime). Any other mint failure
|
|
47
|
-
// rejects, which ReconnectingWebSocket retries with backoff
|
|
47
|
+
// rejects, which ReconnectingWebSocket retries with backoff, except the
|
|
48
48
|
// terminal statuses, which close this connection for good.
|
|
49
49
|
let useProxy = config.transport === "proxy";
|
|
50
50
|
const urlProvider = async () => {
|
|
@@ -172,7 +172,7 @@ function makeActorRef(actorName, instanceId, config, connections) {
|
|
|
172
172
|
* The legacy platform-proxy URL, byte-for-byte what PartySocket built before
|
|
173
173
|
* the direct path existed: same scheme swap (including its localhost-needs-a-
|
|
174
174
|
* port quirk), case-preserved party segment, `_pk` first in the query. The
|
|
175
|
-
* `handler` param is load-bearing
|
|
175
|
+
* `handler` param is load-bearing, because the proxy reads it for the actor name.
|
|
176
176
|
*/
|
|
177
177
|
export function buildProxyActorUrl(rawHost, actorName, instanceId, connectionId, appId, token, functionsVersion) {
|
|
178
178
|
let host = rawHost.replace(/^(http|https|ws|wss):\/\//, "");
|
|
@@ -21,7 +21,7 @@ export interface ActorRegistry {
|
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* Auto-populated by `base44 types generate` with the names of your deployed actors.
|
|
24
|
-
* Do not edit this interface manually
|
|
24
|
+
* Do not edit this interface manually. Use {@link ActorRegistry} for message types.
|
|
25
25
|
*/
|
|
26
26
|
export interface ActorNameRegistry {
|
|
27
27
|
}
|
|
@@ -35,7 +35,7 @@ type ToServerFor<N extends string> = N extends keyof ActorRegistry ? ActorRegist
|
|
|
35
35
|
/** Options for {@link ActorRef.connect}. */
|
|
36
36
|
export interface ActorConnectOptions {
|
|
37
37
|
/**
|
|
38
|
-
* The connection id
|
|
38
|
+
* The connection id, which becomes the actor's `conn.id`. Supply a stable value
|
|
39
39
|
* (e.g. persisted per tab) so a reconnect reuses the same server-side
|
|
40
40
|
* identity; omit for an auto-generated per-connection id.
|
|
41
41
|
*/
|
|
@@ -48,7 +48,7 @@ export interface ActorSubscription {
|
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* A live connection to an actor instance, returned by {@link ActorRef.connect}.
|
|
51
|
-
* `subscribe`/`send` are always valid
|
|
51
|
+
* `subscribe`/`send` are always valid. You only get a `Connection` once the
|
|
52
52
|
* socket has been opened, so there's no pre-connect state to guard against.
|
|
53
53
|
*/
|
|
54
54
|
export interface Connection<N extends string = string> {
|
|
@@ -61,13 +61,13 @@ export interface Connection<N extends string = string> {
|
|
|
61
61
|
send(data: ToServerFor<N>): void;
|
|
62
62
|
/**
|
|
63
63
|
* Tear down the socket, heartbeat, and all listeners. Safe to call more
|
|
64
|
-
* than once. A connection also closes itself when it fails permanently
|
|
64
|
+
* than once. A connection also closes itself when it fails permanently.
|
|
65
65
|
* see {@link ActorRef.connect}.
|
|
66
66
|
*/
|
|
67
67
|
close(): void;
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
|
-
* A handle to one actor instance
|
|
70
|
+
* A handle to one actor instance, obtained from `base44.actors.MyActor(id)`. Call
|
|
71
71
|
* {@link connect} to open the socket and get a {@link Connection}.
|
|
72
72
|
*/
|
|
73
73
|
export interface ActorRef<N extends string = string> {
|
|
@@ -83,7 +83,7 @@ export interface ActorRef<N extends string = string> {
|
|
|
83
83
|
connect(options?: ActorConnectOptions): Connection<N>;
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
|
-
* Client for a single named Actor
|
|
86
|
+
* Client for a single named Actor. Call it with an instance id to get an
|
|
87
87
|
* {@link ActorRef}. Typed automatically when the actor is registered in
|
|
88
88
|
* {@link ActorRegistry}.
|
|
89
89
|
*/
|
|
@@ -11,8 +11,9 @@ export interface AnalyticsModuleArgs {
|
|
|
11
11
|
serverUrl: string;
|
|
12
12
|
appId: string;
|
|
13
13
|
userAuthModule: InternalAuthModule;
|
|
14
|
+
enabled: boolean;
|
|
14
15
|
}
|
|
15
|
-
export declare const createAnalyticsModule: ({ axiosClient, serverUrl, appId, userAuthModule, }: AnalyticsModuleArgs) => {
|
|
16
|
+
export declare const createAnalyticsModule: ({ axiosClient, serverUrl, appId, userAuthModule, enabled, }: AnalyticsModuleArgs) => {
|
|
16
17
|
track: (params: TrackEventParams) => void;
|
|
17
18
|
cleanup: () => void;
|
|
18
19
|
};
|
|
@@ -25,7 +25,7 @@ const analyticsSharedState = getSharedInstance(ANALYTICS_SHARED_STATE_NAME, () =
|
|
|
25
25
|
wasInitializationTracked: false,
|
|
26
26
|
sessionContext: null,
|
|
27
27
|
sessionStartTime: null,
|
|
28
|
-
// Memoized session id for when `localStorage` can't persist one
|
|
28
|
+
// Memoized session id for when `localStorage` can't persist one. See
|
|
29
29
|
// getAnalyticsSessionId.
|
|
30
30
|
fallbackSessionId: null,
|
|
31
31
|
config: {
|
|
@@ -33,7 +33,7 @@ const analyticsSharedState = getSharedInstance(ANALYTICS_SHARED_STATE_NAME, () =
|
|
|
33
33
|
...getAnalyticsConfigFromUrlParams(),
|
|
34
34
|
},
|
|
35
35
|
}));
|
|
36
|
-
export const createAnalyticsModule = ({ axiosClient, serverUrl, appId, userAuthModule, }) => {
|
|
36
|
+
export const createAnalyticsModule = ({ axiosClient, serverUrl, appId, userAuthModule, enabled, }) => {
|
|
37
37
|
var _a;
|
|
38
38
|
// prevent overflow of events //
|
|
39
39
|
const { maxQueueSize, throttleTime, batchSize } = analyticsSharedState.config;
|
|
@@ -41,7 +41,7 @@ export const createAnalyticsModule = ({ axiosClient, serverUrl, appId, userAuthM
|
|
|
41
41
|
// so the per-callsite `typeof window` guards below aren't enough to keep it
|
|
42
42
|
// from touching `document` (e.g. `document.referrer` on init). Node/SSR is
|
|
43
43
|
// still handled by those `window` guards, so this doesn't affect it.
|
|
44
|
-
if (!((_a = analyticsSharedState.config) === null || _a === void 0 ? void 0 : _a.enabled) || isReactNative) {
|
|
44
|
+
if (!enabled || !((_a = analyticsSharedState.config) === null || _a === void 0 ? void 0 : _a.enabled) || isReactNative) {
|
|
45
45
|
return {
|
|
46
46
|
track: () => { },
|
|
47
47
|
cleanup: () => { },
|
|
@@ -255,7 +255,7 @@ async function getSessionContext(userAuthModule) {
|
|
|
255
255
|
// With no token there is no identity to resolve: `me()` can only answer 401,
|
|
256
256
|
// which the browser logs to the console before any handler here sees it. On
|
|
257
257
|
// a public page that request is the sole reason an error appears, so skip
|
|
258
|
-
// it. This is not memoized
|
|
258
|
+
// it. This is not memoized, because a visitor who logs in later must still resolve.
|
|
259
259
|
if (!userAuthModule.hasToken()) {
|
|
260
260
|
return { user_id: null, session_id: getAnalyticsSessionId() };
|
|
261
261
|
}
|
|
@@ -21,7 +21,7 @@ export interface AppPublicSettingsResponse {
|
|
|
21
21
|
* ## Authentication Modes
|
|
22
22
|
*
|
|
23
23
|
* This module is available to use with a client in all authentication modes. The
|
|
24
|
-
* client's token, when it has one, is sent with the request
|
|
24
|
+
* client's token, when it has one, is sent with the request, so a signed-in visitor
|
|
25
25
|
* who has no access to the app is reported differently from an anonymous one.
|
|
26
26
|
*/
|
|
27
27
|
export interface AppModule {
|
|
@@ -29,9 +29,9 @@ export interface AppModule {
|
|
|
29
29
|
* Get the app's public configuration.
|
|
30
30
|
*
|
|
31
31
|
* Rejects with a {@linkcode Base44Error} when the visitor may not open the app:
|
|
32
|
-
* `status` is `403` and `data.extra_data.reason` says why
|
|
33
|
-
* when the visitor must sign in,
|
|
34
|
-
* visitor has no access to this app.
|
|
32
|
+
* `status` is `403` and `data.extra_data.reason` says why. It is
|
|
33
|
+
* `"auth_required"` when the visitor must sign in, and
|
|
34
|
+
* `"user_not_registered"` when the signed-in visitor has no access to this app.
|
|
35
35
|
*
|
|
36
36
|
* @returns Promise resolving to the app's ID and access policy.
|
|
37
37
|
*
|
package/dist/modules/auth.js
CHANGED
|
@@ -70,7 +70,7 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
70
70
|
// two identical GETs, so the second pays the first's full latency on every
|
|
71
71
|
// cold load.
|
|
72
72
|
//
|
|
73
|
-
// This shares the pending promise only
|
|
73
|
+
// This shares the pending promise only, and it is cleared as soon as the request
|
|
74
74
|
// settles, so no resolved user is ever retained. Caching the user across
|
|
75
75
|
// requests would leave the app rendering a stale identity after logout or a
|
|
76
76
|
// session swap.
|
|
@@ -526,7 +526,7 @@ export interface AuthModule {
|
|
|
526
526
|
/**
|
|
527
527
|
* The auth module as constructed internally, before it is narrowed to
|
|
528
528
|
* {@link AuthModule} on the public client. Not exported from the package
|
|
529
|
-
* index
|
|
529
|
+
* index. SDK consumers see only {@link AuthModule}.
|
|
530
530
|
*
|
|
531
531
|
* @internal
|
|
532
532
|
*/
|
|
@@ -534,7 +534,7 @@ export interface InternalAuthModule extends AuthModule {
|
|
|
534
534
|
/**
|
|
535
535
|
* Whether an access token is currently set on the client.
|
|
536
536
|
*
|
|
537
|
-
* Reports only the presence of a token, never its validity
|
|
537
|
+
* Reports only the presence of a token, never its validity. An expired or
|
|
538
538
|
* revoked token still reads as `true`. Callers use this to skip requests that
|
|
539
539
|
* could not succeed without a session, not to decide that one is valid.
|
|
540
540
|
*/
|
|
@@ -93,8 +93,8 @@ function assertNonEmptyString(value, label) {
|
|
|
93
93
|
* POST a request to the connector proxy and normalize the response.
|
|
94
94
|
*
|
|
95
95
|
* The proxy reports upstream outcomes in the body rather than as HTTP status, so
|
|
96
|
-
* a provider 4xx/5xx arrives here as a resolved response with `success: false
|
|
97
|
-
*
|
|
96
|
+
* a provider 4xx/5xx arrives here as a resolved response with `success: false`.
|
|
97
|
+
* Only Base44-side failures reject through the axios error interceptor.
|
|
98
98
|
*
|
|
99
99
|
* @internal
|
|
100
100
|
*/
|
|
@@ -87,7 +87,7 @@ export interface ConnectorApiResponse<T = unknown> {
|
|
|
87
87
|
status: number | null;
|
|
88
88
|
/**
|
|
89
89
|
* The parsed upstream response body, or proxy error details when no response
|
|
90
|
-
* was received. `null` when the response was binary
|
|
90
|
+
* was received. `null` when the response was binary. See {@link dataBase64}.
|
|
91
91
|
*/
|
|
92
92
|
data: T | null;
|
|
93
93
|
/**
|
|
@@ -148,9 +148,9 @@ export interface ConnectorProxyRawResponse {
|
|
|
148
148
|
*
|
|
149
149
|
* ## Metered connectors
|
|
150
150
|
*
|
|
151
|
-
* A few [platform connectors](#shared-connectors) are backed by paid third-party APIs that charge Base44 per call. For those, the OAuth token is **not** available to your code
|
|
151
|
+
* A few [platform connectors](#shared-connectors) are backed by paid third-party APIs that charge Base44 per call. For those, the OAuth token is **not** available to your code, and {@linkcode getConnection | getConnection()} rejects with a `403`. Call them with {@linkcode callApi | callApi()} instead: Base44 attaches the credential server-side, forwards the request, and bills your workspace's integration credits for the call.
|
|
152
152
|
*
|
|
153
|
-
* This applies to platform connectors only. A workspace-registered or app user connector runs on **your own** OAuth app, so the provider invoices you directly and there is nothing for Base44 to meter
|
|
153
|
+
* This applies to platform connectors only. A workspace-registered or app user connector runs on **your own** OAuth app, so the provider invoices you directly and there is nothing for Base44 to meter, so those keep normal token access via {@linkcode getWorkspaceConnection | getWorkspaceConnection()} and {@linkcode getCurrentAppUserConnection | getCurrentAppUserConnection()}.
|
|
154
154
|
*
|
|
155
155
|
* Two things to keep in mind when writing against a metered connector:
|
|
156
156
|
*
|
|
@@ -422,7 +422,7 @@ export interface ConnectorsModule {
|
|
|
422
422
|
*
|
|
423
423
|
* @param integrationType - The type of integration, such as `'x'`. See [Available connectors](#available-connectors).
|
|
424
424
|
* @param request - The upstream request to forward. See {@link ConnectorApiRequest}.
|
|
425
|
-
* @returns Promise resolving to a {@link ConnectorApiResponse}. Note that an upstream error is reported in `success` and `status`, not thrown
|
|
425
|
+
* @returns Promise resolving to a {@link ConnectorApiResponse}. Note that an upstream error is reported in `success` and `status`, not thrown. Only Base44-side failures reject.
|
|
426
426
|
*
|
|
427
427
|
* @example
|
|
428
428
|
* ```typescript
|
package/dist/modules/entities.js
CHANGED
|
@@ -143,7 +143,7 @@ function createEntityHandler(axios, appId, entityName, getSocket) {
|
|
|
143
143
|
// developer console so they know to fetch the full record on
|
|
144
144
|
// demand (e.g. a follow-up entities.X.get(id) call) instead of
|
|
145
145
|
// rendering the slimmed payload directly. Skip on delete events
|
|
146
|
-
//
|
|
146
|
+
// because the record no longer exists.
|
|
147
147
|
if (event.type !== "delete" && ((_a = event.data) === null || _a === void 0 ? void 0 : _a._oversize)) {
|
|
148
148
|
console.error(`[Base44 SDK] Realtime broadcast for ${entityName}#${event.id} was oversize and got slimmed for transport. ` +
|
|
149
149
|
`Fields >10 KB are empty and the rest of the record may be a stub. ` +
|
package/dist/utils/common.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const isNode = typeof window === "undefined";
|
|
2
2
|
export const isInIFrame = !isNode && window.self !== window.top;
|
|
3
3
|
// React Native defines `window` (so `isNode` is false there) but not `document`.
|
|
4
|
-
// Browser-only code paths gated on `window`/`isNode` alone would run
|
|
4
|
+
// Browser-only code paths gated on `window`/`isNode` alone would run, and crash,
|
|
5
5
|
// on React Native. Node (no `window`) is already handled by those `window` guards;
|
|
6
6
|
// this flags the window-without-a-DOM case that isn't.
|
|
7
7
|
export const isReactNative = !isNode && typeof document === "undefined";
|