Skip to content

feat(api): wire Nest API to @worksight/common types and fixtures (#17) - #24

Closed
kuyacarlo wants to merge 1 commit into
feat/mvp-stabilizefrom
feat/mvp-wire-api-17
Closed

feat(api): wire Nest API to @worksight/common types and fixtures (#17)#24
kuyacarlo wants to merge 1 commit into
feat/mvp-stabilizefrom
feat/mvp-wire-api-17

Conversation

@kuyacarlo

Copy link
Copy Markdown
Contributor

Closes #17. Parent: #14.

Summary

  • Nest API now serves the shared @worksight/common contract: GET /users, /users/:id, /users/stats, /teams, /teams/:id return EmployeeProfile/Team fixtures; new tasks module serves GET /tasks (with ?employee_id= filter), /tasks/:id, /tasks/stats/:employeeId, and /activities as Assignment/Activity. The placeholder users controller (hardcoded junk strings) is gone.
  • Fixed the API build silently emitting nothing: apps/api/tsconfig.json inherited noEmit: true from the root, so nest build produced an empty dist/ and start:prod could never work. Now emits CommonJS, resolves @worksight/common against its built dist (matching runtime), and a new tsconfig.build.json keeps specs out of dist/.
  • Fixed @worksight/common's dist being unloadable by Node: tsc emitted ESM with extensionless directory imports (export * from './data'). The build now runs tsc-alias --resolve-full-paths (already a devDependency).
  • Fixed BaseLookup.filter() reconstructing subclasses as new Cls(schema, entries) while subclasses take (entries) — every chained filter/getById/stat silently returned garbage (e.g. /users/:id 404'd for real ids). Also fixed department stats matching a string against the array-valued department field.
  • Added jest specs for UsersService/TasksService asserting responses equal the shared fixtures; added node + jest globals to the root eslint config (API lint previously failed on process is not defined at baseline).

Verification (all run locally, Node v22.22.2)

pnpm install                              # ok
pnpm --filter @worksight/common build     # tsc -b && tsc-alias, ok
pnpm --filter @worksight/api build        # nest build, dist/ now populated
pnpm type-check                           # turbo: 7/7 tasks successful
pnpm lint                                 # turbo: 7/7 tasks successful
pnpm --filter @worksight/api test         # 2 suites, 10 tests passed

Runtime smoke test (PORT=3123 node apps/api/dist/main.js):

GET /users            -> 11 employees (EmployeeProfile[])
GET /users/7f1fcc2a-… -> System Admin / super_admin
GET /users/stats      -> totals + role/department counts
GET /tasks            -> 8 assignments; ?employee_id= filters to 4
GET /tasks/stats/:id  -> totalTasks 4, workLifeBalanceScore 65
GET /activities       -> 14 activities
GET /teams            -> 5 teams
GET /users/nope       -> 404

Remaining gaps

  • Responses are fixture-backed only; no DB/Supabase reads yet (fine for MVP per handoff).
  • Attendance/survey/burnout types exist in common but have no endpoints; attendance module is still commented out in app.module.ts.
  • Several employee fixture ids in common are not valid UUIDs, so strict EmployeeProfileSchema.parse would fail even though TS shapes match.
  • API type-check/build requires pnpm --filter @worksight/common build first when run directly (turbo's ^build handles this in pipeline runs).

Handoff doc updated: docs/handoffs/2026-07-25-wire-api-common.md.

Made with Cursor

Serve users/teams/tasks/activities endpoints from the shared
@worksight/common contract instead of placeholder responses, so web and
API agree on payload shapes.

- users module returns EmployeeProfile/Team fixtures; new tasks module
  returns Assignment/Activity fixtures, all typed from common
- fix api build emitting nothing (inherited noEmit) and switch to CJS
  emit resolved against the built common dist; add tsconfig.build.json
- fix common dist being unloadable ESM (directory imports) via
  tsc-alias --resolve-full-paths in the build script
- fix BaseLookup.filter() constructing subclasses with the wrong
  argument order, which broke every chained lookup/getById
- fix department stats matching against array-valued departments
- add jest specs for both services; add node/jest globals to eslint

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Jul 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
worksight Ready Ready Preview, Comment Jul 25, 2026 3:26am
worksight-api Ready Ready Preview, Comment Jul 25, 2026 3:26am
worksight-docs Ready Ready Preview, Comment Jul 25, 2026 3:26am

@kuyacarlo

Copy link
Copy Markdown
Contributor Author

Rolled up into #27 (feat/mvp-integration), which merges the MVP stack against canary and is verified end to end (type-check, lint, API tests, all three builds, plus a live API + web smoke through /demo). This PR stays open for per-workstream review.

@kuyacarlo

Copy link
Copy Markdown
Contributor Author

Rolled into #27 (merged to canary). Closing child PR.

@kuyacarlo kuyacarlo closed this Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant