@hasna/shortlinks 0.1.22 → 0.1.24

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.
@@ -1,3 +1,4 @@
1
+ import type { TypedQueryClient } from "./generated/storage-kit/query.js";
1
2
  import type { AddDomainInput, Click, ClickInput, CreateLinkInput, Domain, Link, LinkStats } from "./types.js";
2
3
  type PgAdapterLike = {
3
4
  get(sql: string, ...params: unknown[]): Promise<any>;
@@ -5,11 +6,23 @@ type PgAdapterLike = {
5
6
  run(sql: string, ...params: unknown[]): Promise<unknown>;
6
7
  close?: () => Promise<void>;
7
8
  };
9
+ export interface PgConnectionOptions {
10
+ ssl?: boolean;
11
+ }
12
+ /**
13
+ * Adapt a vendored storage-kit `TypedQueryClient` (which speaks `$1` positional
14
+ * params) to the `?`-placeholder `PgAdapterLike` the store queries are written
15
+ * against. This lets `shortlinks-serve` reuse the exact same SQL as the CLI while
16
+ * opening its cloud pool through the sanctioned kit (`createCloudPoolFromEnv`).
17
+ */
18
+ export declare function createKitPgAdapter(client: TypedQueryClient): PgAdapterLike;
8
19
  export declare class PgShortlinksStore {
9
20
  private readonly pg;
10
21
  constructor(pg: PgAdapterLike);
11
- static fromConnectionString(connectionString: string): Promise<PgShortlinksStore>;
12
- static fromCloud(service?: string): Promise<PgShortlinksStore>;
22
+ static fromConnectionString(connectionString: string, options?: PgConnectionOptions): Promise<PgShortlinksStore>;
23
+ /** Build a store over a vendored storage-kit query client (the serve path). */
24
+ static fromQueryClient(client: TypedQueryClient): PgShortlinksStore;
25
+ static fromEnv(env?: NodeJS.ProcessEnv): Promise<PgShortlinksStore>;
13
26
  close(): Promise<void>;
14
27
  addDomain(input: AddDomainInput): Promise<Domain>;
15
28
  listDomains(): Promise<Domain[]>;
@@ -35,4 +48,9 @@ export declare class PgShortlinksStore {
35
48
  private hashIp;
36
49
  private generateAvailableSlug;
37
50
  }
51
+ export declare function applyPostgresMigrations(connectionString: string, migrations: string[], options?: PgConnectionOptions): Promise<{
52
+ service: "shortlinks";
53
+ applied: number[];
54
+ skipped: number[];
55
+ }>;
38
56
  export {};