Skip to content

Commit

Permalink
export types with namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Mar 21, 2019
1 parent 58b7994 commit 2fbfd00
Show file tree
Hide file tree
Showing 22 changed files with 66 additions and 92 deletions.
2 changes: 1 addition & 1 deletion src/core/public/base_path/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export { BasePathService, BasePathStart } from './base_path_service';
export * from './base_path_service';
2 changes: 1 addition & 1 deletion src/core/public/chrome/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export { Breadcrumb, ChromeService, ChromeStart, Brand, HelpExtension } from './chrome_service';
export * from './chrome_service';
2 changes: 1 addition & 1 deletion src/core/public/fatal_errors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export { FatalErrorsStart, FatalErrorsService } from './fatal_errors_service';
export * from './fatal_errors_service';
2 changes: 1 addition & 1 deletion src/core/public/http/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export { HttpService, HttpStart } from './http_service';
export * from './http_service';
2 changes: 1 addition & 1 deletion src/core/public/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export { I18nService, I18nStart } from './i18n_service';
export * from './i18n_service';
44 changes: 17 additions & 27 deletions src/core/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,26 @@
* under the License.
*/

import { BasePathStart } from './base_path';
import { Brand, Breadcrumb, ChromeStart, HelpExtension } from './chrome';
import { FatalErrorsStart } from './fatal_errors';
import { HttpStart } from './http';
import { I18nStart } from './i18n';
import { InjectedMetadataStart } from './injected_metadata';
import { NotificationsStart, Toast, ToastInput, ToastsStart } from './notifications';
import { UiSettingsClient } from './ui_settings';
import * as BasePath from './base_path';
import * as Chrome from './chrome';
import * as FatalErrors from './fatal_errors';
import * as Http from './http';
import * as I18n from './i18n';
import * as InjectedMetadata from './injected_metadata';
import * as Notifications from './notifications';
import * as UiSettings from './ui_settings';

export { CoreSystem } from './core_system';

export interface CoreStart {
i18n: I18nStart;
injectedMetadata: InjectedMetadataStart;
fatalErrors: FatalErrorsStart;
notifications: NotificationsStart;
http: HttpStart;
basePath: BasePathStart;
uiSettings: UiSettingsClient;
chrome: ChromeStart;
i18n: I18n.I18nStart;
injectedMetadata: InjectedMetadata.InjectedMetadataStart;
fatalErrors: FatalErrors.FatalErrorsStart;
notifications: Notifications.NotificationsStart;
http: Http.HttpStart;
basePath: BasePath.BasePathStart;
uiSettings: UiSettings.UiSettingsStart;
chrome: Chrome.ChromeStart;
}

export interface Chrome {
Brand: Brand;
Breadcrumb: Breadcrumb;
HelpExtension: HelpExtension;
}

export interface Notifications {
Toast: Toast;
ToastInput: ToastInput;
ToastsStart: ToastsStart;
}
export { BasePath, Chrome, FatalErrors, Http, I18n, InjectedMetadata, Notifications, UiSettings };
6 changes: 1 addition & 5 deletions src/core/public/injected_metadata/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,4 @@
* under the License.
*/

export {
InjectedMetadataService,
InjectedMetadataParams,
InjectedMetadataStart,
} from './injected_metadata_service';
export * from './injected_metadata_service';
4 changes: 2 additions & 2 deletions src/core/public/notifications/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
* under the License.
*/

export { Toast, ToastInput, ToastsStart } from './toasts';
export { NotificationsService, NotificationsStart } from './notifications_service';
export * from './toasts';
export * from './notifications_service';
6 changes: 3 additions & 3 deletions src/core/public/ui_settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
* under the License.
*/

export { UiSettingsService, UiSettingsStart } from './ui_settings_service';
export { UiSettingsClient } from './ui_settings_client';
export { UiSettingsState } from './types';
export * from './ui_settings_service';
export * from './ui_settings_client';
export * from './types';
6 changes: 3 additions & 3 deletions src/legacy/ui/public/chrome/api/base_path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* under the License.
*/

import { CoreStart } from '../../../../../core/public/';
let newPlatformBasePath: CoreStart['basePath'];
import { BasePath } from '../../../../../core/public/';
let newPlatformBasePath: BasePath.BasePathStart;

export function __newPlatformInit__(instance: CoreStart['basePath']) {
export function __newPlatformInit__(instance: BasePath.BasePathStart) {
if (newPlatformBasePath) {
throw new Error('ui/chrome/api/base_path is already initialized');
}
Expand Down
10 changes: 5 additions & 5 deletions src/legacy/ui/public/chrome/api/breadcrumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@

import { IRootScopeService } from 'angular';
import { fatalError } from 'ui/notify/fatal_error';
import { Chrome, CoreStart } from '../../../../../core/public';
import { Chrome } from '../../../../../core/public';

type Breadcrumb = Chrome['Breadcrumb'];
type Breadcrumb = Chrome.Breadcrumb;
export { Breadcrumb };

export type BreadcrumbsApi = ReturnType<typeof createBreadcrumbsApi>['breadcrumbs'];
type ChromeStart = CoreStart['chrome'];
let newPlatformChrome: ChromeStart;
export function __newPlatformInit__(instance: ChromeStart) {

let newPlatformChrome: Chrome.ChromeStart;
export function __newPlatformInit__(instance: Chrome.ChromeStart) {
if (newPlatformChrome) {
throw new Error('ui/chrome/api/breadcrumbs is already initialized');
}
Expand Down
7 changes: 3 additions & 4 deletions src/legacy/ui/public/chrome/api/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
*/

import * as Rx from 'rxjs';
import { CoreStart } from '../../../../../core/public/';
import { Chrome } from '../../../../../core/public/';

type ChromeStart = CoreStart['chrome'];
let newPlatformChrome: ChromeStart;
let newPlatformChrome: Chrome.ChromeStart;

export function __newPlatformInit__(instance: ChromeStart) {
export function __newPlatformInit__(instance: Chrome.ChromeStart) {
if (newPlatformChrome) {
throw new Error('ui/chrome/api/controls is already initialized');
}
Expand Down
11 changes: 5 additions & 6 deletions src/legacy/ui/public/chrome/api/help_extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@

import { IRootScopeService } from 'angular';

import { Chrome, CoreStart } from '../../../../../core/public/';
import { Chrome } from '../../../../../core/public/';

type HelpExtension = Chrome['HelpExtension'];
type ChromeStart = CoreStart['chrome'];

let newPlatformChrome: ChromeStart;
export function __newPlatformInit__(instance: ChromeStart) {
let newPlatformChrome: Chrome.ChromeStart;
export function __newPlatformInit__(instance: Chrome.ChromeStart) {
if (newPlatformChrome) {
throw new Error('ui/chrome/api/help_extension is already initialized');
}
Expand All @@ -34,6 +31,8 @@ export function __newPlatformInit__(instance: ChromeStart) {
}

export type HelpExtensionApi = ReturnType<typeof createHelpExtensionApi>['helpExtension'];

type HelpExtension = Chrome.HelpExtension;
export { HelpExtension };

function createHelpExtensionApi() {
Expand Down
7 changes: 3 additions & 4 deletions src/legacy/ui/public/chrome/api/injected_vars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
*/

import { cloneDeep } from 'lodash';
import { CoreStart } from '../../../../../core/public/';
import { InjectedMetadata } from '../../../../../core/public/';

type InjectedMetadataStart = CoreStart['injectedMetadata'];
let newPlatformInjectedVars: InjectedMetadataStart;
let newPlatformInjectedVars: InjectedMetadata.InjectedMetadataStart;

export function __newPlatformInit__(instance: InjectedMetadataStart) {
export function __newPlatformInit__(instance: InjectedMetadata.InjectedMetadataStart) {
if (newPlatformInjectedVars) {
throw new Error('ui/chrome/api/injected_vars is already initialized');
}
Expand Down
14 changes: 6 additions & 8 deletions src/legacy/ui/public/chrome/api/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@

import * as Rx from 'rxjs';

import { Chrome, CoreStart } from '../../../../../core/public/';
import { Chrome } from '../../../../../core/public/';

type Brand = Chrome['Brand'];
type ChromeStart = CoreStart['chrome'];
let newPlatformChrome: ChromeStart;
let newPlatformChrome: Chrome.ChromeStart;

export function __newPlatformInit__(instance: ChromeStart) {
export function __newPlatformInit__(instance: Chrome.ChromeStart) {
if (newPlatformChrome) {
throw new Error('ui/chrome/api/theme is already initialized');
}
Expand All @@ -34,18 +32,18 @@ export function __newPlatformInit__(instance: ChromeStart) {
}

export function initChromeThemeApi(chrome: { [key: string]: any }) {
const brandCache$ = new Rx.BehaviorSubject<Brand>({});
const brandCache$ = new Rx.BehaviorSubject<Chrome.Brand>({});
newPlatformChrome.getBrand$().subscribe(brandCache$);

const applicationClassesCache$ = new Rx.BehaviorSubject<string[]>([]);
newPlatformChrome.getApplicationClasses$().subscribe(applicationClassesCache$);

chrome.setBrand = (brand: Brand) => {
chrome.setBrand = (brand: Chrome.Brand) => {
newPlatformChrome.setBrand(brand);
return chrome;
};

chrome.getBrand = (key: keyof Brand) => {
chrome.getBrand = (key: keyof Chrome.Brand) => {
return brandCache$.getValue()[key];
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ import { relativeToAbsolute } from 'ui/url/relative_to_absolute';
import { NavControlSide } from '../';
import { Chrome } from '../../../../../../../core/public/';

type Breadcrumb = Chrome['Breadcrumb'];
interface Props {
appTitle?: string;
breadcrumbs$: Rx.Observable<Breadcrumb[]>;
breadcrumbs$: Rx.Observable<Chrome.Breadcrumb[]>;
homeHref: string;
isVisible: boolean;
navLinks$: Rx.Observable<NavLink[]>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ import React from 'react';
import * as Rx from 'rxjs';
import { Chrome } from '../../../../../../../core/public/';
import { HeaderBreadcrumbs } from './header_breadcrumbs';
type Breadcrumb = Chrome['Breadcrumb'];

describe('HeaderBreadcrumbs', () => {
it('renders updates to the breadcrumbs$ observable', () => {
const breadcrumbs$ = new Rx.Subject<Breadcrumb[]>();
const breadcrumbs$ = new Rx.Subject<Chrome.Breadcrumb[]>();
const wrapper = mount(<HeaderBreadcrumbs breadcrumbs$={breadcrumbs$} />);

breadcrumbs$.next([{ text: 'First' }]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ import {
} from '@elastic/eui';

import { Chrome } from '../../../../../../../core/public/';
type Breadcrumb = Chrome['Breadcrumb'];

interface Props {
appTitle?: string;
breadcrumbs$: Rx.Observable<Breadcrumb[]>;
breadcrumbs$: Rx.Observable<Chrome.Breadcrumb[]>;
}

interface State {
breadcrumbs: Breadcrumb[];
breadcrumbs: Chrome.Breadcrumb[];
}

export class HeaderBreadcrumbs extends Component<Props, State> {
Expand Down
5 changes: 2 additions & 3 deletions src/legacy/ui/public/i18n/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ import React from 'react';
import { i18nDirective, i18nFilter, I18nProvider } from '@kbn/i18n/angular';
// @ts-ignore
import { uiModules } from 'ui/modules';
import { CoreStart } from '../../../../core/public';
import { I18n } from '../../../../core/public';

type I18nStart = CoreStart['i18n'];
export let I18nContext: I18nStart['Context'] = null!;
export let I18nContext: I18n.I18nStart['Context'] = null!;
export function __newPlatformInit__(context: typeof I18nContext) {
if (I18nContext) {
throw new Error('ui/i18n already initialized with new platform apis');
Expand Down
7 changes: 3 additions & 4 deletions src/legacy/ui/public/notify/fatal_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@
* under the License.
*/

import { CoreStart } from '../../../../core/public';
import { FatalErrors } from '../../../../core/public';
import {
AngularHttpError,
formatAngularHttpError,
isAngularHttpError,
} from './lib/format_angular_http_error';

type FatalErrorsStart = CoreStart['fatalErrors'];
let newPlatformFatalErrors: FatalErrorsStart;
let newPlatformFatalErrors: FatalErrors.FatalErrorsStart;

export function __newPlatformInit__(instance: FatalErrorsStart) {
export function __newPlatformInit__(instance: FatalErrors.FatalErrorsStart) {
if (newPlatformFatalErrors) {
throw new Error('ui/notify/fatal_error already initialized with new platform apis');
}
Expand Down
7 changes: 3 additions & 4 deletions src/legacy/ui/public/notify/toasts/toast_notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
*/
import { Notifications } from '../../../../../core/public/';

type Toast = Notifications['Toast'];
type ToastInput = Notifications['ToastInput'];
type ToastsStart = Notifications['ToastsStart'];
type Toast = Notifications.Toast;
type ToastInput = Notifications.ToastInput;

export { Toast, ToastInput };

Expand All @@ -29,7 +28,7 @@ export class ToastNotifications {

private onChangeCallback?: () => void;

constructor(private readonly toasts: ToastsStart) {
constructor(private readonly toasts: Notifications.ToastsStart) {
toasts.get$().subscribe(list => {
this.list = list;

Expand Down
3 changes: 1 addition & 2 deletions src/legacy/ui/public/notify/toasts/toasts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
import { Notifications } from '../../../../../core/public/';
import { ToastNotifications } from './toast_notifications';

type ToastsStart = Notifications['ToastsStart'];
export let toastNotifications: ToastNotifications;

export function __newPlatformInit__(toasts: ToastsStart) {
export function __newPlatformInit__(toasts: Notifications.ToastsStart) {
if (toastNotifications) {
throw new Error('ui/notify/toasts already initialized with new platform apis');
}
Expand Down

0 comments on commit 2fbfd00

Please sign in to comment.