@dpkit/ckan
Version:
Fast TypeScript data management framework built on top of the Data Package standard and Polars DataFrames
35 lines (27 loc) • 850 B
text/typescript
import type { Resource } from "@dpkit/core"
import type { CkanResource } from "../Resource.js"
/**
* Denormalizes a Frictionless Data Resource to CKAN Resource format
* @param props Object containing the Resource to denormalize
* @returns Denormalized CKAN Resource object
*/
export function denormalizeCkanResource(resource: Resource) {
const ckanResource: Partial<CkanResource> = {}
if (resource.description) {
ckanResource.description = resource.description
}
if (resource.format) {
// CKAN format is traditionally uppercase
ckanResource.format = resource.format.toUpperCase()
}
if (resource.mediatype) {
ckanResource.mimetype = resource.mediatype
}
if (resource.bytes) {
ckanResource.size = resource.bytes
}
if (resource.hash) {
ckanResource.hash = resource.hash
}
return ckanResource
}