@hasna/shortlinks 0.1.18 → 0.1.20

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hasna/shortlinks",
3
- "version": "0.1.18",
4
- "description": "CLI-only shortlink manager for custom domains, click tracking, Cloudflare setup, and repo-native storage sync",
3
+ "version": "0.1.20",
4
+ "description": "CLI-only shortlink manager for custom domains, click tracking, Cloudflare setup, and @hasna cloud sync",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -20,10 +20,6 @@
20
20
  "./cloudflare": {
21
21
  "types": "./dist/cloudflare.d.ts",
22
22
  "import": "./dist/cloudflare.js"
23
- },
24
- "./storage": {
25
- "types": "./dist/storage.d.ts",
26
- "import": "./dist/storage.js"
27
23
  }
28
24
  },
29
25
  "files": [
@@ -35,7 +31,7 @@
35
31
  "SECURITY.md"
36
32
  ],
37
33
  "scripts": {
38
- "build": "rm -rf dist && bun build src/cli/index.ts --outdir dist/cli --target bun && bun build src/index.ts src/storage.ts --outdir dist --target bun && bun build src/server.ts --outdir dist --target bun && bun build src/cloudflare.ts --outdir dist --target bun && tsc -p tsconfig.build.json --emitDeclarationOnly --outDir dist",
34
+ "build": "rm -rf dist && bun build src/cli/index.ts --outdir dist/cli --target bun --external @hasna/cloud && bun build src/index.ts --outdir dist --target bun --external @hasna/cloud && bun build src/server.ts --outdir dist --target bun --external @hasna/cloud && bun build src/cloudflare.ts --outdir dist --target bun && tsc -p tsconfig.build.json --emitDeclarationOnly --outDir dist",
39
35
  "typecheck": "tsc --noEmit",
40
36
  "test": "bun test",
41
37
  "dev:cli": "bun run src/cli/index.ts",
@@ -70,14 +66,13 @@
70
66
  "author": "Andrei Hasna <andrei@hasna.com>",
71
67
  "license": "Apache-2.0",
72
68
  "dependencies": {
69
+ "@hasna/cloud": "0.1.30",
70
+ "@hasna/events": "^0.1.6",
73
71
  "chalk": "^5.4.1",
74
- "commander": "^13.1.0",
75
- "pg": "^8.13.3",
76
- "@hasna/events": "^0.1.6"
72
+ "commander": "^13.1.0"
77
73
  },
78
74
  "devDependencies": {
79
75
  "@types/bun": "^1.2.4",
80
- "@types/pg": "^8.11.11",
81
76
  "typescript": "^5.7.3"
82
77
  }
83
78
  }
@@ -1,30 +0,0 @@
1
- import type { AddDomainInput, CreateLinkInput, Domain, Link, LinkStats } from "./types.js";
2
- export interface ShortlinksApiClientOptions {
3
- baseUrl?: string;
4
- token?: string;
5
- }
6
- export declare class ShortlinksApiClient {
7
- private readonly options;
8
- constructor(options?: ShortlinksApiClientOptions);
9
- private url;
10
- private headers;
11
- totalStats(): Promise<{
12
- domains: number;
13
- links: number;
14
- clicks: number;
15
- }>;
16
- createLink(input: CreateLinkInput): Promise<Link>;
17
- listLinks(options?: {
18
- domain?: string;
19
- activeOnly?: boolean;
20
- limit?: number;
21
- }): Promise<Link[]>;
22
- getLink(domainOrSlug: string, maybeSlug?: string): Promise<Link | null>;
23
- setLinkActive(domainOrSlug: string, maybeSlugOrActive: string | boolean, maybeActive?: boolean): Promise<Link>;
24
- deleteLink(domainOrSlug: string, maybeSlug?: string): Promise<Link>;
25
- getStats(domainOrSlug: string, maybeSlug?: string): Promise<LinkStats>;
26
- addDomain(input: AddDomainInput): Promise<Domain>;
27
- listDomains(): Promise<Domain[]>;
28
- getDomain(hostname: string): Promise<Domain | null>;
29
- close(): Promise<void>;
30
- }
@@ -1,7 +0,0 @@
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>;
@@ -1,11 +0,0 @@
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
- }
@@ -1,37 +0,0 @@
1
- export type StorageMode = "local" | "remote" | "hybrid";
2
- export interface StorageConfig {
3
- mode: StorageMode;
4
- rds: {
5
- host: string;
6
- port: number;
7
- username: string;
8
- password_env: string;
9
- ssl: boolean;
10
- };
11
- }
12
- export interface StorageEnv {
13
- name: string;
14
- }
15
- export declare const SHORTLINKS_STORAGE_ENV = "HASNA_SHORTLINKS_DATABASE_URL";
16
- export declare const SHORTLINKS_STORAGE_FALLBACK_ENV = "SHORTLINKS_DATABASE_URL";
17
- export declare const SHORTLINKS_STORAGE_MODE_ENV = "HASNA_SHORTLINKS_STORAGE_MODE";
18
- export declare const SHORTLINKS_STORAGE_MODE_FALLBACK_ENV = "SHORTLINKS_STORAGE_MODE";
19
- export declare const STORAGE_DATABASE_ENV: readonly ["HASNA_SHORTLINKS_DATABASE_URL", "SHORTLINKS_DATABASE_URL"];
20
- export declare const STORAGE_MODE_ENV: readonly ["HASNA_SHORTLINKS_STORAGE_MODE", "SHORTLINKS_STORAGE_MODE"];
21
- export declare const CANONICAL_SHORTLINKS_RDS_CLUSTER = "postgres-compatible-database";
22
- export declare const CANONICAL_SHORTLINKS_RDS_DATABASE = "shortlinks";
23
- export declare const CANONICAL_SHORTLINKS_RDS_SECRET_PATH = "configured-by-environment";
24
- export interface CanonicalShortlinksRdsConfig {
25
- cluster: typeof CANONICAL_SHORTLINKS_RDS_CLUSTER;
26
- database: typeof CANONICAL_SHORTLINKS_RDS_DATABASE;
27
- runtimeSecretPath: typeof CANONICAL_SHORTLINKS_RDS_SECRET_PATH;
28
- primaryEnv: typeof SHORTLINKS_STORAGE_ENV;
29
- fallbackEnv: typeof SHORTLINKS_STORAGE_FALLBACK_ENV;
30
- }
31
- export declare function getCanonicalShortlinksRdsConfig(): CanonicalShortlinksRdsConfig;
32
- export declare function getStorageDatabaseUrl(): string | undefined;
33
- export declare function getStorageDatabaseEnvName(): (typeof STORAGE_DATABASE_ENV)[number] | null;
34
- export declare function getStorageDatabaseEnv(): StorageEnv | null;
35
- export declare function getStorageConfig(): StorageConfig;
36
- export declare function getStorageConnectionString(dbName?: string): string;
37
- export declare const getConnectionString: typeof getStorageConnectionString;
@@ -1,36 +0,0 @@
1
- import { STORAGE_DATABASE_ENV, type CanonicalShortlinksRdsConfig, type StorageMode } from "./storage-config.js";
2
- import { PgAdapterAsync } from "./remote-storage.js";
3
- export interface StorageSyncResult {
4
- table: string;
5
- direction: "push" | "pull";
6
- rowsRead: number;
7
- rowsWritten: number;
8
- errors: string[];
9
- }
10
- export type SyncResult = StorageSyncResult;
11
- export interface StorageStatus {
12
- configured: boolean;
13
- mode: StorageMode;
14
- enabled: boolean;
15
- env: typeof STORAGE_DATABASE_ENV;
16
- activeEnv: string | null;
17
- canonical: CanonicalShortlinksRdsConfig;
18
- service: "shortlinks";
19
- db_path: string;
20
- tables: Array<{
21
- table: string;
22
- rows: number;
23
- }>;
24
- }
25
- export declare const STORAGE_TABLES: readonly ["domains", "links", "clicks"];
26
- export declare const SHORTLINKS_STORAGE_TABLES: readonly ["domains", "links", "clicks"];
27
- export declare function getStoragePg(): Promise<PgAdapterAsync>;
28
- export declare function runStorageMigrations(remote: PgAdapterAsync): Promise<void>;
29
- export declare function getStorageStatus(dbPath?: string): StorageStatus;
30
- export declare function pushStorageChanges(dbPath?: string, tables?: string[]): Promise<StorageSyncResult[]>;
31
- export declare function pullStorageChanges(dbPath?: string, tables?: string[]): Promise<StorageSyncResult[]>;
32
- export declare function syncStorageChanges(dbPath?: string, tables?: string[]): Promise<{
33
- push: StorageSyncResult[];
34
- pull: StorageSyncResult[];
35
- }>;
36
- export declare function parseStorageTables(raw?: string): string[];
package/dist/storage.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export { CANONICAL_SHORTLINKS_RDS_CLUSTER, CANONICAL_SHORTLINKS_RDS_DATABASE, CANONICAL_SHORTLINKS_RDS_SECRET_PATH, SHORTLINKS_STORAGE_ENV, SHORTLINKS_STORAGE_FALLBACK_ENV, SHORTLINKS_STORAGE_MODE_ENV, SHORTLINKS_STORAGE_MODE_FALLBACK_ENV, STORAGE_DATABASE_ENV, STORAGE_MODE_ENV, getConnectionString, getCanonicalShortlinksRdsConfig, getStorageConfig, getStorageConnectionString, getStorageDatabaseEnv, getStorageDatabaseEnvName, getStorageDatabaseUrl, } from "./storage-config.js";
2
- export type { CanonicalShortlinksRdsConfig, StorageConfig, StorageEnv, StorageMode } from "./storage-config.js";
3
- export { SHORTLINKS_STORAGE_TABLES, STORAGE_TABLES, getStoragePg, getStorageStatus, parseStorageTables, pullStorageChanges, pushStorageChanges, runStorageMigrations, syncStorageChanges, } from "./storage-sync.js";
4
- export type { StorageStatus, StorageSyncResult, SyncResult } from "./storage-sync.js";
5
- export { PgAdapterAsync } from "./remote-storage.js";
6
- export { PG_MIGRATIONS } from "./pg-migrations.js";