ont-run 0.0.4 → 0.0.6

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.
@@ -1,84 +1,11 @@
1
- import { join, dirname, isAbsolute } from "path";
2
- import { existsSync } from "fs";
3
- import type { ResolverFunction, ResolverContext, OntologyConfig } from "../config/types.js";
1
+ import type { ResolverFunction } from "../config/types.js";
4
2
 
5
3
  /**
6
- * Cache of loaded resolvers to avoid re-importing
4
+ * Get a resolver function. Since resolvers are now passed directly as functions,
5
+ * this is a simple passthrough that could be removed in the future.
7
6
  */
8
- const resolverCache = new Map<string, ResolverFunction>();
9
-
10
- /**
11
- * Load a resolver from a file path.
12
- * The path is relative to the config file location.
13
- *
14
- * @param resolverPath - Path to the resolver file (relative to configDir)
15
- * @param configDir - Directory containing the ontology.config.ts
16
- */
17
- export async function loadResolver(
18
- resolverPath: string,
19
- configDir: string
20
- ): Promise<ResolverFunction> {
21
- // Resolve the full path
22
- const fullPath = isAbsolute(resolverPath)
23
- ? resolverPath
24
- : join(configDir, resolverPath);
25
-
26
- // Check cache
27
- if (resolverCache.has(fullPath)) {
28
- return resolverCache.get(fullPath)!;
29
- }
30
-
31
- try {
32
- // Dynamic import the resolver
33
- const module = await import(fullPath);
34
-
35
- // Expect default export to be the resolver function
36
- const resolver = module.default;
37
-
38
- if (typeof resolver !== "function") {
39
- throw new Error(
40
- `Resolver at ${resolverPath} must export a default function`
41
- );
42
- }
43
-
44
- // Cache and return
45
- resolverCache.set(fullPath, resolver);
46
- return resolver;
47
- } catch (error) {
48
- if ((error as NodeJS.ErrnoException).code === "ERR_MODULE_NOT_FOUND") {
49
- throw new Error(`Resolver not found: ${resolverPath}`);
50
- }
51
- throw error;
52
- }
53
- }
54
-
55
- /**
56
- * Clear the resolver cache (useful for hot reloading)
57
- */
58
- export function clearResolverCache(): void {
59
- resolverCache.clear();
60
- }
61
-
62
- /**
63
- * Check which resolvers are missing and return their paths
64
- */
65
- export function findMissingResolvers(
66
- config: OntologyConfig,
67
- configDir: string
68
- ): string[] {
69
- const missing: string[] = [];
70
-
71
- for (const [name, fn] of Object.entries(config.functions)) {
72
- const fullPath = isAbsolute(fn.resolver)
73
- ? fn.resolver
74
- : join(configDir, fn.resolver);
75
-
76
- if (!existsSync(fullPath)) {
77
- missing.push(fn.resolver);
78
- }
79
- }
80
-
81
- return missing;
7
+ export function loadResolver(resolver: ResolverFunction): ResolverFunction {
8
+ return resolver;
82
9
  }
83
10
 
84
11
  /**
@@ -121,7 +121,6 @@ export async function startOnt(options: StartOntOptions = {}): Promise<StartOntR
121
121
  if (!mcpOnly) {
122
122
  const api = createApiApp({
123
123
  config,
124
- configDir,
125
124
  env,
126
125
  });
127
126
 
@@ -144,7 +143,6 @@ export async function startOnt(options: StartOntOptions = {}): Promise<StartOntR
144
143
  if (!apiOnly) {
145
144
  const mcpServer = await startMcpServer({
146
145
  config,
147
- configDir,
148
146
  env,
149
147
  port: mcpPort,
150
148
  });