@caleb-collar/steamcmd 1.0.0-alpha.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,466 +0,0 @@
1
- /**
2
- * TypeScript definitions for steamcmd
3
- * Node.js wrapper for SteamCMD - download, install, and manage Steam applications programmatically
4
- */
5
-
6
- import { EventEmitter } from "events";
7
-
8
- /**
9
- * Progress information for download/install operations
10
- */
11
- export interface Progress {
12
- /** Current phase of the operation */
13
- phase:
14
- | "starting"
15
- | "downloading"
16
- | "validating"
17
- | "preallocating"
18
- | "complete"
19
- | string;
20
- /** Percentage complete (0-100) */
21
- percent: number;
22
- /** Number of bytes downloaded so far */
23
- bytesDownloaded: number;
24
- /** Total bytes to download (0 if unknown) */
25
- totalBytes: number;
26
- }
27
-
28
- /**
29
- * Options for the install() function
30
- */
31
- export interface InstallOptions {
32
- /** Steam application ID to install */
33
- applicationId?: number | string;
34
- /** Workshop item ID to install (requires applicationId) */
35
- workshopId?: number | string;
36
- /** Installation directory path */
37
- path?: string;
38
- /** Steam username for authentication */
39
- username?: string;
40
- /** Steam password for authentication */
41
- password?: string;
42
- /** Steam Guard code for two-factor authentication */
43
- steamGuardCode?: string;
44
- /** Target platform for download ('windows', 'macos', 'linux') */
45
- platform?: "windows" | "macos" | "linux";
46
- /**
47
- * Progress callback fired during download/install operations
48
- * @param progress - Progress information
49
- */
50
- onProgress?: (progress: Progress) => void;
51
- /**
52
- * Output callback fired when SteamCMD produces output
53
- * @param data - Output text
54
- * @param type - Output stream type ('stdout' or 'stderr')
55
- */
56
- onOutput?: (data: string, type: "stdout" | "stderr") => void;
57
- }
58
-
59
- /**
60
- * Options for the download functions
61
- */
62
- export interface DownloadOptions {
63
- /**
64
- * Progress callback fired during download
65
- * @param progress - Progress information
66
- */
67
- onProgress?: (progress: Progress) => void;
68
- }
69
-
70
- /**
71
- * Options for getInstalledApps() function
72
- */
73
- export interface GetInstalledAppsOptions {
74
- /** Installation directory to scan */
75
- path: string;
76
- }
77
-
78
- /**
79
- * Information about an installed Steam application
80
- */
81
- export interface InstalledApp {
82
- /** Steam application ID */
83
- appId: number;
84
- /** Application name */
85
- name: string;
86
- /** Installation directory name */
87
- installDir: string | null;
88
- /** Size on disk in bytes */
89
- sizeOnDisk: number;
90
- /** Build ID (version) */
91
- buildId: number;
92
- /** Last update timestamp */
93
- lastUpdated: Date | null;
94
- /** State flags */
95
- state: number;
96
- }
97
-
98
- /**
99
- * Options for update() function
100
- */
101
- export interface UpdateOptions {
102
- /** Steam application ID to update */
103
- applicationId: number | string;
104
- /** Installation directory path */
105
- path?: string;
106
- /** Steam username for authentication */
107
- username?: string;
108
- /** Steam password for authentication */
109
- password?: string;
110
- /** Steam Guard code for two-factor authentication */
111
- steamGuardCode?: string;
112
- /** Target platform for download */
113
- platform?: "windows" | "macos" | "linux";
114
- /** Progress callback */
115
- onProgress?: (progress: Progress) => void;
116
- /** Output callback */
117
- onOutput?: (data: string, type: "stdout" | "stderr") => void;
118
- }
119
-
120
- /**
121
- * Options for validate() function
122
- */
123
- export interface ValidateOptions {
124
- /** Steam application ID to validate */
125
- applicationId: number | string;
126
- /** Installation directory path */
127
- path?: string;
128
- /** Steam username for authentication */
129
- username?: string;
130
- /** Steam password for authentication */
131
- password?: string;
132
- /** Steam Guard code for two-factor authentication */
133
- steamGuardCode?: string;
134
- /** Progress callback */
135
- onProgress?: (progress: Progress) => void;
136
- /** Output callback */
137
- onOutput?: (data: string, type: "stdout" | "stderr") => void;
138
- }
139
-
140
- /**
141
- * Options for getInstalledVersion() function
142
- */
143
- export interface GetInstalledVersionOptions {
144
- /** Steam application ID */
145
- applicationId: number | string;
146
- /** Installation directory path */
147
- path: string;
148
- }
149
-
150
- /**
151
- * Version information for an installed application
152
- */
153
- export interface InstalledVersion {
154
- /** Steam application ID */
155
- appId: number;
156
- /** Application name */
157
- name: string;
158
- /** Build ID (version) */
159
- buildId: number;
160
- /** Last update timestamp */
161
- lastUpdated: Date | null;
162
- }
163
-
164
- /**
165
- * Information about the SteamCMD installation
166
- */
167
- export interface SteamCmdInfo {
168
- /** Directory where SteamCMD is installed */
169
- directory: string;
170
- /** Path to the SteamCMD executable, or null if unsupported platform */
171
- executable: string | null;
172
- /** Current platform identifier */
173
- platform: NodeJS.Platform;
174
- /** Whether the current platform is supported */
175
- isSupported: boolean;
176
- }
177
-
178
- /**
179
- * Callback function type for legacy callback-based API
180
- */
181
- export type InstallCallback = (error: Error | null) => void;
182
-
183
- /**
184
- * Custom error class for SteamCMD operations
185
- */
186
- export class SteamCmdError extends Error {
187
- name: "SteamCmdError";
188
- /** Error code identifying the type of error */
189
- code: string;
190
- /** Original error that caused this error */
191
- cause?: Error;
192
-
193
- constructor(message: string, code: string, cause?: Error);
194
- }
195
-
196
- /**
197
- * Custom error class for download failures
198
- */
199
- export class DownloadError extends Error {
200
- name: "DownloadError";
201
- /** Error code: 'UNSUPPORTED_PLATFORM' | 'DIRECTORY_ERROR' | 'HTTP_ERROR' | 'EXTRACT_ERROR' | 'NETWORK_ERROR' */
202
- code: string;
203
-
204
- constructor(message: string, code: string);
205
- }
206
-
207
- /**
208
- * Custom error class for installation failures
209
- */
210
- export class InstallError extends Error {
211
- name: "InstallError";
212
- /** Error code: 'INVALID_OPTIONS' | 'INVALID_APP_ID' | 'MISSING_APP_ID' | 'INVALID_WORKSHOP_ID' | 'INVALID_PLATFORM' | 'MISSING_USERNAME' | 'INVALID_PATH' | 'SPAWN_ERROR' | 'EXIT_ERROR' */
213
- code: string;
214
- /** Exit code from SteamCMD process (for EXIT_ERROR) */
215
- exitCode?: number;
216
- /** Captured stdout from SteamCMD (for EXIT_ERROR) */
217
- stdout?: string;
218
- /** Captured stderr from SteamCMD (for EXIT_ERROR) */
219
- stderr?: string;
220
-
221
- constructor(message: string, code: string, exitCode?: number);
222
- }
223
-
224
- /**
225
- * EventEmitter for download operations with progress events
226
- */
227
- export interface DownloadEmitter extends EventEmitter {
228
- on(event: "progress", listener: (progress: Progress) => void): this;
229
- on(event: "complete", listener: () => void): this;
230
- on(event: "error", listener: (error: DownloadError) => void): this;
231
-
232
- once(event: "progress", listener: (progress: Progress) => void): this;
233
- once(event: "complete", listener: () => void): this;
234
- once(event: "error", listener: (error: DownloadError) => void): this;
235
-
236
- emit(event: "progress", progress: Progress): boolean;
237
- emit(event: "complete"): boolean;
238
- emit(event: "error", error: DownloadError): boolean;
239
- }
240
-
241
- /**
242
- * EventEmitter for install operations with progress events
243
- */
244
- export interface InstallEmitter extends EventEmitter {
245
- on(event: "progress", listener: (progress: Progress) => void): this;
246
- on(
247
- event: "output",
248
- listener: (data: string, type: "stdout" | "stderr") => void,
249
- ): this;
250
- on(event: "complete", listener: () => void): this;
251
- on(event: "error", listener: (error: InstallError) => void): this;
252
-
253
- once(event: "progress", listener: (progress: Progress) => void): this;
254
- once(
255
- event: "output",
256
- listener: (data: string, type: "stdout" | "stderr") => void,
257
- ): this;
258
- once(event: "complete", listener: () => void): this;
259
- once(event: "error", listener: (error: InstallError) => void): this;
260
-
261
- emit(event: "progress", progress: Progress): boolean;
262
- emit(event: "output", data: string, type: "stdout" | "stderr"): boolean;
263
- emit(event: "complete"): boolean;
264
- emit(event: "error", error: InstallError): boolean;
265
- }
266
-
267
- /**
268
- * Install a Steam application or Workshop item
269
- *
270
- * @param options - Installation options
271
- * @returns Promise that resolves when installation is complete
272
- *
273
- * @example
274
- * // Promise-based usage with progress
275
- * await steamcmd.install({
276
- * applicationId: 740,
277
- * path: './server',
278
- * onProgress: (p) => console.log(`${p.phase}: ${p.percent}%`)
279
- * });
280
- */
281
- export function install(options: InstallOptions): Promise<void>;
282
-
283
- /**
284
- * Install a Steam application or Workshop item (callback-based)
285
- *
286
- * @param options - Installation options
287
- * @param callback - Callback function called when complete
288
- *
289
- * @example
290
- * // Callback-based usage (legacy)
291
- * steamcmd.install({ applicationId: 740 }, (err) => {
292
- * if (err) console.error(err);
293
- * });
294
- */
295
- export function install(
296
- options: InstallOptions,
297
- callback: InstallCallback,
298
- ): void;
299
-
300
- /**
301
- * Check if SteamCMD is installed and executable
302
- *
303
- * @returns Promise that resolves to true if SteamCMD is available
304
- */
305
- export function isInstalled(): Promise<boolean>;
306
-
307
- /**
308
- * Ensure SteamCMD is installed, downloading if necessary
309
- *
310
- * @param options - Download options
311
- * @returns Promise that resolves when SteamCMD is available
312
- * @throws {SteamCmdError} If download fails
313
- */
314
- export function ensureInstalled(options?: DownloadOptions): Promise<void>;
315
-
316
- /**
317
- * Get information about the SteamCMD installation
318
- *
319
- * @returns Object containing SteamCMD paths and status
320
- */
321
- export function getInfo(): SteamCmdInfo;
322
-
323
- /**
324
- * Download SteamCMD with EventEmitter-based progress
325
- *
326
- * @param options - Download options
327
- * @returns EventEmitter that fires 'progress', 'error', and 'complete' events
328
- *
329
- * @example
330
- * const emitter = downloadWithProgress();
331
- * emitter.on('progress', (p) => console.log(`${p.percent}%`));
332
- * emitter.on('complete', () => console.log('Done!'));
333
- * emitter.on('error', (err) => console.error(err));
334
- */
335
- export function downloadWithProgress(
336
- options?: DownloadOptions,
337
- ): DownloadEmitter;
338
-
339
- /**
340
- * Run SteamCMD installation with EventEmitter-based progress
341
- *
342
- * @param steamCmdPath - Path to SteamCMD executable
343
- * @param options - Installation options
344
- * @returns EventEmitter that fires 'progress', 'output', 'error', and 'complete' events
345
- *
346
- * @example
347
- * const emitter = installWithProgress(execPath, { applicationId: 740 });
348
- * emitter.on('progress', (p) => console.log(`${p.percent}%`));
349
- * emitter.on('output', (data, type) => console.log(`[${type}] ${data}`));
350
- * emitter.on('complete', () => console.log('Done!'));
351
- * emitter.on('error', (err) => console.error(err));
352
- */
353
- export function installWithProgress(
354
- steamCmdPath: string,
355
- options: InstallOptions,
356
- ): InstallEmitter;
357
-
358
- /**
359
- * Get a list of installed Steam applications in a directory
360
- *
361
- * @param options - Options with path to scan
362
- * @returns Promise that resolves to array of installed app information
363
- *
364
- * @example
365
- * const apps = await steamcmd.getInstalledApps({ path: './server' });
366
- * // [{ appId: 740, name: 'Counter-Strike Global Offensive - Dedicated Server', ... }]
367
- */
368
- export function getInstalledApps(
369
- options: GetInstalledAppsOptions,
370
- ): Promise<InstalledApp[]>;
371
-
372
- /**
373
- * Update an installed Steam application
374
- *
375
- * @param options - Update options including applicationId
376
- * @returns Promise that resolves when update is complete
377
- *
378
- * @example
379
- * await steamcmd.update({
380
- * applicationId: 740,
381
- * path: './server',
382
- * onProgress: (p) => console.log(`${p.phase}: ${p.percent}%`)
383
- * });
384
- */
385
- export function update(options: UpdateOptions): Promise<void>;
386
-
387
- /**
388
- * Validate an installed Steam application
389
- *
390
- * @param options - Validation options including applicationId
391
- * @returns Promise that resolves when validation is complete
392
- *
393
- * @example
394
- * await steamcmd.validate({
395
- * applicationId: 740,
396
- * path: './server'
397
- * });
398
- */
399
- export function validate(options: ValidateOptions): Promise<void>;
400
-
401
- /**
402
- * Get the installed version (build ID) of a Steam application
403
- *
404
- * @param options - Options with applicationId and path
405
- * @returns Promise that resolves to version information or null if not installed
406
- *
407
- * @example
408
- * const version = await steamcmd.getInstalledVersion({
409
- * applicationId: 740,
410
- * path: './server'
411
- * });
412
- * // { appId: 740, buildId: 12345678, lastUpdated: Date }
413
- */
414
- export function getInstalledVersion(
415
- options: GetInstalledVersionOptions,
416
- ): Promise<InstalledVersion | null>;
417
-
418
- /**
419
- * Operation type for createProgressEmitter
420
- */
421
- export type OperationType = "install" | "update" | "validate";
422
-
423
- /**
424
- * EventEmitter for general SteamCMD operations with progress events
425
- */
426
- export interface ProgressEmitter extends EventEmitter {
427
- on(event: "progress", listener: (progress: Progress) => void): this;
428
- on(
429
- event: "output",
430
- listener: (data: string, type: "stdout" | "stderr") => void,
431
- ): this;
432
- on(event: "complete", listener: () => void): this;
433
- on(event: "error", listener: (error: Error) => void): this;
434
-
435
- once(event: "progress", listener: (progress: Progress) => void): this;
436
- once(
437
- event: "output",
438
- listener: (data: string, type: "stdout" | "stderr") => void,
439
- ): this;
440
- once(event: "complete", listener: () => void): this;
441
- once(event: "error", listener: (error: Error) => void): this;
442
-
443
- emit(event: "progress", progress: Progress): boolean;
444
- emit(event: "output", data: string, type: "stdout" | "stderr"): boolean;
445
- emit(event: "complete"): boolean;
446
- emit(event: "error", error: Error): boolean;
447
- }
448
-
449
- /**
450
- * Create an EventEmitter for SteamCMD operations with real-time progress
451
- *
452
- * @param operation - Operation type ('install', 'update', 'validate')
453
- * @param options - Operation options
454
- * @returns EventEmitter that fires 'progress', 'output', 'error', and 'complete' events
455
- *
456
- * @example
457
- * const emitter = steamcmd.createProgressEmitter('install', { applicationId: 740 });
458
- * emitter.on('progress', (p) => console.log(`${p.phase}: ${p.percent}%`));
459
- * emitter.on('output', (data, type) => console.log(`[${type}] ${data}`));
460
- * emitter.on('complete', () => console.log('Done!'));
461
- * emitter.on('error', (err) => console.error(err));
462
- */
463
- export function createProgressEmitter(
464
- operation: OperationType,
465
- options: InstallOptions,
466
- ): ProgressEmitter;