@prisma-next/extension-paradedb 0.5.0-dev.9 → 0.6.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -105
- package/dist/control.d.mts +21 -1
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +132 -2
- package/dist/control.mjs.map +1 -0
- package/dist/descriptor-meta-Dr4mAlbx.mjs +276 -0
- package/dist/descriptor-meta-Dr4mAlbx.mjs.map +1 -0
- package/dist/index-types-BZqoAhWT.mjs +11 -0
- package/dist/index-types-BZqoAhWT.mjs.map +1 -0
- package/dist/index-types.d.mts +9 -106
- package/dist/index-types.d.mts.map +1 -1
- package/dist/index-types.mjs +2 -84
- package/dist/operation-types-DXmTJ7jd.d.mts +135 -0
- package/dist/operation-types-DXmTJ7jd.d.mts.map +1 -0
- package/dist/operation-types.d.mts +2 -0
- package/dist/operation-types.mjs +1 -0
- package/dist/pack.d.mts +16 -0
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +3 -5
- package/dist/pack.mjs.map +1 -1
- package/dist/runtime.d.mts +7 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +21 -0
- package/dist/runtime.mjs.map +1 -0
- package/package.json +24 -6
- package/src/contract.d.ts +81 -0
- package/src/contract.json +33 -0
- package/src/contract.prisma +22 -0
- package/src/core/constants.ts +26 -15
- package/src/core/descriptor-meta.ts +200 -0
- package/src/core/proximity-chain.ts +83 -0
- package/src/exports/control.ts +70 -2
- package/src/exports/index-types.ts +2 -12
- package/src/exports/operation-types.ts +1 -0
- package/src/exports/runtime.ts +20 -0
- package/src/types/index-types.ts +12 -179
- package/src/types/operation-types.ts +84 -0
- package/dist/descriptor-meta-BTFnIGJ6.mjs +0 -20
- package/dist/descriptor-meta-BTFnIGJ6.mjs.map +0 -1
- package/dist/index-types.mjs.map +0 -1
package/src/types/index-types.ts
CHANGED
|
@@ -1,179 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* BM25 field config for a SQL expression.
|
|
17
|
-
*/
|
|
18
|
-
export type Bm25ExpressionFieldConfig = {
|
|
19
|
-
readonly expression: string;
|
|
20
|
-
readonly column?: never;
|
|
21
|
-
readonly alias: string;
|
|
22
|
-
readonly tokenizer?: string;
|
|
23
|
-
readonly tokenizerParams?: Record<string, unknown>;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* BM25 field config union.
|
|
28
|
-
*/
|
|
29
|
-
export type Bm25FieldConfig = Bm25ColumnFieldConfig | Bm25ExpressionFieldConfig;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* BM25 index configuration payload stored in `IndexDef.config`.
|
|
33
|
-
*/
|
|
34
|
-
export type Bm25IndexConfig = {
|
|
35
|
-
readonly keyField: string;
|
|
36
|
-
readonly fields: readonly Bm25FieldConfig[];
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Options for a BM25 text field (text, varchar columns).
|
|
41
|
-
*/
|
|
42
|
-
export type Bm25TextFieldOptions = {
|
|
43
|
-
readonly tokenizer?: TokenizerId | (string & {});
|
|
44
|
-
readonly stemmer?: string;
|
|
45
|
-
readonly alias?: string;
|
|
46
|
-
readonly remove_emojis?: boolean;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Options for a BM25 JSON field (json, jsonb columns).
|
|
51
|
-
*/
|
|
52
|
-
export type Bm25JsonFieldOptions = {
|
|
53
|
-
readonly tokenizer?: TokenizerId | (string & {});
|
|
54
|
-
readonly alias?: string;
|
|
55
|
-
/** Ngram-specific params when tokenizer is 'ngram'. */
|
|
56
|
-
readonly min?: number;
|
|
57
|
-
readonly max?: number;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Options for a BM25 expression-based field.
|
|
62
|
-
*/
|
|
63
|
-
export type Bm25ExpressionFieldOptions = {
|
|
64
|
-
readonly alias: string;
|
|
65
|
-
readonly tokenizer?: TokenizerId | (string & {});
|
|
66
|
-
readonly min?: number;
|
|
67
|
-
readonly max?: number;
|
|
68
|
-
readonly stemmer?: string;
|
|
69
|
-
readonly pattern?: string;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
type TokenizerConfig = {
|
|
73
|
-
readonly tokenizer?: string;
|
|
74
|
-
readonly tokenizerParams?: Record<string, unknown>;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Options for constructing a BM25 index definition.
|
|
79
|
-
*/
|
|
80
|
-
export type Bm25IndexOptions = {
|
|
81
|
-
readonly keyField: string;
|
|
82
|
-
readonly fields: readonly Bm25FieldConfig[];
|
|
83
|
-
readonly name?: string;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Typed BM25 field builders.
|
|
88
|
-
* These produce `Bm25FieldConfig` objects for use in `bm25Index()`.
|
|
89
|
-
*/
|
|
90
|
-
export const bm25 = {
|
|
91
|
-
/** Text field with optional tokenizer config. */
|
|
92
|
-
text(column: string, opts?: Bm25TextFieldOptions): Bm25FieldConfig {
|
|
93
|
-
return {
|
|
94
|
-
column,
|
|
95
|
-
...buildTokenizerConfig(opts?.tokenizer, {
|
|
96
|
-
stemmer: opts?.stemmer,
|
|
97
|
-
remove_emojis: opts?.remove_emojis,
|
|
98
|
-
}),
|
|
99
|
-
...(opts?.alias !== undefined && { alias: opts.alias }),
|
|
100
|
-
};
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
/** Numeric field (filterable, sortable in BM25). */
|
|
104
|
-
numeric(column: string): Bm25FieldConfig {
|
|
105
|
-
return { column };
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
/** Boolean field. */
|
|
109
|
-
boolean(column: string): Bm25FieldConfig {
|
|
110
|
-
return { column };
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
/** JSON/JSONB field with optional tokenizer config. */
|
|
114
|
-
json(column: string, opts?: Bm25JsonFieldOptions): Bm25FieldConfig {
|
|
115
|
-
return {
|
|
116
|
-
column,
|
|
117
|
-
...buildTokenizerConfig(opts?.tokenizer, { min: opts?.min, max: opts?.max }),
|
|
118
|
-
...(opts?.alias !== undefined && { alias: opts.alias }),
|
|
119
|
-
};
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
/** Datetime (timestamp/date) field. */
|
|
123
|
-
datetime(column: string): Bm25FieldConfig {
|
|
124
|
-
return { column };
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
/** Range field. */
|
|
128
|
-
range(column: string): Bm25FieldConfig {
|
|
129
|
-
return { column };
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
/** Raw SQL expression field. `alias` is required. */
|
|
133
|
-
expression(sql: string, opts: Bm25ExpressionFieldOptions): Bm25FieldConfig {
|
|
134
|
-
return {
|
|
135
|
-
expression: sql,
|
|
136
|
-
alias: opts.alias,
|
|
137
|
-
...buildTokenizerConfig(opts.tokenizer, {
|
|
138
|
-
min: opts.min,
|
|
139
|
-
max: opts.max,
|
|
140
|
-
stemmer: opts.stemmer,
|
|
141
|
-
pattern: opts.pattern,
|
|
142
|
-
}),
|
|
143
|
-
};
|
|
144
|
-
},
|
|
145
|
-
} as const;
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Creates a generic index definition with a ParadeDB BM25 payload.
|
|
149
|
-
*
|
|
150
|
-
* `columns` only includes real table columns so core index validation remains
|
|
151
|
-
* target-agnostic. Expression fields stay in extension-owned `config.fields`.
|
|
152
|
-
*/
|
|
153
|
-
export function bm25Index(opts: Bm25IndexOptions): IndexDef {
|
|
154
|
-
return {
|
|
155
|
-
columns: opts.fields.flatMap((field) => ('column' in field ? [field.column] : [])),
|
|
156
|
-
...(opts.name !== undefined && { name: opts.name }),
|
|
157
|
-
using: 'bm25',
|
|
158
|
-
config: {
|
|
159
|
-
keyField: opts.keyField,
|
|
160
|
-
fields: opts.fields,
|
|
161
|
-
} satisfies Bm25IndexConfig,
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Builds `{ tokenizer, tokenizerParams? }` from a tokenizer ID and a bag of params.
|
|
167
|
-
* Filters out undefined values and omits `tokenizerParams` when empty.
|
|
168
|
-
*/
|
|
169
|
-
function buildTokenizerConfig(
|
|
170
|
-
tokenizer: string | undefined,
|
|
171
|
-
params: Record<string, unknown>,
|
|
172
|
-
): TokenizerConfig {
|
|
173
|
-
if (!tokenizer) return {};
|
|
174
|
-
const filtered = Object.fromEntries(Object.entries(params).filter(([, v]) => v !== undefined));
|
|
175
|
-
return {
|
|
176
|
-
tokenizer,
|
|
177
|
-
...(Object.keys(filtered).length > 0 && { tokenizerParams: filtered }),
|
|
178
|
-
};
|
|
179
|
-
}
|
|
1
|
+
import { defineIndexTypes } from '@prisma-next/sql-contract/index-types';
|
|
2
|
+
import { type } from 'arktype';
|
|
3
|
+
|
|
4
|
+
export const paradedbIndexTypes = defineIndexTypes().add('bm25', {
|
|
5
|
+
options: type({
|
|
6
|
+
'+': 'reject',
|
|
7
|
+
key_field: 'string',
|
|
8
|
+
}),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export type IndexTypes = typeof paradedbIndexTypes.IndexTypes;
|
|
12
|
+
export type Bm25IndexOptions = IndexTypes['bm25']['options'];
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { SqlQueryOperationTypes } from '@prisma-next/sql-contract/types';
|
|
2
|
+
import type { CodecExpression, Expression } from '@prisma-next/sql-relational-core/expression';
|
|
3
|
+
import type { ParadeDbProximityChain } from '../core/proximity-chain';
|
|
4
|
+
|
|
5
|
+
type CodecTypesBase = Record<string, { readonly input: unknown; readonly output: unknown }>;
|
|
6
|
+
|
|
7
|
+
export type QueryOperationTypes<CT extends CodecTypesBase> = SqlQueryOperationTypes<
|
|
8
|
+
CT,
|
|
9
|
+
{
|
|
10
|
+
readonly paradeDbMatch: {
|
|
11
|
+
readonly self: { readonly codecId: 'pg/text@1' };
|
|
12
|
+
readonly impl: (
|
|
13
|
+
self: CodecExpression<'pg/text@1', boolean, CT>,
|
|
14
|
+
query: CodecExpression<'pg/text@1', boolean, CT>,
|
|
15
|
+
) => Expression<{ codecId: 'pg/bool@1'; nullable: false }>;
|
|
16
|
+
};
|
|
17
|
+
readonly paradeDbMatchAny: {
|
|
18
|
+
readonly self: { readonly codecId: 'pg/text@1' };
|
|
19
|
+
readonly impl: (
|
|
20
|
+
self: CodecExpression<'pg/text@1', boolean, CT>,
|
|
21
|
+
query: CodecExpression<'pg/text@1', boolean, CT>,
|
|
22
|
+
) => Expression<{ codecId: 'pg/bool@1'; nullable: false }>;
|
|
23
|
+
};
|
|
24
|
+
readonly paradeDbMatchAll: {
|
|
25
|
+
readonly self: { readonly codecId: 'pg/text@1' };
|
|
26
|
+
readonly impl: (
|
|
27
|
+
self: CodecExpression<'pg/text@1', boolean, CT>,
|
|
28
|
+
query: CodecExpression<'pg/text@1', boolean, CT>,
|
|
29
|
+
) => Expression<{ codecId: 'pg/bool@1'; nullable: false }>;
|
|
30
|
+
};
|
|
31
|
+
readonly paradeDbTerm: {
|
|
32
|
+
readonly self: { readonly codecId: 'pg/text@1' };
|
|
33
|
+
readonly impl: (
|
|
34
|
+
self: CodecExpression<'pg/text@1', boolean, CT>,
|
|
35
|
+
query: CodecExpression<'pg/text@1', boolean, CT>,
|
|
36
|
+
) => Expression<{ codecId: 'pg/bool@1'; nullable: false }>;
|
|
37
|
+
};
|
|
38
|
+
readonly paradeDbPhrase: {
|
|
39
|
+
readonly self: { readonly codecId: 'pg/text@1' };
|
|
40
|
+
readonly impl: (
|
|
41
|
+
self: CodecExpression<'pg/text@1', boolean, CT>,
|
|
42
|
+
query: CodecExpression<'pg/text@1', boolean, CT>,
|
|
43
|
+
) => Expression<{ codecId: 'pg/bool@1'; nullable: false }>;
|
|
44
|
+
};
|
|
45
|
+
readonly paradeDbScore: {
|
|
46
|
+
readonly self: { readonly codecId: 'pg/int4@1' };
|
|
47
|
+
readonly impl: (
|
|
48
|
+
self: CodecExpression<'pg/int4@1', boolean, CT>,
|
|
49
|
+
) => Expression<{ codecId: 'pg/float4@1'; nullable: false }>;
|
|
50
|
+
};
|
|
51
|
+
readonly paradeDbFuzzy: {
|
|
52
|
+
readonly self: { readonly codecId: 'pg/text@1' };
|
|
53
|
+
readonly impl: (
|
|
54
|
+
self: CodecExpression<'pg/text@1', boolean, CT>,
|
|
55
|
+
distance: number,
|
|
56
|
+
) => Expression<{ codecId: 'pg/text@1'; nullable: false }>;
|
|
57
|
+
};
|
|
58
|
+
readonly paradeDbBoost: {
|
|
59
|
+
readonly self: { readonly codecId: 'pg/text@1' };
|
|
60
|
+
readonly impl: (
|
|
61
|
+
self: CodecExpression<'pg/text@1', boolean, CT>,
|
|
62
|
+
weight: number,
|
|
63
|
+
) => Expression<{ codecId: 'pg/text@1'; nullable: false }>;
|
|
64
|
+
};
|
|
65
|
+
readonly paradeDbConst: {
|
|
66
|
+
readonly self: { readonly codecId: 'pg/text@1' };
|
|
67
|
+
readonly impl: (
|
|
68
|
+
self: CodecExpression<'pg/text@1', boolean, CT>,
|
|
69
|
+
value: number,
|
|
70
|
+
) => Expression<{ codecId: 'pg/text@1'; nullable: false }>;
|
|
71
|
+
};
|
|
72
|
+
readonly paradeDbSlop: {
|
|
73
|
+
readonly self: { readonly codecId: 'pg/text@1' };
|
|
74
|
+
readonly impl: (
|
|
75
|
+
self: CodecExpression<'pg/text@1', boolean, CT>,
|
|
76
|
+
slop: number,
|
|
77
|
+
) => Expression<{ codecId: 'pg/text@1'; nullable: false }>;
|
|
78
|
+
};
|
|
79
|
+
readonly paradeDbProximity: {
|
|
80
|
+
readonly self: { readonly codecId: 'pg/text@1' };
|
|
81
|
+
readonly impl: (start: CodecExpression<'pg/text@1', boolean, CT>) => ParadeDbProximityChain;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
//#region src/core/constants.ts
|
|
2
|
-
/**
|
|
3
|
-
* Extension ID for ParadeDB pg_search.
|
|
4
|
-
*/
|
|
5
|
-
const PARADEDB_EXTENSION_ID = "paradedb";
|
|
6
|
-
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/core/descriptor-meta.ts
|
|
9
|
-
const paradedbPackMeta = {
|
|
10
|
-
kind: "extension",
|
|
11
|
-
id: PARADEDB_EXTENSION_ID,
|
|
12
|
-
familyId: "sql",
|
|
13
|
-
targetId: "postgres",
|
|
14
|
-
version: "0.0.1",
|
|
15
|
-
capabilities: { postgres: { "paradedb/bm25": true } }
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { paradedbPackMeta as t };
|
|
20
|
-
//# sourceMappingURL=descriptor-meta-BTFnIGJ6.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor-meta-BTFnIGJ6.mjs","names":[],"sources":["../src/core/constants.ts","../src/core/descriptor-meta.ts"],"sourcesContent":["/**\n * Extension ID for ParadeDB pg_search.\n */\nexport const PARADEDB_EXTENSION_ID = 'paradedb' as const;\n\n/**\n * Built-in ParadeDB tokenizer IDs.\n * These correspond to the `pdb.*` casting syntax in `CREATE INDEX ... USING bm25`.\n */\nexport type TokenizerId =\n | 'unicode_words'\n | 'simple'\n | 'ngram'\n | 'icu'\n | 'regex_pattern'\n | 'source_code'\n | 'literal'\n | 'literal_normalized'\n | 'whitespace'\n | 'chinese_compatible'\n | 'jieba'\n | 'lindera';\n","import { PARADEDB_EXTENSION_ID } from './constants';\n\nexport const paradedbPackMeta = {\n kind: 'extension',\n id: PARADEDB_EXTENSION_ID,\n familyId: 'sql',\n targetId: 'postgres',\n version: '0.0.1',\n capabilities: {\n postgres: {\n 'paradedb/bm25': true,\n },\n },\n} as const;\n"],"mappings":";;;;AAGA,MAAa,wBAAwB;;;;ACDrC,MAAa,mBAAmB;CAC9B,MAAM;CACN,IAAI;CACJ,UAAU;CACV,UAAU;CACV,SAAS;CACT,cAAc,EACZ,UAAU,EACR,iBAAiB,MAClB,EACF;CACF"}
|
package/dist/index-types.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-types.mjs","names":[],"sources":["../src/types/index-types.ts"],"sourcesContent":["import type { IndexDef } from '@prisma-next/contract-authoring';\nimport type { TokenizerId } from '../core/constants';\n\n/**\n * BM25 field config for a table column.\n */\nexport type Bm25ColumnFieldConfig = {\n readonly column: string;\n readonly expression?: never;\n readonly tokenizer?: string;\n readonly tokenizerParams?: Record<string, unknown>;\n readonly alias?: string;\n};\n\n/**\n * BM25 field config for a SQL expression.\n */\nexport type Bm25ExpressionFieldConfig = {\n readonly expression: string;\n readonly column?: never;\n readonly alias: string;\n readonly tokenizer?: string;\n readonly tokenizerParams?: Record<string, unknown>;\n};\n\n/**\n * BM25 field config union.\n */\nexport type Bm25FieldConfig = Bm25ColumnFieldConfig | Bm25ExpressionFieldConfig;\n\n/**\n * BM25 index configuration payload stored in `IndexDef.config`.\n */\nexport type Bm25IndexConfig = {\n readonly keyField: string;\n readonly fields: readonly Bm25FieldConfig[];\n};\n\n/**\n * Options for a BM25 text field (text, varchar columns).\n */\nexport type Bm25TextFieldOptions = {\n readonly tokenizer?: TokenizerId | (string & {});\n readonly stemmer?: string;\n readonly alias?: string;\n readonly remove_emojis?: boolean;\n};\n\n/**\n * Options for a BM25 JSON field (json, jsonb columns).\n */\nexport type Bm25JsonFieldOptions = {\n readonly tokenizer?: TokenizerId | (string & {});\n readonly alias?: string;\n /** Ngram-specific params when tokenizer is 'ngram'. */\n readonly min?: number;\n readonly max?: number;\n};\n\n/**\n * Options for a BM25 expression-based field.\n */\nexport type Bm25ExpressionFieldOptions = {\n readonly alias: string;\n readonly tokenizer?: TokenizerId | (string & {});\n readonly min?: number;\n readonly max?: number;\n readonly stemmer?: string;\n readonly pattern?: string;\n};\n\ntype TokenizerConfig = {\n readonly tokenizer?: string;\n readonly tokenizerParams?: Record<string, unknown>;\n};\n\n/**\n * Options for constructing a BM25 index definition.\n */\nexport type Bm25IndexOptions = {\n readonly keyField: string;\n readonly fields: readonly Bm25FieldConfig[];\n readonly name?: string;\n};\n\n/**\n * Typed BM25 field builders.\n * These produce `Bm25FieldConfig` objects for use in `bm25Index()`.\n */\nexport const bm25 = {\n /** Text field with optional tokenizer config. */\n text(column: string, opts?: Bm25TextFieldOptions): Bm25FieldConfig {\n return {\n column,\n ...buildTokenizerConfig(opts?.tokenizer, {\n stemmer: opts?.stemmer,\n remove_emojis: opts?.remove_emojis,\n }),\n ...(opts?.alias !== undefined && { alias: opts.alias }),\n };\n },\n\n /** Numeric field (filterable, sortable in BM25). */\n numeric(column: string): Bm25FieldConfig {\n return { column };\n },\n\n /** Boolean field. */\n boolean(column: string): Bm25FieldConfig {\n return { column };\n },\n\n /** JSON/JSONB field with optional tokenizer config. */\n json(column: string, opts?: Bm25JsonFieldOptions): Bm25FieldConfig {\n return {\n column,\n ...buildTokenizerConfig(opts?.tokenizer, { min: opts?.min, max: opts?.max }),\n ...(opts?.alias !== undefined && { alias: opts.alias }),\n };\n },\n\n /** Datetime (timestamp/date) field. */\n datetime(column: string): Bm25FieldConfig {\n return { column };\n },\n\n /** Range field. */\n range(column: string): Bm25FieldConfig {\n return { column };\n },\n\n /** Raw SQL expression field. `alias` is required. */\n expression(sql: string, opts: Bm25ExpressionFieldOptions): Bm25FieldConfig {\n return {\n expression: sql,\n alias: opts.alias,\n ...buildTokenizerConfig(opts.tokenizer, {\n min: opts.min,\n max: opts.max,\n stemmer: opts.stemmer,\n pattern: opts.pattern,\n }),\n };\n },\n} as const;\n\n/**\n * Creates a generic index definition with a ParadeDB BM25 payload.\n *\n * `columns` only includes real table columns so core index validation remains\n * target-agnostic. Expression fields stay in extension-owned `config.fields`.\n */\nexport function bm25Index(opts: Bm25IndexOptions): IndexDef {\n return {\n columns: opts.fields.flatMap((field) => ('column' in field ? [field.column] : [])),\n ...(opts.name !== undefined && { name: opts.name }),\n using: 'bm25',\n config: {\n keyField: opts.keyField,\n fields: opts.fields,\n } satisfies Bm25IndexConfig,\n };\n}\n\n/**\n * Builds `{ tokenizer, tokenizerParams? }` from a tokenizer ID and a bag of params.\n * Filters out undefined values and omits `tokenizerParams` when empty.\n */\nfunction buildTokenizerConfig(\n tokenizer: string | undefined,\n params: Record<string, unknown>,\n): TokenizerConfig {\n if (!tokenizer) return {};\n const filtered = Object.fromEntries(Object.entries(params).filter(([, v]) => v !== undefined));\n return {\n tokenizer,\n ...(Object.keys(filtered).length > 0 && { tokenizerParams: filtered }),\n };\n}\n"],"mappings":";;;;;AAyFA,MAAa,OAAO;CAElB,KAAK,QAAgB,MAA8C;AACjE,SAAO;GACL;GACA,GAAG,qBAAqB,MAAM,WAAW;IACvC,SAAS,MAAM;IACf,eAAe,MAAM;IACtB,CAAC;GACF,GAAI,MAAM,UAAU,UAAa,EAAE,OAAO,KAAK,OAAO;GACvD;;CAIH,QAAQ,QAAiC;AACvC,SAAO,EAAE,QAAQ;;CAInB,QAAQ,QAAiC;AACvC,SAAO,EAAE,QAAQ;;CAInB,KAAK,QAAgB,MAA8C;AACjE,SAAO;GACL;GACA,GAAG,qBAAqB,MAAM,WAAW;IAAE,KAAK,MAAM;IAAK,KAAK,MAAM;IAAK,CAAC;GAC5E,GAAI,MAAM,UAAU,UAAa,EAAE,OAAO,KAAK,OAAO;GACvD;;CAIH,SAAS,QAAiC;AACxC,SAAO,EAAE,QAAQ;;CAInB,MAAM,QAAiC;AACrC,SAAO,EAAE,QAAQ;;CAInB,WAAW,KAAa,MAAmD;AACzE,SAAO;GACL,YAAY;GACZ,OAAO,KAAK;GACZ,GAAG,qBAAqB,KAAK,WAAW;IACtC,KAAK,KAAK;IACV,KAAK,KAAK;IACV,SAAS,KAAK;IACd,SAAS,KAAK;IACf,CAAC;GACH;;CAEJ;;;;;;;AAQD,SAAgB,UAAU,MAAkC;AAC1D,QAAO;EACL,SAAS,KAAK,OAAO,SAAS,UAAW,YAAY,QAAQ,CAAC,MAAM,OAAO,GAAG,EAAE,CAAE;EAClF,GAAI,KAAK,SAAS,UAAa,EAAE,MAAM,KAAK,MAAM;EAClD,OAAO;EACP,QAAQ;GACN,UAAU,KAAK;GACf,QAAQ,KAAK;GACd;EACF;;;;;;AAOH,SAAS,qBACP,WACA,QACiB;AACjB,KAAI,CAAC,UAAW,QAAO,EAAE;CACzB,MAAM,WAAW,OAAO,YAAY,OAAO,QAAQ,OAAO,CAAC,QAAQ,GAAG,OAAO,MAAM,OAAU,CAAC;AAC9F,QAAO;EACL;EACA,GAAI,OAAO,KAAK,SAAS,CAAC,SAAS,KAAK,EAAE,iBAAiB,UAAU;EACtE"}
|