@ekairos/events 1.22.46-beta.development.0 → 1.22.48-beta.development.0
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/dist/context.config.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type ContextEnvironment = Record<string, unknown>;
|
|
|
4
4
|
export type ContextRuntime = {
|
|
5
5
|
store: ContextStore;
|
|
6
6
|
db: any;
|
|
7
|
+
env?: ContextEnvironment;
|
|
7
8
|
domain?: ConcreteDomain<any, any>;
|
|
8
9
|
};
|
|
9
|
-
export declare function coerceContextRuntime(value: any): Promise<ContextRuntime>;
|
|
10
|
+
export declare function coerceContextRuntime(value: any, env?: ContextEnvironment): Promise<ContextRuntime>;
|
package/dist/context.config.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
const runtimeByDb = new WeakMap();
|
|
2
|
-
export async function coerceContextRuntime(value) {
|
|
2
|
+
export async function coerceContextRuntime(value, env) {
|
|
3
3
|
if (!value) {
|
|
4
4
|
throw new Error("Context runtime resolver returned no value.");
|
|
5
5
|
}
|
|
6
|
+
const resolvedEnv = env ??
|
|
7
|
+
(typeof value === "object" && value !== null
|
|
8
|
+
? value.env
|
|
9
|
+
: undefined);
|
|
6
10
|
if (typeof value === "object" && value.store) {
|
|
7
|
-
return value;
|
|
11
|
+
return resolvedEnv ? { ...value, env: resolvedEnv } : value;
|
|
8
12
|
}
|
|
9
13
|
const dbCandidate = typeof value === "object" && value !== null && "db" in value
|
|
10
14
|
? value.db
|
|
@@ -15,12 +19,13 @@ export async function coerceContextRuntime(value) {
|
|
|
15
19
|
if (typeof dbCandidate === "object" && dbCandidate !== null) {
|
|
16
20
|
const cached = runtimeByDb.get(dbCandidate);
|
|
17
21
|
if (cached)
|
|
18
|
-
return cached;
|
|
22
|
+
return resolvedEnv ? { ...cached, env: resolvedEnv } : cached;
|
|
19
23
|
}
|
|
20
24
|
const { InstantStore } = await import("./stores/instant.store.js");
|
|
21
25
|
const runtime = {
|
|
22
26
|
store: new InstantStore(dbCandidate),
|
|
23
27
|
db: dbCandidate,
|
|
28
|
+
env: resolvedEnv,
|
|
24
29
|
domain: typeof value === "object" ? value.domain : undefined,
|
|
25
30
|
};
|
|
26
31
|
if (typeof dbCandidate === "object" && dbCandidate !== null) {
|
|
@@ -4,7 +4,11 @@ import type { ContextEnvironment } from "./context.config.js";
|
|
|
4
4
|
import type { ContextStore } from "./context.store.js";
|
|
5
5
|
import { eventsDomain } from "./schema.js";
|
|
6
6
|
export type ContextRuntime<Env extends ContextEnvironment = ContextEnvironment> = EkairosRuntime<Env, any, any>;
|
|
7
|
-
export type ContextRuntimeServiceHandle =
|
|
7
|
+
export type ContextRuntimeServiceHandle = {
|
|
8
|
+
db: any | ((...args: any[]) => Promise<any> | any);
|
|
9
|
+
resolve?: (...args: any[]) => Promise<any> | any;
|
|
10
|
+
meta?: (...args: any[]) => Record<string, unknown> | undefined;
|
|
11
|
+
};
|
|
8
12
|
export type ContextRuntimeHandleForDomain<Env extends ContextEnvironment = ContextEnvironment, RequiredDomain extends DomainSchemaResult = typeof eventsDomain> = ContextRuntimeServiceHandle & {
|
|
9
13
|
use<Subdomain extends typeof eventsDomain | RequiredDomain>(subdomain: Subdomain, options?: RuntimeResolveOptions): Promise<Omit<ActiveDomain<Subdomain, Env>, "env">>;
|
|
10
14
|
};
|
package/dist/context.runtime.js
CHANGED
|
@@ -3,7 +3,11 @@ function asRecord(value) {
|
|
|
3
3
|
return value && typeof value === "object" ? value : {};
|
|
4
4
|
}
|
|
5
5
|
export async function getContextRuntimeServices(runtime) {
|
|
6
|
-
const
|
|
6
|
+
const runtimeRecord = asRecord(runtime);
|
|
7
|
+
const dbMember = runtimeRecord.db;
|
|
8
|
+
const db = typeof dbMember === "function"
|
|
9
|
+
? await dbMember.call(runtime)
|
|
10
|
+
: dbMember;
|
|
7
11
|
if (!db) {
|
|
8
12
|
throw new Error("Context runtime did not provide a database instance.");
|
|
9
13
|
}
|
|
@@ -15,9 +19,17 @@ export async function getContextRuntimeServices(runtime) {
|
|
|
15
19
|
storeByDb.set(db, store);
|
|
16
20
|
}
|
|
17
21
|
}
|
|
18
|
-
const
|
|
22
|
+
const resolveMember = runtimeRecord.resolve;
|
|
23
|
+
const resolved = typeof resolveMember === "function"
|
|
24
|
+
? await resolveMember.call(runtime)
|
|
25
|
+
: runtime;
|
|
19
26
|
const resolvedMeta = asRecord(resolved).meta;
|
|
20
|
-
const
|
|
27
|
+
const ownMeta = runtimeRecord.meta;
|
|
28
|
+
const meta = typeof resolvedMeta === "function"
|
|
29
|
+
? resolvedMeta.call(resolved)
|
|
30
|
+
: typeof ownMeta === "function"
|
|
31
|
+
? ownMeta.call(runtime)
|
|
32
|
+
: undefined;
|
|
21
33
|
const domain = asRecord(meta).domain;
|
|
22
34
|
return {
|
|
23
35
|
db,
|
package/dist/runtime.step.js
CHANGED
|
@@ -3,5 +3,5 @@ import { eventsDomain } from "./schema.js";
|
|
|
3
3
|
export async function getContextRuntime(env) {
|
|
4
4
|
const { resolveRuntime } = await import("@ekairos/domain/runtime");
|
|
5
5
|
const resolved = await resolveRuntime(eventsDomain, env);
|
|
6
|
-
return await coerceContextRuntime(resolved);
|
|
6
|
+
return await coerceContextRuntime(resolved, env);
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekairos/events",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.48-beta.development.0",
|
|
4
4
|
"description": "Ekairos Events - Context-first workflow runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
},
|
|
128
128
|
"dependencies": {
|
|
129
129
|
"@ai-sdk/openai": "^2.0.52",
|
|
130
|
-
"@ekairos/domain": "^1.22.
|
|
130
|
+
"@ekairos/domain": "^1.22.48-beta.development.0",
|
|
131
131
|
"@instantdb/admin": "0.22.158",
|
|
132
132
|
"@instantdb/core": "0.22.142",
|
|
133
133
|
"@vercel/mcp-adapter": "^1.0.0",
|