UNPKG

@destinyitemmanager/dim-api-types

Version:
805 lines (804 loc) 30 kB
import { DestinyClass } from 'bungie-api-ts/destiny2'; import { DestinyItemSubType } from 'bungie-api-ts/destiny2'; /** * An app registered with the DIM API. */ export interface ApiApp { /** A short ID that uniquely identifies the app. */ id: string; /** Apps must share their Bungie.net API key with us. */ bungieApiKey: string; /** Apps also get a generated API key for accessing DIM APIs that don't involve user data. */ dimApiKey: string; /** The origin used to allow CORS for this app. Only requests from this origin are allowed. */ origin: string; } /** * A request to register a new app with the DIM API. */ export type CreateAppRequest = Pick<ApiApp, 'id' | 'bungieApiKey' | 'origin'>; export interface CreateAppResponse { app: ApiApp; } export interface AuthTokenRequest { /** The access token from authenticating with the Bungie.net API */ bungieAccessToken: string; /** The user's Bungie.net membership ID */ membershipId: string; } export interface AuthTokenResponse { /** Your DIM API access token, to be used in further requests. */ accessToken: string; /** How many seconds from now the token will expire. */ expiresInSeconds: number; } /** traditional custom stats use a binary 1 or 0 for all 6 armor stats, but this could support more complex weights */ export interface CustomStatWeights { [statHash: number]: number | undefined; [statHash: string]: number | undefined; } export interface CustomStatDef { /** a unique-per-user fake statHash used to look this stat up */ statHash: number; /** a unique-per-class name for this stat */ label: string; /** an abbreviated/crunched form of the stat label, for use in search filters */ shortLabel: string; /** which guardian class this stat should be used for. DestinyClass.Unknown makes a global (all 3 classes) stat */ class: DestinyClass; /** info about how to calculate the stat total */ weights: CustomStatWeights; } export interface DeleteAllResponse { deleted: { settings: number; loadouts: number; tags: number; itemHashTags: number; triumphs: number; searches: number; }; } export interface ErrorResponse { error: string; message: string; } export interface ExportResponse { settings: Partial<Settings>; loadouts: { platformMembershipId: string; destinyVersion: DestinyVersion; loadout: Loadout; }[]; tags: { platformMembershipId: string; destinyVersion: DestinyVersion; annotation: ItemAnnotation; }[]; itemHashTags: ItemHashTag[]; triumphs: { platformMembershipId: string; triumphs: number[]; }[]; searches: { destinyVersion: DestinyVersion; search: Search; }[]; } export type DestinyVersion = 1 | 2; export interface GlobalSettings { /** Whether to use the DIM API for */ dimApiEnabled: boolean; /** Don't allow refresh more often than this many seconds. */ destinyProfileMinimumRefreshInterval: number; /** Time in seconds to refresh the profile when autoRefresh is true. */ destinyProfileRefreshInterval: number; /** Whether to refresh profile automatically. */ autoRefresh: boolean; /** Whether to refresh profile when the page becomes visible after being in the background. */ refreshProfileOnVisible: boolean; /** Don't automatically refresh DIM profile info more often than this many seconds. */ dimProfileMinimumRefreshInterval: number; /** Display an issue banner, if there is one. */ showIssueBanner: boolean; /** The unix milliseconds timestamp for when this was last updated. */ lastUpdated: number; } export declare const defaultGlobalSettings: GlobalSettings; export interface PlatformInfoResponse { settings: GlobalSettings; } export interface ImportResponse { loadouts: number; tags: number; itemHashTags: number; triumphs: number; searches: number; } export type TagValue = 'favorite' | 'keep' | 'infuse' | 'junk' | 'archive'; export declare const enum TagVariant { PVP = 1, PVE = 2 } /** Any extra info added by the user to individual items - tags, notes, etc. */ export interface ItemAnnotation extends Annotation { /** The item instance ID for an individual item */ id: string; /** * UTC epoch seconds timestamp of when the item was crafted. Used to * match up items that have changed instance ID from being reshaped since they * were tagged. */ craftedDate?: number; } /** Any extra info added by the user to item hashes (shaders and mods) */ export interface ItemHashTag extends Annotation { /** The inventory item hash for an item */ hash: number; } interface Annotation { /** Optional tag for the item. */ tag?: TagValue | null; /** Optional text notes on the item. */ notes?: string | null; /** * An optional "variant" for the tag that only has meaning if the tag is set. * This provides a backwards and forwards compatible way to say a roll is * "Keep-PVP" or "Keep-PVE". Clients that don't understand this flag will * simply show "Keep". This is only really meant to be used with the "keep" * tag. */ v?: TagVariant; } /** * A loadout to share. */ export interface LoadoutShareRequest { /** Platform (and authentication) is required to know who shared the loadout. */ platformMembershipId: string; /** A complete loadout object to share. */ loadout: Loadout; } export interface LoadoutShareResponse { /** The full dim.gg URL to the shared loadout. */ shareUrl: string; } /** * A request to get a shared loadout. */ export interface GetSharedLoadoutRequest { /** The share ID (from dim.gg/<shareId>/<slug>) */ shareId: string; } export interface GetSharedLoadoutResponse { /** The full loadout */ loadout: Loadout; /** The full dim.gg URL to the shared loadout. */ shareUrl: string; } export interface LoadoutItem { /** itemInstanceId of the item (if it's instanced) */ id?: string; /** DestinyInventoryItemDefinition hash of the item */ hash: number; /** Optional amount (for consumables), default to zero */ amount?: number; /** * The socket overrides for the item. These signal what DestinyInventoryItemDefinition * (by it's hash) is supposed to be socketed into the given socket index. */ socketOverrides?: { [socketIndex: number]: number; }; /** * UTC epoch seconds timestamp of when the item was crafted. Used to * match up items that have changed instance ID from being reshaped since they * were added to the loadout. */ craftedDate?: number; } /** normally found inside DestinyLoadoutComponent, mapped to respective definition tables */ export interface InGameLoadoutIdentifiers { colorHash: number; iconHash: number; nameHash: number; } export interface Loadout { /** * A globally unique (UUID) identifier for the loadout. * Chosen by the client */ id: string; name: string; /** Optional longform notes about the loadout. */ notes?: string; /** * DestinyClass enum value for the class this loadout is restricted * to. This is optional (set to Unknown for loadouts that can be used anywhere). */ classType: DestinyClass; /** * DestinyInventoryItemDefinition hash of an emblem to use as * an icon for this loadout. * * @deprecated this was added for Little Light but never used by DIM. */ emblemHash?: number; /** * Whether to clear out other items when applying this loadout * @deprecated in favor of parameters.clearWeapons and parameters.clearArmor */ /** Whether to clear out other items when applying this loadout */ clearSpace?: boolean; /** List of equipped items in the loadout */ equipped: LoadoutItem[]; /** List of unequipped items in the loadout */ unequipped: LoadoutItem[]; /** Information about the desired properties of this loadout - used to drive the Loadout Optimizer or apply Mod Loadouts */ parameters?: LoadoutParameters; /** When was this Loadout initially created? Tracked automatically by the API - when saving a loadout this field is ignored. */ createdAt?: number; /** When was this Loadout last changed? Tracked automatically by the API - when saving a loadout this field is ignored. */ lastUpdatedAt?: number; /** * Automatically added stat mods. These are separate from the manually chosen * mods in parameters.mods, and are saved here to avoid having to figure them * out all over again every time (especially since our algorithm might * change). Combine this list and parameters.mods when displaying or actually * applying the loadout. * * @deprecated we just throw away stat mods when using LO auto stats */ autoStatMods?: number[]; } /** Whether armor of this type will have assumed masterworked stats in the Loadout Optimizer. */ export declare const enum AssumeArmorMasterwork { /** No armor will have assumed masterworked stats. */ None = 1, /** Only legendary armor will have assumed masterworked stats. */ Legendary = 2, /** All armor (legendary & exotic) will have assumed masterworked stats. */ All = 3, /** All armor (legendary & exotic) will have assumed masterworked stats, and Exotic Armor will be upgraded to have an artifice mod slot. */ ArtificeExotic = 4 } /** How the loadouts menu and page should be sorted */ export declare const enum LoadoutSort { ByEditTime = 0, ByName = 1 } /** * Parameters that explain how this loadout was chosen (in Loadout Optimizer) * and at the same time, how this loadout should be configured when equipped. * This can be used to re-load a loadout into Loadout Optimizer with its * settings intact, or to equip the right mods when applying a loadout if AWA is * ever released. * * Originally this was meant to model parameters independent of specific items, * as a means of sharing Loadout Optimizer settings between users, but now we * just share whole loadouts, so this can be used for any sort of parameter we * want to add to loadouts. * * All properties are optional, but most have defaults specified in * defaultLoadoutParameters that should be used if they are undefined. */ export interface LoadoutParameters { /** * The stats the user cared about for this loadout, in the order they cared about them and * with optional range by tier. If a stat is "ignored" it should just be missing from this * list. */ statConstraints?: StatConstraint[]; /** * The mods that will be used with this loadout. Each entry is an inventory * item hash representing the mod item. Hashes may appear multiple times. * These are not associated with any specific item in the loadout - when * applying the loadout we should automatically determine the minimum of * changes required to match the desired mods, and apply these mods to the * equipped items. */ mods?: number[]; /** * If set, after applying the mods above, all other mods will be removed from armor. */ clearMods?: boolean; /** Whether to clear out other weapons when applying this loadout */ clearWeapons?: boolean; /** Whether to clear out other weapons when applying this loadout */ clearArmor?: boolean; /** * Mods that must be applied to a specific bucket hash. In general, prefer to * use the flat mods list above, and rely on the loadout function to assign * mods automatically. However there are some mods like shaders which can't * be automatically assigned to the right piece. These only apply to the equipped * item. */ modsByBucket?: { [bucketHash: number]: number[]; }; /** The artifact unlocks relevant to this build. */ artifactUnlocks?: { /** The item hashes of the unlocked artifact perk items. */ unlockedItemHashes: number[]; /** The season this set of artifact unlocks was chosen from. */ seasonNumber: number; }; /** * Whether to automatically add stat mods. */ autoStatMods?: boolean; /** * A search filter applied while editing the loadout in Loadout Optimizer, * which constrains the items that can be in the loadout. */ query?: string; /** * Whether armor of this type will have assumed materwork stats in the Loadout Optimizer. */ assumeArmorMasterwork?: AssumeArmorMasterwork; /** * The InventoryItemHash of the pinned exotic, if any was chosen. */ exoticArmorHash?: number; /** * a user may optionally specify which icon/color/name will be used, * if this DIM loadout is saved to an in-game slot */ inGameIdentifiers?: InGameLoadoutIdentifiers; /** * When calculating loadout stats, should "Font of ..." mods be assumed active * and their runtime bonus stats be included? */ includeRuntimeStatBenefits?: boolean; } /** * All properties of LoadoutParameters are optional, in order to make them * compact when shared. Before using LoadoutParameters, merge it with these * defaults. */ export declare const defaultLoadoutParameters: LoadoutParameters; /** A constraint on the values an armor stat can take */ export interface StatConstraint { /** The stat definition hash of the stat */ statHash: number; /** The minimum tier value for the stat. 0 if unset. */ minTier?: number; /** The maximum tier value for the stat. 10 if unset. */ maxTier?: number; } export interface ProfileResponse { settings?: Settings; loadouts?: Loadout[]; tags?: ItemAnnotation[]; /** Tags for shaders and other uninstanced items */ itemHashTags?: ItemHashTag[]; /** Hashes of tracked triumphs */ triumphs?: number[]; searches?: Search[]; /** If the response is a sync, this will include loadout IDs of deleted loadouts. */ deletedLoadoutIds?: string[]; /** If the response is a sync, this will include MD5 hashes of deleted search queries. */ deletedSearchHashes?: string[]; /** If the response is a sync, this will include triumph hashes of untracked triumphs. */ deletedTriumphs?: number[]; /** If the response is a sync, this will include instance IDs of deleted tags. */ deletedTagsIds?: string[]; /** If the response is a sync, this will include hashes of deleted item hash tags. */ deletedItemHashTagHashes?: number[]; /** Set to true if this response only contains new/changed/deleted items. */ sync?: boolean; /** * This token allows for syncing the profile after the initial load. If you * provide it as the `sync=` query parameter, the server will return only * changed items made since the last sync. */ syncToken?: string; } /** * A list of updates for a particular profile. */ export interface ProfileUpdateRequest { platformMembershipId?: string; destinyVersion?: DestinyVersion; updates: ProfileUpdate[]; } export interface ProfileUpdateResponse { results: ProfileUpdateResult[]; } export type ProfileUpdate = TagUpdate | ItemHashTagUpdate | TagCleanupUpdate | SettingUpdate | LoadoutUpdate | DeleteLoadoutUpdate | TrackTriumphUpdate | UsedSearchUpdate | SavedSearchUpdate | DeleteSearchUpdate; export interface TagUpdate { action: 'tag'; payload: ItemAnnotation; } export interface ItemHashTagUpdate { action: 'item_hash_tag'; payload: ItemHashTag; } export interface TagCleanupUpdate { action: 'tag_cleanup'; payload: string[]; } export interface SettingUpdate { action: 'setting'; payload: Partial<Settings>; } export interface LoadoutUpdate { action: 'loadout'; payload: Loadout; } export interface DeleteLoadoutUpdate { action: 'delete_loadout'; payload: string; } export interface TrackTriumphUpdate { action: 'track_triumph'; /** true for tracked, false for untracked */ payload: { recordHash: number; tracked: boolean; }; } /** * Record that a search was used. */ export interface UsedSearchUpdate { action: 'search'; payload: { query: string; type: SearchType; }; } /** * Save or unsave a search. This is separate from marking a search as used. */ export interface SavedSearchUpdate { action: 'save_search'; payload: { query: string; type: SearchType; /** * Whether the search should be saved */ saved: boolean; }; } /** * Delete a search. This allows for "forgetting" a recent or saved search. */ export interface DeleteSearchUpdate { action: 'delete_search'; payload: { query: string; type: SearchType; }; } export interface ProfileUpdateResponse { results: ProfileUpdateResult[]; } export interface ProfileUpdateResult { status: 'Success' | string; message?: string; } export declare const enum SearchType { Item = 1, Loadout = 2 } /** * A search query. This can either be from history (recent searches), pinned (saved searches), or suggested. */ export interface Search { query: string; /** * A zero usage count means this is a suggested/preloaded search. */ usageCount: number; /** * Has this search been saved/favorited/pinned by the user? */ saved: boolean; /** * The last time this was used, as a unix millisecond timestamp. */ lastUsage: number; /** * Which kind of thing is this search for? Searches of different types are * stored together and need to be filtered to the specific type. */ type: SearchType; } export type CharacterOrder = 'mostRecent' | 'mostRecentReverse' | 'fixed' | 'custom'; export declare const enum InfuseDirection { /** infuse something into the query (query = target) */ INFUSE = 0, /** infuse the query into the target (query = source) */ FUEL = 1 } export declare const enum ItemPopupTab { Overview = 0, Triage = 1 } export declare const enum VaultWeaponGroupingStyle { Lines = 0, Inline = 1 } export interface Settings { /** Show item quality percentages */ readonly itemQuality: boolean; /** Show new items with an overlay */ readonly showNewItems: boolean; /** Sort characters (mostRecent, mostRecentReverse, fixed) */ readonly characterOrder: CharacterOrder; /** Custom sorting properties, in order of application */ readonly itemSortOrderCustom: string[]; /** supplements itemSortOrderCustom by allowing each sort to be reversed */ readonly itemSortReversals: string[]; /** How many columns to display character buckets */ readonly charCol: number; /** How many columns to display character buckets on Mobile */ readonly charColMobile: number; /** How big in pixels to draw items - start smaller for iPad */ readonly itemSize: number; /** Which categories or buckets should be collapsed? */ readonly collapsedSections: { [key: string]: boolean; }; /** Hide triumphs once they're completed */ readonly completedRecordsHidden: boolean; /** Hide show triumphs the manifest recommends be redacted */ readonly redactedRecordsRevealed: boolean; /** Whether to keep one slot per item type open */ readonly farmingMakeRoomForItems: boolean; /** How many spaces to clear when using Farming Mode(make space). */ readonly inventoryClearSpaces: number; /** Hide completed Destiny 1 records */ readonly hideCompletedRecords: boolean; /** Custom character sort - across all accounts and characters! */ readonly customCharacterSort: string[]; /** The last direction the infusion fuel finder was set to. */ readonly infusionDirection: InfuseDirection; /** The user's preferred language. */ readonly language: string; /** * External source for wish lists. * Expected to be a valid URL. * initialState should hold the current location of a reasonably-useful collection of rolls. * Set to empty string to not use wishListSource. */ readonly wishListSource: string; /** * The last used settings for the Loadout Optimizer. These apply to all classes. */ readonly loParameters: Exclude<LoadoutParameters, 'mods' | 'query' | 'exoticArmorHash' | 'statConstraints' | 'clearMods'>; /** * Stat order, enablement, etc. Stored per class. */ readonly loStatConstraintsByClass: { [key: number]: StatConstraint[]; }; /** list of stat hashes of interest, keyed by class enum */ readonly customTotalStatsByClass: { [key: number]: number[]; }; /** Selected columns for the Vault Organizer */ readonly organizerColumnsWeapons: string[]; readonly organizerColumnsArmor: string[]; readonly organizerColumnsGhost: string[]; /** Compare base stats or actual stats in Compare */ readonly compareBaseStats: boolean; /** Item popup sidecar collapsed just shows icon and no character locations */ readonly sidecarCollapsed: boolean; /** In "Single Character Mode" DIM pretends you only have one (active) character and all the other characters' items are in the vault. */ readonly singleCharacter: boolean; /** Badge the app icon with the number of postmaster items on the current character */ readonly badgePostmaster: boolean; /** Display perks as a list instead of a grid. */ readonly perkList: boolean; /** How the loadouts menu and page should be sorted */ readonly loadoutSort: LoadoutSort; /** Hide tagged items in the Item Feed */ readonly itemFeedHideTagged: boolean; /** Show the Item Feed */ readonly itemFeedExpanded: boolean; /** Pull from postmaster is an irreversible action and some people don't want to accidentally hit it. */ readonly hidePullFromPostmaster: boolean; /** Select descriptions to display */ readonly descriptionsToDisplay: 'bungie' | 'community' | 'both'; /** Plug the T10 masterwork into D2Y2+ random roll weapons for comparison purposes. */ readonly compareWeaponMasterwork: boolean; /** * Cutoff point; the instance ID of the newest item that isn't shown in * the item feed anymore after the user presses the "clear" button. */ readonly itemFeedWatermark: string; /** * a set of user-defined custom stat totals. * this will supercede customTotalStatsByClass. * it defaults below to empty, which in DIM, initiates fallback to customTotalStatsByClass */ readonly customStats: CustomStatDef[]; /** Automatically sync lock status with tag */ readonly autoLockTagged: boolean; /** The currently chosen theme. */ theme: string; /** Whether to sort triumphs on the records tab by their progression percentage. */ sortRecordProgression: boolean; /** Whether to hide items that cost silver from the Vendors screen. */ vendorsHideSilverItems: boolean; /** An additional layer of grouping for weapons in the vault. */ vaultWeaponGrouping: string; /** How grouped weapons in the vault should be displayed. */ vaultWeaponGroupingStyle: VaultWeaponGroupingStyle; /** The currently selected item popup tab. */ itemPopupTab: ItemPopupTab; } export declare const defaultSettings: Settings; export interface UserInfo { /** The user's Bungie.net membership ID, from the JWT */ bungieMembershipId: number; /** The DIM App API key this token was issued for */ dimApiKey: string; /** A list of Destiny 2 membership profiles this account can access. */ profileIds: string[]; } /** Compatible superset of Little Light wishlist format */ export type ItemHash = number; export type StatHash = number; export interface WishList { /** * Indicates that this JSON file is in the format described by this schema. If * the format is changed in a non-backwards-compatible way this string will be * changed. It otherwise has no semantic meaning. */ format: 'wishlist.v1'; /** * The name of the wish list itself, as a plain string. e.g. "Voltron". */ name: string; /** The description of the wish list itself, as a plain string. */ description: string; /** Information about the author(s) of this wish list. */ authors?: Author[]; /** * URLs of other wish lists that are transitively included into this wishlist. * This allows wish lists to be composed of other wish lists, which are then * fetched individually. A wish list may specify multiple includes, and no * rolls of its own. */ include?: string[]; /** * UNIX timestamp (milliseconds) representing when this wish list was first * created, for display to humans. */ createdTime?: number; /** * UNIX timestamp (milliseconds) representing when this wish list was last * updated, for display to humans. This shouldn't be used to manage cache * freshness - use HTTP headers for that. */ updatedTime?: number; /** * Per-item-hash rolls - each one specifies one or more rolls that are * specific to a particular DestinyInventoryItem. E.g. "These are the god * rolls for The Messenger" */ itemRolls?: ItemRoll[]; /** * Perk rolls match specific plug combinations, but without specifying an * item. E.g. "Outlaw + Kill Clip is always good" */ perkRolls?: Roll[]; /** * Rolls that apply to any weapons in a specific category. E.g. "Shotguns with * Shot Package + Slideshot are always good". * * If you specify the intrinsic perk hash, you can also specify things like * "Adaptive Frame Scout Rifles with Surplus + Demolitionist are good" */ categoryRolls?: CategoryRoll[]; } /** These tags are meant to match the Little Light JSON wishlist tags. */ type Tag = /** This roll is intended for use in PVE */ 'PvE' /** This roll is intended for use in PVP */ | 'PvP' /** This roll is specifically good for mouse+keyboard users */ | 'MnK' /** This roll is specifically good for controller users */ | 'Ctrl' /** * God Roll - "don't you dare throw this away" - not all guns need to have one * of these! */ | 'Godroll' /** * Good Roll - "this is worth keeping/trying" - for guns you would tell * someone to seek out/grind for. if your review of X gun is "you should go * get Y gun instead", then X gun doesn't need a Good Roll */ | 'Good' /** * Perk Recommendation - "if you want this gun, here are the perks you should * use" - if you're a wishlist maker, you should write some of these for each * gun */ | 'Recommended' /** * Trash - this sucks, these perks clash - controversial. Makes people very * sad when they see it, but like the roll. Allowing users to uncheck tags * when importing wish lists may make using this viable. */ | 'Trash' | string; interface Roll { /** * An explanation about this roll. Usually contains a general explanation of * the good and bad parts of this weapon. */ description?: string; /** * Describe a combination of perks, which are really plugs for sockets. * * ItemHash is the `DestinyInventoryItem` hash for a socket plug. * * Each element in the top-level array represents a "group" of perks, which * means they belong to the same socket (column) in the perk selection UI. * * Masterworks, Weapon Mod, Shader, and other non-Perk plugs *should not* be * included. * * The order of perks group is not specified. Do not include empty groups. * * For hash in the same group, their relation is OR. For different groups, * their relation is AND. (e.g. `[[1, 2], [3, 4]]` means `(1 OR 2) AND (3 OR * 4)`) * * e.g. For `"Randy's Throwing Knife" <3292795429>`, * - `[[247725512, 2387244414]]` is a valid value meaning "the weapon must * have plug 247725512 or 2387244414 available on it". * - Implementers should iterate the groups in `socketEntries`'s `plugSet` * info to determine the actual socket. (Recommended) * - `[[247725512], [2387244414]]` is a valid value meaning "the weapon must * have plug 247725512 and 2387244414 available on it on different sockets". * * Implementers must ignore any invalid combination they can't match. */ plugs: ItemHash[][]; /** * Optionally, one or more masterwork stats can be chosen which must also be * present for this roll to match. This is more convenient than having to * specify 10 plug hashes per masterwork stat. */ masterworkStats?: StatHash[]; /** * Tag for the current combination. This can be used to show special flair on * the item, as a search filter, or to allow users to select which types of * tags they want to import from a wishlist. * * All tags that are not ReservedTags should be treated as user-defined tags. */ tags?: Tag[]; } interface ItemRoll extends Roll { /** Inventory item hash this roll applies to. */ hash: ItemHash; } interface CategoryRoll extends Roll { /** * The subtypes of items this roll applies to. This allows targeting rolls to * "Shotguns" for example. */ categories: DestinyItemSubType[]; /** * Optional intrinsic perk hash, used to narrow this to a specific archetype. * * If you specify the intrinsic perk hash, you can also specify things like * "Adaptive Frame Scout Rifles with Surplus + Demolitionist are good". */ intrinsic?: ItemHash; } interface Author { /** The name of one of the authors of this wish list. */ name: string; /** An optional URL to a public profile or home page for the author. */ url?: string; }