deepspace 0.7.0 → 0.8.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.
- package/CHANGELOG.md +30 -0
- package/README.md +22 -8
- package/dist/cli.js +10306 -5256
- package/dist/cli.js.map +1 -1
- package/dist/feature-installer.js +638 -0
- package/dist/feature-installer.js.map +1 -0
- package/dist/index.d.ts +107 -117
- package/dist/index.js +610 -779
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +403 -167
- package/dist/server.js +498 -367
- package/dist/server.js.map +1 -1
- package/dist/testing.d.ts +115 -0
- package/dist/testing.js +3 -3
- package/dist/testing.js.map +1 -1
- package/dist/worker.d.ts +397 -160
- package/dist/worker.js +506 -367
- package/dist/worker.js.map +1 -1
- package/features/ai-chat/feature.json +2 -0
- package/features/ai-chat/src/AiChatPage.tsx +2 -3
- package/features/ai-chat/src/ChatPanel.messages.tsx +344 -0
- package/features/ai-chat/src/ChatPanel.stream.ts +397 -0
- package/features/ai-chat/src/ChatPanel.tsx +158 -862
- package/features/ai-chat/src/__tests__/ChatPanel.stream.test.ts +163 -0
- package/features/canvas/src/CanvasListPage.tsx +1 -1
- package/features/docs/feature.json +4 -8
- package/features/docs/src/DocsEditorPage.tsx +33 -326
- package/features/docs/src/DocsListPage.tsx +33 -29
- package/features/docs/src/InviteDialog.tsx +11 -40
- package/features/docs/src/__tests__/docs-presence-access.test.ts +71 -0
- package/features/docs/src/docs-library-types.ts +28 -3
- package/features/docs/src/docs-ui.css +1 -4
- package/features/docs/src/use-docs-presence-access.ts +330 -0
- package/features/file-attachments/feature.json +2 -2
- package/features/file-attachments/src/AttachmentPreview.tsx +428 -0
- package/features/file-attachments/src/AttachmentsPage.tsx +100 -462
- package/features/file-attachments/src/useFilePreview.ts +54 -68
- package/features/file-manager/src/FileManagerPage.tsx +1 -1
- package/features/integration-test/src/integration.spec.ts +1 -1
- package/features/items/feature.json +1 -5
- package/features/items/src/ItemsPage.tsx +207 -135
- package/features/landing/feature.json +3 -0
- package/features/landing/src/LandingPage.tsx +4 -18
- package/features/leaderboard/feature.json +1 -5
- package/features/leaderboard/src/LeaderboardPage.tsx +333 -198
- package/features/messaging/feature.json +0 -4
- package/features/messaging/src/ChatMultiPage.tsx +1 -3
- package/features/messaging/src/ChatPage.tsx +1 -3
- package/features/messaging/src/components/chat/MessageActionSheet.tsx +40 -16
- package/features/search-bar/feature.json +8 -3
- package/features/search-bar/src/SearchOverlay.tsx +108 -252
- package/features/search-bar/src/__tests__/search-model.test.ts +40 -0
- package/features/search-bar/src/search-model.ts +223 -0
- package/features/tasks/src/TasksPage.tsx +3 -3
- package/features/topbar/src/Topbar.tsx +0 -17
- package/package.json +1 -2
- package/features/docs/src/docs-favorites.ts +0 -18
- package/features/docs/src/use-yjs-room-with-awareness.ts +0 -289
- package/features/file-attachments/src/attachments-constants.ts +0 -9
- package/features/items/src/items-constants.ts +0 -10
- package/features/leaderboard/src/leaderboard-constants.ts +0 -21
- package/features/messaging/src/components/chat/ReactionPicker.tsx +0 -2
- package/scripts/add-feature.cjs +0 -807
package/dist/server.d.ts
CHANGED
|
@@ -2,16 +2,104 @@ import { LanguageModel, ToolSet, ModelMessage } from 'ai';
|
|
|
2
2
|
import * as Y from 'yjs';
|
|
3
3
|
import * as zod_v4_core from 'zod/v4/core';
|
|
4
4
|
import * as zod from 'zod';
|
|
5
|
+
import * as better_auth_plugins from 'better-auth/plugins';
|
|
5
6
|
import * as better_auth from 'better-auth';
|
|
6
7
|
import { betterAuth } from 'better-auth';
|
|
7
|
-
import * as better_auth_plugins from 'better-auth/plugins';
|
|
8
8
|
import { Context } from 'hono';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Wildcard-aware CORS origin matching for the platform workers.
|
|
12
|
+
*
|
|
13
|
+
* Hono's array form of `cors({ origin: [...] })` is an exact `includes()` — it
|
|
14
|
+
* never expands `*`. Every worker that listed `https://*.app.space` or
|
|
15
|
+
* `http://localhost:*` in an array had a dead entry: the wildcard rows matched
|
|
16
|
+
* nothing, silently narrowing the effective CORS surface to the literal
|
|
17
|
+
* entries. This helper is the single implementation both the api and deploy
|
|
18
|
+
* workers pass to Hono's function-form `origin`, so the pattern semantics
|
|
19
|
+
* can't drift between them.
|
|
20
|
+
*
|
|
21
|
+
* `*` stands for exactly one host label or a port: it never crosses a dot or
|
|
22
|
+
* a slash, so `https://*.app.space` matches `https://x.app.space` but neither
|
|
23
|
+
* `https://a.b.app.space` nor `https://x.app.space.evil.com`.
|
|
24
|
+
*/
|
|
25
|
+
declare function matchOrigin(origin: string, patterns: string[]): string | null;
|
|
26
|
+
/**
|
|
27
|
+
* The platform's standard browser-origin allow-list, derived from the
|
|
28
|
+
* environment's apexes so a second constellation (staging) trusts its own
|
|
29
|
+
* hosts and only its own. Both values are explicit deployment-plane config.
|
|
30
|
+
* Dedupes for environments that serve both roles from one apex.
|
|
31
|
+
*/
|
|
32
|
+
declare function platformCorsPatterns(env: {
|
|
33
|
+
APP_DOMAIN: string;
|
|
34
|
+
PLATFORM_DOMAIN: string;
|
|
35
|
+
}): string[];
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Deployed-app quota defaults — the ONE copy.
|
|
39
|
+
*
|
|
40
|
+
* Two workers use these numbers for different jobs: the deploy worker
|
|
41
|
+
* ENFORCES them at registration time, the api worker DISPLAYS them via
|
|
42
|
+
* GET /api/plan-limits. They used to be independent literal sets (plus the
|
|
43
|
+
* same numbers again in six wrangler [vars] blocks as overrides) and had
|
|
44
|
+
* already diverged once — the display copy was missing the admin tier
|
|
45
|
+
* entirely. The env vars remain the per-plane override mechanism; only the
|
|
46
|
+
* fallbacks live here.
|
|
47
|
+
*/
|
|
48
|
+
declare const DEPLOYED_APPS_DEFAULTS: {
|
|
49
|
+
readonly free: 1;
|
|
50
|
+
readonly starter: 4;
|
|
51
|
+
readonly premium: 10;
|
|
52
|
+
readonly admin: 100;
|
|
53
|
+
};
|
|
54
|
+
/** Parse a quota env override; anything non-integer/negative = fallback. */
|
|
55
|
+
declare function parseQuotaLimit(raw: string | undefined, fallback: number): number;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The ONE registry client. Every platform worker reaches the app-registry
|
|
59
|
+
* Durable Object (hosted by the deploy worker, singleton `v1:global`) through
|
|
60
|
+
* a cross-script REGISTRY binding — and before this module, each of the five
|
|
61
|
+
* workers hand-rolled its own copy of the same mechanics: the instance name
|
|
62
|
+
* appeared in 6 places, the `https://registry/` URL in 6, `APP_ID_RE` in 5,
|
|
63
|
+
* and `RegistryClientError` + `registryErrorJson` existed byte-identical in
|
|
64
|
+
* two workers. Copies that must agree and nothing enforcing it.
|
|
65
|
+
*
|
|
66
|
+
* This module owns the MECHANICS: instance name, stub lookup, the wire call,
|
|
67
|
+
* the error type, and the standard route mapping. Each worker still declares
|
|
68
|
+
* its own typed convenience wrapper listing only the actions it uses — that
|
|
69
|
+
* subset is genuinely per-worker; the plumbing is not.
|
|
70
|
+
*/
|
|
71
|
+
/** The singleton registry instance — one DO holds every app/route/collaborator. */
|
|
72
|
+
declare const REGISTRY_INSTANCE = "v1:global";
|
|
73
|
+
/** App id shape: a ULID-minted `app_…` id, or a legacy name-as-id. */
|
|
74
|
+
declare const APP_ID_RE: RegExp;
|
|
75
|
+
/** ONLY a ULID-minted id — surfaces that must not accept a legacy name. */
|
|
76
|
+
declare const STRICT_APP_ID_RE: RegExp;
|
|
77
|
+
declare class RegistryClientError extends Error {
|
|
78
|
+
readonly code: string;
|
|
79
|
+
readonly status: number;
|
|
80
|
+
constructor(message: string, code: string, status: number);
|
|
81
|
+
}
|
|
82
|
+
declare function registryStub(ns: DurableObjectNamespace): DurableObjectStub;
|
|
83
|
+
/**
|
|
84
|
+
* One registry action over the wire. Non-2xx answers throw
|
|
85
|
+
* {@link RegistryClientError} carrying the DO's structured `code` (or
|
|
86
|
+
* `'error'` for a transport-shaped body) — callers distinguish a registry-
|
|
87
|
+
* REPORTED miss (`code === 'not_found'`) from an outage by that code, never
|
|
88
|
+
* by treating every throw as "not found".
|
|
89
|
+
*/
|
|
90
|
+
declare function callRegistry<T>(stub: DurableObjectStub, body: {
|
|
91
|
+
action: string;
|
|
92
|
+
} & Record<string, unknown>): Promise<T>;
|
|
93
|
+
/** Standard mapping of a registry failure onto a route response. */
|
|
94
|
+
declare function registryErrorJson(c: {
|
|
95
|
+
json: (body: unknown, status?: number) => Response;
|
|
96
|
+
}, err: unknown): Response;
|
|
97
|
+
|
|
10
98
|
/**
|
|
11
99
|
* Tools API Types and Definitions
|
|
12
100
|
*
|
|
13
101
|
* MCP-like interface for agent tool calls.
|
|
14
|
-
* Built-in tools for
|
|
102
|
+
* Built-in tools for records, schemas, users, and Yjs documents.
|
|
15
103
|
*/
|
|
16
104
|
interface ToolSchema {
|
|
17
105
|
name: string;
|
|
@@ -59,7 +147,7 @@ declare const DEFAULT_QUERY_LIMIT = 50;
|
|
|
59
147
|
*/
|
|
60
148
|
declare function applyAiToolDefaults(toolName: string, params: Record<string, unknown>): Record<string, unknown>;
|
|
61
149
|
/**
|
|
62
|
-
* Built-in tool definitions for
|
|
150
|
+
* Built-in tool definitions for record, schema, user, and Yjs operations.
|
|
63
151
|
*/
|
|
64
152
|
declare const BUILT_IN_TOOLS: ToolSchema[];
|
|
65
153
|
|
|
@@ -119,6 +207,95 @@ type ScopedR2Handler = (request: Request, url: URL, bucket: R2Bucket, auth: Scop
|
|
|
119
207
|
*/
|
|
120
208
|
declare function createScopedR2Handler(config: ScopedR2Config): ScopedR2Handler;
|
|
121
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Shared type definitions for the DeepSpace SDK
|
|
212
|
+
*
|
|
213
|
+
* Types used by both client-side SDK and server-side workers.
|
|
214
|
+
*/
|
|
215
|
+
type ColumnInterpretation = {
|
|
216
|
+
kind: 'plain';
|
|
217
|
+
} | {
|
|
218
|
+
kind: 'currency';
|
|
219
|
+
symbol: string;
|
|
220
|
+
decimals: number;
|
|
221
|
+
} | {
|
|
222
|
+
kind: 'date';
|
|
223
|
+
format?: string;
|
|
224
|
+
} | {
|
|
225
|
+
kind: 'datetime';
|
|
226
|
+
format?: string;
|
|
227
|
+
} | {
|
|
228
|
+
kind: 'boolean';
|
|
229
|
+
trueLabel?: string;
|
|
230
|
+
falseLabel?: string;
|
|
231
|
+
} | {
|
|
232
|
+
kind: 'percent';
|
|
233
|
+
decimals?: number;
|
|
234
|
+
} | {
|
|
235
|
+
kind: 'select';
|
|
236
|
+
options: string[];
|
|
237
|
+
} | {
|
|
238
|
+
kind: 'multiselect';
|
|
239
|
+
options: string[];
|
|
240
|
+
} | {
|
|
241
|
+
kind: 'url';
|
|
242
|
+
} | {
|
|
243
|
+
kind: 'email';
|
|
244
|
+
} | {
|
|
245
|
+
kind: 'json';
|
|
246
|
+
} | {
|
|
247
|
+
kind: 'reference';
|
|
248
|
+
targetTable: string;
|
|
249
|
+
displayColumn: string;
|
|
250
|
+
};
|
|
251
|
+
interface ColumnDefinition {
|
|
252
|
+
/** Stable ID override (survives renames). Falls back to `col_{name}`. */
|
|
253
|
+
id?: string;
|
|
254
|
+
name: string;
|
|
255
|
+
storage: 'number' | 'text';
|
|
256
|
+
interpretation: ColumnInterpretation | string;
|
|
257
|
+
expression?: string;
|
|
258
|
+
userBound?: boolean;
|
|
259
|
+
immutable?: boolean;
|
|
260
|
+
required?: boolean;
|
|
261
|
+
default?: unknown;
|
|
262
|
+
timestampTrigger?: {
|
|
263
|
+
field: string;
|
|
264
|
+
value?: unknown;
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
type PermissionLevel = boolean | 'own' | 'unclaimed-or-own' | 'collaborator' | 'team' | 'access' | 'published' | 'shared';
|
|
268
|
+
interface RolePermissions {
|
|
269
|
+
read: PermissionLevel;
|
|
270
|
+
/** Create has no existing record to evaluate, so it is an explicit grant. */
|
|
271
|
+
create: boolean;
|
|
272
|
+
update: PermissionLevel;
|
|
273
|
+
delete: PermissionLevel;
|
|
274
|
+
/** If set, only these columns can be updated by this role. */
|
|
275
|
+
writableFields?: string[];
|
|
276
|
+
}
|
|
277
|
+
interface CollectionSchema {
|
|
278
|
+
name: string;
|
|
279
|
+
/** Every collection is stored in typed SQL columns. */
|
|
280
|
+
columns: ColumnDefinition[];
|
|
281
|
+
/** Composite uniqueness constraint (for example `['userId', 'taskId']`). */
|
|
282
|
+
uniqueOn?: string[];
|
|
283
|
+
/** Ownership column; defaults to the row creator. */
|
|
284
|
+
ownerField?: string;
|
|
285
|
+
/** Column containing a JSON array of collaborator user ids. */
|
|
286
|
+
collaboratorsField?: string;
|
|
287
|
+
/** Column containing the team id used by team permission rules. */
|
|
288
|
+
teamField?: string;
|
|
289
|
+
/** A string is public when equal to `public`; an object supplies an exact value. */
|
|
290
|
+
visibilityField?: string | {
|
|
291
|
+
field: string;
|
|
292
|
+
value: unknown;
|
|
293
|
+
};
|
|
294
|
+
/** Permissions per role; `*` is the catch-all role. */
|
|
295
|
+
permissions: Record<string, RolePermissions>;
|
|
296
|
+
/** Default role assigned on the `users` collection. */
|
|
297
|
+
defaultRole?: string;
|
|
298
|
+
}
|
|
122
299
|
interface Query {
|
|
123
300
|
collection: string;
|
|
124
301
|
where?: Record<string, unknown>;
|
|
@@ -397,7 +574,7 @@ type ActionHandler<TEnv = Record<string, unknown>> = (ctx: ActionContext<TEnv>)
|
|
|
397
574
|
* in deployed apps.
|
|
398
575
|
*
|
|
399
576
|
* 2. **HTTPS URL** (`env.API_WORKER_URL` / `env.PLATFORM_WORKER_URL`) — the
|
|
400
|
-
* fallback used in local development. `deepspace dev` writes these
|
|
577
|
+
* fallback used in local development. `deepspace dev start` writes these
|
|
401
578
|
* into `.dev.vars`, which `wrangler dev` exposes as env vars. Service
|
|
402
579
|
* bindings don't work cross-process under `wrangler dev` for SDK apps,
|
|
403
580
|
* so the URL is the only working path in dev.
|
|
@@ -415,7 +592,7 @@ type ActionHandler<TEnv = Record<string, unknown>> = (ctx: ActionContext<TEnv>)
|
|
|
415
592
|
* History: a previous in-tree helper folded the binding/URL fallback into
|
|
416
593
|
* the AI module's `resolveTransport`. Inline call sites in the starter
|
|
417
594
|
* template (integrations, files, debug) used `c.env.X.fetch(...)` directly,
|
|
418
|
-
* which broke `npx deepspace dev` for any app calling those routes — the
|
|
595
|
+
* which broke `npx deepspace dev start` for any app calling those routes — the
|
|
419
596
|
* binding is undefined locally, so the fetch threw. These helpers
|
|
420
597
|
* standardize on the same shape `resolveTransport` had, so every upstream
|
|
421
598
|
* call works in both dev and prod.
|
|
@@ -536,13 +713,13 @@ declare function buildCronContext(env: CronEnv, ownerUserId: string, roomId?: st
|
|
|
536
713
|
* - Service binding `env.API_WORKER` (Cloudflare Fetcher) — preferred in
|
|
537
714
|
* production if the app has declared the binding in wrangler.toml.
|
|
538
715
|
* - HTTPS URL `env.API_WORKER_URL` — used in local dev and in production
|
|
539
|
-
* for apps that don't declare the binding. `deepspace dev` writes this
|
|
716
|
+
* for apps that don't declare the binding. `deepspace dev start` writes this
|
|
540
717
|
* into `.dev.vars` automatically.
|
|
541
718
|
*
|
|
542
719
|
* Auth is automatic by default:
|
|
543
720
|
* - For server-side autonomous calls (cron, DO alarms, background agents),
|
|
544
721
|
* the helper reads the long-lived `env.APP_OWNER_JWT` minted at deploy
|
|
545
|
-
* time (or by `deepspace dev` in local development) and uses it for the
|
|
722
|
+
* time (or by `deepspace dev start` in local development) and uses it for the
|
|
546
723
|
* proxy auth header. The owner is billed automatically via the JWT sub.
|
|
547
724
|
* - For user-initiated calls (e.g. an `/api/ai/chat` route handling a
|
|
548
725
|
* browser request), pass `options.authToken` explicitly with the user's
|
|
@@ -569,7 +746,7 @@ type DeepSpaceModelFactory = (modelId: string) => LanguageModel;
|
|
|
569
746
|
type Provider = 'anthropic' | 'openai' | 'cerebras';
|
|
570
747
|
interface DeepSpaceAIEnv extends ApiWorkerEnv {
|
|
571
748
|
/**
|
|
572
|
-
* Long-lived owner-scoped JWT minted at deploy time (or by `deepspace dev`).
|
|
749
|
+
* Long-lived owner-scoped JWT minted at deploy time (or by `deepspace dev start`).
|
|
573
750
|
* Used as the default proxy auth token when `options.authToken` is absent.
|
|
574
751
|
* Bills the app owner.
|
|
575
752
|
*/
|
|
@@ -646,10 +823,9 @@ declare function composioTools(env: ApiWorkerEnv, options: ComposioToolsOptions)
|
|
|
646
823
|
* own bundle. The platform holds the binding; consumers call this
|
|
647
824
|
* helper to get PNG bytes for a URL.
|
|
648
825
|
*
|
|
649
|
-
* The platform enforces
|
|
650
|
-
*
|
|
651
|
-
*
|
|
652
|
-
* and surface their own fallback UX.
|
|
826
|
+
* The platform enforces HTTPS, a DeepSpace host allowlist, a per-app rate
|
|
827
|
+
* limit, and one fixed viewport-only capture profile. Returns `null` on any
|
|
828
|
+
* non-2xx — callers should treat that as "no preview available".
|
|
653
829
|
*
|
|
654
830
|
* Auth is the same HMAC-of-appId pattern `/internal/files` uses:
|
|
655
831
|
* x-app-identity-token = hmac(PLATFORM_IDENTITY_SECRET, DEEPSPACE_APP_ID)
|
|
@@ -659,16 +835,6 @@ declare function composioTools(env: ApiWorkerEnv, options: ComposioToolsOptions)
|
|
|
659
835
|
* so this helper is a thin wrapper — no extra secrets to manage.
|
|
660
836
|
*/
|
|
661
837
|
|
|
662
|
-
interface ScreenshotOptions {
|
|
663
|
-
url: string;
|
|
664
|
-
viewport?: {
|
|
665
|
-
width: number;
|
|
666
|
-
height: number;
|
|
667
|
-
};
|
|
668
|
-
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2';
|
|
669
|
-
timeoutMs?: number;
|
|
670
|
-
fullPage?: boolean;
|
|
671
|
-
}
|
|
672
838
|
interface ScreenshotEnv extends PlatformWorkerEnv {
|
|
673
839
|
/** Immutable app id — the identity the platform verifies (HMAC input). */
|
|
674
840
|
DEEPSPACE_APP_ID: string;
|
|
@@ -682,14 +848,13 @@ interface ScreenshotResult {
|
|
|
682
848
|
contentType: string;
|
|
683
849
|
}
|
|
684
850
|
/**
|
|
685
|
-
* Capture a screenshot of `
|
|
851
|
+
* Capture a screenshot of `url` and return the PNG bytes.
|
|
686
852
|
*
|
|
687
853
|
* Returns null on capture failure (target unreachable, timeout, BR
|
|
688
|
-
* binding misconfigured platform-side). The platform
|
|
689
|
-
*
|
|
690
|
-
* and surface their own UX fallback.
|
|
854
|
+
* binding misconfigured platform-side). The platform logs a generic failure
|
|
855
|
+
* without target details; callers should surface their own fallback UX.
|
|
691
856
|
*/
|
|
692
|
-
declare function captureScreenshot(env: ScreenshotEnv,
|
|
857
|
+
declare function captureScreenshot(env: ScreenshotEnv, url: string): Promise<ScreenshotResult | null>;
|
|
693
858
|
|
|
694
859
|
/**
|
|
695
860
|
* Chat context pipeline — keeps the per-request payload to the LLM bounded.
|
|
@@ -833,23 +998,8 @@ declare function makeDefaultSummarizer(env: DeepSpaceAIEnv, options?: {
|
|
|
833
998
|
* The tools API returns records as `{ recordId, data, createdAt, updatedAt }`
|
|
834
999
|
* envelopes; helpers below flatten them into ChatRow / ChatMessageRow.
|
|
835
1000
|
*/
|
|
836
|
-
/**
|
|
837
|
-
* Canonical chat row.
|
|
838
|
-
*
|
|
839
|
-
* `recordId` is the primary identifier — same envelope shape as every
|
|
840
|
-
* other DeepSpace data type (records.* tools, useQuery results, etc.).
|
|
841
|
-
*
|
|
842
|
-
* `id` is kept as a deprecated alias so existing callers don't break,
|
|
843
|
-
* but every new caller should prefer `recordId`. Without this rename
|
|
844
|
-
* an integrator who reads `chat.recordId` (the obvious thing given the
|
|
845
|
-
* rest of the SDK) silently gets `undefined`, then ships code that
|
|
846
|
-
* sends `{"chatId": undefined}` to `/api/ai/chat` and gets back a 400
|
|
847
|
-
* with a misleading error.
|
|
848
|
-
*/
|
|
849
1001
|
type ChatRow = {
|
|
850
1002
|
recordId: string;
|
|
851
|
-
/** @deprecated Use `recordId`. Retained for backward compatibility. */
|
|
852
|
-
id: string;
|
|
853
1003
|
userId: string;
|
|
854
1004
|
title: string;
|
|
855
1005
|
model?: string;
|
|
@@ -860,8 +1010,6 @@ type ChatRow = {
|
|
|
860
1010
|
};
|
|
861
1011
|
type ChatMessageRow = {
|
|
862
1012
|
recordId: string;
|
|
863
|
-
/** @deprecated Use `recordId`. Retained for backward compatibility. */
|
|
864
|
-
id: string;
|
|
865
1013
|
chatId: string;
|
|
866
1014
|
userId: string;
|
|
867
1015
|
role: 'user' | 'assistant' | 'system';
|
|
@@ -1412,7 +1560,7 @@ declare abstract class BaseRoom<E = Record<string, unknown>> {
|
|
|
1412
1560
|
private handleWebSocketUpgrade;
|
|
1413
1561
|
webSocketMessage(ws: WebSocket, message: ArrayBuffer | string): Promise<void>;
|
|
1414
1562
|
webSocketClose(ws: WebSocket, _code: number, _reason: string): Promise<void>;
|
|
1415
|
-
webSocketError(
|
|
1563
|
+
webSocketError(_ws: WebSocket, error: unknown): Promise<void>;
|
|
1416
1564
|
alarm(): Promise<void>;
|
|
1417
1565
|
/**
|
|
1418
1566
|
* Called when a new WebSocket connects (after auth parsing).
|
|
@@ -1523,8 +1671,6 @@ interface ConnectionAttachment extends UserAttachment {
|
|
|
1523
1671
|
subscriptions: Subscription[];
|
|
1524
1672
|
/** Yjs docs this connection is editing */
|
|
1525
1673
|
yjsSubscriptions: YjsSubscription[];
|
|
1526
|
-
/** Yjs client ID for awareness */
|
|
1527
|
-
yjsClientId?: number;
|
|
1528
1674
|
/** Client-side Yjs awareness clientId (extracted from first awareness message) */
|
|
1529
1675
|
awarenessClientId?: number;
|
|
1530
1676
|
}
|
|
@@ -1534,63 +1680,7 @@ interface ConnectionAttachment extends UserAttachment {
|
|
|
1534
1680
|
*
|
|
1535
1681
|
* All collections use typed SQL columns. No document-mode / fields-based storage.
|
|
1536
1682
|
*/
|
|
1537
|
-
|
|
1538
|
-
kind: 'plain';
|
|
1539
|
-
} | {
|
|
1540
|
-
kind: 'currency';
|
|
1541
|
-
symbol: string;
|
|
1542
|
-
decimals: number;
|
|
1543
|
-
} | {
|
|
1544
|
-
kind: 'date';
|
|
1545
|
-
format?: string;
|
|
1546
|
-
} | {
|
|
1547
|
-
kind: 'datetime';
|
|
1548
|
-
format?: string;
|
|
1549
|
-
} | {
|
|
1550
|
-
kind: 'boolean';
|
|
1551
|
-
trueLabel?: string;
|
|
1552
|
-
falseLabel?: string;
|
|
1553
|
-
} | {
|
|
1554
|
-
kind: 'percent';
|
|
1555
|
-
decimals?: number;
|
|
1556
|
-
} | {
|
|
1557
|
-
kind: 'select';
|
|
1558
|
-
options: string[];
|
|
1559
|
-
} | {
|
|
1560
|
-
kind: 'multiselect';
|
|
1561
|
-
options: string[];
|
|
1562
|
-
} | {
|
|
1563
|
-
kind: 'url';
|
|
1564
|
-
} | {
|
|
1565
|
-
kind: 'email';
|
|
1566
|
-
} | {
|
|
1567
|
-
kind: 'json';
|
|
1568
|
-
} | {
|
|
1569
|
-
kind: 'reference';
|
|
1570
|
-
targetTable: string;
|
|
1571
|
-
displayColumn: string;
|
|
1572
|
-
};
|
|
1573
|
-
interface ColumnDefinition {
|
|
1574
|
-
/** Stable ID override (survives renames). Falls back to `col_{name}`. */
|
|
1575
|
-
id?: string;
|
|
1576
|
-
name: string;
|
|
1577
|
-
storage: 'number' | 'text';
|
|
1578
|
-
interpretation: ColumnInterpretation | string;
|
|
1579
|
-
expression?: string;
|
|
1580
|
-
/** Auto-populate with current user ID on create. */
|
|
1581
|
-
userBound?: boolean;
|
|
1582
|
-
/** Cannot be changed after initial creation. */
|
|
1583
|
-
immutable?: boolean;
|
|
1584
|
-
/** Must be provided on create (non-null). */
|
|
1585
|
-
required?: boolean;
|
|
1586
|
-
/** Default value if not provided on create. */
|
|
1587
|
-
default?: unknown;
|
|
1588
|
-
/** Auto-set ISO timestamp when the named field changes (optionally to a specific value). */
|
|
1589
|
-
timestampTrigger?: {
|
|
1590
|
-
field: string;
|
|
1591
|
-
value?: unknown;
|
|
1592
|
-
};
|
|
1593
|
-
}
|
|
1683
|
+
|
|
1594
1684
|
interface ResolvedColumn {
|
|
1595
1685
|
id: string;
|
|
1596
1686
|
name: string;
|
|
@@ -1614,41 +1704,6 @@ declare function rowToData(row: Record<string, unknown>, columns: ResolvedColumn
|
|
|
1614
1704
|
declare function dataToColumnValues(data: Record<string, unknown>, columns: ResolvedColumn[]): Record<string, unknown>;
|
|
1615
1705
|
declare function coerceValue(value: unknown, storage: 'number' | 'text', interpretation: ColumnInterpretation): unknown;
|
|
1616
1706
|
declare function buildTableSelect(collectionName: string, columns: ResolvedColumn[]): string;
|
|
1617
|
-
type PermissionLevel = boolean | 'own' | 'unclaimed-or-own' | 'collaborator' | 'team' | 'access' | 'published' | 'shared';
|
|
1618
|
-
interface RolePermissions {
|
|
1619
|
-
read: PermissionLevel;
|
|
1620
|
-
create: boolean;
|
|
1621
|
-
update: PermissionLevel;
|
|
1622
|
-
delete: PermissionLevel;
|
|
1623
|
-
/** If set, only these columns can be updated by this role. */
|
|
1624
|
-
writableFields?: string[];
|
|
1625
|
-
}
|
|
1626
|
-
interface CollectionSchema {
|
|
1627
|
-
name: string;
|
|
1628
|
-
/** Column definitions — every collection is stored in a typed SQL table. */
|
|
1629
|
-
columns: ColumnDefinition[];
|
|
1630
|
-
/** Composite uniqueness constraint (e.g., ['userId', 'taskId']). */
|
|
1631
|
-
uniqueOn?: string[];
|
|
1632
|
-
/** Column name used for ownership checks (default: `_created_by`). */
|
|
1633
|
-
ownerField?: string;
|
|
1634
|
-
/** Column containing JSON array of collaborator user IDs. */
|
|
1635
|
-
collaboratorsField?: string;
|
|
1636
|
-
/** Column containing team ID for team-based access. */
|
|
1637
|
-
teamField?: string;
|
|
1638
|
-
/**
|
|
1639
|
-
* Column controlling per-record read visibility.
|
|
1640
|
-
* String: visible when `data[field] === 'public'`.
|
|
1641
|
-
* Object: visible when `data[field] === value`.
|
|
1642
|
-
*/
|
|
1643
|
-
visibilityField?: string | {
|
|
1644
|
-
field: string;
|
|
1645
|
-
value: unknown;
|
|
1646
|
-
};
|
|
1647
|
-
/** Permissions per role. Use '*' for a catch-all fallback. */
|
|
1648
|
-
permissions: Record<string, RolePermissions>;
|
|
1649
|
-
/** Default role for new users (only on 'users' collection). */
|
|
1650
|
-
defaultRole?: string;
|
|
1651
|
-
}
|
|
1652
1707
|
interface User {
|
|
1653
1708
|
id: string;
|
|
1654
1709
|
email: string;
|
|
@@ -1783,8 +1838,6 @@ declare class RecordRoom<E = Record<string, unknown>> extends BaseRoom<E> {
|
|
|
1783
1838
|
private initPromise;
|
|
1784
1839
|
/** Yjs docs loaded in memory (key: collection:recordId:fieldName) */
|
|
1785
1840
|
private yjsDocs;
|
|
1786
|
-
/** Next Yjs client ID counter */
|
|
1787
|
-
private nextYjsClientId;
|
|
1788
1841
|
/** Owner user ID — gets admin role automatically */
|
|
1789
1842
|
private ownerUserId;
|
|
1790
1843
|
/** True until the first fetch() completes — detects hibernation wake-up */
|
|
@@ -1799,7 +1852,7 @@ declare class RecordRoom<E = Record<string, unknown>> extends BaseRoom<E> {
|
|
|
1799
1852
|
* The HTTP debug API (`/api/debug/*`) runs arbitrary SQL and role changes
|
|
1800
1853
|
* with no auth of its own, so it is gated here at the DO's single ingress.
|
|
1801
1854
|
* Off unless a deployment opts in with `ALLOW_DEBUG_ROUTES=true`
|
|
1802
|
-
* (`deepspace dev`/`test` set it automatically). Deployments holding shared
|
|
1855
|
+
* (`deepspace dev start`/`test run` set it automatically). Deployments holding shared
|
|
1803
1856
|
* data override this to always return false.
|
|
1804
1857
|
*/
|
|
1805
1858
|
protected get debugRoutesEnabled(): boolean;
|
|
@@ -1824,7 +1877,7 @@ declare class RecordRoom<E = Record<string, unknown>> extends BaseRoom<E> {
|
|
|
1824
1877
|
protected onMessage(): void;
|
|
1825
1878
|
webSocketMessage(ws: WebSocket, message: ArrayBuffer | string): Promise<void>;
|
|
1826
1879
|
webSocketClose(ws: WebSocket, code: number, reason: string): Promise<void>;
|
|
1827
|
-
webSocketError(
|
|
1880
|
+
webSocketError(_ws: WebSocket, error: unknown): Promise<void>;
|
|
1828
1881
|
private handleRecordMessage;
|
|
1829
1882
|
private handleListSchemas;
|
|
1830
1883
|
private createHandlerContext;
|
|
@@ -1869,7 +1922,7 @@ declare class YjsRoom<E = Record<string, unknown>> extends BaseRoom<E> {
|
|
|
1869
1922
|
type: string;
|
|
1870
1923
|
[key: string]: unknown;
|
|
1871
1924
|
}): void;
|
|
1872
|
-
protected onBinaryMessage(ws: WebSocket,
|
|
1925
|
+
protected onBinaryMessage(ws: WebSocket, _user: UserAttachment, data: ArrayBuffer): void;
|
|
1873
1926
|
protected onDisconnect(ws: WebSocket, _user: UserAttachment): void;
|
|
1874
1927
|
private handleSync;
|
|
1875
1928
|
private handleAwareness;
|
|
@@ -1936,7 +1989,7 @@ declare abstract class GameRoom<E = Record<string, unknown>> extends BaseRoom<E>
|
|
|
1936
1989
|
type: string;
|
|
1937
1990
|
[key: string]: unknown;
|
|
1938
1991
|
}): Promise<void>;
|
|
1939
|
-
protected onDisconnect(
|
|
1992
|
+
protected onDisconnect(_ws: WebSocket, user: UserAttachment): void;
|
|
1940
1993
|
protected onAlarm(): Promise<void>;
|
|
1941
1994
|
private checkAutoStart;
|
|
1942
1995
|
private startGame;
|
|
@@ -2036,7 +2089,7 @@ declare class CanvasRoom<E = Record<string, unknown>> extends BaseRoom<E> {
|
|
|
2036
2089
|
type: string;
|
|
2037
2090
|
[key: string]: unknown;
|
|
2038
2091
|
}): Promise<void>;
|
|
2039
|
-
protected onDisconnect(
|
|
2092
|
+
protected onDisconnect(_ws: WebSocket, user: UserAttachment): void;
|
|
2040
2093
|
private pushUndo;
|
|
2041
2094
|
private clearRedo;
|
|
2042
2095
|
private handleUndo;
|
|
@@ -2090,6 +2143,19 @@ declare class PresenceRoom<E = Record<string, unknown>> extends BaseRoom<E> {
|
|
|
2090
2143
|
protected onDisconnect(ws: WebSocket, user: UserAttachment): void;
|
|
2091
2144
|
}
|
|
2092
2145
|
|
|
2146
|
+
/** Pure validation and evaluation for CronRoom schedules. */
|
|
2147
|
+
interface CronTask {
|
|
2148
|
+
name: string;
|
|
2149
|
+
/** Interval in minutes (interval mode) — mutually exclusive with `schedule`. */
|
|
2150
|
+
intervalMinutes?: number;
|
|
2151
|
+
/** 5-field cron expression (cron mode) — requires `timezone`. */
|
|
2152
|
+
schedule?: string;
|
|
2153
|
+
/** IANA timezone string (e.g. "America/New_York"). Required with `schedule`. */
|
|
2154
|
+
timezone?: string;
|
|
2155
|
+
/** Whether the task starts paused. */
|
|
2156
|
+
paused?: boolean;
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2093
2159
|
/**
|
|
2094
2160
|
* CronRoom — Per-app scheduled task execution Durable Object.
|
|
2095
2161
|
*
|
|
@@ -2108,17 +2174,6 @@ declare class PresenceRoom<E = Record<string, unknown>> extends BaseRoom<E> {
|
|
|
2108
2174
|
* Message types: cron.*
|
|
2109
2175
|
*/
|
|
2110
2176
|
|
|
2111
|
-
interface CronTask {
|
|
2112
|
-
name: string;
|
|
2113
|
-
/** Interval in minutes (interval mode) — mutually exclusive with `schedule`. */
|
|
2114
|
-
intervalMinutes?: number;
|
|
2115
|
-
/** 5-field cron expression (cron mode) — requires `timezone`. */
|
|
2116
|
-
schedule?: string;
|
|
2117
|
-
/** IANA timezone string (e.g. "America/New_York"). Required with `schedule`. */
|
|
2118
|
-
timezone?: string;
|
|
2119
|
-
/** Whether the task starts paused. */
|
|
2120
|
-
paused?: boolean;
|
|
2121
|
-
}
|
|
2122
2177
|
interface CronRoomConfig {
|
|
2123
2178
|
tasks: CronTask[];
|
|
2124
2179
|
}
|
|
@@ -2922,7 +2977,7 @@ interface UserUpdatePayload {
|
|
|
2922
2977
|
email?: string;
|
|
2923
2978
|
imageUrl?: string;
|
|
2924
2979
|
}
|
|
2925
|
-
declare function handleUserUpdate(ctx: RecordContext,
|
|
2980
|
+
declare function handleUserUpdate(ctx: RecordContext, _ws: WebSocket, attachment: ConnectionAttachment, payload: UserUpdatePayload): void;
|
|
2926
2981
|
/**
|
|
2927
2982
|
* Handle set role request (admin only).
|
|
2928
2983
|
* Updates the role field in the c_users table.
|
|
@@ -2960,7 +3015,7 @@ declare function getYjsDocKey(collection: string, recordId: string, fieldName: s
|
|
|
2960
3015
|
* Get or create a Y.Doc for a record field.
|
|
2961
3016
|
* Loads from database if exists, creates new if not.
|
|
2962
3017
|
*/
|
|
2963
|
-
declare function getOrCreateYjsDoc(ctx: YjsContext, docKey: YjsDocKey):
|
|
3018
|
+
declare function getOrCreateYjsDoc(ctx: YjsContext, docKey: YjsDocKey): Y.Doc;
|
|
2964
3019
|
/**
|
|
2965
3020
|
* Save Yjs doc state to database.
|
|
2966
3021
|
*/
|
|
@@ -2969,11 +3024,11 @@ declare function saveYjsDoc(sql: SqlStorage, docKey: YjsDocKey, doc: Y.Doc): voi
|
|
|
2969
3024
|
* Handle request to join Yjs sync for a record field.
|
|
2970
3025
|
* System collections (see SYSTEM_COLLECTIONS) are permissive; others require schema.
|
|
2971
3026
|
*/
|
|
2972
|
-
declare function handleYjsJoin(ctx: YjsContext, ws: WebSocket, attachment: ConnectionAttachment, payload: YjsJoinPayload):
|
|
3027
|
+
declare function handleYjsJoin(ctx: YjsContext, ws: WebSocket, attachment: ConnectionAttachment, payload: YjsJoinPayload): void;
|
|
2973
3028
|
/**
|
|
2974
3029
|
* Handle request to leave Yjs sync for a record field.
|
|
2975
3030
|
*/
|
|
2976
|
-
declare function handleYjsLeave(ws: WebSocket, attachment: ConnectionAttachment, payload: YjsLeavePayload): void;
|
|
3031
|
+
declare function handleYjsLeave(ctx: YjsContext, ws: WebSocket, attachment: ConnectionAttachment, payload: YjsLeavePayload): void;
|
|
2977
3032
|
/**
|
|
2978
3033
|
* Handle binary Yjs sync messages from clients.
|
|
2979
3034
|
*
|
|
@@ -2981,7 +3036,7 @@ declare function handleYjsLeave(ws: WebSocket, attachment: ConnectionAttachment,
|
|
|
2981
3036
|
* - MSG_SYNC_STEP1: Client sends state vector → Server responds with SYNC_STEP2 (diff)
|
|
2982
3037
|
* - MSG_SYNC_STEP2/UPDATE: Client sends update → Server applies and broadcasts
|
|
2983
3038
|
*/
|
|
2984
|
-
declare function handleYjsBinaryMessage(ctx: YjsContext, ws: WebSocket, attachment: ConnectionAttachment, data: Uint8Array):
|
|
3039
|
+
declare function handleYjsBinaryMessage(ctx: YjsContext, ws: WebSocket, attachment: ConnectionAttachment, data: Uint8Array): void;
|
|
2985
3040
|
/**
|
|
2986
3041
|
* Broadcast a Yjs update to all subscribers of a doc, except the sender.
|
|
2987
3042
|
*/
|
|
@@ -3118,7 +3173,7 @@ declare function decodeJwtPayload(token: string | null | undefined): TokenDebugI
|
|
|
3118
3173
|
/**
|
|
3119
3174
|
* Test-account identification, shared by every platform worker.
|
|
3120
3175
|
*
|
|
3121
|
-
* Test accounts (created via `deepspace test
|
|
3176
|
+
* Test accounts (created via `deepspace test accounts`) are real Better Auth
|
|
3122
3177
|
* users demarcated three ways, and a caller may present as any of them
|
|
3123
3178
|
* depending on where the check runs:
|
|
3124
3179
|
* - their email always ends with @deepspace.test (enforced at creation)
|
|
@@ -3179,8 +3234,184 @@ interface DeepSpaceAuthConfig {
|
|
|
3179
3234
|
emailAndPassword?: boolean;
|
|
3180
3235
|
/** Trusted origins for CORS */
|
|
3181
3236
|
trustedOrigins?: string[];
|
|
3237
|
+
/**
|
|
3238
|
+
* Called after a new user row is created (any flow: social OAuth callback,
|
|
3239
|
+
* email/password, server-side `auth.api.signUpEmail`). When the signup came
|
|
3240
|
+
* in over HTTP, `ctx.request` exposes the inbound request; some better-auth
|
|
3241
|
+
* entry points carry standalone `ctx.headers` instead of (or as well as) a
|
|
3242
|
+
* request, so both are forwarded. For server-side creations (`auth.api.*`
|
|
3243
|
+
* calls) an endpoint context usually still exists but may carry NEITHER —
|
|
3244
|
+
* guard every field.
|
|
3245
|
+
*
|
|
3246
|
+
* Better Auth awaits `user.create.after` hooks inline before the response
|
|
3247
|
+
* is sent, so keep this cheap (e.g. a single D1 write) and hand slow work
|
|
3248
|
+
* to `ctx.waitUntil` at the call site. Exceptions are caught and logged so
|
|
3249
|
+
* a failing observer can never break signup itself.
|
|
3250
|
+
*/
|
|
3251
|
+
onUserCreated?: (user: {
|
|
3252
|
+
id: string;
|
|
3253
|
+
email: string;
|
|
3254
|
+
name: string;
|
|
3255
|
+
}, ctx: {
|
|
3256
|
+
request?: Request;
|
|
3257
|
+
headers?: Headers;
|
|
3258
|
+
} | null) => Promise<void>;
|
|
3182
3259
|
}
|
|
3183
3260
|
declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.Auth<{
|
|
3261
|
+
databaseHooks: {
|
|
3262
|
+
user?: {
|
|
3263
|
+
create?: {
|
|
3264
|
+
before?: (user: better_auth.User & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<boolean | void | {
|
|
3265
|
+
data: {
|
|
3266
|
+
id?: string | undefined;
|
|
3267
|
+
createdAt?: Date | undefined;
|
|
3268
|
+
updatedAt?: Date | undefined;
|
|
3269
|
+
email?: string | undefined;
|
|
3270
|
+
emailVerified?: boolean | undefined;
|
|
3271
|
+
name?: string | undefined;
|
|
3272
|
+
image?: string | null | undefined;
|
|
3273
|
+
} & Record<string, any>;
|
|
3274
|
+
}>;
|
|
3275
|
+
after?: (user: better_auth.User & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<void>;
|
|
3276
|
+
};
|
|
3277
|
+
update?: {
|
|
3278
|
+
before?: (user: Partial<better_auth.User> & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<boolean | void | {
|
|
3279
|
+
data: {
|
|
3280
|
+
[x: string]: any;
|
|
3281
|
+
id?: string | undefined;
|
|
3282
|
+
createdAt?: Date | undefined;
|
|
3283
|
+
updatedAt?: Date | undefined;
|
|
3284
|
+
email?: string | undefined;
|
|
3285
|
+
emailVerified?: boolean | undefined;
|
|
3286
|
+
name?: string | undefined;
|
|
3287
|
+
image?: string | null | undefined;
|
|
3288
|
+
};
|
|
3289
|
+
}>;
|
|
3290
|
+
after?: (user: better_auth.User & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<void>;
|
|
3291
|
+
};
|
|
3292
|
+
delete?: {
|
|
3293
|
+
before?: (user: better_auth.User & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<boolean | void>;
|
|
3294
|
+
after?: (user: better_auth.User & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<void>;
|
|
3295
|
+
};
|
|
3296
|
+
};
|
|
3297
|
+
session?: {
|
|
3298
|
+
create?: {
|
|
3299
|
+
before?: (session: better_auth.Session & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<boolean | void | {
|
|
3300
|
+
data: {
|
|
3301
|
+
id?: string | undefined;
|
|
3302
|
+
createdAt?: Date | undefined;
|
|
3303
|
+
updatedAt?: Date | undefined;
|
|
3304
|
+
userId?: string | undefined;
|
|
3305
|
+
expiresAt?: Date | undefined;
|
|
3306
|
+
token?: string | undefined;
|
|
3307
|
+
ipAddress?: string | null | undefined;
|
|
3308
|
+
userAgent?: string | null | undefined;
|
|
3309
|
+
} & Record<string, any>;
|
|
3310
|
+
}>;
|
|
3311
|
+
after?: (session: better_auth.Session & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<void>;
|
|
3312
|
+
};
|
|
3313
|
+
update?: {
|
|
3314
|
+
before?: (session: Partial<better_auth.Session> & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<boolean | void | {
|
|
3315
|
+
data: {
|
|
3316
|
+
[x: string]: any;
|
|
3317
|
+
id?: string | undefined;
|
|
3318
|
+
createdAt?: Date | undefined;
|
|
3319
|
+
updatedAt?: Date | undefined;
|
|
3320
|
+
userId?: string | undefined;
|
|
3321
|
+
expiresAt?: Date | undefined;
|
|
3322
|
+
token?: string | undefined;
|
|
3323
|
+
ipAddress?: string | null | undefined;
|
|
3324
|
+
userAgent?: string | null | undefined;
|
|
3325
|
+
};
|
|
3326
|
+
}>;
|
|
3327
|
+
after?: (session: better_auth.Session & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<void>;
|
|
3328
|
+
};
|
|
3329
|
+
delete?: {
|
|
3330
|
+
before?: (session: better_auth.Session & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<boolean | void>;
|
|
3331
|
+
after?: (session: better_auth.Session & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<void>;
|
|
3332
|
+
};
|
|
3333
|
+
};
|
|
3334
|
+
account?: {
|
|
3335
|
+
create?: {
|
|
3336
|
+
before?: (account: better_auth.Account, context: better_auth.GenericEndpointContext | null) => Promise<boolean | void | {
|
|
3337
|
+
data: {
|
|
3338
|
+
id?: string | undefined;
|
|
3339
|
+
createdAt?: Date | undefined;
|
|
3340
|
+
updatedAt?: Date | undefined;
|
|
3341
|
+
providerId?: string | undefined;
|
|
3342
|
+
accountId?: string | undefined;
|
|
3343
|
+
userId?: string | undefined;
|
|
3344
|
+
accessToken?: string | null | undefined;
|
|
3345
|
+
refreshToken?: string | null | undefined;
|
|
3346
|
+
idToken?: string | null | undefined;
|
|
3347
|
+
accessTokenExpiresAt?: Date | null | undefined;
|
|
3348
|
+
refreshTokenExpiresAt?: Date | null | undefined;
|
|
3349
|
+
scope?: string | null | undefined;
|
|
3350
|
+
password?: string | null | undefined;
|
|
3351
|
+
} & Record<string, any>;
|
|
3352
|
+
}>;
|
|
3353
|
+
after?: (account: better_auth.Account, context: better_auth.GenericEndpointContext | null) => Promise<void>;
|
|
3354
|
+
};
|
|
3355
|
+
update?: {
|
|
3356
|
+
before?: (account: Partial<better_auth.Account> & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<boolean | void | {
|
|
3357
|
+
data: {
|
|
3358
|
+
[x: string]: any;
|
|
3359
|
+
id?: string | undefined;
|
|
3360
|
+
createdAt?: Date | undefined;
|
|
3361
|
+
updatedAt?: Date | undefined;
|
|
3362
|
+
providerId?: string | undefined;
|
|
3363
|
+
accountId?: string | undefined;
|
|
3364
|
+
userId?: string | undefined;
|
|
3365
|
+
accessToken?: string | null | undefined;
|
|
3366
|
+
refreshToken?: string | null | undefined;
|
|
3367
|
+
idToken?: string | null | undefined;
|
|
3368
|
+
accessTokenExpiresAt?: Date | null | undefined;
|
|
3369
|
+
refreshTokenExpiresAt?: Date | null | undefined;
|
|
3370
|
+
scope?: string | null | undefined;
|
|
3371
|
+
password?: string | null | undefined;
|
|
3372
|
+
};
|
|
3373
|
+
}>;
|
|
3374
|
+
after?: (account: better_auth.Account & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<void>;
|
|
3375
|
+
};
|
|
3376
|
+
delete?: {
|
|
3377
|
+
before?: (account: better_auth.Account & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<boolean | void>;
|
|
3378
|
+
after?: (account: better_auth.Account & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<void>;
|
|
3379
|
+
};
|
|
3380
|
+
};
|
|
3381
|
+
verification?: {
|
|
3382
|
+
create?: {
|
|
3383
|
+
before?: (verification: better_auth.Verification & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<boolean | void | {
|
|
3384
|
+
data: {
|
|
3385
|
+
id?: string | undefined;
|
|
3386
|
+
createdAt?: Date | undefined;
|
|
3387
|
+
updatedAt?: Date | undefined;
|
|
3388
|
+
value?: string | undefined;
|
|
3389
|
+
expiresAt?: Date | undefined;
|
|
3390
|
+
identifier?: string | undefined;
|
|
3391
|
+
} & Record<string, any>;
|
|
3392
|
+
}>;
|
|
3393
|
+
after?: (verification: better_auth.Verification & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<void>;
|
|
3394
|
+
};
|
|
3395
|
+
update?: {
|
|
3396
|
+
before?: (verification: Partial<better_auth.Verification> & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<boolean | void | {
|
|
3397
|
+
data: {
|
|
3398
|
+
[x: string]: any;
|
|
3399
|
+
id?: string | undefined;
|
|
3400
|
+
createdAt?: Date | undefined;
|
|
3401
|
+
updatedAt?: Date | undefined;
|
|
3402
|
+
value?: string | undefined;
|
|
3403
|
+
expiresAt?: Date | undefined;
|
|
3404
|
+
identifier?: string | undefined;
|
|
3405
|
+
};
|
|
3406
|
+
}>;
|
|
3407
|
+
after?: (verification: better_auth.Verification & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<void>;
|
|
3408
|
+
};
|
|
3409
|
+
delete?: {
|
|
3410
|
+
before?: (verification: better_auth.Verification & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<boolean | void>;
|
|
3411
|
+
after?: (verification: better_auth.Verification & Record<string, unknown>, context: better_auth.GenericEndpointContext | null) => Promise<void>;
|
|
3412
|
+
};
|
|
3413
|
+
};
|
|
3414
|
+
} | undefined;
|
|
3184
3415
|
plugins: [{
|
|
3185
3416
|
id: "organization";
|
|
3186
3417
|
version: string;
|
|
@@ -4033,6 +4264,10 @@ declare function createDeepSpaceAuth(config: DeepSpaceAuthConfig): better_auth.A
|
|
|
4033
4264
|
database: D1Database;
|
|
4034
4265
|
baseURL: string;
|
|
4035
4266
|
secret: string;
|
|
4267
|
+
session: {
|
|
4268
|
+
expiresIn: number;
|
|
4269
|
+
updateAge: number;
|
|
4270
|
+
};
|
|
4036
4271
|
emailAndPassword: {
|
|
4037
4272
|
enabled: boolean;
|
|
4038
4273
|
};
|
|
@@ -4056,9 +4291,10 @@ interface PlanPrice {
|
|
|
4056
4291
|
currency?: string;
|
|
4057
4292
|
}
|
|
4058
4293
|
/**
|
|
4059
|
-
* Plan shape returned by `/api/subscriptions/me` and consumed
|
|
4060
|
-
* `<PricingTable plans={sub.plans}>`. Fields beyond slug/rank
|
|
4061
|
-
* a free tier (no prices, no trial) doesn't need to fabricate
|
|
4294
|
+
* Plan shape returned by `/api/subscriptions/me` and consumed by
|
|
4295
|
+
* `<PricingTable plans={sub.plans} onSelect={...}>`. Fields beyond slug/rank
|
|
4296
|
+
* are optional so a free tier (no prices, no trial) doesn't need to fabricate
|
|
4297
|
+
* them.
|
|
4062
4298
|
*/
|
|
4063
4299
|
interface PlanInfo {
|
|
4064
4300
|
slug: string;
|
|
@@ -4198,4 +4434,4 @@ declare class RefundError extends Error {
|
|
|
4198
4434
|
constructor(message: string, status: number);
|
|
4199
4435
|
}
|
|
4200
4436
|
|
|
4201
|
-
export { AI_CHATS_SCHEMA, AI_MESSAGES_SCHEMA, ALLOWED_BINDING_TYPES, APP_NAME_RULES, AUTO_PROVISIONABLE_TYPES, AUTO_PROVISION_SENTINEL, type ActionContext, type ActionHandler, type ActionResult, type ActionTools, type ApiWorkerEnv, type AppNameResolution, type AppNameValidation, type AuthWorkerEnv, BASE_USERS_SCHEMA, BUILT_IN_TOOLS, BaseRoom, CHANNELS_SCHEMA, CHANNEL_INVITATIONS_SCHEMA, CHANNEL_MEMBERS_SCHEMA, CONVERSATION_SCHEMAS, COST_RATES, CancelSubscriptionError, type CancelSubscriptionOpts, type CancelSubscriptionResult, CanvasRoom, type CanvasShape, type ChatContextConfig, type ChatMessageRow, type ChatRow, type ChatTurn, type CollectionPermissionSummary, type CollectionSchema, type ColumnDefinition, type ColumnInterpretation, type ComposioToolsOptions, type ConvMemberData, type ConvMessageData, type ConvReactionData, type ConvReadCursorData, type ConvVoteData, type ConversationStateData, type CronContext, type CronExecution, CronRoom, type CronRoomConfig, type CronTask, type CustomBinding, type CustomBindingManifest, DEFAULT_CONTEXT_CONFIG, DEFAULT_DO_MANIFEST, DEFAULT_QUERY_LIMIT, DIRECTORY_SCHEMAS, type DOBindings, type DOManifest, type DOManifestEntry, type DebugApiContext, type DeepSpaceAIEnv, type DeepSpaceAIOptions, type DeepSpaceAuth, type DeepSpaceAuthConfig, type DirectoryCommunityData, type DirectoryConversationData, type DirectoryMembershipData, type DirectoryPostData, type DoMigrationDirective, type DoMigrationPlan, type ExistingDOBinding, GLOBAL_DO_TYPES, GLOBAL_DO_TYPE_NAMES, type GameInput, GameRoom, type GameRoomConfig, type GetActionData, type GlobalDOType, type Job, type JobContext, JobRoom, type JobRoomConfig, type JobStatus, type JwtClaims, type JwtVerifierConfig, MESSAGES_SCHEMA, type MutateActionData, type PermissionAnalysis, type PermissionContext, type PermissionLevel, type PermissionSource, type PlanInfo, type PlatformWorkerEnv, type Player, type PrefixResult, type PresencePeer, PresenceRoom, type QueryActionData, REACTIONS_SCHEMA, READ_RECEIPTS_SCHEMA, RESERVED_BINDING_NAMES, RESERVED_COLLECTION_NAMES, type RecordContext, RecordRoom, type RecordRoomConfig, RefundError, type RefundOpts, type RefundResult, type ResolvedColumn, type ResolvedPermission, type RolePermissions, type RunMigrationsResult, SYSTEM_COLLECTION_SCHEMAS, SYSTEM_MANAGED_COLUMNS, SchemaRegistry, type ScopeContext, type ScopedR2Auth, type ScopedR2Config, type ScopedR2Handler, type ScreenshotEnv, type
|
|
4437
|
+
export { AI_CHATS_SCHEMA, AI_MESSAGES_SCHEMA, ALLOWED_BINDING_TYPES, APP_ID_RE, APP_NAME_RULES, AUTO_PROVISIONABLE_TYPES, AUTO_PROVISION_SENTINEL, type ActionContext, type ActionHandler, type ActionResult, type ActionTools, type ApiWorkerEnv, type AppNameResolution, type AppNameValidation, type AuthWorkerEnv, BASE_USERS_SCHEMA, BUILT_IN_TOOLS, BaseRoom, CHANNELS_SCHEMA, CHANNEL_INVITATIONS_SCHEMA, CHANNEL_MEMBERS_SCHEMA, CONVERSATION_SCHEMAS, COST_RATES, CancelSubscriptionError, type CancelSubscriptionOpts, type CancelSubscriptionResult, CanvasRoom, type CanvasShape, type ChatContextConfig, type ChatMessageRow, type ChatRow, type ChatTurn, type CollectionPermissionSummary, type CollectionSchema, type ColumnDefinition, type ColumnInterpretation, type ComposioToolsOptions, type ConvMemberData, type ConvMessageData, type ConvReactionData, type ConvReadCursorData, type ConvVoteData, type ConversationStateData, type CronContext, type CronExecution, CronRoom, type CronRoomConfig, type CronTask, type CustomBinding, type CustomBindingManifest, DEFAULT_CONTEXT_CONFIG, DEFAULT_DO_MANIFEST, DEFAULT_QUERY_LIMIT, DEPLOYED_APPS_DEFAULTS, DIRECTORY_SCHEMAS, type DOBindings, type DOManifest, type DOManifestEntry, type DebugApiContext, type DeepSpaceAIEnv, type DeepSpaceAIOptions, type DeepSpaceAuth, type DeepSpaceAuthConfig, type DirectoryCommunityData, type DirectoryConversationData, type DirectoryMembershipData, type DirectoryPostData, type DoMigrationDirective, type DoMigrationPlan, type ExistingDOBinding, GLOBAL_DO_TYPES, GLOBAL_DO_TYPE_NAMES, type GameInput, GameRoom, type GameRoomConfig, type GetActionData, type GlobalDOType, type Job, type JobContext, JobRoom, type JobRoomConfig, type JobStatus, type JwtClaims, type JwtVerifierConfig, MESSAGES_SCHEMA, type MutateActionData, type PermissionAnalysis, type PermissionContext, type PermissionLevel, type PermissionSource, type PlanInfo, type PlatformWorkerEnv, type Player, type PrefixResult, type PresencePeer, PresenceRoom, type QueryActionData, REACTIONS_SCHEMA, READ_RECEIPTS_SCHEMA, REGISTRY_INSTANCE, RESERVED_BINDING_NAMES, RESERVED_COLLECTION_NAMES, type RecordContext, RecordRoom, type RecordRoomConfig, RefundError, type RefundOpts, type RefundResult, RegistryClientError, type ResolvedColumn, type ResolvedPermission, type RolePermissions, type RunMigrationsResult, STRICT_APP_ID_RE, SYSTEM_COLLECTION_SCHEMAS, SYSTEM_MANAGED_COLUMNS, SchemaRegistry, type ScopeContext, type ScopedR2Auth, type ScopedR2Config, type ScopedR2Handler, type ScreenshotEnv, type ScreenshotResult, type SharedConnection, type StoredRecord, SubscriptionAuthError, type SubscriptionContext, type SubscriptionRead, SubscriptionRequiredError, type SubscriptionStatus, type Summarizer, TEST_ACCOUNT_EMAIL_SUFFIX, type TokenDebugInfo, type ToolResult, type ToolSchema, type ToolsApiContext, USERS_COLUMNS, type User, type UserAttachment, type UserContext, VOTING_SCHEMAS, type ValidationError, type VerifiedAuth, type VerifyOutcome, type VerifyResult, type Viewport, WORKSPACE_SCHEMAS, type YjsContext, YjsRoom, analyzePermissions, apiWorkerFetch, appendMessage, applyAiToolDefaults, applySlidingWindow, authWorkerFetch, bindingManifestFromOutputConfig, broadcastChange, broadcastYjsUpdate, buildCronContext, buildTableSelect, buildUiParts, callRegistry, canCreate, canDelete, canRead, canUpdate, cancelSubscription, capToolResultSize, captureScreenshot, checkFieldPermissions, coerceValue, collectionTableName, columnId, composioTools, computeDoMigration, computeHmacHex, createChat, createDeepSpaceAI, createDeepSpaceAuth, createScopedR2Handler, dataToColumnValues, decodeJwtPayload, deleteChatCascade, deleteRecord, enqueueJob, executeQuery, getAllUsers, getChat, getGlobalDOSchemas, getGlobalDOType, getOrCreateYjsDoc, getRecord, getRolePermissions, getSubscription, getUser, getYjsDocKey, handleApiRequest, handleDelete, handlePut, handleSetRole, handleSubscribe, handleToolsRequest, handleUnsubscribe, handleUserList, handleUserUpdate, handleYjsBinaryMessage, handleYjsJoin, handleYjsLeave, isAutoProvision, isOwner, isTestAccountClaims, isTestAccountEmail, isTestAccountTier, lintSchema, loadMessages, makeDefaultSummarizer, matchOrigin, meterAi, meterUsage, meterVectorize, noopPermissionContext, parseQuotaLimit, platformCorsPatterns, platformWorkerFetch, prepareMessagesWithCompaction, priceBindingUsageEvent, putRecord, readRecord, recordMatchesSubscription, refundInvoice, registerUser, registryErrorJson, registryStub, requireSubscription, resolveAppName, resolveColumn, rowToData, runMigrations, saveYjsDoc, timingSafeEqualHex, timingSafeEqualStrings, totalChars, truncateOldToolResults, turnsToCoreMessages, unwrapToolOutput, updateChat, validateAppName, validateBindingManifest, validateDoManifest, verifyJwt, workspaceAccountsSchema, workspaceContentSharesSchema, workspaceEmailHandlesSchema, workspaceFormResponsesSchema, workspacePeopleSchema, workspaceProjectsSchema, workspaceTagsSchema, workspaceTasksSchema, workspaceTeamMembersSchema, workspaceTeamsSchema, workspaceTransactionsSchema };
|