diff --git a/.prettierrc.js b/.prettierrc.js index c14684b..a4df736 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,3 +1,5 @@ module.exports = { - ...require('@grafana/toolkit/src/config/prettier.plugin.config.json'), + trailingComma: 'es5', + singleQuote: true, + printWidth: 120, }; diff --git a/CHANGELOG.md b/CHANGELOG.md index a5137cb..b5df0d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. +## v0.3.3 + +- Fix: broken ESM imports due to `src` in ESM build output path +- Fix: circular dependencies in components +- Fix: ESM builds importing entire react, grafana/ui, grafana/data, and grafana/experimental +- Refactor: prefer named exports over asterisk in barrel files ## v0.3.2 diff --git a/rollup.config.ts b/rollup.config.ts index 134527b..e584cb9 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -13,7 +13,7 @@ export default [ plugins: [ externals({ deps: true, - include: ['react', '@grafana/data', '@grafana/ui', '@grafana/runtime', 'lodash'], + include: ['react', '@emotion/css', '@grafana/data', '@grafana/ui', '@grafana/runtime', 'lodash'], packagePath, }), resolve(), @@ -30,6 +30,7 @@ export default [ sourcemap: true, dir: path.dirname(pkg.module), preserveModules: true, + preserveModulesRoot: './src', }, ], }, diff --git a/src/components/ConnectionConfig.styles.ts b/src/components/ConnectionConfig.styles.ts new file mode 100644 index 0000000..c097665 --- /dev/null +++ b/src/components/ConnectionConfig.styles.ts @@ -0,0 +1,5 @@ +import { css } from '@emotion/css'; + +export const assumeRoleInstructionsStyle = css({ + maxWidth: '715px', +}); diff --git a/src/components/ConnectionConfig.tsx b/src/components/ConnectionConfig.tsx index 4987d8f..0dfae23 100644 --- a/src/components/ConnectionConfig.tsx +++ b/src/components/ConnectionConfig.tsx @@ -1,7 +1,6 @@ import React, { FC, useEffect, useMemo, useState } from 'react'; import { Input, Select, InlineField, ButtonGroup, ToolbarButton, FieldSet, Collapse } from '@grafana/ui'; import { - DataSourcePluginOptionsEditorProps, onUpdateDatasourceJsonDataOptionSelect, onUpdateDatasourceResetOption, onUpdateDatasourceJsonDataOption, @@ -9,10 +8,10 @@ import { } from '@grafana/data'; import { config } from '@grafana/runtime'; import { standardRegions } from '../regions'; -import { AwsAuthDataSourceJsonData, AwsAuthDataSourceSecureJsonData, AwsAuthType } from '../types'; +import { AwsAuthType, ConnectionConfigProps } from '../types'; import { awsAuthProviderOptions } from '../providers'; -import { css } from '@emotion/css'; import { NewConnectionConfig } from './NewConnectionConfig'; +import { assumeRoleInstructionsStyle } from './ConnectionConfig.styles'; export const DEFAULT_LABEL_WIDTH = 28; const DS_TYPES_THAT_SUPPORT_TEMP_CREDS = ['cloudwatch', 'grafana-athena-datasource']; @@ -20,21 +19,6 @@ const toOption = (value: string) => ({ value, label: value }); const isAwsAuthType = (value: any): value is AwsAuthType => { return typeof value === 'string' && awsAuthProviderOptions.some((opt) => opt.value === value); }; -export interface ConnectionConfigProps< - J extends AwsAuthDataSourceJsonData = AwsAuthDataSourceJsonData, - S = AwsAuthDataSourceSecureJsonData -> extends DataSourcePluginOptionsEditorProps { - standardRegions?: string[]; - loadRegions?: () => Promise; - defaultEndpoint?: string; - skipHeader?: boolean; - skipEndpoint?: boolean; - children?: React.ReactNode; - labelWidth?: number; - inExperimentalAuthComponent?: boolean; - externalId?: string; - newFormStylingEnabled?: boolean; -} export const ConnectionConfig: FC = (props: ConnectionConfigProps) => { const [isARNInstructionsOpen, setIsARNInstructionsOpen] = useState(false); @@ -184,9 +168,8 @@ export const ConnectionConfig: FC = (props: ConnectionCon
  1. - 1. Create a new IAM role in the AWS console, - and select AWS account as the Trusted entity, - and select Another AWS account as the account. + 1. Create a new IAM role in the AWS console, and select AWS account as the Trusted + entity, and select Another AWS account as the account.

  2. @@ -302,8 +285,3 @@ export const ConnectionConfig: FC = (props: ConnectionCon ); }; - -export const assumeRoleInstructionsStyle = css({ - maxWidth: '715px', -}) - diff --git a/src/components/NewConnectionConfig.tsx b/src/components/NewConnectionConfig.tsx index 612eb1e..92a1d9b 100644 --- a/src/components/NewConnectionConfig.tsx +++ b/src/components/NewConnectionConfig.tsx @@ -7,10 +7,10 @@ import { onUpdateDatasourceSecureJsonDataOption, SelectableValue, } from '@grafana/data'; -import { AwsAuthType } from '../types'; +import { AwsAuthType, ConnectionConfigProps } from '../types'; import { awsAuthProviderOptions } from '../providers'; import { ConfigSection, ConfigSubSection } from '@grafana/experimental'; -import { ConnectionConfigProps, assumeRoleInstructionsStyle } from './ConnectionConfig'; +import { assumeRoleInstructionsStyle } from './ConnectionConfig.styles'; interface NewConnectionConfigProps extends ConnectionConfigProps { currentProvider?: SelectableValue | undefined; diff --git a/src/components/SIGV4ConnectionConfig.tsx b/src/components/SIGV4ConnectionConfig.tsx index 1a4172b..7a7f027 100644 --- a/src/components/SIGV4ConnectionConfig.tsx +++ b/src/components/SIGV4ConnectionConfig.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { DataSourcePluginOptionsEditorProps, DataSourceSettings } from '@grafana/data'; -import { ConnectionConfig, ConnectionConfigProps } from '../components/ConnectionConfig'; +import { ConnectionConfig } from '../components/ConnectionConfig'; -import { AwsAuthDataSourceSecureJsonData, AwsAuthDataSourceJsonData } from '../types'; +import { AwsAuthDataSourceSecureJsonData, AwsAuthDataSourceJsonData, ConnectionConfigProps } from '../types'; export interface SIGV4ConnectionConfigProps extends DataSourcePluginOptionsEditorProps { inExperimentalAuthComponent?: boolean; diff --git a/src/components/index.ts b/src/components/index.ts index fac9aa2..05eac29 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -1,3 +1,2 @@ -export { ConnectionConfig, type ConnectionConfigProps, DEFAULT_LABEL_WIDTH } from './ConnectionConfig'; -export { NewConnectionConfig } from './NewConnectionConfig'; +export { ConnectionConfig, DEFAULT_LABEL_WIDTH } from './ConnectionConfig'; export { Divider } from './Divider'; diff --git a/src/index.ts b/src/index.ts index 0c1cfb8..e2523b6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,16 @@ -export { ConnectionConfig, type ConnectionConfigProps, DEFAULT_LABEL_WIDTH, Divider } from './components'; +export { ConnectionConfig, DEFAULT_LABEL_WIDTH, Divider } from './components'; export { SIGV4ConnectionConfig } from './components/SIGV4ConnectionConfig'; export { ConfigSelect, InlineInput } from './sql/ConfigEditor'; export { ResourceSelector, type ResourceSelectorProps } from './sql/ResourceSelector'; export { type SQLQuery } from './sql/types'; export { QueryEditorHeader, QueryCodeEditor, FormatSelect, FillValueSelect, FillValueOptions } from './sql/QueryEditor'; -export * from './sql/utils'; -export * from './types'; -export * from './regions'; -export * from './providers'; +export { filterSQLQuery, applySQLTemplateVariables, appendTemplateVariablesAsSuggestions } from './sql/utils'; +export { + AwsAuthType, + type AwsAuthDataSourceJsonData, + type AwsAuthDataSourceSecureJsonData, + type AwsAuthDataSourceSettings, + type ConnectionConfigProps, +} from './types'; +export { standardRegions } from './regions'; +export { awsAuthProviderOptions } from './providers'; diff --git a/src/types.ts b/src/types.ts index 5c6d2f0..c07c8d4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,4 @@ -import { DataSourceJsonData, DataSourceSettings } from '@grafana/data'; +import type { DataSourceJsonData, DataSourcePluginOptionsEditorProps, DataSourceSettings } from '@grafana/data'; export enum AwsAuthType { Keys = 'keys', @@ -28,3 +28,19 @@ export interface AwsAuthDataSourceSecureJsonData { } export type AwsAuthDataSourceSettings = DataSourceSettings; + +export interface ConnectionConfigProps< + J extends AwsAuthDataSourceJsonData = AwsAuthDataSourceJsonData, + S = AwsAuthDataSourceSecureJsonData +> extends DataSourcePluginOptionsEditorProps { + standardRegions?: string[]; + loadRegions?: () => Promise; + defaultEndpoint?: string; + skipHeader?: boolean; + skipEndpoint?: boolean; + children?: React.ReactNode; + labelWidth?: number; + inExperimentalAuthComponent?: boolean; + externalId?: string; + newFormStylingEnabled?: boolean; +}