@prisma-next/extension-pgvector 0.3.0-dev.6 → 0.3.0-dev.64

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 (70) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +18 -11
  3. package/dist/codec-types.d.mts +41 -0
  4. package/dist/codec-types.d.mts.map +1 -0
  5. package/dist/codec-types.mjs +1 -0
  6. package/dist/column-types.d.mts +33 -0
  7. package/dist/column-types.d.mts.map +1 -0
  8. package/dist/column-types.mjs +36 -0
  9. package/dist/column-types.mjs.map +1 -0
  10. package/dist/constants-BmZpaev5.mjs +13 -0
  11. package/dist/constants-BmZpaev5.mjs.map +1 -0
  12. package/dist/control.d.mts +7 -0
  13. package/dist/control.d.mts.map +1 -0
  14. package/dist/control.mjs +49 -0
  15. package/dist/control.mjs.map +1 -0
  16. package/dist/descriptor-meta-BADTQp0u.mjs +57 -0
  17. package/dist/descriptor-meta-BADTQp0u.mjs.map +1 -0
  18. package/dist/operation-types.d.mts +32 -0
  19. package/dist/operation-types.d.mts.map +1 -0
  20. package/dist/operation-types.mjs +1 -0
  21. package/dist/pack.d.mts +46 -0
  22. package/dist/pack.d.mts.map +1 -0
  23. package/dist/pack.mjs +9 -0
  24. package/dist/pack.mjs.map +1 -0
  25. package/dist/runtime.d.mts +7 -0
  26. package/dist/runtime.d.mts.map +1 -0
  27. package/dist/runtime.mjs +74 -0
  28. package/dist/runtime.mjs.map +1 -0
  29. package/package.json +37 -49
  30. package/src/core/constants.ts +9 -0
  31. package/src/core/descriptor-meta.ts +16 -17
  32. package/src/exports/codec-types.ts +1 -1
  33. package/src/exports/column-types.ts +34 -1
  34. package/src/exports/control.ts +2 -13
  35. package/src/exports/runtime.ts +37 -27
  36. package/src/types/codec-types.ts +23 -1
  37. package/dist/chunk-SHWLERB3.js +0 -60
  38. package/dist/chunk-SHWLERB3.js.map +0 -1
  39. package/dist/core/codecs.d.ts +0 -23
  40. package/dist/core/codecs.d.ts.map +0 -1
  41. package/dist/core/descriptor-meta.d.ts +0 -53
  42. package/dist/core/descriptor-meta.d.ts.map +0 -1
  43. package/dist/exports/codec-types.d.ts +0 -7
  44. package/dist/exports/codec-types.d.ts.map +0 -1
  45. package/dist/exports/codec-types.js +0 -1
  46. package/dist/exports/codec-types.js.map +0 -1
  47. package/dist/exports/column-types.d.ts +0 -11
  48. package/dist/exports/column-types.d.ts.map +0 -1
  49. package/dist/exports/column-types.js +0 -9
  50. package/dist/exports/column-types.js.map +0 -1
  51. package/dist/exports/control.d.ts +0 -9
  52. package/dist/exports/control.d.ts.map +0 -1
  53. package/dist/exports/control.js +0 -67
  54. package/dist/exports/control.js.map +0 -1
  55. package/dist/exports/operation-types.d.ts +0 -7
  56. package/dist/exports/operation-types.d.ts.map +0 -1
  57. package/dist/exports/operation-types.js +0 -1
  58. package/dist/exports/operation-types.js.map +0 -1
  59. package/dist/exports/pack.d.ts +0 -52
  60. package/dist/exports/pack.d.ts.map +0 -1
  61. package/dist/exports/pack.js +0 -11
  62. package/dist/exports/pack.js.map +0 -1
  63. package/dist/exports/runtime.d.ts +0 -8
  64. package/dist/exports/runtime.d.ts.map +0 -1
  65. package/dist/exports/runtime.js +0 -86
  66. package/dist/exports/runtime.js.map +0 -1
  67. package/dist/types/codec-types.d.ts +0 -10
  68. package/dist/types/codec-types.d.ts.map +0 -1
  69. package/dist/types/operation-types.d.ts +0 -31
  70. package/dist/types/operation-types.d.ts.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2026] [Prisma Data, Inc]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -8,7 +8,7 @@ This extension pack adds support for the `vector` data type and vector similarit
8
8
 
9
9
  ## Responsibilities
10
10
 
11
- - **Vector Codec**: Provides codec for `pg/vector@1` type ID mapping to `number[]` JavaScript type
11
+ - **Vector Codec**: Provides codec for `pg/vector@1` mapping to `number[]` at runtime, and a `Vector<N>` type for dimensioned typing in `contract.d.ts`
12
12
  - **Vector Operations**: Registers vector similarity operations (e.g., `cosineDistance`) for use in queries
13
13
  - **CLI Integration**: Provides extension descriptor for `prisma-next.config.ts` configuration
14
14
  - **Runtime Extension**: Registers codecs and operations at runtime for vector column operations
@@ -91,19 +91,22 @@ export const contract = defineContract<AllCodecTypes>()
91
91
 
92
92
  ### Runtime Setup
93
93
 
94
- Register the extension when creating your runtime context:
94
+ Register the extension when creating your execution stack:
95
95
 
96
96
  ```typescript
97
- import { createRuntimeContext } from '@prisma-next/sql-runtime';
98
- import { createPostgresAdapter } from '@prisma-next/adapter-postgres/runtime';
97
+ import { instantiateExecutionStack } from '@prisma-next/core-execution-plane/stack';
98
+ import { createExecutionContext, createSqlExecutionStack } from '@prisma-next/sql-runtime';
99
+ import postgresAdapter from '@prisma-next/adapter-postgres/runtime';
100
+ import postgresTarget from '@prisma-next/target-postgres/runtime';
99
101
  import pgvector from '@prisma-next/extension-pgvector/runtime';
100
102
 
101
- const adapter = createPostgresAdapter();
102
- const context = createRuntimeContext({
103
- contract,
104
- adapter,
105
- extensions: [pgvector()],
103
+ const stack = createSqlExecutionStack({
104
+ target: postgresTarget,
105
+ adapter: postgresAdapter,
106
+ extensionPacks: [pgvector],
106
107
  });
108
+ const context = createExecutionContext({ contract, stack });
109
+ const stackInstance = instantiateExecutionStack(stack);
107
110
  ```
108
111
 
109
112
  ### Query Usage
@@ -135,12 +138,16 @@ type Row = ResultType<typeof plan>;
135
138
 
136
139
  ### Codec Types
137
140
 
138
- The extension provides a `CodecTypes` export mapping the `pg/vector@1` type ID to `number[]`:
141
+ The extension provides:
142
+
143
+ - `CodecTypes` mapping the `pg/vector@1` type ID to `number[]` (runtime representation)
144
+ - `Vector<N>` type for dimensioned vector typing in emitted `contract.d.ts` and schema result types when the contract includes dimension metadata
139
145
 
140
146
  ```typescript
141
- import type { CodecTypes } from '@prisma-next/extension-pgvector/codec-types';
147
+ import type { CodecTypes, Vector } from '@prisma-next/extension-pgvector/codec-types';
142
148
 
143
149
  // CodecTypes['pg/vector@1']['output'] = number[]
150
+ // Vector<1536> is a branded number[] type used for dimensioned typing
144
151
  ```
145
152
 
146
153
  ### Operation Types
@@ -0,0 +1,41 @@
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", 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$1 extends number = number> = number[] & {
22
+ readonly __vectorLength?: N$1;
23
+ };
24
+ /**
25
+ * Codec types for pgvector.
26
+ *
27
+ * - Scalar output remains `number[]` (runtime representation).
28
+ * - `parameterizedOutput` enables lane typing to compute `Vector<N>` from column `typeParams`.
29
+ */
30
+ type CodecTypes = CodecTypes$1 & {
31
+ readonly 'pg/vector@1': CodecTypes$1['pg/vector@1'] & {
32
+ readonly parameterizedOutput: <P extends {
33
+ readonly length: number;
34
+ }>(params: P) => P extends {
35
+ readonly length: infer N extends number;
36
+ } ? Vector<N> : Vector<number>;
37
+ };
38
+ };
39
+ //#endregion
40
+ export { type CodecTypes, type Vector };
41
+ //# sourceMappingURL=codec-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec-types.d.mts","names":[],"sources":["../src/core/codecs.ts","../src/types/codec-types.ts"],"sourcesContent":[],"mappings":";;;;;;;AA0DY;;;cAAN,MAAM,EAAA,qCAAA,CAAA,eAAA,CAAA,CAAA,CAAA,GAAA,MAAA,CAAA,QAAA,EAAA,qCAAA,CAAA,KAAA,CAAA,aAAA,EAAA,MAAA,EAAA,MAAA,EAAA,EAAA,MAAA,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,OAAA,CAAA,CAAA,CAAA;AC7BqD,KDoCrD,YAAA,GCpCqD,ODoCjC,MAAA,CAAO,UCpC0B;;;ADoCjE;;;;AChDA;AAQA;AAAyB,KARb,MAQa,CAAA,YAAA,MAAA,GAAA,MAAA,CAAA,GAAA,MAAA,EAAA,GAAA;EACC,SAAA,cAAA,CAAA,EAT6D,GAS7D;CAEZ;;;;;;;KAHF,UAAA,GAAa;0BACC;;;eAEZ,MACL;;QAAwD,OAAO,KAAK"}
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,33 @@
1
+ import { ColumnTypeDescriptor } from "@prisma-next/contract-authoring";
2
+
3
+ //#region src/exports/column-types.d.ts
4
+
5
+ /**
6
+ * Static vector column descriptor without dimension.
7
+ * Use `vector(N)` for dimensioned vectors that produce `vector(N)` DDL.
8
+ */
9
+ declare const vectorColumn: {
10
+ readonly codecId: "pg/vector@1";
11
+ readonly nativeType: "vector";
12
+ };
13
+ /**
14
+ * Factory for creating dimensioned vector column descriptors.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * .column('embedding', { type: vector(1536), nullable: false })
19
+ * // Produces: nativeType: 'vector(1536)', typeParams: { length: 1536 }
20
+ * ```
21
+ *
22
+ * @param length - The dimension of the vector (e.g., 1536 for OpenAI embeddings)
23
+ * @returns A column type descriptor with `typeParams.length` set
24
+ * @throws {RangeError} If length is not an integer in the range [1, VECTOR_MAX_DIM]
25
+ */
26
+ declare function vector<N extends number>(length: N): ColumnTypeDescriptor & {
27
+ readonly typeParams: {
28
+ readonly length: N;
29
+ };
30
+ };
31
+ //#endregion
32
+ export { vector, vectorColumn };
33
+ //# sourceMappingURL=column-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column-types.d.mts","names":[],"sources":["../src/exports/column-types.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAca;;;;;;;;;;;;;;;;;iBAkBG,iCACN,IACP;;qBAAiE"}
@@ -0,0 +1,36 @@
1
+ import { n as VECTOR_MAX_DIM, t as VECTOR_CODEC_ID } from "./constants-BmZpaev5.mjs";
2
+
3
+ //#region src/exports/column-types.ts
4
+ /**
5
+ * Static vector column descriptor without dimension.
6
+ * Use `vector(N)` for dimensioned vectors that produce `vector(N)` DDL.
7
+ */
8
+ const vectorColumn = {
9
+ codecId: VECTOR_CODEC_ID,
10
+ nativeType: "vector"
11
+ };
12
+ /**
13
+ * Factory for creating dimensioned vector column descriptors.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * .column('embedding', { type: vector(1536), nullable: false })
18
+ * // Produces: nativeType: 'vector(1536)', typeParams: { length: 1536 }
19
+ * ```
20
+ *
21
+ * @param length - The dimension of the vector (e.g., 1536 for OpenAI embeddings)
22
+ * @returns A column type descriptor with `typeParams.length` set
23
+ * @throws {RangeError} If length is not an integer in the range [1, VECTOR_MAX_DIM]
24
+ */
25
+ function vector(length) {
26
+ if (!Number.isInteger(length) || length < 1 || length > VECTOR_MAX_DIM) throw new RangeError(`pgvector: dimension must be an integer in [1, ${VECTOR_MAX_DIM}], got ${length}`);
27
+ return {
28
+ codecId: VECTOR_CODEC_ID,
29
+ nativeType: `vector(${length})`,
30
+ typeParams: { length }
31
+ };
32
+ }
33
+
34
+ //#endregion
35
+ export { vector, vectorColumn };
36
+ //# sourceMappingURL=column-types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column-types.mjs","names":[],"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';\nimport { VECTOR_CODEC_ID, VECTOR_MAX_DIM } from '../core/constants';\n\n/**\n * Static vector column descriptor without dimension.\n * Use `vector(N)` for dimensioned vectors that produce `vector(N)` DDL.\n */\nexport const vectorColumn = {\n codecId: VECTOR_CODEC_ID,\n nativeType: 'vector',\n} as const satisfies ColumnTypeDescriptor;\n\n/**\n * Factory for creating dimensioned vector column descriptors.\n *\n * @example\n * ```typescript\n * .column('embedding', { type: vector(1536), nullable: false })\n * // Produces: nativeType: 'vector(1536)', typeParams: { length: 1536 }\n * ```\n *\n * @param length - The dimension of the vector (e.g., 1536 for OpenAI embeddings)\n * @returns A column type descriptor with `typeParams.length` set\n * @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(${length})`,\n typeParams: { length },\n } as const;\n}\n"],"mappings":";;;;;;;AAcA,MAAa,eAAe;CAC1B,SAAS;CACT,YAAY;CACb;;;;;;;;;;;;;;AAeD,SAAgB,OACd,QACwE;AACxE,KAAI,CAAC,OAAO,UAAU,OAAO,IAAI,SAAS,KAAK,SAAS,eACtD,OAAM,IAAI,WACR,iDAAiD,eAAe,SAAS,SAC1E;AAEH,QAAO;EACL,SAAS;EACT,YAAY,UAAU,OAAO;EAC7B,YAAY,EAAE,QAAQ;EACvB"}
@@ -0,0 +1,13 @@
1
+ //#region src/core/constants.ts
2
+ /**
3
+ * Codec ID for pgvector's vector type.
4
+ */
5
+ const VECTOR_CODEC_ID = "pg/vector@1";
6
+ /**
7
+ * Maximum dimension for pgvector vectors (VECTOR_MAX_DIM from pgvector).
8
+ */
9
+ const VECTOR_MAX_DIM = 16e3;
10
+
11
+ //#endregion
12
+ export { VECTOR_MAX_DIM as n, VECTOR_CODEC_ID as t };
13
+ //# sourceMappingURL=constants-BmZpaev5.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants-BmZpaev5.mjs","names":[],"sources":["../src/core/constants.ts"],"sourcesContent":["/**\n * Codec ID for pgvector's vector type.\n */\nexport const VECTOR_CODEC_ID = 'pg/vector@1' as const;\n\n/**\n * Maximum dimension for pgvector vectors (VECTOR_MAX_DIM from pgvector).\n */\nexport const VECTOR_MAX_DIM = 16000;\n"],"mappings":";;;;AAGA,MAAa,kBAAkB;;;;AAK/B,MAAa,iBAAiB"}
@@ -0,0 +1,7 @@
1
+ import { SqlControlExtensionDescriptor } from "@prisma-next/family-sql/control";
2
+
3
+ //#region src/exports/control.d.ts
4
+ declare const pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'>;
5
+ //#endregion
6
+ export { pgvectorExtensionDescriptor as default, pgvectorExtensionDescriptor };
7
+ //# sourceMappingURL=control.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control.d.mts","names":[],"sources":["../src/exports/control.ts"],"sourcesContent":[],"mappings":";;;cA0DM,6BAA6B"}
@@ -0,0 +1,49 @@
1
+ import { n as pgvectorPackMeta, t as pgvectorOperationSignature } from "./descriptor-meta-BADTQp0u.mjs";
2
+
3
+ //#region src/exports/control.ts
4
+ function verifyVectorExtensionInstalled(schema) {
5
+ if (!schema.extensions.includes("vector")) return [{
6
+ kind: "extension_missing",
7
+ table: "",
8
+ message: "Extension \"vector\" is missing from database (required by pgvector)"
9
+ }];
10
+ return [];
11
+ }
12
+ const pgvectorDatabaseDependencies = { init: [{
13
+ id: "postgres.extension.vector",
14
+ label: "Enable vector extension",
15
+ install: [{
16
+ id: "extension.vector",
17
+ label: "Enable extension \"vector\"",
18
+ summary: "Ensures the vector extension is available for pgvector operations",
19
+ operationClass: "additive",
20
+ target: { id: "postgres" },
21
+ precheck: [{
22
+ description: "verify extension \"vector\" is not already enabled",
23
+ sql: "SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')"
24
+ }],
25
+ execute: [{
26
+ description: "create extension \"vector\"",
27
+ sql: "CREATE EXTENSION IF NOT EXISTS vector"
28
+ }],
29
+ postcheck: [{
30
+ description: "confirm extension \"vector\" is enabled",
31
+ sql: "SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')"
32
+ }]
33
+ }],
34
+ verifyDatabaseDependencyInstalled: verifyVectorExtensionInstalled
35
+ }] };
36
+ const pgvectorExtensionDescriptor = {
37
+ ...pgvectorPackMeta,
38
+ operationSignatures: () => [pgvectorOperationSignature],
39
+ databaseDependencies: pgvectorDatabaseDependencies,
40
+ create: () => ({
41
+ familyId: "sql",
42
+ targetId: "postgres"
43
+ })
44
+ };
45
+ var control_default = pgvectorExtensionDescriptor;
46
+
47
+ //#endregion
48
+ export { control_default as default, pgvectorExtensionDescriptor };
49
+ //# sourceMappingURL=control.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control.mjs","names":["pgvectorDatabaseDependencies: ComponentDatabaseDependencies<unknown>","pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'>"],"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 { pgvectorOperationSignature, pgvectorPackMeta } from '../core/descriptor-meta';\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\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\nconst pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {\n ...pgvectorPackMeta,\n operationSignatures: () => [pgvectorOperationSignature],\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":";;;AAQA,SAAS,+BAA+B,QAA6C;AACnF,KAAI,CAAC,OAAO,WAAW,SAAS,SAAS,CACvC,QAAO,CACL;EACE,MAAM;EACN,OAAO;EACP,SAAS;EACV,CACF;AAEH,QAAO,EAAE;;AAGX,MAAMA,+BAAuE,EAC3E,MAAM,CACJ;CACE,IAAI;CACJ,OAAO;CACP,SAAS,CACP;EACE,IAAI;EACJ,OAAO;EACP,SAAS;EACT,gBAAgB;EAChB,QAAQ,EAAE,IAAI,YAAY;EAC1B,UAAU,CACR;GACE,aAAa;GACb,KAAK;GACN,CACF;EACD,SAAS,CACP;GACE,aAAa;GACb,KAAK;GACN,CACF;EACD,WAAW,CACT;GACE,aAAa;GACb,KAAK;GACN,CACF;EACF,CACF;CACD,mCAAmC;CACpC,CACF,EACF;AAED,MAAMC,8BAAyE;CAC7E,GAAG;CACH,2BAA2B,CAAC,2BAA2B;CACvD,sBAAsB;CACtB,eAAe;EACb,UAAU;EACV,UAAU;EACX;CACF;AAGD,sBAAe"}
@@ -0,0 +1,57 @@
1
+ //#region src/core/descriptor-meta.ts
2
+ const pgvectorTypeId = "pg/vector@1";
3
+ const cosineDistanceOperation = Object.freeze({
4
+ method: "cosineDistance",
5
+ args: [{ kind: "param" }],
6
+ returns: {
7
+ kind: "builtin",
8
+ type: "number"
9
+ },
10
+ lowering: {
11
+ targetFamily: "sql",
12
+ strategy: "function",
13
+ template: "1 - ({{self}} <=> {{arg0}})"
14
+ }
15
+ });
16
+ const pgvectorOperationSignature = {
17
+ forTypeId: pgvectorTypeId,
18
+ ...cosineDistanceOperation
19
+ };
20
+ const pgvectorPackMeta = {
21
+ kind: "extension",
22
+ id: "pgvector",
23
+ familyId: "sql",
24
+ targetId: "postgres",
25
+ version: "0.0.1",
26
+ capabilities: { postgres: { "pgvector/cosine": true } },
27
+ types: {
28
+ codecTypes: {
29
+ import: {
30
+ package: "@prisma-next/extension-pgvector/codec-types",
31
+ named: "CodecTypes",
32
+ alias: "PgVectorTypes"
33
+ },
34
+ typeImports: [{
35
+ package: "@prisma-next/extension-pgvector/codec-types",
36
+ named: "Vector",
37
+ alias: "Vector"
38
+ }],
39
+ parameterized: { [pgvectorTypeId]: "Vector<{{length}}>" }
40
+ },
41
+ operationTypes: { import: {
42
+ package: "@prisma-next/extension-pgvector/operation-types",
43
+ named: "OperationTypes",
44
+ alias: "PgVectorOperationTypes"
45
+ } },
46
+ storage: [{
47
+ typeId: pgvectorTypeId,
48
+ familyId: "sql",
49
+ targetId: "postgres",
50
+ nativeType: "vector"
51
+ }]
52
+ }
53
+ };
54
+
55
+ //#endregion
56
+ export { pgvectorPackMeta as n, pgvectorOperationSignature as t };
57
+ //# sourceMappingURL=descriptor-meta-BADTQp0u.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptor-meta-BADTQp0u.mjs","names":["pgvectorOperationSignature: SqlOperationSignature"],"sources":["../src/core/descriptor-meta.ts"],"sourcesContent":["import 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\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 pgvectorOperationSignature: SqlOperationSignature = {\n forTypeId: pgvectorTypeId,\n ...cosineDistanceOperation,\n};\n\nexport const pgvectorPackMeta = {\n kind: 'extension',\n id: 'pgvector',\n familyId: 'sql',\n targetId: 'postgres',\n version: '0.0.1',\n capabilities: {\n postgres: {\n 'pgvector/cosine': true,\n },\n },\n types: {\n codecTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/codec-types',\n named: 'CodecTypes',\n alias: 'PgVectorTypes',\n },\n typeImports: [\n {\n package: '@prisma-next/extension-pgvector/codec-types',\n named: 'Vector',\n alias: 'Vector',\n },\n ],\n parameterized: {\n [pgvectorTypeId]: 'Vector<{{length}}>',\n },\n },\n operationTypes: {\n import: {\n package: '@prisma-next/extension-pgvector/operation-types',\n named: 'OperationTypes',\n alias: 'PgVectorOperationTypes',\n },\n },\n storage: [\n { typeId: pgvectorTypeId, familyId: 'sql', targetId: 'postgres', nativeType: 'vector' },\n ],\n },\n} as const;\n"],"mappings":";AAEA,MAAM,iBAAiB;AAQvB,MAAM,0BAA0B,OAAO,OAAO;CAC5C,QAAQ;CACR,MAAM,CAAC,EAAE,MAAM,SAAS,CAAC;CACzB,SAAS;EAAE,MAAM;EAAW,MAAM;EAAU;CAC5C,UAVqB;EACrB,cAAc;EACd,UAAU;EACV,UAAU;EACX;CAOA,CAAU;AAEX,MAAaA,6BAAoD;CAC/D,WAAW;CACX,GAAG;CACJ;AAED,MAAa,mBAAmB;CAC9B,MAAM;CACN,IAAI;CACJ,UAAU;CACV,UAAU;CACV,SAAS;CACT,cAAc,EACZ,UAAU,EACR,mBAAmB,MACpB,EACF;CACD,OAAO;EACL,YAAY;GACV,QAAQ;IACN,SAAS;IACT,OAAO;IACP,OAAO;IACR;GACD,aAAa,CACX;IACE,SAAS;IACT,OAAO;IACP,OAAO;IACR,CACF;GACD,eAAe,GACZ,iBAAiB,sBACnB;GACF;EACD,gBAAgB,EACd,QAAQ;GACN,SAAS;GACT,OAAO;GACP,OAAO;GACR,EACF;EACD,SAAS,CACP;GAAE,QAAQ;GAAgB,UAAU;GAAO,UAAU;GAAY,YAAY;GAAU,CACxF;EACF;CACF"}
@@ -0,0 +1,32 @@
1
+ //#region src/types/operation-types.d.ts
2
+ /**
3
+ * Operation type definitions for pgvector extension.
4
+ *
5
+ * This file exports type-only definitions for operation method signatures.
6
+ * These types are imported by contract.d.ts files for compile-time type inference.
7
+ */
8
+ /**
9
+ * Operation types for pgvector extension.
10
+ * Maps typeId to operation methods.
11
+ */
12
+ type OperationTypes = {
13
+ readonly 'pg/vector@1': {
14
+ readonly cosineDistance: {
15
+ readonly args: readonly [{
16
+ readonly kind: 'param';
17
+ }];
18
+ readonly returns: {
19
+ readonly kind: 'builtin';
20
+ readonly type: 'number';
21
+ };
22
+ readonly lowering: {
23
+ readonly targetFamily: 'sql';
24
+ readonly strategy: 'function';
25
+ readonly template: string;
26
+ };
27
+ };
28
+ };
29
+ };
30
+ //#endregion
31
+ export { type OperationTypes };
32
+ //# sourceMappingURL=operation-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-types.d.mts","names":[],"sources":["../src/types/operation-types.ts"],"sourcesContent":[],"mappings":";;AAWA;;;;;;;;;KAAY,cAAA"}
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,46 @@
1
+ //#region src/exports/pack.d.ts
2
+ declare const pgvectorPack: {
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
+ readonly typeImports: readonly [{
21
+ readonly package: "@prisma-next/extension-pgvector/codec-types";
22
+ readonly named: "Vector";
23
+ readonly alias: "Vector";
24
+ }];
25
+ readonly parameterized: {
26
+ readonly "pg/vector@1": "Vector<{{length}}>";
27
+ };
28
+ };
29
+ readonly operationTypes: {
30
+ readonly import: {
31
+ readonly package: "@prisma-next/extension-pgvector/operation-types";
32
+ readonly named: "OperationTypes";
33
+ readonly alias: "PgVectorOperationTypes";
34
+ };
35
+ };
36
+ readonly storage: readonly [{
37
+ readonly typeId: "pg/vector@1";
38
+ readonly familyId: "sql";
39
+ readonly targetId: "postgres";
40
+ readonly nativeType: "vector";
41
+ }];
42
+ };
43
+ };
44
+ //#endregion
45
+ export { pgvectorPack as default };
46
+ //# sourceMappingURL=pack.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pack.d.mts","names":[],"sources":["../src/exports/pack.ts"],"sourcesContent":[],"mappings":";cAEM;EAAA,SAAA,IAAA,EAA+B,WAAA"}
package/dist/pack.mjs ADDED
@@ -0,0 +1,9 @@
1
+ import { n as pgvectorPackMeta } from "./descriptor-meta-BADTQp0u.mjs";
2
+
3
+ //#region src/exports/pack.ts
4
+ const pgvectorPack = pgvectorPackMeta;
5
+ var pack_default = pgvectorPack;
6
+
7
+ //#endregion
8
+ export { pack_default as default };
9
+ //# sourceMappingURL=pack.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pack.mjs","names":[],"sources":["../src/exports/pack.ts"],"sourcesContent":["import { pgvectorPackMeta } from '../core/descriptor-meta';\n\nconst pgvectorPack = pgvectorPackMeta;\n\nexport default pgvectorPack;\n"],"mappings":";;;AAEA,MAAM,eAAe;AAErB,mBAAe"}