Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shaungrady committed Aug 7, 2020
1 parent 226a3a1 commit 08ac176
Show file tree
Hide file tree
Showing 54 changed files with 2,750 additions and 2 deletions.
16 changes: 16 additions & 0 deletions lib/cjs/api/api.class.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ApiCallGenerator, ApiConfig, ApiCallGeneratorConfig, ApiCallOptions } from './api.types';
export default class Api {
readonly key: string;
static readonly defaultOrigin = "https://monitoringapi.solaredge.com";
static readonly dateFormat = "yyyy-MM-dd";
static readonly dateTimeFormat = "yyyy-MM-dd HH:mm:ss";
static isValidApiKey(key: string): boolean;
static serializeDate(date: Date): string;
static serializeDateTime(date: Date): string;
private static parseDateOrTimeRange;
private static serializeRange;
readonly config: Readonly<ApiConfig>;
constructor(key: string, config?: Partial<ApiConfig>);
call<T>(path: string, options?: Partial<ApiCallOptions>): Promise<T>;
callGenerator<T>(config: ApiCallGeneratorConfig<T>): ApiCallGenerator<T>;
}
133 changes: 133 additions & 0 deletions lib/cjs/api/api.class.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/cjs/api/api.class.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 83 additions & 0 deletions lib/cjs/api/api.types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
export interface ApiConfig {
/**
* URL origin of the API without a trailing slash.
* @default https://monitoringapi.solaredge.com
*/
origin: string;
}
export interface DateRange {
dateRange: [Date, Date];
}
export interface DateRangeParams {
startDate: Date;
endDate: Date;
}
export interface DateTimeRange {
timeRange: [Date, Date];
}
export interface DateTimeRangeParams {
startTime: Date;
endTime: Date;
}
export declare type DateOrTimeRange = DateRange | DateTimeRange;
export declare type DateOrTimeRangeParams = DateRangeParams | DateTimeRangeParams;
export interface TimeUnitParam {
timeUnit: TimeUnit;
}
export declare type Serialized<T> = T extends Date ? string : T extends object ? {
[k in keyof T]: Serialized<T[k]>;
} : T;
export declare const enum TimeUnit {
QuarterHour = "QUARTER_OF_AN_HOUR",
Hour = "HOUR",
Day = "DAY",
Week = "WEEK",
Month = "MONTH",
Year = "YEAR"
}
export declare const enum SortOrder {
Ascending = "ASC",
Descending = "DESC"
}
export declare const enum SiteStatus {
Active = "Active",
Pending = "Pending",
Disabled = "Disabled",
All = "All"
}
export declare const enum Meter {
Production = "Production",
Consumption = "Consumption",
SelfConsumption = "SelfConsumption",
FeedIn = "FeedIn",
Purchased = "Purchased"
}
export interface ApiCallOptions {
params: Record<string, any>;
}
export declare type ApiCallGeneratorConfig<T> = {
apiPath: string;
interval: Duration;
timeUnit?: TimeUnit;
/** Parses the API response into a collection to be iterated over. */
parser: (res: any) => T[];
} & DateOrTimeRange;
/**
* Generator that yields individual collection items, lazily calling the API to
* fetch more. Returns number of API calls performed.
*/
export declare type ApiCallGenerator<T> = AsyncGenerator<T, ApiCallGeneratorReturn, void>;
export interface ApiCallGeneratorReturn {
config: ApiCallGeneratorConfig<unknown>;
apiCallTotal: number;
recordTotal: number;
}
export interface Range {
type: RangeType;
start: Date;
end: Date;
}
export declare enum RangeType {
Date = 0,
DateTime = 1
}
9 changes: 9 additions & 0 deletions lib/cjs/api/api.types.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/cjs/api/api.types.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions lib/cjs/client/client.class.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ApiCallGenerator, DateRange, DateTimeRange, TimeUnitParam } from '../api/api.types';
import { EquipmentChange, InverterTelemetry, SiteDataPeriod, SiteDetails, SiteEnvironmentalBenefits, SiteEquipmentList, SiteMeasurement, SitesParams, SolaredgeClientOptions } from './client.types';
export default class Client {
private readonly api;
constructor({ apiKey, apiOrigin }: SolaredgeClientOptions);
/**
* Returns a list of sites related to the given token, which is the account api key.
* This API accepts parameters for convenient search, sort and pagination.
*/
fetchSiteList(params?: SitesParams): Promise<SiteDetails[]>;
fetchSiteDetails(siteId: string): Promise<SiteDetails>;
/**
* Return the energy production start and end dates of the site.
*/
fetchSiteDataPeriod(siteId: string): Promise<SiteDataPeriod>;
fetchSiteEnergyGenerator(siteId: string, options: DateRange & Partial<TimeUnitParam>): ApiCallGenerator<SiteMeasurement>;
fetchSitePowerGenerator(siteId: string, options: DateTimeRange): ApiCallGenerator<SiteMeasurement>;
fetchSiteCurrentPowerFlow(siteId: string): Promise<unknown>;
fetchSiteStorageData(siteId: string): Promise<unknown>;
fetchSiteEnvironmentalBenefits(siteId: string, metricUnits?: boolean): Promise<SiteEnvironmentalBenefits>;
fetchSiteEquipmentList(siteId: string): Promise<SiteEquipmentList>;
fetchSiteEquipmentChangeLog(siteId: string, equipmentId: string): Promise<EquipmentChange[]>;
fetchInverterTelemetryGenerator(siteId: string, inverterId: string, options: DateTimeRange): ApiCallGenerator<InverterTelemetry>;
private static measurementsResponseParser;
}
Loading

0 comments on commit 08ac176

Please sign in to comment.