@prisma-next/extension-pgvector 0.14.0-dev.76 → 0.14.0-dev.78

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.
@@ -1 +1 @@
1
- {"version":3,"file":"codec-types-BAjDDnH_.d.mts","names":[],"sources":["../src/core/constants.ts","../src/core/codecs.ts","../src/types/codec-types.ts"],"mappings":";;;;;;;;;cAGa,eAAA;;;KCyBR,YAAA;EAAA,SAA0B,MAAM;AAAA;AAAA,cAiBxB,aAAA,SAAsB,SAAA,QAC1B,eAAA;EAAA,SAKE,MAAA;cAEG,UAAA,EAAY,kBAAA,EAAoB,MAAA;EAK5C,YAAA,CAAa,KAAA,oBAAyB,KAAA;EAYhC,MAAA,CAAO,KAAA,YAAiB,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAKjD,MAAA,CAAO,IAAA,UAAc,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAsBpD,UAAA,CAAW,KAAA,aAAkB,SAAA;EAK7B,UAAA,CAAW,IAAA,EAAM,SAAA;AAAA;AAAA,cAMN,kBAAA,SAA2B,mBAAA,CAAoB,YAAA;EAAA,SACxC,OAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,IAAA;IAAA;;;;;;;;WACA,YAAA,EAAc,gBAAA,CAAiB,YAAA;EACxC,gBAAA,CAAiB,MAAA,EAAQ,YAAA;EAGzB,OAAA,CAAQ,MAAA,EAAQ,YAAA,IAAgB,GAAA,EAAK,oBAAA,KAAyB,aAAA;AAAA;AAAA,cAkBnE,kBAAA;EAAA,iBAEI,kBAAA;AAAA;AAAA,KAEE,YAAA,GAAa,iBAAiB,QAAQ,kBAAA;;;;ADxIG;;;;ACuBS;KCTlD,MAAA;EAAA,SAA0D,cAAA,GAAiB,CAAC;AAAA;AAAA,KAE5E,UAAA,GAAa,YAAc"}
1
+ {"version":3,"file":"codec-types-BAjDDnH_.d.mts","names":[],"sources":["../src/core/constants.ts","../src/core/codecs.ts","../src/types/codec-types.ts"],"mappings":";;;;;;;;;cAGa,eAAA;;;KCyBR,YAAA;EAAA,SAA0B,MAAM;AAAA;AAAA,cAiCxB,aAAA,SAAsB,SAAA,QAC1B,eAAA;EAAA,SAKE,MAAA;cAEG,UAAA,EAAY,kBAAA,EAAoB,MAAA;EAK5C,YAAA,CAAa,KAAA,oBAAyB,KAAA;EAiBhC,MAAA,CAAO,KAAA,YAAiB,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAKjD,MAAA,CAAO,IAAA,UAAc,IAAA,EAAM,gBAAA,GAAmB,OAAA;EASpD,UAAA,CAAW,KAAA,aAAkB,SAAA;EAK7B,UAAA,CAAW,IAAA,EAAM,SAAA;AAAA;AAAA,cAUN,kBAAA,SAA2B,mBAAA,CAAoB,YAAA;EAAA,SACxC,OAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,IAAA;IAAA;;;;;;;;WACA,YAAA,EAAc,gBAAA,CAAiB,YAAA;EACxC,gBAAA,CAAiB,MAAA,EAAQ,YAAA;EAGzB,OAAA,CAAQ,MAAA,EAAQ,YAAA,IAAgB,GAAA,EAAK,oBAAA,KAAyB,aAAA;AAAA;AAAA,cAkBnE,kBAAA;EAAA,iBAEI,kBAAA;AAAA;AAAA,KAEE,YAAA,GAAa,iBAAiB,QAAQ,kBAAA;;;;ADpJG;;;;ACuBS;KCTlD,MAAA;EAAA,SAA0D,cAAA,GAAiB,CAAC;AAAA;AAAA,KAE5E,UAAA,GAAa,YAAc"}
package/dist/control.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as pgvectorQueryOperations, t as pgvectorPackMeta } from "./descriptor-meta-Bv7s7XWG.mjs";
1
+ import { n as pgvectorQueryOperations, t as pgvectorPackMeta } from "./descriptor-meta-G5zBc8J8.mjs";
2
2
  import { contractSpaceFromJson } from "@prisma-next/migration-tools/spaces";
3
3
  //#region migrations/20260601T0000_install_vector_extension/migration.json
4
4
  var migration_default = {
@@ -31,6 +31,15 @@ const vectorParamsSchema = type({ length: "number" }).narrow((params, ctx) => {
31
31
  return true;
32
32
  });
33
33
  const PG_VECTOR_META = { db: { sql: { postgres: { nativeType: "vector" } } } };
34
+ function parseVector(value) {
35
+ if (!value.startsWith("[") || !value.endsWith("]")) throw new Error(`Invalid vector format: expected "[...]", got "${value}"`);
36
+ const content = value.slice(1, -1).trim();
37
+ return content === "" ? [] : content.split(",").map((entry) => {
38
+ const number = Number.parseFloat(entry.trim());
39
+ if (Number.isNaN(number)) throw new Error(`Invalid vector value: "${entry}" is not a number`);
40
+ return number;
41
+ });
42
+ }
34
43
  var PgVectorCodec = class extends CodecImpl {
35
44
  length;
36
45
  constructor(descriptor, length) {
@@ -39,7 +48,10 @@ var PgVectorCodec = class extends CodecImpl {
39
48
  }
40
49
  assertVector(value) {
41
50
  if (!Array.isArray(value)) throw new Error("Vector value must be an array of numbers");
42
- if (!value.every((v) => typeof v === "number")) throw new Error("Vector value must contain only numbers");
51
+ for (const element of value) {
52
+ if (typeof element !== "number") throw new Error("Vector value must contain only numbers");
53
+ if (!Number.isFinite(element)) throw new Error("Vector value must contain only finite numbers");
54
+ }
43
55
  if (value.length !== this.length) throw new Error(`Vector length mismatch: expected ${this.length}, got ${value.length}`);
44
56
  }
45
57
  async encode(value, _ctx) {
@@ -48,23 +60,19 @@ var PgVectorCodec = class extends CodecImpl {
48
60
  }
49
61
  async decode(wire, _ctx) {
50
62
  if (typeof wire !== "string") throw new Error("Vector wire value must be a string");
51
- if (!wire.startsWith("[") || !wire.endsWith("]")) throw new Error(`Invalid vector format: expected "[...]", got "${wire}"`);
52
- const content = wire.slice(1, -1).trim();
53
- const parsed = content === "" ? [] : content.split(",").map((v) => {
54
- const num = Number.parseFloat(v.trim());
55
- if (Number.isNaN(num)) throw new Error(`Invalid vector value: "${v}" is not a number`);
56
- return num;
57
- });
58
- this.assertVector(parsed);
59
- return parsed;
63
+ const value = parseVector(wire);
64
+ this.assertVector(value);
65
+ return value;
60
66
  }
61
67
  encodeJson(value) {
62
68
  this.assertVector(value);
63
- return value;
69
+ return `[${value.join(",")}]`;
64
70
  }
65
71
  decodeJson(json) {
66
- this.assertVector(json);
67
- return json;
72
+ if (typeof json !== "string") throw new Error("Vector database JSON value must be a string");
73
+ const value = parseVector(json);
74
+ this.assertVector(value);
75
+ return value;
68
76
  }
69
77
  };
70
78
  var PgVectorDescriptor = class extends CodecDescriptorImpl {
@@ -177,4 +185,4 @@ const pgvectorPackMeta = {
177
185
  //#endregion
178
186
  export { pgvectorQueryOperations as n, pgvectorCodecRegistry as r, pgvectorPackMeta as t };
179
187
 
180
- //# sourceMappingURL=descriptor-meta-Bv7s7XWG.mjs.map
188
+ //# sourceMappingURL=descriptor-meta-G5zBc8J8.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptor-meta-G5zBc8J8.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\nfunction parseVector(value: string): number[] {\n if (!value.startsWith('[') || !value.endsWith(']')) {\n throw new Error(`Invalid vector format: expected \"[...]\", got \"${value}\"`);\n }\n const content = value.slice(1, -1).trim();\n return content === ''\n ? []\n : content.split(',').map((entry) => {\n const number = Number.parseFloat(entry.trim());\n if (Number.isNaN(number)) {\n throw new Error(`Invalid vector value: \"${entry}\" is not a number`);\n }\n return number;\n });\n}\n\nexport class PgVectorCodec extends CodecImpl<\n typeof VECTOR_CODEC_ID,\n readonly ['equality'],\n string,\n number[]\n> {\n readonly length: number;\n\n constructor(descriptor: AnyCodecDescriptor, length: number) {\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 for (const element of value) {\n if (typeof element !== 'number') {\n throw new Error('Vector value must contain only numbers');\n }\n if (!Number.isFinite(element)) {\n throw new Error('Vector value must contain only finite numbers');\n }\n }\n if (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 const value = parseVector(wire);\n this.assertVector(value);\n return value;\n }\n\n encodeJson(value: number[]): JsonValue {\n this.assertVector(value);\n return `[${value.join(',')}]`;\n }\n\n decodeJson(json: JsonValue): number[] {\n if (typeof json !== 'string') {\n throw new Error('Vector database JSON value must be a string');\n }\n const value = parseVector(json);\n this.assertVector(value);\n return value;\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 override factory(params: VectorParams): (ctx: CodecInstanceContext) => PgVectorCodec {\n return () => new PgVectorCodec(this, params.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 {\n buildOperation,\n type CodecExpression,\n codecOf,\n type Expression,\n toExpr,\n} 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: (\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 selfCodec = codecOf(self);\n return buildOperation({\n method: 'cosineDistance',\n args: [toExpr(self, selfCodec), toExpr(other, selfCodec)],\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: (\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 selfCodec = codecOf(self);\n return buildOperation({\n method: 'cosineSimilarity',\n args: [toExpr(self, selfCodec), toExpr(other, selfCodec)],\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;CAAe,CACvF;CACA,QAAQ;EACN,SAAS;EACT,YAAY;EACZ,YAAY,EACV,QAAQ;GAAE,MAAM;GAAO,OAAO;EAAE,EAClC;CACF;AACF,EACF,EACF;;;ACWA,MAAM,qBAAqBA,KAAQ,EACjC,QAAQ,SACV,CAAC,CAAC,CAAC,QAAQ,QAAQ,QAAQ;CACzB,MAAM,EAAE,WAAW;CACnB,IAAI,CAAC,OAAO,UAAU,MAAM,GAC1B,OAAO,IAAI,OAAO,YAAY;CAEhC,IAAI,SAAS,KAAK,SAAA,MAChB,OAAO,IAAI,OAAO,oBAAoB,eAAe,EAAE;CAEzD,OAAO;AACT,CAAC;AAED,MAAM,iBAAiB,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,SAAS,EAAE,EAAE,EAAE;AAE7E,SAAS,YAAY,OAAyB;CAC5C,IAAI,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,SAAS,GAAG,GAC/C,MAAM,IAAI,MAAM,iDAAiD,MAAM,EAAE;CAE3E,MAAM,UAAU,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK;CACxC,OAAO,YAAY,KACf,CAAC,IACD,QAAQ,MAAM,GAAG,CAAC,CAAC,KAAK,UAAU;EAChC,MAAM,SAAS,OAAO,WAAW,MAAM,KAAK,CAAC;EAC7C,IAAI,OAAO,MAAM,MAAM,GACrB,MAAM,IAAI,MAAM,0BAA0B,MAAM,kBAAkB;EAEpE,OAAO;CACT,CAAC;AACP;AAEA,IAAa,g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,SAAS;GACT,OAAO;GACP,OAAO;EACT,EACF;EACA,SAAS,CACP;GAAE,QAAQ;GAAgB,UAAU;GAAO,UAAU;GAAY,YAAY;EAAS,CACxF;CACF;AAKE"}
package/dist/pack.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as pgvectorPackMeta } from "./descriptor-meta-Bv7s7XWG.mjs";
1
+ import { t as pgvectorPackMeta } from "./descriptor-meta-G5zBc8J8.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-Bv7s7XWG.mjs";
1
+ import { n as pgvectorQueryOperations, r as pgvectorCodecRegistry, t as pgvectorPackMeta } from "./descriptor-meta-G5zBc8J8.mjs";
2
2
  //#region src/exports/runtime.ts
3
3
  const pgvectorRuntimeDescriptor = {
4
4
  kind: "extension",
package/package.json CHANGED
@@ -1,39 +1,39 @@
1
1
  {
2
2
  "name": "@prisma-next/extension-pgvector",
3
- "version": "0.14.0-dev.76",
3
+ "version": "0.14.0-dev.78",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "dependencies": {
8
- "@prisma-next/contract": "0.14.0-dev.76",
9
- "@prisma-next/contract-authoring": "0.14.0-dev.76",
10
- "@prisma-next/family-sql": "0.14.0-dev.76",
11
- "@prisma-next/framework-components": "0.14.0-dev.76",
12
- "@prisma-next/migration-tools": "0.14.0-dev.76",
13
- "@prisma-next/sql-contract": "0.14.0-dev.76",
14
- "@prisma-next/sql-operations": "0.14.0-dev.76",
15
- "@prisma-next/sql-relational-core": "0.14.0-dev.76",
16
- "@prisma-next/sql-runtime": "0.14.0-dev.76",
17
- "@prisma-next/sql-schema-ir": "0.14.0-dev.76",
8
+ "@prisma-next/contract": "0.14.0-dev.78",
9
+ "@prisma-next/contract-authoring": "0.14.0-dev.78",
10
+ "@prisma-next/family-sql": "0.14.0-dev.78",
11
+ "@prisma-next/framework-components": "0.14.0-dev.78",
12
+ "@prisma-next/migration-tools": "0.14.0-dev.78",
13
+ "@prisma-next/sql-contract": "0.14.0-dev.78",
14
+ "@prisma-next/sql-operations": "0.14.0-dev.78",
15
+ "@prisma-next/sql-relational-core": "0.14.0-dev.78",
16
+ "@prisma-next/sql-runtime": "0.14.0-dev.78",
17
+ "@prisma-next/sql-schema-ir": "0.14.0-dev.78",
18
18
  "@standard-schema/spec": "^1.1.0",
19
19
  "arktype": "^2.2.2"
20
20
  },
21
21
  "devDependencies": {
22
- "@prisma-next/adapter-postgres": "0.14.0-dev.76",
23
- "@prisma-next/cli": "0.14.0-dev.76",
24
- "@prisma-next/operations": "0.14.0-dev.76",
25
- "@prisma-next/postgres": "0.14.0-dev.76",
26
- "@prisma-next/sql-contract-ts": "0.14.0-dev.76",
27
- "@prisma-next/target-postgres": "0.14.0-dev.76",
28
- "@prisma-next/test-utils": "0.14.0-dev.76",
29
- "@prisma-next/tsconfig": "0.14.0-dev.76",
30
- "@prisma-next/tsdown": "0.14.0-dev.76",
22
+ "@prisma-next/adapter-postgres": "0.14.0-dev.78",
23
+ "@prisma-next/cli": "0.14.0-dev.78",
24
+ "@prisma-next/operations": "0.14.0-dev.78",
25
+ "@prisma-next/postgres": "0.14.0-dev.78",
26
+ "@prisma-next/sql-contract-ts": "0.14.0-dev.78",
27
+ "@prisma-next/target-postgres": "0.14.0-dev.78",
28
+ "@prisma-next/test-utils": "0.14.0-dev.78",
29
+ "@prisma-next/tsconfig": "0.14.0-dev.78",
30
+ "@prisma-next/tsdown": "0.14.0-dev.78",
31
31
  "tsdown": "0.22.3",
32
32
  "typescript": "5.9.3",
33
33
  "vitest": "4.1.10"
34
34
  },
35
35
  "peerDependencies": {
36
- "@prisma-next/adapter-postgres": "0.14.0-dev.76",
36
+ "@prisma-next/adapter-postgres": "0.14.0-dev.78",
37
37
  "typescript": ">=5.9"
38
38
  },
39
39
  "peerDependenciesMeta": {
@@ -43,6 +43,22 @@ const vectorParamsSchema = arktype({
43
43
 
44
44
  const PG_VECTOR_META = { db: { sql: { postgres: { nativeType: 'vector' } } } } as const;
45
45
 
46
+ function parseVector(value: string): number[] {
47
+ if (!value.startsWith('[') || !value.endsWith(']')) {
48
+ throw new Error(`Invalid vector format: expected "[...]", got "${value}"`);
49
+ }
50
+ const content = value.slice(1, -1).trim();
51
+ return content === ''
52
+ ? []
53
+ : content.split(',').map((entry) => {
54
+ const number = Number.parseFloat(entry.trim());
55
+ if (Number.isNaN(number)) {
56
+ throw new Error(`Invalid vector value: "${entry}" is not a number`);
57
+ }
58
+ return number;
59
+ });
60
+ }
61
+
46
62
  export class PgVectorCodec extends CodecImpl<
47
63
  typeof VECTOR_CODEC_ID,
48
64
  readonly ['equality'],
@@ -60,8 +76,13 @@ export class PgVectorCodec extends CodecImpl<
60
76
  if (!Array.isArray(value)) {
61
77
  throw new Error('Vector value must be an array of numbers');
62
78
  }
63
- if (!value.every((v) => typeof v === 'number')) {
64
- throw new Error('Vector value must contain only numbers');
79
+ for (const element of value) {
80
+ if (typeof element !== 'number') {
81
+ throw new Error('Vector value must contain only numbers');
82
+ }
83
+ if (!Number.isFinite(element)) {
84
+ throw new Error('Vector value must contain only finite numbers');
85
+ }
65
86
  }
66
87
  if (value.length !== this.length) {
67
88
  throw new Error(`Vector length mismatch: expected ${this.length}, got ${value.length}`);
@@ -77,32 +98,23 @@ export class PgVectorCodec extends CodecImpl<
77
98
  if (typeof wire !== 'string') {
78
99
  throw new Error('Vector wire value must be a string');
79
100
  }
80
- if (!wire.startsWith('[') || !wire.endsWith(']')) {
81
- throw new Error(`Invalid vector format: expected "[...]", got "${wire}"`);
82
- }
83
- const content = wire.slice(1, -1).trim();
84
- const parsed =
85
- content === ''
86
- ? []
87
- : content.split(',').map((v) => {
88
- const num = Number.parseFloat(v.trim());
89
- if (Number.isNaN(num)) {
90
- throw new Error(`Invalid vector value: "${v}" is not a number`);
91
- }
92
- return num;
93
- });
94
- this.assertVector(parsed);
95
- return parsed;
101
+ const value = parseVector(wire);
102
+ this.assertVector(value);
103
+ return value;
96
104
  }
97
105
 
98
106
  encodeJson(value: number[]): JsonValue {
99
107
  this.assertVector(value);
100
- return value;
108
+ return `[${value.join(',')}]`;
101
109
  }
102
110
 
103
111
  decodeJson(json: JsonValue): number[] {
104
- this.assertVector(json);
105
- return json;
112
+ if (typeof json !== 'string') {
113
+ throw new Error('Vector database JSON value must be a string');
114
+ }
115
+ const value = parseVector(json);
116
+ this.assertVector(value);
117
+ return value;
106
118
  }
107
119
  }
108
120
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"descriptor-meta-Bv7s7XWG.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;\n\n constructor(descriptor: AnyCodecDescriptor, length: number) {\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 (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 override factory(params: VectorParams): (ctx: CodecInstanceContext) => PgVectorCodec {\n return () => new PgVectorCodec(this, params.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 {\n buildOperation,\n type CodecExpression,\n codecOf,\n type Expression,\n toExpr,\n} 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: (\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 selfCodec = codecOf(self);\n return buildOperation({\n method: 'cosineDistance',\n args: [toExpr(self, selfCodec), toExpr(other, selfCodec)],\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: (\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 selfCodec = codecOf(self);\n return buildOperation({\n method: 'cosineSimilarity',\n args: [toExpr(self, selfCodec), toExpr(other, selfCodec)],\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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