@prisma-next/extension-pgvector 0.5.0-dev.82 → 0.5.0-dev.84
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/control.mjs +1 -1
- package/dist/{descriptor-meta-CBnWOxms.mjs → descriptor-meta-DEgJjLLi.mjs} +40 -44
- package/dist/{descriptor-meta-CBnWOxms.mjs.map → descriptor-meta-DEgJjLLi.mjs.map} +1 -1
- 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 -52
- package/dist/pack.d.mts +1 -7
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/runtime.mjs +1 -1
- package/package.json +15 -15
- package/src/core/descriptor-meta.ts +9 -32
- package/src/exports/operation-types.ts +1 -1
- package/src/types/operation-types.ts +0 -11
- package/dist/operation-types.d.mts.map +0 -1
package/dist/control.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as VECTOR_CODEC_ID } from "./constants-DX-00vYk.mjs";
|
|
2
|
-
import { n as pgvectorQueryOperations, t as pgvectorPackMeta } from "./descriptor-meta-
|
|
2
|
+
import { n as pgvectorQueryOperations, t as pgvectorPackMeta } from "./descriptor-meta-DEgJjLLi.mjs";
|
|
3
3
|
import { computeStorageHash } from "@prisma-next/contract/hashing";
|
|
4
4
|
import { coreHash, profileHash } from "@prisma-next/contract/types";
|
|
5
5
|
import { computeMigrationHash } from "@prisma-next/migration-tools/hash";
|
|
@@ -96,45 +96,46 @@ const pgvectorCodecRegistry = buildCodecDescriptorRegistry(Object.values(codecDe
|
|
|
96
96
|
//#region src/core/descriptor-meta.ts
|
|
97
97
|
const pgvectorTypeId = "pg/vector@1";
|
|
98
98
|
function pgvectorQueryOperations() {
|
|
99
|
-
return
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
99
|
+
return {
|
|
100
|
+
cosineDistance: {
|
|
101
|
+
self: { codecId: pgvectorTypeId },
|
|
102
|
+
impl: (self, other) => {
|
|
103
|
+
const selfRefs = refsOf(self);
|
|
104
|
+
return buildOperation({
|
|
105
|
+
method: "cosineDistance",
|
|
106
|
+
args: [toExpr(self, pgvectorTypeId, selfRefs), toExpr(other, pgvectorTypeId, selfRefs)],
|
|
107
|
+
returns: {
|
|
108
|
+
codecId: "pg/float8@1",
|
|
109
|
+
nullable: false
|
|
110
|
+
},
|
|
111
|
+
lowering: {
|
|
112
|
+
targetFamily: "sql",
|
|
113
|
+
strategy: "function",
|
|
114
|
+
template: "{{self}} <=> {{arg0}}"
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
cosineSimilarity: {
|
|
120
|
+
self: { codecId: pgvectorTypeId },
|
|
121
|
+
impl: (self, other) => {
|
|
122
|
+
const selfRefs = refsOf(self);
|
|
123
|
+
return buildOperation({
|
|
124
|
+
method: "cosineSimilarity",
|
|
125
|
+
args: [toExpr(self, pgvectorTypeId, selfRefs), toExpr(other, pgvectorTypeId, selfRefs)],
|
|
126
|
+
returns: {
|
|
127
|
+
codecId: "pg/float8@1",
|
|
128
|
+
nullable: false
|
|
129
|
+
},
|
|
130
|
+
lowering: {
|
|
131
|
+
targetFamily: "sql",
|
|
132
|
+
strategy: "function",
|
|
133
|
+
template: "1 - ({{self}} <=> {{arg0}})"
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
136
137
|
}
|
|
137
|
-
}
|
|
138
|
+
};
|
|
138
139
|
}
|
|
139
140
|
const pgvectorPackMeta = {
|
|
140
141
|
kind: "extension",
|
|
@@ -158,11 +159,6 @@ const pgvectorPackMeta = {
|
|
|
158
159
|
alias: "Vector"
|
|
159
160
|
}]
|
|
160
161
|
},
|
|
161
|
-
operationTypes: { import: {
|
|
162
|
-
package: "@prisma-next/extension-pgvector/operation-types",
|
|
163
|
-
named: "OperationTypes",
|
|
164
|
-
alias: "PgVectorOperationTypes"
|
|
165
|
-
} },
|
|
166
162
|
queryOperationTypes: { import: {
|
|
167
163
|
package: "@prisma-next/extension-pgvector/operation-types",
|
|
168
164
|
named: "QueryOperationTypes",
|
|
@@ -179,4 +175,4 @@ const pgvectorPackMeta = {
|
|
|
179
175
|
//#endregion
|
|
180
176
|
export { pgvectorQueryOperations as n, pgvectorCodecRegistry as r, pgvectorPackMeta as t };
|
|
181
177
|
|
|
182
|
-
//# sourceMappingURL=descriptor-meta-
|
|
178
|
+
//# sourceMappingURL=descriptor-meta-DEgJjLLi.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor-meta-CBnWOxms.mjs","names":["arktype"],"sources":["../src/core/authoring.ts","../src/core/codecs.ts","../src/core/registry.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 * pgvector extension codec.\n *\n * Mirrors the patterns in `postgres/codecs-class.ts` and `sqlite/codecs-class.ts` for the single `pg/vector@1` codec. Three artifacts:\n *\n * 1. `PgVectorCodec` extends {@link CodecImpl} with the runtime encode/decode/encodeJson/decodeJson conversions inline. Conversions are simple enough (PostgreSQL `[1,2,3]` text format) that no shared helper module is warranted; the class body is the source of truth.\n * 2. `PgVectorDescriptor` extends {@link CodecDescriptorImpl} with the codec id, traits, target types, params schema (`{ length: number }`, validated against {@link VECTOR_MAX_DIM}), `meta` (postgres `nativeType: 'vector'`), and the emit-path `renderOutputType` producing `Vector<${length}>`.\n * 3. `pgVectorColumn(length)` per-codec column helper invoking `descriptor.factory({ length })` directly + passing the bare `nativeType: 'vector'`. The family-layer {@link expandNativeType} hook renders the parameterized form (`vector(1536)`) at emit/verify time from `nativeType` + `typeParams`.\n *\n * `length` threads into the runtime codec via the constructor so encode/decode/encodeJson/decodeJson enforce the declared dimension at every ingress path. Without this, `vector(3)` and `vector(1536)` would produce codecs with identical behaviour and a dimension-mismatched value would round-trip undetected.\n */\n\nimport type { JsonValue } from '@prisma-next/contract/types';\nimport {\n type AnyCodecDescriptor,\n type CodecCallContext,\n CodecDescriptorImpl,\n CodecImpl,\n type CodecInstanceContext,\n type ColumnHelperFor,\n type ColumnHelperForStrict,\n column,\n} from '@prisma-next/framework-components/codec';\nimport type { ExtractCodecTypes } from '@prisma-next/sql-relational-core/ast';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { type as arktype } from 'arktype';\nimport { VECTOR_CODEC_ID, VECTOR_MAX_DIM } from './constants';\n\ntype VectorParams = { readonly length: number };\n\nconst vectorParamsSchema = arktype({\n length: 'number',\n}).narrow((params, ctx) => {\n const { length } = params;\n if (!Number.isInteger(length)) {\n return ctx.mustBe('an integer');\n }\n if (length < 1 || length > VECTOR_MAX_DIM) {\n return ctx.mustBe(`in the range [1, ${VECTOR_MAX_DIM}]`);\n }\n return true;\n}) satisfies StandardSchemaV1<VectorParams>;\n\nconst PG_VECTOR_META = { db: { sql: { postgres: { nativeType: 'vector' } } } } as const;\n\nexport class PgVectorCodec extends CodecImpl<\n typeof VECTOR_CODEC_ID,\n readonly ['equality'],\n string,\n number[]\n> {\n readonly length: number | undefined;\n\n constructor(descriptor: AnyCodecDescriptor, length: number | undefined) {\n super(descriptor);\n this.length = length;\n }\n\n assertVector(value: unknown): asserts value is number[] {\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 if (this.length !== undefined && value.length !== this.length) {\n throw new Error(`Vector length mismatch: expected ${this.length}, got ${value.length}`);\n }\n }\n\n async encode(value: number[], _ctx: CodecCallContext): Promise<string> {\n this.assertVector(value);\n return `[${value.join(',')}]`;\n }\n\n async decode(wire: string, _ctx: CodecCallContext): Promise<number[]> {\n if (typeof wire !== 'string') {\n throw new Error('Vector wire value must be a string');\n }\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 const parsed =\n content === ''\n ? []\n : 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 this.assertVector(parsed);\n return parsed;\n }\n\n encodeJson(value: number[]): JsonValue {\n this.assertVector(value);\n return value;\n }\n\n decodeJson(json: JsonValue): number[] {\n this.assertVector(json);\n return json;\n }\n}\n\nexport class PgVectorDescriptor extends CodecDescriptorImpl<VectorParams> {\n override readonly codecId = VECTOR_CODEC_ID;\n override readonly traits = ['equality'] as const;\n override readonly targetTypes = ['vector'] as const;\n override readonly meta = PG_VECTOR_META;\n override readonly paramsSchema: StandardSchemaV1<VectorParams> = vectorParamsSchema;\n override renderOutputType(params: VectorParams): string {\n return `Vector<${params.length}>`;\n }\n /**\n * The runtime calls `factory(undefined)(ctx)` to materialize a representative codec for parameterized descriptors that ship a no-params column variant (here, `vectorColumn` vs `vector(N)`). The runtime cast widens `params` to `unknown`, so guarding with an optional read keeps the typed call site (`factory({ length })`) strict while still producing a length-agnostic codec for representative use. Encode/decode for an undimensioned column run through this representative; the wire format `[v1,v2,...]` is dimension-independent.\n */\n override factory(params: VectorParams): (ctx: CodecInstanceContext) => PgVectorCodec {\n return () => new PgVectorCodec(this, (params as VectorParams | undefined)?.length);\n }\n}\n\nexport const pgVectorDescriptor = new PgVectorDescriptor();\n\n/**\n * Per-codec column helper for `pg/vector@1`. Generic over `N extends number` so the column site preserves the dimension literal in `typeParams` (e.g. `pgVectorColumn(1536)` packs `typeParams: { length: 1536 }`).\n *\n * Passes the bare `nativeType: 'vector'`; the family-layer `expandNativeType` hook renders the parameterized form (`vector(1536)`) at emit/verify time from `nativeType` + `typeParams`.\n */\nexport const pgVectorColumn = <N extends number>(length: N) =>\n column(pgVectorDescriptor.factory({ length }), pgVectorDescriptor.codecId, { length }, 'vector');\n\npgVectorColumn satisfies ColumnHelperFor<PgVectorDescriptor>;\npgVectorColumn satisfies ColumnHelperForStrict<PgVectorDescriptor>;\n\nconst codecDescriptorMap = {\n vector: pgVectorDescriptor,\n} as const;\n\nexport type CodecTypes = ExtractCodecTypes<typeof codecDescriptorMap>;\n\nexport const codecDescriptors: readonly AnyCodecDescriptor[] = Object.values(codecDescriptorMap);\n","import { buildCodecDescriptorRegistry } from '@prisma-next/sql-relational-core/codec-descriptor-registry';\nimport type { CodecDescriptorRegistry } from '@prisma-next/sql-relational-core/query-lane-context';\nimport { codecDescriptors } from './codecs';\n\n/**\n * Registry of every codec descriptor shipped by `@prisma-next/extension-pgvector`.\n *\n * Public consumer surface for the pgvector codec set. Currently a single entry (`pg/vector@1`); the registry shape stays consistent with the other codec-shipping packages so consumers don't need to special-case extensions. See ADR 208.\n */\nexport const pgvectorCodecRegistry: CodecDescriptorRegistry =\n buildCodecDescriptorRegistry(codecDescriptors);\n","import type { SqlOperationDescriptor } from '@prisma-next/sql-operations';\nimport {\n buildOperation,\n type CodecExpression,\n type Expression,\n refsOf,\n toExpr,\n} from '@prisma-next/sql-relational-core/expression';\nimport type { CodecTypes } from '../types/codec-types';\nimport { pgvectorAuthoringTypes } from './authoring';\nimport { pgvectorCodecRegistry } from './registry';\n\nconst pgvectorTypeId = 'pg/vector@1' as const;\n\ntype CodecTypesBase = Record<string, { readonly input: unknown; readonly output: unknown }>;\n\nexport function pgvectorQueryOperations<\n CT extends CodecTypesBase,\n>(): readonly SqlOperationDescriptor[] {\n return [\n {\n method: 'cosineDistance',\n self: { codecId: pgvectorTypeId },\n impl: (\n self: CodecExpression<'pg/vector@1', boolean, CT>,\n other: CodecExpression<'pg/vector@1', boolean, CT>,\n ): Expression<{ codecId: 'pg/float8@1'; nullable: false }> => {\n const selfRefs = refsOf(self);\n return buildOperation({\n method: 'cosineDistance',\n args: [toExpr(self, pgvectorTypeId, selfRefs), toExpr(other, pgvectorTypeId, selfRefs)],\n returns: { codecId: 'pg/float8@1', nullable: false },\n lowering: {\n targetFamily: 'sql',\n strategy: 'function',\n template: '{{self}} <=> {{arg0}}',\n },\n });\n },\n },\n {\n method: 'cosineSimilarity',\n self: { codecId: pgvectorTypeId },\n impl: (\n self: CodecExpression<'pg/vector@1', boolean, CT>,\n other: CodecExpression<'pg/vector@1', boolean, CT>,\n ): Expression<{ codecId: 'pg/float8@1'; nullable: false }> => {\n const selfRefs = refsOf(self);\n return buildOperation({\n method: 'cosineSimilarity',\n args: [toExpr(self, pgvectorTypeId, selfRefs), toExpr(other, pgvectorTypeId, selfRefs)],\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 },\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 codecDescriptors: Array.from(pgvectorCodecRegistry.values()),\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;;;ACWD,MAAM,qBAAqBA,KAAQ,EACjC,QAAQ,UACT,CAAC,CAAC,QAAQ,QAAQ,QAAQ;CACzB,MAAM,EAAE,WAAW;CACnB,IAAI,CAAC,OAAO,UAAU,OAAO,EAC3B,OAAO,IAAI,OAAO,aAAa;CAEjC,IAAI,SAAS,KAAK,SAAA,MAChB,OAAO,IAAI,OAAO,oBAAoB,eAAe,GAAG;CAE1D,OAAO;EACP;AAEF,MAAM,iBAAiB,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,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B,QAAQ,CAAC;GAC5D,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;CAKC"}
|
|
1
|
+
{"version":3,"file":"descriptor-meta-DEgJjLLi.mjs","names":["arktype"],"sources":["../src/core/authoring.ts","../src/core/codecs.ts","../src/core/registry.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 * pgvector extension codec.\n *\n * Mirrors the patterns in `postgres/codecs-class.ts` and `sqlite/codecs-class.ts` for the single `pg/vector@1` codec. Three artifacts:\n *\n * 1. `PgVectorCodec` extends {@link CodecImpl} with the runtime encode/decode/encodeJson/decodeJson conversions inline. Conversions are simple enough (PostgreSQL `[1,2,3]` text format) that no shared helper module is warranted; the class body is the source of truth.\n * 2. `PgVectorDescriptor` extends {@link CodecDescriptorImpl} with the codec id, traits, target types, params schema (`{ length: number }`, validated against {@link VECTOR_MAX_DIM}), `meta` (postgres `nativeType: 'vector'`), and the emit-path `renderOutputType` producing `Vector<${length}>`.\n * 3. `pgVectorColumn(length)` per-codec column helper invoking `descriptor.factory({ length })` directly + passing the bare `nativeType: 'vector'`. The family-layer {@link expandNativeType} hook renders the parameterized form (`vector(1536)`) at emit/verify time from `nativeType` + `typeParams`.\n *\n * `length` threads into the runtime codec via the constructor so encode/decode/encodeJson/decodeJson enforce the declared dimension at every ingress path. Without this, `vector(3)` and `vector(1536)` would produce codecs with identical behaviour and a dimension-mismatched value would round-trip undetected.\n */\n\nimport type { JsonValue } from '@prisma-next/contract/types';\nimport {\n type AnyCodecDescriptor,\n type CodecCallContext,\n CodecDescriptorImpl,\n CodecImpl,\n type CodecInstanceContext,\n type ColumnHelperFor,\n type ColumnHelperForStrict,\n column,\n} from '@prisma-next/framework-components/codec';\nimport type { ExtractCodecTypes } from '@prisma-next/sql-relational-core/ast';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { type as arktype } from 'arktype';\nimport { VECTOR_CODEC_ID, VECTOR_MAX_DIM } from './constants';\n\ntype VectorParams = { readonly length: number };\n\nconst vectorParamsSchema = arktype({\n length: 'number',\n}).narrow((params, ctx) => {\n const { length } = params;\n if (!Number.isInteger(length)) {\n return ctx.mustBe('an integer');\n }\n if (length < 1 || length > VECTOR_MAX_DIM) {\n return ctx.mustBe(`in the range [1, ${VECTOR_MAX_DIM}]`);\n }\n return true;\n}) satisfies StandardSchemaV1<VectorParams>;\n\nconst PG_VECTOR_META = { db: { sql: { postgres: { nativeType: 'vector' } } } } as const;\n\nexport class PgVectorCodec extends CodecImpl<\n typeof VECTOR_CODEC_ID,\n readonly ['equality'],\n string,\n number[]\n> {\n readonly length: number | undefined;\n\n constructor(descriptor: AnyCodecDescriptor, length: number | undefined) {\n super(descriptor);\n this.length = length;\n }\n\n assertVector(value: unknown): asserts value is number[] {\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 if (this.length !== undefined && value.length !== this.length) {\n throw new Error(`Vector length mismatch: expected ${this.length}, got ${value.length}`);\n }\n }\n\n async encode(value: number[], _ctx: CodecCallContext): Promise<string> {\n this.assertVector(value);\n return `[${value.join(',')}]`;\n }\n\n async decode(wire: string, _ctx: CodecCallContext): Promise<number[]> {\n if (typeof wire !== 'string') {\n throw new Error('Vector wire value must be a string');\n }\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 const parsed =\n content === ''\n ? []\n : 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 this.assertVector(parsed);\n return parsed;\n }\n\n encodeJson(value: number[]): JsonValue {\n this.assertVector(value);\n return value;\n }\n\n decodeJson(json: JsonValue): number[] {\n this.assertVector(json);\n return json;\n }\n}\n\nexport class PgVectorDescriptor extends CodecDescriptorImpl<VectorParams> {\n override readonly codecId = VECTOR_CODEC_ID;\n override readonly traits = ['equality'] as const;\n override readonly targetTypes = ['vector'] as const;\n override readonly meta = PG_VECTOR_META;\n override readonly paramsSchema: StandardSchemaV1<VectorParams> = vectorParamsSchema;\n override renderOutputType(params: VectorParams): string {\n return `Vector<${params.length}>`;\n }\n /**\n * The runtime calls `factory(undefined)(ctx)` to materialize a representative codec for parameterized descriptors that ship a no-params column variant (here, `vectorColumn` vs `vector(N)`). The runtime cast widens `params` to `unknown`, so guarding with an optional read keeps the typed call site (`factory({ length })`) strict while still producing a length-agnostic codec for representative use. Encode/decode for an undimensioned column run through this representative; the wire format `[v1,v2,...]` is dimension-independent.\n */\n override factory(params: VectorParams): (ctx: CodecInstanceContext) => PgVectorCodec {\n return () => new PgVectorCodec(this, (params as VectorParams | undefined)?.length);\n }\n}\n\nexport const pgVectorDescriptor = new PgVectorDescriptor();\n\n/**\n * Per-codec column helper for `pg/vector@1`. Generic over `N extends number` so the column site preserves the dimension literal in `typeParams` (e.g. `pgVectorColumn(1536)` packs `typeParams: { length: 1536 }`).\n *\n * Passes the bare `nativeType: 'vector'`; the family-layer `expandNativeType` hook renders the parameterized form (`vector(1536)`) at emit/verify time from `nativeType` + `typeParams`.\n */\nexport const pgVectorColumn = <N extends number>(length: N) =>\n column(pgVectorDescriptor.factory({ length }), pgVectorDescriptor.codecId, { length }, 'vector');\n\npgVectorColumn satisfies ColumnHelperFor<PgVectorDescriptor>;\npgVectorColumn satisfies ColumnHelperForStrict<PgVectorDescriptor>;\n\nconst codecDescriptorMap = {\n vector: pgVectorDescriptor,\n} as const;\n\nexport type CodecTypes = ExtractCodecTypes<typeof codecDescriptorMap>;\n\nexport const codecDescriptors: readonly AnyCodecDescriptor[] = Object.values(codecDescriptorMap);\n","import { buildCodecDescriptorRegistry } from '@prisma-next/sql-relational-core/codec-descriptor-registry';\nimport type { CodecDescriptorRegistry } from '@prisma-next/sql-relational-core/query-lane-context';\nimport { codecDescriptors } from './codecs';\n\n/**\n * Registry of every codec descriptor shipped by `@prisma-next/extension-pgvector`.\n *\n * Public consumer surface for the pgvector codec set. Currently a single entry (`pg/vector@1`); the registry shape stays consistent with the other codec-shipping packages so consumers don't need to special-case extensions. See ADR 208.\n */\nexport const pgvectorCodecRegistry: CodecDescriptorRegistry =\n buildCodecDescriptorRegistry(codecDescriptors);\n","import { buildOperation, refsOf, toExpr } from '@prisma-next/sql-relational-core/expression';\nimport type { CodecTypes } from '../types/codec-types';\nimport type { QueryOperationTypes } from '../types/operation-types';\nimport { pgvectorAuthoringTypes } from './authoring';\nimport { pgvectorCodecRegistry } from './registry';\n\nconst pgvectorTypeId = 'pg/vector@1' as const;\n\ntype CodecTypesBase = Record<string, { readonly input: unknown; readonly output: unknown }>;\n\nexport function pgvectorQueryOperations<CT extends CodecTypesBase>(): QueryOperationTypes<CT> {\n return {\n cosineDistance: {\n self: { codecId: pgvectorTypeId },\n impl: (self, other) => {\n const selfRefs = refsOf(self);\n return buildOperation({\n method: 'cosineDistance',\n args: [toExpr(self, pgvectorTypeId, selfRefs), toExpr(other, pgvectorTypeId, selfRefs)],\n returns: { codecId: 'pg/float8@1', nullable: false },\n lowering: {\n targetFamily: 'sql',\n strategy: 'function',\n template: '{{self}} <=> {{arg0}}',\n },\n });\n },\n },\n cosineSimilarity: {\n self: { codecId: pgvectorTypeId },\n impl: (self, other) => {\n const selfRefs = refsOf(self);\n return buildOperation({\n method: 'cosineSimilarity',\n args: [toExpr(self, pgvectorTypeId, selfRefs), toExpr(other, pgvectorTypeId, selfRefs)],\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 },\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 codecDescriptors: Array.from(pgvectorCodecRegistry.values()),\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 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;EAAg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,KAAK;IAC7B,OAAO,eAAe;KACpB,QAAQ;KACR,MAAM,CAAC,OAAO,MAAM,gBAAgB,SAAS,EAAE,OAAO,OAAO,gBAAgB,SAAS,CAAC;KACvF,SAAS;MAAE,SAAS;MAAe,UAAU;MAAO;KACpD,UAAU;MACR,cAAc;MACd,UAAU;MACV,UAAU;MACX;KACF,CAAC;;GAEL;EACF;;AA8CH,MAAa,mBAET;CA5CF,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,kBAAkB,MAAM,KAAK,sBAAsB,QAAQ,CAAC;GAC5D,QAAQ;IACN,SAAS;IACT,OAAO;IACP,OAAO;IACR;GACD,aAAa,CACX;IACE,SAAS;IACT,OAAO;IACP,OAAO;IACR,CACF;GACF;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;CAKC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CodecExpression, Expression } from "@prisma-next/sql-relational-core/expression";
|
|
2
|
+
import { SqlQueryOperationTypes } from "@prisma-next/sql-contract/types";
|
|
3
|
+
|
|
4
|
+
//#region src/types/operation-types.d.ts
|
|
5
|
+
type CodecTypesBase = Record<string, {
|
|
6
|
+
readonly input: unknown;
|
|
7
|
+
readonly output: unknown;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Operation type definitions for pgvector extension.
|
|
11
|
+
*
|
|
12
|
+
* This file exports type-only definitions for operation method signatures.
|
|
13
|
+
* These types are imported by contract.d.ts files for compile-time type inference.
|
|
14
|
+
*/
|
|
15
|
+
/** Flat operation signatures for the query builder. */
|
|
16
|
+
type QueryOperationTypes<CT extends CodecTypesBase> = SqlQueryOperationTypes<CT, {
|
|
17
|
+
readonly cosineDistance: {
|
|
18
|
+
readonly self: {
|
|
19
|
+
readonly codecId: 'pg/vector@1';
|
|
20
|
+
};
|
|
21
|
+
readonly impl: (self: CodecExpression<'pg/vector@1', boolean, CT>, other: CodecExpression<'pg/vector@1', boolean, CT>) => Expression<{
|
|
22
|
+
codecId: 'pg/float8@1';
|
|
23
|
+
nullable: false;
|
|
24
|
+
}>;
|
|
25
|
+
};
|
|
26
|
+
readonly cosineSimilarity: {
|
|
27
|
+
readonly self: {
|
|
28
|
+
readonly codecId: 'pg/vector@1';
|
|
29
|
+
};
|
|
30
|
+
readonly impl: (self: CodecExpression<'pg/vector@1', boolean, CT>, other: CodecExpression<'pg/vector@1', boolean, CT>) => Expression<{
|
|
31
|
+
codecId: 'pg/float8@1';
|
|
32
|
+
nullable: false;
|
|
33
|
+
}>;
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { QueryOperationTypes as t };
|
|
38
|
+
//# sourceMappingURL=operation-types-Bd-jkNN3.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-types-Bd-jkNN3.d.mts","names":[],"sources":["../src/types/operation-types.ts"],"mappings":";;;;KAGK,cAAA,GAAiB,MAAA;EAAA,SAA0B,KAAA;EAAA,SAAyB,MAAA;AAAA;;;;;;;;KAU7D,mBAAA,YAA+B,cAAA,IAAkB,sBAAA,CAC3D,EAAA;EAAA,SAEW,cAAA;IAAA,SACE,IAAA;MAAA,SAAiB,OAAA;IAAA;IAAA,SACjB,IAAA,GACP,IAAA,EAAM,eAAA,yBAAwC,EAAA,GAC9C,KAAA,EAAO,eAAA,yBAAwC,EAAA,MAC5C,UAAA;MAAa,OAAA;MAAwB,QAAA;IAAA;EAAA;EAAA,SAEnC,gBAAA;IAAA,SACE,IAAA;MAAA,SAAiB,OAAA;IAAA;IAAA,SACjB,IAAA,GACP,IAAA,EAAM,eAAA,yBAAwC,EAAA,GAC9C,KAAA,EAAO,eAAA,yBAAwC,EAAA,MAC5C,UAAA;MAAa,OAAA;MAAwB,QAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1,52 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
//#region src/types/operation-types.d.ts
|
|
5
|
-
type CodecTypesBase = Record<string, {
|
|
6
|
-
readonly input: unknown;
|
|
7
|
-
readonly output: unknown;
|
|
8
|
-
}>;
|
|
9
|
-
/**
|
|
10
|
-
* Operation type definitions for pgvector extension.
|
|
11
|
-
*
|
|
12
|
-
* This file exports type-only definitions for operation method signatures.
|
|
13
|
-
* These types are imported by contract.d.ts files for compile-time type inference.
|
|
14
|
-
*/
|
|
15
|
-
type OperationTypes = {
|
|
16
|
-
readonly 'pg/vector@1': {
|
|
17
|
-
readonly cosineDistance: {
|
|
18
|
-
readonly self: {
|
|
19
|
-
readonly codecId: 'pg/vector@1';
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
readonly cosineSimilarity: {
|
|
23
|
-
readonly self: {
|
|
24
|
-
readonly codecId: 'pg/vector@1';
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
/** Flat operation signatures for the query builder. */
|
|
30
|
-
type QueryOperationTypes<CT extends CodecTypesBase> = SqlQueryOperationTypes<CT, {
|
|
31
|
-
readonly cosineDistance: {
|
|
32
|
-
readonly self: {
|
|
33
|
-
readonly codecId: 'pg/vector@1';
|
|
34
|
-
};
|
|
35
|
-
readonly impl: (self: CodecExpression<'pg/vector@1', boolean, CT>, other: CodecExpression<'pg/vector@1', boolean, CT>) => Expression<{
|
|
36
|
-
codecId: 'pg/float8@1';
|
|
37
|
-
nullable: false;
|
|
38
|
-
}>;
|
|
39
|
-
};
|
|
40
|
-
readonly cosineSimilarity: {
|
|
41
|
-
readonly self: {
|
|
42
|
-
readonly codecId: 'pg/vector@1';
|
|
43
|
-
};
|
|
44
|
-
readonly impl: (self: CodecExpression<'pg/vector@1', boolean, CT>, other: CodecExpression<'pg/vector@1', boolean, CT>) => Expression<{
|
|
45
|
-
codecId: 'pg/float8@1';
|
|
46
|
-
nullable: false;
|
|
47
|
-
}>;
|
|
48
|
-
};
|
|
49
|
-
}>;
|
|
50
|
-
//#endregion
|
|
51
|
-
export { type OperationTypes, type QueryOperationTypes };
|
|
52
|
-
//# sourceMappingURL=operation-types.d.mts.map
|
|
1
|
+
import { t as QueryOperationTypes } from "./operation-types-Bd-jkNN3.mjs";
|
|
2
|
+
export { type QueryOperationTypes };
|
package/dist/pack.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { t as CodecTypes } from "./codec-types-yMSpEJJM.mjs";
|
|
2
2
|
import * as _$_prisma_next_framework_components_codec0 from "@prisma-next/framework-components/codec";
|
|
3
|
+
|
|
3
4
|
//#region src/core/descriptor-meta.d.ts
|
|
4
5
|
declare const pgvectorPackMetaBase: {
|
|
5
6
|
readonly kind: "extension";
|
|
@@ -52,13 +53,6 @@ declare const pgvectorPackMetaBase: {
|
|
|
52
53
|
readonly alias: "Vector";
|
|
53
54
|
}];
|
|
54
55
|
};
|
|
55
|
-
readonly operationTypes: {
|
|
56
|
-
readonly import: {
|
|
57
|
-
readonly package: "@prisma-next/extension-pgvector/operation-types";
|
|
58
|
-
readonly named: "OperationTypes";
|
|
59
|
-
readonly alias: "PgVectorOperationTypes";
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
56
|
readonly queryOperationTypes: {
|
|
63
57
|
readonly import: {
|
|
64
58
|
readonly package: "@prisma-next/extension-pgvector/operation-types";
|
package/dist/pack.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pack.d.mts","names":[],"sources":["../src/core/descriptor-meta.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"pack.d.mts","names":[],"sources":["../src/core/descriptor-meta.ts"],"mappings":";;;;cA+CM,oBAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAyCI,0CAAA,CAAA,eAAA;MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;cAEG,gBAAA,SAAyB,oBAAA;EAAA,SAC3B,YAAA,GAAe,UAAA;AAAA"}
|
package/dist/pack.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as pgvectorPackMeta } from "./descriptor-meta-
|
|
1
|
+
import { t as pgvectorPackMeta } from "./descriptor-meta-DEgJjLLi.mjs";
|
|
2
2
|
export { pgvectorPackMeta as default };
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as pgvectorQueryOperations, r as pgvectorCodecRegistry, t as pgvectorPackMeta } from "./descriptor-meta-
|
|
1
|
+
import { n as pgvectorQueryOperations, r as pgvectorCodecRegistry, t as pgvectorPackMeta } from "./descriptor-meta-DEgJjLLi.mjs";
|
|
2
2
|
//#region src/exports/runtime.ts
|
|
3
3
|
const pgvectorRuntimeDescriptor = {
|
|
4
4
|
kind: "extension",
|
package/package.json
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/extension-pgvector",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.84",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@standard-schema/spec": "^1.1.0",
|
|
9
9
|
"arktype": "^2.1.29",
|
|
10
|
-
"@prisma-next/contract": "0.5.0-dev.
|
|
11
|
-
"@prisma-next/contract-authoring": "0.5.0-dev.
|
|
12
|
-
"@prisma-next/family-sql": "0.5.0-dev.
|
|
13
|
-
"@prisma-next/migration-tools": "0.5.0-dev.
|
|
14
|
-
"@prisma-next/sql-contract": "0.5.0-dev.
|
|
15
|
-
"@prisma-next/
|
|
16
|
-
"@prisma-next/sql-operations": "0.5.0-dev.
|
|
17
|
-
"@prisma-next/
|
|
18
|
-
"@prisma-next/sql-
|
|
19
|
-
"@prisma-next/sql-schema-ir": "0.5.0-dev.
|
|
10
|
+
"@prisma-next/contract": "0.5.0-dev.84",
|
|
11
|
+
"@prisma-next/contract-authoring": "0.5.0-dev.84",
|
|
12
|
+
"@prisma-next/family-sql": "0.5.0-dev.84",
|
|
13
|
+
"@prisma-next/migration-tools": "0.5.0-dev.84",
|
|
14
|
+
"@prisma-next/sql-contract": "0.5.0-dev.84",
|
|
15
|
+
"@prisma-next/sql-relational-core": "0.5.0-dev.84",
|
|
16
|
+
"@prisma-next/sql-operations": "0.5.0-dev.84",
|
|
17
|
+
"@prisma-next/framework-components": "0.5.0-dev.84",
|
|
18
|
+
"@prisma-next/sql-runtime": "0.5.0-dev.84",
|
|
19
|
+
"@prisma-next/sql-schema-ir": "0.5.0-dev.84"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"tsdown": "0.22.0",
|
|
23
23
|
"typescript": "5.9.3",
|
|
24
24
|
"vitest": "4.1.5",
|
|
25
|
-
"@prisma-next/
|
|
26
|
-
"@prisma-next/
|
|
25
|
+
"@prisma-next/sql-contract-ts": "0.5.0-dev.84",
|
|
26
|
+
"@prisma-next/tsconfig": "0.0.0",
|
|
27
27
|
"@prisma-next/test-utils": "0.0.1",
|
|
28
|
-
"@prisma-next/
|
|
29
|
-
"@prisma-next/
|
|
28
|
+
"@prisma-next/operations": "0.5.0-dev.84",
|
|
29
|
+
"@prisma-next/tsdown": "0.0.0"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
buildOperation,
|
|
4
|
-
type CodecExpression,
|
|
5
|
-
type Expression,
|
|
6
|
-
refsOf,
|
|
7
|
-
toExpr,
|
|
8
|
-
} from '@prisma-next/sql-relational-core/expression';
|
|
1
|
+
import { buildOperation, refsOf, toExpr } from '@prisma-next/sql-relational-core/expression';
|
|
9
2
|
import type { CodecTypes } from '../types/codec-types';
|
|
3
|
+
import type { QueryOperationTypes } from '../types/operation-types';
|
|
10
4
|
import { pgvectorAuthoringTypes } from './authoring';
|
|
11
5
|
import { pgvectorCodecRegistry } from './registry';
|
|
12
6
|
|
|
@@ -14,17 +8,11 @@ const pgvectorTypeId = 'pg/vector@1' as const;
|
|
|
14
8
|
|
|
15
9
|
type CodecTypesBase = Record<string, { readonly input: unknown; readonly output: unknown }>;
|
|
16
10
|
|
|
17
|
-
export function pgvectorQueryOperations<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return [
|
|
21
|
-
{
|
|
22
|
-
method: 'cosineDistance',
|
|
11
|
+
export function pgvectorQueryOperations<CT extends CodecTypesBase>(): QueryOperationTypes<CT> {
|
|
12
|
+
return {
|
|
13
|
+
cosineDistance: {
|
|
23
14
|
self: { codecId: pgvectorTypeId },
|
|
24
|
-
impl: (
|
|
25
|
-
self: CodecExpression<'pg/vector@1', boolean, CT>,
|
|
26
|
-
other: CodecExpression<'pg/vector@1', boolean, CT>,
|
|
27
|
-
): Expression<{ codecId: 'pg/float8@1'; nullable: false }> => {
|
|
15
|
+
impl: (self, other) => {
|
|
28
16
|
const selfRefs = refsOf(self);
|
|
29
17
|
return buildOperation({
|
|
30
18
|
method: 'cosineDistance',
|
|
@@ -38,13 +26,9 @@ export function pgvectorQueryOperations<
|
|
|
38
26
|
});
|
|
39
27
|
},
|
|
40
28
|
},
|
|
41
|
-
{
|
|
42
|
-
method: 'cosineSimilarity',
|
|
29
|
+
cosineSimilarity: {
|
|
43
30
|
self: { codecId: pgvectorTypeId },
|
|
44
|
-
impl: (
|
|
45
|
-
self: CodecExpression<'pg/vector@1', boolean, CT>,
|
|
46
|
-
other: CodecExpression<'pg/vector@1', boolean, CT>,
|
|
47
|
-
): Expression<{ codecId: 'pg/float8@1'; nullable: false }> => {
|
|
31
|
+
impl: (self, other) => {
|
|
48
32
|
const selfRefs = refsOf(self);
|
|
49
33
|
return buildOperation({
|
|
50
34
|
method: 'cosineSimilarity',
|
|
@@ -58,7 +42,7 @@ export function pgvectorQueryOperations<
|
|
|
58
42
|
});
|
|
59
43
|
},
|
|
60
44
|
},
|
|
61
|
-
|
|
45
|
+
};
|
|
62
46
|
}
|
|
63
47
|
|
|
64
48
|
const pgvectorPackMetaBase = {
|
|
@@ -91,13 +75,6 @@ const pgvectorPackMetaBase = {
|
|
|
91
75
|
},
|
|
92
76
|
],
|
|
93
77
|
},
|
|
94
|
-
operationTypes: {
|
|
95
|
-
import: {
|
|
96
|
-
package: '@prisma-next/extension-pgvector/operation-types',
|
|
97
|
-
named: 'OperationTypes',
|
|
98
|
-
alias: 'PgVectorOperationTypes',
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
78
|
queryOperationTypes: {
|
|
102
79
|
import: {
|
|
103
80
|
package: '@prisma-next/extension-pgvector/operation-types',
|
|
@@ -10,17 +10,6 @@ type CodecTypesBase = Record<string, { readonly input: unknown; readonly output:
|
|
|
10
10
|
* These types are imported by contract.d.ts files for compile-time type inference.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export type OperationTypes = {
|
|
14
|
-
readonly 'pg/vector@1': {
|
|
15
|
-
readonly cosineDistance: {
|
|
16
|
-
readonly self: { readonly codecId: 'pg/vector@1' };
|
|
17
|
-
};
|
|
18
|
-
readonly cosineSimilarity: {
|
|
19
|
-
readonly self: { readonly codecId: 'pg/vector@1' };
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
13
|
/** Flat operation signatures for the query builder. */
|
|
25
14
|
export type QueryOperationTypes<CT extends CodecTypesBase> = SqlQueryOperationTypes<
|
|
26
15
|
CT,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"operation-types.d.mts","names":[],"sources":["../src/types/operation-types.ts"],"mappings":";;;;KAGK,cAAA,GAAiB,MAAA;EAAA,SAA0B,KAAA;EAAA,SAAyB,MAAA;AAAA;;;;;;;KAS7D,cAAA;EAAA,SACD,aAAA;IAAA,SACE,cAAA;MAAA,SACE,IAAA;QAAA,SAAiB,OAAA;MAAA;IAAA;IAAA,SAEnB,gBAAA;MAAA,SACE,IAAA;QAAA,SAAiB,OAAA;MAAA;IAAA;EAAA;AAAA;AAMhC;AAAA,KAAY,mBAAA,YAA+B,cAAA,IAAkB,sBAAA,CAC3D,EAAA;EAAA,SAEW,cAAA;IAAA,SACE,IAAA;MAAA,SAAiB,OAAA;IAAA;IAAA,SACjB,IAAA,GACP,IAAA,EAAM,eAAA,yBAAwC,EAAA,GAC9C,KAAA,EAAO,eAAA,yBAAwC,EAAA,MAC5C,UAAA;MAAa,OAAA;MAAwB,QAAA;IAAA;EAAA;EAAA,SAEnC,gBAAA;IAAA,SACE,IAAA;MAAA,SAAiB,OAAA;IAAA;IAAA,SACjB,IAAA,GACP,IAAA,EAAM,eAAA,yBAAwC,EAAA,GAC9C,KAAA,EAAO,eAAA,yBAAwC,EAAA,MAC5C,UAAA;MAAa,OAAA;MAAwB,QAAA;IAAA;EAAA;AAAA"}
|