Initial Commit
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
/** Domain values are JSON-safe. EVE item/location IDs are decimal strings, not JS floats. */
|
||||
export type UserId = string;
|
||||
export type Character = {
|
||||
id: number;
|
||||
userId: UserId;
|
||||
name: string;
|
||||
scopes: string[];
|
||||
assets: { status: 'never' | 'syncing' | 'ready' | 'error'; syncedAt?: number; expiresAt?: number; error?: string };
|
||||
};
|
||||
export type Asset = {
|
||||
itemId: string;
|
||||
characterId: number;
|
||||
typeId: number;
|
||||
quantity: number;
|
||||
locationId: string;
|
||||
locationType: string;
|
||||
locationFlag: string;
|
||||
isBlueprintCopy?: boolean;
|
||||
};
|
||||
export type InventoryType = { id: number; name: string; categoryId: number; volume?: number };
|
||||
/** Integer cents (0.01 ISK), serialized as decimal text. No floating-point accumulation. */
|
||||
export type Isk = string;
|
||||
export type ValuationMethod = 'reference_estimate' | 'immediate_liquidation' | 'expected_sell_order' | 'replacement';
|
||||
export type PriceEstimate = { typeId: number; unitPrice: Isk };
|
||||
export type PriceSnapshot = {
|
||||
prices: PriceEstimate[];
|
||||
source: string;
|
||||
asOf: number;
|
||||
expiresAt: number;
|
||||
};
|
||||
export interface CharacterAssetRepository {
|
||||
characters(userId: UserId): Promise<Character[]>;
|
||||
assets(userId: UserId, characterId: number): Promise<Asset[]>;
|
||||
}
|
||||
export interface ReferenceRepository {
|
||||
types(ids: number[]): Promise<InventoryType[]>;
|
||||
version(): Promise<string>;
|
||||
}
|
||||
export interface MarketEstimates {
|
||||
estimates(typeIds: number[]): Promise<PriceSnapshot>;
|
||||
}
|
||||
export type Requirement = 'assets' | 'blueprints' | 'skills' | 'market_data';
|
||||
export type Capability = 'asset_search' | 'asset_valuation' | 'manufacturing_opportunities';
|
||||
export type Action = { kind: 'connect_character' | 'synchronize'; label: string; href: string };
|
||||
export type MissingRequirement = { requirement: Requirement; characterId?: number; reason: 'authorization' | 'synchronization' | 'stale' | 'not_implemented' };
|
||||
export type CapabilityGate =
|
||||
| { status: 'available' }
|
||||
| { status: 'authentication_required' | 'requirements_missing'; capability: Capability; missing: MissingRequirement[]; actions: Action[] };
|
||||
export type ValuedAsset = Asset & { name: string; unitPrice: Isk | null; estimatedValue: Isk | null; exclusion?: 'missing_price' | 'blueprint_copy' | 'unknown_type' };
|
||||
export type AssetReport = {
|
||||
method: 'reference_estimate';
|
||||
total: Isk;
|
||||
items: ValuedAsset[];
|
||||
characters: { id: number; name: string; syncedAt: number }[];
|
||||
unpricedItems: number;
|
||||
referenceVersion: string;
|
||||
prices: Omit<PriceSnapshot, 'prices'>;
|
||||
warnings: string[];
|
||||
};
|
||||
export type AssetOperation =
|
||||
| Exclude<CapabilityGate, { status: 'available' }>
|
||||
| { status: 'ready'; report: AssetReport }
|
||||
| { status: 'unavailable'; reason: string };
|
||||
|
||||
// Planned domains: contracts only. These are not implemented features.
|
||||
export type IndustryEconomics = {
|
||||
expectedRevenue: Isk;
|
||||
additionalIskRequired: Isk;
|
||||
ownedMaterialOpportunityValue: Isk;
|
||||
totalEconomicCost: Isk;
|
||||
cashFlowGain: Isk;
|
||||
economicProfit: Isk;
|
||||
economicMargin: number | null;
|
||||
productionSeconds: number;
|
||||
iskPerHour: Isk | null;
|
||||
};
|
||||
export type SystemCoordinates = { systemId: number; x: number; y: number; z: number };
|
||||
export type DockingEvidence = {
|
||||
structureId: string;
|
||||
characterId: number;
|
||||
status: 'unknown' | 'allowed' | 'denied';
|
||||
source: 'visibility_only' | 'esi_structure_access' | 'acl_evaluation' | 'observed_docking' | 'user_report';
|
||||
observedAt: number;
|
||||
expiresAt: number;
|
||||
limitations: string[];
|
||||
};
|
||||
export interface StructureEvidenceRepository { docking(characterId: number, structureId: string): Promise<DockingEvidence>; }
|
||||
export interface BlueprintRepository { manufacturingMaterials(blueprintTypeId: number): Promise<{ typeId: number; quantity: number }[]>; }
|
||||
export interface CapitalRouter {
|
||||
route(request: { from: number; to: number; shipTypeId: number; characterId: number; calibrationLevel: number; avoidSystems: number[]; avoidRegions: number[]; preferDockableFortizars: boolean }): Promise<{ systems: number[]; evidence: DockingEvidence[]; weight: number }>;
|
||||
}
|
||||
export interface OrderBook {
|
||||
buyOrders(typeId: number, locationId: string): Promise<{ orderId: string; price: Isk; remaining: number; minimumVolume: number; range: string }[]>;
|
||||
}
|
||||
Reference in New Issue
Block a user