@base44-preview/sdk 0.8.48-pr.283.2de4c8a → 0.8.48-pr.284.e0a8d2f
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/README.md +0 -18
- package/package.json +5 -41
- package/dist/platform/server/client.d.ts +0 -29
- package/dist/platform/server/client.js +0 -57
- package/dist/platform/server/errors.d.ts +0 -28
- package/dist/platform/server/errors.js +0 -20
- package/dist/platform/server/index.d.ts +0 -9
- package/dist/platform/server/index.js +0 -4
- package/dist/platform/server/modules/apps.d.ts +0 -4
- package/dist/platform/server/modules/apps.js +0 -66
- package/dist/platform/server/modules/apps.types.d.ts +0 -87
- package/dist/platform/server/modules/apps.types.js +0 -1
- package/dist/platform/server/modules/users.d.ts +0 -4
- package/dist/platform/server/modules/users.js +0 -40
- package/dist/platform/server/modules/users.types.d.ts +0 -33
- package/dist/platform/server/modules/users.types.js +0 -1
- package/dist/platform/server/token-store.d.ts +0 -11
- package/dist/platform/server/token-store.js +0 -17
- package/dist/platform/server/tokens.d.ts +0 -16
- package/dist/platform/server/tokens.js +0 -80
- package/dist/platform/server/transport.d.ts +0 -10
- package/dist/platform/server/transport.js +0 -69
- package/dist/platform/server/types.d.ts +0 -60
- package/dist/platform/server/types.js +0 -1
- package/dist/platform/server/validation.d.ts +0 -9
- package/dist/platform/server/validation.js +0 -36
package/README.md
CHANGED
|
@@ -7,24 +7,6 @@ You can use it in two ways:
|
|
|
7
7
|
- **Inside Base44 apps**: When Base44 generates your app, the SDK is already set up and ready to use.
|
|
8
8
|
- **External apps**: Use the SDK to build your own frontend or backend that uses Base44 as a backend service.
|
|
9
9
|
|
|
10
|
-
## Platform SDK (server)
|
|
11
|
-
|
|
12
|
-
The same package includes a separate server entry point for provisioning users and
|
|
13
|
-
managing their apps:
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import { Base44PlatformClient } from "@base44/sdk/platform/server";
|
|
17
|
-
|
|
18
|
-
const platform = new Base44PlatformClient({ apiKey, workspaceId });
|
|
19
|
-
await platform.users.provision({ externalId: "customer_42" });
|
|
20
|
-
const apps = await platform.asUser("customer_42").apps.list();
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Use this entry point only on your server. `tokenStore` is optional and defaults to
|
|
24
|
-
in-memory caching. See the [platform guide](platform-docs/README.md),
|
|
25
|
-
[complete API reference](platform-docs/api.md), and [token lifecycle](platform-docs/tokens.md).
|
|
26
|
-
The existing `@base44/sdk` root import continues to provide the runtime SDK.
|
|
27
|
-
|
|
28
10
|
## Installation
|
|
29
11
|
|
|
30
12
|
**Inside Base44 apps**: The SDK is already available. No installation needed.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@base44-preview/sdk",
|
|
3
|
-
"version": "0.8.48-pr.
|
|
3
|
+
"version": "0.8.48-pr.284.e0a8d2f",
|
|
4
4
|
"description": "JavaScript SDK for Base44 API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "
|
|
13
|
-
"lint": "eslint src
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"lint": "eslint src",
|
|
14
14
|
"test": "npm run test:types && vitest run",
|
|
15
15
|
"test:types": "tsc --noEmit -p tsconfig.type-tests.json",
|
|
16
16
|
"test:unit": "vitest run tests/unit",
|
|
@@ -23,12 +23,7 @@
|
|
|
23
23
|
"create-docs-local": "npm run create-docs && npm run copy-docs-local",
|
|
24
24
|
"copy-docs-local": "node scripts/mintlify-post-processing/copy-to-local-docs.js",
|
|
25
25
|
"create-docs:generate": "typedoc",
|
|
26
|
-
"create-docs:process": "node scripts/mintlify-post-processing/file-processing/file-processing.js"
|
|
27
|
-
"build:runtime": "tsc",
|
|
28
|
-
"build:platform": "tsc -p tsconfig.platform.json",
|
|
29
|
-
"test:platform": "vitest run tests/unit/platform",
|
|
30
|
-
"test:package": "npm run build && node --test tests/package/platform-server.test.mjs",
|
|
31
|
-
"docs:platform": "typedoc --options typedoc.platform.json"
|
|
26
|
+
"create-docs:process": "node scripts/mintlify-post-processing/file-processing/file-processing.js"
|
|
32
27
|
},
|
|
33
28
|
"dependencies": {
|
|
34
29
|
"axios": "^1.18.1",
|
|
@@ -68,36 +63,5 @@
|
|
|
68
63
|
"bugs": {
|
|
69
64
|
"url": "https://github.com/base44/javascript-sdk/issues"
|
|
70
65
|
},
|
|
71
|
-
"homepage": "https://github.com/base44/javascript-sdk#readme"
|
|
72
|
-
"exports": {
|
|
73
|
-
".": {
|
|
74
|
-
"types": "./dist/index.d.ts",
|
|
75
|
-
"default": "./dist/index.js"
|
|
76
|
-
},
|
|
77
|
-
"./platform/server": {
|
|
78
|
-
"types": "./dist/platform/server/index.d.ts",
|
|
79
|
-
"default": "./dist/platform/server/index.js"
|
|
80
|
-
},
|
|
81
|
-
"./dist/*.d.ts": "./dist/*.d.ts",
|
|
82
|
-
"./dist/*.js": {
|
|
83
|
-
"types": "./dist/*.d.ts",
|
|
84
|
-
"default": "./dist/*.js"
|
|
85
|
-
},
|
|
86
|
-
"./dist/*": {
|
|
87
|
-
"types": "./dist/*.d.ts",
|
|
88
|
-
"default": "./dist/*.js"
|
|
89
|
-
},
|
|
90
|
-
"./package.json": "./package.json",
|
|
91
|
-
"./*": "./*"
|
|
92
|
-
},
|
|
93
|
-
"typesVersions": {
|
|
94
|
-
"*": {
|
|
95
|
-
"platform/server": [
|
|
96
|
-
"dist/platform/server/index.d.ts"
|
|
97
|
-
],
|
|
98
|
-
"*": [
|
|
99
|
-
"*"
|
|
100
|
-
]
|
|
101
|
-
}
|
|
102
|
-
}
|
|
66
|
+
"homepage": "https://github.com/base44/javascript-sdk#readme"
|
|
103
67
|
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { PlatformClientConfig, TokenRequestOptions } from "./types.js";
|
|
2
|
-
import type { UsersModule } from "./modules/users.types.js";
|
|
3
|
-
import type { AppsModule } from "./modules/apps.types.js";
|
|
4
|
-
/** Immutable server-side view of one provisioned user; never a browser session. */
|
|
5
|
-
export interface PlatformUserClient {
|
|
6
|
-
/** Canonical caller-owned external ID, not the Base44 user ID. */
|
|
7
|
-
readonly externalId: string;
|
|
8
|
-
/** App operations authenticated as this user. */
|
|
9
|
-
readonly apps: AppsModule;
|
|
10
|
-
/** Lazily mint/reuse a server credential. Never send the result to the browser. */
|
|
11
|
-
getAccessToken(options?: TokenRequestOptions): Promise<string>;
|
|
12
|
-
/** Revoke refresh credentials and clear storage even if remote revocation fails. Does not deprovision. */
|
|
13
|
-
revokeToken(): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
/** Server-only client for provisioning users and managing their apps.
|
|
16
|
-
* @example
|
|
17
|
-
* const platform = new Base44PlatformClient({ apiKey, workspaceId });
|
|
18
|
-
* await platform.users.provision({ externalId: "customer_42" });
|
|
19
|
-
* const apps = await platform.asUser("customer_42").apps.list();
|
|
20
|
-
*/
|
|
21
|
-
export declare class Base44PlatformClient {
|
|
22
|
-
#private;
|
|
23
|
-
/** Explicit identity provisioning and offboarding, using the configured workspace API key. */
|
|
24
|
-
readonly users: UsersModule;
|
|
25
|
-
/** Construct without network access. One key must support provisioning and minting. */
|
|
26
|
-
constructor(config: PlatformClientConfig);
|
|
27
|
-
/** Bind a previously provisioned external user ID. Lazy, synchronous and safe to call concurrently. */
|
|
28
|
-
asUser(value: string): PlatformUserClient;
|
|
29
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Base44PlatformError } from "./errors.js";
|
|
2
|
-
import { InMemoryTokenStore } from "./token-store.js";
|
|
3
|
-
import { Tokens } from "./tokens.js";
|
|
4
|
-
import { Transport, checkAbort, waitFor } from "./transport.js";
|
|
5
|
-
import { createUsers } from "./modules/users.js";
|
|
6
|
-
import { createApps } from "./modules/apps.js";
|
|
7
|
-
import { externalId, identifier, invalid, positive } from "./validation.js";
|
|
8
|
-
/** Server-only client for provisioning users and managing their apps.
|
|
9
|
-
* @example
|
|
10
|
-
* const platform = new Base44PlatformClient({ apiKey, workspaceId });
|
|
11
|
-
* await platform.users.provision({ externalId: "customer_42" });
|
|
12
|
-
* const apps = await platform.asUser("customer_42").apps.list();
|
|
13
|
-
*/
|
|
14
|
-
export class Base44PlatformClient {
|
|
15
|
-
/** Explicit identity provisioning and offboarding, using the configured workspace API key. */
|
|
16
|
-
users;
|
|
17
|
-
#transport;
|
|
18
|
-
#tokens;
|
|
19
|
-
#workspaceId;
|
|
20
|
-
#buildTimeoutMs;
|
|
21
|
-
/** Construct without network access. One key must support provisioning and minting. */
|
|
22
|
-
constructor(config) {
|
|
23
|
-
if (typeof window !== "undefined")
|
|
24
|
-
throw new Base44PlatformError("server_only", "The platform client must run on your server.");
|
|
25
|
-
if (typeof config.apiKey !== "string" || !config.apiKey.trim())
|
|
26
|
-
invalid("apiKey is required.");
|
|
27
|
-
identifier(config.workspaceId);
|
|
28
|
-
let url;
|
|
29
|
-
try {
|
|
30
|
-
url = new URL(config.serverUrl ?? "https://base44.app");
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
invalid("serverUrl must be an absolute HTTP(S) URL.");
|
|
34
|
-
}
|
|
35
|
-
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || url.search || url.hash)
|
|
36
|
-
invalid("serverUrl must be an HTTP(S) URL without credentials, query or fragment.");
|
|
37
|
-
const serverUrl = url.toString().replace(/\/+$/, "");
|
|
38
|
-
this.#workspaceId = config.workspaceId;
|
|
39
|
-
this.#buildTimeoutMs = positive(config.buildTimeoutMs ?? 120_000);
|
|
40
|
-
this.#transport = new Transport(serverUrl, config.fetch ?? globalThis.fetch, positive(config.timeoutMs ?? 30_000));
|
|
41
|
-
this.#tokens = new Tokens(this.#transport, config.tokenStore ?? new InMemoryTokenStore(), config.apiKey, { serverUrl, workspaceId: config.workspaceId });
|
|
42
|
-
this.users = Object.freeze(createUsers(this.#transport, this.#tokens, config.apiKey));
|
|
43
|
-
}
|
|
44
|
-
/** Bind a previously provisioned external user ID. Lazy, synchronous and safe to call concurrently. */
|
|
45
|
-
asUser(value) {
|
|
46
|
-
const id = externalId(value);
|
|
47
|
-
return Object.freeze({
|
|
48
|
-
externalId: id,
|
|
49
|
-
apps: Object.freeze(createApps(this.#transport, this.#tokens, id, this.#workspaceId, this.#buildTimeoutMs)),
|
|
50
|
-
getAccessToken: async (options = {}) => {
|
|
51
|
-
checkAbort(options.signal);
|
|
52
|
-
return waitFor(this.#tokens.get(id, options.forceRefresh), options.signal);
|
|
53
|
-
},
|
|
54
|
-
revokeToken: () => this.#tokens.revoke(id),
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/** Stable SDK failure categories; server response prose is never copied into errors. */
|
|
2
|
-
export type PlatformErrorCode = "invalid_argument" | "server_only" | "http_error" | "invalid_response" | "network_error" | "timeout" | "aborted" | "token_store_error";
|
|
3
|
-
/** Safe error representation, suitable for returning to your own application. */
|
|
4
|
-
export interface PlatformErrorJSON {
|
|
5
|
-
/** Always Base44PlatformError. */
|
|
6
|
-
name: "Base44PlatformError";
|
|
7
|
-
/** SDK-defined message containing no request or response bodies. */
|
|
8
|
-
message: string;
|
|
9
|
-
/** HTTP status, or 0 for a local, network, cancellation or storage failure. */
|
|
10
|
-
status: number;
|
|
11
|
-
/** Stable SDK category; inspect status for HTTP failures. */
|
|
12
|
-
code: PlatformErrorCode;
|
|
13
|
-
}
|
|
14
|
-
/** All SDK failures use this error; no raw response, credential or fetch error is retained. */
|
|
15
|
-
export declare class Base44PlatformError extends Error {
|
|
16
|
-
/** SDK failure category. */
|
|
17
|
-
readonly code: PlatformErrorCode;
|
|
18
|
-
/** HTTP status, or 0 if no HTTP failure response was received. */
|
|
19
|
-
readonly status: number;
|
|
20
|
-
/** Create a safe error from an SDK category, message and optional HTTP status. */
|
|
21
|
-
constructor(
|
|
22
|
-
/** SDK failure category. */
|
|
23
|
-
code: PlatformErrorCode, message: string,
|
|
24
|
-
/** HTTP status, or 0 if no HTTP failure response was received. */
|
|
25
|
-
status?: number);
|
|
26
|
-
/** Return safe fields only; excludes stack traces and transport internals. */
|
|
27
|
-
toJSON(): PlatformErrorJSON;
|
|
28
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/** All SDK failures use this error; no raw response, credential or fetch error is retained. */
|
|
2
|
-
export class Base44PlatformError extends Error {
|
|
3
|
-
code;
|
|
4
|
-
status;
|
|
5
|
-
/** Create a safe error from an SDK category, message and optional HTTP status. */
|
|
6
|
-
constructor(
|
|
7
|
-
/** SDK failure category. */
|
|
8
|
-
code, message,
|
|
9
|
-
/** HTTP status, or 0 if no HTTP failure response was received. */
|
|
10
|
-
status = 0) {
|
|
11
|
-
super(message);
|
|
12
|
-
this.code = code;
|
|
13
|
-
this.status = status;
|
|
14
|
-
this.name = "Base44PlatformError";
|
|
15
|
-
}
|
|
16
|
-
/** Return safe fields only; excludes stack traces and transport internals. */
|
|
17
|
-
toJSON() {
|
|
18
|
-
return { name: "Base44PlatformError", message: this.message, status: this.status, code: this.code };
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** Server-side Base44 platform SDK. Runtime app entities remain in @base44/sdk. */
|
|
2
|
-
export { Base44PlatformClient } from "./client.js";
|
|
3
|
-
export type { PlatformUserClient } from "./client.js";
|
|
4
|
-
export { Base44PlatformError } from "./errors.js";
|
|
5
|
-
export type { PlatformErrorCode, PlatformErrorJSON } from "./errors.js";
|
|
6
|
-
export { InMemoryTokenStore } from "./token-store.js";
|
|
7
|
-
export type { PlatformClientConfig, RequestOptions, TokenRequestOptions, TokenKey, TokenRecord, TokenStore } from "./types.js";
|
|
8
|
-
export type { UsersModule, ProvisionUserInput, ProvisionedUser, DeprovisionResult } from "./modules/users.types.js";
|
|
9
|
-
export type { AppsModule, PlatformApp, AppState, ListAppsInput, CreateAppInput, PreviewResult, DeployResult } from "./modules/apps.types.js";
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Transport } from "../transport.js";
|
|
2
|
-
import { Tokens } from "../tokens.js";
|
|
3
|
-
import type { AppsModule } from "./apps.types.js";
|
|
4
|
-
export declare function createApps(transport: Transport, tokens: Tokens, id: string, workspaceId: string, buildTimeoutMs: number): AppsModule;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { checkAbort, waitFor } from "../transport.js";
|
|
2
|
-
import { object, identifier, requiredString, nullableString, badResponse, invalid } from "../validation.js";
|
|
3
|
-
function projectApp(value) {
|
|
4
|
-
const data = object(value);
|
|
5
|
-
const state = data.status && typeof data.status === "object" ? object(data.status).state : undefined;
|
|
6
|
-
return {
|
|
7
|
-
id: requiredString(data.id), name: nullableString(data.name), slug: nullableString(data.slug),
|
|
8
|
-
state: state === "ready" || state === "processing" || state === "error" ? state : "unknown",
|
|
9
|
-
updatedAt: nullableString(data.updated_date), previewScreenshotUrl: nullableString(data.preview_screenshot_url),
|
|
10
|
-
logoUrl: nullableString(data.logo_url), lastDeployedAt: nullableString(data.last_deployed_at),
|
|
11
|
-
currentRevision: nullableString(data.last_git_commit_hash), deployedRevision: nullableString(data.last_deployed_git_commit_hash),
|
|
12
|
-
hasCustomInstructions: typeof data.custom_instructions === "string" && data.custom_instructions.length > 0,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export function createApps(transport, tokens, id, workspaceId, buildTimeoutMs) {
|
|
16
|
-
async function request(path, method, body, options = {}) {
|
|
17
|
-
checkAbort(options.signal);
|
|
18
|
-
const token = await waitFor(tokens.get(id), options.signal);
|
|
19
|
-
return transport.request(path, method, {
|
|
20
|
-
Authorization: `Bearer ${token}`, "X-Active-Workspace-Id": workspaceId, "Content-Type": "application/json",
|
|
21
|
-
}, body, options);
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
async list(input = {}, options) {
|
|
25
|
-
const limit = input.limit ?? 20, skip = input.skip ?? 0;
|
|
26
|
-
if (!Number.isInteger(limit) || limit < 1 || !Number.isInteger(skip) || skip < 0)
|
|
27
|
-
invalid("limit must be positive and skip nonnegative integers.");
|
|
28
|
-
const query = new URLSearchParams({ q: JSON.stringify({ app_type: { $nin: ["user_agent"] } }), sort: "-updated_date", limit: String(limit), skip: String(skip), filter_mode: "all_apps_workspace" });
|
|
29
|
-
if (input.folderId !== undefined) {
|
|
30
|
-
identifier(input.folderId);
|
|
31
|
-
query.set("folder_id", input.folderId);
|
|
32
|
-
}
|
|
33
|
-
const data = await request(`/api/apps?${query}`, "GET", undefined, options);
|
|
34
|
-
return Array.isArray(data) ? data.map(projectApp) : badResponse();
|
|
35
|
-
},
|
|
36
|
-
async create(input, options) {
|
|
37
|
-
if (typeof input.prompt !== "string" || !input.prompt.trim())
|
|
38
|
-
invalid("An initial prompt is required.");
|
|
39
|
-
return projectApp(await request("/api/apps", "POST", {
|
|
40
|
-
name: input.name, user_description: input.prompt, organization_id: workspaceId,
|
|
41
|
-
public_settings: input.publicSettings, prevent_iframe_embedding: input.preventIframeEmbedding,
|
|
42
|
-
custom_instructions: input.customInstructions,
|
|
43
|
-
secrets: input.secrets === undefined ? undefined : Object.fromEntries(Object.entries(input.secrets).map(([key, value]) => [key, { type: "value", value }])),
|
|
44
|
-
initial_message: { content: input.prompt },
|
|
45
|
-
}, { timeoutMs: buildTimeoutMs, ...options }));
|
|
46
|
-
},
|
|
47
|
-
async get(appId, options) { return projectApp(await request(`/api/apps/${identifier(appId)}`, "GET", undefined, options)); },
|
|
48
|
-
async rename(appId, name, options) {
|
|
49
|
-
if (typeof name !== "string" || !name.trim())
|
|
50
|
-
invalid("A nonempty app name is required.");
|
|
51
|
-
return projectApp(await request(`/api/apps/${identifier(appId)}`, "PUT", { name: name.trim() }, options));
|
|
52
|
-
},
|
|
53
|
-
async addToFolder(folderId, appIds, options) {
|
|
54
|
-
appIds.forEach(identifier);
|
|
55
|
-
await request(`/api/app-folders/${identifier(folderId)}/items`, "POST", { app_ids: appIds }, options);
|
|
56
|
-
},
|
|
57
|
-
async getPreviewUrl(appId, options) {
|
|
58
|
-
const data = object(await request(`/api/apps/${identifier(appId)}/sandbox/preview-url`, "GET", undefined, options));
|
|
59
|
-
return { url: requiredString(data.preview_url), token: nullableString(data.preview_token) };
|
|
60
|
-
},
|
|
61
|
-
async deploy(appId, options) {
|
|
62
|
-
const data = object(await request(`/api/apps/${identifier(appId)}/deploy`, "POST", {}, { timeoutMs: buildTimeoutMs, ...options }));
|
|
63
|
-
return { appId: requiredString(data.app_id), checkpointId: nullableString(data.checkpoint_id), revision: requiredString(data.git_commit_hash), deployedAt: requiredString(data.deployed_at) };
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import type { RequestOptions } from "../types.js";
|
|
2
|
-
/** Public build state. Unrecognized server states map to unknown. */
|
|
3
|
-
export type AppState = "ready" | "processing" | "error" | "unknown";
|
|
4
|
-
/** Projected app metadata. No source files, author identity, billing or raw status details. */
|
|
5
|
-
export interface PlatformApp {
|
|
6
|
-
/** Base44 app ID. */
|
|
7
|
-
id: string;
|
|
8
|
-
/** App display name, or null if absent. */
|
|
9
|
-
name: string | null;
|
|
10
|
-
/** Public URL slug, or null if absent. */
|
|
11
|
-
slug: string | null;
|
|
12
|
-
/** Build state; unknown when missing or newly introduced by the server. */
|
|
13
|
-
state: AppState;
|
|
14
|
-
/** ISO 8601 update timestamp, or null. */
|
|
15
|
-
updatedAt: string | null;
|
|
16
|
-
/** Preview screenshot URL, or null. */
|
|
17
|
-
previewScreenshotUrl: string | null;
|
|
18
|
-
/** App logo URL, or null. */
|
|
19
|
-
logoUrl: string | null;
|
|
20
|
-
/** ISO 8601 last deployment timestamp, or null. */
|
|
21
|
-
lastDeployedAt: string | null;
|
|
22
|
-
/** Current code revision, or null; permits comparing edits with the deployed version. */
|
|
23
|
-
currentRevision: string | null;
|
|
24
|
-
/** Last deployed code revision, or null. */
|
|
25
|
-
deployedRevision: string | null;
|
|
26
|
-
/** Whether persisted custom instructions are nonempty. Does not return their contents. */
|
|
27
|
-
hasCustomInstructions: boolean;
|
|
28
|
-
}
|
|
29
|
-
/** App listing options; this is not a partner-user authorization filter. */
|
|
30
|
-
export interface ListAppsInput {
|
|
31
|
-
/** Optional Base44 folder ID; omitted means no folder restriction. */
|
|
32
|
-
folderId?: string;
|
|
33
|
-
/** Maximum results; integer > 0, defaults to 20. No total count is returned. */
|
|
34
|
-
limit?: number;
|
|
35
|
-
/** Number of results to skip; integer >= 0, defaults to 0. */
|
|
36
|
-
skip?: number;
|
|
37
|
-
}
|
|
38
|
-
/** App creation, including the first build. Subsequent chat is not part of this SDK. */
|
|
39
|
-
export interface CreateAppInput {
|
|
40
|
-
/** Initial build prompt; required, nonempty. Also used as the app description. */
|
|
41
|
-
prompt: string;
|
|
42
|
-
/** Optional display name; omitted lets the server choose. */
|
|
43
|
-
name?: string;
|
|
44
|
-
/** Optional persisted instructions applied starting with the initial build. */
|
|
45
|
-
customInstructions?: string;
|
|
46
|
-
/** Server-resolved secret name/value pairs installed before the build. Never accept browser-supplied values blindly. */
|
|
47
|
-
secrets?: Record<string, string>;
|
|
48
|
-
/** App access policy; omitted leaves the server default. */
|
|
49
|
-
publicSettings?: "private_with_login" | "public_with_login" | "public_without_login" | "workspace_with_login";
|
|
50
|
-
/** Whether to block iframe embedding; omitted leaves the server default. Starter sets false. */
|
|
51
|
-
preventIframeEmbedding?: boolean;
|
|
52
|
-
}
|
|
53
|
-
/** Preview access. Credential-bearing fields must not be logged or cached. */
|
|
54
|
-
export interface PreviewResult {
|
|
55
|
-
/** Preview URL for unpublished changes. May itself include authorization material. */
|
|
56
|
-
url: string;
|
|
57
|
-
/** Short-lived preview credential, or null when not needed. Not a platform access token. */
|
|
58
|
-
token: string | null;
|
|
59
|
-
}
|
|
60
|
-
/** Completed deployment response; identifies the version published by this request. */
|
|
61
|
-
export interface DeployResult {
|
|
62
|
-
/** Deployed app ID. */
|
|
63
|
-
appId: string;
|
|
64
|
-
/** Associated saved-version ID, or null. */
|
|
65
|
-
checkpointId: string | null;
|
|
66
|
-
/** Exact published code revision. */
|
|
67
|
-
revision: string;
|
|
68
|
-
/** ISO 8601 deployment timestamp. */
|
|
69
|
-
deployedAt: string;
|
|
70
|
-
}
|
|
71
|
-
/** App operations performed as the user bound by asUser. */
|
|
72
|
-
export interface AppsModule {
|
|
73
|
-
/** List apps newest-updated first, excluding agent apps; returns a bare array. */
|
|
74
|
-
list(input?: ListAppsInput, options?: RequestOptions): Promise<PlatformApp[]>;
|
|
75
|
-
/** Create and start the first build. No automatic retry, filing or local ownership write. */
|
|
76
|
-
create(input: CreateAppInput, options?: RequestOptions): Promise<PlatformApp>;
|
|
77
|
-
/** Read projected metadata for an authorized app. */
|
|
78
|
-
get(appId: string, options?: RequestOptions): Promise<PlatformApp>;
|
|
79
|
-
/** Rename only; whitespace around the name is trimmed. */
|
|
80
|
-
rename(appId: string, name: string, options?: RequestOptions): Promise<PlatformApp>;
|
|
81
|
-
/** Move apps into a folder. Separate from creation; failure leaves created apps intact. */
|
|
82
|
-
addToFolder(folderId: string, appIds: string[], options?: RequestOptions): Promise<void>;
|
|
83
|
-
/** Boot or reuse a preview; request fresh access each time it is needed. */
|
|
84
|
-
getPreviewUrl(appId: string, options?: RequestOptions): Promise<PreviewResult>;
|
|
85
|
-
/** Publish the current main version. No polling or chat subscription is started. */
|
|
86
|
-
deploy(appId: string, options?: RequestOptions): Promise<DeployResult>;
|
|
87
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Base44PlatformError } from "../errors.js";
|
|
2
|
-
import { externalId, object, requiredString, boolean, badResponse } from "../validation.js";
|
|
3
|
-
export function createUsers(transport, tokens, apiKey) {
|
|
4
|
-
const headers = { Authorization: apiKey, "Content-Type": "application/json" };
|
|
5
|
-
return {
|
|
6
|
-
async provision(input, options) {
|
|
7
|
-
const id = externalId(input.externalId);
|
|
8
|
-
return tokens.exclusive(id, async () => {
|
|
9
|
-
const data = object(await transport.request("/api/service/users", "POST", headers, {
|
|
10
|
-
service_external_id: id, display_name: input.displayName,
|
|
11
|
-
}, options));
|
|
12
|
-
const email = requiredString(data.email);
|
|
13
|
-
const domain = email.split("@")[1]?.toLowerCase();
|
|
14
|
-
if (!domain || !(domain === "svc.base44.invalid" || domain.endsWith(".svc.base44.invalid")))
|
|
15
|
-
return badResponse();
|
|
16
|
-
return {
|
|
17
|
-
externalId: requiredString(data.service_external_id), userId: requiredString(data.user_id),
|
|
18
|
-
email, role: requiredString(data.role), created: boolean(data.created),
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
},
|
|
22
|
-
async deprovision(value, options) {
|
|
23
|
-
const id = externalId(value);
|
|
24
|
-
return tokens.exclusive(id, async () => {
|
|
25
|
-
let removed;
|
|
26
|
-
try {
|
|
27
|
-
const data = object(await transport.request(`/api/service/users/${encodeURIComponent(id)}`, "DELETE", headers, undefined, options));
|
|
28
|
-
removed = boolean(data.removed);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
if (!(error instanceof Base44PlatformError) || error.status !== 404)
|
|
32
|
-
throw error;
|
|
33
|
-
removed = false;
|
|
34
|
-
}
|
|
35
|
-
await tokens.remove(id);
|
|
36
|
-
return { removed };
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { RequestOptions } from "../types.js";
|
|
2
|
-
/** Input for an explicitly requested provisioning operation. */
|
|
3
|
-
export interface ProvisionUserInput {
|
|
4
|
-
/** Stable ID from your system; trimmed and lowercased, never a Base44 user ID. */
|
|
5
|
-
externalId: string;
|
|
6
|
-
/** Optional display label visible to workspace administrators; avoid personal data. */
|
|
7
|
-
displayName?: string;
|
|
8
|
-
}
|
|
9
|
-
/** Synthetic service identity returned by provisioning, not a login-capable account. */
|
|
10
|
-
export interface ProvisionedUser {
|
|
11
|
-
/** Canonical ID from your system. */
|
|
12
|
-
externalId: string;
|
|
13
|
-
/** Base44-assigned user ID. */
|
|
14
|
-
userId: string;
|
|
15
|
-
/** Synthetic, non-routable service address; not your customer's email. */
|
|
16
|
-
email: string;
|
|
17
|
-
/** Workspace role returned by Base44; this SDK never requests an elevated role. */
|
|
18
|
-
role: string;
|
|
19
|
-
/** True if created by this request, false if it already existed. */
|
|
20
|
-
created: boolean;
|
|
21
|
-
}
|
|
22
|
-
/** Outcome of removing a service identity. */
|
|
23
|
-
export interface DeprovisionResult {
|
|
24
|
-
/** False if already absent; true if removed. */
|
|
25
|
-
removed: boolean;
|
|
26
|
-
}
|
|
27
|
-
/** Workspace-level identity operations, authenticated with the configured API key. */
|
|
28
|
-
export interface UsersModule {
|
|
29
|
-
/** Explicitly create or return a principal; idempotent within its workspace. */
|
|
30
|
-
provision(input: ProvisionUserInput, options?: RequestOptions): Promise<ProvisionedUser>;
|
|
31
|
-
/** Offboard and clear local tokens. Owned apps may transfer to the workspace owner. */
|
|
32
|
-
deprovision(externalId: string, options?: RequestOptions): Promise<DeprovisionResult>;
|
|
33
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { TokenKey, TokenRecord, TokenStore } from "./types.js";
|
|
2
|
-
/** Process-local storage. Reuse a client to reuse tokens; no cross-process synchronization. */
|
|
3
|
-
export declare class InMemoryTokenStore implements TokenStore {
|
|
4
|
-
#private;
|
|
5
|
-
/** Return a copy, or null when absent. */
|
|
6
|
-
get(key: TokenKey): Promise<TokenRecord | null>;
|
|
7
|
-
/** Store a copy, isolated by URL, workspace and external user ID. */
|
|
8
|
-
set(key: TokenKey, record: TokenRecord): Promise<void>;
|
|
9
|
-
/** Remove cached credentials; does not revoke them remotely. */
|
|
10
|
-
delete(key: TokenKey): Promise<void>;
|
|
11
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** Process-local storage. Reuse a client to reuse tokens; no cross-process synchronization. */
|
|
2
|
-
export class InMemoryTokenStore {
|
|
3
|
-
#records = new Map();
|
|
4
|
-
/** Return a copy, or null when absent. */
|
|
5
|
-
async get(key) {
|
|
6
|
-
const record = this.#records.get(JSON.stringify([key.serverUrl, key.workspaceId, key.externalId]));
|
|
7
|
-
return record ? { ...record } : null;
|
|
8
|
-
}
|
|
9
|
-
/** Store a copy, isolated by URL, workspace and external user ID. */
|
|
10
|
-
async set(key, record) {
|
|
11
|
-
this.#records.set(JSON.stringify([key.serverUrl, key.workspaceId, key.externalId]), { ...record });
|
|
12
|
-
}
|
|
13
|
-
/** Remove cached credentials; does not revoke them remotely. */
|
|
14
|
-
async delete(key) {
|
|
15
|
-
this.#records.delete(JSON.stringify([key.serverUrl, key.workspaceId, key.externalId]));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Transport } from "./transport.js";
|
|
2
|
-
import type { TokenKey, TokenStore } from "./types.js";
|
|
3
|
-
export declare class Tokens {
|
|
4
|
-
#private;
|
|
5
|
-
private transport;
|
|
6
|
-
private store;
|
|
7
|
-
private apiKey;
|
|
8
|
-
private base;
|
|
9
|
-
constructor(transport: Transport, store: TokenStore, apiKey: string, base: Omit<TokenKey, "externalId">);
|
|
10
|
-
exclusive<T>(id: string, operation: () => Promise<T>): Promise<T>;
|
|
11
|
-
storage<T>(operation: () => Promise<T>): Promise<T>;
|
|
12
|
-
key(id: string): TokenKey;
|
|
13
|
-
get(id: string, force?: boolean): Promise<string>;
|
|
14
|
-
remove(id: string): Promise<void>;
|
|
15
|
-
revoke(id: string): Promise<void>;
|
|
16
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { Base44PlatformError } from "./errors.js";
|
|
2
|
-
import { object, requiredString, nullableString, badResponse } from "./validation.js";
|
|
3
|
-
export class Tokens {
|
|
4
|
-
transport;
|
|
5
|
-
store;
|
|
6
|
-
apiKey;
|
|
7
|
-
base;
|
|
8
|
-
#generation = new Map();
|
|
9
|
-
#pending = new Map();
|
|
10
|
-
constructor(transport, store, apiKey, base) {
|
|
11
|
-
this.transport = transport;
|
|
12
|
-
this.store = store;
|
|
13
|
-
this.apiKey = apiKey;
|
|
14
|
-
this.base = base;
|
|
15
|
-
}
|
|
16
|
-
async exclusive(id, operation) {
|
|
17
|
-
const prior = this.#pending.get(id);
|
|
18
|
-
const task = (async () => { await prior?.catch(() => { }); return operation(); })();
|
|
19
|
-
this.#pending.set(id, task);
|
|
20
|
-
try {
|
|
21
|
-
return await task;
|
|
22
|
-
}
|
|
23
|
-
finally {
|
|
24
|
-
if (this.#pending.get(id) === task)
|
|
25
|
-
this.#pending.delete(id);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
async storage(operation) {
|
|
29
|
-
try {
|
|
30
|
-
return await operation();
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
throw new Base44PlatformError("token_store_error", "Token storage could not complete the operation.");
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
key(id) { return { ...this.base, externalId: id }; }
|
|
37
|
-
async get(id, force = false) {
|
|
38
|
-
// Capture before joining the queue so concurrent forced renewals share the new token.
|
|
39
|
-
const generation = this.#generation.get(id) ?? 0;
|
|
40
|
-
return this.exclusive(id, async () => {
|
|
41
|
-
const key = this.key(id);
|
|
42
|
-
const held = await this.storage(() => this.store.get(key));
|
|
43
|
-
const now = Date.now();
|
|
44
|
-
if (held && (held.renewAt ?? held.expiresAt) > now && (!force || (this.#generation.get(id) ?? 0) !== generation))
|
|
45
|
-
return held.accessToken;
|
|
46
|
-
const data = object(await this.transport.request("/api/service/user-tokens", "POST", {
|
|
47
|
-
Authorization: this.apiKey, "Content-Type": "application/json",
|
|
48
|
-
}, { service_external_id: id }));
|
|
49
|
-
const lifetime = Number(data.expires_in) * 1000;
|
|
50
|
-
if (!Number.isFinite(lifetime) || lifetime <= 0)
|
|
51
|
-
return badResponse();
|
|
52
|
-
const issuedAt = Date.now();
|
|
53
|
-
const record = {
|
|
54
|
-
accessToken: requiredString(data.access_token), refreshToken: nullableString(data.refresh_token),
|
|
55
|
-
expiresAt: issuedAt + lifetime,
|
|
56
|
-
renewAt: issuedAt + lifetime - Math.min(300_000, lifetime / 2),
|
|
57
|
-
};
|
|
58
|
-
await this.storage(() => this.store.set(key, record));
|
|
59
|
-
this.#generation.set(id, (this.#generation.get(id) ?? 0) + 1);
|
|
60
|
-
return record.accessToken;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
async remove(id) {
|
|
64
|
-
await this.storage(() => this.store.delete(this.key(id)));
|
|
65
|
-
}
|
|
66
|
-
async revoke(id) {
|
|
67
|
-
return this.exclusive(id, async () => {
|
|
68
|
-
const record = await this.storage(() => this.store.get(this.key(id)));
|
|
69
|
-
try {
|
|
70
|
-
if (record?.refreshToken)
|
|
71
|
-
await this.transport.request("/oauth/revoke", "POST", {
|
|
72
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
73
|
-
}, new URLSearchParams({ token: record.refreshToken, client_id: "svc_delegate" }));
|
|
74
|
-
}
|
|
75
|
-
finally {
|
|
76
|
-
await this.remove(id);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { RequestOptions } from "./types.js";
|
|
2
|
-
export declare function checkAbort(signal?: AbortSignal): void;
|
|
3
|
-
export declare function waitFor<T>(promise: Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
4
|
-
export declare class Transport {
|
|
5
|
-
private url;
|
|
6
|
-
private fetcher;
|
|
7
|
-
private timeoutMs;
|
|
8
|
-
constructor(url: string, fetcher: typeof fetch, timeoutMs: number);
|
|
9
|
-
request(path: string, method: string, headers: Record<string, string>, body?: unknown, options?: RequestOptions): Promise<unknown>;
|
|
10
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Base44PlatformError } from "./errors.js";
|
|
2
|
-
import { positive } from "./validation.js";
|
|
3
|
-
export function checkAbort(signal) {
|
|
4
|
-
if (signal?.aborted)
|
|
5
|
-
throw new Base44PlatformError("aborted", "The request was cancelled.");
|
|
6
|
-
}
|
|
7
|
-
export async function waitFor(promise, signal) {
|
|
8
|
-
checkAbort(signal);
|
|
9
|
-
if (!signal)
|
|
10
|
-
return promise;
|
|
11
|
-
let abort = () => { };
|
|
12
|
-
try {
|
|
13
|
-
return await Promise.race([promise, new Promise((_, reject) => {
|
|
14
|
-
abort = () => reject(new Base44PlatformError("aborted", "The request was cancelled."));
|
|
15
|
-
signal.addEventListener("abort", abort, { once: true });
|
|
16
|
-
})]);
|
|
17
|
-
}
|
|
18
|
-
finally {
|
|
19
|
-
signal.removeEventListener("abort", abort);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export class Transport {
|
|
23
|
-
url;
|
|
24
|
-
fetcher;
|
|
25
|
-
timeoutMs;
|
|
26
|
-
constructor(url, fetcher, timeoutMs) {
|
|
27
|
-
this.url = url;
|
|
28
|
-
this.fetcher = fetcher;
|
|
29
|
-
this.timeoutMs = timeoutMs;
|
|
30
|
-
}
|
|
31
|
-
async request(path, method, headers, body, options = {}) {
|
|
32
|
-
checkAbort(options.signal);
|
|
33
|
-
const timeoutMs = positive(options.timeoutMs ?? this.timeoutMs);
|
|
34
|
-
const controller = new AbortController();
|
|
35
|
-
const abort = () => controller.abort();
|
|
36
|
-
options.signal?.addEventListener("abort", abort, { once: true });
|
|
37
|
-
const timer = setTimeout(abort, timeoutMs);
|
|
38
|
-
try {
|
|
39
|
-
const response = await this.fetcher(`${this.url}${path}`, {
|
|
40
|
-
method, headers, signal: controller.signal, redirect: "error", cache: "no-store",
|
|
41
|
-
body: body === undefined ? undefined : body instanceof URLSearchParams ? body : JSON.stringify(body),
|
|
42
|
-
});
|
|
43
|
-
if (!response.ok)
|
|
44
|
-
throw new Base44PlatformError("http_error", `Platform request failed (HTTP ${response.status}).`, response.status);
|
|
45
|
-
const text = await response.text();
|
|
46
|
-
if (!text.trim())
|
|
47
|
-
return undefined;
|
|
48
|
-
try {
|
|
49
|
-
return JSON.parse(text);
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
throw new Base44PlatformError("invalid_response", "The platform returned invalid JSON.");
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
if (error instanceof Base44PlatformError)
|
|
57
|
-
throw error;
|
|
58
|
-
if (options.signal?.aborted)
|
|
59
|
-
throw new Base44PlatformError("aborted", "The request was cancelled.");
|
|
60
|
-
if (controller.signal.aborted)
|
|
61
|
-
throw new Base44PlatformError("timeout", "The request timed out; the server operation may still have completed.");
|
|
62
|
-
throw new Base44PlatformError("network_error", "The platform request could not be completed.");
|
|
63
|
-
}
|
|
64
|
-
finally {
|
|
65
|
-
clearTimeout(timer);
|
|
66
|
-
options.signal?.removeEventListener("abort", abort);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/** Per-call controls. Cancellation does not roll back an accepted server operation. */
|
|
2
|
-
export interface RequestOptions {
|
|
3
|
-
/** Abort this caller's wait and HTTP request. Shared token minting may finish. */
|
|
4
|
-
signal?: AbortSignal;
|
|
5
|
-
/** HTTP timeout in milliseconds; overrides the method default. Must be positive. */
|
|
6
|
-
timeoutMs?: number;
|
|
7
|
-
}
|
|
8
|
-
/** Persisted server credential. Never expose this record to a browser or logs. */
|
|
9
|
-
export interface TokenRecord {
|
|
10
|
-
/** Opaque Base44 service-user access token. */
|
|
11
|
-
accessToken: string;
|
|
12
|
-
/** Refresh credential used only for revocation; null if not issued. */
|
|
13
|
-
refreshToken: string | null;
|
|
14
|
-
/** Access-token expiry, Unix epoch milliseconds. */
|
|
15
|
-
expiresAt: number;
|
|
16
|
-
/** Renew at this epoch millisecond timestamp; defaults to expiresAt when absent. */
|
|
17
|
-
renewAt?: number;
|
|
18
|
-
}
|
|
19
|
-
/** Storage namespace. All three fields participate in isolation. */
|
|
20
|
-
export interface TokenKey {
|
|
21
|
-
/** Normalized configured platform URL (no trailing slash). */
|
|
22
|
-
serverUrl: string;
|
|
23
|
-
/** Configured Base44 workspace ID, not an external user ID. */
|
|
24
|
-
workspaceId: string;
|
|
25
|
-
/** Caller-owned ID, trimmed and lowercased to match provisioning. */
|
|
26
|
-
externalId: string;
|
|
27
|
-
}
|
|
28
|
-
/** Server-side storage adapter; operations must complete before their promise resolves. */
|
|
29
|
-
export interface TokenStore {
|
|
30
|
-
/** Return a record or null on a miss. Do not log credentials. */
|
|
31
|
-
get(key: TokenKey): Promise<TokenRecord | null>;
|
|
32
|
-
/** Persist the complete record, replacing the previous one for this key. */
|
|
33
|
-
set(key: TokenKey, record: TokenRecord): Promise<void>;
|
|
34
|
-
/** Remove the record only; do not delete or provision the user. Missing is a no-op. */
|
|
35
|
-
delete(key: TokenKey): Promise<void>;
|
|
36
|
-
}
|
|
37
|
-
/** Server-only platform client configuration. */
|
|
38
|
-
export interface PlatformClientConfig {
|
|
39
|
-
/** Workspace key with service_users:provision and user_tokens:mint permissions. */
|
|
40
|
-
apiKey: string;
|
|
41
|
-
/** Workspace for app operations. Must match the workspace that owns apiKey. */
|
|
42
|
-
workspaceId: string;
|
|
43
|
-
/** Trusted server configuration; defaults to https://base44.app. Never use request input. */
|
|
44
|
-
serverUrl?: string;
|
|
45
|
-
/** Defaults to a private in-memory store per client instance. */
|
|
46
|
-
tokenStore?: TokenStore;
|
|
47
|
-
/** Fetch-compatible transport; defaults to globalThis.fetch. */
|
|
48
|
-
fetch?: typeof globalThis.fetch;
|
|
49
|
-
/** Ordinary request timeout in milliseconds; default 30000. */
|
|
50
|
-
timeoutMs?: number;
|
|
51
|
-
/** Create/deploy timeout in milliseconds; default 120000. */
|
|
52
|
-
buildTimeoutMs?: number;
|
|
53
|
-
}
|
|
54
|
-
/** Controls acquisition of a server credential for legacy integrations. */
|
|
55
|
-
export interface TokenRequestOptions {
|
|
56
|
-
/** Abort this caller’s wait; shared acquisition may finish and populate storage. */
|
|
57
|
-
signal?: AbortSignal;
|
|
58
|
-
/** Re-mint even if cached; default false. Never provisions a missing user. */
|
|
59
|
-
forceRefresh?: boolean;
|
|
60
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare function invalid(message: string): never;
|
|
2
|
-
export declare function identifier(value: string): string;
|
|
3
|
-
export declare function externalId(value: string): string;
|
|
4
|
-
export declare function positive(value: number): number;
|
|
5
|
-
export declare function object(value: unknown): Record<string, unknown>;
|
|
6
|
-
export declare function badResponse(): never;
|
|
7
|
-
export declare function requiredString(value: unknown): string;
|
|
8
|
-
export declare function nullableString(value: unknown): string | null;
|
|
9
|
-
export declare function boolean(value: unknown): boolean;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Base44PlatformError } from "./errors.js";
|
|
2
|
-
export function invalid(message) {
|
|
3
|
-
throw new Base44PlatformError("invalid_argument", message);
|
|
4
|
-
}
|
|
5
|
-
export function identifier(value) {
|
|
6
|
-
if (typeof value !== "string" || !/^[A-Za-z0-9_-]+$/.test(value))
|
|
7
|
-
invalid("Expected a nonempty resource ID containing letters, digits, underscores or hyphens.");
|
|
8
|
-
return encodeURIComponent(value);
|
|
9
|
-
}
|
|
10
|
-
export function externalId(value) {
|
|
11
|
-
if (typeof value !== "string" || !value.trim() || value.trim() === "." || value.trim() === "..")
|
|
12
|
-
invalid("Expected a nonempty external user ID, excluding dot path segments.");
|
|
13
|
-
return value.trim().toLowerCase();
|
|
14
|
-
}
|
|
15
|
-
export function positive(value) {
|
|
16
|
-
if (!Number.isFinite(value) || value <= 0)
|
|
17
|
-
invalid("Expected a positive finite number.");
|
|
18
|
-
return value;
|
|
19
|
-
}
|
|
20
|
-
export function object(value) {
|
|
21
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
22
|
-
return badResponse();
|
|
23
|
-
return value;
|
|
24
|
-
}
|
|
25
|
-
export function badResponse() {
|
|
26
|
-
throw new Base44PlatformError("invalid_response", "The platform returned an unexpected response shape.");
|
|
27
|
-
}
|
|
28
|
-
export function requiredString(value) {
|
|
29
|
-
return typeof value === "string" && value.length > 0 ? value : badResponse();
|
|
30
|
-
}
|
|
31
|
-
export function nullableString(value) {
|
|
32
|
-
return value == null ? null : typeof value === "string" ? value : badResponse();
|
|
33
|
-
}
|
|
34
|
-
export function boolean(value) {
|
|
35
|
-
return typeof value === "boolean" ? value : badResponse();
|
|
36
|
-
}
|