v0.1 was about basic "push" functionality which is done.
v0.2 is about refactoring this to be more elegant and support for reading/writing metadata
This is relatively raw low level APIs.
client = Client(...)
client.action_api(...)
// create a dataset (or overwrite existing one) - just puts metadata (file uploading is separate)
client.push(datasetMetadata)
// longform of previous item
resource = open(path) # f11s.Resource object
// this uploads just the data to storage ...
// resource has .stream,
client.pushBlob(resource)
// f11s.Dataset({metadata})
// so can do dataset.descriptor
dataset = client.retrieve(dataset_name)
dataset.resources.push(resource.descriptor)
client.push(dataset)
// bonus
// convenience function
// dataset must exist
client.pushResource(f11s_resource, dataset=dataset_name)
// convenience
client.pushResourceMetadata(...) # only save resource metadata ...
// GET functions
client.retrieve(dataset_id_or_name)
// BONUS
client.retrieveResource(resource_id OR dataset_id + resource_name)
import data.js as f11s
import ckanclient
// resource is a data.js file object from a browser file selection
resource = filereader object wrapped ...
dataset = {
descriptor:
name: ...
resources:
}
dataset.descriptor => Frictionless formatted object for a dataset ...
Client.action_api = async function(action, payload) {
}
Client.put = async function(f11s_dataset) {
ckan_metadata = f11s2ckan.dataset(f11s_dataset.descriptor)
// https://docs.ckan.org/en/2.9/api/index.html#ckan.logic.action.create.package_create
// see existing code https://github.com/okfn/ckan.js#catalog
await res = client.action_api('package_create', ckan_metadata)
return res
}