@hasna/cloud 0.1.14 → 0.1.16

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,58 @@
1
+ /**
2
+ * Generic PostgreSQL migration runner.
3
+ *
4
+ * Applies a flat array of SQL migration strings to a PG database.
5
+ * Tracks applied versions in a `_pg_migrations` table.
6
+ * Forward-only — no rollbacks. Migrations must be idempotent.
7
+ *
8
+ * Usage:
9
+ * import { applyPgMigrations } from "@hasna/cloud";
10
+ * const result = await applyPgMigrations(connectionString, migrations);
11
+ *
12
+ * Or for service discovery:
13
+ * import { migrateService, migrateAllServices } from "@hasna/cloud";
14
+ * await migrateService("todos", connectionString);
15
+ * await migrateAllServices(); // discovers all installed @hasna/* services
16
+ */
17
+ export interface PgMigrationResult {
18
+ service: string;
19
+ applied: number[];
20
+ alreadyApplied: number[];
21
+ errors: string[];
22
+ totalMigrations: number;
23
+ }
24
+ /**
25
+ * Apply an array of SQL migrations to a PostgreSQL database.
26
+ *
27
+ * @param connectionString - PG connection string (postgres://...)
28
+ * @param migrations - Ordered array of SQL strings. Index = version number.
29
+ * @param service - Service name for result reporting (default: "unknown")
30
+ */
31
+ export declare function applyPgMigrations(connectionString: string, migrations: string[], service?: string): Promise<PgMigrationResult>;
32
+ /**
33
+ * Migrate a single service's PG database.
34
+ *
35
+ * @param service - Service name (e.g., "todos", "conversations")
36
+ * @param connectionString - Optional override. Default: auto-detected from cloud config.
37
+ */
38
+ export declare function migrateService(service: string, connectionString?: string): Promise<PgMigrationResult>;
39
+ /**
40
+ * Discover all installed @hasna/* services and migrate their PG databases.
41
+ *
42
+ * Discovery: scans ~/.hasna/ for service directories that have local DBs.
43
+ */
44
+ export declare function migrateAllServices(): Promise<PgMigrationResult[]>;
45
+ /**
46
+ * Ensure a PostgreSQL database exists for a service.
47
+ * Connects to the `postgres` default database and runs CREATE DATABASE.
48
+ */
49
+ export declare function ensurePgDatabase(service: string): Promise<boolean>;
50
+ /**
51
+ * Ensure PG databases exist for all discovered services.
52
+ */
53
+ export declare function ensureAllPgDatabases(): Promise<Array<{
54
+ service: string;
55
+ created: boolean;
56
+ error?: string;
57
+ }>>;
58
+ //# sourceMappingURL=pg-migrate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pg-migrate.d.ts","sourceRoot":"","sources":["../src/pg-migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB;AAMD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,MAAM,EAAE,EACpB,OAAO,SAAY,GAClB,OAAO,CAAC,iBAAiB,CAAC,CAwD5B;AA+CD;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAe5B;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAqBvE;AAMD;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA0BxE;AAED;;GAEG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAelH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/cloud",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "Shared cloud infrastructure — database adapter (SQLite + PostgreSQL), sync engine, feedback system, unified dotfile config",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",