Migrate all plugins and shared packages to the new Resource-layer methods
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
Tracking issue for migrating all Kolibri plugin code from the old resource-layer methods to the new, simpler ones added in #15056. Once every plugin has been moved over, a later issue can safely remove the old methods. This issue holds the shared migration recipe; the actual work is split into one task per plugin.
Scope
In scope — migrate each of these to the new methods (one child task each):
coachdevicefacilitylearnpoliciessetup_wizarduser_authuser_profilepackages/kolibripackages/kolibri-common
Out of scope (handled in other issues):
- Adding the new methods (done in #15056).
- Removing the old methods and cache-management helpers.
- Recovering
_v2custom method names back to their originals. - Moving scattered
clientcalls into resources. - Cross-package type inference improvements.
Strategy
Every child task applies the same recipe to one plugin/package. All of this is additive-safe: the new methods already exist (#15056) and the old ones still work until a later removal issue.
1. Replace old base-method calls with the new ones:
| Old | New |
|---|---|
fetchModel |
retrieve |
fetchCollection |
list |
createModel |
create |
saveModel (new object) |
create |
saveModel (existing object) |
update/useUpdate* (se below) |
deleteModel |
delete |
saveCollection |
bulkCreate |
deleteCollection |
bulkDelete |
raw get / list / create |
retrieve / list / create |
fetchDetailModel, fetchDetailCollection, fetchListCollection, getListEndpoint, postDetailEndpoint, postListEndpoint, accessDetailEndpoint, accessListEndpoint |
the new request primitive (via retrieve/list shaping, or the custom method's own request call) |
2. Remove cache-management calls that no longer mean anything: clearCache, getModel, getCollection, addModel, findModel, removeModel, removeCollection, unCacheModel, unCacheCollection.
3. For custom methods the plugin/package uses:
- If the custom method's Resource is defined and used only within this same plugin, rewrite the method to build on the new
requestprimitive. - If the custom method is on a shared resource (used by more than one plugin/package — e.g. resources in
kolibri-common), add a parallel method with a_v2suffix (e.g.createuseronremote→createuseronremote_v2) that usesrequest, and point this plugin at the_v2name. Leave the original method in place so other not-yet-migrated consumers keep working. _v2methods will be removed in a future issue, so please do not leave any unnecessary comments about the method it will replace (flagging differences, etc), because we will remove them anyway.
4. Reactive reads should use the useRetrieve / useList composables where applicable; if it will become a large refactor, then omit it.
5. Updates
- The new
updatemethod introduced a difference: Now it does not compute the payload diff automatically; instead, it receives abaselineobject to compute the diff. This means now it's the consumer's responsibility to keep a snapshot of the object being updated.- For simple updates like a toggle switch, this is not relevant, but for patches of large objects we will need to store the `baseline.
- For these large objects, we should migrate the code to use the
Resource.useUpdatecomposable instead; this composable abstracts the baseline snapshots and sends the baseline properly to the update method.
5. Preferences
- For new methods, always prefer
async/await, no matter if all other methods in the same class/module use callbacks. - New methods for custom actions should use arg/param names consistent with the new Resource API. (e.g.
paramsinstead ofgetParamseven if the method being replaced usesgetParams)
Testing Requirements
Migration is behavior-preserving. Each child task should keep the plugin/package's existing tests passing (pnpm test-jest), with no change to runtime behavior — only the resource methods being called change. Also check for tests that call or mock the replaced methods (e.g. mocking fetchModel, fetchCollection, clearCache) and update them to use/mock the new methods accordingly.
Acceptance Criteria
- [ ] Every plugin/package in Scope has a completed migration task.
- [ ] No in-scope code calls the old base methods or cache-management helpers.
- [ ] Shared-resource custom methods used by migrated code exist in
_v2form; originals remain for not-yet-migrated consumers. - [ ] Existing tests pass across all migrated plugins/packages.
AI usage
I used Claude Code to help draft this tracking issue, and its migration recipe from my notes on the resource-layer refactor plan. I reviewed and edited the content and confirmed the scope and plugin list myself.
Watching for resolution on behalf of learningequality/kolibri#15061.
All subissues are already closed.