-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpostgres.zod.ts
More file actions
103 lines (87 loc) · 2.78 KB
/
postgres.zod.ts
File metadata and controls
103 lines (87 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { z } from 'zod';
/**
* PostgreSQL Driver Configuration Schema
* Defines the connection settings specific to PostgreSQL.
*/
export const PostgresConfigSchema = z.object({
/**
* Connection URI.
* If provided, it takes precedence over host/port/database.
* Format: postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]
*/
url: z.string().optional().describe('Connection URI'),
/**
* Database Name.
*/
database: z.string().describe('Database Name'),
/**
* Hostname or IP address.
* Defaults to localhost.
*/
host: z.string().default('localhost').describe('Host address'),
/**
* Port number.
* Defaults to 5432.
*/
port: z.number().default(5432).describe('Port number'),
/**
* Authentication Username.
*/
username: z.string().optional().describe('Auth User'),
/**
* Authentication Password.
*/
password: z.string().optional().describe('Auth Password'),
/**
* Default Schema.
* The schema to use for tables that do not specify a schema.
* Defaults to 'public'.
*/
schema: z.string().default('public').describe('Default Schema'),
/**
* Enable SSL/TLS.
* Can be a boolean or an object with specific SSL configuration (ca, cert, key, rejectUnauthorized).
*/
ssl: z.union([
z.boolean(),
z.object({
rejectUnauthorized: z.boolean().optional(),
ca: z.string().optional(),
key: z.string().optional(),
cert: z.string().optional(),
})
]).optional().describe('Enable SSL'),
/**
* Application Name.
* Sets the application_name configuration parameter.
*/
applicationName: z.string().optional().describe('Application Name'),
/**
* Connection Pool: Max Clients.
* Maximum number of clients the pool should contain.
*/
max: z.number().default(10).describe('Max Pool Size'),
/**
* Connection Pool: Min Clients.
* Minimum number of clients to keep in the pool.
*/
min: z.number().default(0).describe('Min Pool Size'),
/**
* Idle Timeout (ms).
* The number of milliseconds a client must sit idle in the pool and not be checked out
* before it is disconnected from the backend and discarded.
*/
idleTimeoutMillis: z.number().optional().describe('Idle Timeout (ms)'),
/**
* Connection Timeout (ms).
* The number of milliseconds to wait before timing out when connecting a new client.
*/
connectionTimeoutMillis: z.number().optional().describe('Connection Timeout (ms)'),
/**
* Statement Timeout (ms).
* Abort any statement that takes more than the specified number of milliseconds.
*/
statementTimeout: z.number().optional().describe('Statement Timeout (ms)'),
});
export type PostgresConfig = z.infer<typeof PostgresConfigSchema>;