@prisma-next/adapter-postgres 0.3.0-dev.6 → 0.3.0-dev.63

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 (91) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +64 -2
  3. package/dist/adapter-DtehReRR.mjs +271 -0
  4. package/dist/adapter-DtehReRR.mjs.map +1 -0
  5. package/dist/adapter.d.mts +23 -0
  6. package/dist/adapter.d.mts.map +1 -0
  7. package/dist/adapter.mjs +5 -0
  8. package/dist/codec-ids-Bsm9c7ns.mjs +29 -0
  9. package/dist/codec-ids-Bsm9c7ns.mjs.map +1 -0
  10. package/dist/codec-types.d.mts +141 -0
  11. package/dist/codec-types.d.mts.map +1 -0
  12. package/dist/codec-types.mjs +4 -0
  13. package/dist/codecs-BfC_5c-4.mjs +207 -0
  14. package/dist/codecs-BfC_5c-4.mjs.map +1 -0
  15. package/dist/column-types.d.mts +110 -0
  16. package/dist/column-types.d.mts.map +1 -0
  17. package/dist/column-types.mjs +180 -0
  18. package/dist/column-types.mjs.map +1 -0
  19. package/dist/control.d.mts +111 -0
  20. package/dist/control.d.mts.map +1 -0
  21. package/dist/control.mjs +463 -0
  22. package/dist/control.mjs.map +1 -0
  23. package/dist/descriptor-meta-ilnFI7bx.mjs +921 -0
  24. package/dist/descriptor-meta-ilnFI7bx.mjs.map +1 -0
  25. package/dist/runtime.d.mts +19 -0
  26. package/dist/runtime.d.mts.map +1 -0
  27. package/dist/runtime.mjs +85 -0
  28. package/dist/runtime.mjs.map +1 -0
  29. package/dist/sql-utils-CSfAGEwF.mjs +78 -0
  30. package/dist/sql-utils-CSfAGEwF.mjs.map +1 -0
  31. package/dist/types-CXO7EB60.d.mts +19 -0
  32. package/dist/types-CXO7EB60.d.mts.map +1 -0
  33. package/dist/types.d.mts +2 -0
  34. package/dist/types.mjs +1 -0
  35. package/package.json +37 -46
  36. package/src/core/adapter.ts +139 -28
  37. package/src/core/codec-ids.ts +28 -0
  38. package/src/core/codecs.ts +325 -23
  39. package/src/core/control-adapter.ts +400 -178
  40. package/src/core/default-normalizer.ts +90 -0
  41. package/src/core/descriptor-meta.ts +221 -9
  42. package/src/core/enum-control-hooks.ts +735 -0
  43. package/src/core/json-schema-type-expression.ts +131 -0
  44. package/src/core/json-schema-validator.ts +53 -0
  45. package/src/core/parameterized-types.ts +118 -0
  46. package/src/core/sql-utils.ts +111 -0
  47. package/src/core/standard-schema.ts +71 -0
  48. package/src/exports/codec-types.ts +73 -1
  49. package/src/exports/column-types.ts +233 -9
  50. package/src/exports/control.ts +16 -9
  51. package/src/exports/runtime.ts +61 -18
  52. package/dist/chunk-HD5YISNQ.js +0 -47
  53. package/dist/chunk-HD5YISNQ.js.map +0 -1
  54. package/dist/chunk-J3XSOAM2.js +0 -162
  55. package/dist/chunk-J3XSOAM2.js.map +0 -1
  56. package/dist/chunk-T6S3A6VT.js +0 -301
  57. package/dist/chunk-T6S3A6VT.js.map +0 -1
  58. package/dist/core/adapter.d.ts +0 -19
  59. package/dist/core/adapter.d.ts.map +0 -1
  60. package/dist/core/codecs.d.ts +0 -110
  61. package/dist/core/codecs.d.ts.map +0 -1
  62. package/dist/core/control-adapter.d.ts +0 -33
  63. package/dist/core/control-adapter.d.ts.map +0 -1
  64. package/dist/core/descriptor-meta.d.ts +0 -72
  65. package/dist/core/descriptor-meta.d.ts.map +0 -1
  66. package/dist/core/types.d.ts +0 -16
  67. package/dist/core/types.d.ts.map +0 -1
  68. package/dist/exports/adapter.d.ts +0 -2
  69. package/dist/exports/adapter.d.ts.map +0 -1
  70. package/dist/exports/adapter.js +0 -8
  71. package/dist/exports/adapter.js.map +0 -1
  72. package/dist/exports/codec-types.d.ts +0 -11
  73. package/dist/exports/codec-types.d.ts.map +0 -1
  74. package/dist/exports/codec-types.js +0 -7
  75. package/dist/exports/codec-types.js.map +0 -1
  76. package/dist/exports/column-types.d.ts +0 -17
  77. package/dist/exports/column-types.d.ts.map +0 -1
  78. package/dist/exports/column-types.js +0 -49
  79. package/dist/exports/column-types.js.map +0 -1
  80. package/dist/exports/control.d.ts +0 -8
  81. package/dist/exports/control.d.ts.map +0 -1
  82. package/dist/exports/control.js +0 -279
  83. package/dist/exports/control.js.map +0 -1
  84. package/dist/exports/runtime.d.ts +0 -15
  85. package/dist/exports/runtime.d.ts.map +0 -1
  86. package/dist/exports/runtime.js +0 -20
  87. package/dist/exports/runtime.js.map +0 -1
  88. package/dist/exports/types.d.ts +0 -2
  89. package/dist/exports/types.d.ts.map +0 -1
  90. package/dist/exports/types.js +0 -1
  91. package/dist/exports/types.js.map +0 -1
@@ -6,48 +6,272 @@
6
6
  */
7
7
 
8
8
  import type { ColumnTypeDescriptor } from '@prisma-next/contract-authoring';
9
+ import type { StorageTypeInstance } from '@prisma-next/sql-contract/types';
10
+ import {
11
+ PG_BIT_CODEC_ID,
12
+ PG_BOOL_CODEC_ID,
13
+ PG_ENUM_CODEC_ID,
14
+ PG_FLOAT4_CODEC_ID,
15
+ PG_FLOAT8_CODEC_ID,
16
+ PG_INT2_CODEC_ID,
17
+ PG_INT4_CODEC_ID,
18
+ PG_INT8_CODEC_ID,
19
+ PG_INTERVAL_CODEC_ID,
20
+ PG_JSON_CODEC_ID,
21
+ PG_JSONB_CODEC_ID,
22
+ PG_NUMERIC_CODEC_ID,
23
+ PG_TEXT_CODEC_ID,
24
+ PG_TIME_CODEC_ID,
25
+ PG_TIMESTAMP_CODEC_ID,
26
+ PG_TIMESTAMPTZ_CODEC_ID,
27
+ PG_TIMETZ_CODEC_ID,
28
+ PG_VARBIT_CODEC_ID,
29
+ SQL_CHAR_CODEC_ID,
30
+ SQL_VARCHAR_CODEC_ID,
31
+ } from '../core/codec-ids';
32
+ import {
33
+ extractStandardSchemaOutputJsonSchema,
34
+ extractStandardSchemaTypeExpression,
35
+ isStandardSchemaLike,
36
+ type StandardSchemaLike,
37
+ } from '../core/standard-schema';
9
38
 
10
39
  export const textColumn: ColumnTypeDescriptor = {
11
- codecId: 'pg/text@1',
40
+ codecId: PG_TEXT_CODEC_ID,
12
41
  nativeType: 'text',
13
42
  } as const;
14
43
 
44
+ export function charColumn(length: number): ColumnTypeDescriptor & {
45
+ readonly typeParams: { readonly length: number };
46
+ } {
47
+ return {
48
+ codecId: SQL_CHAR_CODEC_ID,
49
+ nativeType: 'character',
50
+ typeParams: { length },
51
+ } as const;
52
+ }
53
+
54
+ export function varcharColumn(length: number): ColumnTypeDescriptor & {
55
+ readonly typeParams: { readonly length: number };
56
+ } {
57
+ return {
58
+ codecId: SQL_VARCHAR_CODEC_ID,
59
+ nativeType: 'character varying',
60
+ typeParams: { length },
61
+ } as const;
62
+ }
63
+
15
64
  export const int4Column: ColumnTypeDescriptor = {
16
- codecId: 'pg/int4@1',
65
+ codecId: PG_INT4_CODEC_ID,
17
66
  nativeType: 'int4',
18
67
  } as const;
19
68
 
20
69
  export const int2Column: ColumnTypeDescriptor = {
21
- codecId: 'pg/int2@1',
70
+ codecId: PG_INT2_CODEC_ID,
22
71
  nativeType: 'int2',
23
72
  } as const;
24
73
 
25
74
  export const int8Column: ColumnTypeDescriptor = {
26
- codecId: 'pg/int8@1',
75
+ codecId: PG_INT8_CODEC_ID,
27
76
  nativeType: 'int8',
28
77
  } as const;
29
78
 
30
79
  export const float4Column: ColumnTypeDescriptor = {
31
- codecId: 'pg/float4@1',
80
+ codecId: PG_FLOAT4_CODEC_ID,
32
81
  nativeType: 'float4',
33
82
  } as const;
34
83
 
35
84
  export const float8Column: ColumnTypeDescriptor = {
36
- codecId: 'pg/float8@1',
85
+ codecId: PG_FLOAT8_CODEC_ID,
37
86
  nativeType: 'float8',
38
87
  } as const;
39
88
 
89
+ export function numericColumn(
90
+ precision: number,
91
+ scale?: number,
92
+ ): ColumnTypeDescriptor & {
93
+ readonly typeParams: { readonly precision: number; readonly scale?: number };
94
+ } {
95
+ return {
96
+ codecId: PG_NUMERIC_CODEC_ID,
97
+ nativeType: 'numeric',
98
+ typeParams: scale === undefined ? { precision } : { precision, scale },
99
+ } as const;
100
+ }
101
+
40
102
  export const timestampColumn: ColumnTypeDescriptor = {
41
- codecId: 'pg/timestamp@1',
103
+ codecId: PG_TIMESTAMP_CODEC_ID,
42
104
  nativeType: 'timestamp',
43
105
  } as const;
44
106
 
45
107
  export const timestamptzColumn: ColumnTypeDescriptor = {
46
- codecId: 'pg/timestamptz@1',
108
+ codecId: PG_TIMESTAMPTZ_CODEC_ID,
47
109
  nativeType: 'timestamptz',
48
110
  } as const;
49
111
 
112
+ export function timeColumn(precision?: number): ColumnTypeDescriptor & {
113
+ readonly typeParams?: { readonly precision: number };
114
+ } {
115
+ return {
116
+ codecId: PG_TIME_CODEC_ID,
117
+ nativeType: 'time',
118
+ ...(precision === undefined ? {} : { typeParams: { precision } }),
119
+ } as const;
120
+ }
121
+
122
+ export function timetzColumn(precision?: number): ColumnTypeDescriptor & {
123
+ readonly typeParams?: { readonly precision: number };
124
+ } {
125
+ return {
126
+ codecId: PG_TIMETZ_CODEC_ID,
127
+ nativeType: 'timetz',
128
+ ...(precision === undefined ? {} : { typeParams: { precision } }),
129
+ } as const;
130
+ }
131
+
50
132
  export const boolColumn: ColumnTypeDescriptor = {
51
- codecId: 'pg/bool@1',
133
+ codecId: PG_BOOL_CODEC_ID,
52
134
  nativeType: 'bool',
53
135
  } as const;
136
+
137
+ export function bitColumn(length: number): ColumnTypeDescriptor & {
138
+ readonly typeParams: { readonly length: number };
139
+ } {
140
+ return {
141
+ codecId: PG_BIT_CODEC_ID,
142
+ nativeType: 'bit',
143
+ typeParams: { length },
144
+ } as const;
145
+ }
146
+
147
+ export function varbitColumn(length: number): ColumnTypeDescriptor & {
148
+ readonly typeParams: { readonly length: number };
149
+ } {
150
+ return {
151
+ codecId: PG_VARBIT_CODEC_ID,
152
+ nativeType: 'bit varying',
153
+ typeParams: { length },
154
+ } as const;
155
+ }
156
+
157
+ export function intervalColumn(precision?: number): ColumnTypeDescriptor & {
158
+ readonly typeParams?: { readonly precision: number };
159
+ } {
160
+ return {
161
+ codecId: PG_INTERVAL_CODEC_ID,
162
+ nativeType: 'interval',
163
+ ...(precision === undefined ? {} : { typeParams: { precision } }),
164
+ } as const;
165
+ }
166
+
167
+ export const jsonColumn: ColumnTypeDescriptor = {
168
+ codecId: PG_JSON_CODEC_ID,
169
+ nativeType: 'json',
170
+ } as const;
171
+
172
+ export const jsonbColumn: ColumnTypeDescriptor = {
173
+ codecId: PG_JSONB_CODEC_ID,
174
+ nativeType: 'jsonb',
175
+ } as const;
176
+
177
+ type JsonSchemaTypeParams = {
178
+ readonly schemaJson: Record<string, unknown>;
179
+ readonly type?: string;
180
+ };
181
+
182
+ function createJsonTypeParams(schema: StandardSchemaLike): JsonSchemaTypeParams {
183
+ const outputSchema = extractStandardSchemaOutputJsonSchema(schema);
184
+ if (!outputSchema) {
185
+ throw new Error('JSON schema must expose ~standard.jsonSchema.output()');
186
+ }
187
+
188
+ const expression = extractStandardSchemaTypeExpression(schema);
189
+ if (expression) {
190
+ return { schemaJson: outputSchema, type: expression };
191
+ }
192
+
193
+ return { schemaJson: outputSchema };
194
+ }
195
+
196
+ /**
197
+ * Typed column descriptor for JSON/JSONB columns with Standard Schema.
198
+ *
199
+ * `typeParams.schemaJson` carries the runtime JSON Schema payload (serializable record)
200
+ * used by the emitter to render TypeScript type expressions in contract.d.ts.
201
+ *
202
+ * `typeParams.schema` is a phantom-only key: at runtime it does not exist, but at the
203
+ * type level it preserves the original `TSchema` so that `ResolveStandardSchemaOutput<P>`
204
+ * in codec-types.ts can resolve the output type via `~standard.types.output` or `.infer`.
205
+ */
206
+ type TypedColumnDescriptor<TSchema extends StandardSchemaLike> = ColumnTypeDescriptor & {
207
+ readonly typeParams: JsonSchemaTypeParams & { readonly schema: TSchema };
208
+ };
209
+
210
+ function createJsonColumnFactory(
211
+ codecId: string,
212
+ nativeType: string,
213
+ staticDescriptor: ColumnTypeDescriptor,
214
+ ) {
215
+ return <TSchema extends StandardSchemaLike>(schema?: TSchema): ColumnTypeDescriptor => {
216
+ if (!schema) {
217
+ return staticDescriptor;
218
+ }
219
+
220
+ if (!isStandardSchemaLike(schema)) {
221
+ throw new Error(`${nativeType}(schema) expects a Standard Schema value`);
222
+ }
223
+
224
+ return {
225
+ codecId,
226
+ nativeType,
227
+ // At runtime, typeParams only contains { schemaJson, type? }.
228
+ // The `schema` key exists only at the type level (phantom) so that
229
+ // `ResolveStandardSchemaOutput<P>` in codec-types.ts can resolve the
230
+ // schema's output type via `~standard.types.output` or `.infer`.
231
+ typeParams: createJsonTypeParams(schema) as JsonSchemaTypeParams & {
232
+ readonly schema: TSchema;
233
+ },
234
+ };
235
+ };
236
+ }
237
+
238
+ const _json = createJsonColumnFactory(PG_JSON_CODEC_ID, 'json', jsonColumn);
239
+ const _jsonb = createJsonColumnFactory(PG_JSONB_CODEC_ID, 'jsonb', jsonbColumn);
240
+
241
+ export function json(): ColumnTypeDescriptor;
242
+ export function json<TSchema extends StandardSchemaLike>(
243
+ schema: TSchema,
244
+ ): TypedColumnDescriptor<TSchema>;
245
+ export function json<TSchema extends StandardSchemaLike>(schema?: TSchema): ColumnTypeDescriptor {
246
+ return _json(schema);
247
+ }
248
+
249
+ export function jsonb(): ColumnTypeDescriptor;
250
+ export function jsonb<TSchema extends StandardSchemaLike>(
251
+ schema: TSchema,
252
+ ): TypedColumnDescriptor<TSchema>;
253
+ export function jsonb<TSchema extends StandardSchemaLike>(schema?: TSchema): ColumnTypeDescriptor {
254
+ return _jsonb(schema);
255
+ }
256
+
257
+ export function enumType<const Values extends readonly string[]>(
258
+ name: string,
259
+ values: Values,
260
+ ): StorageTypeInstance & { readonly typeParams: { readonly values: Values } } {
261
+ return {
262
+ codecId: PG_ENUM_CODEC_ID,
263
+ nativeType: name,
264
+ typeParams: { values },
265
+ } as const;
266
+ }
267
+
268
+ export function enumColumn<TypeName extends string>(
269
+ typeName: TypeName,
270
+ nativeType: string,
271
+ ): ColumnTypeDescriptor & { readonly typeRef: TypeName } {
272
+ return {
273
+ codecId: PG_ENUM_CODEC_ID,
274
+ nativeType,
275
+ typeRef: typeName,
276
+ };
277
+ }
@@ -1,20 +1,27 @@
1
- import type { ControlAdapterDescriptor } from '@prisma-next/core-control-plane/types';
1
+ import type { SqlControlAdapterDescriptor } from '@prisma-next/family-sql/control';
2
2
  import type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';
3
3
  import { PostgresControlAdapter } from '../core/control-adapter';
4
+ import { parsePostgresDefault } from '../core/default-normalizer';
4
5
  import { postgresAdapterDescriptorMeta } from '../core/descriptor-meta';
6
+ import { expandParameterizedNativeType } from '../core/parameterized-types';
7
+ import { escapeLiteral, qualifyName, quoteIdentifier, SqlEscapeError } from '../core/sql-utils';
5
8
 
6
- /**
7
- * Postgres adapter descriptor for CLI config.
8
- */
9
- const postgresAdapterDescriptor: ControlAdapterDescriptor<
10
- 'sql',
11
- 'postgres',
12
- SqlControlAdapter<'postgres'>
13
- > = {
9
+ const postgresAdapterDescriptor: SqlControlAdapterDescriptor<'postgres'> = {
14
10
  ...postgresAdapterDescriptorMeta,
11
+ operationSignatures: () => [],
15
12
  create(): SqlControlAdapter<'postgres'> {
16
13
  return new PostgresControlAdapter();
17
14
  },
18
15
  };
19
16
 
20
17
  export default postgresAdapterDescriptor;
18
+
19
+ export { normalizeSchemaNativeType } from '../core/control-adapter';
20
+ export {
21
+ escapeLiteral,
22
+ expandParameterizedNativeType,
23
+ parsePostgresDefault,
24
+ qualifyName,
25
+ quoteIdentifier,
26
+ SqlEscapeError,
27
+ };
@@ -1,32 +1,75 @@
1
+ import type { RuntimeAdapterInstance } from '@prisma-next/core-execution-plane/types';
2
+ import type { Adapter, CodecRegistry, QueryAst } from '@prisma-next/sql-relational-core/ast';
3
+ import { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';
1
4
  import type {
2
- RuntimeAdapterDescriptor,
3
- RuntimeAdapterInstance,
4
- } from '@prisma-next/core-execution-plane/types';
5
- import type { Adapter, QueryAst } from '@prisma-next/sql-relational-core/ast';
5
+ RuntimeParameterizedCodecDescriptor,
6
+ SqlRuntimeAdapterDescriptor,
7
+ } from '@prisma-next/sql-runtime';
8
+ import { type as arktype } from 'arktype';
6
9
  import { createPostgresAdapter } from '../core/adapter';
10
+ import { PG_JSON_CODEC_ID, PG_JSONB_CODEC_ID } from '../core/codec-ids';
11
+ import { codecDefinitions } from '../core/codecs';
7
12
  import { postgresAdapterDescriptorMeta } from '../core/descriptor-meta';
13
+ import {
14
+ compileJsonSchemaValidator,
15
+ type JsonSchemaValidateFn,
16
+ } from '../core/json-schema-validator';
8
17
  import type { PostgresContract, PostgresLoweredStatement } from '../core/types';
9
18
 
10
- /**
11
- * SQL runtime adapter interface for Postgres.
12
- * Extends RuntimeAdapterInstance with SQL-specific adapter methods.
13
- */
14
19
  export interface SqlRuntimeAdapter
15
20
  extends RuntimeAdapterInstance<'sql', 'postgres'>,
16
21
  Adapter<QueryAst, PostgresContract, PostgresLoweredStatement> {}
17
22
 
23
+ function createPostgresCodecRegistry(): CodecRegistry {
24
+ const registry = createCodecRegistry();
25
+ for (const definition of Object.values(codecDefinitions)) {
26
+ registry.register(definition.codec);
27
+ }
28
+ return registry;
29
+ }
30
+
31
+ const jsonTypeParamsSchema = arktype({
32
+ schemaJson: 'object',
33
+ 'type?': 'string',
34
+ });
35
+
36
+ /** The inferred type params shape from the arktype schema. */
37
+ type JsonTypeParams = typeof jsonTypeParamsSchema.infer;
38
+
18
39
  /**
19
- * Postgres adapter descriptor for runtime plane.
40
+ * Helper returned by the JSON/JSONB `init` hook.
41
+ * Contains a compiled JSON Schema validate function for runtime conformance checks.
20
42
  */
21
- const postgresRuntimeAdapterDescriptor: RuntimeAdapterDescriptor<
22
- 'sql',
23
- 'postgres',
24
- SqlRuntimeAdapter
25
- > = {
26
- ...postgresAdapterDescriptorMeta,
27
- create(): SqlRuntimeAdapter {
28
- return createPostgresAdapter();
43
+ export type JsonCodecHelper = { readonly validate: JsonSchemaValidateFn };
44
+
45
+ function initJsonCodecHelper(params: JsonTypeParams): JsonCodecHelper {
46
+ return { validate: compileJsonSchemaValidator(params.schemaJson as Record<string, unknown>) };
47
+ }
48
+
49
+ const parameterizedCodecDescriptors = [
50
+ {
51
+ codecId: PG_JSON_CODEC_ID,
52
+ paramsSchema: jsonTypeParamsSchema,
53
+ init: initJsonCodecHelper,
29
54
  },
30
- };
55
+ {
56
+ codecId: PG_JSONB_CODEC_ID,
57
+ paramsSchema: jsonTypeParamsSchema,
58
+ init: initJsonCodecHelper,
59
+ },
60
+ ] as const satisfies ReadonlyArray<
61
+ RuntimeParameterizedCodecDescriptor<JsonTypeParams, JsonCodecHelper>
62
+ >;
63
+
64
+ const postgresRuntimeAdapterDescriptor: SqlRuntimeAdapterDescriptor<'postgres', SqlRuntimeAdapter> =
65
+ {
66
+ ...postgresAdapterDescriptorMeta,
67
+ codecs: createPostgresCodecRegistry,
68
+ operationSignatures: () => [],
69
+ parameterizedCodecs: () => parameterizedCodecDescriptors,
70
+ create(): SqlRuntimeAdapter {
71
+ return createPostgresAdapter();
72
+ },
73
+ };
31
74
 
32
75
  export default postgresRuntimeAdapterDescriptor;
@@ -1,47 +0,0 @@
1
- // src/core/descriptor-meta.ts
2
- var postgresAdapterDescriptorMeta = {
3
- kind: "adapter",
4
- familyId: "sql",
5
- targetId: "postgres",
6
- id: "postgres",
7
- version: "0.0.1",
8
- capabilities: {
9
- postgres: {
10
- orderBy: true,
11
- limit: true,
12
- lateral: true,
13
- jsonAgg: true,
14
- returning: true
15
- }
16
- },
17
- types: {
18
- codecTypes: {
19
- import: {
20
- package: "@prisma-next/adapter-postgres/codec-types",
21
- named: "CodecTypes",
22
- alias: "PgTypes"
23
- }
24
- },
25
- storage: [
26
- { typeId: "pg/text@1", familyId: "sql", targetId: "postgres", nativeType: "text" },
27
- { typeId: "pg/int4@1", familyId: "sql", targetId: "postgres", nativeType: "int4" },
28
- { typeId: "pg/int2@1", familyId: "sql", targetId: "postgres", nativeType: "int2" },
29
- { typeId: "pg/int8@1", familyId: "sql", targetId: "postgres", nativeType: "int8" },
30
- { typeId: "pg/float4@1", familyId: "sql", targetId: "postgres", nativeType: "float4" },
31
- { typeId: "pg/float8@1", familyId: "sql", targetId: "postgres", nativeType: "float8" },
32
- { typeId: "pg/timestamp@1", familyId: "sql", targetId: "postgres", nativeType: "timestamp" },
33
- {
34
- typeId: "pg/timestamptz@1",
35
- familyId: "sql",
36
- targetId: "postgres",
37
- nativeType: "timestamptz"
38
- },
39
- { typeId: "pg/bool@1", familyId: "sql", targetId: "postgres", nativeType: "bool" }
40
- ]
41
- }
42
- };
43
-
44
- export {
45
- postgresAdapterDescriptorMeta
46
- };
47
- //# sourceMappingURL=chunk-HD5YISNQ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/descriptor-meta.ts"],"sourcesContent":["export const postgresAdapterDescriptorMeta = {\n kind: 'adapter',\n familyId: 'sql',\n targetId: 'postgres',\n id: 'postgres',\n version: '0.0.1',\n capabilities: {\n postgres: {\n orderBy: true,\n limit: true,\n lateral: true,\n jsonAgg: true,\n returning: true,\n },\n },\n types: {\n codecTypes: {\n import: {\n package: '@prisma-next/adapter-postgres/codec-types',\n named: 'CodecTypes',\n alias: 'PgTypes',\n },\n },\n storage: [\n { typeId: 'pg/text@1', familyId: 'sql', targetId: 'postgres', nativeType: 'text' },\n { typeId: 'pg/int4@1', familyId: 'sql', targetId: 'postgres', nativeType: 'int4' },\n { typeId: 'pg/int2@1', familyId: 'sql', targetId: 'postgres', nativeType: 'int2' },\n { typeId: 'pg/int8@1', familyId: 'sql', targetId: 'postgres', nativeType: 'int8' },\n { typeId: 'pg/float4@1', familyId: 'sql', targetId: 'postgres', nativeType: 'float4' },\n { typeId: 'pg/float8@1', familyId: 'sql', targetId: 'postgres', nativeType: 'float8' },\n { typeId: 'pg/timestamp@1', familyId: 'sql', targetId: 'postgres', nativeType: 'timestamp' },\n {\n typeId: 'pg/timestamptz@1',\n familyId: 'sql',\n targetId: 'postgres',\n nativeType: 'timestamptz',\n },\n { typeId: 'pg/bool@1', familyId: 'sql', targetId: 'postgres', nativeType: 'bool' },\n ],\n },\n} as const;\n"],"mappings":";AAAO,IAAM,gCAAgC;AAAA,EAC3C,MAAM;AAAA,EACN,UAAU;AAAA,EACV,UAAU;AAAA,EACV,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,cAAc;AAAA,IACZ,UAAU;AAAA,MACR,SAAS;AAAA,MACT,OAAO;AAAA,MACP,SAAS;AAAA,MACT,SAAS;AAAA,MACT,WAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IACL,YAAY;AAAA,MACV,QAAQ;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,EAAE,QAAQ,aAAa,UAAU,OAAO,UAAU,YAAY,YAAY,OAAO;AAAA,MACjF,EAAE,QAAQ,aAAa,UAAU,OAAO,UAAU,YAAY,YAAY,OAAO;AAAA,MACjF,EAAE,QAAQ,aAAa,UAAU,OAAO,UAAU,YAAY,YAAY,OAAO;AAAA,MACjF,EAAE,QAAQ,aAAa,UAAU,OAAO,UAAU,YAAY,YAAY,OAAO;AAAA,MACjF,EAAE,QAAQ,eAAe,UAAU,OAAO,UAAU,YAAY,YAAY,SAAS;AAAA,MACrF,EAAE,QAAQ,eAAe,UAAU,OAAO,UAAU,YAAY,YAAY,SAAS;AAAA,MACrF,EAAE,QAAQ,kBAAkB,UAAU,OAAO,UAAU,YAAY,YAAY,YAAY;AAAA,MAC3F;AAAA,QACE,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,UAAU;AAAA,QACV,YAAY;AAAA,MACd;AAAA,MACA,EAAE,QAAQ,aAAa,UAAU,OAAO,UAAU,YAAY,YAAY,OAAO;AAAA,IACnF;AAAA,EACF;AACF;","names":[]}
@@ -1,162 +0,0 @@
1
- // src/core/codecs.ts
2
- import { codec, defineCodecs } from "@prisma-next/sql-relational-core/ast";
3
- var pgTextCodec = codec({
4
- typeId: "pg/text@1",
5
- targetTypes: ["text"],
6
- encode: (value) => value,
7
- decode: (wire) => wire,
8
- meta: {
9
- db: {
10
- sql: {
11
- postgres: {
12
- nativeType: "text"
13
- }
14
- }
15
- }
16
- }
17
- });
18
- var pgInt4Codec = codec({
19
- typeId: "pg/int4@1",
20
- targetTypes: ["int4"],
21
- encode: (value) => value,
22
- decode: (wire) => wire,
23
- meta: {
24
- db: {
25
- sql: {
26
- postgres: {
27
- nativeType: "integer"
28
- }
29
- }
30
- }
31
- }
32
- });
33
- var pgInt2Codec = codec({
34
- typeId: "pg/int2@1",
35
- targetTypes: ["int2"],
36
- encode: (value) => value,
37
- decode: (wire) => wire,
38
- meta: {
39
- db: {
40
- sql: {
41
- postgres: {
42
- nativeType: "smallint"
43
- }
44
- }
45
- }
46
- }
47
- });
48
- var pgInt8Codec = codec({
49
- typeId: "pg/int8@1",
50
- targetTypes: ["int8"],
51
- encode: (value) => value,
52
- decode: (wire) => wire,
53
- meta: {
54
- db: {
55
- sql: {
56
- postgres: {
57
- nativeType: "bigint"
58
- }
59
- }
60
- }
61
- }
62
- });
63
- var pgFloat4Codec = codec({
64
- typeId: "pg/float4@1",
65
- targetTypes: ["float4"],
66
- encode: (value) => value,
67
- decode: (wire) => wire,
68
- meta: {
69
- db: {
70
- sql: {
71
- postgres: {
72
- nativeType: "real"
73
- }
74
- }
75
- }
76
- }
77
- });
78
- var pgFloat8Codec = codec({
79
- typeId: "pg/float8@1",
80
- targetTypes: ["float8"],
81
- encode: (value) => value,
82
- decode: (wire) => wire,
83
- meta: {
84
- db: {
85
- sql: {
86
- postgres: {
87
- nativeType: "double precision"
88
- }
89
- }
90
- }
91
- }
92
- });
93
- var pgTimestampCodec = codec({
94
- typeId: "pg/timestamp@1",
95
- targetTypes: ["timestamp"],
96
- encode: (value) => {
97
- if (value instanceof Date) return value.toISOString();
98
- if (typeof value === "string") return value;
99
- return String(value);
100
- },
101
- decode: (wire) => {
102
- if (typeof wire === "string") return wire;
103
- if (wire instanceof Date) return wire.toISOString();
104
- return String(wire);
105
- },
106
- meta: {
107
- db: {
108
- sql: {
109
- postgres: {
110
- nativeType: "timestamp without time zone"
111
- }
112
- }
113
- }
114
- }
115
- });
116
- var pgTimestamptzCodec = codec({
117
- typeId: "pg/timestamptz@1",
118
- targetTypes: ["timestamptz"],
119
- encode: (value) => {
120
- if (value instanceof Date) return value.toISOString();
121
- if (typeof value === "string") return value;
122
- return String(value);
123
- },
124
- decode: (wire) => {
125
- if (typeof wire === "string") return wire;
126
- if (wire instanceof Date) return wire.toISOString();
127
- return String(wire);
128
- },
129
- meta: {
130
- db: {
131
- sql: {
132
- postgres: {
133
- nativeType: "timestamp with time zone"
134
- }
135
- }
136
- }
137
- }
138
- });
139
- var pgBoolCodec = codec({
140
- typeId: "pg/bool@1",
141
- targetTypes: ["bool"],
142
- encode: (value) => value,
143
- decode: (wire) => wire,
144
- meta: {
145
- db: {
146
- sql: {
147
- postgres: {
148
- nativeType: "boolean"
149
- }
150
- }
151
- }
152
- }
153
- });
154
- var codecs = defineCodecs().add("text", pgTextCodec).add("int4", pgInt4Codec).add("int2", pgInt2Codec).add("int8", pgInt8Codec).add("float4", pgFloat4Codec).add("float8", pgFloat8Codec).add("timestamp", pgTimestampCodec).add("timestamptz", pgTimestamptzCodec).add("bool", pgBoolCodec);
155
- var codecDefinitions = codecs.codecDefinitions;
156
- var dataTypes = codecs.dataTypes;
157
-
158
- export {
159
- codecDefinitions,
160
- dataTypes
161
- };
162
- //# sourceMappingURL=chunk-J3XSOAM2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/codecs.ts"],"sourcesContent":["/**\n * Unified codec definitions for Postgres adapter.\n *\n * This file contains a single source of truth for all codec information:\n * - Scalar names\n * - Type IDs\n * - Codec implementations (runtime)\n * - Type information (compile-time)\n *\n * This structure is used both at runtime (to populate the registry) and\n * at compile time (to derive CodecTypes).\n */\n\nimport { codec, defineCodecs } from '@prisma-next/sql-relational-core/ast';\n\n// Create individual codec instances\nconst pgTextCodec = codec({\n typeId: 'pg/text@1',\n targetTypes: ['text'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'text',\n },\n },\n },\n },\n});\n\nconst pgInt4Codec = codec<'pg/int4@1', number, number>({\n typeId: 'pg/int4@1',\n targetTypes: ['int4'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'integer',\n },\n },\n },\n },\n});\n\nconst pgInt2Codec = codec<'pg/int2@1', number, number>({\n typeId: 'pg/int2@1',\n targetTypes: ['int2'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'smallint',\n },\n },\n },\n },\n});\n\nconst pgInt8Codec = codec<'pg/int8@1', number, number>({\n typeId: 'pg/int8@1',\n targetTypes: ['int8'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'bigint',\n },\n },\n },\n },\n});\n\nconst pgFloat4Codec = codec<'pg/float4@1', number, number>({\n typeId: 'pg/float4@1',\n targetTypes: ['float4'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'real',\n },\n },\n },\n },\n});\n\nconst pgFloat8Codec = codec<'pg/float8@1', number, number>({\n typeId: 'pg/float8@1',\n targetTypes: ['float8'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'double precision',\n },\n },\n },\n },\n});\n\nconst pgTimestampCodec = codec<'pg/timestamp@1', string | Date, string>({\n typeId: 'pg/timestamp@1',\n targetTypes: ['timestamp'],\n encode: (value: string | Date): string => {\n if (value instanceof Date) return value.toISOString();\n if (typeof value === 'string') return value;\n return String(value);\n },\n decode: (wire: string | Date): string => {\n if (typeof wire === 'string') return wire;\n if (wire instanceof Date) return wire.toISOString();\n return String(wire);\n },\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'timestamp without time zone',\n },\n },\n },\n },\n});\n\nconst pgTimestamptzCodec = codec<'pg/timestamptz@1', string | Date, string>({\n typeId: 'pg/timestamptz@1',\n targetTypes: ['timestamptz'],\n encode: (value: string | Date): string => {\n if (value instanceof Date) return value.toISOString();\n if (typeof value === 'string') return value;\n return String(value);\n },\n decode: (wire: string | Date): string => {\n if (typeof wire === 'string') return wire;\n if (wire instanceof Date) return wire.toISOString();\n return String(wire);\n },\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'timestamp with time zone',\n },\n },\n },\n },\n});\n\nconst pgBoolCodec = codec<'pg/bool@1', boolean, boolean>({\n typeId: 'pg/bool@1',\n targetTypes: ['bool'],\n encode: (value) => value,\n decode: (wire) => wire,\n meta: {\n db: {\n sql: {\n postgres: {\n nativeType: 'boolean',\n },\n },\n },\n },\n});\n\n// Build codec definitions using the builder DSL\nconst codecs = defineCodecs()\n .add('text', pgTextCodec)\n .add('int4', pgInt4Codec)\n .add('int2', pgInt2Codec)\n .add('int8', pgInt8Codec)\n .add('float4', pgFloat4Codec)\n .add('float8', pgFloat8Codec)\n .add('timestamp', pgTimestampCodec)\n .add('timestamptz', pgTimestamptzCodec)\n .add('bool', pgBoolCodec);\n\n// Export derived structures directly from codecs builder\nexport const codecDefinitions = codecs.codecDefinitions;\nexport const dataTypes = codecs.dataTypes;\n\n// Export types derived from codecs builder\nexport type CodecTypes = typeof codecs.CodecTypes;\n"],"mappings":";AAaA,SAAS,OAAO,oBAAoB;AAGpC,IAAM,cAAc,MAAM;AAAA,EACxB,QAAQ;AAAA,EACR,aAAa,CAAC,MAAM;AAAA,EACpB,QAAQ,CAAC,UAA0B;AAAA,EACnC,QAAQ,CAAC,SAAyB;AAAA,EAClC,MAAM;AAAA,IACJ,IAAI;AAAA,MACF,KAAK;AAAA,QACH,UAAU;AAAA,UACR,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EAC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