@intelligo-dev/core 1.0.0-beta.2 → 1.0.0-beta.5
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/README.md +44 -0
- package/dist/conversations/index.d.ts +3 -3
- package/dist/conversations/index.js +2 -2
- package/dist/conversations/service.d.ts +4 -5
- package/dist/conversations/service.d.ts.map +1 -1
- package/dist/conversations/service.js +6 -7
- package/dist/conversations/service.js.map +1 -1
- package/dist/conversations/types.d.ts +1 -1
- package/dist/db/client.js +1 -1
- package/dist/db/index.d.ts +3 -3
- package/dist/db/index.js +3 -3
- package/dist/db/schema/agents.js +4 -4
- package/dist/db/schema/agents.js.map +1 -1
- package/dist/db/schema/ai.d.ts +8 -9
- package/dist/db/schema/ai.d.ts.map +1 -1
- package/dist/db/schema/ai.js +14 -15
- package/dist/db/schema/ai.js.map +1 -1
- package/dist/db/schema/billing.js +1 -1
- package/dist/db/schema/identity.js +1 -1
- package/dist/db/schema/index.d.ts +9 -9
- package/dist/db/schema/index.js +9 -9
- package/dist/db/schema/rag.d.ts +3 -4
- package/dist/db/schema/rag.d.ts.map +1 -1
- package/dist/db/schema/rag.js +3 -4
- package/dist/db/schema/rag.js.map +1 -1
- package/dist/db/schema/usage.js +3 -3
- package/dist/db/validate.js +1 -1
- package/dist/documents/classifier.d.ts +3 -2
- package/dist/documents/classifier.d.ts.map +1 -1
- package/dist/documents/classifier.js +16 -7
- package/dist/documents/classifier.js.map +1 -1
- package/dist/documents/index.d.ts +4 -4
- package/dist/documents/index.js +3 -3
- package/dist/documents/service.d.ts +1 -1
- package/dist/documents/service.js +4 -4
- package/dist/email/index.d.ts +4 -4
- package/dist/email/index.js +4 -4
- package/dist/email/send.d.ts +1 -1
- package/dist/email/send.js +1 -1
- package/dist/email/senders.d.ts +1 -1
- package/dist/email/senders.js +2 -2
- package/dist/email/templates/index.d.ts +10 -10
- package/dist/email/templates/index.js +10 -10
- package/dist/email/templates/password-reset.js +1 -1
- package/dist/email/templates/payment-failed.js +1 -1
- package/dist/email/templates/quota-warning.js +1 -1
- package/dist/email/templates/subscription-confirmed.js +1 -1
- package/dist/email/templates/trial-expiry.js +1 -1
- package/dist/email/templates/trial-warning.js +1 -1
- package/dist/email/templates/verify-email.js +1 -1
- package/dist/email/templates/welcome.js +1 -1
- package/dist/email/templates/workspace-invitation.js +1 -1
- package/dist/identity/audit.d.ts +1 -1
- package/dist/identity/audit.js +3 -3
- package/dist/identity/index.d.ts +3 -3
- package/dist/identity/index.js +2 -2
- package/dist/identity/service.d.ts +10 -10
- package/dist/identity/service.js +12 -12
- package/dist/identity/types.d.ts +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/money.d.ts +112 -0
- package/dist/money.d.ts.map +1 -0
- package/dist/money.js +217 -0
- package/dist/money.js.map +1 -0
- package/dist/notifications/index.d.ts +3 -3
- package/dist/notifications/index.js +3 -3
- package/dist/notifications/triggers.js +2 -2
- package/dist/registry.d.ts +61 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +92 -0
- package/dist/registry.js.map +1 -0
- package/dist/request-context.d.ts +66 -0
- package/dist/request-context.d.ts.map +1 -0
- package/dist/request-context.js +99 -0
- package/dist/request-context.js.map +1 -0
- package/package.json +35 -10
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where request-scoped context comes from.
|
|
3
|
+
*
|
|
4
|
+
* `@intelligo-dev/auth` needs the incoming request's headers to resolve
|
|
5
|
+
* a session, and it got them by importing `next/headers` directly in
|
|
6
|
+
* five files. That made a package whose subject is authentication —
|
|
7
|
+
* not rendering — unusable outside Next: a queue worker that wants to
|
|
8
|
+
* check a session, a Hono API, a product on another framework, a test
|
|
9
|
+
* that is not running inside a request. ADR-0005 named the fix in its
|
|
10
|
+
* consequences; this is it.
|
|
11
|
+
*
|
|
12
|
+
* The framework asks for headers through `getRequestHeaders()`. The
|
|
13
|
+
* application says where they come from, once, from its composition
|
|
14
|
+
* root:
|
|
15
|
+
*
|
|
16
|
+
* import { setRequestContextSource } from "@intelligo-dev/core/request-context";
|
|
17
|
+
* import { nextRequestContext } from "@intelligo-dev/next";
|
|
18
|
+
*
|
|
19
|
+
* setRequestContextSource(nextRequestContext);
|
|
20
|
+
*
|
|
21
|
+
* `@intelligo-dev/next` is the only package in the framework that
|
|
22
|
+
* imports `next/*`, and an architecture test keeps it that way. This
|
|
23
|
+
* module imports nothing but `./registry`, so the contract is reachable
|
|
24
|
+
* from any runtime the adapter is not.
|
|
25
|
+
*
|
|
26
|
+
* Nothing self-registers. An unbound source throws where the headers
|
|
27
|
+
* are needed, naming the two lines that fix it — the alternative is a
|
|
28
|
+
* framework that guesses at the request, which is how a session gets
|
|
29
|
+
* read from the wrong one.
|
|
30
|
+
*/
|
|
31
|
+
import { createRegistryRef } from "./registry.js";
|
|
32
|
+
export class RequestContextUnavailableError extends Error {
|
|
33
|
+
constructor() {
|
|
34
|
+
super("No request context source is bound. Call setRequestContextSource() " +
|
|
35
|
+
"from your composition root — `nextRequestContext` from " +
|
|
36
|
+
"@intelligo-dev/next in a Next.js app — or wrap the call in " +
|
|
37
|
+
"withRequestHeaders() outside a request.");
|
|
38
|
+
this.code = "request_context_unavailable";
|
|
39
|
+
this.name = "RequestContextUnavailableError";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Held in the cross-instance registry rather than a module variable
|
|
44
|
+
* for the same reason every other framework registry is: a bundler
|
|
45
|
+
* that duplicates this module would otherwise give the composition
|
|
46
|
+
* root one copy and the request path another.
|
|
47
|
+
*/
|
|
48
|
+
const source = createRegistryRef("core/request-context-source", undefined);
|
|
49
|
+
/** Explicitly bound headers, for a call that is not inside a request. */
|
|
50
|
+
const override = createRegistryRef("core/request-headers-override", undefined);
|
|
51
|
+
export function setRequestContextSource(next) {
|
|
52
|
+
source.set(next);
|
|
53
|
+
}
|
|
54
|
+
/** Forget the bound source. For tests composing a fresh root. */
|
|
55
|
+
export function clearRequestContextSource() {
|
|
56
|
+
source.set(undefined);
|
|
57
|
+
override.set(undefined);
|
|
58
|
+
}
|
|
59
|
+
export function hasRequestContextSource() {
|
|
60
|
+
return source.get() !== undefined || override.get() !== undefined;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The current request's headers.
|
|
64
|
+
*
|
|
65
|
+
* @throws {RequestContextUnavailableError} when nothing is bound.
|
|
66
|
+
*/
|
|
67
|
+
export async function getRequestHeaders() {
|
|
68
|
+
const explicit = override.get();
|
|
69
|
+
if (explicit)
|
|
70
|
+
return explicit;
|
|
71
|
+
const resolve = source.get();
|
|
72
|
+
if (!resolve)
|
|
73
|
+
throw new RequestContextUnavailableError();
|
|
74
|
+
return await resolve();
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Run `fn` with these headers, whatever the ambient source says.
|
|
78
|
+
*
|
|
79
|
+
* For the callers that have a request but are not inside the
|
|
80
|
+
* framework's request scope: a background job replaying a webhook, a
|
|
81
|
+
* script acting as a user, an integration test that wants a real
|
|
82
|
+
* session without a server. Restores the previous value afterwards, so
|
|
83
|
+
* nesting behaves.
|
|
84
|
+
*
|
|
85
|
+
* Not `AsyncLocalStorage`: the value is set and restored around one
|
|
86
|
+
* awaited call, and ALS would make the package require a Node built-in
|
|
87
|
+
* that Edge runtimes only partly provide.
|
|
88
|
+
*/
|
|
89
|
+
export async function withRequestHeaders(headers, fn) {
|
|
90
|
+
const previous = override.get();
|
|
91
|
+
override.set(headers);
|
|
92
|
+
try {
|
|
93
|
+
return await fn();
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
override.set(previous);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=request-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-context.js","sourceRoot":"","sources":["../src/request-context.ts"],"names":[],"mappings":"AA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AM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAgB,EAChB,EAAwB;IAExB,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC;IAChC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtB,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,EAAE,CAAC;IACpB,CAAC;YAAS,CAAC;QACT,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intelligo-dev/core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.5",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -49,6 +49,18 @@
|
|
|
49
49
|
"types": "./dist/env.d.ts",
|
|
50
50
|
"default": "./dist/env.js"
|
|
51
51
|
},
|
|
52
|
+
"./registry": {
|
|
53
|
+
"types": "./dist/registry.d.ts",
|
|
54
|
+
"default": "./dist/registry.js"
|
|
55
|
+
},
|
|
56
|
+
"./money": {
|
|
57
|
+
"types": "./dist/money.d.ts",
|
|
58
|
+
"default": "./dist/money.js"
|
|
59
|
+
},
|
|
60
|
+
"./request-context": {
|
|
61
|
+
"types": "./dist/request-context.d.ts",
|
|
62
|
+
"default": "./dist/request-context.js"
|
|
63
|
+
},
|
|
52
64
|
"./logger": {
|
|
53
65
|
"types": "./dist/logger.d.ts",
|
|
54
66
|
"import": "./dist/logger.js",
|
|
@@ -59,16 +71,14 @@
|
|
|
59
71
|
"@neondatabase/serverless": "^0.10.4",
|
|
60
72
|
"@react-email/components": "^1.0.7",
|
|
61
73
|
"dotenv": "^16.4.7",
|
|
62
|
-
"drizzle-orm": "^0.45.1",
|
|
63
74
|
"pg": "^8.18.0",
|
|
64
75
|
"pino": "^10.3.1",
|
|
65
|
-
"
|
|
66
|
-
"resend": "^6.9.1",
|
|
67
|
-
"server-only": "^0.0.1",
|
|
68
|
-
"zod": "^3.24.1"
|
|
76
|
+
"resend": "^6.9.1"
|
|
69
77
|
},
|
|
70
78
|
"peerDependencies": {
|
|
71
|
-
"
|
|
79
|
+
"drizzle-orm": "^0.45.1",
|
|
80
|
+
"react": "^19.0.0",
|
|
81
|
+
"zod": "^3.24.1"
|
|
72
82
|
},
|
|
73
83
|
"devDependencies": {
|
|
74
84
|
"@types/bcryptjs": "^3.0.0",
|
|
@@ -76,18 +86,33 @@
|
|
|
76
86
|
"@types/react": "^19.0.10",
|
|
77
87
|
"bcryptjs": "^3.0.3",
|
|
78
88
|
"drizzle-kit": "^0.31.8",
|
|
89
|
+
"drizzle-orm": "^0.45.1",
|
|
79
90
|
"next": "^16.0.7",
|
|
80
91
|
"pino-pretty": "^13.1.3",
|
|
92
|
+
"react": "^19.0.0",
|
|
81
93
|
"tsx": "^4.21.0",
|
|
82
|
-
"typescript": "^5.7.2"
|
|
94
|
+
"typescript": "^5.7.2",
|
|
95
|
+
"zod": "^3.24.1"
|
|
83
96
|
},
|
|
84
97
|
"files": [
|
|
85
98
|
"dist",
|
|
86
|
-
"src/db/migrations"
|
|
99
|
+
"src/db/migrations",
|
|
100
|
+
"LICENSE",
|
|
101
|
+
"README.md",
|
|
102
|
+
"!dist/**/*.tsbuildinfo"
|
|
87
103
|
],
|
|
88
104
|
"publishConfig": {
|
|
89
105
|
"access": "public"
|
|
90
106
|
},
|
|
107
|
+
"peerDependenciesMeta": {
|
|
108
|
+
"react": {
|
|
109
|
+
"optional": true
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"engines": {
|
|
113
|
+
"node": ">=22"
|
|
114
|
+
},
|
|
115
|
+
"sideEffects": false,
|
|
91
116
|
"scripts": {
|
|
92
117
|
"type-check": "tsc --noEmit",
|
|
93
118
|
"lint": "eslint .",
|
|
@@ -96,6 +121,6 @@
|
|
|
96
121
|
"db:studio": "drizzle-kit studio",
|
|
97
122
|
"db:push": "drizzle-kit push",
|
|
98
123
|
"db:check": "tsx scripts/check-db.ts",
|
|
99
|
-
"build": "tsc -p tsconfig.build.json"
|
|
124
|
+
"build": "tsc -p tsconfig.build.json && node ../../scripts/fix-esm-extensions.mjs dist"
|
|
100
125
|
}
|
|
101
126
|
}
|