@prisma-next/extension-pgvector 0.3.0-dev.4 → 0.3.0-dev.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/dist/{exports/chunk-QZXQPESZ.js → chunk-SHWLERB3.js} +1 -1
- package/dist/chunk-SHWLERB3.js.map +1 -0
- package/dist/core/codecs.d.ts +23 -0
- package/dist/core/codecs.d.ts.map +1 -0
- package/dist/core/descriptor-meta.d.ts +53 -0
- package/dist/core/descriptor-meta.d.ts.map +1 -0
- package/dist/exports/codec-types.d.ts +4 -9
- package/dist/exports/codec-types.d.ts.map +1 -0
- package/dist/exports/column-types.d.ts +2 -3
- package/dist/exports/column-types.d.ts.map +1 -0
- package/dist/exports/control.d.ts +4 -4
- package/dist/exports/control.d.ts.map +1 -0
- package/dist/exports/control.js +1 -1
- package/dist/exports/operation-types.d.ts +3 -28
- package/dist/exports/operation-types.d.ts.map +1 -0
- package/dist/exports/pack.d.ts +2 -2
- package/dist/exports/pack.d.ts.map +1 -0
- package/dist/exports/pack.js +1 -1
- package/dist/exports/runtime.d.ts +3 -4
- package/dist/exports/runtime.d.ts.map +1 -0
- package/dist/exports/runtime.js +1 -1
- package/dist/types/codec-types.d.ts +10 -0
- package/dist/types/codec-types.d.ts.map +1 -0
- package/dist/types/operation-types.d.ts +31 -0
- package/dist/types/operation-types.d.ts.map +1 -0
- package/package.json +18 -17
- package/src/core/codecs.ts +66 -0
- package/src/core/descriptor-meta.ts +64 -0
- package/src/exports/codec-types.ts +7 -0
- package/src/exports/column-types.ts +13 -0
- package/src/exports/control.ts +81 -0
- package/src/exports/operation-types.ts +7 -0
- package/src/exports/pack.ts +5 -0
- package/src/exports/runtime.ts +48 -0
- package/src/types/codec-types.ts +10 -0
- package/src/types/operation-types.ts +31 -0
- package/dist/exports/chunk-QZXQPESZ.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/descriptor-meta.ts"],"sourcesContent":["import type { ExtensionPackRef } from '@prisma-next/contract/framework-components';\nimport type { SqlOperationSignature } from '@prisma-next/sql-operations';\n\nconst pgvectorTypeId = 'pg/vector@1' as const;\n\nconst cosineLowering = {\n targetFamily: 'sql',\n strategy: 'function',\n template: '1 - ({{self}} <=> {{arg0}})',\n} as const;\n\n/**\n * Shared operation definition used by both pack metadata and runtime descriptor.\n * Frozen to prevent accidental mutation.\n */\nconst cosineDistanceOperation = Object.freeze({\n method: 'cosineDistance',\n args: [{ kind: 'param' }],\n returns: { kind: 'builtin', type: 'number' },\n lowering: cosineLowering,\n} as const);\n\nexport const pgvectorPackMeta = {\n kind: 'extension',\n id: 'pgvector',\n familyId: 'sql',\n targetId: 'postgres',\n version: '0.0.1',\n capabilities: {\n postgres: {\n 'pgvector/cosine': true,\n },\n },\n types: {\n codecTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/codec-types',\n named: 'CodecTypes',\n alias: 'PgVectorTypes',\n },\n },\n operationTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/operation-types',\n named: 'OperationTypes',\n alias: 'PgVectorOperationTypes',\n },\n },\n storage: [\n { typeId: pgvectorTypeId, familyId: 'sql', targetId: 'postgres', nativeType: 'vector' },\n ],\n },\n operations: [\n {\n for: pgvectorTypeId,\n ...cosineDistanceOperation,\n },\n ],\n} as const satisfies ExtensionPackRef<'sql', 'postgres'>;\n\nexport const pgvectorRuntimeOperation: SqlOperationSignature = {\n forTypeId: pgvectorTypeId,\n ...cosineDistanceOperation,\n};\n"],"mappings":";AAGA,IAAM,iBAAiB;AAEvB,IAAM,iBAAiB;AAAA,EACrB,cAAc;AAAA,EACd,UAAU;AAAA,EACV,UAAU;AACZ;AAMA,IAAM,0BAA0B,OAAO,OAAO;AAAA,EAC5C,QAAQ;AAAA,EACR,MAAM,CAAC,EAAE,MAAM,QAAQ,CAAC;AAAA,EACxB,SAAS,EAAE,MAAM,WAAW,MAAM,SAAS;AAAA,EAC3C,UAAU;AACZ,CAAU;AAEH,IAAM,mBAAmB;AAAA,EAC9B,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,UAAU;AAAA,EACV,SAAS;AAAA,EACT,cAAc;AAAA,IACZ,UAAU;AAAA,MACR,mBAAmB;AAAA,IACrB;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IACL,YAAY;AAAA,MACV,QAAQ;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,gBAAgB;AAAA,MACd,QAAQ;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,EAAE,QAAQ,gBAAgB,UAAU,OAAO,UAAU,YAAY,YAAY,SAAS;AAAA,IACxF;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV;AAAA,MACE,KAAK;AAAA,MACL,GAAG;AAAA,IACL;AAAA,EACF;AACF;AAEO,IAAM,2BAAkD;AAAA,EAC7D,WAAW;AAAA,EACX,GAAG;AACL;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vector codec implementation for pgvector extension.
|
|
3
|
+
*
|
|
4
|
+
* Provides encoding/decoding for the `vector` PostgreSQL type.
|
|
5
|
+
* Wire format is a string like `[1,2,3]` (PostgreSQL vector text format).
|
|
6
|
+
*/
|
|
7
|
+
declare const codecs: import("@prisma-next/sql-relational-core/ast").CodecDefBuilder<{} & Record<"vector", import("@prisma-next/sql-relational-core/ast").Codec<"pg/vector@1", string, number[]>>>;
|
|
8
|
+
export declare const codecDefinitions: {
|
|
9
|
+
readonly vector: {
|
|
10
|
+
readonly typeId: "pg/vector@1";
|
|
11
|
+
readonly scalar: "vector";
|
|
12
|
+
readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/vector@1", string, number[]>;
|
|
13
|
+
readonly input: number[];
|
|
14
|
+
readonly output: number[];
|
|
15
|
+
readonly jsType: number[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare const dataTypes: {
|
|
19
|
+
readonly vector: "pg/vector@1";
|
|
20
|
+
};
|
|
21
|
+
export type CodecTypes = typeof codecs.CodecTypes;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=codecs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../src/core/codecs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqDH,QAAA,MAAM,MAAM,8KAA8C,CAAC;AAG3D,eAAO,MAAM,gBAAgB;;;;;;;;;CAA0B,CAAC;AACxD,eAAO,MAAM,SAAS;;CAAmB,CAAC;AAG1C,MAAM,MAAM,UAAU,GAAG,OAAO,MAAM,CAAC,UAAU,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { SqlOperationSignature } from '@prisma-next/sql-operations';
|
|
2
|
+
export declare const pgvectorPackMeta: {
|
|
3
|
+
readonly kind: "extension";
|
|
4
|
+
readonly id: "pgvector";
|
|
5
|
+
readonly familyId: "sql";
|
|
6
|
+
readonly targetId: "postgres";
|
|
7
|
+
readonly version: "0.0.1";
|
|
8
|
+
readonly capabilities: {
|
|
9
|
+
readonly postgres: {
|
|
10
|
+
readonly 'pgvector/cosine': true;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
readonly types: {
|
|
14
|
+
readonly codecTypes: {
|
|
15
|
+
readonly import: {
|
|
16
|
+
readonly package: "@prisma-next/extension-pgvector/codec-types";
|
|
17
|
+
readonly named: "CodecTypes";
|
|
18
|
+
readonly alias: "PgVectorTypes";
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
readonly operationTypes: {
|
|
22
|
+
readonly import: {
|
|
23
|
+
readonly package: "@prisma-next/extension-pgvector/operation-types";
|
|
24
|
+
readonly named: "OperationTypes";
|
|
25
|
+
readonly alias: "PgVectorOperationTypes";
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
readonly storage: readonly [{
|
|
29
|
+
readonly typeId: "pg/vector@1";
|
|
30
|
+
readonly familyId: "sql";
|
|
31
|
+
readonly targetId: "postgres";
|
|
32
|
+
readonly nativeType: "vector";
|
|
33
|
+
}];
|
|
34
|
+
};
|
|
35
|
+
readonly operations: readonly [{
|
|
36
|
+
readonly method: "cosineDistance";
|
|
37
|
+
readonly args: readonly [{
|
|
38
|
+
readonly kind: "param";
|
|
39
|
+
}];
|
|
40
|
+
readonly returns: {
|
|
41
|
+
readonly kind: "builtin";
|
|
42
|
+
readonly type: "number";
|
|
43
|
+
};
|
|
44
|
+
readonly lowering: {
|
|
45
|
+
readonly targetFamily: "sql";
|
|
46
|
+
readonly strategy: "function";
|
|
47
|
+
readonly template: "1 - ({{self}} <=> {{arg0}})";
|
|
48
|
+
};
|
|
49
|
+
readonly for: "pg/vector@1";
|
|
50
|
+
}];
|
|
51
|
+
};
|
|
52
|
+
export declare const pgvectorRuntimeOperation: SqlOperationSignature;
|
|
53
|
+
//# sourceMappingURL=descriptor-meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-meta.d.ts","sourceRoot":"","sources":["../../src/core/descriptor-meta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAqBzE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoC2B,CAAC;AAEzD,eAAO,MAAM,wBAAwB,EAAE,qBAGtC,CAAC"}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import * as _prisma_next_sql_relational_core_ast from '@prisma-next/sql-relational-core/ast';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
2
|
+
* Codec type definitions for pgvector extension.
|
|
5
3
|
*
|
|
6
|
-
*
|
|
7
|
-
* Wire format is a string like `[1,2,3]` (PostgreSQL vector text format).
|
|
4
|
+
* Re-export from types module for public API.
|
|
8
5
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export type { CodecTypes };
|
|
6
|
+
export type { CodecTypes } from '../types/codec-types';
|
|
7
|
+
//# sourceMappingURL=codec-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec-types.d.ts","sourceRoot":"","sources":["../../src/exports/codec-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
* These descriptors provide both codecId and nativeType for use in contract authoring.
|
|
5
5
|
* They are derived from the same source of truth as codec definitions and manifests.
|
|
6
6
|
*/
|
|
7
|
-
declare const vectorColumn: {
|
|
7
|
+
export declare const vectorColumn: {
|
|
8
8
|
readonly codecId: "pg/vector@1";
|
|
9
9
|
readonly nativeType: "vector";
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
export { vectorColumn };
|
|
11
|
+
//# sourceMappingURL=column-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-types.d.ts","sourceRoot":"","sources":["../../src/exports/column-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,eAAO,MAAM,YAAY;;;CAGgB,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { SqlControlExtensionDescriptor } from '@prisma-next/family-sql/control';
|
|
2
|
-
|
|
1
|
+
import type { SqlControlExtensionDescriptor } from '@prisma-next/family-sql/control';
|
|
3
2
|
/**
|
|
4
3
|
* pgvector extension descriptor for CLI config.
|
|
5
4
|
* Declares database dependencies for the 'vector' Postgres extension.
|
|
6
5
|
*/
|
|
7
6
|
declare const pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'>;
|
|
8
|
-
|
|
9
|
-
export
|
|
7
|
+
export { pgvectorExtensionDescriptor };
|
|
8
|
+
export default pgvectorExtensionDescriptor;
|
|
9
|
+
//# sourceMappingURL=control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/exports/control.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,6BAA6B,EAC9B,MAAM,iCAAiC,CAAC;AA8DzC;;;GAGG;AACH,QAAA,MAAM,2BAA2B,EAAE,6BAA6B,CAAC,UAAU,CAO1E,CAAC;AAEF,OAAO,EAAE,2BAA2B,EAAE,CAAC;AACvC,eAAe,2BAA2B,CAAC"}
|
package/dist/exports/control.js
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Operation type definitions for pgvector extension.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* These types are imported by contract.d.ts files for compile-time type inference.
|
|
4
|
+
* Re-export from types module for public API.
|
|
6
5
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* Maps typeId to operation methods.
|
|
10
|
-
*/
|
|
11
|
-
type OperationTypes = {
|
|
12
|
-
readonly 'pg/vector@1': {
|
|
13
|
-
readonly cosineDistance: {
|
|
14
|
-
readonly args: readonly [
|
|
15
|
-
{
|
|
16
|
-
readonly kind: 'param';
|
|
17
|
-
}
|
|
18
|
-
];
|
|
19
|
-
readonly returns: {
|
|
20
|
-
readonly kind: 'builtin';
|
|
21
|
-
readonly type: 'number';
|
|
22
|
-
};
|
|
23
|
-
readonly lowering: {
|
|
24
|
-
readonly targetFamily: 'sql';
|
|
25
|
-
readonly strategy: 'function';
|
|
26
|
-
readonly template: string;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type { OperationTypes };
|
|
6
|
+
export type { OperationTypes } from '../types/operation-types';
|
|
7
|
+
//# sourceMappingURL=operation-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-types.d.ts","sourceRoot":"","sources":["../../src/exports/operation-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/exports/pack.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack.d.ts","sourceRoot":"","sources":["../../src/exports/pack.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAmB,CAAC;AAEtC,eAAe,YAAY,CAAC"}
|
package/dist/exports/pack.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { SqlRuntimeExtensionDescriptor } from '@prisma-next/sql-runtime';
|
|
2
|
-
|
|
1
|
+
import type { SqlRuntimeExtensionDescriptor } from '@prisma-next/sql-runtime';
|
|
3
2
|
/**
|
|
4
3
|
* pgvector SQL runtime extension descriptor.
|
|
5
4
|
* Provides metadata and factory for creating runtime extension instances.
|
|
6
5
|
*/
|
|
7
6
|
declare const pgvectorRuntimeDescriptor: SqlRuntimeExtensionDescriptor<'postgres'>;
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export default pgvectorRuntimeDescriptor;
|
|
8
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/exports/runtime.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,6BAA6B,EAE9B,MAAM,0BAA0B,CAAC;AA0BlC;;;GAGG;AACH,QAAA,MAAM,yBAAyB,EAAE,6BAA6B,CAAC,UAAU,CASxE,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
|
package/dist/exports/runtime.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codec type definitions for pgvector extension.
|
|
3
|
+
*
|
|
4
|
+
* This file exports type-only definitions for codec input/output types.
|
|
5
|
+
* These types are imported by contract.d.ts files for compile-time type inference.
|
|
6
|
+
*
|
|
7
|
+
* Runtime codec implementations are provided by the extension's codec registry.
|
|
8
|
+
*/
|
|
9
|
+
export type { CodecTypes } from '../core/codecs';
|
|
10
|
+
//# sourceMappingURL=codec-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec-types.d.ts","sourceRoot":"","sources":["../../src/types/codec-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operation type definitions for pgvector extension.
|
|
3
|
+
*
|
|
4
|
+
* This file exports type-only definitions for operation method signatures.
|
|
5
|
+
* These types are imported by contract.d.ts files for compile-time type inference.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Operation types for pgvector extension.
|
|
9
|
+
* Maps typeId to operation methods.
|
|
10
|
+
*/
|
|
11
|
+
export type OperationTypes = {
|
|
12
|
+
readonly 'pg/vector@1': {
|
|
13
|
+
readonly cosineDistance: {
|
|
14
|
+
readonly args: readonly [
|
|
15
|
+
{
|
|
16
|
+
readonly kind: 'param';
|
|
17
|
+
}
|
|
18
|
+
];
|
|
19
|
+
readonly returns: {
|
|
20
|
+
readonly kind: 'builtin';
|
|
21
|
+
readonly type: 'number';
|
|
22
|
+
};
|
|
23
|
+
readonly lowering: {
|
|
24
|
+
readonly targetFamily: 'sql';
|
|
25
|
+
readonly strategy: 'function';
|
|
26
|
+
readonly template: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=operation-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-types.d.ts","sourceRoot":"","sources":["../../src/types/operation-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,aAAa,EAAE;QACtB,QAAQ,CAAC,cAAc,EAAE;YACvB,QAAQ,CAAC,IAAI,EAAE,SAAS;gBACtB;oBACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;iBACxB;aACF,CAAC;YACF,QAAQ,CAAC,OAAO,EAAE;gBAChB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;gBACzB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;aACzB,CAAC;YACF,QAAQ,CAAC,QAAQ,EAAE;gBACjB,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC;gBAC7B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;gBAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;aAC3B,CAAC;SACH,CAAC;KACH,CAAC;CACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/extension-pgvector",
|
|
3
|
-
"version": "0.3.0-dev.
|
|
3
|
+
"version": "0.3.0-dev.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"arktype": "^2.0.0",
|
|
8
|
-
"@prisma-next/cli": "0.3.0-dev.
|
|
9
|
-
"@prisma-next/contract": "0.3.0-dev.
|
|
10
|
-
"@prisma-next/contract-authoring": "0.3.0-dev.
|
|
11
|
-
"@prisma-next/core-control-plane": "0.3.0-dev.
|
|
12
|
-
"@prisma-next/
|
|
13
|
-
"@prisma-next/sql-
|
|
14
|
-
"@prisma-next/sql
|
|
15
|
-
"@prisma-next/sql-runtime": "0.3.0-dev.
|
|
16
|
-
"@prisma-next/sql-schema-ir": "0.3.0-dev.
|
|
8
|
+
"@prisma-next/cli": "0.3.0-dev.5",
|
|
9
|
+
"@prisma-next/contract": "0.3.0-dev.5",
|
|
10
|
+
"@prisma-next/contract-authoring": "0.3.0-dev.5",
|
|
11
|
+
"@prisma-next/core-control-plane": "0.3.0-dev.5",
|
|
12
|
+
"@prisma-next/sql-operations": "0.3.0-dev.5",
|
|
13
|
+
"@prisma-next/sql-relational-core": "0.3.0-dev.5",
|
|
14
|
+
"@prisma-next/family-sql": "0.3.0-dev.5",
|
|
15
|
+
"@prisma-next/sql-runtime": "0.3.0-dev.5",
|
|
16
|
+
"@prisma-next/sql-schema-ir": "0.3.0-dev.5"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@vitest/coverage-v8": "4.0.16",
|
|
20
20
|
"tsup": "8.5.1",
|
|
21
21
|
"typescript": "5.9.3",
|
|
22
22
|
"vitest": "4.0.16",
|
|
23
|
-
"@prisma-next/adapter-postgres": "0.3.0-dev.
|
|
24
|
-
"@prisma-next/operations": "0.3.0-dev.
|
|
25
|
-
"@prisma-next/sql-contract": "0.3.0-dev.
|
|
26
|
-
"@prisma-next/sql-contract-ts": "0.3.0-dev.
|
|
27
|
-
"@prisma-next/sql-lane": "0.3.0-dev.
|
|
23
|
+
"@prisma-next/adapter-postgres": "0.3.0-dev.5",
|
|
24
|
+
"@prisma-next/operations": "0.3.0-dev.5",
|
|
25
|
+
"@prisma-next/sql-contract": "0.3.0-dev.5",
|
|
26
|
+
"@prisma-next/sql-contract-ts": "0.3.0-dev.5",
|
|
27
|
+
"@prisma-next/sql-lane": "0.3.0-dev.5",
|
|
28
28
|
"@prisma-next/test-utils": "0.0.1"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
|
-
"dist"
|
|
31
|
+
"dist",
|
|
32
|
+
"src"
|
|
32
33
|
],
|
|
33
34
|
"exports": {
|
|
34
35
|
"./package.json": "./package.json",
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
}
|
|
59
60
|
},
|
|
60
61
|
"scripts": {
|
|
61
|
-
"build": "tsup --config tsup.config.ts",
|
|
62
|
+
"build": "tsup --config tsup.config.ts && tsc --project tsconfig.build.json",
|
|
62
63
|
"test": "vitest run",
|
|
63
64
|
"test:coverage": "vitest run --coverage",
|
|
64
65
|
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vector codec implementation for pgvector extension.
|
|
3
|
+
*
|
|
4
|
+
* Provides encoding/decoding for the `vector` PostgreSQL type.
|
|
5
|
+
* Wire format is a string like `[1,2,3]` (PostgreSQL vector text format).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { codec, defineCodecs } from '@prisma-next/sql-relational-core/ast';
|
|
9
|
+
|
|
10
|
+
const pgVectorCodec = codec<'pg/vector@1', string, number[]>({
|
|
11
|
+
typeId: 'pg/vector@1',
|
|
12
|
+
targetTypes: ['vector'],
|
|
13
|
+
encode: (value: number[]): string => {
|
|
14
|
+
// Validate that value is an array of numbers
|
|
15
|
+
if (!Array.isArray(value)) {
|
|
16
|
+
throw new Error('Vector value must be an array of numbers');
|
|
17
|
+
}
|
|
18
|
+
if (!value.every((v) => typeof v === 'number')) {
|
|
19
|
+
throw new Error('Vector value must contain only numbers');
|
|
20
|
+
}
|
|
21
|
+
// Format as PostgreSQL vector text format: [1,2,3]
|
|
22
|
+
// PostgreSQL's pg library requires the vector format string
|
|
23
|
+
return `[${value.join(',')}]`;
|
|
24
|
+
},
|
|
25
|
+
decode: (wire: string): number[] => {
|
|
26
|
+
// Handle string format from PostgreSQL: [1,2,3]
|
|
27
|
+
if (typeof wire !== 'string') {
|
|
28
|
+
throw new Error('Vector wire value must be a string');
|
|
29
|
+
}
|
|
30
|
+
// Parse PostgreSQL vector format: [1,2,3]
|
|
31
|
+
if (!wire.startsWith('[') || !wire.endsWith(']')) {
|
|
32
|
+
throw new Error(`Invalid vector format: expected "[...]", got "${wire}"`);
|
|
33
|
+
}
|
|
34
|
+
const content = wire.slice(1, -1).trim();
|
|
35
|
+
if (content === '') {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
const values = content.split(',').map((v) => {
|
|
39
|
+
const num = Number.parseFloat(v.trim());
|
|
40
|
+
if (Number.isNaN(num)) {
|
|
41
|
+
throw new Error(`Invalid vector value: "${v}" is not a number`);
|
|
42
|
+
}
|
|
43
|
+
return num;
|
|
44
|
+
});
|
|
45
|
+
return values;
|
|
46
|
+
},
|
|
47
|
+
meta: {
|
|
48
|
+
db: {
|
|
49
|
+
sql: {
|
|
50
|
+
postgres: {
|
|
51
|
+
nativeType: 'vector',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Build codec definitions using the builder DSL
|
|
59
|
+
const codecs = defineCodecs().add('vector', pgVectorCodec);
|
|
60
|
+
|
|
61
|
+
// Export derived structures directly from codecs builder
|
|
62
|
+
export const codecDefinitions = codecs.codecDefinitions;
|
|
63
|
+
export const dataTypes = codecs.dataTypes;
|
|
64
|
+
|
|
65
|
+
// Export types derived from codecs builder
|
|
66
|
+
export type CodecTypes = typeof codecs.CodecTypes;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ExtensionPackRef } from '@prisma-next/contract/framework-components';
|
|
2
|
+
import type { SqlOperationSignature } from '@prisma-next/sql-operations';
|
|
3
|
+
|
|
4
|
+
const pgvectorTypeId = 'pg/vector@1' as const;
|
|
5
|
+
|
|
6
|
+
const cosineLowering = {
|
|
7
|
+
targetFamily: 'sql',
|
|
8
|
+
strategy: 'function',
|
|
9
|
+
template: '1 - ({{self}} <=> {{arg0}})',
|
|
10
|
+
} as const;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Shared operation definition used by both pack metadata and runtime descriptor.
|
|
14
|
+
* Frozen to prevent accidental mutation.
|
|
15
|
+
*/
|
|
16
|
+
const cosineDistanceOperation = Object.freeze({
|
|
17
|
+
method: 'cosineDistance',
|
|
18
|
+
args: [{ kind: 'param' }],
|
|
19
|
+
returns: { kind: 'builtin', type: 'number' },
|
|
20
|
+
lowering: cosineLowering,
|
|
21
|
+
} as const);
|
|
22
|
+
|
|
23
|
+
export const pgvectorPackMeta = {
|
|
24
|
+
kind: 'extension',
|
|
25
|
+
id: 'pgvector',
|
|
26
|
+
familyId: 'sql',
|
|
27
|
+
targetId: 'postgres',
|
|
28
|
+
version: '0.0.1',
|
|
29
|
+
capabilities: {
|
|
30
|
+
postgres: {
|
|
31
|
+
'pgvector/cosine': true,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
types: {
|
|
35
|
+
codecTypes: {
|
|
36
|
+
import: {
|
|
37
|
+
package: '@prisma-next/extension-pgvector/codec-types',
|
|
38
|
+
named: 'CodecTypes',
|
|
39
|
+
alias: 'PgVectorTypes',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
operationTypes: {
|
|
43
|
+
import: {
|
|
44
|
+
package: '@prisma-next/extension-pgvector/operation-types',
|
|
45
|
+
named: 'OperationTypes',
|
|
46
|
+
alias: 'PgVectorOperationTypes',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
storage: [
|
|
50
|
+
{ typeId: pgvectorTypeId, familyId: 'sql', targetId: 'postgres', nativeType: 'vector' },
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
operations: [
|
|
54
|
+
{
|
|
55
|
+
for: pgvectorTypeId,
|
|
56
|
+
...cosineDistanceOperation,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
} as const satisfies ExtensionPackRef<'sql', 'postgres'>;
|
|
60
|
+
|
|
61
|
+
export const pgvectorRuntimeOperation: SqlOperationSignature = {
|
|
62
|
+
forTypeId: pgvectorTypeId,
|
|
63
|
+
...cosineDistanceOperation,
|
|
64
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Column type descriptors for pgvector extension.
|
|
3
|
+
*
|
|
4
|
+
* These descriptors provide both codecId and nativeType for use in contract authoring.
|
|
5
|
+
* They are derived from the same source of truth as codec definitions and manifests.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ColumnTypeDescriptor } from '@prisma-next/contract-authoring';
|
|
9
|
+
|
|
10
|
+
export const vectorColumn = {
|
|
11
|
+
codecId: 'pg/vector@1',
|
|
12
|
+
nativeType: 'vector',
|
|
13
|
+
} as const satisfies ColumnTypeDescriptor;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { SchemaIssue } from '@prisma-next/core-control-plane/types';
|
|
2
|
+
import type {
|
|
3
|
+
ComponentDatabaseDependencies,
|
|
4
|
+
SqlControlExtensionDescriptor,
|
|
5
|
+
} from '@prisma-next/family-sql/control';
|
|
6
|
+
import type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';
|
|
7
|
+
import { pgvectorPackMeta } from '../core/descriptor-meta';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Pure verification hook: checks whether the 'vector' extension is installed
|
|
11
|
+
* based on the in-memory schema IR (no DB I/O).
|
|
12
|
+
*/
|
|
13
|
+
function verifyVectorExtensionInstalled(schema: SqlSchemaIR): readonly SchemaIssue[] {
|
|
14
|
+
if (!schema.extensions.includes('vector')) {
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
kind: 'extension_missing',
|
|
18
|
+
table: '',
|
|
19
|
+
message: 'Extension "vector" is missing from database (required by pgvector)',
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Database dependencies for the pgvector extension.
|
|
28
|
+
* Declares the 'vector' Postgres extension as a required dependency.
|
|
29
|
+
*/
|
|
30
|
+
const pgvectorDatabaseDependencies: ComponentDatabaseDependencies<unknown> = {
|
|
31
|
+
init: [
|
|
32
|
+
{
|
|
33
|
+
id: 'postgres.extension.vector',
|
|
34
|
+
label: 'Enable vector extension',
|
|
35
|
+
install: [
|
|
36
|
+
{
|
|
37
|
+
id: 'extension.vector',
|
|
38
|
+
label: 'Enable extension "vector"',
|
|
39
|
+
summary: 'Ensures the vector extension is available for pgvector operations',
|
|
40
|
+
operationClass: 'additive',
|
|
41
|
+
target: { id: 'postgres' },
|
|
42
|
+
precheck: [
|
|
43
|
+
{
|
|
44
|
+
description: 'verify extension "vector" is not already enabled',
|
|
45
|
+
sql: "SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')",
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
execute: [
|
|
49
|
+
{
|
|
50
|
+
description: 'create extension "vector"',
|
|
51
|
+
sql: 'CREATE EXTENSION IF NOT EXISTS vector',
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
postcheck: [
|
|
55
|
+
{
|
|
56
|
+
description: 'confirm extension "vector" is enabled',
|
|
57
|
+
sql: "SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')",
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
verifyDatabaseDependencyInstalled: verifyVectorExtensionInstalled,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* pgvector extension descriptor for CLI config.
|
|
69
|
+
* Declares database dependencies for the 'vector' Postgres extension.
|
|
70
|
+
*/
|
|
71
|
+
const pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {
|
|
72
|
+
...pgvectorPackMeta,
|
|
73
|
+
databaseDependencies: pgvectorDatabaseDependencies,
|
|
74
|
+
create: () => ({
|
|
75
|
+
familyId: 'sql' as const,
|
|
76
|
+
targetId: 'postgres' as const,
|
|
77
|
+
}),
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export { pgvectorExtensionDescriptor };
|
|
81
|
+
export default pgvectorExtensionDescriptor;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { SqlOperationSignature } from '@prisma-next/sql-operations';
|
|
2
|
+
import type { CodecRegistry } from '@prisma-next/sql-relational-core/ast';
|
|
3
|
+
import { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';
|
|
4
|
+
import type {
|
|
5
|
+
SqlRuntimeExtensionDescriptor,
|
|
6
|
+
SqlRuntimeExtensionInstance,
|
|
7
|
+
} from '@prisma-next/sql-runtime';
|
|
8
|
+
import { codecDefinitions } from '../core/codecs';
|
|
9
|
+
import { pgvectorPackMeta, pgvectorRuntimeOperation } from '../core/descriptor-meta';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* pgvector SQL runtime extension instance.
|
|
13
|
+
* Provides codecs and operations for vector data type and similarity operations.
|
|
14
|
+
*/
|
|
15
|
+
class PgVectorRuntimeExtensionInstance implements SqlRuntimeExtensionInstance<'postgres'> {
|
|
16
|
+
readonly familyId = 'sql' as const;
|
|
17
|
+
readonly targetId = 'postgres' as const;
|
|
18
|
+
|
|
19
|
+
codecs(): CodecRegistry {
|
|
20
|
+
const registry = createCodecRegistry();
|
|
21
|
+
// Register all codecs from codecDefinitions
|
|
22
|
+
for (const def of Object.values(codecDefinitions)) {
|
|
23
|
+
registry.register(def.codec);
|
|
24
|
+
}
|
|
25
|
+
return registry;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
operations(): ReadonlyArray<SqlOperationSignature> {
|
|
29
|
+
return [pgvectorRuntimeOperation];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* pgvector SQL runtime extension descriptor.
|
|
35
|
+
* Provides metadata and factory for creating runtime extension instances.
|
|
36
|
+
*/
|
|
37
|
+
const pgvectorRuntimeDescriptor: SqlRuntimeExtensionDescriptor<'postgres'> = {
|
|
38
|
+
kind: 'extension' as const,
|
|
39
|
+
id: pgvectorPackMeta.id,
|
|
40
|
+
version: pgvectorPackMeta.version,
|
|
41
|
+
familyId: 'sql' as const,
|
|
42
|
+
targetId: 'postgres' as const,
|
|
43
|
+
create(): SqlRuntimeExtensionInstance<'postgres'> {
|
|
44
|
+
return new PgVectorRuntimeExtensionInstance();
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default pgvectorRuntimeDescriptor;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codec type definitions for pgvector extension.
|
|
3
|
+
*
|
|
4
|
+
* This file exports type-only definitions for codec input/output types.
|
|
5
|
+
* These types are imported by contract.d.ts files for compile-time type inference.
|
|
6
|
+
*
|
|
7
|
+
* Runtime codec implementations are provided by the extension's codec registry.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export type { CodecTypes } from '../core/codecs';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operation type definitions for pgvector extension.
|
|
3
|
+
*
|
|
4
|
+
* This file exports type-only definitions for operation method signatures.
|
|
5
|
+
* These types are imported by contract.d.ts files for compile-time type inference.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Operation types for pgvector extension.
|
|
10
|
+
* Maps typeId to operation methods.
|
|
11
|
+
*/
|
|
12
|
+
export type OperationTypes = {
|
|
13
|
+
readonly 'pg/vector@1': {
|
|
14
|
+
readonly cosineDistance: {
|
|
15
|
+
readonly args: readonly [
|
|
16
|
+
{
|
|
17
|
+
readonly kind: 'param';
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
readonly returns: {
|
|
21
|
+
readonly kind: 'builtin';
|
|
22
|
+
readonly type: 'number';
|
|
23
|
+
};
|
|
24
|
+
readonly lowering: {
|
|
25
|
+
readonly targetFamily: 'sql';
|
|
26
|
+
readonly strategy: 'function';
|
|
27
|
+
readonly template: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/descriptor-meta.ts"],"sourcesContent":["import type { ExtensionPackRef } from '@prisma-next/contract/framework-components';\nimport type { SqlOperationSignature } from '@prisma-next/sql-operations';\n\nconst pgvectorTypeId = 'pg/vector@1' as const;\n\nconst cosineLowering = {\n targetFamily: 'sql',\n strategy: 'function',\n template: '1 - ({{self}} <=> {{arg0}})',\n} as const;\n\n/**\n * Shared operation definition used by both pack metadata and runtime descriptor.\n * Frozen to prevent accidental mutation.\n */\nconst cosineDistanceOperation = Object.freeze({\n method: 'cosineDistance',\n args: [{ kind: 'param' }],\n returns: { kind: 'builtin', type: 'number' },\n lowering: cosineLowering,\n} as const);\n\nexport const pgvectorPackMeta = {\n kind: 'extension',\n id: 'pgvector',\n familyId: 'sql',\n targetId: 'postgres',\n version: '0.0.1',\n capabilities: {\n postgres: {\n 'pgvector/cosine': true,\n },\n },\n types: {\n codecTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/codec-types',\n named: 'CodecTypes',\n alias: 'PgVectorTypes',\n },\n },\n operationTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/operation-types',\n named: 'OperationTypes',\n alias: 'PgVectorOperationTypes',\n },\n },\n storage: [\n { typeId: pgvectorTypeId, familyId: 'sql', targetId: 'postgres', nativeType: 'vector' },\n ],\n },\n operations: [\n {\n for: pgvectorTypeId,\n ...cosineDistanceOperation,\n },\n ],\n} as const satisfies ExtensionPackRef<'sql', 'postgres'>;\n\nexport const pgvectorRuntimeOperation: SqlOperationSignature = {\n forTypeId: pgvectorTypeId,\n ...cosineDistanceOperation,\n};\n"],"mappings":";AAGA,IAAM,iBAAiB;AAEvB,IAAM,iBAAiB;AAAA,EACrB,cAAc;AAAA,EACd,UAAU;AAAA,EACV,UAAU;AACZ;AAMA,IAAM,0BAA0B,OAAO,OAAO;AAAA,EAC5C,QAAQ;AAAA,EACR,MAAM,CAAC,EAAE,MAAM,QAAQ,CAAC;AAAA,EACxB,SAAS,EAAE,MAAM,WAAW,MAAM,SAAS;AAAA,EAC3C,UAAU;AACZ,CAAU;AAEH,IAAM,mBAAmB;AAAA,EAC9B,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,UAAU;AAAA,EACV,SAAS;AAAA,EACT,cAAc;AAAA,IACZ,UAAU;AAAA,MACR,mBAAmB;AAAA,IACrB;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IACL,YAAY;AAAA,MACV,QAAQ;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,gBAAgB;AAAA,MACd,QAAQ;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,EAAE,QAAQ,gBAAgB,UAAU,OAAO,UAAU,YAAY,YAAY,SAAS;AAAA,IACxF;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV;AAAA,MACE,KAAK;AAAA,MACL,GAAG;AAAA,IACL;AAAA,EACF;AACF;AAEO,IAAM,2BAAkD;AAAA,EAC7D,WAAW;AAAA,EACX,GAAG;AACL;","names":[]}
|