@intelligo-dev/core 1.0.0-beta.1 → 1.0.0-beta.13
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/NOTICE +6 -0
- package/README.md +102 -0
- package/dist/attachments/errors.d.ts +7 -0
- package/dist/attachments/errors.d.ts.map +1 -0
- package/dist/attachments/errors.js +11 -0
- package/dist/attachments/errors.js.map +1 -0
- package/dist/attachments/index.d.ts +8 -0
- package/dist/attachments/index.d.ts.map +1 -0
- package/dist/attachments/index.js +7 -0
- package/dist/attachments/index.js.map +1 -0
- package/dist/attachments/service.d.ts +45 -0
- package/dist/attachments/service.d.ts.map +1 -0
- package/dist/attachments/service.js +100 -0
- package/dist/attachments/service.js.map +1 -0
- package/dist/attachments/types.d.ts +6 -0
- package/dist/attachments/types.d.ts.map +1 -0
- package/dist/attachments/types.js +2 -0
- package/dist/attachments/types.js.map +1 -0
- package/dist/conversations/errors.d.ts +2 -8
- package/dist/conversations/errors.d.ts.map +1 -1
- package/dist/conversations/errors.js +2 -8
- package/dist/conversations/errors.js.map +1 -1
- package/dist/conversations/index.d.ts +4 -12
- package/dist/conversations/index.d.ts.map +1 -1
- package/dist/conversations/index.js +2 -11
- package/dist/conversations/index.js.map +1 -1
- package/dist/conversations/service.d.ts +49 -61
- package/dist/conversations/service.d.ts.map +1 -1
- package/dist/conversations/service.js +110 -83
- package/dist/conversations/service.js.map +1 -1
- package/dist/conversations/types.d.ts +1 -4
- package/dist/conversations/types.d.ts.map +1 -1
- package/dist/conversations/types.js +0 -3
- package/dist/conversations/types.js.map +1 -1
- package/dist/db/client.d.ts +21 -10
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +43 -18
- package/dist/db/client.js.map +1 -1
- package/dist/db/index.d.ts +3 -3
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +3 -7
- package/dist/db/index.js.map +1 -1
- package/dist/db/schema/agents.d.ts +14 -51
- package/dist/db/schema/agents.d.ts.map +1 -1
- package/dist/db/schema/agents.js +9 -21
- package/dist/db/schema/agents.js.map +1 -1
- package/dist/db/schema/ai.d.ts +86 -1556
- package/dist/db/schema/ai.d.ts.map +1 -1
- package/dist/db/schema/ai.js +32 -236
- package/dist/db/schema/ai.js.map +1 -1
- package/dist/db/schema/auth.d.ts +5 -34
- package/dist/db/schema/auth.d.ts.map +1 -1
- package/dist/db/schema/auth.js +25 -56
- package/dist/db/schema/auth.js.map +1 -1
- package/dist/db/schema/billing.d.ts +136 -107
- package/dist/db/schema/billing.d.ts.map +1 -1
- package/dist/db/schema/billing.js +72 -60
- package/dist/db/schema/billing.js.map +1 -1
- package/dist/db/schema/feature-flags.d.ts +3 -12
- package/dist/db/schema/feature-flags.d.ts.map +1 -1
- package/dist/db/schema/feature-flags.js +3 -12
- package/dist/db/schema/feature-flags.js.map +1 -1
- package/dist/db/schema/identity.d.ts +12 -274
- package/dist/db/schema/identity.d.ts.map +1 -1
- package/dist/db/schema/identity.js +19 -104
- package/dist/db/schema/identity.js.map +1 -1
- package/dist/db/schema/index.d.ts +8 -15
- package/dist/db/schema/index.d.ts.map +1 -1
- package/dist/db/schema/index.js +12 -42
- package/dist/db/schema/index.js.map +1 -1
- package/dist/db/schema/notifications.d.ts +3 -17
- package/dist/db/schema/notifications.d.ts.map +1 -1
- package/dist/db/schema/notifications.js +3 -17
- package/dist/db/schema/notifications.js.map +1 -1
- package/dist/db/schema/usage.d.ts +94 -77
- package/dist/db/schema/usage.d.ts.map +1 -1
- package/dist/db/schema/usage.js +59 -89
- package/dist/db/schema/usage.js.map +1 -1
- package/dist/db/validate.d.ts +2 -11
- package/dist/db/validate.d.ts.map +1 -1
- package/dist/db/validate.js +6 -17
- package/dist/db/validate.js.map +1 -1
- package/dist/db/workspace-queries.d.ts +5 -29
- package/dist/db/workspace-queries.d.ts.map +1 -1
- package/dist/db/workspace-queries.js +5 -29
- package/dist/db/workspace-queries.js.map +1 -1
- package/dist/documents/classifier.d.ts +5 -12
- package/dist/documents/classifier.d.ts.map +1 -1
- package/dist/documents/classifier.js +16 -16
- package/dist/documents/classifier.js.map +1 -1
- package/dist/documents/errors.d.ts +2 -10
- package/dist/documents/errors.d.ts.map +1 -1
- package/dist/documents/errors.js +2 -10
- package/dist/documents/errors.js.map +1 -1
- package/dist/documents/index.d.ts +4 -13
- package/dist/documents/index.d.ts.map +1 -1
- package/dist/documents/index.js +3 -12
- package/dist/documents/index.js.map +1 -1
- package/dist/documents/service.d.ts +19 -26
- package/dist/documents/service.d.ts.map +1 -1
- package/dist/documents/service.js +44 -38
- package/dist/documents/service.js.map +1 -1
- package/dist/documents/types.d.ts +6 -10
- package/dist/documents/types.d.ts.map +1 -1
- package/dist/documents/types.js +0 -3
- package/dist/documents/types.js.map +1 -1
- package/dist/email/brand.d.ts +17 -0
- package/dist/email/brand.d.ts.map +1 -0
- package/dist/email/brand.js +9 -0
- package/dist/email/brand.js.map +1 -0
- package/dist/email/index.d.ts +4 -4
- package/dist/email/index.js +4 -4
- package/dist/email/provider.d.ts +1 -7
- package/dist/email/provider.d.ts.map +1 -1
- package/dist/email/provider.js +10 -19
- package/dist/email/provider.js.map +1 -1
- package/dist/email/send.d.ts +12 -12
- package/dist/email/send.d.ts.map +1 -1
- package/dist/email/send.js +5 -19
- package/dist/email/send.js.map +1 -1
- package/dist/email/senders.d.ts +17 -30
- package/dist/email/senders.d.ts.map +1 -1
- package/dist/email/senders.js +33 -47
- package/dist/email/senders.js.map +1 -1
- package/dist/email/templates/base-layout.d.ts +1 -1
- package/dist/email/templates/base-layout.d.ts.map +1 -1
- package/dist/email/templates/base-layout.js +4 -6
- package/dist/email/templates/base-layout.js.map +1 -1
- package/dist/email/templates/index.d.ts +10 -10
- package/dist/email/templates/index.d.ts.map +1 -1
- package/dist/email/templates/index.js +10 -16
- package/dist/email/templates/index.js.map +1 -1
- package/dist/email/templates/password-reset.d.ts +2 -2
- package/dist/email/templates/password-reset.d.ts.map +1 -1
- package/dist/email/templates/password-reset.js +10 -22
- package/dist/email/templates/password-reset.js.map +1 -1
- package/dist/email/templates/payment-failed.d.ts +2 -2
- package/dist/email/templates/payment-failed.d.ts.map +1 -1
- package/dist/email/templates/payment-failed.js +11 -24
- package/dist/email/templates/payment-failed.js.map +1 -1
- package/dist/email/templates/quota-warning.d.ts +4 -4
- package/dist/email/templates/quota-warning.d.ts.map +1 -1
- package/dist/email/templates/quota-warning.js +19 -39
- package/dist/email/templates/quota-warning.js.map +1 -1
- package/dist/email/templates/subscription-confirmed.d.ts +2 -2
- package/dist/email/templates/subscription-confirmed.d.ts.map +1 -1
- package/dist/email/templates/subscription-confirmed.js +13 -28
- package/dist/email/templates/subscription-confirmed.js.map +1 -1
- package/dist/email/templates/trial-expiry.d.ts +2 -2
- package/dist/email/templates/trial-expiry.d.ts.map +1 -1
- package/dist/email/templates/trial-expiry.js +12 -36
- package/dist/email/templates/trial-expiry.js.map +1 -1
- package/dist/email/templates/trial-warning.d.ts +2 -2
- package/dist/email/templates/trial-warning.d.ts.map +1 -1
- package/dist/email/templates/trial-warning.js +15 -32
- package/dist/email/templates/trial-warning.js.map +1 -1
- package/dist/email/templates/verify-email.d.ts +2 -2
- package/dist/email/templates/verify-email.d.ts.map +1 -1
- package/dist/email/templates/verify-email.js +10 -22
- package/dist/email/templates/verify-email.js.map +1 -1
- package/dist/email/templates/welcome.d.ts +2 -2
- package/dist/email/templates/welcome.d.ts.map +1 -1
- package/dist/email/templates/welcome.js +13 -20
- package/dist/email/templates/welcome.js.map +1 -1
- package/dist/email/templates/workspace-invitation.d.ts +2 -2
- package/dist/email/templates/workspace-invitation.d.ts.map +1 -1
- package/dist/email/templates/workspace-invitation.js +12 -26
- package/dist/email/templates/workspace-invitation.js.map +1 -1
- package/dist/env.d.ts +5 -10
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +41 -31
- package/dist/env.js.map +1 -1
- package/dist/identity/audit.d.ts +11 -24
- package/dist/identity/audit.d.ts.map +1 -1
- package/dist/identity/audit.js +13 -27
- package/dist/identity/audit.js.map +1 -1
- package/dist/identity/errors.d.ts +4 -12
- package/dist/identity/errors.d.ts.map +1 -1
- package/dist/identity/errors.js +2 -8
- package/dist/identity/errors.js.map +1 -1
- package/dist/identity/index.d.ts +5 -13
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/index.js +4 -12
- package/dist/identity/index.js.map +1 -1
- package/dist/identity/service.d.ts +13 -47
- package/dist/identity/service.d.ts.map +1 -1
- package/dist/identity/service.js +31 -78
- package/dist/identity/service.js.map +1 -1
- package/dist/identity/types.d.ts +1 -4
- package/dist/identity/types.d.ts.map +1 -1
- package/dist/identity/types.js +0 -3
- package/dist/identity/types.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -10
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +7 -18
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +45 -49
- package/dist/logger.js.map +1 -1
- package/dist/money.d.ts +95 -0
- package/dist/money.d.ts.map +1 -0
- package/dist/money.js +208 -0
- package/dist/money.js.map +1 -0
- package/dist/notifications/index.d.ts +9 -43
- package/dist/notifications/index.d.ts.map +1 -1
- package/dist/notifications/index.js +9 -49
- package/dist/notifications/index.js.map +1 -1
- package/dist/notifications/triggers.d.ts +9 -32
- package/dist/notifications/triggers.d.ts.map +1 -1
- package/dist/notifications/triggers.js +21 -58
- package/dist/notifications/triggers.js.map +1 -1
- package/dist/notifications/types.d.ts +1 -10
- package/dist/notifications/types.d.ts.map +1 -1
- package/dist/notifications/types.js +0 -9
- package/dist/notifications/types.js.map +1 -1
- package/dist/prompt.d.ts +38 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +118 -0
- package/dist/prompt.js.map +1 -0
- package/dist/registry.d.ts +32 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +60 -0
- package/dist/registry.js.map +1 -0
- package/dist/request-context.d.ts +49 -0
- package/dist/request-context.d.ts.map +1 -0
- package/dist/request-context.js +100 -0
- package/dist/request-context.js.map +1 -0
- package/dist/storage/index.d.ts +65 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +109 -0
- package/dist/storage/index.js.map +1 -0
- package/package.json +74 -24
- package/src/attachments/errors.ts +18 -0
- package/src/attachments/index.ts +22 -0
- package/src/attachments/service.ts +178 -0
- package/src/attachments/types.ts +6 -0
- package/src/conversations/errors.ts +45 -0
- package/src/conversations/index.ts +39 -0
- package/src/conversations/service.ts +594 -0
- package/src/conversations/types.ts +15 -0
- package/src/db/client.ts +91 -0
- package/src/db/index.ts +3 -0
- package/src/db/migrations/0000_baseline.sql +652 -0
- package/src/db/migrations/0001_reconcile_chain_built_databases.sql +53 -0
- package/src/db/migrations/0002_webhook_claim_lease.sql +1 -0
- package/src/db/migrations/README.md +74 -36
- package/src/db/migrations/legacy-chain.json +197 -0
- package/src/db/migrations/meta/0000_snapshot.json +4182 -157
- package/src/db/migrations/meta/0002_snapshot.json +2478 -368
- package/src/db/migrations/meta/_journal.json +6 -279
- package/src/db/schema/agents.ts +57 -0
- package/src/db/schema/ai.ts +174 -0
- package/src/db/schema/auth.ts +183 -0
- package/src/db/schema/billing.ts +209 -0
- package/src/db/schema/feature-flags.ts +20 -0
- package/src/db/schema/identity.ts +250 -0
- package/src/db/schema/index.ts +12 -0
- package/src/db/schema/notifications.ts +31 -0
- package/src/db/schema/usage.ts +269 -0
- package/src/db/validate.ts +63 -0
- package/src/db/workspace-queries.ts +64 -0
- package/src/documents/classifier.ts +61 -0
- package/src/documents/errors.ts +44 -0
- package/src/documents/index.ts +24 -0
- package/src/documents/service.ts +256 -0
- package/src/documents/types.ts +24 -0
- package/src/email/brand.ts +24 -0
- package/src/email/index.ts +19 -0
- package/src/email/provider.ts +278 -0
- package/src/email/send.ts +169 -0
- package/src/email/senders.ts +292 -0
- package/src/email/templates/base-layout.tsx +145 -0
- package/src/email/templates/index.ts +28 -0
- package/src/email/templates/password-reset.tsx +72 -0
- package/src/email/templates/payment-failed.tsx +77 -0
- package/src/email/templates/quota-warning.tsx +118 -0
- package/src/email/templates/subscription-confirmed.tsx +91 -0
- package/src/email/templates/trial-expiry.tsx +124 -0
- package/src/email/templates/trial-warning.tsx +104 -0
- package/src/email/templates/verify-email.tsx +72 -0
- package/src/email/templates/welcome.tsx +64 -0
- package/src/email/templates/workspace-invitation.tsx +105 -0
- package/src/env.ts +180 -0
- package/src/identity/audit.ts +65 -0
- package/src/identity/errors.ts +44 -0
- package/src/identity/index.ts +26 -0
- package/src/identity/service.ts +202 -0
- package/src/identity/types.ts +28 -0
- package/src/index.ts +4 -0
- package/src/logger.ts +198 -0
- package/src/money.ts +270 -0
- package/src/notifications/index.ts +108 -0
- package/src/notifications/triggers.ts +158 -0
- package/src/notifications/types.ts +18 -0
- package/src/prompt.ts +142 -0
- package/src/registry.ts +75 -0
- package/src/request-context.ts +137 -0
- package/src/storage/index.ts +153 -0
- package/dist/db/schema/rag.d.ts +0 -171
- package/dist/db/schema/rag.d.ts.map +0 -1
- package/dist/db/schema/rag.js +0 -42
- package/dist/db/schema/rag.js.map +0 -1
- package/src/db/migrations/0000_sharp_night_nurse.sql +0 -52
- package/src/db/migrations/0001_hesitant_vapor.sql +0 -40
- package/src/db/migrations/0002_numerous_lady_vermin.sql +0 -235
- package/src/db/migrations/0003_mighty_jean_grey.sql +0 -37
- package/src/db/migrations/0004_cynical_grandmaster.sql +0 -2
- package/src/db/migrations/0005_careful_switch.sql +0 -8
- package/src/db/migrations/0006_tense_blue_marvel.sql +0 -16
- package/src/db/migrations/0007_next_squadron_sinister.sql +0 -1
- package/src/db/migrations/0008_powerful_scream.sql +0 -39
- package/src/db/migrations/0009_sad_ink.sql +0 -1
- package/src/db/migrations/0010_shocking_omega_flight.sql +0 -2
- package/src/db/migrations/0011_ambiguous_otto_octavius.sql +0 -151
- package/src/db/migrations/0011_hnsw_vector_index.sql +0 -17
- package/src/db/migrations/0012_user_profiles.sql +0 -30
- package/src/db/migrations/0013_trending_seasonal_columns.sql +0 -9
- package/src/db/migrations/0014_add_product_type_to_agents.sql +0 -6
- package/src/db/migrations/0015_new_v1_tables.sql +0 -149
- package/src/db/migrations/0016_document_types.sql +0 -30
- package/src/db/migrations/0017_document_metadata.sql +0 -2
- package/src/db/migrations/0018_identity_graph.sql +0 -200
- package/src/db/migrations/0019_db_driven_prompts.sql +0 -20
- package/src/db/migrations/0020_pending_extractions.sql +0 -35
- package/src/db/migrations/0021_rag_documents.sql +0 -39
- package/src/db/migrations/0022_user_quotas_usage_jsonb.sql +0 -70
- package/src/db/migrations/0023_user_facts_user_scoped_unique.sql +0 -17
- package/src/db/migrations/0024_user_memories_hnsw.sql +0 -23
- package/src/db/migrations/0025_audit_trigger_errcode.sql +0 -21
- package/src/db/migrations/0026_user_profile_snapshots_composite_pk.sql +0 -17
- package/src/db/migrations/0027_billing_settings_mnt_columns.sql +0 -54
- package/src/db/migrations/0028_trial_credits_normalized_email.sql +0 -37
- package/src/db/migrations/0029_usage_records_conversation_idx.sql +0 -13
- package/src/db/migrations/0030_pending_extractions_composite_idx.sql +0 -11
- package/src/db/migrations/0031_rag_documents_hnsw.sql +0 -16
- package/src/db/migrations/0032_rate_limit_unique_idx.sql +0 -16
- package/src/db/migrations/0033_pending_extractions_partial_idx.sql +0 -18
- package/src/db/migrations/0034_rate_limit_count.sql +0 -9
- package/src/db/migrations/0035_credit_reservations.sql +0 -24
- package/src/db/migrations/0036_executions_audit_jobs.sql +0 -96
- package/src/db/migrations/0037_rate_limit_minute_bucket.sql +0 -46
- package/src/db/migrations/0038_user_quotas_generic_usage.sql +0 -25
- package/src/db/migrations/0039_platform_admin_impersonation.sql +0 -27
- package/src/db/migrations/0040_ee_audit_chain.sql +0 -23
- package/src/db/migrations/meta/0001_snapshot.json +0 -631
- package/src/db/migrations/meta/0003_snapshot.json +0 -2488
- package/src/db/migrations/meta/0004_snapshot.json +0 -2500
- package/src/db/migrations/meta/0005_snapshot.json +0 -2548
- package/src/db/migrations/meta/0006_snapshot.json +0 -2650
- package/src/db/migrations/meta/0007_snapshot.json +0 -2657
- package/src/db/migrations/meta/0008_snapshot.json +0 -2719
- package/src/db/migrations/meta/0009_snapshot.json +0 -2726
- package/src/db/migrations/meta/0010_snapshot.json +0 -2739
- package/src/db/migrations/meta/0011_snapshot.json +0 -3886
package/dist/db/schema/rag.d.ts
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RAG documents schema (Phase H).
|
|
3
|
-
*
|
|
4
|
-
* Single shared table that backs every collection in
|
|
5
|
-
* @intelligo-dev/agents/rag. Each collection (e.g., career.universities,
|
|
6
|
-
* career.scholarships, career.majors) lives as a `collection` slug
|
|
7
|
-
* filter on this table — so adding a new collection means writing a
|
|
8
|
-
* Collection<TMeta> instance, not a migration.
|
|
9
|
-
*
|
|
10
|
-
* Schema choices:
|
|
11
|
-
* - `collection` is indexed for the per-collection filter clause.
|
|
12
|
-
* - `metadata` is freeform JSONB; the typed Collection wrapper in
|
|
13
|
-
* @intelligo-dev/agents validates with Zod at write time.
|
|
14
|
-
* - `embedding` is a 1536-dim pgvector to match
|
|
15
|
-
* OpenAI text-embedding-3-small (the embeddings module in
|
|
16
|
-
* @intelligo-dev/ai already targets that model).
|
|
17
|
-
* - `external_id` lets ingestion be idempotent — re-running a seed
|
|
18
|
-
* upserts on (collection, external_id) instead of duplicating.
|
|
19
|
-
*
|
|
20
|
-
* The pgvector IVFFlat / HNSW index lives in the SQL migration
|
|
21
|
-
* because drizzle-orm doesn't expose the syntax natively, same
|
|
22
|
-
* pattern as user_memories in identity.ts.
|
|
23
|
-
*/
|
|
24
|
-
export declare const ragDocuments: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
25
|
-
name: "rag_documents";
|
|
26
|
-
schema: undefined;
|
|
27
|
-
columns: {
|
|
28
|
-
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
29
|
-
name: "id";
|
|
30
|
-
tableName: "rag_documents";
|
|
31
|
-
dataType: "string";
|
|
32
|
-
columnType: "PgText";
|
|
33
|
-
data: string;
|
|
34
|
-
driverParam: string;
|
|
35
|
-
notNull: true;
|
|
36
|
-
hasDefault: false;
|
|
37
|
-
isPrimaryKey: true;
|
|
38
|
-
isAutoincrement: false;
|
|
39
|
-
hasRuntimeDefault: false;
|
|
40
|
-
enumValues: [string, ...string[]];
|
|
41
|
-
baseColumn: never;
|
|
42
|
-
identity: undefined;
|
|
43
|
-
generated: undefined;
|
|
44
|
-
}, {}, {}>;
|
|
45
|
-
collection: import("drizzle-orm/pg-core").PgColumn<{
|
|
46
|
-
name: "collection";
|
|
47
|
-
tableName: "rag_documents";
|
|
48
|
-
dataType: "string";
|
|
49
|
-
columnType: "PgText";
|
|
50
|
-
data: string;
|
|
51
|
-
driverParam: string;
|
|
52
|
-
notNull: true;
|
|
53
|
-
hasDefault: false;
|
|
54
|
-
isPrimaryKey: false;
|
|
55
|
-
isAutoincrement: false;
|
|
56
|
-
hasRuntimeDefault: false;
|
|
57
|
-
enumValues: [string, ...string[]];
|
|
58
|
-
baseColumn: never;
|
|
59
|
-
identity: undefined;
|
|
60
|
-
generated: undefined;
|
|
61
|
-
}, {}, {}>;
|
|
62
|
-
externalId: import("drizzle-orm/pg-core").PgColumn<{
|
|
63
|
-
name: "external_id";
|
|
64
|
-
tableName: "rag_documents";
|
|
65
|
-
dataType: "string";
|
|
66
|
-
columnType: "PgText";
|
|
67
|
-
data: string;
|
|
68
|
-
driverParam: string;
|
|
69
|
-
notNull: false;
|
|
70
|
-
hasDefault: false;
|
|
71
|
-
isPrimaryKey: false;
|
|
72
|
-
isAutoincrement: false;
|
|
73
|
-
hasRuntimeDefault: false;
|
|
74
|
-
enumValues: [string, ...string[]];
|
|
75
|
-
baseColumn: never;
|
|
76
|
-
identity: undefined;
|
|
77
|
-
generated: undefined;
|
|
78
|
-
}, {}, {}>;
|
|
79
|
-
content: import("drizzle-orm/pg-core").PgColumn<{
|
|
80
|
-
name: "content";
|
|
81
|
-
tableName: "rag_documents";
|
|
82
|
-
dataType: "string";
|
|
83
|
-
columnType: "PgText";
|
|
84
|
-
data: string;
|
|
85
|
-
driverParam: string;
|
|
86
|
-
notNull: true;
|
|
87
|
-
hasDefault: false;
|
|
88
|
-
isPrimaryKey: false;
|
|
89
|
-
isAutoincrement: false;
|
|
90
|
-
hasRuntimeDefault: false;
|
|
91
|
-
enumValues: [string, ...string[]];
|
|
92
|
-
baseColumn: never;
|
|
93
|
-
identity: undefined;
|
|
94
|
-
generated: undefined;
|
|
95
|
-
}, {}, {}>;
|
|
96
|
-
metadata: import("drizzle-orm/pg-core").PgColumn<{
|
|
97
|
-
name: "metadata";
|
|
98
|
-
tableName: "rag_documents";
|
|
99
|
-
dataType: "json";
|
|
100
|
-
columnType: "PgJsonb";
|
|
101
|
-
data: unknown;
|
|
102
|
-
driverParam: unknown;
|
|
103
|
-
notNull: true;
|
|
104
|
-
hasDefault: true;
|
|
105
|
-
isPrimaryKey: false;
|
|
106
|
-
isAutoincrement: false;
|
|
107
|
-
hasRuntimeDefault: false;
|
|
108
|
-
enumValues: undefined;
|
|
109
|
-
baseColumn: never;
|
|
110
|
-
identity: undefined;
|
|
111
|
-
generated: undefined;
|
|
112
|
-
}, {}, {}>;
|
|
113
|
-
embedding: import("drizzle-orm/pg-core").PgColumn<{
|
|
114
|
-
name: "embedding";
|
|
115
|
-
tableName: "rag_documents";
|
|
116
|
-
dataType: "array";
|
|
117
|
-
columnType: "PgVector";
|
|
118
|
-
data: number[];
|
|
119
|
-
driverParam: string;
|
|
120
|
-
notNull: false;
|
|
121
|
-
hasDefault: false;
|
|
122
|
-
isPrimaryKey: false;
|
|
123
|
-
isAutoincrement: false;
|
|
124
|
-
hasRuntimeDefault: false;
|
|
125
|
-
enumValues: undefined;
|
|
126
|
-
baseColumn: never;
|
|
127
|
-
identity: undefined;
|
|
128
|
-
generated: undefined;
|
|
129
|
-
}, {}, {
|
|
130
|
-
dimensions: 1536;
|
|
131
|
-
}>;
|
|
132
|
-
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
133
|
-
name: "created_at";
|
|
134
|
-
tableName: "rag_documents";
|
|
135
|
-
dataType: "date";
|
|
136
|
-
columnType: "PgTimestamp";
|
|
137
|
-
data: Date;
|
|
138
|
-
driverParam: string;
|
|
139
|
-
notNull: true;
|
|
140
|
-
hasDefault: true;
|
|
141
|
-
isPrimaryKey: false;
|
|
142
|
-
isAutoincrement: false;
|
|
143
|
-
hasRuntimeDefault: false;
|
|
144
|
-
enumValues: undefined;
|
|
145
|
-
baseColumn: never;
|
|
146
|
-
identity: undefined;
|
|
147
|
-
generated: undefined;
|
|
148
|
-
}, {}, {}>;
|
|
149
|
-
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
150
|
-
name: "updated_at";
|
|
151
|
-
tableName: "rag_documents";
|
|
152
|
-
dataType: "date";
|
|
153
|
-
columnType: "PgTimestamp";
|
|
154
|
-
data: Date;
|
|
155
|
-
driverParam: string;
|
|
156
|
-
notNull: true;
|
|
157
|
-
hasDefault: true;
|
|
158
|
-
isPrimaryKey: false;
|
|
159
|
-
isAutoincrement: false;
|
|
160
|
-
hasRuntimeDefault: false;
|
|
161
|
-
enumValues: undefined;
|
|
162
|
-
baseColumn: never;
|
|
163
|
-
identity: undefined;
|
|
164
|
-
generated: undefined;
|
|
165
|
-
}, {}, {}>;
|
|
166
|
-
};
|
|
167
|
-
dialect: "pg";
|
|
168
|
-
}>;
|
|
169
|
-
export type RagDocument = typeof ragDocuments.$inferSelect;
|
|
170
|
-
export type InsertRagDocument = typeof ragDocuments.$inferInsert;
|
|
171
|
-
//# sourceMappingURL=rag.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rag.d.ts","sourceRoot":"","sources":["../../../src/db/schema/rag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAYH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwBxB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,OAAO,YAAY,CAAC,YAAY,CAAC;AAC3D,MAAM,MAAM,iBAAiB,GAAG,OAAO,YAAY,CAAC,YAAY,CAAC"}
|
package/dist/db/schema/rag.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RAG documents schema (Phase H).
|
|
3
|
-
*
|
|
4
|
-
* Single shared table that backs every collection in
|
|
5
|
-
* @intelligo-dev/agents/rag. Each collection (e.g., career.universities,
|
|
6
|
-
* career.scholarships, career.majors) lives as a `collection` slug
|
|
7
|
-
* filter on this table — so adding a new collection means writing a
|
|
8
|
-
* Collection<TMeta> instance, not a migration.
|
|
9
|
-
*
|
|
10
|
-
* Schema choices:
|
|
11
|
-
* - `collection` is indexed for the per-collection filter clause.
|
|
12
|
-
* - `metadata` is freeform JSONB; the typed Collection wrapper in
|
|
13
|
-
* @intelligo-dev/agents validates with Zod at write time.
|
|
14
|
-
* - `embedding` is a 1536-dim pgvector to match
|
|
15
|
-
* OpenAI text-embedding-3-small (the embeddings module in
|
|
16
|
-
* @intelligo-dev/ai already targets that model).
|
|
17
|
-
* - `external_id` lets ingestion be idempotent — re-running a seed
|
|
18
|
-
* upserts on (collection, external_id) instead of duplicating.
|
|
19
|
-
*
|
|
20
|
-
* The pgvector IVFFlat / HNSW index lives in the SQL migration
|
|
21
|
-
* because drizzle-orm doesn't expose the syntax natively, same
|
|
22
|
-
* pattern as user_memories in identity.ts.
|
|
23
|
-
*/
|
|
24
|
-
import { pgTable, text, timestamp, jsonb, index, uniqueIndex, } from "drizzle-orm/pg-core";
|
|
25
|
-
import { vector } from "drizzle-orm/pg-core/columns/vector_extension/vector";
|
|
26
|
-
export const ragDocuments = pgTable("rag_documents", {
|
|
27
|
-
id: text("id").primaryKey(),
|
|
28
|
-
collection: text("collection").notNull(),
|
|
29
|
-
externalId: text("external_id"),
|
|
30
|
-
content: text("content").notNull(),
|
|
31
|
-
metadata: jsonb("metadata").notNull().default({}),
|
|
32
|
-
embedding: vector({ dimensions: 1536 }),
|
|
33
|
-
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
34
|
-
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
35
|
-
}, (table) => [
|
|
36
|
-
index("rag_documents_collection_idx").on(table.collection),
|
|
37
|
-
uniqueIndex("rag_documents_collection_external_uniq").on(table.collection, table.externalId),
|
|
38
|
-
// HNSW index for vector similarity search lives in the SQL migration
|
|
39
|
-
// (0031_rag_documents_hnsw.sql) because drizzle-orm doesn't expose the
|
|
40
|
-
// HNSW index syntax natively. Pattern mirrors knowledge_chunks above.
|
|
41
|
-
]);
|
|
42
|
-
//# sourceMappingURL=rag.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rag.js","sourceRoot":"","sources":["../../../src/db/schema/rag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACL,OAAO,EACP,IAAI,EACJ,SAAS,EACT,KAAK,EACL,KAAK,EACL,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,qDAAqD,CAAC;AAE7E,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CACjC,eAAe,EACf;IACE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE;IAC3B,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IACxC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC;IAE/B,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE;IAClC,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IACjD,SAAS,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IAEvC,SAAS,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;IACzD,SAAS,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;CAC1D,EACD,CAAC,KAAK,EAAE,EAAE,CAAC;IACT,KAAK,CAAC,8BAA8B,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC;IAC1D,WAAW,CAAC,wCAAwC,CAAC,CAAC,EAAE,CACtD,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,UAAU,CACjB;IACD,qEAAqE;IACrE,uEAAuE;IACvE,sEAAsE;CACvE,CACF,CAAC"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
CREATE TABLE "accounts" (
|
|
2
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
3
|
-
"user_id" text NOT NULL,
|
|
4
|
-
"account_id" text NOT NULL,
|
|
5
|
-
"provider_id" text NOT NULL,
|
|
6
|
-
"access_token" text,
|
|
7
|
-
"refresh_token" text,
|
|
8
|
-
"access_token_expires_at" timestamp,
|
|
9
|
-
"refresh_token_expires_at" timestamp,
|
|
10
|
-
"scope" text,
|
|
11
|
-
"id_token" text,
|
|
12
|
-
"password" text,
|
|
13
|
-
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
14
|
-
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
15
|
-
);
|
|
16
|
-
--> statement-breakpoint
|
|
17
|
-
CREATE TABLE "sessions" (
|
|
18
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
19
|
-
"user_id" text NOT NULL,
|
|
20
|
-
"token" text NOT NULL,
|
|
21
|
-
"expires_at" timestamp NOT NULL,
|
|
22
|
-
"ip_address" text,
|
|
23
|
-
"user_agent" text,
|
|
24
|
-
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
25
|
-
"updated_at" timestamp DEFAULT now() NOT NULL,
|
|
26
|
-
CONSTRAINT "sessions_token_unique" UNIQUE("token")
|
|
27
|
-
);
|
|
28
|
-
--> statement-breakpoint
|
|
29
|
-
CREATE TABLE "users" (
|
|
30
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
31
|
-
"name" text NOT NULL,
|
|
32
|
-
"email" text NOT NULL,
|
|
33
|
-
"email_verified" boolean DEFAULT false NOT NULL,
|
|
34
|
-
"image" text,
|
|
35
|
-
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
36
|
-
"updated_at" timestamp DEFAULT now() NOT NULL,
|
|
37
|
-
CONSTRAINT "users_email_unique" UNIQUE("email")
|
|
38
|
-
);
|
|
39
|
-
--> statement-breakpoint
|
|
40
|
-
CREATE TABLE "verifications" (
|
|
41
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
42
|
-
"identifier" text NOT NULL,
|
|
43
|
-
"value" text NOT NULL,
|
|
44
|
-
"expires_at" timestamp NOT NULL,
|
|
45
|
-
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
46
|
-
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
47
|
-
);
|
|
48
|
-
--> statement-breakpoint
|
|
49
|
-
ALTER TABLE "accounts" ADD CONSTRAINT "accounts_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
50
|
-
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
51
|
-
CREATE INDEX "accounts_user_id_idx" ON "accounts" USING btree ("user_id");--> statement-breakpoint
|
|
52
|
-
CREATE INDEX "sessions_user_id_idx" ON "sessions" USING btree ("user_id");
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
CREATE TABLE "invitation" (
|
|
2
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
3
|
-
"organization_id" text NOT NULL,
|
|
4
|
-
"email" text NOT NULL,
|
|
5
|
-
"role" text NOT NULL,
|
|
6
|
-
"status" text NOT NULL,
|
|
7
|
-
"expires_at" timestamp NOT NULL,
|
|
8
|
-
"inviter_id" text NOT NULL,
|
|
9
|
-
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
10
|
-
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
11
|
-
);
|
|
12
|
-
--> statement-breakpoint
|
|
13
|
-
CREATE TABLE "member" (
|
|
14
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
15
|
-
"organization_id" text NOT NULL,
|
|
16
|
-
"user_id" text NOT NULL,
|
|
17
|
-
"role" text NOT NULL,
|
|
18
|
-
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
19
|
-
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
20
|
-
);
|
|
21
|
-
--> statement-breakpoint
|
|
22
|
-
CREATE TABLE "organization" (
|
|
23
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
24
|
-
"name" text NOT NULL,
|
|
25
|
-
"slug" text,
|
|
26
|
-
"logo" text,
|
|
27
|
-
"metadata" text,
|
|
28
|
-
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
29
|
-
"updated_at" timestamp DEFAULT now() NOT NULL,
|
|
30
|
-
CONSTRAINT "organization_slug_unique" UNIQUE("slug")
|
|
31
|
-
);
|
|
32
|
-
--> statement-breakpoint
|
|
33
|
-
ALTER TABLE "invitation" ADD CONSTRAINT "invitation_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
34
|
-
ALTER TABLE "invitation" ADD CONSTRAINT "invitation_inviter_id_users_id_fk" FOREIGN KEY ("inviter_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
35
|
-
ALTER TABLE "member" ADD CONSTRAINT "member_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
36
|
-
ALTER TABLE "member" ADD CONSTRAINT "member_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
37
|
-
CREATE INDEX "invitation_organization_id_idx" ON "invitation" USING btree ("organization_id");--> statement-breakpoint
|
|
38
|
-
CREATE INDEX "invitation_email_idx" ON "invitation" USING btree ("email");--> statement-breakpoint
|
|
39
|
-
CREATE INDEX "member_organization_id_idx" ON "member" USING btree ("organization_id");--> statement-breakpoint
|
|
40
|
-
CREATE INDEX "member_user_id_idx" ON "member" USING btree ("user_id");
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
-- Enable pgvector extension for vector embeddings (AI Phase 16)
|
|
2
|
-
CREATE EXTENSION IF NOT EXISTS vector;
|
|
3
|
-
--> statement-breakpoint
|
|
4
|
-
CREATE TABLE "conversations" (
|
|
5
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
6
|
-
"workspace_id" text NOT NULL,
|
|
7
|
-
"user_id" text NOT NULL,
|
|
8
|
-
"agent_id" text NOT NULL,
|
|
9
|
-
"title" text,
|
|
10
|
-
"model_id" text,
|
|
11
|
-
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
12
|
-
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
13
|
-
);
|
|
14
|
-
--> statement-breakpoint
|
|
15
|
-
CREATE TABLE "knowledge_chunks" (
|
|
16
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
17
|
-
"document_id" text NOT NULL,
|
|
18
|
-
"workspace_id" text NOT NULL,
|
|
19
|
-
"content" text NOT NULL,
|
|
20
|
-
"embedding" vector(1536),
|
|
21
|
-
"metadata" text,
|
|
22
|
-
"chunk_index" integer NOT NULL,
|
|
23
|
-
"created_at" timestamp DEFAULT now() NOT NULL
|
|
24
|
-
);
|
|
25
|
-
--> statement-breakpoint
|
|
26
|
-
CREATE TABLE "knowledge_documents" (
|
|
27
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
28
|
-
"workspace_id" text NOT NULL,
|
|
29
|
-
"filename" text NOT NULL,
|
|
30
|
-
"mime_type" text NOT NULL,
|
|
31
|
-
"size_bytes" integer,
|
|
32
|
-
"chunk_count" integer DEFAULT 0,
|
|
33
|
-
"status" text DEFAULT 'processing' NOT NULL,
|
|
34
|
-
"product" text,
|
|
35
|
-
"metadata" text,
|
|
36
|
-
"created_at" timestamp DEFAULT now() NOT NULL
|
|
37
|
-
);
|
|
38
|
-
--> statement-breakpoint
|
|
39
|
-
CREATE TABLE "messages" (
|
|
40
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
41
|
-
"conversation_id" text NOT NULL,
|
|
42
|
-
"role" text NOT NULL,
|
|
43
|
-
"content" text NOT NULL,
|
|
44
|
-
"tool_invocations" text,
|
|
45
|
-
"token_count" integer,
|
|
46
|
-
"created_at" timestamp DEFAULT now() NOT NULL
|
|
47
|
-
);
|
|
48
|
-
--> statement-breakpoint
|
|
49
|
-
CREATE TABLE "credit_balances" (
|
|
50
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
51
|
-
"workspace_id" text NOT NULL,
|
|
52
|
-
"balance" integer DEFAULT 0 NOT NULL,
|
|
53
|
-
"total_purchased" integer DEFAULT 0 NOT NULL,
|
|
54
|
-
"total_used" integer DEFAULT 0 NOT NULL,
|
|
55
|
-
"updated_at" timestamp DEFAULT now() NOT NULL,
|
|
56
|
-
CONSTRAINT "credit_balances_workspace_id_unique" UNIQUE("workspace_id")
|
|
57
|
-
);
|
|
58
|
-
--> statement-breakpoint
|
|
59
|
-
CREATE TABLE "credit_purchases" (
|
|
60
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
61
|
-
"workspace_id" text NOT NULL,
|
|
62
|
-
"amount" integer NOT NULL,
|
|
63
|
-
"credits" integer NOT NULL,
|
|
64
|
-
"stripe_payment_intent_id" text,
|
|
65
|
-
"stripe_checkout_session_id" text,
|
|
66
|
-
"status" text DEFAULT 'pending' NOT NULL,
|
|
67
|
-
"created_at" timestamp DEFAULT now() NOT NULL
|
|
68
|
-
);
|
|
69
|
-
--> statement-breakpoint
|
|
70
|
-
CREATE TABLE "finance_events" (
|
|
71
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
72
|
-
"workspace_id" text,
|
|
73
|
-
"stripe_event_id" text NOT NULL,
|
|
74
|
-
"type" text NOT NULL,
|
|
75
|
-
"amount" integer,
|
|
76
|
-
"currency" text DEFAULT 'usd',
|
|
77
|
-
"metadata" text,
|
|
78
|
-
"processed_at" timestamp,
|
|
79
|
-
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
80
|
-
CONSTRAINT "finance_events_stripe_event_id_unique" UNIQUE("stripe_event_id")
|
|
81
|
-
);
|
|
82
|
-
--> statement-breakpoint
|
|
83
|
-
CREATE TABLE "plans" (
|
|
84
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
85
|
-
"name" text NOT NULL,
|
|
86
|
-
"slug" text NOT NULL,
|
|
87
|
-
"description" text,
|
|
88
|
-
"price_monthly" integer NOT NULL,
|
|
89
|
-
"price_yearly" integer NOT NULL,
|
|
90
|
-
"stripe_price_id_monthly" text,
|
|
91
|
-
"stripe_price_id_yearly" text,
|
|
92
|
-
"features" text NOT NULL,
|
|
93
|
-
"limits" text NOT NULL,
|
|
94
|
-
"is_active" boolean DEFAULT true NOT NULL,
|
|
95
|
-
"sort_order" integer DEFAULT 0 NOT NULL,
|
|
96
|
-
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
97
|
-
"updated_at" timestamp DEFAULT now() NOT NULL,
|
|
98
|
-
CONSTRAINT "plans_slug_unique" UNIQUE("slug")
|
|
99
|
-
);
|
|
100
|
-
--> statement-breakpoint
|
|
101
|
-
CREATE TABLE "subscriptions" (
|
|
102
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
103
|
-
"workspace_id" text NOT NULL,
|
|
104
|
-
"plan_id" text NOT NULL,
|
|
105
|
-
"stripe_customer_id" text,
|
|
106
|
-
"stripe_subscription_id" text,
|
|
107
|
-
"status" text DEFAULT 'active' NOT NULL,
|
|
108
|
-
"billing_mode" text DEFAULT 'subscription' NOT NULL,
|
|
109
|
-
"current_period_start" timestamp,
|
|
110
|
-
"current_period_end" timestamp,
|
|
111
|
-
"cancel_at_period_end" boolean DEFAULT false NOT NULL,
|
|
112
|
-
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
113
|
-
"updated_at" timestamp DEFAULT now() NOT NULL,
|
|
114
|
-
CONSTRAINT "subscriptions_stripe_subscription_id_unique" UNIQUE("stripe_subscription_id"),
|
|
115
|
-
CONSTRAINT "subscriptions_workspace_id_unique" UNIQUE("workspace_id")
|
|
116
|
-
);
|
|
117
|
-
--> statement-breakpoint
|
|
118
|
-
CREATE TABLE "feature_flags" (
|
|
119
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
120
|
-
"name" text NOT NULL,
|
|
121
|
-
"description" text,
|
|
122
|
-
"enabled_plans" text NOT NULL,
|
|
123
|
-
"is_active" boolean DEFAULT true NOT NULL,
|
|
124
|
-
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
125
|
-
"updated_at" timestamp DEFAULT now() NOT NULL,
|
|
126
|
-
CONSTRAINT "feature_flags_name_unique" UNIQUE("name")
|
|
127
|
-
);
|
|
128
|
-
--> statement-breakpoint
|
|
129
|
-
CREATE TABLE "monthly_usage" (
|
|
130
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
131
|
-
"workspace_id" text NOT NULL,
|
|
132
|
-
"period_start" timestamp NOT NULL,
|
|
133
|
-
"period_end" timestamp NOT NULL,
|
|
134
|
-
"tokens_used" integer DEFAULT 0 NOT NULL,
|
|
135
|
-
"request_count" integer DEFAULT 0 NOT NULL,
|
|
136
|
-
"updated_at" timestamp DEFAULT now() NOT NULL,
|
|
137
|
-
CONSTRAINT "monthly_usage_workspace_period_unique" UNIQUE("workspace_id","period_start")
|
|
138
|
-
);
|
|
139
|
-
--> statement-breakpoint
|
|
140
|
-
CREATE TABLE "notification_history" (
|
|
141
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
142
|
-
"workspace_id" text NOT NULL,
|
|
143
|
-
"type" text NOT NULL,
|
|
144
|
-
"period_key" text NOT NULL,
|
|
145
|
-
"sent_at" timestamp DEFAULT now() NOT NULL,
|
|
146
|
-
"channel" text DEFAULT 'console' NOT NULL,
|
|
147
|
-
"metadata" text,
|
|
148
|
-
CONSTRAINT "notification_history_dedup_unique" UNIQUE("workspace_id","type","period_key")
|
|
149
|
-
);
|
|
150
|
-
--> statement-breakpoint
|
|
151
|
-
CREATE TABLE "rate_limit_entries" (
|
|
152
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
153
|
-
"workspace_id" text NOT NULL,
|
|
154
|
-
"endpoint" text DEFAULT 'chat' NOT NULL,
|
|
155
|
-
"requested_at" timestamp DEFAULT now() NOT NULL
|
|
156
|
-
);
|
|
157
|
-
--> statement-breakpoint
|
|
158
|
-
CREATE TABLE "trial_credits" (
|
|
159
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
160
|
-
"workspace_id" text NOT NULL,
|
|
161
|
-
"initial_credits" integer DEFAULT 100000 NOT NULL,
|
|
162
|
-
"credits_used" integer DEFAULT 0 NOT NULL,
|
|
163
|
-
"credits_remaining" integer DEFAULT 100000 NOT NULL,
|
|
164
|
-
"status" text DEFAULT 'active' NOT NULL,
|
|
165
|
-
"provisioned_at" timestamp DEFAULT now() NOT NULL,
|
|
166
|
-
"depleted_at" timestamp,
|
|
167
|
-
"converted_at" timestamp,
|
|
168
|
-
"created_by_ip" text,
|
|
169
|
-
"created_by_email" text,
|
|
170
|
-
CONSTRAINT "trial_credits_workspace_id_unique" UNIQUE("workspace_id")
|
|
171
|
-
);
|
|
172
|
-
--> statement-breakpoint
|
|
173
|
-
CREATE TABLE "usage_records" (
|
|
174
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
175
|
-
"workspace_id" text NOT NULL,
|
|
176
|
-
"user_id" text NOT NULL,
|
|
177
|
-
"type" text NOT NULL,
|
|
178
|
-
"model" text,
|
|
179
|
-
"agent" text,
|
|
180
|
-
"input_tokens" integer DEFAULT 0 NOT NULL,
|
|
181
|
-
"output_tokens" integer DEFAULT 0 NOT NULL,
|
|
182
|
-
"total_tokens" integer DEFAULT 0 NOT NULL,
|
|
183
|
-
"metadata" text,
|
|
184
|
-
"recorded_at" timestamp DEFAULT now() NOT NULL
|
|
185
|
-
);
|
|
186
|
-
--> statement-breakpoint
|
|
187
|
-
CREATE TABLE "notifications" (
|
|
188
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
189
|
-
"user_id" text NOT NULL,
|
|
190
|
-
"workspace_id" text,
|
|
191
|
-
"type" text NOT NULL,
|
|
192
|
-
"title" text NOT NULL,
|
|
193
|
-
"message" text NOT NULL,
|
|
194
|
-
"is_read" boolean DEFAULT false NOT NULL,
|
|
195
|
-
"metadata" text,
|
|
196
|
-
"created_at" timestamp DEFAULT now() NOT NULL
|
|
197
|
-
);
|
|
198
|
-
--> statement-breakpoint
|
|
199
|
-
ALTER TABLE "conversations" ADD CONSTRAINT "conversations_workspace_id_organization_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
200
|
-
ALTER TABLE "conversations" ADD CONSTRAINT "conversations_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
201
|
-
ALTER TABLE "knowledge_chunks" ADD CONSTRAINT "knowledge_chunks_document_id_knowledge_documents_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."knowledge_documents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
202
|
-
ALTER TABLE "knowledge_chunks" ADD CONSTRAINT "knowledge_chunks_workspace_id_organization_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
203
|
-
ALTER TABLE "knowledge_documents" ADD CONSTRAINT "knowledge_documents_workspace_id_organization_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
204
|
-
ALTER TABLE "messages" ADD CONSTRAINT "messages_conversation_id_conversations_id_fk" FOREIGN KEY ("conversation_id") REFERENCES "public"."conversations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
205
|
-
ALTER TABLE "credit_balances" ADD CONSTRAINT "credit_balances_workspace_id_organization_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
206
|
-
ALTER TABLE "credit_purchases" ADD CONSTRAINT "credit_purchases_workspace_id_organization_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
207
|
-
ALTER TABLE "finance_events" ADD CONSTRAINT "finance_events_workspace_id_organization_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."organization"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
208
|
-
ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_workspace_id_organization_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
209
|
-
ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_plan_id_plans_id_fk" FOREIGN KEY ("plan_id") REFERENCES "public"."plans"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
210
|
-
ALTER TABLE "monthly_usage" ADD CONSTRAINT "monthly_usage_workspace_id_organization_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
211
|
-
ALTER TABLE "notification_history" ADD CONSTRAINT "notification_history_workspace_id_organization_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
212
|
-
ALTER TABLE "rate_limit_entries" ADD CONSTRAINT "rate_limit_entries_workspace_id_organization_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
213
|
-
ALTER TABLE "trial_credits" ADD CONSTRAINT "trial_credits_workspace_id_organization_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
214
|
-
ALTER TABLE "usage_records" ADD CONSTRAINT "usage_records_workspace_id_organization_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
215
|
-
ALTER TABLE "usage_records" ADD CONSTRAINT "usage_records_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
216
|
-
CREATE INDEX "conversations_workspace_id_idx" ON "conversations" USING btree ("workspace_id");--> statement-breakpoint
|
|
217
|
-
CREATE INDEX "conversations_user_id_idx" ON "conversations" USING btree ("user_id");--> statement-breakpoint
|
|
218
|
-
CREATE INDEX "conversations_workspace_updated_idx" ON "conversations" USING btree ("workspace_id","updated_at");--> statement-breakpoint
|
|
219
|
-
CREATE INDEX "knowledge_chunks_document_id_idx" ON "knowledge_chunks" USING btree ("document_id");--> statement-breakpoint
|
|
220
|
-
CREATE INDEX "knowledge_chunks_workspace_id_idx" ON "knowledge_chunks" USING btree ("workspace_id");--> statement-breakpoint
|
|
221
|
-
CREATE INDEX IF NOT EXISTS "knowledge_chunks_embedding_hnsw_idx" ON "knowledge_chunks" USING hnsw ("embedding" vector_cosine_ops);--> statement-breakpoint
|
|
222
|
-
CREATE INDEX "knowledge_documents_workspace_id_idx" ON "knowledge_documents" USING btree ("workspace_id");--> statement-breakpoint
|
|
223
|
-
CREATE INDEX "messages_conversation_id_idx" ON "messages" USING btree ("conversation_id");--> statement-breakpoint
|
|
224
|
-
CREATE INDEX "messages_conversation_created_idx" ON "messages" USING btree ("conversation_id","created_at");--> statement-breakpoint
|
|
225
|
-
CREATE INDEX "credit_purchases_workspace_id_idx" ON "credit_purchases" USING btree ("workspace_id");--> statement-breakpoint
|
|
226
|
-
CREATE INDEX "subscriptions_workspace_id_idx" ON "subscriptions" USING btree ("workspace_id");--> statement-breakpoint
|
|
227
|
-
CREATE INDEX "monthly_usage_workspace_id_idx" ON "monthly_usage" USING btree ("workspace_id");--> statement-breakpoint
|
|
228
|
-
CREATE INDEX "notification_history_workspace_id_idx" ON "notification_history" USING btree ("workspace_id");--> statement-breakpoint
|
|
229
|
-
CREATE INDEX "rate_limit_entries_window_idx" ON "rate_limit_entries" USING btree ("workspace_id","endpoint","requested_at");--> statement-breakpoint
|
|
230
|
-
CREATE INDEX "usage_records_workspace_id_idx" ON "usage_records" USING btree ("workspace_id");--> statement-breakpoint
|
|
231
|
-
CREATE INDEX "usage_records_workspace_recorded_at_idx" ON "usage_records" USING btree ("workspace_id","recorded_at");--> statement-breakpoint
|
|
232
|
-
CREATE INDEX "usage_records_workspace_type_idx" ON "usage_records" USING btree ("workspace_id","type");--> statement-breakpoint
|
|
233
|
-
CREATE INDEX "notifications_user_id_idx" ON "notifications" USING btree ("user_id");--> statement-breakpoint
|
|
234
|
-
CREATE INDEX "notifications_user_id_is_read_idx" ON "notifications" USING btree ("user_id","is_read");--> statement-breakpoint
|
|
235
|
-
CREATE INDEX "notifications_created_at_idx" ON "notifications" USING btree ("created_at");
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
CREATE TABLE "documents" (
|
|
2
|
-
"id" text NOT NULL,
|
|
3
|
-
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
4
|
-
"title" text NOT NULL,
|
|
5
|
-
"content" text,
|
|
6
|
-
"kind" text DEFAULT 'text' NOT NULL,
|
|
7
|
-
"user_id" text NOT NULL,
|
|
8
|
-
CONSTRAINT "documents_id_created_at_pk" PRIMARY KEY("id","created_at")
|
|
9
|
-
);
|
|
10
|
-
--> statement-breakpoint
|
|
11
|
-
CREATE TABLE "suggestions" (
|
|
12
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
13
|
-
"document_id" text NOT NULL,
|
|
14
|
-
"document_created_at" timestamp NOT NULL,
|
|
15
|
-
"original_text" text NOT NULL,
|
|
16
|
-
"suggested_text" text NOT NULL,
|
|
17
|
-
"description" text,
|
|
18
|
-
"is_resolved" boolean DEFAULT false NOT NULL,
|
|
19
|
-
"user_id" text NOT NULL,
|
|
20
|
-
"created_at" timestamp DEFAULT now() NOT NULL
|
|
21
|
-
);
|
|
22
|
-
--> statement-breakpoint
|
|
23
|
-
CREATE TABLE "votes" (
|
|
24
|
-
"chat_id" text NOT NULL,
|
|
25
|
-
"message_id" text NOT NULL,
|
|
26
|
-
"is_upvoted" boolean NOT NULL,
|
|
27
|
-
CONSTRAINT "votes_chat_id_message_id_pk" PRIMARY KEY("chat_id","message_id")
|
|
28
|
-
);
|
|
29
|
-
--> statement-breakpoint
|
|
30
|
-
ALTER TABLE "messages" ALTER COLUMN "content" DROP NOT NULL;--> statement-breakpoint
|
|
31
|
-
ALTER TABLE "conversations" ADD COLUMN "visibility" text DEFAULT 'private' NOT NULL;--> statement-breakpoint
|
|
32
|
-
ALTER TABLE "messages" ADD COLUMN "parts" text NOT NULL;--> statement-breakpoint
|
|
33
|
-
ALTER TABLE "messages" ADD COLUMN "attachments" text;--> statement-breakpoint
|
|
34
|
-
ALTER TABLE "documents" ADD CONSTRAINT "documents_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
35
|
-
ALTER TABLE "suggestions" ADD CONSTRAINT "suggestions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
36
|
-
ALTER TABLE "votes" ADD CONSTRAINT "votes_chat_id_conversations_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."conversations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
37
|
-
ALTER TABLE "votes" ADD CONSTRAINT "votes_message_id_messages_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."messages"("id") ON DELETE cascade ON UPDATE no action;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
ALTER TABLE "subscriptions" DROP CONSTRAINT "subscriptions_plan_id_plans_id_fk";
|
|
2
|
-
--> statement-breakpoint
|
|
3
|
-
ALTER TABLE "users" ADD COLUMN "deleted_at" timestamp;--> statement-breakpoint
|
|
4
|
-
ALTER TABLE "users" ADD COLUMN "onboarding_completed" boolean DEFAULT false NOT NULL;--> statement-breakpoint
|
|
5
|
-
ALTER TABLE "users" ADD COLUMN "onboarding_step" text;--> statement-breakpoint
|
|
6
|
-
ALTER TABLE "users" ADD COLUMN "preferred_language" text DEFAULT 'en' NOT NULL;--> statement-breakpoint
|
|
7
|
-
ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_plan_id_plans_id_fk" FOREIGN KEY ("plan_id") REFERENCES "public"."plans"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
|
8
|
-
CREATE INDEX "trial_credits_expiry_idx" ON "trial_credits" USING btree ("status","trial_end_date");
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
CREATE TABLE "agents" (
|
|
2
|
-
"id" text PRIMARY KEY NOT NULL,
|
|
3
|
-
"name" jsonb NOT NULL,
|
|
4
|
-
"description" jsonb NOT NULL,
|
|
5
|
-
"system_prompt_key" text NOT NULL,
|
|
6
|
-
"icon" text NOT NULL,
|
|
7
|
-
"default_model" text NOT NULL,
|
|
8
|
-
"max_steps" integer NOT NULL,
|
|
9
|
-
"context_window_size" integer NOT NULL,
|
|
10
|
-
"tools" jsonb DEFAULT '[]'::jsonb NOT NULL,
|
|
11
|
-
"base_path" text NOT NULL,
|
|
12
|
-
"is_active" boolean DEFAULT true NOT NULL,
|
|
13
|
-
"is_system" boolean DEFAULT true NOT NULL,
|
|
14
|
-
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
15
|
-
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
16
|
-
);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
ALTER TABLE "agents" ADD COLUMN "suggestions" jsonb DEFAULT '[]'::jsonb NOT NULL;
|