Skip to content

Commit fd4969c

Browse files
Copilothotlong
andcommitted
Add SQL driver tests and export SQL driver schema
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent fc80492 commit fd4969c

10 files changed

Lines changed: 821 additions & 3 deletions

File tree

content/docs/references/data/object.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const result = CDCConfigSchema.parse(data);
3939

4040
| Property | Type | Required | Description |
4141
| :--- | :--- | :--- | :--- |
42-
| **name** | `string` | | Index name (auto-generated if not provided) |
42+
| **name** | `string` | optional | Index name (auto-generated if not provided) |
4343
| **fields** | `string[]` || Fields included in the index |
4444
| **type** | `Enum<'btree' \| 'hash' \| 'gin' \| 'gist' \| 'fulltext'>` | optional | Index algorithm type |
4545
| **unique** | `boolean` | optional | Whether the index enforces uniqueness |
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
title: Driver Sql
3+
description: Driver Sql protocol schemas
4+
---
5+
6+
# Driver Sql
7+
8+
<Callout type="info">
9+
**Source:** `packages/spec/src/system/driver-sql.zod.ts`
10+
</Callout>
11+
12+
## TypeScript Usage
13+
14+
```typescript
15+
import { DataTypeMappingSchema, SQLDialectSchema, SQLDriverConfigSchema, SSLConfigSchema } from '@objectstack/spec/system';
16+
import type { DataTypeMapping, SQLDialect, SQLDriverConfig, SSLConfig } from '@objectstack/spec/system';
17+
18+
// Validate data
19+
const result = DataTypeMappingSchema.parse(data);
20+
```
21+
22+
---
23+
24+
## DataTypeMapping
25+
26+
### Properties
27+
28+
| Property | Type | Required | Description |
29+
| :--- | :--- | :--- | :--- |
30+
| **text** | `string` || SQL type for text fields (e.g., VARCHAR, TEXT) |
31+
| **number** | `string` || SQL type for number fields (e.g., NUMERIC, DECIMAL, INT) |
32+
| **boolean** | `string` || SQL type for boolean fields (e.g., BOOLEAN, BIT) |
33+
| **date** | `string` || SQL type for date fields (e.g., DATE) |
34+
| **datetime** | `string` || SQL type for datetime fields (e.g., TIMESTAMP, DATETIME) |
35+
| **json** | `string` | optional | SQL type for JSON fields (e.g., JSON, JSONB) |
36+
| **uuid** | `string` | optional | SQL type for UUID fields (e.g., UUID, CHAR(36)) |
37+
| **binary** | `string` | optional | SQL type for binary fields (e.g., BLOB, BYTEA) |
38+
39+
---
40+
41+
## SQLDialect
42+
43+
### Allowed Values
44+
45+
* `postgresql`
46+
* `mysql`
47+
* `sqlite`
48+
* `mssql`
49+
* `oracle`
50+
* `mariadb`
51+
52+
---
53+
54+
## SQLDriverConfig
55+
56+
### Properties
57+
58+
| Property | Type | Required | Description |
59+
| :--- | :--- | :--- | :--- |
60+
| **name** | `string` || Driver instance name |
61+
| **type** | `string` || Driver type must be "sql" |
62+
| **capabilities** | `object` || Driver capability flags |
63+
| **connectionString** | `string` | optional | Database connection string (driver-specific format) |
64+
| **poolConfig** | `object` | optional | Connection pool configuration |
65+
| **dialect** | `Enum<'postgresql' \| 'mysql' \| 'sqlite' \| 'mssql' \| 'oracle' \| 'mariadb'>` || SQL database dialect |
66+
| **dataTypeMapping** | `object` || SQL data type mapping configuration |
67+
| **ssl** | `boolean` | optional | Enable SSL/TLS connection |
68+
| **sslConfig** | `object` | optional | SSL/TLS configuration (required when ssl is true) |
69+
70+
---
71+
72+
## SSLConfig
73+
74+
### Properties
75+
76+
| Property | Type | Required | Description |
77+
| :--- | :--- | :--- | :--- |
78+
| **rejectUnauthorized** | `boolean` | optional | Reject connections with invalid certificates |
79+
| **ca** | `string` | optional | CA certificate file path or content |
80+
| **cert** | `string` | optional | Client certificate file path or content |
81+
| **key** | `string` | optional | Client private key file path or content |
82+

packages/spec/json-schema/data/Index.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
}
3939
},
4040
"required": [
41-
"name",
4241
"fields"
4342
],
4443
"additionalProperties": false

packages/spec/json-schema/data/Object.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,6 @@
954954
}
955955
},
956956
"required": [
957-
"name",
958957
"fields"
959958
],
960959
"additionalProperties": false
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"$ref": "#/definitions/DataTypeMapping",
3+
"definitions": {
4+
"DataTypeMapping": {
5+
"type": "object",
6+
"properties": {
7+
"text": {
8+
"type": "string",
9+
"description": "SQL type for text fields (e.g., VARCHAR, TEXT)"
10+
},
11+
"number": {
12+
"type": "string",
13+
"description": "SQL type for number fields (e.g., NUMERIC, DECIMAL, INT)"
14+
},
15+
"boolean": {
16+
"type": "string",
17+
"description": "SQL type for boolean fields (e.g., BOOLEAN, BIT)"
18+
},
19+
"date": {
20+
"type": "string",
21+
"description": "SQL type for date fields (e.g., DATE)"
22+
},
23+
"datetime": {
24+
"type": "string",
25+
"description": "SQL type for datetime fields (e.g., TIMESTAMP, DATETIME)"
26+
},
27+
"json": {
28+
"type": "string",
29+
"description": "SQL type for JSON fields (e.g., JSON, JSONB)"
30+
},
31+
"uuid": {
32+
"type": "string",
33+
"description": "SQL type for UUID fields (e.g., UUID, CHAR(36))"
34+
},
35+
"binary": {
36+
"type": "string",
37+
"description": "SQL type for binary fields (e.g., BLOB, BYTEA)"
38+
}
39+
},
40+
"required": [
41+
"text",
42+
"number",
43+
"boolean",
44+
"date",
45+
"datetime"
46+
],
47+
"additionalProperties": false
48+
}
49+
},
50+
"$schema": "http://json-schema.org/draft-07/schema#"
51+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$ref": "#/definitions/SQLDialect",
3+
"definitions": {
4+
"SQLDialect": {
5+
"type": "string",
6+
"enum": [
7+
"postgresql",
8+
"mysql",
9+
"sqlite",
10+
"mssql",
11+
"oracle",
12+
"mariadb"
13+
]
14+
}
15+
},
16+
"$schema": "http://json-schema.org/draft-07/schema#"
17+
}

0 commit comments

Comments
 (0)