Skip to content

Commit 9226316

Browse files
committed
Detect unreferenced manifest tables
1 parent a84e9f4 commit 9226316

5 files changed

Lines changed: 243 additions & 9 deletions

File tree

generated-src/destiny2/interfaces.ts

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15512,3 +15512,112 @@ export interface DestinyItemFilterDefinition {
1551215512
*/
1551315513
readonly redacted: boolean;
1551415514
}
15515+
15516+
export interface DestinyGlobalConstantsDefinition {
15517+
/** Assorted constants for Pathfinder objectives */
15518+
readonly pathfinderConstants: DestinyPathfinderConstantsDefinition;
15519+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15520+
readonly collectionsRootNodeHash: number;
15521+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15522+
readonly collectionBadgesRootNodeHash: number;
15523+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15524+
readonly activeTriumphsRootNodeHash: number;
15525+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15526+
readonly activeSealsRootNodeHash: number;
15527+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15528+
readonly legacyTriumphsRootNodeHash: number;
15529+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15530+
readonly legacySealsRootNodeHash: number;
15531+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15532+
readonly medalsRootNodeHash: number;
15533+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15534+
readonly exoticCatalystsRootNodeHash: number;
15535+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15536+
readonly loreRootNodeHash: number;
15537+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15538+
readonly metricsRootNodeHash: number;
15539+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15540+
readonly craftingRootNodeHash: number;
15541+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15542+
readonly guardianRanksRootNodeHash: number;
15543+
/** Mapped to DestinyEventCardDefinition in the manifest. */
15544+
readonly seasonalHubEventCardHash: number;
15545+
readonly destinyRewardPassRankSealImages: DestinyRewardPassRankSealImages;
15546+
readonly destinySeasonalHubRankIconImages: DestinySeasonalHubRankIconImages;
15547+
/** Mapped to DestinyPlugSetDefinition in the manifest. */
15548+
readonly armorArchetypePlugSetHash: number;
15549+
/** Mapped to DestinyItemFilterDefinition in the manifest. */
15550+
readonly featuredItemsListHash: number;
15551+
/**
15552+
* The unique identifier for this entity. Guaranteed to be unique for the type of
15553+
* entity, but not globally.
15554+
*
15555+
* When entities refer to each other in Destiny content, it is this hash that they
15556+
* are referring to.
15557+
*/
15558+
readonly hash: number;
15559+
/** The index of the entity as it was found in the investment tables. */
15560+
readonly index: number;
15561+
/**
15562+
* If this is true, then there is an entity with this identifier/type combination,
15563+
* but BNet is not yet allowed to show it. Sorry!
15564+
*/
15565+
readonly redacted: boolean;
15566+
}
15567+
15568+
export interface DestinyPathfinderConstantsDefinition {
15569+
/**
15570+
* Pathfinder root node for The Pale Heart
15571+
*
15572+
* Mapped to DestinyPresentationNodeDefinition in the manifest.
15573+
*/
15574+
readonly thePaleHeartPathfinderRootNodeHash: number;
15575+
/**
15576+
* Root presentation nodes for all currently valid Pathfinder boards
15577+
*
15578+
* Mapped to DestinyPresentationNodeDefinition in the manifest.
15579+
*/
15580+
readonly allPathfinderRootNodeHashes: number[];
15581+
/**
15582+
* The current shape of Pathfinder boards, where a Pathfinder board is stored as as
15583+
* flat list of Records. The key of this dictionary is the index at which a tier
15584+
* starts, and the value is the total number of objectives in the tier.
15585+
*/
15586+
readonly pathfinderTreeTiers: { [key: number]: number };
15587+
/**
15588+
* The topology of the Pathfinder board. The key is the index of the Record in the
15589+
* Pathfinder board, and the value is a list of the indices of Records that are
15590+
* connected to the Key Record. Using this topology, clients can ascertain if a
15591+
* Record can be unlocked, by checking if the objective of any connected Record has
15592+
* been completed and/or claimed.
15593+
*/
15594+
readonly pathfinderTopology: { [key: number]: number[] };
15595+
/**
15596+
* The unique identifier for this entity. Guaranteed to be unique for the type of
15597+
* entity, but not globally.
15598+
*
15599+
* When entities refer to each other in Destiny content, it is this hash that they
15600+
* are referring to.
15601+
*/
15602+
readonly hash: number;
15603+
/** The index of the entity as it was found in the investment tables. */
15604+
readonly index: number;
15605+
/**
15606+
* If this is true, then there is an entity with this identifier/type combination,
15607+
* but BNet is not yet allowed to show it. Sorry!
15608+
*/
15609+
readonly redacted: boolean;
15610+
}
15611+
15612+
export interface DestinyRewardPassRankSealImages {
15613+
readonly rewardPassRankSealImagePath: string;
15614+
readonly rewardPassRankSealPremiumImagePath: string;
15615+
readonly rewardPassRankSealPrestigeImagePath: string;
15616+
readonly rewardPassRankSealPremiumPrestigeImagePath: string;
15617+
}
15618+
15619+
export interface DestinySeasonalHubRankIconImages {
15620+
readonly seasonalHubRankIconUnearned: string;
15621+
readonly seasonalHubRankIconEarning: string;
15622+
readonly seasonalHubRankIconActive: string;
15623+
}

generated-src/destiny2/manifest.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ import {
9292
DestinyGuardianRankConstantsDefinition,
9393
DestinyLoadoutConstantsDefinition,
9494
DestinyFireteamFinderConstantsDefinition,
95+
DestinyGlobalConstantsDefinition,
9596
DestinyInventoryItemConstantsDefinition,
9697
DestinyManifest
9798
} from './interfaces.js';
@@ -180,6 +181,7 @@ export interface AllDestinyManifestComponents {
180181
DestinyGuardianRankConstantsDefinition: { [key: number]: DestinyGuardianRankConstantsDefinition };
181182
DestinyLoadoutConstantsDefinition: { [key: number]: DestinyLoadoutConstantsDefinition };
182183
DestinyFireteamFinderConstantsDefinition: { [key: number]: DestinyFireteamFinderConstantsDefinition };
184+
DestinyGlobalConstantsDefinition: { [key: number]: DestinyGlobalConstantsDefinition };
183185
DestinyInventoryItemConstantsDefinition: { [key: number]: DestinyInventoryItemConstantsDefinition };
184186
}
185187

generator/type-index.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,26 @@ export function computeTypeMaps(
2222
const allDefsEverywhere = new Set<string>();
2323
const defsByTag: { [tag: string]: Set<string> } = {};
2424
_.each(pathPairsByTag, (paths, tag) => {
25-
const defs = findReachableComponents(tag, paths, doc);
25+
const defs = findReachableComponents(paths, doc);
2626
addAll(allDefsEverywhere, defs);
2727
defsByTag[tag] = defs;
2828
});
2929

30+
// Add manifest tables that aren't referenced by any API endpoint.
31+
for (const [defName, def] of Object.entries(doc.components!.schemas!)) {
32+
const typePath = `#/components/schemas/${defName}`;
33+
if (
34+
!allDefsEverywhere.has(typePath) &&
35+
'type' in def &&
36+
def.type === 'object' &&
37+
def['x-mobile-manifest-name']
38+
) {
39+
console.log(`Found unreferenced manifest table ${typePath}`);
40+
allDefsEverywhere.add(typePath);
41+
addReachableComponentsFromComponent(allDefsEverywhere, typePath, doc);
42+
}
43+
}
44+
3045
const allTags = Object.keys(pathPairsByTag);
3146

3247
const componentsByFile: { [filename: string]: DefInfo[] } = {};
@@ -78,14 +93,9 @@ function chooseFile(def: string, tags: string[], allTags: string[]) {
7893
}
7994
}
8095

81-
function findReachableComponents(
82-
tag: string,
83-
paths: [string, PathItemObject][],
84-
doc: OpenAPIObject
85-
) {
96+
function findReachableComponents(paths: [string, PathItemObject][], doc: OpenAPIObject) {
8697
const pathDefinitions = paths.reduce(
87-
(memo: Set<string>, [_, pathDef]) =>
88-
addAll(memo, findReachableComponentsFromPath(pathDef, doc)),
98+
(memo: Set<string>, [_, pathDef]) => addAll(memo, findReachableComponentsFromPath(pathDef)),
8999
new Set<string>()
90100
);
91101

@@ -103,7 +113,7 @@ function addAll<T>(first: Set<T>, second: Set<T>): Set<T> {
103113
return first;
104114
}
105115

106-
function findReachableComponentsFromPath(pathDef: PathItemObject, doc: OpenAPIObject): Set<string> {
116+
function findReachableComponentsFromPath(pathDef: PathItemObject): Set<string> {
107117
const methodDef = pathDef.get || pathDef.post!;
108118
const params = (methodDef.parameters || []) as ParameterObject[];
109119
const paramTypes = new Set(

lib/destiny2/interfaces.d.ts

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15133,3 +15133,112 @@ export interface DestinyItemFilterDefinition {
1513315133
*/
1513415134
readonly redacted: boolean;
1513515135
}
15136+
export interface DestinyGlobalConstantsDefinition {
15137+
/** Assorted constants for Pathfinder objectives */
15138+
readonly pathfinderConstants: DestinyPathfinderConstantsDefinition;
15139+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15140+
readonly collectionsRootNodeHash: number;
15141+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15142+
readonly collectionBadgesRootNodeHash: number;
15143+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15144+
readonly activeTriumphsRootNodeHash: number;
15145+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15146+
readonly activeSealsRootNodeHash: number;
15147+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15148+
readonly legacyTriumphsRootNodeHash: number;
15149+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15150+
readonly legacySealsRootNodeHash: number;
15151+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15152+
readonly medalsRootNodeHash: number;
15153+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15154+
readonly exoticCatalystsRootNodeHash: number;
15155+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15156+
readonly loreRootNodeHash: number;
15157+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15158+
readonly metricsRootNodeHash: number;
15159+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15160+
readonly craftingRootNodeHash: number;
15161+
/** Mapped to DestinyPresentationNodeDefinition in the manifest. */
15162+
readonly guardianRanksRootNodeHash: number;
15163+
/** Mapped to DestinyEventCardDefinition in the manifest. */
15164+
readonly seasonalHubEventCardHash: number;
15165+
readonly destinyRewardPassRankSealImages: DestinyRewardPassRankSealImages;
15166+
readonly destinySeasonalHubRankIconImages: DestinySeasonalHubRankIconImages;
15167+
/** Mapped to DestinyPlugSetDefinition in the manifest. */
15168+
readonly armorArchetypePlugSetHash: number;
15169+
/** Mapped to DestinyItemFilterDefinition in the manifest. */
15170+
readonly featuredItemsListHash: number;
15171+
/**
15172+
* The unique identifier for this entity. Guaranteed to be unique for the type of
15173+
* entity, but not globally.
15174+
*
15175+
* When entities refer to each other in Destiny content, it is this hash that they
15176+
* are referring to.
15177+
*/
15178+
readonly hash: number;
15179+
/** The index of the entity as it was found in the investment tables. */
15180+
readonly index: number;
15181+
/**
15182+
* If this is true, then there is an entity with this identifier/type combination,
15183+
* but BNet is not yet allowed to show it. Sorry!
15184+
*/
15185+
readonly redacted: boolean;
15186+
}
15187+
export interface DestinyPathfinderConstantsDefinition {
15188+
/**
15189+
* Pathfinder root node for The Pale Heart
15190+
*
15191+
* Mapped to DestinyPresentationNodeDefinition in the manifest.
15192+
*/
15193+
readonly thePaleHeartPathfinderRootNodeHash: number;
15194+
/**
15195+
* Root presentation nodes for all currently valid Pathfinder boards
15196+
*
15197+
* Mapped to DestinyPresentationNodeDefinition in the manifest.
15198+
*/
15199+
readonly allPathfinderRootNodeHashes: number[];
15200+
/**
15201+
* The current shape of Pathfinder boards, where a Pathfinder board is stored as as
15202+
* flat list of Records. The key of this dictionary is the index at which a tier
15203+
* starts, and the value is the total number of objectives in the tier.
15204+
*/
15205+
readonly pathfinderTreeTiers: {
15206+
[key: number]: number;
15207+
};
15208+
/**
15209+
* The topology of the Pathfinder board. The key is the index of the Record in the
15210+
* Pathfinder board, and the value is a list of the indices of Records that are
15211+
* connected to the Key Record. Using this topology, clients can ascertain if a
15212+
* Record can be unlocked, by checking if the objective of any connected Record has
15213+
* been completed and/or claimed.
15214+
*/
15215+
readonly pathfinderTopology: {
15216+
[key: number]: number[];
15217+
};
15218+
/**
15219+
* The unique identifier for this entity. Guaranteed to be unique for the type of
15220+
* entity, but not globally.
15221+
*
15222+
* When entities refer to each other in Destiny content, it is this hash that they
15223+
* are referring to.
15224+
*/
15225+
readonly hash: number;
15226+
/** The index of the entity as it was found in the investment tables. */
15227+
readonly index: number;
15228+
/**
15229+
* If this is true, then there is an entity with this identifier/type combination,
15230+
* but BNet is not yet allowed to show it. Sorry!
15231+
*/
15232+
readonly redacted: boolean;
15233+
}
15234+
export interface DestinyRewardPassRankSealImages {
15235+
readonly rewardPassRankSealImagePath: string;
15236+
readonly rewardPassRankSealPremiumImagePath: string;
15237+
readonly rewardPassRankSealPrestigeImagePath: string;
15238+
readonly rewardPassRankSealPremiumPrestigeImagePath: string;
15239+
}
15240+
export interface DestinySeasonalHubRankIconImages {
15241+
readonly seasonalHubRankIconUnearned: string;
15242+
readonly seasonalHubRankIconEarning: string;
15243+
readonly seasonalHubRankIconActive: string;
15244+
}

lib/destiny2/manifest.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ import {
9090
DestinyGuardianRankConstantsDefinition,
9191
DestinyLoadoutConstantsDefinition,
9292
DestinyFireteamFinderConstantsDefinition,
93+
DestinyGlobalConstantsDefinition,
9394
DestinyInventoryItemConstantsDefinition,
9495
DestinyManifest,
9596
} from './interfaces.js';
@@ -333,6 +334,9 @@ export interface AllDestinyManifestComponents {
333334
DestinyFireteamFinderConstantsDefinition: {
334335
[key: number]: DestinyFireteamFinderConstantsDefinition;
335336
};
337+
DestinyGlobalConstantsDefinition: {
338+
[key: number]: DestinyGlobalConstantsDefinition;
339+
};
336340
DestinyInventoryItemConstantsDefinition: {
337341
[key: number]: DestinyInventoryItemConstantsDefinition;
338342
};

0 commit comments

Comments
 (0)