Merge pull request #1016 from spotify/rugvip/apistructure

packages/core: group api implementations by the name of the declarations
This commit is contained in:
Patrik Oldsberg
2020-05-26 16:59:27 +02:00
committed by GitHub
18 changed files with 57 additions and 17 deletions
@@ -13,10 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AlertApi, AlertMessage } from '../../../';
import { PublishSubject } from './lib';
import { Observable } from '../../types';
import { AlertApi, AlertMessage } from '../../../..';
import { PublishSubject } from '../lib';
import { Observable } from '../../../types';
/**
* Base implementation for the AlertApi that simply forwards alerts to consumers.
*/
export class AlertApiForwarder implements AlertApi {
private readonly subject = new PublishSubject<AlertMessage>();
@@ -0,0 +1,17 @@
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { AlertApiForwarder } from './AlertApiForwarder';
@@ -33,7 +33,7 @@ export class AppThemeSelector implements AppThemeApi {
selector.setActiveThemeId(initialThemeId);
selector.activeThemeId$().subscribe((themeId) => {
selector.activeThemeId$().subscribe(themeId => {
if (themeId) {
window.localStorage.setItem(STORAGE_KEY, themeId);
} else {
@@ -41,7 +41,7 @@ export class AppThemeSelector implements AppThemeApi {
}
});
window.addEventListener('storage', (event) => {
window.addEventListener('storage', event => {
if (event.key === STORAGE_KEY) {
const themeId = localStorage.getItem(STORAGE_KEY) ?? undefined;
selector.setActiveThemeId(themeId);
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ErrorApi, ErrorContext, AlertApi } from '../../../';
import { ErrorApi, ErrorContext, AlertApi } from '../../../..';
/**
* Decorates an ErrorApi by also forwarding error messages
@@ -13,10 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ErrorApi, ErrorContext } from '../../../';
import { PublishSubject } from './lib';
import { Observable } from '../../types';
import { ErrorApi, ErrorContext } from '../../../..';
import { PublishSubject } from '../lib';
import { Observable } from '../../../types';
/**
* Base implementation for the ErrorApi that simply forwards errors to consumers.
*/
export class ErrorApiForwarder implements ErrorApi {
private readonly subject = new PublishSubject<{
error: Error;
@@ -0,0 +1,18 @@
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { ErrorAlerter } from './ErrorAlerter';
export { ErrorApiForwarder } from './ErrorApiForwarder';
@@ -19,8 +19,8 @@
// Plugins should rely on these APIs for functionality as much as possible.
export * from './auth';
export * from './AppThemeSelector';
export * from './AlertApiForwarder';
export * from './ErrorAlerter';
export * from './ErrorApiForwarder';
export * from './OAuthRequestManager';
export * from './AlertApi';
export * from './AppThemeApi';
export * from './ErrorApi';
export * from './OAuthRequestApi';
@@ -16,7 +16,7 @@
import ProviderIcon from '@material-ui/icons/AcUnit';
import { DefaultAuthConnector } from './DefaultAuthConnector';
import MockOAuthApi from '../../OAuthRequestManager/MockOAuthApi';
import MockOAuthApi from '../../OAuthRequestApi/MockOAuthApi';
import * as loginPopup from '../loginPopup';
const anyFetch = fetch as any;
@@ -20,8 +20,7 @@ import {
SessionShouldRefreshFunc,
} from './types';
import { AuthConnector } from '../AuthConnector';
import { SessionScopeHelper } from './common';
import { hasScopes } from '../../OAuthRequestManager/OAuthPendingRequests';
import { SessionScopeHelper, hasScopes } from './common';
type Options<T> = {
/** The connector used for acting on the auth session */