@intelligo-dev/core 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/dist/conversations/errors.d.ts +31 -0
- package/dist/conversations/errors.d.ts.map +1 -0
- package/dist/conversations/errors.js +25 -0
- package/dist/conversations/errors.js.map +1 -0
- package/dist/conversations/index.d.ts +13 -0
- package/dist/conversations/index.d.ts.map +1 -0
- package/dist/conversations/index.js +12 -0
- package/dist/conversations/index.js.map +1 -0
- package/dist/conversations/service.d.ts +132 -0
- package/dist/conversations/service.d.ts.map +1 -0
- package/dist/conversations/service.js +347 -0
- package/dist/conversations/service.js.map +1 -0
- package/dist/conversations/types.d.ts +10 -0
- package/dist/conversations/types.d.ts.map +1 -0
- package/dist/conversations/types.js +5 -0
- package/dist/conversations/types.js.map +1 -0
- package/dist/db/client.d.ts +19 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +52 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/index.d.ts +4 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +8 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/schema/agents.d.ts +400 -0
- package/dist/db/schema/agents.d.ts.map +1 -0
- package/dist/db/schema/agents.js +39 -0
- package/dist/db/schema/agents.js.map +1 -0
- package/dist/db/schema/ai.d.ts +2222 -0
- package/dist/db/schema/ai.d.ts.map +1 -0
- package/dist/db/schema/ai.js +313 -0
- package/dist/db/schema/ai.js.map +1 -0
- package/dist/db/schema/auth.d.ts +1222 -0
- package/dist/db/schema/auth.d.ts.map +1 -0
- package/dist/db/schema/auth.js +162 -0
- package/dist/db/schema/auth.js.map +1 -0
- package/dist/db/schema/billing.d.ts +1199 -0
- package/dist/db/schema/billing.d.ts.map +1 -0
- package/dist/db/schema/billing.js +150 -0
- package/dist/db/schema/billing.js.map +1 -0
- package/dist/db/schema/feature-flags.d.ts +143 -0
- package/dist/db/schema/feature-flags.d.ts.map +1 -0
- package/dist/db/schema/feature-flags.js +25 -0
- package/dist/db/schema/feature-flags.js.map +1 -0
- package/dist/db/schema/identity.d.ts +1295 -0
- package/dist/db/schema/identity.d.ts.map +1 -0
- package/dist/db/schema/identity.js +258 -0
- package/dist/db/schema/identity.js.map +1 -0
- package/dist/db/schema/index.d.ts +16 -0
- package/dist/db/schema/index.d.ts.map +1 -0
- package/dist/db/schema/index.js +43 -0
- package/dist/db/schema/index.js.map +1 -0
- package/dist/db/schema/notifications.d.ts +182 -0
- package/dist/db/schema/notifications.d.ts.map +1 -0
- package/dist/db/schema/notifications.js +38 -0
- package/dist/db/schema/notifications.js.map +1 -0
- package/dist/db/schema/rag.d.ts +171 -0
- package/dist/db/schema/rag.d.ts.map +1 -0
- package/dist/db/schema/rag.js +42 -0
- package/dist/db/schema/rag.js.map +1 -0
- package/dist/db/schema/usage.d.ts +1193 -0
- package/dist/db/schema/usage.d.ts.map +1 -0
- package/dist/db/schema/usage.js +224 -0
- package/dist/db/schema/usage.js.map +1 -0
- package/dist/db/validate.d.ts +19 -0
- package/dist/db/validate.d.ts.map +1 -0
- package/dist/db/validate.js +58 -0
- package/dist/db/validate.js.map +1 -0
- package/dist/db/workspace-queries.d.ts +75 -0
- package/dist/db/workspace-queries.d.ts.map +1 -0
- package/dist/db/workspace-queries.js +78 -0
- package/dist/db/workspace-queries.js.map +1 -0
- package/dist/documents/classifier.d.ts +31 -0
- package/dist/documents/classifier.d.ts.map +1 -0
- package/dist/documents/classifier.js +41 -0
- package/dist/documents/classifier.js.map +1 -0
- package/dist/documents/errors.d.ts +32 -0
- package/dist/documents/errors.d.ts.map +1 -0
- package/dist/documents/errors.js +27 -0
- package/dist/documents/errors.js.map +1 -0
- package/dist/documents/index.d.ts +14 -0
- package/dist/documents/index.d.ts.map +1 -0
- package/dist/documents/index.js +13 -0
- package/dist/documents/index.js.map +1 -0
- package/dist/documents/service.d.ts +54 -0
- package/dist/documents/service.d.ts.map +1 -0
- package/dist/documents/service.js +146 -0
- package/dist/documents/service.js.map +1 -0
- package/dist/documents/types.d.ts +27 -0
- package/dist/documents/types.d.ts.map +1 -0
- package/dist/documents/types.js +5 -0
- package/dist/documents/types.js.map +1 -0
- package/dist/email/index.d.ts +5 -0
- package/dist/email/index.d.ts.map +1 -0
- package/dist/email/index.js +5 -0
- package/dist/email/index.js.map +1 -0
- package/dist/email/provider.d.ts +68 -0
- package/dist/email/provider.d.ts.map +1 -0
- package/dist/email/provider.js +199 -0
- package/dist/email/provider.js.map +1 -0
- package/dist/email/send.d.ts +47 -0
- package/dist/email/send.d.ts.map +1 -0
- package/dist/email/send.js +110 -0
- package/dist/email/send.js.map +1 -0
- package/dist/email/senders.d.ts +93 -0
- package/dist/email/senders.d.ts.map +1 -0
- package/dist/email/senders.js +232 -0
- package/dist/email/senders.js.map +1 -0
- package/dist/email/templates/base-layout.d.ts +7 -0
- package/dist/email/templates/base-layout.d.ts.map +1 -0
- package/dist/email/templates/base-layout.js +69 -0
- package/dist/email/templates/base-layout.js.map +1 -0
- package/dist/email/templates/index.d.ts +11 -0
- package/dist/email/templates/index.d.ts.map +1 -0
- package/dist/email/templates/index.js +17 -0
- package/dist/email/templates/index.js.map +1 -0
- package/dist/email/templates/password-reset.d.ts +7 -0
- package/dist/email/templates/password-reset.d.ts.map +1 -0
- package/dist/email/templates/password-reset.js +59 -0
- package/dist/email/templates/password-reset.js.map +1 -0
- package/dist/email/templates/payment-failed.d.ts +8 -0
- package/dist/email/templates/payment-failed.d.ts.map +1 -0
- package/dist/email/templates/payment-failed.js +62 -0
- package/dist/email/templates/payment-failed.js.map +1 -0
- package/dist/email/templates/quota-warning.d.ts +11 -0
- package/dist/email/templates/quota-warning.d.ts.map +1 -0
- package/dist/email/templates/quota-warning.js +82 -0
- package/dist/email/templates/quota-warning.js.map +1 -0
- package/dist/email/templates/subscription-confirmed.d.ts +9 -0
- package/dist/email/templates/subscription-confirmed.d.ts.map +1 -0
- package/dist/email/templates/subscription-confirmed.js +72 -0
- package/dist/email/templates/subscription-confirmed.js.map +1 -0
- package/dist/email/templates/trial-expiry.d.ts +9 -0
- package/dist/email/templates/trial-expiry.d.ts.map +1 -0
- package/dist/email/templates/trial-expiry.js +86 -0
- package/dist/email/templates/trial-expiry.js.map +1 -0
- package/dist/email/templates/trial-warning.d.ts +11 -0
- package/dist/email/templates/trial-warning.d.ts.map +1 -0
- package/dist/email/templates/trial-warning.js +70 -0
- package/dist/email/templates/trial-warning.js.map +1 -0
- package/dist/email/templates/verify-email.d.ts +7 -0
- package/dist/email/templates/verify-email.d.ts.map +1 -0
- package/dist/email/templates/verify-email.js +59 -0
- package/dist/email/templates/verify-email.js.map +1 -0
- package/dist/email/templates/welcome.d.ts +7 -0
- package/dist/email/templates/welcome.d.ts.map +1 -0
- package/dist/email/templates/welcome.js +51 -0
- package/dist/email/templates/welcome.js.map +1 -0
- package/dist/email/templates/workspace-invitation.d.ts +10 -0
- package/dist/email/templates/workspace-invitation.d.ts.map +1 -0
- package/dist/email/templates/workspace-invitation.js +79 -0
- package/dist/email/templates/workspace-invitation.js.map +1 -0
- package/dist/env.d.ts +21 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +129 -0
- package/dist/env.js.map +1 -0
- package/dist/identity/audit.d.ts +39 -0
- package/dist/identity/audit.d.ts.map +1 -0
- package/dist/identity/audit.js +51 -0
- package/dist/identity/audit.js.map +1 -0
- package/dist/identity/errors.d.ts +32 -0
- package/dist/identity/errors.d.ts.map +1 -0
- package/dist/identity/errors.js +25 -0
- package/dist/identity/errors.js.map +1 -0
- package/dist/identity/index.d.ts +16 -0
- package/dist/identity/index.d.ts.map +1 -0
- package/dist/identity/index.js +15 -0
- package/dist/identity/index.js.map +1 -0
- package/dist/identity/service.d.ts +70 -0
- package/dist/identity/service.d.ts.map +1 -0
- package/dist/identity/service.js +179 -0
- package/dist/identity/service.js.map +1 -0
- package/dist/identity/types.d.ts +27 -0
- package/dist/identity/types.d.ts.map +1 -0
- package/dist/identity/types.js +5 -0
- package/dist/identity/types.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +50 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +183 -0
- package/dist/logger.js.map +1 -0
- package/dist/notifications/index.d.ts +86 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +112 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/triggers.d.ts +68 -0
- package/dist/notifications/triggers.d.ts.map +1 -0
- package/dist/notifications/triggers.js +145 -0
- package/dist/notifications/triggers.js.map +1 -0
- package/dist/notifications/types.d.ts +19 -0
- package/dist/notifications/types.d.ts.map +1 -0
- package/dist/notifications/types.js +11 -0
- package/dist/notifications/types.js.map +1 -0
- package/package.json +101 -0
- package/src/db/migrations/0000_sharp_night_nurse.sql +52 -0
- package/src/db/migrations/0001_hesitant_vapor.sql +40 -0
- package/src/db/migrations/0002_numerous_lady_vermin.sql +235 -0
- package/src/db/migrations/0003_mighty_jean_grey.sql +37 -0
- package/src/db/migrations/0004_cynical_grandmaster.sql +2 -0
- package/src/db/migrations/0005_careful_switch.sql +8 -0
- package/src/db/migrations/0006_tense_blue_marvel.sql +16 -0
- package/src/db/migrations/0007_next_squadron_sinister.sql +1 -0
- package/src/db/migrations/0008_powerful_scream.sql +39 -0
- package/src/db/migrations/0009_sad_ink.sql +1 -0
- package/src/db/migrations/0010_shocking_omega_flight.sql +2 -0
- package/src/db/migrations/0011_ambiguous_otto_octavius.sql +151 -0
- package/src/db/migrations/0011_hnsw_vector_index.sql +17 -0
- package/src/db/migrations/0012_user_profiles.sql +30 -0
- package/src/db/migrations/0013_trending_seasonal_columns.sql +9 -0
- package/src/db/migrations/0014_add_product_type_to_agents.sql +6 -0
- package/src/db/migrations/0015_new_v1_tables.sql +149 -0
- package/src/db/migrations/0016_document_types.sql +30 -0
- package/src/db/migrations/0017_document_metadata.sql +2 -0
- package/src/db/migrations/0018_identity_graph.sql +200 -0
- package/src/db/migrations/0019_db_driven_prompts.sql +20 -0
- package/src/db/migrations/0020_pending_extractions.sql +35 -0
- package/src/db/migrations/0021_rag_documents.sql +39 -0
- package/src/db/migrations/0022_user_quotas_usage_jsonb.sql +70 -0
- package/src/db/migrations/0023_user_facts_user_scoped_unique.sql +17 -0
- package/src/db/migrations/0024_user_memories_hnsw.sql +23 -0
- package/src/db/migrations/0025_audit_trigger_errcode.sql +21 -0
- package/src/db/migrations/0026_user_profile_snapshots_composite_pk.sql +17 -0
- package/src/db/migrations/0027_billing_settings_mnt_columns.sql +54 -0
- package/src/db/migrations/0028_trial_credits_normalized_email.sql +37 -0
- package/src/db/migrations/0029_usage_records_conversation_idx.sql +13 -0
- package/src/db/migrations/0030_pending_extractions_composite_idx.sql +11 -0
- package/src/db/migrations/0031_rag_documents_hnsw.sql +16 -0
- package/src/db/migrations/0032_rate_limit_unique_idx.sql +16 -0
- package/src/db/migrations/0033_pending_extractions_partial_idx.sql +18 -0
- package/src/db/migrations/0034_rate_limit_count.sql +9 -0
- package/src/db/migrations/0035_credit_reservations.sql +24 -0
- package/src/db/migrations/0036_executions_audit_jobs.sql +96 -0
- package/src/db/migrations/0037_rate_limit_minute_bucket.sql +46 -0
- package/src/db/migrations/0038_user_quotas_generic_usage.sql +25 -0
- package/src/db/migrations/0039_platform_admin_impersonation.sql +27 -0
- package/src/db/migrations/0040_ee_audit_chain.sql +23 -0
- package/src/db/migrations/README.md +57 -0
- package/src/db/migrations/meta/0000_snapshot.json +348 -0
- package/src/db/migrations/meta/0001_snapshot.json +631 -0
- package/src/db/migrations/meta/0002_snapshot.json +2269 -0
- package/src/db/migrations/meta/0003_snapshot.json +2488 -0
- package/src/db/migrations/meta/0004_snapshot.json +2500 -0
- package/src/db/migrations/meta/0005_snapshot.json +2548 -0
- package/src/db/migrations/meta/0006_snapshot.json +2650 -0
- package/src/db/migrations/meta/0007_snapshot.json +2657 -0
- package/src/db/migrations/meta/0008_snapshot.json +2719 -0
- package/src/db/migrations/meta/0009_snapshot.json +2726 -0
- package/src/db/migrations/meta/0010_snapshot.json +2739 -0
- package/src/db/migrations/meta/0011_snapshot.json +3886 -0
- package/src/db/migrations/meta/_journal.json +300 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-email.js","sourceRoot":"","sources":["../../../src/email/templates/verify-email.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAe3C,MAAM,UAAU,gBAAgB,CAAC,EAC/B,QAAQ,EACR,eAAe,EACf,MAAM,GAAG,IAAI,GACS;IACtB,MAAM,IAAI,GACR,MAAM,KAAK,IAAI;QACb,CAAC,CAAC;YACE,OAAO,EAAE,gCAAgC;YACzC,OAAO,EAAE,sBAAsB;YAC/B,QAAQ,EAAE,eAAe;YACzB,IAAI,EAAE,oDAAoD;YAC1D,MAAM,EAAE,sBAAsB;YAC9B,IAAI,EAAE,8GAA8G;SACrH;QACH,CAAC,CAAC;YACE,OAAO,EAAE,2BAA2B;YACpC,OAAO,EAAE,mBAAmB;YAC5B,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,gEAAgE;YACtE,MAAM,EAAE,cAAc;YACtB,IAAI,EAAE,mGAAmG;SAC1G,CAAC;IAER,OAAO,CACL,MAAC,UAAU,IAAC,OAAO,EAAE,IAAI,CAAC,OAAO,aAC/B,KAAC,IAAI,IAAC,KAAK,EAAE,YAAY,YAAG,IAAI,CAAC,OAAO,GAAQ,EAChD,MAAC,IAAI,IAAC,KAAK,EAAE,aAAa,aACvB,IAAI,CAAC,QAAQ,OAAG,QAAQ,SACpB,EACP,KAAC,IAAI,IAAC,KAAK,EAAE,aAAa,YAAG,IAAI,CAAC,IAAI,GAAQ,EAC9C,KAAC,MAAM,IAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,YAC9C,IAAI,CAAC,MAAM,GACL,EACT,KAAC,IAAI,IAAC,KAAK,EAAE,SAAS,YAAG,IAAI,CAAC,IAAI,GAAQ,IAC/B,CACd,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E,MAAM,YAAY,GAAwB;IACxC,KAAK,EAAE,SAAS;IAChB,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,GAAG;IACf,UAAU,EAAE,MAAM;IAClB,MAAM,EAAE,UAAU;CACnB,CAAC;AAEF,MAAM,aAAa,GAAwB;IACzC,KAAK,EAAE,SAAS;IAChB,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,MAAM;IAClB,MAAM,EAAE,UAAU;CACnB,CAAC;AAEF,MAAM,WAAW,GAAwB;IACvC,eAAe,EAAE,SAAS;IAC1B,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE,SAAS;IAChB,OAAO,EAAE,cAAc;IACvB,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,GAAG;IACf,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,WAAW;IACpB,cAAc,EAAE,MAAM;IACtB,SAAS,EAAE,QAAiB;IAC5B,SAAS,EAAE,KAAK;CACjB,CAAC;AAEF,MAAM,SAAS,GAAwB;IACrC,KAAK,EAAE,SAAS;IAChB,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE,MAAM;CAClB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface WelcomeEmailProps {
|
|
2
|
+
userName: string;
|
|
3
|
+
dashboardUrl: string;
|
|
4
|
+
locale?: "en" | "mn";
|
|
5
|
+
}
|
|
6
|
+
export declare function WelcomeEmail({ userName, dashboardUrl, locale, }: WelcomeEmailProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=welcome.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"welcome.d.ts","sourceRoot":"","sources":["../../../src/email/templates/welcome.tsx"],"names":[],"mappings":"AAUA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACtB;AAED,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,YAAY,EACZ,MAAa,GACd,EAAE,iBAAiB,2CA8BnB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Text } from "@react-email/components";
|
|
3
|
+
import { BaseLayout } from "./base-layout";
|
|
4
|
+
export function WelcomeEmail({ userName, dashboardUrl, locale = "en", }) {
|
|
5
|
+
const text = locale === "mn"
|
|
6
|
+
? {
|
|
7
|
+
preview: `Тавтай морил, ${userName}!`,
|
|
8
|
+
heading: "Intelligo-д тавтай морил",
|
|
9
|
+
greeting: "Сайн байна уу",
|
|
10
|
+
body: "Бүртгүүлсэнд баярлалаа! Та одоо AI хэрэгслүүдийг ашиглаж бүтээмжээ нэмэгдүүлэх бэлэн боллоо.",
|
|
11
|
+
button: "Хянах самбар руу очих",
|
|
12
|
+
}
|
|
13
|
+
: {
|
|
14
|
+
preview: `Welcome to Intelligo, ${userName}!`,
|
|
15
|
+
heading: "Welcome to Intelligo",
|
|
16
|
+
greeting: "Hi",
|
|
17
|
+
body: "Thanks for signing up! You're all set to start using AI-powered tools to boost your productivity.",
|
|
18
|
+
button: "Go to Dashboard",
|
|
19
|
+
};
|
|
20
|
+
return (_jsxs(BaseLayout, { preview: text.preview, children: [_jsx(Text, { style: headingStyle, children: text.heading }), _jsxs(Text, { style: bodyTextStyle, children: [text.greeting, " ", userName, ","] }), _jsx(Text, { style: bodyTextStyle, children: text.body }), _jsx(Button, { href: dashboardUrl, style: buttonStyle, children: text.button })] }));
|
|
21
|
+
}
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// Inline Styles
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
const headingStyle = {
|
|
26
|
+
color: "#18181b",
|
|
27
|
+
fontSize: "22px",
|
|
28
|
+
fontWeight: 700,
|
|
29
|
+
lineHeight: "30px",
|
|
30
|
+
margin: "0 0 16px",
|
|
31
|
+
};
|
|
32
|
+
const bodyTextStyle = {
|
|
33
|
+
color: "#18181b",
|
|
34
|
+
fontSize: "15px",
|
|
35
|
+
lineHeight: "24px",
|
|
36
|
+
margin: "0 0 12px",
|
|
37
|
+
};
|
|
38
|
+
const buttonStyle = {
|
|
39
|
+
backgroundColor: "#7c3aed",
|
|
40
|
+
borderRadius: "6px",
|
|
41
|
+
color: "#ffffff",
|
|
42
|
+
display: "inline-block",
|
|
43
|
+
fontSize: "15px",
|
|
44
|
+
fontWeight: 600,
|
|
45
|
+
lineHeight: "100%",
|
|
46
|
+
padding: "12px 24px",
|
|
47
|
+
textDecoration: "none",
|
|
48
|
+
textAlign: "center",
|
|
49
|
+
marginTop: "8px",
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=welcome.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"welcome.js","sourceRoot":"","sources":["../../../src/email/templates/welcome.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAc3C,MAAM,UAAU,YAAY,CAAC,EAC3B,QAAQ,EACR,YAAY,EACZ,MAAM,GAAG,IAAI,GACK;IAClB,MAAM,IAAI,GACR,MAAM,KAAK,IAAI;QACb,CAAC,CAAC;YACE,OAAO,EAAE,iBAAiB,QAAQ,GAAG;YACrC,OAAO,EAAE,0BAA0B;YACnC,QAAQ,EAAE,eAAe;YACzB,IAAI,EAAE,8FAA8F;YACpG,MAAM,E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S,EAAE,KAAK;CACjB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface WorkspaceInvitationEmailProps {
|
|
2
|
+
inviterName: string;
|
|
3
|
+
workspaceName: string;
|
|
4
|
+
role: string;
|
|
5
|
+
acceptUrl: string;
|
|
6
|
+
declineUrl: string;
|
|
7
|
+
locale?: "en" | "mn";
|
|
8
|
+
}
|
|
9
|
+
export declare function WorkspaceInvitationEmail({ inviterName, workspaceName, role, acceptUrl, declineUrl, locale, }: WorkspaceInvitationEmailProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=workspace-invitation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-invitation.d.ts","sourceRoot":"","sources":["../../../src/email/templates/workspace-invitation.tsx"],"names":[],"mappings":"AAUA,MAAM,WAAW,6BAA6B;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACtB;AAED,wBAAgB,wBAAwB,CAAC,EACvC,WAAW,EACX,aAAa,EACb,IAAI,EACJ,SAAS,EACT,UAAU,EACV,MAAa,GACd,EAAE,6BAA6B,2CA4C/B"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Section, Text } from "@react-email/components";
|
|
3
|
+
import { BaseLayout } from "./base-layout";
|
|
4
|
+
export function WorkspaceInvitationEmail({ inviterName, workspaceName, role, acceptUrl, declineUrl, locale = "en", }) {
|
|
5
|
+
const text = locale === "mn"
|
|
6
|
+
? {
|
|
7
|
+
preview: `${inviterName} таныг ${workspaceName} руу урьсан байна`,
|
|
8
|
+
heading: "Та урьигдсан байна!",
|
|
9
|
+
body: "таныг ажлын орчинд",
|
|
10
|
+
as: "нэртэй",
|
|
11
|
+
invitedYou: "урьж байна",
|
|
12
|
+
acceptButton: "Урилга хүлээн авах",
|
|
13
|
+
declineButton: "Татгалзах",
|
|
14
|
+
note: "Энэ урилга 7 хоногийн дараа хүчингүй болно.",
|
|
15
|
+
}
|
|
16
|
+
: {
|
|
17
|
+
preview: `${inviterName} invited you to join ${workspaceName}`,
|
|
18
|
+
heading: "You're invited!",
|
|
19
|
+
body: "has invited you to join the workspace",
|
|
20
|
+
as: "as a",
|
|
21
|
+
invitedYou: "",
|
|
22
|
+
acceptButton: "Accept Invitation",
|
|
23
|
+
declineButton: "Decline",
|
|
24
|
+
note: "This invitation expires in 7 days.",
|
|
25
|
+
};
|
|
26
|
+
return (_jsxs(BaseLayout, { preview: text.preview, children: [_jsx(Text, { style: headingStyle, children: text.heading }), _jsxs(Text, { style: bodyTextStyle, children: [_jsx("strong", { children: inviterName }), " ", text.body, " ", _jsxs("strong", { children: ["\u2018", workspaceName, "\u2019"] }), " ", text.as, " ", _jsx("strong", { children: role }), text.invitedYou ? ` ${text.invitedYou}` : "", "."] }), _jsxs(Section, { style: buttonGroupStyle, children: [_jsx(Button, { href: acceptUrl, style: acceptButtonStyle, children: text.acceptButton }), _jsx(Button, { href: declineUrl, style: declineButtonStyle, children: text.declineButton })] }), _jsx(Text, { style: noteStyle, children: text.note })] }));
|
|
27
|
+
}
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
// Inline Styles
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
const headingStyle = {
|
|
32
|
+
color: "#18181b",
|
|
33
|
+
fontSize: "22px",
|
|
34
|
+
fontWeight: 700,
|
|
35
|
+
lineHeight: "30px",
|
|
36
|
+
margin: "0 0 16px",
|
|
37
|
+
};
|
|
38
|
+
const bodyTextStyle = {
|
|
39
|
+
color: "#18181b",
|
|
40
|
+
fontSize: "15px",
|
|
41
|
+
lineHeight: "24px",
|
|
42
|
+
margin: "0 0 12px",
|
|
43
|
+
};
|
|
44
|
+
const buttonGroupStyle = {
|
|
45
|
+
marginTop: "8px",
|
|
46
|
+
};
|
|
47
|
+
const acceptButtonStyle = {
|
|
48
|
+
backgroundColor: "#7c3aed",
|
|
49
|
+
borderRadius: "6px",
|
|
50
|
+
color: "#ffffff",
|
|
51
|
+
display: "inline-block",
|
|
52
|
+
fontSize: "15px",
|
|
53
|
+
fontWeight: 600,
|
|
54
|
+
lineHeight: "100%",
|
|
55
|
+
padding: "12px 24px",
|
|
56
|
+
textDecoration: "none",
|
|
57
|
+
textAlign: "center",
|
|
58
|
+
marginRight: "12px",
|
|
59
|
+
};
|
|
60
|
+
const declineButtonStyle = {
|
|
61
|
+
backgroundColor: "transparent",
|
|
62
|
+
border: "1px solid #d4d4d8",
|
|
63
|
+
borderRadius: "6px",
|
|
64
|
+
color: "#71717a",
|
|
65
|
+
display: "inline-block",
|
|
66
|
+
fontSize: "15px",
|
|
67
|
+
fontWeight: 600,
|
|
68
|
+
lineHeight: "100%",
|
|
69
|
+
padding: "12px 24px",
|
|
70
|
+
textDecoration: "none",
|
|
71
|
+
textAlign: "center",
|
|
72
|
+
};
|
|
73
|
+
const noteStyle = {
|
|
74
|
+
color: "#71717a",
|
|
75
|
+
fontSize: "13px",
|
|
76
|
+
lineHeight: "20px",
|
|
77
|
+
marginTop: "20px",
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=workspace-invitation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-invitation.js","sourceRoot":"","sources":["../../../src/email/templates/workspace-invitation.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAiB3C,MAAM,UAAU,wBAAwB,CAAC,EACvC,WAAW,EACX,aAAa,EACb,IAAI,EACJ,SAA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Q,EAAE,MAAM;IAChB,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE,MAAM;CAClB,CAAC"}
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Variable Validation
|
|
3
|
+
*
|
|
4
|
+
* Validates required environment variables at startup.
|
|
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).
|
|
10
|
+
*/
|
|
11
|
+
export declare function validateEnv(): {
|
|
12
|
+
valid: boolean;
|
|
13
|
+
errors: string[];
|
|
14
|
+
warnings: string[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Log validation results. Call during app initialization.
|
|
18
|
+
* Throws on missing required vars; logs warnings for optional vars.
|
|
19
|
+
*/
|
|
20
|
+
export declare function assertEnv(): void;
|
|
21
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA2EH,wBAAgB,WAAW,IAAI;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CA8CA;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAgBhC"}
|
package/dist/env.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Variable Validation
|
|
3
|
+
*
|
|
4
|
+
* Validates required environment variables at startup.
|
|
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).
|
|
10
|
+
*/
|
|
11
|
+
const ENV_VARS = [
|
|
12
|
+
{
|
|
13
|
+
name: "DATABASE_URL",
|
|
14
|
+
required: true,
|
|
15
|
+
description: "PostgreSQL connection string",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "AUTH_SECRET",
|
|
19
|
+
required: true,
|
|
20
|
+
description: "Better-Auth session encryption key",
|
|
21
|
+
minLength: 32,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "NEXT_PUBLIC_APP_URL",
|
|
25
|
+
required: true,
|
|
26
|
+
description: "Application base URL for auth and redirects",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "OPENAI_API_KEY",
|
|
30
|
+
required: false,
|
|
31
|
+
description: "OpenAI API key (AI chat features)",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "STRIPE_SECRET_KEY",
|
|
35
|
+
required: false,
|
|
36
|
+
description: "Stripe API key (billing features)",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "STRIPE_WEBHOOK_SECRET",
|
|
40
|
+
required: false,
|
|
41
|
+
description: "Stripe webhook signature secret",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY",
|
|
45
|
+
required: false,
|
|
46
|
+
description: "Stripe publishable key (billing UI)",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "RESEND_API_KEY",
|
|
50
|
+
required: false,
|
|
51
|
+
description: "Resend API key (email features)",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "LOOPS_API_KEY",
|
|
55
|
+
required: false,
|
|
56
|
+
description: "Loops API key (email features; templates mapped via LOOPS_TRANSACTIONAL_ID_*)",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "EMAIL_PROVIDER",
|
|
60
|
+
required: false,
|
|
61
|
+
description: "Explicit email provider selection (resend | loops | console)",
|
|
62
|
+
},
|
|
63
|
+
// Cron endpoints (e.g. /api/cron/trial-expiry) gate on a Bearer
|
|
64
|
+
// header equal to CRON_SECRET. The secret is optional in dev so
|
|
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.
|
|
67
|
+
{
|
|
68
|
+
name: "CRON_SECRET",
|
|
69
|
+
required: false,
|
|
70
|
+
description: "Shared secret for /api/cron/* Bearer auth",
|
|
71
|
+
minLength: 32,
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
export function validateEnv() {
|
|
75
|
+
const errors = [];
|
|
76
|
+
const warnings = [];
|
|
77
|
+
for (const envVar of ENV_VARS) {
|
|
78
|
+
const value = process.env[envVar.name];
|
|
79
|
+
if (!value || value.trim() === "") {
|
|
80
|
+
if (envVar.required) {
|
|
81
|
+
errors.push(`Missing required env var: ${envVar.name} — ${envVar.description}`);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
warnings.push(`Missing optional env var: ${envVar.name} — ${envVar.description}`);
|
|
85
|
+
}
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (envVar.minLength && value.length < envVar.minLength) {
|
|
89
|
+
const msg = `${envVar.name} is shorter than ${envVar.minLength} chars — too weak for ${envVar.description}`;
|
|
90
|
+
if (envVar.required) {
|
|
91
|
+
errors.push(msg);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
warnings.push(msg);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Production safety checks
|
|
99
|
+
if (process.env.NODE_ENV === "production") {
|
|
100
|
+
if (process.env.STRIPE_SECRET_KEY?.startsWith("sk_test_")) {
|
|
101
|
+
warnings.push("STRIPE_SECRET_KEY is a test key in production environment");
|
|
102
|
+
}
|
|
103
|
+
if (!process.env.CRON_SECRET || process.env.CRON_SECRET.length < 32) {
|
|
104
|
+
// Promote to error in production — an unset or weak cron secret
|
|
105
|
+
// means the cron endpoints are wide open to anyone who guesses
|
|
106
|
+
// the path.
|
|
107
|
+
errors.push("CRON_SECRET must be set (≥32 chars) in production for /api/cron/* auth");
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return { valid: errors.length === 0, errors, warnings };
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Log validation results. Call during app initialization.
|
|
114
|
+
* Throws on missing required vars; logs warnings for optional vars.
|
|
115
|
+
*/
|
|
116
|
+
export function assertEnv() {
|
|
117
|
+
const { valid, errors, warnings } = validateEnv();
|
|
118
|
+
for (const warning of warnings) {
|
|
119
|
+
console.warn(`[Env] ${warning}`);
|
|
120
|
+
}
|
|
121
|
+
if (!valid) {
|
|
122
|
+
console.error("[Env] Missing required environment variables:");
|
|
123
|
+
for (const error of errors) {
|
|
124
|
+
console.error(` - ${error}`);
|
|
125
|
+
}
|
|
126
|
+
throw new Error(`Missing ${errors.length} required environment variable(s). See logs above.`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=env.js.map
|
package/dist/env.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAUH,MAAM,QAAQ,GAAa;IACzB;QACE,IAAI,EAAE,cAAc;QACpB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,8BAA8B;KAC5C;IACD;QACE,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,oCAAoC;QACjD,SAAS,EAAE,EAAE;KACd;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,6CAA6C;KAC3D;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,QAAQ,EAAE,KAAK;QACf,WA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,EAAE,CAAC;QAC/B,OAAO,CAAC,IAAI,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAC/D,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC;QAChC,CAAC;QACD,MAAM,IAAI,KAAK,CACb,WAAW,MAAM,CAAC,MAAM,oDAAoD,CAC7E,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory-audit write — the ADR-0008 destination, reconciled with the
|
|
3
|
+
* allowlist.
|
|
4
|
+
*
|
|
5
|
+
* ADR-0008 names `@intelligo-dev/audit` as `recordMemoryAudit`'s
|
|
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.
|
|
24
|
+
*/
|
|
25
|
+
import type { AuditTargetKind, AuditAction, AuditActorKind, UserMemoryAuditRow } from "../db/schema";
|
|
26
|
+
export type RecordMemoryAuditInput = {
|
|
27
|
+
userId: string;
|
|
28
|
+
workspaceId: string;
|
|
29
|
+
targetKind: AuditTargetKind;
|
|
30
|
+
targetId: string;
|
|
31
|
+
action: AuditAction;
|
|
32
|
+
actorKind: AuditActorKind;
|
|
33
|
+
actorId?: string;
|
|
34
|
+
beforeValue?: unknown;
|
|
35
|
+
afterValue?: unknown;
|
|
36
|
+
reason?: string;
|
|
37
|
+
};
|
|
38
|
+
export declare function recordMemoryAudit(input: RecordMemoryAuditInput): Promise<UserMemoryAuditRow>;
|
|
39
|
+
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/identity/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,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,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,kBAAkB,CAAC,CA2B7B"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory-audit write — the ADR-0008 destination, reconciled with the
|
|
3
|
+
* allowlist.
|
|
4
|
+
*
|
|
5
|
+
* ADR-0008 names `@intelligo-dev/audit` as `recordMemoryAudit`'s
|
|
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.
|
|
24
|
+
*/
|
|
25
|
+
import { db } from "../db";
|
|
26
|
+
import { userMemoryAudit } from "../db/schema";
|
|
27
|
+
import { IdentityServiceError } from "./errors";
|
|
28
|
+
export async function recordMemoryAudit(input) {
|
|
29
|
+
const [row] = await db
|
|
30
|
+
.insert(userMemoryAudit)
|
|
31
|
+
.values({
|
|
32
|
+
id: crypto.randomUUID(),
|
|
33
|
+
userId: input.userId,
|
|
34
|
+
workspaceId: input.workspaceId,
|
|
35
|
+
targetKind: input.targetKind,
|
|
36
|
+
targetId: input.targetId,
|
|
37
|
+
action: input.action,
|
|
38
|
+
actorKind: input.actorKind,
|
|
39
|
+
actorId: input.actorId,
|
|
40
|
+
beforeValue: input.beforeValue,
|
|
41
|
+
afterValue: input.afterValue,
|
|
42
|
+
reason: input.reason,
|
|
43
|
+
createdAt: new Date(),
|
|
44
|
+
})
|
|
45
|
+
.returning();
|
|
46
|
+
if (!row) {
|
|
47
|
+
throw new IdentityServiceError("database_error", "Failed to record memory audit event");
|
|
48
|
+
}
|
|
49
|
+
return row;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/identity/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;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,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,KAA6B;IAE7B,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,EAAE;SACnB,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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity service error type.
|
|
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.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* - `not_found` — no fact exists at the given id within the actor's
|
|
13
|
+
* workspace/user scope. Covers both "no such fact" and "a fact that
|
|
14
|
+
* belongs to a different user in the same workspace" — the two are
|
|
15
|
+
* deliberately indistinguishable to the caller (same reasoning as
|
|
16
|
+
* `../conversations/service.ts`'s `verifyConversation`: an id alone
|
|
17
|
+
* should never reveal whose data exists behind it).
|
|
18
|
+
* - `invalid_input` — a caller-supplied argument failed a basic
|
|
19
|
+
* invariant (e.g. an empty fact id).
|
|
20
|
+
* - `database_error` — the underlying insert did not return the row it
|
|
21
|
+
* was expected to.
|
|
22
|
+
*/
|
|
23
|
+
export type IdentityServiceErrorCode = "not_found" | "invalid_input" | "database_error";
|
|
24
|
+
export declare class IdentityServiceError extends Error {
|
|
25
|
+
readonly code: IdentityServiceErrorCode;
|
|
26
|
+
readonly cause?: unknown;
|
|
27
|
+
constructor(code: IdentityServiceErrorCode, message: string, options?: {
|
|
28
|
+
cause?: unknown;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export declare function isIdentityServiceError(error: unknown): error is IdentityServiceError;
|
|
32
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/identity/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,wBAAwB,GAChC,WAAW,GACX,eAAe,GACf,gBAAgB,CAAC;AAErB,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IAIxC,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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity service error type.
|
|
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.
|
|
10
|
+
*/
|
|
11
|
+
export class IdentityServiceError extends Error {
|
|
12
|
+
constructor(code, message, options) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = "IdentityServiceError";
|
|
15
|
+
this.code = code;
|
|
16
|
+
if (options?.cause !== undefined) {
|
|
17
|
+
this.cause = options.cause;
|
|
18
|
+
}
|
|
19
|
+
Object.setPrototypeOf(this, IdentityServiceError.prototype);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function isIdentityServiceError(error) {
|
|
23
|
+
return error instanceof IdentityServiceError;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/identity/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAmBH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAO7C,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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity Module (ADR-0008/ADR-0009 precedent)
|
|
3
|
+
*
|
|
4
|
+
* Privacy-facing reads and mutations over the user identity graph:
|
|
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
|
|
12
|
+
*/
|
|
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";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,SAAS,EACT,UAAU,EACV,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,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity Module (ADR-0008/ADR-0009 precedent)
|
|
3
|
+
*
|
|
4
|
+
* Privacy-facing reads and mutations over the user identity graph:
|
|
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
|
|
12
|
+
*/
|
|
13
|
+
export { listFacts, deleteFact, exportIdentity, getAuditTrail, } from "./service";
|
|
14
|
+
export { IdentityServiceError, isIdentityServiceError, } from "./errors";
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,aAAa,GACd,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GAEvB,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity Service — Server-only
|
|
3
|
+
*
|
|
4
|
+
* Privacy-facing reads and mutations over the user identity graph:
|
|
5
|
+
* fact listing/deletion, a full-identity data export, and the
|
|
6
|
+
* memory-audit trail that records every mutation to a user's facts,
|
|
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.
|
|
16
|
+
*
|
|
17
|
+
* What did NOT come with it (stays product/agents-side):
|
|
18
|
+
* - `updateMyFactImportance` and the `synthesizeProfile()` re-trigger
|
|
19
|
+
* Ignite's `deleteMyFact` ran after deleting — synthesis is
|
|
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.
|
|
43
|
+
*/
|
|
44
|
+
import type { UserFact, UserMemoryAuditRow } from "../db/schema";
|
|
45
|
+
import type { IdentityActor, IdentityExport } from "./types";
|
|
46
|
+
/** List the actor's facts, most important and most confident first. */
|
|
47
|
+
export declare function listFacts(actor: IdentityActor): Promise<UserFact[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Read the actor's memory-audit trail, most recent first. Optionally
|
|
50
|
+
* scoped to a single target (e.g. one fact's history).
|
|
51
|
+
*/
|
|
52
|
+
export declare function getAuditTrail(actor: IdentityActor, options?: {
|
|
53
|
+
limit?: number;
|
|
54
|
+
targetId?: string;
|
|
55
|
+
}): Promise<UserMemoryAuditRow[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Delete a fact and record the deletion in the audit trail. Throws
|
|
58
|
+
* `invalid_input` for an empty id and `not_found` for anything outside
|
|
59
|
+
* the actor's scope (see `verifyFact`). Does NOT re-trigger profile
|
|
60
|
+
* synthesis — see the module doc comment.
|
|
61
|
+
*/
|
|
62
|
+
export declare function deleteFact(actor: IdentityActor, factId: string): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Aggregate the actor's full identity graph — facts, memories, latest
|
|
65
|
+
* profile snapshot, and full audit trail — for a data-export flow.
|
|
66
|
+
* Records its own audit row (action "export"): the export operation
|
|
67
|
+
* audits itself, same as the ported Ignite implementation.
|
|
68
|
+
*/
|
|
69
|
+
export declare function exportIdentity(actor: IdentityActor): Promise<IdentityExport>;
|
|
70
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/identity/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAUH,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGjE,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAuC7D,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;AAMD;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAoBf;AAMD;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,aAAa,GACnB,OAAO,CAAC,cAAc,CAAC,CA+DzB"}
|