Skip to content

Release v4.0.0

Compare
Choose a tag to compare
@akord-service akord-service released this 25 Apr 09:10

includes breaking changes

  • auth module
    • separate authentication into independent module
    • handle token refresh in the background for browser scenarios
    • API key for server-side scenarios
    • token storage configuration (memoryStorage, localStorage, sessionStorage, etc.)
// to authenticate in this version
import { Akord, Auth } from "@akord/akord-js";
const { wallet } = await Auth.signIn(email, password);
const akord = await Akord.init(wallet);
  • fully move to the new API
  • vault & membership pagination
// to get all user vaults in this version
const vaults = await akord.vault.listAll();

// or iterate through all user vaults
let token = undefined;
let vaults = [];
do {
  const { items, nextToken } = await akord.vault.list({ nextToken: token });
  vaults = vaults.concat(items);
  token = nextToken;
} while (token);
// to create a private vault
const { vaultId } = await akord.vault.create("my private vault");

// to create a public vault with terms of access
const { vaultId } = await akord.vault.create(
  "my public vault",
  { public: true, termsOfAccess: "terms of access here - if the vault is intended for professional or legal use, you can add terms of access and they must be digitally signed before accessing the vault" }
);

// to list all stacks within the given folder
const stacks = await akord.stack.listAll(vaultId, { parentId: folderId });

// to create a stack in an existing folder
import { NodeJs } from "@akord/akord-js/lib/types/file";
const file = await NodeJs.File.fromPath("path to your file");
const { stackId } = await akord.stack.create(vaultId, file, "your stack name", { parentId: folderId });

// to create a JSON note
const { noteId } = await akord.note.create(
  vaultId,
  JSON.stringify({ name: "My first JSON note" }),
  "My first JSON note",
  { parentId: parentId, mimeType: "application/json" }
);
  • general code cleanup & bug fixes
  • improved error handling
  • return object on create/update
// create new folder
const { folderId, object } = await akord.folder.create(vaultId, "new folder");
// display newly created folder
console.log(object);
// to get the vault with all its content (memos, folders, etc.)
const vault = await akord.vault.get(vaultId, { deep: true });