@prisma-next/extension-pgvector 0.3.0-dev.12 → 0.3.0-dev.122
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/LICENSE +201 -0
- package/README.md +35 -18
- package/dist/codec-types-BcHC4dXB.d.mts +41 -0
- package/dist/codec-types-BcHC4dXB.d.mts.map +1 -0
- package/dist/codec-types.d.mts +2 -0
- package/dist/codec-types.mjs +1 -0
- package/dist/column-types.d.mts +33 -0
- package/dist/column-types.d.mts.map +1 -0
- package/dist/column-types.mjs +36 -0
- package/dist/column-types.mjs.map +1 -0
- package/dist/constants-BmZpaev5.mjs +13 -0
- package/dist/constants-BmZpaev5.mjs.map +1 -0
- package/dist/control.d.mts +7 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +61 -0
- package/dist/control.mjs.map +1 -0
- package/dist/descriptor-meta-IXkObAr0.mjs +117 -0
- package/dist/descriptor-meta-IXkObAr0.mjs.map +1 -0
- package/dist/operation-types.d.mts +78 -0
- package/dist/operation-types.d.mts.map +1 -0
- package/dist/operation-types.mjs +1 -0
- package/dist/pack.d.mts +10 -0
- package/dist/pack.d.mts.map +1 -0
- package/dist/pack.mjs +9 -0
- package/dist/pack.mjs.map +1 -0
- package/dist/runtime.d.mts +7 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +76 -0
- package/dist/runtime.mjs.map +1 -0
- package/package.json +34 -46
- package/src/core/codecs.ts +2 -1
- package/src/core/constants.ts +9 -0
- package/src/core/descriptor-meta.ts +68 -19
- package/src/exports/codec-types.ts +1 -1
- package/src/exports/column-types.ts +34 -1
- package/src/exports/control.ts +32 -26
- package/src/exports/operation-types.ts +1 -1
- package/src/exports/pack.ts +5 -1
- package/src/exports/runtime.ts +42 -27
- package/src/types/codec-types.ts +23 -1
- package/src/types/operation-types.ts +36 -0
- package/dist/chunk-SHWLERB3.js +0 -60
- package/dist/chunk-SHWLERB3.js.map +0 -1
- package/dist/core/codecs.d.ts +0 -23
- package/dist/core/codecs.d.ts.map +0 -1
- package/dist/core/descriptor-meta.d.ts +0 -53
- package/dist/core/descriptor-meta.d.ts.map +0 -1
- package/dist/exports/codec-types.d.ts +0 -7
- package/dist/exports/codec-types.d.ts.map +0 -1
- package/dist/exports/codec-types.js +0 -1
- package/dist/exports/codec-types.js.map +0 -1
- package/dist/exports/column-types.d.ts +0 -11
- package/dist/exports/column-types.d.ts.map +0 -1
- package/dist/exports/column-types.js +0 -9
- package/dist/exports/column-types.js.map +0 -1
- package/dist/exports/control.d.ts +0 -9
- package/dist/exports/control.d.ts.map +0 -1
- package/dist/exports/control.js +0 -67
- package/dist/exports/control.js.map +0 -1
- package/dist/exports/operation-types.d.ts +0 -7
- package/dist/exports/operation-types.d.ts.map +0 -1
- package/dist/exports/operation-types.js +0 -1
- package/dist/exports/operation-types.js.map +0 -1
- package/dist/exports/pack.d.ts +0 -52
- package/dist/exports/pack.d.ts.map +0 -1
- package/dist/exports/pack.js +0 -11
- package/dist/exports/pack.js.map +0 -1
- package/dist/exports/runtime.d.ts +0 -8
- package/dist/exports/runtime.d.ts.map +0 -1
- package/dist/exports/runtime.js +0 -86
- package/dist/exports/runtime.js.map +0 -1
- package/dist/types/codec-types.d.ts +0 -10
- package/dist/types/codec-types.d.ts.map +0 -1
- package/dist/types/operation-types.d.ts +0 -31
- package/dist/types/operation-types.d.ts.map +0 -1
package/src/exports/control.ts
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import type { SchemaIssue } from '@prisma-next/core-control-plane/types';
|
|
2
1
|
import type {
|
|
2
|
+
CodecControlHooks,
|
|
3
3
|
ComponentDatabaseDependencies,
|
|
4
4
|
SqlControlExtensionDescriptor,
|
|
5
5
|
} from '@prisma-next/family-sql/control';
|
|
6
|
-
import
|
|
7
|
-
import { pgvectorPackMeta } from '../core/descriptor-meta';
|
|
6
|
+
import { pgvectorOperationSignatures, pgvectorPackMeta } from '../core/descriptor-meta';
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return [
|
|
16
|
-
{
|
|
17
|
-
kind: 'extension_missing',
|
|
18
|
-
table: '',
|
|
19
|
-
message: 'Extension "vector" is missing from database (required by pgvector)',
|
|
20
|
-
},
|
|
21
|
-
];
|
|
8
|
+
const PGVECTOR_CODEC_ID = 'pg/vector@1' as const;
|
|
9
|
+
|
|
10
|
+
function buildVectorIdentityValue(typeParams: Record<string, unknown> | undefined): string | null {
|
|
11
|
+
const length = typeParams?.['length'];
|
|
12
|
+
if (typeof length !== 'number' || !Number.isInteger(length) || length <= 0) {
|
|
13
|
+
return null;
|
|
22
14
|
}
|
|
23
|
-
|
|
15
|
+
|
|
16
|
+
const zeroVector = `[${new Array(length).fill('0').join(',')}]`;
|
|
17
|
+
return `'${zeroVector}'::vector`;
|
|
24
18
|
}
|
|
25
19
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
const vectorControlPlaneHooks: CodecControlHooks = {
|
|
21
|
+
expandNativeType: ({ nativeType, typeParams }) => {
|
|
22
|
+
const length = typeParams?.['length'];
|
|
23
|
+
if (typeof length === 'number' && Number.isInteger(length) && length > 0) {
|
|
24
|
+
return `${nativeType}(${length})`;
|
|
25
|
+
}
|
|
26
|
+
return nativeType;
|
|
27
|
+
},
|
|
28
|
+
resolveIdentityValue: ({ typeParams }) => buildVectorIdentityValue(typeParams),
|
|
29
|
+
};
|
|
30
|
+
|
|
30
31
|
const pgvectorDatabaseDependencies: ComponentDatabaseDependencies<unknown> = {
|
|
31
32
|
init: [
|
|
32
33
|
{
|
|
@@ -59,17 +60,22 @@ const pgvectorDatabaseDependencies: ComponentDatabaseDependencies<unknown> = {
|
|
|
59
60
|
],
|
|
60
61
|
},
|
|
61
62
|
],
|
|
62
|
-
verifyDatabaseDependencyInstalled: verifyVectorExtensionInstalled,
|
|
63
63
|
},
|
|
64
64
|
],
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
/**
|
|
68
|
-
* pgvector extension descriptor for CLI config.
|
|
69
|
-
* Declares database dependencies for the 'vector' Postgres extension.
|
|
70
|
-
*/
|
|
71
67
|
const pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {
|
|
72
68
|
...pgvectorPackMeta,
|
|
69
|
+
types: {
|
|
70
|
+
...pgvectorPackMeta.types,
|
|
71
|
+
codecTypes: {
|
|
72
|
+
...pgvectorPackMeta.types.codecTypes,
|
|
73
|
+
controlPlaneHooks: {
|
|
74
|
+
[PGVECTOR_CODEC_ID]: vectorControlPlaneHooks,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
operationSignatures: () => pgvectorOperationSignatures,
|
|
73
79
|
databaseDependencies: pgvectorDatabaseDependencies,
|
|
74
80
|
create: () => ({
|
|
75
81
|
familyId: 'sql' as const,
|
package/src/exports/pack.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type { ExtensionPackRef } from '@prisma-next/contract/framework-components';
|
|
1
2
|
import { pgvectorPackMeta } from '../core/descriptor-meta';
|
|
3
|
+
import type { CodecTypes } from '../types/codec-types';
|
|
2
4
|
|
|
3
5
|
const pgvectorPack = pgvectorPackMeta;
|
|
4
6
|
|
|
5
|
-
export default pgvectorPack
|
|
7
|
+
export default pgvectorPack as ExtensionPackRef<'sql', 'postgres'> & {
|
|
8
|
+
readonly __codecTypes?: CodecTypes;
|
|
9
|
+
};
|
package/src/exports/runtime.ts
CHANGED
|
@@ -1,47 +1,62 @@
|
|
|
1
|
-
import type { SqlOperationSignature } from '@prisma-next/sql-operations';
|
|
2
|
-
import type { CodecRegistry } from '@prisma-next/sql-relational-core/ast';
|
|
3
1
|
import { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';
|
|
4
2
|
import type {
|
|
3
|
+
RuntimeParameterizedCodecDescriptor,
|
|
5
4
|
SqlRuntimeExtensionDescriptor,
|
|
6
|
-
SqlRuntimeExtensionInstance,
|
|
7
5
|
} from '@prisma-next/sql-runtime';
|
|
6
|
+
import { type as arktype } from 'arktype';
|
|
8
7
|
import { codecDefinitions } from '../core/codecs';
|
|
9
|
-
import {
|
|
8
|
+
import { VECTOR_CODEC_ID, VECTOR_MAX_DIM } from '../core/constants';
|
|
9
|
+
import {
|
|
10
|
+
pgvectorOperationSignatures,
|
|
11
|
+
pgvectorPackMeta,
|
|
12
|
+
pgvectorQueryOperations,
|
|
13
|
+
} from '../core/descriptor-meta';
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const registry = createCodecRegistry();
|
|
21
|
-
// Register all codecs from codecDefinitions
|
|
22
|
-
for (const def of Object.values(codecDefinitions)) {
|
|
23
|
-
registry.register(def.codec);
|
|
24
|
-
}
|
|
25
|
-
return registry;
|
|
15
|
+
const vectorParamsSchema = arktype({
|
|
16
|
+
length: 'number',
|
|
17
|
+
}).narrow((params, ctx) => {
|
|
18
|
+
const { length } = params;
|
|
19
|
+
if (!Number.isInteger(length)) {
|
|
20
|
+
return ctx.mustBe('an integer');
|
|
21
|
+
}
|
|
22
|
+
if (length < 1 || length > VECTOR_MAX_DIM) {
|
|
23
|
+
return ctx.mustBe(`in the range [1, ${VECTOR_MAX_DIM}]`);
|
|
26
24
|
}
|
|
25
|
+
return true;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const parameterizedCodecDescriptors = [
|
|
29
|
+
{
|
|
30
|
+
codecId: VECTOR_CODEC_ID,
|
|
31
|
+
paramsSchema: vectorParamsSchema,
|
|
32
|
+
},
|
|
33
|
+
] as const satisfies ReadonlyArray<
|
|
34
|
+
RuntimeParameterizedCodecDescriptor<{ readonly length: number }>
|
|
35
|
+
>;
|
|
27
36
|
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
function createPgvectorCodecRegistry() {
|
|
38
|
+
const registry = createCodecRegistry();
|
|
39
|
+
for (const def of Object.values(codecDefinitions)) {
|
|
40
|
+
registry.register(def.codec);
|
|
30
41
|
}
|
|
42
|
+
return registry;
|
|
31
43
|
}
|
|
32
44
|
|
|
33
|
-
/**
|
|
34
|
-
* pgvector SQL runtime extension descriptor.
|
|
35
|
-
* Provides metadata and factory for creating runtime extension instances.
|
|
36
|
-
*/
|
|
37
45
|
const pgvectorRuntimeDescriptor: SqlRuntimeExtensionDescriptor<'postgres'> = {
|
|
38
46
|
kind: 'extension' as const,
|
|
39
47
|
id: pgvectorPackMeta.id,
|
|
40
48
|
version: pgvectorPackMeta.version,
|
|
41
49
|
familyId: 'sql' as const,
|
|
42
50
|
targetId: 'postgres' as const,
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
codecs: createPgvectorCodecRegistry,
|
|
52
|
+
operationSignatures: () => pgvectorOperationSignatures,
|
|
53
|
+
queryOperations: () => pgvectorQueryOperations,
|
|
54
|
+
parameterizedCodecs: () => parameterizedCodecDescriptors,
|
|
55
|
+
create() {
|
|
56
|
+
return {
|
|
57
|
+
familyId: 'sql' as const,
|
|
58
|
+
targetId: 'postgres' as const,
|
|
59
|
+
};
|
|
45
60
|
},
|
|
46
61
|
};
|
|
47
62
|
|
package/src/types/codec-types.ts
CHANGED
|
@@ -7,4 +7,26 @@
|
|
|
7
7
|
* Runtime codec implementations are provided by the extension's codec registry.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
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,3 +1,5 @@
|
|
|
1
|
+
import type { SqlQueryOperationTypes } from '@prisma-next/sql-contract/types';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Operation type definitions for pgvector extension.
|
|
3
5
|
*
|
|
@@ -27,5 +29,39 @@ export type OperationTypes = {
|
|
|
27
29
|
readonly template: string;
|
|
28
30
|
};
|
|
29
31
|
};
|
|
32
|
+
readonly cosineSimilarity: {
|
|
33
|
+
readonly args: readonly [
|
|
34
|
+
{
|
|
35
|
+
readonly kind: 'param';
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
readonly returns: {
|
|
39
|
+
readonly kind: 'builtin';
|
|
40
|
+
readonly type: 'number';
|
|
41
|
+
};
|
|
42
|
+
readonly lowering: {
|
|
43
|
+
readonly targetFamily: 'sql';
|
|
44
|
+
readonly strategy: 'function';
|
|
45
|
+
readonly template: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
30
48
|
};
|
|
31
49
|
};
|
|
50
|
+
|
|
51
|
+
/** Flat operation signatures for the query builder. */
|
|
52
|
+
export type QueryOperationTypes = SqlQueryOperationTypes<{
|
|
53
|
+
readonly cosineDistance: {
|
|
54
|
+
readonly args: readonly [
|
|
55
|
+
{ readonly codecId: 'pg/vector@1'; readonly nullable: boolean },
|
|
56
|
+
{ readonly codecId: 'pg/vector@1'; readonly nullable: boolean },
|
|
57
|
+
];
|
|
58
|
+
readonly returns: { readonly codecId: 'pg/float8@1'; readonly nullable: false };
|
|
59
|
+
};
|
|
60
|
+
readonly cosineSimilarity: {
|
|
61
|
+
readonly args: readonly [
|
|
62
|
+
{ readonly codecId: 'pg/vector@1'; readonly nullable: boolean },
|
|
63
|
+
{ readonly codecId: 'pg/vector@1'; readonly nullable: boolean },
|
|
64
|
+
];
|
|
65
|
+
readonly returns: { readonly codecId: 'pg/float8@1'; readonly nullable: false };
|
|
66
|
+
};
|
|
67
|
+
}>;
|
package/dist/chunk-SHWLERB3.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// src/core/descriptor-meta.ts
|
|
2
|
-
var pgvectorTypeId = "pg/vector@1";
|
|
3
|
-
var cosineLowering = {
|
|
4
|
-
targetFamily: "sql",
|
|
5
|
-
strategy: "function",
|
|
6
|
-
template: "1 - ({{self}} <=> {{arg0}})"
|
|
7
|
-
};
|
|
8
|
-
var cosineDistanceOperation = Object.freeze({
|
|
9
|
-
method: "cosineDistance",
|
|
10
|
-
args: [{ kind: "param" }],
|
|
11
|
-
returns: { kind: "builtin", type: "number" },
|
|
12
|
-
lowering: cosineLowering
|
|
13
|
-
});
|
|
14
|
-
var pgvectorPackMeta = {
|
|
15
|
-
kind: "extension",
|
|
16
|
-
id: "pgvector",
|
|
17
|
-
familyId: "sql",
|
|
18
|
-
targetId: "postgres",
|
|
19
|
-
version: "0.0.1",
|
|
20
|
-
capabilities: {
|
|
21
|
-
postgres: {
|
|
22
|
-
"pgvector/cosine": true
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
types: {
|
|
26
|
-
codecTypes: {
|
|
27
|
-
import: {
|
|
28
|
-
package: "@prisma-next/extension-pgvector/codec-types",
|
|
29
|
-
named: "CodecTypes",
|
|
30
|
-
alias: "PgVectorTypes"
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
operationTypes: {
|
|
34
|
-
import: {
|
|
35
|
-
package: "@prisma-next/extension-pgvector/operation-types",
|
|
36
|
-
named: "OperationTypes",
|
|
37
|
-
alias: "PgVectorOperationTypes"
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
storage: [
|
|
41
|
-
{ typeId: pgvectorTypeId, familyId: "sql", targetId: "postgres", nativeType: "vector" }
|
|
42
|
-
]
|
|
43
|
-
},
|
|
44
|
-
operations: [
|
|
45
|
-
{
|
|
46
|
-
for: pgvectorTypeId,
|
|
47
|
-
...cosineDistanceOperation
|
|
48
|
-
}
|
|
49
|
-
]
|
|
50
|
-
};
|
|
51
|
-
var pgvectorRuntimeOperation = {
|
|
52
|
-
forTypeId: pgvectorTypeId,
|
|
53
|
-
...cosineDistanceOperation
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export {
|
|
57
|
-
pgvectorPackMeta,
|
|
58
|
-
pgvectorRuntimeOperation
|
|
59
|
-
};
|
|
60
|
-
//# sourceMappingURL=chunk-SHWLERB3.js.map
|
|
@@ -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":[]}
|
package/dist/core/codecs.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vector codec implementation for pgvector extension.
|
|
3
|
-
*
|
|
4
|
-
* Provides encoding/decoding for the `vector` PostgreSQL type.
|
|
5
|
-
* Wire format is a string like `[1,2,3]` (PostgreSQL vector text format).
|
|
6
|
-
*/
|
|
7
|
-
declare const codecs: import("@prisma-next/sql-relational-core/ast").CodecDefBuilder<{} & Record<"vector", import("@prisma-next/sql-relational-core/ast").Codec<"pg/vector@1", string, number[]>>>;
|
|
8
|
-
export declare const codecDefinitions: {
|
|
9
|
-
readonly vector: {
|
|
10
|
-
readonly typeId: "pg/vector@1";
|
|
11
|
-
readonly scalar: "vector";
|
|
12
|
-
readonly codec: import("@prisma-next/sql-relational-core/ast").Codec<"pg/vector@1", string, number[]>;
|
|
13
|
-
readonly input: number[];
|
|
14
|
-
readonly output: number[];
|
|
15
|
-
readonly jsType: number[];
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export declare const dataTypes: {
|
|
19
|
-
readonly vector: "pg/vector@1";
|
|
20
|
-
};
|
|
21
|
-
export type CodecTypes = typeof codecs.CodecTypes;
|
|
22
|
-
export {};
|
|
23
|
-
//# sourceMappingURL=codecs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../src/core/codecs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqDH,QAAA,MAAM,MAAM,8KAA8C,CAAC;AAG3D,eAAO,MAAM,gBAAgB;;;;;;;;;CAA0B,CAAC;AACxD,eAAO,MAAM,SAAS;;CAAmB,CAAC;AAG1C,MAAM,MAAM,UAAU,GAAG,OAAO,MAAM,CAAC,UAAU,CAAC"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { SqlOperationSignature } from '@prisma-next/sql-operations';
|
|
2
|
-
export declare const pgvectorPackMeta: {
|
|
3
|
-
readonly kind: "extension";
|
|
4
|
-
readonly id: "pgvector";
|
|
5
|
-
readonly familyId: "sql";
|
|
6
|
-
readonly targetId: "postgres";
|
|
7
|
-
readonly version: "0.0.1";
|
|
8
|
-
readonly capabilities: {
|
|
9
|
-
readonly postgres: {
|
|
10
|
-
readonly 'pgvector/cosine': true;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
readonly types: {
|
|
14
|
-
readonly codecTypes: {
|
|
15
|
-
readonly import: {
|
|
16
|
-
readonly package: "@prisma-next/extension-pgvector/codec-types";
|
|
17
|
-
readonly named: "CodecTypes";
|
|
18
|
-
readonly alias: "PgVectorTypes";
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
readonly operationTypes: {
|
|
22
|
-
readonly import: {
|
|
23
|
-
readonly package: "@prisma-next/extension-pgvector/operation-types";
|
|
24
|
-
readonly named: "OperationTypes";
|
|
25
|
-
readonly alias: "PgVectorOperationTypes";
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
readonly storage: readonly [{
|
|
29
|
-
readonly typeId: "pg/vector@1";
|
|
30
|
-
readonly familyId: "sql";
|
|
31
|
-
readonly targetId: "postgres";
|
|
32
|
-
readonly nativeType: "vector";
|
|
33
|
-
}];
|
|
34
|
-
};
|
|
35
|
-
readonly operations: readonly [{
|
|
36
|
-
readonly method: "cosineDistance";
|
|
37
|
-
readonly args: readonly [{
|
|
38
|
-
readonly kind: "param";
|
|
39
|
-
}];
|
|
40
|
-
readonly returns: {
|
|
41
|
-
readonly kind: "builtin";
|
|
42
|
-
readonly type: "number";
|
|
43
|
-
};
|
|
44
|
-
readonly lowering: {
|
|
45
|
-
readonly targetFamily: "sql";
|
|
46
|
-
readonly strategy: "function";
|
|
47
|
-
readonly template: "1 - ({{self}} <=> {{arg0}})";
|
|
48
|
-
};
|
|
49
|
-
readonly for: "pg/vector@1";
|
|
50
|
-
}];
|
|
51
|
-
};
|
|
52
|
-
export declare const pgvectorRuntimeOperation: SqlOperationSignature;
|
|
53
|
-
//# sourceMappingURL=descriptor-meta.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=codec-types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Column type descriptors for pgvector extension.
|
|
3
|
-
*
|
|
4
|
-
* These descriptors provide both codecId and nativeType for use in contract authoring.
|
|
5
|
-
* They are derived from the same source of truth as codec definitions and manifests.
|
|
6
|
-
*/
|
|
7
|
-
export declare const vectorColumn: {
|
|
8
|
-
readonly codecId: "pg/vector@1";
|
|
9
|
-
readonly nativeType: "vector";
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=column-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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,9 +0,0 @@
|
|
|
1
|
-
import type { SqlControlExtensionDescriptor } from '@prisma-next/family-sql/control';
|
|
2
|
-
/**
|
|
3
|
-
* pgvector extension descriptor for CLI config.
|
|
4
|
-
* Declares database dependencies for the 'vector' Postgres extension.
|
|
5
|
-
*/
|
|
6
|
-
declare const pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'>;
|
|
7
|
-
export { pgvectorExtensionDescriptor };
|
|
8
|
-
export default pgvectorExtensionDescriptor;
|
|
9
|
-
//# sourceMappingURL=control.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/exports/control.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,6BAA6B,EAC9B,MAAM,iCAAiC,CAAC;AA8DzC;;;GAGG;AACH,QAAA,MAAM,2BAA2B,EAAE,6BAA6B,CAAC,UAAU,CAO1E,CAAC;AAEF,OAAO,EAAE,2BAA2B,EAAE,CAAC;AACvC,eAAe,2BAA2B,CAAC"}
|
package/dist/exports/control.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
pgvectorPackMeta
|
|
3
|
-
} from "../chunk-SHWLERB3.js";
|
|
4
|
-
|
|
5
|
-
// src/exports/control.ts
|
|
6
|
-
function verifyVectorExtensionInstalled(schema) {
|
|
7
|
-
if (!schema.extensions.includes("vector")) {
|
|
8
|
-
return [
|
|
9
|
-
{
|
|
10
|
-
kind: "extension_missing",
|
|
11
|
-
table: "",
|
|
12
|
-
message: 'Extension "vector" is missing from database (required by pgvector)'
|
|
13
|
-
}
|
|
14
|
-
];
|
|
15
|
-
}
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
var pgvectorDatabaseDependencies = {
|
|
19
|
-
init: [
|
|
20
|
-
{
|
|
21
|
-
id: "postgres.extension.vector",
|
|
22
|
-
label: "Enable vector extension",
|
|
23
|
-
install: [
|
|
24
|
-
{
|
|
25
|
-
id: "extension.vector",
|
|
26
|
-
label: 'Enable extension "vector"',
|
|
27
|
-
summary: "Ensures the vector extension is available for pgvector operations",
|
|
28
|
-
operationClass: "additive",
|
|
29
|
-
target: { id: "postgres" },
|
|
30
|
-
precheck: [
|
|
31
|
-
{
|
|
32
|
-
description: 'verify extension "vector" is not already enabled',
|
|
33
|
-
sql: "SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')"
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
execute: [
|
|
37
|
-
{
|
|
38
|
-
description: 'create extension "vector"',
|
|
39
|
-
sql: "CREATE EXTENSION IF NOT EXISTS vector"
|
|
40
|
-
}
|
|
41
|
-
],
|
|
42
|
-
postcheck: [
|
|
43
|
-
{
|
|
44
|
-
description: 'confirm extension "vector" is enabled',
|
|
45
|
-
sql: "SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')"
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
}
|
|
49
|
-
],
|
|
50
|
-
verifyDatabaseDependencyInstalled: verifyVectorExtensionInstalled
|
|
51
|
-
}
|
|
52
|
-
]
|
|
53
|
-
};
|
|
54
|
-
var pgvectorExtensionDescriptor = {
|
|
55
|
-
...pgvectorPackMeta,
|
|
56
|
-
databaseDependencies: pgvectorDatabaseDependencies,
|
|
57
|
-
create: () => ({
|
|
58
|
-
familyId: "sql",
|
|
59
|
-
targetId: "postgres"
|
|
60
|
-
})
|
|
61
|
-
};
|
|
62
|
-
var control_default = pgvectorExtensionDescriptor;
|
|
63
|
-
export {
|
|
64
|
-
control_default as default,
|
|
65
|
-
pgvectorExtensionDescriptor
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=control.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/control.ts"],"sourcesContent":["import type { SchemaIssue } from '@prisma-next/core-control-plane/types';\nimport type {\n ComponentDatabaseDependencies,\n SqlControlExtensionDescriptor,\n} from '@prisma-next/family-sql/control';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { pgvectorPackMeta } from '../core/descriptor-meta';\n\n/**\n * Pure verification hook: checks whether the 'vector' extension is installed\n * based on the in-memory schema IR (no DB I/O).\n */\nfunction verifyVectorExtensionInstalled(schema: SqlSchemaIR): readonly SchemaIssue[] {\n if (!schema.extensions.includes('vector')) {\n return [\n {\n kind: 'extension_missing',\n table: '',\n message: 'Extension \"vector\" is missing from database (required by pgvector)',\n },\n ];\n }\n return [];\n}\n\n/**\n * Database dependencies for the pgvector extension.\n * Declares the 'vector' Postgres extension as a required dependency.\n */\nconst pgvectorDatabaseDependencies: ComponentDatabaseDependencies<unknown> = {\n init: [\n {\n id: 'postgres.extension.vector',\n label: 'Enable vector extension',\n install: [\n {\n id: 'extension.vector',\n label: 'Enable extension \"vector\"',\n summary: 'Ensures the vector extension is available for pgvector operations',\n operationClass: 'additive',\n target: { id: 'postgres' },\n precheck: [\n {\n description: 'verify extension \"vector\" is not already enabled',\n sql: \"SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')\",\n },\n ],\n execute: [\n {\n description: 'create extension \"vector\"',\n sql: 'CREATE EXTENSION IF NOT EXISTS vector',\n },\n ],\n postcheck: [\n {\n description: 'confirm extension \"vector\" is enabled',\n sql: \"SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')\",\n },\n ],\n },\n ],\n verifyDatabaseDependencyInstalled: verifyVectorExtensionInstalled,\n },\n ],\n};\n\n/**\n * pgvector extension descriptor for CLI config.\n * Declares database dependencies for the 'vector' Postgres extension.\n */\nconst pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {\n ...pgvectorPackMeta,\n databaseDependencies: pgvectorDatabaseDependencies,\n create: () => ({\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n }),\n};\n\nexport { pgvectorExtensionDescriptor };\nexport default pgvectorExtensionDescriptor;\n"],"mappings":";;;;;AAYA,SAAS,+BAA+B,QAA6C;AACnF,MAAI,CAAC,OAAO,WAAW,SAAS,QAAQ,GAAG;AACzC,WAAO;AAAA,MACL;AAAA,QACE,MAAM;AAAA,QACN,OAAO;AAAA,QACP,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACA,SAAO,CAAC;AACV;AAMA,IAAM,+BAAuE;AAAA,EAC3E,MAAM;AAAA,IACJ;AAAA,MACE,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,SAAS;AAAA,QACP;AAAA,UACE,IAAI;AAAA,UACJ,OAAO;AAAA,UACP,SAAS;AAAA,UACT,gBAAgB;AAAA,UAChB,QAAQ,EAAE,IAAI,WAAW;AAAA,UACzB,UAAU;AAAA,YACR;AAAA,cACE,aAAa;AAAA,cACb,KAAK;AAAA,YACP;AAAA,UACF;AAAA,UACA,SAAS;AAAA,YACP;AAAA,cACE,aAAa;AAAA,cACb,KAAK;AAAA,YACP;AAAA,UACF;AAAA,UACA,WAAW;AAAA,YACT;AAAA,cACE,aAAa;AAAA,cACb,KAAK;AAAA,YACP;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,MACA,mCAAmC;AAAA,IACrC;AAAA,EACF;AACF;AAMA,IAAM,8BAAyE;AAAA,EAC7E,GAAG;AAAA,EACH,sBAAsB;AAAA,EACtB,QAAQ,OAAO;AAAA,IACb,UAAU;AAAA,IACV,UAAU;AAAA,EACZ;AACF;AAGA,IAAO,kBAAQ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"operation-types.d.ts","sourceRoot":"","sources":["../../src/exports/operation-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=operation-types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/exports/pack.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
declare const pgvectorPack: {
|
|
2
|
-
readonly kind: "extension";
|
|
3
|
-
readonly id: "pgvector";
|
|
4
|
-
readonly familyId: "sql";
|
|
5
|
-
readonly targetId: "postgres";
|
|
6
|
-
readonly version: "0.0.1";
|
|
7
|
-
readonly capabilities: {
|
|
8
|
-
readonly postgres: {
|
|
9
|
-
readonly 'pgvector/cosine': true;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
readonly types: {
|
|
13
|
-
readonly codecTypes: {
|
|
14
|
-
readonly import: {
|
|
15
|
-
readonly package: "@prisma-next/extension-pgvector/codec-types";
|
|
16
|
-
readonly named: "CodecTypes";
|
|
17
|
-
readonly alias: "PgVectorTypes";
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
readonly operationTypes: {
|
|
21
|
-
readonly import: {
|
|
22
|
-
readonly package: "@prisma-next/extension-pgvector/operation-types";
|
|
23
|
-
readonly named: "OperationTypes";
|
|
24
|
-
readonly alias: "PgVectorOperationTypes";
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
readonly storage: readonly [{
|
|
28
|
-
readonly typeId: "pg/vector@1";
|
|
29
|
-
readonly familyId: "sql";
|
|
30
|
-
readonly targetId: "postgres";
|
|
31
|
-
readonly nativeType: "vector";
|
|
32
|
-
}];
|
|
33
|
-
};
|
|
34
|
-
readonly operations: readonly [{
|
|
35
|
-
readonly method: "cosineDistance";
|
|
36
|
-
readonly args: readonly [{
|
|
37
|
-
readonly kind: "param";
|
|
38
|
-
}];
|
|
39
|
-
readonly returns: {
|
|
40
|
-
readonly kind: "builtin";
|
|
41
|
-
readonly type: "number";
|
|
42
|
-
};
|
|
43
|
-
readonly lowering: {
|
|
44
|
-
readonly targetFamily: "sql";
|
|
45
|
-
readonly strategy: "function";
|
|
46
|
-
readonly template: "1 - ({{self}} <=> {{arg0}})";
|
|
47
|
-
};
|
|
48
|
-
readonly for: "pg/vector@1";
|
|
49
|
-
}];
|
|
50
|
-
};
|
|
51
|
-
export default pgvectorPack;
|
|
52
|
-
//# sourceMappingURL=pack.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/exports/pack.js
DELETED
package/dist/exports/pack.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/pack.ts"],"sourcesContent":["import { pgvectorPackMeta } from '../core/descriptor-meta';\n\nconst pgvectorPack = pgvectorPackMeta;\n\nexport default pgvectorPack;\n"],"mappings":";;;;;AAEA,IAAM,eAAe;AAErB,IAAO,eAAQ;","names":[]}
|