diff --git a/packages/components/package.json b/packages/components/package.json index c70fba19d..5efefe1f1 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -32,6 +32,7 @@ "@awsui/design-tokens": "^3.0.0", "@iot-app-kit/core": "0.0.1", "@iot-app-kit/related-table": "1.0.0", + "@iot-app-kit/source-iotsitewise": "0.0.1", "@stencil/core": "^2.7.0", "@synchro-charts/core": "^1.1.1", "styled-components": "^5.3.0" diff --git a/packages/components/src/components/iot-bar-chart/iot-bar-chart.spec.ts b/packages/components/src/components/iot-bar-chart/iot-bar-chart.spec.ts index c0c383937..c5243f76d 100644 --- a/packages/components/src/components/iot-bar-chart/iot-bar-chart.spec.ts +++ b/packages/components/src/components/iot-bar-chart/iot-bar-chart.spec.ts @@ -2,7 +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, query } from '@iot-app-kit/core'; +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'; diff --git a/packages/components/src/components/iot-kpi/iot-kpi.spec.ts b/packages/components/src/components/iot-kpi/iot-kpi.spec.ts index d1fd37e7b..77b437c9b 100644 --- a/packages/components/src/components/iot-kpi/iot-kpi.spec.ts +++ b/packages/components/src/components/iot-kpi/iot-kpi.spec.ts @@ -1,5 +1,6 @@ import { newSpecPage } from '@stencil/core/testing'; -import { initialize, query } from '@iot-app-kit/core'; +import { initialize } from '@iot-app-kit/core'; +import { query } from '@iot-app-kit/source-iotsitewise'; import { MinimalLiveViewport } from '@synchro-charts/core'; import { IotKpi } from './iot-kpi'; import { Components } from '../../components.d'; diff --git a/packages/components/src/components/iot-line-chart/iot-line-chart.spec.ts b/packages/components/src/components/iot-line-chart/iot-line-chart.spec.ts index efd5bb76d..e01d3cc06 100644 --- a/packages/components/src/components/iot-line-chart/iot-line-chart.spec.ts +++ b/packages/components/src/components/iot-line-chart/iot-line-chart.spec.ts @@ -5,7 +5,8 @@ import { Components } from '../../components.d'; import { createMockSource } from '../../testing/createMockSource'; import { DATA_STREAM } from '../../testing/mockWidgetProperties'; import { CustomHTMLElement } from '../../testing/types'; -import { initialize, query } from '@iot-app-kit/core'; +import { initialize } from '@iot-app-kit/core'; +import { query } from '@iot-app-kit/source-iotsitewise'; import { IotTimeSeriesConnector } from '../iot-time-series-connector.ts/iot-time-series-connector'; import { update } from '../../testing/update'; import { mockSiteWiseSDK } from '../../testing/mocks/siteWiseSDK'; diff --git a/packages/components/src/components/iot-scatter-chart/iot-scatter-chart.spec.ts b/packages/components/src/components/iot-scatter-chart/iot-scatter-chart.spec.ts index 2fba398aa..07aa8f9f9 100644 --- a/packages/components/src/components/iot-scatter-chart/iot-scatter-chart.spec.ts +++ b/packages/components/src/components/iot-scatter-chart/iot-scatter-chart.spec.ts @@ -2,7 +2,8 @@ import { newSpecPage } from '@stencil/core/testing'; import { MinimalLiveViewport } from '@synchro-charts/core'; import { IotScatterChart } from './iot-scatter-chart'; import { Components } from '../../components.d'; -import { initialize, query } from '@iot-app-kit/core'; +import { initialize } from '@iot-app-kit/core'; +import { query } from '@iot-app-kit/source-iotsitewise'; import { createMockSource } from '../../testing/createMockSource'; import { IotTimeSeriesConnector } from '../iot-time-series-connector.ts/iot-time-series-connector'; import { CustomHTMLElement } from '../../testing/types'; diff --git a/packages/components/src/components/iot-status-grid/iot-status-grid.spec.ts b/packages/components/src/components/iot-status-grid/iot-status-grid.spec.ts index ecec71ec9..197222942 100644 --- a/packages/components/src/components/iot-status-grid/iot-status-grid.spec.ts +++ b/packages/components/src/components/iot-status-grid/iot-status-grid.spec.ts @@ -2,7 +2,8 @@ import { newSpecPage } from '@stencil/core/testing'; import { MinimalLiveViewport } from '@synchro-charts/core'; import { IotStatusGrid } from './iot-status-grid'; import { Components } from '../../components.d'; -import { initialize, query } from '@iot-app-kit/core'; +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'; diff --git a/packages/components/src/components/iot-status-timeline/iot-status-timeline.spec.ts b/packages/components/src/components/iot-status-timeline/iot-status-timeline.spec.ts index 42d3686b3..14b6e0f6a 100644 --- a/packages/components/src/components/iot-status-timeline/iot-status-timeline.spec.ts +++ b/packages/components/src/components/iot-status-timeline/iot-status-timeline.spec.ts @@ -2,7 +2,8 @@ import { newSpecPage } from '@stencil/core/testing'; import { MinimalLiveViewport } from '@synchro-charts/core'; import { IotStatusTimeline } from './iot-status-timeline'; import { Components } from '../../components.d'; -import { initialize, query } from '@iot-app-kit/core'; +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'; diff --git a/packages/components/src/components/iot-table/iot-table.spec.ts b/packages/components/src/components/iot-table/iot-table.spec.ts index a9452140f..9ea81fb66 100644 --- a/packages/components/src/components/iot-table/iot-table.spec.ts +++ b/packages/components/src/components/iot-table/iot-table.spec.ts @@ -2,7 +2,8 @@ import { newSpecPage } from '@stencil/core/testing'; import { MinimalLiveViewport } from '@synchro-charts/core'; import { IotTable } from './iot-table'; import { Components } from '../../components.d'; -import { initialize, query } from '@iot-app-kit/core'; +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'; diff --git a/packages/components/src/components/iot-time-series-connector.ts/iot-time-series-connector.spec.ts b/packages/components/src/components/iot-time-series-connector.ts/iot-time-series-connector.spec.ts index b2f44636b..4b0f65c1a 100644 --- a/packages/components/src/components/iot-time-series-connector.ts/iot-time-series-connector.spec.ts +++ b/packages/components/src/components/iot-time-series-connector.ts/iot-time-series-connector.spec.ts @@ -1,7 +1,8 @@ import { newSpecPage } from '@stencil/core/testing'; import { MinimalLiveViewport } from '@synchro-charts/core'; import flushPromises from 'flush-promises'; -import { initialize, IoTAppKitInitInputs, query, createMockSiteWiseSDK } from '@iot-app-kit/core'; +import { initialize, IoTAppKitInitInputs, createMockSiteWiseSDK } from '@iot-app-kit/core'; +import { query } from '@iot-app-kit/source-iotsitewise'; import { IotTimeSeriesConnector } from './iot-time-series-connector'; import { createMockSource } from '../../testing/createMockSource'; import { update } from '../../testing/update'; diff --git a/packages/components/src/testing/renderChart.tsx b/packages/components/src/testing/renderChart.tsx index 7b29ab520..7b10af11e 100644 --- a/packages/components/src/testing/renderChart.tsx +++ b/packages/components/src/testing/renderChart.tsx @@ -5,11 +5,11 @@ import { StyleSettingsMap, initialize, IoTAppKit, - query, TimeSeriesQuery, SiteWiseTimeSeriesDataProvider, TimeSeriesDataRequestSettings, } from '@iot-app-kit/core'; +import { query } from '@iot-app-kit/source-iotsitewise'; import { MinimalViewPortConfig } from '@synchro-charts/core'; import { MINUTE_IN_MS } from '@iot-app-kit/core/src/common/time'; const { defineCustomElements } = require('@iot-app-kit/components/loader'); diff --git a/packages/components/src/testing/testing-ground/testing-ground.tsx b/packages/components/src/testing/testing-ground/testing-ground.tsx index d98c298d1..bfcdba2fb 100755 --- a/packages/components/src/testing/testing-ground/testing-ground.tsx +++ b/packages/components/src/testing/testing-ground/testing-ground.tsx @@ -1,5 +1,6 @@ import { Component, State, h } from '@stencil/core'; -import { initialize, ResolutionConfig, IoTAppKit, query } from '@iot-app-kit/core'; +import { initialize, ResolutionConfig, IoTAppKit } from '@iot-app-kit/core'; +import { query } from '@iot-app-kit/source-iotsitewise'; import { ASSET_DETAILS_QUERY, DEMO_TURBINE_ASSET_1, diff --git a/packages/source-iotsitewise/README.md b/packages/source-iotsitewise/README.md index 9c163c1aa..24d784a75 100644 --- a/packages/source-iotsitewise/README.md +++ b/packages/source-iotsitewise/README.md @@ -5,7 +5,7 @@ ## Usage ``` -const sourceIotsitewise = require('@iot-app-kit/source-iotsitewise'); +import { query } from '@iot-app-kit/source-iotsitewise'; // TODO: DEMONSTRATE API ``` diff --git a/packages/source-iotsitewise/global.d.ts b/packages/source-iotsitewise/global.d.ts new file mode 100644 index 000000000..9e6c1dbd9 --- /dev/null +++ b/packages/source-iotsitewise/global.d.ts @@ -0,0 +1 @@ +import 'jest-extended'; diff --git a/packages/source-iotsitewise/jest.config.js b/packages/source-iotsitewise/jest.config.js new file mode 100644 index 000000000..f0623519b --- /dev/null +++ b/packages/source-iotsitewise/jest.config.js @@ -0,0 +1,20 @@ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node', + setupFilesAfterEnv: ['jest-extended/all'], + collectCoverageFrom: ['src/**/*.{ts,tsx}'], + coveragePathIgnorePatterns: ['/src/__mocks__'], + testPathIgnorePatterns: ['/dist'], + coverageReporters: ['text-summary', 'cobertura', 'html', 'json', 'json-summary'], + moduleNameMapper: { + '\\.(css|scss|svg)$': 'identity-obj-proxy', + }, + coverageThreshold: { + global: { + statements: 80, + branches: 80, + functions: 80, + lines: 80, + }, + }, +}; diff --git a/packages/source-iotsitewise/lib/source-iotsitewise.js b/packages/source-iotsitewise/lib/source-iotsitewise.js deleted file mode 100644 index 8af260e1e..000000000 --- a/packages/source-iotsitewise/lib/source-iotsitewise.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = sourceIotsitewise; - -function sourceIotsitewise() { - // TODO -} diff --git a/packages/source-iotsitewise/package.json b/packages/source-iotsitewise/package.json index 9d1b12ff8..78de4b8f2 100644 --- a/packages/source-iotsitewise/package.json +++ b/packages/source-iotsitewise/package.json @@ -4,13 +4,15 @@ "description": "AWS IoT SiteWise source for IoT Application Kit", "homepage": "https://github.com/awslabs/iot-app-kit#readme", "license": "Apache-2.0", - "main": "lib/source-iotsitewise.js", + "main": "./dist/index.cj.js", + "module": "./dist/index.js", + "types": "./dist/index.d.ts", "directories": { - "lib": "lib", + "dist": "dist", "test": "__tests__" }, "files": [ - "lib" + "dist/" ], "publishConfig": { "access": "public" @@ -20,7 +22,32 @@ "url": "git+https://github.com/awslabs/iot-app-kit.git" }, "scripts": { - "test": "echo \"Error: run tests from root\" && exit 0" + "clean": "rm -rf dist && rm -rf screenshot", + "build": "yarn run clean && rollup --config rollup.config.js", + "test": "echo \"Error: run tests from root\" && exit 0", + "test:jest": "TZ=UTC jest --coverage", + "test.watch": "TZ=UTC jest --watchAll", + "test:typescript": "tsc --noEmit", + "copy:license": "cp ../../LICENSE LICENSE", + "copy:notice": "cp ../../NOTICE NOTICE", + "release": "yarn run clean && npm-run-all -p build test", + "prepublishOnly": "yarn release", + "prepack": "yarn run copy:license && yarn run copy:notice", + "pack": "yarn pack" + }, + "dependencies": { + "@iot-app-kit/core": "0.0.1", + "@aws-sdk/client-iotsitewise": "^3.39.0", + "@rollup/plugin-typescript": "^8.3.0", + "@synchro-charts/core": "^1.1.1", + "flush-promises": "^1.0.2", + "typescript": "4.4.4" + }, + "devDependencies": { + "@types/jest": "^27.4.0", + "jest": "^27.5.1", + "jest-extended": "^2.0.0", + "ts-jest": "^27.1.3" }, "bugs": { "url": "https://github.com/awslabs/iot-app-kit/issues" diff --git a/packages/source-iotsitewise/rollup.config.js b/packages/source-iotsitewise/rollup.config.js new file mode 100644 index 000000000..81385b3a0 --- /dev/null +++ b/packages/source-iotsitewise/rollup.config.js @@ -0,0 +1,19 @@ +import typescript from '@rollup/plugin-typescript'; +import pkg from './package.json'; + +export default [ + { + input: 'src/index.ts', + output: [ + { + file: pkg.main, + format: 'cjs', + }, + { + file: pkg.module, + format: 'esm', + }, + ], + plugins: [typescript({ tsconfig: './tsconfig.json' })], + }, +]; diff --git a/packages/source-iotsitewise/src/index.ts b/packages/source-iotsitewise/src/index.ts new file mode 100644 index 000000000..dba7e720c --- /dev/null +++ b/packages/source-iotsitewise/src/index.ts @@ -0,0 +1,3 @@ +import { query, datamodule } from '@iot-app-kit/core'; + +export { query, datamodule }; diff --git a/packages/source-iotsitewise/tsconfig.json b/packages/source-iotsitewise/tsconfig.json new file mode 100755 index 000000000..b509e906f --- /dev/null +++ b/packages/source-iotsitewise/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "allowUnreachableCode": false, + "declaration": true, + "declarationDir": ".", + "outDir": "dist", + "experimentalDecorators": true, + "lib": ["dom", "es2019"], + "moduleResolution": "node", + "module": "esnext", + "target": "es2017", + "esModuleInterop": true, + "strict": true, + "strictPropertyInitialization": false, + "skipLibCheck": true, + "resolveJsonModule": true + }, + "include": ["src"], + "exclude": ["node_modules", "dist"], + "files": ["global.d.ts"] +}