Skip to content

Commit

Permalink
0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
colin969 committed Mar 4, 2024
1 parent b98c09a commit 79ff43e
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 10 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ export interface PartialGame {
archiveState?: number
addApps?: Array<AdditionalApp>
}
export interface GameRedirect {
sourceId: string
destId: string
}
export interface GameData {
id: number
gameId: string
Expand Down Expand Up @@ -334,6 +338,9 @@ export function genContentTree(root: string): Promise<ContentTreeNode>
export function copyFolder(src: string, dest: string): Promise<number>
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()
Expand Down Expand Up @@ -389,11 +396,14 @@ export class FlashpointArchive {
findAllGameApplicationPaths(): Promise<Array<string>>
findPlatformAppPaths(): Promise<Record<string, Array<PlatformAppPath>>>
forceGamesActiveDataMostRecent(): Promise<void>
createGameRedirect(srcId: string, destId: string): Promise<void>
deleteGameRedirect(srcId: string, destId: string): Promise<void>
updateApplyCategories(cats: Array<RemoteCategory>): Promise<void>
updateApplyPlatforms(plats: Array<RemotePlatform>): Promise<void>
updateApplyTags(tags: Array<RemoteTag>): Promise<void>
updateApplyGames(games: RemoteGamesRes): Promise<void>
updateDeleteGames(games: RemoteDeletedGamesRes): Promise<void>
updateApplyRedirects(redirects: Array<GameRedirect>): Promise<void>
optimizeDatabase(): Promise<void>
}

Expand Down
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
40 changes: 38 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<RemoteCategory>) -> Result<()> {
self.flashpoint.update_apply_categories(cats).await.map_err(|e| {
Expand Down Expand Up @@ -421,6 +435,13 @@ impl FlashpointNode {
Error::new(Status::GenericFailure, e)
})
}

#[napi]
pub async fn update_apply_redirects(&self, redirects: Vec<GameRedirect>) -> Result<()> {
self.flashpoint.update_apply_redirects(redirects).await.map_err(|e| {
Error::new(Status::GenericFailure, e)
})
}

#[napi]
pub async fn optimize_database(&self) -> Result<()> {
Expand Down Expand Up @@ -456,4 +477,19 @@ pub fn parse_user_search_input(input: String) -> GameSearch {
#[napi]
pub fn new_subfilter() -> GameFilter {
GameFilter::default()
}
}

#[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()
}

0 comments on commit 79ff43e

Please sign in to comment.