@memberjunction/ai-vectors-memory 5.38.0 → 5.39.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/README.md CHANGED
@@ -328,12 +328,42 @@ results.forEach(r => {
328
328
 
329
329
  **Memory usage**: approximately `8 bytes * dimensions + ~100 bytes` per vector. Example: 10,000 vectors at 384 dimensions is roughly 31 MB.
330
330
 
331
+ ## VectorDBBase Providers
332
+
333
+ This package ships **two `VectorDBBase` driver implementations** so the in-memory primitive can be consumed by the broader vector-sync / EntityDocument infrastructure without standing up a remote store:
334
+
335
+ ### `SimpleVectorDatabase`
336
+
337
+ In-process VectorDBBase driver that reads from an `MJ: Vector Indexes` row configured to point at any entity and field. Use when you have arbitrary entity rows with embeddings stored in a column and want to make them queryable through the `SearchEngine` cross-scope fusion path.
338
+
339
+ ### `SimpleVectorServiceProvider` (new in v5.38)
340
+
341
+ **EntityDocument-keyed** in-process driver, purpose-built for `Provider.SearchEntities()` and any other `EntityDocument`-backed search. Each "index" corresponds to one `MJ: Entity Documents` row; vectors come from `MJ: Entity Record Documents.VectorJSON` filtered by `EntityDocumentID`, and matches surface the **underlying entity record's RecordID** in their metadata (not the EntityRecordDocument PK).
342
+
343
+ ```typescript
344
+ import { SimpleVectorServiceProvider } from '@memberjunction/ai-vectors-memory';
345
+
346
+ const provider = new SimpleVectorServiceProvider();
347
+ const result = await provider.QueryIndex(
348
+ { id: entityDocumentId, vector: queryEmbedding, topK: 10 },
349
+ contextUser
350
+ );
351
+ // result.data.matches[i].metadata.RecordID is the parent record's ID
352
+ ```
353
+
354
+ **Lazy cache:** `Map<EntityDocumentID, LoadedIndex>` with TTL eviction (default 15 minutes). After the vector-sync pipeline writes back fresh embeddings, call `SimpleVectorServiceProvider.InvalidateIndex(entityDocumentId)` for deterministic cache refresh; TTL is the safety net.
355
+
356
+ **Read-only:** ingestion methods (`CreateRecord`, `UpdateRecord`, etc.) throw via the `unsupported()` path. The vector-sync pipeline writes `EntityRecordDocument.VectorJSON` directly; this driver just rehydrates from those rows.
357
+
358
+ **When NOT to use:** > a few thousand `EntityRecordDocument` rows per `EntityDocument`, multi-process deployments, scenarios that need a real ANN index (HNSW / IVF). For those, configure a remote provider (Pinecone, Qdrant, pgvector) on the `EntityDocument`'s `VectorDatabaseID` instead.
359
+
331
360
  ## Dependencies
332
361
 
333
362
  | Package | Purpose |
334
363
  |---|---|
335
- | `@memberjunction/core` | `LogError` for error reporting |
336
- | `@memberjunction/global` | Global utilities |
364
+ | `@memberjunction/core` | `LogError`, `RunView`, `UserInfo` |
365
+ | `@memberjunction/global` | `RegisterClass` for VectorDBBase registrations |
366
+ | `@memberjunction/ai-vectordb` | `VectorDBBase` contract that the two providers implement |
337
367
 
338
368
  This package has minimal dependencies, making it lightweight and suitable for both server-side and client-side use.
339
369
 
package/dist/index.d.ts CHANGED
@@ -4,4 +4,5 @@
4
4
  */
5
5
  export { SimpleVectorService, VectorEntry, VectorSearchResult, DistanceMetric, ClusterResult } from './models/SimpleVectorService.js';
6
6
  export { SimpleVectorDatabase, LoadSimpleVectorDatabase } from './models/SimpleVectorDatabase.js';
7
+ export { SimpleVectorServiceProvider, SimpleVectorIndexCache, LoadSimpleVectorServiceProvider } from './models/SimpleVectorServiceProvider.js';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,aAAa,EACd,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,aAAa,EACd,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAC/F,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC"}
package/dist/index.js CHANGED
@@ -4,4 +4,5 @@
4
4
  */
5
5
  export { SimpleVectorService } from './models/SimpleVectorService.js';
6
6
  export { SimpleVectorDatabase, LoadSimpleVectorDatabase } from './models/SimpleVectorDatabase.js';
7
+ export { SimpleVectorServiceProvider, SimpleVectorIndexCache, LoadSimpleVectorServiceProvider } from './models/SimpleVectorServiceProvider.js';
7
8
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,mBAAmB,EAKpB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,mBAAmB,EAKpB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAC/F,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC"}
@@ -0,0 +1,170 @@
1
+ /**
2
+ * @fileoverview EntityDocument-keyed in-process VectorDBBase driver.
3
+ *
4
+ * Where {@link SimpleVectorDatabase} reads from an `MJ: Vector Indexes` row
5
+ * configured to point at any entity, **this** driver is purpose-built for
6
+ * `EntityDocument`-backed search: each "index" corresponds to one
7
+ * `MJ: Entity Documents` row, vectors are loaded from
8
+ * `MJ: Entity Record Documents.VectorJSON` filtered by `EntityDocumentID`,
9
+ * and matches surface the **underlying entity record's RecordID** in their
10
+ * metadata (not the EntityRecordDocument PK).
11
+ *
12
+ * This is the bridge that lets `Provider.SearchEntities()` query the existing
13
+ * `EntityDocument` / `EntityRecordDocument` pipeline through the standard
14
+ * `VectorDBBase` contract, without standing up a remote vector store.
15
+ *
16
+ * **Cache:** held on the `SimpleVectorIndexCache` singleton (BaseSingleton-based)
17
+ * so every `SimpleVectorServiceProvider` instance in the process — and every
18
+ * bundler-duplicated copy of this module — shares one Map of loaded indexes.
19
+ * The cache:
20
+ *
21
+ * - Dedupes concurrent cold loads (the first caller installs an in-flight
22
+ * Promise; later callers await the same one — no duplicate DB reads or
23
+ * vector-pool builds).
24
+ * - Subscribes once to `BaseEntity` save/delete events for
25
+ * `MJ: Entity Record Documents` and invalidates the affected
26
+ * EntityDocumentID automatically — manual fixes, ad-hoc imports, and
27
+ * anything that goes through `BaseEntity.Save()` invalidates without the
28
+ * sync pipeline needing to remember to call `InvalidateIndex`.
29
+ * - Honors a TTL as a safety net for non-BaseEntity writes.
30
+ *
31
+ * **When NOT to use this driver:** > a few thousand `EntityRecordDocument`
32
+ * rows per `EntityDocument`, multi-process deployments, scenarios that need
33
+ * a real ANN index.
34
+ *
35
+ * @module @memberjunction/ai-vectors-memory
36
+ */
37
+ import { BaseSingleton } from '@memberjunction/global';
38
+ import { UserInfo } from '@memberjunction/core';
39
+ import { VectorDBBase } from '@memberjunction/ai-vectordb';
40
+ import type { BaseRequestParams, BaseResponse, CreateIndexParams, EditIndexParams, IndexList, ListVectorIDsParams, ListVectorIDsResult, UpdateOptions, VectorRecord } from '@memberjunction/ai-vectordb';
41
+ import type { QueryOptions } from '@memberjunction/ai-vectordb';
42
+ import { SimpleVectorService } from './SimpleVectorService.js';
43
+ /**
44
+ * Internal shape of a loaded EntityDocument index. The `service` holds the
45
+ * in-memory vector pool keyed by EntityRecordDocument.ID; `recordIdsByDocId`
46
+ * maps EntityRecordDocument.ID → parent entity's RecordID so QueryIndex can
47
+ * surface the underlying record ID in match metadata.
48
+ */
49
+ interface LoadedIndex {
50
+ service: SimpleVectorService;
51
+ recordIdsByDocId: Map<string, string>;
52
+ loadedAt: number;
53
+ }
54
+ /**
55
+ * BaseSingleton-backed cache for `SimpleVectorServiceProvider`. Holds the
56
+ * per-EntityDocument index pool plus the in-flight Promise map used to dedupe
57
+ * cold loads, and subscribes once to BaseEntity events so cache entries
58
+ * invalidate automatically when underlying EntityRecordDocument rows change.
59
+ *
60
+ * The provider class itself (`SimpleVectorServiceProvider`) remains a
61
+ * non-singleton — callers can `new` one freely and they all delegate to this
62
+ * shared cache. That separation matches the existing VectorDBBase contract
63
+ * while giving us process-wide cache coherence.
64
+ */
65
+ export declare class SimpleVectorIndexCache extends BaseSingleton<SimpleVectorIndexCache> {
66
+ private indexCache;
67
+ private inFlightLoads;
68
+ private ttlMs;
69
+ private subscribedToBaseEntityEvents;
70
+ protected constructor();
71
+ static get Instance(): SimpleVectorIndexCache;
72
+ get TtlMs(): number;
73
+ set TtlMs(value: number);
74
+ get Size(): number;
75
+ /**
76
+ * Get the cached index (or load it). Concurrent callers asking for the
77
+ * same EntityDocumentID before the first load completes share the same
78
+ * Promise — only one DB read and vector-pool build happens.
79
+ */
80
+ GetOrLoad(entityDocumentId: string, contextUser: UserInfo | undefined, loader: () => Promise<LoadedIndex | null>): Promise<LoadedIndex | null>;
81
+ Invalidate(entityDocumentId: string): void;
82
+ InvalidateAll(): void;
83
+ /**
84
+ * Subscribe to BaseEntity save/delete events and invalidate the affected
85
+ * EntityDocument index when an `MJ: Entity Record Documents` row changes.
86
+ * Idempotent — only subscribes once per singleton instance.
87
+ */
88
+ private subscribeToBaseEntityEvents;
89
+ }
90
+ /**
91
+ * In-process VectorDBBase driver that loads embeddings from
92
+ * `MJ: Entity Record Documents.VectorJSON` rows associated with a given
93
+ * `EntityDocumentID`.
94
+ *
95
+ * Callers pass the EntityDocumentID as the `id` field of `QueryIndex` params:
96
+ *
97
+ * ```typescript
98
+ * provider.QueryIndex({ id: entityDocumentId, vector: queryEmbedding, topK: 10 }, contextUser);
99
+ * ```
100
+ *
101
+ * Multiple instances share one cache via {@link SimpleVectorIndexCache}.
102
+ */
103
+ export declare class SimpleVectorServiceProvider extends VectorDBBase {
104
+ /**
105
+ * Static accessor preserved for back-compat with existing callers. Delegates
106
+ * to the underlying singleton.
107
+ */
108
+ static get TtlMs(): number;
109
+ static set TtlMs(value: number);
110
+ /**
111
+ * In-process driver — no remote auth. Same placeholder fallback as
112
+ * {@link SimpleVectorDatabase}: the base constructor rejects empty keys,
113
+ * which makes sense for Pinecone/Qdrant but not for an in-memory provider.
114
+ */
115
+ constructor(apiKey?: string);
116
+ /** SVS reads vectors out of `MJ: Entity Record Documents.VectorJSON`; it
117
+ * intentionally does not implement `CreateRecord(s)`. Flagging this lets
118
+ * ingestion pipelines short-circuit the upsert call instead of logging
119
+ * spurious "unsupported" errors per batch. */
120
+ get IsReadOnly(): boolean;
121
+ /**
122
+ * Drop a cached index. The BaseEntity event subscription handles this
123
+ * automatically for `Save()` / `Delete()` paths; call this manually only
124
+ * when writing VectorJSON via a path that bypasses BaseEntity (raw SQL,
125
+ * the sync pipeline's bulk inserts, etc.).
126
+ */
127
+ static InvalidateIndex(entityDocumentId: string): void;
128
+ /** Drop ALL cached indexes. Used in tests and after global re-syncs. */
129
+ static InvalidateAll(): void;
130
+ /** Expose the cache size for diagnostics / tests. */
131
+ static get CacheSize(): number;
132
+ /**
133
+ * Load (or reload after TTL) the vector pool for an `EntityDocumentID`.
134
+ * Returns null when the EntityDocument has no embedded records yet — the
135
+ * caller treats this as an empty result rather than an error so a
136
+ * freshly-installed system without a sync run yet just returns nothing.
137
+ *
138
+ * Concurrent calls for the same `entityDocumentId` while a load is in
139
+ * flight share the in-flight Promise via {@link SimpleVectorIndexCache}.
140
+ */
141
+ private loadIndex;
142
+ /**
143
+ * Run cosine search over the cached vector pool for the supplied
144
+ * EntityDocumentID. Match objects surface the parent entity's RecordID
145
+ * under `metadata.RecordID` so callers can map results back without
146
+ * a second lookup.
147
+ */
148
+ QueryIndex(params: QueryOptions, contextUser?: UserInfo): Promise<BaseResponse>;
149
+ ListIndexes(): IndexList;
150
+ GetIndex(_p: BaseRequestParams): BaseResponse;
151
+ CreateIndex(_p: CreateIndexParams): BaseResponse;
152
+ DeleteIndex(_p: BaseRequestParams): BaseResponse;
153
+ EditIndex(_p: EditIndexParams): BaseResponse;
154
+ CreateRecord(_r: VectorRecord): BaseResponse;
155
+ CreateRecords(_r: VectorRecord[]): BaseResponse;
156
+ GetRecord(_p: BaseRequestParams): BaseResponse;
157
+ GetRecords(_p: BaseRequestParams): BaseResponse;
158
+ UpdateRecord(_r: UpdateOptions): BaseResponse;
159
+ UpdateRecords(_r: UpdateOptions): BaseResponse;
160
+ DeleteRecord(_r: VectorRecord): BaseResponse;
161
+ DeleteRecords(_r: VectorRecord[]): BaseResponse;
162
+ DeleteAllRecords(_n: string): BaseResponse;
163
+ ListVectorIDs(_p: ListVectorIDsParams): Promise<ListVectorIDsResult>;
164
+ private unsupported;
165
+ }
166
+ /** Tree-shaking prevention export — call from a module-level location that
167
+ * is always loaded so the class registration runs. */
168
+ export declare function LoadSimpleVectorServiceProvider(): void;
169
+ export {};
170
+ //# sourceMappingURL=SimpleVectorServiceProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimpleVectorServiceProvider.d.ts","sourceRoot":"","sources":["../../src/models/SimpleVectorServiceProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,aAAa,EAAwC,MAAM,wBAAwB,CAAC;AAC7F,OAAO,EAAkD,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EACR,iBAAiB,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EACnE,SAAS,EAAE,mBAAmB,E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I,IAAI,CAEtD"}
@@ -0,0 +1,346 @@
1
+ /**
2
+ * @fileoverview EntityDocument-keyed in-process VectorDBBase driver.
3
+ *
4
+ * Where {@link SimpleVectorDatabase} reads from an `MJ: Vector Indexes` row
5
+ * configured to point at any entity, **this** driver is purpose-built for
6
+ * `EntityDocument`-backed search: each "index" corresponds to one
7
+ * `MJ: Entity Documents` row, vectors are loaded from
8
+ * `MJ: Entity Record Documents.VectorJSON` filtered by `EntityDocumentID`,
9
+ * and matches surface the **underlying entity record's RecordID** in their
10
+ * metadata (not the EntityRecordDocument PK).
11
+ *
12
+ * This is the bridge that lets `Provider.SearchEntities()` query the existing
13
+ * `EntityDocument` / `EntityRecordDocument` pipeline through the standard
14
+ * `VectorDBBase` contract, without standing up a remote vector store.
15
+ *
16
+ * **Cache:** held on the `SimpleVectorIndexCache` singleton (BaseSingleton-based)
17
+ * so every `SimpleVectorServiceProvider` instance in the process — and every
18
+ * bundler-duplicated copy of this module — shares one Map of loaded indexes.
19
+ * The cache:
20
+ *
21
+ * - Dedupes concurrent cold loads (the first caller installs an in-flight
22
+ * Promise; later callers await the same one — no duplicate DB reads or
23
+ * vector-pool builds).
24
+ * - Subscribes once to `BaseEntity` save/delete events for
25
+ * `MJ: Entity Record Documents` and invalidates the affected
26
+ * EntityDocumentID automatically — manual fixes, ad-hoc imports, and
27
+ * anything that goes through `BaseEntity.Save()` invalidates without the
28
+ * sync pipeline needing to remember to call `InvalidateIndex`.
29
+ * - Honors a TTL as a safety net for non-BaseEntity writes.
30
+ *
31
+ * **When NOT to use this driver:** > a few thousand `EntityRecordDocument`
32
+ * rows per `EntityDocument`, multi-process deployments, scenarios that need
33
+ * a real ANN index.
34
+ *
35
+ * @module @memberjunction/ai-vectors-memory
36
+ */
37
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
38
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
39
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
40
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
41
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
42
+ };
43
+ var __metadata = (this && this.__metadata) || function (k, v) {
44
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
45
+ };
46
+ var SimpleVectorServiceProvider_1;
47
+ import { BaseSingleton, MJEventType, MJGlobal, RegisterClass } from '@memberjunction/global';
48
+ import { BaseEntity, LogError, RunView } from '@memberjunction/core';
49
+ import { VectorDBBase } from '@memberjunction/ai-vectordb';
50
+ import { SimpleVectorService } from './SimpleVectorService.js';
51
+ /**
52
+ * Default TTL (ms) before a cached index is considered stale and reloaded
53
+ * on the next query. The BaseEntity event subscription invalidates affected
54
+ * indexes the moment an `EntityRecordDocument` row is saved/deleted; TTL is
55
+ * just the safety net for writes that bypass BaseEntity (raw SQL, external
56
+ * tools).
57
+ */
58
+ const DEFAULT_TTL_MS = 15 * 60 * 1000; // 15 minutes
59
+ /**
60
+ * BaseSingleton-backed cache for `SimpleVectorServiceProvider`. Holds the
61
+ * per-EntityDocument index pool plus the in-flight Promise map used to dedupe
62
+ * cold loads, and subscribes once to BaseEntity events so cache entries
63
+ * invalidate automatically when underlying EntityRecordDocument rows change.
64
+ *
65
+ * The provider class itself (`SimpleVectorServiceProvider`) remains a
66
+ * non-singleton — callers can `new` one freely and they all delegate to this
67
+ * shared cache. That separation matches the existing VectorDBBase contract
68
+ * while giving us process-wide cache coherence.
69
+ */
70
+ export class SimpleVectorIndexCache extends BaseSingleton {
71
+ constructor() {
72
+ super();
73
+ this.indexCache = new Map();
74
+ this.inFlightLoads = new Map();
75
+ this.ttlMs = DEFAULT_TTL_MS;
76
+ this.subscribedToBaseEntityEvents = false;
77
+ // Wire BaseEntity event subscription exactly once per process.
78
+ this.subscribeToBaseEntityEvents();
79
+ }
80
+ static get Instance() {
81
+ return super.getInstance();
82
+ }
83
+ get TtlMs() { return this.ttlMs; }
84
+ set TtlMs(value) { this.ttlMs = value; }
85
+ get Size() { return this.indexCache.size; }
86
+ /**
87
+ * Get the cached index (or load it). Concurrent callers asking for the
88
+ * same EntityDocumentID before the first load completes share the same
89
+ * Promise — only one DB read and vector-pool build happens.
90
+ */
91
+ async GetOrLoad(entityDocumentId, contextUser, loader) {
92
+ const now = Date.now();
93
+ const cached = this.indexCache.get(entityDocumentId);
94
+ if (cached && (now - cached.loadedAt) < this.ttlMs) {
95
+ return cached;
96
+ }
97
+ // Dedupe: if another caller is already loading, return their Promise.
98
+ const existing = this.inFlightLoads.get(entityDocumentId);
99
+ if (existing)
100
+ return existing;
101
+ const p = (async () => {
102
+ try {
103
+ const loaded = await loader();
104
+ if (loaded) {
105
+ this.indexCache.set(entityDocumentId, loaded);
106
+ }
107
+ return loaded;
108
+ }
109
+ finally {
110
+ // Always clear in-flight slot, success or failure, so the next
111
+ // caller can retry on failure instead of being stuck with a
112
+ // resolved-null Promise forever.
113
+ this.inFlightLoads.delete(entityDocumentId);
114
+ }
115
+ })();
116
+ this.inFlightLoads.set(entityDocumentId, p);
117
+ // Suppress unhandled rejection warning if no awaiter exists at throw time.
118
+ p.catch(() => { });
119
+ return p;
120
+ }
121
+ Invalidate(entityDocumentId) {
122
+ this.indexCache.delete(entityDocumentId);
123
+ // Don't drop in-flight loads — let any in-progress caller complete and
124
+ // we'll just discard their result on the next read (TTL handles it).
125
+ // Aggressively cancelling would race with concurrent QueryIndex calls.
126
+ }
127
+ InvalidateAll() {
128
+ this.indexCache.clear();
129
+ }
130
+ /**
131
+ * Subscribe to BaseEntity save/delete events and invalidate the affected
132
+ * EntityDocument index when an `MJ: Entity Record Documents` row changes.
133
+ * Idempotent — only subscribes once per singleton instance.
134
+ */
135
+ subscribeToBaseEntityEvents() {
136
+ if (this.subscribedToBaseEntityEvents)
137
+ return;
138
+ this.subscribedToBaseEntityEvents = true;
139
+ try {
140
+ MJGlobal.Instance.GetEventListener(false).subscribe((mjEvent) => {
141
+ if (mjEvent.event !== MJEventType.ComponentEvent)
142
+ return;
143
+ if (mjEvent.eventCode !== BaseEntity.BaseEventCode)
144
+ return;
145
+ const ev = mjEvent.args;
146
+ if (!ev)
147
+ return;
148
+ if (ev.type !== 'save' && ev.type !== 'delete' && ev.type !== 'remote-invalidate')
149
+ return;
150
+ const entityName = ev.baseEntity?.EntityInfo?.Name ?? ev.entityName;
151
+ if (entityName !== 'MJ: Entity Record Documents')
152
+ return;
153
+ // Pull EntityDocumentID off the affected row. On save/delete the
154
+ // BaseEntity is hydrated; on remote-invalidate we may have only
155
+ // the entity name, in which case we conservatively drop ALL
156
+ // cached indexes (small price for correctness — TTL would have
157
+ // expired them within 15 min anyway).
158
+ if (ev.baseEntity) {
159
+ const docId = ev.baseEntity.Get('EntityDocumentID');
160
+ if (typeof docId === 'string' && docId.length > 0) {
161
+ this.Invalidate(docId);
162
+ }
163
+ }
164
+ else {
165
+ this.InvalidateAll();
166
+ }
167
+ });
168
+ }
169
+ catch (e) {
170
+ // Subscription is best-effort — falling back to TTL is fine.
171
+ LogError(`SimpleVectorIndexCache: failed to subscribe to BaseEntity events: ${e instanceof Error ? e.message : String(e)}`);
172
+ }
173
+ }
174
+ }
175
+ /**
176
+ * In-process VectorDBBase driver that loads embeddings from
177
+ * `MJ: Entity Record Documents.VectorJSON` rows associated with a given
178
+ * `EntityDocumentID`.
179
+ *
180
+ * Callers pass the EntityDocumentID as the `id` field of `QueryIndex` params:
181
+ *
182
+ * ```typescript
183
+ * provider.QueryIndex({ id: entityDocumentId, vector: queryEmbedding, topK: 10 }, contextUser);
184
+ * ```
185
+ *
186
+ * Multiple instances share one cache via {@link SimpleVectorIndexCache}.
187
+ */
188
+ let SimpleVectorServiceProvider = SimpleVectorServiceProvider_1 = class SimpleVectorServiceProvider extends VectorDBBase {
189
+ /**
190
+ * Static accessor preserved for back-compat with existing callers. Delegates
191
+ * to the underlying singleton.
192
+ */
193
+ static get TtlMs() { return SimpleVectorIndexCache.Instance.TtlMs; }
194
+ static set TtlMs(value) { SimpleVectorIndexCache.Instance.TtlMs = value; }
195
+ /**
196
+ * In-process driver — no remote auth. Same placeholder fallback as
197
+ * {@link SimpleVectorDatabase}: the base constructor rejects empty keys,
198
+ * which makes sense for Pinecone/Qdrant but not for an in-memory provider.
199
+ */
200
+ constructor(apiKey) { super(apiKey && apiKey.trim().length > 0 ? apiKey : 'in-memory-no-auth'); }
201
+ /** SVS reads vectors out of `MJ: Entity Record Documents.VectorJSON`; it
202
+ * intentionally does not implement `CreateRecord(s)`. Flagging this lets
203
+ * ingestion pipelines short-circuit the upsert call instead of logging
204
+ * spurious "unsupported" errors per batch. */
205
+ get IsReadOnly() {
206
+ return true;
207
+ }
208
+ /**
209
+ * Drop a cached index. The BaseEntity event subscription handles this
210
+ * automatically for `Save()` / `Delete()` paths; call this manually only
211
+ * when writing VectorJSON via a path that bypasses BaseEntity (raw SQL,
212
+ * the sync pipeline's bulk inserts, etc.).
213
+ */
214
+ static InvalidateIndex(entityDocumentId) {
215
+ SimpleVectorIndexCache.Instance.Invalidate(entityDocumentId);
216
+ }
217
+ /** Drop ALL cached indexes. Used in tests and after global re-syncs. */
218
+ static InvalidateAll() {
219
+ SimpleVectorIndexCache.Instance.InvalidateAll();
220
+ }
221
+ /** Expose the cache size for diagnostics / tests. */
222
+ static get CacheSize() {
223
+ return SimpleVectorIndexCache.Instance.Size;
224
+ }
225
+ /**
226
+ * Load (or reload after TTL) the vector pool for an `EntityDocumentID`.
227
+ * Returns null when the EntityDocument has no embedded records yet — the
228
+ * caller treats this as an empty result rather than an error so a
229
+ * freshly-installed system without a sync run yet just returns nothing.
230
+ *
231
+ * Concurrent calls for the same `entityDocumentId` while a load is in
232
+ * flight share the in-flight Promise via {@link SimpleVectorIndexCache}.
233
+ */
234
+ loadIndex(entityDocumentId, contextUser) {
235
+ return SimpleVectorIndexCache.Instance.GetOrLoad(entityDocumentId, contextUser, async () => {
236
+ const rv = new RunView();
237
+ const r = await rv.RunView({
238
+ EntityName: 'MJ: Entity Record Documents',
239
+ ExtraFilter: `EntityDocumentID='${entityDocumentId.replace(/'/g, "''")}' AND VectorJSON IS NOT NULL`,
240
+ Fields: ['ID', 'RecordID', 'VectorJSON'],
241
+ ResultType: 'simple',
242
+ }, contextUser);
243
+ if (!r.Success) {
244
+ LogError(`SimpleVectorServiceProvider.loadIndex: RunView failed for EntityDocumentID="${entityDocumentId}": ${r.ErrorMessage}`);
245
+ return null;
246
+ }
247
+ const service = new SimpleVectorService();
248
+ const recordIdsByDocId = new Map();
249
+ const entries = [];
250
+ for (const row of r.Results ?? []) {
251
+ if (!row.ID || !row.RecordID || !row.VectorJSON)
252
+ continue;
253
+ try {
254
+ const parsed = JSON.parse(row.VectorJSON);
255
+ if (!Array.isArray(parsed) || !parsed.every(v => typeof v === 'number'))
256
+ continue;
257
+ entries.push({ key: row.ID, vector: parsed, metadata: { RecordID: row.RecordID } });
258
+ recordIdsByDocId.set(row.ID, row.RecordID);
259
+ }
260
+ catch {
261
+ // Skip rows with unparseable VectorJSON — likely stale/corrupted; sync will fix
262
+ }
263
+ }
264
+ service.LoadVectors(entries);
265
+ return { service, recordIdsByDocId, loadedAt: Date.now() };
266
+ });
267
+ }
268
+ // ── VectorDBBase implementation ──────────────────────────────────────────
269
+ /**
270
+ * Run cosine search over the cached vector pool for the supplied
271
+ * EntityDocumentID. Match objects surface the parent entity's RecordID
272
+ * under `metadata.RecordID` so callers can map results back without
273
+ * a second lookup.
274
+ */
275
+ async QueryIndex(params, contextUser) {
276
+ const p = params;
277
+ const entityDocumentId = String(p.id ?? '');
278
+ const queryVector = p.vector;
279
+ const topK = Number(p.topK ?? 10);
280
+ if (!entityDocumentId || !Array.isArray(queryVector)) {
281
+ return { success: false, message: 'Missing EntityDocumentID or query vector', data: null };
282
+ }
283
+ const loaded = await this.loadIndex(entityDocumentId, contextUser);
284
+ if (!loaded) {
285
+ return { success: false, message: `Failed to load index for EntityDocumentID="${entityDocumentId}"`, data: null };
286
+ }
287
+ if (loaded.service.Size === 0) {
288
+ // Freshly-installed system without any embeddings yet — return empty,
289
+ // not error. Caller can fall back to lexical-only ranking.
290
+ return { success: true, message: 'No embedded records yet', data: { matches: [] } };
291
+ }
292
+ const matches = loaded.service.FindNearest(queryVector, topK, 0);
293
+ return {
294
+ success: true,
295
+ message: `Returned ${matches.length} match(es)`,
296
+ data: {
297
+ matches: matches.map(m => ({
298
+ id: m.key, // EntityRecordDocument.ID
299
+ score: m.score,
300
+ metadata: { RecordID: loaded.recordIdsByDocId.get(m.key) ?? null },
301
+ })),
302
+ },
303
+ };
304
+ }
305
+ // Read-only driver: ingestion methods throw. The actual ingestion happens
306
+ // through the vector-sync pipeline which writes EntityRecordDocument rows
307
+ // directly — this provider just rehydrates from those rows.
308
+ ListIndexes() { return { indexes: [] }; }
309
+ GetIndex(_p) { return this.unsupported('GetIndex'); }
310
+ CreateIndex(_p) { return this.unsupported('CreateIndex'); }
311
+ DeleteIndex(_p) { return this.unsupported('DeleteIndex'); }
312
+ EditIndex(_p) { return this.unsupported('EditIndex'); }
313
+ CreateRecord(_r) { return this.unsupported('CreateRecord'); }
314
+ CreateRecords(_r) { return this.unsupported('CreateRecords'); }
315
+ GetRecord(_p) { return this.unsupported('GetRecord'); }
316
+ GetRecords(_p) { return this.unsupported('GetRecords'); }
317
+ UpdateRecord(_r) { return this.unsupported('UpdateRecord'); }
318
+ UpdateRecords(_r) { return this.unsupported('UpdateRecords'); }
319
+ DeleteRecord(_r) { return this.unsupported('DeleteRecord'); }
320
+ DeleteRecords(_r) { return this.unsupported('DeleteRecords'); }
321
+ DeleteAllRecords(_n) {
322
+ SimpleVectorServiceProvider_1.InvalidateAll();
323
+ return { success: true, message: 'cache cleared', data: null };
324
+ }
325
+ ListVectorIDs(_p) {
326
+ return Promise.resolve({ IDs: [], NextCursor: undefined });
327
+ }
328
+ unsupported(name) {
329
+ return {
330
+ success: false,
331
+ message: `SimpleVectorServiceProvider does not support ${name} — embeddings are read directly from MJ: Entity Record Documents.VectorJSON. Use the vector-sync pipeline (or a remote VectorDB provider) for ingestion.`,
332
+ data: null,
333
+ };
334
+ }
335
+ };
336
+ SimpleVectorServiceProvider = SimpleVectorServiceProvider_1 = __decorate([
337
+ RegisterClass(VectorDBBase, 'SimpleVectorServiceProvider'),
338
+ __metadata("design:paramtypes", [String])
339
+ ], SimpleVectorServiceProvider);
340
+ export { SimpleVectorServiceProvider };
341
+ /** Tree-shaking prevention export — call from a module-level location that
342
+ * is always loaded so the class registration runs. */
343
+ export function LoadSimpleVectorServiceProvider() {
344
+ // intentionally empty
345
+ }
346
+ //# sourceMappingURL=SimpleVectorServiceProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimpleVectorServiceProvider.js","sourceRoot":"","sources":["../../src/models/SimpleVectorServiceProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;;;;;;;;;;AAEH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAmB,QAAQ,EAAE,OAAO,EAAY,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAM3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAc5D;;;;;;GAMG;AACH,MAAM,cAAc,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAEpD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,sBAAuB,SAAQ,aAAqC;IAM7E;QACI,KAAK,EAAE,CAAC;QANJ,eAAU,GAAG,IAAI,GAAG,EAAuB,CAAC;QAC5C,kBAAa,GAAG,IAAI,GAAG,EAAuC,CAAC;QAC/D,UAAK,GAAG,cAAc,CAAC;QACvB,iCAA4B,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B,CAAC,aAAa,EAAE,CAAC;QAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACnE,CAAC;IACM,aAAa,CAAC,EAAuB;QACxC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC;IAC/D,CAAC;IAEO,WAAW,CAAC,IAAY;QAC5B,OAAO;YACH,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,gDAAgD,IAAI,0JAA0J;YACvN,IAAI,EAAE,IAAI;SACb,CAAC;IACN,CAAC;CACJ,CAAA;AAnKY,2BAA2B;IADvC,aAAa,CAAC,YAAY,EAAE,6BAA6B,CAAC;;GAC9C,2BAA2B,CAmKvC;;AAED;uDACuD;AACvD,MAAM,UAAU,+BAA+B;IAC3C,sBAAsB;AAC1B,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@memberjunction/ai-vectors-memory",
3
3
  "type": "module",
4
- "version": "5.38.0",
4
+ "version": "5.39.0",
5
5
  "description": "MemberJunction: AI Vectors In-Memory Utilities",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -17,9 +17,9 @@
17
17
  "author": "MemberJunction.com",
18
18
  "license": "ISC",
19
19
  "dependencies": {
20
- "@memberjunction/ai-vectordb": "5.38.0",
21
- "@memberjunction/core": "5.38.0",
22
- "@memberjunction/global": "5.38.0"
20
+ "@memberjunction/ai-vectordb": "5.39.0",
21
+ "@memberjunction/core": "5.39.0",
22
+ "@memberjunction/global": "5.39.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "24.10.11",