oneie 3.6.7 → 3.6.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/.claude/agents/agent-backend.md +83 -0
  2. package/.claude/agents/agent-designer.md +97 -0
  3. package/.claude/agents/agent-director.md +118 -7
  4. package/.claude/agents/agent-documenter.md +93 -0
  5. package/.claude/agents/agent-frontend.md +96 -0
  6. package/.claude/agents/agent-ops.md +182 -25
  7. package/.claude/agents/agent-problem-solver.md +166 -0
  8. package/.claude/agents/agent-quality.md +127 -0
  9. package/.claude/commands/build.md +293 -0
  10. package/.claude/commands/cascade.md +231 -127
  11. package/.claude/commands/mcp-toggle.md +93 -0
  12. package/.claude/commands/one.md +198 -116
  13. package/.claude/commands/plan.md +394 -80
  14. package/.claude/commands/release.md +41 -19
  15. package/.claude/commands/server.md +2 -0
  16. package/.claude/hooks/root-cleanup.py +75 -0
  17. package/.claude/skills/INDEX.md +523 -0
  18. package/.claude/skills/REGISTRY.md +529 -0
  19. package/.claude/skills/agent-backend-create-mutation.md +319 -0
  20. package/.claude/skills/agent-designer-create-wireframe.md +341 -0
  21. package/.claude/skills/agent-frontend-create-page.md +413 -0
  22. package/.claude/skills/agents/README.md +238 -0
  23. package/dist/clone-web.js +1 -1
  24. package/dist/clone-web.js.map +1 -1
  25. package/folders.yaml +1 -1
  26. package/one/.obsidian/workspace.json +38 -38
  27. package/one/connections/api/queries-reference.md +842 -0
  28. package/one/connections/api-reference.md +1011 -0
  29. package/one/connections/integration-examples.md +875 -0
  30. package/one/connections/integration-guide.md +869 -0
  31. package/one/connections/integration-phase2.md +736 -0
  32. package/one/events/API_ROUTES_FIXES_SUMMARY.md +262 -0
  33. package/one/events/ASTRO-INTEGRATION-EXAMPLES.md +636 -0
  34. package/one/events/BEFORE_AFTER_COMPARISON.md +960 -0
  35. package/one/events/CONNECTIONS_DEMO.md +501 -0
  36. package/one/events/DELIVERABLES.md +432 -0
  37. package/one/events/DEMO-GROUPS-PAGE.md +392 -0
  38. package/one/events/DEMO-TESTING-SUMMARY.md +518 -0
  39. package/one/events/DEMO_COMPONENTS.md +487 -0
  40. package/one/events/DEMO_HOOKS_INDEX.md +334 -0
  41. package/one/events/DEMO_INFRASTRUCTURE.md +905 -0
  42. package/one/events/DEMO_INFRASTRUCTURE_SUMMARY.md +570 -0
  43. package/one/events/DEMO_INTEGRATION_CHECKLIST.md +431 -0
  44. package/one/events/DEMO_QUICK_REFERENCE.md +441 -0
  45. package/one/events/DEMO_SETUP.md +476 -0
  46. package/one/events/EFFECT_TS_API_PATTERN.md +478 -0
  47. package/one/events/GROUPS_DEMO_IMPLEMENTATION.md +414 -0
  48. package/one/events/HOOKS-DEMO.md +441 -0
  49. package/one/events/ONTOLOGY-HOOKS-README.md +700 -0
  50. package/one/events/ONTOLOGY-INTEGRATION-MANIFEST.md +365 -0
  51. package/one/events/QA-CHECKLIST.md +674 -0
  52. package/one/events/QUICK-START-ONTOLOGY.md +408 -0
  53. package/one/events/SEARCH_DEMO_CODE_REFERENCE.md +639 -0
  54. package/one/events/SEARCH_DEMO_DELIVERY.md +415 -0
  55. package/one/events/SEARCH_DEMO_SUMMARY.md +303 -0
  56. package/one/events/SEARCH_DEMO_VISUAL_GUIDE.md +381 -0
  57. package/one/events/TEST-PLAN-INDEX.md +346 -0
  58. package/one/events/TEST-PLAN.md +1417 -0
  59. package/one/events/TESTING-DELIVERY.txt +372 -0
  60. package/one/events/TRANSITIONS-QUICK-START.md +141 -0
  61. package/one/events/TYPESCRIPT_FIXES.md +152 -0
  62. package/one/events/TYPESCRIPT_FIXES_COMPLETE.txt +412 -0
  63. package/one/events/TYPESCRIPT_FIXES_INDEX.md +341 -0
  64. package/one/events/VIEW-TRANSITIONS.md +428 -0
  65. package/one/events/backend-integration-tests.md +606 -0
  66. package/one/events/backend-structure-diagram.txt +393 -0
  67. package/one/events/backend-structure-summary.txt +269 -0
  68. package/one/events/cloudflare-pages-infrastructure-setup.md +264 -0
  69. package/one/events/convex-analysis-index.md +304 -0
  70. package/one/events/convex-structure-analysis.md +700 -0
  71. package/one/events/design-spec-complete.md +208 -0
  72. package/one/events/ontology-test-examples.md +562 -0
  73. package/one/events/phase1-backend-implementation-complete.md +518 -0
  74. package/one/events/test-dashboard.md +345 -0
  75. package/one/events/test-index.md +361 -0
  76. package/one/events/test-report-ontology.md +582 -0
  77. package/one/events/testing-summary.md +344 -0
  78. package/one/groups/features.md +2878 -0
  79. package/one/groups/strategy copy.md +869 -0
  80. package/one/knowledge/backend-api-reference.md +710 -0
  81. package/one/knowledge/documentation-summary.md +285 -0
  82. package/one/knowledge/lessons-learned.md +294 -4
  83. package/one/knowledge/ontology-visual-guide.md +360 -0
  84. package/one/knowledge/ontology.md +9 -17
  85. package/one/things/demo-accessibility-animations.md +999 -0
  86. package/one/things/demo-components.md +1304 -0
  87. package/one/things/demo-design-summary.md +629 -0
  88. package/one/things/demo-design-system.md +919 -0
  89. package/one/things/demo-page-layouts.md +989 -0
  90. package/one/things/designs/accessibility-audit.md +790 -0
  91. package/one/things/designs/component-specifications.md +757 -0
  92. package/one/things/designs/design-overview.md +318 -0
  93. package/one/things/designs/design-tokens.md +414 -0
  94. package/one/things/designs/wireframes-dashboard.md +653 -0
  95. package/one/things/docs/api-requests.md +923 -0
  96. package/one/things/features/0 All Features.md +2 -0
  97. package/one/things/implementation/backend-guide.md +412 -0
  98. package/one/things/plans/2-backend-agnostic-frontend.md +11 -8
  99. package/one/things/plans/ai-elements.md +1259 -0
  100. package/one/things/plans/ai-integration.md +947 -0
  101. package/one/things/plans/ai-sdk.md +761 -0
  102. package/one/things/plans/app.md +1 -1
  103. package/one/things/plans/architecture-summary.md +283 -0
  104. package/one/things/plans/async-ai-agents.md +215 -0
  105. package/one/things/plans/backend-agnostic-frontend.md +11 -6
  106. package/one/things/plans/backend-cleanup-quickstart.md +346 -0
  107. package/one/things/plans/backend-ontology-conformance.md +416 -0
  108. package/one/things/plans/backend-status.md +541 -0
  109. package/one/things/plans/backend-structure.md +799 -0
  110. package/one/things/plans/backend-target-structure.md +438 -0
  111. package/one/things/plans/backend.md +1133 -0
  112. package/one/things/plans/better-auth-any-backend.md +11 -11
  113. package/one/things/plans/cli-updates-required.md +280 -0
  114. package/one/things/plans/complete-step-by-step.md +1302 -0
  115. package/one/things/plans/convex-agents.md +1005 -0
  116. package/one/things/plans/deployment-architecture.md +426 -0
  117. package/one/things/plans/development-plan.md +1220 -0
  118. package/one/things/plans/effect.md +808 -48
  119. package/one/things/plans/integrate-frontend-and-backend.md +579 -0
  120. package/one/things/plans/mcp-clear-context-prompt.md +60 -0
  121. package/one/things/plans/mcp-simple.md +228 -0
  122. package/one/things/plans/one.md +8 -7
  123. package/one/things/plans/ontology-6-dimensions.md +20 -14
  124. package/one/things/plans/quick-wins.md +1273 -0
  125. package/one/things/plans/readme-backend-cleanup.md +361 -0
  126. package/one/things/plans/separate-demo.md +830 -0
  127. package/one/things/plans/separate.md +3 -3
  128. package/one/things/plans/sequence.md +1897 -0
  129. package/one/things/plans/sync-checklist.md +321 -0
  130. package/one/things/plans/unified-implementation-plan.md +3 -3
  131. package/one/things/plans/update-demos.md +513 -0
  132. package/package.json +1 -1
  133. package/.claude/agents/backend-specialist.md +0 -169
  134. package/.claude/agents/designer.md +0 -216
  135. package/.claude/agents/frontend-specialist.md +0 -236
  136. package/.claude/commands/done.md +0 -35
  137. package/.claude/commands/infer.md +0 -138
  138. package/.claude/commands/next.md +0 -53
  139. package/.claude/commands/one copy.md +0 -565
  140. package/.claude/commands/one-template.md +0 -106
  141. package/.claude/commands/one-v1.md +0 -609
  142. package/.claude/hooks/__pycache__/knowledge-post.cpython-313.pyc +0 -0
  143. package/.claude/hooks/__pycache__/knowledge-pre.cpython-313.pyc +0 -0
  144. package/.claude/hooks/__pycache__/todo.cpython-313.pyc +0 -0
  145. package/one/groups/nine-padel-customers.md +0 -138
  146. package/one/groups/nine-padel-data-structure.md +0 -167
  147. package/one/groups/nine-padel-ontology-specification.md +0 -359
  148. package/one/groups/nine-padel-ontology.md +0 -143
  149. package/one/groups/nine-padel-strategy.md +0 -234
  150. package/one/groups/nine-padel.md +0 -211
  151. package/one/groups/nine-padle-contents.baked.md +0 -1252
  152. package/one/groups/nine-padle-contents.md +0 -6
  153. package/one/things/features/1-1-agent-prompts/design.md +0 -470
  154. package/one/things/features/1-1-agent-prompts/tests.md +0 -264
  155. package/one/things/features/1-2-yaml-orchestrator/design.md +0 -497
  156. package/one/things/features/1-2-yaml-orchestrator/tests.md +0 -227
  157. package/one/things/features/1-3-event-coordination/design.md +0 -544
  158. package/one/things/features/1-3-event-coordination/tests.md +0 -223
  159. package/one/things/features/1-4-knowledge-management/design.md +0 -609
  160. package/one/things/features/1-4-knowledge-management/tests.md +0 -195
  161. package/one/things/features/1-5-quality-loops/design.md +0 -797
  162. package/one/things/features/1-5-quality-loops/tests.md +0 -212
  163. package/one/things/features/1-6-numbering-structure/design.md +0 -610
  164. package/one/things/features/1-6-numbering-structure/tests.md +0 -213
  165. package/one/things/features/dataprovider-interface/1-tests.md +0 -1522
@@ -0,0 +1,869 @@
1
+ # ONE Platform Integration Guide
2
+
3
+ **Version:** 1.0.0
4
+ **Created:** 2025-01-25
5
+ **Purpose:** How to integrate external applications with ONE Platform
6
+
7
+ ---
8
+
9
+ ## Overview
10
+
11
+ ONE Platform provides a complete API for external integrations. This guide shows you how to:
12
+
13
+ 1. **Authenticate** your application
14
+ 2. **Connect** to the 6-dimension ontology
15
+ 3. **Build** multi-tenant features
16
+ 4. **Handle** rate limiting and errors
17
+ 5. **Deploy** production-ready integrations
18
+
19
+ ---
20
+
21
+ ## Quick Start (5 Minutes)
22
+
23
+ ### Step 1: Install Dependencies
24
+
25
+ ```bash
26
+ npm install convex @better-auth/client
27
+ ```
28
+
29
+ ### Step 2: Initialize Convex Client
30
+
31
+ ```typescript
32
+ // lib/convex.ts
33
+ import { ConvexHttpClient } from "convex/browser";
34
+
35
+ export const convex = new ConvexHttpClient(
36
+ process.env.NEXT_PUBLIC_CONVEX_URL!
37
+ );
38
+ ```
39
+
40
+ ### Step 3: Authenticate
41
+
42
+ ```typescript
43
+ // lib/auth.ts
44
+ import { createAuthClient } from "@better-auth/client";
45
+
46
+ export const auth = createAuthClient({
47
+ baseURL: process.env.NEXT_PUBLIC_AUTH_URL!
48
+ });
49
+
50
+ // Sign in
51
+ await auth.signIn.email({
52
+ email: "user@example.com",
53
+ password: "password123"
54
+ });
55
+ ```
56
+
57
+ ### Step 4: Query Data
58
+
59
+ ```typescript
60
+ import { convex } from "./lib/convex";
61
+ import { api } from "@/convex/_generated/api";
62
+
63
+ // Get your group
64
+ const group = await convex.query(api.queries.groups.getBySlug, {
65
+ slug: "my-org"
66
+ });
67
+
68
+ // List entities
69
+ const entities = await convex.query(api.queries.entities.list, {
70
+ groupId: group._id,
71
+ type: "course",
72
+ status: "published"
73
+ });
74
+ ```
75
+
76
+ ### Step 5: Create Data
77
+
78
+ ```typescript
79
+ // Create new entity
80
+ const courseId = await convex.mutation(api.mutations.entities.create, {
81
+ groupId: group._id,
82
+ type: "course",
83
+ name: "TypeScript Fundamentals",
84
+ properties: {
85
+ description: "Learn TypeScript from scratch",
86
+ price: 99,
87
+ duration: 40
88
+ },
89
+ status: "published"
90
+ });
91
+ ```
92
+
93
+ **Done!** You've integrated with ONE Platform in 5 minutes.
94
+
95
+ ---
96
+
97
+ ## Authentication Methods
98
+
99
+ ### 1. Email/Password
100
+
101
+ ```typescript
102
+ import { auth } from "./lib/auth";
103
+
104
+ // Sign up
105
+ await auth.signUp.email({
106
+ email: "user@example.com",
107
+ password: "secure_password",
108
+ name: "John Doe"
109
+ });
110
+
111
+ // Sign in
112
+ await auth.signIn.email({
113
+ email: "user@example.com",
114
+ password: "secure_password"
115
+ });
116
+
117
+ // Sign out
118
+ await auth.signOut();
119
+ ```
120
+
121
+ ---
122
+
123
+ ### 2. OAuth (GitHub, Google)
124
+
125
+ ```typescript
126
+ // Redirect to OAuth provider
127
+ await auth.signIn.social({
128
+ provider: "github",
129
+ callbackURL: "/auth/callback"
130
+ });
131
+
132
+ // Handle callback
133
+ await auth.handleCallback();
134
+ ```
135
+
136
+ **Supported Providers:**
137
+ - GitHub
138
+ - Google
139
+ - More providers coming soon
140
+
141
+ ---
142
+
143
+ ### 3. Magic Links
144
+
145
+ ```typescript
146
+ // Request magic link
147
+ await auth.signIn.magicLink({
148
+ email: "user@example.com"
149
+ });
150
+
151
+ // User clicks link in email, automatically signs in
152
+ ```
153
+
154
+ **Use Case:** Passwordless authentication, better UX
155
+
156
+ ---
157
+
158
+ ### 4. API Keys (Server-Side)
159
+
160
+ ```typescript
161
+ // Generate API key (one-time, save securely)
162
+ const apiKey = await convex.mutation(api.mutations.apiKeys.create, {
163
+ groupId,
164
+ name: "Production API Key",
165
+ permissions: ["read", "write"]
166
+ });
167
+
168
+ // Use API key for authentication
169
+ const convex = new ConvexHttpClient(
170
+ process.env.CONVEX_URL,
171
+ {
172
+ headers: {
173
+ "Authorization": `Bearer ${process.env.API_KEY}`
174
+ }
175
+ }
176
+ );
177
+ ```
178
+
179
+ **Use Case:** Server-to-server integrations, CI/CD pipelines
180
+
181
+ ---
182
+
183
+ ## Multi-Tenancy Best Practices
184
+
185
+ ### Rule 1: Always Scope to GroupId
186
+
187
+ ```typescript
188
+ // ✅ CORRECT - Scoped to group
189
+ const entities = await convex.query(api.queries.entities.list, {
190
+ groupId: currentGroup._id,
191
+ type: "course"
192
+ });
193
+
194
+ // ❌ WRONG - Missing groupId (security risk!)
195
+ const entities = await convex.query(api.queries.entities.listAll);
196
+ ```
197
+
198
+ **Why:** GroupId provides perfect data isolation between organizations.
199
+
200
+ ---
201
+
202
+ ### Rule 2: Validate Group Access
203
+
204
+ ```typescript
205
+ // ✅ CORRECT - Validate entity belongs to expected group
206
+ const entity = await convex.query(api.queries.entities.getById, {
207
+ entityId: courseId,
208
+ groupId: currentGroup._id // Security check
209
+ });
210
+
211
+ if (!entity) {
212
+ throw new Error("Entity not found in your organization");
213
+ }
214
+ ```
215
+
216
+ **Why:** Prevents cross-tenant data leakage.
217
+
218
+ ---
219
+
220
+ ### Rule 3: Use Hierarchical Groups
221
+
222
+ ```typescript
223
+ // Create organization (top-level)
224
+ const orgId = await convex.mutation(api.mutations.groups.create, {
225
+ slug: "acme-corp",
226
+ name: "Acme Corporation",
227
+ type: "organization",
228
+ settings: {
229
+ visibility: "private",
230
+ joinPolicy: "invite_only",
231
+ plan: "enterprise"
232
+ }
233
+ });
234
+
235
+ // Create department (nested)
236
+ const engineeringId = await convex.mutation(api.mutations.groups.create, {
237
+ slug: "engineering",
238
+ name: "Engineering",
239
+ type: "community",
240
+ parentGroupId: orgId // Nested under org
241
+ });
242
+
243
+ // Create team (nested under department)
244
+ const backendId = await convex.mutation(api.mutations.groups.create, {
245
+ slug: "backend",
246
+ name: "Backend Team",
247
+ type: "community",
248
+ parentGroupId: engineeringId // Nested under engineering
249
+ });
250
+
251
+ // Query all entities in org + subgroups
252
+ const allEntities = await convex.query(
253
+ api.queries.groups.getEntitiesInHierarchy,
254
+ {
255
+ rootGroupId: orgId,
256
+ entityType: "project"
257
+ }
258
+ );
259
+ ```
260
+
261
+ **Use Case:** Organizations → Departments → Teams → Projects
262
+
263
+ ---
264
+
265
+ ## Working with the 6-Dimension Ontology
266
+
267
+ ### Dimension 1: Groups
268
+
269
+ **What:** Multi-tenant isolation boundary with hierarchical nesting
270
+
271
+ **Types:**
272
+ - `friend_circle` - Personal friend groups
273
+ - `business` - Small businesses
274
+ - `community` - Communities
275
+ - `dao` - Decentralized organizations
276
+ - `government` - Government agencies
277
+ - `organization` - Enterprises
278
+
279
+ **Example:**
280
+ ```typescript
281
+ const group = await convex.mutation(api.mutations.groups.create, {
282
+ slug: "my-org",
283
+ name: "My Organization",
284
+ type: "business",
285
+ settings: {
286
+ visibility: "private",
287
+ joinPolicy: "invite_only",
288
+ plan: "pro"
289
+ }
290
+ });
291
+ ```
292
+
293
+ ---
294
+
295
+ ### Dimension 3: Things (Entities)
296
+
297
+ **What:** All nouns in the system
298
+
299
+ **Example Types:**
300
+ - `user` - Platform users
301
+ - `course` - Educational courses
302
+ - `lesson` - Course lessons
303
+ - `project` - Portfolio projects
304
+ - `blog_post` - Blog articles
305
+ - `token` - Digital tokens
306
+ - `agent` - AI agents
307
+
308
+ **Example:**
309
+ ```typescript
310
+ const courseId = await convex.mutation(api.mutations.entities.create, {
311
+ groupId,
312
+ type: "course",
313
+ name: "TypeScript Fundamentals",
314
+ properties: {
315
+ description: "Learn TypeScript",
316
+ price: 99,
317
+ duration: 40,
318
+ instructor: "Jane Doe"
319
+ },
320
+ status: "published"
321
+ });
322
+ ```
323
+
324
+ ---
325
+
326
+ ### Dimension 4: Connections
327
+
328
+ **What:** Relationships between entities
329
+
330
+ **Example Types:**
331
+ - `owns` - Ownership
332
+ - `enrolled_in` - Course enrollment
333
+ - `created` - Authorship
334
+ - `tagged_with` - Categorization
335
+ - `member_of` - Group membership
336
+
337
+ **Example:**
338
+ ```typescript
339
+ // Student enrolls in course
340
+ const connectionId = await convex.mutation(api.mutations.connections.create, {
341
+ groupId,
342
+ fromEntityId: studentId,
343
+ toEntityId: courseId,
344
+ relationshipType: "enrolled_in",
345
+ metadata: {
346
+ enrolledAt: Date.now(),
347
+ progress: 0
348
+ }
349
+ });
350
+
351
+ // Query enrolled courses
352
+ const enrollments = await convex.query(api.queries.connections.list, {
353
+ groupId,
354
+ fromEntityId: studentId,
355
+ relationshipType: "enrolled_in"
356
+ });
357
+ ```
358
+
359
+ ---
360
+
361
+ ### Dimension 5: Events
362
+
363
+ **What:** Audit trail of all actions
364
+
365
+ **Example Types:**
366
+ - `thing_created` - Entity created
367
+ - `thing_updated` - Entity updated
368
+ - `thing_deleted` - Entity deleted
369
+ - `user_logged_in` - User logged in
370
+ - `payment_processed` - Payment completed
371
+
372
+ **Example:**
373
+ ```typescript
374
+ // Events are automatically logged by mutations
375
+ await convex.mutation(api.mutations.entities.create, {
376
+ groupId,
377
+ type: "course",
378
+ name: "TypeScript Fundamentals"
379
+ });
380
+ // Automatically creates "thing_created" event
381
+
382
+ // Query event timeline
383
+ const timeline = await convex.query(api.queries.events.list, {
384
+ groupId,
385
+ limit: 20
386
+ });
387
+ ```
388
+
389
+ **Use Case:** Complete audit trail, activity feeds, compliance
390
+
391
+ ---
392
+
393
+ ### Dimension 6: Knowledge
394
+
395
+ **What:** RAG (Retrieval-Augmented Generation) for AI features
396
+
397
+ **Example:**
398
+ ```typescript
399
+ // Add knowledge
400
+ const knowledgeId = await convex.mutation(api.mutations.knowledge.add, {
401
+ groupId,
402
+ text: "TypeScript is a typed superset of JavaScript",
403
+ labels: ["typescript", "programming", "education"],
404
+ sourceThingId: courseId
405
+ });
406
+
407
+ // Semantic search
408
+ const results = await convex.query(api.queries.knowledge.search, {
409
+ groupId,
410
+ query: "What is TypeScript?",
411
+ limit: 5
412
+ });
413
+ ```
414
+
415
+ **Use Case:** AI chatbots, semantic search, recommendations
416
+
417
+ ---
418
+
419
+ ## Real-Time Subscriptions
420
+
421
+ ONE Platform provides real-time updates via Convex subscriptions.
422
+
423
+ ### React Example
424
+
425
+ ```typescript
426
+ import { useQuery, useMutation } from "convex/react";
427
+ import { api } from "@/convex/_generated/api";
428
+
429
+ export function CourseList({ groupId }) {
430
+ // Real-time subscription - updates automatically
431
+ const courses = useQuery(api.queries.entities.list, {
432
+ groupId,
433
+ type: "course",
434
+ status: "published"
435
+ });
436
+
437
+ const createCourse = useMutation(api.mutations.entities.create);
438
+
439
+ if (courses === undefined) {
440
+ return <div>Loading...</div>;
441
+ }
442
+
443
+ return (
444
+ <div>
445
+ {courses.map(course => (
446
+ <div key={course._id}>{course.name}</div>
447
+ ))}
448
+ <button onClick={() => createCourse({
449
+ groupId,
450
+ type: "course",
451
+ name: "New Course"
452
+ })}>
453
+ Create Course
454
+ </button>
455
+ </div>
456
+ );
457
+ }
458
+ ```
459
+
460
+ **Behavior:**
461
+ - `courses` updates automatically when data changes
462
+ - No polling needed
463
+ - Sub-100ms latency
464
+ - Works globally via Convex edge network
465
+
466
+ ---
467
+
468
+ ### Vanilla JavaScript Example
469
+
470
+ ```typescript
471
+ import { ConvexHttpClient } from "convex/browser";
472
+ import { api } from "@/convex/_generated/api";
473
+
474
+ const convex = new ConvexHttpClient(process.env.CONVEX_URL);
475
+
476
+ // Subscribe to query
477
+ const unsubscribe = convex.subscribe(
478
+ api.queries.entities.list,
479
+ { groupId, type: "course" },
480
+ (courses) => {
481
+ console.log("Courses updated:", courses);
482
+ // Update UI with new data
483
+ }
484
+ );
485
+
486
+ // Later: unsubscribe
487
+ unsubscribe();
488
+ ```
489
+
490
+ ---
491
+
492
+ ## Error Handling
493
+
494
+ ### Handle Common Errors
495
+
496
+ ```typescript
497
+ try {
498
+ const entity = await convex.query(api.queries.entities.getById, {
499
+ entityId: courseId,
500
+ groupId
501
+ });
502
+ } catch (error) {
503
+ // Type-safe error handling
504
+ if (error.code === "NOT_FOUND") {
505
+ console.error("Entity not found");
506
+ } else if (error.code === "UNAUTHENTICATED") {
507
+ // Redirect to login
508
+ window.location.href = "/login";
509
+ } else if (error.code === "GROUP_ACCESS_DENIED") {
510
+ console.error("You don't have access to this group");
511
+ } else {
512
+ // Log unexpected errors
513
+ console.error("Unexpected error:", error);
514
+ }
515
+ }
516
+ ```
517
+
518
+ ---
519
+
520
+ ### Retry with Exponential Backoff
521
+
522
+ ```typescript
523
+ async function retryQuery(fn, maxRetries = 3) {
524
+ let lastError;
525
+
526
+ for (let i = 0; i < maxRetries; i++) {
527
+ try {
528
+ return await fn();
529
+ } catch (error) {
530
+ lastError = error;
531
+ const delay = Math.pow(2, i) * 1000; // 1s, 2s, 4s
532
+ await new Promise(resolve => setTimeout(resolve, delay));
533
+ }
534
+ }
535
+
536
+ throw lastError;
537
+ }
538
+
539
+ // Usage
540
+ const courses = await retryQuery(() =>
541
+ convex.query(api.queries.entities.list, { groupId, type: "course" })
542
+ );
543
+ ```
544
+
545
+ ---
546
+
547
+ ## Rate Limiting
548
+
549
+ ### Rate Limit Headers
550
+
551
+ ```typescript
552
+ const response = await fetch("/api/entities", {
553
+ headers: {
554
+ "Authorization": `Bearer ${apiKey}`
555
+ }
556
+ });
557
+
558
+ console.log(response.headers.get("X-RateLimit-Limit")); // 1000
559
+ console.log(response.headers.get("X-RateLimit-Remaining")); // 950
560
+ console.log(response.headers.get("X-RateLimit-Reset")); // 1622547600
561
+ ```
562
+
563
+ ### Handle Rate Limit Errors
564
+
565
+ ```typescript
566
+ try {
567
+ await convex.mutation(api.mutations.entities.create, { /* ... */ });
568
+ } catch (error) {
569
+ if (error.code === "RATE_LIMIT_EXCEEDED") {
570
+ const resetTime = parseInt(error.headers["X-RateLimit-Reset"]);
571
+ const waitSeconds = Math.ceil((resetTime - Date.now()) / 1000);
572
+ console.log(`Rate limit exceeded. Retry in ${waitSeconds} seconds`);
573
+ }
574
+ }
575
+ ```
576
+
577
+ ---
578
+
579
+ ## Pagination
580
+
581
+ ### Cursor-Based Pagination
582
+
583
+ ```typescript
584
+ async function* paginateEntities(groupId, type) {
585
+ let cursor = null;
586
+
587
+ while (true) {
588
+ const response = await convex.query(api.queries.entities.list, {
589
+ groupId,
590
+ type,
591
+ limit: 100,
592
+ cursor
593
+ });
594
+
595
+ yield response.items;
596
+
597
+ if (!response.hasMore) break;
598
+ cursor = response.nextCursor;
599
+ }
600
+ }
601
+
602
+ // Usage
603
+ for await (const batch of paginateEntities(groupId, "course")) {
604
+ console.log("Batch:", batch);
605
+ }
606
+ ```
607
+
608
+ ---
609
+
610
+ ## Webhooks (Coming Soon)
611
+
612
+ Receive real-time notifications when data changes.
613
+
614
+ ### Subscribe to Webhook
615
+
616
+ ```typescript
617
+ const webhook = await convex.mutation(api.mutations.webhooks.create, {
618
+ groupId,
619
+ url: "https://yourapp.com/webhooks/one",
620
+ events: ["thing_created", "thing_updated"],
621
+ secret: "your_webhook_secret"
622
+ });
623
+ ```
624
+
625
+ ### Handle Webhook
626
+
627
+ ```typescript
628
+ // Your webhook endpoint
629
+ app.post("/webhooks/one", async (req, res) => {
630
+ // Verify signature
631
+ const signature = req.headers["x-one-signature"];
632
+ const payload = JSON.stringify(req.body);
633
+ const expected = crypto
634
+ .createHmac("sha256", process.env.WEBHOOK_SECRET)
635
+ .update(payload)
636
+ .digest("hex");
637
+
638
+ if (signature !== expected) {
639
+ return res.status(401).send("Invalid signature");
640
+ }
641
+
642
+ // Process event
643
+ const { event, data } = req.body;
644
+
645
+ if (event === "thing_created") {
646
+ console.log("New entity created:", data);
647
+ }
648
+
649
+ res.status(200).send("OK");
650
+ });
651
+ ```
652
+
653
+ ---
654
+
655
+ ## Example Integrations
656
+
657
+ ### 1. Mobile App (React Native)
658
+
659
+ ```typescript
660
+ import { ConvexHttpClient } from "convex/browser";
661
+ import { api } from "@/convex/_generated/api";
662
+
663
+ const convex = new ConvexHttpClient(
664
+ process.env.EXPO_PUBLIC_CONVEX_URL
665
+ );
666
+
667
+ export function CourseScreen({ groupId }) {
668
+ const [courses, setCourses] = useState([]);
669
+
670
+ useEffect(() => {
671
+ const unsubscribe = convex.subscribe(
672
+ api.queries.entities.list,
673
+ { groupId, type: "course" },
674
+ (data) => setCourses(data)
675
+ );
676
+
677
+ return () => unsubscribe();
678
+ }, [groupId]);
679
+
680
+ return (
681
+ <FlatList
682
+ data={courses}
683
+ keyExtractor={item => item._id}
684
+ renderItem={({ item }) => <CourseCard course={item} />}
685
+ />
686
+ );
687
+ }
688
+ ```
689
+
690
+ ---
691
+
692
+ ### 2. Zapier Integration
693
+
694
+ ```typescript
695
+ // Zapier trigger: New Course Created
696
+ const newCourse = {
697
+ key: "new_course",
698
+ noun: "Course",
699
+ display: {
700
+ label: "New Course",
701
+ description: "Triggers when a new course is created"
702
+ },
703
+ operation: {
704
+ perform: async (z, bundle) => {
705
+ const courses = await z.request({
706
+ url: `${bundle.authData.baseUrl}/api/entities`,
707
+ params: {
708
+ groupId: bundle.authData.groupId,
709
+ type: "course",
710
+ limit: 100
711
+ }
712
+ });
713
+
714
+ return courses.json();
715
+ }
716
+ }
717
+ };
718
+ ```
719
+
720
+ ---
721
+
722
+ ### 3. N8N Workflow
723
+
724
+ ```json
725
+ {
726
+ "nodes": [
727
+ {
728
+ "name": "ONE Trigger",
729
+ "type": "n8n-nodes-base.httpRequest",
730
+ "parameters": {
731
+ "url": "={{$env.ONE_API_URL}}/api/entities",
732
+ "authentication": "genericCredentialType",
733
+ "method": "GET",
734
+ "queryParameters": {
735
+ "groupId": "={{$env.ONE_GROUP_ID}}",
736
+ "type": "course",
737
+ "status": "published"
738
+ }
739
+ }
740
+ },
741
+ {
742
+ "name": "Process Courses",
743
+ "type": "n8n-nodes-base.function",
744
+ "parameters": {
745
+ "functionCode": "return items.map(item => ({\n json: {\n courseName: item.json.name,\n price: item.json.properties.price\n }\n}));"
746
+ }
747
+ }
748
+ ]
749
+ }
750
+ ```
751
+
752
+ ---
753
+
754
+ ## Performance Optimization
755
+
756
+ ### 1. Use Indexes
757
+
758
+ ```typescript
759
+ // ✅ FAST - Uses group_type index
760
+ const courses = await convex.query(api.queries.entities.list, {
761
+ groupId,
762
+ type: "course"
763
+ });
764
+
765
+ // ❌ SLOW - No index, filters in memory
766
+ const courses = (await convex.query(api.queries.entities.list, { groupId }))
767
+ .filter(e => e.type === "course");
768
+ ```
769
+
770
+ ---
771
+
772
+ ### 2. Batch Requests
773
+
774
+ ```typescript
775
+ // ✅ FAST - Parallel requests
776
+ const [courses, projects, users] = await Promise.all([
777
+ convex.query(api.queries.entities.list, { groupId, type: "course" }),
778
+ convex.query(api.queries.entities.list, { groupId, type: "project" }),
779
+ convex.query(api.queries.entities.list, { groupId, type: "user" })
780
+ ]);
781
+
782
+ // ❌ SLOW - Sequential requests
783
+ const courses = await convex.query(api.queries.entities.list, { groupId, type: "course" });
784
+ const projects = await convex.query(api.queries.entities.list, { groupId, type: "project" });
785
+ const users = await convex.query(api.queries.entities.list, { groupId, type: "user" });
786
+ ```
787
+
788
+ ---
789
+
790
+ ### 3. Cache Aggressively
791
+
792
+ ```typescript
793
+ // Client-side caching
794
+ const cache = new Map();
795
+
796
+ async function getCachedEntity(entityId) {
797
+ if (cache.has(entityId)) {
798
+ return cache.get(entityId);
799
+ }
800
+
801
+ const entity = await convex.query(api.queries.entities.getById, { entityId });
802
+ cache.set(entityId, entity);
803
+
804
+ // Invalidate after 5 minutes
805
+ setTimeout(() => cache.delete(entityId), 5 * 60 * 1000);
806
+
807
+ return entity;
808
+ }
809
+ ```
810
+
811
+ ---
812
+
813
+ ## Security Best Practices
814
+
815
+ ### 1. Never Expose API Keys
816
+
817
+ ```typescript
818
+ // ✅ CORRECT - Server-side only
819
+ // server.ts
820
+ const apiKey = process.env.ONE_API_KEY;
821
+
822
+ // ❌ WRONG - Exposed to client
823
+ // client.ts
824
+ const apiKey = "pk_live_12345"; // Never hardcode!
825
+ ```
826
+
827
+ ---
828
+
829
+ ### 2. Validate Input
830
+
831
+ ```typescript
832
+ // ✅ CORRECT - Validate before mutation
833
+ function validateCourse(data) {
834
+ if (!data.name || data.name.length < 3) {
835
+ throw new Error("Course name must be at least 3 characters");
836
+ }
837
+ if (data.properties?.price < 0) {
838
+ throw new Error("Price cannot be negative");
839
+ }
840
+ }
841
+
842
+ validateCourse(courseData);
843
+ await convex.mutation(api.mutations.entities.create, courseData);
844
+ ```
845
+
846
+ ---
847
+
848
+ ### 3. Use HTTPS Only
849
+
850
+ ```typescript
851
+ // ✅ CORRECT
852
+ const convex = new ConvexHttpClient("https://your-app.convex.cloud");
853
+
854
+ // ❌ WRONG - Never use HTTP in production
855
+ const convex = new ConvexHttpClient("http://your-app.convex.cloud");
856
+ ```
857
+
858
+ ---
859
+
860
+ ## Support
861
+
862
+ **Documentation:** https://one.ie/docs
863
+ **API Reference:** /one/connections/api-reference.md
864
+ **Community:** https://discord.gg/one-platform
865
+ **Email:** support@one.ie
866
+
867
+ ---
868
+
869
+ **Built for seamless integration and infinite scale.**