From 79ff43ec92b37d7db5d6cedab821f968ed2d873f Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 4 Mar 2024 17:17:07 +0000 Subject: [PATCH] 0.6.0 --- Cargo.toml | 2 +- index.d.ts | 10 ++++++++++ index.js | 5 ++++- package.json | 2 +- src/lib.rs | 40 ++++++++++++++++++++++++++++++++++++++-- 5 files changed, 54 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0bf6b3b..371da0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib"] [dependencies] napi = { version = "2", features = ["async"] } napi-derive = "2" -flashpoint-archive = { version = "0.5.0", features = ["napi"] } +flashpoint-archive = { version = "0.6.0", features = ["napi"] } [build-dependencies] napi-build = "2" diff --git a/index.d.ts b/index.d.ts index f4eba3c..cf6b359 100644 --- a/index.d.ts +++ b/index.d.ts @@ -171,6 +171,10 @@ export interface PartialGame { archiveState?: number addApps?: Array } +export interface GameRedirect { + sourceId: string + destId: string +} export interface GameData { id: number gameId: string @@ -334,6 +338,9 @@ export function genContentTree(root: string): Promise export function copyFolder(src: string, dest: string): Promise export function parseUserSearchInput(input: string): GameSearch export function newSubfilter(): GameFilter +export function enableDebug(): void +export function disableDebug(): void +export function debugEnabled(): boolean export type FlashpointNode = FlashpointArchive export class FlashpointArchive { constructor() @@ -389,11 +396,14 @@ export class FlashpointArchive { findAllGameApplicationPaths(): Promise> findPlatformAppPaths(): Promise>> forceGamesActiveDataMostRecent(): Promise + createGameRedirect(srcId: string, destId: string): Promise + deleteGameRedirect(srcId: string, destId: string): Promise updateApplyCategories(cats: Array): Promise updateApplyPlatforms(plats: Array): Promise updateApplyTags(tags: Array): Promise updateApplyGames(games: RemoteGamesRes): Promise updateDeleteGames(games: RemoteDeletedGamesRes): Promise + updateApplyRedirects(redirects: Array): Promise optimizeDatabase(): Promise } diff --git a/index.js b/index.js index e52ea89..dd8c9c5 100644 --- a/index.js +++ b/index.js @@ -295,7 +295,7 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`) } -const { GameSearchSortable, GameSearchDirection, FlashpointArchive, genContentTree, copyFolder, parseUserSearchInput, newSubfilter } = nativeBinding +const { GameSearchSortable, GameSearchDirection, FlashpointArchive, genContentTree, copyFolder, parseUserSearchInput, newSubfilter, enableDebug, disableDebug, debugEnabled } = nativeBinding module.exports.GameSearchSortable = GameSearchSortable module.exports.GameSearchDirection = GameSearchDirection @@ -304,3 +304,6 @@ module.exports.genContentTree = genContentTree module.exports.copyFolder = copyFolder module.exports.parseUserSearchInput = parseUserSearchInput module.exports.newSubfilter = newSubfilter +module.exports.enableDebug = enableDebug +module.exports.disableDebug = disableDebug +module.exports.debugEnabled = debugEnabled diff --git a/package.json b/package.json index 951cd27..ad1f94c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fparchive/flashpoint-archive", - "version": "0.5.0", + "version": "0.6.0", "main": "index.js", "types": "index.d.ts", "license": "MIT", diff --git a/src/lib.rs b/src/lib.rs index 1faf50a..caea764 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use napi::{Result, Error, Status}; use napi_derive::napi; -use flashpoint_archive::{game::{search::{GameFilter, GameSearch, PageTuple}, AdditionalApp, Game, PartialGame}, game_data::{GameData, PartialGameData}, platform::PlatformAppPath, tag::{PartialTag, Tag, TagSuggestion}, tag_category::{PartialTagCategory, TagCategory}, update::{RemoteCategory, RemoteDeletedGamesRes, RemoteGamesRes, RemotePlatform, RemoteTag}, util::ContentTreeNode, FlashpointArchive}; +use flashpoint_archive::{game::{search::{GameFilter, GameSearch, PageTuple}, GameRedirect, AdditionalApp, Game, PartialGame}, game_data::{GameData, PartialGameData}, platform::PlatformAppPath, tag::{PartialTag, Tag, TagSuggestion}, tag_category::{PartialTagCategory, TagCategory}, update::{RemoteCategory, RemoteDeletedGamesRes, RemoteGamesRes, RemotePlatform, RemoteTag}, util::ContentTreeNode, FlashpointArchive}; #[napi(js_name = "FlashpointArchive")] pub struct FlashpointNode { @@ -387,6 +387,20 @@ impl FlashpointNode { }) } + #[napi] + pub async fn create_game_redirect(&self, src_id: String, dest_id: String) -> Result<()> { + self.flashpoint.create_game_redirect(&src_id, &dest_id).await.map_err(|e| { + Error::new(Status::GenericFailure, e) + }) + } + + #[napi] + pub async fn delete_game_redirect(&self, src_id: String, dest_id: String) -> Result<()> { + self.flashpoint.delete_game_redirect(&src_id, &dest_id).await.map_err(|e| { + Error::new(Status::GenericFailure, e) + }) + } + #[napi] pub async fn update_apply_categories(&self, cats: Vec) -> Result<()> { self.flashpoint.update_apply_categories(cats).await.map_err(|e| { @@ -421,6 +435,13 @@ impl FlashpointNode { Error::new(Status::GenericFailure, e) }) } + + #[napi] + pub async fn update_apply_redirects(&self, redirects: Vec) -> Result<()> { + self.flashpoint.update_apply_redirects(redirects).await.map_err(|e| { + Error::new(Status::GenericFailure, e) + }) + } #[napi] pub async fn optimize_database(&self) -> Result<()> { @@ -456,4 +477,19 @@ pub fn parse_user_search_input(input: String) -> GameSearch { #[napi] pub fn new_subfilter() -> GameFilter { GameFilter::default() -} \ No newline at end of file +} + +#[napi] +pub fn enable_debug() { + flashpoint_archive::enable_debug(); +} + +#[napi] +pub fn disable_debug() { + flashpoint_archive::disable_debug(); +} + +#[napi] +pub fn debug_enabled() -> bool { + flashpoint_archive::debug_enabled() +}