-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocuments.ts
More file actions
57 lines (51 loc) · 1.64 KB
/
Copy pathdocuments.ts
File metadata and controls
57 lines (51 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* documents.ts — Git-backed Headless CMS document schema (blueprint definition)
*
* Tables: documents
* Data* nodes: SearchUnified (embedding + BM25 + chunks)
*
* Documents represent version-controlled files ingested from
* Git repositories (e.g. biz-docs). They carry structured metadata,
* repo/path/commit tracking for sync, and full unified search with
* chunked embeddings for RAG.
*/
import {
type BlueprintDefinition,
provisionBlueprint,
} from '../blueprint';
const definition: BlueprintDefinition = {
tables: [
// -- Documents ------------------------------------------------------------
{
ref: 'documents',
table_name: 'documents',
nodes: [
'DataId',
'DataTimestamps',
{ $type: 'SearchUnified', data: {
embedding: { source_fields: ['title', 'content'], chunks: {} },
bm25: { field_name: 'embedding_text' },
}},
],
fields: [
{ name: 'title', type: 'text' },
{ name: 'content', type: 'text', is_required: true },
{ name: 'metadata', type: 'jsonb' },
{ name: 'repo_name', type: 'text' },
{ name: 'file_path', type: 'text' },
{ name: 'commit_hash', type: 'text' },
{ name: 'tags', type: 'citext[]' },
],
},
],
relations: [],
indexes: [
{ table_ref: 'documents', column: 'tags', access_method: 'gin' },
{ table_ref: 'documents', column: 'repo_name', access_method: 'btree' },
{ table_ref: 'documents', column: 'file_path', access_method: 'btree' },
],
};
async function main() {
await provisionBlueprint(definition, 'Documents Schema');
}
export { main as default };