Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactor iotsitewise source structure #67

Merged
merged 2 commits into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 51 additions & 74 deletions packages/components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,94 +5,98 @@
* It contains typing information for all components that exist in this project.
*/
import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";
import { IoTAppKit, Provider, SiteWiseAssetTreeQuery, SiteWiseTimeSeriesDataProvider, StyleSettingsMap, TimeSeriesData, TimeSeriesDataRequestSettings, TimeSeriesQuery } from "@iot-app-kit/core";
import { Annotations, MinimalViewPortConfig } from "@synchro-charts/core";
import { ColumnDefinition, FilterTexts, ResourceExplorerQuery, SitewiseAssetResource } from "./components/iot-resource-explorer/types";
import { Annotations, MinimalViewPortConfig, TableColumn } from "@synchro-charts/core";
import { Provider, StyleSettingsMap, TimeQuery, TimeSeriesData, TimeSeriesDataRequest, TimeSeriesDataRequestSettings, TreeQuery } from "@iot-app-kit/core";
import { BranchReference, SiteWiseAssetTreeNode } from "@iot-app-kit/source-iotsitewise";
import { ColumnDefinition, FilterTexts } from "./components/iot-resource-explorer/types";
import { TableProps } from "@awsui/components-react/table";
import { EmptyStateProps, ITreeNode, UseTreeCollection } from "@iot-app-kit/related-table";
import { NonCancelableCustomEvent } from "@awsui/components-react";
export namespace Components {
interface IotBarChart {
"annotations": Annotations;
"appKit": IoTAppKit;
"isEditing": boolean | undefined;
"queries": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>[];
"queries": TimeQuery<TimeSeriesData[], TimeSeriesDataRequest>[];
"settings": TimeSeriesDataRequestSettings;
"styleSettings": StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId": string;
}
interface IotKpi {
"annotations": Annotations;
"appKit": IoTAppKit;
"isEditing": boolean | undefined;
"queries": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>[];
"queries": TimeQuery<TimeSeriesData[], TimeSeriesDataRequest>[];
"settings": TimeSeriesDataRequestSettings;
"styleSettings": StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId": string;
}
interface IotLineChart {
"annotations": Annotations;
"appKit": IoTAppKit;
"isEditing": boolean | undefined;
"queries": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>[];
"queries": TimeQuery<TimeSeriesData[], TimeSeriesDataRequest>[];
"settings": TimeSeriesDataRequestSettings;
"styleSettings": StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId": string;
}
interface IotResourceExplorer {
"appKit": IoTAppKit;
"columnDefinitions"?: ColumnDefinition<SitewiseAssetResource>[];
"columnDefinitions": ColumnDefinition<any>[];
"empty"?: EmptyStateProps;
"filterEnabled": boolean;
"filterTexts"?: FilterTexts;
"loadingText"?: string;
"onSelectionChange": (event: NonCancelableCustomEvent<TableProps.SelectionChangeDetail<unknown>>) => void;
"paginationEnabled": boolean;
"query": ResourceExplorerQuery;
"query": TreeQuery<SiteWiseAssetTreeNode[], BranchReference>;
"selectionType"?: TableProps.SelectionType;
"sortingEnabled": boolean;
"widgetId": string;
"wrapLines": boolean;
}
interface IotResourceExplorerDemo {
}
interface IotScatterChart {
"annotations": Annotations;
"appKit": IoTAppKit;
"isEditing": boolean | undefined;
"queries": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>[];
"queries": TimeQuery<TimeSeriesData[], TimeSeriesDataRequest>[];
"settings": TimeSeriesDataRequestSettings;
"styleSettings": StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId": string;
}
interface IotStatusGrid {
"annotations": Annotations;
"appKit": IoTAppKit;
"isEditing": boolean | undefined;
"queries": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>[];
"queries": TimeQuery<TimeSeriesData[], TimeSeriesDataRequest>[];
"settings": TimeSeriesDataRequestSettings;
"styleSettings": StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId": string;
}
interface IotStatusTimeline {
"annotations": Annotations;
"appKit": IoTAppKit;
"isEditing": boolean | undefined;
"queries": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>[];
"queries": TimeQuery<TimeSeriesData[], TimeSeriesDataRequest>[];
"settings": TimeSeriesDataRequestSettings;
"styleSettings": StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId": string;
}
interface IotTable {
"annotations": Annotations;
"queries": TimeQuery<TimeSeriesData[], TimeSeriesDataRequest>[];
"settings": TimeSeriesDataRequestSettings;
"styleSettings": StyleSettingsMap | undefined;
"tableColumns": TableColumn[];
"viewport": MinimalViewPortConfig;
"widgetId": string;
}
interface IotTestRoutes {
}
interface IotTimeSeriesConnector {
"initialViewport": MinimalViewPortConfig;
"provider": Provider<TimeSeriesData>;
"provider": Provider<TimeSeriesData[]>;
"renderFunc": (data: TimeSeriesData) => void;
"styleSettings": StyleSettingsMap | undefined;
}
Expand All @@ -118,21 +122,6 @@ export namespace Components {
}
interface IotWebglContext {
}
interface SitewiseResourceExplorer {
"appKit": IoTAppKit;
"columnDefinitions": ColumnDefinition<any>[];
"empty"?: EmptyStateProps;
"filterEnabled": boolean;
"filterTexts"?: FilterTexts;
"loadingText"?: string;
"onSelectionChange": (event: NonCancelableCustomEvent<TableProps.SelectionChangeDetail<unknown>>) => void;
"paginationEnabled": boolean;
"query": SiteWiseAssetTreeQuery;
"selectionType"?: TableProps.SelectionType;
"sortingEnabled": boolean;
"widgetId": string;
"wrapLines": boolean;
}
interface TestingGround {
}
}
Expand Down Expand Up @@ -185,6 +174,12 @@ declare global {
prototype: HTMLIotStatusTimelineElement;
new (): HTMLIotStatusTimelineElement;
};
interface HTMLIotTableElement extends Components.IotTable, HTMLStencilElement {
}
var HTMLIotTableElement: {
prototype: HTMLIotTableElement;
new (): HTMLIotTableElement;
};
interface HTMLIotTestRoutesElement extends Components.IotTestRoutes, HTMLStencilElement {
}
var HTMLIotTestRoutesElement: {
Expand Down Expand Up @@ -215,12 +210,6 @@ declare global {
prototype: HTMLIotWebglContextElement;
new (): HTMLIotWebglContextElement;
};
interface HTMLSitewiseResourceExplorerElement extends Components.SitewiseResourceExplorer, HTMLStencilElement {
}
var HTMLSitewiseResourceExplorerElement: {
prototype: HTMLSitewiseResourceExplorerElement;
new (): HTMLSitewiseResourceExplorerElement;
};
interface HTMLTestingGroundElement extends Components.TestingGround, HTMLStencilElement {
}
var HTMLTestingGroundElement: {
Expand All @@ -236,97 +225,100 @@ declare global {
"iot-scatter-chart": HTMLIotScatterChartElement;
"iot-status-grid": HTMLIotStatusGridElement;
"iot-status-timeline": HTMLIotStatusTimelineElement;
"iot-table": HTMLIotTableElement;
"iot-test-routes": HTMLIotTestRoutesElement;
"iot-time-series-connector": HTMLIotTimeSeriesConnectorElement;
"iot-tree-table": HTMLIotTreeTableElement;
"iot-tree-table-demo": HTMLIotTreeTableDemoElement;
"iot-webgl-context": HTMLIotWebglContextElement;
"sitewise-resource-explorer": HTMLSitewiseResourceExplorerElement;
"testing-ground": HTMLTestingGroundElement;
}
}
declare namespace LocalJSX {
interface IotBarChart {
"annotations"?: Annotations;
"appKit": IoTAppKit;
"isEditing"?: boolean | undefined;
"queries": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>[];
"queries": TimeQuery<TimeSeriesData[], TimeSeriesDataRequest>[];
"settings"?: TimeSeriesDataRequestSettings;
"styleSettings"?: StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId"?: string;
}
interface IotKpi {
"annotations"?: Annotations;
"appKit": IoTAppKit;
"isEditing"?: boolean | undefined;
"queries": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>[];
"queries": TimeQuery<TimeSeriesData[], TimeSeriesDataRequest>[];
"settings"?: TimeSeriesDataRequestSettings;
"styleSettings"?: StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId"?: string;
}
interface IotLineChart {
"annotations"?: Annotations;
"appKit": IoTAppKit;
"isEditing"?: boolean | undefined;
"queries": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>[];
"queries": TimeQuery<TimeSeriesData[], TimeSeriesDataRequest>[];
"settings"?: TimeSeriesDataRequestSettings;
"styleSettings"?: StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId"?: string;
}
interface IotResourceExplorer {
"appKit"?: IoTAppKit;
"columnDefinitions"?: ColumnDefinition<SitewiseAssetResource>[];
"columnDefinitions"?: ColumnDefinition<any>[];
"empty"?: EmptyStateProps;
"filterEnabled"?: boolean;
"filterTexts"?: FilterTexts;
"loadingText"?: string;
"onSelectionChange"?: (event: NonCancelableCustomEvent<TableProps.SelectionChangeDetail<unknown>>) => void;
"paginationEnabled"?: boolean;
"query"?: ResourceExplorerQuery;
"query"?: TreeQuery<SiteWiseAssetTreeNode[], BranchReference>;
"selectionType"?: TableProps.SelectionType;
"sortingEnabled"?: boolean;
"widgetId"?: string;
"wrapLines"?: boolean;
}
interface IotResourceExplorerDemo {
}
interface IotScatterChart {
"annotations"?: Annotations;
"appKit": IoTAppKit;
"isEditing"?: boolean | undefined;
"queries": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>[];
"queries": TimeQuery<TimeSeriesData[], TimeSeriesDataRequest>[];
"settings"?: TimeSeriesDataRequestSettings;
"styleSettings"?: StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId"?: string;
}
interface IotStatusGrid {
"annotations"?: Annotations;
"appKit": IoTAppKit;
"isEditing"?: boolean | undefined;
"queries": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>[];
"queries": TimeQuery<TimeSeriesData[], TimeSeriesDataRequest>[];
"settings"?: TimeSeriesDataRequestSettings;
"styleSettings"?: StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId"?: string;
}
interface IotStatusTimeline {
"annotations"?: Annotations;
"appKit": IoTAppKit;
"isEditing"?: boolean | undefined;
"queries": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>[];
"queries": TimeQuery<TimeSeriesData[], TimeSeriesDataRequest>[];
"settings"?: TimeSeriesDataRequestSettings;
"styleSettings"?: StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId"?: string;
}
interface IotTable {
"annotations"?: Annotations;
"queries": TimeQuery<TimeSeriesData[], TimeSeriesDataRequest>[];
"settings"?: TimeSeriesDataRequestSettings;
"styleSettings"?: StyleSettingsMap | undefined;
"tableColumns"?: TableColumn[];
"viewport": MinimalViewPortConfig;
"widgetId"?: string;
}
interface IotTestRoutes {
}
interface IotTimeSeriesConnector {
"initialViewport"?: MinimalViewPortConfig;
"provider"?: Provider<TimeSeriesData>;
"provider"?: Provider<TimeSeriesData[]>;
"renderFunc"?: (data: TimeSeriesData) => void;
"styleSettings"?: StyleSettingsMap | undefined;
}
Expand All @@ -352,21 +344,6 @@ declare namespace LocalJSX {
}
interface IotWebglContext {
}
interface SitewiseResourceExplorer {
"appKit"?: IoTAppKit;
"columnDefinitions"?: ColumnDefinition<any>[];
"empty"?: EmptyStateProps;
"filterEnabled"?: boolean;
"filterTexts"?: FilterTexts;
"loadingText"?: string;
"onSelectionChange"?: (event: NonCancelableCustomEvent<TableProps.SelectionChangeDetail<unknown>>) => void;
"paginationEnabled"?: boolean;
"query"?: SiteWiseAssetTreeQuery;
"selectionType"?: TableProps.SelectionType;
"sortingEnabled"?: boolean;
"widgetId"?: string;
"wrapLines"?: boolean;
}
interface TestingGround {
}
interface IntrinsicElements {
Expand All @@ -378,12 +355,12 @@ declare namespace LocalJSX {
"iot-scatter-chart": IotScatterChart;
"iot-status-grid": IotStatusGrid;
"iot-status-timeline": IotStatusTimeline;
"iot-table": IotTable;
"iot-test-routes": IotTestRoutes;
"iot-time-series-connector": IotTimeSeriesConnector;
"iot-tree-table": IotTreeTable;
"iot-tree-table-demo": IotTreeTableDemo;
"iot-webgl-context": IotWebglContext;
"sitewise-resource-explorer": SitewiseResourceExplorer;
"testing-ground": TestingGround;
}
}
Expand All @@ -399,12 +376,12 @@ declare module "@stencil/core" {
"iot-scatter-chart": LocalJSX.IotScatterChart & JSXBase.HTMLAttributes<HTMLIotScatterChartElement>;
"iot-status-grid": LocalJSX.IotStatusGrid & JSXBase.HTMLAttributes<HTMLIotStatusGridElement>;
"iot-status-timeline": LocalJSX.IotStatusTimeline & JSXBase.HTMLAttributes<HTMLIotStatusTimelineElement>;
"iot-table": LocalJSX.IotTable & JSXBase.HTMLAttributes<HTMLIotTableElement>;
"iot-test-routes": LocalJSX.IotTestRoutes & JSXBase.HTMLAttributes<HTMLIotTestRoutesElement>;
"iot-time-series-connector": LocalJSX.IotTimeSeriesConnector & JSXBase.HTMLAttributes<HTMLIotTimeSeriesConnectorElement>;
"iot-tree-table": LocalJSX.IotTreeTable & JSXBase.HTMLAttributes<HTMLIotTreeTableElement>;
"iot-tree-table-demo": LocalJSX.IotTreeTableDemo & JSXBase.HTMLAttributes<HTMLIotTreeTableDemoElement>;
"iot-webgl-context": LocalJSX.IotWebglContext & JSXBase.HTMLAttributes<HTMLIotWebglContextElement>;
"sitewise-resource-explorer": LocalJSX.SitewiseResourceExplorer & JSXBase.HTMLAttributes<HTMLSitewiseResourceExplorerElement>;
"testing-ground": LocalJSX.TestingGround & JSXBase.HTMLAttributes<HTMLTestingGroundElement>;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import { newSpecPage } from '@stencil/core/testing';
import { MinimalLiveViewport } from '@synchro-charts/core';
import { IotBarChart } from './iot-bar-chart';
import { Components } from '../../components.d';
import { initialize } from '@iot-app-kit/core';
import { query } from '@iot-app-kit/source-iotsitewise';
import { createMockSource } from '../../testing/createMockSource';
import { DATA_STREAM } from '../../testing/mockWidgetProperties';
import { IotTimeSeriesConnector } from '../iot-time-series-connector.ts/iot-time-series-connector';
import { initialize } from '@iot-app-kit/source-iotsitewise';
import { IotTimeSeriesConnector } from '../iot-time-series-connector/iot-time-series-connector';
import { CustomHTMLElement } from '../../testing/types';
import { update } from '../../testing/update';
import { mockSiteWiseSDK } from '../../testing/mocks/siteWiseSDK';
Expand All @@ -16,11 +13,9 @@ const viewport: MinimalLiveViewport = {
};

const barChartSpecPage = async (propOverrides: Partial<Components.IotBarChart> = {}) => {
const appKit = initialize({
registerDataSources: false,
const { query } = initialize({
iotSiteWiseClient: mockSiteWiseSDK,
});
appKit.registerTimeSeriesDataSource(createMockSource([DATA_STREAM]));

const page = await newSpecPage({
components: [IotBarChart, IotTimeSeriesConnector],
Expand All @@ -29,12 +24,10 @@ const barChartSpecPage = async (propOverrides: Partial<Components.IotBarChart> =
});
const barChart = page.doc.createElement('iot-bar-chart') as CustomHTMLElement<Components.IotBarChart>;
const props: Partial<Components.IotBarChart> = {
appKit,
widgetId: 'test-bar-chart-widget',
isEditing: false,
viewport,
queries: [
query.iotsitewise.timeSeriesData({
query.timeSeriesData({
assets: [{ assetId: 'some-asset-id', properties: [{ propertyId: 'some-property-id' }] }],
}),
],
Expand Down
Loading