@hasna/shortlinks 0.2.0 → 0.2.1

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/dist/server.js CHANGED
@@ -430,6 +430,17 @@ class ShortlinksStore {
430
430
  `).get(normalized, hostnameOrId);
431
431
  return row ? domainFromRow(row) : null;
432
432
  }
433
+ deleteDomain(hostnameOrId) {
434
+ const domain = this.getDomain(hostnameOrId);
435
+ if (!domain)
436
+ throw new Error("Domain not found.");
437
+ this.database.db.query("DELETE FROM domains WHERE id = ?").run(domain.id);
438
+ const config = loadConfig();
439
+ if (config.defaultDomain && normalizeHostname(config.defaultDomain) === domain.hostname) {
440
+ updateConfig({ defaultDomain: undefined, publicBaseUrl: undefined });
441
+ }
442
+ return domain;
443
+ }
433
444
  getDefaultDomain() {
434
445
  const config = loadConfig();
435
446
  if (config.defaultDomain) {
@@ -20,6 +20,11 @@ export interface Store {
20
20
  listDomains(): Promise<Domain[]>;
21
21
  getDomain(hostnameOrId: string): Promise<Domain | null>;
22
22
  getDefaultDomain(): Promise<Domain | null>;
23
+ /**
24
+ * Delete a domain (by hostname or id) and, via ON DELETE CASCADE, all of its
25
+ * links and clicks. Returns the deleted domain. Throws when not found.
26
+ */
27
+ deleteDomain(hostnameOrId: string): Promise<Domain>;
23
28
  createLink(input: CreateLinkInput): Promise<Link>;
24
29
  listLinks(options?: ListLinksOptions): Promise<Link[]>;
25
30
  getLink(domainOrSlug: string, maybeSlug?: string): Promise<Link | null>;
package/dist/store.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare class ShortlinksStore {
7
7
  addDomain(input: AddDomainInput): Domain;
8
8
  listDomains(): Domain[];
9
9
  getDomain(hostnameOrId: string): Domain | null;
10
+ deleteDomain(hostnameOrId: string): Domain;
10
11
  getDefaultDomain(): Domain | null;
11
12
  createLink(input: CreateLinkInput): Link;
12
13
  listLinks(options?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/shortlinks",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Shortlink manager for custom domains and click tracking, with local SQLite or self-hosted cloud (/v1 API + bearer key) storage and Cloudflare setup helpers",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -41,7 +41,7 @@
41
41
  "SECURITY.md"
42
42
  ],
43
43
  "scripts": {
44
- "build": "rm -rf dist && bun build src/cli/index.ts src/mcp/index.ts src/serve/index.ts src/sdk/index.ts src/index.ts src/server.ts src/cloudflare.ts src/pg-store.ts --root src --outdir dist --target bun --external @modelcontextprotocol/sdk --external @hasna/mcp-harness --external @hasna/mcp-harness/node && tsc -p tsconfig.build.json --emitDeclarationOnly --outDir dist",
44
+ "build": "rm -rf dist && bun build src/cli/index.ts src/mcp/index.ts src/serve/index.ts src/sdk/index.ts src/index.ts src/server.ts src/cloudflare.ts src/pg-store.ts --root src --outdir dist --target bun --external @modelcontextprotocol/sdk && tsc -p tsconfig.build.json --emitDeclarationOnly --outDir dist",
45
45
  "sdk:generate": "bun run scripts/generate-sdk.ts",
46
46
  "typecheck": "tsc --noEmit",
47
47
  "test": "bun test",
@@ -81,7 +81,6 @@
81
81
  "license": "Apache-2.0",
82
82
  "dependencies": {
83
83
  "@hasna/events": "^0.1.6",
84
- "@hasna/mcp-harness": "file:../open-mcp",
85
84
  "@modelcontextprotocol/sdk": "^1.27.1",
86
85
  "chalk": "^5.4.1",
87
86
  "commander": "^13.1.0",
@@ -89,7 +88,7 @@
89
88
  "pg": "^8.13.3"
90
89
  },
91
90
  "devDependencies": {
92
- "@hasna/contracts": "file:../open-contracts",
91
+ "@hasna/contracts": "^0.5.2",
93
92
  "@types/pg": "^8.11.11",
94
93
  "@types/bun": "^1.2.4",
95
94
  "typescript": "^5.7.3"