@hasna/sandboxes 0.1.27 → 0.1.29

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.
@@ -0,0 +1,13 @@
1
+ export type CloudMode = "local" | "hybrid" | "cloud";
2
+ export interface CloudConfig {
3
+ mode: CloudMode;
4
+ rds: {
5
+ host: string;
6
+ port: number;
7
+ username: string;
8
+ password_env: string;
9
+ ssl: boolean;
10
+ };
11
+ }
12
+ export declare function getCloudConfig(): CloudConfig;
13
+ export declare function getConnectionString(dbName?: string): string;
@@ -0,0 +1,29 @@
1
+ import { type Database } from "bun:sqlite";
2
+ import { PgAdapterAsync } from "./remote-storage.js";
3
+ export interface SyncResult {
4
+ table: string;
5
+ direction: "push" | "pull";
6
+ rowsRead: number;
7
+ rowsWritten: number;
8
+ errors: string[];
9
+ }
10
+ export interface CloudStatus {
11
+ mode: string;
12
+ enabled: boolean;
13
+ db_path: string;
14
+ tables: Array<{
15
+ table: string;
16
+ rows: number;
17
+ }>;
18
+ }
19
+ export declare const CLOUD_TABLES: readonly ["projects", "agents", "sandboxes", "sandbox_sessions", "sandbox_events", "webhooks", "templates", "snapshots", "feedback"];
20
+ export declare function getCloudPg(): Promise<PgAdapterAsync>;
21
+ export declare function runCloudMigrations(remote: PgAdapterAsync): Promise<void>;
22
+ export declare function getCloudStatus(db?: Database): CloudStatus;
23
+ export declare function pushCloudChanges(tables?: string[]): Promise<SyncResult[]>;
24
+ export declare function pullCloudChanges(tables?: string[]): Promise<SyncResult[]>;
25
+ export declare function syncCloudChanges(tables?: string[]): Promise<{
26
+ push: SyncResult[];
27
+ pull: SyncResult[];
28
+ }>;
29
+ export declare function parseCloudTables(raw?: string): string[];
@@ -1,4 +1,5 @@
1
1
  import { Database } from "bun:sqlite";
2
+ export declare function getDbPath(): string;
2
3
  export declare function getDatabase(): Database;
3
4
  export declare function closeDatabase(): void;
4
5
  export declare function resetDatabase(): void;
@@ -0,0 +1,7 @@
1
+ export interface PgMigrationResult {
2
+ applied: number[];
3
+ alreadyApplied: number[];
4
+ errors: string[];
5
+ totalMigrations: number;
6
+ }
7
+ export declare function applyPgMigrations(connectionString: string): Promise<PgMigrationResult>;
@@ -0,0 +1,11 @@
1
+ export declare class PgAdapterAsync {
2
+ private readonly pool;
3
+ constructor(connectionString: string);
4
+ run(sql: string, ...params: unknown[]): Promise<{
5
+ changes: number;
6
+ }>;
7
+ get(sql: string, ...params: unknown[]): Promise<unknown>;
8
+ all(sql: string, ...params: unknown[]): Promise<unknown[]>;
9
+ exec(sql: string): Promise<void>;
10
+ close(): Promise<void>;
11
+ }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  export * from "./types/index.js";
2
2
  export { getDatabase, closeDatabase, resetDatabase, uuid, shortId, now, resolvePartialId } from "./db/database.js";
3
+ export { getCloudConfig, getConnectionString } from "./db/cloud-config.js";
4
+ export { PgAdapterAsync } from "./db/remote-storage.js";
5
+ export { applyPgMigrations } from "./db/pg-migrate.js";
6
+ export { CLOUD_TABLES, getCloudPg, getCloudStatus, parseCloudTables, pullCloudChanges, pushCloudChanges, runCloudMigrations, syncCloudChanges, } from "./db/cloud-sync.js";
7
+ export type { CloudStatus, SyncResult } from "./db/cloud-sync.js";
3
8
  export { createSandbox, getSandbox, listSandboxes, updateSandbox, deleteSandbox } from "./db/sandboxes.js";
4
9
  export { createSession, getSession, listSessions, updateSession, endSession } from "./db/sessions.js";
5
10
  export { addEvent, listEvents } from "./db/events.js";