@prisma-next/adapter-postgres 0.3.0-pr.99.5 → 0.3.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.
Files changed (92) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +64 -2
  3. package/dist/adapter-7pXt8ej9.mjs +369 -0
  4. package/dist/adapter-7pXt8ej9.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 +3 -0
  8. package/dist/codec-ids-BwjcIf74.mjs +29 -0
  9. package/dist/codec-ids-BwjcIf74.mjs.map +1 -0
  10. package/dist/codec-types.d.mts +107 -0
  11. package/dist/codec-types.d.mts.map +1 -0
  12. package/dist/codec-types.mjs +3 -0
  13. package/dist/codecs-C3wlpdV7.mjs +385 -0
  14. package/dist/codecs-C3wlpdV7.mjs.map +1 -0
  15. package/dist/column-types.d.mts +122 -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 +77 -0
  20. package/dist/control.d.mts.map +1 -0
  21. package/dist/control.mjs +776 -0
  22. package/dist/control.mjs.map +1 -0
  23. package/dist/descriptor-meta-DemWrTfB.mjs +768 -0
  24. package/dist/descriptor-meta-DemWrTfB.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 +98 -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-DxaTd7aP.d.mts +20 -0
  32. package/dist/types-DxaTd7aP.d.mts.map +1 -0
  33. package/dist/types.d.mts +2 -0
  34. package/dist/types.mjs +1 -0
  35. package/package.json +33 -42
  36. package/src/core/adapter.ts +535 -256
  37. package/src/core/codec-ids.ts +30 -0
  38. package/src/core/codecs.ts +487 -36
  39. package/src/core/control-adapter.ts +405 -184
  40. package/src/core/control-mutation-defaults.ts +335 -0
  41. package/src/core/default-normalizer.ts +145 -0
  42. package/src/core/descriptor-meta.ts +227 -9
  43. package/src/core/enum-control-hooks.ts +739 -0
  44. package/src/core/json-schema-type-expression.ts +131 -0
  45. package/src/core/json-schema-validator.ts +53 -0
  46. package/src/core/sql-utils.ts +111 -0
  47. package/src/core/standard-schema.ts +71 -0
  48. package/src/core/types.ts +8 -10
  49. package/src/exports/codec-types.ts +34 -1
  50. package/src/exports/column-types.ts +223 -27
  51. package/src/exports/control.ts +19 -9
  52. package/src/exports/runtime.ts +75 -19
  53. package/dist/chunk-HD5YISNQ.js +0 -47
  54. package/dist/chunk-HD5YISNQ.js.map +0 -1
  55. package/dist/chunk-J3XSOAM2.js +0 -162
  56. package/dist/chunk-J3XSOAM2.js.map +0 -1
  57. package/dist/chunk-T6S3A6VT.js +0 -301
  58. package/dist/chunk-T6S3A6VT.js.map +0 -1
  59. package/dist/core/adapter.d.ts +0 -19
  60. package/dist/core/adapter.d.ts.map +0 -1
  61. package/dist/core/codecs.d.ts +0 -110
  62. package/dist/core/codecs.d.ts.map +0 -1
  63. package/dist/core/control-adapter.d.ts +0 -33
  64. package/dist/core/control-adapter.d.ts.map +0 -1
  65. package/dist/core/descriptor-meta.d.ts +0 -72
  66. package/dist/core/descriptor-meta.d.ts.map +0 -1
  67. package/dist/core/types.d.ts +0 -16
  68. package/dist/core/types.d.ts.map +0 -1
  69. package/dist/exports/adapter.d.ts +0 -2
  70. package/dist/exports/adapter.d.ts.map +0 -1
  71. package/dist/exports/adapter.js +0 -8
  72. package/dist/exports/adapter.js.map +0 -1
  73. package/dist/exports/codec-types.d.ts +0 -11
  74. package/dist/exports/codec-types.d.ts.map +0 -1
  75. package/dist/exports/codec-types.js +0 -7
  76. package/dist/exports/codec-types.js.map +0 -1
  77. package/dist/exports/column-types.d.ts +0 -17
  78. package/dist/exports/column-types.d.ts.map +0 -1
  79. package/dist/exports/column-types.js +0 -49
  80. package/dist/exports/column-types.js.map +0 -1
  81. package/dist/exports/control.d.ts +0 -8
  82. package/dist/exports/control.d.ts.map +0 -1
  83. package/dist/exports/control.js +0 -279
  84. package/dist/exports/control.js.map +0 -1
  85. package/dist/exports/runtime.d.ts +0 -15
  86. package/dist/exports/runtime.d.ts.map +0 -1
  87. package/dist/exports/runtime.js +0 -20
  88. package/dist/exports/runtime.js.map +0 -1
  89. package/dist/exports/types.d.ts +0 -2
  90. package/dist/exports/types.d.ts.map +0 -1
  91. package/dist/exports/types.js +0 -1
  92. package/dist/exports/types.js.map +0 -1
@@ -6,48 +6,244 @@
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
- export const textColumn: ColumnTypeDescriptor = {
11
- codecId: 'pg/text@1',
39
+ export const textColumn = {
40
+ codecId: PG_TEXT_CODEC_ID,
12
41
  nativeType: 'text',
13
- } as const;
42
+ } as const satisfies ColumnTypeDescriptor;
14
43
 
15
- export const int4Column: ColumnTypeDescriptor = {
16
- codecId: 'pg/int4@1',
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
+
64
+ export const int4Column = {
65
+ codecId: PG_INT4_CODEC_ID,
17
66
  nativeType: 'int4',
18
- } as const;
67
+ } as const satisfies ColumnTypeDescriptor;
19
68
 
20
- export const int2Column: ColumnTypeDescriptor = {
21
- codecId: 'pg/int2@1',
69
+ export const int2Column = {
70
+ codecId: PG_INT2_CODEC_ID,
22
71
  nativeType: 'int2',
23
- } as const;
72
+ } as const satisfies ColumnTypeDescriptor;
24
73
 
25
- export const int8Column: ColumnTypeDescriptor = {
26
- codecId: 'pg/int8@1',
74
+ export const int8Column = {
75
+ codecId: PG_INT8_CODEC_ID,
27
76
  nativeType: 'int8',
28
- } as const;
77
+ } as const satisfies ColumnTypeDescriptor;
29
78
 
30
- export const float4Column: ColumnTypeDescriptor = {
31
- codecId: 'pg/float4@1',
79
+ export const float4Column = {
80
+ codecId: PG_FLOAT4_CODEC_ID,
32
81
  nativeType: 'float4',
33
- } as const;
82
+ } as const satisfies ColumnTypeDescriptor;
34
83
 
35
- export const float8Column: ColumnTypeDescriptor = {
36
- codecId: 'pg/float8@1',
84
+ export const float8Column = {
85
+ codecId: PG_FLOAT8_CODEC_ID,
37
86
  nativeType: 'float8',
38
- } as const;
87
+ } as const satisfies ColumnTypeDescriptor;
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
+ }
39
101
 
40
- export const timestampColumn: ColumnTypeDescriptor = {
41
- codecId: 'pg/timestamp@1',
102
+ export const timestampColumn = {
103
+ codecId: PG_TIMESTAMP_CODEC_ID,
42
104
  nativeType: 'timestamp',
43
- } as const;
105
+ } as const satisfies ColumnTypeDescriptor;
44
106
 
45
- export const timestamptzColumn: ColumnTypeDescriptor = {
46
- codecId: 'pg/timestamptz@1',
107
+ export const timestamptzColumn = {
108
+ codecId: PG_TIMESTAMPTZ_CODEC_ID,
47
109
  nativeType: 'timestamptz',
48
- } as const;
110
+ } as const satisfies ColumnTypeDescriptor;
49
111
 
50
- export const boolColumn: ColumnTypeDescriptor = {
51
- codecId: 'pg/bool@1',
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
+
132
+ export const boolColumn = {
133
+ codecId: PG_BOOL_CODEC_ID,
52
134
  nativeType: 'bool',
53
- } as const;
135
+ } as const satisfies ColumnTypeDescriptor;
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 = {
168
+ codecId: PG_JSON_CODEC_ID,
169
+ nativeType: 'json',
170
+ } as const satisfies ColumnTypeDescriptor;
171
+
172
+ export const jsonbColumn = {
173
+ codecId: PG_JSONB_CODEC_ID,
174
+ nativeType: 'jsonb',
175
+ } as const satisfies ColumnTypeDescriptor;
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
+ function createJsonColumnFactory(
197
+ codecId: string,
198
+ nativeType: string,
199
+ staticDescriptor: ColumnTypeDescriptor,
200
+ ) {
201
+ return (schema?: StandardSchemaLike): ColumnTypeDescriptor => {
202
+ if (!schema) {
203
+ return staticDescriptor;
204
+ }
205
+
206
+ if (!isStandardSchemaLike(schema)) {
207
+ throw new Error(`${nativeType}(schema) expects a Standard Schema value`);
208
+ }
209
+
210
+ return {
211
+ codecId,
212
+ nativeType,
213
+ typeParams: createJsonTypeParams(schema),
214
+ };
215
+ };
216
+ }
217
+
218
+ const _json = createJsonColumnFactory(PG_JSON_CODEC_ID, 'json', jsonColumn);
219
+ const _jsonb = createJsonColumnFactory(PG_JSONB_CODEC_ID, 'jsonb', jsonbColumn);
220
+
221
+ export function json(schema?: StandardSchemaLike): ColumnTypeDescriptor {
222
+ return _json(schema);
223
+ }
224
+
225
+ export function jsonb(schema?: StandardSchemaLike): ColumnTypeDescriptor {
226
+ return _jsonb(schema);
227
+ }
228
+
229
+ export function enumType<const Values extends readonly string[]>(
230
+ name: string,
231
+ values: Values,
232
+ ): StorageTypeInstance & { readonly typeParams: { readonly values: Values } } {
233
+ return {
234
+ codecId: PG_ENUM_CODEC_ID,
235
+ nativeType: name,
236
+ typeParams: { values },
237
+ } as const;
238
+ }
239
+
240
+ export function enumColumn<TypeName extends string>(
241
+ typeName: TypeName,
242
+ nativeType: string,
243
+ ): ColumnTypeDescriptor & { readonly typeRef: TypeName } {
244
+ return {
245
+ codecId: PG_ENUM_CODEC_ID,
246
+ nativeType,
247
+ typeRef: typeName,
248
+ };
249
+ }
@@ -1,20 +1,30 @@
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 {
5
+ createPostgresDefaultFunctionRegistry,
6
+ createPostgresMutationDefaultGeneratorDescriptors,
7
+ createPostgresPslScalarTypeDescriptors,
8
+ } from '../core/control-mutation-defaults';
4
9
  import { postgresAdapterDescriptorMeta } from '../core/descriptor-meta';
10
+ import { escapeLiteral, qualifyName, quoteIdentifier, SqlEscapeError } from '../core/sql-utils';
5
11
 
6
- /**
7
- * Postgres adapter descriptor for CLI config.
8
- */
9
- const postgresAdapterDescriptor: ControlAdapterDescriptor<
10
- 'sql',
11
- 'postgres',
12
- SqlControlAdapter<'postgres'>
13
- > = {
12
+ const postgresAdapterDescriptor: SqlControlAdapterDescriptor<'postgres'> = {
14
13
  ...postgresAdapterDescriptorMeta,
14
+ pslTypeDescriptors: () => ({
15
+ scalarTypeDescriptors: createPostgresPslScalarTypeDescriptors(),
16
+ }),
17
+ controlMutationDefaults: () => ({
18
+ defaultFunctionRegistry: createPostgresDefaultFunctionRegistry(),
19
+ generatorDescriptors: createPostgresMutationDefaultGeneratorDescriptors(),
20
+ }),
15
21
  create(): SqlControlAdapter<'postgres'> {
16
22
  return new PostgresControlAdapter();
17
23
  },
18
24
  };
19
25
 
20
26
  export default postgresAdapterDescriptor;
27
+
28
+ export { normalizeSchemaNativeType } from '../core/control-adapter';
29
+ export { parsePostgresDefault } from '../core/default-normalizer';
30
+ export { escapeLiteral, qualifyName, quoteIdentifier, SqlEscapeError };
@@ -1,32 +1,88 @@
1
+ import type { GeneratedValueSpec } from '@prisma-next/contract/types';
2
+ import type { RuntimeAdapterInstance } from '@prisma-next/framework-components/execution';
3
+ import { builtinGeneratorIds } from '@prisma-next/ids';
4
+ import { generateId } from '@prisma-next/ids/runtime';
5
+ import type { Adapter, AnyQueryAst, CodecRegistry } from '@prisma-next/sql-relational-core/ast';
6
+ import { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';
1
7
  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';
8
+ RuntimeParameterizedCodecDescriptor,
9
+ SqlRuntimeAdapterDescriptor,
10
+ } from '@prisma-next/sql-runtime';
11
+ import { type as arktype } from 'arktype';
6
12
  import { createPostgresAdapter } from '../core/adapter';
13
+ import { PG_JSON_CODEC_ID, PG_JSONB_CODEC_ID } from '../core/codec-ids';
14
+ import { codecDefinitions } from '../core/codecs';
7
15
  import { postgresAdapterDescriptorMeta } from '../core/descriptor-meta';
16
+ import {
17
+ compileJsonSchemaValidator,
18
+ type JsonSchemaValidateFn,
19
+ } from '../core/json-schema-validator';
8
20
  import type { PostgresContract, PostgresLoweredStatement } from '../core/types';
9
21
 
10
- /**
11
- * SQL runtime adapter interface for Postgres.
12
- * Extends RuntimeAdapterInstance with SQL-specific adapter methods.
13
- */
14
22
  export interface SqlRuntimeAdapter
15
23
  extends RuntimeAdapterInstance<'sql', 'postgres'>,
16
- Adapter<QueryAst, PostgresContract, PostgresLoweredStatement> {}
24
+ Adapter<AnyQueryAst, PostgresContract, PostgresLoweredStatement> {}
25
+
26
+ function createPostgresCodecRegistry(): CodecRegistry {
27
+ const registry = createCodecRegistry();
28
+ for (const definition of Object.values(codecDefinitions)) {
29
+ registry.register(definition.codec);
30
+ }
31
+ return registry;
32
+ }
33
+
34
+ const jsonTypeParamsSchema = arktype({
35
+ schemaJson: 'object',
36
+ 'type?': 'string',
37
+ });
38
+
39
+ /** The inferred type params shape from the arktype schema. */
40
+ type JsonTypeParams = typeof jsonTypeParamsSchema.infer;
17
41
 
18
42
  /**
19
- * Postgres adapter descriptor for runtime plane.
43
+ * Helper returned by the JSON/JSONB `init` hook.
44
+ * Contains a compiled JSON Schema validate function for runtime conformance checks.
20
45
  */
21
- const postgresRuntimeAdapterDescriptor: RuntimeAdapterDescriptor<
22
- 'sql',
23
- 'postgres',
24
- SqlRuntimeAdapter
25
- > = {
26
- ...postgresAdapterDescriptorMeta,
27
- create(): SqlRuntimeAdapter {
28
- return createPostgresAdapter();
46
+ export type JsonCodecHelper = { readonly validate: JsonSchemaValidateFn };
47
+
48
+ function createPostgresMutationDefaultGenerators() {
49
+ return builtinGeneratorIds.map((id) => ({
50
+ id,
51
+ generate: (params?: Record<string, unknown>) => {
52
+ const spec: GeneratedValueSpec = params ? { id, params } : { id };
53
+ return generateId(spec);
54
+ },
55
+ }));
56
+ }
57
+
58
+ function initJsonCodecHelper(params: JsonTypeParams): JsonCodecHelper {
59
+ return { validate: compileJsonSchemaValidator(params.schemaJson as Record<string, unknown>) };
60
+ }
61
+
62
+ const parameterizedCodecDescriptors = [
63
+ {
64
+ codecId: PG_JSON_CODEC_ID,
65
+ paramsSchema: jsonTypeParamsSchema,
66
+ init: initJsonCodecHelper,
29
67
  },
30
- };
68
+ {
69
+ codecId: PG_JSONB_CODEC_ID,
70
+ paramsSchema: jsonTypeParamsSchema,
71
+ init: initJsonCodecHelper,
72
+ },
73
+ ] as const satisfies ReadonlyArray<
74
+ RuntimeParameterizedCodecDescriptor<JsonTypeParams, JsonCodecHelper>
75
+ >;
76
+
77
+ const postgresRuntimeAdapterDescriptor: SqlRuntimeAdapterDescriptor<'postgres', SqlRuntimeAdapter> =
78
+ {
79
+ ...postgresAdapterDescriptorMeta,
80
+ codecs: createPostgresCodecRegistry,
81
+ parameterizedCodecs: () => parameterizedCodecDescriptors,
82
+ mutationDefaultGenerators: createPostgresMutationDefaultGenerators,
83
+ create(): SqlRuntimeAdapter {
84
+ return createPostgresAdapter();
85
+ },
86
+ };
31
87
 
32
88
  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,IA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