@prisma-next/extension-pgvector 0.5.0-dev.9 → 0.6.0-dev.1
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/README.md +23 -6
- package/dist/codec-types-CQubO6uQ.d.mts +63 -0
- package/dist/codec-types-CQubO6uQ.d.mts.map +1 -0
- package/dist/codec-types.d.mts +1 -1
- package/dist/codec-types.mjs +1 -1
- package/dist/column-types.d.mts +2 -5
- package/dist/column-types.d.mts.map +1 -1
- package/dist/column-types.mjs +4 -7
- package/dist/column-types.mjs.map +1 -1
- package/dist/{constants-Co5golCK.mjs → constants-DX-00vYk.mjs} +2 -2
- package/dist/{constants-Co5golCK.mjs.map → constants-DX-00vYk.mjs.map} +1 -1
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +163 -30
- package/dist/control.mjs.map +1 -1
- package/dist/descriptor-meta-DEgJjLLi.mjs +178 -0
- package/dist/descriptor-meta-DEgJjLLi.mjs.map +1 -0
- package/dist/operation-types-Bd-jkNN3.d.mts +38 -0
- package/dist/operation-types-Bd-jkNN3.d.mts.map +1 -0
- package/dist/operation-types.d.mts +2 -76
- package/dist/operation-types.mjs +1 -1
- package/dist/pack.d.mts +3 -10
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +2 -3
- package/dist/runtime.d.mts +10 -1
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +6 -25
- package/dist/runtime.mjs.map +1 -1
- package/package.json +32 -17
- package/src/contract.d.ts +91 -0
- package/src/contract.json +40 -0
- package/src/contract.ts +67 -0
- package/src/core/codecs.ts +127 -59
- package/src/core/contract-space-constants.ts +30 -0
- package/src/core/descriptor-meta.ts +40 -36
- package/src/core/registry.ts +11 -0
- package/src/exports/column-types.ts +3 -6
- package/src/exports/control.ts +56 -35
- package/src/exports/operation-types.ts +1 -1
- package/src/exports/runtime.ts +11 -41
- package/src/types/operation-types.ts +19 -36
- package/dist/codec-types-BifaP625.d.mts +0 -27
- package/dist/codec-types-BifaP625.d.mts.map +0 -1
- package/dist/descriptor-meta-BQbvJJxu.mjs +0 -148
- package/dist/descriptor-meta-BQbvJJxu.mjs.map +0 -1
- package/dist/operation-types.d.mts.map +0 -1
package/src/exports/runtime.ts
CHANGED
|
@@ -1,42 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
RuntimeParameterizedCodecDescriptor,
|
|
4
|
-
SqlRuntimeExtensionDescriptor,
|
|
5
|
-
} from '@prisma-next/sql-runtime';
|
|
6
|
-
import { type as arktype } from 'arktype';
|
|
7
|
-
import { codecDefinitions } from '../core/codecs';
|
|
8
|
-
import { VECTOR_CODEC_ID, VECTOR_MAX_DIM } from '../core/constants';
|
|
1
|
+
import type { SqlRuntimeExtensionDescriptor } from '@prisma-next/sql-runtime';
|
|
9
2
|
import { pgvectorPackMeta, pgvectorQueryOperations } from '../core/descriptor-meta';
|
|
10
|
-
|
|
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}]`);
|
|
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
|
-
>;
|
|
32
|
-
|
|
33
|
-
function createPgvectorCodecRegistry() {
|
|
34
|
-
const registry = createCodecRegistry();
|
|
35
|
-
for (const def of Object.values(codecDefinitions)) {
|
|
36
|
-
registry.register(def.codec);
|
|
37
|
-
}
|
|
38
|
-
return registry;
|
|
39
|
-
}
|
|
3
|
+
import { pgvectorCodecRegistry } from '../core/registry';
|
|
40
4
|
|
|
41
5
|
const pgvectorRuntimeDescriptor: SqlRuntimeExtensionDescriptor<'postgres'> = {
|
|
42
6
|
kind: 'extension' as const,
|
|
@@ -44,9 +8,14 @@ const pgvectorRuntimeDescriptor: SqlRuntimeExtensionDescriptor<'postgres'> = {
|
|
|
44
8
|
version: pgvectorPackMeta.version,
|
|
45
9
|
familyId: 'sql' as const,
|
|
46
10
|
targetId: 'postgres' as const,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
11
|
+
// Expose the unified descriptor list so `extractCodecLookup` reads `targetTypes` / `meta` / `renderOutputType` directly off the descriptors and materializes the representative `Codec` for the SQL renderer's cast-policy lookup.
|
|
12
|
+
types: {
|
|
13
|
+
codecTypes: {
|
|
14
|
+
codecDescriptors: Array.from(pgvectorCodecRegistry.values()),
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
codecs: () => Array.from(pgvectorCodecRegistry.values()),
|
|
18
|
+
queryOperations: () => pgvectorQueryOperations(),
|
|
50
19
|
create() {
|
|
51
20
|
return {
|
|
52
21
|
familyId: 'sql' as const,
|
|
@@ -55,4 +24,5 @@ const pgvectorRuntimeDescriptor: SqlRuntimeExtensionDescriptor<'postgres'> = {
|
|
|
55
24
|
},
|
|
56
25
|
};
|
|
57
26
|
|
|
27
|
+
export { pgvectorCodecRegistry };
|
|
58
28
|
export default pgvectorRuntimeDescriptor;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { SqlQueryOperationTypes } from '@prisma-next/sql-contract/types';
|
|
2
|
+
import type { CodecExpression, Expression } from '@prisma-next/sql-relational-core/expression';
|
|
3
|
+
|
|
4
|
+
type CodecTypesBase = Record<string, { readonly input: unknown; readonly output: unknown }>;
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* Operation type definitions for pgvector extension.
|
|
@@ -7,43 +10,23 @@ import type { SqlQueryOperationTypes } from '@prisma-next/sql-contract/types';
|
|
|
7
10
|
* These types are imported by contract.d.ts files for compile-time type inference.
|
|
8
11
|
*/
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
/** Flat operation signatures for the query builder. */
|
|
14
|
+
export type QueryOperationTypes<CT extends CodecTypesBase> = SqlQueryOperationTypes<
|
|
15
|
+
CT,
|
|
16
|
+
{
|
|
12
17
|
readonly cosineDistance: {
|
|
13
|
-
readonly
|
|
14
|
-
readonly
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
readonly template: string;
|
|
19
|
-
};
|
|
18
|
+
readonly self: { readonly codecId: 'pg/vector@1' };
|
|
19
|
+
readonly impl: (
|
|
20
|
+
self: CodecExpression<'pg/vector@1', boolean, CT>,
|
|
21
|
+
other: CodecExpression<'pg/vector@1', boolean, CT>,
|
|
22
|
+
) => Expression<{ codecId: 'pg/float8@1'; nullable: false }>;
|
|
20
23
|
};
|
|
21
24
|
readonly cosineSimilarity: {
|
|
22
|
-
readonly
|
|
23
|
-
readonly
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
readonly template: string;
|
|
28
|
-
};
|
|
25
|
+
readonly self: { readonly codecId: 'pg/vector@1' };
|
|
26
|
+
readonly impl: (
|
|
27
|
+
self: CodecExpression<'pg/vector@1', boolean, CT>,
|
|
28
|
+
other: CodecExpression<'pg/vector@1', boolean, CT>,
|
|
29
|
+
) => Expression<{ codecId: 'pg/float8@1'; nullable: false }>;
|
|
29
30
|
};
|
|
30
|
-
}
|
|
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
|
-
}>;
|
|
31
|
+
}
|
|
32
|
+
>;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as _prisma_next_sql_relational_core_ast0 from "@prisma-next/sql-relational-core/ast";
|
|
2
|
-
|
|
3
|
-
//#region src/core/codecs.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Vector codec implementation for pgvector extension.
|
|
7
|
-
*
|
|
8
|
-
* Provides encoding/decoding for the `vector` PostgreSQL type.
|
|
9
|
-
* Wire format is a string like `[1,2,3]` (PostgreSQL vector text format).
|
|
10
|
-
*/
|
|
11
|
-
declare const codecs: _prisma_next_sql_relational_core_ast0.CodecDefBuilder<{} & Record<"vector", _prisma_next_sql_relational_core_ast0.Codec<"pg/vector@1", readonly ["equality"], string, number[], Record<string, unknown>, unknown>>>;
|
|
12
|
-
type CodecTypes$1 = typeof codecs.CodecTypes;
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/types/codec-types.d.ts
|
|
15
|
-
/**
|
|
16
|
-
* Type-level branded vector.
|
|
17
|
-
*
|
|
18
|
-
* The runtime values are plain number arrays, but parameterized column typing can
|
|
19
|
-
* carry the dimension at the type level (e.g. Vector<1536>).
|
|
20
|
-
*/
|
|
21
|
-
type Vector<N extends number = number> = number[] & {
|
|
22
|
-
readonly __vectorLength?: N;
|
|
23
|
-
};
|
|
24
|
-
type CodecTypes = CodecTypes$1;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { Vector as n, CodecTypes as t };
|
|
27
|
-
//# sourceMappingURL=codec-types-BifaP625.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codec-types-BifaP625.d.mts","names":[],"sources":["../src/core/codecs.ts","../src/types/codec-types.ts"],"sourcesContent":[],"mappings":";;;;;;;AAqEY;;;cAAN,MAAM,EAAA,qCAAA,CAAA,eAAA,CAAA,CAAA,CAAA,GAAA,MAAA,CAAA,QAAA,EAAA,qCAAA,CAAA,KAAA,CAAA,aAAA,EAAA,SAAA,CAAA,UAAA,CAAA,EAAA,MAAA,EAAA,MAAA,EAAA,EAAA,MAAA,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,OAAA,CAAA,CAAA,CAAA;KAOA,YAAA,UAAoB,MAAA,CAAO;;;AAAvC;;;;AC3DA;AAEA;KAFY;4BAA2E;;KAE3E,UAAA,GAAa"}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { n as VECTOR_MAX_DIM } from "./constants-Co5golCK.mjs";
|
|
2
|
-
import { codec, defineCodecs } from "@prisma-next/sql-relational-core/ast";
|
|
3
|
-
|
|
4
|
-
//#region src/core/authoring.ts
|
|
5
|
-
const pgvectorAuthoringTypes = { pgvector: { Vector: {
|
|
6
|
-
kind: "typeConstructor",
|
|
7
|
-
args: [{
|
|
8
|
-
kind: "number",
|
|
9
|
-
name: "length",
|
|
10
|
-
integer: true,
|
|
11
|
-
minimum: 1,
|
|
12
|
-
maximum: VECTOR_MAX_DIM
|
|
13
|
-
}],
|
|
14
|
-
output: {
|
|
15
|
-
codecId: "pg/vector@1",
|
|
16
|
-
nativeType: "vector",
|
|
17
|
-
typeParams: { length: {
|
|
18
|
-
kind: "arg",
|
|
19
|
-
index: 0
|
|
20
|
-
} }
|
|
21
|
-
}
|
|
22
|
-
} } };
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region src/core/codecs.ts
|
|
26
|
-
/**
|
|
27
|
-
* Vector codec implementation for pgvector extension.
|
|
28
|
-
*
|
|
29
|
-
* Provides encoding/decoding for the `vector` PostgreSQL type.
|
|
30
|
-
* Wire format is a string like `[1,2,3]` (PostgreSQL vector text format).
|
|
31
|
-
*/
|
|
32
|
-
const pgVectorCodec = codec({
|
|
33
|
-
typeId: "pg/vector@1",
|
|
34
|
-
targetTypes: ["vector"],
|
|
35
|
-
traits: ["equality"],
|
|
36
|
-
renderOutputType: (typeParams) => {
|
|
37
|
-
const length = typeParams["length"];
|
|
38
|
-
if (length === void 0) return void 0;
|
|
39
|
-
if (typeof length !== "number" || !Number.isFinite(length) || !Number.isInteger(length)) throw new Error(`renderOutputType: expected positive integer "length" in typeParams for Vector, got ${String(length)}`);
|
|
40
|
-
return `Vector<${length}>`;
|
|
41
|
-
},
|
|
42
|
-
encode: (value) => {
|
|
43
|
-
if (!Array.isArray(value)) throw new Error("Vector value must be an array of numbers");
|
|
44
|
-
if (!value.every((v) => typeof v === "number")) throw new Error("Vector value must contain only numbers");
|
|
45
|
-
return `[${value.join(",")}]`;
|
|
46
|
-
},
|
|
47
|
-
decode: (wire) => {
|
|
48
|
-
if (typeof wire !== "string") throw new Error("Vector wire value must be a string");
|
|
49
|
-
if (!wire.startsWith("[") || !wire.endsWith("]")) throw new Error(`Invalid vector format: expected "[...]", got "${wire}"`);
|
|
50
|
-
const content = wire.slice(1, -1).trim();
|
|
51
|
-
if (content === "") return [];
|
|
52
|
-
return content.split(",").map((v) => {
|
|
53
|
-
const num = Number.parseFloat(v.trim());
|
|
54
|
-
if (Number.isNaN(num)) throw new Error(`Invalid vector value: "${v}" is not a number`);
|
|
55
|
-
return num;
|
|
56
|
-
});
|
|
57
|
-
},
|
|
58
|
-
meta: { db: { sql: { postgres: { nativeType: "vector" } } } }
|
|
59
|
-
});
|
|
60
|
-
const codecs = defineCodecs().add("vector", pgVectorCodec);
|
|
61
|
-
const codecDefinitions = codecs.codecDefinitions;
|
|
62
|
-
const dataTypes = codecs.dataTypes;
|
|
63
|
-
|
|
64
|
-
//#endregion
|
|
65
|
-
//#region src/core/descriptor-meta.ts
|
|
66
|
-
const pgvectorTypeId = "pg/vector@1";
|
|
67
|
-
const pgvectorQueryOperations = [{
|
|
68
|
-
method: "cosineDistance",
|
|
69
|
-
args: [{
|
|
70
|
-
codecId: pgvectorTypeId,
|
|
71
|
-
nullable: false
|
|
72
|
-
}, {
|
|
73
|
-
codecId: pgvectorTypeId,
|
|
74
|
-
nullable: false
|
|
75
|
-
}],
|
|
76
|
-
returns: {
|
|
77
|
-
codecId: "pg/float8@1",
|
|
78
|
-
nullable: false
|
|
79
|
-
},
|
|
80
|
-
lowering: {
|
|
81
|
-
targetFamily: "sql",
|
|
82
|
-
strategy: "function",
|
|
83
|
-
template: "{{self}} <=> {{arg0}}"
|
|
84
|
-
}
|
|
85
|
-
}, {
|
|
86
|
-
method: "cosineSimilarity",
|
|
87
|
-
args: [{
|
|
88
|
-
codecId: pgvectorTypeId,
|
|
89
|
-
nullable: false
|
|
90
|
-
}, {
|
|
91
|
-
codecId: pgvectorTypeId,
|
|
92
|
-
nullable: false
|
|
93
|
-
}],
|
|
94
|
-
returns: {
|
|
95
|
-
codecId: "pg/float8@1",
|
|
96
|
-
nullable: false
|
|
97
|
-
},
|
|
98
|
-
lowering: {
|
|
99
|
-
targetFamily: "sql",
|
|
100
|
-
strategy: "function",
|
|
101
|
-
template: "1 - ({{self}} <=> {{arg0}})"
|
|
102
|
-
}
|
|
103
|
-
}];
|
|
104
|
-
const pgvectorPackMetaBase = {
|
|
105
|
-
kind: "extension",
|
|
106
|
-
id: "pgvector",
|
|
107
|
-
familyId: "sql",
|
|
108
|
-
targetId: "postgres",
|
|
109
|
-
version: "0.0.1",
|
|
110
|
-
capabilities: { postgres: { "pgvector.cosine": true } },
|
|
111
|
-
authoring: { type: pgvectorAuthoringTypes },
|
|
112
|
-
types: {
|
|
113
|
-
codecTypes: {
|
|
114
|
-
codecInstances: Object.values(codecDefinitions).map((def) => def.codec),
|
|
115
|
-
import: {
|
|
116
|
-
package: "@prisma-next/extension-pgvector/codec-types",
|
|
117
|
-
named: "CodecTypes",
|
|
118
|
-
alias: "PgVectorTypes"
|
|
119
|
-
},
|
|
120
|
-
typeImports: [{
|
|
121
|
-
package: "@prisma-next/extension-pgvector/codec-types",
|
|
122
|
-
named: "Vector",
|
|
123
|
-
alias: "Vector"
|
|
124
|
-
}]
|
|
125
|
-
},
|
|
126
|
-
operationTypes: { import: {
|
|
127
|
-
package: "@prisma-next/extension-pgvector/operation-types",
|
|
128
|
-
named: "OperationTypes",
|
|
129
|
-
alias: "PgVectorOperationTypes"
|
|
130
|
-
} },
|
|
131
|
-
queryOperationTypes: { import: {
|
|
132
|
-
package: "@prisma-next/extension-pgvector/operation-types",
|
|
133
|
-
named: "QueryOperationTypes",
|
|
134
|
-
alias: "PgVectorQueryOperationTypes"
|
|
135
|
-
} },
|
|
136
|
-
storage: [{
|
|
137
|
-
typeId: pgvectorTypeId,
|
|
138
|
-
familyId: "sql",
|
|
139
|
-
targetId: "postgres",
|
|
140
|
-
nativeType: "vector"
|
|
141
|
-
}]
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
const pgvectorPackMeta = pgvectorPackMetaBase;
|
|
145
|
-
|
|
146
|
-
//#endregion
|
|
147
|
-
export { pgvectorQueryOperations as n, codecDefinitions as r, pgvectorPackMeta as t };
|
|
148
|
-
//# sourceMappingURL=descriptor-meta-BQbvJJxu.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor-meta-BQbvJJxu.mjs","names":["pgvectorQueryOperations: readonly SqlOperationDescriptor[]","pgvectorPackMeta: typeof pgvectorPackMetaBase & {\n readonly __codecTypes?: CodecTypes;\n}"],"sources":["../src/core/authoring.ts","../src/core/codecs.ts","../src/core/descriptor-meta.ts"],"sourcesContent":["import type { AuthoringTypeNamespace } from '@prisma-next/framework-components/authoring';\nimport { VECTOR_MAX_DIM } from './constants';\n\nexport const pgvectorAuthoringTypes = {\n pgvector: {\n Vector: {\n kind: 'typeConstructor',\n args: [\n { kind: 'number', name: 'length', integer: true, minimum: 1, maximum: VECTOR_MAX_DIM },\n ],\n output: {\n codecId: 'pg/vector@1',\n nativeType: 'vector',\n typeParams: {\n length: { kind: 'arg', index: 0 },\n },\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n","/**\n * Vector codec implementation for pgvector extension.\n *\n * Provides encoding/decoding for the `vector` PostgreSQL type.\n * Wire format is a string like `[1,2,3]` (PostgreSQL vector text format).\n */\n\nimport { codec, defineCodecs } from '@prisma-next/sql-relational-core/ast';\n\nconst pgVectorCodec = codec({\n typeId: 'pg/vector@1',\n targetTypes: ['vector'],\n traits: ['equality'],\n renderOutputType: (typeParams) => {\n const length = typeParams['length'];\n if (length === undefined) return undefined;\n if (typeof length !== 'number' || !Number.isFinite(length) || !Number.isInteger(length)) {\n throw new Error(\n `renderOutputType: expected positive integer \"length\" in typeParams for Vector, got ${String(length)}`,\n );\n }\n return `Vector<${length}>`;\n },\n encode: (value: number[]): string => {\n // Validate that value is an array of numbers\n if (!Array.isArray(value)) {\n throw new Error('Vector value must be an array of numbers');\n }\n if (!value.every((v) => typeof v === 'number')) {\n throw new Error('Vector value must contain only numbers');\n }\n // Format as PostgreSQL vector text format: [1,2,3]\n // PostgreSQL's pg library requires the vector format string\n return `[${value.join(',')}]`;\n },\n decode: (wire: string): number[] => {\n // Handle string format from PostgreSQL: [1,2,3]\n if (typeof wire !== 'string') {\n throw new Error('Vector wire value must be a string');\n }\n // Parse PostgreSQL vector format: [1,2,3]\n if (!wire.startsWith('[') || !wire.endsWith(']')) {\n throw new Error(`Invalid vector format: expected \"[...]\", got \"${wire}\"`);\n }\n const content = wire.slice(1, -1).trim();\n if (content === '') {\n return [];\n }\n const values = content.split(',').map((v) => {\n const num = Number.parseFloat(v.trim());\n if (Number.isNaN(num)) {\n throw new Error(`Invalid vector value: \"${v}\" is not a number`);\n }\n return num;\n });\n return values;\n },\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'vector',\n },\n },\n },\n },\n});\n\n// Build codec definitions using the builder DSL\nconst codecs = defineCodecs().add('vector', pgVectorCodec);\n\n// Export derived structures directly from codecs builder\nexport const codecDefinitions = codecs.codecDefinitions;\nexport const dataTypes = codecs.dataTypes;\n\n// Export types derived from codecs builder\nexport type CodecTypes = typeof codecs.CodecTypes;\n","import type { SqlOperationDescriptor } from '@prisma-next/sql-operations';\nimport type { CodecTypes } from '../types/codec-types';\nimport { pgvectorAuthoringTypes } from './authoring';\nimport { codecDefinitions } from './codecs';\n\nconst pgvectorTypeId = 'pg/vector@1' as const;\n\nexport const pgvectorQueryOperations: readonly SqlOperationDescriptor[] = [\n {\n method: 'cosineDistance',\n args: [\n { codecId: pgvectorTypeId, nullable: false },\n { codecId: pgvectorTypeId, nullable: false },\n ],\n returns: { codecId: 'pg/float8@1', nullable: false },\n lowering: {\n targetFamily: 'sql',\n strategy: 'function',\n template: '{{self}} <=> {{arg0}}',\n },\n },\n {\n method: 'cosineSimilarity',\n args: [\n { codecId: pgvectorTypeId, nullable: false },\n { codecId: pgvectorTypeId, nullable: false },\n ],\n returns: { codecId: 'pg/float8@1', nullable: false },\n lowering: {\n targetFamily: 'sql',\n strategy: 'function',\n template: '1 - ({{self}} <=> {{arg0}})',\n },\n },\n];\n\nconst pgvectorPackMetaBase = {\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 authoring: {\n type: pgvectorAuthoringTypes,\n },\n types: {\n codecTypes: {\n codecInstances: Object.values(codecDefinitions).map((def) => def.codec),\n import: {\n package: '@prisma-next/extension-pgvector/codec-types',\n named: 'CodecTypes',\n alias: 'PgVectorTypes',\n },\n typeImports: [\n {\n package: '@prisma-next/extension-pgvector/codec-types',\n named: 'Vector',\n alias: 'Vector',\n },\n ],\n },\n operationTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/operation-types',\n named: 'OperationTypes',\n alias: 'PgVectorOperationTypes',\n },\n },\n queryOperationTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/operation-types',\n named: 'QueryOperationTypes',\n alias: 'PgVectorQueryOperationTypes',\n },\n },\n storage: [\n { typeId: pgvectorTypeId, familyId: 'sql', targetId: 'postgres', nativeType: 'vector' },\n ],\n },\n} as const;\n\nexport const pgvectorPackMeta: typeof pgvectorPackMetaBase & {\n readonly __codecTypes?: CodecTypes;\n} = pgvectorPackMetaBase;\n"],"mappings":";;;;AAGA,MAAa,yBAAyB,EACpC,UAAU,EACR,QAAQ;CACN,MAAM;CACN,MAAM,CACJ;EAAE,MAAM;EAAU,MAAM;EAAU,SAAS;EAAM,SAAS;EAAG,SAAS;EAAgB,CACvF;CACD,QAAQ;EACN,SAAS;EACT,YAAY;EACZ,YAAY,EACV,QAAQ;GAAE,MAAM;GAAO,OAAO;GAAG,EAClC;EACF;CACF,EACF,EACF;;;;;;;;;;ACVD,MAAM,gBAAgB,MAAM;CAC1B,QAAQ;CACR,aAAa,CAAC,SAAS;CACvB,QAAQ,CAAC,WAAW;CACpB,mBAAmB,eAAe;EAChC,MAAM,SAAS,WAAW;AAC1B,MAAI,WAAW,OAAW,QAAO;AACjC,MAAI,OAAO,WAAW,YAAY,CAAC,OAAO,SAAS,OAAO,IAAI,CAAC,OAAO,UAAU,OAAO,CACrF,OAAM,IAAI,MACR,sFAAsF,OAAO,OAAO,GACrG;AAEH,SAAO,UAAU,OAAO;;CAE1B,SAAS,UAA4B;AAEnC,MAAI,CAAC,MAAM,QAAQ,MAAM,CACvB,OAAM,IAAI,MAAM,2CAA2C;AAE7D,MAAI,CAAC,MAAM,OAAO,MAAM,OAAO,MAAM,SAAS,CAC5C,OAAM,IAAI,MAAM,yCAAyC;AAI3D,SAAO,IAAI,MAAM,KAAK,IAAI,CAAC;;CAE7B,SAAS,SAA2B;AAElC,MAAI,OAAO,SAAS,SAClB,OAAM,IAAI,MAAM,qCAAqC;AAGvD,MAAI,CAAC,KAAK,WAAW,IAAI,IAAI,CAAC,KAAK,SAAS,IAAI,CAC9C,OAAM,IAAI,MAAM,iDAAiD,KAAK,GAAG;EAE3E,MAAM,UAAU,KAAK,MAAM,GAAG,GAAG,CAAC,MAAM;AACxC,MAAI,YAAY,GACd,QAAO,EAAE;AASX,SAPe,QAAQ,MAAM,IAAI,CAAC,KAAK,MAAM;GAC3C,MAAM,MAAM,OAAO,WAAW,EAAE,MAAM,CAAC;AACvC,OAAI,OAAO,MAAM,IAAI,CACnB,OAAM,IAAI,MAAM,0BAA0B,EAAE,mBAAmB;AAEjE,UAAO;IACP;;CAGJ,MAAM,EACJ,IAAI,EACF,KAAK,EACH,UAAU,EACR,YAAY,UACb,EACF,EACF,EACF;CACF,CAAC;AAGF,MAAM,SAAS,cAAc,CAAC,IAAI,UAAU,cAAc;AAG1D,MAAa,mBAAmB,OAAO;AACvC,MAAa,YAAY,OAAO;;;;ACpEhC,MAAM,iBAAiB;AAEvB,MAAaA,0BAA6D,CACxE;CACE,QAAQ;CACR,MAAM,CACJ;EAAE,SAAS;EAAgB,UAAU;EAAO,EAC5C;EAAE,SAAS;EAAgB,UAAU;EAAO,CAC7C;CACD,SAAS;EAAE,SAAS;EAAe,UAAU;EAAO;CACpD,UAAU;EACR,cAAc;EACd,UAAU;EACV,UAAU;EACX;CACF,EACD;CACE,QAAQ;CACR,MAAM,CACJ;EAAE,SAAS;EAAgB,UAAU;EAAO,EAC5C;EAAE,SAAS;EAAgB,UAAU;EAAO,CAC7C;CACD,SAAS;EAAE,SAAS;EAAe,UAAU;EAAO;CACpD,UAAU;EACR,cAAc;EACd,UAAU;EACV,UAAU;EACX;CACF,CACF;AAED,MAAM,uBAAuB;CAC3B,MAAM;CACN,IAAI;CACJ,UAAU;CACV,UAAU;CACV,SAAS;CACT,cAAc,EACZ,UAAU,EACR,mBAAmB,MACpB,EACF;CACD,WAAW,EACT,MAAM,wBACP;CACD,OAAO;EACL,YAAY;GACV,gBAAgB,OAAO,OAAO,iBAAiB,CAAC,KAAK,QAAQ,IAAI,MAAM;GACvE,QAAQ;IACN,SAAS;IACT,OAAO;IACP,OAAO;IACR;GACD,aAAa,CACX;IACE,SAAS;IACT,OAAO;IACP,OAAO;IACR,CACF;GACF;EACD,gBAAgB,EACd,QAAQ;GACN,SAAS;GACT,OAAO;GACP,OAAO;GACR,EACF;EACD,qBAAqB,EACnB,QAAQ;GACN,SAAS;GACT,OAAO;GACP,OAAO;GACR,EACF;EACD,SAAS,CACP;GAAE,QAAQ;GAAgB,UAAU;GAAO,UAAU;GAAY,YAAY;GAAU,CACxF;EACF;CACF;AAED,MAAaC,mBAET"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"operation-types.d.mts","names":[],"sources":["../src/types/operation-types.ts"],"sourcesContent":[],"mappings":";;;;;;AASA;AAwBA;;;KAxBY,cAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwBA,mBAAA,GAAsB"}
|