@apistudio/apim-cli
Version:
CLI for API Management Products
56 lines (47 loc) • 2.08 kB
text/typescript
import { MasterContent, RuntimeInventory } from "@apic/smith-inventory";
import { getMasterContent } from "../resources/wmgw-smith-master.js";
import { getCombinedSource } from "../resources/wmgw-smith-schemas-json.js";
import { getDefaultVersions } from "../resources/wmgw-smith-defaultVersion.js";
import { getCombinedRuleset } from "../resources/wmgw-smith-ruleset.js";
export class WMGWRuntimeInventory extends RuntimeInventory {
public webmMasterContent: MasterContent;
public webmSchemaDefinitions: Record<string, any>;
public webmDefaultVersionMap: Record<string, string>;
private webmRulesetDefinitions: Record<string, any>;
constructor() {
super();
this.extendDefaultVersions(getDefaultVersions(),true);
this.extendRulesetDefinitions(getCombinedRuleset(),true);
this.extendSchemaDefinitions(getCombinedSource(),true);
try{
// Add custom master content
this.webmMasterContent=getMasterContent();
// Add custom schema definitions
this.webmSchemaDefinitions=getCombinedSource();
// Add custom default versions
this.webmDefaultVersionMap=getDefaultVersions();
this.webmRulesetDefinitions=getCombinedRuleset();
} catch (error) {
this.webmSchemaDefinitions = {};
this.webmRulesetDefinitions = {};
this.webmDefaultVersionMap = {};
this.webmMasterContent = {};
}
}
/**
* Hook method for subclasses to populate their extensions before schema retrieval
* This is called automatically by getSchema() before looking up the schema
* @param key - The kind name and version requested being requested
*/
public getOverriddenSchema(key: string): any {
return this.webmSchemaDefinitions[key];
}
/**
* Hook method for subclasses to populate their extensions before schema retrieval
* This is called automatically by getSchema() before looking up the schema
* @param key - The kind name and version requested being requested
*/
public getOverriddenRule(key: string): any {
return this.webmRulesetDefinitions[key]
}
}