@intelligo-dev/core 1.0.0-beta.1 → 1.0.0-beta.14
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 +339 -105
- package/dist/db/schema/billing.d.ts.map +1 -1
- package/dist/db/schema/billing.js +99 -58
- 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 +6 -13
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/index.js +5 -12
- package/dist/identity/index.js.map +1 -1
- package/dist/identity/service.d.ts +29 -47
- package/dist/identity/service.d.ts.map +1 -1
- package/dist/identity/service.js +107 -79
- package/dist/identity/service.js.map +1 -1
- package/dist/identity/types.d.ts +28 -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 +6 -8
- 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/0003_local_payments.sql +18 -0
- package/src/db/migrations/README.md +103 -36
- package/src/db/migrations/legacy-chain.json +206 -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/0003_snapshot.json +2567 -554
- package/src/db/migrations/meta/_journal.json +8 -274
- 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 +245 -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 +29 -0
- package/src/identity/service.ts +303 -0
- package/src/identity/types.ts +58 -0
- package/src/index.ts +4 -0
- package/src/logger.ts +198 -0
- package/src/money.ts +270 -0
- package/src/notifications/index.ts +112 -0
- package/src/notifications/triggers.ts +158 -0
- package/src/notifications/types.ts +26 -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/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/validate.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
* Database Connection Validation
|
|
3
|
-
*
|
|
4
|
-
* Validates that the database is connected and tables exist before allowing the app to start.
|
|
5
|
-
*/
|
|
6
|
-
import { db } from "./client";
|
|
1
|
+
import { db } from "./client.js";
|
|
7
2
|
import { sql } from "drizzle-orm";
|
|
8
|
-
/**
|
|
9
|
-
* Check if database connection is valid and tables exist
|
|
10
|
-
*/
|
|
3
|
+
/** Checks that the database answers and the four auth tables exist. */
|
|
11
4
|
export async function validateDatabaseConnection() {
|
|
12
5
|
try {
|
|
13
|
-
// Test database connection
|
|
14
6
|
await db.execute(sql `SELECT 1`);
|
|
15
|
-
// Check if auth tables exist
|
|
16
7
|
const result = await db.execute(sql `
|
|
17
8
|
SELECT COUNT(*) as table_count
|
|
18
9
|
FROM information_schema.tables
|
|
@@ -26,7 +17,7 @@ export async function validateDatabaseConnection() {
|
|
|
26
17
|
tablesExist,
|
|
27
18
|
error: tablesExist
|
|
28
19
|
? undefined
|
|
29
|
-
: "Auth tables do not exist. Run '
|
|
20
|
+
: "Auth tables do not exist. Run 'intelligo migrate' to apply the framework's migration chain.",
|
|
30
21
|
};
|
|
31
22
|
}
|
|
32
23
|
catch (error) {
|
|
@@ -37,9 +28,7 @@ export async function validateDatabaseConnection() {
|
|
|
37
28
|
};
|
|
38
29
|
}
|
|
39
30
|
}
|
|
40
|
-
/**
|
|
41
|
-
* Validate database or throw error (for startup validation)
|
|
42
|
-
*/
|
|
31
|
+
/** Startup check: throws with setup instructions when validation fails. */
|
|
43
32
|
export async function requireDatabaseConnection() {
|
|
44
33
|
const result = await validateDatabaseConnection();
|
|
45
34
|
if (!result.isConnected) {
|
|
@@ -50,8 +39,8 @@ export async function requireDatabaseConnection() {
|
|
|
50
39
|
if (!result.tablesExist) {
|
|
51
40
|
throw new Error(`❌ Database tables do not exist.\n\n` +
|
|
52
41
|
`Run the following commands to set up the database:\n` +
|
|
53
|
-
` 1.
|
|
54
|
-
` 2.
|
|
42
|
+
` 1. intelligo migrate (applies the framework's migration chain)\n` +
|
|
43
|
+
` 2. drizzle-kit migrate (your own tables, if any)`);
|
|
55
44
|
}
|
|
56
45
|
console.log("✓ Database connection validated");
|
|
57
46
|
}
|
package/dist/db/validate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/db/validate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/db/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAQlC,uEAAuE;AACvE,MAAM,CAAC,KAAK,UAAU,0BAA0B;IAC9C,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA,UAAU,CAAC,CAAC;QAEhC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;;;;;KAKlC,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW,IAAI,CAAC,CAAC,CAAC;QAC5D,MAAM,WAAW,GAAG,UAAU,KAAK,CAAC,CAAC;QAErC,OAAO;YACL,WAAW,EAAE,IAAI;YACjB,WAAW;YACX,KAAK,EAAE,WAAW;gBAChB,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,6FAA6F;SAClG,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,WAAW,EAAE,KAAK;YAClB,WAAW,EAAE,KAAK;YAClB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB;SACzE,CAAC;IACJ,CAAC;AACH,CAAC;AAED,2EAA2E;AAC3E,MAAM,CAAC,KAAK,UAAU,yBAAyB;IAC7C,MAAM,MAAM,GAAG,MAAM,0BAA0B,EAAE,CAAC;IAElD,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,iCAAiC,MAAM,CAAC,KAAK,MAAM;YACjD,sDAAsD;YACtD,oDAAoD,CACvD,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,qCAAqC;YACnC,sDAAsD;YACtD,sEAAsE;YACtE,oDAAoD,CACvD,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -1,37 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Workspace
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* These APIs provide inherent data isolation — all operations are scoped to the
|
|
7
|
-
* authenticated user's session and active organization. No raw DB queries needed.
|
|
8
|
-
*
|
|
9
|
-
* Better-Auth API isolation guarantees:
|
|
10
|
-
* - auth.api.listOrganizations() — returns ONLY organizations the authenticated user belongs to
|
|
11
|
-
* - auth.api.getFullOrganization() — returns ONLY the active organization (set via session)
|
|
12
|
-
* - auth.api.createInvitation() — requires organizationId from requireWorkspace() (authenticated context)
|
|
13
|
-
* - auth.api.removeMember() — scoped to the organizationId from requireWorkspace()
|
|
14
|
-
* - All other org API methods operate on the authenticated user's session context
|
|
15
|
-
*
|
|
16
|
-
* - Future phases (11+) will add product-specific tables (conversations, knowledge_bases,
|
|
17
|
-
* usage_logs, etc.) that contain a workspaceId column. ALL queries on these tables
|
|
18
|
-
* MUST use the helpers below to enforce workspace-scoped data isolation.
|
|
19
|
-
*
|
|
20
|
-
* USAGE PATTERN (for future phases):
|
|
21
|
-
* import { withWorkspaceFilter } from "@intelligo-dev/core/db/workspace-queries";
|
|
22
|
-
* import { requireWorkspace } from "@intelligo-dev/auth";
|
|
23
|
-
*
|
|
24
|
-
* const { workspace } = await requireWorkspace();
|
|
25
|
-
* const conversations = await db
|
|
26
|
-
* .select()
|
|
27
|
-
* .from(conversationsTable)
|
|
28
|
-
* .where(withWorkspaceFilter(conversationsTable.workspaceId, workspace.id));
|
|
2
|
+
* Workspace scoping for tables with a `workspaceId` column. Every query on
|
|
3
|
+
* such a table filters by the workspace resolved from `requireWorkspace()`.
|
|
4
|
+
* Organization, member and invitation rows go through the Better-Auth API,
|
|
5
|
+
* which scopes them to the caller's session.
|
|
29
6
|
*/
|
|
30
7
|
import { type SQL } from "drizzle-orm";
|
|
31
8
|
import type { PgColumn } from "drizzle-orm/pg-core";
|
|
32
9
|
/**
|
|
33
10
|
* Creates a workspace-scoped WHERE condition for any table with a workspaceId column.
|
|
34
|
-
* Use
|
|
11
|
+
* Use it in every custom Drizzle query to enforce workspace isolation.
|
|
35
12
|
*
|
|
36
13
|
* @param workspaceIdColumn - The workspaceId column from the table schema
|
|
37
14
|
* @param workspaceId - The active workspace ID from requireWorkspace()
|
|
@@ -49,7 +26,6 @@ import type { PgColumn } from "drizzle-orm/pg-core";
|
|
|
49
26
|
export declare function workspaceEq(workspaceIdColumn: PgColumn, workspaceId: string): SQL;
|
|
50
27
|
/**
|
|
51
28
|
* Combines a workspace scope condition with additional WHERE conditions.
|
|
52
|
-
* Convenience helper to ensure workspaceId is always the first filter.
|
|
53
29
|
*
|
|
54
30
|
* @param workspaceIdColumn - The workspaceId column from the table schema
|
|
55
31
|
* @param workspaceId - The active workspace ID from requireWorkspace()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-queries.d.ts","sourceRoot":"","sources":["../../src/db/workspace-queries.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"workspace-queries.d.ts","sourceRoot":"","sources":["../../src/db/workspace-queries.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAW,KAAK,GAAG,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CACzB,iBAAiB,EAAE,QAAQ,EAC3B,WAAW,EAAE,MAAM,GAClB,GAAG,CAEL;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,mBAAmB,CACjC,iBAAiB,EAAE,QAAQ,EAC3B,WAAW,EAAE,MAAM,EACnB,GAAG,oBAAoB,EAAE,GAAG,EAAE,GAC7B,GAAG,CAEL"}
|
|
@@ -1,36 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Workspace
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* These APIs provide inherent data isolation — all operations are scoped to the
|
|
7
|
-
* authenticated user's session and active organization. No raw DB queries needed.
|
|
8
|
-
*
|
|
9
|
-
* Better-Auth API isolation guarantees:
|
|
10
|
-
* - auth.api.listOrganizations() — returns ONLY organizations the authenticated user belongs to
|
|
11
|
-
* - auth.api.getFullOrganization() — returns ONLY the active organization (set via session)
|
|
12
|
-
* - auth.api.createInvitation() — requires organizationId from requireWorkspace() (authenticated context)
|
|
13
|
-
* - auth.api.removeMember() — scoped to the organizationId from requireWorkspace()
|
|
14
|
-
* - All other org API methods operate on the authenticated user's session context
|
|
15
|
-
*
|
|
16
|
-
* - Future phases (11+) will add product-specific tables (conversations, knowledge_bases,
|
|
17
|
-
* usage_logs, etc.) that contain a workspaceId column. ALL queries on these tables
|
|
18
|
-
* MUST use the helpers below to enforce workspace-scoped data isolation.
|
|
19
|
-
*
|
|
20
|
-
* USAGE PATTERN (for future phases):
|
|
21
|
-
* import { withWorkspaceFilter } from "@intelligo-dev/core/db/workspace-queries";
|
|
22
|
-
* import { requireWorkspace } from "@intelligo-dev/auth";
|
|
23
|
-
*
|
|
24
|
-
* const { workspace } = await requireWorkspace();
|
|
25
|
-
* const conversations = await db
|
|
26
|
-
* .select()
|
|
27
|
-
* .from(conversationsTable)
|
|
28
|
-
* .where(withWorkspaceFilter(conversationsTable.workspaceId, workspace.id));
|
|
2
|
+
* Workspace scoping for tables with a `workspaceId` column. Every query on
|
|
3
|
+
* such a table filters by the workspace resolved from `requireWorkspace()`.
|
|
4
|
+
* Organization, member and invitation rows go through the Better-Auth API,
|
|
5
|
+
* which scopes them to the caller's session.
|
|
29
6
|
*/
|
|
30
7
|
import { eq, and } from "drizzle-orm";
|
|
31
8
|
/**
|
|
32
9
|
* Creates a workspace-scoped WHERE condition for any table with a workspaceId column.
|
|
33
|
-
* Use
|
|
10
|
+
* Use it in every custom Drizzle query to enforce workspace isolation.
|
|
34
11
|
*
|
|
35
12
|
* @param workspaceIdColumn - The workspaceId column from the table schema
|
|
36
13
|
* @param workspaceId - The active workspace ID from requireWorkspace()
|
|
@@ -50,7 +27,6 @@ export function workspaceEq(workspaceIdColumn, workspaceId) {
|
|
|
50
27
|
}
|
|
51
28
|
/**
|
|
52
29
|
* Combines a workspace scope condition with additional WHERE conditions.
|
|
53
|
-
* Convenience helper to ensure workspaceId is always the first filter.
|
|
54
30
|
*
|
|
55
31
|
* @param workspaceIdColumn - The workspaceId column from the table schema
|
|
56
32
|
* @param workspaceId - The active workspace ID from requireWorkspace()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-queries.js","sourceRoot":"","sources":["../../src/db/workspace-queries.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"workspace-queries.js","sourceRoot":"","sources":["../../src/db/workspace-queries.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,EAAE,EAAE,GAAG,EAAY,MAAM,aAAa,CAAC;AAGhD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,WAAW,CACzB,iBAA2B,EAC3B,WAAmB;IAEnB,OAAO,EAAE,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,mBAAmB,CACjC,iBAA2B,EAC3B,WAAmB,EACnB,GAAG,oBAA2B;IAE9B,OAAO,GAAG,CAAC,EAAE,CAAC,iBAAiB,EAAE,WAAW,CAAC,EAAE,GAAG,oBAAoB,CAAE,CAAC;AAC3E,CAAC"}
|
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Document title classifier
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* document persistence API (./service.ts) uses the same registry to
|
|
6
|
-
* derive agent labels and the "report" filter. Kept in its own module
|
|
7
|
-
* with zero imports so client-safe code and tests can load it without
|
|
8
|
-
* dragging in the server-only persistence chain (db).
|
|
9
|
-
*
|
|
10
|
-
* Ported from @intelligo-dev/agents/documents/classifier (ADR-0009) —
|
|
11
|
-
* unchanged.
|
|
2
|
+
* Document title classifier. Products register their title patterns here;
|
|
3
|
+
* the documents service uses them to derive agent labels and the "report"
|
|
4
|
+
* filter. Kept free of the db import so client code and tests can load it.
|
|
12
5
|
*/
|
|
13
6
|
export type DocumentPatternEntry = {
|
|
14
7
|
/** Stable product slug — same one used across product configs. */
|
|
15
8
|
productSlug: string;
|
|
16
9
|
/** Human-readable agent label rendered in the documents UI. */
|
|
17
10
|
agentLabel: string;
|
|
18
|
-
/** Case-insensitive substring patterns; document matches
|
|
19
|
-
*
|
|
11
|
+
/** Case-insensitive substring patterns; a document matches when its
|
|
12
|
+
* title contains ANY of these, whatever the case of either. */
|
|
20
13
|
patterns: string[];
|
|
21
14
|
};
|
|
22
15
|
export declare function registerDocumentPatterns(entry: DocumentPatternEntry): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classifier.d.ts","sourceRoot":"","sources":["../../src/documents/classifier.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"classifier.d.ts","sourceRoot":"","sources":["../../src/documents/classifier.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,MAAM,oBAAoB,GAAG;IACjC,kEAAkE;IAClE,WAAW,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB;oEACgE;IAChE,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAUF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAE1E;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG;IACpD,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;CACpB,CAQA;AAED,sFAAsF;AACtF,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAKT;AAED,wBAAgB,8BAA8B,IAAI,SAAS,oBAAoB,EAAE,CAEhF;AAED,wBAAgB,4BAA4B,IAAI,IAAI,CAEnD"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Document title classifier
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* document persistence API (./service.ts) uses the same registry to
|
|
6
|
-
* derive agent labels and the "report" filter. Kept in its own module
|
|
7
|
-
* with zero imports so client-safe code and tests can load it without
|
|
8
|
-
* dragging in the server-only persistence chain (db).
|
|
9
|
-
*
|
|
10
|
-
* Ported from @intelligo-dev/agents/documents/classifier (ADR-0009) —
|
|
11
|
-
* unchanged.
|
|
2
|
+
* Document title classifier. Products register their title patterns here;
|
|
3
|
+
* the documents service uses them to derive agent labels and the "report"
|
|
4
|
+
* filter. Kept free of the db import so client code and tests can load it.
|
|
12
5
|
*/
|
|
13
|
-
|
|
6
|
+
import { createRegistry } from "../registry.js";
|
|
7
|
+
/**
|
|
8
|
+
* Keyed by product slug rather than appended, so a composition root that
|
|
9
|
+
* runs twice (or two copies of it) replaces the entry instead of matching
|
|
10
|
+
* the same patterns twice. Insertion order decides first-match
|
|
11
|
+
* classification.
|
|
12
|
+
*/
|
|
13
|
+
const registry = createRegistry("core/document-patterns");
|
|
14
14
|
export function registerDocumentPatterns(entry) {
|
|
15
|
-
registry.
|
|
15
|
+
registry.set(entry.productSlug, entry);
|
|
16
16
|
}
|
|
17
17
|
export function classifyDocumentTitle(title) {
|
|
18
18
|
const lower = title.toLowerCase();
|
|
19
|
-
for (const entry of registry) {
|
|
20
|
-
if (entry.patterns.some((p) => lower.includes(p))) {
|
|
19
|
+
for (const entry of registry.values()) {
|
|
20
|
+
if (entry.patterns.some((p) => lower.includes(p.toLowerCase()))) {
|
|
21
21
|
return { productSlug: entry.productSlug, agentLabel: entry.agentLabel };
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -33,9 +33,9 @@ export function isProductDocument(title, productSlug) {
|
|
|
33
33
|
return true;
|
|
34
34
|
}
|
|
35
35
|
export function listRegisteredDocumentPatterns() {
|
|
36
|
-
return registry;
|
|
36
|
+
return [...registry.values()];
|
|
37
37
|
}
|
|
38
38
|
export function clearDocumentPatternRegistry() {
|
|
39
|
-
registry.
|
|
39
|
+
registry.clear();
|
|
40
40
|
}
|
|
41
41
|
//# sourceMappingURL=classifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classifier.js","sourceRoot":"","sources":["../../src/documents/classifier.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"classifier.js","sourceRoot":"","sources":["../../src/documents/classifier.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc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
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Mirrors `@intelligo-dev/auth`'s `WorkspaceServiceError` exactly (see that
|
|
5
|
-
* file's doc comment for the full rationale): the documents service
|
|
6
|
-
* (./service.ts) throws this for every failure it recognizes rather
|
|
7
|
-
* than returning an ad-hoc `{ success, error }` envelope — that
|
|
8
|
-
* shaping is a transport concern (a Server Action, a route handler)
|
|
9
|
-
* and belongs one layer up, alongside revalidatePath/Sentry/i18n, none
|
|
10
|
-
* of which this package may depend on (core's dependency allowlist is
|
|
11
|
-
* empty — see tests/architecture/dependency-direction.test.ts).
|
|
2
|
+
* Thrown by the documents service for every failure it recognizes. Shaping
|
|
3
|
+
* it into a transport envelope is the caller's job.
|
|
12
4
|
*/
|
|
13
5
|
/**
|
|
14
6
|
* - `not_found` — no document (or no version of it) exists at the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/documents/errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/documents/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AACH,MAAM,MAAM,wBAAwB,GAClC,WAAW,GAAG,WAAW,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAEjE,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IAGxC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;gBAGvB,IAAI,EAAE,wBAAwB,EAC9B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAUhC;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,oBAAoB,CAE/B"}
|
package/dist/documents/errors.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Mirrors `@intelligo-dev/auth`'s `WorkspaceServiceError` exactly (see that
|
|
5
|
-
* file's doc comment for the full rationale): the documents service
|
|
6
|
-
* (./service.ts) throws this for every failure it recognizes rather
|
|
7
|
-
* than returning an ad-hoc `{ success, error }` envelope — that
|
|
8
|
-
* shaping is a transport concern (a Server Action, a route handler)
|
|
9
|
-
* and belongs one layer up, alongside revalidatePath/Sentry/i18n, none
|
|
10
|
-
* of which this package may depend on (core's dependency allowlist is
|
|
11
|
-
* empty — see tests/architecture/dependency-direction.test.ts).
|
|
2
|
+
* Thrown by the documents service for every failure it recognizes. Shaping
|
|
3
|
+
* it into a transport envelope is the caller's job.
|
|
12
4
|
*/
|
|
13
5
|
export class DocumentServiceError extends Error {
|
|
14
6
|
constructor(code, message, options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/documents/errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/documents/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAM7C,YACE,IAA8B,EAC9B,OAAe,EACf,OAA6B;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,OAAO,EAAE,KAAK,KAAK,SAAS,EAAE,CAAC;YAChC,IAA4B,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QACtD,CAAC;QACD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;CACF;AAED,MAAM,UAAU,sBAAsB,CACpC,KAAc;IAEd,OAAO,KAAK,YAAY,oBAAoB,CAAC;AAC/C,CAAC"}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* ownership and workspace/user access checks. See ./service.ts for
|
|
6
|
-
* the full module doc comment.
|
|
7
|
-
*
|
|
8
|
-
* Use via subpath import: @intelligo-dev/core/documents
|
|
9
|
-
*/
|
|
10
|
-
export { getUserDocuments, getDocument, saveDocument, deleteDocumentVersions, } from "./service";
|
|
11
|
-
export { DocumentServiceError, isDocumentServiceError, type DocumentServiceErrorCode, } from "./errors";
|
|
12
|
-
export type { DocumentActor, DocumentFilter, DocumentListItem } from "./types";
|
|
13
|
-
export { registerDocumentPatterns, classifyDocumentTitle, isProductDocument, listRegisteredDocumentPatterns, clearDocumentPatternRegistry, type DocumentPatternEntry, } from "./classifier";
|
|
1
|
+
export { getUserDocuments, getDocument, getDocumentVersions, saveDocument, deleteDocumentVersions, } from "./service.js";
|
|
2
|
+
export { DocumentServiceError, isDocumentServiceError, type DocumentServiceErrorCode, } from "./errors.js";
|
|
3
|
+
export type { DocumentActor, DocumentFilter, DocumentListItem } from "./types.js";
|
|
4
|
+
export { registerDocumentPatterns, classifyDocumentTitle, isProductDocument, listRegisteredDocumentPatterns, clearDocumentPatternRegistry, type DocumentPatternEntry, } from "./classifier.js";
|
|
14
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,sBAAsB,GACvB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,wBAAwB,GAC9B,MAAM,UAAU,CAAC;AAElB,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE/E,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,8BAA8B,EAC9B,4BAA4B,EAC5B,KAAK,oBAAoB,GAC1B,MAAM,cAAc,CAAC"}
|
package/dist/documents/index.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Document lifecycle: save, list, read, delete versions, plus
|
|
5
|
-
* ownership and workspace/user access checks. See ./service.ts for
|
|
6
|
-
* the full module doc comment.
|
|
7
|
-
*
|
|
8
|
-
* Use via subpath import: @intelligo-dev/core/documents
|
|
9
|
-
*/
|
|
10
|
-
export { getUserDocuments, getDocument, saveDocument, deleteDocumentVersions, } from "./service";
|
|
11
|
-
export { DocumentServiceError, isDocumentServiceError, } from "./errors";
|
|
12
|
-
export { registerDocumentPatterns, classifyDocumentTitle, isProductDocument, listRegisteredDocumentPatterns, clearDocumentPatternRegistry, } from "./classifier";
|
|
1
|
+
export { getUserDocuments, getDocument, getDocumentVersions, saveDocument, deleteDocumentVersions, } from "./service.js";
|
|
2
|
+
export { DocumentServiceError, isDocumentServiceError, } from "./errors.js";
|
|
3
|
+
export { registerDocumentPatterns, classifyDocumentTitle, isProductDocument, listRegisteredDocumentPatterns, clearDocumentPatternRegistry, } from "./classifier.js";
|
|
13
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,sBAAsB,GACvB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GAEvB,MAAM,UAAU,CAAC;AAIlB,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,8BAA8B,EAC9B,4BAA4B,GAE7B,MAAM,cAAc,CAAC"}
|
|
@@ -1,40 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Server-only persistence for AI-generated documents.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `document_types`) always lived in @intelligo-dev/core's schema, only the
|
|
8
|
-
* service layer sat in a dissolving package.
|
|
9
|
-
*
|
|
10
|
-
* Callers pass a resolved actor (workspaceId, userId) rather than this
|
|
11
|
-
* module resolving one itself — @intelligo-dev/core cannot depend on
|
|
12
|
-
* @intelligo-dev/auth (see tests/architecture/dependency-direction.test.ts),
|
|
13
|
-
* so `requireWorkspace()` moved to the caller. Every query still
|
|
14
|
-
* filters by workspaceId AND userId internally; the actor is never
|
|
15
|
-
* trusted to have done that itself.
|
|
16
|
-
*
|
|
17
|
-
* Failure is reported by throwing `DocumentServiceError` (a small,
|
|
18
|
-
* typed code set) rather than returning a `{ success, error }`
|
|
19
|
-
* envelope — that shaping, plus any error-reporting side effect
|
|
20
|
-
* (Sentry, logging), is a transport concern the caller applies at the
|
|
21
|
-
* Server Action / route boundary.
|
|
22
|
-
*
|
|
23
|
-
* This module is SERVER-ONLY. Do not import from client components.
|
|
4
|
+
* Callers pass a resolved actor (workspaceId, userId); core cannot depend on
|
|
5
|
+
* `@intelligo-dev/auth`. Every query filters by both ids — the caller is
|
|
6
|
+
* never trusted to have done it. Failures throw `DocumentServiceError`.
|
|
24
7
|
*/
|
|
25
|
-
import type { DocumentActor, DocumentFilter, DocumentListItem } from "./types";
|
|
8
|
+
import type { DocumentActor, DocumentFilter, DocumentListItem } from "./types.js";
|
|
26
9
|
/**
|
|
27
|
-
*
|
|
28
|
-
* first. Uses DISTINCT ON to get the latest version of each document.
|
|
10
|
+
* The latest version of each of the actor's documents, newest first.
|
|
29
11
|
*/
|
|
30
12
|
export declare function getUserDocuments(actor: DocumentActor, filter?: DocumentFilter): Promise<DocumentListItem[]>;
|
|
31
13
|
/**
|
|
32
|
-
*
|
|
14
|
+
* The latest version of one document, scoped to the actor.
|
|
33
15
|
* Throws DocumentServiceError("not_found") if no such document exists.
|
|
34
16
|
*/
|
|
35
17
|
export declare function getDocument(actor: DocumentActor, id: string): Promise<DocumentListItem>;
|
|
36
18
|
/**
|
|
37
|
-
*
|
|
19
|
+
* Every version of a document, newest first — what a canvas version
|
|
20
|
+
* picker walks. Throws ("not_found") when the actor has no such id.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getDocumentVersions(actor: DocumentActor, id: string): Promise<DocumentListItem[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Saves a document as a new version.
|
|
38
25
|
* Throws DocumentServiceError("forbidden") if a document with this id
|
|
39
26
|
* already exists in the workspace under a different user.
|
|
40
27
|
*/
|
|
@@ -43,6 +30,12 @@ export declare function saveDocument(actor: DocumentActor, params: {
|
|
|
43
30
|
title: string;
|
|
44
31
|
content: string;
|
|
45
32
|
kind: string;
|
|
33
|
+
/**
|
|
34
|
+
* The conversation this was written in, stored on `metadata` so
|
|
35
|
+
* the artifacts page can link back to it. Optional: a document
|
|
36
|
+
* saved by a job or an import belongs to no conversation.
|
|
37
|
+
*/
|
|
38
|
+
conversationId?: string;
|
|
46
39
|
}): Promise<DocumentListItem>;
|
|
47
40
|
/**
|
|
48
41
|
* Delete all versions of a document created after `timestamp`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/documents/service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/documents/service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAkC/E;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,aAAa,EACpB,MAAM,CAAC,EAAE,cAAc,GACtB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAuB7B;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,aAAa,EACpB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,gBAAgB,CAAC,CAkB3B;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,aAAa,EACpB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAiB7B;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE;IACN,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GACA,OAAO,CAAC,gBAAgB,CAAC,CA+C3B;AAID;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,aAAa,EACpB,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA4C7B"}
|
|
@@ -1,32 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Server-only persistence for AI-generated documents.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `document_types`) always lived in @intelligo-dev/core's schema, only the
|
|
8
|
-
* service layer sat in a dissolving package.
|
|
9
|
-
*
|
|
10
|
-
* Callers pass a resolved actor (workspaceId, userId) rather than this
|
|
11
|
-
* module resolving one itself — @intelligo-dev/core cannot depend on
|
|
12
|
-
* @intelligo-dev/auth (see tests/architecture/dependency-direction.test.ts),
|
|
13
|
-
* so `requireWorkspace()` moved to the caller. Every query still
|
|
14
|
-
* filters by workspaceId AND userId internally; the actor is never
|
|
15
|
-
* trusted to have done that itself.
|
|
16
|
-
*
|
|
17
|
-
* Failure is reported by throwing `DocumentServiceError` (a small,
|
|
18
|
-
* typed code set) rather than returning a `{ success, error }`
|
|
19
|
-
* envelope — that shaping, plus any error-reporting side effect
|
|
20
|
-
* (Sentry, logging), is a transport concern the caller applies at the
|
|
21
|
-
* Server Action / route boundary.
|
|
22
|
-
*
|
|
23
|
-
* This module is SERVER-ONLY. Do not import from client components.
|
|
4
|
+
* Callers pass a resolved actor (workspaceId, userId); core cannot depend on
|
|
5
|
+
* `@intelligo-dev/auth`. Every query filters by both ids — the caller is
|
|
6
|
+
* never trusted to have done it. Failures throw `DocumentServiceError`.
|
|
24
7
|
*/
|
|
25
8
|
import { and, desc, eq, gt } from "drizzle-orm";
|
|
26
|
-
import { db } from "../db";
|
|
27
|
-
import { documents } from "../db/schema";
|
|
28
|
-
import { classifyDocumentTitle, isProductDocument } from "./classifier";
|
|
29
|
-
import { DocumentServiceError } from "./errors";
|
|
9
|
+
import { db } from "../db/index.js";
|
|
10
|
+
import { documents } from "../db/schema/index.js";
|
|
11
|
+
import { classifyDocumentTitle, isProductDocument } from "./classifier.js";
|
|
12
|
+
import { DocumentServiceError } from "./errors.js";
|
|
13
|
+
/**
|
|
14
|
+
* `metadata` is untyped `jsonb` written by whoever saved the document,
|
|
15
|
+
* so it is read defensively: anything that is not a non-empty string
|
|
16
|
+
* is no link at all.
|
|
17
|
+
*/
|
|
18
|
+
function conversationIdOf(metadata) {
|
|
19
|
+
if (!metadata || typeof metadata !== "object")
|
|
20
|
+
return null;
|
|
21
|
+
const value = metadata.conversationId;
|
|
22
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
23
|
+
}
|
|
30
24
|
function toListItem(doc) {
|
|
31
25
|
return {
|
|
32
26
|
id: doc.id,
|
|
@@ -35,14 +29,11 @@ function toListItem(doc) {
|
|
|
35
29
|
createdAt: doc.createdAt.toISOString(),
|
|
36
30
|
agentLabel: classifyDocumentTitle(doc.title).agentLabel,
|
|
37
31
|
content: doc.content,
|
|
32
|
+
conversationId: conversationIdOf(doc.metadata),
|
|
38
33
|
};
|
|
39
34
|
}
|
|
40
|
-
// ---------------------------------------------------------------------------
|
|
41
|
-
// Query Operations
|
|
42
|
-
// ---------------------------------------------------------------------------
|
|
43
35
|
/**
|
|
44
|
-
*
|
|
45
|
-
* first. Uses DISTINCT ON to get the latest version of each document.
|
|
36
|
+
* The latest version of each of the actor's documents, newest first.
|
|
46
37
|
*/
|
|
47
38
|
export async function getUserDocuments(actor, filter) {
|
|
48
39
|
const uniqueDocs = await db
|
|
@@ -61,7 +52,7 @@ export async function getUserDocuments(actor, filter) {
|
|
|
61
52
|
return result;
|
|
62
53
|
}
|
|
63
54
|
/**
|
|
64
|
-
*
|
|
55
|
+
* The latest version of one document, scoped to the actor.
|
|
65
56
|
* Throws DocumentServiceError("not_found") if no such document exists.
|
|
66
57
|
*/
|
|
67
58
|
export async function getDocument(actor, id) {
|
|
@@ -75,11 +66,23 @@ export async function getDocument(actor, id) {
|
|
|
75
66
|
}
|
|
76
67
|
return toListItem(doc);
|
|
77
68
|
}
|
|
78
|
-
// ---------------------------------------------------------------------------
|
|
79
|
-
// Mutation Operations
|
|
80
|
-
// ---------------------------------------------------------------------------
|
|
81
69
|
/**
|
|
82
|
-
*
|
|
70
|
+
* Every version of a document, newest first — what a canvas version
|
|
71
|
+
* picker walks. Throws ("not_found") when the actor has no such id.
|
|
72
|
+
*/
|
|
73
|
+
export async function getDocumentVersions(actor, id) {
|
|
74
|
+
const rows = await db
|
|
75
|
+
.select()
|
|
76
|
+
.from(documents)
|
|
77
|
+
.where(and(eq(documents.id, id), eq(documents.workspaceId, actor.workspaceId), eq(documents.userId, actor.userId)))
|
|
78
|
+
.orderBy(desc(documents.createdAt));
|
|
79
|
+
if (rows.length === 0) {
|
|
80
|
+
throw new DocumentServiceError("not_found", "Document not found");
|
|
81
|
+
}
|
|
82
|
+
return rows.map(toListItem);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Saves a document as a new version.
|
|
83
86
|
* Throws DocumentServiceError("forbidden") if a document with this id
|
|
84
87
|
* already exists in the workspace under a different user.
|
|
85
88
|
*/
|
|
@@ -94,6 +97,11 @@ export async function saveDocument(actor, params) {
|
|
|
94
97
|
throw new DocumentServiceError("forbidden", "Document belongs to a different user");
|
|
95
98
|
}
|
|
96
99
|
}
|
|
100
|
+
// Every save writes a new version row, so an edit that does not resend
|
|
101
|
+
// the conversation link would drop it. Carry the known one forward.
|
|
102
|
+
const conversationId = params.conversationId ??
|
|
103
|
+
existingDocs.map((doc) => conversationIdOf(doc.metadata)).find(Boolean) ??
|
|
104
|
+
null;
|
|
97
105
|
const [newDocument] = await db
|
|
98
106
|
.insert(documents)
|
|
99
107
|
.values({
|
|
@@ -104,6 +112,7 @@ export async function saveDocument(actor, params) {
|
|
|
104
112
|
content: params.content,
|
|
105
113
|
kind: params.kind,
|
|
106
114
|
createdAt: new Date(),
|
|
115
|
+
metadata: conversationId ? { conversationId } : null,
|
|
107
116
|
})
|
|
108
117
|
.returning();
|
|
109
118
|
if (!newDocument) {
|
|
@@ -111,9 +120,6 @@ export async function saveDocument(actor, params) {
|
|
|
111
120
|
}
|
|
112
121
|
return toListItem(newDocument);
|
|
113
122
|
}
|
|
114
|
-
// ---------------------------------------------------------------------------
|
|
115
|
-
// Delete Operations
|
|
116
|
-
// ---------------------------------------------------------------------------
|
|
117
123
|
const MAX_DELETE_WINDOW_DAYS = 30;
|
|
118
124
|
/**
|
|
119
125
|
* Delete all versions of a document created after `timestamp`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/documents/service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/documents/service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,GAA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