@prisma-next/extension-pgvector 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"codec-types-D9jU-l1B.d.mts","names":[],"sources":["../src/core/constants.ts","../src/core/codecs.ts","../src/types/codec-types.ts"],"mappings":";;;;;;;;;cAGa,eAAA;;;KCyBR,YAAA;EAAA,SAA0B,MAAA;AAAA;AAAA,cAiBlB,aAAA,SAAsB,SAAA,QAC1B,eAAA;EAAA,SAKE,MAAA;cAEG,UAAA,EAAY,kBAAA,EAAoB,MAAA;EAK5C,YAAA,CAAa,KAAA,oBAAyB,KAAA;EAYhC,MAAA,CAAO,KAAA,YAAiB,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAKjD,MAAA,CAAO,IAAA,UAAc,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAsBpD,UAAA,CAAW,KAAA,aAAkB,SAAA;EAK7B,UAAA,CAAW,IAAA,EAAM,SAAA;AAAA;AAAA,cAMN,kBAAA,SAA2B,mBAAA,CAAoB,YAAA;EAAA,SACxC,OAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,IAAA;IAAA;;;;;;;;WACA,YAAA,EAAc,gBAAA,CAAiB,YAAA;EACxC,gBAAA,CAAiB,MAAA,EAAQ,YAAA;EAGzB,OAAA,CAAQ,MAAA,EAAQ,YAAA,IAAgB,GAAA,EAAK,oBAAA,KAAyB,aAAA;AAAA;AAAA,cAkBnE,kBAAA;EAAA,iBAEI,kBAAA;AAAA;AAAA,KAEE,YAAA,GAAa,iBAAA,QAAyB,kBAAA;;;;;;;;AAjHY;KCTlD,MAAA;EAAA,SAA0D,cAAA,GAAiB,CAAA;AAAA;AAAA,KAE3E,UAAA,GAAa,YAAA"}
1
+ {"version":3,"file":"codec-types-D9jU-l1B.d.mts","names":[],"sources":["../src/core/constants.ts","../src/core/codecs.ts","../src/types/codec-types.ts"],"mappings":";;;;;;;;;cAGa,eAAA;;;KCyBR,YAAA;EAAA,SAA0B,MAAM;AAAA;AAAA,cAiBxB,aAAA,SAAsB,SAAA,QAC1B,eAAA;EAAA,SAKE,MAAA;cAEG,UAAA,EAAY,kBAAA,EAAoB,MAAA;EAK5C,YAAA,CAAa,KAAA,oBAAyB,KAAA;EAYhC,MAAA,CAAO,KAAA,YAAiB,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAKjD,MAAA,CAAO,IAAA,UAAc,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAsBpD,UAAA,CAAW,KAAA,aAAkB,SAAA;EAK7B,UAAA,CAAW,IAAA,EAAM,SAAA;AAAA;AAAA,cAMN,kBAAA,SAA2B,mBAAA,CAAoB,YAAA;EAAA,SACxC,OAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,IAAA;IAAA;;;;;;;;WACA,YAAA,EAAc,gBAAA,CAAiB,YAAA;EACxC,gBAAA,CAAiB,MAAA,EAAQ,YAAA;EAGzB,OAAA,CAAQ,MAAA,EAAQ,YAAA,IAAgB,GAAA,EAAK,oBAAA,KAAyB,aAAA;AAAA;AAAA,cAkBnE,kBAAA;EAAA,iBAEI,kBAAA;AAAA;AAAA,KAEE,YAAA,GAAa,iBAAiB,QAAQ,kBAAA;;;;ADxIG;;;;ACuBS;KCTlD,MAAA;EAAA,SAA0D,cAAA,GAAiB,CAAC;AAAA;AAAA,KAE5E,UAAA,GAAa,YAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"column-types.mjs","names":[],"sources":["../src/exports/column-types.ts"],"sourcesContent":["/**\n * Column type descriptor factory for pgvector extension. `vector(N)` is the canonical authoring surface; every pgvector column must declare a dimension via this factory. The dimension threads into the runtime codec through `paramsSchema.length` and into the DDL via the family-layer `expandNativeType` hook (e.g. `vector(1536)`).\n */\n\nimport type { ColumnTypeDescriptor } from '@prisma-next/framework-components/codec';\nimport { VECTOR_CODEC_ID, VECTOR_MAX_DIM } from '../core/constants';\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', typeParams: { length: 1536 }\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 * @throws {RangeError} If length is not an integer in the range [1, VECTOR_MAX_DIM]\n */\nexport function vector<N extends number>(\n length: N,\n): ColumnTypeDescriptor & { readonly typeParams: { readonly length: N } } {\n if (!Number.isInteger(length) || length < 1 || length > VECTOR_MAX_DIM) {\n throw new RangeError(\n `pgvector: dimension must be an integer in [1, ${VECTOR_MAX_DIM}], got ${length}`,\n );\n }\n return {\n codecId: VECTOR_CODEC_ID,\n nativeType: 'vector',\n typeParams: { length },\n } as const;\n}\n"],"mappings":";;;;;;;;;;;;;;AAmBA,SAAgB,OACd,QACwE;CACxE,IAAI,CAAC,OAAO,UAAU,OAAO,IAAI,SAAS,KAAK,SAAA,MAC7C,MAAM,IAAI,WACR,iDAAiD,eAAe,SAAS,SAC1E;CAEH,OAAO;EACL,SAAS;EACT,YAAY;EACZ,YAAY,EAAE,QAAQ;EACvB"}
1
+ {"version":3,"file":"column-types.mjs","names":[],"sources":["../src/exports/column-types.ts"],"sourcesContent":["/**\n * Column type descriptor factory for pgvector extension. `vector(N)` is the canonical authoring surface; every pgvector column must declare a dimension via this factory. The dimension threads into the runtime codec through `paramsSchema.length` and into the DDL via the family-layer `expandNativeType` hook (e.g. `vector(1536)`).\n */\n\nimport type { ColumnTypeDescriptor } from '@prisma-next/framework-components/codec';\nimport { VECTOR_CODEC_ID, VECTOR_MAX_DIM } from '../core/constants';\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', typeParams: { length: 1536 }\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 * @throws {RangeError} If length is not an integer in the range [1, VECTOR_MAX_DIM]\n */\nexport function vector<N extends number>(\n length: N,\n): ColumnTypeDescriptor & { readonly typeParams: { readonly length: N } } {\n if (!Number.isInteger(length) || length < 1 || length > VECTOR_MAX_DIM) {\n throw new RangeError(\n `pgvector: dimension must be an integer in [1, ${VECTOR_MAX_DIM}], got ${length}`,\n );\n }\n return {\n codecId: VECTOR_CODEC_ID,\n nativeType: 'vector',\n typeParams: { length },\n } as const;\n}\n"],"mappings":";;;;;;;;;;;;;;AAmBA,SAAgB,OACd,QACwE;CACxE,IAAI,CAAC,OAAO,UAAU,MAAM,KAAK,SAAS,KAAK,SAAA,MAC7C,MAAM,IAAI,WACR,iDAAiD,eAAe,SAAS,QAC3E;CAEF,OAAO;EACL,SAAS;EACT,YAAY;EACZ,YAAY,EAAE,OAAO;CACvB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"control.d.mts","names":[],"sources":["../src/exports/control.ts"],"mappings":";;;cAsFM,2BAAA,EAA6B,6BAAA"}
1
+ {"version":3,"file":"control.d.mts","names":[],"sources":["../src/exports/control.ts"],"mappings":";;;cAsFM,2BAAA,EAA6B,6BAA6B"}
package/dist/control.mjs CHANGED
@@ -3,16 +3,10 @@ import { contractSpaceFromJson } from "@prisma-next/migration-tools/spaces";
3
3
  //#region migrations/20260601T0000_install_vector_extension/migration.json
4
4
  var migration_default = {
5
5
  from: null,
6
- to: "sha256:06733db8971afcf2fb373dcd1278e801e9e1e083d6f07d07bc7479e143c938e3",
7
- labels: [],
6
+ to: "sha256:29059dfe21ca210e1f8cc382550e24c429f91f9021607b0c61c90228c4fb84a6",
8
7
  providedInvariants: ["pgvector:install-vector-v1"],
9
8
  createdAt: "2026-06-01T00:00:00.000Z",
10
- hints: {
11
- "used": [],
12
- "applied": [],
13
- "plannerVersion": "2.0.0"
14
- },
15
- migrationHash: "sha256:ff4ad2e6c7af025eafc529c7194a81bf2e2d760939892dc49e81fc701088f262"
9
+ migrationHash: "sha256:b96ff47e8da34232e94ceec345de674908979465d8f394965a980e0a958dea56"
16
10
  };
17
11
  //#endregion
18
12
  //#region migrations/20260601T0000_install_vector_extension/ops.json
@@ -45,7 +39,7 @@ var ops_default = [{
45
39
  //#endregion
46
40
  //#region migrations/refs/head.json
47
41
  var head_default = {
48
- hash: "sha256:06733db8971afcf2fb373dcd1278e801e9e1e083d6f07d07bc7479e143c938e3",
42
+ hash: "sha256:29059dfe21ca210e1f8cc382550e24c429f91f9021607b0c61c90228c4fb84a6",
49
43
  invariants: ["pgvector:install-vector-v1"]
50
44
  };
51
45
  //#endregion
@@ -54,16 +48,16 @@ var contract_default = {
54
48
  schemaVersion: "1",
55
49
  targetFamily: "sql",
56
50
  target: "postgres",
57
- profileHash: "sha256:1a8dbe044289f30a1de958fe800cc5a8378b285d2e126a8c44b58864bac2c18e",
51
+ profileHash: "sha256:9c8aa3114e84ed3b7ea2bd57526d9c2e1bf7c5292be694e9d3801f566fda7ccb",
58
52
  roots: {},
59
- models: {},
53
+ domain: { "namespaces": { "public": { "models": {} } } },
60
54
  storage: {
61
- "namespaces": { "__unbound__": {
62
- "id": "__unbound__",
63
- "kind": "postgres-unbound-schema",
55
+ "namespaces": { "public": {
56
+ "id": "public",
57
+ "kind": "postgres-schema",
64
58
  "tables": {}
65
59
  } },
66
- "storageHash": "sha256:06733db8971afcf2fb373dcd1278e801e9e1e083d6f07d07bc7479e143c938e3",
60
+ "storageHash": "sha256:29059dfe21ca210e1f8cc382550e24c429f91f9021607b0c61c90228c4fb84a6",
67
61
  "types": { "vector": {
68
62
  "codecId": "pg/vector@1",
69
63
  "kind": "codec-instance",
@@ -73,6 +67,7 @@ var contract_default = {
73
67
  },
74
68
  capabilities: {
75
69
  "postgres": {
70
+ "distinctOn": true,
76
71
  "jsonAgg": true,
77
72
  "lateral": true,
78
73
  "limit": true,
@@ -82,6 +77,7 @@ var contract_default = {
82
77
  "sql": {
83
78
  "defaultInInsert": true,
84
79
  "enums": true,
80
+ "lateral": true,
85
81
  "returning": true
86
82
  }
87
83
  },
@@ -1 +1 @@
1
- {"version":3,"file":"control.mjs","names":["baselineMetadata","baselineOps"],"sources":["../migrations/20260601T0000_install_vector_extension/migration.json","../migrations/20260601T0000_install_vector_extension/ops.json","../migrations/refs/head.json","../src/contract.json","../src/core/contract-space-constants.ts","../src/exports/control.ts"],"sourcesContent":["","","","","/**\n * Static names and identifiers used across pgvector's contract space.\n *\n * Centralised here so the contract IR (`./contract`), the baseline\n * migration ops (`./migrations`), the head ref, and the descriptor\n * (`../exports/control`) all reference the same values without typos.\n *\n * The space identifier `'pgvector'` is what the framework writes to\n * `migrations/` in the user's repo and what the marker table's\n * `space` column carries for pgvector-owned rows.\n *\n * The `pgvector:*` invariantId namespace is locked here — once\n * published, an invariantId is immutable so downstream consumers can\n * reference it by literal string match.\n */\n\nexport const PGVECTOR_SPACE_ID = 'pgvector' as const;\n\nexport const PGVECTOR_NATIVE_TYPE = 'vector' as const;\n\nexport const PGVECTOR_BASELINE_MIGRATION_NAME = '20260601T0000_install_vector_extension' as const;\n\n/**\n * `pgvector:*` invariantIds emitted by the baseline migration. Each id,\n * once published, is immutable: downstream consumers (other extensions,\n * the marker table) reference them by literal string match.\n */\nexport const PGVECTOR_INVARIANTS = {\n installVector: 'pgvector:install-vector-v1',\n} as const;\n","/**\n * Control-plane descriptor for the pgvector extension.\n *\n * **Contract-space package layout.** The extension's contract\n * + migrations are emitted by the same pipeline application authors use:\n *\n * `prisma-next contract emit` → `<package>/src/contract.{json,d.ts}`\n * `prisma-next migration plan` → `<package>/migrations/<dir>/...`\n *\n * The descriptor wires those JSON artefacts via JSON-import declarations\n * so they flow through the consuming application's module resolver\n * without filesystem assumptions, and synthesises the canonical\n * {@link import('@prisma-next/framework-components/control').MigrationPackage}\n * shape for the framework's runner / verifier to consume. Readers in\n * `@prisma-next/migration-tools` add `dirPath` when loading from disk\n * (`OnDiskMigrationPackage`); descriptor-bundled packages do not need\n * it because the framework reads them directly from the descriptor.\n *\n * Wired surfaces:\n *\n * - `contractSpace.{contractJson,migrations,headRef}` — sourced from\n * the on-disk artefacts emitted by `build:contract-space`.\n * - `types.codecTypes.controlPlaneHooks[PGVECTOR_CODEC_ID]` — codec\n * control hooks (`expandNativeType`, `resolveIdentityValue`) the\n * SQL planner extracts via `extractCodecControlHooks` and uses to\n * render `vector(N)` column types and the canonical zero-vector\n * identity literal.\n *\n * @see docs/architecture docs/adrs/ADR 212 - Contract spaces.md\n * (contract-space package layout convention).\n */\n\nimport type { Contract } from '@prisma-next/contract/types';\nimport type {\n CodecControlHooks,\n SqlControlExtensionDescriptor,\n} from '@prisma-next/family-sql/control';\nimport { contractSpaceFromJson } from '@prisma-next/migration-tools/spaces';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport baselineMetadata from '../../migrations/20260601T0000_install_vector_extension/migration.json' with {\n type: 'json',\n};\nimport baselineOps from '../../migrations/20260601T0000_install_vector_extension/ops.json' with {\n type: 'json',\n};\nimport headRef from '../../migrations/refs/head.json' with { type: 'json' };\nimport contractJson from '../contract.json' with { type: 'json' };\nimport { PGVECTOR_SPACE_ID } from '../core/contract-space-constants';\nimport { pgvectorPackMeta, pgvectorQueryOperations } from '../core/descriptor-meta';\n\nconst PGVECTOR_CODEC_ID = 'pg/vector@1' as const;\nconst BASELINE_DIR_NAME = '20260601T0000_install_vector_extension';\n\nfunction buildVectorIdentityValue(typeParams: Record<string, unknown> | undefined): string | null {\n const length = typeParams?.['length'];\n if (typeof length !== 'number' || !Number.isInteger(length) || length <= 0) {\n return null;\n }\n\n const zeroVector = `[${new Array(length).fill('0').join(',')}]`;\n return `'${zeroVector}'::vector`;\n}\n\nconst vectorControlPlaneHooks: CodecControlHooks = {\n expandNativeType: ({ nativeType, typeParams }) => {\n const length = typeParams?.['length'];\n if (typeof length === 'number' && Number.isInteger(length) && length > 0) {\n return `${nativeType}(${length})`;\n }\n return nativeType;\n },\n resolveIdentityValue: ({ typeParams }) => buildVectorIdentityValue(typeParams),\n};\n\nconst pgvectorContractSpace = contractSpaceFromJson<Contract<SqlStorage>>({\n contractJson,\n migrations: [\n {\n dirName: BASELINE_DIR_NAME,\n metadata: baselineMetadata,\n ops: baselineOps,\n },\n ],\n headRef,\n});\n\nconst pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {\n ...pgvectorPackMeta,\n id: PGVECTOR_SPACE_ID,\n contractSpace: pgvectorContractSpace,\n types: {\n ...pgvectorPackMeta.types,\n codecTypes: {\n ...pgvectorPackMeta.types.codecTypes,\n controlPlaneHooks: {\n [PGVECTOR_CODEC_ID]: vectorControlPlaneHooks,\n },\n },\n },\n queryOperations: () => pgvectorQueryOperations(),\n create: () => ({\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n }),\n};\n\nexport { pgvectorExtensionDescriptor };\nexport default pgvectorExtensionDescriptor;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AIgBA,MAAa,oBAAoB;;;ACkCjC,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB;AAE1B,SAAS,yBAAyB,YAAgE;CAChG,MAAM,SAAS,aAAa;CAC5B,IAAI,OAAO,WAAW,YAAY,CAAC,OAAO,UAAU,OAAO,IAAI,UAAU,GACvE,OAAO;CAIT,OAAO,IAAI,IADY,IAAI,MAAM,OAAO,CAAC,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC,GACvC;;AAGxB,MAAM,0BAA6C;CACjD,mBAAmB,EAAE,YAAY,iBAAiB;EAChD,MAAM,SAAS,aAAa;EAC5B,IAAI,OAAO,WAAW,YAAY,OAAO,UAAU,OAAO,IAAI,SAAS,GACrE,OAAO,GAAG,WAAW,GAAG,OAAO;EAEjC,OAAO;;CAET,uBAAuB,EAAE,iBAAiB,yBAAyB,WAAW;CAC/E;AAED,MAAM,wBAAwB,sBAA4C;CACxE,cAAA;CACA,YAAY,CACV;EACE,SAAS;EACT,UAAUA;EACV,KAAKC;EACN,CACF;CACD,SAAA;CACD,CAAC;AAEF,MAAM,8BAAyE;CAC7E,GAAG;CACH,IAAI;CACJ,eAAe;CACf,OAAO;EACL,GAAG,iBAAiB;EACpB,YAAY;GACV,GAAG,iBAAiB,MAAM;GAC1B,mBAAmB,GAChB,oBAAoB,yBACtB;GACF;EACF;CACD,uBAAuB,yBAAyB;CAChD,eAAe;EACb,UAAU;EACV,UAAU;EACX;CACF"}
1
+ {"version":3,"file":"control.mjs","names":["baselineMetadata","baselineOps"],"sources":["../migrations/20260601T0000_install_vector_extension/migration.json","../migrations/20260601T0000_install_vector_extension/ops.json","../migrations/refs/head.json","../src/contract.json","../src/core/contract-space-constants.ts","../src/exports/control.ts"],"sourcesContent":["","","","","/**\n * Static names and identifiers used across pgvector's contract space.\n *\n * Centralised here so the contract IR (`./contract`), the baseline\n * migration ops (`./migrations`), the head ref, and the descriptor\n * (`../exports/control`) all reference the same values without typos.\n *\n * The space identifier `'pgvector'` is what the framework writes to\n * `migrations/` in the user's repo and what the marker table's\n * `space` column carries for pgvector-owned rows.\n *\n * The `pgvector:*` invariantId namespace is locked here — once\n * published, an invariantId is immutable so downstream consumers can\n * reference it by literal string match.\n */\n\nexport const PGVECTOR_SPACE_ID = 'pgvector' as const;\n\nexport const PGVECTOR_NATIVE_TYPE = 'vector' as const;\n\nexport const PGVECTOR_BASELINE_MIGRATION_NAME = '20260601T0000_install_vector_extension' as const;\n\n/**\n * `pgvector:*` invariantIds emitted by the baseline migration. Each id,\n * once published, is immutable: downstream consumers (other extensions,\n * the marker table) reference them by literal string match.\n */\nexport const PGVECTOR_INVARIANTS = {\n installVector: 'pgvector:install-vector-v1',\n} as const;\n","/**\n * Control-plane descriptor for the pgvector extension.\n *\n * **Contract-space package layout.** The extension's contract\n * + migrations are emitted by the same pipeline application authors use:\n *\n * `prisma-next contract emit` → `<package>/src/contract.{json,d.ts}`\n * `prisma-next migration plan` → `<package>/migrations/<dir>/...`\n *\n * The descriptor wires those JSON artefacts via JSON-import declarations\n * so they flow through the consuming application's module resolver\n * without filesystem assumptions, and synthesises the canonical\n * {@link import('@prisma-next/framework-components/control').MigrationPackage}\n * shape for the framework's runner / verifier to consume. Readers in\n * `@prisma-next/migration-tools` add `dirPath` when loading from disk\n * (`OnDiskMigrationPackage`); descriptor-bundled packages do not need\n * it because the framework reads them directly from the descriptor.\n *\n * Wired surfaces:\n *\n * - `contractSpace.{contractJson,migrations,headRef}` — sourced from\n * the on-disk artefacts emitted by `build:contract-space`.\n * - `types.codecTypes.controlPlaneHooks[PGVECTOR_CODEC_ID]` — codec\n * control hooks (`expandNativeType`, `resolveIdentityValue`) the\n * SQL planner extracts via `extractCodecControlHooks` and uses to\n * render `vector(N)` column types and the canonical zero-vector\n * identity literal.\n *\n * @see docs/architecture docs/adrs/ADR 212 - Contract spaces.md\n * (contract-space package layout convention).\n */\n\nimport type { Contract } from '@prisma-next/contract/types';\nimport type {\n CodecControlHooks,\n SqlControlExtensionDescriptor,\n} from '@prisma-next/family-sql/control';\nimport { contractSpaceFromJson } from '@prisma-next/migration-tools/spaces';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport baselineMetadata from '../../migrations/20260601T0000_install_vector_extension/migration.json' with {\n type: 'json',\n};\nimport baselineOps from '../../migrations/20260601T0000_install_vector_extension/ops.json' with {\n type: 'json',\n};\nimport headRef from '../../migrations/refs/head.json' with { type: 'json' };\nimport contractJson from '../contract.json' with { type: 'json' };\nimport { PGVECTOR_SPACE_ID } from '../core/contract-space-constants';\nimport { pgvectorPackMeta, pgvectorQueryOperations } from '../core/descriptor-meta';\n\nconst PGVECTOR_CODEC_ID = 'pg/vector@1' as const;\nconst BASELINE_DIR_NAME = '20260601T0000_install_vector_extension';\n\nfunction buildVectorIdentityValue(typeParams: Record<string, unknown> | undefined): string | null {\n const length = typeParams?.['length'];\n if (typeof length !== 'number' || !Number.isInteger(length) || length <= 0) {\n return null;\n }\n\n const zeroVector = `[${new Array(length).fill('0').join(',')}]`;\n return `'${zeroVector}'::vector`;\n}\n\nconst vectorControlPlaneHooks: CodecControlHooks = {\n expandNativeType: ({ nativeType, typeParams }) => {\n const length = typeParams?.['length'];\n if (typeof length === 'number' && Number.isInteger(length) && length > 0) {\n return `${nativeType}(${length})`;\n }\n return nativeType;\n },\n resolveIdentityValue: ({ typeParams }) => buildVectorIdentityValue(typeParams),\n};\n\nconst pgvectorContractSpace = contractSpaceFromJson<Contract<SqlStorage>>({\n contractJson,\n migrations: [\n {\n dirName: BASELINE_DIR_NAME,\n metadata: baselineMetadata,\n ops: baselineOps,\n },\n ],\n headRef,\n});\n\nconst pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {\n ...pgvectorPackMeta,\n id: PGVECTOR_SPACE_ID,\n contractSpace: pgvectorContractSpace,\n types: {\n ...pgvectorPackMeta.types,\n codecTypes: {\n ...pgvectorPackMeta.types.codecTypes,\n controlPlaneHooks: {\n [PGVECTOR_CODEC_ID]: vectorControlPlaneHooks,\n },\n },\n },\n queryOperations: () => pgvectorQueryOperations(),\n create: () => ({\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n }),\n};\n\nexport { pgvectorExtensionDescriptor };\nexport default pgvectorExtensionDescriptor;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AIgBA,MAAa,oBAAoB;;;ACkCjC,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB;AAE1B,SAAS,yBAAyB,YAAgE;CAChG,MAAM,SAAS,aAAa;CAC5B,IAAI,OAAO,WAAW,YAAY,CAAC,OAAO,UAAU,MAAM,KAAK,UAAU,GACvE,OAAO;CAIT,OAAO,IAAI,IADY,IAAI,MAAM,MAAM,EAAE,KAAK,GAAG,EAAE,KAAK,GAAG,EAAE,GACvC;AACxB;AAEA,MAAM,0BAA6C;CACjD,mBAAmB,EAAE,YAAY,iBAAiB;EAChD,MAAM,SAAS,aAAa;EAC5B,IAAI,OAAO,WAAW,YAAY,OAAO,UAAU,MAAM,KAAK,SAAS,GACrE,OAAO,GAAG,WAAW,GAAG,OAAO;EAEjC,OAAO;CACT;CACA,uBAAuB,EAAE,iBAAiB,yBAAyB,UAAU;AAC/E;AAEA,MAAM,wBAAwB,sBAA4C;CACxE,cAAA;CACA,YAAY,CACV;EACE,SAAS;EACT,UAAUA;EACV,KAAKC;CACP,CACF;CACA,SAAA;AACF,CAAC;AAED,MAAM,8BAAyE;CAC7E,GAAG;CACH,IAAI;CACJ,eAAe;CACf,OAAO;EACL,GAAG,iBAAiB;EACpB,YAAY;GACV,GAAG,iBAAiB,MAAM;GAC1B,mBAAmB,GAChB,oBAAoB,wBACvB;EACF;CACF;CACA,uBAAuB,wBAAwB;CAC/C,eAAe;EACb,UAAU;EACV,UAAU;CACZ;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"descriptor-meta-8UnGdpZ6.mjs","names":["arktype"],"sources":["../src/core/authoring.ts","../src/core/codecs.ts","../src/core/registry.ts","../src/core/descriptor-meta.ts"],"sourcesContent":["import type { AuthoringTypeNamespace } from '@prisma-next/framework-components/authoring';\nimport { VECTOR_MAX_DIM } from './constants';\n\nexport const pgvectorAuthoringTypes = {\n pgvector: {\n Vector: {\n kind: 'typeConstructor',\n args: [\n { kind: 'number', name: 'length', integer: true, minimum: 1, maximum: VECTOR_MAX_DIM },\n ],\n output: {\n codecId: 'pg/vector@1',\n nativeType: 'vector',\n typeParams: {\n length: { kind: 'arg', index: 0 },\n },\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n","/**\n * pgvector extension codec.\n *\n * Mirrors the patterns in `postgres/codecs-class.ts` and `sqlite/codecs-class.ts` for the single `pg/vector@1` codec. Three artifacts:\n *\n * 1. `PgVectorCodec` extends {@link CodecImpl} with the runtime encode/decode/encodeJson/decodeJson conversions inline. Conversions are simple enough (PostgreSQL `[1,2,3]` text format) that no shared helper module is warranted; the class body is the source of truth.\n * 2. `PgVectorDescriptor` extends {@link CodecDescriptorImpl} with the codec id, traits, target types, params schema (`{ length: number }`, validated against {@link VECTOR_MAX_DIM}), `meta` (postgres `nativeType: 'vector'`), and the emit-path `renderOutputType` producing `Vector<${length}>`.\n * 3. `pgVectorColumn(length)` per-codec column helper invoking `descriptor.factory({ length })` directly + passing the bare `nativeType: 'vector'`. The family-layer {@link expandNativeType} hook renders the parameterized form (`vector(1536)`) at emit/verify time from `nativeType` + `typeParams`.\n *\n * `length` threads into the runtime codec via the constructor so encode/decode/encodeJson/decodeJson enforce the declared dimension at every ingress path. Without this, `vector(3)` and `vector(1536)` would produce codecs with identical behaviour and a dimension-mismatched value would round-trip undetected.\n */\n\nimport type { JsonValue } from '@prisma-next/contract/types';\nimport {\n type AnyCodecDescriptor,\n type CodecCallContext,\n CodecDescriptorImpl,\n CodecImpl,\n type CodecInstanceContext,\n type ColumnHelperFor,\n type ColumnHelperForStrict,\n column,\n} from '@prisma-next/framework-components/codec';\nimport type { ExtractCodecTypes } from '@prisma-next/sql-relational-core/ast';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { type as arktype } from 'arktype';\nimport { VECTOR_CODEC_ID, VECTOR_MAX_DIM } from './constants';\n\ntype VectorParams = { readonly length: number };\n\nconst vectorParamsSchema = arktype({\n length: 'number',\n}).narrow((params, ctx) => {\n const { length } = params;\n if (!Number.isInteger(length)) {\n return ctx.mustBe('an integer');\n }\n if (length < 1 || length > VECTOR_MAX_DIM) {\n return ctx.mustBe(`in the range [1, ${VECTOR_MAX_DIM}]`);\n }\n return true;\n}) satisfies StandardSchemaV1<VectorParams>;\n\nconst PG_VECTOR_META = { db: { sql: { postgres: { nativeType: 'vector' } } } } as const;\n\nexport class PgVectorCodec extends CodecImpl<\n typeof VECTOR_CODEC_ID,\n readonly ['equality'],\n string,\n number[]\n> {\n readonly length: number;\n\n constructor(descriptor: AnyCodecDescriptor, length: number) {\n super(descriptor);\n this.length = length;\n }\n\n assertVector(value: unknown): asserts value is number[] {\n if (!Array.isArray(value)) {\n throw new Error('Vector value must be an array of numbers');\n }\n if (!value.every((v) => typeof v === 'number')) {\n throw new Error('Vector value must contain only numbers');\n }\n if (value.length !== this.length) {\n throw new Error(`Vector length mismatch: expected ${this.length}, got ${value.length}`);\n }\n }\n\n async encode(value: number[], _ctx: CodecCallContext): Promise<string> {\n this.assertVector(value);\n return `[${value.join(',')}]`;\n }\n\n async decode(wire: string, _ctx: CodecCallContext): Promise<number[]> {\n if (typeof wire !== 'string') {\n throw new Error('Vector wire value must be a string');\n }\n if (!wire.startsWith('[') || !wire.endsWith(']')) {\n throw new Error(`Invalid vector format: expected \"[...]\", got \"${wire}\"`);\n }\n const content = wire.slice(1, -1).trim();\n const parsed =\n content === ''\n ? []\n : content.split(',').map((v) => {\n const num = Number.parseFloat(v.trim());\n if (Number.isNaN(num)) {\n throw new Error(`Invalid vector value: \"${v}\" is not a number`);\n }\n return num;\n });\n this.assertVector(parsed);\n return parsed;\n }\n\n encodeJson(value: number[]): JsonValue {\n this.assertVector(value);\n return value;\n }\n\n decodeJson(json: JsonValue): number[] {\n this.assertVector(json);\n return json;\n }\n}\n\nexport class PgVectorDescriptor extends CodecDescriptorImpl<VectorParams> {\n override readonly codecId = VECTOR_CODEC_ID;\n override readonly traits = ['equality'] as const;\n override readonly targetTypes = ['vector'] as const;\n override readonly meta = PG_VECTOR_META;\n override readonly paramsSchema: StandardSchemaV1<VectorParams> = vectorParamsSchema;\n override renderOutputType(params: VectorParams): string {\n return `Vector<${params.length}>`;\n }\n override factory(params: VectorParams): (ctx: CodecInstanceContext) => PgVectorCodec {\n return () => new PgVectorCodec(this, params.length);\n }\n}\n\nexport const pgVectorDescriptor = new PgVectorDescriptor();\n\n/**\n * Per-codec column helper for `pg/vector@1`. Generic over `N extends number` so the column site preserves the dimension literal in `typeParams` (e.g. `pgVectorColumn(1536)` packs `typeParams: { length: 1536 }`).\n *\n * Passes the bare `nativeType: 'vector'`; the family-layer `expandNativeType` hook renders the parameterized form (`vector(1536)`) at emit/verify time from `nativeType` + `typeParams`.\n */\nexport const pgVectorColumn = <N extends number>(length: N) =>\n column(pgVectorDescriptor.factory({ length }), pgVectorDescriptor.codecId, { length }, 'vector');\n\npgVectorColumn satisfies ColumnHelperFor<PgVectorDescriptor>;\npgVectorColumn satisfies ColumnHelperForStrict<PgVectorDescriptor>;\n\nconst codecDescriptorMap = {\n vector: pgVectorDescriptor,\n} as const;\n\nexport type CodecTypes = ExtractCodecTypes<typeof codecDescriptorMap>;\n\nexport const codecDescriptors: readonly AnyCodecDescriptor[] = Object.values(codecDescriptorMap);\n","import { buildCodecDescriptorRegistry } from '@prisma-next/sql-relational-core/codec-descriptor-registry';\nimport type { CodecDescriptorRegistry } from '@prisma-next/sql-relational-core/query-lane-context';\nimport { codecDescriptors } from './codecs';\n\n/**\n * Registry of every codec descriptor shipped by `@prisma-next/extension-pgvector`.\n *\n * Public consumer surface for the pgvector codec set. Currently a single entry (`pg/vector@1`); the registry shape stays consistent with the other codec-shipping packages so consumers don't need to special-case extensions. See ADR 208.\n */\nexport const pgvectorCodecRegistry: CodecDescriptorRegistry =\n buildCodecDescriptorRegistry(codecDescriptors);\n","import {\n buildOperation,\n type CodecExpression,\n codecOf,\n type Expression,\n toExpr,\n} from '@prisma-next/sql-relational-core/expression';\nimport type { CodecTypes } from '../types/codec-types';\nimport type { QueryOperationTypes } from '../types/operation-types';\nimport { pgvectorAuthoringTypes } from './authoring';\nimport { pgvectorCodecRegistry } from './registry';\n\nconst pgvectorTypeId = 'pg/vector@1' as const;\n\ntype CodecTypesBase = Record<string, { readonly input: unknown; readonly output: unknown }>;\n\nexport function pgvectorQueryOperations<CT extends CodecTypesBase>(): QueryOperationTypes<CT> {\n return {\n cosineDistance: {\n self: { codecId: pgvectorTypeId },\n impl: (\n self: CodecExpression<'pg/vector@1', boolean, CT>,\n other: CodecExpression<'pg/vector@1', boolean, CT>,\n ): Expression<{ codecId: 'pg/float8@1'; nullable: false }> => {\n const selfCodec = codecOf(self);\n return buildOperation({\n method: 'cosineDistance',\n args: [toExpr(self, selfCodec), toExpr(other, selfCodec)],\n returns: { codecId: 'pg/float8@1', nullable: false },\n lowering: {\n targetFamily: 'sql',\n strategy: 'function',\n template: '{{self}} <=> {{arg0}}',\n },\n });\n },\n },\n cosineSimilarity: {\n self: { codecId: pgvectorTypeId },\n impl: (\n self: CodecExpression<'pg/vector@1', boolean, CT>,\n other: CodecExpression<'pg/vector@1', boolean, CT>,\n ): Expression<{ codecId: 'pg/float8@1'; nullable: false }> => {\n const selfCodec = codecOf(self);\n return buildOperation({\n method: 'cosineSimilarity',\n args: [toExpr(self, selfCodec), toExpr(other, selfCodec)],\n returns: { codecId: 'pg/float8@1', nullable: false },\n lowering: {\n targetFamily: 'sql',\n strategy: 'function',\n template: '1 - ({{self}} <=> {{arg0}})',\n },\n });\n },\n },\n };\n}\n\nconst pgvectorPackMetaBase = {\n kind: 'extension',\n id: 'pgvector',\n familyId: 'sql',\n targetId: 'postgres',\n version: '0.0.1',\n capabilities: {\n postgres: {\n 'pgvector.cosine': true,\n },\n },\n authoring: {\n type: pgvectorAuthoringTypes,\n },\n types: {\n codecTypes: {\n codecDescriptors: Array.from(pgvectorCodecRegistry.values()),\n import: {\n package: '@prisma-next/extension-pgvector/codec-types',\n named: 'CodecTypes',\n alias: 'PgVectorTypes',\n },\n typeImports: [\n {\n package: '@prisma-next/extension-pgvector/codec-types',\n named: 'Vector',\n alias: 'Vector',\n },\n ],\n },\n operationTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/operation-types',\n named: 'OperationTypes',\n alias: 'PgVectorOperationTypes',\n },\n },\n queryOperationTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/operation-types',\n named: 'QueryOperationTypes',\n alias: 'PgVectorQueryOperationTypes',\n },\n },\n storage: [\n { typeId: pgvectorTypeId, familyId: 'sql', targetId: 'postgres', nativeType: 'vector' },\n ],\n },\n} as const;\n\nexport const pgvectorPackMeta: typeof pgvectorPackMetaBase & {\n readonly __codecTypes?: CodecTypes;\n} = pgvectorPackMetaBase;\n"],"mappings":"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"}
1
+ {"version":3,"file":"descriptor-meta-8UnGdpZ6.mjs","names":["arktype"],"sources":["../src/core/authoring.ts","../src/core/codecs.ts","../src/core/registry.ts","../src/core/descriptor-meta.ts"],"sourcesContent":["import type { AuthoringTypeNamespace } from '@prisma-next/framework-components/authoring';\nimport { VECTOR_MAX_DIM } from './constants';\n\nexport const pgvectorAuthoringTypes = {\n pgvector: {\n Vector: {\n kind: 'typeConstructor',\n args: [\n { kind: 'number', name: 'length', integer: true, minimum: 1, maximum: VECTOR_MAX_DIM },\n ],\n output: {\n codecId: 'pg/vector@1',\n nativeType: 'vector',\n typeParams: {\n length: { kind: 'arg', index: 0 },\n },\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n","/**\n * pgvector extension codec.\n *\n * Mirrors the patterns in `postgres/codecs-class.ts` and `sqlite/codecs-class.ts` for the single `pg/vector@1` codec. Three artifacts:\n *\n * 1. `PgVectorCodec` extends {@link CodecImpl} with the runtime encode/decode/encodeJson/decodeJson conversions inline. Conversions are simple enough (PostgreSQL `[1,2,3]` text format) that no shared helper module is warranted; the class body is the source of truth.\n * 2. `PgVectorDescriptor` extends {@link CodecDescriptorImpl} with the codec id, traits, target types, params schema (`{ length: number }`, validated against {@link VECTOR_MAX_DIM}), `meta` (postgres `nativeType: 'vector'`), and the emit-path `renderOutputType` producing `Vector<${length}>`.\n * 3. `pgVectorColumn(length)` per-codec column helper invoking `descriptor.factory({ length })` directly + passing the bare `nativeType: 'vector'`. The family-layer {@link expandNativeType} hook renders the parameterized form (`vector(1536)`) at emit/verify time from `nativeType` + `typeParams`.\n *\n * `length` threads into the runtime codec via the constructor so encode/decode/encodeJson/decodeJson enforce the declared dimension at every ingress path. Without this, `vector(3)` and `vector(1536)` would produce codecs with identical behaviour and a dimension-mismatched value would round-trip undetected.\n */\n\nimport type { JsonValue } from '@prisma-next/contract/types';\nimport {\n type AnyCodecDescriptor,\n type CodecCallContext,\n CodecDescriptorImpl,\n CodecImpl,\n type CodecInstanceContext,\n type ColumnHelperFor,\n type ColumnHelperForStrict,\n column,\n} from '@prisma-next/framework-components/codec';\nimport type { ExtractCodecTypes } from '@prisma-next/sql-relational-core/ast';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { type as arktype } from 'arktype';\nimport { VECTOR_CODEC_ID, VECTOR_MAX_DIM } from './constants';\n\ntype VectorParams = { readonly length: number };\n\nconst vectorParamsSchema = arktype({\n length: 'number',\n}).narrow((params, ctx) => {\n const { length } = params;\n if (!Number.isInteger(length)) {\n return ctx.mustBe('an integer');\n }\n if (length < 1 || length > VECTOR_MAX_DIM) {\n return ctx.mustBe(`in the range [1, ${VECTOR_MAX_DIM}]`);\n }\n return true;\n}) satisfies StandardSchemaV1<VectorParams>;\n\nconst PG_VECTOR_META = { db: { sql: { postgres: { nativeType: 'vector' } } } } as const;\n\nexport class PgVectorCodec extends CodecImpl<\n typeof VECTOR_CODEC_ID,\n readonly ['equality'],\n string,\n number[]\n> {\n readonly length: number;\n\n constructor(descriptor: AnyCodecDescriptor, length: number) {\n super(descriptor);\n this.length = length;\n }\n\n assertVector(value: unknown): asserts value is number[] {\n if (!Array.isArray(value)) {\n throw new Error('Vector value must be an array of numbers');\n }\n if (!value.every((v) => typeof v === 'number')) {\n throw new Error('Vector value must contain only numbers');\n }\n if (value.length !== this.length) {\n throw new Error(`Vector length mismatch: expected ${this.length}, got ${value.length}`);\n }\n }\n\n async encode(value: number[], _ctx: CodecCallContext): Promise<string> {\n this.assertVector(value);\n return `[${value.join(',')}]`;\n }\n\n async decode(wire: string, _ctx: CodecCallContext): Promise<number[]> {\n if (typeof wire !== 'string') {\n throw new Error('Vector wire value must be a string');\n }\n if (!wire.startsWith('[') || !wire.endsWith(']')) {\n throw new Error(`Invalid vector format: expected \"[...]\", got \"${wire}\"`);\n }\n const content = wire.slice(1, -1).trim();\n const parsed =\n content === ''\n ? []\n : content.split(',').map((v) => {\n const num = Number.parseFloat(v.trim());\n if (Number.isNaN(num)) {\n throw new Error(`Invalid vector value: \"${v}\" is not a number`);\n }\n return num;\n });\n this.assertVector(parsed);\n return parsed;\n }\n\n encodeJson(value: number[]): JsonValue {\n this.assertVector(value);\n return value;\n }\n\n decodeJson(json: JsonValue): number[] {\n this.assertVector(json);\n return json;\n }\n}\n\nexport class PgVectorDescriptor extends CodecDescriptorImpl<VectorParams> {\n override readonly codecId = VECTOR_CODEC_ID;\n override readonly traits = ['equality'] as const;\n override readonly targetTypes = ['vector'] as const;\n override readonly meta = PG_VECTOR_META;\n override readonly paramsSchema: StandardSchemaV1<VectorParams> = vectorParamsSchema;\n override renderOutputType(params: VectorParams): string {\n return `Vector<${params.length}>`;\n }\n override factory(params: VectorParams): (ctx: CodecInstanceContext) => PgVectorCodec {\n return () => new PgVectorCodec(this, params.length);\n }\n}\n\nexport const pgVectorDescriptor = new PgVectorDescriptor();\n\n/**\n * Per-codec column helper for `pg/vector@1`. Generic over `N extends number` so the column site preserves the dimension literal in `typeParams` (e.g. `pgVectorColumn(1536)` packs `typeParams: { length: 1536 }`).\n *\n * Passes the bare `nativeType: 'vector'`; the family-layer `expandNativeType` hook renders the parameterized form (`vector(1536)`) at emit/verify time from `nativeType` + `typeParams`.\n */\nexport const pgVectorColumn = <N extends number>(length: N) =>\n column(pgVectorDescriptor.factory({ length }), pgVectorDescriptor.codecId, { length }, 'vector');\n\npgVectorColumn satisfies ColumnHelperFor<PgVectorDescriptor>;\npgVectorColumn satisfies ColumnHelperForStrict<PgVectorDescriptor>;\n\nconst codecDescriptorMap = {\n vector: pgVectorDescriptor,\n} as const;\n\nexport type CodecTypes = ExtractCodecTypes<typeof codecDescriptorMap>;\n\nexport const codecDescriptors: readonly AnyCodecDescriptor[] = Object.values(codecDescriptorMap);\n","import { buildCodecDescriptorRegistry } from '@prisma-next/sql-relational-core/codec-descriptor-registry';\nimport type { CodecDescriptorRegistry } from '@prisma-next/sql-relational-core/query-lane-context';\nimport { codecDescriptors } from './codecs';\n\n/**\n * Registry of every codec descriptor shipped by `@prisma-next/extension-pgvector`.\n *\n * Public consumer surface for the pgvector codec set. Currently a single entry (`pg/vector@1`); the registry shape stays consistent with the other codec-shipping packages so consumers don't need to special-case extensions. See ADR 208.\n */\nexport const pgvectorCodecRegistry: CodecDescriptorRegistry =\n buildCodecDescriptorRegistry(codecDescriptors);\n","import {\n buildOperation,\n type CodecExpression,\n codecOf,\n type Expression,\n toExpr,\n} from '@prisma-next/sql-relational-core/expression';\nimport type { CodecTypes } from '../types/codec-types';\nimport type { QueryOperationTypes } from '../types/operation-types';\nimport { pgvectorAuthoringTypes } from './authoring';\nimport { pgvectorCodecRegistry } from './registry';\n\nconst pgvectorTypeId = 'pg/vector@1' as const;\n\ntype CodecTypesBase = Record<string, { readonly input: unknown; readonly output: unknown }>;\n\nexport function pgvectorQueryOperations<CT extends CodecTypesBase>(): QueryOperationTypes<CT> {\n return {\n cosineDistance: {\n self: { codecId: pgvectorTypeId },\n impl: (\n self: CodecExpression<'pg/vector@1', boolean, CT>,\n other: CodecExpression<'pg/vector@1', boolean, CT>,\n ): Expression<{ codecId: 'pg/float8@1'; nullable: false }> => {\n const selfCodec = codecOf(self);\n return buildOperation({\n method: 'cosineDistance',\n args: [toExpr(self, selfCodec), toExpr(other, selfCodec)],\n returns: { codecId: 'pg/float8@1', nullable: false },\n lowering: {\n targetFamily: 'sql',\n strategy: 'function',\n template: '{{self}} <=> {{arg0}}',\n },\n });\n },\n },\n cosineSimilarity: {\n self: { codecId: pgvectorTypeId },\n impl: (\n self: CodecExpression<'pg/vector@1', boolean, CT>,\n other: CodecExpression<'pg/vector@1', boolean, CT>,\n ): Expression<{ codecId: 'pg/float8@1'; nullable: false }> => {\n const selfCodec = codecOf(self);\n return buildOperation({\n method: 'cosineSimilarity',\n args: [toExpr(self, selfCodec), toExpr(other, selfCodec)],\n returns: { codecId: 'pg/float8@1', nullable: false },\n lowering: {\n targetFamily: 'sql',\n strategy: 'function',\n template: '1 - ({{self}} <=> {{arg0}})',\n },\n });\n },\n },\n };\n}\n\nconst pgvectorPackMetaBase = {\n kind: 'extension',\n id: 'pgvector',\n familyId: 'sql',\n targetId: 'postgres',\n version: '0.0.1',\n capabilities: {\n postgres: {\n 'pgvector.cosine': true,\n },\n },\n authoring: {\n type: pgvectorAuthoringTypes,\n },\n types: {\n codecTypes: {\n codecDescriptors: Array.from(pgvectorCodecRegistry.values()),\n import: {\n package: '@prisma-next/extension-pgvector/codec-types',\n named: 'CodecTypes',\n alias: 'PgVectorTypes',\n },\n typeImports: [\n {\n package: '@prisma-next/extension-pgvector/codec-types',\n named: 'Vector',\n alias: 'Vector',\n },\n ],\n },\n operationTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/operation-types',\n named: 'OperationTypes',\n alias: 'PgVectorOperationTypes',\n },\n },\n queryOperationTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/operation-types',\n named: 'QueryOperationTypes',\n alias: 'PgVectorQueryOperationTypes',\n },\n },\n storage: [\n { typeId: pgvectorTypeId, familyId: 'sql', targetId: 'postgres', nativeType: 'vector' },\n ],\n },\n} as const;\n\nexport const pgvectorPackMeta: typeof pgvectorPackMetaBase & {\n readonly __codecTypes?: CodecTypes;\n} = pgvectorPackMetaBase;\n"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"operation-types-Bd-jkNN3.d.mts","names":[],"sources":["../src/types/operation-types.ts"],"mappings":";;;;KAGK,cAAA,GAAiB,MAAA;EAAA,SAA0B,KAAA;EAAA,SAAyB,MAAA;AAAA;;;;;;;;KAU7D,mBAAA,YAA+B,cAAA,IAAkB,sBAAA,CAC3D,EAAA;EAAA,SAEW,cAAA;IAAA,SACE,IAAA;MAAA,SAAiB,OAAA;IAAA;IAAA,SACjB,IAAA,GACP,IAAA,EAAM,eAAA,yBAAwC,EAAA,GAC9C,KAAA,EAAO,eAAA,yBAAwC,EAAA,MAC5C,UAAA;MAAa,OAAA;MAAwB,QAAA;IAAA;EAAA;EAAA,SAEnC,gBAAA;IAAA,SACE,IAAA;MAAA,SAAiB,OAAA;IAAA;IAAA,SACjB,IAAA,GACP,IAAA,EAAM,eAAA,yBAAwC,EAAA,GAC9C,KAAA,EAAO,eAAA,yBAAwC,EAAA,MAC5C,UAAA;MAAa,OAAA;MAAwB,QAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"file":"operation-types-Bd-jkNN3.d.mts","names":[],"sources":["../src/types/operation-types.ts"],"mappings":";;;;KAGK,cAAA,GAAiB,MAAM;EAAA,SAAoB,KAAA;EAAA,SAAyB,MAAA;AAAA;;;;;;;AAAM;AAAA,KAUnE,mBAAA,YAA+B,cAAA,IAAkB,sBAAA,CAC3D,EAAA;EAAA,SAEW,cAAA;IAAA,SACE,IAAA;MAAA,SAAiB,OAAA;IAAA;IAAA,SACjB,IAAA,GACP,IAAA,EAAM,eAAA,yBAAwC,EAAA,GAC9C,KAAA,EAAO,eAAA,yBAAwC,EAAA,MAC5C,UAAA;MAAa,OAAA;MAAwB,QAAA;IAAA;EAAA;EAAA,SAEnC,gBAAA;IAAA,SACE,IAAA;MAAA,SAAiB,OAAA;IAAA;IAAA,SACjB,IAAA,GACP,IAAA,EAAM,eAAA,yBAAwC,EAAA,GAC9C,KAAA,EAAO,eAAA,yBAAwC,EAAA,MAC5C,UAAA;MAAa,OAAA;MAAwB,QAAA;IAAA;EAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"pack.d.mts","names":[],"sources":["../src/core/descriptor-meta.ts"],"mappings":";;;;cA2DM,oBAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAgDI,0CAAA,CAAA,eAAA;MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEG,gBAAA,SAAyB,oBAAA;EAAA,SAC3B,YAAA,GAAe,UAAA;AAAA"}
1
+ {"version":3,"file":"pack.d.mts","names":[],"sources":["../src/core/descriptor-meta.ts"],"mappings":";;;;cA2DM,oBAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAgDI,0CAAA,CAAA,eAAA;MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEG,gBAAA,SAAyB,oBAAA;EAAA,SAC3B,YAAA,GAAe,UAAU;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/registry.ts","../src/exports/runtime.ts"],"mappings":";;;;;;;AASA;;cAAa,qBAAA,EAAuB,uBAAA;;;cCL9B,yBAAA,EAA2B,6BAAA"}
1
+ {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/registry.ts","../src/exports/runtime.ts"],"mappings":";;;;;;;AASA;;cAAa,qBAAA,EAAuB,uBACY;;;cCN1C,yBAAA,EAA2B,6BAA6B"}
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type { SqlRuntimeExtensionDescriptor } from '@prisma-next/sql-runtime';\nimport { pgvectorPackMeta, pgvectorQueryOperations } from '../core/descriptor-meta';\nimport { pgvectorCodecRegistry } from '../core/registry';\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 // 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.\n types: {\n codecTypes: {\n codecDescriptors: Array.from(pgvectorCodecRegistry.values()),\n },\n },\n codecs: () => Array.from(pgvectorCodecRegistry.values()),\n queryOperations: () => pgvectorQueryOperations(),\n create() {\n return {\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n };\n },\n};\n\nexport { pgvectorCodecRegistry };\nexport default pgvectorRuntimeDescriptor;\n"],"mappings":";;AAIA,MAAM,4BAAuE;CAC3E,MAAM;CACN,IAAI,iBAAiB;CACrB,SAAS,iBAAiB;CAC1B,UAAU;CACV,UAAU;CAEV,OAAO,EACL,YAAY,EACV,kBAAkB,MAAM,KAAK,sBAAsB,QAAQ,CAAC,EAC7D,EACF;CACD,cAAc,MAAM,KAAK,sBAAsB,QAAQ,CAAC;CACxD,uBAAuB,yBAAyB;CAChD,SAAS;EACP,OAAO;GACL,UAAU;GACV,UAAU;GACX;;CAEJ"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type { SqlRuntimeExtensionDescriptor } from '@prisma-next/sql-runtime';\nimport { pgvectorPackMeta, pgvectorQueryOperations } from '../core/descriptor-meta';\nimport { pgvectorCodecRegistry } from '../core/registry';\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 // 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.\n types: {\n codecTypes: {\n codecDescriptors: Array.from(pgvectorCodecRegistry.values()),\n },\n },\n codecs: () => Array.from(pgvectorCodecRegistry.values()),\n queryOperations: () => pgvectorQueryOperations(),\n create() {\n return {\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n };\n },\n};\n\nexport { pgvectorCodecRegistry };\nexport default pgvectorRuntimeDescriptor;\n"],"mappings":";;AAIA,MAAM,4BAAuE;CAC3E,MAAM;CACN,IAAI,iBAAiB;CACrB,SAAS,iBAAiB;CAC1B,UAAU;CACV,UAAU;CAEV,OAAO,EACL,YAAY,EACV,kBAAkB,MAAM,KAAK,sBAAsB,OAAO,CAAC,EAC7D,EACF;CACA,cAAc,MAAM,KAAK,sBAAsB,OAAO,CAAC;CACvD,uBAAuB,wBAAwB;CAC/C,SAAS;EACP,OAAO;GACL,UAAU;GACV,UAAU;EACZ;CACF;AACF"}
package/package.json CHANGED
@@ -1,43 +1,47 @@
1
1
  {
2
2
  "name": "@prisma-next/extension-pgvector",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "dependencies": {
8
- "@prisma-next/contract": "0.11.0",
9
- "@prisma-next/contract-authoring": "0.11.0",
10
- "@prisma-next/family-sql": "0.11.0",
11
- "@prisma-next/framework-components": "0.11.0",
12
- "@prisma-next/migration-tools": "0.11.0",
13
- "@prisma-next/sql-contract": "0.11.0",
14
- "@prisma-next/sql-operations": "0.11.0",
15
- "@prisma-next/sql-relational-core": "0.11.0",
16
- "@prisma-next/sql-runtime": "0.11.0",
17
- "@prisma-next/sql-schema-ir": "0.11.0",
8
+ "@prisma-next/contract": "0.12.0",
9
+ "@prisma-next/contract-authoring": "0.12.0",
10
+ "@prisma-next/family-sql": "0.12.0",
11
+ "@prisma-next/framework-components": "0.12.0",
12
+ "@prisma-next/migration-tools": "0.12.0",
13
+ "@prisma-next/sql-contract": "0.12.0",
14
+ "@prisma-next/sql-operations": "0.12.0",
15
+ "@prisma-next/sql-relational-core": "0.12.0",
16
+ "@prisma-next/sql-runtime": "0.12.0",
17
+ "@prisma-next/sql-schema-ir": "0.12.0",
18
18
  "@standard-schema/spec": "^1.1.0",
19
19
  "arktype": "^2.2.0"
20
20
  },
21
21
  "devDependencies": {
22
- "@prisma-next/adapter-postgres": "0.11.0",
23
- "@prisma-next/cli": "0.11.0",
24
- "@prisma-next/operations": "0.11.0",
25
- "@prisma-next/postgres": "0.11.0",
26
- "@prisma-next/sql-contract-ts": "0.11.0",
27
- "@prisma-next/target-postgres": "0.11.0",
28
- "@prisma-next/test-utils": "0.11.0",
29
- "@prisma-next/tsconfig": "0.11.0",
30
- "@prisma-next/tsdown": "0.11.0",
22
+ "@prisma-next/adapter-postgres": "0.12.0",
23
+ "@prisma-next/cli": "0.12.0",
24
+ "@prisma-next/operations": "0.12.0",
25
+ "@prisma-next/postgres": "0.12.0",
26
+ "@prisma-next/sql-contract-ts": "0.12.0",
27
+ "@prisma-next/target-postgres": "0.12.0",
28
+ "@prisma-next/test-utils": "0.12.0",
29
+ "@prisma-next/tsconfig": "0.12.0",
30
+ "@prisma-next/tsdown": "0.12.0",
31
31
  "tsdown": "0.22.0",
32
32
  "typescript": "5.9.3",
33
33
  "vitest": "4.1.6"
34
34
  },
35
35
  "peerDependencies": {
36
- "@prisma-next/adapter-postgres": "0.11.0"
36
+ "@prisma-next/adapter-postgres": "0.12.0",
37
+ "typescript": ">=5.9"
37
38
  },
38
39
  "peerDependenciesMeta": {
39
40
  "@prisma-next/adapter-postgres": {
40
41
  "optional": true
42
+ },
43
+ "typescript": {
44
+ "optional": true
41
45
  }
42
46
  },
43
47
  "files": [
@@ -53,6 +57,9 @@
53
57
  "./runtime": "./dist/runtime.mjs",
54
58
  "./package.json": "./package.json"
55
59
  },
60
+ "engines": {
61
+ "node": ">=24"
62
+ },
56
63
  "repository": {
57
64
  "type": "git",
58
65
  "url": "https://github.com/prisma/prisma-next.git",
package/src/contract.d.ts CHANGED
@@ -1,19 +1,21 @@
1
1
  // ⚠️ GENERATED FILE - DO NOT EDIT
2
2
  // This file is automatically generated by 'prisma-next contract emit'.
3
3
  // To regenerate, run: prisma-next contract emit
4
- import type { CodecTypes as PgTypes } from '@prisma-next/target-postgres/codec-types';
5
- import type { JsonValue } from '@prisma-next/target-postgres/codec-types';
6
- import type { Char } from '@prisma-next/target-postgres/codec-types';
7
- import type { Varchar } from '@prisma-next/target-postgres/codec-types';
8
- import type { Numeric } from '@prisma-next/target-postgres/codec-types';
9
- import type { Bit } from '@prisma-next/target-postgres/codec-types';
10
- import type { VarBit } from '@prisma-next/target-postgres/codec-types';
11
- import type { Timestamp } from '@prisma-next/target-postgres/codec-types';
12
- import type { Timestamptz } from '@prisma-next/target-postgres/codec-types';
13
- import type { Time } from '@prisma-next/target-postgres/codec-types';
14
- import type { Timetz } from '@prisma-next/target-postgres/codec-types';
15
- import type { Interval } from '@prisma-next/target-postgres/codec-types';
16
4
  import type { QueryOperationTypes as PgAdapterQueryOps } from '@prisma-next/adapter-postgres/operation-types';
5
+ import type {
6
+ Bit,
7
+ Char,
8
+ CodecTypes as PgTypes,
9
+ Interval,
10
+ JsonValue,
11
+ Numeric,
12
+ Time,
13
+ Timestamp,
14
+ Timestamptz,
15
+ Timetz,
16
+ VarBit,
17
+ Varchar,
18
+ } from '@prisma-next/target-postgres/codec-types';
17
19
 
18
20
  import type {
19
21
  ContractWithTypeMaps,
@@ -21,16 +23,18 @@ import type {
21
23
  } from '@prisma-next/sql-contract/types';
22
24
  import type {
23
25
  Contract as ContractType,
26
+ ContractModelsMap,
24
27
  ExecutionHashBase,
28
+ NamespaceId,
25
29
  ProfileHashBase,
26
30
  StorageHashBase,
27
31
  } from '@prisma-next/contract/types';
28
32
 
29
33
  export type StorageHash =
30
- StorageHashBase<'sha256:06733db8971afcf2fb373dcd1278e801e9e1e083d6f07d07bc7479e143c938e3'>;
34
+ StorageHashBase<'sha256:29059dfe21ca210e1f8cc382550e24c429f91f9021607b0c61c90228c4fb84a6'>;
31
35
  export type ExecutionHash = ExecutionHashBase<string>;
32
36
  export type ProfileHash =
33
- ProfileHashBase<'sha256:1a8dbe044289f30a1de958fe800cc5a8378b285d2e126a8c44b58864bac2c18e'>;
37
+ ProfileHashBase<'sha256:9c8aa3114e84ed3b7ea2bd57526d9c2e1bf7c5292be694e9d3801f566fda7ccb'>;
34
38
 
35
39
  export type CodecTypes = PgTypes;
36
40
  export type LaneCodecTypes = CodecTypes;
@@ -48,32 +52,43 @@ export type TypeMaps = TypeMapsType<
48
52
  FieldInputTypes
49
53
  >;
50
54
 
51
- type ContractBase = ContractType<
52
- {
53
- readonly namespaces: {
54
- readonly __unbound__: {
55
- readonly id: '__unbound__';
56
- readonly kind: 'sql-namespace';
57
- readonly tables: {};
55
+ type ContractBase = Omit<
56
+ ContractType<
57
+ {
58
+ readonly namespaces: {
59
+ readonly public: {
60
+ readonly id: 'public';
61
+ readonly kind: 'sql-namespace';
62
+ readonly tables: {};
63
+ };
58
64
  };
59
- };
60
- readonly types: {
61
- readonly vector: {
62
- readonly kind: 'codec-instance';
63
- readonly codecId: 'pg/vector@1';
64
- readonly nativeType: 'vector';
65
- readonly typeParams: Record<string, never>;
65
+ readonly types: {
66
+ readonly vector: {
67
+ readonly kind: 'codec-instance';
68
+ readonly codecId: 'pg/vector@1';
69
+ readonly nativeType: 'vector';
70
+ readonly typeParams: Record<string, never>;
71
+ };
66
72
  };
67
- };
68
- readonly storageHash: StorageHash;
69
- },
70
- Record<string, never>
73
+ readonly storageHash: StorageHash;
74
+ },
75
+ Record<string, never>
76
+ >,
77
+ 'roots' | 'domain'
71
78
  > & {
72
79
  readonly target: 'postgres';
73
80
  readonly targetFamily: 'sql';
74
- readonly roots: Record<string, string>;
81
+ readonly roots: Record<string, never>;
82
+ readonly domain: {
83
+ readonly namespaces: {
84
+ readonly public: {
85
+ readonly models: Record<string, never>;
86
+ };
87
+ };
88
+ };
75
89
  readonly capabilities: {
76
90
  readonly postgres: {
91
+ readonly distinctOn: true;
77
92
  readonly jsonAgg: true;
78
93
  readonly lateral: true;
79
94
  readonly limit: true;
@@ -83,6 +98,7 @@ type ContractBase = ContractType<
83
98
  readonly sql: {
84
99
  readonly defaultInInsert: true;
85
100
  readonly enums: true;
101
+ readonly lateral: true;
86
102
  readonly returning: true;
87
103
  };
88
104
  };
@@ -95,4 +111,4 @@ type ContractBase = ContractType<
95
111
  export type Contract = ContractWithTypeMaps<ContractBase, TypeMaps>;
96
112
 
97
113
  export type Namespaces = Contract['storage']['namespaces'];
98
- export type Models = Contract['models'];
114
+ export type Models = ContractModelsMap<Contract>;
package/src/contract.json CHANGED
@@ -2,18 +2,24 @@
2
2
  "schemaVersion": "1",
3
3
  "targetFamily": "sql",
4
4
  "target": "postgres",
5
- "profileHash": "sha256:1a8dbe044289f30a1de958fe800cc5a8378b285d2e126a8c44b58864bac2c18e",
5
+ "profileHash": "sha256:9c8aa3114e84ed3b7ea2bd57526d9c2e1bf7c5292be694e9d3801f566fda7ccb",
6
6
  "roots": {},
7
- "models": {},
7
+ "domain": {
8
+ "namespaces": {
9
+ "public": {
10
+ "models": {}
11
+ }
12
+ }
13
+ },
8
14
  "storage": {
9
15
  "namespaces": {
10
- "__unbound__": {
11
- "id": "__unbound__",
12
- "kind": "postgres-unbound-schema",
16
+ "public": {
17
+ "id": "public",
18
+ "kind": "postgres-schema",
13
19
  "tables": {}
14
20
  }
15
21
  },
16
- "storageHash": "sha256:06733db8971afcf2fb373dcd1278e801e9e1e083d6f07d07bc7479e143c938e3",
22
+ "storageHash": "sha256:29059dfe21ca210e1f8cc382550e24c429f91f9021607b0c61c90228c4fb84a6",
17
23
  "types": {
18
24
  "vector": {
19
25
  "codecId": "pg/vector@1",
@@ -25,6 +31,7 @@
25
31
  },
26
32
  "capabilities": {
27
33
  "postgres": {
34
+ "distinctOn": true,
28
35
  "jsonAgg": true,
29
36
  "lateral": true,
30
37
  "limit": true,
@@ -34,6 +41,7 @@
34
41
  "sql": {
35
42
  "defaultInInsert": true,
36
43
  "enums": true,
44
+ "lateral": true,
37
45
  "returning": true
38
46
  }
39
47
  },
package/src/contract.ts CHANGED
@@ -21,9 +21,8 @@
21
21
  * pgvector's space contribution and so the pinned `contract.json` on
22
22
  * disk is materially distinct from an empty space.
23
23
  *
24
- * Unlike CipherStash's deferred typed objects (composite types /
25
- * domains / enums IR vocabulary deferral, see
26
- * `packages/3-extensions/cipherstash/src/contract.prisma`),
24
+ * Unlike extensions that defer typed objects (composite types /
25
+ * domains / enums) beyond the current IR vocabulary,
27
26
  * pgvector's `vector` IS representable in today's IR via
28
27
  * {@link StorageTypeInstance}.
29
28
  *