Skip to content

Commit

Permalink
Add missing exports
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexagon committed Feb 7, 2023
1 parent fa3447e commit aa7b6e3
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
66 changes: 65 additions & 1 deletion mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,72 @@ const QueryConfiguration = async (securityToken: string, params: QueryParameters
return [];
};

/**
* Fetch and process Balancing_MarketDocument(s)
*
* Identifies the fetched docuement, validates key features, and returns an array of typed documents
*
* If the query yield smething other than Balancing_MarketDocument(s), an error will be thrown.
*
* @public
*
* @param securityToken - Entsoe API security token/key
* @param params - Object with all requested parameters
*
* @returns - Array of typed documents
*/
const QueryBalancing = async (securityToken: string, params: QueryParameters): Promise<BalancingDocument[]> => {
const result = await Query(securityToken, params);
if (result && Array.isArray(result) && result.length && result[0].rootType === "balancing") return result as BalancingDocument[];
if (result && Array.isArray(result) && result.length && result[0].rootType !== "balancing") throw new Error("Got " + result[0].rootType + " when expecting balancing document")
return [];
};

/**
* Fetch and process TransmissionNetwork_MarketDocument(s)
*
* Identifies the fetched docuement, validates key features, and returns an array of typed documents
*
* If the query yield smething other than TransmissionNetwork_MarketDocument(s), an error will be thrown.
*
* @public
*
* @param securityToken - Entsoe API security token/key
* @param params - Object with all requested parameters
*
* @returns - Array of typed documents
*/
const QueryTransmissionNetwork = async (securityToken: string, params: QueryParameters): Promise<TransmissionNetworkDocument[]> => {
const result = await Query(securityToken, params);
if (result && Array.isArray(result) && result.length && result[0].rootType === "transmissionnetwork") return result as TransmissionNetworkDocument[];
if (result && Array.isArray(result) && result.length && result[0].rootType !== "transmissionnetwork") throw new Error("Got " + result[0].rootType + " when expecting transmissionnetwork document")
return [];
};

/**
* Fetch and process CriticalNetworkElement_MarketDocument(s)
*
* Identifies the fetched docuement, validates key features, and returns an array of typed documents
*
* If the query yield smething other than CriticalNetworkElement_MarketDocument(s), an error will be thrown.
*
* @public
*
* @param securityToken - Entsoe API security token/key
* @param params - Object with all requested parameters
*
* @returns - Array of typed documents
*/
const QueryCriticalNetworkElement = async (securityToken: string, params: QueryParameters): Promise<CriticalNetworkElementDocument[]> => {
const result = await Query(securityToken, params);
if (result && Array.isArray(result) && result.length && result[0].rootType === "criticalnetworkelement") return result as CriticalNetworkElementDocument[];
if (result && Array.isArray(result) && result.length && result[0].rootType !== "criticalnetworkelement") throw new Error("Got " + result[0].rootType + " when expecting criticalnetworkelement document")
return [];
};


/** Export all functions intended for public use */
export { Query, QueryPublication, QueryGL, QueryUnavailability, QueryConfiguration };
export { Query, QueryPublication, QueryGL, QueryUnavailability, QueryConfiguration, QueryBalancing, QueryTransmissionNetwork, QueryCriticalNetworkElement };

/** Export all types intended for public use */
export type { GLDocument, PublicationDocument, UnavailabilityDocument, ConfigurationDocument, QueryParameters, TransmissionNetworkDocument, CriticalNetworkElementDocument, BalancingDocument};
2 changes: 1 addition & 1 deletion src/documents/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ interface Period {
interface BaseDocument {
mRID: string;
revision?: number;
rootType?: "configuration" | "gl" | "unavailability" | "publication";
rootType?: "configuration" | "gl" | "unavailability" | "publication" | "balancing" | "criticalnetworkelement" | "transmissionnetwork";
created?: Date;
documentType: string;
documentTypeDescription?: string;
Expand Down

0 comments on commit aa7b6e3

Please sign in to comment.