0.0.9 • Published 2 years ago
vd2hc v0.0.9
vd2hc
vd2hc is designed to interact with VoiceDeck's CMS and transform them into HypercertMetadata. It includes two primary functions:
fetchReports: Retrieves all reports from VoiceDeck CMS that have apublishedstatus and where thehypercert_idfield is null.transformToHypercertData: Takes aReportobject, as defined insrc/types/report.ts, and converts it into aHypercertMetadataobject compatible with the Hypercerts.
Prerequisites
Before installing vd2hc, make sure you are using Node.js version 18 or higher.
Installation
To install the library, run the following command:
npm install vd2hc@0.0.9Usage
To use the library, you need to import the fetchReports and transformToHypercertData functions. Here's a basic example:
import { fetchReports, transformToHypercertData } from 'vd2hc';
import { validateMetaData, validateClaimData } from "@hypercerts-org/sdk";
const VD_REPORTS_ENDPOINT = 'https://directus.vd-dev.org/';
const response = await fetchReports(VD_REPORTS_ENDPOINT);
const hypercerts = response.data.map(report => {
const metadata = transformToHypercertData(report);
// Validate metadata
const isMetadataValid = validateMetaData(metadata);
if (!isMetadataValid) {
throw new Error('Invalid metadata');
}
// Validate claimData
const isClaimDataValid = validateClaimData(metadata.hypercert);
if (!isClaimDataValid) {
throw new Error('Invalid claim data');
}
return metadata;
});Build
pnpm install
pnpm buildTest
pnpm test