Skip to content

Commit 60717e1

Browse files
authored
Merge pull request #568 from objectstack-ai/copilot/test-spec-api-implementation
2 parents 86e514e + f80cc1a commit 60717e1

12 files changed

Lines changed: 2001 additions & 129 deletions

File tree

content/docs/guides/client-sdk.mdx

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The `@objectstack/client` is the official TypeScript client for ObjectStack. It
1717
- **Batch Operations**: Efficient bulk create/update/upsert/delete with transaction support
1818
- **Query Builder**: Programmatic query construction with `createQuery()` and `createFilter()`
1919
- **Standardized Errors**: Machine-readable error codes with retry guidance
20+
- **100% Protocol Compliant**: Implements all 13 API namespaces and 95+ methods defined in `@objectstack/spec`
2021

2122
## Installation
2223

@@ -102,6 +103,32 @@ if (discovery.services?.auth?.enabled) {
102103

103104
---
104105

106+
## Protocol Coverage
107+
108+
The `@objectstack/client` SDK aims to implement the ObjectStack API protocol specification. It covers all 13 API namespaces defined in `@objectstack/spec`:
109+
110+
| Namespace | Status | Methods | Purpose |
111+
|:----------|:------:|:--------|:--------|
112+
| **discovery** || 1 | API version & capabilities detection |
113+
| **meta** || 7 | Metadata operations (objects, views, plugins) |
114+
| **data** || 10 | CRUD & query operations |
115+
| **auth** || 5 | Authentication & user management |
116+
| **packages** || 6 | Plugin/package lifecycle management |
117+
| **views** || 5 | UI view definitions |
118+
| **workflow** || 5 | Workflow state transitions |
119+
| **analytics** || 2 | Analytics queries |
120+
| **automation** || 1 | Automation triggers |
121+
| **i18n** || 3 | Internationalization |
122+
| **notifications** || 7 | Push notifications |
123+
| **realtime** || 6 | WebSocket subscriptions |
124+
| **ai** || 4 | AI services (NLQ, chat, insights) |
125+
126+
<Callout type="info">
127+
**Protocol compliance & verification**: See [`CLIENT_SPEC_COMPLIANCE.md`](https://github.com/objectstack-ai/spec/blob/main/packages/client/CLIENT_SPEC_COMPLIANCE.md) for detailed method-by-method verification and [`CLIENT_SERVER_INTEGRATION_TESTS.md`](https://github.com/objectstack-ai/spec/blob/main/packages/client/CLIENT_SERVER_INTEGRATION_TESTS.md) for comprehensive integration test specifications.
128+
</Callout>
129+
130+
---
131+
105132
## API Namespaces
106133

107134
### `client.meta` — Metadata
@@ -206,6 +233,72 @@ await client.packages.disable('plugin-auth');
206233
await client.packages.uninstall('plugin-auth');
207234
```
208235

236+
### Additional Namespaces
237+
238+
The client also provides full implementations for:
239+
240+
```typescript
241+
// Auth — User authentication and session management
242+
await client.auth.login({ email: 'user@example.com', password: 'pass' });
243+
await client.auth.register({ email: 'new@example.com', password: 'pass' });
244+
await client.auth.me();
245+
await client.auth.logout();
246+
await client.auth.refreshToken('refresh-token-string');
247+
248+
// Permissions — Access control checks
249+
await client.permissions.check({ object: 'account', action: 'create' });
250+
await client.permissions.getObjectPermissions('account');
251+
await client.permissions.getEffectivePermissions();
252+
253+
// Workflow — State machine management
254+
await client.workflow.getConfig('approval');
255+
await client.workflow.getState('approval', recordId);
256+
await client.workflow.transition({ object: 'approval', recordId, transition: 'submit' });
257+
await client.workflow.approve({ object: 'approval', recordId });
258+
await client.workflow.reject({ object: 'approval', recordId, reason: 'Incomplete' });
259+
260+
// Realtime — WebSocket subscriptions
261+
await client.realtime.connect({ protocol: 'websocket' });
262+
await client.realtime.subscribe({ channel: 'account', event: 'update' });
263+
await client.realtime.setPresence({ status: 'online' });
264+
await client.realtime.disconnect();
265+
266+
// Notifications — Push notification management
267+
await client.notifications.registerDevice({ token: 'device-token', platform: 'ios' });
268+
await client.notifications.list({ unreadOnly: true });
269+
await client.notifications.markRead(['notif-1', 'notif-2']);
270+
await client.notifications.markAllRead();
271+
272+
// AI — AI-powered features
273+
await client.ai.nlq({ query: 'Show me all active accounts' });
274+
await client.ai.chat({ message: 'Summarize this project', context: projectId });
275+
await client.ai.suggest({ object: 'account', field: 'industry' });
276+
await client.ai.insights({ object: 'sales', recordId: dealId });
277+
278+
// i18n — Internationalization
279+
await client.i18n.getLocales();
280+
await client.i18n.getTranslations('zh-CN');
281+
await client.i18n.getFieldLabels('account', 'zh-CN');
282+
283+
// Automation — Trigger workflows and automations
284+
await client.automation.trigger('send_welcome_email', { userId });
285+
286+
// Storage — File upload and management
287+
await client.storage.upload(fileData, 'user');
288+
await client.storage.getDownloadUrl('file-123');
289+
290+
// Views — UI view management
291+
await client.views.list('account');
292+
await client.views.get('account', viewId);
293+
await client.views.create('account', { name: 'my_view', ... });
294+
await client.views.update('account', viewId, { ... });
295+
await client.views.delete('account', viewId);
296+
```
297+
298+
<Callout type="info">
299+
**Service availability**: Optional services (workflow, ai, etc.) are only available when the corresponding plugin is installed on the server. Always check `client.discovery?.services` to verify service availability before calling these methods.
300+
</Callout>
301+
209302
---
210303

211304
## Query Builder
@@ -329,6 +422,52 @@ function AccountList() {
329422

330423
---
331424

425+
## Testing
426+
427+
The client SDK includes comprehensive unit and integration tests to ensure reliability and protocol compliance.
428+
429+
### Unit Tests
430+
431+
```bash
432+
cd packages/client
433+
pnpm test
434+
```
435+
436+
Unit tests use mocks to verify client behavior without requiring a server.
437+
438+
### Integration Tests
439+
440+
**Note:** Integration tests require a running ObjectStack server. The server is provided by a separate repository and must be set up independently.
441+
442+
```bash
443+
# Prerequisite: Start an ObjectStack server with test data
444+
# For example, using the reference server repository
445+
# Follow the server repository's documentation for local setup
446+
447+
# From this repository, run the integration test script
448+
cd packages/client
449+
pnpm test:integration
450+
```
451+
452+
Integration tests verify end-to-end communication with a live ObjectStack server across all 13 API namespaces.
453+
454+
<Callout type="info">
455+
**Test coverage**: Integration test specifications cover discovery/connection, authentication, metadata operations, CRUD operations (basic, batch, advanced queries), permissions, workflow, realtime, notifications, AI services, i18n, analytics, packages, views, storage, and automation.
456+
</Callout>
457+
458+
---
459+
460+
## Protocol Compliance Documentation
461+
462+
For detailed information about the client's protocol implementation:
463+
464+
- **[Protocol Compliance Matrix](https://github.com/objectstack-ai/spec/blob/main/packages/client/CLIENT_SPEC_COMPLIANCE.md)** — Method-by-method verification of all 95+ API methods across 13 namespaces
465+
- **[Integration Test Specifications](https://github.com/objectstack-ai/spec/blob/main/packages/client/CLIENT_SERVER_INTEGRATION_TESTS.md)** — Comprehensive test cases for client-server communication
466+
- **[Quick Reference Guide](https://github.com/objectstack-ai/spec/blob/main/packages/client/QUICK_REFERENCE.md)** — Developer navigation and API reference
467+
- **[中文合规性报告](https://github.com/objectstack-ai/spec/blob/main/packages/client/CLIENT_SPEC_COMPLIANCE_CN.md)** — Chinese language compliance verification report
468+
469+
---
470+
332471
## Next Steps
333472

334473
<Cards>

packages/adapters/nextjs/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
},
1010
"peerDependencies": {
1111
"@objectstack/runtime": "workspace:*",
12-
"next": "^14.0.0",
12+
"next": "^15.0.8",
1313
"react": "^19.2.4",
14-
"react-dom": "^18.3.1"
14+
"react-dom": "^19.2.4"
1515
},
1616
"devDependencies": {
1717
"@objectstack/runtime": "workspace:*",
18-
"next": "^14.0.0",
18+
"next": "^15.0.8",
1919
"react": "^19.2.4",
20-
"react-dom": "^18.3.1",
20+
"react-dom": "^19.2.4",
2121
"typescript": "^5.0.0"
2222
}
2323
}

0 commit comments

Comments
 (0)