busa-sdk 0.17.2 → 0.18.0

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.
@@ -1,66 +1,111 @@
1
- import { BusabaseAirAppCredentialStoreOptions } from './oauth-node.js';
2
- import './oauth.js';
3
-
1
+ import { t as BusabaseAirAppCredentialStoreOptions } from "./oauth-node-DGiWkh_l.js";
2
+ //#region src/airapp-node.d.ts
3
+ /**
4
+ * The env var Busabase injects into every AirApp process it spawns. Nobody else
5
+ * sets it, which is what makes its **absence** the positive fact "standalone".
6
+ */
7
+ declare const BUSABASE_AIRAPP_RUNTIME_ENV = "BUSABASE_AIRAPP_RUNTIME";
8
+ /**
9
+ * Every runtime Busabase hosts an AirApp in, as known to *this* SDK version.
10
+ *
11
+ * **Informational. Not what decides whether an app is hosted.** That separation
12
+ * is the whole point of this constant existing here rather than being pasted
13
+ * into each app, and getting it backwards is a bug we have already shipped once:
14
+ * every generated AirApp used to carry its own hardcoded copy of this list and
15
+ * answer `hosted` from membership in it. When the `local-node` engine was
16
+ * renamed to `local`, all of them started answering "standalone" *inside a
17
+ * hosted preview* — showing their own connection gate, calling `/api/v1` with no
18
+ * credential, and leaving the operator with nothing to act on.
19
+ *
20
+ * Moving the list into the SDK does not by itself fix that. An app pins an SDK
21
+ * version, so a list that gates behaviour would simply rot on a slower clock:
22
+ * add an engine, and every app on an older SDK is wrong again until it upgrades.
23
+ *
24
+ * So the list names runtimes; {@link isBusabaseAirAppHosted} decides hosting,
25
+ * from presence alone, and needs no upgrade to stay correct.
26
+ */
27
+ declare const BUSABASE_AIRAPP_RUNTIMES: readonly ["nodepod", "local", "srt", "sandock", "embed"];
28
+ type BusabaseAirAppRuntime = (typeof BUSABASE_AIRAPP_RUNTIMES)[number];
29
+ /** Read the injected runtime, normalised. `""` means nobody hosted this process. */
30
+ declare const readBusabaseAirAppRuntime: (env?: Record<string, string | undefined>) => string;
31
+ /**
32
+ * Whether Busabase is hosting this process.
33
+ *
34
+ * Presence, never membership — see {@link BUSABASE_AIRAPP_RUNTIMES}. An engine
35
+ * this SDK has never heard of still means "Busabase spawned me", because only
36
+ * Busabase sets the variable at all.
37
+ */
38
+ declare const isBusabaseAirAppHosted: (runtime?: string) => boolean;
39
+ /**
40
+ * Narrow a runtime string to one this SDK knows, or `null`.
41
+ *
42
+ * For code that wants to *branch* on a specific engine — an app that renders
43
+ * differently under a public embed, say. Deliberately returns `null` rather than
44
+ * throwing on an unknown value: a newer Busabase naming an engine this SDK
45
+ * predates is normal, not an error, and the caller should fall back to generic
46
+ * behaviour rather than break.
47
+ */
48
+ declare const asKnownBusabaseAirAppRuntime: (runtime: string) => BusabaseAirAppRuntime | null;
4
49
  declare const BUSABASE_AIRAPP_GATEWAY_REASONS: {
5
- readonly authRequired: "AUTH_REQUIRED";
6
- readonly authUnavailable: "AUTH_UNAVAILABLE";
7
- readonly connectionRequired: "CONNECTION_REQUIRED";
8
- readonly oauthCallbackInvalid: "OAUTH_CALLBACK_INVALID";
9
- readonly spaceNotAllowed: "SPACE_NOT_ALLOWED";
10
- readonly spaceSelectionRequired: "SPACE_SELECTION_REQUIRED";
50
+ readonly authRequired: "AUTH_REQUIRED";
51
+ readonly authUnavailable: "AUTH_UNAVAILABLE";
52
+ readonly connectionRequired: "CONNECTION_REQUIRED";
53
+ readonly oauthCallbackInvalid: "OAUTH_CALLBACK_INVALID";
54
+ readonly spaceNotAllowed: "SPACE_NOT_ALLOWED";
55
+ readonly spaceSelectionRequired: "SPACE_SELECTION_REQUIRED";
11
56
  };
12
57
  type GatewayReason = (typeof BUSABASE_AIRAPP_GATEWAY_REASONS)[keyof typeof BUSABASE_AIRAPP_GATEWAY_REASONS];
13
58
  interface AuthSpace {
14
- id: string;
15
- name: string;
16
- slug?: string | null;
17
- plan?: string | null;
59
+ id: string;
60
+ name: string;
61
+ slug?: string | null;
62
+ plan?: string | null;
18
63
  }
19
64
  interface GatewayTarget {
20
- baseUrl: string;
21
- accessToken: string;
22
- selectedSpace?: AuthSpace;
23
- source: "airapp-oauth-local" | "environment" | "open-server";
65
+ baseUrl: string;
66
+ accessToken: string;
67
+ selectedSpace?: AuthSpace;
68
+ source: "airapp-oauth-local" | "environment" | "open-server";
24
69
  }
25
70
  interface BusabaseAirAppLocalGatewayOptions {
26
- appId: string;
27
- cloudBaseUrl?: string;
28
- clientId?: string;
29
- environment?: Record<string, string | undefined>;
30
- fetch?: typeof fetch;
31
- now?: () => number;
32
- oauthPendingTtlMs?: number;
33
- requestTimeoutMs?: number;
34
- credentialStore?: BusabaseAirAppCredentialStoreOptions;
35
- successPath?: string;
36
- errorPath?: string;
71
+ appId: string;
72
+ cloudBaseUrl?: string;
73
+ clientId?: string;
74
+ environment?: Record<string, string | undefined>;
75
+ fetch?: typeof fetch;
76
+ now?: () => number;
77
+ oauthPendingTtlMs?: number;
78
+ requestTimeoutMs?: number;
79
+ credentialStore?: BusabaseAirAppCredentialStoreOptions;
80
+ successPath?: string;
81
+ errorPath?: string;
37
82
  }
38
83
  interface BusabaseAirAppAuthStatus {
39
- connected: boolean;
40
- cloudBaseUrl: string;
41
- baseUrl?: string;
42
- source?: GatewayTarget["source"];
43
- readiness: "needs_connection" | "needs_auth" | "needs_space" | "ready" | "retry";
44
- action: "connect" | "reconnect" | "select_space" | "continue" | "retry";
45
- requiresSpace?: boolean;
46
- selectedSpace?: AuthSpace | null;
47
- space?: AuthSpace | null;
48
- spaces?: AuthSpace[];
49
- reason?: GatewayReason;
50
- message?: string;
84
+ connected: boolean;
85
+ cloudBaseUrl: string;
86
+ baseUrl?: string;
87
+ source?: GatewayTarget["source"];
88
+ readiness: "needs_connection" | "needs_auth" | "needs_space" | "ready" | "retry";
89
+ action: "connect" | "reconnect" | "select_space" | "continue" | "retry";
90
+ requiresSpace?: boolean;
91
+ selectedSpace?: AuthSpace | null;
92
+ space?: AuthSpace | null;
93
+ spaces?: AuthSpace[];
94
+ reason?: GatewayReason;
95
+ message?: string;
51
96
  }
52
97
  declare class BusabaseAirAppLocalGateway {
53
- #private;
54
- constructor(options: BusabaseAirAppLocalGatewayOptions);
55
- get cloudBaseUrl(): string;
56
- status(): Promise<BusabaseAirAppAuthStatus>;
57
- statusResponse: () => Promise<Response>;
58
- start: (request: Request) => Promise<Response>;
59
- callback: (request: Request) => Promise<Response>;
60
- selectSpace: (request: Request) => Promise<Response>;
61
- logout: (request: Request) => Promise<Response>;
62
- proxy: (request: Request) => Promise<Response>;
98
+ #private;
99
+ constructor(options: BusabaseAirAppLocalGatewayOptions);
100
+ get cloudBaseUrl(): string;
101
+ status(): Promise<BusabaseAirAppAuthStatus>;
102
+ statusResponse: () => Promise<Response>;
103
+ start: (request: Request) => Promise<Response>;
104
+ callback: (request: Request) => Promise<Response>;
105
+ selectSpace: (request: Request) => Promise<Response>;
106
+ logout: (request: Request) => Promise<Response>;
107
+ proxy: (request: Request) => Promise<Response>;
63
108
  }
64
109
  declare const createBusabaseAirAppLocalGateway: (options: BusabaseAirAppLocalGatewayOptions) => BusabaseAirAppLocalGateway;
65
-
66
- export { BUSABASE_AIRAPP_GATEWAY_REASONS, type BusabaseAirAppAuthStatus, BusabaseAirAppLocalGateway, type BusabaseAirAppLocalGatewayOptions, createBusabaseAirAppLocalGateway };
110
+ //#endregion
111
+ export { BUSABASE_AIRAPP_GATEWAY_REASONS, BUSABASE_AIRAPP_RUNTIMES, BUSABASE_AIRAPP_RUNTIME_ENV, BusabaseAirAppAuthStatus, BusabaseAirAppLocalGateway, BusabaseAirAppLocalGatewayOptions, BusabaseAirAppRuntime, asKnownBusabaseAirAppRuntime, createBusabaseAirAppLocalGateway, isBusabaseAirAppHosted, readBusabaseAirAppRuntime };