Skip to content

Commit

Permalink
chore: 80 character lines
Browse files Browse the repository at this point in the history
  • Loading branch information
tracy-french committed Jan 8, 2024
1 parent 4c6215f commit 7dcfaeb
Show file tree
Hide file tree
Showing 815 changed files with 16,806 additions and 5,357 deletions.
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"jsxSingleQuote": true,
"singleQuote": true,
"bracketSpacing": true,
"printWidth": 120,
"printWidth": 80,
"trailingComma": "es5"
}
24 changes: 18 additions & 6 deletions packages/components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export namespace Components {
"filterEnabled": boolean;
"filterTexts"?: FilterTexts;
"loadingText"?: string;
"onSelectionChange": (event: NonCancelableCustomEvent<TableProps.SelectionChangeDetail<unknown>>) => void;
"onSelectionChange": (
event: NonCancelableCustomEvent<TableProps.SelectionChangeDetail<unknown>>
) => void;
"paginationEnabled": boolean;
"query": TreeQuery<SiteWiseAssetTreeNode[], BranchReference>;
"selectionType"?: TableProps.SelectionType;
Expand All @@ -43,8 +45,12 @@ export namespace Components {
"loading": boolean;
"loadingText": string;
"onExpandChildren": (node: ITreeNode<any>) => void;
"onSelectionChange": (event: NonCancelableCustomEvent<TableProps.SelectionChangeDetail<unknown>>) => void;
"onSortingChange": (event: NonCancelableCustomEvent<TableProps.SortingState<unknown>>) => void;
"onSelectionChange": (
event: NonCancelableCustomEvent<TableProps.SelectionChangeDetail<unknown>>
) => void;
"onSortingChange": (
event: NonCancelableCustomEvent<TableProps.SortingState<unknown>>
) => void;
"resizableColumns": boolean;
"selectionType": TableProps.SelectionType;
"sortingDisabled": boolean;
Expand Down Expand Up @@ -100,7 +106,9 @@ declare namespace LocalJSX {
"filterEnabled"?: boolean;
"filterTexts"?: FilterTexts;
"loadingText"?: string;
"onSelectionChange"?: (event: NonCancelableCustomEvent<TableProps.SelectionChangeDetail<unknown>>) => void;
"onSelectionChange"?: (
event: NonCancelableCustomEvent<TableProps.SelectionChangeDetail<unknown>>
) => void;
"paginationEnabled"?: boolean;
"query"?: TreeQuery<SiteWiseAssetTreeNode[], BranchReference>;
"selectionType"?: TableProps.SelectionType;
Expand All @@ -124,8 +132,12 @@ declare namespace LocalJSX {
"loading"?: boolean;
"loadingText"?: string;
"onExpandChildren"?: (node: ITreeNode<any>) => void;
"onSelectionChange"?: (event: NonCancelableCustomEvent<TableProps.SelectionChangeDetail<unknown>>) => void;
"onSortingChange"?: (event: NonCancelableCustomEvent<TableProps.SortingState<unknown>>) => void;
"onSelectionChange"?: (
event: NonCancelableCustomEvent<TableProps.SelectionChangeDetail<unknown>>
) => void;
"onSortingChange"?: (
event: NonCancelableCustomEvent<TableProps.SortingState<unknown>>
) => void;
"resizableColumns"?: boolean;
"selectionType"?: TableProps.SelectionType;
"sortingDisabled"?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { update } from '../../testing/update';
import flushPromises from 'flush-promises';
import { mocklistAssetsResponse } from '../../testing/mocks/data/listAssetsResponse';
import { IoTSiteWiseClient } from '@aws-sdk/client-iotsitewise';
import { createMockIoTEventsSDK, createMockSiteWiseSDK } from '@iot-app-kit/testing-util';
import {
createMockIoTEventsSDK,
createMockSiteWiseSDK,
} from '@iot-app-kit/testing-util';

jest.useFakeTimers();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { Component, h, Prop, State, Watch } from '@stencil/core';
import { ErrorDetails, TreeProvider, TreeQuery } from '@iot-app-kit/core';
import { BranchReference, SiteWiseAssetTreeNode } from '@iot-app-kit/source-iotsitewise';
import {
BranchReference,
SiteWiseAssetTreeNode,
} from '@iot-app-kit/source-iotsitewise';
import { SiteWiseAssetResource, FilterTexts, ColumnDefinition } from './types';
import { EmptyStateProps, ITreeNode, UseTreeCollection } from '@iot-app-kit/related-table';
import {
EmptyStateProps,
ITreeNode,
UseTreeCollection,
} from '@iot-app-kit/related-table';
import { parseSitewiseAssetTree } from './utils';
import { TableProps } from '@awsui/components-react/table';
import { NonCancelableCustomEvent } from '@awsui/components-react';
Expand All @@ -25,13 +32,15 @@ const DEFAULT_COLUMNS: ColumnDefinition<SiteWiseAssetResource>[] = [
sortingField: 'creationDate',
id: 'creationDate',
header: 'Created',
cell: ({ creationDate }: SiteWiseAssetResource) => creationDate?.toUTCString(),
cell: ({ creationDate }: SiteWiseAssetResource) =>
creationDate?.toUTCString(),
},
{
sortingField: 'lastUpdateDate',
id: 'lastUpdateDate',
header: 'Updated',
cell: ({ lastUpdateDate }: SiteWiseAssetResource) => lastUpdateDate?.toUTCString(),
cell: ({ lastUpdateDate }: SiteWiseAssetResource) =>
lastUpdateDate?.toUTCString(),
},
];
@Component({
Expand All @@ -50,7 +59,9 @@ export class IotResourceExplorer {
@Prop() paginationEnabled = true;
@Prop() wrapLines = false;
@Prop() widgetId: string = uuidv4();
@Prop() onSelectionChange: (event: NonCancelableCustomEvent<TableProps.SelectionChangeDetail<unknown>>) => void;
@Prop() onSelectionChange: (
event: NonCancelableCustomEvent<TableProps.SelectionChangeDetail<unknown>>
) => void;
@Prop() expanded?: boolean = false;

@State() provider: TreeProvider<SiteWiseAssetTreeNode[], BranchReference>;
Expand Down Expand Up @@ -95,7 +106,9 @@ export class IotResourceExplorer {

expandNode = (node: ITreeNode<SiteWiseAssetResource>) => {
node.hierarchies?.forEach((hierarchy: any) => {
this.provider.expand(new BranchReference(node.id, hierarchy.id as string));
this.provider.expand(
new BranchReference(node.id, hierarchy.id as string)
);
});
};

Expand All @@ -107,7 +120,9 @@ export class IotResourceExplorer {
newItems.forEach(({ id, hierarchies, hasChildren }) => {
if (!this.expandedItems[id] && hasChildren) {
hierarchies?.forEach((hierarchy: any) => {
this.provider.expand(new BranchReference(id, hierarchy.id as string));
this.provider.expand(
new BranchReference(id, hierarchy.id as string)
);
});

newExpandedItems[id] = true;
Expand All @@ -119,7 +134,9 @@ export class IotResourceExplorer {
}

render() {
const filtering = this.filterEnabled ? this.filterTexts || this.defaults.filterText : undefined;
const filtering = this.filterEnabled
? this.filterTexts || this.defaults.filterText
: undefined;
const collectionOptions: UseTreeCollection<unknown> = {
columnDefinitions: this.columnDefinitions,
keyPropertyName: 'id',
Expand Down Expand Up @@ -149,7 +166,10 @@ export class IotResourceExplorer {

if (this.errors.length > 0) {
// TODO: Make use of all the errors
empty = { header: 'Error', description: this.errors[this.errors.length - 1]?.msg };
empty = {
header: 'Error',
description: this.errors[this.errors.length - 1]?.msg,
};
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ const treeTableSpecPage = async () => {
html: '<div></div>',
supportsShadowDom: false,
});
const treeTable = page.doc.createElement('iot-tree-table') as CustomHTMLElement<Components.IotTreeTable>;
const treeTable = page.doc.createElement(
'iot-tree-table'
) as CustomHTMLElement<Components.IotTreeTable>;
const props: Partial<Components.IotTreeTable> = {
items,
collectionOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ export class IotTreeTable {
@Prop() sortingDisabled: boolean;
@Prop() ariaLabels: TableProps.AriaLabels<unknown>;

@Prop() onSelectionChange: (event: NonCancelableCustomEvent<TableProps.SelectionChangeDetail<unknown>>) => void;
@Prop() onSelectionChange: (
event: NonCancelableCustomEvent<TableProps.SelectionChangeDetail<unknown>>
) => void;
@Prop() onExpandChildren: (node: ITreeNode<any>) => void;
@Prop() onSortingChange: (event: NonCancelableCustomEvent<TableProps.SortingState<unknown>>) => void;
@Prop() onSortingChange: (
event: NonCancelableCustomEvent<TableProps.SortingState<unknown>>
) => void;
private root: Root;

componentDidLoad() {
Expand Down Expand Up @@ -72,15 +76,21 @@ export class IotTreeTable {

expandChildren: this.onExpandChildren,
onSortingChange: this.onSortingChange,
onSelectionChange: (event: NonCancelableCustomEvent<TableProps.SelectionChangeDetail<unknown>>) => {
onSelectionChange: (
event: NonCancelableCustomEvent<
TableProps.SelectionChangeDetail<unknown>
>
) => {
this.selectedItems = event.detail.selectedItems;
if (this.onSelectionChange) {
this.onSelectionChange(event);
}
},
} as unknown as RelatedTableExtendedProps<unknown>;

this.root.render(createElement(RelatedTableWithCollectionHooks, attributes));
this.root.render(
createElement(RelatedTableWithCollectionHooks, attributes)
);
}

render() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { SiteWiseAssetTreeNode, HierarchyGroup } from '@iot-app-kit/source-iotsitewise';
import {
SiteWiseAssetTreeNode,
HierarchyGroup,
} from '@iot-app-kit/source-iotsitewise';
import { SiteWiseAssetResource } from './types';

const recursiveParseSitewiseAssetTree = (
Expand All @@ -13,7 +16,11 @@ const recursiveParseSitewiseAssetTree = (
parentId,
});
node.hierarchies.forEach((hierarchy: HierarchyGroup) => {
recursiveParseSitewiseAssetTree(flattenTree, hierarchy.children, node.asset.id);
recursiveParseSitewiseAssetTree(
flattenTree,
hierarchy.children,
node.asset.id
);
});
});
};
Expand Down
7 changes: 6 additions & 1 deletion packages/components/src/testing/app/iot-test-routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ export class IotTestRoutes {
<stencil-router>
<stencil-route-switch scrollTopOffset={0}>
{routes.map((r) => (
<stencil-route key={r.url} url={r.url} component={r.component} exact />
<stencil-route
key={r.url}
url={r.url}
component={r.component}
exact
/>
))}
</stencil-route-switch>
</stencil-router>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export class IotResourceExplorerDemo {
private query: SiteWiseQuery;

componentWillLoad() {
const { query } = initialize({ awsCredentials: getEnvCredentials(), awsRegion: 'us-east-1' });
const { query } = initialize({
awsCredentials: getEnvCredentials(),
awsRegion: 'us-east-1',
});
this.query = query;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ export class IotTreeTableDemo {
filterPlaceholder={this.filterPlaceholder}
onExpandChildren={(node) => {
if (!loaded.has(node.id)) {
const newItems = allItems.filter((item) => item.parentId === node.id);
const newItems = allItems.filter(
(item) => item.parentId === node.id
);
this.items = [...this.items, ...newItems];
}
loaded.set(node.id, true);
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/testing/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
* For certain situations where we wish to ensure that T maintains it's type rather
* than mutating types. This is the reason for this helper function.
*/
export const update = <T>(target: T, source: Partial<T>): T => Object.assign(target, source);
export const update = <T>(target: T, source: Partial<T>): T =>
Object.assign(target, source);
2 changes: 1 addition & 1 deletion packages/core-util/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const config = {
statements: 54,
branches: 50,
functions: 51,
lines: 51,
lines: 50,
},
},
};
Expand Down
15 changes: 11 additions & 4 deletions packages/core-util/src/sdks/endpointProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export const DEFAULT_PARTITION = 'com';
const constructEndpoint =
(subDomain: string) =>
([awsRegion, awsPartition]: [string, string]): EndpointV2 => ({
url: new URL(`https://${subDomain}.${awsRegion}.amazonaws.${awsPartition}/`),
url: new URL(
`https://${subDomain}.${awsRegion}.amazonaws.${awsPartition}/`
),
});

export const getEndpointPovider = ({
Expand All @@ -23,12 +25,17 @@ export const getEndpointPovider = ({
let partition = Promise.resolve(DEFAULT_PARTITION);

if (awsRegion) {
region = typeof awsRegion === 'string' ? Promise.resolve(awsRegion) : awsRegion();
region =
typeof awsRegion === 'string' ? Promise.resolve(awsRegion) : awsRegion();
}

if (awsPartition) {
partition = typeof awsPartition === 'string' ? Promise.resolve(awsPartition) : awsPartition();
partition =
typeof awsPartition === 'string'
? Promise.resolve(awsPartition)
: awsPartition();
}

return () => Promise.all([region, partition]).then(constructEndpoint(subDomain));
return () =>
Promise.all([region, partition]).then(constructEndpoint(subDomain));
};
4 changes: 3 additions & 1 deletion packages/core-util/src/sdks/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export const eventsSdk = ({
credentials,
});

export const getIotEventsClient = (input: SiteWiseDataSourceInitalization): IoTEventsClient => {
export const getIotEventsClient = (
input: SiteWiseDataSourceInitalization
): IoTEventsClient => {
const { iotEventsClient, awsCredentials, awsRegion } = input;

if (iotEventsClient) {
Expand Down
11 changes: 9 additions & 2 deletions packages/core-util/src/sdks/number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import type { Primitive } from '@iot-app-kit/core';
* round(.02345678) => 0.02346
*/
export const round = (num: number, precision = 4): number => {
if (Number.isNaN(num) || num === Infinity || num === -Infinity || precision <= 0) {
if (
Number.isNaN(num) ||
num === Infinity ||
num === -Infinity ||
precision <= 0
) {
return num;
}

Expand All @@ -18,7 +23,9 @@ export const round = (num: number, precision = 4): number => {

const integer = Math.trunc(num);
const decimal = num - integer;
return Number((integer + Number(decimal.toFixed(precision))).toFixed(precision));
return Number(
(integer + Number(decimal.toFixed(precision))).toFixed(precision)
);
};

/**
Expand Down
4 changes: 3 additions & 1 deletion packages/core-util/src/sdks/sitewise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export const sitewiseSdk = ({
credentials,
});

export const getSiteWiseClient = (input: SiteWiseDataSourceInitalization): IoTSiteWiseClient => {
export const getSiteWiseClient = (
input: SiteWiseDataSourceInitalization
): IoTSiteWiseClient => {
const { iotSiteWiseClient, awsCredentials, awsRegion } = input;

if (iotSiteWiseClient) {
Expand Down
Loading

0 comments on commit 7dcfaeb

Please sign in to comment.