@absolutejs/rag-postgres 0.0.5 → 0.0.6

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.
@@ -0,0 +1,3 @@
1
+ import type { RAGVectorStore } from "@absolutejs/rag/adapter-kit";
2
+ import type { PostgresRAGStoreOptions } from "./types";
3
+ export declare const createPostgresRAGStore: (options?: PostgresRAGStoreOptions) => RAGVectorStore;
package/dist/index.d.ts CHANGED
@@ -1,122 +1,25 @@
1
- import type { RAGBackendCapabilities, RAGCollection, RAGVectorStore, RAGVectorStoreStatus } from '@absolutejs/rag';
1
+ import type { RAGBackendCapabilities, RAGCollection, RAGVectorStore, RAGVectorStoreStatus } from '@absolutejs/rag/adapter-kit';
2
+ import { createRAGCollection, ragPlugin } from '@absolutejs/rag/adapter-kit';
3
+ import { createPostgresRAGStore } from './createPostgresRAGStore';
4
+ import type { PostgresRAGStoreOptions } from './types';
2
5
  export declare const ABSOLUTE_POSTGRESQL_RAG_PACKAGE_NAME = "@absolutejs/rag-postgres";
3
- export declare const POSTGRESQL_RAG_IMPLEMENTATIONS: readonly ["pgvector"];
4
- export declare const PGVECTOR_DISTANCE_METRICS: readonly ["cosine", "l2", "inner_product"];
5
- export declare const PGVECTOR_INDEX_TYPES: readonly ["none", "hnsw", "ivfflat"];
6
- export type PostgreSQLRAGVectorImplementation = 'pgvector';
7
- export type PgvectorDistanceMetric = 'cosine' | 'l2' | 'inner_product';
8
- export type PgvectorIndexType = 'none' | 'hnsw' | 'ivfflat';
9
- export type PostgreSQLRAGClient = {
10
- query: <TRow = Record<string, unknown>>(sql: string, params?: unknown[]) => Promise<{
11
- rows: TRow[];
12
- rowCount?: number;
13
- }>;
14
- transaction?: <T>(run: (client: PostgreSQLRAGClient) => Promise<T>) => Promise<T>;
15
- close?: () => Promise<void>;
6
+ export type PostgresRAGCollectionOptions = {
7
+ store?: RAGVectorStore;
8
+ storeOptions?: PostgresRAGStoreOptions;
16
9
  };
17
- export type PostgreSQLRAGClientFactory = () => Promise<PostgreSQLRAGClient> | PostgreSQLRAGClient;
18
- export type PostgreSQLRAGSchemaConfig = {
19
- schemaName?: string;
20
- chunkTableName?: string;
21
- migrationTableName?: string;
10
+ export type PostgresRAGOptions = {
11
+ store?: RAGVectorStore;
12
+ collection?: RAGCollection;
13
+ storeOptions?: PostgresRAGStoreOptions;
22
14
  };
23
- export type PgvectorHNSWConfig = {
24
- type: 'hnsw';
25
- m?: number;
26
- efConstruction?: number;
27
- efSearch?: number;
28
- iterativeScan?: 'off' | 'strict_order' | 'relaxed_order';
29
- };
30
- export type PgvectorIVFFlatConfig = {
31
- type: 'ivfflat';
32
- lists?: number;
33
- probes?: number;
34
- maxProbes?: number;
35
- iterativeScan?: 'off' | 'strict_order' | 'relaxed_order';
36
- };
37
- export type PgvectorNoIndexConfig = {
38
- type: 'none';
39
- };
40
- export type PgvectorIndexConfig = PgvectorNoIndexConfig | PgvectorHNSWConfig | PgvectorIVFFlatConfig;
41
- export type PgvectorConfig = {
42
- provider: 'pgvector';
43
- dimensions: number;
44
- distanceMetric?: PgvectorDistanceMetric;
45
- extensionName?: 'vector' | string;
46
- autoCreateExtension?: boolean;
47
- autoCreateSchema?: boolean;
48
- autoCreateTables?: boolean;
49
- autoCreateIndex?: boolean;
50
- index?: PgvectorIndexConfig;
51
- };
52
- export type PostgreSQLDriverOptions = {
53
- max?: number;
54
- prepare?: boolean;
55
- idle_timeout?: number;
56
- connect_timeout?: number;
57
- max_lifetime?: number;
58
- ssl?: boolean | 'require' | 'allow' | 'prefer' | 'verify-full';
59
- };
60
- export type PostgreSQLRAGOptions = {
61
- connectionString?: string;
62
- client?: PostgreSQLRAGClient;
63
- clientFactory?: PostgreSQLRAGClientFactory;
64
- driver?: PostgreSQLDriverOptions;
65
- schema?: PostgreSQLRAGSchemaConfig;
66
- vector: PgvectorConfig;
67
- embedding?: RAGVectorStore['embed'];
68
- };
69
- export type PostgreSQLSchemaPlan = {
70
- implementation: PostgreSQLRAGVectorImplementation;
71
- extensionSql: string[];
72
- schemaSql: string[];
73
- tableSql: string[];
74
- indexSql: string[];
75
- querySessionSql: string[];
76
- migrationTableQualifiedName: string;
77
- };
78
- export type PostgreSQLMigrationStage = 'extension' | 'table' | 'index';
79
- export type PostgreSQLMigrationEntry = {
80
- name: string;
81
- stage: PostgreSQLMigrationStage;
82
- sql: string;
83
- };
84
- export type PostgreSQLMigrationPlan = {
85
- implementation: PostgreSQLRAGVectorImplementation;
86
- schemaName: string;
87
- migrationTableName: string;
88
- migrationTableQualifiedName: string;
89
- bootstrapSql: string[];
90
- migrations: PostgreSQLMigrationEntry[];
91
- schemaPlan: PostgreSQLSchemaPlan;
92
- };
93
- export type PostgreSQLApplyMigrationsOptions = {
94
- client?: PostgreSQLRAGClient;
95
- dryRun?: boolean;
96
- };
97
- export type PostgreSQLApplyMigrationsResult = {
98
- migrationPlan: PostgreSQLMigrationPlan;
99
- appliedNames: string[];
100
- skippedNames: string[];
101
- pendingNames: string[];
102
- appliedCount: number;
103
- pendingCount: number;
104
- dryRun: boolean;
105
- };
106
- export type PostgreSQLRAG = {
15
+ export type PostgresRAG = {
107
16
  store: RAGVectorStore;
108
17
  collection: RAGCollection;
109
18
  getStatus: () => RAGVectorStoreStatus | undefined;
110
19
  getCapabilities: () => RAGBackendCapabilities | undefined;
111
- getSchemaPlan: () => PostgreSQLSchemaPlan;
112
- getMigrationPlan: () => PostgreSQLMigrationPlan;
113
- applyMigrations: (options?: PostgreSQLApplyMigrationsOptions) => Promise<PostgreSQLApplyMigrationsResult>;
114
20
  };
115
- export declare const createPostgresSchemaPlan: (options: PostgreSQLRAGOptions) => PostgreSQLSchemaPlan;
116
- export declare const createPostgresMigrationPlan: (options: PostgreSQLRAGOptions) => PostgreSQLMigrationPlan;
117
- export declare const applyPostgresMigrations: (options: PostgreSQLRAGOptions, applyOptions?: PostgreSQLApplyMigrationsOptions) => Promise<PostgreSQLApplyMigrationsResult>;
118
- export declare const applyPostgresSchemaPlan: typeof applyPostgresMigrations;
119
- export declare const createPgvectorStore: (options: PostgreSQLRAGOptions) => RAGVectorStore;
120
- export declare const createPostgresRAGCollection: (options: PostgreSQLRAGOptions) => RAGCollection;
121
- export declare const createPostgresRAG: (options: PostgreSQLRAGOptions) => PostgreSQLRAG;
21
+ export declare const createPostgresRAGCollection: (options?: PostgresRAGCollectionOptions) => RAGCollection;
22
+ export declare const createPostgresRAG: (options?: PostgresRAGOptions) => PostgresRAG;
122
23
  export declare const createPostgreSQLRAG: typeof createPostgresRAG;
24
+ export { createPostgresRAGStore, createRAGCollection, ragPlugin };
25
+ export type { PostgresRAGStoreOptions, RAGBackendCapabilities, RAGCollection, RAGVectorStore, RAGVectorStoreStatus };