@prisma-next/extension-paradedb 0.5.0-dev.9 → 0.5.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 +25 -7
- 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
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1",
|
|
3
|
+
"targetFamily": "sql",
|
|
4
|
+
"target": "postgres",
|
|
5
|
+
"profileHash": "sha256:1a8dbe044289f30a1de958fe800cc5a8378b285d2e126a8c44b58864bac2c18e",
|
|
6
|
+
"roots": {},
|
|
7
|
+
"models": {},
|
|
8
|
+
"storage": {
|
|
9
|
+
"storageHash": "sha256:7d13ea93bd4726b9962c00ced807a79149e3ff69e0a47d936c0e82f39a637393",
|
|
10
|
+
"tables": {}
|
|
11
|
+
},
|
|
12
|
+
"capabilities": {
|
|
13
|
+
"postgres": {
|
|
14
|
+
"jsonAgg": true,
|
|
15
|
+
"lateral": true,
|
|
16
|
+
"limit": true,
|
|
17
|
+
"orderBy": true,
|
|
18
|
+
"returning": true
|
|
19
|
+
},
|
|
20
|
+
"sql": {
|
|
21
|
+
"defaultInInsert": true,
|
|
22
|
+
"enums": true,
|
|
23
|
+
"returning": true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"extensionPacks": {},
|
|
27
|
+
"meta": {},
|
|
28
|
+
"_generated": {
|
|
29
|
+
"warning": "⚠️ GENERATED FILE - DO NOT EDIT",
|
|
30
|
+
"message": "This file is automatically generated by \"prisma-next contract emit\".",
|
|
31
|
+
"regenerate": "To regenerate, run: prisma-next contract emit"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// PSL contract source for the `extension-paradedb` package.
|
|
2
|
+
//
|
|
3
|
+
// Authored against the contract-space package layout convention. The same
|
|
4
|
+
// emit pipeline application authors use is applied here:
|
|
5
|
+
//
|
|
6
|
+
// `prisma-next contract emit` → `<package>/src/contract.{json,d.ts}`
|
|
7
|
+
// `prisma-next migration plan` → `<package>/migrations/<dirName>/`
|
|
8
|
+
//
|
|
9
|
+
// The descriptor at `src/exports/control.ts` then wires the emitted JSON
|
|
10
|
+
// artefacts via JSON-import declarations.
|
|
11
|
+
//
|
|
12
|
+
// ## IR coverage
|
|
13
|
+
//
|
|
14
|
+
// paradedb ships **no tables** and **no native types** of its own. Its
|
|
15
|
+
// baseline migration installs the `pg_search` Postgres extension; all
|
|
16
|
+
// BM25 index configuration is carried by the user contract's own models
|
|
17
|
+
// (via the `'bm25'` index-type entry registered in `src/types/index-types.ts`).
|
|
18
|
+
// The contract IR is therefore intentionally empty — the space is still
|
|
19
|
+
// required so the migration runner can track the `pg_search` installation
|
|
20
|
+
// invariant independently of any user models.
|
|
21
|
+
//
|
|
22
|
+
// @see docs/architecture docs/adrs/ADR 212 - Contract spaces.md
|
package/src/core/constants.ts
CHANGED
|
@@ -4,19 +4,30 @@
|
|
|
4
4
|
export const PARADEDB_EXTENSION_ID = 'paradedb' as const;
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Static names and identifiers used across paradedb's contract space.
|
|
8
|
+
*
|
|
9
|
+
* Centralised here so the contract IR (`./contract`), the baseline
|
|
10
|
+
* migration ops (`./migrations`), the head ref, and the descriptor
|
|
11
|
+
* (`../exports/control`) all reference the same values without typos.
|
|
12
|
+
*
|
|
13
|
+
* The space identifier `'paradedb'` is what the framework writes to
|
|
14
|
+
* `migrations/` in the user's repo and what the marker table's
|
|
15
|
+
* `space` column carries for paradedb-owned rows.
|
|
16
|
+
*
|
|
17
|
+
* The `paradedb:*` invariantId namespace is locked here — once
|
|
18
|
+
* published, an invariantId is immutable so downstream consumers can
|
|
19
|
+
* reference it by literal string match.
|
|
9
20
|
*/
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
export const PARADEDB_SPACE_ID = 'paradedb' as const;
|
|
22
|
+
|
|
23
|
+
export const PARADEDB_BASELINE_MIGRATION_NAME =
|
|
24
|
+
'20260601T0000_install_pg_search_extension' as const;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* `paradedb:*` invariantIds emitted by the baseline migration. Each id,
|
|
28
|
+
* once published, is immutable: downstream consumers reference them by
|
|
29
|
+
* literal string match.
|
|
30
|
+
*/
|
|
31
|
+
export const PARADEDB_INVARIANTS = {
|
|
32
|
+
installPgSearch: 'paradedb:install-pg-search-v1',
|
|
33
|
+
} as const;
|
|
@@ -1,4 +1,194 @@
|
|
|
1
|
+
import { LiteralExpr } from '@prisma-next/sql-relational-core/ast';
|
|
2
|
+
import { buildOperation, toExpr } from '@prisma-next/sql-relational-core/expression';
|
|
3
|
+
import { paradedbIndexTypes } from '../types/index-types';
|
|
4
|
+
import type { QueryOperationTypes } from '../types/operation-types';
|
|
1
5
|
import { PARADEDB_EXTENSION_ID } from './constants';
|
|
6
|
+
import { ParadeDbProximityChain } from './proximity-chain';
|
|
7
|
+
|
|
8
|
+
type CodecTypesBase = Record<string, { readonly input: unknown; readonly output: unknown }>;
|
|
9
|
+
|
|
10
|
+
const TEXT = 'pg/text@1' as const;
|
|
11
|
+
const BOOL = 'pg/bool@1' as const;
|
|
12
|
+
const FLOAT4 = 'pg/float4@1' as const;
|
|
13
|
+
const INT4 = 'pg/int4@1' as const;
|
|
14
|
+
|
|
15
|
+
export function paradedbQueryOperations<CT extends CodecTypesBase>(): QueryOperationTypes<CT> {
|
|
16
|
+
return {
|
|
17
|
+
// `@@@` accepts both text and structured query types on its RHS.
|
|
18
|
+
// https://docs.paradedb.com/documentation/full-text/match
|
|
19
|
+
paradeDbMatch: {
|
|
20
|
+
self: { codecId: TEXT },
|
|
21
|
+
impl: (self, query) =>
|
|
22
|
+
buildOperation({
|
|
23
|
+
method: 'paradeDbMatch',
|
|
24
|
+
args: [toExpr(self, TEXT), toExpr(query, TEXT)],
|
|
25
|
+
returns: { codecId: BOOL, nullable: false },
|
|
26
|
+
lowering: {
|
|
27
|
+
targetFamily: 'sql',
|
|
28
|
+
strategy: 'function',
|
|
29
|
+
template: '{{self}} @@@ {{arg0}}',
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
paradeDbMatchAny: {
|
|
34
|
+
self: { codecId: TEXT },
|
|
35
|
+
impl: (self, query) =>
|
|
36
|
+
buildOperation({
|
|
37
|
+
method: 'paradeDbMatchAny',
|
|
38
|
+
args: [toExpr(self, TEXT), toExpr(query, TEXT)],
|
|
39
|
+
returns: { codecId: BOOL, nullable: false },
|
|
40
|
+
lowering: {
|
|
41
|
+
targetFamily: 'sql',
|
|
42
|
+
strategy: 'function',
|
|
43
|
+
template: '{{self}} ||| {{arg0}}',
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
paradeDbMatchAll: {
|
|
48
|
+
self: { codecId: TEXT },
|
|
49
|
+
impl: (self, query) =>
|
|
50
|
+
buildOperation({
|
|
51
|
+
method: 'paradeDbMatchAll',
|
|
52
|
+
args: [toExpr(self, TEXT), toExpr(query, TEXT)],
|
|
53
|
+
returns: { codecId: BOOL, nullable: false },
|
|
54
|
+
lowering: {
|
|
55
|
+
targetFamily: 'sql',
|
|
56
|
+
strategy: 'function',
|
|
57
|
+
template: '{{self}} &&& {{arg0}}',
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
},
|
|
61
|
+
// https://docs.paradedb.com/documentation/full-text/term
|
|
62
|
+
paradeDbTerm: {
|
|
63
|
+
self: { codecId: TEXT },
|
|
64
|
+
impl: (self, query) =>
|
|
65
|
+
buildOperation({
|
|
66
|
+
method: 'paradeDbTerm',
|
|
67
|
+
args: [toExpr(self, TEXT), toExpr(query, TEXT)],
|
|
68
|
+
returns: { codecId: BOOL, nullable: false },
|
|
69
|
+
lowering: {
|
|
70
|
+
targetFamily: 'sql',
|
|
71
|
+
strategy: 'function',
|
|
72
|
+
template: '{{self}} === {{arg0}}',
|
|
73
|
+
},
|
|
74
|
+
}),
|
|
75
|
+
},
|
|
76
|
+
// https://docs.paradedb.com/documentation/full-text/phrase
|
|
77
|
+
paradeDbPhrase: {
|
|
78
|
+
self: { codecId: TEXT },
|
|
79
|
+
impl: (self, query) =>
|
|
80
|
+
buildOperation({
|
|
81
|
+
method: 'paradeDbPhrase',
|
|
82
|
+
args: [toExpr(self, TEXT), toExpr(query, TEXT)],
|
|
83
|
+
returns: { codecId: BOOL, nullable: false },
|
|
84
|
+
lowering: {
|
|
85
|
+
targetFamily: 'sql',
|
|
86
|
+
strategy: 'function',
|
|
87
|
+
template: '{{self}} ### {{arg0}}',
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
},
|
|
91
|
+
// https://docs.paradedb.com/documentation/sorting/score
|
|
92
|
+
paradeDbScore: {
|
|
93
|
+
self: { codecId: INT4 },
|
|
94
|
+
impl: (self) =>
|
|
95
|
+
buildOperation({
|
|
96
|
+
method: 'paradeDbScore',
|
|
97
|
+
args: [toExpr(self, INT4)],
|
|
98
|
+
returns: { codecId: FLOAT4, nullable: false },
|
|
99
|
+
lowering: {
|
|
100
|
+
targetFamily: 'sql',
|
|
101
|
+
strategy: 'function',
|
|
102
|
+
template: 'pdb.score({{self}})',
|
|
103
|
+
},
|
|
104
|
+
}),
|
|
105
|
+
},
|
|
106
|
+
// PG rejects parameterized typmods, so the cast argument lowers to a literal.
|
|
107
|
+
// https://docs.paradedb.com/documentation/full-text/fuzzy
|
|
108
|
+
paradeDbFuzzy: {
|
|
109
|
+
self: { codecId: TEXT },
|
|
110
|
+
impl: (self, distance) => {
|
|
111
|
+
if (!Number.isInteger(distance) || distance < 0 || distance > 2) {
|
|
112
|
+
throw new Error(
|
|
113
|
+
`paradeDbFuzzy: distance must be an integer in [0, 2]; got ${String(distance)}`,
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
return buildOperation({
|
|
117
|
+
method: 'paradeDbFuzzy',
|
|
118
|
+
args: [toExpr(self, TEXT), LiteralExpr.of(distance)],
|
|
119
|
+
returns: { codecId: TEXT, nullable: false },
|
|
120
|
+
lowering: {
|
|
121
|
+
targetFamily: 'sql',
|
|
122
|
+
strategy: 'function',
|
|
123
|
+
template: '{{self}}::pdb.fuzzy({{arg0}})',
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
// https://docs.paradedb.com/documentation/sorting/boost
|
|
129
|
+
paradeDbBoost: {
|
|
130
|
+
self: { codecId: TEXT },
|
|
131
|
+
impl: (self, weight) => {
|
|
132
|
+
if (!Number.isInteger(weight) || weight < -2048 || weight > 2048) {
|
|
133
|
+
throw new Error(
|
|
134
|
+
`paradeDbBoost: boost must be an integer in [-2048, 2048]; got ${String(weight)}`,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
return buildOperation({
|
|
138
|
+
method: 'paradeDbBoost',
|
|
139
|
+
args: [toExpr(self, TEXT), LiteralExpr.of(weight)],
|
|
140
|
+
returns: { codecId: TEXT, nullable: false },
|
|
141
|
+
lowering: {
|
|
142
|
+
targetFamily: 'sql',
|
|
143
|
+
strategy: 'function',
|
|
144
|
+
template: '{{self}}::pdb.boost({{arg0}})',
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
paradeDbConst: {
|
|
150
|
+
self: { codecId: TEXT },
|
|
151
|
+
impl: (self, value) => {
|
|
152
|
+
if (!Number.isInteger(value)) {
|
|
153
|
+
throw new Error(`paradeDbConst: value must be an integer; got ${String(value)}`);
|
|
154
|
+
}
|
|
155
|
+
return buildOperation({
|
|
156
|
+
method: 'paradeDbConst',
|
|
157
|
+
args: [toExpr(self, TEXT), LiteralExpr.of(value)],
|
|
158
|
+
returns: { codecId: TEXT, nullable: false },
|
|
159
|
+
lowering: {
|
|
160
|
+
targetFamily: 'sql',
|
|
161
|
+
strategy: 'function',
|
|
162
|
+
template: '{{self}}::pdb.const({{arg0}})',
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
paradeDbSlop: {
|
|
168
|
+
self: { codecId: TEXT },
|
|
169
|
+
impl: (self, slop) => {
|
|
170
|
+
if (!Number.isInteger(slop) || slop < 0) {
|
|
171
|
+
throw new Error(`paradeDbSlop: slop must be a non-negative integer; got ${String(slop)}`);
|
|
172
|
+
}
|
|
173
|
+
return buildOperation({
|
|
174
|
+
method: 'paradeDbSlop',
|
|
175
|
+
args: [toExpr(self, TEXT), LiteralExpr.of(slop)],
|
|
176
|
+
returns: { codecId: TEXT, nullable: false },
|
|
177
|
+
lowering: {
|
|
178
|
+
targetFamily: 'sql',
|
|
179
|
+
strategy: 'function',
|
|
180
|
+
template: '{{self}}::pdb.slop({{arg0}})',
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
// https://docs.paradedb.com/documentation/full-text/proximity
|
|
186
|
+
paradeDbProximity: {
|
|
187
|
+
self: { codecId: TEXT },
|
|
188
|
+
impl: (start) => new ParadeDbProximityChain(start),
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
}
|
|
2
192
|
|
|
3
193
|
export const paradedbPackMeta = {
|
|
4
194
|
kind: 'extension',
|
|
@@ -11,4 +201,14 @@ export const paradedbPackMeta = {
|
|
|
11
201
|
'paradedb/bm25': true,
|
|
12
202
|
},
|
|
13
203
|
},
|
|
204
|
+
indexTypes: paradedbIndexTypes,
|
|
205
|
+
types: {
|
|
206
|
+
queryOperationTypes: {
|
|
207
|
+
import: {
|
|
208
|
+
package: '@prisma-next/extension-paradedb/operation-types',
|
|
209
|
+
named: 'QueryOperationTypes',
|
|
210
|
+
alias: 'ParadeDbQueryOperationTypes',
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
},
|
|
14
214
|
} as const;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type AnyExpression,
|
|
3
|
+
LiteralExpr,
|
|
4
|
+
OperationExpr,
|
|
5
|
+
} from '@prisma-next/sql-relational-core/ast';
|
|
6
|
+
import { type Expression, toExpr } from '@prisma-next/sql-relational-core/expression';
|
|
7
|
+
|
|
8
|
+
const TEXT = 'pg/text@1' as const;
|
|
9
|
+
|
|
10
|
+
export type ProximityTerm = unknown;
|
|
11
|
+
|
|
12
|
+
export interface ProximityWithinOptions {
|
|
13
|
+
readonly ordered?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface ProximityStep {
|
|
17
|
+
readonly distance: number;
|
|
18
|
+
readonly term: ProximityTerm;
|
|
19
|
+
readonly ordered: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// https://docs.paradedb.com/documentation/full-text/proximity
|
|
23
|
+
export class ParadeDbProximityChain
|
|
24
|
+
implements Expression<{ codecId: 'pg/text@1'; nullable: false }>
|
|
25
|
+
{
|
|
26
|
+
readonly returnType = { codecId: TEXT, nullable: false } as const;
|
|
27
|
+
|
|
28
|
+
private readonly start: ProximityTerm;
|
|
29
|
+
private readonly steps: readonly ProximityStep[];
|
|
30
|
+
|
|
31
|
+
constructor(start: ProximityTerm, steps: readonly ProximityStep[] = []) {
|
|
32
|
+
this.start = start;
|
|
33
|
+
this.steps = steps;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
within(
|
|
37
|
+
distance: number,
|
|
38
|
+
term: ProximityTerm,
|
|
39
|
+
options?: ProximityWithinOptions,
|
|
40
|
+
): ParadeDbProximityChain {
|
|
41
|
+
if (!Number.isInteger(distance) || distance < 0) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`paradeDbProximity.within: distance must be a non-negative integer; got ${String(distance)}`,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return new ParadeDbProximityChain(this.start, [
|
|
47
|
+
...this.steps,
|
|
48
|
+
{ distance, term, ordered: options?.ordered === true },
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
buildAst(): AnyExpression {
|
|
53
|
+
if (this.steps.length === 0) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
'paradeDbProximity: chain must have at least one .within(distance, term) step',
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
const args: AnyExpression[] = [toExpr(this.start, TEXT)];
|
|
59
|
+
let template = '({{self}}';
|
|
60
|
+
this.steps.forEach((step, i) => {
|
|
61
|
+
const op = step.ordered ? '##>' : '##';
|
|
62
|
+
args.push(LiteralExpr.of(step.distance));
|
|
63
|
+
args.push(toExpr(step.term, TEXT));
|
|
64
|
+
template += ` ${op} {{arg${2 * i}}} ${op} {{arg${2 * i + 1}}}`;
|
|
65
|
+
});
|
|
66
|
+
template += ')';
|
|
67
|
+
const [self, ...rest] = args;
|
|
68
|
+
if (!self) {
|
|
69
|
+
throw new Error('paradeDbProximity: invariant violation — empty args');
|
|
70
|
+
}
|
|
71
|
+
return new OperationExpr({
|
|
72
|
+
method: 'paradeDbProximity',
|
|
73
|
+
self,
|
|
74
|
+
args: rest.length > 0 ? rest : undefined,
|
|
75
|
+
returns: this.returnType,
|
|
76
|
+
lowering: {
|
|
77
|
+
targetFamily: 'sql',
|
|
78
|
+
strategy: 'function',
|
|
79
|
+
template,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
package/src/exports/control.ts
CHANGED
|
@@ -1,3 +1,71 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Control-plane descriptor for the paradedb extension.
|
|
3
|
+
*
|
|
4
|
+
* **Contract-space package layout.** The extension's contract
|
|
5
|
+
* + migrations are emitted by the same pipeline application authors use:
|
|
6
|
+
*
|
|
7
|
+
* `prisma-next contract emit` → `<package>/src/contract.{json,d.ts}`
|
|
8
|
+
* `prisma-next migration plan` → `<package>/migrations/<dir>/...`
|
|
9
|
+
*
|
|
10
|
+
* The descriptor wires those JSON artefacts via JSON-import declarations
|
|
11
|
+
* so they flow through the consuming application's module resolver
|
|
12
|
+
* without filesystem assumptions, and synthesises the canonical
|
|
13
|
+
* {@link import('@prisma-next/framework-components/control').MigrationPackage}
|
|
14
|
+
* shape for the framework's runner / verifier to consume. Readers in
|
|
15
|
+
* `@prisma-next/migration-tools` add `dirPath` when loading from disk
|
|
16
|
+
* (`OnDiskMigrationPackage`); descriptor-bundled packages do not need
|
|
17
|
+
* it because the framework reads them directly from the descriptor.
|
|
18
|
+
*
|
|
19
|
+
* Wired surfaces:
|
|
20
|
+
*
|
|
21
|
+
* - `contractSpace.{contractJson,migrations,headRef}` — sourced from
|
|
22
|
+
* the on-disk artefacts emitted by `build:contract-space`.
|
|
23
|
+
* - `queryOperations` — BM25 full-text search operations registered
|
|
24
|
+
* via `paradedbQueryOperations()`.
|
|
25
|
+
*
|
|
26
|
+
* @see docs/architecture docs/adrs/ADR 212 - Contract spaces.md
|
|
27
|
+
* (contract-space package layout convention).
|
|
28
|
+
*/
|
|
2
29
|
|
|
3
|
-
|
|
30
|
+
import type { Contract } from '@prisma-next/contract/types';
|
|
31
|
+
import type { SqlControlExtensionDescriptor } from '@prisma-next/family-sql/control';
|
|
32
|
+
import { contractSpaceFromJson } from '@prisma-next/migration-tools/spaces';
|
|
33
|
+
import type { SqlStorage } from '@prisma-next/sql-contract/types';
|
|
34
|
+
import baselineMetadata from '../../migrations/20260601T0000_install_pg_search_extension/migration.json' with {
|
|
35
|
+
type: 'json',
|
|
36
|
+
};
|
|
37
|
+
import baselineOps from '../../migrations/20260601T0000_install_pg_search_extension/ops.json' with {
|
|
38
|
+
type: 'json',
|
|
39
|
+
};
|
|
40
|
+
import headRef from '../../migrations/refs/head.json' with { type: 'json' };
|
|
41
|
+
import contractJson from '../contract.json' with { type: 'json' };
|
|
42
|
+
import { PARADEDB_SPACE_ID } from '../core/constants';
|
|
43
|
+
import { paradedbPackMeta, paradedbQueryOperations } from '../core/descriptor-meta';
|
|
44
|
+
|
|
45
|
+
const BASELINE_DIR_NAME = '20260601T0000_install_pg_search_extension';
|
|
46
|
+
|
|
47
|
+
const paradedbContractSpace = contractSpaceFromJson<Contract<SqlStorage>>({
|
|
48
|
+
contractJson,
|
|
49
|
+
migrations: [
|
|
50
|
+
{
|
|
51
|
+
dirName: BASELINE_DIR_NAME,
|
|
52
|
+
metadata: baselineMetadata,
|
|
53
|
+
ops: baselineOps,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
headRef,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const paradedbExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {
|
|
60
|
+
...paradedbPackMeta,
|
|
61
|
+
id: PARADEDB_SPACE_ID,
|
|
62
|
+
contractSpace: paradedbContractSpace,
|
|
63
|
+
queryOperations: () => paradedbQueryOperations(),
|
|
64
|
+
create: () => ({
|
|
65
|
+
familyId: 'sql' as const,
|
|
66
|
+
targetId: 'postgres' as const,
|
|
67
|
+
}),
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { paradedbExtensionDescriptor, paradedbPackMeta };
|
|
71
|
+
export default paradedbExtensionDescriptor;
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
export
|
|
3
|
-
Bm25ColumnFieldConfig,
|
|
4
|
-
Bm25ExpressionFieldConfig,
|
|
5
|
-
Bm25ExpressionFieldOptions,
|
|
6
|
-
Bm25FieldConfig,
|
|
7
|
-
Bm25IndexConfig,
|
|
8
|
-
Bm25IndexOptions,
|
|
9
|
-
Bm25JsonFieldOptions,
|
|
10
|
-
Bm25TextFieldOptions,
|
|
11
|
-
} from '../types/index-types';
|
|
12
|
-
export { bm25, bm25Index } from '../types/index-types';
|
|
1
|
+
export type { Bm25IndexOptions, IndexTypes } from '../types/index-types';
|
|
2
|
+
export { paradedbIndexTypes } from '../types/index-types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { QueryOperationTypes } from '../types/operation-types';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SqlRuntimeExtensionDescriptor } from '@prisma-next/sql-runtime';
|
|
2
|
+
import { paradedbPackMeta, paradedbQueryOperations } from '../core/descriptor-meta';
|
|
3
|
+
|
|
4
|
+
const paradedbRuntimeDescriptor: SqlRuntimeExtensionDescriptor<'postgres'> = {
|
|
5
|
+
kind: 'extension' as const,
|
|
6
|
+
id: paradedbPackMeta.id,
|
|
7
|
+
version: paradedbPackMeta.version,
|
|
8
|
+
familyId: 'sql' as const,
|
|
9
|
+
targetId: 'postgres' as const,
|
|
10
|
+
codecs: () => [],
|
|
11
|
+
queryOperations: () => paradedbQueryOperations(),
|
|
12
|
+
create() {
|
|
13
|
+
return {
|
|
14
|
+
familyId: 'sql' as const,
|
|
15
|
+
targetId: 'postgres' as const,
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default paradedbRuntimeDescriptor;
|