From aead039a6cdbd02f93841b8d2c93b0bd34e91d94 Mon Sep 17 00:00:00 2001 From: Alex Howard Date: Wed, 28 May 2025 11:37:40 -0700 Subject: [PATCH] add fileType argument to workshop.createItem --- client.d.ts | 20 ++++++++++++++++- src/api/workshop.rs | 53 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/client.d.ts b/client.d.ts index a2501ab..d04696b 100644 --- a/client.d.ts +++ b/client.d.ts @@ -281,7 +281,25 @@ export declare namespace workshop { progress: bigint total: bigint } - export function createItem(appId?: number | undefined | null): Promise + export const enum FileType { + Community = 0, + Microtransaction = 1, + Collection = 2, + Art = 3, + Video = 4, + Screenshot = 5, + Game = 6, + Software = 7, + Concept = 8, + WebGuide = 9, + IntegratedGuide = 10, + Merch = 11, + ControllerBinding = 12, + SteamworksAccessInvite = 13, + SteamVideo = 14, + GameManagedItem = 15 + } + export function createItem(appId?: number | undefined | null, fileType?: FileType | undefined | null): Promise export function updateItem(itemId: bigint, updateDetails: UgcUpdate, appId?: number | undefined | null): Promise export function updateItemWithCallback(itemId: bigint, updateDetails: UgcUpdate, appId: number | undefined | null, successCallback: (data: UgcResult) => void, errorCallback: (err: any) => void, progressCallback?: (data: UpdateProgress) => void, progressCallbackIntervalMs?: number | undefined | null): void /** diff --git a/src/api/workshop.rs b/src/api/workshop.rs index 865235b..f418f1d 100644 --- a/src/api/workshop.rs +++ b/src/api/workshop.rs @@ -7,7 +7,7 @@ pub mod workshop { use napi::threadsafe_function::ThreadsafeFunction; use napi::threadsafe_function::ThreadsafeFunctionCallMode; use std::path::Path; - use steamworks::{ClientManager, FileType, PublishedFileId, UpdateHandle}; + use steamworks::{ClientManager, PublishedFileId, UpdateHandle}; use tokio::sync::oneshot; #[napi(object)] @@ -142,17 +142,64 @@ pub mod workshop { } #[napi] - pub async fn create_item(app_id: Option) -> Result { + pub enum FileType { + Community, + Microtransaction, + Collection, + Art, + Video, + Screenshot, + Game, + Software, + Concept, + WebGuide, + IntegratedGuide, + Merch, + ControllerBinding, + SteamworksAccessInvite, + SteamVideo, + GameManagedItem, + } + + impl From for steamworks::FileType { + fn from(file_type: FileType) -> steamworks::FileType { + match file_type { + FileType::Community => steamworks::FileType::Community, + FileType::Microtransaction => steamworks::FileType::Microtransaction, + FileType::Collection => steamworks::FileType::Collection, + FileType::Art => steamworks::FileType::Art, + FileType::Video => steamworks::FileType::Video, + FileType::Screenshot => steamworks::FileType::Screenshot, + FileType::Game => steamworks::FileType::Game, + FileType::Software => steamworks::FileType::Software, + FileType::Concept => steamworks::FileType::Concept, + FileType::WebGuide => steamworks::FileType::WebGuide, + FileType::IntegratedGuide => steamworks::FileType::IntegratedGuide, + FileType::Merch => steamworks::FileType::Merch, + FileType::ControllerBinding => steamworks::FileType::ControllerBinding, + FileType::SteamworksAccessInvite => steamworks::FileType::SteamworksAccessInvite, + FileType::SteamVideo => steamworks::FileType::SteamVideo, + FileType::GameManagedItem => steamworks::FileType::GameManagedItem, + } + } + } + + #[napi] + pub async fn create_item( + app_id: Option, + file_type: Option, + ) -> Result { let client = crate::client::get_client(); let app_id = app_id .map(steamworks::AppId) .unwrap_or_else(|| client.utils().app_id()); + let file_type = file_type.unwrap_or(FileType::Community); let (tx, rx) = oneshot::channel(); client .ugc() - .create_item(app_id, FileType::Community, |result| { + .create_item(app_id, file_type.into(), |result| { tx.send(result).unwrap(); });