Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions content/docs/references/automation/connector.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ description: Connector protocol schemas
# Connector

<Callout type="info">
**Source:** `packages/spec/src/automation/connector.zod.ts`
**Source:** `packages/spec/src/integration/connector.zod.ts`
</Callout>

## TypeScript Usage

```typescript
import { AuthenticationSchema, ConflictResolutionSchema, ConnectorSchema, DataSyncConfigSchema } from '@objectstack/spec/automation';
import type { Authentication, ConflictResolution, Connector, DataSyncConfig } from '@objectstack/spec/automation';
import { AuthenticationSchema, ConflictResolutionSchema, ConnectorSchema, DataSyncConfigSchema } from '@objectstack/spec/integration';
import type { Authentication, ConflictResolution, Connector, DataSyncConfig } from '@objectstack/spec/integration';

// Validate data
const result = AuthenticationSchema.parse(data);
Expand Down
147 changes: 147 additions & 0 deletions content/docs/references/data/driver-mongo.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
---
title: MongoDB Driver
description: MongoDB driver configuration schema
---

# MongoDB Driver

<Callout type="info">
**Source:** `packages/spec/src/data/driver/mongo.zod.ts`
</Callout>

## Overview

MongoDB driver configuration schema defines connection settings and capabilities specific to MongoDB databases.

## TypeScript Usage

```typescript
import { MongoConfigSchema, MongoDriverSpec } from '@objectstack/spec/data/driver/mongo';
import type { MongoConfig } from '@objectstack/spec/data/driver/mongo';

// Validate MongoDB configuration
const config: MongoConfig = MongoConfigSchema.parse({
database: 'myapp',
host: '127.0.0.1',
port: 27017,
username: 'admin',
password: 'secret',
});
```

---

## MongoConfig

MongoDB connection configuration schema.

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **url** | `string` | optional | Connection URI. Format: mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]] |
| **database** | `string` | ✅ | Database name (required) |
| **host** | `string` | optional | Hostname (default: '127.0.0.1') |
| **port** | `number` | optional | Port number (default: 27017) |
| **username** | `string` | optional | Username for authentication |
| **password** | `string` | optional | Password for authentication |
| **authSource** | `string` | optional | Authentication database (defaults to admin or database name) |
| **options** | `Record<string, any>` | optional | Extra driver options (ssl, poolSize, etc) |

---

## MongoDriverSpec

The static definition of MongoDB driver capabilities.

### Capabilities

| Capability | Supported | Description |
| :--- | :--- | :--- |
| **transactions** | ✅ | ACID transactions |
| **fullTextSearch** | ✅ | Full-text search indexes |
| **geoSpatial** | ✅ | Geospatial queries |
| **aggregation** | ✅ | Aggregation pipeline |
| **mutableSchema** | ✅ | Dynamic schema changes |
| **jsonField** | ✅ | Native JSON/BSON storage |
| **crossObjectJoin** | ✅ | $lookup aggregation |

---

## Examples

### Basic Configuration

```typescript
const config: MongoConfig = {
database: 'crm',
host: '127.0.0.1',
port: 27017,
username: 'app_user',
password: 'secure_password',
};
```

### Connection URI

```typescript
const config: MongoConfig = {
url: 'mongodb://user:password@localhost:27017/mydb',
database: 'mydb', // Still required
};
```

### Replica Set Configuration

```typescript
const config: MongoConfig = {
url: 'mongodb://node1:27017,node2:27017,node3:27017/mydb?replicaSet=rs0',
database: 'mydb',
options: {
replicaSet: 'rs0',
readPreference: 'secondaryPreferred',
},
};
```

### SSL Configuration

```typescript
const config: MongoConfig = {
database: 'production',
host: 'mongodb.example.com',
port: 27017,
username: 'app_user',
password: 'secure_password',
authSource: 'admin',
options: {
ssl: true,
sslValidate: true,
sslCA: '/path/to/ca.pem',
},
};
```

### Connection Pool Options

```typescript
const config: MongoConfig = {
database: 'myapp',
host: 'localhost',
port: 27017,
options: {
poolSize: 20,
socketTimeoutMS: 30000,
connectTimeoutMS: 10000,
serverSelectionTimeoutMS: 5000,
},
};
```

---

## Related

- [Driver](/docs/references/data/driver) - Base driver protocol
- [Driver NoSQL](/docs/references/data/driver-nosql) - NoSQL driver interface
- [Datasource](/docs/references/system/datasource) - Datasource configuration
133 changes: 133 additions & 0 deletions content/docs/references/data/driver-postgres.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
title: PostgreSQL Driver
description: PostgreSQL driver configuration schema
---

# PostgreSQL Driver

<Callout type="info">
**Source:** `packages/spec/src/data/driver/postgres.zod.ts`
</Callout>

## Overview

PostgreSQL driver configuration schema defines connection settings and options specific to PostgreSQL databases.

## TypeScript Usage

```typescript
import { PostgresConfigSchema } from '@objectstack/spec/data/driver/postgres';
import type { PostgresConfig } from '@objectstack/spec/data/driver/postgres';

// Validate PostgreSQL configuration
const config: PostgresConfig = PostgresConfigSchema.parse({
database: 'myapp',
host: 'localhost',
port: 5432,
username: 'postgres',
password: 'secret',
ssl: false,
});
```

---

## PostgresConfig

PostgreSQL connection configuration schema.

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **url** | `string` | optional | Connection URI. Format: postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...] |
| **database** | `string` | ✅ | Database name |
| **host** | `string` | optional | Hostname or IP address (default: 'localhost') |
| **port** | `number` | optional | Port number (default: 5432) |
| **username** | `string` | optional | Authentication username |
| **password** | `string` | optional | Authentication password |
| **schema** | `string` | optional | Default schema for tables (default: 'public') |
| **ssl** | `boolean \| object` | optional | Enable SSL/TLS connection |
| **applicationName** | `string` | optional | Sets the application_name configuration parameter |
| **max** | `number` | optional | Maximum number of clients in pool (default: 10) |
| **min** | `number` | optional | Minimum number of clients in pool (default: 0) |
| **idleTimeoutMillis** | `number` | optional | Idle timeout in milliseconds |
| **connectionTimeoutMillis** | `number` | optional | Connection timeout in milliseconds |
| **statementTimeout** | `number` | optional | Statement timeout in milliseconds |

### SSL Configuration

When `ssl` is an object, it can contain:

| Property | Type | Description |
| :--- | :--- | :--- |
| **rejectUnauthorized** | `boolean` | Whether to reject unauthorized certificates |
| **ca** | `string` | CA certificate |
| **key** | `string` | Client key |
| **cert** | `string` | Client certificate |

---

## Examples

### Basic Configuration

```typescript
const config: PostgresConfig = {
database: 'crm',
host: 'localhost',
port: 5432,
username: 'app_user',
password: 'secure_password',
};
```

### Connection URI

```typescript
const config: PostgresConfig = {
url: 'postgresql://user:password@localhost:5432/mydb',
database: 'mydb', // Required even with URL
};
```

### SSL Configuration

```typescript
const config: PostgresConfig = {
database: 'production',
host: 'db.example.com',
port: 5432,
username: 'app_user',
password: 'secure_password',
ssl: {
rejectUnauthorized: true,
ca: '-----BEGIN CERTIFICATE-----\n...',
},
};
```

### Connection Pool Configuration

```typescript
const config: PostgresConfig = {
database: 'myapp',
host: 'localhost',
port: 5432,
username: 'postgres',
password: 'secret',
max: 20, // Max 20 connections
min: 5, // Keep at least 5 connections
idleTimeoutMillis: 30000, // Close idle connections after 30s
connectionTimeoutMillis: 2000, // Timeout connection attempts after 2s
statementTimeout: 5000, // Abort slow queries after 5s
};
```

---

## Related

- [Driver](/docs/references/data/driver) - Base driver protocol
- [Driver SQL](/docs/references/data/driver-sql) - SQL driver interface
- [Datasource](/docs/references/system/datasource) - Datasource configuration
2 changes: 2 additions & 0 deletions content/docs/references/data/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"dataset",
"document",
"driver",
"driver-mongo",
"driver-nosql",
"driver-postgres",
"driver-sql",
"external-lookup",
"field",
Expand Down
33 changes: 0 additions & 33 deletions content/docs/references/data/search-engine.mdx

This file was deleted.

Loading
Loading