Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pubsub): Vite build issues #10353

Merged
merged 2 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { GraphQLError } from 'graphql';
import * as url from 'url';
import { v4 as uuid } from 'uuid';
import { Buffer } from 'buffer';
import { ProviderOptions } from '../../types';
import { ProviderOptions } from '../../types/Provider';
import {
Logger,
Credentials,
Expand All @@ -30,7 +30,7 @@ import {
import Cache from '@aws-amplify/cache';
import Auth, { GRAPHQL_AUTH_MODE } from '@aws-amplify/auth';
import { AbstractPubSubProvider } from '../PubSubProvider';
import { CONNECTION_STATE_CHANGE, CONTROL_MSG } from '../../index';
import { CONTROL_MSG } from '../../types/PubSub';

import {
AMPLIFY_SYMBOL,
Expand All @@ -44,6 +44,7 @@ import {
SOCKET_STATUS,
START_ACK_TIMEOUT,
SUBSCRIPTION_STATUS,
CONNECTION_STATE_CHANGE,
} from '../constants';
import {
ConnectionStateMonitor,
Expand Down
3 changes: 2 additions & 1 deletion packages/pubsub/src/Providers/MqttOverWSProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { v4 as uuid } from 'uuid';
import Observable from 'zen-observable-ts';

import { AbstractPubSubProvider } from './PubSubProvider';
import { ProviderOptions, SubscriptionObserver } from '../types';
import { SubscriptionObserver } from '../types/PubSub';
import { ProviderOptions } from '../types/Provider';
import { ConsoleLogger as Logger, Hub } from '@aws-amplify/core';
import {
ConnectionStateMonitor,
Expand Down
2 changes: 1 addition & 1 deletion packages/pubsub/src/Providers/PubSubProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* and limitations under the License.
*/
import Observable from 'zen-observable-ts';
import { PubSubProvider, ProviderOptions } from '../types';
import { PubSubProvider, ProviderOptions } from '../types/Provider';
import { ConsoleLogger as Logger } from '@aws-amplify/core';

const logger = new Logger('AbstractPubSubProvider');
Expand Down
12 changes: 2 additions & 10 deletions packages/pubsub/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,11 @@ import { PubSub } from './PubSub';

export * from './Providers';

enum CONTROL_MSG {
CONNECTION_CLOSED = 'Connection closed',
CONNECTION_FAILED = 'Connection failed',
REALTIME_SUBSCRIPTION_INIT_ERROR = 'AppSync Realtime subscription init error',
SUBSCRIPTION_ACK = 'Subscription ack',
TIMEOUT_DISCONNECT = 'Timeout disconnect',
}

export { CONNECTION_STATE_CHANGE } from './Providers/constants';

export { ConnectionState } from './types';
export { ConnectionState, CONTROL_MSG } from './types';

export { PubSub, CONTROL_MSG };
export { PubSub };

/**
* @deprecated use named import
Expand Down
14 changes: 13 additions & 1 deletion packages/pubsub/src/types/Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@
* and limitations under the License.
*/
import Observable from 'zen-observable-ts';
import { ProviderOptions } from './PubSub';

export interface PubSubOptions {
[key: string]: any;
}

export interface ProviderOptions {
[key: string]: any;
}

/**
* @deprecated Migrated to ProviderOptions
*/
export type ProvidertOptions = ProviderOptions;

export interface PubSubProvider {
// configure your provider
Expand Down
55 changes: 47 additions & 8 deletions packages/pubsub/src/types/PubSub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,54 @@
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
export interface PubSubOptions {
[key: string]: any;

export interface SubscriptionObserver<T> {
closed: boolean;
next(value: T): void;
error(errorValue: any): void;
complete(): void;
}

export interface ProviderOptions {
[key: string]: any;
export enum CONTROL_MSG {
CONNECTION_CLOSED = 'Connection closed',
CONNECTION_FAILED = 'Connection failed',
REALTIME_SUBSCRIPTION_INIT_ERROR = 'AppSync Realtime subscription init error',
SUBSCRIPTION_ACK = 'Subscription ack',
TIMEOUT_DISCONNECT = 'Timeout disconnect',
}

/**
* @deprecated Migrated to ProviderOptions
*/
export type ProvidertOptions = ProviderOptions;
/** @enum {string} */
export enum ConnectionState {
/*
* The connection is alive and healthy
*/
Connected = 'Connected',
/*
* The connection is alive, but the connection is offline
*/
ConnectedPendingNetwork = 'ConnectedPendingNetwork',
/*
* The connection has been disconnected while in use
*/
ConnectionDisrupted = 'ConnectionDisrupted',
/*
* The connection has been disconnected and the network is offline
*/
ConnectionDisruptedPendingNetwork = 'ConnectionDisruptedPendingNetwork',
/*
* The connection is in the process of connecting
*/
Connecting = 'Connecting',
/*
* The connection is not in use and is being disconnected
*/
ConnectedPendingDisconnect = 'ConnectedPendingDisconnect',
/*
* The connection is not in use and has been disconnected
*/
Disconnected = 'Disconnected',
/*
* The connection is alive, but a keep alive message has been missed
*/
ConnectedPendingKeepAlive = 'ConnectedPendingKeepAlive',
}
43 changes: 0 additions & 43 deletions packages/pubsub/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,3 @@
*/
export * from './Provider';
export * from './PubSub';

export interface SubscriptionObserver<T> {
closed: boolean;
next(value: T): void;
error(errorValue: any): void;
complete(): void;
}

/** @enum {string} */
export enum ConnectionState {
/*
* The connection is alive and healthy
*/
Connected = 'Connected',
/*
* The connection is alive, but the connection is offline
*/
ConnectedPendingNetwork = 'ConnectedPendingNetwork',
/*
* The connection has been disconnected while in use
*/
ConnectionDisrupted = 'ConnectionDisrupted',
/*
* The connection has been disconnected and the network is offline
*/
ConnectionDisruptedPendingNetwork = 'ConnectionDisruptedPendingNetwork',
/*
* The connection is in the process of connecting
*/
Connecting = 'Connecting',
/*
* The connection is not in use and is being disconnected
*/
ConnectedPendingDisconnect = 'ConnectedPendingDisconnect',
/*
* The connection is not in use and has been disconnected
*/
Disconnected = 'Disconnected',
/*
* The connection is alive, but a keep alive message has been missed
*/
ConnectedPendingKeepAlive = 'ConnectedPendingKeepAlive',
}
2 changes: 1 addition & 1 deletion packages/pubsub/src/utils/ConnectionStateMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import { Reachability } from '@aws-amplify/core';
import Observable, { ZenObservable } from 'zen-observable-ts';
import { ConnectionState } from '../index';
import { ConnectionState } from '../types/PubSub';
import { ReachabilityMonitor } from './ReachabilityMonitor';

// Internal types for tracking different connection states
Expand Down