@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
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
-- A database built by the framework's pre-1.0 migration chain is adopted
|
|
2
|
+
-- at 0000_baseline without running it. That chain never quite matched
|
|
3
|
+
-- the schema the code was written against — every environment used to
|
|
4
|
+
-- be provisioned with `db:push` — so this brings such a database to the
|
|
5
|
+
-- baseline's shape. On a database created from the baseline every
|
|
6
|
+
-- statement is a no-op.
|
|
7
|
+
|
|
8
|
+
-- conversations.metadata was created as text; the code reads and writes
|
|
9
|
+
-- it as jsonb.
|
|
10
|
+
DO $$
|
|
11
|
+
BEGIN
|
|
12
|
+
IF (SELECT data_type FROM information_schema.columns
|
|
13
|
+
WHERE table_schema = 'public' AND table_name = 'conversations' AND column_name = 'metadata') = 'text' THEN
|
|
14
|
+
ALTER TABLE "conversations" ALTER COLUMN "metadata" TYPE jsonb USING NULLIF("metadata", '')::jsonb;
|
|
15
|
+
END IF;
|
|
16
|
+
END $$;
|
|
17
|
+
--> statement-breakpoint
|
|
18
|
+
-- Deleting a user keeps the invitations they sent, without an inviter.
|
|
19
|
+
ALTER TABLE "invitation" ALTER COLUMN "inviter_id" DROP NOT NULL;
|
|
20
|
+
--> statement-breakpoint
|
|
21
|
+
DO $$
|
|
22
|
+
BEGIN
|
|
23
|
+
IF EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'invitation_inviter_id_users_id_fk' AND confdeltype <> 'n') THEN
|
|
24
|
+
ALTER TABLE "invitation" DROP CONSTRAINT "invitation_inviter_id_users_id_fk";
|
|
25
|
+
ALTER TABLE "invitation" ADD CONSTRAINT "invitation_inviter_id_users_id_fk"
|
|
26
|
+
FOREIGN KEY ("inviter_id") REFERENCES "users"("id") ON DELETE SET NULL;
|
|
27
|
+
END IF;
|
|
28
|
+
END $$;
|
|
29
|
+
--> statement-breakpoint
|
|
30
|
+
-- Deleting a workspace keeps its finance events for the books.
|
|
31
|
+
DO $$
|
|
32
|
+
BEGIN
|
|
33
|
+
IF EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'finance_events_workspace_id_organization_id_fk' AND confdeltype <> 'n') THEN
|
|
34
|
+
ALTER TABLE "finance_events" DROP CONSTRAINT "finance_events_workspace_id_organization_id_fk";
|
|
35
|
+
ALTER TABLE "finance_events" ADD CONSTRAINT "finance_events_workspace_id_organization_id_fk"
|
|
36
|
+
FOREIGN KEY ("workspace_id") REFERENCES "organization"("id") ON DELETE SET NULL;
|
|
37
|
+
END IF;
|
|
38
|
+
END $$;
|
|
39
|
+
--> statement-breakpoint
|
|
40
|
+
-- One quota row per user per workspace. The old chain made this a
|
|
41
|
+
-- unique index of the same name, which serves ON CONFLICT equally.
|
|
42
|
+
DO $$
|
|
43
|
+
BEGIN
|
|
44
|
+
IF to_regclass('public.user_quotas_user_workspace_unique') IS NULL THEN
|
|
45
|
+
ALTER TABLE "user_quotas" ADD CONSTRAINT "user_quotas_user_workspace_unique" UNIQUE ("user_id", "workspace_id");
|
|
46
|
+
END IF;
|
|
47
|
+
END $$;
|
|
48
|
+
--> statement-breakpoint
|
|
49
|
+
CREATE INDEX IF NOT EXISTS "conversations_workspace_user_idx" ON "conversations" USING btree ("workspace_id", "user_id");
|
|
50
|
+
--> statement-breakpoint
|
|
51
|
+
CREATE INDEX IF NOT EXISTS "documents_user_id_idx" ON "documents" USING btree ("user_id");
|
|
52
|
+
--> statement-breakpoint
|
|
53
|
+
CREATE UNIQUE INDEX IF NOT EXISTS "member_organization_user_uniq" ON "member" USING btree ("organization_id", "user_id");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "finance_events" ADD COLUMN "claimed_at" timestamp;
|
|
@@ -1,43 +1,82 @@
|
|
|
1
1
|
# Migrations
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
The framework's schema is one migration, `0000_baseline.sql`, generated
|
|
4
|
+
from the Drizzle schema (`src/db/schema/*` plus the audit, executions
|
|
5
|
+
and jobs packages' `schema.ts`) with the pieces Drizzle cannot express
|
|
6
|
+
added by hand: the `vector` extension, the HNSW index on memory
|
|
7
|
+
embeddings, and the triggers that keep `audit_events` and
|
|
8
|
+
`user_memory_audit` append-only. Later migrations follow it in
|
|
9
|
+
`meta/_journal.json`.
|
|
10
|
+
|
|
11
|
+
A migration here changes structure only. It never inserts or edits rows:
|
|
12
|
+
what a deployment bills in, its plans and its agents come from its own
|
|
13
|
+
composition root (`ensureBillingSettingsRow`, the plan registry).
|
|
14
|
+
`tests/architecture/baseline.test.ts` enforces it.
|
|
15
|
+
|
|
16
|
+
## In a consumer application
|
|
17
|
+
|
|
18
|
+
This directory ships inside the published package (it is in `files`,
|
|
19
|
+
next to `dist`), and `intelligo migrate` applies it: it resolves the
|
|
20
|
+
chain from `node_modules/@intelligo-dev/core/src/db/migrations`, applies
|
|
21
|
+
what is pending by content hash, and records it in drizzle's default
|
|
22
|
+
`drizzle.__drizzle_migrations` table — the table
|
|
23
|
+
`intelligo migrate --check` reads.
|
|
24
|
+
|
|
25
|
+
The tables an application owns are a second chain, kept apart on
|
|
26
|
+
purpose: drizzle-kit applies by timestamp, so a framework migration
|
|
27
|
+
published after the consumer generated one of theirs would be skipped
|
|
28
|
+
silently if the two shared a journal. `intelligo create` scaffolds a
|
|
29
|
+
`drizzle.config.ts` whose `schema` lists only the consumer's files,
|
|
30
|
+
whose `out` is the app's own `./drizzle`, and whose `migrations.table`
|
|
31
|
+
is `__app_migrations`. A consumer schema file may `references()` a
|
|
32
|
+
framework table — drizzle-kit emits the foreign key by name and does
|
|
33
|
+
not try to create the referenced table. The scaffold's scripts:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
pnpm db:generate # drizzle-kit generate — your chain
|
|
37
|
+
pnpm db:migrate # intelligo migrate && drizzle-kit migrate
|
|
38
|
+
pnpm db:check # intelligo migrate --check — deploy gate
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`drizzle-kit push` has no place in this layout: it diffs the whole
|
|
42
|
+
database against the schema it can see, and the consumer config sees
|
|
43
|
+
only the consumer's tables.
|
|
15
44
|
|
|
16
45
|
## Adding a migration
|
|
17
46
|
|
|
18
|
-
|
|
19
|
-
the `.sql` file and its journal entry. A
|
|
20
|
-
|
|
21
|
-
|
|
47
|
+
Change the schema, then `pnpm --filter @intelligo-dev/core db:generate`,
|
|
48
|
+
which writes the `.sql` file, its snapshot and its journal entry. A
|
|
49
|
+
hand-written file (a trigger, a data-free `DO` block) needs its journal
|
|
50
|
+
entry added by hand — `intelligo doctor` fails if the journal and the
|
|
51
|
+
directory disagree.
|
|
52
|
+
|
|
53
|
+
## Databases from before 1.0
|
|
22
54
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
55
|
+
Before 1.0 the framework's schema was a chain of 48 migrations that had
|
|
56
|
+
grown with the product it came from; some created tables the framework
|
|
57
|
+
no longer owns. `legacy-chain.json` lists that chain's tags and content
|
|
58
|
+
hashes — not its SQL. A database that ran the whole chain is **adopted**:
|
|
59
|
+
`intelligo migrate` records `0000_baseline` as applied without running
|
|
60
|
+
it, then applies `0001_reconcile_chain_built_databases`, which brings
|
|
61
|
+
the few places where the old chain and the schema disagreed into line
|
|
62
|
+
(a no-op on a database created from the baseline). Tables the old chain
|
|
63
|
+
created that the framework no longer defines are left untouched; a
|
|
64
|
+
product that still uses them keeps them in its own migrations.
|
|
27
65
|
|
|
28
|
-
|
|
66
|
+
A database that ran only part of the old chain is refused: finish it
|
|
67
|
+
with `@intelligo-dev/core@1.0.0-beta.7` first.
|
|
29
68
|
|
|
30
|
-
|
|
31
|
-
database provisioned with `push` has the schema but no record of the
|
|
32
|
-
migrations. Running `migrate` against it now would try to apply all 39.
|
|
33
|
-
Most are `IF NOT EXISTS`-guarded, but not all.
|
|
69
|
+
## Baselining a push-provisioned database
|
|
34
70
|
|
|
35
|
-
|
|
36
|
-
|
|
71
|
+
A database provisioned with `drizzle-kit push` has the schema but no
|
|
72
|
+
migration records, and `intelligo migrate` refuses it rather than
|
|
73
|
+
applying the baseline to tables that already exist. Record the chain as
|
|
74
|
+
applied before the first `migrate`, one row per journal entry, in
|
|
75
|
+
journal order: `hash` is the sha256 of the `.sql` file's contents and
|
|
76
|
+
`created_at` the entry's `when`.
|
|
37
77
|
|
|
38
78
|
```sql
|
|
39
|
-
|
|
40
|
-
-- the .sql file contents; drizzle compares it on subsequent runs.
|
|
79
|
+
CREATE SCHEMA IF NOT EXISTS drizzle;
|
|
41
80
|
CREATE TABLE IF NOT EXISTS drizzle.__drizzle_migrations (
|
|
42
81
|
id SERIAL PRIMARY KEY,
|
|
43
82
|
hash text NOT NULL,
|
|
@@ -45,13 +84,12 @@ CREATE TABLE IF NOT EXISTS drizzle.__drizzle_migrations (
|
|
|
45
84
|
);
|
|
46
85
|
```
|
|
47
86
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
reports nothing to apply. Do this on a restored copy first.
|
|
87
|
+
Then verify with `intelligo migrate --check`. Do this on a restored copy
|
|
88
|
+
first.
|
|
51
89
|
|
|
52
90
|
## Verifying the chain
|
|
53
91
|
|
|
54
|
-
CI replays every file against an empty database on each run
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
rather than documentation.
|
|
92
|
+
CI replays every file against an empty database on each run and then
|
|
93
|
+
asserts the columns the running code depends on, and the database
|
|
94
|
+
integration suites run against that replay — which is what proves these
|
|
95
|
+
files are a provisioning mechanism rather than documentation.
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "The framework's migration chain before the 1.0 baseline: every entry's tag and the sha256 of its .sql file, as drizzle recorded it in drizzle.__drizzle_migrations. `intelligo migrate` reads it to adopt a database that ran the whole old chain \u2014 it records 0000_baseline as applied without running it. The SQL itself is not shipped.",
|
|
3
|
+
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"tag": "0000_sharp_night_nurse",
|
|
6
|
+
"hash": "095685bd97c0d51b9ec5413d866c84e1ff1f5a86c51a1228ec1a87d372f19899"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"tag": "0001_hesitant_vapor",
|
|
10
|
+
"hash": "403a33243ec4687a3c114a7d1b60e469988452fb54aea93d2e69c29839c86f04"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"tag": "0002_numerous_lady_vermin",
|
|
14
|
+
"hash": "90d931beaaea073d5a363318119449c957cde32282dd53e5bcd5ad488174f97a"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"tag": "0003_mighty_jean_grey",
|
|
18
|
+
"hash": "9d0128a08223a0a112ac8e197315e85eb86d9d7a92028577bc763a5dd9ac84ec"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"tag": "0004_cynical_grandmaster",
|
|
22
|
+
"hash": "53ca240bb183a4416bac27fe430019e36b5c63a8e592f33a8d058f986ad56d97"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"tag": "0005_careful_switch",
|
|
26
|
+
"hash": "b1bd2845c02008f37d49f4c89ab56f8584ec4c3a1f95f23291e836d21bec9465"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"tag": "0006_tense_blue_marvel",
|
|
30
|
+
"hash": "2bab2a70e4ce5fda000d595193800b07ff88a8492da95034c79e82da4b937755"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"tag": "0007_next_squadron_sinister",
|
|
34
|
+
"hash": "c071b97e8edd8b034ecda51764e40ca9e50b3719103f31acd098cfc2e9390b98"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"tag": "0008_powerful_scream",
|
|
38
|
+
"hash": "f88f2a55354442843293abf91069bf0f0a274e8426a954930cba06ed89c557c6"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"tag": "0009_sad_ink",
|
|
42
|
+
"hash": "c5b957dd7abf7dedbe13d2fb4a6c4f3ab5da26d3b8690f8e4f610c53b9366c85"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"tag": "0010_shocking_omega_flight",
|
|
46
|
+
"hash": "c82b4be9f37fbf4d65c0713231a05f162f87a2713df39956155ded4e228217f3"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"tag": "0011_ambiguous_otto_octavius",
|
|
50
|
+
"hash": "0688a1389e8eb66a645103ec3984e77859d91889359cb75eb36b1cd4a07052e5"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"tag": "0011_hnsw_vector_index",
|
|
54
|
+
"hash": "69663f644a3df6c644c5b8b2cd5edbf6045d8c6a319dc15fad35e413128ef243"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"tag": "0012_user_profiles",
|
|
58
|
+
"hash": "aec846995de9798d97524dbfc2bbfc65249cf8142f35c80746688d2ce1807fd5"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"tag": "0013_trending_seasonal_columns",
|
|
62
|
+
"hash": "895d018d85eee1dec5f24ef2c00b5f58de8d036577a8fefec87fef785605891c"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"tag": "0014_add_product_type_to_agents",
|
|
66
|
+
"hash": "9102dcc2b9671a78a1691ab6d35e92c1fc560032d2df86103ed597521db20419"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"tag": "0015_new_v1_tables",
|
|
70
|
+
"hash": "2c6a834de43d4d87c3e857440ede60a725f9f314a0521b9b5ff75e9b152dc04d"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"tag": "0016_document_types",
|
|
74
|
+
"hash": "f96cf97918fc694318b8b6f94d0c3d9ce55daa7e01048ec32cb9755bad786e76"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"tag": "0017_document_metadata",
|
|
78
|
+
"hash": "7da47750df213b13956bdcbb7573196b81d84bc6bdd0da3991d3510f2f9090af"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"tag": "0018_identity_graph",
|
|
82
|
+
"hash": "f32c53f18a9d9e5ca41cc7aed3960d6c114bb468f0abc3de5c69fa40ddc3811d"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"tag": "0019_db_driven_prompts",
|
|
86
|
+
"hash": "fc0ff0e6057e5142b0a4ef5efb39737d6757ad7cd4a744d594e655b3e61e5708"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"tag": "0020_pending_extractions",
|
|
90
|
+
"hash": "c811cb83038597a8d533bc759338fcd7e8515e3a0312e1860d9ab898f7f9ccdb"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"tag": "0021_rag_documents",
|
|
94
|
+
"hash": "0c72555507227726e03003536f059ceeb833644d1f10d8474b3599ab9a8b9636"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"tag": "0022_user_quotas_usage_jsonb",
|
|
98
|
+
"hash": "73664463ec2d4c7a998a8adb44925367bff4d9f6c46b49e28903b1960edd2084"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"tag": "0023_user_facts_user_scoped_unique",
|
|
102
|
+
"hash": "6f8f6a7e823a298e7a6fa9bc9a124abc557516bd442a637d91801eb87233c7ec"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"tag": "0024_user_memories_hnsw",
|
|
106
|
+
"hash": "cffca18b0e4f2081546ae8cd19d027b0fcb5372dc16e6536f2c759ad6e1d391e"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"tag": "0025_audit_trigger_errcode",
|
|
110
|
+
"hash": "eb45e223eabce2f692587967ce24ea31c152bd1ecf50dfe60b28c7a8fc6d3443"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"tag": "0026_user_profile_snapshots_composite_pk",
|
|
114
|
+
"hash": "09dc229039b2e48df073c9cd181e58aa2c210357e077413aecfa70dc482687ee"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"tag": "0027_billing_settings_mnt_columns",
|
|
118
|
+
"hash": "f21baf51c21bf23e2ddd13985f06cf1acefd2f5fb6bf4fbc4c925d49f62051ae"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"tag": "0028_trial_credits_normalized_email",
|
|
122
|
+
"hash": "17c557228ee81f27073a537b5b534abf4557a27e7755a367cba566b14c307235"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"tag": "0029_usage_records_conversation_idx",
|
|
126
|
+
"hash": "260c39df837b8f21feddd35ef2263f52bc3821f288466b15e80d95f20bfe1e72"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"tag": "0030_pending_extractions_composite_idx",
|
|
130
|
+
"hash": "d0e398772a42f6e5de6b3f2a5562b9d98c996e72489413f51a2bb244f4317dda"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"tag": "0031_rag_documents_hnsw",
|
|
134
|
+
"hash": "bc96dba2f49403281d1f27e6f8ac1f55f22d34a3e701af19be54e666f4b088b1"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"tag": "0032_rate_limit_unique_idx",
|
|
138
|
+
"hash": "c2995c76b96b69d8dc6e8a676fe7c45c2fc66d7ed17ce8a68914f8c756869399"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"tag": "0033_pending_extractions_partial_idx",
|
|
142
|
+
"hash": "b74373ba8076cc1f38c3805063023e8dc89de11f3d98502f818460354de18f39"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"tag": "0034_rate_limit_count",
|
|
146
|
+
"hash": "6263b9451b91500213a5559ad960f9186b2fee9d73eeb30a4b3209ae1d3366cc"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"tag": "0035_credit_reservations",
|
|
150
|
+
"hash": "fe95a71462bde8980924e77aff20e38cbee92b4bbae210c504c83015720b10ff"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"tag": "0036_executions_audit_jobs",
|
|
154
|
+
"hash": "8665606757ec96bbd48eaab2b2ebb1ee5b5a86d58ba73635b3229ff94c40e572"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"tag": "0037_rate_limit_minute_bucket",
|
|
158
|
+
"hash": "112683e434f07c4db20179ebaffdc52d6f21f644e0573b718b2ff060794db064"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"tag": "0038_user_quotas_generic_usage",
|
|
162
|
+
"hash": "658b6f64424522d955f2aa4d2ce1fe32b52f0e5adbdba14af75c1678389d7754"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"tag": "0039_platform_admin_impersonation",
|
|
166
|
+
"hash": "e9d67dae6b4e0c1149aadd9f29d23a48c93861cfd5d176d61ca3ade00d735617"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"tag": "0040_ee_audit_chain",
|
|
170
|
+
"hash": "16b01fa704f75e13fe85cee307a2dd287e3cbd93e77fd58ce0eb18cc32e178e6"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"tag": "0041_audit_events_append_only",
|
|
174
|
+
"hash": "963fc9a3c589713ad74e8eed1000e5259f920bba908720d7628f56ad2fb81c40"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"tag": "0042_sessions_active_organization_id",
|
|
178
|
+
"hash": "31b737d2d7ba48959f7daeff2a4a162ed141cb8bfc933a0e1dfd49528295849c"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"tag": "0043_attachments",
|
|
182
|
+
"hash": "922c9c29097b128bfbdf012398541440304f06cfcc9a4ce3a8a9d7adc9f8fab2"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"tag": "0044_money_micros",
|
|
186
|
+
"hash": "794d552ba21338553376a7d0cc926d07bfe493b51afad48bd647b962d38efe51"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"tag": "0045_drop_legacy_money_columns",
|
|
190
|
+
"hash": "f50cf0e58acc2993693ece80bb6ccf21f738f8c828aed3dcad7e88bc30bef40c"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"tag": "0046_user_quotas_per_workspace",
|
|
194
|
+
"hash": "96ddd49d5163edb23328b703fe15d7397a319e43aa104ae4184d1221096b5a63"
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
}
|