@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/README.md
CHANGED
|
@@ -4,21 +4,21 @@ ParadeDB full-text search extension pack for Prisma Next.
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
This extension pack
|
|
7
|
+
This extension pack registers a `'bm25'` index type with the SQL family's index-type registry, so contracts can author BM25 full-text search indexes via the standard `constraints.index(...)` surface and the Postgres adapter emits `CREATE INDEX ... USING bm25 WITH (...)` DDL.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
The v1 surface covers the `key_field` storage parameter only. Per-field tokenizer and column configuration is deferred to expression-index support.
|
|
10
10
|
|
|
11
11
|
## Responsibilities
|
|
12
12
|
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
16
|
-
- **Pack Ref Export**: Ships a pure `/pack` entrypoint for TypeScript contract authoring
|
|
13
|
+
- **bm25 index registration**: declares a `'bm25'` entry via `defineIndexTypes()` carrying an arktype validator for the bm25 options shape
|
|
14
|
+
- **Extension descriptor**: declares the `paradedb/bm25` capability for contract-level feature detection
|
|
15
|
+
- **Pack ref export**: ships a pure `/pack` entrypoint for TypeScript contract authoring
|
|
17
16
|
|
|
18
17
|
## Dependencies
|
|
19
18
|
|
|
20
|
-
- **`@prisma-next/contract`**:
|
|
21
|
-
- **`@prisma-next/contract-authoring`**:
|
|
19
|
+
- **`@prisma-next/sql-contract`**: index-type registry primitive
|
|
20
|
+
- **`@prisma-next/contract`** / **`@prisma-next/contract-authoring`**: core contract types
|
|
21
|
+
- **`arktype`**: option-shape validation
|
|
22
22
|
|
|
23
23
|
## Installation
|
|
24
24
|
|
|
@@ -28,15 +28,14 @@ pnpm add @prisma-next/extension-paradedb
|
|
|
28
28
|
|
|
29
29
|
## Usage
|
|
30
30
|
|
|
31
|
-
### Contract
|
|
31
|
+
### Contract definition
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
Author bm25 indexes via the standard `constraints.index(...)` surface; the registered `'bm25'` entry narrows `options` per-`type`:
|
|
34
34
|
|
|
35
35
|
```typescript
|
|
36
|
-
import { int4Column, textColumn
|
|
36
|
+
import { int4Column, textColumn } from '@prisma-next/adapter-postgres/column-types';
|
|
37
37
|
import sqlFamily from '@prisma-next/family-sql/pack';
|
|
38
38
|
import { defineContract, field, model } from '@prisma-next/sql-contract-ts/contract-builder';
|
|
39
|
-
import { bm25, bm25Index } from '@prisma-next/extension-paradedb/index-types';
|
|
40
39
|
import paradedb from '@prisma-next/extension-paradedb/pack';
|
|
41
40
|
import postgres from '@prisma-next/target-postgres/pack';
|
|
42
41
|
|
|
@@ -48,121 +47,53 @@ export const contract = defineContract({
|
|
|
48
47
|
Item: model('Item', {
|
|
49
48
|
fields: {
|
|
50
49
|
id: field.column(int4Column).id(),
|
|
51
|
-
|
|
52
|
-
category: field.column(textColumn),
|
|
53
|
-
rating: field.column(int4Column),
|
|
54
|
-
metadata: field.column(jsonbColumn),
|
|
50
|
+
body: field.column(textColumn),
|
|
55
51
|
},
|
|
56
|
-
}).sql({
|
|
52
|
+
}).sql(({ cols, constraints }) => ({
|
|
57
53
|
table: 'items',
|
|
58
54
|
indexes: [
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
bm25.text('category'),
|
|
64
|
-
bm25.numeric('rating'),
|
|
65
|
-
bm25.json('metadata', { tokenizer: 'ngram', min: 2, max: 3 }),
|
|
66
|
-
],
|
|
67
|
-
name: 'search_idx',
|
|
55
|
+
constraints.index([cols.body], {
|
|
56
|
+
name: 'item_body_bm25_idx',
|
|
57
|
+
type: 'bm25',
|
|
58
|
+
options: { key_field: 'id' },
|
|
68
59
|
}),
|
|
69
60
|
],
|
|
70
|
-
}),
|
|
61
|
+
})),
|
|
71
62
|
},
|
|
72
63
|
});
|
|
73
64
|
```
|
|
74
65
|
|
|
75
|
-
###
|
|
66
|
+
### key_field
|
|
76
67
|
|
|
77
|
-
|
|
68
|
+
ParadeDB BM25 indexes require a `key_field` — a unique column that identifies each document. It is required, must be a string, and is typically (but not always) the table's primary key.
|
|
78
69
|
|
|
79
|
-
|
|
80
|
-
|---------|-------------|-------------------|
|
|
81
|
-
| `bm25.text(column, opts?)` | Text field (`text`, `varchar`) | Yes — any tokenizer + stemmer, remove_emojis |
|
|
82
|
-
| `bm25.numeric(column)` | Numeric field (filterable, sortable) | No |
|
|
83
|
-
| `bm25.boolean(column)` | Boolean field | No |
|
|
84
|
-
| `bm25.json(column, opts?)` | JSON/JSONB field | Yes — tokenizer + ngram params |
|
|
85
|
-
| `bm25.datetime(column)` | Timestamp/date field | No |
|
|
86
|
-
| `bm25.range(column)` | Range field | No |
|
|
87
|
-
| `bm25.expression(sql, opts)` | Raw SQL expression | Yes — `alias` required |
|
|
88
|
-
|
|
89
|
-
### Expression-Based Fields
|
|
90
|
-
|
|
91
|
-
For computed or JSON sub-field indexing, use `bm25.expression()` with a raw SQL string:
|
|
92
|
-
|
|
93
|
-
```typescript
|
|
94
|
-
.index(
|
|
95
|
-
bm25Index({
|
|
96
|
-
keyField: 'id',
|
|
97
|
-
fields: [
|
|
98
|
-
bm25.text('description'),
|
|
99
|
-
bm25.expression("description || ' ' || category", {
|
|
100
|
-
alias: 'concat',
|
|
101
|
-
tokenizer: 'simple',
|
|
102
|
-
}),
|
|
103
|
-
bm25.expression("(metadata->>'color')", {
|
|
104
|
-
alias: 'meta_color',
|
|
105
|
-
tokenizer: 'ngram',
|
|
106
|
-
min: 2,
|
|
107
|
-
max: 3,
|
|
108
|
-
}),
|
|
109
|
-
],
|
|
110
|
-
}),
|
|
111
|
-
)
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### keyField Behavior
|
|
115
|
-
|
|
116
|
-
ParadeDB BM25 indexes require a `key_field` — a unique column that identifies each document:
|
|
117
|
-
|
|
118
|
-
- **Required**: Set `keyField` explicitly in `bm25Index(...)`.
|
|
119
|
-
- **Recommended**: Use the table primary key in most cases.
|
|
120
|
-
- **Override**: You can choose another unique column when needed.
|
|
70
|
+
## Capabilities
|
|
121
71
|
|
|
122
|
-
|
|
123
|
-
.index(bm25Index({ keyField: 'id', fields: [bm25.text('body')] }))
|
|
124
|
-
.index(bm25Index({ keyField: 'uuid', fields: [bm25.text('body')] }))
|
|
125
|
-
```
|
|
72
|
+
- `paradedb/bm25` — indicates support for BM25 full-text search indexes
|
|
126
73
|
|
|
127
|
-
##
|
|
128
|
-
|
|
129
|
-
All 12 built-in ParadeDB tokenizers are available via the `TokenizerId` type:
|
|
130
|
-
|
|
131
|
-
| Tokenizer | Description |
|
|
132
|
-
|-----------|-------------|
|
|
133
|
-
| `unicode_words` | Default. Unicode word boundaries (UAX #29). Lowercases. |
|
|
134
|
-
| `simple` | Splits on non-alphanumeric. Lowercases. |
|
|
135
|
-
| `ngram` | Character n-grams of configurable length. |
|
|
136
|
-
| `icu` | ICU Unicode standard segmentation. Multilingual. |
|
|
137
|
-
| `regex_pattern` | Regex-based tokenization. |
|
|
138
|
-
| `source_code` | camelCase / snake_case splitting. |
|
|
139
|
-
| `literal` | No splitting. Exact match, sort, aggregation. |
|
|
140
|
-
| `literal_normalized` | Literal + lowercase + token filters. |
|
|
141
|
-
| `whitespace` | Whitespace splitting + lowercase. |
|
|
142
|
-
| `chinese_compatible` | CJK-aware word segmentation. |
|
|
143
|
-
| `jieba` | Chinese segmentation via Jieba. |
|
|
144
|
-
| `lindera` | Japanese/Korean/Chinese via Lindera. |
|
|
74
|
+
## Authoring (maintainers)
|
|
145
75
|
|
|
146
|
-
|
|
76
|
+
The extension's contract + baseline migration are emitted on-disk inside this package using the same pipeline application authors use:
|
|
147
77
|
|
|
148
|
-
|
|
78
|
+
- `pnpm build:contract-space` — runs `prisma-next contract emit` to produce `src/contract.{json,d.ts}` from the PSL source at `src/contract.prisma`.
|
|
79
|
+
- `pnpm exec prisma-next migration plan --name <slug>` (run from this package directory) — scaffolds a new migration directory under `migrations/<dirName>/` for schema changes. **Not chained into `pnpm build`**: `migration plan` is non-idempotent (each invocation generates a new timestamped directory), so it runs manually when the contract source changes. Note: paradedb's contract declares no tables or models, so the planner currently refuses to scaffold the baseline migration (this is **Path B** authoring per [ADR 212](../../../docs/architecture%20docs/adrs/ADR%20212%20-%20Contract%20spaces.md#contract-space-package-layout)). That directory was hand-authored once (Migration subclass + seed `migration.json` preserving the full `toContract`) and `pnpm tsx migrations/<dirName>/migration.ts` re-emits `ops.json` + `migration.json` deterministically. Future migrations that add tables or models can use `migration plan` directly (Path A).
|
|
80
|
+
- `pnpm tsx migrations/<dirName>/migration.ts` (run from this package directory) — re-emits `ops.json` + `migration.json` from the hand-edited subclass. Use `tsx`, not bare `node`, because the Migration subclass imports relative TypeScript siblings which Node's native loader can't resolve without a TS-aware loader.
|
|
81
|
+
- `migrations/refs/head.json` is hand-pinned with the latest migration's `to` hash + `providedInvariants`.
|
|
149
82
|
|
|
150
|
-
|
|
83
|
+
The descriptor at `src/exports/control.ts` then JSON-imports those artefacts and synthesises the framework's `MigrationPackage` shape.
|
|
151
84
|
|
|
152
|
-
|
|
85
|
+
See [ADR 212 — Contract spaces](../../../docs/architecture%20docs/adrs/ADR%20212%20-%20Contract%20spaces.md) ("Contract-space package layout") for the canonical layout and rationale.
|
|
153
86
|
|
|
154
|
-
|
|
87
|
+
## Not yet implemented
|
|
155
88
|
|
|
156
|
-
-
|
|
157
|
-
-
|
|
158
|
-
-
|
|
159
|
-
- **Runtime**: Scoring, aggregation, and highlight functions
|
|
160
|
-
- **Database dependencies**: `CREATE EXTENSION pg_search` via migration planner
|
|
89
|
+
- Per-column / per-expression tokenizer configuration (deferred to expression-index support)
|
|
90
|
+
- `@@@` operator and `pdb.*` query builder functions
|
|
91
|
+
- Scoring, aggregation, and highlight functions
|
|
161
92
|
|
|
162
93
|
## References
|
|
163
94
|
|
|
164
95
|
- [ParadeDB documentation](https://docs.paradedb.com/)
|
|
165
96
|
- [ParadeDB CREATE INDEX](https://docs.paradedb.com/documentation/indexing/create-index)
|
|
166
|
-
- [
|
|
167
|
-
- [
|
|
97
|
+
- [ADR 210 — Index-type registry](../../../docs/architecture%20docs/adrs/ADR%20210%20-%20Index-type%20registry.md)
|
|
98
|
+
- [ADR 212 — Contract spaces](../../../docs/architecture%20docs/adrs/ADR%20212%20-%20Contract%20spaces.md)
|
|
168
99
|
- [Prisma Next Architecture Overview](../../../docs/Architecture%20Overview.md)
|
package/dist/control.d.mts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import * as _$_prisma_next_sql_contract_index_types0 from "@prisma-next/sql-contract/index-types";
|
|
2
|
+
import { SqlControlExtensionDescriptor } from "@prisma-next/family-sql/control";
|
|
3
|
+
|
|
1
4
|
//#region src/core/descriptor-meta.d.ts
|
|
2
5
|
declare const paradedbPackMeta: {
|
|
3
6
|
readonly kind: "extension";
|
|
@@ -10,7 +13,24 @@ declare const paradedbPackMeta: {
|
|
|
10
13
|
readonly 'paradedb/bm25': true;
|
|
11
14
|
};
|
|
12
15
|
};
|
|
16
|
+
readonly indexTypes: _$_prisma_next_sql_contract_index_types0.IndexTypeBuilder<Record<never, never> & Record<"bm25", {
|
|
17
|
+
readonly options: {
|
|
18
|
+
key_field: string;
|
|
19
|
+
};
|
|
20
|
+
}>>;
|
|
21
|
+
readonly types: {
|
|
22
|
+
readonly queryOperationTypes: {
|
|
23
|
+
readonly import: {
|
|
24
|
+
readonly package: "@prisma-next/extension-paradedb/operation-types";
|
|
25
|
+
readonly named: "QueryOperationTypes";
|
|
26
|
+
readonly alias: "ParadeDbQueryOperationTypes";
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
13
30
|
};
|
|
14
31
|
//#endregion
|
|
15
|
-
|
|
32
|
+
//#region src/exports/control.d.ts
|
|
33
|
+
declare const paradedbExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'>;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { paradedbExtensionDescriptor as default, paradedbExtensionDescriptor, paradedbPackMeta };
|
|
16
36
|
//# sourceMappingURL=control.d.mts.map
|
package/dist/control.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/descriptor-meta.ts"
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/descriptor-meta.ts","../src/exports/control.ts"],"mappings":";;;;cAgMa,gBAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;cCtIP,2BAAA,EAA6B,6BAAA"}
|
package/dist/control.mjs
CHANGED
|
@@ -1,3 +1,133 @@
|
|
|
1
|
-
import { t as paradedbPackMeta } from "./descriptor-meta-
|
|
1
|
+
import { n as paradedbQueryOperations, r as PARADEDB_SPACE_ID, t as paradedbPackMeta } from "./descriptor-meta-Dr4mAlbx.mjs";
|
|
2
|
+
import { contractSpaceFromJson } from "@prisma-next/migration-tools/spaces";
|
|
3
|
+
//#endregion
|
|
4
|
+
//#region src/exports/control.ts
|
|
5
|
+
const paradedbContractSpace = contractSpaceFromJson({
|
|
6
|
+
contractJson: {
|
|
7
|
+
schemaVersion: "1",
|
|
8
|
+
targetFamily: "sql",
|
|
9
|
+
target: "postgres",
|
|
10
|
+
profileHash: "sha256:1a8dbe044289f30a1de958fe800cc5a8378b285d2e126a8c44b58864bac2c18e",
|
|
11
|
+
roots: {},
|
|
12
|
+
models: {},
|
|
13
|
+
storage: {
|
|
14
|
+
"storageHash": "sha256:7d13ea93bd4726b9962c00ced807a79149e3ff69e0a47d936c0e82f39a637393",
|
|
15
|
+
"tables": {}
|
|
16
|
+
},
|
|
17
|
+
capabilities: {
|
|
18
|
+
"postgres": {
|
|
19
|
+
"jsonAgg": true,
|
|
20
|
+
"lateral": true,
|
|
21
|
+
"limit": true,
|
|
22
|
+
"orderBy": true,
|
|
23
|
+
"returning": true
|
|
24
|
+
},
|
|
25
|
+
"sql": {
|
|
26
|
+
"defaultInInsert": true,
|
|
27
|
+
"enums": true,
|
|
28
|
+
"returning": true
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
extensionPacks: {},
|
|
32
|
+
meta: {},
|
|
33
|
+
_generated: {
|
|
34
|
+
"warning": "⚠️ GENERATED FILE - DO NOT EDIT",
|
|
35
|
+
"message": "This file is automatically generated by \"prisma-next contract emit\".",
|
|
36
|
+
"regenerate": "To regenerate, run: prisma-next contract emit"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
migrations: [{
|
|
40
|
+
dirName: "20260601T0000_install_pg_search_extension",
|
|
41
|
+
metadata: {
|
|
42
|
+
from: null,
|
|
43
|
+
to: "sha256:7d13ea93bd4726b9962c00ced807a79149e3ff69e0a47d936c0e82f39a637393",
|
|
44
|
+
labels: [],
|
|
45
|
+
providedInvariants: ["paradedb:install-pg-search-v1"],
|
|
46
|
+
createdAt: "2026-06-01T00:00:00.000Z",
|
|
47
|
+
fromContract: null,
|
|
48
|
+
toContract: {
|
|
49
|
+
"schemaVersion": "1",
|
|
50
|
+
"targetFamily": "sql",
|
|
51
|
+
"target": "postgres",
|
|
52
|
+
"profileHash": "sha256:1a8dbe044289f30a1de958fe800cc5a8378b285d2e126a8c44b58864bac2c18e",
|
|
53
|
+
"roots": {},
|
|
54
|
+
"models": {},
|
|
55
|
+
"storage": {
|
|
56
|
+
"storageHash": "sha256:7d13ea93bd4726b9962c00ced807a79149e3ff69e0a47d936c0e82f39a637393",
|
|
57
|
+
"tables": {}
|
|
58
|
+
},
|
|
59
|
+
"capabilities": {
|
|
60
|
+
"postgres": {
|
|
61
|
+
"jsonAgg": true,
|
|
62
|
+
"lateral": true,
|
|
63
|
+
"limit": true,
|
|
64
|
+
"orderBy": true,
|
|
65
|
+
"returning": true
|
|
66
|
+
},
|
|
67
|
+
"sql": {
|
|
68
|
+
"defaultInInsert": true,
|
|
69
|
+
"enums": true,
|
|
70
|
+
"returning": true
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"extensionPacks": {},
|
|
74
|
+
"meta": {},
|
|
75
|
+
"_generated": {
|
|
76
|
+
"warning": "⚠️ GENERATED FILE - DO NOT EDIT",
|
|
77
|
+
"message": "This file is automatically generated by \"prisma-next contract emit\".",
|
|
78
|
+
"regenerate": "To regenerate, run: prisma-next contract emit"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
hints: {
|
|
82
|
+
"used": [],
|
|
83
|
+
"applied": [],
|
|
84
|
+
"plannerVersion": "2.0.0"
|
|
85
|
+
},
|
|
86
|
+
migrationHash: "sha256:3eb230aa63c65ee27e664c067dbf6a23c59e03fd0ad34b3f09d74fe4053b3ab4"
|
|
87
|
+
},
|
|
88
|
+
ops: [{
|
|
89
|
+
"id": "paradedb.install-pg-search-extension",
|
|
90
|
+
"label": "Enable extension \"pg_search\"",
|
|
91
|
+
"operationClass": "additive",
|
|
92
|
+
"invariantId": "paradedb:install-pg-search-v1",
|
|
93
|
+
"target": {
|
|
94
|
+
"id": "postgres",
|
|
95
|
+
"details": {
|
|
96
|
+
"schema": "public",
|
|
97
|
+
"objectType": "dependency",
|
|
98
|
+
"name": "pg_search"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"precheck": [{
|
|
102
|
+
"description": "verify extension \"pg_search\" is not already enabled",
|
|
103
|
+
"sql": "SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'pg_search')"
|
|
104
|
+
}],
|
|
105
|
+
"execute": [{
|
|
106
|
+
"description": "create extension \"pg_search\"",
|
|
107
|
+
"sql": "CREATE EXTENSION IF NOT EXISTS pg_search"
|
|
108
|
+
}],
|
|
109
|
+
"postcheck": [{
|
|
110
|
+
"description": "confirm extension \"pg_search\" is enabled",
|
|
111
|
+
"sql": "SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'pg_search')"
|
|
112
|
+
}]
|
|
113
|
+
}]
|
|
114
|
+
}],
|
|
115
|
+
headRef: {
|
|
116
|
+
hash: "sha256:7d13ea93bd4726b9962c00ced807a79149e3ff69e0a47d936c0e82f39a637393",
|
|
117
|
+
invariants: ["paradedb:install-pg-search-v1"]
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
const paradedbExtensionDescriptor = {
|
|
121
|
+
...paradedbPackMeta,
|
|
122
|
+
id: PARADEDB_SPACE_ID,
|
|
123
|
+
contractSpace: paradedbContractSpace,
|
|
124
|
+
queryOperations: () => paradedbQueryOperations(),
|
|
125
|
+
create: () => ({
|
|
126
|
+
familyId: "sql",
|
|
127
|
+
targetId: "postgres"
|
|
128
|
+
})
|
|
129
|
+
};
|
|
130
|
+
//#endregion
|
|
131
|
+
export { paradedbExtensionDescriptor as default, paradedbExtensionDescriptor, paradedbPackMeta };
|
|
2
132
|
|
|
3
|
-
|
|
133
|
+
//# sourceMappingURL=control.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.mjs","names":["baselineMetadata","baselineOps"],"sources":["../migrations/20260601T0000_install_pg_search_extension/migration.json","../migrations/20260601T0000_install_pg_search_extension/ops.json","../migrations/refs/head.json","../src/contract.json","../src/exports/control.ts"],"sourcesContent":["","","","","/**\n * Control-plane descriptor for the paradedb extension.\n *\n * **Contract-space package layout.** The extension's contract\n * + migrations are emitted by the same pipeline application authors use:\n *\n * `prisma-next contract emit` → `<package>/src/contract.{json,d.ts}`\n * `prisma-next migration plan` → `<package>/migrations/<dir>/...`\n *\n * The descriptor wires those JSON artefacts via JSON-import declarations\n * so they flow through the consuming application's module resolver\n * without filesystem assumptions, and synthesises the canonical\n * {@link import('@prisma-next/framework-components/control').MigrationPackage}\n * shape for the framework's runner / verifier to consume. Readers in\n * `@prisma-next/migration-tools` add `dirPath` when loading from disk\n * (`OnDiskMigrationPackage`); descriptor-bundled packages do not need\n * it because the framework reads them directly from the descriptor.\n *\n * Wired surfaces:\n *\n * - `contractSpace.{contractJson,migrations,headRef}` — sourced from\n * the on-disk artefacts emitted by `build:contract-space`.\n * - `queryOperations` — BM25 full-text search operations registered\n * via `paradedbQueryOperations()`.\n *\n * @see docs/architecture docs/adrs/ADR 212 - Contract spaces.md\n * (contract-space package layout convention).\n */\n\nimport type { Contract } from '@prisma-next/contract/types';\nimport type { SqlControlExtensionDescriptor } from '@prisma-next/family-sql/control';\nimport { contractSpaceFromJson } from '@prisma-next/migration-tools/spaces';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport baselineMetadata from '../../migrations/20260601T0000_install_pg_search_extension/migration.json' with {\n type: 'json',\n};\nimport baselineOps from '../../migrations/20260601T0000_install_pg_search_extension/ops.json' with {\n type: 'json',\n};\nimport headRef from '../../migrations/refs/head.json' with { type: 'json' };\nimport contractJson from '../contract.json' with { type: 'json' };\nimport { PARADEDB_SPACE_ID } from '../core/constants';\nimport { paradedbPackMeta, paradedbQueryOperations } from '../core/descriptor-meta';\n\nconst BASELINE_DIR_NAME = '20260601T0000_install_pg_search_extension';\n\nconst paradedbContractSpace = contractSpaceFromJson<Contract<SqlStorage>>({\n contractJson,\n migrations: [\n {\n dirName: BASELINE_DIR_NAME,\n metadata: baselineMetadata,\n ops: baselineOps,\n },\n ],\n headRef,\n});\n\nconst paradedbExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {\n ...paradedbPackMeta,\n id: PARADEDB_SPACE_ID,\n contractSpace: paradedbContractSpace,\n queryOperations: () => paradedbQueryOperations(),\n create: () => ({\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n }),\n};\n\nexport { paradedbExtensionDescriptor, paradedbPackMeta };\nexport default paradedbExtensionDescriptor;\n"],"mappings":";;;;AI8CA,MAAM,wBAAwB,sBAA4C;CACxE,cAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;CACA,YAAY,CACV;EACE,SAAS;EACT,UAAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAAA;EACV,KAAKC;;;;;;;;;;;;;;;;;;;;;;;;;IAAAA;EACN,CACF;CACD,SAAA;;;EAAA;CACD,CAAC;AAEF,MAAM,8BAAyE;CAC7E,GAAG;CACH,IAAI;CACJ,eAAe;CACf,uBAAuB,yBAAyB;CAChD,eAAe;EACb,UAAU;EACV,UAAU;EACX;CACF"}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { t as paradedbIndexTypes } from "./index-types-BZqoAhWT.mjs";
|
|
2
|
+
import { LiteralExpr, OperationExpr } from "@prisma-next/sql-relational-core/ast";
|
|
3
|
+
import { buildOperation, toExpr } from "@prisma-next/sql-relational-core/expression";
|
|
4
|
+
//#region src/core/constants.ts
|
|
5
|
+
/**
|
|
6
|
+
* Extension ID for ParadeDB pg_search.
|
|
7
|
+
*/
|
|
8
|
+
const PARADEDB_EXTENSION_ID = "paradedb";
|
|
9
|
+
/**
|
|
10
|
+
* Static names and identifiers used across paradedb's contract space.
|
|
11
|
+
*
|
|
12
|
+
* Centralised here so the contract IR (`./contract`), the baseline
|
|
13
|
+
* migration ops (`./migrations`), the head ref, and the descriptor
|
|
14
|
+
* (`../exports/control`) all reference the same values without typos.
|
|
15
|
+
*
|
|
16
|
+
* The space identifier `'paradedb'` is what the framework writes to
|
|
17
|
+
* `migrations/` in the user's repo and what the marker table's
|
|
18
|
+
* `space` column carries for paradedb-owned rows.
|
|
19
|
+
*
|
|
20
|
+
* The `paradedb:*` invariantId namespace is locked here — once
|
|
21
|
+
* published, an invariantId is immutable so downstream consumers can
|
|
22
|
+
* reference it by literal string match.
|
|
23
|
+
*/
|
|
24
|
+
const PARADEDB_SPACE_ID = "paradedb";
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/core/proximity-chain.ts
|
|
27
|
+
const TEXT$1 = "pg/text@1";
|
|
28
|
+
var ParadeDbProximityChain = class ParadeDbProximityChain {
|
|
29
|
+
returnType = {
|
|
30
|
+
codecId: TEXT$1,
|
|
31
|
+
nullable: false
|
|
32
|
+
};
|
|
33
|
+
start;
|
|
34
|
+
steps;
|
|
35
|
+
constructor(start, steps = []) {
|
|
36
|
+
this.start = start;
|
|
37
|
+
this.steps = steps;
|
|
38
|
+
}
|
|
39
|
+
within(distance, term, options) {
|
|
40
|
+
if (!Number.isInteger(distance) || distance < 0) throw new Error(`paradeDbProximity.within: distance must be a non-negative integer; got ${String(distance)}`);
|
|
41
|
+
return new ParadeDbProximityChain(this.start, [...this.steps, {
|
|
42
|
+
distance,
|
|
43
|
+
term,
|
|
44
|
+
ordered: options?.ordered === true
|
|
45
|
+
}]);
|
|
46
|
+
}
|
|
47
|
+
buildAst() {
|
|
48
|
+
if (this.steps.length === 0) throw new Error("paradeDbProximity: chain must have at least one .within(distance, term) step");
|
|
49
|
+
const args = [toExpr(this.start, TEXT$1)];
|
|
50
|
+
let template = "({{self}}";
|
|
51
|
+
this.steps.forEach((step, i) => {
|
|
52
|
+
const op = step.ordered ? "##>" : "##";
|
|
53
|
+
args.push(LiteralExpr.of(step.distance));
|
|
54
|
+
args.push(toExpr(step.term, TEXT$1));
|
|
55
|
+
template += ` ${op} {{arg${2 * i}}} ${op} {{arg${2 * i + 1}}}`;
|
|
56
|
+
});
|
|
57
|
+
template += ")";
|
|
58
|
+
const [self, ...rest] = args;
|
|
59
|
+
if (!self) throw new Error("paradeDbProximity: invariant violation — empty args");
|
|
60
|
+
return new OperationExpr({
|
|
61
|
+
method: "paradeDbProximity",
|
|
62
|
+
self,
|
|
63
|
+
args: rest.length > 0 ? rest : void 0,
|
|
64
|
+
returns: this.returnType,
|
|
65
|
+
lowering: {
|
|
66
|
+
targetFamily: "sql",
|
|
67
|
+
strategy: "function",
|
|
68
|
+
template
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/core/descriptor-meta.ts
|
|
75
|
+
const TEXT = "pg/text@1";
|
|
76
|
+
const BOOL = "pg/bool@1";
|
|
77
|
+
const FLOAT4 = "pg/float4@1";
|
|
78
|
+
const INT4 = "pg/int4@1";
|
|
79
|
+
function paradedbQueryOperations() {
|
|
80
|
+
return {
|
|
81
|
+
paradeDbMatch: {
|
|
82
|
+
self: { codecId: TEXT },
|
|
83
|
+
impl: (self, query) => buildOperation({
|
|
84
|
+
method: "paradeDbMatch",
|
|
85
|
+
args: [toExpr(self, TEXT), toExpr(query, TEXT)],
|
|
86
|
+
returns: {
|
|
87
|
+
codecId: BOOL,
|
|
88
|
+
nullable: false
|
|
89
|
+
},
|
|
90
|
+
lowering: {
|
|
91
|
+
targetFamily: "sql",
|
|
92
|
+
strategy: "function",
|
|
93
|
+
template: "{{self}} @@@ {{arg0}}"
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
},
|
|
97
|
+
paradeDbMatchAny: {
|
|
98
|
+
self: { codecId: TEXT },
|
|
99
|
+
impl: (self, query) => buildOperation({
|
|
100
|
+
method: "paradeDbMatchAny",
|
|
101
|
+
args: [toExpr(self, TEXT), toExpr(query, TEXT)],
|
|
102
|
+
returns: {
|
|
103
|
+
codecId: BOOL,
|
|
104
|
+
nullable: false
|
|
105
|
+
},
|
|
106
|
+
lowering: {
|
|
107
|
+
targetFamily: "sql",
|
|
108
|
+
strategy: "function",
|
|
109
|
+
template: "{{self}} ||| {{arg0}}"
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
},
|
|
113
|
+
paradeDbMatchAll: {
|
|
114
|
+
self: { codecId: TEXT },
|
|
115
|
+
impl: (self, query) => buildOperation({
|
|
116
|
+
method: "paradeDbMatchAll",
|
|
117
|
+
args: [toExpr(self, TEXT), toExpr(query, TEXT)],
|
|
118
|
+
returns: {
|
|
119
|
+
codecId: BOOL,
|
|
120
|
+
nullable: false
|
|
121
|
+
},
|
|
122
|
+
lowering: {
|
|
123
|
+
targetFamily: "sql",
|
|
124
|
+
strategy: "function",
|
|
125
|
+
template: "{{self}} &&& {{arg0}}"
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
},
|
|
129
|
+
paradeDbTerm: {
|
|
130
|
+
self: { codecId: TEXT },
|
|
131
|
+
impl: (self, query) => buildOperation({
|
|
132
|
+
method: "paradeDbTerm",
|
|
133
|
+
args: [toExpr(self, TEXT), toExpr(query, TEXT)],
|
|
134
|
+
returns: {
|
|
135
|
+
codecId: BOOL,
|
|
136
|
+
nullable: false
|
|
137
|
+
},
|
|
138
|
+
lowering: {
|
|
139
|
+
targetFamily: "sql",
|
|
140
|
+
strategy: "function",
|
|
141
|
+
template: "{{self}} === {{arg0}}"
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
},
|
|
145
|
+
paradeDbPhrase: {
|
|
146
|
+
self: { codecId: TEXT },
|
|
147
|
+
impl: (self, query) => buildOperation({
|
|
148
|
+
method: "paradeDbPhrase",
|
|
149
|
+
args: [toExpr(self, TEXT), toExpr(query, TEXT)],
|
|
150
|
+
returns: {
|
|
151
|
+
codecId: BOOL,
|
|
152
|
+
nullable: false
|
|
153
|
+
},
|
|
154
|
+
lowering: {
|
|
155
|
+
targetFamily: "sql",
|
|
156
|
+
strategy: "function",
|
|
157
|
+
template: "{{self}} ### {{arg0}}"
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
},
|
|
161
|
+
paradeDbScore: {
|
|
162
|
+
self: { codecId: INT4 },
|
|
163
|
+
impl: (self) => buildOperation({
|
|
164
|
+
method: "paradeDbScore",
|
|
165
|
+
args: [toExpr(self, INT4)],
|
|
166
|
+
returns: {
|
|
167
|
+
codecId: FLOAT4,
|
|
168
|
+
nullable: false
|
|
169
|
+
},
|
|
170
|
+
lowering: {
|
|
171
|
+
targetFamily: "sql",
|
|
172
|
+
strategy: "function",
|
|
173
|
+
template: "pdb.score({{self}})"
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
},
|
|
177
|
+
paradeDbFuzzy: {
|
|
178
|
+
self: { codecId: TEXT },
|
|
179
|
+
impl: (self, distance) => {
|
|
180
|
+
if (!Number.isInteger(distance) || distance < 0 || distance > 2) throw new Error(`paradeDbFuzzy: distance must be an integer in [0, 2]; got ${String(distance)}`);
|
|
181
|
+
return buildOperation({
|
|
182
|
+
method: "paradeDbFuzzy",
|
|
183
|
+
args: [toExpr(self, TEXT), LiteralExpr.of(distance)],
|
|
184
|
+
returns: {
|
|
185
|
+
codecId: TEXT,
|
|
186
|
+
nullable: false
|
|
187
|
+
},
|
|
188
|
+
lowering: {
|
|
189
|
+
targetFamily: "sql",
|
|
190
|
+
strategy: "function",
|
|
191
|
+
template: "{{self}}::pdb.fuzzy({{arg0}})"
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
paradeDbBoost: {
|
|
197
|
+
self: { codecId: TEXT },
|
|
198
|
+
impl: (self, weight) => {
|
|
199
|
+
if (!Number.isInteger(weight) || weight < -2048 || weight > 2048) throw new Error(`paradeDbBoost: boost must be an integer in [-2048, 2048]; got ${String(weight)}`);
|
|
200
|
+
return buildOperation({
|
|
201
|
+
method: "paradeDbBoost",
|
|
202
|
+
args: [toExpr(self, TEXT), LiteralExpr.of(weight)],
|
|
203
|
+
returns: {
|
|
204
|
+
codecId: TEXT,
|
|
205
|
+
nullable: false
|
|
206
|
+
},
|
|
207
|
+
lowering: {
|
|
208
|
+
targetFamily: "sql",
|
|
209
|
+
strategy: "function",
|
|
210
|
+
template: "{{self}}::pdb.boost({{arg0}})"
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
paradeDbConst: {
|
|
216
|
+
self: { codecId: TEXT },
|
|
217
|
+
impl: (self, value) => {
|
|
218
|
+
if (!Number.isInteger(value)) throw new Error(`paradeDbConst: value must be an integer; got ${String(value)}`);
|
|
219
|
+
return buildOperation({
|
|
220
|
+
method: "paradeDbConst",
|
|
221
|
+
args: [toExpr(self, TEXT), LiteralExpr.of(value)],
|
|
222
|
+
returns: {
|
|
223
|
+
codecId: TEXT,
|
|
224
|
+
nullable: false
|
|
225
|
+
},
|
|
226
|
+
lowering: {
|
|
227
|
+
targetFamily: "sql",
|
|
228
|
+
strategy: "function",
|
|
229
|
+
template: "{{self}}::pdb.const({{arg0}})"
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
paradeDbSlop: {
|
|
235
|
+
self: { codecId: TEXT },
|
|
236
|
+
impl: (self, slop) => {
|
|
237
|
+
if (!Number.isInteger(slop) || slop < 0) throw new Error(`paradeDbSlop: slop must be a non-negative integer; got ${String(slop)}`);
|
|
238
|
+
return buildOperation({
|
|
239
|
+
method: "paradeDbSlop",
|
|
240
|
+
args: [toExpr(self, TEXT), LiteralExpr.of(slop)],
|
|
241
|
+
returns: {
|
|
242
|
+
codecId: TEXT,
|
|
243
|
+
nullable: false
|
|
244
|
+
},
|
|
245
|
+
lowering: {
|
|
246
|
+
targetFamily: "sql",
|
|
247
|
+
strategy: "function",
|
|
248
|
+
template: "{{self}}::pdb.slop({{arg0}})"
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
paradeDbProximity: {
|
|
254
|
+
self: { codecId: TEXT },
|
|
255
|
+
impl: (start) => new ParadeDbProximityChain(start)
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
const paradedbPackMeta = {
|
|
260
|
+
kind: "extension",
|
|
261
|
+
id: PARADEDB_EXTENSION_ID,
|
|
262
|
+
familyId: "sql",
|
|
263
|
+
targetId: "postgres",
|
|
264
|
+
version: "0.0.1",
|
|
265
|
+
capabilities: { postgres: { "paradedb/bm25": true } },
|
|
266
|
+
indexTypes: paradedbIndexTypes,
|
|
267
|
+
types: { queryOperationTypes: { import: {
|
|
268
|
+
package: "@prisma-next/extension-paradedb/operation-types",
|
|
269
|
+
named: "QueryOperationTypes",
|
|
270
|
+
alias: "ParadeDbQueryOperationTypes"
|
|
271
|
+
} } }
|
|
272
|
+
};
|
|
273
|
+
//#endregion
|
|
274
|
+
export { paradedbQueryOperations as n, PARADEDB_SPACE_ID as r, paradedbPackMeta as t };
|
|
275
|
+
|
|
276
|
+
//# sourceMappingURL=descriptor-meta-Dr4mAlbx.mjs.map
|