@prisma-next/extension-pgvector 0.3.0-pr.99.6 → 0.3.0
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 +201 -0
- package/README.md +50 -30
- package/dist/codec-types-BifaP625.d.mts +27 -0
- package/dist/codec-types-BifaP625.d.mts.map +1 -0
- package/dist/codec-types.d.mts +2 -0
- package/dist/codec-types.mjs +1 -0
- package/dist/column-types.d.mts +33 -0
- package/dist/column-types.d.mts.map +1 -0
- package/dist/column-types.mjs +36 -0
- package/dist/column-types.mjs.map +1 -0
- package/dist/constants-Co5golCK.mjs +13 -0
- package/dist/constants-Co5golCK.mjs.map +1 -0
- package/dist/control.d.mts +7 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +61 -0
- package/dist/control.mjs.map +1 -0
- package/dist/descriptor-meta-CHj8SCio.mjs +147 -0
- package/dist/descriptor-meta-CHj8SCio.mjs.map +1 -0
- package/dist/operation-types.d.mts +76 -0
- package/dist/operation-types.d.mts.map +1 -0
- package/dist/operation-types.mjs +1 -0
- package/dist/pack.d.mts +86 -0
- package/dist/pack.d.mts.map +1 -0
- package/dist/pack.mjs +9 -0
- package/dist/pack.mjs.map +1 -0
- package/dist/runtime.d.mts +7 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +41 -0
- package/dist/runtime.mjs.map +1 -0
- package/package.json +30 -44
- package/src/core/authoring.ts +20 -0
- package/src/core/codecs.ts +12 -1
- package/src/core/constants.ts +9 -0
- package/src/core/descriptor-meta.ts +51 -38
- package/src/exports/codec-types.ts +1 -1
- package/src/exports/column-types.ts +34 -1
- package/src/exports/control.ts +32 -26
- package/src/exports/operation-types.ts +1 -1
- package/src/exports/pack.ts +6 -1
- package/src/exports/runtime.ts +37 -27
- package/src/types/codec-types.ts +11 -1
- package/src/types/operation-types.ts +30 -12
- package/dist/chunk-OI5XEHIN.js +0 -67
- package/dist/chunk-OI5XEHIN.js.map +0 -1
- package/dist/core/codecs.d.ts +0 -23
- package/dist/core/codecs.d.ts.map +0 -1
- package/dist/core/descriptor-meta.d.ts +0 -56
- package/dist/core/descriptor-meta.d.ts.map +0 -1
- package/dist/exports/codec-types.d.ts +0 -7
- package/dist/exports/codec-types.d.ts.map +0 -1
- package/dist/exports/codec-types.js +0 -1
- package/dist/exports/codec-types.js.map +0 -1
- package/dist/exports/column-types.d.ts +0 -11
- package/dist/exports/column-types.d.ts.map +0 -1
- package/dist/exports/column-types.js +0 -9
- package/dist/exports/column-types.js.map +0 -1
- package/dist/exports/control.d.ts +0 -9
- package/dist/exports/control.d.ts.map +0 -1
- package/dist/exports/control.js +0 -67
- package/dist/exports/control.js.map +0 -1
- package/dist/exports/operation-types.d.ts +0 -7
- package/dist/exports/operation-types.d.ts.map +0 -1
- package/dist/exports/operation-types.js +0 -1
- package/dist/exports/operation-types.js.map +0 -1
- package/dist/exports/pack.d.ts +0 -55
- package/dist/exports/pack.d.ts.map +0 -1
- package/dist/exports/pack.js +0 -11
- package/dist/exports/pack.js.map +0 -1
- package/dist/exports/runtime.d.ts +0 -8
- package/dist/exports/runtime.d.ts.map +0 -1
- package/dist/exports/runtime.js +0 -86
- package/dist/exports/runtime.js.map +0 -1
- package/dist/types/codec-types.d.ts +0 -10
- package/dist/types/codec-types.d.ts.map +0 -1
- package/dist/types/operation-types.d.ts +0 -31
- package/dist/types/operation-types.d.ts.map +0 -1
|
@@ -1,24 +1,37 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
1
|
+
import type { SqlOperationDescriptor } from '@prisma-next/sql-operations';
|
|
2
|
+
import { pgvectorAuthoringTypes } from './authoring';
|
|
3
|
+
import { codecDefinitions } from './codecs';
|
|
3
4
|
|
|
4
5
|
const pgvectorTypeId = 'pg/vector@1' as const;
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
export const pgvectorQueryOperations: readonly SqlOperationDescriptor[] = [
|
|
8
|
+
{
|
|
9
|
+
method: 'cosineDistance',
|
|
10
|
+
args: [
|
|
11
|
+
{ codecId: pgvectorTypeId, nullable: false },
|
|
12
|
+
{ codecId: pgvectorTypeId, nullable: false },
|
|
13
|
+
],
|
|
14
|
+
returns: { codecId: 'pg/float8@1', nullable: false },
|
|
15
|
+
lowering: {
|
|
16
|
+
targetFamily: 'sql',
|
|
17
|
+
strategy: 'function',
|
|
18
|
+
template: '{{self}} <=> {{arg0}}',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
method: 'cosineSimilarity',
|
|
23
|
+
args: [
|
|
24
|
+
{ codecId: pgvectorTypeId, nullable: false },
|
|
25
|
+
{ codecId: pgvectorTypeId, nullable: false },
|
|
26
|
+
],
|
|
27
|
+
returns: { codecId: 'pg/float8@1', nullable: false },
|
|
28
|
+
lowering: {
|
|
29
|
+
targetFamily: 'sql',
|
|
30
|
+
strategy: 'function',
|
|
31
|
+
template: '1 - ({{self}} <=> {{arg0}})',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
];
|
|
22
35
|
|
|
23
36
|
export const pgvectorPackMeta = {
|
|
24
37
|
kind: 'extension',
|
|
@@ -28,23 +41,27 @@ export const pgvectorPackMeta = {
|
|
|
28
41
|
version: '0.0.1',
|
|
29
42
|
capabilities: {
|
|
30
43
|
postgres: {
|
|
31
|
-
'pgvector
|
|
44
|
+
'pgvector.cosine': true,
|
|
32
45
|
},
|
|
33
46
|
},
|
|
47
|
+
authoring: {
|
|
48
|
+
type: pgvectorAuthoringTypes,
|
|
49
|
+
},
|
|
34
50
|
types: {
|
|
35
51
|
codecTypes: {
|
|
52
|
+
codecInstances: Object.values(codecDefinitions).map((def) => def.codec),
|
|
36
53
|
import: {
|
|
37
54
|
package: '@prisma-next/extension-pgvector/codec-types',
|
|
38
55
|
named: 'CodecTypes',
|
|
39
56
|
alias: 'PgVectorTypes',
|
|
40
57
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
58
|
+
typeImports: [
|
|
59
|
+
{
|
|
60
|
+
package: '@prisma-next/extension-pgvector/codec-types',
|
|
61
|
+
named: 'Vector',
|
|
62
|
+
alias: 'Vector',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
48
65
|
},
|
|
49
66
|
operationTypes: {
|
|
50
67
|
import: {
|
|
@@ -53,19 +70,15 @@ export const pgvectorPackMeta = {
|
|
|
53
70
|
alias: 'PgVectorOperationTypes',
|
|
54
71
|
},
|
|
55
72
|
},
|
|
73
|
+
queryOperationTypes: {
|
|
74
|
+
import: {
|
|
75
|
+
package: '@prisma-next/extension-pgvector/operation-types',
|
|
76
|
+
named: 'QueryOperationTypes',
|
|
77
|
+
alias: 'PgVectorQueryOperationTypes',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
56
80
|
storage: [
|
|
57
81
|
{ typeId: pgvectorTypeId, familyId: 'sql', targetId: 'postgres', nativeType: 'vector' },
|
|
58
82
|
],
|
|
59
83
|
},
|
|
60
|
-
|
|
61
|
-
{
|
|
62
|
-
for: pgvectorTypeId,
|
|
63
|
-
...cosineDistanceOperation,
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
} as const satisfies ExtensionPackRef<'sql', 'postgres'>;
|
|
67
|
-
|
|
68
|
-
export const pgvectorRuntimeOperation: SqlOperationSignature = {
|
|
69
|
-
forTypeId: pgvectorTypeId,
|
|
70
|
-
...cosineDistanceOperation,
|
|
71
|
-
};
|
|
84
|
+
} as const;
|
|
@@ -6,8 +6,41 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type { ColumnTypeDescriptor } from '@prisma-next/contract-authoring';
|
|
9
|
+
import { VECTOR_CODEC_ID, VECTOR_MAX_DIM } from '../core/constants';
|
|
9
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Static vector column descriptor without dimension.
|
|
13
|
+
* Use `vector(N)` for dimensioned vectors that produce `vector(N)` DDL.
|
|
14
|
+
*/
|
|
10
15
|
export const vectorColumn = {
|
|
11
|
-
codecId:
|
|
16
|
+
codecId: VECTOR_CODEC_ID,
|
|
12
17
|
nativeType: 'vector',
|
|
13
18
|
} as const satisfies ColumnTypeDescriptor;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Factory for creating dimensioned vector column descriptors.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* .column('embedding', { type: vector(1536), nullable: false })
|
|
26
|
+
* // Produces: nativeType: 'vector', typeParams: { length: 1536 }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @param length - The dimension of the vector (e.g., 1536 for OpenAI embeddings)
|
|
30
|
+
* @returns A column type descriptor with `typeParams.length` set
|
|
31
|
+
* @throws {RangeError} If length is not an integer in the range [1, VECTOR_MAX_DIM]
|
|
32
|
+
*/
|
|
33
|
+
export function vector<N extends number>(
|
|
34
|
+
length: N,
|
|
35
|
+
): ColumnTypeDescriptor & { readonly typeParams: { readonly length: N } } {
|
|
36
|
+
if (!Number.isInteger(length) || length < 1 || length > VECTOR_MAX_DIM) {
|
|
37
|
+
throw new RangeError(
|
|
38
|
+
`pgvector: dimension must be an integer in [1, ${VECTOR_MAX_DIM}], got ${length}`,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
codecId: VECTOR_CODEC_ID,
|
|
43
|
+
nativeType: 'vector',
|
|
44
|
+
typeParams: { length },
|
|
45
|
+
} as const;
|
|
46
|
+
}
|
package/src/exports/control.ts
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import type { SchemaIssue } from '@prisma-next/core-control-plane/types';
|
|
2
1
|
import type {
|
|
2
|
+
CodecControlHooks,
|
|
3
3
|
ComponentDatabaseDependencies,
|
|
4
4
|
SqlControlExtensionDescriptor,
|
|
5
5
|
} from '@prisma-next/family-sql/control';
|
|
6
|
-
import
|
|
7
|
-
import { pgvectorPackMeta } from '../core/descriptor-meta';
|
|
6
|
+
import { pgvectorPackMeta, pgvectorQueryOperations } from '../core/descriptor-meta';
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return [
|
|
16
|
-
{
|
|
17
|
-
kind: 'extension_missing',
|
|
18
|
-
table: '',
|
|
19
|
-
message: 'Extension "vector" is missing from database (required by pgvector)',
|
|
20
|
-
},
|
|
21
|
-
];
|
|
8
|
+
const PGVECTOR_CODEC_ID = 'pg/vector@1' as const;
|
|
9
|
+
|
|
10
|
+
function buildVectorIdentityValue(typeParams: Record<string, unknown> | undefined): string | null {
|
|
11
|
+
const length = typeParams?.['length'];
|
|
12
|
+
if (typeof length !== 'number' || !Number.isInteger(length) || length <= 0) {
|
|
13
|
+
return null;
|
|
22
14
|
}
|
|
23
|
-
|
|
15
|
+
|
|
16
|
+
const zeroVector = `[${new Array(length).fill('0').join(',')}]`;
|
|
17
|
+
return `'${zeroVector}'::vector`;
|
|
24
18
|
}
|
|
25
19
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
const vectorControlPlaneHooks: CodecControlHooks = {
|
|
21
|
+
expandNativeType: ({ nativeType, typeParams }) => {
|
|
22
|
+
const length = typeParams?.['length'];
|
|
23
|
+
if (typeof length === 'number' && Number.isInteger(length) && length > 0) {
|
|
24
|
+
return `${nativeType}(${length})`;
|
|
25
|
+
}
|
|
26
|
+
return nativeType;
|
|
27
|
+
},
|
|
28
|
+
resolveIdentityValue: ({ typeParams }) => buildVectorIdentityValue(typeParams),
|
|
29
|
+
};
|
|
30
|
+
|
|
30
31
|
const pgvectorDatabaseDependencies: ComponentDatabaseDependencies<unknown> = {
|
|
31
32
|
init: [
|
|
32
33
|
{
|
|
@@ -59,17 +60,22 @@ const pgvectorDatabaseDependencies: ComponentDatabaseDependencies<unknown> = {
|
|
|
59
60
|
],
|
|
60
61
|
},
|
|
61
62
|
],
|
|
62
|
-
verifyDatabaseDependencyInstalled: verifyVectorExtensionInstalled,
|
|
63
63
|
},
|
|
64
64
|
],
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
/**
|
|
68
|
-
* pgvector extension descriptor for CLI config.
|
|
69
|
-
* Declares database dependencies for the 'vector' Postgres extension.
|
|
70
|
-
*/
|
|
71
67
|
const pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {
|
|
72
68
|
...pgvectorPackMeta,
|
|
69
|
+
types: {
|
|
70
|
+
...pgvectorPackMeta.types,
|
|
71
|
+
codecTypes: {
|
|
72
|
+
...pgvectorPackMeta.types.codecTypes,
|
|
73
|
+
controlPlaneHooks: {
|
|
74
|
+
[PGVECTOR_CODEC_ID]: vectorControlPlaneHooks,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
queryOperations: () => pgvectorQueryOperations,
|
|
73
79
|
databaseDependencies: pgvectorDatabaseDependencies,
|
|
74
80
|
create: () => ({
|
|
75
81
|
familyId: 'sql' as const,
|
package/src/exports/pack.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import type { ExtensionPackRef } from '@prisma-next/framework-components/components';
|
|
1
2
|
import { pgvectorPackMeta } from '../core/descriptor-meta';
|
|
3
|
+
import type { CodecTypes } from '../types/codec-types';
|
|
2
4
|
|
|
3
5
|
const pgvectorPack = pgvectorPackMeta;
|
|
4
6
|
|
|
5
|
-
export default pgvectorPack
|
|
7
|
+
export default pgvectorPack as typeof pgvectorPackMeta &
|
|
8
|
+
ExtensionPackRef<'sql', 'postgres'> & {
|
|
9
|
+
readonly __codecTypes?: CodecTypes;
|
|
10
|
+
};
|
package/src/exports/runtime.ts
CHANGED
|
@@ -1,47 +1,57 @@
|
|
|
1
|
-
import type { SqlOperationSignature } from '@prisma-next/sql-operations';
|
|
2
|
-
import type { CodecRegistry } from '@prisma-next/sql-relational-core/ast';
|
|
3
1
|
import { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';
|
|
4
2
|
import type {
|
|
3
|
+
RuntimeParameterizedCodecDescriptor,
|
|
5
4
|
SqlRuntimeExtensionDescriptor,
|
|
6
|
-
SqlRuntimeExtensionInstance,
|
|
7
5
|
} from '@prisma-next/sql-runtime';
|
|
6
|
+
import { type as arktype } from 'arktype';
|
|
8
7
|
import { codecDefinitions } from '../core/codecs';
|
|
9
|
-
import {
|
|
8
|
+
import { VECTOR_CODEC_ID, VECTOR_MAX_DIM } from '../core/constants';
|
|
9
|
+
import { pgvectorPackMeta, pgvectorQueryOperations } from '../core/descriptor-meta';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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;
|
|
11
|
+
const vectorParamsSchema = arktype({
|
|
12
|
+
length: 'number',
|
|
13
|
+
}).narrow((params, ctx) => {
|
|
14
|
+
const { length } = params;
|
|
15
|
+
if (!Number.isInteger(length)) {
|
|
16
|
+
return ctx.mustBe('an integer');
|
|
17
|
+
}
|
|
18
|
+
if (length < 1 || length > VECTOR_MAX_DIM) {
|
|
19
|
+
return ctx.mustBe(`in the range [1, ${VECTOR_MAX_DIM}]`);
|
|
26
20
|
}
|
|
21
|
+
return true;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const parameterizedCodecDescriptors = [
|
|
25
|
+
{
|
|
26
|
+
codecId: VECTOR_CODEC_ID,
|
|
27
|
+
paramsSchema: vectorParamsSchema,
|
|
28
|
+
},
|
|
29
|
+
] as const satisfies ReadonlyArray<
|
|
30
|
+
RuntimeParameterizedCodecDescriptor<{ readonly length: number }>
|
|
31
|
+
>;
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
function createPgvectorCodecRegistry() {
|
|
34
|
+
const registry = createCodecRegistry();
|
|
35
|
+
for (const def of Object.values(codecDefinitions)) {
|
|
36
|
+
registry.register(def.codec);
|
|
30
37
|
}
|
|
38
|
+
return registry;
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
/**
|
|
34
|
-
* pgvector SQL runtime extension descriptor.
|
|
35
|
-
* Provides metadata and factory for creating runtime extension instances.
|
|
36
|
-
*/
|
|
37
41
|
const pgvectorRuntimeDescriptor: SqlRuntimeExtensionDescriptor<'postgres'> = {
|
|
38
42
|
kind: 'extension' as const,
|
|
39
43
|
id: pgvectorPackMeta.id,
|
|
40
44
|
version: pgvectorPackMeta.version,
|
|
41
45
|
familyId: 'sql' as const,
|
|
42
46
|
targetId: 'postgres' as const,
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
codecs: createPgvectorCodecRegistry,
|
|
48
|
+
queryOperations: () => pgvectorQueryOperations,
|
|
49
|
+
parameterizedCodecs: () => parameterizedCodecDescriptors,
|
|
50
|
+
create() {
|
|
51
|
+
return {
|
|
52
|
+
familyId: 'sql' as const,
|
|
53
|
+
targetId: 'postgres' as const,
|
|
54
|
+
};
|
|
45
55
|
},
|
|
46
56
|
};
|
|
47
57
|
|
package/src/types/codec-types.ts
CHANGED
|
@@ -7,4 +7,14 @@
|
|
|
7
7
|
* Runtime codec implementations are provided by the extension's codec registry.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
import type { CodecTypes as CoreCodecTypes } from '../core/codecs';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Type-level branded vector.
|
|
14
|
+
*
|
|
15
|
+
* The runtime values are plain number arrays, but parameterized column typing can
|
|
16
|
+
* carry the dimension at the type level (e.g. Vector<1536>).
|
|
17
|
+
*/
|
|
18
|
+
export type Vector<N extends number = number> = number[] & { readonly __vectorLength?: N };
|
|
19
|
+
|
|
20
|
+
export type CodecTypes = CoreCodecTypes;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { SqlQueryOperationTypes } from '@prisma-next/sql-contract/types';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Operation type definitions for pgvector extension.
|
|
3
5
|
*
|
|
@@ -5,22 +7,20 @@
|
|
|
5
7
|
* These types are imported by contract.d.ts files for compile-time type inference.
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
|
-
/**
|
|
9
|
-
* Operation types for pgvector extension.
|
|
10
|
-
* Maps typeId to operation methods.
|
|
11
|
-
*/
|
|
12
10
|
export type OperationTypes = {
|
|
13
11
|
readonly 'pg/vector@1': {
|
|
14
12
|
readonly cosineDistance: {
|
|
15
|
-
readonly args: readonly [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
readonly kind: 'builtin';
|
|
22
|
-
readonly type: 'number';
|
|
13
|
+
readonly args: readonly [{ readonly codecId: 'pg/vector@1'; readonly nullable: false }];
|
|
14
|
+
readonly returns: { readonly codecId: 'pg/float8@1'; readonly nullable: false };
|
|
15
|
+
readonly lowering: {
|
|
16
|
+
readonly targetFamily: 'sql';
|
|
17
|
+
readonly strategy: 'function';
|
|
18
|
+
readonly template: string;
|
|
23
19
|
};
|
|
20
|
+
};
|
|
21
|
+
readonly cosineSimilarity: {
|
|
22
|
+
readonly args: readonly [{ readonly codecId: 'pg/vector@1'; readonly nullable: false }];
|
|
23
|
+
readonly returns: { readonly codecId: 'pg/float8@1'; readonly nullable: false };
|
|
24
24
|
readonly lowering: {
|
|
25
25
|
readonly targetFamily: 'sql';
|
|
26
26
|
readonly strategy: 'function';
|
|
@@ -29,3 +29,21 @@ export type OperationTypes = {
|
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
|
+
|
|
33
|
+
/** Flat operation signatures for the query builder. */
|
|
34
|
+
export type QueryOperationTypes = SqlQueryOperationTypes<{
|
|
35
|
+
readonly cosineDistance: {
|
|
36
|
+
readonly args: readonly [
|
|
37
|
+
{ readonly codecId: 'pg/vector@1'; readonly nullable: boolean },
|
|
38
|
+
{ readonly codecId: 'pg/vector@1'; readonly nullable: boolean },
|
|
39
|
+
];
|
|
40
|
+
readonly returns: { readonly codecId: 'pg/float8@1'; readonly nullable: false };
|
|
41
|
+
};
|
|
42
|
+
readonly cosineSimilarity: {
|
|
43
|
+
readonly args: readonly [
|
|
44
|
+
{ readonly codecId: 'pg/vector@1'; readonly nullable: boolean },
|
|
45
|
+
{ readonly codecId: 'pg/vector@1'; readonly nullable: boolean },
|
|
46
|
+
];
|
|
47
|
+
readonly returns: { readonly codecId: 'pg/float8@1'; readonly nullable: false };
|
|
48
|
+
};
|
|
49
|
+
}>;
|
package/dist/chunk-OI5XEHIN.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// src/core/descriptor-meta.ts
|
|
2
|
-
var pgvectorTypeId = "pg/vector@1";
|
|
3
|
-
var cosineLowering = {
|
|
4
|
-
targetFamily: "sql",
|
|
5
|
-
strategy: "function",
|
|
6
|
-
template: "1 - ({{self}} <=> {{arg0}})"
|
|
7
|
-
};
|
|
8
|
-
var cosineDistanceOperation = Object.freeze({
|
|
9
|
-
method: "cosineDistance",
|
|
10
|
-
args: [{ kind: "param" }],
|
|
11
|
-
returns: { kind: "builtin", type: "number" },
|
|
12
|
-
lowering: cosineLowering
|
|
13
|
-
});
|
|
14
|
-
var pgvectorPackMeta = {
|
|
15
|
-
kind: "extension",
|
|
16
|
-
id: "pgvector",
|
|
17
|
-
familyId: "sql",
|
|
18
|
-
targetId: "postgres",
|
|
19
|
-
version: "0.0.1",
|
|
20
|
-
capabilities: {
|
|
21
|
-
postgres: {
|
|
22
|
-
"pgvector/cosine": true
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
types: {
|
|
26
|
-
codecTypes: {
|
|
27
|
-
import: {
|
|
28
|
-
package: "@prisma-next/extension-pgvector/codec-types",
|
|
29
|
-
named: "CodecTypes",
|
|
30
|
-
alias: "PgVectorTypes"
|
|
31
|
-
},
|
|
32
|
-
// Parameterized codec renderers for type emission.
|
|
33
|
-
// The renderer template produces precise TypeScript types like Vector<1536>
|
|
34
|
-
// when columns have typeParams with a `length` property.
|
|
35
|
-
// Note: The Vector<N> type import is deferred to Phase 6.
|
|
36
|
-
parameterized: {
|
|
37
|
-
[pgvectorTypeId]: "Vector<{{length}}>"
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
operationTypes: {
|
|
41
|
-
import: {
|
|
42
|
-
package: "@prisma-next/extension-pgvector/operation-types",
|
|
43
|
-
named: "OperationTypes",
|
|
44
|
-
alias: "PgVectorOperationTypes"
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
storage: [
|
|
48
|
-
{ typeId: pgvectorTypeId, familyId: "sql", targetId: "postgres", nativeType: "vector" }
|
|
49
|
-
]
|
|
50
|
-
},
|
|
51
|
-
operations: [
|
|
52
|
-
{
|
|
53
|
-
for: pgvectorTypeId,
|
|
54
|
-
...cosineDistanceOperation
|
|
55
|
-
}
|
|
56
|
-
]
|
|
57
|
-
};
|
|
58
|
-
var pgvectorRuntimeOperation = {
|
|
59
|
-
forTypeId: pgvectorTypeId,
|
|
60
|
-
...cosineDistanceOperation
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export {
|
|
64
|
-
pgvectorPackMeta,
|
|
65
|
-
pgvectorRuntimeOperation
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=chunk-OI5XEHIN.js.map
|
|
@@ -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 // Parameterized codec renderers for type emission.\n // The renderer template produces precise TypeScript types like Vector<1536>\n // when columns have typeParams with a `length` property.\n // Note: The Vector<N> type import is deferred to Phase 6.\n parameterized: {\n [pgvectorTypeId]: 'Vector<{{length}}>',\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;AAAA;AAAA;AAAA;AAAA,MAKA,eAAe;AAAA,QACb,CAAC,cAAc,GAAG;AAAA,MACpB;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":[]}
|
package/dist/core/codecs.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,56 +0,0 @@
|
|
|
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
|
-
readonly parameterized: {
|
|
21
|
-
readonly "pg/vector@1": "Vector<{{length}}>";
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
readonly operationTypes: {
|
|
25
|
-
readonly import: {
|
|
26
|
-
readonly package: "@prisma-next/extension-pgvector/operation-types";
|
|
27
|
-
readonly named: "OperationTypes";
|
|
28
|
-
readonly alias: "PgVectorOperationTypes";
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
readonly storage: readonly [{
|
|
32
|
-
readonly typeId: "pg/vector@1";
|
|
33
|
-
readonly familyId: "sql";
|
|
34
|
-
readonly targetId: "postgres";
|
|
35
|
-
readonly nativeType: "vector";
|
|
36
|
-
}];
|
|
37
|
-
};
|
|
38
|
-
readonly operations: readonly [{
|
|
39
|
-
readonly method: "cosineDistance";
|
|
40
|
-
readonly args: readonly [{
|
|
41
|
-
readonly kind: "param";
|
|
42
|
-
}];
|
|
43
|
-
readonly returns: {
|
|
44
|
-
readonly kind: "builtin";
|
|
45
|
-
readonly type: "number";
|
|
46
|
-
};
|
|
47
|
-
readonly lowering: {
|
|
48
|
-
readonly targetFamily: "sql";
|
|
49
|
-
readonly strategy: "function";
|
|
50
|
-
readonly template: "1 - ({{self}} <=> {{arg0}})";
|
|
51
|
-
};
|
|
52
|
-
readonly for: "pg/vector@1";
|
|
53
|
-
}];
|
|
54
|
-
};
|
|
55
|
-
export declare const pgvectorRuntimeOperation: SqlOperationSignature;
|
|
56
|
-
//# sourceMappingURL=descriptor-meta.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C2B,CAAC;AAEzD,eAAO,MAAM,wBAAwB,EAAE,qBAGtC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=codec-types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
export declare const vectorColumn: {
|
|
8
|
-
readonly codecId: "pg/vector@1";
|
|
9
|
-
readonly nativeType: "vector";
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=column-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/column-types.ts"],"sourcesContent":["/**\n * Column type descriptors for pgvector extension.\n *\n * These descriptors provide both codecId and nativeType for use in contract authoring.\n * They are derived from the same source of truth as codec definitions and manifests.\n */\n\nimport type { ColumnTypeDescriptor } from '@prisma-next/contract-authoring';\n\nexport const vectorColumn = {\n codecId: 'pg/vector@1',\n nativeType: 'vector',\n} as const satisfies ColumnTypeDescriptor;\n"],"mappings":";AASO,IAAM,eAAe;AAAA,EAC1B,SAAS;AAAA,EACT,YAAY;AACd;","names":[]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { SqlControlExtensionDescriptor } from '@prisma-next/family-sql/control';
|
|
2
|
-
/**
|
|
3
|
-
* pgvector extension descriptor for CLI config.
|
|
4
|
-
* Declares database dependencies for the 'vector' Postgres extension.
|
|
5
|
-
*/
|
|
6
|
-
declare const pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'>;
|
|
7
|
-
export { pgvectorExtensionDescriptor };
|
|
8
|
-
export default pgvectorExtensionDescriptor;
|
|
9
|
-
//# sourceMappingURL=control.d.ts.map
|