Ferrite-backup/Ferrite/Models/BackupModels.swift
kingbri 4512318e8f Ferrite: Add actions, plugins, and tags
Plugins are now a unified format for both sources and actions. Actions
dictate what to do with a link and can now be added through a plugin
JSON file.

Backups have also been versioned to improve performance and add action
support.

Tags are used to give small amounts of information before a user
installs a plugin.

Signed-off-by: kingbri <bdashore3@proton.me>
2023-02-08 12:09:37 -05:00

56 lines
1.2 KiB
Swift

//
// BackupModels.swift
// Ferrite
//
// Created by Brian Dashore on 9/17/22.
//
import Foundation
public struct Backup: Codable {
let version: Int
var bookmarks: [BookmarkJson]?
var history: [HistoryJson]?
var sourceNames: [String]?
var actionNames: [String]?
var pluginListUrls: [String]?
// MARK: Remove once v1 backups are unsupported
var sourceLists: [PluginListBackupJson]?
}
// MARK: - CoreData translation
// Don't typealias to search result as this is a reflection of CoreData's struct
struct BookmarkJson: Codable {
let title: String?
let source: String
let size: String?
let magnetLink: String?
let magnetHash: String?
let seeders: String?
let leechers: String?
}
// Date is an epoch timestamp
struct HistoryJson: Codable {
let dateString: String?
let date: Double
let entries: [HistoryEntryJson]
}
struct HistoryEntryJson: Codable {
var name: String? = nil
var subName: String? = nil
var url: String? = nil
var timeStamp: Double? = nil
let source: String?
}
// Differs from PluginListJson
struct PluginListBackupJson: Codable {
let name: String
let author: String
let id: String
let urlString: String
}