@danielsimonjr/memoryjs 2.6.0 → 2.8.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/cli/index.js +65 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +198 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +162 -1
- package/dist/index.d.ts +162 -1
- package/dist/index.js +195 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -1557,6 +1557,17 @@ var init_WorkerPoolManager = __esm({
|
|
|
1557
1557
|
}
|
|
1558
1558
|
});
|
|
1559
1559
|
|
|
1560
|
+
// src/utils/WorkerTaskManager.ts
|
|
1561
|
+
var init_WorkerTaskManager = __esm({
|
|
1562
|
+
"src/utils/WorkerTaskManager.ts"() {
|
|
1563
|
+
"use strict";
|
|
1564
|
+
init_esm_shims();
|
|
1565
|
+
init_taskScheduler();
|
|
1566
|
+
init_WorkerPoolManager();
|
|
1567
|
+
init_logger();
|
|
1568
|
+
}
|
|
1569
|
+
});
|
|
1570
|
+
|
|
1560
1571
|
// src/utils/BatchProcessor.ts
|
|
1561
1572
|
var init_BatchProcessor = __esm({
|
|
1562
1573
|
"src/utils/BatchProcessor.ts"() {
|
|
@@ -2003,6 +2014,7 @@ var init_utils = __esm({
|
|
|
2003
2014
|
init_taskScheduler();
|
|
2004
2015
|
init_operationUtils();
|
|
2005
2016
|
init_WorkerPoolManager();
|
|
2017
|
+
init_WorkerTaskManager();
|
|
2006
2018
|
init_BatchProcessor();
|
|
2007
2019
|
init_MemoryMonitor();
|
|
2008
2020
|
init_relationHelpers();
|
|
@@ -9122,6 +9134,27 @@ CREATE INDEX IF NOT EXISTS idx_entities_project_id ON entities(project_id);
|
|
|
9122
9134
|
CREATE INDEX IF NOT EXISTS idx_entities_content_hash ON entities(content_hash);
|
|
9123
9135
|
CREATE INDEX IF NOT EXISTS idx_entities_tags_gin ON entities USING GIN(tags);
|
|
9124
9136
|
|
|
9137
|
+
-- v2.8.0 \u2014 generated tsvector column for full-text search.
|
|
9138
|
+
-- name is weighted A (highest), observations B, tags C. PostgreSQL 12+
|
|
9139
|
+
-- supports GENERATED ALWAYS AS ... STORED; the DO block makes the column
|
|
9140
|
+
-- add idempotent on older + newer servers without requiring CREATE OR
|
|
9141
|
+
-- REPLACE semantics on ALTER.
|
|
9142
|
+
DO $$ BEGIN
|
|
9143
|
+
IF NOT EXISTS (
|
|
9144
|
+
SELECT 1 FROM information_schema.columns
|
|
9145
|
+
WHERE table_name = 'entities' AND column_name = 'fts_vector'
|
|
9146
|
+
) THEN
|
|
9147
|
+
ALTER TABLE entities ADD COLUMN fts_vector tsvector
|
|
9148
|
+
GENERATED ALWAYS AS (
|
|
9149
|
+
setweight(to_tsvector('english', name), 'A') ||
|
|
9150
|
+
setweight(to_tsvector('english', coalesce(array_to_string(observations, ' '), '')), 'B') ||
|
|
9151
|
+
setweight(to_tsvector('english', coalesce(array_to_string(tags, ' '), '')), 'C')
|
|
9152
|
+
) STORED;
|
|
9153
|
+
END IF;
|
|
9154
|
+
END $$;
|
|
9155
|
+
|
|
9156
|
+
CREATE INDEX IF NOT EXISTS idx_entities_fts_gin ON entities USING GIN(fts_vector);
|
|
9157
|
+
|
|
9125
9158
|
CREATE TABLE IF NOT EXISTS relations (
|
|
9126
9159
|
from_name TEXT NOT NULL,
|
|
9127
9160
|
to_name TEXT NOT NULL,
|
|
@@ -9441,6 +9474,38 @@ CREATE INDEX IF NOT EXISTS idx_relations_type ON relations(relation_type);
|
|
|
9441
9474
|
hasRelations(entityName) {
|
|
9442
9475
|
return (this.outgoingRelations.get(entityName)?.length ?? 0) + (this.incomingRelations.get(entityName)?.length ?? 0) > 0;
|
|
9443
9476
|
}
|
|
9477
|
+
// ==================== Full-text search ====================
|
|
9478
|
+
/**
|
|
9479
|
+
* tsvector-backed full-text search. Uses `plainto_tsquery` so the input is
|
|
9480
|
+
* free-form (no boolean operator syntax required); ranks via `ts_rank` on
|
|
9481
|
+
* the weighted `fts_vector` column (name × A, observations × B, tags × C).
|
|
9482
|
+
*
|
|
9483
|
+
* Results are ordered by descending score and capped at `options.limit`
|
|
9484
|
+
* (default 50). Empty / whitespace-only queries return `[]` without
|
|
9485
|
+
* issuing a SQL call.
|
|
9486
|
+
*
|
|
9487
|
+
* @example
|
|
9488
|
+
* ```typescript
|
|
9489
|
+
* const matches = await storage.fullTextSearch('authentication flow', { limit: 10 });
|
|
9490
|
+
* // → [{ name: 'AuthService', score: 0.62 }, ...]
|
|
9491
|
+
* ```
|
|
9492
|
+
*/
|
|
9493
|
+
async fullTextSearch(query, options = {}) {
|
|
9494
|
+
const trimmed = query.trim();
|
|
9495
|
+
if (trimmed.length === 0) return [];
|
|
9496
|
+
await this.initSchema();
|
|
9497
|
+
const pool = await this.getPool();
|
|
9498
|
+
const limit = options.limit ?? 50;
|
|
9499
|
+
const res = await pool.query(
|
|
9500
|
+
`SELECT name, ts_rank(fts_vector, plainto_tsquery('english', $1))::float AS score
|
|
9501
|
+
FROM entities
|
|
9502
|
+
WHERE fts_vector @@ plainto_tsquery('english', $1)
|
|
9503
|
+
ORDER BY score DESC
|
|
9504
|
+
LIMIT $2`,
|
|
9505
|
+
[trimmed, limit]
|
|
9506
|
+
);
|
|
9507
|
+
return res.rows.map((r) => ({ name: r.name, score: Number(r.score) }));
|
|
9508
|
+
}
|
|
9444
9509
|
// ==================== Utility ====================
|
|
9445
9510
|
getFilePath() {
|
|
9446
9511
|
return this.connectionString;
|