@prisma-next/extension-pgvector 0.3.0-dev.9 → 0.3.0-pr.100.2

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 CHANGED
@@ -8,7 +8,7 @@ This extension pack adds support for the `vector` data type and vector similarit
8
8
 
9
9
  ## Responsibilities
10
10
 
11
- - **Vector Codec**: Provides codec for `pg/vector@1` type ID mapping to `number[]` JavaScript type
11
+ - **Vector Codec**: Provides codec for `pg/vector@1` mapping to `number[]` at runtime, and a `Vector<N>` type for dimensioned typing in `contract.d.ts`
12
12
  - **Vector Operations**: Registers vector similarity operations (e.g., `cosineDistance`) for use in queries
13
13
  - **CLI Integration**: Provides extension descriptor for `prisma-next.config.ts` configuration
14
14
  - **Runtime Extension**: Registers codecs and operations at runtime for vector column operations
@@ -135,12 +135,16 @@ type Row = ResultType<typeof plan>;
135
135
 
136
136
  ### Codec Types
137
137
 
138
- The extension provides a `CodecTypes` export mapping the `pg/vector@1` type ID to `number[]`:
138
+ The extension provides:
139
+
140
+ - `CodecTypes` mapping the `pg/vector@1` type ID to `number[]` (runtime representation)
141
+ - `Vector<N>` type for dimensioned vector typing in emitted `contract.d.ts` and schema result types when the contract includes dimension metadata
139
142
 
140
143
  ```typescript
141
- import type { CodecTypes } from '@prisma-next/extension-pgvector/codec-types';
144
+ import type { CodecTypes, Vector } from '@prisma-next/extension-pgvector/codec-types';
142
145
 
143
146
  // CodecTypes['pg/vector@1']['output'] = number[]
147
+ // Vector<1536> is a branded number[] type used for dimensioned typing
144
148
  ```
145
149
 
146
150
  ### Operation Types
@@ -28,6 +28,19 @@ var pgvectorPackMeta = {
28
28
  package: "@prisma-next/extension-pgvector/codec-types",
29
29
  named: "CodecTypes",
30
30
  alias: "PgVectorTypes"
31
+ },
32
+ typeImports: [
33
+ {
34
+ package: "@prisma-next/extension-pgvector/codec-types",
35
+ named: "Vector",
36
+ alias: "Vector"
37
+ }
38
+ ],
39
+ // Parameterized codec renderers for type emission.
40
+ // The renderer template produces precise TypeScript types like Vector<1536>
41
+ // when columns have typeParams with a `length` property.
42
+ parameterized: {
43
+ [pgvectorTypeId]: "Vector<{{length}}>"
31
44
  }
32
45
  },
33
46
  operationTypes: {
@@ -57,4 +70,4 @@ export {
57
70
  pgvectorPackMeta,
58
71
  pgvectorRuntimeOperation
59
72
  };
60
- //# sourceMappingURL=chunk-SHWLERB3.js.map
73
+ //# sourceMappingURL=chunk-DSJTFXJR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/descriptor-meta.ts"],"sourcesContent":["import type { ExtensionPackRef } from '@prisma-next/contract/framework-components';\nimport type { SqlOperationSignature } from '@prisma-next/sql-operations';\n\nconst pgvectorTypeId = 'pg/vector@1' as const;\n\nconst cosineLowering = {\n targetFamily: 'sql',\n strategy: 'function',\n template: '1 - ({{self}} <=> {{arg0}})',\n} as const;\n\n/**\n * Shared operation definition used by both pack metadata and runtime descriptor.\n * Frozen to prevent accidental mutation.\n */\nconst cosineDistanceOperation = Object.freeze({\n method: 'cosineDistance',\n args: [{ kind: 'param' }],\n returns: { kind: 'builtin', type: 'number' },\n lowering: cosineLowering,\n} as const);\n\nexport const pgvectorPackMeta = {\n kind: 'extension',\n id: 'pgvector',\n familyId: 'sql',\n targetId: 'postgres',\n version: '0.0.1',\n capabilities: {\n postgres: {\n 'pgvector/cosine': true,\n },\n },\n types: {\n codecTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/codec-types',\n named: 'CodecTypes',\n alias: 'PgVectorTypes',\n },\n typeImports: [\n {\n package: '@prisma-next/extension-pgvector/codec-types',\n named: 'Vector',\n alias: 'Vector',\n },\n ],\n // Parameterized codec renderers for type emission.\n // The renderer template produces precise TypeScript types like Vector<1536>\n // when columns have typeParams with a `length` property.\n parameterized: {\n [pgvectorTypeId]: 'Vector<{{length}}>',\n },\n },\n operationTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/operation-types',\n named: 'OperationTypes',\n alias: 'PgVectorOperationTypes',\n },\n },\n storage: [\n { typeId: pgvectorTypeId, familyId: 'sql', targetId: 'postgres', nativeType: 'vector' },\n ],\n },\n operations: [\n {\n for: pgvectorTypeId,\n ...cosineDistanceOperation,\n },\n ],\n} as const satisfies ExtensionPackRef<'sql', 'postgres'>;\n\nexport const pgvectorRuntimeOperation: SqlOperationSignature = {\n forTypeId: pgvectorTypeId,\n ...cosineDistanceOperation,\n};\n"],"mappings":";AAGA,IAAM,iBAAiB;AAEvB,IAAM,iBAAiB;AAAA,EACrB,cAAc;AAAA,EACd,UAAU;AAAA,EACV,UAAU;AACZ;AAMA,IAAM,0BAA0B,OAAO,OAAO;AAAA,EAC5C,QAAQ;AAAA,EACR,MAAM,CAAC,EAAE,MAAM,QAAQ,CAAC;AAAA,EACxB,SAAS,EAAE,MAAM,WAAW,MAAM,SAAS;AAAA,EAC3C,UAAU;AACZ,CAAU;AAEH,IAAM,mBAAmB;AAAA,EAC9B,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,UAAU;AAAA,EACV,SAAS;AAAA,EACT,cAAc;AAAA,IACZ,UAAU;AAAA,MACR,mBAAmB;AAAA,IACrB;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IACL,YAAY;AAAA,MACV,QAAQ;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,OAAO;AAAA,MACT;AAAA,MACA,aAAa;AAAA,QACX;AAAA,UACE,SAAS;AAAA,UACT,OAAO;AAAA,UACP,OAAO;AAAA,QACT;AAAA,MACF;AAAA;AAAA;AAAA;AAAA,MAIA,eAAe;AAAA,QACb,CAAC,cAAc,GAAG;AAAA,MACpB;AAAA,IACF;AAAA,IACA,gBAAgB;AAAA,MACd,QAAQ;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,EAAE,QAAQ,gBAAgB,UAAU,OAAO,UAAU,YAAY,YAAY,SAAS;AAAA,IACxF;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV;AAAA,MACE,KAAK;AAAA,MACL,GAAG;AAAA,IACL;AAAA,EACF;AACF;AAEO,IAAM,2BAAkD;AAAA,EAC7D,WAAW;AAAA,EACX,GAAG;AACL;","names":[]}
@@ -17,6 +17,14 @@ export declare const pgvectorPackMeta: {
17
17
  readonly named: "CodecTypes";
18
18
  readonly alias: "PgVectorTypes";
19
19
  };
20
+ readonly typeImports: readonly [{
21
+ readonly package: "@prisma-next/extension-pgvector/codec-types";
22
+ readonly named: "Vector";
23
+ readonly alias: "Vector";
24
+ }];
25
+ readonly parameterized: {
26
+ readonly "pg/vector@1": "Vector<{{length}}>";
27
+ };
20
28
  };
21
29
  readonly operationTypes: {
22
30
  readonly import: {
@@ -1 +1 @@
1
- {"version":3,"file":"descriptor-meta.d.ts","sourceRoot":"","sources":["../../src/core/descriptor-meta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAqBzE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoC2B,CAAC;AAEzD,eAAO,MAAM,wBAAwB,EAAE,qBAGtC,CAAC"}
1
+ {"version":3,"file":"descriptor-meta.d.ts","sourceRoot":"","sources":["../../src/core/descriptor-meta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAqBzE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiD2B,CAAC;AAEzD,eAAO,MAAM,wBAAwB,EAAE,qBAGtC,CAAC"}
@@ -3,5 +3,5 @@
3
3
  *
4
4
  * Re-export from types module for public API.
5
5
  */
6
- export type { CodecTypes } from '../types/codec-types';
6
+ export type { CodecTypes, Vector } from '../types/codec-types';
7
7
  //# sourceMappingURL=codec-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codec-types.d.ts","sourceRoot":"","sources":["../../src/exports/codec-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"codec-types.d.ts","sourceRoot":"","sources":["../../src/exports/codec-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC"}
@@ -4,8 +4,30 @@
4
4
  * These descriptors provide both codecId and nativeType for use in contract authoring.
5
5
  * They are derived from the same source of truth as codec definitions and manifests.
6
6
  */
7
+ import type { ColumnTypeDescriptor } from '@prisma-next/contract-authoring';
8
+ /**
9
+ * Static vector column descriptor without dimension.
10
+ * Use `vector(N)` for dimensioned vectors that produce `vector(N)` DDL.
11
+ */
7
12
  export declare const vectorColumn: {
8
13
  readonly codecId: "pg/vector@1";
9
14
  readonly nativeType: "vector";
10
15
  };
16
+ /**
17
+ * Factory for creating dimensioned vector column descriptors.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * .column('embedding', { type: vector(1536), nullable: false })
22
+ * // Produces: nativeType: 'vector(1536)', typeParams: { length: 1536 }
23
+ * ```
24
+ *
25
+ * @param length - The dimension of the vector (e.g., 1536 for OpenAI embeddings)
26
+ * @returns A column type descriptor with `typeParams.length` set
27
+ */
28
+ export declare function vector<N extends number>(length: N): ColumnTypeDescriptor & {
29
+ readonly typeParams: {
30
+ readonly length: N;
31
+ };
32
+ };
11
33
  //# sourceMappingURL=column-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"column-types.d.ts","sourceRoot":"","sources":["../../src/exports/column-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,eAAO,MAAM,YAAY;;;CAGgB,CAAC"}
1
+ {"version":3,"file":"column-types.d.ts","sourceRoot":"","sources":["../../src/exports/column-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5E;;;GAGG;AACH,eAAO,MAAM,YAAY;;;CAGgB,CAAC;AAE1C;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EACrC,MAAM,EAAE,CAAC,GACR,oBAAoB,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;KAAE,CAAA;CAAE,CAMxE"}
@@ -3,7 +3,15 @@ var vectorColumn = {
3
3
  codecId: "pg/vector@1",
4
4
  nativeType: "vector"
5
5
  };
6
+ function vector(length) {
7
+ return {
8
+ codecId: "pg/vector@1",
9
+ nativeType: `vector(${length})`,
10
+ typeParams: { length }
11
+ };
12
+ }
6
13
  export {
14
+ vector,
7
15
  vectorColumn
8
16
  };
9
17
  //# sourceMappingURL=column-types.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/column-types.ts"],"sourcesContent":["/**\n * Column type descriptors for pgvector extension.\n *\n * These descriptors provide both codecId and nativeType for use in contract authoring.\n * They are derived from the same source of truth as codec definitions and manifests.\n */\n\nimport type { ColumnTypeDescriptor } from '@prisma-next/contract-authoring';\n\nexport const vectorColumn = {\n codecId: 'pg/vector@1',\n nativeType: 'vector',\n} as const satisfies ColumnTypeDescriptor;\n"],"mappings":";AASO,IAAM,eAAe;AAAA,EAC1B,SAAS;AAAA,EACT,YAAY;AACd;","names":[]}
1
+ {"version":3,"sources":["../../src/exports/column-types.ts"],"sourcesContent":["/**\n * Column type descriptors for pgvector extension.\n *\n * These descriptors provide both codecId and nativeType for use in contract authoring.\n * They are derived from the same source of truth as codec definitions and manifests.\n */\n\nimport type { ColumnTypeDescriptor } from '@prisma-next/contract-authoring';\n\n/**\n * Static vector column descriptor without dimension.\n * Use `vector(N)` for dimensioned vectors that produce `vector(N)` DDL.\n */\nexport const vectorColumn = {\n codecId: 'pg/vector@1',\n nativeType: 'vector',\n} as const satisfies ColumnTypeDescriptor;\n\n/**\n * Factory for creating dimensioned vector column descriptors.\n *\n * @example\n * ```typescript\n * .column('embedding', { type: vector(1536), nullable: false })\n * // Produces: nativeType: 'vector(1536)', typeParams: { length: 1536 }\n * ```\n *\n * @param length - The dimension of the vector (e.g., 1536 for OpenAI embeddings)\n * @returns A column type descriptor with `typeParams.length` set\n */\nexport function vector<N extends number>(\n length: N,\n): ColumnTypeDescriptor & { readonly typeParams: { readonly length: N } } {\n return {\n codecId: 'pg/vector@1',\n nativeType: `vector(${length})`,\n typeParams: { length },\n } as const;\n}\n"],"mappings":";AAaO,IAAM,eAAe;AAAA,EAC1B,SAAS;AAAA,EACT,YAAY;AACd;AAcO,SAAS,OACd,QACwE;AACxE,SAAO;AAAA,IACL,SAAS;AAAA,IACT,YAAY,UAAU,MAAM;AAAA,IAC5B,YAAY,EAAE,OAAO;AAAA,EACvB;AACF;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pgvectorPackMeta
3
- } from "../chunk-SHWLERB3.js";
3
+ } from "../chunk-DSJTFXJR.js";
4
4
 
5
5
  // src/exports/control.ts
6
6
  function verifyVectorExtensionInstalled(schema) {
@@ -16,6 +16,14 @@ declare const pgvectorPack: {
16
16
  readonly named: "CodecTypes";
17
17
  readonly alias: "PgVectorTypes";
18
18
  };
19
+ readonly typeImports: readonly [{
20
+ readonly package: "@prisma-next/extension-pgvector/codec-types";
21
+ readonly named: "Vector";
22
+ readonly alias: "Vector";
23
+ }];
24
+ readonly parameterized: {
25
+ readonly "pg/vector@1": "Vector<{{length}}>";
26
+ };
19
27
  };
20
28
  readonly operationTypes: {
21
29
  readonly import: {
@@ -1 +1 @@
1
- {"version":3,"file":"pack.d.ts","sourceRoot":"","sources":["../../src/exports/pack.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAmB,CAAC;AAEtC,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"pack.d.ts","sourceRoot":"","sources":["../../src/exports/pack.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAmB,CAAC;AAEtC,eAAe,YAAY,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pgvectorPackMeta
3
- } from "../chunk-SHWLERB3.js";
3
+ } from "../chunk-DSJTFXJR.js";
4
4
 
5
5
  // src/exports/pack.ts
6
6
  var pgvectorPack = pgvectorPackMeta;
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/exports/runtime.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,6BAA6B,EAE9B,MAAM,0BAA0B,CAAC;AA0BlC;;;GAGG;AACH,QAAA,MAAM,yBAAyB,EAAE,6BAA6B,CAAC,UAAU,CASxE,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/exports/runtime.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,6BAA6B,EAE9B,MAAM,0BAA0B,CAAC;AA2ClC;;;GAGG;AACH,QAAA,MAAM,yBAAyB,EAAE,6BAA6B,CAAC,UAAU,CASxE,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  pgvectorPackMeta,
3
3
  pgvectorRuntimeOperation
4
- } from "../chunk-SHWLERB3.js";
4
+ } from "../chunk-DSJTFXJR.js";
5
5
 
6
6
  // src/exports/runtime.ts
7
7
  import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
8
+ import { type as arktype } from "arktype";
8
9
 
9
10
  // src/core/codecs.ts
10
11
  import { codec, defineCodecs } from "@prisma-next/sql-relational-core/ast";
@@ -55,6 +56,10 @@ var codecDefinitions = codecs.codecDefinitions;
55
56
  var dataTypes = codecs.dataTypes;
56
57
 
57
58
  // src/exports/runtime.ts
59
+ var vectorTypeId = "pg/vector@1";
60
+ var vectorParamsSchema = arktype({
61
+ length: "number"
62
+ });
58
63
  var PgVectorRuntimeExtensionInstance = class {
59
64
  familyId = "sql";
60
65
  targetId = "postgres";
@@ -68,6 +73,14 @@ var PgVectorRuntimeExtensionInstance = class {
68
73
  operations() {
69
74
  return [pgvectorRuntimeOperation];
70
75
  }
76
+ parameterizedCodecs() {
77
+ return [
78
+ {
79
+ codecId: vectorTypeId,
80
+ paramsSchema: vectorParamsSchema
81
+ }
82
+ ];
83
+ }
71
84
  };
72
85
  var pgvectorRuntimeDescriptor = {
73
86
  kind: "extension",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/runtime.ts","../../src/core/codecs.ts"],"sourcesContent":["import type { SqlOperationSignature } from '@prisma-next/sql-operations';\nimport type { CodecRegistry } from '@prisma-next/sql-relational-core/ast';\nimport { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';\nimport type {\n SqlRuntimeExtensionDescriptor,\n SqlRuntimeExtensionInstance,\n} from '@prisma-next/sql-runtime';\nimport { codecDefinitions } from '../core/codecs';\nimport { pgvectorPackMeta, pgvectorRuntimeOperation } from '../core/descriptor-meta';\n\n/**\n * pgvector SQL runtime extension instance.\n * Provides codecs and operations for vector data type and similarity operations.\n */\nclass PgVectorRuntimeExtensionInstance implements SqlRuntimeExtensionInstance<'postgres'> {\n readonly familyId = 'sql' as const;\n readonly targetId = 'postgres' as const;\n\n codecs(): CodecRegistry {\n const registry = createCodecRegistry();\n // Register all codecs from codecDefinitions\n for (const def of Object.values(codecDefinitions)) {\n registry.register(def.codec);\n }\n return registry;\n }\n\n operations(): ReadonlyArray<SqlOperationSignature> {\n return [pgvectorRuntimeOperation];\n }\n}\n\n/**\n * pgvector SQL runtime extension descriptor.\n * Provides metadata and factory for creating runtime extension instances.\n */\nconst pgvectorRuntimeDescriptor: SqlRuntimeExtensionDescriptor<'postgres'> = {\n kind: 'extension' as const,\n id: pgvectorPackMeta.id,\n version: pgvectorPackMeta.version,\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n create(): SqlRuntimeExtensionInstance<'postgres'> {\n return new PgVectorRuntimeExtensionInstance();\n },\n};\n\nexport default pgvectorRuntimeDescriptor;\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<'pg/vector@1', string, number[]>({\n typeId: 'pg/vector@1',\n targetTypes: ['vector'],\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"],"mappings":";;;;;;AAEA,SAAS,2BAA2B;;;ACKpC,SAAS,OAAO,oBAAoB;AAEpC,IAAM,gBAAgB,MAAuC;AAAA,EAC3D,QAAQ;AAAA,EACR,aAAa,CAAC,QAAQ;AAAA,EACtB,QAAQ,CAAC,UAA4B;AAEnC,QAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AACzB,YAAM,IAAI,MAAM,0CAA0C;AAAA,IAC5D;AACA,QAAI,CAAC,MAAM,MAAM,CAAC,MAAM,OAAO,MAAM,QAAQ,GAAG;AAC9C,YAAM,IAAI,MAAM,wCAAwC;AAAA,IAC1D;AAGA,WAAO,IAAI,MAAM,KAAK,GAAG,CAAC;AAAA,EAC5B;AAAA,EACA,QAAQ,CAAC,SAA2B;AAElC,QAAI,OAAO,SAAS,UAAU;AAC5B,YAAM,IAAI,MAAM,oCAAoC;AAAA,IACtD;AAEA,QAAI,CAAC,KAAK,WAAW,GAAG,KAAK,CAAC,KAAK,SAAS,GAAG,GAAG;AAChD,YAAM,IAAI,MAAM,iDAAiD,IAAI,GAAG;AAAA,IAC1E;AACA,UAAM,UAAU,KAAK,MAAM,GAAG,EAAE,EAAE,KAAK;AACvC,QAAI,YAAY,IAAI;AAClB,aAAO,CAAC;AAAA,IACV;AACA,UAAM,SAAS,QAAQ,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM;AAC3C,YAAM,MAAM,OAAO,WAAW,EAAE,KAAK,CAAC;AACtC,UAAI,OAAO,MAAM,GAAG,GAAG;AACrB,cAAM,IAAI,MAAM,0BAA0B,CAAC,mBAAmB;AAAA,MAChE;AACA,aAAO;AAAA,IACT,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EACA,MAAM;AAAA,IACJ,IAAI;AAAA,MACF,KAAK;AAAA,QACH,UAAU;AAAA,UACR,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAGD,IAAM,SAAS,aAAa,EAAE,IAAI,UAAU,aAAa;AAGlD,IAAM,mBAAmB,OAAO;AAChC,IAAM,YAAY,OAAO;;;ADhDhC,IAAM,mCAAN,MAA0F;AAAA,EAC/E,WAAW;AAAA,EACX,WAAW;AAAA,EAEpB,SAAwB;AACtB,UAAM,WAAW,oBAAoB;AAErC,eAAW,OAAO,OAAO,OAAO,gBAAgB,GAAG;AACjD,eAAS,SAAS,IAAI,KAAK;AAAA,IAC7B;AACA,WAAO;AAAA,EACT;AAAA,EAEA,aAAmD;AACjD,WAAO,CAAC,wBAAwB;AAAA,EAClC;AACF;AAMA,IAAM,4BAAuE;AAAA,EAC3E,MAAM;AAAA,EACN,IAAI,iBAAiB;AAAA,EACrB,SAAS,iBAAiB;AAAA,EAC1B,UAAU;AAAA,EACV,UAAU;AAAA,EACV,SAAkD;AAChD,WAAO,IAAI,iCAAiC;AAAA,EAC9C;AACF;AAEA,IAAO,kBAAQ;","names":[]}
1
+ {"version":3,"sources":["../../src/exports/runtime.ts","../../src/core/codecs.ts"],"sourcesContent":["import type { SqlOperationSignature } from '@prisma-next/sql-operations';\nimport type { CodecRegistry } from '@prisma-next/sql-relational-core/ast';\nimport { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';\nimport type {\n RuntimeParameterizedCodecDescriptor,\n SqlRuntimeExtensionDescriptor,\n SqlRuntimeExtensionInstance,\n} from '@prisma-next/sql-runtime';\nimport { type as arktype } from 'arktype';\nimport { codecDefinitions } from '../core/codecs';\nimport { pgvectorPackMeta, pgvectorRuntimeOperation } from '../core/descriptor-meta';\n\nconst vectorTypeId = 'pg/vector@1' as const;\nconst vectorParamsSchema = arktype({\n length: 'number',\n});\n\n/**\n * pgvector SQL runtime extension instance.\n * Provides codecs and operations for vector data type and similarity operations.\n */\nclass PgVectorRuntimeExtensionInstance implements SqlRuntimeExtensionInstance<'postgres'> {\n readonly familyId = 'sql' as const;\n readonly targetId = 'postgres' as const;\n\n codecs(): CodecRegistry {\n const registry = createCodecRegistry();\n // Register all codecs from codecDefinitions\n for (const def of Object.values(codecDefinitions)) {\n registry.register(def.codec);\n }\n return registry;\n }\n\n operations(): ReadonlyArray<SqlOperationSignature> {\n return [pgvectorRuntimeOperation];\n }\n\n parameterizedCodecs(): ReadonlyArray<\n RuntimeParameterizedCodecDescriptor<{ readonly length: number }>\n > {\n return [\n {\n codecId: vectorTypeId,\n paramsSchema: vectorParamsSchema,\n },\n ];\n }\n}\n\n/**\n * pgvector SQL runtime extension descriptor.\n * Provides metadata and factory for creating runtime extension instances.\n */\nconst pgvectorRuntimeDescriptor: SqlRuntimeExtensionDescriptor<'postgres'> = {\n kind: 'extension' as const,\n id: pgvectorPackMeta.id,\n version: pgvectorPackMeta.version,\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n create(): SqlRuntimeExtensionInstance<'postgres'> {\n return new PgVectorRuntimeExtensionInstance();\n },\n};\n\nexport default pgvectorRuntimeDescriptor;\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<'pg/vector@1', string, number[]>({\n typeId: 'pg/vector@1',\n targetTypes: ['vector'],\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"],"mappings":";;;;;;AAEA,SAAS,2BAA2B;AAMpC,SAAS,QAAQ,eAAe;;;ACDhC,SAAS,OAAO,oBAAoB;AAEpC,IAAM,gBAAgB,MAAuC;AAAA,EAC3D,QAAQ;AAAA,EACR,aAAa,CAAC,QAAQ;AAAA,EACtB,QAAQ,CAAC,UAA4B;AAEnC,QAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AACzB,YAAM,IAAI,MAAM,0CAA0C;AAAA,IAC5D;AACA,QAAI,CAAC,MAAM,MAAM,CAAC,MAAM,OAAO,MAAM,QAAQ,GAAG;AAC9C,YAAM,IAAI,MAAM,wCAAwC;AAAA,IAC1D;AAGA,WAAO,IAAI,MAAM,KAAK,GAAG,CAAC;AAAA,EAC5B;AAAA,EACA,QAAQ,CAAC,SAA2B;AAElC,QAAI,OAAO,SAAS,UAAU;AAC5B,YAAM,IAAI,MAAM,oCAAoC;AAAA,IACtD;AAEA,QAAI,CAAC,KAAK,WAAW,GAAG,KAAK,CAAC,KAAK,SAAS,GAAG,GAAG;AAChD,YAAM,IAAI,MAAM,iDAAiD,IAAI,GAAG;AAAA,IAC1E;AACA,UAAM,UAAU,KAAK,MAAM,GAAG,EAAE,EAAE,KAAK;AACvC,QAAI,YAAY,IAAI;AAClB,aAAO,CAAC;AAAA,IACV;AACA,UAAM,SAAS,QAAQ,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM;AAC3C,YAAM,MAAM,OAAO,WAAW,EAAE,KAAK,CAAC;AACtC,UAAI,OAAO,MAAM,GAAG,GAAG;AACrB,cAAM,IAAI,MAAM,0BAA0B,CAAC,mBAAmB;AAAA,MAChE;AACA,aAAO;AAAA,IACT,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EACA,MAAM;AAAA,IACJ,IAAI;AAAA,MACF,KAAK;AAAA,QACH,UAAU;AAAA,UACR,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAGD,IAAM,SAAS,aAAa,EAAE,IAAI,UAAU,aAAa;AAGlD,IAAM,mBAAmB,OAAO;AAChC,IAAM,YAAY,OAAO;;;ADlDhC,IAAM,eAAe;AACrB,IAAM,qBAAqB,QAAQ;AAAA,EACjC,QAAQ;AACV,CAAC;AAMD,IAAM,mCAAN,MAA0F;AAAA,EAC/E,WAAW;AAAA,EACX,WAAW;AAAA,EAEpB,SAAwB;AACtB,UAAM,WAAW,oBAAoB;AAErC,eAAW,OAAO,OAAO,OAAO,gBAAgB,GAAG;AACjD,eAAS,SAAS,IAAI,KAAK;AAAA,IAC7B;AACA,WAAO;AAAA,EACT;AAAA,EAEA,aAAmD;AACjD,WAAO,CAAC,wBAAwB;AAAA,EAClC;AAAA,EAEA,sBAEE;AACA,WAAO;AAAA,MACL;AAAA,QACE,SAAS;AAAA,QACT,cAAc;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;AAMA,IAAM,4BAAuE;AAAA,EAC3E,MAAM;AAAA,EACN,IAAI,iBAAiB;AAAA,EACrB,SAAS,iBAAiB;AAAA,EAC1B,UAAU;AAAA,EACV,UAAU;AAAA,EACV,SAAkD;AAChD,WAAO,IAAI,iCAAiC;AAAA,EAC9C;AACF;AAEA,IAAO,kBAAQ;","names":[]}
@@ -6,5 +6,29 @@
6
6
  *
7
7
  * Runtime codec implementations are provided by the extension's codec registry.
8
8
  */
9
- export type { CodecTypes } from '../core/codecs';
9
+ import type { CodecTypes as CoreCodecTypes } from '../core/codecs';
10
+ /**
11
+ * Type-level branded vector.
12
+ *
13
+ * The runtime values are plain number arrays, but parameterized column typing can
14
+ * carry the dimension at the type level (e.g. Vector<1536>).
15
+ */
16
+ export type Vector<N extends number = number> = number[] & {
17
+ readonly __vectorLength?: N;
18
+ };
19
+ /**
20
+ * Codec types for pgvector.
21
+ *
22
+ * - Scalar output remains `number[]` (runtime representation).
23
+ * - `parameterizedOutput` enables lane typing to compute `Vector<N>` from column `typeParams`.
24
+ */
25
+ export type CodecTypes = CoreCodecTypes & {
26
+ readonly 'pg/vector@1': CoreCodecTypes['pg/vector@1'] & {
27
+ readonly parameterizedOutput: <P extends {
28
+ readonly length: number;
29
+ }>(params: P) => P extends {
30
+ readonly length: infer N extends number;
31
+ } ? Vector<N> : Vector<number>;
32
+ };
33
+ };
10
34
  //# sourceMappingURL=codec-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codec-types.d.ts","sourceRoot":"","sources":["../../src/types/codec-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"codec-types.d.ts","sourceRoot":"","sources":["../../src/types/codec-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,EAAE,GAAG;IAAE,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC;AAE3F;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG;IACxC,QAAQ,CAAC,aAAa,EAAE,cAAc,CAAC,aAAa,CAAC,GAAG;QACtD,QAAQ,CAAC,mBAAmB,EAAE,CAAC,CAAC,SAAS;YAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;SAAE,EAClE,MAAM,EAAE,CAAC,KACN,CAAC,SAAS;YAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,SAAS,MAAM,CAAA;SAAE,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;KACzF,CAAC;CACH,CAAC"}
package/package.json CHANGED
@@ -1,31 +1,31 @@
1
1
  {
2
2
  "name": "@prisma-next/extension-pgvector",
3
- "version": "0.3.0-dev.9",
3
+ "version": "0.3.0-pr.100.2",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "dependencies": {
7
7
  "arktype": "^2.0.0",
8
- "@prisma-next/cli": "0.3.0-dev.9",
9
- "@prisma-next/contract": "0.3.0-dev.9",
10
- "@prisma-next/contract-authoring": "0.3.0-dev.9",
11
- "@prisma-next/core-control-plane": "0.3.0-dev.9",
12
- "@prisma-next/family-sql": "0.3.0-dev.9",
13
- "@prisma-next/sql-operations": "0.3.0-dev.9",
14
- "@prisma-next/sql-relational-core": "0.3.0-dev.9",
15
- "@prisma-next/sql-schema-ir": "0.3.0-dev.9",
16
- "@prisma-next/sql-runtime": "0.3.0-dev.9"
8
+ "@prisma-next/cli": "0.3.0-pr.100.2",
9
+ "@prisma-next/contract-authoring": "0.3.0-pr.100.2",
10
+ "@prisma-next/core-control-plane": "0.3.0-pr.100.2",
11
+ "@prisma-next/family-sql": "0.3.0-pr.100.2",
12
+ "@prisma-next/sql-operations": "0.3.0-pr.100.2",
13
+ "@prisma-next/sql-relational-core": "0.3.0-pr.100.2",
14
+ "@prisma-next/sql-runtime": "0.3.0-pr.100.2",
15
+ "@prisma-next/sql-schema-ir": "0.3.0-pr.100.2",
16
+ "@prisma-next/contract": "0.3.0-pr.100.2"
17
17
  },
18
18
  "devDependencies": {
19
- "@vitest/coverage-v8": "4.0.16",
20
19
  "tsup": "8.5.1",
21
20
  "typescript": "5.9.3",
22
21
  "vitest": "4.0.16",
23
- "@prisma-next/adapter-postgres": "0.3.0-dev.9",
24
- "@prisma-next/operations": "0.3.0-dev.9",
25
- "@prisma-next/sql-contract": "0.3.0-dev.9",
26
- "@prisma-next/sql-contract-ts": "0.3.0-dev.9",
27
- "@prisma-next/sql-lane": "0.3.0-dev.9",
28
- "@prisma-next/test-utils": "0.0.1"
22
+ "@prisma-next/adapter-postgres": "0.3.0-pr.100.2",
23
+ "@prisma-next/operations": "0.3.0-pr.100.2",
24
+ "@prisma-next/sql-contract": "0.3.0-pr.100.2",
25
+ "@prisma-next/sql-contract-ts": "0.3.0-pr.100.2",
26
+ "@prisma-next/sql-lane": "0.3.0-pr.100.2",
27
+ "@prisma-next/test-utils": "0.0.1",
28
+ "@prisma-next/tsconfig": "0.0.0"
29
29
  },
30
30
  "files": [
31
31
  "dist",
@@ -63,9 +63,9 @@
63
63
  "test": "vitest run",
64
64
  "test:coverage": "vitest run --coverage",
65
65
  "typecheck": "tsc --project tsconfig.json --noEmit",
66
- "lint": "biome check . --config-path ../../../biome.json --error-on-warnings",
67
- "lint:fix": "biome check --write . --config-path ../../../biome.json",
68
- "lint:fix:unsafe": "biome check --write --unsafe . --config-path ../../../biome.json",
69
- "clean": "node ../../../scripts/clean.mjs"
66
+ "lint": "biome check . --error-on-warnings",
67
+ "lint:fix": "biome check --write .",
68
+ "lint:fix:unsafe": "biome check --write --unsafe .",
69
+ "clean": "rm -rf dist dist-tsc dist-tsc-prod coverage .tmp-output"
70
70
  }
71
71
  }
@@ -38,6 +38,19 @@ export const pgvectorPackMeta = {
38
38
  named: 'CodecTypes',
39
39
  alias: 'PgVectorTypes',
40
40
  },
41
+ typeImports: [
42
+ {
43
+ package: '@prisma-next/extension-pgvector/codec-types',
44
+ named: 'Vector',
45
+ alias: 'Vector',
46
+ },
47
+ ],
48
+ // Parameterized codec renderers for type emission.
49
+ // The renderer template produces precise TypeScript types like Vector<1536>
50
+ // when columns have typeParams with a `length` property.
51
+ parameterized: {
52
+ [pgvectorTypeId]: 'Vector<{{length}}>',
53
+ },
41
54
  },
42
55
  operationTypes: {
43
56
  import: {
@@ -4,4 +4,4 @@
4
4
  * Re-export from types module for public API.
5
5
  */
6
6
 
7
- export type { CodecTypes } from '../types/codec-types';
7
+ export type { CodecTypes, Vector } from '../types/codec-types';
@@ -7,7 +7,33 @@
7
7
 
8
8
  import type { ColumnTypeDescriptor } from '@prisma-next/contract-authoring';
9
9
 
10
+ /**
11
+ * Static vector column descriptor without dimension.
12
+ * Use `vector(N)` for dimensioned vectors that produce `vector(N)` DDL.
13
+ */
10
14
  export const vectorColumn = {
11
15
  codecId: 'pg/vector@1',
12
16
  nativeType: 'vector',
13
17
  } as const satisfies ColumnTypeDescriptor;
18
+
19
+ /**
20
+ * Factory for creating dimensioned vector column descriptors.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * .column('embedding', { type: vector(1536), nullable: false })
25
+ * // Produces: nativeType: 'vector(1536)', typeParams: { length: 1536 }
26
+ * ```
27
+ *
28
+ * @param length - The dimension of the vector (e.g., 1536 for OpenAI embeddings)
29
+ * @returns A column type descriptor with `typeParams.length` set
30
+ */
31
+ export function vector<N extends number>(
32
+ length: N,
33
+ ): ColumnTypeDescriptor & { readonly typeParams: { readonly length: N } } {
34
+ return {
35
+ codecId: 'pg/vector@1',
36
+ nativeType: `vector(${length})`,
37
+ typeParams: { length },
38
+ } as const;
39
+ }
@@ -2,12 +2,19 @@ import type { SqlOperationSignature } from '@prisma-next/sql-operations';
2
2
  import type { CodecRegistry } from '@prisma-next/sql-relational-core/ast';
3
3
  import { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';
4
4
  import type {
5
+ RuntimeParameterizedCodecDescriptor,
5
6
  SqlRuntimeExtensionDescriptor,
6
7
  SqlRuntimeExtensionInstance,
7
8
  } from '@prisma-next/sql-runtime';
9
+ import { type as arktype } from 'arktype';
8
10
  import { codecDefinitions } from '../core/codecs';
9
11
  import { pgvectorPackMeta, pgvectorRuntimeOperation } from '../core/descriptor-meta';
10
12
 
13
+ const vectorTypeId = 'pg/vector@1' as const;
14
+ const vectorParamsSchema = arktype({
15
+ length: 'number',
16
+ });
17
+
11
18
  /**
12
19
  * pgvector SQL runtime extension instance.
13
20
  * Provides codecs and operations for vector data type and similarity operations.
@@ -28,6 +35,17 @@ class PgVectorRuntimeExtensionInstance implements SqlRuntimeExtensionInstance<'p
28
35
  operations(): ReadonlyArray<SqlOperationSignature> {
29
36
  return [pgvectorRuntimeOperation];
30
37
  }
38
+
39
+ parameterizedCodecs(): ReadonlyArray<
40
+ RuntimeParameterizedCodecDescriptor<{ readonly length: number }>
41
+ > {
42
+ return [
43
+ {
44
+ codecId: vectorTypeId,
45
+ paramsSchema: vectorParamsSchema,
46
+ },
47
+ ];
48
+ }
31
49
  }
32
50
 
33
51
  /**
@@ -7,4 +7,26 @@
7
7
  * Runtime codec implementations are provided by the extension's codec registry.
8
8
  */
9
9
 
10
- export type { CodecTypes } from '../core/codecs';
10
+ import type { CodecTypes as CoreCodecTypes } from '../core/codecs';
11
+
12
+ /**
13
+ * Type-level branded vector.
14
+ *
15
+ * The runtime values are plain number arrays, but parameterized column typing can
16
+ * carry the dimension at the type level (e.g. Vector<1536>).
17
+ */
18
+ export type Vector<N extends number = number> = number[] & { readonly __vectorLength?: N };
19
+
20
+ /**
21
+ * Codec types for pgvector.
22
+ *
23
+ * - Scalar output remains `number[]` (runtime representation).
24
+ * - `parameterizedOutput` enables lane typing to compute `Vector<N>` from column `typeParams`.
25
+ */
26
+ export type CodecTypes = CoreCodecTypes & {
27
+ readonly 'pg/vector@1': CoreCodecTypes['pg/vector@1'] & {
28
+ readonly parameterizedOutput: <P extends { readonly length: number }>(
29
+ params: P,
30
+ ) => P extends { readonly length: infer N extends number } ? Vector<N> : Vector<number>;
31
+ };
32
+ };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/descriptor-meta.ts"],"sourcesContent":["import type { ExtensionPackRef } from '@prisma-next/contract/framework-components';\nimport type { SqlOperationSignature } from '@prisma-next/sql-operations';\n\nconst pgvectorTypeId = 'pg/vector@1' as const;\n\nconst cosineLowering = {\n targetFamily: 'sql',\n strategy: 'function',\n template: '1 - ({{self}} <=> {{arg0}})',\n} as const;\n\n/**\n * Shared operation definition used by both pack metadata and runtime descriptor.\n * Frozen to prevent accidental mutation.\n */\nconst cosineDistanceOperation = Object.freeze({\n method: 'cosineDistance',\n args: [{ kind: 'param' }],\n returns: { kind: 'builtin', type: 'number' },\n lowering: cosineLowering,\n} as const);\n\nexport const pgvectorPackMeta = {\n kind: 'extension',\n id: 'pgvector',\n familyId: 'sql',\n targetId: 'postgres',\n version: '0.0.1',\n capabilities: {\n postgres: {\n 'pgvector/cosine': true,\n },\n },\n types: {\n codecTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/codec-types',\n named: 'CodecTypes',\n alias: 'PgVectorTypes',\n },\n },\n operationTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/operation-types',\n named: 'OperationTypes',\n alias: 'PgVectorOperationTypes',\n },\n },\n storage: [\n { typeId: pgvectorTypeId, familyId: 'sql', targetId: 'postgres', nativeType: 'vector' },\n ],\n },\n operations: [\n {\n for: pgvectorTypeId,\n ...cosineDistanceOperation,\n },\n ],\n} as const satisfies ExtensionPackRef<'sql', 'postgres'>;\n\nexport const pgvectorRuntimeOperation: SqlOperationSignature = {\n forTypeId: pgvectorTypeId,\n ...cosineDistanceOperation,\n};\n"],"mappings":";AAGA,IAAM,iBAAiB;AAEvB,IAAM,iBAAiB;AAAA,EACrB,cAAc;AAAA,EACd,UAAU;AAAA,EACV,UAAU;AACZ;AAMA,IAAM,0BAA0B,OAAO,OAAO;AAAA,EAC5C,QAAQ;AAAA,EACR,MAAM,CAAC,EAAE,MAAM,QAAQ,CAAC;AAAA,EACxB,SAAS,EAAE,MAAM,WAAW,MAAM,SAAS;AAAA,EAC3C,UAAU;AACZ,CAAU;AAEH,IAAM,mBAAmB;AAAA,EAC9B,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,UAAU;AAAA,EACV,SAAS;AAAA,EACT,cAAc;AAAA,IACZ,UAAU;AAAA,MACR,mBAAmB;AAAA,IACrB;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IACL,YAAY;AAAA,MACV,QAAQ;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,gBAAgB;AAAA,MACd,QAAQ;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,EAAE,QAAQ,gBAAgB,UAAU,OAAO,UAAU,YAAY,YAAY,SAAS;AAAA,IACxF;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV;AAAA,MACE,KAAK;AAAA,MACL,GAAG;AAAA,IACL;AAAA,EACF;AACF;AAEO,IAAM,2BAAkD;AAAA,EAC7D,WAAW;AAAA,EACX,GAAG;AACL;","names":[]}