@memberjunction/ai-vectors-memory 5.33.0 → 5.34.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/index.d.ts CHANGED
@@ -3,4 +3,5 @@
3
3
  * @description In-memory vector similarity search service for MemberJunction
4
4
  */
5
5
  export { SimpleVectorService, VectorEntry, VectorSearchResult, DistanceMetric, ClusterResult } from './models/SimpleVectorService.js';
6
+ export { SimpleVectorDatabase, LoadSimpleVectorDatabase } from './models/SimpleVectorDatabase.js';
6
7
  //# 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"}
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"}
package/dist/index.js CHANGED
@@ -3,4 +3,5 @@
3
3
  * @description In-memory vector similarity search service for MemberJunction
4
4
  */
5
5
  export { SimpleVectorService } from './models/SimpleVectorService.js';
6
+ export { SimpleVectorDatabase, LoadSimpleVectorDatabase } from './models/SimpleVectorDatabase.js';
6
7
  //# 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"}
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"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * @fileoverview In-process VectorDBBase driver backed by a per-row column.
3
+ *
4
+ * Use this driver when you want SearchScope multi-provider fusion to include
5
+ * vector search WITHOUT standing up a remote store (Pinecone / pgvector /
6
+ * Qdrant). It reads the rows of a single MJ entity, parses each row's
7
+ * `EmbeddingVector` JSON column, and uses {@link SimpleVectorService} for
8
+ * cosine ranking — exactly the same primitive `AgentContextInjector` already
9
+ * uses for its `FindSimilarAgentNotes` path.
10
+ *
11
+ * **When NOT to use this driver:**
12
+ * - Production deployments with > a few thousand rows per entity. Cosine
13
+ * runs in JS over every row on every query; that scales linearly.
14
+ * - Multi-process deployments. Each process holds its own snapshot; updates
15
+ * in process A are not visible to process B.
16
+ * - Anywhere a real ANN index (HNSW / IVF) would matter.
17
+ *
18
+ * **When this driver is the right call:**
19
+ * - Single-tenant in-process workbench / dev environments.
20
+ * - Tests that need to exercise the SearchEngine vector code path without
21
+ * external dependencies.
22
+ * - Small-corpus production cases (e.g. agent-memory, configuration metadata).
23
+ *
24
+ * @module @memberjunction/ai-vectors-memory
25
+ */
26
+ import { UserInfo } from '@memberjunction/core';
27
+ import { VectorDBBase } from '@memberjunction/ai-vectordb';
28
+ import type { BaseRequestParams, BaseResponse, CreateIndexParams, EditIndexParams, IndexList, ListVectorIDsParams, ListVectorIDsResult, UpdateOptions, VectorRecord } from '@memberjunction/ai-vectordb';
29
+ import type { QueryOptions } from '@memberjunction/ai-vectordb';
30
+ export declare class SimpleVectorDatabase extends VectorDBBase {
31
+ /** Constructor accepts any non-empty string. The base class enforces
32
+ * non-empty for remote stores; in-memory has no real key, so the test
33
+ * setup uses a placeholder env var (e.g. AI_VENDOR_API_KEY__SIMPLEVECTORDATABASE=in-memory). */
34
+ /**
35
+ * In-process driver — no remote authentication. `VectorDBBase`'s base
36
+ * constructor rejects empty keys (designed for Pinecone/Qdrant which
37
+ * authenticate via API key), so we substitute a placeholder when the
38
+ * caller didn't provide one. This means deployments don't need to set
39
+ * `AI_VENDOR_API_KEY__SIMPLEVECTORDATABASE` for the driver to load.
40
+ */
41
+ constructor(apiKey?: string);
42
+ /** Look up the MJVectorIndex row by name and return its parsed config. */
43
+ private loadIndexConfig;
44
+ /** Materialize the index — load rows from the configured entity, parse
45
+ * each row's vector, and pack them into a `SimpleVectorService`.
46
+ *
47
+ * **Cache freshness model:** the cache key is `indexName` and the
48
+ * validity signal is `rowCount`. This means in-place edits of an
49
+ * existing row's `EmbeddingVector` (without changing the row count)
50
+ * are NOT detected by the cache — the stale vector will be returned
51
+ * until the process restarts or the row is deleted/inserted.
52
+ * This is acceptable for the dev/agent-memory positioning of this
53
+ * driver; production-scale corpora should use Pinecone/Qdrant. */
54
+ private loadIndex;
55
+ /** Run RunView for the configured entity; returns null if the entity is
56
+ * unknown or the RunView call failed (both already logged). */
57
+ private fetchEntityRows;
58
+ /** Parse each row's vector field, validate it's a numeric array, and
59
+ * pack the survivors into a fresh `SimpleVectorService` plus the
60
+ * ID→row map used to enrich match metadata. Rows with missing IDs,
61
+ * missing vector columns, or unparseable JSON are silently skipped
62
+ * — callers haven't necessarily embedded every row yet (e.g. only
63
+ * `Status='Active'` rows have embeddings), so logging would spam. */
64
+ private buildServiceFromRows;
65
+ /** Build the metadata bag returned in QueryIndex matches. Mirrors what
66
+ * Pinecone/Qdrant return so {@link VectorSearchProvider.convertMatches}
67
+ * can consume it without special-casing. */
68
+ private buildMatchMetadata;
69
+ QueryIndex(params: QueryOptions, contextUser?: UserInfo): Promise<BaseResponse>;
70
+ ListIndexes(): IndexList;
71
+ GetIndex(_p: BaseRequestParams): BaseResponse;
72
+ CreateIndex(_p: CreateIndexParams): BaseResponse;
73
+ DeleteIndex(_p: BaseRequestParams): BaseResponse;
74
+ EditIndex(_p: EditIndexParams): BaseResponse;
75
+ CreateRecord(_r: VectorRecord): BaseResponse;
76
+ CreateRecords(_r: VectorRecord[]): BaseResponse;
77
+ GetRecord(_p: BaseRequestParams): BaseResponse;
78
+ GetRecords(_p: BaseRequestParams): BaseResponse;
79
+ UpdateRecord(_r: UpdateOptions): BaseResponse;
80
+ UpdateRecords(_r: UpdateOptions): BaseResponse;
81
+ DeleteRecord(_r: VectorRecord): BaseResponse;
82
+ DeleteRecords(_r: VectorRecord[]): BaseResponse;
83
+ DeleteAllRecords(_n: string): BaseResponse;
84
+ ListVectorIDs(_p: ListVectorIDsParams): Promise<ListVectorIDsResult>;
85
+ private unsupported;
86
+ }
87
+ /** Tree-shake hook. Import this from a top-level entry point if the
88
+ * bundler doesn't pick up the @RegisterClass side-effect automatically. */
89
+ export declare function LoadSimpleVectorDatabase(): void;
90
+ //# sourceMappingURL=SimpleVectorDatabase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimpleVectorDatabase.d.ts","sourceRoot":"","sources":["../../src/models/SimpleVectorDatabase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAA0C,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EACR,iBAAiB,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EACnE,SAAS,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,aAAa,EAAE,YAAY,EACnF,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AA+BhE,qBACa,oBAAqB,SAAQ,YAAY;IAClD;;qGAEiG;IACjG;;;;;;OAMG;gBACS,MAAM,CAAC,EAAE,MAAM;IAE3B,0EAA0E;YAC5D,eAAe;IAyC7B;;;;;;;;;uEASmE;YACrD,SAAS;IAqBvB;oEACgE;YAClD,eAAe;IAsB7B;;;;;0EAKsE;IACtE,OAAO,CAAC,oBAAoB;IAyB5B;;iDAE6C;IAC7C,OAAO,CAAC,kBAAkB;IAmBb,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IAyCrF,WAAW,IAAI,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,iBAAiB,GAAG,YAAY;IAC7C,WAAW,CAAC,EAAE,EAAE,iBAAiB,GAAG,YAAY;IAChD,WAAW,CAAC,EAAE,EAAE,iBAAiB,GAAG,YAAY;IAChD,SAAS,CAAC,EAAE,EAAE,eAAe,GAAG,YAAY;IAC5C,YAAY,CAAC,EAAE,EAAE,YAAY,GAAG,YAAY;IAC5C,aAAa,CAAC,EAAE,EAAE,YAAY,EAAE,GAAG,YAAY;IAC/C,SAAS,CAAC,EAAE,EAAE,iBAAiB,GAAG,YAAY;IAC9C,UAAU,CAAC,EAAE,EAAE,iBAAiB,GAAG,YAAY;IAC/C,YAAY,CAAC,EAAE,EAAE,aAAa,GAAG,YAAY;IAC7C,aAAa,CAAC,EAAE,EAAE,aAAa,GAAG,YAAY;IAC9C,YAAY,CAAC,EAAE,EAAE,YAAY,GAAG,YAAY;IAC5C,aAAa,CAAC,EAAE,EAAE,YAAY,EAAE,GAAG,YAAY;IAC/C,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY;IAI1C,aAAa,CAAC,EAAE,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI3E,OAAO,CAAC,WAAW;CAOtB;AAED;4EAC4E;AAC5E,wBAAgB,wBAAwB,IAAI,IAAI,CAG/C"}
@@ -0,0 +1,272 @@
1
+ /**
2
+ * @fileoverview In-process VectorDBBase driver backed by a per-row column.
3
+ *
4
+ * Use this driver when you want SearchScope multi-provider fusion to include
5
+ * vector search WITHOUT standing up a remote store (Pinecone / pgvector /
6
+ * Qdrant). It reads the rows of a single MJ entity, parses each row's
7
+ * `EmbeddingVector` JSON column, and uses {@link SimpleVectorService} for
8
+ * cosine ranking — exactly the same primitive `AgentContextInjector` already
9
+ * uses for its `FindSimilarAgentNotes` path.
10
+ *
11
+ * **When NOT to use this driver:**
12
+ * - Production deployments with > a few thousand rows per entity. Cosine
13
+ * runs in JS over every row on every query; that scales linearly.
14
+ * - Multi-process deployments. Each process holds its own snapshot; updates
15
+ * in process A are not visible to process B.
16
+ * - Anywhere a real ANN index (HNSW / IVF) would matter.
17
+ *
18
+ * **When this driver is the right call:**
19
+ * - Single-tenant in-process workbench / dev environments.
20
+ * - Tests that need to exercise the SearchEngine vector code path without
21
+ * external dependencies.
22
+ * - Small-corpus production cases (e.g. agent-memory, configuration metadata).
23
+ *
24
+ * @module @memberjunction/ai-vectors-memory
25
+ */
26
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
27
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
28
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
29
+ 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;
30
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
31
+ };
32
+ var __metadata = (this && this.__metadata) || function (k, v) {
33
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
34
+ };
35
+ import { RegisterClass } from '@memberjunction/global';
36
+ import { Metadata, RunView, LogError, LogStatus } from '@memberjunction/core';
37
+ import { VectorDBBase } from '@memberjunction/ai-vectordb';
38
+ import { SimpleVectorService } from './SimpleVectorService.js';
39
+ /**
40
+ * Per-call cache of (indexName → loaded entity rows + parsed vectors).
41
+ * Lives at module scope so repeated queries inside one process don't re-read
42
+ * the DB. Cleared on `DeleteAllRecords` or when the entity row count changes.
43
+ */
44
+ const indexCache = new Map();
45
+ let SimpleVectorDatabase = class SimpleVectorDatabase extends VectorDBBase {
46
+ /** Constructor accepts any non-empty string. The base class enforces
47
+ * non-empty for remote stores; in-memory has no real key, so the test
48
+ * setup uses a placeholder env var (e.g. AI_VENDOR_API_KEY__SIMPLEVECTORDATABASE=in-memory). */
49
+ /**
50
+ * In-process driver — no remote authentication. `VectorDBBase`'s base
51
+ * constructor rejects empty keys (designed for Pinecone/Qdrant which
52
+ * authenticate via API key), so we substitute a placeholder when the
53
+ * caller didn't provide one. This means deployments don't need to set
54
+ * `AI_VENDOR_API_KEY__SIMPLEVECTORDATABASE` for the driver to load.
55
+ */
56
+ constructor(apiKey) { super(apiKey && apiKey.trim().length > 0 ? apiKey : 'in-memory-no-auth'); }
57
+ /** Look up the MJVectorIndex row by name and return its parsed config. */
58
+ async loadIndexConfig(indexName, contextUser) {
59
+ const rv = new RunView();
60
+ const r = await rv.RunView({
61
+ EntityName: 'MJ: Vector Indexes',
62
+ ExtraFilter: `Name='${indexName.replace(/'/g, "''")}'`,
63
+ Fields: ['ID', 'ProviderConfig'],
64
+ ResultType: 'simple',
65
+ MaxRows: 1,
66
+ }, contextUser);
67
+ if (!r.Success) {
68
+ LogError(`SimpleVectorDatabase.loadIndexConfig: RunView failed for "${indexName}": ${r.ErrorMessage}`);
69
+ return null;
70
+ }
71
+ if ((r.Results?.length ?? 0) === 0) {
72
+ LogError(`SimpleVectorDatabase.loadIndexConfig: no MJVectorIndex row with Name="${indexName}"`);
73
+ return null;
74
+ }
75
+ const cfgRaw = r.Results[0].ProviderConfig;
76
+ if (!cfgRaw) {
77
+ LogError(`SimpleVectorDatabase.loadIndexConfig: index "${indexName}" exists but ProviderConfig is empty`);
78
+ return null;
79
+ }
80
+ try {
81
+ const parsed = JSON.parse(cfgRaw);
82
+ if (!parsed.entityName || !parsed.vectorField) {
83
+ LogError(`SimpleVectorDatabase.loadIndexConfig: index "${indexName}" ProviderConfig missing entityName/vectorField`);
84
+ return null;
85
+ }
86
+ return {
87
+ entityName: parsed.entityName,
88
+ vectorField: parsed.vectorField,
89
+ filter: parsed.filter,
90
+ titleField: parsed.titleField,
91
+ snippetField: parsed.snippetField,
92
+ };
93
+ }
94
+ catch (e) {
95
+ LogError(`SimpleVectorDatabase.loadIndexConfig: index "${indexName}" ProviderConfig JSON parse failed: ${e instanceof Error ? e.message : String(e)}`);
96
+ return null;
97
+ }
98
+ }
99
+ /** Materialize the index — load rows from the configured entity, parse
100
+ * each row's vector, and pack them into a `SimpleVectorService`.
101
+ *
102
+ * **Cache freshness model:** the cache key is `indexName` and the
103
+ * validity signal is `rowCount`. This means in-place edits of an
104
+ * existing row's `EmbeddingVector` (without changing the row count)
105
+ * are NOT detected by the cache — the stale vector will be returned
106
+ * until the process restarts or the row is deleted/inserted.
107
+ * This is acceptable for the dev/agent-memory positioning of this
108
+ * driver; production-scale corpora should use Pinecone/Qdrant. */
109
+ async loadIndex(indexName, contextUser) {
110
+ const config = await this.loadIndexConfig(indexName, contextUser);
111
+ if (!config)
112
+ return null;
113
+ const rows = await this.fetchEntityRows(config, contextUser);
114
+ if (rows == null)
115
+ return null;
116
+ const cached = indexCache.get(indexName);
117
+ if (cached && cached.rowCount === rows.length) {
118
+ return { config: cached.config, service: cached.service, rowsByID: cached.rowsByID };
119
+ }
120
+ const { service, rowsByID } = this.buildServiceFromRows(rows, config);
121
+ indexCache.set(indexName, { config, service, rowCount: rows.length, rowsByID });
122
+ return { config, service, rowsByID };
123
+ }
124
+ /** Run RunView for the configured entity; returns null if the entity is
125
+ * unknown or the RunView call failed (both already logged). */
126
+ async fetchEntityRows(config, contextUser) {
127
+ const md = new Metadata(); // global-provider-ok: VectorDBBase has no per-request provider context; entity lookup is read-only metadata access
128
+ const entity = md.Entities.find(e => e.Name === config.entityName);
129
+ if (!entity)
130
+ return null;
131
+ const rv = new RunView();
132
+ const r = await rv.RunView({
133
+ EntityName: config.entityName,
134
+ ExtraFilter: config.filter,
135
+ ResultType: 'simple',
136
+ BypassCache: true,
137
+ }, contextUser);
138
+ if (!r.Success) {
139
+ LogError(`SimpleVectorDatabase.loadIndex: RunView on "${config.entityName}" failed: ${r.ErrorMessage}`);
140
+ return null;
141
+ }
142
+ return r.Results ?? [];
143
+ }
144
+ /** Parse each row's vector field, validate it's a numeric array, and
145
+ * pack the survivors into a fresh `SimpleVectorService` plus the
146
+ * ID→row map used to enrich match metadata. Rows with missing IDs,
147
+ * missing vector columns, or unparseable JSON are silently skipped
148
+ * — callers haven't necessarily embedded every row yet (e.g. only
149
+ * `Status='Active'` rows have embeddings), so logging would spam. */
150
+ buildServiceFromRows(rows, config) {
151
+ const service = new SimpleVectorService();
152
+ const entries = [];
153
+ const rowsByID = new Map();
154
+ for (const row of rows) {
155
+ const id = String(row['ID'] ?? '');
156
+ const vecRaw = row[config.vectorField];
157
+ if (!id || !vecRaw)
158
+ continue;
159
+ try {
160
+ const vector = typeof vecRaw === 'string' ? JSON.parse(vecRaw) : vecRaw;
161
+ if (Array.isArray(vector) && vector.every(v => typeof v === 'number')) {
162
+ entries.push({ key: id, vector: vector, metadata: row });
163
+ rowsByID.set(id, row);
164
+ }
165
+ }
166
+ catch {
167
+ // Vector column is unparseable — silently skip (see JSDoc above).
168
+ }
169
+ }
170
+ service.LoadVectors(entries);
171
+ return { service, rowsByID };
172
+ }
173
+ /** Build the metadata bag returned in QueryIndex matches. Mirrors what
174
+ * Pinecone/Qdrant return so {@link VectorSearchProvider.convertMatches}
175
+ * can consume it without special-casing. */
176
+ buildMatchMetadata(row, config) {
177
+ const meta = {
178
+ Entity: config.entityName,
179
+ // RecordID in CompositeKey URL format ("ID|<value>") so VectorSearchProvider's
180
+ // CompositeKey parser treats it the same as a Pinecone-stored ID.
181
+ RecordID: `ID|${String(row['ID'] ?? '')}`,
182
+ };
183
+ if (config.titleField && row[config.titleField] != null) {
184
+ meta['Title'] = String(row[config.titleField]);
185
+ }
186
+ if (config.snippetField && row[config.snippetField] != null) {
187
+ meta['Snippet'] = String(row[config.snippetField]);
188
+ }
189
+ if (row['__mj_UpdatedAt'] != null)
190
+ meta['__mj_UpdatedAt'] = row['__mj_UpdatedAt'];
191
+ return meta;
192
+ }
193
+ // ── VectorDBBase implementation ────────────────────────────────────────
194
+ async QueryIndex(params, contextUser) {
195
+ // VectorSearchProvider invokes QueryIndex with both `id` (the index
196
+ // name to query) and `vector` (the query embedding). This doesn't
197
+ // fit cleanly into either QueryByRecordId or QueryByVectorValues
198
+ // taken alone — the union members don't share `id`+`vector`. We
199
+ // narrow via property-existence to handle both fields.
200
+ const p = params;
201
+ const indexName = String(p.id ?? '');
202
+ const queryVector = p.vector;
203
+ const topK = Number(p.topK ?? 10);
204
+ // contextUser is required for RunView's server-side guard. Remote
205
+ // drivers (Pinecone/Qdrant) ignore it; in-process drivers like this
206
+ // one need it to honor row-level security on the source entity.
207
+ if (!indexName || !Array.isArray(queryVector)) {
208
+ LogError(`SimpleVectorDatabase.QueryIndex: missing indexName="${indexName}" or vector (length ${Array.isArray(queryVector) ? queryVector.length : 'n/a'})`);
209
+ return { success: false, message: 'Missing indexName or vector', data: null };
210
+ }
211
+ const loaded = await this.loadIndex(indexName, contextUser);
212
+ if (!loaded) {
213
+ // loadIndex / loadIndexConfig already logged the specific failure reason
214
+ return { success: false, message: `Index "${indexName}" not configured`, data: null };
215
+ }
216
+ LogStatus(`SimpleVectorDatabase.QueryIndex: index="${indexName}" loaded ${loaded.service.Size} vectors, querying topK=${topK}`);
217
+ const matches = loaded.service.FindNearest(queryVector, topK, 0);
218
+ return {
219
+ success: true,
220
+ message: `Returned ${matches.length} match(es)`,
221
+ data: {
222
+ matches: matches.map(m => ({
223
+ id: m.key,
224
+ score: m.score,
225
+ metadata: this.buildMatchMetadata(loaded.rowsByID.get(m.key) ?? {}, loaded.config),
226
+ })),
227
+ },
228
+ };
229
+ }
230
+ // The remaining VectorDBBase methods are not exercised by the SearchEngine
231
+ // path. They throw so any caller that mistakenly uses this driver for
232
+ // ingestion gets a clear signal to use the real Pinecone/pgvector driver.
233
+ ListIndexes() { return { indexes: [] }; }
234
+ GetIndex(_p) { return this.unsupported('GetIndex'); }
235
+ CreateIndex(_p) { return this.unsupported('CreateIndex'); }
236
+ DeleteIndex(_p) { return this.unsupported('DeleteIndex'); }
237
+ EditIndex(_p) { return this.unsupported('EditIndex'); }
238
+ CreateRecord(_r) { return this.unsupported('CreateRecord'); }
239
+ CreateRecords(_r) { return this.unsupported('CreateRecords'); }
240
+ GetRecord(_p) { return this.unsupported('GetRecord'); }
241
+ GetRecords(_p) { return this.unsupported('GetRecords'); }
242
+ UpdateRecord(_r) { return this.unsupported('UpdateRecord'); }
243
+ UpdateRecords(_r) { return this.unsupported('UpdateRecords'); }
244
+ DeleteRecord(_r) { return this.unsupported('DeleteRecord'); }
245
+ DeleteRecords(_r) { return this.unsupported('DeleteRecords'); }
246
+ DeleteAllRecords(_n) {
247
+ indexCache.clear();
248
+ return { success: true, message: 'cache cleared', data: null };
249
+ }
250
+ ListVectorIDs(_p) {
251
+ return Promise.resolve({ IDs: [], NextCursor: undefined });
252
+ }
253
+ unsupported(name) {
254
+ return {
255
+ success: false,
256
+ message: `SimpleVectorDatabase does not support ${name} — embeddings are read directly from the entity row's vector column. Use Pinecone/pgvector/Qdrant for ingestion.`,
257
+ data: null,
258
+ };
259
+ }
260
+ };
261
+ SimpleVectorDatabase = __decorate([
262
+ RegisterClass(VectorDBBase, 'SimpleVectorDatabase'),
263
+ __metadata("design:paramtypes", [String])
264
+ ], SimpleVectorDatabase);
265
+ export { SimpleVectorDatabase };
266
+ /** Tree-shake hook. Import this from a top-level entry point if the
267
+ * bundler doesn't pick up the @RegisterClass side-effect automatically. */
268
+ export function LoadSimpleVectorDatabase() {
269
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
270
+ const _ref = SimpleVectorDatabase;
271
+ }
272
+ //# sourceMappingURL=SimpleVectorDatabase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimpleVectorDatabase.js","sourceRoot":"","sources":["../../src/models/SimpleVectorDatabase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CAAC,CAAC;IAC1F,aAAa,CAAC,EAAiB,IAAkB,OAAO,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC5F,YAAY,CAAC,EAAgB,IAAkB,OAAO,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IACzF,aAAa,CAAC,EAAkB,IAAkB,OAAO,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC7F,gBAAgB,CAAC,EAAU;QAC9B,UAAU,CAAC,KAAK,EAAE,CAAC;QACnB,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,yCAAyC,IAAI,kHAAkH;YACxK,IAAI,EAAE,IAAI;SACb,CAAC;IACN,CAAC;CACJ,CAAA;AAxOY,oBAAoB;IADhC,aAAa,CAAC,YAAY,EAAE,sBAAsB,CAAC;;GACvC,oBAAoB,CAwOhC;;AAED;4EAC4E;AAC5E,MAAM,UAAU,wBAAwB;IACpC,6DAA6D;IAC7D,MAAM,IAAI,GAAG,oBAAoB,CAAC;AACtC,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.33.0",
4
+ "version": "5.34.0",
5
5
  "description": "MemberJunction: AI Vectors In-Memory Utilities",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -17,8 +17,9 @@
17
17
  "author": "MemberJunction.com",
18
18
  "license": "ISC",
19
19
  "dependencies": {
20
- "@memberjunction/core": "5.33.0",
21
- "@memberjunction/global": "5.33.0"
20
+ "@memberjunction/ai-vectordb": "5.34.0",
21
+ "@memberjunction/core": "5.34.0",
22
+ "@memberjunction/global": "5.34.0"
22
23
  },
23
24
  "devDependencies": {
24
25
  "@types/node": "24.10.11",