@hasna/treasury 0.1.2

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.
Files changed (110) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +85 -0
  3. package/dist/adapters/fixtures.d.ts +31 -0
  4. package/dist/adapters/fixtures.d.ts.map +1 -0
  5. package/dist/adapters/types.d.ts +42 -0
  6. package/dist/adapters/types.d.ts.map +1 -0
  7. package/dist/api/index.d.ts +37 -0
  8. package/dist/api/index.d.ts.map +1 -0
  9. package/dist/cli/context.d.ts +9 -0
  10. package/dist/cli/context.d.ts.map +1 -0
  11. package/dist/cli/dashboard.d.ts +5 -0
  12. package/dist/cli/dashboard.d.ts.map +1 -0
  13. package/dist/cli/index.d.ts +3 -0
  14. package/dist/cli/index.d.ts.map +1 -0
  15. package/dist/cli/index.js +4353 -0
  16. package/dist/cli/namespaces.d.ts +7 -0
  17. package/dist/cli/namespaces.d.ts.map +1 -0
  18. package/dist/config.d.ts +42 -0
  19. package/dist/config.d.ts.map +1 -0
  20. package/dist/core/app-home.d.ts +9 -0
  21. package/dist/core/app-home.d.ts.map +1 -0
  22. package/dist/core/errors.d.ts +8 -0
  23. package/dist/core/errors.d.ts.map +1 -0
  24. package/dist/db/audit.d.ts +16 -0
  25. package/dist/db/audit.d.ts.map +1 -0
  26. package/dist/db/backup.d.ts +14 -0
  27. package/dist/db/backup.d.ts.map +1 -0
  28. package/dist/db/database.d.ts +40 -0
  29. package/dist/db/database.d.ts.map +1 -0
  30. package/dist/db/migration-plan.d.ts +14 -0
  31. package/dist/db/migration-plan.d.ts.map +1 -0
  32. package/dist/db/schema.d.ts +8 -0
  33. package/dist/db/schema.d.ts.map +1 -0
  34. package/dist/generated/storage-kit/health.d.ts +20 -0
  35. package/dist/generated/storage-kit/health.d.ts.map +1 -0
  36. package/dist/generated/storage-kit/index.d.ts +8 -0
  37. package/dist/generated/storage-kit/index.d.ts.map +1 -0
  38. package/dist/generated/storage-kit/migrations.d.ts +48 -0
  39. package/dist/generated/storage-kit/migrations.d.ts.map +1 -0
  40. package/dist/generated/storage-kit/mode.d.ts +48 -0
  41. package/dist/generated/storage-kit/mode.d.ts.map +1 -0
  42. package/dist/generated/storage-kit/pool.d.ts +34 -0
  43. package/dist/generated/storage-kit/pool.d.ts.map +1 -0
  44. package/dist/generated/storage-kit/query.d.ts +36 -0
  45. package/dist/generated/storage-kit/query.d.ts.map +1 -0
  46. package/dist/generated/storage-kit/tls.d.ts +26 -0
  47. package/dist/generated/storage-kit/tls.d.ts.map +1 -0
  48. package/dist/index.d.ts +22 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +23773 -0
  51. package/dist/mcp/compact.d.ts +12 -0
  52. package/dist/mcp/compact.d.ts.map +1 -0
  53. package/dist/mcp/http.d.ts +38 -0
  54. package/dist/mcp/http.d.ts.map +1 -0
  55. package/dist/mcp/index.d.ts +32 -0
  56. package/dist/mcp/index.d.ts.map +1 -0
  57. package/dist/mcp/index.js +6243 -0
  58. package/dist/mcp/tools/domain.d.ts +10 -0
  59. package/dist/mcp/tools/domain.d.ts.map +1 -0
  60. package/dist/mcp/tools/standard.d.ts +4 -0
  61. package/dist/mcp/tools/standard.d.ts.map +1 -0
  62. package/dist/mcp/tools/storage.d.ts +4 -0
  63. package/dist/mcp/tools/storage.d.ts.map +1 -0
  64. package/dist/release/package-smoke.d.ts +11 -0
  65. package/dist/release/package-smoke.d.ts.map +1 -0
  66. package/dist/server/app.d.ts +19 -0
  67. package/dist/server/app.d.ts.map +1 -0
  68. package/dist/server/auth-constants.d.ts +22 -0
  69. package/dist/server/auth-constants.d.ts.map +1 -0
  70. package/dist/server/auth.d.ts +147 -0
  71. package/dist/server/auth.d.ts.map +1 -0
  72. package/dist/server/health.d.ts +23 -0
  73. package/dist/server/health.d.ts.map +1 -0
  74. package/dist/server/index.d.ts +11 -0
  75. package/dist/server/index.d.ts.map +1 -0
  76. package/dist/server/index.js +2094 -0
  77. package/dist/server/list-query.d.ts +7 -0
  78. package/dist/server/list-query.d.ts.map +1 -0
  79. package/dist/services/authorization-constants.d.ts +14 -0
  80. package/dist/services/authorization-constants.d.ts.map +1 -0
  81. package/dist/services/authorization.d.ts +95 -0
  82. package/dist/services/authorization.d.ts.map +1 -0
  83. package/dist/services/balances.d.ts +33 -0
  84. package/dist/services/balances.d.ts.map +1 -0
  85. package/dist/services/context.d.ts +24 -0
  86. package/dist/services/context.d.ts.map +1 -0
  87. package/dist/services/entities.d.ts +14 -0
  88. package/dist/services/entities.d.ts.map +1 -0
  89. package/dist/services/forecast.d.ts +10 -0
  90. package/dist/services/forecast.d.ts.map +1 -0
  91. package/dist/services/fx.d.ts +33 -0
  92. package/dist/services/fx.d.ts.map +1 -0
  93. package/dist/services/ingest.d.ts +19 -0
  94. package/dist/services/ingest.d.ts.map +1 -0
  95. package/dist/services/registry.d.ts +33 -0
  96. package/dist/services/registry.d.ts.map +1 -0
  97. package/dist/services/runway.d.ts +28 -0
  98. package/dist/services/runway.d.ts.map +1 -0
  99. package/dist/services/storage.d.ts +35 -0
  100. package/dist/services/storage.d.ts.map +1 -0
  101. package/dist/services/sweeps.d.ts +26 -0
  102. package/dist/services/sweeps.d.ts.map +1 -0
  103. package/dist/types/index.d.ts +133 -0
  104. package/dist/types/index.d.ts.map +1 -0
  105. package/dist/version.d.ts +3 -0
  106. package/dist/version.d.ts.map +1 -0
  107. package/docker-compose.yml +53 -0
  108. package/hasna.contract.json +20 -0
  109. package/openapi.json +615 -0
  110. package/package.json +80 -0
@@ -0,0 +1,7 @@
1
+ import { Command } from "commander";
2
+ export interface EmitOptions {
3
+ json: () => boolean;
4
+ }
5
+ /** Build one command namespace per domain resource, generated from the registry. */
6
+ export declare function registerOpCommands(program: Command, emitOpts: EmitOptions): void;
7
+ //# sourceMappingURL=namespaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespaces.d.ts","sourceRoot":"","sources":["../../src/cli/namespaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,OAAO,CAAC;CACrB;AAmBD,oFAAoF;AACpF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,IAAI,CA4BhF"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Canonical Hasna Service Contract v1 storage config for treasury.
3
+ *
4
+ * Runtime storage modes are `local | cloud` ONLY (Amendment A1, PURE REMOTE):
5
+ * - local: SQLite at ~/.hasna/treasury/treasury.db is authoritative.
6
+ * - cloud: reads AND writes go directly to the app-owned cloud Postgres.
7
+ *
8
+ * The legacy words `remote`, `hybrid`, and `self_hosted` are accepted only as
9
+ * deprecated aliases that normalize to `cloud`.
10
+ */
11
+ export declare const APP_NAME = "treasury";
12
+ export declare const ENV_TOKEN = "TREASURY";
13
+ export type StorageMode = "local" | "cloud";
14
+ type Env = Record<string, string | undefined>;
15
+ /**
16
+ * Resolve the storage mode from the environment; defaults to `local`.
17
+ *
18
+ * Fail-closed misconfig guard (BUILD-SPEC §2.3): a DATABASE_URL present while
19
+ * mode resolves to `local` is almost certainly a mis-deploy that would silently
20
+ * write to SQLite while a cloud DB is configured — that is a hard startup error.
21
+ */
22
+ export declare function resolveStorageMode(env?: Env): StorageMode;
23
+ /** Whether a cloud database URL is present (presence only — the value is never read to pick a mode). */
24
+ export declare function databaseUrlPresent(env?: Env): boolean;
25
+ /**
26
+ * Resolve the DSN value (BUILD-SPEC §2.4): prefer a `0400` file mount
27
+ * (`*_DATABASE_URL_FILE`), else the env var (local/dev only). Secrets-Manager
28
+ * fetch is a cloud-runtime concern handled by the deploy module; here we only
29
+ * read a file mount or env var. Never logs the value.
30
+ */
31
+ export declare function resolveDatabaseUrl(env?: Env): string | null;
32
+ /**
33
+ * Scrub the DSN from process.env after the store has connected so child
34
+ * processes and `/proc/<pid>/environ` introspection cannot read it (§2.4).
35
+ */
36
+ export declare function scrubDatabaseUrl(env?: Env): void;
37
+ /** Canonical local SQLite path: ~/.hasna/treasury/treasury.db */
38
+ export declare function defaultSqlitePath(): string;
39
+ /** Resolve the SQLite path, honoring the HASNA_TREASURY_DB_PATH override (used by tests). */
40
+ export declare function resolveDbPath(env?: Env): string;
41
+ export {};
42
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ,aAAa,CAAC;AACnC,eAAO,MAAM,SAAS,aAAa,CAAC;AAEpC,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,OAAO,CAAC;AAS5C,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAU9C;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,GAAE,GAAiB,GAAG,WAAW,CA0BtE;AAED,wGAAwG;AACxG,wBAAgB,kBAAkB,CAAC,GAAG,GAAE,GAAiB,GAAG,OAAO,CAElE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,GAAE,GAAiB,GAAG,MAAM,GAAG,IAAI,CAIxE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,GAAiB,GAAG,IAAI,CAE7D;AAED,iEAAiE;AACjE,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,6FAA6F;AAC7F,wBAAgB,aAAa,CAAC,GAAG,GAAE,GAAiB,GAAG,MAAM,CAE5D"}
@@ -0,0 +1,9 @@
1
+ export declare const TREASURY_APP_SUBDIRS: readonly ["config", "data", "exports", "backups", "logs", "tmp"];
2
+ export type TreasuryAppSubdir = (typeof TREASURY_APP_SUBDIRS)[number];
3
+ /** Root: ~/.hasna/treasury (dirs are created mode 0700). */
4
+ export declare function getTreasuryAppHome(): string;
5
+ export declare function getTreasuryAppDir(name: TreasuryAppSubdir): string;
6
+ /** Create ~/.hasna/treasury and all subdirs with mode 0700 (deny-by-default perms). */
7
+ export declare function ensureTreasuryAppHome(): Record<TreasuryAppSubdir | "root", string>;
8
+ export declare function getDefaultTreasuryBackupDir(): string;
9
+ //# sourceMappingURL=app-home.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-home.d.ts","sourceRoot":"","sources":["../../src/core/app-home.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB,kEAAmE,CAAC;AACrG,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAMtE,4DAA4D;AAC5D,wBAAgB,kBAAkB,IAAI,MAAM,CAI3C;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAEjE;AAED,uFAAuF;AACvF,wBAAgB,qBAAqB,IAAI,MAAM,CAAC,iBAAiB,GAAG,MAAM,EAAE,MAAM,CAAC,CAUlF;AAED,wBAAgB,2BAA2B,IAAI,MAAM,CAEpD"}
@@ -0,0 +1,8 @@
1
+ export interface ErrorEnvelope {
2
+ code: string;
3
+ message: string;
4
+ suggestion: string;
5
+ }
6
+ export declare function normalizeError(error: unknown): ErrorEnvelope;
7
+ export declare function httpStatusForCode(code: string): number;
8
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAW5D;AAYD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD"}
@@ -0,0 +1,16 @@
1
+ import type { QueryClient } from "./database.js";
2
+ import type { AuditEvent } from "../types/index.js";
3
+ export interface AppendAuditInput {
4
+ entity_id: string | null;
5
+ actor_id: string;
6
+ action: string;
7
+ detail: string;
8
+ }
9
+ export declare function appendAudit(db: QueryClient, input: AppendAuditInput): Promise<void>;
10
+ export declare function listAudit(db: QueryClient, limit?: number): Promise<AuditEvent[]>;
11
+ /** Recompute the chain and report the first row whose hash does not verify. */
12
+ export declare function verifyAuditChain(db: QueryClient): Promise<{
13
+ ok: boolean;
14
+ brokenAt: number | null;
15
+ }>;
16
+ //# sourceMappingURL=audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/db/audit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAcpD,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,WAAW,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBzF;AAED,wBAAsB,SAAS,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,SAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAEnF;AAED,+EAA+E;AAC/E,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAazG"}
@@ -0,0 +1,14 @@
1
+ export declare function backupsDisabled(): boolean;
2
+ export interface BackupResult {
3
+ skipped: boolean;
4
+ reason?: string;
5
+ backup_path?: string;
6
+ }
7
+ /**
8
+ * Snapshot an existing local DB before applying migrations (BUILD-SPEC §4.4).
9
+ * File mode 0600; backups dir 0700; retains the last N=10 snapshots.
10
+ * Refuses to proceed if it cannot write the required snapshot.
11
+ */
12
+ export declare function maybeBackupBeforeMigration(dbPath: string): BackupResult;
13
+ export declare function listBackups(dbPath: string): string[];
14
+ //# sourceMappingURL=backup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backup.d.ts","sourceRoot":"","sources":["../../src/db/backup.ts"],"names":[],"mappings":"AAMA,wBAAgB,eAAe,IAAI,OAAO,CAIzC;AAYD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAcvE;AAiBD,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAOpD"}
@@ -0,0 +1,40 @@
1
+ import { type StorageMode } from "../config.js";
2
+ /**
3
+ * A tiny dialect-agnostic async query surface shared by every service so the
4
+ * SAME domain code runs over local SQLite and cloud Postgres. Services write
5
+ * `?`-placeholder SQL; the Postgres client rewrites to `$n`.
6
+ */
7
+ export interface QueryClient {
8
+ readonly mode: StorageMode;
9
+ all<T = Record<string, unknown>>(sql: string, params?: unknown[]): Promise<T[]>;
10
+ get<T = Record<string, unknown>>(sql: string, params?: unknown[]): Promise<T | null>;
11
+ run(sql: string, params?: unknown[]): Promise<void>;
12
+ transaction<T>(fn: (tx: QueryClient) => Promise<T>): Promise<T>;
13
+ close(): Promise<void>;
14
+ }
15
+ export interface OpenOptions {
16
+ /** Explicit path/`:memory:` for local tests. */
17
+ path?: string;
18
+ /** Force a fresh client (ignore singleton). */
19
+ fresh?: boolean;
20
+ /**
21
+ * Force a specific storage mode instead of resolving it from env. Used by the
22
+ * storage push/pull/sync tools to open the OPPOSITE (counterpart) store so a
23
+ * transfer truly crosses local<->cloud. Cloud still fails closed without a DSN.
24
+ */
25
+ mode?: StorageMode;
26
+ }
27
+ /**
28
+ * Open the treasury store.
29
+ *
30
+ * - local: bun:sqlite at the resolved path (`:memory:` for tests) — authoritative.
31
+ * - cloud: PURE REMOTE — a real pg pool built from the vendored storage-kit with
32
+ * `sslmode=verify-full`. It NEVER silently falls back to in-memory/SQLite; a
33
+ * missing DSN or connection failure is a hard fail-closed error.
34
+ */
35
+ export declare function openDatabase(opts?: OpenOptions): Promise<QueryClient>;
36
+ export declare function closeDatabase(): void;
37
+ export declare function resetDatabaseSingleton(): void;
38
+ export declare function now(): string;
39
+ export declare function uuid(): string;
40
+ //# sourceMappingURL=database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/db/database.ts"],"names":[],"mappings":"AAGA,OAAO,EAA2E,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAKzH;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IAChF,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACrF,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAChE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAgFD,MAAM,WAAW,WAAW;IAC1B,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,CAQ/E;AA6DD,wBAAgB,aAAa,IAAI,IAAI,CAKpC;AAED,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C;AAED,wBAAgB,GAAG,IAAI,MAAM,CAE5B;AAED,wBAAgB,IAAI,IAAI,MAAM,CAE7B"}
@@ -0,0 +1,14 @@
1
+ export interface MigrationPlanEntry {
2
+ id: string;
3
+ name: string;
4
+ status: "applied" | "planned";
5
+ description: string;
6
+ }
7
+ export interface MigrationPlan {
8
+ version: string;
9
+ current_schema_id: string;
10
+ entries: MigrationPlanEntry[];
11
+ }
12
+ export declare const CURRENT_MIGRATION_PLAN: MigrationPlan;
13
+ export declare function getCurrentMigrationPlan(): MigrationPlan;
14
+ //# sourceMappingURL=migration-plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-plan.d.ts","sourceRoot":"","sources":["../../src/db/migration-plan.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,kBAAkB,EAAE,CAAC;CAC/B;AAED,eAAO,MAAM,sBAAsB,EAAE,aAYpC,CAAC;AAEF,wBAAgB,uBAAuB,IAAI,aAAa,CAEvD"}
@@ -0,0 +1,8 @@
1
+ import type { Database } from "bun:sqlite";
2
+ export declare function runSqliteMigrations(db: Database): void;
3
+ /**
4
+ * Logical migrations for cloud Postgres. Applied in order through the vendored
5
+ * storage-kit executor. Kept in lockstep with the SQLite schema above.
6
+ */
7
+ export declare const POSTGRES_MIGRATIONS: string[];
8
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAmG3C,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAGtD;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,EA0EvC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { TypedQueryClient } from "./query.js";
2
+ import { type Migration, type MigrationRunnerOptions } from "./migrations.js";
3
+ export interface HealthResult {
4
+ ok: boolean;
5
+ /** Round-trip latency of the probe query, in milliseconds. */
6
+ latencyMs: number;
7
+ error?: string;
8
+ }
9
+ /** Cheap reachability probe: `SELECT 1`. Never throws — reports `ok: false`. */
10
+ export declare function checkHealth(client: TypedQueryClient): Promise<HealthResult>;
11
+ export interface ReadyResult extends HealthResult {
12
+ /** Migration ids that are defined but not yet applied. */
13
+ pendingMigrations: string[];
14
+ }
15
+ /**
16
+ * Readiness probe: reachable AND fully migrated. Reports `ok: false` with the
17
+ * list of pending migration ids when the schema is behind.
18
+ */
19
+ export declare function checkReady(client: TypedQueryClient, migrations: readonly Migration[], options?: MigrationRunnerOptions): Promise<ReadyResult>;
20
+ //# sourceMappingURL=health.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../src/generated/storage-kit/health.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAmB,KAAK,SAAS,EAAE,KAAK,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE/F,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,gFAAgF;AAChF,wBAAsB,WAAW,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAYjF;AAED,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C,0DAA0D;IAC1D,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,SAAS,SAAS,EAAE,EAChC,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,WAAW,CAAC,CAetB"}
@@ -0,0 +1,8 @@
1
+ export declare const KIT_VERSION = "0.4.1";
2
+ export * from "./mode.js";
3
+ export * from "./tls.js";
4
+ export * from "./query.js";
5
+ export * from "./pool.js";
6
+ export * from "./migrations.js";
7
+ export * from "./health.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generated/storage-kit/index.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,48 @@
1
+ import type { TypedQueryClient } from "./query.js";
2
+ /** Default ledger table name. Override per app if a legacy name exists. */
3
+ export declare const DEFAULT_MIGRATION_LEDGER_TABLE = "schema_migrations";
4
+ export interface Migration {
5
+ readonly id: string;
6
+ readonly sql: string;
7
+ readonly checksum: string;
8
+ }
9
+ export type MigrationState = "already_applied" | "pending";
10
+ export interface MigrationPlanItem {
11
+ readonly migration: Migration;
12
+ readonly state: MigrationState;
13
+ }
14
+ export interface AppliedMigration {
15
+ readonly id: string;
16
+ readonly checksum: string;
17
+ readonly appliedAt: string;
18
+ }
19
+ export interface MigrationResult {
20
+ readonly dryRun: boolean;
21
+ readonly applied: AppliedMigration[];
22
+ readonly plan: MigrationPlanItem[];
23
+ }
24
+ /** Stable sha256 checksum for a migration's SQL text. */
25
+ export declare function checksumSql(sql: string): string;
26
+ /** Freeze a migration definition, computing its checksum from the SQL. */
27
+ export declare function defineMigration(id: string, sql: string): Migration;
28
+ export interface MigrationRunnerOptions {
29
+ ledgerTable?: string;
30
+ }
31
+ export declare class MigrationLedger {
32
+ private readonly client;
33
+ private readonly migrations;
34
+ private readonly ledgerTable;
35
+ constructor(client: TypedQueryClient, migrations: readonly Migration[], options?: MigrationRunnerOptions);
36
+ ensureLedger(): Promise<void>;
37
+ listApplied(): Promise<AppliedMigration[]>;
38
+ private readApplied;
39
+ /** Compute the migration plan and guard against drift/downgrade. */
40
+ private buildPlan;
41
+ /** Apply all pending migrations. With `dryRun`, report the plan only. */
42
+ migrate(opts?: {
43
+ dryRun?: boolean;
44
+ }): Promise<MigrationResult>;
45
+ }
46
+ /** Convenience: build a ledger and run all pending migrations. */
47
+ export declare function createMigrationLedger(client: TypedQueryClient, migrations: readonly Migration[], options?: MigrationRunnerOptions): MigrationLedger;
48
+ //# sourceMappingURL=migrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../src/generated/storage-kit/migrations.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,2EAA2E;AAC3E,eAAO,MAAM,8BAA8B,sBAAsB,CAAC;AAElE,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,cAAc,GAAG,iBAAiB,GAAG,SAAS,CAAC;AAE3D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;CAChC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,gBAAgB,EAAE,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,EAAE,CAAC;CACpC;AAED,yDAAyD;AACzD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG/C;AAED,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAElE;AAQD,MAAM,WAAW,sBAAsB;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,eAAe;IAIxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJ7B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;gBAGlB,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,SAAS,SAAS,EAAE,EACjD,OAAO,GAAE,sBAA2B;IAUhC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAU7B,WAAW,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAKlC,WAAW;IAWzB,oEAAoE;IACpE,OAAO,CAAC,SAAS;IAsBjB,yEAAyE;IACnE,OAAO,CAAC,IAAI,GAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,eAAe,CAAC;CAiBzE;AAED,kEAAkE;AAClE,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,SAAS,SAAS,EAAE,EAChC,OAAO,GAAE,sBAA2B,GACnC,eAAe,CAEjB"}
@@ -0,0 +1,48 @@
1
+ export declare const STORAGE_MODES: readonly ["local", "cloud"];
2
+ export type StorageMode = (typeof STORAGE_MODES)[number];
3
+ export declare const DEPRECATED_STORAGE_MODE_ALIASES: readonly ["remote", "hybrid", "self_hosted"];
4
+ export type Env = Record<string, string | undefined>;
5
+ export interface StorageModeNormalization {
6
+ mode: StorageMode;
7
+ /** The deprecated alias that was normalized to `cloud`, if any. */
8
+ deprecatedAlias: string | null;
9
+ }
10
+ /**
11
+ * Normalize a raw storage-mode string to the `local | cloud` runtime enum.
12
+ * Accepts deprecated aliases (`remote`, `hybrid`, `self_hosted`) and maps them
13
+ * to `cloud`. Throws on any other value.
14
+ */
15
+ export declare function normalizeStorageMode(value: string): StorageModeNormalization;
16
+ /** Upper-snake env token for an app name, e.g. `todos` -> `TODOS`. */
17
+ export declare function envToken(name: string): string;
18
+ export interface StorageEnvKeys {
19
+ /** `HASNA_<NAME>_STORAGE_MODE` then the optional `<NAME>_STORAGE_MODE` alias. */
20
+ modeKeys: string[];
21
+ /** `HASNA_<NAME>_DATABASE_URL` then the optional `<NAME>_DATABASE_URL` alias. */
22
+ databaseUrlKeys: string[];
23
+ }
24
+ /** Resolve the canonical env-key spec for an app's storage config. */
25
+ export declare function storageEnvKeys(name: string): StorageEnvKeys;
26
+ export interface StorageModeResolution {
27
+ mode: StorageMode;
28
+ /** Env key the mode came from, or `"default"`. */
29
+ source: string;
30
+ deprecatedAlias: string | null;
31
+ databaseUrlPresent: boolean;
32
+ /** Env key the database URL came from, or `null`. */
33
+ databaseUrlSource: string | null;
34
+ warning: string | null;
35
+ }
36
+ /**
37
+ * Resolve an app's storage mode from the environment per the contract env spec.
38
+ * Precedence: `HASNA_<NAME>_STORAGE_MODE`, then `<NAME>_STORAGE_MODE`, else
39
+ * `local`. Never reads secret values — only detects DATABASE_URL presence.
40
+ */
41
+ export declare function resolveStorageMode(name: string, env?: Env): StorageModeResolution;
42
+ /**
43
+ * Resolve the database URL value for an app, honoring the canonical then alias
44
+ * env keys. Returns `null` when unset. The caller is responsible for never
45
+ * logging the returned value.
46
+ */
47
+ export declare function resolveDatabaseUrl(name: string, env?: Env): string | null;
48
+ //# sourceMappingURL=mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode.d.ts","sourceRoot":"","sources":["../../../src/generated/storage-kit/mode.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,aAAa,6BAA8B,CAAC;AACzD,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,eAAO,MAAM,+BAA+B,8CAIlC,CAAC;AAEX,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAErD,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,WAAW,CAAC;IAClB,mEAAmE;IACnE,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,wBAAwB,CAQ5E;AAED,sEAAsE;AACtE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,MAAM,WAAW,cAAc;IAC7B,iFAAiF;IACjF,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,iFAAiF;IACjF,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,sEAAsE;AACtE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAM3D;AAUD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,WAAW,CAAC;IAClB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,qDAAqD;IACrD,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,GAAiB,GAAG,qBAAqB,CAwC9F;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,GAAiB,GAAG,MAAM,GAAG,IAAI,CAItF"}
@@ -0,0 +1,34 @@
1
+ import type { Pool } from "pg";
2
+ import { type TlsResolveOptions } from "./tls.js";
3
+ import { type PoolQueryClient } from "./query.js";
4
+ export interface CreatePgPoolOptions extends TlsResolveOptions {
5
+ connectionString: string;
6
+ /** Max clients in the pool. Defaults to pg's default (10). */
7
+ max?: number;
8
+ /** Idle client timeout (ms). */
9
+ idleTimeoutMillis?: number;
10
+ /** Connection acquisition timeout (ms). */
11
+ connectionTimeoutMillis?: number;
12
+ /** Application name reported to Postgres (shows in pg_stat_activity). */
13
+ applicationName?: string;
14
+ }
15
+ /** Build a `pg.Pool` with fleet-standard TLS handling. */
16
+ export declare function createPgPool(options: CreatePgPoolOptions): Pool;
17
+ export interface CreateCloudPoolFromEnvOptions extends TlsResolveOptions {
18
+ max?: number;
19
+ idleTimeoutMillis?: number;
20
+ connectionTimeoutMillis?: number;
21
+ applicationName?: string;
22
+ }
23
+ export interface CloudPoolFromEnv {
24
+ client: PoolQueryClient;
25
+ connectionSource: string;
26
+ }
27
+ /**
28
+ * Resolve mode + database URL from the environment and build a cloud pool.
29
+ *
30
+ * Throws when the resolved mode is not `cloud` (PURE REMOTE has no Postgres in
31
+ * `local` mode) or when the database URL is missing. Never logs the URL.
32
+ */
33
+ export declare function createCloudPoolFromEnv(appName: string, options?: CreateCloudPoolFromEnvOptions): CloudPoolFromEnv;
34
+ //# sourceMappingURL=pool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../../src/generated/storage-kit/pool.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,IAAI,CAAC;AAE3C,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAErE,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,gBAAgB,EAAE,MAAM,CAAC;IACzB,8DAA8D;IAC9D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,2CAA2C;IAC3C,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,yEAAyE;IACzE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,0DAA0D;AAC1D,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAe/D;AAED,MAAM,WAAW,6BAA8B,SAAQ,iBAAiB;IACtE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,eAAe,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,6BAAkC,GAC1C,gBAAgB,CAgClB"}
@@ -0,0 +1,36 @@
1
+ import type { Pool, QueryResultRow } from "pg";
2
+ export interface QueryResult<T extends QueryResultRow> {
3
+ rows: T[];
4
+ rowCount: number;
5
+ }
6
+ /**
7
+ * Minimal executor contract. `pg.Pool` and `pg.PoolClient` both satisfy the
8
+ * `query` method; the wrapper builds the rest on top so tests can substitute a
9
+ * lightweight shim without pulling in a live Postgres.
10
+ */
11
+ export interface PgExecutor {
12
+ query<T extends QueryResultRow>(sql: string, params?: readonly unknown[]): Promise<{
13
+ rows: T[];
14
+ rowCount: number | null;
15
+ }>;
16
+ }
17
+ export interface TypedQueryClient {
18
+ query<T extends QueryResultRow>(sql: string, params?: readonly unknown[]): Promise<QueryResult<T>>;
19
+ many<T extends QueryResultRow>(sql: string, params?: readonly unknown[]): Promise<T[]>;
20
+ /** First row or `null`. Restored here after open-knowledge dropped it. */
21
+ get<T extends QueryResultRow>(sql: string, params?: readonly unknown[]): Promise<T | null>;
22
+ /** Exactly one row; throws if zero or more than one row is returned. */
23
+ one<T extends QueryResultRow>(sql: string, params?: readonly unknown[]): Promise<T>;
24
+ execute(sql: string, params?: readonly unknown[]): Promise<void>;
25
+ }
26
+ /** Wrap any `PgExecutor` (a Pool, a PoolClient, or a test shim) with the typed vocabulary. */
27
+ export declare function wrapExecutor(executor: PgExecutor): TypedQueryClient;
28
+ export interface PoolQueryClient extends TypedQueryClient {
29
+ readonly pool: Pool;
30
+ /** Run a callback inside a `BEGIN`/`COMMIT` transaction on a dedicated client. */
31
+ transaction<T>(fn: (client: TypedQueryClient) => Promise<T>): Promise<T>;
32
+ close(): Promise<void>;
33
+ }
34
+ /** Build a `PoolQueryClient` around a live `pg.Pool`. */
35
+ export declare function createQueryClient(pool: Pool): PoolQueryClient;
36
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/generated/storage-kit/query.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,IAAI,EAAc,cAAc,EAAE,MAAM,IAAI,CAAC;AAE3D,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,cAAc;IACnD,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,CAAC,SAAS,cAAc,EAC5B,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAC1B,OAAO,CAAC;QAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,CAAC,SAAS,cAAc,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACnG,IAAI,CAAC,CAAC,SAAS,cAAc,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IACvF,0EAA0E;IAC1E,GAAG,CAAC,CAAC,SAAS,cAAc,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC3F,wEAAwE;IACxE,GAAG,CAAC,CAAC,SAAS,cAAc,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACpF,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClE;AAED,8FAA8F;AAC9F,wBAAgB,YAAY,CAAC,QAAQ,EAAE,UAAU,GAAG,gBAAgB,CAyBnE;AAED,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,kFAAkF;IAClF,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACzE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,yDAAyD;AACzD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,eAAe,CA2B7D"}
@@ -0,0 +1,26 @@
1
+ /** The `ssl` field shape accepted by `pg.Pool` / `pg.Client`. */
2
+ export type PgSslConfig = boolean | {
3
+ rejectUnauthorized: boolean;
4
+ ca?: string;
5
+ };
6
+ export interface TlsResolveOptions {
7
+ /** Inline CA bundle (PEM). Wins over every other CA source. */
8
+ ca?: string;
9
+ /** Path to a CA bundle PEM file, e.g. the Amazon RDS global bundle. */
10
+ caCertPath?: string;
11
+ /** Environment used to discover PGSSLROOTCERT / NODE_EXTRA_CA_CERTS. */
12
+ env?: Record<string, string | undefined>;
13
+ }
14
+ export type SslMode = "disable" | "prefer" | "require" | "verify-ca" | "verify-full";
15
+ /**
16
+ * Extract the effective `sslmode` from a Postgres connection string. Honors the
17
+ * `sslmode` query param and the legacy `ssl=true` boolean. Returns `disable`
18
+ * when TLS is not requested.
19
+ */
20
+ export declare function sslModeFromConnectionString(connectionString: string): SslMode;
21
+ /**
22
+ * Resolve the `pg` ssl config for a connection string. See the module header
23
+ * for the full mode table. Returns `undefined` when TLS should be off.
24
+ */
25
+ export declare function resolveTlsConfig(connectionString: string, options?: TlsResolveOptions): PgSslConfig | undefined;
26
+ //# sourceMappingURL=tls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tls.d.ts","sourceRoot":"","sources":["../../../src/generated/storage-kit/tls.ts"],"names":[],"mappings":"AAkCA,iEAAiE;AACjE,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG;IAAE,kBAAkB,EAAE,OAAO,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjF,MAAM,WAAW,iBAAiB;IAChC,+DAA+D;IAC/D,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC1C;AAED,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,aAAa,CAAC;AAErF;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAwB7E;AAUD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,gBAAgB,EAAE,MAAM,EACxB,OAAO,GAAE,iBAAsB,GAC9B,WAAW,GAAG,SAAS,CA2BzB"}
@@ -0,0 +1,22 @@
1
+ export * from "./version.js";
2
+ export * from "./config.js";
3
+ export * from "./types/index.js";
4
+ export * from "./db/database.js";
5
+ export * from "./db/audit.js";
6
+ export { getCurrentMigrationPlan } from "./db/migration-plan.js";
7
+ export * from "./services/context.js";
8
+ export * from "./services/authorization.js";
9
+ export * as auth from "./server/auth.js";
10
+ export * from "./services/entities.js";
11
+ export * from "./services/balances.js";
12
+ export * from "./services/fx.js";
13
+ export * from "./services/runway.js";
14
+ export * from "./services/forecast.js";
15
+ export * from "./services/sweeps.js";
16
+ export * from "./services/ingest.js";
17
+ export * from "./services/storage.js";
18
+ export { OPS } from "./services/registry.js";
19
+ export { openApiDocument } from "./api/index.js";
20
+ export { buildServer } from "./mcp/index.js";
21
+ export { createApp } from "./server/app.js";
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}