oneie 3.6.7 → 3.6.12

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 (168) 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 +264 -32
  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/deploy.md +56 -17
  12. package/.claude/commands/mcp-toggle.md +93 -0
  13. package/.claude/commands/one.md +78 -127
  14. package/.claude/commands/plan.md +394 -80
  15. package/.claude/commands/push.md +75 -14
  16. package/.claude/commands/release.md +89 -25
  17. package/.claude/commands/server.md +2 -0
  18. package/.claude/hooks/__pycache__/todo.cpython-313.pyc +0 -0
  19. package/.claude/hooks/root-cleanup.py +75 -0
  20. package/.claude/skills/INDEX.md +523 -0
  21. package/.claude/skills/REGISTRY.md +529 -0
  22. package/.claude/skills/agent-backend-create-mutation.md +319 -0
  23. package/.claude/skills/agent-designer-create-wireframe.md +341 -0
  24. package/.claude/skills/agent-frontend-create-page.md +413 -0
  25. package/.claude/skills/agents/README.md +238 -0
  26. package/dist/clone-web.js +1 -1
  27. package/dist/clone-web.js.map +1 -1
  28. package/folders.yaml +1 -1
  29. package/one/.obsidian/workspace.json +38 -38
  30. package/one/connections/api/queries-reference.md +842 -0
  31. package/one/connections/api-reference.md +1011 -0
  32. package/one/connections/integration-examples.md +875 -0
  33. package/one/connections/integration-guide.md +869 -0
  34. package/one/connections/integration-phase2.md +736 -0
  35. package/one/events/API_ROUTES_FIXES_SUMMARY.md +262 -0
  36. package/one/events/ASTRO-INTEGRATION-EXAMPLES.md +636 -0
  37. package/one/events/BEFORE_AFTER_COMPARISON.md +960 -0
  38. package/one/events/CONNECTIONS_DEMO.md +501 -0
  39. package/one/events/DELIVERABLES.md +432 -0
  40. package/one/events/DEMO-GROUPS-PAGE.md +392 -0
  41. package/one/events/DEMO-TESTING-SUMMARY.md +518 -0
  42. package/one/events/DEMO_COMPONENTS.md +487 -0
  43. package/one/events/DEMO_HOOKS_INDEX.md +334 -0
  44. package/one/events/DEMO_INFRASTRUCTURE.md +905 -0
  45. package/one/events/DEMO_INFRASTRUCTURE_SUMMARY.md +570 -0
  46. package/one/events/DEMO_INTEGRATION_CHECKLIST.md +431 -0
  47. package/one/events/DEMO_QUICK_REFERENCE.md +441 -0
  48. package/one/events/DEMO_SETUP.md +476 -0
  49. package/one/events/EFFECT_TS_API_PATTERN.md +478 -0
  50. package/one/events/GROUPS_DEMO_IMPLEMENTATION.md +414 -0
  51. package/one/events/HOOKS-DEMO.md +441 -0
  52. package/one/events/ONTOLOGY-HOOKS-README.md +700 -0
  53. package/one/events/ONTOLOGY-INTEGRATION-MANIFEST.md +365 -0
  54. package/one/events/QA-CHECKLIST.md +674 -0
  55. package/one/events/QUICK-START-ONTOLOGY.md +408 -0
  56. package/one/events/SEARCH_DEMO_CODE_REFERENCE.md +639 -0
  57. package/one/events/SEARCH_DEMO_DELIVERY.md +415 -0
  58. package/one/events/SEARCH_DEMO_SUMMARY.md +303 -0
  59. package/one/events/SEARCH_DEMO_VISUAL_GUIDE.md +381 -0
  60. package/one/events/TEST-PLAN-INDEX.md +346 -0
  61. package/one/events/TEST-PLAN.md +1417 -0
  62. package/one/events/TESTING-DELIVERY.txt +372 -0
  63. package/one/events/TRANSITIONS-QUICK-START.md +141 -0
  64. package/one/events/TYPESCRIPT_FIXES.md +152 -0
  65. package/one/events/TYPESCRIPT_FIXES_COMPLETE.txt +412 -0
  66. package/one/events/TYPESCRIPT_FIXES_INDEX.md +341 -0
  67. package/one/events/VIEW-TRANSITIONS.md +428 -0
  68. package/one/events/backend-integration-tests.md +606 -0
  69. package/one/events/backend-structure-diagram.txt +393 -0
  70. package/one/events/backend-structure-summary.txt +269 -0
  71. package/one/events/cloudflare-pages-infrastructure-setup.md +264 -0
  72. package/one/events/convex-analysis-index.md +304 -0
  73. package/one/events/convex-structure-analysis.md +700 -0
  74. package/one/events/design-spec-complete.md +208 -0
  75. package/one/events/ontology-test-examples.md +562 -0
  76. package/one/events/phase1-backend-implementation-complete.md +518 -0
  77. package/one/events/test-dashboard.md +345 -0
  78. package/one/events/test-index.md +361 -0
  79. package/one/events/test-report-ontology.md +582 -0
  80. package/one/events/testing-summary.md +344 -0
  81. package/one/groups/features.md +2878 -0
  82. package/one/groups/strategy copy.md +869 -0
  83. package/one/knowledge/backend-api-reference.md +710 -0
  84. package/one/knowledge/documentation-summary.md +285 -0
  85. package/one/knowledge/lessons-learned.md +294 -4
  86. package/one/knowledge/ontology-visual-guide.md +360 -0
  87. package/one/knowledge/ontology.md +9 -17
  88. package/one/things/demo-accessibility-animations.md +999 -0
  89. package/one/things/demo-components.md +1304 -0
  90. package/one/things/demo-design-summary.md +629 -0
  91. package/one/things/demo-design-system.md +919 -0
  92. package/one/things/demo-page-layouts.md +989 -0
  93. package/one/things/designs/accessibility-audit.md +790 -0
  94. package/one/things/designs/component-specifications.md +757 -0
  95. package/one/things/designs/design-overview.md +318 -0
  96. package/one/things/designs/design-tokens.md +414 -0
  97. package/one/things/designs/wireframes-dashboard.md +653 -0
  98. package/one/things/docs/api-requests.md +923 -0
  99. package/one/things/features/0 All Features.md +2 -0
  100. package/one/things/implementation/backend-guide.md +412 -0
  101. package/one/things/plans/2-backend-agnostic-frontend.md +11 -8
  102. package/one/things/plans/2-sites.md +895 -0
  103. package/one/things/plans/ai-elements.md +1259 -0
  104. package/one/things/plans/ai-integration.md +947 -0
  105. package/one/things/plans/ai-sdk.md +761 -0
  106. package/one/things/plans/app.md +1 -1
  107. package/one/things/plans/architecture-summary.md +283 -0
  108. package/one/things/plans/async-ai-agents.md +215 -0
  109. package/one/things/plans/backend-agnostic-frontend.md +11 -6
  110. package/one/things/plans/backend-cleanup-quickstart.md +346 -0
  111. package/one/things/plans/backend-ontology-conformance.md +416 -0
  112. package/one/things/plans/backend-status.md +541 -0
  113. package/one/things/plans/backend-structure.md +799 -0
  114. package/one/things/plans/backend-target-structure.md +438 -0
  115. package/one/things/plans/backend.md +1133 -0
  116. package/one/things/plans/better-auth-any-backend.md +11 -11
  117. package/one/things/plans/cli-updates-required.md +280 -0
  118. package/one/things/plans/complete-step-by-step.md +1302 -0
  119. package/one/things/plans/convex-agents.md +1005 -0
  120. package/one/things/plans/deployment-architecture.md +426 -0
  121. package/one/things/plans/development-plan.md +1220 -0
  122. package/one/things/plans/effect.md +808 -48
  123. package/one/things/plans/integrate-frontend-and-backend.md +579 -0
  124. package/one/things/plans/mcp-clear-context-prompt.md +60 -0
  125. package/one/things/plans/mcp-simple.md +228 -0
  126. package/one/things/plans/one.md +8 -7
  127. package/one/things/plans/ontology-6-dimensions.md +20 -14
  128. package/one/things/plans/quick-wins.md +1273 -0
  129. package/one/things/plans/readme-backend-cleanup.md +361 -0
  130. package/one/things/plans/separate-demo.md +830 -0
  131. package/one/things/plans/separate.md +3 -3
  132. package/one/things/plans/sequence.md +1897 -0
  133. package/one/things/plans/sync-checklist.md +321 -0
  134. package/one/things/plans/unified-implementation-plan.md +3 -3
  135. package/one/things/plans/update-demos.md +513 -0
  136. package/package.json +1 -1
  137. package/.claude/agents/backend-specialist.md +0 -169
  138. package/.claude/agents/designer.md +0 -216
  139. package/.claude/agents/frontend-specialist.md +0 -236
  140. package/.claude/commands/done.md +0 -35
  141. package/.claude/commands/infer.md +0 -138
  142. package/.claude/commands/next.md +0 -53
  143. package/.claude/commands/one copy.md +0 -565
  144. package/.claude/commands/one-template.md +0 -106
  145. package/.claude/commands/one-v1.md +0 -609
  146. package/.claude/hooks/__pycache__/knowledge-post.cpython-313.pyc +0 -0
  147. package/.claude/hooks/__pycache__/knowledge-pre.cpython-313.pyc +0 -0
  148. package/one/groups/nine-padel-customers.md +0 -138
  149. package/one/groups/nine-padel-data-structure.md +0 -167
  150. package/one/groups/nine-padel-ontology-specification.md +0 -359
  151. package/one/groups/nine-padel-ontology.md +0 -143
  152. package/one/groups/nine-padel-strategy.md +0 -234
  153. package/one/groups/nine-padel.md +0 -211
  154. package/one/groups/nine-padle-contents.baked.md +0 -1252
  155. package/one/groups/nine-padle-contents.md +0 -6
  156. package/one/things/features/1-1-agent-prompts/design.md +0 -470
  157. package/one/things/features/1-1-agent-prompts/tests.md +0 -264
  158. package/one/things/features/1-2-yaml-orchestrator/design.md +0 -497
  159. package/one/things/features/1-2-yaml-orchestrator/tests.md +0 -227
  160. package/one/things/features/1-3-event-coordination/design.md +0 -544
  161. package/one/things/features/1-3-event-coordination/tests.md +0 -223
  162. package/one/things/features/1-4-knowledge-management/design.md +0 -609
  163. package/one/things/features/1-4-knowledge-management/tests.md +0 -195
  164. package/one/things/features/1-5-quality-loops/design.md +0 -797
  165. package/one/things/features/1-5-quality-loops/tests.md +0 -212
  166. package/one/things/features/1-6-numbering-structure/design.md +0 -610
  167. package/one/things/features/1-6-numbering-structure/tests.md +0 -213
  168. package/one/things/features/dataprovider-interface/1-tests.md +0 -1522
@@ -0,0 +1,923 @@
1
+ # API Requests Guide
2
+
3
+ Complete reference for making HTTP requests to the ONE Platform APIs.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Backend API (Convex)](#backend-api-convex)
8
+ - [Frontend API (Astro)](#frontend-api-astro)
9
+ - [Authentication](#authentication)
10
+ - [Common Query Parameters](#common-query-parameters)
11
+ - [Error Handling](#error-handling)
12
+ - [Examples by Use Case](#examples-by-use-case)
13
+
14
+ ---
15
+
16
+ ## Backend API (Convex)
17
+
18
+ **Base URL:** `https://veracious-marlin-319.convex.site`
19
+
20
+ The backend implements the **6-dimension ontology** with HTTP endpoints for managing groups, things, connections, events, and knowledge.
21
+
22
+ ### Health Check
23
+
24
+ ```bash
25
+ curl https://veracious-marlin-319.convex.site/health
26
+ ```
27
+
28
+ **Response:**
29
+ ```json
30
+ {
31
+ "status": "ok",
32
+ "timestamp": 1729878000000,
33
+ "environment": "production"
34
+ }
35
+ ```
36
+
37
+ ---
38
+
39
+ ## Dimension 1: Groups (Multi-tenancy)
40
+
41
+ Groups are hierarchical containers for data isolation. All other dimensions are scoped to a groupId.
42
+
43
+ ### List Groups
44
+
45
+ ```bash
46
+ curl https://veracious-marlin-319.convex.site/groups
47
+ ```
48
+
49
+ **Query Parameters:**
50
+ - `type` - Filter by group type (organization, business, community, dao, friend_circle, government)
51
+ - `status` - Filter by status (active, draft, archived)
52
+ - `limit` - Results per page (default 50, max 1000)
53
+ - `offset` - Pagination offset
54
+
55
+ **Example:**
56
+ ```bash
57
+ curl "https://veracious-marlin-319.convex.site/groups?type=organization&status=active&limit=20"
58
+ ```
59
+
60
+ **Response:**
61
+ ```json
62
+ {
63
+ "success": true,
64
+ "data": [
65
+ {
66
+ "_id": "group_123",
67
+ "name": "Acme Corporation",
68
+ "type": "organization",
69
+ "parentGroupId": null,
70
+ "status": "active",
71
+ "properties": {
72
+ "plan": "enterprise",
73
+ "description": "Global tech company"
74
+ },
75
+ "createdAt": 1729878000000,
76
+ "updatedAt": 1729878000000
77
+ }
78
+ ]
79
+ }
80
+ ```
81
+
82
+ ### Create Group
83
+
84
+ ```bash
85
+ curl -X POST https://veracious-marlin-319.convex.site/groups \
86
+ -H "Content-Type: application/json" \
87
+ -d '{
88
+ "name": "Engineering Department",
89
+ "type": "organization",
90
+ "parentGroupId": "group_123",
91
+ "properties": {
92
+ "description": "Engineering team",
93
+ "budget": 500000
94
+ }
95
+ }'
96
+ ```
97
+
98
+ **Response:**
99
+ ```json
100
+ {
101
+ "success": true,
102
+ "data": {
103
+ "_id": "group_456"
104
+ }
105
+ }
106
+ ```
107
+
108
+ ---
109
+
110
+ ## Dimension 3: Things (All Entities)
111
+
112
+ Things represent all nouns in the system: users, courses, products, agents, content, tokens, etc.
113
+
114
+ ### List Things
115
+
116
+ ```bash
117
+ curl https://veracious-marlin-319.convex.site/things
118
+ ```
119
+
120
+ **Query Parameters:**
121
+ - `groupId` - **Required** - Filter by group ID
122
+ - `type` - Filter by thing type (user, course, product, blog_post, agent, token, etc.)
123
+ - `status` - Filter by status (draft, active, published, archived)
124
+ - `search` - Search by name (partial match, case-insensitive)
125
+ - `limit` - Results per page (default 50, max 1000)
126
+ - `offset` - Pagination offset
127
+ - `sort` - Sort field (default 'createdAt', can be 'name', 'updatedAt')
128
+ - `order` - Sort order ('asc' or 'desc', default 'desc')
129
+
130
+ **Examples:**
131
+
132
+ List all things in a group:
133
+ ```bash
134
+ curl "https://veracious-marlin-319.convex.site/things?groupId=group_123"
135
+ ```
136
+
137
+ Filter by type:
138
+ ```bash
139
+ curl "https://veracious-marlin-319.convex.site/things?groupId=group_123&type=course&status=active"
140
+ ```
141
+
142
+ Search with pagination:
143
+ ```bash
144
+ curl "https://veracious-marlin-319.convex.site/things?groupId=group_123&search=python&limit=20&offset=0"
145
+ ```
146
+
147
+ **Response:**
148
+ ```json
149
+ {
150
+ "success": true,
151
+ "data": {
152
+ "things": [
153
+ {
154
+ "_id": "thing_course_789",
155
+ "groupId": "group_123",
156
+ "type": "course",
157
+ "name": "Python Fundamentals",
158
+ "status": "active",
159
+ "properties": {
160
+ "description": "Learn Python basics",
161
+ "level": "beginner",
162
+ "duration": 40,
163
+ "instructor": "Jane Doe"
164
+ },
165
+ "createdAt": 1729878000000,
166
+ "updatedAt": 1729878000000
167
+ }
168
+ ],
169
+ "total": 150,
170
+ "limit": 50,
171
+ "offset": 0
172
+ }
173
+ }
174
+ ```
175
+
176
+ ### Create Thing
177
+
178
+ ```bash
179
+ curl -X POST https://veracious-marlin-319.convex.site/things \
180
+ -H "Content-Type: application/json" \
181
+ -d '{
182
+ "type": "course",
183
+ "name": "Advanced Python",
184
+ "groupId": "group_123",
185
+ "properties": {
186
+ "description": "Master Python programming",
187
+ "level": "advanced",
188
+ "duration": 80,
189
+ "instructor": "John Smith",
190
+ "price": 199
191
+ },
192
+ "status": "draft"
193
+ }'
194
+ ```
195
+
196
+ **Required Fields:**
197
+ - `type` - Thing type (string)
198
+ - `name` - Thing name (string)
199
+ - `groupId` - Group ID (string)
200
+
201
+ **Optional Fields:**
202
+ - `properties` - Flexible object for type-specific data
203
+ - `status` - Status (default 'draft')
204
+
205
+ **Response:**
206
+ ```json
207
+ {
208
+ "success": true,
209
+ "data": {
210
+ "_id": "thing_course_new"
211
+ }
212
+ }
213
+ ```
214
+
215
+ ### Get Single Thing
216
+
217
+ ```bash
218
+ curl "https://veracious-marlin-319.convex.site/things/thing_course_789?groupId=group_123"
219
+ ```
220
+
221
+ ---
222
+
223
+ ## Dimension 4: Connections (Relationships)
224
+
225
+ Connections represent relationships between entities with optional metadata.
226
+
227
+ ### List Connections
228
+
229
+ ```bash
230
+ curl https://veracious-marlin-319.convex.site/connections
231
+ ```
232
+
233
+ **Query Parameters:**
234
+ - `groupId` - **Required** - Filter by group ID
235
+ - `relationshipType` - Filter by relationship type (owns, enrolled_in, follows, member_of, transacted, authored, part_of, etc.)
236
+ - `fromThingId` - Filter by source entity
237
+ - `toThingId` - Filter by target entity
238
+ - `limit` - Results per page (default 50, max 1000)
239
+ - `offset` - Pagination offset
240
+
241
+ **Examples:**
242
+
243
+ List all connections in a group:
244
+ ```bash
245
+ curl "https://veracious-marlin-319.convex.site/connections?groupId=group_123"
246
+ ```
247
+
248
+ Filter by relationship type:
249
+ ```bash
250
+ curl "https://veracious-marlin-319.convex.site/connections?groupId=group_123&relationshipType=enrolled_in"
251
+ ```
252
+
253
+ Find connections from a specific entity:
254
+ ```bash
255
+ curl "https://veracious-marlin-319.convex.site/connections?groupId=group_123&fromThingId=user_123"
256
+ ```
257
+
258
+ Find connections to a specific entity:
259
+ ```bash
260
+ curl "https://veracious-marlin-319.convex.site/connections?groupId=group_123&toThingId=course_456"
261
+ ```
262
+
263
+ **Response:**
264
+ ```json
265
+ {
266
+ "success": true,
267
+ "data": {
268
+ "connections": [
269
+ {
270
+ "_id": "conn_123",
271
+ "groupId": "group_123",
272
+ "fromThingId": "user_456",
273
+ "toThingId": "course_789",
274
+ "relationshipType": "enrolled_in",
275
+ "metadata": {
276
+ "enrolledAt": 1729878000000,
277
+ "progress": 45,
278
+ "lastAccessedAt": 1729900000000
279
+ },
280
+ "createdAt": 1729878000000,
281
+ "updatedAt": 1729900000000
282
+ }
283
+ ],
284
+ "total": 250,
285
+ "limit": 50,
286
+ "offset": 0
287
+ }
288
+ }
289
+ ```
290
+
291
+ ### Create Connection
292
+
293
+ ```bash
294
+ curl -X POST https://veracious-marlin-319.convex.site/connections \
295
+ -H "Content-Type: application/json" \
296
+ -d '{
297
+ "fromThingId": "user_456",
298
+ "toThingId": "course_789",
299
+ "relationshipType": "enrolled_in",
300
+ "groupId": "group_123",
301
+ "metadata": {
302
+ "enrolledAt": 1729878000000,
303
+ "progress": 0
304
+ }
305
+ }'
306
+ ```
307
+
308
+ **Required Fields:**
309
+ - `fromThingId` - Source entity ID
310
+ - `toThingId` - Target entity ID
311
+ - `relationshipType` - Type of relationship
312
+ - `groupId` - Group ID
313
+
314
+ **Optional Fields:**
315
+ - `metadata` - Flexible object for relationship-specific data
316
+
317
+ **Common Relationship Types:**
318
+ - `owns` - X owns Y
319
+ - `enrolled_in` - X is enrolled in Y
320
+ - `follows` - X follows Y
321
+ - `member_of` - X is member of Y
322
+ - `transacted` - X transacted with Y
323
+ - `authored` - X authored Y
324
+ - `part_of` - X is part of Y
325
+ - `holds_tokens` - X holds tokens from Y
326
+ - `manages` - X manages Y
327
+ - `teaches` - X teaches Y
328
+
329
+ **Response:**
330
+ ```json
331
+ {
332
+ "success": true,
333
+ "data": {
334
+ "_id": "conn_new"
335
+ }
336
+ }
337
+ ```
338
+
339
+ ---
340
+
341
+ ## Dimension 5: Events (Audit Trail)
342
+
343
+ Events record all actions and state changes for complete audit trails.
344
+
345
+ ### List Events
346
+
347
+ ```bash
348
+ curl https://veracious-marlin-319.convex.site/events
349
+ ```
350
+
351
+ **Query Parameters:**
352
+ - `groupId` - **Required** - Filter by group ID
353
+ - `eventType` - Filter by event type (thing_created, thing_updated, connection_created, enrollment_completed, etc.)
354
+ - `thingId` - Filter by thing ID
355
+ - `actorId` - Filter by actor (who performed the action)
356
+ - `limit` - Results per page (default 50, max 1000)
357
+ - `offset` - Pagination offset
358
+ - `startTime` - Filter events after timestamp
359
+ - `endTime` - Filter events before timestamp
360
+
361
+ **Examples:**
362
+
363
+ List all events in a group:
364
+ ```bash
365
+ curl "https://veracious-marlin-319.convex.site/events?groupId=group_123"
366
+ ```
367
+
368
+ Filter by event type:
369
+ ```bash
370
+ curl "https://veracious-marlin-319.convex.site/events?groupId=group_123&eventType=thing_created"
371
+ ```
372
+
373
+ Get event history for a specific thing:
374
+ ```bash
375
+ curl "https://veracious-marlin-319.convex.site/events?groupId=group_123&thingId=course_789&limit=100"
376
+ ```
377
+
378
+ Get events by a specific actor:
379
+ ```bash
380
+ curl "https://veracious-marlin-319.convex.site/events?groupId=group_123&actorId=user_456"
381
+ ```
382
+
383
+ Events in a time range:
384
+ ```bash
385
+ curl "https://veracious-marlin-319.convex.site/events?groupId=group_123&startTime=1729800000000&endTime=1729900000000"
386
+ ```
387
+
388
+ **Response:**
389
+ ```json
390
+ {
391
+ "success": true,
392
+ "data": {
393
+ "events": [
394
+ {
395
+ "_id": "event_123",
396
+ "groupId": "group_123",
397
+ "eventType": "enrollment_completed",
398
+ "thingId": "course_789",
399
+ "actorId": "user_456",
400
+ "timestamp": 1729878000000,
401
+ "metadata": {
402
+ "enrollmentId": "conn_123",
403
+ "completionTime": 3600000,
404
+ "score": 95
405
+ }
406
+ }
407
+ ],
408
+ "total": 1000,
409
+ "limit": 50,
410
+ "offset": 0
411
+ }
412
+ }
413
+ ```
414
+
415
+ **Common Event Types:**
416
+ - `thing_created` - Entity was created
417
+ - `thing_updated` - Entity was updated
418
+ - `thing_deleted` - Entity was deleted
419
+ - `connection_created` - Relationship was created
420
+ - `connection_updated` - Relationship was updated
421
+ - `enrollment_completed` - User completed enrollment
422
+ - `tokens_purchased` - Tokens were purchased
423
+ - `payment_processed` - Payment was processed
424
+ - `knowledge_indexed` - Content was indexed for search
425
+
426
+ ---
427
+
428
+ ## Dimension 6: Knowledge (Semantic Search)
429
+
430
+ Knowledge base for embeddings and semantic search capabilities.
431
+
432
+ ### Search Knowledge
433
+
434
+ ```bash
435
+ curl -X POST https://veracious-marlin-319.convex.site/knowledge/search \
436
+ -H "Content-Type: application/json" \
437
+ -d '{
438
+ "query": "python programming",
439
+ "groupId": "group_123",
440
+ "limit": 10,
441
+ "threshold": 0.7
442
+ }'
443
+ ```
444
+
445
+ **Request Fields:**
446
+ - `query` - Search query (string) - **Required**
447
+ - `groupId` - Group ID - **Required**
448
+ - `limit` - Max results (default 10, max 100)
449
+ - `threshold` - Relevance threshold (0-1, default 0.5)
450
+ - `type` - Filter by thing type (optional)
451
+
452
+ **Response:**
453
+ ```json
454
+ {
455
+ "success": true,
456
+ "data": {
457
+ "results": [
458
+ {
459
+ "_id": "knowledge_123",
460
+ "thingId": "course_789",
461
+ "thingName": "Python Fundamentals",
462
+ "relevance": 0.95,
463
+ "content": "Learn Python basics including variables, functions, and data structures",
464
+ "tags": ["programming", "python", "beginner"]
465
+ }
466
+ ],
467
+ "total": 25,
468
+ "query": "python programming"
469
+ }
470
+ }
471
+ ```
472
+
473
+ ### Index Content
474
+
475
+ ```bash
476
+ curl -X POST https://veracious-marlin-319.convex.site/knowledge/index \
477
+ -H "Content-Type: application/json" \
478
+ -d '{
479
+ "thingId": "course_789",
480
+ "groupId": "group_123",
481
+ "content": "Learn Python basics including variables, functions, and data structures",
482
+ "tags": ["programming", "python", "beginner"]
483
+ }'
484
+ ```
485
+
486
+ ---
487
+
488
+ ## Frontend API (Astro)
489
+
490
+ **Base URL:** `http://localhost:4321` (development) or your deployed domain
491
+
492
+ The frontend provides convenience endpoints that wrap Convex functionality.
493
+
494
+ ### List Things
495
+
496
+ ```bash
497
+ curl http://localhost:4321/api/things
498
+ ```
499
+
500
+ **Query Parameters:** Same as backend (groupId, type, status, search, limit, offset, sort, order)
501
+
502
+ ### Create Thing
503
+
504
+ ```bash
505
+ curl -X POST http://localhost:4321/api/things \
506
+ -H "Content-Type: application/json" \
507
+ -d '{
508
+ "type": "course",
509
+ "name": "Python Basics",
510
+ "groupId": "group_123",
511
+ "properties": {
512
+ "description": "Learn Python",
513
+ "level": "beginner"
514
+ }
515
+ }'
516
+ ```
517
+
518
+ ### List Connections
519
+
520
+ ```bash
521
+ curl http://localhost:4321/api/connections
522
+ ```
523
+
524
+ ### Create Connection
525
+
526
+ ```bash
527
+ curl -X POST http://localhost:4321/api/connections \
528
+ -H "Content-Type: application/json" \
529
+ -d '{
530
+ "fromEntityId": "user_123",
531
+ "toEntityId": "course_456",
532
+ "relationshipType": "enrolled_in",
533
+ "groupId": "group_789",
534
+ "metadata": {
535
+ "enrolledAt": 1729878000000
536
+ }
537
+ }'
538
+ ```
539
+
540
+ ### Search Knowledge
541
+
542
+ ```bash
543
+ curl "http://localhost:4321/api/knowledge/search?q=python&limit=10"
544
+ ```
545
+
546
+ ---
547
+
548
+ ## Authentication
549
+
550
+ ### Option 1: Session Cookies (Browser)
551
+
552
+ When making requests from a browser, session cookies are automatically included:
553
+
554
+ ```javascript
555
+ // In browser JavaScript
556
+ const response = await fetch('/api/things?groupId=group_123', {
557
+ credentials: 'include', // Include cookies
558
+ });
559
+ const data = await response.json();
560
+ ```
561
+
562
+ ### Option 2: Bearer Token (API Clients)
563
+
564
+ For programmatic access, use Bearer tokens:
565
+
566
+ ```bash
567
+ curl -H "Authorization: Bearer YOUR_TOKEN" \
568
+ https://veracious-marlin-319.convex.site/things?groupId=group_123
569
+ ```
570
+
571
+ **Getting a Token:**
572
+
573
+ 1. Sign in to the application
574
+ 2. Navigate to Account Settings → API Tokens
575
+ 3. Create a new token with required scopes
576
+ 4. Use in Authorization header
577
+
578
+ ### Option 3: API Key
579
+
580
+ For server-to-server communication:
581
+
582
+ ```bash
583
+ curl -H "X-API-Key: your-api-key" \
584
+ https://veracious-marlin-319.convex.site/things?groupId=group_123
585
+ ```
586
+
587
+ ---
588
+
589
+ ## Common Query Parameters
590
+
591
+ ### Pagination
592
+
593
+ ```bash
594
+ curl "https://backend.api/things?groupId=group_123&limit=20&offset=40"
595
+ ```
596
+
597
+ - `limit` - Results per page (default 50, max 1000)
598
+ - `offset` - Starting position (default 0)
599
+
600
+ ### Sorting
601
+
602
+ ```bash
603
+ curl "https://backend.api/things?groupId=group_123&sort=name&order=asc"
604
+ ```
605
+
606
+ - `sort` - Field to sort by (createdAt, name, updatedAt)
607
+ - `order` - Sort direction (asc, desc)
608
+
609
+ ### Filtering
610
+
611
+ ```bash
612
+ curl "https://backend.api/things?groupId=group_123&type=course&status=active"
613
+ ```
614
+
615
+ - `type` - Filter by entity type
616
+ - `status` - Filter by status
617
+ - `search` - Text search on name
618
+
619
+ ### Relationships
620
+
621
+ ```bash
622
+ curl "https://backend.api/connections?groupId=group_123&fromThingId=user_123&relationshipType=enrolled_in"
623
+ ```
624
+
625
+ - `fromThingId` - Filter by source
626
+ - `toThingId` - Filter by target
627
+ - `relationshipType` - Filter by relationship type
628
+
629
+ ---
630
+
631
+ ## Error Handling
632
+
633
+ ### Error Response Format
634
+
635
+ ```json
636
+ {
637
+ "success": false,
638
+ "error": {
639
+ "code": "VALIDATION_ERROR",
640
+ "message": "groupId is required"
641
+ }
642
+ }
643
+ ```
644
+
645
+ ### Common Error Codes
646
+
647
+ | Code | Status | Description |
648
+ |------|--------|-------------|
649
+ | `VALIDATION_ERROR` | 400 | Invalid request parameters |
650
+ | `UNAUTHORIZED` | 401 | Missing or invalid authentication |
651
+ | `FORBIDDEN` | 403 | Insufficient permissions |
652
+ | `NOT_FOUND` | 404 | Resource not found |
653
+ | `CONFLICT` | 409 | Resource already exists |
654
+ | `RATE_LIMITED` | 429 | Rate limit exceeded |
655
+ | `INTERNAL_ERROR` | 500 | Server error |
656
+
657
+ ### Example Error Response
658
+
659
+ ```bash
660
+ curl -X POST https://backend.api/things \
661
+ -H "Content-Type: application/json" \
662
+ -d '{"type": "course", "name": "Test"}'
663
+ ```
664
+
665
+ **Response (missing groupId):**
666
+ ```json
667
+ {
668
+ "success": false,
669
+ "error": {
670
+ "code": "VALIDATION_ERROR",
671
+ "message": "groupId is required and must be a string"
672
+ }
673
+ }
674
+ ```
675
+
676
+ ---
677
+
678
+ ## Examples by Use Case
679
+
680
+ ### Create a Course and Enroll Users
681
+
682
+ **Step 1: Create the course (thing)**
683
+ ```bash
684
+ curl -X POST https://backend.api/things \
685
+ -H "Content-Type: application/json" \
686
+ -d '{
687
+ "type": "course",
688
+ "name": "Python Fundamentals",
689
+ "groupId": "group_123",
690
+ "properties": {
691
+ "description": "Learn Python",
692
+ "level": "beginner",
693
+ "duration": 40
694
+ },
695
+ "status": "active"
696
+ }'
697
+ ```
698
+
699
+ **Step 2: Create enrollment connections**
700
+ ```bash
701
+ curl -X POST https://backend.api/connections \
702
+ -H "Content-Type: application/json" \
703
+ -d '{
704
+ "fromThingId": "user_456",
705
+ "toThingId": "course_789",
706
+ "relationshipType": "enrolled_in",
707
+ "groupId": "group_123",
708
+ "metadata": {
709
+ "enrolledAt": 1729878000000,
710
+ "progress": 0
711
+ }
712
+ }'
713
+ ```
714
+
715
+ **Step 3: Track completion event**
716
+ ```bash
717
+ curl -X POST https://backend.api/events \
718
+ -H "Content-Type: application/json" \
719
+ -d '{
720
+ "eventType": "enrollment_completed",
721
+ "thingId": "course_789",
722
+ "actorId": "user_456",
723
+ "groupId": "group_123",
724
+ "metadata": {
725
+ "completionTime": 3600000,
726
+ "score": 92
727
+ }
728
+ }'
729
+ ```
730
+
731
+ ### Build a Product Catalog with Recommendations
732
+
733
+ **Step 1: Create products**
734
+ ```bash
735
+ curl -X POST https://backend.api/things \
736
+ -H "Content-Type: application/json" \
737
+ -d '{
738
+ "type": "product",
739
+ "name": "Premium Plan",
740
+ "groupId": "group_123",
741
+ "properties": {
742
+ "price": 99,
743
+ "features": ["unlimited access", "priority support"],
744
+ "category": "subscription"
745
+ },
746
+ "status": "active"
747
+ }'
748
+ ```
749
+
750
+ **Step 2: Link related products**
751
+ ```bash
752
+ curl -X POST https://backend.api/connections \
753
+ -H "Content-Type: application/json" \
754
+ -d '{
755
+ "fromThingId": "product_premium",
756
+ "toThingId": "product_addon_storage",
757
+ "relationshipType": "part_of",
758
+ "groupId": "group_123",
759
+ "metadata": {
760
+ "order": 1
761
+ }
762
+ }'
763
+ ```
764
+
765
+ **Step 3: Record purchases**
766
+ ```bash
767
+ curl -X POST https://backend.api/connections \
768
+ -H "Content-Type: application/json" \
769
+ -d '{
770
+ "fromThingId": "user_456",
771
+ "toThingId": "product_premium",
772
+ "relationshipType": "owns",
773
+ "groupId": "group_123",
774
+ "metadata": {
775
+ "purchasedAt": 1729878000000,
776
+ "renewalDate": 1737654000000
777
+ }
778
+ }'
779
+ ```
780
+
781
+ ### Search Content Recommendations
782
+
783
+ **Index content**
784
+ ```bash
785
+ curl -X POST https://backend.api/knowledge/index \
786
+ -H "Content-Type: application/json" \
787
+ -d '{
788
+ "thingId": "course_789",
789
+ "groupId": "group_123",
790
+ "content": "Learn Python fundamentals including variables, functions, decorators, and async programming",
791
+ "tags": ["python", "programming", "backend", "advanced"]
792
+ }'
793
+ ```
794
+
795
+ **Search for recommendations**
796
+ ```bash
797
+ curl -X POST https://backend.api/knowledge/search \
798
+ -H "Content-Type: application/json" \
799
+ -d '{
800
+ "query": "async programming in Python",
801
+ "groupId": "group_123",
802
+ "limit": 5,
803
+ "threshold": 0.8
804
+ }'
805
+ ```
806
+
807
+ ### Monitor User Activity
808
+
809
+ **Get user's actions**
810
+ ```bash
811
+ curl "https://backend.api/events?groupId=group_123&actorId=user_456&limit=50"
812
+ ```
813
+
814
+ **Get entity's history**
815
+ ```bash
816
+ curl "https://backend.api/events?groupId=group_123&thingId=course_789&limit=100"
817
+ ```
818
+
819
+ **Get activity in time range**
820
+ ```bash
821
+ curl "https://backend.api/events?groupId=group_123&startTime=1729800000000&endTime=1729900000000&limit=100"
822
+ ```
823
+
824
+ ---
825
+
826
+ ## Best Practices
827
+
828
+ ### 1. Always Include groupId
829
+
830
+ Every request to Things, Connections, Events, or Knowledge endpoints must filter by `groupId` for data isolation:
831
+
832
+ ```bash
833
+ # ❌ WRONG - No groupId filter
834
+ curl https://backend.api/things
835
+
836
+ # ✅ CORRECT - Include groupId
837
+ curl "https://backend.api/things?groupId=group_123"
838
+ ```
839
+
840
+ ### 2. Use Pagination for Large Results
841
+
842
+ Don't fetch unlimited results. Always paginate:
843
+
844
+ ```bash
845
+ # ✅ GOOD - Paginated
846
+ curl "https://backend.api/things?groupId=group_123&limit=50&offset=0"
847
+
848
+ # ❌ AVOID - Unbounded query
849
+ curl "https://backend.api/things?groupId=group_123"
850
+ ```
851
+
852
+ ### 3. Cache Responses When Appropriate
853
+
854
+ Use HTTP caching headers:
855
+
856
+ ```bash
857
+ curl -H "Cache-Control: max-age=300" \
858
+ "https://backend.api/things?groupId=group_123&type=course"
859
+ ```
860
+
861
+ ### 4. Use POST for Mutations, GET for Queries
862
+
863
+ ```bash
864
+ # ✅ GET for reading
865
+ curl "https://backend.api/things?groupId=group_123"
866
+
867
+ # ✅ POST for creating
868
+ curl -X POST https://backend.api/things \
869
+ -H "Content-Type: application/json" \
870
+ -d '{...}'
871
+
872
+ # ✅ PATCH for updating
873
+ curl -X PATCH https://backend.api/things/thing_123 \
874
+ -H "Content-Type: application/json" \
875
+ -d '{...}'
876
+
877
+ # ✅ DELETE for removing
878
+ curl -X DELETE "https://backend.api/things/thing_123?groupId=group_123"
879
+ ```
880
+
881
+ ### 5. Validate Responses
882
+
883
+ Always check the `success` field:
884
+
885
+ ```bash
886
+ curl https://backend.api/things | jq '.success'
887
+ ```
888
+
889
+ ### 6. Handle Rate Limiting
890
+
891
+ Respect rate limits:
892
+ - Wait on 429 status
893
+ - Use exponential backoff
894
+ - Cache results when possible
895
+
896
+ ### 7. Log Audit Trail with Events
897
+
898
+ For important actions, create audit events:
899
+
900
+ ```bash
901
+ # Always log significant changes
902
+ curl -X POST https://backend.api/events \
903
+ -H "Content-Type: application/json" \
904
+ -d '{
905
+ "eventType": "thing_updated",
906
+ "thingId": "course_789",
907
+ "actorId": "user_456",
908
+ "groupId": "group_123",
909
+ "metadata": {
910
+ "changedFields": ["description", "price"],
911
+ "timestamp": 1729878000000
912
+ }
913
+ }'
914
+ ```
915
+
916
+ ---
917
+
918
+ ## See Also
919
+
920
+ - [Ontology Reference](/one/knowledge/ontology.md) - Complete 6-dimension ontology
921
+ - [Architecture Guide](/one/knowledge/architecture.md) - System design
922
+ - [Error Codes Reference](/one/knowledge/errors.md) - Detailed error documentation
923
+ - [Webhook Events](/one/connections/webhooks.md) - Real-time event subscriptions