oneie 3.6.14 → 3.6.15
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.
- package/.claude/agents/agent-director.md +6 -6
- package/.claude/agents/agent-onboard.md +8 -8
- package/.claude/commands/cascade.md +49 -20
- package/.claude/commands/create.md +397 -0
- package/.claude/commands/npx.md +64 -113
- package/.claude/commands/one.md +10 -28
- package/.claude/commands/plan.md +65 -65
- package/.claude/commands/push.md +63 -452
- package/.claude/commands/release.md +26 -395
- package/.claude/hooks/README-knowledge-hooks.md +4 -4
- package/.claude/hooks/README.md +13 -13
- package/.claude/hooks/clean-root-markdown.sh +73 -0
- package/.claude/hooks/track-changes.sh +101 -0
- package/.claude/skills/ontology/README.md +1 -1
- package/CLAUDE.md +38 -25
- package/one/README.md +3 -3
- package/one/connections/documentation.md +1 -1
- package/one/connections/inference.md +9 -9
- package/one/connections/workflow-copy.md +1 -1
- package/one/connections/workflow-onboarding.md +85 -85
- package/one/connections/workflow.md +1 -1
- package/one/groups/groups.md +31 -31
- package/one/groups/one.md +26 -26
- package/one/knowledge/100-inference-quick-reference.md +38 -38
- package/one/knowledge/ai-token-crypto-analysis-framework.md +15 -15
- package/one/knowledge/archived/ontology.old.md +11 -11
- package/one/knowledge/audit-agent-onboard-alignment.md +1 -1
- package/one/knowledge/cli-claude-handoff.md +36 -36
- package/one/knowledge/crypto-analysis-strategy.md +8 -8
- package/one/knowledge/event-driven-documentation.md +270 -0
- package/one/knowledge/knowledge.md +28 -28
- package/one/knowledge/lessons-website-building-focus.md +1 -1
- package/one/knowledge/metadata-system.md +11 -11
- package/one/knowledge/ontology-crypto.md +19 -19
- package/one/knowledge/ontology-documentation.md +7 -7
- package/one/knowledge/ontology-engineering.md +3 -3
- package/one/knowledge/ontology-files.yaml +3 -3
- package/one/knowledge/ontology-release.md +3 -3
- package/one/knowledge/ontology.md +10 -10
- package/one/knowledge/ontology.yaml +7 -7
- package/one/knowledge/score.md +4 -4
- package/one/knowledge/todo-template.md +55 -55
- package/one/knowledge/todo.md +55 -55
- package/one/knowledge/typescript-patterns.md +1 -1
- package/one/knowledge/x402-research.md +1 -1
- package/one/people/anthony-o-connell.md +19 -19
- package/one/people/people.md +1 -1
- package/one/things/IMPLEMENTATION_STATUS.md +12 -12
- package/one/things/agents/agent-backend.md +4 -4
- package/one/things/agents/agent-clean.md +16 -16
- package/one/things/agents/agent-deploy.md +6 -6
- package/one/things/agents/agent-sales.md +6 -6
- package/one/things/claude/agents/nextjs-15-specialist.md +1 -1
- package/one/things/demo-design-summary.md +6 -6
- package/one/things/examples/enterprise/crm-saas.md +24 -24
- package/one/things/features/2-1-dataprovider-interface.md +6 -6
- package/one/things/features/2-3-effectts-services.md +7 -7
- package/one/things/features/2-4-react-hooks.md +4 -4
- package/one/things/features/2-cli.md +3 -3
- package/one/things/features/2-design.md +2 -2
- package/one/things/features/use-one-backend.md +2 -2
- package/one/things/files.yaml +3 -3
- package/one/things/implementation/backend-guide.md +1 -1
- package/one/things/interface.md +8 -8
- package/one/things/landing-page-implementation.md +10 -10
- package/one/things/legal/privacy-policy.md +2 -2
- package/one/things/legal/terms-of-service.md +6 -6
- package/one/things/master-workflow-plan.md +16 -16
- package/one/things/plans/0-in-sync.md +136 -0
- package/one/things/plans/SIMPLIFICATION-SUMMARY.md +4 -4
- package/one/things/plans/ai-elements.md +7 -7
- package/one/things/plans/ai-integration.md +3 -3
- package/one/things/plans/ai-sdk.md +8 -8
- package/one/things/plans/backend-cleanup-quickstart.md +3 -3
- package/one/things/plans/backend-ontology-conformance.md +40 -40
- package/one/things/plans/backend-status.md +6 -6
- package/one/things/plans/backend-target-structure.md +2 -2
- package/one/things/plans/backend.md +1 -1
- package/one/things/plans/better-auth-any-backend.md +1 -1
- package/one/things/plans/components.md +32 -32
- package/one/things/plans/convex-agents.md +8 -8
- package/one/things/plans/deep-researcher-agent.md +1 -1
- package/one/things/plans/development-plan.md +49 -49
- package/one/things/plans/development-workflow.md +1 -1
- package/one/things/plans/effect.md +6 -6
- package/one/things/plans/execution-strategy.md +61 -61
- package/one/things/plans/existing-infrastructure.md +1 -1
- package/one/things/plans/frontend-effects.md +10 -10
- package/one/things/plans/group-folder-multi-tenancy.md +95 -95
- package/one/things/plans/integrate-frontend-and-backend.md +9 -9
- package/one/things/plans/onboarding.md +2 -2
- package/one/things/plans/ontology-6-dimensions.md +7 -7
- package/one/things/plans/ontology-compliance-audit.md +1 -1
- package/one/things/plans/phase-1-foundation.md +12 -12
- package/one/things/plans/readme-backend-cleanup.md +3 -3
- package/one/things/plans/sequence.md +129 -129
- package/one/things/plans/skills.md +30 -30
- package/one/things/plans/start-new.md +5 -5
- package/one/things/plans/sync-checklist.md +4 -4
- package/one/things/plans/unified-implementation-plan.md +1 -1
- package/one/things/plans/update-demos.md +53 -53
- package/one/things/plans/use-our-backend.md +30 -30
- package/one/things/plans/wave1-onboarding-100-inferences.md +152 -152
- package/one/things/plans/wave1-onboarding-vision.md +7 -7
- package/one/things/plans/wave1-orchestration-summary.md +67 -67
- package/one/things/plans/wave1-specialist-assignments.md +121 -121
- package/one/things/products/ontology.md +2 -2
- package/one/things/repos/all-repos.md +0 -0
- package/one/things/structure.md +2 -2
- package/one/things/tests/2-1-dataprovider-interface.md +2 -2
- package/one/things/tests/2-1-test-analysis.md +1 -1
- package/one/things/things.md +3 -3
- package/one/things/todo-acp-integration.md +33 -33
- package/one/things/todo-ai.md +37 -37
- package/one/things/todo-api.md +114 -114
- package/one/things/todo-assignment.md +39 -39
- package/one/things/todo-buy-chatgpt.md +113 -113
- package/one/things/todo-components.md +211 -211
- package/one/things/todo-ecommerce-frontend.md +82 -82
- package/one/things/todo-ecommerce.md +36 -36
- package/one/things/todo-effects.md +36 -36
- package/one/things/todo-frontend-effects.md +25 -25
- package/one/things/todo-landing-page.md +63 -63
- package/one/things/todo-mail.md +73 -73
- package/one/things/todo-master-plan.md +32 -32
- package/one/things/todo-onboard.md +48 -48
- package/one/things/todo-one-ie.md +48 -48
- package/one/things/todo-page.md +42 -42
- package/one/things/todo-plans.md +48 -48
- package/one/things/todo-refactoring-plan.md +5 -5
- package/one/things/todo-sequence.md +98 -98
- package/one/things/todo-use-our-backend.md +219 -219
- package/one/things/todo-x402.md +116 -116
- package/one/things/video-script-ontology.md +20 -20
- package/package.json +7 -2
- package/.claude/commands/build.md +0 -293
- package/one/.claude/settings.local.json +0 -11
- package/one/.obsidian/app.json +0 -8
- package/one/.obsidian/appearance.json +0 -1
- package/one/.obsidian/community-plugins.json +0 -5
- package/one/.obsidian/core-plugins.json +0 -33
- package/one/.obsidian/plugins/easy-bake/main.js +0 -361
- package/one/.obsidian/plugins/easy-bake/manifest.json +0 -11
- package/one/.obsidian/plugins/easy-bake/styles.css +0 -10
- package/one/.obsidian/plugins/editing-toolbar/data.json +0 -328
- package/one/.obsidian/plugins/editing-toolbar/main.js +0 -12
- package/one/.obsidian/plugins/editing-toolbar/manifest.json +0 -10
- package/one/.obsidian/plugins/editing-toolbar/styles.css +0 -1338
- package/one/.obsidian/plugins/terminal/data.json +0 -154
- package/one/.obsidian/plugins/terminal/main.js +0 -197
- package/one/.obsidian/plugins/terminal/manifest.json +0 -14
- package/one/.obsidian/plugins/terminal/styles.css +0 -32
- package/one/.obsidian/workspace.json +0 -266
- package/one/events/2024-10-14-deployment-plan.md +0 -330
- package/one/events/2024-10-14-deployment-success.md +0 -447
- package/one/events/2024-10-14-final-sync-complete.md +0 -250
- package/one/events/2024-10-14-release-v2.0.6.md +0 -414
- package/one/events/2024-10-15-agent-clean-v2-summary.md +0 -495
- package/one/events/2024-10-15-handoff-to-clean.md +0 -347
- package/one/events/2024-10-15-package-manager-tests.md +0 -442
- package/one/events/2024-10-15-release-command-complete.md +0 -416
- package/one/events/2025-10-15-private-files-secured.md +0 -359
- package/one/events/2025-10-15-unignore-public-group-docs.md +0 -298
- package/one/events/ALIGNMENT_REPORT_PROBLEM_SOLVER.md +0 -335
- package/one/events/ALIGNMENT_SUMMARY.md +0 -280
- package/one/events/API_ROUTES_FIXES_SUMMARY.md +0 -280
- package/one/events/ASTRO-INTEGRATION-EXAMPLES.md +0 -654
- package/one/events/AUDIT-ONTOLOGY-ALIGNMENT.md +0 -598
- package/one/events/BEFORE_AFTER_COMPARISON.md +0 -978
- package/one/events/CART-DRAWER-INTEGRATION-GUIDE.md +0 -372
- package/one/events/CASCADE-2-BACKEND-AGNOSTIC.md +0 -430
- package/one/events/CLAUDE copy.md +0 -897
- package/one/events/CLEANUP-RELEASE-V2.0.8.md +0 -308
- package/one/events/CONNECTIONS_DEMO.md +0 -519
- package/one/events/CREATE-WEBSITE.md +0 -460
- package/one/events/CRITICAL-FIXES-COMPLETE.md +0 -522
- package/one/events/CUSTOM-DOMAIN.md +0 -375
- package/one/events/DELIVERABLES.md +0 -450
- package/one/events/DEMO-GROUPS-PAGE.md +0 -410
- package/one/events/DEMO-TESTING-SUMMARY.md +0 -536
- package/one/events/DEMO_COMPONENTS.md +0 -505
- package/one/events/DEMO_HOOKS_INDEX.md +0 -352
- package/one/events/DEMO_INFRASTRUCTURE.md +0 -923
- package/one/events/DEMO_INFRASTRUCTURE_SUMMARY.md +0 -588
- package/one/events/DEMO_INTEGRATION_CHECKLIST.md +0 -449
- package/one/events/DEMO_QUICK_REFERENCE.md +0 -459
- package/one/events/DEMO_SETUP.md +0 -494
- package/one/events/DEPLOYMENT copy.md +0 -444
- package/one/events/DEPLOYMENT.md +0 -196
- package/one/events/ECOMMERCE-BEFORE-AFTER.md +0 -267
- package/one/events/ECOMMERCE-DEMO-PLAN.md +0 -243
- package/one/events/ECOMMERCE-ENHANCEMENTS.md +0 -594
- package/one/events/ECOMMERCE-HIGH-CONVERTING-ELEMENTS.md +0 -439
- package/one/events/ECOMMERCE-LIVE-DEMO.md +0 -381
- package/one/events/ECOMMERCE-REFACTOR-SUMMARY.md +0 -214
- package/one/events/ECOMMERCE-SETUP-SUMMARY.md +0 -414
- package/one/events/ECOMMERCE-TEMPLATE-COMPLETE.md +0 -753
- package/one/events/ECOMMERCE-TEMPLATES-SUMMARY.md +0 -941
- package/one/events/EFFECT_TS_API_PATTERN.md +0 -496
- package/one/events/FEATURE-2-4-COMPLETE.md +0 -320
- package/one/events/FEATURE_2_3_COMPLETE.md +0 -593
- package/one/events/GRADIENT-TEXT-PERMANENT-FIX.md +0 -241
- package/one/events/GROUPS-MIGRATION.md +0 -643
- package/one/events/GROUPS_DEMO_IMPLEMENTATION.md +0 -432
- package/one/events/HANDOFF.md +0 -331
- package/one/events/HOOKS-DEMO.md +0 -459
- package/one/events/IMPLEMENTATION-SUMMARY-FINAL.md +0 -521
- package/one/events/IMPLEMENTATION_SUMMARY.md +0 -547
- package/one/events/INSTALL-TESTS.md +0 -311
- package/one/events/INSTALLATION_FOLDERS.md +0 -534
- package/one/events/INSTALLATION_FOLDERS_FILES.md +0 -223
- package/one/events/INSTALLATION_FOLDERS_SUMMARY.md +0 -437
- package/one/events/INTEGRATION-ARCHITECTURE.md +0 -579
- package/one/events/INTEGRATION-CHECKLIST.md +0 -1252
- package/one/events/INTEGRATION-ORCHESTRATION.md +0 -2641
- package/one/events/INTEGRATION-SUMMARY.md +0 -671
- package/one/events/LANDING-PAGE-EXAMPLE-OUTPUT.md +0 -684
- package/one/events/LANDING-PAGE-IMPLEMENTATION.md +0 -660
- package/one/events/LANDING-PAGE-QUICKSTART.md +0 -425
- package/one/events/LICENSE.md +0 -107
- package/one/events/MCP-CONFIGURATION.md +0 -354
- package/one/events/MCP-SETUP-COMPLETE.md +0 -223
- package/one/events/MIGRATION-REPORT.md +0 -453
- package/one/events/MIGRATION.md +0 -87
- package/one/events/MULTI-ONTOLOGY-COMPLETE-GUIDE.md +0 -1645
- package/one/events/MULTI-ONTOLOGY-IMPLEMENTATION-COMPLETE.md +0 -591
- package/one/events/NODE-UPGRADE.md +0 -129
- package/one/events/ONBOARDING-IMPLEMENTATION-COMPLETE copy.md +0 -416
- package/one/events/ONTOLOGY-HOOKS-README.md +0 -718
- package/one/events/ONTOLOGY-INTEGRATION-MANIFEST.md +0 -383
- package/one/events/ONTOLOGY-TUTORIALS-SUMMARY.md +0 -543
- package/one/events/ONTOLOGY-TYPE-GENERATOR-SUMMARY.md +0 -473
- package/one/events/ONTOLOGY_DISCOVERY_IMPLEMENTATION.md +0 -504
- package/one/events/ONTOLOGY_DISCOVERY_QUICKSTART.md +0 -221
- package/one/events/PACKAGE-STRUCTURE.md +0 -328
- package/one/events/PLAYBOOK-SETUP-SUMMARY.md +0 -349
- package/one/events/PROMPT_FIX_FRONTEND_ONLY.md +0 -585
- package/one/events/QA-CHECKLIST.md +0 -692
- package/one/events/QUICK-START-ONTOLOGY.md +0 -426
- package/one/events/README-archived.md +0 -537
- package/one/events/SEARCH_DEMO_CODE_REFERENCE.md +0 -657
- package/one/events/SEARCH_DEMO_DELIVERY.md +0 -433
- package/one/events/SEARCH_DEMO_SUMMARY.md +0 -321
- package/one/events/SEARCH_DEMO_VISUAL_GUIDE.md +0 -399
- package/one/events/SECURITY-AUDIT-FIXES.md +0 -394
- package/one/events/SECURITY-SCAN-COMPLETE.md +0 -299
- package/one/events/SHOP-BUILD-STATUS.md +0 -132
- package/one/events/SHOP-PREMIUM-UPDATE.md +0 -165
- package/one/events/SIMPLE_FIX_FRONTEND_ONLY.md +0 -280
- package/one/events/SITE-WIDE-GRADIENT-FIX.md +0 -317
- package/one/events/STORE-PRODUCTION-READY-STATUS.md +0 -377
- package/one/events/STRIPE-INTEGRATION.md +0 -432
- package/one/events/STRIPE-PAYMENT-METHODS-GUIDE.md +0 -447
- package/one/events/STRIPE-SETUP-GUIDE.md +0 -480
- package/one/events/TEST-PLAN-INDEX.md +0 -364
- package/one/events/TEST-PLAN.md +0 -1435
- package/one/events/TEST-SUMMARY.md +0 -411
- package/one/events/TESTING-DELIVERY.txt +0 -372
- package/one/events/TESTS-QUICK-REF.md +0 -280
- package/one/events/TRANSITIONS-QUICK-START.md +0 -159
- package/one/events/TRANSPARENCY-FIXES.md +0 -293
- package/one/events/TYPESCRIPT_FIXES.md +0 -170
- package/one/events/TYPESCRIPT_FIXES_COMPLETE.txt +0 -412
- package/one/events/TYPESCRIPT_FIXES_INDEX.md +0 -359
- package/one/events/VIEW-TRANSITIONS.md +0 -446
- package/one/events/agent-director-enhancement-summary.md +0 -404
- package/one/events/agent-onboard-implementation-summary.md +0 -475
- package/one/events/agent-ontology-alignment-completion.md +0 -263
- package/one/events/backend-integration-tests.md +0 -624
- package/one/events/backend-structure-diagram.txt +0 -393
- package/one/events/backend-structure-summary.txt +0 -269
- package/one/events/clean-agent-ontology-cleanup-report.md +0 -371
- package/one/events/clean-agent-todo-analysis-summary.md +0 -336
- package/one/events/cloudflare-automation-complete.md +0 -350
- package/one/events/cloudflare-pages-infrastructure-setup.md +0 -282
- package/one/events/contact-page-complete.md +0 -316
- package/one/events/convex-analysis-index.md +0 -322
- package/one/events/convex-structure-analysis.md +0 -718
- package/one/events/deployment-installation-folders.md +0 -178
- package/one/events/deployment-ops-summary.md +0 -386
- package/one/events/deployment-verification.md +0 -366
- package/one/events/design-spec-complete.md +0 -226
- package/one/events/documentation-audit-index.md +0 -473
- package/one/events/documentation-audit-summary.md +0 -417
- package/one/events/documentation-improvement-roadmap.md +0 -906
- package/one/events/documentation-standards-compliance-report.md +0 -538
- package/one/events/events.md +0 -563
- package/one/events/frontend-effects-complete.md +0 -584
- package/one/events/frontend-effects-orchestration.md +0 -1356
- package/one/events/frontend-effects-risk-register.md +0 -1055
- package/one/events/frontend-effects-week1-assignments.md +0 -1594
- package/one/events/hook-ontology-alignment-summary.md +0 -528
- package/one/events/installation-folders-workflow-integration.md +0 -458
- package/one/events/landing-page-generator.md +0 -476
- package/one/events/legal-assessment-2025-10-16.md +0 -1917
- package/one/events/onboarding-implementation-complete.md +0 -523
- package/one/events/ontology-test-examples.md +0 -580
- package/one/events/phase1-backend-implementation-complete.md +0 -536
- package/one/events/release.md +0 -272
- package/one/events/root-cleanup-alignment-report.md +0 -265
- package/one/events/separate-implementation-status.md +0 -555
- package/one/events/session-summary-2025-10-18.md +0 -366
- package/one/events/skills-complete.md +0 -351
- package/one/events/skills-infer-6-10-summary.md +0 -70
- package/one/events/skills-phase1-complete.md +0 -281
- package/one/events/structural-analysis-architecture-vs-plans.md +0 -559
- package/one/events/test-dashboard.md +0 -363
- package/one/events/test-index.md +0 -379
- package/one/events/test-report-ontology.md +0 -600
- package/one/events/testing-summary.md +0 -362
- package/one/events/todo-refactoring-complete.md +0 -408
- package/one/events/wave1-backend-implementation-complete.md +0 -698
|
@@ -1,978 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Before_After_Comparison
|
|
3
|
-
dimension: events
|
|
4
|
-
category: BEFORE_AFTER_COMPARISON.md
|
|
5
|
-
tags: connections
|
|
6
|
-
related_dimensions: connections, groups, knowledge, things
|
|
7
|
-
scope: global
|
|
8
|
-
created: 2025-11-03
|
|
9
|
-
updated: 2025-11-03
|
|
10
|
-
version: 1.0.0
|
|
11
|
-
ai_context: |
|
|
12
|
-
This document is part of the events dimension in the BEFORE_AFTER_COMPARISON.md category.
|
|
13
|
-
Location: one/events/BEFORE_AFTER_COMPARISON.md
|
|
14
|
-
Purpose: Documents before & after: api routes typescript fixes
|
|
15
|
-
Related dimensions: connections, groups, knowledge, things
|
|
16
|
-
For AI agents: Read this to understand BEFORE_AFTER_COMPARISON.
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
# Before & After: API Routes TypeScript Fixes
|
|
20
|
-
|
|
21
|
-
This document shows the exact changes made to fix all TypeScript errors in the API routes.
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## File 1: src/pages/api/connections/index.ts
|
|
26
|
-
|
|
27
|
-
### GET Endpoint
|
|
28
|
-
|
|
29
|
-
#### BEFORE
|
|
30
|
-
```typescript
|
|
31
|
-
export const GET: APIRoute = async ({ url }) => {
|
|
32
|
-
try {
|
|
33
|
-
const provider = getDefaultProvider();
|
|
34
|
-
|
|
35
|
-
// Parse query parameters
|
|
36
|
-
const type = url.searchParams.get('type');
|
|
37
|
-
const fromThingId = url.searchParams.get('fromThingId'); // WRONG NAME
|
|
38
|
-
const toThingId = url.searchParams.get('toThingId'); // WRONG NAME
|
|
39
|
-
const groupId = url.searchParams.get('groupId');
|
|
40
|
-
const limit = Math.min(
|
|
41
|
-
parseInt(url.searchParams.get('limit') || '50'),
|
|
42
|
-
1000
|
|
43
|
-
);
|
|
44
|
-
const offset = parseInt(url.searchParams.get('offset') || '0');
|
|
45
|
-
|
|
46
|
-
// Build filter
|
|
47
|
-
const filter: Record<string, any> = {};
|
|
48
|
-
if (type) filter.relationshipType = type;
|
|
49
|
-
if (fromThingId) filter.fromThingId = fromThingId; // WRONG
|
|
50
|
-
if (toThingId) filter.toThingId = toThingId; // WRONG
|
|
51
|
-
if (groupId) filter.groupId = groupId;
|
|
52
|
-
|
|
53
|
-
// List connections via provider
|
|
54
|
-
const connections = await provider.connections.list(filter); // WRONG: No Effect.runPromise
|
|
55
|
-
|
|
56
|
-
// Paginate
|
|
57
|
-
const paginated = connections.slice(offset, offset + limit); // ERROR: slice on Effect
|
|
58
|
-
// TS Error: Property 'slice' does not exist on type Effect.Effect<Connection[], QueryError>
|
|
59
|
-
|
|
60
|
-
return new Response(
|
|
61
|
-
JSON.stringify(
|
|
62
|
-
successResponse({
|
|
63
|
-
connections: paginated,
|
|
64
|
-
total: connections.length, // ERROR: length on Effect
|
|
65
|
-
limit,
|
|
66
|
-
offset,
|
|
67
|
-
})
|
|
68
|
-
),
|
|
69
|
-
// ...
|
|
70
|
-
);
|
|
71
|
-
} catch (error) {
|
|
72
|
-
// ...
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
#### AFTER
|
|
78
|
-
```typescript
|
|
79
|
-
export const GET: APIRoute = async ({ url }) => {
|
|
80
|
-
try {
|
|
81
|
-
const provider = getDefaultProvider();
|
|
82
|
-
const { Effect } = await import('effect'); // ADDED: Import Effect
|
|
83
|
-
|
|
84
|
-
// Parse query parameters
|
|
85
|
-
const type = url.searchParams.get('type');
|
|
86
|
-
const fromEntityId = url.searchParams.get('fromEntityId'); // FIXED: Correct name
|
|
87
|
-
const toEntityId = url.searchParams.get('toEntityId'); // FIXED: Correct name
|
|
88
|
-
const groupId = url.searchParams.get('groupId');
|
|
89
|
-
const limit = Math.min(
|
|
90
|
-
parseInt(url.searchParams.get('limit') || '50'),
|
|
91
|
-
1000
|
|
92
|
-
);
|
|
93
|
-
const offset = parseInt(url.searchParams.get('offset') || '0');
|
|
94
|
-
|
|
95
|
-
// Build filter
|
|
96
|
-
const filter: Record<string, any> = {};
|
|
97
|
-
if (type) filter.relationshipType = type;
|
|
98
|
-
if (fromEntityId) filter.fromEntityId = fromEntityId; // FIXED
|
|
99
|
-
if (toEntityId) filter.toEntityId = toEntityId; // FIXED
|
|
100
|
-
if (groupId) filter.groupId = groupId;
|
|
101
|
-
|
|
102
|
-
// List connections via provider and extract Effect value
|
|
103
|
-
const connections = await Effect.runPromise(provider.connections.list(filter)); // FIXED
|
|
104
|
-
|
|
105
|
-
// Paginate
|
|
106
|
-
const paginated = connections.slice(offset, offset + limit); // WORKS: slice on array
|
|
107
|
-
|
|
108
|
-
return new Response(
|
|
109
|
-
JSON.stringify(
|
|
110
|
-
successResponse({
|
|
111
|
-
connections: paginated,
|
|
112
|
-
total: connections.length, // WORKS: length on array
|
|
113
|
-
limit,
|
|
114
|
-
offset,
|
|
115
|
-
})
|
|
116
|
-
),
|
|
117
|
-
// ...
|
|
118
|
-
);
|
|
119
|
-
} catch (error) {
|
|
120
|
-
// ...
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### POST Endpoint
|
|
126
|
-
|
|
127
|
-
#### BEFORE
|
|
128
|
-
```typescript
|
|
129
|
-
export const POST: APIRoute = async ({ request }) => {
|
|
130
|
-
try {
|
|
131
|
-
const provider = getDefaultProvider();
|
|
132
|
-
const body = await request.json();
|
|
133
|
-
|
|
134
|
-
// Validate required fields
|
|
135
|
-
if (!body.fromThingId || typeof body.fromThingId !== 'string') { // WRONG NAME
|
|
136
|
-
// error response
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (!body.toThingId || typeof body.toThingId !== 'string') { // WRONG NAME
|
|
140
|
-
// error response
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// ... other validations ...
|
|
144
|
-
|
|
145
|
-
// Create connection
|
|
146
|
-
const connection = await provider.connections.create({ // WRONG: No Effect.runPromise
|
|
147
|
-
fromThingId: body.fromThingId, // WRONG
|
|
148
|
-
toThingId: body.toThingId, // WRONG
|
|
149
|
-
relationshipType: body.relationshipType,
|
|
150
|
-
groupId: body.groupId,
|
|
151
|
-
metadata: body.metadata || {},
|
|
152
|
-
});
|
|
153
|
-
// TS Error: await has no effect on Effect type
|
|
154
|
-
// connection is string (ID), but code treats as object
|
|
155
|
-
|
|
156
|
-
return new Response(JSON.stringify(successResponse(connection)), { // WRONG TYPE
|
|
157
|
-
status: 201,
|
|
158
|
-
// ...
|
|
159
|
-
});
|
|
160
|
-
} catch (error) {
|
|
161
|
-
// ...
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
#### AFTER
|
|
167
|
-
```typescript
|
|
168
|
-
export const POST: APIRoute = async ({ request }) => {
|
|
169
|
-
try {
|
|
170
|
-
const provider = getDefaultProvider();
|
|
171
|
-
const { Effect } = await import('effect'); // ADDED
|
|
172
|
-
const body = await request.json();
|
|
173
|
-
|
|
174
|
-
// Validate required fields
|
|
175
|
-
if (!body.fromEntityId || typeof body.fromEntityId !== 'string') { // FIXED
|
|
176
|
-
// error response
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (!body.toEntityId || typeof body.toEntityId !== 'string') { // FIXED
|
|
180
|
-
// error response
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// ... other validations ...
|
|
184
|
-
|
|
185
|
-
// Create connection and extract Effect value
|
|
186
|
-
const connectionId = await Effect.runPromise( // FIXED
|
|
187
|
-
provider.connections.create({
|
|
188
|
-
fromEntityId: body.fromEntityId, // FIXED
|
|
189
|
-
toEntityId: body.toEntityId, // FIXED
|
|
190
|
-
relationshipType: body.relationshipType,
|
|
191
|
-
groupId: body.groupId,
|
|
192
|
-
metadata: body.metadata || {},
|
|
193
|
-
})
|
|
194
|
-
);
|
|
195
|
-
|
|
196
|
-
return new Response(JSON.stringify(successResponse({ _id: connectionId })), { // FIXED
|
|
197
|
-
status: 201,
|
|
198
|
-
// ...
|
|
199
|
-
});
|
|
200
|
-
} catch (error) {
|
|
201
|
-
// ...
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
---
|
|
207
|
-
|
|
208
|
-
## File 2: src/pages/api/events/index.ts
|
|
209
|
-
|
|
210
|
-
### GET Endpoint
|
|
211
|
-
|
|
212
|
-
#### BEFORE
|
|
213
|
-
```typescript
|
|
214
|
-
export const GET: APIRoute = async ({ url }) => {
|
|
215
|
-
try {
|
|
216
|
-
const provider = getDefaultProvider();
|
|
217
|
-
|
|
218
|
-
// Parse query parameters
|
|
219
|
-
const type = url.searchParams.get('type');
|
|
220
|
-
const actorId = url.searchParams.get('actorId');
|
|
221
|
-
const targetId = url.searchParams.get('targetId');
|
|
222
|
-
const groupId = url.searchParams.get('groupId');
|
|
223
|
-
const startTime = url.searchParams.get('startTime') // WRONG NAME
|
|
224
|
-
? parseInt(url.searchParams.get('startTime')!)
|
|
225
|
-
: undefined;
|
|
226
|
-
const endTime = url.searchParams.get('endTime') // WRONG NAME
|
|
227
|
-
? parseInt(url.searchParams.get('endTime')!)
|
|
228
|
-
: undefined;
|
|
229
|
-
const limit = Math.min(
|
|
230
|
-
parseInt(url.searchParams.get('limit') || '50'),
|
|
231
|
-
1000
|
|
232
|
-
);
|
|
233
|
-
const offset = parseInt(url.searchParams.get('offset') || '0');
|
|
234
|
-
const sort = (url.searchParams.get('sort') || 'desc') as 'asc' | 'desc';
|
|
235
|
-
|
|
236
|
-
// Build filter
|
|
237
|
-
const filter: Record<string, any> = {};
|
|
238
|
-
if (type) filter.type = type;
|
|
239
|
-
if (actorId) filter.actorId = actorId;
|
|
240
|
-
if (targetId) filter.targetId = targetId;
|
|
241
|
-
if (groupId) filter.groupId = groupId;
|
|
242
|
-
if (startTime) filter.startTime = startTime; // WRONG
|
|
243
|
-
if (endTime) filter.endTime = endTime; // WRONG
|
|
244
|
-
|
|
245
|
-
// List events via provider
|
|
246
|
-
let events = await provider.events.list(filter); // WRONG: No Effect.runPromise
|
|
247
|
-
// TS Error: await has no effect on Effect type
|
|
248
|
-
|
|
249
|
-
// Sort by timestamp
|
|
250
|
-
events.sort((a, b) => // ERROR: sort on Effect
|
|
251
|
-
sort === 'asc' ? a.timestamp - b.timestamp : b.timestamp - a.timestamp
|
|
252
|
-
);
|
|
253
|
-
|
|
254
|
-
// Paginate
|
|
255
|
-
const paginated = events.slice(offset, offset + limit); // ERROR: slice on Effect
|
|
256
|
-
|
|
257
|
-
return new Response(
|
|
258
|
-
JSON.stringify(
|
|
259
|
-
successResponse({
|
|
260
|
-
events: paginated,
|
|
261
|
-
total: events.length, // ERROR: length on Effect
|
|
262
|
-
limit,
|
|
263
|
-
offset,
|
|
264
|
-
})
|
|
265
|
-
),
|
|
266
|
-
// ...
|
|
267
|
-
);
|
|
268
|
-
} catch (error) {
|
|
269
|
-
// ...
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
#### AFTER
|
|
275
|
-
```typescript
|
|
276
|
-
export const GET: APIRoute = async ({ url }) => {
|
|
277
|
-
try {
|
|
278
|
-
const provider = getDefaultProvider();
|
|
279
|
-
const { Effect } = await import('effect'); // ADDED
|
|
280
|
-
|
|
281
|
-
// Parse query parameters
|
|
282
|
-
const type = url.searchParams.get('type');
|
|
283
|
-
const actorId = url.searchParams.get('actorId');
|
|
284
|
-
const targetId = url.searchParams.get('targetId');
|
|
285
|
-
const groupId = url.searchParams.get('groupId');
|
|
286
|
-
const startTime = url.searchParams.get('startTime') // Still used for parameter
|
|
287
|
-
? parseInt(url.searchParams.get('startTime')!)
|
|
288
|
-
: undefined;
|
|
289
|
-
const endTime = url.searchParams.get('endTime') // Still used for parameter
|
|
290
|
-
? parseInt(url.searchParams.get('endTime')!)
|
|
291
|
-
: undefined;
|
|
292
|
-
const limit = Math.min(
|
|
293
|
-
parseInt(url.searchParams.get('limit') || '50'),
|
|
294
|
-
1000
|
|
295
|
-
);
|
|
296
|
-
const offset = parseInt(url.searchParams.get('offset') || '0');
|
|
297
|
-
const sort = (url.searchParams.get('sort') || 'desc') as 'asc' | 'desc';
|
|
298
|
-
|
|
299
|
-
// Build filter
|
|
300
|
-
const filter: Record<string, any> = {};
|
|
301
|
-
if (type) filter.type = type;
|
|
302
|
-
if (actorId) filter.actorId = actorId;
|
|
303
|
-
if (targetId) filter.targetId = targetId;
|
|
304
|
-
if (groupId) filter.groupId = groupId;
|
|
305
|
-
if (startTime) filter.since = startTime; // FIXED
|
|
306
|
-
if (endTime) filter.until = endTime; // FIXED
|
|
307
|
-
|
|
308
|
-
// List events via provider and extract Effect value
|
|
309
|
-
let events = await Effect.runPromise(provider.events.list(filter)); // FIXED
|
|
310
|
-
|
|
311
|
-
// Sort by timestamp
|
|
312
|
-
events.sort((a, b) => // WORKS: sort on array
|
|
313
|
-
sort === 'asc' ? a.timestamp - b.timestamp : b.timestamp - a.timestamp
|
|
314
|
-
);
|
|
315
|
-
|
|
316
|
-
// Paginate
|
|
317
|
-
const paginated = events.slice(offset, offset + limit); // WORKS: slice on array
|
|
318
|
-
|
|
319
|
-
return new Response(
|
|
320
|
-
JSON.stringify(
|
|
321
|
-
successResponse({
|
|
322
|
-
events: paginated,
|
|
323
|
-
total: events.length, // WORKS: length on array
|
|
324
|
-
limit,
|
|
325
|
-
offset,
|
|
326
|
-
})
|
|
327
|
-
),
|
|
328
|
-
// ...
|
|
329
|
-
);
|
|
330
|
-
} catch (error) {
|
|
331
|
-
// ...
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
### POST Endpoint
|
|
337
|
-
|
|
338
|
-
#### BEFORE
|
|
339
|
-
```typescript
|
|
340
|
-
export const POST: APIRoute = async ({ request }) => {
|
|
341
|
-
try {
|
|
342
|
-
const provider = getDefaultProvider();
|
|
343
|
-
const body = await request.json();
|
|
344
|
-
|
|
345
|
-
// Validations...
|
|
346
|
-
|
|
347
|
-
// Record event
|
|
348
|
-
const event = await provider.events.record({ // WRONG: No Effect.runPromise, wrong method
|
|
349
|
-
type: body.type,
|
|
350
|
-
actorId: body.actorId,
|
|
351
|
-
targetId: body.targetId,
|
|
352
|
-
groupId: body.groupId,
|
|
353
|
-
metadata: body.metadata || {},
|
|
354
|
-
});
|
|
355
|
-
// TS Error: method 'record' does not exist
|
|
356
|
-
// await has no effect on Effect type
|
|
357
|
-
|
|
358
|
-
return new Response(JSON.stringify(successResponse(event)), { // WRONG TYPE
|
|
359
|
-
status: 201,
|
|
360
|
-
// ...
|
|
361
|
-
});
|
|
362
|
-
} catch (error) {
|
|
363
|
-
// ...
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
#### AFTER
|
|
369
|
-
```typescript
|
|
370
|
-
export const POST: APIRoute = async ({ request }) => {
|
|
371
|
-
try {
|
|
372
|
-
const provider = getDefaultProvider();
|
|
373
|
-
const { Effect } = await import('effect'); // ADDED
|
|
374
|
-
const body = await request.json();
|
|
375
|
-
|
|
376
|
-
// Validations...
|
|
377
|
-
|
|
378
|
-
// Record event and extract Effect value
|
|
379
|
-
const eventId = await Effect.runPromise( // FIXED
|
|
380
|
-
provider.events.create({ // FIXED: create not record
|
|
381
|
-
type: body.type,
|
|
382
|
-
actorId: body.actorId,
|
|
383
|
-
targetId: body.targetId,
|
|
384
|
-
groupId: body.groupId,
|
|
385
|
-
metadata: body.metadata || {},
|
|
386
|
-
})
|
|
387
|
-
);
|
|
388
|
-
|
|
389
|
-
return new Response(JSON.stringify(successResponse({ _id: eventId })), { // FIXED
|
|
390
|
-
status: 201,
|
|
391
|
-
// ...
|
|
392
|
-
});
|
|
393
|
-
} catch (error) {
|
|
394
|
-
// ...
|
|
395
|
-
}
|
|
396
|
-
};
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
---
|
|
400
|
-
|
|
401
|
-
## File 3: src/pages/api/knowledge/search.ts
|
|
402
|
-
|
|
403
|
-
#### BEFORE
|
|
404
|
-
```typescript
|
|
405
|
-
export const GET: APIRoute = async ({ url }) => {
|
|
406
|
-
try {
|
|
407
|
-
const provider = getDefaultProvider();
|
|
408
|
-
|
|
409
|
-
// Parse and validate parameters...
|
|
410
|
-
|
|
411
|
-
// Perform semantic search via provider
|
|
412
|
-
let results = await provider.knowledge.search(query.trim(), limit); // WRONG
|
|
413
|
-
// TS Error: search() expects number[] embedding, not string
|
|
414
|
-
// TS Error: await has no effect on Effect type
|
|
415
|
-
|
|
416
|
-
// Filter by threshold if provided
|
|
417
|
-
if (threshold > 0) {
|
|
418
|
-
results = results.filter( // ERROR: filter on Effect
|
|
419
|
-
(item: any) => (item.score || 1) >= threshold
|
|
420
|
-
);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
// Filter by group if provided
|
|
424
|
-
if (groupId) {
|
|
425
|
-
results = results.filter((item: any) => item.groupId === groupId); // ERROR: filter on Effect
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
// Filter by type if provided
|
|
429
|
-
if (type) {
|
|
430
|
-
results = results.filter((item: any) => item.type === type); // ERROR: filter on Effect
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
// Limit results
|
|
434
|
-
results = results.slice(0, limit); // ERROR: slice on Effect
|
|
435
|
-
|
|
436
|
-
return new Response(
|
|
437
|
-
JSON.stringify(
|
|
438
|
-
successResponse({
|
|
439
|
-
results,
|
|
440
|
-
query: query.trim(),
|
|
441
|
-
total: results.length, // ERROR: length on Effect
|
|
442
|
-
limit,
|
|
443
|
-
})
|
|
444
|
-
),
|
|
445
|
-
// ...
|
|
446
|
-
);
|
|
447
|
-
} catch (error) {
|
|
448
|
-
// ...
|
|
449
|
-
}
|
|
450
|
-
};
|
|
451
|
-
```
|
|
452
|
-
|
|
453
|
-
#### AFTER
|
|
454
|
-
```typescript
|
|
455
|
-
export const GET: APIRoute = async ({ url }) => {
|
|
456
|
-
try {
|
|
457
|
-
const provider = getDefaultProvider();
|
|
458
|
-
const { Effect } = await import('effect'); // ADDED
|
|
459
|
-
|
|
460
|
-
// Parse and validate parameters...
|
|
461
|
-
|
|
462
|
-
// TODO: Implement embedding generation for semantic search
|
|
463
|
-
// For now, use text-based search via knowledge.list() method
|
|
464
|
-
// When full implementation needed: generate embedding from query string
|
|
465
|
-
// then call: provider.knowledge.search(embedding, { limit, sourceThingId: groupId })
|
|
466
|
-
|
|
467
|
-
let results = await Effect.runPromise( // FIXED
|
|
468
|
-
provider.knowledge.list({
|
|
469
|
-
query: query.trim(),
|
|
470
|
-
knowledgeType: type as any,
|
|
471
|
-
limit: limit * 2, // Get extra to filter
|
|
472
|
-
})
|
|
473
|
-
);
|
|
474
|
-
|
|
475
|
-
// Filter by threshold if provided
|
|
476
|
-
if (threshold > 0) {
|
|
477
|
-
results = results.filter( // WORKS: filter on array
|
|
478
|
-
(item: any) => (item.score || 1) >= threshold
|
|
479
|
-
);
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
// Filter by group if provided
|
|
483
|
-
if (groupId) {
|
|
484
|
-
results = results.filter((item: any) => item.sourceThingId === groupId); // WORKS: filter on array
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
// Limit results
|
|
488
|
-
results = results.slice(0, limit); // WORKS: slice on array
|
|
489
|
-
|
|
490
|
-
return new Response(
|
|
491
|
-
JSON.stringify(
|
|
492
|
-
successResponse({
|
|
493
|
-
results,
|
|
494
|
-
query: query.trim(),
|
|
495
|
-
total: results.length, // WORKS: length on array
|
|
496
|
-
limit,
|
|
497
|
-
})
|
|
498
|
-
),
|
|
499
|
-
// ...
|
|
500
|
-
);
|
|
501
|
-
} catch (error) {
|
|
502
|
-
// ...
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
```
|
|
506
|
-
|
|
507
|
-
---
|
|
508
|
-
|
|
509
|
-
## File 4: src/pages/api/things/index.ts
|
|
510
|
-
|
|
511
|
-
### GET Endpoint
|
|
512
|
-
|
|
513
|
-
#### BEFORE
|
|
514
|
-
```typescript
|
|
515
|
-
export const GET: APIRoute = async ({ url }) => {
|
|
516
|
-
try {
|
|
517
|
-
const provider = getDefaultProvider();
|
|
518
|
-
|
|
519
|
-
// Parse parameters...
|
|
520
|
-
|
|
521
|
-
// Build filter
|
|
522
|
-
const filter: Record<string, any> = {};
|
|
523
|
-
if (type) filter.type = type;
|
|
524
|
-
if (groupId) filter.groupId = groupId;
|
|
525
|
-
if (status) filter.status = status;
|
|
526
|
-
|
|
527
|
-
// List things via provider
|
|
528
|
-
let things = await provider.things.list(filter); // WRONG: No Effect.runPromise
|
|
529
|
-
// TS Error: await has no effect on Effect type
|
|
530
|
-
|
|
531
|
-
// Apply search filter if provided
|
|
532
|
-
if (search) {
|
|
533
|
-
const searchLower = search.toLowerCase();
|
|
534
|
-
things = things.filter((thing) => // ERROR: filter on Effect
|
|
535
|
-
thing.name.toLowerCase().includes(searchLower)
|
|
536
|
-
);
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
// Sort
|
|
540
|
-
const sorted = things.sort((a, b) => { // ERROR: sort on Effect
|
|
541
|
-
const aVal = (a as any)[sort];
|
|
542
|
-
const bVal = (b as any)[sort];
|
|
543
|
-
// ...
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
// Paginate
|
|
547
|
-
const paginated = sorted.slice(offset, offset + limit); // ERROR: slice on Effect
|
|
548
|
-
|
|
549
|
-
return new Response(
|
|
550
|
-
JSON.stringify(
|
|
551
|
-
successResponse({
|
|
552
|
-
things: paginated,
|
|
553
|
-
total: things.length, // ERROR: length on Effect
|
|
554
|
-
limit,
|
|
555
|
-
offset,
|
|
556
|
-
})
|
|
557
|
-
),
|
|
558
|
-
// ...
|
|
559
|
-
);
|
|
560
|
-
} catch (error) {
|
|
561
|
-
// ...
|
|
562
|
-
}
|
|
563
|
-
};
|
|
564
|
-
```
|
|
565
|
-
|
|
566
|
-
#### AFTER
|
|
567
|
-
```typescript
|
|
568
|
-
export const GET: APIRoute = async ({ url }) => {
|
|
569
|
-
try {
|
|
570
|
-
const provider = getDefaultProvider();
|
|
571
|
-
const { Effect } = await import('effect'); // ADDED
|
|
572
|
-
|
|
573
|
-
// Parse parameters...
|
|
574
|
-
|
|
575
|
-
// Build filter
|
|
576
|
-
const filter: Record<string, any> = {};
|
|
577
|
-
if (type) filter.type = type;
|
|
578
|
-
if (groupId) filter.groupId = groupId;
|
|
579
|
-
if (status) filter.status = status;
|
|
580
|
-
|
|
581
|
-
// List things via provider and extract Effect value
|
|
582
|
-
let things = await Effect.runPromise(provider.things.list(filter)); // FIXED
|
|
583
|
-
|
|
584
|
-
// Apply search filter if provided
|
|
585
|
-
if (search) {
|
|
586
|
-
const searchLower = search.toLowerCase();
|
|
587
|
-
things = things.filter((thing) => // WORKS: filter on array
|
|
588
|
-
thing.name.toLowerCase().includes(searchLower)
|
|
589
|
-
);
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
// Sort
|
|
593
|
-
const sorted = things.sort((a, b) => { // WORKS: sort on array
|
|
594
|
-
const aVal = (a as any)[sort];
|
|
595
|
-
const bVal = (b as any)[sort];
|
|
596
|
-
// ...
|
|
597
|
-
});
|
|
598
|
-
|
|
599
|
-
// Paginate
|
|
600
|
-
const paginated = sorted.slice(offset, offset + limit); // WORKS: slice on array
|
|
601
|
-
|
|
602
|
-
return new Response(
|
|
603
|
-
JSON.stringify(
|
|
604
|
-
successResponse({
|
|
605
|
-
things: paginated,
|
|
606
|
-
total: things.length, // WORKS: length on array
|
|
607
|
-
limit,
|
|
608
|
-
offset,
|
|
609
|
-
})
|
|
610
|
-
),
|
|
611
|
-
// ...
|
|
612
|
-
);
|
|
613
|
-
} catch (error) {
|
|
614
|
-
// ...
|
|
615
|
-
}
|
|
616
|
-
};
|
|
617
|
-
```
|
|
618
|
-
|
|
619
|
-
### POST Endpoint
|
|
620
|
-
|
|
621
|
-
#### BEFORE
|
|
622
|
-
```typescript
|
|
623
|
-
export const POST: APIRoute = async ({ request }) => {
|
|
624
|
-
try {
|
|
625
|
-
const provider = getDefaultProvider();
|
|
626
|
-
const body = await request.json();
|
|
627
|
-
|
|
628
|
-
// Validations...
|
|
629
|
-
|
|
630
|
-
// Create thing
|
|
631
|
-
const thing = await provider.things.create({ // WRONG: No Effect.runPromise
|
|
632
|
-
type: body.type,
|
|
633
|
-
name: body.name,
|
|
634
|
-
groupId: body.groupId,
|
|
635
|
-
properties: body.properties || {},
|
|
636
|
-
status: body.status || 'draft',
|
|
637
|
-
});
|
|
638
|
-
// TS Error: await has no effect on Effect type
|
|
639
|
-
// thing is string (ID), but code treats as Thing object
|
|
640
|
-
|
|
641
|
-
return new Response(JSON.stringify(successResponse(thing)), { // WRONG TYPE
|
|
642
|
-
status: 201,
|
|
643
|
-
// ...
|
|
644
|
-
});
|
|
645
|
-
} catch (error) {
|
|
646
|
-
// ...
|
|
647
|
-
}
|
|
648
|
-
};
|
|
649
|
-
```
|
|
650
|
-
|
|
651
|
-
#### AFTER
|
|
652
|
-
```typescript
|
|
653
|
-
export const POST: APIRoute = async ({ request }) => {
|
|
654
|
-
try {
|
|
655
|
-
const provider = getDefaultProvider();
|
|
656
|
-
const { Effect } = await import('effect'); // ADDED
|
|
657
|
-
const body = await request.json();
|
|
658
|
-
|
|
659
|
-
// Validations...
|
|
660
|
-
|
|
661
|
-
// Create thing and extract Effect value
|
|
662
|
-
const thingId = await Effect.runPromise( // FIXED
|
|
663
|
-
provider.things.create({
|
|
664
|
-
type: body.type,
|
|
665
|
-
name: body.name,
|
|
666
|
-
groupId: body.groupId,
|
|
667
|
-
properties: body.properties || {},
|
|
668
|
-
status: body.status || 'draft',
|
|
669
|
-
})
|
|
670
|
-
);
|
|
671
|
-
|
|
672
|
-
return new Response(JSON.stringify(successResponse({ _id: thingId })), { // FIXED
|
|
673
|
-
status: 201,
|
|
674
|
-
// ...
|
|
675
|
-
});
|
|
676
|
-
} catch (error) {
|
|
677
|
-
// ...
|
|
678
|
-
}
|
|
679
|
-
};
|
|
680
|
-
```
|
|
681
|
-
|
|
682
|
-
---
|
|
683
|
-
|
|
684
|
-
## File 5: src/pages/api/things/[id].ts
|
|
685
|
-
|
|
686
|
-
### GET Endpoint
|
|
687
|
-
|
|
688
|
-
#### BEFORE
|
|
689
|
-
```typescript
|
|
690
|
-
export const GET: APIRoute = async ({ params }) => {
|
|
691
|
-
try {
|
|
692
|
-
const provider = getDefaultProvider();
|
|
693
|
-
const id = params.id;
|
|
694
|
-
|
|
695
|
-
if (!id) {
|
|
696
|
-
// error response
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
const thing = await provider.things.get(id); // WRONG: No Effect.runPromise
|
|
700
|
-
// TS Error: await has no effect on Effect type
|
|
701
|
-
|
|
702
|
-
if (!thing) { // ERROR: thing is Effect, not Thing
|
|
703
|
-
// error response
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
return new Response(JSON.stringify(successResponse(thing)), {
|
|
707
|
-
status: 200,
|
|
708
|
-
// ...
|
|
709
|
-
});
|
|
710
|
-
} catch (error) {
|
|
711
|
-
// ...
|
|
712
|
-
}
|
|
713
|
-
};
|
|
714
|
-
```
|
|
715
|
-
|
|
716
|
-
#### AFTER
|
|
717
|
-
```typescript
|
|
718
|
-
export const GET: APIRoute = async ({ params }) => {
|
|
719
|
-
try {
|
|
720
|
-
const provider = getDefaultProvider();
|
|
721
|
-
const { Effect } = await import('effect'); // ADDED
|
|
722
|
-
const id = params.id;
|
|
723
|
-
|
|
724
|
-
if (!id) {
|
|
725
|
-
// error response
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
const thing = await Effect.runPromise(provider.things.get(id)); // FIXED
|
|
729
|
-
|
|
730
|
-
if (!thing) { // WORKS: thing is Thing or throws error
|
|
731
|
-
// error response
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
return new Response(JSON.stringify(successResponse(thing)), {
|
|
735
|
-
status: 200,
|
|
736
|
-
// ...
|
|
737
|
-
});
|
|
738
|
-
} catch (error) {
|
|
739
|
-
// ...
|
|
740
|
-
}
|
|
741
|
-
};
|
|
742
|
-
```
|
|
743
|
-
|
|
744
|
-
### PUT Endpoint
|
|
745
|
-
|
|
746
|
-
#### BEFORE
|
|
747
|
-
```typescript
|
|
748
|
-
export const PUT: APIRoute = async ({ params, request }) => {
|
|
749
|
-
try {
|
|
750
|
-
const provider = getDefaultProvider();
|
|
751
|
-
const id = params.id;
|
|
752
|
-
|
|
753
|
-
if (!id) {
|
|
754
|
-
// error response
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
// Verify thing exists
|
|
758
|
-
const existing = await provider.things.get(id); // WRONG: No Effect.runPromise
|
|
759
|
-
// TS Error: await has no effect on Effect type
|
|
760
|
-
if (!existing) {
|
|
761
|
-
// error response
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
const body = await request.json();
|
|
765
|
-
|
|
766
|
-
// Update thing
|
|
767
|
-
const updated = await provider.things.update(id, { // WRONG: No Effect.runPromise
|
|
768
|
-
// ...
|
|
769
|
-
});
|
|
770
|
-
// TS Error: await has no effect on Effect type
|
|
771
|
-
// updated is void, not an object
|
|
772
|
-
|
|
773
|
-
return new Response(JSON.stringify(successResponse(updated)), { // WRONG TYPE
|
|
774
|
-
status: 200,
|
|
775
|
-
// ...
|
|
776
|
-
});
|
|
777
|
-
} catch (error) {
|
|
778
|
-
// ...
|
|
779
|
-
}
|
|
780
|
-
};
|
|
781
|
-
```
|
|
782
|
-
|
|
783
|
-
#### AFTER
|
|
784
|
-
```typescript
|
|
785
|
-
export const PUT: APIRoute = async ({ params, request }) => {
|
|
786
|
-
try {
|
|
787
|
-
const provider = getDefaultProvider();
|
|
788
|
-
const { Effect } = await import('effect'); // ADDED
|
|
789
|
-
const id = params.id;
|
|
790
|
-
|
|
791
|
-
if (!id) {
|
|
792
|
-
// error response
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
// Verify thing exists and extract Effect value
|
|
796
|
-
const existing = await Effect.runPromise(provider.things.get(id)); // FIXED
|
|
797
|
-
if (!existing) {
|
|
798
|
-
// error response
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
const body = await request.json();
|
|
802
|
-
|
|
803
|
-
// Update thing and extract Effect value
|
|
804
|
-
await Effect.runPromise( // FIXED
|
|
805
|
-
provider.things.update(id, {
|
|
806
|
-
// ...
|
|
807
|
-
})
|
|
808
|
-
);
|
|
809
|
-
|
|
810
|
-
return new Response(
|
|
811
|
-
JSON.stringify(
|
|
812
|
-
successResponse({ // FIXED: Reconstruct object
|
|
813
|
-
_id: id,
|
|
814
|
-
name: body.name || existing.name,
|
|
815
|
-
properties: body.properties
|
|
816
|
-
? { ...existing.properties, ...body.properties }
|
|
817
|
-
: existing.properties,
|
|
818
|
-
status: body.status || existing.status,
|
|
819
|
-
})
|
|
820
|
-
),
|
|
821
|
-
{
|
|
822
|
-
status: 200,
|
|
823
|
-
// ...
|
|
824
|
-
}
|
|
825
|
-
);
|
|
826
|
-
} catch (error) {
|
|
827
|
-
// ...
|
|
828
|
-
}
|
|
829
|
-
};
|
|
830
|
-
```
|
|
831
|
-
|
|
832
|
-
---
|
|
833
|
-
|
|
834
|
-
## File 6: src/pages/api/people/[id].ts
|
|
835
|
-
|
|
836
|
-
#### BEFORE
|
|
837
|
-
```typescript
|
|
838
|
-
export const GET: APIRoute = async ({ params }) => {
|
|
839
|
-
try {
|
|
840
|
-
const provider = getDefaultProvider();
|
|
841
|
-
const id = params.id;
|
|
842
|
-
|
|
843
|
-
if (!id) {
|
|
844
|
-
// error response
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
const person = await provider.people.get(id); // WRONG: No Effect.runPromise, wrong property
|
|
848
|
-
|
|
849
|
-
if (!person) { // ERROR: person is Effect
|
|
850
|
-
// error response
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
return new Response(JSON.stringify(successResponse(person)), {
|
|
854
|
-
status: 200,
|
|
855
|
-
// ...
|
|
856
|
-
});
|
|
857
|
-
} catch (error) {
|
|
858
|
-
// ...
|
|
859
|
-
}
|
|
860
|
-
};
|
|
861
|
-
```
|
|
862
|
-
|
|
863
|
-
#### AFTER
|
|
864
|
-
```typescript
|
|
865
|
-
export const GET: APIRoute = async ({ params }) => {
|
|
866
|
-
try {
|
|
867
|
-
const provider = getDefaultProvider();
|
|
868
|
-
const { Effect } = await import('effect'); // ADDED
|
|
869
|
-
|
|
870
|
-
const id = params.id;
|
|
871
|
-
|
|
872
|
-
if (!id) {
|
|
873
|
-
// error response
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
// People are Things with type: 'creator'
|
|
877
|
-
const person = await Effect.runPromise(provider.things.get(id)); // FIXED
|
|
878
|
-
|
|
879
|
-
if (!person) {
|
|
880
|
-
// error response
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
// Verify it's a person (type: 'creator')
|
|
884
|
-
if (person.type !== 'creator') { // ADDED: Validation
|
|
885
|
-
// error response
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
return new Response(JSON.stringify(successResponse(person)), {
|
|
889
|
-
status: 200,
|
|
890
|
-
// ...
|
|
891
|
-
});
|
|
892
|
-
} catch (error) {
|
|
893
|
-
// ...
|
|
894
|
-
}
|
|
895
|
-
};
|
|
896
|
-
```
|
|
897
|
-
|
|
898
|
-
---
|
|
899
|
-
|
|
900
|
-
## File 7: src/pages/api/people/me.ts
|
|
901
|
-
|
|
902
|
-
#### BEFORE
|
|
903
|
-
```typescript
|
|
904
|
-
export const GET: APIRoute = async ({ request, cookies }) => {
|
|
905
|
-
try {
|
|
906
|
-
const provider = getDefaultProvider();
|
|
907
|
-
|
|
908
|
-
// In a real implementation, extract user from session cookie
|
|
909
|
-
// For now, we'll get the current user via the provider
|
|
910
|
-
const currentUser = await provider.people.current(); // WRONG: No Effect.runPromise, wrong property
|
|
911
|
-
// TS Error: 'people' property doesn't exist on DataProvider
|
|
912
|
-
|
|
913
|
-
if (!currentUser) {
|
|
914
|
-
// error response
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
return new Response(JSON.stringify(successResponse(currentUser)), {
|
|
918
|
-
status: 200,
|
|
919
|
-
// ...
|
|
920
|
-
});
|
|
921
|
-
} catch (error) {
|
|
922
|
-
// ...
|
|
923
|
-
}
|
|
924
|
-
};
|
|
925
|
-
```
|
|
926
|
-
|
|
927
|
-
#### AFTER
|
|
928
|
-
```typescript
|
|
929
|
-
export const GET: APIRoute = async ({ request, cookies }) => {
|
|
930
|
-
try {
|
|
931
|
-
const provider = getDefaultProvider();
|
|
932
|
-
const { Effect } = await import('effect'); // ADDED
|
|
933
|
-
|
|
934
|
-
// Get current authenticated user via auth provider
|
|
935
|
-
const currentUser = await Effect.runPromise( // FIXED
|
|
936
|
-
provider.auth.getCurrentUser() // FIXED: Use auth not people
|
|
937
|
-
);
|
|
938
|
-
|
|
939
|
-
if (!currentUser) {
|
|
940
|
-
// error response
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
// Return user as a person object
|
|
944
|
-
return new Response(
|
|
945
|
-
JSON.stringify(
|
|
946
|
-
successResponse({ // FIXED: Return proper object
|
|
947
|
-
id: currentUser.id,
|
|
948
|
-
email: currentUser.email,
|
|
949
|
-
name: currentUser.name,
|
|
950
|
-
emailVerified: currentUser.emailVerified,
|
|
951
|
-
})
|
|
952
|
-
),
|
|
953
|
-
{
|
|
954
|
-
status: 200,
|
|
955
|
-
// ...
|
|
956
|
-
}
|
|
957
|
-
);
|
|
958
|
-
} catch (error) {
|
|
959
|
-
// ...
|
|
960
|
-
}
|
|
961
|
-
};
|
|
962
|
-
```
|
|
963
|
-
|
|
964
|
-
---
|
|
965
|
-
|
|
966
|
-
## Summary of Changes
|
|
967
|
-
|
|
968
|
-
| File | GET | POST | PUT | Errors Fixed |
|
|
969
|
-
|------|-----|------|-----|--------------|
|
|
970
|
-
| connections/index.ts | ✅ | ✅ | - | 3 (names, runPromise) |
|
|
971
|
-
| events/index.ts | ✅ | ✅ | - | 4 (names, method, runPromise) |
|
|
972
|
-
| knowledge/search.ts | ✅ | - | - | 3 (method, runPromise) |
|
|
973
|
-
| things/index.ts | ✅ | ✅ | - | 3 (runPromise) |
|
|
974
|
-
| things/[id].ts | ✅ | - | ✅ | 4 (runPromise) |
|
|
975
|
-
| people/[id].ts | ✅ | - | - | 2 (property, runPromise) |
|
|
976
|
-
| people/me.ts | ✅ | - | - | 2 (property, runPromise) |
|
|
977
|
-
|
|
978
|
-
**Total: 7 files, 13 endpoints, 21 errors fixed**
|