@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/env.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* Fail-fast approach: missing critical env vars throw immediately
|
|
6
|
-
* rather than failing at runtime when the feature is first used.
|
|
7
|
-
*
|
|
8
|
-
* Usage: Import and call validateEnv() in app layout or middleware.
|
|
9
|
-
* Note: Some vars are optional for local dev (STRIPE_*, RESEND_API_KEY).
|
|
2
|
+
* Startup validation of environment variables: a missing required variable
|
|
3
|
+
* throws immediately instead of when its feature is first used. Some are
|
|
4
|
+
* optional in development (STRIPE_*, RESEND_API_KEY).
|
|
10
5
|
*/
|
|
6
|
+
// Only variables the framework itself reads. A model provider's key is
|
|
7
|
+
// absent on purpose: which provider a deployment calls is the product's
|
|
8
|
+
// choice, and its SDK reports a missing key on the first request.
|
|
11
9
|
const ENV_VARS = [
|
|
12
10
|
{
|
|
13
11
|
name: "DATABASE_URL",
|
|
@@ -15,9 +13,9 @@ const ENV_VARS = [
|
|
|
15
13
|
description: "PostgreSQL connection string",
|
|
16
14
|
},
|
|
17
15
|
{
|
|
18
|
-
name: "
|
|
16
|
+
name: "BETTER_AUTH_SECRET",
|
|
19
17
|
required: true,
|
|
20
|
-
description: "Better-Auth session encryption key",
|
|
18
|
+
description: "Better-Auth session encryption key (AUTH_SECRET is accepted as a legacy alias)",
|
|
21
19
|
minLength: 32,
|
|
22
20
|
},
|
|
23
21
|
{
|
|
@@ -25,11 +23,6 @@ const ENV_VARS = [
|
|
|
25
23
|
required: true,
|
|
26
24
|
description: "Application base URL for auth and redirects",
|
|
27
25
|
},
|
|
28
|
-
{
|
|
29
|
-
name: "OPENAI_API_KEY",
|
|
30
|
-
required: false,
|
|
31
|
-
description: "OpenAI API key (AI chat features)",
|
|
32
|
-
},
|
|
33
26
|
{
|
|
34
27
|
name: "STRIPE_SECRET_KEY",
|
|
35
28
|
required: false,
|
|
@@ -40,11 +33,6 @@ const ENV_VARS = [
|
|
|
40
33
|
required: false,
|
|
41
34
|
description: "Stripe webhook signature secret",
|
|
42
35
|
},
|
|
43
|
-
{
|
|
44
|
-
name: "NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY",
|
|
45
|
-
required: false,
|
|
46
|
-
description: "Stripe publishable key (billing UI)",
|
|
47
|
-
},
|
|
48
36
|
{
|
|
49
37
|
name: "RESEND_API_KEY",
|
|
50
38
|
required: false,
|
|
@@ -60,10 +48,8 @@ const ENV_VARS = [
|
|
|
60
48
|
required: false,
|
|
61
49
|
description: "Explicit email provider selection (resend | loops | console)",
|
|
62
50
|
},
|
|
63
|
-
// Cron endpoints
|
|
64
|
-
//
|
|
65
|
-
// local cron testing isn't blocked, but production MUST set it
|
|
66
|
-
// and the value must be at least 32 chars to resist guessing.
|
|
51
|
+
// Cron endpoints gate on a Bearer header equal to CRON_SECRET. Optional
|
|
52
|
+
// in development; production should set at least 32 characters.
|
|
67
53
|
{
|
|
68
54
|
name: "CRON_SECRET",
|
|
69
55
|
required: false,
|
|
@@ -75,7 +61,15 @@ export function validateEnv() {
|
|
|
75
61
|
const errors = [];
|
|
76
62
|
const warnings = [];
|
|
77
63
|
for (const envVar of ENV_VARS) {
|
|
78
|
-
|
|
64
|
+
let value = process.env[envVar.name];
|
|
65
|
+
// Better-Auth reads BETTER_AUTH_SECRET then AUTH_SECRET; the CLI, the
|
|
66
|
+
// scaffold and this validator use the former.
|
|
67
|
+
if (envVar.name === "BETTER_AUTH_SECRET" &&
|
|
68
|
+
!value &&
|
|
69
|
+
process.env.AUTH_SECRET) {
|
|
70
|
+
value = process.env.AUTH_SECRET;
|
|
71
|
+
warnings.push("AUTH_SECRET is set but BETTER_AUTH_SECRET is not — rename it; AUTH_SECRET is a legacy alias");
|
|
72
|
+
}
|
|
79
73
|
if (!value || value.trim() === "") {
|
|
80
74
|
if (envVar.required) {
|
|
81
75
|
errors.push(`Missing required env var: ${envVar.name} — ${envVar.description}`);
|
|
@@ -95,23 +89,39 @@ export function validateEnv() {
|
|
|
95
89
|
}
|
|
96
90
|
}
|
|
97
91
|
}
|
|
92
|
+
// Resend rejects a send without a sender on a verified domain, and the
|
|
93
|
+
// framework has no domain of its own to fall back on. Loops takes the
|
|
94
|
+
// sender from each template, so only Resend is checked.
|
|
95
|
+
const emailProvider = process.env.EMAIL_PROVIDER?.toLowerCase();
|
|
96
|
+
const sendsThroughResend = Boolean(process.env.RESEND_API_KEY?.trim()) &&
|
|
97
|
+
emailProvider !== "loops" &&
|
|
98
|
+
emailProvider !== "console";
|
|
99
|
+
if (sendsThroughResend && !process.env.EMAIL_FROM?.trim()) {
|
|
100
|
+
warnings.push('RESEND_API_KEY is set but EMAIL_FROM is not — every email fails until EMAIL_FROM names a sender on a domain verified with Resend, e.g. "Acme <noreply@acme.com>"');
|
|
101
|
+
}
|
|
98
102
|
// Production safety checks
|
|
99
103
|
if (process.env.NODE_ENV === "production") {
|
|
104
|
+
const appUrl = process.env.NEXT_PUBLIC_APP_URL?.trim();
|
|
105
|
+
if (appUrl && !appUrl.startsWith("https://")) {
|
|
106
|
+
warnings.push(`NEXT_PUBLIC_APP_URL is ${appUrl}, not an https URL — auth callbacks, email links and secure cookies are built from it`);
|
|
107
|
+
}
|
|
108
|
+
if (!process.env.RESEND_API_KEY && !process.env.LOOPS_API_KEY) {
|
|
109
|
+
warnings.push("No email provider (RESEND_API_KEY or LOOPS_API_KEY) — sign-ups are not email-verified and emails only reach the server console");
|
|
110
|
+
}
|
|
100
111
|
if (process.env.STRIPE_SECRET_KEY?.startsWith("sk_test_")) {
|
|
101
112
|
warnings.push("STRIPE_SECRET_KEY is a test key in production environment");
|
|
102
113
|
}
|
|
103
114
|
if (!process.env.CRON_SECRET || process.env.CRON_SECRET.length < 32) {
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
errors.push("CRON_SECRET must be set (≥32 chars) in production for /api/cron/* auth");
|
|
115
|
+
// A warning, not an error: the framework ships no cron route of its
|
|
116
|
+
// own, and the maintenance route refuses to serve without it.
|
|
117
|
+
warnings.push("CRON_SECRET unset or shorter than 32 chars — required by any /api/cron/* route you mount");
|
|
108
118
|
}
|
|
109
119
|
}
|
|
110
120
|
return { valid: errors.length === 0, errors, warnings };
|
|
111
121
|
}
|
|
112
122
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
123
|
+
* Call during app initialization. Throws on missing required variables;
|
|
124
|
+
* logs warnings for optional ones.
|
|
115
125
|
*/
|
|
116
126
|
export function assertEnv() {
|
|
117
127
|
const { valid, errors, warnings } = validateEnv();
|
package/dist/env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,uEAAuE;AACvE,wEAAwE;AACxE,kEAAkE;AAClE,MAAM,QAAQ,GAAa;IACzB;QACE,IAAI,EAAE,cAAc;QACpB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,8BAA8B;KAC5C;IACD;QACE,IAAI,EAAE,oBAAoB;QAC1B,QAAQ,EAAE,IAAI;QACd,WAAW,EACT,gFAAgF;QAClF,SAAS,EAAE,EAAE;KACd;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,6CAA6C;KAC3D;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,mCAAmC;KACjD;IACD;QACE,IA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ity/audit.d.ts
CHANGED
|
@@ -1,28 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* destination. `tests/architecture/dependency-direction.test.ts` only
|
|
7
|
-
* grants the audit -> core edge (`audit: ["@intelligo-dev/core"]`);
|
|
8
|
-
* `@intelligo-dev/core`'s own allowlist entry is empty
|
|
9
|
-
* (`core: []` — see `../documents/service.ts`'s doc comment for the
|
|
10
|
-
* same constraint against `@intelligo-dev/auth`). This module — part of
|
|
11
|
-
* `@intelligo-dev/core/identity`, which owns `user_memory_audit` alongside
|
|
12
|
-
* the rest of the identity graph (see `../db/schema/identity.ts`) —
|
|
13
|
-
* therefore cannot import `@intelligo-dev/audit` to call a writer defined
|
|
14
|
-
* there.
|
|
15
|
-
*
|
|
16
|
-
* `@intelligo-dev/audit` exports the event *contract* only
|
|
17
|
-
* (`packages/audit/src/memory-audit.ts`, re-exported from its index).
|
|
18
|
-
* This file is the faithful, in-package port of the write itself,
|
|
19
|
-
* ported verbatim from `@intelligo-dev/agents/memory/audit.ts` (ADR-0008),
|
|
20
|
-
* kept local so `./service.ts`'s mutations (`deleteFact`,
|
|
21
|
-
* `exportIdentity`) never cross the disallowed core -> audit edge.
|
|
22
|
-
* Not re-exported from `./index.ts`: it is this module's own
|
|
23
|
-
* implementation detail, not identity's public API.
|
|
2
|
+
* Writes `user_memory_audit` rows. Core may not import
|
|
3
|
+
* `@intelligo-dev/audit` (only audit -> core is allowed), so the write lives
|
|
4
|
+
* here and audit exports only the event contract. Internal to identity; not
|
|
5
|
+
* re-exported.
|
|
24
6
|
*/
|
|
25
|
-
import
|
|
7
|
+
import { db } from "../db/index.js";
|
|
8
|
+
import type { AuditTargetKind, AuditAction, AuditActorKind, UserMemoryAuditRow } from "../db/schema/index.js";
|
|
26
9
|
export type RecordMemoryAuditInput = {
|
|
27
10
|
userId: string;
|
|
28
11
|
workspaceId: string;
|
|
@@ -35,5 +18,9 @@ export type RecordMemoryAuditInput = {
|
|
|
35
18
|
afterValue?: unknown;
|
|
36
19
|
reason?: string;
|
|
37
20
|
};
|
|
38
|
-
|
|
21
|
+
/**
|
|
22
|
+
* `writer` is the transaction of the mutation being audited, so the
|
|
23
|
+
* change and its record commit or fail together.
|
|
24
|
+
*/
|
|
25
|
+
export declare function recordMemoryAudit(input: RecordMemoryAuditInput, writer?: Pick<typeof db, "insert">): Promise<UserMemoryAuditRow>;
|
|
39
26
|
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/identity/audit.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/identity/audit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAE3B,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,cAAc,EACd,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAGtB,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,eAAe,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,cAAc,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,sBAAsB,EAC7B,MAAM,GAAE,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAM,GACrC,OAAO,CAAC,kBAAkB,CAAC,CA2B7B"}
|
package/dist/identity/audit.js
CHANGED
|
@@ -1,32 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* destination. `tests/architecture/dependency-direction.test.ts` only
|
|
7
|
-
* grants the audit -> core edge (`audit: ["@intelligo-dev/core"]`);
|
|
8
|
-
* `@intelligo-dev/core`'s own allowlist entry is empty
|
|
9
|
-
* (`core: []` — see `../documents/service.ts`'s doc comment for the
|
|
10
|
-
* same constraint against `@intelligo-dev/auth`). This module — part of
|
|
11
|
-
* `@intelligo-dev/core/identity`, which owns `user_memory_audit` alongside
|
|
12
|
-
* the rest of the identity graph (see `../db/schema/identity.ts`) —
|
|
13
|
-
* therefore cannot import `@intelligo-dev/audit` to call a writer defined
|
|
14
|
-
* there.
|
|
15
|
-
*
|
|
16
|
-
* `@intelligo-dev/audit` exports the event *contract* only
|
|
17
|
-
* (`packages/audit/src/memory-audit.ts`, re-exported from its index).
|
|
18
|
-
* This file is the faithful, in-package port of the write itself,
|
|
19
|
-
* ported verbatim from `@intelligo-dev/agents/memory/audit.ts` (ADR-0008),
|
|
20
|
-
* kept local so `./service.ts`'s mutations (`deleteFact`,
|
|
21
|
-
* `exportIdentity`) never cross the disallowed core -> audit edge.
|
|
22
|
-
* Not re-exported from `./index.ts`: it is this module's own
|
|
23
|
-
* implementation detail, not identity's public API.
|
|
2
|
+
* Writes `user_memory_audit` rows. Core may not import
|
|
3
|
+
* `@intelligo-dev/audit` (only audit -> core is allowed), so the write lives
|
|
4
|
+
* here and audit exports only the event contract. Internal to identity; not
|
|
5
|
+
* re-exported.
|
|
24
6
|
*/
|
|
25
|
-
import { db } from "../db";
|
|
26
|
-
import { userMemoryAudit } from "../db/schema";
|
|
27
|
-
import { IdentityServiceError } from "./errors";
|
|
28
|
-
|
|
29
|
-
|
|
7
|
+
import { db } from "../db/index.js";
|
|
8
|
+
import { userMemoryAudit } from "../db/schema/index.js";
|
|
9
|
+
import { IdentityServiceError } from "./errors.js";
|
|
10
|
+
/**
|
|
11
|
+
* `writer` is the transaction of the mutation being audited, so the
|
|
12
|
+
* change and its record commit or fail together.
|
|
13
|
+
*/
|
|
14
|
+
export async function recordMemoryAudit(input, writer = db) {
|
|
15
|
+
const [row] = await writer
|
|
30
16
|
.insert(userMemoryAudit)
|
|
31
17
|
.values({
|
|
32
18
|
id: crypto.randomUUID(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/identity/audit.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/identity/audit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAO/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAehD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,KAA6B,EAC7B,SAAoC,EAAE;IAEtC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,MAAM;SACvB,MAAM,CAAC,eAAe,CAAC;SACvB,MAAM,CAAC;QACN,EAAE,EAAE,MAAM,CAAC,UAAU,EAAE;QACvB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,SAAS,EAAE,IAAI,IAAI,EAAE;KACtB,CAAC;SACD,SAAS,EAAE,CAAC;IAEf,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,oBAAoB,CAC5B,gBAAgB,EAChB,qCAAqC,CACtC,CAAC;IACJ,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Mirrors `../documents/errors.ts` and `../conversations/errors.ts`
|
|
5
|
-
* exactly (see either's doc comment for the full rationale): the
|
|
6
|
-
* identity service (./service.ts) throws this for every failure it
|
|
7
|
-
* recognizes rather than returning an ad-hoc `{ success, error }`
|
|
8
|
-
* envelope. Shaping to a transport-facing envelope (plus
|
|
9
|
-
* Sentry/logging/revalidatePath) is the caller's job, one layer up.
|
|
2
|
+
* Thrown by the identity service for every failure it recognizes. Shaping
|
|
3
|
+
* it into a transport envelope is the caller's job.
|
|
10
4
|
*/
|
|
11
5
|
/**
|
|
12
6
|
* - `not_found` — no fact exists at the given id within the actor's
|
|
13
7
|
* workspace/user scope. Covers both "no such fact" and "a fact that
|
|
14
|
-
* belongs to a different user in the same workspace" —
|
|
15
|
-
*
|
|
16
|
-
* `../conversations/service.ts`'s `verifyConversation`: an id alone
|
|
17
|
-
* should never reveal whose data exists behind it).
|
|
8
|
+
* belongs to a different user in the same workspace" — deliberately
|
|
9
|
+
* indistinguishable, so an id never reveals whose data exists behind it.
|
|
18
10
|
* - `invalid_input` — a caller-supplied argument failed a basic
|
|
19
11
|
* invariant (e.g. an empty fact id).
|
|
20
12
|
* - `database_error` — the underlying insert did not return the row it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/identity/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/identity/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AACH,MAAM,MAAM,wBAAwB,GAClC,WAAW,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAEnD,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/identity/errors.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Mirrors `../documents/errors.ts` and `../conversations/errors.ts`
|
|
5
|
-
* exactly (see either's doc comment for the full rationale): the
|
|
6
|
-
* identity service (./service.ts) throws this for every failure it
|
|
7
|
-
* recognizes rather than returning an ad-hoc `{ success, error }`
|
|
8
|
-
* envelope. Shaping to a transport-facing envelope (plus
|
|
9
|
-
* Sentry/logging/revalidatePath) is the caller's job, one layer up.
|
|
2
|
+
* Thrown by the identity service for every failure it recognizes. Shaping
|
|
3
|
+
* it into a transport envelope is the caller's job.
|
|
10
4
|
*/
|
|
11
5
|
export class IdentityServiceError extends Error {
|
|
12
6
|
constructor(code, message, options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/identity/errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/identity/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"}
|
package/dist/identity/index.d.ts
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* fact listing/deletion, full-identity export, and the memory-audit
|
|
6
|
-
* trail. See ./service.ts for the full module doc comment, including
|
|
7
|
-
* what stayed agents-side (profile re-synthesis) and why the
|
|
8
|
-
* memory-audit writer lives in this module rather than in
|
|
9
|
-
* `@intelligo-dev/audit`.
|
|
10
|
-
*
|
|
11
|
-
* Use via subpath import: @intelligo-dev/core/identity
|
|
2
|
+
* Privacy-facing reads and mutations over the user identity graph: fact
|
|
3
|
+
* listing and deletion, the profile snapshot's write, full-identity
|
|
4
|
+
* export, and the memory-audit trail.
|
|
12
5
|
*/
|
|
13
|
-
export { listFacts, deleteFact, exportIdentity, getAuditTrail, } from "./service";
|
|
14
|
-
export { IdentityServiceError, isIdentityServiceError, type IdentityServiceErrorCode, } from "./errors";
|
|
15
|
-
export type { IdentityActor, IdentityExport, UserFact, UserMemory, UserProfileSnapshot, UserMemoryAuditRow, } from "./types";
|
|
6
|
+
export { listFacts, deleteFact, saveProfileSnapshot, exportIdentity, getAuditTrail, } from "./service.js";
|
|
7
|
+
export { IdentityServiceError, isIdentityServiceError, type IdentityServiceErrorCode, } from "./errors.js";
|
|
8
|
+
export type { IdentityActor, IdentityExport, SaveProfileSnapshotInput, UserFact, UserMemory, UserProfileSnapshot, UserMemoryAuditRow, } from "./types.js";
|
|
16
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,cAAc,EACd,aAAa,GACd,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,wBAAwB,GAC9B,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,SAAS,CAAC"}
|
package/dist/identity/index.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* fact listing/deletion, full-identity export, and the memory-audit
|
|
6
|
-
* trail. See ./service.ts for the full module doc comment, including
|
|
7
|
-
* what stayed agents-side (profile re-synthesis) and why the
|
|
8
|
-
* memory-audit writer lives in this module rather than in
|
|
9
|
-
* `@intelligo-dev/audit`.
|
|
10
|
-
*
|
|
11
|
-
* Use via subpath import: @intelligo-dev/core/identity
|
|
2
|
+
* Privacy-facing reads and mutations over the user identity graph: fact
|
|
3
|
+
* listing and deletion, the profile snapshot's write, full-identity
|
|
4
|
+
* export, and the memory-audit trail.
|
|
12
5
|
*/
|
|
13
|
-
export { listFacts, deleteFact, exportIdentity, getAuditTrail, } from "./service";
|
|
14
|
-
export { IdentityServiceError, isIdentityServiceError, } from "./errors";
|
|
6
|
+
export { listFacts, deleteFact, saveProfileSnapshot, exportIdentity, getAuditTrail, } from "./service.js";
|
|
7
|
+
export { IdentityServiceError, isIdentityServiceError, } from "./errors.js";
|
|
15
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,cAAc,EACd,aAAa,GACd,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GAEvB,MAAM,UAAU,CAAC"}
|
|
@@ -1,48 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Server-only reads and mutations over the user identity graph: fact
|
|
3
|
+
* listing and deletion, the profile snapshot's write, a full data export,
|
|
4
|
+
* and the memory-audit trail.
|
|
3
5
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* memories, and synthesized profile snapshot. Ported from Ignite's
|
|
8
|
-
* `actions/identity.ts` (ADR-0008/ADR-0009 precedent — see
|
|
9
|
-
* `../documents/service.ts` and `../conversations/service.ts` for the
|
|
10
|
-
* same move): the tables (`user_facts`, `user_memories`,
|
|
11
|
-
* `user_profile_snapshots`, `user_memory_audit`) always lived in
|
|
12
|
-
* `@intelligo-dev/core`'s schema (`../db/schema/identity.ts`, documented
|
|
13
|
-
* there as "a platform-level memory primitive — separate from any
|
|
14
|
-
* single product"); only the service layer sat in the product
|
|
15
|
-
* application.
|
|
6
|
+
* `deleteFact` does not touch the cached profile snapshot; profile synthesis
|
|
7
|
+
* is the product's AI code, so a caller that owns it re-triggers it and
|
|
8
|
+
* stores the result with `saveProfileSnapshot`.
|
|
16
9
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* `@intelligo-dev/agents`' concern (deprecated, dissolving under
|
|
21
|
-
* ADR-0008), and this package cannot depend on it. `deleteFact`
|
|
22
|
-
* below does not touch the cached snapshot; a caller that also
|
|
23
|
-
* owns a synthesis engine re-triggers it after calling this.
|
|
24
|
-
*
|
|
25
|
-
* Callers pass a resolved actor (workspaceId, userId) rather than this
|
|
26
|
-
* module resolving one itself — `@intelligo-dev/core` cannot depend on
|
|
27
|
-
* `@intelligo-dev/auth` (see tests/architecture/dependency-direction.test.ts).
|
|
28
|
-
* Every query filters by workspaceId AND userId internally; the actor
|
|
29
|
-
* is never trusted to have done that itself.
|
|
30
|
-
*
|
|
31
|
-
* Every mutation writes a `user_memory_audit` row via the internal
|
|
32
|
-
* `recordMemoryAudit` (./audit.ts). See that file's doc comment for
|
|
33
|
-
* why the writer lives here rather than in `@intelligo-dev/audit`, which
|
|
34
|
-
* is where ADR-0008 names its destination — the allowlist only grants
|
|
35
|
-
* audit -> core, never core -> audit
|
|
36
|
-
* (tests/architecture/dependency-direction.test.ts), so
|
|
37
|
-
* `@intelligo-dev/audit` exports the event *contract* only.
|
|
38
|
-
*
|
|
39
|
-
* Failure is reported by throwing `IdentityServiceError` rather than
|
|
40
|
-
* returning a `{ success, error }` envelope — see ./errors.ts.
|
|
41
|
-
*
|
|
42
|
-
* This module is SERVER-ONLY. Do not import from client components.
|
|
10
|
+
* Callers pass a resolved actor (workspaceId, userId); core cannot depend on
|
|
11
|
+
* `@intelligo-dev/auth`. Every query filters by both ids. Every mutation
|
|
12
|
+
* writes a `user_memory_audit` row. Failures throw `IdentityServiceError`.
|
|
43
13
|
*/
|
|
44
|
-
import type { UserFact, UserMemoryAuditRow } from "../db/schema";
|
|
45
|
-
import type { IdentityActor, IdentityExport } from "./types";
|
|
14
|
+
import type { UserFact, UserMemoryAuditRow, UserProfileSnapshot } from "../db/schema/index.js";
|
|
15
|
+
import type { IdentityActor, IdentityExport, SaveProfileSnapshotInput } from "./types.js";
|
|
46
16
|
/** List the actor's facts, most important and most confident first. */
|
|
47
17
|
export declare function listFacts(actor: IdentityActor): Promise<UserFact[]>;
|
|
48
18
|
/**
|
|
@@ -56,15 +26,27 @@ export declare function getAuditTrail(actor: IdentityActor, options?: {
|
|
|
56
26
|
/**
|
|
57
27
|
* Delete a fact and record the deletion in the audit trail. Throws
|
|
58
28
|
* `invalid_input` for an empty id and `not_found` for anything outside
|
|
59
|
-
* the actor's scope
|
|
60
|
-
* synthesis — see the module doc comment.
|
|
29
|
+
* the actor's scope. Does not re-trigger profile synthesis.
|
|
61
30
|
*/
|
|
62
31
|
export declare function deleteFact(actor: IdentityActor, factId: string): Promise<void>;
|
|
63
32
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* audits itself, same as the ported Ignite implementation.
|
|
33
|
+
* The actor's full identity graph — facts, memories, latest profile
|
|
34
|
+
* snapshot and audit trail — for a "download my data" flow. Records its own
|
|
35
|
+
* audit row (action "export").
|
|
68
36
|
*/
|
|
69
37
|
export declare function exportIdentity(actor: IdentityActor): Promise<IdentityExport>;
|
|
38
|
+
/**
|
|
39
|
+
* Store the actor's synthesized profile — one row per user per workspace,
|
|
40
|
+
* inserted on the first synthesis and replaced on every later one. The
|
|
41
|
+
* version is bumped in the same statement (`ON CONFLICT … version + 1`),
|
|
42
|
+
* so two syntheses racing each other get two versions rather than one
|
|
43
|
+
* overwriting the other's number; it starts at 1.
|
|
44
|
+
*
|
|
45
|
+
* A field left `undefined` keeps what the row holds (null on insert); an
|
|
46
|
+
* explicit `null` clears it. `synthesizedAt` defaults to now. Records an
|
|
47
|
+
* audit row (`snapshot`, `create` or `update`) in the same transaction,
|
|
48
|
+
* attributed to `input.actorKind` — `system_job` unless the caller says
|
|
49
|
+
* otherwise. Throws `invalid_input` for an empty summary.
|
|
50
|
+
*/
|
|
51
|
+
export declare function saveProfileSnapshot(actor: IdentityActor, input: SaveProfileSnapshotInput): Promise<UserProfileSnapshot>;
|
|
70
52
|
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/identity/service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/identity/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAUH,OAAO,KAAK,EACV,QAAQ,EACR,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,wBAAwB,EACzB,MAAM,SAAS,CAAC;AA4BjB,uEAAuE;AACvE,wBAAsB,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAWzE;AAID;;;GAGG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,aAAa,EACpB,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9C,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAqB/B;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAwBf;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,aAAa,GACnB,OAAO,CAAC,cAAc,CAAC,CA+DzB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAAC,mBAAmB,CAAC,CAkE9B"}
|