Hi everyone,
in the current deployment, we made a breaking change to wikibase.RepoApi. We will do another breaking change to it in the next deployment. If you use RepoApi on wikidata.org or any Wikidata client wiki, please read these instructions on how to migrate your code.
== Use case 1: RepoApi.get, RepoApi.post ==
You exclusively use RepoApi.get or RepoApi.post.
You can and will have to use a mw.Api directly.
If you are on wikidata.org, just use the following:
var api = new mw.Api(); // api.get( { … } ); // api.post( { … } );
If you are on a Wikidata client wiki, use the new wikibase.client.getMwApiForRepo:
mw.loader.using( [ 'wikibase.client.getMwApiForRepo' ] ).done( function() { var api = wikibase.client.getMwApiForRepo(); // api.get( { … } ); // api.post( { … } ); } );
In this case, I would encourage you to look into the features RepoApi provides. Chances are RepoApi could build your api call for you.
== Use case 2: RepoApi's wrapper methods ==
You use one of RepoApi.createEntity, RepoApi.editEntity, RepoApi.formatValue, RepoApi.getEntities, RepoApi.getEntitiesByPage, RepoApi.parseValue, RepoApi.searchEntities, RepoApi.setLabel, RepoApi.setDescription, RepoApi.setAliases, RepoApi.setClaim, RepoApi.createClaim, RepoApi.removeClaim, RepoApi.getClaims, RepoApi.setClaimValue, RepoApi.setReference, RepoApi.removeReferences, RepoApi.setSitelink, or RepoApi.mergeItems.
You should continue using RepoApi, but have to provide it a mw.Api instance.
If you are on wikidata.org, just use the following:
mw.loader.using( [ 'wikibase.RepoApi' ] ).done( function() { var mwApi = new mw.Api(); var repoApi = new wikibase.RepoApi( mwApi ); // mwApi.get( { … } ); // mwApi.post( { … } ); // repoApi.setClaim( … ); } );
If you are on a Wikidata client wiki, use the new wikibase.client.getMwApiForRepo:
mw.loader.using( [ 'wikibase.client.getMwApiForRepo' ] ).done( function() { var mwApi = wikibase.client.getMwApiForRepo(); var repoApi = new wikibase.RepoApi( mwApi ); // mwApi.get( { … } ); // mwApi.post( { … } ); // repoApi.setClaim( … ); } );
If you have any questions, feel free to contact me.
Bye, Adrian