fix: default engine auto with graphql primary
This commit is contained in:
+2
-17
@@ -17,6 +17,7 @@ import JSON5 from 'json5';
|
||||
import kleur from 'kleur';
|
||||
import { resolveCliInvocation } from './lib/cli-args.js';
|
||||
import { resolveCredentials } from './lib/cookies.js';
|
||||
import { resolveEngineMode, shouldUseSweetistics, type EngineMode } from './lib/engine.js';
|
||||
import { extractTweetId } from './lib/extract-tweet-id.js';
|
||||
import { SweetisticsClient } from './lib/sweetistics-client.js';
|
||||
import { type TweetData, TwitterClient } from './lib/twitter-client.js';
|
||||
@@ -130,12 +131,10 @@ program
|
||||
.option(
|
||||
'--engine <engine>',
|
||||
'Engine: graphql | sweetistics | auto',
|
||||
process.env.BIRD_ENGINE || config.engine || 'graphql',
|
||||
process.env.BIRD_ENGINE || config.engine || 'auto',
|
||||
)
|
||||
.option('--timeout <ms>', 'Request timeout in milliseconds');
|
||||
|
||||
type EngineMode = 'graphql' | 'sweetistics' | 'auto';
|
||||
|
||||
type MediaSpec = { path: string; alt?: string; mime: string; buffer: Buffer };
|
||||
|
||||
function resolveSweetisticsConfig(options: { sweetisticsApiKey?: string; sweetisticsBaseUrl?: string }) {
|
||||
@@ -147,20 +146,6 @@ function resolveSweetisticsConfig(options: { sweetisticsApiKey?: string; sweetis
|
||||
return { apiKey, baseUrl };
|
||||
}
|
||||
|
||||
function resolveEngineMode(value?: string): EngineMode {
|
||||
const normalized = (value || 'auto').toLowerCase();
|
||||
if (normalized === 'graphql' || normalized === 'sweetistics' || normalized === 'auto') {
|
||||
return normalized;
|
||||
}
|
||||
return 'auto';
|
||||
}
|
||||
|
||||
function shouldUseSweetistics(engine: EngineMode, hasApiKey: boolean): boolean {
|
||||
if (engine === 'sweetistics') return true;
|
||||
if (engine === 'graphql') return false;
|
||||
return hasApiKey; // auto
|
||||
}
|
||||
|
||||
function resolveTimeoutMs(...values: Array<string | number | undefined | null>): number | undefined {
|
||||
for (const value of values) {
|
||||
if (value === undefined || value === null || value === '') continue;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
export type EngineMode = 'graphql' | 'sweetistics' | 'auto';
|
||||
|
||||
export function resolveEngineMode(value?: string): EngineMode {
|
||||
const normalized = (value || 'auto').toLowerCase();
|
||||
if (normalized === 'graphql' || normalized === 'sweetistics' || normalized === 'auto') {
|
||||
return normalized;
|
||||
}
|
||||
return 'auto';
|
||||
}
|
||||
|
||||
export function shouldUseSweetistics(engine: EngineMode, hasApiKey: boolean): boolean {
|
||||
if (engine === 'sweetistics') return true;
|
||||
if (engine === 'graphql') return false;
|
||||
return false; // auto: GraphQL primary, Sweetistics only as fallback
|
||||
}
|
||||
Reference in New Issue
Block a user