-
-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathupdated_openapi_section.txt
More file actions
318 lines (275 loc) · 8.61 KB
/
updated_openapi_section.txt
File metadata and controls
318 lines (275 loc) · 8.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
## 🔄 Real-time & Communication Features
### WebSocket Integration
Daptin provides real-time capabilities through WebSocket connections at `/live`.
**Connection Setup:**
~~~javascript
// WebSocket authentication via query parameter
const token = 'YOUR_JWT_TOKEN';
const ws = new WebSocket(`ws://localhost:6336/live?token=${token}`);
ws.onopen = () => console.log('Connected to Daptin real-time server');
ws.onmessage = (event) => console.log('Received:', JSON.parse(event.data));
~~~
**Supported Methods:**
- `subscribe` - Subscribe to topics with optional filters
- `unsubscribe` - Unsubscribe from topics
- `list-topicName` - List all available topics
- `create-topicName` - Create custom topics
- `destroy-topicName` - Remove custom topics
- `new-message` - Publish messages to topics
**WebSocket Message Format:**
~~~json
{
"method": "subscribe",
"attributes": {
"topicName": "user_account,document",
"filters": {
"EventType": "create|update|delete"
}
}
}
~~~
**Pub/Sub Pattern:**
- System topics: One per database table (automatic)
- Custom topics: User-created for custom messaging
- Permission-aware: Events filtered based on user permissions
- Distributed: Uses Olric for cluster-wide messaging
**Real-time Event Example:**
~~~json
{
"EventData": {
"__type": "user_account",
"email": "user@example.com",
"reference_id": "uuid-here",
"created_at": "2024-01-15T09:30:00Z"
},
"MessageSource": "database",
"EventType": "create",
"ObjectType": "user_account"
}
~~~
### YJS Collaborative Editing
Real-time document collaboration powered by YJS protocol.
**Configuration:**
~~~bash
# Check YJS status
curl -H "Authorization: Bearer TOKEN" http://localhost:6336/_config | grep yjs
# Returns: "yjs.enabled": "true", "yjs.storage.path": "./storage/yjs-documents"
~~~
**YJS WebSocket Connection:**
~~~javascript
// Connect to YJS document collaboration (token in URL)
const token = 'YOUR_JWT_TOKEN';
const yjsProvider = new WebsocketProvider(
`ws://localhost:6336/live/document/REFERENCE_ID/content/yjs?token=${token}`,
'document-room',
ydoc,
{
awareness: {
user: {
name: 'User Name',
color: '#ff0000'
}
}
}
);
~~~
**YJS Endpoints:**
- **Document Collaboration**: `/live/{typename}/{referenceId}/{columnName}/yjs`
- **Direct YJS**: `/yjs/{documentName}`
- **Automatic**: Any file-type column gets YJS endpoints
**Supported File Types for Collaboration:**
- `file.document` - Rich text documents
- `file.diagram` - Mermaid/diagram files
- `file.spreadsheet` - Spreadsheet collaboration
- `file.*` - Any file type column
**Example: Create Collaborative Document:**
~~~bash
curl -X POST http://localhost:6336/api/document \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-d '{
"data": {
"type": "document",
"attributes": {
"title": "Collaborative Doc",
"content": [{
"name": "doc.yjs",
"type": "x-crdt/yjs",
"contents": "BASE64_ENCODED_YJS_STATE"
}]
}
}
}'
~~~
### Live Data Subscription
Subscribe to real-time changes across all entities:
~~~bash
# WebSocket message to subscribe to user account changes
{
"method": "subscribe",
"attributes": {
"topicName": "user_account",
"filters": {"EventType": "update"}
}
}
~~~
## 📧 Communication Systems
### SMTP Email Server
Built-in email server with full SMTP/IMAP support.
**Configuration:**
~~~bash
# Enable SMTP server
curl -X PUT http://localhost:6336/_config/backend/smtp.enable \
-H "Authorization: Bearer TOKEN" \
-d '"true"'
~~~
**Create Mail Server:**
~~~bash
curl -X POST http://localhost:6336/api/mail_server \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/vnd.api+json" \
-d '{
"data": {
"type": "mail_server",
"attributes": {
"hostname": "smtp.yourdomain.com",
"is_enabled": true,
"listen_interface": "0.0.0.0:465",
"max_size": 10485760,
"max_clients": 100,
"always_on_tls": true,
"authentication_required": true
}
}
}'
~~~
**Send Email:**
~~~bash
curl -X POST http://localhost:6336/action/world/mail.send \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-d '{
"attributes": {
"from": "sender@yourdomain.com",
"to": ["recipient@example.com"],
"subject": "Test Email",
"body": "This is a test email sent via Daptin SMTP"
}
}'
~~~
**Email Features:**
- TLS/SSL with automatic certificate management
- DKIM signing for all outgoing emails
- SPF verification for incoming emails
- Spam scoring and filtering
- Full IMAP support for email retrieval
- AWS SES integration available
### CalDAV Calendar Sync
Synchronize calendars and contacts via CalDAV/CardDAV protocols.
**Configuration:**
~~~bash
# Enable CalDAV server
curl -X PUT http://localhost:6336/_config/backend/caldav.enable \
-H "Authorization: Bearer TOKEN" \
-d '"true"'
~~~
**CalDAV Endpoints:**
- **Calendar**: `/caldav/*` - Calendar synchronization
- **Contacts**: `/carddav/*` - Contact synchronization
- **Authentication**: Basic auth with Daptin credentials
**Client Configuration:**
- **Server URL**: `http://localhost:6336/caldav/`
- **Username**: Your Daptin email
- **Password**: Your Daptin password
- **Protocol**: CalDAV for calendars, CardDAV for contacts
### FTP File Transfer
Built-in FTP server for file transfer operations.
**Configuration:**
~~~bash
# Enable FTP server
curl -X PUT http://localhost:6336/_config/backend/ftp.enable \
-H "Authorization: Bearer TOKEN" \
-d '"true"'
~~~
**FTP Features:**
- Multi-site support with subsite isolation
- Cloud storage backend integration
- User authentication via Daptin credentials
- TLS support for secure transfers
- Site-specific FTP access control
## 📰 Feed System
### RSS/Atom Feed Generation
Automatic feed generation for any entity.
**Create Feed:**
~~~bash
curl -X POST http://localhost:6336/api/feed \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-d '{
"data": {
"type": "feed",
"attributes": {
"feed_name": "blog-posts",
"table_name": "blog_post",
"title": "Blog RSS Feed",
"description": "Latest blog posts",
"order": "created_at desc",
"limit": 20
}
}
}'
~~~
**Access Feed:**
~~~bash
# RSS format
curl http://localhost:6336/feed/blog-posts.rss
# Atom format
curl http://localhost:6336/feed/blog-posts.atom
# JSON format
curl http://localhost:6336/feed/blog-posts.json
~~~
**Feed Features:**
- Automatic RSS/Atom/JSON generation
- Customizable field mapping
- Public or authenticated access
- Pagination support
- Multiple format outputs
## 🚀 Advanced Features Summary
### Real-time Capabilities
- **WebSockets**: Pub/sub messaging, live data updates, custom topics
- **YJS Collaboration**: Document co-editing, presence awareness, conflict resolution
- **Event Streaming**: Database change notifications with permission filtering
- **Distributed Messaging**: Olric-based pub/sub for cluster deployments
### Communication Protocols
- **SMTP/IMAP**: Full email server with TLS, DKIM, SPF
- **CalDAV/CardDAV**: Calendar and contact synchronization
- **FTP/FTPS**: Secure file transfer with multi-site support
- **RSS/Atom**: Automatic feed generation from any entity
### Integration Patterns
- **Client SDK Generation**: Auto-generated TypeScript/JavaScript models
- **GraphQL Support**: Optional GraphQL API layer
- **External Storage**: S3, Google Cloud, Azure blob integration
- **Authentication**: JWT, OAuth2, Basic Auth, API keys
### Developer Experience
- **Self-Discovery**: All features discoverable via API
- **Progressive Complexity**: Simple CRUD to advanced workflows
- **Hot Configuration**: Most settings changeable without restart
- **Comprehensive Logging**: Detailed logs for debugging
## 📚 Learning Resources
### Quick References
- **Entity Discovery**: `GET /api/world`
- **Action Discovery**: `GET /api/action`
- **Configuration**: `GET /_config` (admin only)
- **Statistics**: `GET /statistics` (public)
- **Client Models**: `GET /jsmodel/{entity}`
### Common Patterns
1. **Authentication Flow**: signup → signin → become_admin → use API
2. **Entity Creation**: create world entry → restart → use new entity
3. **Real-time Setup**: enable feature → create entity → connect WebSocket
4. **Email Setup**: create mail_server → create mail_account → send emails
### Best Practices
- Always check permissions with `GET /api/user_account`
- Use filter parameters for efficient queries
- Enable only needed features for security
- Monitor rate limits in response headers
- Use appropriate authentication method for use case