kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Move scattered client() calls into the appropriate Resources

Open AlexVelezLl opened this issue 4 months ago • 1 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

Move raw client(...) API calls that currently live outside the resource layer — in components, composables, and vuex modules — into the appropriate Resource as proper methods, so API access is centralized in resources. Calls whose endpoint has no corresponding resource, or that are genuine one-offs, can stay as-is.

Complexity: Medium Target branch: develop

Context

Some API calls bypass the resource layer entirely — a component or vuex module imports kolibri/client and calls a urls[...] endpoint directly (e.g. the facility CSV endpoints). This scatters API access and duplicates the URL/handling logic that resources are meant to own. Around 40 files across plugins and shared packages do this today.

The Change

For each raw client(...) call made outside the resource layer:

  • If the endpoint belongs to a viewset that has (or should have) a Resource, move the call into that Resource as a method (built on the new request primitive) and update the caller to use it.
  • Leave the call in place when the endpoint has no natural resource home — e.g. it targets a different viewset than any resource's own, or it's a genuine standalone endpoint. These are acceptable, contained exceptions.

Out of Scope

Handled in other issues:

  • Migrating existing resource-method calls to the new methods (#15057).
  • Removing the old methods and _v2 scaffolding (#15068).
  • Cross-package type inference improvements.
  • Documentation updates.

Acceptance Criteria

  • [ ] Raw client(...) calls outside resources are moved into the appropriate Resource wherever the endpoint has a resource home.
  • [ ] Moved calls are implemented as Resource methods built on request, and their callers use those methods.
  • [ ] Remaining direct client usages are only genuine exceptions (no resource home / cross-viewset one-offs).
  • [ ] Existing tests pass; tests covering moved calls are updated.

AI usage

I used Claude Code to help draft this issue from the resource-layer refactor plan. I reviewed and edited it and confirmed the scope myself.

AlexVelezLl avatar Jul 23 '26 15:07 AlexVelezLl

Plan: Move every raw client({ url: urls[...] }) call that targets a router-registered viewset out of components/composables/vuex modules and into a Resource method built on request.

  • [ ] Baseline
  • [ ] Bookmarks onto BookmarksResource
  • [ ] TrackProgressResource
  • [ ] FacilityDatasetResource pin and login-settings actions
  • [ ] FacilityResource.createFacility
  • [ ] PluginsResource and DriveInfoResource
  • [ ] Peer facilities onto NetworkLocationResource.fetchFacilities_v2
  • [ ] SessionResource and useUser.login
  • [ ] Acceptance sweep and live replay
  • [ ] Self-review the produced code

@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
  • Ran the project's full test suite and linter before committing
  • For UI changes: captured live screenshots to verify rendering
  • For backend changes: verified with example API/CLI output

rtibblesbot avatar Aug 31 '26 14:08 rtibblesbot