@intelligo-dev/core 1.0.0-beta.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/LICENSE +201 -0
- package/dist/conversations/errors.d.ts +31 -0
- package/dist/conversations/errors.d.ts.map +1 -0
- package/dist/conversations/errors.js +25 -0
- package/dist/conversations/errors.js.map +1 -0
- package/dist/conversations/index.d.ts +13 -0
- package/dist/conversations/index.d.ts.map +1 -0
- package/dist/conversations/index.js +12 -0
- package/dist/conversations/index.js.map +1 -0
- package/dist/conversations/service.d.ts +132 -0
- package/dist/conversations/service.d.ts.map +1 -0
- package/dist/conversations/service.js +347 -0
- package/dist/conversations/service.js.map +1 -0
- package/dist/conversations/types.d.ts +10 -0
- package/dist/conversations/types.d.ts.map +1 -0
- package/dist/conversations/types.js +5 -0
- package/dist/conversations/types.js.map +1 -0
- package/dist/db/client.d.ts +19 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +52 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/index.d.ts +4 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +8 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/schema/agents.d.ts +400 -0
- package/dist/db/schema/agents.d.ts.map +1 -0
- package/dist/db/schema/agents.js +39 -0
- package/dist/db/schema/agents.js.map +1 -0
- package/dist/db/schema/ai.d.ts +2222 -0
- package/dist/db/schema/ai.d.ts.map +1 -0
- package/dist/db/schema/ai.js +313 -0
- package/dist/db/schema/ai.js.map +1 -0
- package/dist/db/schema/auth.d.ts +1222 -0
- package/dist/db/schema/auth.d.ts.map +1 -0
- package/dist/db/schema/auth.js +162 -0
- package/dist/db/schema/auth.js.map +1 -0
- package/dist/db/schema/billing.d.ts +1199 -0
- package/dist/db/schema/billing.d.ts.map +1 -0
- package/dist/db/schema/billing.js +150 -0
- package/dist/db/schema/billing.js.map +1 -0
- package/dist/db/schema/feature-flags.d.ts +143 -0
- package/dist/db/schema/feature-flags.d.ts.map +1 -0
- package/dist/db/schema/feature-flags.js +25 -0
- package/dist/db/schema/feature-flags.js.map +1 -0
- package/dist/db/schema/identity.d.ts +1295 -0
- package/dist/db/schema/identity.d.ts.map +1 -0
- package/dist/db/schema/identity.js +258 -0
- package/dist/db/schema/identity.js.map +1 -0
- package/dist/db/schema/index.d.ts +16 -0
- package/dist/db/schema/index.d.ts.map +1 -0
- package/dist/db/schema/index.js +43 -0
- package/dist/db/schema/index.js.map +1 -0
- package/dist/db/schema/notifications.d.ts +182 -0
- package/dist/db/schema/notifications.d.ts.map +1 -0
- package/dist/db/schema/notifications.js +38 -0
- package/dist/db/schema/notifications.js.map +1 -0
- package/dist/db/schema/rag.d.ts +171 -0
- package/dist/db/schema/rag.d.ts.map +1 -0
- package/dist/db/schema/rag.js +42 -0
- package/dist/db/schema/rag.js.map +1 -0
- package/dist/db/schema/usage.d.ts +1193 -0
- package/dist/db/schema/usage.d.ts.map +1 -0
- package/dist/db/schema/usage.js +224 -0
- package/dist/db/schema/usage.js.map +1 -0
- package/dist/db/validate.d.ts +19 -0
- package/dist/db/validate.d.ts.map +1 -0
- package/dist/db/validate.js +58 -0
- package/dist/db/validate.js.map +1 -0
- package/dist/db/workspace-queries.d.ts +75 -0
- package/dist/db/workspace-queries.d.ts.map +1 -0
- package/dist/db/workspace-queries.js +78 -0
- package/dist/db/workspace-queries.js.map +1 -0
- package/dist/documents/classifier.d.ts +31 -0
- package/dist/documents/classifier.d.ts.map +1 -0
- package/dist/documents/classifier.js +41 -0
- package/dist/documents/classifier.js.map +1 -0
- package/dist/documents/errors.d.ts +32 -0
- package/dist/documents/errors.d.ts.map +1 -0
- package/dist/documents/errors.js +27 -0
- package/dist/documents/errors.js.map +1 -0
- package/dist/documents/index.d.ts +14 -0
- package/dist/documents/index.d.ts.map +1 -0
- package/dist/documents/index.js +13 -0
- package/dist/documents/index.js.map +1 -0
- package/dist/documents/service.d.ts +54 -0
- package/dist/documents/service.d.ts.map +1 -0
- package/dist/documents/service.js +146 -0
- package/dist/documents/service.js.map +1 -0
- package/dist/documents/types.d.ts +27 -0
- package/dist/documents/types.d.ts.map +1 -0
- package/dist/documents/types.js +5 -0
- package/dist/documents/types.js.map +1 -0
- package/dist/email/index.d.ts +5 -0
- package/dist/email/index.d.ts.map +1 -0
- package/dist/email/index.js +5 -0
- package/dist/email/index.js.map +1 -0
- package/dist/email/provider.d.ts +68 -0
- package/dist/email/provider.d.ts.map +1 -0
- package/dist/email/provider.js +199 -0
- package/dist/email/provider.js.map +1 -0
- package/dist/email/send.d.ts +47 -0
- package/dist/email/send.d.ts.map +1 -0
- package/dist/email/send.js +110 -0
- package/dist/email/send.js.map +1 -0
- package/dist/email/senders.d.ts +93 -0
- package/dist/email/senders.d.ts.map +1 -0
- package/dist/email/senders.js +232 -0
- package/dist/email/senders.js.map +1 -0
- package/dist/email/templates/base-layout.d.ts +7 -0
- package/dist/email/templates/base-layout.d.ts.map +1 -0
- package/dist/email/templates/base-layout.js +69 -0
- package/dist/email/templates/base-layout.js.map +1 -0
- package/dist/email/templates/index.d.ts +11 -0
- package/dist/email/templates/index.d.ts.map +1 -0
- package/dist/email/templates/index.js +17 -0
- package/dist/email/templates/index.js.map +1 -0
- package/dist/email/templates/password-reset.d.ts +7 -0
- package/dist/email/templates/password-reset.d.ts.map +1 -0
- package/dist/email/templates/password-reset.js +59 -0
- package/dist/email/templates/password-reset.js.map +1 -0
- package/dist/email/templates/payment-failed.d.ts +8 -0
- package/dist/email/templates/payment-failed.d.ts.map +1 -0
- package/dist/email/templates/payment-failed.js +62 -0
- package/dist/email/templates/payment-failed.js.map +1 -0
- package/dist/email/templates/quota-warning.d.ts +11 -0
- package/dist/email/templates/quota-warning.d.ts.map +1 -0
- package/dist/email/templates/quota-warning.js +82 -0
- package/dist/email/templates/quota-warning.js.map +1 -0
- package/dist/email/templates/subscription-confirmed.d.ts +9 -0
- package/dist/email/templates/subscription-confirmed.d.ts.map +1 -0
- package/dist/email/templates/subscription-confirmed.js +72 -0
- package/dist/email/templates/subscription-confirmed.js.map +1 -0
- package/dist/email/templates/trial-expiry.d.ts +9 -0
- package/dist/email/templates/trial-expiry.d.ts.map +1 -0
- package/dist/email/templates/trial-expiry.js +86 -0
- package/dist/email/templates/trial-expiry.js.map +1 -0
- package/dist/email/templates/trial-warning.d.ts +11 -0
- package/dist/email/templates/trial-warning.d.ts.map +1 -0
- package/dist/email/templates/trial-warning.js +70 -0
- package/dist/email/templates/trial-warning.js.map +1 -0
- package/dist/email/templates/verify-email.d.ts +7 -0
- package/dist/email/templates/verify-email.d.ts.map +1 -0
- package/dist/email/templates/verify-email.js +59 -0
- package/dist/email/templates/verify-email.js.map +1 -0
- package/dist/email/templates/welcome.d.ts +7 -0
- package/dist/email/templates/welcome.d.ts.map +1 -0
- package/dist/email/templates/welcome.js +51 -0
- package/dist/email/templates/welcome.js.map +1 -0
- package/dist/email/templates/workspace-invitation.d.ts +10 -0
- package/dist/email/templates/workspace-invitation.d.ts.map +1 -0
- package/dist/email/templates/workspace-invitation.js +79 -0
- package/dist/email/templates/workspace-invitation.js.map +1 -0
- package/dist/env.d.ts +21 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +129 -0
- package/dist/env.js.map +1 -0
- package/dist/identity/audit.d.ts +39 -0
- package/dist/identity/audit.d.ts.map +1 -0
- package/dist/identity/audit.js +51 -0
- package/dist/identity/audit.js.map +1 -0
- package/dist/identity/errors.d.ts +32 -0
- package/dist/identity/errors.d.ts.map +1 -0
- package/dist/identity/errors.js +25 -0
- package/dist/identity/errors.js.map +1 -0
- package/dist/identity/index.d.ts +16 -0
- package/dist/identity/index.d.ts.map +1 -0
- package/dist/identity/index.js +15 -0
- package/dist/identity/index.js.map +1 -0
- package/dist/identity/service.d.ts +70 -0
- package/dist/identity/service.d.ts.map +1 -0
- package/dist/identity/service.js +179 -0
- package/dist/identity/service.js.map +1 -0
- package/dist/identity/types.d.ts +27 -0
- package/dist/identity/types.d.ts.map +1 -0
- package/dist/identity/types.js +5 -0
- package/dist/identity/types.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +50 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +183 -0
- package/dist/logger.js.map +1 -0
- package/dist/notifications/index.d.ts +86 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +112 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/triggers.d.ts +68 -0
- package/dist/notifications/triggers.d.ts.map +1 -0
- package/dist/notifications/triggers.js +145 -0
- package/dist/notifications/triggers.js.map +1 -0
- package/dist/notifications/types.d.ts +19 -0
- package/dist/notifications/types.d.ts.map +1 -0
- package/dist/notifications/types.js +11 -0
- package/dist/notifications/types.js.map +1 -0
- package/package.json +101 -0
- package/src/db/migrations/0000_sharp_night_nurse.sql +52 -0
- package/src/db/migrations/0001_hesitant_vapor.sql +40 -0
- package/src/db/migrations/0002_numerous_lady_vermin.sql +235 -0
- package/src/db/migrations/0003_mighty_jean_grey.sql +37 -0
- package/src/db/migrations/0004_cynical_grandmaster.sql +2 -0
- package/src/db/migrations/0005_careful_switch.sql +8 -0
- package/src/db/migrations/0006_tense_blue_marvel.sql +16 -0
- package/src/db/migrations/0007_next_squadron_sinister.sql +1 -0
- package/src/db/migrations/0008_powerful_scream.sql +39 -0
- package/src/db/migrations/0009_sad_ink.sql +1 -0
- package/src/db/migrations/0010_shocking_omega_flight.sql +2 -0
- package/src/db/migrations/0011_ambiguous_otto_octavius.sql +151 -0
- package/src/db/migrations/0011_hnsw_vector_index.sql +17 -0
- package/src/db/migrations/0012_user_profiles.sql +30 -0
- package/src/db/migrations/0013_trending_seasonal_columns.sql +9 -0
- package/src/db/migrations/0014_add_product_type_to_agents.sql +6 -0
- package/src/db/migrations/0015_new_v1_tables.sql +149 -0
- package/src/db/migrations/0016_document_types.sql +30 -0
- package/src/db/migrations/0017_document_metadata.sql +2 -0
- package/src/db/migrations/0018_identity_graph.sql +200 -0
- package/src/db/migrations/0019_db_driven_prompts.sql +20 -0
- package/src/db/migrations/0020_pending_extractions.sql +35 -0
- package/src/db/migrations/0021_rag_documents.sql +39 -0
- package/src/db/migrations/0022_user_quotas_usage_jsonb.sql +70 -0
- package/src/db/migrations/0023_user_facts_user_scoped_unique.sql +17 -0
- package/src/db/migrations/0024_user_memories_hnsw.sql +23 -0
- package/src/db/migrations/0025_audit_trigger_errcode.sql +21 -0
- package/src/db/migrations/0026_user_profile_snapshots_composite_pk.sql +17 -0
- package/src/db/migrations/0027_billing_settings_mnt_columns.sql +54 -0
- package/src/db/migrations/0028_trial_credits_normalized_email.sql +37 -0
- package/src/db/migrations/0029_usage_records_conversation_idx.sql +13 -0
- package/src/db/migrations/0030_pending_extractions_composite_idx.sql +11 -0
- package/src/db/migrations/0031_rag_documents_hnsw.sql +16 -0
- package/src/db/migrations/0032_rate_limit_unique_idx.sql +16 -0
- package/src/db/migrations/0033_pending_extractions_partial_idx.sql +18 -0
- package/src/db/migrations/0034_rate_limit_count.sql +9 -0
- package/src/db/migrations/0035_credit_reservations.sql +24 -0
- package/src/db/migrations/0036_executions_audit_jobs.sql +96 -0
- package/src/db/migrations/0037_rate_limit_minute_bucket.sql +46 -0
- package/src/db/migrations/0038_user_quotas_generic_usage.sql +25 -0
- package/src/db/migrations/0039_platform_admin_impersonation.sql +27 -0
- package/src/db/migrations/0040_ee_audit_chain.sql +23 -0
- package/src/db/migrations/README.md +57 -0
- package/src/db/migrations/meta/0000_snapshot.json +348 -0
- package/src/db/migrations/meta/0001_snapshot.json +631 -0
- package/src/db/migrations/meta/0002_snapshot.json +2269 -0
- package/src/db/migrations/meta/0003_snapshot.json +2488 -0
- package/src/db/migrations/meta/0004_snapshot.json +2500 -0
- package/src/db/migrations/meta/0005_snapshot.json +2548 -0
- package/src/db/migrations/meta/0006_snapshot.json +2650 -0
- package/src/db/migrations/meta/0007_snapshot.json +2657 -0
- package/src/db/migrations/meta/0008_snapshot.json +2719 -0
- package/src/db/migrations/meta/0009_snapshot.json +2726 -0
- package/src/db/migrations/meta/0010_snapshot.json +2739 -0
- package/src/db/migrations/meta/0011_snapshot.json +3886 -0
- package/src/db/migrations/meta/_journal.json +300 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/db/schema/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAoBH;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,+GAUvB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAErE;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,sFAK/B,CAAC;AAEX,MAAM,MAAM,wBAAwB,GAClC,CAAC,OAAO,4BAA4B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCrB,CAAC;AAMF,eAAO,MAAM,iBAAiB,kHAQpB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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|
|
2
|
+
* User Identity Graph Schema (AI-ARCHITECTURE Phase B)
|
|
3
|
+
*
|
|
4
|
+
* Platform-level memory primitive — separate from any single product. The
|
|
5
|
+
* four tables below turn a user's scattered signals (facts, episodic
|
|
6
|
+
* memories, audit trails) into a single synthesized profile snapshot that
|
|
7
|
+
* every agent session hydrates from in one DB read.
|
|
8
|
+
*
|
|
9
|
+
* Why four tables instead of a JSON blob:
|
|
10
|
+
* 1. `user_facts` is the structured source of truth — queryable by
|
|
11
|
+
* category and weightable by confidence / importance.
|
|
12
|
+
* 2. `user_memories` is the unstructured narrative surface — pgvector
|
|
13
|
+
* search for episodic recall during long-running conversations.
|
|
14
|
+
* 3. `user_profile_snapshots` is the cached synthesis layer — voice
|
|
15
|
+
* agents can't afford to rebuild the profile at the top of every
|
|
16
|
+
* turn (<500ms budget), so we pre-render to this table and refresh
|
|
17
|
+
* on trigger events (session close, fact threshold, daily cron).
|
|
18
|
+
* 4. `user_memory_audit` is the trust layer — every write is logged
|
|
19
|
+
* so the "My Memory" settings page can show provenance per fact.
|
|
20
|
+
*
|
|
21
|
+
* See docs/AI-ARCHITECTURE.md §2 for the full design.
|
|
22
|
+
*
|
|
23
|
+
* Migration: src/db/migrations/0018_identity_graph.sql creates all four
|
|
24
|
+
* tables, their indexes, and the append-only triggers on
|
|
25
|
+
* user_memory_audit. Apply via `pnpm --filter @intelligo-dev/core db:push`
|
|
26
|
+
* before any code path calls into @intelligo-dev/agents/memory.
|
|
27
|
+
*/
|
|
28
|
+
import { pgTable, primaryKey, text, timestamp, integer, index, uniqueIndex, jsonb, doublePrecision, } from "drizzle-orm/pg-core";
|
|
29
|
+
import { vector } from "drizzle-orm/pg-core/columns/vector_extension/vector";
|
|
30
|
+
import { organization, users } from "./auth";
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// 1. user_facts — structured, evidence-backed facts
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
/**
|
|
35
|
+
* Discriminated category for a fact. Used as a filter axis when querying
|
|
36
|
+
* facts for synthesis or display. Keep this list tight — adding a new
|
|
37
|
+
* category should be a product decision, not a free-form string.
|
|
38
|
+
*/
|
|
39
|
+
export const USER_FACT_CATEGORIES = [
|
|
40
|
+
"interest",
|
|
41
|
+
"skill",
|
|
42
|
+
"goal",
|
|
43
|
+
"constraint",
|
|
44
|
+
"trait",
|
|
45
|
+
"value",
|
|
46
|
+
"preference",
|
|
47
|
+
"context",
|
|
48
|
+
"background",
|
|
49
|
+
];
|
|
50
|
+
/**
|
|
51
|
+
* How a fact entered the system. "explicit_user_input" facts are
|
|
52
|
+
* considered ground truth and survive conflict resolution against
|
|
53
|
+
* lower-confidence LLM extractions.
|
|
54
|
+
*/
|
|
55
|
+
export const USER_FACT_EXTRACTION_METHODS = [
|
|
56
|
+
"llm_extraction",
|
|
57
|
+
"explicit_user_input",
|
|
58
|
+
"inline_tool",
|
|
59
|
+
"onboarding_form",
|
|
60
|
+
];
|
|
61
|
+
export const userFacts = pgTable("user_facts", {
|
|
62
|
+
id: text("id").primaryKey(),
|
|
63
|
+
userId: text("user_id")
|
|
64
|
+
.notNull()
|
|
65
|
+
.references(() => users.id, { onDelete: "cascade" }),
|
|
66
|
+
workspaceId: text("workspace_id")
|
|
67
|
+
.notNull()
|
|
68
|
+
.references(() => organization.id, { onDelete: "cascade" }),
|
|
69
|
+
category: text("category").$type().notNull(),
|
|
70
|
+
key: text("key").notNull(),
|
|
71
|
+
value: jsonb("value").notNull(),
|
|
72
|
+
confidence: doublePrecision("confidence").notNull(),
|
|
73
|
+
importance: integer("importance").notNull().default(5),
|
|
74
|
+
sourceProduct: text("source_product"),
|
|
75
|
+
sourceSessionId: text("source_session_id"),
|
|
76
|
+
sourceMessageId: text("source_message_id"),
|
|
77
|
+
extractionMethod: text("extraction_method").$type(),
|
|
78
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
79
|
+
lastConfirmedAt: timestamp("last_confirmed_at"),
|
|
80
|
+
expiresAt: timestamp("expires_at"),
|
|
81
|
+
}, (table) => [
|
|
82
|
+
index("user_facts_user_idx").on(table.userId),
|
|
83
|
+
index("user_facts_workspace_idx").on(table.workspaceId),
|
|
84
|
+
index("user_facts_category_idx").on(table.workspaceId, table.category),
|
|
85
|
+
// Uniqueness is scoped to (user, workspace, category, key) — a shared
|
|
86
|
+
// workspace (e.g. a family or classroom org) can hold the same fact
|
|
87
|
+
// key for multiple members without collision.
|
|
88
|
+
uniqueIndex("user_facts_user_workspace_category_key_uniq").on(table.userId, table.workspaceId, table.category, table.key),
|
|
89
|
+
]);
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
// 2. user_memories — episodic, semantic recall via pgvector
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
export const USER_MEMORY_KINDS = [
|
|
94
|
+
"conversation_summary",
|
|
95
|
+
"event",
|
|
96
|
+
"insight",
|
|
97
|
+
"preference_statement",
|
|
98
|
+
"decision",
|
|
99
|
+
"struggle",
|
|
100
|
+
"success",
|
|
101
|
+
];
|
|
102
|
+
export const userMemories = pgTable("user_memories", {
|
|
103
|
+
id: text("id").primaryKey(),
|
|
104
|
+
userId: text("user_id")
|
|
105
|
+
.notNull()
|
|
106
|
+
.references(() => users.id, { onDelete: "cascade" }),
|
|
107
|
+
workspaceId: text("workspace_id")
|
|
108
|
+
.notNull()
|
|
109
|
+
.references(() => organization.id, { onDelete: "cascade" }),
|
|
110
|
+
kind: text("kind").$type().notNull(),
|
|
111
|
+
content: text("content").notNull(),
|
|
112
|
+
embedding: vector({ dimensions: 1536 }),
|
|
113
|
+
sourceProduct: text("source_product"),
|
|
114
|
+
sourceSessionId: text("source_session_id"),
|
|
115
|
+
sourceMessageIds: text("source_message_ids").array(),
|
|
116
|
+
importance: integer("importance").notNull().default(5),
|
|
117
|
+
decayFactor: doublePrecision("decay_factor").notNull().default(1.0),
|
|
118
|
+
metadata: jsonb("metadata"),
|
|
119
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
120
|
+
}, (table) => [
|
|
121
|
+
index("user_memories_user_idx").on(table.userId),
|
|
122
|
+
index("user_memories_workspace_idx").on(table.workspaceId),
|
|
123
|
+
index("user_memories_kind_idx").on(table.workspaceId, table.kind),
|
|
124
|
+
// pgvector IVFFlat / HNSW index is added in the migration SQL because
|
|
125
|
+
// drizzle-orm doesn't expose the syntax natively.
|
|
126
|
+
]);
|
|
127
|
+
// ---------------------------------------------------------------------------
|
|
128
|
+
// 3. user_profile_snapshots — synthesized, fast-read cache
|
|
129
|
+
// ---------------------------------------------------------------------------
|
|
130
|
+
export const SYNTHESIS_TRIGGER_REASONS = [
|
|
131
|
+
"fact_threshold",
|
|
132
|
+
"session_close",
|
|
133
|
+
"daily_cron",
|
|
134
|
+
"manual",
|
|
135
|
+
];
|
|
136
|
+
export const userProfileSnapshots = pgTable("user_profile_snapshots", {
|
|
137
|
+
userId: text("user_id")
|
|
138
|
+
.notNull()
|
|
139
|
+
.references(() => users.id, { onDelete: "cascade" }),
|
|
140
|
+
workspaceId: text("workspace_id")
|
|
141
|
+
.notNull()
|
|
142
|
+
.references(() => organization.id, { onDelete: "cascade" }),
|
|
143
|
+
version: integer("version").notNull(),
|
|
144
|
+
summary: text("summary").notNull(),
|
|
145
|
+
summaryEn: text("summary_en"),
|
|
146
|
+
summaryMn: text("summary_mn"),
|
|
147
|
+
factsDigest: jsonb("facts_digest").notNull(),
|
|
148
|
+
activeGoals: jsonb("active_goals"),
|
|
149
|
+
personalitySignals: jsonb("personality_signals"),
|
|
150
|
+
relationshipNotes: jsonb("relationship_notes"),
|
|
151
|
+
synthesizedByModel: text("synthesized_by_model"),
|
|
152
|
+
synthesizedAt: timestamp("synthesized_at").notNull().defaultNow(),
|
|
153
|
+
nextSynthesisAt: timestamp("next_synthesis_at"),
|
|
154
|
+
triggerReason: text("trigger_reason").$type(),
|
|
155
|
+
},
|
|
156
|
+
// Composite PK: a user can have one snapshot per workspace. Scoping
|
|
157
|
+
// by workspace matters the moment a user belongs to more than one
|
|
158
|
+
// org — e.g. a student in both their family workspace and a
|
|
159
|
+
// classroom workspace should get two distinct synthesized profiles.
|
|
160
|
+
(table) => [
|
|
161
|
+
primaryKey({ columns: [table.userId, table.workspaceId] }),
|
|
162
|
+
index("user_profile_snapshots_workspace_idx").on(table.workspaceId),
|
|
163
|
+
]);
|
|
164
|
+
// ---------------------------------------------------------------------------
|
|
165
|
+
// 4. user_memory_audit — privacy + trust audit trail
|
|
166
|
+
// ---------------------------------------------------------------------------
|
|
167
|
+
export const AUDIT_TARGET_KINDS = ["fact", "memory", "snapshot"];
|
|
168
|
+
export const AUDIT_ACTIONS = [
|
|
169
|
+
"create",
|
|
170
|
+
"update",
|
|
171
|
+
"delete",
|
|
172
|
+
"view",
|
|
173
|
+
"export",
|
|
174
|
+
];
|
|
175
|
+
export const AUDIT_ACTOR_KINDS = [
|
|
176
|
+
"agent",
|
|
177
|
+
"user",
|
|
178
|
+
"system_job",
|
|
179
|
+
"admin",
|
|
180
|
+
];
|
|
181
|
+
export const userMemoryAudit = pgTable("user_memory_audit", {
|
|
182
|
+
id: text("id").primaryKey(),
|
|
183
|
+
userId: text("user_id")
|
|
184
|
+
.notNull()
|
|
185
|
+
.references(() => users.id, { onDelete: "cascade" }),
|
|
186
|
+
workspaceId: text("workspace_id")
|
|
187
|
+
.notNull()
|
|
188
|
+
.references(() => organization.id, { onDelete: "cascade" }),
|
|
189
|
+
targetKind: text("target_kind").$type().notNull(),
|
|
190
|
+
targetId: text("target_id").notNull(),
|
|
191
|
+
action: text("action").$type().notNull(),
|
|
192
|
+
actorKind: text("actor_kind").$type().notNull(),
|
|
193
|
+
actorId: text("actor_id"),
|
|
194
|
+
beforeValue: jsonb("before_value"),
|
|
195
|
+
afterValue: jsonb("after_value"),
|
|
196
|
+
reason: text("reason"),
|
|
197
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
198
|
+
}, (table) => [
|
|
199
|
+
index("user_memory_audit_user_idx").on(table.userId),
|
|
200
|
+
index("user_memory_audit_workspace_idx").on(table.workspaceId),
|
|
201
|
+
index("user_memory_audit_target_idx").on(table.targetKind, table.targetId),
|
|
202
|
+
]);
|
|
203
|
+
// ---------------------------------------------------------------------------
|
|
204
|
+
// 5. pending_extractions — queue of conversations awaiting fact extraction
|
|
205
|
+
// ---------------------------------------------------------------------------
|
|
206
|
+
/**
|
|
207
|
+
* Background-job queue for fact extraction (Phase F). When a chat
|
|
208
|
+
* session ends the chat handler enqueues the conversation id here;
|
|
209
|
+
* the worker (packages/agents/src/extraction/worker.ts) polls and
|
|
210
|
+
* processes pending rows. Status starts as 'pending', flips to
|
|
211
|
+
* 'processing' while the worker holds the row, then 'completed' or
|
|
212
|
+
* 'failed' on exit. Failed rows track attempts so we can retry with
|
|
213
|
+
* exponential backoff and a hard cap.
|
|
214
|
+
*
|
|
215
|
+
* Keeping the queue in Postgres rather than Inngest/QStash for now —
|
|
216
|
+
* launch traffic is small enough that DB polling is sufficient and
|
|
217
|
+
* the doc explicitly calls this out as the V1 design.
|
|
218
|
+
*/
|
|
219
|
+
export const EXTRACTION_STATUSES = [
|
|
220
|
+
"pending",
|
|
221
|
+
"processing",
|
|
222
|
+
"completed",
|
|
223
|
+
"failed",
|
|
224
|
+
];
|
|
225
|
+
export const pendingExtractions = pgTable("pending_extractions", {
|
|
226
|
+
id: text("id").primaryKey(),
|
|
227
|
+
conversationId: text("conversation_id").notNull(),
|
|
228
|
+
workspaceId: text("workspace_id")
|
|
229
|
+
.notNull()
|
|
230
|
+
.references(() => organization.id, { onDelete: "cascade" }),
|
|
231
|
+
userId: text("user_id")
|
|
232
|
+
.notNull()
|
|
233
|
+
.references(() => users.id, { onDelete: "cascade" }),
|
|
234
|
+
productSlug: text("product_slug").notNull(),
|
|
235
|
+
status: text("status")
|
|
236
|
+
.$type()
|
|
237
|
+
.notNull()
|
|
238
|
+
.default("pending"),
|
|
239
|
+
attempts: integer("attempts").notNull().default(0),
|
|
240
|
+
maxAttempts: integer("max_attempts").notNull().default(3),
|
|
241
|
+
lastError: text("last_error"),
|
|
242
|
+
nextRetryAt: timestamp("next_retry_at"),
|
|
243
|
+
enqueuedAt: timestamp("enqueued_at").notNull().defaultNow(),
|
|
244
|
+
startedAt: timestamp("started_at"),
|
|
245
|
+
completedAt: timestamp("completed_at"),
|
|
246
|
+
}, (table) => [
|
|
247
|
+
index("pending_extractions_status_idx").on(table.status),
|
|
248
|
+
index("pending_extractions_workspace_idx").on(table.workspaceId),
|
|
249
|
+
uniqueIndex("pending_extractions_conversation_uniq").on(table.conversationId),
|
|
250
|
+
// Composite index for listPendingExtractions + claimNextExtraction
|
|
251
|
+
// queries that filter by (status = 'pending' AND next_retry_at IS NULL / <= now).
|
|
252
|
+
// Without this, the OR clause forces a seq scan on status='pending' rows.
|
|
253
|
+
index("pending_extractions_status_retry_idx").on(table.status, table.nextRetryAt),
|
|
254
|
+
// 0033_pending_extractions_partial_idx.sql adds a partial index
|
|
255
|
+
// (workspace_id) WHERE status = 'pending' — used by claimNextExtraction
|
|
256
|
+
// and listPendingExtractions for per-workspace queue polling.
|
|
257
|
+
]);
|
|
258
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/db/schema/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EACL,OAAO,EACP,UAAU,EACV,IAAI,EACJ,SAAS,EACT,OAAO,EACP,KAAK,EACL,WAAW,EACX,KAAK,EACL,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,qDAAqD,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE7C,8EAA8E;AAC9E,oDAAoD;AACpD,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,UAAU;IACV,O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AAO,EAAE;SACT,OAAO,CAAC,SAAS,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAClD,WAAW,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEzD,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC;IAC7B,WAAW,EAAE,SAAS,CAAC,eAAe,CAAC;IAEvC,UAAU,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;IAC3D,SAAS,EAAE,SAAS,CAAC,YAAY,CAAC;IAClC,WAAW,EAAE,SAAS,CAAC,cAAc,CAAC;CACvC,EACD,CAAC,KAAK,EAAE,EAAE,CAAC;IACT,KAAK,CAAC,gCAAgC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;IACxD,KAAK,CAAC,mCAAmC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC;IAChE,WAAW,CAAC,uCAAuC,CAAC,CAAC,EAAE,CACrD,KAAK,CAAC,cAAc,CACrB;IACD,mEAAmE;IACnE,kFAAkF;IAClF,0EAA0E;IAC1E,KAAK,CAAC,sCAAsC,CAAC,CAAC,EAAE,CAC9C,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,WAAW,CAClB;IACD,gEAAgE;IAChE,wEAAwE;IACxE,8DAA8D;CAC/D,CACF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drizzle Database Schema
|
|
3
|
+
*
|
|
4
|
+
* Central export point for all database tables.
|
|
5
|
+
* This file will be extended in future phases with workspace, billing, and AI schemas.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./auth";
|
|
8
|
+
export * from "./billing";
|
|
9
|
+
export * from "./usage";
|
|
10
|
+
export * from "./notifications";
|
|
11
|
+
export * from "./feature-flags";
|
|
12
|
+
export * from "./ai";
|
|
13
|
+
export * from "./agents";
|
|
14
|
+
export * from "./identity";
|
|
15
|
+
export * from "./rag";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/db/schema/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,QAAQ,CAAC;AAiBvB,cAAc,WAAW,CAAC;AAG1B,cAAc,SAAS,CAAC;AAGxB,cAAc,iBAAiB,CAAC;AAGhC,cAAc,iBAAiB,CAAC;AAGhC,cAAc,MAAM,CAAC;AAGrB,cAAc,UAAU,CAAC;AAKzB,cAAc,YAAY,CAAC;AAM3B,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drizzle Database Schema
|
|
3
|
+
*
|
|
4
|
+
* Central export point for all database tables.
|
|
5
|
+
* This file will be extended in future phases with workspace, billing, and AI schemas.
|
|
6
|
+
*/
|
|
7
|
+
// Auth tables (Better-Auth managed)
|
|
8
|
+
export * from "./auth";
|
|
9
|
+
// Organization/Workspace tables are managed by Better-Auth organization plugin (Phase 10)
|
|
10
|
+
// Tables: organization, member, invitation (auto-created by plugin on first API use)
|
|
11
|
+
// These tables are NOT in our Drizzle schema — Better-Auth manages them directly.
|
|
12
|
+
// Access via Better-Auth API: auth.api.listOrganizations(), auth.api.createInvitation(), etc.
|
|
13
|
+
//
|
|
14
|
+
// Organization plugin indexes (TECH-02 verified pattern):
|
|
15
|
+
// Better-Auth's organization plugin creates these indexes automatically:
|
|
16
|
+
// - member.organizationId (workspace member lookup)
|
|
17
|
+
// - member.userId (user's memberships lookup)
|
|
18
|
+
// - invitation.organizationId (workspace invitations lookup)
|
|
19
|
+
// - invitation.email (invited email lookup)
|
|
20
|
+
// These indexes are created by Better-Auth when tables are auto-created on first use.
|
|
21
|
+
// No manual migration needed — plugin handles all schema management.
|
|
22
|
+
// Billing tables (Phase 11)
|
|
23
|
+
export * from "./billing";
|
|
24
|
+
// Usage tracking tables (Phase 12)
|
|
25
|
+
export * from "./usage";
|
|
26
|
+
// Notification tables (Phase 14)
|
|
27
|
+
export * from "./notifications";
|
|
28
|
+
// Feature flags (Phase 15)
|
|
29
|
+
export * from "./feature-flags";
|
|
30
|
+
// AI tables (Phase 16)
|
|
31
|
+
export * from "./ai";
|
|
32
|
+
// Agents table (Phase 37)
|
|
33
|
+
export * from "./agents";
|
|
34
|
+
// User Identity Graph (AI-ARCHITECTURE Phase B)
|
|
35
|
+
// Four tables that back the cross-product memory system:
|
|
36
|
+
// user_facts, user_memories, user_profile_snapshots, user_memory_audit.
|
|
37
|
+
export * from "./identity";
|
|
38
|
+
// RAG documents table (AI-ARCHITECTURE Phase H)
|
|
39
|
+
// Single shared table that backs every collection in
|
|
40
|
+
// @intelligo-dev/agents/rag. Per-collection wrappers live in the
|
|
41
|
+
// product packages.
|
|
42
|
+
export * from "./rag";
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/db/schema/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,oCAAoC;AACpC,cAAc,QAAQ,CAAC;AAEvB,0FAA0F;AAC1F,qFAAqF;AACrF,kFAAkF;AAClF,8FAA8F;AAC9F,EAAE;AACF,0DAA0D;AAC1D,yEAAyE;AACzE,oDAAoD;AACpD,8CAA8C;AAC9C,6DAA6D;AAC7D,4CAA4C;AAC5C,sFAAsF;AACtF,qEAAqE;AAErE,4BAA4B;AAC5B,cAAc,WAAW,CAAC;AAE1B,mCAAmC;AACnC,cAAc,SAAS,CAAC;AAExB,iCAAiC;AACjC,cAAc,iBAAiB,CAAC;AAEhC,2BAA2B;AAC3B,cAAc,iBAAiB,CAAC;AAEhC,uBAAuB;AACvB,cAAc,MAAM,CAAC;AAErB,0BAA0B;AAC1B,cAAc,UAAU,CAAC;AAEzB,gDAAgD;AAChD,yDAAyD;AACzD,wEAAwE;AACxE,cAAc,YAAY,CAAC;AAE3B,gDAAgD;AAChD,qDAAqD;AACrD,iEAAiE;AACjE,oBAAoB;AACpB,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notifications Database Schema
|
|
3
|
+
*
|
|
4
|
+
* Persistent notifications for users (quota warnings, payment events, team updates).
|
|
5
|
+
* These are user-scoped (not workspace-scoped) so a user sees all their notifications
|
|
6
|
+
* across workspaces in one place.
|
|
7
|
+
*
|
|
8
|
+
* Pattern: snake_case columns in PostgreSQL, camelCase TypeScript API (via Drizzle mapping)
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Notifications table - User-facing notification records (NOTIF-06)
|
|
12
|
+
*
|
|
13
|
+
* Each notification has a type (matching NotificationType), a title/message for display,
|
|
14
|
+
* and optional metadata for additional context. The isRead flag supports read/unread
|
|
15
|
+
* filtering for the notification bell badge.
|
|
16
|
+
*
|
|
17
|
+
* userId references Better-Auth's user table by convention (no FK constraint).
|
|
18
|
+
* workspaceId is nullable — some notifications are user-level (e.g., payment_failed).
|
|
19
|
+
*/
|
|
20
|
+
export declare const notifications: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
21
|
+
name: "notifications";
|
|
22
|
+
schema: undefined;
|
|
23
|
+
columns: {
|
|
24
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
25
|
+
name: "id";
|
|
26
|
+
tableName: "notifications";
|
|
27
|
+
dataType: "string";
|
|
28
|
+
columnType: "PgText";
|
|
29
|
+
data: string;
|
|
30
|
+
driverParam: string;
|
|
31
|
+
notNull: true;
|
|
32
|
+
hasDefault: true;
|
|
33
|
+
isPrimaryKey: true;
|
|
34
|
+
isAutoincrement: false;
|
|
35
|
+
hasRuntimeDefault: true;
|
|
36
|
+
enumValues: [string, ...string[]];
|
|
37
|
+
baseColumn: never;
|
|
38
|
+
identity: undefined;
|
|
39
|
+
generated: undefined;
|
|
40
|
+
}, {}, {}>;
|
|
41
|
+
userId: import("drizzle-orm/pg-core").PgColumn<{
|
|
42
|
+
name: "user_id";
|
|
43
|
+
tableName: "notifications";
|
|
44
|
+
dataType: "string";
|
|
45
|
+
columnType: "PgText";
|
|
46
|
+
data: string;
|
|
47
|
+
driverParam: string;
|
|
48
|
+
notNull: true;
|
|
49
|
+
hasDefault: false;
|
|
50
|
+
isPrimaryKey: false;
|
|
51
|
+
isAutoincrement: false;
|
|
52
|
+
hasRuntimeDefault: false;
|
|
53
|
+
enumValues: [string, ...string[]];
|
|
54
|
+
baseColumn: never;
|
|
55
|
+
identity: undefined;
|
|
56
|
+
generated: undefined;
|
|
57
|
+
}, {}, {}>;
|
|
58
|
+
workspaceId: import("drizzle-orm/pg-core").PgColumn<{
|
|
59
|
+
name: "workspace_id";
|
|
60
|
+
tableName: "notifications";
|
|
61
|
+
dataType: "string";
|
|
62
|
+
columnType: "PgText";
|
|
63
|
+
data: string;
|
|
64
|
+
driverParam: string;
|
|
65
|
+
notNull: false;
|
|
66
|
+
hasDefault: false;
|
|
67
|
+
isPrimaryKey: false;
|
|
68
|
+
isAutoincrement: false;
|
|
69
|
+
hasRuntimeDefault: false;
|
|
70
|
+
enumValues: [string, ...string[]];
|
|
71
|
+
baseColumn: never;
|
|
72
|
+
identity: undefined;
|
|
73
|
+
generated: undefined;
|
|
74
|
+
}, {}, {}>;
|
|
75
|
+
type: import("drizzle-orm/pg-core").PgColumn<{
|
|
76
|
+
name: "type";
|
|
77
|
+
tableName: "notifications";
|
|
78
|
+
dataType: "string";
|
|
79
|
+
columnType: "PgText";
|
|
80
|
+
data: string;
|
|
81
|
+
driverParam: string;
|
|
82
|
+
notNull: true;
|
|
83
|
+
hasDefault: false;
|
|
84
|
+
isPrimaryKey: false;
|
|
85
|
+
isAutoincrement: false;
|
|
86
|
+
hasRuntimeDefault: false;
|
|
87
|
+
enumValues: [string, ...string[]];
|
|
88
|
+
baseColumn: never;
|
|
89
|
+
identity: undefined;
|
|
90
|
+
generated: undefined;
|
|
91
|
+
}, {}, {}>;
|
|
92
|
+
title: import("drizzle-orm/pg-core").PgColumn<{
|
|
93
|
+
name: "title";
|
|
94
|
+
tableName: "notifications";
|
|
95
|
+
dataType: "string";
|
|
96
|
+
columnType: "PgText";
|
|
97
|
+
data: string;
|
|
98
|
+
driverParam: string;
|
|
99
|
+
notNull: true;
|
|
100
|
+
hasDefault: false;
|
|
101
|
+
isPrimaryKey: false;
|
|
102
|
+
isAutoincrement: false;
|
|
103
|
+
hasRuntimeDefault: false;
|
|
104
|
+
enumValues: [string, ...string[]];
|
|
105
|
+
baseColumn: never;
|
|
106
|
+
identity: undefined;
|
|
107
|
+
generated: undefined;
|
|
108
|
+
}, {}, {}>;
|
|
109
|
+
message: import("drizzle-orm/pg-core").PgColumn<{
|
|
110
|
+
name: "message";
|
|
111
|
+
tableName: "notifications";
|
|
112
|
+
dataType: "string";
|
|
113
|
+
columnType: "PgText";
|
|
114
|
+
data: string;
|
|
115
|
+
driverParam: string;
|
|
116
|
+
notNull: true;
|
|
117
|
+
hasDefault: false;
|
|
118
|
+
isPrimaryKey: false;
|
|
119
|
+
isAutoincrement: false;
|
|
120
|
+
hasRuntimeDefault: false;
|
|
121
|
+
enumValues: [string, ...string[]];
|
|
122
|
+
baseColumn: never;
|
|
123
|
+
identity: undefined;
|
|
124
|
+
generated: undefined;
|
|
125
|
+
}, {}, {}>;
|
|
126
|
+
isRead: import("drizzle-orm/pg-core").PgColumn<{
|
|
127
|
+
name: "is_read";
|
|
128
|
+
tableName: "notifications";
|
|
129
|
+
dataType: "boolean";
|
|
130
|
+
columnType: "PgBoolean";
|
|
131
|
+
data: boolean;
|
|
132
|
+
driverParam: boolean;
|
|
133
|
+
notNull: true;
|
|
134
|
+
hasDefault: true;
|
|
135
|
+
isPrimaryKey: false;
|
|
136
|
+
isAutoincrement: false;
|
|
137
|
+
hasRuntimeDefault: false;
|
|
138
|
+
enumValues: undefined;
|
|
139
|
+
baseColumn: never;
|
|
140
|
+
identity: undefined;
|
|
141
|
+
generated: undefined;
|
|
142
|
+
}, {}, {}>;
|
|
143
|
+
metadata: import("drizzle-orm/pg-core").PgColumn<{
|
|
144
|
+
name: "metadata";
|
|
145
|
+
tableName: "notifications";
|
|
146
|
+
dataType: "string";
|
|
147
|
+
columnType: "PgText";
|
|
148
|
+
data: string;
|
|
149
|
+
driverParam: string;
|
|
150
|
+
notNull: false;
|
|
151
|
+
hasDefault: false;
|
|
152
|
+
isPrimaryKey: false;
|
|
153
|
+
isAutoincrement: false;
|
|
154
|
+
hasRuntimeDefault: false;
|
|
155
|
+
enumValues: [string, ...string[]];
|
|
156
|
+
baseColumn: never;
|
|
157
|
+
identity: undefined;
|
|
158
|
+
generated: undefined;
|
|
159
|
+
}, {}, {}>;
|
|
160
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
161
|
+
name: "created_at";
|
|
162
|
+
tableName: "notifications";
|
|
163
|
+
dataType: "date";
|
|
164
|
+
columnType: "PgTimestamp";
|
|
165
|
+
data: Date;
|
|
166
|
+
driverParam: string;
|
|
167
|
+
notNull: true;
|
|
168
|
+
hasDefault: true;
|
|
169
|
+
isPrimaryKey: false;
|
|
170
|
+
isAutoincrement: false;
|
|
171
|
+
hasRuntimeDefault: false;
|
|
172
|
+
enumValues: undefined;
|
|
173
|
+
baseColumn: never;
|
|
174
|
+
identity: undefined;
|
|
175
|
+
generated: undefined;
|
|
176
|
+
}, {}, {}>;
|
|
177
|
+
};
|
|
178
|
+
dialect: "pg";
|
|
179
|
+
}>;
|
|
180
|
+
export type Notification = typeof notifications.$inferSelect;
|
|
181
|
+
export type InsertNotification = typeof notifications.$inferInsert;
|
|
182
|
+
//# sourceMappingURL=notifications.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../../src/db/schema/notifications.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoBzB,CAAC;AAGF,MAAM,MAAM,YAAY,GAAG,OAAO,aAAa,CAAC,YAAY,CAAC;AAC7D,MAAM,MAAM,kBAAkB,GAAG,OAAO,aAAa,CAAC,YAAY,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notifications Database Schema
|
|
3
|
+
*
|
|
4
|
+
* Persistent notifications for users (quota warnings, payment events, team updates).
|
|
5
|
+
* These are user-scoped (not workspace-scoped) so a user sees all their notifications
|
|
6
|
+
* across workspaces in one place.
|
|
7
|
+
*
|
|
8
|
+
* Pattern: snake_case columns in PostgreSQL, camelCase TypeScript API (via Drizzle mapping)
|
|
9
|
+
*/
|
|
10
|
+
import { pgTable, text, timestamp, boolean, index } from "drizzle-orm/pg-core";
|
|
11
|
+
/**
|
|
12
|
+
* Notifications table - User-facing notification records (NOTIF-06)
|
|
13
|
+
*
|
|
14
|
+
* Each notification has a type (matching NotificationType), a title/message for display,
|
|
15
|
+
* and optional metadata for additional context. The isRead flag supports read/unread
|
|
16
|
+
* filtering for the notification bell badge.
|
|
17
|
+
*
|
|
18
|
+
* userId references Better-Auth's user table by convention (no FK constraint).
|
|
19
|
+
* workspaceId is nullable — some notifications are user-level (e.g., payment_failed).
|
|
20
|
+
*/
|
|
21
|
+
export const notifications = pgTable("notifications", {
|
|
22
|
+
id: text("id")
|
|
23
|
+
.primaryKey()
|
|
24
|
+
.$defaultFn(() => crypto.randomUUID()),
|
|
25
|
+
userId: text("user_id").notNull(),
|
|
26
|
+
workspaceId: text("workspace_id"),
|
|
27
|
+
type: text("type").notNull(),
|
|
28
|
+
title: text("title").notNull(),
|
|
29
|
+
message: text("message").notNull(),
|
|
30
|
+
isRead: boolean("is_read").notNull().default(false),
|
|
31
|
+
metadata: text("metadata"),
|
|
32
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
33
|
+
}, (table) => [
|
|
34
|
+
index("notifications_user_id_idx").on(table.userId),
|
|
35
|
+
index("notifications_user_id_is_read_idx").on(table.userId, table.isRead),
|
|
36
|
+
index("notifications_created_at_idx").on(table.createdAt),
|
|
37
|
+
]);
|
|
38
|
+
//# sourceMappingURL=notifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../../src/db/schema/notifications.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE/E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAClC,eAAe,EACf;IACE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC;SACX,UAAU,EAAE;SACZ,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IACxC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE;IACjC,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC;IACjC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE;IAC5B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE;IAC9B,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE;IAClC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACnD,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC;IAC1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