@hasna/cloud 0.1.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.
@@ -0,0 +1,16 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ /**
3
+ * Register cloud-related MCP tools onto an existing MCP server.
4
+ * Services call this to embed cloud sync/feedback tools into their own MCP server.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
9
+ * import { registerCloudTools } from "@hasna/cloud";
10
+ *
11
+ * const server = new McpServer({ name: "my-service", version: "0.1.0" });
12
+ * registerCloudTools(server, "my-service");
13
+ * ```
14
+ */
15
+ export declare function registerCloudTools(server: McpServer, serviceName: string): void;
16
+ //# sourceMappingURL=mcp-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-helpers.d.ts","sourceRoot":"","sources":["../src/mcp-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAYzE;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,MAAM,GAClB,IAAI,CAuJN"}
package/dist/sync.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ import type { DbAdapter } from "./adapter.js";
2
+ export interface SyncProgress {
3
+ table: string;
4
+ phase: "reading" | "writing" | "done";
5
+ rowsRead: number;
6
+ rowsWritten: number;
7
+ totalTables: number;
8
+ currentTableIndex: number;
9
+ }
10
+ export type SyncProgressCallback = (progress: SyncProgress) => void;
11
+ export interface SyncOptions {
12
+ /** Tables to sync. */
13
+ tables: string[];
14
+ /** Optional progress callback. */
15
+ onProgress?: SyncProgressCallback;
16
+ /** Batch size for UPSERT operations. Default: 500 */
17
+ batchSize?: number;
18
+ /** Conflict resolution column (default: "updated_at"). Newest wins. */
19
+ conflictColumn?: string;
20
+ /** Primary key column name (default: "id"). */
21
+ primaryKey?: string;
22
+ }
23
+ export interface SyncResult {
24
+ table: string;
25
+ rowsRead: number;
26
+ rowsWritten: number;
27
+ rowsSkipped: number;
28
+ errors: string[];
29
+ }
30
+ /**
31
+ * Push data from a local database to the cloud database.
32
+ * For each table: SELECT * from source → UPSERT into target.
33
+ * Conflict resolution: compare `updated_at`, newest wins.
34
+ */
35
+ export declare function syncPush(local: DbAdapter, cloud: DbAdapter, options: SyncOptions): SyncResult[];
36
+ /**
37
+ * Pull data from the cloud database into the local database.
38
+ */
39
+ export declare function syncPull(local: DbAdapter, cloud: DbAdapter, options: SyncOptions): SyncResult[];
40
+ /**
41
+ * List all user tables in a SQLite database.
42
+ */
43
+ export declare function listSqliteTables(db: DbAdapter): string[];
44
+ /**
45
+ * List all user tables in a PostgreSQL database.
46
+ */
47
+ export declare function listPgTables(db: DbAdapter): string[];
48
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAM9C,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,YAAY,KAAK,IAAI,CAAC;AAEpE,MAAM,WAAW,WAAW;IAC1B,sBAAsB;IACtB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,kCAAkC;IAClC,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAMD;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,WAAW,GACnB,UAAU,EAAE,CAEd;AAMD;;GAEG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,WAAW,GACnB,UAAU,EAAE,CAEd;AAoLD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,EAAE,CAKxD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,EAAE,CAKpD"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@hasna/cloud",
3
+ "version": "0.1.0",
4
+ "description": "Shared cloud infrastructure — database adapter (SQLite + PostgreSQL), sync engine, feedback system, unified dotfile config",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "bin": {
10
+ "cloud": "dist/cli/index.js",
11
+ "cloud-mcp": "dist/mcp/index.js"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "import": "./dist/index.js",
16
+ "types": "./dist/index.d.ts"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "LICENSE"
22
+ ],
23
+ "scripts": {
24
+ "build": "bun build src/index.ts --outdir dist --target node && bun build src/cli/index.ts --outdir dist/cli --target node && bun build src/mcp/index.ts --outdir dist/mcp --target node && bun run build:types",
25
+ "build:types": "tsc --emitDeclarationOnly --declaration --outDir dist",
26
+ "test": "bun test",
27
+ "prepublishOnly": "bun run build"
28
+ },
29
+ "publishConfig": {
30
+ "registry": "https://registry.npmjs.org",
31
+ "access": "public"
32
+ },
33
+ "dependencies": {
34
+ "@modelcontextprotocol/sdk": "^1.12.1",
35
+ "commander": "^13.1.0",
36
+ "pg": "^8.13.3",
37
+ "zod": "^3.24.2"
38
+ },
39
+ "devDependencies": {
40
+ "@types/bun": "^1.2.6",
41
+ "@types/pg": "^8.11.11",
42
+ "typescript": "^5.7.3"
43
+ }
44
+ }