@prisma-next/extension-pgvector 0.5.0-dev.8 → 0.5.0-dev.81

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.
Files changed (41) hide show
  1. package/README.md +5 -2
  2. package/dist/codec-types-yMSpEJJM.d.mts +63 -0
  3. package/dist/codec-types-yMSpEJJM.d.mts.map +1 -0
  4. package/dist/codec-types.d.mts +1 -1
  5. package/dist/codec-types.mjs +1 -1
  6. package/dist/column-types.d.mts +2 -5
  7. package/dist/column-types.d.mts.map +1 -1
  8. package/dist/column-types.mjs +4 -7
  9. package/dist/column-types.mjs.map +1 -1
  10. package/dist/{constants-Co5golCK.mjs → constants-DX-00vYk.mjs} +2 -2
  11. package/dist/{constants-Co5golCK.mjs.map → constants-DX-00vYk.mjs.map} +1 -1
  12. package/dist/control.d.mts.map +1 -1
  13. package/dist/control.mjs +177 -30
  14. package/dist/control.mjs.map +1 -1
  15. package/dist/descriptor-meta-CBnWOxms.mjs +182 -0
  16. package/dist/descriptor-meta-CBnWOxms.mjs.map +1 -0
  17. package/dist/operation-types.d.mts +18 -42
  18. package/dist/operation-types.d.mts.map +1 -1
  19. package/dist/operation-types.mjs +1 -1
  20. package/dist/pack.d.mts +3 -4
  21. package/dist/pack.d.mts.map +1 -1
  22. package/dist/pack.mjs +2 -3
  23. package/dist/runtime.d.mts +10 -1
  24. package/dist/runtime.d.mts.map +1 -1
  25. package/dist/runtime.mjs +6 -25
  26. package/dist/runtime.mjs.map +1 -1
  27. package/package.json +20 -17
  28. package/src/core/codecs.ts +127 -59
  29. package/src/core/contract-space-constants.ts +30 -0
  30. package/src/core/contract.ts +74 -0
  31. package/src/core/descriptor-meta.ts +55 -28
  32. package/src/core/migrations.ts +125 -0
  33. package/src/core/registry.ts +11 -0
  34. package/src/exports/column-types.ts +3 -6
  35. package/src/exports/control.ts +35 -37
  36. package/src/exports/runtime.ts +11 -41
  37. package/src/types/operation-types.ts +24 -30
  38. package/dist/codec-types-BifaP625.d.mts +0 -27
  39. package/dist/codec-types-BifaP625.d.mts.map +0 -1
  40. package/dist/descriptor-meta-BQbvJJxu.mjs +0 -148
  41. package/dist/descriptor-meta-BQbvJJxu.mjs.map +0 -1
@@ -1,38 +1,65 @@
1
1
  import type { SqlOperationDescriptor } from '@prisma-next/sql-operations';
2
+ import {
3
+ buildOperation,
4
+ type CodecExpression,
5
+ type Expression,
6
+ refsOf,
7
+ toExpr,
8
+ } from '@prisma-next/sql-relational-core/expression';
2
9
  import type { CodecTypes } from '../types/codec-types';
3
10
  import { pgvectorAuthoringTypes } from './authoring';
4
- import { codecDefinitions } from './codecs';
11
+ import { pgvectorCodecRegistry } from './registry';
5
12
 
6
13
  const pgvectorTypeId = 'pg/vector@1' as const;
7
14
 
8
- export const pgvectorQueryOperations: readonly SqlOperationDescriptor[] = [
9
- {
10
- method: 'cosineDistance',
11
- args: [
12
- { codecId: pgvectorTypeId, nullable: false },
13
- { codecId: pgvectorTypeId, nullable: false },
14
- ],
15
- returns: { codecId: 'pg/float8@1', nullable: false },
16
- lowering: {
17
- targetFamily: 'sql',
18
- strategy: 'function',
19
- template: '{{self}} <=> {{arg0}}',
15
+ type CodecTypesBase = Record<string, { readonly input: unknown; readonly output: unknown }>;
16
+
17
+ export function pgvectorQueryOperations<
18
+ CT extends CodecTypesBase,
19
+ >(): readonly SqlOperationDescriptor[] {
20
+ return [
21
+ {
22
+ method: 'cosineDistance',
23
+ self: { codecId: pgvectorTypeId },
24
+ impl: (
25
+ self: CodecExpression<'pg/vector@1', boolean, CT>,
26
+ other: CodecExpression<'pg/vector@1', boolean, CT>,
27
+ ): Expression<{ codecId: 'pg/float8@1'; nullable: false }> => {
28
+ const selfRefs = refsOf(self);
29
+ return buildOperation({
30
+ method: 'cosineDistance',
31
+ args: [toExpr(self, pgvectorTypeId, selfRefs), toExpr(other, pgvectorTypeId, selfRefs)],
32
+ returns: { codecId: 'pg/float8@1', nullable: false },
33
+ lowering: {
34
+ targetFamily: 'sql',
35
+ strategy: 'function',
36
+ template: '{{self}} <=> {{arg0}}',
37
+ },
38
+ });
39
+ },
20
40
  },
21
- },
22
- {
23
- method: 'cosineSimilarity',
24
- args: [
25
- { codecId: pgvectorTypeId, nullable: false },
26
- { codecId: pgvectorTypeId, nullable: false },
27
- ],
28
- returns: { codecId: 'pg/float8@1', nullable: false },
29
- lowering: {
30
- targetFamily: 'sql',
31
- strategy: 'function',
32
- template: '1 - ({{self}} <=> {{arg0}})',
41
+ {
42
+ method: 'cosineSimilarity',
43
+ self: { codecId: pgvectorTypeId },
44
+ impl: (
45
+ self: CodecExpression<'pg/vector@1', boolean, CT>,
46
+ other: CodecExpression<'pg/vector@1', boolean, CT>,
47
+ ): Expression<{ codecId: 'pg/float8@1'; nullable: false }> => {
48
+ const selfRefs = refsOf(self);
49
+ return buildOperation({
50
+ method: 'cosineSimilarity',
51
+ args: [toExpr(self, pgvectorTypeId, selfRefs), toExpr(other, pgvectorTypeId, selfRefs)],
52
+ returns: { codecId: 'pg/float8@1', nullable: false },
53
+ lowering: {
54
+ targetFamily: 'sql',
55
+ strategy: 'function',
56
+ template: '1 - ({{self}} <=> {{arg0}})',
57
+ },
58
+ });
59
+ },
33
60
  },
34
- },
35
- ];
61
+ ];
62
+ }
36
63
 
37
64
  const pgvectorPackMetaBase = {
38
65
  kind: 'extension',
@@ -50,7 +77,7 @@ const pgvectorPackMetaBase = {
50
77
  },
51
78
  types: {
52
79
  codecTypes: {
53
- codecInstances: Object.values(codecDefinitions).map((def) => def.codec),
80
+ codecDescriptors: Array.from(pgvectorCodecRegistry.values()),
54
81
  import: {
55
82
  package: '@prisma-next/extension-pgvector/codec-types',
56
83
  named: 'CodecTypes',
@@ -0,0 +1,125 @@
1
+ /**
2
+ * pgvector contract space — baseline migration package.
3
+ *
4
+ * An extension's `contractSpace.migrations` is a list of in-memory
5
+ * `MigrationPackage` values whose `ops` carry framework-level
6
+ * `MigrationPlanOperation`s. The SQL family runner reads the additional
7
+ * runtime fields (`target`, `precheck`, `execute`, `postcheck`) at
8
+ * apply time.
9
+ *
10
+ * Ships a single baseline migration whose only op is
11
+ * {@link installVectorExtensionOp} — it carries the
12
+ * `CREATE EXTENSION IF NOT EXISTS vector` DDL plus a postcondition that
13
+ * confirms the extension landed. Mirrors the prior
14
+ * `databaseDependencies.init[0]` shape (precheck / execute / postcheck)
15
+ * but as a `MigrationPackage` op so the framework's per-space runner /
16
+ * verifier can manage it the same way it manages an application's own
17
+ * migrations.
18
+ *
19
+ * The op carries the stable `pgvector:install-vector-v1` invariantId —
20
+ * once published it is immutable.
21
+ */
22
+
23
+ import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';
24
+ import type {
25
+ ContractSpaceHeadRef,
26
+ MigrationPackage,
27
+ MigrationPlanOperation,
28
+ } from '@prisma-next/framework-components/control';
29
+ import { computeMigrationHash } from '@prisma-next/migration-tools/hash';
30
+ import { PGVECTOR_STORAGE_HASH, pgvectorContract } from './contract';
31
+ import { PGVECTOR_BASELINE_MIGRATION_NAME, PGVECTOR_INVARIANTS } from './contract-space-constants';
32
+
33
+ /**
34
+ * Postgres-style `target.details` shape the SQL runner consumes when
35
+ * executing extension-space ops. pgvector targets only Postgres;
36
+ * locking the target id here keeps the per-op `target` literal narrow
37
+ * without coupling to the Postgres adapter package's
38
+ * `PostgresPlanTargetDetails`.
39
+ */
40
+ type PostgresTargetDetails = {
41
+ readonly schema: string;
42
+ readonly objectType: 'extension';
43
+ readonly name: string;
44
+ };
45
+
46
+ const installVectorExtensionOp: SqlMigrationPlanOperation<unknown> = {
47
+ id: 'pgvector.install-vector-extension',
48
+ label: 'Enable extension "vector"',
49
+ operationClass: 'additive',
50
+ invariantId: PGVECTOR_INVARIANTS.installVector,
51
+ target: {
52
+ id: 'postgres',
53
+ details: {
54
+ schema: 'public',
55
+ objectType: 'extension',
56
+ name: 'vector',
57
+ } satisfies PostgresTargetDetails,
58
+ },
59
+ precheck: [
60
+ {
61
+ description: 'verify extension "vector" is not already enabled',
62
+ sql: "SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')",
63
+ },
64
+ ],
65
+ execute: [
66
+ {
67
+ description: 'create extension "vector"',
68
+ sql: 'CREATE EXTENSION IF NOT EXISTS vector',
69
+ },
70
+ ],
71
+ postcheck: [
72
+ {
73
+ description: 'confirm extension "vector" is enabled',
74
+ sql: "SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')",
75
+ },
76
+ ],
77
+ };
78
+
79
+ const pgvectorBaselineOps: readonly MigrationPlanOperation[] = [installVectorExtensionOp];
80
+
81
+ /** Sorted list of invariantIds the baseline migration provides. */
82
+ export const PGVECTOR_BASELINE_INVARIANTS: readonly string[] = (() => {
83
+ const ids = pgvectorBaselineOps
84
+ .map((op) => op.invariantId)
85
+ .filter((id): id is string => typeof id === 'string');
86
+ return [...new Set(ids)].sort();
87
+ })();
88
+
89
+ const baselineMetadataWithoutHash: Omit<MigrationPackage['metadata'], 'migrationHash'> = {
90
+ from: null,
91
+ to: PGVECTOR_STORAGE_HASH,
92
+ fromContract: null,
93
+ toContract: pgvectorContract,
94
+ hints: { used: [], applied: [], plannerVersion: '2.0.0' },
95
+ labels: [],
96
+ providedInvariants: PGVECTOR_BASELINE_INVARIANTS,
97
+ createdAt: '2026-06-01T00:00:00.000Z',
98
+ };
99
+
100
+ /**
101
+ * Baseline migration package the descriptor publishes via
102
+ * `contractSpace.migrations`. The framework's emitter writes this to
103
+ * `migrations/pgvector/<dirName>/{manifest,ops,contract}.json` in the
104
+ * user's repo at `migrate` time.
105
+ */
106
+ export const pgvectorBaselineMigration: MigrationPackage = {
107
+ dirName: PGVECTOR_BASELINE_MIGRATION_NAME,
108
+ metadata: {
109
+ ...baselineMetadataWithoutHash,
110
+ migrationHash: computeMigrationHash(baselineMetadataWithoutHash, pgvectorBaselineOps),
111
+ },
112
+ ops: pgvectorBaselineOps,
113
+ };
114
+
115
+ /**
116
+ * Pinned head ref the descriptor publishes. The framework writes this
117
+ * verbatim to `migrations/pgvector/refs/head.json` (with `invariants`
118
+ * sorted alphabetically per the canonicalisation rules); the runner's
119
+ * `findPathWithDecision` step consults `head.json` to decide which
120
+ * migrations need to apply.
121
+ */
122
+ export const pgvectorHeadRef: ContractSpaceHeadRef = {
123
+ hash: PGVECTOR_STORAGE_HASH,
124
+ invariants: PGVECTOR_BASELINE_INVARIANTS,
125
+ };
@@ -0,0 +1,11 @@
1
+ import { buildCodecDescriptorRegistry } from '@prisma-next/sql-relational-core/codec-descriptor-registry';
2
+ import type { CodecDescriptorRegistry } from '@prisma-next/sql-relational-core/query-lane-context';
3
+ import { codecDescriptors } from './codecs';
4
+
5
+ /**
6
+ * Registry of every codec descriptor shipped by `@prisma-next/extension-pgvector`.
7
+ *
8
+ * Public consumer surface for the pgvector codec set. Currently a single entry (`pg/vector@1`); the registry shape stays consistent with the other codec-shipping packages so consumers don't need to special-case extensions. See ADR 208.
9
+ */
10
+ export const pgvectorCodecRegistry: CodecDescriptorRegistry =
11
+ buildCodecDescriptorRegistry(codecDescriptors);
@@ -1,16 +1,14 @@
1
1
  /**
2
2
  * Column type descriptors for pgvector extension.
3
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.
4
+ * These descriptors provide both codecId and nativeType for use in contract authoring. They are derived from the same source of truth as codec definitions and manifests.
6
5
  */
7
6
 
8
- import type { ColumnTypeDescriptor } from '@prisma-next/contract-authoring';
7
+ import type { ColumnTypeDescriptor } from '@prisma-next/framework-components/codec';
9
8
  import { VECTOR_CODEC_ID, VECTOR_MAX_DIM } from '../core/constants';
10
9
 
11
10
  /**
12
- * Static vector column descriptor without dimension.
13
- * Use `vector(N)` for dimensioned vectors that produce `vector(N)` DDL.
11
+ * Static vector column descriptor without dimension. Use `vector(N)` for dimensioned vectors that produce `vector(N)` DDL.
14
12
  */
15
13
  export const vectorColumn = {
16
14
  codecId: VECTOR_CODEC_ID,
@@ -25,7 +23,6 @@ export const vectorColumn = {
25
23
  * .column('embedding', { type: vector(1536), nullable: false })
26
24
  * // Produces: nativeType: 'vector', typeParams: { length: 1536 }
27
25
  * ```
28
- *
29
26
  * @param length - The dimension of the vector (e.g., 1536 for OpenAI embeddings)
30
27
  * @returns A column type descriptor with `typeParams.length` set
31
28
  * @throws {RangeError} If length is not an integer in the range [1, VECTOR_MAX_DIM]
@@ -1,9 +1,36 @@
1
+ /**
2
+ * Control-plane descriptor for the pgvector extension.
3
+ *
4
+ * Exposes a `contractSpace` so the framework's per-space planner /
5
+ * runner / verifier (project: extension-contract-spaces, M1+M2)
6
+ * manages the pgvector extension's database scaffolding the same way
7
+ * it manages an application's own schema. The descriptor is consumed
8
+ * by the framework only at authoring time (`migrate`); apply / verify
9
+ * paths read the user's repo (`migrations/pgvector/...`) instead — see
10
+ * project spec NFR3 / FR2 / FR10.
11
+ *
12
+ * `databaseDependencies` is intentionally absent — pgvector was
13
+ * migrated off the legacy `databaseDependencies.init` mechanism in M4
14
+ * (project spec FR13). The `CREATE EXTENSION IF NOT EXISTS vector`
15
+ * DDL the legacy entry carried now lives as the body of the
16
+ * `installVectorExtension` op inside the baseline migration package
17
+ * (`../core/migrations.ts`). Presence of `contractSpace` is the
18
+ * shipping-strategy gate: the framework loads the contract space and
19
+ * ignores any `databaseDependencies` block (project plan §
20
+ * "Shipping Strategy"). M5 removes the field at the framework level.
21
+ */
22
+
23
+ import type { Contract } from '@prisma-next/contract/types';
1
24
  import type {
2
25
  CodecControlHooks,
3
- ComponentDatabaseDependencies,
4
26
  SqlControlExtensionDescriptor,
5
27
  } from '@prisma-next/family-sql/control';
28
+ import type { ContractSpace } from '@prisma-next/framework-components/control';
29
+ import type { SqlStorage } from '@prisma-next/sql-contract/types';
30
+ import { pgvectorContract } from '../core/contract';
31
+ import { PGVECTOR_SPACE_ID } from '../core/contract-space-constants';
6
32
  import { pgvectorPackMeta, pgvectorQueryOperations } from '../core/descriptor-meta';
33
+ import { pgvectorBaselineMigration, pgvectorHeadRef } from '../core/migrations';
7
34
 
8
35
  const PGVECTOR_CODEC_ID = 'pg/vector@1' as const;
9
36
 
@@ -28,44 +55,16 @@ const vectorControlPlaneHooks: CodecControlHooks = {
28
55
  resolveIdentityValue: ({ typeParams }) => buildVectorIdentityValue(typeParams),
29
56
  };
30
57
 
31
- const pgvectorDatabaseDependencies: ComponentDatabaseDependencies<unknown> = {
32
- init: [
33
- {
34
- id: 'postgres.extension.vector',
35
- label: 'Enable vector extension',
36
- install: [
37
- {
38
- id: 'extension.vector',
39
- label: 'Enable extension "vector"',
40
- summary: 'Ensures the vector extension is available for pgvector operations',
41
- operationClass: 'additive',
42
- target: { id: 'postgres' },
43
- precheck: [
44
- {
45
- description: 'verify extension "vector" is not already enabled',
46
- sql: "SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')",
47
- },
48
- ],
49
- execute: [
50
- {
51
- description: 'create extension "vector"',
52
- sql: 'CREATE EXTENSION IF NOT EXISTS vector',
53
- },
54
- ],
55
- postcheck: [
56
- {
57
- description: 'confirm extension "vector" is enabled',
58
- sql: "SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')",
59
- },
60
- ],
61
- },
62
- ],
63
- },
64
- ],
58
+ const pgvectorContractSpace: ContractSpace<Contract<SqlStorage>> = {
59
+ contractJson: pgvectorContract,
60
+ migrations: [pgvectorBaselineMigration],
61
+ headRef: pgvectorHeadRef,
65
62
  };
66
63
 
67
64
  const pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {
68
65
  ...pgvectorPackMeta,
66
+ id: PGVECTOR_SPACE_ID,
67
+ contractSpace: pgvectorContractSpace,
69
68
  types: {
70
69
  ...pgvectorPackMeta.types,
71
70
  codecTypes: {
@@ -75,8 +74,7 @@ const pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {
75
74
  },
76
75
  },
77
76
  },
78
- queryOperations: () => pgvectorQueryOperations,
79
- databaseDependencies: pgvectorDatabaseDependencies,
77
+ queryOperations: () => pgvectorQueryOperations(),
80
78
  create: () => ({
81
79
  familyId: 'sql' as const,
82
80
  targetId: 'postgres' as const,
@@ -1,42 +1,6 @@
1
- import { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';
2
- import type {
3
- RuntimeParameterizedCodecDescriptor,
4
- SqlRuntimeExtensionDescriptor,
5
- } from '@prisma-next/sql-runtime';
6
- import { type as arktype } from 'arktype';
7
- import { codecDefinitions } from '../core/codecs';
8
- import { VECTOR_CODEC_ID, VECTOR_MAX_DIM } from '../core/constants';
1
+ import type { SqlRuntimeExtensionDescriptor } from '@prisma-next/sql-runtime';
9
2
  import { pgvectorPackMeta, pgvectorQueryOperations } from '../core/descriptor-meta';
10
-
11
- const vectorParamsSchema = arktype({
12
- length: 'number',
13
- }).narrow((params, ctx) => {
14
- const { length } = params;
15
- if (!Number.isInteger(length)) {
16
- return ctx.mustBe('an integer');
17
- }
18
- if (length < 1 || length > VECTOR_MAX_DIM) {
19
- return ctx.mustBe(`in the range [1, ${VECTOR_MAX_DIM}]`);
20
- }
21
- return true;
22
- });
23
-
24
- const parameterizedCodecDescriptors = [
25
- {
26
- codecId: VECTOR_CODEC_ID,
27
- paramsSchema: vectorParamsSchema,
28
- },
29
- ] as const satisfies ReadonlyArray<
30
- RuntimeParameterizedCodecDescriptor<{ readonly length: number }>
31
- >;
32
-
33
- function createPgvectorCodecRegistry() {
34
- const registry = createCodecRegistry();
35
- for (const def of Object.values(codecDefinitions)) {
36
- registry.register(def.codec);
37
- }
38
- return registry;
39
- }
3
+ import { pgvectorCodecRegistry } from '../core/registry';
40
4
 
41
5
  const pgvectorRuntimeDescriptor: SqlRuntimeExtensionDescriptor<'postgres'> = {
42
6
  kind: 'extension' as const,
@@ -44,9 +8,14 @@ const pgvectorRuntimeDescriptor: SqlRuntimeExtensionDescriptor<'postgres'> = {
44
8
  version: pgvectorPackMeta.version,
45
9
  familyId: 'sql' as const,
46
10
  targetId: 'postgres' as const,
47
- codecs: createPgvectorCodecRegistry,
48
- queryOperations: () => pgvectorQueryOperations,
49
- parameterizedCodecs: () => parameterizedCodecDescriptors,
11
+ // Expose the unified descriptor list so `extractCodecLookup` reads `targetTypes` / `meta` / `renderOutputType` directly off the descriptors and materializes the representative `Codec` for the SQL renderer's cast-policy lookup.
12
+ types: {
13
+ codecTypes: {
14
+ codecDescriptors: Array.from(pgvectorCodecRegistry.values()),
15
+ },
16
+ },
17
+ codecs: () => Array.from(pgvectorCodecRegistry.values()),
18
+ queryOperations: () => pgvectorQueryOperations(),
50
19
  create() {
51
20
  return {
52
21
  familyId: 'sql' as const,
@@ -55,4 +24,5 @@ const pgvectorRuntimeDescriptor: SqlRuntimeExtensionDescriptor<'postgres'> = {
55
24
  },
56
25
  };
57
26
 
27
+ export { pgvectorCodecRegistry };
58
28
  export default pgvectorRuntimeDescriptor;
@@ -1,4 +1,7 @@
1
1
  import type { SqlQueryOperationTypes } from '@prisma-next/sql-contract/types';
2
+ import type { CodecExpression, Expression } from '@prisma-next/sql-relational-core/expression';
3
+
4
+ type CodecTypesBase = Record<string, { readonly input: unknown; readonly output: unknown }>;
2
5
 
3
6
  /**
4
7
  * Operation type definitions for pgvector extension.
@@ -10,40 +13,31 @@ import type { SqlQueryOperationTypes } from '@prisma-next/sql-contract/types';
10
13
  export type OperationTypes = {
11
14
  readonly 'pg/vector@1': {
12
15
  readonly cosineDistance: {
13
- readonly args: readonly [{ readonly codecId: 'pg/vector@1'; readonly nullable: false }];
14
- readonly returns: { readonly codecId: 'pg/float8@1'; readonly nullable: false };
15
- readonly lowering: {
16
- readonly targetFamily: 'sql';
17
- readonly strategy: 'function';
18
- readonly template: string;
19
- };
16
+ readonly self: { readonly codecId: 'pg/vector@1' };
20
17
  };
21
18
  readonly cosineSimilarity: {
22
- readonly args: readonly [{ readonly codecId: 'pg/vector@1'; readonly nullable: false }];
23
- readonly returns: { readonly codecId: 'pg/float8@1'; readonly nullable: false };
24
- readonly lowering: {
25
- readonly targetFamily: 'sql';
26
- readonly strategy: 'function';
27
- readonly template: string;
28
- };
19
+ readonly self: { readonly codecId: 'pg/vector@1' };
29
20
  };
30
21
  };
31
22
  };
32
23
 
33
24
  /** Flat operation signatures for the query builder. */
34
- export type QueryOperationTypes = SqlQueryOperationTypes<{
35
- readonly cosineDistance: {
36
- readonly args: readonly [
37
- { readonly codecId: 'pg/vector@1'; readonly nullable: boolean },
38
- { readonly codecId: 'pg/vector@1'; readonly nullable: boolean },
39
- ];
40
- readonly returns: { readonly codecId: 'pg/float8@1'; readonly nullable: false };
41
- };
42
- readonly cosineSimilarity: {
43
- readonly args: readonly [
44
- { readonly codecId: 'pg/vector@1'; readonly nullable: boolean },
45
- { readonly codecId: 'pg/vector@1'; readonly nullable: boolean },
46
- ];
47
- readonly returns: { readonly codecId: 'pg/float8@1'; readonly nullable: false };
48
- };
49
- }>;
25
+ export type QueryOperationTypes<CT extends CodecTypesBase> = SqlQueryOperationTypes<
26
+ CT,
27
+ {
28
+ readonly cosineDistance: {
29
+ readonly self: { readonly codecId: 'pg/vector@1' };
30
+ readonly impl: (
31
+ self: CodecExpression<'pg/vector@1', boolean, CT>,
32
+ other: CodecExpression<'pg/vector@1', boolean, CT>,
33
+ ) => Expression<{ codecId: 'pg/float8@1'; nullable: false }>;
34
+ };
35
+ readonly cosineSimilarity: {
36
+ readonly self: { readonly codecId: 'pg/vector@1' };
37
+ readonly impl: (
38
+ self: CodecExpression<'pg/vector@1', boolean, CT>,
39
+ other: CodecExpression<'pg/vector@1', boolean, CT>,
40
+ ) => Expression<{ codecId: 'pg/float8@1'; nullable: false }>;
41
+ };
42
+ }
43
+ >;
@@ -1,27 +0,0 @@
1
- import * as _prisma_next_sql_relational_core_ast0 from "@prisma-next/sql-relational-core/ast";
2
-
3
- //#region src/core/codecs.d.ts
4
-
5
- /**
6
- * Vector codec implementation for pgvector extension.
7
- *
8
- * Provides encoding/decoding for the `vector` PostgreSQL type.
9
- * Wire format is a string like `[1,2,3]` (PostgreSQL vector text format).
10
- */
11
- declare const codecs: _prisma_next_sql_relational_core_ast0.CodecDefBuilder<{} & Record<"vector", _prisma_next_sql_relational_core_ast0.Codec<"pg/vector@1", readonly ["equality"], string, number[], Record<string, unknown>, unknown>>>;
12
- type CodecTypes$1 = typeof codecs.CodecTypes;
13
- //#endregion
14
- //#region src/types/codec-types.d.ts
15
- /**
16
- * Type-level branded vector.
17
- *
18
- * The runtime values are plain number arrays, but parameterized column typing can
19
- * carry the dimension at the type level (e.g. Vector<1536>).
20
- */
21
- type Vector<N extends number = number> = number[] & {
22
- readonly __vectorLength?: N;
23
- };
24
- type CodecTypes = CodecTypes$1;
25
- //#endregion
26
- export { Vector as n, CodecTypes as t };
27
- //# sourceMappingURL=codec-types-BifaP625.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"codec-types-BifaP625.d.mts","names":[],"sources":["../src/core/codecs.ts","../src/types/codec-types.ts"],"sourcesContent":[],"mappings":";;;;;;;AAqEY;;;cAAN,MAAM,EAAA,qCAAA,CAAA,eAAA,CAAA,CAAA,CAAA,GAAA,MAAA,CAAA,QAAA,EAAA,qCAAA,CAAA,KAAA,CAAA,aAAA,EAAA,SAAA,CAAA,UAAA,CAAA,EAAA,MAAA,EAAA,MAAA,EAAA,EAAA,MAAA,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,OAAA,CAAA,CAAA,CAAA;KAOA,YAAA,UAAoB,MAAA,CAAO;;;AAAvC;;;;AC3DA;AAEA;KAFY;4BAA2E;;KAE3E,UAAA,GAAa"}