@prisma-next/adapter-postgres 0.4.1 → 0.4.3

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 (59) hide show
  1. package/README.md +21 -15
  2. package/dist/adapter-_L4wXA4O.mjs +64 -0
  3. package/dist/adapter-_L4wXA4O.mjs.map +1 -0
  4. package/dist/adapter.d.mts +3 -8
  5. package/dist/adapter.d.mts.map +1 -1
  6. package/dist/adapter.mjs +1 -1
  7. package/dist/column-types.d.mts +15 -23
  8. package/dist/column-types.d.mts.map +1 -1
  9. package/dist/column-types.mjs +15 -58
  10. package/dist/column-types.mjs.map +1 -1
  11. package/dist/control.d.mts +73 -67
  12. package/dist/control.d.mts.map +1 -1
  13. package/dist/control.mjs +59 -162
  14. package/dist/control.mjs.map +1 -1
  15. package/dist/{descriptor-meta-BB9XPAFi.mjs → descriptor-meta-Dxnoq_rr.mjs} +27 -26
  16. package/dist/descriptor-meta-Dxnoq_rr.mjs.map +1 -0
  17. package/dist/operation-types.d.mts +11 -10
  18. package/dist/operation-types.d.mts.map +1 -1
  19. package/dist/runtime.d.mts +3 -11
  20. package/dist/runtime.d.mts.map +1 -1
  21. package/dist/runtime.mjs +23 -66
  22. package/dist/runtime.mjs.map +1 -1
  23. package/dist/{adapter-Du9Hr9Rl.mjs → sql-renderer-DLwYpnxz.mjs} +176 -113
  24. package/dist/sql-renderer-DLwYpnxz.mjs.map +1 -0
  25. package/dist/{types-TyL62f9Y.d.mts → types-tLtmYqCO.d.mts} +12 -1
  26. package/dist/types-tLtmYqCO.d.mts.map +1 -0
  27. package/dist/types.d.mts +1 -1
  28. package/package.json +22 -18
  29. package/src/core/adapter.ts +13 -626
  30. package/src/core/codec-lookup.ts +24 -0
  31. package/src/core/control-adapter.ts +88 -47
  32. package/src/core/descriptor-meta.ts +34 -16
  33. package/src/core/enum-control-hooks.ts +7 -2
  34. package/src/core/sql-renderer.ts +778 -0
  35. package/src/core/types.ts +11 -0
  36. package/src/exports/column-types.ts +14 -59
  37. package/src/exports/control.ts +11 -5
  38. package/src/exports/runtime.ts +29 -42
  39. package/src/types/operation-types.ts +19 -9
  40. package/dist/adapter-Du9Hr9Rl.mjs.map +0 -1
  41. package/dist/codec-ids-5g4Gwrgm.mjs +0 -29
  42. package/dist/codec-ids-5g4Gwrgm.mjs.map +0 -1
  43. package/dist/codec-types.d.mts +0 -107
  44. package/dist/codec-types.d.mts.map +0 -1
  45. package/dist/codec-types.mjs +0 -3
  46. package/dist/codecs-DiPlMi3-.mjs +0 -385
  47. package/dist/codecs-DiPlMi3-.mjs.map +0 -1
  48. package/dist/descriptor-meta-BB9XPAFi.mjs.map +0 -1
  49. package/dist/sql-utils-DkUJyZmA.mjs +0 -78
  50. package/dist/sql-utils-DkUJyZmA.mjs.map +0 -1
  51. package/dist/types-TyL62f9Y.d.mts.map +0 -1
  52. package/src/core/codec-ids.ts +0 -30
  53. package/src/core/codecs.ts +0 -645
  54. package/src/core/default-normalizer.ts +0 -145
  55. package/src/core/json-schema-type-expression.ts +0 -131
  56. package/src/core/json-schema-validator.ts +0 -53
  57. package/src/core/sql-utils.ts +0 -111
  58. package/src/core/standard-schema.ts +0 -71
  59. package/src/exports/codec-types.ts +0 -44
@@ -1,145 +0,0 @@
1
- import type { ColumnDefault } from '@prisma-next/contract/types';
2
-
3
- /**
4
- * Pre-compiled regex patterns for performance.
5
- * These are compiled once at module load time rather than on each function call.
6
- */
7
- const NEXTVAL_PATTERN = /^nextval\s*\(/i;
8
- const NOW_FUNCTION_PATTERN = /^(now\s*\(\s*\)|CURRENT_TIMESTAMP)$/i;
9
- const CLOCK_TIMESTAMP_PATTERN = /^clock_timestamp\s*\(\s*\)$/i;
10
- const TIMESTAMP_CAST_SUFFIX = /::timestamp(?:tz|\s+(?:with|without)\s+time\s+zone)?$/i;
11
- const TEXT_CAST_SUFFIX = /::text$/i;
12
- const NOW_LITERAL_PATTERN = /^'now'$/i;
13
- const UUID_PATTERN = /^gen_random_uuid\s*\(\s*\)$/i;
14
- const UUID_OSSP_PATTERN = /^uuid_generate_v4\s*\(\s*\)$/i;
15
- const NULL_PATTERN = /^NULL(?:::.+)?$/i;
16
- const TRUE_PATTERN = /^true$/i;
17
- const FALSE_PATTERN = /^false$/i;
18
- const NUMERIC_PATTERN = /^-?\d+(\.\d+)?$/;
19
- const STRING_LITERAL_PATTERN = /^'((?:[^']|'')*)'(?:::(?:"[^"]+"|[\w\s]+)(?:\(\d+\))?)?$/;
20
-
21
- /**
22
- * Returns the canonical expression for a timestamp default function, or undefined
23
- * if the expression is not a recognized timestamp default.
24
- *
25
- * Keeps now()/CURRENT_TIMESTAMP and clock_timestamp() distinct:
26
- * - now(), CURRENT_TIMESTAMP, ('now'::text)::timestamp... → 'now()'
27
- * - clock_timestamp(), clock_timestamp()::timestamptz → 'clock_timestamp()'
28
- *
29
- * These are semantically different in Postgres: now() returns the transaction
30
- * start time (constant within a transaction), while clock_timestamp() returns
31
- * the actual wall-clock time (can differ across rows in a single INSERT).
32
- */
33
- function canonicalizeTimestampDefault(expr: string): string | undefined {
34
- if (NOW_FUNCTION_PATTERN.test(expr)) return 'now()';
35
- if (CLOCK_TIMESTAMP_PATTERN.test(expr)) return 'clock_timestamp()';
36
-
37
- if (!TIMESTAMP_CAST_SUFFIX.test(expr)) return undefined;
38
-
39
- let inner = expr.replace(TIMESTAMP_CAST_SUFFIX, '').trim();
40
-
41
- // Strip outer parentheses
42
- if (inner.startsWith('(') && inner.endsWith(')')) {
43
- inner = inner.slice(1, -1).trim();
44
- }
45
-
46
- if (NOW_FUNCTION_PATTERN.test(inner)) return 'now()';
47
- if (CLOCK_TIMESTAMP_PATTERN.test(inner)) return 'clock_timestamp()';
48
-
49
- // Handle 'now'::text form (Postgres casts the string literal 'now' through ::text)
50
- inner = inner.replace(TEXT_CAST_SUFFIX, '').trim();
51
- if (NOW_LITERAL_PATTERN.test(inner)) return 'now()';
52
-
53
- return undefined;
54
- }
55
-
56
- /**
57
- * Parses a raw Postgres column default expression into a normalized ColumnDefault.
58
- * This enables semantic comparison between contract defaults and introspected schema defaults.
59
- *
60
- * Used by the migration diff layer to normalize raw database defaults during comparison,
61
- * keeping the introspection layer focused on faithful data capture.
62
- *
63
- * @param rawDefault - Raw default expression from information_schema.columns.column_default
64
- * @param nativeType - Native column type, used for type-aware parsing (bigint tagging, JSON detection)
65
- * @returns Normalized ColumnDefault or undefined if the expression cannot be parsed
66
- */
67
- export function parsePostgresDefault(
68
- rawDefault: string,
69
- nativeType?: string,
70
- ): ColumnDefault | undefined {
71
- const trimmed = rawDefault.trim();
72
- const normalizedType = nativeType?.toLowerCase();
73
- const isBigInt = normalizedType === 'bigint' || normalizedType === 'int8';
74
-
75
- // Autoincrement: nextval('tablename_column_seq'::regclass)
76
- if (NEXTVAL_PATTERN.test(trimmed)) {
77
- return { kind: 'function', expression: 'autoincrement()' };
78
- }
79
-
80
- // Timestamp defaults: now()/CURRENT_TIMESTAMP → 'now()', clock_timestamp() → 'clock_timestamp()'
81
- const canonicalTimestamp = canonicalizeTimestampDefault(trimmed);
82
- if (canonicalTimestamp) {
83
- return { kind: 'function', expression: canonicalTimestamp };
84
- }
85
-
86
- // gen_random_uuid()
87
- if (UUID_PATTERN.test(trimmed)) {
88
- return { kind: 'function', expression: 'gen_random_uuid()' };
89
- }
90
-
91
- // uuid_generate_v4() from uuid-ossp extension
92
- if (UUID_OSSP_PATTERN.test(trimmed)) {
93
- return { kind: 'function', expression: 'gen_random_uuid()' };
94
- }
95
-
96
- // NULL or NULL::type — explicit null default
97
- if (NULL_PATTERN.test(trimmed)) {
98
- return { kind: 'literal', value: null };
99
- }
100
-
101
- // Boolean literals
102
- if (TRUE_PATTERN.test(trimmed)) {
103
- return { kind: 'literal', value: true };
104
- }
105
- if (FALSE_PATTERN.test(trimmed)) {
106
- return { kind: 'literal', value: false };
107
- }
108
-
109
- // Numeric literals (integer or decimal)
110
- if (NUMERIC_PATTERN.test(trimmed)) {
111
- const num = Number(trimmed);
112
- if (!Number.isFinite(num)) return undefined;
113
- if (isBigInt && !Number.isSafeInteger(num)) {
114
- return { kind: 'literal', value: trimmed };
115
- }
116
- return { kind: 'literal', value: num };
117
- }
118
-
119
- // String literals: 'value'::type or just 'value'
120
- // Match: 'some text'::text, 'hello'::character varying, 'value', etc.
121
- // Strip the ::type cast so the normalized expression matches what contract authors write.
122
- const stringMatch = trimmed.match(STRING_LITERAL_PATTERN);
123
- if (stringMatch?.[1] !== undefined) {
124
- const unescaped = stringMatch[1].replace(/''/g, "'");
125
- if (normalizedType === 'json' || normalizedType === 'jsonb') {
126
- try {
127
- return { kind: 'literal', value: JSON.parse(unescaped) };
128
- } catch {
129
- // Keep legacy behavior for malformed/non-JSON string content.
130
- }
131
- }
132
- if (isBigInt && NUMERIC_PATTERN.test(unescaped)) {
133
- const num = Number(unescaped);
134
- if (Number.isSafeInteger(num)) {
135
- return { kind: 'literal', value: num };
136
- }
137
- return { kind: 'literal', value: unescaped };
138
- }
139
- return { kind: 'literal', value: unescaped };
140
- }
141
-
142
- // Unrecognized expression - return as a function with the raw expression
143
- // This preserves the information for debugging while still being comparable
144
- return { kind: 'function', expression: trimmed };
145
- }
@@ -1,131 +0,0 @@
1
- type JsonSchemaRecord = Record<string, unknown>;
2
-
3
- const MAX_DEPTH = 32;
4
-
5
- function isRecord(value: unknown): value is JsonSchemaRecord {
6
- return typeof value === 'object' && value !== null;
7
- }
8
-
9
- function escapeStringLiteral(str: string): string {
10
- return str
11
- .replace(/\\/g, '\\\\')
12
- .replace(/'/g, "\\'")
13
- .replace(/\n/g, '\\n')
14
- .replace(/\r/g, '\\r');
15
- }
16
-
17
- function quotePropertyKey(key: string): string {
18
- return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : `'${escapeStringLiteral(key)}'`;
19
- }
20
-
21
- function renderLiteral(value: unknown): string {
22
- if (typeof value === 'string') {
23
- return `'${escapeStringLiteral(value)}'`;
24
- }
25
- if (typeof value === 'number' || typeof value === 'boolean') {
26
- return String(value);
27
- }
28
- if (value === null) {
29
- return 'null';
30
- }
31
- return 'unknown';
32
- }
33
-
34
- function renderUnion(items: readonly unknown[], depth: number): string {
35
- const rendered = items.map((item) => render(item, depth));
36
- return rendered.join(' | ');
37
- }
38
-
39
- function renderObjectType(schema: JsonSchemaRecord, depth: number): string {
40
- const properties = isRecord(schema['properties']) ? schema['properties'] : {};
41
- const required = Array.isArray(schema['required'])
42
- ? new Set(schema['required'].filter((key): key is string => typeof key === 'string'))
43
- : new Set<string>();
44
- const keys = Object.keys(properties).sort((left, right) => left.localeCompare(right));
45
-
46
- if (keys.length === 0) {
47
- const additionalProperties = schema['additionalProperties'];
48
- if (additionalProperties === true || additionalProperties === undefined) {
49
- return 'Record<string, unknown>';
50
- }
51
- return `Record<string, ${render(additionalProperties, depth)}>`;
52
- }
53
-
54
- const renderedProperties = keys.map((key) => {
55
- const valueSchema = (properties as JsonSchemaRecord)[key];
56
- const optionalMarker = required.has(key) ? '' : '?';
57
- return `${quotePropertyKey(key)}${optionalMarker}: ${render(valueSchema, depth)}`;
58
- });
59
-
60
- return `{ ${renderedProperties.join('; ')} }`;
61
- }
62
-
63
- function renderArrayType(schema: JsonSchemaRecord, depth: number): string {
64
- if (Array.isArray(schema['items'])) {
65
- return `readonly [${schema['items'].map((item) => render(item, depth)).join(', ')}]`;
66
- }
67
-
68
- if (schema['items'] !== undefined) {
69
- const itemType = render(schema['items'], depth);
70
- const needsParens = itemType.includes(' | ') || itemType.includes(' & ');
71
- return needsParens ? `(${itemType})[]` : `${itemType}[]`;
72
- }
73
-
74
- return 'unknown[]';
75
- }
76
-
77
- function render(schema: unknown, depth: number): string {
78
- if (depth > MAX_DEPTH || !isRecord(schema)) {
79
- return 'JsonValue';
80
- }
81
-
82
- const nextDepth = depth + 1;
83
-
84
- if ('const' in schema) {
85
- return renderLiteral(schema['const']);
86
- }
87
-
88
- if (Array.isArray(schema['enum'])) {
89
- return schema['enum'].map((value) => renderLiteral(value)).join(' | ');
90
- }
91
-
92
- if (Array.isArray(schema['oneOf'])) {
93
- return renderUnion(schema['oneOf'], nextDepth);
94
- }
95
-
96
- if (Array.isArray(schema['anyOf'])) {
97
- return renderUnion(schema['anyOf'], nextDepth);
98
- }
99
-
100
- if (Array.isArray(schema['allOf'])) {
101
- return schema['allOf'].map((item) => render(item, nextDepth)).join(' & ');
102
- }
103
-
104
- if (Array.isArray(schema['type'])) {
105
- return schema['type'].map((item) => render({ ...schema, type: item }, nextDepth)).join(' | ');
106
- }
107
-
108
- switch (schema['type']) {
109
- case 'string':
110
- return 'string';
111
- case 'number':
112
- case 'integer':
113
- return 'number';
114
- case 'boolean':
115
- return 'boolean';
116
- case 'null':
117
- return 'null';
118
- case 'array':
119
- return renderArrayType(schema, nextDepth);
120
- case 'object':
121
- return renderObjectType(schema, nextDepth);
122
- default:
123
- break;
124
- }
125
-
126
- return 'JsonValue';
127
- }
128
-
129
- export function renderTypeScriptTypeFromJsonSchema(schema: unknown): string {
130
- return render(schema, 0);
131
- }
@@ -1,53 +0,0 @@
1
- import type {
2
- JsonSchemaValidateFn,
3
- JsonSchemaValidationError,
4
- JsonSchemaValidationResult,
5
- } from '@prisma-next/sql-relational-core/query-lane-context';
6
- import Ajv from 'ajv';
7
-
8
- export type { JsonSchemaValidateFn, JsonSchemaValidationError, JsonSchemaValidationResult };
9
-
10
- /**
11
- * Shared Ajv instance for all JSON Schema validators.
12
- * Reusing a single instance avoids ~50-100KB memory overhead per compiled schema.
13
- */
14
- let sharedAjv: Ajv | undefined;
15
-
16
- function getSharedAjv(): Ajv {
17
- if (!sharedAjv) {
18
- sharedAjv = new Ajv({ allErrors: false, strict: false });
19
- }
20
- return sharedAjv;
21
- }
22
-
23
- /**
24
- * Compiles a JSON Schema object into a reusable validate function using Ajv.
25
- *
26
- * The returned function validates a value against the schema and returns
27
- * a structured result with error details on failure.
28
- *
29
- * Uses a shared Ajv instance and fail-fast mode (`allErrors: false`)
30
- * to minimize memory and CPU overhead.
31
- *
32
- * @param schema - A JSON Schema object (draft-07 compatible)
33
- * @returns A validate function
34
- */
35
- export function compileJsonSchemaValidator(schema: Record<string, unknown>): JsonSchemaValidateFn {
36
- const ajv = getSharedAjv();
37
- const validate = ajv.compile(schema);
38
-
39
- return (value: unknown): JsonSchemaValidationResult => {
40
- const valid = validate(value);
41
- if (valid) {
42
- return { valid: true };
43
- }
44
-
45
- const errors: JsonSchemaValidationError[] = (validate.errors ?? []).map((err) => ({
46
- path: err.instancePath || '/',
47
- message: err.message ?? 'unknown validation error',
48
- keyword: err.keyword,
49
- }));
50
-
51
- return { valid: false, errors };
52
- };
53
- }
@@ -1,111 +0,0 @@
1
- /**
2
- * Shared SQL utility functions for the Postgres adapter.
3
- *
4
- * These functions handle safe SQL identifier and literal escaping
5
- * with security validations to prevent injection and encoding issues.
6
- */
7
-
8
- /**
9
- * Error thrown when an invalid SQL identifier or literal is detected.
10
- * Boundary layers map this to structured envelopes.
11
- */
12
- export class SqlEscapeError extends Error {
13
- constructor(
14
- message: string,
15
- public readonly value: string,
16
- public readonly kind: 'identifier' | 'literal',
17
- ) {
18
- super(message);
19
- this.name = 'SqlEscapeError';
20
- }
21
- }
22
-
23
- /**
24
- * Maximum length for PostgreSQL identifiers (NAMEDATALEN - 1).
25
- */
26
- const MAX_IDENTIFIER_LENGTH = 63;
27
-
28
- /**
29
- * Validates and quotes a PostgreSQL identifier (table, column, type, schema names).
30
- *
31
- * Security validations:
32
- * - Rejects null bytes which could cause truncation or unexpected behavior
33
- * - Rejects empty identifiers
34
- * - Warns on identifiers exceeding PostgreSQL's 63-character limit
35
- *
36
- * @throws {SqlEscapeError} If the identifier contains null bytes or is empty
37
- */
38
- export function quoteIdentifier(identifier: string): string {
39
- if (identifier.length === 0) {
40
- throw new SqlEscapeError('Identifier cannot be empty', identifier, 'identifier');
41
- }
42
- if (identifier.includes('\0')) {
43
- throw new SqlEscapeError(
44
- 'Identifier cannot contain null bytes',
45
- identifier.replace(/\0/g, '\\0'),
46
- 'identifier',
47
- );
48
- }
49
- // PostgreSQL will truncate identifiers longer than 63 characters.
50
- // We don't throw here because it's not a security issue, but callers should be aware.
51
- if (identifier.length > MAX_IDENTIFIER_LENGTH) {
52
- // Log warning in development, but don't fail - PostgreSQL handles truncation
53
- console.warn(
54
- `Identifier "${identifier.slice(0, 20)}..." exceeds PostgreSQL's ${MAX_IDENTIFIER_LENGTH}-character limit and will be truncated`,
55
- );
56
- }
57
- return `"${identifier.replace(/"/g, '""')}"`;
58
- }
59
-
60
- /**
61
- * Escapes a string literal for safe use in SQL statements.
62
- *
63
- * Security validations:
64
- * - Rejects null bytes which could cause truncation or unexpected behavior
65
- *
66
- * Note: This assumes PostgreSQL's `standard_conforming_strings` is ON (default since PG 9.1).
67
- * Backslashes are treated as literal characters, not escape sequences.
68
- *
69
- * @throws {SqlEscapeError} If the value contains null bytes
70
- */
71
- export function escapeLiteral(value: string): string {
72
- if (value.includes('\0')) {
73
- throw new SqlEscapeError(
74
- 'Literal value cannot contain null bytes',
75
- value.replace(/\0/g, '\\0'),
76
- 'literal',
77
- );
78
- }
79
- return value.replace(/'/g, "''");
80
- }
81
-
82
- /**
83
- * Builds a qualified name (schema.object) with proper quoting.
84
- */
85
- export function qualifyName(schemaName: string, objectName: string): string {
86
- return `${quoteIdentifier(schemaName)}.${quoteIdentifier(objectName)}`;
87
- }
88
-
89
- /**
90
- * Validates that an enum value doesn't exceed PostgreSQL's label length limit.
91
- *
92
- * PostgreSQL enum labels have a maximum length of NAMEDATALEN-1 (63 bytes by default).
93
- * Unlike identifiers, enum labels that exceed this limit cause an error rather than
94
- * silent truncation.
95
- *
96
- * @param value - The enum value to validate
97
- * @param enumTypeName - Name of the enum type (for error messages)
98
- * @throws {SqlEscapeError} If the value exceeds the maximum length
99
- */
100
- export function validateEnumValueLength(value: string, enumTypeName: string): void {
101
- // PostgreSQL uses byte length, not character length. For simplicity, we use
102
- // character length as a conservative approximation (multi-byte chars would fail earlier).
103
- if (value.length > MAX_IDENTIFIER_LENGTH) {
104
- throw new SqlEscapeError(
105
- `Enum value "${value.slice(0, 20)}..." for type "${enumTypeName}" exceeds PostgreSQL's ` +
106
- `${MAX_IDENTIFIER_LENGTH}-character label limit`,
107
- value,
108
- 'literal',
109
- );
110
- }
111
- }
@@ -1,71 +0,0 @@
1
- type UnknownRecord = Record<string, unknown>;
2
-
3
- type StandardSchemaJsonSchemaField = {
4
- readonly output?: unknown;
5
- };
6
-
7
- /**
8
- * Runtime view of the Standard Schema protocol.
9
- * Reads `~standard.jsonSchema.output` for the serializable JSON Schema representation,
10
- * and `.expression` for an optional TypeScript type expression string (Arktype-specific).
11
- *
12
- * This differs from the compile-time `StandardSchemaLike` in `codec-types.ts`, which reads
13
- * `~standard.types.output` for TypeScript type narrowing in contract.d.ts.
14
- */
15
- export type StandardSchemaLike = {
16
- readonly '~standard'?: {
17
- readonly version?: number;
18
- readonly jsonSchema?: StandardSchemaJsonSchemaField;
19
- };
20
- readonly expression?: unknown;
21
- };
22
-
23
- function isObjectLike(value: unknown): value is UnknownRecord {
24
- return (typeof value === 'object' || typeof value === 'function') && value !== null;
25
- }
26
-
27
- function resolveOutputJsonSchemaField(schema: StandardSchemaLike): unknown {
28
- const jsonSchema = schema['~standard']?.jsonSchema;
29
- if (!jsonSchema) {
30
- return undefined;
31
- }
32
-
33
- if (typeof jsonSchema.output === 'function') {
34
- return jsonSchema.output({
35
- target: 'draft-07',
36
- });
37
- }
38
-
39
- return jsonSchema.output;
40
- }
41
-
42
- export function extractStandardSchemaOutputJsonSchema(
43
- schema: StandardSchemaLike,
44
- ): UnknownRecord | undefined {
45
- const outputSchema = resolveOutputJsonSchemaField(schema);
46
- if (!isObjectLike(outputSchema)) {
47
- return undefined;
48
- }
49
-
50
- return outputSchema;
51
- }
52
-
53
- export function extractStandardSchemaTypeExpression(
54
- schema: StandardSchemaLike,
55
- ): string | undefined {
56
- const expression = schema.expression;
57
- if (typeof expression !== 'string') {
58
- return undefined;
59
- }
60
-
61
- const trimmedExpression = expression.trim();
62
- if (trimmedExpression.length === 0) {
63
- return undefined;
64
- }
65
-
66
- return trimmedExpression;
67
- }
68
-
69
- export function isStandardSchemaLike(value: unknown): value is StandardSchemaLike {
70
- return isObjectLike(value) && isObjectLike((value as StandardSchemaLike)['~standard']);
71
- }
@@ -1,44 +0,0 @@
1
- /**
2
- * Codec type definitions for Postgres adapter.
3
- *
4
- * This file exports type-only definitions for codec input/output types.
5
- * These types are imported by contract.d.ts files for compile-time type inference.
6
- *
7
- * Runtime codec implementations are provided by the adapter's codec registry.
8
- */
9
-
10
- import type { JsonValue } from '@prisma-next/contract/types';
11
- import type { CodecTypes as CoreCodecTypes } from '../core/codecs';
12
-
13
- export type CodecTypes = CoreCodecTypes;
14
-
15
- export type { JsonValue };
16
- export { dataTypes } from '../core/codecs';
17
-
18
- type Branded<T, Shape extends Record<string, unknown>> = T & {
19
- readonly [K in keyof Shape]: Shape[K];
20
- };
21
-
22
- type BrandedString<Shape extends Record<string, unknown>> = Branded<string, Shape>;
23
-
24
- export type Char<N extends number> = BrandedString<{ __charLength: N }>;
25
- export type Varchar<N extends number> = BrandedString<{ __varcharLength: N }>;
26
- export type Numeric<P extends number, S extends number | undefined = undefined> = BrandedString<{
27
- __numericPrecision: P;
28
- __numericScale: S;
29
- }>;
30
- export type Bit<N extends number> = BrandedString<{ __bitLength: N }>;
31
- export type VarBit<N extends number> = BrandedString<{ __varbitLength: N }>;
32
- export type Timestamp<P extends number | undefined = undefined> = BrandedString<{
33
- __timestampPrecision: P;
34
- }>;
35
- export type Timestamptz<P extends number | undefined = undefined> = BrandedString<{
36
- __timestamptzPrecision: P;
37
- }>;
38
- export type Time<P extends number | undefined = undefined> = BrandedString<{ __timePrecision: P }>;
39
- export type Timetz<P extends number | undefined = undefined> = BrandedString<{
40
- __timetzPrecision: P;
41
- }>;
42
- export type Interval<P extends number | undefined = undefined> = BrandedString<{
43
- __intervalPrecision: P;
44
- }>;