@vibeorm/extensions 2.0.0-alpha.3 → 2.0.0-alpha.4
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.js +113 -30
- package/dist/index.js.map +3 -3
- package/dist/search/index.d.ts +16 -1
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +113 -30
- package/dist/search/index.js.map +3 -3
- package/package.json +4 -4
package/dist/search/index.js
CHANGED
|
@@ -101,6 +101,10 @@ function resolveSearchEngine(params) {
|
|
|
101
101
|
hint: `this dialect supports "${native}"${dialect === "postgres" ? ' and "bm25"' : ""}`
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
|
+
function declRank(declaration) {
|
|
105
|
+
const value = declaration["rank"];
|
|
106
|
+
return value === "ts_rank" || value === "ts_rank_cd" ? value : undefined;
|
|
107
|
+
}
|
|
104
108
|
function readDeclaration(params) {
|
|
105
109
|
const fields = declStringArray(params.declaration, "fields");
|
|
106
110
|
if (fields === undefined || fields.length === 0)
|
|
@@ -109,7 +113,10 @@ function readDeclaration(params) {
|
|
|
109
113
|
fields,
|
|
110
114
|
weights: declNumberArray(params.declaration, "weights"),
|
|
111
115
|
base: declString(params.declaration, "name") ?? `${tableNameOf({ model: params.model })}_search`,
|
|
112
|
-
language: declString(params.declaration, "language")
|
|
116
|
+
language: declString(params.declaration, "language"),
|
|
117
|
+
columnName: declString(params.declaration, "columnName"),
|
|
118
|
+
indexName: declString(params.declaration, "indexName"),
|
|
119
|
+
rank: declRank(params.declaration)
|
|
113
120
|
};
|
|
114
121
|
}
|
|
115
122
|
function weightLetters(params) {
|
|
@@ -119,6 +126,41 @@ function weightLetters(params) {
|
|
|
119
126
|
const ranked = [...new Set(decl.weights)].sort((a, b) => b - a);
|
|
120
127
|
return decl.weights.map((weight) => WEIGHT_LETTERS[Math.min(ranked.indexOf(weight), WEIGHT_LETTERS.length - 1)]);
|
|
121
128
|
}
|
|
129
|
+
function resolveArtifactNames(params) {
|
|
130
|
+
const { decl, engine, dialect } = params;
|
|
131
|
+
if (engine === "fts5" && (decl.columnName !== undefined || decl.indexName !== undefined)) {
|
|
132
|
+
throw unsupportedCapability({
|
|
133
|
+
dialect,
|
|
134
|
+
feature: "@@search columnName/indexName overrides on the fts5 engine",
|
|
135
|
+
hint: "fts5 emits a shadow table + triggers \u2014 there is no column or index to rename; use name: to change the table base"
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (decl.columnName !== undefined && engine !== "tsvector") {
|
|
139
|
+
throw unsupportedCapability({
|
|
140
|
+
dialect,
|
|
141
|
+
feature: `@@search columnName on the ${engine} engine`,
|
|
142
|
+
hint: "only the tsvector engine materializes a generated column \u2014 drop columnName or target tsvector"
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
tsvColumn: decl.columnName ?? `${decl.base}_tsv`,
|
|
147
|
+
indexName: decl.indexName ?? `${decl.base}_idx`
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function resolveRank(params) {
|
|
151
|
+
const { decl, options, engine, dialect } = params;
|
|
152
|
+
if (decl.rank !== undefined && engine !== "tsvector") {
|
|
153
|
+
throw unsupportedCapability({
|
|
154
|
+
dialect,
|
|
155
|
+
feature: `@@search rank on the ${engine} engine`,
|
|
156
|
+
hint: "rank chooses between the postgres ranking functions ts_rank and ts_rank_cd \u2014 a tsvector-only concept"
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
if (engine !== "tsvector")
|
|
160
|
+
return;
|
|
161
|
+
const fallback = options["rank"];
|
|
162
|
+
return decl.rank ?? (fallback === "ts_rank" || fallback === "ts_rank_cd" ? fallback : undefined);
|
|
163
|
+
}
|
|
122
164
|
function tsvectorExpression(params) {
|
|
123
165
|
const { dialect, model, decl, language } = params;
|
|
124
166
|
const quote = (name) => dialect.quoteIdent({ name });
|
|
@@ -152,9 +194,10 @@ function searchArtifacts(ctx) {
|
|
|
152
194
|
continue;
|
|
153
195
|
const table = tableNameOf({ model });
|
|
154
196
|
const columns = decl.fields.map((field) => columnNameOf({ model, field }));
|
|
197
|
+
resolveRank({ decl, options: ctx.options, engine, dialect: ctx.dialect });
|
|
155
198
|
if (engine === "tsvector") {
|
|
156
199
|
const language = decl.language ?? ctx.options["language"] ?? "english";
|
|
157
|
-
const tsvColumn =
|
|
200
|
+
const { tsvColumn, indexName } = resolveArtifactNames({ decl, engine, dialect: ctx.dialect });
|
|
158
201
|
const expression = tsvectorExpression({ dialect, model, decl, language });
|
|
159
202
|
artifacts.push({
|
|
160
203
|
id: `search:${modelName}:column`,
|
|
@@ -165,11 +208,11 @@ function searchArtifacts(ctx) {
|
|
|
165
208
|
drop: [`ALTER TABLE ${quote(table)} DROP COLUMN IF EXISTS ${quote(tsvColumn)};`]
|
|
166
209
|
}, {
|
|
167
210
|
id: `search:${modelName}:index`,
|
|
168
|
-
owns: { kind: "index", table, name:
|
|
211
|
+
owns: { kind: "index", table, name: indexName },
|
|
169
212
|
create: [
|
|
170
|
-
`CREATE INDEX IF NOT EXISTS ${quote(
|
|
213
|
+
`CREATE INDEX IF NOT EXISTS ${quote(indexName)} ON ${quote(table)} USING gin (${quote(tsvColumn)});`
|
|
171
214
|
],
|
|
172
|
-
drop: [`DROP INDEX IF EXISTS ${quote(
|
|
215
|
+
drop: [`DROP INDEX IF EXISTS ${quote(indexName)};`]
|
|
173
216
|
});
|
|
174
217
|
continue;
|
|
175
218
|
}
|
|
@@ -183,17 +226,19 @@ function searchArtifacts(ctx) {
|
|
|
183
226
|
});
|
|
184
227
|
}
|
|
185
228
|
const pkColumn = columnNameOf({ model, field: pkField });
|
|
229
|
+
const bm25Names = resolveArtifactNames({ decl, engine, dialect: ctx.dialect });
|
|
186
230
|
artifacts.push({
|
|
187
231
|
id: `search:${modelName}:index`,
|
|
188
|
-
owns: { kind: "index", table, name:
|
|
232
|
+
owns: { kind: "index", table, name: bm25Names.indexName },
|
|
189
233
|
create: [
|
|
190
|
-
`CREATE INDEX IF NOT EXISTS ${quote(
|
|
234
|
+
`CREATE INDEX IF NOT EXISTS ${quote(bm25Names.indexName)} ON ${quote(table)} USING bm25 (${[pkColumn, ...columns].map((column) => quote(column)).join(", ")}) WITH (key_field='${pkColumn}');`
|
|
191
235
|
],
|
|
192
|
-
drop: [`DROP INDEX IF EXISTS ${quote(
|
|
236
|
+
drop: [`DROP INDEX IF EXISTS ${quote(bm25Names.indexName)};`]
|
|
193
237
|
});
|
|
194
238
|
continue;
|
|
195
239
|
}
|
|
196
240
|
if (engine === "fts5") {
|
|
241
|
+
resolveArtifactNames({ decl, engine, dialect: ctx.dialect });
|
|
197
242
|
const pkName = primaryKeyFieldOf({ model });
|
|
198
243
|
const pkField = pkName === null ? undefined : model.fields.find((field) => field.name === pkName);
|
|
199
244
|
const pkIsRowidAlias = pkField !== undefined && !pkField.isList && (pkField.type === "Int" || pkField.type === "BigInt");
|
|
@@ -242,13 +287,14 @@ END;`
|
|
|
242
287
|
});
|
|
243
288
|
continue;
|
|
244
289
|
}
|
|
290
|
+
const fulltextNames = resolveArtifactNames({ decl, engine, dialect: ctx.dialect });
|
|
245
291
|
artifacts.push({
|
|
246
292
|
id: `search:${modelName}:index`,
|
|
247
|
-
owns: { kind: "index", table, name:
|
|
293
|
+
owns: { kind: "index", table, name: fulltextNames.indexName },
|
|
248
294
|
create: [
|
|
249
|
-
`CREATE FULLTEXT INDEX ${quote(
|
|
295
|
+
`CREATE FULLTEXT INDEX ${quote(fulltextNames.indexName)} ON ${quote(table)} (${columns.map((column) => quote(column)).join(", ")});`
|
|
250
296
|
],
|
|
251
|
-
drop: [`DROP INDEX ${quote(
|
|
297
|
+
drop: [`DROP INDEX ${quote(fulltextNames.indexName)} ON ${quote(table)};`]
|
|
252
298
|
});
|
|
253
299
|
}
|
|
254
300
|
return artifacts;
|
|
@@ -297,6 +343,15 @@ function createSearchDelegate(config) {
|
|
|
297
343
|
const take = Math.max(1, Math.trunc(args.take ?? 10));
|
|
298
344
|
const skip = args.skip === undefined ? null : Math.max(0, Math.trunc(args.skip));
|
|
299
345
|
const hlColumn = highlightColumn({ config, args });
|
|
346
|
+
const idOnly = args.select === "id";
|
|
347
|
+
if (idOnly && config.pkColumn === undefined) {
|
|
348
|
+
throw new VibeError2({
|
|
349
|
+
code: "VIBE_VALIDATION",
|
|
350
|
+
message: `select: "id" needs a single-column primary key baked into the client \u2014 ${config.table} has none, or the client predates the projection (run vibeorm generate)`,
|
|
351
|
+
meta: { table: config.table }
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
const projection = idOnly ? `${t}.${quote(config.pkColumn ?? "")}` : `${t}.*`;
|
|
300
355
|
const collector = new ParamCollector(dialect);
|
|
301
356
|
const userWhere = (qualify) => {
|
|
302
357
|
if (args.where === undefined)
|
|
@@ -309,9 +364,10 @@ function createSearchDelegate(config) {
|
|
|
309
364
|
let engineHasHighlights = true;
|
|
310
365
|
if (config.engine === "tsvector") {
|
|
311
366
|
const language = config.language ?? "english";
|
|
367
|
+
const ranker = config.rank ?? "ts_rank_cd";
|
|
312
368
|
const tsv = `${t}.${quote(config.tsvColumn ?? "")}`;
|
|
313
369
|
const tsquery = () => `websearch_to_tsquery('${language}', ${collector.add(args.query)})`;
|
|
314
|
-
text = `SELECT ${
|
|
370
|
+
text = `SELECT ${projection}, ${ranker}(${tsv}, ${tsquery()}) AS ${quote(SCORE_ALIAS)}`;
|
|
315
371
|
if (hlColumn !== null) {
|
|
316
372
|
text += `, ts_headline('${language}', ${t}.${quote(hlColumn)}, ${tsquery()}) AS ${quote(HIGHLIGHT_ALIAS)}`;
|
|
317
373
|
}
|
|
@@ -320,13 +376,13 @@ function createSearchDelegate(config) {
|
|
|
320
376
|
if (where !== null)
|
|
321
377
|
text += ` AND (${where})`;
|
|
322
378
|
if (args.minScore !== undefined) {
|
|
323
|
-
text += ` AND
|
|
379
|
+
text += ` AND ${ranker}(${tsv}, ${tsquery()}) >= ${collector.add(args.minScore)}`;
|
|
324
380
|
}
|
|
325
381
|
text += ` ORDER BY ${quote(SCORE_ALIAS)} DESC`;
|
|
326
|
-
strip = [config.tsvColumn ?? ""];
|
|
382
|
+
strip = idOnly ? [] : [config.tsvColumn ?? ""];
|
|
327
383
|
} else if (config.engine === "fts5") {
|
|
328
384
|
const fts = quote(config.ftsTable ?? "");
|
|
329
|
-
text = `SELECT ${
|
|
385
|
+
text = `SELECT ${projection}, -bm25(${fts}) AS ${quote(SCORE_ALIAS)}`;
|
|
330
386
|
if (hlColumn !== null) {
|
|
331
387
|
const index = config.fields.findIndex((field) => field.column === hlColumn);
|
|
332
388
|
text += `, snippet(${fts}, ${index}, '<b>', '</b>', '\u2026', 16) AS ${quote(HIGHLIGHT_ALIAS)}`;
|
|
@@ -343,7 +399,7 @@ function createSearchDelegate(config) {
|
|
|
343
399
|
} else if (config.engine === "fulltext") {
|
|
344
400
|
engineHasHighlights = false;
|
|
345
401
|
const match = () => `MATCH (${config.fields.map((field) => `${t}.${quote(field.column)}`).join(", ")}) AGAINST (${collector.add(args.query)} IN NATURAL LANGUAGE MODE)`;
|
|
346
|
-
text = `SELECT ${
|
|
402
|
+
text = `SELECT ${projection}, ${match()} AS ${quote(SCORE_ALIAS)} FROM ${quote(config.table)} AS ${t}`;
|
|
347
403
|
text += ` WHERE ${match()}`;
|
|
348
404
|
const where = userWhere("t");
|
|
349
405
|
if (where !== null)
|
|
@@ -354,7 +410,7 @@ function createSearchDelegate(config) {
|
|
|
354
410
|
text += ` ORDER BY ${quote(SCORE_ALIAS)} DESC`;
|
|
355
411
|
} else {
|
|
356
412
|
const pk = `${t}.${quote(config.pkColumn ?? "")}`;
|
|
357
|
-
text = `SELECT ${
|
|
413
|
+
text = `SELECT ${projection}, paradedb.score(${pk}) AS ${quote(SCORE_ALIAS)}`;
|
|
358
414
|
if (hlColumn !== null) {
|
|
359
415
|
text += `, paradedb.snippet(${t}.${quote(hlColumn)}) AS ${quote(HIGHLIGHT_ALIAS)}`;
|
|
360
416
|
}
|
|
@@ -415,6 +471,16 @@ function search(options = {}) {
|
|
|
415
471
|
if (language !== undefined && (typeof language !== "string" || !isSafeSqlName({ name: language }))) {
|
|
416
472
|
return { error: `language must be a plain text-search config name` };
|
|
417
473
|
}
|
|
474
|
+
for (const key of ["columnName", "indexName"]) {
|
|
475
|
+
const value = args.named[key];
|
|
476
|
+
if (value !== undefined && (typeof value !== "string" || !isSafeSqlName({ name: value }))) {
|
|
477
|
+
return { error: `${key} must be a plain identifier` };
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
const rank = args.named["rank"];
|
|
481
|
+
if (rank !== undefined && rank !== "ts_rank" && rank !== "ts_rank_cd") {
|
|
482
|
+
return { error: `rank must be "ts_rank" or "ts_rank_cd"` };
|
|
483
|
+
}
|
|
418
484
|
return { declaration: { fields, ...args.named } };
|
|
419
485
|
}
|
|
420
486
|
}
|
|
@@ -438,6 +504,8 @@ function search(options = {}) {
|
|
|
438
504
|
});
|
|
439
505
|
}
|
|
440
506
|
const pkField = primaryKeyFieldOf({ model });
|
|
507
|
+
const rank = resolveRank({ decl, options: extOptions, engine, dialect });
|
|
508
|
+
const names = resolveArtifactNames({ decl, engine, dialect });
|
|
441
509
|
const config = {
|
|
442
510
|
engine,
|
|
443
511
|
table: tableNameOf({ model }),
|
|
@@ -445,26 +513,41 @@ function search(options = {}) {
|
|
|
445
513
|
name: field,
|
|
446
514
|
column: columnNameOf({ model, field })
|
|
447
515
|
})),
|
|
448
|
-
...engine === "tsvector" ? { tsvColumn:
|
|
516
|
+
...engine === "tsvector" ? { tsvColumn: names.tsvColumn, language, ...rank === undefined ? {} : { rank } } : {},
|
|
449
517
|
...engine === "fts5" ? { ftsTable: `${decl.base}_fts` } : {},
|
|
450
|
-
...
|
|
518
|
+
...pkField !== null ? { pkColumn: columnNameOf({ model, field: pkField }) } : {}
|
|
451
519
|
};
|
|
452
520
|
const fieldUnion = decl.fields.map((field) => JSON.stringify(field)).join(" | ");
|
|
521
|
+
const argLines = [
|
|
522
|
+
` readonly query: string;`,
|
|
523
|
+
` readonly where?: ${typeNames.whereInput};`,
|
|
524
|
+
` readonly take?: number;`,
|
|
525
|
+
` readonly skip?: number;`,
|
|
526
|
+
` readonly minScore?: number;`,
|
|
527
|
+
` readonly highlight?: { readonly field: ${fieldUnion} };`
|
|
528
|
+
];
|
|
529
|
+
const dts = pkField === null ? [
|
|
530
|
+
`readonly search: (args: {`,
|
|
531
|
+
...argLines,
|
|
532
|
+
`}) => Promise<SearchHit<${typeNames.payload}>[]>;`
|
|
533
|
+
] : [
|
|
534
|
+
`readonly search: {`,
|
|
535
|
+
` (args: {`,
|
|
536
|
+
...argLines.map((line) => ` ${line}`),
|
|
537
|
+
` readonly select: "id";`,
|
|
538
|
+
` }): Promise<SearchHit<Pick<${typeNames.payload}, ${JSON.stringify(pkField)}>>[]>;`,
|
|
539
|
+
` (args: {`,
|
|
540
|
+
...argLines.map((line) => ` ${line}`),
|
|
541
|
+
` readonly select?: "row";`,
|
|
542
|
+
` }): Promise<SearchHit<${typeNames.payload}>[]>;`,
|
|
543
|
+
`};`
|
|
544
|
+
];
|
|
453
545
|
return {
|
|
454
546
|
kind: "method",
|
|
455
547
|
runtimeGlue: `createSearchDelegate(${JSON.stringify(config)})`,
|
|
456
548
|
imports: [{ from: "@vibeorm/extensions/search", names: ["createSearchDelegate"] }],
|
|
457
549
|
dtsImports: [{ from: "@vibeorm/extensions/search", names: ["SearchHit"] }],
|
|
458
|
-
dts
|
|
459
|
-
`readonly search: (args: {`,
|
|
460
|
-
` readonly query: string;`,
|
|
461
|
-
` readonly where?: ${typeNames.whereInput};`,
|
|
462
|
-
` readonly take?: number;`,
|
|
463
|
-
` readonly skip?: number;`,
|
|
464
|
-
` readonly minScore?: number;`,
|
|
465
|
-
` readonly highlight?: { readonly field: ${fieldUnion} };`,
|
|
466
|
-
`}) => Promise<SearchHit<${typeNames.payload}>[]>;`
|
|
467
|
-
]
|
|
550
|
+
dts
|
|
468
551
|
};
|
|
469
552
|
}
|
|
470
553
|
},
|
|
@@ -508,4 +591,4 @@ export {
|
|
|
508
591
|
createSearchDelegate
|
|
509
592
|
};
|
|
510
593
|
|
|
511
|
-
//# debugId=
|
|
594
|
+
//# debugId=938A9D655B0836DD64756E2164756E21
|
package/dist/search/index.js.map
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/search/index.ts", "../src/shared.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * `search` — unified full-text search (extensions.md §4).\n *\n * One API, four engines resolved per dialect at GENERATE time:\n * - `tsvector` (postgres/pglite): generated STORED tsvector column + GIN,\n * websearch_to_tsquery / ts_rank_cd / ts_headline.\n * - `bm25` (postgres + ParadeDB pg_search, opt-in via `engine: \"bm25\"`):\n * bm25 index + `@@@` + paradedb.score/snippet.\n * - `fts5` (sqlite): external-content virtual table + sync triggers,\n * MATCH / bm25() / snippet().\n * - `fulltext` (mysql): FULLTEXT index + MATCH … AGAINST; highlights are\n * typed `null` (mysql has none).\n *\n * `engine: \"auto\"` picks the dialect's native engine (never bm25 — ParadeDB\n * availability is unknowable at generate time; opt in explicitly).\n */\n\nimport { VibeError, defineExtension, unsupportedCapability } from \"@vibeorm/schema\";\nimport type {\n Dialect,\n ExtensionArtifact,\n ExtensionSchemaContext,\n ModelIR,\n Provider,\n VibeExtension,\n} from \"@vibeorm/schema\";\nimport { ParamCollector, getSqlDialect, renderExpr } from \"@vibeorm/sql\";\nimport type { SqlDialect } from \"@vibeorm/sql\";\nimport type { ExtensionMountContext } from \"@vibeorm/runtime\";\nimport {\n columnNameOf,\n declNumberArray,\n declString,\n declStringArray,\n isSafeSqlName,\n pgExtensionCheck,\n primaryKeyFieldOf,\n tableNameOf,\n} from \"../shared.ts\";\n\n// ─── Options & types ──────────────────────────────────────────────\n\nexport type SearchEngine = \"bm25\" | \"tsvector\" | \"fts5\" | \"fulltext\";\n\nexport type SearchOptions = {\n /** Engine choice; `\"auto\"` (default) resolves per dialect. */\n readonly engine?: SearchEngine | \"auto\";\n /** Default text-search language for the tsvector engine (default \"english\"). */\n readonly language?: string;\n};\n\n/** One search hit. `highlights` is `null` on engines without highlighting. */\nexport type SearchHit<T> = {\n readonly row: T;\n readonly score: number;\n readonly highlights: readonly string[] | null;\n};\n\nconst VERSION = \"2.0.0-alpha.0\";\nconst SCORE_ALIAS = \"_vibe_score\";\nconst HIGHLIGHT_ALIAS = \"_vibe_highlight\";\nconst WEIGHT_LETTERS = [\"A\", \"B\", \"C\", \"D\"] as const;\n\n// ─── Engine resolution (generate/migrate time) ────────────────────\n\n/** Resolve the engine for a dialect; throws on impossible explicit choices. */\nexport function resolveSearchEngine(params: {\n dialect: Dialect;\n provider: Provider;\n requested: SearchEngine | \"auto\";\n}): SearchEngine {\n const { dialect, provider, requested } = params;\n const native: SearchEngine = dialect === \"postgres\" ? \"tsvector\" : dialect === \"sqlite\" ? \"fts5\" : \"fulltext\";\n if (requested === \"auto\") return native;\n if (requested === native) return native;\n if (requested === \"bm25\" && dialect === \"postgres\") {\n if (provider === \"pglite\") {\n throw unsupportedCapability({\n dialect,\n feature: 'the search engine \"bm25\" (ParadeDB pg_search)',\n hint: 'pglite does not bundle pg_search — use engine \"auto\"/\"tsvector\"',\n });\n }\n return \"bm25\";\n }\n throw unsupportedCapability({\n dialect,\n feature: `the search engine \"${requested}\"`,\n hint: `this dialect supports \"${native}\"${dialect === \"postgres\" ? ' and \"bm25\"' : \"\"}`,\n });\n}\n\n// ─── Declaration ──────────────────────────────────────────────────\n\ntype SearchDecl = {\n readonly fields: readonly string[];\n readonly weights: readonly number[] | undefined;\n readonly base: string;\n readonly language: string | undefined;\n};\n\nfunction readDeclaration(params: {\n model: ModelIR;\n declaration: Readonly<Record<string, unknown>>;\n}): SearchDecl | null {\n const fields = declStringArray(params.declaration, \"fields\");\n if (fields === undefined || fields.length === 0) return null;\n return {\n fields,\n weights: declNumberArray(params.declaration, \"weights\"),\n base: declString(params.declaration, \"name\") ?? `${tableNameOf({ model: params.model })}_search`,\n language: declString(params.declaration, \"language\"),\n };\n}\n\n/** Weight letter per field: highest weight → 'A', capped at 'D'. */\nfunction weightLetters(params: { decl: SearchDecl }): readonly string[] | null {\n const { decl } = params;\n if (decl.weights === undefined || decl.weights.length !== decl.fields.length) return null;\n const ranked = [...new Set(decl.weights)].sort((a, b) => b - a);\n return decl.weights.map(\n (weight) => WEIGHT_LETTERS[Math.min(ranked.indexOf(weight), WEIGHT_LETTERS.length - 1)] as string,\n );\n}\n\nfunction tsvectorExpression(params: {\n dialect: SqlDialect;\n model: ModelIR;\n decl: SearchDecl;\n language: string;\n}): string {\n const { dialect, model, decl, language } = params;\n const quote = (name: string): string => dialect.quoteIdent({ name });\n const letters = weightLetters({ decl });\n const parts = decl.fields.map((field, index) => {\n const vector = `to_tsvector('${language}', coalesce(${quote(columnNameOf({ model, field }))}, ''))`;\n return letters === null ? vector : `setweight(${vector}, '${letters[index]}')`;\n });\n return letters === null && parts.length > 1\n ? `to_tsvector('${language}', ${decl.fields\n .map((field) => `coalesce(${quote(columnNameOf({ model, field }))}, '')`)\n .join(\" || ' ' || \")})`\n : parts.join(\" || \");\n}\n\n// ─── Artifacts ────────────────────────────────────────────────────\n\nfunction searchArtifacts(ctx: ExtensionSchemaContext): readonly ExtensionArtifact[] {\n const requested = (ctx.options[\"engine\"] as SearchEngine | \"auto\" | undefined) ?? \"auto\";\n const engine = resolveSearchEngine({ dialect: ctx.dialect, provider: ctx.provider, requested });\n const dialect = getSqlDialect({ dialect: ctx.dialect });\n const quote = (name: string): string => dialect.quoteIdent({ name });\n const artifacts: ExtensionArtifact[] = [];\n\n if (engine === \"bm25\") {\n artifacts.push({\n id: \"search:extension:pg_search\",\n owns: { kind: \"postgresExtension\", name: \"pg_search\" },\n create: [\"CREATE EXTENSION IF NOT EXISTS pg_search;\"],\n drop: [\"DROP EXTENSION IF EXISTS pg_search;\"],\n });\n }\n\n for (const [modelName, declaration] of Object.entries(ctx.declarations)) {\n const model = ctx.schema.models.find((candidate) => candidate.name === modelName);\n if (model === undefined) continue;\n const decl = readDeclaration({ model, declaration });\n if (decl === null) continue;\n const table = tableNameOf({ model });\n const columns = decl.fields.map((field) => columnNameOf({ model, field }));\n\n if (engine === \"tsvector\") {\n const language = decl.language ?? (ctx.options[\"language\"] as string | undefined) ?? \"english\";\n const tsvColumn = `${decl.base}_tsv`;\n const expression = tsvectorExpression({ dialect, model, decl, language });\n artifacts.push(\n {\n id: `search:${modelName}:column`,\n owns: { kind: \"column\", table, column: tsvColumn },\n create: [\n `ALTER TABLE ${quote(table)} ADD COLUMN IF NOT EXISTS ${quote(tsvColumn)} tsvector GENERATED ALWAYS AS (${expression}) STORED;`,\n ],\n drop: [`ALTER TABLE ${quote(table)} DROP COLUMN IF EXISTS ${quote(tsvColumn)};`],\n },\n {\n id: `search:${modelName}:index`,\n owns: { kind: \"index\", table, name: `${decl.base}_idx` },\n create: [\n `CREATE INDEX IF NOT EXISTS ${quote(`${decl.base}_idx`)} ON ${quote(table)} USING gin (${quote(tsvColumn)});`,\n ],\n drop: [`DROP INDEX IF EXISTS ${quote(`${decl.base}_idx`)};`],\n },\n );\n continue;\n }\n\n if (engine === \"bm25\") {\n const pkField = primaryKeyFieldOf({ model });\n if (pkField === null) {\n throw new VibeError({\n code: \"VIBE_SCHEMA_INVALID\",\n message: `@@search with engine \"bm25\" needs a single-column primary key on \"${modelName}\" (key_field)`,\n meta: { model: modelName },\n });\n }\n const pkColumn = columnNameOf({ model, field: pkField });\n artifacts.push({\n id: `search:${modelName}:index`,\n owns: { kind: \"index\", table, name: `${decl.base}_idx` },\n create: [\n `CREATE INDEX IF NOT EXISTS ${quote(`${decl.base}_idx`)} ON ${quote(table)} USING bm25 (${[pkColumn, ...columns]\n .map((column) => quote(column))\n .join(\", \")}) WITH (key_field='${pkColumn}');`,\n ],\n drop: [`DROP INDEX IF EXISTS ${quote(`${decl.base}_idx`)};`],\n });\n continue;\n }\n\n if (engine === \"fts5\") {\n // N7 (SQL review): the external-content table and its sync triggers key\n // on the host's ROWID. Only a single Int/BigInt @id aliases (and pins)\n // the rowid; any other primary key leaves an IMPLICIT rowid that VACUUM\n // may renumber — a documented sqlite non-guarantee — after which the\n // shadow table silently points at the WRONG rows. Refuse at generate\n // time (earliest-moment rule); recovery for a database that already\n // drifted is `INSERT INTO <fts>(<fts>) VALUES('rebuild')`.\n const pkName = primaryKeyFieldOf({ model });\n const pkField = pkName === null ? undefined : model.fields.find((field) => field.name === pkName);\n const pkIsRowidAlias =\n pkField !== undefined && !pkField.isList && (pkField.type === \"Int\" || pkField.type === \"BigInt\");\n if (!pkIsRowidAlias) {\n throw unsupportedCapability({\n dialect: \"sqlite\",\n feature: `@@search (fts5) on \"${modelName}\", whose primary key is not a single INTEGER column`,\n hint: \"fts5 external-content tables key on the rowid; only an Int/BigInt @id aliases and PINS it — any other key's implicit rowid can be renumbered by VACUUM, silently mis-linking search hits. Give the searched model an Int/BigInt @id.\",\n });\n }\n const fts = `${decl.base}_fts`;\n const columnList = columns.map((column) => quote(column)).join(\", \");\n const newList = columns.map((column) => `new.${quote(column)}`).join(\", \");\n const oldList = columns.map((column) => `old.${quote(column)}`).join(\", \");\n artifacts.push(\n {\n id: `search:${modelName}:fts5-table`,\n owns: {\n kind: \"table\",\n name: fts,\n auxiliaryPrefixes: [`${fts}_`],\n },\n create: [\n `CREATE VIRTUAL TABLE IF NOT EXISTS ${quote(fts)} USING fts5(${columnList}, content='${table}');`,\n ],\n drop: [`DROP TABLE IF EXISTS ${quote(fts)};`],\n },\n {\n id: `search:${modelName}:fts5-triggers`,\n owns: { kind: \"trigger\", table, name: `${fts}_ai` },\n create: [\n `CREATE TRIGGER IF NOT EXISTS ${quote(`${fts}_ai`)} AFTER INSERT ON ${quote(table)} BEGIN\\n INSERT INTO ${quote(fts)}(rowid, ${columnList}) VALUES (new.rowid, ${newList});\\nEND;`,\n `CREATE TRIGGER IF NOT EXISTS ${quote(`${fts}_ad`)} AFTER DELETE ON ${quote(table)} BEGIN\\n INSERT INTO ${quote(fts)}(${quote(fts)}, rowid, ${columnList}) VALUES ('delete', old.rowid, ${oldList});\\nEND;`,\n `CREATE TRIGGER IF NOT EXISTS ${quote(`${fts}_au`)} AFTER UPDATE ON ${quote(table)} BEGIN\\n INSERT INTO ${quote(fts)}(${quote(fts)}, rowid, ${columnList}) VALUES ('delete', old.rowid, ${oldList});\\n INSERT INTO ${quote(fts)}(rowid, ${columnList}) VALUES (new.rowid, ${newList});\\nEND;`,\n ],\n drop: [\n `DROP TRIGGER IF EXISTS ${quote(`${fts}_ai`)};`,\n `DROP TRIGGER IF EXISTS ${quote(`${fts}_ad`)};`,\n `DROP TRIGGER IF EXISTS ${quote(`${fts}_au`)};`,\n ],\n },\n );\n continue;\n }\n\n // fulltext (mysql): no IF NOT EXISTS form exists — migrate's presence\n // check (introspected index name) decides whether the create runs.\n artifacts.push({\n id: `search:${modelName}:index`,\n owns: { kind: \"index\", table, name: `${decl.base}_idx` },\n create: [\n `CREATE FULLTEXT INDEX ${quote(`${decl.base}_idx`)} ON ${quote(table)} (${columns\n .map((column) => quote(column))\n .join(\", \")});`,\n ],\n drop: [`DROP INDEX ${quote(`${decl.base}_idx`)} ON ${quote(table)};`],\n });\n }\n return artifacts;\n}\n\n// ─── Runtime delegate (generated-glue target) ─────────────────────\n\n/** Baked per-model config the generator writes into the client. */\nexport type SearchDelegateConfig = {\n readonly engine: SearchEngine;\n readonly table: string;\n /** Searched fields in declaration order → column names. */\n readonly fields: readonly { readonly name: string; readonly column: string }[];\n /** tsvector engine: the generated column. */\n readonly tsvColumn?: string;\n /** fts5 engine: the shadow table. */\n readonly ftsTable?: string;\n /** tsvector engine: regconfig name (validated identifier). */\n readonly language?: string;\n /** bm25 engine: key_field column. */\n readonly pkColumn?: string;\n};\n\nexport type SearchArgs = {\n readonly query: string;\n readonly where?: Record<string, unknown>;\n readonly take?: number;\n readonly skip?: number;\n readonly minScore?: number;\n readonly highlight?: { readonly field: string };\n};\n\nexport type SearchMethod = (args: SearchArgs) => Promise<SearchHit<Record<string, unknown>>[]>;\n\nfunction highlightColumn(params: { config: SearchDelegateConfig; args: SearchArgs }): string | null {\n const { config, args } = params;\n if (args.highlight === undefined) return null;\n const field = config.fields.find((candidate) => candidate.name === args.highlight?.field);\n if (field === undefined) {\n throw new VibeError({\n code: \"VIBE_VALIDATION\",\n message: `highlight.field \"${args.highlight.field}\" is not searched — declared: ${config.fields\n .map((candidate) => candidate.name)\n .join(\", \")}`,\n meta: { field: args.highlight.field },\n });\n }\n return field.column;\n}\n\nfunction shapeHits(params: {\n rows: readonly Record<string, unknown>[];\n strip: readonly string[];\n highlightsRequested: boolean;\n engineHasHighlights: boolean;\n}): SearchHit<Record<string, unknown>>[] {\n const { rows, strip, highlightsRequested, engineHasHighlights } = params;\n return rows.map((raw) => {\n const row: Record<string, unknown> = { ...raw };\n const score = Number(row[SCORE_ALIAS]);\n const highlight = row[HIGHLIGHT_ALIAS];\n delete row[SCORE_ALIAS];\n delete row[HIGHLIGHT_ALIAS];\n for (const name of strip) delete row[name];\n const highlights =\n engineHasHighlights && highlightsRequested && highlight !== null && highlight !== undefined\n ? [String(highlight)]\n : null;\n return { row, score, highlights };\n });\n}\n\n/**\n * The generated client's glue target: bakes engine + names at generate time,\n * mounts as the `search` method at runtime (D9).\n */\nexport function createSearchDelegate(\n config: SearchDelegateConfig,\n): (ctx: ExtensionMountContext) => SearchMethod {\n return (ctx: ExtensionMountContext): SearchMethod => {\n const dialect = ctx.dialect;\n const quote = (name: string): string => dialect.quoteIdent({ name });\n const t = quote(\"t\");\n\n return async (args: SearchArgs): Promise<SearchHit<Record<string, unknown>>[]> => {\n if (typeof args.query !== \"string\" || args.query.trim().length === 0) {\n throw new VibeError({\n code: \"VIBE_VALIDATION\",\n message: \"search requires a non-empty query string\",\n meta: { table: config.table },\n });\n }\n const take = Math.max(1, Math.trunc(args.take ?? 10));\n const skip = args.skip === undefined ? null : Math.max(0, Math.trunc(args.skip));\n const hlColumn = highlightColumn({ config, args });\n const collector = new ParamCollector(dialect);\n\n const userWhere = (qualify: string): string | null => {\n if (args.where === undefined) return null;\n const expr = ctx.compileWhere({ where: args.where, qualify });\n return expr === undefined ? null : renderExpr({ dialect, expr, collector });\n };\n\n let text: string;\n let strip: readonly string[] = [];\n let engineHasHighlights = true;\n\n if (config.engine === \"tsvector\") {\n const language = config.language ?? \"english\";\n const tsv = `${t}.${quote(config.tsvColumn ?? \"\")}`;\n const tsquery = (): string => `websearch_to_tsquery('${language}', ${collector.add(args.query)})`;\n text = `SELECT ${t}.*, ts_rank_cd(${tsv}, ${tsquery()}) AS ${quote(SCORE_ALIAS)}`;\n if (hlColumn !== null) {\n text += `, ts_headline('${language}', ${t}.${quote(hlColumn)}, ${tsquery()}) AS ${quote(HIGHLIGHT_ALIAS)}`;\n }\n text += ` FROM ${quote(config.table)} AS ${t} WHERE ${tsv} @@ ${tsquery()}`;\n const where = userWhere(\"t\");\n if (where !== null) text += ` AND (${where})`;\n if (args.minScore !== undefined) {\n text += ` AND ts_rank_cd(${tsv}, ${tsquery()}) >= ${collector.add(args.minScore)}`;\n }\n text += ` ORDER BY ${quote(SCORE_ALIAS)} DESC`;\n strip = [config.tsvColumn ?? \"\"];\n } else if (config.engine === \"fts5\") {\n const fts = quote(config.ftsTable ?? \"\");\n text = `SELECT ${t}.*, -bm25(${fts}) AS ${quote(SCORE_ALIAS)}`;\n if (hlColumn !== null) {\n const index = config.fields.findIndex((field) => field.column === hlColumn);\n text += `, snippet(${fts}, ${index}, '<b>', '</b>', '…', 16) AS ${quote(HIGHLIGHT_ALIAS)}`;\n }\n text += ` FROM ${fts} JOIN ${quote(config.table)} AS ${t} ON ${t}.rowid = ${fts}.rowid`;\n text += ` WHERE ${fts} MATCH ${collector.add(args.query)}`;\n const where = userWhere(\"t\");\n if (where !== null) text += ` AND (${where})`;\n if (args.minScore !== undefined) {\n text += ` AND -bm25(${fts}) >= ${collector.add(args.minScore)}`;\n }\n text += ` ORDER BY ${quote(SCORE_ALIAS)} DESC`;\n } else if (config.engine === \"fulltext\") {\n engineHasHighlights = false;\n const match = (): string =>\n `MATCH (${config.fields.map((field) => `${t}.${quote(field.column)}`).join(\", \")}) AGAINST (${collector.add(args.query)} IN NATURAL LANGUAGE MODE)`;\n text = `SELECT ${t}.*, ${match()} AS ${quote(SCORE_ALIAS)} FROM ${quote(config.table)} AS ${t}`;\n text += ` WHERE ${match()}`;\n const where = userWhere(\"t\");\n if (where !== null) text += ` AND (${where})`;\n if (args.minScore !== undefined) {\n text += ` AND ${match()} >= ${collector.add(args.minScore)}`;\n }\n text += ` ORDER BY ${quote(SCORE_ALIAS)} DESC`;\n } else {\n // bm25 (ParadeDB). minScore filters client-side (paradedb.score is not\n // reliably WHERE-safe); highlights via paradedb.snippet.\n const pk = `${t}.${quote(config.pkColumn ?? \"\")}`;\n text = `SELECT ${t}.*, paradedb.score(${pk}) AS ${quote(SCORE_ALIAS)}`;\n if (hlColumn !== null) {\n text += `, paradedb.snippet(${t}.${quote(hlColumn)}) AS ${quote(HIGHLIGHT_ALIAS)}`;\n }\n text += ` FROM ${quote(config.table)} AS ${t} WHERE (${config.fields\n .map((field) => `${t}.${quote(field.column)} @@@ ${collector.add(args.query)}`)\n .join(\" OR \")})`;\n const where = userWhere(\"t\");\n if (where !== null) text += ` AND (${where})`;\n text += ` ORDER BY ${quote(SCORE_ALIAS)} DESC`;\n }\n\n text += ` LIMIT ${take}`;\n if (skip !== null) text += ` OFFSET ${skip}`;\n\n const rows = await ctx.executeRows({ text, values: collector.values, method: \"search\" });\n let hits = shapeHits({\n rows,\n strip,\n highlightsRequested: args.highlight !== undefined,\n engineHasHighlights,\n });\n if (config.engine === \"bm25\" && args.minScore !== undefined) {\n const min = args.minScore;\n hits = hits.filter((hit) => hit.score >= min);\n }\n return hits;\n };\n };\n}\n\n// ─── Factory ──────────────────────────────────────────────────────\n\n/**\n * Unified full-text search.\n *\n * @example schema\n * // @@search([title, body], name: \"post_search\", weights: [2, 1])\n * const hits = await db.post.search({ query: \"sqlite full text\", take: 20 });\n * // → [{ row, score, highlights }]\n */\nexport function search(options: SearchOptions = {}): VibeExtension {\n return defineExtension({\n name: \"search\",\n version: VERSION,\n options: { ...options },\n requires: { postgresql: null, pglite: null, sqlite: null, mysql: null },\n\n schema: {\n modelAttributes: [\n {\n name: \"search\",\n parse: ({ args, fieldNames }) => {\n const fields = args.fields ?? [];\n if (fields.length === 0) {\n return { error: \"@@search requires a field list, e.g. @@search([title, body])\" };\n }\n const missing = fields.find((name) => !fieldNames.includes(name));\n if (missing !== undefined) {\n return { error: `@@search references unknown field \"${missing}\"` };\n }\n const name = args.named[\"name\"];\n if (name !== undefined && (typeof name !== \"string\" || !isSafeSqlName({ name }))) {\n return { error: `name must be a plain identifier` };\n }\n const weights = args.named[\"weights\"];\n if (weights !== undefined) {\n if (\n !Array.isArray(weights) ||\n weights.length !== fields.length ||\n weights.some((weight) => typeof weight !== \"number\")\n ) {\n return { error: `weights must be a number list matching the field list` };\n }\n }\n const language = args.named[\"language\"];\n if (language !== undefined && (typeof language !== \"string\" || !isSafeSqlName({ name: language }))) {\n return { error: `language must be a plain text-search config name` };\n }\n return { declaration: { fields, ...args.named } };\n },\n },\n ],\n indexKinds: [\"bm25\", \"fts5\", \"fulltext\", \"gin\"],\n },\n\n migrate: { artifacts: searchArtifacts },\n\n client: {\n model: ({ model, dialect, provider, options: extOptions, declaration, typeNames }) => {\n const decl = readDeclaration({ model, declaration });\n if (decl === null) return null;\n const requested = (extOptions[\"engine\"] as SearchEngine | \"auto\" | undefined) ?? \"auto\";\n const engine = resolveSearchEngine({ dialect, provider, requested });\n const language =\n decl.language ?? (extOptions[\"language\"] as string | undefined) ?? \"english\";\n if (!isSafeSqlName({ name: language })) {\n throw new VibeError({\n code: \"VIBE_SCHEMA_INVALID\",\n message: `search language \"${language}\" is not a plain text-search config name`,\n meta: { model: model.name, language },\n });\n }\n\n const pkField = primaryKeyFieldOf({ model });\n const config: SearchDelegateConfig = {\n engine,\n table: tableNameOf({ model }),\n fields: decl.fields.map((field) => ({\n name: field,\n column: columnNameOf({ model, field }),\n })),\n ...(engine === \"tsvector\" ? { tsvColumn: `${decl.base}_tsv`, language } : {}),\n ...(engine === \"fts5\" ? { ftsTable: `${decl.base}_fts` } : {}),\n ...(engine === \"bm25\" && pkField !== null\n ? { pkColumn: columnNameOf({ model, field: pkField }) }\n : {}),\n };\n\n const fieldUnion = decl.fields.map((field) => JSON.stringify(field)).join(\" | \");\n return {\n kind: \"method\",\n runtimeGlue: `createSearchDelegate(${JSON.stringify(config)})`,\n imports: [{ from: \"@vibeorm/extensions/search\", names: [\"createSearchDelegate\"] }],\n dtsImports: [{ from: \"@vibeorm/extensions/search\", names: [\"SearchHit\"] }],\n dts: [\n `readonly search: (args: {`,\n ` readonly query: string;`,\n ` readonly where?: ${typeNames.whereInput};`,\n ` readonly take?: number;`,\n ` readonly skip?: number;`,\n ` readonly minScore?: number;`,\n ` readonly highlight?: { readonly field: ${fieldUnion} };`,\n `}) => Promise<SearchHit<${typeNames.payload}>[]>;`,\n ],\n };\n },\n },\n\n doctor: async ({ execute, dialect, options: extOptions }) => {\n if (dialect === \"postgres\") {\n const requested = (extOptions[\"engine\"] as SearchEngine | \"auto\" | undefined) ?? \"auto\";\n if (requested === \"bm25\") {\n return { checks: [await pgExtensionCheck({ execute, name: \"pg_search\" })] };\n }\n return { checks: [{ name: \"tsvector\", ok: true, note: \"built in\" }] };\n }\n if (dialect === \"sqlite\") {\n try {\n const rows = await execute({\n text: \"SELECT 1 AS ok FROM pragma_compile_options WHERE compile_options = 'ENABLE_FTS5'\",\n });\n return {\n checks: [\n rows.length > 0\n ? { name: \"fts5\", ok: true, note: \"compiled in\" }\n : { name: \"fts5\", ok: false, note: \"sqlite built without FTS5\" },\n ],\n };\n } catch (error) {\n return {\n checks: [\n {\n name: \"fts5\",\n ok: false,\n note: `check failed: ${error instanceof Error ? error.message : String(error)}`,\n },\n ],\n };\n }\n }\n return { checks: [{ name: \"fulltext\", ok: true, note: \"built in (InnoDB FULLTEXT)\" }] };\n },\n });\n}\n",
|
|
5
|
+
"/**\n * `search` — unified full-text search (extensions.md §4).\n *\n * One API, four engines resolved per dialect at GENERATE time:\n * - `tsvector` (postgres/pglite): generated STORED tsvector column + GIN,\n * websearch_to_tsquery / ts_rank_cd / ts_headline.\n * - `bm25` (postgres + ParadeDB pg_search, opt-in via `engine: \"bm25\"`):\n * bm25 index + `@@@` + paradedb.score/snippet.\n * - `fts5` (sqlite): external-content virtual table + sync triggers,\n * MATCH / bm25() / snippet().\n * - `fulltext` (mysql): FULLTEXT index + MATCH … AGAINST; highlights are\n * typed `null` (mysql has none).\n *\n * `engine: \"auto\"` picks the dialect's native engine (never bm25 — ParadeDB\n * availability is unknowable at generate time; opt in explicitly).\n */\n\nimport { VibeError, defineExtension, unsupportedCapability } from \"@vibeorm/schema\";\nimport type {\n Dialect,\n ExtensionArtifact,\n ExtensionSchemaContext,\n ModelIR,\n Provider,\n VibeExtension,\n} from \"@vibeorm/schema\";\nimport { ParamCollector, getSqlDialect, renderExpr } from \"@vibeorm/sql\";\nimport type { SqlDialect } from \"@vibeorm/sql\";\nimport type { ExtensionMountContext } from \"@vibeorm/runtime\";\nimport {\n columnNameOf,\n declNumberArray,\n declString,\n declStringArray,\n isSafeSqlName,\n pgExtensionCheck,\n primaryKeyFieldOf,\n tableNameOf,\n} from \"../shared.ts\";\n\n// ─── Options & types ──────────────────────────────────────────────\n\nexport type SearchEngine = \"bm25\" | \"tsvector\" | \"fts5\" | \"fulltext\";\n\nexport type SearchOptions = {\n /** Engine choice; `\"auto\"` (default) resolves per dialect. */\n readonly engine?: SearchEngine | \"auto\";\n /** Default text-search language for the tsvector engine (default \"english\"). */\n readonly language?: string;\n /**\n * Ranking function for the tsvector engine (default `\"ts_rank_cd\"`).\n * `ts_rank` ignores cover density, so the two order results differently —\n * consumers migrating hand-written `ts_rank` queries keep their ordering by\n * setting this. A per-model `rank:` declaration overrides the default.\n */\n readonly rank?: \"ts_rank\" | \"ts_rank_cd\";\n};\n\n/** One search hit. `highlights` is `null` on engines without highlighting. */\nexport type SearchHit<T> = {\n readonly row: T;\n readonly score: number;\n readonly highlights: readonly string[] | null;\n};\n\nconst VERSION = \"2.0.0-alpha.0\";\nconst SCORE_ALIAS = \"_vibe_score\";\nconst HIGHLIGHT_ALIAS = \"_vibe_highlight\";\nconst WEIGHT_LETTERS = [\"A\", \"B\", \"C\", \"D\"] as const;\n\n// ─── Engine resolution (generate/migrate time) ────────────────────\n\n/** Resolve the engine for a dialect; throws on impossible explicit choices. */\nexport function resolveSearchEngine(params: {\n dialect: Dialect;\n provider: Provider;\n requested: SearchEngine | \"auto\";\n}): SearchEngine {\n const { dialect, provider, requested } = params;\n const native: SearchEngine = dialect === \"postgres\" ? \"tsvector\" : dialect === \"sqlite\" ? \"fts5\" : \"fulltext\";\n if (requested === \"auto\") return native;\n if (requested === native) return native;\n if (requested === \"bm25\" && dialect === \"postgres\") {\n if (provider === \"pglite\") {\n throw unsupportedCapability({\n dialect,\n feature: 'the search engine \"bm25\" (ParadeDB pg_search)',\n hint: 'pglite does not bundle pg_search — use engine \"auto\"/\"tsvector\"',\n });\n }\n return \"bm25\";\n }\n throw unsupportedCapability({\n dialect,\n feature: `the search engine \"${requested}\"`,\n hint: `this dialect supports \"${native}\"${dialect === \"postgres\" ? ' and \"bm25\"' : \"\"}`,\n });\n}\n\n// ─── Declaration ──────────────────────────────────────────────────\n\ntype SearchDecl = {\n readonly fields: readonly string[];\n readonly weights: readonly number[] | undefined;\n readonly base: string;\n readonly language: string | undefined;\n /** Override for the tsvector column name (adopt-existing; tsvector engine only). */\n readonly columnName: string | undefined;\n /** Override for the index name (tsvector / bm25 / fulltext engines). */\n readonly indexName: string | undefined;\n /** Ranking function override (tsvector engine only). */\n readonly rank: \"ts_rank\" | \"ts_rank_cd\" | undefined;\n};\n\nfunction declRank(\n declaration: Readonly<Record<string, unknown>>,\n): \"ts_rank\" | \"ts_rank_cd\" | undefined {\n const value = declaration[\"rank\"];\n return value === \"ts_rank\" || value === \"ts_rank_cd\" ? value : undefined;\n}\n\nfunction readDeclaration(params: {\n model: ModelIR;\n declaration: Readonly<Record<string, unknown>>;\n}): SearchDecl | null {\n const fields = declStringArray(params.declaration, \"fields\");\n if (fields === undefined || fields.length === 0) return null;\n return {\n fields,\n weights: declNumberArray(params.declaration, \"weights\"),\n base: declString(params.declaration, \"name\") ?? `${tableNameOf({ model: params.model })}_search`,\n language: declString(params.declaration, \"language\"),\n columnName: declString(params.declaration, \"columnName\"),\n indexName: declString(params.declaration, \"indexName\"),\n rank: declRank(params.declaration),\n };\n}\n\n/** Weight letter per field: highest weight → 'A', capped at 'D'. */\nfunction weightLetters(params: { decl: SearchDecl }): readonly string[] | null {\n const { decl } = params;\n if (decl.weights === undefined || decl.weights.length !== decl.fields.length) return null;\n const ranked = [...new Set(decl.weights)].sort((a, b) => b - a);\n return decl.weights.map(\n (weight) => WEIGHT_LETTERS[Math.min(ranked.indexOf(weight), WEIGHT_LETTERS.length - 1)] as string,\n );\n}\n\n/**\n * Artifact names with the adoption overrides applied (`columnName:` /\n * `indexName:` — declared independently so a consumer with LIVE objects can\n * adopt them without a rename migration). Engines without the named object\n * refuse the override instead of silently ignoring it.\n */\nfunction resolveArtifactNames(params: {\n decl: SearchDecl;\n engine: SearchEngine;\n dialect: Dialect;\n}): { tsvColumn: string; indexName: string } {\n const { decl, engine, dialect } = params;\n if (engine === \"fts5\" && (decl.columnName !== undefined || decl.indexName !== undefined)) {\n throw unsupportedCapability({\n dialect,\n feature: \"@@search columnName/indexName overrides on the fts5 engine\",\n hint: \"fts5 emits a shadow table + triggers — there is no column or index to rename; use name: to change the table base\",\n });\n }\n if (decl.columnName !== undefined && engine !== \"tsvector\") {\n throw unsupportedCapability({\n dialect,\n feature: `@@search columnName on the ${engine} engine`,\n hint: \"only the tsvector engine materializes a generated column — drop columnName or target tsvector\",\n });\n }\n return {\n tsvColumn: decl.columnName ?? `${decl.base}_tsv`,\n indexName: decl.indexName ?? `${decl.base}_idx`,\n };\n}\n\n/**\n * Ranking function for the tsvector engine: the model's `rank:` declaration\n * wins over the factory-level default. A DECLARED rank on any other engine is\n * refused (it names postgres ranking functions); the factory default is just\n * a default and stays inert off tsvector.\n */\nfunction resolveRank(params: {\n decl: SearchDecl;\n options: Readonly<Record<string, unknown>>;\n engine: SearchEngine;\n dialect: Dialect;\n}): \"ts_rank\" | \"ts_rank_cd\" | undefined {\n const { decl, options, engine, dialect } = params;\n if (decl.rank !== undefined && engine !== \"tsvector\") {\n throw unsupportedCapability({\n dialect,\n feature: `@@search rank on the ${engine} engine`,\n hint: \"rank chooses between the postgres ranking functions ts_rank and ts_rank_cd — a tsvector-only concept\",\n });\n }\n if (engine !== \"tsvector\") return undefined;\n const fallback = options[\"rank\"];\n return decl.rank ?? (fallback === \"ts_rank\" || fallback === \"ts_rank_cd\" ? fallback : undefined);\n}\n\nfunction tsvectorExpression(params: {\n dialect: SqlDialect;\n model: ModelIR;\n decl: SearchDecl;\n language: string;\n}): string {\n const { dialect, model, decl, language } = params;\n const quote = (name: string): string => dialect.quoteIdent({ name });\n const letters = weightLetters({ decl });\n const parts = decl.fields.map((field, index) => {\n const vector = `to_tsvector('${language}', coalesce(${quote(columnNameOf({ model, field }))}, ''))`;\n return letters === null ? vector : `setweight(${vector}, '${letters[index]}')`;\n });\n return letters === null && parts.length > 1\n ? `to_tsvector('${language}', ${decl.fields\n .map((field) => `coalesce(${quote(columnNameOf({ model, field }))}, '')`)\n .join(\" || ' ' || \")})`\n : parts.join(\" || \");\n}\n\n// ─── Artifacts ────────────────────────────────────────────────────\n\nfunction searchArtifacts(ctx: ExtensionSchemaContext): readonly ExtensionArtifact[] {\n const requested = (ctx.options[\"engine\"] as SearchEngine | \"auto\" | undefined) ?? \"auto\";\n const engine = resolveSearchEngine({ dialect: ctx.dialect, provider: ctx.provider, requested });\n const dialect = getSqlDialect({ dialect: ctx.dialect });\n const quote = (name: string): string => dialect.quoteIdent({ name });\n const artifacts: ExtensionArtifact[] = [];\n\n if (engine === \"bm25\") {\n artifacts.push({\n id: \"search:extension:pg_search\",\n owns: { kind: \"postgresExtension\", name: \"pg_search\" },\n create: [\"CREATE EXTENSION IF NOT EXISTS pg_search;\"],\n drop: [\"DROP EXTENSION IF EXISTS pg_search;\"],\n });\n }\n\n for (const [modelName, declaration] of Object.entries(ctx.declarations)) {\n const model = ctx.schema.models.find((candidate) => candidate.name === modelName);\n if (model === undefined) continue;\n const decl = readDeclaration({ model, declaration });\n if (decl === null) continue;\n const table = tableNameOf({ model });\n const columns = decl.fields.map((field) => columnNameOf({ model, field }));\n resolveRank({ decl, options: ctx.options, engine, dialect: ctx.dialect });\n\n if (engine === \"tsvector\") {\n const language = decl.language ?? (ctx.options[\"language\"] as string | undefined) ?? \"english\";\n const { tsvColumn, indexName } = resolveArtifactNames({ decl, engine, dialect: ctx.dialect });\n const expression = tsvectorExpression({ dialect, model, decl, language });\n artifacts.push(\n {\n id: `search:${modelName}:column`,\n owns: { kind: \"column\", table, column: tsvColumn },\n create: [\n `ALTER TABLE ${quote(table)} ADD COLUMN IF NOT EXISTS ${quote(tsvColumn)} tsvector GENERATED ALWAYS AS (${expression}) STORED;`,\n ],\n drop: [`ALTER TABLE ${quote(table)} DROP COLUMN IF EXISTS ${quote(tsvColumn)};`],\n },\n {\n id: `search:${modelName}:index`,\n owns: { kind: \"index\", table, name: indexName },\n create: [\n `CREATE INDEX IF NOT EXISTS ${quote(indexName)} ON ${quote(table)} USING gin (${quote(tsvColumn)});`,\n ],\n drop: [`DROP INDEX IF EXISTS ${quote(indexName)};`],\n },\n );\n continue;\n }\n\n if (engine === \"bm25\") {\n const pkField = primaryKeyFieldOf({ model });\n if (pkField === null) {\n throw new VibeError({\n code: \"VIBE_SCHEMA_INVALID\",\n message: `@@search with engine \"bm25\" needs a single-column primary key on \"${modelName}\" (key_field)`,\n meta: { model: modelName },\n });\n }\n const pkColumn = columnNameOf({ model, field: pkField });\n const bm25Names = resolveArtifactNames({ decl, engine, dialect: ctx.dialect });\n artifacts.push({\n id: `search:${modelName}:index`,\n owns: { kind: \"index\", table, name: bm25Names.indexName },\n create: [\n `CREATE INDEX IF NOT EXISTS ${quote(bm25Names.indexName)} ON ${quote(table)} USING bm25 (${[pkColumn, ...columns]\n .map((column) => quote(column))\n .join(\", \")}) WITH (key_field='${pkColumn}');`,\n ],\n drop: [`DROP INDEX IF EXISTS ${quote(bm25Names.indexName)};`],\n });\n continue;\n }\n\n if (engine === \"fts5\") {\n resolveArtifactNames({ decl, engine, dialect: ctx.dialect });\n // N7 (SQL review): the external-content table and its sync triggers key\n // on the host's ROWID. Only a single Int/BigInt @id aliases (and pins)\n // the rowid; any other primary key leaves an IMPLICIT rowid that VACUUM\n // may renumber — a documented sqlite non-guarantee — after which the\n // shadow table silently points at the WRONG rows. Refuse at generate\n // time (earliest-moment rule); recovery for a database that already\n // drifted is `INSERT INTO <fts>(<fts>) VALUES('rebuild')`.\n const pkName = primaryKeyFieldOf({ model });\n const pkField = pkName === null ? undefined : model.fields.find((field) => field.name === pkName);\n const pkIsRowidAlias =\n pkField !== undefined && !pkField.isList && (pkField.type === \"Int\" || pkField.type === \"BigInt\");\n if (!pkIsRowidAlias) {\n throw unsupportedCapability({\n dialect: \"sqlite\",\n feature: `@@search (fts5) on \"${modelName}\", whose primary key is not a single INTEGER column`,\n hint: \"fts5 external-content tables key on the rowid; only an Int/BigInt @id aliases and PINS it — any other key's implicit rowid can be renumbered by VACUUM, silently mis-linking search hits. Give the searched model an Int/BigInt @id.\",\n });\n }\n const fts = `${decl.base}_fts`;\n const columnList = columns.map((column) => quote(column)).join(\", \");\n const newList = columns.map((column) => `new.${quote(column)}`).join(\", \");\n const oldList = columns.map((column) => `old.${quote(column)}`).join(\", \");\n artifacts.push(\n {\n id: `search:${modelName}:fts5-table`,\n owns: {\n kind: \"table\",\n name: fts,\n auxiliaryPrefixes: [`${fts}_`],\n },\n create: [\n `CREATE VIRTUAL TABLE IF NOT EXISTS ${quote(fts)} USING fts5(${columnList}, content='${table}');`,\n ],\n drop: [`DROP TABLE IF EXISTS ${quote(fts)};`],\n },\n {\n id: `search:${modelName}:fts5-triggers`,\n owns: { kind: \"trigger\", table, name: `${fts}_ai` },\n create: [\n `CREATE TRIGGER IF NOT EXISTS ${quote(`${fts}_ai`)} AFTER INSERT ON ${quote(table)} BEGIN\\n INSERT INTO ${quote(fts)}(rowid, ${columnList}) VALUES (new.rowid, ${newList});\\nEND;`,\n `CREATE TRIGGER IF NOT EXISTS ${quote(`${fts}_ad`)} AFTER DELETE ON ${quote(table)} BEGIN\\n INSERT INTO ${quote(fts)}(${quote(fts)}, rowid, ${columnList}) VALUES ('delete', old.rowid, ${oldList});\\nEND;`,\n `CREATE TRIGGER IF NOT EXISTS ${quote(`${fts}_au`)} AFTER UPDATE ON ${quote(table)} BEGIN\\n INSERT INTO ${quote(fts)}(${quote(fts)}, rowid, ${columnList}) VALUES ('delete', old.rowid, ${oldList});\\n INSERT INTO ${quote(fts)}(rowid, ${columnList}) VALUES (new.rowid, ${newList});\\nEND;`,\n ],\n drop: [\n `DROP TRIGGER IF EXISTS ${quote(`${fts}_ai`)};`,\n `DROP TRIGGER IF EXISTS ${quote(`${fts}_ad`)};`,\n `DROP TRIGGER IF EXISTS ${quote(`${fts}_au`)};`,\n ],\n },\n );\n continue;\n }\n\n // fulltext (mysql): no IF NOT EXISTS form exists — migrate's presence\n // check (introspected index name) decides whether the create runs.\n const fulltextNames = resolveArtifactNames({ decl, engine, dialect: ctx.dialect });\n artifacts.push({\n id: `search:${modelName}:index`,\n owns: { kind: \"index\", table, name: fulltextNames.indexName },\n create: [\n `CREATE FULLTEXT INDEX ${quote(fulltextNames.indexName)} ON ${quote(table)} (${columns\n .map((column) => quote(column))\n .join(\", \")});`,\n ],\n drop: [`DROP INDEX ${quote(fulltextNames.indexName)} ON ${quote(table)};`],\n });\n }\n return artifacts;\n}\n\n// ─── Runtime delegate (generated-glue target) ─────────────────────\n\n/** Baked per-model config the generator writes into the client. */\nexport type SearchDelegateConfig = {\n readonly engine: SearchEngine;\n readonly table: string;\n /** Searched fields in declaration order → column names. */\n readonly fields: readonly { readonly name: string; readonly column: string }[];\n /** tsvector engine: the generated column. */\n readonly tsvColumn?: string;\n /** fts5 engine: the shadow table. */\n readonly ftsTable?: string;\n /** tsvector engine: regconfig name (validated identifier). */\n readonly language?: string;\n /** tsvector engine: ranking function (default `ts_rank_cd`). */\n readonly rank?: \"ts_rank\" | \"ts_rank_cd\";\n /** Single-column primary key: bm25's key_field and the `select: \"id\"` projection. */\n readonly pkColumn?: string;\n};\n\nexport type SearchArgs = {\n readonly query: string;\n readonly where?: Record<string, unknown>;\n readonly take?: number;\n readonly skip?: number;\n readonly minScore?: number;\n readonly highlight?: { readonly field: string };\n /**\n * Projection: `\"row\"` (default) returns full rows; `\"id\"` returns only the\n * primary key — for repositories that re-read hits through their own typed\n * queries (full rows are wasted bandwidth there).\n */\n readonly select?: \"row\" | \"id\";\n};\n\nexport type SearchMethod = (args: SearchArgs) => Promise<SearchHit<Record<string, unknown>>[]>;\n\nfunction highlightColumn(params: { config: SearchDelegateConfig; args: SearchArgs }): string | null {\n const { config, args } = params;\n if (args.highlight === undefined) return null;\n const field = config.fields.find((candidate) => candidate.name === args.highlight?.field);\n if (field === undefined) {\n throw new VibeError({\n code: \"VIBE_VALIDATION\",\n message: `highlight.field \"${args.highlight.field}\" is not searched — declared: ${config.fields\n .map((candidate) => candidate.name)\n .join(\", \")}`,\n meta: { field: args.highlight.field },\n });\n }\n return field.column;\n}\n\nfunction shapeHits(params: {\n rows: readonly Record<string, unknown>[];\n strip: readonly string[];\n highlightsRequested: boolean;\n engineHasHighlights: boolean;\n}): SearchHit<Record<string, unknown>>[] {\n const { rows, strip, highlightsRequested, engineHasHighlights } = params;\n return rows.map((raw) => {\n const row: Record<string, unknown> = { ...raw };\n const score = Number(row[SCORE_ALIAS]);\n const highlight = row[HIGHLIGHT_ALIAS];\n delete row[SCORE_ALIAS];\n delete row[HIGHLIGHT_ALIAS];\n for (const name of strip) delete row[name];\n const highlights =\n engineHasHighlights && highlightsRequested && highlight !== null && highlight !== undefined\n ? [String(highlight)]\n : null;\n return { row, score, highlights };\n });\n}\n\n/**\n * The generated client's glue target: bakes engine + names at generate time,\n * mounts as the `search` method at runtime (D9).\n */\nexport function createSearchDelegate(\n config: SearchDelegateConfig,\n): (ctx: ExtensionMountContext) => SearchMethod {\n return (ctx: ExtensionMountContext): SearchMethod => {\n const dialect = ctx.dialect;\n const quote = (name: string): string => dialect.quoteIdent({ name });\n const t = quote(\"t\");\n\n return async (args: SearchArgs): Promise<SearchHit<Record<string, unknown>>[]> => {\n if (typeof args.query !== \"string\" || args.query.trim().length === 0) {\n throw new VibeError({\n code: \"VIBE_VALIDATION\",\n message: \"search requires a non-empty query string\",\n meta: { table: config.table },\n });\n }\n const take = Math.max(1, Math.trunc(args.take ?? 10));\n const skip = args.skip === undefined ? null : Math.max(0, Math.trunc(args.skip));\n const hlColumn = highlightColumn({ config, args });\n const idOnly = args.select === \"id\";\n if (idOnly && config.pkColumn === undefined) {\n throw new VibeError({\n code: \"VIBE_VALIDATION\",\n message: `select: \"id\" needs a single-column primary key baked into the client — ${config.table} has none, or the client predates the projection (run vibeorm generate)`,\n meta: { table: config.table },\n });\n }\n const projection = idOnly ? `${t}.${quote(config.pkColumn ?? \"\")}` : `${t}.*`;\n const collector = new ParamCollector(dialect);\n\n const userWhere = (qualify: string): string | null => {\n if (args.where === undefined) return null;\n const expr = ctx.compileWhere({ where: args.where, qualify });\n return expr === undefined ? null : renderExpr({ dialect, expr, collector });\n };\n\n let text: string;\n let strip: readonly string[] = [];\n let engineHasHighlights = true;\n\n if (config.engine === \"tsvector\") {\n const language = config.language ?? \"english\";\n const ranker: \"ts_rank\" | \"ts_rank_cd\" = config.rank ?? \"ts_rank_cd\";\n const tsv = `${t}.${quote(config.tsvColumn ?? \"\")}`;\n const tsquery = (): string => `websearch_to_tsquery('${language}', ${collector.add(args.query)})`;\n text = `SELECT ${projection}, ${ranker}(${tsv}, ${tsquery()}) AS ${quote(SCORE_ALIAS)}`;\n if (hlColumn !== null) {\n text += `, ts_headline('${language}', ${t}.${quote(hlColumn)}, ${tsquery()}) AS ${quote(HIGHLIGHT_ALIAS)}`;\n }\n text += ` FROM ${quote(config.table)} AS ${t} WHERE ${tsv} @@ ${tsquery()}`;\n const where = userWhere(\"t\");\n if (where !== null) text += ` AND (${where})`;\n if (args.minScore !== undefined) {\n text += ` AND ${ranker}(${tsv}, ${tsquery()}) >= ${collector.add(args.minScore)}`;\n }\n text += ` ORDER BY ${quote(SCORE_ALIAS)} DESC`;\n strip = idOnly ? [] : [config.tsvColumn ?? \"\"];\n } else if (config.engine === \"fts5\") {\n const fts = quote(config.ftsTable ?? \"\");\n text = `SELECT ${projection}, -bm25(${fts}) AS ${quote(SCORE_ALIAS)}`;\n if (hlColumn !== null) {\n const index = config.fields.findIndex((field) => field.column === hlColumn);\n text += `, snippet(${fts}, ${index}, '<b>', '</b>', '…', 16) AS ${quote(HIGHLIGHT_ALIAS)}`;\n }\n text += ` FROM ${fts} JOIN ${quote(config.table)} AS ${t} ON ${t}.rowid = ${fts}.rowid`;\n text += ` WHERE ${fts} MATCH ${collector.add(args.query)}`;\n const where = userWhere(\"t\");\n if (where !== null) text += ` AND (${where})`;\n if (args.minScore !== undefined) {\n text += ` AND -bm25(${fts}) >= ${collector.add(args.minScore)}`;\n }\n text += ` ORDER BY ${quote(SCORE_ALIAS)} DESC`;\n } else if (config.engine === \"fulltext\") {\n engineHasHighlights = false;\n const match = (): string =>\n `MATCH (${config.fields.map((field) => `${t}.${quote(field.column)}`).join(\", \")}) AGAINST (${collector.add(args.query)} IN NATURAL LANGUAGE MODE)`;\n text = `SELECT ${projection}, ${match()} AS ${quote(SCORE_ALIAS)} FROM ${quote(config.table)} AS ${t}`;\n text += ` WHERE ${match()}`;\n const where = userWhere(\"t\");\n if (where !== null) text += ` AND (${where})`;\n if (args.minScore !== undefined) {\n text += ` AND ${match()} >= ${collector.add(args.minScore)}`;\n }\n text += ` ORDER BY ${quote(SCORE_ALIAS)} DESC`;\n } else {\n // bm25 (ParadeDB). minScore filters client-side (paradedb.score is not\n // reliably WHERE-safe); highlights via paradedb.snippet.\n const pk = `${t}.${quote(config.pkColumn ?? \"\")}`;\n text = `SELECT ${projection}, paradedb.score(${pk}) AS ${quote(SCORE_ALIAS)}`;\n if (hlColumn !== null) {\n text += `, paradedb.snippet(${t}.${quote(hlColumn)}) AS ${quote(HIGHLIGHT_ALIAS)}`;\n }\n text += ` FROM ${quote(config.table)} AS ${t} WHERE (${config.fields\n .map((field) => `${t}.${quote(field.column)} @@@ ${collector.add(args.query)}`)\n .join(\" OR \")})`;\n const where = userWhere(\"t\");\n if (where !== null) text += ` AND (${where})`;\n text += ` ORDER BY ${quote(SCORE_ALIAS)} DESC`;\n }\n\n text += ` LIMIT ${take}`;\n if (skip !== null) text += ` OFFSET ${skip}`;\n\n const rows = await ctx.executeRows({ text, values: collector.values, method: \"search\" });\n let hits = shapeHits({\n rows,\n strip,\n highlightsRequested: args.highlight !== undefined,\n engineHasHighlights,\n });\n if (config.engine === \"bm25\" && args.minScore !== undefined) {\n const min = args.minScore;\n hits = hits.filter((hit) => hit.score >= min);\n }\n return hits;\n };\n };\n}\n\n// ─── Factory ──────────────────────────────────────────────────────\n\n/**\n * Unified full-text search.\n *\n * @example schema\n * // @@search([title, body], name: \"post_search\", weights: [2, 1])\n * const hits = await db.post.search({ query: \"sqlite full text\", take: 20 });\n * // → [{ row, score, highlights }]\n */\nexport function search(options: SearchOptions = {}): VibeExtension {\n return defineExtension({\n name: \"search\",\n version: VERSION,\n options: { ...options },\n requires: { postgresql: null, pglite: null, sqlite: null, mysql: null },\n\n schema: {\n modelAttributes: [\n {\n name: \"search\",\n parse: ({ args, fieldNames }) => {\n const fields = args.fields ?? [];\n if (fields.length === 0) {\n return { error: \"@@search requires a field list, e.g. @@search([title, body])\" };\n }\n const missing = fields.find((name) => !fieldNames.includes(name));\n if (missing !== undefined) {\n return { error: `@@search references unknown field \"${missing}\"` };\n }\n const name = args.named[\"name\"];\n if (name !== undefined && (typeof name !== \"string\" || !isSafeSqlName({ name }))) {\n return { error: `name must be a plain identifier` };\n }\n const weights = args.named[\"weights\"];\n if (weights !== undefined) {\n if (\n !Array.isArray(weights) ||\n weights.length !== fields.length ||\n weights.some((weight) => typeof weight !== \"number\")\n ) {\n return { error: `weights must be a number list matching the field list` };\n }\n }\n const language = args.named[\"language\"];\n if (language !== undefined && (typeof language !== \"string\" || !isSafeSqlName({ name: language }))) {\n return { error: `language must be a plain text-search config name` };\n }\n for (const key of [\"columnName\", \"indexName\"] as const) {\n const value = args.named[key];\n if (value !== undefined && (typeof value !== \"string\" || !isSafeSqlName({ name: value }))) {\n return { error: `${key} must be a plain identifier` };\n }\n }\n const rank = args.named[\"rank\"];\n if (rank !== undefined && rank !== \"ts_rank\" && rank !== \"ts_rank_cd\") {\n return { error: `rank must be \"ts_rank\" or \"ts_rank_cd\"` };\n }\n return { declaration: { fields, ...args.named } };\n },\n },\n ],\n indexKinds: [\"bm25\", \"fts5\", \"fulltext\", \"gin\"],\n },\n\n migrate: { artifacts: searchArtifacts },\n\n client: {\n model: ({ model, dialect, provider, options: extOptions, declaration, typeNames }) => {\n const decl = readDeclaration({ model, declaration });\n if (decl === null) return null;\n const requested = (extOptions[\"engine\"] as SearchEngine | \"auto\" | undefined) ?? \"auto\";\n const engine = resolveSearchEngine({ dialect, provider, requested });\n const language =\n decl.language ?? (extOptions[\"language\"] as string | undefined) ?? \"english\";\n if (!isSafeSqlName({ name: language })) {\n throw new VibeError({\n code: \"VIBE_SCHEMA_INVALID\",\n message: `search language \"${language}\" is not a plain text-search config name`,\n meta: { model: model.name, language },\n });\n }\n\n const pkField = primaryKeyFieldOf({ model });\n const rank = resolveRank({ decl, options: extOptions, engine, dialect });\n const names = resolveArtifactNames({ decl, engine, dialect });\n const config: SearchDelegateConfig = {\n engine,\n table: tableNameOf({ model }),\n fields: decl.fields.map((field) => ({\n name: field,\n column: columnNameOf({ model, field }),\n })),\n ...(engine === \"tsvector\"\n ? { tsvColumn: names.tsvColumn, language, ...(rank === undefined ? {} : { rank }) }\n : {}),\n ...(engine === \"fts5\" ? { ftsTable: `${decl.base}_fts` } : {}),\n ...(pkField !== null ? { pkColumn: columnNameOf({ model, field: pkField }) } : {}),\n };\n\n const fieldUnion = decl.fields.map((field) => JSON.stringify(field)).join(\" | \");\n const argLines: string[] = [\n ` readonly query: string;`,\n ` readonly where?: ${typeNames.whereInput};`,\n ` readonly take?: number;`,\n ` readonly skip?: number;`,\n ` readonly minScore?: number;`,\n ` readonly highlight?: { readonly field: ${fieldUnion} };`,\n ];\n // With a single-column pk the id projection is offered as an overload:\n // `select: \"id\"` narrows the hit row to the pk.\n const dts: string[] =\n pkField === null\n ? [\n `readonly search: (args: {`,\n ...argLines,\n `}) => Promise<SearchHit<${typeNames.payload}>[]>;`,\n ]\n : [\n `readonly search: {`,\n ` (args: {`,\n ...argLines.map((line) => ` ${line}`),\n ` readonly select: \"id\";`,\n ` }): Promise<SearchHit<Pick<${typeNames.payload}, ${JSON.stringify(pkField)}>>[]>;`,\n ` (args: {`,\n ...argLines.map((line) => ` ${line}`),\n ` readonly select?: \"row\";`,\n ` }): Promise<SearchHit<${typeNames.payload}>[]>;`,\n `};`,\n ];\n return {\n kind: \"method\",\n runtimeGlue: `createSearchDelegate(${JSON.stringify(config)})`,\n imports: [{ from: \"@vibeorm/extensions/search\", names: [\"createSearchDelegate\"] }],\n dtsImports: [{ from: \"@vibeorm/extensions/search\", names: [\"SearchHit\"] }],\n dts,\n };\n },\n },\n\n doctor: async ({ execute, dialect, options: extOptions }) => {\n if (dialect === \"postgres\") {\n const requested = (extOptions[\"engine\"] as SearchEngine | \"auto\" | undefined) ?? \"auto\";\n if (requested === \"bm25\") {\n return { checks: [await pgExtensionCheck({ execute, name: \"pg_search\" })] };\n }\n return { checks: [{ name: \"tsvector\", ok: true, note: \"built in\" }] };\n }\n if (dialect === \"sqlite\") {\n try {\n const rows = await execute({\n text: \"SELECT 1 AS ok FROM pragma_compile_options WHERE compile_options = 'ENABLE_FTS5'\",\n });\n return {\n checks: [\n rows.length > 0\n ? { name: \"fts5\", ok: true, note: \"compiled in\" }\n : { name: \"fts5\", ok: false, note: \"sqlite built without FTS5\" },\n ],\n };\n } catch (error) {\n return {\n checks: [\n {\n name: \"fts5\",\n ok: false,\n note: `check failed: ${error instanceof Error ? error.message : String(error)}`,\n },\n ],\n };\n }\n }\n return { checks: [{ name: \"fulltext\", ok: true, note: \"built in (InnoDB FULLTEXT)\" }] };\n },\n });\n}\n",
|
|
6
6
|
"/**\n * Helpers shared by the tier-1 extensions. Nothing here is privileged —\n * userland extensions can do everything these do with the same public hooks.\n */\n\nimport { VibeError } from \"@vibeorm/schema\";\nimport type {\n ExtensionDoctorCheck,\n ExtensionSqlExecutor,\n ModelIR,\n} from \"@vibeorm/schema\";\n\n// ─── IR lookups ───────────────────────────────────────────────────\n\n/** Table name of a model (`dbName ?? name`). */\nexport function tableNameOf(params: { model: ModelIR }): string {\n return params.model.dbName ?? params.model.name;\n}\n\n/** Column name of a field (`dbName ?? name`); the field must exist. */\nexport function columnNameOf(params: { model: ModelIR; field: string }): string {\n const found = params.model.fields.find((candidate) => candidate.name === params.field);\n if (found === undefined) {\n throw new VibeError({\n code: \"VIBE_INTERNAL\",\n message: `extension referenced unknown field \"${params.field}\" on model \"${params.model.name}\"`,\n meta: { model: params.model.name, field: params.field },\n });\n }\n return found.dbName ?? found.name;\n}\n\n/** The model's single primary-key field name, for key_field-style options. */\nexport function primaryKeyFieldOf(params: { model: ModelIR }): string | null {\n const { model } = params;\n if (model.primaryKey !== undefined && model.primaryKey.fields.length === 1) {\n return model.primaryKey.fields[0] ?? null;\n }\n const idField = model.fields.find((field) => field.isId);\n return idField?.name ?? null;\n}\n\n// ─── Declaration readers (ExtensionDeclIR.options are untyped JSON) ─\n\nexport function declString(decl: Readonly<Record<string, unknown>>, key: string): string | undefined {\n const value = decl[key];\n return typeof value === \"string\" ? value : undefined;\n}\n\nexport function declStringArray(\n decl: Readonly<Record<string, unknown>>,\n key: string,\n): readonly string[] | undefined {\n const value = decl[key];\n if (!Array.isArray(value)) return undefined;\n return value.every((entry): entry is string => typeof entry === \"string\") ? value : undefined;\n}\n\nexport function declNumberArray(\n decl: Readonly<Record<string, unknown>>,\n key: string,\n): readonly number[] | undefined {\n const value = decl[key];\n if (!Array.isArray(value)) return undefined;\n return value.every((entry): entry is number => typeof entry === \"number\") ? value : undefined;\n}\n\n// ─── Identifier safety ────────────────────────────────────────────\n\nconst SQL_LITERAL_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/**\n * Names an extension splices as SQL LITERALS (regconfig names, key_field\n * options) must be plain identifiers — everything else is rejected at parse\n * time so no schema-borne text ever reaches SQL unquoted.\n */\nexport function isSafeSqlName(params: { name: string }): boolean {\n return SQL_LITERAL_NAME.test(params.name);\n}\n\n// ─── Doctor helpers ───────────────────────────────────────────────\n\n/** Availability of a postgres extension, per pg_available_extensions. */\nexport async function pgExtensionCheck(params: {\n execute: ExtensionSqlExecutor;\n name: string;\n}): Promise<ExtensionDoctorCheck> {\n const { execute, name } = params;\n try {\n const rows = await execute({\n text: \"SELECT name, default_version, installed_version FROM pg_available_extensions WHERE name = $1\",\n values: [name],\n });\n const row = rows[0];\n if (row === undefined) {\n return { name: `extension ${name}`, ok: false, note: \"not available on this server\" };\n }\n const installed = row[\"installed_version\"];\n return {\n name: `extension ${name}`,\n ok: true,\n note: installed === null || installed === undefined ? \"available, not installed\" : `installed ${String(installed)}`,\n };\n } catch (error) {\n return {\n name: `extension ${name}`,\n ok: false,\n note: `check failed: ${error instanceof Error ? error.message : String(error)}`,\n };\n }\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";;AAiBA,sBAAS;AAST;;;ACrBA;AAUO,SAAS,WAAW,CAAC,QAAoC;AAAA,EAC9D,OAAO,OAAO,MAAM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
"name": "@vibeorm/extensions",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.4",
|
|
4
4
|
"description": "Tier-1 VibeORM extensions — full-text search, pgvector similarity and pg_trgm fuzzy matching",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"orm",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"bun": ">=1.2.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@vibeorm/runtime": "2.0.0-alpha.
|
|
58
|
-
"@vibeorm/schema": "2.0.0-alpha.
|
|
59
|
-
"@vibeorm/sql": "2.0.0-alpha.
|
|
57
|
+
"@vibeorm/runtime": "2.0.0-alpha.4",
|
|
58
|
+
"@vibeorm/schema": "2.0.0-alpha.4",
|
|
59
|
+
"@vibeorm/sql": "2.0.0-alpha.4"
|
|
60
60
|
},
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|