|
| 1 | +# @objectstack/client - Quick Reference |
| 2 | + |
| 3 | +This quick reference provides an overview of the compliance verification work and how to use it. |
| 4 | + |
| 5 | +## 📚 Documentation Index |
| 6 | + |
| 7 | +### Compliance & Verification |
| 8 | + |
| 9 | +1. **[CLIENT_SPEC_COMPLIANCE.md](./CLIENT_SPEC_COMPLIANCE.md)** (English) |
| 10 | + - Complete protocol compliance matrix |
| 11 | + - Method-by-method verification for all 95+ API methods |
| 12 | + - Architecture and implementation notes |
| 13 | + - 358 lines of detailed analysis |
| 14 | + |
| 15 | +2. **[CLIENT_SPEC_COMPLIANCE_CN.md](./CLIENT_SPEC_COMPLIANCE_CN.md)** (中文) |
| 16 | + - Chinese language compliance report |
| 17 | + - Summary of key findings |
| 18 | + - Recommendations for next steps |
| 19 | + - 383 lines |
| 20 | + |
| 21 | +### Testing |
| 22 | + |
| 23 | +3. **[CLIENT_SERVER_INTEGRATION_TESTS.md](./CLIENT_SERVER_INTEGRATION_TESTS.md)** |
| 24 | + - Comprehensive test specification for 17 test suites |
| 25 | + - Detailed test cases with code examples |
| 26 | + - Mock server setup guide |
| 27 | + - CI/CD configuration examples |
| 28 | + - 932 lines of test specifications |
| 29 | + |
| 30 | +4. **[tests/integration/README.md](./tests/integration/README.md)** |
| 31 | + - How to run integration tests |
| 32 | + - Environment variables |
| 33 | + - Test structure overview |
| 34 | + |
| 35 | +### Usage |
| 36 | + |
| 37 | +5. **[README.md](./README.md)** |
| 38 | + - Updated with protocol coverage information |
| 39 | + - Complete namespace examples |
| 40 | + - Testing instructions |
| 41 | + - Error handling guide |
| 42 | + |
| 43 | +## ✅ Compliance Status |
| 44 | + |
| 45 | +``` |
| 46 | +✅ 13/13 API Namespaces Implemented (100%) |
| 47 | +✅ 4/4 Core Services (discovery, meta, data, auth) |
| 48 | +✅ 9/9 Optional Services (packages, ui, workflow, analytics, automation, i18n, notifications, realtime, ai) |
| 49 | +✅ 95+ Protocol Methods |
| 50 | +✅ Batch Operations |
| 51 | +✅ ETag Caching |
| 52 | +✅ Error Handling |
| 53 | +``` |
| 54 | + |
| 55 | +## 🧪 Running Tests |
| 56 | + |
| 57 | +### Unit Tests (Existing) |
| 58 | + |
| 59 | +```bash |
| 60 | +cd packages/client |
| 61 | +pnpm test |
| 62 | +``` |
| 63 | + |
| 64 | +Runs existing unit tests: |
| 65 | +- `src/client.test.ts` - Mock-based unit tests |
| 66 | +- `src/client.hono.test.ts` - Hono server integration |
| 67 | +- `src/client.msw.test.ts` - MSW-based tests |
| 68 | + |
| 69 | +### Integration Tests (New) |
| 70 | + |
| 71 | +```bash |
| 72 | +# Terminal 1: Start test server |
| 73 | +cd packages/server |
| 74 | +pnpm dev:test |
| 75 | + |
| 76 | +# Terminal 2: Run integration tests |
| 77 | +cd packages/client |
| 78 | +pnpm test:integration |
| 79 | +``` |
| 80 | + |
| 81 | +Currently available: |
| 82 | +- `tests/integration/01-discovery.test.ts` - Discovery and connection tests |
| 83 | + |
| 84 | +**To be implemented:** Tests 02-17 (see CLIENT_SERVER_INTEGRATION_TESTS.md) |
| 85 | + |
| 86 | +## 📋 API Namespace Reference |
| 87 | + |
| 88 | +Quick reference to all 13 implemented namespaces: |
| 89 | + |
| 90 | +| Namespace | Client API | Example | |
| 91 | +|-----------|-----------|---------| |
| 92 | +| **Discovery** | `client.connect()` | `await client.connect()` | |
| 93 | +| **Metadata** | `client.meta.*` | `await client.meta.getItem('object', 'contact')` | |
| 94 | +| **Data** | `client.data.*` | `await client.data.find('contact', { filters: { status: 'active' } })` | |
| 95 | +| **Auth** | `client.auth.*` | `await client.auth.login({ email, password })` | |
| 96 | +| **Packages** | `client.packages.*` | `await client.packages.install({ packageId })` | |
| 97 | +| **Views** | `client.views.*` | `await client.views.list({ object: 'contact' })` | |
| 98 | +| **Workflow** | `client.workflow.*` | `await client.workflow.transition({ object, recordId, transition })` | |
| 99 | +| **Analytics** | `client.analytics.*` | `await client.analytics.query({ object, aggregations })` | |
| 100 | +| **Automation** | `client.automation.*` | `await client.automation.trigger({ trigger, payload })` | |
| 101 | +| **i18n** | `client.i18n.*` | `await client.i18n.getTranslations('zh-CN')` | |
| 102 | +| **Notifications** | `client.notifications.*` | `await client.notifications.list({ unreadOnly: true })` | |
| 103 | +| **Realtime** | `client.realtime.*` | `await client.realtime.subscribe({ channel, event })` | |
| 104 | +| **AI** | `client.ai.*` | `await client.ai.nlq({ query: 'show active contacts' })` | |
| 105 | +| **Storage** | `client.storage.*` | `await client.storage.upload({ file, object, field })` | |
| 106 | +| **Hub** | `client.hub.*` | `await client.hub.connect()` | |
| 107 | + |
| 108 | +## 🎯 Next Steps for Developers |
| 109 | + |
| 110 | +### Immediate (High Priority) |
| 111 | + |
| 112 | +1. **Implement Remaining Integration Tests** |
| 113 | + - Copy `tests/integration/01-discovery.test.ts` as a template |
| 114 | + - Implement tests 02-17 per specifications in CLIENT_SERVER_INTEGRATION_TESTS.md |
| 115 | + - Focus on core services first (auth, metadata, data) |
| 116 | + |
| 117 | +2. **Set Up Test Server** |
| 118 | + - Create lightweight test server configuration |
| 119 | + - Seed test database with sample data |
| 120 | + - Enable all core and optional services |
| 121 | + |
| 122 | +3. **CI/CD Integration** |
| 123 | + - Create `.github/workflows/client-integration-tests.yml` |
| 124 | + - Automate test server startup |
| 125 | + - Run integration tests on PR and push |
| 126 | + |
| 127 | +### Medium Priority |
| 128 | + |
| 129 | +4. **Error Scenario Testing** |
| 130 | + - Network failures |
| 131 | + - 4xx client errors |
| 132 | + - 5xx server errors |
| 133 | + - Timeout handling |
| 134 | + |
| 135 | +5. **Performance Benchmarks** |
| 136 | + - Request latency measurements |
| 137 | + - Batch operation efficiency |
| 138 | + - Cache hit rates |
| 139 | + |
| 140 | +6. **Documentation Improvements** |
| 141 | + - Add more code examples |
| 142 | + - Create migration guide from v1 |
| 143 | + - Add troubleshooting section |
| 144 | + |
| 145 | +### Long Term |
| 146 | + |
| 147 | +7. **End-to-End Tests** |
| 148 | + - Browser-based tests with Playwright |
| 149 | + - Full user flow testing |
| 150 | + - Multi-browser support |
| 151 | + |
| 152 | +8. **Monitoring** |
| 153 | + - Client-side telemetry |
| 154 | + - Performance monitoring |
| 155 | + - Error tracking integration |
| 156 | + |
| 157 | +## 📖 Reading Order |
| 158 | + |
| 159 | +For new developers reviewing this work: |
| 160 | + |
| 161 | +1. Start with **README.md** - Understand basic usage |
| 162 | +2. Read **CLIENT_SPEC_COMPLIANCE.md** (or CN version) - Understand what's implemented |
| 163 | +3. Review **CLIENT_SERVER_INTEGRATION_TESTS.md** - Understand testing strategy |
| 164 | +4. Explore **tests/integration/** - See example tests |
| 165 | +5. Review spec definitions in `../spec/src/api/` - Understand the source of truth |
| 166 | + |
| 167 | +## 🔗 Related Documentation |
| 168 | + |
| 169 | +- [Spec Protocol Map](../spec/PROTOCOL_MAP.md) - Complete protocol reference |
| 170 | +- [REST API Plugin](../spec/REST_API_PLUGIN.md) - API implementation details |
| 171 | +- [Dispatcher Protocol](../spec/src/api/dispatcher.zod.ts) - Route-to-service mapping |
| 172 | +- [Protocol Schemas](../spec/src/api/protocol.zod.ts) - Request/response schemas |
| 173 | + |
| 174 | +## 🤝 Contributing |
| 175 | + |
| 176 | +When adding new features: |
| 177 | + |
| 178 | +1. ✅ Check if it requires new protocol methods in `@objectstack/spec` |
| 179 | +2. ✅ Update CLIENT_SPEC_COMPLIANCE.md if adding new methods |
| 180 | +3. ✅ Add integration tests in `tests/integration/` |
| 181 | +4. ✅ Update README.md with usage examples |
| 182 | +5. ✅ Ensure all tests pass before submitting PR |
| 183 | + |
| 184 | +## ❓ FAQ |
| 185 | + |
| 186 | +**Q: Why two separate test suites (unit and integration)?** |
| 187 | +A: Unit tests (`src/*.test.ts`) use mocks and run quickly. Integration tests (`tests/integration/*.test.ts`) require a real server and test end-to-end communication. |
| 188 | + |
| 189 | +**Q: Do I need to implement all 17 integration test suites?** |
| 190 | +A: Not immediately. Start with core services (discovery, auth, metadata, data). Others can be added incrementally. |
| 191 | + |
| 192 | +**Q: Can I run integration tests without a server?** |
| 193 | +A: Not yet. You need a running ObjectStack server. We plan to add a mock server option in the future. |
| 194 | + |
| 195 | +**Q: Is the client compatible with older server versions?** |
| 196 | +A: The client implements the latest protocol. Check the discovery response for API version compatibility. |
| 197 | + |
| 198 | +**Q: Where can I find the protocol definitions?** |
| 199 | +A: In `@objectstack/spec` package, primarily in `src/api/protocol.zod.ts` and `src/api/dispatcher.zod.ts`. |
| 200 | + |
| 201 | +--- |
| 202 | + |
| 203 | +**Last Updated:** 2026-02-09 |
| 204 | +**Status:** ✅ Documentation Complete - Ready for Implementation |
| 205 | +**Maintainer:** ObjectStack Team |
0 commit comments