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
36 changes: 33 additions & 3 deletions content/docs/references/data/field.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ description: Field protocol schemas
## TypeScript Usage

```typescript
import { AddressSchema, CurrencyConfigSchema, CurrencyValueSchema, FieldSchema, FieldTypeSchema, FileAttachmentConfigSchema, LocationCoordinatesSchema, SelectOptionSchema, VectorConfigSchema } from '@objectstack/spec/data';
import type { Address, CurrencyConfig, CurrencyValue, Field, FieldType, FileAttachmentConfig, LocationCoordinates, SelectOption, VectorConfig } from '@objectstack/spec/data';
import { AddressSchema, ComputedFieldCacheSchema, CurrencyConfigSchema, CurrencyValueSchema, DataQualityRulesSchema, FieldSchema, FieldTypeSchema, FileAttachmentConfigSchema, LocationCoordinatesSchema, SelectOptionSchema, VectorConfigSchema } from '@objectstack/spec/data';
import type { Address, ComputedFieldCache, CurrencyConfig, CurrencyValue, DataQualityRules, Field, FieldType, FileAttachmentConfig, LocationCoordinates, SelectOption, VectorConfig } from '@objectstack/spec/data';

// Validate data
const result = AddressSchema.parse(data);
Expand All @@ -37,6 +37,18 @@ const result = AddressSchema.parse(data);

---

## ComputedFieldCache

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **enabled** | `boolean` | ✅ | Enable caching for computed field results |
| **ttl** | `number` | ✅ | Cache TTL in seconds (0 = no expiration) |
| **invalidateOn** | `string[]` | ✅ | Field paths that invalidate cache (e.g., ["inventory.quantity", "pricing.base_price"]) |

---

## CurrencyConfig

### Properties
Expand All @@ -60,6 +72,18 @@ const result = AddressSchema.parse(data);

---

## DataQualityRules

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **uniqueness** | `boolean` | optional | Enforce unique values across all records |
| **completeness** | `number` | optional | Minimum ratio of non-null values (0-1, default: 0 = no requirement) |
| **accuracy** | `object` | optional | Accuracy validation configuration |

---

## Field

### Properties
Expand Down Expand Up @@ -111,9 +135,15 @@ const result = AddressSchema.parse(data);
| **currencyConfig** | `object` | optional | Configuration for currency field type |
| **vectorConfig** | `object` | optional | Configuration for vector field type (AI/ML embeddings) |
| **fileAttachmentConfig** | `object` | optional | Configuration for file and attachment field types |
| **encryptionConfig** | `object` | optional | Field-level encryption configuration for sensitive data (GDPR/HIPAA/PCI-DSS) |
| **maskingRule** | `object` | optional | Data masking rules for PII protection |
| **auditTrail** | `boolean` | optional | Enable detailed audit trail for this field (tracks all changes with user and timestamp) |
| **dependencies** | `string[]` | optional | Array of field names that this field depends on (for formulas, visibility rules, etc.) |
| **cached** | `object` | optional | Caching configuration for computed/formula fields |
| **dataQuality** | `object` | optional | Data quality validation and monitoring rules |
| **hidden** | `boolean` | optional | Hidden from default UI |
| **readonly** | `boolean` | optional | Read-only in UI |
| **encryption** | `boolean` | optional | Encrypt at rest |
| **encryption** | `boolean` | optional | Deprecated: Use encryptionConfig for enhanced encryption features. Simple flag for backward compatibility. |
| **index** | `boolean` | optional | Create standard database index |
| **externalId** | `boolean` | optional | Is external ID for upsert operations |

Expand Down
81 changes: 75 additions & 6 deletions content/docs/references/data/object.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,38 @@ description: Object protocol schemas
## TypeScript Usage

```typescript
import { IndexSchema, ObjectSchema, ObjectCapabilitiesSchema } from '@objectstack/spec/data';
import type { Index, Object, ObjectCapabilities } from '@objectstack/spec/data';
import { CDCConfigSchema, IndexSchema, ObjectSchema, ObjectCapabilitiesSchema, PartitioningConfigSchema, SoftDeleteConfigSchema, TenancyConfigSchema, VersioningConfigSchema } from '@objectstack/spec/data';
import type { CDCConfig, Index, Object, ObjectCapabilities, PartitioningConfig, SoftDeleteConfig, TenancyConfig, VersioningConfig } from '@objectstack/spec/data';

// Validate data
const result = IndexSchema.parse(data);
const result = CDCConfigSchema.parse(data);
```

---

## CDCConfig

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **enabled** | `boolean` | ✅ | Enable Change Data Capture |
| **events** | `Enum<'insert' \| 'update' \| 'delete'>[]` | ✅ | Event types to capture |
| **destination** | `string` | ✅ | Destination endpoint (e.g., "kafka://topic", "webhook://url") |

---

## Index

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **name** | `string` | optional | Index name |
| **name** | `string` | optional | Index name (auto-generated if not provided) |
| **fields** | `string[]` | ✅ | Fields included in the index |
| **unique** | `boolean` | optional | Whether the index is unique |
| **type** | `Enum<'btree' \| 'hash' \| 'gin' \| 'gist'>` | optional | Index type (default: btree) |
| **type** | `Enum<'btree' \| 'hash' \| 'gin' \| 'gist' \| 'fulltext'>` | optional | Index algorithm type |
| **unique** | `boolean` | optional | Whether the index enforces uniqueness |
| **partial** | `string` | optional | Partial index condition (SQL WHERE clause for conditional indexes) |

---

Expand All @@ -53,6 +66,11 @@ const result = IndexSchema.parse(data);
| **tableName** | `string` | optional | Physical table/collection name in the target datasource |
| **fields** | `Record<string, object>` | ✅ | Field definitions map |
| **indexes** | `object[]` | optional | Database performance indexes |
| **tenancy** | `object` | optional | Multi-tenancy configuration for SaaS applications |
| **softDelete** | `object` | optional | Soft delete (trash/recycle bin) configuration |
| **versioning** | `object` | optional | Record versioning and history tracking configuration |
| **partitioning** | `object` | optional | Table partitioning configuration for performance |
| **cdc** | `object` | optional | Change Data Capture (CDC) configuration for real-time data streaming |
| **validations** | `object \| object \| object \| object \| object \| object \| object \| object \| object[]` | optional | Object-level validation rules |
| **titleFormat** | `string` | optional | Title expression (e.g. "`{name}` - `{code}`"). Overrides nameField. |
| **compactLayout** | `string[]` | optional | Primary fields for hover/cards/lookups |
Expand All @@ -78,3 +96,54 @@ const result = IndexSchema.parse(data);
| **mru** | `boolean` | optional | Track Most Recently Used (MRU) list for users |
| **clone** | `boolean` | optional | Allow record deep cloning |

---

## PartitioningConfig

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **enabled** | `boolean` | ✅ | Enable table partitioning |
| **strategy** | `Enum<'range' \| 'hash' \| 'list'>` | ✅ | Partitioning strategy: range (date ranges), hash (consistent hashing), list (predefined values) |
| **key** | `string` | ✅ | Field name to partition by |
| **interval** | `string` | optional | Partition interval for range strategy (e.g., "1 month", "1 year") |

---

## SoftDeleteConfig

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **enabled** | `boolean` | ✅ | Enable soft delete (trash/recycle bin) |
| **field** | `string` | optional | Field name for soft delete timestamp |
| **cascadeDelete** | `boolean` | optional | Cascade soft delete to related records |

---

## TenancyConfig

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **enabled** | `boolean` | ✅ | Enable multi-tenancy for this object |
| **strategy** | `Enum<'shared' \| 'isolated' \| 'hybrid'>` | ✅ | Tenant isolation strategy: shared (single DB, row-level), isolated (separate DB per tenant), hybrid (mix) |
| **tenantField** | `string` | optional | Field name for tenant identifier |
| **crossTenantAccess** | `boolean` | optional | Allow cross-tenant data access (with explicit permission) |

---

## VersioningConfig

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **enabled** | `boolean` | ✅ | Enable record versioning |
| **strategy** | `Enum<'snapshot' \| 'delta' \| 'event-sourcing'>` | ✅ | Versioning strategy: snapshot (full copy), delta (changes only), event-sourcing (event log) |
| **retentionDays** | `number` | optional | Number of days to retain old versions (undefined = infinite) |
| **versionField** | `string` | optional | Field name for version number/timestamp |

82 changes: 82 additions & 0 deletions content/docs/references/system/driver-sql.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
title: Driver Sql
description: Driver Sql protocol schemas
---

# Driver Sql

<Callout type="info">
**Source:** `packages/spec/src/system/driver-sql.zod.ts`
</Callout>

## TypeScript Usage

```typescript
import { DataTypeMappingSchema, SQLDialectSchema, SQLDriverConfigSchema, SSLConfigSchema } from '@objectstack/spec/system';
import type { DataTypeMapping, SQLDialect, SQLDriverConfig, SSLConfig } from '@objectstack/spec/system';

// Validate data
const result = DataTypeMappingSchema.parse(data);
```

---

## DataTypeMapping

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **text** | `string` | ✅ | SQL type for text fields (e.g., VARCHAR, TEXT) |
| **number** | `string` | ✅ | SQL type for number fields (e.g., NUMERIC, DECIMAL, INT) |
| **boolean** | `string` | ✅ | SQL type for boolean fields (e.g., BOOLEAN, BIT) |
| **date** | `string` | ✅ | SQL type for date fields (e.g., DATE) |
| **datetime** | `string` | ✅ | SQL type for datetime fields (e.g., TIMESTAMP, DATETIME) |
| **json** | `string` | optional | SQL type for JSON fields (e.g., JSON, JSONB) |
| **uuid** | `string` | optional | SQL type for UUID fields (e.g., UUID, CHAR(36)) |
| **binary** | `string` | optional | SQL type for binary fields (e.g., BLOB, BYTEA) |

---

## SQLDialect

### Allowed Values

* `postgresql`
* `mysql`
* `sqlite`
* `mssql`
* `oracle`
* `mariadb`

---

## SQLDriverConfig

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **name** | `string` | ✅ | Driver instance name |
| **type** | `string` | ✅ | Driver type must be "sql" |
| **capabilities** | `object` | ✅ | Driver capability flags |
| **connectionString** | `string` | optional | Database connection string (driver-specific format) |
| **poolConfig** | `object` | optional | Connection pool configuration |
| **dialect** | `Enum<'postgresql' \| 'mysql' \| 'sqlite' \| 'mssql' \| 'oracle' \| 'mariadb'>` | ✅ | SQL database dialect |
| **dataTypeMapping** | `object` | ✅ | SQL data type mapping configuration |
| **ssl** | `boolean` | optional | Enable SSL/TLS connection |
| **sslConfig** | `object` | optional | SSL/TLS configuration (required when ssl is true) |

---

## SSLConfig

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **rejectUnauthorized** | `boolean` | optional | Reject connections with invalid certificates |
| **ca** | `string` | optional | CA certificate file path or content |
| **cert** | `string` | optional | Client certificate file path or content |
| **key** | `string` | optional | Client private key file path or content |

74 changes: 60 additions & 14 deletions content/docs/references/system/driver.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ description: Driver protocol schemas
## TypeScript Usage

```typescript
import { DriverCapabilitiesSchema, DriverInterfaceSchema, DriverOptionsSchema } from '@objectstack/spec/system';
import type { DriverCapabilities, DriverInterface, DriverOptions } from '@objectstack/spec/system';
import { DriverCapabilitiesSchema, DriverConfigSchema, DriverInterfaceSchema, DriverOptionsSchema, PoolConfigSchema } from '@objectstack/spec/system';
import type { DriverCapabilities, DriverConfig, DriverInterface, DriverOptions, PoolConfig } from '@objectstack/spec/system';

// Validate data
const result = DriverCapabilitiesSchema.parse(data);
Expand All @@ -27,19 +27,52 @@ const result = DriverCapabilitiesSchema.parse(data);

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **transactions** | `boolean` | ✅ | Supports transactions |
| **queryFilters** | `boolean` | ✅ | Supports WHERE clause filtering |
| **queryAggregations** | `boolean` | ✅ | Supports GROUP BY and aggregation functions |
| **querySorting** | `boolean` | ✅ | Supports ORDER BY sorting |
| **queryPagination** | `boolean` | ✅ | Supports LIMIT/OFFSET pagination |
| **queryWindowFunctions** | `boolean` | ✅ | Supports window functions with OVER clause |
| **querySubqueries** | `boolean` | ✅ | Supports subqueries |
| **joins** | `boolean` | ✅ | Supports SQL joins |
| **fullTextSearch** | `boolean` | ✅ | Supports full-text search |
| **jsonFields** | `boolean` | ✅ | Supports JSON field types |
| **arrayFields** | `boolean` | ✅ | Supports array field types |
| **create** | `boolean` | optional | Supports CREATE operations |
| **read** | `boolean` | optional | Supports READ operations |
| **update** | `boolean` | optional | Supports UPDATE operations |
| **delete** | `boolean` | optional | Supports DELETE operations |
| **bulkCreate** | `boolean` | optional | Supports bulk CREATE operations |
| **bulkUpdate** | `boolean` | optional | Supports bulk UPDATE operations |
| **bulkDelete** | `boolean` | optional | Supports bulk DELETE operations |
| **transactions** | `boolean` | optional | Supports ACID transactions |
| **savepoints** | `boolean` | optional | Supports transaction savepoints |
| **isolationLevels** | `Enum<'read-uncommitted' \| 'read-committed' \| 'repeatable-read' \| 'serializable'>[]` | optional | Supported transaction isolation levels |
| **queryFilters** | `boolean` | optional | Supports WHERE clause filtering |
| **queryAggregations** | `boolean` | optional | Supports GROUP BY and aggregation functions |
| **querySorting** | `boolean` | optional | Supports ORDER BY sorting |
| **queryPagination** | `boolean` | optional | Supports LIMIT/OFFSET pagination |
| **queryWindowFunctions** | `boolean` | optional | Supports window functions with OVER clause |
| **querySubqueries** | `boolean` | optional | Supports subqueries |
| **queryCTE** | `boolean` | optional | Supports Common Table Expressions (WITH clause) |
| **joins** | `boolean` | optional | Supports SQL joins |
| **fullTextSearch** | `boolean` | optional | Supports full-text search |
| **jsonQuery** | `boolean` | optional | Supports JSON field querying |
| **geospatialQuery** | `boolean` | optional | Supports geospatial queries |
| **streaming** | `boolean` | optional | Supports result streaming (cursors/iterators) |
| **jsonFields** | `boolean` | optional | Supports JSON field types |
| **arrayFields** | `boolean` | optional | Supports array field types |
| **vectorSearch** | `boolean` | optional | Supports vector embeddings and similarity search |
| **geoSpatial** | `boolean` | optional | Supports geospatial queries |
| **geoSpatial** | `boolean` | optional | Supports geospatial queries (deprecated: use geospatialQuery) |
| **schemaSync** | `boolean` | optional | Supports automatic schema synchronization |
| **migrations** | `boolean` | optional | Supports database migrations |
| **indexes** | `boolean` | optional | Supports index creation and management |
| **connectionPooling** | `boolean` | optional | Supports connection pooling |
| **preparedStatements** | `boolean` | optional | Supports prepared statements (SQL injection prevention) |
| **queryCache** | `boolean` | optional | Supports query result caching |

---

## DriverConfig

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **name** | `string` | ✅ | Driver instance name |
| **type** | `Enum<'sql' \| 'nosql' \| 'cache' \| 'search' \| 'graph' \| 'timeseries'>` | ✅ | Driver type category |
| **capabilities** | `object` | ✅ | Driver capability flags |
| **connectionString** | `string` | optional | Database connection string (driver-specific format) |
| **poolConfig** | `object` | optional | Connection pool configuration |

---

Expand Down Expand Up @@ -67,3 +100,16 @@ const result = DriverCapabilitiesSchema.parse(data);
| **traceContext** | `Record<string, string>` | optional | OpenTelemetry context or request ID |
| **tenantId** | `string` | optional | Tenant Isolation identifier |

---

## PoolConfig

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **min** | `number` | optional | Minimum number of connections in pool |
| **max** | `number` | optional | Maximum number of connections in pool |
| **idleTimeoutMillis** | `number` | optional | Time in ms before idle connection is closed |
| **connectionTimeoutMillis** | `number` | optional | Time in ms to wait for available connection |

1 change: 1 addition & 0 deletions content/docs/references/system/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This section contains all protocol schemas for the system layer of ObjectStack.
<Card href="./data-engine" title="Data Engine" description="Source: packages/spec/src/system/data-engine.zod.ts" />
<Card href="./datasource" title="Datasource" description="Source: packages/spec/src/system/datasource.zod.ts" />
<Card href="./driver" title="Driver" description="Source: packages/spec/src/system/driver.zod.ts" />
<Card href="./driver-sql" title="Driver Sql" description="Source: packages/spec/src/system/driver-sql.zod.ts" />
<Card href="./encryption" title="Encryption" description="Source: packages/spec/src/system/encryption.zod.ts" />
<Card href="./events" title="Events" description="Source: packages/spec/src/system/events.zod.ts" />
<Card href="./feature" title="Feature" description="Source: packages/spec/src/system/feature.zod.ts" />
Expand Down
1 change: 1 addition & 0 deletions content/docs/references/system/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"data-engine",
"datasource",
"driver",
"driver-sql",
"encryption",
"events",
"feature",
Expand Down
Loading
Loading