Skip to content

Build your personal knowledge base with Trilium Notes

client-ts: Port services/entities/fblob

Elian Doran0c8092b8f4b3
diff --git a/src/public/app/entities/fblob.js b/src/public/app/entities/fblob.js
deleted file mode 100644
index e335d7cb87..0000000000
--- a/src/public/app/entities/fblob.js
+++ /dev/null
@@ -1,39 +0,0 @@
-export default class FBlob {
- constructor(row) {
- /** @type {string} */
- this.blobId = row.blobId;
-
- /**
- * can either contain the whole content (in e.g. string notes), only part (large text notes) or nothing at all (binary notes, images)
- * @type {string}
- */
- this.content = row.content;
- this.contentLength = row.contentLength;
-
- /** @type {string} */
- this.dateModified = row.dateModified;
- /** @type {string} */
- this.utcDateModified = row.utcDateModified;
- }
-
- /**
- * @returns {*}
- * @throws Error in case of invalid JSON */
- getJsonContent() {
- if (!this.content || !this.content.trim()) {
- return null;
- }
-
- return JSON.parse(this.content);
- }
-
- /** @returns {*|null} valid object or null if the content cannot be parsed as JSON */
- getJsonContentSafely() {
- try {
- return this.getJsonContent();
- }
- catch (e) {
- return null;
- }
- }
-}
diff --git a/src/public/app/entities/fblob.ts b/src/public/app/entities/fblob.ts
new file mode 100644
index 0000000000..d260f7da64
--- /dev/null
+++ b/src/public/app/entities/fblob.ts
@@ -0,0 +1,48 @@
+
+export interface FBlobRow {
+ blobId: string;
+ content: string;
+ contentLength: number;
+ dateModified: string;
+ utcDateModified: string;
+}
+
+export default class FBlob {
+
+ blobId: string;
+ /**
+ * can either contain the whole content (in e.g. string notes), only part (large text notes) or nothing at all (binary notes, images)
+ */
+ content: string;
+ contentLength: number;
+ dateModified: string;
+ utcDateModified: string;
+
+ constructor(row: FBlobRow) {
+ this.blobId = row.blobId;
+ this.content = row.content;
+ this.contentLength = row.contentLength;
+ this.dateModified = row.dateModified;
+ this.utcDateModified = row.utcDateModified;
+ }
+
+ /**
+ * @throws Error in case of invalid JSON
+ */
+ getJsonContent(): unknown {
+ if (!this.content || !this.content.trim()) {
+ return null;
+ }
+
+ return JSON.parse(this.content);
+ }
+
+ getJsonContentSafely(): unknown | null {
+ try {
+ return this.getJsonContent();
+ }
+ catch (e) {
+ return null;
+ }
+ }
+}