@prisma-next/extension-pgvector 0.4.0-dev.6 → 0.4.0-dev.8
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-CHj8SCio.mjs → descriptor-meta-BQbvJJxu.mjs} +3 -2
- package/dist/descriptor-meta-BQbvJJxu.mjs.map +1 -0
- package/dist/pack.d.mts +3 -6
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +2 -8
- package/dist/runtime.mjs +1 -1
- package/package.json +14 -14
- package/src/core/descriptor-meta.ts +6 -1
- package/src/exports/pack.ts +1 -10
- package/dist/descriptor-meta-CHj8SCio.mjs.map +0 -1
- package/dist/pack.mjs.map +0 -1
package/dist/control.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as pgvectorQueryOperations, t as pgvectorPackMeta } from "./descriptor-meta-
|
|
1
|
+
import { n as pgvectorQueryOperations, t as pgvectorPackMeta } from "./descriptor-meta-BQbvJJxu.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/exports/control.ts
|
|
4
4
|
const PGVECTOR_CODEC_ID = "pg/vector@1";
|
|
@@ -101,7 +101,7 @@ const pgvectorQueryOperations = [{
|
|
|
101
101
|
template: "1 - ({{self}} <=> {{arg0}})"
|
|
102
102
|
}
|
|
103
103
|
}];
|
|
104
|
-
const
|
|
104
|
+
const pgvectorPackMetaBase = {
|
|
105
105
|
kind: "extension",
|
|
106
106
|
id: "pgvector",
|
|
107
107
|
familyId: "sql",
|
|
@@ -141,7 +141,8 @@ const pgvectorPackMeta = {
|
|
|
141
141
|
}]
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
|
+
const pgvectorPackMeta = pgvectorPackMetaBase;
|
|
144
145
|
|
|
145
146
|
//#endregion
|
|
146
147
|
export { pgvectorQueryOperations as n, codecDefinitions as r, pgvectorPackMeta as t };
|
|
147
|
-
//# sourceMappingURL=descriptor-meta-
|
|
148
|
+
//# sourceMappingURL=descriptor-meta-BQbvJJxu.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-meta-BQbvJJxu.mjs","names":["pgvectorQueryOperations: readonly SqlOperationDescriptor[]","pgvectorPackMeta: typeof pgvectorPackMetaBase & {\n readonly __codecTypes?: CodecTypes;\n}"],"sources":["../src/core/authoring.ts","../src/core/codecs.ts","../src/core/descriptor-meta.ts"],"sourcesContent":["import type { AuthoringTypeNamespace } from '@prisma-next/framework-components/authoring';\nimport { VECTOR_MAX_DIM } from './constants';\n\nexport const pgvectorAuthoringTypes = {\n pgvector: {\n Vector: {\n kind: 'typeConstructor',\n args: [\n { kind: 'number', name: 'length', integer: true, minimum: 1, maximum: VECTOR_MAX_DIM },\n ],\n output: {\n codecId: 'pg/vector@1',\n nativeType: 'vector',\n typeParams: {\n length: { kind: 'arg', index: 0 },\n },\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n","/**\n * Vector codec implementation for pgvector extension.\n *\n * Provides encoding/decoding for the `vector` PostgreSQL type.\n * Wire format is a string like `[1,2,3]` (PostgreSQL vector text format).\n */\n\nimport { codec, defineCodecs } from '@prisma-next/sql-relational-core/ast';\n\nconst pgVectorCodec = codec({\n typeId: 'pg/vector@1',\n targetTypes: ['vector'],\n traits: ['equality'],\n renderOutputType: (typeParams) => {\n const length = typeParams['length'];\n if (length === undefined) return undefined;\n if (typeof length !== 'number' || !Number.isFinite(length) || !Number.isInteger(length)) {\n throw new Error(\n `renderOutputType: expected positive integer \"length\" in typeParams for Vector, got ${String(length)}`,\n );\n }\n return `Vector<${length}>`;\n },\n encode: (value: number[]): string => {\n // Validate that value is an array of numbers\n if (!Array.isArray(value)) {\n throw new Error('Vector value must be an array of numbers');\n }\n if (!value.every((v) => typeof v === 'number')) {\n throw new Error('Vector value must contain only numbers');\n }\n // Format as PostgreSQL vector text format: [1,2,3]\n // PostgreSQL's pg library requires the vector format string\n return `[${value.join(',')}]`;\n },\n decode: (wire: string): number[] => {\n // Handle string format from PostgreSQL: [1,2,3]\n if (typeof wire !== 'string') {\n throw new Error('Vector wire value must be a string');\n }\n // Parse PostgreSQL vector format: [1,2,3]\n if (!wire.startsWith('[') || !wire.endsWith(']')) {\n throw new Error(`Invalid vector format: expected \"[...]\", got \"${wire}\"`);\n }\n const content = wire.slice(1, -1).trim();\n if (content === '') {\n return [];\n }\n const values = content.split(',').map((v) => {\n const num = Number.parseFloat(v.trim());\n if (Number.isNaN(num)) {\n throw new Error(`Invalid vector value: \"${v}\" is not a number`);\n }\n return num;\n });\n return values;\n },\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'vector',\n },\n },\n },\n },\n});\n\n// Build codec definitions using the builder DSL\nconst codecs = defineCodecs().add('vector', pgVectorCodec);\n\n// Export derived structures directly from codecs builder\nexport const codecDefinitions = codecs.codecDefinitions;\nexport const dataTypes = codecs.dataTypes;\n\n// Export types derived from codecs builder\nexport type CodecTypes = typeof codecs.CodecTypes;\n","import type { SqlOperationDescriptor } from '@prisma-next/sql-operations';\nimport type { CodecTypes } from '../types/codec-types';\nimport { pgvectorAuthoringTypes } from './authoring';\nimport { codecDefinitions } from './codecs';\n\nconst pgvectorTypeId = 'pg/vector@1' as const;\n\nexport const pgvectorQueryOperations: readonly SqlOperationDescriptor[] = [\n {\n method: 'cosineDistance',\n args: [\n { codecId: pgvectorTypeId, nullable: false },\n { codecId: pgvectorTypeId, nullable: false },\n ],\n returns: { codecId: 'pg/float8@1', nullable: false },\n lowering: {\n targetFamily: 'sql',\n strategy: 'function',\n template: '{{self}} <=> {{arg0}}',\n },\n },\n {\n method: 'cosineSimilarity',\n args: [\n { codecId: pgvectorTypeId, nullable: false },\n { codecId: pgvectorTypeId, nullable: false },\n ],\n returns: { codecId: 'pg/float8@1', nullable: false },\n lowering: {\n targetFamily: 'sql',\n strategy: 'function',\n template: '1 - ({{self}} <=> {{arg0}})',\n },\n },\n];\n\nconst pgvectorPackMetaBase = {\n kind: 'extension',\n id: 'pgvector',\n familyId: 'sql',\n targetId: 'postgres',\n version: '0.0.1',\n capabilities: {\n postgres: {\n 'pgvector.cosine': true,\n },\n },\n authoring: {\n type: pgvectorAuthoringTypes,\n },\n types: {\n codecTypes: {\n codecInstances: Object.values(codecDefinitions).map((def) => def.codec),\n import: {\n package: '@prisma-next/extension-pgvector/codec-types',\n named: 'CodecTypes',\n alias: 'PgVectorTypes',\n },\n typeImports: [\n {\n package: '@prisma-next/extension-pgvector/codec-types',\n named: 'Vector',\n alias: 'Vector',\n },\n ],\n },\n operationTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/operation-types',\n named: 'OperationTypes',\n alias: 'PgVectorOperationTypes',\n },\n },\n queryOperationTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/operation-types',\n named: 'QueryOperationTypes',\n alias: 'PgVectorQueryOperationTypes',\n },\n },\n storage: [\n { typeId: pgvectorTypeId, familyId: 'sql', targetId: 'postgres', nativeType: 'vector' },\n ],\n },\n} as const;\n\nexport const pgvectorPackMeta: typeof pgvectorPackMetaBase & {\n readonly __codecTypes?: CodecTypes;\n} = pgvectorPackMetaBase;\n"],"mappings":";;;;AAGA,MAAa,yBAAyB,EACpC,UAAU,EACR,QAAQ;CACN,MAAM;CACN,MAAM,CACJ;EAAE,MAAM;EAAU,MAAM;EAAU,SAAS;EAAM,SAAS;EAAG,SAAS;EAAgB,CACvF;CACD,QAAQ;EACN,SAAS;EACT,YAAY;EACZ,YAAY,EACV,QAAQ;GAAE,MAAM;GAAO,OAAO;GAAG,EAClC;EACF;CACF,EACF,EACF;;;;;;;;;;ACVD,MAAM,gBAAgB,MAAM;CAC1B,QAAQ;CACR,aAAa,CAAC,SAAS;CACvB,QAAQ,CAAC,WAAW;CACpB,mBAAmB,eAAe;EAChC,MAAM,SAAS,WAAW;AAC1B,MAAI,WAAW,OAAW,QAAO;AACjC,MAAI,OAAO,WAAW,YAAY,CAAC,OAAO,SAAS,OAAO,IAAI,CAAC,OAA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EACD;CACE,QAAQ;CACR,MAAM,CACJ;EAAE,SAAS;EAAgB,UAAU;EAAO,EAC5C;EAAE,SAAS;EAAgB,UAAU;EAAO,CAC7C;CACD,SAAS;EAAE,SAAS;EAAe,UAAU;EAAO;CACpD,UAAU;EACR,cAAc;EACd,UAAU;EACV,UAAU;EACX;CACF,CACF;AAED,MAAM,uBAAuB;CAC3B,MAAM;CACN,IAAI;CACJ,UAAU;CACV,UAAU;CACV,SAAS;CACT,cAAc,EACZ,UAAU,EACR,mBAAmB,MACpB,EACF;CACD,WAAW,EACT,MAAM,wBACP;CACD,OAAO;EACL,YAAY;GACV,gBAAgB,OAAO,OAAO,iBAAiB,CAAC,KAAK,QAAQ,IAAI,MAAM;GACvE,QAAQ;IACN,SAAS;IACT,OAAO;IACP,OAAO;IACR;GACD,aAAa,CACX;IACE,SAAS;IACT,OAAO;IACP,OAAO;IACR,CACF;GACF;EACD,gBAAgB,EACd,QAAQ;GACN,SAAS;GACT,OAAO;GACP,OAAO;GACR,EACF;EACD,qBAAqB,EACnB,QAAQ;GACN,SAAS;GACT,OAAO;GACP,OAAO;GACR,EACF;EACD,SAAS,CACP;GAAE,QAAQ;GAAgB,UAAU;GAAO,UAAU;GAAY,YAAY;GAAU,CACxF;EACF;CACF;AAED,MAAaC,mBAET"}
|
package/dist/pack.d.mts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { t as CodecTypes } from "./codec-types-BifaP625.mjs";
|
|
2
2
|
import * as _prisma_next_sql_relational_core_ast0 from "@prisma-next/sql-relational-core/ast";
|
|
3
|
-
import { ExtensionPackRef } from "@prisma-next/framework-components/components";
|
|
4
3
|
|
|
5
4
|
//#region src/core/descriptor-meta.d.ts
|
|
6
|
-
declare const
|
|
5
|
+
declare const pgvectorPackMetaBase: {
|
|
7
6
|
readonly kind: "extension";
|
|
8
7
|
readonly id: "pgvector";
|
|
9
8
|
readonly familyId: "sql";
|
|
@@ -76,11 +75,9 @@ declare const pgvectorPackMeta: {
|
|
|
76
75
|
}];
|
|
77
76
|
};
|
|
78
77
|
};
|
|
79
|
-
|
|
80
|
-
//#region src/exports/pack.d.ts
|
|
81
|
-
declare const _default: typeof pgvectorPackMeta & ExtensionPackRef<"sql", "postgres"> & {
|
|
78
|
+
declare const pgvectorPackMeta: typeof pgvectorPackMetaBase & {
|
|
82
79
|
readonly __codecTypes?: CodecTypes;
|
|
83
80
|
};
|
|
84
81
|
//#endregion
|
|
85
|
-
export {
|
|
82
|
+
export { pgvectorPackMeta as default };
|
|
86
83
|
//# sourceMappingURL=pack.d.mts.map
|
package/dist/pack.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pack.d.mts","names":[],"sources":["../src/core/descriptor-meta.ts"
|
|
1
|
+
{"version":3,"file":"pack.d.mts","names":[],"sources":["../src/core/descriptor-meta.ts"],"sourcesContent":[],"mappings":";;;;cAoCM;EAAA,SAAA,IAAA,EAAA,WAgDI;EAEG,SAAA,EAAA,EAAA,UAEW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAJd,qCAAA,CAAA,8DAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEG,yBAAyB;0BACZ"}
|
package/dist/pack.mjs
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { t as pgvectorPackMeta } from "./descriptor-meta-
|
|
1
|
+
import { t as pgvectorPackMeta } from "./descriptor-meta-BQbvJJxu.mjs";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
const pgvectorPack = pgvectorPackMeta;
|
|
5
|
-
var pack_default = pgvectorPack;
|
|
6
|
-
|
|
7
|
-
//#endregion
|
|
8
|
-
export { pack_default as default };
|
|
9
|
-
//# sourceMappingURL=pack.mjs.map
|
|
3
|
+
export { pgvectorPackMeta as default };
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as VECTOR_MAX_DIM, t as VECTOR_CODEC_ID } from "./constants-Co5golCK.mjs";
|
|
2
|
-
import { n as pgvectorQueryOperations, r as codecDefinitions, t as pgvectorPackMeta } from "./descriptor-meta-
|
|
2
|
+
import { n as pgvectorQueryOperations, r as codecDefinitions, t as pgvectorPackMeta } from "./descriptor-meta-BQbvJJxu.mjs";
|
|
3
3
|
import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
|
|
4
4
|
import { type } from "arktype";
|
|
5
5
|
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/extension-pgvector",
|
|
3
|
-
"version": "0.4.0-dev.
|
|
3
|
+
"version": "0.4.0-dev.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"arktype": "^2.0.0",
|
|
8
|
-
"@prisma-next/contract": "0.4.0-dev.
|
|
9
|
-
"@prisma-next/
|
|
10
|
-
"@prisma-next/family-sql": "0.4.0-dev.
|
|
11
|
-
"@prisma-next/
|
|
12
|
-
"@prisma-next/
|
|
13
|
-
"@prisma-next/sql-relational-core": "0.4.0-dev.
|
|
14
|
-
"@prisma-next/sql-
|
|
15
|
-
"@prisma-next/sql-
|
|
8
|
+
"@prisma-next/contract": "0.4.0-dev.8",
|
|
9
|
+
"@prisma-next/contract-authoring": "0.4.0-dev.8",
|
|
10
|
+
"@prisma-next/family-sql": "0.4.0-dev.8",
|
|
11
|
+
"@prisma-next/framework-components": "0.4.0-dev.8",
|
|
12
|
+
"@prisma-next/sql-operations": "0.4.0-dev.8",
|
|
13
|
+
"@prisma-next/sql-relational-core": "0.4.0-dev.8",
|
|
14
|
+
"@prisma-next/sql-runtime": "0.4.0-dev.8",
|
|
15
|
+
"@prisma-next/sql-schema-ir": "0.4.0-dev.8"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"tsdown": "0.18.4",
|
|
19
19
|
"typescript": "5.9.3",
|
|
20
20
|
"vitest": "4.0.17",
|
|
21
|
-
"@prisma-next/
|
|
22
|
-
"@prisma-next/
|
|
23
|
-
"@prisma-next/sql-contract": "0.4.0-dev.
|
|
21
|
+
"@prisma-next/operations": "0.4.0-dev.8",
|
|
22
|
+
"@prisma-next/adapter-postgres": "0.4.0-dev.8",
|
|
23
|
+
"@prisma-next/sql-contract": "0.4.0-dev.8",
|
|
24
24
|
"@prisma-next/test-utils": "0.0.1",
|
|
25
|
-
"@prisma-next/
|
|
25
|
+
"@prisma-next/sql-contract-ts": "0.4.0-dev.8",
|
|
26
26
|
"@prisma-next/tsconfig": "0.0.0",
|
|
27
|
-
"@prisma-next/
|
|
27
|
+
"@prisma-next/tsdown": "0.0.0"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
30
|
"dist",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SqlOperationDescriptor } from '@prisma-next/sql-operations';
|
|
2
|
+
import type { CodecTypes } from '../types/codec-types';
|
|
2
3
|
import { pgvectorAuthoringTypes } from './authoring';
|
|
3
4
|
import { codecDefinitions } from './codecs';
|
|
4
5
|
|
|
@@ -33,7 +34,7 @@ export const pgvectorQueryOperations: readonly SqlOperationDescriptor[] = [
|
|
|
33
34
|
},
|
|
34
35
|
];
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
const pgvectorPackMetaBase = {
|
|
37
38
|
kind: 'extension',
|
|
38
39
|
id: 'pgvector',
|
|
39
40
|
familyId: 'sql',
|
|
@@ -82,3 +83,7 @@ export const pgvectorPackMeta = {
|
|
|
82
83
|
],
|
|
83
84
|
},
|
|
84
85
|
} as const;
|
|
86
|
+
|
|
87
|
+
export const pgvectorPackMeta: typeof pgvectorPackMetaBase & {
|
|
88
|
+
readonly __codecTypes?: CodecTypes;
|
|
89
|
+
} = pgvectorPackMetaBase;
|
package/src/exports/pack.ts
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { pgvectorPackMeta } from '../core/descriptor-meta';
|
|
3
|
-
import type { CodecTypes } from '../types/codec-types';
|
|
4
|
-
|
|
5
|
-
const pgvectorPack = pgvectorPackMeta;
|
|
6
|
-
|
|
7
|
-
export default pgvectorPack as typeof pgvectorPackMeta &
|
|
8
|
-
ExtensionPackRef<'sql', 'postgres'> & {
|
|
9
|
-
readonly __codecTypes?: CodecTypes;
|
|
10
|
-
};
|
|
1
|
+
export { pgvectorPackMeta as default } from '../core/descriptor-meta';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor-meta-CHj8SCio.mjs","names":["pgvectorQueryOperations: readonly SqlOperationDescriptor[]"],"sources":["../src/core/authoring.ts","../src/core/codecs.ts","../src/core/descriptor-meta.ts"],"sourcesContent":["import type { AuthoringTypeNamespace } from '@prisma-next/framework-components/authoring';\nimport { VECTOR_MAX_DIM } from './constants';\n\nexport const pgvectorAuthoringTypes = {\n pgvector: {\n Vector: {\n kind: 'typeConstructor',\n args: [\n { kind: 'number', name: 'length', integer: true, minimum: 1, maximum: VECTOR_MAX_DIM },\n ],\n output: {\n codecId: 'pg/vector@1',\n nativeType: 'vector',\n typeParams: {\n length: { kind: 'arg', index: 0 },\n },\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n","/**\n * Vector codec implementation for pgvector extension.\n *\n * Provides encoding/decoding for the `vector` PostgreSQL type.\n * Wire format is a string like `[1,2,3]` (PostgreSQL vector text format).\n */\n\nimport { codec, defineCodecs } from '@prisma-next/sql-relational-core/ast';\n\nconst pgVectorCodec = codec({\n typeId: 'pg/vector@1',\n targetTypes: ['vector'],\n traits: ['equality'],\n renderOutputType: (typeParams) => {\n const length = typeParams['length'];\n if (length === undefined) return undefined;\n if (typeof length !== 'number' || !Number.isFinite(length) || !Number.isInteger(length)) {\n throw new Error(\n `renderOutputType: expected positive integer \"length\" in typeParams for Vector, got ${String(length)}`,\n );\n }\n return `Vector<${length}>`;\n },\n encode: (value: number[]): string => {\n // Validate that value is an array of numbers\n if (!Array.isArray(value)) {\n throw new Error('Vector value must be an array of numbers');\n }\n if (!value.every((v) => typeof v === 'number')) {\n throw new Error('Vector value must contain only numbers');\n }\n // Format as PostgreSQL vector text format: [1,2,3]\n // PostgreSQL's pg library requires the vector format string\n return `[${value.join(',')}]`;\n },\n decode: (wire: string): number[] => {\n // Handle string format from PostgreSQL: [1,2,3]\n if (typeof wire !== 'string') {\n throw new Error('Vector wire value must be a string');\n }\n // Parse PostgreSQL vector format: [1,2,3]\n if (!wire.startsWith('[') || !wire.endsWith(']')) {\n throw new Error(`Invalid vector format: expected \"[...]\", got \"${wire}\"`);\n }\n const content = wire.slice(1, -1).trim();\n if (content === '') {\n return [];\n }\n const values = content.split(',').map((v) => {\n const num = Number.parseFloat(v.trim());\n if (Number.isNaN(num)) {\n throw new Error(`Invalid vector value: \"${v}\" is not a number`);\n }\n return num;\n });\n return values;\n },\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'vector',\n },\n },\n },\n },\n});\n\n// Build codec definitions using the builder DSL\nconst codecs = defineCodecs().add('vector', pgVectorCodec);\n\n// Export derived structures directly from codecs builder\nexport const codecDefinitions = codecs.codecDefinitions;\nexport const dataTypes = codecs.dataTypes;\n\n// Export types derived from codecs builder\nexport type CodecTypes = typeof codecs.CodecTypes;\n","import type { SqlOperationDescriptor } from '@prisma-next/sql-operations';\nimport { pgvectorAuthoringTypes } from './authoring';\nimport { codecDefinitions } from './codecs';\n\nconst pgvectorTypeId = 'pg/vector@1' as const;\n\nexport const pgvectorQueryOperations: readonly SqlOperationDescriptor[] = [\n {\n method: 'cosineDistance',\n args: [\n { codecId: pgvectorTypeId, nullable: false },\n { codecId: pgvectorTypeId, nullable: false },\n ],\n returns: { codecId: 'pg/float8@1', nullable: false },\n lowering: {\n targetFamily: 'sql',\n strategy: 'function',\n template: '{{self}} <=> {{arg0}}',\n },\n },\n {\n method: 'cosineSimilarity',\n args: [\n { codecId: pgvectorTypeId, nullable: false },\n { codecId: pgvectorTypeId, nullable: false },\n ],\n returns: { codecId: 'pg/float8@1', nullable: false },\n lowering: {\n targetFamily: 'sql',\n strategy: 'function',\n template: '1 - ({{self}} <=> {{arg0}})',\n },\n },\n];\n\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 authoring: {\n type: pgvectorAuthoringTypes,\n },\n types: {\n codecTypes: {\n codecInstances: Object.values(codecDefinitions).map((def) => def.codec),\n import: {\n package: '@prisma-next/extension-pgvector/codec-types',\n named: 'CodecTypes',\n alias: 'PgVectorTypes',\n },\n typeImports: [\n {\n package: '@prisma-next/extension-pgvector/codec-types',\n named: 'Vector',\n alias: 'Vector',\n },\n ],\n },\n operationTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/operation-types',\n named: 'OperationTypes',\n alias: 'PgVectorOperationTypes',\n },\n },\n queryOperationTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/operation-types',\n named: 'QueryOperationTypes',\n alias: 'PgVectorQueryOperationTypes',\n },\n },\n storage: [\n { typeId: pgvectorTypeId, familyId: 'sql', targetId: 'postgres', nativeType: 'vector' },\n ],\n },\n} as const;\n"],"mappings":";;;;AAGA,MAAa,yBAAyB,EACpC,UAAU,EACR,QAAQ;CACN,MAAM;CACN,MAAM,CACJ;EAAE,MAAM;EAAU,MAAM;EAAU,SAAS;EAAM,SAAS;EAAG,SAAS;EAAgB,CACvF;CACD,QAAQ;EACN,SAAS;EACT,YAAY;EACZ,YAAY,EACV,QAAQ;GAAE,MAAM;GAAO,OAAO;GAAG,EAClC;EACF;CACF,EACF,EACF;;;;;;;;;;ACVD,MAAM,gBAAgB,MAAM;CAC1B,QAAQ;CACR,aAAa,CAAC,SAAS;CACvB,QAAQ,CAAC,WAAW;CACpB,mBAAmB,eAAe;EAChC,MAAM,SAAS,WAAW;AAC1B,MAAI,WAAW,OAAW,QAAO;AACjC,MAAI,OAAO,WAAW,YA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;EACR,cAAc;EACd,UAAU;EACV,UAAU;EACX;CACF,EACD;CACE,QAAQ;CACR,MAAM,CACJ;EAAE,SAAS;EAAgB,UAAU;EAAO,EAC5C;EAAE,SAAS;EAAgB,UAAU;EAAO,CAC7C;CACD,SAAS;EAAE,SAAS;EAAe,UAAU;EAAO;CACpD,UAAU;EACR,cAAc;EACd,UAAU;EACV,UAAU;EACX;CACF,CACF;AAED,MAAa,mBAAmB;CAC9B,MAAM;CACN,IAAI;CACJ,UAAU;CACV,UAAU;CACV,SAAS;CACT,cAAc,EACZ,UAAU,EACR,mBAAmB,MACpB,EACF;CACD,WAAW,EACT,MAAM,wBACP;CACD,OAAO;EACL,YAAY;GACV,gBAAgB,OAAO,OAAO,iBAAiB,CAAC,KAAK,QAAQ,IAAI,MAAM;GACvE,QAAQ;IACN,SAAS;IACT,OAAO;IACP,OAAO;IACR;GACD,aAAa,CACX;IACE,SAAS;IACT,OAAO;IACP,OAAO;IACR,CACF;GACF;EACD,gBAAgB,EACd,QAAQ;GACN,SAAS;GACT,OAAO;GACP,OAAO;GACR,EACF;EACD,qBAAqB,EACnB,QAAQ;GACN,SAAS;GACT,OAAO;GACP,OAAO;GACR,EACF;EACD,SAAS,CACP;GAAE,QAAQ;GAAgB,UAAU;GAAO,UAAU;GAAY,YAAY;GAAU,CACxF;EACF;CACF"}
|
package/dist/pack.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pack.mjs","names":[],"sources":["../src/exports/pack.ts"],"sourcesContent":["import type { ExtensionPackRef } from '@prisma-next/framework-components/components';\nimport { pgvectorPackMeta } from '../core/descriptor-meta';\nimport type { CodecTypes } from '../types/codec-types';\n\nconst pgvectorPack = pgvectorPackMeta;\n\nexport default pgvectorPack as typeof pgvectorPackMeta &\n ExtensionPackRef<'sql', 'postgres'> & {\n readonly __codecTypes?: CodecTypes;\n };\n"],"mappings":";;;AAIA,MAAM,eAAe;AAErB,mBAAe"}
|