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

Apply tslint rules to all files #510

Merged
merged 3 commits into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion libraries/botbuilder-ai/src/luisRecognizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export interface LuisPredictionOptions {
* @remarks
* This class is used to recognize intents and extract entities from incoming messages.
* See this class in action [in this sample application](https://github.com/Microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/12.nlp-with-luis).

*
* This component can be used within your bots logic by calling [recognize()](#recognize).
*/
export class LuisRecognizer {
Expand Down
2 changes: 1 addition & 1 deletion libraries/botbuilder-azure/src/blobStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface BlobStorageSettings {
*/
storageAccountOrConnectionString: string;

/**
/**
* The storage access key.
*/
storageAccessKey?: string;
Expand Down
5 changes: 4 additions & 1 deletion libraries/botbuilder-azure/src/cosmosDbStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ export class CosmosDbStorage implements Storage {
* @param settings Setting to configure the provider.
* @param connectionPolicyConfigurator (Optional) An optional delegate that accepts a ConnectionPolicy for customizing policies. More information at http://azure.github.io/azure-documentdb-node/global.html#ConnectionPolicy
*/
public constructor(settings: CosmosDbStorageSettings, connectionPolicyConfigurator: (policy: DocumentBase.ConnectionPolicy) => void = null) {
public constructor(
settings: CosmosDbStorageSettings,
connectionPolicyConfigurator: (policy: DocumentBase.ConnectionPolicy) => void = null
) {
if (!settings) {
throw new Error('The settings parameter is required.');
}
Expand Down
23 changes: 12 additions & 11 deletions libraries/botbuilder-core/src/autoSaveStateMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import { TurnContext } from './turnContext';
* Middleware that will automatically save any state changes at the end of the turn.
*
* @remarks
* The `AutoSaveStateMiddleware` class should be added towards the top of your bot's middleware
* stack, before any other components that use state. Any `BotState` plugins passed to the
* The `AutoSaveStateMiddleware` class should be added towards the top of your bot's middleware
* stack, before any other components that use state. Any `BotState` plugins passed to the
* constructor will have their `BotState.saveChanges()` method called upon successful completion
* of the turn.
*
* of the turn.
*
* This example shows boilerplate code for reading and writing conversation and user state within
* a bot:
*
Expand All @@ -37,13 +37,18 @@ import { TurnContext } from './turnContext';
* const user = await userState.load(turnContext);
*
* // ... route activity ...
* // ...make changes to state objects...
* // ... no need to call userState.saveChanges() or conversationState.saveChanges() anymore!
* // ...make changes to state objects...
* // ... no need to call userState.saveChanges() or conversationState.saveChanges() anymore!
* });
* });
* ```
*/
export class AutoSaveStateMiddleware implements Middleware {

/**
* Set of `BotState` plugins being automatically saved.
*/
public botStateSet: BotStateSet;
/**
* Creates a new AutoSaveStateiMiddleware instance.
* @param botStates One or more BotState plugins to automatically save at the end of the turn.
Expand All @@ -53,11 +58,6 @@ export class AutoSaveStateMiddleware implements Middleware {
BotStateSet.prototype.add.apply(this.botStateSet, botStates);
}

/**
* Set of `BotState` plugins being automatically saved.
*/
public botStateSet: BotStateSet;

public async onTurn(context: TurnContext, next: () => Promise<void>): Promise<void> {
await next();
await this.botStateSet.saveAllChanges(context, true);
Expand All @@ -69,6 +69,7 @@ export class AutoSaveStateMiddleware implements Middleware {
*/
public add(...botStates: BotState[]): this {
BotStateSet.prototype.add.apply(this.botStateSet, botStates);

return this;
}

Expand Down
20 changes: 10 additions & 10 deletions libraries/botbuilder-core/src/botAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ import { TurnContext } from './turnContext';

/**
* Abstract base class for all adapter plugins.
*
*
* @remarks
* Adapters manage the communication between the bot and a user over a specific channel, or set
* Adapters manage the communication between the bot and a user over a specific channel, or set
* of channels.
*/
export abstract class BotAdapter {
private middleware: MiddlewareSet = new MiddlewareSet();
private turnError: (context: TurnContext, error: Error) => Promise<void>;

/**
* Sends a set of activities to the user.
*
* Sends a set of activities to the user.
*
* @remarks
* An array of responses from the server will be returned.
* @param context Context for the current turn of conversation with the user.
Expand Down Expand Up @@ -79,14 +79,14 @@ export abstract class BotAdapter {

/**
* Executes the adapters middleware chain.
*
*
* @remarks
* This should be be called by the parent class to run the adapters middleware chain. The
* This should be be called by the parent class to run the adapters middleware chain. The
* `next()` handler passed to the method will be called at the end of the chain.
*
* While the context object is passed in from the caller is created by the caller, what gets
* passed to the `next()` handler is a wrapped version of the context which will automatically
* be revoked upon completion of the turn. This causes the bots logic to throw an error if it
*
* While the context object is passed in from the caller is created by the caller, what gets
* passed to the `next()` handler is a wrapped version of the context which will automatically
* be revoked upon completion of the turn. This causes the bots logic to throw an error if it
* tries to use the context object after the turn completes.
* @param context Context for the current turn of conversation with the user.
* @param next Function to call at the end of the middleware chain.
Expand Down
24 changes: 12 additions & 12 deletions libraries/botbuilder-core/src/botState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@ export interface CachedBotState {
* Base class for the frameworks state persistance scopes.
*
* @remarks
* This class will read and write state, to a provided storage provider, for each turn of
* conversation with a user. Derived classes, like `ConversationState` and `UserState`, provide a
* This class will read and write state, to a provided storage provider, for each turn of
* conversation with a user. Derived classes, like `ConversationState` and `UserState`, provide a
* `StorageKeyFactory` which is used to determine the key used to persist a given storage object.
*
* The state object thats loaded will be automatically cached on the context object for the
*
* The state object thats loaded will be automatically cached on the context object for the
* lifetime of the turn and will only be written to storage if it has been modified.
*/
export class BotState implements PropertyManager {

/**
* Collection of state property accessors added through [createProperty()](#createproperty).
*/
public readonly properties: Map<string, StatePropertyAccessor> = new Map();
private stateKey: symbol = Symbol('state');

/**
Expand All @@ -47,12 +52,7 @@ export class BotState implements PropertyManager {
constructor(protected storage: Storage, protected storageKey: StorageKeyFactory) { }

/**
* Collection of state property accessors added through [createProperty()](#createproperty).
*/
public readonly properties: Map<string, StatePropertyAccessor> = new Map();

/**
* Creates a new property accessor for reading and writing an individual property to the bot
* Creates a new property accessor for reading and writing an individual property to the bot
* states storage object.
* @param T (Optional) type of property to create. Defaults to `any` type.
* @param name Name of the property to add. Must be unique within the set.
Expand All @@ -71,7 +71,7 @@ export class BotState implements PropertyManager {
* @remarks
* Subsequent reads will return the cached object unless the `force` flag is passed in which
* will force the state object to be re-read.
*
*
* This method is automatically called on first access of any of created property accessors.
*
* ```JavaScript
Expand Down Expand Up @@ -135,7 +135,7 @@ export class BotState implements PropertyManager {
* Clears the current state object for a turn.
*
* @remarks
* The cleared state object will not be persisted until [saveChanges()](#savechanges) has
* The cleared state object will not be persisted until [saveChanges()](#savechanges) has
* been called.
*
* ```JavaScript
Expand Down
30 changes: 15 additions & 15 deletions libraries/botbuilder-core/src/botStatePropertyAccessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ import { BotState } from './botState';
import { TurnContext } from './turnContext';

/**
* An interface components can use to read and write individual properties to the bot's state
* An interface components can use to read and write individual properties to the bot's state
* management system.
* @param T (Optional) type of property being persisted. Defaults to `any` type.
*/
export interface StatePropertyAccessor<T = any> {
/**
* Deletes the persisted property from its backing storage object.
*
*
* @remarks
* The properties backing storage object SHOULD be loaded into memory on first access.
*
* The properties backing storage object SHOULD be loaded into memory on first access.
*
* ```JavaScript
* await myProperty.delete(context);
* ```
Expand All @@ -29,31 +29,31 @@ export interface StatePropertyAccessor<T = any> {

/**
* Reads a persisted property from its backing storage object.
*
*
* @remarks
* The properties backing storage object SHOULD be loaded into memory on first access.
*
* The properties backing storage object SHOULD be loaded into memory on first access.
*
* If the property does not currently exist on the storage object and a `defaultValue` has been
* specified, a clone of the `defaultValue` SHOULD be copied to the storage object. If a
* `defaultValue` has not been specified then a value of `undefined` SHOULD be returned.
*
*
* ```JavaScript
* const value = await myProperty.get(context, { count: 0 });
* ```
* @param context Context for the current turn of conversation with the user.
* @param defaultValue (Optional) default value to copy to the backing storage object if the property isn't found.
* @param defaultValue (Optional) default value to copy to the backing storage object if the property isn't found.
*/
get(context: TurnContext, defaultValue?: T): Promise<T|undefined>;

/**
* Assigns a new value to the properties backing storage object.
*
*
* @remarks
* The properties backing storage object SHOULD be loaded into memory on first access.
*
* Depending on the state systems implementation, an additional step may be required to
*
* Depending on the state systems implementation, an additional step may be required to
* persist the actual changes to disk.
*
*
* ```JavaScript
* await myProperty.set(context, value);
* ```
Expand All @@ -65,10 +65,10 @@ export interface StatePropertyAccessor<T = any> {

/**
* A `BotState` specific implementation of the `StatePropertyAccessor` interface.
*
*
* @remarks
* Properties can be defined for a given `BotState` instance using `createProperty()`.
*
*
* ```JavaScript
* const dialogStateProperty = ConversationState.createProperty('dialogState');
* const dialogs = new DialogSet(dialogStateProperty);
Expand Down
12 changes: 7 additions & 5 deletions libraries/botbuilder-core/src/botStateSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import { TurnContext } from './turnContext';
*/
export class BotStateSet {

/**
* Array of the sets `BotState` plugins.
*/
public readonly botStates: BotState[] = [];

/**
* Creates a new BotStateSet instance.
* @param botStates One or more BotState plugins to register.
Expand All @@ -22,11 +27,6 @@ export class BotStateSet {
BotStateSet.prototype.add.apply(this, botStates);
}

/**
* Array of the sets `BotState` plugins.
*/
public readonly botStates: BotState[] = [];

/**
* Registers One or more `BotState` plugins with the set.
* @param botStates One or more BotState plugins to register.
Expand Down Expand Up @@ -59,6 +59,7 @@ export class BotStateSet {
const promises: Promise<any>[] = this.botStates.map((botstate: BotState) => botstate.load(context, force));

await Promise.all(promises);

return;
}

Expand All @@ -78,6 +79,7 @@ export class BotStateSet {
const promises: Promise<void>[] = this.botStates.map((botstate: BotState) => botstate.saveChanges(context, force));

await Promise.all(promises);

return;
}
}
24 changes: 12 additions & 12 deletions libraries/botbuilder-core/src/cardFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ import {
* @remarks
* All of these functions return an `Attachment` which can be added to an `Activity` directly or
* passed as input to a `MessageFactory` method.
*
*
* The following example shows sending a message containing a single hero card:
*
*
* ```javascript
* const { MessageFactory, CardFactory } = require('botbuilder');
*
*
* const card = CardFactory.heroCard(
* 'White T-Shirt',
* ['https://example.com/whiteShirt.jpg'],
Expand All @@ -60,7 +60,7 @@ export class CardFactory {
};

/**
* Returns an attachment for an adaptive card.
* Returns an attachment for an adaptive card.
*
* @remarks
* Adaptive Cards are a new way for bots to send interactive and immersive card content to
Expand Down Expand Up @@ -204,9 +204,9 @@ export class CardFactory {

/**
* Returns an attachment for a signin card.
*
*
* @remarks
* For channels that don't natively support signin cards an alternative message will be
* For channels that don't natively support signin cards an alternative message will be
* rendered.
* @param title Title of the cards signin button.
* @param url The link to the signin page the user needs to visit.
Expand All @@ -220,12 +220,12 @@ export class CardFactory {
}

/**
* Returns an attachment for a thumbnail card.
*
* Returns an attachment for a thumbnail card.
*
* @remarks
* Thumbnail cards are similar to [hero cards](#herocard) but instead of a full width image,
* they're typically rendered with a smaller thumbnail version of the image on either side
* and the text will be rendered in column next to the image. Any buttons will typically
* they're typically rendered with a smaller thumbnail version of the image on either side
* and the text will be rendered in column next to the image. Any buttons will typically
* show up under the card.
* @param title The cards title.
* @param text (Optional) text field for the card.
Expand Down Expand Up @@ -286,9 +286,9 @@ export class CardFactory {

/**
* Returns a properly formatted array of actions.
*
*
* @remarks
* Supports converting strings to `messageBack` actions (note: using 'imBack' for now as
* Supports converting strings to `messageBack` actions (note: using 'imBack' for now as
* 'messageBack' doesn't work properly in emulator.)
* @param actions Array of card actions or strings. Strings will be converted to `messageBack` actions.
*/
Expand Down
1 change: 0 additions & 1 deletion libraries/botbuilder-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ export * from './testAdapter';
export * from './transcriptLogger';
export * from './turnContext';
export * from './userState';

2 changes: 1 addition & 1 deletion libraries/botbuilder-core/src/memoryStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Storage, StoreItems } from './storage';
* - Anything written to the store will be forgotten when the process exits.
* - Objects that are read and written to the store are cloned to properly simulate network based
* storage providers.
* - Cloned objects are serialized using `JSON.stringify()` to catch any possible serialization
* - Cloned objects are serialized using `JSON.stringify()` to catch any possible serialization
* related issues that might occur when using a network based storage provider.
*
* ```JavaScript
Expand Down
4 changes: 2 additions & 2 deletions libraries/botbuilder-core/src/memoryTranscriptStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { PagedResult, TranscriptInfo, TranscriptStore } from './transcriptLogger

/**
* The memory transcript store stores transcripts in volatile memory in a Map.
*
*
* @remarks
* Because this uses an unbounded volatile dictionary this should only be used for unit tests or
* Because this uses an unbounded volatile dictionary this should only be used for unit tests or
* non-production environments.
*/
export class MemoryTranscriptStore implements TranscriptStore {
Expand Down
Loading