@omniojs/idx-postgresql.node 0.0.0-stage → 0.0.5

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026-present, omnio-project
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,21 @@
1
- # Temporary Holding Version
1
+ # @omniojs/idx-postgresql.node
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ PostgreSQL による Omnio.js 用の `IObjectIndex` 実装です。
4
+
5
+ ベクトル検索には pgvector を使います。接続先のデータベースで pgvector 拡張を利用できるようにしてください。マイグレーション時に `CREATE EXTENSION IF NOT EXISTS vector` を実行します。
6
+
7
+ [Document](https://omnio-project.github.io/omnio-js/)
8
+
9
+ ## テスト
10
+
11
+ ローカルで `mise run test` を実行すると、Docker Compose で pgvector 入りの PostgreSQL 17 を起動し、テスト終了後に停止します。Docker が必要です。
12
+
13
+ PostgreSQL を起動したままテストを繰り返す場合は、次のコマンドを使います。
14
+
15
+ ```sh
16
+ mise run db:start
17
+ mise run test:server
18
+ mise run db:stop
19
+ ```
20
+
21
+ `DATABASE_URL` を指定した場合は、そのサーバーを使ってローカルのコンテナを起動しません。
@@ -0,0 +1,44 @@
1
+ import { Migration, Migration as Migration$1, MigrationProvider, Migrator } from "kysely/migration";
2
+ import { PgVectorObjectIndex, SqlIndexBackend, SqlIndexDatabase as PostgresqlDatabase, SqlMigrationProvider, SqlObjectRow as ObjectRow, SqlObjectTagRow as ObjectTagRow, cosineSimilarity, decodeEmbedding, encodeEmbedding, l2Distance, scoreVector } from "@omniojs/idx-sql";
3
+ //#region ../src/migrations.d.ts
4
+ /**
5
+ * 適用するマイグレーションの一覧です。キー名の辞書順で実行します。
6
+ */
7
+ export declare const MIGRATIONS: Record<string, Migration$1>;
8
+ /**
9
+ * PostgreSQL 用のマイグレーション提供器です。
10
+ */
11
+ export declare class PostgresqlMigrationProvider extends SqlMigrationProvider {
12
+ /**
13
+ * マイグレーションの一覧を設定します。
14
+ */
15
+ constructor();
16
+ }
17
+ //#endregion
18
+ //#region ../src/postgresql-index.d.ts
19
+ /**
20
+ * `PostgresqlIndex` のオプションです。
21
+ */
22
+ type PostgresqlIndexOptions = {
23
+ /** PostgreSQL への接続文字列です。 */
24
+ readonly connectionString: string;
25
+ /** コネクションプールの最大接続数です。既定値は 10 です。 */
26
+ readonly maxConnections?: number | undefined;
27
+ };
28
+ /**
29
+ * PostgreSQL による `IObjectIndex` の実装です。
30
+ */
31
+ export declare class PostgresqlIndex extends PgVectorObjectIndex {
32
+ #private;
33
+ protected override readonly fullTextOperator: "ILIKE";
34
+ /**
35
+ * @param options 接続文字列などの設定です。
36
+ */
37
+ constructor(options: PostgresqlIndexOptions);
38
+ protected override createBackend(): Promise<SqlIndexBackend>;
39
+ protected override createMigrationProvider(): MigrationProvider;
40
+ protected override toStoredSize(size: number): string;
41
+ }
42
+ //#endregion
43
+ export { type Migration, Migrator, type ObjectRow, type ObjectTagRow, type PostgresqlDatabase, type PostgresqlIndexOptions, cosineSimilarity, decodeEmbedding, encodeEmbedding, l2Distance, scoreVector };
44
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":["Migration"],"sources":["../src/migrations.ts","../src/postgresql-index.ts"],"mappings":";;;;;;qBAMa,YAAY,eAAeA;;;;qBAQ3B,oCAAoC;;;;EAI/C;;;;;;;KCLU;;WAED;;WAGA;;;;;qBA6BE,wBAAwB;;8BACP;;;;EAS5B,YAAmB,SAAS;qBAQT,iBAAiB,QAAQ;qBAyBzB,2BAA2B;qBAI3B,aAAa"}
package/dist/index.js ADDED
@@ -0,0 +1,115 @@
1
+ import { Migrator } from "kysely/migration";
2
+ import { PgVectorObjectIndex, SqlMigrationProvider, cosineSimilarity, createSqlMigrations, decodeEmbedding, encodeEmbedding, l2Distance, scoreVector } from "@omniojs/idx-sql";
3
+ import { Kysely, PostgresDialect } from "kysely";
4
+ import { Pool } from "pg";
5
+ import * as v from "valibot";
6
+ //#region ../src/migrations.ts
7
+ /**
8
+ * 適用するマイグレーションの一覧です。キー名の辞書順で実行します。
9
+ */
10
+ const MIGRATIONS = createSqlMigrations({
11
+ sizeColumnType: "bigint",
12
+ embeddingColumnType: "vector"
13
+ });
14
+ /**
15
+ * PostgreSQL 用のマイグレーション提供器です。
16
+ */
17
+ var PostgresqlMigrationProvider = class extends SqlMigrationProvider {
18
+ /**
19
+ * マイグレーションの一覧を設定します。
20
+ */
21
+ constructor() {
22
+ super(MIGRATIONS);
23
+ }
24
+ };
25
+ //#endregion
26
+ //#region \0@oxc-project+runtime@0.154.0/helpers/esm/checkPrivateRedeclaration.js
27
+ function _checkPrivateRedeclaration(e, t) {
28
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
29
+ }
30
+ //#endregion
31
+ //#region \0@oxc-project+runtime@0.154.0/helpers/esm/classPrivateFieldInitSpec.js
32
+ function _classPrivateFieldInitSpec(e, t, a) {
33
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
34
+ }
35
+ //#endregion
36
+ //#region \0@oxc-project+runtime@0.154.0/helpers/esm/assertClassBrand.js
37
+ function _assertClassBrand(e, t, n) {
38
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
39
+ throw new TypeError("Private element is not present on this object");
40
+ }
41
+ //#endregion
42
+ //#region \0@oxc-project+runtime@0.154.0/helpers/esm/classPrivateFieldSet2.js
43
+ function _classPrivateFieldSet2(s, a, r) {
44
+ return s.set(_assertClassBrand(s, a), r), r;
45
+ }
46
+ //#endregion
47
+ //#region \0@oxc-project+runtime@0.154.0/helpers/esm/classPrivateFieldGet2.js
48
+ function _classPrivateFieldGet2(s, a) {
49
+ return s.get(_assertClassBrand(s, a));
50
+ }
51
+ //#endregion
52
+ //#region ../src/postgresql-index.ts
53
+ /**
54
+ * `PostgresqlIndex` のコンストラクター引数を検証するスキーマです。
55
+ */
56
+ const PostgresqlIndexOptionsSchema = v.object({
57
+ maxConnections: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1))),
58
+ connectionString: v.pipe(v.string(), v.minLength(1))
59
+ });
60
+ /**
61
+ * 開いているコネクションプールを閉じます。
62
+ *
63
+ * Kysely の `destroy()` はドライバーの初期化に失敗していると接続を破棄しないため、後始末のフォールバックとして使います。
64
+ *
65
+ * @param pool 閉じるコネクションプールです。
66
+ */
67
+ async function closePool(pool) {
68
+ try {
69
+ await pool.end();
70
+ } catch {}
71
+ }
72
+ var _connectionString = /* @__PURE__ */ new WeakMap();
73
+ var _maxConnections = /* @__PURE__ */ new WeakMap();
74
+ /**
75
+ * PostgreSQL による `IObjectIndex` の実装です。
76
+ */
77
+ var PostgresqlIndex = class extends PgVectorObjectIndex {
78
+ /**
79
+ * @param options 接続文字列などの設定です。
80
+ */
81
+ constructor(options) {
82
+ super();
83
+ this.fullTextOperator = "ILIKE";
84
+ _classPrivateFieldInitSpec(this, _connectionString, void 0);
85
+ _classPrivateFieldInitSpec(this, _maxConnections, void 0);
86
+ const parsed = v.parse(PostgresqlIndexOptionsSchema, options);
87
+ _classPrivateFieldSet2(_connectionString, this, parsed.connectionString);
88
+ _classPrivateFieldSet2(_maxConnections, this, parsed.maxConnections);
89
+ }
90
+ createBackend() {
91
+ const pool = new Pool({
92
+ max: _classPrivateFieldGet2(_maxConnections, this),
93
+ connectionString: _classPrivateFieldGet2(_connectionString, this)
94
+ });
95
+ pool.on("error", () => {});
96
+ const kysely = new Kysely({ dialect: new PostgresDialect({ pool }) });
97
+ return Promise.resolve({
98
+ kysely,
99
+ dispose: async () => {
100
+ await kysely.destroy().catch(() => void 0);
101
+ await closePool(pool);
102
+ }
103
+ });
104
+ }
105
+ createMigrationProvider() {
106
+ return new PostgresqlMigrationProvider();
107
+ }
108
+ toStoredSize(size) {
109
+ return String(size);
110
+ }
111
+ };
112
+ //#endregion
113
+ export { MIGRATIONS, Migrator, PostgresqlIndex, PostgresqlMigrationProvider, cosineSimilarity, decodeEmbedding, encodeEmbedding, l2Distance, scoreVector };
114
+
115
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/migrations.ts","../src/postgresql-index.ts"],"sourcesContent":["import { createSqlMigrations, SqlMigrationProvider } from \"@omniojs/idx-sql\";\nimport type { Migration } from \"kysely/migration\";\n\n/**\n * 適用するマイグレーションの一覧です。キー名の辞書順で実行します。\n */\nexport const MIGRATIONS: Record<string, Migration> = createSqlMigrations({\n sizeColumnType: \"bigint\",\n embeddingColumnType: \"vector\",\n});\n\n/**\n * PostgreSQL 用のマイグレーション提供器です。\n */\nexport class PostgresqlMigrationProvider extends SqlMigrationProvider {\n /**\n * マイグレーションの一覧を設定します。\n */\n public constructor() {\n super(MIGRATIONS);\n }\n}\n","import type { SqlIndexBackend } from \"@omniojs/idx-sql\";\nimport { PgVectorObjectIndex } from \"@omniojs/idx-sql\";\nimport { Kysely, PostgresDialect } from \"kysely\";\nimport type { MigrationProvider } from \"kysely/migration\";\nimport { Pool } from \"pg\";\nimport * as v from \"valibot\";\n\nimport { PostgresqlMigrationProvider } from \"./migrations.js\";\nimport type { PostgresqlDatabase } from \"./schema.js\";\n\n/**\n * `PostgresqlIndex` のオプションです。\n */\nexport type PostgresqlIndexOptions = {\n /** PostgreSQL への接続文字列です。 */\n readonly connectionString: string;\n\n /** コネクションプールの最大接続数です。既定値は 10 です。 */\n readonly maxConnections?: number | undefined;\n};\n\n/**\n * `PostgresqlIndex` のコンストラクター引数を検証するスキーマです。\n */\nconst PostgresqlIndexOptionsSchema = v.object({\n maxConnections: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1))),\n connectionString: v.pipe(v.string(), v.minLength(1)),\n});\n\n/**\n * 開いているコネクションプールを閉じます。\n *\n * Kysely の `destroy()` はドライバーの初期化に失敗していると接続を破棄しないため、後始末のフォールバックとして使います。\n *\n * @param pool 閉じるコネクションプールです。\n */\nasync function closePool(pool: Pool): Promise<void> {\n try {\n await pool.end();\n } catch {\n // 元のエラーを優先するため、後始末の失敗は無視します。\n }\n}\n\n/**\n * PostgreSQL による `IObjectIndex` の実装です。\n */\nexport class PostgresqlIndex extends PgVectorObjectIndex {\n protected override readonly fullTextOperator = \"ILIKE\" as const;\n\n readonly #connectionString: string;\n\n readonly #maxConnections: number | undefined;\n\n /**\n * @param options 接続文字列などの設定です。\n */\n public constructor(options: PostgresqlIndexOptions) {\n super();\n\n const parsed = v.parse(PostgresqlIndexOptionsSchema, options);\n this.#connectionString = parsed.connectionString;\n this.#maxConnections = parsed.maxConnections;\n }\n\n protected override createBackend(): Promise<SqlIndexBackend> {\n const pool = new Pool({\n max: this.#maxConnections,\n connectionString: this.#connectionString,\n });\n\n // 待機中のクライアントで発生したエラーはクエリーの Promise に紐付かないため、リスナーがないと未処理の error イベントでプロセスが終了します。\n // クエリー実行中のエラーは引き続き Promise の reject として呼び出し元に伝わります。\n pool.on(\"error\", () => {\n // プールは影響を受けたクライアントを破棄するため、ここでは何もしません。\n });\n\n const kysely = new Kysely<PostgresqlDatabase>({\n dialect: new PostgresDialect({ pool }),\n });\n\n return Promise.resolve({\n kysely,\n dispose: async () => {\n await kysely.destroy().catch(() => undefined);\n await closePool(pool);\n },\n });\n }\n\n protected override createMigrationProvider(): MigrationProvider {\n return new PostgresqlMigrationProvider();\n }\n\n protected override toStoredSize(size: number): string {\n return String(size);\n }\n}\n"],"mappings":";;;;;;;;;AAMA,MAAa,aAAwC,oBAAoB;CACvE,gBAAgB;CAChB,qBAAqB;AACvB,CAAC;;;;AAKD,IAAa,8BAAb,cAAiD,qBAAqB;;;;CAIpE,cAAqB;EACnB,MAAM,UAAU;CAClB;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACGA,MAAM,+BAA+B,EAAE,OAAO;CAC5C,gBAAgB,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;CACzE,kBAAkB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,UAAU,CAAC,CAAC;AACrD,CAAC;;;;;;;;AASD,eAAe,UAAU,MAA2B;CAClD,IAAI;EACF,MAAM,KAAK,IAAI;CACjB,QAAQ,CAER;AACF;;;;;;AAKA,IAAa,kBAAb,cAAqC,oBAAoB;;;;CAUvD,YAAmB,SAAiC;EAClD,MAAM;EAVR,KAA4B,mBAAmB;;;EAY7C,MAAM,SAAS,EAAE,MAAM,8BAA8B,OAAO;EAC5D,uBAAA,mBAAA,MAAyB,OAAO,gBAAA;EAChC,uBAAA,iBAAA,MAAuB,OAAO,cAAA;CAChC;CAEA,gBAA6D;EAC3D,MAAM,OAAO,IAAI,KAAK;GACpB,KAAA,uBAAA,iBAAK,IAAA;GACL,kBAAA,uBAAA,mBAAkB,IAAA;EACpB,CAAC;EAID,KAAK,GAAG,eAAe,CAEvB,CAAC;EAED,MAAM,SAAS,IAAI,OAA2B,EAC5C,SAAS,IAAI,gBAAgB,EAAE,KAAK,CAAC,EACvC,CAAC;EAED,OAAO,QAAQ,QAAQ;GACrB;GACA,SAAS,YAAY;IACnB,MAAM,OAAO,QAAQ,CAAC,CAAC,YAAY,KAAA,CAAS;IAC5C,MAAM,UAAU,IAAI;GACtB;EACF,CAAC;CACH;CAEA,0BAAgE;EAC9D,OAAO,IAAI,4BAA4B;CACzC;CAEA,aAAgC,MAAsB;EACpD,OAAO,OAAO,IAAI;CACpB;AACF"}
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "@omniojs/idx-postgresql.node",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.5",
4
+ "description": "PostgreSQL による Omnio.js 用 ObjectIndex です。",
5
+ "homepage": "https://omnio-project.github.io/omnio-js/",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "url": "https://github.com/omnio-project/omnio-js",
9
+ "directory": "packages/idx-postgresql.node"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "src",
14
+ "package.json",
15
+ "LICENSE",
16
+ "README.md"
17
+ ],
18
+ "type": "module",
19
+ "sideEffects": false,
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/index.js"
24
+ }
25
+ },
26
+ "dependencies": {
27
+ "@omniojs/core": "0.0.5",
28
+ "@omniojs/idx-sql": "0.0.5",
29
+ "asyncmux": "^0.0.12",
30
+ "kysely": "^0.29.7",
31
+ "pg": "^8.23.1",
32
+ "valibot": "^1.0.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/pg": "^8.23.1",
36
+ "@vitest/coverage-v8": "5.0.5",
37
+ "vite-plus": "1.3.0"
38
+ },
39
+ "readme": "README.md",
40
+ "scripts": {
41
+ "build": "vp -C .config pack"
42
+ }
6
43
  }
package/src/index.ts ADDED
@@ -0,0 +1,16 @@
1
+ export type { Migration } from "kysely/migration";
2
+ export { Migrator } from "kysely/migration";
3
+ export { MIGRATIONS, PostgresqlMigrationProvider } from "./migrations.js";
4
+
5
+ export type { PostgresqlIndexOptions } from "./postgresql-index.js";
6
+ export { PostgresqlIndex } from "./postgresql-index.js";
7
+
8
+ export type { ObjectRow, ObjectTagRow, PostgresqlDatabase } from "./schema.js";
9
+
10
+ export {
11
+ l2Distance,
12
+ scoreVector,
13
+ decodeEmbedding,
14
+ encodeEmbedding,
15
+ cosineSimilarity,
16
+ } from "./vector.js";
@@ -0,0 +1,22 @@
1
+ import { createSqlMigrations, SqlMigrationProvider } from "@omniojs/idx-sql";
2
+ import type { Migration } from "kysely/migration";
3
+
4
+ /**
5
+ * 適用するマイグレーションの一覧です。キー名の辞書順で実行します。
6
+ */
7
+ export const MIGRATIONS: Record<string, Migration> = createSqlMigrations({
8
+ sizeColumnType: "bigint",
9
+ embeddingColumnType: "vector",
10
+ });
11
+
12
+ /**
13
+ * PostgreSQL 用のマイグレーション提供器です。
14
+ */
15
+ export class PostgresqlMigrationProvider extends SqlMigrationProvider {
16
+ /**
17
+ * マイグレーションの一覧を設定します。
18
+ */
19
+ public constructor() {
20
+ super(MIGRATIONS);
21
+ }
22
+ }
@@ -0,0 +1,98 @@
1
+ import type { SqlIndexBackend } from "@omniojs/idx-sql";
2
+ import { PgVectorObjectIndex } from "@omniojs/idx-sql";
3
+ import { Kysely, PostgresDialect } from "kysely";
4
+ import type { MigrationProvider } from "kysely/migration";
5
+ import { Pool } from "pg";
6
+ import * as v from "valibot";
7
+
8
+ import { PostgresqlMigrationProvider } from "./migrations.js";
9
+ import type { PostgresqlDatabase } from "./schema.js";
10
+
11
+ /**
12
+ * `PostgresqlIndex` のオプションです。
13
+ */
14
+ export type PostgresqlIndexOptions = {
15
+ /** PostgreSQL への接続文字列です。 */
16
+ readonly connectionString: string;
17
+
18
+ /** コネクションプールの最大接続数です。既定値は 10 です。 */
19
+ readonly maxConnections?: number | undefined;
20
+ };
21
+
22
+ /**
23
+ * `PostgresqlIndex` のコンストラクター引数を検証するスキーマです。
24
+ */
25
+ const PostgresqlIndexOptionsSchema = v.object({
26
+ maxConnections: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1))),
27
+ connectionString: v.pipe(v.string(), v.minLength(1)),
28
+ });
29
+
30
+ /**
31
+ * 開いているコネクションプールを閉じます。
32
+ *
33
+ * Kysely の `destroy()` はドライバーの初期化に失敗していると接続を破棄しないため、後始末のフォールバックとして使います。
34
+ *
35
+ * @param pool 閉じるコネクションプールです。
36
+ */
37
+ async function closePool(pool: Pool): Promise<void> {
38
+ try {
39
+ await pool.end();
40
+ } catch {
41
+ // 元のエラーを優先するため、後始末の失敗は無視します。
42
+ }
43
+ }
44
+
45
+ /**
46
+ * PostgreSQL による `IObjectIndex` の実装です。
47
+ */
48
+ export class PostgresqlIndex extends PgVectorObjectIndex {
49
+ protected override readonly fullTextOperator = "ILIKE" as const;
50
+
51
+ readonly #connectionString: string;
52
+
53
+ readonly #maxConnections: number | undefined;
54
+
55
+ /**
56
+ * @param options 接続文字列などの設定です。
57
+ */
58
+ public constructor(options: PostgresqlIndexOptions) {
59
+ super();
60
+
61
+ const parsed = v.parse(PostgresqlIndexOptionsSchema, options);
62
+ this.#connectionString = parsed.connectionString;
63
+ this.#maxConnections = parsed.maxConnections;
64
+ }
65
+
66
+ protected override createBackend(): Promise<SqlIndexBackend> {
67
+ const pool = new Pool({
68
+ max: this.#maxConnections,
69
+ connectionString: this.#connectionString,
70
+ });
71
+
72
+ // 待機中のクライアントで発生したエラーはクエリーの Promise に紐付かないため、リスナーがないと未処理の error イベントでプロセスが終了します。
73
+ // クエリー実行中のエラーは引き続き Promise の reject として呼び出し元に伝わります。
74
+ pool.on("error", () => {
75
+ // プールは影響を受けたクライアントを破棄するため、ここでは何もしません。
76
+ });
77
+
78
+ const kysely = new Kysely<PostgresqlDatabase>({
79
+ dialect: new PostgresDialect({ pool }),
80
+ });
81
+
82
+ return Promise.resolve({
83
+ kysely,
84
+ dispose: async () => {
85
+ await kysely.destroy().catch(() => undefined);
86
+ await closePool(pool);
87
+ },
88
+ });
89
+ }
90
+
91
+ protected override createMigrationProvider(): MigrationProvider {
92
+ return new PostgresqlMigrationProvider();
93
+ }
94
+
95
+ protected override toStoredSize(size: number): string {
96
+ return String(size);
97
+ }
98
+ }
package/src/schema.ts ADDED
@@ -0,0 +1,5 @@
1
+ export type {
2
+ SqlObjectRow as ObjectRow,
3
+ SqlObjectTagRow as ObjectTagRow,
4
+ SqlIndexDatabase as PostgresqlDatabase,
5
+ } from "@omniojs/idx-sql";
package/src/vector.ts ADDED
@@ -0,0 +1,8 @@
1
+ export {
2
+ l2Distance,
3
+ scoreVector,
4
+ decodeEmbedding,
5
+ encodeEmbedding,
6
+ cosineSimilarity,
7
+ decodeEmbeddingInto,
8
+ } from "@omniojs/idx-sql";