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
60 changes: 58 additions & 2 deletions content/docs/references/api/websocket.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ description: Websocket protocol schemas
## TypeScript Usage

```typescript
import { AckMessageSchema, CursorMessageSchema, CursorPositionSchema, DocumentStateSchema, EditMessageSchema, EditOperationSchema, EditOperationTypeSchema, ErrorMessageSchema, EventFilterSchema, EventFilterConditionSchema, EventMessageSchema, EventPatternSchema, EventSubscriptionSchema, FilterOperatorSchema, PingMessageSchema, PongMessageSchema, PresenceMessageSchema, PresenceStateSchema, PresenceUpdateSchema, SubscribeMessageSchema, UnsubscribeMessageSchema, UnsubscribeRequestSchema, WebSocketConfigSchema, WebSocketMessageSchema, WebSocketMessageTypeSchema, WebSocketPresenceStatusSchema } from '@objectstack/spec/api';
import type { AckMessage, CursorMessage, CursorPosition, DocumentState, EditMessage, EditOperation, EditOperationType, ErrorMessage, EventFilter, EventFilterCondition, EventMessage, EventPattern, EventSubscription, FilterOperator, PingMessage, PongMessage, PresenceMessage, PresenceState, PresenceUpdate, SubscribeMessage, UnsubscribeMessage, UnsubscribeRequest, WebSocketConfig, WebSocketMessage, WebSocketMessageType, WebSocketPresenceStatus } from '@objectstack/spec/api';
import { AckMessageSchema, CursorMessageSchema, CursorPositionSchema, DocumentStateSchema, EditMessageSchema, EditOperationSchema, EditOperationTypeSchema, ErrorMessageSchema, EventFilterSchema, EventFilterConditionSchema, EventMessageSchema, EventPatternSchema, EventSubscriptionSchema, FilterOperatorSchema, PingMessageSchema, PongMessageSchema, PresenceMessageSchema, PresenceStateSchema, PresenceUpdateSchema, SimpleCursorPositionSchema, SimplePresenceStateSchema, SubscribeMessageSchema, UnsubscribeMessageSchema, UnsubscribeRequestSchema, WebSocketConfigSchema, WebSocketEventSchema, WebSocketMessageSchema, WebSocketMessageTypeSchema, WebSocketPresenceStatusSchema, WebSocketServerConfigSchema } from '@objectstack/spec/api';
import type { AckMessage, CursorMessage, CursorPosition, DocumentState, EditMessage, EditOperation, EditOperationType, ErrorMessage, EventFilter, EventFilterCondition, EventMessage, EventPattern, EventSubscription, FilterOperator, PingMessage, PongMessage, PresenceMessage, PresenceState, PresenceUpdate, SimpleCursorPosition, SimplePresenceState, SubscribeMessage, UnsubscribeMessage, UnsubscribeRequest, WebSocketConfig, WebSocketEvent, WebSocketMessage, WebSocketMessageType, WebSocketPresenceStatus, WebSocketServerConfig } from '@objectstack/spec/api';

// Validate data
const result = AckMessageSchema.parse(data);
Expand Down Expand Up @@ -289,6 +289,34 @@ Event pattern (supports wildcards like "record.*" or "*.created")

---

## SimpleCursorPosition

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **userId** | `string` | ✅ | User identifier |
| **recordId** | `string` | ✅ | Record identifier being edited |
| **fieldName** | `string` | ✅ | Field name being edited |
| **position** | `number` | ✅ | Cursor position (character offset from start) |
| **selection** | `object` | optional | Text selection range (if text is selected) |

---

## SimplePresenceState

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **userId** | `string` | ✅ | User identifier |
| **userName** | `string` | ✅ | User display name |
| **status** | `Enum<'online' \| 'away' \| 'offline'>` | ✅ | User presence status |
| **lastSeen** | `number` | ✅ | Unix timestamp of last activity in milliseconds |
| **metadata** | `Record<string, any>` | optional | Additional presence metadata (e.g., current page, custom status) |

---

## SubscribeMessage

### Properties
Expand Down Expand Up @@ -342,6 +370,19 @@ Event pattern (supports wildcards like "record.*" or "*.created")

---

## WebSocketEvent

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **type** | `Enum<'subscribe' \| 'unsubscribe' \| 'data-change' \| 'presence-update' \| 'cursor-update' \| 'error'>` | ✅ | Event type |
| **channel** | `string` | ✅ | Channel identifier (e.g., "record.account.123", "user.456") |
| **payload** | `any` | optional | Event payload data |
| **timestamp** | `number` | ✅ | Unix timestamp in milliseconds |

---

## WebSocketMessage

---
Expand Down Expand Up @@ -372,3 +413,18 @@ Event pattern (supports wildcards like "record.*" or "*.created")
* `busy`
* `offline`

---

## WebSocketServerConfig

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **enabled** | `boolean` | optional | Enable WebSocket server |
| **path** | `string` | optional | WebSocket endpoint path |
| **heartbeatInterval** | `number` | optional | Heartbeat interval in milliseconds |
| **reconnectAttempts** | `number` | optional | Maximum reconnection attempts for clients |
| **presence** | `boolean` | optional | Enable presence tracking |
| **cursorSharing** | `boolean` | optional | Enable collaborative cursor sharing |

21 changes: 19 additions & 2 deletions content/docs/references/permission/permission.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ description: Permission protocol schemas
## TypeScript Usage

```typescript
import { FieldPermissionSchema, ObjectPermissionSchema, PermissionSetSchema } from '@objectstack/spec/permission';
import type { FieldPermission, ObjectPermission, PermissionSet } from '@objectstack/spec/permission';
import { FieldPermissionSchema, ObjectPermissionSchema, PermissionSetSchema, RLSRuleSchema } from '@objectstack/spec/permission';
import type { FieldPermission, ObjectPermission, PermissionSet, RLSRule } from '@objectstack/spec/permission';

// Validate data
const result = FieldPermissionSchema.parse(data);
Expand Down Expand Up @@ -62,4 +62,21 @@ const result = FieldPermissionSchema.parse(data);
| **objects** | `Record<string, object>` | ✅ | Entity permissions |
| **fields** | `Record<string, object>` | optional | Field level security |
| **systemPermissions** | `string[]` | optional | System level capabilities |
| **rls** | `object[]` | optional | Row-level security rules |
| **contextVariables** | `Record<string, any>` | optional | Context variables for RLS evaluation |

---

## RLSRule

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **name** | `string` | ✅ | Rule unique identifier (snake_case) |
| **objectName** | `string` | ✅ | Target object name |
| **operation** | `Enum<'read' \| 'create' \| 'update' \| 'delete'>` | ✅ | Database operation this rule applies to |
| **filter** | `object` | ✅ | Filter condition for row-level access |
| **enabled** | `boolean` | optional | Whether this rule is active |
| **priority** | `number` | optional | Rule evaluation priority (higher = evaluated first) |

53 changes: 53 additions & 0 deletions packages/spec/json-schema/api/SimpleCursorPosition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"$ref": "#/definitions/SimpleCursorPosition",
"definitions": {
"SimpleCursorPosition": {
"type": "object",
"properties": {
"userId": {
"type": "string",
"description": "User identifier"
},
"recordId": {
"type": "string",
"description": "Record identifier being edited"
},
"fieldName": {
"type": "string",
"description": "Field name being edited"
},
"position": {
"type": "number",
"description": "Cursor position (character offset from start)"
},
"selection": {
"type": "object",
"properties": {
"start": {
"type": "number",
"description": "Selection start position"
},
"end": {
"type": "number",
"description": "Selection end position"
}
},
"required": [
"start",
"end"
],
"additionalProperties": false,
"description": "Text selection range (if text is selected)"
}
},
"required": [
"userId",
"recordId",
"fieldName",
"position"
],
"additionalProperties": false
}
},
"$schema": "http://json-schema.org/draft-07/schema#"
}
44 changes: 44 additions & 0 deletions packages/spec/json-schema/api/SimplePresenceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"$ref": "#/definitions/SimplePresenceState",
"definitions": {
"SimplePresenceState": {
"type": "object",
"properties": {
"userId": {
"type": "string",
"description": "User identifier"
},
"userName": {
"type": "string",
"description": "User display name"
},
"status": {
"type": "string",
"enum": [
"online",
"away",
"offline"
],
"description": "User presence status"
},
"lastSeen": {
"type": "number",
"description": "Unix timestamp of last activity in milliseconds"
},
"metadata": {
"type": "object",
"additionalProperties": {},
"description": "Additional presence metadata (e.g., current page, custom status)"
}
},
"required": [
"userId",
"userName",
"status",
"lastSeen"
],
"additionalProperties": false
}
},
"$schema": "http://json-schema.org/draft-07/schema#"
}
40 changes: 40 additions & 0 deletions packages/spec/json-schema/api/WebSocketEvent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"$ref": "#/definitions/WebSocketEvent",
"definitions": {
"WebSocketEvent": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"subscribe",
"unsubscribe",
"data-change",
"presence-update",
"cursor-update",
"error"
],
"description": "Event type"
},
"channel": {
"type": "string",
"description": "Channel identifier (e.g., \"record.account.123\", \"user.456\")"
},
"payload": {
"description": "Event payload data"
},
"timestamp": {
"type": "number",
"description": "Unix timestamp in milliseconds"
}
},
"required": [
"type",
"channel",
"timestamp"
],
"additionalProperties": false
}
},
"$schema": "http://json-schema.org/draft-07/schema#"
}
42 changes: 42 additions & 0 deletions packages/spec/json-schema/api/WebSocketServerConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"$ref": "#/definitions/WebSocketServerConfig",
"definitions": {
"WebSocketServerConfig": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"default": false,
"description": "Enable WebSocket server"
},
"path": {
"type": "string",
"default": "/ws",
"description": "WebSocket endpoint path"
},
"heartbeatInterval": {
"type": "number",
"default": 30000,
"description": "Heartbeat interval in milliseconds"
},
"reconnectAttempts": {
"type": "number",
"default": 5,
"description": "Maximum reconnection attempts for clients"
},
"presence": {
"type": "boolean",
"default": false,
"description": "Enable presence tracking"
},
"cursorSharing": {
"type": "boolean",
"default": false,
"description": "Enable collaborative cursor sharing"
}
},
"additionalProperties": false
}
},
"$schema": "http://json-schema.org/draft-07/schema#"
}
Loading
Loading