Jellyfish Client SDK
This is a client side library to interact with the Jellyfish API.
It's meant to provide high level useful functionality to the web UI and any other clients.
Usage
Below is an example how to use Jellyfish:
import { getSdk } from "@balena/jellyfish-client-sdk";
const sdk = getSdk({
apiUrl: "https://api.ly.fish",
apiPrefix: "api/v2/",
});
(async () => {
const sessionContract = await sdk.auth.login({
username: "jellyfish",
password: "jellyfish",
});
if (sessionContract) {
sdk.setAuthToken(sessionContract.id);
const channelContracts = await sdk.card.getAllByType('channel@1.0.0');
console.log('channelContracts:', JSON.stringify(channelContracts, null, 2));
const userContract = await window.sdk.query({
type: 'object',
properties: {
type: {
const: 'user@1.0.0',
},
slug: {
const: 'user-foobar',
},
},
});
console.log('userContract:', JSON.stringify(userContract, null, 2));
const userContractWithLinks = await window.sdk.query({
type: 'object',
properties: {
type: {
const: 'user@1.0.0',
},
slug: {
const: 'user-foobar',
},
},
$$links: {
'is member of': {
type: 'object',
},
},
});
console.log('userContractWithLinks:', JSON.stringify(userContractWithLinks, null, 2));
}
})();