Feature: Basic Events, Models and Projections #2

Merged
piarrot merged 37 commits from feat-base-projections into main 2024-10-15 15:20:25 -03:00
Showing only changes of commit 3afdb5d230 - Show all commits

View File

@ -1,19 +1,14 @@
import { isRecord } from "@fabric/core"; import { isRecord } from "@fabric/core";
import validator from "validator";
import { InMemoryFile } from "./in-memory-file.js"; import { InMemoryFile } from "./in-memory-file.js";
const { isBase64, isMimeType } = validator;
export function isInMemoryFile(value: unknown): value is InMemoryFile { export function isInMemoryFile(value: unknown): value is InMemoryFile {
try { try {
return ( return (
isRecord(value) && isRecord(value) &&
"data" in value && "data" in value &&
typeof value.data === "string" && typeof value.data === "string" &&
isBase64(value.data.split(",")[1]) &&
"mimeType" in value && "mimeType" in value &&
typeof value.mimeType === "string" && typeof value.mimeType === "string" &&
isMimeType(value.mimeType) &&
"name" in value && "name" in value &&
typeof value.name === "string" && typeof value.name === "string" &&
"sizeInBytes" in value && "sizeInBytes" in value &&