Skip to content

Commit ffb2e4b

Browse files
Copilothotlong
andcommitted
Phase 2 complete: Created NoSQL Driver Protocol with comprehensive schemas
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 06cc8ba commit ffb2e4b

20 files changed

+2144
-0
lines changed
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
---
2+
title: Driver Nosql
3+
description: Driver Nosql protocol schemas
4+
---
5+
6+
# Driver Nosql
7+
8+
<Callout type="info">
9+
**Source:** `packages/spec/src/system/driver-nosql.zod.ts`
10+
</Callout>
11+
12+
## TypeScript Usage
13+
14+
```typescript
15+
import { AggregationPipelineSchema, AggregationStageSchema, ConsistencyLevelSchema, DocumentValidationSchemaSchema, NoSQLDataTypeMappingSchema, NoSQLDatabaseTypeSchema, NoSQLDriverConfigSchema, NoSQLIndexSchema, NoSQLIndexTypeSchema, NoSQLOperationTypeSchema, NoSQLQueryOptionsSchema, NoSQLTransactionOptionsSchema, ReplicationConfigSchema, ShardingConfigSchema } from '@objectstack/spec/system';
16+
import type { AggregationPipeline, AggregationStage, ConsistencyLevel, DocumentValidationSchema, NoSQLDataTypeMapping, NoSQLDatabaseType, NoSQLDriverConfig, NoSQLIndex, NoSQLIndexType, NoSQLOperationType, NoSQLQueryOptions, NoSQLTransactionOptions, ReplicationConfig, ShardingConfig } from '@objectstack/spec/system';
17+
18+
// Validate data
19+
const result = AggregationPipelineSchema.parse(data);
20+
```
21+
22+
---
23+
24+
## AggregationPipeline
25+
26+
### Properties
27+
28+
| Property | Type | Required | Description |
29+
| :--- | :--- | :--- | :--- |
30+
| **collection** | `string` || Collection/table name |
31+
| **stages** | `object[]` || Aggregation pipeline stages |
32+
| **options** | `object` | optional | Query options |
33+
34+
---
35+
36+
## AggregationStage
37+
38+
### Properties
39+
40+
| Property | Type | Required | Description |
41+
| :--- | :--- | :--- | :--- |
42+
| **operator** | `string` || Aggregation operator (e.g., $match, $group, $sort) |
43+
| **options** | `Record<string, any>` || Stage-specific options |
44+
45+
---
46+
47+
## ConsistencyLevel
48+
49+
### Allowed Values
50+
51+
* `all`
52+
* `quorum`
53+
* `one`
54+
* `local_quorum`
55+
* `each_quorum`
56+
* `eventual`
57+
58+
---
59+
60+
## DocumentValidationSchema
61+
62+
### Properties
63+
64+
| Property | Type | Required | Description |
65+
| :--- | :--- | :--- | :--- |
66+
| **enabled** | `boolean` | optional | Enable schema validation |
67+
| **validationLevel** | `Enum<'strict' \| 'moderate' \| 'off'>` | optional | Validation strictness |
68+
| **validationAction** | `Enum<'error' \| 'warn'>` | optional | Action on validation failure |
69+
| **jsonSchema** | `Record<string, any>` | optional | JSON Schema for validation |
70+
71+
---
72+
73+
## NoSQLDataTypeMapping
74+
75+
### Properties
76+
77+
| Property | Type | Required | Description |
78+
| :--- | :--- | :--- | :--- |
79+
| **text** | `string` || NoSQL type for text fields |
80+
| **number** | `string` || NoSQL type for number fields |
81+
| **boolean** | `string` || NoSQL type for boolean fields |
82+
| **date** | `string` || NoSQL type for date fields |
83+
| **datetime** | `string` || NoSQL type for datetime fields |
84+
| **json** | `string` | optional | NoSQL type for JSON/object fields |
85+
| **uuid** | `string` | optional | NoSQL type for UUID fields |
86+
| **binary** | `string` | optional | NoSQL type for binary fields |
87+
| **array** | `string` | optional | NoSQL type for array fields |
88+
| **objectId** | `string` | optional | NoSQL type for ObjectID fields (MongoDB) |
89+
| **geopoint** | `string` | optional | NoSQL type for geospatial point fields |
90+
91+
---
92+
93+
## NoSQLDatabaseType
94+
95+
### Allowed Values
96+
97+
* `mongodb`
98+
* `couchdb`
99+
* `dynamodb`
100+
* `cassandra`
101+
* `redis`
102+
* `elasticsearch`
103+
* `neo4j`
104+
* `orientdb`
105+
106+
---
107+
108+
## NoSQLDriverConfig
109+
110+
### Properties
111+
112+
| Property | Type | Required | Description |
113+
| :--- | :--- | :--- | :--- |
114+
| **name** | `string` || Driver instance name |
115+
| **type** | `string` || Driver type must be "nosql" |
116+
| **capabilities** | `object` || Driver capability flags |
117+
| **connectionString** | `string` | optional | Database connection string (driver-specific format) |
118+
| **poolConfig** | `object` | optional | Connection pool configuration |
119+
| **databaseType** | `Enum<'mongodb' \| 'couchdb' \| 'dynamodb' \| 'cassandra' \| 'redis' \| 'elasticsearch' \| 'neo4j' \| 'orientdb'>` || Specific NoSQL database type |
120+
| **dataTypeMapping** | `object` || NoSQL data type mapping configuration |
121+
| **consistency** | `Enum<'all' \| 'quorum' \| 'one' \| 'local_quorum' \| 'each_quorum' \| 'eventual'>` | optional | Consistency level for operations |
122+
| **replication** | `object` | optional | Replication configuration |
123+
| **sharding** | `object` | optional | Sharding configuration |
124+
| **schemaValidation** | `object` | optional | Document schema validation |
125+
| **region** | `string` | optional | AWS region (for managed NoSQL services) |
126+
| **accessKeyId** | `string` | optional | AWS access key ID |
127+
| **secretAccessKey** | `string` | optional | AWS secret access key |
128+
| **ttlField** | `string` | optional | Field name for TTL (auto-deletion) |
129+
| **maxDocumentSize** | `integer` | optional | Maximum document size in bytes |
130+
| **collectionPrefix** | `string` | optional | Prefix for collection/table names |
131+
132+
---
133+
134+
## NoSQLIndex
135+
136+
### Properties
137+
138+
| Property | Type | Required | Description |
139+
| :--- | :--- | :--- | :--- |
140+
| **name** | `string` || Index name |
141+
| **type** | `Enum<'single' \| 'compound' \| 'unique' \| 'text' \| 'geospatial' \| 'hashed' \| 'ttl' \| 'sparse'>` || Index type |
142+
| **fields** | `object[]` || Fields to index |
143+
| **unique** | `boolean` | optional | Enforce uniqueness |
144+
| **sparse** | `boolean` | optional | Sparse index |
145+
| **expireAfterSeconds** | `integer` | optional | TTL in seconds |
146+
| **partialFilterExpression** | `Record<string, any>` | optional | Partial index filter |
147+
| **background** | `boolean` | optional | Create index in background |
148+
149+
---
150+
151+
## NoSQLIndexType
152+
153+
### Allowed Values
154+
155+
* `single`
156+
* `compound`
157+
* `unique`
158+
* `text`
159+
* `geospatial`
160+
* `hashed`
161+
* `ttl`
162+
* `sparse`
163+
164+
---
165+
166+
## NoSQLOperationType
167+
168+
### Allowed Values
169+
170+
* `find`
171+
* `findOne`
172+
* `insert`
173+
* `update`
174+
* `delete`
175+
* `aggregate`
176+
* `mapReduce`
177+
* `count`
178+
* `distinct`
179+
* `createIndex`
180+
* `dropIndex`
181+
182+
---
183+
184+
## NoSQLQueryOptions
185+
186+
### Properties
187+
188+
| Property | Type | Required | Description |
189+
| :--- | :--- | :--- | :--- |
190+
| **consistency** | `Enum<'all' \| 'quorum' \| 'one' \| 'local_quorum' \| 'each_quorum' \| 'eventual'>` | optional | Consistency level override |
191+
| **readFromSecondary** | `boolean` | optional | Allow reading from secondary replicas |
192+
| **projection** | `Record<string, Enum<'0' \| '1'>>` | optional | Field projection |
193+
| **timeout** | `integer` | optional | Query timeout (ms) |
194+
| **useCursor** | `boolean` | optional | Use cursor instead of loading all results |
195+
| **batchSize** | `integer` | optional | Cursor batch size |
196+
| **profile** | `boolean` | optional | Enable query profiling |
197+
| **hint** | `string` | optional | Index hint for query optimization |
198+
199+
---
200+
201+
## NoSQLTransactionOptions
202+
203+
### Properties
204+
205+
| Property | Type | Required | Description |
206+
| :--- | :--- | :--- | :--- |
207+
| **readConcern** | `Enum<'local' \| 'majority' \| 'linearizable' \| 'snapshot'>` | optional | Read concern level |
208+
| **writeConcern** | `Enum<'majority' \| 'acknowledged' \| 'unacknowledged'>` | optional | Write concern level |
209+
| **readPreference** | `Enum<'primary' \| 'primaryPreferred' \| 'secondary' \| 'secondaryPreferred' \| 'nearest'>` | optional | Read preference |
210+
| **maxCommitTimeMS** | `integer` | optional | Transaction commit timeout (ms) |
211+
212+
---
213+
214+
## ReplicationConfig
215+
216+
### Properties
217+
218+
| Property | Type | Required | Description |
219+
| :--- | :--- | :--- | :--- |
220+
| **enabled** | `boolean` | optional | Enable replication |
221+
| **replicaSetName** | `string` | optional | Replica set name |
222+
| **replicas** | `integer` | optional | Number of replicas |
223+
| **readPreference** | `Enum<'primary' \| 'primaryPreferred' \| 'secondary' \| 'secondaryPreferred' \| 'nearest'>` | optional | Read preference for replica set |
224+
| **writeConcern** | `Enum<'majority' \| 'acknowledged' \| 'unacknowledged'>` | optional | Write concern level |
225+
226+
---
227+
228+
## ShardingConfig
229+
230+
### Properties
231+
232+
| Property | Type | Required | Description |
233+
| :--- | :--- | :--- | :--- |
234+
| **enabled** | `boolean` | optional | Enable sharding |
235+
| **shardKey** | `string` | optional | Field to use as shard key |
236+
| **shardingStrategy** | `Enum<'hash' \| 'range' \| 'zone'>` | optional | Sharding strategy |
237+
| **numShards** | `integer` | optional | Number of shards |
238+

content/docs/references/system/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This section contains all protocol schemas for the system layer of ObjectStack.
1616
<Card href="./data-engine" title="Data Engine" description="Source: packages/spec/src/system/data-engine.zod.ts" />
1717
<Card href="./datasource" title="Datasource" description="Source: packages/spec/src/system/datasource.zod.ts" />
1818
<Card href="./driver" title="Driver" description="Source: packages/spec/src/system/driver.zod.ts" />
19+
<Card href="./driver-nosql" title="Driver Nosql" description="Source: packages/spec/src/system/driver-nosql.zod.ts" />
1920
<Card href="./driver-sql" title="Driver Sql" description="Source: packages/spec/src/system/driver-sql.zod.ts" />
2021
<Card href="./encryption" title="Encryption" description="Source: packages/spec/src/system/encryption.zod.ts" />
2122
<Card href="./events" title="Events" description="Source: packages/spec/src/system/events.zod.ts" />

content/docs/references/system/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"data-engine",
1010
"datasource",
1111
"driver",
12+
"driver-nosql",
1213
"driver-sql",
1314
"encryption",
1415
"events",
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
"$ref": "#/definitions/AggregationPipeline",
3+
"definitions": {
4+
"AggregationPipeline": {
5+
"type": "object",
6+
"properties": {
7+
"collection": {
8+
"type": "string",
9+
"description": "Collection/table name"
10+
},
11+
"stages": {
12+
"type": "array",
13+
"items": {
14+
"type": "object",
15+
"properties": {
16+
"operator": {
17+
"type": "string",
18+
"description": "Aggregation operator (e.g., $match, $group, $sort)"
19+
},
20+
"options": {
21+
"type": "object",
22+
"additionalProperties": {},
23+
"description": "Stage-specific options"
24+
}
25+
},
26+
"required": [
27+
"operator",
28+
"options"
29+
],
30+
"additionalProperties": false
31+
},
32+
"description": "Aggregation pipeline stages"
33+
},
34+
"options": {
35+
"type": "object",
36+
"properties": {
37+
"consistency": {
38+
"type": "string",
39+
"enum": [
40+
"all",
41+
"quorum",
42+
"one",
43+
"local_quorum",
44+
"each_quorum",
45+
"eventual"
46+
],
47+
"description": "Consistency level override"
48+
},
49+
"readFromSecondary": {
50+
"type": "boolean",
51+
"description": "Allow reading from secondary replicas"
52+
},
53+
"projection": {
54+
"type": "object",
55+
"additionalProperties": {
56+
"type": "number",
57+
"enum": [
58+
0,
59+
1
60+
]
61+
},
62+
"description": "Field projection"
63+
},
64+
"timeout": {
65+
"type": "integer",
66+
"exclusiveMinimum": 0,
67+
"description": "Query timeout (ms)"
68+
},
69+
"useCursor": {
70+
"type": "boolean",
71+
"description": "Use cursor instead of loading all results"
72+
},
73+
"batchSize": {
74+
"type": "integer",
75+
"exclusiveMinimum": 0,
76+
"description": "Cursor batch size"
77+
},
78+
"profile": {
79+
"type": "boolean",
80+
"description": "Enable query profiling"
81+
},
82+
"hint": {
83+
"type": "string",
84+
"description": "Index hint for query optimization"
85+
}
86+
},
87+
"additionalProperties": false,
88+
"description": "Query options"
89+
}
90+
},
91+
"required": [
92+
"collection",
93+
"stages"
94+
],
95+
"additionalProperties": false
96+
}
97+
},
98+
"$schema": "http://json-schema.org/draft-07/schema#"
99+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$ref": "#/definitions/AggregationStage",
3+
"definitions": {
4+
"AggregationStage": {
5+
"type": "object",
6+
"properties": {
7+
"operator": {
8+
"type": "string",
9+
"description": "Aggregation operator (e.g., $match, $group, $sort)"
10+
},
11+
"options": {
12+
"type": "object",
13+
"additionalProperties": {},
14+
"description": "Stage-specific options"
15+
}
16+
},
17+
"required": [
18+
"operator",
19+
"options"
20+
],
21+
"additionalProperties": false
22+
}
23+
},
24+
"$schema": "http://json-schema.org/draft-07/schema#"
25+
}

0 commit comments

Comments
 (0)