@query-farm/vgi 0.21.0 → 0.22.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/src/worker.ts CHANGED
@@ -65,6 +65,14 @@ export interface WorkerConfig {
65
65
  /** Factory that receives the built ReadOnlyCatalogInterface and returns a custom catalog. */
66
66
  catalogInterfaceFactory?: (base: ReadOnlyCatalogInterface) => CatalogInterface;
67
67
  catalogName?: string;
68
+ /**
69
+ * Registry to dispatch through. Pass the same instance used to build a
70
+ * pre-constructed `catalogInterface` — catalogs record which schema (and
71
+ * catalog) declares each function on the registry they are given, and
72
+ * schema-qualified resolution only works if that is the registry the worker
73
+ * dispatches on. Omit to have the worker create its own.
74
+ */
75
+ registry?: FunctionRegistry;
68
76
  }
69
77
 
70
78
  export class Worker {
@@ -73,7 +81,10 @@ export class Worker {
73
81
  private _catalogName?: string;
74
82
 
75
83
  constructor(config: WorkerConfig) {
76
- this._registry = new FunctionRegistry();
84
+ // Reuse the caller's registry when given: a catalogInterface built
85
+ // elsewhere recorded its per-schema function ownership there, and that
86
+ // index is what makes a schema-qualified bind resolve correctly.
87
+ this._registry = config.registry ?? new FunctionRegistry();
77
88
  this._catalogName = config.catalogName;
78
89
 
79
90
  // Register explicit functions
@@ -89,6 +100,9 @@ export class Worker {
89
100
  if (schema.functions) {
90
101
  for (const func of schema.functions) {
91
102
  this._registry.register(func);
103
+ // Also index by owning schema + catalog so a schema-qualified bind
104
+ // resolves when one name is declared in more than one schema.
105
+ this._registry.registerInSchema(func, schema.name, config.catalog.name);
92
106
  }
93
107
  }
94
108
  }