farmOS / field-kit

A modular, offline-first companion app to farmOS.
https://farmOS.org
GNU General Public License v3.0
59 stars 38 forks source link

farmConnect library in farmOS.js 2.x #430

Closed jgaehring closed 3 years ago

jgaehring commented 3 years ago

The first step in providing support for farmOS 2.x is to replicate the networking methods in farmOS.js that currently connect to a 1.x server. Unlike farmOS.js 1.x, this will not comprise the entirety of the farmOS.js library, but will only be one library, what I'm currently calling farmConnect, among a collection of libraries which will also include farmData, the successor to farmLog.

Here are the main features and the order in which I think makes sense to try to implement them.

This should cover all the basic operations needed for Field Kit. The JSON Schema part will be critical to the next phase of development, farmData.

jgaehring commented 3 years ago

Made some good progress with farmOS/farmOS.js@527d4f4. Although there's still plenty more I could do to extend the functionality of the filter option, and I haven't even touched options like sort and page, I think this is a good start and should probably meet most of the needs of Field Kit for now. I can come back later to work on those other options as necessity dictates.

The next steps are going to require some rewriting of the helper functions, like request and batchRequest, but that should be a good opportunity to reorganize things in general so we don't just have one big monster file with index.js.

With those changes I should be pretty set with log.get, and hopefully all the other get methods too, and should be able to procede directly to the send methods.

jgaehring commented 3 years ago

Oh, I'm also going to have to figure out how to handle requests for undefined types. I think I'd like to allow farmData to plug in to this part of the process, and provide its list of all available types, but I should also have a default behavior that simply throws if the type is not provided. I can probably stub the farmData functionality for now, just to get some basic functionality.

jgaehring commented 3 years ago

I think the essential methods are all in place now. As I mentioned above, sort and page options may just have to wait until there's a clear need. I should probably write some tests for refreshToken and revokeToken, but as long as they appear to be working I'm just going to push ahead.

I scratched the main area methods off the list b/c they seem redundant now that they're just location assets.

Last remaining issue that will be required for FK is the area.geojson() method. As far as I know, there is no dedicated endpoint for this implemented on the server, as of yet. It may be possible to just apply some kind of filter to get the geojson we need, w/o a special endpoint, but I'm going to wait and see what can be done once we actually need to integrate this into FK.

For now, I'm closing this issue and moving on to #431!