Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

921 B
Raw Blame
import { create } from "@bufbuild/protobuf";
import { FieldMaskSchema } from "@bufbuild/protobuf/wkt";
import type { MemoSaveOperations } from "@/components/MemoEditor/edit/services/memoService";
import { memoServiceClient } from "@/connect";
import { MemoSchema } from "@/types/proto/api/memo_service_pb";

/**
 * Save operations over the bare (mocked) client, shaping requests as the memo
 * mutation hooks do, for tests of the service's own logic.
 */
export const clientSaveOperations: MemoSaveOperations = {
  getMemo: (name) => memoServiceClient.getMemo({ name }),
  updateMemo: (update, paths) =>
    memoServiceClient.updateMemo({
      memo: create(MemoSchema, update as Record<string, unknown>),
      updateMask: create(FieldMaskSchema, { paths }),
    }),
  createMemo: (memo, parent) =>
    parent ? memoServiceClient.createMemoComment({ parent, comment: memo }) : memoServiceClient.createMemo({ memo }),
};