@hasna/contacts 0.6.23 → 0.6.28
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/README.md +61 -3
- package/dist/cli/commands/advanced.d.ts.map +1 -1
- package/dist/cli/commands/audience.d.ts +18 -0
- package/dist/cli/commands/audience.d.ts.map +1 -0
- package/dist/cli/commands/core.d.ts.map +1 -1
- package/dist/cli/commands/crm.d.ts.map +1 -1
- package/dist/cli/index.js +8605 -5889
- package/dist/cli/storage.d.ts.map +1 -1
- package/dist/cloud/http-storage.d.ts +88 -0
- package/dist/cloud/http-storage.d.ts.map +1 -0
- package/dist/db/audiences.d.ts +51 -0
- package/dist/db/audiences.d.ts.map +1 -0
- package/dist/db/companies.d.ts.map +1 -1
- package/dist/db/contacts.d.ts.map +1 -1
- package/dist/db/database.d.ts +1 -2
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/paths.d.ts +3 -0
- package/dist/db/paths.d.ts.map +1 -0
- package/dist/db/pg-migrations.d.ts.map +1 -1
- package/dist/db/storage.d.ts +1 -1
- package/dist/db/storage.d.ts.map +1 -1
- package/dist/db/tags.d.ts.map +1 -1
- package/dist/db/tombstones.d.ts +19 -0
- package/dist/db/tombstones.d.ts.map +1 -0
- package/dist/generated/storage-kit/health.d.ts +20 -0
- package/dist/generated/storage-kit/health.d.ts.map +1 -0
- package/dist/generated/storage-kit/index.d.ts +8 -0
- package/dist/generated/storage-kit/index.d.ts.map +1 -0
- package/dist/generated/storage-kit/migrations.d.ts +48 -0
- package/dist/generated/storage-kit/migrations.d.ts.map +1 -0
- package/dist/generated/storage-kit/mode.d.ts +48 -0
- package/dist/generated/storage-kit/mode.d.ts.map +1 -0
- package/dist/generated/storage-kit/pool.d.ts +34 -0
- package/dist/generated/storage-kit/pool.d.ts.map +1 -0
- package/dist/generated/storage-kit/query.d.ts +36 -0
- package/dist/generated/storage-kit/query.d.ts.map +1 -0
- package/dist/generated/storage-kit/tls.d.ts +26 -0
- package/dist/generated/storage-kit/tls.d.ts.map +1 -0
- package/dist/index.d.ts +6 -79
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4144 -4050
- package/dist/lib/audience-contract.d.ts +215 -0
- package/dist/lib/audience-contract.d.ts.map +1 -0
- package/dist/lib/mailery-sync.d.ts +46 -0
- package/dist/lib/mailery-sync.d.ts.map +1 -0
- package/dist/lib/package-version.d.ts +6 -0
- package/dist/lib/package-version.d.ts.map +1 -0
- package/dist/mcp/handlers/advanced.d.ts +5 -0
- package/dist/mcp/handlers/advanced.d.ts.map +1 -1
- package/dist/mcp/handlers/audience.d.ts +9 -0
- package/dist/mcp/handlers/audience.d.ts.map +1 -0
- package/dist/mcp/handlers/core.d.ts +4 -0
- package/dist/mcp/handlers/core.d.ts.map +1 -1
- package/dist/mcp/handlers/crm.d.ts +5 -0
- package/dist/mcp/handlers/crm.d.ts.map +1 -1
- package/dist/mcp/handlers/index.d.ts.map +1 -1
- package/dist/mcp/index.js +10963 -10178
- package/dist/mcp/storage-tools.d.ts.map +1 -1
- package/dist/mcp/tools.d.ts +252 -0
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/sdk/index.d.ts +16 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.js +173 -0
- package/dist/sdk/v1.generated.d.ts +189 -0
- package/dist/sdk/v1.generated.d.ts.map +1 -0
- package/dist/server/cloud.d.ts +51 -0
- package/dist/server/cloud.d.ts.map +1 -0
- package/dist/server/index.js +23204 -20342
- package/dist/server/openapi.d.ts +708 -0
- package/dist/server/openapi.d.ts.map +1 -0
- package/dist/server/pg-store.d.ts +57 -0
- package/dist/server/pg-store.d.ts.map +1 -0
- package/dist/server/security.d.ts +24 -0
- package/dist/server/security.d.ts.map +1 -0
- package/dist/server/serve.d.ts +8 -1
- package/dist/server/serve.d.ts.map +1 -1
- package/dist/server/v1.d.ts +6 -0
- package/dist/server/v1.d.ts.map +1 -0
- package/dist/store/index.d.ts +383 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +96 -0
- package/dist/types/index.d.ts.map +1 -1
- package/hasna.contract.json +32 -0
- package/migrations/0001_core_schema.sql +162 -0
- package/migrations/0002_contact_fields_groups.sql +22 -0
- package/migrations/0003_status_archiving.sql +17 -0
- package/migrations/0004_company_relationships.sql +16 -0
- package/migrations/0005_contact_projects.sql +19 -0
- package/migrations/0006_contact_notes.sql +14 -0
- package/migrations/0007_entities_vendor_tasks.sql +91 -0
- package/migrations/0008_deals_events.sql +36 -0
- package/migrations/0009_history_learnings_coordination.sql +122 -0
- package/migrations/0010_documents_health.sql +38 -0
- package/migrations/0011_feedback.sql +14 -0
- package/migrations/0012_audiences_consent_suppressions.sql +38 -0
- package/migrations/9001_api_keys.sql +18 -0
- package/package.json +14 -3
- package/dist/db/feedback.d.ts +0 -15
- package/dist/db/feedback.d.ts.map +0 -1
- package/dist/db/remote-storage.d.ts +0 -14
- package/dist/db/remote-storage.d.ts.map +0 -1
- package/dist/db/remote-sync.d.ts +0 -49
- package/dist/db/remote-sync.d.ts.map +0 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
-- @hasna/contacts cloud schema (A1 pure-remote) — generated from src/db/pg-migrations.ts
|
|
2
|
+
-- Idempotent: CREATE ... IF NOT EXISTS / ADD COLUMN IF NOT EXISTS / ON CONFLICT.
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS contact_field_history (
|
|
5
|
+
id TEXT PRIMARY KEY,
|
|
6
|
+
contact_id TEXT NOT NULL REFERENCES contacts(id) ON DELETE CASCADE,
|
|
7
|
+
field_name TEXT NOT NULL,
|
|
8
|
+
old_value TEXT,
|
|
9
|
+
new_value TEXT,
|
|
10
|
+
valid_from TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
11
|
+
source TEXT,
|
|
12
|
+
confidence TEXT NOT NULL DEFAULT 'imported' CHECK(confidence IN ('verified','inferred','imported','stale')),
|
|
13
|
+
created_by TEXT,
|
|
14
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE TABLE IF NOT EXISTS job_history (
|
|
18
|
+
id TEXT PRIMARY KEY,
|
|
19
|
+
contact_id TEXT NOT NULL REFERENCES contacts(id) ON DELETE CASCADE,
|
|
20
|
+
company_id TEXT REFERENCES companies(id) ON DELETE SET NULL,
|
|
21
|
+
company_name TEXT NOT NULL,
|
|
22
|
+
title TEXT,
|
|
23
|
+
start_date TEXT,
|
|
24
|
+
end_date TEXT,
|
|
25
|
+
is_current BOOLEAN NOT NULL DEFAULT FALSE,
|
|
26
|
+
inferred BOOLEAN NOT NULL DEFAULT FALSE,
|
|
27
|
+
source TEXT,
|
|
28
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
CREATE TABLE IF NOT EXISTS contact_learnings (
|
|
32
|
+
id TEXT PRIMARY KEY,
|
|
33
|
+
contact_id TEXT NOT NULL REFERENCES contacts(id) ON DELETE CASCADE,
|
|
34
|
+
content TEXT NOT NULL,
|
|
35
|
+
type TEXT NOT NULL DEFAULT 'fact' CHECK(type IN ('preference','fact','inference','warning','signal')),
|
|
36
|
+
confidence INTEGER NOT NULL DEFAULT 70 CHECK(confidence BETWEEN 0 AND 100),
|
|
37
|
+
importance INTEGER NOT NULL DEFAULT 5 CHECK(importance BETWEEN 1 AND 10),
|
|
38
|
+
learned_by TEXT,
|
|
39
|
+
session_id TEXT,
|
|
40
|
+
visibility TEXT NOT NULL DEFAULT 'shared' CHECK(visibility IN ('private','shared','human')),
|
|
41
|
+
tags TEXT NOT NULL DEFAULT '[]',
|
|
42
|
+
confirmed_count INTEGER NOT NULL DEFAULT 0,
|
|
43
|
+
contradicts_id TEXT REFERENCES contact_learnings(id) ON DELETE SET NULL,
|
|
44
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
45
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
CREATE TABLE IF NOT EXISTS contact_locks (
|
|
49
|
+
id TEXT PRIMARY KEY,
|
|
50
|
+
contact_id TEXT NOT NULL UNIQUE REFERENCES contacts(id) ON DELETE CASCADE,
|
|
51
|
+
agent_name TEXT NOT NULL,
|
|
52
|
+
reason TEXT,
|
|
53
|
+
acquired_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
54
|
+
expires_at TIMESTAMPTZ NOT NULL,
|
|
55
|
+
session_id TEXT
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
CREATE TABLE IF NOT EXISTS contact_agent_activity (
|
|
59
|
+
id TEXT PRIMARY KEY,
|
|
60
|
+
contact_id TEXT NOT NULL REFERENCES contacts(id) ON DELETE CASCADE,
|
|
61
|
+
agent_name TEXT NOT NULL,
|
|
62
|
+
action TEXT NOT NULL,
|
|
63
|
+
details TEXT,
|
|
64
|
+
session_id TEXT,
|
|
65
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
ALTER TABLE contact_relationships ADD COLUMN IF NOT EXISTS strength_score INTEGER NOT NULL DEFAULT 50;
|
|
69
|
+
ALTER TABLE contact_relationships ADD COLUMN IF NOT EXISTS interaction_count INTEGER NOT NULL DEFAULT 0;
|
|
70
|
+
ALTER TABLE contact_relationships ADD COLUMN IF NOT EXISTS last_interaction TEXT;
|
|
71
|
+
ALTER TABLE contact_relationships ADD COLUMN IF NOT EXISTS relationship_status TEXT NOT NULL DEFAULT 'stable' CHECK(relationship_status IN ('warming','stable','cooling','ghost'));
|
|
72
|
+
|
|
73
|
+
CREATE TABLE IF NOT EXISTS contact_identities (
|
|
74
|
+
id TEXT PRIMARY KEY,
|
|
75
|
+
contact_id TEXT NOT NULL REFERENCES contacts(id) ON DELETE CASCADE,
|
|
76
|
+
system TEXT NOT NULL,
|
|
77
|
+
external_id TEXT NOT NULL,
|
|
78
|
+
external_url TEXT,
|
|
79
|
+
confidence TEXT NOT NULL DEFAULT 'inferred' CHECK(confidence IN ('verified','inferred')),
|
|
80
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
81
|
+
UNIQUE(system, external_id)
|
|
82
|
+
);
|
|
83
|
+
ALTER TABLE contacts ADD COLUMN IF NOT EXISTS canonical_id TEXT;
|
|
84
|
+
|
|
85
|
+
ALTER TABLE contacts ADD COLUMN IF NOT EXISTS relationship_health INTEGER NOT NULL DEFAULT 50;
|
|
86
|
+
ALTER TABLE contacts ADD COLUMN IF NOT EXISTS avg_response_hours DOUBLE PRECISION;
|
|
87
|
+
ALTER TABLE contacts ADD COLUMN IF NOT EXISTS preferred_channel TEXT;
|
|
88
|
+
ALTER TABLE contacts ADD COLUMN IF NOT EXISTS engagement_status TEXT NOT NULL DEFAULT 'new' CHECK(engagement_status IN ('warming','stable','cooling','ghost','new'));
|
|
89
|
+
ALTER TABLE contacts ADD COLUMN IF NOT EXISTS interaction_count_30d INTEGER NOT NULL DEFAULT 0;
|
|
90
|
+
ALTER TABLE contacts ADD COLUMN IF NOT EXISTS interaction_count_90d INTEGER NOT NULL DEFAULT 0;
|
|
91
|
+
|
|
92
|
+
CREATE TABLE IF NOT EXISTS contact_field_confidence (
|
|
93
|
+
id TEXT PRIMARY KEY,
|
|
94
|
+
contact_id TEXT NOT NULL REFERENCES contacts(id) ON DELETE CASCADE,
|
|
95
|
+
field_name TEXT NOT NULL,
|
|
96
|
+
confidence TEXT NOT NULL DEFAULT 'imported' CHECK(confidence IN ('verified','inferred','imported','stale')),
|
|
97
|
+
source TEXT,
|
|
98
|
+
last_verified_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
99
|
+
UNIQUE(contact_id, field_name)
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
CREATE TABLE IF NOT EXISTS org_chart_edges (
|
|
103
|
+
id TEXT PRIMARY KEY,
|
|
104
|
+
company_id TEXT NOT NULL REFERENCES companies(id) ON DELETE CASCADE,
|
|
105
|
+
contact_a_id TEXT NOT NULL REFERENCES contacts(id) ON DELETE CASCADE,
|
|
106
|
+
contact_b_id TEXT NOT NULL REFERENCES contacts(id) ON DELETE CASCADE,
|
|
107
|
+
edge_type TEXT NOT NULL CHECK(edge_type IN ('reports_to','manages','collaborates_with','peer')),
|
|
108
|
+
inferred BOOLEAN NOT NULL DEFAULT FALSE,
|
|
109
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
110
|
+
UNIQUE(company_id, contact_a_id, contact_b_id, edge_type)
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
CREATE TABLE IF NOT EXISTS deal_contact_roles (
|
|
114
|
+
id TEXT PRIMARY KEY,
|
|
115
|
+
deal_id TEXT NOT NULL REFERENCES deals(id) ON DELETE CASCADE,
|
|
116
|
+
contact_id TEXT NOT NULL REFERENCES contacts(id) ON DELETE CASCADE,
|
|
117
|
+
account_role TEXT NOT NULL CHECK(account_role IN ('economic_buyer','technical_evaluator','champion','blocker','influencer','user','sponsor','other')),
|
|
118
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
119
|
+
UNIQUE(deal_id, contact_id)
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
INSERT INTO _migrations (version) VALUES (8) ON CONFLICT DO NOTHING;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
-- @hasna/contacts cloud schema (A1 pure-remote) — generated from src/db/pg-migrations.ts
|
|
2
|
+
-- Idempotent: CREATE ... IF NOT EXISTS / ADD COLUMN IF NOT EXISTS / ON CONFLICT.
|
|
3
|
+
|
|
4
|
+
ALTER TABLE contacts ADD COLUMN IF NOT EXISTS sensitivity TEXT NOT NULL DEFAULT 'normal' CHECK(sensitivity IN ('normal','confidential','restricted'));
|
|
5
|
+
|
|
6
|
+
CREATE TABLE IF NOT EXISTS contact_documents (
|
|
7
|
+
id TEXT PRIMARY KEY,
|
|
8
|
+
contact_id TEXT NOT NULL REFERENCES contacts(id) ON DELETE CASCADE,
|
|
9
|
+
doc_type TEXT NOT NULL,
|
|
10
|
+
label TEXT,
|
|
11
|
+
encrypted_value TEXT NOT NULL,
|
|
12
|
+
iv TEXT NOT NULL,
|
|
13
|
+
encrypted_file_path TEXT,
|
|
14
|
+
metadata TEXT NOT NULL DEFAULT '{}',
|
|
15
|
+
expires_at TEXT,
|
|
16
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
17
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
CREATE TABLE IF NOT EXISTS contact_health (
|
|
21
|
+
id TEXT PRIMARY KEY,
|
|
22
|
+
contact_id TEXT NOT NULL UNIQUE REFERENCES contacts(id) ON DELETE CASCADE,
|
|
23
|
+
blood_type TEXT,
|
|
24
|
+
allergies TEXT NOT NULL DEFAULT '[]',
|
|
25
|
+
medical_conditions TEXT NOT NULL DEFAULT '[]',
|
|
26
|
+
medications TEXT NOT NULL DEFAULT '[]',
|
|
27
|
+
emergency_contacts TEXT NOT NULL DEFAULT '[]',
|
|
28
|
+
health_insurance_provider TEXT,
|
|
29
|
+
health_insurance_id TEXT,
|
|
30
|
+
primary_physician TEXT,
|
|
31
|
+
primary_physician_phone TEXT,
|
|
32
|
+
organ_donor BOOLEAN NOT NULL DEFAULT FALSE,
|
|
33
|
+
notes TEXT,
|
|
34
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
35
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
INSERT INTO _migrations (version) VALUES (9) ON CONFLICT DO NOTHING;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-- @hasna/contacts cloud schema (A1 pure-remote) — generated from src/db/pg-migrations.ts
|
|
2
|
+
-- Idempotent: CREATE ... IF NOT EXISTS / ADD COLUMN IF NOT EXISTS / ON CONFLICT.
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS feedback (
|
|
5
|
+
id TEXT PRIMARY KEY DEFAULT gen_random_uuid()::text,
|
|
6
|
+
message TEXT NOT NULL,
|
|
7
|
+
email TEXT,
|
|
8
|
+
category TEXT DEFAULT 'general',
|
|
9
|
+
version TEXT,
|
|
10
|
+
machine_id TEXT,
|
|
11
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
INSERT INTO _migrations (version) VALUES (10) ON CONFLICT DO NOTHING;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
-- @hasna/contacts cloud schema (A1 pure-remote) — generated from src/db/pg-migrations.ts
|
|
2
|
+
-- Idempotent: CREATE ... IF NOT EXISTS / ADD COLUMN IF NOT EXISTS / ON CONFLICT.
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS audiences (
|
|
5
|
+
id TEXT PRIMARY KEY,
|
|
6
|
+
audience_id TEXT NOT NULL UNIQUE,
|
|
7
|
+
name TEXT NOT NULL,
|
|
8
|
+
match TEXT NOT NULL DEFAULT 'all' CHECK(match IN ('all','any')),
|
|
9
|
+
predicates TEXT NOT NULL DEFAULT '[]',
|
|
10
|
+
consent_policy TEXT NOT NULL DEFAULT 'opt_in' CHECK(consent_policy IN ('opt_in','opt_out','transactional','none')),
|
|
11
|
+
suppression_synced_at TEXT,
|
|
12
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
13
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
CREATE TABLE IF NOT EXISTS contact_consent (
|
|
17
|
+
contact_id TEXT NOT NULL REFERENCES contacts(id) ON DELETE CASCADE,
|
|
18
|
+
channel TEXT NOT NULL CHECK(channel IN ('email','telegram','sms')),
|
|
19
|
+
status TEXT NOT NULL DEFAULT 'unknown' CHECK(status IN ('opt_in','opt_out','unknown')),
|
|
20
|
+
source TEXT,
|
|
21
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
22
|
+
PRIMARY KEY (contact_id, channel)
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
CREATE TABLE IF NOT EXISTS contact_suppressions (
|
|
26
|
+
id TEXT PRIMARY KEY,
|
|
27
|
+
contact_id TEXT REFERENCES contacts(id) ON DELETE CASCADE,
|
|
28
|
+
channel TEXT NOT NULL CHECK(channel IN ('email','telegram','sms')),
|
|
29
|
+
address TEXT NOT NULL,
|
|
30
|
+
reason TEXT,
|
|
31
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
32
|
+
synced_at TIMESTAMPTZ,
|
|
33
|
+
UNIQUE(channel, address)
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
CREATE INDEX IF NOT EXISTS idx_contact_suppressions_unsynced ON contact_suppressions(channel) WHERE synced_at IS NULL;
|
|
37
|
+
|
|
38
|
+
INSERT INTO _migrations (version) VALUES (11) ON CONFLICT DO NOTHING;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
-- @hasna/contracts API-key store (idempotent). Applied by ApiKeyStore.ensureSchema()
|
|
2
|
+
-- in the serve/migrate code path; committed here for transparency.
|
|
3
|
+
CREATE TABLE IF NOT EXISTS api_keys (
|
|
4
|
+
kid TEXT PRIMARY KEY,
|
|
5
|
+
app TEXT NOT NULL,
|
|
6
|
+
agent TEXT,
|
|
7
|
+
scopes JSONB NOT NULL,
|
|
8
|
+
token_hash TEXT NOT NULL UNIQUE,
|
|
9
|
+
issued_at TIMESTAMPTZ NOT NULL,
|
|
10
|
+
expires_at TIMESTAMPTZ,
|
|
11
|
+
revoked_at TIMESTAMPTZ,
|
|
12
|
+
revoked_reason TEXT,
|
|
13
|
+
last_used_at TIMESTAMPTZ,
|
|
14
|
+
created_by TEXT,
|
|
15
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
16
|
+
);
|
|
17
|
+
CREATE INDEX IF NOT EXISTS api_keys_app_idx ON api_keys (app);
|
|
18
|
+
CREATE INDEX IF NOT EXISTS api_keys_token_hash_idx ON api_keys (token_hash);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hasna/contacts",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.28",
|
|
4
4
|
"description": "Contact management for AI coding agents — CLI + MCP + Web",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -14,19 +14,29 @@
|
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
16
|
"import": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./sdk": {
|
|
19
|
+
"types": "./dist/sdk/index.d.ts",
|
|
20
|
+
"import": "./dist/sdk/index.js"
|
|
17
21
|
}
|
|
18
22
|
},
|
|
19
23
|
"files": [
|
|
20
24
|
"dist",
|
|
21
25
|
"dashboard/dist",
|
|
26
|
+
"migrations",
|
|
27
|
+
"hasna.contract.json",
|
|
22
28
|
"LICENSE",
|
|
23
29
|
"README.md"
|
|
24
30
|
],
|
|
25
31
|
"scripts": {
|
|
26
32
|
"clean": "rm -rf dist dashboard/dist",
|
|
27
33
|
"clean:core": "rm -rf dist",
|
|
28
|
-
"build": "bun run clean && cd dashboard && bun run build && cd .. && bun
|
|
29
|
-
"build:core": "bun run clean:core && bun
|
|
34
|
+
"build": "bun run clean && cd dashboard && bun run build && cd .. && bun run build:bundles && tsc -p tsconfig.build.json --emitDeclarationOnly --outDir dist",
|
|
35
|
+
"build:core": "bun run clean:core && bun run build:bundles && tsc -p tsconfig.build.json --emitDeclarationOnly --outDir dist",
|
|
36
|
+
"build:bundles": "bun build src/cli/index.tsx --outdir dist/cli --target bun --external ink --external react --external chalk --external pg --external @hasna/contracts --external @modelcontextprotocol/sdk && bun build src/mcp/index.ts --outdir dist/mcp --target bun --external pg --external @hasna/contracts --external @modelcontextprotocol/sdk && bun build src/server/index.ts --outdir dist/server --target bun --external pg --external @hasna/contracts && bun build src/sdk/index.ts --outdir dist/sdk --target bun && bun build src/index.ts --outdir dist --target bun --external pg --external @hasna/contracts",
|
|
37
|
+
"build:server": "rm -rf dist/server dist/sdk && bun build src/server/index.ts --outdir dist/server --target bun --external pg --external @hasna/contracts",
|
|
38
|
+
"generate:sdk": "bun run scripts/generate-sdk.ts",
|
|
39
|
+
"migrate": "bun run scripts/migrate.ts",
|
|
30
40
|
"typecheck": "tsc --noEmit",
|
|
31
41
|
"test": "bun test",
|
|
32
42
|
"dev:cli": "bun run src/cli/index.tsx",
|
|
@@ -63,6 +73,7 @@
|
|
|
63
73
|
"author": "Andrei Hasna <andrei@hasna.com>",
|
|
64
74
|
"license": "Apache-2.0",
|
|
65
75
|
"dependencies": {
|
|
76
|
+
"@hasna/contracts": "^0.5.1",
|
|
66
77
|
"@hasna/events": "^0.1.6",
|
|
67
78
|
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
68
79
|
"chalk": "^5.4.1",
|
package/dist/db/feedback.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface LocalFeedbackInput {
|
|
2
|
-
message: string;
|
|
3
|
-
email?: string | null;
|
|
4
|
-
category?: string | null;
|
|
5
|
-
version?: string | null;
|
|
6
|
-
machine_id?: string | null;
|
|
7
|
-
}
|
|
8
|
-
export interface LocalFeedbackResult {
|
|
9
|
-
id: string;
|
|
10
|
-
saved: true;
|
|
11
|
-
sent: false;
|
|
12
|
-
mode: "local";
|
|
13
|
-
}
|
|
14
|
-
export declare function saveLocalFeedback(input: LocalFeedbackInput): LocalFeedbackResult;
|
|
15
|
-
//# sourceMappingURL=feedback.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"feedback.d.ts","sourceRoot":"","sources":["../../src/db/feedback.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,EAAE,OAAO,CAAC;CACf;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,kBAAkB,GAAG,mBAAmB,CAiBhF"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { PoolConfig } from "pg";
|
|
2
|
-
export declare function buildPgPoolConfig(connectionString: string): PoolConfig;
|
|
3
|
-
export declare class PgAdapterAsync {
|
|
4
|
-
private readonly pool;
|
|
5
|
-
constructor(connectionString: string);
|
|
6
|
-
run(sql: string, ...params: unknown[]): Promise<{
|
|
7
|
-
changes: number;
|
|
8
|
-
}>;
|
|
9
|
-
get(sql: string, ...params: unknown[]): Promise<unknown>;
|
|
10
|
-
all(sql: string, ...params: unknown[]): Promise<unknown[]>;
|
|
11
|
-
exec(sql: string): Promise<void>;
|
|
12
|
-
close(): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=remote-storage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remote-storage.d.ts","sourceRoot":"","sources":["../../src/db/remote-storage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAQ,UAAU,EAAE,MAAM,IAAI,CAAC;AAmC3C,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,MAAM,GAAG,UAAU,CAwBtE;AAYD,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAO;gBAEhB,gBAAgB,EAAE,MAAM;IAI9B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAKpE,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAKxD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAK1D,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
package/dist/db/remote-sync.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { PgAdapterAsync } from "./remote-storage.js";
|
|
2
|
-
export declare const CONTACTS_REMOTE_TABLES: readonly ["companies", "contacts", "tags", "contact_tags", "company_tags", "emails", "phones", "addresses", "social_profiles", "contact_relationships", "activity_log", "webhooks", "groups", "contact_groups", "company_groups", "company_relationships", "contact_projects", "contact_notes", "org_members", "vendor_communications", "contact_tasks", "applications", "deals", "events", "contact_field_history", "job_history", "contact_learnings", "contact_locks", "contact_agent_activity", "contact_identities", "contact_field_confidence", "org_chart_edges", "deal_contact_roles", "contact_embeddings", "contact_documents", "contact_health", "feedback"];
|
|
3
|
-
type RemoteTable = (typeof CONTACTS_REMOTE_TABLES)[number];
|
|
4
|
-
export declare const CONTACTS_REMOTE_SENSITIVE_TABLES: readonly ["webhooks", "contact_documents", "contact_health"];
|
|
5
|
-
export declare const CONTACTS_REMOTE_DEFAULT_TABLES: RemoteTable[];
|
|
6
|
-
export declare const CONTACTS_REMOTE_ENV: readonly ["HASNA_CONTACTS_POSTGRES_URL", "OPEN_CONTACTS_POSTGRES_URL", "CONTACTS_POSTGRES_URL", "HASNA_CONTACTS_DATABASE_URL", "CONTACTS_DATABASE_URL"];
|
|
7
|
-
export interface SyncResult {
|
|
8
|
-
table: string;
|
|
9
|
-
rowsRead: number;
|
|
10
|
-
rowsWritten: number;
|
|
11
|
-
errors: string[];
|
|
12
|
-
}
|
|
13
|
-
export interface SyncMeta {
|
|
14
|
-
table_name: string;
|
|
15
|
-
last_synced_at: string | null;
|
|
16
|
-
direction: "push" | "pull";
|
|
17
|
-
}
|
|
18
|
-
export declare class ContactsRemoteSyncError extends Error {
|
|
19
|
-
readonly results: SyncResult[];
|
|
20
|
-
constructor(message: string, results: SyncResult[]);
|
|
21
|
-
}
|
|
22
|
-
export declare function getRemoteDatabaseUrl(): string | null;
|
|
23
|
-
export declare function getRemotePg(): Promise<PgAdapterAsync>;
|
|
24
|
-
export declare function runRemoteMigrations(remote: PgAdapterAsync): Promise<void>;
|
|
25
|
-
export declare function pushRemote(options?: {
|
|
26
|
-
tables?: string[];
|
|
27
|
-
}): Promise<SyncResult[]>;
|
|
28
|
-
export declare function pullRemote(options?: {
|
|
29
|
-
tables?: string[];
|
|
30
|
-
}): Promise<SyncResult[]>;
|
|
31
|
-
export declare function syncRemote(options?: {
|
|
32
|
-
tables?: string[];
|
|
33
|
-
}): Promise<{
|
|
34
|
-
pull: SyncResult[];
|
|
35
|
-
push: SyncResult[];
|
|
36
|
-
}>;
|
|
37
|
-
export declare function getSyncMetaAll(): SyncMeta[];
|
|
38
|
-
export declare function getRemoteStatus(): {
|
|
39
|
-
configured: boolean;
|
|
40
|
-
env: readonly ["HASNA_CONTACTS_POSTGRES_URL", "OPEN_CONTACTS_POSTGRES_URL", "CONTACTS_POSTGRES_URL", "HASNA_CONTACTS_DATABASE_URL", "CONTACTS_DATABASE_URL"];
|
|
41
|
-
default_tables: ("contacts" | "companies" | "tags" | "contact_tags" | "company_tags" | "emails" | "phones" | "addresses" | "social_profiles" | "contact_relationships" | "activity_log" | "webhooks" | "groups" | "contact_groups" | "company_groups" | "company_relationships" | "contact_projects" | "contact_notes" | "org_members" | "vendor_communications" | "contact_tasks" | "applications" | "deals" | "events" | "contact_field_history" | "job_history" | "contact_learnings" | "contact_locks" | "contact_agent_activity" | "contact_identities" | "contact_field_confidence" | "org_chart_edges" | "deal_contact_roles" | "contact_embeddings" | "contact_documents" | "contact_health" | "feedback")[];
|
|
42
|
-
sensitive_tables: readonly ["webhooks", "contact_documents", "contact_health"];
|
|
43
|
-
tables: readonly ["companies", "contacts", "tags", "contact_tags", "company_tags", "emails", "phones", "addresses", "social_profiles", "contact_relationships", "activity_log", "webhooks", "groups", "contact_groups", "company_groups", "company_relationships", "contact_projects", "contact_notes", "org_members", "vendor_communications", "contact_tasks", "applications", "deals", "events", "contact_field_history", "job_history", "contact_learnings", "contact_locks", "contact_agent_activity", "contact_identities", "contact_field_confidence", "org_chart_edges", "deal_contact_roles", "contact_embeddings", "contact_documents", "contact_health", "feedback"];
|
|
44
|
-
sync: SyncMeta[];
|
|
45
|
-
};
|
|
46
|
-
export declare function resolveRemoteTables(tables?: string[]): RemoteTable[];
|
|
47
|
-
export declare function normalizeSqliteSyncValue(value: unknown): unknown;
|
|
48
|
-
export {};
|
|
49
|
-
//# sourceMappingURL=remote-sync.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remote-sync.d.ts","sourceRoot":"","sources":["../../src/db/remote-sync.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,eAAO,MAAM,sBAAsB,yoBAsCzB,CAAC;AAEX,KAAK,WAAW,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAG3D,eAAO,MAAM,gCAAgC,8DAIF,CAAC;AAE5C,eAAO,MAAM,8BAA8B,EAEtC,WAAW,EAAE,CAAC;AA0CnB,eAAO,MAAM,mBAAmB,yJAMtB,CAAC;AAEX,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,QAAQ;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IAG9C,QAAQ,CAAC,OAAO,EAAE,UAAU,EAAE;gBAD9B,OAAO,EAAE,MAAM,EACN,OAAO,EAAE,UAAU,EAAE;CAKjC;AAED,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,IAAI,CAMpD;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,cAAc,CAAC,CAI3D;AAED,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAG/E;AAED,wBAAsB,UAAU,CAAC,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAavF;AAED,wBAAsB,UAAU,CAAC,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAavF;AAED,wBAAsB,UAAU,CAAC,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAAC,IAAI,EAAE,UAAU,EAAE,CAAA;CAAE,CAAC,CAIrH;AAED,wBAAgB,cAAc,IAAI,QAAQ,EAAE,CAI3C;AAED,wBAAgB,eAAe;;;;;;;EAS9B;AAED,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,CAOpE;AAsHD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAOhE"}
|